@b4moss/hyogen-md 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +23 -2
  2. package/README_ja.md +23 -2
  3. package/dist/build/build.d.ts +2 -0
  4. package/dist/build/buildDependencyGraph.d.ts +22 -0
  5. package/dist/build/collectDependencies.d.ts +8 -0
  6. package/dist/build/collectEntryPaths.d.ts +10 -0
  7. package/dist/build/isUnderscorePartial.d.ts +4 -0
  8. package/dist/cli.js +5587 -0
  9. package/dist/client.js +1022 -895
  10. package/dist/component/ComponentRegistry.d.ts +11 -0
  11. package/dist/component/parsePropsContract.d.ts +10 -0
  12. package/dist/component/renderComponent.d.ts +17 -0
  13. package/dist/component/validateProps.d.ts +7 -0
  14. package/dist/config/defineConfig.d.ts +5 -0
  15. package/dist/config/index.d.ts +3 -0
  16. package/dist/config/index.js +143 -0
  17. package/dist/config/loadConfig.d.ts +13 -0
  18. package/dist/config/types.d.ts +26 -0
  19. package/dist/context/mergeContext.d.ts +3 -0
  20. package/dist/control/StructureNestTracker.d.ts +14 -0
  21. package/dist/control/expandControlStructures.d.ts +3 -0
  22. package/dist/control/parseControlOpener.d.ts +2 -0
  23. package/dist/control/parseControlStructures.d.ts +2 -0
  24. package/dist/createError-WZmAl05N.js +30 -0
  25. package/dist/errors/createError.d.ts +7 -0
  26. package/dist/errors/formatDiagnosticLog.d.ts +6 -0
  27. package/dist/errors/formatMessage.d.ts +3 -0
  28. package/dist/expr/evaluateExpression.d.ts +4 -0
  29. package/dist/expr/interpolateExpressions.d.ts +4 -0
  30. package/dist/expr/parseExpression.d.ts +4 -0
  31. package/dist/frontmatter/parseFrontMatter.d.ts +3 -0
  32. package/dist/include/VisitStack.d.ts +13 -0
  33. package/dist/include/expandIncludes.d.ts +18 -0
  34. package/dist/index.d.ts +11 -113
  35. package/dist/index.js +753 -625
  36. package/dist/io/createFsLoader.d.ts +6 -0
  37. package/dist/io/createNodeLoader.d.ts +4 -0
  38. package/dist/io/isRemotePath.d.ts +2 -0
  39. package/dist/io/loadDataSources.d.ts +8 -0
  40. package/dist/io/parseCsvFromString.d.ts +1 -0
  41. package/dist/io/parseDataFile.d.ts +1 -0
  42. package/dist/io/resolveIncludePath.d.ts +1 -0
  43. package/dist/layout/expandExtendsAndBlocks.d.ts +19 -0
  44. package/dist/layout/parseBlockOpener.d.ts +8 -0
  45. package/dist/layout/parseBlockStructures.d.ts +15 -0
  46. package/dist/layout/parseExtendBlock.d.ts +12 -0
  47. package/dist/layout/parseExtendDirective.d.ts +5 -0
  48. package/dist/logic/executeDeclaration.d.ts +6 -0
  49. package/dist/logic/executeDeclarations.d.ts +6 -0
  50. package/dist/logic/executeStatement.d.ts +10 -0
  51. package/dist/logic/hgBlockUtils.d.ts +3 -0
  52. package/dist/logic/parseDeclaration.d.ts +5 -0
  53. package/dist/logic/parseStatement.d.ts +3 -0
  54. package/dist/logic/reservedWords.d.ts +2 -0
  55. package/dist/logic/stripComments.d.ts +2 -0
  56. package/dist/markdown/shiftHeadings.d.ts +25 -0
  57. package/dist/parse/hgMarkers.d.ts +5 -0
  58. package/dist/parse/parseComponentDirective.d.ts +6 -0
  59. package/dist/parse/parseIncludeDirective.d.ts +2 -0
  60. package/dist/parse/scanHgBlocks.d.ts +10 -0
  61. package/dist/paths/assertWithinRootDir.d.ts +2 -0
  62. package/dist/paths/findDocRoot.d.ts +1 -0
  63. package/dist/paths/resolveRenderInput.d.ts +11 -0
  64. package/dist/paths/resolveTemplatePath.d.ts +9 -0
  65. package/dist/pipeline/applyFrontMatterOutputOption.d.ts +4 -0
  66. package/dist/pipeline/executeHgBlocks.d.ts +9 -0
  67. package/dist/pipeline/joinRemovalSeam.d.ts +12 -0
  68. package/dist/pipeline/renderDocument.d.ts +22 -0
  69. package/dist/pipeline/stripHgComments.d.ts +7 -0
  70. package/dist/renderClient.d.ts +15 -0
  71. package/dist/renderServer.d.ts +4 -0
  72. package/dist/security/forbiddenKeys.d.ts +3 -0
  73. package/dist/security/scanSuspiciousContext.d.ts +6 -0
  74. package/dist/shims/fs-browser.d.ts +6 -0
  75. package/dist/shims/fs-promises-browser.d.ts +5 -0
  76. package/dist/toc/expandToc.d.ts +8 -0
  77. package/dist/toc/extractHeadings.d.ts +10 -0
  78. package/dist/toc/formatTocMarkdown.d.ts +7 -0
  79. package/dist/toc/githubHeadingSlug.d.ts +11 -0
  80. package/dist/toc/parseTocDirective.d.ts +10 -0
  81. package/dist/toc/plainifyHeadingText.d.ts +2 -0
  82. package/dist/types.d.ts +211 -0
  83. package/package.json +17 -4
package/dist/client.js CHANGED
@@ -1,25 +1,25 @@
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 Je } from "yaml";
2
+ const Qe = { 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})" }, et = { 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})' }, tt = { 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: Qe,
4
+ warnings: et,
5
+ warningReasons: tt
6
+ }, nt = Q.errors, rt = Q.warnings;
7
+ function Se(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 it(t, e) {
16
+ return Se(nt[t], e);
17
17
  }
18
- function R(t, e) {
19
- return ye(qe[t], e);
18
+ function H(t, e) {
19
+ return Se(rt[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 ?? it(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
25
  function _(...t) {
@@ -28,17 +28,17 @@ function _(...t) {
28
28
  n != null && Object.assign(e, n);
29
29
  return e;
30
30
  }
31
- class _e {
31
+ class Ce {
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 }
@@ -53,7 +53,7 @@ class _e {
53
53
  }
54
54
  }
55
55
  const de = 64 * 1024;
56
- function P(t, e) {
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 > de)
69
+ throw d({
70
70
  code: "frontmatter_too_large",
71
71
  path: e,
72
72
  details: {
73
- size: i,
73
+ size: s,
74
74
  limit: de
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 = Je(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 st = /* @__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 ot(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
+ st.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 at(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 ct(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 lt(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 ?? at(h);
176
+ l && !ct(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 We(t) {
197
197
  return /^https?:\/\//i.test(t);
198
198
  }
199
- function Qe(t) {
199
+ function ht(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, fe;
203
+ function ut() {
204
+ if (fe) return q;
205
+ fe = 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 S = s.charCodeAt(a + p), D = o.charCodeAt(l + p);
288
+ if (S !== D)
289
289
  break;
290
- $ === 47 && (m = p);
290
+ S === 47 && (m = p);
291
291
  }
292
- var b = "";
292
+ var v = "";
293
293
  for (p = a + m + 1; p <= c; ++p)
294
- (p === c || i.charCodeAt(p) === 47) && (b.length === 0 ? b += ".." : b += "/..");
295
- return b.length > 0 ? b + o.slice(l + m) : (l += m, o.charCodeAt(l) === 47 && ++l, o.slice(l));
294
+ (p === c || s.charCodeAt(p) === 47) && (v.length === 0 ? v += ".." : v += "/..");
295
+ return v.length > 0 ? v + 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,36 +378,36 @@ 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;
388
+ return r.posix = r, q = r, q;
389
389
  }
390
- var tt = et();
391
- const y = /* @__PURE__ */ Qe(tt);
392
- function nt(t, e) {
390
+ var dt = ut();
391
+ const y = /* @__PURE__ */ ht(dt);
392
+ function ft(t, e) {
393
393
  const n = y.relative(e, t);
394
394
  return n === "" || !n.startsWith("..") && !y.isAbsolute(n);
395
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({
396
+ function pt(t, e, n) {
397
+ const r = y.resolve(e), i = y.resolve(t);
398
+ if (!ft(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 $e(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;
@@ -416,17 +416,17 @@ function Ce(t, e = {}) {
416
416
  a = y.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
424
  if (y.isAbsolute(t))
425
425
  a = y.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
  }
@@ -436,9 +436,9 @@ function Ce(t, e = {}) {
436
436
  else if (n)
437
437
  a = y.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
444
  else if (y.isAbsolute(t))
@@ -446,41 +446,42 @@ function Ce(t, e = {}) {
446
446
  else if (n)
447
447
  a = y.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 && pt(a, n, i), a;
455
455
  }
456
- async function it(t) {
456
+ async function mt(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 = We(e.componentPath) ? e.componentPath : $e(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 = ot(i, n), { values: a, warnings: c } = lt(
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 = _(
479
479
  t.parentContext,
480
480
  l,
481
481
  a
482
- ), g = (await le(i, {
483
- context: d,
482
+ );
483
+ return (await he(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 gt = /* @__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 xt(t) {
504
+ return gt.has(t);
512
505
  }
513
- function fe(t, e) {
514
- if (ot(t))
515
- throw u({
506
+ function pe(t, e) {
507
+ if (xt(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 wt(t, e, n) {
533
526
  switch (t) {
534
527
  case "+":
535
528
  return e + n;
@@ -556,48 +549,48 @@ 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
  }
565
558
  }
566
- async function k(t, e) {
559
+ async function w(t, e) {
567
560
  const { context: n, path: r } = e;
568
561
  switch (t.type) {
569
562
  case "literal":
570
563
  return t.value;
571
564
  case "identifier":
572
- return fe(t.name, r), n[t.name];
565
+ return pe(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
+ pe(t.property, r);
568
+ const i = await w(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 w(t.left, e);
573
+ return O(i) ? w(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 w(t.operand, e);
577
+ return t.op === "!" ? !i : void 0;
585
578
  }
586
579
  case "binary": {
587
580
  if (t.op === "&&") {
588
- const o = await k(t.left, e);
589
- return M(o) ? o : k(t.right, e);
581
+ const o = await w(t.left, e);
582
+ return O(o) ? o : w(t.right, e);
590
583
  }
591
584
  if (t.op === "||") {
592
- const o = await k(t.left, e);
593
- return M(o) ? k(t.right, e) : o;
585
+ const o = await w(t.left, e);
586
+ return O(o) ? w(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 w(t.left, e), s = await w(t.right, e);
589
+ return wt(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 w(o, e);
611
+ return mt({
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 w(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 w(t.condition, e);
639
+ return O(i) ? w(t.alternate, e) : w(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 w(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 vt(t) {
667
660
  return /[A-Za-z0-9_$]/.test(t);
668
661
  }
669
- function C(t, e, n = {}) {
662
+ function W(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 bt(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 bt {
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 = W(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 && vt(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,196 @@ class ht {
1083
1076
  return r;
1084
1077
  }
1085
1078
  }
1086
- async function We(t, e, n = {}) {
1079
+ const yt = /^( {0,3})(=+|-+)[ \t]*$/, Ae = /^( {0,3})(`{3,}|~{3,})(.*)$/;
1080
+ function M(t) {
1081
+ return t === " " || t === " ";
1082
+ }
1083
+ function Ee(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 Te() {
1117
+ return { active: !1, marker: null, length: 0 };
1118
+ }
1119
+ function Le(t, e) {
1120
+ const n = Ae.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 = Ee(t);
1136
+ return e ? e.level : null;
1137
+ }
1138
+ function Oe(t) {
1139
+ const e = yt.exec(t);
1140
+ return e ? e[2][0] === "=" ? 1 : 2 : null;
1141
+ }
1142
+ function _t(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 !(_t(t) || Me(t) !== null || Ae.test(t) || t.startsWith(" ") || t.startsWith(" "));
1150
+ }
1151
+ function He(t) {
1152
+ const e = t.split(`
1153
+ `), n = Te();
1154
+ let r = 0;
1155
+ for (let i = 0; i < e.length; i++) {
1156
+ const s = e[i];
1157
+ if (Le(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 St(t) {
1173
+ return t < 1 ? 1 : t > 6 ? 6 : t;
1174
+ }
1175
+ function me(t, e) {
1176
+ const n = e.trim(), r = "#".repeat(St(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 = Te(), i = [];
1184
+ for (let s = 0; s < n.length; s++) {
1185
+ const o = n[s];
1186
+ if (Le(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] = me(a + e, h);
1195
+ continue;
1196
+ }
1197
+ }
1198
+ const c = Ee(o);
1199
+ if (c !== null) {
1200
+ i.push(c.indent + me(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 = W(f, r), m = await w(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 S = He(i);
1239
+ p = De(p, S);
1240
+ }
1241
+ i += p, s = u + l.length;
1115
1242
  }
1116
- return s;
1243
+ return i;
1117
1244
  }
1118
- function dt(t, e) {
1245
+ function Ct(t, e) {
1119
1246
  let n = 0, r = 0;
1120
1247
  for (; r < t.length; ) {
1121
- const s = t.indexOf(e, r);
1122
- if (s === -1)
1248
+ const i = t.indexOf(e, r);
1249
+ if (i === -1)
1123
1250
  break;
1124
- n++, r = s + e.length;
1251
+ n++, r = i + e.length;
1125
1252
  }
1126
1253
  return n;
1127
1254
  }
1128
- function Q(t) {
1129
- const e = t.includes("@hg"), n = t.includes("@endhg"), r = dt(t, "@@");
1255
+ function ee(t) {
1256
+ const e = t.includes("@hg"), n = t.includes("@endhg"), r = Ct(t, "@@");
1130
1257
  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
1258
  }
1132
- function ee(t) {
1259
+ function te(t) {
1133
1260
  return t.replace(/@endhg/g, "").replace(/@hg/g, "").replace(/@@/g, "");
1134
1261
  }
1135
- function te(t, e) {
1262
+ function ne(t, e) {
1136
1263
  let n = 0, r = !1;
1137
1264
  for (; n < e; ) {
1138
- const s = t.indexOf("```", n);
1139
- if (s === -1 || s >= e)
1265
+ const i = t.indexOf("```", n);
1266
+ if (i === -1 || i >= e)
1140
1267
  break;
1141
- r = !r, n = s + 3;
1268
+ r = !r, n = i + 3;
1142
1269
  }
1143
1270
  return r;
1144
1271
  }
@@ -1149,233 +1276,233 @@ function E(t) {
1149
1276
  const r = t.indexOf("<!--", n);
1150
1277
  if (r === -1)
1151
1278
  break;
1152
- if (te(t, r)) {
1279
+ if (ne(t, r)) {
1153
1280
  n = r + 4;
1154
1281
  continue;
1155
1282
  }
1156
- const s = t.indexOf("-->", r + 4);
1157
- if (s === -1)
1283
+ const i = t.indexOf("-->", r + 4);
1284
+ if (i === -1)
1158
1285
  break;
1159
- const i = t.slice(r, s + 3), o = i.slice(4, i.length - 3), a = Q(o);
1286
+ const s = t.slice(r, i + 3), o = s.slice(4, s.length - 3), a = ee(o);
1160
1287
  (a === "hg" || a === "at-at") && e.push({
1161
1288
  start: r,
1162
- end: s + 3,
1289
+ end: i + 3,
1163
1290
  inner: o,
1164
- raw: i
1165
- }), n = s + 3;
1291
+ raw: s
1292
+ }), n = i + 3;
1166
1293
  }
1167
1294
  return e;
1168
1295
  }
1169
- function Ae(t) {
1296
+ function Be(t) {
1170
1297
  let e = 0;
1171
1298
  for (; e < t.length; ) {
1172
1299
  const n = t.indexOf("<!--", e);
1173
1300
  if (n === -1)
1174
1301
  return !1;
1175
- if (te(t, n)) {
1302
+ if (ne(t, n)) {
1176
1303
  e = n + 4;
1177
1304
  continue;
1178
1305
  }
1179
1306
  const r = t.indexOf("-->", n + 4);
1180
1307
  if (r === -1)
1181
1308
  return !1;
1182
- const s = t.slice(n + 4, r), i = Q(s);
1183
- if (i === "unclosed" || i === "mixed")
1309
+ const i = t.slice(n + 4, r), s = ee(i);
1310
+ if (s === "unclosed" || s === "mixed")
1184
1311
  return !0;
1185
1312
  e = r + 3;
1186
1313
  }
1187
1314
  return !1;
1188
1315
  }
1189
- function $e(t) {
1316
+ function Fe(t) {
1190
1317
  let e = 0;
1191
1318
  for (; e < t.length; ) {
1192
1319
  const n = t.indexOf("<!--", e);
1193
1320
  if (n === -1)
1194
1321
  return null;
1195
- if (te(t, n)) {
1322
+ if (ne(t, n)) {
1196
1323
  e = n + 4;
1197
1324
  continue;
1198
1325
  }
1199
1326
  const r = t.indexOf("-->", n + 4);
1200
1327
  if (r === -1)
1201
1328
  return null;
1202
- const s = t.slice(n + 4, r), i = Q(s);
1203
- if (i === "mixed")
1329
+ const i = t.slice(n + 4, r), s = ee(i);
1330
+ if (s === "mixed")
1204
1331
  return "mixed @hg and @@ markers are not allowed";
1205
- if (i === "unclosed")
1332
+ if (s === "unclosed")
1206
1333
  return "unclosed hyogen block (missing closing marker)";
1207
1334
  e = r + 3;
1208
1335
  }
1209
1336
  return null;
1210
1337
  }
1211
1338
  function A(t) {
1212
- return ee(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
1339
+ return te(t).trim().split(/\r?\n/).map((n) => n.trim()).filter((n) => n.length > 0);
1213
1340
  }
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());
1341
+ const Wt = /^(if\s+.+|else\s+if\s+.+|else|endif|each\s+[A-Za-z_$][A-Za-z0-9_$]*\s+in\s+.+|endeach)$/i;
1342
+ function je(t) {
1343
+ return Wt.test(t.trim());
1217
1344
  }
1218
- function V(t, e) {
1219
- throw u({
1345
+ function K(t, e) {
1346
+ throw d({
1220
1347
  code: "parse_error",
1221
1348
  path: t,
1222
1349
  details: { message: e }
1223
1350
  });
1224
1351
  }
1225
- function ft(t, e) {
1352
+ function $t(t, e) {
1226
1353
  let n = t;
1227
1354
  const r = /^<!--([\s\S]*?)-->$/.exec(t.trim());
1228
1355
  r && (n = r[1]);
1229
- const s = A(n);
1230
- if (s.length !== 1)
1356
+ const i = A(n);
1357
+ if (i.length !== 1)
1231
1358
  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))
1359
+ const s = i[0];
1360
+ 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
1361
  return null;
1235
- if (i === "else")
1362
+ if (s === "else")
1236
1363
  return { kind: "else" };
1237
- if (i === "endif")
1364
+ if (s === "endif")
1238
1365
  return { kind: "endif" };
1239
- if (i === "endeach")
1366
+ if (s === "endeach")
1240
1367
  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);
1368
+ if (/^IF\b/.test(s) || /^ELSE\b/.test(s) || /^ENDIF\b/.test(s))
1369
+ throw K(e, "control keywords must be lowercase");
1370
+ const o = /^else\s+if\s+(.+)$/.exec(s);
1244
1371
  if (o)
1245
1372
  return {
1246
1373
  kind: "else_if",
1247
- expr: C(o[1], e)
1374
+ expr: W(o[1], e)
1248
1375
  };
1249
- const a = /^if\s+(.+)$/.exec(i);
1376
+ const a = /^if\s+(.+)$/.exec(s);
1250
1377
  if (a)
1251
1378
  return {
1252
1379
  kind: "if",
1253
- expr: C(a[1], e)
1380
+ expr: W(a[1], e)
1254
1381
  };
1255
- const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(i);
1382
+ const c = /^each\s+([A-Za-z_$][A-Za-z0-9_$]*)\s+in\s+(.+)$/.exec(s);
1256
1383
  if (c)
1257
1384
  return {
1258
1385
  kind: "each",
1259
1386
  item: c[1],
1260
- expr: C(c[2], e)
1387
+ expr: W(c[2], e)
1261
1388
  };
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");
1389
+ if (s === "if")
1390
+ throw K(e, "if requires an expression");
1391
+ if (/^each\s+/.test(s))
1392
+ throw K(e, "invalid each directive");
1266
1393
  return null;
1267
1394
  }
1268
- function O(t) {
1395
+ function R(t) {
1269
1396
  return { start: t.start, end: t.end, raw: t.raw };
1270
1397
  }
1271
- function W(t, e) {
1272
- throw u({
1398
+ function $(t, e) {
1399
+ throw d({
1273
1400
  code: "parse_error",
1274
1401
  path: t,
1275
1402
  details: { message: e }
1276
1403
  });
1277
1404
  }
1278
- function pt(t, e) {
1405
+ function At(t, e) {
1279
1406
  const n = [];
1280
1407
  for (const r of E(t)) {
1281
- const s = ft(r.inner, e);
1282
- s && n.push({
1408
+ const i = $t(r.inner, e);
1409
+ i && n.push({
1283
1410
  start: r.start,
1284
1411
  end: r.end,
1285
1412
  raw: r.raw,
1286
- opener: s
1413
+ opener: i
1287
1414
  });
1288
1415
  }
1289
1416
  return n;
1290
1417
  }
1291
- function Te(t) {
1418
+ function Pe(t) {
1292
1419
  return t.kind === "if" || t.kind === "each";
1293
1420
  }
1294
- function mt(t, e) {
1295
- const n = pt(t, e);
1421
+ function Et(t, e) {
1422
+ const n = At(t, e);
1296
1423
  if (n.length === 0)
1297
1424
  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");
1425
+ const { nodes: r, nextIndex: i } = F(t, n, 0, n.length, e);
1426
+ if (i < n.length) {
1427
+ const s = n[i];
1428
+ if (s.opener.kind === "endif")
1429
+ throw $(e, "endif without matching if");
1430
+ if (s.opener.kind === "endeach")
1431
+ throw $(e, "endeach without matching each");
1432
+ if (s.opener.kind === "else" || s.opener.kind === "else_if")
1433
+ throw $(e, "else without matching if");
1307
1434
  }
1308
1435
  return r;
1309
1436
  }
1310
- function B(t, e, n, r, s, i = 0, o) {
1437
+ function F(t, e, n, r, i, s = 0, o) {
1311
1438
  const a = o ?? t.length, c = [];
1312
- let h = i, l = n;
1439
+ let h = s, l = n;
1313
1440
  for (; l < r; ) {
1314
- const d = e[l];
1315
- if (d.start >= a)
1441
+ const u = e[l];
1442
+ if (u.start >= a)
1316
1443
  break;
1317
- if (d.end <= i) {
1444
+ if (u.end <= s) {
1318
1445
  l++;
1319
1446
  continue;
1320
1447
  }
1321
- if (d.start > h && c.push({
1448
+ if (u.start > h && c.push({
1322
1449
  kind: "text",
1323
- content: t.slice(h, d.start)
1324
- }), d.opener.kind === "if") {
1325
- const f = gt(t, e, l, r, s);
1450
+ content: t.slice(h, u.start)
1451
+ }), u.opener.kind === "if") {
1452
+ const f = Tt(t, e, l, r, i);
1326
1453
  c.push(f.node), h = f.endPos, l = f.nextIndex;
1327
1454
  continue;
1328
1455
  }
1329
- if (d.opener.kind === "each") {
1330
- const f = xt(t, e, l, r, s);
1456
+ if (u.opener.kind === "each") {
1457
+ const f = Lt(t, e, l, r, i);
1331
1458
  c.push(f.node), h = f.endPos, l = f.nextIndex;
1332
1459
  continue;
1333
1460
  }
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");
1461
+ if (u.opener.kind === "else" || u.opener.kind === "else_if")
1462
+ throw $(i, "else without matching if");
1463
+ if (u.opener.kind === "endif")
1464
+ throw $(i, "endif without matching if");
1465
+ if (u.opener.kind === "endeach")
1466
+ throw $(i, "endeach without matching each");
1340
1467
  l++;
1341
1468
  }
1342
1469
  return h < a && c.push({ kind: "text", content: t.slice(h, a) }), { nodes: c, nextIndex: l };
1343
1470
  }
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");
1471
+ function Tt(t, e, n, r, i) {
1472
+ const s = e[n];
1473
+ if (s.opener.kind !== "if")
1474
+ throw $(i, "expected if");
1348
1475
  const o = [];
1349
- let a = n, c = i.end, h = 0;
1476
+ let a = n, c = s.end, h = 0;
1350
1477
  for (; a < r; ) {
1351
1478
  const l = e[a];
1352
1479
  if (a === n) {
1353
1480
  if (l.opener.kind !== "if")
1354
- throw W(s, "expected if");
1481
+ throw $(i, "expected if");
1355
1482
  o.push({
1356
1483
  kind: "if",
1357
1484
  expr: l.opener.expr,
1358
- opener: O(l),
1485
+ opener: R(l),
1359
1486
  body: []
1360
1487
  }), a++;
1361
1488
  continue;
1362
1489
  }
1363
- if (Te(l.opener)) {
1490
+ if (Pe(l.opener)) {
1364
1491
  h++, a++;
1365
1492
  continue;
1366
1493
  }
1367
1494
  if (l.opener.kind === "endif") {
1368
1495
  if (h === 0)
1369
- return o[o.length - 1].body = B(
1496
+ return o[o.length - 1].body = F(
1370
1497
  t,
1371
1498
  e,
1372
1499
  n + 1,
1373
1500
  a,
1374
- s,
1501
+ i,
1375
1502
  c,
1376
1503
  l.start
1377
1504
  ).nodes, {
1378
- node: { kind: "if", branches: o, closer: O(l) },
1505
+ node: { kind: "if", branches: o, closer: R(l) },
1379
1506
  nextIndex: a + 1,
1380
1507
  endPos: l.end
1381
1508
  };
@@ -1388,34 +1515,34 @@ function gt(t, e, n, r, s) {
1388
1515
  }
1389
1516
  if (h === 0) {
1390
1517
  if (l.opener.kind === "else_if") {
1391
- o[o.length - 1].body = B(
1518
+ o[o.length - 1].body = F(
1392
1519
  t,
1393
1520
  e,
1394
1521
  n + 1,
1395
1522
  a,
1396
- s,
1523
+ i,
1397
1524
  c,
1398
1525
  l.start
1399
1526
  ).nodes, o.push({
1400
1527
  kind: "else_if",
1401
1528
  expr: l.opener.expr,
1402
- opener: O(l),
1529
+ opener: R(l),
1403
1530
  body: []
1404
1531
  }), c = l.end, a++;
1405
1532
  continue;
1406
1533
  }
1407
1534
  if (l.opener.kind === "else") {
1408
- o[o.length - 1].body = B(
1535
+ o[o.length - 1].body = F(
1409
1536
  t,
1410
1537
  e,
1411
1538
  n + 1,
1412
1539
  a,
1413
- s,
1540
+ i,
1414
1541
  c,
1415
1542
  l.start
1416
1543
  ).nodes, o.push({
1417
1544
  kind: "else",
1418
- opener: O(l),
1545
+ opener: R(l),
1419
1546
  body: []
1420
1547
  }), c = l.end, a++;
1421
1548
  continue;
@@ -1423,40 +1550,40 @@ function gt(t, e, n, r, s) {
1423
1550
  }
1424
1551
  a++;
1425
1552
  }
1426
- throw W(s, "unclosed if block (missing endif)");
1553
+ throw $(i, "unclosed if block (missing endif)");
1427
1554
  }
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");
1555
+ function Lt(t, e, n, r, i) {
1556
+ const s = e[n];
1557
+ if (s.opener.kind !== "each")
1558
+ throw $(i, "expected each");
1432
1559
  let o = n + 1;
1433
- const a = i.end;
1560
+ const a = s.end;
1434
1561
  let c = 0;
1435
1562
  for (; o < r; ) {
1436
1563
  const h = e[o];
1437
- if (Te(h.opener)) {
1564
+ if (Pe(h.opener)) {
1438
1565
  c++, o++;
1439
1566
  continue;
1440
1567
  }
1441
1568
  if (h.opener.kind === "endeach") {
1442
1569
  if (c === 0) {
1443
- const l = B(
1570
+ const l = F(
1444
1571
  t,
1445
1572
  e,
1446
1573
  n + 1,
1447
1574
  o,
1448
- s,
1575
+ i,
1449
1576
  a,
1450
1577
  h.start
1451
1578
  ).nodes;
1452
1579
  return {
1453
1580
  node: {
1454
1581
  kind: "each",
1455
- item: i.opener.item,
1456
- expr: i.opener.expr,
1457
- opener: O(i),
1582
+ item: s.opener.item,
1583
+ expr: s.opener.expr,
1584
+ opener: R(s),
1458
1585
  body: l,
1459
- closer: O(h)
1586
+ closer: R(h)
1460
1587
  },
1461
1588
  nextIndex: o + 1,
1462
1589
  endPos: h.end
@@ -1471,28 +1598,28 @@ function xt(t, e, n, r, s) {
1471
1598
  }
1472
1599
  o++;
1473
1600
  }
1474
- throw W(s, "unclosed each block (missing endeach)");
1601
+ throw $(i, "unclosed each block (missing endeach)");
1475
1602
  }
1476
- const pe = 20;
1477
- class wt {
1603
+ const ge = 20;
1604
+ class Mt {
1478
1605
  depth = 0;
1479
1606
  get currentDepth() {
1480
1607
  return this.depth;
1481
1608
  }
1482
1609
  enter() {
1483
- return this.depth >= pe ? { exceeded: !0, limit: pe } : (this.depth++, { exceeded: !1, depth: this.depth });
1610
+ return this.depth >= ge ? { exceeded: !0, limit: ge } : (this.depth++, { exceeded: !1, depth: this.depth });
1484
1611
  }
1485
1612
  exit() {
1486
1613
  this.depth > 0 && this.depth--;
1487
1614
  }
1488
1615
  }
1489
- function kt(t) {
1616
+ function Ot(t) {
1490
1617
  return !!t;
1491
1618
  }
1492
- function bt(t) {
1619
+ function Rt(t) {
1493
1620
  return t != null && typeof t[Symbol.iterator] == "function";
1494
1621
  }
1495
- function Le(t) {
1622
+ function Ie(t) {
1496
1623
  return {
1497
1624
  code: "nest_limit_exceeded",
1498
1625
  message: "structure nest limit exceeded",
@@ -1500,49 +1627,49 @@ function Le(t) {
1500
1627
  details: { limit: 20 }
1501
1628
  };
1502
1629
  }
1503
- function ne(t) {
1630
+ function re(t) {
1504
1631
  return t.startsWith(`
1505
1632
  `) ? t.slice(1) : t;
1506
1633
  }
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);
1634
+ async function Ht(t, e) {
1635
+ const n = e.path, r = e.warnings ?? [], i = Et(t, n), s = new Mt();
1636
+ return ie(i, e, s, r);
1510
1637
  }
1511
- async function re(t, e, n, r) {
1512
- const s = e.preserveHgComments === !0;
1513
- let i = "", o = !1;
1638
+ async function ie(t, e, n, r) {
1639
+ const i = e.preserveHgComments === !0;
1640
+ let s = "", o = !1;
1514
1641
  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");
1642
+ let c = await Dt(a, e, n, r);
1643
+ o && (c = re(c)), s += c, o = !i && (a.kind === "if" || a.kind === "each");
1517
1644
  }
1518
- return i;
1645
+ return s;
1519
1646
  }
1520
- async function yt(t, e, n, r) {
1647
+ async function Dt(t, e, n, r) {
1521
1648
  switch (t.kind) {
1522
1649
  case "text":
1523
1650
  return t.content;
1524
1651
  case "if":
1525
- return _t(t, e, n, r);
1652
+ return Nt(t, e, n, r);
1526
1653
  case "each":
1527
- return St(t, e, n, r);
1654
+ return Bt(t, e, n, r);
1528
1655
  default:
1529
1656
  return "";
1530
1657
  }
1531
1658
  }
1532
- async function _t(t, e, n, r) {
1659
+ async function Nt(t, e, n, r) {
1533
1660
  if (n.enter().exceeded)
1534
- return r.push(Le(e.path)), "";
1661
+ return r.push(Ie(e.path)), "";
1535
1662
  try {
1536
- let i = -1;
1663
+ let s = -1;
1537
1664
  for (let c = 0; c < t.branches.length; c++) {
1538
1665
  const h = t.branches[c];
1539
1666
  if (h.kind === "else") {
1540
- i = c;
1667
+ s = c;
1541
1668
  break;
1542
1669
  }
1543
- const l = await k(h.expr, e);
1544
- if (kt(l)) {
1545
- i = c;
1670
+ const l = await w(h.expr, e);
1671
+ if (Ot(l)) {
1672
+ s = c;
1546
1673
  break;
1547
1674
  }
1548
1675
  }
@@ -1550,9 +1677,9 @@ async function _t(t, e, n, r) {
1550
1677
  let a = "";
1551
1678
  for (let c = 0; c < t.branches.length; c++) {
1552
1679
  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;
1680
+ if (o && (a += h.opener.raw), c === s) {
1681
+ let l = await ie(h.body, e, n, r);
1682
+ o || (l = re(l)), a += l;
1556
1683
  }
1557
1684
  }
1558
1685
  return o && (a += t.closer.raw), a;
@@ -1560,24 +1687,24 @@ async function _t(t, e, n, r) {
1560
1687
  n.exit();
1561
1688
  }
1562
1689
  }
1563
- async function St(t, e, n, r) {
1690
+ async function Bt(t, e, n, r) {
1564
1691
  if (n.enter().exceeded)
1565
- return r.push(Le(e.path)), "";
1692
+ return r.push(Ie(e.path)), "";
1566
1693
  try {
1567
- const i = await k(t.expr, e);
1568
- if (!bt(i))
1694
+ const s = await w(t.expr, e);
1695
+ if (!Rt(s))
1569
1696
  return "";
1570
1697
  const o = e.preserveHgComments === !0;
1571
1698
  let a = "";
1572
- for (const c of i) {
1699
+ for (const c of s) {
1573
1700
  const h = { ...e.context, [t.item]: c };
1574
1701
  o && (a += t.opener.raw);
1575
- let l = await re(t.body, {
1702
+ let l = await ie(t.body, {
1576
1703
  ...e,
1577
1704
  context: h
1578
1705
  }, n, r);
1579
- o || (l = ne(l));
1580
- const d = await We(l, h, {
1706
+ o || (l = re(l));
1707
+ const u = await Ne(l, h, {
1581
1708
  path: e.path,
1582
1709
  registry: e.registry,
1583
1710
  loader: e.loader,
@@ -1588,30 +1715,30 @@ async function St(t, e, n, r) {
1588
1715
  preserveHgComments: e.preserveHgComments,
1589
1716
  constrainToRoot: e.constrainToRoot
1590
1717
  });
1591
- a += d, o && (a += t.closer.raw);
1718
+ a += u, o && (a += t.closer.raw);
1592
1719
  }
1593
1720
  return a;
1594
1721
  } finally {
1595
1722
  n.exit();
1596
1723
  }
1597
1724
  }
1598
- function Y(t, e, n, r, s = !1, i = !1) {
1599
- return Se(e) ? e : Ce(e, {
1725
+ function X(t, e, n, r, i = !1, s = !1) {
1726
+ return We(e) ? e : $e(e, {
1600
1727
  rootDir: t,
1601
1728
  fromPath: r,
1602
1729
  documentPath: n,
1603
- constrainToRoot: s,
1604
- hyogenPath: i
1730
+ constrainToRoot: i,
1731
+ hyogenPath: s
1605
1732
  });
1606
1733
  }
1607
- function Me(t) {
1734
+ function ze(t) {
1608
1735
  let e = 0;
1609
1736
  for (let n = t.length - 1; n >= 0 && t[n] === `
1610
1737
  `; n--)
1611
1738
  e++;
1612
1739
  return e;
1613
1740
  }
1614
- function Oe(t) {
1741
+ function Ue(t) {
1615
1742
  let e = 0;
1616
1743
  for (; e < t.length && t[e] === `
1617
1744
  `; )
@@ -1619,25 +1746,25 @@ function Oe(t) {
1619
1746
  return e;
1620
1747
  }
1621
1748
  function T(t, e) {
1622
- const n = Me(t), r = Oe(e), s = Math.max(n, r);
1749
+ const n = ze(t), r = Ue(e), i = Math.max(n, r);
1623
1750
  return t.slice(0, t.length - n) + `
1624
- `.repeat(s) + e.slice(r);
1751
+ `.repeat(i) + e.slice(r);
1625
1752
  }
1626
- function ie(t, e) {
1627
- const n = Me(t), r = Oe(e);
1753
+ function se(t, e) {
1754
+ const n = ze(t), r = Ue(e);
1628
1755
  return n + r - Math.max(n, r);
1629
1756
  }
1630
- function me(t, e, n) {
1757
+ function xe(t, e, n) {
1631
1758
  const r = t.indexOf(e);
1632
1759
  if (r < 0)
1633
1760
  return t;
1634
- const s = t.slice(0, r), i = t.slice(r + e.length);
1635
- return T(T(s, n), i);
1761
+ const i = t.slice(0, r), s = t.slice(r + e.length);
1762
+ return T(T(i, n), s);
1636
1763
  }
1637
- async function Ct(t) {
1764
+ async function Ft(t) {
1638
1765
  let e = t.source;
1639
1766
  for (const n of t.directives) {
1640
- const r = Y(
1767
+ const r = X(
1641
1768
  t.root,
1642
1769
  n.path,
1643
1770
  t.path,
@@ -1646,28 +1773,28 @@ async function Ct(t) {
1646
1773
  !0
1647
1774
  );
1648
1775
  if (t.visitStack) {
1649
- const s = t.visitStack.check(r);
1650
- if (s.circular) {
1776
+ const i = t.visitStack.check(r);
1777
+ if (i.circular) {
1651
1778
  t.warnings?.push({
1652
1779
  code: "circular_include",
1653
- message: R("circular_include", {
1780
+ message: H("circular_include", {
1654
1781
  path: r,
1655
- from: s.from,
1782
+ from: i.from,
1656
1783
  via: "include"
1657
1784
  }),
1658
1785
  path: t.path,
1659
1786
  details: {
1660
1787
  path: r,
1661
- from: s.from,
1788
+ from: i.from,
1662
1789
  via: "include"
1663
1790
  }
1664
- }), e = me(e, n.marker, "");
1791
+ }), e = xe(e, n.marker, "");
1665
1792
  continue;
1666
1793
  }
1667
1794
  t.visitStack.push(r);
1668
1795
  }
1669
1796
  try {
1670
- const s = await t.loader(r), i = await fn(s, {
1797
+ const i = await t.loader(r), s = await $n(i, {
1671
1798
  context: t.context,
1672
1799
  loader: t.loader,
1673
1800
  root: t.root,
@@ -1677,16 +1804,16 @@ async function Ct(t) {
1677
1804
  visitStack: t.visitStack,
1678
1805
  warnings: t.warnings,
1679
1806
  registry: t.registry
1680
- }), o = t.preserveHgComments && n.raw ? `${n.raw}
1681
- ${i}` : i;
1682
- e = me(e, n.marker, o);
1807
+ }), 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}
1808
+ ${h}` : h;
1809
+ e = xe(e, n.marker, l);
1683
1810
  } finally {
1684
1811
  t.visitStack?.pop();
1685
1812
  }
1686
1813
  }
1687
1814
  return e;
1688
1815
  }
1689
- class Re {
1816
+ class Ze {
1690
1817
  stack = [];
1691
1818
  check(e) {
1692
1819
  return e.length === 0 ? { circular: !1 } : this.stack.indexOf(e) !== -1 ? {
@@ -1702,28 +1829,28 @@ class Re {
1702
1829
  this.stack.pop();
1703
1830
  }
1704
1831
  }
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 });
1832
+ async function jt(t, e, n = {}) {
1833
+ const { path: r, constBindings: i = /* @__PURE__ */ new Set() } = n, s = await w(t.expr, { context: e, path: r });
1707
1834
  switch (t.kind) {
1708
1835
  case "const": {
1709
- if (s.has(t.name))
1710
- throw u({
1836
+ if (i.has(t.name))
1837
+ throw d({
1711
1838
  code: "parse_error",
1712
1839
  path: r,
1713
1840
  details: {
1714
1841
  message: `cannot reassign const binding: ${t.name}`
1715
1842
  }
1716
1843
  });
1717
- e[t.name] = i, s.add(t.name);
1844
+ e[t.name] = s, i.add(t.name);
1718
1845
  break;
1719
1846
  }
1720
1847
  case "let": {
1721
- e[t.name] = i;
1848
+ e[t.name] = s;
1722
1849
  break;
1723
1850
  }
1724
1851
  case "assign": {
1725
- if (s.has(t.name))
1726
- throw u({
1852
+ if (i.has(t.name))
1853
+ throw d({
1727
1854
  code: "parse_error",
1728
1855
  path: r,
1729
1856
  details: {
@@ -1731,33 +1858,33 @@ async function Wt(t, e, n = {}) {
1731
1858
  }
1732
1859
  });
1733
1860
  if (!(t.name in e))
1734
- throw u({
1861
+ throw d({
1735
1862
  code: "parse_error",
1736
1863
  path: r,
1737
1864
  details: {
1738
1865
  message: `assignment to undeclared variable: ${t.name}`
1739
1866
  }
1740
1867
  });
1741
- e[t.name] = i;
1868
+ e[t.name] = s;
1742
1869
  break;
1743
1870
  }
1744
1871
  }
1745
1872
  }
1746
- function ge(t) {
1873
+ function ke(t) {
1747
1874
  return !t;
1748
1875
  }
1749
- async function N(t, e, n = {}) {
1750
- const { path: r, constBindings: s = /* @__PURE__ */ new Set(), onUpdate: i, echoChunks: o } = n;
1876
+ async function B(t, e, n = {}) {
1877
+ const { path: r, constBindings: i = /* @__PURE__ */ new Set(), onUpdate: s, echoChunks: o } = n;
1751
1878
  switch (t.kind) {
1752
1879
  case "const":
1753
1880
  case "let":
1754
1881
  case "assign": {
1755
- await Wt(t, e, { path: r, constBindings: s }), i?.(t.name);
1882
+ await jt(t, e, { path: r, constBindings: i }), s?.(t.name);
1756
1883
  return;
1757
1884
  }
1758
1885
  case "update": {
1759
- if (s.has(t.name))
1760
- throw u({
1886
+ if (i.has(t.name))
1887
+ throw d({
1761
1888
  code: "parse_error",
1762
1889
  path: r,
1763
1890
  details: {
@@ -1765,7 +1892,7 @@ async function N(t, e, n = {}) {
1765
1892
  }
1766
1893
  });
1767
1894
  if (!(t.name in e))
1768
- throw u({
1895
+ throw d({
1769
1896
  code: "parse_error",
1770
1897
  path: r,
1771
1898
  details: {
@@ -1773,12 +1900,12 @@ async function N(t, e, n = {}) {
1773
1900
  }
1774
1901
  });
1775
1902
  const a = Number(e[t.name]), c = t.op === "++" ? a + 1 : a - 1;
1776
- e[t.name] = c, i?.(t.name);
1903
+ e[t.name] = c, s?.(t.name);
1777
1904
  return;
1778
1905
  }
1779
1906
  case "compound_assign": {
1780
- if (s.has(t.name))
1781
- throw u({
1907
+ if (i.has(t.name))
1908
+ throw d({
1782
1909
  code: "parse_error",
1783
1910
  path: r,
1784
1911
  details: {
@@ -1786,14 +1913,14 @@ async function N(t, e, n = {}) {
1786
1913
  }
1787
1914
  });
1788
1915
  if (!(t.name in e))
1789
- throw u({
1916
+ throw d({
1790
1917
  code: "parse_error",
1791
1918
  path: r,
1792
1919
  details: {
1793
1920
  message: `assignment to undeclared variable: ${t.name}`
1794
1921
  }
1795
1922
  });
1796
- const a = await k(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
1923
+ const a = await w(t.expr, { context: e, path: r }), c = Number(e[t.name]), h = Number(a);
1797
1924
  let l;
1798
1925
  switch (t.op) {
1799
1926
  case "+=":
@@ -1809,11 +1936,11 @@ async function N(t, e, n = {}) {
1809
1936
  l = c / h;
1810
1937
  break;
1811
1938
  }
1812
- e[t.name] = l, i?.(t.name);
1939
+ e[t.name] = l, s?.(t.name);
1813
1940
  return;
1814
1941
  }
1815
1942
  case "echo": {
1816
- const a = await k(t.expr, {
1943
+ const a = await w(t.expr, {
1817
1944
  context: e,
1818
1945
  path: r
1819
1946
  }), c = a == null ? "" : String(a);
@@ -1821,39 +1948,39 @@ async function N(t, e, n = {}) {
1821
1948
  return;
1822
1949
  }
1823
1950
  case "for": {
1824
- for (t.init && await N(t.init, e, n); ; ) {
1825
- const a = await k(t.cond, {
1951
+ for (t.init && await B(t.init, e, n); ; ) {
1952
+ const a = await w(t.cond, {
1826
1953
  context: e,
1827
1954
  path: r
1828
1955
  });
1829
- if (ge(a))
1956
+ if (ke(a))
1830
1957
  break;
1831
1958
  for (const c of t.body)
1832
- await N(c, e, n);
1833
- t.update && await N(t.update, e, n);
1959
+ await B(c, e, n);
1960
+ t.update && await B(t.update, e, n);
1834
1961
  }
1835
1962
  return;
1836
1963
  }
1837
1964
  case "do_while": {
1838
1965
  do {
1839
1966
  for (const c of t.body)
1840
- await N(c, e, n);
1841
- const a = await k(t.cond, {
1967
+ await B(c, e, n);
1968
+ const a = await w(t.cond, {
1842
1969
  context: e,
1843
1970
  path: r
1844
1971
  });
1845
- if (ge(a))
1972
+ if (ke(a))
1846
1973
  break;
1847
1974
  } while (!0);
1848
1975
  return;
1849
1976
  }
1850
1977
  }
1851
1978
  }
1852
- async function xe(t, e, n = {}) {
1979
+ async function we(t, e, n = {}) {
1853
1980
  for (const r of t)
1854
- await N(r, e, n);
1981
+ await B(r, e, n);
1855
1982
  }
1856
- const At = /* @__PURE__ */ new Set([
1983
+ const Pt = /* @__PURE__ */ new Set([
1857
1984
  "if",
1858
1985
  "else",
1859
1986
  "endif",
@@ -1872,23 +1999,23 @@ const At = /* @__PURE__ */ new Set([
1872
1999
  "as",
1873
2000
  "echo"
1874
2001
  ]);
1875
- function De(t) {
1876
- return At.has(t);
2002
+ function qe(t) {
2003
+ return Pt.has(t);
1877
2004
  }
1878
- function se(t) {
2005
+ function oe(t) {
1879
2006
  let e = "", n = 0, r = null;
1880
2007
  for (; n < t.length; ) {
1881
- const s = t[n];
2008
+ const i = t[n];
1882
2009
  if (r) {
1883
- if (e += s, s === "\\" && n + 1 < t.length) {
2010
+ if (e += i, i === "\\" && n + 1 < t.length) {
1884
2011
  e += t[++n], n++;
1885
2012
  continue;
1886
2013
  }
1887
- s === r && (r = null), n++;
2014
+ i === r && (r = null), n++;
1888
2015
  continue;
1889
2016
  }
1890
- if (s === '"' || s === "'" || s === "`") {
1891
- r = s, e += s, n++;
2017
+ if (i === '"' || i === "'" || i === "`") {
2018
+ r = i, e += i, n++;
1892
2019
  continue;
1893
2020
  }
1894
2021
  if (t.startsWith("//", n)) {
@@ -1898,42 +2025,42 @@ function se(t) {
1898
2025
  continue;
1899
2026
  }
1900
2027
  if (t.startsWith("/*", n)) {
1901
- const i = t.indexOf("*/", n + 2);
1902
- if (i === -1)
2028
+ const s = t.indexOf("*/", n + 2);
2029
+ if (s === -1)
1903
2030
  break;
1904
- n = i + 2;
2031
+ n = s + 2;
1905
2032
  continue;
1906
2033
  }
1907
- e += s, n++;
2034
+ e += i, n++;
1908
2035
  }
1909
2036
  return e;
1910
2037
  }
1911
- function w(t, e) {
1912
- throw u({
2038
+ function k(t, e) {
2039
+ throw d({
1913
2040
  code: "parse_error",
1914
2041
  path: t,
1915
2042
  details: { message: e }
1916
2043
  });
1917
2044
  }
1918
- function we(t, e) {
1919
- const n = se(t).trim();
2045
+ function ve(t, e) {
2046
+ const n = oe(t).trim();
1920
2047
  if (n.length === 0)
1921
- throw w(e, "empty statement block");
1922
- const r = new oe(n, e), s = r.parseStatementList();
2048
+ throw k(e, "empty statement block");
2049
+ const r = new ae(n, e), i = r.parseStatementList();
1923
2050
  if (r.skipWhitespace(), r.hasMore())
1924
- throw w(
2051
+ throw k(
1925
2052
  e,
1926
2053
  `unexpected token at position ${r.position}`
1927
2054
  );
1928
- if (s.length === 0)
1929
- throw w(e, "empty statement block");
1930
- return s;
2055
+ if (i.length === 0)
2056
+ throw k(e, "empty statement block");
2057
+ return i;
1931
2058
  }
1932
- function He(t) {
1933
- const e = se(t).trim();
2059
+ function Ve(t) {
2060
+ const e = oe(t).trim();
1934
2061
  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
2062
  }
1936
- class oe {
2063
+ class ae {
1937
2064
  constructor(e, n) {
1938
2065
  this.input = e, this.path = n;
1939
2066
  }
@@ -1962,7 +2089,7 @@ class oe {
1962
2089
  if (this.matchWord("do"))
1963
2090
  return this.parseDoWhile();
1964
2091
  if (this.matchWord("while"))
1965
- throw w(
2092
+ throw k(
1966
2093
  this.path,
1967
2094
  "bare while loops are not allowed (use do…while)"
1968
2095
  );
@@ -1979,46 +2106,46 @@ class oe {
1979
2106
  return this.parseBindingDeclaration("let");
1980
2107
  const n = this.readIdentifier();
1981
2108
  if (!n)
1982
- throw w(this.path, "expected statement");
2109
+ throw k(this.path, "expected statement");
1983
2110
  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" };
2111
+ const i = this.input.slice(this.index - 2, this.index);
2112
+ return { kind: "update", name: n, op: i, position: "postfix" };
1986
2113
  }
1987
2114
  const r = this.readCompoundOp();
1988
2115
  if (r) {
1989
- const s = this.readExpressionSourceUntilTerminator();
2116
+ const i = this.readExpressionSourceUntilTerminator();
1990
2117
  return {
1991
2118
  kind: "compound_assign",
1992
2119
  name: n,
1993
2120
  op: r,
1994
- expr: C(s, this.path)
2121
+ expr: W(i, this.path)
1995
2122
  };
1996
2123
  }
1997
2124
  if (this.match("=")) {
1998
2125
  if (this.peek() === "=")
1999
- throw w(this.path, "unexpected '==' in assignment");
2000
- const s = this.readExpressionSourceUntilTerminator();
2126
+ throw k(this.path, "unexpected '==' in assignment");
2127
+ const i = this.readExpressionSourceUntilTerminator();
2001
2128
  return {
2002
2129
  kind: "assign",
2003
2130
  name: n,
2004
- expr: C(s, this.path)
2131
+ expr: W(i, this.path)
2005
2132
  };
2006
2133
  }
2007
- throw w(this.path, `invalid statement starting with: ${n}`);
2134
+ throw k(this.path, `invalid statement starting with: ${n}`);
2008
2135
  }
2009
2136
  parseEcho() {
2010
2137
  this.skipWhitespace();
2011
2138
  const e = this.readExpressionSourceUntilTerminator();
2012
2139
  return {
2013
2140
  kind: "echo",
2014
- expr: C(e, this.path)
2141
+ expr: W(e, this.path)
2015
2142
  };
2016
2143
  }
2017
2144
  readPrefixUpdate() {
2018
2145
  if (this.skipWhitespace(), this.match("++") || this.match("--")) {
2019
2146
  const e = this.input.slice(this.index - 2, this.index), n = this.readIdentifier();
2020
2147
  if (!n)
2021
- throw w(this.path, `expected identifier after ${e}`);
2148
+ throw k(this.path, `expected identifier after ${e}`);
2022
2149
  return this.assertAssignableName(n), { kind: "update", name: n, op: e, position: "prefix" };
2023
2150
  }
2024
2151
  return null;
@@ -2026,69 +2153,69 @@ class oe {
2026
2153
  parseBindingDeclaration(e) {
2027
2154
  const n = this.readIdentifier();
2028
2155
  if (!n)
2029
- throw w(this.path, `expected identifier after ${e}`);
2156
+ throw k(this.path, `expected identifier after ${e}`);
2030
2157
  if (this.assertAssignableName(n), this.skipWhitespace(), !this.match("="))
2031
- throw w(this.path, `expected '=' in ${e} declaration`);
2158
+ throw k(this.path, `expected '=' in ${e} declaration`);
2032
2159
  const r = this.readExpressionSourceUntilTerminator();
2033
2160
  return {
2034
2161
  kind: e,
2035
2162
  name: n,
2036
- expr: C(r, this.path)
2163
+ expr: W(r, this.path)
2037
2164
  };
2038
2165
  }
2039
2166
  parseFor() {
2040
2167
  if (this.skipWhitespace(), !this.match("("))
2041
- throw w(this.path, "expected '(' after for");
2042
- const e = this.readBalanced(")"), n = $t(e);
2168
+ throw k(this.path, "expected '(' after for");
2169
+ const e = this.readBalanced(")"), n = It(e);
2043
2170
  if (n.length !== 3)
2044
- throw w(
2171
+ throw k(
2045
2172
  this.path,
2046
2173
  "for…of / for…in are not allowed; use for (init; cond; update)"
2047
2174
  );
2048
- const [r, s, i] = n;
2049
- if (s.trim().length === 0)
2050
- throw w(this.path, "for loop condition cannot be empty");
2175
+ const [r, i, s] = n;
2176
+ if (i.trim().length === 0)
2177
+ throw k(this.path, "for loop condition cannot be empty");
2051
2178
  if (/^\s*[A-Za-z_$][A-Za-z0-9_$]*\s+(of|in)\s+/.test(r))
2052
- throw w(
2179
+ throw k(
2053
2180
  this.path,
2054
2181
  "for…of / for…in are not allowed; use for (init; cond; update)"
2055
2182
  );
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());
2183
+ const o = r.trim().length === 0 ? null : this.parseClauseStatement(r.trim()), a = W(i.trim(), this.path), c = s.trim().length === 0 ? null : this.parseClauseStatement(s.trim());
2057
2184
  if (this.skipWhitespace(), !this.match("{"))
2058
- throw w(this.path, "expected '{' after for (...)");
2185
+ throw k(this.path, "expected '{' after for (...)");
2059
2186
  const h = this.parseStatementList();
2060
2187
  if (this.skipWhitespace(), !this.match("}"))
2061
- throw w(this.path, "expected '}' to close for body");
2188
+ throw k(this.path, "expected '}' to close for body");
2062
2189
  return { kind: "for", init: o, cond: a, update: c, body: h };
2063
2190
  }
2064
2191
  parseDoWhile() {
2065
2192
  if (this.skipWhitespace(), !this.match("{"))
2066
- throw w(this.path, "expected '{' after do");
2193
+ throw k(this.path, "expected '{' after do");
2067
2194
  const e = this.parseStatementList();
2068
2195
  if (this.skipWhitespace(), !this.match("}"))
2069
- throw w(this.path, "expected '}' to close do body");
2196
+ throw k(this.path, "expected '}' to close do body");
2070
2197
  if (this.skipWhitespace(), !this.matchWord("while"))
2071
- throw w(this.path, "expected 'while' after do body");
2198
+ throw k(this.path, "expected 'while' after do body");
2072
2199
  if (this.skipWhitespace(), !this.match("("))
2073
- throw w(this.path, "expected '(' after while");
2200
+ throw k(this.path, "expected '(' after while");
2074
2201
  const n = this.readBalanced(")");
2075
2202
  if (n.trim().length === 0)
2076
- throw w(this.path, "do…while condition cannot be empty");
2077
- const r = C(n.trim(), this.path);
2203
+ throw k(this.path, "do…while condition cannot be empty");
2204
+ const r = W(n.trim(), this.path);
2078
2205
  return { kind: "do_while", body: e, cond: r };
2079
2206
  }
2080
2207
  parseClauseStatement(e) {
2081
- const n = new oe(e, this.path), r = n.parseSimpleStatement();
2208
+ const n = new ae(e, this.path), r = n.parseSimpleStatement();
2082
2209
  if (n.skipWhitespace(), n.hasMore())
2083
- throw w(
2210
+ throw k(
2084
2211
  this.path,
2085
2212
  `unexpected token in for clause at position ${n.position}`
2086
2213
  );
2087
2214
  return r;
2088
2215
  }
2089
2216
  assertAssignableName(e) {
2090
- if (De(e))
2091
- throw w(
2217
+ if (qe(e))
2218
+ throw k(
2092
2219
  this.path,
2093
2220
  `reserved word cannot be used as identifier: ${e}`
2094
2221
  );
@@ -2096,53 +2223,53 @@ class oe {
2096
2223
  readExpressionSourceUntilTerminator() {
2097
2224
  this.skipWhitespace();
2098
2225
  const e = this.index;
2099
- let n = 0, r = 0, s = 0, i = null;
2226
+ let n = 0, r = 0, i = 0, s = null;
2100
2227
  for (; this.index < this.input.length; ) {
2101
2228
  const a = this.input[this.index];
2102
- if (i) {
2229
+ if (s) {
2103
2230
  if (a === "\\") {
2104
2231
  this.index += 2;
2105
2232
  continue;
2106
2233
  }
2107
- a === i && (i = null), this.index++;
2234
+ a === s && (s = null), this.index++;
2108
2235
  continue;
2109
2236
  }
2110
2237
  if (a === '"' || a === "'" || a === "`") {
2111
- i = a, this.index++;
2238
+ s = a, this.index++;
2112
2239
  continue;
2113
2240
  }
2114
2241
  if (a === "(" && n++, a === ")" && (n = Math.max(0, n - 1)), a === "{" && r++, a === "}") {
2115
- if (r === 0 && n === 0 && s === 0)
2242
+ if (r === 0 && n === 0 && i === 0)
2116
2243
  break;
2117
2244
  r = Math.max(0, r - 1);
2118
2245
  }
2119
- if (a === "[" && s++, a === "]" && (s = Math.max(0, s - 1)), (a === ";" || a === `
2120
- `) && n === 0 && r === 0 && s === 0)
2246
+ if (a === "[" && i++, a === "]" && (i = Math.max(0, i - 1)), (a === ";" || a === `
2247
+ `) && n === 0 && r === 0 && i === 0)
2121
2248
  break;
2122
2249
  this.index++;
2123
2250
  }
2124
2251
  const o = this.input.slice(e, this.index).trim();
2125
2252
  if (o.length === 0)
2126
- throw w(this.path, "expected expression");
2253
+ throw k(this.path, "expected expression");
2127
2254
  return o;
2128
2255
  }
2129
2256
  readBalanced(e) {
2130
2257
  const n = e === ")" ? "(" : "{";
2131
2258
  let r = 1;
2132
- const s = this.index;
2133
- let i = null;
2259
+ const i = this.index;
2260
+ let s = null;
2134
2261
  for (; this.index < this.input.length; ) {
2135
2262
  const o = this.input[this.index];
2136
- if (i) {
2263
+ if (s) {
2137
2264
  if (o === "\\") {
2138
2265
  this.index += 2;
2139
2266
  continue;
2140
2267
  }
2141
- o === i && (i = null), this.index++;
2268
+ o === s && (s = null), this.index++;
2142
2269
  continue;
2143
2270
  }
2144
2271
  if (o === '"' || o === "'" || o === "`") {
2145
- i = o, this.index++;
2272
+ s = o, this.index++;
2146
2273
  continue;
2147
2274
  }
2148
2275
  if (o === n) {
@@ -2151,7 +2278,7 @@ class oe {
2151
2278
  }
2152
2279
  if (o === e) {
2153
2280
  if (r--, r === 0) {
2154
- const a = this.input.slice(s, this.index);
2281
+ const a = this.input.slice(i, this.index);
2155
2282
  return this.index++, a;
2156
2283
  }
2157
2284
  this.index++;
@@ -2159,7 +2286,7 @@ class oe {
2159
2286
  }
2160
2287
  this.index++;
2161
2288
  }
2162
- throw w(this.path, `expected '${e}'`);
2289
+ throw k(this.path, `expected '${e}'`);
2163
2290
  }
2164
2291
  readCompoundOp() {
2165
2292
  this.skipWhitespace();
@@ -2194,21 +2321,21 @@ class oe {
2194
2321
  return this.input.slice(e, this.index);
2195
2322
  }
2196
2323
  }
2197
- function $t(t) {
2324
+ function It(t) {
2198
2325
  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];
2326
+ let n = "", r = 0, i = null;
2327
+ for (let s = 0; s < t.length; s++) {
2328
+ const o = t[s];
2329
+ if (i) {
2330
+ if (n += o, o === "\\" && s + 1 < t.length) {
2331
+ n += t[++s];
2205
2332
  continue;
2206
2333
  }
2207
- o === s && (s = null);
2334
+ o === i && (i = null);
2208
2335
  continue;
2209
2336
  }
2210
2337
  if (o === '"' || o === "'" || o === "`") {
2211
- s = o, n += o;
2338
+ i = o, n += o;
2212
2339
  continue;
2213
2340
  }
2214
2341
  if (o === "(" || o === "[" || o === "{") {
@@ -2227,56 +2354,56 @@ function $t(t) {
2227
2354
  }
2228
2355
  return e.push(n), e;
2229
2356
  }
2230
- function ae(t, e) {
2357
+ function ce(t, e) {
2231
2358
  const n = t.trim();
2232
2359
  if (!/^extend\b/i.test(n)) return null;
2233
2360
  if (!/^extend\s+/i.test(n))
2234
- throw u({
2361
+ throw d({
2235
2362
  code: "parse_error",
2236
2363
  path: e,
2237
2364
  details: { message: "missing extend path" }
2238
2365
  });
2239
2366
  const r = /^extend\s+(\S+)\s*$/.exec(n);
2240
2367
  if (!r)
2241
- throw u({
2368
+ throw d({
2242
2369
  code: "parse_error",
2243
2370
  path: e,
2244
2371
  details: { message: "invalid extend directive" }
2245
2372
  });
2246
- const s = r[1];
2247
- if (s.length === 0)
2248
- throw u({
2373
+ const i = r[1];
2374
+ if (i.length === 0)
2375
+ throw d({
2249
2376
  code: "parse_error",
2250
2377
  path: e,
2251
2378
  details: { message: "invalid extend path" }
2252
2379
  });
2253
- return { path: s };
2380
+ return { path: i };
2254
2381
  }
2255
- function Et(t, e) {
2382
+ function zt(t, e) {
2256
2383
  const n = A(t);
2257
2384
  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({
2385
+ const r = n[0], i = ce(r, e);
2386
+ if (!i) return null;
2387
+ for (const s of n.slice(1))
2388
+ if (/^extend\s+/i.test(s))
2389
+ throw d({
2263
2390
  code: "parse_error",
2264
2391
  path: e,
2265
2392
  details: { message: "extend must be the first line of extend block" }
2266
2393
  });
2267
2394
  return {
2268
- path: s.path,
2395
+ path: i.path,
2269
2396
  declarationsSource: n.slice(1).join(`
2270
2397
  `)
2271
2398
  };
2272
2399
  }
2273
- function ce(t) {
2400
+ function le(t) {
2274
2401
  return /^toc(\(.*\))?$/.test(t.trim());
2275
2402
  }
2276
- function Tt(t, e) {
2403
+ function Ut(t, e) {
2277
2404
  const n = A(t);
2278
2405
  if (n.length !== 1)
2279
- throw u({
2406
+ throw d({
2280
2407
  code: "parse_error",
2281
2408
  path: e,
2282
2409
  details: {
@@ -2286,126 +2413,126 @@ function Tt(t, e) {
2286
2413
  const r = n[0];
2287
2414
  if (r === "toc")
2288
2415
  return { maxLevel: 6 };
2289
- const s = /^toc\((.*)\)$/.exec(r);
2290
- if (!s)
2291
- throw u({
2416
+ const i = /^toc\((.*)\)$/.exec(r);
2417
+ if (!i)
2418
+ throw d({
2292
2419
  code: "parse_error",
2293
2420
  path: e,
2294
2421
  details: { message: `invalid toc directive: ${r}` }
2295
2422
  });
2296
- const i = s[1];
2297
- if (!/^[1-6]$/.test(i))
2298
- throw u({
2423
+ const s = i[1];
2424
+ if (!/^[1-6]$/.test(s))
2425
+ throw d({
2299
2426
  code: "parse_error",
2300
2427
  path: e,
2301
2428
  details: {
2302
- message: `invalid toc max level: ${i || "(empty)"} (expected integer 1–6)`
2429
+ message: `invalid toc max level: ${s || "(empty)"} (expected integer 1–6)`
2303
2430
  }
2304
2431
  });
2305
- return { maxLevel: Number(i) };
2432
+ return { maxLevel: Number(s) };
2306
2433
  }
2307
- async function Lt(t, e = {}) {
2434
+ async function Zt(t, e = {}) {
2308
2435
  const n = e.path, r = e.context ?? {};
2309
- if (Ae(t))
2310
- throw u({
2436
+ if (Be(t))
2437
+ throw d({
2311
2438
  code: "parse_error",
2312
2439
  path: n,
2313
2440
  details: {
2314
- message: $e(t) ?? "unclosed hyogen block (missing closing marker)"
2441
+ message: Fe(t) ?? "unclosed hyogen block (missing closing marker)"
2315
2442
  }
2316
2443
  });
2317
- const s = E(t);
2318
- if (s.length === 0)
2444
+ const i = E(t);
2445
+ if (i.length === 0)
2319
2446
  return { source: t, context: r, declarationUpdates: {} };
2320
- const i = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
2447
+ const s = /* @__PURE__ */ new Set(), o = {}, a = (l) => {
2321
2448
  o[l] = r[l];
2322
2449
  };
2323
2450
  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]))
2451
+ for (const l of i) {
2452
+ const u = A(l.inner);
2453
+ if (u.length === 1 && je(u[0]) || u.length === 1 && le(u[0]) || u.length === 1 && /^include\s+/i.test(u[0]) || u.length === 1 && /^component\s+/i.test(u[0]))
2327
2454
  continue;
2328
- const f = Et(l.inner, n);
2455
+ const f = zt(l.inner, n);
2329
2456
  if (f) {
2330
2457
  if (f.declarationsSource.trim().length > 0) {
2331
- const H = we(
2458
+ const N = ve(
2332
2459
  f.declarationsSource,
2333
2460
  n
2334
2461
  );
2335
- await xe(H, r, {
2462
+ await we(N, r, {
2336
2463
  path: n,
2337
- constBindings: i,
2464
+ constBindings: s,
2338
2465
  onUpdate: a
2339
2466
  });
2340
2467
  }
2341
- const S = l.start - h, L = l.end - h, j = `<!--@hg
2468
+ const C = l.start - h, L = l.end - h, j = `<!--@hg
2342
2469
  extend ${f.path}
2343
2470
  @endhg-->`;
2344
- c = c.slice(0, S) + j + c.slice(L), h += l.raw.length - j.length;
2471
+ c = c.slice(0, C) + j + c.slice(L), h += l.raw.length - j.length;
2345
2472
  continue;
2346
2473
  }
2347
- const g = d.join(`
2474
+ const g = u.join(`
2348
2475
  `);
2349
- if (!He(g)) {
2350
- if (d.length === 1)
2476
+ if (!Ve(g)) {
2477
+ if (u.length === 1)
2351
2478
  continue;
2352
- throw u({
2479
+ throw d({
2353
2480
  code: "parse_error",
2354
2481
  path: n,
2355
- details: { message: `unsupported hyogen directive: ${d[0]}` }
2482
+ details: { message: `unsupported hyogen directive: ${u[0]}` }
2356
2483
  });
2357
2484
  }
2358
- const m = we(g, n), p = [];
2359
- await xe(m, r, {
2485
+ const m = ve(g, n), p = [];
2486
+ await we(m, r, {
2360
2487
  path: n,
2361
- constBindings: i,
2488
+ constBindings: s,
2362
2489
  onUpdate: a,
2363
2490
  echoChunks: p
2364
2491
  });
2365
- const $ = l.start - h, D = l.end - h, b = c.slice(0, $), v = c.slice(D);
2492
+ const S = l.start - h, D = l.end - h, v = c.slice(0, S), b = c.slice(D);
2366
2493
  if (p.length > 0) {
2367
- const S = p.join("");
2368
- c = b + S + v, h += l.raw.length - S.length;
2494
+ const C = p.join("");
2495
+ c = v + C + b, h += l.raw.length - C.length;
2369
2496
  } else
2370
- c = T(b, v), h += l.raw.length + ie(b, v);
2497
+ c = T(v, b), h += l.raw.length + se(v, b);
2371
2498
  }
2372
2499
  return { source: c, context: r, declarationUpdates: o };
2373
2500
  }
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();
2501
+ const qt = /^component\s+(\S+)\s+as\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*$/;
2502
+ function Vt(t, e) {
2503
+ const n = te(t).trim();
2377
2504
  if (n.length === 0)
2378
- throw u({
2505
+ throw d({
2379
2506
  code: "parse_error",
2380
2507
  path: e,
2381
2508
  details: { message: "empty hyogen block" }
2382
2509
  });
2383
2510
  const r = n.split(/\r?\n/).map((a) => a.trim()).filter((a) => a.length > 0);
2384
2511
  if (r.length !== 1)
2385
- throw u({
2512
+ throw d({
2386
2513
  code: "parse_error",
2387
2514
  path: e,
2388
2515
  details: {
2389
2516
  message: "hyogen block must contain a single component directive"
2390
2517
  }
2391
2518
  });
2392
- const s = r[0];
2393
- if (/^include\s+/i.test(s))
2394
- throw u({
2519
+ const i = r[0];
2520
+ if (/^include\s+/i.test(i))
2521
+ throw d({
2395
2522
  code: "parse_error",
2396
2523
  path: e,
2397
2524
  details: { message: "include and component cannot coexist in one block" }
2398
2525
  });
2399
- const i = Mt.exec(s);
2400
- if (!i)
2401
- throw u({
2526
+ const s = qt.exec(i);
2527
+ if (!s)
2528
+ throw d({
2402
2529
  code: "parse_error",
2403
2530
  path: e,
2404
- details: { message: `unsupported component directive: ${s}` }
2531
+ details: { message: `unsupported component directive: ${i}` }
2405
2532
  });
2406
- const o = i[1];
2533
+ const o = s[1];
2407
2534
  if (o.length === 0)
2408
- throw u({
2535
+ throw d({
2409
2536
  code: "parse_error",
2410
2537
  path: e,
2411
2538
  details: { message: "empty component path" }
@@ -2413,92 +2540,92 @@ function Ot(t, e) {
2413
2540
  return {
2414
2541
  kind: "component",
2415
2542
  path: o,
2416
- alias: i[2]
2543
+ alias: s[2]
2417
2544
  };
2418
2545
  }
2419
- function Rt(t, e) {
2420
- const n = ee(t).trim();
2546
+ function Kt(t, e) {
2547
+ const n = te(t).trim();
2421
2548
  if (n.length === 0)
2422
- throw u({
2549
+ throw d({
2423
2550
  code: "parse_error",
2424
2551
  path: e,
2425
2552
  details: { message: "empty hyogen block" }
2426
2553
  });
2427
2554
  const r = n.split(/\r?\n/).map((o) => o.trim()).filter((o) => o.length > 0);
2428
2555
  if (r.length !== 1)
2429
- throw u({
2556
+ throw d({
2430
2557
  code: "parse_error",
2431
2558
  path: e,
2432
2559
  details: { message: "hyogen block must contain a single include directive" }
2433
2560
  });
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({
2561
+ const i = r[0], s = /^include\s+(\S+)\s*$/.exec(i);
2562
+ if (s)
2563
+ return { kind: "include", path: s[1] };
2564
+ throw d({
2438
2565
  code: "parse_error",
2439
2566
  path: e,
2440
- details: { message: `unsupported hyogen directive: ${s}` }
2567
+ details: { message: `unsupported hyogen directive: ${i}` }
2441
2568
  });
2442
2569
  }
2443
- function Dt(t) {
2444
- const e = se(t).trim();
2570
+ function Yt(t) {
2571
+ const e = oe(t).trim();
2445
2572
  return e.length === 0 ? !1 : /^const\s+/.test(e) || /^let\s+/.test(e) || /^[A-Za-z_$][A-Za-z0-9_$]*\s*=/.test(e);
2446
2573
  }
2447
- const Ht = "\0HYOGEN_INCLUDE_";
2448
- function Nt(t) {
2449
- return `${Ht}${t}\0`;
2574
+ const Xt = "\0HYOGEN_INCLUDE_";
2575
+ function Gt(t) {
2576
+ return `${Xt}${t}\0`;
2450
2577
  }
2451
- function Bt(t, e) {
2578
+ function Jt(t, e) {
2452
2579
  const n = A(t);
2453
- if (n.length === 1 && Ee(n[0]))
2580
+ if (n.length === 1 && je(n[0]))
2454
2581
  return { kind: "control" };
2455
- if (n.length === 1 && ce(n[0]) || n.length === 1 && (Dt(n[0]) || He(n[0])))
2582
+ if (n.length === 1 && le(n[0]) || n.length === 1 && (Yt(n[0]) || Ve(n[0])))
2456
2583
  return null;
2457
2584
  if (n.length !== 1)
2458
- throw u({
2585
+ throw d({
2459
2586
  code: "parse_error",
2460
2587
  path: e,
2461
2588
  details: { message: "hyogen block must contain a single directive" }
2462
2589
  });
2463
2590
  const r = n[0];
2464
2591
  if (/^include\s+/i.test(r) && /\bcomponent\s+/i.test(r))
2465
- throw u({
2592
+ throw d({
2466
2593
  code: "parse_error",
2467
2594
  path: e,
2468
2595
  details: { message: "include and component cannot coexist in one block" }
2469
2596
  });
2470
2597
  if (/^include\s+/i.test(r))
2471
- return Rt(t, e);
2598
+ return Kt(t, e);
2472
2599
  if (/^component\s+/i.test(r))
2473
- return Ot(t, e);
2600
+ return Vt(t, e);
2474
2601
  if (r === "endblock" || /^block\s+/.test(r) || /^extend\s+/.test(r))
2475
2602
  return null;
2476
- throw u({
2603
+ throw d({
2477
2604
  code: "parse_error",
2478
2605
  path: e,
2479
2606
  details: { message: `unsupported hyogen directive: ${r}` }
2480
2607
  });
2481
2608
  }
2482
- function jt(t, e = {}) {
2609
+ function Qt(t, e = {}) {
2483
2610
  const n = e.path;
2484
- if (Ae(t))
2485
- throw u({
2611
+ if (Be(t))
2612
+ throw d({
2486
2613
  code: "parse_error",
2487
2614
  path: n,
2488
2615
  details: {
2489
- message: $e(t) ?? "unclosed hyogen block (missing closing marker)"
2616
+ message: Fe(t) ?? "unclosed hyogen block (missing closing marker)"
2490
2617
  }
2491
2618
  });
2492
2619
  const r = E(t);
2493
2620
  if (r.length === 0)
2494
2621
  return { source: t, directives: [] };
2495
- const s = [];
2496
- let i = t, o = 0, a = 0;
2622
+ const i = [];
2623
+ let s = t, o = 0, a = 0;
2497
2624
  for (const c of r) {
2498
- const h = Bt(c.inner, n);
2625
+ const h = Jt(c.inner, n);
2499
2626
  if (!h || h.kind === "control")
2500
2627
  continue;
2501
- const l = c.start - o, d = c.end - o;
2628
+ const l = c.start - o, u = c.end - o;
2502
2629
  if (h.kind === "component") {
2503
2630
  e.registry && e.registry.register(
2504
2631
  {
@@ -2509,74 +2636,74 @@ function jt(t, e = {}) {
2509
2636
  Object.keys(e.context ?? {}),
2510
2637
  n
2511
2638
  );
2512
- const g = i.slice(0, l), m = i.slice(d);
2513
- i = T(g, m), o += c.raw.length + ie(g, m);
2639
+ const g = s.slice(0, l), m = s.slice(u);
2640
+ s = T(g, m), o += c.raw.length + se(g, m);
2514
2641
  continue;
2515
2642
  }
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;
2643
+ const f = Gt(a++);
2644
+ i.push({ ...h, marker: f, raw: c.raw }), s = s.slice(0, l) + f + s.slice(u), o += c.raw.length - f.length;
2518
2645
  }
2519
- return { source: i, directives: s };
2646
+ return { source: s, directives: i };
2520
2647
  }
2521
- function Ft(t, e) {
2648
+ function en(t, e) {
2522
2649
  return !e.preserveFrontMatter || !e.rawFrontMatter ? t : t.length === 0 ? `${e.rawFrontMatter}
2523
2650
  ` : `${e.rawFrontMatter}
2524
2651
  ${t}`;
2525
2652
  }
2526
- function Pt(t, e = !1) {
2653
+ function tn(t, e = !1) {
2527
2654
  if (e)
2528
2655
  return t;
2529
2656
  const n = E(t);
2530
2657
  if (n.length === 0)
2531
2658
  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);
2659
+ let r = t, i = 0;
2660
+ for (const s of n) {
2661
+ const o = s.start - i, a = s.end - i, c = r.slice(0, o), h = r.slice(a);
2662
+ r = T(c, h), i += s.raw.length + se(c, h);
2536
2663
  }
2537
2664
  return r;
2538
2665
  }
2539
- const It = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
2540
- function zt(t, e) {
2666
+ const nn = /^block\s+([A-Za-z_$][A-Za-z0-9_$]*)$/;
2667
+ function rn(t, e) {
2541
2668
  const n = t.trim();
2542
2669
  if (n === "endblock")
2543
2670
  return { kind: "endblock" };
2544
- const r = It.exec(n);
2671
+ const r = nn.exec(n);
2545
2672
  if (!r)
2546
- throw u({
2673
+ throw d({
2547
2674
  code: "parse_error",
2548
2675
  path: e,
2549
2676
  details: { message: "invalid block directive" }
2550
2677
  });
2551
- const s = r[1];
2552
- if (De(s))
2553
- throw u({
2678
+ const i = r[1];
2679
+ if (qe(i))
2680
+ throw d({
2554
2681
  code: "parse_error",
2555
2682
  path: e,
2556
- details: { message: `reserved word cannot be used as block name: ${s}` }
2683
+ details: { message: `reserved word cannot be used as block name: ${i}` }
2557
2684
  });
2558
- return { kind: "block", name: s };
2685
+ return { kind: "block", name: i };
2559
2686
  }
2560
- function ke(t, e) {
2561
- const { path: n, mode: r, hasExtend: s = !1 } = e, i = E(t);
2562
- if (i.length === 0) return [];
2687
+ function be(t, e) {
2688
+ const { path: n, mode: r, hasExtend: i = !1 } = e, s = E(t);
2689
+ if (s.length === 0) return [];
2563
2690
  const o = [], a = [], c = /* @__PURE__ */ new Set();
2564
- for (const h of i) {
2691
+ for (const h of s) {
2565
2692
  const l = A(h.inner);
2566
2693
  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({
2694
+ const u = l[0];
2695
+ if (!(u === "endblock" || u.startsWith("block "))) continue;
2696
+ if (r === "child" && !i)
2697
+ throw d({
2571
2698
  code: "parse_error",
2572
2699
  path: n,
2573
2700
  details: { message: "orphan block without extend" }
2574
2701
  });
2575
- const g = zt(d, n);
2702
+ const g = rn(u, n);
2576
2703
  if (g.kind === "endblock") {
2577
2704
  const m = a.pop();
2578
2705
  if (!m)
2579
- throw u({
2706
+ throw d({
2580
2707
  code: "parse_error",
2581
2708
  path: n,
2582
2709
  details: { message: "endblock without matching block opener" }
@@ -2591,13 +2718,13 @@ function ke(t, e) {
2591
2718
  continue;
2592
2719
  }
2593
2720
  if (a.length > 0)
2594
- throw u({
2721
+ throw d({
2595
2722
  code: "parse_error",
2596
2723
  path: n,
2597
2724
  details: { message: "nested block structures are not supported" }
2598
2725
  });
2599
2726
  if (c.has(g.name))
2600
- throw u({
2727
+ throw d({
2601
2728
  code: "parse_error",
2602
2729
  path: n,
2603
2730
  details: { message: `duplicate block: ${g.name}` }
@@ -2609,44 +2736,44 @@ function ke(t, e) {
2609
2736
  });
2610
2737
  }
2611
2738
  if (a.length > 0)
2612
- throw u({
2739
+ throw d({
2613
2740
  code: "parse_error",
2614
2741
  path: n,
2615
2742
  details: { message: "missing endblock" }
2616
2743
  });
2617
2744
  return o;
2618
2745
  }
2619
- function be(t) {
2746
+ function ye(t) {
2620
2747
  const e = E(t), n = [];
2621
2748
  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 });
2749
+ const i = A(r.inner);
2750
+ if (i.length === 0) continue;
2751
+ const s = ce(i[0]);
2752
+ s && n.push({ path: s.path, start: r.start });
2626
2753
  }
2627
2754
  return n;
2628
2755
  }
2629
- function Ut(t) {
2756
+ function sn(t) {
2630
2757
  const e = E(t);
2631
2758
  for (const n of e) {
2632
2759
  const r = A(n.inner);
2633
2760
  if (r.length !== 1) continue;
2634
- const s = r[0];
2635
- if (s === "endblock" || s.startsWith("block ")) return !0;
2761
+ const i = r[0];
2762
+ if (i === "endblock" || i.startsWith("block ")) return !0;
2636
2763
  }
2637
2764
  return !1;
2638
2765
  }
2639
- function K(t) {
2766
+ function Y(t) {
2640
2767
  return t.map((e) => e.body).join("");
2641
2768
  }
2642
- function Zt(t, e, n) {
2643
- const r = [...e].sort((o, a) => o.start - a.start), s = [];
2644
- let i = 0;
2769
+ function on(t, e, n) {
2770
+ const r = [...e].sort((o, a) => o.start - a.start), i = [];
2771
+ let s = 0;
2645
2772
  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));
2773
+ i.push(t.slice(s, o.start)), i.push(n.get(o.name) ?? o.body), s = o.end;
2774
+ return i.push(t.slice(s)), i.reduce((o, a) => T(o, a));
2648
2775
  }
2649
- function qt(t) {
2776
+ function an(t) {
2650
2777
  if (t instanceof Error && "code" in t && "details" in t) {
2651
2778
  const e = t;
2652
2779
  if (e.code === "file_not_found" && e.details && e.details.via === "include")
@@ -2654,46 +2781,46 @@ function qt(t) {
2654
2781
  }
2655
2782
  return { errorToThrow: t, adjusted: !1 };
2656
2783
  }
2657
- async function Vt(t, e) {
2784
+ async function cn(t, e) {
2658
2785
  const {
2659
2786
  path: n,
2660
2787
  context: r,
2661
- declarationUpdates: s,
2662
- loader: i,
2788
+ declarationUpdates: i,
2789
+ loader: s,
2663
2790
  root: o,
2664
2791
  constrainToRoot: a,
2665
2792
  visitStack: c,
2666
2793
  warnings: h,
2667
2794
  inComponent: l = !1
2668
- } = e, d = be(t);
2669
- if (d.length === 0) {
2670
- if (Ut(t))
2671
- throw u({
2795
+ } = e, u = ye(t);
2796
+ if (u.length === 0) {
2797
+ if (sn(t))
2798
+ throw d({
2672
2799
  code: "parse_error",
2673
2800
  path: n,
2674
2801
  details: { message: "orphan block without extend" }
2675
2802
  });
2676
- return { source: t, context: _(r, s) };
2803
+ return { source: t, context: _(r, i) };
2677
2804
  }
2678
2805
  const g = E(t)[0];
2679
2806
  if (!g)
2680
- return { source: t, context: _(r, s) };
2681
- if (!i)
2807
+ return { source: t, context: _(r, i) };
2808
+ if (!s)
2682
2809
  throw new Error("loader is required when processing extend directives");
2683
2810
  const m = A(g.inner);
2684
- if (!(m.length > 0 ? ae(m[0]) : null))
2685
- throw u({
2811
+ if (!(m.length > 0 ? ce(m[0]) : null))
2812
+ throw d({
2686
2813
  code: "parse_error",
2687
2814
  path: n,
2688
2815
  details: { message: "extend must be the first hyogen block" }
2689
2816
  });
2690
- if (d.length > 1)
2691
- throw u({
2817
+ if (u.length > 1)
2818
+ throw d({
2692
2819
  code: "parse_error",
2693
2820
  path: n,
2694
2821
  details: { message: "multiple extend directives are not supported" }
2695
2822
  });
2696
- const $ = ke(t, {
2823
+ const S = be(t, {
2697
2824
  path: n,
2698
2825
  mode: "child",
2699
2826
  hasExtend: !0
@@ -2701,14 +2828,14 @@ async function Vt(t, e) {
2701
2828
  if (l)
2702
2829
  return h?.push({
2703
2830
  code: "extend_in_component",
2704
- message: R("extend_in_component", { path: n }),
2831
+ message: H("extend_in_component", { path: n }),
2705
2832
  path: n,
2706
2833
  details: { path: n }
2707
2834
  }), {
2708
- source: K($),
2709
- context: _(r, s)
2835
+ source: Y(S),
2836
+ context: _(r, i)
2710
2837
  };
2711
- const D = d[0].path, b = n, v = Y(
2838
+ const D = u[0].path, v = n, b = X(
2712
2839
  o,
2713
2840
  D,
2714
2841
  n,
@@ -2716,87 +2843,87 @@ async function Vt(t, e) {
2716
2843
  a,
2717
2844
  !0
2718
2845
  );
2719
- b && c.push(b);
2846
+ v && c.push(v);
2720
2847
  try {
2721
- const S = b ? c.check(v) : { circular: !1 };
2722
- if (S.circular)
2848
+ const C = v ? c.check(b) : { circular: !1 };
2849
+ if (C.circular)
2723
2850
  return h?.push({
2724
2851
  code: "circular_include",
2725
- message: R("circular_include", {
2726
- path: v,
2727
- from: S.from,
2852
+ message: H("circular_include", {
2853
+ path: b,
2854
+ from: C.from,
2728
2855
  via: "extend"
2729
2856
  }),
2730
2857
  path: n,
2731
- details: { path: v, from: S.from, via: "extend" }
2858
+ details: { path: b, from: C.from, via: "extend" }
2732
2859
  }), {
2733
- source: K($),
2734
- context: _(r, s)
2860
+ source: Y(S),
2861
+ context: _(r, i)
2735
2862
  };
2736
- c.push(v);
2863
+ c.push(b);
2737
2864
  try {
2738
- const L = await i(v);
2865
+ const L = await s(b);
2739
2866
  if (L === void 0)
2740
2867
  throw new Error("loader returned undefined");
2741
- const { context: j, body: H } = P(
2868
+ const { context: j, body: N } = I(
2742
2869
  L,
2743
- v
2744
- ), he = be(H);
2745
- if (he.length > 0) {
2746
- const F = he[0].path, I = Y(
2870
+ b
2871
+ ), ue = ye(N);
2872
+ if (ue.length > 0) {
2873
+ const P = ue[0].path, z = X(
2747
2874
  o,
2748
- F,
2749
- v,
2750
- v,
2875
+ P,
2876
+ b,
2877
+ b,
2751
2878
  a,
2752
2879
  !0
2753
- ), z = c.check(I);
2754
- if (z.circular)
2880
+ ), U = c.check(z);
2881
+ if (U.circular)
2755
2882
  return h?.push({
2756
2883
  code: "circular_include",
2757
- message: R("circular_include", {
2758
- path: I,
2759
- from: z.from,
2884
+ message: H("circular_include", {
2885
+ path: z,
2886
+ from: U.from,
2760
2887
  via: "extend"
2761
2888
  }),
2762
2889
  path: n,
2763
- details: { path: I, from: z.from, via: "extend" }
2890
+ details: { path: z, from: U.from, via: "extend" }
2764
2891
  }), {
2765
- source: K($),
2766
- context: _(r, s)
2892
+ source: Y(S),
2893
+ context: _(r, i)
2767
2894
  };
2768
- throw u({
2895
+ throw d({
2769
2896
  code: "parse_error",
2770
- path: v,
2897
+ path: b,
2771
2898
  details: { message: "layout extend is not supported" }
2772
2899
  });
2773
2900
  }
2774
- const Ne = ke(H, {
2775
- path: v,
2901
+ const Ke = be(N, {
2902
+ path: b,
2776
2903
  mode: "layout"
2777
- }), Be = new Map(
2778
- $.map((F) => [F.name, F.body])
2779
- ), je = Zt(
2780
- H,
2781
- Ne,
2782
- Be
2783
- ), Fe = _(
2904
+ }), Ye = new Map(
2905
+ S.map((P) => [P.name, P.body])
2906
+ ), Xe = on(
2907
+ N,
2908
+ Ke,
2909
+ Ye
2910
+ ), Ge = _(
2784
2911
  r,
2785
2912
  j,
2786
- s
2913
+ i
2787
2914
  );
2788
- return { source: je, context: Fe };
2915
+ return { source: Xe, context: Ge };
2789
2916
  } finally {
2790
2917
  c.pop();
2791
2918
  }
2792
- } catch (S) {
2793
- const L = qt(S);
2794
- throw L.adjusted ? L.errorToThrow : S;
2919
+ } catch (C) {
2920
+ const L = an(C);
2921
+ throw L.adjusted ? L.errorToThrow : C;
2795
2922
  } finally {
2796
- b && c.pop();
2923
+ v && c.pop();
2797
2924
  }
2798
2925
  }
2799
- const Kt = J.warningReasons, Yt = [
2926
+ const ln = Q.warningReasons, hn = [
2800
2927
  {
2801
2928
  reason: "contains_html_script_tag",
2802
2929
  test: (t) => /<\/?script\b/i.test(t)
@@ -2818,51 +2945,51 @@ const Kt = J.warningReasons, Yt = [
2818
2945
  test: (t) => /<meta\b[^>]*\bhttp-equiv\b/i.test(t)
2819
2946
  }
2820
2947
  ];
2821
- function Xt(t) {
2822
- return Kt[t] ?? t;
2948
+ function un(t) {
2949
+ return ln[t] ?? t;
2823
2950
  }
2824
- function X(t, e, n, r) {
2951
+ function G(t, e, n, r) {
2825
2952
  if (typeof t == "string") {
2826
- for (const s of Yt)
2827
- s.test(t) && n.push({
2953
+ for (const i of hn)
2954
+ i.test(t) && n.push({
2828
2955
  code: "suspicious_context_value",
2829
- message: R("suspicious_context_value", {
2956
+ message: H("suspicious_context_value", {
2830
2957
  key: e,
2831
- reason: Xt(s.reason)
2958
+ reason: un(i.reason)
2832
2959
  }),
2833
2960
  path: r,
2834
- details: { key: e, reason: s.reason }
2961
+ details: { key: e, reason: i.reason }
2835
2962
  });
2836
2963
  return;
2837
2964
  }
2838
2965
  if (t != null) {
2839
2966
  if (Array.isArray(t)) {
2840
- for (let s = 0; s < t.length; s++)
2841
- X(t[s], `${e}[${s}]`, n, r);
2967
+ for (let i = 0; i < t.length; i++)
2968
+ G(t[i], `${e}[${i}]`, n, r);
2842
2969
  return;
2843
2970
  }
2844
2971
  if (typeof t == "object")
2845
- for (const [s, i] of Object.entries(
2972
+ for (const [i, s] of Object.entries(
2846
2973
  t
2847
2974
  )) {
2848
- const o = e.length > 0 ? `${e}.${s}` : s;
2849
- X(i, o, n, r);
2975
+ const o = e.length > 0 ? `${e}.${i}` : i;
2976
+ G(s, o, n, r);
2850
2977
  }
2851
2978
  }
2852
2979
  }
2853
- function Gt(t, e, n) {
2854
- for (const [r, s] of Object.entries(t))
2855
- X(s, r, e, n);
2980
+ function dn(t, e, n) {
2981
+ for (const [r, i] of Object.entries(t))
2982
+ G(i, r, e, n);
2856
2983
  }
2857
- const Jt = /^=+[ \t]*$/, Qt = /^-+[ \t]*$/, en = /^(```|~~~)/, tn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
2858
- function G(t) {
2859
- const e = tn.exec(t);
2984
+ const fn = /^=+[ \t]*$/, pn = /^-+[ \t]*$/, mn = /^(```|~~~)/, gn = /\{#([A-Za-z][\w:.-]*)\}\s*$/;
2985
+ function J(t) {
2986
+ const e = gn.exec(t);
2860
2987
  return e && e.index !== void 0 ? {
2861
2988
  text: t.slice(0, e.index).trim(),
2862
2989
  explicitId: e[1]
2863
2990
  } : { text: t.trim() };
2864
2991
  }
2865
- function nn(t) {
2992
+ function xn(t) {
2866
2993
  let e = 0;
2867
2994
  for (; e < t.length && e < 6 && t[e] === "#"; )
2868
2995
  e += 1;
@@ -2876,7 +3003,7 @@ function nn(t) {
2876
3003
  let r = t.length;
2877
3004
  for (; r > n && (t[r - 1] === " " || t[r - 1] === " "); )
2878
3005
  r -= 1;
2879
- let s = r;
3006
+ let i = r;
2880
3007
  if (r > n && t[r - 1] === "#") {
2881
3008
  let o = r - 1;
2882
3009
  for (; o > n && t[o - 1] === "#"; )
@@ -2885,141 +3012,141 @@ function nn(t) {
2885
3012
  let a = o - 1;
2886
3013
  for (; a >= n && (t[a] === " " || t[a] === " "); )
2887
3014
  a -= 1;
2888
- s = a + 1;
3015
+ i = a + 1;
2889
3016
  }
2890
3017
  }
2891
- if (s <= n)
3018
+ if (i <= n)
2892
3019
  return null;
2893
- const i = G(t.slice(n, s));
2894
- return { level: e, ...i };
3020
+ const s = J(t.slice(n, i));
3021
+ return { level: e, ...s };
2895
3022
  }
2896
- function ve(t, e, n) {
3023
+ function _e(t, e, n) {
2897
3024
  let r = n;
2898
3025
  for (; r < t.length; ) {
2899
3026
  if (!e.inHtmlComment) {
2900
- const i = t.indexOf("<!--", r);
2901
- if (i === -1)
3027
+ const s = t.indexOf("<!--", r);
3028
+ if (s === -1)
2902
3029
  return;
2903
- e.inHtmlComment = !0, r = i + 4;
3030
+ e.inHtmlComment = !0, r = s + 4;
2904
3031
  continue;
2905
3032
  }
2906
- const s = t.indexOf("-->", r);
2907
- if (s === -1)
3033
+ const i = t.indexOf("-->", r);
3034
+ if (i === -1)
2908
3035
  return;
2909
- e.inHtmlComment = !1, r = s + 3;
3036
+ e.inHtmlComment = !1, r = i + 3;
2910
3037
  }
2911
3038
  }
2912
- function rn(t, e) {
3039
+ function kn(t, e) {
2913
3040
  if (e.inFence || e.inHtmlComment)
2914
3041
  return !0;
2915
3042
  const n = t.trim();
2916
3043
  return !!(n.startsWith("<!--") && n.endsWith("-->") && n.length >= 7 || n.startsWith("<!--") && !n.includes("-->"));
2917
3044
  }
2918
- function sn(t) {
3045
+ function wn(t) {
2919
3046
  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];
3047
+ for (let i = 0; i < e.length; i++) {
3048
+ const s = e[i];
2922
3049
  if (r.inFence) {
2923
- const l = i.trim();
3050
+ const l = s.trim();
2924
3051
  l.startsWith(r.inFence.marker) && /^(`{3,}|~{3,})\s*$/.test(l) && (r.inFence = !1);
2925
3052
  continue;
2926
3053
  }
2927
3054
  if (r.inHtmlComment) {
2928
- ve(i, r, 0);
3055
+ _e(s, r, 0);
2929
3056
  continue;
2930
3057
  }
2931
- const o = en.exec(i.trimStart());
3058
+ const o = mn.exec(s.trimStart());
2932
3059
  if (o) {
2933
3060
  const l = o[1];
2934
- i.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
3061
+ s.trimStart().slice(l.length).includes(l) || (r.inFence = { marker: l });
2935
3062
  continue;
2936
3063
  }
2937
- if (i.trim().startsWith("<!--")) {
2938
- ve(i, r, i.indexOf("<!--"));
3064
+ if (s.trim().startsWith("<!--")) {
3065
+ _e(s, r, s.indexOf("<!--"));
2939
3066
  continue;
2940
3067
  }
2941
- if (rn(i, r))
3068
+ if (kn(s, r))
2942
3069
  continue;
2943
- const c = nn(i);
3070
+ const c = xn(s);
2944
3071
  if (c) {
2945
3072
  n.push(c);
2946
3073
  continue;
2947
3074
  }
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;
3075
+ const h = e[i + 1];
3076
+ if (h !== void 0 && s.trim().length > 0 && !s.trimStart().startsWith("#") && !s.trimStart().startsWith(">") && !s.trimStart().startsWith("|")) {
3077
+ if (fn.test(h)) {
3078
+ const l = J(s.trim());
3079
+ n.push({ level: 1, ...l }), i += 1;
2953
3080
  continue;
2954
3081
  }
2955
- if (Qt.test(h) && h.trim().length >= 1) {
2956
- const l = G(i.trim());
2957
- n.push({ level: 2, ...l }), s += 1;
3082
+ if (pn.test(h) && h.trim().length >= 1) {
3083
+ const l = J(s.trim());
3084
+ n.push({ level: 2, ...l }), i += 1;
2958
3085
  continue;
2959
3086
  }
2960
3087
  }
2961
3088
  }
2962
3089
  return n;
2963
3090
  }
2964
- const on = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
2965
- function an() {
3091
+ const vn = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
3092
+ function bn() {
2966
3093
  const t = /* @__PURE__ */ new Map();
2967
3094
  return {
2968
3095
  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}`;
3096
+ const r = n !== void 0 && n.length > 0 ? n : yn(e), i = t.get(r) ?? 0;
3097
+ return t.set(r, i + 1), i === 0 ? r : `${r}-${i}`;
2971
3098
  }
2972
3099
  };
2973
3100
  }
2974
- function cn(t) {
2975
- return t.toLowerCase().replace(on, "").replace(/\s+/g, "-");
3101
+ function yn(t) {
3102
+ return t.toLowerCase().replace(vn, "").replace(/\s+/g, "-");
2976
3103
  }
2977
- function ln(t) {
3104
+ function _n(t) {
2978
3105
  let e = t.trim();
2979
3106
  e = e.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"), e = e.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
2980
3107
  for (let n = 0; n < 3; n++)
2981
3108
  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
3109
  return e.trim();
2983
3110
  }
2984
- function hn(t, e) {
3111
+ function Sn(t, e) {
2985
3112
  if (t.length === 0)
2986
3113
  return "";
2987
- const n = an(), s = t.map((o) => {
2988
- const a = ln(o.text), c = n.slug(a, o.explicitId);
3114
+ const n = bn(), i = t.map((o) => {
3115
+ const a = _n(o.text), c = n.slug(a, o.explicitId);
2989
3116
  return { level: o.level, text: a, anchor: c };
2990
3117
  }).filter((o) => o.level <= e);
2991
- if (s.length === 0)
3118
+ if (i.length === 0)
2992
3119
  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(`
3120
+ const s = Math.min(...i.map((o) => o.level));
3121
+ return i.map((o) => `${" ".repeat((o.level - s) * 2)}- [${o.text}](#${o.anchor})`).join(`
2995
3122
  `);
2996
3123
  }
2997
- function dn(t, e = {}) {
3124
+ function Cn(t, e = {}) {
2998
3125
  const r = E(t).filter((o) => {
2999
3126
  const a = A(o.inner);
3000
- return a.length === 1 && ce(a[0]);
3127
+ return a.length === 1 && le(a[0]);
3001
3128
  });
3002
3129
  if (r.length === 0)
3003
3130
  return t;
3004
- const s = sn(t);
3005
- let i = t;
3131
+ const i = wn(t);
3132
+ let s = t;
3006
3133
  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);
3134
+ const a = r[o], { maxLevel: c } = Ut(a.inner, e.path), h = Sn(i, c), l = s.slice(0, a.start), u = s.slice(a.end);
3135
+ s = T(T(l, h), u);
3009
3136
  }
3010
- return i;
3137
+ return s;
3011
3138
  }
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(), {
3139
+ async function he(t, e) {
3140
+ const n = e.path, r = e.context, i = e.registry ?? new Ce(), s = e.warnings ?? [], o = e.visitStack ?? new Ze(), {
3014
3141
  source: a,
3015
3142
  declarationUpdates: c
3016
- } = await Lt(t, { path: n, context: { ...r } });
3017
- Gt(
3143
+ } = await Zt(t, { path: n, context: { ...r } });
3144
+ dn(
3018
3145
  _(r, c ?? {}),
3019
- i,
3146
+ s,
3020
3147
  n
3021
3148
  );
3022
- const h = await Vt(a, {
3149
+ const h = await cn(a, {
3023
3150
  path: n,
3024
3151
  context: r,
3025
3152
  declarationUpdates: c ?? {},
@@ -3027,123 +3154,123 @@ async function le(t, e) {
3027
3154
  root: e.root,
3028
3155
  constrainToRoot: e.constrainToRoot,
3029
3156
  visitStack: o,
3030
- warnings: i,
3157
+ warnings: s,
3031
3158
  inComponent: e.inComponent ?? !1
3032
- }), { source: l, context: d } = h, { source: f, directives: g } = jt(l, {
3159
+ }), { source: l, context: u } = h, { source: f, directives: g } = Qt(l, {
3033
3160
  path: n,
3034
- registry: s,
3035
- context: d
3161
+ registry: i,
3162
+ context: u
3036
3163
  }), m = e.loader;
3037
3164
  if (g.length > 0 && !m)
3038
3165
  throw new Error("loader is required when processing include directives");
3039
3166
  let p = f;
3040
- return g.length > 0 && m && (p = await Ct({
3167
+ return g.length > 0 && m && (p = await Ft({
3041
3168
  source: f,
3042
3169
  directives: g,
3043
- context: d,
3170
+ context: u,
3044
3171
  loader: m,
3045
3172
  root: e.root,
3046
3173
  path: n,
3047
3174
  preserveFrontMatter: e.preserveFrontMatter,
3048
3175
  preserveHgComments: e.preserveHgComments,
3049
3176
  visitStack: o,
3050
- warnings: i,
3051
- registry: s,
3177
+ warnings: s,
3178
+ registry: i,
3052
3179
  constrainToRoot: e.constrainToRoot
3053
- })), p = await vt(p, {
3054
- context: d,
3180
+ })), p = await Ht(p, {
3181
+ context: u,
3055
3182
  path: n,
3056
- registry: s,
3183
+ registry: i,
3057
3184
  loader: m,
3058
3185
  rootDir: e.root,
3059
- warnings: i,
3186
+ warnings: s,
3060
3187
  visitStack: o,
3061
- parentContext: d,
3188
+ parentContext: u,
3062
3189
  preserveHgComments: e.preserveHgComments,
3063
3190
  constrainToRoot: e.constrainToRoot
3064
- }), p = await We(p, d, {
3191
+ }), p = await Ne(p, u, {
3065
3192
  path: n,
3066
- registry: s,
3193
+ registry: i,
3067
3194
  loader: m,
3068
3195
  rootDir: e.root,
3069
- warnings: i,
3196
+ warnings: s,
3070
3197
  visitStack: o,
3071
- parentContext: d,
3198
+ parentContext: u,
3072
3199
  preserveHgComments: e.preserveHgComments,
3073
3200
  constrainToRoot: e.constrainToRoot
3074
- }), p = dn(p, { path: n }), p = Pt(p, e.preserveHgComments), p;
3201
+ }), p = Cn(p, { path: n }), p = tn(p, e.preserveHgComments), p;
3075
3202
  }
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(
3203
+ async function Wn(t, e = {}) {
3204
+ const n = e.path, r = _(e.context), i = e.registry ?? new Ce(), s = e.warnings ?? [], o = e.visitStack ?? new Ze(), { context: a, body: c, rawFrontMatter: h } = I(
3078
3205
  t,
3079
3206
  n
3080
3207
  ), l = _(r, a);
3081
- let d = await le(c, {
3208
+ let u = await he(c, {
3082
3209
  ...e,
3083
3210
  context: l,
3084
- registry: s,
3085
- warnings: i,
3211
+ registry: i,
3212
+ warnings: s,
3086
3213
  visitStack: o
3087
3214
  });
3088
- return d = Ft(d, {
3215
+ return u = en(u, {
3089
3216
  preserveFrontMatter: e.preserveFrontMatter,
3090
3217
  rawFrontMatter: h
3091
3218
  }), {
3092
- markdown: d,
3093
- warnings: i
3219
+ markdown: u,
3220
+ warnings: s
3094
3221
  };
3095
3222
  }
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, {
3223
+ async function $n(t, e) {
3224
+ const n = e.path, { context: r, body: i } = I(t, n), s = _(e.context, r);
3225
+ return he(i, {
3099
3226
  ...e,
3100
- context: i,
3227
+ context: s,
3101
3228
  preserveFrontMatter: !1
3102
3229
  });
3103
3230
  }
3104
- async function mn(t, e, n) {
3231
+ async function En(t, e, n) {
3105
3232
  if (n != null && "serverContext" in n && n.serverContext != null)
3106
- throw u({
3233
+ throw d({
3107
3234
  code: "server_context_on_client"
3108
3235
  });
3109
3236
  if (n != null && "dataSources" in n && n.dataSources != null && Object.keys(n.dataSources).length > 0)
3110
- throw u({
3237
+ throw d({
3111
3238
  code: "data_sources_on_client"
3112
3239
  });
3113
3240
  const r = n?.loader;
3114
3241
  if (!r)
3115
- throw u({
3242
+ throw d({
3116
3243
  code: "parse_error",
3117
3244
  details: { message: "loader is required for renderClient" }
3118
3245
  });
3119
- let s, i;
3120
- typeof t == "string" ? s = t : (i = t.path, s = await r(t.path));
3246
+ let i, s;
3247
+ typeof t == "string" ? i = t : (s = t.path, i = await r(t.path));
3121
3248
  const o = _(e);
3122
- return un(s, {
3249
+ return Wn(i, {
3123
3250
  context: o,
3124
3251
  loader: r,
3125
3252
  root: n?.root,
3126
- path: i ?? n?.path,
3253
+ path: s ?? n?.path,
3127
3254
  preserveFrontMatter: n?.preserveFrontMatter,
3128
3255
  preserveHgComments: n?.preserveHgComments,
3129
3256
  constrainToRoot: n?.constrainToRoot
3130
3257
  });
3131
3258
  }
3132
- function gn(t, e) {
3259
+ function Tn(t, e) {
3133
3260
  const n = [`[hyogen:${t}] ${e.code}`], r = {};
3134
3261
  if (e.details)
3135
- for (const [s, i] of Object.entries(e.details))
3136
- i !== void 0 && (r[s] = i);
3262
+ for (const [i, s] of Object.entries(e.details))
3263
+ s !== void 0 && (r[i] = s);
3137
3264
  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)}`);
3265
+ for (const [i, s] of Object.entries(r))
3266
+ n.push(` ${i}: ${String(s)}`);
3140
3267
  return n.join(`
3141
3268
  `);
3142
3269
  }
3143
3270
  export {
3144
- u as createHyogenError,
3145
- gn as formatDiagnosticLog,
3146
- Ve as formatMessage,
3147
- mn as renderClient
3271
+ d as createHyogenError,
3272
+ Tn as formatDiagnosticLog,
3273
+ it as formatMessage,
3274
+ En as renderClient
3148
3275
  };
3149
3276
  //# sourceMappingURL=client.js.map