@rohal12/spindle-lsp 0.15.6 → 0.15.8

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.
package/dist/bin.js CHANGED
@@ -55,7 +55,7 @@ var VERSION;
55
55
  var init_version = __esm({
56
56
  "src/version.ts"() {
57
57
  "use strict";
58
- VERSION = false ? pkg.version : "0.15.6";
58
+ VERSION = false ? pkg.version : "0.15.8";
59
59
  }
60
60
  });
61
61
 
@@ -7011,10 +7011,10 @@ var require_resolve_block_map = __commonJS({
7011
7011
  let offset2 = bm.offset;
7012
7012
  let commentEnd = null;
7013
7013
  for (const collItem of bm.items) {
7014
- const { start, key, sep: sep3, value } = collItem;
7014
+ const { start, key, sep: sep4, value } = collItem;
7015
7015
  const keyProps = resolveProps.resolveProps(start, {
7016
7016
  indicator: "explicit-key-ind",
7017
- next: key ?? sep3?.[0],
7017
+ next: key ?? sep4?.[0],
7018
7018
  offset: offset2,
7019
7019
  onError,
7020
7020
  parentIndent: bm.indent,
@@ -7028,7 +7028,7 @@ var require_resolve_block_map = __commonJS({
7028
7028
  else if ("indent" in key && key.indent !== bm.indent)
7029
7029
  onError(offset2, "BAD_INDENT", startColMsg);
7030
7030
  }
7031
- if (!keyProps.anchor && !keyProps.tag && !sep3) {
7031
+ if (!keyProps.anchor && !keyProps.tag && !sep4) {
7032
7032
  commentEnd = keyProps.end;
7033
7033
  if (keyProps.comment) {
7034
7034
  if (map2.comment)
@@ -7052,7 +7052,7 @@ var require_resolve_block_map = __commonJS({
7052
7052
  ctx.atKey = false;
7053
7053
  if (utilMapIncludes.mapIncludes(ctx, map2.items, keyNode))
7054
7054
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
7055
- const valueProps = resolveProps.resolveProps(sep3 ?? [], {
7055
+ const valueProps = resolveProps.resolveProps(sep4 ?? [], {
7056
7056
  indicator: "map-value-ind",
7057
7057
  next: value,
7058
7058
  offset: keyNode.range[2],
@@ -7068,7 +7068,7 @@ var require_resolve_block_map = __commonJS({
7068
7068
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
7069
7069
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
7070
7070
  }
7071
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset2, sep3, null, valueProps, onError);
7071
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset2, sep4, null, valueProps, onError);
7072
7072
  if (ctx.schema.compat)
7073
7073
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
7074
7074
  offset2 = valueNode.range[2];
@@ -7159,7 +7159,7 @@ var require_resolve_end = __commonJS({
7159
7159
  let comment = "";
7160
7160
  if (end) {
7161
7161
  let hasSpace = false;
7162
- let sep3 = "";
7162
+ let sep4 = "";
7163
7163
  for (const token of end) {
7164
7164
  const { source, type } = token;
7165
7165
  switch (type) {
@@ -7173,13 +7173,13 @@ var require_resolve_end = __commonJS({
7173
7173
  if (!comment)
7174
7174
  comment = cb;
7175
7175
  else
7176
- comment += sep3 + cb;
7177
- sep3 = "";
7176
+ comment += sep4 + cb;
7177
+ sep4 = "";
7178
7178
  break;
7179
7179
  }
7180
7180
  case "newline":
7181
7181
  if (comment)
7182
- sep3 += source;
7182
+ sep4 += source;
7183
7183
  hasSpace = true;
7184
7184
  break;
7185
7185
  default:
@@ -7222,18 +7222,18 @@ var require_resolve_flow_collection = __commonJS({
7222
7222
  let offset2 = fc.offset + fc.start.source.length;
7223
7223
  for (let i2 = 0; i2 < fc.items.length; ++i2) {
7224
7224
  const collItem = fc.items[i2];
7225
- const { start, key, sep: sep3, value } = collItem;
7225
+ const { start, key, sep: sep4, value } = collItem;
7226
7226
  const props = resolveProps.resolveProps(start, {
7227
7227
  flow: fcName,
7228
7228
  indicator: "explicit-key-ind",
7229
- next: key ?? sep3?.[0],
7229
+ next: key ?? sep4?.[0],
7230
7230
  offset: offset2,
7231
7231
  onError,
7232
7232
  parentIndent: fc.indent,
7233
7233
  startOnNewline: false
7234
7234
  });
7235
7235
  if (!props.found) {
7236
- if (!props.anchor && !props.tag && !sep3 && !value) {
7236
+ if (!props.anchor && !props.tag && !sep4 && !value) {
7237
7237
  if (i2 === 0 && props.comma)
7238
7238
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
7239
7239
  else if (i2 < fc.items.length - 1)
@@ -7287,8 +7287,8 @@ var require_resolve_flow_collection = __commonJS({
7287
7287
  }
7288
7288
  }
7289
7289
  }
7290
- if (!isMap2 && !sep3 && !props.found) {
7291
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep3, null, props, onError);
7290
+ if (!isMap2 && !sep4 && !props.found) {
7291
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep4, null, props, onError);
7292
7292
  coll.items.push(valueNode);
7293
7293
  offset2 = valueNode.range[2];
7294
7294
  if (isBlock(value))
@@ -7300,7 +7300,7 @@ var require_resolve_flow_collection = __commonJS({
7300
7300
  if (isBlock(key))
7301
7301
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
7302
7302
  ctx.atKey = false;
7303
- const valueProps = resolveProps.resolveProps(sep3 ?? [], {
7303
+ const valueProps = resolveProps.resolveProps(sep4 ?? [], {
7304
7304
  flow: fcName,
7305
7305
  indicator: "map-value-ind",
7306
7306
  next: value,
@@ -7311,8 +7311,8 @@ var require_resolve_flow_collection = __commonJS({
7311
7311
  });
7312
7312
  if (valueProps.found) {
7313
7313
  if (!isMap2 && !props.found && ctx.options.strict) {
7314
- if (sep3)
7315
- for (const st2 of sep3) {
7314
+ if (sep4)
7315
+ for (const st2 of sep4) {
7316
7316
  if (st2 === valueProps.found)
7317
7317
  break;
7318
7318
  if (st2.type === "newline") {
@@ -7329,7 +7329,7 @@ var require_resolve_flow_collection = __commonJS({
7329
7329
  else
7330
7330
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
7331
7331
  }
7332
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep3, null, valueProps, onError) : null;
7332
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep4, null, valueProps, onError) : null;
7333
7333
  if (valueNode) {
7334
7334
  if (isBlock(value))
7335
7335
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -7509,7 +7509,7 @@ var require_resolve_block_scalar = __commonJS({
7509
7509
  chompStart = i2 + 1;
7510
7510
  }
7511
7511
  let value = "";
7512
- let sep3 = "";
7512
+ let sep4 = "";
7513
7513
  let prevMoreIndented = false;
7514
7514
  for (let i2 = 0; i2 < contentStart; ++i2)
7515
7515
  value += lines[i2][0].slice(trimIndent) + "\n";
@@ -7526,24 +7526,24 @@ var require_resolve_block_scalar = __commonJS({
7526
7526
  indent = "";
7527
7527
  }
7528
7528
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
7529
- value += sep3 + indent.slice(trimIndent) + content2;
7530
- sep3 = "\n";
7529
+ value += sep4 + indent.slice(trimIndent) + content2;
7530
+ sep4 = "\n";
7531
7531
  } else if (indent.length > trimIndent || content2[0] === " ") {
7532
- if (sep3 === " ")
7533
- sep3 = "\n";
7534
- else if (!prevMoreIndented && sep3 === "\n")
7535
- sep3 = "\n\n";
7536
- value += sep3 + indent.slice(trimIndent) + content2;
7537
- sep3 = "\n";
7532
+ if (sep4 === " ")
7533
+ sep4 = "\n";
7534
+ else if (!prevMoreIndented && sep4 === "\n")
7535
+ sep4 = "\n\n";
7536
+ value += sep4 + indent.slice(trimIndent) + content2;
7537
+ sep4 = "\n";
7538
7538
  prevMoreIndented = true;
7539
7539
  } else if (content2 === "") {
7540
- if (sep3 === "\n")
7540
+ if (sep4 === "\n")
7541
7541
  value += "\n";
7542
7542
  else
7543
- sep3 = "\n";
7543
+ sep4 = "\n";
7544
7544
  } else {
7545
- value += sep3 + content2;
7546
- sep3 = " ";
7545
+ value += sep4 + content2;
7546
+ sep4 = " ";
7547
7547
  prevMoreIndented = false;
7548
7548
  }
7549
7549
  }
@@ -7726,25 +7726,25 @@ var require_resolve_flow_scalar = __commonJS({
7726
7726
  trimBoth = /^[ \t]+|[ \t]+$/g;
7727
7727
  }
7728
7728
  let res = match2[1].replace(trimEnd, "");
7729
- let sep3 = " ";
7729
+ let sep4 = " ";
7730
7730
  let pos = line.lastIndex;
7731
7731
  while (match2 = line.exec(source)) {
7732
7732
  const lm = match2[1].replace(trimBoth, "");
7733
7733
  if (lm === "") {
7734
- if (sep3 === "\n")
7735
- res += sep3;
7734
+ if (sep4 === "\n")
7735
+ res += sep4;
7736
7736
  else
7737
- sep3 = "\n";
7737
+ sep4 = "\n";
7738
7738
  } else {
7739
- res += sep3 + lm;
7740
- sep3 = " ";
7739
+ res += sep4 + lm;
7740
+ sep4 = " ";
7741
7741
  }
7742
7742
  pos = line.lastIndex;
7743
7743
  }
7744
7744
  const last2 = /[ \t]*(.*)/sy;
7745
7745
  last2.lastIndex = pos;
7746
7746
  match2 = last2.exec(source);
7747
- return res + sep3 + (match2?.[1] ?? "");
7747
+ return res + sep4 + (match2?.[1] ?? "");
7748
7748
  }
7749
7749
  function doubleQuotedValue(source, onError) {
7750
7750
  let res = "";
@@ -8554,14 +8554,14 @@ var require_cst_stringify = __commonJS({
8554
8554
  }
8555
8555
  }
8556
8556
  }
8557
- function stringifyItem({ start, key, sep: sep3, value }) {
8557
+ function stringifyItem({ start, key, sep: sep4, value }) {
8558
8558
  let res = "";
8559
8559
  for (const st2 of start)
8560
8560
  res += st2.source;
8561
8561
  if (key)
8562
8562
  res += stringifyToken(key);
8563
- if (sep3)
8564
- for (const st2 of sep3)
8563
+ if (sep4)
8564
+ for (const st2 of sep4)
8565
8565
  res += st2.source;
8566
8566
  if (value)
8567
8567
  res += stringifyToken(value);
@@ -9728,18 +9728,18 @@ var require_parser = __commonJS({
9728
9728
  if (this.type === "map-value-ind") {
9729
9729
  const prev = getPrevProps(this.peek(2));
9730
9730
  const start = getFirstKeyStartProps(prev);
9731
- let sep3;
9731
+ let sep4;
9732
9732
  if (scalar.end) {
9733
- sep3 = scalar.end;
9734
- sep3.push(this.sourceToken);
9733
+ sep4 = scalar.end;
9734
+ sep4.push(this.sourceToken);
9735
9735
  delete scalar.end;
9736
9736
  } else
9737
- sep3 = [this.sourceToken];
9737
+ sep4 = [this.sourceToken];
9738
9738
  const map2 = {
9739
9739
  type: "block-map",
9740
9740
  offset: scalar.offset,
9741
9741
  indent: scalar.indent,
9742
- items: [{ start, key: scalar, sep: sep3 }]
9742
+ items: [{ start, key: scalar, sep: sep4 }]
9743
9743
  };
9744
9744
  this.onKeyLine = true;
9745
9745
  this.stack[this.stack.length - 1] = map2;
@@ -9892,15 +9892,15 @@ var require_parser = __commonJS({
9892
9892
  } else if (isFlowToken(it2.key) && !includesToken(it2.sep, "newline")) {
9893
9893
  const start2 = getFirstKeyStartProps(it2.start);
9894
9894
  const key = it2.key;
9895
- const sep3 = it2.sep;
9896
- sep3.push(this.sourceToken);
9895
+ const sep4 = it2.sep;
9896
+ sep4.push(this.sourceToken);
9897
9897
  delete it2.key;
9898
9898
  delete it2.sep;
9899
9899
  this.stack.push({
9900
9900
  type: "block-map",
9901
9901
  offset: this.offset,
9902
9902
  indent: this.indent,
9903
- items: [{ start: start2, key, sep: sep3 }]
9903
+ items: [{ start: start2, key, sep: sep4 }]
9904
9904
  });
9905
9905
  } else if (start.length > 0) {
9906
9906
  it2.sep = it2.sep.concat(start, this.sourceToken);
@@ -10094,13 +10094,13 @@ var require_parser = __commonJS({
10094
10094
  const prev = getPrevProps(parent);
10095
10095
  const start = getFirstKeyStartProps(prev);
10096
10096
  fixFlowSeqItems(fc);
10097
- const sep3 = fc.end.splice(1, fc.end.length);
10098
- sep3.push(this.sourceToken);
10097
+ const sep4 = fc.end.splice(1, fc.end.length);
10098
+ sep4.push(this.sourceToken);
10099
10099
  const map2 = {
10100
10100
  type: "block-map",
10101
10101
  offset: fc.offset,
10102
10102
  indent: fc.indent,
10103
- items: [{ start, key: fc, sep: sep3 }]
10103
+ items: [{ start, key: fc, sep: sep4 }]
10104
10104
  };
10105
10105
  this.onKeyLine = true;
10106
10106
  this.stack[this.stack.length - 1] = map2;
@@ -10489,8 +10489,8 @@ var init_config_loader = __esm({
10489
10489
  });
10490
10490
 
10491
10491
  // src/core/workspace/macro-sources.ts
10492
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
10493
- import { dirname, isAbsolute, join as join2, relative } from "node:path";
10492
+ import { existsSync as existsSync2, lstatSync, readdir, readFileSync as readFileSync2 } from "node:fs";
10493
+ import { dirname, isAbsolute, join as join2, relative, resolve as resolve2, sep } from "node:path";
10494
10494
  import { pathToFileURL } from "node:url";
10495
10495
  function isExcludedSegment(segment) {
10496
10496
  return EXCLUDED_DIRS.includes(segment) || segment.startsWith(".") && segment !== "." && segment !== "..";
@@ -10501,19 +10501,41 @@ function isMacroSource(uriOrPath) {
10501
10501
  function isExcludedProjectFile(path2, root) {
10502
10502
  return (root ? relative(root, path2) : path2).split(/[\\/]/).some(isExcludedSegment);
10503
10503
  }
10504
+ function canDiscoverProjectPath(path2, root) {
10505
+ let current2 = resolve2(root);
10506
+ try {
10507
+ for (const segment of relative(root, path2).split(sep)) {
10508
+ current2 = resolve2(current2, segment);
10509
+ if (lstatSync(current2).isSymbolicLink()) return false;
10510
+ }
10511
+ } catch (error48) {
10512
+ if (["ENOENT", "ENOTDIR", "EACCES", "EPERM"].includes(error48.code ?? "")) return false;
10513
+ throw error48;
10514
+ }
10515
+ return true;
10516
+ }
10504
10517
  function findMacroSourceFiles(root) {
10505
10518
  return findProjectFiles(root, MACRO_SOURCE_GLOB);
10506
10519
  }
10507
- function findProjectFiles(root, pattern) {
10508
- const excluded = (p) => isExcludedProjectFile(p.fullpath(), root);
10509
- return Ze(pattern, {
10520
+ async function findProjectFiles(root, pattern) {
10521
+ const excluded = (p) => isExcludedProjectFile(p.fullpath(), root) || !canDiscoverProjectPath(p.fullpath(), root);
10522
+ const files = await Ze(pattern, {
10510
10523
  cwd: root,
10511
10524
  absolute: true,
10512
10525
  nodir: true,
10526
+ follow: false,
10513
10527
  // Hidden entries are excluded by the predicate, not by glob's default
10514
10528
  dot: true,
10515
- ignore: { ignored: excluded, childrenIgnored: excluded }
10529
+ ignore: { ignored: excluded, childrenIgnored: excluded },
10530
+ // Glob can read a literal prefix before consulting childrenIgnored.
10531
+ fs: {
10532
+ readdir(path2, options, callback) {
10533
+ if (canDiscoverProjectPath(path2, root)) readdir(path2, options, callback);
10534
+ else callback(null, []);
10535
+ }
10536
+ }
10516
10537
  });
10538
+ return files.filter((file2) => canDiscoverProjectPath(file2, root));
10517
10539
  }
10518
10540
  function isWithin(path2, dir) {
10519
10541
  const rel = relative(dir, path2);
@@ -10558,16 +10580,16 @@ var init_macro_sources = __esm({
10558
10580
 
10559
10581
  // src/core/workspace/file-inputs.ts
10560
10582
  import { readFileSync as readFileSync3, statSync } from "node:fs";
10561
- import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve2, sep } from "node:path";
10583
+ import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve3, sep as sep2 } from "node:path";
10562
10584
  async function resolveFiles(pattern, cwd) {
10563
10585
  let input = pattern;
10564
10586
  let directory = cwd;
10565
- const literal3 = resolve2(cwd, pattern);
10587
+ const literal3 = resolve3(cwd, pattern);
10566
10588
  try {
10567
10589
  const stat = statSync(literal3);
10568
10590
  if (stat.isFile()) return [literal3];
10569
10591
  if (stat.isDirectory()) {
10570
- if (isExcludedProjectFile(literal3, cwd)) return [];
10592
+ if (isExcludedProjectFile(literal3, cwd) || !canDiscoverProjectPath(literal3, cwd)) return [];
10571
10593
  directory = literal3;
10572
10594
  input = "**/*.{tw,twee}";
10573
10595
  }
@@ -10586,7 +10608,7 @@ async function resolveInputs(patterns, cwd) {
10586
10608
  }
10587
10609
  function relativeTo(cwd, filePath) {
10588
10610
  const rel = relative2(cwd, filePath);
10589
- return rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute2(rel) ? filePath : rel;
10611
+ return rel === ".." || rel.startsWith(`..${sep2}`) || isAbsolute2(rel) ? filePath : rel;
10590
10612
  }
10591
10613
  var init_file_inputs = __esm({
10592
10614
  "src/core/workspace/file-inputs.ts"() {
@@ -10800,10 +10822,11 @@ function peg$parse(input, options) {
10800
10822
  const peg$c11 = "}";
10801
10823
  const peg$c12 = "/";
10802
10824
  const peg$c13 = "@";
10803
- const peg$c14 = "</";
10804
- const peg$c15 = "=";
10805
- const peg$c16 = '"';
10806
- const peg$c17 = "'";
10825
+ const peg$c14 = ":";
10826
+ const peg$c15 = "</";
10827
+ const peg$c16 = "=";
10828
+ const peg$c17 = '"';
10829
+ const peg$c18 = "'";
10807
10830
  const peg$r0 = /^[^\\{[<]/;
10808
10831
  const peg$r1 = /^[{}]/;
10809
10832
  const peg$r2 = /^[$_@%(!\/a-zA-Z]/;
@@ -10816,14 +10839,16 @@ function peg$parse(input, options) {
10816
10839
  const peg$r9 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF}]/;
10817
10840
  const peg$r10 = /^[a-zA-Z0-9.!#$%&'*+\/=?\^_`|~\-]/;
10818
10841
  const peg$r11 = /^[a-zA-Z0-9.\-]/;
10819
- const peg$r12 = /^[\t-\r \/>\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
10820
- const peg$r13 = /^[a-zA-Z0-9\-]/;
10821
- const peg$r14 = /^[\t-\r "'\/<->{}\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
10822
- const peg$r15 = /^[^"]/;
10823
- const peg$r16 = /^[^']/;
10824
- const peg$r17 = /^["']/;
10825
- const peg$r18 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF>]/;
10826
- const peg$r19 = /^[ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;
10842
+ const peg$r12 = /^[a-zA-Z0-9+.\-]/;
10843
+ const peg$r13 = /^[^\0- \x7F<>{}]/;
10844
+ const peg$r14 = /^[\t-\r \/>\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
10845
+ const peg$r15 = /^[a-zA-Z0-9\-]/;
10846
+ const peg$r16 = /^[\t-\r "'\/<->{}\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
10847
+ const peg$r17 = /^[^"]/;
10848
+ const peg$r18 = /^[^']/;
10849
+ const peg$r19 = /^["']/;
10850
+ const peg$r20 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF>]/;
10851
+ const peg$r21 = /^[ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;
10827
10852
  const peg$e0 = peg$anyExpectation();
10828
10853
  const peg$e1 = peg$classExpectation([
10829
10854
  "\\",
@@ -10936,6 +10961,23 @@ function peg$parse(input, options) {
10936
10961
  "-"
10937
10962
  ], false, false, false);
10938
10963
  const peg$e27 = peg$classExpectation([
10964
+ ["a", "z"],
10965
+ ["A", "Z"],
10966
+ ["0", "9"],
10967
+ "+",
10968
+ ".",
10969
+ "-"
10970
+ ], false, false, false);
10971
+ const peg$e28 = peg$literalExpectation(":", false);
10972
+ const peg$e29 = peg$classExpectation([
10973
+ ["\0", " "],
10974
+ "\x7F",
10975
+ "<",
10976
+ ">",
10977
+ "{",
10978
+ "}"
10979
+ ], true, false, false);
10980
+ const peg$e30 = peg$classExpectation([
10939
10981
  [" ", "\r"],
10940
10982
  " ",
10941
10983
  "/",
@@ -10949,14 +10991,14 @@ function peg$parse(input, options) {
10949
10991
  "\u3000",
10950
10992
  "\uFEFF"
10951
10993
  ], false, false, false);
10952
- const peg$e28 = peg$literalExpectation("</", false);
10953
- const peg$e29 = peg$classExpectation([
10994
+ const peg$e31 = peg$literalExpectation("</", false);
10995
+ const peg$e32 = peg$classExpectation([
10954
10996
  ["a", "z"],
10955
10997
  ["A", "Z"],
10956
10998
  ["0", "9"],
10957
10999
  "-"
10958
11000
  ], false, false, false);
10959
- const peg$e30 = peg$classExpectation([
11001
+ const peg$e33 = peg$classExpectation([
10960
11002
  [" ", "\r"],
10961
11003
  " ",
10962
11004
  '"',
@@ -10974,13 +11016,13 @@ function peg$parse(input, options) {
10974
11016
  "\u3000",
10975
11017
  "\uFEFF"
10976
11018
  ], false, false, false);
10977
- const peg$e31 = peg$literalExpectation("=", false);
10978
- const peg$e32 = peg$literalExpectation('"', false);
10979
- const peg$e33 = peg$classExpectation(['"'], true, false, false);
10980
- const peg$e34 = peg$literalExpectation("'", false);
10981
- const peg$e35 = peg$classExpectation(["'"], true, false, false);
10982
- const peg$e36 = peg$classExpectation(['"', "'"], false, false, false);
10983
- const peg$e37 = peg$classExpectation([
11019
+ const peg$e34 = peg$literalExpectation("=", false);
11020
+ const peg$e35 = peg$literalExpectation('"', false);
11021
+ const peg$e36 = peg$classExpectation(['"'], true, false, false);
11022
+ const peg$e37 = peg$literalExpectation("'", false);
11023
+ const peg$e38 = peg$classExpectation(["'"], true, false, false);
11024
+ const peg$e39 = peg$classExpectation(['"', "'"], false, false, false);
11025
+ const peg$e40 = peg$classExpectation([
10984
11026
  " ",
10985
11027
  " ",
10986
11028
  "\n",
@@ -10998,7 +11040,7 @@ function peg$parse(input, options) {
10998
11040
  "\uFEFF",
10999
11041
  ">"
11000
11042
  ], true, false, false);
11001
- const peg$e38 = peg$classExpectation([
11043
+ const peg$e41 = peg$classExpectation([
11002
11044
  " ",
11003
11045
  " ",
11004
11046
  "\n",
@@ -11021,68 +11063,71 @@ function peg$parse(input, options) {
11021
11063
  function peg$f1() {
11022
11064
  return !textMode;
11023
11065
  }
11024
- function peg$f2(tag) {
11066
+ function peg$f2() {
11067
+ return !textMode;
11068
+ }
11069
+ function peg$f3(tag) {
11025
11070
  return tag;
11026
11071
  }
11027
- function peg$f3() {
11072
+ function peg$f4() {
11028
11073
  return !textMode;
11029
11074
  }
11030
- function peg$f4(tag) {
11075
+ function peg$f5(tag) {
11031
11076
  return VOID_TAGS.has(tag.lower) ? null : tag;
11032
11077
  }
11033
- function peg$f5(tag) {
11078
+ function peg$f6(tag) {
11034
11079
  rawName = tag.lower;
11035
11080
  return tag.kind === "open" && hooks.isRaw(rawName);
11036
11081
  }
11037
- function peg$f6(tag, b) {
11082
+ function peg$f7(tag, b) {
11038
11083
  return b;
11039
11084
  }
11040
- function peg$f7(tag, body) {
11085
+ function peg$f8(tag, body) {
11041
11086
  return body ? [tag, body] : tag;
11042
11087
  }
11043
- function peg$f8(tag) {
11088
+ function peg$f9(tag) {
11044
11089
  return tag.kind === "close";
11045
11090
  }
11046
- function peg$f9(tag) {
11091
+ function peg$f10(tag) {
11047
11092
  return tag;
11048
11093
  }
11049
- function peg$f10() {
11094
+ function peg$f11() {
11050
11095
  return !textMode;
11051
11096
  }
11052
- function peg$f11(tag) {
11097
+ function peg$f12(tag) {
11053
11098
  return tag;
11054
11099
  }
11055
- function peg$f12(start) {
11100
+ function peg$f13(start) {
11056
11101
  return skipTo(hooks.rawBodyEnd(input, start, rawName));
11057
11102
  }
11058
- function peg$f13(start) {
11103
+ function peg$f14(start) {
11059
11104
  return skipEnd - offset2();
11060
11105
  }
11061
- function peg$f14(start, body, end) {
11106
+ function peg$f15(start, body, end) {
11062
11107
  const loc = {
11063
11108
  start: { offset: start },
11064
11109
  end: { offset: start + body.length }
11065
11110
  };
11066
11111
  return [body ? lexeme("text", loc, { value: body }) : null, end];
11067
11112
  }
11068
- function peg$f15() {
11113
+ function peg$f16() {
11069
11114
  return offset2();
11070
11115
  }
11071
- function peg$f16(value) {
11116
+ function peg$f17(value) {
11072
11117
  return lexeme("text", location(), { value });
11073
11118
  }
11074
- function peg$f17(value) {
11119
+ function peg$f18(value) {
11075
11120
  const node = lexeme("text", location(), { value });
11076
11121
  node.comment = true;
11077
11122
  return node;
11078
11123
  }
11079
- function peg$f18(bs2) {
11124
+ function peg$f19(bs2) {
11080
11125
  return bs2.length % 2 === 1;
11081
11126
  }
11082
- function peg$f19(bs2, c) {
11127
+ function peg$f20(bs2, c) {
11083
11128
  return c;
11084
11129
  }
11085
- function peg$f20(bs2, brace) {
11130
+ function peg$f21(bs2, brace) {
11086
11131
  const loc = location();
11087
11132
  const next = input.charAt(loc.end.offset);
11088
11133
  if (textMode) {
@@ -11099,48 +11144,48 @@ function peg$parse(input, options) {
11099
11144
  escaped.escape = true;
11100
11145
  return bs2.length > 1 ? [before, escaped] : escaped;
11101
11146
  }
11102
- function peg$f21() {
11147
+ function peg$f22() {
11103
11148
  return lexeme("text", location(), { value: LB });
11104
11149
  }
11105
- function peg$f22() {
11150
+ function peg$f23() {
11106
11151
  return !textMode;
11107
11152
  }
11108
- function peg$f23() {
11153
+ function peg$f24() {
11109
11154
  return lexeme("text", location(), { value: "<" });
11110
11155
  }
11111
- function peg$f24() {
11156
+ function peg$f25() {
11112
11157
  return lexeme("text", location(), { value: "[" });
11113
11158
  }
11114
- function peg$f25() {
11159
+ function peg$f26() {
11115
11160
  return !textMode;
11116
11161
  }
11117
- function peg$f26(ss2, s, at3, inner) {
11162
+ function peg$f27(ss2, s, at3, inner) {
11118
11163
  const link = lexeme("link", location(), parseLink(inner, at3, (separator) => linkSeparatorIndex(inner, at3, separator)));
11119
11164
  link.selectorSpan = selectorSpan(s, ss2, at3);
11120
11165
  return withSelectors(link, s);
11121
11166
  }
11122
- function peg$f27() {
11167
+ function peg$f28() {
11123
11168
  return !textMode;
11124
11169
  }
11125
- function peg$f28() {
11170
+ function peg$f29() {
11126
11171
  fail("Unclosed link: [[ without ]]", location(), "unclosed-link");
11127
11172
  }
11128
- function peg$f29(parts) {
11173
+ function peg$f30(parts) {
11129
11174
  return selectorsOf(parts);
11130
11175
  }
11131
- function peg$f30() {
11176
+ function peg$f31() {
11132
11177
  return NO_SELECTORS;
11133
11178
  }
11134
- function peg$f31(s, end) {
11179
+ function peg$f32(s, end) {
11135
11180
  return {
11136
11181
  ...s,
11137
11182
  end
11138
11183
  };
11139
11184
  }
11140
- function peg$f32(prefix, name) {
11185
+ function peg$f33(prefix, name) {
11141
11186
  return [prefix, name];
11142
11187
  }
11143
- function peg$f33(ss2, s, sigil, nameStart, name) {
11188
+ function peg$f34(ss2, s, sigil, nameStart, name) {
11144
11189
  const variable = lexeme("variable", location(), {
11145
11190
  name,
11146
11191
  nameStart,
@@ -11150,7 +11195,7 @@ function peg$parse(input, options) {
11150
11195
  variable.selectorSpan = selectorSpan(s, ss2, nameStart - 1);
11151
11196
  return withSelectors(variable, s);
11152
11197
  }
11153
- function peg$f34(ss2, s, after, expression) {
11198
+ function peg$f35(ss2, s, after, expression) {
11154
11199
  const node = lexeme("expression", location(), {
11155
11200
  expression,
11156
11201
  expressionStart: after,
@@ -11159,28 +11204,28 @@ function peg$parse(input, options) {
11159
11204
  node.selectorSpan = selectorSpan(s, ss2, after);
11160
11205
  return withSelectors(node, s);
11161
11206
  }
11162
- function peg$f35() {
11207
+ function peg$f36() {
11163
11208
  fail("Unclosed {" + input.substr(location().end.offset, 1) + "\u2026: no } ends it", location(), "unclosed-expression");
11164
11209
  }
11165
- function peg$f36(start) {
11210
+ function peg$f37(start) {
11166
11211
  return skipTo(hooks.closeBrace(input, start, start));
11167
11212
  }
11168
- function peg$f37(start) {
11213
+ function peg$f38(start) {
11169
11214
  return skipEnd - offset2();
11170
11215
  }
11171
- function peg$f38(start, code) {
11216
+ function peg$f39(start, code) {
11172
11217
  return code;
11173
11218
  }
11174
- function peg$f39(ss2, s, start, close, name, nameEnd) {
11219
+ function peg$f40(ss2, s, start, close, name, nameEnd) {
11175
11220
  return skipTo(hooks.closeBrace(input, nameEnd, start));
11176
11221
  }
11177
- function peg$f40(ss2, s, start, close, name, nameEnd) {
11222
+ function peg$f41(ss2, s, start, close, name, nameEnd) {
11178
11223
  return skipEnd - offset2();
11179
11224
  }
11180
- function peg$f41(ss2, s, start, close, name, nameEnd, args2) {
11225
+ function peg$f42(ss2, s, start, close, name, nameEnd, args2) {
11181
11226
  return args2;
11182
11227
  }
11183
- function peg$f42(ss2, s, start, close, name, nameEnd, tail) {
11228
+ function peg$f43(ss2, s, start, close, name, nameEnd, tail) {
11184
11229
  const loc = location();
11185
11230
  const lower = name.toLowerCase();
11186
11231
  const tag = lexeme("macro", loc, {
@@ -11206,16 +11251,19 @@ function peg$parse(input, options) {
11206
11251
  }
11207
11252
  return tag;
11208
11253
  }
11209
- function peg$f43(s) {
11254
+ function peg$f44(s) {
11210
11255
  fail("A closing tag starts with a letter after {/", location(), "invalid-closer");
11211
11256
  }
11212
- function peg$f44(value) {
11257
+ function peg$f45(value) {
11213
11258
  return EMAIL_AUTOLINK.test(value);
11214
11259
  }
11215
- function peg$f45(value) {
11260
+ function peg$f46(value) {
11261
+ return lexeme("text", location(), { value });
11262
+ }
11263
+ function peg$f47(value) {
11216
11264
  return lexeme("text", location(), { value });
11217
11265
  }
11218
- function peg$f46(tagStart, tag, list3, slash) {
11266
+ function peg$f48(tagStart, tag, list3, slash) {
11219
11267
  const lower = tag.toLowerCase();
11220
11268
  return lexeme("html", location(), {
11221
11269
  tag,
@@ -11228,7 +11276,7 @@ function peg$parse(input, options) {
11228
11276
  isSelfClose: !!slash || VOID_TAGS.has(lower)
11229
11277
  });
11230
11278
  }
11231
- function peg$f47(tag, bad) {
11279
+ function peg$f49(tag, bad) {
11232
11280
  const c = input.charAt(bad);
11233
11281
  if (!c) fail("Unclosed tag <" + tag + ": no > ends it (write &lt; for a < that starts no tag)", location(), "unclosed-tag");
11234
11282
  const at3 = {
@@ -11246,7 +11294,7 @@ function peg$parse(input, options) {
11246
11294
  };
11247
11295
  fail("Unexpected " + JSON.stringify(c) + " in the tag <" + tag + ">: expected an attribute, or > to end the tag", at3, "unexpected-character");
11248
11296
  }
11249
- function peg$f48(tagStart, tag) {
11297
+ function peg$f50(tagStart, tag) {
11250
11298
  return lexeme("html", location(), {
11251
11299
  tag,
11252
11300
  lower: tag.toLowerCase(),
@@ -11258,14 +11306,14 @@ function peg$parse(input, options) {
11258
11306
  isSelfClose: false
11259
11307
  });
11260
11308
  }
11261
- function peg$f49(nameStart, name) {
11309
+ function peg$f51(nameStart, name) {
11262
11310
  attrCode = hooks.isCodeAttribute(name);
11263
11311
  return true;
11264
11312
  }
11265
- function peg$f50(nameStart, name, v2) {
11313
+ function peg$f52(nameStart, name, v2) {
11266
11314
  return v2;
11267
11315
  }
11268
- function peg$f51(nameStart, name, value) {
11316
+ function peg$f53(nameStart, name, value) {
11269
11317
  const attribute = {
11270
11318
  name,
11271
11319
  value: value ? value.value : "",
@@ -11279,7 +11327,7 @@ function peg$parse(input, options) {
11279
11327
  }
11280
11328
  return attribute;
11281
11329
  }
11282
- function peg$f52(start, value, end) {
11330
+ function peg$f54(start, value, end) {
11283
11331
  return {
11284
11332
  value,
11285
11333
  start,
@@ -11287,7 +11335,7 @@ function peg$parse(input, options) {
11287
11335
  quote: '"'
11288
11336
  };
11289
11337
  }
11290
- function peg$f53(start, value, end) {
11338
+ function peg$f55(start, value, end) {
11291
11339
  return {
11292
11340
  value,
11293
11341
  start,
@@ -11295,35 +11343,35 @@ function peg$parse(input, options) {
11295
11343
  quote: "'"
11296
11344
  };
11297
11345
  }
11298
- function peg$f54(q2) {
11346
+ function peg$f56(q2) {
11299
11347
  fail("Unclosed attribute value: the " + q2 + " here has no closing " + q2, location(), "unclosed-attribute");
11300
11348
  }
11301
- function peg$f55(start, value, end) {
11349
+ function peg$f57(start, value, end) {
11302
11350
  return {
11303
11351
  value,
11304
11352
  start,
11305
11353
  end
11306
11354
  };
11307
11355
  }
11308
- function peg$f56() {
11356
+ function peg$f58() {
11309
11357
  return !attrCode;
11310
11358
  }
11311
- function peg$f57(bs2) {
11359
+ function peg$f59(bs2) {
11312
11360
  return bs2.length % 2 === 1;
11313
11361
  }
11314
- function peg$f58() {
11362
+ function peg$f60() {
11315
11363
  return !attrCode;
11316
11364
  }
11317
- function peg$f59(start, nameEnd) {
11365
+ function peg$f61(start, nameEnd) {
11318
11366
  return skipTo(hooks.closeBrace(input, nameEnd, start));
11319
11367
  }
11320
- function peg$f60(start, nameEnd) {
11368
+ function peg$f62(start, nameEnd) {
11321
11369
  return skipEnd - offset2();
11322
11370
  }
11323
- function peg$f61() {
11371
+ function peg$f63() {
11324
11372
  return !attrCode;
11325
11373
  }
11326
- function peg$f62() {
11374
+ function peg$f64() {
11327
11375
  return attrCode;
11328
11376
  }
11329
11377
  let peg$currPos = options.peg$currPos | 0;
@@ -11471,10 +11519,10 @@ function peg$parse(input, options) {
11471
11519
  if (s1) s1 = void 0;
11472
11520
  else s1 = peg$FAILED;
11473
11521
  if (s1 !== peg$FAILED) {
11474
- s2 = peg$parseHtmlOpen();
11522
+ s2 = peg$parseUriAutolink();
11475
11523
  if (s2 !== peg$FAILED) {
11476
- peg$savedPos = s0;
11477
- s0 = peg$f2(s2);
11524
+ s1 = [s1, s2];
11525
+ s0 = s1;
11478
11526
  } else {
11479
11527
  peg$currPos = s0;
11480
11528
  s0 = peg$FAILED;
@@ -11486,14 +11534,14 @@ function peg$parse(input, options) {
11486
11534
  if (s0 === peg$FAILED) {
11487
11535
  s0 = peg$currPos;
11488
11536
  peg$savedPos = peg$currPos;
11489
- s1 = peg$f3();
11537
+ s1 = peg$f2();
11490
11538
  if (s1) s1 = void 0;
11491
11539
  else s1 = peg$FAILED;
11492
11540
  if (s1 !== peg$FAILED) {
11493
- s2 = peg$parseHtmlClose();
11541
+ s2 = peg$parseHtmlOpen();
11494
11542
  if (s2 !== peg$FAILED) {
11495
11543
  peg$savedPos = s0;
11496
- s0 = peg$f4(s2);
11544
+ s0 = peg$f3(s2);
11497
11545
  } else {
11498
11546
  peg$currPos = s0;
11499
11547
  s0 = peg$FAILED;
@@ -11503,37 +11551,57 @@ function peg$parse(input, options) {
11503
11551
  s0 = peg$FAILED;
11504
11552
  }
11505
11553
  if (s0 === peg$FAILED) {
11506
- s0 = peg$parseValue();
11554
+ s0 = peg$currPos;
11555
+ peg$savedPos = peg$currPos;
11556
+ s1 = peg$f4();
11557
+ if (s1) s1 = void 0;
11558
+ else s1 = peg$FAILED;
11559
+ if (s1 !== peg$FAILED) {
11560
+ s2 = peg$parseHtmlClose();
11561
+ if (s2 !== peg$FAILED) {
11562
+ peg$savedPos = s0;
11563
+ s0 = peg$f5(s2);
11564
+ } else {
11565
+ peg$currPos = s0;
11566
+ s0 = peg$FAILED;
11567
+ }
11568
+ } else {
11569
+ peg$currPos = s0;
11570
+ s0 = peg$FAILED;
11571
+ }
11507
11572
  if (s0 === peg$FAILED) {
11508
- s0 = peg$currPos;
11509
- s1 = peg$parseMacroTag();
11510
- if (s1 !== peg$FAILED) {
11511
- s2 = peg$currPos;
11512
- peg$savedPos = peg$currPos;
11513
- s3 = peg$f5(s1);
11514
- if (s3) s3 = void 0;
11515
- else s3 = peg$FAILED;
11516
- if (s3 !== peg$FAILED) {
11517
- s4 = peg$parseRawTokens();
11518
- if (s4 !== peg$FAILED) {
11519
- peg$savedPos = s2;
11520
- s2 = peg$f6(s1, s4);
11573
+ s0 = peg$parseValue();
11574
+ if (s0 === peg$FAILED) {
11575
+ s0 = peg$currPos;
11576
+ s1 = peg$parseMacroTag();
11577
+ if (s1 !== peg$FAILED) {
11578
+ s2 = peg$currPos;
11579
+ peg$savedPos = peg$currPos;
11580
+ s3 = peg$f6(s1);
11581
+ if (s3) s3 = void 0;
11582
+ else s3 = peg$FAILED;
11583
+ if (s3 !== peg$FAILED) {
11584
+ s4 = peg$parseRawTokens();
11585
+ if (s4 !== peg$FAILED) {
11586
+ peg$savedPos = s2;
11587
+ s2 = peg$f7(s1, s4);
11588
+ } else {
11589
+ peg$currPos = s2;
11590
+ s2 = peg$FAILED;
11591
+ }
11521
11592
  } else {
11522
11593
  peg$currPos = s2;
11523
11594
  s2 = peg$FAILED;
11524
11595
  }
11596
+ if (s2 === peg$FAILED) s2 = null;
11597
+ peg$savedPos = s0;
11598
+ s0 = peg$f8(s1, s2);
11525
11599
  } else {
11526
- peg$currPos = s2;
11527
- s2 = peg$FAILED;
11600
+ peg$currPos = s0;
11601
+ s0 = peg$FAILED;
11528
11602
  }
11529
- if (s2 === peg$FAILED) s2 = null;
11530
- peg$savedPos = s0;
11531
- s0 = peg$f7(s1, s2);
11532
- } else {
11533
- peg$currPos = s0;
11534
- s0 = peg$FAILED;
11603
+ if (s0 === peg$FAILED) s0 = peg$parseLiteral();
11535
11604
  }
11536
- if (s0 === peg$FAILED) s0 = peg$parseLiteral();
11537
11605
  }
11538
11606
  }
11539
11607
  }
@@ -11550,12 +11618,12 @@ function peg$parse(input, options) {
11550
11618
  s1 = peg$parseMacroTag();
11551
11619
  if (s1 !== peg$FAILED) {
11552
11620
  peg$savedPos = peg$currPos;
11553
- s2 = peg$f8(s1);
11621
+ s2 = peg$f9(s1);
11554
11622
  if (s2) s2 = void 0;
11555
11623
  else s2 = peg$FAILED;
11556
11624
  if (s2 !== peg$FAILED) {
11557
11625
  peg$savedPos = s0;
11558
- s0 = peg$f9(s1);
11626
+ s0 = peg$f10(s1);
11559
11627
  } else {
11560
11628
  peg$currPos = s0;
11561
11629
  s0 = peg$FAILED;
@@ -11567,14 +11635,14 @@ function peg$parse(input, options) {
11567
11635
  if (s0 === peg$FAILED) {
11568
11636
  s0 = peg$currPos;
11569
11637
  peg$savedPos = peg$currPos;
11570
- s1 = peg$f10();
11638
+ s1 = peg$f11();
11571
11639
  if (s1) s1 = void 0;
11572
11640
  else s1 = peg$FAILED;
11573
11641
  if (s1 !== peg$FAILED) {
11574
11642
  s2 = peg$parseHtmlClose();
11575
11643
  if (s2 !== peg$FAILED) {
11576
11644
  peg$savedPos = s0;
11577
- s0 = peg$f11(s2);
11645
+ s0 = peg$f12(s2);
11578
11646
  } else {
11579
11647
  peg$currPos = s0;
11580
11648
  s0 = peg$FAILED;
@@ -11591,12 +11659,12 @@ function peg$parse(input, options) {
11591
11659
  s0 = peg$currPos;
11592
11660
  s1 = peg$parseHere();
11593
11661
  peg$savedPos = peg$currPos;
11594
- s2 = peg$f12(s1);
11662
+ s2 = peg$f13(s1);
11595
11663
  if (s2) s2 = void 0;
11596
11664
  else s2 = peg$FAILED;
11597
11665
  if (s2 !== peg$FAILED) {
11598
11666
  s3 = peg$currPos;
11599
- s4 = peg$f13(s1);
11667
+ s4 = peg$f14(s1);
11600
11668
  s5 = peg$currPos;
11601
11669
  s6 = [];
11602
11670
  if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
@@ -11629,7 +11697,7 @@ function peg$parse(input, options) {
11629
11697
  s4 = peg$parseCloseTag();
11630
11698
  if (s4 !== peg$FAILED) {
11631
11699
  peg$savedPos = s0;
11632
- s0 = peg$f14(s1, s3, s4);
11700
+ s0 = peg$f15(s1, s3, s4);
11633
11701
  } else {
11634
11702
  peg$currPos = s0;
11635
11703
  s0 = peg$FAILED;
@@ -11649,7 +11717,7 @@ function peg$parse(input, options) {
11649
11717
  s0 = peg$currPos;
11650
11718
  s1 = "";
11651
11719
  peg$savedPos = s0;
11652
- s1 = peg$f15();
11720
+ s1 = peg$f16();
11653
11721
  s0 = s1;
11654
11722
  return s0;
11655
11723
  }
@@ -11678,7 +11746,7 @@ function peg$parse(input, options) {
11678
11746
  else s1 = s2;
11679
11747
  if (s1 !== peg$FAILED) {
11680
11748
  peg$savedPos = s0;
11681
- s1 = peg$f16(s1);
11749
+ s1 = peg$f17(s1);
11682
11750
  }
11683
11751
  s0 = s1;
11684
11752
  return s0;
@@ -11818,7 +11886,7 @@ function peg$parse(input, options) {
11818
11886
  else s1 = s2;
11819
11887
  if (s1 !== peg$FAILED) {
11820
11888
  peg$savedPos = s0;
11821
- s1 = peg$f17(s1);
11889
+ s1 = peg$f18(s1);
11822
11890
  }
11823
11891
  s0 = s1;
11824
11892
  return s0;
@@ -11851,7 +11919,7 @@ function peg$parse(input, options) {
11851
11919
  if (s1 !== peg$FAILED) {
11852
11920
  s2 = peg$currPos;
11853
11921
  peg$savedPos = peg$currPos;
11854
- s3 = peg$f18(s1);
11922
+ s3 = peg$f19(s1);
11855
11923
  if (s3) s3 = void 0;
11856
11924
  else s3 = peg$FAILED;
11857
11925
  if (s3 !== peg$FAILED) {
@@ -11863,7 +11931,7 @@ function peg$parse(input, options) {
11863
11931
  }
11864
11932
  if (s4 !== peg$FAILED) {
11865
11933
  peg$savedPos = s2;
11866
- s2 = peg$f19(s1, s4);
11934
+ s2 = peg$f20(s1, s4);
11867
11935
  } else {
11868
11936
  peg$currPos = s2;
11869
11937
  s2 = peg$FAILED;
@@ -11874,7 +11942,7 @@ function peg$parse(input, options) {
11874
11942
  }
11875
11943
  if (s2 === peg$FAILED) s2 = null;
11876
11944
  peg$savedPos = s0;
11877
- s0 = peg$f20(s1, s2);
11945
+ s0 = peg$f21(s1, s2);
11878
11946
  } else {
11879
11947
  peg$currPos = s0;
11880
11948
  s0 = peg$FAILED;
@@ -11922,7 +11990,7 @@ function peg$parse(input, options) {
11922
11990
  }
11923
11991
  if (s2 !== peg$FAILED) {
11924
11992
  peg$savedPos = s0;
11925
- s0 = peg$f21();
11993
+ s0 = peg$f22();
11926
11994
  } else {
11927
11995
  peg$currPos = s0;
11928
11996
  s0 = peg$FAILED;
@@ -11937,7 +12005,7 @@ function peg$parse(input, options) {
11937
12005
  peg$silentFails++;
11938
12006
  s2 = peg$currPos;
11939
12007
  peg$savedPos = peg$currPos;
11940
- s3 = peg$f22();
12008
+ s3 = peg$f23();
11941
12009
  if (s3) s3 = void 0;
11942
12010
  else s3 = peg$FAILED;
11943
12011
  if (s3 !== peg$FAILED) {
@@ -11969,7 +12037,7 @@ function peg$parse(input, options) {
11969
12037
  }
11970
12038
  if (s2 !== peg$FAILED) {
11971
12039
  peg$savedPos = s0;
11972
- s0 = peg$f23();
12040
+ s0 = peg$f24();
11973
12041
  } else {
11974
12042
  peg$currPos = s0;
11975
12043
  s0 = peg$FAILED;
@@ -11989,7 +12057,7 @@ function peg$parse(input, options) {
11989
12057
  }
11990
12058
  if (s1 !== peg$FAILED) {
11991
12059
  peg$savedPos = s0;
11992
- s1 = peg$f24();
12060
+ s1 = peg$f25();
11993
12061
  }
11994
12062
  s0 = s1;
11995
12063
  }
@@ -12000,7 +12068,7 @@ function peg$parse(input, options) {
12000
12068
  let s0, s1, s2, s3, s4, s5, s6, s7;
12001
12069
  s0 = peg$currPos;
12002
12070
  peg$savedPos = peg$currPos;
12003
- s1 = peg$f25();
12071
+ s1 = peg$f26();
12004
12072
  if (s1) s1 = void 0;
12005
12073
  else s1 = peg$FAILED;
12006
12074
  if (s1 !== peg$FAILED) {
@@ -12028,7 +12096,7 @@ function peg$parse(input, options) {
12028
12096
  }
12029
12097
  if (s7 !== peg$FAILED) {
12030
12098
  peg$savedPos = s0;
12031
- s0 = peg$f26(s3, s4, s5, s6);
12099
+ s0 = peg$f27(s3, s4, s5, s6);
12032
12100
  } else {
12033
12101
  peg$currPos = s0;
12034
12102
  s0 = peg$FAILED;
@@ -12048,7 +12116,7 @@ function peg$parse(input, options) {
12048
12116
  if (s0 === peg$FAILED) {
12049
12117
  s0 = peg$currPos;
12050
12118
  peg$savedPos = peg$currPos;
12051
- s1 = peg$f27();
12119
+ s1 = peg$f28();
12052
12120
  if (s1) s1 = void 0;
12053
12121
  else s1 = peg$FAILED;
12054
12122
  if (s1 !== peg$FAILED) {
@@ -12061,7 +12129,7 @@ function peg$parse(input, options) {
12061
12129
  }
12062
12130
  if (s2 !== peg$FAILED) {
12063
12131
  peg$savedPos = s0;
12064
- s0 = peg$f28();
12132
+ s0 = peg$f29();
12065
12133
  } else {
12066
12134
  peg$currPos = s0;
12067
12135
  s0 = peg$FAILED;
@@ -12189,7 +12257,7 @@ function peg$parse(input, options) {
12189
12257
  }
12190
12258
  if (s2 === peg$FAILED) s2 = null;
12191
12259
  peg$savedPos = s0;
12192
- s0 = peg$f29(s1);
12260
+ s0 = peg$f30(s1);
12193
12261
  } else {
12194
12262
  peg$currPos = s0;
12195
12263
  s0 = peg$FAILED;
@@ -12198,7 +12266,7 @@ function peg$parse(input, options) {
12198
12266
  s0 = peg$currPos;
12199
12267
  s1 = "";
12200
12268
  peg$savedPos = s0;
12201
- s1 = peg$f30();
12269
+ s1 = peg$f31();
12202
12270
  s0 = s1;
12203
12271
  }
12204
12272
  return s0;
@@ -12228,7 +12296,7 @@ function peg$parse(input, options) {
12228
12296
  }
12229
12297
  }
12230
12298
  peg$savedPos = s0;
12231
- s0 = peg$f31(s1, s2);
12299
+ s0 = peg$f32(s1, s2);
12232
12300
  } else {
12233
12301
  peg$currPos = s0;
12234
12302
  s0 = peg$FAILED;
@@ -12254,7 +12322,7 @@ function peg$parse(input, options) {
12254
12322
  }
12255
12323
  s2 = input.substring(s2, peg$currPos);
12256
12324
  peg$savedPos = s0;
12257
- s0 = peg$f32(s1, s2);
12325
+ s0 = peg$f33(s1, s2);
12258
12326
  } else {
12259
12327
  peg$currPos = s0;
12260
12328
  s0 = peg$FAILED;
@@ -12381,7 +12449,7 @@ function peg$parse(input, options) {
12381
12449
  }
12382
12450
  if (s7 !== peg$FAILED) {
12383
12451
  peg$savedPos = s0;
12384
- s0 = peg$f33(s2, s3, s4, s5, s6);
12452
+ s0 = peg$f34(s2, s3, s4, s5, s6);
12385
12453
  } else {
12386
12454
  peg$currPos = s0;
12387
12455
  s0 = peg$FAILED;
@@ -12437,7 +12505,7 @@ function peg$parse(input, options) {
12437
12505
  }
12438
12506
  if (s7 !== peg$FAILED) {
12439
12507
  peg$savedPos = s0;
12440
- s0 = peg$f34(s2, s3, s4, s6);
12508
+ s0 = peg$f35(s2, s3, s4, s6);
12441
12509
  } else {
12442
12510
  peg$currPos = s0;
12443
12511
  s0 = peg$FAILED;
@@ -12485,7 +12553,7 @@ function peg$parse(input, options) {
12485
12553
  } else s3 = peg$FAILED;
12486
12554
  if (s3 !== peg$FAILED) {
12487
12555
  peg$savedPos = s0;
12488
- s0 = peg$f35();
12556
+ s0 = peg$f36();
12489
12557
  } else {
12490
12558
  peg$currPos = s0;
12491
12559
  s0 = peg$FAILED;
@@ -12507,12 +12575,12 @@ function peg$parse(input, options) {
12507
12575
  s0 = peg$currPos;
12508
12576
  s1 = peg$parseHere();
12509
12577
  peg$savedPos = peg$currPos;
12510
- s2 = peg$f36(s1);
12578
+ s2 = peg$f37(s1);
12511
12579
  if (s2) s2 = void 0;
12512
12580
  else s2 = peg$FAILED;
12513
12581
  if (s2 !== peg$FAILED) {
12514
12582
  s3 = peg$currPos;
12515
- s4 = peg$f37(s1);
12583
+ s4 = peg$f38(s1);
12516
12584
  s5 = peg$currPos;
12517
12585
  s6 = [];
12518
12586
  if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
@@ -12543,7 +12611,7 @@ function peg$parse(input, options) {
12543
12611
  else s3 = s4;
12544
12612
  if (s3 !== peg$FAILED) {
12545
12613
  peg$savedPos = s0;
12546
- s0 = peg$f38(s1, s3);
12614
+ s0 = peg$f39(s1, s3);
12547
12615
  } else {
12548
12616
  peg$currPos = s0;
12549
12617
  s0 = peg$FAILED;
@@ -12582,12 +12650,12 @@ function peg$parse(input, options) {
12582
12650
  s7 = peg$parseHere();
12583
12651
  s8 = peg$currPos;
12584
12652
  peg$savedPos = peg$currPos;
12585
- s9 = peg$f39(s2, s3, s4, s5, s6, s7);
12653
+ s9 = peg$f40(s2, s3, s4, s5, s6, s7);
12586
12654
  if (s9) s9 = void 0;
12587
12655
  else s9 = peg$FAILED;
12588
12656
  if (s9 !== peg$FAILED) {
12589
12657
  s10 = peg$currPos;
12590
- s11 = peg$f40(s2, s3, s4, s5, s6, s7);
12658
+ s11 = peg$f41(s2, s3, s4, s5, s6, s7);
12591
12659
  s12 = peg$currPos;
12592
12660
  s13 = [];
12593
12661
  if (s13.length >= (s11 | 0)) s14 = peg$FAILED;
@@ -12626,7 +12694,7 @@ function peg$parse(input, options) {
12626
12694
  }
12627
12695
  if (s11 !== peg$FAILED) {
12628
12696
  peg$savedPos = s8;
12629
- s8 = peg$f41(s2, s3, s4, s5, s6, s7, s10);
12697
+ s8 = peg$f42(s2, s3, s4, s5, s6, s7, s10);
12630
12698
  } else {
12631
12699
  peg$currPos = s8;
12632
12700
  s8 = peg$FAILED;
@@ -12641,7 +12709,7 @@ function peg$parse(input, options) {
12641
12709
  }
12642
12710
  if (s8 === peg$FAILED) s8 = null;
12643
12711
  peg$savedPos = s0;
12644
- s0 = peg$f42(s2, s3, s4, s5, s6, s7, s8);
12712
+ s0 = peg$f43(s2, s3, s4, s5, s6, s7, s8);
12645
12713
  } else {
12646
12714
  peg$currPos = s0;
12647
12715
  s0 = peg$FAILED;
@@ -12675,7 +12743,7 @@ function peg$parse(input, options) {
12675
12743
  }
12676
12744
  if (s3 !== peg$FAILED) {
12677
12745
  peg$savedPos = s0;
12678
- s0 = peg$f43(s2);
12746
+ s0 = peg$f44(s2);
12679
12747
  } else {
12680
12748
  peg$currPos = s0;
12681
12749
  s0 = peg$FAILED;
@@ -12825,12 +12893,12 @@ function peg$parse(input, options) {
12825
12893
  else s1 = s2;
12826
12894
  if (s1 !== peg$FAILED) {
12827
12895
  peg$savedPos = peg$currPos;
12828
- s2 = peg$f44(s1);
12896
+ s2 = peg$f45(s1);
12829
12897
  if (s2) s2 = void 0;
12830
12898
  else s2 = peg$FAILED;
12831
12899
  if (s2 !== peg$FAILED) {
12832
12900
  peg$savedPos = s0;
12833
- s0 = peg$f45(s1);
12901
+ s0 = peg$f46(s1);
12834
12902
  } else {
12835
12903
  peg$currPos = s0;
12836
12904
  s0 = peg$FAILED;
@@ -12841,6 +12909,177 @@ function peg$parse(input, options) {
12841
12909
  }
12842
12910
  return s0;
12843
12911
  }
12912
+ function peg$parseUriAutolink() {
12913
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
12914
+ s0 = peg$currPos;
12915
+ s1 = peg$currPos;
12916
+ s2 = peg$currPos;
12917
+ if (input.charCodeAt(peg$currPos) === 60) {
12918
+ s3 = peg$c6;
12919
+ peg$currPos++;
12920
+ } else {
12921
+ s3 = peg$FAILED;
12922
+ if (peg$silentFails === 0) peg$fail(peg$e10);
12923
+ }
12924
+ if (s3 !== peg$FAILED) {
12925
+ s4 = input.charAt(peg$currPos);
12926
+ if (peg$r8.test(s4)) peg$currPos++;
12927
+ else {
12928
+ s4 = peg$FAILED;
12929
+ if (peg$silentFails === 0) peg$fail(peg$e22);
12930
+ }
12931
+ if (s4 !== peg$FAILED) {
12932
+ s5 = peg$currPos;
12933
+ s6 = [];
12934
+ s7 = input.charAt(peg$currPos);
12935
+ if (peg$r12.test(s7)) peg$currPos++;
12936
+ else {
12937
+ s7 = peg$FAILED;
12938
+ if (peg$silentFails === 0) peg$fail(peg$e27);
12939
+ }
12940
+ while (s7 !== peg$FAILED) {
12941
+ s6.push(s7);
12942
+ if (s6.length >= 31) s7 = peg$FAILED;
12943
+ else {
12944
+ s7 = input.charAt(peg$currPos);
12945
+ if (peg$r12.test(s7)) peg$currPos++;
12946
+ else {
12947
+ s7 = peg$FAILED;
12948
+ if (peg$silentFails === 0) peg$fail(peg$e27);
12949
+ }
12950
+ }
12951
+ }
12952
+ if (s6.length < 1) {
12953
+ peg$currPos = s5;
12954
+ s5 = peg$FAILED;
12955
+ } else s5 = s6;
12956
+ if (s5 !== peg$FAILED) {
12957
+ if (input.charCodeAt(peg$currPos) === 58) {
12958
+ s6 = peg$c14;
12959
+ peg$currPos++;
12960
+ } else {
12961
+ s6 = peg$FAILED;
12962
+ if (peg$silentFails === 0) peg$fail(peg$e28);
12963
+ }
12964
+ if (s6 !== peg$FAILED) {
12965
+ s7 = [];
12966
+ s8 = peg$currPos;
12967
+ s9 = peg$currPos;
12968
+ peg$silentFails++;
12969
+ if (input.substr(peg$currPos, 2) === peg$c8) {
12970
+ s10 = peg$c8;
12971
+ peg$currPos += 2;
12972
+ } else {
12973
+ s10 = peg$FAILED;
12974
+ if (peg$silentFails === 0) peg$fail(peg$e12);
12975
+ }
12976
+ peg$silentFails--;
12977
+ if (s10 === peg$FAILED) s9 = void 0;
12978
+ else {
12979
+ peg$currPos = s9;
12980
+ s9 = peg$FAILED;
12981
+ }
12982
+ if (s9 !== peg$FAILED) {
12983
+ s10 = input.charAt(peg$currPos);
12984
+ if (peg$r13.test(s10)) peg$currPos++;
12985
+ else {
12986
+ s10 = peg$FAILED;
12987
+ if (peg$silentFails === 0) peg$fail(peg$e29);
12988
+ }
12989
+ if (s10 !== peg$FAILED) {
12990
+ s9 = [s9, s10];
12991
+ s8 = s9;
12992
+ } else {
12993
+ peg$currPos = s8;
12994
+ s8 = peg$FAILED;
12995
+ }
12996
+ } else {
12997
+ peg$currPos = s8;
12998
+ s8 = peg$FAILED;
12999
+ }
13000
+ while (s8 !== peg$FAILED) {
13001
+ s7.push(s8);
13002
+ s8 = peg$currPos;
13003
+ s9 = peg$currPos;
13004
+ peg$silentFails++;
13005
+ if (input.substr(peg$currPos, 2) === peg$c8) {
13006
+ s10 = peg$c8;
13007
+ peg$currPos += 2;
13008
+ } else {
13009
+ s10 = peg$FAILED;
13010
+ if (peg$silentFails === 0) peg$fail(peg$e12);
13011
+ }
13012
+ peg$silentFails--;
13013
+ if (s10 === peg$FAILED) s9 = void 0;
13014
+ else {
13015
+ peg$currPos = s9;
13016
+ s9 = peg$FAILED;
13017
+ }
13018
+ if (s9 !== peg$FAILED) {
13019
+ s10 = input.charAt(peg$currPos);
13020
+ if (peg$r13.test(s10)) peg$currPos++;
13021
+ else {
13022
+ s10 = peg$FAILED;
13023
+ if (peg$silentFails === 0) peg$fail(peg$e29);
13024
+ }
13025
+ if (s10 !== peg$FAILED) {
13026
+ s9 = [s9, s10];
13027
+ s8 = s9;
13028
+ } else {
13029
+ peg$currPos = s8;
13030
+ s8 = peg$FAILED;
13031
+ }
13032
+ } else {
13033
+ peg$currPos = s8;
13034
+ s8 = peg$FAILED;
13035
+ }
13036
+ }
13037
+ if (input.charCodeAt(peg$currPos) === 62) {
13038
+ s8 = peg$c1;
13039
+ peg$currPos++;
13040
+ } else {
13041
+ s8 = peg$FAILED;
13042
+ if (peg$silentFails === 0) peg$fail(peg$e3);
13043
+ }
13044
+ if (s8 !== peg$FAILED) {
13045
+ s3 = [
13046
+ s3,
13047
+ s4,
13048
+ s5,
13049
+ s6,
13050
+ s7,
13051
+ s8
13052
+ ];
13053
+ s2 = s3;
13054
+ } else {
13055
+ peg$currPos = s2;
13056
+ s2 = peg$FAILED;
13057
+ }
13058
+ } else {
13059
+ peg$currPos = s2;
13060
+ s2 = peg$FAILED;
13061
+ }
13062
+ } else {
13063
+ peg$currPos = s2;
13064
+ s2 = peg$FAILED;
13065
+ }
13066
+ } else {
13067
+ peg$currPos = s2;
13068
+ s2 = peg$FAILED;
13069
+ }
13070
+ } else {
13071
+ peg$currPos = s2;
13072
+ s2 = peg$FAILED;
13073
+ }
13074
+ if (s2 !== peg$FAILED) s1 = input.substring(s1, peg$currPos);
13075
+ else s1 = s2;
13076
+ if (s1 !== peg$FAILED) {
13077
+ peg$savedPos = s0;
13078
+ s1 = peg$f47(s1);
13079
+ }
13080
+ s0 = s1;
13081
+ return s0;
13082
+ }
12844
13083
  function peg$parseHtmlOpen() {
12845
13084
  let s0, s1, s2, s3, s4, s5, s6, s7;
12846
13085
  s0 = peg$currPos;
@@ -12879,7 +13118,7 @@ function peg$parse(input, options) {
12879
13118
  }
12880
13119
  if (s7 !== peg$FAILED) {
12881
13120
  peg$savedPos = s0;
12882
- s0 = peg$f46(s2, s3, s4, s6);
13121
+ s0 = peg$f48(s2, s3, s4, s6);
12883
13122
  } else {
12884
13123
  peg$currPos = s0;
12885
13124
  s0 = peg$FAILED;
@@ -12907,10 +13146,10 @@ function peg$parse(input, options) {
12907
13146
  s3 = peg$currPos;
12908
13147
  peg$silentFails++;
12909
13148
  s4 = input.charAt(peg$currPos);
12910
- if (peg$r12.test(s4)) peg$currPos++;
13149
+ if (peg$r14.test(s4)) peg$currPos++;
12911
13150
  else {
12912
13151
  s4 = peg$FAILED;
12913
- if (peg$silentFails === 0) peg$fail(peg$e27);
13152
+ if (peg$silentFails === 0) peg$fail(peg$e30);
12914
13153
  }
12915
13154
  if (s4 === peg$FAILED) {
12916
13155
  s4 = peg$currPos;
@@ -12944,7 +13183,7 @@ function peg$parse(input, options) {
12944
13183
  s5 = peg$parse_();
12945
13184
  s6 = peg$parseHere();
12946
13185
  peg$savedPos = s0;
12947
- s0 = peg$f47(s2, s6);
13186
+ s0 = peg$f49(s2, s6);
12948
13187
  } else {
12949
13188
  peg$currPos = s0;
12950
13189
  s0 = peg$FAILED;
@@ -12963,12 +13202,12 @@ function peg$parse(input, options) {
12963
13202
  function peg$parseHtmlClose() {
12964
13203
  let s0, s1, s2, s3, s5;
12965
13204
  s0 = peg$currPos;
12966
- if (input.substr(peg$currPos, 2) === peg$c14) {
12967
- s1 = peg$c14;
13205
+ if (input.substr(peg$currPos, 2) === peg$c15) {
13206
+ s1 = peg$c15;
12968
13207
  peg$currPos += 2;
12969
13208
  } else {
12970
13209
  s1 = peg$FAILED;
12971
- if (peg$silentFails === 0) peg$fail(peg$e28);
13210
+ if (peg$silentFails === 0) peg$fail(peg$e31);
12972
13211
  }
12973
13212
  if (s1 !== peg$FAILED) {
12974
13213
  s2 = peg$parseHere();
@@ -12984,7 +13223,7 @@ function peg$parse(input, options) {
12984
13223
  }
12985
13224
  if (s5 !== peg$FAILED) {
12986
13225
  peg$savedPos = s0;
12987
- s0 = peg$f48(s2, s3);
13226
+ s0 = peg$f50(s2, s3);
12988
13227
  } else {
12989
13228
  peg$currPos = s0;
12990
13229
  s0 = peg$FAILED;
@@ -13012,18 +13251,18 @@ function peg$parse(input, options) {
13012
13251
  if (s2 !== peg$FAILED) {
13013
13252
  s3 = [];
13014
13253
  s4 = input.charAt(peg$currPos);
13015
- if (peg$r13.test(s4)) peg$currPos++;
13254
+ if (peg$r15.test(s4)) peg$currPos++;
13016
13255
  else {
13017
13256
  s4 = peg$FAILED;
13018
- if (peg$silentFails === 0) peg$fail(peg$e29);
13257
+ if (peg$silentFails === 0) peg$fail(peg$e32);
13019
13258
  }
13020
13259
  while (s4 !== peg$FAILED) {
13021
13260
  s3.push(s4);
13022
13261
  s4 = input.charAt(peg$currPos);
13023
- if (peg$r13.test(s4)) peg$currPos++;
13262
+ if (peg$r15.test(s4)) peg$currPos++;
13024
13263
  else {
13025
13264
  s4 = peg$FAILED;
13026
- if (peg$silentFails === 0) peg$fail(peg$e29);
13265
+ if (peg$silentFails === 0) peg$fail(peg$e32);
13027
13266
  }
13028
13267
  }
13029
13268
  s2 = [s2, s3];
@@ -13047,10 +13286,10 @@ function peg$parse(input, options) {
13047
13286
  s6 = peg$currPos;
13048
13287
  peg$silentFails++;
13049
13288
  s7 = input.charAt(peg$currPos);
13050
- if (peg$r14.test(s7)) peg$currPos++;
13289
+ if (peg$r16.test(s7)) peg$currPos++;
13051
13290
  else {
13052
13291
  s7 = peg$FAILED;
13053
- if (peg$silentFails === 0) peg$fail(peg$e30);
13292
+ if (peg$silentFails === 0) peg$fail(peg$e33);
13054
13293
  }
13055
13294
  peg$silentFails--;
13056
13295
  if (s7 === peg$FAILED) s6 = void 0;
@@ -13083,10 +13322,10 @@ function peg$parse(input, options) {
13083
13322
  s6 = peg$currPos;
13084
13323
  peg$silentFails++;
13085
13324
  s7 = input.charAt(peg$currPos);
13086
- if (peg$r14.test(s7)) peg$currPos++;
13325
+ if (peg$r16.test(s7)) peg$currPos++;
13087
13326
  else {
13088
13327
  s7 = peg$FAILED;
13089
- if (peg$silentFails === 0) peg$fail(peg$e30);
13328
+ if (peg$silentFails === 0) peg$fail(peg$e33);
13090
13329
  }
13091
13330
  peg$silentFails--;
13092
13331
  if (s7 === peg$FAILED) s6 = void 0;
@@ -13119,25 +13358,25 @@ function peg$parse(input, options) {
13119
13358
  else s3 = s4;
13120
13359
  if (s3 !== peg$FAILED) {
13121
13360
  peg$savedPos = peg$currPos;
13122
- s4 = peg$f49(s2, s3);
13361
+ s4 = peg$f51(s2, s3);
13123
13362
  if (s4) s4 = void 0;
13124
13363
  else s4 = peg$FAILED;
13125
13364
  if (s4 !== peg$FAILED) {
13126
13365
  s5 = peg$currPos;
13127
13366
  s6 = peg$parse_();
13128
13367
  if (input.charCodeAt(peg$currPos) === 61) {
13129
- s7 = peg$c15;
13368
+ s7 = peg$c16;
13130
13369
  peg$currPos++;
13131
13370
  } else {
13132
13371
  s7 = peg$FAILED;
13133
- if (peg$silentFails === 0) peg$fail(peg$e31);
13372
+ if (peg$silentFails === 0) peg$fail(peg$e34);
13134
13373
  }
13135
13374
  if (s7 !== peg$FAILED) {
13136
13375
  peg$parse_();
13137
13376
  s9 = peg$parseAttrValue();
13138
13377
  if (s9 !== peg$FAILED) {
13139
13378
  peg$savedPos = s5;
13140
- s5 = peg$f50(s2, s3, s9);
13379
+ s5 = peg$f52(s2, s3, s9);
13141
13380
  } else {
13142
13381
  peg$currPos = s5;
13143
13382
  s5 = peg$FAILED;
@@ -13148,7 +13387,7 @@ function peg$parse(input, options) {
13148
13387
  }
13149
13388
  if (s5 === peg$FAILED) s5 = null;
13150
13389
  peg$savedPos = s0;
13151
- s0 = peg$f51(s2, s3, s5);
13390
+ s0 = peg$f53(s2, s3, s5);
13152
13391
  } else {
13153
13392
  peg$currPos = s0;
13154
13393
  s0 = peg$FAILED;
@@ -13163,11 +13402,11 @@ function peg$parse(input, options) {
13163
13402
  let s0, s1, s2, s3, s4, s5;
13164
13403
  s0 = peg$currPos;
13165
13404
  if (input.charCodeAt(peg$currPos) === 34) {
13166
- s1 = peg$c16;
13405
+ s1 = peg$c17;
13167
13406
  peg$currPos++;
13168
13407
  } else {
13169
13408
  s1 = peg$FAILED;
13170
- if (peg$silentFails === 0) peg$fail(peg$e32);
13409
+ if (peg$silentFails === 0) peg$fail(peg$e35);
13171
13410
  }
13172
13411
  if (s1 !== peg$FAILED) {
13173
13412
  s2 = peg$parseHere();
@@ -13176,10 +13415,10 @@ function peg$parse(input, options) {
13176
13415
  s5 = peg$parseValuePart();
13177
13416
  if (s5 === peg$FAILED) {
13178
13417
  s5 = input.charAt(peg$currPos);
13179
- if (peg$r15.test(s5)) peg$currPos++;
13418
+ if (peg$r17.test(s5)) peg$currPos++;
13180
13419
  else {
13181
13420
  s5 = peg$FAILED;
13182
- if (peg$silentFails === 0) peg$fail(peg$e33);
13421
+ if (peg$silentFails === 0) peg$fail(peg$e36);
13183
13422
  }
13184
13423
  }
13185
13424
  while (s5 !== peg$FAILED) {
@@ -13187,25 +13426,25 @@ function peg$parse(input, options) {
13187
13426
  s5 = peg$parseValuePart();
13188
13427
  if (s5 === peg$FAILED) {
13189
13428
  s5 = input.charAt(peg$currPos);
13190
- if (peg$r15.test(s5)) peg$currPos++;
13429
+ if (peg$r17.test(s5)) peg$currPos++;
13191
13430
  else {
13192
13431
  s5 = peg$FAILED;
13193
- if (peg$silentFails === 0) peg$fail(peg$e33);
13432
+ if (peg$silentFails === 0) peg$fail(peg$e36);
13194
13433
  }
13195
13434
  }
13196
13435
  }
13197
13436
  s3 = input.substring(s3, peg$currPos);
13198
13437
  s4 = peg$parseHere();
13199
13438
  if (input.charCodeAt(peg$currPos) === 34) {
13200
- s5 = peg$c16;
13439
+ s5 = peg$c17;
13201
13440
  peg$currPos++;
13202
13441
  } else {
13203
13442
  s5 = peg$FAILED;
13204
- if (peg$silentFails === 0) peg$fail(peg$e32);
13443
+ if (peg$silentFails === 0) peg$fail(peg$e35);
13205
13444
  }
13206
13445
  if (s5 !== peg$FAILED) {
13207
13446
  peg$savedPos = s0;
13208
- s0 = peg$f52(s2, s3, s4);
13447
+ s0 = peg$f54(s2, s3, s4);
13209
13448
  } else {
13210
13449
  peg$currPos = s0;
13211
13450
  s0 = peg$FAILED;
@@ -13217,11 +13456,11 @@ function peg$parse(input, options) {
13217
13456
  if (s0 === peg$FAILED) {
13218
13457
  s0 = peg$currPos;
13219
13458
  if (input.charCodeAt(peg$currPos) === 39) {
13220
- s1 = peg$c17;
13459
+ s1 = peg$c18;
13221
13460
  peg$currPos++;
13222
13461
  } else {
13223
13462
  s1 = peg$FAILED;
13224
- if (peg$silentFails === 0) peg$fail(peg$e34);
13463
+ if (peg$silentFails === 0) peg$fail(peg$e37);
13225
13464
  }
13226
13465
  if (s1 !== peg$FAILED) {
13227
13466
  s2 = peg$parseHere();
@@ -13230,10 +13469,10 @@ function peg$parse(input, options) {
13230
13469
  s5 = peg$parseValuePart();
13231
13470
  if (s5 === peg$FAILED) {
13232
13471
  s5 = input.charAt(peg$currPos);
13233
- if (peg$r16.test(s5)) peg$currPos++;
13472
+ if (peg$r18.test(s5)) peg$currPos++;
13234
13473
  else {
13235
13474
  s5 = peg$FAILED;
13236
- if (peg$silentFails === 0) peg$fail(peg$e35);
13475
+ if (peg$silentFails === 0) peg$fail(peg$e38);
13237
13476
  }
13238
13477
  }
13239
13478
  while (s5 !== peg$FAILED) {
@@ -13241,25 +13480,25 @@ function peg$parse(input, options) {
13241
13480
  s5 = peg$parseValuePart();
13242
13481
  if (s5 === peg$FAILED) {
13243
13482
  s5 = input.charAt(peg$currPos);
13244
- if (peg$r16.test(s5)) peg$currPos++;
13483
+ if (peg$r18.test(s5)) peg$currPos++;
13245
13484
  else {
13246
13485
  s5 = peg$FAILED;
13247
- if (peg$silentFails === 0) peg$fail(peg$e35);
13486
+ if (peg$silentFails === 0) peg$fail(peg$e38);
13248
13487
  }
13249
13488
  }
13250
13489
  }
13251
13490
  s3 = input.substring(s3, peg$currPos);
13252
13491
  s4 = peg$parseHere();
13253
13492
  if (input.charCodeAt(peg$currPos) === 39) {
13254
- s5 = peg$c17;
13493
+ s5 = peg$c18;
13255
13494
  peg$currPos++;
13256
13495
  } else {
13257
13496
  s5 = peg$FAILED;
13258
- if (peg$silentFails === 0) peg$fail(peg$e34);
13497
+ if (peg$silentFails === 0) peg$fail(peg$e37);
13259
13498
  }
13260
13499
  if (s5 !== peg$FAILED) {
13261
13500
  peg$savedPos = s0;
13262
- s0 = peg$f53(s2, s3, s4);
13501
+ s0 = peg$f55(s2, s3, s4);
13263
13502
  } else {
13264
13503
  peg$currPos = s0;
13265
13504
  s0 = peg$FAILED;
@@ -13271,14 +13510,14 @@ function peg$parse(input, options) {
13271
13510
  if (s0 === peg$FAILED) {
13272
13511
  s0 = peg$currPos;
13273
13512
  s1 = input.charAt(peg$currPos);
13274
- if (peg$r17.test(s1)) peg$currPos++;
13513
+ if (peg$r19.test(s1)) peg$currPos++;
13275
13514
  else {
13276
13515
  s1 = peg$FAILED;
13277
- if (peg$silentFails === 0) peg$fail(peg$e36);
13516
+ if (peg$silentFails === 0) peg$fail(peg$e39);
13278
13517
  }
13279
13518
  if (s1 !== peg$FAILED) {
13280
13519
  peg$savedPos = s0;
13281
- s1 = peg$f54(s1);
13520
+ s1 = peg$f56(s1);
13282
13521
  }
13283
13522
  s0 = s1;
13284
13523
  if (s0 === peg$FAILED) {
@@ -13287,24 +13526,24 @@ function peg$parse(input, options) {
13287
13526
  s2 = peg$currPos;
13288
13527
  s3 = [];
13289
13528
  s4 = input.charAt(peg$currPos);
13290
- if (peg$r18.test(s4)) peg$currPos++;
13529
+ if (peg$r20.test(s4)) peg$currPos++;
13291
13530
  else {
13292
13531
  s4 = peg$FAILED;
13293
- if (peg$silentFails === 0) peg$fail(peg$e37);
13532
+ if (peg$silentFails === 0) peg$fail(peg$e40);
13294
13533
  }
13295
13534
  while (s4 !== peg$FAILED) {
13296
13535
  s3.push(s4);
13297
13536
  s4 = input.charAt(peg$currPos);
13298
- if (peg$r18.test(s4)) peg$currPos++;
13537
+ if (peg$r20.test(s4)) peg$currPos++;
13299
13538
  else {
13300
13539
  s4 = peg$FAILED;
13301
- if (peg$silentFails === 0) peg$fail(peg$e37);
13540
+ if (peg$silentFails === 0) peg$fail(peg$e40);
13302
13541
  }
13303
13542
  }
13304
13543
  s2 = input.substring(s2, peg$currPos);
13305
13544
  s3 = peg$parseHere();
13306
13545
  peg$savedPos = s0;
13307
- s0 = peg$f55(s1, s2, s3);
13546
+ s0 = peg$f57(s1, s2, s3);
13308
13547
  }
13309
13548
  }
13310
13549
  }
@@ -13314,7 +13553,7 @@ function peg$parse(input, options) {
13314
13553
  let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
13315
13554
  s0 = peg$currPos;
13316
13555
  peg$savedPos = peg$currPos;
13317
- s1 = peg$f56();
13556
+ s1 = peg$f58();
13318
13557
  if (s1) s1 = void 0;
13319
13558
  else s1 = peg$FAILED;
13320
13559
  if (s1 !== peg$FAILED) {
@@ -13343,7 +13582,7 @@ function peg$parse(input, options) {
13343
13582
  if (s2 !== peg$FAILED) {
13344
13583
  s3 = peg$currPos;
13345
13584
  peg$savedPos = peg$currPos;
13346
- s4 = peg$f57(s2);
13585
+ s4 = peg$f59(s2);
13347
13586
  if (s4) s4 = void 0;
13348
13587
  else s4 = peg$FAILED;
13349
13588
  if (s4 !== peg$FAILED) {
@@ -13382,7 +13621,7 @@ function peg$parse(input, options) {
13382
13621
  if (s0 === peg$FAILED) {
13383
13622
  s0 = peg$currPos;
13384
13623
  peg$savedPos = peg$currPos;
13385
- s1 = peg$f58();
13624
+ s1 = peg$f60();
13386
13625
  if (s1) s1 = void 0;
13387
13626
  else s1 = peg$FAILED;
13388
13627
  if (s1 !== peg$FAILED) {
@@ -13409,12 +13648,12 @@ function peg$parse(input, options) {
13409
13648
  if (s6 !== peg$FAILED) {
13410
13649
  s7 = peg$parseHere();
13411
13650
  peg$savedPos = peg$currPos;
13412
- s8 = peg$f59(s4, s7);
13651
+ s8 = peg$f61(s4, s7);
13413
13652
  if (s8) s8 = void 0;
13414
13653
  else s8 = peg$FAILED;
13415
13654
  if (s8 !== peg$FAILED) {
13416
13655
  s9 = peg$currPos;
13417
- s10 = peg$f60(s4, s7);
13656
+ s10 = peg$f62(s4, s7);
13418
13657
  s11 = peg$currPos;
13419
13658
  s12 = [];
13420
13659
  if (s12.length >= (s10 | 0)) s13 = peg$FAILED;
@@ -13496,7 +13735,7 @@ function peg$parse(input, options) {
13496
13735
  if (s0 === peg$FAILED) {
13497
13736
  s0 = peg$currPos;
13498
13737
  peg$savedPos = peg$currPos;
13499
- s1 = peg$f61();
13738
+ s1 = peg$f63();
13500
13739
  if (s1) s1 = void 0;
13501
13740
  else s1 = peg$FAILED;
13502
13741
  if (s1 !== peg$FAILED) {
@@ -13587,7 +13826,7 @@ function peg$parse(input, options) {
13587
13826
  if (s0 === peg$FAILED) {
13588
13827
  s0 = peg$currPos;
13589
13828
  peg$savedPos = peg$currPos;
13590
- s1 = peg$f62();
13829
+ s1 = peg$f64();
13591
13830
  if (s1) s1 = void 0;
13592
13831
  else s1 = peg$FAILED;
13593
13832
  if (s1 !== peg$FAILED) {
@@ -13669,10 +13908,10 @@ function peg$parse(input, options) {
13669
13908
  function peg$parse_c() {
13670
13909
  let s0;
13671
13910
  s0 = input.charAt(peg$currPos);
13672
- if (peg$r19.test(s0)) peg$currPos++;
13911
+ if (peg$r21.test(s0)) peg$currPos++;
13673
13912
  else {
13674
13913
  s0 = peg$FAILED;
13675
- if (peg$silentFails === 0) peg$fail(peg$e38);
13914
+ if (peg$silentFails === 0) peg$fail(peg$e41);
13676
13915
  }
13677
13916
  return s0;
13678
13917
  }
@@ -14336,13 +14575,13 @@ function propertyName(node, src) {
14336
14575
  const c = src.charAt(node.start);
14337
14576
  if (c === "@" || c === "%") throw new CodeSyntaxError(`"${node.name}" can't be a property name`, src, node.start);
14338
14577
  }
14339
- function walk(node, src, out, binding, shorthand) {
14578
+ function walk(node, src, out, binding, shorthand, access = "read") {
14340
14579
  if (Array.isArray(node)) {
14341
- for (const n7 of node) walk(n7, src, out, binding, false);
14580
+ for (const n7 of node) walk(n7, src, out, binding, false, access);
14342
14581
  return;
14343
14582
  }
14344
14583
  if (!isNode(node)) return;
14345
- const sub = (child, bind = false, short = false) => walk(child, src, out, bind, short);
14584
+ const sub = (child, bind = false, short = false, role = "read") => walk(child, src, out, bind, short, role);
14346
14585
  switch (node.type) {
14347
14586
  case "Identifier": {
14348
14587
  const sigil = sigilOf(node, src);
@@ -14353,7 +14592,9 @@ function walk(node, src, out, binding, shorthand) {
14353
14592
  name: sigil[1],
14354
14593
  start: node.start,
14355
14594
  end: node.end,
14356
- shorthand
14595
+ shorthand,
14596
+ read: access !== "write",
14597
+ write: access !== "read"
14357
14598
  });
14358
14599
  return;
14359
14600
  }
@@ -14374,10 +14615,10 @@ function walk(node, src, out, binding, shorthand) {
14374
14615
  if (node.shorthand) {
14375
14616
  const value = node.value;
14376
14617
  if (value.type === "AssignmentPattern") {
14377
- sub(value.left, binding, true);
14618
+ sub(value.left, binding, true, access);
14378
14619
  sub(value.right);
14379
- } else sub(value, binding, true);
14380
- } else sub(node.value, binding);
14620
+ } else sub(value, binding, true, access);
14621
+ } else sub(node.value, binding, false, access);
14381
14622
  return;
14382
14623
  case "MethodDefinition":
14383
14624
  case "PropertyDefinition":
@@ -14414,8 +14655,24 @@ function walk(node, src, out, binding, shorthand) {
14414
14655
  sub(node.param, true);
14415
14656
  sub(node.body);
14416
14657
  return;
14658
+ case "AssignmentExpression":
14659
+ sub(node.left, false, false, node.operator === "=" ? "write" : "readwrite");
14660
+ sub(node.right);
14661
+ return;
14662
+ case "UnaryExpression":
14663
+ sub(node.argument, false, false, node.operator === "delete" ? "write" : "read");
14664
+ return;
14665
+ case "UpdateExpression":
14666
+ sub(node.argument, false, false, "readwrite");
14667
+ return;
14668
+ case "ForInStatement":
14669
+ case "ForOfStatement":
14670
+ sub(node.left, false, false, "write");
14671
+ sub(node.right);
14672
+ sub(node.body);
14673
+ return;
14417
14674
  case "AssignmentPattern":
14418
- sub(node.left, binding);
14675
+ sub(node.left, binding, false, access);
14419
14676
  sub(node.right);
14420
14677
  return;
14421
14678
  case "ObjectPattern":
@@ -14425,7 +14682,7 @@ function walk(node, src, out, binding, shorthand) {
14425
14682
  "properties",
14426
14683
  "elements",
14427
14684
  "argument"
14428
- ]) sub(node[key], binding);
14685
+ ]) sub(node[key], binding, false, access);
14429
14686
  return;
14430
14687
  default:
14431
14688
  for (const key in node) {
@@ -15023,13 +15280,13 @@ function isCloser(ch) {
15023
15280
  function unescapeQuoted(body) {
15024
15281
  return body.replace(/\\(["'\\])/g, "$1");
15025
15282
  }
15026
- function readQuoted(src, start) {
15283
+ function readQuoted(src, start, tolerant = false) {
15027
15284
  const quote = src[start];
15028
15285
  if (quote !== '"' && quote !== "'") return null;
15029
15286
  const { end, closed } = scanStringLiteral(src, start);
15030
- if (!closed) return null;
15287
+ if (!closed && !tolerant) return null;
15031
15288
  return {
15032
- value: unescapeQuoted(src.slice(start + 1, end - 1)),
15289
+ value: unescapeQuoted(src.slice(start + 1, closed ? end - 1 : end)),
15033
15290
  end
15034
15291
  };
15035
15292
  }
@@ -15087,8 +15344,7 @@ function startsLikeValue(token) {
15087
15344
  const first = token[0];
15088
15345
  if (first === '"' || first === "'" || first === "`") return true;
15089
15346
  if (/^[$_@]\w|^%[A-Za-z_]/.test(token)) return true;
15090
- if (/\d/.test(first)) return true;
15091
- if ((first === "-" || first === "+") && token.length > 1 && /\d/.test(token[1])) return true;
15347
+ if (/^[+-]?(?:\d|\.\d)/.test(token)) return true;
15092
15348
  if (first === "(" || first === "[" || first === "{") return true;
15093
15349
  if (/^(?:true|false|null|undefined)(?![\w$])/.test(token)) return true;
15094
15350
  if (first === "!" && token.length > 1 && token[1] !== "=") return true;
@@ -15133,11 +15389,16 @@ function readText(src) {
15133
15389
  return readWholeQuoted(src) ?? stripLooseQuotes(src);
15134
15390
  }
15135
15391
  function readValue(param, src, place) {
15136
- place.spans?.set(param, [place.at, place.at + src.length]);
15392
+ const span = [place.at, place.at + src.length];
15393
+ place.spans?.set(param, span);
15394
+ place.toolingSpans?.set(param, span);
15137
15395
  switch (param.type) {
15138
15396
  case "string": {
15139
15397
  const value = readWholeQuoted(src);
15140
- if (value === null) throw new MacroArgumentError(param, src);
15398
+ if (value === null) {
15399
+ if (place.toolingSpans && (src[0] === '"' || src[0] === "'")) return readText(src);
15400
+ throw new MacroArgumentError(param, src);
15401
+ }
15141
15402
  return value;
15142
15403
  }
15143
15404
  case "text":
@@ -15162,20 +15423,21 @@ function matchAt(re2, src, pos) {
15162
15423
  re2.lastIndex = pos;
15163
15424
  return re2.exec(src)?.[0] ?? null;
15164
15425
  }
15165
- function readOptions(params, src, { at: at3, spans }) {
15426
+ function readOptions(params, src, { at: at3, spans, toolingSpans }) {
15166
15427
  const options = {};
15167
15428
  let i2 = 0;
15168
15429
  while (i2 < src.length) {
15169
15430
  const key = matchAt(WORD_RE$1, src, i2);
15170
15431
  if (!key) {
15171
- i2 = readQuoted(src, i2)?.end ?? i2 + 1;
15432
+ i2 = readQuoted(src, i2, !!toolingSpans)?.end ?? i2 + 1;
15172
15433
  continue;
15173
15434
  }
15435
+ const keyAt = i2;
15174
15436
  i2 += key.length;
15175
15437
  let val;
15176
15438
  let j2 = i2;
15177
15439
  while (j2 < src.length && isWhitespace(src[j2])) j2++;
15178
- const quoted = readQuoted(src, j2);
15440
+ const quoted = readQuoted(src, j2, !!toolingSpans);
15179
15441
  const digits = quoted || j2 === i2 ? null : matchAt(NUMBER_RE$1, src, j2);
15180
15442
  if (quoted) {
15181
15443
  val = quoted.value;
@@ -15186,7 +15448,8 @@ function readOptions(params, src, { at: at3, spans }) {
15186
15448
  }
15187
15449
  const param = params.find((p) => p.name === key);
15188
15450
  if (param && param.type !== "flag" && val !== void 0) spans?.set(param, [at3 + j2, at3 + i2]);
15189
- if (param?.type === "string" && !quoted) throw new MacroArgumentError(param, matchAt(WORD_OR_PUNCT_RE, src, j2) ?? "");
15451
+ if (param) toolingSpans?.set(param, [at3 + keyAt, at3 + i2]);
15452
+ if (param?.type === "string" && !quoted && !toolingSpans) throw new MacroArgumentError(param, matchAt(WORD_OR_PUNCT_RE, src, j2) ?? "");
15190
15453
  if (param?.type === "flag") options[key] = true;
15191
15454
  else if (param?.type === "number") options[key] = Number(val ?? 0);
15192
15455
  else if (param) options[key] = val;
@@ -15207,7 +15470,7 @@ function takeFlag(src, word, alone) {
15207
15470
  }
15208
15471
  return null;
15209
15472
  }
15210
- function findSeparator(src, word) {
15473
+ function findSeparator(src, word, tolerant = false) {
15211
15474
  if (word === "=") {
15212
15475
  const indices = topLevelIndices(src, (ch) => ch === "=");
15213
15476
  for (let k2 = 0; k2 < indices.length; k2++) {
@@ -15221,29 +15484,42 @@ function findSeparator(src, word) {
15221
15484
  return null;
15222
15485
  }
15223
15486
  const spans = terms(src);
15224
- for (let k2 = 1; k2 < spans.length - 1; k2++) if (slice(src, spans[k2]) === word) return [spans[k2 - 1][1], spans[k2 + 1][0]];
15487
+ for (let k2 = 1; k2 < spans.length - (tolerant ? 0 : 1); k2++) if (slice(src, spans[k2]) === word) return [spans[k2 - 1][1], spans[k2 + 1]?.[0] ?? src.length];
15225
15488
  return null;
15226
15489
  }
15227
15490
  function trimmed(src, at3) {
15228
15491
  const text3 = src.trim();
15229
15492
  return [text3, text3 ? at3 + src.indexOf(text3) : at3];
15230
15493
  }
15231
- function readGroup(params, src, args2, { at: srcAt, spans }) {
15494
+ function readGroup(params, src, args2, { at: srcAt, spans, toolingSpans }) {
15232
15495
  let [text3, at3] = trimmed(src ?? "", srcAt);
15233
15496
  const alone = !params.some((p) => p.type !== "flag" && p.required);
15234
15497
  for (const flag of params.filter((p) => p.type === "flag")) {
15235
15498
  const rest2 = src === null ? null : takeFlag(text3, flag.name, alone);
15236
15499
  args2[flag.name] = rest2 !== null;
15237
- if (rest2) [text3, at3] = trimmed(slice(text3, rest2), at3 + rest2[0]);
15500
+ if (rest2) {
15501
+ const flagSpan = rest2[0] > 0 ? [0, text3.indexOf(flag.name) + flag.name.length] : [text3.lastIndexOf(flag.name), text3.length];
15502
+ toolingSpans?.set(flag, [at3 + flagSpan[0], at3 + flagSpan[1]]);
15503
+ [text3, at3] = trimmed(slice(text3, rest2), at3 + rest2[0]);
15504
+ }
15238
15505
  }
15239
15506
  const positional = params.filter((p) => p.type !== "flag");
15240
15507
  if (positional.length === 0) return;
15241
15508
  const lastText = positional.findIndex((p, i2) => takesRest(p) && !positional.slice(i2 + 1).some(takesRest));
15242
15509
  const restIndex = lastText < 0 ? positional.length - 1 : lastText;
15243
- const read = (param, [start, end]) => start === end ? unset(param) : readValue(param, text3.slice(start, end), {
15244
- at: at3 + start,
15245
- spans
15246
- });
15510
+ const read = (param, [start, end], tolerant = true) => {
15511
+ if (start === end) return unset(param);
15512
+ try {
15513
+ return readValue(param, text3.slice(start, end), {
15514
+ at: at3 + start,
15515
+ spans,
15516
+ toolingSpans
15517
+ });
15518
+ } catch (error48) {
15519
+ if (toolingSpans && tolerant && error48 instanceof MacroArgumentError) return;
15520
+ throw error48;
15521
+ }
15522
+ };
15247
15523
  if (positional.length === 1) {
15248
15524
  args2[positional[0].name] = read(positional[0], [0, text3.length]);
15249
15525
  return;
@@ -15254,7 +15530,7 @@ function readGroup(params, src, args2, { at: srcAt, spans }) {
15254
15530
  for (const param of positional.slice(0, restIndex)) args2[param.name] = from < to ? read(param, parts[from++]) : unset(param);
15255
15531
  const readTrailing = (param, span) => {
15256
15532
  try {
15257
- return read(param, span);
15533
+ return read(param, span, false);
15258
15534
  } catch (error48) {
15259
15535
  if (error48 instanceof MacroArgumentError) return void 0;
15260
15536
  throw error48;
@@ -15264,23 +15540,31 @@ function readGroup(params, src, args2, { at: srcAt, spans }) {
15264
15540
  const value = from < to && !endsWithOperator(text3.slice(0, parts[to - 1][0])) ? readTrailing(param, parts[to - 1]) : void 0;
15265
15541
  args2[param.name] = value ?? unset(param);
15266
15542
  if (value !== void 0) to--;
15267
- else spans?.delete(param);
15543
+ else {
15544
+ spans?.delete(param);
15545
+ toolingSpans?.delete(param);
15546
+ }
15268
15547
  }
15269
15548
  const rest = positional[restIndex];
15270
15549
  args2[rest.name] = from < to ? read(rest, [parts[from][0], parts[to - 1][1]]) : unset(rest);
15271
15550
  }
15272
- function parseMacroArgs(rawArgs, parameters, spans) {
15551
+ function parseMacroArgs(rawArgs, parameters, spans, toolingSpans) {
15273
15552
  const args2 = {};
15274
15553
  let [rest, restAt] = trimmed(rawArgs, 0);
15275
15554
  let groupStart = 0;
15276
15555
  parameters.forEach((separator, i2) => {
15277
15556
  if (separator.type !== "separator") return;
15278
- const at3 = rest === null ? null : findSeparator(rest, separator.name);
15557
+ const at3 = rest === null ? null : findSeparator(rest, separator.name, !!toolingSpans);
15279
15558
  args2[separator.name] = at3 !== null;
15559
+ if (at3 && toolingSpans) {
15560
+ const start = restAt + at3[0] + rest.slice(at3[0], at3[1]).indexOf(separator.name);
15561
+ toolingSpans.set(separator, [start, start + separator.name.length]);
15562
+ }
15280
15563
  const before = at3 ? rest.slice(0, at3[0]) : rest;
15281
15564
  readGroup(parameters.slice(groupStart, i2), before, args2, {
15282
15565
  at: restAt,
15283
- spans
15566
+ spans,
15567
+ toolingSpans
15284
15568
  });
15285
15569
  rest = at3 ? rest.slice(at3[1]) : null;
15286
15570
  if (at3) restAt += at3[1];
@@ -15288,7 +15572,8 @@ function parseMacroArgs(rawArgs, parameters, spans) {
15288
15572
  });
15289
15573
  readGroup(parameters.slice(groupStart), rest, args2, {
15290
15574
  at: restAt,
15291
- spans
15575
+ spans,
15576
+ toolingSpans
15292
15577
  });
15293
15578
  return args2;
15294
15579
  }
@@ -15395,7 +15680,14 @@ function stringHolds(param) {
15395
15680
  return param.holds ?? "markup";
15396
15681
  }
15397
15682
  function* codeAndText(src, tokens2, parametersOf2) {
15398
- const closeOf = (t, name) => tokens2.findIndex((c, k2) => k2 > t && c.type === "macro" && c.isClose && c.name.toLowerCase() === name);
15683
+ const closeOfTextBody = (t, name) => {
15684
+ for (let k2 = t + 1; k2 < tokens2.length; k2++) {
15685
+ const c = tokens2[k2];
15686
+ if (c.type === "text") continue;
15687
+ return c.type === "macro" && c.isClose && c.name.toLowerCase() === name ? k2 : -1;
15688
+ }
15689
+ return -1;
15690
+ };
15399
15691
  for (let t = 0; t < tokens2.length; t++) {
15400
15692
  const token = tokens2[t];
15401
15693
  if (token.type === "link") {
@@ -15431,7 +15723,7 @@ function* codeAndText(src, tokens2, parametersOf2) {
15431
15723
  else if (token.type === "macro" && !token.isClose) {
15432
15724
  const name = token.name.toLowerCase();
15433
15725
  if (name === "do") {
15434
- const close = closeOf(t, name);
15726
+ const close = closeOfTextBody(t, name);
15435
15727
  if (close < 0) continue;
15436
15728
  yield {
15437
15729
  kind: "code",
@@ -15445,9 +15737,8 @@ function* codeAndText(src, tokens2, parametersOf2) {
15445
15737
  }
15446
15738
  const args2 = token.rawArgs;
15447
15739
  if (PASSAGE_BODIES.has(name)) {
15448
- const close = closeOf(t, name);
15449
- const body = tokens2.slice(t + 1, close);
15450
- if (close > t + 1 && body.every((b) => b.type === "text")) {
15740
+ const close = closeOfTextBody(t, name);
15741
+ if (close > t + 1) {
15451
15742
  const text3 = src.slice(token.end, tokens2[close].start);
15452
15743
  const written2 = text3.trim();
15453
15744
  yield {
@@ -16837,10 +17128,10 @@ function resolveAll(constructs2, events, context) {
16837
17128
  const called = [];
16838
17129
  let index = -1;
16839
17130
  while (++index < constructs2.length) {
16840
- const resolve7 = constructs2[index].resolveAll;
16841
- if (resolve7 && !called.includes(resolve7)) {
16842
- events = resolve7(events, context);
16843
- called.push(resolve7);
17131
+ const resolve8 = constructs2[index].resolveAll;
17132
+ if (resolve8 && !called.includes(resolve8)) {
17133
+ events = resolve8(events, context);
17134
+ called.push(resolve8);
16844
17135
  }
16845
17136
  }
16846
17137
  return events;
@@ -20304,10 +20595,25 @@ function markdownOptions(options) {
20304
20595
  htmlExtensions: [gfmTableHtml(), gfmStrikethroughHtml()]
20305
20596
  };
20306
20597
  }
20307
- function fencedCodeLines(source, isBlock) {
20598
+ function sourceLines(source) {
20599
+ const starts = [0];
20600
+ for (let i2 = 0; i2 < source.length; i2++) if (source[i2] === "\n") starts.push(i2 + 1);
20601
+ return (offset2) => {
20602
+ let low = 0;
20603
+ let high = starts.length;
20604
+ while (low < high) {
20605
+ const middle = low + high >>> 1;
20606
+ if (starts[middle] <= offset2) low = middle + 1;
20607
+ else high = middle;
20608
+ }
20609
+ return Math.max(0, low - 1);
20610
+ };
20611
+ }
20612
+ function markdownLines(source, isBlock, types3) {
20308
20613
  const found = /* @__PURE__ */ new Set();
20309
- if (!/`{3}|~{3}/.test(source)) return found;
20614
+ if (types3.size === 1 && types3.has("codeFenced") && !/`{3}|~{3}/.test(source)) return found;
20310
20615
  const { nodes } = analyzeMarkup(source, { hooks: { isBlock } });
20616
+ const lineAt = sourceLines(source);
20311
20617
  function visit(nodes2) {
20312
20618
  let markdown = "";
20313
20619
  const spans = [];
@@ -20319,23 +20625,32 @@ function fencedCodeLines(source, isBlock) {
20319
20625
  end: markdown.length,
20320
20626
  node
20321
20627
  });
20322
- if (node.body && !(node.token.type === "macro" && node.token.name === "do")) {
20628
+ if (node.body && !(node.token.type === "macro" && node.token.name.toLowerCase() === "do")) {
20323
20629
  visit(node.body.children);
20324
20630
  for (const branch of node.body.branches) visit(branch.children);
20325
20631
  }
20326
20632
  }
20327
20633
  const events = postprocess(parse3(markdownOptions()).document().write(preprocess()(markdown, void 0, true)));
20328
20634
  for (const [event, token] of events) {
20329
- if (event !== "enter" || token.type !== "codeFenced") continue;
20330
- for (const span of spans) {
20635
+ if (event !== "enter" || !types3.has(token.type)) continue;
20636
+ let low = 0;
20637
+ let high = spans.length;
20638
+ while (low < high) {
20639
+ const middle = low + high >>> 1;
20640
+ if (spans[middle].end <= token.start.offset) low = middle + 1;
20641
+ else high = middle;
20642
+ }
20643
+ for (let i2 = low; i2 < spans.length; i2++) {
20644
+ const span = spans[i2];
20645
+ if (span.start >= token.end.offset) break;
20331
20646
  const start = Math.max(token.start.offset, span.start);
20332
20647
  const end = Math.min(token.end.offset, span.end);
20333
20648
  if (start >= end) continue;
20334
20649
  const text3 = span.node.token.type === "text";
20335
20650
  const a = text3 ? span.node.start + start - span.start : span.node.start;
20336
20651
  const b = text3 ? span.node.start + end - span.start : span.node.end;
20337
- const first = source.slice(0, a).split("\n").length - 1;
20338
- const last2 = source.slice(0, Math.max(a, b - 1)).split("\n").length - 1;
20652
+ const first = lineAt(a);
20653
+ const last2 = lineAt(Math.max(a, b - 1));
20339
20654
  for (let line = first; line <= last2; line++) found.add(line);
20340
20655
  }
20341
20656
  }
@@ -20395,7 +20710,7 @@ function scanSpindleMarkup(text3) {
20395
20710
  }, true);
20396
20711
  }
20397
20712
  } else if (t.type !== "text") {
20398
- if (t.type === "macro" && t.name === "do") {
20713
+ if (t.type === "macro" && t.name.toLowerCase() === "do") {
20399
20714
  if (!t.isClose) open = t;
20400
20715
  else if (open) {
20401
20716
  doBlocks.push({
@@ -20428,9 +20743,6 @@ function multilineJsLiterals(code) {
20428
20743
  } }, "statements");
20429
20744
  return spans;
20430
20745
  }
20431
- function lineHasTag(tags, start, end) {
20432
- return tags.some((tag) => tag.start < end && tag.end > start);
20433
- }
20434
20746
  function replaceSvgBlocks(html) {
20435
20747
  const tokens2 = [];
20436
20748
  return {
@@ -20443,7 +20755,17 @@ function replaceSvgBlocks(html) {
20443
20755
  };
20444
20756
  }
20445
20757
  function placeholdersIntact(text3, tokens2, placeholdersOf) {
20446
- return tokens2.every((_2, index) => placeholdersOf(index).reduce((count, placeholder) => count + text3.split(placeholder).length - 1, 0) === 1);
20758
+ if (tokens2.length === 0) return true;
20759
+ const indices = /* @__PURE__ */ new Map();
20760
+ const counts = new Array(tokens2.length).fill(0);
20761
+ tokens2.forEach((_2, index) => {
20762
+ for (const marker of placeholdersOf(index)) indices.set(marker, index);
20763
+ });
20764
+ for (const [marker] of text3.matchAll(PLACEHOLDER_PATTERN)) {
20765
+ const index = indices.get(marker);
20766
+ if (index !== void 0 && ++counts[index] > 1) return false;
20767
+ }
20768
+ return counts.every((count) => count === 1);
20447
20769
  }
20448
20770
  function sameSpindleTokens(before, after) {
20449
20771
  const tokensOf2 = (text3) => scanSpindleMarkup(text3).tokens.map((m) => m.token);
@@ -20451,15 +20773,19 @@ function sameSpindleTokens(before, after) {
20451
20773
  const found = tokensOf2(after);
20452
20774
  return expected.length === found.length && expected.every((t, i2) => t === found[i2]);
20453
20775
  }
20454
- function restorePlaceholders(text3, tokens2, placeholdersOf) {
20455
- let result2 = text3;
20456
- tokens2.forEach((token, index) => {
20457
- for (const placeholder of placeholdersOf(index)) result2 = result2.replace(placeholder, () => token);
20776
+ function restorePlaceholders(text3, groups) {
20777
+ const replacements = /* @__PURE__ */ new Map();
20778
+ for (const [tokens2, placeholdersOf] of groups) tokens2.forEach((token, index) => {
20779
+ for (const marker of placeholdersOf(index)) replacements.set(marker, token);
20780
+ });
20781
+ return text3.replace(PLACEHOLDER_PATTERN, (marker) => {
20782
+ const token = replacements.get(marker);
20783
+ replacements.delete(marker);
20784
+ return token ?? marker;
20458
20785
  });
20459
- return result2;
20460
20786
  }
20461
- function restoreSvgBlocks(text3, tokens2) {
20462
- return restorePlaceholders(text3, tokens2, SVG_PLACEHOLDERS);
20787
+ function restoreHtmlTokens(text3, spindle, svg) {
20788
+ return restorePlaceholders(text3, [[spindle, SPINDLE_PLACEHOLDERS], [svg, SVG_PLACEHOLDERS]]);
20463
20789
  }
20464
20790
  function replaceSpindleTokens(html) {
20465
20791
  const { tokens: found, tags, doBlocks } = scanSpindleMarkup(html);
@@ -20484,6 +20810,7 @@ function replaceSpindleTokens(html) {
20484
20810
  const tokens2 = [];
20485
20811
  const resultLines = [];
20486
20812
  let unit = 0;
20813
+ let tag = 0;
20487
20814
  let lineStart = 0;
20488
20815
  while (lineStart <= html.length) {
20489
20816
  let lineEnd = lineStart;
@@ -20503,8 +20830,10 @@ function replaceSpindleTokens(html) {
20503
20830
  }
20504
20831
  const line = html.slice(lineStart, lineEnd);
20505
20832
  const indent = line.match(/^(\s*)/)?.[1] ?? "";
20833
+ while (tag < tags.length && tags[tag].end <= lineStart) tag++;
20834
+ const hasTag = tag < tags.length && tags[tag].start < lineEnd;
20506
20835
  if (lineUnits.length === 0) resultLines.push(line);
20507
- else if (!lineHasTag(tags, lineStart, lineEnd)) {
20836
+ else if (!hasTag) {
20508
20837
  const idx = tokens2.length;
20509
20838
  tokens2.push(line.trim());
20510
20839
  resultLines.push(`${indent}<!--SP:${idx}-->`);
@@ -20526,9 +20855,6 @@ function replaceSpindleTokens(html) {
20526
20855
  tokens: tokens2
20527
20856
  };
20528
20857
  }
20529
- function restoreSpindleTokens(text3, tokens2) {
20530
- return restorePlaceholders(text3, tokens2, SPINDLE_PLACEHOLDERS);
20531
- }
20532
20858
  function closedMacroNames(text3) {
20533
20859
  const found = /* @__PURE__ */ new Set();
20534
20860
  for (const t of tokenizeMarkupTolerant(text3).tokens) if (t.type === "macro" && t.isClose) found.add(t.name.toLowerCase());
@@ -20594,7 +20920,7 @@ async function formatLf(text3, options) {
20594
20920
  const literalSentinel = newlineSentinel(body + sentinel);
20595
20921
  const literalLines = /* @__PURE__ */ new Map();
20596
20922
  const literalMarkers = /* @__PURE__ */ new Set();
20597
- const fenced = fencedCodeLines(body, isBlock);
20923
+ const fenced = markdownLines(body, isBlock, /* @__PURE__ */ new Set(["codeFenced"]));
20598
20924
  const literalHtml = whitespaceSensitiveLines(body, isBlock);
20599
20925
  body = body.split("\n").map((line, index) => {
20600
20926
  if (!fenced.has(index) && !literalHtml.has(index)) return line;
@@ -20637,18 +20963,22 @@ async function formatLf(text3, options) {
20637
20963
  continue;
20638
20964
  }
20639
20965
  const { text: svgPlaceholdered, tokens: svgTokens } = replaceSvgBlocks(htmlText2);
20966
+ if (!placeholdersIntact(svgPlaceholdered, svgTokens, SVG_PLACEHOLDERS)) {
20967
+ lines.push(...region.lines);
20968
+ continue;
20969
+ }
20640
20970
  const { text: placeholdered, tokens: tokens2 } = replaceSpindleTokens(svgPlaceholdered);
20641
20971
  const formatted = await formatHTML(placeholdered, prettier2, prettierOptions);
20642
20972
  if (formatted === void 0 || !placeholdersIntact(formatted, tokens2, SPINDLE_PLACEHOLDERS) || !placeholdersIntact(formatted, svgTokens, SVG_PLACEHOLDERS)) {
20643
20973
  lines.push(...region.lines);
20644
20974
  continue;
20645
20975
  }
20646
- const restored = restoreSvgBlocks(restoreSpindleTokens(formatted.trim(), tokens2.map((t) => replaceAll(t, "\n", sentinel))), svgTokens);
20976
+ const restored = restoreHtmlTokens(formatted.trim(), tokens2.map((t) => replaceAll(t, "\n", sentinel)), svgTokens);
20647
20977
  for (const fLine of restored.split("\n")) lines.push(fLine);
20648
20978
  continue;
20649
20979
  }
20650
20980
  let indented = indentMacros(region.lines, isBlock, isDedenting, literalMarkers);
20651
- if (options.maxLineLength) indented = wrapLines(indented, options.maxLineLength, literalLines);
20981
+ if (options.maxLineLength) indented = wrapLines(indented, options.maxLineLength, literalLines, isBlock);
20652
20982
  for (const line of indented) {
20653
20983
  if (line.endsWith(" ")) hardBreakLines.add(lines.length);
20654
20984
  lines.push(line);
@@ -20661,13 +20991,14 @@ async function formatLf(text3, options) {
20661
20991
  function whitespaceSensitiveLines(source, isBlock) {
20662
20992
  const lines = /* @__PURE__ */ new Set();
20663
20993
  if (!WHITESPACE_AS_WRITTEN.test(source)) return lines;
20994
+ const lineAt = sourceLines(source);
20664
20995
  const { nodes } = analyzeMarkup(source, { hooks: { isBlock } });
20665
20996
  function visit(nodes2) {
20666
20997
  for (const node of nodes2) {
20667
20998
  const { token, body } = node;
20668
20999
  if (token.type === "html" && (["pre", "textarea"].includes(token.tag.toLowerCase()) || Object.entries(token.attributes).some(([name, value]) => name.toLowerCase() === "style" && /white-space\s*:/i.test(value)))) {
20669
- const first = source.slice(0, node.start).split("\n").length - 1;
20670
- const last2 = source.slice(0, node.end - 1).split("\n").length - 1;
21000
+ const first = lineAt(node.start);
21001
+ const last2 = lineAt(node.end - 1);
20671
21002
  for (let line = first; line <= last2; line++) lines.add(line);
20672
21003
  } else if (body) {
20673
21004
  visit(body.children);
@@ -20794,11 +21125,12 @@ function indentColumn(line) {
20794
21125
  else break;
20795
21126
  return col;
20796
21127
  }
20797
- function wrapLines(lines, maxLen, literalLines) {
21128
+ function wrapLines(lines, maxLen, literalLines, isBlock) {
20798
21129
  const result2 = [];
20799
- const javaScript = doBodyLines(lines);
21130
+ const verbatim = verbatimLines(lines);
21131
+ const structured = markdownLines(lines.join("\n"), isBlock, NO_WRAP);
20800
21132
  for (const [index, line] of lines.entries()) {
20801
- if (line.length <= maxLen || javaScript.has(index) || literalLines.has(line.trim())) {
21133
+ if (line.length <= maxLen || verbatim.has(index) || structured.has(index) || literalLines.has(line.trim())) {
20802
21134
  result2.push(line);
20803
21135
  continue;
20804
21136
  }
@@ -20808,17 +21140,29 @@ function wrapLines(lines, maxLen, literalLines) {
20808
21140
  continue;
20809
21141
  }
20810
21142
  const wrapped = wordWrap(trimmed2, maxLen, line.match(/^(\s*)/)?.[1] ?? "");
21143
+ if (wrapped.length > 1 && markdownLines(wrapped.join("\n"), isBlock, NO_WRAP).size) {
21144
+ result2.push(line);
21145
+ continue;
21146
+ }
20811
21147
  if (line.endsWith(" ")) wrapped[wrapped.length - 1] += " ";
20812
21148
  result2.push(...wrapped);
20813
21149
  }
20814
21150
  return result2;
20815
21151
  }
20816
- function doBodyLines(lines) {
21152
+ function verbatimLines(lines) {
20817
21153
  const found = /* @__PURE__ */ new Set();
20818
21154
  const text3 = lines.join("\n");
20819
- for (const block of scanSpindleMarkup(text3).doBlocks) {
20820
- const first = text3.slice(0, block.bodyStart).split("\n").length - 1;
20821
- const last2 = text3.slice(0, block.bodyEnd).split("\n").length - 1;
21155
+ const lineAt = sourceLines(text3);
21156
+ const { doBlocks, tags } = scanSpindleMarkup(text3);
21157
+ for (const block of doBlocks) {
21158
+ const first = lineAt(block.bodyStart);
21159
+ const last2 = lineAt(block.bodyEnd);
21160
+ for (let i2 = first; i2 <= last2; i2++) found.add(i2);
21161
+ }
21162
+ for (const tag of tags) {
21163
+ const first = lineAt(tag.start);
21164
+ const last2 = lineAt(tag.end - 1);
21165
+ if (first === last2) continue;
20822
21166
  for (let i2 = first; i2 <= last2; i2++) found.add(i2);
20823
21167
  }
20824
21168
  return found;
@@ -20827,7 +21171,7 @@ function wordWrap(text3, maxLen, indent) {
20827
21171
  const lines = [];
20828
21172
  const inToken = new Array(text3.length).fill(false);
20829
21173
  for (const token of tokenizeMarkupTolerant(text3).tokens) {
20830
- if (token.type === "text" || token.type === "html") continue;
21174
+ if (token.type === "text") continue;
20831
21175
  inToken.fill(true, token.start, token.end);
20832
21176
  }
20833
21177
  const room = maxLen - indentColumn(indent);
@@ -20859,8 +21203,8 @@ function validateStoryMarkup(passages, macros, options = {}) {
20859
21203
  const list3 = [...passages];
20860
21204
  const all = [...macros];
20861
21205
  const known = /* @__PURE__ */ new Set();
20862
- const widgets = widgetDefinitions$1(list3, parameterLookup(all));
20863
- const blocks = new Set(effectiveWidgetDefinitions(widgets).filter((def) => def.block).map((def) => def.name.toLowerCase()));
21206
+ const widgets = effectiveWidgetDefinitions(widgetDefinitions$1(list3, parameterLookup(all)));
21207
+ const blocks = new Set(widgets.filter((def) => def.block).map((def) => def.name.toLowerCase()));
20864
21208
  const parametersOf2 = parameterLookup([...all, ...definedWidgetMacros(widgets)]);
20865
21209
  for (const macro of all) {
20866
21210
  const name = macro.name.toLowerCase();
@@ -20900,7 +21244,7 @@ function widgetDefinitions(passages, macros = []) {
20900
21244
  }
20901
21245
  function referenceOptions(macros, all = false, passages = []) {
20902
21246
  const list3 = [...macros];
20903
- const widgets = widgetDefinitions$1(passages, parameterLookup(list3));
21247
+ const widgets = effectiveWidgetDefinitions(widgetDefinitions$1(passages, parameterLookup(list3)));
20904
21248
  return {
20905
21249
  all,
20906
21250
  storeVarMacros: new Set(list3.filter((m) => m.storeVar).map((m) => m.name.toLowerCase())),
@@ -20915,7 +21259,7 @@ function validateVariableReferences(passages, declarations, macros = []) {
20915
21259
  const list3 = [...passages];
20916
21260
  return checkVariableReferences(list3.filter((p) => !p.tags?.some((t) => NOT_MARKUP_TAGS.includes(t))), declarations, referenceOptions(macros, false, list3));
20917
21261
  }
20918
- var __defProp2, __exportAll, NameMap, NameSet, PARAMETER_TYPES, STRING_HOLDS, metadataRegistry, companionParents, SIGIL_SCOPES, SIGIL_CHARS, grammar_shared_default, LB, RB, SIGIL_SCOPES$1, withSelectors, VOID_TAGS, BRANCH_PARENT$1, LINK_SEPARATORS, NO_SELECTORS, EMAIL_AUTOLINK, peg$SyntaxError, BLOCK_MACROS, BLOCK_WIDGETS, DEFINED_BLOCK_MACROS, RAW_BODY_MACROS, BRANCHING, quoteArg, last$1, BRANCH_PARENT, lowerName, nameOf, closerOf, closes, astralIdentifierCodes, astralIdentifierStartCodes, nonASCIIidentifierChars, nonASCIIidentifierStartChars, reservedWords, ecma5AndLessKeywords, keywords$1, keywordRelationalOperator, nonASCIIidentifierStart, nonASCIIidentifier, TokenType, beforeExpr, startsExpr, keywords, types$1, lineBreak, lineBreakG, nonASCIIwhitespace, skipWhiteSpace, ref, hasOwnProperty$1, toString, hasOwn$1, isArray, regexpCache, loneSurrogate, Position, SourceLocation, defaultOptions, warnedAboutEcmaVersion, SCOPE_TOP, SCOPE_FUNCTION, SCOPE_ASYNC, SCOPE_GENERATOR, SCOPE_ARROW, SCOPE_SIMPLE_CATCH, SCOPE_SUPER, SCOPE_DIRECT_SUPER, SCOPE_CLASS_STATIC_BLOCK, SCOPE_CLASS_FIELD_INIT, SCOPE_SWITCH, SCOPE_VAR, BIND_NONE, BIND_VAR, BIND_LEXICAL, BIND_FUNCTION, BIND_SIMPLE_CATCH, BIND_OUTSIDE, Parser, prototypeAccessors, pp$9, literal, DestructuringErrors, pp$8, loopLabel, switchLabel, empty$1, FUNC_STATEMENT, FUNC_HANGING_STATEMENT, FUNC_NULLABLE_ID, pp$7, TokContext, types, pp$6, pp$5, empty, pp$4, pp$3, Scope, Node, pp$2, scriptValuesAddedInUnicode, ecma9BinaryProperties, ecma10BinaryProperties, ecma11BinaryProperties, ecma12BinaryProperties, ecma13BinaryProperties, unicodeBinaryProperties, unicodeBinaryPropertiesOfStrings, unicodeGeneralCategoryValues, ecma9ScriptValues, ecma10ScriptValues, ecma11ScriptValues, ecma12ScriptValues, ecma13ScriptValues, unicodeScriptValues, data, ecmaVersion, i, list$2, pp$1, BranchID, RegExpValidationState, CharSetNone, CharSetOk, CharSetString, Token, pp, INVALID_TEMPLATE_ESCAPE_ERROR, OPTIONS, AT_NAME_RE, TRANS_NAME_RE, SIGIL_IDENT_RE, LINE_BREAK_RE, NOT_A_BODY_RE, OPERAND_ENDS, SigilParser, OPENERS, CLOSERS$1, CodeSyntaxError, last, CLOSER, isNode, NAMESPACE_NAME, WORD_RE$2, FLAGS_RE, WORDS_BEFORE_STRING, NON_STRING_QUOTE_PREFIX, memoInput, memo, defaultCodeEnd, defaultHooks, MarkupError, OFFSET_FIELD, listeners, TRAILING_OPERATOR_RE, slice, MacroArgumentError, WORD_RE$1, NUMBER_RE$1, WORD_OR_PUNCT_RE, LEADING_OPERATOR_RE, takesRest, SUB_MACRO_PARAMETERS, RESERVED_NAME, isArrayIndex, hasOwn, createNamespace, parses, CONDITION_MACROS, PASSAGE_BODIES, holdsByDefault, JS_ESCAPE_RE, textPiece, registeredParameters, WIDGET_PARAMETERS, NOT_MARKUP, NOT_MARKUP_TAGS$1, BRANCH_MACROS, didYouMean, PASSAGE_ARGUMENT_HINT, BARE_WORD_RE, NUMBER_RE, IDENT_RE, KEY_RE, ARROW_RE, LINE_END_RE, ARRAY_INDEX_RE, UNSUPPORTED_UNDEFINED, Reader, VAR_PATH_RE, QUOTED_VAR_ARG_RE, VALID_VAR_TYPES, PRIMITIVE_SAMPLES, UNSUPPORTED_TYPE, NO_STORE_VAR_MACROS, FIELD_PATH_RE, CLOSERS, BLOCK_WORDS, NOT_PARAMETERS, DECLARATIONS, WRITE_RE, MUTATORS, MUTATING_CALL_RE, BEFORE_BINDING, isWordChar, Bindings, CALL_RE, IDENTIFIER_ARGUMENT_RE, WORD_RE, MODIFIER_RE, KEY_START_RE, CONFIG_KEYS, ConfigReader, stringOf, booleanOf, textOf, stringsOf, VOID_ELEMENTS, characterEntities, own, hasOwnProperty, asciiAlpha, asciiAlphanumeric, asciiAtext, asciiDigit, asciiHexDigit, asciiPunctuation, unicodePunctuation, unicodeWhitespace, content$1, EditMap$1, document$1, containerConstruct, attention, autolink, blankLine, blockQuote, characterEscape, characterReference, nonLazyContinuation, codeFenced, codeIndented, furtherStart, codeText, SpliceBuffer, content, continuationConstruct, definition, titleBefore, hardBreakEscape, headingAtx, htmlBlockNames, htmlRawNames, htmlFlow, blankLineBefore, nonLazyContinuationStart, htmlText, labelEnd, resourceConstruct, referenceFullConstruct, referenceCollapsedConstruct, labelStartImage, labelStartLink, lineEnding, thematicBreak, list, listItemPrefixWhitespaceConstruct, indentConstruct, setextUnderline, flow$1, resolver, string$1, text$1, constructs_exports, document, contentInitial, flowInitial, flow, string, text, insideSpan, attentionMarkers, disable, search, alignment, EditMap, DEFAULT_PRETTIER_OPTIONS, SVG_PLACEHOLDERS, SPINDLE_PLACEHOLDERS, DEFAULT_DEDENTING, WHITESPACE_AS_WRITTEN, LIST_ITEM_REGEX, CODE_FENCE_REGEX, NOT_MARKUP_TAGS;
21262
+ var __defProp2, __exportAll, NameMap, NameSet, PARAMETER_TYPES, STRING_HOLDS, metadataRegistry, companionParents, SIGIL_SCOPES, SIGIL_CHARS, grammar_shared_default, LB, RB, SIGIL_SCOPES$1, withSelectors, VOID_TAGS, BRANCH_PARENT$1, LINK_SEPARATORS, NO_SELECTORS, EMAIL_AUTOLINK, peg$SyntaxError, BLOCK_MACROS, BLOCK_WIDGETS, DEFINED_BLOCK_MACROS, RAW_BODY_MACROS, BRANCHING, quoteArg, last$1, BRANCH_PARENT, lowerName, nameOf, closerOf, closes, astralIdentifierCodes, astralIdentifierStartCodes, nonASCIIidentifierChars, nonASCIIidentifierStartChars, reservedWords, ecma5AndLessKeywords, keywords$1, keywordRelationalOperator, nonASCIIidentifierStart, nonASCIIidentifier, TokenType, beforeExpr, startsExpr, keywords, types$1, lineBreak, lineBreakG, nonASCIIwhitespace, skipWhiteSpace, ref, hasOwnProperty$1, toString, hasOwn$1, isArray, regexpCache, loneSurrogate, Position, SourceLocation, defaultOptions, warnedAboutEcmaVersion, SCOPE_TOP, SCOPE_FUNCTION, SCOPE_ASYNC, SCOPE_GENERATOR, SCOPE_ARROW, SCOPE_SIMPLE_CATCH, SCOPE_SUPER, SCOPE_DIRECT_SUPER, SCOPE_CLASS_STATIC_BLOCK, SCOPE_CLASS_FIELD_INIT, SCOPE_SWITCH, SCOPE_VAR, BIND_NONE, BIND_VAR, BIND_LEXICAL, BIND_FUNCTION, BIND_SIMPLE_CATCH, BIND_OUTSIDE, Parser, prototypeAccessors, pp$9, literal, DestructuringErrors, pp$8, loopLabel, switchLabel, empty$1, FUNC_STATEMENT, FUNC_HANGING_STATEMENT, FUNC_NULLABLE_ID, pp$7, TokContext, types, pp$6, pp$5, empty, pp$4, pp$3, Scope, Node, pp$2, scriptValuesAddedInUnicode, ecma9BinaryProperties, ecma10BinaryProperties, ecma11BinaryProperties, ecma12BinaryProperties, ecma13BinaryProperties, unicodeBinaryProperties, unicodeBinaryPropertiesOfStrings, unicodeGeneralCategoryValues, ecma9ScriptValues, ecma10ScriptValues, ecma11ScriptValues, ecma12ScriptValues, ecma13ScriptValues, unicodeScriptValues, data, ecmaVersion, i, list$2, pp$1, BranchID, RegExpValidationState, CharSetNone, CharSetOk, CharSetString, Token, pp, INVALID_TEMPLATE_ESCAPE_ERROR, OPTIONS, AT_NAME_RE, TRANS_NAME_RE, SIGIL_IDENT_RE, LINE_BREAK_RE, NOT_A_BODY_RE, OPERAND_ENDS, SigilParser, OPENERS, CLOSERS$1, CodeSyntaxError, last, CLOSER, isNode, NAMESPACE_NAME, WORD_RE$2, FLAGS_RE, WORDS_BEFORE_STRING, NON_STRING_QUOTE_PREFIX, memoInput, memo, defaultCodeEnd, defaultHooks, MarkupError, OFFSET_FIELD, listeners, TRAILING_OPERATOR_RE, slice, MacroArgumentError, WORD_RE$1, NUMBER_RE$1, WORD_OR_PUNCT_RE, LEADING_OPERATOR_RE, takesRest, SUB_MACRO_PARAMETERS, RESERVED_NAME, isArrayIndex, hasOwn, createNamespace, parses, CONDITION_MACROS, PASSAGE_BODIES, holdsByDefault, JS_ESCAPE_RE, textPiece, registeredParameters, WIDGET_PARAMETERS, NOT_MARKUP, NOT_MARKUP_TAGS$1, BRANCH_MACROS, didYouMean, PASSAGE_ARGUMENT_HINT, BARE_WORD_RE, NUMBER_RE, IDENT_RE, KEY_RE, ARROW_RE, LINE_END_RE, ARRAY_INDEX_RE, UNSUPPORTED_UNDEFINED, Reader, VAR_PATH_RE, QUOTED_VAR_ARG_RE, VALID_VAR_TYPES, PRIMITIVE_SAMPLES, UNSUPPORTED_TYPE, NO_STORE_VAR_MACROS, FIELD_PATH_RE, CLOSERS, BLOCK_WORDS, NOT_PARAMETERS, DECLARATIONS, WRITE_RE, MUTATORS, MUTATING_CALL_RE, BEFORE_BINDING, isWordChar, Bindings, CALL_RE, IDENTIFIER_ARGUMENT_RE, WORD_RE, MODIFIER_RE, KEY_START_RE, CONFIG_KEYS, ConfigReader, stringOf, booleanOf, textOf, stringsOf, VOID_ELEMENTS, characterEntities, own, hasOwnProperty, asciiAlpha, asciiAlphanumeric, asciiAtext, asciiDigit, asciiHexDigit, asciiPunctuation, unicodePunctuation, unicodeWhitespace, content$1, EditMap$1, document$1, containerConstruct, attention, autolink, blankLine, blockQuote, characterEscape, characterReference, nonLazyContinuation, codeFenced, codeIndented, furtherStart, codeText, SpliceBuffer, content, continuationConstruct, definition, titleBefore, hardBreakEscape, headingAtx, htmlBlockNames, htmlRawNames, htmlFlow, blankLineBefore, nonLazyContinuationStart, htmlText, labelEnd, resourceConstruct, referenceFullConstruct, referenceCollapsedConstruct, labelStartImage, labelStartLink, lineEnding, thematicBreak, list, listItemPrefixWhitespaceConstruct, indentConstruct, setextUnderline, flow$1, resolver, string$1, text$1, constructs_exports, document, contentInitial, flowInitial, flow, string, text, insideSpan, attentionMarkers, disable, search, alignment, EditMap, DEFAULT_PRETTIER_OPTIONS, SVG_PLACEHOLDERS, SPINDLE_PLACEHOLDERS, PLACEHOLDER_PATTERN, DEFAULT_DEDENTING, WHITESPACE_AS_WRITTEN, LIST_ITEM_REGEX, CODE_FENCE_REGEX, NO_WRAP, NOT_MARKUP_TAGS;
20919
21263
  var init_story_variables = __esm({
20920
21264
  "node_modules/@rohal12/spindle/dist/pkg/story-variables.js"() {
20921
21265
  __defProp2 = Object.defineProperty;
@@ -26268,6 +26612,7 @@ var init_story_variables = __esm({
26268
26612
  braceIsBlock(prevType) {
26269
26613
  if (prevType === types$1.colon && this.colonEndsTernary) return false;
26270
26614
  if (prevType === types$1.braceR && this.closedBlock) return true;
26615
+ if (prevType === types$1._do) return true;
26271
26616
  if (prevType === types$1.name && this.prevValue === "static") return true;
26272
26617
  if (this.breakHere && OPERAND_ENDS.has(prevType)) {
26273
26618
  const { context } = this;
@@ -26369,7 +26714,7 @@ var init_story_variables = __esm({
26369
26714
  WORD_RE$1 = /\w+/y;
26370
26715
  NUMBER_RE$1 = /[-+]?(?:\d+\.?\d*|\.\d+)/y;
26371
26716
  WORD_OR_PUNCT_RE = /\S+/y;
26372
- LEADING_OPERATOR_RE = /^(?:[-+*/&|^=<>?:,.]|%(?![A-Za-z_]))/;
26717
+ LEADING_OPERATOR_RE = /^(?:[-+*/&|^=<>?:,]|\.(?!\d)|%(?![A-Za-z_]))/;
26373
26718
  takesRest = (param) => param.type === "expression" || param.type === "statements" || param.type === "passage" || param.type === "text";
26374
26719
  SUB_MACRO_PARAMETERS = /* @__PURE__ */ new Map([["option", [{
26375
26720
  name: "value",
@@ -30156,6 +30501,7 @@ var init_story_variables = __esm({
30156
30501
  DEFAULT_PRETTIER_OPTIONS = { tabWidth: 2 };
30157
30502
  SVG_PLACEHOLDERS = (i2) => [`<!--SVG:${i2}-->`];
30158
30503
  SPINDLE_PLACEHOLDERS = (i2) => [`<!--SP:${i2}-->`, `__SP${i2}__`];
30504
+ PLACEHOLDER_PATTERN = /<!--(?:SP|SVG):\d+-->|__SP\d+__/g;
30159
30505
  DEFAULT_DEDENTING = /* @__PURE__ */ new Set([
30160
30506
  "else",
30161
30507
  "elseif",
@@ -30166,6 +30512,21 @@ var init_story_variables = __esm({
30166
30512
  WHITESPACE_AS_WRITTEN = /<(?:pre|textarea)[\s>]|white-space\s*:/i;
30167
30513
  LIST_ITEM_REGEX = /^(?:[-+*]|\d{1,9}[.)])(?:[ \t]|$)/;
30168
30514
  CODE_FENCE_REGEX = /^(?:`{3,}|~{3,})/;
30515
+ NO_WRAP = /* @__PURE__ */ new Set([
30516
+ "atxHeading",
30517
+ "setextHeading",
30518
+ "table",
30519
+ "listOrdered",
30520
+ "listUnordered",
30521
+ "blockQuote",
30522
+ "definition",
30523
+ "thematicBreak",
30524
+ "htmlFlow",
30525
+ "codeText",
30526
+ "codeFenced",
30527
+ "link",
30528
+ "image"
30529
+ ]);
30169
30530
  NOT_MARKUP_TAGS = ["script", "stylesheet"];
30170
30531
  }
30171
30532
  });
@@ -31568,7 +31929,7 @@ function usagesOf(byUri, name) {
31568
31929
  }
31569
31930
  return results;
31570
31931
  }
31571
- var STORY_SCRIPT_PASSAGE, BUILTIN_CONTEXT, ARRAY_MEMBERS, DeclarationSet, VariableTracker;
31932
+ var BUILTIN_CONTEXT, ARRAY_MEMBERS, DeclarationSet, VariableTracker;
31572
31933
  var init_variable_tracker = __esm({
31573
31934
  "src/core/workspace/variable-tracker.ts"() {
31574
31935
  "use strict";
@@ -31578,7 +31939,6 @@ var init_variable_tracker = __esm({
31578
31939
  init_text();
31579
31940
  init_passage_index();
31580
31941
  init_declaration_check();
31581
- STORY_SCRIPT_PASSAGE = "StoryScript";
31582
31942
  BUILTIN_CONTEXT = { macros: builtinMacros, isBlock: isBlockMacro };
31583
31943
  ARRAY_MEMBERS = /* @__PURE__ */ new Set([
31584
31944
  ...Object.getOwnPropertyNames(Array.prototype),
@@ -31682,7 +32042,6 @@ var init_variable_tracker = __esm({
31682
32042
  const usages = [];
31683
32043
  const transientUsages = [];
31684
32044
  for (const passage of markup.passages) {
31685
- if (passage.passage.name === STORY_SCRIPT_PASSAGE) continue;
31686
32045
  for (const ref2 of collectVariableReferences2(passage)) {
31687
32046
  const usage = {
31688
32047
  uri,
@@ -31816,6 +32175,25 @@ var init_tokens = __esm({
31816
32175
  }
31817
32176
  });
31818
32177
 
32178
+ // src/core/markup/widgets.ts
32179
+ function widgetSources(passages, macros) {
32180
+ const sources = /* @__PURE__ */ new Map();
32181
+ for (const passage of passages) {
32182
+ if (!passage.isMarkup) continue;
32183
+ const { name, tags } = passage.passage;
32184
+ for (const definition2 of widgetDefinitions([{ name, tags, content: passage.content }], macros)) {
32185
+ sources.set(definition2, passage);
32186
+ }
32187
+ }
32188
+ return sources;
32189
+ }
32190
+ var init_widgets = __esm({
32191
+ "src/core/markup/widgets.ts"() {
32192
+ "use strict";
32193
+ init_tooling();
32194
+ }
32195
+ });
32196
+
31819
32197
  // src/core/workspace/widget-registry.ts
31820
32198
  var WidgetRegistry;
31821
32199
  var init_widget_registry = __esm({
@@ -31823,40 +32201,45 @@ var init_widget_registry = __esm({
31823
32201
  "use strict";
31824
32202
  init_tooling();
31825
32203
  init_tokens();
32204
+ init_widgets();
31826
32205
  WidgetRegistry = class {
31827
32206
  /** Widgets keyed by lower-cased name; Spindle resolves widgets case-insensitively. */
31828
32207
  widgets = /* @__PURE__ */ new Map();
32208
+ /** Half-typed declarations remain discoverable in the editor, without replacing effective widgets. */
32209
+ incomplete = /* @__PURE__ */ new Map();
31829
32210
  /** Per-URI set of lower-cased macro names opened in that document. */
31830
32211
  invokedByUri = /* @__PURE__ */ new Map();
31831
32212
  /**
31832
32213
  * Read the widget definitions of `passages` (all of them, in workspace
31833
- * order; a name defined twice keeps the later definition, as when the
31834
- * runtime registers them).
32214
+ * order). Public tooling selects the closed definitions in runtime phase
32215
+ * order, preserving their identities so the original source is retained.
31835
32216
  */
31836
32217
  scan(passages, macros) {
31837
32218
  this.widgets.clear();
31838
- const known = [...macros];
31839
- for (const markup of passages) {
31840
- if (!markup.isMarkup) continue;
31841
- const { name, tags } = markup.passage;
31842
- for (const definition2 of widgetDefinitions([{ name, tags, content: markup.content }], known)) {
31843
- this.widgets.set(definition2.name.toLowerCase(), {
31844
- tooling: definition2,
31845
- name: definition2.name,
31846
- params: definition2.params,
31847
- uri: markup.passage.uri,
31848
- range: markup.range(definition2.start, definition2.end),
31849
- nameRange: markup.range(definition2.nameStart, definition2.nameEnd),
31850
- block: definition2.block
31851
- });
31852
- }
32219
+ this.incomplete.clear();
32220
+ const sources = widgetSources(passages, [...macros]);
32221
+ const effective = new Set(effectiveWidgetDefinitions([...sources.keys()]));
32222
+ for (const [definition2, markup] of sources) {
32223
+ const widget = {
32224
+ tooling: definition2,
32225
+ name: definition2.name,
32226
+ params: definition2.params,
32227
+ uri: markup.passage.uri,
32228
+ range: markup.range(definition2.start, definition2.end),
32229
+ nameRange: markup.range(definition2.nameStart, definition2.nameEnd),
32230
+ block: definition2.block
32231
+ };
32232
+ const key = definition2.name.toLowerCase();
32233
+ if (effective.has(definition2)) this.widgets.set(key, widget);
32234
+ else if (definition2.closeStart === void 0) this.incomplete.set(key, widget);
31853
32235
  }
31854
32236
  }
31855
- /** Get a widget definition by name (case-insensitive). */
32237
+ /** The effective definition, or an incomplete declaration while its first definition is being typed. */
31856
32238
  getWidget(name) {
31857
- return this.widgets.get(name.toLowerCase());
32239
+ const key = name.toLowerCase();
32240
+ return this.widgets.get(key) ?? this.incomplete.get(key);
31858
32241
  }
31859
- /** Get all registered widget definitions. */
32242
+ /** Get the effective registered definitions, excluding incomplete editor declarations. */
31860
32243
  getAllWidgets() {
31861
32244
  return Array.from(this.widgets.values());
31862
32245
  }
@@ -31937,7 +32320,7 @@ var init_markup_index = __esm({
31937
32320
 
31938
32321
  // src/core/workspace/spindle-version.ts
31939
32322
  import { existsSync as existsSync3, readFileSync as readFileSync5 } from "node:fs";
31940
- import { dirname as dirname2, join as join3, resolve as resolve3 } from "node:path";
32323
+ import { dirname as dirname2, join as join3, resolve as resolve4 } from "node:path";
31941
32324
  import { fileURLToPath } from "node:url";
31942
32325
  function parseSpindleVersion(text3) {
31943
32326
  const m = /^\s*v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?\s*$/.exec(text3);
@@ -31993,7 +32376,7 @@ function readSpindlePackageVersion(file2) {
31993
32376
  });
31994
32377
  }
31995
32378
  function findUp(startDir, visit) {
31996
- let dir = resolve3(startDir);
32379
+ let dir = resolve4(startDir);
31997
32380
  for (; ; ) {
31998
32381
  const found = visit(dir);
31999
32382
  if (found) return found.version;
@@ -32674,7 +33057,9 @@ var init_workspace_model = __esm({
32674
33057
  this.documents.on("documentChanged", this.onDocumentChanged);
32675
33058
  this.rebuildAll();
32676
33059
  this.initialized = true;
32677
- this.scheduleModelReady();
33060
+ if (this.debounceTimer) clearTimeout(this.debounceTimer);
33061
+ this.debounceTimer = null;
33062
+ this.emit("modelReady");
32678
33063
  }
32679
33064
  /**
32680
33065
  * Re-run cross-document analysis and schedule 'modelReady', e.g. after
@@ -33889,16 +34274,15 @@ function buildReport(documents, workspace) {
33889
34274
  if (list3) list3.push(diagnostic);
33890
34275
  else markup.set(passage, [diagnostic]);
33891
34276
  }
33892
- const widgets = /* @__PURE__ */ new Map();
33893
- const widgetList = [];
34277
+ const sources = widgetSources(passages, macros);
34278
+ const widgetList = [...sources].map(([definition2, passage]) => ({ definition: definition2, passage }));
34279
+ const widgets = new Map(effectiveWidgetDefinitions([...sources.keys()]).map((definition2) => [
34280
+ definition2.name.toLowerCase(),
34281
+ { definition: definition2, passage: sources.get(definition2) }
34282
+ ]));
33894
34283
  const invoked = /* @__PURE__ */ new Set();
33895
34284
  for (const passage of passages) {
33896
34285
  if (!passage.isMarkup) continue;
33897
- for (const definition2 of widgetDefinitions([{ name: passage.passage.name, content: passage.content, tags: passage.passage.tags }], macros)) {
33898
- const widget = { definition: definition2, passage };
33899
- widgets.set(definition2.name.toLowerCase(), widget);
33900
- widgetList.push(widget);
33901
- }
33902
34286
  for (const token of macroTokens(passage)) {
33903
34287
  if (!token.isClose) invoked.add(token.name.toLowerCase());
33904
34288
  }
@@ -34211,14 +34595,12 @@ function isReadInBody(passage, bodyStart, bodyEnd, name, macroStart, macroEnd) {
34211
34595
  }
34212
34596
  for (const piece of passage.pieces) {
34213
34597
  if (piece.kind !== "code") continue;
34214
- let read = false;
34215
- lexJs(piece.code, {
34216
- variable(sigil, found, index, _nesting, end) {
34217
- if (sigil !== "_" || found !== name || !eligible(pieceOffset(piece, index))) return;
34218
- if (!/^\s*=(?![=>])/.test(maskLiterals(piece.code.slice(end)))) read = true;
34219
- }
34220
- }, piece.goal);
34221
- if (read) return true;
34598
+ try {
34599
+ if (parseCode(piece.code, piece.goal).refs.some(
34600
+ (ref2) => ref2.sigil === "_" && ref2.name === name && ref2.read && eligible(pieceOffset(piece, ref2.start))
34601
+ )) return true;
34602
+ } catch {
34603
+ }
34222
34604
  }
34223
34605
  return false;
34224
34606
  }
@@ -34388,6 +34770,7 @@ var init_diagnostics = __esm({
34388
34770
  init_diagnostic_codes();
34389
34771
  init_tokens();
34390
34772
  init_source_view();
34773
+ init_widgets();
34391
34774
  init_argument_lexer();
34392
34775
  init_parameter_validator();
34393
34776
  init_link_parser();
@@ -34629,7 +35012,7 @@ var check_exports = {};
34629
35012
  __export(check_exports, {
34630
35013
  runCheck: () => runCheck
34631
35014
  });
34632
- import { resolve as resolve4 } from "node:path";
35015
+ import { resolve as resolve5 } from "node:path";
34633
35016
  import { pathToFileURL as pathToFileURL3 } from "node:url";
34634
35017
  function parseArgs(args2) {
34635
35018
  const options = {
@@ -34705,7 +35088,7 @@ async function runCheck(args2) {
34705
35088
  let explicitConfig = null;
34706
35089
  if (options.configPath) {
34707
35090
  try {
34708
- explicitConfig = loadConfigFile(resolve4(cwd, options.configPath));
35091
+ explicitConfig = loadConfigFile(resolve5(cwd, options.configPath));
34709
35092
  } catch (err) {
34710
35093
  console.error(`spindle-lsp check: ${err instanceof Error ? err.message : String(err)}`);
34711
35094
  return 2;
@@ -35962,7 +36345,7 @@ var init_escape = __esm({
35962
36345
  });
35963
36346
 
35964
36347
  // node_modules/minimatch/dist/esm/index.js
35965
- var minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path, sep2, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
36348
+ var minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path, sep3, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
35966
36349
  var init_esm3 = __esm({
35967
36350
  "node_modules/minimatch/dist/esm/index.js"() {
35968
36351
  init_esm2();
@@ -36035,8 +36418,8 @@ var init_esm3 = __esm({
36035
36418
  win32: { sep: "\\" },
36036
36419
  posix: { sep: "/" }
36037
36420
  };
36038
- sep2 = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
36039
- minimatch.sep = sep2;
36421
+ sep3 = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
36422
+ minimatch.sep = sep3;
36040
36423
  GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
36041
36424
  minimatch.GLOBSTAR = GLOBSTAR;
36042
36425
  qmark2 = "[^/]";
@@ -36785,7 +37168,7 @@ var init_esm3 = __esm({
36785
37168
 
36786
37169
  // src/plugins/format/prettier-bridge.ts
36787
37170
  import { readFile } from "node:fs/promises";
36788
- import { basename, dirname as dirname3, extname, relative as relative3, resolve as resolve5 } from "node:path";
37171
+ import { basename, dirname as dirname3, extname, relative as relative3, resolve as resolve6 } from "node:path";
36789
37172
  import { fileURLToPath as fileURLToPath3 } from "node:url";
36790
37173
  async function loadPrettier(filePath) {
36791
37174
  prettier ??= import("prettier").catch(() => null);
@@ -36794,7 +37177,7 @@ async function loadPrettier(filePath) {
36794
37177
  let resolved = null;
36795
37178
  try {
36796
37179
  const path2 = filePath?.startsWith("file:") ? fileURLToPath3(filePath) : filePath;
36797
- const target = path2 ?? resolve5(process.cwd(), "story.tw");
37180
+ const target = path2 ?? resolve6(process.cwd(), "story.tw");
36798
37181
  resolved = process.env.SPINDLE_LSP_TRUSTED_FORMAT === "1" ? await p.resolveConfig(target, { useCache: false }) : await loadDataConfig(p, target);
36799
37182
  } catch {
36800
37183
  }
@@ -36809,7 +37192,7 @@ async function loadDataConfig(p, target) {
36809
37192
  if (!config2 || typeof config2 !== "object" || Array.isArray(config2)) return null;
36810
37193
  const { overrides, ...base } = config2;
36811
37194
  let options = base;
36812
- const file2 = relative3(dirname3(configFile), resolve5(target)).replaceAll("\\", "/");
37195
+ const file2 = relative3(dirname3(configFile), resolve6(target)).replaceAll("\\", "/");
36813
37196
  for (const override of Array.isArray(overrides) ? overrides : []) {
36814
37197
  if (matchesPatterns(file2, override.files, override.excludeFiles)) {
36815
37198
  options = { ...options, ...override.options };
@@ -59323,7 +59706,7 @@ var init_protocol = __esm({
59323
59706
  return;
59324
59707
  }
59325
59708
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
59326
- await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
59709
+ await new Promise((resolve8) => setTimeout(resolve8, pollInterval));
59327
59710
  options?.signal?.throwIfAborted();
59328
59711
  }
59329
59712
  } catch (error48) {
@@ -59340,7 +59723,7 @@ var init_protocol = __esm({
59340
59723
  */
59341
59724
  request(request, resultSchema, options) {
59342
59725
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
59343
- return new Promise((resolve7, reject) => {
59726
+ return new Promise((resolve8, reject) => {
59344
59727
  const earlyReject = (error48) => {
59345
59728
  reject(error48);
59346
59729
  };
@@ -59418,7 +59801,7 @@ var init_protocol = __esm({
59418
59801
  if (!parseResult.success) {
59419
59802
  reject(parseResult.error);
59420
59803
  } else {
59421
- resolve7(parseResult.data);
59804
+ resolve8(parseResult.data);
59422
59805
  }
59423
59806
  } catch (error48) {
59424
59807
  reject(error48);
@@ -59680,12 +60063,12 @@ var init_protocol = __esm({
59680
60063
  }
59681
60064
  } catch {
59682
60065
  }
59683
- return new Promise((resolve7, reject) => {
60066
+ return new Promise((resolve8, reject) => {
59684
60067
  if (signal.aborted) {
59685
60068
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
59686
60069
  return;
59687
60070
  }
59688
- const timeoutId = setTimeout(resolve7, interval);
60071
+ const timeoutId = setTimeout(resolve8, interval);
59689
60072
  signal.addEventListener("abort", () => {
59690
60073
  clearTimeout(timeoutId);
59691
60074
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -62712,7 +63095,7 @@ var require_compile = __commonJS({
62712
63095
  const schOrFunc = root.refs[ref2];
62713
63096
  if (schOrFunc)
62714
63097
  return schOrFunc;
62715
- let _sch = resolve7.call(this, root, ref2);
63098
+ let _sch = resolve8.call(this, root, ref2);
62716
63099
  if (_sch === void 0) {
62717
63100
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref2];
62718
63101
  const { schemaId } = this.opts;
@@ -62739,7 +63122,7 @@ var require_compile = __commonJS({
62739
63122
  function sameSchemaEnv(s1, s2) {
62740
63123
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
62741
63124
  }
62742
- function resolve7(root, ref2) {
63125
+ function resolve8(root, ref2) {
62743
63126
  let sch;
62744
63127
  while (typeof (sch = this.refs[ref2]) == "string")
62745
63128
  ref2 = sch;
@@ -63314,7 +63697,7 @@ var require_fast_uri = __commonJS({
63314
63697
  }
63315
63698
  return uri;
63316
63699
  }
63317
- function resolve7(baseURI, relativeURI, options) {
63700
+ function resolve8(baseURI, relativeURI, options) {
63318
63701
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
63319
63702
  const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
63320
63703
  schemelessOptions.skipEscape = true;
@@ -63541,7 +63924,7 @@ var require_fast_uri = __commonJS({
63541
63924
  var fastUri = {
63542
63925
  SCHEMES,
63543
63926
  normalize,
63544
- resolve: resolve7,
63927
+ resolve: resolve8,
63545
63928
  resolveComponent,
63546
63929
  equal,
63547
63930
  serialize,
@@ -67699,7 +68082,7 @@ var init_mcp = __esm({
67699
68082
  let task = createTaskResult.task;
67700
68083
  const pollInterval = task.pollInterval ?? 5e3;
67701
68084
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
67702
- await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
68085
+ await new Promise((resolve8) => setTimeout(resolve8, pollInterval));
67703
68086
  const updatedTask = await extra.taskStore.getTask(taskId);
67704
68087
  if (!updatedTask) {
67705
68088
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -68308,12 +68691,12 @@ var init_stdio2 = __esm({
68308
68691
  this.onclose?.();
68309
68692
  }
68310
68693
  send(message) {
68311
- return new Promise((resolve7) => {
68694
+ return new Promise((resolve8) => {
68312
68695
  const json2 = serializeMessage(message);
68313
68696
  if (this._stdout.write(json2)) {
68314
- resolve7();
68697
+ resolve8();
68315
68698
  } else {
68316
- this._stdout.once("drain", resolve7);
68699
+ this._stdout.once("drain", resolve8);
68317
68700
  }
68318
68701
  });
68319
68702
  }
@@ -68324,7 +68707,7 @@ var init_stdio2 = __esm({
68324
68707
  // src/mcp/play/sessions.ts
68325
68708
  import { randomBytes } from "node:crypto";
68326
68709
  import { statSync as statSync2 } from "node:fs";
68327
- import { dirname as dirname4, resolve as resolve6 } from "node:path";
68710
+ import { dirname as dirname4, resolve as resolve7 } from "node:path";
68328
68711
  function missingPlayMessage() {
68329
68712
  return `spindle_play needs @rohal12/spindle ${PLAY_SPINDLE_VERSION} or later`;
68330
68713
  }
@@ -68414,7 +68797,7 @@ var init_sessions = __esm({
68414
68797
  this.starting++;
68415
68798
  try {
68416
68799
  const play = await this.load();
68417
- const path2 = resolve6(process.cwd(), storyPath);
68800
+ const path2 = resolve7(process.cwd(), storyPath);
68418
68801
  const { html, notes: storyNotes } = await play.resolveStoryHtml({ path: path2 });
68419
68802
  const notes = [...storyNotes, ...runtimeNote(path2, play.version)];
68420
68803
  const sessionOptions = { html, trusted: this.trustedHostCode };
@@ -70154,8 +70537,8 @@ var require_semaphore = __commonJS({
70154
70537
  this._waiting = [];
70155
70538
  }
70156
70539
  lock(thunk) {
70157
- return new Promise((resolve7, reject) => {
70158
- this._waiting.push({ thunk, resolve: resolve7, reject });
70540
+ return new Promise((resolve8, reject) => {
70541
+ this._waiting.push({ thunk, resolve: resolve8, reject });
70159
70542
  this.runNext();
70160
70543
  });
70161
70544
  }
@@ -71781,9 +72164,9 @@ ${JSON.stringify(message, null, 4)}`);
71781
72164
  if (typeof cancellationStrategy.sender.enableCancellation === "function") {
71782
72165
  cancellationStrategy.sender.enableCancellation(requestMessage);
71783
72166
  }
71784
- return new Promise(async (resolve7, reject) => {
72167
+ return new Promise(async (resolve8, reject) => {
71785
72168
  const resolveWithCleanup = (r) => {
71786
- resolve7(r);
72169
+ resolve8(r);
71787
72170
  cancellationStrategy.sender.cleanup(id);
71788
72171
  disposable?.dispose();
71789
72172
  };
@@ -77425,8 +77808,8 @@ var require_server = __commonJS({
77425
77808
  if (value instanceof Promise) {
77426
77809
  return value;
77427
77810
  } else if (Is3.thenable(value)) {
77428
- return new Promise((resolve7, reject) => {
77429
- value.then((resolved) => resolve7(resolved), (error48) => reject(error48));
77811
+ return new Promise((resolve8, reject) => {
77812
+ value.then((resolved) => resolve8(resolved), (error48) => reject(error48));
77430
77813
  });
77431
77814
  } else {
77432
77815
  return Promise.resolve(value);
@@ -77710,7 +78093,7 @@ var require_files = __commonJS({
77710
78093
  Object.defineProperty(exports, "__esModule", { value: true });
77711
78094
  exports.FileSystem = void 0;
77712
78095
  exports.uriToFilePath = uriToFilePath;
77713
- exports.resolve = resolve7;
78096
+ exports.resolve = resolve8;
77714
78097
  exports.resolveGlobalNodePath = resolveGlobalNodePath;
77715
78098
  exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
77716
78099
  exports.resolveModulePath = resolveModulePath;
@@ -77739,7 +78122,7 @@ var require_files = __commonJS({
77739
78122
  function isWindows() {
77740
78123
  return process.platform === "win32";
77741
78124
  }
77742
- function resolve7(moduleName, nodePath, cwd, tracer) {
78125
+ function resolve8(moduleName, nodePath, cwd, tracer) {
77743
78126
  const nodePathKey = "NODE_PATH";
77744
78127
  const app = [
77745
78128
  "var p = process;",
@@ -77758,7 +78141,7 @@ var require_files = __commonJS({
77758
78141
  "}",
77759
78142
  "});"
77760
78143
  ].join("");
77761
- return new Promise((resolve8, reject) => {
78144
+ return new Promise((resolve9, reject) => {
77762
78145
  const env = process.env;
77763
78146
  const newEnv = /* @__PURE__ */ Object.create(null);
77764
78147
  Object.keys(env).forEach((key) => newEnv[key] = env[key]);
@@ -77790,7 +78173,7 @@ var require_files = __commonJS({
77790
78173
  if (message2.c === "r") {
77791
78174
  cp.send({ c: "e" });
77792
78175
  if (message2.s) {
77793
- resolve8(message2.r);
78176
+ resolve9(message2.r);
77794
78177
  } else {
77795
78178
  reject(new Error(`Failed to resolve module: ${moduleName}`));
77796
78179
  }
@@ -77918,17 +78301,17 @@ var require_files = __commonJS({
77918
78301
  if (!path2.isAbsolute(nodePath)) {
77919
78302
  nodePath = path2.join(workspaceRoot, nodePath);
77920
78303
  }
77921
- return resolve7(moduleName, nodePath, nodePath, tracer).then((value) => {
78304
+ return resolve8(moduleName, nodePath, nodePath, tracer).then((value) => {
77922
78305
  if (FileSystem.isParent(nodePath, value)) {
77923
78306
  return value;
77924
78307
  } else {
77925
78308
  return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
77926
78309
  }
77927
78310
  }).then(void 0, (_error) => {
77928
- return resolve7(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
78311
+ return resolve8(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
77929
78312
  });
77930
78313
  } else {
77931
- return resolve7(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
78314
+ return resolve8(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
77932
78315
  }
77933
78316
  }
77934
78317
  }
@@ -78010,10 +78393,10 @@ var require_ril = __commonJS({
78010
78393
  return api_1.Disposable.create(() => this.stream.off("end", listener));
78011
78394
  }
78012
78395
  write(data2, encoding) {
78013
- return new Promise((resolve7, reject) => {
78396
+ return new Promise((resolve8, reject) => {
78014
78397
  const callback = (error48) => {
78015
78398
  if (error48 === void 0 || error48 === null) {
78016
- resolve7();
78399
+ resolve8();
78017
78400
  } else {
78018
78401
  reject(error48);
78019
78402
  }
@@ -78305,10 +78688,10 @@ var require_main = __commonJS({
78305
78688
  }
78306
78689
  function createClientPipeTransport(pipeName, encoding = "utf-8") {
78307
78690
  let connectResolve;
78308
- const connected = new Promise((resolve7, _reject) => {
78309
- connectResolve = resolve7;
78691
+ const connected = new Promise((resolve8, _reject) => {
78692
+ connectResolve = resolve8;
78310
78693
  });
78311
- return new Promise((resolve7, reject) => {
78694
+ return new Promise((resolve8, reject) => {
78312
78695
  const server = (0, net_1.createServer)((socket) => {
78313
78696
  server.close();
78314
78697
  connectResolve([
@@ -78319,7 +78702,7 @@ var require_main = __commonJS({
78319
78702
  server.on("error", reject);
78320
78703
  server.listen(pipeName, () => {
78321
78704
  server.removeListener("error", reject);
78322
- resolve7({
78705
+ resolve8({
78323
78706
  onConnected: () => {
78324
78707
  return connected;
78325
78708
  }
@@ -78336,10 +78719,10 @@ var require_main = __commonJS({
78336
78719
  }
78337
78720
  function createClientSocketTransport(port, encoding = "utf-8") {
78338
78721
  let connectResolve;
78339
- const connected = new Promise((resolve7, _reject) => {
78340
- connectResolve = resolve7;
78722
+ const connected = new Promise((resolve8, _reject) => {
78723
+ connectResolve = resolve8;
78341
78724
  });
78342
- return new Promise((resolve7, reject) => {
78725
+ return new Promise((resolve8, reject) => {
78343
78726
  const server = (0, net_1.createServer)((socket) => {
78344
78727
  server.close();
78345
78728
  connectResolve([
@@ -78356,7 +78739,7 @@ var require_main = __commonJS({
78356
78739
  return;
78357
78740
  }
78358
78741
  const boundPort = address.port;
78359
- resolve7({
78742
+ resolve8({
78360
78743
  port: () => boundPort,
78361
78744
  onConnected: () => {
78362
78745
  return connected;
@@ -79432,9 +79815,8 @@ function getDocumentVariableCompletions(sigil, cursor, workspace) {
79432
79815
  for (const passage of doc.passages) {
79433
79816
  for (const use of variableUses(passage)) if (use.sigil === sigil) names.add(use.name);
79434
79817
  }
79435
- for (const widget of workspace.widgets.getAllWidgets()) {
79436
- if (widget.uri !== doc.uri) continue;
79437
- for (const param of widget.params) if (param[0] === sigil) names.add(param.slice(1));
79818
+ for (const definition2 of widgetSources(doc.passages, doc.context.macros).keys()) {
79819
+ for (const param of definition2.params) if (param[0] === sigil) names.add(param.slice(1));
79438
79820
  }
79439
79821
  return [...names].map((name) => ({
79440
79822
  label: `${sigil}${name}`,
@@ -79473,6 +79855,7 @@ var init_completions = __esm({
79473
79855
  "src/plugins/completions.ts"() {
79474
79856
  "use strict";
79475
79857
  init_tooling();
79858
+ init_widgets();
79476
79859
  init_passage_refs();
79477
79860
  init_link_runtime();
79478
79861
  init_markup_cursor();