@rohal12/spindle-lsp 0.15.38 → 0.15.39

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.38";
58
+ VERSION = false ? pkg.version : "0.15.39";
59
59
  }
60
60
  });
61
61
 
@@ -10640,11 +10640,6 @@ var init_file_inputs = __esm({
10640
10640
  });
10641
10641
 
10642
10642
  // node_modules/@rohal12/spindle/dist/pkg/story-variables.js
10643
- function effectiveNamedDefinitions(definitions) {
10644
- const latest = new NameMap();
10645
- for (const definition2 of definitions) latest.set(definition2.name, definition2);
10646
- return [...latest.values()];
10647
- }
10648
10643
  function isSigil(c) {
10649
10644
  return c !== void 0 && SIGIL_CHARS.has(c);
10650
10645
  }
@@ -11067,79 +11062,96 @@ function peg$parse(input2, options) {
11067
11062
  return joinText(items);
11068
11063
  }
11069
11064
  function peg$f1() {
11070
- return !textMode;
11065
+ return !htmlTextTag;
11071
11066
  }
11072
11067
  function peg$f2() {
11073
- return !textMode;
11068
+ return !htmlTextTag;
11074
11069
  }
11075
- function peg$f3(tag) {
11076
- return tag;
11070
+ function peg$f3() {
11071
+ return !htmlTextTag;
11077
11072
  }
11078
11073
  function peg$f4() {
11074
+ return !textMode && !htmlTextTag;
11075
+ }
11076
+ function peg$f5() {
11077
+ return !textMode && !htmlTextTag;
11078
+ }
11079
+ function peg$f6(tag) {
11080
+ if (!tag.isSelfClose && HTML_TEXT_ELEMENTS.has(tag.lower)) htmlTextTag = tag.lower;
11081
+ return tag;
11082
+ }
11083
+ function peg$f7() {
11079
11084
  return !textMode;
11080
11085
  }
11081
- function peg$f5(tag) {
11086
+ function peg$f8(tag) {
11087
+ return !htmlTextTag || tag.lower === htmlTextTag;
11088
+ }
11089
+ function peg$f9(tag) {
11090
+ htmlTextTag = "";
11082
11091
  return VOID_TAGS.has(tag.lower) ? null : tag;
11083
11092
  }
11084
- function peg$f6(tag) {
11093
+ function peg$f10(tag) {
11085
11094
  rawName = tag.lower;
11086
11095
  return tag.kind === "open" && hooks.isRaw(rawName);
11087
11096
  }
11088
- function peg$f7(tag, b) {
11097
+ function peg$f11(tag, b) {
11089
11098
  return b;
11090
11099
  }
11091
- function peg$f8(tag, body) {
11100
+ function peg$f12(tag, body) {
11092
11101
  return body ? [tag, body] : tag;
11093
11102
  }
11094
- function peg$f9(tag) {
11103
+ function peg$f13(tag) {
11095
11104
  return tag.kind === "close";
11096
11105
  }
11097
- function peg$f10(tag) {
11106
+ function peg$f14(tag) {
11098
11107
  return tag;
11099
11108
  }
11100
- function peg$f11() {
11109
+ function peg$f15() {
11101
11110
  return !textMode;
11102
11111
  }
11103
- function peg$f12(tag) {
11112
+ function peg$f16(tag) {
11104
11113
  return tag;
11105
11114
  }
11106
- function peg$f13(start) {
11115
+ function peg$f17(start) {
11107
11116
  return skipTo(hooks.rawBodyEnd(input2, start, rawName));
11108
11117
  }
11109
- function peg$f14(start) {
11118
+ function peg$f18(start) {
11110
11119
  return skipEnd - offset2();
11111
11120
  }
11112
- function peg$f15(start, body, end) {
11121
+ function peg$f19(start, body, end) {
11113
11122
  const loc = {
11114
11123
  start: { offset: start },
11115
11124
  end: { offset: start + body.length }
11116
11125
  };
11117
11126
  return [body ? lexeme("text", loc, { value: body }) : null, end];
11118
11127
  }
11119
- function peg$f16() {
11128
+ function peg$f20() {
11120
11129
  return completionMode;
11121
11130
  }
11122
- function peg$f17(body) {
11131
+ function peg$f21(body) {
11123
11132
  return lexeme("text", location(), { value: body });
11124
11133
  }
11125
- function peg$f18() {
11134
+ function peg$f22() {
11126
11135
  return offset2();
11127
11136
  }
11128
- function peg$f19(value) {
11137
+ function peg$f23(value) {
11129
11138
  return lexeme("text", location(), { value });
11130
11139
  }
11131
- function peg$f20(value) {
11140
+ function peg$f24() {
11141
+ return completionMode || offset2() <= lastCommentClose;
11142
+ }
11143
+ function peg$f25(value) {
11132
11144
  const node2 = lexeme("text", location(), { value });
11133
11145
  node2.comment = true;
11134
11146
  return node2;
11135
11147
  }
11136
- function peg$f21(bs2) {
11148
+ function peg$f26(bs2) {
11137
11149
  return bs2.length % 2 === 1;
11138
11150
  }
11139
- function peg$f22(bs2, c) {
11151
+ function peg$f27(bs2, c) {
11140
11152
  return c;
11141
11153
  }
11142
- function peg$f23(bs2, brace) {
11154
+ function peg$f28(bs2, brace) {
11143
11155
  const loc = location();
11144
11156
  const next = input2.charAt(loc.end.offset);
11145
11157
  if (textMode) {
@@ -11156,48 +11168,48 @@ function peg$parse(input2, options) {
11156
11168
  escaped.escape = true;
11157
11169
  return bs2.length > 1 ? [before, escaped] : escaped;
11158
11170
  }
11159
- function peg$f24() {
11171
+ function peg$f29() {
11160
11172
  return lexeme("text", location(), { value: LB });
11161
11173
  }
11162
- function peg$f25() {
11163
- return !textMode;
11174
+ function peg$f30() {
11175
+ return !textMode && !htmlTextTag;
11164
11176
  }
11165
- function peg$f26() {
11177
+ function peg$f31() {
11166
11178
  return lexeme("text", location(), { value: "<" });
11167
11179
  }
11168
- function peg$f27() {
11180
+ function peg$f32() {
11169
11181
  return lexeme("text", location(), { value: "[" });
11170
11182
  }
11171
- function peg$f28() {
11183
+ function peg$f33() {
11172
11184
  return !textMode;
11173
11185
  }
11174
- function peg$f29(ss2, s, at3, inner) {
11186
+ function peg$f34(ss2, s, at3, inner) {
11175
11187
  const link = lexeme("link", location(), parseLink(inner, at3, (separator) => linkSeparatorIndex(inner, at3, separator)));
11176
11188
  link.selectorSpan = selectorSpan(s, ss2, at3);
11177
11189
  return withSelectors(link, s);
11178
11190
  }
11179
- function peg$f30() {
11191
+ function peg$f35() {
11180
11192
  return !textMode;
11181
11193
  }
11182
- function peg$f31() {
11194
+ function peg$f36() {
11183
11195
  fail("Unclosed link: [[ without ]]", location(), "unclosed-link");
11184
11196
  }
11185
- function peg$f32(parts) {
11197
+ function peg$f37(parts) {
11186
11198
  return selectorsOf(parts);
11187
11199
  }
11188
- function peg$f33() {
11200
+ function peg$f38() {
11189
11201
  return NO_SELECTORS;
11190
11202
  }
11191
- function peg$f34(s, end) {
11203
+ function peg$f39(s, end) {
11192
11204
  return {
11193
11205
  ...s,
11194
11206
  end
11195
11207
  };
11196
11208
  }
11197
- function peg$f35(prefix, name) {
11209
+ function peg$f40(prefix, name) {
11198
11210
  return [prefix, name];
11199
11211
  }
11200
- function peg$f36(ss2, s, sigil, nameStart, name) {
11212
+ function peg$f41(ss2, s, sigil, nameStart, name) {
11201
11213
  const variable = lexeme("variable", location(), {
11202
11214
  name,
11203
11215
  nameStart,
@@ -11207,7 +11219,7 @@ function peg$parse(input2, options) {
11207
11219
  variable.selectorSpan = selectorSpan(s, ss2, nameStart - 1);
11208
11220
  return withSelectors(variable, s);
11209
11221
  }
11210
- function peg$f37(ss2, s, after, expression) {
11222
+ function peg$f42(ss2, s, after, expression) {
11211
11223
  const node2 = lexeme("expression", location(), {
11212
11224
  expression,
11213
11225
  expressionStart: after,
@@ -11216,33 +11228,33 @@ function peg$parse(input2, options) {
11216
11228
  node2.selectorSpan = selectorSpan(s, ss2, after);
11217
11229
  return withSelectors(node2, s);
11218
11230
  }
11219
- function peg$f38() {
11231
+ function peg$f43() {
11220
11232
  fail("Unclosed {" + input2.substr(location().end.offset, 1) + "\u2026: no } ends it", location(), "unclosed-expression");
11221
11233
  }
11222
- function peg$f39(start) {
11234
+ function peg$f44(start) {
11223
11235
  const end = hooks.closeBrace(input2, start, start);
11224
11236
  return skipTo(end < 0 && completionMode ? input2.length : end);
11225
11237
  }
11226
- function peg$f40(start) {
11238
+ function peg$f45(start) {
11227
11239
  return skipEnd - offset2();
11228
11240
  }
11229
- function peg$f41(start, code) {
11241
+ function peg$f46(start, code) {
11230
11242
  return code;
11231
11243
  }
11232
- function peg$f42() {
11244
+ function peg$f47() {
11233
11245
  return completionMode;
11234
11246
  }
11235
- function peg$f43(ss2, s, start, close, name, nameEnd) {
11247
+ function peg$f48(ss2, s, start, close, name, nameEnd) {
11236
11248
  const end = hooks.closeBrace(input2, nameEnd, start);
11237
11249
  return skipTo(end < 0 && completionMode ? input2.length : end);
11238
11250
  }
11239
- function peg$f44(ss2, s, start, close, name, nameEnd) {
11251
+ function peg$f49(ss2, s, start, close, name, nameEnd) {
11240
11252
  return skipEnd - offset2();
11241
11253
  }
11242
- function peg$f45(ss2, s, start, close, name, nameEnd, args2) {
11254
+ function peg$f50(ss2, s, start, close, name, nameEnd, args2) {
11243
11255
  return args2;
11244
11256
  }
11245
- function peg$f46(ss2, s, start, close, name, nameEnd, tail) {
11257
+ function peg$f51(ss2, s, start, close, name, nameEnd, tail) {
11246
11258
  const loc = location();
11247
11259
  const lower = name.toLowerCase();
11248
11260
  const tag = lexeme("macro", loc, {
@@ -11268,19 +11280,19 @@ function peg$parse(input2, options) {
11268
11280
  }
11269
11281
  return tag;
11270
11282
  }
11271
- function peg$f47(s) {
11283
+ function peg$f52(s) {
11272
11284
  fail("A closing tag starts with a letter after {/", location(), "invalid-closer");
11273
11285
  }
11274
- function peg$f48(value) {
11286
+ function peg$f53(value) {
11275
11287
  return EMAIL_AUTOLINK.test(value);
11276
11288
  }
11277
- function peg$f49(value) {
11289
+ function peg$f54(value) {
11278
11290
  return lexeme("text", location(), { value });
11279
11291
  }
11280
- function peg$f50(value) {
11292
+ function peg$f55(value) {
11281
11293
  return lexeme("text", location(), { value });
11282
11294
  }
11283
- function peg$f51(tagStart, tag, list3, slash) {
11295
+ function peg$f56(tagStart, tag, list3, slash) {
11284
11296
  const lower = tag.toLowerCase();
11285
11297
  return lexeme("html", location(), {
11286
11298
  tag,
@@ -11293,7 +11305,7 @@ function peg$parse(input2, options) {
11293
11305
  isSelfClose: !!slash || VOID_TAGS.has(lower)
11294
11306
  });
11295
11307
  }
11296
- function peg$f52(tag, bad) {
11308
+ function peg$f57(tag, bad) {
11297
11309
  const c = input2.charAt(bad);
11298
11310
  if (!c) fail("Unclosed tag <" + tag + ": no > ends it (write &lt; for a < that starts no tag)", location(), "unclosed-tag");
11299
11311
  const at3 = {
@@ -11311,7 +11323,7 @@ function peg$parse(input2, options) {
11311
11323
  };
11312
11324
  fail("Unexpected " + JSON.stringify(c) + " in the tag <" + tag + ">: expected an attribute, or > to end the tag", at3, "unexpected-character");
11313
11325
  }
11314
- function peg$f53(tagStart, tag) {
11326
+ function peg$f58(tagStart, tag) {
11315
11327
  return lexeme("html", location(), {
11316
11328
  tag,
11317
11329
  lower: tag.toLowerCase(),
@@ -11323,14 +11335,14 @@ function peg$parse(input2, options) {
11323
11335
  isSelfClose: false
11324
11336
  });
11325
11337
  }
11326
- function peg$f54(nameStart, name) {
11338
+ function peg$f59(nameStart, name) {
11327
11339
  attrCode = hooks.isCodeAttribute(name);
11328
11340
  return true;
11329
11341
  }
11330
- function peg$f55(nameStart, name, v2) {
11342
+ function peg$f60(nameStart, name, v2) {
11331
11343
  return v2;
11332
11344
  }
11333
- function peg$f56(nameStart, name, value) {
11345
+ function peg$f61(nameStart, name, value) {
11334
11346
  const attribute = {
11335
11347
  name,
11336
11348
  value: value ? value.value : "",
@@ -11344,7 +11356,7 @@ function peg$parse(input2, options) {
11344
11356
  }
11345
11357
  return attribute;
11346
11358
  }
11347
- function peg$f57(start, value, end) {
11359
+ function peg$f62(start, value, end) {
11348
11360
  return {
11349
11361
  value,
11350
11362
  start,
@@ -11352,7 +11364,7 @@ function peg$parse(input2, options) {
11352
11364
  quote: '"'
11353
11365
  };
11354
11366
  }
11355
- function peg$f58(start, value, end) {
11367
+ function peg$f63(start, value, end) {
11356
11368
  return {
11357
11369
  value,
11358
11370
  start,
@@ -11360,36 +11372,36 @@ function peg$parse(input2, options) {
11360
11372
  quote: "'"
11361
11373
  };
11362
11374
  }
11363
- function peg$f59(q2) {
11375
+ function peg$f64(q2) {
11364
11376
  fail("Unclosed attribute value: the " + q2 + " here has no closing " + q2, location(), "unclosed-attribute");
11365
11377
  }
11366
- function peg$f60(start, value, end) {
11378
+ function peg$f65(start, value, end) {
11367
11379
  return {
11368
11380
  value,
11369
11381
  start,
11370
11382
  end
11371
11383
  };
11372
11384
  }
11373
- function peg$f61() {
11385
+ function peg$f66() {
11374
11386
  return !attrCode;
11375
11387
  }
11376
- function peg$f62(bs2) {
11388
+ function peg$f67(bs2) {
11377
11389
  return bs2.length % 2 === 1;
11378
11390
  }
11379
- function peg$f63() {
11391
+ function peg$f68() {
11380
11392
  return !attrCode;
11381
11393
  }
11382
- function peg$f64(start, nameEnd) {
11394
+ function peg$f69(start, nameEnd) {
11383
11395
  const end = hooks.closeBrace(input2, nameEnd, start);
11384
11396
  return skipTo(end < 0 && completionMode ? input2.length : end);
11385
11397
  }
11386
- function peg$f65(start, nameEnd) {
11398
+ function peg$f70(start, nameEnd) {
11387
11399
  return skipEnd - offset2();
11388
11400
  }
11389
- function peg$f66() {
11401
+ function peg$f71() {
11390
11402
  return !attrCode;
11391
11403
  }
11392
- function peg$f67() {
11404
+ function peg$f72() {
11393
11405
  return attrCode;
11394
11406
  }
11395
11407
  let peg$currPos = options.peg$currPos | 0;
@@ -11525,15 +11537,66 @@ function peg$parse(input2, options) {
11525
11537
  if (s0 === peg$FAILED) {
11526
11538
  s0 = peg$parseEscape();
11527
11539
  if (s0 === peg$FAILED) {
11528
- s0 = peg$parseComment();
11540
+ s0 = peg$currPos;
11541
+ peg$savedPos = peg$currPos;
11542
+ s1 = peg$f1();
11543
+ if (s1) s1 = void 0;
11544
+ else s1 = peg$FAILED;
11545
+ if (s1 !== peg$FAILED) {
11546
+ s2 = peg$parseComment();
11547
+ if (s2 !== peg$FAILED) {
11548
+ s1 = [s1, s2];
11549
+ s0 = s1;
11550
+ } else {
11551
+ peg$currPos = s0;
11552
+ s0 = peg$FAILED;
11553
+ }
11554
+ } else {
11555
+ peg$currPos = s0;
11556
+ s0 = peg$FAILED;
11557
+ }
11529
11558
  if (s0 === peg$FAILED) {
11530
- s0 = peg$parseLinkLexeme();
11559
+ s0 = peg$currPos;
11560
+ peg$savedPos = peg$currPos;
11561
+ s1 = peg$f2();
11562
+ if (s1) s1 = void 0;
11563
+ else s1 = peg$FAILED;
11564
+ if (s1 !== peg$FAILED) {
11565
+ s2 = peg$parseLinkLexeme();
11566
+ if (s2 !== peg$FAILED) {
11567
+ s1 = [s1, s2];
11568
+ s0 = s1;
11569
+ } else {
11570
+ peg$currPos = s0;
11571
+ s0 = peg$FAILED;
11572
+ }
11573
+ } else {
11574
+ peg$currPos = s0;
11575
+ s0 = peg$FAILED;
11576
+ }
11531
11577
  if (s0 === peg$FAILED) {
11532
- s0 = peg$parseEmailAutolink();
11578
+ s0 = peg$currPos;
11579
+ peg$savedPos = peg$currPos;
11580
+ s1 = peg$f3();
11581
+ if (s1) s1 = void 0;
11582
+ else s1 = peg$FAILED;
11583
+ if (s1 !== peg$FAILED) {
11584
+ s2 = peg$parseEmailAutolink();
11585
+ if (s2 !== peg$FAILED) {
11586
+ s1 = [s1, s2];
11587
+ s0 = s1;
11588
+ } else {
11589
+ peg$currPos = s0;
11590
+ s0 = peg$FAILED;
11591
+ }
11592
+ } else {
11593
+ peg$currPos = s0;
11594
+ s0 = peg$FAILED;
11595
+ }
11533
11596
  if (s0 === peg$FAILED) {
11534
11597
  s0 = peg$currPos;
11535
11598
  peg$savedPos = peg$currPos;
11536
- s1 = peg$f1();
11599
+ s1 = peg$f4();
11537
11600
  if (s1) s1 = void 0;
11538
11601
  else s1 = peg$FAILED;
11539
11602
  if (s1 !== peg$FAILED) {
@@ -11552,14 +11615,14 @@ function peg$parse(input2, options) {
11552
11615
  if (s0 === peg$FAILED) {
11553
11616
  s0 = peg$currPos;
11554
11617
  peg$savedPos = peg$currPos;
11555
- s1 = peg$f2();
11618
+ s1 = peg$f5();
11556
11619
  if (s1) s1 = void 0;
11557
11620
  else s1 = peg$FAILED;
11558
11621
  if (s1 !== peg$FAILED) {
11559
11622
  s2 = peg$parseHtmlOpen();
11560
11623
  if (s2 !== peg$FAILED) {
11561
11624
  peg$savedPos = s0;
11562
- s0 = peg$f3(s2);
11625
+ s0 = peg$f6(s2);
11563
11626
  } else {
11564
11627
  peg$currPos = s0;
11565
11628
  s0 = peg$FAILED;
@@ -11571,14 +11634,23 @@ function peg$parse(input2, options) {
11571
11634
  if (s0 === peg$FAILED) {
11572
11635
  s0 = peg$currPos;
11573
11636
  peg$savedPos = peg$currPos;
11574
- s1 = peg$f4();
11637
+ s1 = peg$f7();
11575
11638
  if (s1) s1 = void 0;
11576
11639
  else s1 = peg$FAILED;
11577
11640
  if (s1 !== peg$FAILED) {
11578
11641
  s2 = peg$parseHtmlClose();
11579
11642
  if (s2 !== peg$FAILED) {
11580
- peg$savedPos = s0;
11581
- s0 = peg$f5(s2);
11643
+ peg$savedPos = peg$currPos;
11644
+ s3 = peg$f8(s2);
11645
+ if (s3) s3 = void 0;
11646
+ else s3 = peg$FAILED;
11647
+ if (s3 !== peg$FAILED) {
11648
+ peg$savedPos = s0;
11649
+ s0 = peg$f9(s2);
11650
+ } else {
11651
+ peg$currPos = s0;
11652
+ s0 = peg$FAILED;
11653
+ }
11582
11654
  } else {
11583
11655
  peg$currPos = s0;
11584
11656
  s0 = peg$FAILED;
@@ -11595,14 +11667,14 @@ function peg$parse(input2, options) {
11595
11667
  if (s1 !== peg$FAILED) {
11596
11668
  s2 = peg$currPos;
11597
11669
  peg$savedPos = peg$currPos;
11598
- s3 = peg$f6(s1);
11670
+ s3 = peg$f10(s1);
11599
11671
  if (s3) s3 = void 0;
11600
11672
  else s3 = peg$FAILED;
11601
11673
  if (s3 !== peg$FAILED) {
11602
11674
  s4 = peg$parseRawTokens();
11603
11675
  if (s4 !== peg$FAILED) {
11604
11676
  peg$savedPos = s2;
11605
- s2 = peg$f7(s1, s4);
11677
+ s2 = peg$f11(s1, s4);
11606
11678
  } else {
11607
11679
  peg$currPos = s2;
11608
11680
  s2 = peg$FAILED;
@@ -11613,7 +11685,7 @@ function peg$parse(input2, options) {
11613
11685
  }
11614
11686
  if (s2 === peg$FAILED) s2 = null;
11615
11687
  peg$savedPos = s0;
11616
- s0 = peg$f8(s1, s2);
11688
+ s0 = peg$f12(s1, s2);
11617
11689
  } else {
11618
11690
  peg$currPos = s0;
11619
11691
  s0 = peg$FAILED;
@@ -11636,12 +11708,12 @@ function peg$parse(input2, options) {
11636
11708
  s1 = peg$parseMacroTag();
11637
11709
  if (s1 !== peg$FAILED) {
11638
11710
  peg$savedPos = peg$currPos;
11639
- s2 = peg$f9(s1);
11711
+ s2 = peg$f13(s1);
11640
11712
  if (s2) s2 = void 0;
11641
11713
  else s2 = peg$FAILED;
11642
11714
  if (s2 !== peg$FAILED) {
11643
11715
  peg$savedPos = s0;
11644
- s0 = peg$f10(s1);
11716
+ s0 = peg$f14(s1);
11645
11717
  } else {
11646
11718
  peg$currPos = s0;
11647
11719
  s0 = peg$FAILED;
@@ -11653,14 +11725,14 @@ function peg$parse(input2, options) {
11653
11725
  if (s0 === peg$FAILED) {
11654
11726
  s0 = peg$currPos;
11655
11727
  peg$savedPos = peg$currPos;
11656
- s1 = peg$f11();
11728
+ s1 = peg$f15();
11657
11729
  if (s1) s1 = void 0;
11658
11730
  else s1 = peg$FAILED;
11659
11731
  if (s1 !== peg$FAILED) {
11660
11732
  s2 = peg$parseHtmlClose();
11661
11733
  if (s2 !== peg$FAILED) {
11662
11734
  peg$savedPos = s0;
11663
- s0 = peg$f12(s2);
11735
+ s0 = peg$f16(s2);
11664
11736
  } else {
11665
11737
  peg$currPos = s0;
11666
11738
  s0 = peg$FAILED;
@@ -11677,12 +11749,12 @@ function peg$parse(input2, options) {
11677
11749
  s0 = peg$currPos;
11678
11750
  s1 = peg$parseHere();
11679
11751
  peg$savedPos = peg$currPos;
11680
- s2 = peg$f13(s1);
11752
+ s2 = peg$f17(s1);
11681
11753
  if (s2) s2 = void 0;
11682
11754
  else s2 = peg$FAILED;
11683
11755
  if (s2 !== peg$FAILED) {
11684
11756
  s3 = peg$currPos;
11685
- s4 = peg$f14(s1);
11757
+ s4 = peg$f18(s1);
11686
11758
  s5 = peg$currPos;
11687
11759
  s6 = [];
11688
11760
  if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
@@ -11715,7 +11787,7 @@ function peg$parse(input2, options) {
11715
11787
  s4 = peg$parseCloseTag();
11716
11788
  if (s4 !== peg$FAILED) {
11717
11789
  peg$savedPos = s0;
11718
- s0 = peg$f15(s1, s3, s4);
11790
+ s0 = peg$f19(s1, s3, s4);
11719
11791
  } else {
11720
11792
  peg$currPos = s0;
11721
11793
  s0 = peg$FAILED;
@@ -11731,7 +11803,7 @@ function peg$parse(input2, options) {
11731
11803
  if (s0 === peg$FAILED) {
11732
11804
  s0 = peg$currPos;
11733
11805
  peg$savedPos = peg$currPos;
11734
- s1 = peg$f16();
11806
+ s1 = peg$f20();
11735
11807
  if (s1) s1 = void 0;
11736
11808
  else s1 = peg$FAILED;
11737
11809
  if (s1 !== peg$FAILED) {
@@ -11756,7 +11828,7 @@ function peg$parse(input2, options) {
11756
11828
  }
11757
11829
  s2 = input2.substring(s2, peg$currPos);
11758
11830
  peg$savedPos = s0;
11759
- s0 = peg$f17(s2);
11831
+ s0 = peg$f21(s2);
11760
11832
  } else {
11761
11833
  peg$currPos = s0;
11762
11834
  s0 = peg$FAILED;
@@ -11769,7 +11841,7 @@ function peg$parse(input2, options) {
11769
11841
  s0 = peg$currPos;
11770
11842
  s1 = "";
11771
11843
  peg$savedPos = s0;
11772
- s1 = peg$f18();
11844
+ s1 = peg$f22();
11773
11845
  s0 = s1;
11774
11846
  return s0;
11775
11847
  }
@@ -11798,13 +11870,13 @@ function peg$parse(input2, options) {
11798
11870
  else s1 = s2;
11799
11871
  if (s1 !== peg$FAILED) {
11800
11872
  peg$savedPos = s0;
11801
- s1 = peg$f19(s1);
11873
+ s1 = peg$f23(s1);
11802
11874
  }
11803
11875
  s0 = s1;
11804
11876
  return s0;
11805
11877
  }
11806
11878
  function peg$parseComment() {
11807
- let s0, s1, s2, s3, s4, s5, s6, s7, s8;
11879
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
11808
11880
  s0 = peg$currPos;
11809
11881
  s1 = peg$currPos;
11810
11882
  s2 = peg$currPos;
@@ -11833,91 +11905,104 @@ function peg$parse(input2, options) {
11833
11905
  }
11834
11906
  if (s4 === peg$FAILED) {
11835
11907
  s4 = peg$currPos;
11836
- s5 = [];
11837
- s6 = peg$currPos;
11838
- s7 = peg$currPos;
11839
- peg$silentFails++;
11840
- if (input2.substr(peg$currPos, 3) === peg$c3) {
11841
- s8 = peg$c3;
11842
- peg$currPos += 3;
11843
- } else {
11844
- s8 = peg$FAILED;
11845
- if (peg$silentFails === 0) peg$fail(peg$e5);
11846
- }
11847
- peg$silentFails--;
11848
- if (s8 === peg$FAILED) s7 = void 0;
11849
- else {
11850
- peg$currPos = s7;
11851
- s7 = peg$FAILED;
11852
- }
11853
- if (s7 !== peg$FAILED) {
11854
- if (input2.length > peg$currPos) {
11855
- s8 = input2.charAt(peg$currPos);
11856
- peg$currPos++;
11857
- } else {
11858
- s8 = peg$FAILED;
11859
- if (peg$silentFails === 0) peg$fail(peg$e0);
11860
- }
11861
- if (s8 !== peg$FAILED) {
11862
- s7 = [s7, s8];
11863
- s6 = s7;
11864
- } else {
11865
- peg$currPos = s6;
11866
- s6 = peg$FAILED;
11867
- }
11868
- } else {
11869
- peg$currPos = s6;
11870
- s6 = peg$FAILED;
11871
- }
11872
- while (s6 !== peg$FAILED) {
11873
- s5.push(s6);
11874
- s6 = peg$currPos;
11908
+ peg$savedPos = peg$currPos;
11909
+ s5 = peg$f24();
11910
+ if (s5) s5 = void 0;
11911
+ else s5 = peg$FAILED;
11912
+ if (s5 !== peg$FAILED) {
11913
+ s6 = [];
11875
11914
  s7 = peg$currPos;
11915
+ s8 = peg$currPos;
11876
11916
  peg$silentFails++;
11877
11917
  if (input2.substr(peg$currPos, 3) === peg$c3) {
11878
- s8 = peg$c3;
11918
+ s9 = peg$c3;
11879
11919
  peg$currPos += 3;
11880
11920
  } else {
11881
- s8 = peg$FAILED;
11921
+ s9 = peg$FAILED;
11882
11922
  if (peg$silentFails === 0) peg$fail(peg$e5);
11883
11923
  }
11884
11924
  peg$silentFails--;
11885
- if (s8 === peg$FAILED) s7 = void 0;
11925
+ if (s9 === peg$FAILED) s8 = void 0;
11886
11926
  else {
11887
- peg$currPos = s7;
11888
- s7 = peg$FAILED;
11927
+ peg$currPos = s8;
11928
+ s8 = peg$FAILED;
11889
11929
  }
11890
- if (s7 !== peg$FAILED) {
11930
+ if (s8 !== peg$FAILED) {
11891
11931
  if (input2.length > peg$currPos) {
11892
- s8 = input2.charAt(peg$currPos);
11932
+ s9 = input2.charAt(peg$currPos);
11893
11933
  peg$currPos++;
11894
11934
  } else {
11895
- s8 = peg$FAILED;
11935
+ s9 = peg$FAILED;
11896
11936
  if (peg$silentFails === 0) peg$fail(peg$e0);
11897
11937
  }
11938
+ if (s9 !== peg$FAILED) {
11939
+ s8 = [s8, s9];
11940
+ s7 = s8;
11941
+ } else {
11942
+ peg$currPos = s7;
11943
+ s7 = peg$FAILED;
11944
+ }
11945
+ } else {
11946
+ peg$currPos = s7;
11947
+ s7 = peg$FAILED;
11948
+ }
11949
+ while (s7 !== peg$FAILED) {
11950
+ s6.push(s7);
11951
+ s7 = peg$currPos;
11952
+ s8 = peg$currPos;
11953
+ peg$silentFails++;
11954
+ if (input2.substr(peg$currPos, 3) === peg$c3) {
11955
+ s9 = peg$c3;
11956
+ peg$currPos += 3;
11957
+ } else {
11958
+ s9 = peg$FAILED;
11959
+ if (peg$silentFails === 0) peg$fail(peg$e5);
11960
+ }
11961
+ peg$silentFails--;
11962
+ if (s9 === peg$FAILED) s8 = void 0;
11963
+ else {
11964
+ peg$currPos = s8;
11965
+ s8 = peg$FAILED;
11966
+ }
11898
11967
  if (s8 !== peg$FAILED) {
11899
- s7 = [s7, s8];
11900
- s6 = s7;
11968
+ if (input2.length > peg$currPos) {
11969
+ s9 = input2.charAt(peg$currPos);
11970
+ peg$currPos++;
11971
+ } else {
11972
+ s9 = peg$FAILED;
11973
+ if (peg$silentFails === 0) peg$fail(peg$e0);
11974
+ }
11975
+ if (s9 !== peg$FAILED) {
11976
+ s8 = [s8, s9];
11977
+ s7 = s8;
11978
+ } else {
11979
+ peg$currPos = s7;
11980
+ s7 = peg$FAILED;
11981
+ }
11901
11982
  } else {
11902
- peg$currPos = s6;
11903
- s6 = peg$FAILED;
11983
+ peg$currPos = s7;
11984
+ s7 = peg$FAILED;
11904
11985
  }
11986
+ }
11987
+ if (input2.substr(peg$currPos, 3) === peg$c3) {
11988
+ s7 = peg$c3;
11989
+ peg$currPos += 3;
11905
11990
  } else {
11906
- peg$currPos = s6;
11907
- s6 = peg$FAILED;
11991
+ s7 = peg$FAILED;
11992
+ if (peg$silentFails === 0) peg$fail(peg$e5);
11993
+ }
11994
+ if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
11995
+ if (s7 !== peg$FAILED) {
11996
+ s5 = [
11997
+ s5,
11998
+ s6,
11999
+ s7
12000
+ ];
12001
+ s4 = s5;
12002
+ } else {
12003
+ peg$currPos = s4;
12004
+ s4 = peg$FAILED;
11908
12005
  }
11909
- }
11910
- if (input2.substr(peg$currPos, 3) === peg$c3) {
11911
- s6 = peg$c3;
11912
- peg$currPos += 3;
11913
- } else {
11914
- s6 = peg$FAILED;
11915
- if (peg$silentFails === 0) peg$fail(peg$e5);
11916
- }
11917
- if (s6 === peg$FAILED) s6 = peg$parseOpenEnd();
11918
- if (s6 !== peg$FAILED) {
11919
- s5 = [s5, s6];
11920
- s4 = s5;
11921
12006
  } else {
11922
12007
  peg$currPos = s4;
11923
12008
  s4 = peg$FAILED;
@@ -11939,7 +12024,7 @@ function peg$parse(input2, options) {
11939
12024
  else s1 = s2;
11940
12025
  if (s1 !== peg$FAILED) {
11941
12026
  peg$savedPos = s0;
11942
- s1 = peg$f20(s1);
12027
+ s1 = peg$f25(s1);
11943
12028
  }
11944
12029
  s0 = s1;
11945
12030
  return s0;
@@ -11972,7 +12057,7 @@ function peg$parse(input2, options) {
11972
12057
  if (s1 !== peg$FAILED) {
11973
12058
  s2 = peg$currPos;
11974
12059
  peg$savedPos = peg$currPos;
11975
- s3 = peg$f21(s1);
12060
+ s3 = peg$f26(s1);
11976
12061
  if (s3) s3 = void 0;
11977
12062
  else s3 = peg$FAILED;
11978
12063
  if (s3 !== peg$FAILED) {
@@ -11984,7 +12069,7 @@ function peg$parse(input2, options) {
11984
12069
  }
11985
12070
  if (s4 !== peg$FAILED) {
11986
12071
  peg$savedPos = s2;
11987
- s2 = peg$f22(s1, s4);
12072
+ s2 = peg$f27(s1, s4);
11988
12073
  } else {
11989
12074
  peg$currPos = s2;
11990
12075
  s2 = peg$FAILED;
@@ -11995,7 +12080,7 @@ function peg$parse(input2, options) {
11995
12080
  }
11996
12081
  if (s2 === peg$FAILED) s2 = null;
11997
12082
  peg$savedPos = s0;
11998
- s0 = peg$f23(s1, s2);
12083
+ s0 = peg$f28(s1, s2);
11999
12084
  } else {
12000
12085
  peg$currPos = s0;
12001
12086
  s0 = peg$FAILED;
@@ -12043,7 +12128,7 @@ function peg$parse(input2, options) {
12043
12128
  }
12044
12129
  if (s2 !== peg$FAILED) {
12045
12130
  peg$savedPos = s0;
12046
- s0 = peg$f24();
12131
+ s0 = peg$f29();
12047
12132
  } else {
12048
12133
  peg$currPos = s0;
12049
12134
  s0 = peg$FAILED;
@@ -12058,7 +12143,7 @@ function peg$parse(input2, options) {
12058
12143
  peg$silentFails++;
12059
12144
  s2 = peg$currPos;
12060
12145
  peg$savedPos = peg$currPos;
12061
- s3 = peg$f25();
12146
+ s3 = peg$f30();
12062
12147
  if (s3) s3 = void 0;
12063
12148
  else s3 = peg$FAILED;
12064
12149
  if (s3 !== peg$FAILED) {
@@ -12090,7 +12175,7 @@ function peg$parse(input2, options) {
12090
12175
  }
12091
12176
  if (s2 !== peg$FAILED) {
12092
12177
  peg$savedPos = s0;
12093
- s0 = peg$f26();
12178
+ s0 = peg$f31();
12094
12179
  } else {
12095
12180
  peg$currPos = s0;
12096
12181
  s0 = peg$FAILED;
@@ -12110,7 +12195,7 @@ function peg$parse(input2, options) {
12110
12195
  }
12111
12196
  if (s1 !== peg$FAILED) {
12112
12197
  peg$savedPos = s0;
12113
- s1 = peg$f27();
12198
+ s1 = peg$f32();
12114
12199
  }
12115
12200
  s0 = s1;
12116
12201
  }
@@ -12121,7 +12206,7 @@ function peg$parse(input2, options) {
12121
12206
  let s0, s1, s2, s3, s4, s5, s6, s7;
12122
12207
  s0 = peg$currPos;
12123
12208
  peg$savedPos = peg$currPos;
12124
- s1 = peg$f28();
12209
+ s1 = peg$f33();
12125
12210
  if (s1) s1 = void 0;
12126
12211
  else s1 = peg$FAILED;
12127
12212
  if (s1 !== peg$FAILED) {
@@ -12150,7 +12235,7 @@ function peg$parse(input2, options) {
12150
12235
  if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
12151
12236
  if (s7 !== peg$FAILED) {
12152
12237
  peg$savedPos = s0;
12153
- s0 = peg$f29(s3, s4, s5, s6);
12238
+ s0 = peg$f34(s3, s4, s5, s6);
12154
12239
  } else {
12155
12240
  peg$currPos = s0;
12156
12241
  s0 = peg$FAILED;
@@ -12170,7 +12255,7 @@ function peg$parse(input2, options) {
12170
12255
  if (s0 === peg$FAILED) {
12171
12256
  s0 = peg$currPos;
12172
12257
  peg$savedPos = peg$currPos;
12173
- s1 = peg$f30();
12258
+ s1 = peg$f35();
12174
12259
  if (s1) s1 = void 0;
12175
12260
  else s1 = peg$FAILED;
12176
12261
  if (s1 !== peg$FAILED) {
@@ -12183,7 +12268,7 @@ function peg$parse(input2, options) {
12183
12268
  }
12184
12269
  if (s2 !== peg$FAILED) {
12185
12270
  peg$savedPos = s0;
12186
- s0 = peg$f31();
12271
+ s0 = peg$f36();
12187
12272
  } else {
12188
12273
  peg$currPos = s0;
12189
12274
  s0 = peg$FAILED;
@@ -12311,7 +12396,7 @@ function peg$parse(input2, options) {
12311
12396
  }
12312
12397
  if (s2 === peg$FAILED) s2 = null;
12313
12398
  peg$savedPos = s0;
12314
- s0 = peg$f32(s1);
12399
+ s0 = peg$f37(s1);
12315
12400
  } else {
12316
12401
  peg$currPos = s0;
12317
12402
  s0 = peg$FAILED;
@@ -12320,7 +12405,7 @@ function peg$parse(input2, options) {
12320
12405
  s0 = peg$currPos;
12321
12406
  s1 = "";
12322
12407
  peg$savedPos = s0;
12323
- s1 = peg$f33();
12408
+ s1 = peg$f38();
12324
12409
  s0 = s1;
12325
12410
  }
12326
12411
  return s0;
@@ -12350,7 +12435,7 @@ function peg$parse(input2, options) {
12350
12435
  }
12351
12436
  }
12352
12437
  peg$savedPos = s0;
12353
- s0 = peg$f34(s1, s2);
12438
+ s0 = peg$f39(s1, s2);
12354
12439
  } else {
12355
12440
  peg$currPos = s0;
12356
12441
  s0 = peg$FAILED;
@@ -12376,7 +12461,7 @@ function peg$parse(input2, options) {
12376
12461
  }
12377
12462
  s2 = input2.substring(s2, peg$currPos);
12378
12463
  peg$savedPos = s0;
12379
- s0 = peg$f35(s1, s2);
12464
+ s0 = peg$f40(s1, s2);
12380
12465
  } else {
12381
12466
  peg$currPos = s0;
12382
12467
  s0 = peg$FAILED;
@@ -12497,7 +12582,7 @@ function peg$parse(input2, options) {
12497
12582
  s7 = peg$parseBraceEnd();
12498
12583
  if (s7 !== peg$FAILED) {
12499
12584
  peg$savedPos = s0;
12500
- s0 = peg$f36(s2, s3, s4, s5, s6);
12585
+ s0 = peg$f41(s2, s3, s4, s5, s6);
12501
12586
  } else {
12502
12587
  peg$currPos = s0;
12503
12588
  s0 = peg$FAILED;
@@ -12547,7 +12632,7 @@ function peg$parse(input2, options) {
12547
12632
  s7 = peg$parseBraceEnd();
12548
12633
  if (s7 !== peg$FAILED) {
12549
12634
  peg$savedPos = s0;
12550
- s0 = peg$f37(s2, s3, s4, s6);
12635
+ s0 = peg$f42(s2, s3, s4, s6);
12551
12636
  } else {
12552
12637
  peg$currPos = s0;
12553
12638
  s0 = peg$FAILED;
@@ -12595,7 +12680,7 @@ function peg$parse(input2, options) {
12595
12680
  } else s3 = peg$FAILED;
12596
12681
  if (s3 !== peg$FAILED) {
12597
12682
  peg$savedPos = s0;
12598
- s0 = peg$f38();
12683
+ s0 = peg$f43();
12599
12684
  } else {
12600
12685
  peg$currPos = s0;
12601
12686
  s0 = peg$FAILED;
@@ -12617,12 +12702,12 @@ function peg$parse(input2, options) {
12617
12702
  s0 = peg$currPos;
12618
12703
  s1 = peg$parseHere();
12619
12704
  peg$savedPos = peg$currPos;
12620
- s2 = peg$f39(s1);
12705
+ s2 = peg$f44(s1);
12621
12706
  if (s2) s2 = void 0;
12622
12707
  else s2 = peg$FAILED;
12623
12708
  if (s2 !== peg$FAILED) {
12624
12709
  s3 = peg$currPos;
12625
- s4 = peg$f40(s1);
12710
+ s4 = peg$f45(s1);
12626
12711
  s5 = peg$currPos;
12627
12712
  s6 = [];
12628
12713
  if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
@@ -12653,7 +12738,7 @@ function peg$parse(input2, options) {
12653
12738
  else s3 = s4;
12654
12739
  if (s3 !== peg$FAILED) {
12655
12740
  peg$savedPos = s0;
12656
- s0 = peg$f41(s1, s3);
12741
+ s0 = peg$f46(s1, s3);
12657
12742
  } else {
12658
12743
  peg$currPos = s0;
12659
12744
  s0 = peg$FAILED;
@@ -12668,7 +12753,7 @@ function peg$parse(input2, options) {
12668
12753
  let s0, s1, s2, s3;
12669
12754
  s0 = peg$currPos;
12670
12755
  peg$savedPos = peg$currPos;
12671
- s1 = peg$f42();
12756
+ s1 = peg$f47();
12672
12757
  if (s1) s1 = void 0;
12673
12758
  else s1 = peg$FAILED;
12674
12759
  if (s1 !== peg$FAILED) {
@@ -12740,12 +12825,12 @@ function peg$parse(input2, options) {
12740
12825
  s7 = peg$parseHere();
12741
12826
  s8 = peg$currPos;
12742
12827
  peg$savedPos = peg$currPos;
12743
- s9 = peg$f43(s2, s3, s4, s5, s6, s7);
12828
+ s9 = peg$f48(s2, s3, s4, s5, s6, s7);
12744
12829
  if (s9) s9 = void 0;
12745
12830
  else s9 = peg$FAILED;
12746
12831
  if (s9 !== peg$FAILED) {
12747
12832
  s10 = peg$currPos;
12748
- s11 = peg$f44(s2, s3, s4, s5, s6, s7);
12833
+ s11 = peg$f49(s2, s3, s4, s5, s6, s7);
12749
12834
  s12 = peg$currPos;
12750
12835
  s13 = [];
12751
12836
  if (s13.length >= (s11 | 0)) s14 = peg$FAILED;
@@ -12778,7 +12863,7 @@ function peg$parse(input2, options) {
12778
12863
  s11 = peg$parseBraceEnd();
12779
12864
  if (s11 !== peg$FAILED) {
12780
12865
  peg$savedPos = s8;
12781
- s8 = peg$f45(s2, s3, s4, s5, s6, s7, s10);
12866
+ s8 = peg$f50(s2, s3, s4, s5, s6, s7, s10);
12782
12867
  } else {
12783
12868
  peg$currPos = s8;
12784
12869
  s8 = peg$FAILED;
@@ -12793,7 +12878,7 @@ function peg$parse(input2, options) {
12793
12878
  }
12794
12879
  if (s8 === peg$FAILED) s8 = null;
12795
12880
  peg$savedPos = s0;
12796
- s0 = peg$f46(s2, s3, s4, s5, s6, s7, s8);
12881
+ s0 = peg$f51(s2, s3, s4, s5, s6, s7, s8);
12797
12882
  } else {
12798
12883
  peg$currPos = s0;
12799
12884
  s0 = peg$FAILED;
@@ -12827,7 +12912,7 @@ function peg$parse(input2, options) {
12827
12912
  }
12828
12913
  if (s3 !== peg$FAILED) {
12829
12914
  peg$savedPos = s0;
12830
- s0 = peg$f47(s2);
12915
+ s0 = peg$f52(s2);
12831
12916
  } else {
12832
12917
  peg$currPos = s0;
12833
12918
  s0 = peg$FAILED;
@@ -12977,12 +13062,12 @@ function peg$parse(input2, options) {
12977
13062
  else s1 = s2;
12978
13063
  if (s1 !== peg$FAILED) {
12979
13064
  peg$savedPos = peg$currPos;
12980
- s2 = peg$f48(s1);
13065
+ s2 = peg$f53(s1);
12981
13066
  if (s2) s2 = void 0;
12982
13067
  else s2 = peg$FAILED;
12983
13068
  if (s2 !== peg$FAILED) {
12984
13069
  peg$savedPos = s0;
12985
- s0 = peg$f49(s1);
13070
+ s0 = peg$f54(s1);
12986
13071
  } else {
12987
13072
  peg$currPos = s0;
12988
13073
  s0 = peg$FAILED;
@@ -13159,7 +13244,7 @@ function peg$parse(input2, options) {
13159
13244
  else s1 = s2;
13160
13245
  if (s1 !== peg$FAILED) {
13161
13246
  peg$savedPos = s0;
13162
- s1 = peg$f50(s1);
13247
+ s1 = peg$f55(s1);
13163
13248
  }
13164
13249
  s0 = s1;
13165
13250
  return s0;
@@ -13203,7 +13288,7 @@ function peg$parse(input2, options) {
13203
13288
  if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
13204
13289
  if (s7 !== peg$FAILED) {
13205
13290
  peg$savedPos = s0;
13206
- s0 = peg$f51(s2, s3, s4, s6);
13291
+ s0 = peg$f56(s2, s3, s4, s6);
13207
13292
  } else {
13208
13293
  peg$currPos = s0;
13209
13294
  s0 = peg$FAILED;
@@ -13268,7 +13353,7 @@ function peg$parse(input2, options) {
13268
13353
  s5 = peg$parse_();
13269
13354
  s6 = peg$parseHere();
13270
13355
  peg$savedPos = s0;
13271
- s0 = peg$f52(s2, s6);
13356
+ s0 = peg$f57(s2, s6);
13272
13357
  } else {
13273
13358
  peg$currPos = s0;
13274
13359
  s0 = peg$FAILED;
@@ -13308,7 +13393,7 @@ function peg$parse(input2, options) {
13308
13393
  }
13309
13394
  if (s5 !== peg$FAILED) {
13310
13395
  peg$savedPos = s0;
13311
- s0 = peg$f53(s2, s3);
13396
+ s0 = peg$f58(s2, s3);
13312
13397
  } else {
13313
13398
  peg$currPos = s0;
13314
13399
  s0 = peg$FAILED;
@@ -13443,7 +13528,7 @@ function peg$parse(input2, options) {
13443
13528
  else s3 = s4;
13444
13529
  if (s3 !== peg$FAILED) {
13445
13530
  peg$savedPos = peg$currPos;
13446
- s4 = peg$f54(s2, s3);
13531
+ s4 = peg$f59(s2, s3);
13447
13532
  if (s4) s4 = void 0;
13448
13533
  else s4 = peg$FAILED;
13449
13534
  if (s4 !== peg$FAILED) {
@@ -13461,7 +13546,7 @@ function peg$parse(input2, options) {
13461
13546
  s9 = peg$parseAttrValue();
13462
13547
  if (s9 !== peg$FAILED) {
13463
13548
  peg$savedPos = s5;
13464
- s5 = peg$f55(s2, s3, s9);
13549
+ s5 = peg$f60(s2, s3, s9);
13465
13550
  } else {
13466
13551
  peg$currPos = s5;
13467
13552
  s5 = peg$FAILED;
@@ -13472,7 +13557,7 @@ function peg$parse(input2, options) {
13472
13557
  }
13473
13558
  if (s5 === peg$FAILED) s5 = null;
13474
13559
  peg$savedPos = s0;
13475
- s0 = peg$f56(s2, s3, s5);
13560
+ s0 = peg$f61(s2, s3, s5);
13476
13561
  } else {
13477
13562
  peg$currPos = s0;
13478
13563
  s0 = peg$FAILED;
@@ -13530,7 +13615,7 @@ function peg$parse(input2, options) {
13530
13615
  if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
13531
13616
  if (s5 !== peg$FAILED) {
13532
13617
  peg$savedPos = s0;
13533
- s0 = peg$f57(s2, s3, s4);
13618
+ s0 = peg$f62(s2, s3, s4);
13534
13619
  } else {
13535
13620
  peg$currPos = s0;
13536
13621
  s0 = peg$FAILED;
@@ -13585,7 +13670,7 @@ function peg$parse(input2, options) {
13585
13670
  if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
13586
13671
  if (s5 !== peg$FAILED) {
13587
13672
  peg$savedPos = s0;
13588
- s0 = peg$f58(s2, s3, s4);
13673
+ s0 = peg$f63(s2, s3, s4);
13589
13674
  } else {
13590
13675
  peg$currPos = s0;
13591
13676
  s0 = peg$FAILED;
@@ -13604,7 +13689,7 @@ function peg$parse(input2, options) {
13604
13689
  }
13605
13690
  if (s1 !== peg$FAILED) {
13606
13691
  peg$savedPos = s0;
13607
- s1 = peg$f59(s1);
13692
+ s1 = peg$f64(s1);
13608
13693
  }
13609
13694
  s0 = s1;
13610
13695
  if (s0 === peg$FAILED) {
@@ -13630,7 +13715,7 @@ function peg$parse(input2, options) {
13630
13715
  s2 = input2.substring(s2, peg$currPos);
13631
13716
  s3 = peg$parseHere();
13632
13717
  peg$savedPos = s0;
13633
- s0 = peg$f60(s1, s2, s3);
13718
+ s0 = peg$f65(s1, s2, s3);
13634
13719
  }
13635
13720
  }
13636
13721
  }
@@ -13640,7 +13725,7 @@ function peg$parse(input2, options) {
13640
13725
  let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
13641
13726
  s0 = peg$currPos;
13642
13727
  peg$savedPos = peg$currPos;
13643
- s1 = peg$f61();
13728
+ s1 = peg$f66();
13644
13729
  if (s1) s1 = void 0;
13645
13730
  else s1 = peg$FAILED;
13646
13731
  if (s1 !== peg$FAILED) {
@@ -13669,7 +13754,7 @@ function peg$parse(input2, options) {
13669
13754
  if (s2 !== peg$FAILED) {
13670
13755
  s3 = peg$currPos;
13671
13756
  peg$savedPos = peg$currPos;
13672
- s4 = peg$f62(s2);
13757
+ s4 = peg$f67(s2);
13673
13758
  if (s4) s4 = void 0;
13674
13759
  else s4 = peg$FAILED;
13675
13760
  if (s4 !== peg$FAILED) {
@@ -13708,7 +13793,7 @@ function peg$parse(input2, options) {
13708
13793
  if (s0 === peg$FAILED) {
13709
13794
  s0 = peg$currPos;
13710
13795
  peg$savedPos = peg$currPos;
13711
- s1 = peg$f63();
13796
+ s1 = peg$f68();
13712
13797
  if (s1) s1 = void 0;
13713
13798
  else s1 = peg$FAILED;
13714
13799
  if (s1 !== peg$FAILED) {
@@ -13735,12 +13820,12 @@ function peg$parse(input2, options) {
13735
13820
  if (s6 !== peg$FAILED) {
13736
13821
  s7 = peg$parseHere();
13737
13822
  peg$savedPos = peg$currPos;
13738
- s8 = peg$f64(s4, s7);
13823
+ s8 = peg$f69(s4, s7);
13739
13824
  if (s8) s8 = void 0;
13740
13825
  else s8 = peg$FAILED;
13741
13826
  if (s8 !== peg$FAILED) {
13742
13827
  s9 = peg$currPos;
13743
- s10 = peg$f65(s4, s7);
13828
+ s10 = peg$f70(s4, s7);
13744
13829
  s11 = peg$currPos;
13745
13830
  s12 = [];
13746
13831
  if (s12.length >= (s10 | 0)) s13 = peg$FAILED;
@@ -13816,7 +13901,7 @@ function peg$parse(input2, options) {
13816
13901
  if (s0 === peg$FAILED) {
13817
13902
  s0 = peg$currPos;
13818
13903
  peg$savedPos = peg$currPos;
13819
- s1 = peg$f66();
13904
+ s1 = peg$f71();
13820
13905
  if (s1) s1 = void 0;
13821
13906
  else s1 = peg$FAILED;
13822
13907
  if (s1 !== peg$FAILED) {
@@ -13901,7 +13986,7 @@ function peg$parse(input2, options) {
13901
13986
  if (s0 === peg$FAILED) {
13902
13987
  s0 = peg$currPos;
13903
13988
  peg$savedPos = peg$currPos;
13904
- s1 = peg$f67();
13989
+ s1 = peg$f72();
13905
13990
  if (s1) s1 = void 0;
13906
13991
  else s1 = peg$FAILED;
13907
13992
  if (s1 !== peg$FAILED) {
@@ -13987,9 +14072,11 @@ function peg$parse(input2, options) {
13987
14072
  const textMode = options.text === true;
13988
14073
  const completionMode = options.completion === true;
13989
14074
  const hooks = options.hooks;
14075
+ const lastCommentClose = input2.lastIndexOf("-->");
13990
14076
  let skipEnd = -1;
13991
14077
  let attrCode = false;
13992
14078
  let rawName = "";
14079
+ let htmlTextTag = "";
13993
14080
  function linkSeparatorIndex(inner, at3, separator) {
13994
14081
  for (let i2 = 0; i2 < inner.length; i2++) {
13995
14082
  const c = inner.charAt(i2);
@@ -14056,6 +14143,11 @@ function peg$parse(input2, options) {
14056
14143
  if (peg$success) return peg$result;
14057
14144
  else peg$throw();
14058
14145
  }
14146
+ function effectiveNamedDefinitions(definitions) {
14147
+ const latest = new NameMap();
14148
+ for (const definition2 of definitions) latest.set(definition2.name, definition2);
14149
+ return [...latest.values()];
14150
+ }
14059
14151
  function isOptionClause(name) {
14060
14152
  return name.toLowerCase() === OPTION_CLAUSE;
14061
14153
  }
@@ -14691,29 +14783,17 @@ function parseCode(src, goal = "expression") {
14691
14783
  return parseWithAst(src, goal).out;
14692
14784
  }
14693
14785
  function parseWithAst(src, goal) {
14694
- const percentAt = /* @__PURE__ */ new Map();
14695
- for (; ; ) {
14696
- const transientsRead = /* @__PURE__ */ new Set();
14697
- try {
14698
- const ast = parseAst(src, goal, percentAt, transientsRead);
14699
- const out = {
14700
- refs: [],
14701
- strings: []
14702
- };
14703
- walk(ast, src, out, false, false);
14704
- out.refs.sort((a, b) => a.start - b.start);
14705
- return {
14706
- out,
14707
- ast
14708
- };
14709
- } catch (error62) {
14710
- const pos = error62.pos ?? -1;
14711
- if (!(error62 instanceof SyntaxError) || percentAt.has(pos)) throw error62;
14712
- TRANS_NAME_RE.lastIndex = pos + 1;
14713
- if (src.charAt(pos) !== "%" || !TRANS_NAME_RE.test(src)) throw error62;
14714
- percentAt.set(pos, !transientsRead.has(pos));
14715
- }
14716
- }
14786
+ const ast = parseAst(src, goal);
14787
+ const out = {
14788
+ refs: [],
14789
+ strings: []
14790
+ };
14791
+ walk(ast, src, out, false, false);
14792
+ out.refs.sort((a, b) => a.start - b.start);
14793
+ return {
14794
+ out,
14795
+ ast
14796
+ };
14717
14797
  }
14718
14798
  function parseReferencePath(src) {
14719
14799
  const { ast } = parseWithAst(src, "expression");
@@ -14762,11 +14842,9 @@ function readMemberPath(src, end) {
14762
14842
  end
14763
14843
  };
14764
14844
  }
14765
- function parseAst(src, goal, percentAt, transientsRead) {
14845
+ function parseAst(src, goal) {
14766
14846
  try {
14767
14847
  const p = tokenizerAt(src, 0, goal);
14768
- p.percentAt = percentAt;
14769
- p.transientsRead = transientsRead;
14770
14848
  if (goal === "statements") return p.parse();
14771
14849
  p.nextToken();
14772
14850
  const ast = p.parseExpression();
@@ -14933,25 +15011,45 @@ function walk(root, src, out, binding, shorthand, access = "read") {
14933
15011
  }
14934
15012
  }
14935
15013
  function findCodeEnd(src, start, { goal = "expression", stop, onRunOut } = {}) {
14936
- const end = scanCodeEnd(src, start, goal, stop, onRunOut);
14937
- return end < 0 && !stop ? parsedCodeEnd(src, start, goal) : end;
15014
+ let verifyStop = false;
15015
+ const end = scanCodeEnd(src, start, goal, stop, onRunOut, () => {
15016
+ verifyStop = true;
15017
+ });
15018
+ if (end < 0 || verifyStop) {
15019
+ const parsed = parsedCodeEnd(src, start, goal, stop);
15020
+ if (parsed >= 0) return parsed;
15021
+ }
15022
+ return end;
14938
15023
  }
14939
- function parsedCodeEnd(src, start, goal) {
15024
+ function parsedCodeEnd(src, start, goal, stop) {
14940
15025
  const p = tokenizerAt(src, start, goal);
15026
+ const stopped = {};
15027
+ let stoppedAt = -1;
15028
+ if (stop) {
15029
+ const nextToken = p.nextToken;
15030
+ p.nextToken = () => {
15031
+ nextToken.call(p);
15032
+ if (p.type === types$1.braceL && stop(p.start)) {
15033
+ stoppedAt = p.start;
15034
+ throw stopped;
15035
+ }
15036
+ };
15037
+ }
14941
15038
  try {
14942
15039
  if (goal === "statements") p.parse();
14943
15040
  else {
14944
15041
  p.nextToken();
14945
15042
  p.parseExpression();
14946
- if (p.type === types$1.braceR) return p.start;
15043
+ if (!stop && p.type === types$1.braceR) return p.start;
14947
15044
  }
14948
15045
  } catch (error62) {
15046
+ if (error62 === stopped) return stoppedAt;
14949
15047
  const pos = error62.pos ?? -1;
14950
- if (src.charAt(pos) === "}") return pos;
15048
+ if (!stop && src.charAt(pos) === "}") return pos;
14951
15049
  }
14952
15050
  return -1;
14953
15051
  }
14954
- function scanCodeEnd(src, start, goal, stop, onRunOut) {
15052
+ function scanCodeEnd(src, start, goal, stop, onRunOut, onTemplateStop) {
14955
15053
  const ranOut = () => {
14956
15054
  onRunOut?.();
14957
15055
  return -1;
@@ -14962,6 +15060,7 @@ function scanCodeEnd(src, start, goal, stop, onRunOut) {
14962
15060
  let from = start;
14963
15061
  let afterOperand = false;
14964
15062
  let templateSlip = false;
15063
+ let interpolated = false;
14965
15064
  for (; ; ) {
14966
15065
  let resumeAt = -1;
14967
15066
  for (const tok of tokens(src, from, goal, { afterOperand })) {
@@ -14990,10 +15089,15 @@ function scanCodeEnd(src, start, goal, stop, onRunOut) {
14990
15089
  prevWord = t === types$1.name && !WORDS_BEFORE_STRING.has(tok.value) || t === types$1.num;
14991
15090
  prevEnd = tok.end;
14992
15091
  if (t === types$1.braceL) {
14993
- if (stop?.(tok.start)) return tok.start;
15092
+ if (stop?.(tok.start)) {
15093
+ if (interpolated) onTemplateStop();
15094
+ return tok.start;
15095
+ }
14994
15096
  stack.push("{");
14995
- } else if (t === types$1.dollarBraceL) stack.push("${");
14996
- else if (t === types$1.parenL) stack.push("(");
15097
+ } else if (t === types$1.dollarBraceL) {
15098
+ interpolated = true;
15099
+ stack.push("${");
15100
+ } else if (t === types$1.parenL) stack.push("(");
14997
15101
  else if (t === types$1.bracketL) stack.push("[");
14998
15102
  else if (t === types$1.parenR || t === types$1.bracketR) {
14999
15103
  if (last(stack) === (t === types$1.parenR ? "(" : "[")) stack.pop();
@@ -15064,7 +15168,8 @@ function* tokens(src, start, goal, options = {}) {
15064
15168
  type: p.type,
15065
15169
  start: p.start,
15066
15170
  end: p.end,
15067
- value: p.value
15171
+ value: p.value,
15172
+ operand: p.operandHere
15068
15173
  };
15069
15174
  if (p.type === types$1.eof) return;
15070
15175
  }
@@ -15210,6 +15315,58 @@ function scanStringLiteral(src, start) {
15210
15315
  closed: false
15211
15316
  };
15212
15317
  }
15318
+ function completionIdentifier(source, cursor, goal = "expression") {
15319
+ let previous2;
15320
+ for (const token of tokens(source, 0, goal)) {
15321
+ if ("error" in token) {
15322
+ if (source[token.pos] === "@" && cursor === token.pos + 1) return {
15323
+ kind: "root",
15324
+ name: "",
15325
+ start: token.pos,
15326
+ end: cursor
15327
+ };
15328
+ return;
15329
+ }
15330
+ const member = previous2 && isMemberDot(previous2.type) ? previous2 : void 0;
15331
+ if (token.start <= cursor && cursor <= token.end) {
15332
+ if (member && (token.type === types$1.name || token.type.keyword)) return {
15333
+ kind: "member",
15334
+ name: token.value,
15335
+ start: token.start,
15336
+ end: token.end,
15337
+ dotStart: member.start
15338
+ };
15339
+ if (token.type === types$1.name && !member) {
15340
+ const value = token.value;
15341
+ if ((sigilAt(source, token.start, value) || value === "$" || value === "_") && !keyPosition(source, token.end, previous2?.type)) return {
15342
+ kind: "root",
15343
+ name: value.slice(1),
15344
+ start: token.start,
15345
+ end: token.end
15346
+ };
15347
+ }
15348
+ if (token.type === types$1.modulo && source.slice(token.start, token.end) === "%" && cursor === token.end && token.operand) return {
15349
+ kind: "root",
15350
+ name: "",
15351
+ start: token.start,
15352
+ end: token.end
15353
+ };
15354
+ }
15355
+ if (isMemberDot(token.type) && token.end === cursor) {
15356
+ previous2 = token;
15357
+ continue;
15358
+ }
15359
+ if (member && member.end === cursor && token.start >= cursor) return {
15360
+ kind: "member",
15361
+ name: "",
15362
+ start: cursor,
15363
+ end: cursor,
15364
+ dotStart: member.start
15365
+ };
15366
+ if (token.start > cursor || token.type === types$1.eof) return;
15367
+ previous2 = token;
15368
+ }
15369
+ }
15213
15370
  function skipLiteral(input2, i2) {
15214
15371
  const quote = input2[i2];
15215
15372
  const template = quote === "`";
@@ -16447,12 +16604,18 @@ function locate(text3, part, from) {
16447
16604
  return anywhere >= 0 ? anywhere : from;
16448
16605
  }
16449
16606
  function completionContext(source, cursor, macros = []) {
16450
- if (!Number.isInteger(cursor) || cursor < 0 || cursor > source.length) throw new RangeError("cursor must be a UTF-16 offset within source");
16607
+ return readCompletion(source.slice(0, cursor), cursor, macros, false, source.length);
16608
+ }
16609
+ function readCompletion(source, cursor, macros, full, sourceLength = source.length, visit2) {
16610
+ if (!Number.isInteger(cursor) || cursor < 0 || cursor > sourceLength) throw new RangeError("cursor must be a UTF-16 offset within source");
16451
16611
  const parametersOf2 = parameterLookup(macros);
16452
16612
  const codeContext = (code, goal, map2, containers) => {
16453
- const probe = code.length + 1;
16613
+ let position = 0;
16614
+ while (position < code.length && map2(position) < cursor) position++;
16615
+ const prefix = code.slice(0, position);
16616
+ const probe = prefix.length + 1;
16454
16617
  let executable = false;
16455
- lexJs(code + " __spindle_cursor__", {
16618
+ lexJs(prefix + " __spindle_cursor__", {
16456
16619
  code(_ch, at3) {
16457
16620
  if (at3 >= probe) executable = true;
16458
16621
  },
@@ -16461,6 +16624,7 @@ function completionContext(source, cursor, macros = []) {
16461
16624
  }
16462
16625
  }, goal);
16463
16626
  if (!executable) return LITERAL;
16627
+ const identifier = full ? completionIdentifier(code, position, goal) : void 0;
16464
16628
  const offset2 = map2(0);
16465
16629
  const offsets = Array.from({ length: code.length + 1 }, (_2, i2) => map2(i2));
16466
16630
  return {
@@ -16468,7 +16632,8 @@ function completionContext(source, cursor, macros = []) {
16468
16632
  code,
16469
16633
  goal,
16470
16634
  offset: offset2,
16471
- cursor: code.length,
16635
+ cursor: position,
16636
+ ...identifier && { identifier },
16472
16637
  ...containers.length ? { containers } : {},
16473
16638
  ...offsets.some((at3, i2) => at3 !== offset2 + i2) ? { sourceOffsets: offsets } : {}
16474
16639
  };
@@ -16478,7 +16643,7 @@ function completionContext(source, cursor, macros = []) {
16478
16643
  if (sigilsOnly) {
16479
16644
  let at3 = 0;
16480
16645
  for (const part of splitSigilTemplate(src, true)) if ("expr" in part) {
16481
- if (at3 + 1 + part.expr.length === src.length) return codeContext(part.expr, "expression", (i2) => map2(at3 + 1 + i2), containers);
16646
+ if (map2(at3 + 1) <= cursor && cursor <= map2(at3 + 1 + part.expr.length)) return codeContext(part.expr, "expression", (i2) => map2(at3 + 1 + i2), containers);
16482
16647
  at3 += part.expr.length + 2;
16483
16648
  } else at3 += ("text" in part ? part.text : part.verbatim).length;
16484
16649
  return LITERAL;
@@ -16487,14 +16652,17 @@ function completionContext(source, cursor, macros = []) {
16487
16652
  text: text3,
16488
16653
  hooks: { isRaw: (name) => isRawMacro(name, parametersOf2.widget?.(name) !== void 0) }
16489
16654
  });
16490
- const token = tokens2[tokens2.length - 1];
16491
- if (!token || token.end !== src.length) return LITERAL;
16655
+ if (visit2 && !visit2(tokens2, map2)) return LITERAL;
16656
+ const contains = (start, end) => map2(start) <= cursor && cursor <= map2(end);
16657
+ const index = tokens2.findIndex((token2) => map2(token2.start) < cursor && cursor <= map2(token2.end));
16658
+ const token = tokens2[index];
16659
+ if (!token) return LITERAL;
16492
16660
  const codeAt = (code, at3, goal = "expression") => codeContext(code, goal, (i2) => map2(at3 + i2), containers);
16493
16661
  const nested = (value, at3, offsets, onlySigils = false, container) => read(value, (i2) => map2(offsets?.[i2] ?? at3 + i2), true, depth + 1, onlySigils, container ? [...containers, container] : containers);
16494
- if (token.type === "variable" && token.nameEnd === src.length) return codeAt(src.slice(token.nameStart - 1), token.nameStart - 1);
16495
- if (token.type === "expression" && token.expressionEnd === src.length) return codeAt(token.expression, token.expressionStart);
16662
+ if (token.type === "variable" && contains(token.nameStart - 1, token.nameEnd)) return codeAt(src.slice(token.nameStart - 1, token.nameEnd), token.nameStart - 1);
16663
+ if (token.type === "expression" && contains(token.expressionStart, token.expressionEnd)) return codeAt(token.expression, token.expressionStart);
16496
16664
  if (token.type === "html") {
16497
- for (const { name, value, at: at3 } of attributeValues(src, token)) if (at3 + value.length === src.length) {
16665
+ for (const { name, value, at: at3 } of attributeValues(src, token)) if (contains(at3, at3 + value.length)) {
16498
16666
  const span = token.attributeSpans.find((span2) => span2.valueStart === at3);
16499
16667
  return nested(value, at3, void 0, isCodeAttribute(name), {
16500
16668
  kind: "attribute",
@@ -16503,11 +16671,11 @@ function completionContext(source, cursor, macros = []) {
16503
16671
  code: isCodeAttribute(name)
16504
16672
  });
16505
16673
  }
16506
- } else if (token.type === "link" && token.displayEnd === src.length) return nested(token.display, token.displayStart, void 0, false, { kind: "link-label" });
16674
+ } else if (token.type === "link" && contains(token.displayStart, token.displayEnd)) return nested(token.display, token.displayStart, void 0, false, { kind: "link-label" });
16507
16675
  else if (token.type === "text" && !token.comment) {
16508
- const opener = tokens2[tokens2.length - 2];
16676
+ const opener = tokens2[index - 1];
16509
16677
  if (opener?.type === "macro" && !opener.isClose && executesRawBody(opener.name, parametersOf2)) return codeAt(token.value, token.start, "statements");
16510
- } else if (token.type === "macro" && !token.isClose && token.argsEnd === src.length) {
16678
+ } else if (token.type === "macro" && !token.isClose && contains(token.argsStart, token.argsEnd)) {
16511
16679
  const name = token.name.toLowerCase();
16512
16680
  const args2 = token.rawArgs;
16513
16681
  const widget = parametersOf2.widget?.(name);
@@ -16520,29 +16688,32 @@ function completionContext(source, cursor, macros = []) {
16520
16688
  if (holds === "expression" || holds === "statements") return codeAt(raw2, at4, holds);
16521
16689
  return holds === "markup" ? nested(raw2, at4) : LITERAL;
16522
16690
  }
16523
- if (scanStringLiteral(raw2, 0).closed) return LITERAL;
16524
- const value = escapes === "javascript" ? stringLiteralValue(raw2 + raw2[0]) : quoted.value;
16691
+ const scan = scanStringLiteral(raw2, 0);
16692
+ const bodyEnd = scan.closed ? scan.end - 1 : scan.end;
16693
+ if (!contains(at4 + 1, at4 + bodyEnd)) return LITERAL;
16694
+ const value = escapes === "javascript" ? stringLiteralValue(raw2.slice(0, scan.end) + (scan.closed ? "" : raw2[0])) : quoted.value;
16525
16695
  if (value == null) return LITERAL;
16526
16696
  const container = {
16527
16697
  kind: "string",
16528
16698
  quote: raw2[0],
16529
16699
  escapes
16530
16700
  };
16531
- const offsets = escapeOffsets(raw2.slice(1), at4 + 1, value, escapes);
16701
+ const offsets = escapeOffsets(raw2.slice(1, bodyEnd), at4 + 1, value, escapes);
16532
16702
  if (holds === "expression" || holds === "statements") return codeContext(value, holds, (i2) => map2(offsets?.[i2] ?? at4 + 1 + i2), [...containers, container]);
16533
16703
  return holds === "markup" ? nested(value, at4 + 1, offsets, false, container) : LITERAL;
16534
16704
  };
16535
16705
  if (widget) {
16536
16706
  const spans2 = splitArgSpans(args2);
16537
- const span2 = spans2[spans2.length - 1];
16707
+ const which = spans2.findIndex(([start, end]) => contains(token.argsStart + start, token.argsStart + end));
16708
+ const span2 = spans2[which];
16538
16709
  if (!span2) return LITERAL;
16539
- const raw2 = args2.slice(span2[0]);
16540
- const holds = widget[spans2.length - 1]?.holds;
16710
+ const raw2 = args2.slice(...span2);
16711
+ const holds = widget[which]?.holds;
16541
16712
  return /^["']/.test(raw2) && holds ? stringContext(raw2, token.argsStart + span2[0], holds, "javascript") : codeAt(raw2, token.argsStart + span2[0]);
16542
16713
  }
16543
16714
  const params = parametersOf2(name);
16544
16715
  if (!params) return LITERAL;
16545
- const spans = macroArgumentSpans(args2, params).filter((span2) => span2.parameter.type !== "options" && span2.end === args2.trimEnd().length);
16716
+ const spans = macroArgumentSpans(args2, params).filter((span2) => span2.parameter.type !== "options" && contains(token.argsStart + span2.start, token.argsStart + span2.end));
16546
16717
  const span = spans[spans.length - 1];
16547
16718
  if (!span) return LITERAL;
16548
16719
  const param = span.parameter;
@@ -16551,7 +16722,7 @@ function completionContext(source, cursor, macros = []) {
16551
16722
  at3 += param.name.length;
16552
16723
  while (/\s/.test(args2.charAt(at3))) at3++;
16553
16724
  }
16554
- const raw = args2.slice(at3);
16725
+ const raw = args2.slice(at3, span.end);
16555
16726
  const offset2 = token.argsStart + at3;
16556
16727
  if (param.type === "expression" || param.type === "passage") return codeAt(raw, offset2);
16557
16728
  if (param.type === "statements") return codeAt(raw, offset2, "statements");
@@ -16559,7 +16730,7 @@ function completionContext(source, cursor, macros = []) {
16559
16730
  }
16560
16731
  return LITERAL;
16561
16732
  };
16562
- return read(source.slice(0, cursor), (i2) => i2);
16733
+ return read(source, (i2) => i2);
16563
16734
  }
16564
16735
  function textContainsChildren(text3, parametersOf2, hooks, budget = new MarkupExpansionBudget(text3.length)) {
16565
16736
  if (!text3.includes("{")) return false;
@@ -21208,6 +21379,72 @@ function markdownOptions(options) {
21208
21379
  htmlExtensions: [gfmTableHtml(), gfmStrikethroughHtml()]
21209
21380
  };
21210
21381
  }
21382
+ function boundedMarkdownOptions(text3, options) {
21383
+ const base = markdownOptions(options);
21384
+ return {
21385
+ ...base,
21386
+ extensions: [
21387
+ ...base.extensions ?? [],
21388
+ unclosedHtml(text3),
21389
+ textData
21390
+ ]
21391
+ };
21392
+ }
21393
+ function unclosedHtml(text3) {
21394
+ const shift = text3.charCodeAt(0) === 65279 ? 1 : 0;
21395
+ const comment = text3.lastIndexOf("-->");
21396
+ const instruction = text3.lastIndexOf("?>");
21397
+ const cdata = text3.lastIndexOf("]]>");
21398
+ const declaration = text3.lastIndexOf(">");
21399
+ function unclosed(p) {
21400
+ if (text3[p] !== "<") return false;
21401
+ if (text3.startsWith("<!--", p)) return comment < p + 2;
21402
+ if (text3.startsWith("<![CDATA[", p)) return cdata < p + 9;
21403
+ if (text3[p + 1] === "!" && ALPHA.test(text3[p + 2] ?? "")) return declaration < p + 3;
21404
+ if (text3[p + 1] === "?") return instruction < p + 2 && !emailAutolink(p);
21405
+ return false;
21406
+ }
21407
+ function emailAutolink(p) {
21408
+ let i2 = p + 1;
21409
+ while (ATEXT.test(text3[i2] ?? "")) i2++;
21410
+ if (text3[i2] !== "@") return false;
21411
+ i2++;
21412
+ let size = 0;
21413
+ let state = "atSignOrDot";
21414
+ for (; ; ) {
21415
+ const c = text3[i2] ?? "";
21416
+ if (state === "atSignOrDot") {
21417
+ if (!ALPHANUMERIC.test(c)) return false;
21418
+ state = "label";
21419
+ } else if (state === "label") {
21420
+ if (c === ">") return true;
21421
+ if (c === ".") {
21422
+ i2++;
21423
+ size = 0;
21424
+ state = "atSignOrDot";
21425
+ } else state = "value";
21426
+ } else {
21427
+ if (!((c === "-" || ALPHANUMERIC.test(c)) && size++ < 63)) return false;
21428
+ i2++;
21429
+ state = c === "-" ? "value" : "label";
21430
+ }
21431
+ }
21432
+ }
21433
+ return { text: { 60: {
21434
+ name: "unclosedHtml",
21435
+ resolveTo: joinData,
21436
+ tokenize(effects, ok, nok) {
21437
+ const at3 = this.now().offset + shift;
21438
+ return (code) => {
21439
+ if (code !== 60 || !unclosed(at3)) return nok(code);
21440
+ effects.enter("data");
21441
+ effects.consume(code);
21442
+ effects.exit("data");
21443
+ return ok;
21444
+ };
21445
+ }
21446
+ } } };
21447
+ }
21211
21448
  function sourceLines(source) {
21212
21449
  const position = sourcePositions(source);
21213
21450
  return (offset2) => position(offset2).line - 1;
@@ -21233,7 +21470,7 @@ function markdownLines(source, isBlock, types3) {
21233
21470
  for (const branch of node2.body.branches) visit2(branch.children);
21234
21471
  }
21235
21472
  }
21236
- const events = postprocess(parse3(markdownOptions()).document().write(preprocess()(markdown, void 0, true)));
21473
+ const events = postprocess(parse3(boundedMarkdownOptions(markdown)).document().write(preprocess()(markdown, void 0, true)));
21237
21474
  for (const [event, token] of events) {
21238
21475
  if (event !== "enter" || !types3.has(token.type)) continue;
21239
21476
  let low = 0;
@@ -21877,7 +22114,6 @@ function blockLookup(macros, includeRuntime = true) {
21877
22114
  }
21878
22115
  function macroCalls(source, macros = []) {
21879
22116
  const all = effectiveToolingMacros(macros);
21880
- const definitions = new NameMap(all.map((macro) => [macro.name, macro]));
21881
22117
  const parametersOf2 = parameterLookup(all);
21882
22118
  const options = tokenizationOptions({
21883
22119
  macros: all,
@@ -21886,9 +22122,32 @@ function macroCalls(source, macros = []) {
21886
22122
  const hooks = options.hooks;
21887
22123
  const tokens2 = tokenizeMarkupTolerant$1(source, options).tokens;
21888
22124
  const calls = [];
22125
+ const classifier = macroClassifier(all);
21889
22126
  const classify2 = (tokens3) => {
22127
+ for (const call of classifier(tokens3)) calls.push(call);
22128
+ };
22129
+ classify2(tokens2);
22130
+ for (const piece of passagePiecesOf(source, tokens2, parametersOf2, { isBlock: hooks.isBlock })) {
22131
+ if (piece.kind !== "text" || !piece.tokens.length) continue;
22132
+ classify2(piece.tokens);
22133
+ }
22134
+ let literalEnd = -1;
22135
+ return calls.sort((a, b) => a.token.start - b.token.start).filter((call) => {
22136
+ if (call.token.start < literalEnd) return false;
22137
+ if (call.kind === "value" || call.kind === "branch") literalEnd = call.token.argsEnd;
22138
+ return true;
22139
+ });
22140
+ }
22141
+ function macroClassifier(all) {
22142
+ const definitions = new NameMap(all.map((macro) => [macro.name, macro]));
22143
+ const hooks = tokenizationOptions({
22144
+ macros: all,
22145
+ hooks: { isBlock: blockLookup(all, false) }
22146
+ }).hooks;
22147
+ return (tokens2) => {
22148
+ const calls = [];
21890
22149
  const found = /* @__PURE__ */ new Map();
21891
- const pending = pairMarkup(tokens3, hooks).nodes.map((node2) => ({ node: node2 }));
22150
+ const pending = pairMarkup(tokens2, hooks).nodes.map((node2) => ({ node: node2 }));
21892
22151
  while (pending.length) {
21893
22152
  const { node: node2, parent } = pending.pop();
21894
22153
  const token = node2.token;
@@ -21919,7 +22178,7 @@ function macroCalls(source, macros = []) {
21919
22178
  });
21920
22179
  }
21921
22180
  }
21922
- for (const token of tokens3) {
22181
+ for (const token of tokens2) {
21923
22182
  if (token.type !== "macro" || token.isClose) continue;
21924
22183
  const call = found.get(token) ?? {
21925
22184
  token,
@@ -21927,18 +22186,8 @@ function macroCalls(source, macros = []) {
21927
22186
  };
21928
22187
  calls.push(call);
21929
22188
  }
22189
+ return calls;
21930
22190
  };
21931
- classify2(tokens2);
21932
- for (const piece of passagePiecesOf(source, tokens2, parametersOf2, { isBlock: hooks.isBlock })) {
21933
- if (piece.kind !== "text" || !piece.tokens.length) continue;
21934
- classify2(piece.tokens);
21935
- }
21936
- let literalEnd = -1;
21937
- return calls.sort((a, b) => a.token.start - b.token.start).filter((call) => {
21938
- if (call.token.start < literalEnd) return false;
21939
- if (call.kind === "value" || call.kind === "branch") literalEnd = call.token.argsEnd;
21940
- return true;
21941
- });
21942
22191
  }
21943
22192
  function passagePieces(source, macros = []) {
21944
22193
  const all = effectiveToolingMacros(macros);
@@ -21971,7 +22220,7 @@ function validateVariableReferences(passages, declarations, macros = []) {
21971
22220
  const list3 = [...passages];
21972
22221
  return checkVariableReferences(list3.filter((p) => !p.tags?.some((t) => NOT_MARKUP_TAGS.includes(t))), declarations, referenceOptions(macros, false, list3));
21973
22222
  }
21974
- var __defProp2, __exportAll, NameMap, NameSet, 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, OPTION_CLAUSE, PARAMETER_TYPES, STRING_HOLDS, metadataRegistry, companionParents, BLOCK_MACROS, BLOCK_WIDGETS, WIDGETS, DEFINED_BLOCK_MACROS, DEFINED_MACROS, REGISTERED_BLOCK_MACROS, RAW_BODY_MACROS, BRANCHING, quoteArg, MAX_MARKUP_DEPTH, 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, RESERVED_NAME, isArrayIndex, hasOwn, createNamespace, TRAILING_OPERATOR_RE, slice, MacroArgumentError, WORD_RE$1, NUMBER_RE$1, WORD_OR_PUNCT_RE, LEADING_OPERATOR_RE, takesRest, SUB_MACRO_PARAMETERS, _MarkupExpansionBudget, MarkupExpansionBudget, parses, CONDITION_MACROS, PASSAGE_BODIES, holdsByDefault, JS_ESCAPE_RE, textPiece, LITERAL, registeredParameters, WIDGET_PARAMETERS, SPECIAL_PASSAGES, 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, VALID_VAR_TYPES, PRIMITIVE_SAMPLES, UNSUPPORTED_TYPE, NO_STORE_VAR_MACROS, 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, 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, HTML_MARKDOWN_BOUNDARIES, LIST_ITEM_REGEX, CODE_FENCE_REGEX, NO_WRAP, NOT_MARKUP_TAGS;
22223
+ var __defProp2, __exportAll, HTML_TEXT_ELEMENTS$1, SIGIL_SCOPES, SIGIL_CHARS, grammar_shared_default, LB, RB, SIGIL_SCOPES$1, withSelectors, HTML_TEXT_ELEMENTS, VOID_TAGS, BRANCH_PARENT$1, LINK_SEPARATORS, NO_SELECTORS, EMAIL_AUTOLINK, peg$SyntaxError, NameMap, NameSet, OPTION_CLAUSE, PARAMETER_TYPES, STRING_HOLDS, metadataRegistry, companionParents, BLOCK_MACROS, BLOCK_WIDGETS, WIDGETS, DEFINED_BLOCK_MACROS, DEFINED_MACROS, REGISTERED_BLOCK_MACROS, RAW_BODY_MACROS, BRANCHING, quoteArg, MAX_MARKUP_DEPTH, 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, RESERVED_NAME, isArrayIndex, hasOwn, createNamespace, TRAILING_OPERATOR_RE, slice, MacroArgumentError, WORD_RE$1, NUMBER_RE$1, WORD_OR_PUNCT_RE, LEADING_OPERATOR_RE, takesRest, SUB_MACRO_PARAMETERS, _MarkupExpansionBudget, MarkupExpansionBudget, parses, CONDITION_MACROS, PASSAGE_BODIES, holdsByDefault, JS_ESCAPE_RE, textPiece, LITERAL, registeredParameters, WIDGET_PARAMETERS, SPECIAL_PASSAGES, 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, VALID_VAR_TYPES, PRIMITIVE_SAMPLES, UNSUPPORTED_TYPE, NO_STORE_VAR_MACROS, 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, 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, joinData, textData, ATEXT, ALPHANUMERIC, ALPHA, DEFAULT_PRETTIER_OPTIONS, SVG_PLACEHOLDERS, SPINDLE_PLACEHOLDERS, PLACEHOLDER_PATTERN, DEFAULT_DEDENTING, WHITESPACE_AS_WRITTEN, HTML_MARKDOWN_BOUNDARIES, LIST_ITEM_REGEX, CODE_FENCE_REGEX, NO_WRAP, NOT_MARKUP_TAGS;
21975
22224
  var init_story_variables = __esm({
21976
22225
  "node_modules/@rohal12/spindle/dist/pkg/story-variables.js"() {
21977
22226
  __defProp2 = Object.defineProperty;
@@ -21984,38 +22233,18 @@ var init_story_variables = __esm({
21984
22233
  if (!no_symbols) __defProp2(target, Symbol.toStringTag, { value: "Module" });
21985
22234
  return target;
21986
22235
  };
21987
- NameMap = class extends Map {
21988
- get(name) {
21989
- return super.get(name.toLowerCase());
21990
- }
21991
- set(name, value) {
21992
- return super.set(name.toLowerCase(), value);
21993
- }
21994
- has(name) {
21995
- return super.has(name.toLowerCase());
21996
- }
21997
- delete(name) {
21998
- return super.delete(name.toLowerCase());
21999
- }
22000
- };
22001
- NameSet = class {
22002
- constructor(names = []) {
22003
- this.names = new NameMap();
22004
- for (const name of names) this.add(name);
22005
- }
22006
- add(name) {
22007
- this.names.set(name, true);
22008
- }
22009
- has(name) {
22010
- return this.names.has(name);
22011
- }
22012
- delete(name) {
22013
- this.names.delete(name);
22014
- }
22015
- clear() {
22016
- this.names.clear();
22017
- }
22018
- };
22236
+ HTML_TEXT_ELEMENTS$1 = /* @__PURE__ */ new Set([
22237
+ .../* @__PURE__ */ new Set([
22238
+ "script",
22239
+ "style",
22240
+ "xmp",
22241
+ "iframe",
22242
+ "noembed",
22243
+ "noframes"
22244
+ ]),
22245
+ "textarea",
22246
+ "title"
22247
+ ]);
22019
22248
  SIGIL_SCOPES = {
22020
22249
  $: "variable",
22021
22250
  _: "temporary",
@@ -22026,11 +22255,12 @@ var init_story_variables = __esm({
22026
22255
  SIGIL_CHARS = new Set(Object.keys(SIGIL_SCOPES));
22027
22256
  grammar_shared_default = {
22028
22257
  SIGIL_SCOPES,
22029
- withSelectors: withSelectors$1
22258
+ withSelectors: withSelectors$1,
22259
+ HTML_TEXT_ELEMENTS: HTML_TEXT_ELEMENTS$1
22030
22260
  };
22031
22261
  LB = String.fromCharCode(123);
22032
22262
  RB = String.fromCharCode(125);
22033
- ({ SIGIL_SCOPES: SIGIL_SCOPES$1, withSelectors } = grammar_shared_default);
22263
+ ({ SIGIL_SCOPES: SIGIL_SCOPES$1, withSelectors, HTML_TEXT_ELEMENTS } = grammar_shared_default);
22034
22264
  VOID_TAGS = /* @__PURE__ */ new Set([
22035
22265
  "area",
22036
22266
  "base",
@@ -22150,6 +22380,38 @@ var init_story_variables = __esm({
22150
22380
  return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
22151
22381
  }
22152
22382
  };
22383
+ NameMap = class extends Map {
22384
+ get(name) {
22385
+ return super.get(name.toLowerCase());
22386
+ }
22387
+ set(name, value) {
22388
+ return super.set(name.toLowerCase(), value);
22389
+ }
22390
+ has(name) {
22391
+ return super.has(name.toLowerCase());
22392
+ }
22393
+ delete(name) {
22394
+ return super.delete(name.toLowerCase());
22395
+ }
22396
+ };
22397
+ NameSet = class {
22398
+ constructor(names = []) {
22399
+ this.names = new NameMap();
22400
+ for (const name of names) this.add(name);
22401
+ }
22402
+ add(name) {
22403
+ this.names.set(name, true);
22404
+ }
22405
+ has(name) {
22406
+ return this.names.has(name);
22407
+ }
22408
+ delete(name) {
22409
+ this.names.delete(name);
22410
+ }
22411
+ clear() {
22412
+ this.names.clear();
22413
+ }
22414
+ };
22153
22415
  OPTION_CLAUSE = "option";
22154
22416
  new NameMap();
22155
22417
  new NameMap();
@@ -27292,9 +27554,7 @@ var init_story_variables = __esm({
27292
27554
  if (name) {
27293
27555
  const end = at3 + 1 + name.length;
27294
27556
  const afterPrefix = self.type === types$1.incDec && (this.operandBeforeLast || this.breakBeforeLast);
27295
- const forced = code === 37 ? this.percentAt?.get(at3) : void 0;
27296
- if (code === 64 || (forced ?? (self.exprAllowed || afterPrefix || this.lookahead && transientAssignment(self, end)))) {
27297
- if (code === 37) this.transientsRead?.add(at3);
27557
+ if (code === 64 || self.exprAllowed || afterPrefix || this.lookahead && transientAssignment(self, end)) {
27298
27558
  self.pos = end;
27299
27559
  self.finishToken(types$1.name, self.input.charAt(at3) + name);
27300
27560
  return;
@@ -27317,16 +27577,31 @@ var init_story_variables = __esm({
27317
27577
  }
27318
27578
  const self = this;
27319
27579
  const prevType = self.type;
27580
+ const beforePreviousValue = this.prevValue;
27320
27581
  this.prevValue = isMemberDot(this.typeBeforeLast) ? void 0 : self.value;
27321
27582
  const property = type.keyword !== void 0 && isMemberDot(prevType) || (type === types$1._function || type === types$1._class) && notABody(self.input, self.pos);
27322
27583
  if (!property && (type === types$1._function || type === types$1._class)) {
27323
- const before = type === types$1._function && prevType === types$1.name && this.prevValue === "async" && !this.breakHere ? this.typeBeforeLast : prevType;
27324
- self.type = before === types$1.colon && this.colonEndsTernary ? types$1.parenL : before;
27584
+ const afterAsync = type === types$1._function && prevType === types$1.name && this.prevValue === "async" && !this.breakHere;
27585
+ const before = afterAsync ? this.typeBeforeLast : prevType;
27586
+ const contextualOperand = before === types$1.name && (afterAsync ? this.operandBeforeLast : self.exprAllowed) && ((afterAsync ? beforePreviousValue : this.prevValue) !== "yield" || !(afterAsync ? this.breakBeforeLast : this.breakHere));
27587
+ self.type = before === types$1.colon && this.colonEndsTernary || contextualOperand ? types$1.parenL : before;
27325
27588
  }
27326
27589
  this.typeBeforeLast = prevType;
27327
27590
  super.finishToken(property ? types$1.name : type, value);
27328
27591
  if (type === types$1.name && (isMemberDot(prevType) || value === "of" && (prevType === types$1._const || prevType === types$1._var || this.prevValue === "let"))) self.exprAllowed = false;
27329
27592
  }
27593
+ parseIdent(liberal) {
27594
+ this.exprAllowed = false;
27595
+ return super.parseIdent(liberal);
27596
+ }
27597
+ parseForIn(node2, init) {
27598
+ this.exprAllowed = true;
27599
+ return super.parseForIn(node2, init);
27600
+ }
27601
+ parseAwait(forInit) {
27602
+ this.exprAllowed = true;
27603
+ return super.parseAwait(forInit);
27604
+ }
27330
27605
  braceIsBlock(prevType) {
27331
27606
  if (prevType === types$1.colon && this.colonEndsTernary) return false;
27332
27607
  if (prevType === types$1.braceR && this.closedBlock) return true;
@@ -31281,6 +31556,44 @@ var init_story_variables = __esm({
31281
31556
  this.index.clear();
31282
31557
  }
31283
31558
  };
31559
+ joinData = (events) => {
31560
+ const at3 = events.length - 2;
31561
+ const before = events[at3 - 1];
31562
+ if (before && before[0] === "exit" && before[1].type === "data") {
31563
+ before[1].end = events[at3][1].end;
31564
+ events.length = at3;
31565
+ }
31566
+ return events;
31567
+ };
31568
+ textData = { text: { null: {
31569
+ name: "textData",
31570
+ tokenize(effects, ok) {
31571
+ const self = this;
31572
+ const constructs2 = this.parser.constructs.text;
31573
+ function atBreak(code) {
31574
+ if (code === null) return true;
31575
+ const list3 = constructs2[code] ?? [];
31576
+ return (Array.isArray(list3) ? list3 : [list3]).some((item) => !item.previous || item.previous.call(self, self.previous));
31577
+ }
31578
+ function data2(code) {
31579
+ if (atBreak(code)) {
31580
+ effects.exit("data");
31581
+ return ok(code);
31582
+ }
31583
+ effects.consume(code);
31584
+ return data2;
31585
+ }
31586
+ return (code) => {
31587
+ effects.enter("data");
31588
+ effects.consume(code);
31589
+ return data2;
31590
+ };
31591
+ },
31592
+ resolveTo: joinData
31593
+ } } };
31594
+ ATEXT = /[#-'*+\--9=?A-Z^-~]/;
31595
+ ALPHANUMERIC = /[0-9A-Za-z]/;
31596
+ ALPHA = /[A-Za-z]/;
31284
31597
  DEFAULT_PRETTIER_OPTIONS = { tabWidth: 2 };
31285
31598
  SVG_PLACEHOLDERS = (i2) => [`<!--SVG:${i2}-->`];
31286
31599
  SPINDLE_PLACEHOLDERS = (i2) => [`<!--SP:${i2}-->`, `__SP${i2}__`];