@puzzmo/sdk 1.0.62 → 1.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/chunk-350yNsax.cjs +1 -0
  2. package/dist/createSimulator-Ce3StrQI.cjs +1930 -0
  3. package/dist/createSimulator-Ce3StrQI.cjs.map +1 -0
  4. package/dist/{createSimulator-CdInpCHG.js → createSimulator-DUZOd1Hx.js} +2231 -439
  5. package/dist/createSimulator-DUZOd1Hx.js.map +1 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.js +3 -3
  8. package/dist/inputs/index.cjs +1 -1
  9. package/dist/inputs/index.cjs.map +1 -1
  10. package/dist/inputs/index.js +1 -1
  11. package/dist/{lua-QeU9Rzet.cjs → lua-CclI-QKD.cjs} +1 -1
  12. package/dist/{lua-QeU9Rzet.cjs.map → lua-CclI-QKD.cjs.map} +1 -1
  13. package/dist/pico8/index.cjs +1 -1
  14. package/dist/pico8/index.js +2 -2
  15. package/dist/simulator/checklistProgress.d.ts +34 -0
  16. package/dist/simulator/checklistProgress.d.ts.map +1 -0
  17. package/dist/simulator/checklistProgress.spec.d.ts +2 -0
  18. package/dist/simulator/checklistProgress.spec.d.ts.map +1 -0
  19. package/dist/simulator/createSimulator.d.ts.map +1 -1
  20. package/dist/simulator/index.cjs +1 -1
  21. package/dist/simulator/index.js +1 -1
  22. package/dist/simulator/standalone.cjs +1 -1
  23. package/dist/simulator/standalone.js +1 -1
  24. package/dist/simulator/styles.d.ts +1 -1
  25. package/dist/simulator/styles.d.ts.map +1 -1
  26. package/dist/simulator/types.d.ts +25 -0
  27. package/dist/simulator/types.d.ts.map +1 -1
  28. package/dist/simulator/views/ChecklistView.d.ts +4 -0
  29. package/dist/simulator/views/ChecklistView.d.ts.map +1 -0
  30. package/dist/simulator/views/index.d.ts +1 -0
  31. package/dist/simulator/views/index.d.ts.map +1 -1
  32. package/dist/vite.cjs +5 -5
  33. package/dist/vite.cjs.map +1 -1
  34. package/dist/vite.d.ts +3 -1
  35. package/dist/vite.d.ts.map +1 -1
  36. package/dist/vite.js +20 -7
  37. package/dist/vite.js.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/createSimulator-CdInpCHG.js.map +0 -1
  40. package/dist/createSimulator-PNeBoNux.cjs +0 -1775
  41. package/dist/createSimulator-PNeBoNux.cjs.map +0 -1
  42. /package/dist/{asyncToGenerator-BotOOyB7.js → asyncToGenerator-DSd3oTwb.js} +0 -0
  43. /package/dist/{asyncToGenerator-DIL7svO7.cjs → asyncToGenerator-Tjg_Hpik.cjs} +0 -0
  44. /package/dist/{objectSpread2-BQwrzeNG.js → objectSpread2-BJrS9rM5.js} +0 -0
  45. /package/dist/{objectSpread2-CCAs_T0X.cjs → objectSpread2-BU9HzoRm.cjs} +0 -0
  46. /package/dist/{objectWithoutProperties-Bjd1IAMi.js → objectWithoutProperties-54Cbyogk.js} +0 -0
  47. /package/dist/{objectWithoutProperties-Ee8z5QMa.cjs → objectWithoutProperties-CL_8JSCP.cjs} +0 -0
@@ -1,6 +1,7 @@
1
- import { t as e } from "./objectSpread2-BQwrzeNG.js";
2
- import { t } from "./asyncToGenerator-BotOOyB7.js";
3
- const n = [
1
+ import { t as e } from "./objectSpread2-BJrS9rM5.js";
2
+ import { t } from "./asyncToGenerator-DSd3oTwb.js";
3
+ var n = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
4
+ const r = [
4
5
  {
5
6
  name: "Puzzmo (light)",
6
7
  type: "light",
@@ -306,7 +307,7 @@ const n = [
306
307
  a_infoBG: "#001900"
307
308
  }
308
309
  ];
309
- var r = {
310
+ var i = {
310
311
  collapsed: "simulator-collapsed",
311
312
  tab: "simulator-tab",
312
313
  theme: "simulator-theme",
@@ -318,42 +319,42 @@ var r = {
318
319
  gameSettings: "simulator-game-settings",
319
320
  hostContext: "simulator-host-context",
320
321
  keyboardDocked: "simulator-keyboard-docked"
321
- }, i = "simulator-override:";
322
+ }, a = "simulator-override:";
322
323
  /**
323
324
  * Overrides are scoped to the page that applied them. localStorage is per-origin but a dev server
324
325
  * commonly hosts many games from one origin (each at its own /games/<name>/ path), and an input
325
326
  * string is only meaningful to the game it came from.
326
327
  */
327
- function a(e) {
328
- return `${i}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
328
+ function o(e) {
329
+ return `${a}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
329
330
  }
330
331
  /** The applied override for this page, or null when nothing has been applied. "" is a real value. */
331
- function o(e) {
332
+ function s(e) {
332
333
  try {
333
- return localStorage.getItem(a(e));
334
+ return localStorage.getItem(o(e));
334
335
  } catch (e) {
335
336
  return null;
336
337
  }
337
338
  }
338
339
  /** False when the write failed — private-mode storage, or a board state over the origin's quota. */
339
- function s(e, t) {
340
+ function c(e, t) {
340
341
  try {
341
- return localStorage.setItem(a(e), t), !0;
342
+ return localStorage.setItem(o(e), t), !0;
342
343
  } catch (e) {
343
344
  return !1;
344
345
  }
345
346
  }
346
- function c(e) {
347
+ function l(e) {
347
348
  try {
348
- localStorage.removeItem(a(e));
349
+ localStorage.removeItem(o(e));
349
350
  } catch (e) {}
350
351
  }
351
- function l() {
352
- c("puzzle"), c("input");
352
+ function u() {
353
+ l("puzzle"), l("input");
353
354
  }
354
355
  /** The Host tab's persisted `hostContext` override, or null when the tab hasn't set one. */
355
- function u() {
356
- let e = localStorage.getItem(r.hostContext);
356
+ function d() {
357
+ let e = localStorage.getItem(i.hostContext);
357
358
  if (!e) return null;
358
359
  try {
359
360
  let t = JSON.parse(e);
@@ -361,21 +362,21 @@ function u() {
361
362
  } catch (e) {}
362
363
  return null;
363
364
  }
364
- function d(e) {
365
- localStorage.setItem(r.hostContext, JSON.stringify(e));
365
+ function f(e) {
366
+ localStorage.setItem(i.hostContext, JSON.stringify(e));
366
367
  }
367
- function f() {
368
- localStorage.removeItem(r.hostContext);
368
+ function p() {
369
+ localStorage.removeItem(i.hostContext);
369
370
  }
370
371
  /** The Kbd tab's "show keyboard under game" checkbox. Off until asked for: it takes space from the game. */
371
- function p() {
372
- return localStorage.getItem(r.keyboardDocked) === "true";
372
+ function m() {
373
+ return localStorage.getItem(i.keyboardDocked) === "true";
373
374
  }
374
- function m(e) {
375
- localStorage.setItem(r.keyboardDocked, String(e));
375
+ function h(e) {
376
+ localStorage.setItem(i.keyboardDocked, String(e));
376
377
  }
377
- function h() {
378
- let e = localStorage.getItem(r.gameSettings);
378
+ function g() {
379
+ let e = localStorage.getItem(i.gameSettings);
379
380
  if (!e) return {};
380
381
  try {
381
382
  let t = JSON.parse(e);
@@ -383,36 +384,36 @@ function h() {
383
384
  } catch (e) {}
384
385
  return {};
385
386
  }
386
- function g() {
387
- let e = localStorage.getItem(r.theme);
387
+ function _() {
388
+ let e = localStorage.getItem(i.theme);
388
389
  if (e) {
389
- let t = n.find((t) => t.name === e);
390
+ let t = r.find((t) => t.name === e);
390
391
  if (t) return t;
391
392
  }
392
- return n[0];
393
+ return r[0];
393
394
  }
394
- function _(e) {
395
+ function v(e) {
395
396
  var t;
396
- let n = localStorage.getItem(r.tab);
397
+ let n = localStorage.getItem(i.tab);
397
398
  return n && e.includes(n) ? n : (t = e[0]) == null ? "ctrl" : t;
398
399
  }
399
- function v(e) {
400
- let t = localStorage.getItem(r.collapsed);
400
+ function y(e) {
401
+ let t = localStorage.getItem(i.collapsed);
401
402
  return t === null ? e : t === "true";
402
403
  }
403
- function y() {
404
- let e = localStorage.getItem(r.renderHost);
404
+ function b() {
405
+ let e = localStorage.getItem(i.renderHost);
405
406
  return e && [
406
407
  "game",
407
408
  "app",
408
409
  "opengraph"
409
410
  ].includes(e) ? e : "game";
410
411
  }
411
- function b() {
412
- return localStorage.getItem(r.previewKind) === "text" ? "text" : "image";
413
- }
414
412
  function x() {
415
- let e = localStorage.getItem(r.renderContext);
413
+ return localStorage.getItem(i.previewKind) === "text" ? "text" : "image";
414
+ }
415
+ function S() {
416
+ let e = localStorage.getItem(i.renderContext);
416
417
  if (e && [
417
418
  "preview",
418
419
  "share",
@@ -421,68 +422,68 @@ function x() {
421
422
  ].includes(e)) return e;
422
423
  }
423
424
  function ee(e, t, n) {
424
- var i, a, s;
425
- let c = localStorage.getItem(r.fixtureCategory), l = localStorage.getItem(r.fixturePuzzle), d = u(), f = o("puzzle"), m = o("input");
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
427
  return {
427
- hostContext: (i = d == null ? e.hostContext : d) == null ? [{
428
+ hostContext: (r = u == null ? e.hostContext : u) == null ? [{
428
429
  type: "app",
429
430
  layout: "desktop",
430
431
  host: null
431
- }] : i,
432
- hostContextIsOverridden: d !== null,
433
- isCollapsed: v((a = e.collapsed) == null ? !0 : a),
432
+ }] : r,
433
+ hostContextIsOverridden: u !== null,
434
+ isCollapsed: y((a = e.collapsed) == null ? !0 : a),
434
435
  isPaused: !1,
435
436
  hasStarted: !1,
436
- activeTab: _(n),
437
+ activeTab: v(n),
437
438
  puzzleData: f,
438
439
  originalPuzzle: f == null ? "" : f,
439
- currentInputStr: m == null ? "" : m,
440
+ currentInputStr: p == null ? "" : p,
440
441
  appliedPuzzleOverride: f,
441
- appliedInputOverride: m,
442
+ appliedInputOverride: p,
442
443
  completionData: null,
443
- selectedTheme: g(),
444
- selectedCategory: c && t.includes(c) ? c : (s = t[0]) == null ? null : s,
444
+ selectedTheme: _(),
445
+ selectedCategory: c && t.includes(c) ? c : (o = t[0]) == null ? null : o,
445
446
  selectedPuzzle: l == null ? null : l,
446
- renderHost: y(),
447
- renderContext: x(),
448
- previewKind: b(),
449
- gameSettings: h(),
450
- keyboardDocked: p(),
447
+ renderHost: b(),
448
+ renderContext: S(),
449
+ previewKind: x(),
450
+ gameSettings: g(),
451
+ keyboardDocked: m(),
451
452
  settingsComponents: null
452
453
  };
453
454
  }
454
- function S(e) {
455
- localStorage.setItem(r.gameSettings, JSON.stringify(e));
455
+ function C(e) {
456
+ localStorage.setItem(i.gameSettings, JSON.stringify(e));
456
457
  }
457
- function C() {
458
- localStorage.removeItem(r.gameSettings);
458
+ function w() {
459
+ localStorage.removeItem(i.gameSettings);
459
460
  }
460
461
  function te(e) {
461
- localStorage.setItem(r.collapsed, String(e));
462
+ localStorage.setItem(i.collapsed, String(e));
462
463
  }
463
464
  function ne(e) {
464
- localStorage.setItem(r.tab, e);
465
- }
466
- function w(e) {
467
- localStorage.setItem(r.theme, e);
465
+ localStorage.setItem(i.tab, e);
468
466
  }
469
467
  function T(e) {
470
- localStorage.setItem(r.fixtureCategory, e);
468
+ localStorage.setItem(i.theme, e);
471
469
  }
472
470
  function E(e) {
473
- localStorage.setItem(r.fixturePuzzle, e);
471
+ localStorage.setItem(i.fixtureCategory, e);
474
472
  }
475
- function D() {
476
- localStorage.removeItem(r.fixturePuzzle);
473
+ function D(e) {
474
+ localStorage.setItem(i.fixturePuzzle, e);
477
475
  }
478
- function O(e) {
479
- e ? localStorage.setItem(r.renderHost, e) : localStorage.removeItem(r.renderHost);
476
+ function O() {
477
+ localStorage.removeItem(i.fixturePuzzle);
480
478
  }
481
479
  function k(e) {
482
- localStorage.setItem(r.previewKind, e);
480
+ e ? localStorage.setItem(i.renderHost, e) : localStorage.removeItem(i.renderHost);
483
481
  }
484
482
  function A(e) {
485
- e ? localStorage.setItem(r.renderContext, e) : localStorage.removeItem(r.renderContext);
483
+ localStorage.setItem(i.previewKind, e);
484
+ }
485
+ function j(e) {
486
+ e ? localStorage.setItem(i.renderContext, e) : localStorage.removeItem(i.renderContext);
486
487
  }
487
488
  function re(e) {
488
489
  let t = [];
@@ -509,13 +510,13 @@ function re(e) {
509
510
  }
510
511
  };
511
512
  }
512
- function ie(e, t, n) {
513
+ function M(e, t, n) {
513
514
  console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
514
515
  type: e,
515
516
  data: t
516
517
  }, "*");
517
518
  }
518
- function ae(e, t) {
519
+ function N(e, t) {
519
520
  let n = (n) => {
520
521
  var r, i, a;
521
522
  if (!(!(n == null || (r = n.data) == null) && r.type)) return;
@@ -525,7 +526,7 @@ function ae(e, t) {
525
526
  return window.addEventListener("message", n), () => window.removeEventListener("message", n);
526
527
  }
527
528
  /** Parse fixture imports into a structured format: { category: { filename: data } } */
528
- function oe(e) {
529
+ function ie(e) {
529
530
  let t = /* @__PURE__ */ new Map();
530
531
  console.log("Simulator: Parsing fixtures", Object.keys(e));
531
532
  for (let [o, s] of Object.entries(e)) {
@@ -544,7 +545,7 @@ function oe(e) {
544
545
  }), t;
545
546
  }
546
547
  /** Render fixture selector HTML */
547
- function j(e, t) {
548
+ function P(e, t) {
548
549
  return e.length === 0 ? "" : `
549
550
  <div class="simulator-fixtures">
550
551
  <div class="simulator-field">
@@ -561,7 +562,7 @@ function j(e, t) {
561
562
  `;
562
563
  }
563
564
  /** Update puzzle select options based on selected category */
564
- function M(e, t, n, r) {
565
+ function F(e, t, n, r) {
565
566
  let i = t.get(n);
566
567
  if (!i) return null;
567
568
  let a = Array.from(i.keys()), o = r;
@@ -572,7 +573,7 @@ function M(e, t, n, r) {
572
573
  return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
573
574
  }
574
575
  /** Get puzzle data from fixtures */
575
- function N(e, t, n) {
576
+ function I(e, t, n) {
576
577
  var r, i;
577
578
  return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
578
579
  }
@@ -584,8 +585,8 @@ function N(e, t, n) {
584
585
  * `puzzmo games validate` greps build output for it — keep it in sync with the copy in
585
586
  * packages/cli/src/util/lintDist.ts.
586
587
  */
587
- const se = "puzzmo-simulator-dev-only-do-not-ship";
588
- function ce() {
588
+ const ae = "puzzmo-simulator-dev-only-do-not-ship";
589
+ function oe() {
589
590
  return {
590
591
  id: "ctrl",
591
592
  label: "Ctrl",
@@ -600,19 +601,19 @@ function ce() {
600
601
  selectedCategory: e.state.selectedCategory,
601
602
  selectedPuzzle: e.state.selectedPuzzle
602
603
  }), e.fixtures && e.fixtureCategories.length > 0 && i) {
603
- i.innerHTML = j(e.fixtureCategories, e.state.selectedCategory);
604
+ i.innerHTML = P(e.fixtureCategories, e.state.selectedCategory);
604
605
  let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
605
606
  if (t && n && e.state.selectedCategory) {
606
- e.state.selectedPuzzle = M(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
607
- let r = N(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
607
+ e.state.selectedPuzzle = F(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
608
+ let r = I(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
608
609
  console.log("Simulator: Loading fixture puzzle", {
609
610
  category: e.state.selectedCategory,
610
611
  puzzle: e.state.selectedPuzzle,
611
612
  hasPuzzleData: !!r
612
- }), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && T(e.state.selectedCategory), e.state.selectedPuzzle && E(e.state.selectedPuzzle)), t.addEventListener("change", () => {
613
- console.log("Simulator: Category changed, reloading...", t.value), l(), T(t.value), D(), window.location.reload();
613
+ }), 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", () => {
614
+ console.log("Simulator: Category changed, reloading...", t.value), u(), E(t.value), O(), window.location.reload();
614
615
  }), n.addEventListener("change", () => {
615
- console.log("Simulator: Puzzle changed, reloading...", n.value), l(), E(n.value), window.location.reload();
616
+ console.log("Simulator: Puzzle changed, reloading...", n.value), u(), D(n.value), window.location.reload();
616
617
  });
617
618
  }
618
619
  }
@@ -638,10 +639,10 @@ function ce() {
638
639
  * Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
639
640
  * must stay self-contained.
640
641
  */
641
- function P(e) {
642
+ function L(e) {
642
643
  var t;
643
644
  if (typeof e != "string") return e;
644
- let n = (t = F(e)) == null ? {
645
+ let n = (t = R(e)) == null ? {
645
646
  width: 800,
646
647
  height: 800
647
648
  } : t;
@@ -652,7 +653,7 @@ function P(e) {
652
653
  };
653
654
  }
654
655
  /** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
655
- function F(e) {
656
+ function R(e) {
656
657
  var t, n, r, i;
657
658
  let a = e.indexOf("<svg");
658
659
  if (a === -1) return;
@@ -670,9 +671,9 @@ function F(e) {
670
671
  height: u
671
672
  };
672
673
  }
673
- var I = "simulator-saved-states";
674
+ var z = "simulator-saved-states";
674
675
  /** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
675
- function L() {
676
+ function B() {
676
677
  let e = globalThis;
677
678
  for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
678
679
  name: t,
@@ -681,8 +682,8 @@ function L() {
681
682
  return null;
682
683
  }
683
684
  /** Generate a small thumbnail SVG for a given input string */
684
- function R(e, t) {
685
- let n = L();
685
+ function V(e, t) {
686
+ let n = B();
686
687
  if (!n) return "";
687
688
  try {
688
689
  var r;
@@ -692,19 +693,19 @@ function R(e, t) {
692
693
  strict: !0,
693
694
  renderHost: "game"
694
695
  };
695
- return P(n.fn(i, t, a)).svg;
696
+ return L(n.fn(i, t, a)).svg;
696
697
  } catch (e) {
697
698
  return "";
698
699
  }
699
700
  }
700
- var z = [];
701
- function B(e, t = 8) {
701
+ var H = [];
702
+ function U(e, t = 8) {
702
703
  let n = 14 * t + 8 + 4;
703
704
  e.style.height = "auto";
704
705
  let r = Math.min(Math.max(e.scrollHeight, 40), n);
705
706
  e.style.height = `${r}px`;
706
707
  }
707
- function le() {
708
+ function se() {
708
709
  let e = "", t = "";
709
710
  return {
710
711
  id: "data",
@@ -722,43 +723,43 @@ function le() {
722
723
  let i = n.getElement(".data-view-container");
723
724
  i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
724
725
  e.classList.toggle("active", e.id === `data-subtab-${t}`);
725
- }), t === "edit" ? de(n) : t === "history" ? H(n) : t === "saves" && U(n);
726
+ }), t === "edit" ? ue(n) : t === "history" ? W(n) : t === "saves" && G(n);
726
727
  });
727
728
  });
728
- let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), l = n.getElement("#simulator-puzzle-apply"), u = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
729
+ 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");
729
730
  setTimeout(() => {
730
- i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, B(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, B(a)), fe(n);
731
+ 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)), de(n);
731
732
  }, 0), i == null || i.addEventListener("input", () => {
732
- B(i);
733
+ U(i);
733
734
  let t = i.value !== e;
734
- l && (l.disabled = !t);
735
+ s && (s.disabled = !t);
735
736
  }), a == null || a.addEventListener("input", () => {
736
- B(a);
737
+ U(a);
737
738
  let e = a.value !== t;
738
739
  d && (d.disabled = !e);
739
740
  }), o == null || o.addEventListener("click", () => {
740
741
  if (n.state.appliedPuzzleOverride !== null) {
741
- c("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
742
+ l("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
742
743
  return;
743
744
  }
744
- i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, B(i), l && (l.disabled = !0));
745
- }), l == null || l.addEventListener("click", () => {
745
+ i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i), s && (s.disabled = !0));
746
+ }), s == null || s.addEventListener("click", () => {
746
747
  if (i) {
747
- if (!s("puzzle", i.value)) {
748
+ if (!c("puzzle", i.value)) {
748
749
  n.updateStatus("Could not store puzzle — storage unavailable", "paused");
749
750
  return;
750
751
  }
751
- c("input"), l.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
752
+ l("input"), s.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
752
753
  }
753
754
  }), u == null || u.addEventListener("click", () => {
754
755
  if (n.state.appliedInputOverride !== null) {
755
- c("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
756
+ l("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
756
757
  return;
757
758
  }
758
- a && (a.value = t, B(a), d && (d.disabled = !0));
759
+ a && (a.value = t, U(a), d && (d.disabled = !0));
759
760
  }), d == null || d.addEventListener("click", () => {
760
761
  if (a) {
761
- if (!s("input", a.value)) {
762
+ if (!c("input", a.value)) {
762
763
  n.updateStatus("Could not store input — storage unavailable", "paused");
763
764
  return;
764
765
  }
@@ -767,87 +768,87 @@ function le() {
767
768
  });
768
769
  let f = n.getElement("#simulator-history-clear");
769
770
  f == null || f.addEventListener("click", () => {
770
- z = [], H(n);
771
+ H = [], W(n);
771
772
  });
772
773
  let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
773
774
  m == null || m.addEventListener("click", () => {
774
775
  if (!p || !p.value.trim()) return;
775
- let e = V(), t = {
776
+ let e = ce(), t = {
776
777
  name: p.value.trim(),
777
778
  puzzleStr: n.state.originalPuzzle,
778
779
  inputStr: n.state.currentInputStr,
779
780
  timestamp: Date.now()
780
781
  };
781
- e.push(t), localStorage.setItem(I, JSON.stringify(e)), p.value = "", U(n);
782
- }), U(n);
782
+ e.push(t), localStorage.setItem(z, JSON.stringify(e)), p.value = "", G(n);
783
+ }), G(n);
783
784
  },
784
785
  onActivate(n) {
785
- e = n.state.originalPuzzle, t = n.state.currentInputStr, de(n), H(n);
786
+ e = n.state.originalPuzzle, t = n.state.currentInputStr, ue(n), W(n);
786
787
  },
787
788
  onMessage(e, n, r) {
788
789
  var i, a;
789
790
  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;
790
791
  if (e === "UPLOAD_NEW_GAME_STATE" && c) {
791
- if (r.state.currentInputStr = c, z.length === 0 || z[z.length - 1].value !== c) {
792
- z.push({
792
+ if (r.state.currentInputStr = c, H.length === 0 || H[H.length - 1].value !== c) {
793
+ H.push({
793
794
  value: c,
794
795
  timestamp: Date.now()
795
- }), z.length > 100 && (z = z.slice(-100));
796
+ }), H.length > 100 && (H = H.slice(-100));
796
797
  let e = r.getElement("#data-subtab-history");
797
- e != null && e.classList.contains("active") && H(r);
798
+ e != null && e.classList.contains("active") && W(r);
798
799
  }
799
- o && document.activeElement !== o && (o.value !== c && (o.value = c, B(o)), t = c, s && (s.disabled = !0));
800
+ o && document.activeElement !== o && (o.value !== c && (o.value = c, U(o)), t = c, s && (s.disabled = !0));
800
801
  }
801
802
  }
802
803
  };
803
804
  }
804
- function V() {
805
+ function ce() {
805
806
  try {
806
- let e = localStorage.getItem(I);
807
+ let e = localStorage.getItem(z);
807
808
  return e ? JSON.parse(e) : [];
808
809
  } catch (e) {
809
810
  return [];
810
811
  }
811
812
  }
812
- function H(e) {
813
+ function W(e) {
813
814
  let t = e.getElement("#simulator-history-list");
814
815
  if (t) {
815
- if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), z.length === 0) {
816
+ if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), H.length === 0) {
816
817
  t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
817
818
  return;
818
819
  }
819
- t.innerHTML = [...z].reverse().map((t, n) => {
820
- let r = z.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
820
+ t.innerHTML = [...H].reverse().map((t, n) => {
821
+ let r = H.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
821
822
  return `
822
823
  <div class="history-item" data-history-idx="${r}">
823
- <div class="history-item-thumb">${R(e, t.value)}</div>
824
+ <div class="history-item-thumb">${V(e, t.value)}</div>
824
825
  <div class="history-item-content">
825
826
  <div class="history-item-header">
826
827
  <span class="history-item-num">#${r + 1}</span>
827
828
  <span class="history-item-time">${i}</span>
828
829
  <button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
829
830
  </div>
830
- <div class="history-item-preview">${ue(a)}</div>
831
+ <div class="history-item-preview">${le(a)}</div>
831
832
  </div>
832
833
  </div>
833
834
  `;
834
835
  }).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
835
836
  t.addEventListener("click", (t) => {
836
- let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = z[n];
837
+ let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = H[n];
837
838
  if (r) {
838
839
  let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
839
840
  t == null || t.click();
840
841
  let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
841
- n && (n.value = r.value, B(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
842
+ n && (n.value = r.value, U(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
842
843
  }
843
844
  });
844
845
  });
845
846
  }
846
847
  }
847
- function U(e) {
848
+ function G(e) {
848
849
  let t = e.getElement("#simulator-saves-list");
849
850
  if (!t) return;
850
- let n = V();
851
+ let n = ce();
851
852
  if (n.length === 0) {
852
853
  t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
853
854
  return;
@@ -857,7 +858,7 @@ function U(e) {
857
858
  return `
858
859
  <div class="save-item">
859
860
  <div class="save-item-header">
860
- <span class="save-item-name">${ue(e.name)}</span>
861
+ <span class="save-item-name">${le(e.name)}</span>
861
862
  <span class="save-item-time">${i} ${a}</span>
862
863
  </div>
863
864
  <div class="save-item-actions">
@@ -870,8 +871,8 @@ function U(e) {
870
871
  t.addEventListener("click", (t) => {
871
872
  let r = n[parseInt(t.target.getAttribute("data-save-idx") || "0")];
872
873
  if (r) {
873
- if (!s("puzzle", r.puzzleStr) || !s("input", r.inputStr)) {
874
- l(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
874
+ if (!c("puzzle", r.puzzleStr) || !c("input", r.inputStr)) {
875
+ u(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
875
876
  return;
876
877
  }
877
878
  e.updateStatus(`Loading: ${r.name}`, "waiting"), window.location.reload();
@@ -880,25 +881,25 @@ function U(e) {
880
881
  }), t.querySelectorAll(".save-delete-btn").forEach((t) => {
881
882
  t.addEventListener("click", (t) => {
882
883
  let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
883
- localStorage.setItem(I, JSON.stringify(i)), U(e);
884
+ localStorage.setItem(z, JSON.stringify(i)), G(e);
884
885
  });
885
886
  });
886
887
  }
887
- function ue(e) {
888
+ function le(e) {
888
889
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
889
890
  }
890
- function de(e) {
891
+ function ue(e) {
891
892
  let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
892
- t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, B(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, B(n), i && (i.disabled = !0)), fe(e);
893
+ 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)), de(e);
893
894
  }
894
- function fe(e) {
895
+ function de(e) {
895
896
  let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
896
897
  t && (t.hidden = e.state.appliedPuzzleOverride === null), n && (n.hidden = e.state.appliedInputOverride === null);
897
898
  }
898
- function pe(e) {
899
+ function fe(e) {
899
900
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
900
901
  }
901
- function me() {
902
+ function pe() {
902
903
  let e = 0;
903
904
  return {
904
905
  id: "msgs",
@@ -925,7 +926,7 @@ function me() {
925
926
  <span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
926
927
  <span class="simulator-msg-time">${t.time}</span>
927
928
  </div>
928
- ${a ? `<div class="simulator-msg-data">${pe(a)}</div>` : ""}
929
+ ${a ? `<div class="simulator-msg-data">${fe(a)}</div>` : ""}
929
930
  `;
930
931
  let o = i.querySelector(".simulator-msg-data");
931
932
  for (o && o.addEventListener("click", () => {
@@ -936,7 +937,7 @@ function me() {
936
937
  }
937
938
  };
938
939
  }
939
- function he() {
940
+ function me() {
940
941
  return {
941
942
  id: "done",
942
943
  label: "Done",
@@ -973,7 +974,7 @@ function he() {
973
974
  }
974
975
  };
975
976
  }
976
- function ge() {
977
+ function he() {
977
978
  let e = [], t = () => (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), n = (e) => {
978
979
  let { checkpointName: t, augConfig: n, time: r } = e, i = n == null ? void 0 : n.deeds;
979
980
  return `
@@ -1023,8 +1024,1676 @@ function ge() {
1023
1024
  }
1024
1025
  };
1025
1026
  }
1027
+ var ge = /* @__PURE__ */ n(((e) => {
1028
+ var t = { document: {} }, n = Object.prototype.hasOwnProperty, r = function(e) {
1029
+ return v(e) ? e.toLowerCase() : e;
1030
+ }, i = Array.isArray;
1031
+ function a(e) {
1032
+ var t = Function.prototype.constructor;
1033
+ delete Function.prototype.constructor;
1034
+ var n = e();
1035
+ return Function.prototype.constructor = t, n;
1036
+ }
1037
+ var o, s = Object.prototype.toString, c = Object.getPrototypeOf, l = O("ng");
1038
+ /**
1039
+ * @private
1040
+ * @param {*} obj
1041
+ * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments,
1042
+ * String ...)
1043
+ */
1044
+ function u(e) {
1045
+ if (e == null || x(e)) return !1;
1046
+ if (i(e) || v(e) || o && e instanceof o) return !0;
1047
+ var t = "length" in Object(e) && e.length;
1048
+ return y(t) && (t >= 0 && (t - 1 in e || e instanceof Array) || typeof e.item == "function");
1049
+ }
1050
+ /**
1051
+ * @ngdoc function
1052
+ * @name angular.forEach
1053
+ * @module ng
1054
+ * @kind function
1055
+ *
1056
+ * @description
1057
+ * Invokes the `iterator` function once for each item in `obj` collection, which can be either an
1058
+ * object or an array. The `iterator` function is invoked with `iterator(value, key, obj)`, where `value`
1059
+ * is the value of an object property or an array element, `key` is the object property key or
1060
+ * array element index and obj is the `obj` itself. Specifying a `context` for the function is optional.
1061
+ *
1062
+ * It is worth noting that `.forEach` does not iterate over inherited properties because it filters
1063
+ * using the `hasOwnProperty` method.
1064
+ *
1065
+ * Unlike ES262's
1066
+ * [Array.prototype.forEach](http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.18),
1067
+ * providing 'undefined' or 'null' values for `obj` will not throw a TypeError, but rather just
1068
+ * return the value provided.
1069
+ *
1070
+ ```js
1071
+ var values = {name: 'misko', gender: 'male'};
1072
+ var log = [];
1073
+ angular.forEach(values, function(value, key) {
1074
+ this.push(key + ': ' + value);
1075
+ }, log);
1076
+ expect(log).toEqual(['name: misko', 'gender: male']);
1077
+ ```
1078
+ *
1079
+ * @param {Object|Array} obj Object to iterate over.
1080
+ * @param {Function} iterator Iterator function.
1081
+ * @param {Object=} context Object to become context (`this`) for the iterator function.
1082
+ * @returns {Object|Array} Reference to `obj`.
1083
+ */
1084
+ function d(e, t, r) {
1085
+ var a, o;
1086
+ if (e) if (b(e)) for (a in e) a !== "prototype" && a !== "length" && a !== "name" && e.hasOwnProperty(a) && t.call(r, e[a], a, e);
1087
+ else if (i(e) || u(e)) {
1088
+ var s = typeof e != "object";
1089
+ for (a = 0, o = e.length; a < o; a++) (s || a in e) && t.call(r, e[a], a, e);
1090
+ } else if (e.forEach && e.forEach !== d) e.forEach(t, r, e);
1091
+ else if (_(e)) for (a in e) t.call(r, e[a], a, e);
1092
+ else if (typeof e.hasOwnProperty == "function") for (a in e) e.hasOwnProperty(a) && t.call(r, e[a], a, e);
1093
+ else for (a in e) n.call(e, a) && t.call(r, e[a], a, e);
1094
+ return e;
1095
+ }
1096
+ /**
1097
+ * Set or clear the hashkey for an object.
1098
+ * @param obj object
1099
+ * @param h the hashkey (!truthy to delete the hashkey)
1100
+ */
1101
+ function f(e, t) {
1102
+ t ? e.$$hashKey = t : delete e.$$hashKey;
1103
+ }
1104
+ function p() {}
1105
+ /**
1106
+ * @ngdoc function
1107
+ * @name angular.isUndefined
1108
+ * @module ng
1109
+ * @kind function
1110
+ *
1111
+ * @description
1112
+ * Determines if a reference is undefined.
1113
+ *
1114
+ * @param {*} value Reference to check.
1115
+ * @returns {boolean} True if `value` is undefined.
1116
+ */
1117
+ function m(e) {
1118
+ return e === void 0;
1119
+ }
1120
+ /**
1121
+ * @ngdoc function
1122
+ * @name angular.isDefined
1123
+ * @module ng
1124
+ * @kind function
1125
+ *
1126
+ * @description
1127
+ * Determines if a reference is defined.
1128
+ *
1129
+ * @param {*} value Reference to check.
1130
+ * @returns {boolean} True if `value` is defined.
1131
+ */
1132
+ function h(e) {
1133
+ return e !== void 0;
1134
+ }
1135
+ /**
1136
+ * @ngdoc function
1137
+ * @name angular.isObject
1138
+ * @module ng
1139
+ * @kind function
1140
+ *
1141
+ * @description
1142
+ * Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not
1143
+ * considered to be objects. Note that JavaScript arrays are objects.
1144
+ *
1145
+ * @param {*} value Reference to check.
1146
+ * @returns {boolean} True if `value` is an `Object` but not `null`.
1147
+ */
1148
+ function g(e) {
1149
+ return typeof e == "object" && !!e;
1150
+ }
1151
+ /**
1152
+ * Determine if a value is an object with a null prototype
1153
+ *
1154
+ * @returns {boolean} True if `value` is an `Object` with a null prototype
1155
+ */
1156
+ function _(e) {
1157
+ return typeof e == "object" && !!e && !c(e);
1158
+ }
1159
+ /**
1160
+ * @ngdoc function
1161
+ * @name angular.isString
1162
+ * @module ng
1163
+ * @kind function
1164
+ *
1165
+ * @description
1166
+ * Determines if a reference is a `String`.
1167
+ *
1168
+ * @param {*} value Reference to check.
1169
+ * @returns {boolean} True if `value` is a `String`.
1170
+ */
1171
+ function v(e) {
1172
+ return typeof e == "string";
1173
+ }
1174
+ /**
1175
+ * @ngdoc function
1176
+ * @name angular.isNumber
1177
+ * @module ng
1178
+ * @kind function
1179
+ *
1180
+ * @description
1181
+ * Determines if a reference is a `Number`.
1182
+ *
1183
+ * This includes the "special" numbers `NaN`, `+Infinity` and `-Infinity`.
1184
+ *
1185
+ * If you wish to exclude these then you can use the native
1186
+ * [`isFinite'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
1187
+ * method.
1188
+ *
1189
+ * @param {*} value Reference to check.
1190
+ * @returns {boolean} True if `value` is a `Number`.
1191
+ */
1192
+ function y(e) {
1193
+ return typeof e == "number";
1194
+ }
1195
+ /**
1196
+ * @ngdoc function
1197
+ * @name angular.isFunction
1198
+ * @module ng
1199
+ * @kind function
1200
+ *
1201
+ * @description
1202
+ * Determines if a reference is a `Function`.
1203
+ *
1204
+ * @param {*} value Reference to check.
1205
+ * @returns {boolean} True if `value` is a `Function`.
1206
+ */
1207
+ function b(e) {
1208
+ return typeof e == "function";
1209
+ }
1210
+ /**
1211
+ * Checks if `obj` is a window object.
1212
+ *
1213
+ * @private
1214
+ * @param {*} obj Object to check
1215
+ * @returns {boolean} True if `obj` is a window obj.
1216
+ */
1217
+ function x(e) {
1218
+ return e && e.window === e;
1219
+ }
1220
+ function S(e) {
1221
+ return e && e.$evalAsync && e.$watch;
1222
+ }
1223
+ var ee = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;
1224
+ function C(e) {
1225
+ return e && y(e.length) && ee.test(s.call(e));
1226
+ }
1227
+ function w(e) {
1228
+ return s.call(e) === "[object ArrayBuffer]";
1229
+ }
1230
+ /**
1231
+ * @ngdoc function
1232
+ * @name angular.copy
1233
+ * @module ng
1234
+ * @kind function
1235
+ *
1236
+ * @description
1237
+ * Creates a deep copy of `source`, which should be an object or an array.
1238
+ *
1239
+ * * If no destination is supplied, a copy of the object or array is created.
1240
+ * * If a destination is provided, all of its elements (for arrays) or properties (for objects)
1241
+ * are deleted and then all elements/properties from the source are copied to it.
1242
+ * * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned.
1243
+ * * If `source` is identical to `destination` an exception will be thrown.
1244
+ *
1245
+ * <br />
1246
+ * <div class="alert alert-warning">
1247
+ * Only enumerable properties are taken into account. Non-enumerable properties (both on `source`
1248
+ * and on `destination`) will be ignored.
1249
+ * </div>
1250
+ *
1251
+ * @param {*} source The source that will be used to make a copy.
1252
+ * Can be any type, including primitives, `null`, and `undefined`.
1253
+ * @param {(Object|Array)=} destination Destination into which the source is copied. If
1254
+ * provided, must be of the same type as `source`.
1255
+ * @returns {*} The copy or updated `destination`, if `destination` was specified.
1256
+ *
1257
+ * @example
1258
+ <example module="copyExample" name="angular-copy">
1259
+ <file name="index.html">
1260
+ <div ng-controller="ExampleController">
1261
+ <form novalidate class="simple-form">
1262
+ <label>Name: <input type="text" ng-model="user.name" /></label><br />
1263
+ <label>Age: <input type="number" ng-model="user.age" /></label><br />
1264
+ Gender: <label><input type="radio" ng-model="user.gender" value="male" />male</label>
1265
+ <label><input type="radio" ng-model="user.gender" value="female" />female</label><br />
1266
+ <button ng-click="reset()">RESET</button>
1267
+ <button ng-click="update(user)">SAVE</button>
1268
+ </form>
1269
+ <pre>form = {{user | json}}</pre>
1270
+ <pre>master = {{master | json}}</pre>
1271
+ </div>
1272
+ </file>
1273
+ <file name="script.js">
1274
+ // Module: copyExample
1275
+ angular.
1276
+ module('copyExample', []).
1277
+ controller('ExampleController', ['$scope', function($scope) {
1278
+ $scope.master = {};
1279
+
1280
+ $scope.reset = function() {
1281
+ // Example with 1 argument
1282
+ $scope.user = angular.copy($scope.master);
1283
+ };
1284
+
1285
+ $scope.update = function(user) {
1286
+ // Example with 2 arguments
1287
+ angular.copy(user, $scope.master);
1288
+ };
1289
+
1290
+ $scope.reset();
1291
+ }]);
1292
+ </file>
1293
+ </example>
1294
+ */
1295
+ function te(e, t) {
1296
+ var r = [], a = [];
1297
+ if (t) {
1298
+ if (C(t) || w(t)) throw l("cpta", "Can't copy! TypedArray destination cannot be mutated.");
1299
+ if (e === t) throw l("cpi", "Can't copy! Source and destination are identical.");
1300
+ return i(t) ? t.length = 0 : d(t, function(e, n) {
1301
+ n !== "$$hashKey" && delete t[n];
1302
+ }), r.push(e), a.push(t), o(e, t);
1303
+ }
1304
+ return u(e);
1305
+ function o(e, t) {
1306
+ var r = t.$$hashKey, a;
1307
+ if (i(e)) for (var o = 0, s = e.length; o < s; o++) t.push(u(e[o]));
1308
+ else if (_(e)) for (a in e) t[a] = u(e[a]);
1309
+ else if (e && typeof e.hasOwnProperty == "function") for (a in e) e.hasOwnProperty(a) && (t[a] = u(e[a]));
1310
+ else for (a in e) n.call(e, a) && (t[a] = u(e[a]));
1311
+ return f(t, r), t;
1312
+ }
1313
+ function u(e) {
1314
+ if (!g(e)) return e;
1315
+ var t = r.indexOf(e);
1316
+ if (t !== -1) return a[t];
1317
+ if (x(e) || S(e)) throw l("cpws", "Can't copy! Making copies of Window or Scope instances is not supported.");
1318
+ var n = !1, s = p(e);
1319
+ return s === void 0 && (s = i(e) ? [] : Object.create(c(e)), n = !0), r.push(e), a.push(s), n ? o(e, s) : s;
1320
+ }
1321
+ function p(e) {
1322
+ switch (s.call(e)) {
1323
+ case "[object Int8Array]":
1324
+ case "[object Int16Array]":
1325
+ case "[object Int32Array]":
1326
+ case "[object Float32Array]":
1327
+ case "[object Float64Array]":
1328
+ case "[object Uint8Array]":
1329
+ case "[object Uint8ClampedArray]":
1330
+ case "[object Uint16Array]":
1331
+ case "[object Uint32Array]": return new e.constructor(u(e.buffer), e.byteOffset, e.length);
1332
+ case "[object ArrayBuffer]":
1333
+ if (!e.slice) {
1334
+ var t = new ArrayBuffer(e.byteLength);
1335
+ return new Uint8Array(t).set(new Uint8Array(e)), t;
1336
+ }
1337
+ return e.slice(0);
1338
+ case "[object Boolean]":
1339
+ case "[object Number]":
1340
+ case "[object String]":
1341
+ case "[object Date]": return new e.constructor(e.valueOf());
1342
+ case "[object RegExp]":
1343
+ var n = new RegExp(e.source, e.toString().match(/[^\/]*$/)[0]);
1344
+ return n.lastIndex = e.lastIndex, n;
1345
+ case "[object Blob]": return new e.constructor([e], { type: e.type });
1346
+ }
1347
+ if (b(e.cloneNode)) return e.cloneNode(!0);
1348
+ }
1349
+ }
1350
+ /**
1351
+ * @ngdoc function
1352
+ * @name angular.bind
1353
+ * @module ng
1354
+ * @kind function
1355
+ *
1356
+ * @description
1357
+ * Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for
1358
+ * `fn`). You can supply optional `args` that are prebound to the function. This feature is also
1359
+ * known as [partial application](http://en.wikipedia.org/wiki/Partial_application), as
1360
+ * distinguished from [function currying](http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application).
1361
+ *
1362
+ * @param {Object} self Context which `fn` should be evaluated in.
1363
+ * @param {function()} fn Function to be bound.
1364
+ * @param {...*} args Optional arguments to be prebound to the `fn` function call.
1365
+ * @returns {function()} Function that wraps the `fn` with all the specified bindings.
1366
+ */
1367
+ function ne(e, n) {
1368
+ var r = n;
1369
+ 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;
1370
+ }
1371
+ /**
1372
+ * Creates a new object without a prototype. This object is useful for lookup without having to
1373
+ * guard against prototypically inherited properties via hasOwnProperty.
1374
+ *
1375
+ * Related micro-benchmarks:
1376
+ * - http://jsperf.com/object-create2
1377
+ * - http://jsperf.com/proto-map-lookup/2
1378
+ * - http://jsperf.com/for-in-vs-object-keys2
1379
+ *
1380
+ * @returns {Object}
1381
+ */
1382
+ function T() {
1383
+ return Object.create(null);
1384
+ }
1385
+ function E(e) {
1386
+ var t = [];
1387
+ return JSON.stringify(e, function(e, n) {
1388
+ if (n = ne(e, n), g(n)) {
1389
+ if (t.indexOf(n) >= 0) return "...";
1390
+ t.push(n);
1391
+ }
1392
+ return n;
1393
+ });
1394
+ }
1395
+ function D(e) {
1396
+ return typeof e == "function" ? e.toString().replace(/ \{[\s\S]*$/, "") : m(e) ? "undefined" : typeof e == "string" ? e : E(e);
1397
+ }
1398
+ /**
1399
+ * @description
1400
+ *
1401
+ * This object provides a utility for producing rich Error messages within
1402
+ * Angular. It can be called as follows:
1403
+ *
1404
+ * var exampleMinErr = minErr('example');
1405
+ * throw exampleMinErr('one', 'This {0} is {1}', foo, bar);
1406
+ *
1407
+ * The above creates an instance of minErr in the example namespace. The
1408
+ * resulting error will have a namespaced error code of example.one. The
1409
+ * resulting error will replace {0} with the value of foo, and {1} with the
1410
+ * value of bar. The object is not restricted in the number of arguments it can
1411
+ * take.
1412
+ *
1413
+ * If fewer arguments are specified than necessary for interpolation, the extra
1414
+ * interpolation markers will be preserved in the final string.
1415
+ *
1416
+ * Since data will be parsed statically during a build step, some restrictions
1417
+ * are applied with respect to how minErr instances are created and called.
1418
+ * Instances should have names of the form namespaceMinErr for a minErr created
1419
+ * using minErr('namespace') . Error codes, namespaces and template strings
1420
+ * should all be static strings, not variables or general expressions.
1421
+ *
1422
+ * @param {string} module The namespace to use for the new minErr instance.
1423
+ * @param {function} ErrorConstructor Custom error constructor to be instantiated when returning
1424
+ * error from returned function, for cases when a particular type of error is useful.
1425
+ * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance
1426
+ */
1427
+ function O(e, t) {
1428
+ return t = t || Error, function() {
1429
+ var n = 2, r = arguments, i = r[0], a = "[" + (e ? e + ":" : "") + i + "] ", o = r[1], s, c;
1430
+ for (a += o.replace(/\{\d+\}/g, function(e) {
1431
+ var t = +e.slice(1, -1) + n;
1432
+ return t < r.length ? D(r[t]) : e;
1433
+ }), a += "\nhttp://errors.angularjs.org/\"NG_VERSION_FULL\"/" + (e ? e + "/" : "") + i, c = n, s = "?"; c < r.length; c++, s = "&") a += s + "p" + (c - n) + "=" + encodeURIComponent(D(r[c]));
1434
+ return new t(a);
1435
+ };
1436
+ }
1437
+ var k = O("$parse");
1438
+ function A(e) {
1439
+ return e + "";
1440
+ }
1441
+ var j = T();
1442
+ d("+ - * / % === !== == != < > <= >= && || ?? ! = | ?".split(" "), function(e) {
1443
+ j[e] = !0;
1444
+ });
1445
+ var re = {
1446
+ n: "\n",
1447
+ f: "\f",
1448
+ r: "\r",
1449
+ t: " ",
1450
+ v: "\v",
1451
+ "'": "'",
1452
+ "\"": "\""
1453
+ };
1454
+ /**
1455
+ * @constructor
1456
+ */
1457
+ function M(e) {
1458
+ this.options = e || {};
1459
+ }
1460
+ M.prototype = {
1461
+ constructor: M,
1462
+ lex: function(e) {
1463
+ for (this.text = e, this.index = 0, this.tokens = []; this.index < this.text.length;) {
1464
+ var t = this.text.charAt(this.index);
1465
+ if (t === "\"" || t === "'" || t === "`") this.readString(t);
1466
+ else if (this.isNumber(t) || t === "." && this.isNumber(this.peek())) this.readNumber();
1467
+ else if (this.isIdentifierStart(this.peekMultichar())) this.readIdent();
1468
+ else if (this.is(t, "(){}[].,;:")) this.tokens.push({
1469
+ index: this.index,
1470
+ text: t
1471
+ }), this.index++;
1472
+ else if (this.isWhitespace(t)) this.index++;
1473
+ else {
1474
+ var n = t + this.peek(), r = n + this.peek(2), i = j[t], a = j[n], o = j[r];
1475
+ if (i || a || o) {
1476
+ var s = o ? r : a ? n : t;
1477
+ this.tokens.push({
1478
+ index: this.index,
1479
+ text: s,
1480
+ operator: !0
1481
+ }), this.index += s.length;
1482
+ } else this.throwError("Unexpected next character ", this.index, this.index + 1);
1483
+ }
1484
+ }
1485
+ return this.tokens;
1486
+ },
1487
+ is: function(e, t) {
1488
+ return t.indexOf(e) !== -1;
1489
+ },
1490
+ peek: function(e) {
1491
+ var t = e || 1;
1492
+ return this.index + t < this.text.length ? this.text.charAt(this.index + t) : !1;
1493
+ },
1494
+ isNumber: function(e) {
1495
+ return e >= "0" && e <= "9" && typeof e == "string";
1496
+ },
1497
+ isWhitespace: function(e) {
1498
+ return e === " " || e === "\r" || e === " " || e === "\n" || e === "\v" || e === "\xA0";
1499
+ },
1500
+ isIdentifierStart: function(e) {
1501
+ return this.options.isIdentifierStart ? this.options.isIdentifierStart(e, this.codePointAt(e)) : this.isValidIdentifierStart(e);
1502
+ },
1503
+ isValidIdentifierStart: function(e) {
1504
+ return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_" || e === "$";
1505
+ },
1506
+ isIdentifierContinue: function(e) {
1507
+ return this.options.isIdentifierContinue ? this.options.isIdentifierContinue(e, this.codePointAt(e)) : this.isValidIdentifierContinue(e);
1508
+ },
1509
+ isValidIdentifierContinue: function(e, t) {
1510
+ return this.isValidIdentifierStart(e, t) || this.isNumber(e);
1511
+ },
1512
+ codePointAt: function(e) {
1513
+ return e.length === 1 ? e.charCodeAt(0) : (e.charCodeAt(0) << 10) + e.charCodeAt(1) - 56613888;
1514
+ },
1515
+ peekMultichar: function() {
1516
+ var e = this.text.charAt(this.index), t = this.peek();
1517
+ if (!t) return e;
1518
+ var n = e.charCodeAt(0), r = t.charCodeAt(0);
1519
+ return n >= 55296 && n <= 56319 && r >= 56320 && r <= 57343 ? e + t : e;
1520
+ },
1521
+ isExpOperator: function(e) {
1522
+ return e === "-" || e === "+" || this.isNumber(e);
1523
+ },
1524
+ throwError: function(e, t, n) {
1525
+ throw n = n || this.index, k("lexerr", "Lexer Error: {0} at column{1} in expression [{2}].", e, h(t) ? "s " + t + "-" + this.index + " [" + this.text.substring(t, n) + "]" : " " + n, this.text);
1526
+ },
1527
+ readNumber: function() {
1528
+ for (var e = "", t = this.index; this.index < this.text.length;) {
1529
+ var n = r(this.text.charAt(this.index));
1530
+ if (n === "." || this.isNumber(n)) e += n;
1531
+ else {
1532
+ var i = this.peek();
1533
+ if (n === "e" && this.isExpOperator(i)) e += n;
1534
+ else if (this.isExpOperator(n) && i && this.isNumber(i) && e.charAt(e.length - 1) === "e") e += n;
1535
+ else if (this.isExpOperator(n) && (!i || !this.isNumber(i)) && e.charAt(e.length - 1) === "e") this.throwError("Invalid exponent");
1536
+ else break;
1537
+ }
1538
+ this.index++;
1539
+ }
1540
+ this.tokens.push({
1541
+ index: t,
1542
+ text: e,
1543
+ constant: !0,
1544
+ value: Number(e)
1545
+ });
1546
+ },
1547
+ readIdent: function() {
1548
+ var e = this.index;
1549
+ for (this.index += this.peekMultichar().length; this.index < this.text.length;) {
1550
+ var t = this.peekMultichar();
1551
+ if (!this.isIdentifierContinue(t)) break;
1552
+ this.index += t.length;
1553
+ }
1554
+ this.tokens.push({
1555
+ index: e,
1556
+ text: this.text.slice(e, this.index),
1557
+ identifier: !0
1558
+ });
1559
+ },
1560
+ readString: function(e) {
1561
+ var t = this.index;
1562
+ this.index++;
1563
+ for (var n = "", r = e, i = e === "`", a = !1; this.index < this.text.length;) {
1564
+ var o = this.text.charAt(this.index);
1565
+ if (i && o === "$" && this.text.charAt(this.index + 1) === "{") {
1566
+ this.tokens.push({
1567
+ index: t,
1568
+ text: r,
1569
+ constant: !0,
1570
+ value: n
1571
+ });
1572
+ var s = this.text.indexOf("}", this.index), c = this.text.substr(this.index + 2, s - this.index - 2);
1573
+ this.tokens.push({
1574
+ index: this.index,
1575
+ text: "+",
1576
+ operator: !0
1577
+ });
1578
+ for (var l = new M(this.options).lex(c), u = 0, d = l.length; u < d; u++) this.tokens.push(l[u]);
1579
+ this.tokens.push({
1580
+ index: this.index,
1581
+ text: "+",
1582
+ operator: !0
1583
+ }), this.index = s, this.readString("`");
1584
+ return;
1585
+ }
1586
+ if (r += o, a) {
1587
+ if (o === "u") {
1588
+ var f = this.text.substring(this.index + 1, this.index + 5);
1589
+ f.match(/[\da-f]{4}/i) || this.throwError("Invalid unicode escape [\\u" + f + "]"), this.index += 4, n += String.fromCharCode(parseInt(f, 16));
1590
+ } else {
1591
+ var p = re[o];
1592
+ n += p || o;
1593
+ }
1594
+ a = !1;
1595
+ } else if (o === "\\") a = !0;
1596
+ else if (o === e) {
1597
+ this.index++, this.tokens.push({
1598
+ index: t,
1599
+ text: r,
1600
+ constant: !0,
1601
+ value: n
1602
+ });
1603
+ return;
1604
+ } else n += o;
1605
+ this.index++;
1606
+ }
1607
+ this.throwError("Unterminated quote", t);
1608
+ }
1609
+ };
1610
+ function N(e, t) {
1611
+ this.lexer = e, this.options = t;
1612
+ }
1613
+ 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 = {
1614
+ ast: function(e) {
1615
+ this.text = e, this.tokens = this.lexer.lex(e);
1616
+ var t = this.program();
1617
+ return this.tokens.length !== 0 && this.throwError("is an unexpected token", this.tokens[0]), t;
1618
+ },
1619
+ program: function() {
1620
+ for (var e = [];;) if (this.tokens.length > 0 && !this.peek("}", ")", ";", "]") && e.push(this.expressionStatement()), !this.expect(";")) return {
1621
+ type: N.Program,
1622
+ body: e
1623
+ };
1624
+ },
1625
+ expressionStatement: function() {
1626
+ return {
1627
+ type: N.ExpressionStatement,
1628
+ expression: this.filterChain()
1629
+ };
1630
+ },
1631
+ filterChain: function() {
1632
+ for (var e = this.expression(); this.expect("|");) e = this.filter(e);
1633
+ return e;
1634
+ },
1635
+ expression: function() {
1636
+ return this.assignment();
1637
+ },
1638
+ assignment: function() {
1639
+ var e = this.ternary();
1640
+ if (this.expect("=")) {
1641
+ if (!oe(e)) throw k("lval", "Trying to assign a value to a non l-value");
1642
+ e = {
1643
+ type: N.AssignmentExpression,
1644
+ left: e,
1645
+ right: this.assignment(),
1646
+ operator: "="
1647
+ };
1648
+ }
1649
+ return e;
1650
+ },
1651
+ ternary: function() {
1652
+ var e = this.nullishCoalescing(), t, n;
1653
+ return this.expect("?") && (t = this.expression(), this.consume(":")) ? (n = this.expression(), {
1654
+ type: N.ConditionalExpression,
1655
+ test: e,
1656
+ alternate: t,
1657
+ consequent: n
1658
+ }) : e;
1659
+ },
1660
+ nullishCoalescing: function() {
1661
+ for (var e = this.logicalOR(); this.expect("??");) e = {
1662
+ type: N.LogicalExpression,
1663
+ operator: "??",
1664
+ left: e,
1665
+ right: this.logicalOR()
1666
+ };
1667
+ return e;
1668
+ },
1669
+ logicalOR: function() {
1670
+ for (var e = this.logicalAND(); this.expect("||");) e = {
1671
+ type: N.LogicalExpression,
1672
+ operator: "||",
1673
+ left: e,
1674
+ right: this.logicalAND()
1675
+ };
1676
+ return e;
1677
+ },
1678
+ logicalAND: function() {
1679
+ for (var e = this.equality(); this.expect("&&");) e = {
1680
+ type: N.LogicalExpression,
1681
+ operator: "&&",
1682
+ left: e,
1683
+ right: this.equality()
1684
+ };
1685
+ return e;
1686
+ },
1687
+ equality: function() {
1688
+ for (var e = this.relational(), t; t = this.expect("==", "!=", "===", "!==");) e = {
1689
+ type: N.BinaryExpression,
1690
+ operator: t.text,
1691
+ left: e,
1692
+ right: this.relational()
1693
+ };
1694
+ return e;
1695
+ },
1696
+ relational: function() {
1697
+ for (var e = this.additive(), t; t = this.expect("<", ">", "<=", ">=");) e = {
1698
+ type: N.BinaryExpression,
1699
+ operator: t.text,
1700
+ left: e,
1701
+ right: this.additive()
1702
+ };
1703
+ return e;
1704
+ },
1705
+ additive: function() {
1706
+ for (var e = this.multiplicative(), t; t = this.expect("+", "-");) e = {
1707
+ type: N.BinaryExpression,
1708
+ operator: t.text,
1709
+ left: e,
1710
+ right: this.multiplicative()
1711
+ };
1712
+ return e;
1713
+ },
1714
+ multiplicative: function() {
1715
+ for (var e = this.unary(), t; t = this.expect("*", "/", "%");) e = {
1716
+ type: N.BinaryExpression,
1717
+ operator: t.text,
1718
+ left: e,
1719
+ right: this.unary()
1720
+ };
1721
+ return e;
1722
+ },
1723
+ unary: function() {
1724
+ var e;
1725
+ return (e = this.expect("+", "-", "!")) ? {
1726
+ type: N.UnaryExpression,
1727
+ operator: e.text,
1728
+ prefix: !0,
1729
+ argument: this.unary()
1730
+ } : this.primary();
1731
+ },
1732
+ primary: function() {
1733
+ var e;
1734
+ 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 = {
1735
+ type: N.Literal,
1736
+ value: this.options.literals[this.consume().text]
1737
+ } : this.peek().identifier ? e = this.identifier() : this.peek().constant ? e = this.constant() : this.throwError("not a primary expression", this.peek());
1738
+ for (var t; t = this.expect("(", "[", ".");) t.text === "(" ? (e = {
1739
+ type: N.CallExpression,
1740
+ callee: e,
1741
+ arguments: this.parseArguments()
1742
+ }, this.consume(")")) : t.text === "[" ? (e = {
1743
+ type: N.MemberExpression,
1744
+ object: e,
1745
+ property: this.expression(),
1746
+ computed: !0
1747
+ }, this.consume("]")) : t.text === "." ? e = {
1748
+ type: N.MemberExpression,
1749
+ object: e,
1750
+ property: this.identifier(),
1751
+ computed: !1
1752
+ } : this.throwError("IMPOSSIBLE");
1753
+ return e;
1754
+ },
1755
+ filter: function(e) {
1756
+ for (var t = [e], n = {
1757
+ type: N.CallExpression,
1758
+ callee: this.identifier(),
1759
+ arguments: t,
1760
+ filter: !0
1761
+ }; this.expect(":");) t.push(this.expression());
1762
+ return n;
1763
+ },
1764
+ parseArguments: function() {
1765
+ var e = [];
1766
+ if (this.peekToken().text !== ")") do
1767
+ e.push(this.filterChain());
1768
+ while (this.expect(","));
1769
+ return e;
1770
+ },
1771
+ identifier: function() {
1772
+ var e = this.consume();
1773
+ return e.identifier || this.throwError("is not a valid identifier", e), {
1774
+ type: N.Identifier,
1775
+ name: e.text
1776
+ };
1777
+ },
1778
+ constant: function() {
1779
+ return {
1780
+ type: N.Literal,
1781
+ value: this.consume().value
1782
+ };
1783
+ },
1784
+ arrayDeclaration: function() {
1785
+ var e = [];
1786
+ if (this.peekToken().text !== "]") do {
1787
+ if (this.peek("]")) break;
1788
+ e.push(this.expression());
1789
+ } while (this.expect(","));
1790
+ return this.consume("]"), {
1791
+ type: N.ArrayExpression,
1792
+ elements: e
1793
+ };
1794
+ },
1795
+ object: function() {
1796
+ var e = [], t;
1797
+ if (this.peekToken().text !== "}") do {
1798
+ if (this.peek("}")) break;
1799
+ t = {
1800
+ type: N.Property,
1801
+ kind: "init"
1802
+ }, 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);
1803
+ } while (this.expect(","));
1804
+ return this.consume("}"), {
1805
+ type: N.ObjectExpression,
1806
+ properties: e
1807
+ };
1808
+ },
1809
+ throwError: function(e, t) {
1810
+ throw k("syntax", "Syntax Error: Token '{0}' {1} at column {2} of the expression [{3}] starting at [{4}].", t.text, e, t.index + 1, this.text, this.text.substring(t.index));
1811
+ },
1812
+ consume: function(e) {
1813
+ if (this.tokens.length === 0) throw k("ueoe", "Unexpected end of expression: {0}", this.text);
1814
+ var t = this.expect(e);
1815
+ return t || this.throwError("is unexpected, expecting [" + e + "]", this.peek()), t;
1816
+ },
1817
+ peekToken: function() {
1818
+ if (this.tokens.length === 0) throw k("ueoe", "Unexpected end of expression: {0}", this.text);
1819
+ return this.tokens[0];
1820
+ },
1821
+ peek: function(e, t, n, r) {
1822
+ return this.peekAhead(0, e, t, n, r);
1823
+ },
1824
+ peekAhead: function(e, t, n, r, i) {
1825
+ if (this.tokens.length > e) {
1826
+ var a = this.tokens[e], o = a.text;
1827
+ if (o === t || o === n || o === r || o === i || !t && !n && !r && !i) return a;
1828
+ }
1829
+ return !1;
1830
+ },
1831
+ expect: function(e, t, n, r) {
1832
+ var i = this.peek(e, t, n, r);
1833
+ return i ? (this.tokens.shift(), i) : !1;
1834
+ }
1835
+ };
1836
+ function ie(e, t) {
1837
+ return e === void 0 ? t : e;
1838
+ }
1839
+ function P(e, t) {
1840
+ return e === void 0 ? t : t === void 0 ? e : e + t;
1841
+ }
1842
+ function F(e, t) {
1843
+ var n = e(t);
1844
+ if (!n) throw Error("Filter '" + t + "' is not defined");
1845
+ return !n.$stateful;
1846
+ }
1847
+ function I(e, t) {
1848
+ var n, r, i;
1849
+ switch (e.type) {
1850
+ case N.Program:
1851
+ n = !0, d(e.body, function(e) {
1852
+ I(e.expression, t), n = n && e.expression.constant;
1853
+ }), e.constant = n;
1854
+ break;
1855
+ case N.Literal:
1856
+ e.constant = !0, e.toWatch = [];
1857
+ break;
1858
+ case N.UnaryExpression:
1859
+ I(e.argument, t), e.constant = e.argument.constant, e.toWatch = e.argument.toWatch;
1860
+ break;
1861
+ case N.BinaryExpression:
1862
+ 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);
1863
+ break;
1864
+ case N.LogicalExpression:
1865
+ I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.constant ? [] : [e];
1866
+ break;
1867
+ case N.ConditionalExpression:
1868
+ 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];
1869
+ break;
1870
+ case N.Identifier:
1871
+ e.constant = !1, e.toWatch = [e];
1872
+ break;
1873
+ case N.MemberExpression:
1874
+ I(e.object, t), e.computed && I(e.property, t), e.constant = e.object.constant && (!e.computed || e.property.constant), e.toWatch = [e];
1875
+ break;
1876
+ case N.CallExpression:
1877
+ i = e.filter ? F(t, e.callee.name) : !1, n = i, r = [], d(e.arguments, function(e) {
1878
+ I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1879
+ }), e.constant = n, e.toWatch = i ? r : [e];
1880
+ break;
1881
+ case N.AssignmentExpression:
1882
+ I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = [e];
1883
+ break;
1884
+ case N.ArrayExpression:
1885
+ n = !0, r = [], d(e.elements, function(e) {
1886
+ I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1887
+ }), e.constant = n, e.toWatch = r;
1888
+ break;
1889
+ case N.ObjectExpression:
1890
+ n = !0, r = [], d(e.properties, function(e) {
1891
+ I(e.value, t), n = n && e.value.constant && !e.computed, e.value.constant || r.push.apply(r, e.value.toWatch);
1892
+ }), e.constant = n, e.toWatch = r;
1893
+ break;
1894
+ case N.ThisExpression:
1895
+ e.constant = !1, e.toWatch = [];
1896
+ break;
1897
+ case N.LocalsExpression:
1898
+ e.constant = !1, e.toWatch = [];
1899
+ break;
1900
+ }
1901
+ }
1902
+ function ae(e) {
1903
+ if (e.length === 1) {
1904
+ var t = e[0].expression, n = t.toWatch;
1905
+ return n.length === 1 && n[0] === t ? void 0 : n;
1906
+ }
1907
+ }
1908
+ function oe(e) {
1909
+ return e.type === N.Identifier || e.type === N.MemberExpression;
1910
+ }
1911
+ function L(e) {
1912
+ if (e.body.length === 1 && oe(e.body[0].expression)) return {
1913
+ type: N.AssignmentExpression,
1914
+ left: e.body[0].expression,
1915
+ right: { type: N.NGValueParameter },
1916
+ operator: "="
1917
+ };
1918
+ }
1919
+ function R(e) {
1920
+ 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);
1921
+ }
1922
+ function z(e) {
1923
+ return e.constant;
1924
+ }
1925
+ function B(e, t) {
1926
+ this.astBuilder = e, this.$filter = t;
1927
+ }
1928
+ B.prototype = {
1929
+ compile: function(e) {
1930
+ var t = this, n = this.astBuilder.ast(e);
1931
+ this.state = {
1932
+ nextId: 0,
1933
+ filters: {},
1934
+ fn: {
1935
+ vars: [],
1936
+ body: [],
1937
+ own: {}
1938
+ },
1939
+ assign: {
1940
+ vars: [],
1941
+ body: [],
1942
+ own: {}
1943
+ },
1944
+ inputs: []
1945
+ }, I(n, t.$filter);
1946
+ var r = "", i;
1947
+ if (this.stage = "assign", i = L(n)) {
1948
+ this.state.computing = "assign";
1949
+ var o = this.nextId();
1950
+ this.recurse(i, o), this.return_(o), r = "fn.assign=" + this.generateFunction("assign", "s,v,l");
1951
+ }
1952
+ var s = ae(n.body);
1953
+ t.stage = "inputs", d(s, function(e, n) {
1954
+ var r = "fn" + n;
1955
+ t.state[r] = {
1956
+ vars: [],
1957
+ body: [],
1958
+ own: {}
1959
+ }, t.state.computing = r;
1960
+ var i = t.nextId();
1961
+ t.recurse(e, i), t.return_(i), t.state.inputs.push(r), e.watchId = n;
1962
+ }), this.state.computing = "fn", this.stage = "main", this.recurse(n);
1963
+ 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) {
1964
+ return a(function() {
1965
+ return l(e, t, n, r);
1966
+ });
1967
+ };
1968
+ return u.assign = function(e, t, n) {
1969
+ return a(function() {
1970
+ return l.assign(e, t, n);
1971
+ });
1972
+ }, u.inputs = l.inputs, this.state = this.stage = void 0, u.ast = n, u.literal = R(n), u.constant = z(n), u;
1973
+ },
1974
+ USE: "use",
1975
+ STRICT: "strict",
1976
+ watchFns: function() {
1977
+ var e = [], t = this.state.inputs, n = this;
1978
+ return d(t, function(t) {
1979
+ e.push("var " + t + "=" + n.generateFunction(t, "s"));
1980
+ }), t.length && e.push("fn.inputs=[" + t.join(",") + "];"), e.join("");
1981
+ },
1982
+ generateFunction: function(e, t) {
1983
+ return "function(" + t + "){" + this.varsPrefix(e) + this.body(e) + "};";
1984
+ },
1985
+ filterPrefix: function() {
1986
+ var e = [], t = this;
1987
+ return d(this.state.filters, function(n, r) {
1988
+ e.push(n + "=$filter(" + t.escape(r) + ")");
1989
+ }), e.length ? "var " + e.join(",") + ";" : "";
1990
+ },
1991
+ varsPrefix: function(e) {
1992
+ return this.state[e].vars.length ? "var " + this.state[e].vars.join(",") + ";" : "";
1993
+ },
1994
+ body: function(e) {
1995
+ return this.state[e].body.join("");
1996
+ },
1997
+ recurse: function(e, t, n, r, i, a) {
1998
+ var o, s, c = this, l, u, f;
1999
+ if (r = r || p, !a && h(e.watchId)) {
2000
+ t = t || this.nextId(), this.if_("i", this.lazyAssign(t, this.unsafeComputedMember("i", e.watchId)), this.lazyRecurse(e, t, n, r, i, !0));
2001
+ return;
2002
+ }
2003
+ switch (e.type) {
2004
+ case N.Program:
2005
+ d(e.body, function(t, n) {
2006
+ c.recurse(t.expression, void 0, void 0, function(e) {
2007
+ s = e;
2008
+ }), n === e.body.length - 1 ? c.return_(s) : c.current().body.push(s, ";");
2009
+ });
2010
+ break;
2011
+ case N.Literal:
2012
+ u = this.escape(e.value), this.assign(t, u), r(t || u);
2013
+ break;
2014
+ case N.UnaryExpression:
2015
+ this.recurse(e.argument, void 0, void 0, function(e) {
2016
+ s = e;
2017
+ }), u = e.operator + "(" + this.ifDefined(s, 0) + ")", this.assign(t, u), r(u);
2018
+ break;
2019
+ case N.BinaryExpression:
2020
+ this.recurse(e.left, void 0, void 0, function(e) {
2021
+ o = e;
2022
+ }), this.recurse(e.right, void 0, void 0, function(e) {
2023
+ s = e;
2024
+ }), 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);
2025
+ break;
2026
+ case N.LogicalExpression:
2027
+ 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);
2028
+ break;
2029
+ case N.ConditionalExpression:
2030
+ t = t || this.nextId(), c.recurse(e.test, t), c.if_(t, c.lazyRecurse(e.alternate, t), c.lazyRecurse(e.consequent, t)), r(t);
2031
+ break;
2032
+ case N.Identifier:
2033
+ t = t || this.nextId();
2034
+ var m = c.current().inAssignment;
2035
+ 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() {
2036
+ c.if_(c.stage === "inputs" || "s", function() {
2037
+ var n = c.nextId();
2038
+ c.assign(n, c.nonComputedMember("s", e.name)), c.if_(c.or_(c.isNull(n), c.hasOwnProperty_("s", e.name)), function() {
2039
+ i && i !== 1 ? (c.if_(c.isNull(n), c.lazyAssign(c.nonComputedMember("s", e.name), "{}")), c.assign(t, c.nonComputedMember("s", e.name))) : c.assign(t, n);
2040
+ });
2041
+ });
2042
+ }, t && function() {
2043
+ c.if_(c.hasOwnProperty_("l", e.name), c.lazyAssign(t, c.nonComputedMember("l", e.name)));
2044
+ }), r(t);
2045
+ break;
2046
+ case N.MemberExpression:
2047
+ o = n && (n.context = this.nextId()) || this.nextId(), t = t || this.nextId(), c.recurse(e.object, o, void 0, function() {
2048
+ var a = null, l = c.current().inAssignment;
2049
+ 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() {
2050
+ 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
+ }, function() {
2052
+ c.assign(t, "undefined");
2053
+ }), r(t);
2054
+ }, !!i);
2055
+ break;
2056
+ case N.CallExpression:
2057
+ t = t || this.nextId(), e.filter ? (s = c.filter(e.callee.name), l = [], d(e.arguments, function(e) {
2058
+ var t = c.nextId();
2059
+ c.recurse(e, t), l.push(t);
2060
+ }), u = s + ".call(" + s + "," + l.join(",") + ")", c.assign(t, u), r(t)) : (s = c.nextId(), o = {}, l = [], c.recurse(e.callee, s, o, function() {
2061
+ c.if_(c.notNull(s), function() {
2062
+ d(e.arguments, function(t) {
2063
+ c.recurse(t, e.constant ? void 0 : c.nextId(), void 0, function(e) {
2064
+ l.push(e);
2065
+ });
2066
+ }), u = o.name ? "(" + c.member(o.context, o.name, o.computed) + " === null ? null : " + c.unsafeMember(o.context, o.name, o.computed) + ".call(" + [o.context].concat(l).join(",") + "))" : s + "(" + l.join(",") + ")", c.assign(t, u);
2067
+ }, function() {
2068
+ c.assign(t, "undefined");
2069
+ }), r(t);
2070
+ }));
2071
+ break;
2072
+ case N.AssignmentExpression:
2073
+ s = this.nextId(), o = {}, c.current().inAssignment = !0, this.recurse(e.left, void 0, o, function() {
2074
+ 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() {
2075
+ c.recurse(e.right, s), u = c.member(o.context, o.name, o.computed) + e.operator + s, c.assign(t, u), r(t || u);
2076
+ }), c.current().inAssignment = !1, c.recurse(e.right, s), c.current().inAssignment = !0;
2077
+ }, 1), c.current().inAssignment = !1;
2078
+ break;
2079
+ case N.ArrayExpression:
2080
+ l = [], d(e.elements, function(t) {
2081
+ c.recurse(t, e.constant ? void 0 : c.nextId(), void 0, function(e) {
2082
+ l.push(e);
2083
+ });
2084
+ }), u = "[" + l.join(",") + "]", this.assign(t, u), r(t || u);
2085
+ break;
2086
+ case N.ObjectExpression:
2087
+ l = [], f = !1, d(e.properties, function(e) {
2088
+ e.computed && (f = !0);
2089
+ }), f ? (t = t || this.nextId(), this.assign(t, "{}"), d(e.properties, function(e) {
2090
+ 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);
2091
+ })) : (d(e.properties, function(t) {
2092
+ c.recurse(t.value, e.constant ? void 0 : c.nextId(), void 0, function(e) {
2093
+ l.push(c.escape(t.key.type === N.Identifier ? t.key.name : "" + t.key.value) + ":" + e);
2094
+ });
2095
+ }), u = "{" + l.join(",") + "}", this.assign(t, u)), r(t || u);
2096
+ break;
2097
+ case N.ThisExpression:
2098
+ this.assign(t, "s"), r(t || "s");
2099
+ break;
2100
+ case N.LocalsExpression:
2101
+ this.assign(t, "l"), r(t || "l");
2102
+ break;
2103
+ case N.NGValueParameter:
2104
+ this.assign(t, "v"), r(t || "v");
2105
+ break;
2106
+ }
2107
+ },
2108
+ getHasOwnProperty: function(e, t) {
2109
+ var n = e + "." + t, r = this.current().own;
2110
+ return r.hasOwnProperty(n) || (r[n] = this.nextId(!1, e + "&&(" + this.escape(t) + " in " + e + ")")), r[n];
2111
+ },
2112
+ assign: function(e, t) {
2113
+ if (e) return this.current().body.push(e, "=", t, ";"), e;
2114
+ },
2115
+ filter: function(e) {
2116
+ return n.call(this.state.filters, e) || (this.state.filters[e] = this.nextId(!0)), this.state.filters[e];
2117
+ },
2118
+ ifDefined: function(e, t) {
2119
+ return "ifDefined(" + e + "," + this.escape(t) + ")";
2120
+ },
2121
+ plus: function(e, t) {
2122
+ return "plus(" + e + "," + t + ")";
2123
+ },
2124
+ return_: function(e) {
2125
+ this.current().body.push("return ", e, ";");
2126
+ },
2127
+ if_: function(e, t, n) {
2128
+ if (e === !0) t();
2129
+ else {
2130
+ var r = this.current().body;
2131
+ r.push("if(", e, "){"), t(), r.push("}"), n && (r.push("else{"), n(), r.push("}"));
2132
+ }
2133
+ },
2134
+ or_: function(e, t) {
2135
+ return "(" + e + ") || (" + t + ")";
2136
+ },
2137
+ hasOwnProperty_: function(e, t, n) {
2138
+ return n ? "(Object.prototype.hasOwnProperty.call(" + e + "," + t + "))" : "(Object.prototype.hasOwnProperty.call(" + e + ",'" + t + "'))";
2139
+ },
2140
+ and_: function(e, t) {
2141
+ return "(" + e + ") && (" + t + ")";
2142
+ },
2143
+ not: function(e) {
2144
+ return "!(" + e + ")";
2145
+ },
2146
+ isNull: function(e) {
2147
+ return e + "==null";
2148
+ },
2149
+ notNull: function(e) {
2150
+ return e + "!=null";
2151
+ },
2152
+ nonComputedMember: function(e, t) {
2153
+ var n = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/, r = /[^$_a-zA-Z0-9]/g, i = "";
2154
+ return n.test(t) ? i = e + "." + t : (t = t.replace(r, this.stringEscapeFn), i = e + "[\"" + t + "\"]"), i;
2155
+ },
2156
+ unsafeComputedMember: function(e, t) {
2157
+ return e + "[" + t + "]";
2158
+ },
2159
+ unsafeNonComputedMember: function(e, t) {
2160
+ return this.nonComputedMember(e, t);
2161
+ },
2162
+ computedMember: function(e, t) {
2163
+ return this.state.computing === "assign" ? this.unsafeComputedMember(e, t) : "(" + e + ".hasOwnProperty(" + t + ") ? " + e + "[" + t + "] : undefined)";
2164
+ },
2165
+ unsafeMember: function(e, t, n) {
2166
+ return n ? this.unsafeComputedMember(e, t) : this.unsafeNonComputedMember(e, t);
2167
+ },
2168
+ member: function(e, t, n) {
2169
+ return n ? this.computedMember(e, t) : this.nonComputedMember(e, t);
2170
+ },
2171
+ getStringValue: function(e) {
2172
+ this.assign(e, "getStringValue(" + e + ")");
2173
+ },
2174
+ lazyRecurse: function(e, t, n, r, i, a) {
2175
+ var o = this;
2176
+ return function() {
2177
+ o.recurse(e, t, n, r, i, a);
2178
+ };
2179
+ },
2180
+ lazyAssign: function(e, t) {
2181
+ var n = this;
2182
+ return function() {
2183
+ n.assign(e, t);
2184
+ };
2185
+ },
2186
+ stringEscapeRegex: /[^ a-zA-Z0-9]/g,
2187
+ stringEscapeFn: function(e) {
2188
+ return "\\u" + ("0000" + e.charCodeAt(0).toString(16)).slice(-4);
2189
+ },
2190
+ escape: function(e) {
2191
+ if (v(e)) return "'" + e.replace(this.stringEscapeRegex, this.stringEscapeFn) + "'";
2192
+ if (y(e)) return e.toString();
2193
+ if (e === !0) return "true";
2194
+ if (e === !1) return "false";
2195
+ if (e === null) return "null";
2196
+ if (e === void 0) return "undefined";
2197
+ throw k("esc", "IMPOSSIBLE");
2198
+ },
2199
+ nextId: function(e, t) {
2200
+ var n = "v" + this.state.nextId++;
2201
+ return e || this.current().vars.push(n + (t ? "=" + t : "")), n;
2202
+ },
2203
+ current: function() {
2204
+ return this.state[this.state.computing];
2205
+ }
2206
+ };
2207
+ function V(e, t) {
2208
+ this.astBuilder = e, this.$filter = t;
2209
+ }
2210
+ V.prototype = {
2211
+ compile: function(e) {
2212
+ var t = this, n = this.astBuilder.ast(e);
2213
+ I(n, t.$filter);
2214
+ var r, i;
2215
+ (r = L(n)) && (i = this.recurse(r));
2216
+ var o = ae(n.body), s;
2217
+ o && (s = [], d(o, function(e, n) {
2218
+ var r = t.recurse(e);
2219
+ e.input = r, s.push(r), e.watchId = n;
2220
+ }));
2221
+ var c = [];
2222
+ d(n.body, function(e) {
2223
+ c.push(t.recurse(e.expression));
2224
+ });
2225
+ var l = n.body.length === 0 ? p : n.body.length === 1 ? c[0] : function(e, t) {
2226
+ var n;
2227
+ return d(c, function(r) {
2228
+ n = r(e, t);
2229
+ }), n;
2230
+ };
2231
+ i && (l.assign = function(e, t, n) {
2232
+ return i(e, n, t);
2233
+ });
2234
+ var u = function(e, t) {
2235
+ return a(function() {
2236
+ return l(e, t);
2237
+ });
2238
+ };
2239
+ return u.assign = function(e, t, n) {
2240
+ return a(function() {
2241
+ return l.assign(e, t, n);
2242
+ });
2243
+ }, s && (u.inputs = s), u.ast = n, u.literal = R(n), u.constant = z(n), u;
2244
+ },
2245
+ recurse: function(e, t, n) {
2246
+ var r, i, a = this, o;
2247
+ if (e.input) return this.inputs(e.input, e.watchId);
2248
+ switch (e.type) {
2249
+ case N.Literal: return this.value(e.value, t);
2250
+ case N.UnaryExpression: return i = this.recurse(e.argument), this["unary" + e.operator](i, t);
2251
+ case N.BinaryExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2252
+ case N.LogicalExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2253
+ case N.ConditionalExpression: return this["ternary?:"](this.recurse(e.test), this.recurse(e.alternate), this.recurse(e.consequent), t);
2254
+ case N.Identifier: return a.identifier(e.name, t, n);
2255
+ 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);
2256
+ case N.CallExpression: return o = [], d(e.arguments, function(e) {
2257
+ o.push(a.recurse(e));
2258
+ }), e.filter && (i = this.$filter(e.callee.name)), e.filter || (i = this.recurse(e.callee, !0)), e.filter ? function(e, n, r, a) {
2259
+ for (var s = [], c = 0; c < o.length; ++c) s.push(o[c](e, n, r, a));
2260
+ var l = i.apply(void 0, s, a);
2261
+ return t ? {
2262
+ context: void 0,
2263
+ name: void 0,
2264
+ value: l
2265
+ } : l;
2266
+ } : function(e, n, r, a) {
2267
+ var s = i(e, n, r, a), c;
2268
+ if (s.value != null) {
2269
+ for (var l = [], u = 0; u < o.length; ++u) l.push(o[u](e, n, r, a));
2270
+ c = s.value.apply(s.context, l);
2271
+ }
2272
+ return t ? { value: c } : c;
2273
+ };
2274
+ case N.AssignmentExpression: return r = this.recurse(e.left, !0, 1), i = this.recurse(e.right), function(e, n, a, o) {
2275
+ var s = r(e, !1, a, o), c = i(e, n, a, o);
2276
+ return s.context[s.name] = c, t ? { value: c } : c;
2277
+ };
2278
+ case N.ArrayExpression: return o = [], d(e.elements, function(e) {
2279
+ o.push(a.recurse(e));
2280
+ }), function(e, n, r, i) {
2281
+ for (var a = [], s = 0; s < o.length; ++s) a.push(o[s](e, n, r, i));
2282
+ return t ? { value: a } : a;
2283
+ };
2284
+ case N.ObjectExpression: return o = [], d(e.properties, function(e) {
2285
+ e.computed ? o.push({
2286
+ key: a.recurse(e.key),
2287
+ computed: !0,
2288
+ value: a.recurse(e.value)
2289
+ }) : o.push({
2290
+ key: e.key.type === N.Identifier ? e.key.name : "" + e.key.value,
2291
+ computed: !1,
2292
+ value: a.recurse(e.value)
2293
+ });
2294
+ }), function(e, n, r, i) {
2295
+ 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);
2296
+ return t ? { value: a } : a;
2297
+ };
2298
+ case N.ThisExpression: return function(e) {
2299
+ return t ? { value: e } : e;
2300
+ };
2301
+ case N.LocalsExpression: return function(e, n) {
2302
+ return t ? { value: n } : n;
2303
+ };
2304
+ case N.NGValueParameter: return function(e, n, r) {
2305
+ return t ? { value: r } : r;
2306
+ };
2307
+ }
2308
+ },
2309
+ "unary+": function(e, t) {
2310
+ return function(n, r, i, a) {
2311
+ var o = e(n, r, i, a);
2312
+ return o = h(o) ? +o : 0, t ? { value: o } : o;
2313
+ };
2314
+ },
2315
+ "unary-": function(e, t) {
2316
+ return function(n, r, i, a) {
2317
+ var o = e(n, r, i, a);
2318
+ return o = h(o) ? -o : -0, t ? { value: o } : o;
2319
+ };
2320
+ },
2321
+ "unary!": function(e, t) {
2322
+ return function(n, r, i, a) {
2323
+ var o = !e(n, r, i, a);
2324
+ return t ? { value: o } : o;
2325
+ };
2326
+ },
2327
+ "binary+": function(e, t, n) {
2328
+ return function(r, i, a, o) {
2329
+ var s = P(e(r, i, a, o), t(r, i, a, o));
2330
+ return n ? { value: s } : s;
2331
+ };
2332
+ },
2333
+ "binary-": function(e, t, n) {
2334
+ return function(r, i, a, o) {
2335
+ var s = e(r, i, a, o), c = t(r, i, a, o), l = (h(s) ? s : 0) - (h(c) ? c : 0);
2336
+ return n ? { value: l } : l;
2337
+ };
2338
+ },
2339
+ "binary*": function(e, t, n) {
2340
+ return function(r, i, a, o) {
2341
+ var s = e(r, i, a, o) * t(r, i, a, o);
2342
+ return n ? { value: s } : s;
2343
+ };
2344
+ },
2345
+ "binary/": function(e, t, n) {
2346
+ return function(r, i, a, o) {
2347
+ var s = e(r, i, a, o) / t(r, i, a, o);
2348
+ return n ? { value: s } : s;
2349
+ };
2350
+ },
2351
+ "binary%": function(e, t, n) {
2352
+ return function(r, i, a, o) {
2353
+ var s = e(r, i, a, o) % t(r, i, a, o);
2354
+ return n ? { value: s } : s;
2355
+ };
2356
+ },
2357
+ "binary===": function(e, t, n) {
2358
+ return function(r, i, a, o) {
2359
+ var s = e(r, i, a, o) === t(r, i, a, o);
2360
+ return n ? { value: s } : s;
2361
+ };
2362
+ },
2363
+ "binary!==": function(e, t, n) {
2364
+ return function(r, i, a, o) {
2365
+ var s = e(r, i, a, o) !== t(r, i, a, o);
2366
+ return n ? { value: s } : s;
2367
+ };
2368
+ },
2369
+ "binary==": function(e, t, n) {
2370
+ return function(r, i, a, o) {
2371
+ var s = e(r, i, a, o) == t(r, i, a, o);
2372
+ return n ? { value: s } : s;
2373
+ };
2374
+ },
2375
+ "binary!=": function(e, t, n) {
2376
+ return function(r, i, a, o) {
2377
+ var s = e(r, i, a, o) != t(r, i, a, o);
2378
+ return n ? { value: s } : s;
2379
+ };
2380
+ },
2381
+ "binary<": function(e, t, n) {
2382
+ return function(r, i, a, o) {
2383
+ var s = e(r, i, a, o) < t(r, i, a, o);
2384
+ return n ? { value: s } : s;
2385
+ };
2386
+ },
2387
+ "binary>": function(e, t, n) {
2388
+ return function(r, i, a, o) {
2389
+ var s = e(r, i, a, o) > t(r, i, a, o);
2390
+ return n ? { value: s } : s;
2391
+ };
2392
+ },
2393
+ "binary<=": function(e, t, n) {
2394
+ return function(r, i, a, o) {
2395
+ var s = e(r, i, a, o) <= t(r, i, a, o);
2396
+ return n ? { value: s } : s;
2397
+ };
2398
+ },
2399
+ "binary>=": function(e, t, n) {
2400
+ return function(r, i, a, o) {
2401
+ var s = e(r, i, a, o) >= t(r, i, a, o);
2402
+ return n ? { value: s } : s;
2403
+ };
2404
+ },
2405
+ "binary&&": function(e, t, n) {
2406
+ return function(r, i, a, o) {
2407
+ var s = e(r, i, a, o) && t(r, i, a, o);
2408
+ return n ? { value: s } : s;
2409
+ };
2410
+ },
2411
+ "binary||": function(e, t, n) {
2412
+ return function(r, i, a, o) {
2413
+ var s = e(r, i, a, o) || t(r, i, a, o);
2414
+ return n ? { value: s } : s;
2415
+ };
2416
+ },
2417
+ "binary??": function(e, t, n) {
2418
+ return function(r, i, a, o) {
2419
+ var s = e(r, i, a, o), c = s != null && s !== void 0 ? s : t(r, i, a, o);
2420
+ return n ? { value: c } : c;
2421
+ };
2422
+ },
2423
+ "ternary?:": function(e, t, n, r) {
2424
+ return function(i, a, o, s) {
2425
+ var c = e(i, a, o, s) ? t(i, a, o, s) : n(i, a, o, s);
2426
+ return r ? { value: c } : c;
2427
+ };
2428
+ },
2429
+ value: function(e, t) {
2430
+ return function() {
2431
+ return t ? {
2432
+ context: void 0,
2433
+ name: void 0,
2434
+ value: e
2435
+ } : e;
2436
+ };
2437
+ },
2438
+ identifier: function(e, t, r) {
2439
+ return function(i, a) {
2440
+ var o = a && e in a ? a : i;
2441
+ r && r !== 1 && o && o[e] == null && (o[e] = {});
2442
+ var s;
2443
+ return o && n.call(o, e) && (s = o ? o[e] : void 0), t ? {
2444
+ context: o,
2445
+ name: e,
2446
+ value: s
2447
+ } : s;
2448
+ };
2449
+ },
2450
+ computedMember: function(e, t, n, r) {
2451
+ return function(i, a, o, s) {
2452
+ var c = e(i, a, o, s), l, u;
2453
+ return c != null && (l = t(i, a, o, s), l = A(l), r && r !== 1 && c && !c[l] && (c[l] = {}), Object.prototype.hasOwnProperty.call(c, l) && (u = c[l])), n ? {
2454
+ context: c,
2455
+ name: l,
2456
+ value: u
2457
+ } : u;
2458
+ };
2459
+ },
2460
+ nonComputedMember: function(e, t, n, r) {
2461
+ return function(i, a, o, s) {
2462
+ var c = e(i, a, o, s);
2463
+ r && r !== 1 && c && c[t] == null && (c[t] = {});
2464
+ var l = void 0;
2465
+ return c != null && Object.prototype.hasOwnProperty.call(c, t) && (l = c[t]), n ? {
2466
+ context: c,
2467
+ name: t,
2468
+ value: l
2469
+ } : l;
2470
+ };
2471
+ },
2472
+ inputs: function(e, t) {
2473
+ return function(n, r, i, a) {
2474
+ return a ? a[t] : e(n, r, i);
2475
+ };
2476
+ }
2477
+ };
2478
+ /**
2479
+ * @constructor
2480
+ */
2481
+ var H = function(e, t, n) {
2482
+ 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 V(this.ast, t) : new B(this.ast, t);
2483
+ };
2484
+ H.prototype = {
2485
+ constructor: H,
2486
+ parse: function(e) {
2487
+ return this.astCompiler.compile(e);
2488
+ }
2489
+ }, e.Lexer = M, e.Parser = H;
2490
+ })), _e = (/* @__PURE__ */ n(((e) => {
2491
+ var t = ge(), n = {}, r = t.Lexer, i = t.Parser;
2492
+ function a(e) {
2493
+ return e = e || {}, e.filters && (e.cache = e.cache || {}), e.cache = e.cache || s.cache, e.filters = e.filters || n, e;
2494
+ }
2495
+ function o(e) {
2496
+ return {
2497
+ handleThis: e.handleThis == null ? !0 : e.handleThis,
2498
+ csp: e.csp == null ? !1 : e.csp,
2499
+ literals: e.literals == null ? {
2500
+ true: !0,
2501
+ false: !1,
2502
+ null: null,
2503
+ undefined: void 0
2504
+ } : e.literals
2505
+ };
2506
+ }
2507
+ /**
2508
+ * Compiles src and returns a function that executes src on a target object.
2509
+ * To speed up further calls the compiled function is cached under compile.cache[src] if options.filters is not present.
2510
+ *
2511
+ * @param {string} src
2512
+ * @param {object | undefined} options
2513
+ * @returns {function}
2514
+ */
2515
+ function s(e, t) {
2516
+ if (typeof e != "string") throw TypeError("src must be a string, instead saw '" + typeof e + "'");
2517
+ t = a(t);
2518
+ var n = t, s = o(t), c = new i(new r(n), function(e) {
2519
+ return t.filters[e];
2520
+ }, s);
2521
+ if (!t.cache) return c.parse(e);
2522
+ delete t.src;
2523
+ var l = JSON.stringify(Object.assign({ src: e }, t)), u = t.cache[l];
2524
+ return u || (u = t.cache[l] = c.parse(e)), u;
2525
+ }
2526
+ s.cache = Object.create(null), e.compile = s;
2527
+ })))();
2528
+ /** Cleans deeds the way puzzmo.com's PlayGameIframe and the API's `getDeedsFromCompletion` do, collecting what was dropped. */
2529
+ const ve = (e, t) => {
2530
+ let n = [];
2531
+ e !== void 0 && !Array.isArray(e) && n.push("deeds is not an array, the host ignores it");
2532
+ let r = [];
2533
+ for (let [i, a] of (Array.isArray(e) ? e : []).entries()) {
2534
+ if (a == null || typeof a.id != "string") {
2535
+ n.push(`deed ${i} has no string id, the host drops it`);
2536
+ continue;
2537
+ }
2538
+ if (t === "checkpoint") {
2539
+ r.push({
2540
+ id: a.id,
2541
+ value: a.value
2542
+ });
2543
+ continue;
2544
+ }
2545
+ a.value === void 0 || a.value === null || r.push({
2546
+ id: a.id,
2547
+ value: typeof a.value == "number" ? Math.floor(a.value) : a.value,
2548
+ persist: a.persist === !0
2549
+ });
2550
+ }
2551
+ if (t === "checkpoint") return {
2552
+ deeds: r,
2553
+ warnings: n
2554
+ };
2555
+ let i = r.filter((e) => e.persist), a = r.filter((e) => !e.persist), o = i.splice(3);
2556
+ return o.length && n.push(`only 3 persisted deeds are kept, dropped: ${o.map((e) => e.id).join(", ")}`), {
2557
+ deeds: [...i, ...a].map(({ id: e, value: t }) => ({
2558
+ id: e,
2559
+ value: t
2560
+ })),
2561
+ warnings: n
2562
+ };
2563
+ }, ye = (e) => {
2564
+ let t = {};
2565
+ for (let n of e) n.value !== void 0 && (t[Se(n.id)] = n.value);
2566
+ return t;
2567
+ }, be = (e, t) => {
2568
+ try {
2569
+ if (e.filterExp && !(0, _e.compile)(e.filterExp)(t) || !e.incrementExp) return {
2570
+ complete: !1,
2571
+ value: 0
2572
+ };
2573
+ let n = (0, _e.compile)(e.incrementExp)(t);
2574
+ if (typeof n == "boolean" && (n = n ? 1 : 0), n === void 0 && (n = 0), typeof n != "number" || isNaN(n)) throw Error(`incrementExp must return a number, undefined or boolean, got ${n}`);
2575
+ let r = Math.floor(n);
2576
+ return {
2577
+ complete: r >= (e.targetCount || 1),
2578
+ value: r
2579
+ };
2580
+ } catch (e) {
2581
+ return {
2582
+ complete: !1,
2583
+ value: 0,
2584
+ error: e.message
2585
+ };
2586
+ }
2587
+ }, xe = (e) => {
2588
+ let { items: t, scope: n, mode: r } = e, i = Math.min(Math.max(e.index, 0), t.length), a;
2589
+ for (; i < t.length && (a = be(t[i], n), !(!a.complete || r === "checkpoint" && !t[i].liveUpdate)); i++);
2590
+ return {
2591
+ index: i,
2592
+ head: i < t.length ? a : void 0
2593
+ };
2594
+ };
2595
+ var Se = (e) => e.replace(/-./g, (e) => e[1].toUpperCase());
2596
+ /** A minimal take on puzzmo.com's tutorial checklist, driven by deeds from checkpoints and completion. */
2597
+ function Ce(e) {
2598
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = null, i = 0, a, o = [], s = (e) => {
2599
+ var t;
2600
+ return `simulator-checklist:${(t = r) == null ? "game" : t}:${e}`;
2601
+ }, c = (e) => {
2602
+ try {
2603
+ let t = Number(localStorage.getItem(s(e.stableID))) || 0;
2604
+ return Math.min(Math.max(t, 0), e.items.length);
2605
+ } catch (e) {
2606
+ return 0;
2607
+ }
2608
+ }, l = (e, t) => {
2609
+ try {
2610
+ t === 0 ? localStorage.removeItem(s(e)) : localStorage.setItem(s(e), String(t));
2611
+ } catch (e) {}
2612
+ }, u = (e, t, r, i) => {
2613
+ var a;
2614
+ let o = r < i.index ? "done" : r === i.index ? "active" : "upcoming", s = `${e.stableID}:${r}`, c = n.has(s), l = !!t.expandMD && o !== "done", u = t.targetCount || 1, d = o === "active" && i.head ? `${Math.min(i.head.value, u)}/${u}` : "", f = [
2615
+ t.incrementExp && `increment: ${t.incrementExp}`,
2616
+ t.filterExp && `filter: ${t.filterExp}`,
2617
+ `target: ${u}`,
2618
+ t.liveUpdate ? "liveUpdate: checkpoints + completion" : "completion only"
2619
+ ].filter(Boolean).join("\n");
2620
+ return `${e.instructionsVisibleFromItemIndex === r && r > 0 ? "<div class=\"checklist-divider\"><span>full instructions unlock</span></div>" : ""}
2621
+ <div class="checklist-item ${o}" title="${K(f)}">
2622
+ <div class="checklist-row">
2623
+ <span class="checklist-tick">${o === "done" ? "■" : "□"}</span>
2624
+ <span class="checklist-title">${K((a = t.title) == null ? `Step ${r + 1}` : a)}</span>
2625
+ ${d ? `<span class="checklist-count">${d}</span>` : ""}
2626
+ ${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${K(s)}">?</button>` : ""}
2627
+ </div>
2628
+ ${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${K(t.subtitle)}</div>` : ""}
2629
+ ${l && c ? `<pre class="checklist-expand">${K(t.expandMD)}</pre>` : ""}
2630
+ </div>`;
2631
+ }, d = (e) => {
2632
+ var n, r, i, s;
2633
+ let c = (n = t.get(e.stableID)) == null ? { index: 0 } : n, l = e.items.length, d = c.index, f = ((r = c.head) == null ? void 0 : r.error) && `${(i = (s = e.items[c.index]) == null ? void 0 : s.title) == null ? `Step ${c.index + 1}` : i}: ${c.head.error}`;
2634
+ return `
2635
+ <div class="checklist-section">
2636
+ <div class="checklist-header">
2637
+ <span class="simulator-label">Checklist</span>
2638
+ <span class="checklist-progress${d === l ? " complete" : ""}">${d}/${l}</span>
2639
+ <button class="simulator-btn subtle small" data-reset="${K(e.stableID)}">Reset</button>
2640
+ </div>
2641
+ <div class="checklist-items">
2642
+ ${e.items.map((t, n) => u(e, t, n, c)).join("")}
2643
+ </div>
2644
+ ${a ? `<div class="checklist-footer">last eval: ${K(a)}</div>` : ""}
2645
+ ${f ? `<div class="checklist-error">${K(f)}</div>` : ""}
2646
+ ${o.map((e) => `<div class="checklist-error">${K(e)}</div>`).join("")}
2647
+ </div>`;
2648
+ }, 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) => {
2649
+ let t = e.getElement("#simulator-checklist-list");
2650
+ t && (t.innerHTML = f());
2651
+ }, m = (n, r, s, c) => {
2652
+ let u = 0, d = ve(r, s), f = ye(d.deeds);
2653
+ a = c, o = d.warnings;
2654
+ for (let n of e) {
2655
+ var m, h;
2656
+ let e = (m = (h = t.get(n.stableID)) == null ? void 0 : h.index) == null ? 0 : m, r = xe({
2657
+ items: n.items,
2658
+ index: e,
2659
+ scope: f,
2660
+ mode: s
2661
+ });
2662
+ u += r.index - e, t.set(n.stableID, r), r.index !== e && l(n.stableID, r.index);
2663
+ }
2664
+ u > 0 && (i += u, n.updateBadge("checklist", i)), p(n);
2665
+ };
2666
+ return {
2667
+ id: "checklist",
2668
+ label: "Cklst",
2669
+ render() {
2670
+ return `<div id="simulator-checklist-list" class="checklist-view-container">${f()}</div>`;
2671
+ },
2672
+ bind(s) {
2673
+ var u;
2674
+ r = s.gameSlug;
2675
+ for (let n of e) t.set(n.stableID, { index: c(n) });
2676
+ p(s), (u = s.getElement("#simulator-checklist-list")) == null || u.addEventListener("click", (e) => {
2677
+ var r, c;
2678
+ let u = e.target, d = (r = u.closest("[data-reset]")) == null ? void 0 : r.dataset.reset, f = (c = u.closest("[data-help]")) == null ? void 0 : c.dataset.help;
2679
+ if (d) t.set(d, { index: 0 }), l(d, 0), a = void 0, o = [], i = 0, s.updateBadge("checklist", 0);
2680
+ else if (f) n.has(f) ? n.delete(f) : n.add(f);
2681
+ else return;
2682
+ p(s);
2683
+ });
2684
+ },
2685
+ onActivate() {
2686
+ i = 0;
2687
+ },
2688
+ onMessage(e, t, n) {
2689
+ var r, i, a;
2690
+ e === "HIT_CHECKPOINT" ? m(n, t == null || (r = t.augConfig) == null ? void 0 : r.deeds, "checkpoint", `checkpoint "${(i = t == null ? void 0 : t.checkpointName) == null ? "?" : i}"`) : e === "GAME_COMPLETED" && m(n, t == null || (a = t.config) == null ? void 0 : a.deeds, "completion", "completion");
2691
+ }
2692
+ };
2693
+ }
2694
+ var K = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1026
2695
  /** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
1027
- function _e() {
2696
+ function we() {
1028
2697
  let e = globalThis;
1029
2698
  for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
1030
2699
  name: t,
@@ -1033,23 +2702,23 @@ function _e() {
1033
2702
  return null;
1034
2703
  }
1035
2704
  /** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
1036
- function ve() {
2705
+ function Te() {
1037
2706
  let e = globalThis.getShareString;
1038
2707
  return typeof e == "function" ? e : null;
1039
2708
  }
1040
- function ye(e) {
2709
+ function Ee(e) {
1041
2710
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1042
2711
  }
1043
- function be() {
2712
+ function De() {
1044
2713
  let e = /* @__PURE__ */ new Date();
1045
2714
  return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
1046
2715
  }
1047
- function xe(e) {
2716
+ function Oe(e) {
1048
2717
  return e.charAt(0).toUpperCase() + e.slice(1);
1049
2718
  }
1050
2719
  /** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
1051
- var Se = "\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";
1052
- function Ce() {
2720
+ var ke = "\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";
2721
+ function Ae() {
1053
2722
  return {
1054
2723
  id: "thumb",
1055
2724
  label: "Thumb",
@@ -1071,12 +2740,12 @@ function Ce() {
1071
2740
  o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
1072
2741
  t.addEventListener("click", () => {
1073
2742
  let n = t.dataset.previewKind;
1074
- !n || n === e.state.previewKind || (e.state.previewKind = n, k(n), c(), s(), e.updateThumbnail());
2743
+ !n || n === e.state.previewKind || (e.state.previewKind = n, A(n), c(), s(), e.updateThumbnail());
1075
2744
  });
1076
- }), n && (e.state.renderHost || (e.state.renderHost = "game", O(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
1077
- e.state.renderHost = n.value, O(e.state.renderHost), s(), e.updateThumbnail();
1078
- })), r && (e.state.renderContext || (e.state.renderContext = "preview", A(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
1079
- e.state.renderContext = r.value, A(e.state.renderContext), e.updateThumbnail();
2745
+ }), n && (e.state.renderHost || (e.state.renderHost = "game", k(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
2746
+ e.state.renderHost = n.value, k(e.state.renderHost), s(), e.updateThumbnail();
2747
+ })), r && (e.state.renderContext || (e.state.renderContext = "preview", j(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
2748
+ e.state.renderContext = r.value, j(e.state.renderContext), e.updateThumbnail();
1080
2749
  })), c(), s();
1081
2750
  },
1082
2751
  onActivate(e) {
@@ -1085,26 +2754,26 @@ function Ce() {
1085
2754
  updatePreview: (e) => {
1086
2755
  let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
1087
2756
  if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
1088
- let s = ve();
2757
+ let s = Te();
1089
2758
  if (!s) {
1090
- t && (t.innerHTML = Se), n && (n.textContent = "");
2759
+ t && (t.innerHTML = ke), n && (n.textContent = "");
1091
2760
  return;
1092
2761
  }
1093
2762
  n && (n.textContent = "Using: getShareString()");
1094
2763
  try {
1095
2764
  var r, i, a, o;
1096
- let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, xe(n), {
2765
+ let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, Oe(n), {
1097
2766
  puzzleString: (a = e.state.puzzleData) == null ? "" : a,
1098
- dateKey: be(),
2767
+ dateKey: De(),
1099
2768
  gameplaySlug: `simulator:${n}`
1100
2769
  }), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
1101
- t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${ye(l)}</pre>`);
2770
+ t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${Ee(l)}</pre>`);
1102
2771
  } catch (e) {
1103
2772
  console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
1104
2773
  }
1105
2774
  return;
1106
2775
  }
1107
- let s = _e();
2776
+ let s = we();
1108
2777
  if (!s) {
1109
2778
  t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
1110
2779
  return;
@@ -1118,7 +2787,7 @@ function Ce() {
1118
2787
  strict: !0,
1119
2788
  renderHost: e.state.renderHost,
1120
2789
  renderContext: e.state.renderContext
1121
- }, { svg: i } = P(s.fn(n, e.state.currentInputStr, r));
2790
+ }, { svg: i } = L(s.fn(n, e.state.currentInputStr, r));
1122
2791
  t && (t.innerHTML = i);
1123
2792
  } catch (e) {
1124
2793
  console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
@@ -1127,7 +2796,7 @@ function Ce() {
1127
2796
  };
1128
2797
  }
1129
2798
  /** Generate theme preview HTML showing key colors */
1130
- function we(e) {
2799
+ function je(e) {
1131
2800
  let t = [
1132
2801
  e.key,
1133
2802
  e.subBrand,
@@ -1138,7 +2807,7 @@ function we(e) {
1138
2807
  ].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
1139
2808
  return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
1140
2809
  }
1141
- function Te() {
2810
+ function Me() {
1142
2811
  return {
1143
2812
  id: "theme",
1144
2813
  label: "Theme",
@@ -1147,20 +2816,20 @@ function Te() {
1147
2816
  },
1148
2817
  bind(e) {
1149
2818
  let t = e.getElement("#simulator-themes");
1150
- t && n.forEach((n) => {
2819
+ t && r.forEach((n) => {
1151
2820
  let r = document.createElement("div");
1152
2821
  r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
1153
- ${we(n)}
2822
+ ${je(n)}
1154
2823
  <div class="simulator-theme-name">${n.name}</div>
1155
2824
  <div class="simulator-theme-type">${n.type}</div>
1156
2825
  `, r.addEventListener("click", () => {
1157
- console.log("Simulator: Theme changed, reloading...", n.name), w(n.name), window.location.reload();
2826
+ console.log("Simulator: Theme changed, reloading...", n.name), T(n.name), window.location.reload();
1158
2827
  }), t.appendChild(r);
1159
2828
  });
1160
2829
  }
1161
2830
  };
1162
2831
  }
1163
- var Ee = [
2832
+ var Ne = [
1164
2833
  {
1165
2834
  name: "app (desktop)",
1166
2835
  context: [{
@@ -1207,8 +2876,8 @@ var Ee = [
1207
2876
  * The bootstrap is only read at game boot, so applying a change persists it to localStorage and
1208
2877
  * restarts (reloads) the page — the same flow as the Theme tab.
1209
2878
  */
1210
- function De(e = []) {
1211
- let t = [...Ee, ...e];
2879
+ function Pe(e = []) {
2880
+ let t = [...Ne, ...e];
1212
2881
  return {
1213
2882
  id: "host",
1214
2883
  label: "Host",
@@ -1225,7 +2894,7 @@ function De(e = []) {
1225
2894
  <div class="host-note" id="host-source"></div>
1226
2895
  <select class="simulator-select" id="host-presets">
1227
2896
  <option value="">Preset…</option>
1228
- ${t.map((e, t) => `<option value="${t}">${Oe(e.name)}</option>`).join("")}
2897
+ ${t.map((e, t) => `<option value="${t}">${Fe(e.name)}</option>`).join("")}
1229
2898
  </select>
1230
2899
  <textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
1231
2900
  <div class="host-actions">
@@ -1254,50 +2923,50 @@ function De(e = []) {
1254
2923
  o.textContent = "hostContext must be an array of { type: string, ... } objects";
1255
2924
  return;
1256
2925
  }
1257
- console.log("Simulator: hostContext changed, reloading...", e), d(e), window.location.reload();
2926
+ console.log("Simulator: hostContext changed, reloading...", e), f(e), window.location.reload();
1258
2927
  }), (r = e.getElement("#host-reset")) == null || r.addEventListener("click", () => {
1259
- f(), window.location.reload();
2928
+ p(), window.location.reload();
1260
2929
  }));
1261
2930
  }
1262
2931
  };
1263
2932
  }
1264
2933
  /** Minimal HTML-escape so preset names can't break the simulator markup. */
1265
- function Oe(e) {
2934
+ function Fe(e) {
1266
2935
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1267
2936
  }
1268
- var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.puzzmo.com", G = () => localStorage.getItem(ke) === "dev" ? "dev" : "prod", je = (e) => {
1269
- localStorage.setItem(ke, e);
1270
- }, K = null, Me = function() {
2937
+ var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.puzzmo.com", q = () => localStorage.getItem(Ie) === "dev" ? "dev" : "prod", ze = (e) => {
2938
+ localStorage.setItem(Ie, e);
2939
+ }, J = null, Be = function() {
1271
2940
  var e = t(function* () {
1272
- if (K !== null) return K;
2941
+ if (J !== null) return J;
1273
2942
  try {
1274
- let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${W}/healthz`, { signal: e.signal });
1275
- return clearTimeout(t), K = n.ok, K;
2943
+ let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${Le}/healthz`, { signal: e.signal });
2944
+ return clearTimeout(t), J = n.ok, J;
1276
2945
  } catch (e) {
1277
- return K = !1, !1;
2946
+ return J = !1, !1;
1278
2947
  }
1279
2948
  });
1280
2949
  return function() {
1281
2950
  return e.apply(this, arguments);
1282
2951
  };
1283
- }(), q = () => ({
1284
- apiURL: G() === "dev" ? W : Ae,
2952
+ }(), Ve = () => ({
2953
+ apiURL: q() === "dev" ? Le : Re,
1285
2954
  clientID: "protosdk:oauthclient",
1286
2955
  redirectUri: `${window.location.origin}/oauth/callback`
1287
- }), Ne = () => {
2956
+ }), He = () => {
1288
2957
  let e = new Uint8Array(32);
1289
2958
  return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
1290
- }, Pe = "puzzmo_sim_oauth_token", Fe = "puzzmo_sim_oauth_refresh_token", Ie = (e) => localStorage.setItem(Pe, e), Le = (e) => localStorage.setItem(Fe, e), Re = () => {
1291
- let e = localStorage.getItem(Pe);
2959
+ }, Ue = "puzzmo_sim_oauth_token", We = "puzzmo_sim_oauth_refresh_token", Ge = (e) => localStorage.setItem(Ue, e), Ke = (e) => localStorage.setItem(We, e), qe = () => {
2960
+ let e = localStorage.getItem(Ue);
1292
2961
  return e && `${e.substring(0, 20)}`, e;
1293
- }, ze = () => localStorage.getItem(Fe), Be = () => {
1294
- localStorage.removeItem(Pe), localStorage.removeItem(Fe);
1295
- }, Ve = () => {
1296
- let e = q(), t = Ne();
2962
+ }, Je = () => localStorage.getItem(We), Ye = () => {
2963
+ localStorage.removeItem(Ue), localStorage.removeItem(We);
2964
+ }, Xe = () => {
2965
+ let e = Ve(), t = He();
1297
2966
  sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
1298
2967
  let n = new URL(`${e.apiURL}/oauth/auth`);
1299
2968
  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();
1300
- }, He = (e) => {
2969
+ }, Ze = (e) => {
1301
2970
  try {
1302
2971
  let t = e.split(".");
1303
2972
  if (t.length !== 3) return !0;
@@ -1306,11 +2975,11 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
1306
2975
  } catch (e) {
1307
2976
  return !0;
1308
2977
  }
1309
- }, Ue = function() {
2978
+ }, Qe = function() {
1310
2979
  var e = t(function* () {
1311
- let e = ze();
2980
+ let e = Je();
1312
2981
  if (!e) return !1;
1313
- let t = q();
2982
+ let t = Ve();
1314
2983
  try {
1315
2984
  let n = new URLSearchParams({
1316
2985
  grant_type: "refresh_token",
@@ -1324,9 +2993,9 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
1324
2993
  if (!r.ok) return r.statusText, !1;
1325
2994
  let i = yield r.json(), a = i.access_token || i.accessToken;
1326
2995
  if (!a) return !1;
1327
- Ie(a);
2996
+ Ge(a);
1328
2997
  let o = i.refresh_token || i.refreshToken;
1329
- return o && Le(o), !0;
2998
+ return o && Ke(o), !0;
1330
2999
  } catch (e) {
1331
3000
  return !1;
1332
3001
  }
@@ -1334,9 +3003,9 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
1334
3003
  return function() {
1335
3004
  return e.apply(this, arguments);
1336
3005
  };
1337
- }(), We = function() {
3006
+ }(), $e = function() {
1338
3007
  var e = t(function* (e, t) {
1339
- let n = q(), r = sessionStorage.getItem("oauth_state");
3008
+ let n = Ve(), r = sessionStorage.getItem("oauth_state");
1340
3009
  if (!r || r !== t) return null;
1341
3010
  sessionStorage.removeItem("oauth_state");
1342
3011
  try {
@@ -1358,13 +3027,13 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
1358
3027
  return function(t, n) {
1359
3028
  return e.apply(this, arguments);
1360
3029
  };
1361
- }(), Ge = function() {
3030
+ }(), et = function() {
1362
3031
  var e = t(function* (e, t = {}) {
1363
- let n = q(), r = Re();
3032
+ let n = Ve(), r = qe();
1364
3033
  if (!r) throw Error("Not authenticated");
1365
- if (He(r)) if (yield Ue()) {
1366
- if (r = Re(), !r) throw Error("Token refresh succeeded but no token available");
1367
- } else throw Be(), Error("Session expired. Please log in again.");
3034
+ if (Ze(r)) if (yield Qe()) {
3035
+ if (r = qe(), !r) throw Error("Token refresh succeeded but no token available");
3036
+ } else throw Ye(), Error("Session expired. Please log in again.");
1368
3037
  let i = yield fetch(`${n.apiURL}/graphql`, {
1369
3038
  method: "POST",
1370
3039
  headers: {
@@ -1383,7 +3052,7 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
1383
3052
  return function(t) {
1384
3053
  return e.apply(this, arguments);
1385
3054
  };
1386
- }(), Ke = (e) => {
3055
+ }(), tt = (e) => {
1387
3056
  try {
1388
3057
  let t = e.split(".");
1389
3058
  return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
@@ -1391,15 +3060,15 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
1391
3060
  return null;
1392
3061
  }
1393
3062
  };
1394
- function qe() {
3063
+ function nt() {
1395
3064
  let e = !1;
1396
3065
  return {
1397
3066
  id: "auth",
1398
3067
  label: "Auth",
1399
3068
  render() {
1400
- let e = Re(), t = !!e, n = G(), r = n === "dev" ? W : Ae, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
3069
+ let e = qe(), t = !!e, n = q(), r = n === "dev" ? Le : Re, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
1401
3070
  if (t) {
1402
- let t = Ke(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!ze(), o = a ? Ke(ze()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
3071
+ 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;
1403
3072
  return `
1404
3073
  <div class="simulator-section">
1405
3074
  <div class="simulator-section-title auth-title-row">
@@ -1440,7 +3109,7 @@ function qe() {
1440
3109
  </div>
1441
3110
  <p class="auth-description">
1442
3111
  Login with your Puzzmo account to make authenticated API requests.
1443
- ${n === "dev" ? `<br><strong>Using local dev server:</strong> ${W}` : ""}
3112
+ ${n === "dev" ? `<br><strong>Using local dev server:</strong> ${Le}` : ""}
1444
3113
  </p>
1445
3114
  <div class="simulator-row">
1446
3115
  <button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
@@ -1451,21 +3120,21 @@ function qe() {
1451
3120
  },
1452
3121
  bind(n) {
1453
3122
  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");
1454
- e ? K && c && (c.style.display = "", G() === "dev" && c.classList.add("active")) : (e = !0, Me().then((e) => {
1455
- e && c && (c.style.display = "", G() === "dev" && c.classList.add("active"));
3123
+ e ? J && c && (c.style.display = "", q() === "dev" && c.classList.add("active")) : (e = !0, Be().then((e) => {
3124
+ e && c && (c.style.display = "", q() === "dev" && c.classList.add("active"));
1456
3125
  })), c == null || c.addEventListener("click", () => {
1457
- je(G() === "dev" ? "prod" : "dev"), Be(), window.location.reload();
3126
+ ze(q() === "dev" ? "prod" : "dev"), Ye(), window.location.reload();
1458
3127
  }), r == null || r.addEventListener("click", () => {
1459
- Ve();
3128
+ Xe();
1460
3129
  }), i == null || i.addEventListener("click", () => {
1461
- Be(), window.location.reload();
3130
+ Ye(), window.location.reload();
1462
3131
  }), a == null || a.addEventListener("click", t(function* () {
1463
- a.disabled = !0, a.textContent = "Refreshing...", (yield Ue()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
3132
+ a.disabled = !0, a.textContent = "Refreshing...", (yield Qe()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
1464
3133
  })), o == null || o.addEventListener("click", t(function* () {
1465
3134
  if (s) {
1466
3135
  s.innerHTML = "<div class=\"loading\">Loading...</div>";
1467
3136
  try {
1468
- let t = yield Ge("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
3137
+ let t = yield et("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
1469
3138
  if (t.errors) {
1470
3139
  var e;
1471
3140
  s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
@@ -1487,13 +3156,13 @@ function qe() {
1487
3156
  if (n && r) {
1488
3157
  let t = e.getElement("#auth-status");
1489
3158
  t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
1490
- let i = yield We(n, r);
3159
+ let i = yield $e(n, r);
1491
3160
  if (window.history.replaceState({}, "", window.location.pathname), i) {
1492
3161
  let e = i.access_token || i.accessToken;
1493
3162
  if (e) {
1494
- Ie(e);
3163
+ Ge(e);
1495
3164
  let t = i.refresh_token || i.refreshToken;
1496
- t && Le(t);
3165
+ t && Ke(t);
1497
3166
  }
1498
3167
  window.location.reload();
1499
3168
  } else {
@@ -1505,9 +3174,9 @@ function qe() {
1505
3174
  }
1506
3175
  };
1507
3176
  }
1508
- var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.puzzmo.com", Ze = "puzzmo_sim_oauth_token", Qe = "puzzmo_sim_oauth_refresh_token", $e = () => localStorage.getItem(Je) === "dev" ? "dev" : "prod", et = () => localStorage.getItem(Ze), tt = () => localStorage.getItem(Qe), nt = (e) => localStorage.setItem(Ze, e), rt = (e) => localStorage.setItem(Qe, e), it = () => {
1509
- localStorage.removeItem(Ze), localStorage.removeItem(Qe);
1510
- }, at = (e) => {
3177
+ 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 = () => {
3178
+ localStorage.removeItem(ot), localStorage.removeItem(st);
3179
+ }, mt = (e) => {
1511
3180
  try {
1512
3181
  let t = e.split(".");
1513
3182
  if (t.length !== 3) return !0;
@@ -1516,11 +3185,11 @@ var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.
1516
3185
  } catch (e) {
1517
3186
  return !0;
1518
3187
  }
1519
- }, ot = function() {
3188
+ }, ht = function() {
1520
3189
  var e = t(function* () {
1521
- let e = tt();
3190
+ let e = ut();
1522
3191
  if (!e) return !1;
1523
- let t = $e() === "dev" ? Ye : Xe;
3192
+ let t = ct() === "dev" ? it : at;
1524
3193
  try {
1525
3194
  let n = new URLSearchParams({
1526
3195
  grant_type: "refresh_token",
@@ -1534,9 +3203,9 @@ var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.
1534
3203
  if (!r.ok) return !1;
1535
3204
  let i = yield r.json(), a = i.access_token || i.accessToken;
1536
3205
  if (!a) return !1;
1537
- nt(a);
3206
+ dt(a);
1538
3207
  let o = i.refresh_token || i.refreshToken;
1539
- return o && rt(o), !0;
3208
+ return o && ft(o), !0;
1540
3209
  } catch (e) {
1541
3210
  return !1;
1542
3211
  }
@@ -1544,13 +3213,13 @@ var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.
1544
3213
  return function() {
1545
3214
  return e.apply(this, arguments);
1546
3215
  };
1547
- }(), st = function() {
3216
+ }(), gt = function() {
1548
3217
  var e = t(function* (e, t = {}) {
1549
- let n = $e() === "dev" ? Ye : Xe, r = et();
3218
+ let n = ct() === "dev" ? it : at, r = lt();
1550
3219
  if (!r) throw Error("Not authenticated");
1551
- if (at(r)) if (yield ot()) {
1552
- if (r = et(), !r) throw Error("Token refresh succeeded but no token available");
1553
- } else throw it(), Error("Session expired. Please log in again.");
3220
+ if (mt(r)) if (yield ht()) {
3221
+ if (r = lt(), !r) throw Error("Token refresh succeeded but no token available");
3222
+ } else throw pt(), Error("Session expired. Please log in again.");
1554
3223
  let i = yield fetch(`${n}/graphql`, {
1555
3224
  method: "POST",
1556
3225
  headers: {
@@ -1569,19 +3238,19 @@ var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.
1569
3238
  return function(t) {
1570
3239
  return e.apply(this, arguments);
1571
3240
  };
1572
- }(), ct = "\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", lt = "\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", ut = (e, t) => {
3241
+ }(), _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) => {
1573
3242
  let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
1574
3243
  for (; a.length <= r;) a.push(0);
1575
3244
  return a[r] = a[r] ^ 1 << i, a;
1576
3245
  };
1577
- const dt = () => !!et();
1578
- function ft() {
3246
+ const bt = () => !!lt();
3247
+ function xt() {
1579
3248
  let n = null, r = !1, i = null, a = function() {
1580
3249
  var e = t(function* (e) {
1581
3250
  r = !0, i = null;
1582
3251
  try {
1583
3252
  var t;
1584
- let r = yield st(ct, { slug: e });
3253
+ let r = yield gt(_t, { slug: e });
1585
3254
  if (r.errors) {
1586
3255
  var a;
1587
3256
  i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
@@ -1598,10 +3267,10 @@ function ft() {
1598
3267
  }(), o = function() {
1599
3268
  var r = t(function* (t) {
1600
3269
  if (!n) return;
1601
- let r = ut(n.featuresArr, t);
3270
+ let r = yt(n.featuresArr, t);
1602
3271
  try {
1603
3272
  var i;
1604
- let t = yield st(lt, {
3273
+ let t = yield gt(vt, {
1605
3274
  gameSlug: n.slug,
1606
3275
  input: { featuresArr: r }
1607
3276
  });
@@ -1649,7 +3318,7 @@ function ft() {
1649
3318
  id: "features",
1650
3319
  label: "Features",
1651
3320
  render() {
1652
- return dt() ? `
3321
+ return bt() ? `
1653
3322
  <div class="features-view-container">
1654
3323
  <div class="simulator-section">
1655
3324
  <div class="simulator-section-title">Game Features</div>
@@ -1690,7 +3359,7 @@ function ft() {
1690
3359
  e && (yield d(e));
1691
3360
  })), i == null || i.addEventListener("keypress", (e) => {
1692
3361
  e.key === "Enter" && (r == null || r.click());
1693
- }), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, dt() && !n && d(e.gameSlug)), u();
3362
+ }), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, bt() && !n && d(e.gameSlug)), u();
1694
3363
  },
1695
3364
  onActivate(e) {
1696
3365
  let t = e.getElement("#simulator-tab-features");
@@ -1714,19 +3383,19 @@ function ft() {
1714
3383
  * tuning it needs to see it.
1715
3384
  */
1716
3385
  /** Space the keys occupy. */
1717
- var pt = 200, mt = 24;
3386
+ var St = 200, Ct = 24;
1718
3387
  /** What the keyboard takes off the bottom of the game, and what the game must lay out without. */
1719
- const J = pt + mt;
3388
+ const Y = St + Ct;
1720
3389
  /** Drag-cursor thresholds, from useKeyboardCursor in @puzzmo-com/keyboard. */
1721
- var ht = 6, gt = 2.5, _t = 100, vt = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", Y = (e, t) => {
3390
+ var wt = 6, Tt = 2.5, Et = 100, Dt = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", X = (e, t) => {
1722
3391
  let n = e.replace("#", ""), r = n.length === 3 ? [...n].map((e) => e + e).join("") : n, i = parseInt(r, 16);
1723
3392
  return r.length !== 6 || Number.isNaN(i) ? e : `rgba(${i >> 16 & 255}, ${i >> 8 & 255}, ${i & 255}, ${t})`;
1724
- }, yt = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), bt = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1725
- function xt(e) {
3393
+ }, Ot = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), kt = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3394
+ function At(e) {
1726
3395
  let { theme: t, sendToGame: n } = e, r = !1, i = null, a = null, o = document.createElement("style");
1727
3396
  o.id = "sim-docked-kbd-page-style", o.textContent = `
1728
3397
  html.sim-kbd-docked #simulator {
1729
- bottom: ${J + 4}px;
3398
+ bottom: ${Y + 4}px;
1730
3399
  }
1731
3400
  `;
1732
3401
  /** The element the game mounted into: `#root` per the SDK's page template, else the page's first element. */
@@ -1739,7 +3408,7 @@ function xt(e) {
1739
3408
  let { height: t, maxHeight: n, position: r } = e.style;
1740
3409
  c = () => {
1741
3410
  e.style.height = t, e.style.maxHeight = n, e.style.position = r, c = null;
1742
- }, e.style.height = `calc(100% - ${J}px)`, e.style.maxHeight = `calc(100% - ${J}px)`, getComputedStyle(e).position === "static" && (e.style.position = "relative");
3411
+ }, e.style.height = `calc(100% - ${Y}px)`, e.style.maxHeight = `calc(100% - ${Y}px)`, getComputedStyle(e).position === "static" && (e.style.position = "relative");
1743
3412
  }, u = (e, n) => {
1744
3413
  var r;
1745
3414
  let i = n.disabled.includes(e), a = n.highlight.includes(e);
@@ -1754,8 +3423,8 @@ function xt(e) {
1754
3423
  "overflow:hidden",
1755
3424
  "background:transparent",
1756
3425
  "pointer-events:none",
1757
- `border:${i ? `1px dashed ${Y(t.fg, .25)}` : a ? `2px solid ${Y(t.fg, .75)}` : `1px solid ${Y(t.fg, .4)}`}`,
1758
- X((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.background)
3426
+ `border:${i ? `1px dashed ${X(t.fg, .25)}` : a ? `2px solid ${X(t.fg, .75)}` : `1px solid ${X(t.fg, .4)}`}`,
3427
+ Z((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.background)
1759
3428
  ].filter(Boolean).join(";");
1760
3429
  }, d = (e, n) => {
1761
3430
  var r;
@@ -1764,14 +3433,14 @@ function xt(e) {
1764
3433
  "letter-spacing:0.5px",
1765
3434
  "text-transform:uppercase",
1766
3435
  "white-space:nowrap",
1767
- `color:${Y(t.fg, n.disabled.includes(e) ? .3 : .65)}`,
1768
- n.highlight.includes(e) ? "" : X(n.keyStyles),
1769
- X((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.text)
3436
+ `color:${X(t.fg, n.disabled.includes(e) ? .3 : .65)}`,
3437
+ n.highlight.includes(e) ? "" : Z(n.keyStyles),
3438
+ Z((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.text)
1770
3439
  ].filter(Boolean).join(";");
1771
3440
  }, f = (e, t) => {
1772
3441
  var n, r;
1773
3442
  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 = [
1774
- `width:${vt(t.l.includes(e), t.xl.includes(e))}`,
3443
+ `width:${Dt(t.l.includes(e), t.xl.includes(e))}`,
1775
3444
  `flex:${o ? "1 0 auto" : "0 1 auto"}`,
1776
3445
  "height:100%",
1777
3446
  "display:flex",
@@ -1781,43 +3450,43 @@ function xt(e) {
1781
3450
  "position:relative",
1782
3451
  a ? "pointer-events:none" : ""
1783
3452
  ].filter(Boolean).join(";"), c = u(e, t), l = d(e, t);
1784
- return `<div class="sim-docked-kbd-key" data-key="${yt(e)}" style="${s}">
1785
- <div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${bt(i)}</div></div>
3453
+ return `<div class="sim-docked-kbd-key" data-key="${Ot(e)}" style="${s}">
3454
+ <div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${kt(i)}</div></div>
1786
3455
  </div>`;
1787
3456
  }, p = (e) => {
1788
3457
  let n = e.layout.filter((e) => !!e), r = `calc(100% / ${n.length})`;
1789
3458
  return `${n.map((t, n) => {
1790
3459
  var i, a;
1791
3460
  return `<div style="${`height:${r};display:flex;flex-direction:row;align-items:center;justify-content:${(i = (a = e.rowPositioning) == null ? void 0 : a[n]) == null ? "center" : i}`}">${[...t].map((t) => f(t, e)).join("")}</div>`;
1792
- }).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${Y(t.fg, .12)};opacity:0;transition:opacity 0.1s ease-in-out;pointer-events:none"></div>`}`;
3461
+ }).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${X(t.fg, .12)};opacity:0;transition:opacity 0.1s ease-in-out;pointer-events:none"></div>`}`;
1793
3462
  }, m = !1, h = [0, 0], g = null, _ = 0, v = null, y = null, b = (e) => {
1794
3463
  let t = a == null ? void 0 : a.querySelector("#sim-docked-kbd-cursor");
1795
3464
  t && (t.style.opacity = e ? "0.5" : "0");
1796
3465
  }, x = () => {
1797
3466
  m = !1, h = [0, 0], g = null, _ = 0, v = null, y = null, b(!1);
1798
- }, ee = (e) => {
3467
+ }, S = (e) => {
1799
3468
  var t, n;
1800
3469
  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;
1801
- }, S = (e) => {
1802
- y = ee(e), a == null || a.setPointerCapture(e.pointerId);
3470
+ }, ee = (e) => {
3471
+ y = S(e), a == null || a.setPointerCapture(e.pointerId);
1803
3472
  }, C = (e) => {
1804
- !(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, _ >= ht && Date.now() - v >= _t && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * gt, h[1] + (e.clientY - g.clientY) * gt]), g = {
3473
+ !(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 = {
1805
3474
  clientX: e.clientX,
1806
3475
  clientY: e.clientY,
1807
3476
  pointerId: e.pointerId
1808
3477
  }, m && n("KEYBOARD_CURSOR_CHANGE", { position: h }));
1809
- }, te = (e) => {
1810
- m ? n("KEYBOARD_CURSOR_END", {}) : y && ee(e) === y && n("KEYBOARD_KEY_PRESS", { key: y }), x();
1811
- }, ne = () => {
3478
+ }, w = (e) => {
3479
+ m ? n("KEYBOARD_CURSOR_END", {}) : y && S(e) === y && n("KEYBOARD_KEY_PRESS", { key: y }), x();
3480
+ }, te = () => {
1812
3481
  a || !i || (a = document.createElement("div"), a.id = "sim-docked-kbd", a.style.cssText = [
1813
3482
  "position:fixed",
1814
3483
  "left:0",
1815
3484
  "right:0",
1816
3485
  "bottom:0",
1817
- `height:${J}px`,
3486
+ `height:${Y}px`,
1818
3487
  "box-sizing:border-box",
1819
3488
  "padding-top:8px",
1820
- `padding-bottom:${mt}px`,
3489
+ `padding-bottom:${Ct}px`,
1821
3490
  "display:flex",
1822
3491
  "flex-direction:column",
1823
3492
  "z-index:999998",
@@ -1825,9 +3494,9 @@ function xt(e) {
1825
3494
  "user-select:none",
1826
3495
  "-webkit-user-select:none",
1827
3496
  `background:${t.a_bg}`,
1828
- `border-top:1px solid ${Y(t.fg, .2)}`
1829
- ].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", S), a.addEventListener("pointermove", C), a.addEventListener("pointerup", te), 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());
1830
- }, w = () => {
3497
+ `border-top:1px solid ${X(t.fg, .2)}`
3498
+ ].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());
3499
+ }, ne = () => {
1831
3500
  a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), x());
1832
3501
  }, T = () => {
1833
3502
  let e = i;
@@ -1836,8 +3505,8 @@ function xt(e) {
1836
3505
  !n || !r || !i || (r.style.cssText = u(n, e), i.style.cssText = d(n, e));
1837
3506
  });
1838
3507
  }, E = () => {
1839
- if (!r || !i) return w();
1840
- if (!a) return ne();
3508
+ if (!r || !i) return ne();
3509
+ if (!a) return te();
1841
3510
  a.innerHTML = p(i), b(m);
1842
3511
  };
1843
3512
  return {
@@ -1845,13 +3514,13 @@ function xt(e) {
1845
3514
  r = e, E();
1846
3515
  },
1847
3516
  setConfig(e) {
1848
- let t = a && e && i && St(e) === St(i);
3517
+ let t = a && e && i && jt(e) === jt(i);
1849
3518
  i = e, t ? T() : E();
1850
3519
  }
1851
3520
  };
1852
3521
  }
1853
3522
  /** Everything about a config except its per-key styling, so a styling-only update can be spotted. */
1854
- var St = (e) => JSON.stringify([
3523
+ var jt = (e) => JSON.stringify([
1855
3524
  e.layout,
1856
3525
  e.symbols,
1857
3526
  e.highlight,
@@ -1863,9 +3532,9 @@ var St = (e) => JSON.stringify([
1863
3532
  e.keyStyles
1864
3533
  ]);
1865
3534
  /** Serializes a style object into inline CSS, so `{ backgroundColor: "red" }` becomes `background-color:red`. */
1866
- const X = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${yt(String(t))}`).join(";");
3535
+ const Z = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${Ot(String(t))}`).join(";");
1867
3536
  /** Renders a single keyboard key as an HTML button string */
1868
- var Ct = (e, t) => {
3537
+ var Mt = (e, t) => {
1869
3538
  var n, r, i, a;
1870
3539
  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 = [
1871
3540
  "sim-kb-key",
@@ -1874,11 +3543,11 @@ var Ct = (e, t) => {
1874
3543
  l ? "xl" : "",
1875
3544
  u ? "l" : "",
1876
3545
  d ? "grow" : ""
1877
- ].filter(Boolean).join(" "), p = X((i = t.individualKeyStyles) == null || (i = i[e]) == null ? void 0 : i.background), m = X((a = t.individualKeyStyles) == null || (a = a[e]) == null ? void 0 : a.text);
3546
+ ].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);
1878
3547
  return `<button class="${f}" data-key="${e}" style="${p}" ${s ? "disabled" : ""}><span style="${m}">${o}</span></button>`;
1879
- }, wt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => Ct(t, e)).join("")}</div>`).join("")}</div>`;
1880
- function Tt() {
1881
- let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${J}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : wt(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>";
3548
+ }, 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>`;
3549
+ function Pt() {
3550
+ 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>";
1882
3551
  return {
1883
3552
  id: "kbd",
1884
3553
  label: "Kbd",
@@ -1898,14 +3567,14 @@ function Tt() {
1898
3567
  `;
1899
3568
  },
1900
3569
  bind(e) {
1901
- t != null || (t = xt({
3570
+ t != null || (t = At({
1902
3571
  theme: e.state.selectedTheme,
1903
3572
  sendToGame: e.sendToGame
1904
3573
  })), t.setEnabled(e.state.keyboardDocked);
1905
3574
  let n = e.getElement("#sim-kb-dock");
1906
3575
  n && (n.checked = e.state.keyboardDocked, n.addEventListener("change", () => {
1907
- e.state.keyboardDocked = n.checked, m(n.checked), t == null || t.setEnabled(n.checked), r(e);
1908
- })), Et(e);
3576
+ e.state.keyboardDocked = n.checked, h(n.checked), t == null || t.setEnabled(n.checked), r(e);
3577
+ })), Ft(e);
1909
3578
  },
1910
3579
  onMessage(n, i, a) {
1911
3580
  var o;
@@ -1915,11 +3584,11 @@ function Tt() {
1915
3584
  /** Re-render the tab's own content (not the dock) and rebind its keys. */
1916
3585
  function r(e) {
1917
3586
  let t = e.getElement("#sim-kb-content");
1918
- t && (t.innerHTML = n(e.state.keyboardDocked), Et(e));
3587
+ t && (t.innerHTML = n(e.state.keyboardDocked), Ft(e));
1919
3588
  }
1920
3589
  }
1921
3590
  /** Attach click handlers to all rendered keys */
1922
- function Et(e) {
3591
+ function Ft(e) {
1923
3592
  var t;
1924
3593
  let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
1925
3594
  n == null || n.forEach((t) => {
@@ -1934,15 +3603,15 @@ function Et(e) {
1934
3603
  * change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
1935
3604
  * production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
1936
3605
  */
1937
- function Dt() {
3606
+ function It() {
1938
3607
  let t = (e) => {
1939
3608
  let t = e.state.settingsComponents;
1940
- 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) => Ot(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>`;
3609
+ 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>`;
1941
3610
  }, n = (e) => {
1942
3611
  let n = e.getElement("#sim-settings-content");
1943
3612
  n && (n.innerHTML = t(e), i(e));
1944
3613
  }, r = (e) => {
1945
- S(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
3614
+ C(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
1946
3615
  }, i = (t) => {
1947
3616
  var i;
1948
3617
  let a = t.getElement("#sim-settings-content");
@@ -1958,7 +3627,7 @@ function Dt() {
1958
3627
  });
1959
3628
  }), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
1960
3629
  var e;
1961
- C(), t.state.gameSettings = kt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
3630
+ w(), t.state.gameSettings = zt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
1962
3631
  }));
1963
3632
  };
1964
3633
  return {
@@ -1973,21 +3642,21 @@ function Dt() {
1973
3642
  onMessage(t, r, i) {
1974
3643
  if (t === "INITIALIZE_SETTINGS") {
1975
3644
  var a;
1976
- 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), S(i.state.gameSettings), n(i);
3645
+ 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);
1977
3646
  return;
1978
3647
  }
1979
- t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), S(i.state.gameSettings), n(i));
3648
+ 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));
1980
3649
  }
1981
3650
  };
1982
3651
  }
1983
3652
  /** Renders a single settings UI component as HTML, reading its current value from `settings` */
1984
- function Ot(e, t) {
3653
+ function Lt(e, t) {
1985
3654
  switch (e.type) {
1986
3655
  case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
1987
3656
  case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
1988
3657
  case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
1989
3658
  case "separator": return "<div class=\"simulator-divider\"></div>";
1990
- case "split": return `<div class="sim-settings-split">${e.content.map((e) => Ot(e, t)).join("")}</div>`;
3659
+ case "split": return `<div class="sim-settings-split">${e.content.map((e) => Lt(e, t)).join("")}</div>`;
1991
3660
  case "boolean": {
1992
3661
  var n;
1993
3662
  let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
@@ -2008,7 +3677,7 @@ function Ot(e, t) {
2008
3677
  }).join("");
2009
3678
  return `
2010
3679
  <div class="simulator-field">
2011
- ${Z(e)}
3680
+ ${Rt(e)}
2012
3681
  <select class="simulator-select" data-setting="${e.name}">${i}</select>
2013
3682
  </div>`;
2014
3683
  }
@@ -2024,7 +3693,7 @@ function Ot(e, t) {
2024
3693
  }).join("");
2025
3694
  return `
2026
3695
  <div class="simulator-field">
2027
- ${Z(e)}
3696
+ ${Rt(e)}
2028
3697
  ${a}
2029
3698
  </div>`;
2030
3699
  }
@@ -2033,7 +3702,7 @@ function Ot(e, t) {
2033
3702
  let n = (a = t[e.name]) == null ? e.defaultValue : a, r = e.values.map((e) => `<option value="${e}" ${e === n ? "selected" : ""}>${e}</option>`).join("");
2034
3703
  return `
2035
3704
  <div class="simulator-field">
2036
- ${Z(e)}
3705
+ ${Rt(e)}
2037
3706
  <select class="simulator-select" data-setting="${e.name}" data-setting-type="number">${r}</select>
2038
3707
  </div>`;
2039
3708
  }
@@ -2042,7 +3711,7 @@ function Ot(e, t) {
2042
3711
  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)}" />`;
2043
3712
  return `
2044
3713
  <div class="simulator-field">
2045
- ${Z(e)}
3714
+ ${Rt(e)}
2046
3715
  ${r}
2047
3716
  </div>`;
2048
3717
  }
@@ -2050,14 +3719,14 @@ function Ot(e, t) {
2050
3719
  }
2051
3720
  }
2052
3721
  /** Title + optional subtitle markup for a value-producing component */
2053
- function Z(e) {
3722
+ function Rt(e) {
2054
3723
  let t = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
2055
3724
  return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
2056
3725
  }
2057
3726
  /** Collects name → defaultValue pairs from components, recursing into split groups */
2058
- function kt(e) {
3727
+ function zt(e) {
2059
3728
  let t = {};
2060
- for (let n of e) n.type === "split" ? Object.assign(t, kt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
3729
+ for (let n of e) n.type === "split" ? Object.assign(t, zt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
2061
3730
  return t;
2062
3731
  }
2063
3732
  function Q(e) {
@@ -2068,8 +3737,8 @@ function Q(e) {
2068
3737
  * parts the host owns: the sound-enabled gate (games boot muted, so this is what lets you hear
2069
3738
  * anything) and a log of the cues the game asked us for, with any haptic it wanted.
2070
3739
  */
2071
- function At() {
2072
- 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">${Mt(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${Mt(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
3740
+ function Bt() {
3741
+ 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) => {
2073
3742
  let r = t.getElement("#sound-events");
2074
3743
  r && (r.innerHTML = n()), t.updateBadge("sound", e.length);
2075
3744
  };
@@ -2116,13 +3785,13 @@ function At() {
2116
3785
  n === "SENSORY_EVENT" && (e.unshift({
2117
3786
  id: (o = i == null ? void 0 : i.id) == null ? JSON.stringify(i) : o,
2118
3787
  haptic: i == null ? void 0 : i.haptic,
2119
- time: jt()
3788
+ time: Vt()
2120
3789
  }), e.length > 100 && e.pop(), r(a));
2121
3790
  }
2122
3791
  };
2123
3792
  }
2124
3793
  /** Current wall-clock time as HH:MM:SS, matching the simulator's message log formatting. */
2125
- function jt() {
3794
+ function Vt() {
2126
3795
  return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
2127
3796
  hour12: !1,
2128
3797
  hour: "2-digit",
@@ -2131,16 +3800,16 @@ function jt() {
2131
3800
  });
2132
3801
  }
2133
3802
  /** Minimal HTML-escape so event ids can't break the simulator markup. */
2134
- function Mt(e) {
3803
+ function Ht(e) {
2135
3804
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2136
3805
  }
2137
3806
  var $ = null;
2138
3807
  /** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
2139
- function Nt() {
3808
+ function Ut() {
2140
3809
  return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
2141
3810
  }
2142
3811
  /** Inert instance returned when the simulator declines to boot (the app is the host). */
2143
- var Pt = {
3812
+ var Wt = {
2144
3813
  updateFixtures: () => {},
2145
3814
  sendToGame: () => {},
2146
3815
  loadPuzzle: function() {
@@ -2189,37 +3858,38 @@ var Pt = {
2189
3858
  * Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
2190
3859
  * This will show dropdowns in the Ctrl tab to select category and puzzle.
2191
3860
  */
2192
- function Ft(n = {}) {
2193
- var r, i, a;
2194
- if (Nt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Pt;
3861
+ function Gt(n = {}) {
3862
+ var r, i, a, o, s;
3863
+ if (Ut()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Wt;
2195
3864
  if (console.log("[Simulator] createSimulator called with config:", {
2196
3865
  slug: n.slug,
2197
3866
  hasFixtures: !!n.fixtures
2198
3867
  }), $) return n.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(n.fixtures)), $;
2199
- let o = (r = n.autoStart) == null ? !0 : r, s = n.fixtures ? oe(n.fixtures) : null, c = s ? Array.from(s.keys()).sort() : [], l = me(), u = Ce(), d = [
2200
- ce(),
2201
- le(),
2202
- l,
3868
+ let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ? ie(n.fixtures) : null, u = l ? Array.from(l.keys()).sort() : [], d = pe(), f = Ae(), p = [
3869
+ oe(),
3870
+ se(),
3871
+ d,
3872
+ me(),
2203
3873
  he(),
2204
- ge(),
2205
- u,
2206
- Te(),
2207
- De(n.hostContextPresets),
2208
- qe(),
2209
- ft(),
2210
- Tt(),
2211
- Dt(),
2212
- At(),
2213
- ...(i = n.views) == null ? [] : i
2214
- ], f = d.map((e) => e.id), p = ee(n, c, f), m = {
3874
+ Ce((i = (a = n.integrations) == null ? void 0 : a.checklists) == null ? [] : i),
3875
+ f,
3876
+ Me(),
3877
+ Pe(n.hostContextPresets),
3878
+ nt(),
3879
+ xt(),
3880
+ Pt(),
3881
+ It(),
3882
+ Bt(),
3883
+ ...(o = n.views) == null ? [] : o
3884
+ ], m = p.map((e) => e.id), h = ee(n, u, m), g = {
2215
3885
  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>",
2216
3886
  play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
2217
3887
  retry: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><path d=\"M5 1C2.8 1 1 2.8 1 5s1.8 4 4 4c1.8 0 3.3-1.2 3.8-2.8H7.5c-.4.9-1.3 1.5-2.5 1.5-1.5 0-2.7-1.2-2.7-2.7S3.5 2.3 5 2.3c.7 0 1.4.3 1.9.8L5.5 4.5H9V1L7.6 2.4C6.9 1.5 5.9 1 5 1z\"/></svg>",
2218
3888
  cog: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><path d=\"M9.5 5.8l-.8-.5c0-.2.1-.5.1-.8s0-.5-.1-.8l.8-.5c.1-.1.2-.2.1-.4l-.8-1.4c-.1-.1-.2-.2-.4-.1l-1 .3c-.3-.3-.7-.5-1.1-.6L6.1.2C6.1.1 6 0 5.8 0H4.2c-.2 0-.3.1-.3.2l-.2 1c-.4.1-.7.3-1.1.6l-1-.3c-.2 0-.3 0-.4.1l-.8 1.4c-.1.2 0 .3.1.4l.8.5c0 .2-.1.5-.1.8s0 .5.1.8l-.8.5c-.1.1-.2.2-.1.4l.8 1.4c.1.1.2.2.4.1l1-.3c.3.3.7.5 1.1.6l.2 1c0 .1.1.2.3.2h1.6c.2 0 .3-.1.3-.2l.2-1c.4-.1.7-.3 1.1-.6l1 .3c.2 0 .3 0 .4-.1l.8-1.4c.1-.2 0-.3-.1-.4zM5 6.5c-.8 0-1.5-.7-1.5-1.5S4.2 3.5 5 3.5 6.5 4.2 6.5 5 5.8 6.5 5 6.5z\"/></svg>",
2219
3889
  minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
2220
3890
  expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
2221
- }, h = document.createElement("div");
2222
- h.id = "simulator", h.dataset.puzzmoBuild = se, h.innerHTML = `
3891
+ }, _ = document.createElement("div");
3892
+ _.id = "simulator", _.dataset.puzzmoBuild = ae, _.innerHTML = `
2223
3893
  <style>
2224
3894
  :root {
2225
3895
  --sim-bg: #1a1a2e;
@@ -3395,6 +5065,128 @@ function Ft(n = {}) {
3395
5065
  color: var(--sim-text-dim);
3396
5066
  font-size: 9px;
3397
5067
  }
5068
+ /* Checklist view styles */
5069
+ .checklist-view-container {
5070
+ display: flex;
5071
+ flex-direction: column;
5072
+ gap: 10px;
5073
+ overflow-y: auto;
5074
+ }
5075
+ .checklist-header {
5076
+ display: flex;
5077
+ align-items: center;
5078
+ gap: 6px;
5079
+ padding-bottom: 4px;
5080
+ margin-bottom: 4px;
5081
+ border-bottom: 1px solid var(--sim-border);
5082
+ }
5083
+ .checklist-progress {
5084
+ flex: 1;
5085
+ color: var(--sim-text-dim);
5086
+ font-size: 10px;
5087
+ }
5088
+ .checklist-progress.complete {
5089
+ color: var(--sim-success);
5090
+ }
5091
+ .checklist-items {
5092
+ display: flex;
5093
+ flex-direction: column;
5094
+ gap: 1px;
5095
+ }
5096
+ .checklist-item {
5097
+ padding: 3px 6px;
5098
+ border-left: 3px solid transparent;
5099
+ }
5100
+ .checklist-item.done {
5101
+ opacity: 0.5;
5102
+ }
5103
+ .checklist-item.upcoming {
5104
+ opacity: 0.35;
5105
+ }
5106
+ .checklist-item.active {
5107
+ border-left-color: var(--sim-accent);
5108
+ background: var(--sim-bg);
5109
+ }
5110
+ .checklist-row {
5111
+ display: flex;
5112
+ align-items: center;
5113
+ gap: 6px;
5114
+ }
5115
+ .checklist-tick {
5116
+ color: var(--sim-text-dim);
5117
+ }
5118
+ .checklist-item.done .checklist-tick {
5119
+ color: var(--sim-success);
5120
+ }
5121
+ .checklist-title {
5122
+ flex: 1;
5123
+ color: var(--sim-text);
5124
+ }
5125
+ .checklist-item.active .checklist-title {
5126
+ color: var(--sim-accent);
5127
+ font-weight: bold;
5128
+ }
5129
+ .checklist-count {
5130
+ color: var(--sim-text-dim);
5131
+ font-size: 10px;
5132
+ }
5133
+ .checklist-help {
5134
+ width: 14px;
5135
+ height: 14px;
5136
+ padding: 0;
5137
+ border: 1px solid var(--sim-border-light);
5138
+ border-radius: 50%;
5139
+ background: transparent;
5140
+ color: var(--sim-text-dim);
5141
+ font: inherit;
5142
+ font-size: 9px;
5143
+ line-height: 12px;
5144
+ cursor: pointer;
5145
+ }
5146
+ .checklist-help:hover, .checklist-help.open {
5147
+ color: var(--sim-accent);
5148
+ border-color: var(--sim-accent);
5149
+ }
5150
+ .checklist-subtitle {
5151
+ margin: 2px 0 0 15px;
5152
+ color: var(--sim-text-dim);
5153
+ font-size: 10px;
5154
+ }
5155
+ .checklist-expand {
5156
+ margin: 4px 0 0 15px;
5157
+ padding: 4px 6px;
5158
+ background: var(--sim-panel);
5159
+ border: 1px solid var(--sim-border);
5160
+ border-radius: 2px;
5161
+ color: var(--sim-text);
5162
+ font: inherit;
5163
+ font-size: 10px;
5164
+ white-space: pre-wrap;
5165
+ text-align: left;
5166
+ user-select: text;
5167
+ }
5168
+ .checklist-divider {
5169
+ display: flex;
5170
+ align-items: center;
5171
+ gap: 6px;
5172
+ margin: 3px 0;
5173
+ color: var(--sim-text-dim);
5174
+ font-size: 9px;
5175
+ }
5176
+ .checklist-divider::before, .checklist-divider::after {
5177
+ content: "";
5178
+ flex: 1;
5179
+ border-top: 1px dashed var(--sim-border-light);
5180
+ }
5181
+ .checklist-footer {
5182
+ margin-top: 4px;
5183
+ color: var(--sim-text-dim);
5184
+ font-size: 9px;
5185
+ }
5186
+ .checklist-error {
5187
+ color: var(--sim-error);
5188
+ font-size: 9px;
5189
+ }
3398
5190
  /* Keyboard view styles */
3399
5191
  .keyboard-view-container {
3400
5192
  padding: 4px;
@@ -3537,15 +5329,15 @@ function Ft(n = {}) {
3537
5329
  border-top: 2px solid var(--sim-border);
3538
5330
  }
3539
5331
  </style>
3540
- <div id="simulator-panel" class="${p.isCollapsed ? "collapsed" : ""}">
5332
+ <div id="simulator-panel" class="${h.isCollapsed ? "collapsed" : ""}">
3541
5333
  <div id="simulator-header">
3542
5334
  <span id="simulator-title">PUZZMO SIMULATOR</span>
3543
5335
  <span class="header-sep">|</span>
3544
5336
  <div id="simulator-timer">--:--</div>
3545
5337
  <span class="header-sep">|</span>
3546
5338
  <div id="simulator-header-controls">
3547
- <button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${m.pause}</button>
3548
- <button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${m.retry}</button>
5339
+ <button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${g.pause}</button>
5340
+ <button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${g.retry}</button>
3549
5341
  </div>
3550
5342
  <span class="header-sep">|</span>
3551
5343
  <div id="simulator-header-status">
@@ -3553,108 +5345,108 @@ function Ft(n = {}) {
3553
5345
  <span id="simulator-header-status-text">Waiting...</span>
3554
5346
  </div>
3555
5347
  <span class="header-spacer"></span>
3556
- <button id="simulator-header-settings" class="header-icon-btn" title="Settings">${m.cog}</button>
3557
- <button id="simulator-toggle" class="header-icon-btn" title="Minimize">${m.minimize}</button>
5348
+ <button id="simulator-header-settings" class="header-icon-btn" title="Settings">${g.cog}</button>
5349
+ <button id="simulator-toggle" class="header-icon-btn" title="Minimize">${g.minimize}</button>
3558
5350
  </div>
3559
5351
  <div id="simulator-body">
3560
5352
  <div id="simulator-tabs">
3561
- ${d.filter((e) => e.id !== "auth").map((e) => `<button class="simulator-tab" data-tab="${e.id}">${e.label}<span class="simulator-tab-badge" data-badge="${e.id}"></span></button>`).join("")}
5353
+ ${p.filter((e) => e.id !== "auth").map((e) => `<button class="simulator-tab" data-tab="${e.id}">${e.label}<span class="simulator-tab-badge" data-badge="${e.id}"></span></button>`).join("")}
3562
5354
  </div>
3563
5355
  <div id="simulator-content" class="hidden">
3564
- ${d.map((e) => `<div id="simulator-tab-${e.id}" class="simulator-tab-content">${e.render()}</div>`).join("")}
5356
+ ${p.map((e) => `<div id="simulator-tab-${e.id}" class="simulator-tab-content">${e.render()}</div>`).join("")}
3565
5357
  </div>
3566
5358
  </div>
3567
5359
  </div>
3568
- `, document.body.appendChild(h);
3569
- let g = h.querySelector("#simulator-panel"), _ = h.querySelector("#simulator-header"), v = h.querySelector("#simulator-header-indicator"), y = h.querySelector("#simulator-header-status-text"), b = h.querySelector("#simulator-header-pause"), x = h.querySelector("#simulator-header-retry"), S = h.querySelector("#simulator-header-settings"), C = h.querySelector("#simulator-toggle"), w = h.querySelector("#simulator-timer"), T = h.querySelector("#simulator-tabs"), E = h.querySelector("#simulator-content"), D = (e) => h.querySelector(e), O = (e) => {
3570
- b.innerHTML = e ? m.play : m.pause, b.title = e ? "Resume" : "Pause";
3571
- }, k = (e, t) => {
3572
- let n = D("#simulator-status .text"), r = D("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
3573
- n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), v.className = t, v.textContent = i, y.textContent = e;
3574
- }, A = (e, t) => {
3575
- t && t !== "0" ? w.innerHTML = `${e}<span class="penalty">+${t}</span>` : w.textContent = e;
3576
- }, j = (e) => {
5360
+ `, document.body.appendChild(_);
5361
+ let v = _.querySelector("#simulator-panel"), y = _.querySelector("#simulator-header"), b = _.querySelector("#simulator-header-indicator"), x = _.querySelector("#simulator-header-status-text"), S = _.querySelector("#simulator-header-pause"), C = _.querySelector("#simulator-header-retry"), w = _.querySelector("#simulator-header-settings"), T = _.querySelector("#simulator-toggle"), E = _.querySelector("#simulator-timer"), D = _.querySelector("#simulator-tabs"), O = _.querySelector("#simulator-content"), k = (e) => _.querySelector(e), A = (e) => {
5362
+ S.innerHTML = e ? g.play : g.pause, S.title = e ? "Resume" : "Pause";
5363
+ }, j = (e, t) => {
5364
+ let n = k("#simulator-status .text"), r = k("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
5365
+ n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), b.className = t, b.textContent = i, x.textContent = e;
5366
+ }, P = (e, t) => {
5367
+ t && t !== "0" ? E.innerHTML = `${e}<span class="penalty">+${t}</span>` : E.textContent = e;
5368
+ }, F = (e) => {
3577
5369
  var t;
3578
- p.activeTab = e, E.classList.remove("hidden"), ne(e), T.querySelectorAll(".simulator-tab").forEach((t) => {
5370
+ h.activeTab = e, O.classList.remove("hidden"), ne(e), D.querySelectorAll(".simulator-tab").forEach((t) => {
3579
5371
  t.classList.toggle("active", t.getAttribute("data-tab") === e);
3580
- }), h.querySelectorAll(".simulator-tab-content").forEach((t) => {
5372
+ }), _.querySelectorAll(".simulator-tab-content").forEach((t) => {
3581
5373
  t.classList.toggle("active", t.id === `simulator-tab-${e}`);
3582
- }), S.classList.toggle("active", e === "auth");
3583
- let n = d.find((t) => t.id === e);
3584
- n == null || (t = n.onActivate) == null || t.call(n, R);
3585
- }, M = (e) => {
3586
- p.isCollapsed = e, g.classList.toggle("collapsed", e), te(e), e ? (E.classList.add("hidden"), T.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : j(p.activeTab);
3587
- }, N = () => {
3588
- u.updatePreview(R);
3589
- }, P = function() {
5374
+ }), w.classList.toggle("active", e === "auth");
5375
+ let n = p.find((t) => t.id === e);
5376
+ n == null || (t = n.onActivate) == null || t.call(n, H);
5377
+ }, I = (e) => {
5378
+ h.isCollapsed = e, v.classList.toggle("collapsed", e), te(e), e ? (O.classList.add("hidden"), D.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : F(h.activeTab);
5379
+ }, L = () => {
5380
+ f.updatePreview(H);
5381
+ }, R = function() {
3590
5382
  var e = t(function* () {
3591
5383
  var e, t;
3592
- if (p.appliedPuzzleOverride !== null) return p.appliedPuzzleOverride;
3593
- if (p.puzzleData) return p.puzzleData;
3594
- if (!s || s.size === 0) throw Error("No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.");
3595
- let n = (e = p.selectedCategory) == null ? c[0] : e, r = n ? s.get(n) : void 0;
5384
+ if (h.appliedPuzzleOverride !== null) return h.appliedPuzzleOverride;
5385
+ if (h.puzzleData) return h.puzzleData;
5386
+ if (!l || l.size === 0) throw Error("No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.");
5387
+ let n = (e = h.selectedCategory) == null ? u[0] : e, r = n ? l.get(n) : void 0;
3596
5388
  if (!r || r.size === 0) throw Error(`No puzzles found in fixture category "${n}"`);
3597
- let i = (t = p.selectedPuzzle) == null ? r.keys().next().value : t, a = i ? r.get(i) : void 0;
5389
+ let i = (t = h.selectedPuzzle) == null ? r.keys().next().value : t, a = i ? r.get(i) : void 0;
3598
5390
  if (!a) throw Error(`Puzzle "${i}" not found in category "${n}"`);
3599
- p.puzzleData = a, console.log("Simulator: Puzzle loaded from fixtures", {
5391
+ h.puzzleData = a, console.log("Simulator: Puzzle loaded from fixtures", {
3600
5392
  category: n,
3601
5393
  puzzle: i
3602
- }), p.originalPuzzle = a;
3603
- let o = D("#simulator-puzzle");
3604
- return o && (o.value = p.originalPuzzle), p.activeTab === "thumb" && N(), p.puzzleData;
5394
+ }), h.originalPuzzle = a;
5395
+ let o = k("#simulator-puzzle");
5396
+ return o && (o.value = h.originalPuzzle), h.activeTab === "thumb" && L(), h.puzzleData;
3605
5397
  });
3606
5398
  return function() {
3607
5399
  return e.apply(this, arguments);
3608
5400
  };
3609
- }(), F = re((e) => {
3610
- l.addLogEntry(e, R);
3611
- }), I = (e, t) => {
3612
- ie(e, t, F);
3613
- }, L = (e, t) => {
3614
- let n = h.querySelector(`[data-badge="${e}"]`);
5401
+ }(), z = re((e) => {
5402
+ d.addLogEntry(e, H);
5403
+ }), B = (e, t) => {
5404
+ M(e, t, z);
5405
+ }, V = (e, t) => {
5406
+ let n = _.querySelector(`[data-badge="${e}"]`);
3615
5407
  n && (n.textContent = t && t > 0 ? String(t) : "");
3616
- }, R = {
3617
- state: p,
3618
- getElement: D,
3619
- sendToGame: I,
3620
- logMessage: F.log,
3621
- loadPuzzle: P,
3622
- updateStatus: k,
3623
- updateTimer: A,
3624
- setCollapsed: M,
3625
- switchTab: j,
3626
- updateThumbnail: N,
3627
- updateBadge: L,
3628
- fixtures: s,
3629
- fixtureCategories: c,
3630
- gameSlug: (a = n.slug) == null ? null : a
5408
+ }, H = {
5409
+ state: h,
5410
+ getElement: k,
5411
+ sendToGame: B,
5412
+ logMessage: z.log,
5413
+ loadPuzzle: R,
5414
+ updateStatus: j,
5415
+ updateTimer: P,
5416
+ setCollapsed: I,
5417
+ switchTab: F,
5418
+ updateThumbnail: L,
5419
+ updateBadge: V,
5420
+ fixtures: l,
5421
+ fixtureCategories: u,
5422
+ gameSlug: (s = n.slug) == null ? null : s
3631
5423
  };
3632
- console.log("[Simulator] Context created with gameSlug:", R.gameSlug), d.forEach((e) => e.bind(R)), T.querySelectorAll(".simulator-tab").forEach((e) => {
5424
+ console.log("[Simulator] Context created with gameSlug:", H.gameSlug), p.forEach((e) => e.bind(H)), D.querySelectorAll(".simulator-tab").forEach((e) => {
3633
5425
  e.addEventListener("click", () => {
3634
5426
  let t = e.getAttribute("data-tab");
3635
- j(t), L(t, 0);
5427
+ F(t), V(t, 0);
3636
5428
  });
5429
+ }), T.addEventListener("click", (e) => {
5430
+ e.stopPropagation(), I(!0);
5431
+ }), S.addEventListener("click", (e) => {
5432
+ e.stopPropagation(), h.isPaused ? (B("RESUME_GAME", {}), h.isPaused = !1, A(!1), j("Running", "ready")) : (B("PAUSE_GAME", {}), h.isPaused = !0, A(!0), j("Paused", "paused"));
5433
+ let t = k("#simulator-pause");
5434
+ t && (t.textContent = h.isPaused ? "Resume" : "Pause");
3637
5435
  }), C.addEventListener("click", (e) => {
3638
- e.stopPropagation(), M(!0);
3639
- }), b.addEventListener("click", (e) => {
3640
- e.stopPropagation(), p.isPaused ? (I("RESUME_GAME", {}), p.isPaused = !1, O(!1), k("Running", "ready")) : (I("PAUSE_GAME", {}), p.isPaused = !0, O(!0), k("Paused", "paused"));
3641
- let t = D("#simulator-pause");
3642
- t && (t.textContent = p.isPaused ? "Resume" : "Pause");
3643
- }), x.addEventListener("click", (e) => {
3644
- e.stopPropagation(), I("RETRY_PUZZLE", {}), p.hasStarted = !1, p.isPaused = !1, O(!1), b.disabled = !0, k("Ready to retry", "ready");
3645
- let t = D("#simulator-pause"), n = D("#simulator-start");
5436
+ e.stopPropagation(), B("RETRY_PUZZLE", {}), h.hasStarted = !1, h.isPaused = !1, A(!1), S.disabled = !0, j("Ready to retry", "ready");
5437
+ let t = k("#simulator-pause"), n = k("#simulator-start");
3646
5438
  t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
3647
- }), S.addEventListener("click", (e) => {
3648
- e.stopPropagation(), p.isCollapsed && M(!1), j("auth");
3649
- }), _.addEventListener("click", (e) => {
3650
- p.isCollapsed && e.target !== C && M(!1);
3651
- }), p.isCollapsed || j(p.activeTab);
3652
- let z = new URLSearchParams(window.location.search);
3653
- (z.has("code") || z.has("error")) && (M(!1), j("auth"));
3654
- let B = (e) => {
5439
+ }), w.addEventListener("click", (e) => {
5440
+ e.stopPropagation(), h.isCollapsed && I(!1), F("auth");
5441
+ }), y.addEventListener("click", (e) => {
5442
+ h.isCollapsed && e.target !== T && I(!1);
5443
+ }), h.isCollapsed || F(h.activeTab);
5444
+ let U = new URLSearchParams(window.location.search);
5445
+ (U.has("code") || U.has("error")) && (I(!1), F("auth"));
5446
+ let ce = (e) => {
3655
5447
  let t = {
3656
5448
  additionalTimeAddedSecs: 0,
3657
- boardState: p.currentInputStr,
5449
+ boardState: h.currentInputStr,
3658
5450
  combinedTimeSecs: 0,
3659
5451
  completed: !1,
3660
5452
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3672,7 +5464,7 @@ function Ft(n = {}) {
3672
5464
  };
3673
5465
  return {
3674
5466
  userState: {
3675
- gameSettings: { "proto-game": p.gameSettings },
5467
+ gameSettings: { "proto-game": h.gameSettings },
3676
5468
  id: "simulator-user",
3677
5469
  ownerID: "simulator-owner"
3678
5470
  },
@@ -3684,51 +5476,51 @@ function Ft(n = {}) {
3684
5476
  type: "User",
3685
5477
  roles: ""
3686
5478
  },
3687
- game: It,
5479
+ game: Kt,
3688
5480
  session: {
3689
5481
  gameplay: t,
3690
5482
  puzzle: n
3691
5483
  },
3692
- theme: p.selectedTheme,
3693
- hostContext: p.hostContext,
5484
+ theme: h.selectedTheme,
5485
+ hostContext: h.hostContext,
3694
5486
  appRuntimeContract: "1.0"
3695
5487
  };
3696
- }, V = function() {
5488
+ }, W = function() {
3697
5489
  var n = t(function* (t) {
3698
- k("Loading puzzle...", "waiting");
5490
+ j("Loading puzzle...", "waiting");
3699
5491
  try {
3700
- let n = e(e({}, B(yield P())), {}, { appRuntimeContract: t });
3701
- k("Sending READY_DATA...", "waiting"), I("READY_DATA", n), k("Waiting for game to load...", "waiting");
5492
+ let n = e(e({}, ce(yield R())), {}, { appRuntimeContract: t });
5493
+ j("Sending READY_DATA...", "waiting"), B("READY_DATA", n), j("Waiting for game to load...", "waiting");
3702
5494
  } catch (e) {
3703
- k(`Error: ${e}`, "paused");
5495
+ j(`Error: ${e}`, "paused");
3704
5496
  }
3705
5497
  });
3706
5498
  return function(e) {
3707
5499
  return n.apply(this, arguments);
3708
5500
  };
3709
- }(), H = () => {
3710
- console.log("Simulator: Game loaded, ready to start"), x.disabled = !1, d.forEach((e) => {
5501
+ }(), G = () => {
5502
+ console.log("Simulator: Game loaded, ready to start"), C.disabled = !1, p.forEach((e) => {
3711
5503
  var t;
3712
- return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, R);
3713
- }), o && !p.hasStarted && setTimeout(() => {
3714
- let e = D("#simulator-start");
3715
- e == null || e.click(), b.disabled = !1, p.hasStarted = !0, k("Running", "ready");
5504
+ return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, H);
5505
+ }), c && !h.hasStarted && setTimeout(() => {
5506
+ let e = k("#simulator-start");
5507
+ e == null || e.click(), S.disabled = !1, h.hasStarted = !0, j("Running", "ready");
3716
5508
  }, 100);
3717
5509
  };
3718
- return ae((e, t) => {
5510
+ return N((e, t) => {
3719
5511
  var n, r;
3720
5512
  if (e === "READY") {
3721
- console.log("Simulator: Received READY from game"), V((t == null ? void 0 : t.runtimeContract) === "1.1" ? "1.1" : "1.0");
5513
+ console.log("Simulator: Received READY from game"), W((t == null ? void 0 : t.runtimeContract) === "1.1" ? "1.1" : "1.0");
3722
5514
  return;
3723
5515
  }
3724
5516
  if (e === "READY_GAME_LOADED") {
3725
- H();
5517
+ G();
3726
5518
  return;
3727
5519
  }
3728
5520
  if (e === "TIMER_TICK") {
3729
5521
  if (t != null && t.display) {
3730
5522
  let [e, n] = t.display;
3731
- A(e, n);
5523
+ P(e, n);
3732
5524
  }
3733
5525
  return;
3734
5526
  }
@@ -3737,32 +5529,32 @@ function Ft(n = {}) {
3737
5529
  console.log("Simulator: Sidebar update", t);
3738
5530
  return;
3739
5531
  }
3740
- d.forEach((n) => {
5532
+ p.forEach((n) => {
3741
5533
  var r;
3742
- return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, R);
5534
+ return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, H);
3743
5535
  });
3744
5536
  let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
3745
- e === "UPLOAD_NEW_GAME_STATE" && i && (p.currentInputStr = i, p.activeTab === "thumb" && N(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), b.disabled = !0, p.hasStarted = !1, k("Completed!", "complete"));
3746
- }, F), console.log("Simulator initialized"), $ = {
5537
+ e === "UPLOAD_NEW_GAME_STATE" && i && (h.currentInputStr = i, h.activeTab === "thumb" && L(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), S.disabled = !0, h.hasStarted = !1, j("Completed!", "complete"));
5538
+ }, z), console.log("Simulator initialized"), $ = {
3747
5539
  updateFixtures: (e) => {
3748
- s = oe(e), c = Array.from(s.keys()).sort(), R.fixtures = s, R.fixtureCategories = c;
5540
+ l = ie(e), u = Array.from(l.keys()).sort(), H.fixtures = l, H.fixtureCategories = u;
3749
5541
  let t = localStorage.getItem("simulator-fixture-category");
3750
- if (!p.selectedCategory || !c.includes(p.selectedCategory)) {
5542
+ if (!h.selectedCategory || !u.includes(h.selectedCategory)) {
3751
5543
  var n;
3752
- p.selectedCategory = t && c.includes(t) ? t : (n = c[0]) == null ? null : n;
5544
+ h.selectedCategory = t && u.includes(t) ? t : (n = u[0]) == null ? null : n;
3753
5545
  }
3754
- let r = d.find((e) => e.id === "ctrl");
3755
- r == null || r.bind(R), console.log("Simulator: Fixtures updated", {
3756
- categories: c,
3757
- selectedCategory: p.selectedCategory
5546
+ let r = p.find((e) => e.id === "ctrl");
5547
+ r == null || r.bind(H), console.log("Simulator: Fixtures updated", {
5548
+ categories: u,
5549
+ selectedCategory: h.selectedCategory
3758
5550
  });
3759
5551
  },
3760
- sendToGame: I,
3761
- loadPuzzle: P
5552
+ sendToGame: B,
5553
+ loadPuzzle: R
3762
5554
  }, $;
3763
5555
  }
3764
5556
  /** The game the simulator stands in for, with placeholder IDs since nothing is stored */
3765
- var It = {
5557
+ var Kt = {
3766
5558
  id: "simulator-game",
3767
5559
  slug: "proto-game",
3768
5560
  stableSlug: "proto-game",
@@ -3778,6 +5570,6 @@ var It = {
3778
5570
  }
3779
5571
  }
3780
5572
  };
3781
- export { At as n, se as r, Ft as t };
5573
+ export { Bt as n, ae as r, Gt as t };
3782
5574
 
3783
- //# sourceMappingURL=createSimulator-CdInpCHG.js.map
5575
+ //# sourceMappingURL=createSimulator-DUZOd1Hx.js.map