@b4moss/hyogen-md 0.12.0 → 0.13.0

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 (83) hide show
  1. package/README.md +23 -2
  2. package/README_ja.md +23 -2
  3. package/dist/build/build.d.ts +2 -0
  4. package/dist/build/buildDependencyGraph.d.ts +22 -0
  5. package/dist/build/collectDependencies.d.ts +8 -0
  6. package/dist/build/collectEntryPaths.d.ts +10 -0
  7. package/dist/build/isUnderscorePartial.d.ts +4 -0
  8. package/dist/cli.js +5587 -0
  9. package/dist/client.js +1022 -895
  10. package/dist/component/ComponentRegistry.d.ts +11 -0
  11. package/dist/component/parsePropsContract.d.ts +10 -0
  12. package/dist/component/renderComponent.d.ts +17 -0
  13. package/dist/component/validateProps.d.ts +7 -0
  14. package/dist/config/defineConfig.d.ts +5 -0
  15. package/dist/config/index.d.ts +3 -0
  16. package/dist/config/index.js +143 -0
  17. package/dist/config/loadConfig.d.ts +13 -0
  18. package/dist/config/types.d.ts +26 -0
  19. package/dist/context/mergeContext.d.ts +3 -0
  20. package/dist/control/StructureNestTracker.d.ts +14 -0
  21. package/dist/control/expandControlStructures.d.ts +3 -0
  22. package/dist/control/parseControlOpener.d.ts +2 -0
  23. package/dist/control/parseControlStructures.d.ts +2 -0
  24. package/dist/createError-WZmAl05N.js +30 -0
  25. package/dist/errors/createError.d.ts +7 -0
  26. package/dist/errors/formatDiagnosticLog.d.ts +6 -0
  27. package/dist/errors/formatMessage.d.ts +3 -0
  28. package/dist/expr/evaluateExpression.d.ts +4 -0
  29. package/dist/expr/interpolateExpressions.d.ts +4 -0
  30. package/dist/expr/parseExpression.d.ts +4 -0
  31. package/dist/frontmatter/parseFrontMatter.d.ts +3 -0
  32. package/dist/include/VisitStack.d.ts +13 -0
  33. package/dist/include/expandIncludes.d.ts +18 -0
  34. package/dist/index.d.ts +11 -113
  35. package/dist/index.js +753 -625
  36. package/dist/io/createFsLoader.d.ts +6 -0
  37. package/dist/io/createNodeLoader.d.ts +4 -0
  38. package/dist/io/isRemotePath.d.ts +2 -0
  39. package/dist/io/loadDataSources.d.ts +8 -0
  40. package/dist/io/parseCsvFromString.d.ts +1 -0
  41. package/dist/io/parseDataFile.d.ts +1 -0
  42. package/dist/io/resolveIncludePath.d.ts +1 -0
  43. package/dist/layout/expandExtendsAndBlocks.d.ts +19 -0
  44. package/dist/layout/parseBlockOpener.d.ts +8 -0
  45. package/dist/layout/parseBlockStructures.d.ts +15 -0
  46. package/dist/layout/parseExtendBlock.d.ts +12 -0
  47. package/dist/layout/parseExtendDirective.d.ts +5 -0
  48. package/dist/logic/executeDeclaration.d.ts +6 -0
  49. package/dist/logic/executeDeclarations.d.ts +6 -0
  50. package/dist/logic/executeStatement.d.ts +10 -0
  51. package/dist/logic/hgBlockUtils.d.ts +3 -0
  52. package/dist/logic/parseDeclaration.d.ts +5 -0
  53. package/dist/logic/parseStatement.d.ts +3 -0
  54. package/dist/logic/reservedWords.d.ts +2 -0
  55. package/dist/logic/stripComments.d.ts +2 -0
  56. package/dist/markdown/shiftHeadings.d.ts +25 -0
  57. package/dist/parse/hgMarkers.d.ts +5 -0
  58. package/dist/parse/parseComponentDirective.d.ts +6 -0
  59. package/dist/parse/parseIncludeDirective.d.ts +2 -0
  60. package/dist/parse/scanHgBlocks.d.ts +10 -0
  61. package/dist/paths/assertWithinRootDir.d.ts +2 -0
  62. package/dist/paths/findDocRoot.d.ts +1 -0
  63. package/dist/paths/resolveRenderInput.d.ts +11 -0
  64. package/dist/paths/resolveTemplatePath.d.ts +9 -0
  65. package/dist/pipeline/applyFrontMatterOutputOption.d.ts +4 -0
  66. package/dist/pipeline/executeHgBlocks.d.ts +9 -0
  67. package/dist/pipeline/joinRemovalSeam.d.ts +12 -0
  68. package/dist/pipeline/renderDocument.d.ts +22 -0
  69. package/dist/pipeline/stripHgComments.d.ts +7 -0
  70. package/dist/renderClient.d.ts +15 -0
  71. package/dist/renderServer.d.ts +4 -0
  72. package/dist/security/forbiddenKeys.d.ts +3 -0
  73. package/dist/security/scanSuspiciousContext.d.ts +6 -0
  74. package/dist/shims/fs-browser.d.ts +6 -0
  75. package/dist/shims/fs-promises-browser.d.ts +5 -0
  76. package/dist/toc/expandToc.d.ts +8 -0
  77. package/dist/toc/extractHeadings.d.ts +10 -0
  78. package/dist/toc/formatTocMarkdown.d.ts +7 -0
  79. package/dist/toc/githubHeadingSlug.d.ts +11 -0
  80. package/dist/toc/parseTocDirective.d.ts +10 -0
  81. package/dist/toc/plainifyHeadingText.d.ts +2 -0
  82. package/dist/types.d.ts +211 -0
  83. package/package.json +17 -4
package/dist/index.js CHANGED
@@ -1,48 +1,27 @@
1
- import { stat as ie, readFile as Me, mkdir as Xe, writeFile as Je } from "node:fs/promises";
2
- import p from "node:path";
3
- import { parse as Oe } from "yaml";
4
- import { Readable as Qe } from "node:stream";
5
- import et from "csv-parser";
6
- import { existsSync as ye, statSync as tt } from "node:fs";
7
- import nt from "fast-glob";
8
- import rt from "picomatch";
1
+ import { stat as se, readFile as Oe, mkdir as at, writeFile as ct } from "node:fs/promises";
2
+ import { c as d, f as H, m as lt } from "./createError-WZmAl05N.js";
3
+ import { a as mr } from "./createError-WZmAl05N.js";
4
+ import f from "node:path";
5
+ import { parse as Re } from "yaml";
6
+ import { Readable as ht } from "node:stream";
7
+ import dt from "csv-parser";
8
+ import { existsSync as ke, statSync as ut } from "node:fs";
9
+ import ft from "fast-glob";
10
+ import pt from "picomatch";
9
11
  function v(...t) {
10
12
  const e = {};
11
13
  for (const n of t)
12
14
  n != null && Object.assign(e, n);
13
15
  return e;
14
16
  }
15
- const it = { file_not_found: "File not found: {path} (referenced from {from} via {via})", frontmatter_too_large: "Front matter exceeds size limit in {path} ({size} bytes, limit {limit})", duplicate_component_alias: 'Duplicate component alias "{alias}" in {path}', alias_collision: 'Component alias "{alias}" collides with an existing binding in {path}', forbidden_property_access: 'Forbidden property access "{property}" in {path}', parse_error: "Parse error in {path}: {message}", component_multiline_output: 'Component "{alias}" returned multiline output (single line required)', server_context_on_client: "serverContext is not allowed with renderClient", load_failed: "Failed to load {path}: {reason}", data_sources_on_client: "dataSources is not allowed with renderClient", data_source_too_large: "Data source exceeds size limit in {path} ({size} bytes, limit {limit})" }, st = { circular_include: "Circular reference detected; skipped {path} (referenced from {from} via {via})", nest_limit_exceeded: "Nesting limit exceeded ({limit}); skipped block in {path}", extend_in_component: "extend is not allowed inside a component; skipped in {path}", prop_type_mismatch: 'Prop "{prop}" type mismatch in component "{component}"; expected {expected}, got {actual}', prop_missing: 'Required prop "{prop}" is missing for component "{component}"', prop_unknown: 'Unknown prop "{prop}" passed to component "{component}"; ignored', suspicious_context_value: 'Suspicious value in context key "{key}" ({reason})' }, ot = { contains_html_script_tag: "contains HTML script tag", contains_event_handler: "contains inline event handler", contains_dangerous_scheme: "contains dangerous URL scheme", contains_embed_tag: "contains embeddable HTML tag", contains_meta_refresh: "contains meta refresh" }, se = {
16
- errors: it,
17
- warnings: st,
18
- warningReasons: ot
19
- }, at = se.errors, ct = se.warnings;
20
- function Le(t, e) {
21
- return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n, r) => {
22
- if (e === void 0 || !(r in e))
23
- return n;
24
- const i = e[r];
25
- return i == null ? "" : String(i);
26
- });
27
- }
28
- function lt(t, e) {
29
- return Le(at[t], e);
30
- }
31
- function L(t, e) {
32
- return Le(ct[t], e);
33
- }
34
- function d(t) {
35
- const e = t.message ?? lt(t.code, t.details), n = new Error(e);
36
- return n.name = "HyogenError", n.code = t.code, n.message = e, n.path = t.path, n.details = t.details, n;
37
- }
38
- function ht(t) {
17
+ function mt(t) {
39
18
  return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
40
19
  }
41
- function dt(t = {}) {
20
+ function Me(t = {}) {
42
21
  const { from: e, via: n = "include" } = t;
43
22
  return async (r) => {
44
23
  try {
45
- if (!(await ie(r)).isFile())
24
+ if (!(await se(r)).isFile())
46
25
  throw d({
47
26
  code: "load_failed",
48
27
  path: e,
@@ -51,9 +30,9 @@ function dt(t = {}) {
51
30
  reason: "not a file"
52
31
  }
53
32
  });
54
- return await Me(r, "utf8");
33
+ return await Oe(r, "utf8");
55
34
  } catch (i) {
56
- if (ht(i))
35
+ if (mt(i))
57
36
  throw i;
58
37
  const s = i;
59
38
  throw s.code === "ENOENT" ? d({
@@ -75,21 +54,43 @@ function dt(t = {}) {
75
54
  }
76
55
  };
77
56
  }
78
- function H(t) {
57
+ function N(t) {
79
58
  return /^https?:\/\//i.test(t);
80
59
  }
81
- function ut(t) {
60
+ function gt(t) {
82
61
  return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
83
62
  }
84
- function oe(t = {}) {
85
- const { from: e, via: n = "include" } = t, r = dt(t);
63
+ function He(t = {}) {
64
+ const { from: e, via: n = "include" } = t, r = Me(t);
86
65
  return async (i) => {
87
- if (!H(i))
66
+ if (!N(i))
88
67
  return r(i);
68
+ let s;
89
69
  try {
90
- const s = await fetch(i);
91
- if (!s.ok)
92
- throw s.status === 404 ? d({
70
+ s = new URL(i);
71
+ } catch {
72
+ throw d({
73
+ code: "load_failed",
74
+ path: e,
75
+ details: {
76
+ path: i,
77
+ reason: "invalid remote URL"
78
+ }
79
+ });
80
+ }
81
+ if (s.protocol !== "http:" && s.protocol !== "https:")
82
+ throw d({
83
+ code: "load_failed",
84
+ path: e,
85
+ details: {
86
+ path: i,
87
+ reason: `unsupported protocol: ${s.protocol}`
88
+ }
89
+ });
90
+ try {
91
+ const o = await fetch(s);
92
+ if (!o.ok)
93
+ throw o.status === 404 ? d({
93
94
  code: "file_not_found",
94
95
  path: e,
95
96
  details: {
@@ -102,44 +103,44 @@ function oe(t = {}) {
102
103
  path: e,
103
104
  details: {
104
105
  path: i,
105
- reason: `HTTP ${s.status}`
106
+ reason: `HTTP ${o.status}`
106
107
  }
107
108
  });
108
- return await s.text();
109
- } catch (s) {
110
- if (ut(s))
111
- throw s;
112
- const o = s instanceof Error ? s.message : "unknown fetch error";
109
+ return await o.text();
110
+ } catch (o) {
111
+ if (gt(o))
112
+ throw o;
113
+ const a = o instanceof Error ? o.message : "unknown fetch error";
113
114
  throw d({
114
115
  code: "load_failed",
115
116
  path: e,
116
117
  details: {
117
118
  path: i,
118
- reason: o
119
+ reason: a
119
120
  }
120
121
  });
121
122
  }
122
123
  };
123
124
  }
124
- function pt(t) {
125
+ function wt(t) {
125
126
  return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
126
127
  }
127
- function ft(t) {
128
+ function xt(t) {
128
129
  return Object.keys(t).sort((e, n) => Number(e) - Number(n)).map((e) => t[e] ?? "");
129
130
  }
130
- function mt(t) {
131
+ function kt(t) {
131
132
  return t.every((e) => e === "");
132
133
  }
133
- async function gt(t) {
134
+ async function yt(t) {
134
135
  return new Promise((e, n) => {
135
136
  const r = [];
136
- Qe.from([t]).pipe(et({ headers: !1 })).on("data", (i) => {
137
- const s = ft(i);
138
- mt(s) || r.push(s);
137
+ ht.from([t]).pipe(dt({ headers: !1 })).on("data", (i) => {
138
+ const s = xt(i);
139
+ kt(s) || r.push(s);
139
140
  }).on("end", () => e(r)).on("error", (i) => n(i));
140
141
  });
141
142
  }
142
- async function wt(t, e) {
143
+ async function bt(t, e) {
143
144
  if (t.length === 0 || t.trim().length === 0)
144
145
  throw d({
145
146
  code: "parse_error",
@@ -148,9 +149,9 @@ async function wt(t, e) {
148
149
  });
149
150
  let n;
150
151
  try {
151
- n = await gt(t);
152
+ n = await yt(t);
152
153
  } catch (o) {
153
- throw pt(o) ? o : d({
154
+ throw wt(o) ? o : d({
154
155
  code: "parse_error",
155
156
  path: e,
156
157
  details: {
@@ -179,10 +180,10 @@ async function wt(t, e) {
179
180
  return a;
180
181
  });
181
182
  }
182
- function xt(t) {
183
- return p.extname(t).slice(1).toLowerCase();
183
+ function vt(t) {
184
+ return f.extname(t).slice(1).toLowerCase();
184
185
  }
185
- function kt(t, e) {
186
+ function _t(t, e) {
186
187
  if (t.length === 0)
187
188
  throw d({
188
189
  code: "parse_error",
@@ -190,9 +191,9 @@ function kt(t, e) {
190
191
  details: { message: "empty data file" }
191
192
  });
192
193
  }
193
- async function yt(t, e) {
194
- kt(t, e);
195
- const n = xt(e);
194
+ async function St(t, e) {
195
+ _t(t, e);
196
+ const n = vt(e);
196
197
  switch (n) {
197
198
  case "json":
198
199
  try {
@@ -209,7 +210,7 @@ async function yt(t, e) {
209
210
  case "yaml":
210
211
  case "yml":
211
212
  try {
212
- return Oe(t);
213
+ return Re(t);
213
214
  } catch (r) {
214
215
  throw d({
215
216
  code: "parse_error",
@@ -220,7 +221,7 @@ async function yt(t, e) {
220
221
  });
221
222
  }
222
223
  case "csv":
223
- return wt(t, e);
224
+ return bt(t, e);
224
225
  default:
225
226
  throw d({
226
227
  code: "parse_error",
@@ -232,26 +233,26 @@ async function yt(t, e) {
232
233
  });
233
234
  }
234
235
  }
235
- const bt = ".doc_root";
236
- function B(t) {
236
+ const Et = ".doc_root";
237
+ function I(t) {
237
238
  let e;
238
- for (ye(t) ? e = tt(t).isFile() ? p.dirname(t) : p.resolve(t) : e = p.dirname(p.resolve(t)); ; ) {
239
- const n = p.join(e, bt);
240
- if (ye(n))
239
+ for (ke(t) ? e = ut(t).isFile() ? f.dirname(t) : f.resolve(t) : e = f.dirname(f.resolve(t)); ; ) {
240
+ const n = f.join(e, Et);
241
+ if (ke(n))
241
242
  return e;
242
- const r = p.dirname(e);
243
+ const r = f.dirname(e);
243
244
  if (r === e)
244
245
  return;
245
246
  e = r;
246
247
  }
247
248
  }
248
- function vt(t, e) {
249
- const n = p.relative(e, t);
250
- return n === "" || !n.startsWith("..") && !p.isAbsolute(n);
249
+ function Ct(t, e) {
250
+ const n = f.relative(e, t);
251
+ return n === "" || !n.startsWith("..") && !f.isAbsolute(n);
251
252
  }
252
- function _t(t, e, n) {
253
- const r = p.resolve(e), i = p.resolve(t);
254
- if (!vt(i, r))
253
+ function $t(t, e, n) {
254
+ const r = f.resolve(e), i = f.resolve(t);
255
+ if (!Ct(i, r))
255
256
  throw d({
256
257
  code: "parse_error",
257
258
  path: n,
@@ -269,7 +270,7 @@ function Z(t, e = {}) {
269
270
  let a;
270
271
  if (t.startsWith("/"))
271
272
  if (n)
272
- a = p.resolve(n, t.slice(1));
273
+ a = f.resolve(n, t.slice(1));
273
274
  else {
274
275
  if (o)
275
276
  throw d({
@@ -277,8 +278,8 @@ function Z(t, e = {}) {
277
278
  path: i,
278
279
  details: { message: "root-relative paths require a doc root" }
279
280
  });
280
- if (p.isAbsolute(t))
281
- a = p.resolve(t);
281
+ if (f.isAbsolute(t))
282
+ a = f.resolve(t);
282
283
  else
283
284
  throw d({
284
285
  code: "parse_error",
@@ -288,38 +289,38 @@ function Z(t, e = {}) {
288
289
  }
289
290
  else if (t.startsWith("./") || t.startsWith("../"))
290
291
  if (r)
291
- a = p.resolve(p.dirname(r), t);
292
+ a = f.resolve(f.dirname(r), t);
292
293
  else if (n)
293
- a = p.resolve(n, t);
294
+ a = f.resolve(n, t);
294
295
  else
295
296
  throw d({
296
297
  code: "parse_error",
297
298
  path: i,
298
299
  details: { message: "root is required for relative template paths" }
299
300
  });
300
- else if (p.isAbsolute(t))
301
- a = p.resolve(t);
301
+ else if (f.isAbsolute(t))
302
+ a = f.resolve(t);
302
303
  else if (n)
303
- a = p.resolve(n, t);
304
+ a = f.resolve(n, t);
304
305
  else
305
306
  throw d({
306
307
  code: "parse_error",
307
308
  path: i,
308
309
  details: { message: "root is required for relative template paths" }
309
310
  });
310
- return n && s && _t(a, n, i), a;
311
+ return n && s && $t(a, n, i), a;
311
312
  }
312
- const be = 5 * 1024 * 1024;
313
- function St(t) {
313
+ const ye = 5 * 1024 * 1024;
314
+ function Wt(t) {
314
315
  return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
315
316
  }
316
- function Ct(t) {
317
- return t?.root ? p.resolve(t.root) : B(process.cwd()) ?? process.cwd();
317
+ function Tt(t) {
318
+ return t?.root ? f.resolve(t.root) : I(process.cwd()) ?? process.cwd();
318
319
  }
319
- async function He(t, e) {
320
- const n = Ct(e), r = e?.loader ?? oe(), i = {};
320
+ async function Ne(t, e) {
321
+ const n = Tt(e), r = e?.loader ?? Me(), i = {};
321
322
  for (const [s, o] of Object.entries(t)) {
322
- if (H(o))
323
+ if (N(o))
323
324
  throw d({
324
325
  code: "load_failed",
325
326
  path: o,
@@ -333,7 +334,7 @@ async function He(t, e) {
333
334
  try {
334
335
  c = await r(a);
335
336
  } catch (l) {
336
- throw St(l) ? l : d({
337
+ throw Wt(l) ? l : d({
337
338
  code: "load_failed",
338
339
  path: a,
339
340
  details: {
@@ -343,30 +344,30 @@ async function He(t, e) {
343
344
  });
344
345
  }
345
346
  const h = Buffer.byteLength(c, "utf8");
346
- if (h > be)
347
+ if (h > ye)
347
348
  throw d({
348
349
  code: "data_source_too_large",
349
350
  path: a,
350
351
  details: {
351
352
  path: a,
352
353
  size: h,
353
- limit: be
354
+ limit: ye
354
355
  }
355
356
  });
356
- i[s] = await yt(c, a);
357
+ i[s] = await St(c, a);
357
358
  }
358
359
  return i;
359
360
  }
360
- async function Et(t, e) {
361
+ async function At(t, e) {
361
362
  if (typeof t == "string")
362
363
  return {
363
364
  source: t,
364
365
  rootDir: e?.root
365
366
  };
366
- const n = p.resolve(t.path);
367
+ const n = f.resolve(t.path);
367
368
  let r;
368
369
  try {
369
- r = await ie(n);
370
+ r = await se(n);
370
371
  } catch (a) {
371
372
  const c = a;
372
373
  throw c.code === "ENOENT" ? d({
@@ -394,7 +395,7 @@ async function Et(t, e) {
394
395
  });
395
396
  let i;
396
397
  try {
397
- i = await Me(n, "utf8");
398
+ i = await Oe(n, "utf8");
398
399
  } catch (a) {
399
400
  throw d({
400
401
  code: "load_failed",
@@ -405,7 +406,7 @@ async function Et(t, e) {
405
406
  }
406
407
  });
407
408
  }
408
- const s = B(n), o = e?.root ?? s;
409
+ const s = I(n), o = e?.root ?? s;
409
410
  return {
410
411
  source: i,
411
412
  rootDir: o,
@@ -437,8 +438,8 @@ class De {
437
438
  return this.components.has(e);
438
439
  }
439
440
  }
440
- const ve = 64 * 1024;
441
- function V(t, e) {
441
+ const be = 64 * 1024;
442
+ function q(t, e) {
442
443
  if (!t.startsWith("---"))
443
444
  return { context: {}, body: t };
444
445
  const n = t.indexOf(`
@@ -450,13 +451,13 @@ function V(t, e) {
450
451
  if (r === -1)
451
452
  return { context: {}, body: t };
452
453
  const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
453
- if (s > ve)
454
+ if (s > be)
454
455
  throw d({
455
456
  code: "frontmatter_too_large",
456
457
  path: e,
457
458
  details: {
458
459
  size: s,
459
- limit: ve
460
+ limit: be
460
461
  }
461
462
  });
462
463
  if (i.trim().length === 0)
@@ -467,7 +468,7 @@ function V(t, e) {
467
468
  });
468
469
  let o;
469
470
  try {
470
- const h = Oe(i);
471
+ const h = Re(i);
471
472
  if (h == null)
472
473
  o = {};
473
474
  else if (typeof h == "object" && !Array.isArray(h))
@@ -495,14 +496,14 @@ ${i}
495
496
  ---`
496
497
  };
497
498
  }
498
- const $t = /* @__PURE__ */ new Set([
499
+ const Lt = /* @__PURE__ */ new Set([
499
500
  "string",
500
501
  "number",
501
502
  "boolean",
502
503
  "object",
503
504
  "array"
504
505
  ]);
505
- function Wt(t, e) {
506
+ function Ot(t, e) {
506
507
  const n = t.props;
507
508
  if (n === void 0)
508
509
  return {};
@@ -521,13 +522,13 @@ function Wt(t, e) {
521
522
  const o = s, a = {};
522
523
  if ("type" in o && o.type !== void 0) {
523
524
  const c = String(o.type);
524
- $t.has(c) ? a.type = c : a.type = void 0;
525
+ Lt.has(c) ? a.type = c : a.type = void 0;
525
526
  }
526
527
  "isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
527
528
  }
528
529
  return r;
529
530
  }
530
- function Tt(t) {
531
+ function Rt(t) {
531
532
  if (t != null) {
532
533
  if (typeof t == "string") return "string";
533
534
  if (typeof t == "number") return "number";
@@ -536,17 +537,17 @@ function Tt(t) {
536
537
  if (typeof t == "object") return "object";
537
538
  }
538
539
  }
539
- function At(t, e) {
540
+ function Mt(t, e) {
540
541
  return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
541
542
  }
542
543
  function G(t, e) {
543
544
  return {
544
545
  code: t,
545
- message: L(t, e),
546
+ message: H(t, e),
546
547
  details: e
547
548
  };
548
549
  }
549
- function Rt(t, e, n) {
550
+ function Ht(t, e, n) {
550
551
  const r = [], i = {}, s = new Set(Object.keys(e));
551
552
  for (const [o, a] of Object.entries(e)) {
552
553
  const c = Object.prototype.hasOwnProperty.call(t, o);
@@ -557,8 +558,8 @@ function Rt(t, e, n) {
557
558
  component: n
558
559
  })
559
560
  ), h = void 0)), c && h !== void 0 && h !== null) {
560
- const l = a.type ?? Tt(h);
561
- l && !At(h, l) && (r.push(
561
+ const l = a.type ?? Rt(h);
562
+ l && !Mt(h, l) && (r.push(
562
563
  G("prop_type_mismatch", {
563
564
  prop: o,
564
565
  component: n,
@@ -578,7 +579,7 @@ function Rt(t, e, n) {
578
579
  ) : i[o] = t[o]);
579
580
  return { values: i, warnings: r };
580
581
  }
581
- async function Mt(t) {
582
+ async function Nt(t) {
582
583
  const e = t.registry.get(t.alias);
583
584
  if (!e)
584
585
  throw d({
@@ -588,13 +589,13 @@ async function Mt(t) {
588
589
  message: `unregistered component: ${t.alias}`
589
590
  }
590
591
  });
591
- const n = H(e.componentPath) ? e.componentPath : Z(e.componentPath, {
592
+ const n = N(e.componentPath) ? e.componentPath : Z(e.componentPath, {
592
593
  rootDir: t.rootDir,
593
594
  fromPath: e.definedAt,
594
595
  documentPath: t.path,
595
596
  constrainToRoot: t.constrainToRoot,
596
597
  hyogenPath: !0
597
- }), r = await t.loader(n), { context: i, body: s } = V(r, n), o = Wt(i, n), { values: a, warnings: c } = Rt(
598
+ }), r = await t.loader(n), { context: i, body: s } = q(r, n), o = Ot(i, n), { values: a, warnings: c } = Ht(
598
599
  t.props,
599
600
  o,
600
601
  t.alias
@@ -604,7 +605,8 @@ async function Mt(t) {
604
605
  t.parentContext,
605
606
  l,
606
607
  a
607
- ), m = (await xe(s, {
608
+ );
609
+ return (await we(s, {
608
610
  context: u,
609
611
  loader: t.loader,
610
612
  root: t.rootDir,
@@ -617,36 +619,28 @@ async function Mt(t) {
617
619
  preserveHgComments: t.preserveHgComments,
618
620
  constrainToRoot: t.constrainToRoot
619
621
  })).trim();
620
- if (m.includes(`
621
- `))
622
- throw d({
623
- code: "component_multiline_output",
624
- path: n,
625
- details: { alias: t.alias }
626
- });
627
- return m;
628
622
  }
629
- const Ot = /* @__PURE__ */ new Set([
623
+ const Dt = /* @__PURE__ */ new Set([
630
624
  "__proto__",
631
625
  "prototype",
632
626
  "constructor",
633
627
  "__defineGetter__"
634
628
  ]);
635
- function Lt(t) {
636
- return Ot.has(t);
629
+ function Ft(t) {
630
+ return Dt.has(t);
637
631
  }
638
- function _e(t, e) {
639
- if (Lt(t))
632
+ function ve(t, e) {
633
+ if (Ft(t))
640
634
  throw d({
641
635
  code: "forbidden_property_access",
642
636
  path: e,
643
637
  details: { property: t }
644
638
  });
645
639
  }
646
- function M(t) {
640
+ function R(t) {
647
641
  return !t;
648
642
  }
649
- function Ht(t, e) {
643
+ function jt(t, e) {
650
644
  if (t != null) {
651
645
  if (typeof t == "string")
652
646
  return e === "length" ? t.length : void 0;
@@ -654,7 +648,7 @@ function Ht(t, e) {
654
648
  return t[e];
655
649
  }
656
650
  }
657
- function Dt(t, e, n) {
651
+ function Bt(t, e, n) {
658
652
  switch (t) {
659
653
  case "+":
660
654
  return e + n;
@@ -681,44 +675,44 @@ function Dt(t, e, n) {
681
675
  case "<":
682
676
  return e < n;
683
677
  case "&&":
684
- return M(e) ? e : n;
678
+ return R(e) ? e : n;
685
679
  case "||":
686
- return M(e) ? n : e;
680
+ return R(e) ? n : e;
687
681
  default:
688
682
  return;
689
683
  }
690
684
  }
691
- async function k(t, e) {
685
+ async function y(t, e) {
692
686
  const { context: n, path: r } = e;
693
687
  switch (t.type) {
694
688
  case "literal":
695
689
  return t.value;
696
690
  case "identifier":
697
- return _e(t.name, r), n[t.name];
691
+ return ve(t.name, r), n[t.name];
698
692
  case "member": {
699
- _e(t.property, r);
700
- const i = await k(t.object, e);
701
- return Ht(i, t.property);
693
+ ve(t.property, r);
694
+ const i = await y(t.object, e);
695
+ return jt(i, t.property);
702
696
  }
703
697
  case "default": {
704
- const i = await k(t.left, e);
705
- return M(i) ? k(t.right, e) : i;
698
+ const i = await y(t.left, e);
699
+ return R(i) ? y(t.right, e) : i;
706
700
  }
707
701
  case "unary": {
708
- const i = await k(t.operand, e);
702
+ const i = await y(t.operand, e);
709
703
  return t.op === "!" ? !i : void 0;
710
704
  }
711
705
  case "binary": {
712
706
  if (t.op === "&&") {
713
- const o = await k(t.left, e);
714
- return M(o) ? o : k(t.right, e);
707
+ const o = await y(t.left, e);
708
+ return R(o) ? o : y(t.right, e);
715
709
  }
716
710
  if (t.op === "||") {
717
- const o = await k(t.left, e);
718
- return M(o) ? k(t.right, e) : o;
711
+ const o = await y(t.left, e);
712
+ return R(o) ? y(t.right, e) : o;
719
713
  }
720
- const i = await k(t.left, e), s = await k(t.right, e);
721
- return Dt(t.op, i, s);
714
+ const i = await y(t.left, e), s = await y(t.right, e);
715
+ return Bt(t.op, i, s);
722
716
  }
723
717
  case "call": {
724
718
  if (!e.registry || !e.loader || !e.visitStack)
@@ -739,8 +733,8 @@ async function k(t, e) {
739
733
  });
740
734
  const i = {};
741
735
  for (const [s, o] of Object.entries(t.args))
742
- i[s] = await k(o, e);
743
- return Mt({
736
+ i[s] = await y(o, e);
737
+ return Nt({
744
738
  alias: t.callee,
745
739
  props: i,
746
740
  parentContext: e.parentContext ?? n,
@@ -761,14 +755,14 @@ async function k(t, e) {
761
755
  path: r,
762
756
  details: { message: `unsupported method: ${t.method}()` }
763
757
  });
764
- const i = await k(t.object, e);
758
+ const i = await y(t.object, e);
765
759
  return i == null || typeof i.toLocaleString != "function" ? void 0 : i.toLocaleString(
766
760
  ...t.args
767
761
  );
768
762
  }
769
763
  case "ternary": {
770
- const i = await k(t.condition, e);
771
- return M(i) ? k(t.alternate, e) : k(t.consequent, e);
764
+ const i = await y(t.condition, e);
765
+ return R(i) ? y(t.alternate, e) : y(t.consequent, e);
772
766
  }
773
767
  case "template": {
774
768
  let i = "";
@@ -776,7 +770,7 @@ async function k(t, e) {
776
770
  if (typeof s == "string")
777
771
  i += s;
778
772
  else {
779
- const o = await k(s, e);
773
+ const o = await y(s, e);
780
774
  o != null && (i += String(o));
781
775
  }
782
776
  return i;
@@ -785,29 +779,29 @@ async function k(t, e) {
785
779
  return;
786
780
  }
787
781
  }
788
- function X(t) {
782
+ function J(t) {
789
783
  return /[A-Za-z_$]/.test(t);
790
784
  }
791
- function Nt(t) {
785
+ function It(t) {
792
786
  return /[A-Za-z0-9_$]/.test(t);
793
787
  }
794
788
  function S(t, e, n = {}) {
795
789
  const r = t.trim();
796
790
  if (r.length === 0)
797
- throw g(e, "empty expression");
798
- const i = new Ft(r, e, n), s = i.parseExpression();
791
+ throw m(e, "empty expression");
792
+ const i = new Ut(r, e, n), s = i.parseExpression();
799
793
  if (i.skipWhitespace(), i.hasMore())
800
- throw g(e, `unexpected token at position ${i.position}`);
794
+ throw m(e, `unexpected token at position ${i.position}`);
801
795
  return s;
802
796
  }
803
- function g(t, e) {
797
+ function m(t, e) {
804
798
  throw d({
805
799
  code: "parse_error",
806
800
  path: t,
807
801
  details: { message: e }
808
802
  });
809
803
  }
810
- class Ft {
804
+ class Ut {
811
805
  constructor(e, n, r = {}) {
812
806
  this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
813
807
  }
@@ -844,7 +838,7 @@ class Ft {
844
838
  this.index++;
845
839
  const n = this.parseTernary();
846
840
  if (this.skipWhitespace(), this.peek() !== ":")
847
- throw g(this.path, "expected ':' in ternary expression");
841
+ throw m(this.path, "expected ':' in ternary expression");
848
842
  this.index++;
849
843
  const r = this.parseTernary();
850
844
  return { type: "ternary", condition: e, consequent: n, alternate: r };
@@ -937,10 +931,10 @@ class Ft {
937
931
  this.skipWhitespace();
938
932
  const n = this.readIdentifier();
939
933
  if (!n)
940
- throw g(this.path, "expected property name after '.'");
934
+ throw m(this.path, "expected property name after '.'");
941
935
  if (this.skipWhitespace(), this.peek() === "(") {
942
936
  if (n !== "toLocaleString")
943
- throw g(this.path, `unsupported method: ${n}()`);
937
+ throw m(this.path, `unsupported method: ${n}()`);
944
938
  this.index++;
945
939
  const r = this.parseMethodArgs();
946
940
  return { type: "method", object: e, method: n, args: r };
@@ -955,7 +949,7 @@ class Ft {
955
949
  for (e.push(this.parseLiteralValue()), this.skipWhitespace(); this.peek() === ","; )
956
950
  this.index++, e.push(this.parseLiteralValue()), this.skipWhitespace();
957
951
  if (this.peek() !== ")")
958
- throw g(this.path, "expected ')' after method arguments");
952
+ throw m(this.path, "expected ')' after method arguments");
959
953
  return this.index++, e;
960
954
  }
961
955
  parsePrimary() {
@@ -965,7 +959,7 @@ class Ft {
965
959
  this.index++;
966
960
  const n = this.parseExpression();
967
961
  if (this.skipWhitespace(), this.peek() !== ")")
968
- throw g(this.path, "expected ')'");
962
+ throw m(this.path, "expected ')'");
969
963
  return this.index++, n;
970
964
  }
971
965
  if (e === "`")
@@ -978,13 +972,13 @@ class Ft {
978
972
  return { type: "literal", value: this.parseObjectLiteral() };
979
973
  if (e === "[")
980
974
  return { type: "literal", value: this.parseArrayLiteral() };
981
- if (X(e)) {
975
+ if (J(e)) {
982
976
  const n = this.readIdentifier();
983
977
  if (n === "true" || n === "false" || n === "null" || n === "undefined")
984
978
  return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
985
979
  if (this.skipWhitespace(), this.peek() === "(") {
986
980
  if (!this.allowCalls)
987
- throw g(
981
+ throw m(
988
982
  this.path,
989
983
  "component calls are not allowed in template literals"
990
984
  );
@@ -993,10 +987,10 @@ class Ft {
993
987
  return { type: "call", callee: n, args: r };
994
988
  }
995
989
  if (this.peek() === "[")
996
- throw g(this.path, "bracket access is not allowed");
990
+ throw m(this.path, "bracket access is not allowed");
997
991
  return { type: "identifier", name: n };
998
992
  }
999
- throw g(this.path, `unexpected character '${e}'`);
993
+ throw m(this.path, `unexpected character '${e}'`);
1000
994
  }
1001
995
  parseTemplateLiteral() {
1002
996
  this.index++;
@@ -1008,7 +1002,7 @@ class Ft {
1008
1002
  return this.index++, e.push(n), { type: "template", parts: e };
1009
1003
  if (r === "\\") {
1010
1004
  if (this.index++, this.index >= this.input.length)
1011
- throw g(this.path, "unterminated template literal escape");
1005
+ throw m(this.path, "unterminated template literal escape");
1012
1006
  n += this.input[this.index], this.index++;
1013
1007
  continue;
1014
1008
  }
@@ -1022,7 +1016,7 @@ class Ft {
1022
1016
  }
1023
1017
  n += r, this.index++;
1024
1018
  }
1025
- throw g(this.path, "unterminated template literal");
1019
+ throw m(this.path, "unterminated template literal");
1026
1020
  }
1027
1021
  readTemplateExpression() {
1028
1022
  let e = 1;
@@ -1056,27 +1050,27 @@ class Ft {
1056
1050
  }
1057
1051
  this.index++;
1058
1052
  }
1059
- throw g(this.path, "unterminated template expression");
1053
+ throw m(this.path, "unterminated template expression");
1060
1054
  }
1061
1055
  parseCallArgs() {
1062
1056
  if (this.skipWhitespace(), this.peek() === ")")
1063
1057
  return this.index++, {};
1064
1058
  if (this.peek() !== "{")
1065
- throw g(this.path, "expected object literal");
1059
+ throw m(this.path, "expected object literal");
1066
1060
  this.index++, this.skipWhitespace();
1067
1061
  const e = {};
1068
1062
  if (this.peek() === "}") {
1069
1063
  if (this.index++, this.skipWhitespace(), this.peek() !== ")")
1070
- throw g(this.path, "expected ')' after call arguments");
1064
+ throw m(this.path, "expected ')' after call arguments");
1071
1065
  return this.index++, e;
1072
1066
  }
1073
1067
  for (; ; ) {
1074
1068
  this.skipWhitespace();
1075
1069
  const n = this.readIdentifier();
1076
1070
  if (!n)
1077
- throw g(this.path, "expected property name in object literal");
1071
+ throw m(this.path, "expected property name in object literal");
1078
1072
  if (this.skipWhitespace(), this.peek() !== ":")
1079
- throw g(this.path, "expected ':' in object literal");
1073
+ throw m(this.path, "expected ':' in object literal");
1080
1074
  if (this.index++, this.skipWhitespace(), e[n] = this.parseTernary(), this.skipWhitespace(), this.peek() === "}") {
1081
1075
  this.index++;
1082
1076
  break;
@@ -1088,15 +1082,15 @@ class Ft {
1088
1082
  }
1089
1083
  continue;
1090
1084
  }
1091
- throw g(this.path, "expected ',' or '}' in object literal");
1085
+ throw m(this.path, "expected ',' or '}' in object literal");
1092
1086
  }
1093
1087
  if (this.skipWhitespace(), this.peek() !== ")")
1094
- throw g(this.path, "expected ')' after call arguments");
1088
+ throw m(this.path, "expected ')' after call arguments");
1095
1089
  return this.index++, e;
1096
1090
  }
1097
1091
  parseObjectLiteral() {
1098
1092
  if (this.peek() !== "{")
1099
- throw g(this.path, "expected object literal");
1093
+ throw m(this.path, "expected object literal");
1100
1094
  this.index++, this.skipWhitespace();
1101
1095
  const e = {};
1102
1096
  if (this.peek() === "}")
@@ -1105,9 +1099,9 @@ class Ft {
1105
1099
  this.skipWhitespace();
1106
1100
  const n = this.readIdentifier();
1107
1101
  if (!n)
1108
- throw g(this.path, "expected property name in object literal");
1102
+ throw m(this.path, "expected property name in object literal");
1109
1103
  if (this.skipWhitespace(), this.peek() !== ":")
1110
- throw g(this.path, "expected ':' in object literal");
1104
+ throw m(this.path, "expected ':' in object literal");
1111
1105
  if (this.index++, this.skipWhitespace(), e[n] = this.parseLiteralValue(), this.skipWhitespace(), this.peek() === "}") {
1112
1106
  this.index++;
1113
1107
  break;
@@ -1118,13 +1112,13 @@ class Ft {
1118
1112
  break;
1119
1113
  }
1120
1114
  } else
1121
- throw g(this.path, "expected ',' or '}' in object literal");
1115
+ throw m(this.path, "expected ',' or '}' in object literal");
1122
1116
  }
1123
1117
  return e;
1124
1118
  }
1125
1119
  parseArrayLiteral() {
1126
1120
  if (this.peek() !== "[")
1127
- throw g(this.path, "expected array literal");
1121
+ throw m(this.path, "expected array literal");
1128
1122
  this.index++, this.skipWhitespace();
1129
1123
  const e = [];
1130
1124
  if (this.peek() === "]")
@@ -1140,7 +1134,7 @@ class Ft {
1140
1134
  break;
1141
1135
  }
1142
1136
  } else
1143
- throw g(this.path, "expected ',' or ']' in array literal");
1137
+ throw m(this.path, "expected ',' or ']' in array literal");
1144
1138
  }
1145
1139
  return e;
1146
1140
  }
@@ -1155,14 +1149,14 @@ class Ft {
1155
1149
  return this.parseObjectLiteral();
1156
1150
  if (e === "[")
1157
1151
  return this.parseArrayLiteral();
1158
- if (X(e)) {
1152
+ if (J(e)) {
1159
1153
  const n = this.readIdentifier();
1160
1154
  if (n === "true") return !0;
1161
1155
  if (n === "false") return !1;
1162
1156
  if (n === "null") return null;
1163
- throw g(this.path, "object literal values must be literals");
1157
+ throw m(this.path, "object literal values must be literals");
1164
1158
  }
1165
- throw g(this.path, "object literal values must be literals");
1159
+ throw m(this.path, "object literal values must be literals");
1166
1160
  }
1167
1161
  match(e) {
1168
1162
  return this.skipWhitespace(), this.input.startsWith(e, this.index) ? (this.index += e.length, !0) : !1;
@@ -1173,9 +1167,9 @@ class Ft {
1173
1167
  readIdentifier() {
1174
1168
  this.skipWhitespace();
1175
1169
  const e = this.index;
1176
- if (!X(this.peek()))
1170
+ if (!J(this.peek()))
1177
1171
  return "";
1178
- for (this.index++; this.index < this.input.length && Nt(this.peek()); )
1172
+ for (this.index++; this.index < this.input.length && It(this.peek()); )
1179
1173
  this.index++;
1180
1174
  return this.input.slice(e, this.index);
1181
1175
  }
@@ -1189,14 +1183,14 @@ class Ft {
1189
1183
  return this.index++, n;
1190
1184
  if (r === "\\") {
1191
1185
  if (this.index++, this.index >= this.input.length)
1192
- throw g(this.path, "unterminated string escape");
1186
+ throw m(this.path, "unterminated string escape");
1193
1187
  const i = this.input[this.index];
1194
1188
  n += i, this.index++;
1195
1189
  continue;
1196
1190
  }
1197
1191
  n += r, this.index++;
1198
1192
  }
1199
- throw g(this.path, "unterminated string literal");
1193
+ throw m(this.path, "unterminated string literal");
1200
1194
  }
1201
1195
  readNumber() {
1202
1196
  const e = this.index;
@@ -1204,11 +1198,140 @@ class Ft {
1204
1198
  this.index++;
1205
1199
  const n = this.input.slice(e, this.index), r = Number(n);
1206
1200
  if (Number.isNaN(r))
1207
- throw g(this.path, `invalid number '${n}'`);
1201
+ throw m(this.path, `invalid number '${n}'`);
1208
1202
  return r;
1209
1203
  }
1210
1204
  }
1211
- async function Ne(t, e, n = {}) {
1205
+ const zt = /^( {0,3})(=+|-+)[ \t]*$/, Fe = /^( {0,3})(`{3,}|~{3,})(.*)$/;
1206
+ function O(t) {
1207
+ return t === " " || t === " ";
1208
+ }
1209
+ function je(t) {
1210
+ let e = 0;
1211
+ for (; e < t.length && e < 3 && t[e] === " "; )
1212
+ e += 1;
1213
+ const n = t.slice(0, e);
1214
+ let r = 0;
1215
+ for (; e < t.length && r < 6 && t[e] === "#"; )
1216
+ r += 1, e += 1;
1217
+ if (r === 0 || r === 6 && e < t.length && t[e] === "#")
1218
+ return null;
1219
+ if (e >= t.length)
1220
+ return { indent: n, level: r, text: "" };
1221
+ if (!O(t[e]))
1222
+ return null;
1223
+ for (; e < t.length && O(t[e]); )
1224
+ e += 1;
1225
+ let i = t.length;
1226
+ for (; i > e && O(t[i - 1]); )
1227
+ i -= 1;
1228
+ let s = i;
1229
+ if (i > e && t[i - 1] === "#") {
1230
+ let o = i - 1;
1231
+ for (; o > e && t[o - 1] === "#"; )
1232
+ o -= 1;
1233
+ if (o > e && O(t[o - 1])) {
1234
+ let a = o - 1;
1235
+ for (; a >= e && O(t[a]); )
1236
+ a -= 1;
1237
+ s = a + 1;
1238
+ }
1239
+ }
1240
+ return { indent: n, level: r, text: t.slice(e, s) };
1241
+ }
1242
+ function Be() {
1243
+ return { active: !1, marker: null, length: 0 };
1244
+ }
1245
+ function Ie(t, e) {
1246
+ const n = Fe.exec(e);
1247
+ if (!t.active) {
1248
+ if (n) {
1249
+ const r = n[2];
1250
+ return t.active = !0, t.marker = r[0], t.length = r.length, !0;
1251
+ }
1252
+ return !1;
1253
+ }
1254
+ if (n) {
1255
+ const r = n[2], i = (n[3] ?? "").trim();
1256
+ r[0] === t.marker && r.length >= t.length && i.length === 0 && (t.active = !1, t.marker = null, t.length = 0);
1257
+ }
1258
+ return !0;
1259
+ }
1260
+ function Ue(t) {
1261
+ const e = je(t);
1262
+ return e ? e.level : null;
1263
+ }
1264
+ function ze(t) {
1265
+ const e = zt.exec(t);
1266
+ return e ? e[2][0] === "=" ? 1 : 2 : null;
1267
+ }
1268
+ function Vt(t) {
1269
+ for (let e = 0; e < t.length; e++)
1270
+ if (!O(t[e]))
1271
+ return !1;
1272
+ return !0;
1273
+ }
1274
+ function Ve(t) {
1275
+ return !(Vt(t) || Ue(t) !== null || Fe.test(t) || t.startsWith(" ") || t.startsWith(" "));
1276
+ }
1277
+ function Ze(t) {
1278
+ const e = t.split(`
1279
+ `), n = Be();
1280
+ let r = 0;
1281
+ for (let i = 0; i < e.length; i++) {
1282
+ const s = e[i];
1283
+ if (Ie(n, s))
1284
+ continue;
1285
+ const o = Ue(s);
1286
+ if (o !== null) {
1287
+ r = o;
1288
+ continue;
1289
+ }
1290
+ const a = ze(s);
1291
+ if (a !== null && i > 0) {
1292
+ const c = e[i - 1];
1293
+ Ve(c) && (r = a);
1294
+ }
1295
+ }
1296
+ return r;
1297
+ }
1298
+ function Zt(t) {
1299
+ return t < 1 ? 1 : t > 6 ? 6 : t;
1300
+ }
1301
+ function _e(t, e) {
1302
+ const n = e.trim(), r = "#".repeat(Zt(t));
1303
+ return n.length === 0 ? r : `${r} ${n}`;
1304
+ }
1305
+ function qe(t, e) {
1306
+ if (e <= 0 || t.length === 0)
1307
+ return t;
1308
+ const n = t.split(`
1309
+ `), r = Be(), i = [];
1310
+ for (let s = 0; s < n.length; s++) {
1311
+ const o = n[s];
1312
+ if (Ie(r, o)) {
1313
+ i.push(o);
1314
+ continue;
1315
+ }
1316
+ const a = ze(o);
1317
+ if (a !== null && i.length > 0) {
1318
+ const h = i[i.length - 1];
1319
+ if (Ve(h)) {
1320
+ i[i.length - 1] = _e(a + e, h);
1321
+ continue;
1322
+ }
1323
+ }
1324
+ const c = je(o);
1325
+ if (c !== null) {
1326
+ i.push(c.indent + _e(c.level + e, c.text));
1327
+ continue;
1328
+ }
1329
+ i.push(o);
1330
+ }
1331
+ return i.join(`
1332
+ `);
1333
+ }
1334
+ async function Pe(t, e, n = {}) {
1212
1335
  const r = n.path;
1213
1336
  let i = "", s = 0;
1214
1337
  for (; s < t.length; ) {
@@ -1230,17 +1353,22 @@ async function Ne(t, e, n = {}) {
1230
1353
  path: r,
1231
1354
  details: { message: "unclosed expression" }
1232
1355
  });
1233
- const w = t.slice(o + h, u).trim(), m = S(w, r), f = await k(m, {
1356
+ const g = t.slice(o + h, u).trim(), w = S(g, r), p = await y(w, {
1234
1357
  ...n,
1235
1358
  context: e,
1236
1359
  path: r,
1237
1360
  parentContext: n.parentContext ?? e
1238
1361
  });
1239
- i += f == null ? "" : String(f), s = u + l.length;
1362
+ let x = p == null ? "" : String(p);
1363
+ if (w.type === "call" && x.length > 0) {
1364
+ const $ = Ze(i);
1365
+ x = qe(x, $);
1366
+ }
1367
+ i += x, s = u + l.length;
1240
1368
  }
1241
1369
  return i;
1242
1370
  }
1243
- function jt(t, e) {
1371
+ function qt(t, e) {
1244
1372
  let n = 0, r = 0;
1245
1373
  for (; r < t.length; ) {
1246
1374
  const i = t.indexOf(e, r);
@@ -1250,14 +1378,14 @@ function jt(t, e) {
1250
1378
  }
1251
1379
  return n;
1252
1380
  }
1253
- function ae(t) {
1254
- const e = t.includes("@hg"), n = t.includes("@endhg"), r = jt(t, "@@");
1381
+ function oe(t) {
1382
+ const e = t.includes("@hg"), n = t.includes("@endhg"), r = qt(t, "@@");
1255
1383
  return e && n ? r > 0 ? "mixed" : "hg" : r >= 2 && !e && !n ? "at-at" : (e || n) && r > 0 ? "mixed" : e && !n || r === 1 && !n ? "unclosed" : "none";
1256
1384
  }
1257
- function ce(t) {
1385
+ function ae(t) {
1258
1386
  return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
1259
1387
  }
1260
- function le(t, e) {
1388
+ function ce(t, e) {
1261
1389
  let n = 0, r = !1;
1262
1390
  for (; n < e; ) {
1263
1391
  const i = t.indexOf("```", n);
@@ -1267,21 +1395,21 @@ function le(t, e) {
1267
1395
  }
1268
1396
  return r;
1269
1397
  }
1270
- function $(t) {
1398
+ function W(t) {
1271
1399
  const e = [];
1272
1400
  let n = 0;
1273
1401
  for (; n < t.length; ) {
1274
1402
  const r = t.indexOf("<!--", n);
1275
1403
  if (r === -1)
1276
1404
  break;
1277
- if (le(t, r)) {
1405
+ if (ce(t, r)) {
1278
1406
  n = r + 4;
1279
1407
  continue;
1280
1408
  }
1281
1409
  const i = t.indexOf("-->", r + 4);
1282
1410
  if (i === -1)
1283
1411
  break;
1284
- const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = ae(o);
1412
+ const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = oe(o);
1285
1413
  (a === "hg" || a === "at-at") && e.push({
1286
1414
  start: r,
1287
1415
  end: i + 3,
@@ -1291,40 +1419,40 @@ function $(t) {
1291
1419
  }
1292
1420
  return e;
1293
1421
  }
1294
- function he(t) {
1422
+ function le(t) {
1295
1423
  let e = 0;
1296
1424
  for (; e < t.length; ) {
1297
1425
  const n = t.indexOf("<!--", e);
1298
1426
  if (n === -1)
1299
1427
  return !1;
1300
- if (le(t, n)) {
1428
+ if (ce(t, n)) {
1301
1429
  e = n + 4;
1302
1430
  continue;
1303
1431
  }
1304
1432
  const r = t.indexOf("-->", n + 4);
1305
1433
  if (r === -1)
1306
1434
  return !1;
1307
- const i = t.slice(n + 4, r), s = ae(i);
1435
+ const i = t.slice(n + 4, r), s = oe(i);
1308
1436
  if (s === "unclosed" || s === "mixed")
1309
1437
  return !0;
1310
1438
  e = r + 3;
1311
1439
  }
1312
1440
  return !1;
1313
1441
  }
1314
- function de(t) {
1442
+ function he(t) {
1315
1443
  let e = 0;
1316
1444
  for (; e < t.length; ) {
1317
1445
  const n = t.indexOf("<!--", e);
1318
1446
  if (n === -1)
1319
1447
  return null;
1320
- if (le(t, n)) {
1448
+ if (ce(t, n)) {
1321
1449
  e = n + 4;
1322
1450
  continue;
1323
1451
  }
1324
1452
  const r = t.indexOf("-->", n + 4);
1325
1453
  if (r === -1)
1326
1454
  return null;
1327
- const i = t.slice(n + 4, r), s = ae(i);
1455
+ const i = t.slice(n + 4, r), s = oe(i);
1328
1456
  if (s === "mixed")
1329
1457
  return "mixed @hg and @@ markers are not allowed";
1330
1458
  if (s === "unclosed")
@@ -1333,25 +1461,25 @@ function de(t) {
1333
1461
  }
1334
1462
  return null;
1335
1463
  }
1336
- function E(t) {
1337
- return ce(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
1464
+ function C(t) {
1465
+ return ae(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
1338
1466
  }
1339
- const Bt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
1340
- function ue(t) {
1341
- return Bt.test(t.trim());
1467
+ const Pt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
1468
+ function de(t) {
1469
+ return Pt.test(t.trim());
1342
1470
  }
1343
- function J(t, e) {
1471
+ function Q(t, e) {
1344
1472
  throw d({
1345
1473
  code: "parse_error",
1346
1474
  path: t,
1347
1475
  details: { message: e }
1348
1476
  });
1349
1477
  }
1350
- function It(t, e) {
1478
+ function Kt(t, e) {
1351
1479
  let n = t;
1352
1480
  const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
1353
1481
  r && (n = r[1]);
1354
- const i = E(n);
1482
+ const i = C(n);
1355
1483
  if (i.length !== 1)
1356
1484
  return null;
1357
1485
  const s = i[0];
@@ -1364,7 +1492,7 @@ function It(t, e) {
1364
1492
  if (s === "endeach")
1365
1493
  return { kind: "endeach" };
1366
1494
  if (/^IF\b/.test(s) || /^ELSE\b/.test(s) || /^ENDIF\b/.test(s))
1367
- throw J(e, "control keywords must be lowercase");
1495
+ throw Q(e, "control keywords must be lowercase");
1368
1496
  const o = /^else\s+if\s+(.+)$/.exec(s);
1369
1497
  if (o)
1370
1498
  return {
@@ -1385,25 +1513,25 @@ function It(t, e) {
1385
1513
  expr: S(c[2], e)
1386
1514
  };
1387
1515
  if (s === "if")
1388
- throw J(e, "if requires an expression");
1516
+ throw Q(e, "if requires an expression");
1389
1517
  if (/^each\s+/.test(s))
1390
- throw J(e, "invalid each directive");
1518
+ throw Q(e, "invalid each directive");
1391
1519
  return null;
1392
1520
  }
1393
- function O(t) {
1521
+ function M(t) {
1394
1522
  return { start: t.start, end: t.end, raw: t.raw };
1395
1523
  }
1396
- function C(t, e) {
1524
+ function E(t, e) {
1397
1525
  throw d({
1398
1526
  code: "parse_error",
1399
1527
  path: t,
1400
1528
  details: { message: e }
1401
1529
  });
1402
1530
  }
1403
- function Ut(t, e) {
1531
+ function Yt(t, e) {
1404
1532
  const n = [];
1405
- for (const r of $(t)) {
1406
- const i = It(r.inner, e);
1533
+ for (const r of W(t)) {
1534
+ const i = Kt(r.inner, e);
1407
1535
  i && n.push({
1408
1536
  start: r.start,
1409
1537
  end: r.end,
@@ -1413,26 +1541,26 @@ function Ut(t, e) {
1413
1541
  }
1414
1542
  return n;
1415
1543
  }
1416
- function Fe(t) {
1544
+ function Ke(t) {
1417
1545
  return t.kind === "if" || t.kind === "each";
1418
1546
  }
1419
- function zt(t, e) {
1420
- const n = Ut(t, e);
1547
+ function Xt(t, e) {
1548
+ const n = Yt(t, e);
1421
1549
  if (n.length === 0)
1422
1550
  return t.length > 0 ? [{ kind: "text", content: t }] : [];
1423
- const { nodes: r, nextIndex: i } = F(t, n, 0, n.length, e);
1551
+ const { nodes: r, nextIndex: i } = j(t, n, 0, n.length, e);
1424
1552
  if (i < n.length) {
1425
1553
  const s = n[i];
1426
1554
  if (s.opener.kind === "endif")
1427
- throw C(e, "endif without matching if");
1555
+ throw E(e, "endif without matching if");
1428
1556
  if (s.opener.kind === "endeach")
1429
- throw C(e, "endeach without matching each");
1557
+ throw E(e, "endeach without matching each");
1430
1558
  if (s.opener.kind === "else" || s.opener.kind === "else_if")
1431
- throw C(e, "else without matching if");
1559
+ throw E(e, "else without matching if");
1432
1560
  }
1433
1561
  return r;
1434
1562
  }
1435
- function F(t, e, n, r, i, s = 0, o) {
1563
+ function j(t, e, n, r, i, s = 0, o) {
1436
1564
  const a = o ?? t.length, c = [];
1437
1565
  let h = s, l = n;
1438
1566
  for (; l < r; ) {
@@ -1447,51 +1575,51 @@ function F(t, e, n, r, i, s = 0, o) {
1447
1575
  kind: "text",
1448
1576
  content: t.slice(h, u.start)
1449
1577
  }), u.opener.kind === "if") {
1450
- const w = Zt(t, e, l, r, i);
1451
- c.push(w.node), h = w.endPos, l = w.nextIndex;
1578
+ const g = Gt(t, e, l, r, i);
1579
+ c.push(g.node), h = g.endPos, l = g.nextIndex;
1452
1580
  continue;
1453
1581
  }
1454
1582
  if (u.opener.kind === "each") {
1455
- const w = Vt(t, e, l, r, i);
1456
- c.push(w.node), h = w.endPos, l = w.nextIndex;
1583
+ const g = Jt(t, e, l, r, i);
1584
+ c.push(g.node), h = g.endPos, l = g.nextIndex;
1457
1585
  continue;
1458
1586
  }
1459
1587
  if (u.opener.kind === "else" || u.opener.kind === "else_if")
1460
- throw C(i, "else without matching if");
1588
+ throw E(i, "else without matching if");
1461
1589
  if (u.opener.kind === "endif")
1462
- throw C(i, "endif without matching if");
1590
+ throw E(i, "endif without matching if");
1463
1591
  if (u.opener.kind === "endeach")
1464
- throw C(i, "endeach without matching each");
1592
+ throw E(i, "endeach without matching each");
1465
1593
  l++;
1466
1594
  }
1467
1595
  return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
1468
1596
  }
1469
- function Zt(t, e, n, r, i) {
1597
+ function Gt(t, e, n, r, i) {
1470
1598
  const s = e[n];
1471
1599
  if (s.opener.kind !== "if")
1472
- throw C(i, "expected if");
1600
+ throw E(i, "expected if");
1473
1601
  const o = [];
1474
1602
  let a = n, c = s.end, h = 0;
1475
1603
  for (; a < r; ) {
1476
1604
  const l = e[a];
1477
1605
  if (a === n) {
1478
1606
  if (l.opener.kind !== "if")
1479
- throw C(i, "expected if");
1607
+ throw E(i, "expected if");
1480
1608
  o.push({
1481
1609
  kind: "if",
1482
1610
  expr: l.opener.expr,
1483
- opener: O(l),
1611
+ opener: M(l),
1484
1612
  body: []
1485
1613
  }), a++;
1486
1614
  continue;
1487
1615
  }
1488
- if (Fe(l.opener)) {
1616
+ if (Ke(l.opener)) {
1489
1617
  h++, a++;
1490
1618
  continue;
1491
1619
  }
1492
1620
  if (l.opener.kind === "endif") {
1493
1621
  if (h === 0)
1494
- return o[o.length - 1].body = F(
1622
+ return o[o.length - 1].body = j(
1495
1623
  t,
1496
1624
  e,
1497
1625
  n + 1,
@@ -1500,7 +1628,7 @@ function Zt(t, e, n, r, i) {
1500
1628
  c,
1501
1629
  l.start
1502
1630
  ).nodes, {
1503
- node: { kind: "if", branches: o, closer: O(l) },
1631
+ node: { kind: "if", branches: o, closer: M(l) },
1504
1632
  nextIndex: a + 1,
1505
1633
  endPos: l.end
1506
1634
  };
@@ -1513,7 +1641,7 @@ function Zt(t, e, n, r, i) {
1513
1641
  }
1514
1642
  if (h === 0) {
1515
1643
  if (l.opener.kind === "else_if") {
1516
- o[o.length - 1].body = F(
1644
+ o[o.length - 1].body = j(
1517
1645
  t,
1518
1646
  e,
1519
1647
  n + 1,
@@ -1524,13 +1652,13 @@ function Zt(t, e, n, r, i) {
1524
1652
  ).nodes, o.push({
1525
1653
  kind: "else_if",
1526
1654
  expr: l.opener.expr,
1527
- opener: O(l),
1655
+ opener: M(l),
1528
1656
  body: []
1529
1657
  }), c = l.end, a++;
1530
1658
  continue;
1531
1659
  }
1532
1660
  if (l.opener.kind === "else") {
1533
- o[o.length - 1].body = F(
1661
+ o[o.length - 1].body = j(
1534
1662
  t,
1535
1663
  e,
1536
1664
  n + 1,
@@ -1540,7 +1668,7 @@ function Zt(t, e, n, r, i) {
1540
1668
  l.start
1541
1669
  ).nodes, o.push({
1542
1670
  kind: "else",
1543
- opener: O(l),
1671
+ opener: M(l),
1544
1672
  body: []
1545
1673
  }), c = l.end, a++;
1546
1674
  continue;
@@ -1548,24 +1676,24 @@ function Zt(t, e, n, r, i) {
1548
1676
  }
1549
1677
  a++;
1550
1678
  }
1551
- throw C(i, "unclosed if block (missing endif)");
1679
+ throw E(i, "unclosed if block (missing endif)");
1552
1680
  }
1553
- function Vt(t, e, n, r, i) {
1681
+ function Jt(t, e, n, r, i) {
1554
1682
  const s = e[n];
1555
1683
  if (s.opener.kind !== "each")
1556
- throw C(i, "expected each");
1684
+ throw E(i, "expected each");
1557
1685
  let o = n + 1;
1558
1686
  const a = s.end;
1559
1687
  let c = 0;
1560
1688
  for (; o < r; ) {
1561
1689
  const h = e[o];
1562
- if (Fe(h.opener)) {
1690
+ if (Ke(h.opener)) {
1563
1691
  c++, o++;
1564
1692
  continue;
1565
1693
  }
1566
1694
  if (h.opener.kind === "endeach") {
1567
1695
  if (c === 0) {
1568
- const l = F(
1696
+ const l = j(
1569
1697
  t,
1570
1698
  e,
1571
1699
  n + 1,
@@ -1579,9 +1707,9 @@ function Vt(t, e, n, r, i) {
1579
1707
  kind: "each",
1580
1708
  item: s.opener.item,
1581
1709
  expr: s.opener.expr,
1582
- opener: O(s),
1710
+ opener: M(s),
1583
1711
  body: l,
1584
- closer: O(h)
1712
+ closer: M(h)
1585
1713
  },
1586
1714
  nextIndex: o + 1,
1587
1715
  endPos: h.end
@@ -1596,10 +1724,10 @@ function Vt(t, e, n, r, i) {
1596
1724
  }
1597
1725
  o++;
1598
1726
  }
1599
- throw C(i, "unclosed each block (missing endeach)");
1727
+ throw E(i, "unclosed each block (missing endeach)");
1600
1728
  }
1601
1729
  const Se = 20;
1602
- class qt {
1730
+ class Qt {
1603
1731
  depth = 0;
1604
1732
  get currentDepth() {
1605
1733
  return this.depth;
@@ -1611,13 +1739,13 @@ class qt {
1611
1739
  this.depth > 0 && this.depth--;
1612
1740
  }
1613
1741
  }
1614
- function Pt(t) {
1742
+ function en(t) {
1615
1743
  return !!t;
1616
1744
  }
1617
- function Kt(t) {
1745
+ function tn(t) {
1618
1746
  return t != null && typeof t[Symbol.iterator] == "function";
1619
1747
  }
1620
- function je(t) {
1748
+ function Ye(t) {
1621
1749
  return {
1622
1750
  code: "nest_limit_exceeded",
1623
1751
  message: "structure nest limit exceeded",
@@ -1625,38 +1753,38 @@ function je(t) {
1625
1753
  details: { limit: 20 }
1626
1754
  };
1627
1755
  }
1628
- function pe(t) {
1756
+ function ue(t) {
1629
1757
  return t.startsWith(`
1630
1758
  `) ? t.slice(1) : t;
1631
1759
  }
1632
- async function Yt(t, e) {
1633
- const n = e.path, r = e.warnings ?? [], i = zt(t, n), s = new qt();
1760
+ async function nn(t, e) {
1761
+ const n = e.path, r = e.warnings ?? [], i = Xt(t, n), s = new Qt();
1634
1762
  return fe(i, e, s, r);
1635
1763
  }
1636
1764
  async function fe(t, e, n, r) {
1637
1765
  const i = e.preserveHgComments === !0;
1638
1766
  let s = "", o = !1;
1639
1767
  for (const a of t) {
1640
- let c = await Gt(a, e, n, r);
1641
- o && (c = pe(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
1768
+ let c = await rn(a, e, n, r);
1769
+ o && (c = ue(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
1642
1770
  }
1643
1771
  return s;
1644
1772
  }
1645
- async function Gt(t, e, n, r) {
1773
+ async function rn(t, e, n, r) {
1646
1774
  switch (t.kind) {
1647
1775
  case "text":
1648
1776
  return t.content;
1649
1777
  case "if":
1650
- return Xt(t, e, n, r);
1778
+ return sn(t, e, n, r);
1651
1779
  case "each":
1652
- return Jt(t, e, n, r);
1780
+ return on(t, e, n, r);
1653
1781
  default:
1654
1782
  return "";
1655
1783
  }
1656
1784
  }
1657
- async function Xt(t, e, n, r) {
1785
+ async function sn(t, e, n, r) {
1658
1786
  if (n.enter().exceeded)
1659
- return r.push(je(e.path)), "";
1787
+ return r.push(Ye(e.path)), "";
1660
1788
  try {
1661
1789
  let s = -1;
1662
1790
  for (let c = 0; c < t.branches.length; c++) {
@@ -1665,8 +1793,8 @@ async function Xt(t, e, n, r) {
1665
1793
  s = c;
1666
1794
  break;
1667
1795
  }
1668
- const l = await k(h.expr, e);
1669
- if (Pt(l)) {
1796
+ const l = await y(h.expr, e);
1797
+ if (en(l)) {
1670
1798
  s = c;
1671
1799
  break;
1672
1800
  }
@@ -1677,7 +1805,7 @@ async function Xt(t, e, n, r) {
1677
1805
  const h = t.branches[c];
1678
1806
  if (o && (a += h.opener.raw), c === s) {
1679
1807
  let l = await fe(h.body, e, n, r);
1680
- o || (l = pe(l)), a += l;
1808
+ o || (l = ue(l)), a += l;
1681
1809
  }
1682
1810
  }
1683
1811
  return o && (a += t.closer.raw), a;
@@ -1685,12 +1813,12 @@ async function Xt(t, e, n, r) {
1685
1813
  n.exit();
1686
1814
  }
1687
1815
  }
1688
- async function Jt(t, e, n, r) {
1816
+ async function on(t, e, n, r) {
1689
1817
  if (n.enter().exceeded)
1690
- return r.push(je(e.path)), "";
1818
+ return r.push(Ye(e.path)), "";
1691
1819
  try {
1692
- const s = await k(t.expr, e);
1693
- if (!Kt(s))
1820
+ const s = await y(t.expr, e);
1821
+ if (!tn(s))
1694
1822
  return "";
1695
1823
  const o = e.preserveHgComments === !0;
1696
1824
  let a = "";
@@ -1701,8 +1829,8 @@ async function Jt(t, e, n, r) {
1701
1829
  ...e,
1702
1830
  context: h
1703
1831
  }, n, r);
1704
- o || (l = pe(l));
1705
- const u = await Ne(l, h, {
1832
+ o || (l = ue(l));
1833
+ const u = await Pe(l, h, {
1706
1834
  path: e.path,
1707
1835
  registry: e.registry,
1708
1836
  loader: e.loader,
@@ -1720,8 +1848,8 @@ async function Jt(t, e, n, r) {
1720
1848
  n.exit();
1721
1849
  }
1722
1850
  }
1723
- function ee(t, e, n, r, i = !1, s = !1) {
1724
- return H(e) ? e : Z(e, {
1851
+ function te(t, e, n, r, i = !1, s = !1) {
1852
+ return N(e) ? e : Z(e, {
1725
1853
  rootDir: t,
1726
1854
  fromPath: r,
1727
1855
  documentPath: n,
@@ -1729,14 +1857,14 @@ function ee(t, e, n, r, i = !1, s = !1) {
1729
1857
  hyogenPath: s
1730
1858
  });
1731
1859
  }
1732
- function Be(t) {
1860
+ function Xe(t) {
1733
1861
  let e = 0;
1734
1862
  for (let n = t.length - 1; n >= 0 && t[n] === `
1735
1863
  `; n--)
1736
1864
  e++;
1737
1865
  return e;
1738
1866
  }
1739
- function Ie(t) {
1867
+ function Ge(t) {
1740
1868
  let e = 0;
1741
1869
  for (; e < t.length && t[e] === `
1742
1870
  `; )
@@ -1744,25 +1872,25 @@ function Ie(t) {
1744
1872
  return e;
1745
1873
  }
1746
1874
  function A(t, e) {
1747
- const n = Be(t), r = Ie(e), i = Math.max(n, r);
1875
+ const n = Xe(t), r = Ge(e), i = Math.max(n, r);
1748
1876
  return t.slice(0, t.length - n) + `
1749
1877
  `.repeat(i) + e.slice(r);
1750
1878
  }
1751
- function me(t, e) {
1752
- const n = Be(t), r = Ie(e);
1879
+ function pe(t, e) {
1880
+ const n = Xe(t), r = Ge(e);
1753
1881
  return n + r - Math.max(n, r);
1754
1882
  }
1755
- function Ce(t, e, n) {
1883
+ function Ee(t, e, n) {
1756
1884
  const r = t.indexOf(e);
1757
1885
  if (r < 0)
1758
1886
  return t;
1759
1887
  const i = t.slice(0, r), s = t.slice(r + e.length);
1760
1888
  return A(A(i, n), s);
1761
1889
  }
1762
- async function Qt(t) {
1890
+ async function an(t) {
1763
1891
  let e = t.source;
1764
1892
  for (const n of t.directives) {
1765
- const r = ee(
1893
+ const r = te(
1766
1894
  t.root,
1767
1895
  n.path,
1768
1896
  t.path,
@@ -1775,7 +1903,7 @@ async function Qt(t) {
1775
1903
  if (i.circular) {
1776
1904
  t.warnings?.push({
1777
1905
  code: "circular_include",
1778
- message: L("circular_include", {
1906
+ message: H("circular_include", {
1779
1907
  path: r,
1780
1908
  from: i.from,
1781
1909
  via: "include"
@@ -1786,13 +1914,13 @@ async function Qt(t) {
1786
1914
  from: i.from,
1787
1915
  via: "include"
1788
1916
  }
1789
- }), e = Ce(e, n.marker, "");
1917
+ }), e = Ee(e, n.marker, "");
1790
1918
  continue;
1791
1919
  }
1792
1920
  t.visitStack.push(r);
1793
1921
  }
1794
1922
  try {
1795
- const i = await t.loader(r), s = await Nn(i, {
1923
+ const i = await t.loader(r), s = await Vn(i, {
1796
1924
  context: t.context,
1797
1925
  loader: t.loader,
1798
1926
  root: t.root,
@@ -1802,16 +1930,16 @@ async function Qt(t) {
1802
1930
  visitStack: t.visitStack,
1803
1931
  warnings: t.warnings,
1804
1932
  registry: t.registry
1805
- }), o = t.preserveHgComments && n.raw ? `${n.raw}
1806
- ${s}` : s;
1807
- e = Ce(e, n.marker, o);
1933
+ }), o = e.indexOf(n.marker), a = o >= 0 ? e.slice(0, o) : e, c = Ze(a), h = qe(s, c), l = t.preserveHgComments && n.raw ? `${n.raw}
1934
+ ${h}` : h;
1935
+ e = Ee(e, n.marker, l);
1808
1936
  } finally {
1809
1937
  t.visitStack?.pop();
1810
1938
  }
1811
1939
  }
1812
1940
  return e;
1813
1941
  }
1814
- class Ue {
1942
+ class Je {
1815
1943
  stack = [];
1816
1944
  check(e) {
1817
1945
  return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
@@ -1827,8 +1955,8 @@ class Ue {
1827
1955
  this.stack.pop();
1828
1956
  }
1829
1957
  }
1830
- async function en(t, e, n = {}) {
1831
- const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await k(t.expr, { context: e, path: r });
1958
+ async function cn(t, e, n = {}) {
1959
+ const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await y(t.expr, { context: e, path: r });
1832
1960
  switch (t.kind) {
1833
1961
  case "const": {
1834
1962
  if (i.has(t.name))
@@ -1868,16 +1996,16 @@ async function en(t, e, n = {}) {
1868
1996
  }
1869
1997
  }
1870
1998
  }
1871
- function Ee(t) {
1999
+ function Ce(t) {
1872
2000
  return !t;
1873
2001
  }
1874
- async function N(t, e, n = {}) {
2002
+ async function F(t, e, n = {}) {
1875
2003
  const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s, echoChunks: o } = n;
1876
2004
  switch (t.kind) {
1877
2005
  case "const":
1878
2006
  case "let":
1879
2007
  case "assign": {
1880
- await en(t, e, { path: r, constBindings: i }), s?.(t.name);
2008
+ await cn(t, e, { path: r, constBindings: i }), s?.(t.name);
1881
2009
  return;
1882
2010
  }
1883
2011
  case "update": {
@@ -1918,7 +2046,7 @@ async function N(t, e, n = {}) {
1918
2046
  message: `assignment to undeclared variable: ${t.name}`
1919
2047
  }
1920
2048
  });
1921
- const a = await k(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
2049
+ const a = await y(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
1922
2050
  let l;
1923
2051
  switch (t.op) {
1924
2052
  case "+=":
@@ -1938,7 +2066,7 @@ async function N(t, e, n = {}) {
1938
2066
  return;
1939
2067
  }
1940
2068
  case "echo": {
1941
- const a = await k(t.expr, {
2069
+ const a = await y(t.expr, {
1942
2070
  context: e,
1943
2071
  path: r
1944
2072
  }), c = a == null ? "" : String(a);
@@ -1946,28 +2074,28 @@ async function N(t, e, n = {}) {
1946
2074
  return;
1947
2075
  }
1948
2076
  case "for": {
1949
- for (t.init && await N(t.init, e, n); ; ) {
1950
- const a = await k(t.cond, {
2077
+ for (t.init && await F(t.init, e, n); ; ) {
2078
+ const a = await y(t.cond, {
1951
2079
  context: e,
1952
2080
  path: r
1953
2081
  });
1954
- if (Ee(a))
2082
+ if (Ce(a))
1955
2083
  break;
1956
2084
  for (const c of t.body)
1957
- await N(c, e, n);
1958
- t.update && await N(t.update, e, n);
2085
+ await F(c, e, n);
2086
+ t.update && await F(t.update, e, n);
1959
2087
  }
1960
2088
  return;
1961
2089
  }
1962
2090
  case "do_while": {
1963
2091
  do {
1964
2092
  for (const c of t.body)
1965
- await N(c, e, n);
1966
- const a = await k(t.cond, {
2093
+ await F(c, e, n);
2094
+ const a = await y(t.cond, {
1967
2095
  context: e,
1968
2096
  path: r
1969
2097
  });
1970
- if (Ee(a))
2098
+ if (Ce(a))
1971
2099
  break;
1972
2100
  } while (!0);
1973
2101
  return;
@@ -1976,9 +2104,9 @@ async function N(t, e, n = {}) {
1976
2104
  }
1977
2105
  async function $e(t, e, n = {}) {
1978
2106
  for (const r of t)
1979
- await N(r, e, n);
2107
+ await F(r, e, n);
1980
2108
  }
1981
- const tn = /* @__PURE__ */ new Set([
2109
+ const ln = /* @__PURE__ */ new Set([
1982
2110
  "if",
1983
2111
  "else",
1984
2112
  "endif",
@@ -1997,10 +2125,10 @@ const tn = /* @__PURE__ */ new Set([
1997
2125
  "as",
1998
2126
  "echo"
1999
2127
  ]);
2000
- function ze(t) {
2001
- return tn.has(t);
2128
+ function Qe(t) {
2129
+ return ln.has(t);
2002
2130
  }
2003
- function ge(t) {
2131
+ function me(t) {
2004
2132
  let e = "", n = 0, r = null;
2005
2133
  for (; n < t.length; ) {
2006
2134
  const i = t[n];
@@ -2033,7 +2161,7 @@ function ge(t) {
2033
2161
  }
2034
2162
  return e;
2035
2163
  }
2036
- function x(t, e) {
2164
+ function k(t, e) {
2037
2165
  throw d({
2038
2166
  code: "parse_error",
2039
2167
  path: t,
@@ -2041,24 +2169,24 @@ function x(t, e) {
2041
2169
  });
2042
2170
  }
2043
2171
  function We(t, e) {
2044
- const n = ge(t).trim();
2172
+ const n = me(t).trim();
2045
2173
  if (n.length === 0)
2046
- throw x(e, "empty statement block");
2047
- const r = new we(n, e), i = r.parseStatementList();
2174
+ throw k(e, "empty statement block");
2175
+ const r = new ge(n, e), i = r.parseStatementList();
2048
2176
  if (r.skipWhitespace(), r.hasMore())
2049
- throw x(
2177
+ throw k(
2050
2178
  e,
2051
2179
  `unexpected token at position ${r.position}`
2052
2180
  );
2053
2181
  if (i.length === 0)
2054
- throw x(e, "empty statement block");
2182
+ throw k(e, "empty statement block");
2055
2183
  return i;
2056
2184
  }
2057
- function z(t) {
2058
- const e = ge(t).trim();
2185
+ function V(t) {
2186
+ const e = me(t).trim();
2059
2187
  return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^echo\b/.test(e) || /^for\s*\(/.test(e) || /^do\b/.test(e) || /^(\+\+|--)/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*(\+\+|--|[+\-*/]=|=)/.test(e);
2060
2188
  }
2061
- class we {
2189
+ class ge {
2062
2190
  constructor(e, n) {
2063
2191
  this.input = e, this.path = n;
2064
2192
  }
@@ -2087,7 +2215,7 @@ class we {
2087
2215
  if (this.matchWord("do"))
2088
2216
  return this.parseDoWhile();
2089
2217
  if (this.matchWord("while"))
2090
- throw x(
2218
+ throw k(
2091
2219
  this.path,
2092
2220
  "bare while loops are not allowed (use do…while)"
2093
2221
  );
@@ -2104,7 +2232,7 @@ class we {
2104
2232
  return this.parseBindingDeclaration("let");
2105
2233
  const n = this.readIdentifier();
2106
2234
  if (!n)
2107
- throw x(this.path, "expected statement");
2235
+ throw k(this.path, "expected statement");
2108
2236
  if (this.assertAssignableName(n), this.skipWhitespace(), this.match("++") || this.match("--")) {
2109
2237
  const i = this.input.slice(this.index - 2, this.index);
2110
2238
  return { kind: "update", name: n, op: i, position: "postfix" };
@@ -2121,7 +2249,7 @@ class we {
2121
2249
  }
2122
2250
  if (this.match("=")) {
2123
2251
  if (this.peek() === "=")
2124
- throw x(this.path, "unexpected '==' in assignment");
2252
+ throw k(this.path, "unexpected '==' in assignment");
2125
2253
  const i = this.readExpressionSourceUntilTerminator();
2126
2254
  return {
2127
2255
  kind: "assign",
@@ -2129,7 +2257,7 @@ class we {
2129
2257
  expr: S(i, this.path)
2130
2258
  };
2131
2259
  }
2132
- throw x(this.path, `invalid statement starting with: ${n}`);
2260
+ throw k(this.path, `invalid statement starting with: ${n}`);
2133
2261
  }
2134
2262
  parseEcho() {
2135
2263
  this.skipWhitespace();
@@ -2143,7 +2271,7 @@ class we {
2143
2271
  if (this.skipWhitespace(), this.match("++") || this.match("--")) {
2144
2272
  const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
2145
2273
  if (!n)
2146
- throw x(this.path, `expected identifier after ${e}`);
2274
+ throw k(this.path, `expected identifier after ${e}`);
2147
2275
  return this.assertAssignableName(n), { kind: "update", name: n, op: e, position: "prefix" };
2148
2276
  }
2149
2277
  return null;
@@ -2151,9 +2279,9 @@ class we {
2151
2279
  parseBindingDeclaration(e) {
2152
2280
  const n = this.readIdentifier();
2153
2281
  if (!n)
2154
- throw x(this.path, `expected identifier after ${e}`);
2282
+ throw k(this.path, `expected identifier after ${e}`);
2155
2283
  if (this.assertAssignableName(n), this.skipWhitespace(), !this.match("="))
2156
- throw x(this.path, `expected '=' in ${e} declaration`);
2284
+ throw k(this.path, `expected '=' in ${e} declaration`);
2157
2285
  const r = this.readExpressionSourceUntilTerminator();
2158
2286
  return {
2159
2287
  kind: e,
@@ -2163,57 +2291,57 @@ class we {
2163
2291
  }
2164
2292
  parseFor() {
2165
2293
  if (this.skipWhitespace(), !this.match("("))
2166
- throw x(this.path, "expected '(' after for");
2167
- const e = this.readBalanced(")"), n = nn(e);
2294
+ throw k(this.path, "expected '(' after for");
2295
+ const e = this.readBalanced(")"), n = hn(e);
2168
2296
  if (n.length !== 3)
2169
- throw x(
2297
+ throw k(
2170
2298
  this.path,
2171
2299
  "for…of / for…in are not allowed; use for (init; cond; update)"
2172
2300
  );
2173
2301
  const [r, i, s] = n;
2174
2302
  if (i.trim().length === 0)
2175
- throw x(this.path, "for loop condition cannot be empty");
2303
+ throw k(this.path, "for loop condition cannot be empty");
2176
2304
  if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(r))
2177
- throw x(
2305
+ throw k(
2178
2306
  this.path,
2179
2307
  "for…of / for…in are not allowed; use for (init; cond; update)"
2180
2308
  );
2181
2309
  const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = S(i.trim(), this.path), c = s.trim().length === 0 ? null : this.parseClauseStatement(s.trim());
2182
2310
  if (this.skipWhitespace(), !this.match("{"))
2183
- throw x(this.path, "expected '{' after for (...)");
2311
+ throw k(this.path, "expected '{' after for (...)");
2184
2312
  const h = this.parseStatementList();
2185
2313
  if (this.skipWhitespace(), !this.match("}"))
2186
- throw x(this.path, "expected '}' to close for body");
2314
+ throw k(this.path, "expected '}' to close for body");
2187
2315
  return { kind: "for", init: o, cond: a, update: c, body: h };
2188
2316
  }
2189
2317
  parseDoWhile() {
2190
2318
  if (this.skipWhitespace(), !this.match("{"))
2191
- throw x(this.path, "expected '{' after do");
2319
+ throw k(this.path, "expected '{' after do");
2192
2320
  const e = this.parseStatementList();
2193
2321
  if (this.skipWhitespace(), !this.match("}"))
2194
- throw x(this.path, "expected '}' to close do body");
2322
+ throw k(this.path, "expected '}' to close do body");
2195
2323
  if (this.skipWhitespace(), !this.matchWord("while"))
2196
- throw x(this.path, "expected 'while' after do body");
2324
+ throw k(this.path, "expected 'while' after do body");
2197
2325
  if (this.skipWhitespace(), !this.match("("))
2198
- throw x(this.path, "expected '(' after while");
2326
+ throw k(this.path, "expected '(' after while");
2199
2327
  const n = this.readBalanced(")");
2200
2328
  if (n.trim().length === 0)
2201
- throw x(this.path, "do…while condition cannot be empty");
2329
+ throw k(this.path, "do…while condition cannot be empty");
2202
2330
  const r = S(n.trim(), this.path);
2203
2331
  return { kind: "do_while", body: e, cond: r };
2204
2332
  }
2205
2333
  parseClauseStatement(e) {
2206
- const n = new we(e, this.path), r = n.parseSimpleStatement();
2334
+ const n = new ge(e, this.path), r = n.parseSimpleStatement();
2207
2335
  if (n.skipWhitespace(), n.hasMore())
2208
- throw x(
2336
+ throw k(
2209
2337
  this.path,
2210
2338
  `unexpected token in for clause at position ${n.position}`
2211
2339
  );
2212
2340
  return r;
2213
2341
  }
2214
2342
  assertAssignableName(e) {
2215
- if (ze(e))
2216
- throw x(
2343
+ if (Qe(e))
2344
+ throw k(
2217
2345
  this.path,
2218
2346
  `reserved word cannot be used as identifier: ${e}`
2219
2347
  );
@@ -2248,7 +2376,7 @@ class we {
2248
2376
  }
2249
2377
  const o = this.input.slice(e, this.index).trim();
2250
2378
  if (o.length === 0)
2251
- throw x(this.path, "expected expression");
2379
+ throw k(this.path, "expected expression");
2252
2380
  return o;
2253
2381
  }
2254
2382
  readBalanced(e) {
@@ -2284,7 +2412,7 @@ class we {
2284
2412
  }
2285
2413
  this.index++;
2286
2414
  }
2287
- throw x(this.path, `expected '${e}'`);
2415
+ throw k(this.path, `expected '${e}'`);
2288
2416
  }
2289
2417
  readCompoundOp() {
2290
2418
  this.skipWhitespace();
@@ -2319,7 +2447,7 @@ class we {
2319
2447
  return this.input.slice(e, this.index);
2320
2448
  }
2321
2449
  }
2322
- function nn(t) {
2450
+ function hn(t) {
2323
2451
  const e = [];
2324
2452
  let n = "", r = 0, i = null;
2325
2453
  for (let s = 0; s < t.length; s++) {
@@ -2352,7 +2480,7 @@ function nn(t) {
2352
2480
  }
2353
2481
  return e.push(n), e;
2354
2482
  }
2355
- function j(t, e) {
2483
+ function B(t, e) {
2356
2484
  const n = t.trim();
2357
2485
  if (!/^extend\b/i.test(n)) return null;
2358
2486
  if (!/^extend\s+/i.test(n))
@@ -2377,10 +2505,10 @@ function j(t, e) {
2377
2505
  });
2378
2506
  return { path: i };
2379
2507
  }
2380
- function rn(t, e) {
2381
- const n = E(t);
2508
+ function dn(t, e) {
2509
+ const n = C(t);
2382
2510
  if (n.length === 0) return null;
2383
- const r = n[0], i = j(r, e);
2511
+ const r = n[0], i = B(r, e);
2384
2512
  if (!i) return null;
2385
2513
  for (const s of n.slice(1))
2386
2514
  if (/^extend\s+/i.test(s))
@@ -2395,11 +2523,11 @@ function rn(t, e) {
2395
2523
  `)
2396
2524
  };
2397
2525
  }
2398
- function q(t) {
2526
+ function P(t) {
2399
2527
  return /^toc(\(.*\))?$/.test(t.trim());
2400
2528
  }
2401
- function sn(t, e) {
2402
- const n = E(t);
2529
+ function un(t, e) {
2530
+ const n = C(t);
2403
2531
  if (n.length !== 1)
2404
2532
  throw d({
2405
2533
  code: "parse_error",
@@ -2429,17 +2557,17 @@ function sn(t, e) {
2429
2557
  });
2430
2558
  return { maxLevel: Number(s) };
2431
2559
  }
2432
- async function on(t, e = {}) {
2560
+ async function fn(t, e = {}) {
2433
2561
  const n = e.path, r = e.context ?? {};
2434
- if (he(t))
2562
+ if (le(t))
2435
2563
  throw d({
2436
2564
  code: "parse_error",
2437
2565
  path: n,
2438
2566
  details: {
2439
- message: de(t) ?? "unclosed hyogen block (missing closing marker)"
2567
+ message: he(t) ?? "unclosed hyogen block (missing closing marker)"
2440
2568
  }
2441
2569
  });
2442
- const i = $(t);
2570
+ const i = W(t);
2443
2571
  if (i.length === 0)
2444
2572
  return { source: t, context: r, declarationUpdates: {} };
2445
2573
  const s = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
@@ -2447,14 +2575,14 @@ async function on(t, e = {}) {
2447
2575
  };
2448
2576
  let c = t, h = 0;
2449
2577
  for (const l of i) {
2450
- const u = E(l.inner);
2451
- if (u.length === 1 && ue(u[0]) || u.length === 1 && q(u[0]) || u.length === 1 && /^include\s+/i.test(u[0]) || u.length === 1 && /^component\s+/i.test(u[0]))
2578
+ const u = C(l.inner);
2579
+ if (u.length === 1 && de(u[0]) || u.length === 1 && P(u[0]) || u.length === 1 && /^include\s+/i.test(u[0]) || u.length === 1 && /^component\s+/i.test(u[0]))
2452
2580
  continue;
2453
- const w = rn(l.inner, n);
2454
- if (w) {
2455
- if (w.declarationsSource.trim().length > 0) {
2581
+ const g = dn(l.inner, n);
2582
+ if (g) {
2583
+ if (g.declarationsSource.trim().length > 0) {
2456
2584
  const D = We(
2457
- w.declarationsSource,
2585
+ g.declarationsSource,
2458
2586
  n
2459
2587
  );
2460
2588
  await $e(D, r, {
@@ -2463,15 +2591,15 @@ async function on(t, e = {}) {
2463
2591
  onUpdate: a
2464
2592
  });
2465
2593
  }
2466
- const _ = l.start - h, R = l.end - h, I = `<!--@hg
2467
- extend ${w.path}
2594
+ const _ = l.start - h, L = l.end - h, U = `<!--@hg
2595
+ extend ${g.path}
2468
2596
  @endhg-->`;
2469
- c = c.slice(0, _) + I + c.slice(R), h += l.raw.length - I.length;
2597
+ c = c.slice(0, _) + U + c.slice(L), h += l.raw.length - U.length;
2470
2598
  continue;
2471
2599
  }
2472
- const m = u.join(`
2600
+ const w = u.join(`
2473
2601
  `);
2474
- if (!z(m)) {
2602
+ if (!V(w)) {
2475
2603
  if (u.length === 1)
2476
2604
  continue;
2477
2605
  throw d({
@@ -2480,25 +2608,25 @@ extend ${w.path}
2480
2608
  details: { message: `unsupported hyogen directive: ${u[0]}` }
2481
2609
  });
2482
2610
  }
2483
- const f = We(m, n), y = [];
2484
- await $e(f, r, {
2611
+ const p = We(w, n), x = [];
2612
+ await $e(p, r, {
2485
2613
  path: n,
2486
2614
  constBindings: s,
2487
2615
  onUpdate: a,
2488
- echoChunks: y
2616
+ echoChunks: x
2489
2617
  });
2490
- const W = l.start - h, P = l.end - h, T = c.slice(0, W), b = c.slice(P);
2491
- if (y.length > 0) {
2492
- const _ = y.join("");
2618
+ const $ = l.start - h, K = l.end - h, T = c.slice(0, $), b = c.slice(K);
2619
+ if (x.length > 0) {
2620
+ const _ = x.join("");
2493
2621
  c = T + _ + b, h += l.raw.length - _.length;
2494
2622
  } else
2495
- c = A(T, b), h += l.raw.length + me(T, b);
2623
+ c = A(T, b), h += l.raw.length + pe(T, b);
2496
2624
  }
2497
2625
  return { source: c, context: r, declarationUpdates: o };
2498
2626
  }
2499
- const an = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
2500
- function Ze(t, e) {
2501
- const n = ce(t).trim();
2627
+ const pn = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
2628
+ function et(t, e) {
2629
+ const n = ae(t).trim();
2502
2630
  if (n.length === 0)
2503
2631
  throw d({
2504
2632
  code: "parse_error",
@@ -2521,7 +2649,7 @@ function Ze(t, e) {
2521
2649
  path: e,
2522
2650
  details: { message: "include and component cannot coexist in one block" }
2523
2651
  });
2524
- const s = an.exec(i);
2652
+ const s = pn.exec(i);
2525
2653
  if (!s)
2526
2654
  throw d({
2527
2655
  code: "parse_error",
@@ -2541,8 +2669,8 @@ function Ze(t, e) {
2541
2669
  alias: s[2]
2542
2670
  };
2543
2671
  }
2544
- function Ve(t, e) {
2545
- const n = ce(t).trim();
2672
+ function tt(t, e) {
2673
+ const n = ae(t).trim();
2546
2674
  if (n.length === 0)
2547
2675
  throw d({
2548
2676
  code: "parse_error",
@@ -2565,19 +2693,19 @@ function Ve(t, e) {
2565
2693
  details: { message: `unsupported hyogen directive: ${i}` }
2566
2694
  });
2567
2695
  }
2568
- function te(t) {
2569
- const e = ge(t).trim();
2696
+ function ne(t) {
2697
+ const e = me(t).trim();
2570
2698
  return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
2571
2699
  }
2572
- const cn = "\0HYOGEN_INCLUDE_";
2573
- function ln(t) {
2574
- return `${cn}${t}\0`;
2700
+ const mn = "\0HYOGEN_INCLUDE_";
2701
+ function gn(t) {
2702
+ return `${mn}${t}\0`;
2575
2703
  }
2576
- function hn(t, e) {
2577
- const n = E(t);
2578
- if (n.length === 1 && ue(n[0]))
2704
+ function wn(t, e) {
2705
+ const n = C(t);
2706
+ if (n.length === 1 && de(n[0]))
2579
2707
  return { kind: "control" };
2580
- if (n.length === 1 && q(n[0]) || n.length === 1 && (te(n[0]) || z(n[0])))
2708
+ if (n.length === 1 && P(n[0]) || n.length === 1 && (ne(n[0]) || V(n[0])))
2581
2709
  return null;
2582
2710
  if (n.length !== 1)
2583
2711
  throw d({
@@ -2593,9 +2721,9 @@ function hn(t, e) {
2593
2721
  details: { message: "include and component cannot coexist in one block" }
2594
2722
  });
2595
2723
  if (/^include\s+/i.test(r))
2596
- return Ve(t, e);
2724
+ return tt(t, e);
2597
2725
  if (/^component\s+/i.test(r))
2598
- return Ze(t, e);
2726
+ return et(t, e);
2599
2727
  if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
2600
2728
  return null;
2601
2729
  throw d({
@@ -2604,23 +2732,23 @@ function hn(t, e) {
2604
2732
  details: { message: `unsupported hyogen directive: ${r}` }
2605
2733
  });
2606
2734
  }
2607
- function dn(t, e = {}) {
2735
+ function xn(t, e = {}) {
2608
2736
  const n = e.path;
2609
- if (he(t))
2737
+ if (le(t))
2610
2738
  throw d({
2611
2739
  code: "parse_error",
2612
2740
  path: n,
2613
2741
  details: {
2614
- message: de(t) ?? "unclosed hyogen block (missing closing marker)"
2742
+ message: he(t) ?? "unclosed hyogen block (missing closing marker)"
2615
2743
  }
2616
2744
  });
2617
- const r = $(t);
2745
+ const r = W(t);
2618
2746
  if (r.length === 0)
2619
2747
  return { source: t, directives: [] };
2620
2748
  const i = [];
2621
2749
  let s = t, o = 0, a = 0;
2622
2750
  for (const c of r) {
2623
- const h = hn(c.inner, n);
2751
+ const h = wn(c.inner, n);
2624
2752
  if (!h || h.kind === "control")
2625
2753
  continue;
2626
2754
  const l = c.start - o, u = c.end - o;
@@ -2634,39 +2762,39 @@ function dn(t, e = {}) {
2634
2762
  Object.keys(e.context ?? {}),
2635
2763
  n
2636
2764
  );
2637
- const m = s.slice(0, l), f = s.slice(u);
2638
- s = A(m, f), o += c.raw.length + me(m, f);
2765
+ const w = s.slice(0, l), p = s.slice(u);
2766
+ s = A(w, p), o += c.raw.length + pe(w, p);
2639
2767
  continue;
2640
2768
  }
2641
- const w = ln(a++);
2642
- i.push({ ...h, marker: w, raw: c.raw }), s = s.slice(0, l) + w + s.slice(u), o += c.raw.length - w.length;
2769
+ const g = gn(a++);
2770
+ i.push({ ...h, marker: g, raw: c.raw }), s = s.slice(0, l) + g + s.slice(u), o += c.raw.length - g.length;
2643
2771
  }
2644
2772
  return { source: s, directives: i };
2645
2773
  }
2646
- function un(t, e) {
2774
+ function kn(t, e) {
2647
2775
  return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
2648
2776
  ` : `${e.rawFrontMatter}
2649
2777
  ${t}`;
2650
2778
  }
2651
- function pn(t, e = !1) {
2779
+ function yn(t, e = !1) {
2652
2780
  if (e)
2653
2781
  return t;
2654
- const n = $(t);
2782
+ const n = W(t);
2655
2783
  if (n.length === 0)
2656
2784
  return t;
2657
2785
  let r = t, i = 0;
2658
2786
  for (const s of n) {
2659
2787
  const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
2660
- r = A(c, h), i += s.raw.length + me(c, h);
2788
+ r = A(c, h), i += s.raw.length + pe(c, h);
2661
2789
  }
2662
2790
  return r;
2663
2791
  }
2664
- const fn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
2665
- function mn(t, e) {
2792
+ const bn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
2793
+ function vn(t, e) {
2666
2794
  const n = t.trim();
2667
2795
  if (n === "endblock")
2668
2796
  return { kind: "endblock" };
2669
- const r = fn.exec(n);
2797
+ const r = bn.exec(n);
2670
2798
  if (!r)
2671
2799
  throw d({
2672
2800
  code: "parse_error",
@@ -2674,7 +2802,7 @@ function mn(t, e) {
2674
2802
  details: { message: "invalid block directive" }
2675
2803
  });
2676
2804
  const i = r[1];
2677
- if (ze(i))
2805
+ if (Qe(i))
2678
2806
  throw d({
2679
2807
  code: "parse_error",
2680
2808
  path: e,
@@ -2683,11 +2811,11 @@ function mn(t, e) {
2683
2811
  return { kind: "block", name: i };
2684
2812
  }
2685
2813
  function Te(t, e) {
2686
- const { path: n, mode: r, hasExtend: i = !1 } = e, s = $(t);
2814
+ const { path: n, mode: r, hasExtend: i = !1 } = e, s = W(t);
2687
2815
  if (s.length === 0) return [];
2688
2816
  const o = [], a = [], c = /* @__PURE__ */ new Set();
2689
2817
  for (const h of s) {
2690
- const l = E(h.inner);
2818
+ const l = C(h.inner);
2691
2819
  if (l.length !== 1) continue;
2692
2820
  const u = l[0];
2693
2821
  if (!(u === "endblock" || u.startsWith("block "))) continue;
@@ -2697,20 +2825,20 @@ function Te(t, e) {
2697
2825
  path: n,
2698
2826
  details: { message: "orphan block without extend" }
2699
2827
  });
2700
- const m = mn(u, n);
2701
- if (m.kind === "endblock") {
2702
- const f = a.pop();
2703
- if (!f)
2828
+ const w = vn(u, n);
2829
+ if (w.kind === "endblock") {
2830
+ const p = a.pop();
2831
+ if (!p)
2704
2832
  throw d({
2705
2833
  code: "parse_error",
2706
2834
  path: n,
2707
2835
  details: { message: "endblock without matching block opener" }
2708
2836
  });
2709
- const y = t.slice(f.openerEnd, h.start);
2837
+ const x = t.slice(p.openerEnd, h.start);
2710
2838
  o.push({
2711
- name: f.name,
2712
- body: y,
2713
- start: f.start,
2839
+ name: p.name,
2840
+ body: x,
2841
+ start: p.start,
2714
2842
  end: h.end
2715
2843
  });
2716
2844
  continue;
@@ -2721,14 +2849,14 @@ function Te(t, e) {
2721
2849
  path: n,
2722
2850
  details: { message: "nested block structures are not supported" }
2723
2851
  });
2724
- if (c.has(m.name))
2852
+ if (c.has(w.name))
2725
2853
  throw d({
2726
2854
  code: "parse_error",
2727
2855
  path: n,
2728
- details: { message: `duplicate block: ${m.name}` }
2856
+ details: { message: `duplicate block: ${w.name}` }
2729
2857
  });
2730
- c.add(m.name), a.push({
2731
- name: m.name,
2858
+ c.add(w.name), a.push({
2859
+ name: w.name,
2732
2860
  openerEnd: h.end,
2733
2861
  start: h.start
2734
2862
  });
@@ -2742,36 +2870,36 @@ function Te(t, e) {
2742
2870
  return o;
2743
2871
  }
2744
2872
  function Ae(t) {
2745
- const e = $(t), n = [];
2873
+ const e = W(t), n = [];
2746
2874
  for (const r of e) {
2747
- const i = E(r.inner);
2875
+ const i = C(r.inner);
2748
2876
  if (i.length === 0) continue;
2749
- const s = j(i[0]);
2877
+ const s = B(i[0]);
2750
2878
  s && n.push({ path: s.path, start: r.start });
2751
2879
  }
2752
2880
  return n;
2753
2881
  }
2754
- function gn(t) {
2755
- const e = $(t);
2882
+ function _n(t) {
2883
+ const e = W(t);
2756
2884
  for (const n of e) {
2757
- const r = E(n.inner);
2885
+ const r = C(n.inner);
2758
2886
  if (r.length !== 1) continue;
2759
2887
  const i = r[0];
2760
2888
  if (i === "endblock" || i.startsWith("block ")) return !0;
2761
2889
  }
2762
2890
  return !1;
2763
2891
  }
2764
- function Q(t) {
2892
+ function ee(t) {
2765
2893
  return t.map((e) => e.body).join("");
2766
2894
  }
2767
- function wn(t, e, n) {
2895
+ function Sn(t, e, n) {
2768
2896
  const r = [...e].sort((o, a) => o.start - a.start), i = [];
2769
2897
  let s = 0;
2770
2898
  for (const o of r)
2771
2899
  i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
2772
2900
  return i.push(t.slice(s)), i.reduce((o, a) => A(o, a));
2773
2901
  }
2774
- function xn(t) {
2902
+ function En(t) {
2775
2903
  if (t instanceof Error && "code" in t && "details" in t) {
2776
2904
  const e = t;
2777
2905
  if (e.code === "file_not_found" && e.details && e.details.via === "include")
@@ -2779,7 +2907,7 @@ function xn(t) {
2779
2907
  }
2780
2908
  return { errorToThrow: t, adjusted: !1 };
2781
2909
  }
2782
- async function kn(t, e) {
2910
+ async function Cn(t, e) {
2783
2911
  const {
2784
2912
  path: n,
2785
2913
  context: r,
@@ -2792,7 +2920,7 @@ async function kn(t, e) {
2792
2920
  inComponent: l = !1
2793
2921
  } = e, u = Ae(t);
2794
2922
  if (u.length === 0) {
2795
- if (gn(t))
2923
+ if (_n(t))
2796
2924
  throw d({
2797
2925
  code: "parse_error",
2798
2926
  path: n,
@@ -2800,13 +2928,13 @@ async function kn(t, e) {
2800
2928
  });
2801
2929
  return { source: t, context: v(r, i) };
2802
2930
  }
2803
- const m = $(t)[0];
2804
- if (!m)
2931
+ const w = W(t)[0];
2932
+ if (!w)
2805
2933
  return { source: t, context: v(r, i) };
2806
2934
  if (!s)
2807
2935
  throw new Error("loader is required when processing extend directives");
2808
- const f = E(m.inner);
2809
- if (!(f.length > 0 ? j(f[0]) : null))
2936
+ const p = C(w.inner);
2937
+ if (!(p.length > 0 ? B(p[0]) : null))
2810
2938
  throw d({
2811
2939
  code: "parse_error",
2812
2940
  path: n,
@@ -2818,7 +2946,7 @@ async function kn(t, e) {
2818
2946
  path: n,
2819
2947
  details: { message: "multiple extend directives are not supported" }
2820
2948
  });
2821
- const W = Te(t, {
2949
+ const $ = Te(t, {
2822
2950
  path: n,
2823
2951
  mode: "child",
2824
2952
  hasExtend: !0
@@ -2826,16 +2954,16 @@ async function kn(t, e) {
2826
2954
  if (l)
2827
2955
  return h?.push({
2828
2956
  code: "extend_in_component",
2829
- message: L("extend_in_component", { path: n }),
2957
+ message: H("extend_in_component", { path: n }),
2830
2958
  path: n,
2831
2959
  details: { path: n }
2832
2960
  }), {
2833
- source: Q(W),
2961
+ source: ee($),
2834
2962
  context: v(r, i)
2835
2963
  };
2836
- const P = u[0].path, T = n, b = ee(
2964
+ const K = u[0].path, T = n, b = te(
2837
2965
  o,
2838
- P,
2966
+ K,
2839
2967
  n,
2840
2968
  n,
2841
2969
  a,
@@ -2847,7 +2975,7 @@ async function kn(t, e) {
2847
2975
  if (_.circular)
2848
2976
  return h?.push({
2849
2977
  code: "circular_include",
2850
- message: L("circular_include", {
2978
+ message: H("circular_include", {
2851
2979
  path: b,
2852
2980
  from: _.from,
2853
2981
  via: "extend"
@@ -2855,39 +2983,39 @@ async function kn(t, e) {
2855
2983
  path: n,
2856
2984
  details: { path: b, from: _.from, via: "extend" }
2857
2985
  }), {
2858
- source: Q(W),
2986
+ source: ee($),
2859
2987
  context: v(r, i)
2860
2988
  };
2861
2989
  c.push(b);
2862
2990
  try {
2863
- const R = await s(b);
2864
- if (R === void 0)
2991
+ const L = await s(b);
2992
+ if (L === void 0)
2865
2993
  throw new Error("loader returned undefined");
2866
- const { context: I, body: D } = V(
2867
- R,
2994
+ const { context: U, body: D } = q(
2995
+ L,
2868
2996
  b
2869
- ), ke = Ae(D);
2870
- if (ke.length > 0) {
2871
- const U = ke[0].path, K = ee(
2997
+ ), xe = Ae(D);
2998
+ if (xe.length > 0) {
2999
+ const z = xe[0].path, Y = te(
2872
3000
  o,
2873
- U,
3001
+ z,
2874
3002
  b,
2875
3003
  b,
2876
3004
  a,
2877
3005
  !0
2878
- ), Y = c.check(K);
2879
- if (Y.circular)
3006
+ ), X = c.check(Y);
3007
+ if (X.circular)
2880
3008
  return h?.push({
2881
3009
  code: "circular_include",
2882
- message: L("circular_include", {
2883
- path: K,
2884
- from: Y.from,
3010
+ message: H("circular_include", {
3011
+ path: Y,
3012
+ from: X.from,
2885
3013
  via: "extend"
2886
3014
  }),
2887
3015
  path: n,
2888
- details: { path: K, from: Y.from, via: "extend" }
3016
+ details: { path: Y, from: X.from, via: "extend" }
2889
3017
  }), {
2890
- source: Q(W),
3018
+ source: ee($),
2891
3019
  context: v(r, i)
2892
3020
  };
2893
3021
  throw d({
@@ -2896,32 +3024,32 @@ async function kn(t, e) {
2896
3024
  details: { message: "layout extend is not supported" }
2897
3025
  });
2898
3026
  }
2899
- const Pe = Te(D, {
3027
+ const rt = Te(D, {
2900
3028
  path: b,
2901
3029
  mode: "layout"
2902
- }), Ke = new Map(
2903
- W.map((U) => [U.name, U.body])
2904
- ), Ye = wn(
3030
+ }), it = new Map(
3031
+ $.map((z) => [z.name, z.body])
3032
+ ), st = Sn(
2905
3033
  D,
2906
- Pe,
2907
- Ke
2908
- ), Ge = v(
3034
+ rt,
3035
+ it
3036
+ ), ot = v(
2909
3037
  r,
2910
- I,
3038
+ U,
2911
3039
  i
2912
3040
  );
2913
- return { source: Ye, context: Ge };
3041
+ return { source: st, context: ot };
2914
3042
  } finally {
2915
3043
  c.pop();
2916
3044
  }
2917
3045
  } catch (_) {
2918
- const R = xn(_);
2919
- throw R.adjusted ? R.errorToThrow : _;
3046
+ const L = En(_);
3047
+ throw L.adjusted ? L.errorToThrow : _;
2920
3048
  } finally {
2921
3049
  T && c.pop();
2922
3050
  }
2923
3051
  }
2924
- const yn = se.warningReasons, bn = [
3052
+ const $n = lt.warningReasons, Wn = [
2925
3053
  {
2926
3054
  reason: "contains_html_script_tag",
2927
3055
  test: (t) => /<\/?script\b/i.test(t)
@@ -2943,17 +3071,17 @@ const yn = se.warningReasons, bn = [
2943
3071
  test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
2944
3072
  }
2945
3073
  ];
2946
- function vn(t) {
2947
- return yn[t] ?? t;
3074
+ function Tn(t) {
3075
+ return $n[t] ?? t;
2948
3076
  }
2949
- function ne(t, e, n, r) {
3077
+ function re(t, e, n, r) {
2950
3078
  if (typeof t == "string") {
2951
- for (const i of bn)
3079
+ for (const i of Wn)
2952
3080
  i.test(t) && n.push({
2953
3081
  code: "suspicious_context_value",
2954
- message: L("suspicious_context_value", {
3082
+ message: H("suspicious_context_value", {
2955
3083
  key: e,
2956
- reason: vn(i.reason)
3084
+ reason: Tn(i.reason)
2957
3085
  }),
2958
3086
  path: r,
2959
3087
  details: { key: e, reason: i.reason }
@@ -2963,7 +3091,7 @@ function ne(t, e, n, r) {
2963
3091
  if (t != null) {
2964
3092
  if (Array.isArray(t)) {
2965
3093
  for (let i = 0; i < t.length; i++)
2966
- ne(t[i], `${e}[${i}]`, n, r);
3094
+ re(t[i], `${e}[${i}]`, n, r);
2967
3095
  return;
2968
3096
  }
2969
3097
  if (typeof t == "object")
@@ -2971,23 +3099,23 @@ function ne(t, e, n, r) {
2971
3099
  t
2972
3100
  )) {
2973
3101
  const o = e.length > 0 ? `${e}.${i}` : i;
2974
- ne(s, o, n, r);
3102
+ re(s, o, n, r);
2975
3103
  }
2976
3104
  }
2977
3105
  }
2978
- function _n(t, e, n) {
3106
+ function An(t, e, n) {
2979
3107
  for (const [r, i] of Object.entries(t))
2980
- ne(i, r, e, n);
3108
+ re(i, r, e, n);
2981
3109
  }
2982
- const Sn = /^=+[ \t]*$/, Cn = /^-+[ \t]*$/, En = /^(```|~~~)/, $n = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
2983
- function re(t) {
2984
- const e = $n.exec(t);
3110
+ const Ln = /^=+[ \t]*$/, On = /^-+[ \t]*$/, Rn = /^(```|~~~)/, Mn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
3111
+ function ie(t) {
3112
+ const e = Mn.exec(t);
2985
3113
  return e && e.index !== void 0 ? {
2986
3114
  text: t.slice(0, e.index).trim(),
2987
3115
  explicitId: e[1]
2988
3116
  } : { text: t.trim() };
2989
3117
  }
2990
- function Wn(t) {
3118
+ function Hn(t) {
2991
3119
  let e = 0;
2992
3120
  for (; e < t.length && e < 6 && t[e] === "#"; )
2993
3121
  e += 1;
@@ -3015,10 +3143,10 @@ function Wn(t) {
3015
3143
  }
3016
3144
  if (i <= n)
3017
3145
  return null;
3018
- const s = re(t.slice(n, i));
3146
+ const s = ie(t.slice(n, i));
3019
3147
  return { level: e, ...s };
3020
3148
  }
3021
- function Re(t, e, n) {
3149
+ function Le(t, e, n) {
3022
3150
  let r = n;
3023
3151
  for (; r < t.length; ) {
3024
3152
  if (!e.inHtmlComment) {
@@ -3034,13 +3162,13 @@ function Re(t, e, n) {
3034
3162
  e.inHtmlComment = !1, r = i + 3;
3035
3163
  }
3036
3164
  }
3037
- function Tn(t, e) {
3165
+ function Nn(t, e) {
3038
3166
  if (e.inFence || e.inHtmlComment)
3039
3167
  return !0;
3040
3168
  const n = t.trim();
3041
3169
  return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
3042
3170
  }
3043
- function An(t) {
3171
+ function Dn(t) {
3044
3172
  const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
3045
3173
  for (let i = 0; i < e.length; i++) {
3046
3174
  const s = e[i];
@@ -3050,35 +3178,35 @@ function An(t) {
3050
3178
  continue;
3051
3179
  }
3052
3180
  if (r.inHtmlComment) {
3053
- Re(s, r, 0);
3181
+ Le(s, r, 0);
3054
3182
  continue;
3055
3183
  }
3056
- const o = En.exec(s.trimStart());
3184
+ const o = Rn.exec(s.trimStart());
3057
3185
  if (o) {
3058
3186
  const l = o[1];
3059
3187
  s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
3060
3188
  continue;
3061
3189
  }
3062
3190
  if (s.trim().startsWith("<!--")) {
3063
- Re(s, r, s.indexOf("<!--"));
3191
+ Le(s, r, s.indexOf("<!--"));
3064
3192
  continue;
3065
3193
  }
3066
- if (Tn(s, r))
3194
+ if (Nn(s, r))
3067
3195
  continue;
3068
- const c = Wn(s);
3196
+ const c = Hn(s);
3069
3197
  if (c) {
3070
3198
  n.push(c);
3071
3199
  continue;
3072
3200
  }
3073
3201
  const h = e[i + 1];
3074
3202
  if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
3075
- if (Sn.test(h)) {
3076
- const l = re(s.trim());
3203
+ if (Ln.test(h)) {
3204
+ const l = ie(s.trim());
3077
3205
  n.push({ level: 1, ...l }), i += 1;
3078
3206
  continue;
3079
3207
  }
3080
- if (Cn.test(h) && h.trim().length >= 1) {
3081
- const l = re(s.trim());
3208
+ if (On.test(h) && h.trim().length >= 1) {
3209
+ const l = ie(s.trim());
3082
3210
  n.push({ level: 2, ...l }), i += 1;
3083
3211
  continue;
3084
3212
  }
@@ -3086,31 +3214,31 @@ function An(t) {
3086
3214
  }
3087
3215
  return n;
3088
3216
  }
3089
- const Rn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
3090
- function Mn() {
3217
+ const Fn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
3218
+ function jn() {
3091
3219
  const t = /* @__PURE__ */ new Map();
3092
3220
  return {
3093
3221
  slug(e, n) {
3094
- const r = n !== void 0 && n.length > 0 ? n : On(e), i = t.get(r) ?? 0;
3222
+ const r = n !== void 0 && n.length > 0 ? n : Bn(e), i = t.get(r) ?? 0;
3095
3223
  return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
3096
3224
  }
3097
3225
  };
3098
3226
  }
3099
- function On(t) {
3100
- return t.toLowerCase().replace(Rn, "").replace(/\s+/g, "-");
3227
+ function Bn(t) {
3228
+ return t.toLowerCase().replace(Fn, "").replace(/\s+/g, "-");
3101
3229
  }
3102
- function Ln(t) {
3230
+ function In(t) {
3103
3231
  let e = t.trim();
3104
3232
  e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
3105
3233
  for (let n = 0; n < 3; n++)
3106
3234
  e = e.replace(/\*\*([^*]+)\*\*/g, "$1"), e = e.replace(/__([^_]+)__/g, "$1"), e = e.replace(/~~([^~]+)~~/g, "$1"), e = e.replace(/\*([^*]+)\*/g, "$1"), e = e.replace(/_([^_]+)_/g, "$1"), e = e.replace(/`([^`]+)`/g, "$1");
3107
3235
  return e.trim();
3108
3236
  }
3109
- function Hn(t, e) {
3237
+ function Un(t, e) {
3110
3238
  if (t.length === 0)
3111
3239
  return "";
3112
- const n = Mn(), i = t.map((o) => {
3113
- const a = Ln(o.text), c = n.slug(a, o.explicitId);
3240
+ const n = jn(), i = t.map((o) => {
3241
+ const a = In(o.text), c = n.slug(a, o.explicitId);
3114
3242
  return { level: o.level, text: a, anchor: c };
3115
3243
  }).filter((o) => o.level <= e);
3116
3244
  if (i.length === 0)
@@ -3119,32 +3247,32 @@ function Hn(t, e) {
3119
3247
  return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
3120
3248
  `);
3121
3249
  }
3122
- function Dn(t, e = {}) {
3123
- const r = $(t).filter((o) => {
3124
- const a = E(o.inner);
3125
- return a.length === 1 && q(a[0]);
3250
+ function zn(t, e = {}) {
3251
+ const r = W(t).filter((o) => {
3252
+ const a = C(o.inner);
3253
+ return a.length === 1 && P(a[0]);
3126
3254
  });
3127
3255
  if (r.length === 0)
3128
3256
  return t;
3129
- const i = An(t);
3257
+ const i = Dn(t);
3130
3258
  let s = t;
3131
3259
  for (let o = r.length - 1; o >= 0; o--) {
3132
- const a = r[o], { maxLevel: c } = sn(a.inner, e.path), h = Hn(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
3260
+ const a = r[o], { maxLevel: c } = un(a.inner, e.path), h = Un(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
3133
3261
  s = A(A(l, h), u);
3134
3262
  }
3135
3263
  return s;
3136
3264
  }
3137
- async function xe(t, e) {
3138
- const n = e.path, r = e.context, i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Ue(), {
3265
+ async function we(t, e) {
3266
+ const n = e.path, r = e.context, i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Je(), {
3139
3267
  source: a,
3140
3268
  declarationUpdates: c
3141
- } = await on(t, { path: n, context: { ...r } });
3142
- _n(
3269
+ } = await fn(t, { path: n, context: { ...r } });
3270
+ An(
3143
3271
  v(r, c ?? {}),
3144
3272
  s,
3145
3273
  n
3146
3274
  );
3147
- const h = await kn(a, {
3275
+ const h = await Cn(a, {
3148
3276
  path: n,
3149
3277
  context: r,
3150
3278
  declarationUpdates: c ?? {},
@@ -3154,19 +3282,19 @@ async function xe(t, e) {
3154
3282
  visitStack: o,
3155
3283
  warnings: s,
3156
3284
  inComponent: e.inComponent ?? !1
3157
- }), { source: l, context: u } = h, { source: w, directives: m } = dn(l, {
3285
+ }), { source: l, context: u } = h, { source: g, directives: w } = xn(l, {
3158
3286
  path: n,
3159
3287
  registry: i,
3160
3288
  context: u
3161
- }), f = e.loader;
3162
- if (m.length > 0 && !f)
3289
+ }), p = e.loader;
3290
+ if (w.length > 0 && !p)
3163
3291
  throw new Error("loader is required when processing include directives");
3164
- let y = w;
3165
- return m.length > 0 && f && (y = await Qt({
3166
- source: w,
3167
- directives: m,
3292
+ let x = g;
3293
+ return w.length > 0 && p && (x = await an({
3294
+ source: g,
3295
+ directives: w,
3168
3296
  context: u,
3169
- loader: f,
3297
+ loader: p,
3170
3298
  root: e.root,
3171
3299
  path: n,
3172
3300
  preserveFrontMatter: e.preserveFrontMatter,
@@ -3175,42 +3303,42 @@ async function xe(t, e) {
3175
3303
  warnings: s,
3176
3304
  registry: i,
3177
3305
  constrainToRoot: e.constrainToRoot
3178
- })), y = await Yt(y, {
3306
+ })), x = await nn(x, {
3179
3307
  context: u,
3180
3308
  path: n,
3181
3309
  registry: i,
3182
- loader: f,
3310
+ loader: p,
3183
3311
  rootDir: e.root,
3184
3312
  warnings: s,
3185
3313
  visitStack: o,
3186
3314
  parentContext: u,
3187
3315
  preserveHgComments: e.preserveHgComments,
3188
3316
  constrainToRoot: e.constrainToRoot
3189
- }), y = await Ne(y, u, {
3317
+ }), x = await Pe(x, u, {
3190
3318
  path: n,
3191
3319
  registry: i,
3192
- loader: f,
3320
+ loader: p,
3193
3321
  rootDir: e.root,
3194
3322
  warnings: s,
3195
3323
  visitStack: o,
3196
3324
  parentContext: u,
3197
3325
  preserveHgComments: e.preserveHgComments,
3198
3326
  constrainToRoot: e.constrainToRoot
3199
- }), y = Dn(y, { path: n }), y = pn(y, e.preserveHgComments), y;
3327
+ }), x = zn(x, { path: n }), x = yn(x, e.preserveHgComments), x;
3200
3328
  }
3201
- async function qe(t, e = {}) {
3202
- const n = e.path, r = v(e.context), i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Ue(), { context: a, body: c, rawFrontMatter: h } = V(
3329
+ async function nt(t, e = {}) {
3330
+ const n = e.path, r = v(e.context), i = e.registry ?? new De(), s = e.warnings ?? [], o = e.visitStack ?? new Je(), { context: a, body: c, rawFrontMatter: h } = q(
3203
3331
  t,
3204
3332
  n
3205
3333
  ), l = v(r, a);
3206
- let u = await xe(c, {
3334
+ let u = await we(c, {
3207
3335
  ...e,
3208
3336
  context: l,
3209
3337
  registry: i,
3210
3338
  warnings: s,
3211
3339
  visitStack: o
3212
3340
  });
3213
- return u = un(u, {
3341
+ return u = kn(u, {
3214
3342
  preserveFrontMatter: e.preserveFrontMatter,
3215
3343
  rawFrontMatter: h
3216
3344
  }), {
@@ -3218,21 +3346,21 @@ async function qe(t, e = {}) {
3218
3346
  warnings: s
3219
3347
  };
3220
3348
  }
3221
- async function Nn(t, e) {
3222
- const n = e.path, { context: r, body: i } = V(t, n), s = v(e.context, r);
3223
- return xe(i, {
3349
+ async function Vn(t, e) {
3350
+ const n = e.path, { context: r, body: i } = q(t, n), s = v(e.context, r);
3351
+ return we(i, {
3224
3352
  ...e,
3225
3353
  context: s,
3226
3354
  preserveFrontMatter: !1
3227
3355
  });
3228
3356
  }
3229
- async function Fn(t, e, n) {
3230
- const r = n?.loader ?? oe(), i = await Et(t, { root: n?.root }), s = i.rootDir ?? n?.root, o = n?.dataSources, a = o && Object.keys(o).length > 0 ? await He(o, { root: s, loader: r }) : {}, c = v(
3357
+ async function Zn(t, e, n) {
3358
+ const r = n?.loader ?? He(), i = await At(t, { root: n?.root }), s = i.rootDir ?? n?.root, o = n?.dataSources, a = o && Object.keys(o).length > 0 ? await Ne(o, { root: s, loader: r }) : {}, c = v(
3231
3359
  a,
3232
3360
  e,
3233
3361
  n?.serverContext
3234
3362
  );
3235
- return qe(i.source, {
3363
+ return nt(i.source, {
3236
3364
  context: c,
3237
3365
  loader: r,
3238
3366
  root: s,
@@ -3242,7 +3370,7 @@ async function Fn(t, e, n) {
3242
3370
  preserveHgComments: n?.preserveHgComments
3243
3371
  });
3244
3372
  }
3245
- async function nr(t, e, n) {
3373
+ async function hr(t, e, n) {
3246
3374
  if (n != null && "serverContext" in n && n.serverContext != null)
3247
3375
  throw d({
3248
3376
  code: "server_context_on_client"
@@ -3260,7 +3388,7 @@ async function nr(t, e, n) {
3260
3388
  let i, s;
3261
3389
  typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
3262
3390
  const o = v(e);
3263
- return qe(i, {
3391
+ return nt(i, {
3264
3392
  context: o,
3265
3393
  loader: r,
3266
3394
  root: n?.root,
@@ -3270,30 +3398,30 @@ async function nr(t, e, n) {
3270
3398
  constrainToRoot: n?.constrainToRoot
3271
3399
  });
3272
3400
  }
3273
- function jn(t, e) {
3274
- if (he(t))
3401
+ function qn(t, e) {
3402
+ if (le(t))
3275
3403
  throw d({
3276
3404
  code: "parse_error",
3277
3405
  path: e,
3278
3406
  details: {
3279
- message: de(t) ?? "unclosed hyogen block (missing closing marker)"
3407
+ message: he(t) ?? "unclosed hyogen block (missing closing marker)"
3280
3408
  }
3281
3409
  });
3282
- const n = [], r = $(t);
3410
+ const n = [], r = W(t);
3283
3411
  for (const i of r) {
3284
- const s = E(i.inner);
3412
+ const s = C(i.inner);
3285
3413
  if (s.length === 0)
3286
3414
  throw d({
3287
3415
  code: "parse_error",
3288
3416
  path: e,
3289
3417
  details: { message: "empty hyogen block" }
3290
3418
  });
3291
- if (s.length === 1 && ue(s[0]) || s.length === 1 && q(s[0]) || s.length === 1 && (te(s[0]) || z(s[0])))
3419
+ if (s.length === 1 && de(s[0]) || s.length === 1 && P(s[0]) || s.length === 1 && (ne(s[0]) || V(s[0])))
3292
3420
  continue;
3293
3421
  const o = s[0];
3294
3422
  if (o === "endblock" || /^block\s+/.test(o))
3295
3423
  continue;
3296
- const a = j(o, e);
3424
+ const a = B(o, e);
3297
3425
  if (a) {
3298
3426
  n.push({ kind: "extend", path: a.path });
3299
3427
  continue;
@@ -3301,8 +3429,8 @@ function jn(t, e) {
3301
3429
  if (s.length !== 1) {
3302
3430
  const c = s.join(`
3303
3431
  `);
3304
- if (z(c) || s.every(
3305
- (l) => te(l) || j(l) !== null
3432
+ if (V(c) || s.every(
3433
+ (l) => ne(l) || B(l) !== null
3306
3434
  ))
3307
3435
  continue;
3308
3436
  throw d({
@@ -3312,12 +3440,12 @@ function jn(t, e) {
3312
3440
  });
3313
3441
  }
3314
3442
  if (/^include\s+/i.test(o)) {
3315
- const c = Ve(i.inner, e);
3443
+ const c = tt(i.inner, e);
3316
3444
  n.push({ kind: "include", path: c.path });
3317
3445
  continue;
3318
3446
  }
3319
3447
  if (/^component\s+/i.test(o)) {
3320
- const c = Ze(i.inner, e);
3448
+ const c = et(i.inner, e);
3321
3449
  n.push({ kind: "component", path: c.path });
3322
3450
  continue;
3323
3451
  }
@@ -3329,8 +3457,8 @@ function jn(t, e) {
3329
3457
  }
3330
3458
  return n;
3331
3459
  }
3332
- function Bn(t, e, n) {
3333
- return H(t) ? t : Z(t, {
3460
+ function Pn(t, e, n) {
3461
+ return N(t) ? t : Z(t, {
3334
3462
  rootDir: n.root,
3335
3463
  fromPath: e,
3336
3464
  documentPath: e,
@@ -3338,19 +3466,19 @@ function Bn(t, e, n) {
3338
3466
  hyogenPath: !0
3339
3467
  });
3340
3468
  }
3341
- async function In(t, e, n = {}) {
3469
+ async function Kn(t, e, n = {}) {
3342
3470
  const r = t.map(
3343
- (l) => H(l) ? l : p.resolve(l)
3471
+ (l) => N(l) ? l : f.resolve(l)
3344
3472
  ), i = new Set(r), s = /* @__PURE__ */ new Set(), o = [], a = [...r];
3345
3473
  for (; a.length > 0; ) {
3346
3474
  const l = a.shift();
3347
3475
  if (s.has(l))
3348
3476
  continue;
3349
3477
  s.add(l);
3350
- const u = await e(l), w = jn(u, l);
3351
- for (const m of w) {
3352
- const f = Bn(m.path, l, n);
3353
- o.push({ from: l, to: f, kind: m.kind }), s.has(f) || a.push(f);
3478
+ const u = await e(l), g = qn(u, l);
3479
+ for (const w of g) {
3480
+ const p = Pn(w.path, l, n);
3481
+ o.push({ from: l, to: p, kind: w.kind }), s.has(p) || a.push(p);
3354
3482
  }
3355
3483
  }
3356
3484
  const c = [...s], h = c.filter((l) => !i.has(l));
@@ -3361,22 +3489,22 @@ async function In(t, e, n = {}) {
3361
3489
  edges: o
3362
3490
  };
3363
3491
  }
3364
- function Un(t) {
3492
+ function Yn(t) {
3365
3493
  return t.replace(/\\/g, "/").split("/").filter((r) => r.length > 0).some((r) => r.startsWith("_"));
3366
3494
  }
3367
- function zn(t) {
3368
- return rt.scan(t).isGlob;
3495
+ function Xn(t) {
3496
+ return pt.scan(t).isGlob;
3369
3497
  }
3370
- function Zn(t) {
3371
- return t.root ? p.resolve(t.root) : t.cwd ? p.resolve(t.cwd) : B(process.cwd()) ?? process.cwd();
3498
+ function Gn(t) {
3499
+ return t.root ? f.resolve(t.root) : t.cwd ? f.resolve(t.cwd) : I(process.cwd()) ?? process.cwd();
3372
3500
  }
3373
- async function Vn(t, e = {}) {
3374
- const n = Array.isArray(t) ? t : [t], r = Zn(e), i = e.includeUnderscoreEntries === !0, s = /* @__PURE__ */ new Map();
3501
+ async function Jn(t, e = {}) {
3502
+ const n = Array.isArray(t) ? t : [t], r = Gn(e), i = e.includeUnderscoreEntries === !0, s = /* @__PURE__ */ new Map();
3375
3503
  for (const o of n) {
3376
- if (!zn(o)) {
3377
- const c = p.isAbsolute(o) ? p.resolve(o) : p.resolve(r, o);
3504
+ if (!Xn(o)) {
3505
+ const c = f.isAbsolute(o) ? f.resolve(o) : f.resolve(r, o);
3378
3506
  try {
3379
- if (!(await ie(c)).isFile())
3507
+ if (!(await se(c)).isFile())
3380
3508
  throw d({
3381
3509
  code: "file_not_found",
3382
3510
  path: c,
@@ -3397,48 +3525,48 @@ async function Vn(t, e = {}) {
3397
3525
  }
3398
3526
  }) : l;
3399
3527
  }
3400
- const h = p.relative(r, c).replace(/\\/g, "/");
3528
+ const h = f.relative(r, c).replace(/\\/g, "/");
3401
3529
  s.set(h, c);
3402
3530
  continue;
3403
3531
  }
3404
- const a = await nt(o, {
3532
+ const a = await ft(o, {
3405
3533
  cwd: r,
3406
3534
  absolute: !0,
3407
3535
  onlyFiles: !0,
3408
3536
  dot: !1
3409
3537
  });
3410
3538
  for (const c of a) {
3411
- const h = p.relative(r, c).replace(/\\/g, "/");
3412
- !i && Un(h) || s.set(h, p.resolve(c));
3539
+ const h = f.relative(r, c).replace(/\\/g, "/");
3540
+ !i && Yn(h) || s.set(h, f.resolve(c));
3413
3541
  }
3414
3542
  }
3415
3543
  return [...s.values()];
3416
3544
  }
3417
- function qn(t) {
3545
+ function Qn(t) {
3418
3546
  return t instanceof Error && t.name === "HyogenError" && "code" in t && typeof t.code == "string";
3419
3547
  }
3420
- function Pn(t, e) {
3548
+ function er(t, e) {
3421
3549
  if (t)
3422
- return p.resolve(t);
3550
+ return f.resolve(t);
3423
3551
  for (const n of e) {
3424
- const r = B(n);
3552
+ const r = I(n);
3425
3553
  if (r)
3426
3554
  return r;
3427
3555
  }
3428
- return e.length > 0 ? p.dirname(p.resolve(e[0])) : process.cwd();
3556
+ return e.length > 0 ? f.dirname(f.resolve(e[0])) : process.cwd();
3429
3557
  }
3430
- async function rr(t) {
3431
- const e = await Vn(t.input, {
3558
+ async function dr(t) {
3559
+ const e = await Jn(t.input, {
3432
3560
  root: t.root,
3433
3561
  includeUnderscoreEntries: t.includeUnderscoreEntries
3434
- }), n = Pn(t.root, e), r = t.loader ?? oe(), i = B(n) !== void 0;
3435
- e.length > 0 && await In(e, r, {
3562
+ }), n = er(t.root, e), r = t.loader ?? He(), i = I(n) !== void 0;
3563
+ e.length > 0 && await Kn(e, r, {
3436
3564
  root: n,
3437
3565
  constrainToRoot: i
3438
3566
  });
3439
- const s = t.dataSources, o = s && Object.keys(s).length > 0 ? await He(s, { root: n, loader: r }) : {}, a = v(o, t.context), c = [], h = [];
3567
+ const s = t.dataSources, o = s && Object.keys(s).length > 0 ? await Ne(s, { root: n, loader: r }) : {}, a = v(o, t.context), c = [], h = [];
3440
3568
  for (const l of e) {
3441
- const u = p.resolve(l), w = p.relative(n, u).replace(/\\/g, "/"), m = await Fn(
3569
+ const u = f.resolve(l), g = f.relative(n, u).replace(/\\/g, "/"), w = await Zn(
3442
3570
  { path: u },
3443
3571
  a,
3444
3572
  {
@@ -3448,27 +3576,27 @@ async function rr(t) {
3448
3576
  preserveFrontMatter: t.preserveFrontMatter,
3449
3577
  preserveHgComments: t.preserveHgComments
3450
3578
  }
3451
- ), f = p.join(t.outDir, w);
3579
+ ), p = f.join(t.outDir, g);
3452
3580
  try {
3453
- await Xe(p.dirname(f), { recursive: !0 }), await Je(f, m.markdown, "utf8");
3454
- } catch (y) {
3455
- if (qn(y))
3456
- throw y;
3457
- const W = y instanceof Error ? y.message : "unknown write error";
3581
+ await at(f.dirname(p), { recursive: !0 }), await ct(p, w.markdown, "utf8");
3582
+ } catch (x) {
3583
+ if (Qn(x))
3584
+ throw x;
3585
+ const $ = x instanceof Error ? x.message : "unknown write error";
3458
3586
  throw d({
3459
3587
  code: "load_failed",
3460
- path: f,
3588
+ path: p,
3461
3589
  details: {
3462
- path: f,
3463
- reason: W
3590
+ path: p,
3591
+ reason: $
3464
3592
  }
3465
3593
  });
3466
3594
  }
3467
- c.push({ path: w, markdown: m.markdown }), h.push(...m.warnings);
3595
+ c.push({ path: g, markdown: w.markdown }), h.push(...w.warnings);
3468
3596
  }
3469
3597
  return { files: c, warnings: h };
3470
3598
  }
3471
- function ir(t, e) {
3599
+ function ur(t, e) {
3472
3600
  const n = [`[hyogen:${t}] ${e.code}`], r = {};
3473
3601
  if (e.details)
3474
3602
  for (const [i, s] of Object.entries(e.details))
@@ -3480,15 +3608,15 @@ function ir(t, e) {
3480
3608
  `);
3481
3609
  }
3482
3610
  export {
3483
- rr as build,
3484
- dt as createFsLoader,
3611
+ dr as build,
3612
+ Me as createFsLoader,
3485
3613
  d as createHyogenError,
3486
- oe as createNodeLoader,
3487
- ir as formatDiagnosticLog,
3488
- lt as formatMessage,
3489
- H as isRemotePath,
3490
- He as loadDataSources,
3491
- nr as renderClient,
3492
- Fn as renderServer
3614
+ He as createNodeLoader,
3615
+ ur as formatDiagnosticLog,
3616
+ mr as formatMessage,
3617
+ N as isRemotePath,
3618
+ Ne as loadDataSources,
3619
+ hr as renderClient,
3620
+ Zn as renderServer
3493
3621
  };
3494
3622
  //# sourceMappingURL=index.js.map