@rohal12/spindle 0.64.23 → 0.64.25

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.
@@ -81,12 +81,23 @@ var NOT_TEXT = /* @__PURE__ */ new Set([
81
81
  "template",
82
82
  "noscript"
83
83
  ]);
84
+ var SVG_NOT_TEXT = /* @__PURE__ */ new Set([
85
+ "title",
86
+ "desc",
87
+ "metadata",
88
+ "defs",
89
+ "symbol",
90
+ "clippath",
91
+ "mask",
92
+ "pattern",
93
+ "marker"
94
+ ]);
84
95
  /**
85
96
  * Whether the element hides its whole subtree, including stylesheet rules.
86
97
  * This needs computed styles but no layout, so it also works headlessly.
87
98
  */
88
99
  function isHidden(el) {
89
- return el.hasAttribute("hidden") || el.getAttribute("aria-hidden") === "true" || /(^|;)\s*display\s*:\s*none\b/i.test(el.getAttribute("style") ?? "") || el.ownerDocument.defaultView?.getComputedStyle(el).display === "none" || NOT_TEXT.has(el.localName.toLowerCase()) || el.parentElement?.tagName === "DETAILS" && !el.parentElement.hasAttribute("open") && el !== Array.from(el.parentElement.children).find((c) => c.tagName === "SUMMARY");
100
+ return el.hasAttribute("hidden") || el.getAttribute("aria-hidden") === "true" || /(^|;)\s*display\s*:\s*none\b/i.test(el.getAttribute("style") ?? "") || el.ownerDocument.defaultView?.getComputedStyle(el).display === "none" || NOT_TEXT.has(el.localName.toLowerCase()) || el.namespaceURI === "http://www.w3.org/2000/svg" && SVG_NOT_TEXT.has(el.localName.toLowerCase()) || el.parentElement?.tagName === "DETAILS" && !el.parentElement.hasAttribute("open") && el !== Array.from(el.parentElement.children).find((c) => c.tagName === "SUMMARY");
90
101
  }
91
102
  /**
92
103
  * Whether `el` is in a closed `<details>`, other than in the summary that
@@ -9953,9 +9964,9 @@ function peg$parse(input, options) {
9953
9964
  const peg$c7 = "[";
9954
9965
  const peg$c8 = "[[";
9955
9966
  const peg$c9 = "]]";
9956
- const peg$c10 = " ";
9967
+ const peg$c10 = "/";
9957
9968
  const peg$c11 = "}";
9958
- const peg$c12 = "/";
9969
+ const peg$c12 = " ";
9959
9970
  const peg$c13 = "@";
9960
9971
  const peg$c14 = ":";
9961
9972
  const peg$c15 = "</";
@@ -9991,38 +10002,38 @@ function peg$parse(input, options) {
9991
10002
  const peg$e11 = peg$literalExpectation("[", false);
9992
10003
  const peg$e12 = peg$literalExpectation("[[", false);
9993
10004
  const peg$e13 = peg$literalExpectation("]]", false);
9994
- const peg$e14 = peg$literalExpectation(" ", false);
9995
- const peg$e15 = peg$classExpectation([".", "#"], false, false, false);
9996
- const peg$e16 = peg$classExpectation([
10005
+ const peg$e14 = peg$literalExpectation("/", false);
10006
+ const peg$e15 = peg$classExpectation([
10007
+ "$",
10008
+ "_",
10009
+ "@",
10010
+ "%",
10011
+ "(",
10012
+ "!"
10013
+ ], false, false, false);
10014
+ const peg$e16 = peg$literalExpectation("}", false);
10015
+ const peg$e17 = peg$literalExpectation(" ", false);
10016
+ const peg$e18 = peg$classExpectation([".", "#"], false, false, false);
10017
+ const peg$e19 = peg$classExpectation([
9997
10018
  ["a", "z"],
9998
10019
  ["A", "Z"],
9999
10020
  ["0", "9"],
10000
10021
  "_",
10001
10022
  "-"
10002
10023
  ], false, false, false);
10003
- const peg$e17 = peg$classExpectation([
10024
+ const peg$e20 = peg$classExpectation([
10004
10025
  "$",
10005
10026
  "_",
10006
10027
  "@",
10007
10028
  "%"
10008
10029
  ], false, false, false);
10009
- const peg$e18 = peg$classExpectation([
10030
+ const peg$e21 = peg$classExpectation([
10010
10031
  ["a", "z"],
10011
10032
  ["A", "Z"],
10012
10033
  ["0", "9"],
10013
10034
  "_",
10014
10035
  "."
10015
10036
  ], false, false, false);
10016
- const peg$e19 = peg$literalExpectation("}", false);
10017
- const peg$e20 = peg$classExpectation([
10018
- "$",
10019
- "_",
10020
- "@",
10021
- "%",
10022
- "(",
10023
- "!"
10024
- ], false, false, false);
10025
- const peg$e21 = peg$literalExpectation("/", false);
10026
10037
  const peg$e22 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false, false);
10027
10038
  const peg$e23 = peg$classExpectation([
10028
10039
  " ",
@@ -10296,7 +10307,7 @@ function peg$parse(input, options) {
10296
10307
  return !textMode;
10297
10308
  }
10298
10309
  function peg$f34(ss, s, at, inner) {
10299
- const link = lexeme("link", location(), parseLink(inner, at, (separator) => linkSeparatorIndex(inner, at, separator)));
10310
+ const link = lexeme("link", location(), parseLink(inner.value, at, (separator) => linkSeparatorIndex(inner.value, at, separator, inner.spans)));
10300
10311
  link.selectorSpan = selectorSpan(s, ss, at);
10301
10312
  return withSelectors(link, s);
10302
10313
  }
@@ -10306,22 +10317,56 @@ function peg$parse(input, options) {
10306
10317
  function peg$f36() {
10307
10318
  fail("Unclosed link: [[ without ]]", location(), "unclosed-link");
10308
10319
  }
10309
- function peg$f37(parts) {
10320
+ function peg$f37(start) {
10321
+ const close = input.indexOf("]]", start);
10322
+ const nested = input.indexOf("[[", start);
10323
+ linkTextEnd = Math.min(close < 0 ? input.length : close, nested < 0 ? input.length : nested);
10324
+ return true;
10325
+ }
10326
+ function peg$f38(start, part) {
10327
+ return typeof part === "string" ? null : part;
10328
+ }
10329
+ function peg$f39(start, parts, end) {
10330
+ return {
10331
+ value: input.slice(start, end),
10332
+ spans: parts.filter(Boolean)
10333
+ };
10334
+ }
10335
+ function peg$f40(start, end) {
10336
+ return {
10337
+ start,
10338
+ end
10339
+ };
10340
+ }
10341
+ function peg$f41(start, codeStart, nameEnd) {
10342
+ const close = hooks.closeBrace(input, nameEnd, codeStart);
10343
+ return close >= 0 && close < linkTextEnd && skipTo(close);
10344
+ }
10345
+ function peg$f42(start, codeStart, nameEnd) {
10346
+ return skipEnd - offset();
10347
+ }
10348
+ function peg$f43(start, codeStart, nameEnd, end) {
10349
+ return {
10350
+ start,
10351
+ end
10352
+ };
10353
+ }
10354
+ function peg$f44(parts) {
10310
10355
  return selectorsOf(parts);
10311
10356
  }
10312
- function peg$f38() {
10357
+ function peg$f45() {
10313
10358
  return NO_SELECTORS;
10314
10359
  }
10315
- function peg$f39(s, end) {
10360
+ function peg$f46(s, end) {
10316
10361
  return {
10317
10362
  ...s,
10318
10363
  end
10319
10364
  };
10320
10365
  }
10321
- function peg$f40(prefix, name) {
10366
+ function peg$f47(prefix, name) {
10322
10367
  return [prefix, name];
10323
10368
  }
10324
- function peg$f41(ss, s, sigil, nameStart, name) {
10369
+ function peg$f48(ss, s, sigil, nameStart, name) {
10325
10370
  const variable = lexeme("variable", location(), {
10326
10371
  name,
10327
10372
  nameStart,
@@ -10331,7 +10376,7 @@ function peg$parse(input, options) {
10331
10376
  variable.selectorSpan = selectorSpan(s, ss, nameStart - 1);
10332
10377
  return withSelectors(variable, s);
10333
10378
  }
10334
- function peg$f42(ss, s, after, expression) {
10379
+ function peg$f49(ss, s, after, expression) {
10335
10380
  const node = lexeme("expression", location(), {
10336
10381
  expression,
10337
10382
  expressionStart: after,
@@ -10340,33 +10385,33 @@ function peg$parse(input, options) {
10340
10385
  node.selectorSpan = selectorSpan(s, ss, after);
10341
10386
  return withSelectors(node, s);
10342
10387
  }
10343
- function peg$f43() {
10388
+ function peg$f50() {
10344
10389
  fail("Unclosed {" + input.substr(location().end.offset, 1) + "…: no } ends it", location(), "unclosed-expression");
10345
10390
  }
10346
- function peg$f44(start) {
10391
+ function peg$f51(start) {
10347
10392
  const end = hooks.closeBrace(input, start, start);
10348
10393
  return skipTo(end < 0 && completionMode ? input.length : end);
10349
10394
  }
10350
- function peg$f45(start) {
10395
+ function peg$f52(start) {
10351
10396
  return skipEnd - offset();
10352
10397
  }
10353
- function peg$f46(start, code) {
10398
+ function peg$f53(start, code) {
10354
10399
  return code;
10355
10400
  }
10356
- function peg$f47() {
10401
+ function peg$f54() {
10357
10402
  return completionMode;
10358
10403
  }
10359
- function peg$f48(ss, s, start, close, name, nameEnd) {
10404
+ function peg$f55(ss, s, start, close, name, nameEnd) {
10360
10405
  const end = hooks.closeBrace(input, nameEnd, start);
10361
10406
  return skipTo(end < 0 && completionMode ? input.length : end);
10362
10407
  }
10363
- function peg$f49(ss, s, start, close, name, nameEnd) {
10408
+ function peg$f56(ss, s, start, close, name, nameEnd) {
10364
10409
  return skipEnd - offset();
10365
10410
  }
10366
- function peg$f50(ss, s, start, close, name, nameEnd, args) {
10411
+ function peg$f57(ss, s, start, close, name, nameEnd, args) {
10367
10412
  return args;
10368
10413
  }
10369
- function peg$f51(ss, s, start, close, name, nameEnd, tail) {
10414
+ function peg$f58(ss, s, start, close, name, nameEnd, tail) {
10370
10415
  const loc = location();
10371
10416
  const lower = name.toLowerCase();
10372
10417
  const tag = lexeme("macro", loc, {
@@ -10392,19 +10437,19 @@ function peg$parse(input, options) {
10392
10437
  }
10393
10438
  return tag;
10394
10439
  }
10395
- function peg$f52(s) {
10440
+ function peg$f59(s) {
10396
10441
  fail("A closing tag starts with a letter after {/", location(), "invalid-closer");
10397
10442
  }
10398
- function peg$f53(value) {
10443
+ function peg$f60(value) {
10399
10444
  return EMAIL_AUTOLINK.test(value);
10400
10445
  }
10401
- function peg$f54(value) {
10446
+ function peg$f61(value) {
10402
10447
  return lexeme("text", location(), { value });
10403
10448
  }
10404
- function peg$f55(value) {
10449
+ function peg$f62(value) {
10405
10450
  return lexeme("text", location(), { value });
10406
10451
  }
10407
- function peg$f56(tagStart, tag, list, slash) {
10452
+ function peg$f63(tagStart, tag, list, slash) {
10408
10453
  const lower = tag.toLowerCase();
10409
10454
  return lexeme("html", location(), {
10410
10455
  tag,
@@ -10417,7 +10462,7 @@ function peg$parse(input, options) {
10417
10462
  isSelfClose: !!slash || VOID_TAGS.has(lower)
10418
10463
  });
10419
10464
  }
10420
- function peg$f57(tag, bad) {
10465
+ function peg$f64(tag, bad) {
10421
10466
  const c = input.charAt(bad);
10422
10467
  if (!c) fail("Unclosed tag <" + tag + ": no > ends it (write &lt; for a < that starts no tag)", location(), "unclosed-tag");
10423
10468
  const at = {
@@ -10435,7 +10480,7 @@ function peg$parse(input, options) {
10435
10480
  };
10436
10481
  fail("Unexpected " + JSON.stringify(c) + " in the tag <" + tag + ">: expected an attribute, or > to end the tag", at, "unexpected-character");
10437
10482
  }
10438
- function peg$f58(tagStart, tag) {
10483
+ function peg$f65(tagStart, tag) {
10439
10484
  return lexeme("html", location(), {
10440
10485
  tag,
10441
10486
  lower: tag.toLowerCase(),
@@ -10447,14 +10492,14 @@ function peg$parse(input, options) {
10447
10492
  isSelfClose: false
10448
10493
  });
10449
10494
  }
10450
- function peg$f59(nameStart, name) {
10495
+ function peg$f66(nameStart, name) {
10451
10496
  attrCode = hooks.isCodeAttribute(name);
10452
10497
  return true;
10453
10498
  }
10454
- function peg$f60(nameStart, name, v) {
10499
+ function peg$f67(nameStart, name, v) {
10455
10500
  return v;
10456
10501
  }
10457
- function peg$f61(nameStart, name, value) {
10502
+ function peg$f68(nameStart, name, value) {
10458
10503
  const attribute = {
10459
10504
  name,
10460
10505
  value: value ? value.value : "",
@@ -10468,7 +10513,7 @@ function peg$parse(input, options) {
10468
10513
  }
10469
10514
  return attribute;
10470
10515
  }
10471
- function peg$f62(start, value, end) {
10516
+ function peg$f69(start, value, end) {
10472
10517
  return {
10473
10518
  value,
10474
10519
  start,
@@ -10476,7 +10521,7 @@ function peg$parse(input, options) {
10476
10521
  quote: "\""
10477
10522
  };
10478
10523
  }
10479
- function peg$f63(start, value, end) {
10524
+ function peg$f70(start, value, end) {
10480
10525
  return {
10481
10526
  value,
10482
10527
  start,
@@ -10484,36 +10529,36 @@ function peg$parse(input, options) {
10484
10529
  quote: "'"
10485
10530
  };
10486
10531
  }
10487
- function peg$f64(q) {
10532
+ function peg$f71(q) {
10488
10533
  fail("Unclosed attribute value: the " + q + " here has no closing " + q, location(), "unclosed-attribute");
10489
10534
  }
10490
- function peg$f65(start, value, end) {
10535
+ function peg$f72(start, value, end) {
10491
10536
  return {
10492
10537
  value,
10493
10538
  start,
10494
10539
  end
10495
10540
  };
10496
10541
  }
10497
- function peg$f66() {
10542
+ function peg$f73() {
10498
10543
  return !attrCode;
10499
10544
  }
10500
- function peg$f67(bs) {
10545
+ function peg$f74(bs) {
10501
10546
  return bs.length % 2 === 1;
10502
10547
  }
10503
- function peg$f68() {
10548
+ function peg$f75() {
10504
10549
  return !attrCode;
10505
10550
  }
10506
- function peg$f69(start, nameEnd) {
10551
+ function peg$f76(start, nameEnd) {
10507
10552
  const end = hooks.closeBrace(input, nameEnd, start);
10508
10553
  return skipTo(end < 0 && completionMode ? input.length : end);
10509
10554
  }
10510
- function peg$f70(start, nameEnd) {
10555
+ function peg$f77(start, nameEnd) {
10511
10556
  return skipEnd - offset();
10512
10557
  }
10513
- function peg$f71() {
10558
+ function peg$f78() {
10514
10559
  return !attrCode;
10515
10560
  }
10516
- function peg$f72() {
10561
+ function peg$f79() {
10517
10562
  return attrCode;
10518
10563
  }
10519
10564
  let peg$currPos = options.peg$currPos | 0;
@@ -11284,20 +11329,23 @@ function peg$parse(input, options) {
11284
11329
  s4 = peg$parseSelectors();
11285
11330
  if (s4 !== peg$FAILED) {
11286
11331
  s5 = peg$parseHere();
11287
- s6 = peg$currPos;
11288
- s7 = peg$parseLinkText();
11289
- s6 = input.substring(s6, peg$currPos);
11290
- if (input.substr(peg$currPos, 2) === peg$c9) {
11291
- s7 = peg$c9;
11292
- peg$currPos += 2;
11293
- } else {
11294
- s7 = peg$FAILED;
11295
- if (peg$silentFails === 0) peg$fail(peg$e13);
11296
- }
11297
- if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
11298
- if (s7 !== peg$FAILED) {
11299
- peg$savedPos = s0;
11300
- s0 = peg$f34(s3, s4, s5, s6);
11332
+ s6 = peg$parseLinkText();
11333
+ if (s6 !== peg$FAILED) {
11334
+ if (input.substr(peg$currPos, 2) === peg$c9) {
11335
+ s7 = peg$c9;
11336
+ peg$currPos += 2;
11337
+ } else {
11338
+ s7 = peg$FAILED;
11339
+ if (peg$silentFails === 0) peg$fail(peg$e13);
11340
+ }
11341
+ if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
11342
+ if (s7 !== peg$FAILED) {
11343
+ peg$savedPos = s0;
11344
+ s0 = peg$f34(s3, s4, s5, s6);
11345
+ } else {
11346
+ peg$currPos = s0;
11347
+ s0 = peg$FAILED;
11348
+ }
11301
11349
  } else {
11302
11350
  peg$currPos = s0;
11303
11351
  s0 = peg$FAILED;
@@ -11343,55 +11391,224 @@ function peg$parse(input, options) {
11343
11391
  return s0;
11344
11392
  }
11345
11393
  function peg$parseLinkText() {
11346
- let s0, s1, s2, s3;
11347
- s0 = [];
11348
- for (;;) {
11349
- s1 = peg$currPos;
11350
- s2 = peg$currPos;
11351
- peg$silentFails++;
11352
- if (input.substr(peg$currPos, 2) === peg$c9) {
11353
- s3 = peg$c9;
11354
- peg$currPos += 2;
11355
- } else {
11356
- s3 = peg$FAILED;
11357
- if (peg$silentFails === 0) peg$fail(peg$e13);
11358
- }
11359
- if (s3 === peg$FAILED) {
11360
- if (input.substr(peg$currPos, 2) === peg$c8) {
11361
- s3 = peg$c8;
11394
+ let s0, s1, s2, s3, s4, s5, s6;
11395
+ s0 = peg$currPos;
11396
+ s1 = peg$parseHere();
11397
+ peg$savedPos = peg$currPos;
11398
+ s2 = peg$f37(s1);
11399
+ if (s2) s2 = void 0;
11400
+ else s2 = peg$FAILED;
11401
+ if (s2 !== peg$FAILED) {
11402
+ s3 = [];
11403
+ for (;;) {
11404
+ s4 = peg$currPos;
11405
+ s5 = peg$currPos;
11406
+ peg$silentFails++;
11407
+ if (input.substr(peg$currPos, 2) === peg$c9) {
11408
+ s6 = peg$c9;
11362
11409
  peg$currPos += 2;
11363
11410
  } else {
11364
- s3 = peg$FAILED;
11365
- if (peg$silentFails === 0) peg$fail(peg$e12);
11411
+ s6 = peg$FAILED;
11412
+ if (peg$silentFails === 0) peg$fail(peg$e13);
11413
+ }
11414
+ if (s6 === peg$FAILED) {
11415
+ if (input.substr(peg$currPos, 2) === peg$c8) {
11416
+ s6 = peg$c8;
11417
+ peg$currPos += 2;
11418
+ } else {
11419
+ s6 = peg$FAILED;
11420
+ if (peg$silentFails === 0) peg$fail(peg$e12);
11421
+ }
11422
+ }
11423
+ peg$silentFails--;
11424
+ if (s6 === peg$FAILED) s5 = void 0;
11425
+ else {
11426
+ peg$currPos = s5;
11427
+ s5 = peg$FAILED;
11428
+ }
11429
+ if (s5 !== peg$FAILED) {
11430
+ s6 = peg$parseLinkLabelCode();
11431
+ if (s6 === peg$FAILED) {
11432
+ if (input.length > peg$currPos) {
11433
+ s6 = input.charAt(peg$currPos);
11434
+ peg$currPos++;
11435
+ } else {
11436
+ s6 = peg$FAILED;
11437
+ if (peg$silentFails === 0) peg$fail(peg$e0);
11438
+ }
11439
+ }
11440
+ if (s6 !== peg$FAILED) {
11441
+ peg$savedPos = s4;
11442
+ s4 = peg$f38(s1, s6);
11443
+ } else {
11444
+ peg$currPos = s4;
11445
+ s4 = peg$FAILED;
11446
+ }
11447
+ } else {
11448
+ peg$currPos = s4;
11449
+ s4 = peg$FAILED;
11366
11450
  }
11451
+ if (s4 === peg$FAILED) break;
11452
+ s3.push(s4);
11367
11453
  }
11368
- peg$silentFails--;
11369
- if (s3 === peg$FAILED) s2 = void 0;
11454
+ s4 = peg$parseHere();
11455
+ peg$savedPos = s0;
11456
+ s0 = peg$f39(s1, s3, s4);
11457
+ } else {
11458
+ peg$currPos = s0;
11459
+ s0 = peg$FAILED;
11460
+ }
11461
+ return s0;
11462
+ }
11463
+ function peg$parseLinkLabelCode() {
11464
+ let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
11465
+ s0 = peg$currPos;
11466
+ s1 = peg$parseHere();
11467
+ if (input.charCodeAt(peg$currPos) === 92) {
11468
+ s2 = peg$c4;
11469
+ peg$currPos++;
11470
+ } else {
11471
+ s2 = peg$FAILED;
11472
+ if (peg$silentFails === 0) peg$fail(peg$e6);
11473
+ }
11474
+ if (s2 !== peg$FAILED) {
11475
+ s3 = input.charAt(peg$currPos);
11476
+ if (peg$charCode = s3.charCodeAt(0), peg$charCode === 123 || peg$charCode === 125) peg$currPos++;
11370
11477
  else {
11371
- peg$currPos = s2;
11478
+ s3 = peg$FAILED;
11479
+ if (peg$silentFails === 0) peg$fail(peg$e7);
11480
+ }
11481
+ if (s3 !== peg$FAILED) {
11482
+ s4 = peg$parseHere();
11483
+ peg$savedPos = s0;
11484
+ s0 = peg$f40(s1, s4);
11485
+ } else {
11486
+ peg$currPos = s0;
11487
+ s0 = peg$FAILED;
11488
+ }
11489
+ } else {
11490
+ peg$currPos = s0;
11491
+ s0 = peg$FAILED;
11492
+ }
11493
+ if (s0 === peg$FAILED) {
11494
+ s0 = peg$currPos;
11495
+ s1 = peg$parseHere();
11496
+ if (input.charCodeAt(peg$currPos) === 123) {
11497
+ s2 = peg$c5;
11498
+ peg$currPos++;
11499
+ } else {
11372
11500
  s2 = peg$FAILED;
11501
+ if (peg$silentFails === 0) peg$fail(peg$e8);
11373
11502
  }
11374
11503
  if (s2 !== peg$FAILED) {
11375
- if (input.length > peg$currPos) {
11376
- s3 = input.charAt(peg$currPos);
11377
- peg$currPos++;
11378
- } else {
11379
- s3 = peg$FAILED;
11380
- if (peg$silentFails === 0) peg$fail(peg$e0);
11381
- }
11504
+ s3 = peg$parseSelectors();
11382
11505
  if (s3 !== peg$FAILED) {
11383
- s2 = [s2, s3];
11384
- s1 = s2;
11506
+ s4 = peg$parseHere();
11507
+ s5 = peg$currPos;
11508
+ if (input.charCodeAt(peg$currPos) === 47) {
11509
+ s6 = peg$c10;
11510
+ peg$currPos++;
11511
+ } else {
11512
+ s6 = peg$FAILED;
11513
+ if (peg$silentFails === 0) peg$fail(peg$e14);
11514
+ }
11515
+ if (s6 === peg$FAILED) s6 = null;
11516
+ s7 = peg$parseMacroName();
11517
+ if (s7 !== peg$FAILED) {
11518
+ s6 = [s6, s7];
11519
+ s5 = s6;
11520
+ } else {
11521
+ peg$currPos = s5;
11522
+ s5 = peg$FAILED;
11523
+ }
11524
+ if (s5 === peg$FAILED) {
11525
+ s5 = peg$currPos;
11526
+ peg$silentFails++;
11527
+ s6 = input.charAt(peg$currPos);
11528
+ if (peg$charCode = s6.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37 || peg$charCode === 40 || peg$charCode === 33) peg$currPos++;
11529
+ else {
11530
+ s6 = peg$FAILED;
11531
+ if (peg$silentFails === 0) peg$fail(peg$e15);
11532
+ }
11533
+ peg$silentFails--;
11534
+ if (s6 !== peg$FAILED) {
11535
+ peg$currPos = s5;
11536
+ s5 = void 0;
11537
+ } else s5 = peg$FAILED;
11538
+ }
11539
+ if (s5 !== peg$FAILED) {
11540
+ s6 = peg$parseHere();
11541
+ peg$savedPos = peg$currPos;
11542
+ s7 = peg$f41(s1, s4, s6);
11543
+ if (s7) s7 = void 0;
11544
+ else s7 = peg$FAILED;
11545
+ if (s7 !== peg$FAILED) {
11546
+ s8 = peg$currPos;
11547
+ s9 = peg$f42(s1, s4, s6);
11548
+ s10 = peg$currPos;
11549
+ s11 = [];
11550
+ if (s11.length >= (s9 | 0)) s12 = peg$FAILED;
11551
+ else if (input.length > peg$currPos) {
11552
+ s12 = input.charAt(peg$currPos);
11553
+ peg$currPos++;
11554
+ } else {
11555
+ s12 = peg$FAILED;
11556
+ if (peg$silentFails === 0) peg$fail(peg$e0);
11557
+ }
11558
+ while (s12 !== peg$FAILED) {
11559
+ s11.push(s12);
11560
+ if (s11.length >= (s9 | 0)) s12 = peg$FAILED;
11561
+ else if (input.length > peg$currPos) {
11562
+ s12 = input.charAt(peg$currPos);
11563
+ peg$currPos++;
11564
+ } else {
11565
+ s12 = peg$FAILED;
11566
+ if (peg$silentFails === 0) peg$fail(peg$e0);
11567
+ }
11568
+ }
11569
+ if (s11.length < (s9 | 0)) {
11570
+ peg$currPos = s10;
11571
+ s10 = peg$FAILED;
11572
+ } else s10 = s11;
11573
+ s9 = s10;
11574
+ if (s9 !== peg$FAILED) s8 = input.substring(s8, peg$currPos);
11575
+ else s8 = s9;
11576
+ if (s8 !== peg$FAILED) {
11577
+ if (input.charCodeAt(peg$currPos) === 125) {
11578
+ s9 = peg$c11;
11579
+ peg$currPos++;
11580
+ } else {
11581
+ s9 = peg$FAILED;
11582
+ if (peg$silentFails === 0) peg$fail(peg$e16);
11583
+ }
11584
+ if (s9 !== peg$FAILED) {
11585
+ s10 = peg$parseHere();
11586
+ peg$savedPos = s0;
11587
+ s0 = peg$f43(s1, s4, s6, s10);
11588
+ } else {
11589
+ peg$currPos = s0;
11590
+ s0 = peg$FAILED;
11591
+ }
11592
+ } else {
11593
+ peg$currPos = s0;
11594
+ s0 = peg$FAILED;
11595
+ }
11596
+ } else {
11597
+ peg$currPos = s0;
11598
+ s0 = peg$FAILED;
11599
+ }
11600
+ } else {
11601
+ peg$currPos = s0;
11602
+ s0 = peg$FAILED;
11603
+ }
11385
11604
  } else {
11386
- peg$currPos = s1;
11387
- s1 = peg$FAILED;
11605
+ peg$currPos = s0;
11606
+ s0 = peg$FAILED;
11388
11607
  }
11389
11608
  } else {
11390
- peg$currPos = s1;
11391
- s1 = peg$FAILED;
11609
+ peg$currPos = s0;
11610
+ s0 = peg$FAILED;
11392
11611
  }
11393
- if (s1 === peg$FAILED) break;
11394
- s0.push(s1);
11395
11612
  }
11396
11613
  return s0;
11397
11614
  }
@@ -11407,15 +11624,15 @@ function peg$parse(input, options) {
11407
11624
  if (s1.length < 1) s1 = peg$FAILED;
11408
11625
  if (s1 !== peg$FAILED) {
11409
11626
  if (input.charCodeAt(peg$currPos) === 32) {
11410
- s2 = peg$c10;
11627
+ s2 = peg$c12;
11411
11628
  peg$currPos++;
11412
11629
  } else {
11413
11630
  s2 = peg$FAILED;
11414
- if (peg$silentFails === 0) peg$fail(peg$e14);
11631
+ if (peg$silentFails === 0) peg$fail(peg$e17);
11415
11632
  }
11416
11633
  if (s2 === peg$FAILED) s2 = null;
11417
11634
  peg$savedPos = s0;
11418
- s0 = peg$f37(s1);
11635
+ s0 = peg$f44(s1);
11419
11636
  } else {
11420
11637
  peg$currPos = s0;
11421
11638
  s0 = peg$FAILED;
@@ -11424,7 +11641,7 @@ function peg$parse(input, options) {
11424
11641
  s0 = peg$currPos;
11425
11642
  s1 = "";
11426
11643
  peg$savedPos = s0;
11427
- s1 = peg$f38();
11644
+ s1 = peg$f45();
11428
11645
  s0 = s1;
11429
11646
  }
11430
11647
  return s0;
@@ -11448,7 +11665,7 @@ function peg$parse(input, options) {
11448
11665
  s3.push(s4);
11449
11666
  }
11450
11667
  peg$savedPos = s0;
11451
- s0 = peg$f39(s1, s2);
11668
+ s0 = peg$f46(s1, s2);
11452
11669
  } else {
11453
11670
  peg$currPos = s0;
11454
11671
  s0 = peg$FAILED;
@@ -11462,7 +11679,7 @@ function peg$parse(input, options) {
11462
11679
  if (peg$charCode = s1.charCodeAt(0), peg$charCode === 46 || peg$charCode === 35) peg$currPos++;
11463
11680
  else {
11464
11681
  s1 = peg$FAILED;
11465
- if (peg$silentFails === 0) peg$fail(peg$e15);
11682
+ if (peg$silentFails === 0) peg$fail(peg$e18);
11466
11683
  }
11467
11684
  if (s1 !== peg$FAILED) {
11468
11685
  s2 = peg$currPos;
@@ -11474,7 +11691,7 @@ function peg$parse(input, options) {
11474
11691
  }
11475
11692
  s2 = input.substring(s2, peg$currPos);
11476
11693
  peg$savedPos = s0;
11477
- s0 = peg$f40(s1, s2);
11694
+ s0 = peg$f47(s1, s2);
11478
11695
  } else {
11479
11696
  peg$currPos = s0;
11480
11697
  s0 = peg$FAILED;
@@ -11487,7 +11704,7 @@ function peg$parse(input, options) {
11487
11704
  if (peg$charCode = s0.charCodeAt(0), peg$charCode >= 97 && peg$charCode <= 122 || peg$charCode >= 65 && peg$charCode <= 90 || peg$charCode >= 48 && peg$charCode <= 57 || peg$charCode === 95 || peg$charCode === 45) peg$currPos++;
11488
11705
  else {
11489
11706
  s0 = peg$FAILED;
11490
- if (peg$silentFails === 0) peg$fail(peg$e16);
11707
+ if (peg$silentFails === 0) peg$fail(peg$e19);
11491
11708
  }
11492
11709
  if (s0 === peg$FAILED) {
11493
11710
  s0 = peg$currPos;
@@ -11503,7 +11720,7 @@ function peg$parse(input, options) {
11503
11720
  if (peg$charCode = s2.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37) peg$currPos++;
11504
11721
  else {
11505
11722
  s2 = peg$FAILED;
11506
- if (peg$silentFails === 0) peg$fail(peg$e17);
11723
+ if (peg$silentFails === 0) peg$fail(peg$e20);
11507
11724
  }
11508
11725
  if (s2 !== peg$FAILED) {
11509
11726
  s3 = [];
@@ -11512,7 +11729,7 @@ function peg$parse(input, options) {
11512
11729
  if (peg$charCode = s4.charCodeAt(0), peg$charCode >= 97 && peg$charCode <= 122 || peg$charCode >= 65 && peg$charCode <= 90 || peg$charCode >= 48 && peg$charCode <= 57 || peg$charCode === 95 || peg$charCode === 46) peg$currPos++;
11513
11730
  else {
11514
11731
  s4 = peg$FAILED;
11515
- if (peg$silentFails === 0) peg$fail(peg$e18);
11732
+ if (peg$silentFails === 0) peg$fail(peg$e21);
11516
11733
  }
11517
11734
  if (s4 === peg$FAILED) break;
11518
11735
  s3.push(s4);
@@ -11522,7 +11739,7 @@ function peg$parse(input, options) {
11522
11739
  peg$currPos++;
11523
11740
  } else {
11524
11741
  s4 = peg$FAILED;
11525
- if (peg$silentFails === 0) peg$fail(peg$e19);
11742
+ if (peg$silentFails === 0) peg$fail(peg$e16);
11526
11743
  }
11527
11744
  if (s4 !== peg$FAILED) {
11528
11745
  s1 = [
@@ -11565,7 +11782,7 @@ function peg$parse(input, options) {
11565
11782
  if (peg$charCode = s4.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37) peg$currPos++;
11566
11783
  else {
11567
11784
  s4 = peg$FAILED;
11568
- if (peg$silentFails === 0) peg$fail(peg$e17);
11785
+ if (peg$silentFails === 0) peg$fail(peg$e20);
11569
11786
  }
11570
11787
  if (s4 !== peg$FAILED) {
11571
11788
  s5 = peg$parseHere();
@@ -11576,7 +11793,7 @@ function peg$parse(input, options) {
11576
11793
  if (peg$charCode = s8.charCodeAt(0), peg$charCode >= 97 && peg$charCode <= 122 || peg$charCode >= 65 && peg$charCode <= 90 || peg$charCode >= 48 && peg$charCode <= 57 || peg$charCode === 95 || peg$charCode === 46) peg$currPos++;
11577
11794
  else {
11578
11795
  s8 = peg$FAILED;
11579
- if (peg$silentFails === 0) peg$fail(peg$e18);
11796
+ if (peg$silentFails === 0) peg$fail(peg$e21);
11580
11797
  }
11581
11798
  if (s8 === peg$FAILED) break;
11582
11799
  s7.push(s8);
@@ -11585,7 +11802,7 @@ function peg$parse(input, options) {
11585
11802
  s7 = peg$parseBraceEnd();
11586
11803
  if (s7 !== peg$FAILED) {
11587
11804
  peg$savedPos = s0;
11588
- s0 = peg$f41(s2, s3, s4, s5, s6);
11805
+ s0 = peg$f48(s2, s3, s4, s5, s6);
11589
11806
  } else {
11590
11807
  peg$currPos = s0;
11591
11808
  s0 = peg$FAILED;
@@ -11622,7 +11839,7 @@ function peg$parse(input, options) {
11622
11839
  if (peg$charCode = s6.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37 || peg$charCode === 40 || peg$charCode === 33) peg$currPos++;
11623
11840
  else {
11624
11841
  s6 = peg$FAILED;
11625
- if (peg$silentFails === 0) peg$fail(peg$e20);
11842
+ if (peg$silentFails === 0) peg$fail(peg$e15);
11626
11843
  }
11627
11844
  peg$silentFails--;
11628
11845
  if (s6 !== peg$FAILED) {
@@ -11635,7 +11852,7 @@ function peg$parse(input, options) {
11635
11852
  s7 = peg$parseBraceEnd();
11636
11853
  if (s7 !== peg$FAILED) {
11637
11854
  peg$savedPos = s0;
11638
- s0 = peg$f42(s2, s3, s4, s6);
11855
+ s0 = peg$f49(s2, s3, s4, s6);
11639
11856
  } else {
11640
11857
  peg$currPos = s0;
11641
11858
  s0 = peg$FAILED;
@@ -11674,7 +11891,7 @@ function peg$parse(input, options) {
11674
11891
  if (peg$charCode = s4.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37 || peg$charCode === 40 || peg$charCode === 33) peg$currPos++;
11675
11892
  else {
11676
11893
  s4 = peg$FAILED;
11677
- if (peg$silentFails === 0) peg$fail(peg$e20);
11894
+ if (peg$silentFails === 0) peg$fail(peg$e15);
11678
11895
  }
11679
11896
  peg$silentFails--;
11680
11897
  if (s4 !== peg$FAILED) {
@@ -11683,7 +11900,7 @@ function peg$parse(input, options) {
11683
11900
  } else s3 = peg$FAILED;
11684
11901
  if (s3 !== peg$FAILED) {
11685
11902
  peg$savedPos = s0;
11686
- s0 = peg$f43();
11903
+ s0 = peg$f50();
11687
11904
  } else {
11688
11905
  peg$currPos = s0;
11689
11906
  s0 = peg$FAILED;
@@ -11705,12 +11922,12 @@ function peg$parse(input, options) {
11705
11922
  s0 = peg$currPos;
11706
11923
  s1 = peg$parseHere();
11707
11924
  peg$savedPos = peg$currPos;
11708
- s2 = peg$f44(s1);
11925
+ s2 = peg$f51(s1);
11709
11926
  if (s2) s2 = void 0;
11710
11927
  else s2 = peg$FAILED;
11711
11928
  if (s2 !== peg$FAILED) {
11712
11929
  s3 = peg$currPos;
11713
- s4 = peg$f45(s1);
11930
+ s4 = peg$f52(s1);
11714
11931
  s5 = peg$currPos;
11715
11932
  s6 = [];
11716
11933
  if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
@@ -11741,7 +11958,7 @@ function peg$parse(input, options) {
11741
11958
  else s3 = s4;
11742
11959
  if (s3 !== peg$FAILED) {
11743
11960
  peg$savedPos = s0;
11744
- s0 = peg$f46(s1, s3);
11961
+ s0 = peg$f53(s1, s3);
11745
11962
  } else {
11746
11963
  peg$currPos = s0;
11747
11964
  s0 = peg$FAILED;
@@ -11756,7 +11973,7 @@ function peg$parse(input, options) {
11756
11973
  let s0, s1, s2, s3;
11757
11974
  s0 = peg$currPos;
11758
11975
  peg$savedPos = peg$currPos;
11759
- s1 = peg$f47();
11976
+ s1 = peg$f54();
11760
11977
  if (s1) s1 = void 0;
11761
11978
  else s1 = peg$FAILED;
11762
11979
  if (s1 !== peg$FAILED) {
@@ -11795,7 +12012,7 @@ function peg$parse(input, options) {
11795
12012
  peg$currPos++;
11796
12013
  } else {
11797
12014
  s0 = peg$FAILED;
11798
- if (peg$silentFails === 0) peg$fail(peg$e19);
12015
+ if (peg$silentFails === 0) peg$fail(peg$e16);
11799
12016
  }
11800
12017
  if (s0 === peg$FAILED) s0 = peg$parseOpenEnd();
11801
12018
  return s0;
@@ -11816,11 +12033,11 @@ function peg$parse(input, options) {
11816
12033
  if (s3 !== peg$FAILED) {
11817
12034
  s4 = peg$parseHere();
11818
12035
  if (input.charCodeAt(peg$currPos) === 47) {
11819
- s5 = peg$c12;
12036
+ s5 = peg$c10;
11820
12037
  peg$currPos++;
11821
12038
  } else {
11822
12039
  s5 = peg$FAILED;
11823
- if (peg$silentFails === 0) peg$fail(peg$e21);
12040
+ if (peg$silentFails === 0) peg$fail(peg$e14);
11824
12041
  }
11825
12042
  if (s5 === peg$FAILED) s5 = null;
11826
12043
  s6 = peg$parseMacroName();
@@ -11828,12 +12045,12 @@ function peg$parse(input, options) {
11828
12045
  s7 = peg$parseHere();
11829
12046
  s8 = peg$currPos;
11830
12047
  peg$savedPos = peg$currPos;
11831
- s9 = peg$f48(s2, s3, s4, s5, s6, s7);
12048
+ s9 = peg$f55(s2, s3, s4, s5, s6, s7);
11832
12049
  if (s9) s9 = void 0;
11833
12050
  else s9 = peg$FAILED;
11834
12051
  if (s9 !== peg$FAILED) {
11835
12052
  s10 = peg$currPos;
11836
- s11 = peg$f49(s2, s3, s4, s5, s6, s7);
12053
+ s11 = peg$f56(s2, s3, s4, s5, s6, s7);
11837
12054
  s12 = peg$currPos;
11838
12055
  s13 = [];
11839
12056
  if (s13.length >= (s11 | 0)) s14 = peg$FAILED;
@@ -11866,7 +12083,7 @@ function peg$parse(input, options) {
11866
12083
  s11 = peg$parseBraceEnd();
11867
12084
  if (s11 !== peg$FAILED) {
11868
12085
  peg$savedPos = s8;
11869
- s8 = peg$f50(s2, s3, s4, s5, s6, s7, s10);
12086
+ s8 = peg$f57(s2, s3, s4, s5, s6, s7, s10);
11870
12087
  } else {
11871
12088
  peg$currPos = s8;
11872
12089
  s8 = peg$FAILED;
@@ -11881,7 +12098,7 @@ function peg$parse(input, options) {
11881
12098
  }
11882
12099
  if (s8 === peg$FAILED) s8 = null;
11883
12100
  peg$savedPos = s0;
11884
- s0 = peg$f51(s2, s3, s4, s5, s6, s7, s8);
12101
+ s0 = peg$f58(s2, s3, s4, s5, s6, s7, s8);
11885
12102
  } else {
11886
12103
  peg$currPos = s0;
11887
12104
  s0 = peg$FAILED;
@@ -11907,15 +12124,15 @@ function peg$parse(input, options) {
11907
12124
  s2 = peg$parseSelectors();
11908
12125
  if (s2 !== peg$FAILED) {
11909
12126
  if (input.charCodeAt(peg$currPos) === 47) {
11910
- s3 = peg$c12;
12127
+ s3 = peg$c10;
11911
12128
  peg$currPos++;
11912
12129
  } else {
11913
12130
  s3 = peg$FAILED;
11914
- if (peg$silentFails === 0) peg$fail(peg$e21);
12131
+ if (peg$silentFails === 0) peg$fail(peg$e14);
11915
12132
  }
11916
12133
  if (s3 !== peg$FAILED) {
11917
12134
  peg$savedPos = s0;
11918
- s0 = peg$f52(s2);
12135
+ s0 = peg$f59(s2);
11919
12136
  } else {
11920
12137
  peg$currPos = s0;
11921
12138
  s0 = peg$FAILED;
@@ -12050,12 +12267,12 @@ function peg$parse(input, options) {
12050
12267
  else s1 = s2;
12051
12268
  if (s1 !== peg$FAILED) {
12052
12269
  peg$savedPos = peg$currPos;
12053
- s2 = peg$f53(s1);
12270
+ s2 = peg$f60(s1);
12054
12271
  if (s2) s2 = void 0;
12055
12272
  else s2 = peg$FAILED;
12056
12273
  if (s2 !== peg$FAILED) {
12057
12274
  peg$savedPos = s0;
12058
- s0 = peg$f54(s1);
12275
+ s0 = peg$f61(s1);
12059
12276
  } else {
12060
12277
  peg$currPos = s0;
12061
12278
  s0 = peg$FAILED;
@@ -12199,7 +12416,7 @@ function peg$parse(input, options) {
12199
12416
  else s1 = s2;
12200
12417
  if (s1 !== peg$FAILED) {
12201
12418
  peg$savedPos = s0;
12202
- s1 = peg$f55(s1);
12419
+ s1 = peg$f62(s1);
12203
12420
  }
12204
12421
  s0 = s1;
12205
12422
  return s0;
@@ -12226,11 +12443,11 @@ function peg$parse(input, options) {
12226
12443
  }
12227
12444
  s5 = peg$parse_();
12228
12445
  if (input.charCodeAt(peg$currPos) === 47) {
12229
- s6 = peg$c12;
12446
+ s6 = peg$c10;
12230
12447
  peg$currPos++;
12231
12448
  } else {
12232
12449
  s6 = peg$FAILED;
12233
- if (peg$silentFails === 0) peg$fail(peg$e21);
12450
+ if (peg$silentFails === 0) peg$fail(peg$e14);
12234
12451
  }
12235
12452
  if (s6 === peg$FAILED) s6 = null;
12236
12453
  if (input.charCodeAt(peg$currPos) === 62) {
@@ -12243,7 +12460,7 @@ function peg$parse(input, options) {
12243
12460
  if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
12244
12461
  if (s7 !== peg$FAILED) {
12245
12462
  peg$savedPos = s0;
12246
- s0 = peg$f56(s2, s3, s4, s6);
12463
+ s0 = peg$f63(s2, s3, s4, s6);
12247
12464
  } else {
12248
12465
  peg$currPos = s0;
12249
12466
  s0 = peg$FAILED;
@@ -12308,7 +12525,7 @@ function peg$parse(input, options) {
12308
12525
  s5 = peg$parse_();
12309
12526
  s6 = peg$parseHere();
12310
12527
  peg$savedPos = s0;
12311
- s0 = peg$f57(s2, s6);
12528
+ s0 = peg$f64(s2, s6);
12312
12529
  } else {
12313
12530
  peg$currPos = s0;
12314
12531
  s0 = peg$FAILED;
@@ -12348,7 +12565,7 @@ function peg$parse(input, options) {
12348
12565
  }
12349
12566
  if (s5 !== peg$FAILED) {
12350
12567
  peg$savedPos = s0;
12351
- s0 = peg$f58(s2, s3);
12568
+ s0 = peg$f65(s2, s3);
12352
12569
  } else {
12353
12570
  peg$currPos = s0;
12354
12571
  s0 = peg$FAILED;
@@ -12445,7 +12662,7 @@ function peg$parse(input, options) {
12445
12662
  else s3 = s4;
12446
12663
  if (s3 !== peg$FAILED) {
12447
12664
  peg$savedPos = peg$currPos;
12448
- s4 = peg$f59(s2, s3);
12665
+ s4 = peg$f66(s2, s3);
12449
12666
  if (s4) s4 = void 0;
12450
12667
  else s4 = peg$FAILED;
12451
12668
  if (s4 !== peg$FAILED) {
@@ -12463,7 +12680,7 @@ function peg$parse(input, options) {
12463
12680
  s9 = peg$parseAttrValue();
12464
12681
  if (s9 !== peg$FAILED) {
12465
12682
  peg$savedPos = s5;
12466
- s5 = peg$f60(s2, s3, s9);
12683
+ s5 = peg$f67(s2, s3, s9);
12467
12684
  } else {
12468
12685
  peg$currPos = s5;
12469
12686
  s5 = peg$FAILED;
@@ -12474,7 +12691,7 @@ function peg$parse(input, options) {
12474
12691
  }
12475
12692
  if (s5 === peg$FAILED) s5 = null;
12476
12693
  peg$savedPos = s0;
12477
- s0 = peg$f61(s2, s3, s5);
12694
+ s0 = peg$f68(s2, s3, s5);
12478
12695
  } else {
12479
12696
  peg$currPos = s0;
12480
12697
  s0 = peg$FAILED;
@@ -12524,7 +12741,7 @@ function peg$parse(input, options) {
12524
12741
  if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
12525
12742
  if (s5 !== peg$FAILED) {
12526
12743
  peg$savedPos = s0;
12527
- s0 = peg$f62(s2, s3, s4);
12744
+ s0 = peg$f69(s2, s3, s4);
12528
12745
  } else {
12529
12746
  peg$currPos = s0;
12530
12747
  s0 = peg$FAILED;
@@ -12571,7 +12788,7 @@ function peg$parse(input, options) {
12571
12788
  if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
12572
12789
  if (s5 !== peg$FAILED) {
12573
12790
  peg$savedPos = s0;
12574
- s0 = peg$f63(s2, s3, s4);
12791
+ s0 = peg$f70(s2, s3, s4);
12575
12792
  } else {
12576
12793
  peg$currPos = s0;
12577
12794
  s0 = peg$FAILED;
@@ -12590,7 +12807,7 @@ function peg$parse(input, options) {
12590
12807
  }
12591
12808
  if (s1 !== peg$FAILED) {
12592
12809
  peg$savedPos = s0;
12593
- s1 = peg$f64(s1);
12810
+ s1 = peg$f71(s1);
12594
12811
  }
12595
12812
  s0 = s1;
12596
12813
  if (s0 === peg$FAILED) {
@@ -12611,7 +12828,7 @@ function peg$parse(input, options) {
12611
12828
  s2 = input.substring(s2, peg$currPos);
12612
12829
  s3 = peg$parseHere();
12613
12830
  peg$savedPos = s0;
12614
- s0 = peg$f65(s1, s2, s3);
12831
+ s0 = peg$f72(s1, s2, s3);
12615
12832
  }
12616
12833
  }
12617
12834
  }
@@ -12621,7 +12838,7 @@ function peg$parse(input, options) {
12621
12838
  let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
12622
12839
  s0 = peg$currPos;
12623
12840
  peg$savedPos = peg$currPos;
12624
- s1 = peg$f66();
12841
+ s1 = peg$f73();
12625
12842
  if (s1) s1 = void 0;
12626
12843
  else s1 = peg$FAILED;
12627
12844
  if (s1 !== peg$FAILED) {
@@ -12644,7 +12861,7 @@ function peg$parse(input, options) {
12644
12861
  if (s2 !== peg$FAILED) {
12645
12862
  s3 = peg$currPos;
12646
12863
  peg$savedPos = peg$currPos;
12647
- s4 = peg$f67(s2);
12864
+ s4 = peg$f74(s2);
12648
12865
  if (s4) s4 = void 0;
12649
12866
  else s4 = peg$FAILED;
12650
12867
  if (s4 !== peg$FAILED) {
@@ -12683,7 +12900,7 @@ function peg$parse(input, options) {
12683
12900
  if (s0 === peg$FAILED) {
12684
12901
  s0 = peg$currPos;
12685
12902
  peg$savedPos = peg$currPos;
12686
- s1 = peg$f68();
12903
+ s1 = peg$f75();
12687
12904
  if (s1) s1 = void 0;
12688
12905
  else s1 = peg$FAILED;
12689
12906
  if (s1 !== peg$FAILED) {
@@ -12699,23 +12916,23 @@ function peg$parse(input, options) {
12699
12916
  if (s3 !== peg$FAILED) {
12700
12917
  s4 = peg$parseHere();
12701
12918
  if (input.charCodeAt(peg$currPos) === 47) {
12702
- s5 = peg$c12;
12919
+ s5 = peg$c10;
12703
12920
  peg$currPos++;
12704
12921
  } else {
12705
12922
  s5 = peg$FAILED;
12706
- if (peg$silentFails === 0) peg$fail(peg$e21);
12923
+ if (peg$silentFails === 0) peg$fail(peg$e14);
12707
12924
  }
12708
12925
  if (s5 === peg$FAILED) s5 = null;
12709
12926
  s6 = peg$parseMacroName();
12710
12927
  if (s6 !== peg$FAILED) {
12711
12928
  s7 = peg$parseHere();
12712
12929
  peg$savedPos = peg$currPos;
12713
- s8 = peg$f69(s4, s7);
12930
+ s8 = peg$f76(s4, s7);
12714
12931
  if (s8) s8 = void 0;
12715
12932
  else s8 = peg$FAILED;
12716
12933
  if (s8 !== peg$FAILED) {
12717
12934
  s9 = peg$currPos;
12718
- s10 = peg$f70(s4, s7);
12935
+ s10 = peg$f77(s4, s7);
12719
12936
  s11 = peg$currPos;
12720
12937
  s12 = [];
12721
12938
  if (s12.length >= (s10 | 0)) s13 = peg$FAILED;
@@ -12791,7 +13008,7 @@ function peg$parse(input, options) {
12791
13008
  if (s0 === peg$FAILED) {
12792
13009
  s0 = peg$currPos;
12793
13010
  peg$savedPos = peg$currPos;
12794
- s1 = peg$f71();
13011
+ s1 = peg$f78();
12795
13012
  if (s1) s1 = void 0;
12796
13013
  else s1 = peg$FAILED;
12797
13014
  if (s1 !== peg$FAILED) {
@@ -12809,11 +13026,11 @@ function peg$parse(input, options) {
12809
13026
  peg$silentFails++;
12810
13027
  s5 = peg$currPos;
12811
13028
  if (input.charCodeAt(peg$currPos) === 47) {
12812
- s6 = peg$c12;
13029
+ s6 = peg$c10;
12813
13030
  peg$currPos++;
12814
13031
  } else {
12815
13032
  s6 = peg$FAILED;
12816
- if (peg$silentFails === 0) peg$fail(peg$e21);
13033
+ if (peg$silentFails === 0) peg$fail(peg$e14);
12817
13034
  }
12818
13035
  if (s6 === peg$FAILED) s6 = null;
12819
13036
  s7 = input.charAt(peg$currPos);
@@ -12876,7 +13093,7 @@ function peg$parse(input, options) {
12876
13093
  if (s0 === peg$FAILED) {
12877
13094
  s0 = peg$currPos;
12878
13095
  peg$savedPos = peg$currPos;
12879
- s1 = peg$f72();
13096
+ s1 = peg$f79();
12880
13097
  if (s1) s1 = void 0;
12881
13098
  else s1 = peg$FAILED;
12882
13099
  if (s1 !== peg$FAILED) {
@@ -12894,7 +13111,7 @@ function peg$parse(input, options) {
12894
13111
  if (peg$charCode = s4.charCodeAt(0), peg$charCode === 36 || peg$charCode === 95 || peg$charCode === 64 || peg$charCode === 37) peg$currPos++;
12895
13112
  else {
12896
13113
  s4 = peg$FAILED;
12897
- if (peg$silentFails === 0) peg$fail(peg$e17);
13114
+ if (peg$silentFails === 0) peg$fail(peg$e20);
12898
13115
  }
12899
13116
  peg$silentFails--;
12900
13117
  if (s4 !== peg$FAILED) {
@@ -12971,22 +13188,17 @@ function peg$parse(input, options) {
12971
13188
  let rawName = "";
12972
13189
  /** The HTML text-only body being read; its own closer ends this context. */
12973
13190
  let htmlTextTag = "";
13191
+ /** First bracket boundary of the current (non-nesting) link label. */
13192
+ let linkTextEnd = -1;
12974
13193
  /**
12975
13194
  * The index in `inner` (at `at` in the input) of the first `separator` that
12976
13195
  * is not inside a {…} of the label: its code (`{if $a || $b}`, a string with
12977
13196
  * a pipe) belongs to the label, not to the link's syntax.
12978
13197
  */
12979
- function linkSeparatorIndex(inner, at, separator) {
12980
- for (let i = 0; i < inner.length; i++) {
12981
- const c = inner.charAt(i);
12982
- if (c === "\\" && /[{}]/.test(inner.charAt(i + 1))) i++;
12983
- else if (c === LB) {
12984
- const head = /^(?:[.#][\w-]*)* ?(\/?[a-zA-Z][\w-]*|(?=[$_@%(!]))/.exec(inner.slice(i + 1));
12985
- if (!head) continue;
12986
- const close = hooks.closeBrace(input, at + i + 1 + head[0].length, at + i + 1);
12987
- if (close !== -1 && close < at + inner.length) i = close - at;
12988
- } else if (inner.startsWith(separator, i)) return i;
12989
- }
13198
+ function linkSeparatorIndex(inner, at, separator, spans) {
13199
+ let span = 0;
13200
+ for (let i = 0; i < inner.length; i++) if (span < spans.length && i === spans[span].start - at) i = spans[span++].end - at - 1;
13201
+ else if (inner.startsWith(separator, i)) return i;
12990
13202
  return -1;
12991
13203
  }
12992
13204
  /**
@@ -15648,6 +15860,18 @@ var PendingIterationContext = createContext(null);
15648
15860
  */
15649
15861
  var OutgoingContext = createContext(null);
15650
15862
  /**
15863
+ * Tells the macros that run code as they mount ({set}, {do}, {unset},
15864
+ * {goto}, {computed}, the count of an {include}) whether they come too late: the
15865
+ * passage they belong to was on the page and has been left since. State
15866
+ * that changed before the navigation can still render new content into the
15867
+ * passage on its way out, and its code would run against the destination's
15868
+ * state (#352, as #410 for timers). The macros that mount while the passage
15869
+ * is first rendered are never late, whatever that render navigates. Null
15870
+ * outside a displayed passage, and in a click body, which renders apart
15871
+ * from the passage and runs as part of the click.
15872
+ */
15873
+ var LateMountContext = createContext(null);
15874
+ /**
15651
15875
  * Story state fields `keys`, re-rendering when any of them changes (as one
15652
15876
  * useStoryStore() selector per field would). The result keeps its identity
15653
15877
  * while the fields don't change, as the store's snapshot must.
@@ -16120,14 +16344,17 @@ function logMacroError(label, error, location = currentSourceLocation()) {
16120
16344
  console.error(`spindle: Error in {${label}}${location}:`, error);
16121
16345
  }
16122
16346
  /**
16123
- * Run `effect` once, during the macro's first render. If it throws, the
16347
+ * Run `effect` once, during the macro's first render, unless that is in a
16348
+ * passage already left (see LateMountContext). If it throws, the
16124
16349
  * error is logged under `{macro rawArgs}` and shown in place of the macro
16125
16350
  * from then on; otherwise the macro renders nothing.
16126
16351
  */
16127
16352
  function useRunOnce(macro, rawArgs, effect) {
16128
16353
  const failure = useRef(void 0);
16354
+ const lateMount = useContext(LateMountContext);
16129
16355
  if (failure.current === void 0) {
16130
16356
  failure.current = null;
16357
+ if (lateMount?.()) return null;
16131
16358
  const location = currentSourceLocation();
16132
16359
  try {
16133
16360
  effect();
@@ -21854,25 +22081,29 @@ function formatValue(value) {
21854
22081
  }
21855
22082
  }
21856
22083
  }
21857
- /** What a control with an action shows: its type, variable and value. */
22084
+ function selectedLabels(el) {
22085
+ const labels = Array.from(el.options).filter((option) => option.selected).map((option) => option.getAttribute("label") || (option.textContent ?? "").trim().replace(/\s+/g, " "));
22086
+ return el.multiple ? labels : labels[0] ?? "";
22087
+ }
22088
+ /** What a control shows: its type, optional action variable and live value. */
21858
22089
  function controlMarker(el) {
21859
22090
  const own = el;
21860
22091
  const action = getAction(el.getAttribute("data-action") ?? "");
21861
- const type = action?.type ?? el.getAttribute("type") ?? el.localName;
22092
+ const type = action?.type ?? el.getAttribute("type")?.toLowerCase() ?? el.localName;
21862
22093
  const isCheckbox = type === "checkbox";
21863
- const value = action?.value !== void 0 ? action.value : isCheckbox ? !!own.checked : own.value ?? "";
22094
+ const value = action?.value !== void 0 ? action.value : isCheckbox ? !!own.checked : el.localName === "select" && !el.hasAttribute("data-action") ? selectedLabels(el) : own.value ?? "";
21864
22095
  const shown = isCheckbox ? value ? "checked" : "unchecked" : formatValue(value);
21865
22096
  const variable = action?.variable;
21866
22097
  const name = variable && !variable.startsWith("$") ? `$${variable}` : variable;
21867
- if (type === "radiobutton" && own.value !== void 0) {
21868
- const state = action?.value === own.value ? "selected" : "unselected";
22098
+ if ((type === "radiobutton" || type === "radio") && own.value !== void 0) {
22099
+ const state = (action?.value !== void 0 ? action.value === own.value : !!own.checked) ? "selected" : "unselected";
21869
22100
  return `[${type}${name ? ` ${name}` : ""} = ${formatValue(own.value)}: ${state}]`;
21870
22101
  }
21871
22102
  return `[${type}${name ? ` ${name}` : ""}: ${shown}]`;
21872
22103
  }
21873
22104
  /**
21874
22105
  * The text a reader sees in the element, as lines: blocks and `<br>` break
21875
- * lines, hidden elements are left out, and a control with a `data-action`
22106
+ * lines, hidden elements are left out, and a native or action-associated control
21876
22107
  * becomes a marker such as `[textbox $name: "Alice"]`. Elements inside `el`
21877
22108
  * that match `skip` are left out with their content. `visibilityRoot` bounds
21878
22109
  * ancestor checks when reading StoryContext inside its hidden host.
@@ -21897,7 +22128,8 @@ function observableText(el, skip, visibilityRoot) {
21897
22128
  if (node.nodeType !== 1) return;
21898
22129
  const child = node;
21899
22130
  if (isHidden(child) || skip && child !== el && child.matches(skip)) return;
21900
- if (child.hasAttribute("data-action") && (child.matches("input, textarea, select") || getAction(child.getAttribute("data-action"))?.type === "cycle")) {
22131
+ if (child.matches("input, textarea, select") || child.hasAttribute("data-action") && getAction(child.getAttribute("data-action"))?.type === "cycle") {
22132
+ if (child.matches("input[type=\"hidden\" i]")) return;
21901
22133
  if (!isRendered(child, visibilityRoot)) return;
21902
22134
  out += controlMarker(child);
21903
22135
  return;
@@ -23766,27 +23998,36 @@ function Passage({ passage, dataTransition, navigationId }) {
23766
23998
  else emit();
23767
23999
  }
23768
24000
  }, [passage.name, navigationId]);
24001
+ const hasLeft = useContext(OutgoingContext);
24002
+ const committed = useRef(false);
24003
+ useLayoutEffect(() => {
24004
+ committed.current = true;
24005
+ }, []);
24006
+ const lateMount = useCallback(() => committed.current && !!hasLeft?.(), [hasLeft]);
23769
24007
  const nobr = passage.tags.includes("nobr");
23770
24008
  const viewScope = useViewScope();
23771
24009
  const inner = /* @__PURE__ */ jsx(InterfaceContext.Provider, {
23772
24010
  value: false,
23773
24011
  children: /* @__PURE__ */ jsx(ViewScopeContext.Provider, {
23774
24012
  value: viewScope,
23775
- children: /* @__PURE__ */ jsxs("div", {
23776
- ref: elRef,
23777
- class: "passage",
23778
- "data-passage": passage.name,
23779
- "data-tags": passage.tags.join(" "),
23780
- "data-transition": dataTransition,
23781
- children: [
23782
- specialPassage("PassageHeader", "header"),
23783
- /* @__PURE__ */ jsx(PassageBody, {
23784
- passage,
23785
- content: passage.content
23786
- }),
23787
- specialPassage("PassageFooter", "footer"),
23788
- doneReady && specialPassage("PassageDone", "done")
23789
- ]
24013
+ children: /* @__PURE__ */ jsx(LateMountContext.Provider, {
24014
+ value: lateMount,
24015
+ children: /* @__PURE__ */ jsxs("div", {
24016
+ ref: elRef,
24017
+ class: "passage",
24018
+ "data-passage": passage.name,
24019
+ "data-tags": passage.tags.join(" "),
24020
+ "data-transition": dataTransition,
24021
+ children: [
24022
+ specialPassage("PassageHeader", "header"),
24023
+ /* @__PURE__ */ jsx(PassageBody, {
24024
+ passage,
24025
+ content: passage.content
24026
+ }),
24027
+ specialPassage("PassageFooter", "footer"),
24028
+ doneReady && specialPassage("PassageDone", "done")
24029
+ ]
24030
+ })
23790
24031
  })
23791
24032
  })
23792
24033
  });
@@ -23991,6 +24232,16 @@ function snapshotUrls(value, ids, base) {
23991
24232
  * definitions would replace that inheritance (and resolve currentColor).
23992
24233
  */
23993
24234
  var snapshotSvgRules = /* @__PURE__ */ new WeakSet();
24235
+ /** Keep only snapshot aliases, retaining their media/layer/nesting context. */
24236
+ function snapshotRuleText(rules) {
24237
+ const text = [];
24238
+ for (const rule of rules) if (snapshotSvgRules.has(rule)) text.push(rule.cssText);
24239
+ else if ("cssRules" in rule && !(rule instanceof CSSKeyframesRule)) {
24240
+ const body = snapshotRuleText(rule.cssRules);
24241
+ if (body) text.push(`${rule.cssText.slice(0, rule.cssText.indexOf("{"))}{${body}}`);
24242
+ }
24243
+ return text.join("\n");
24244
+ }
23994
24245
  /** A detached style element has no sheet yet. Carry its CSSOM, including
23995
24246
  * script-inserted rules and imported styles, into the passive tree.
23996
24247
  */
@@ -24119,11 +24370,15 @@ var snapshotPseudoId = 0;
24119
24370
  * as ordinary native elements, without an `is` option (even if the original
24120
24371
  * has since removed its `is` attribute).
24121
24372
  */
24122
- function cloneSnapshotTree(source, ids, pseudoRules = [], svgMarker = String(++snapshotPseudoId), cleanups = []) {
24373
+ function cloneSnapshotTree(source, ids, pseudoRules = [], svgMarker = String(++snapshotPseudoId), cleanups = [], svgState = {
24374
+ opaqueRoots: /* @__PURE__ */ new Set(),
24375
+ copies: []
24376
+ }) {
24123
24377
  const html = source.namespaceURI === "http://www.w3.org/1999/xhtml";
24124
24378
  const svg = source.namespaceURI === "http://www.w3.org/2000/svg";
24125
24379
  const custom = html && source.localName.includes("-");
24126
- const clone = document.createElementNS(source.namespaceURI, custom ? "span" : source.localName);
24380
+ const linkedSheet = html && source.localName === "link" && source.relList.contains("stylesheet");
24381
+ const clone = document.createElementNS(source.namespaceURI, linkedSheet ? "style" : custom ? "span" : source.localName);
24127
24382
  for (const attr of [...source.attributes]) {
24128
24383
  if (attr.name === "id" || attr.name === "data-action" || attr.name === "is" || attr.name.toLowerCase().startsWith("on")) continue;
24129
24384
  const value = svg && attr.localName === "href" ? snapshotFragment(attr.value, ids) : svg || attr.localName === "style" ? snapshotUrls(attr.value, ids) : attr.value;
@@ -24135,6 +24390,15 @@ function cloneSnapshotTree(source, ids, pseudoRules = [], svgMarker = String(++s
24135
24390
  if (source.id) clone.setAttribute("data-spindle-snapshot-original-id", source.id);
24136
24391
  if (custom) clone.setAttribute("data-spindle-snapshot-tag", source.localName);
24137
24392
  if (svg) clone.setAttribute("data-spindle-snapshot-svg", svgMarker);
24393
+ if (svg) svgState.copies.push({
24394
+ source,
24395
+ clone,
24396
+ ids
24397
+ });
24398
+ if (html && source.localName === "input" && source.type === "radio") {
24399
+ clone.removeAttribute("name");
24400
+ clone.removeAttribute("form");
24401
+ }
24138
24402
  const computed = getComputedStyle(source);
24139
24403
  if (!svg) copyComputedStyle(computed, clone.style, ids);
24140
24404
  let pseudoId;
@@ -24155,21 +24419,21 @@ function cloneSnapshotTree(source, ids, pseudoRules = [], svgMarker = String(++s
24155
24419
  const from = source instanceof HTMLTemplateElement ? source.content : source;
24156
24420
  const to = clone instanceof HTMLTemplateElement ? clone.content : clone;
24157
24421
  const copyChildren = (from, to, rules = pseudoRules, localIds = ids) => {
24158
- for (const node of from.childNodes) to.appendChild(node instanceof Element ? cloneSnapshotTree(node, localIds, rules, svgMarker, cleanups) : node.cloneNode(false));
24422
+ for (const node of from.childNodes) to.appendChild(node instanceof Element ? cloneSnapshotTree(node, localIds, rules, svgMarker, cleanups, svgState) : node.cloneNode(false));
24159
24423
  };
24160
24424
  copyChildren(from, to, pseudoRules, source instanceof HTMLTemplateElement ? snapshotIds(from) : ids);
24161
- if (source instanceof HTMLStyleElement && source.sheet) {
24425
+ if (source.localName === "style" || linkedSheet) {
24426
+ const sourceSheet = source.sheet;
24427
+ clone.textContent = "";
24162
24428
  const root = source.getRootNode();
24163
- if (root.querySelector("svg")) {
24164
- let opaque = false;
24165
- const copy = copySnapshotSheet(source.sheet, ids, () => {
24166
- opaque = true;
24429
+ if (sourceSheet && root.querySelector("svg")) {
24430
+ const copy = copySnapshotSheet(sourceSheet, ids, () => {
24431
+ svgState.opaqueRoots.add(root);
24167
24432
  });
24168
- const sheet = opaque ? source.sheet : copy;
24169
- const dispose = installSnapshotSvgStyles(root, ids, svgMarker, [sheet]);
24170
- clone.textContent = snapshotUrls([...sheet.cssRules].map((rule) => rule.cssText).join("\n"), ids, source.sheet.href ?? document.baseURI);
24433
+ const dispose = installSnapshotSvgStyles(root, ids, svgMarker, [copy]);
24434
+ clone.textContent = snapshotRuleText(copy.cssRules);
24171
24435
  dispose();
24172
- if (source.sheet.disabled) clone.setAttribute("media", "not all");
24436
+ if (sourceSheet.disabled) clone.setAttribute("media", "not all");
24173
24437
  }
24174
24438
  }
24175
24439
  if (source.shadowRoot) {
@@ -24228,7 +24492,12 @@ function createSnapshot(passageEl, transitionType) {
24228
24492
  const cleanups = [];
24229
24493
  const ids = snapshotIds(passageEl);
24230
24494
  const svgMarker = String(++snapshotPseudoId);
24231
- const clone = cloneSnapshotTree(passageEl, ids, pseudoRules, svgMarker, cleanups);
24495
+ const svgState = {
24496
+ opaqueRoots: /* @__PURE__ */ new Set(),
24497
+ copies: []
24498
+ };
24499
+ const clone = cloneSnapshotTree(passageEl, ids, pseudoRules, svgMarker, cleanups, svgState);
24500
+ for (const { source, clone: copy, ids: localIds } of svgState.copies) if (svgState.opaqueRoots.has(source.getRootNode()) && !source.closest("defs, symbol, clipPath, mask, pattern, marker")) copyComputedStyle(getComputedStyle(source), copy.style, localIds);
24232
24501
  clone.style.removeProperty("animation");
24233
24502
  clone.style.removeProperty("grid-area");
24234
24503
  for (const name of ["opacity", "transform"]) clone.style.setProperty(name, clone.style.getPropertyValue(name));
@@ -24613,16 +24882,17 @@ defineMacro({
24613
24882
  const name = target.slice(1);
24614
24883
  const localsUpdate = isLocal ? ctx.update : null;
24615
24884
  const pendingIteration = ctx.hooks.useContext(PendingIterationContext);
24885
+ const tooLate = ctx.hooks.useContext(LateMountContext)?.() ?? false;
24616
24886
  const prevOutput = ctx.hooks.useRef(UNSET);
24617
24887
  const lastNavigation = ctx.hooks.useRef(-1);
24618
24888
  const compute = () => computeAndApply(expr, name, isTemp, isLocal, ctx.getValues, rawArgs, prevOutput, lastNavigation, localsUpdate);
24619
24889
  const ran = ctx.hooks.useRef(false);
24620
24890
  if (!ran.current) {
24621
24891
  ran.current = true;
24622
- compute();
24892
+ if (!tooLate) compute();
24623
24893
  }
24624
24894
  ctx.hooks.useLayoutEffect(() => {
24625
- if (!pendingIteration?.(useStoryStore.getState())) compute();
24895
+ if (!tooLate && !pendingIteration?.(useStoryStore.getState())) compute();
24626
24896
  }, [ctx.merged, pendingIteration]);
24627
24897
  return null;
24628
24898
  }
@@ -25560,6 +25830,10 @@ defineMacro({
25560
25830
  }
25561
25831
  });
25562
25832
  // src/components/macros/SaveManager.tsx
25833
+ /** How long a Delete button stays armed without a second press. */
25834
+ var ARMED_DELETE_MS = 5e3;
25835
+ var ARMED_DELETE_LABEL = "Press again to delete";
25836
+ var ARMED_DELETE_HINT = "Press again to delete this save";
25563
25837
  function relativeTime(iso) {
25564
25838
  const diff = Date.now() - new Date(iso).getTime();
25565
25839
  const secs = Math.floor(diff / 1e3);
@@ -25586,6 +25860,7 @@ function SaveManagerContent({ className, id }) {
25586
25860
  const [status, setStatus] = useState(null);
25587
25861
  const [collapsed, setCollapsed] = useState(() => /* @__PURE__ */ new Set());
25588
25862
  const [renamingId, setRenamingId] = useState(null);
25863
+ const [armedId, setArmedId] = useState(null);
25589
25864
  const renameCancelled = useRef(false);
25590
25865
  const [renameValue, setRenameValue] = useState("");
25591
25866
  const renameInputRef = useRef(null);
@@ -25631,6 +25906,29 @@ function SaveManagerContent({ className, id }) {
25631
25906
  clearTimeout(closeTimer.current);
25632
25907
  };
25633
25908
  }, []);
25909
+ useEffect(() => {
25910
+ if (armedId === null) return;
25911
+ const disarm = () => setArmedId(null);
25912
+ const onArmedButton = (e) => e.target instanceof Element && !!e.target.closest("[data-armed]");
25913
+ const onPointerDown = (e) => {
25914
+ if (!onArmedButton(e)) disarm();
25915
+ };
25916
+ const onKeyDown = (e) => {
25917
+ if (e.key === "Escape") {
25918
+ e.preventDefault();
25919
+ e.stopPropagation();
25920
+ disarm();
25921
+ } else if (!onArmedButton(e)) disarm();
25922
+ };
25923
+ const timer = window.setTimeout(disarm, ARMED_DELETE_MS);
25924
+ document.addEventListener("pointerdown", onPointerDown, true);
25925
+ document.addEventListener("keydown", onKeyDown, true);
25926
+ return () => {
25927
+ clearTimeout(timer);
25928
+ document.removeEventListener("pointerdown", onPointerDown, true);
25929
+ document.removeEventListener("keydown", onKeyDown, true);
25930
+ };
25931
+ }, [armedId]);
25634
25932
  const toggleCollapse = (id) => {
25635
25933
  setCollapsed((prev) => {
25636
25934
  const next = new Set(prev);
@@ -25690,8 +25988,13 @@ function SaveManagerContent({ className, id }) {
25690
25988
  showStatus(failed, "error");
25691
25989
  }
25692
25990
  };
25991
+ /** The first press arms the button; a second press on it deletes. */
25693
25992
  const handleDelete = async (saveId) => {
25694
- if (!confirm("Delete this save?")) return;
25993
+ if (armedId !== saveId) {
25994
+ setArmedId(saveId);
25995
+ return;
25996
+ }
25997
+ setArmedId(null);
25695
25998
  await runAction("Save deleted", "Failed to delete save", async () => {
25696
25999
  await deleteSaveById(saveId);
25697
26000
  const known = await populateKnownSaves(ifid);
@@ -25888,9 +26191,13 @@ function SaveManagerContent({ className, id }) {
25888
26191
  }),
25889
26192
  /* @__PURE__ */ jsx("button", {
25890
26193
  type: "button",
25891
- class: "save-slot-action danger",
26194
+ class: armedId === save.meta.id ? "save-slot-action danger is-armed" : "save-slot-action danger",
26195
+ "data-armed": armedId === save.meta.id ? "true" : void 0,
26196
+ "aria-label": armedId === save.meta.id ? ARMED_DELETE_HINT : void 0,
26197
+ title: armedId === save.meta.id ? ARMED_DELETE_HINT : void 0,
25892
26198
  onClick: () => handleDelete(save.meta.id),
25893
- children: "Delete"
26199
+ onBlur: () => setArmedId((id) => id === save.meta.id ? null : id),
26200
+ children: armedId === save.meta.id ? ARMED_DELETE_LABEL : "Delete"
25894
26201
  })
25895
26202
  ]
25896
26203
  })]
@@ -25915,6 +26222,12 @@ function SaveManagerContent({ className, id }) {
25915
26222
  })
25916
26223
  })]
25917
26224
  }),
26225
+ /* @__PURE__ */ jsx("div", {
26226
+ class: "saves-sr-only",
26227
+ role: "status",
26228
+ "aria-live": "polite",
26229
+ children: armedId !== null ? ARMED_DELETE_HINT : ""
26230
+ }),
25918
26231
  status && /* @__PURE__ */ jsx("div", {
25919
26232
  class: `saves-status ${status.type === "error" ? "error" : ""}`,
25920
26233
  children: status.text
@@ -26030,6 +26343,7 @@ defineMacro({
26030
26343
  parameters: INCLUDE_PARAMETERS,
26031
26344
  render(_props, ctx) {
26032
26345
  const displayOnly = ctx.hooks.useContext(DisplayOnlyContext);
26346
+ const tooLate = ctx.hooks.useContext(LateMountContext)?.() ?? false;
26033
26347
  const { storyData } = useStoryFields("storyData");
26034
26348
  const { inline } = ctx.args;
26035
26349
  let passageName = "";
@@ -26043,7 +26357,7 @@ defineMacro({
26043
26357
  const ast = ctx.hooks.useMemo(() => passage ? parseMarkup(passage.content) : null, [passage]);
26044
26358
  const included = !failure && !!passage;
26045
26359
  ctx.hooks.useEffect(() => {
26046
- if (included && !displayOnly) useStoryStore.getState().trackRender(passageName);
26360
+ if (included && !displayOnly && !tooLate) useStoryStore.getState().trackRender(passageName);
26047
26361
  }, [
26048
26362
  included,
26049
26363
  passageName,
@@ -26082,7 +26396,9 @@ defineMacro({
26082
26396
  }],
26083
26397
  render(_props, ctx) {
26084
26398
  const [failure, setFailure] = ctx.hooks.useState();
26399
+ const tooLate = ctx.hooks.useContext(LateMountContext)?.() ?? false;
26085
26400
  ctx.hooks.useLayoutEffect(() => {
26401
+ if (tooLate) return;
26086
26402
  const location = ctx.sourceLocation();
26087
26403
  try {
26088
26404
  const store = useStoryStore.getState();
@@ -26381,7 +26697,7 @@ defineMacro({
26381
26697
  }
26382
26698
  });
26383
26699
  // src/styles.css?inline
26384
- var styles_default = "*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\nhtml {\n font-size: 16px;\n -webkit-text-size-adjust: 100%;\n}\n\nbody {\n margin: 0;\n padding: 0;\n font-family: Georgia, 'Times New Roman', serif;\n line-height: 1.75;\n color: #e0e0e0;\n background-color: #1a1a2e;\n min-height: 100vh;\n}\n\ntw-storydata {\n display: none !important;\n}\n\n#story {\n max-width: 42em;\n margin: 0 auto;\n padding: 2em 1.5em;\n}\n\n/* Passage transitions */\n\n.passage-container {\n position: relative;\n}\n\n.passage-container--crossfading {\n display: grid;\n}\n\n.passage-container--crossfading > * {\n grid-area: 1 / 1;\n}\n\n.passage {\n animation: passage-fade-in var(--passage-in-duration, 0.3s) ease;\n}\n\n.passage[data-transition='none'] {\n animation: none;\n}\n\n.passage-snapshot {\n animation: passage-fade-out var(--passage-out-duration, 0.3s) ease forwards;\n pointer-events: none;\n user-select: none;\n}\n\n@keyframes passage-fade-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes passage-fade-out {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(-8px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .passage,\n .passage-snapshot {\n animation-duration: 0.01s !important;\n }\n}\n\n.macro-button {\n background: rgba(100, 181, 246, 0.15);\n color: #64b5f6;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 4px;\n padding: 0.25em 0.75em;\n font: inherit;\n font-size: 0.95em;\n cursor: pointer;\n transition:\n background 0.2s,\n border-color 0.2s;\n}\n\n.macro-button:hover {\n background: rgba(100, 181, 246, 0.25);\n border-color: #90caf9;\n}\n\n.macro-button:active {\n background: rgba(100, 181, 246, 0.35);\n}\n\n.error {\n color: #ef5350;\n font-family: monospace;\n padding: 1em;\n border: 1px solid #ef5350;\n border-radius: 4px;\n background: rgba(239, 83, 80, 0.1);\n}\n\n/* Runtime errors shown on the page (see src/components/RuntimeErrors.tsx) */\n.spindle-error-banners {\n position: fixed;\n top: 0.75em;\n left: 50%;\n z-index: 300;\n display: flex;\n flex-direction: column;\n gap: 0.5em;\n width: min(42em, calc(100% - 1.5em));\n transform: translateX(-50%);\n}\n\n.spindle-error-banner {\n position: relative;\n padding: 0.75em 2.75em 0.75em 1em;\n border: 1px solid #ef5350;\n border-radius: 4px;\n background: #2b1a1e;\n color: #ffcdd2;\n font-size: 0.9em;\n line-height: 1.5;\n box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);\n}\n\n.spindle-error-banner-message {\n font-family: monospace;\n color: #ef9a9a;\n}\n\n.spindle-error-banner-dismiss {\n position: absolute;\n top: 0.5em;\n right: 0.5em;\n background: transparent;\n border: none;\n color: inherit;\n font-size: 1em;\n cursor: pointer;\n}\n\n.spindle-error-banner-dismiss:hover {\n color: #fff;\n}\n\n.loading {\n text-align: center;\n padding: 2em;\n opacity: 0.6;\n}\n\n/* Menu bar */\n\n.story-menubar {\n position: sticky;\n top: 0;\n z-index: 100;\n display: flex;\n align-items: center;\n gap: 0.5em;\n padding: 0.5em 1.5em;\n background: #16213e;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n font-family: system-ui, sans-serif;\n font-size: 0.9em;\n}\n\n@media (max-width: 600px) {\n .story-menubar {\n flex-wrap: wrap;\n padding: 0.5em 0.75em;\n }\n\n .story-menubar .story-title {\n flex: 1 1 100%;\n }\n}\n\n.story-title {\n flex: 1;\n font-weight: 600;\n color: #e0e0e0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.menubar-button {\n background: transparent;\n color: #9e9e9e;\n border: 1px solid transparent;\n padding: 0.35em 0.7em;\n border-radius: 4px;\n cursor: pointer;\n font: inherit;\n transition:\n color 0.2s,\n background 0.2s;\n}\n\n.menubar-button:hover {\n color: #e0e0e0;\n background: rgba(255, 255, 255, 0.08);\n}\n\n.menubar-button:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.menubar-button:disabled:hover {\n color: #9e9e9e;\n background: transparent;\n}\n\n/* Generic dialog */\n\n.dialog-overlay {\n position: fixed;\n inset: 0;\n z-index: 200;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.6);\n}\n\n.dialog-panel {\n background: #16213e;\n border: 1px solid rgba(255, 255, 255, 0.1);\n border-radius: 8px;\n width: 90%;\n max-width: 500px;\n max-height: 80vh;\n display: flex;\n flex-direction: column;\n color: #e0e0e0;\n font-family: system-ui, sans-serif;\n position: relative;\n}\n\n/* Focused programmatically when the dialog has no focusable content */\n.dialog-panel:focus {\n outline: none;\n}\n\n.dialog-saves {\n max-width: 550px;\n}\n\n.dialog-settings {\n max-width: 400px;\n}\n\n/* Keep the first control clear of the close button above it */\n.dialog-settings .dialog-body {\n padding-top: 2.25em;\n}\n\n.dialog-close {\n position: absolute;\n top: 0.75em;\n right: 0.75em;\n z-index: 1;\n background: transparent;\n border: none;\n color: #9e9e9e;\n font-size: 1.1em;\n cursor: pointer;\n padding: 0.25em;\n line-height: 1;\n}\n\n.dialog-close:hover {\n color: #e0e0e0;\n}\n\n.dialog-body {\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n\n/* Settings controls */\n\n.settings-controls {\n padding: 1em 1.25em;\n display: flex;\n flex-direction: column;\n gap: 1em;\n}\n\n.settings-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 1em;\n}\n\n.settings-item {\n display: flex;\n flex-direction: column;\n gap: 0.25em;\n}\n\n.settings-description {\n margin: 0;\n font-size: 0.85em;\n color: #9e9e9e;\n}\n\n.settings-row select,\n.settings-row input[type='range'] {\n accent-color: #64b5f6;\n}\n\n.settings-row select {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n.settings-row input[type='checkbox'] {\n accent-color: #64b5f6;\n width: 1.1em;\n height: 1.1em;\n}\n\n/* Save manager */\n\n.save-manager {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n}\n\n.saves-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 1em 1.25em;\n padding-right: 3em;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n font-weight: 600;\n flex-shrink: 0;\n}\n\n.saves-header-left {\n display: flex;\n align-items: center;\n gap: 0.75em;\n}\n\n.saves-mode-toggle {\n display: flex;\n gap: 0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n overflow: hidden;\n}\n\n.saves-mode-toggle button {\n background: transparent;\n color: #9e9e9e;\n border: none;\n padding: 0.3em 0.8em;\n font: inherit;\n font-size: 0.85em;\n font-weight: 600;\n cursor: pointer;\n transition:\n background 0.2s,\n color 0.2s;\n}\n\n.saves-mode-toggle button.active {\n background: rgba(100, 181, 246, 0.2);\n color: #64b5f6;\n}\n\n.saves-mode-toggle button:hover:not(.active) {\n color: #e0e0e0;\n}\n\n.saves-body {\n padding: 0.75em 1.25em;\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n\n.saves-empty {\n text-align: center;\n padding: 2em 1em;\n opacity: 0.5;\n font-size: 0.9em;\n}\n\n.saves-toolbar {\n display: flex;\n gap: 0.5em;\n padding: 0.5em 1.25em;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n flex-shrink: 0;\n}\n\n.saves-toolbar-button {\n background: rgba(255, 255, 255, 0.05);\n color: #9e9e9e;\n border: 1px solid rgba(255, 255, 255, 0.1);\n border-radius: 4px;\n padding: 0.3em 0.7em;\n font: inherit;\n font-size: 0.8em;\n cursor: pointer;\n transition:\n background 0.2s,\n color 0.2s;\n}\n\n.saves-toolbar-button:hover {\n background: rgba(255, 255, 255, 0.1);\n color: #e0e0e0;\n}\n\n.playthrough-group {\n margin-bottom: 0.75em;\n}\n\n.playthrough-header {\n display: flex;\n width: 100%;\n border: 0;\n background: none;\n font-family: inherit;\n text-align: left;\n align-items: center;\n gap: 0.5em;\n padding: 0.4em 0;\n cursor: pointer;\n user-select: none;\n font-size: 0.85em;\n color: #9e9e9e;\n transition: color 0.2s;\n}\n\n.playthrough-header:hover {\n color: #e0e0e0;\n}\n\n.playthrough-chevron {\n display: inline-block;\n font-size: 0.7em;\n transition: transform 0.2s;\n}\n\n.playthrough-chevron.open {\n transform: rotate(90deg);\n}\n\n.playthrough-label {\n font-weight: 600;\n}\n\n.playthrough-date {\n opacity: 0.6;\n font-size: 0.9em;\n}\n\n.playthrough-saves {\n display: flex;\n flex-direction: column;\n gap: 0.4em;\n padding-left: 0.25em;\n}\n\n.save-slot {\n display: flex;\n align-items: center;\n gap: 0.75em;\n padding: 0.5em 0.6em;\n background: rgba(255, 255, 255, 0.03);\n border: 1px solid rgba(255, 255, 255, 0.06);\n border-radius: 6px;\n transition: background 0.15s;\n}\n\n.save-slot:hover {\n background: rgba(255, 255, 255, 0.06);\n}\n\n.save-slot-info {\n flex: 1;\n min-width: 0;\n}\n\n.save-slot-title {\n font-weight: 500;\n font-size: 0.9em;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.save-slot-meta {\n font-size: 0.75em;\n color: #9e9e9e;\n display: flex;\n gap: 0.75em;\n}\n\n.save-slot-actions {\n display: flex;\n gap: 0.3em;\n flex-shrink: 0;\n}\n\n.save-slot-action {\n background: transparent;\n color: #9e9e9e;\n border: 1px solid transparent;\n border-radius: 3px;\n padding: 0.2em 0.5em;\n font: inherit;\n font-size: 0.75em;\n cursor: pointer;\n transition:\n color 0.2s,\n background 0.2s;\n white-space: nowrap;\n}\n\n.save-slot-action:hover {\n color: #e0e0e0;\n background: rgba(255, 255, 255, 0.08);\n}\n\n.save-slot-action.primary {\n color: #64b5f6;\n border-color: rgba(100, 181, 246, 0.3);\n}\n\n.save-slot-action.primary:hover {\n background: rgba(100, 181, 246, 0.15);\n}\n\n.save-slot-action.danger:hover {\n color: #ef5350;\n background: rgba(239, 83, 80, 0.1);\n}\n\n.save-slot-new {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0.5em;\n margin-top: 0.25em;\n border: 1px dashed rgba(255, 255, 255, 0.12);\n border-radius: 6px;\n color: #9e9e9e;\n font: inherit;\n font-size: 0.8em;\n background: transparent;\n cursor: pointer;\n width: 100%;\n transition:\n color 0.2s,\n border-color 0.2s,\n background 0.2s;\n}\n\n.save-slot-new:hover {\n color: #64b5f6;\n border-color: rgba(100, 181, 246, 0.3);\n background: rgba(100, 181, 246, 0.05);\n}\n\n.saves-notice {\n padding: 0.5em 1.25em;\n font-size: 0.8em;\n color: #ffb74d;\n border-bottom: 1px solid rgba(255, 183, 77, 0.3);\n background: rgba(255, 183, 77, 0.08);\n flex-shrink: 0;\n}\n\n.saves-status {\n padding: 0.5em 1.25em;\n font-size: 0.8em;\n color: #81c784;\n border-top: 1px solid rgba(255, 255, 255, 0.08);\n flex-shrink: 0;\n text-align: center;\n}\n\n.saves-status.error {\n color: #ef5350;\n border: none;\n border-radius: 0;\n padding: 0.5em 1.25em;\n font-family: inherit;\n background: transparent;\n}\n\n.save-rename-input {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 3px;\n padding: 0.15em 0.4em;\n font: inherit;\n font-size: 0.9em;\n width: 100%;\n}\n\n.save-rename-input:focus {\n outline: none;\n border-color: #64b5f6;\n}\n\n/* Macro: link */\n\n.macro-link {\n color: #64b5f6;\n text-decoration: none;\n border-bottom: 1px solid rgba(100, 181, 246, 0.3);\n transition:\n color 0.2s,\n border-color 0.2s;\n cursor: pointer;\n}\n\n.macro-link:hover {\n color: #90caf9;\n border-bottom-color: #90caf9;\n}\n\n.macro-link:active {\n color: #42a5f5;\n}\n\n/* Macro: form inputs */\n\n.macro-textbox,\n.macro-numberbox,\n.macro-textarea {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n.macro-textbox:focus,\n.macro-numberbox:focus,\n.macro-textarea:focus {\n outline: none;\n border-color: #64b5f6;\n}\n\n.macro-textarea {\n min-height: 3em;\n resize: vertical;\n}\n\n.macro-checkbox,\n.macro-radiobutton {\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 0.3em;\n}\n\n.macro-checkbox input,\n.macro-radiobutton input {\n accent-color: #64b5f6;\n}\n\n/* Macro: listbox */\n\n.macro-listbox {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n/* Macro: cycle */\n\n.macro-cycle {\n background: rgba(100, 181, 246, 0.15);\n color: #64b5f6;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 4px;\n padding: 0.25em 0.75em;\n font: inherit;\n cursor: pointer;\n transition:\n background 0.2s,\n border-color 0.2s;\n}\n\n.macro-cycle:hover {\n background: rgba(100, 181, 246, 0.25);\n border-color: #90caf9;\n}\n\n/* Macro: meter */\n\n.macro-meter {\n position: relative;\n width: 100%;\n height: 1.4em;\n background: #2a2a3e;\n border-radius: 0.3em;\n overflow: hidden;\n border: 1px solid #444;\n}\n\n.macro-meter-fill {\n height: 100%;\n background: #64b5f6;\n transition: width 0.3s ease;\n}\n\n.macro-meter-label {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 0.85em;\n color: #e0e0e0;\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);\n pointer-events: none;\n}\n\n/* Markdown wrapper — invisible to layout */\n\n.md {\n display: contents;\n}\n\n/* Markdown block elements inside passages */\n\n.passage p {\n margin: 0.6em 0;\n}\n\n.passage p:first-child {\n margin-top: 0;\n}\n\n.passage p:last-child {\n margin-bottom: 0;\n}\n\n.passage h1,\n.passage h2,\n.passage h3,\n.passage h4,\n.passage h5,\n.passage h6 {\n margin: 1em 0 0.4em;\n line-height: 1.3;\n color: #f0f0f0;\n}\n\n.passage h1 {\n font-size: 1.8em;\n}\n.passage h2 {\n font-size: 1.5em;\n}\n.passage h3 {\n font-size: 1.25em;\n}\n.passage h4 {\n font-size: 1.1em;\n}\n.passage h5 {\n font-size: 1em;\n}\n.passage h6 {\n font-size: 0.9em;\n opacity: 0.8;\n}\n\n.passage code {\n font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;\n font-size: 0.9em;\n background: rgba(255, 255, 255, 0.08);\n padding: 0.15em 0.35em;\n border-radius: 3px;\n}\n\n.passage pre {\n background: rgba(0, 0, 0, 0.3);\n border: 1px solid rgba(255, 255, 255, 0.08);\n border-radius: 6px;\n padding: 1em;\n overflow-x: auto;\n margin: 0.8em 0;\n}\n\n.passage pre code {\n background: none;\n padding: 0;\n border-radius: 0;\n font-size: 0.85em;\n}\n\n.passage blockquote {\n border-left: 3px solid rgba(100, 181, 246, 0.5);\n margin: 0.8em 0;\n padding: 0.4em 1em;\n color: #b0b0b0;\n}\n\n.passage blockquote p {\n margin: 0.3em 0;\n}\n\n.passage ul,\n.passage ol {\n margin: 0.6em 0;\n padding-left: 1.8em;\n}\n\n.passage li {\n margin: 0.2em 0;\n}\n\n.passage hr {\n border: none;\n border-top: 1px solid rgba(255, 255, 255, 0.12);\n margin: 1.2em 0;\n}\n\n.passage table {\n border-collapse: collapse;\n width: 100%;\n margin: 0.8em 0;\n}\n\n.passage th,\n.passage td {\n border: 1px solid rgba(255, 255, 255, 0.12);\n padding: 0.5em 0.75em;\n text-align: left;\n}\n\n.passage th {\n background: rgba(255, 255, 255, 0.06);\n font-weight: 600;\n}\n\n.passage tr:nth-child(even) {\n background: rgba(255, 255, 255, 0.02);\n}\n\n.passage del {\n opacity: 0.5;\n}\n\n.passage strong {\n color: #f0f0f0;\n}\n\n/* Macro: type (typewriter) */\n\n.macro-type-cursor::after {\n content: '\\2588';\n animation: type-blink 0.7s step-end infinite;\n color: #64b5f6;\n}\n\n.macro-type-done .macro-type-cursor::after {\n display: none;\n}\n\n@keyframes type-blink {\n 50% {\n opacity: 0;\n }\n}\n";
26700
+ var styles_default = "*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\nhtml {\n font-size: 16px;\n -webkit-text-size-adjust: 100%;\n}\n\nbody {\n margin: 0;\n padding: 0;\n font-family: Georgia, 'Times New Roman', serif;\n line-height: 1.75;\n color: #e0e0e0;\n background-color: #1a1a2e;\n min-height: 100vh;\n}\n\ntw-storydata {\n display: none !important;\n}\n\n#story {\n max-width: 42em;\n margin: 0 auto;\n padding: 2em 1.5em;\n}\n\n/* Passage transitions */\n\n.passage-container {\n position: relative;\n}\n\n.passage-container--crossfading {\n display: grid;\n}\n\n.passage-container--crossfading > * {\n grid-area: 1 / 1;\n}\n\n.passage {\n animation: passage-fade-in var(--passage-in-duration, 0.3s) ease;\n}\n\n.passage[data-transition='none'] {\n animation: none;\n}\n\n.passage-snapshot {\n animation: passage-fade-out var(--passage-out-duration, 0.3s) ease forwards;\n pointer-events: none;\n user-select: none;\n}\n\n@keyframes passage-fade-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes passage-fade-out {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(-8px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .passage,\n .passage-snapshot {\n animation-duration: 0.01s !important;\n }\n}\n\n.macro-button {\n background: rgba(100, 181, 246, 0.15);\n color: #64b5f6;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 4px;\n padding: 0.25em 0.75em;\n font: inherit;\n font-size: 0.95em;\n cursor: pointer;\n transition:\n background 0.2s,\n border-color 0.2s;\n}\n\n.macro-button:hover {\n background: rgba(100, 181, 246, 0.25);\n border-color: #90caf9;\n}\n\n.macro-button:active {\n background: rgba(100, 181, 246, 0.35);\n}\n\n.error {\n color: #ef5350;\n font-family: monospace;\n padding: 1em;\n border: 1px solid #ef5350;\n border-radius: 4px;\n background: rgba(239, 83, 80, 0.1);\n}\n\n/* Runtime errors shown on the page (see src/components/RuntimeErrors.tsx) */\n.spindle-error-banners {\n position: fixed;\n top: 0.75em;\n left: 50%;\n z-index: 300;\n display: flex;\n flex-direction: column;\n gap: 0.5em;\n width: min(42em, calc(100% - 1.5em));\n transform: translateX(-50%);\n}\n\n.spindle-error-banner {\n position: relative;\n padding: 0.75em 2.75em 0.75em 1em;\n border: 1px solid #ef5350;\n border-radius: 4px;\n background: #2b1a1e;\n color: #ffcdd2;\n font-size: 0.9em;\n line-height: 1.5;\n box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);\n}\n\n.spindle-error-banner-message {\n font-family: monospace;\n color: #ef9a9a;\n}\n\n.spindle-error-banner-dismiss {\n position: absolute;\n top: 0.5em;\n right: 0.5em;\n background: transparent;\n border: none;\n color: inherit;\n font-size: 1em;\n cursor: pointer;\n}\n\n.spindle-error-banner-dismiss:hover {\n color: #fff;\n}\n\n.loading {\n text-align: center;\n padding: 2em;\n opacity: 0.6;\n}\n\n/* Menu bar */\n\n.story-menubar {\n position: sticky;\n top: 0;\n z-index: 100;\n display: flex;\n align-items: center;\n gap: 0.5em;\n padding: 0.5em 1.5em;\n background: #16213e;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n font-family: system-ui, sans-serif;\n font-size: 0.9em;\n}\n\n@media (max-width: 600px) {\n .story-menubar {\n flex-wrap: wrap;\n padding: 0.5em 0.75em;\n }\n\n .story-menubar .story-title {\n flex: 1 1 100%;\n }\n}\n\n.story-title {\n flex: 1;\n font-weight: 600;\n color: #e0e0e0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.menubar-button {\n background: transparent;\n color: #9e9e9e;\n border: 1px solid transparent;\n padding: 0.35em 0.7em;\n border-radius: 4px;\n cursor: pointer;\n font: inherit;\n transition:\n color 0.2s,\n background 0.2s;\n}\n\n.menubar-button:hover {\n color: #e0e0e0;\n background: rgba(255, 255, 255, 0.08);\n}\n\n.menubar-button:disabled {\n opacity: 0.4;\n cursor: default;\n}\n\n.menubar-button:disabled:hover {\n color: #9e9e9e;\n background: transparent;\n}\n\n/* Generic dialog */\n\n.dialog-overlay {\n position: fixed;\n inset: 0;\n z-index: 200;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.6);\n}\n\n.dialog-panel {\n background: #16213e;\n border: 1px solid rgba(255, 255, 255, 0.1);\n border-radius: 8px;\n width: 90%;\n max-width: 500px;\n max-height: 80vh;\n display: flex;\n flex-direction: column;\n color: #e0e0e0;\n font-family: system-ui, sans-serif;\n position: relative;\n}\n\n/* Focused programmatically when the dialog has no focusable content */\n.dialog-panel:focus {\n outline: none;\n}\n\n.dialog-saves {\n max-width: 550px;\n}\n\n.dialog-settings {\n max-width: 400px;\n}\n\n/* Keep the first control clear of the close button above it */\n.dialog-settings .dialog-body {\n padding-top: 2.25em;\n}\n\n.dialog-close {\n position: absolute;\n top: 0.75em;\n right: 0.75em;\n z-index: 1;\n background: transparent;\n border: none;\n color: #9e9e9e;\n font-size: 1.1em;\n cursor: pointer;\n padding: 0.25em;\n line-height: 1;\n}\n\n.dialog-close:hover {\n color: #e0e0e0;\n}\n\n.dialog-body {\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n\n/* Settings controls */\n\n.settings-controls {\n padding: 1em 1.25em;\n display: flex;\n flex-direction: column;\n gap: 1em;\n}\n\n.settings-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 1em;\n}\n\n.settings-item {\n display: flex;\n flex-direction: column;\n gap: 0.25em;\n}\n\n.settings-description {\n margin: 0;\n font-size: 0.85em;\n color: #9e9e9e;\n}\n\n.settings-row select,\n.settings-row input[type='range'] {\n accent-color: #64b5f6;\n}\n\n.settings-row select {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n.settings-row input[type='checkbox'] {\n accent-color: #64b5f6;\n width: 1.1em;\n height: 1.1em;\n}\n\n/* Save manager */\n\n.save-manager {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n}\n\n.saves-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 1em 1.25em;\n padding-right: 3em;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n font-weight: 600;\n flex-shrink: 0;\n}\n\n.saves-header-left {\n display: flex;\n align-items: center;\n gap: 0.75em;\n}\n\n.saves-mode-toggle {\n display: flex;\n gap: 0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n overflow: hidden;\n}\n\n.saves-mode-toggle button {\n background: transparent;\n color: #9e9e9e;\n border: none;\n padding: 0.3em 0.8em;\n font: inherit;\n font-size: 0.85em;\n font-weight: 600;\n cursor: pointer;\n transition:\n background 0.2s,\n color 0.2s;\n}\n\n.saves-mode-toggle button.active {\n background: rgba(100, 181, 246, 0.2);\n color: #64b5f6;\n}\n\n.saves-mode-toggle button:hover:not(.active) {\n color: #e0e0e0;\n}\n\n.saves-body {\n padding: 0.75em 1.25em;\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n\n.saves-empty {\n text-align: center;\n padding: 2em 1em;\n opacity: 0.5;\n font-size: 0.9em;\n}\n\n.saves-toolbar {\n display: flex;\n gap: 0.5em;\n padding: 0.5em 1.25em;\n border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n flex-shrink: 0;\n}\n\n.saves-toolbar-button {\n background: rgba(255, 255, 255, 0.05);\n color: #9e9e9e;\n border: 1px solid rgba(255, 255, 255, 0.1);\n border-radius: 4px;\n padding: 0.3em 0.7em;\n font: inherit;\n font-size: 0.8em;\n cursor: pointer;\n transition:\n background 0.2s,\n color 0.2s;\n}\n\n.saves-toolbar-button:hover {\n background: rgba(255, 255, 255, 0.1);\n color: #e0e0e0;\n}\n\n.playthrough-group {\n margin-bottom: 0.75em;\n}\n\n.playthrough-header {\n display: flex;\n width: 100%;\n border: 0;\n background: none;\n font-family: inherit;\n text-align: left;\n align-items: center;\n gap: 0.5em;\n padding: 0.4em 0;\n cursor: pointer;\n user-select: none;\n font-size: 0.85em;\n color: #9e9e9e;\n transition: color 0.2s;\n}\n\n.playthrough-header:hover {\n color: #e0e0e0;\n}\n\n.playthrough-chevron {\n display: inline-block;\n font-size: 0.7em;\n transition: transform 0.2s;\n}\n\n.playthrough-chevron.open {\n transform: rotate(90deg);\n}\n\n.playthrough-label {\n font-weight: 600;\n}\n\n.playthrough-date {\n opacity: 0.6;\n font-size: 0.9em;\n}\n\n.playthrough-saves {\n display: flex;\n flex-direction: column;\n gap: 0.4em;\n padding-left: 0.25em;\n}\n\n.save-slot {\n display: flex;\n align-items: center;\n gap: 0.75em;\n padding: 0.5em 0.6em;\n background: rgba(255, 255, 255, 0.03);\n border: 1px solid rgba(255, 255, 255, 0.06);\n border-radius: 6px;\n transition: background 0.15s;\n}\n\n.save-slot:hover {\n background: rgba(255, 255, 255, 0.06);\n}\n\n.save-slot-info {\n flex: 1;\n min-width: 0;\n}\n\n.save-slot-title {\n font-weight: 500;\n font-size: 0.9em;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.save-slot-meta {\n font-size: 0.75em;\n color: #9e9e9e;\n display: flex;\n gap: 0.75em;\n}\n\n.save-slot-actions {\n display: flex;\n gap: 0.3em;\n flex-shrink: 0;\n}\n\n.save-slot-action {\n background: transparent;\n color: #9e9e9e;\n border: 1px solid transparent;\n border-radius: 3px;\n padding: 0.2em 0.5em;\n font: inherit;\n font-size: 0.75em;\n cursor: pointer;\n transition:\n color 0.2s,\n background 0.2s;\n white-space: nowrap;\n}\n\n.save-slot-action:hover {\n color: #e0e0e0;\n background: rgba(255, 255, 255, 0.08);\n}\n\n.save-slot-action.primary {\n color: #64b5f6;\n border-color: rgba(100, 181, 246, 0.3);\n}\n\n.save-slot-action.primary:hover {\n background: rgba(100, 181, 246, 0.15);\n}\n\n.save-slot-action.danger:hover {\n color: #ef5350;\n background: rgba(239, 83, 80, 0.1);\n}\n\n.save-slot-action.danger.is-armed {\n color: #ef5350;\n background: rgba(239, 83, 80, 0.15);\n border-color: rgba(239, 83, 80, 0.5);\n}\n\n/* Read by screen readers, not shown: announces an armed Delete button */\n.saves-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n}\n\n.save-slot-new {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0.5em;\n margin-top: 0.25em;\n border: 1px dashed rgba(255, 255, 255, 0.12);\n border-radius: 6px;\n color: #9e9e9e;\n font: inherit;\n font-size: 0.8em;\n background: transparent;\n cursor: pointer;\n width: 100%;\n transition:\n color 0.2s,\n border-color 0.2s,\n background 0.2s;\n}\n\n.save-slot-new:hover {\n color: #64b5f6;\n border-color: rgba(100, 181, 246, 0.3);\n background: rgba(100, 181, 246, 0.05);\n}\n\n.saves-notice {\n padding: 0.5em 1.25em;\n font-size: 0.8em;\n color: #ffb74d;\n border-bottom: 1px solid rgba(255, 183, 77, 0.3);\n background: rgba(255, 183, 77, 0.08);\n flex-shrink: 0;\n}\n\n.saves-status {\n padding: 0.5em 1.25em;\n font-size: 0.8em;\n color: #81c784;\n border-top: 1px solid rgba(255, 255, 255, 0.08);\n flex-shrink: 0;\n text-align: center;\n}\n\n.saves-status.error {\n color: #ef5350;\n border: none;\n border-radius: 0;\n padding: 0.5em 1.25em;\n font-family: inherit;\n background: transparent;\n}\n\n.save-rename-input {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 3px;\n padding: 0.15em 0.4em;\n font: inherit;\n font-size: 0.9em;\n width: 100%;\n}\n\n.save-rename-input:focus {\n outline: none;\n border-color: #64b5f6;\n}\n\n/* Macro: link */\n\n.macro-link {\n color: #64b5f6;\n text-decoration: none;\n border-bottom: 1px solid rgba(100, 181, 246, 0.3);\n transition:\n color 0.2s,\n border-color 0.2s;\n cursor: pointer;\n}\n\n.macro-link:hover {\n color: #90caf9;\n border-bottom-color: #90caf9;\n}\n\n.macro-link:active {\n color: #42a5f5;\n}\n\n/* Macro: form inputs */\n\n.macro-textbox,\n.macro-numberbox,\n.macro-textarea {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n.macro-textbox:focus,\n.macro-numberbox:focus,\n.macro-textarea:focus {\n outline: none;\n border-color: #64b5f6;\n}\n\n.macro-textarea {\n min-height: 3em;\n resize: vertical;\n}\n\n.macro-checkbox,\n.macro-radiobutton {\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 0.3em;\n}\n\n.macro-checkbox input,\n.macro-radiobutton input {\n accent-color: #64b5f6;\n}\n\n/* Macro: listbox */\n\n.macro-listbox {\n background: #1a1a2e;\n color: #e0e0e0;\n border: 1px solid rgba(255, 255, 255, 0.15);\n border-radius: 4px;\n padding: 0.3em 0.5em;\n font: inherit;\n}\n\n/* Macro: cycle */\n\n.macro-cycle {\n background: rgba(100, 181, 246, 0.15);\n color: #64b5f6;\n border: 1px solid rgba(100, 181, 246, 0.4);\n border-radius: 4px;\n padding: 0.25em 0.75em;\n font: inherit;\n cursor: pointer;\n transition:\n background 0.2s,\n border-color 0.2s;\n}\n\n.macro-cycle:hover {\n background: rgba(100, 181, 246, 0.25);\n border-color: #90caf9;\n}\n\n/* Macro: meter */\n\n.macro-meter {\n position: relative;\n width: 100%;\n height: 1.4em;\n background: #2a2a3e;\n border-radius: 0.3em;\n overflow: hidden;\n border: 1px solid #444;\n}\n\n.macro-meter-fill {\n height: 100%;\n background: #64b5f6;\n transition: width 0.3s ease;\n}\n\n.macro-meter-label {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 0.85em;\n color: #e0e0e0;\n text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);\n pointer-events: none;\n}\n\n/* Markdown wrapper — invisible to layout */\n\n.md {\n display: contents;\n}\n\n/* Markdown block elements inside passages */\n\n.passage p {\n margin: 0.6em 0;\n}\n\n.passage p:first-child {\n margin-top: 0;\n}\n\n.passage p:last-child {\n margin-bottom: 0;\n}\n\n.passage h1,\n.passage h2,\n.passage h3,\n.passage h4,\n.passage h5,\n.passage h6 {\n margin: 1em 0 0.4em;\n line-height: 1.3;\n color: #f0f0f0;\n}\n\n.passage h1 {\n font-size: 1.8em;\n}\n.passage h2 {\n font-size: 1.5em;\n}\n.passage h3 {\n font-size: 1.25em;\n}\n.passage h4 {\n font-size: 1.1em;\n}\n.passage h5 {\n font-size: 1em;\n}\n.passage h6 {\n font-size: 0.9em;\n opacity: 0.8;\n}\n\n.passage code {\n font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;\n font-size: 0.9em;\n background: rgba(255, 255, 255, 0.08);\n padding: 0.15em 0.35em;\n border-radius: 3px;\n}\n\n.passage pre {\n background: rgba(0, 0, 0, 0.3);\n border: 1px solid rgba(255, 255, 255, 0.08);\n border-radius: 6px;\n padding: 1em;\n overflow-x: auto;\n margin: 0.8em 0;\n}\n\n.passage pre code {\n background: none;\n padding: 0;\n border-radius: 0;\n font-size: 0.85em;\n}\n\n.passage blockquote {\n border-left: 3px solid rgba(100, 181, 246, 0.5);\n margin: 0.8em 0;\n padding: 0.4em 1em;\n color: #b0b0b0;\n}\n\n.passage blockquote p {\n margin: 0.3em 0;\n}\n\n.passage ul,\n.passage ol {\n margin: 0.6em 0;\n padding-left: 1.8em;\n}\n\n.passage li {\n margin: 0.2em 0;\n}\n\n.passage hr {\n border: none;\n border-top: 1px solid rgba(255, 255, 255, 0.12);\n margin: 1.2em 0;\n}\n\n.passage table {\n border-collapse: collapse;\n width: 100%;\n margin: 0.8em 0;\n}\n\n.passage th,\n.passage td {\n border: 1px solid rgba(255, 255, 255, 0.12);\n padding: 0.5em 0.75em;\n text-align: left;\n}\n\n.passage th {\n background: rgba(255, 255, 255, 0.06);\n font-weight: 600;\n}\n\n.passage tr:nth-child(even) {\n background: rgba(255, 255, 255, 0.02);\n}\n\n.passage del {\n opacity: 0.5;\n}\n\n.passage strong {\n color: #f0f0f0;\n}\n\n/* Macro: type (typewriter) */\n\n.macro-type-cursor::after {\n content: '\\2588';\n animation: type-blink 0.7s step-end infinite;\n color: #64b5f6;\n}\n\n.macro-type-done .macro-type-cursor::after {\n display: none;\n}\n\n@keyframes type-blink {\n 50% {\n opacity: 0;\n }\n}\n";
26385
26701
  // src/index.tsx
26386
26702
  function renderErrors(root, errors) {
26387
26703
  root.innerHTML = "";