@pierre/diffs 1.2.8 → 1.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/components/CodeView.d.ts.map +1 -1
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/highlighter/shared_highlighter.js +3 -29
  4. package/dist/highlighter/shared_highlighter.js.map +1 -1
  5. package/dist/highlighter/themes/attachResolvedThemes.js +4 -3
  6. package/dist/highlighter/themes/attachResolvedThemes.js.map +1 -1
  7. package/dist/highlighter/themes/cleanUpResolvedThemes.js +3 -2
  8. package/dist/highlighter/themes/cleanUpResolvedThemes.js.map +1 -1
  9. package/dist/highlighter/themes/constants.d.ts +1 -7
  10. package/dist/highlighter/themes/constants.d.ts.map +1 -1
  11. package/dist/highlighter/themes/constants.js +1 -4
  12. package/dist/highlighter/themes/constants.js.map +1 -1
  13. package/dist/highlighter/themes/getResolvedOrResolveTheme.js +2 -2
  14. package/dist/highlighter/themes/getResolvedOrResolveTheme.js.map +1 -1
  15. package/dist/highlighter/themes/getResolvedThemes.js +2 -8
  16. package/dist/highlighter/themes/getResolvedThemes.js.map +1 -1
  17. package/dist/highlighter/themes/hasResolvedThemes.js +2 -3
  18. package/dist/highlighter/themes/hasResolvedThemes.js.map +1 -1
  19. package/dist/highlighter/themes/registerCustomCSSVariableTheme.js +1 -1
  20. package/dist/highlighter/themes/registerCustomTheme.d.ts +5 -3
  21. package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
  22. package/dist/highlighter/themes/registerCustomTheme.js +15 -5
  23. package/dist/highlighter/themes/registerCustomTheme.js.map +1 -1
  24. package/dist/highlighter/themes/resolveTheme.js +6 -27
  25. package/dist/highlighter/themes/resolveTheme.js.map +1 -1
  26. package/dist/highlighter/themes/resolveThemes.js +5 -12
  27. package/dist/highlighter/themes/resolveThemes.js.map +1 -1
  28. package/dist/highlighter/themes/themeResolution.d.ts +8 -0
  29. package/dist/highlighter/themes/themeResolution.d.ts.map +1 -0
  30. package/dist/highlighter/themes/themeResolution.js +22 -0
  31. package/dist/highlighter/themes/themeResolution.js.map +1 -0
  32. package/dist/highlighter/themes/themeResolver.d.ts +8 -0
  33. package/dist/highlighter/themes/themeResolver.d.ts.map +1 -0
  34. package/dist/highlighter/themes/themeResolver.js +8 -0
  35. package/dist/highlighter/themes/themeResolver.js.map +1 -0
  36. package/dist/index.d.ts +4 -4
  37. package/dist/index.js +3 -3
  38. package/dist/react/index.d.ts +2 -2
  39. package/dist/react/jsx.d.ts.map +1 -1
  40. package/dist/ssr/index.d.ts +2 -2
  41. package/dist/types.d.ts +3 -3
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/utils/getHighlighterThemeStyles.js +16 -12
  44. package/dist/utils/getHighlighterThemeStyles.js.map +1 -1
  45. package/dist/utils/parsePatchFiles.js +93 -4
  46. package/dist/utils/parsePatchFiles.js.map +1 -1
  47. package/dist/worker/{wasm-BaDzIkIn.js → wasm-qE0LgnY3.js} +2 -2
  48. package/dist/worker/{wasm-BaDzIkIn.js.map → wasm-qE0LgnY3.js.map} +1 -1
  49. package/dist/worker/worker-portable.js +1005 -277
  50. package/dist/worker/worker-portable.js.map +1 -1
  51. package/dist/worker/worker.js +23 -15
  52. package/dist/worker/worker.js.map +1 -1
  53. package/package.json +4 -3
@@ -10,42 +10,34 @@ var __export = (all$1) => {
10
10
  };
11
11
 
12
12
  //#endregion
13
- //#region ../../node_modules/.bun/shiki@4.0.2/node_modules/shiki/dist/chunk-CtajNgzt.mjs
13
+ //#region ../../node_modules/.bun/shiki@4.2.0/node_modules/shiki/dist/chunk-BBjsoOtd.mjs
14
14
  var __defProp$1 = Object.defineProperty;
15
15
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
16
  var __getOwnPropNames = Object.getOwnPropertyNames;
17
17
  var __hasOwnProp = Object.prototype.hasOwnProperty;
18
18
  var __exportAll = (all$1, no_symbols) => {
19
19
  let target = {};
20
- for (var name in all$1) {
21
- __defProp$1(target, name, {
22
- get: all$1[name],
23
- enumerable: true
24
- });
25
- }
26
- if (!no_symbols) {
27
- __defProp$1(target, Symbol.toStringTag, { value: "Module" });
28
- }
20
+ for (var name in all$1) __defProp$1(target, name, {
21
+ get: all$1[name],
22
+ enumerable: true
23
+ });
24
+ if (!no_symbols) __defProp$1(target, Symbol.toStringTag, { value: "Module" });
29
25
  return target;
30
26
  };
31
27
  var __copyProps = (to, from, except, desc) => {
32
- if (from && typeof from === "object" || typeof from === "function") {
33
- for (var keys = __getOwnPropNames(from), i$2 = 0, n = keys.length, key$1; i$2 < n; i$2++) {
34
- key$1 = keys[i$2];
35
- if (!__hasOwnProp.call(to, key$1) && key$1 !== except) {
36
- __defProp$1(to, key$1, {
37
- get: ((k$2) => from[k$2]).bind(null, key$1),
38
- enumerable: !(desc = __getOwnPropDesc(from, key$1)) || desc.enumerable
39
- });
40
- }
41
- }
28
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i$2 = 0, n = keys.length, key$1; i$2 < n; i$2++) {
29
+ key$1 = keys[i$2];
30
+ if (!__hasOwnProp.call(to, key$1) && key$1 !== except) __defProp$1(to, key$1, {
31
+ get: ((k$2) => from[k$2]).bind(null, key$1),
32
+ enumerable: !(desc = __getOwnPropDesc(from, key$1)) || desc.enumerable
33
+ });
42
34
  }
43
35
  return to;
44
36
  };
45
37
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
46
38
 
47
39
  //#endregion
48
- //#region ../../node_modules/.bun/@shikijs+types@4.0.2/node_modules/@shikijs/types/dist/index.mjs
40
+ //#region ../../node_modules/.bun/@shikijs+types@4.2.0/node_modules/@shikijs/types/dist/index.mjs
49
41
  var ShikiError$1 = class extends Error {
50
42
  constructor(message) {
51
43
  super(message);
@@ -2911,7 +2903,7 @@ var Registry = class {
2911
2903
  var INITIAL = StateStackImpl.NULL;
2912
2904
 
2913
2905
  //#endregion
2914
- //#region ../../node_modules/.bun/@shikijs+primitive@4.0.2/node_modules/@shikijs/primitive/dist/index.mjs
2906
+ //#region ../../node_modules/.bun/@shikijs+primitive@4.2.0/node_modules/@shikijs/primitive/dist/index.mjs
2915
2907
  function resolveColorReplacements(theme, options) {
2916
2908
  const replacements = typeof theme === "string" ? {} : { ...theme.colorReplacements };
2917
2909
  const themeName = typeof theme === "string" ? theme : theme.name;
@@ -2923,8 +2915,8 @@ function applyColorReplacements(color, replacements) {
2923
2915
  if (!color) return color;
2924
2916
  return replacements?.[color?.toLowerCase()] || color;
2925
2917
  }
2926
- function toArray(x$1) {
2927
- return Array.isArray(x$1) ? x$1 : [x$1];
2918
+ function toArray(x$2) {
2919
+ return Array.isArray(x$2) ? x$2 : [x$2];
2928
2920
  }
2929
2921
  /**
2930
2922
  * Normalize a getter to a promise.
@@ -2985,9 +2977,10 @@ function isSpecialTheme(theme) {
2985
2977
  * // => [['hello\n', 0], ['world', 6]]
2986
2978
  * ```
2987
2979
  */
2980
+ const RE_NEWLINE = /(\r?\n)/g;
2988
2981
  function splitLines$1(code, preserveEnding = false) {
2989
2982
  if (code.length === 0) return [["", 0]];
2990
- const parts = code.split(/(\r?\n)/g);
2983
+ const parts = code.split(RE_NEWLINE);
2991
2984
  let index = 0;
2992
2985
  const lines = [];
2993
2986
  for (let i$2 = 0; i$2 < parts.length; i$2 += 2) {
@@ -3101,7 +3094,7 @@ function normalizeTheme(rawTheme) {
3101
3094
  * Resolve
3102
3095
  */
3103
3096
  async function resolveLangs(langs) {
3104
- return Array.from(new Set((await Promise.all(langs.filter((l$2) => !isSpecialLang(l$2)).map(async (lang) => await normalizeGetter(lang).then((r$3) => Array.isArray(r$3) ? r$3 : [r$3])))).flat()));
3097
+ return [...new Set((await Promise.all(langs.filter((l$2) => !isSpecialLang(l$2)).map(async (lang) => await normalizeGetter(lang).then((r$3) => Array.isArray(r$3) ? r$3 : [r$3])))).flat())];
3105
3098
  }
3106
3099
  async function resolveThemes(themes) {
3107
3100
  return (await Promise.all(themes.map(async (theme) => isSpecialTheme(theme) ? null : normalizeTheme(await normalizeGetter(theme))))).filter((i$2) => !!i$2);
@@ -3112,13 +3105,17 @@ function resolveLangAlias(name, alias) {
3112
3105
  const resolved = new Set([name]);
3113
3106
  while (alias[name]) {
3114
3107
  name = alias[name];
3115
- if (resolved.has(name)) throw new ShikiError$1(`Circular alias \`${Array.from(resolved).join(" -> ")} -> ${name}\``);
3108
+ if (resolved.has(name)) throw new ShikiError$1(`Circular alias \`${[...resolved].join(" -> ")} -> ${name}\``);
3116
3109
  resolved.add(name);
3117
3110
  }
3118
3111
  }
3119
3112
  return name;
3120
3113
  }
3121
3114
  var Registry$1 = class extends Registry {
3115
+ _resolver;
3116
+ _themes;
3117
+ _langs;
3118
+ _alias;
3122
3119
  _resolvedThemes = /* @__PURE__ */ new Map();
3123
3120
  _resolvedGrammars = /* @__PURE__ */ new Map();
3124
3121
  _langMap = /* @__PURE__ */ new Map();
@@ -3197,7 +3194,7 @@ var Registry$1 = class extends Registry {
3197
3194
  }
3198
3195
  loadLanguages(langs) {
3199
3196
  for (const lang of langs) this.resolveEmbeddedLanguages(lang);
3200
- const langsGraphArray = Array.from(this._langGraph.entries());
3197
+ const langsGraphArray = [...this._langGraph.entries()];
3201
3198
  const missingLangs = langsGraphArray.filter(([_$2, lang]) => !lang);
3202
3199
  if (missingLangs.length) {
3203
3200
  const dependents = langsGraphArray.filter(([_$2, lang]) => {
@@ -3463,6 +3460,8 @@ function getGrammarStack(state, theme) {
3463
3460
  if (!(state instanceof GrammarState)) throw new ShikiError$1("Invalid grammar state");
3464
3461
  return state.getInternalStack(theme);
3465
3462
  }
3463
+ const RE_COMMA = /,/;
3464
+ const RE_SPACE = / /;
3466
3465
  /**
3467
3466
  * Code to tokens, with a simple theme.
3468
3467
  */
@@ -3553,7 +3552,7 @@ function _tokenizeWithTheme(code, grammar, theme, colorMap, options) {
3553
3552
  let selectors;
3554
3553
  switch (typeof setting.scope) {
3555
3554
  case "string":
3556
- selectors = setting.scope.split(/,/).map((scope) => scope.trim());
3555
+ selectors = setting.scope.split(RE_COMMA).map((scope) => scope.trim());
3557
3556
  break;
3558
3557
  case "object":
3559
3558
  selectors = setting.scope;
@@ -3562,7 +3561,7 @@ function _tokenizeWithTheme(code, grammar, theme, colorMap, options) {
3562
3561
  }
3563
3562
  themeSettingsSelectors.push({
3564
3563
  settings: setting,
3565
- selectors: selectors.map((selector) => selector.split(/ /))
3564
+ selectors: selectors.map((selector) => selector.split(RE_SPACE))
3566
3565
  });
3567
3566
  }
3568
3567
  token$1.explanation = [];
@@ -3607,7 +3606,7 @@ function matchesOne(selector, scope) {
3607
3606
  return selector === scope || scope.substring(0, selector.length) === selector && scope[selector.length] === ".";
3608
3607
  }
3609
3608
  function matches(selectors, scope, parentScopes) {
3610
- if (!matchesOne(selectors[selectors.length - 1], scope)) return false;
3609
+ if (!matchesOne(selectors.at(-1), scope)) return false;
3611
3610
  let selectorParentIndex = selectors.length - 2;
3612
3611
  let parentIndex = parentScopes.length - 1;
3613
3612
  while (selectorParentIndex >= 0 && parentIndex >= 0) {
@@ -6523,7 +6522,7 @@ function serializeAttributes(state, properties) {
6523
6522
  */
6524
6523
  function serializeAttribute(state, key$1, value) {
6525
6524
  const info = find(state.schema, key$1);
6526
- const x$1 = state.settings.allowParseErrors && state.schema.space === "html" ? 0 : 1;
6525
+ const x$2 = state.settings.allowParseErrors && state.schema.space === "html" ? 0 : 1;
6527
6526
  const y$2 = state.settings.allowDangerousCharacters ? 0 : 1;
6528
6527
  let quote = state.quote;
6529
6528
  /** @type {string | undefined} */
@@ -6536,14 +6535,14 @@ function serializeAttribute(state, key$1, value) {
6536
6535
  if (value === null || value === undefined || value === false || typeof value === "number" && Number.isNaN(value)) {
6537
6536
  return "";
6538
6537
  }
6539
- const name = stringifyEntities(info.attribute, Object.assign({}, state.settings.characterReferences, { subset: constants.name[x$1][y$2] }));
6538
+ const name = stringifyEntities(info.attribute, Object.assign({}, state.settings.characterReferences, { subset: constants.name[x$2][y$2] }));
6540
6539
  if (value === true) return name;
6541
6540
  value = Array.isArray(value) ? (info.commaSeparated ? stringify$1 : stringify$2)(value, { padLeft: !state.settings.tightCommaSeparatedLists }) : String(value);
6542
6541
  if (state.settings.collapseEmptyAttributes && !value) return name;
6543
6542
  if (state.settings.preferUnquoted) {
6544
6543
  result = stringifyEntities(value, Object.assign({}, state.settings.characterReferences, {
6545
6544
  attribute: true,
6546
- subset: constants.unquoted[x$1][y$2]
6545
+ subset: constants.unquoted[x$2][y$2]
6547
6546
  }));
6548
6547
  }
6549
6548
  if (result !== value) {
@@ -6551,7 +6550,7 @@ function serializeAttribute(state, key$1, value) {
6551
6550
  quote = state.alternative;
6552
6551
  }
6553
6552
  result = quote + stringifyEntities(value, Object.assign({}, state.settings.characterReferences, {
6554
- subset: (quote === "'" ? constants.single : constants.double)[x$1][y$2],
6553
+ subset: (quote === "'" ? constants.single : constants.double)[x$2][y$2],
6555
6554
  attribute: true
6556
6555
  })) + quote;
6557
6556
  }
@@ -6759,7 +6758,8 @@ function all(parent) {
6759
6758
  }
6760
6759
 
6761
6760
  //#endregion
6762
- //#region ../../node_modules/.bun/@shikijs+core@4.0.2/node_modules/@shikijs/core/dist/index.mjs
6761
+ //#region ../../node_modules/.bun/@shikijs+core@4.2.0/node_modules/@shikijs/core/dist/index.mjs
6762
+ const RE_WHITESPACE = /\s+/g;
6763
6763
  /**
6764
6764
  * Utility to append class to a hast node
6765
6765
  *
@@ -6769,12 +6769,16 @@ function addClassToHast(node, className) {
6769
6769
  if (!className) return node;
6770
6770
  node.properties ||= {};
6771
6771
  node.properties.class ||= [];
6772
- if (typeof node.properties.class === "string") node.properties.class = node.properties.class.split(/\s+/g);
6772
+ if (typeof node.properties.class === "string") node.properties.class = node.properties.class.split(RE_WHITESPACE);
6773
6773
  if (!Array.isArray(node.properties.class)) node.properties.class = [];
6774
- const targets = Array.isArray(className) ? className : className.split(/\s+/g);
6774
+ const targets = Array.isArray(className) ? className : className.split(RE_WHITESPACE);
6775
6775
  for (const c of targets) if (c && !node.properties.class.includes(c)) node.properties.class.push(c);
6776
6776
  return node;
6777
6777
  }
6778
+ const RE_LANG_ATTR = /:?lang=["']([^"']+)["']/g;
6779
+ const RE_CODE_FENCE = /(?:```|~~~)([\w-]+)/g;
6780
+ const RE_LATEX_BEGIN = /\\begin\{([\w-]+)\}/g;
6781
+ const RE_SCRIPT_LANG = /<script\s+(?:type|lang)=["']([^"']+)["']/gi;
6778
6782
  /**
6779
6783
  * Creates a converter between index and position in a code block.
6780
6784
  *
@@ -6785,7 +6789,7 @@ function createPositionConverter(code) {
6785
6789
  function indexToPos(index) {
6786
6790
  if (index === code.length) return {
6787
6791
  line: lines.length - 1,
6788
- character: lines[lines.length - 1].length
6792
+ character: lines.at(-1).length
6789
6793
  };
6790
6794
  let character = index;
6791
6795
  let line = 0;
@@ -6832,28 +6836,27 @@ function createPositionConverter(code) {
6832
6836
  */
6833
6837
  function guessEmbeddedLanguages(code, _lang, highlighter$1) {
6834
6838
  const langs = /* @__PURE__ */ new Set();
6835
- for (const match of code.matchAll(/:?lang=["']([^"']+)["']/g)) {
6839
+ for (const match of code.matchAll(RE_LANG_ATTR)) {
6836
6840
  const lang = match[1].toLowerCase().trim();
6837
6841
  if (lang) langs.add(lang);
6838
6842
  }
6839
- for (const match of code.matchAll(/(?:```|~~~)([\w-]+)/g)) {
6843
+ for (const match of code.matchAll(RE_CODE_FENCE)) {
6840
6844
  const lang = match[1].toLowerCase().trim();
6841
6845
  if (lang) langs.add(lang);
6842
6846
  }
6843
- for (const match of code.matchAll(/\\begin\{([\w-]+)\}/g)) {
6847
+ for (const match of code.matchAll(RE_LATEX_BEGIN)) {
6844
6848
  const lang = match[1].toLowerCase().trim();
6845
6849
  if (lang) langs.add(lang);
6846
6850
  }
6847
- for (const match of code.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)) {
6851
+ for (const match of code.matchAll(RE_SCRIPT_LANG)) {
6848
6852
  const fullType = match[1].toLowerCase().trim();
6849
6853
  const lang = fullType.includes("/") ? fullType.split("/").pop() : fullType;
6850
6854
  if (lang) langs.add(lang);
6851
6855
  }
6852
- if (!highlighter$1) return Array.from(langs);
6856
+ if (!highlighter$1) return [...langs];
6853
6857
  const bundle = highlighter$1.getBundledLanguages();
6854
- return Array.from(langs).filter((l$2) => l$2 && bundle[l$2]);
6858
+ return [...langs].filter((l$2) => l$2 && bundle[l$2]);
6855
6859
  }
6856
- const DEFAULT_COLOR_LIGHT_DARK = "light-dark()";
6857
6860
  const COLOR_KEYS = ["color", "background-color"];
6858
6861
  /**
6859
6862
  * Split a token into multiple tokens by given offsets.
@@ -6882,7 +6885,7 @@ function splitToken(token$1, offsets) {
6882
6885
  * Split 2D tokens array by given breakpoints.
6883
6886
  */
6884
6887
  function splitTokens(tokens, breakpoints) {
6885
- const sorted = Array.from(breakpoints instanceof Set ? breakpoints : new Set(breakpoints)).sort((a$1, b$2) => a$1 - b$2);
6888
+ const sorted = [...breakpoints instanceof Set ? breakpoints : new Set(breakpoints)].sort((a$1, b$2) => a$1 - b$2);
6886
6889
  if (!sorted.length) return tokens;
6887
6890
  return tokens.map((line) => {
6888
6891
  return line.flatMap((token$1) => {
@@ -6908,7 +6911,7 @@ function flatTokenVariants(merged, variantsOrder, cssVariablePrefix, defaultColo
6908
6911
  styles.forEach((cur, idx) => {
6909
6912
  for (const key$1 of styleKeys) {
6910
6913
  const value = cur[key$1] || "inherit";
6911
- if (idx === 0 && defaultColor && COLOR_KEYS.includes(key$1)) if (defaultColor === DEFAULT_COLOR_LIGHT_DARK && styles.length > 1) {
6914
+ if (idx === 0 && defaultColor && COLOR_KEYS.includes(key$1)) if (defaultColor === "light-dark()" && styles.length > 1) {
6912
6915
  const lightIndex = variantsOrder.findIndex((t) => t === "light");
6913
6916
  const darkIndex = variantsOrder.findIndex((t) => t === "dark");
6914
6917
  if (lightIndex === -1 || darkIndex === -1) throw new ShikiError$1("When using `defaultColor: \"light-dark()\"`, you must provide both `light` and `dark` themes");
@@ -6990,7 +6993,7 @@ function transformerDecorations() {
6990
6993
  code(codeEl) {
6991
6994
  if (!this.options.decorations?.length) return;
6992
6995
  const ctx = getContext(this);
6993
- const lines = Array.from(codeEl.children).filter((i$2) => i$2.type === "element" && i$2.tagName === "span");
6996
+ const lines = [...codeEl.children].filter((i$2) => i$2.type === "element" && i$2.tagName === "span");
6994
6997
  if (lines.length !== ctx.converter.lines.length) throw new ShikiError$1(`Number of lines in code element (${lines.length}) does not match the number of lines in the source (${ctx.converter.lines.length}). Failed to apply decorations.`);
6995
6998
  function applyLineSection(line, start, end, decoration) {
6996
6999
  const lineEl = lines[line];
@@ -7150,8 +7153,8 @@ function findSequence(value, position) {
7150
7153
  function parseColor(sequence) {
7151
7154
  const colorMode = sequence.shift();
7152
7155
  if (colorMode === "2") {
7153
- const rgb = sequence.splice(0, 3).map((x$1) => Number.parseInt(x$1));
7154
- if (rgb.length !== 3 || rgb.some((x$1) => Number.isNaN(x$1))) return;
7156
+ const rgb = sequence.splice(0, 3).map((x$2) => Number.parseInt(x$2));
7157
+ if (rgb.length !== 3 || rgb.some((x$2) => Number.isNaN(x$2))) return;
7155
7158
  return {
7156
7159
  type: "rgb",
7157
7160
  rgb
@@ -7299,7 +7302,7 @@ function createColorPalette(namedColorsMap = defaultNamedColorsMap) {
7299
7302
  return namedColorsMap[name];
7300
7303
  }
7301
7304
  function rgbColor(rgb) {
7302
- return `#${rgb.map((x$1) => Math.max(0, Math.min(x$1, 255)).toString(16).padStart(2, "0")).join("")}`;
7305
+ return `#${rgb.map((x$2) => Math.max(0, Math.min(x$2, 255)).toString(16).padStart(2, "0")).join("")}`;
7303
7306
  }
7304
7307
  let colorTable;
7305
7308
  function getColorTable() {
@@ -7339,6 +7342,8 @@ function createColorPalette(namedColorsMap = defaultNamedColorsMap) {
7339
7342
  }
7340
7343
  return { value };
7341
7344
  }
7345
+ const RE_HEX_COLOR = /#([0-9a-f]{3,8})/i;
7346
+ const RE_CSS_VAR_ANSI = /var\((--[\w-]+-ansi-[\w-]+)\)/;
7342
7347
  /**
7343
7348
  * Default ANSI palette (VSCode compatible fallbacks)
7344
7349
  * Used when the theme does not define terminal.ansi* colors.
@@ -7400,7 +7405,7 @@ function tokenizeAnsiWithTheme(theme, fileContents, options) {
7400
7405
  * Adds 50% alpha to a hex color string or the "-dim" postfix to a CSS variable
7401
7406
  */
7402
7407
  function dimColor(color) {
7403
- const hexMatch = color.match(/#([0-9a-f]{3,8})/i);
7408
+ const hexMatch = color.match(RE_HEX_COLOR);
7404
7409
  if (hexMatch) {
7405
7410
  const hex = hexMatch[1];
7406
7411
  if (hex.length === 8) {
@@ -7420,7 +7425,7 @@ function dimColor(color) {
7420
7425
  return `#${r$3}${r$3}${g}${g}${b$2}${b$2}80`;
7421
7426
  }
7422
7427
  }
7423
- const cssVarMatch = color.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);
7428
+ const cssVarMatch = color.match(RE_CSS_VAR_ANSI);
7424
7429
  if (cssVarMatch) return `var(${cssVarMatch[1]}-dim)`;
7425
7430
  return color;
7426
7431
  }
@@ -7458,7 +7463,7 @@ function codeToTokens(primitive, code, options) {
7458
7463
  if (themes.length === 0) throw new ShikiError$1("`themes` option must not be empty");
7459
7464
  const themeTokens = codeToTokensWithThemes(primitive, code, options, codeToTokensBase$1);
7460
7465
  grammarState = getLastGrammarStateFromMap(themeTokens);
7461
- if (defaultColor && DEFAULT_COLOR_LIGHT_DARK !== defaultColor && !themes.find((t) => t.color === defaultColor)) throw new ShikiError$1(`\`themes\` option must contain the defaultColor key \`${defaultColor}\``);
7466
+ if (defaultColor && "light-dark()" !== defaultColor && !themes.some((t) => t.color === defaultColor)) throw new ShikiError$1(`\`themes\` option must contain the defaultColor key \`${defaultColor}\``);
7462
7467
  const themeRegs = themes.map((t) => primitive.getTheme(t.theme));
7463
7468
  const themesOrder = themes.map((t) => t.color);
7464
7469
  tokens = themeTokens.map((line) => line.map((token$1) => flatTokenVariants(token$1, themesOrder, cssVariablePrefix, defaultColor, colorsRendering)));
@@ -7491,7 +7496,7 @@ function mapThemeColors(themes, themeRegs, themeColorReplacements, cssVariablePr
7491
7496
  const value = applyColorReplacements(themeRegs[idx][property], themeColorReplacements[idx]) || "inherit";
7492
7497
  const cssVar = `${cssVariablePrefix + t.color}${property === "bg" ? "-bg" : ""}:${value}`;
7493
7498
  if (idx === 0 && defaultColor) {
7494
- if (defaultColor === DEFAULT_COLOR_LIGHT_DARK && themes.length > 1) {
7499
+ if (defaultColor === "light-dark()" && themes.length > 1) {
7495
7500
  const lightIndex = themes.findIndex((t$1) => t$1.color === "light");
7496
7501
  const darkIndex = themes.findIndex((t$1) => t$1.color === "dark");
7497
7502
  if (lightIndex === -1 || darkIndex === -1) throw new ShikiError$1("When using `defaultColor: \"light-dark()\"`, you must provide both `light` and `dark` themes");
@@ -7503,6 +7508,8 @@ function mapThemeColors(themes, themeRegs, themeColorReplacements, cssVariablePr
7503
7508
  return null;
7504
7509
  }).filter((i$2) => !!i$2).join(";");
7505
7510
  }
7511
+ const RE_WHITESPACE_ONLY = /^\s+$/;
7512
+ const RE_LEADING_TRAILING_WHITESPACE = /^(\s*)(.*?)(\s*)$/;
7506
7513
  function codeToHast(primitive, code, options, transformerContext = {
7507
7514
  meta: {},
7508
7515
  options,
@@ -7681,7 +7688,7 @@ function mergeWhitespaceTokens(tokens) {
7681
7688
  let firstOffset;
7682
7689
  line.forEach((token$1, idx) => {
7683
7690
  const couldMerge = !(token$1.fontStyle && (token$1.fontStyle & FontStyle.Underline || token$1.fontStyle & FontStyle.Strikethrough));
7684
- if (couldMerge && token$1.content.match(/^\s+$/) && line[idx + 1]) {
7691
+ if (couldMerge && RE_WHITESPACE_ONLY.test(token$1.content) && line[idx + 1]) {
7685
7692
  if (firstOffset === void 0) firstOffset = token$1.offset;
7686
7693
  carryOnContent += token$1.content;
7687
7694
  } else if (carryOnContent) {
@@ -7704,8 +7711,8 @@ function mergeWhitespaceTokens(tokens) {
7704
7711
  function splitWhitespaceTokens(tokens) {
7705
7712
  return tokens.map((line) => {
7706
7713
  return line.flatMap((token$1) => {
7707
- if (token$1.content.match(/^\s+$/)) return token$1;
7708
- const match = token$1.content.match(/^(\s*)(.*?)(\s*)$/);
7714
+ if (RE_WHITESPACE_ONLY.test(token$1.content)) return token$1;
7715
+ const match = token$1.content.match(RE_LEADING_TRAILING_WHITESPACE);
7709
7716
  if (!match) return token$1;
7710
7717
  const [, leading, content, trailing] = match;
7711
7718
  if (!leading && !trailing) return token$1;
@@ -7734,7 +7741,7 @@ function mergeAdjacentStyledTokens(tokens) {
7734
7741
  newLine.push({ ...token$1 });
7735
7742
  continue;
7736
7743
  }
7737
- const prevToken = newLine[newLine.length - 1];
7744
+ const prevToken = newLine.at(-1);
7738
7745
  const prevStyle = stringifyTokenStyle(prevToken.htmlStyle || getTokenStyleObject(prevToken));
7739
7746
  const currentStyle = stringifyTokenStyle(token$1.htmlStyle || getTokenStyleObject(token$1));
7740
7747
  const isPrevDecorated = prevToken.fontStyle && (prevToken.fontStyle & FontStyle.Underline || prevToken.fontStyle & FontStyle.Strikethrough);
@@ -8126,18 +8133,20 @@ function createCssVariablesTheme(options = {}) {
8126
8133
  }
8127
8134
 
8128
8135
  //#endregion
8129
- //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.0.2/node_modules/@shikijs/engine-javascript/dist/scanner-BFcBmQR1.mjs
8136
+ //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.2.0/node_modules/@shikijs/engine-javascript/dist/scanner-DX8LRFGE.mjs
8130
8137
  const MAX = 4294967295;
8131
8138
  var JavaScriptScanner = class {
8139
+ patterns;
8140
+ options;
8132
8141
  regexps;
8133
8142
  constructor(patterns, options = {}) {
8134
8143
  this.patterns = patterns;
8135
8144
  this.options = options;
8136
- const { forgiving = false, cache, regexConstructor } = options;
8145
+ const { forgiving = false, cache: cache$1, regexConstructor } = options;
8137
8146
  if (!regexConstructor) throw new Error("Option `regexConstructor` is not provided");
8138
8147
  this.regexps = patterns.map((p$1) => {
8139
8148
  if (typeof p$1 !== "string") return p$1;
8140
- const cached = cache?.get(p$1);
8149
+ const cached = cache$1?.get(p$1);
8141
8150
  if (cached) {
8142
8151
  if (cached instanceof RegExp) return cached;
8143
8152
  if (forgiving) return null;
@@ -8145,10 +8154,10 @@ var JavaScriptScanner = class {
8145
8154
  }
8146
8155
  try {
8147
8156
  const regex = regexConstructor(p$1);
8148
- cache?.set(p$1, regex);
8157
+ cache$1?.set(p$1, regex);
8149
8158
  return regex;
8150
8159
  } catch (e) {
8151
- cache?.set(p$1, e);
8160
+ cache$1?.set(p$1, e);
8152
8161
  if (forgiving) return null;
8153
8162
  throw e;
8154
8163
  }
@@ -8201,7 +8210,7 @@ var JavaScriptScanner = class {
8201
8210
  };
8202
8211
 
8203
8212
  //#endregion
8204
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/utils.js
8213
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/utils.js
8205
8214
  function r$2(e) {
8206
8215
  if ([...e].length !== 1) throw new Error(`Expected "${e}" to be a single code point`);
8207
8216
  return e.codePointAt(0);
@@ -8231,7 +8240,7 @@ function u(e, t) {
8231
8240
  }
8232
8241
 
8233
8242
  //#endregion
8234
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/tokenizer/tokenize.js
8243
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/tokenizer/tokenize.js
8235
8244
  const m$1 = o$1`\[\^?`, b$1 = `c.? | C(?:-.?)?|${o$1`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${o$1`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${o$1`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${o$1`o\{[^\}]*\}?`}|${o$1`\d{1,3}`}`, y$1 = /[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/, C$1 = new RegExp(o$1`
8236
8245
  \\ (?:
8237
8246
  ${b$1}
@@ -8333,7 +8342,7 @@ function F$1(e, n, t, o$2) {
8333
8342
  if (a$1 === "N" || a$1 === "R") return { token: k$1("newline", t, { negate: a$1 === "N" }) };
8334
8343
  if (a$1 === "O") return { token: k$1("any", t) };
8335
8344
  if (a$1 === "X") return { token: k$1("text_segment", t) };
8336
- const r$3 = x(t, { inCharClass: !1 });
8345
+ const r$3 = x$1(t, { inCharClass: !1 });
8337
8346
  return Array.isArray(r$3) ? { tokens: r$3 } : { token: r$3 };
8338
8347
  }
8339
8348
  if (s$1 === "(") {
@@ -8344,13 +8353,13 @@ function F$1(e, n, t, o$2) {
8344
8353
  return { lastIndex: o$2 + 1 };
8345
8354
  }
8346
8355
  if (/^\(\?[-imx]+[:)]$/.test(t)) return { token: L$1(t, e) };
8347
- if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:") return { token: f$1("group", t) };
8348
- if (t === "(?>") return { token: f$1("atomic", t) };
8349
- if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!") return { token: f$1(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
8350
- if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'")) return { token: f$1("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
8356
+ if (e.pushModX(e.getCurrentModX()), e.numOpenGroups++, t === "(" && !e.captureGroup || t === "(?:") return { token: f("group", t) };
8357
+ if (t === "(?>") return { token: f("atomic", t) };
8358
+ if (t === "(?=" || t === "(?!" || t === "(?<=" || t === "(?<!") return { token: f(t[2] === "<" ? "lookbehind" : "lookahead", t, { negate: t.endsWith("!") }) };
8359
+ if (t === "(" && e.captureGroup || t.startsWith("(?<") && t.endsWith(">") || t.startsWith("(?'") && t.endsWith("'")) return { token: f("capturing", t, { ...t !== "(" && { name: t.slice(3, -1) } }) };
8351
8360
  if (t.startsWith("(?~")) {
8352
8361
  if (t === "(?~|") throw new Error(`Unsupported absence function kind "${t}"`);
8353
- return { token: f$1("absence_repeater", t) };
8362
+ return { token: f("absence_repeater", t) };
8354
8363
  }
8355
8364
  throw t === "(?(" ? new Error(`Unsupported conditional "${t}"`) : new Error(`Invalid or unsupported group option "${t}"`);
8356
8365
  }
@@ -8399,7 +8408,7 @@ function K$1(e, n, t) {
8399
8408
  };
8400
8409
  }
8401
8410
  function X$1(e) {
8402
- if (e[0] === "\\") return x(e, { inCharClass: !0 });
8411
+ if (e[0] === "\\") return x$1(e, { inCharClass: !0 });
8403
8412
  if (e[0] === "[") {
8404
8413
  const n = /\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);
8405
8414
  if (!n || !i.has(n.groups.name)) throw new Error(`Invalid POSIX class "${e}"`);
@@ -8410,7 +8419,7 @@ function X$1(e) {
8410
8419
  }
8411
8420
  return e === "-" ? U$1(e) : e === "&&" ? H(e) : d(r$2(e), e);
8412
8421
  }
8413
- function x(e, { inCharClass: n }) {
8422
+ function x$1(e, { inCharClass: n }) {
8414
8423
  const t = e[1];
8415
8424
  if (t === "c" || t === "C") return Z(e);
8416
8425
  if ("dDhHsSwW".includes(t)) return q(e);
@@ -8523,7 +8532,7 @@ function Q$1(e) {
8523
8532
  raw: e
8524
8533
  };
8525
8534
  }
8526
- function f$1(e, n, t = {}) {
8535
+ function f(e, n, t = {}) {
8527
8536
  return {
8528
8537
  type: "GroupOpen",
8529
8538
  kind: e,
@@ -8584,7 +8593,7 @@ function L$1(e, n) {
8584
8593
  o$2 ??= "";
8585
8594
  const s$1 = (n.getCurrentModX() || t.includes("x")) && !o$2.includes("x"), a$1 = v(t), r$3 = v(o$2), i$2 = {};
8586
8595
  if (a$1 && (i$2.enable = a$1), r$3 && (i$2.disable = r$3), e.endsWith(")")) return n.replaceCurrentModX(s$1), I$1("flags", e, { flags: i$2 });
8587
- if (e.endsWith(":")) return n.pushModX(s$1), n.numOpenGroups++, f$1("group", e, { ...(a$1 || r$3) && { flags: i$2 } });
8596
+ if (e.endsWith(":")) return n.pushModX(s$1), n.numOpenGroups++, f("group", e, { ...(a$1 || r$3) && { flags: i$2 } });
8588
8597
  throw new Error(`Unexpected flag modifier "${e}"`);
8589
8598
  }
8590
8599
  function j(e) {
@@ -8728,7 +8737,7 @@ function te$1(e) {
8728
8737
  }
8729
8738
 
8730
8739
  //#endregion
8731
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/parser/node-utils.js
8740
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/parser/node-utils.js
8732
8741
  function o(e, t) {
8733
8742
  if (!Array.isArray(e.body)) throw new Error("Expected node with body array");
8734
8743
  if (e.body.length !== 1) return !1;
@@ -8761,7 +8770,7 @@ const y = new Set([
8761
8770
  ]);
8762
8771
 
8763
8772
  //#endregion
8764
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/parser/parse.js
8773
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/parser/parse.js
8765
8774
  function J(e, r$3 = {}) {
8766
8775
  const n = {
8767
8776
  flags: "",
@@ -8776,30 +8785,30 @@ function J(e, r$3 = {}) {
8776
8785
  singleline: !1,
8777
8786
  ...r$3.rules
8778
8787
  }
8779
- }, t = M(e, {
8788
+ }, o$2 = M(e, {
8780
8789
  flags: n.flags,
8781
8790
  rules: {
8782
8791
  captureGroup: n.rules.captureGroup,
8783
8792
  singleline: n.rules.singleline
8784
8793
  }
8785
- }), s$1 = (p$1, N) => {
8786
- const u$1 = t.tokens[o$2.nextIndex];
8787
- switch (o$2.parent = p$1, o$2.nextIndex++, u$1.type) {
8794
+ }), i$2 = (p$1, N) => {
8795
+ const u$1 = o$2.tokens[t.nextIndex];
8796
+ switch (t.parent = p$1, t.nextIndex++, u$1.type) {
8788
8797
  case "Alternator": return b();
8789
8798
  case "Assertion": return W(u$1);
8790
- case "Backreference": return X(u$1, o$2);
8799
+ case "Backreference": return X(u$1, t);
8791
8800
  case "Character": return m(u$1.value, { useLastValid: !!N.isCheckingRangeEnd });
8792
- case "CharacterClassHyphen": return ee(u$1, o$2, N);
8793
- case "CharacterClassOpen": return re(u$1, o$2, N);
8794
- case "CharacterSet": return ne(u$1, o$2);
8801
+ case "CharacterClassHyphen": return ee(u$1, t, N);
8802
+ case "CharacterClassOpen": return re(u$1, t, N);
8803
+ case "CharacterSet": return ne(u$1, t);
8795
8804
  case "Directive": return I(u$1.kind, { flags: u$1.flags });
8796
- case "GroupOpen": return te(u$1, o$2, N);
8805
+ case "GroupOpen": return te(u$1, t, N);
8797
8806
  case "NamedCallout": return U(u$1.kind, u$1.tag, u$1.arguments);
8798
- case "Quantifier": return oe(u$1, o$2);
8799
- case "Subroutine": return ae(u$1, o$2);
8807
+ case "Quantifier": return oe(u$1, t);
8808
+ case "Subroutine": return ae(u$1, t);
8800
8809
  default: throw new Error(`Unexpected token type "${u$1.type}"`);
8801
8810
  }
8802
- }, o$2 = {
8811
+ }, t = {
8803
8812
  capturingGroups: [],
8804
8813
  hasNumberedRef: !1,
8805
8814
  namedGroupsByName: new Map(),
@@ -8810,25 +8819,25 @@ function J(e, r$3 = {}) {
8810
8819
  skipLookbehindValidation: n.skipLookbehindValidation,
8811
8820
  skipPropertyNameValidation: n.skipPropertyNameValidation,
8812
8821
  subroutines: [],
8813
- tokens: t.tokens,
8822
+ tokens: o$2.tokens,
8814
8823
  unicodePropertyMap: n.unicodePropertyMap,
8815
- walk: s$1
8816
- }, i$2 = B(T(t.flags));
8817
- let d$1 = i$2.body[0];
8818
- for (; o$2.nextIndex < t.tokens.length;) {
8819
- const p$1 = s$1(d$1, {});
8820
- p$1.type === "Alternative" ? (i$2.body.push(p$1), d$1 = p$1) : d$1.body.push(p$1);
8821
- }
8822
- const { capturingGroups: a$1, hasNumberedRef: l$2, namedGroupsByName: c, subroutines: f$2 } = o$2;
8824
+ walk: i$2
8825
+ }, d$1 = B(T(o$2.flags));
8826
+ let s$1 = d$1.body[0];
8827
+ for (; t.nextIndex < o$2.tokens.length;) {
8828
+ const p$1 = i$2(s$1, {});
8829
+ p$1.type === "Alternative" ? (d$1.body.push(p$1), s$1 = p$1) : s$1.body.push(p$1);
8830
+ }
8831
+ const { capturingGroups: a$1, hasNumberedRef: l$2, namedGroupsByName: c, subroutines: f$1 } = t;
8823
8832
  if (l$2 && c.size && !n.rules.captureGroup) throw new Error("Numbered backref/subroutine not allowed when using named capture");
8824
- for (const { ref: p$1 } of f$2) if (typeof p$1 == "number") {
8833
+ for (const { ref: p$1 } of f$1) if (typeof p$1 == "number") {
8825
8834
  if (p$1 > a$1.length) throw new Error("Subroutine uses a group number that's not defined");
8826
8835
  p$1 && (a$1[p$1 - 1].isSubroutined = !0);
8827
8836
  } else if (c.has(p$1)) {
8828
8837
  if (c.get(p$1).length > 1) throw new Error(o$1`Subroutine uses a duplicate group name "\g<${p$1}>"`);
8829
8838
  c.get(p$1)[0].isSubroutined = !0;
8830
8839
  } else throw new Error(o$1`Subroutine uses a group name that's not defined "\g<${p$1}>"`);
8831
- return i$2;
8840
+ return d$1;
8832
8841
  }
8833
8842
  function W({ kind: e }) {
8834
8843
  return F(u({
@@ -8845,106 +8854,106 @@ function W({ kind: e }) {
8845
8854
  }[e], `Unexpected assertion kind "${e}"`), { negate: e === o$1`\B` || e === o$1`\Y` });
8846
8855
  }
8847
8856
  function X({ raw: e }, r$3) {
8848
- const n = /^\\k[<']/.test(e), t = n ? e.slice(3, -1) : e.slice(1), s$1 = (o$2, i$2 = !1) => {
8849
- const d$1 = r$3.capturingGroups.length;
8857
+ const n = /^\\k[<']/.test(e), o$2 = n ? e.slice(3, -1) : e.slice(1), i$2 = (t, d$1 = !1) => {
8858
+ const s$1 = r$3.capturingGroups.length;
8850
8859
  let a$1 = !1;
8851
- if (o$2 > d$1) if (r$3.skipBackrefValidation) a$1 = !0;
8860
+ if (t > s$1) if (r$3.skipBackrefValidation) a$1 = !0;
8852
8861
  else throw new Error(`Not enough capturing groups defined to the left "${e}"`);
8853
- return r$3.hasNumberedRef = !0, k(i$2 ? d$1 + 1 - o$2 : o$2, { orphan: a$1 });
8862
+ return r$3.hasNumberedRef = !0, k(d$1 ? s$1 + 1 - t : t, { orphan: a$1 });
8854
8863
  };
8855
8864
  if (n) {
8856
- const o$2 = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(t);
8857
- if (o$2) return s$1(+o$2.groups.num, !!o$2.groups.sign);
8858
- if (/[-+]/.test(t)) throw new Error(`Invalid backref name "${e}"`);
8859
- if (!r$3.namedGroupsByName.has(t)) throw new Error(`Group name not defined to the left "${e}"`);
8860
- return k(t);
8865
+ const t = /^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(o$2);
8866
+ if (t) return i$2(+t.groups.num, !!t.groups.sign);
8867
+ if (/[-+]/.test(o$2)) throw new Error(`Invalid backref name "${e}"`);
8868
+ if (!r$3.namedGroupsByName.has(o$2)) throw new Error(`Group name not defined to the left "${e}"`);
8869
+ return k(o$2);
8861
8870
  }
8862
- return s$1(+t);
8871
+ return i$2(+o$2);
8863
8872
  }
8864
8873
  function ee(e, r$3, n) {
8865
- const { tokens: t, walk: s$1 } = r$3, o$2 = r$3.parent, i$2 = o$2.body.at(-1), d$1 = t[r$3.nextIndex];
8866
- if (!n.isCheckingRangeEnd && i$2 && i$2.type !== "CharacterClass" && i$2.type !== "CharacterClassRange" && d$1 && d$1.type !== "CharacterClassOpen" && d$1.type !== "CharacterClassClose" && d$1.type !== "CharacterClassIntersector") {
8867
- const a$1 = s$1(o$2, {
8874
+ const { tokens: o$2, walk: i$2 } = r$3, t = r$3.parent, d$1 = t.body.at(-1), s$1 = o$2[r$3.nextIndex];
8875
+ if (!n.isCheckingRangeEnd && d$1 && d$1.type !== "CharacterClass" && d$1.type !== "CharacterClassRange" && s$1 && s$1.type !== "CharacterClassOpen" && s$1.type !== "CharacterClassClose" && s$1.type !== "CharacterClassIntersector") {
8876
+ const a$1 = i$2(t, {
8868
8877
  ...n,
8869
8878
  isCheckingRangeEnd: !0
8870
8879
  });
8871
- if (i$2.type === "Character" && a$1.type === "Character") return o$2.body.pop(), L(i$2, a$1);
8880
+ if (d$1.type === "Character" && a$1.type === "Character") return t.body.pop(), L(d$1, a$1);
8872
8881
  throw new Error("Invalid character class range");
8873
8882
  }
8874
8883
  return m(r$2("-"));
8875
8884
  }
8876
8885
  function re({ negate: e }, r$3, n) {
8877
- const { tokens: t, walk: s$1 } = r$3, o$2 = t[r$3.nextIndex], i$2 = [C()];
8878
- let d$1 = z(o$2);
8879
- for (; d$1.type !== "CharacterClassClose";) {
8880
- if (d$1.type === "CharacterClassIntersector") i$2.push(C()), r$3.nextIndex++;
8886
+ const { tokens: o$2, walk: i$2 } = r$3, t = [C()], d$1 = o$2[r$3.nextIndex];
8887
+ let s$1 = z(d$1);
8888
+ for (; s$1.type !== "CharacterClassClose";) {
8889
+ if (s$1.type === "CharacterClassIntersector") t.push(C()), r$3.nextIndex++;
8881
8890
  else {
8882
- const l$2 = i$2.at(-1);
8883
- l$2.body.push(s$1(l$2, n));
8891
+ const l$2 = t.at(-1);
8892
+ l$2.body.push(i$2(l$2, n));
8884
8893
  }
8885
- d$1 = z(t[r$3.nextIndex], o$2);
8894
+ s$1 = z(o$2[r$3.nextIndex], d$1);
8886
8895
  }
8887
8896
  const a$1 = C({ negate: e });
8888
- return i$2.length === 1 ? a$1.body = i$2[0].body : (a$1.kind = "intersection", a$1.body = i$2.map((l$2) => l$2.body.length === 1 ? l$2.body[0] : l$2)), r$3.nextIndex++, a$1;
8897
+ return t.length === 1 ? a$1.body = t[0].body : (a$1.kind = "intersection", a$1.body = t.map((l$2) => l$2.body.length === 1 ? l$2.body[0] : l$2)), r$3.nextIndex++, a$1;
8889
8898
  }
8890
- function ne({ kind: e, negate: r$3, value: n }, t) {
8891
- const { normalizeUnknownPropertyNames: s$1, skipPropertyNameValidation: o$2, unicodePropertyMap: i$2 } = t;
8899
+ function ne({ kind: e, negate: r$3, value: n }, o$2) {
8900
+ const { normalizeUnknownPropertyNames: i$2, skipPropertyNameValidation: t, unicodePropertyMap: d$1 } = o$2;
8892
8901
  if (e === "property") {
8893
- const d$1 = w(n);
8894
- if (i.has(d$1) && !i$2?.has(d$1)) e = "posix", n = d$1;
8902
+ const s$1 = w(n);
8903
+ if (i.has(s$1) && !d$1?.has(s$1)) e = "posix", n = s$1;
8895
8904
  else return Q(n, {
8896
8905
  negate: r$3,
8897
- normalizeUnknownPropertyNames: s$1,
8898
- skipPropertyNameValidation: o$2,
8899
- unicodePropertyMap: i$2
8906
+ normalizeUnknownPropertyNames: i$2,
8907
+ skipPropertyNameValidation: t,
8908
+ unicodePropertyMap: d$1
8900
8909
  });
8901
8910
  }
8902
8911
  return e === "posix" ? R(n, { negate: r$3 }) : E(e, { negate: r$3 });
8903
8912
  }
8904
8913
  function te(e, r$3, n) {
8905
- const { tokens: t, capturingGroups: s$1, namedGroupsByName: o$2, skipLookbehindValidation: i$2, walk: d$1 } = r$3, a$1 = ie(e), l$2 = a$1.type === "AbsenceFunction", c = $(a$1), f$2 = c && a$1.negate;
8906
- if (a$1.type === "CapturingGroup" && (s$1.push(a$1), a$1.name && l$1(o$2, a$1.name, []).push(a$1)), l$2 && n.isInAbsenceFunction) throw new Error("Nested absence function not supported by Oniguruma");
8907
- let p$1 = D(t[r$3.nextIndex]);
8914
+ const { tokens: o$2, capturingGroups: i$2, namedGroupsByName: t, skipLookbehindValidation: d$1, walk: s$1 } = r$3, a$1 = ie(e), l$2 = a$1.type === "AbsenceFunction", c = $(a$1), f$1 = c && a$1.negate;
8915
+ if (a$1.type === "CapturingGroup" && (i$2.push(a$1), a$1.name && l$1(t, a$1.name, []).push(a$1)), l$2 && n.isInAbsenceFunction) throw new Error("Nested absence function not supported by Oniguruma");
8916
+ let p$1 = D(o$2[r$3.nextIndex]);
8908
8917
  for (; p$1.type !== "GroupClose";) {
8909
8918
  if (p$1.type === "Alternator") a$1.body.push(b()), r$3.nextIndex++;
8910
8919
  else {
8911
- const N = a$1.body.at(-1), u$1 = d$1(N, {
8920
+ const N = a$1.body.at(-1), u$1 = s$1(N, {
8912
8921
  ...n,
8913
8922
  isInAbsenceFunction: n.isInAbsenceFunction || l$2,
8914
8923
  isInLookbehind: n.isInLookbehind || c,
8915
- isInNegLookbehind: n.isInNegLookbehind || f$2
8924
+ isInNegLookbehind: n.isInNegLookbehind || f$1
8916
8925
  });
8917
- if (N.body.push(u$1), (c || n.isInLookbehind) && !i$2) {
8926
+ if (N.body.push(u$1), (c || n.isInLookbehind) && !d$1) {
8918
8927
  const v$1 = "Lookbehind includes a pattern not allowed by Oniguruma";
8919
- if (f$2 || n.isInNegLookbehind) {
8928
+ if (f$1 || n.isInNegLookbehind) {
8920
8929
  if (M$1(u$1) || u$1.type === "CapturingGroup") throw new Error(v$1);
8921
8930
  } else if (M$1(u$1) || $(u$1) && u$1.negate) throw new Error(v$1);
8922
8931
  }
8923
8932
  }
8924
- p$1 = D(t[r$3.nextIndex]);
8933
+ p$1 = D(o$2[r$3.nextIndex]);
8925
8934
  }
8926
8935
  return r$3.nextIndex++, a$1;
8927
8936
  }
8928
- function oe({ kind: e, min: r$3, max: n }, t) {
8929
- const s$1 = t.parent, o$2 = s$1.body.at(-1);
8930
- if (!o$2 || !s(o$2)) throw new Error("Quantifier requires a repeatable token");
8931
- const i$2 = _(e, r$3, n, o$2);
8932
- return s$1.body.pop(), i$2;
8937
+ function oe({ kind: e, min: r$3, max: n }, o$2) {
8938
+ const i$2 = o$2.parent, t = i$2.body.at(-1);
8939
+ if (!t || !s(t)) throw new Error("Quantifier requires a repeatable token");
8940
+ const d$1 = _(e, r$3, n, t);
8941
+ return i$2.body.pop(), d$1;
8933
8942
  }
8934
8943
  function ae({ raw: e }, r$3) {
8935
- const { capturingGroups: n, subroutines: t } = r$3;
8936
- let s$1 = e.slice(3, -1);
8937
- const o$2 = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s$1);
8938
- if (o$2) {
8939
- const d$1 = +o$2.groups.num, a$1 = n.length;
8940
- if (r$3.hasNumberedRef = !0, s$1 = {
8941
- "": d$1,
8942
- "+": a$1 + d$1,
8943
- "-": a$1 + 1 - d$1
8944
- }[o$2.groups.sign], s$1 < 1) throw new Error("Invalid subroutine number");
8945
- } else s$1 === "0" && (s$1 = 0);
8946
- const i$2 = O(s$1);
8947
- return t.push(i$2), i$2;
8944
+ const { capturingGroups: n, subroutines: o$2 } = r$3;
8945
+ let i$2 = e.slice(3, -1);
8946
+ const t = /^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(i$2);
8947
+ if (t) {
8948
+ const s$1 = +t.groups.num, a$1 = n.length;
8949
+ if (r$3.hasNumberedRef = !0, i$2 = {
8950
+ "": s$1,
8951
+ "+": a$1 + s$1,
8952
+ "-": a$1 + 1 - s$1
8953
+ }[t.groups.sign], i$2 < 1) throw new Error("Invalid subroutine number");
8954
+ } else i$2 === "0" && (i$2 = 0);
8955
+ const d$1 = O(i$2);
8956
+ return o$2.push(d$1), d$1;
8948
8957
  }
8949
8958
  function G(e, r$3) {
8950
8959
  if (e !== "repeater") throw new Error(`Unexpected absence function kind "${e}"`);
@@ -8996,9 +9005,9 @@ function m(e, r$3) {
8996
9005
  ...r$3
8997
9006
  };
8998
9007
  if (e > 1114111) {
8999
- const t = e.toString(16);
9008
+ const o$2 = e.toString(16);
9000
9009
  if (n.useLastValid) e = 1114111;
9001
- else throw e > 1310719 ? new Error(`Invalid code point out of range "\\x{${t}}"`) : new Error(`Invalid code point out of range in JS "\\x{${t}}"`);
9010
+ else throw e > 1310719 ? new Error(`Invalid code point out of range "\\x{${o$2}}"`) : new Error(`Invalid code point out of range in JS "\\x{${o$2}}"`);
9002
9011
  }
9003
9012
  return {
9004
9013
  type: "Character",
@@ -9027,11 +9036,11 @@ function L(e, r$3) {
9027
9036
  };
9028
9037
  }
9029
9038
  function E(e, r$3) {
9030
- const n = !!r$3?.negate, t = {
9039
+ const n = !!r$3?.negate, o$2 = {
9031
9040
  type: "CharacterSet",
9032
9041
  kind: e
9033
9042
  };
9034
- return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (t.negate = n), (e === "text_segment" || e === "newline" && !n) && (t.variableLength = !0), t;
9043
+ return (e === "digit" || e === "hex" || e === "newline" || e === "space" || e === "word") && (o$2.negate = n), (e === "text_segment" || e === "newline" && !n) && (o$2.variableLength = !0), o$2;
9035
9044
  }
9036
9045
  function I(e, r$3 = {}) {
9037
9046
  if (e === "keep") return {
@@ -9092,14 +9101,14 @@ function R(e, r$3) {
9092
9101
  negate: n
9093
9102
  };
9094
9103
  }
9095
- function _(e, r$3, n, t) {
9104
+ function _(e, r$3, n, o$2) {
9096
9105
  if (r$3 > n) throw new Error("Invalid reversed quantifier range");
9097
9106
  return {
9098
9107
  type: "Quantifier",
9099
9108
  kind: e,
9100
9109
  min: r$3,
9101
9110
  max: n,
9102
- body: t
9111
+ body: o$2
9103
9112
  };
9104
9113
  }
9105
9114
  function B(e, r$3) {
@@ -9123,28 +9132,28 @@ function Q(e, r$3) {
9123
9132
  unicodePropertyMap: null,
9124
9133
  ...r$3
9125
9134
  };
9126
- let t = n.unicodePropertyMap?.get(w(e));
9127
- if (!t) {
9128
- if (n.normalizeUnknownPropertyNames) t = de(e);
9135
+ let o$2 = n.unicodePropertyMap?.get(w(e));
9136
+ if (!o$2) {
9137
+ if (n.normalizeUnknownPropertyNames) o$2 = de(e);
9129
9138
  else if (n.unicodePropertyMap && !n.skipPropertyNameValidation) throw new Error(o$1`Invalid Unicode property "\p{${e}}"`);
9130
9139
  }
9131
9140
  return {
9132
9141
  type: "CharacterSet",
9133
9142
  kind: "property",
9134
- value: t ?? e,
9143
+ value: o$2 ?? e,
9135
9144
  negate: n.negate
9136
9145
  };
9137
9146
  }
9138
- function ie({ flags: e, kind: r$3, name: n, negate: t, number: s$1 }) {
9147
+ function ie({ flags: e, kind: r$3, name: n, negate: o$2, number: i$2 }) {
9139
9148
  switch (r$3) {
9140
9149
  case "absence_repeater": return G("repeater");
9141
9150
  case "atomic": return A({ atomic: !0 });
9142
- case "capturing": return P(s$1, { name: n });
9151
+ case "capturing": return P(i$2, { name: n });
9143
9152
  case "group": return A({ flags: e });
9144
9153
  case "lookahead":
9145
9154
  case "lookbehind": return K({
9146
9155
  behind: r$3 === "lookbehind",
9147
- negate: t
9156
+ negate: o$2
9148
9157
  });
9149
9158
  default: throw new Error(`Unexpected group kind "${r$3}"`);
9150
9159
  }
@@ -9175,16 +9184,17 @@ function w(e) {
9175
9184
  return e.replace(/[- _]+/g, "").toLowerCase();
9176
9185
  }
9177
9186
  function z(e, r$3) {
9178
- return u(e, `${r$3?.type === "Character" && r$3.value === 93 ? "Empty" : "Unclosed"} character class`);
9187
+ const n = r$3;
9188
+ return u(e, `Unclosed character class${n?.type === "Character" && n.value === 93 && n.raw === "]" ? " (started with \"]\")" : ""}`);
9179
9189
  }
9180
9190
  function D(e) {
9181
9191
  return u(e, "Unclosed group");
9182
9192
  }
9183
9193
 
9184
9194
  //#endregion
9185
- //#region ../../node_modules/.bun/oniguruma-parser@0.12.1/node_modules/oniguruma-parser/dist/traverser/traverse.js
9195
+ //#region ../../node_modules/.bun/oniguruma-parser@0.12.2/node_modules/oniguruma-parser/dist/traverser/traverse.js
9186
9196
  function S(a$1, v$1, N = null) {
9187
- function u$1(e, s$1) {
9197
+ function b$2(e, s$1) {
9188
9198
  for (let t = 0; t < e.length; t++) {
9189
9199
  const r$3 = n(e[t], s$1, t, e);
9190
9200
  t = Math.max(-1, t + r$3);
@@ -9199,40 +9209,39 @@ function S(a$1, v$1, N = null) {
9199
9209
  container: r$3,
9200
9210
  root: a$1,
9201
9211
  remove() {
9202
- f(r$3).splice(Math.max(0, l(t) + i$2), 1), i$2--, c = !0;
9212
+ x(r$3).splice(Math.max(0, l(t) + i$2), 1), i$2--, c = !0;
9203
9213
  },
9204
9214
  removeAllNextSiblings() {
9205
- return f(r$3).splice(l(t) + 1);
9215
+ return x(r$3).splice(l(t) + 1);
9206
9216
  },
9207
9217
  removeAllPrevSiblings() {
9208
9218
  const o$2 = l(t) + i$2;
9209
- return i$2 -= o$2, f(r$3).splice(0, Math.max(0, o$2));
9219
+ return i$2 -= o$2, x(r$3).splice(0, Math.max(0, o$2));
9210
9220
  },
9211
- replaceWith(o$2, y$2 = {}) {
9212
- const b$2 = !!y$2.traverse;
9213
- r$3 ? r$3[Math.max(0, l(t) + i$2)] = o$2 : u(s$1, "Can't replace root node")[t] = o$2, b$2 && n(o$2, s$1, t, r$3), c = !0;
9221
+ replaceWith(o$2, m$2 = {}) {
9222
+ const y$2 = !!m$2.traverse;
9223
+ r$3 ? r$3[Math.max(0, l(t) + i$2)] = o$2 : u(s$1, "Can't replace root node")[t] = o$2, y$2 && n(o$2, s$1, t, r$3), c = !0;
9214
9224
  },
9215
- replaceWithMultiple(o$2, y$2 = {}) {
9216
- const b$2 = !!y$2.traverse;
9217
- if (f(r$3).splice(Math.max(0, l(t) + i$2), 1, ...o$2), i$2 += o$2.length - 1, b$2) {
9225
+ replaceWithMultiple(o$2, m$2 = {}) {
9226
+ const y$2 = !!m$2.traverse;
9227
+ if (x(r$3).splice(Math.max(0, l(t) + i$2), 1, ...o$2), i$2 += o$2.length - 1, y$2) {
9218
9228
  let g = 0;
9219
- for (let x$1 = 0; x$1 < o$2.length; x$1++) g += n(o$2[x$1], s$1, l(t) + x$1 + g, r$3);
9229
+ for (let p$1 = 0; p$1 < o$2.length; p$1++) g += n(o$2[p$1], s$1, l(t) + p$1 + g, r$3);
9220
9230
  }
9221
9231
  c = !0;
9222
9232
  },
9223
9233
  skip() {
9224
9234
  c = !0;
9225
9235
  }
9226
- }, { type: m$2 } = e, h$1 = v$1["*"], p$1 = v$1[m$2], R$2 = typeof h$1 == "function" ? h$1 : h$1?.enter, P$2 = typeof p$1 == "function" ? p$1 : p$1?.enter;
9227
- if (R$2?.(d$1, N), P$2?.(d$1, N), !c) switch (m$2) {
9236
+ }, { type: f$1 } = e, u$1 = v$1["*"], h$1 = v$1[f$1], R$2 = typeof u$1 == "function" ? u$1 : u$1?.enter, P$2 = typeof h$1 == "function" ? h$1 : h$1?.enter;
9237
+ if (R$2?.(d$1, N), P$2?.(d$1, N), !c) switch (f$1) {
9228
9238
  case "AbsenceFunction":
9229
- case "CapturingGroup":
9230
- case "Group":
9231
- u$1(e.body, e);
9232
- break;
9233
9239
  case "Alternative":
9240
+ case "CapturingGroup":
9234
9241
  case "CharacterClass":
9235
- u$1(e.body, e);
9242
+ case "Group":
9243
+ case "LookaroundAssertion":
9244
+ b$2(e.body, e);
9236
9245
  break;
9237
9246
  case "Assertion":
9238
9247
  case "Backreference":
@@ -9245,22 +9254,19 @@ function S(a$1, v$1, N = null) {
9245
9254
  case "CharacterClassRange":
9246
9255
  n(e.min, e, "min"), n(e.max, e, "max");
9247
9256
  break;
9248
- case "LookaroundAssertion":
9249
- u$1(e.body, e);
9250
- break;
9251
9257
  case "Quantifier":
9252
9258
  n(e.body, e, "body");
9253
9259
  break;
9254
9260
  case "Regex":
9255
- u$1(e.body, e), n(e.flags, e, "flags");
9261
+ b$2(e.body, e), n(e.flags, e, "flags");
9256
9262
  break;
9257
- default: throw new Error(`Unexpected node type "${m$2}"`);
9263
+ default: throw new Error(`Unexpected node type "${f$1}"`);
9258
9264
  }
9259
- return p$1?.exit?.(d$1, N), h$1?.exit?.(d$1, N), i$2;
9265
+ return h$1?.exit?.(d$1, N), u$1?.exit?.(d$1, N), i$2;
9260
9266
  }
9261
9267
  return n(a$1), a$1;
9262
9268
  }
9263
- function f(a$1) {
9269
+ function x(a$1) {
9264
9270
  if (!Array.isArray(a$1)) throw new Error("Container expected");
9265
9271
  return a$1;
9266
9272
  }
@@ -9270,7 +9276,7 @@ function l(a$1) {
9270
9276
  }
9271
9277
 
9272
9278
  //#endregion
9273
- //#region ../../node_modules/.bun/regex@6.0.1/node_modules/regex/src/utils-internals.js
9279
+ //#region ../../node_modules/.bun/regex@6.1.0/node_modules/regex/src/utils-internals.js
9274
9280
  const noncapturingDelim = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
9275
9281
  /**
9276
9282
  Updates the array in place by incrementing each value greater than or equal to the threshold.
@@ -9458,13 +9464,16 @@ function getGroupContents(expression, contentsStartPos) {
9458
9464
  }
9459
9465
 
9460
9466
  //#endregion
9461
- //#region ../../node_modules/.bun/regex@6.0.1/node_modules/regex/src/atomic.js
9467
+ //#region ../../node_modules/.bun/regex@6.1.0/node_modules/regex/src/atomic.js
9468
+ /**
9469
+ @import {PluginData, PluginResult} from './regex.js';
9470
+ */
9462
9471
  const atomicPluginToken = new RegExp(String.raw`(?<noncapturingStart>${noncapturingDelim})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`, "gsu");
9463
9472
  /**
9464
9473
  Apply transformations for atomic groups: `(?>…)`.
9465
9474
  @param {string} expression
9466
- @param {import('./regex.js').PluginData} [data]
9467
- @returns {Required<import('./regex.js').PluginResult>}
9475
+ @param {PluginData} [data]
9476
+ @returns {Required<PluginResult>}
9468
9477
  */
9469
9478
  function atomic(expression, data) {
9470
9479
  const hiddenCaptures = data?.hiddenCaptures ?? [];
@@ -9519,7 +9528,7 @@ function atomic(expression, data) {
9519
9528
  if (captureTransfers.size) {
9520
9529
  const newCaptureTransfers = new Map();
9521
9530
  captureTransfers.forEach((from, to) => {
9522
- newCaptureTransfers.set(to >= addedCaptureNum ? to + 1 : to, from.map((f$2) => f$2 >= addedCaptureNum ? f$2 + 1 : f$2));
9531
+ newCaptureTransfers.set(to >= addedCaptureNum ? to + 1 : to, from.map((f$1) => f$1 >= addedCaptureNum ? f$1 + 1 : f$1));
9523
9532
  });
9524
9533
  captureTransfers = newCaptureTransfers;
9525
9534
  }
@@ -9572,7 +9581,7 @@ Transform posessive quantifiers into atomic groups. The posessessive quantifiers
9572
9581
  This follows Java, PCRE, Perl, and Python.
9573
9582
  Possessive quantifiers in Oniguruma and Onigmo are only: `?+`, `*+`, `++`.
9574
9583
  @param {string} expression
9575
- @returns {import('./regex.js').PluginResult}
9584
+ @returns {PluginResult}
9576
9585
  */
9577
9586
  function possessive(expression) {
9578
9587
  if (!new RegExp(`${baseQuantifier}\\+`).test(expression)) {
@@ -9631,7 +9640,7 @@ function possessive(expression) {
9631
9640
  }
9632
9641
 
9633
9642
  //#endregion
9634
- //#region ../../node_modules/.bun/regex@6.0.1/node_modules/regex/src/subclass.js
9643
+ //#region ../../node_modules/.bun/regex@6.1.0/node_modules/regex/src/subclass.js
9635
9644
  /**
9636
9645
  Works the same as JavaScript's native `RegExp` constructor in all contexts, but automatically
9637
9646
  adjusts subpattern matches and indices (with flag `d`) to account for captures added as part of
@@ -9955,18 +9964,18 @@ function mapCaptureTransfers(captureTransfers, left, reps, numCapturesAddedInExp
9955
9964
  const numCapturesAddedInLeft = numCapturesInLeft * reps;
9956
9965
  const newTo = to > recursionDelimCaptureNum + numCapturesInLeft ? to + numCapturesAddedInExpansion : to;
9957
9966
  const newFrom = [];
9958
- for (const f$2 of from) {
9959
- if (f$2 <= recursionDelimCaptureNum) {
9960
- newFrom.push(f$2);
9961
- } else if (f$2 > recursionDelimCaptureNum + numCapturesInLeft + numCapturesInRight) {
9962
- newFrom.push(f$2 + numCapturesAddedInExpansion);
9963
- } else if (f$2 <= recursionDelimCaptureNum + numCapturesInLeft) {
9967
+ for (const f$1 of from) {
9968
+ if (f$1 <= recursionDelimCaptureNum) {
9969
+ newFrom.push(f$1);
9970
+ } else if (f$1 > recursionDelimCaptureNum + numCapturesInLeft + numCapturesInRight) {
9971
+ newFrom.push(f$1 + numCapturesAddedInExpansion);
9972
+ } else if (f$1 <= recursionDelimCaptureNum + numCapturesInLeft) {
9964
9973
  for (let i$2 = 0; i$2 <= reps; i$2++) {
9965
- newFrom.push(f$2 + numCapturesInLeft * i$2);
9974
+ newFrom.push(f$1 + numCapturesInLeft * i$2);
9966
9975
  }
9967
9976
  } else {
9968
9977
  for (let i$2 = 0; i$2 <= reps; i$2++) {
9969
- newFrom.push(f$2 + numCapturesAddedInLeft + numCapturesInRight * i$2);
9978
+ newFrom.push(f$1 + numCapturesAddedInLeft + numCapturesInRight * i$2);
9970
9979
  }
9971
9980
  }
9972
9981
  }
@@ -9978,36 +9987,36 @@ function mapCaptureTransfers(captureTransfers, left, reps, numCapturesAddedInExp
9978
9987
  }
9979
9988
 
9980
9989
  //#endregion
9981
- //#region ../../node_modules/.bun/oniguruma-to-es@4.3.4/node_modules/oniguruma-to-es/dist/esm/index.js
9990
+ //#region ../../node_modules/.bun/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/dist/esm/index.js
9982
9991
  var cp = String.fromCodePoint;
9983
9992
  var r = String.raw;
9984
- var envFlags = {
9985
- flagGroups: (() => {
9986
- try {
9987
- new RegExp("(?i:)");
9988
- } catch {
9989
- return false;
9990
- }
9991
- return true;
9992
- })(),
9993
- unicodeSets: (() => {
9994
- try {
9995
- new RegExp("[[]]", "v");
9996
- } catch {
9997
- return false;
9998
- }
9999
- return true;
10000
- })()
10001
- };
9993
+ var envFlags = {};
9994
+ var globalRegExp = globalThis.RegExp;
9995
+ envFlags.flagGroups = (() => {
9996
+ try {
9997
+ new globalRegExp("(?i:)");
9998
+ } catch {
9999
+ return false;
10000
+ }
10001
+ return true;
10002
+ })();
10003
+ envFlags.unicodeSets = (() => {
10004
+ try {
10005
+ new globalRegExp("[[]]", "v");
10006
+ } catch {
10007
+ return false;
10008
+ }
10009
+ return true;
10010
+ })();
10002
10011
  envFlags.bugFlagVLiteralHyphenIsRange = envFlags.unicodeSets ? (() => {
10003
10012
  try {
10004
- new RegExp(r`[\d\-a]`, "v");
10013
+ new globalRegExp(r`[\d\-a]`, "v");
10005
10014
  } catch {
10006
10015
  return true;
10007
10016
  }
10008
10017
  return false;
10009
10018
  })() : false;
10010
- envFlags.bugNestedClassIgnoresNegation = envFlags.unicodeSets && new RegExp("[[^a]]", "v").test("a");
10019
+ envFlags.bugNestedClassIgnoresNegation = envFlags.unicodeSets && new globalRegExp("[[^a]]", "v").test("a");
10011
10020
  function getNewCurrentFlags(current, { enable, disable }) {
10012
10021
  return {
10013
10022
  dotAll: !disable?.dotAll && !!(enable?.dotAll || current.dotAll),
@@ -10489,7 +10498,7 @@ var FirstPassVisitor = {
10489
10498
  "spaceIsAscii",
10490
10499
  "wordIsAscii",
10491
10500
  "textSegmentMode"
10492
- ].forEach((f$2) => delete node[f$2]);
10501
+ ].forEach((f$1) => delete node[f$1]);
10493
10502
  Object.assign(node, {
10494
10503
  global: false,
10495
10504
  hasIndices: false,
@@ -10633,7 +10642,9 @@ var SecondPassVisitor = {
10633
10642
  }
10634
10643
  },
10635
10644
  exit({ node }, { openRefs }) {
10636
- openRefs.delete(node.number);
10645
+ if (openRefs.get(node.number) === node) {
10646
+ openRefs.delete(node.number);
10647
+ }
10637
10648
  }
10638
10649
  },
10639
10650
  Group: {
@@ -11633,7 +11644,7 @@ function toRegExpDetails(pattern, options) {
11633
11644
  }
11634
11645
 
11635
11646
  //#endregion
11636
- //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.0.2/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs
11647
+ //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.2.0/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs
11637
11648
  /**
11638
11649
  * The default regex constructor for the JavaScript RegExp engine.
11639
11650
  */
@@ -11661,10 +11672,11 @@ function defaultJavaScriptRegexConstructor(pattern, options) {
11661
11672
  * Set `forgiving` to `true` to ignore these errors and skip any unsupported or invalid patterns.
11662
11673
  */
11663
11674
  function createJavaScriptRegexEngine(options = {}) {
11664
- const _options = Object.assign({
11675
+ const _options = {
11665
11676
  target: "auto",
11666
- cache: /* @__PURE__ */ new Map()
11667
- }, options);
11677
+ cache: /* @__PURE__ */ new Map(),
11678
+ ...options
11679
+ };
11668
11680
  _options.regexConstructor ||= (pattern) => defaultJavaScriptRegexConstructor(pattern, { target: _options.target });
11669
11681
  return {
11670
11682
  createScanner(patterns) {
@@ -11677,7 +11689,7 @@ function createJavaScriptRegexEngine(options = {}) {
11677
11689
  }
11678
11690
 
11679
11691
  //#endregion
11680
- //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.0.2/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs
11692
+ //#region ../../node_modules/.bun/@shikijs+engine-javascript@4.2.0/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs
11681
11693
  /**
11682
11694
  * Raw JavaScript regex engine that only supports precompiled grammars.
11683
11695
  *
@@ -11703,7 +11715,7 @@ function createJavaScriptRawEngine() {
11703
11715
  }
11704
11716
 
11705
11717
  //#endregion
11706
- //#region ../../node_modules/.bun/@shikijs+engine-oniguruma@4.0.2/node_modules/@shikijs/engine-oniguruma/dist/index.mjs
11718
+ //#region ../../node_modules/.bun/@shikijs+engine-oniguruma@4.2.0/node_modules/@shikijs/engine-oniguruma/dist/index.mjs
11707
11719
  var dist_exports = /* @__PURE__ */ __export({
11708
11720
  createOnigurumaEngine: () => createOnigurumaEngine,
11709
11721
  getDefaultWasmLoader: () => getDefaultWasmLoader,
@@ -11722,7 +11734,7 @@ function getHeapMax() {
11722
11734
  function _emscripten_get_now() {
11723
11735
  return typeof performance !== "undefined" ? performance.now() : Date.now();
11724
11736
  }
11725
- const alignUp = (x$1, multiple) => x$1 + (multiple - x$1 % multiple) % multiple;
11737
+ const alignUp = (x$2, multiple) => x$2 + (multiple - x$2 % multiple) % multiple;
11726
11738
  async function main(init) {
11727
11739
  let wasmMemory;
11728
11740
  let buffer;
@@ -11805,10 +11817,10 @@ async function main(init) {
11805
11817
  env: asmLibraryArg,
11806
11818
  wasi_snapshot_preview1: asmLibraryArg
11807
11819
  };
11808
- const exports$1 = await init(info);
11809
- wasmMemory = exports$1.memory;
11820
+ const exports = await init(info);
11821
+ wasmMemory = exports.memory;
11810
11822
  updateGlobalBufferAndViews(wasmMemory.buffer);
11811
- Object.assign(binding, exports$1);
11823
+ Object.assign(binding, exports);
11812
11824
  binding.UTF8ToString = UTF8ToString;
11813
11825
  }
11814
11826
  await createWasm();
@@ -12127,7 +12139,7 @@ async function createOnigurumaEngine(options) {
12127
12139
  }
12128
12140
 
12129
12141
  //#endregion
12130
- //#region ../../node_modules/.bun/shiki@4.0.2/node_modules/shiki/dist/engine-oniguruma.mjs
12142
+ //#region ../../node_modules/.bun/shiki@4.2.0/node_modules/shiki/dist/engine-oniguruma.mjs
12131
12143
  var engine_oniguruma_exports = /* @__PURE__ */ __exportAll({});
12132
12144
  __reExport(engine_oniguruma_exports, dist_exports);
12133
12145
 
@@ -12231,11 +12243,500 @@ function attachResolvedLanguages(resolvedLanguages, highlighter$1) {
12231
12243
 
12232
12244
  //#endregion
12233
12245
  //#region src/highlighter/themes/constants.ts
12234
- const ResolvedThemes = new Map();
12235
- const ResolvingThemes = new Map();
12236
- const RegisteredCustomThemes = new Map();
12237
12246
  const AttachedThemes = new Set();
12238
12247
 
12248
+ //#endregion
12249
+ //#region ../theming/dist/modules/createThemeCollection.js
12250
+ function createThemeCollection(options) {
12251
+ const descriptors = [];
12252
+ const seen = /* @__PURE__ */ new Set();
12253
+ for (const entry of getCollectionEntries(options.themes)) {
12254
+ const themes = isThemeCollectionSource(entry) ? entry.getThemes() : [entry];
12255
+ for (const descriptor of themes) {
12256
+ if (seen.has(descriptor.name)) throw new Error(`Theme collection already contains theme "${descriptor.name}"`);
12257
+ seen.add(descriptor.name);
12258
+ descriptors.push(descriptor);
12259
+ }
12260
+ }
12261
+ const allThemes = Object.freeze([...descriptors]);
12262
+ const lightThemes = Object.freeze(allThemes.filter((descriptor) => descriptor.colorScheme === "light"));
12263
+ const darkThemes = Object.freeze(allThemes.filter((descriptor) => descriptor.colorScheme === "dark"));
12264
+ const themesByName = new Map(allThemes.map((descriptor) => [descriptor.name, descriptor]));
12265
+ const allNames = Object.freeze(allThemes.map((descriptor) => descriptor.name));
12266
+ const lightNames = Object.freeze(lightThemes.map((descriptor) => descriptor.name));
12267
+ const darkNames = Object.freeze(darkThemes.map((descriptor) => descriptor.name));
12268
+ function filteredThemes(filterOptions) {
12269
+ if (filterOptions == null) return allThemes;
12270
+ const { colorScheme, collection } = filterOptions;
12271
+ if (collection == null) {
12272
+ if (colorScheme === "light") return lightThemes;
12273
+ if (colorScheme === "dark") return darkThemes;
12274
+ return allThemes;
12275
+ }
12276
+ return allThemes.filter((descriptor) => {
12277
+ if (descriptor.collection !== collection) return false;
12278
+ return colorScheme == null || descriptor.colorScheme === colorScheme;
12279
+ });
12280
+ }
12281
+ return {
12282
+ getTheme(name) {
12283
+ return themesByName.get(name);
12284
+ },
12285
+ getThemes(themeOptions) {
12286
+ return filteredThemes(themeOptions);
12287
+ },
12288
+ getThemeNames(namesOptions) {
12289
+ if (namesOptions?.collection == null) {
12290
+ if (namesOptions?.colorScheme === "light") return lightNames;
12291
+ if (namesOptions?.colorScheme === "dark") return darkNames;
12292
+ return allNames;
12293
+ }
12294
+ return filteredThemes(namesOptions).map((descriptor) => descriptor.name);
12295
+ },
12296
+ hasTheme(name) {
12297
+ return themesByName.has(name);
12298
+ },
12299
+ orderBy(compare) {
12300
+ return createThemeCollection({ themes: allThemes.map((descriptor, index) => ({
12301
+ descriptor,
12302
+ index
12303
+ })).sort((a$1, b$2) => {
12304
+ const result = compare(a$1.descriptor, b$2.descriptor);
12305
+ if (result !== 0) return result;
12306
+ return a$1.index - b$2.index;
12307
+ }).map((entry) => entry.descriptor) });
12308
+ },
12309
+ pick(names) {
12310
+ const picked = [];
12311
+ const pickedNames = /* @__PURE__ */ new Set();
12312
+ for (const name of names) {
12313
+ if (pickedNames.has(name)) throw new Error(`Theme collection pick already includes theme "${name}"`);
12314
+ pickedNames.add(name);
12315
+ const descriptor = themesByName.get(name);
12316
+ if (descriptor == null) throw new Error(`Theme collection does not contain theme "${name}"`);
12317
+ picked.push(descriptor);
12318
+ }
12319
+ return createThemeCollection({ themes: picked });
12320
+ },
12321
+ registerInto(resolver) {
12322
+ for (const descriptor of allThemes) resolver.registerThemeIfAbsent(descriptor.name, descriptor.load);
12323
+ }
12324
+ };
12325
+ }
12326
+ function getCollectionEntries(input) {
12327
+ if (isThemeCollectionEntry(input)) return [input];
12328
+ return input;
12329
+ }
12330
+ function isThemeCollectionEntry(input) {
12331
+ return isThemeCollectionSource(input) || isThemeDescriptor(input);
12332
+ }
12333
+ function isThemeDescriptor(input) {
12334
+ return typeof input.name === "string" && typeof input.load === "function";
12335
+ }
12336
+ function isThemeCollectionSource(entry) {
12337
+ return typeof entry.getThemes === "function";
12338
+ }
12339
+
12340
+ //#endregion
12341
+ //#region ../theming/dist/modules/createThemeCatalog.js
12342
+ function createThemeCatalog(options) {
12343
+ const collection = createThemeCollection({ themes: options.themes });
12344
+ if (!collection.hasTheme(options.defaultLightThemeName)) throw new Error(`Default light theme "${options.defaultLightThemeName}" is not in the catalog`);
12345
+ if (!collection.hasTheme(options.defaultDarkThemeName)) throw new Error(`Default dark theme "${options.defaultDarkThemeName}" is not in the catalog`);
12346
+ return {
12347
+ ...collection,
12348
+ defaultLightThemeName: options.defaultLightThemeName,
12349
+ defaultDarkThemeName: options.defaultDarkThemeName
12350
+ };
12351
+ }
12352
+
12353
+ //#endregion
12354
+ //#region ../theming/dist/modules/unwrapDefault.js
12355
+ function unwrapDefault(value) {
12356
+ return value !== null && typeof value === "object" && "default" in value ? value.default : value;
12357
+ }
12358
+
12359
+ //#endregion
12360
+ //#region ../theming/dist/modules/createThemeResolver.js
12361
+ var DuplicateThemeError = class extends Error {
12362
+ constructor(name) {
12363
+ super(`Theme "${name}" is already registered`);
12364
+ this.name = "DuplicateThemeError";
12365
+ }
12366
+ };
12367
+ var UnregisteredThemeError = class extends Error {
12368
+ constructor(name) {
12369
+ super(`No loader registered for theme "${name}"`);
12370
+ this.name = "UnregisteredThemeError";
12371
+ }
12372
+ };
12373
+ var UnresolvedThemeError = class extends Error {
12374
+ constructor(name) {
12375
+ super(`Theme "${name}" has not been resolved`);
12376
+ this.name = "UnresolvedThemeError";
12377
+ }
12378
+ };
12379
+ function createThemeResolver() {
12380
+ const loaders = /* @__PURE__ */ new Map();
12381
+ const resolved = /* @__PURE__ */ new Map();
12382
+ const inflight = /* @__PURE__ */ new Map();
12383
+ let cacheGeneration = 0;
12384
+ function registerTheme(name, loader) {
12385
+ if (loaders.has(name)) throw new DuplicateThemeError(name);
12386
+ loaders.set(name, loader);
12387
+ }
12388
+ function registerThemeIfAbsent(name, loader) {
12389
+ if (loaders.has(name)) return false;
12390
+ loaders.set(name, loader);
12391
+ return true;
12392
+ }
12393
+ function hasRegisteredTheme(name) {
12394
+ return loaders.has(name);
12395
+ }
12396
+ function resolveTheme(name) {
12397
+ const cached = resolved.get(name);
12398
+ if (cached !== void 0) return Promise.resolve(cached);
12399
+ const existing = inflight.get(name);
12400
+ if (existing !== void 0) return existing;
12401
+ const loader = loaders.get(name);
12402
+ if (loader === void 0) return Promise.reject(new UnregisteredThemeError(name));
12403
+ const generation = cacheGeneration;
12404
+ const promise = loader().then((result) => {
12405
+ const theme = unwrapDefault(result);
12406
+ if (generation === cacheGeneration) resolved.set(name, theme);
12407
+ if (inflight.get(name) === promise) inflight.delete(name);
12408
+ return theme;
12409
+ }).catch((err) => {
12410
+ if (inflight.get(name) === promise) inflight.delete(name);
12411
+ throw err;
12412
+ });
12413
+ inflight.set(name, promise);
12414
+ return promise;
12415
+ }
12416
+ function resolveThemes$1(names) {
12417
+ return Promise.all(names.map((name) => resolveTheme(name)));
12418
+ }
12419
+ function seedResolvedTheme(name, theme) {
12420
+ resolved.set(name, theme);
12421
+ }
12422
+ function seedResolvedThemes(entries) {
12423
+ for (const [name, theme] of entries) seedResolvedTheme(name, theme);
12424
+ }
12425
+ function getResolvedTheme(name) {
12426
+ return resolved.get(name);
12427
+ }
12428
+ function getResolvedThemes(names) {
12429
+ const themes = [];
12430
+ for (const name of names) {
12431
+ const theme = resolved.get(name);
12432
+ if (theme === void 0) throw new UnresolvedThemeError(name);
12433
+ themes.push(theme);
12434
+ }
12435
+ return themes;
12436
+ }
12437
+ function hasResolvedTheme(name) {
12438
+ return resolved.has(name);
12439
+ }
12440
+ function hasResolvedThemes(names) {
12441
+ for (const name of names) if (!resolved.has(name)) return false;
12442
+ return true;
12443
+ }
12444
+ function getResolvedOrResolveTheme(name) {
12445
+ const cached = resolved.get(name);
12446
+ if (cached !== void 0) return cached;
12447
+ return resolveTheme(name);
12448
+ }
12449
+ function clearResolvedThemes() {
12450
+ cacheGeneration++;
12451
+ resolved.clear();
12452
+ inflight.clear();
12453
+ }
12454
+ return {
12455
+ clearResolvedThemes,
12456
+ getResolvedOrResolveTheme,
12457
+ getResolvedTheme,
12458
+ getResolvedThemes,
12459
+ hasRegisteredTheme,
12460
+ hasResolvedTheme,
12461
+ hasResolvedThemes,
12462
+ registerTheme,
12463
+ registerThemeIfAbsent,
12464
+ resolveTheme,
12465
+ resolveThemes: resolveThemes$1,
12466
+ seedResolvedTheme,
12467
+ seedResolvedThemes
12468
+ };
12469
+ }
12470
+
12471
+ //#endregion
12472
+ //#region ../theming/dist/modules/createThemeController.js
12473
+ const FALLBACK_LIGHT_THEME = "pierre-light";
12474
+ const FALLBACK_DARK_THEME = "pierre-dark";
12475
+ function getStorage() {
12476
+ try {
12477
+ if (typeof globalThis !== "undefined" && globalThis.localStorage != null) return globalThis.localStorage;
12478
+ } catch {}
12479
+ }
12480
+ function createLocalStorageAdapter(storageKey, defaults) {
12481
+ return {
12482
+ load() {
12483
+ const raw$1 = getStorage()?.getItem(storageKey);
12484
+ if (raw$1 == null) return null;
12485
+ try {
12486
+ const parsed = JSON.parse(raw$1);
12487
+ if (parsed.mode == null) return null;
12488
+ return {
12489
+ darkThemeName: parsed.darkThemeName ?? defaults.darkThemeName,
12490
+ lightThemeName: parsed.lightThemeName ?? defaults.lightThemeName,
12491
+ mode: parsed.mode
12492
+ };
12493
+ } catch {
12494
+ return null;
12495
+ }
12496
+ },
12497
+ save(selection) {
12498
+ const storage = getStorage();
12499
+ try {
12500
+ storage?.setItem(storageKey, JSON.stringify(selection));
12501
+ } catch {}
12502
+ }
12503
+ };
12504
+ }
12505
+ function systemPrefersDark() {
12506
+ try {
12507
+ if (typeof globalThis !== "undefined" && globalThis.matchMedia != null) return globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
12508
+ } catch {}
12509
+ return false;
12510
+ }
12511
+ function resolveColorScheme(mode) {
12512
+ if (mode === "dark") return "dark";
12513
+ if (mode === "light") return "light";
12514
+ return systemPrefersDark() ? "dark" : "light";
12515
+ }
12516
+ function createThemeController(options) {
12517
+ const { storageKey, preloadInactive = false } = options;
12518
+ const catalog = "catalog" in options && options.catalog != null ? options.catalog : void 0;
12519
+ const selectedResolver = options.resolver ?? (catalog != null ? createThemeResolver() : void 0);
12520
+ if (selectedResolver == null) throw new Error("createThemeController requires a catalog or resolver");
12521
+ const resolver = selectedResolver;
12522
+ catalog?.registerInto(resolver);
12523
+ const defaultDarkThemeName = options.defaultDarkThemeName ?? catalog?.defaultDarkThemeName ?? FALLBACK_DARK_THEME;
12524
+ const defaultLightThemeName = options.defaultLightThemeName ?? catalog?.defaultLightThemeName ?? FALLBACK_LIGHT_THEME;
12525
+ const persistence = options.persistence ?? (storageKey != null ? createLocalStorageAdapter(storageKey, {
12526
+ darkThemeName: defaultDarkThemeName,
12527
+ lightThemeName: defaultLightThemeName
12528
+ }) : void 0);
12529
+ const initialMode = options.defaultMode ?? "system";
12530
+ let state = {
12531
+ darkThemeName: defaultDarkThemeName,
12532
+ lightThemeName: defaultLightThemeName,
12533
+ mode: initialMode,
12534
+ resolvedTheme: void 0,
12535
+ resolvedColorScheme: resolveColorScheme(initialMode)
12536
+ };
12537
+ const listeners = /* @__PURE__ */ new Set();
12538
+ let activeResolutionId = 0;
12539
+ let pendingSelectionPatch;
12540
+ function notify() {
12541
+ for (const listener of listeners) listener();
12542
+ }
12543
+ function hydrateFromStorage() {
12544
+ const loaded = persistence?.load();
12545
+ if (loaded == null) return;
12546
+ state = {
12547
+ ...state,
12548
+ darkThemeName: loaded.darkThemeName,
12549
+ lightThemeName: loaded.lightThemeName,
12550
+ mode: loaded.mode,
12551
+ resolvedColorScheme: resolveColorScheme(loaded.mode)
12552
+ };
12553
+ }
12554
+ function persist() {
12555
+ persistence?.save({
12556
+ darkThemeName: state.darkThemeName,
12557
+ lightThemeName: state.lightThemeName,
12558
+ mode: state.mode
12559
+ });
12560
+ }
12561
+ function activeThemeNameFor(selection) {
12562
+ return selection.resolvedColorScheme === "dark" ? selection.darkThemeName : selection.lightThemeName;
12563
+ }
12564
+ function intendedState(patch = {}) {
12565
+ return {
12566
+ ...state,
12567
+ ...pendingSelectionPatch,
12568
+ ...patch
12569
+ };
12570
+ }
12571
+ function reportResolutionError(error, context) {
12572
+ if (options.onResolutionError != null) {
12573
+ options.onResolutionError(error, context);
12574
+ return;
12575
+ }
12576
+ console.error(`[theming] Failed to resolve theme "${context.name}" for ${context.colorScheme} color scheme`, error);
12577
+ }
12578
+ function preloadInactiveFor(selection) {
12579
+ if (!preloadInactive) return;
12580
+ const activeName = activeThemeNameFor(selection);
12581
+ const inactive = selection.resolvedColorScheme === "dark" ? selection.lightThemeName : selection.darkThemeName;
12582
+ if (inactive !== activeName && resolver.getResolvedTheme(inactive) === void 0) resolver.resolveTheme(inactive).catch(() => {});
12583
+ }
12584
+ function resolveActive(patch = {}, { notifyPending = false, persistOnSuccess = false } = {}) {
12585
+ const selectionPatch = {
12586
+ ...pendingSelectionPatch,
12587
+ ...patch
12588
+ };
12589
+ const next = intendedState(patch);
12590
+ const name = activeThemeNameFor(next);
12591
+ const colorScheme = next.resolvedColorScheme;
12592
+ const cached = resolver.getResolvedTheme(name);
12593
+ if (cached !== void 0) {
12594
+ activeResolutionId++;
12595
+ pendingSelectionPatch = void 0;
12596
+ state = {
12597
+ ...state,
12598
+ ...selectionPatch,
12599
+ pendingThemeResolution: void 0,
12600
+ resolutionError: void 0,
12601
+ resolvedTheme: cached
12602
+ };
12603
+ if (persistOnSuccess) persist();
12604
+ notify();
12605
+ preloadInactiveFor(state);
12606
+ return;
12607
+ }
12608
+ const resolutionId = ++activeResolutionId;
12609
+ pendingSelectionPatch = selectionPatch;
12610
+ state = {
12611
+ ...state,
12612
+ pendingThemeResolution: {
12613
+ colorScheme,
12614
+ name
12615
+ },
12616
+ resolutionError: void 0
12617
+ };
12618
+ if (notifyPending) notify();
12619
+ resolver.resolveTheme(name).then((theme) => {
12620
+ if (resolutionId !== activeResolutionId) return;
12621
+ const latestIntended = intendedState();
12622
+ if (latestIntended.resolvedColorScheme !== colorScheme || activeThemeNameFor(latestIntended) !== name) return;
12623
+ const patchToCommit = pendingSelectionPatch ?? {};
12624
+ pendingSelectionPatch = void 0;
12625
+ state = {
12626
+ ...state,
12627
+ ...patchToCommit,
12628
+ pendingThemeResolution: void 0,
12629
+ resolutionError: void 0,
12630
+ resolvedTheme: theme
12631
+ };
12632
+ if (persistOnSuccess) persist();
12633
+ notify();
12634
+ preloadInactiveFor(state);
12635
+ }).catch((error) => {
12636
+ if (resolutionId !== activeResolutionId) return;
12637
+ pendingSelectionPatch = void 0;
12638
+ state = {
12639
+ ...state,
12640
+ pendingThemeResolution: void 0,
12641
+ resolutionError: {
12642
+ colorScheme,
12643
+ error,
12644
+ name
12645
+ }
12646
+ };
12647
+ reportResolutionError(error, {
12648
+ colorScheme,
12649
+ name
12650
+ });
12651
+ notify();
12652
+ });
12653
+ }
12654
+ function updateInactiveThemeName(key$1, name) {
12655
+ state = {
12656
+ ...state,
12657
+ [key$1]: name,
12658
+ resolutionError: void 0
12659
+ };
12660
+ persist();
12661
+ notify();
12662
+ preloadInactiveFor(state);
12663
+ }
12664
+ function isSchemeActiveInIntendedState(scheme, patch = {}) {
12665
+ return intendedState(patch).resolvedColorScheme === scheme;
12666
+ }
12667
+ function setActiveSelection(patch) {
12668
+ resolveActive(patch, {
12669
+ notifyPending: true,
12670
+ persistOnSuccess: true
12671
+ });
12672
+ }
12673
+ function setInactiveThemeName(scheme, key$1, name) {
12674
+ if (isSchemeActiveInIntendedState(scheme, { [key$1]: name })) setActiveSelection({ [key$1]: name });
12675
+ else updateInactiveThemeName(key$1, name);
12676
+ }
12677
+ function setMode(mode) {
12678
+ setActiveSelection({
12679
+ mode,
12680
+ resolvedColorScheme: resolveColorScheme(mode)
12681
+ });
12682
+ }
12683
+ function maybeUpdateSystemColorScheme() {
12684
+ if (intendedState().mode !== "system") return;
12685
+ const next = resolveColorScheme("system");
12686
+ if (next !== intendedState().resolvedColorScheme) resolveActive({ resolvedColorScheme: next }, { notifyPending: true });
12687
+ }
12688
+ function isSelectedValue(key$1, value) {
12689
+ return intendedState()[key$1] === value;
12690
+ }
12691
+ let mediaQuery;
12692
+ const handleMediaChange = () => {
12693
+ maybeUpdateSystemColorScheme();
12694
+ };
12695
+ function attachMediaListener() {
12696
+ try {
12697
+ if (typeof globalThis !== "undefined" && globalThis.matchMedia != null) {
12698
+ mediaQuery = globalThis.matchMedia("(prefers-color-scheme: dark)");
12699
+ mediaQuery.addEventListener("change", handleMediaChange);
12700
+ }
12701
+ } catch {}
12702
+ }
12703
+ hydrateFromStorage();
12704
+ attachMediaListener();
12705
+ resolveActive();
12706
+ return {
12707
+ resolver,
12708
+ destroy() {
12709
+ if (mediaQuery != null) {
12710
+ mediaQuery.removeEventListener("change", handleMediaChange);
12711
+ mediaQuery = void 0;
12712
+ }
12713
+ listeners.clear();
12714
+ },
12715
+ getState() {
12716
+ return state;
12717
+ },
12718
+ setColorMode(mode) {
12719
+ if (isSelectedValue("mode", mode)) return;
12720
+ setMode(mode);
12721
+ },
12722
+ setThemeNameForScheme(scheme, name) {
12723
+ const key$1 = scheme === "light" ? "lightThemeName" : "darkThemeName";
12724
+ if (isSelectedValue(key$1, name)) return;
12725
+ setInactiveThemeName(scheme, key$1, name);
12726
+ },
12727
+ subscribe(listener) {
12728
+ listeners.add(listener);
12729
+ return () => {
12730
+ listeners.delete(listener);
12731
+ };
12732
+ }
12733
+ };
12734
+ }
12735
+
12736
+ //#endregion
12737
+ //#region src/highlighter/themes/themeResolver.ts
12738
+ const themeResolver = createThemeResolver();
12739
+
12239
12740
  //#endregion
12240
12741
  //#region src/highlighter/themes/attachResolvedThemes.ts
12241
12742
  function attachResolvedThemes(themes, highlighter$1) {
@@ -12243,15 +12744,15 @@ function attachResolvedThemes(themes, highlighter$1) {
12243
12744
  for (let themeRef of themes) {
12244
12745
  let resolvedTheme;
12245
12746
  if (typeof themeRef === "string") {
12246
- resolvedTheme = ResolvedThemes.get(themeRef);
12747
+ resolvedTheme = themeResolver.getResolvedTheme(themeRef);
12247
12748
  if (resolvedTheme == null) {
12248
12749
  throw new Error(`loadResolvedThemes: ${themeRef} is not resolved, you must resolve it before calling loadResolvedThemes`);
12249
12750
  }
12250
12751
  } else {
12251
12752
  resolvedTheme = themeRef;
12252
12753
  themeRef = themeRef.name;
12253
- if (!ResolvedThemes.has(themeRef)) {
12254
- ResolvedThemes.set(themeRef, resolvedTheme);
12754
+ if (themeResolver.getResolvedTheme(themeRef) == null) {
12755
+ themeResolver.seedResolvedTheme(themeRef, resolvedTheme);
12255
12756
  }
12256
12757
  }
12257
12758
  if (AttachedThemes.has(themeRef)) continue;
@@ -14061,7 +14562,10 @@ function cleanLastNewline(contents) {
14061
14562
  }
14062
14563
 
14063
14564
  //#endregion
14064
- //#region ../../node_modules/.bun/@shikijs+transformers@4.0.2/node_modules/@shikijs/transformers/dist/index.mjs
14565
+ //#region ../../node_modules/.bun/@shikijs+transformers@4.2.0/node_modules/@shikijs/transformers/dist/index.mjs
14566
+ const RE_SPLIT_COMMENT = /(\s+\/\/)/;
14567
+ const RE_V1_END_COMMENT_PREFIX = /(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/;
14568
+ const RE_V3_END_COMMENT_PREFIX = /(?:\/\/|#|;{1,2}|%{1,2}|--)(\s*)$/;
14065
14569
  /**
14066
14570
  * some comment formats have to be located at the end of line
14067
14571
  * hence we can skip matching them for other tokens
@@ -14087,7 +14591,7 @@ function parseComments(lines, jsx, matchAlgorithm) {
14087
14591
  if (token$1.type !== "text") return element$1;
14088
14592
  const isLast = idx === line.children.length - 1;
14089
14593
  if (!matchToken(token$1.value, isLast)) return element$1;
14090
- const rawSplits = token$1.value.split(/(\s+\/\/)/);
14594
+ const rawSplits = token$1.value.split(RE_SPLIT_COMMENT);
14091
14595
  if (rawSplits.length <= 1) return element$1;
14092
14596
  let splits = [rawSplits[0]];
14093
14597
  for (let i$2 = 1; i$2 < rawSplits.length; i$2 += 2) splits.push(rawSplits[i$2] + (rawSplits[i$2 + 1] || ""));
@@ -14193,12 +14697,22 @@ function matchToken(text$1, isLast) {
14193
14697
  * For matchAlgorithm v1
14194
14698
  */
14195
14699
  function v1ClearEndCommentPrefix(text$1) {
14196
- const match = text$1.match(/(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/);
14700
+ const match = text$1.match(RE_V1_END_COMMENT_PREFIX);
14197
14701
  if (match && match[1].trim().length === 0) return text$1.slice(0, match.index);
14198
14702
  return text$1;
14199
14703
  }
14704
+ /**
14705
+ * Remove empty comment prefixes at line end, e.g. `// `
14706
+ *
14707
+ * For matchAlgorithm v3
14708
+ */
14709
+ function v3ClearEndCommentPrefix(text$1) {
14710
+ const match = text$1.match(RE_V3_END_COMMENT_PREFIX);
14711
+ if (match && match[1].trim().length === 0) return text$1.slice(0, match.index).trimEnd();
14712
+ return text$1;
14713
+ }
14200
14714
  function createCommentNotationTransformer(name, regex, onMatch, matchAlgorithm) {
14201
- if (matchAlgorithm == null) matchAlgorithm = "v3";
14715
+ matchAlgorithm ??= "v3";
14202
14716
  return {
14203
14717
  name,
14204
14718
  code(code) {
@@ -14222,6 +14736,7 @@ function createCommentNotationTransformer(name, regex, onMatch, matchAlgorithm)
14222
14736
  });
14223
14737
  if (!replaced) continue;
14224
14738
  if (matchAlgorithm === "v1") comment$1.info[1] = v1ClearEndCommentPrefix(comment$1.info[1]);
14739
+ else if (matchAlgorithm === "v3") comment$1.info[1] = v3ClearEndCommentPrefix(comment$1.info[1]);
14225
14740
  const isEmpty = comment$1.info[1].trim().length === 0;
14226
14741
  if (isEmpty) comment$1.info[1] = "";
14227
14742
  if (isEmpty && comment$1.isLineCommentOnly) linesToRemove.push(comment$1.line);
@@ -14267,9 +14782,10 @@ function transformerCompactLineOptions(lineOptions = []) {
14267
14782
  }
14268
14783
  };
14269
14784
  }
14785
+ const RE_HIGHLIGHT_LINES = /\{([\d,-]+)\}/;
14270
14786
  function parseMetaHighlightString(meta) {
14271
14787
  if (!meta) return null;
14272
- const match = meta.match(/\{([\d,-]+)\}/);
14788
+ const match = meta.match(RE_HIGHLIGHT_LINES);
14273
14789
  if (!match) return null;
14274
14790
  return match[1].split(",").flatMap((v$1) => {
14275
14791
  const range$1 = v$1.split("-").map((n) => Number.parseInt(n, 10));
@@ -14295,9 +14811,11 @@ function transformerMetaHighlight(options = {}) {
14295
14811
  }
14296
14812
  };
14297
14813
  }
14814
+ const RE_WORD_MATCH = /\/((?:\\.|[^/])+)\//g;
14815
+ const RE_ESCAPE_BACKSLASH = /\\(.)/g;
14298
14816
  function parseMetaHighlightWords(meta) {
14299
14817
  if (!meta) return [];
14300
- return Array.from(meta.matchAll(/\/((?:\\.|[^/])+)\//g)).map((v$1) => v$1[1].replace(/\\(.)/g, "$1"));
14818
+ return [...meta.matchAll(RE_WORD_MATCH)].map((v$1) => v$1[1].replace(RE_ESCAPE_BACKSLASH, "$1"));
14301
14819
  }
14302
14820
  /**
14303
14821
  * Allow using `/word/` in the code snippet meta to mark highlighted words.
@@ -14333,8 +14851,9 @@ function findAllSubstringIndexes(str, substr) {
14333
14851
  }
14334
14852
  return indexes;
14335
14853
  }
14854
+ const RE_ESCAPE_SPECIAL = /[.*+?^${}()|[\]\\]/g;
14336
14855
  function escapeRegExp(str) {
14337
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
14856
+ return str.replace(RE_ESCAPE_SPECIAL, "\\$&");
14338
14857
  }
14339
14858
  function transformerNotationMap(options = {}, name = "@shikijs/transformers:notation-map") {
14340
14859
  const { classMap = {}, classActivePre = void 0, classActiveCode = void 0 } = options;
@@ -14466,11 +14985,13 @@ function inheritElement(original, overrides) {
14466
14985
  ...overrides
14467
14986
  };
14468
14987
  }
14988
+ const RE_CODE_WORD = /\s*\[!code word:((?:\\.|[^:\]])+)(:\d+)?\]/;
14989
+ const RE_UNESCAPE = /\\(.)/g;
14469
14990
  function transformerNotationWordHighlight(options = {}) {
14470
14991
  const { classActiveWord = "highlighted-word", classActivePre = void 0 } = options;
14471
- return createCommentNotationTransformer("@shikijs/transformers:notation-highlight-word", /\s*\[!code word:((?:\\.|[^:\]])+)(:\d+)?\]/, function([_$2, word, range$1], _line, comment$1, lines, index) {
14992
+ return createCommentNotationTransformer("@shikijs/transformers:notation-highlight-word", RE_CODE_WORD, function([_$2, word, range$1], _line, comment$1, lines, index) {
14472
14993
  const lineNum = range$1 ? Number.parseInt(range$1.slice(1), 10) : lines.length;
14473
- word = word.replace(/\\(.)/g, "$1");
14994
+ word = word.replace(RE_UNESCAPE, "$1");
14474
14995
  for (let i$2 = index; i$2 < Math.min(index + lineNum, lines.length); i$2++) highlightWordInLine.call(this, lines[i$2], comment$1, word, classActiveWord);
14475
14996
  if (classActivePre) this.addClassToHast(this.pre, classActivePre);
14476
14997
  return true;
@@ -14532,6 +15053,8 @@ function transformerRemoveNotationEscape() {
14532
15053
  }
14533
15054
  };
14534
15055
  }
15056
+ const RE_INDENT_META = /\{indent:(\d+|false)\}/;
15057
+ const RE_NON_BLANK = /[^ \t]/;
14535
15058
  /**
14536
15059
  * Render indentations as separate tokens.
14537
15060
  * Apply with CSS, it can be used to render indent guides visually.
@@ -14540,7 +15063,7 @@ function transformerRenderIndentGuides(options = {}) {
14540
15063
  return {
14541
15064
  name: "@shikijs/transformers:render-indent-guides",
14542
15065
  code(hast) {
14543
- const indent = Number(this.options.meta?.indent ?? this.options.meta?.__raw?.match(/\{indent:(\d+|false)\}/)?.[1] ?? options.indent ?? 2);
15066
+ const indent = Number(this.options.meta?.indent ?? this.options.meta?.__raw?.match(RE_INDENT_META)?.[1] ?? options.indent ?? 2);
14544
15067
  if (Number.isNaN(indent) || indent <= 0) return hast;
14545
15068
  const indentRegex = new RegExp(` {${indent}}| {0,${indent - 1}}\t| {1,}$`, "g");
14546
15069
  const emptyLines = [];
@@ -14553,7 +15076,7 @@ function transformerRenderIndentGuides(options = {}) {
14553
15076
  continue;
14554
15077
  }
14555
15078
  const text$1 = first.children[0];
14556
- const blanks = text$1.value.split(/[^ \t]/, 1)[0];
15079
+ const blanks = text$1.value.split(RE_NON_BLANK, 1)[0];
14557
15080
  const ranges = [];
14558
15081
  for (const match of blanks.matchAll(indentRegex)) {
14559
15082
  const start = match.index;
@@ -14628,6 +15151,7 @@ function splitSpaces(parts, type, renderContinuousSpaces = true) {
14628
15151
  ...parts.slice(parts.length - rightCount)
14629
15152
  ];
14630
15153
  }
15154
+ const RE_SPACE_OR_TAB = /([ \t])/;
14631
15155
  /**
14632
15156
  * Render whitespaces as separate tokens.
14633
15157
  * Apply with CSS, it can be used to render tabs and spaces visually.
@@ -14655,7 +15179,7 @@ function transformerRenderWhitespace(options = {}) {
14655
15179
  if (position === "leading" && index !== 0) return token$1;
14656
15180
  const node = token$1.children[0];
14657
15181
  if (node.type !== "text" || !node.value) return token$1;
14658
- const parts = splitSpaces(node.value.split(/([ \t])/).filter((i$2) => i$2.length), position === "boundary" && index === last && last !== 0 ? "trailing" : position, position !== "trailing" && position !== "leading");
15182
+ const parts = splitSpaces(node.value.split(RE_SPACE_OR_TAB).filter((i$2) => i$2.length), position === "boundary" && index === last && last !== 0 ? "trailing" : position, position !== "trailing" && position !== "leading");
14659
15183
  if (parts.length <= 1) return token$1;
14660
15184
  return parts.map((part) => {
14661
15185
  const clone$1 = {
@@ -15046,30 +15570,234 @@ function formatCSSVariablePrefix(type) {
15046
15570
  return `--${type === "token" ? "diffs-token" : "diffs"}-`;
15047
15571
  }
15048
15572
 
15573
+ //#endregion
15574
+ //#region ../theming/dist/modules/color.js
15575
+ /**
15576
+ * Canonical color/contrast primitives
15577
+ */
15578
+ const MIN_READABLE_RATIO = 3;
15579
+ const MIN_MUTED_RATIO = 4.5;
15580
+ const HEX_TRANSPARENT_RE = /^#(?:[0-9a-f]{3}0|[0-9a-f]{6}00)$/i;
15581
+ const ALPHA_ZERO_RE = /^0(?:\.0+)?%?$/;
15582
+ function getFunctionalAlpha(color) {
15583
+ const openParen = color.indexOf("(");
15584
+ if (openParen <= 0 || !color.endsWith(")")) return;
15585
+ const fn = color.slice(0, openParen).trim();
15586
+ if (!/^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)$/i.test(fn)) return;
15587
+ const inner = color.slice(openParen + 1, -1).trim();
15588
+ if (inner.length === 0) return;
15589
+ const slashIndex = inner.lastIndexOf("/");
15590
+ if (slashIndex !== -1) return inner.slice(slashIndex + 1).trim();
15591
+ if (/^(?:rgba|hsla)$/i.test(fn)) {
15592
+ const parts = inner.split(",");
15593
+ if (parts.length === 4) return parts[3]?.trim();
15594
+ }
15595
+ }
15596
+ function parseHexRgba(color) {
15597
+ const match = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.exec(color.trim());
15598
+ if (match == null) return null;
15599
+ const hex = match[1];
15600
+ let expanded;
15601
+ let alpha = 1;
15602
+ if (hex.length === 3) expanded = hex.split("").map((c) => c + c).join("");
15603
+ else if (hex.length === 6) expanded = hex;
15604
+ else {
15605
+ expanded = hex.slice(0, 6);
15606
+ alpha = parseInt(hex.slice(6, 8), 16) / 255;
15607
+ }
15608
+ return [
15609
+ parseInt(expanded.slice(0, 2), 16),
15610
+ parseInt(expanded.slice(2, 4), 16),
15611
+ parseInt(expanded.slice(4, 6), 16),
15612
+ alpha
15613
+ ];
15614
+ }
15615
+ function relativeLuminance(color) {
15616
+ if (color == null) return null;
15617
+ const rgba = parseHexRgba(color);
15618
+ if (rgba == null) return null;
15619
+ const r$3 = rgba[0] / 255;
15620
+ const g = rgba[1] / 255;
15621
+ const b$2 = rgba[2] / 255;
15622
+ const channel = (v$1) => v$1 <= .03928 ? v$1 / 12.92 : ((v$1 + .055) / 1.055) ** 2.4;
15623
+ return .2126 * channel(r$3) + .7152 * channel(g) + .0722 * channel(b$2);
15624
+ }
15625
+ function contrastRatio(a$1, b$2) {
15626
+ const [hi, lo] = a$1 > b$2 ? [a$1, b$2] : [b$2, a$1];
15627
+ return (hi + .05) / (lo + .05);
15628
+ }
15629
+ function compositeOverBg(fgColor, bgColor) {
15630
+ if (bgColor == null) return void 0;
15631
+ const fgParts = parseHexRgba(fgColor);
15632
+ const bgParts = parseHexRgba(bgColor);
15633
+ if (fgParts == null || bgParts == null) return void 0;
15634
+ const [fr, fg, fb, fa] = fgParts;
15635
+ const [br, bg, bb] = bgParts;
15636
+ return "#" + [
15637
+ Math.round(fr * fa + br * (1 - fa)),
15638
+ Math.round(fg * fa + bg * (1 - fa)),
15639
+ Math.round(fb * fa + bb * (1 - fa))
15640
+ ].map((v$1) => v$1.toString(16).padStart(2, "0")).join("");
15641
+ }
15642
+ function isFullyTransparent(color) {
15643
+ if (color == null) return false;
15644
+ const normalized = color.trim().toLowerCase();
15645
+ if (normalized === "transparent") return true;
15646
+ if (HEX_TRANSPARENT_RE.test(normalized)) return true;
15647
+ const alpha = getFunctionalAlpha(normalized);
15648
+ return alpha != null && ALPHA_ZERO_RE.test(alpha);
15649
+ }
15650
+ function isDarkSurface(bg, fgHint) {
15651
+ const fromBg = relativeLuminance(bg);
15652
+ if (fromBg != null) return fromBg < .4;
15653
+ const fromFg = relativeLuminance(fgHint);
15654
+ return fromFg != null ? fromFg > .6 : false;
15655
+ }
15656
+ function surfacesMatch(a$1, b$2) {
15657
+ if (a$1 == null || b$2 == null) return false;
15658
+ if (a$1.trim().toLowerCase() === b$2.trim().toLowerCase()) return true;
15659
+ const la = relativeLuminance(a$1);
15660
+ const lb = relativeLuminance(b$2);
15661
+ if (la == null || lb == null) return false;
15662
+ return Math.abs(la - lb) < .06;
15663
+ }
15664
+ function hoverWouldEraseText(hover, bg, fg) {
15665
+ if (bg == null || fg == null) return false;
15666
+ const hoverL = relativeLuminance(hover);
15667
+ const bgL = relativeLuminance(bg);
15668
+ const fgL = relativeLuminance(fg);
15669
+ if (hoverL == null || bgL == null || fgL == null) return false;
15670
+ return Math.abs(hoverL - fgL) < Math.abs(hoverL - bgL);
15671
+ }
15672
+ function pickReadableForeground(bg, candidates) {
15673
+ const bgL = relativeLuminance(bg);
15674
+ const firstDefined = candidates.find((candidate) => candidate != null && candidate !== "");
15675
+ if (bgL == null) return firstDefined;
15676
+ let best;
15677
+ let bestRatio = -1;
15678
+ for (const candidate of candidates) {
15679
+ if (candidate == null || candidate === "") continue;
15680
+ const candidateL = relativeLuminance(candidate);
15681
+ if (candidateL == null) continue;
15682
+ const ratio = contrastRatio(bgL, candidateL);
15683
+ if (ratio >= MIN_READABLE_RATIO) return candidate;
15684
+ if (ratio > bestRatio) {
15685
+ best = candidate;
15686
+ bestRatio = ratio;
15687
+ }
15688
+ }
15689
+ return best ?? firstDefined;
15690
+ }
15691
+ function deriveMutedFg(primaryFg, bg) {
15692
+ if (bg == null) return primaryFg;
15693
+ const fgParts = parseHexRgba(primaryFg);
15694
+ const bgParts = parseHexRgba(bg);
15695
+ const bgL = relativeLuminance(bg);
15696
+ if (fgParts == null || bgParts == null || bgL == null) return `color-mix(in srgb, ${primaryFg} 70%, ${bg})`;
15697
+ const [fr, fg2, fb] = fgParts;
15698
+ const [br, bg3, bb] = bgParts;
15699
+ for (const weight of [
15700
+ .6,
15701
+ .7,
15702
+ .8,
15703
+ .9
15704
+ ]) {
15705
+ const hex = "#" + [
15706
+ Math.round(fr * weight + br * (1 - weight)),
15707
+ Math.round(fg2 * weight + bg3 * (1 - weight)),
15708
+ Math.round(fb * weight + bb * (1 - weight))
15709
+ ].map((v$1) => v$1.toString(16).padStart(2, "0")).join("");
15710
+ const L$2 = relativeLuminance(hex);
15711
+ if (L$2 != null && contrastRatio(bgL, L$2) >= MIN_MUTED_RATIO) return hex;
15712
+ }
15713
+ return primaryFg;
15714
+ }
15715
+
15716
+ //#endregion
15717
+ //#region ../theming/dist/modules/normalizeThemeColors.js
15718
+ const cache = /* @__PURE__ */ new WeakMap();
15719
+ function normalizeThemeColors(theme) {
15720
+ const cached = cache.get(theme);
15721
+ if (cached != null) return cached;
15722
+ const originalColors = theme.colors ?? {};
15723
+ const colors = { ...originalColors };
15724
+ const editorBackground = originalColors["editor.background"] ?? theme.bg;
15725
+ const editorForeground = originalColors["editor.foreground"] ?? theme.fg;
15726
+ const sidebarBackground = originalColors["sideBar.background"] ?? editorBackground;
15727
+ const sidebarForeground = originalColors["sideBar.foreground"] ?? editorForeground;
15728
+ fill(colors, "editor.background", editorBackground);
15729
+ fill(colors, "editor.foreground", editorForeground);
15730
+ fill(colors, "sideBar.background", sidebarBackground);
15731
+ fill(colors, "sideBar.foreground", sidebarForeground);
15732
+ fill(colors, "input.background", originalColors["input.background"] ?? sidebarBackground);
15733
+ fill(colors, "sideBarSectionHeader.foreground", originalColors["sideBarSectionHeader.foreground"] ?? sidebarForeground);
15734
+ fill(colors, "list.activeSelectionForeground", originalColors["list.activeSelectionForeground"] ?? sidebarForeground);
15735
+ fill(colors, "gitDecoration.addedResourceForeground", firstColor(originalColors["gitDecoration.addedResourceForeground"], originalColors["terminal.ansiGreen"], originalColors["editorGutter.addedBackground"]));
15736
+ fill(colors, "gitDecoration.modifiedResourceForeground", firstColor(originalColors["gitDecoration.modifiedResourceForeground"], originalColors["terminal.ansiBlue"], originalColors["editorGutter.modifiedBackground"]));
15737
+ fill(colors, "gitDecoration.deletedResourceForeground", firstColor(originalColors["gitDecoration.deletedResourceForeground"], originalColors["terminal.ansiRed"], originalColors["editorGutter.deletedBackground"]));
15738
+ const focusRing = (isFullyTransparent(originalColors["list.focusOutline"]) ? void 0 : originalColors["list.focusOutline"]) ?? (isFullyTransparent(originalColors["focusBorder"]) ? void 0 : originalColors["focusBorder"]);
15739
+ if (focusRing != null) colors["list.focusOutline"] = focusRing;
15740
+ else delete colors["list.focusOutline"];
15741
+ const hover = originalColors["list.hoverBackground"];
15742
+ if (hover != null && (matchesSurface(hover, sidebarBackground) || hoverWouldEraseText(hover, sidebarBackground, sidebarForeground))) delete colors["list.hoverBackground"];
15743
+ const result = Object.freeze({
15744
+ ...theme,
15745
+ colors: Object.freeze(colors)
15746
+ });
15747
+ cache.set(theme, result);
15748
+ return result;
15749
+ }
15750
+ function fill(colors, key$1, value) {
15751
+ if (value != null && value !== "") colors[key$1] = value;
15752
+ }
15753
+ function firstColor(...candidates) {
15754
+ for (const candidate of candidates) if (candidate != null && candidate !== "") return candidate;
15755
+ }
15756
+ function matchesSurface(color, surface) {
15757
+ return surface != null && color.toLowerCase() === surface.toLowerCase();
15758
+ }
15759
+
15760
+ //#endregion
15761
+ //#region ../theming/dist/color.js
15762
+ const colorUtils = {
15763
+ compositeOverBg,
15764
+ contrastRatio,
15765
+ deriveMutedFg,
15766
+ hoverWouldEraseText,
15767
+ isDarkSurface,
15768
+ isFullyTransparent,
15769
+ pickReadableForeground,
15770
+ relativeLuminance,
15771
+ surfacesMatch
15772
+ };
15773
+
15049
15774
  //#endregion
15050
15775
  //#region src/utils/getHighlighterThemeStyles.ts
15051
15776
  function getHighlighterThemeStyles({ theme = DEFAULT_THEMES, highlighter: highlighter$1, prefix }) {
15052
15777
  let styles = "";
15053
15778
  if (typeof theme === "string") {
15054
15779
  const themeData = highlighter$1.getTheme(theme);
15055
- styles += `color:${themeData.fg};`;
15056
- styles += `background-color:${themeData.bg};`;
15057
- styles += `${formatCSSVariablePrefix("global")}fg:${themeData.fg};`;
15058
- styles += `${formatCSSVariablePrefix("global")}bg:${themeData.bg};`;
15059
- styles += getThemeVariables(themeData, prefix);
15780
+ const normalized = normalizeThemeColors(themeData);
15781
+ styles += `color:${normalized.fg};`;
15782
+ styles += `background-color:${normalized.bg};`;
15783
+ styles += `${formatCSSVariablePrefix("global")}fg:${normalized.fg};`;
15784
+ styles += `${formatCSSVariablePrefix("global")}bg:${normalized.bg};`;
15785
+ styles += getGitVariables(themeData, prefix);
15060
15786
  } else {
15061
15787
  let themeData = highlighter$1.getTheme(theme.dark);
15062
- styles += `${formatCSSVariablePrefix("global")}dark:${themeData.fg};`;
15063
- styles += `${formatCSSVariablePrefix("global")}dark-bg:${themeData.bg};`;
15064
- styles += getThemeVariables(themeData, "dark");
15788
+ let normalized = normalizeThemeColors(themeData);
15789
+ styles += `${formatCSSVariablePrefix("global")}dark:${normalized.fg};`;
15790
+ styles += `${formatCSSVariablePrefix("global")}dark-bg:${normalized.bg};`;
15791
+ styles += getGitVariables(themeData, "dark");
15065
15792
  themeData = highlighter$1.getTheme(theme.light);
15066
- styles += `${formatCSSVariablePrefix("global")}light:${themeData.fg};`;
15067
- styles += `${formatCSSVariablePrefix("global")}light-bg:${themeData.bg};`;
15068
- styles += getThemeVariables(themeData, "light");
15793
+ normalized = normalizeThemeColors(themeData);
15794
+ styles += `${formatCSSVariablePrefix("global")}light:${normalized.fg};`;
15795
+ styles += `${formatCSSVariablePrefix("global")}light-bg:${normalized.bg};`;
15796
+ styles += getGitVariables(themeData, "light");
15069
15797
  }
15070
15798
  return styles;
15071
15799
  }
15072
- function getThemeVariables(themeData, modePrefix) {
15800
+ function getGitVariables(themeData, modePrefix) {
15073
15801
  modePrefix = modePrefix != null ? `${modePrefix}-` : "";
15074
15802
  let styles = "";
15075
15803
  const additionGreen = themeData.colors?.["gitDecoration.addedResourceForeground"] ?? themeData.colors?.["terminal.ansiGreen"];
@@ -16438,7 +17166,7 @@ function getHighlighter(preferredHighlighter = "shiki-js") {
16438
17166
  highlighter ??= createHighlighterCore({
16439
17167
  themes: [],
16440
17168
  langs: [],
16441
- engine: preferredHighlighter === "shiki-wasm" ? createOnigurumaEngine(import("./wasm-BaDzIkIn.js")) : createJavaScriptRegexEngine()
17169
+ engine: preferredHighlighter === "shiki-wasm" ? createOnigurumaEngine(import("./wasm-qE0LgnY3.js")) : createJavaScriptRegexEngine()
16442
17170
  });
16443
17171
  return highlighter;
16444
17172
  }