{"version":3,"file":"createPreElement.js","names":[],"sources":["../../src/utils/createPreElement.ts"],"sourcesContent":["import type { Element as HASTElement, Properties } from 'hast';\n\nimport type { PrePropertiesConfig } from '../types';\nimport { createHastElement } from './hast_utils';\n\nexport function createPreElement(options: PrePropertiesConfig): HASTElement {\n  return createHastElement({\n    tagName: 'pre',\n    properties: createPreWrapperProperties(options),\n  });\n}\n\nexport function createPreWrapperProperties({\n  diffIndicators,\n  disableBackground,\n  disableLineNumbers,\n  overflow,\n  split,\n  totalLines,\n  type,\n  customProperties,\n}: PrePropertiesConfig): Properties {\n  const properties: Properties = {\n    // NOTE: We always apply custom properties first so the important\n    // properties cannot be overridden\n    ...customProperties,\n    'data-diff': type === 'diff' ? '' : undefined,\n    'data-file': type === 'file' ? '' : undefined,\n    'data-diff-type':\n      type === 'diff' ? (split ? 'split' : 'single') : undefined,\n    'data-overflow': overflow,\n    'data-disable-line-numbers': disableLineNumbers ? '' : undefined,\n    'data-background': !disableBackground ? '' : undefined,\n    'data-indicators':\n      diffIndicators === 'bars' || diffIndicators === 'classic'\n        ? diffIndicators\n        : undefined,\n    tabIndex: 0,\n    style: `--diffs-min-number-column-width-default:${`${totalLines}`.length}ch;`,\n  };\n\n  return properties;\n}\n"],"mappings":";;;AAKA,SAAgB,iBAAiB,SAA2C;AAC1E,QAAO,kBAAkB;EACvB,SAAS;EACT,YAAY,2BAA2B,QAAQ;EAChD,CAAC;;AAGJ,SAAgB,2BAA2B,EACzC,gBACA,mBACA,oBACA,UACA,OACA,YACA,MACA,oBACkC;AAoBlC,QAnB+B;EAG7B,GAAG;EACH,aAAa,SAAS,SAAS,KAAK;EACpC,aAAa,SAAS,SAAS,KAAK;EACpC,kBACE,SAAS,SAAU,QAAQ,UAAU,WAAY;EACnD,iBAAiB;EACjB,6BAA6B,qBAAqB,KAAK;EACvD,mBAAmB,CAAC,oBAAoB,KAAK;EAC7C,mBACE,mBAAmB,UAAU,mBAAmB,YAC5C,iBACA;EACN,UAAU;EACV,OAAO,2CAA2C,GAAG,aAAa,OAAO;EAC1E"}