@b4moss/hyogen-md 0.12.0 → 0.14.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 (84) hide show
  1. package/README.md +24 -3
  2. package/README_ja.md +24 -3
  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 +5742 -0
  9. package/dist/client.js +1111 -870
  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/interpolateFenceExpressions.d.ts +8 -0
  31. package/dist/expr/parseExpression.d.ts +4 -0
  32. package/dist/frontmatter/parseFrontMatter.d.ts +3 -0
  33. package/dist/include/VisitStack.d.ts +13 -0
  34. package/dist/include/expandIncludes.d.ts +18 -0
  35. package/dist/index.d.ts +11 -113
  36. package/dist/index.js +839 -597
  37. package/dist/io/createFsLoader.d.ts +6 -0
  38. package/dist/io/createNodeLoader.d.ts +4 -0
  39. package/dist/io/isRemotePath.d.ts +2 -0
  40. package/dist/io/loadDataSources.d.ts +8 -0
  41. package/dist/io/parseCsvFromString.d.ts +1 -0
  42. package/dist/io/parseDataFile.d.ts +1 -0
  43. package/dist/io/resolveIncludePath.d.ts +1 -0
  44. package/dist/layout/expandExtendsAndBlocks.d.ts +19 -0
  45. package/dist/layout/parseBlockOpener.d.ts +8 -0
  46. package/dist/layout/parseBlockStructures.d.ts +15 -0
  47. package/dist/layout/parseExtendBlock.d.ts +12 -0
  48. package/dist/layout/parseExtendDirective.d.ts +5 -0
  49. package/dist/logic/executeDeclaration.d.ts +6 -0
  50. package/dist/logic/executeDeclarations.d.ts +6 -0
  51. package/dist/logic/executeStatement.d.ts +10 -0
  52. package/dist/logic/hgBlockUtils.d.ts +3 -0
  53. package/dist/logic/parseDeclaration.d.ts +5 -0
  54. package/dist/logic/parseStatement.d.ts +3 -0
  55. package/dist/logic/reservedWords.d.ts +2 -0
  56. package/dist/logic/stripComments.d.ts +2 -0
  57. package/dist/markdown/shiftHeadings.d.ts +25 -0
  58. package/dist/parse/hgMarkers.d.ts +5 -0
  59. package/dist/parse/parseComponentDirective.d.ts +6 -0
  60. package/dist/parse/parseIncludeDirective.d.ts +2 -0
  61. package/dist/parse/scanHgBlocks.d.ts +10 -0
  62. package/dist/paths/assertWithinRootDir.d.ts +2 -0
  63. package/dist/paths/findDocRoot.d.ts +1 -0
  64. package/dist/paths/resolveRenderInput.d.ts +11 -0
  65. package/dist/paths/resolveTemplatePath.d.ts +9 -0
  66. package/dist/pipeline/applyFrontMatterOutputOption.d.ts +4 -0
  67. package/dist/pipeline/executeHgBlocks.d.ts +9 -0
  68. package/dist/pipeline/joinRemovalSeam.d.ts +12 -0
  69. package/dist/pipeline/renderDocument.d.ts +22 -0
  70. package/dist/pipeline/stripHgComments.d.ts +7 -0
  71. package/dist/renderClient.d.ts +15 -0
  72. package/dist/renderServer.d.ts +4 -0
  73. package/dist/security/forbiddenKeys.d.ts +3 -0
  74. package/dist/security/scanSuspiciousContext.d.ts +6 -0
  75. package/dist/shims/fs-browser.d.ts +6 -0
  76. package/dist/shims/fs-promises-browser.d.ts +5 -0
  77. package/dist/toc/expandToc.d.ts +8 -0
  78. package/dist/toc/extractHeadings.d.ts +10 -0
  79. package/dist/toc/formatTocMarkdown.d.ts +7 -0
  80. package/dist/toc/githubHeadingSlug.d.ts +11 -0
  81. package/dist/toc/parseTocDirective.d.ts +10 -0
  82. package/dist/toc/plainifyHeadingText.d.ts +2 -0
  83. package/dist/types.d.ts +211 -0
  84. package/package.json +17 -4
package/dist/client.js CHANGED
@@ -1,44 +1,44 @@
1
- import { parse as Pe } from "yaml";
2
- const Ie = { 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})" }, ze = { 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})' }, Ue = { 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" }, J = {
3
- errors: Ie,
4
- warnings: ze,
5
- warningReasons: Ue
6
- }, Ze = J.errors, qe = J.warnings;
7
- function ye(t, e) {
1
+ import { parse as Qe } from "yaml";
2
+ const et = { 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}", 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})" }, tt = { 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})' }, nt = { 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" }, Q = {
3
+ errors: et,
4
+ warnings: tt,
5
+ warningReasons: nt
6
+ }, rt = Q.errors, it = Q.warnings;
7
+ function We(t, e) {
8
8
  return t === void 0 ? "" : t.replace(/\{([^}]+)\}/g, (n, r) => {
9
9
  if (e === void 0 || !(r in e))
10
10
  return n;
11
- const s = e[r];
12
- return s == null ? "" : String(s);
11
+ const i = e[r];
12
+ return i == null ? "" : String(i);
13
13
  });
14
14
  }
15
- function Ve(t, e) {
16
- return ye(Ze[t], e);
15
+ function st(t, e) {
16
+ return We(rt[t], e);
17
17
  }
18
- function R(t, e) {
19
- return ye(qe[t], e);
18
+ function H(t, e) {
19
+ return We(it[t], e);
20
20
  }
21
- function u(t) {
22
- const e = t.message ?? Ve(t.code, t.details), n = new Error(e);
21
+ function d(t) {
22
+ const e = t.message ?? st(t.code, t.details), n = new Error(e);
23
23
  return n.name = "HyogenError", n.code = t.code, n.message = e, n.path = t.path, n.details = t.details, n;
24
24
  }
25
- function _(...t) {
25
+ function S(...t) {
26
26
  const e = {};
27
27
  for (const n of t)
28
28
  n != null && Object.assign(e, n);
29
29
  return e;
30
30
  }
31
- class _e {
31
+ class $e {
32
32
  components = /* @__PURE__ */ new Map();
33
33
  register(e, n, r) {
34
34
  if (this.components.has(e.alias))
35
- throw u({
35
+ throw d({
36
36
  code: "duplicate_component_alias",
37
37
  path: r ?? e.definedAt,
38
38
  details: { alias: e.alias }
39
39
  });
40
40
  if (n.includes(e.alias))
41
- throw u({
41
+ throw d({
42
42
  code: "alias_collision",
43
43
  path: r ?? e.definedAt,
44
44
  details: { alias: e.alias }
@@ -52,8 +52,8 @@ class _e {
52
52
  return this.components.has(e);
53
53
  }
54
54
  }
55
- const de = 64 * 1024;
56
- function P(t, e) {
55
+ const pe = 64 * 1024;
56
+ function I(t, e) {
57
57
  if (!t.startsWith("---"))
58
58
  return { context: {}, body: t };
59
59
  const n = t.indexOf(`
@@ -64,25 +64,25 @@ function P(t, e) {
64
64
  ---`, n);
65
65
  if (r === -1)
66
66
  return { context: {}, body: t };
67
- const s = t.slice(n + 1, r), i = Buffer.byteLength(s, "utf8");
68
- if (i > de)
69
- throw u({
67
+ const i = t.slice(n + 1, r), s = Buffer.byteLength(i, "utf8");
68
+ if (s > pe)
69
+ throw d({
70
70
  code: "frontmatter_too_large",
71
71
  path: e,
72
72
  details: {
73
- size: i,
74
- limit: de
73
+ size: s,
74
+ limit: pe
75
75
  }
76
76
  });
77
- if (s.trim().length === 0)
78
- throw u({
77
+ if (i.trim().length === 0)
78
+ throw d({
79
79
  code: "parse_error",
80
80
  path: e,
81
81
  details: { message: "empty front matter" }
82
82
  });
83
83
  let o;
84
84
  try {
85
- const h = Pe(s);
85
+ const h = Qe(i);
86
86
  if (h == null)
87
87
  o = {};
88
88
  else if (typeof h == "object" && !Array.isArray(h))
@@ -90,7 +90,7 @@ function P(t, e) {
90
90
  else
91
91
  throw new Error("front matter must be a YAML mapping");
92
92
  } catch (h) {
93
- throw u({
93
+ throw d({
94
94
  code: "parse_error",
95
95
  path: e,
96
96
  details: {
@@ -106,43 +106,43 @@ function P(t, e) {
106
106
  context: o,
107
107
  body: c,
108
108
  rawFrontMatter: `---
109
- ${s}
109
+ ${i}
110
110
  ---`
111
111
  };
112
112
  }
113
- const Ke = /* @__PURE__ */ new Set([
113
+ const ot = /* @__PURE__ */ new Set([
114
114
  "string",
115
115
  "number",
116
116
  "boolean",
117
117
  "object",
118
118
  "array"
119
119
  ]);
120
- function Ye(t, e) {
120
+ function at(t, e) {
121
121
  const n = t.props;
122
122
  if (n === void 0)
123
123
  return {};
124
124
  if (typeof n != "object" || n === null || Array.isArray(n))
125
- throw u({
125
+ throw d({
126
126
  code: "parse_error",
127
127
  path: e,
128
128
  details: { message: "props must be a YAML mapping" }
129
129
  });
130
130
  const r = {};
131
- for (const [s, i] of Object.entries(n)) {
132
- if (typeof i != "object" || i === null || Array.isArray(i)) {
133
- r[s] = {};
131
+ for (const [i, s] of Object.entries(n)) {
132
+ if (typeof s != "object" || s === null || Array.isArray(s)) {
133
+ r[i] = {};
134
134
  continue;
135
135
  }
136
- const o = i, a = {};
136
+ const o = s, a = {};
137
137
  if ("type" in o && o.type !== void 0) {
138
138
  const c = String(o.type);
139
- Ke.has(c) ? a.type = c : a.type = void 0;
139
+ ot.has(c) ? a.type = c : a.type = void 0;
140
140
  }
141
- "isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[s] = a;
141
+ "isRequired" in o && (a.isRequired = !!o.isRequired), "default" in o && (a.default = o.default), r[i] = a;
142
142
  }
143
143
  return r;
144
144
  }
145
- function Xe(t) {
145
+ function ct(t) {
146
146
  if (t != null) {
147
147
  if (typeof t == "string") return "string";
148
148
  if (typeof t == "number") return "number";
@@ -151,30 +151,30 @@ function Xe(t) {
151
151
  if (typeof t == "object") return "object";
152
152
  }
153
153
  }
154
- function Ge(t, e) {
154
+ function lt(t, e) {
155
155
  return e === "array" ? Array.isArray(t) : e === "object" ? typeof t == "object" && t !== null && !Array.isArray(t) : typeof t === e;
156
156
  }
157
- function U(t, e) {
157
+ function Z(t, e) {
158
158
  return {
159
159
  code: t,
160
- message: R(t, e),
160
+ message: H(t, e),
161
161
  details: e
162
162
  };
163
163
  }
164
- function Je(t, e, n) {
165
- const r = [], s = {}, i = new Set(Object.keys(e));
164
+ function ht(t, e, n) {
165
+ const r = [], i = {}, s = new Set(Object.keys(e));
166
166
  for (const [o, a] of Object.entries(e)) {
167
167
  const c = Object.prototype.hasOwnProperty.call(t, o);
168
168
  let h = c ? t[o] : void 0;
169
169
  if (c || (a.default !== void 0 ? h = a.default : (a.isRequired && r.push(
170
- U("prop_missing", {
170
+ Z("prop_missing", {
171
171
  prop: o,
172
172
  component: n
173
173
  })
174
174
  ), h = void 0)), c && h !== void 0 && h !== null) {
175
- const l = a.type ?? Xe(h);
176
- l && !Ge(h, l) && (r.push(
177
- U("prop_type_mismatch", {
175
+ const l = a.type ?? ct(h);
176
+ l && !lt(h, l) && (r.push(
177
+ Z("prop_type_mismatch", {
178
178
  prop: o,
179
179
  component: n,
180
180
  expected: l,
@@ -182,194 +182,194 @@ function Je(t, e, n) {
182
182
  })
183
183
  ), h = void 0);
184
184
  }
185
- s[o] = h;
185
+ i[o] = h;
186
186
  }
187
187
  for (const o of Object.keys(t))
188
- i.has(o) || (Object.keys(e).length > 0 ? r.push(
189
- U("prop_unknown", {
188
+ s.has(o) || (Object.keys(e).length > 0 ? r.push(
189
+ Z("prop_unknown", {
190
190
  prop: o,
191
191
  component: n
192
192
  })
193
- ) : s[o] = t[o]);
194
- return { values: s, warnings: r };
193
+ ) : i[o] = t[o]);
194
+ return { values: i, warnings: r };
195
195
  }
196
- function Se(t) {
196
+ function Ae(t) {
197
197
  return /^https?:\/\//i.test(t);
198
198
  }
199
- function Qe(t) {
199
+ function ut(t) {
200
200
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
201
201
  }
202
- var Z, ue;
203
- function et() {
204
- if (ue) return Z;
205
- ue = 1;
206
- function t(s) {
207
- if (typeof s != "string")
208
- throw new TypeError("Path must be a string. Received " + JSON.stringify(s));
209
- }
210
- function e(s, i) {
211
- for (var o = "", a = 0, c = -1, h = 0, l, d = 0; d <= s.length; ++d) {
212
- if (d < s.length)
213
- l = s.charCodeAt(d);
202
+ var q, me;
203
+ function dt() {
204
+ if (me) return q;
205
+ me = 1;
206
+ function t(i) {
207
+ if (typeof i != "string")
208
+ throw new TypeError("Path must be a string. Received " + JSON.stringify(i));
209
+ }
210
+ function e(i, s) {
211
+ for (var o = "", a = 0, c = -1, h = 0, l, u = 0; u <= i.length; ++u) {
212
+ if (u < i.length)
213
+ l = i.charCodeAt(u);
214
214
  else {
215
215
  if (l === 47)
216
216
  break;
217
217
  l = 47;
218
218
  }
219
219
  if (l === 47) {
220
- if (!(c === d - 1 || h === 1)) if (c !== d - 1 && h === 2) {
220
+ if (!(c === u - 1 || h === 1)) if (c !== u - 1 && h === 2) {
221
221
  if (o.length < 2 || a !== 2 || o.charCodeAt(o.length - 1) !== 46 || o.charCodeAt(o.length - 2) !== 46) {
222
222
  if (o.length > 2) {
223
223
  var f = o.lastIndexOf("/");
224
224
  if (f !== o.length - 1) {
225
- f === -1 ? (o = "", a = 0) : (o = o.slice(0, f), a = o.length - 1 - o.lastIndexOf("/")), c = d, h = 0;
225
+ f === -1 ? (o = "", a = 0) : (o = o.slice(0, f), a = o.length - 1 - o.lastIndexOf("/")), c = u, h = 0;
226
226
  continue;
227
227
  }
228
228
  } else if (o.length === 2 || o.length === 1) {
229
- o = "", a = 0, c = d, h = 0;
229
+ o = "", a = 0, c = u, h = 0;
230
230
  continue;
231
231
  }
232
232
  }
233
- i && (o.length > 0 ? o += "/.." : o = "..", a = 2);
233
+ s && (o.length > 0 ? o += "/.." : o = "..", a = 2);
234
234
  } else
235
- o.length > 0 ? o += "/" + s.slice(c + 1, d) : o = s.slice(c + 1, d), a = d - c - 1;
236
- c = d, h = 0;
235
+ o.length > 0 ? o += "/" + i.slice(c + 1, u) : o = i.slice(c + 1, u), a = u - c - 1;
236
+ c = u, h = 0;
237
237
  } else l === 46 && h !== -1 ? ++h : h = -1;
238
238
  }
239
239
  return o;
240
240
  }
241
- function n(s, i) {
242
- var o = i.dir || i.root, a = i.base || (i.name || "") + (i.ext || "");
243
- return o ? o === i.root ? o + a : o + s + a : a;
241
+ function n(i, s) {
242
+ var o = s.dir || s.root, a = s.base || (s.name || "") + (s.ext || "");
243
+ return o ? o === s.root ? o + a : o + i + a : a;
244
244
  }
245
245
  var r = {
246
246
  // path.resolve([from ...], to)
247
247
  resolve: function() {
248
- for (var i = "", o = !1, a, c = arguments.length - 1; c >= -1 && !o; c--) {
248
+ for (var s = "", o = !1, a, c = arguments.length - 1; c >= -1 && !o; c--) {
249
249
  var h;
250
- c >= 0 ? h = arguments[c] : (a === void 0 && (a = process.cwd()), h = a), t(h), h.length !== 0 && (i = h + "/" + i, o = h.charCodeAt(0) === 47);
250
+ c >= 0 ? h = arguments[c] : (a === void 0 && (a = process.cwd()), h = a), t(h), h.length !== 0 && (s = h + "/" + s, o = h.charCodeAt(0) === 47);
251
251
  }
252
- return i = e(i, !o), o ? i.length > 0 ? "/" + i : "/" : i.length > 0 ? i : ".";
252
+ return s = e(s, !o), o ? s.length > 0 ? "/" + s : "/" : s.length > 0 ? s : ".";
253
253
  },
254
- normalize: function(i) {
255
- if (t(i), i.length === 0) return ".";
256
- var o = i.charCodeAt(0) === 47, a = i.charCodeAt(i.length - 1) === 47;
257
- return i = e(i, !o), i.length === 0 && !o && (i = "."), i.length > 0 && a && (i += "/"), o ? "/" + i : i;
254
+ normalize: function(s) {
255
+ if (t(s), s.length === 0) return ".";
256
+ var o = s.charCodeAt(0) === 47, a = s.charCodeAt(s.length - 1) === 47;
257
+ return s = e(s, !o), s.length === 0 && !o && (s = "."), s.length > 0 && a && (s += "/"), o ? "/" + s : s;
258
258
  },
259
- isAbsolute: function(i) {
260
- return t(i), i.length > 0 && i.charCodeAt(0) === 47;
259
+ isAbsolute: function(s) {
260
+ return t(s), s.length > 0 && s.charCodeAt(0) === 47;
261
261
  },
262
262
  join: function() {
263
263
  if (arguments.length === 0)
264
264
  return ".";
265
- for (var i, o = 0; o < arguments.length; ++o) {
265
+ for (var s, o = 0; o < arguments.length; ++o) {
266
266
  var a = arguments[o];
267
- t(a), a.length > 0 && (i === void 0 ? i = a : i += "/" + a);
267
+ t(a), a.length > 0 && (s === void 0 ? s = a : s += "/" + a);
268
268
  }
269
- return i === void 0 ? "." : r.normalize(i);
269
+ return s === void 0 ? "." : r.normalize(s);
270
270
  },
271
- relative: function(i, o) {
272
- if (t(i), t(o), i === o || (i = r.resolve(i), o = r.resolve(o), i === o)) return "";
273
- for (var a = 1; a < i.length && i.charCodeAt(a) === 47; ++a)
271
+ relative: function(s, o) {
272
+ if (t(s), t(o), s === o || (s = r.resolve(s), o = r.resolve(o), s === o)) return "";
273
+ for (var a = 1; a < s.length && s.charCodeAt(a) === 47; ++a)
274
274
  ;
275
- for (var c = i.length, h = c - a, l = 1; l < o.length && o.charCodeAt(l) === 47; ++l)
275
+ for (var c = s.length, h = c - a, l = 1; l < o.length && o.charCodeAt(l) === 47; ++l)
276
276
  ;
277
- for (var d = o.length, f = d - l, g = h < f ? h : f, m = -1, p = 0; p <= g; ++p) {
277
+ for (var u = o.length, f = u - l, g = h < f ? h : f, m = -1, p = 0; p <= g; ++p) {
278
278
  if (p === g) {
279
279
  if (f > g) {
280
280
  if (o.charCodeAt(l + p) === 47)
281
281
  return o.slice(l + p + 1);
282
282
  if (p === 0)
283
283
  return o.slice(l + p);
284
- } else h > g && (i.charCodeAt(a + p) === 47 ? m = p : p === 0 && (m = 0));
284
+ } else h > g && (s.charCodeAt(a + p) === 47 ? m = p : p === 0 && (m = 0));
285
285
  break;
286
286
  }
287
- var $ = i.charCodeAt(a + p), D = o.charCodeAt(l + p);
288
- if ($ !== D)
287
+ var v = s.charCodeAt(a + p), D = o.charCodeAt(l + p);
288
+ if (v !== D)
289
289
  break;
290
- $ === 47 && (m = p);
290
+ v === 47 && (m = p);
291
291
  }
292
292
  var b = "";
293
293
  for (p = a + m + 1; p <= c; ++p)
294
- (p === c || i.charCodeAt(p) === 47) && (b.length === 0 ? b += ".." : b += "/..");
294
+ (p === c || s.charCodeAt(p) === 47) && (b.length === 0 ? b += ".." : b += "/..");
295
295
  return b.length > 0 ? b + o.slice(l + m) : (l += m, o.charCodeAt(l) === 47 && ++l, o.slice(l));
296
296
  },
297
- _makeLong: function(i) {
298
- return i;
297
+ _makeLong: function(s) {
298
+ return s;
299
299
  },
300
- dirname: function(i) {
301
- if (t(i), i.length === 0) return ".";
302
- for (var o = i.charCodeAt(0), a = o === 47, c = -1, h = !0, l = i.length - 1; l >= 1; --l)
303
- if (o = i.charCodeAt(l), o === 47) {
300
+ dirname: function(s) {
301
+ if (t(s), s.length === 0) return ".";
302
+ for (var o = s.charCodeAt(0), a = o === 47, c = -1, h = !0, l = s.length - 1; l >= 1; --l)
303
+ if (o = s.charCodeAt(l), o === 47) {
304
304
  if (!h) {
305
305
  c = l;
306
306
  break;
307
307
  }
308
308
  } else
309
309
  h = !1;
310
- return c === -1 ? a ? "/" : "." : a && c === 1 ? "//" : i.slice(0, c);
310
+ return c === -1 ? a ? "/" : "." : a && c === 1 ? "//" : s.slice(0, c);
311
311
  },
312
- basename: function(i, o) {
312
+ basename: function(s, o) {
313
313
  if (o !== void 0 && typeof o != "string") throw new TypeError('"ext" argument must be a string');
314
- t(i);
314
+ t(s);
315
315
  var a = 0, c = -1, h = !0, l;
316
- if (o !== void 0 && o.length > 0 && o.length <= i.length) {
317
- if (o.length === i.length && o === i) return "";
318
- var d = o.length - 1, f = -1;
319
- for (l = i.length - 1; l >= 0; --l) {
320
- var g = i.charCodeAt(l);
316
+ if (o !== void 0 && o.length > 0 && o.length <= s.length) {
317
+ if (o.length === s.length && o === s) return "";
318
+ var u = o.length - 1, f = -1;
319
+ for (l = s.length - 1; l >= 0; --l) {
320
+ var g = s.charCodeAt(l);
321
321
  if (g === 47) {
322
322
  if (!h) {
323
323
  a = l + 1;
324
324
  break;
325
325
  }
326
326
  } else
327
- f === -1 && (h = !1, f = l + 1), d >= 0 && (g === o.charCodeAt(d) ? --d === -1 && (c = l) : (d = -1, c = f));
327
+ f === -1 && (h = !1, f = l + 1), u >= 0 && (g === o.charCodeAt(u) ? --u === -1 && (c = l) : (u = -1, c = f));
328
328
  }
329
- return a === c ? c = f : c === -1 && (c = i.length), i.slice(a, c);
329
+ return a === c ? c = f : c === -1 && (c = s.length), s.slice(a, c);
330
330
  } else {
331
- for (l = i.length - 1; l >= 0; --l)
332
- if (i.charCodeAt(l) === 47) {
331
+ for (l = s.length - 1; l >= 0; --l)
332
+ if (s.charCodeAt(l) === 47) {
333
333
  if (!h) {
334
334
  a = l + 1;
335
335
  break;
336
336
  }
337
337
  } else c === -1 && (h = !1, c = l + 1);
338
- return c === -1 ? "" : i.slice(a, c);
338
+ return c === -1 ? "" : s.slice(a, c);
339
339
  }
340
340
  },
341
- extname: function(i) {
342
- t(i);
343
- for (var o = -1, a = 0, c = -1, h = !0, l = 0, d = i.length - 1; d >= 0; --d) {
344
- var f = i.charCodeAt(d);
341
+ extname: function(s) {
342
+ t(s);
343
+ for (var o = -1, a = 0, c = -1, h = !0, l = 0, u = s.length - 1; u >= 0; --u) {
344
+ var f = s.charCodeAt(u);
345
345
  if (f === 47) {
346
346
  if (!h) {
347
- a = d + 1;
347
+ a = u + 1;
348
348
  break;
349
349
  }
350
350
  continue;
351
351
  }
352
- c === -1 && (h = !1, c = d + 1), f === 46 ? o === -1 ? o = d : l !== 1 && (l = 1) : o !== -1 && (l = -1);
352
+ c === -1 && (h = !1, c = u + 1), f === 46 ? o === -1 ? o = u : l !== 1 && (l = 1) : o !== -1 && (l = -1);
353
353
  }
354
354
  return o === -1 || c === -1 || // We saw a non-dot character immediately before the dot
355
355
  l === 0 || // The (right-most) trimmed path component is exactly '..'
356
- l === 1 && o === c - 1 && o === a + 1 ? "" : i.slice(o, c);
356
+ l === 1 && o === c - 1 && o === a + 1 ? "" : s.slice(o, c);
357
357
  },
358
- format: function(i) {
359
- if (i === null || typeof i != "object")
360
- throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof i);
361
- return n("/", i);
358
+ format: function(s) {
359
+ if (s === null || typeof s != "object")
360
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof s);
361
+ return n("/", s);
362
362
  },
363
- parse: function(i) {
364
- t(i);
363
+ parse: function(s) {
364
+ t(s);
365
365
  var o = { root: "", dir: "", base: "", ext: "", name: "" };
366
- if (i.length === 0) return o;
367
- var a = i.charCodeAt(0), c = a === 47, h;
366
+ if (s.length === 0) return o;
367
+ var a = s.charCodeAt(0), c = a === 47, h;
368
368
  c ? (o.root = "/", h = 1) : h = 0;
369
- for (var l = -1, d = 0, f = -1, g = !0, m = i.length - 1, p = 0; m >= h; --m) {
370
- if (a = i.charCodeAt(m), a === 47) {
369
+ for (var l = -1, u = 0, f = -1, g = !0, m = s.length - 1, p = 0; m >= h; --m) {
370
+ if (a = s.charCodeAt(m), a === 47) {
371
371
  if (!g) {
372
- d = m + 1;
372
+ u = m + 1;
373
373
  break;
374
374
  }
375
375
  continue;
@@ -378,109 +378,110 @@ function et() {
378
378
  }
379
379
  return l === -1 || f === -1 || // We saw a non-dot character immediately before the dot
380
380
  p === 0 || // The (right-most) trimmed path component is exactly '..'
381
- p === 1 && l === f - 1 && l === d + 1 ? f !== -1 && (d === 0 && c ? o.base = o.name = i.slice(1, f) : o.base = o.name = i.slice(d, f)) : (d === 0 && c ? (o.name = i.slice(1, l), o.base = i.slice(1, f)) : (o.name = i.slice(d, l), o.base = i.slice(d, f)), o.ext = i.slice(l, f)), d > 0 ? o.dir = i.slice(0, d - 1) : c && (o.dir = "/"), o;
381
+ p === 1 && l === f - 1 && l === u + 1 ? f !== -1 && (u === 0 && c ? o.base = o.name = s.slice(1, f) : o.base = o.name = s.slice(u, f)) : (u === 0 && c ? (o.name = s.slice(1, l), o.base = s.slice(1, f)) : (o.name = s.slice(u, l), o.base = s.slice(u, f)), o.ext = s.slice(l, f)), u > 0 ? o.dir = s.slice(0, u - 1) : c && (o.dir = "/"), o;
382
382
  },
383
383
  sep: "/",
384
384
  delimiter: ":",
385
385
  win32: null,
386
386
  posix: null
387
387
  };
388
- return r.posix = r, Z = r, Z;
389
- }
390
- var tt = et();
391
- const y = /* @__PURE__ */ Qe(tt);
392
- function nt(t, e) {
393
- const n = y.relative(e, t);
394
- return n === "" || !n.startsWith("..") && !y.isAbsolute(n);
395
- }
396
- function rt(t, e, n) {
397
- const r = y.resolve(e), s = y.resolve(t);
398
- if (!nt(s, r))
399
- throw u({
388
+ return r.posix = r, q = r, q;
389
+ }
390
+ var ft = dt();
391
+ const _ = /* @__PURE__ */ ut(ft);
392
+ function pt(t, e) {
393
+ const n = _.relative(e, t);
394
+ return n === "" || !n.startsWith("..") && !_.isAbsolute(n);
395
+ }
396
+ function mt(t, e, n) {
397
+ const r = _.resolve(e), i = _.resolve(t);
398
+ if (!pt(i, r))
399
+ throw d({
400
400
  code: "parse_error",
401
401
  path: n,
402
402
  details: { message: "path resolves outside root directory" }
403
403
  });
404
404
  }
405
- function Ce(t, e = {}) {
406
- const { rootDir: n, fromPath: r, documentPath: s, constrainToRoot: i = !1, hyogenPath: o = !1 } = e;
405
+ function Ee(t, e = {}) {
406
+ const { rootDir: n, fromPath: r, documentPath: i, constrainToRoot: s = !1, hyogenPath: o = !1 } = e;
407
407
  if (t.length === 0)
408
- throw u({
408
+ throw d({
409
409
  code: "parse_error",
410
- path: s,
410
+ path: i,
411
411
  details: { message: "empty template path" }
412
412
  });
413
413
  let a;
414
414
  if (t.startsWith("/"))
415
415
  if (n)
416
- a = y.resolve(n, t.slice(1));
416
+ a = _.resolve(n, t.slice(1));
417
417
  else {
418
418
  if (o)
419
- throw u({
419
+ throw d({
420
420
  code: "parse_error",
421
- path: s,
421
+ path: i,
422
422
  details: { message: "root-relative paths require a doc root" }
423
423
  });
424
- if (y.isAbsolute(t))
425
- a = y.resolve(t);
424
+ if (_.isAbsolute(t))
425
+ a = _.resolve(t);
426
426
  else
427
- throw u({
427
+ throw d({
428
428
  code: "parse_error",
429
- path: s,
429
+ path: i,
430
430
  details: { message: "root-relative paths require a doc root" }
431
431
  });
432
432
  }
433
433
  else if (t.startsWith("./") || t.startsWith("../"))
434
434
  if (r)
435
- a = y.resolve(y.dirname(r), t);
435
+ a = _.resolve(_.dirname(r), t);
436
436
  else if (n)
437
- a = y.resolve(n, t);
437
+ a = _.resolve(n, t);
438
438
  else
439
- throw u({
439
+ throw d({
440
440
  code: "parse_error",
441
- path: s,
441
+ path: i,
442
442
  details: { message: "root is required for relative template paths" }
443
443
  });
444
- else if (y.isAbsolute(t))
445
- a = y.resolve(t);
444
+ else if (_.isAbsolute(t))
445
+ a = _.resolve(t);
446
446
  else if (n)
447
- a = y.resolve(n, t);
447
+ a = _.resolve(n, t);
448
448
  else
449
- throw u({
449
+ throw d({
450
450
  code: "parse_error",
451
- path: s,
451
+ path: i,
452
452
  details: { message: "root is required for relative template paths" }
453
453
  });
454
- return n && i && rt(a, n, s), a;
454
+ return n && s && mt(a, n, i), a;
455
455
  }
456
- async function it(t) {
456
+ async function gt(t) {
457
457
  const e = t.registry.get(t.alias);
458
458
  if (!e)
459
- throw u({
459
+ throw d({
460
460
  code: "parse_error",
461
461
  path: t.path,
462
462
  details: {
463
463
  message: `unregistered component: ${t.alias}`
464
464
  }
465
465
  });
466
- const n = Se(e.componentPath) ? e.componentPath : Ce(e.componentPath, {
466
+ const n = Ae(e.componentPath) ? e.componentPath : Ee(e.componentPath, {
467
467
  rootDir: t.rootDir,
468
468
  fromPath: e.definedAt,
469
469
  documentPath: t.path,
470
470
  constrainToRoot: t.constrainToRoot,
471
471
  hyogenPath: !0
472
- }), r = await t.loader(n), { context: s, body: i } = P(r, n), o = Ye(s, n), { values: a, warnings: c } = Je(
472
+ }), r = await t.loader(n), { context: i, body: s } = I(r, n), o = at(i, n), { values: a, warnings: c } = ht(
473
473
  t.props,
474
474
  o,
475
475
  t.alias
476
476
  );
477
477
  t.warnings.push(...c);
478
- const { props: h, ...l } = s, d = _(
478
+ const { props: h, ...l } = i, u = S(
479
479
  t.parentContext,
480
480
  l,
481
481
  a
482
- ), g = (await le(i, {
483
- context: d,
482
+ );
483
+ return (await de(s, {
484
+ context: u,
484
485
  loader: t.loader,
485
486
  root: t.rootDir,
486
487
  path: n,
@@ -492,36 +493,28 @@ async function it(t) {
492
493
  preserveHgComments: t.preserveHgComments,
493
494
  constrainToRoot: t.constrainToRoot
494
495
  })).trim();
495
- if (g.includes(`
496
- `))
497
- throw u({
498
- code: "component_multiline_output",
499
- path: n,
500
- details: { alias: t.alias }
501
- });
502
- return g;
503
496
  }
504
- const st = /* @__PURE__ */ new Set([
497
+ const xt = /* @__PURE__ */ new Set([
505
498
  "__proto__",
506
499
  "prototype",
507
500
  "constructor",
508
501
  "__defineGetter__"
509
502
  ]);
510
- function ot(t) {
511
- return st.has(t);
503
+ function wt(t) {
504
+ return xt.has(t);
512
505
  }
513
- function fe(t, e) {
514
- if (ot(t))
515
- throw u({
506
+ function ge(t, e) {
507
+ if (wt(t))
508
+ throw d({
516
509
  code: "forbidden_property_access",
517
510
  path: e,
518
511
  details: { property: t }
519
512
  });
520
513
  }
521
- function M(t) {
514
+ function O(t) {
522
515
  return !t;
523
516
  }
524
- function at(t, e) {
517
+ function kt(t, e) {
525
518
  if (t != null) {
526
519
  if (typeof t == "string")
527
520
  return e === "length" ? t.length : void 0;
@@ -529,7 +522,7 @@ function at(t, e) {
529
522
  return t[e];
530
523
  }
531
524
  }
532
- function ct(t, e, n) {
525
+ function vt(t, e, n) {
533
526
  switch (t) {
534
527
  case "+":
535
528
  return e + n;
@@ -556,9 +549,9 @@ function ct(t, e, n) {
556
549
  case "<":
557
550
  return e < n;
558
551
  case "&&":
559
- return M(e) ? e : n;
552
+ return O(e) ? e : n;
560
553
  case "||":
561
- return M(e) ? n : e;
554
+ return O(e) ? n : e;
562
555
  default:
563
556
  return;
564
557
  }
@@ -569,35 +562,35 @@ async function k(t, e) {
569
562
  case "literal":
570
563
  return t.value;
571
564
  case "identifier":
572
- return fe(t.name, r), n[t.name];
565
+ return ge(t.name, r), n[t.name];
573
566
  case "member": {
574
- fe(t.property, r);
575
- const s = await k(t.object, e);
576
- return at(s, t.property);
567
+ ge(t.property, r);
568
+ const i = await k(t.object, e);
569
+ return kt(i, t.property);
577
570
  }
578
571
  case "default": {
579
- const s = await k(t.left, e);
580
- return M(s) ? k(t.right, e) : s;
572
+ const i = await k(t.left, e);
573
+ return O(i) ? k(t.right, e) : i;
581
574
  }
582
575
  case "unary": {
583
- const s = await k(t.operand, e);
584
- return t.op === "!" ? !s : void 0;
576
+ const i = await k(t.operand, e);
577
+ return t.op === "!" ? !i : void 0;
585
578
  }
586
579
  case "binary": {
587
580
  if (t.op === "&&") {
588
581
  const o = await k(t.left, e);
589
- return M(o) ? o : k(t.right, e);
582
+ return O(o) ? o : k(t.right, e);
590
583
  }
591
584
  if (t.op === "||") {
592
585
  const o = await k(t.left, e);
593
- return M(o) ? k(t.right, e) : o;
586
+ return O(o) ? k(t.right, e) : o;
594
587
  }
595
- const s = await k(t.left, e), i = await k(t.right, e);
596
- return ct(t.op, s, i);
588
+ const i = await k(t.left, e), s = await k(t.right, e);
589
+ return vt(t.op, i, s);
597
590
  }
598
591
  case "call": {
599
592
  if (!e.registry || !e.loader || !e.visitStack)
600
- throw u({
593
+ throw d({
601
594
  code: "parse_error",
602
595
  path: r,
603
596
  details: {
@@ -605,19 +598,19 @@ async function k(t, e) {
605
598
  }
606
599
  });
607
600
  if (!e.registry.has(t.callee))
608
- throw u({
601
+ throw d({
609
602
  code: "parse_error",
610
603
  path: r,
611
604
  details: {
612
605
  message: `unregistered component: ${t.callee}`
613
606
  }
614
607
  });
615
- const s = {};
616
- for (const [i, o] of Object.entries(t.args))
617
- s[i] = await k(o, e);
618
- return it({
608
+ const i = {};
609
+ for (const [s, o] of Object.entries(t.args))
610
+ i[s] = await k(o, e);
611
+ return gt({
619
612
  alias: t.callee,
620
- props: s,
613
+ props: i,
621
614
  parentContext: e.parentContext ?? n,
622
615
  registry: e.registry,
623
616
  loader: e.loader,
@@ -631,58 +624,58 @@ async function k(t, e) {
631
624
  }
632
625
  case "method": {
633
626
  if (t.method !== "toLocaleString")
634
- throw u({
627
+ throw d({
635
628
  code: "parse_error",
636
629
  path: r,
637
630
  details: { message: `unsupported method: ${t.method}()` }
638
631
  });
639
- const s = await k(t.object, e);
640
- return s == null || typeof s.toLocaleString != "function" ? void 0 : s.toLocaleString(
632
+ const i = await k(t.object, e);
633
+ return i == null || typeof i.toLocaleString != "function" ? void 0 : i.toLocaleString(
641
634
  ...t.args
642
635
  );
643
636
  }
644
637
  case "ternary": {
645
- const s = await k(t.condition, e);
646
- return M(s) ? k(t.alternate, e) : k(t.consequent, e);
638
+ const i = await k(t.condition, e);
639
+ return O(i) ? k(t.alternate, e) : k(t.consequent, e);
647
640
  }
648
641
  case "template": {
649
- let s = "";
650
- for (const i of t.parts)
651
- if (typeof i == "string")
652
- s += i;
642
+ let i = "";
643
+ for (const s of t.parts)
644
+ if (typeof s == "string")
645
+ i += s;
653
646
  else {
654
- const o = await k(i, e);
655
- o != null && (s += String(o));
647
+ const o = await k(s, e);
648
+ o != null && (i += String(o));
656
649
  }
657
- return s;
650
+ return i;
658
651
  }
659
652
  default:
660
653
  return;
661
654
  }
662
655
  }
663
- function q(t) {
656
+ function V(t) {
664
657
  return /[A-Za-z_$]/.test(t);
665
658
  }
666
- function lt(t) {
659
+ function bt(t) {
667
660
  return /[A-Za-z0-9_$]/.test(t);
668
661
  }
669
662
  function C(t, e, n = {}) {
670
663
  const r = t.trim();
671
664
  if (r.length === 0)
672
665
  throw x(e, "empty expression");
673
- const s = new ht(r, e, n), i = s.parseExpression();
674
- if (s.skipWhitespace(), s.hasMore())
675
- throw x(e, `unexpected token at position ${s.position}`);
676
- return i;
666
+ const i = new yt(r, e, n), s = i.parseExpression();
667
+ if (i.skipWhitespace(), i.hasMore())
668
+ throw x(e, `unexpected token at position ${i.position}`);
669
+ return s;
677
670
  }
678
671
  function x(t, e) {
679
- throw u({
672
+ throw d({
680
673
  code: "parse_error",
681
674
  path: t,
682
675
  details: { message: e }
683
676
  });
684
677
  }
685
- class ht {
678
+ class yt {
686
679
  constructor(e, n, r = {}) {
687
680
  this.input = e, this.path = n, this.allowCalls = r.allowCalls !== !1;
688
681
  }
@@ -853,7 +846,7 @@ class ht {
853
846
  return { type: "literal", value: this.parseObjectLiteral() };
854
847
  if (e === "[")
855
848
  return { type: "literal", value: this.parseArrayLiteral() };
856
- if (q(e)) {
849
+ if (V(e)) {
857
850
  const n = this.readIdentifier();
858
851
  if (n === "true" || n === "false" || n === "null" || n === "undefined")
859
852
  return { type: "literal", value: n === "true" ? !0 : n === "false" ? !1 : n === "null" ? null : void 0 };
@@ -889,10 +882,10 @@ class ht {
889
882
  }
890
883
  if (r === "$" && this.input[this.index + 1] === "{") {
891
884
  e.push(n), n = "", this.index += 2;
892
- const s = this.readTemplateExpression(), i = C(s, this.path, {
885
+ const i = this.readTemplateExpression(), s = C(i, this.path, {
893
886
  allowCalls: !1
894
887
  });
895
- e.push(i);
888
+ e.push(s);
896
889
  continue;
897
890
  }
898
891
  n += r, this.index++;
@@ -904,27 +897,27 @@ class ht {
904
897
  const n = this.index;
905
898
  let r = null;
906
899
  for (; this.index < this.input.length; ) {
907
- const s = this.input[this.index];
900
+ const i = this.input[this.index];
908
901
  if (r) {
909
- if (s === "\\") {
902
+ if (i === "\\") {
910
903
  this.index += 2;
911
904
  continue;
912
905
  }
913
- s === r && (r = null), this.index++;
906
+ i === r && (r = null), this.index++;
914
907
  continue;
915
908
  }
916
- if (s === '"' || s === "'" || s === "`") {
917
- r = s, this.index++;
909
+ if (i === '"' || i === "'" || i === "`") {
910
+ r = i, this.index++;
918
911
  continue;
919
912
  }
920
- if (s === "{") {
913
+ if (i === "{") {
921
914
  e++, this.index++;
922
915
  continue;
923
916
  }
924
- if (s === "}") {
917
+ if (i === "}") {
925
918
  if (e--, e === 0) {
926
- const i = this.input.slice(n, this.index);
927
- return this.index++, i;
919
+ const s = this.input.slice(n, this.index);
920
+ return this.index++, s;
928
921
  }
929
922
  this.index++;
930
923
  continue;
@@ -1030,7 +1023,7 @@ class ht {
1030
1023
  return this.parseObjectLiteral();
1031
1024
  if (e === "[")
1032
1025
  return this.parseArrayLiteral();
1033
- if (q(e)) {
1026
+ if (V(e)) {
1034
1027
  const n = this.readIdentifier();
1035
1028
  if (n === "true") return !0;
1036
1029
  if (n === "false") return !1;
@@ -1048,9 +1041,9 @@ class ht {
1048
1041
  readIdentifier() {
1049
1042
  this.skipWhitespace();
1050
1043
  const e = this.index;
1051
- if (!q(this.peek()))
1044
+ if (!V(this.peek()))
1052
1045
  return "";
1053
- for (this.index++; this.index < this.input.length && lt(this.peek()); )
1046
+ for (this.index++; this.index < this.input.length && bt(this.peek()); )
1054
1047
  this.index++;
1055
1048
  return this.input.slice(e, this.index);
1056
1049
  }
@@ -1065,8 +1058,8 @@ class ht {
1065
1058
  if (r === "\\") {
1066
1059
  if (this.index++, this.index >= this.input.length)
1067
1060
  throw x(this.path, "unterminated string escape");
1068
- const s = this.input[this.index];
1069
- n += s, this.index++;
1061
+ const i = this.input[this.index];
1062
+ n += i, this.index++;
1070
1063
  continue;
1071
1064
  }
1072
1065
  n += r, this.index++;
@@ -1083,62 +1076,295 @@ class ht {
1083
1076
  return r;
1084
1077
  }
1085
1078
  }
1086
- async function We(t, e, n = {}) {
1079
+ const _t = /^( {0,3})(=+|-+)[ \t]*$/, Te = /^( {0,3})(`{3,}|~{3,})(.*)$/;
1080
+ function M(t) {
1081
+ return t === " " || t === " ";
1082
+ }
1083
+ function Le(t) {
1084
+ let e = 0;
1085
+ for (; e < t.length && e < 3 && t[e] === " "; )
1086
+ e += 1;
1087
+ const n = t.slice(0, e);
1088
+ let r = 0;
1089
+ for (; e < t.length && r < 6 && t[e] === "#"; )
1090
+ r += 1, e += 1;
1091
+ if (r === 0 || r === 6 && e < t.length && t[e] === "#")
1092
+ return null;
1093
+ if (e >= t.length)
1094
+ return { indent: n, level: r, text: "" };
1095
+ if (!M(t[e]))
1096
+ return null;
1097
+ for (; e < t.length && M(t[e]); )
1098
+ e += 1;
1099
+ let i = t.length;
1100
+ for (; i > e && M(t[i - 1]); )
1101
+ i -= 1;
1102
+ let s = i;
1103
+ if (i > e && t[i - 1] === "#") {
1104
+ let o = i - 1;
1105
+ for (; o > e && t[o - 1] === "#"; )
1106
+ o -= 1;
1107
+ if (o > e && M(t[o - 1])) {
1108
+ let a = o - 1;
1109
+ for (; a >= e && M(t[a]); )
1110
+ a -= 1;
1111
+ s = a + 1;
1112
+ }
1113
+ }
1114
+ return { indent: n, level: r, text: t.slice(e, s) };
1115
+ }
1116
+ function ee() {
1117
+ return { active: !1, marker: null, length: 0 };
1118
+ }
1119
+ function te(t, e) {
1120
+ const n = Te.exec(e);
1121
+ if (!t.active) {
1122
+ if (n) {
1123
+ const r = n[2];
1124
+ return t.active = !0, t.marker = r[0], t.length = r.length, !0;
1125
+ }
1126
+ return !1;
1127
+ }
1128
+ if (n) {
1129
+ const r = n[2], i = (n[3] ?? "").trim();
1130
+ r[0] === t.marker && r.length >= t.length && i.length === 0 && (t.active = !1, t.marker = null, t.length = 0);
1131
+ }
1132
+ return !0;
1133
+ }
1134
+ function Me(t) {
1135
+ const e = Le(t);
1136
+ return e ? e.level : null;
1137
+ }
1138
+ function Oe(t) {
1139
+ const e = _t.exec(t);
1140
+ return e ? e[2][0] === "=" ? 1 : 2 : null;
1141
+ }
1142
+ function St(t) {
1143
+ for (let e = 0; e < t.length; e++)
1144
+ if (!M(t[e]))
1145
+ return !1;
1146
+ return !0;
1147
+ }
1148
+ function Re(t) {
1149
+ return !(St(t) || Me(t) !== null || Te.test(t) || t.startsWith(" ") || t.startsWith(" "));
1150
+ }
1151
+ function He(t) {
1152
+ const e = t.split(`
1153
+ `), n = ee();
1154
+ let r = 0;
1155
+ for (let i = 0; i < e.length; i++) {
1156
+ const s = e[i];
1157
+ if (te(n, s))
1158
+ continue;
1159
+ const o = Me(s);
1160
+ if (o !== null) {
1161
+ r = o;
1162
+ continue;
1163
+ }
1164
+ const a = Oe(s);
1165
+ if (a !== null && i > 0) {
1166
+ const c = e[i - 1];
1167
+ Re(c) && (r = a);
1168
+ }
1169
+ }
1170
+ return r;
1171
+ }
1172
+ function Ct(t) {
1173
+ return t < 1 ? 1 : t > 6 ? 6 : t;
1174
+ }
1175
+ function xe(t, e) {
1176
+ const n = e.trim(), r = "#".repeat(Ct(t));
1177
+ return n.length === 0 ? r : `${r} ${n}`;
1178
+ }
1179
+ function De(t, e) {
1180
+ if (e <= 0 || t.length === 0)
1181
+ return t;
1182
+ const n = t.split(`
1183
+ `), r = ee(), i = [];
1184
+ for (let s = 0; s < n.length; s++) {
1185
+ const o = n[s];
1186
+ if (te(r, o)) {
1187
+ i.push(o);
1188
+ continue;
1189
+ }
1190
+ const a = Oe(o);
1191
+ if (a !== null && i.length > 0) {
1192
+ const h = i[i.length - 1];
1193
+ if (Re(h)) {
1194
+ i[i.length - 1] = xe(a + e, h);
1195
+ continue;
1196
+ }
1197
+ }
1198
+ const c = Le(o);
1199
+ if (c !== null) {
1200
+ i.push(c.indent + xe(c.level + e, c.text));
1201
+ continue;
1202
+ }
1203
+ i.push(o);
1204
+ }
1205
+ return i.join(`
1206
+ `);
1207
+ }
1208
+ async function Ne(t, e, n = {}) {
1087
1209
  const r = n.path;
1088
- let s = "", i = 0;
1089
- for (; i < t.length; ) {
1090
- const o = t.indexOf("{", i);
1210
+ let i = "", s = 0;
1211
+ for (; s < t.length; ) {
1212
+ const o = t.indexOf("{", s);
1091
1213
  if (o === -1) {
1092
- s += t.slice(i);
1214
+ i += t.slice(s);
1093
1215
  break;
1094
1216
  }
1095
- s += t.slice(i, o);
1217
+ i += t.slice(s, o);
1096
1218
  const a = t[o + 1] === "{" && t[o + 2] === "{" && (o === 0 || t[o - 1] !== "\\");
1097
1219
  if (!(!a && t[o + 1] === "{" && (o === 0 || t[o - 1] !== "\\")) && !a) {
1098
- s += "{", i = o + 1;
1220
+ i += "{", s = o + 1;
1099
1221
  continue;
1100
1222
  }
1101
- const h = a ? 3 : 2, l = a ? "}}}" : "}}", d = t.indexOf(l, o + h);
1102
- if (d === -1)
1103
- throw u({
1223
+ const h = a ? 3 : 2, l = a ? "}}}" : "}}", u = t.indexOf(l, o + h);
1224
+ if (u === -1)
1225
+ throw d({
1104
1226
  code: "parse_error",
1105
1227
  path: r,
1106
1228
  details: { message: "unclosed expression" }
1107
1229
  });
1108
- const f = t.slice(o + h, d).trim(), g = C(f, r), m = await k(g, {
1230
+ const f = t.slice(o + h, u).trim(), g = C(f, r), m = await k(g, {
1109
1231
  ...n,
1110
1232
  context: e,
1111
1233
  path: r,
1112
1234
  parentContext: n.parentContext ?? e
1113
1235
  });
1114
- s += m == null ? "" : String(m), i = d + l.length;
1236
+ let p = m == null ? "" : String(m);
1237
+ if (g.type === "call" && p.length > 0) {
1238
+ const v = He(i);
1239
+ p = De(p, v);
1240
+ }
1241
+ i += p, s = u + l.length;
1115
1242
  }
1116
- return s;
1243
+ return i;
1244
+ }
1245
+ function Wt(t) {
1246
+ const e = [];
1247
+ let n = 0;
1248
+ for (; n < t.length; ) {
1249
+ const r = t.indexOf(`
1250
+ `, n);
1251
+ if (r === -1) {
1252
+ e.push({ content: t.slice(n), eol: "" });
1253
+ break;
1254
+ }
1255
+ let i = t.slice(n, r), s = `
1256
+ `;
1257
+ i.endsWith("\r") && (i = i.slice(0, -1), s = `\r
1258
+ `), e.push({ content: i, eol: s }), n = r + 1;
1259
+ }
1260
+ return e;
1261
+ }
1262
+ function $t(t, e, n) {
1263
+ let r = 1, i = e, s = null;
1264
+ for (; i < t.length; ) {
1265
+ const o = t[i];
1266
+ if (s) {
1267
+ if (o === "\\") {
1268
+ i += 2;
1269
+ continue;
1270
+ }
1271
+ o === s && (s = null), i++;
1272
+ continue;
1273
+ }
1274
+ if (o === '"' || o === "'" || o === "`") {
1275
+ s = o, i++;
1276
+ continue;
1277
+ }
1278
+ if (o === "{") {
1279
+ r++, i++;
1280
+ continue;
1281
+ }
1282
+ if (o === "}") {
1283
+ if (r--, r === 0)
1284
+ return {
1285
+ expr: t.slice(e, i),
1286
+ end: i + 1
1287
+ };
1288
+ i++;
1289
+ continue;
1290
+ }
1291
+ i++;
1292
+ }
1293
+ throw d({
1294
+ code: "parse_error",
1295
+ path: n,
1296
+ details: { message: "unclosed template expression" }
1297
+ });
1298
+ }
1299
+ function At(t, e) {
1300
+ let n = 0, r = e - 1;
1301
+ for (; r >= 0 && t[r] === "\\"; )
1302
+ n++, r--;
1303
+ return n % 2 === 1;
1304
+ }
1305
+ async function Et(t, e, n) {
1306
+ const r = n.path;
1307
+ let i = "", s = 0;
1308
+ for (; s < t.length; ) {
1309
+ const o = t.indexOf("${", s);
1310
+ if (o === -1) {
1311
+ i += t.slice(s);
1312
+ break;
1313
+ }
1314
+ if (At(t, o)) {
1315
+ i += t.slice(s, o - 1), i += "${", s = o + 2;
1316
+ continue;
1317
+ }
1318
+ i += t.slice(s, o);
1319
+ const { expr: a, end: c } = $t(t, o + 2, r), h = C(a.trim(), r, { allowCalls: !1 }), l = await k(h, {
1320
+ ...n,
1321
+ context: e,
1322
+ path: r,
1323
+ parentContext: n.parentContext ?? e
1324
+ });
1325
+ i += l == null ? "" : String(l), s = c;
1326
+ }
1327
+ return i;
1328
+ }
1329
+ async function Be(t, e, n = {}) {
1330
+ const r = Wt(t);
1331
+ if (r.length === 0)
1332
+ return t;
1333
+ const i = ee();
1334
+ let s = "", o = "", a = !1;
1335
+ const c = async () => {
1336
+ a && (s += await Et(o, e, n), o = "", a = !1);
1337
+ };
1338
+ for (const { content: h, eol: l } of r) {
1339
+ const u = te(i, h), f = h + l;
1340
+ u ? (a || (a = !0, o = ""), o += f) : (await c(), s += f);
1341
+ }
1342
+ return await c(), s;
1117
1343
  }
1118
- function dt(t, e) {
1344
+ function Tt(t, e) {
1119
1345
  let n = 0, r = 0;
1120
1346
  for (; r < t.length; ) {
1121
- const s = t.indexOf(e, r);
1122
- if (s === -1)
1347
+ const i = t.indexOf(e, r);
1348
+ if (i === -1)
1123
1349
  break;
1124
- n++, r = s + e.length;
1350
+ n++, r = i + e.length;
1125
1351
  }
1126
1352
  return n;
1127
1353
  }
1128
- function Q(t) {
1129
- const e = t.includes("@hg"), n = t.includes("@endhg"), r = dt(t, "@@");
1354
+ function ne(t) {
1355
+ const e = t.includes("@hg"), n = t.includes("@endhg"), r = Tt(t, "@@");
1130
1356
  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";
1131
1357
  }
1132
- function ee(t) {
1358
+ function re(t) {
1133
1359
  return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
1134
1360
  }
1135
- function te(t, e) {
1361
+ function ie(t, e) {
1136
1362
  let n = 0, r = !1;
1137
1363
  for (; n < e; ) {
1138
- const s = t.indexOf("```", n);
1139
- if (s === -1 || s >= e)
1364
+ const i = t.indexOf("```", n);
1365
+ if (i === -1 || i >= e)
1140
1366
  break;
1141
- r = !r, n = s + 3;
1367
+ r = !r, n = i + 3;
1142
1368
  }
1143
1369
  return r;
1144
1370
  }
@@ -1149,233 +1375,233 @@ function E(t) {
1149
1375
  const r = t.indexOf("<!--", n);
1150
1376
  if (r === -1)
1151
1377
  break;
1152
- if (te(t, r)) {
1378
+ if (ie(t, r)) {
1153
1379
  n = r + 4;
1154
1380
  continue;
1155
1381
  }
1156
- const s = t.indexOf("-->", r + 4);
1157
- if (s === -1)
1382
+ const i = t.indexOf("-->", r + 4);
1383
+ if (i === -1)
1158
1384
  break;
1159
- const i = t.slice(r, s + 3), o = i.slice(4, i.length - 3), a = Q(o);
1385
+ const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = ne(o);
1160
1386
  (a === "hg" || a === "at-at") && e.push({
1161
1387
  start: r,
1162
- end: s + 3,
1388
+ end: i + 3,
1163
1389
  inner: o,
1164
- raw: i
1165
- }), n = s + 3;
1390
+ raw: s
1391
+ }), n = i + 3;
1166
1392
  }
1167
1393
  return e;
1168
1394
  }
1169
- function Ae(t) {
1395
+ function Fe(t) {
1170
1396
  let e = 0;
1171
1397
  for (; e < t.length; ) {
1172
1398
  const n = t.indexOf("<!--", e);
1173
1399
  if (n === -1)
1174
1400
  return !1;
1175
- if (te(t, n)) {
1401
+ if (ie(t, n)) {
1176
1402
  e = n + 4;
1177
1403
  continue;
1178
1404
  }
1179
1405
  const r = t.indexOf("-->", n + 4);
1180
1406
  if (r === -1)
1181
1407
  return !1;
1182
- const s = t.slice(n + 4, r), i = Q(s);
1183
- if (i === "unclosed" || i === "mixed")
1408
+ const i = t.slice(n + 4, r), s = ne(i);
1409
+ if (s === "unclosed" || s === "mixed")
1184
1410
  return !0;
1185
1411
  e = r + 3;
1186
1412
  }
1187
1413
  return !1;
1188
1414
  }
1189
- function $e(t) {
1415
+ function je(t) {
1190
1416
  let e = 0;
1191
1417
  for (; e < t.length; ) {
1192
1418
  const n = t.indexOf("<!--", e);
1193
1419
  if (n === -1)
1194
1420
  return null;
1195
- if (te(t, n)) {
1421
+ if (ie(t, n)) {
1196
1422
  e = n + 4;
1197
1423
  continue;
1198
1424
  }
1199
1425
  const r = t.indexOf("-->", n + 4);
1200
1426
  if (r === -1)
1201
1427
  return null;
1202
- const s = t.slice(n + 4, r), i = Q(s);
1203
- if (i === "mixed")
1428
+ const i = t.slice(n + 4, r), s = ne(i);
1429
+ if (s === "mixed")
1204
1430
  return "mixed @hg and @@ markers are not allowed";
1205
- if (i === "unclosed")
1431
+ if (s === "unclosed")
1206
1432
  return "unclosed hyogen block (missing closing marker)";
1207
1433
  e = r + 3;
1208
1434
  }
1209
1435
  return null;
1210
1436
  }
1211
1437
  function A(t) {
1212
- return ee(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
1438
+ return re(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
1213
1439
  }
1214
- const ut = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
1215
- function Ee(t) {
1216
- return ut.test(t.trim());
1440
+ const Lt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
1441
+ function Pe(t) {
1442
+ return Lt.test(t.trim());
1217
1443
  }
1218
- function V(t, e) {
1219
- throw u({
1444
+ function K(t, e) {
1445
+ throw d({
1220
1446
  code: "parse_error",
1221
1447
  path: t,
1222
1448
  details: { message: e }
1223
1449
  });
1224
1450
  }
1225
- function ft(t, e) {
1451
+ function Mt(t, e) {
1226
1452
  let n = t;
1227
1453
  const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
1228
1454
  r && (n = r[1]);
1229
- const s = A(n);
1230
- if (s.length !== 1)
1455
+ const i = A(n);
1456
+ if (i.length !== 1)
1231
1457
  return null;
1232
- const i = s[0];
1233
- if (/^include\s+/i.test(i) || /^component\s+/i.test(i) || /^const\s+/i.test(i) || /^let\s+/i.test(i) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(i))
1458
+ const s = i[0];
1459
+ if (/^include\s+/i.test(s) || /^component\s+/i.test(s) || /^const\s+/i.test(s) || /^let\s+/i.test(s) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(s))
1234
1460
  return null;
1235
- if (i === "else")
1461
+ if (s === "else")
1236
1462
  return { kind: "else" };
1237
- if (i === "endif")
1463
+ if (s === "endif")
1238
1464
  return { kind: "endif" };
1239
- if (i === "endeach")
1465
+ if (s === "endeach")
1240
1466
  return { kind: "endeach" };
1241
- if (/^IF\b/.test(i) || /^ELSE\b/.test(i) || /^ENDIF\b/.test(i))
1242
- throw V(e, "control keywords must be lowercase");
1243
- const o = /^else\s+if\s+(.+)$/.exec(i);
1467
+ if (/^IF\b/.test(s) || /^ELSE\b/.test(s) || /^ENDIF\b/.test(s))
1468
+ throw K(e, "control keywords must be lowercase");
1469
+ const o = /^else\s+if\s+(.+)$/.exec(s);
1244
1470
  if (o)
1245
1471
  return {
1246
1472
  kind: "else_if",
1247
1473
  expr: C(o[1], e)
1248
1474
  };
1249
- const a = /^if\s+(.+)$/.exec(i);
1475
+ const a = /^if\s+(.+)$/.exec(s);
1250
1476
  if (a)
1251
1477
  return {
1252
1478
  kind: "if",
1253
1479
  expr: C(a[1], e)
1254
1480
  };
1255
- const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(i);
1481
+ const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(s);
1256
1482
  if (c)
1257
1483
  return {
1258
1484
  kind: "each",
1259
1485
  item: c[1],
1260
1486
  expr: C(c[2], e)
1261
1487
  };
1262
- if (i === "if")
1263
- throw V(e, "if requires an expression");
1264
- if (/^each\s+/.test(i))
1265
- throw V(e, "invalid each directive");
1488
+ if (s === "if")
1489
+ throw K(e, "if requires an expression");
1490
+ if (/^each\s+/.test(s))
1491
+ throw K(e, "invalid each directive");
1266
1492
  return null;
1267
1493
  }
1268
- function O(t) {
1494
+ function R(t) {
1269
1495
  return { start: t.start, end: t.end, raw: t.raw };
1270
1496
  }
1271
- function W(t, e) {
1272
- throw u({
1497
+ function $(t, e) {
1498
+ throw d({
1273
1499
  code: "parse_error",
1274
1500
  path: t,
1275
1501
  details: { message: e }
1276
1502
  });
1277
1503
  }
1278
- function pt(t, e) {
1504
+ function Ot(t, e) {
1279
1505
  const n = [];
1280
1506
  for (const r of E(t)) {
1281
- const s = ft(r.inner, e);
1282
- s && n.push({
1507
+ const i = Mt(r.inner, e);
1508
+ i && n.push({
1283
1509
  start: r.start,
1284
1510
  end: r.end,
1285
1511
  raw: r.raw,
1286
- opener: s
1512
+ opener: i
1287
1513
  });
1288
1514
  }
1289
1515
  return n;
1290
1516
  }
1291
- function Te(t) {
1517
+ function Ie(t) {
1292
1518
  return t.kind === "if" || t.kind === "each";
1293
1519
  }
1294
- function mt(t, e) {
1295
- const n = pt(t, e);
1520
+ function Rt(t, e) {
1521
+ const n = Ot(t, e);
1296
1522
  if (n.length === 0)
1297
1523
  return t.length > 0 ? [{ kind: "text", content: t }] : [];
1298
- const { nodes: r, nextIndex: s } = B(t, n, 0, n.length, e);
1299
- if (s < n.length) {
1300
- const i = n[s];
1301
- if (i.opener.kind === "endif")
1302
- throw W(e, "endif without matching if");
1303
- if (i.opener.kind === "endeach")
1304
- throw W(e, "endeach without matching each");
1305
- if (i.opener.kind === "else" || i.opener.kind === "else_if")
1306
- throw W(e, "else without matching if");
1524
+ const { nodes: r, nextIndex: i } = F(t, n, 0, n.length, e);
1525
+ if (i < n.length) {
1526
+ const s = n[i];
1527
+ if (s.opener.kind === "endif")
1528
+ throw $(e, "endif without matching if");
1529
+ if (s.opener.kind === "endeach")
1530
+ throw $(e, "endeach without matching each");
1531
+ if (s.opener.kind === "else" || s.opener.kind === "else_if")
1532
+ throw $(e, "else without matching if");
1307
1533
  }
1308
1534
  return r;
1309
1535
  }
1310
- function B(t, e, n, r, s, i = 0, o) {
1536
+ function F(t, e, n, r, i, s = 0, o) {
1311
1537
  const a = o ?? t.length, c = [];
1312
- let h = i, l = n;
1538
+ let h = s, l = n;
1313
1539
  for (; l < r; ) {
1314
- const d = e[l];
1315
- if (d.start >= a)
1540
+ const u = e[l];
1541
+ if (u.start >= a)
1316
1542
  break;
1317
- if (d.end <= i) {
1543
+ if (u.end <= s) {
1318
1544
  l++;
1319
1545
  continue;
1320
1546
  }
1321
- if (d.start > h && c.push({
1547
+ if (u.start > h && c.push({
1322
1548
  kind: "text",
1323
- content: t.slice(h, d.start)
1324
- }), d.opener.kind === "if") {
1325
- const f = gt(t, e, l, r, s);
1549
+ content: t.slice(h, u.start)
1550
+ }), u.opener.kind === "if") {
1551
+ const f = Ht(t, e, l, r, i);
1326
1552
  c.push(f.node), h = f.endPos, l = f.nextIndex;
1327
1553
  continue;
1328
1554
  }
1329
- if (d.opener.kind === "each") {
1330
- const f = xt(t, e, l, r, s);
1555
+ if (u.opener.kind === "each") {
1556
+ const f = Dt(t, e, l, r, i);
1331
1557
  c.push(f.node), h = f.endPos, l = f.nextIndex;
1332
1558
  continue;
1333
1559
  }
1334
- if (d.opener.kind === "else" || d.opener.kind === "else_if")
1335
- throw W(s, "else without matching if");
1336
- if (d.opener.kind === "endif")
1337
- throw W(s, "endif without matching if");
1338
- if (d.opener.kind === "endeach")
1339
- throw W(s, "endeach without matching each");
1560
+ if (u.opener.kind === "else" || u.opener.kind === "else_if")
1561
+ throw $(i, "else without matching if");
1562
+ if (u.opener.kind === "endif")
1563
+ throw $(i, "endif without matching if");
1564
+ if (u.opener.kind === "endeach")
1565
+ throw $(i, "endeach without matching each");
1340
1566
  l++;
1341
1567
  }
1342
1568
  return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
1343
1569
  }
1344
- function gt(t, e, n, r, s) {
1345
- const i = e[n];
1346
- if (i.opener.kind !== "if")
1347
- throw W(s, "expected if");
1570
+ function Ht(t, e, n, r, i) {
1571
+ const s = e[n];
1572
+ if (s.opener.kind !== "if")
1573
+ throw $(i, "expected if");
1348
1574
  const o = [];
1349
- let a = n, c = i.end, h = 0;
1575
+ let a = n, c = s.end, h = 0;
1350
1576
  for (; a < r; ) {
1351
1577
  const l = e[a];
1352
1578
  if (a === n) {
1353
1579
  if (l.opener.kind !== "if")
1354
- throw W(s, "expected if");
1580
+ throw $(i, "expected if");
1355
1581
  o.push({
1356
1582
  kind: "if",
1357
1583
  expr: l.opener.expr,
1358
- opener: O(l),
1584
+ opener: R(l),
1359
1585
  body: []
1360
1586
  }), a++;
1361
1587
  continue;
1362
1588
  }
1363
- if (Te(l.opener)) {
1589
+ if (Ie(l.opener)) {
1364
1590
  h++, a++;
1365
1591
  continue;
1366
1592
  }
1367
1593
  if (l.opener.kind === "endif") {
1368
1594
  if (h === 0)
1369
- return o[o.length - 1].body = B(
1595
+ return o[o.length - 1].body = F(
1370
1596
  t,
1371
1597
  e,
1372
1598
  n + 1,
1373
1599
  a,
1374
- s,
1600
+ i,
1375
1601
  c,
1376
1602
  l.start
1377
1603
  ).nodes, {
1378
- node: { kind: "if", branches: o, closer: O(l) },
1604
+ node: { kind: "if", branches: o, closer: R(l) },
1379
1605
  nextIndex: a + 1,
1380
1606
  endPos: l.end
1381
1607
  };
@@ -1388,34 +1614,34 @@ function gt(t, e, n, r, s) {
1388
1614
  }
1389
1615
  if (h === 0) {
1390
1616
  if (l.opener.kind === "else_if") {
1391
- o[o.length - 1].body = B(
1617
+ o[o.length - 1].body = F(
1392
1618
  t,
1393
1619
  e,
1394
1620
  n + 1,
1395
1621
  a,
1396
- s,
1622
+ i,
1397
1623
  c,
1398
1624
  l.start
1399
1625
  ).nodes, o.push({
1400
1626
  kind: "else_if",
1401
1627
  expr: l.opener.expr,
1402
- opener: O(l),
1628
+ opener: R(l),
1403
1629
  body: []
1404
1630
  }), c = l.end, a++;
1405
1631
  continue;
1406
1632
  }
1407
1633
  if (l.opener.kind === "else") {
1408
- o[o.length - 1].body = B(
1634
+ o[o.length - 1].body = F(
1409
1635
  t,
1410
1636
  e,
1411
1637
  n + 1,
1412
1638
  a,
1413
- s,
1639
+ i,
1414
1640
  c,
1415
1641
  l.start
1416
1642
  ).nodes, o.push({
1417
1643
  kind: "else",
1418
- opener: O(l),
1644
+ opener: R(l),
1419
1645
  body: []
1420
1646
  }), c = l.end, a++;
1421
1647
  continue;
@@ -1423,40 +1649,40 @@ function gt(t, e, n, r, s) {
1423
1649
  }
1424
1650
  a++;
1425
1651
  }
1426
- throw W(s, "unclosed if block (missing endif)");
1652
+ throw $(i, "unclosed if block (missing endif)");
1427
1653
  }
1428
- function xt(t, e, n, r, s) {
1429
- const i = e[n];
1430
- if (i.opener.kind !== "each")
1431
- throw W(s, "expected each");
1654
+ function Dt(t, e, n, r, i) {
1655
+ const s = e[n];
1656
+ if (s.opener.kind !== "each")
1657
+ throw $(i, "expected each");
1432
1658
  let o = n + 1;
1433
- const a = i.end;
1659
+ const a = s.end;
1434
1660
  let c = 0;
1435
1661
  for (; o < r; ) {
1436
1662
  const h = e[o];
1437
- if (Te(h.opener)) {
1663
+ if (Ie(h.opener)) {
1438
1664
  c++, o++;
1439
1665
  continue;
1440
1666
  }
1441
1667
  if (h.opener.kind === "endeach") {
1442
1668
  if (c === 0) {
1443
- const l = B(
1669
+ const l = F(
1444
1670
  t,
1445
1671
  e,
1446
1672
  n + 1,
1447
1673
  o,
1448
- s,
1674
+ i,
1449
1675
  a,
1450
1676
  h.start
1451
1677
  ).nodes;
1452
1678
  return {
1453
1679
  node: {
1454
1680
  kind: "each",
1455
- item: i.opener.item,
1456
- expr: i.opener.expr,
1457
- opener: O(i),
1681
+ item: s.opener.item,
1682
+ expr: s.opener.expr,
1683
+ opener: R(s),
1458
1684
  body: l,
1459
- closer: O(h)
1685
+ closer: R(h)
1460
1686
  },
1461
1687
  nextIndex: o + 1,
1462
1688
  endPos: h.end
@@ -1471,28 +1697,28 @@ function xt(t, e, n, r, s) {
1471
1697
  }
1472
1698
  o++;
1473
1699
  }
1474
- throw W(s, "unclosed each block (missing endeach)");
1700
+ throw $(i, "unclosed each block (missing endeach)");
1475
1701
  }
1476
- const pe = 20;
1477
- class wt {
1702
+ const we = 20;
1703
+ class Nt {
1478
1704
  depth = 0;
1479
1705
  get currentDepth() {
1480
1706
  return this.depth;
1481
1707
  }
1482
1708
  enter() {
1483
- return this.depth >= pe ? { exceeded: !0, limit: pe } : (this.depth++, { exceeded: !1, depth: this.depth });
1709
+ return this.depth >= we ? { exceeded: !0, limit: we } : (this.depth++, { exceeded: !1, depth: this.depth });
1484
1710
  }
1485
1711
  exit() {
1486
1712
  this.depth > 0 && this.depth--;
1487
1713
  }
1488
1714
  }
1489
- function kt(t) {
1715
+ function Bt(t) {
1490
1716
  return !!t;
1491
1717
  }
1492
- function bt(t) {
1718
+ function Ft(t) {
1493
1719
  return t != null && typeof t[Symbol.iterator] == "function";
1494
1720
  }
1495
- function Le(t) {
1721
+ function ze(t) {
1496
1722
  return {
1497
1723
  code: "nest_limit_exceeded",
1498
1724
  message: "structure nest limit exceeded",
@@ -1500,49 +1726,49 @@ function Le(t) {
1500
1726
  details: { limit: 20 }
1501
1727
  };
1502
1728
  }
1503
- function ne(t) {
1729
+ function se(t) {
1504
1730
  return t.startsWith(`
1505
1731
  `) ? t.slice(1) : t;
1506
1732
  }
1507
- async function vt(t, e) {
1508
- const n = e.path, r = e.warnings ?? [], s = mt(t, n), i = new wt();
1509
- return re(s, e, i, r);
1733
+ async function jt(t, e) {
1734
+ const n = e.path, r = e.warnings ?? [], i = Rt(t, n), s = new Nt();
1735
+ return oe(i, e, s, r);
1510
1736
  }
1511
- async function re(t, e, n, r) {
1512
- const s = e.preserveHgComments === !0;
1513
- let i = "", o = !1;
1737
+ async function oe(t, e, n, r) {
1738
+ const i = e.preserveHgComments === !0;
1739
+ let s = "", o = !1;
1514
1740
  for (const a of t) {
1515
- let c = await yt(a, e, n, r);
1516
- o && (c = ne(c)), i += c, o = !s && (a.kind === "if" || a.kind === "each");
1741
+ let c = await Pt(a, e, n, r);
1742
+ o && (c = se(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
1517
1743
  }
1518
- return i;
1744
+ return s;
1519
1745
  }
1520
- async function yt(t, e, n, r) {
1746
+ async function Pt(t, e, n, r) {
1521
1747
  switch (t.kind) {
1522
1748
  case "text":
1523
1749
  return t.content;
1524
1750
  case "if":
1525
- return _t(t, e, n, r);
1751
+ return It(t, e, n, r);
1526
1752
  case "each":
1527
- return St(t, e, n, r);
1753
+ return zt(t, e, n, r);
1528
1754
  default:
1529
1755
  return "";
1530
1756
  }
1531
1757
  }
1532
- async function _t(t, e, n, r) {
1758
+ async function It(t, e, n, r) {
1533
1759
  if (n.enter().exceeded)
1534
- return r.push(Le(e.path)), "";
1760
+ return r.push(ze(e.path)), "";
1535
1761
  try {
1536
- let i = -1;
1762
+ let s = -1;
1537
1763
  for (let c = 0; c < t.branches.length; c++) {
1538
1764
  const h = t.branches[c];
1539
1765
  if (h.kind === "else") {
1540
- i = c;
1766
+ s = c;
1541
1767
  break;
1542
1768
  }
1543
1769
  const l = await k(h.expr, e);
1544
- if (kt(l)) {
1545
- i = c;
1770
+ if (Bt(l)) {
1771
+ s = c;
1546
1772
  break;
1547
1773
  }
1548
1774
  }
@@ -1550,9 +1776,9 @@ async function _t(t, e, n, r) {
1550
1776
  let a = "";
1551
1777
  for (let c = 0; c < t.branches.length; c++) {
1552
1778
  const h = t.branches[c];
1553
- if (o && (a += h.opener.raw), c === i) {
1554
- let l = await re(h.body, e, n, r);
1555
- o || (l = ne(l)), a += l;
1779
+ if (o && (a += h.opener.raw), c === s) {
1780
+ let l = await oe(h.body, e, n, r);
1781
+ o || (l = se(l)), a += l;
1556
1782
  }
1557
1783
  }
1558
1784
  return o && (a += t.closer.raw), a;
@@ -1560,24 +1786,24 @@ async function _t(t, e, n, r) {
1560
1786
  n.exit();
1561
1787
  }
1562
1788
  }
1563
- async function St(t, e, n, r) {
1789
+ async function zt(t, e, n, r) {
1564
1790
  if (n.enter().exceeded)
1565
- return r.push(Le(e.path)), "";
1791
+ return r.push(ze(e.path)), "";
1566
1792
  try {
1567
- const i = await k(t.expr, e);
1568
- if (!bt(i))
1793
+ const s = await k(t.expr, e);
1794
+ if (!Ft(s))
1569
1795
  return "";
1570
1796
  const o = e.preserveHgComments === !0;
1571
1797
  let a = "";
1572
- for (const c of i) {
1798
+ for (const c of s) {
1573
1799
  const h = { ...e.context, [t.item]: c };
1574
1800
  o && (a += t.opener.raw);
1575
- let l = await re(t.body, {
1801
+ let l = await oe(t.body, {
1576
1802
  ...e,
1577
1803
  context: h
1578
1804
  }, n, r);
1579
- o || (l = ne(l));
1580
- const d = await We(l, h, {
1805
+ o || (l = se(l));
1806
+ const u = {
1581
1807
  path: e.path,
1582
1808
  registry: e.registry,
1583
1809
  loader: e.loader,
@@ -1587,31 +1813,40 @@ async function St(t, e, n, r) {
1587
1813
  parentContext: e.parentContext ?? e.context,
1588
1814
  preserveHgComments: e.preserveHgComments,
1589
1815
  constrainToRoot: e.constrainToRoot
1590
- });
1591
- a += d, o && (a += t.closer.raw);
1816
+ };
1817
+ let f = await Ne(
1818
+ l,
1819
+ h,
1820
+ u
1821
+ );
1822
+ f = await Be(
1823
+ f,
1824
+ h,
1825
+ u
1826
+ ), a += f, o && (a += t.closer.raw);
1592
1827
  }
1593
1828
  return a;
1594
1829
  } finally {
1595
1830
  n.exit();
1596
1831
  }
1597
1832
  }
1598
- function Y(t, e, n, r, s = !1, i = !1) {
1599
- return Se(e) ? e : Ce(e, {
1833
+ function X(t, e, n, r, i = !1, s = !1) {
1834
+ return Ae(e) ? e : Ee(e, {
1600
1835
  rootDir: t,
1601
1836
  fromPath: r,
1602
1837
  documentPath: n,
1603
- constrainToRoot: s,
1604
- hyogenPath: i
1838
+ constrainToRoot: i,
1839
+ hyogenPath: s
1605
1840
  });
1606
1841
  }
1607
- function Me(t) {
1842
+ function Ue(t) {
1608
1843
  let e = 0;
1609
1844
  for (let n = t.length - 1; n >= 0 && t[n] === `
1610
1845
  `; n--)
1611
1846
  e++;
1612
1847
  return e;
1613
1848
  }
1614
- function Oe(t) {
1849
+ function Ze(t) {
1615
1850
  let e = 0;
1616
1851
  for (; e < t.length && t[e] === `
1617
1852
  `; )
@@ -1619,25 +1854,25 @@ function Oe(t) {
1619
1854
  return e;
1620
1855
  }
1621
1856
  function T(t, e) {
1622
- const n = Me(t), r = Oe(e), s = Math.max(n, r);
1857
+ const n = Ue(t), r = Ze(e), i = Math.max(n, r);
1623
1858
  return t.slice(0, t.length - n) + `
1624
- `.repeat(s) + e.slice(r);
1859
+ `.repeat(i) + e.slice(r);
1625
1860
  }
1626
- function ie(t, e) {
1627
- const n = Me(t), r = Oe(e);
1861
+ function ae(t, e) {
1862
+ const n = Ue(t), r = Ze(e);
1628
1863
  return n + r - Math.max(n, r);
1629
1864
  }
1630
- function me(t, e, n) {
1865
+ function ke(t, e, n) {
1631
1866
  const r = t.indexOf(e);
1632
1867
  if (r < 0)
1633
1868
  return t;
1634
- const s = t.slice(0, r), i = t.slice(r + e.length);
1635
- return T(T(s, n), i);
1869
+ const i = t.slice(0, r), s = t.slice(r + e.length);
1870
+ return T(T(i, n), s);
1636
1871
  }
1637
- async function Ct(t) {
1872
+ async function Ut(t) {
1638
1873
  let e = t.source;
1639
1874
  for (const n of t.directives) {
1640
- const r = Y(
1875
+ const r = X(
1641
1876
  t.root,
1642
1877
  n.path,
1643
1878
  t.path,
@@ -1646,28 +1881,28 @@ async function Ct(t) {
1646
1881
  !0
1647
1882
  );
1648
1883
  if (t.visitStack) {
1649
- const s = t.visitStack.check(r);
1650
- if (s.circular) {
1884
+ const i = t.visitStack.check(r);
1885
+ if (i.circular) {
1651
1886
  t.warnings?.push({
1652
1887
  code: "circular_include",
1653
- message: R("circular_include", {
1888
+ message: H("circular_include", {
1654
1889
  path: r,
1655
- from: s.from,
1890
+ from: i.from,
1656
1891
  via: "include"
1657
1892
  }),
1658
1893
  path: t.path,
1659
1894
  details: {
1660
1895
  path: r,
1661
- from: s.from,
1896
+ from: i.from,
1662
1897
  via: "include"
1663
1898
  }
1664
- }), e = me(e, n.marker, "");
1899
+ }), e = ke(e, n.marker, "");
1665
1900
  continue;
1666
1901
  }
1667
1902
  t.visitStack.push(r);
1668
1903
  }
1669
1904
  try {
1670
- const s = await t.loader(r), i = await fn(s, {
1905
+ const i = await t.loader(r), s = await Mn(i, {
1671
1906
  context: t.context,
1672
1907
  loader: t.loader,
1673
1908
  root: t.root,
@@ -1677,16 +1912,16 @@ async function Ct(t) {
1677
1912
  visitStack: t.visitStack,
1678
1913
  warnings: t.warnings,
1679
1914
  registry: t.registry
1680
- }), o = t.preserveHgComments && n.raw ? `${n.raw}
1681
- ${i}` : i;
1682
- e = me(e, n.marker, o);
1915
+ }), o = e.indexOf(n.marker), a = o >= 0 ? e.slice(0, o) : e, c = He(a), h = De(s, c), l = t.preserveHgComments && n.raw ? `${n.raw}
1916
+ ${h}` : h;
1917
+ e = ke(e, n.marker, l);
1683
1918
  } finally {
1684
1919
  t.visitStack?.pop();
1685
1920
  }
1686
1921
  }
1687
1922
  return e;
1688
1923
  }
1689
- class Re {
1924
+ class qe {
1690
1925
  stack = [];
1691
1926
  check(e) {
1692
1927
  return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
@@ -1702,28 +1937,28 @@ class Re {
1702
1937
  this.stack.pop();
1703
1938
  }
1704
1939
  }
1705
- async function Wt(t, e, n = {}) {
1706
- const { path: r, constBindings: s = /* @__PURE__ */ new Set() } = n, i = await k(t.expr, { context: e, path: r });
1940
+ async function Zt(t, e, n = {}) {
1941
+ const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await k(t.expr, { context: e, path: r });
1707
1942
  switch (t.kind) {
1708
1943
  case "const": {
1709
- if (s.has(t.name))
1710
- throw u({
1944
+ if (i.has(t.name))
1945
+ throw d({
1711
1946
  code: "parse_error",
1712
1947
  path: r,
1713
1948
  details: {
1714
1949
  message: `cannot reassign const binding: ${t.name}`
1715
1950
  }
1716
1951
  });
1717
- e[t.name] = i, s.add(t.name);
1952
+ e[t.name] = s, i.add(t.name);
1718
1953
  break;
1719
1954
  }
1720
1955
  case "let": {
1721
- e[t.name] = i;
1956
+ e[t.name] = s;
1722
1957
  break;
1723
1958
  }
1724
1959
  case "assign": {
1725
- if (s.has(t.name))
1726
- throw u({
1960
+ if (i.has(t.name))
1961
+ throw d({
1727
1962
  code: "parse_error",
1728
1963
  path: r,
1729
1964
  details: {
@@ -1731,33 +1966,33 @@ async function Wt(t, e, n = {}) {
1731
1966
  }
1732
1967
  });
1733
1968
  if (!(t.name in e))
1734
- throw u({
1969
+ throw d({
1735
1970
  code: "parse_error",
1736
1971
  path: r,
1737
1972
  details: {
1738
1973
  message: `assignment to undeclared variable: ${t.name}`
1739
1974
  }
1740
1975
  });
1741
- e[t.name] = i;
1976
+ e[t.name] = s;
1742
1977
  break;
1743
1978
  }
1744
1979
  }
1745
1980
  }
1746
- function ge(t) {
1981
+ function ve(t) {
1747
1982
  return !t;
1748
1983
  }
1749
- async function N(t, e, n = {}) {
1750
- const { path: r, constBindings: s = /* @__PURE__ */ new Set(), onUpdate: i, echoChunks: o } = n;
1984
+ async function B(t, e, n = {}) {
1985
+ const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s, echoChunks: o } = n;
1751
1986
  switch (t.kind) {
1752
1987
  case "const":
1753
1988
  case "let":
1754
1989
  case "assign": {
1755
- await Wt(t, e, { path: r, constBindings: s }), i?.(t.name);
1990
+ await Zt(t, e, { path: r, constBindings: i }), s?.(t.name);
1756
1991
  return;
1757
1992
  }
1758
1993
  case "update": {
1759
- if (s.has(t.name))
1760
- throw u({
1994
+ if (i.has(t.name))
1995
+ throw d({
1761
1996
  code: "parse_error",
1762
1997
  path: r,
1763
1998
  details: {
@@ -1765,7 +2000,7 @@ async function N(t, e, n = {}) {
1765
2000
  }
1766
2001
  });
1767
2002
  if (!(t.name in e))
1768
- throw u({
2003
+ throw d({
1769
2004
  code: "parse_error",
1770
2005
  path: r,
1771
2006
  details: {
@@ -1773,12 +2008,12 @@ async function N(t, e, n = {}) {
1773
2008
  }
1774
2009
  });
1775
2010
  const a = Number(e[t.name]), c = t.op === "++" ? a + 1 : a - 1;
1776
- e[t.name] = c, i?.(t.name);
2011
+ e[t.name] = c, s?.(t.name);
1777
2012
  return;
1778
2013
  }
1779
2014
  case "compound_assign": {
1780
- if (s.has(t.name))
1781
- throw u({
2015
+ if (i.has(t.name))
2016
+ throw d({
1782
2017
  code: "parse_error",
1783
2018
  path: r,
1784
2019
  details: {
@@ -1786,7 +2021,7 @@ async function N(t, e, n = {}) {
1786
2021
  }
1787
2022
  });
1788
2023
  if (!(t.name in e))
1789
- throw u({
2024
+ throw d({
1790
2025
  code: "parse_error",
1791
2026
  path: r,
1792
2027
  details: {
@@ -1809,7 +2044,7 @@ async function N(t, e, n = {}) {
1809
2044
  l = c / h;
1810
2045
  break;
1811
2046
  }
1812
- e[t.name] = l, i?.(t.name);
2047
+ e[t.name] = l, s?.(t.name);
1813
2048
  return;
1814
2049
  }
1815
2050
  case "echo": {
@@ -1821,39 +2056,39 @@ async function N(t, e, n = {}) {
1821
2056
  return;
1822
2057
  }
1823
2058
  case "for": {
1824
- for (t.init && await N(t.init, e, n); ; ) {
2059
+ for (t.init && await B(t.init, e, n); ; ) {
1825
2060
  const a = await k(t.cond, {
1826
2061
  context: e,
1827
2062
  path: r
1828
2063
  });
1829
- if (ge(a))
2064
+ if (ve(a))
1830
2065
  break;
1831
2066
  for (const c of t.body)
1832
- await N(c, e, n);
1833
- t.update && await N(t.update, e, n);
2067
+ await B(c, e, n);
2068
+ t.update && await B(t.update, e, n);
1834
2069
  }
1835
2070
  return;
1836
2071
  }
1837
2072
  case "do_while": {
1838
2073
  do {
1839
2074
  for (const c of t.body)
1840
- await N(c, e, n);
2075
+ await B(c, e, n);
1841
2076
  const a = await k(t.cond, {
1842
2077
  context: e,
1843
2078
  path: r
1844
2079
  });
1845
- if (ge(a))
2080
+ if (ve(a))
1846
2081
  break;
1847
2082
  } while (!0);
1848
2083
  return;
1849
2084
  }
1850
2085
  }
1851
2086
  }
1852
- async function xe(t, e, n = {}) {
2087
+ async function be(t, e, n = {}) {
1853
2088
  for (const r of t)
1854
- await N(r, e, n);
2089
+ await B(r, e, n);
1855
2090
  }
1856
- const At = /* @__PURE__ */ new Set([
2091
+ const qt = /* @__PURE__ */ new Set([
1857
2092
  "if",
1858
2093
  "else",
1859
2094
  "endif",
@@ -1872,23 +2107,23 @@ const At = /* @__PURE__ */ new Set([
1872
2107
  "as",
1873
2108
  "echo"
1874
2109
  ]);
1875
- function De(t) {
1876
- return At.has(t);
2110
+ function Ve(t) {
2111
+ return qt.has(t);
1877
2112
  }
1878
- function se(t) {
2113
+ function ce(t) {
1879
2114
  let e = "", n = 0, r = null;
1880
2115
  for (; n < t.length; ) {
1881
- const s = t[n];
2116
+ const i = t[n];
1882
2117
  if (r) {
1883
- if (e += s, s === "\\" && n + 1 < t.length) {
2118
+ if (e += i, i === "\\" && n + 1 < t.length) {
1884
2119
  e += t[++n], n++;
1885
2120
  continue;
1886
2121
  }
1887
- s === r && (r = null), n++;
2122
+ i === r && (r = null), n++;
1888
2123
  continue;
1889
2124
  }
1890
- if (s === '"' || s === "'" || s === "`") {
1891
- r = s, e += s, n++;
2125
+ if (i === '"' || i === "'" || i === "`") {
2126
+ r = i, e += i, n++;
1892
2127
  continue;
1893
2128
  }
1894
2129
  if (t.startsWith("//", n)) {
@@ -1898,42 +2133,42 @@ function se(t) {
1898
2133
  continue;
1899
2134
  }
1900
2135
  if (t.startsWith("/*", n)) {
1901
- const i = t.indexOf("*/", n + 2);
1902
- if (i === -1)
2136
+ const s = t.indexOf("*/", n + 2);
2137
+ if (s === -1)
1903
2138
  break;
1904
- n = i + 2;
2139
+ n = s + 2;
1905
2140
  continue;
1906
2141
  }
1907
- e += s, n++;
2142
+ e += i, n++;
1908
2143
  }
1909
2144
  return e;
1910
2145
  }
1911
2146
  function w(t, e) {
1912
- throw u({
2147
+ throw d({
1913
2148
  code: "parse_error",
1914
2149
  path: t,
1915
2150
  details: { message: e }
1916
2151
  });
1917
2152
  }
1918
- function we(t, e) {
1919
- const n = se(t).trim();
2153
+ function ye(t, e) {
2154
+ const n = ce(t).trim();
1920
2155
  if (n.length === 0)
1921
2156
  throw w(e, "empty statement block");
1922
- const r = new oe(n, e), s = r.parseStatementList();
2157
+ const r = new le(n, e), i = r.parseStatementList();
1923
2158
  if (r.skipWhitespace(), r.hasMore())
1924
2159
  throw w(
1925
2160
  e,
1926
2161
  `unexpected token at position ${r.position}`
1927
2162
  );
1928
- if (s.length === 0)
2163
+ if (i.length === 0)
1929
2164
  throw w(e, "empty statement block");
1930
- return s;
2165
+ return i;
1931
2166
  }
1932
- function He(t) {
1933
- const e = se(t).trim();
2167
+ function Ke(t) {
2168
+ const e = ce(t).trim();
1934
2169
  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);
1935
2170
  }
1936
- class oe {
2171
+ class le {
1937
2172
  constructor(e, n) {
1938
2173
  this.input = e, this.path = n;
1939
2174
  }
@@ -1981,27 +2216,27 @@ class oe {
1981
2216
  if (!n)
1982
2217
  throw w(this.path, "expected statement");
1983
2218
  if (this.assertAssignableName(n), this.skipWhitespace(), this.match("++") || this.match("--")) {
1984
- const s = this.input.slice(this.index - 2, this.index);
1985
- return { kind: "update", name: n, op: s, position: "postfix" };
2219
+ const i = this.input.slice(this.index - 2, this.index);
2220
+ return { kind: "update", name: n, op: i, position: "postfix" };
1986
2221
  }
1987
2222
  const r = this.readCompoundOp();
1988
2223
  if (r) {
1989
- const s = this.readExpressionSourceUntilTerminator();
2224
+ const i = this.readExpressionSourceUntilTerminator();
1990
2225
  return {
1991
2226
  kind: "compound_assign",
1992
2227
  name: n,
1993
2228
  op: r,
1994
- expr: C(s, this.path)
2229
+ expr: C(i, this.path)
1995
2230
  };
1996
2231
  }
1997
2232
  if (this.match("=")) {
1998
2233
  if (this.peek() === "=")
1999
2234
  throw w(this.path, "unexpected '==' in assignment");
2000
- const s = this.readExpressionSourceUntilTerminator();
2235
+ const i = this.readExpressionSourceUntilTerminator();
2001
2236
  return {
2002
2237
  kind: "assign",
2003
2238
  name: n,
2004
- expr: C(s, this.path)
2239
+ expr: C(i, this.path)
2005
2240
  };
2006
2241
  }
2007
2242
  throw w(this.path, `invalid statement starting with: ${n}`);
@@ -2039,21 +2274,21 @@ class oe {
2039
2274
  parseFor() {
2040
2275
  if (this.skipWhitespace(), !this.match("("))
2041
2276
  throw w(this.path, "expected '(' after for");
2042
- const e = this.readBalanced(")"), n = $t(e);
2277
+ const e = this.readBalanced(")"), n = Vt(e);
2043
2278
  if (n.length !== 3)
2044
2279
  throw w(
2045
2280
  this.path,
2046
2281
  "for…of / for…in are not allowed; use for (init; cond; update)"
2047
2282
  );
2048
- const [r, s, i] = n;
2049
- if (s.trim().length === 0)
2283
+ const [r, i, s] = n;
2284
+ if (i.trim().length === 0)
2050
2285
  throw w(this.path, "for loop condition cannot be empty");
2051
2286
  if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(r))
2052
2287
  throw w(
2053
2288
  this.path,
2054
2289
  "for…of / for…in are not allowed; use for (init; cond; update)"
2055
2290
  );
2056
- const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = C(s.trim(), this.path), c = i.trim().length === 0 ? null : this.parseClauseStatement(i.trim());
2291
+ const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = C(i.trim(), this.path), c = s.trim().length === 0 ? null : this.parseClauseStatement(s.trim());
2057
2292
  if (this.skipWhitespace(), !this.match("{"))
2058
2293
  throw w(this.path, "expected '{' after for (...)");
2059
2294
  const h = this.parseStatementList();
@@ -2078,7 +2313,7 @@ class oe {
2078
2313
  return { kind: "do_while", body: e, cond: r };
2079
2314
  }
2080
2315
  parseClauseStatement(e) {
2081
- const n = new oe(e, this.path), r = n.parseSimpleStatement();
2316
+ const n = new le(e, this.path), r = n.parseSimpleStatement();
2082
2317
  if (n.skipWhitespace(), n.hasMore())
2083
2318
  throw w(
2084
2319
  this.path,
@@ -2087,7 +2322,7 @@ class oe {
2087
2322
  return r;
2088
2323
  }
2089
2324
  assertAssignableName(e) {
2090
- if (De(e))
2325
+ if (Ve(e))
2091
2326
  throw w(
2092
2327
  this.path,
2093
2328
  `reserved word cannot be used as identifier: ${e}`
@@ -2096,28 +2331,28 @@ class oe {
2096
2331
  readExpressionSourceUntilTerminator() {
2097
2332
  this.skipWhitespace();
2098
2333
  const e = this.index;
2099
- let n = 0, r = 0, s = 0, i = null;
2334
+ let n = 0, r = 0, i = 0, s = null;
2100
2335
  for (; this.index < this.input.length; ) {
2101
2336
  const a = this.input[this.index];
2102
- if (i) {
2337
+ if (s) {
2103
2338
  if (a === "\\") {
2104
2339
  this.index += 2;
2105
2340
  continue;
2106
2341
  }
2107
- a === i && (i = null), this.index++;
2342
+ a === s && (s = null), this.index++;
2108
2343
  continue;
2109
2344
  }
2110
2345
  if (a === '"' || a === "'" || a === "`") {
2111
- i = a, this.index++;
2346
+ s = a, this.index++;
2112
2347
  continue;
2113
2348
  }
2114
2349
  if (a === "(" && n++, a === ")" && (n = Math.max(0, n - 1)), a === "{" && r++, a === "}") {
2115
- if (r === 0 && n === 0 && s === 0)
2350
+ if (r === 0 && n === 0 && i === 0)
2116
2351
  break;
2117
2352
  r = Math.max(0, r - 1);
2118
2353
  }
2119
- if (a === "[" && s++, a === "]" && (s = Math.max(0, s - 1)), (a === ";" || a === `
2120
- `) && n === 0 && r === 0 && s === 0)
2354
+ if (a === "[" && i++, a === "]" && (i = Math.max(0, i - 1)), (a === ";" || a === `
2355
+ `) && n === 0 && r === 0 && i === 0)
2121
2356
  break;
2122
2357
  this.index++;
2123
2358
  }
@@ -2129,20 +2364,20 @@ class oe {
2129
2364
  readBalanced(e) {
2130
2365
  const n = e === ")" ? "(" : "{";
2131
2366
  let r = 1;
2132
- const s = this.index;
2133
- let i = null;
2367
+ const i = this.index;
2368
+ let s = null;
2134
2369
  for (; this.index < this.input.length; ) {
2135
2370
  const o = this.input[this.index];
2136
- if (i) {
2371
+ if (s) {
2137
2372
  if (o === "\\") {
2138
2373
  this.index += 2;
2139
2374
  continue;
2140
2375
  }
2141
- o === i && (i = null), this.index++;
2376
+ o === s && (s = null), this.index++;
2142
2377
  continue;
2143
2378
  }
2144
2379
  if (o === '"' || o === "'" || o === "`") {
2145
- i = o, this.index++;
2380
+ s = o, this.index++;
2146
2381
  continue;
2147
2382
  }
2148
2383
  if (o === n) {
@@ -2151,7 +2386,7 @@ class oe {
2151
2386
  }
2152
2387
  if (o === e) {
2153
2388
  if (r--, r === 0) {
2154
- const a = this.input.slice(s, this.index);
2389
+ const a = this.input.slice(i, this.index);
2155
2390
  return this.index++, a;
2156
2391
  }
2157
2392
  this.index++;
@@ -2194,21 +2429,21 @@ class oe {
2194
2429
  return this.input.slice(e, this.index);
2195
2430
  }
2196
2431
  }
2197
- function $t(t) {
2432
+ function Vt(t) {
2198
2433
  const e = [];
2199
- let n = "", r = 0, s = null;
2200
- for (let i = 0; i < t.length; i++) {
2201
- const o = t[i];
2202
- if (s) {
2203
- if (n += o, o === "\\" && i + 1 < t.length) {
2204
- n += t[++i];
2434
+ let n = "", r = 0, i = null;
2435
+ for (let s = 0; s < t.length; s++) {
2436
+ const o = t[s];
2437
+ if (i) {
2438
+ if (n += o, o === "\\" && s + 1 < t.length) {
2439
+ n += t[++s];
2205
2440
  continue;
2206
2441
  }
2207
- o === s && (s = null);
2442
+ o === i && (i = null);
2208
2443
  continue;
2209
2444
  }
2210
2445
  if (o === '"' || o === "'" || o === "`") {
2211
- s = o, n += o;
2446
+ i = o, n += o;
2212
2447
  continue;
2213
2448
  }
2214
2449
  if (o === "(" || o === "[" || o === "{") {
@@ -2227,56 +2462,56 @@ function $t(t) {
2227
2462
  }
2228
2463
  return e.push(n), e;
2229
2464
  }
2230
- function ae(t, e) {
2465
+ function he(t, e) {
2231
2466
  const n = t.trim();
2232
2467
  if (!/^extend\b/i.test(n)) return null;
2233
2468
  if (!/^extend\s+/i.test(n))
2234
- throw u({
2469
+ throw d({
2235
2470
  code: "parse_error",
2236
2471
  path: e,
2237
2472
  details: { message: "missing extend path" }
2238
2473
  });
2239
2474
  const r = /^extend\s+(\S+)\s*$/.exec(n);
2240
2475
  if (!r)
2241
- throw u({
2476
+ throw d({
2242
2477
  code: "parse_error",
2243
2478
  path: e,
2244
2479
  details: { message: "invalid extend directive" }
2245
2480
  });
2246
- const s = r[1];
2247
- if (s.length === 0)
2248
- throw u({
2481
+ const i = r[1];
2482
+ if (i.length === 0)
2483
+ throw d({
2249
2484
  code: "parse_error",
2250
2485
  path: e,
2251
2486
  details: { message: "invalid extend path" }
2252
2487
  });
2253
- return { path: s };
2488
+ return { path: i };
2254
2489
  }
2255
- function Et(t, e) {
2490
+ function Kt(t, e) {
2256
2491
  const n = A(t);
2257
2492
  if (n.length === 0) return null;
2258
- const r = n[0], s = ae(r, e);
2259
- if (!s) return null;
2260
- for (const i of n.slice(1))
2261
- if (/^extend\s+/i.test(i))
2262
- throw u({
2493
+ const r = n[0], i = he(r, e);
2494
+ if (!i) return null;
2495
+ for (const s of n.slice(1))
2496
+ if (/^extend\s+/i.test(s))
2497
+ throw d({
2263
2498
  code: "parse_error",
2264
2499
  path: e,
2265
2500
  details: { message: "extend must be the first line of extend block" }
2266
2501
  });
2267
2502
  return {
2268
- path: s.path,
2503
+ path: i.path,
2269
2504
  declarationsSource: n.slice(1).join(`
2270
2505
  `)
2271
2506
  };
2272
2507
  }
2273
- function ce(t) {
2508
+ function ue(t) {
2274
2509
  return /^toc(\(.*\))?$/.test(t.trim());
2275
2510
  }
2276
- function Tt(t, e) {
2511
+ function Yt(t, e) {
2277
2512
  const n = A(t);
2278
2513
  if (n.length !== 1)
2279
- throw u({
2514
+ throw d({
2280
2515
  code: "parse_error",
2281
2516
  path: e,
2282
2517
  details: {
@@ -2286,126 +2521,126 @@ function Tt(t, e) {
2286
2521
  const r = n[0];
2287
2522
  if (r === "toc")
2288
2523
  return { maxLevel: 6 };
2289
- const s = /^toc\((.*)\)$/.exec(r);
2290
- if (!s)
2291
- throw u({
2524
+ const i = /^toc\((.*)\)$/.exec(r);
2525
+ if (!i)
2526
+ throw d({
2292
2527
  code: "parse_error",
2293
2528
  path: e,
2294
2529
  details: { message: `invalid toc directive: ${r}` }
2295
2530
  });
2296
- const i = s[1];
2297
- if (!/^[1-6]$/.test(i))
2298
- throw u({
2531
+ const s = i[1];
2532
+ if (!/^[1-6]$/.test(s))
2533
+ throw d({
2299
2534
  code: "parse_error",
2300
2535
  path: e,
2301
2536
  details: {
2302
- message: `invalid toc max level: ${i || "(empty)"} (expected integer 1–6)`
2537
+ message: `invalid toc max level: ${s || "(empty)"} (expected integer 1–6)`
2303
2538
  }
2304
2539
  });
2305
- return { maxLevel: Number(i) };
2540
+ return { maxLevel: Number(s) };
2306
2541
  }
2307
- async function Lt(t, e = {}) {
2542
+ async function Xt(t, e = {}) {
2308
2543
  const n = e.path, r = e.context ?? {};
2309
- if (Ae(t))
2310
- throw u({
2544
+ if (Fe(t))
2545
+ throw d({
2311
2546
  code: "parse_error",
2312
2547
  path: n,
2313
2548
  details: {
2314
- message: $e(t) ?? "unclosed hyogen block (missing closing marker)"
2549
+ message: je(t) ?? "unclosed hyogen block (missing closing marker)"
2315
2550
  }
2316
2551
  });
2317
- const s = E(t);
2318
- if (s.length === 0)
2552
+ const i = E(t);
2553
+ if (i.length === 0)
2319
2554
  return { source: t, context: r, declarationUpdates: {} };
2320
- const i = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
2555
+ const s = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
2321
2556
  o[l] = r[l];
2322
2557
  };
2323
2558
  let c = t, h = 0;
2324
- for (const l of s) {
2325
- const d = A(l.inner);
2326
- if (d.length === 1 && Ee(d[0]) || d.length === 1 && ce(d[0]) || d.length === 1 && /^include\s+/i.test(d[0]) || d.length === 1 && /^component\s+/i.test(d[0]))
2559
+ for (const l of i) {
2560
+ const u = A(l.inner);
2561
+ if (u.length === 1 && Pe(u[0]) || u.length === 1 && ue(u[0]) || u.length === 1 && /^include\s+/i.test(u[0]) || u.length === 1 && /^component\s+/i.test(u[0]))
2327
2562
  continue;
2328
- const f = Et(l.inner, n);
2563
+ const f = Kt(l.inner, n);
2329
2564
  if (f) {
2330
2565
  if (f.declarationsSource.trim().length > 0) {
2331
- const H = we(
2566
+ const N = ye(
2332
2567
  f.declarationsSource,
2333
2568
  n
2334
2569
  );
2335
- await xe(H, r, {
2570
+ await be(N, r, {
2336
2571
  path: n,
2337
- constBindings: i,
2572
+ constBindings: s,
2338
2573
  onUpdate: a
2339
2574
  });
2340
2575
  }
2341
- const S = l.start - h, L = l.end - h, j = `<!--@hg
2576
+ const W = l.start - h, L = l.end - h, j = `<!--@hg
2342
2577
  extend ${f.path}
2343
2578
  @endhg-->`;
2344
- c = c.slice(0, S) + j + c.slice(L), h += l.raw.length - j.length;
2579
+ c = c.slice(0, W) + j + c.slice(L), h += l.raw.length - j.length;
2345
2580
  continue;
2346
2581
  }
2347
- const g = d.join(`
2582
+ const g = u.join(`
2348
2583
  `);
2349
- if (!He(g)) {
2350
- if (d.length === 1)
2584
+ if (!Ke(g)) {
2585
+ if (u.length === 1)
2351
2586
  continue;
2352
- throw u({
2587
+ throw d({
2353
2588
  code: "parse_error",
2354
2589
  path: n,
2355
- details: { message: `unsupported hyogen directive: ${d[0]}` }
2590
+ details: { message: `unsupported hyogen directive: ${u[0]}` }
2356
2591
  });
2357
2592
  }
2358
- const m = we(g, n), p = [];
2359
- await xe(m, r, {
2593
+ const m = ye(g, n), p = [];
2594
+ await be(m, r, {
2360
2595
  path: n,
2361
- constBindings: i,
2596
+ constBindings: s,
2362
2597
  onUpdate: a,
2363
2598
  echoChunks: p
2364
2599
  });
2365
- const $ = l.start - h, D = l.end - h, b = c.slice(0, $), v = c.slice(D);
2600
+ const v = l.start - h, D = l.end - h, b = c.slice(0, v), y = c.slice(D);
2366
2601
  if (p.length > 0) {
2367
- const S = p.join("");
2368
- c = b + S + v, h += l.raw.length - S.length;
2602
+ const W = p.join("");
2603
+ c = b + W + y, h += l.raw.length - W.length;
2369
2604
  } else
2370
- c = T(b, v), h += l.raw.length + ie(b, v);
2605
+ c = T(b, y), h += l.raw.length + ae(b, y);
2371
2606
  }
2372
2607
  return { source: c, context: r, declarationUpdates: o };
2373
2608
  }
2374
- const Mt = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
2375
- function Ot(t, e) {
2376
- const n = ee(t).trim();
2609
+ const Gt = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
2610
+ function Jt(t, e) {
2611
+ const n = re(t).trim();
2377
2612
  if (n.length === 0)
2378
- throw u({
2613
+ throw d({
2379
2614
  code: "parse_error",
2380
2615
  path: e,
2381
2616
  details: { message: "empty hyogen block" }
2382
2617
  });
2383
2618
  const r = n.split(/\r?\n/).map((a) => a.trim()).filter((a) => a.length > 0);
2384
2619
  if (r.length !== 1)
2385
- throw u({
2620
+ throw d({
2386
2621
  code: "parse_error",
2387
2622
  path: e,
2388
2623
  details: {
2389
2624
  message: "hyogen block must contain a single component directive"
2390
2625
  }
2391
2626
  });
2392
- const s = r[0];
2393
- if (/^include\s+/i.test(s))
2394
- throw u({
2627
+ const i = r[0];
2628
+ if (/^include\s+/i.test(i))
2629
+ throw d({
2395
2630
  code: "parse_error",
2396
2631
  path: e,
2397
2632
  details: { message: "include and component cannot coexist in one block" }
2398
2633
  });
2399
- const i = Mt.exec(s);
2400
- if (!i)
2401
- throw u({
2634
+ const s = Gt.exec(i);
2635
+ if (!s)
2636
+ throw d({
2402
2637
  code: "parse_error",
2403
2638
  path: e,
2404
- details: { message: `unsupported component directive: ${s}` }
2639
+ details: { message: `unsupported component directive: ${i}` }
2405
2640
  });
2406
- const o = i[1];
2641
+ const o = s[1];
2407
2642
  if (o.length === 0)
2408
- throw u({
2643
+ throw d({
2409
2644
  code: "parse_error",
2410
2645
  path: e,
2411
2646
  details: { message: "empty component path" }
@@ -2413,92 +2648,92 @@ function Ot(t, e) {
2413
2648
  return {
2414
2649
  kind: "component",
2415
2650
  path: o,
2416
- alias: i[2]
2651
+ alias: s[2]
2417
2652
  };
2418
2653
  }
2419
- function Rt(t, e) {
2420
- const n = ee(t).trim();
2654
+ function Qt(t, e) {
2655
+ const n = re(t).trim();
2421
2656
  if (n.length === 0)
2422
- throw u({
2657
+ throw d({
2423
2658
  code: "parse_error",
2424
2659
  path: e,
2425
2660
  details: { message: "empty hyogen block" }
2426
2661
  });
2427
2662
  const r = n.split(/\r?\n/).map((o) => o.trim()).filter((o) => o.length > 0);
2428
2663
  if (r.length !== 1)
2429
- throw u({
2664
+ throw d({
2430
2665
  code: "parse_error",
2431
2666
  path: e,
2432
2667
  details: { message: "hyogen block must contain a single include directive" }
2433
2668
  });
2434
- const s = r[0], i = /^include\s+(\S+)\s*$/.exec(s);
2435
- if (i)
2436
- return { kind: "include", path: i[1] };
2437
- throw u({
2669
+ const i = r[0], s = /^include\s+(\S+)\s*$/.exec(i);
2670
+ if (s)
2671
+ return { kind: "include", path: s[1] };
2672
+ throw d({
2438
2673
  code: "parse_error",
2439
2674
  path: e,
2440
- details: { message: `unsupported hyogen directive: ${s}` }
2675
+ details: { message: `unsupported hyogen directive: ${i}` }
2441
2676
  });
2442
2677
  }
2443
- function Dt(t) {
2444
- const e = se(t).trim();
2678
+ function en(t) {
2679
+ const e = ce(t).trim();
2445
2680
  return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
2446
2681
  }
2447
- const Ht = "\0HYOGEN_INCLUDE_";
2448
- function Nt(t) {
2449
- return `${Ht}${t}\0`;
2682
+ const tn = "\0HYOGEN_INCLUDE_";
2683
+ function nn(t) {
2684
+ return `${tn}${t}\0`;
2450
2685
  }
2451
- function Bt(t, e) {
2686
+ function rn(t, e) {
2452
2687
  const n = A(t);
2453
- if (n.length === 1 && Ee(n[0]))
2688
+ if (n.length === 1 && Pe(n[0]))
2454
2689
  return { kind: "control" };
2455
- if (n.length === 1 && ce(n[0]) || n.length === 1 && (Dt(n[0]) || He(n[0])))
2690
+ if (n.length === 1 && ue(n[0]) || n.length === 1 && (en(n[0]) || Ke(n[0])))
2456
2691
  return null;
2457
2692
  if (n.length !== 1)
2458
- throw u({
2693
+ throw d({
2459
2694
  code: "parse_error",
2460
2695
  path: e,
2461
2696
  details: { message: "hyogen block must contain a single directive" }
2462
2697
  });
2463
2698
  const r = n[0];
2464
2699
  if (/^include\s+/i.test(r) && /\bcomponent\s+/i.test(r))
2465
- throw u({
2700
+ throw d({
2466
2701
  code: "parse_error",
2467
2702
  path: e,
2468
2703
  details: { message: "include and component cannot coexist in one block" }
2469
2704
  });
2470
2705
  if (/^include\s+/i.test(r))
2471
- return Rt(t, e);
2706
+ return Qt(t, e);
2472
2707
  if (/^component\s+/i.test(r))
2473
- return Ot(t, e);
2708
+ return Jt(t, e);
2474
2709
  if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
2475
2710
  return null;
2476
- throw u({
2711
+ throw d({
2477
2712
  code: "parse_error",
2478
2713
  path: e,
2479
2714
  details: { message: `unsupported hyogen directive: ${r}` }
2480
2715
  });
2481
2716
  }
2482
- function jt(t, e = {}) {
2717
+ function sn(t, e = {}) {
2483
2718
  const n = e.path;
2484
- if (Ae(t))
2485
- throw u({
2719
+ if (Fe(t))
2720
+ throw d({
2486
2721
  code: "parse_error",
2487
2722
  path: n,
2488
2723
  details: {
2489
- message: $e(t) ?? "unclosed hyogen block (missing closing marker)"
2724
+ message: je(t) ?? "unclosed hyogen block (missing closing marker)"
2490
2725
  }
2491
2726
  });
2492
2727
  const r = E(t);
2493
2728
  if (r.length === 0)
2494
2729
  return { source: t, directives: [] };
2495
- const s = [];
2496
- let i = t, o = 0, a = 0;
2730
+ const i = [];
2731
+ let s = t, o = 0, a = 0;
2497
2732
  for (const c of r) {
2498
- const h = Bt(c.inner, n);
2733
+ const h = rn(c.inner, n);
2499
2734
  if (!h || h.kind === "control")
2500
2735
  continue;
2501
- const l = c.start - o, d = c.end - o;
2736
+ const l = c.start - o, u = c.end - o;
2502
2737
  if (h.kind === "component") {
2503
2738
  e.registry && e.registry.register(
2504
2739
  {
@@ -2509,74 +2744,74 @@ function jt(t, e = {}) {
2509
2744
  Object.keys(e.context ?? {}),
2510
2745
  n
2511
2746
  );
2512
- const g = i.slice(0, l), m = i.slice(d);
2513
- i = T(g, m), o += c.raw.length + ie(g, m);
2747
+ const g = s.slice(0, l), m = s.slice(u);
2748
+ s = T(g, m), o += c.raw.length + ae(g, m);
2514
2749
  continue;
2515
2750
  }
2516
- const f = Nt(a++);
2517
- s.push({ ...h, marker: f, raw: c.raw }), i = i.slice(0, l) + f + i.slice(d), o += c.raw.length - f.length;
2751
+ const f = nn(a++);
2752
+ i.push({ ...h, marker: f, raw: c.raw }), s = s.slice(0, l) + f + s.slice(u), o += c.raw.length - f.length;
2518
2753
  }
2519
- return { source: i, directives: s };
2754
+ return { source: s, directives: i };
2520
2755
  }
2521
- function Ft(t, e) {
2756
+ function on(t, e) {
2522
2757
  return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
2523
2758
  ` : `${e.rawFrontMatter}
2524
2759
  ${t}`;
2525
2760
  }
2526
- function Pt(t, e = !1) {
2761
+ function an(t, e = !1) {
2527
2762
  if (e)
2528
2763
  return t;
2529
2764
  const n = E(t);
2530
2765
  if (n.length === 0)
2531
2766
  return t;
2532
- let r = t, s = 0;
2533
- for (const i of n) {
2534
- const o = i.start - s, a = i.end - s, c = r.slice(0, o), h = r.slice(a);
2535
- r = T(c, h), s += i.raw.length + ie(c, h);
2767
+ let r = t, i = 0;
2768
+ for (const s of n) {
2769
+ const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
2770
+ r = T(c, h), i += s.raw.length + ae(c, h);
2536
2771
  }
2537
2772
  return r;
2538
2773
  }
2539
- const It = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
2540
- function zt(t, e) {
2774
+ const cn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
2775
+ function ln(t, e) {
2541
2776
  const n = t.trim();
2542
2777
  if (n === "endblock")
2543
2778
  return { kind: "endblock" };
2544
- const r = It.exec(n);
2779
+ const r = cn.exec(n);
2545
2780
  if (!r)
2546
- throw u({
2781
+ throw d({
2547
2782
  code: "parse_error",
2548
2783
  path: e,
2549
2784
  details: { message: "invalid block directive" }
2550
2785
  });
2551
- const s = r[1];
2552
- if (De(s))
2553
- throw u({
2786
+ const i = r[1];
2787
+ if (Ve(i))
2788
+ throw d({
2554
2789
  code: "parse_error",
2555
2790
  path: e,
2556
- details: { message: `reserved word cannot be used as block name: ${s}` }
2791
+ details: { message: `reserved word cannot be used as block name: ${i}` }
2557
2792
  });
2558
- return { kind: "block", name: s };
2793
+ return { kind: "block", name: i };
2559
2794
  }
2560
- function ke(t, e) {
2561
- const { path: n, mode: r, hasExtend: s = !1 } = e, i = E(t);
2562
- if (i.length === 0) return [];
2795
+ function _e(t, e) {
2796
+ const { path: n, mode: r, hasExtend: i = !1 } = e, s = E(t);
2797
+ if (s.length === 0) return [];
2563
2798
  const o = [], a = [], c = /* @__PURE__ */ new Set();
2564
- for (const h of i) {
2799
+ for (const h of s) {
2565
2800
  const l = A(h.inner);
2566
2801
  if (l.length !== 1) continue;
2567
- const d = l[0];
2568
- if (!(d === "endblock" || d.startsWith("block "))) continue;
2569
- if (r === "child" && !s)
2570
- throw u({
2802
+ const u = l[0];
2803
+ if (!(u === "endblock" || u.startsWith("block "))) continue;
2804
+ if (r === "child" && !i)
2805
+ throw d({
2571
2806
  code: "parse_error",
2572
2807
  path: n,
2573
2808
  details: { message: "orphan block without extend" }
2574
2809
  });
2575
- const g = zt(d, n);
2810
+ const g = ln(u, n);
2576
2811
  if (g.kind === "endblock") {
2577
2812
  const m = a.pop();
2578
2813
  if (!m)
2579
- throw u({
2814
+ throw d({
2580
2815
  code: "parse_error",
2581
2816
  path: n,
2582
2817
  details: { message: "endblock without matching block opener" }
@@ -2591,13 +2826,13 @@ function ke(t, e) {
2591
2826
  continue;
2592
2827
  }
2593
2828
  if (a.length > 0)
2594
- throw u({
2829
+ throw d({
2595
2830
  code: "parse_error",
2596
2831
  path: n,
2597
2832
  details: { message: "nested block structures are not supported" }
2598
2833
  });
2599
2834
  if (c.has(g.name))
2600
- throw u({
2835
+ throw d({
2601
2836
  code: "parse_error",
2602
2837
  path: n,
2603
2838
  details: { message: `duplicate block: ${g.name}` }
@@ -2609,44 +2844,44 @@ function ke(t, e) {
2609
2844
  });
2610
2845
  }
2611
2846
  if (a.length > 0)
2612
- throw u({
2847
+ throw d({
2613
2848
  code: "parse_error",
2614
2849
  path: n,
2615
2850
  details: { message: "missing endblock" }
2616
2851
  });
2617
2852
  return o;
2618
2853
  }
2619
- function be(t) {
2854
+ function Se(t) {
2620
2855
  const e = E(t), n = [];
2621
2856
  for (const r of e) {
2622
- const s = A(r.inner);
2623
- if (s.length === 0) continue;
2624
- const i = ae(s[0]);
2625
- i && n.push({ path: i.path, start: r.start });
2857
+ const i = A(r.inner);
2858
+ if (i.length === 0) continue;
2859
+ const s = he(i[0]);
2860
+ s && n.push({ path: s.path, start: r.start });
2626
2861
  }
2627
2862
  return n;
2628
2863
  }
2629
- function Ut(t) {
2864
+ function hn(t) {
2630
2865
  const e = E(t);
2631
2866
  for (const n of e) {
2632
2867
  const r = A(n.inner);
2633
2868
  if (r.length !== 1) continue;
2634
- const s = r[0];
2635
- if (s === "endblock" || s.startsWith("block ")) return !0;
2869
+ const i = r[0];
2870
+ if (i === "endblock" || i.startsWith("block ")) return !0;
2636
2871
  }
2637
2872
  return !1;
2638
2873
  }
2639
- function K(t) {
2874
+ function Y(t) {
2640
2875
  return t.map((e) => e.body).join("");
2641
2876
  }
2642
- function Zt(t, e, n) {
2643
- const r = [...e].sort((o, a) => o.start - a.start), s = [];
2644
- let i = 0;
2877
+ function un(t, e, n) {
2878
+ const r = [...e].sort((o, a) => o.start - a.start), i = [];
2879
+ let s = 0;
2645
2880
  for (const o of r)
2646
- s.push(t.slice(i, o.start)), s.push(n.get(o.name) ?? o.body), i = o.end;
2647
- return s.push(t.slice(i)), s.reduce((o, a) => T(o, a));
2881
+ i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
2882
+ return i.push(t.slice(s)), i.reduce((o, a) => T(o, a));
2648
2883
  }
2649
- function qt(t) {
2884
+ function dn(t) {
2650
2885
  if (t instanceof Error && "code" in t && "details" in t) {
2651
2886
  const e = t;
2652
2887
  if (e.code === "file_not_found" && e.details && e.details.via === "include")
@@ -2654,46 +2889,46 @@ function qt(t) {
2654
2889
  }
2655
2890
  return { errorToThrow: t, adjusted: !1 };
2656
2891
  }
2657
- async function Vt(t, e) {
2892
+ async function fn(t, e) {
2658
2893
  const {
2659
2894
  path: n,
2660
2895
  context: r,
2661
- declarationUpdates: s,
2662
- loader: i,
2896
+ declarationUpdates: i,
2897
+ loader: s,
2663
2898
  root: o,
2664
2899
  constrainToRoot: a,
2665
2900
  visitStack: c,
2666
2901
  warnings: h,
2667
2902
  inComponent: l = !1
2668
- } = e, d = be(t);
2669
- if (d.length === 0) {
2670
- if (Ut(t))
2671
- throw u({
2903
+ } = e, u = Se(t);
2904
+ if (u.length === 0) {
2905
+ if (hn(t))
2906
+ throw d({
2672
2907
  code: "parse_error",
2673
2908
  path: n,
2674
2909
  details: { message: "orphan block without extend" }
2675
2910
  });
2676
- return { source: t, context: _(r, s) };
2911
+ return { source: t, context: S(r, i) };
2677
2912
  }
2678
2913
  const g = E(t)[0];
2679
2914
  if (!g)
2680
- return { source: t, context: _(r, s) };
2681
- if (!i)
2915
+ return { source: t, context: S(r, i) };
2916
+ if (!s)
2682
2917
  throw new Error("loader is required when processing extend directives");
2683
2918
  const m = A(g.inner);
2684
- if (!(m.length > 0 ? ae(m[0]) : null))
2685
- throw u({
2919
+ if (!(m.length > 0 ? he(m[0]) : null))
2920
+ throw d({
2686
2921
  code: "parse_error",
2687
2922
  path: n,
2688
2923
  details: { message: "extend must be the first hyogen block" }
2689
2924
  });
2690
- if (d.length > 1)
2691
- throw u({
2925
+ if (u.length > 1)
2926
+ throw d({
2692
2927
  code: "parse_error",
2693
2928
  path: n,
2694
2929
  details: { message: "multiple extend directives are not supported" }
2695
2930
  });
2696
- const $ = ke(t, {
2931
+ const v = _e(t, {
2697
2932
  path: n,
2698
2933
  mode: "child",
2699
2934
  hasExtend: !0
@@ -2701,14 +2936,14 @@ async function Vt(t, e) {
2701
2936
  if (l)
2702
2937
  return h?.push({
2703
2938
  code: "extend_in_component",
2704
- message: R("extend_in_component", { path: n }),
2939
+ message: H("extend_in_component", { path: n }),
2705
2940
  path: n,
2706
2941
  details: { path: n }
2707
2942
  }), {
2708
- source: K($),
2709
- context: _(r, s)
2943
+ source: Y(v),
2944
+ context: S(r, i)
2710
2945
  };
2711
- const D = d[0].path, b = n, v = Y(
2946
+ const D = u[0].path, b = n, y = X(
2712
2947
  o,
2713
2948
  D,
2714
2949
  n,
@@ -2718,85 +2953,85 @@ async function Vt(t, e) {
2718
2953
  );
2719
2954
  b && c.push(b);
2720
2955
  try {
2721
- const S = b ? c.check(v) : { circular: !1 };
2722
- if (S.circular)
2956
+ const W = b ? c.check(y) : { circular: !1 };
2957
+ if (W.circular)
2723
2958
  return h?.push({
2724
2959
  code: "circular_include",
2725
- message: R("circular_include", {
2726
- path: v,
2727
- from: S.from,
2960
+ message: H("circular_include", {
2961
+ path: y,
2962
+ from: W.from,
2728
2963
  via: "extend"
2729
2964
  }),
2730
2965
  path: n,
2731
- details: { path: v, from: S.from, via: "extend" }
2966
+ details: { path: y, from: W.from, via: "extend" }
2732
2967
  }), {
2733
- source: K($),
2734
- context: _(r, s)
2968
+ source: Y(v),
2969
+ context: S(r, i)
2735
2970
  };
2736
- c.push(v);
2971
+ c.push(y);
2737
2972
  try {
2738
- const L = await i(v);
2973
+ const L = await s(y);
2739
2974
  if (L === void 0)
2740
2975
  throw new Error("loader returned undefined");
2741
- const { context: j, body: H } = P(
2976
+ const { context: j, body: N } = I(
2742
2977
  L,
2743
- v
2744
- ), he = be(H);
2745
- if (he.length > 0) {
2746
- const F = he[0].path, I = Y(
2978
+ y
2979
+ ), fe = Se(N);
2980
+ if (fe.length > 0) {
2981
+ const P = fe[0].path, z = X(
2747
2982
  o,
2748
- F,
2749
- v,
2750
- v,
2983
+ P,
2984
+ y,
2985
+ y,
2751
2986
  a,
2752
2987
  !0
2753
- ), z = c.check(I);
2754
- if (z.circular)
2988
+ ), U = c.check(z);
2989
+ if (U.circular)
2755
2990
  return h?.push({
2756
2991
  code: "circular_include",
2757
- message: R("circular_include", {
2758
- path: I,
2759
- from: z.from,
2992
+ message: H("circular_include", {
2993
+ path: z,
2994
+ from: U.from,
2760
2995
  via: "extend"
2761
2996
  }),
2762
2997
  path: n,
2763
- details: { path: I, from: z.from, via: "extend" }
2998
+ details: { path: z, from: U.from, via: "extend" }
2764
2999
  }), {
2765
- source: K($),
2766
- context: _(r, s)
3000
+ source: Y(v),
3001
+ context: S(r, i)
2767
3002
  };
2768
- throw u({
3003
+ throw d({
2769
3004
  code: "parse_error",
2770
- path: v,
3005
+ path: y,
2771
3006
  details: { message: "layout extend is not supported" }
2772
3007
  });
2773
3008
  }
2774
- const Ne = ke(H, {
2775
- path: v,
3009
+ const Ye = _e(N, {
3010
+ path: y,
2776
3011
  mode: "layout"
2777
- }), Be = new Map(
2778
- $.map((F) => [F.name, F.body])
2779
- ), je = Zt(
2780
- H,
2781
- Ne,
2782
- Be
2783
- ), Fe = _(
3012
+ }), Xe = new Map(
3013
+ v.map((P) => [P.name, P.body])
3014
+ ), Ge = un(
3015
+ N,
3016
+ Ye,
3017
+ Xe
3018
+ ), Je = S(
2784
3019
  r,
2785
3020
  j,
2786
- s
3021
+ i
2787
3022
  );
2788
- return { source: je, context: Fe };
3023
+ return { source: Ge, context: Je };
2789
3024
  } finally {
2790
3025
  c.pop();
2791
3026
  }
2792
- } catch (S) {
2793
- const L = qt(S);
2794
- throw L.adjusted ? L.errorToThrow : S;
3027
+ } catch (W) {
3028
+ const L = dn(W);
3029
+ throw L.adjusted ? L.errorToThrow : W;
2795
3030
  } finally {
2796
3031
  b && c.pop();
2797
3032
  }
2798
3033
  }
2799
- const Kt = J.warningReasons, Yt = [
3034
+ const pn = Q.warningReasons, mn = [
2800
3035
  {
2801
3036
  reason: "contains_html_script_tag",
2802
3037
  test: (t) => /<\/?script\b/i.test(t)
@@ -2818,51 +3053,51 @@ const Kt = J.warningReasons, Yt = [
2818
3053
  test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
2819
3054
  }
2820
3055
  ];
2821
- function Xt(t) {
2822
- return Kt[t] ?? t;
3056
+ function gn(t) {
3057
+ return pn[t] ?? t;
2823
3058
  }
2824
- function X(t, e, n, r) {
3059
+ function G(t, e, n, r) {
2825
3060
  if (typeof t == "string") {
2826
- for (const s of Yt)
2827
- s.test(t) && n.push({
3061
+ for (const i of mn)
3062
+ i.test(t) && n.push({
2828
3063
  code: "suspicious_context_value",
2829
- message: R("suspicious_context_value", {
3064
+ message: H("suspicious_context_value", {
2830
3065
  key: e,
2831
- reason: Xt(s.reason)
3066
+ reason: gn(i.reason)
2832
3067
  }),
2833
3068
  path: r,
2834
- details: { key: e, reason: s.reason }
3069
+ details: { key: e, reason: i.reason }
2835
3070
  });
2836
3071
  return;
2837
3072
  }
2838
3073
  if (t != null) {
2839
3074
  if (Array.isArray(t)) {
2840
- for (let s = 0; s < t.length; s++)
2841
- X(t[s], `${e}[${s}]`, n, r);
3075
+ for (let i = 0; i < t.length; i++)
3076
+ G(t[i], `${e}[${i}]`, n, r);
2842
3077
  return;
2843
3078
  }
2844
3079
  if (typeof t == "object")
2845
- for (const [s, i] of Object.entries(
3080
+ for (const [i, s] of Object.entries(
2846
3081
  t
2847
3082
  )) {
2848
- const o = e.length > 0 ? `${e}.${s}` : s;
2849
- X(i, o, n, r);
3083
+ const o = e.length > 0 ? `${e}.${i}` : i;
3084
+ G(s, o, n, r);
2850
3085
  }
2851
3086
  }
2852
3087
  }
2853
- function Gt(t, e, n) {
2854
- for (const [r, s] of Object.entries(t))
2855
- X(s, r, e, n);
3088
+ function xn(t, e, n) {
3089
+ for (const [r, i] of Object.entries(t))
3090
+ G(i, r, e, n);
2856
3091
  }
2857
- const Jt = /^=+[ \t]*$/, Qt = /^-+[ \t]*$/, en = /^(```|~~~)/, tn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
2858
- function G(t) {
2859
- const e = tn.exec(t);
3092
+ const wn = /^=+[ \t]*$/, kn = /^-+[ \t]*$/, vn = /^(```|~~~)/, bn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
3093
+ function J(t) {
3094
+ const e = bn.exec(t);
2860
3095
  return e && e.index !== void 0 ? {
2861
3096
  text: t.slice(0, e.index).trim(),
2862
3097
  explicitId: e[1]
2863
3098
  } : { text: t.trim() };
2864
3099
  }
2865
- function nn(t) {
3100
+ function yn(t) {
2866
3101
  let e = 0;
2867
3102
  for (; e < t.length && e < 6 && t[e] === "#"; )
2868
3103
  e += 1;
@@ -2876,7 +3111,7 @@ function nn(t) {
2876
3111
  let r = t.length;
2877
3112
  for (; r > n && (t[r - 1] === " " || t[r - 1] === " "); )
2878
3113
  r -= 1;
2879
- let s = r;
3114
+ let i = r;
2880
3115
  if (r > n && t[r - 1] === "#") {
2881
3116
  let o = r - 1;
2882
3117
  for (; o > n && t[o - 1] === "#"; )
@@ -2885,141 +3120,141 @@ function nn(t) {
2885
3120
  let a = o - 1;
2886
3121
  for (; a >= n && (t[a] === " " || t[a] === " "); )
2887
3122
  a -= 1;
2888
- s = a + 1;
3123
+ i = a + 1;
2889
3124
  }
2890
3125
  }
2891
- if (s <= n)
3126
+ if (i <= n)
2892
3127
  return null;
2893
- const i = G(t.slice(n, s));
2894
- return { level: e, ...i };
3128
+ const s = J(t.slice(n, i));
3129
+ return { level: e, ...s };
2895
3130
  }
2896
- function ve(t, e, n) {
3131
+ function Ce(t, e, n) {
2897
3132
  let r = n;
2898
3133
  for (; r < t.length; ) {
2899
3134
  if (!e.inHtmlComment) {
2900
- const i = t.indexOf("<!--", r);
2901
- if (i === -1)
3135
+ const s = t.indexOf("<!--", r);
3136
+ if (s === -1)
2902
3137
  return;
2903
- e.inHtmlComment = !0, r = i + 4;
3138
+ e.inHtmlComment = !0, r = s + 4;
2904
3139
  continue;
2905
3140
  }
2906
- const s = t.indexOf("-->", r);
2907
- if (s === -1)
3141
+ const i = t.indexOf("-->", r);
3142
+ if (i === -1)
2908
3143
  return;
2909
- e.inHtmlComment = !1, r = s + 3;
3144
+ e.inHtmlComment = !1, r = i + 3;
2910
3145
  }
2911
3146
  }
2912
- function rn(t, e) {
3147
+ function _n(t, e) {
2913
3148
  if (e.inFence || e.inHtmlComment)
2914
3149
  return !0;
2915
3150
  const n = t.trim();
2916
3151
  return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
2917
3152
  }
2918
- function sn(t) {
3153
+ function Sn(t) {
2919
3154
  const e = t.split(/\r?\n/), n = [], r = { inFence: !1, inHtmlComment: !1 };
2920
- for (let s = 0; s < e.length; s++) {
2921
- const i = e[s];
3155
+ for (let i = 0; i < e.length; i++) {
3156
+ const s = e[i];
2922
3157
  if (r.inFence) {
2923
- const l = i.trim();
3158
+ const l = s.trim();
2924
3159
  l.startsWith(r.inFence.marker) && /^(`{3,}|~{3,})\s*$/.test(l) && (r.inFence = !1);
2925
3160
  continue;
2926
3161
  }
2927
3162
  if (r.inHtmlComment) {
2928
- ve(i, r, 0);
3163
+ Ce(s, r, 0);
2929
3164
  continue;
2930
3165
  }
2931
- const o = en.exec(i.trimStart());
3166
+ const o = vn.exec(s.trimStart());
2932
3167
  if (o) {
2933
3168
  const l = o[1];
2934
- i.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
3169
+ s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
2935
3170
  continue;
2936
3171
  }
2937
- if (i.trim().startsWith("<!--")) {
2938
- ve(i, r, i.indexOf("<!--"));
3172
+ if (s.trim().startsWith("<!--")) {
3173
+ Ce(s, r, s.indexOf("<!--"));
2939
3174
  continue;
2940
3175
  }
2941
- if (rn(i, r))
3176
+ if (_n(s, r))
2942
3177
  continue;
2943
- const c = nn(i);
3178
+ const c = yn(s);
2944
3179
  if (c) {
2945
3180
  n.push(c);
2946
3181
  continue;
2947
3182
  }
2948
- const h = e[s + 1];
2949
- if (h !== void 0 && i.trim().length > 0 && !i.trimStart().startsWith("#") && !i.trimStart().startsWith(">") && !i.trimStart().startsWith("|")) {
2950
- if (Jt.test(h)) {
2951
- const l = G(i.trim());
2952
- n.push({ level: 1, ...l }), s += 1;
3183
+ const h = e[i + 1];
3184
+ if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
3185
+ if (wn.test(h)) {
3186
+ const l = J(s.trim());
3187
+ n.push({ level: 1, ...l }), i += 1;
2953
3188
  continue;
2954
3189
  }
2955
- if (Qt.test(h) && h.trim().length >= 1) {
2956
- const l = G(i.trim());
2957
- n.push({ level: 2, ...l }), s += 1;
3190
+ if (kn.test(h) && h.trim().length >= 1) {
3191
+ const l = J(s.trim());
3192
+ n.push({ level: 2, ...l }), i += 1;
2958
3193
  continue;
2959
3194
  }
2960
3195
  }
2961
3196
  }
2962
3197
  return n;
2963
3198
  }
2964
- const on = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
2965
- function an() {
3199
+ const Cn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
3200
+ function Wn() {
2966
3201
  const t = /* @__PURE__ */ new Map();
2967
3202
  return {
2968
3203
  slug(e, n) {
2969
- const r = n !== void 0 && n.length > 0 ? n : cn(e), s = t.get(r) ?? 0;
2970
- return t.set(r, s + 1), s === 0 ? r : `${r}-${s}`;
3204
+ const r = n !== void 0 && n.length > 0 ? n : $n(e), i = t.get(r) ?? 0;
3205
+ return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
2971
3206
  }
2972
3207
  };
2973
3208
  }
2974
- function cn(t) {
2975
- return t.toLowerCase().replace(on, "").replace(/\s+/g, "-");
3209
+ function $n(t) {
3210
+ return t.toLowerCase().replace(Cn, "").replace(/\s+/g, "-");
2976
3211
  }
2977
- function ln(t) {
3212
+ function An(t) {
2978
3213
  let e = t.trim();
2979
3214
  e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
2980
3215
  for (let n = 0; n < 3; n++)
2981
3216
  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");
2982
3217
  return e.trim();
2983
3218
  }
2984
- function hn(t, e) {
3219
+ function En(t, e) {
2985
3220
  if (t.length === 0)
2986
3221
  return "";
2987
- const n = an(), s = t.map((o) => {
2988
- const a = ln(o.text), c = n.slug(a, o.explicitId);
3222
+ const n = Wn(), i = t.map((o) => {
3223
+ const a = An(o.text), c = n.slug(a, o.explicitId);
2989
3224
  return { level: o.level, text: a, anchor: c };
2990
3225
  }).filter((o) => o.level <= e);
2991
- if (s.length === 0)
3226
+ if (i.length === 0)
2992
3227
  return "";
2993
- const i = Math.min(...s.map((o) => o.level));
2994
- return s.map((o) => `${" ".repeat((o.level - i) * 2)}- [${o.text}](#${o.anchor})`).join(`
3228
+ const s = Math.min(...i.map((o) => o.level));
3229
+ return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
2995
3230
  `);
2996
3231
  }
2997
- function dn(t, e = {}) {
3232
+ function Tn(t, e = {}) {
2998
3233
  const r = E(t).filter((o) => {
2999
3234
  const a = A(o.inner);
3000
- return a.length === 1 && ce(a[0]);
3235
+ return a.length === 1 && ue(a[0]);
3001
3236
  });
3002
3237
  if (r.length === 0)
3003
3238
  return t;
3004
- const s = sn(t);
3005
- let i = t;
3239
+ const i = Sn(t);
3240
+ let s = t;
3006
3241
  for (let o = r.length - 1; o >= 0; o--) {
3007
- const a = r[o], { maxLevel: c } = Tt(a.inner, e.path), h = hn(s, c), l = i.slice(0, a.start), d = i.slice(a.end);
3008
- i = T(T(l, h), d);
3242
+ const a = r[o], { maxLevel: c } = Yt(a.inner, e.path), h = En(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
3243
+ s = T(T(l, h), u);
3009
3244
  }
3010
- return i;
3245
+ return s;
3011
3246
  }
3012
- async function le(t, e) {
3013
- const n = e.path, r = e.context, s = e.registry ?? new _e(), i = e.warnings ?? [], o = e.visitStack ?? new Re(), {
3247
+ async function de(t, e) {
3248
+ const n = e.path, r = e.context, i = e.registry ?? new $e(), s = e.warnings ?? [], o = e.visitStack ?? new qe(), {
3014
3249
  source: a,
3015
3250
  declarationUpdates: c
3016
- } = await Lt(t, { path: n, context: { ...r } });
3017
- Gt(
3018
- _(r, c ?? {}),
3019
- i,
3251
+ } = await Xt(t, { path: n, context: { ...r } });
3252
+ xn(
3253
+ S(r, c ?? {}),
3254
+ s,
3020
3255
  n
3021
3256
  );
3022
- const h = await Vt(a, {
3257
+ const h = await fn(a, {
3023
3258
  path: n,
3024
3259
  context: r,
3025
3260
  declarationUpdates: c ?? {},
@@ -3027,123 +3262,129 @@ async function le(t, e) {
3027
3262
  root: e.root,
3028
3263
  constrainToRoot: e.constrainToRoot,
3029
3264
  visitStack: o,
3030
- warnings: i,
3265
+ warnings: s,
3031
3266
  inComponent: e.inComponent ?? !1
3032
- }), { source: l, context: d } = h, { source: f, directives: g } = jt(l, {
3267
+ }), { source: l, context: u } = h, { source: f, directives: g } = sn(l, {
3033
3268
  path: n,
3034
- registry: s,
3035
- context: d
3269
+ registry: i,
3270
+ context: u
3036
3271
  }), m = e.loader;
3037
3272
  if (g.length > 0 && !m)
3038
3273
  throw new Error("loader is required when processing include directives");
3039
3274
  let p = f;
3040
- return g.length > 0 && m && (p = await Ct({
3275
+ g.length > 0 && m && (p = await Ut({
3041
3276
  source: f,
3042
3277
  directives: g,
3043
- context: d,
3278
+ context: u,
3044
3279
  loader: m,
3045
3280
  root: e.root,
3046
3281
  path: n,
3047
3282
  preserveFrontMatter: e.preserveFrontMatter,
3048
3283
  preserveHgComments: e.preserveHgComments,
3049
3284
  visitStack: o,
3050
- warnings: i,
3051
- registry: s,
3285
+ warnings: s,
3286
+ registry: i,
3052
3287
  constrainToRoot: e.constrainToRoot
3053
- })), p = await vt(p, {
3054
- context: d,
3288
+ })), p = await jt(p, {
3289
+ context: u,
3055
3290
  path: n,
3056
- registry: s,
3291
+ registry: i,
3057
3292
  loader: m,
3058
3293
  rootDir: e.root,
3059
- warnings: i,
3294
+ warnings: s,
3060
3295
  visitStack: o,
3061
- parentContext: d,
3296
+ parentContext: u,
3062
3297
  preserveHgComments: e.preserveHgComments,
3063
3298
  constrainToRoot: e.constrainToRoot
3064
- }), p = await We(p, d, {
3299
+ });
3300
+ const v = {
3065
3301
  path: n,
3066
- registry: s,
3302
+ registry: i,
3067
3303
  loader: m,
3068
3304
  rootDir: e.root,
3069
- warnings: i,
3305
+ warnings: s,
3070
3306
  visitStack: o,
3071
- parentContext: d,
3307
+ parentContext: u,
3072
3308
  preserveHgComments: e.preserveHgComments,
3073
3309
  constrainToRoot: e.constrainToRoot
3074
- }), p = dn(p, { path: n }), p = Pt(p, e.preserveHgComments), p;
3075
- }
3076
- async function un(t, e = {}) {
3077
- const n = e.path, r = _(e.context), s = e.registry ?? new _e(), i = e.warnings ?? [], o = e.visitStack ?? new Re(), { context: a, body: c, rawFrontMatter: h } = P(
3310
+ };
3311
+ return p = await Ne(p, u, v), p = await Be(
3312
+ p,
3313
+ u,
3314
+ v
3315
+ ), p = Tn(p, { path: n }), p = an(p, e.preserveHgComments), p;
3316
+ }
3317
+ async function Ln(t, e = {}) {
3318
+ const n = e.path, r = S(e.context), i = e.registry ?? new $e(), s = e.warnings ?? [], o = e.visitStack ?? new qe(), { context: a, body: c, rawFrontMatter: h } = I(
3078
3319
  t,
3079
3320
  n
3080
- ), l = _(r, a);
3081
- let d = await le(c, {
3321
+ ), l = S(r, a);
3322
+ let u = await de(c, {
3082
3323
  ...e,
3083
3324
  context: l,
3084
- registry: s,
3085
- warnings: i,
3325
+ registry: i,
3326
+ warnings: s,
3086
3327
  visitStack: o
3087
3328
  });
3088
- return d = Ft(d, {
3329
+ return u = on(u, {
3089
3330
  preserveFrontMatter: e.preserveFrontMatter,
3090
3331
  rawFrontMatter: h
3091
3332
  }), {
3092
- markdown: d,
3093
- warnings: i
3333
+ markdown: u,
3334
+ warnings: s
3094
3335
  };
3095
3336
  }
3096
- async function fn(t, e) {
3097
- const n = e.path, { context: r, body: s } = P(t, n), i = _(e.context, r);
3098
- return le(s, {
3337
+ async function Mn(t, e) {
3338
+ const n = e.path, { context: r, body: i } = I(t, n), s = S(e.context, r);
3339
+ return de(i, {
3099
3340
  ...e,
3100
- context: i,
3341
+ context: s,
3101
3342
  preserveFrontMatter: !1
3102
3343
  });
3103
3344
  }
3104
- async function mn(t, e, n) {
3345
+ async function Rn(t, e, n) {
3105
3346
  if (n != null && "serverContext" in n && n.serverContext != null)
3106
- throw u({
3347
+ throw d({
3107
3348
  code: "server_context_on_client"
3108
3349
  });
3109
3350
  if (n != null && "dataSources" in n && n.dataSources != null && Object.keys(n.dataSources).length > 0)
3110
- throw u({
3351
+ throw d({
3111
3352
  code: "data_sources_on_client"
3112
3353
  });
3113
3354
  const r = n?.loader;
3114
3355
  if (!r)
3115
- throw u({
3356
+ throw d({
3116
3357
  code: "parse_error",
3117
3358
  details: { message: "loader is required for renderClient" }
3118
3359
  });
3119
- let s, i;
3120
- typeof t == "string" ? s = t : (i = t.path, s = await r(t.path));
3121
- const o = _(e);
3122
- return un(s, {
3360
+ let i, s;
3361
+ typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
3362
+ const o = S(e);
3363
+ return Ln(i, {
3123
3364
  context: o,
3124
3365
  loader: r,
3125
3366
  root: n?.root,
3126
- path: i ?? n?.path,
3367
+ path: s ?? n?.path,
3127
3368
  preserveFrontMatter: n?.preserveFrontMatter,
3128
3369
  preserveHgComments: n?.preserveHgComments,
3129
3370
  constrainToRoot: n?.constrainToRoot
3130
3371
  });
3131
3372
  }
3132
- function gn(t, e) {
3373
+ function Hn(t, e) {
3133
3374
  const n = [`[hyogen:${t}] ${e.code}`], r = {};
3134
3375
  if (e.details)
3135
- for (const [s, i] of Object.entries(e.details))
3136
- i !== void 0 && (r[s] = i);
3376
+ for (const [i, s] of Object.entries(e.details))
3377
+ s !== void 0 && (r[i] = s);
3137
3378
  r.path === void 0 && e.path !== void 0 && (r.path = e.path);
3138
- for (const [s, i] of Object.entries(r))
3139
- n.push(` ${s}: ${String(i)}`);
3379
+ for (const [i, s] of Object.entries(r))
3380
+ n.push(` ${i}: ${String(s)}`);
3140
3381
  return n.join(`
3141
3382
  `);
3142
3383
  }
3143
3384
  export {
3144
- u as createHyogenError,
3145
- gn as formatDiagnosticLog,
3146
- Ve as formatMessage,
3147
- mn as renderClient
3385
+ d as createHyogenError,
3386
+ Hn as formatDiagnosticLog,
3387
+ st as formatMessage,
3388
+ Rn as renderClient
3148
3389
  };
3149
3390
  //# sourceMappingURL=client.js.map