@puzzmo/sdk 1.0.72 → 1.0.74

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.
@@ -1,7 +1,8 @@
1
1
  import { t as e } from "./objectSpread2-BJrS9rM5.js";
2
2
  import { t } from "./asyncToGenerator-DSd3oTwb.js";
3
- var n = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
4
- const r = [
3
+ import { createThumbnailMorpher as n } from "./thumbnailMotion.js";
4
+ var r = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
5
+ const i = [
5
6
  {
6
7
  name: "Puzzmo (light)",
7
8
  type: "light",
@@ -307,7 +308,7 @@ const r = [
307
308
  a_infoBG: "#001900"
308
309
  }
309
310
  ];
310
- var i = {
311
+ var a = {
311
312
  collapsed: "simulator-collapsed",
312
313
  tab: "simulator-tab",
313
314
  theme: "simulator-theme",
@@ -319,42 +320,42 @@ var i = {
319
320
  gameSettings: "simulator-game-settings",
320
321
  hostContext: "simulator-host-context",
321
322
  keyboardDocked: "simulator-keyboard-docked"
322
- }, a = "simulator-override:";
323
+ }, o = "simulator-override:";
323
324
  /**
324
325
  * Overrides are scoped to the page that applied them. localStorage is per-origin but a dev server
325
326
  * commonly hosts many games from one origin (each at its own /games/<name>/ path), and an input
326
327
  * string is only meaningful to the game it came from.
327
328
  */
328
- function o(e) {
329
- return `${a}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
329
+ function s(e) {
330
+ return `${o}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
330
331
  }
331
332
  /** The applied override for this page, or null when nothing has been applied. "" is a real value. */
332
- function s(e) {
333
+ function c(e) {
333
334
  try {
334
- return localStorage.getItem(o(e));
335
+ return localStorage.getItem(s(e));
335
336
  } catch (e) {
336
337
  return null;
337
338
  }
338
339
  }
339
340
  /** False when the write failed — private-mode storage, or a board state over the origin's quota. */
340
- function c(e, t) {
341
+ function l(e, t) {
341
342
  try {
342
- return localStorage.setItem(o(e), t), !0;
343
+ return localStorage.setItem(s(e), t), !0;
343
344
  } catch (e) {
344
345
  return !1;
345
346
  }
346
347
  }
347
- function l(e) {
348
+ function u(e) {
348
349
  try {
349
- localStorage.removeItem(o(e));
350
+ localStorage.removeItem(s(e));
350
351
  } catch (e) {}
351
352
  }
352
- function u() {
353
- l("puzzle"), l("input");
353
+ function d() {
354
+ u("puzzle"), u("input");
354
355
  }
355
356
  /** The Host tab's persisted `hostContext` override, or null when the tab hasn't set one. */
356
- function d() {
357
- let e = localStorage.getItem(i.hostContext);
357
+ function f() {
358
+ let e = localStorage.getItem(a.hostContext);
358
359
  if (!e) return null;
359
360
  try {
360
361
  let t = JSON.parse(e);
@@ -362,21 +363,21 @@ function d() {
362
363
  } catch (e) {}
363
364
  return null;
364
365
  }
365
- function f(e) {
366
- localStorage.setItem(i.hostContext, JSON.stringify(e));
366
+ function p(e) {
367
+ localStorage.setItem(a.hostContext, JSON.stringify(e));
367
368
  }
368
- function p() {
369
- localStorage.removeItem(i.hostContext);
369
+ function m() {
370
+ localStorage.removeItem(a.hostContext);
370
371
  }
371
372
  /** The Kbd tab's "show keyboard under game" checkbox. Off until asked for: it takes space from the game. */
372
- function m() {
373
- return localStorage.getItem(i.keyboardDocked) === "true";
373
+ function h() {
374
+ return localStorage.getItem(a.keyboardDocked) === "true";
374
375
  }
375
- function h(e) {
376
- localStorage.setItem(i.keyboardDocked, String(e));
376
+ function g(e) {
377
+ localStorage.setItem(a.keyboardDocked, String(e));
377
378
  }
378
- function g() {
379
- let e = localStorage.getItem(i.gameSettings);
379
+ function _() {
380
+ let e = localStorage.getItem(a.gameSettings);
380
381
  if (!e) return {};
381
382
  try {
382
383
  let t = JSON.parse(e);
@@ -384,36 +385,36 @@ function g() {
384
385
  } catch (e) {}
385
386
  return {};
386
387
  }
387
- function _() {
388
- let e = localStorage.getItem(i.theme);
388
+ function v() {
389
+ let e = localStorage.getItem(a.theme);
389
390
  if (e) {
390
- let t = r.find((t) => t.name === e);
391
+ let t = i.find((t) => t.name === e);
391
392
  if (t) return t;
392
393
  }
393
- return r[0];
394
+ return i[0];
394
395
  }
395
- function v(e) {
396
+ function y(e) {
396
397
  var t;
397
- let n = localStorage.getItem(i.tab);
398
+ let n = localStorage.getItem(a.tab);
398
399
  return n && e.includes(n) ? n : (t = e[0]) == null ? "ctrl" : t;
399
400
  }
400
- function y(e) {
401
- let t = localStorage.getItem(i.collapsed);
401
+ function b(e) {
402
+ let t = localStorage.getItem(a.collapsed);
402
403
  return t === null ? e : t === "true";
403
404
  }
404
- function b() {
405
- let e = localStorage.getItem(i.renderHost);
405
+ function x() {
406
+ let e = localStorage.getItem(a.renderHost);
406
407
  return e && [
407
408
  "game",
408
409
  "app",
409
410
  "opengraph"
410
411
  ].includes(e) ? e : "game";
411
412
  }
412
- function x() {
413
- return localStorage.getItem(i.previewKind) === "text" ? "text" : "image";
414
- }
415
413
  function S() {
416
- let e = localStorage.getItem(i.renderContext);
414
+ return localStorage.getItem(a.previewKind) === "text" ? "text" : "image";
415
+ }
416
+ function C() {
417
+ let e = localStorage.getItem(a.renderContext);
417
418
  if (e && [
418
419
  "preview",
419
420
  "share",
@@ -422,8 +423,8 @@ function S() {
422
423
  ].includes(e)) return e;
423
424
  }
424
425
  function ee(e, t, n) {
425
- var r, a, o;
426
- let c = localStorage.getItem(i.fixtureCategory), l = localStorage.getItem(i.fixturePuzzle), u = d(), f = s("puzzle"), p = s("input");
426
+ var r, i, o;
427
+ let s = localStorage.getItem(a.fixtureCategory), l = localStorage.getItem(a.fixturePuzzle), u = f(), d = c("puzzle"), p = c("input");
427
428
  return {
428
429
  hostContext: (r = u == null ? e.hostContext : u) == null ? [{
429
430
  type: "app",
@@ -431,62 +432,62 @@ function ee(e, t, n) {
431
432
  host: null
432
433
  }] : r,
433
434
  hostContextIsOverridden: u !== null,
434
- isCollapsed: y((a = e.collapsed) == null ? !0 : a),
435
+ isCollapsed: b((i = e.collapsed) == null ? !0 : i),
435
436
  isPaused: !1,
436
437
  hasStarted: !1,
437
- activeTab: v(n),
438
- puzzleData: f,
439
- originalPuzzle: f == null ? "" : f,
438
+ activeTab: y(n),
439
+ puzzleData: d,
440
+ originalPuzzle: d == null ? "" : d,
440
441
  currentInputStr: p == null ? "" : p,
441
442
  userStorage: null,
442
- appliedPuzzleOverride: f,
443
+ appliedPuzzleOverride: d,
443
444
  appliedInputOverride: p,
444
445
  completionData: null,
445
- selectedTheme: _(),
446
- selectedCategory: c && t.includes(c) ? c : (o = t[0]) == null ? null : o,
446
+ selectedTheme: v(),
447
+ selectedCategory: s && t.includes(s) ? s : (o = t[0]) == null ? null : o,
447
448
  selectedPuzzle: l == null ? null : l,
448
- renderHost: b(),
449
- renderContext: S(),
450
- previewKind: x(),
451
- gameSettings: g(),
452
- keyboardDocked: m(),
449
+ renderHost: x(),
450
+ renderContext: C(),
451
+ previewKind: S(),
452
+ gameSettings: _(),
453
+ keyboardDocked: h(),
453
454
  settingsComponents: null
454
455
  };
455
456
  }
456
- function C(e) {
457
- localStorage.setItem(i.gameSettings, JSON.stringify(e));
457
+ function w(e) {
458
+ localStorage.setItem(a.gameSettings, JSON.stringify(e));
458
459
  }
459
- function w() {
460
- localStorage.removeItem(i.gameSettings);
460
+ function T() {
461
+ localStorage.removeItem(a.gameSettings);
461
462
  }
462
463
  function te(e) {
463
- localStorage.setItem(i.collapsed, String(e));
464
+ localStorage.setItem(a.collapsed, String(e));
464
465
  }
465
466
  function ne(e) {
466
- localStorage.setItem(i.tab, e);
467
- }
468
- function T(e) {
469
- localStorage.setItem(i.theme, e);
467
+ localStorage.setItem(a.tab, e);
470
468
  }
471
469
  function E(e) {
472
- localStorage.setItem(i.fixtureCategory, e);
470
+ localStorage.setItem(a.theme, e);
473
471
  }
474
472
  function D(e) {
475
- localStorage.setItem(i.fixturePuzzle, e);
473
+ localStorage.setItem(a.fixtureCategory, e);
476
474
  }
477
- function O() {
478
- localStorage.removeItem(i.fixturePuzzle);
475
+ function O(e) {
476
+ localStorage.setItem(a.fixturePuzzle, e);
479
477
  }
480
- function k(e) {
481
- e ? localStorage.setItem(i.renderHost, e) : localStorage.removeItem(i.renderHost);
478
+ function k() {
479
+ localStorage.removeItem(a.fixturePuzzle);
482
480
  }
483
481
  function A(e) {
484
- localStorage.setItem(i.previewKind, e);
482
+ e ? localStorage.setItem(a.renderHost, e) : localStorage.removeItem(a.renderHost);
485
483
  }
486
484
  function j(e) {
487
- e ? localStorage.setItem(i.renderContext, e) : localStorage.removeItem(i.renderContext);
485
+ localStorage.setItem(a.previewKind, e);
488
486
  }
489
- function re(e) {
487
+ function M(e) {
488
+ e ? localStorage.setItem(a.renderContext, e) : localStorage.removeItem(a.renderContext);
489
+ }
490
+ function N(e) {
490
491
  let t = [];
491
492
  return {
492
493
  log(n, r, i) {
@@ -511,13 +512,13 @@ function re(e) {
511
512
  }
512
513
  };
513
514
  }
514
- function M(e, t, n) {
515
+ function P(e, t, n) {
515
516
  console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
516
517
  type: e,
517
518
  data: t
518
519
  }, "*");
519
520
  }
520
- function N(e, t) {
521
+ function re(e, t) {
521
522
  let n = (n) => {
522
523
  var r, i, a;
523
524
  if (!(!(n == null || (r = n.data) == null) && r.type)) return;
@@ -546,7 +547,7 @@ function ie(e) {
546
547
  }), t;
547
548
  }
548
549
  /** Render fixture selector HTML */
549
- function P(e, t) {
550
+ function F(e, t) {
550
551
  return e.length === 0 ? "" : `
551
552
  <div class="simulator-fixtures">
552
553
  <div class="simulator-field">
@@ -563,7 +564,7 @@ function P(e, t) {
563
564
  `;
564
565
  }
565
566
  /** Update puzzle select options based on selected category */
566
- function F(e, t, n, r) {
567
+ function I(e, t, n, r) {
567
568
  let i = t.get(n);
568
569
  if (!i) return null;
569
570
  let a = Array.from(i.keys()), o = r;
@@ -574,7 +575,7 @@ function F(e, t, n, r) {
574
575
  return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
575
576
  }
576
577
  /** Get puzzle data from fixtures */
577
- function I(e, t, n) {
578
+ function L(e, t, n) {
578
579
  var r, i;
579
580
  return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
580
581
  }
@@ -602,19 +603,19 @@ function oe() {
602
603
  selectedCategory: e.state.selectedCategory,
603
604
  selectedPuzzle: e.state.selectedPuzzle
604
605
  }), e.fixtures && e.fixtureCategories.length > 0 && i) {
605
- i.innerHTML = P(e.fixtureCategories, e.state.selectedCategory);
606
+ i.innerHTML = F(e.fixtureCategories, e.state.selectedCategory);
606
607
  let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
607
608
  if (t && n && e.state.selectedCategory) {
608
- e.state.selectedPuzzle = F(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
609
- let r = I(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
609
+ e.state.selectedPuzzle = I(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
610
+ let r = L(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
610
611
  console.log("Simulator: Loading fixture puzzle", {
611
612
  category: e.state.selectedCategory,
612
613
  puzzle: e.state.selectedPuzzle,
613
614
  hasPuzzleData: !!r
614
- }), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && E(e.state.selectedCategory), e.state.selectedPuzzle && D(e.state.selectedPuzzle)), t.addEventListener("change", () => {
615
- console.log("Simulator: Category changed, reloading...", t.value), u(), E(t.value), O(), window.location.reload();
615
+ }), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && D(e.state.selectedCategory), e.state.selectedPuzzle && O(e.state.selectedPuzzle)), t.addEventListener("change", () => {
616
+ console.log("Simulator: Category changed, reloading...", t.value), d(), D(t.value), k(), window.location.reload();
616
617
  }), n.addEventListener("change", () => {
617
- console.log("Simulator: Puzzle changed, reloading...", n.value), u(), D(n.value), window.location.reload();
618
+ console.log("Simulator: Puzzle changed, reloading...", n.value), d(), O(n.value), window.location.reload();
618
619
  });
619
620
  }
620
621
  }
@@ -640,10 +641,10 @@ function oe() {
640
641
  * Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
641
642
  * must stay self-contained.
642
643
  */
643
- function L(e) {
644
+ function R(e) {
644
645
  var t;
645
646
  if (typeof e != "string") return e;
646
- let n = (t = R(e)) == null ? {
647
+ let n = (t = z(e)) == null ? {
647
648
  width: 800,
648
649
  height: 800
649
650
  } : t;
@@ -654,7 +655,7 @@ function L(e) {
654
655
  };
655
656
  }
656
657
  /** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
657
- function R(e) {
658
+ function z(e) {
658
659
  var t, n, r, i;
659
660
  let a = e.indexOf("<svg");
660
661
  if (a === -1) return;
@@ -672,9 +673,9 @@ function R(e) {
672
673
  height: u
673
674
  };
674
675
  }
675
- var z = "simulator-saved-states";
676
+ var B = "simulator-saved-states";
676
677
  /** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
677
- function B() {
678
+ function se() {
678
679
  let e = globalThis;
679
680
  for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
680
681
  name: t,
@@ -683,8 +684,8 @@ function B() {
683
684
  return null;
684
685
  }
685
686
  /** Generate a small thumbnail SVG for a given input string */
686
- function se(e, t) {
687
- let n = B();
687
+ function V(e, t) {
688
+ let n = se();
688
689
  if (!n) return "";
689
690
  try {
690
691
  var r;
@@ -694,13 +695,13 @@ function se(e, t) {
694
695
  strict: !0,
695
696
  renderHost: "game"
696
697
  };
697
- return L(n.fn(i, t, a)).svg;
698
+ return R(n.fn(i, t, a)).svg;
698
699
  } catch (e) {
699
700
  return "";
700
701
  }
701
702
  }
702
- var V = [];
703
- function H(e, t = 8) {
703
+ var H = [];
704
+ function U(e, t = 8) {
704
705
  let n = 14 * t + 8 + 4;
705
706
  e.style.height = "auto";
706
707
  let r = Math.min(Math.max(e.scrollHeight, 40), n);
@@ -724,43 +725,43 @@ function ce() {
724
725
  let i = n.getElement(".data-view-container");
725
726
  i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
726
727
  e.classList.toggle("active", e.id === `data-subtab-${t}`);
727
- }), t === "edit" ? de(n) : t === "history" ? U(n) : t === "saves" && W(n);
728
+ }), t === "edit" ? de(n) : t === "history" ? W(n) : t === "saves" && G(n);
728
729
  });
729
730
  });
730
- let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), s = n.getElement("#simulator-puzzle-apply"), u = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
731
+ let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), s = n.getElement("#simulator-puzzle-apply"), c = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
731
732
  setTimeout(() => {
732
- i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, H(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, H(a)), fe(n);
733
+ i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, U(a)), fe(n);
733
734
  }, 0), i == null || i.addEventListener("input", () => {
734
- H(i);
735
+ U(i);
735
736
  let t = i.value !== e;
736
737
  s && (s.disabled = !t);
737
738
  }), a == null || a.addEventListener("input", () => {
738
- H(a);
739
+ U(a);
739
740
  let e = a.value !== t;
740
741
  d && (d.disabled = !e);
741
742
  }), o == null || o.addEventListener("click", () => {
742
743
  if (n.state.appliedPuzzleOverride !== null) {
743
- l("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
744
+ u("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
744
745
  return;
745
746
  }
746
- i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, H(i), s && (s.disabled = !0));
747
+ i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i), s && (s.disabled = !0));
747
748
  }), s == null || s.addEventListener("click", () => {
748
749
  if (i) {
749
- if (!c("puzzle", i.value)) {
750
+ if (!l("puzzle", i.value)) {
750
751
  n.updateStatus("Could not store puzzle — storage unavailable", "paused");
751
752
  return;
752
753
  }
753
- l("input"), s.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
754
+ u("input"), s.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
754
755
  }
755
- }), u == null || u.addEventListener("click", () => {
756
+ }), c == null || c.addEventListener("click", () => {
756
757
  if (n.state.appliedInputOverride !== null) {
757
- l("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
758
+ u("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
758
759
  return;
759
760
  }
760
- a && (a.value = t, H(a), d && (d.disabled = !0));
761
+ a && (a.value = t, U(a), d && (d.disabled = !0));
761
762
  }), d == null || d.addEventListener("click", () => {
762
763
  if (a) {
763
- if (!c("input", a.value)) {
764
+ if (!l("input", a.value)) {
764
765
  n.updateStatus("Could not store input — storage unavailable", "paused");
765
766
  return;
766
767
  }
@@ -769,7 +770,7 @@ function ce() {
769
770
  });
770
771
  let f = n.getElement("#simulator-history-clear");
771
772
  f == null || f.addEventListener("click", () => {
772
- V = [], U(n);
773
+ H = [], W(n);
773
774
  });
774
775
  let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
775
776
  m == null || m.addEventListener("click", () => {
@@ -780,49 +781,49 @@ function ce() {
780
781
  inputStr: n.state.currentInputStr,
781
782
  timestamp: Date.now()
782
783
  };
783
- e.push(t), localStorage.setItem(z, JSON.stringify(e)), p.value = "", W(n);
784
- }), W(n);
784
+ e.push(t), localStorage.setItem(B, JSON.stringify(e)), p.value = "", G(n);
785
+ }), G(n);
785
786
  },
786
787
  onActivate(n) {
787
- e = n.state.originalPuzzle, t = n.state.currentInputStr, de(n), U(n);
788
+ e = n.state.originalPuzzle, t = n.state.currentInputStr, de(n), W(n);
788
789
  },
789
790
  onMessage(e, n, r) {
790
791
  var i, a;
791
792
  let o = r.getElement("#simulator-input"), s = r.getElement("#simulator-input-apply"), c = (i = n == null || (a = n.input) == null ? void 0 : a.boardState) == null ? n == null ? void 0 : n.boardState : i;
792
793
  if (e === "UPLOAD_NEW_GAME_STATE" && c) {
793
- if (r.state.currentInputStr = c, V.length === 0 || V[V.length - 1].value !== c) {
794
- V.push({
794
+ if (r.state.currentInputStr = c, H.length === 0 || H[H.length - 1].value !== c) {
795
+ H.push({
795
796
  value: c,
796
797
  timestamp: Date.now()
797
- }), V.length > 100 && (V = V.slice(-100));
798
+ }), H.length > 100 && (H = H.slice(-100));
798
799
  let e = r.getElement("#data-subtab-history");
799
- e != null && e.classList.contains("active") && U(r);
800
+ e != null && e.classList.contains("active") && W(r);
800
801
  }
801
- o && document.activeElement !== o && (o.value !== c && (o.value = c, H(o)), t = c, s && (s.disabled = !0));
802
+ o && document.activeElement !== o && (o.value !== c && (o.value = c, U(o)), t = c, s && (s.disabled = !0));
802
803
  }
803
804
  }
804
805
  };
805
806
  }
806
807
  function le() {
807
808
  try {
808
- let e = localStorage.getItem(z);
809
+ let e = localStorage.getItem(B);
809
810
  return e ? JSON.parse(e) : [];
810
811
  } catch (e) {
811
812
  return [];
812
813
  }
813
814
  }
814
- function U(e) {
815
+ function W(e) {
815
816
  let t = e.getElement("#simulator-history-list");
816
817
  if (t) {
817
- if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), V.length === 0) {
818
+ if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), H.length === 0) {
818
819
  t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
819
820
  return;
820
821
  }
821
- t.innerHTML = [...V].reverse().map((t, n) => {
822
- let r = V.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
822
+ t.innerHTML = [...H].reverse().map((t, n) => {
823
+ let r = H.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
823
824
  return `
824
825
  <div class="history-item" data-history-idx="${r}">
825
- <div class="history-item-thumb">${se(e, t.value)}</div>
826
+ <div class="history-item-thumb">${V(e, t.value)}</div>
826
827
  <div class="history-item-content">
827
828
  <div class="history-item-header">
828
829
  <span class="history-item-num">#${r + 1}</span>
@@ -835,18 +836,18 @@ function U(e) {
835
836
  `;
836
837
  }).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
837
838
  t.addEventListener("click", (t) => {
838
- let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = V[n];
839
+ let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = H[n];
839
840
  if (r) {
840
841
  let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
841
842
  t == null || t.click();
842
843
  let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
843
- n && (n.value = r.value, H(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
844
+ n && (n.value = r.value, U(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
844
845
  }
845
846
  });
846
847
  });
847
848
  }
848
849
  }
849
- function W(e) {
850
+ function G(e) {
850
851
  let t = e.getElement("#simulator-saves-list");
851
852
  if (!t) return;
852
853
  let n = le();
@@ -872,8 +873,8 @@ function W(e) {
872
873
  t.addEventListener("click", (t) => {
873
874
  let r = n[parseInt(t.target.getAttribute("data-save-idx") || "0")];
874
875
  if (r) {
875
- if (!c("puzzle", r.puzzleStr) || !c("input", r.inputStr)) {
876
- u(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
876
+ if (!l("puzzle", r.puzzleStr) || !l("input", r.inputStr)) {
877
+ d(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
877
878
  return;
878
879
  }
879
880
  e.updateStatus(`Loading: ${r.name}`, "waiting"), window.location.reload();
@@ -882,7 +883,7 @@ function W(e) {
882
883
  }), t.querySelectorAll(".save-delete-btn").forEach((t) => {
883
884
  t.addEventListener("click", (t) => {
884
885
  let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
885
- localStorage.setItem(z, JSON.stringify(i)), W(e);
886
+ localStorage.setItem(B, JSON.stringify(i)), G(e);
886
887
  });
887
888
  });
888
889
  }
@@ -891,7 +892,7 @@ function ue(e) {
891
892
  }
892
893
  function de(e) {
893
894
  let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
894
- t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, H(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, H(n), i && (i.disabled = !0)), fe(e);
895
+ t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, U(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, U(n), i && (i.disabled = !0)), fe(e);
895
896
  }
896
897
  function fe(e) {
897
898
  let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
@@ -1025,7 +1026,7 @@ function ge() {
1025
1026
  }
1026
1027
  };
1027
1028
  }
1028
- var _e = /* @__PURE__ */ n(((e) => {
1029
+ var _e = /* @__PURE__ */ r(((e) => {
1029
1030
  var t = { document: {} }, n = Object.prototype.hasOwnProperty, r = function(e) {
1030
1031
  return v(e) ? e.toLowerCase() : e;
1031
1032
  }, i = Array.isArray;
@@ -1221,9 +1222,9 @@ var _e = /* @__PURE__ */ n(((e) => {
1221
1222
  function S(e) {
1222
1223
  return e && e.$evalAsync && e.$watch;
1223
1224
  }
1224
- var ee = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;
1225
- function C(e) {
1226
- return e && y(e.length) && ee.test(s.call(e));
1225
+ var C = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;
1226
+ function ee(e) {
1227
+ return e && y(e.length) && C.test(s.call(e));
1227
1228
  }
1228
1229
  function w(e) {
1229
1230
  return s.call(e) === "[object ArrayBuffer]";
@@ -1293,10 +1294,10 @@ var _e = /* @__PURE__ */ n(((e) => {
1293
1294
  </file>
1294
1295
  </example>
1295
1296
  */
1296
- function te(e, t) {
1297
+ function T(e, t) {
1297
1298
  var r = [], a = [];
1298
1299
  if (t) {
1299
- if (C(t) || w(t)) throw l("cpta", "Can't copy! TypedArray destination cannot be mutated.");
1300
+ if (ee(t) || w(t)) throw l("cpta", "Can't copy! TypedArray destination cannot be mutated.");
1300
1301
  if (e === t) throw l("cpi", "Can't copy! Source and destination are identical.");
1301
1302
  return i(t) ? t.length = 0 : d(t, function(e, n) {
1302
1303
  n !== "$$hashKey" && delete t[n];
@@ -1365,7 +1366,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1365
1366
  * @param {...*} args Optional arguments to be prebound to the `fn` function call.
1366
1367
  * @returns {function()} Function that wraps the `fn` with all the specified bindings.
1367
1368
  */
1368
- function ne(e, n) {
1369
+ function te(e, n) {
1369
1370
  var r = n;
1370
1371
  return typeof e == "string" && e.charAt(0) === "$" && e.charAt(1) === "$" ? r = void 0 : x(n) ? r = "$WINDOW" : n && t.document === n ? r = "$DOCUMENT" : S(n) && (r = "$SCOPE"), r;
1371
1372
  }
@@ -1380,13 +1381,13 @@ var _e = /* @__PURE__ */ n(((e) => {
1380
1381
  *
1381
1382
  * @returns {Object}
1382
1383
  */
1383
- function T() {
1384
+ function ne() {
1384
1385
  return Object.create(null);
1385
1386
  }
1386
1387
  function E(e) {
1387
1388
  var t = [];
1388
1389
  return JSON.stringify(e, function(e, n) {
1389
- if (n = ne(e, n), g(n)) {
1390
+ if (n = te(e, n), g(n)) {
1390
1391
  if (t.indexOf(n) >= 0) return "...";
1391
1392
  t.push(n);
1392
1393
  }
@@ -1439,11 +1440,11 @@ var _e = /* @__PURE__ */ n(((e) => {
1439
1440
  function A(e) {
1440
1441
  return e + "";
1441
1442
  }
1442
- var j = T();
1443
+ var j = ne();
1443
1444
  d("+ - * / % === !== == != < > <= >= && || ?? ! = | ?".split(" "), function(e) {
1444
1445
  j[e] = !0;
1445
1446
  });
1446
- var re = {
1447
+ var M = {
1447
1448
  n: "\n",
1448
1449
  f: "\f",
1449
1450
  r: "\r",
@@ -1455,11 +1456,11 @@ var _e = /* @__PURE__ */ n(((e) => {
1455
1456
  /**
1456
1457
  * @constructor
1457
1458
  */
1458
- function M(e) {
1459
+ function N(e) {
1459
1460
  this.options = e || {};
1460
1461
  }
1461
- M.prototype = {
1462
- constructor: M,
1462
+ N.prototype = {
1463
+ constructor: N,
1463
1464
  lex: function(e) {
1464
1465
  for (this.text = e, this.index = 0, this.tokens = []; this.index < this.text.length;) {
1465
1466
  var t = this.text.charAt(this.index);
@@ -1576,7 +1577,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1576
1577
  text: "+",
1577
1578
  operator: !0
1578
1579
  });
1579
- for (var l = new M(this.options).lex(c), u = 0, d = l.length; u < d; u++) this.tokens.push(l[u]);
1580
+ for (var l = new N(this.options).lex(c), u = 0, d = l.length; u < d; u++) this.tokens.push(l[u]);
1580
1581
  this.tokens.push({
1581
1582
  index: this.index,
1582
1583
  text: "+",
@@ -1589,7 +1590,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1589
1590
  var f = this.text.substring(this.index + 1, this.index + 5);
1590
1591
  f.match(/[\da-f]{4}/i) || this.throwError("Invalid unicode escape [\\u" + f + "]"), this.index += 4, n += String.fromCharCode(parseInt(f, 16));
1591
1592
  } else {
1592
- var p = re[o];
1593
+ var p = M[o];
1593
1594
  n += p || o;
1594
1595
  }
1595
1596
  a = !1;
@@ -1608,10 +1609,10 @@ var _e = /* @__PURE__ */ n(((e) => {
1608
1609
  this.throwError("Unterminated quote", t);
1609
1610
  }
1610
1611
  };
1611
- function N(e, t) {
1612
+ function P(e, t) {
1612
1613
  this.lexer = e, this.options = t;
1613
1614
  }
1614
- N.Program = "Program", N.ExpressionStatement = "ExpressionStatement", N.AssignmentExpression = "AssignmentExpression", N.ConditionalExpression = "ConditionalExpression", N.LogicalExpression = "LogicalExpression", N.BinaryExpression = "BinaryExpression", N.UnaryExpression = "UnaryExpression", N.CallExpression = "CallExpression", N.MemberExpression = "MemberExpression", N.Identifier = "Identifier", N.Literal = "Literal", N.ArrayExpression = "ArrayExpression", N.Property = "Property", N.ObjectExpression = "ObjectExpression", N.ThisExpression = "ThisExpression", N.LocalsExpression = "LocalsExpression", N.NGValueParameter = "NGValueParameter", N.prototype = {
1615
+ P.Program = "Program", P.ExpressionStatement = "ExpressionStatement", P.AssignmentExpression = "AssignmentExpression", P.ConditionalExpression = "ConditionalExpression", P.LogicalExpression = "LogicalExpression", P.BinaryExpression = "BinaryExpression", P.UnaryExpression = "UnaryExpression", P.CallExpression = "CallExpression", P.MemberExpression = "MemberExpression", P.Identifier = "Identifier", P.Literal = "Literal", P.ArrayExpression = "ArrayExpression", P.Property = "Property", P.ObjectExpression = "ObjectExpression", P.ThisExpression = "ThisExpression", P.LocalsExpression = "LocalsExpression", P.NGValueParameter = "NGValueParameter", P.prototype = {
1615
1616
  ast: function(e) {
1616
1617
  this.text = e, this.tokens = this.lexer.lex(e);
1617
1618
  var t = this.program();
@@ -1619,13 +1620,13 @@ var _e = /* @__PURE__ */ n(((e) => {
1619
1620
  },
1620
1621
  program: function() {
1621
1622
  for (var e = [];;) if (this.tokens.length > 0 && !this.peek("}", ")", ";", "]") && e.push(this.expressionStatement()), !this.expect(";")) return {
1622
- type: N.Program,
1623
+ type: P.Program,
1623
1624
  body: e
1624
1625
  };
1625
1626
  },
1626
1627
  expressionStatement: function() {
1627
1628
  return {
1628
- type: N.ExpressionStatement,
1629
+ type: P.ExpressionStatement,
1629
1630
  expression: this.filterChain()
1630
1631
  };
1631
1632
  },
@@ -1639,9 +1640,9 @@ var _e = /* @__PURE__ */ n(((e) => {
1639
1640
  assignment: function() {
1640
1641
  var e = this.ternary();
1641
1642
  if (this.expect("=")) {
1642
- if (!oe(e)) throw k("lval", "Trying to assign a value to a non l-value");
1643
+ if (!ae(e)) throw k("lval", "Trying to assign a value to a non l-value");
1643
1644
  e = {
1644
- type: N.AssignmentExpression,
1645
+ type: P.AssignmentExpression,
1645
1646
  left: e,
1646
1647
  right: this.assignment(),
1647
1648
  operator: "="
@@ -1652,7 +1653,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1652
1653
  ternary: function() {
1653
1654
  var e = this.nullishCoalescing(), t, n;
1654
1655
  return this.expect("?") && (t = this.expression(), this.consume(":")) ? (n = this.expression(), {
1655
- type: N.ConditionalExpression,
1656
+ type: P.ConditionalExpression,
1656
1657
  test: e,
1657
1658
  alternate: t,
1658
1659
  consequent: n
@@ -1660,7 +1661,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1660
1661
  },
1661
1662
  nullishCoalescing: function() {
1662
1663
  for (var e = this.logicalOR(); this.expect("??");) e = {
1663
- type: N.LogicalExpression,
1664
+ type: P.LogicalExpression,
1664
1665
  operator: "??",
1665
1666
  left: e,
1666
1667
  right: this.logicalOR()
@@ -1669,7 +1670,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1669
1670
  },
1670
1671
  logicalOR: function() {
1671
1672
  for (var e = this.logicalAND(); this.expect("||");) e = {
1672
- type: N.LogicalExpression,
1673
+ type: P.LogicalExpression,
1673
1674
  operator: "||",
1674
1675
  left: e,
1675
1676
  right: this.logicalAND()
@@ -1678,7 +1679,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1678
1679
  },
1679
1680
  logicalAND: function() {
1680
1681
  for (var e = this.equality(); this.expect("&&");) e = {
1681
- type: N.LogicalExpression,
1682
+ type: P.LogicalExpression,
1682
1683
  operator: "&&",
1683
1684
  left: e,
1684
1685
  right: this.equality()
@@ -1687,7 +1688,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1687
1688
  },
1688
1689
  equality: function() {
1689
1690
  for (var e = this.relational(), t; t = this.expect("==", "!=", "===", "!==");) e = {
1690
- type: N.BinaryExpression,
1691
+ type: P.BinaryExpression,
1691
1692
  operator: t.text,
1692
1693
  left: e,
1693
1694
  right: this.relational()
@@ -1696,7 +1697,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1696
1697
  },
1697
1698
  relational: function() {
1698
1699
  for (var e = this.additive(), t; t = this.expect("<", ">", "<=", ">=");) e = {
1699
- type: N.BinaryExpression,
1700
+ type: P.BinaryExpression,
1700
1701
  operator: t.text,
1701
1702
  left: e,
1702
1703
  right: this.additive()
@@ -1705,7 +1706,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1705
1706
  },
1706
1707
  additive: function() {
1707
1708
  for (var e = this.multiplicative(), t; t = this.expect("+", "-");) e = {
1708
- type: N.BinaryExpression,
1709
+ type: P.BinaryExpression,
1709
1710
  operator: t.text,
1710
1711
  left: e,
1711
1712
  right: this.multiplicative()
@@ -1714,7 +1715,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1714
1715
  },
1715
1716
  multiplicative: function() {
1716
1717
  for (var e = this.unary(), t; t = this.expect("*", "/", "%");) e = {
1717
- type: N.BinaryExpression,
1718
+ type: P.BinaryExpression,
1718
1719
  operator: t.text,
1719
1720
  left: e,
1720
1721
  right: this.unary()
@@ -1724,7 +1725,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1724
1725
  unary: function() {
1725
1726
  var e;
1726
1727
  return (e = this.expect("+", "-", "!")) ? {
1727
- type: N.UnaryExpression,
1728
+ type: P.UnaryExpression,
1728
1729
  operator: e.text,
1729
1730
  prefix: !0,
1730
1731
  argument: this.unary()
@@ -1732,21 +1733,21 @@ var _e = /* @__PURE__ */ n(((e) => {
1732
1733
  },
1733
1734
  primary: function() {
1734
1735
  var e;
1735
- this.expect("(") ? (e = this.filterChain(), this.consume(")")) : this.expect("[") ? e = this.arrayDeclaration() : this.expect("{") ? e = this.object() : this.selfReferential.hasOwnProperty(this.peek().text) ? e = te(this.selfReferential[this.consume().text]) : this.options.literals.hasOwnProperty(this.peek().text) ? e = {
1736
- type: N.Literal,
1736
+ this.expect("(") ? (e = this.filterChain(), this.consume(")")) : this.expect("[") ? e = this.arrayDeclaration() : this.expect("{") ? e = this.object() : this.selfReferential.hasOwnProperty(this.peek().text) ? e = T(this.selfReferential[this.consume().text]) : this.options.literals.hasOwnProperty(this.peek().text) ? e = {
1737
+ type: P.Literal,
1737
1738
  value: this.options.literals[this.consume().text]
1738
1739
  } : this.peek().identifier ? e = this.identifier() : this.peek().constant ? e = this.constant() : this.throwError("not a primary expression", this.peek());
1739
1740
  for (var t; t = this.expect("(", "[", ".");) t.text === "(" ? (e = {
1740
- type: N.CallExpression,
1741
+ type: P.CallExpression,
1741
1742
  callee: e,
1742
1743
  arguments: this.parseArguments()
1743
1744
  }, this.consume(")")) : t.text === "[" ? (e = {
1744
- type: N.MemberExpression,
1745
+ type: P.MemberExpression,
1745
1746
  object: e,
1746
1747
  property: this.expression(),
1747
1748
  computed: !0
1748
1749
  }, this.consume("]")) : t.text === "." ? e = {
1749
- type: N.MemberExpression,
1750
+ type: P.MemberExpression,
1750
1751
  object: e,
1751
1752
  property: this.identifier(),
1752
1753
  computed: !1
@@ -1755,7 +1756,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1755
1756
  },
1756
1757
  filter: function(e) {
1757
1758
  for (var t = [e], n = {
1758
- type: N.CallExpression,
1759
+ type: P.CallExpression,
1759
1760
  callee: this.identifier(),
1760
1761
  arguments: t,
1761
1762
  filter: !0
@@ -1772,13 +1773,13 @@ var _e = /* @__PURE__ */ n(((e) => {
1772
1773
  identifier: function() {
1773
1774
  var e = this.consume();
1774
1775
  return e.identifier || this.throwError("is not a valid identifier", e), {
1775
- type: N.Identifier,
1776
+ type: P.Identifier,
1776
1777
  name: e.text
1777
1778
  };
1778
1779
  },
1779
1780
  constant: function() {
1780
1781
  return {
1781
- type: N.Literal,
1782
+ type: P.Literal,
1782
1783
  value: this.consume().value
1783
1784
  };
1784
1785
  },
@@ -1789,7 +1790,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1789
1790
  e.push(this.expression());
1790
1791
  } while (this.expect(","));
1791
1792
  return this.consume("]"), {
1792
- type: N.ArrayExpression,
1793
+ type: P.ArrayExpression,
1793
1794
  elements: e
1794
1795
  };
1795
1796
  },
@@ -1798,12 +1799,12 @@ var _e = /* @__PURE__ */ n(((e) => {
1798
1799
  if (this.peekToken().text !== "}") do {
1799
1800
  if (this.peek("}")) break;
1800
1801
  t = {
1801
- type: N.Property,
1802
+ type: P.Property,
1802
1803
  kind: "init"
1803
1804
  }, this.peek().constant ? (t.key = this.constant(), t.computed = !1, this.consume(":"), t.value = this.expression()) : this.peek().identifier ? (t.key = this.identifier(), t.computed = !1, this.peek(":") ? (this.consume(":"), t.value = this.expression()) : t.value = t.key) : this.peek("[") ? (this.consume("["), t.key = this.expression(), this.consume("]"), t.computed = !0, this.consume(":"), t.value = this.expression()) : this.throwError("invalid key", this.peek()), e.push(t);
1804
1805
  } while (this.expect(","));
1805
1806
  return this.consume("}"), {
1806
- type: N.ObjectExpression,
1807
+ type: P.ObjectExpression,
1807
1808
  properties: e
1808
1809
  };
1809
1810
  },
@@ -1834,10 +1835,10 @@ var _e = /* @__PURE__ */ n(((e) => {
1834
1835
  return i ? (this.tokens.shift(), i) : !1;
1835
1836
  }
1836
1837
  };
1837
- function ie(e, t) {
1838
+ function re(e, t) {
1838
1839
  return e === void 0 ? t : e;
1839
1840
  }
1840
- function P(e, t) {
1841
+ function ie(e, t) {
1841
1842
  return e === void 0 ? t : t === void 0 ? e : e + t;
1842
1843
  }
1843
1844
  function F(e, t) {
@@ -1848,77 +1849,77 @@ var _e = /* @__PURE__ */ n(((e) => {
1848
1849
  function I(e, t) {
1849
1850
  var n, r, i;
1850
1851
  switch (e.type) {
1851
- case N.Program:
1852
+ case P.Program:
1852
1853
  n = !0, d(e.body, function(e) {
1853
1854
  I(e.expression, t), n = n && e.expression.constant;
1854
1855
  }), e.constant = n;
1855
1856
  break;
1856
- case N.Literal:
1857
+ case P.Literal:
1857
1858
  e.constant = !0, e.toWatch = [];
1858
1859
  break;
1859
- case N.UnaryExpression:
1860
+ case P.UnaryExpression:
1860
1861
  I(e.argument, t), e.constant = e.argument.constant, e.toWatch = e.argument.toWatch;
1861
1862
  break;
1862
- case N.BinaryExpression:
1863
+ case P.BinaryExpression:
1863
1864
  I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.left.toWatch.concat(e.right.toWatch);
1864
1865
  break;
1865
- case N.LogicalExpression:
1866
+ case P.LogicalExpression:
1866
1867
  I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.constant ? [] : [e];
1867
1868
  break;
1868
- case N.ConditionalExpression:
1869
+ case P.ConditionalExpression:
1869
1870
  I(e.test, t), I(e.alternate, t), I(e.consequent, t), e.constant = e.test.constant && e.alternate.constant && e.consequent.constant, e.toWatch = e.constant ? [] : [e];
1870
1871
  break;
1871
- case N.Identifier:
1872
+ case P.Identifier:
1872
1873
  e.constant = !1, e.toWatch = [e];
1873
1874
  break;
1874
- case N.MemberExpression:
1875
+ case P.MemberExpression:
1875
1876
  I(e.object, t), e.computed && I(e.property, t), e.constant = e.object.constant && (!e.computed || e.property.constant), e.toWatch = [e];
1876
1877
  break;
1877
- case N.CallExpression:
1878
+ case P.CallExpression:
1878
1879
  i = e.filter ? F(t, e.callee.name) : !1, n = i, r = [], d(e.arguments, function(e) {
1879
1880
  I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1880
1881
  }), e.constant = n, e.toWatch = i ? r : [e];
1881
1882
  break;
1882
- case N.AssignmentExpression:
1883
+ case P.AssignmentExpression:
1883
1884
  I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = [e];
1884
1885
  break;
1885
- case N.ArrayExpression:
1886
+ case P.ArrayExpression:
1886
1887
  n = !0, r = [], d(e.elements, function(e) {
1887
1888
  I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1888
1889
  }), e.constant = n, e.toWatch = r;
1889
1890
  break;
1890
- case N.ObjectExpression:
1891
+ case P.ObjectExpression:
1891
1892
  n = !0, r = [], d(e.properties, function(e) {
1892
1893
  I(e.value, t), n = n && e.value.constant && !e.computed, e.value.constant || r.push.apply(r, e.value.toWatch);
1893
1894
  }), e.constant = n, e.toWatch = r;
1894
1895
  break;
1895
- case N.ThisExpression:
1896
+ case P.ThisExpression:
1896
1897
  e.constant = !1, e.toWatch = [];
1897
1898
  break;
1898
- case N.LocalsExpression:
1899
+ case P.LocalsExpression:
1899
1900
  e.constant = !1, e.toWatch = [];
1900
1901
  break;
1901
1902
  }
1902
1903
  }
1903
- function ae(e) {
1904
+ function L(e) {
1904
1905
  if (e.length === 1) {
1905
1906
  var t = e[0].expression, n = t.toWatch;
1906
1907
  return n.length === 1 && n[0] === t ? void 0 : n;
1907
1908
  }
1908
1909
  }
1909
- function oe(e) {
1910
- return e.type === N.Identifier || e.type === N.MemberExpression;
1910
+ function ae(e) {
1911
+ return e.type === P.Identifier || e.type === P.MemberExpression;
1911
1912
  }
1912
- function L(e) {
1913
- if (e.body.length === 1 && oe(e.body[0].expression)) return {
1914
- type: N.AssignmentExpression,
1913
+ function oe(e) {
1914
+ if (e.body.length === 1 && ae(e.body[0].expression)) return {
1915
+ type: P.AssignmentExpression,
1915
1916
  left: e.body[0].expression,
1916
- right: { type: N.NGValueParameter },
1917
+ right: { type: P.NGValueParameter },
1917
1918
  operator: "="
1918
1919
  };
1919
1920
  }
1920
1921
  function R(e) {
1921
- return e.body.length === 0 || e.body.length === 1 && (e.body[0].expression.type === N.Literal || e.body[0].expression.type === N.ArrayExpression || e.body[0].expression.type === N.ObjectExpression);
1922
+ return e.body.length === 0 || e.body.length === 1 && (e.body[0].expression.type === P.Literal || e.body[0].expression.type === P.ArrayExpression || e.body[0].expression.type === P.ObjectExpression);
1922
1923
  }
1923
1924
  function z(e) {
1924
1925
  return e.constant;
@@ -1945,12 +1946,12 @@ var _e = /* @__PURE__ */ n(((e) => {
1945
1946
  inputs: []
1946
1947
  }, I(n, t.$filter);
1947
1948
  var r = "", i;
1948
- if (this.stage = "assign", i = L(n)) {
1949
+ if (this.stage = "assign", i = oe(n)) {
1949
1950
  this.state.computing = "assign";
1950
1951
  var o = this.nextId();
1951
1952
  this.recurse(i, o), this.return_(o), r = "fn.assign=" + this.generateFunction("assign", "s,v,l");
1952
1953
  }
1953
- var s = ae(n.body);
1954
+ var s = L(n.body);
1954
1955
  t.stage = "inputs", d(s, function(e, n) {
1955
1956
  var r = "fn" + n;
1956
1957
  t.state[r] = {
@@ -1961,7 +1962,7 @@ var _e = /* @__PURE__ */ n(((e) => {
1961
1962
  var i = t.nextId();
1962
1963
  t.recurse(e, i), t.return_(i), t.state.inputs.push(r), e.watchId = n;
1963
1964
  }), this.state.computing = "fn", this.stage = "main", this.recurse(n);
1964
- var c = "\"" + this.USE + " " + this.STRICT + "\";\n" + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + r + this.watchFns() + "return fn;", l = Function("$filter", "getStringValue", "ifDefined", "plus", c)(this.$filter, A, ie, P), u = function(e, t, n, r) {
1965
+ var c = "\"" + this.USE + " " + this.STRICT + "\";\n" + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + r + this.watchFns() + "return fn;", l = Function("$filter", "getStringValue", "ifDefined", "plus", c)(this.$filter, A, re, ie), u = function(e, t, n, r) {
1965
1966
  return a(function() {
1966
1967
  return l(e, t, n, r);
1967
1968
  });
@@ -2002,35 +2003,35 @@ var _e = /* @__PURE__ */ n(((e) => {
2002
2003
  return;
2003
2004
  }
2004
2005
  switch (e.type) {
2005
- case N.Program:
2006
+ case P.Program:
2006
2007
  d(e.body, function(t, n) {
2007
2008
  c.recurse(t.expression, void 0, void 0, function(e) {
2008
2009
  s = e;
2009
2010
  }), n === e.body.length - 1 ? c.return_(s) : c.current().body.push(s, ";");
2010
2011
  });
2011
2012
  break;
2012
- case N.Literal:
2013
+ case P.Literal:
2013
2014
  u = this.escape(e.value), this.assign(t, u), r(t || u);
2014
2015
  break;
2015
- case N.UnaryExpression:
2016
+ case P.UnaryExpression:
2016
2017
  this.recurse(e.argument, void 0, void 0, function(e) {
2017
2018
  s = e;
2018
2019
  }), u = e.operator + "(" + this.ifDefined(s, 0) + ")", this.assign(t, u), r(u);
2019
2020
  break;
2020
- case N.BinaryExpression:
2021
+ case P.BinaryExpression:
2021
2022
  this.recurse(e.left, void 0, void 0, function(e) {
2022
2023
  o = e;
2023
2024
  }), this.recurse(e.right, void 0, void 0, function(e) {
2024
2025
  s = e;
2025
2026
  }), u = e.operator === "+" ? this.plus(o, s) : e.operator === "-" ? this.ifDefined(o, 0) + e.operator + this.ifDefined(s, 0) : "(" + o + ")" + e.operator + "(" + s + ")", this.assign(t, u), r(u);
2026
2027
  break;
2027
- case N.LogicalExpression:
2028
+ case P.LogicalExpression:
2028
2029
  t = t || this.nextId(), c.recurse(e.left, t), e.operator === "??" ? c.if_(c.or_(c.isNull(t), "typeof " + t + " === 'undefined'"), c.lazyRecurse(e.right, t)) : c.if_(e.operator === "&&" ? t : c.not(t), c.lazyRecurse(e.right, t)), r(t);
2029
2030
  break;
2030
- case N.ConditionalExpression:
2031
+ case P.ConditionalExpression:
2031
2032
  t = t || this.nextId(), c.recurse(e.test, t), c.if_(t, c.lazyRecurse(e.alternate, t), c.lazyRecurse(e.consequent, t)), r(t);
2032
2033
  break;
2033
- case N.Identifier:
2034
+ case P.Identifier:
2034
2035
  t = t || this.nextId();
2035
2036
  var m = c.current().inAssignment;
2036
2037
  n && (m ? n.context = this.assign(this.nextId(), "s") : n.context = c.stage === "inputs" ? "s" : this.assign(this.nextId(), this.getHasOwnProperty("l", e.name) + "?l:s"), n.computed = !1, n.name = e.name), c.if_(c.stage === "inputs" || c.not(c.getHasOwnProperty("l", e.name)), function() {
@@ -2044,17 +2045,17 @@ var _e = /* @__PURE__ */ n(((e) => {
2044
2045
  c.if_(c.hasOwnProperty_("l", e.name), c.lazyAssign(t, c.nonComputedMember("l", e.name)));
2045
2046
  }), r(t);
2046
2047
  break;
2047
- case N.MemberExpression:
2048
+ case P.MemberExpression:
2048
2049
  o = n && (n.context = this.nextId()) || this.nextId(), t = t || this.nextId(), c.recurse(e.object, o, void 0, function() {
2049
2050
  var a = null, l = c.current().inAssignment;
2050
- e.computed ? (s = c.nextId(), a = l || c.state.computing === "assign" ? c.unsafeComputedMember(o, s) : c.computedMember(o, s)) : (a = l || c.state.computing === "assign" ? c.unsafeNonComputedMember(o, e.property.name) : c.nonComputedMember(o, e.property.name), s = e.property.name), e.computed && e.property.type === N.Literal && c.recurse(e.property, s), c.if_(c.and_(c.notNull(o), c.or_(c.isNull(a), c.hasOwnProperty_(o, s, e.computed))), function() {
2051
- e.computed ? (e.property.type !== N.Literal && c.recurse(e.property, s), i && i !== 1 && c.if_(c.not(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !0, n.name = s)) : (i && i !== 1 && c.if_(c.isNull(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !1, n.name = e.property.name));
2051
+ e.computed ? (s = c.nextId(), a = l || c.state.computing === "assign" ? c.unsafeComputedMember(o, s) : c.computedMember(o, s)) : (a = l || c.state.computing === "assign" ? c.unsafeNonComputedMember(o, e.property.name) : c.nonComputedMember(o, e.property.name), s = e.property.name), e.computed && e.property.type === P.Literal && c.recurse(e.property, s), c.if_(c.and_(c.notNull(o), c.or_(c.isNull(a), c.hasOwnProperty_(o, s, e.computed))), function() {
2052
+ e.computed ? (e.property.type !== P.Literal && c.recurse(e.property, s), i && i !== 1 && c.if_(c.not(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !0, n.name = s)) : (i && i !== 1 && c.if_(c.isNull(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !1, n.name = e.property.name));
2052
2053
  }, function() {
2053
2054
  c.assign(t, "undefined");
2054
2055
  }), r(t);
2055
2056
  }, !!i);
2056
2057
  break;
2057
- case N.CallExpression:
2058
+ case P.CallExpression:
2058
2059
  t = t || this.nextId(), e.filter ? (s = c.filter(e.callee.name), l = [], d(e.arguments, function(e) {
2059
2060
  var t = c.nextId();
2060
2061
  c.recurse(e, t), l.push(t);
@@ -2070,38 +2071,38 @@ var _e = /* @__PURE__ */ n(((e) => {
2070
2071
  }), r(t);
2071
2072
  }));
2072
2073
  break;
2073
- case N.AssignmentExpression:
2074
+ case P.AssignmentExpression:
2074
2075
  s = this.nextId(), o = {}, c.current().inAssignment = !0, this.recurse(e.left, void 0, o, function() {
2075
2076
  c.if_(c.and_(c.notNull(o.context), c.or_(c.hasOwnProperty_(o.context, o.name), c.isNull(c.member(o.context, o.name, o.computed)))), function() {
2076
2077
  c.recurse(e.right, s), u = c.member(o.context, o.name, o.computed) + e.operator + s, c.assign(t, u), r(t || u);
2077
2078
  }), c.current().inAssignment = !1, c.recurse(e.right, s), c.current().inAssignment = !0;
2078
2079
  }, 1), c.current().inAssignment = !1;
2079
2080
  break;
2080
- case N.ArrayExpression:
2081
+ case P.ArrayExpression:
2081
2082
  l = [], d(e.elements, function(t) {
2082
2083
  c.recurse(t, e.constant ? void 0 : c.nextId(), void 0, function(e) {
2083
2084
  l.push(e);
2084
2085
  });
2085
2086
  }), u = "[" + l.join(",") + "]", this.assign(t, u), r(t || u);
2086
2087
  break;
2087
- case N.ObjectExpression:
2088
+ case P.ObjectExpression:
2088
2089
  l = [], f = !1, d(e.properties, function(e) {
2089
2090
  e.computed && (f = !0);
2090
2091
  }), f ? (t = t || this.nextId(), this.assign(t, "{}"), d(e.properties, function(e) {
2091
- e.computed ? (o = c.nextId(), c.recurse(e.key, o)) : o = e.key.type === N.Identifier ? e.key.name : "" + e.key.value, s = c.nextId(), c.recurse(e.value, s), c.assign(c.unsafeMember(t, o, e.computed), s);
2092
+ e.computed ? (o = c.nextId(), c.recurse(e.key, o)) : o = e.key.type === P.Identifier ? e.key.name : "" + e.key.value, s = c.nextId(), c.recurse(e.value, s), c.assign(c.unsafeMember(t, o, e.computed), s);
2092
2093
  })) : (d(e.properties, function(t) {
2093
2094
  c.recurse(t.value, e.constant ? void 0 : c.nextId(), void 0, function(e) {
2094
- l.push(c.escape(t.key.type === N.Identifier ? t.key.name : "" + t.key.value) + ":" + e);
2095
+ l.push(c.escape(t.key.type === P.Identifier ? t.key.name : "" + t.key.value) + ":" + e);
2095
2096
  });
2096
2097
  }), u = "{" + l.join(",") + "}", this.assign(t, u)), r(t || u);
2097
2098
  break;
2098
- case N.ThisExpression:
2099
+ case P.ThisExpression:
2099
2100
  this.assign(t, "s"), r(t || "s");
2100
2101
  break;
2101
- case N.LocalsExpression:
2102
+ case P.LocalsExpression:
2102
2103
  this.assign(t, "l"), r(t || "l");
2103
2104
  break;
2104
- case N.NGValueParameter:
2105
+ case P.NGValueParameter:
2105
2106
  this.assign(t, "v"), r(t || "v");
2106
2107
  break;
2107
2108
  }
@@ -2213,8 +2214,8 @@ var _e = /* @__PURE__ */ n(((e) => {
2213
2214
  var t = this, n = this.astBuilder.ast(e);
2214
2215
  I(n, t.$filter);
2215
2216
  var r, i;
2216
- (r = L(n)) && (i = this.recurse(r));
2217
- var o = ae(n.body), s;
2217
+ (r = oe(n)) && (i = this.recurse(r));
2218
+ var o = L(n.body), s;
2218
2219
  o && (s = [], d(o, function(e, n) {
2219
2220
  var r = t.recurse(e);
2220
2221
  e.input = r, s.push(r), e.watchId = n;
@@ -2247,14 +2248,14 @@ var _e = /* @__PURE__ */ n(((e) => {
2247
2248
  var r, i, a = this, o;
2248
2249
  if (e.input) return this.inputs(e.input, e.watchId);
2249
2250
  switch (e.type) {
2250
- case N.Literal: return this.value(e.value, t);
2251
- case N.UnaryExpression: return i = this.recurse(e.argument), this["unary" + e.operator](i, t);
2252
- case N.BinaryExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2253
- case N.LogicalExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2254
- case N.ConditionalExpression: return this["ternary?:"](this.recurse(e.test), this.recurse(e.alternate), this.recurse(e.consequent), t);
2255
- case N.Identifier: return a.identifier(e.name, t, n);
2256
- case N.MemberExpression: return r = this.recurse(e.object, !1, !!n), e.computed || (i = e.property.name), e.computed && (i = this.recurse(e.property)), e.computed ? this.computedMember(r, i, t, n) : this.nonComputedMember(r, i, t, n);
2257
- case N.CallExpression: return o = [], d(e.arguments, function(e) {
2251
+ case P.Literal: return this.value(e.value, t);
2252
+ case P.UnaryExpression: return i = this.recurse(e.argument), this["unary" + e.operator](i, t);
2253
+ case P.BinaryExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2254
+ case P.LogicalExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2255
+ case P.ConditionalExpression: return this["ternary?:"](this.recurse(e.test), this.recurse(e.alternate), this.recurse(e.consequent), t);
2256
+ case P.Identifier: return a.identifier(e.name, t, n);
2257
+ case P.MemberExpression: return r = this.recurse(e.object, !1, !!n), e.computed || (i = e.property.name), e.computed && (i = this.recurse(e.property)), e.computed ? this.computedMember(r, i, t, n) : this.nonComputedMember(r, i, t, n);
2258
+ case P.CallExpression: return o = [], d(e.arguments, function(e) {
2258
2259
  o.push(a.recurse(e));
2259
2260
  }), e.filter && (i = this.$filter(e.callee.name)), e.filter || (i = this.recurse(e.callee, !0)), e.filter ? function(e, n, r, a) {
2260
2261
  for (var s = [], c = 0; c < o.length; ++c) s.push(o[c](e, n, r, a));
@@ -2272,23 +2273,23 @@ var _e = /* @__PURE__ */ n(((e) => {
2272
2273
  }
2273
2274
  return t ? { value: c } : c;
2274
2275
  };
2275
- case N.AssignmentExpression: return r = this.recurse(e.left, !0, 1), i = this.recurse(e.right), function(e, n, a, o) {
2276
+ case P.AssignmentExpression: return r = this.recurse(e.left, !0, 1), i = this.recurse(e.right), function(e, n, a, o) {
2276
2277
  var s = r(e, !1, a, o), c = i(e, n, a, o);
2277
2278
  return s.context[s.name] = c, t ? { value: c } : c;
2278
2279
  };
2279
- case N.ArrayExpression: return o = [], d(e.elements, function(e) {
2280
+ case P.ArrayExpression: return o = [], d(e.elements, function(e) {
2280
2281
  o.push(a.recurse(e));
2281
2282
  }), function(e, n, r, i) {
2282
2283
  for (var a = [], s = 0; s < o.length; ++s) a.push(o[s](e, n, r, i));
2283
2284
  return t ? { value: a } : a;
2284
2285
  };
2285
- case N.ObjectExpression: return o = [], d(e.properties, function(e) {
2286
+ case P.ObjectExpression: return o = [], d(e.properties, function(e) {
2286
2287
  e.computed ? o.push({
2287
2288
  key: a.recurse(e.key),
2288
2289
  computed: !0,
2289
2290
  value: a.recurse(e.value)
2290
2291
  }) : o.push({
2291
- key: e.key.type === N.Identifier ? e.key.name : "" + e.key.value,
2292
+ key: e.key.type === P.Identifier ? e.key.name : "" + e.key.value,
2292
2293
  computed: !1,
2293
2294
  value: a.recurse(e.value)
2294
2295
  });
@@ -2296,13 +2297,13 @@ var _e = /* @__PURE__ */ n(((e) => {
2296
2297
  for (var a = {}, s = 0; s < o.length; ++s) o[s].computed ? a[o[s].key(e, n, r, i)] = o[s].value(e, n, r, i) : a[o[s].key] = o[s].value(e, n, r, i);
2297
2298
  return t ? { value: a } : a;
2298
2299
  };
2299
- case N.ThisExpression: return function(e) {
2300
+ case P.ThisExpression: return function(e) {
2300
2301
  return t ? { value: e } : e;
2301
2302
  };
2302
- case N.LocalsExpression: return function(e, n) {
2303
+ case P.LocalsExpression: return function(e, n) {
2303
2304
  return t ? { value: n } : n;
2304
2305
  };
2305
- case N.NGValueParameter: return function(e, n, r) {
2306
+ case P.NGValueParameter: return function(e, n, r) {
2306
2307
  return t ? { value: r } : r;
2307
2308
  };
2308
2309
  }
@@ -2327,7 +2328,7 @@ var _e = /* @__PURE__ */ n(((e) => {
2327
2328
  },
2328
2329
  "binary+": function(e, t, n) {
2329
2330
  return function(r, i, a, o) {
2330
- var s = P(e(r, i, a, o), t(r, i, a, o));
2331
+ var s = ie(e(r, i, a, o), t(r, i, a, o));
2331
2332
  return n ? { value: s } : s;
2332
2333
  };
2333
2334
  },
@@ -2480,15 +2481,15 @@ var _e = /* @__PURE__ */ n(((e) => {
2480
2481
  * @constructor
2481
2482
  */
2482
2483
  var V = function(e, t, n) {
2483
- this.lexer = e, this.$filter = t, n = n || {}, n.handleThis = n.handleThis == null ? !0 : n.handleThis, this.options = n, this.ast = new N(e, n), this.ast.selfReferential = { $locals: { type: N.LocalsExpression } }, n.handleThis && (this.ast.selfReferential.this = { type: N.ThisExpression }), this.astCompiler = n.csp ? new se(this.ast, t) : new B(this.ast, t);
2484
+ this.lexer = e, this.$filter = t, n = n || {}, n.handleThis = n.handleThis == null ? !0 : n.handleThis, this.options = n, this.ast = new P(e, n), this.ast.selfReferential = { $locals: { type: P.LocalsExpression } }, n.handleThis && (this.ast.selfReferential.this = { type: P.ThisExpression }), this.astCompiler = n.csp ? new se(this.ast, t) : new B(this.ast, t);
2484
2485
  };
2485
2486
  V.prototype = {
2486
2487
  constructor: V,
2487
2488
  parse: function(e) {
2488
2489
  return this.astCompiler.compile(e);
2489
2490
  }
2490
- }, e.Lexer = M, e.Parser = V;
2491
- })), ve = (/* @__PURE__ */ n(((e) => {
2491
+ }, e.Lexer = N, e.Parser = V;
2492
+ })), ve = (/* @__PURE__ */ r(((e) => {
2492
2493
  var t = _e(), n = {}, r = t.Lexer, i = t.Parser;
2493
2494
  function a(e) {
2494
2495
  return e = e || {}, e.filters && (e.cache = e.cache || {}), e.cache = e.cache || s.cache, e.filters = e.filters || n, e;
@@ -2619,15 +2620,15 @@ function we(e) {
2619
2620
  t.liveUpdate ? "liveUpdate: checkpoints + completion" : "completion only"
2620
2621
  ].filter(Boolean).join("\n");
2621
2622
  return `${e.instructionsVisibleFromItemIndex === r && r > 0 ? "<div class=\"checklist-divider\"><span>full instructions unlock</span></div>" : ""}
2622
- <div class="checklist-item ${o}" title="${G(f)}">
2623
+ <div class="checklist-item ${o}" title="${K(f)}">
2623
2624
  <div class="checklist-row">
2624
2625
  <span class="checklist-tick">${o === "done" ? "■" : "□"}</span>
2625
- <span class="checklist-title">${G((a = t.title) == null ? `Step ${r + 1}` : a)}</span>
2626
+ <span class="checklist-title">${K((a = t.title) == null ? `Step ${r + 1}` : a)}</span>
2626
2627
  ${d ? `<span class="checklist-count">${d}</span>` : ""}
2627
- ${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${G(s)}">?</button>` : ""}
2628
+ ${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${K(s)}">?</button>` : ""}
2628
2629
  </div>
2629
- ${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${G(t.subtitle)}</div>` : ""}
2630
- ${l && c ? `<pre class="checklist-expand">${G(t.expandMD)}</pre>` : ""}
2630
+ ${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${K(t.subtitle)}</div>` : ""}
2631
+ ${l && c ? `<pre class="checklist-expand">${K(t.expandMD)}</pre>` : ""}
2631
2632
  </div>`;
2632
2633
  }, d = (e) => {
2633
2634
  var n, r, i, s;
@@ -2637,14 +2638,14 @@ function we(e) {
2637
2638
  <div class="checklist-header">
2638
2639
  <span class="simulator-label">Checklist</span>
2639
2640
  <span class="checklist-progress${d === l ? " complete" : ""}">${d}/${l}</span>
2640
- <button class="simulator-btn subtle small" data-reset="${G(e.stableID)}">Reset</button>
2641
+ <button class="simulator-btn subtle small" data-reset="${K(e.stableID)}">Reset</button>
2641
2642
  </div>
2642
2643
  <div class="checklist-items">
2643
2644
  ${e.items.map((t, n) => u(e, t, n, c)).join("")}
2644
2645
  </div>
2645
- ${a ? `<div class="checklist-footer">last eval: ${G(a)}</div>` : ""}
2646
- ${f ? `<div class="checklist-error">${G(f)}</div>` : ""}
2647
- ${o.map((e) => `<div class="checklist-error">${G(e)}</div>`).join("")}
2646
+ ${a ? `<div class="checklist-footer">last eval: ${K(a)}</div>` : ""}
2647
+ ${f ? `<div class="checklist-error">${K(f)}</div>` : ""}
2648
+ ${o.map((e) => `<div class="checklist-error">${K(e)}</div>`).join("")}
2648
2649
  </div>`;
2649
2650
  }, f = () => e.length === 0 ? "<div class=\"simulator-empty\">No checklists in puzzmo.json → integrations.checklists\n<pre class=\"checklist-expand\">\"checklists\": [{\n \"stableID\": \"my-game:tutorial\",\n \"type\": \"tutorial\",\n \"items\": [{ \"title\": \"Make a move\", \"incrementExp\": \"moves\", \"liveUpdate\": true }]\n}]</pre></div>" : e.map(d).join(""), p = (e) => {
2650
2651
  let t = e.getElement("#simulator-checklist-list");
@@ -2692,7 +2693,7 @@ function we(e) {
2692
2693
  }
2693
2694
  };
2694
2695
  }
2695
- var G = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
2696
+ var K = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
2696
2697
  /** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
2697
2698
  function Te() {
2698
2699
  let e = globalThis;
@@ -2720,6 +2721,9 @@ function ke(e) {
2720
2721
  /** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
2721
2722
  var Ae = "\n <div class=\"simulator-share-missing\">\n <p>The app bundle doesn't export <code>getShareString</code>.</p>\n <p>Add it to your app bundle to preview share strings here:</p>\n <pre>export const getShareString: AppBundle[\"getShareString\"] = (\n inputStr, title, { puzzleString, dateKey, gameplaySlug },\n) =&gt; ({ str: `${title}: ...` })</pre>\n </div>\n";
2722
2723
  function je() {
2724
+ let e, t, r = () => {
2725
+ e == null || e.dispose(), e = void 0, t = void 0;
2726
+ };
2723
2727
  return {
2724
2728
  id: "thumb",
2725
2729
  label: "Thumb",
@@ -2741,57 +2745,58 @@ function je() {
2741
2745
  o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
2742
2746
  t.addEventListener("click", () => {
2743
2747
  let n = t.dataset.previewKind;
2744
- !n || n === e.state.previewKind || (e.state.previewKind = n, A(n), c(), s(), e.updateThumbnail());
2748
+ !n || n === e.state.previewKind || (e.state.previewKind = n, j(n), c(), s(), e.updateThumbnail());
2745
2749
  });
2746
- }), n && (e.state.renderHost || (e.state.renderHost = "game", k(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
2747
- e.state.renderHost = n.value, k(e.state.renderHost), s(), e.updateThumbnail();
2748
- })), r && (e.state.renderContext || (e.state.renderContext = "preview", j(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
2749
- e.state.renderContext = r.value, j(e.state.renderContext), e.updateThumbnail();
2750
+ }), n && (e.state.renderHost || (e.state.renderHost = "game", A(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
2751
+ e.state.renderHost = n.value, A(e.state.renderHost), s(), e.updateThumbnail();
2752
+ })), r && (e.state.renderContext || (e.state.renderContext = "preview", M(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
2753
+ e.state.renderContext = r.value, M(e.state.renderContext), e.updateThumbnail();
2750
2754
  })), c(), s();
2751
2755
  },
2752
2756
  onActivate(e) {
2753
2757
  setTimeout(() => e.updateThumbnail(), 0);
2754
2758
  },
2755
- updatePreview: (e) => {
2756
- let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
2757
- if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
2758
- let s = Ee();
2759
- if (!s) {
2760
- t && (t.innerHTML = Ae), n && (n.textContent = "");
2759
+ updatePreview: (i) => {
2760
+ let a = i.getElement("#simulator-thumb-preview"), o = i.getElement("#simulator-thumb-fn");
2761
+ if (a == null || a.style.setProperty("--sim-thumb-bg", i.state.selectedTheme.g_bg), i.state.previewKind === "text") {
2762
+ r();
2763
+ let e = Ee();
2764
+ if (!e) {
2765
+ a && (a.innerHTML = Ae), o && (o.textContent = "");
2761
2766
  return;
2762
2767
  }
2763
- n && (n.textContent = "Using: getShareString()");
2768
+ o && (o.textContent = "Using: getShareString()");
2764
2769
  try {
2765
- var r, i, a, o;
2766
- let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, ke(n), {
2767
- puzzleString: (a = e.state.puzzleData) == null ? "" : a,
2770
+ var s, c, l, u;
2771
+ let t = (s = i.gameSlug) == null ? "game" : s, n = e((c = i.state.currentInputStr) == null ? "" : c, ke(t), {
2772
+ puzzleString: (l = i.state.puzzleData) == null ? "" : l,
2768
2773
  dateKey: Oe(),
2769
- gameplaySlug: `simulator:${n}`
2770
- }), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
2771
- t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${De(l)}</pre>`);
2774
+ gameplaySlug: `simulator:${t}`
2775
+ }), r = (u = n == null ? void 0 : n.str) == null ? "" : u;
2776
+ a && (a.innerHTML = `<pre class="simulator-share-preview" style="color: ${i.state.selectedTheme.fg}">${De(r)}</pre>`);
2772
2777
  } catch (e) {
2773
- console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2778
+ console.error("Simulator: Share string error", e), a && (a.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2774
2779
  }
2775
2780
  return;
2776
2781
  }
2777
- let s = Te();
2778
- if (!s) {
2779
- t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
2782
+ let d = Te();
2783
+ if (!d) {
2784
+ r(), a && (a.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), o && (o.textContent = "");
2780
2785
  return;
2781
2786
  }
2782
- n && (n.textContent = `Using: ${s.name}()`);
2787
+ o && (o.textContent = `Using: ${d.name}()`);
2783
2788
  try {
2784
- var c;
2785
- let n = (c = e.state.puzzleData) == null ? "" : c, r = {
2789
+ var f;
2790
+ let o = (f = i.state.puzzleData) == null ? "" : f, s = {
2786
2791
  viewerIsOwner: !0,
2787
- theme: e.state.selectedTheme,
2792
+ theme: i.state.selectedTheme,
2788
2793
  strict: !0,
2789
- renderHost: e.state.renderHost,
2790
- renderContext: e.state.renderContext
2791
- }, { svg: i } = L(s.fn(n, e.state.currentInputStr, r));
2792
- t && (t.innerHTML = i);
2794
+ renderHost: i.state.renderHost,
2795
+ renderContext: i.state.renderContext
2796
+ }, { svg: c } = R(d.fn(o, i.state.currentInputStr, s));
2797
+ a && ((!e || t !== a) && (r(), a.innerHTML = "", e = n(a), t = a), e.show(c));
2793
2798
  } catch (e) {
2794
- console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2799
+ console.error("Simulator: Thumbnail error", e), r(), a && (a.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2795
2800
  }
2796
2801
  }
2797
2802
  };
@@ -2817,14 +2822,14 @@ function Ne() {
2817
2822
  },
2818
2823
  bind(e) {
2819
2824
  let t = e.getElement("#simulator-themes");
2820
- t && r.forEach((n) => {
2825
+ t && i.forEach((n) => {
2821
2826
  let r = document.createElement("div");
2822
2827
  r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
2823
2828
  ${Me(n)}
2824
2829
  <div class="simulator-theme-name">${n.name}</div>
2825
2830
  <div class="simulator-theme-type">${n.type}</div>
2826
2831
  `, r.addEventListener("click", () => {
2827
- console.log("Simulator: Theme changed, reloading...", n.name), T(n.name), window.location.reload();
2832
+ console.log("Simulator: Theme changed, reloading...", n.name), E(n.name), window.location.reload();
2828
2833
  }), t.appendChild(r);
2829
2834
  });
2830
2835
  }
@@ -2924,9 +2929,9 @@ function Fe(e = []) {
2924
2929
  o.textContent = "hostContext must be an array of { type: string, ... } objects";
2925
2930
  return;
2926
2931
  }
2927
- console.log("Simulator: hostContext changed, reloading...", e), f(e), window.location.reload();
2932
+ console.log("Simulator: hostContext changed, reloading...", e), p(e), window.location.reload();
2928
2933
  }), (r = e.getElement("#host-reset")) == null || r.addEventListener("click", () => {
2929
- p(), window.location.reload();
2934
+ m(), window.location.reload();
2930
2935
  }));
2931
2936
  }
2932
2937
  };
@@ -2935,13 +2940,13 @@ function Fe(e = []) {
2935
2940
  function Ie(e) {
2936
2941
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2937
2942
  }
2938
- var Le = "puzzmo_sim_api_mode", K = "http://localhost:8911", Re = "https://api.puzzmo.com", q = () => localStorage.getItem(Le) === "dev" ? "dev" : "prod", ze = (e) => {
2943
+ var Le = "puzzmo_sim_api_mode", Re = "http://localhost:8911", ze = "https://api.puzzmo.com", q = () => localStorage.getItem(Le) === "dev" ? "dev" : "prod", Be = (e) => {
2939
2944
  localStorage.setItem(Le, e);
2940
- }, J = null, Be = function() {
2945
+ }, J = null, Ve = function() {
2941
2946
  var e = t(function* () {
2942
2947
  if (J !== null) return J;
2943
2948
  try {
2944
- let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${K}/healthz`, { signal: e.signal });
2949
+ let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${Re}/healthz`, { signal: e.signal });
2945
2950
  return clearTimeout(t), J = n.ok, J;
2946
2951
  } catch (e) {
2947
2952
  return J = !1, !1;
@@ -2950,24 +2955,24 @@ var Le = "puzzmo_sim_api_mode", K = "http://localhost:8911", Re = "https://api.p
2950
2955
  return function() {
2951
2956
  return e.apply(this, arguments);
2952
2957
  };
2953
- }(), Ve = () => ({
2954
- apiURL: q() === "dev" ? K : Re,
2958
+ }(), He = () => ({
2959
+ apiURL: q() === "dev" ? Re : ze,
2955
2960
  clientID: "protosdk:oauthclient",
2956
2961
  redirectUri: `${window.location.origin}/oauth/callback`
2957
- }), He = () => {
2962
+ }), Ue = () => {
2958
2963
  let e = new Uint8Array(32);
2959
2964
  return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
2960
- }, Ue = "puzzmo_sim_oauth_token", We = "puzzmo_sim_oauth_refresh_token", Ge = (e) => localStorage.setItem(Ue, e), Ke = (e) => localStorage.setItem(We, e), qe = () => {
2961
- let e = localStorage.getItem(Ue);
2965
+ }, We = "puzzmo_sim_oauth_token", Ge = "puzzmo_sim_oauth_refresh_token", Ke = (e) => localStorage.setItem(We, e), qe = (e) => localStorage.setItem(Ge, e), Je = () => {
2966
+ let e = localStorage.getItem(We);
2962
2967
  return e && `${e.substring(0, 20)}`, e;
2963
- }, Je = () => localStorage.getItem(We), Ye = () => {
2964
- localStorage.removeItem(Ue), localStorage.removeItem(We);
2965
- }, Xe = () => {
2966
- let e = Ve(), t = He();
2968
+ }, Ye = () => localStorage.getItem(Ge), Xe = () => {
2969
+ localStorage.removeItem(We), localStorage.removeItem(Ge);
2970
+ }, Ze = () => {
2971
+ let e = He(), t = Ue();
2967
2972
  sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
2968
2973
  let n = new URL(`${e.apiURL}/oauth/auth`);
2969
2974
  n.searchParams.set("client_id", e.clientID), n.searchParams.set("response_type", "code"), n.searchParams.set("redirect_uri", e.redirectUri), n.searchParams.set("state", t), window.location.href = n.toString();
2970
- }, Ze = (e) => {
2975
+ }, Qe = (e) => {
2971
2976
  try {
2972
2977
  let t = e.split(".");
2973
2978
  if (t.length !== 3) return !0;
@@ -2976,11 +2981,11 @@ var Le = "puzzmo_sim_api_mode", K = "http://localhost:8911", Re = "https://api.p
2976
2981
  } catch (e) {
2977
2982
  return !0;
2978
2983
  }
2979
- }, Qe = function() {
2984
+ }, $e = function() {
2980
2985
  var e = t(function* () {
2981
- let e = Je();
2986
+ let e = Ye();
2982
2987
  if (!e) return !1;
2983
- let t = Ve();
2988
+ let t = He();
2984
2989
  try {
2985
2990
  let n = new URLSearchParams({
2986
2991
  grant_type: "refresh_token",
@@ -2994,9 +2999,9 @@ var Le = "puzzmo_sim_api_mode", K = "http://localhost:8911", Re = "https://api.p
2994
2999
  if (!r.ok) return r.statusText, !1;
2995
3000
  let i = yield r.json(), a = i.access_token || i.accessToken;
2996
3001
  if (!a) return !1;
2997
- Ge(a);
3002
+ Ke(a);
2998
3003
  let o = i.refresh_token || i.refreshToken;
2999
- return o && Ke(o), !0;
3004
+ return o && qe(o), !0;
3000
3005
  } catch (e) {
3001
3006
  return !1;
3002
3007
  }
@@ -3004,9 +3009,9 @@ var Le = "puzzmo_sim_api_mode", K = "http://localhost:8911", Re = "https://api.p
3004
3009
  return function() {
3005
3010
  return e.apply(this, arguments);
3006
3011
  };
3007
- }(), $e = function() {
3012
+ }(), et = function() {
3008
3013
  var e = t(function* (e, t) {
3009
- let n = Ve(), r = sessionStorage.getItem("oauth_state");
3014
+ let n = He(), r = sessionStorage.getItem("oauth_state");
3010
3015
  if (!r || r !== t) return null;
3011
3016
  sessionStorage.removeItem("oauth_state");
3012
3017
  try {
@@ -3028,13 +3033,13 @@ var Le = "puzzmo_sim_api_mode", K = "http://localhost:8911", Re = "https://api.p
3028
3033
  return function(t, n) {
3029
3034
  return e.apply(this, arguments);
3030
3035
  };
3031
- }(), et = function() {
3036
+ }(), tt = function() {
3032
3037
  var e = t(function* (e, t = {}) {
3033
- let n = Ve(), r = qe();
3038
+ let n = He(), r = Je();
3034
3039
  if (!r) throw Error("Not authenticated");
3035
- if (Ze(r)) if (yield Qe()) {
3036
- if (r = qe(), !r) throw Error("Token refresh succeeded but no token available");
3037
- } else throw Ye(), Error("Session expired. Please log in again.");
3040
+ if (Qe(r)) if (yield $e()) {
3041
+ if (r = Je(), !r) throw Error("Token refresh succeeded but no token available");
3042
+ } else throw Xe(), Error("Session expired. Please log in again.");
3038
3043
  let i = yield fetch(`${n.apiURL}/graphql`, {
3039
3044
  method: "POST",
3040
3045
  headers: {
@@ -3053,7 +3058,7 @@ var Le = "puzzmo_sim_api_mode", K = "http://localhost:8911", Re = "https://api.p
3053
3058
  return function(t) {
3054
3059
  return e.apply(this, arguments);
3055
3060
  };
3056
- }(), tt = (e) => {
3061
+ }(), nt = (e) => {
3057
3062
  try {
3058
3063
  let t = e.split(".");
3059
3064
  return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
@@ -3061,15 +3066,15 @@ var Le = "puzzmo_sim_api_mode", K = "http://localhost:8911", Re = "https://api.p
3061
3066
  return null;
3062
3067
  }
3063
3068
  };
3064
- function nt() {
3069
+ function rt() {
3065
3070
  let e = !1;
3066
3071
  return {
3067
3072
  id: "auth",
3068
3073
  label: "Auth",
3069
3074
  render() {
3070
- let e = qe(), t = !!e, n = q(), r = n === "dev" ? K : Re, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
3075
+ let e = Je(), t = !!e, n = q(), r = n === "dev" ? Re : ze, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
3071
3076
  if (t) {
3072
- let t = tt(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!Je(), o = a ? tt(Je()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
3077
+ let t = nt(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!Ye(), o = a ? nt(Ye()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
3073
3078
  return `
3074
3079
  <div class="simulator-section">
3075
3080
  <div class="simulator-section-title auth-title-row">
@@ -3110,7 +3115,7 @@ function nt() {
3110
3115
  </div>
3111
3116
  <p class="auth-description">
3112
3117
  Login with your Puzzmo account to make authenticated API requests.
3113
- ${n === "dev" ? `<br><strong>Using local dev server:</strong> ${K}` : ""}
3118
+ ${n === "dev" ? `<br><strong>Using local dev server:</strong> ${Re}` : ""}
3114
3119
  </p>
3115
3120
  <div class="simulator-row">
3116
3121
  <button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
@@ -3121,21 +3126,21 @@ function nt() {
3121
3126
  },
3122
3127
  bind(n) {
3123
3128
  let r = n.getElement("#auth-login"), i = n.getElement("#auth-logout"), a = n.getElement("#auth-refresh"), o = n.getElement("#auth-test-api"), s = n.getElement("#auth-api-result"), c = n.getElement("#auth-dev-toggle");
3124
- e ? J && c && (c.style.display = "", q() === "dev" && c.classList.add("active")) : (e = !0, Be().then((e) => {
3129
+ e ? J && c && (c.style.display = "", q() === "dev" && c.classList.add("active")) : (e = !0, Ve().then((e) => {
3125
3130
  e && c && (c.style.display = "", q() === "dev" && c.classList.add("active"));
3126
3131
  })), c == null || c.addEventListener("click", () => {
3127
- ze(q() === "dev" ? "prod" : "dev"), Ye(), window.location.reload();
3132
+ Be(q() === "dev" ? "prod" : "dev"), Xe(), window.location.reload();
3128
3133
  }), r == null || r.addEventListener("click", () => {
3129
- Xe();
3134
+ Ze();
3130
3135
  }), i == null || i.addEventListener("click", () => {
3131
- Ye(), window.location.reload();
3136
+ Xe(), window.location.reload();
3132
3137
  }), a == null || a.addEventListener("click", t(function* () {
3133
- a.disabled = !0, a.textContent = "Refreshing...", (yield Qe()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
3138
+ a.disabled = !0, a.textContent = "Refreshing...", (yield $e()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
3134
3139
  })), o == null || o.addEventListener("click", t(function* () {
3135
3140
  if (s) {
3136
3141
  s.innerHTML = "<div class=\"loading\">Loading...</div>";
3137
3142
  try {
3138
- let t = yield et("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
3143
+ let t = yield tt("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
3139
3144
  if (t.errors) {
3140
3145
  var e;
3141
3146
  s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
@@ -3157,13 +3162,13 @@ function nt() {
3157
3162
  if (n && r) {
3158
3163
  let t = e.getElement("#auth-status");
3159
3164
  t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
3160
- let i = yield $e(n, r);
3165
+ let i = yield et(n, r);
3161
3166
  if (window.history.replaceState({}, "", window.location.pathname), i) {
3162
3167
  let e = i.access_token || i.accessToken;
3163
3168
  if (e) {
3164
- Ge(e);
3169
+ Ke(e);
3165
3170
  let t = i.refresh_token || i.refreshToken;
3166
- t && Ke(t);
3171
+ t && qe(t);
3167
3172
  }
3168
3173
  window.location.reload();
3169
3174
  } else {
@@ -3175,9 +3180,9 @@ function nt() {
3175
3180
  }
3176
3181
  };
3177
3182
  }
3178
- var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.puzzmo.com", ot = "puzzmo_sim_oauth_token", st = "puzzmo_sim_oauth_refresh_token", ct = () => localStorage.getItem(rt) === "dev" ? "dev" : "prod", lt = () => localStorage.getItem(ot), ut = () => localStorage.getItem(st), dt = (e) => localStorage.setItem(ot, e), ft = (e) => localStorage.setItem(st, e), pt = () => {
3179
- localStorage.removeItem(ot), localStorage.removeItem(st);
3180
- }, mt = (e) => {
3183
+ var it = "puzzmo_sim_api_mode", at = "http://localhost:8911", ot = "https://api.puzzmo.com", st = "puzzmo_sim_oauth_token", ct = "puzzmo_sim_oauth_refresh_token", lt = () => localStorage.getItem(it) === "dev" ? "dev" : "prod", ut = () => localStorage.getItem(st), dt = () => localStorage.getItem(ct), ft = (e) => localStorage.setItem(st, e), pt = (e) => localStorage.setItem(ct, e), mt = () => {
3184
+ localStorage.removeItem(st), localStorage.removeItem(ct);
3185
+ }, ht = (e) => {
3181
3186
  try {
3182
3187
  let t = e.split(".");
3183
3188
  if (t.length !== 3) return !0;
@@ -3186,11 +3191,11 @@ var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.
3186
3191
  } catch (e) {
3187
3192
  return !0;
3188
3193
  }
3189
- }, ht = function() {
3194
+ }, gt = function() {
3190
3195
  var e = t(function* () {
3191
- let e = ut();
3196
+ let e = dt();
3192
3197
  if (!e) return !1;
3193
- let t = ct() === "dev" ? it : at;
3198
+ let t = lt() === "dev" ? at : ot;
3194
3199
  try {
3195
3200
  let n = new URLSearchParams({
3196
3201
  grant_type: "refresh_token",
@@ -3204,9 +3209,9 @@ var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.
3204
3209
  if (!r.ok) return !1;
3205
3210
  let i = yield r.json(), a = i.access_token || i.accessToken;
3206
3211
  if (!a) return !1;
3207
- dt(a);
3212
+ ft(a);
3208
3213
  let o = i.refresh_token || i.refreshToken;
3209
- return o && ft(o), !0;
3214
+ return o && pt(o), !0;
3210
3215
  } catch (e) {
3211
3216
  return !1;
3212
3217
  }
@@ -3214,13 +3219,13 @@ var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.
3214
3219
  return function() {
3215
3220
  return e.apply(this, arguments);
3216
3221
  };
3217
- }(), gt = function() {
3222
+ }(), _t = function() {
3218
3223
  var e = t(function* (e, t = {}) {
3219
- let n = ct() === "dev" ? it : at, r = lt();
3224
+ let n = lt() === "dev" ? at : ot, r = ut();
3220
3225
  if (!r) throw Error("Not authenticated");
3221
- if (mt(r)) if (yield ht()) {
3222
- if (r = lt(), !r) throw Error("Token refresh succeeded but no token available");
3223
- } else throw pt(), Error("Session expired. Please log in again.");
3226
+ if (ht(r)) if (yield gt()) {
3227
+ if (r = ut(), !r) throw Error("Token refresh succeeded but no token available");
3228
+ } else throw mt(), Error("Session expired. Please log in again.");
3224
3229
  let i = yield fetch(`${n}/graphql`, {
3225
3230
  method: "POST",
3226
3231
  headers: {
@@ -3239,19 +3244,19 @@ var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.
3239
3244
  return function(t) {
3240
3245
  return e.apply(this, arguments);
3241
3246
  };
3242
- }(), _t = "\n query GameFeaturesQuery($slug: ID!) {\n game(id: $slug) {\n id\n slug\n displayName\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", vt = "\n mutation ToggleFeatureMutation($gameSlug: ID!, $input: UpdateGameInput!) {\n updateGame(id: $gameSlug, input: $input) {\n id\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", yt = (e, t) => {
3247
+ }(), vt = "\n query GameFeaturesQuery($slug: ID!) {\n game(id: $slug) {\n id\n slug\n displayName\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", yt = "\n mutation ToggleFeatureMutation($gameSlug: ID!, $input: UpdateGameInput!) {\n updateGame(id: $gameSlug, input: $input) {\n id\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", bt = (e, t) => {
3243
3248
  let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
3244
3249
  for (; a.length <= r;) a.push(0);
3245
3250
  return a[r] = a[r] ^ 1 << i, a;
3246
3251
  };
3247
- const bt = () => !!lt();
3248
- function xt() {
3252
+ const xt = () => !!ut();
3253
+ function St() {
3249
3254
  let n = null, r = !1, i = null, a = function() {
3250
3255
  var e = t(function* (e) {
3251
3256
  r = !0, i = null;
3252
3257
  try {
3253
3258
  var t;
3254
- let r = yield gt(_t, { slug: e });
3259
+ let r = yield _t(vt, { slug: e });
3255
3260
  if (r.errors) {
3256
3261
  var a;
3257
3262
  i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
@@ -3268,10 +3273,10 @@ function xt() {
3268
3273
  }(), o = function() {
3269
3274
  var r = t(function* (t) {
3270
3275
  if (!n) return;
3271
- let r = yt(n.featuresArr, t);
3276
+ let r = bt(n.featuresArr, t);
3272
3277
  try {
3273
3278
  var i;
3274
- let t = yield gt(vt, {
3279
+ let t = yield _t(yt, {
3275
3280
  gameSlug: n.slug,
3276
3281
  input: { featuresArr: r }
3277
3282
  });
@@ -3319,7 +3324,7 @@ function xt() {
3319
3324
  id: "features",
3320
3325
  label: "Features",
3321
3326
  render() {
3322
- return bt() ? `
3327
+ return xt() ? `
3323
3328
  <div class="features-view-container">
3324
3329
  <div class="simulator-section">
3325
3330
  <div class="simulator-section-title">Game Features</div>
@@ -3360,7 +3365,7 @@ function xt() {
3360
3365
  e && (yield d(e));
3361
3366
  })), i == null || i.addEventListener("keypress", (e) => {
3362
3367
  e.key === "Enter" && (r == null || r.click());
3363
- }), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, bt() && !n && d(e.gameSlug)), u();
3368
+ }), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, xt() && !n && d(e.gameSlug)), u();
3364
3369
  },
3365
3370
  onActivate(e) {
3366
3371
  let t = e.getElement("#simulator-tab-features");
@@ -3384,15 +3389,15 @@ function xt() {
3384
3389
  * tuning it needs to see it.
3385
3390
  */
3386
3391
  /** Space the keys occupy. */
3387
- var St = 200, Ct = 24;
3392
+ var Ct = 200, wt = 24;
3388
3393
  /** What the keyboard takes off the bottom of the game, and what the game must lay out without. */
3389
- const Y = St + Ct;
3394
+ const Y = Ct + wt;
3390
3395
  /** Drag-cursor thresholds, from useKeyboardCursor in @puzzmo-com/keyboard. */
3391
- var wt = 6, Tt = 2.5, Et = 100, Dt = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", X = (e, t) => {
3396
+ var Tt = 6, Et = 2.5, Dt = 100, Ot = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", X = (e, t) => {
3392
3397
  let n = e.replace("#", ""), r = n.length === 3 ? [...n].map((e) => e + e).join("") : n, i = parseInt(r, 16);
3393
3398
  return r.length !== 6 || Number.isNaN(i) ? e : `rgba(${i >> 16 & 255}, ${i >> 8 & 255}, ${i & 255}, ${t})`;
3394
- }, Ot = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), kt = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3395
- function At(e) {
3399
+ }, kt = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), At = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3400
+ function jt(e) {
3396
3401
  let { theme: t, sendToGame: n } = e, r = !1, i = null, a = null, o = document.createElement("style");
3397
3402
  o.id = "sim-docked-kbd-page-style", o.textContent = `
3398
3403
  html.sim-kbd-docked #simulator {
@@ -3441,7 +3446,7 @@ function At(e) {
3441
3446
  }, f = (e, t) => {
3442
3447
  var n, r;
3443
3448
  let i = (n = t.symbols[e]) == null ? e : n, a = t.disabled.includes(e), o = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e), s = [
3444
- `width:${Dt(t.l.includes(e), t.xl.includes(e))}`,
3449
+ `width:${Ot(t.l.includes(e), t.xl.includes(e))}`,
3445
3450
  `flex:${o ? "1 0 auto" : "0 1 auto"}`,
3446
3451
  "height:100%",
3447
3452
  "display:flex",
@@ -3451,8 +3456,8 @@ function At(e) {
3451
3456
  "position:relative",
3452
3457
  a ? "pointer-events:none" : ""
3453
3458
  ].filter(Boolean).join(";"), c = u(e, t), l = d(e, t);
3454
- return `<div class="sim-docked-kbd-key" data-key="${Ot(e)}" style="${s}">
3455
- <div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${kt(i)}</div></div>
3459
+ return `<div class="sim-docked-kbd-key" data-key="${kt(e)}" style="${s}">
3460
+ <div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${At(i)}</div></div>
3456
3461
  </div>`;
3457
3462
  }, p = (e) => {
3458
3463
  let n = e.layout.filter((e) => !!e), r = `calc(100% / ${n.length})`;
@@ -3468,17 +3473,17 @@ function At(e) {
3468
3473
  }, S = (e) => {
3469
3474
  var t, n;
3470
3475
  return (t = (n = document.elementFromPoint(e.clientX, e.clientY)) == null || (n = n.closest(".sim-docked-kbd-key")) == null ? void 0 : n.getAttribute("data-key")) == null ? null : t;
3471
- }, ee = (e) => {
3472
- y = S(e), a == null || a.setPointerCapture(e.pointerId);
3473
3476
  }, C = (e) => {
3474
- !(i != null && i.supportsDragCursor) || !y || g && g.clientX === e.clientX && g.clientY === e.clientY || (g && g.pointerId !== e.pointerId && (_ = 0, v = null), v || (v = Date.now()), m || (_ += 1, _ >= wt && Date.now() - v >= Et && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * Tt, h[1] + (e.clientY - g.clientY) * Tt]), g = {
3477
+ y = S(e), a == null || a.setPointerCapture(e.pointerId);
3478
+ }, ee = (e) => {
3479
+ !(i != null && i.supportsDragCursor) || !y || g && g.clientX === e.clientX && g.clientY === e.clientY || (g && g.pointerId !== e.pointerId && (_ = 0, v = null), v || (v = Date.now()), m || (_ += 1, _ >= Tt && Date.now() - v >= Dt && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * Et, h[1] + (e.clientY - g.clientY) * Et]), g = {
3475
3480
  clientX: e.clientX,
3476
3481
  clientY: e.clientY,
3477
3482
  pointerId: e.pointerId
3478
3483
  }, m && n("KEYBOARD_CURSOR_CHANGE", { position: h }));
3479
3484
  }, w = (e) => {
3480
3485
  m ? n("KEYBOARD_CURSOR_END", {}) : y && S(e) === y && n("KEYBOARD_KEY_PRESS", { key: y }), x();
3481
- }, te = () => {
3486
+ }, T = () => {
3482
3487
  a || !i || (a = document.createElement("div"), a.id = "sim-docked-kbd", a.style.cssText = [
3483
3488
  "position:fixed",
3484
3489
  "left:0",
@@ -3487,7 +3492,7 @@ function At(e) {
3487
3492
  `height:${Y}px`,
3488
3493
  "box-sizing:border-box",
3489
3494
  "padding-top:8px",
3490
- `padding-bottom:${Ct}px`,
3495
+ `padding-bottom:${wt}px`,
3491
3496
  "display:flex",
3492
3497
  "flex-direction:column",
3493
3498
  "z-index:999998",
@@ -3496,18 +3501,18 @@ function At(e) {
3496
3501
  "-webkit-user-select:none",
3497
3502
  `background:${t.a_bg}`,
3498
3503
  `border-top:1px solid ${X(t.fg, .2)}`
3499
- ].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", ee), a.addEventListener("pointermove", C), a.addEventListener("pointerup", w), a.addEventListener("pointercancel", () => x()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
3500
- }, ne = () => {
3504
+ ].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", C), a.addEventListener("pointermove", ee), a.addEventListener("pointerup", w), a.addEventListener("pointercancel", () => x()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
3505
+ }, te = () => {
3501
3506
  a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), x());
3502
- }, T = () => {
3507
+ }, ne = () => {
3503
3508
  let e = i;
3504
3509
  !a || !e || a.querySelectorAll(".sim-docked-kbd-key").forEach((t) => {
3505
3510
  let n = t.getAttribute("data-key"), r = t.firstElementChild, i = r == null ? void 0 : r.firstElementChild;
3506
3511
  !n || !r || !i || (r.style.cssText = u(n, e), i.style.cssText = d(n, e));
3507
3512
  });
3508
3513
  }, E = () => {
3509
- if (!r || !i) return ne();
3510
- if (!a) return te();
3514
+ if (!r || !i) return te();
3515
+ if (!a) return T();
3511
3516
  a.innerHTML = p(i), b(m);
3512
3517
  };
3513
3518
  return {
@@ -3515,13 +3520,13 @@ function At(e) {
3515
3520
  r = e, E();
3516
3521
  },
3517
3522
  setConfig(e) {
3518
- let t = a && e && i && jt(e) === jt(i);
3519
- i = e, t ? T() : E();
3523
+ let t = a && e && i && Mt(e) === Mt(i);
3524
+ i = e, t ? ne() : E();
3520
3525
  }
3521
3526
  };
3522
3527
  }
3523
3528
  /** Everything about a config except its per-key styling, so a styling-only update can be spotted. */
3524
- var jt = (e) => JSON.stringify([
3529
+ var Mt = (e) => JSON.stringify([
3525
3530
  e.layout,
3526
3531
  e.symbols,
3527
3532
  e.highlight,
@@ -3533,9 +3538,9 @@ var jt = (e) => JSON.stringify([
3533
3538
  e.keyStyles
3534
3539
  ]);
3535
3540
  /** Serializes a style object into inline CSS, so `{ backgroundColor: "red" }` becomes `background-color:red`. */
3536
- const Z = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${Ot(String(t))}`).join(";");
3541
+ const Z = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${kt(String(t))}`).join(";");
3537
3542
  /** Renders a single keyboard key as an HTML button string */
3538
- var Mt = (e, t) => {
3543
+ var Nt = (e, t) => {
3539
3544
  var n, r, i, a;
3540
3545
  let o = (n = t.symbols[e]) == null ? e : n, s = t.disabled.includes(e), c = t.highlight.includes(e), l = t.xl.includes(e), u = t.l.includes(e), d = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e), f = [
3541
3546
  "sim-kb-key",
@@ -3546,9 +3551,9 @@ var Mt = (e, t) => {
3546
3551
  d ? "grow" : ""
3547
3552
  ].filter(Boolean).join(" "), p = Z((i = t.individualKeyStyles) == null || (i = i[e]) == null ? void 0 : i.background), m = Z((a = t.individualKeyStyles) == null || (a = a[e]) == null ? void 0 : a.text);
3548
3553
  return `<button class="${f}" data-key="${e}" style="${p}" ${s ? "disabled" : ""}><span style="${m}">${o}</span></button>`;
3549
- }, Nt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => Mt(t, e)).join("")}</div>`).join("")}</div>`;
3550
- function Pt() {
3551
- let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${Y}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : Nt(e) : "<div class=\"sim-kb-empty\">No keyboard config received from game yet.<br>The game calls <code>sdk.keyboard.show(config)</code> to display a keyboard.</div>";
3554
+ }, Pt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => Nt(t, e)).join("")}</div>`).join("")}</div>`;
3555
+ function Ft() {
3556
+ let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${Y}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : Pt(e) : "<div class=\"sim-kb-empty\">No keyboard config received from game yet.<br>The game calls <code>sdk.keyboard.show(config)</code> to display a keyboard.</div>";
3552
3557
  return {
3553
3558
  id: "kbd",
3554
3559
  label: "Kbd",
@@ -3568,14 +3573,14 @@ function Pt() {
3568
3573
  `;
3569
3574
  },
3570
3575
  bind(e) {
3571
- t != null || (t = At({
3576
+ t != null || (t = jt({
3572
3577
  theme: e.state.selectedTheme,
3573
3578
  sendToGame: e.sendToGame
3574
3579
  })), t.setEnabled(e.state.keyboardDocked);
3575
3580
  let n = e.getElement("#sim-kb-dock");
3576
3581
  n && (n.checked = e.state.keyboardDocked, n.addEventListener("change", () => {
3577
- e.state.keyboardDocked = n.checked, h(n.checked), t == null || t.setEnabled(n.checked), r(e);
3578
- })), Ft(e);
3582
+ e.state.keyboardDocked = n.checked, g(n.checked), t == null || t.setEnabled(n.checked), r(e);
3583
+ })), It(e);
3579
3584
  },
3580
3585
  onMessage(n, i, a) {
3581
3586
  var o;
@@ -3585,11 +3590,11 @@ function Pt() {
3585
3590
  /** Re-render the tab's own content (not the dock) and rebind its keys. */
3586
3591
  function r(e) {
3587
3592
  let t = e.getElement("#sim-kb-content");
3588
- t && (t.innerHTML = n(e.state.keyboardDocked), Ft(e));
3593
+ t && (t.innerHTML = n(e.state.keyboardDocked), It(e));
3589
3594
  }
3590
3595
  }
3591
3596
  /** Attach click handlers to all rendered keys */
3592
- function Ft(e) {
3597
+ function It(e) {
3593
3598
  var t;
3594
3599
  let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
3595
3600
  n == null || n.forEach((t) => {
@@ -3604,15 +3609,15 @@ function Ft(e) {
3604
3609
  * change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
3605
3610
  * production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
3606
3611
  */
3607
- function It() {
3612
+ function Lt() {
3608
3613
  let t = (e) => {
3609
3614
  let t = e.state.settingsComponents;
3610
- return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) => Lt(t, e.state.gameSettings)).join("")}</div><div class="sim-settings-actions"><button class="simulator-btn tiny" id="sim-settings-reset">Reset to defaults</button></div>`;
3615
+ return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) => Rt(t, e.state.gameSettings)).join("")}</div><div class="sim-settings-actions"><button class="simulator-btn tiny" id="sim-settings-reset">Reset to defaults</button></div>`;
3611
3616
  }, n = (e) => {
3612
3617
  let n = e.getElement("#sim-settings-content");
3613
3618
  n && (n.innerHTML = t(e), i(e));
3614
3619
  }, r = (e) => {
3615
- C(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
3620
+ w(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
3616
3621
  }, i = (t) => {
3617
3622
  var i;
3618
3623
  let a = t.getElement("#sim-settings-content");
@@ -3628,7 +3633,7 @@ function It() {
3628
3633
  });
3629
3634
  }), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
3630
3635
  var e;
3631
- w(), t.state.gameSettings = zt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
3636
+ T(), t.state.gameSettings = Bt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
3632
3637
  }));
3633
3638
  };
3634
3639
  return {
@@ -3643,21 +3648,21 @@ function It() {
3643
3648
  onMessage(t, r, i) {
3644
3649
  if (t === "INITIALIZE_SETTINGS") {
3645
3650
  var a;
3646
- i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings), C(i.state.gameSettings), n(i);
3651
+ i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings), w(i.state.gameSettings), n(i);
3647
3652
  return;
3648
3653
  }
3649
- t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), C(i.state.gameSettings), n(i));
3654
+ t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), w(i.state.gameSettings), n(i));
3650
3655
  }
3651
3656
  };
3652
3657
  }
3653
3658
  /** Renders a single settings UI component as HTML, reading its current value from `settings` */
3654
- function Lt(e, t) {
3659
+ function Rt(e, t) {
3655
3660
  switch (e.type) {
3656
3661
  case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
3657
3662
  case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
3658
3663
  case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
3659
3664
  case "separator": return "<div class=\"simulator-divider\"></div>";
3660
- case "split": return `<div class="sim-settings-split">${e.content.map((e) => Lt(e, t)).join("")}</div>`;
3665
+ case "split": return `<div class="sim-settings-split">${e.content.map((e) => Rt(e, t)).join("")}</div>`;
3661
3666
  case "boolean": {
3662
3667
  var n;
3663
3668
  let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
@@ -3678,7 +3683,7 @@ function Lt(e, t) {
3678
3683
  }).join("");
3679
3684
  return `
3680
3685
  <div class="simulator-field">
3681
- ${Rt(e)}
3686
+ ${zt(e)}
3682
3687
  <select class="simulator-select" data-setting="${e.name}">${i}</select>
3683
3688
  </div>`;
3684
3689
  }
@@ -3694,7 +3699,7 @@ function Lt(e, t) {
3694
3699
  }).join("");
3695
3700
  return `
3696
3701
  <div class="simulator-field">
3697
- ${Rt(e)}
3702
+ ${zt(e)}
3698
3703
  ${a}
3699
3704
  </div>`;
3700
3705
  }
@@ -3703,7 +3708,7 @@ function Lt(e, t) {
3703
3708
  let n = (a = t[e.name]) == null ? e.defaultValue : a, r = e.values.map((e) => `<option value="${e}" ${e === n ? "selected" : ""}>${e}</option>`).join("");
3704
3709
  return `
3705
3710
  <div class="simulator-field">
3706
- ${Rt(e)}
3711
+ ${zt(e)}
3707
3712
  <select class="simulator-select" data-setting="${e.name}" data-setting-type="number">${r}</select>
3708
3713
  </div>`;
3709
3714
  }
@@ -3712,7 +3717,7 @@ function Lt(e, t) {
3712
3717
  let n = String((o = (s = t[e.name]) == null ? e.defaultValue : s) == null ? "" : o), r = e.textarea ? `<textarea class="simulator-textarea" data-setting="${e.name}">${Q(n)}</textarea>` : `<input class="simulator-input" type="text" data-setting="${e.name}" value="${Q(n)}" />`;
3713
3718
  return `
3714
3719
  <div class="simulator-field">
3715
- ${Rt(e)}
3720
+ ${zt(e)}
3716
3721
  ${r}
3717
3722
  </div>`;
3718
3723
  }
@@ -3720,14 +3725,14 @@ function Lt(e, t) {
3720
3725
  }
3721
3726
  }
3722
3727
  /** Title + optional subtitle markup for a value-producing component */
3723
- function Rt(e) {
3728
+ function zt(e) {
3724
3729
  let t = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
3725
3730
  return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
3726
3731
  }
3727
3732
  /** Collects name → defaultValue pairs from components, recursing into split groups */
3728
- function zt(e) {
3733
+ function Bt(e) {
3729
3734
  let t = {};
3730
- for (let n of e) n.type === "split" ? Object.assign(t, zt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
3735
+ for (let n of e) n.type === "split" ? Object.assign(t, Bt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
3731
3736
  return t;
3732
3737
  }
3733
3738
  function Q(e) {
@@ -3738,8 +3743,8 @@ function Q(e) {
3738
3743
  * parts the host owns: the sound-enabled gate (games boot muted, so this is what lets you hear
3739
3744
  * anything) and a log of the cues the game asked us for, with any haptic it wanted.
3740
3745
  */
3741
- function Bt() {
3742
- let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No cues yet. Play the game to hear from it.</div>" : e.map((e) => `<div class="sound-row"><span class="sound-id">${Ht(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${Ht(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
3746
+ function Vt() {
3747
+ let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No cues yet. Play the game to hear from it.</div>" : e.map((e) => `<div class="sound-row"><span class="sound-id">${Ut(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${Ut(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
3743
3748
  let r = t.getElement("#sound-events");
3744
3749
  r && (r.innerHTML = n()), t.updateBadge("sound", e.length);
3745
3750
  };
@@ -3786,13 +3791,13 @@ function Bt() {
3786
3791
  n === "SENSORY_EVENT" && (e.unshift({
3787
3792
  id: (o = i == null ? void 0 : i.id) == null ? JSON.stringify(i) : o,
3788
3793
  haptic: i == null ? void 0 : i.haptic,
3789
- time: Vt()
3794
+ time: Ht()
3790
3795
  }), e.length > 100 && e.pop(), r(a));
3791
3796
  }
3792
3797
  };
3793
3798
  }
3794
3799
  /** Current wall-clock time as HH:MM:SS, matching the simulator's message log formatting. */
3795
- function Vt() {
3800
+ function Ht() {
3796
3801
  return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
3797
3802
  hour12: !1,
3798
3803
  hour: "2-digit",
@@ -3801,16 +3806,16 @@ function Vt() {
3801
3806
  });
3802
3807
  }
3803
3808
  /** Minimal HTML-escape so event ids can't break the simulator markup. */
3804
- function Ht(e) {
3809
+ function Ut(e) {
3805
3810
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3806
3811
  }
3807
3812
  var $ = null;
3808
3813
  /** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
3809
- function Ut() {
3814
+ function Wt() {
3810
3815
  return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
3811
3816
  }
3812
3817
  /** Inert instance returned when the simulator declines to boot (the app is the host). */
3813
- var Wt = {
3818
+ var Gt = {
3814
3819
  updateFixtures: () => {},
3815
3820
  sendToGame: () => {},
3816
3821
  loadPuzzle: function() {
@@ -3859,9 +3864,9 @@ var Wt = {
3859
3864
  * Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
3860
3865
  * This will show dropdowns in the Ctrl tab to select category and puzzle.
3861
3866
  */
3862
- function Gt(n = {}) {
3867
+ function Kt(n = {}) {
3863
3868
  var r, i, a, o, s;
3864
- if (Ut()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Wt;
3869
+ if (Wt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Gt;
3865
3870
  if (console.log("[Simulator] createSimulator called with config:", {
3866
3871
  slug: n.slug,
3867
3872
  hasFixtures: !!n.fixtures
@@ -3876,11 +3881,11 @@ function Gt(n = {}) {
3876
3881
  f,
3877
3882
  Ne(),
3878
3883
  Fe(n.hostContextPresets),
3879
- nt(),
3880
- xt(),
3881
- Pt(),
3882
- It(),
3883
- Bt(),
3884
+ rt(),
3885
+ St(),
3886
+ Ft(),
3887
+ Lt(),
3888
+ Vt(),
3884
3889
  ...(o = n.views) == null ? [] : o
3885
3890
  ], m = p.map((e) => e.id), h = ee(n, u, m), g = {
3886
3891
  pause: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"1\" width=\"3\" height=\"8\"/><rect x=\"6\" y=\"1\" width=\"3\" height=\"8\"/></svg>",
@@ -5364,7 +5369,7 @@ function Gt(n = {}) {
5364
5369
  }, j = (e, t) => {
5365
5370
  let n = k("#simulator-status .text"), r = k("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
5366
5371
  n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), b.className = t, b.textContent = i, x.textContent = e;
5367
- }, P = (e, t) => {
5372
+ }, M = (e, t) => {
5368
5373
  t && t !== "0" ? E.innerHTML = `${e}<span class="penalty">+${t}</span>` : E.textContent = e;
5369
5374
  }, F = (e) => {
5370
5375
  var t;
@@ -5399,10 +5404,10 @@ function Gt(n = {}) {
5399
5404
  return function() {
5400
5405
  return e.apply(this, arguments);
5401
5406
  };
5402
- }(), z = re((e) => {
5407
+ }(), z = N((e) => {
5403
5408
  d.addLogEntry(e, H);
5404
5409
  }), B = (e, t) => {
5405
- M(e, t, z);
5410
+ P(e, t, z);
5406
5411
  }, se = (e) => {
5407
5412
  var t;
5408
5413
  let n = (t = e.buckets) != null && t.length ? e.buckets : u, r = n.find((e) => {
@@ -5435,7 +5440,7 @@ function Gt(n = {}) {
5435
5440
  logMessage: z.log,
5436
5441
  loadPuzzle: R,
5437
5442
  updateStatus: j,
5438
- updateTimer: P,
5443
+ updateTimer: M,
5439
5444
  setCollapsed: I,
5440
5445
  switchTab: F,
5441
5446
  updateThumbnail: L,
@@ -5464,9 +5469,9 @@ function Gt(n = {}) {
5464
5469
  }), y.addEventListener("click", (e) => {
5465
5470
  h.isCollapsed && e.target !== T && I(!1);
5466
5471
  }), h.isCollapsed || F(h.activeTab);
5467
- let le = new URLSearchParams(window.location.search);
5468
- (le.has("code") || le.has("error")) && (I(!1), F("auth"));
5469
- let U = (e) => {
5472
+ let U = new URLSearchParams(window.location.search);
5473
+ (U.has("code") || U.has("error")) && (I(!1), F("auth"));
5474
+ let le = (e) => {
5470
5475
  let t = {
5471
5476
  additionalTimeAddedSecs: 0,
5472
5477
  boardState: h.currentInputStr,
@@ -5502,19 +5507,19 @@ function Gt(n = {}) {
5502
5507
  type: "User",
5503
5508
  roles: ""
5504
5509
  },
5505
- game: Kt,
5510
+ game: qt,
5506
5511
  session: n,
5507
5512
  viewerStorage: h.userStorage,
5508
5513
  theme: h.selectedTheme,
5509
5514
  hostContext: h.hostContext,
5510
5515
  appRuntimeContract: "1.0"
5511
5516
  };
5512
- }, W = ["1.0", "1.1"], ue = function() {
5517
+ }, W = ["1.0", "1.1"], G = function() {
5513
5518
  var r = t(function* (t) {
5514
5519
  let r = n.session !== !1 || t === "1.0";
5515
5520
  r ? n.session === !1 && console.warn("Simulator: `session: false` needs a game built on an SDK speaking runtime contract 1.1 or later") : console.log("Simulator: Sending READY_DATA without a session"), j(r ? "Loading puzzle..." : "Sending READY_DATA...", "waiting");
5516
5521
  try {
5517
- let n = e(e({}, U(r ? yield R() : null)), {}, { appRuntimeContract: t });
5522
+ let n = e(e({}, le(r ? yield R() : null)), {}, { appRuntimeContract: t });
5518
5523
  j("Sending READY_DATA...", "waiting"), B("READY_DATA", n), j("Waiting for game to load...", "waiting");
5519
5524
  } catch (e) {
5520
5525
  j(`Error: ${e}`, "paused");
@@ -5523,7 +5528,7 @@ function Gt(n = {}) {
5523
5528
  return function(e) {
5524
5529
  return r.apply(this, arguments);
5525
5530
  };
5526
- }(), de = () => {
5531
+ }(), ue = () => {
5527
5532
  console.log("Simulator: Game loaded, ready to start"), C.disabled = !1, p.forEach((e) => {
5528
5533
  var t;
5529
5534
  return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, H);
@@ -5532,20 +5537,20 @@ function Gt(n = {}) {
5532
5537
  e == null || e.click(), S.disabled = !1, h.hasStarted = !0, j("Running", "ready");
5533
5538
  }, 100);
5534
5539
  };
5535
- return N((e, t) => {
5540
+ return re((e, t) => {
5536
5541
  var n, r;
5537
5542
  if (e === "READY") {
5538
- console.log("Simulator: Received READY from game"), ue(W.includes(t == null ? void 0 : t.runtimeContract) ? t.runtimeContract : "1.0");
5543
+ console.log("Simulator: Received READY from game"), G(W.includes(t == null ? void 0 : t.runtimeContract) ? t.runtimeContract : "1.0");
5539
5544
  return;
5540
5545
  }
5541
5546
  if (e === "READY_GAME_LOADED") {
5542
- de();
5547
+ ue();
5543
5548
  return;
5544
5549
  }
5545
5550
  if (e === "TIMER_TICK") {
5546
5551
  if (t != null && t.display) {
5547
5552
  let [e, n] = t.display;
5548
- P(e, n);
5553
+ M(e, n);
5549
5554
  }
5550
5555
  return;
5551
5556
  }
@@ -5590,7 +5595,7 @@ function Gt(n = {}) {
5590
5595
  }, $;
5591
5596
  }
5592
5597
  /** The game the simulator stands in for, with placeholder IDs since nothing is stored */
5593
- var Kt = {
5598
+ var qt = {
5594
5599
  id: "simulator-game",
5595
5600
  slug: "proto-game",
5596
5601
  stableSlug: "proto-game",
@@ -5606,6 +5611,6 @@ var Kt = {
5606
5611
  }
5607
5612
  }
5608
5613
  };
5609
- export { Bt as n, ae as r, Gt as t };
5614
+ export { Vt as n, ae as r, Kt as t };
5610
5615
 
5611
- //# sourceMappingURL=createSimulator-C5RgI7Gg.js.map
5616
+ //# sourceMappingURL=createSimulator-CYo2KWWM.js.map