@puzzmo/sdk 1.0.81 → 1.0.83

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 (150) hide show
  1. package/dist/analytics.d.ts.map +1 -1
  2. package/dist/bootstrapPayload.d.ts.map +1 -1
  3. package/dist/bootstrapPayload.spec.d.ts.map +1 -1
  4. package/dist/bundleChecks.d.ts +48 -0
  5. package/dist/bundleChecks.d.ts.map +1 -0
  6. package/dist/bundles.cjs +1 -1
  7. package/dist/bundles.cjs.map +1 -1
  8. package/dist/bundles.d.ts +10 -2
  9. package/dist/bundles.d.ts.map +1 -1
  10. package/dist/bundles.js +2 -2
  11. package/dist/bundles.js.map +1 -1
  12. package/dist/contracts.d.ts.map +1 -1
  13. package/dist/createSimulator-CIE72Xs2.cjs +2233 -0
  14. package/dist/createSimulator-CIE72Xs2.cjs.map +1 -0
  15. package/dist/{createSimulator-2M7vXzRZ.js → createSimulator-Dz1KYZ25.js} +1579 -596
  16. package/dist/createSimulator-Dz1KYZ25.js.map +1 -0
  17. package/dist/easing.d.ts +6 -0
  18. package/dist/easing.d.ts.map +1 -0
  19. package/dist/editor.d.ts +25 -3
  20. package/dist/editor.d.ts.map +1 -1
  21. package/dist/fontFiles.gen.d.ts.map +1 -1
  22. package/dist/fonts-CP_kAAac.js +83 -0
  23. package/dist/fonts-CP_kAAac.js.map +1 -0
  24. package/dist/fonts-CS5qdLf3.cjs +3 -0
  25. package/dist/fonts-CS5qdLf3.cjs.map +1 -0
  26. package/dist/fonts.cjs +1 -3
  27. package/dist/fonts.d.ts +2 -0
  28. package/dist/fonts.d.ts.map +1 -1
  29. package/dist/fonts.js +2 -83
  30. package/dist/gameTracker.d.ts.map +1 -1
  31. package/dist/global.d.ts.map +1 -1
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.ts +2 -2
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.global.js.map +1 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/inputs/decoder.d.ts.map +1 -1
  38. package/dist/inputs/encoder.d.ts.map +1 -1
  39. package/dist/inputs/encodings.d.ts.map +1 -1
  40. package/dist/inputs/index.d.ts.map +1 -1
  41. package/dist/inputs/inputStringEncoder.spec.d.ts.map +1 -1
  42. package/dist/inputs/migration.d.ts.map +1 -1
  43. package/dist/inputs/types.d.ts.map +1 -1
  44. package/dist/keyboard.d.ts.map +1 -1
  45. package/dist/keyboard.spec.d.ts.map +1 -1
  46. package/dist/{lua-DKb2Tu2V.js → lua-B8exrfmB.js} +1 -1
  47. package/dist/{lua-DKb2Tu2V.js.map → lua-B8exrfmB.js.map} +1 -1
  48. package/dist/{lua-CclI-QKD.cjs → lua-C5r7UXeR.cjs} +1 -1
  49. package/dist/{lua-CclI-QKD.cjs.map → lua-C5r7UXeR.cjs.map} +1 -1
  50. package/dist/pico8/channel.d.ts.map +1 -1
  51. package/dist/pico8/index.cjs +1 -1
  52. package/dist/pico8/index.d.ts.map +1 -1
  53. package/dist/pico8/index.js +1 -1
  54. package/dist/pico8/lua.d.ts.map +1 -1
  55. package/dist/pico8/palette.d.ts.map +1 -1
  56. package/dist/pico8/pico8.spec.d.ts.map +1 -1
  57. package/dist/pico8/protocol.d.ts.map +1 -1
  58. package/dist/pico8/vitePlugin.d.ts.map +1 -1
  59. package/dist/plugins.d.ts.map +1 -1
  60. package/dist/plugins.spec.d.ts.map +1 -1
  61. package/dist/sdk.d.ts.map +1 -1
  62. package/dist/sdk.gameCompleted.spec.d.ts.map +1 -1
  63. package/dist/sdk.gameReady.spec.d.ts.map +1 -1
  64. package/dist/sdk.pause.spec.d.ts.map +1 -1
  65. package/dist/sdk.session.spec.d.ts.map +1 -1
  66. package/dist/settings.spec.d.ts.map +1 -1
  67. package/dist/simulator/checklistProgress.d.ts.map +1 -1
  68. package/dist/simulator/checklistProgress.spec.d.ts.map +1 -1
  69. package/dist/simulator/createSimulator.d.ts.map +1 -1
  70. package/dist/simulator/dockedKeyboard.d.ts.map +1 -1
  71. package/dist/simulator/fixtures.d.ts.map +1 -1
  72. package/dist/simulator/index.cjs +1 -1
  73. package/dist/simulator/index.d.ts.map +1 -1
  74. package/dist/simulator/index.js +2 -1
  75. package/dist/simulator/marker.d.ts.map +1 -1
  76. package/dist/simulator/messaging.d.ts.map +1 -1
  77. package/dist/simulator/normalizeThumbnail.d.ts.map +1 -1
  78. package/dist/simulator/pmmgOverlay.d.ts +36 -0
  79. package/dist/simulator/pmmgOverlay.d.ts.map +1 -0
  80. package/dist/simulator/pmmgOverlay.spec.d.ts +2 -0
  81. package/dist/simulator/pmmgOverlay.spec.d.ts.map +1 -0
  82. package/dist/simulator/pmmgRenderer.d.ts +86 -0
  83. package/dist/simulator/pmmgRenderer.d.ts.map +1 -0
  84. package/dist/simulator/pmmgRenderer.spec.d.ts +2 -0
  85. package/dist/simulator/pmmgRenderer.spec.d.ts.map +1 -0
  86. package/dist/simulator/standalone.cjs +1 -1
  87. package/dist/simulator/standalone.cjs.map +1 -1
  88. package/dist/simulator/standalone.d.ts.map +1 -1
  89. package/dist/simulator/standalone.js +2 -1
  90. package/dist/simulator/standalone.js.map +1 -1
  91. package/dist/simulator/state.d.ts +19 -0
  92. package/dist/simulator/state.d.ts.map +1 -1
  93. package/dist/simulator/state.spec.d.ts.map +1 -1
  94. package/dist/simulator/styles.d.ts +1 -1
  95. package/dist/simulator/styles.d.ts.map +1 -1
  96. package/dist/simulator/types.d.ts +5 -0
  97. package/dist/simulator/types.d.ts.map +1 -1
  98. package/dist/simulator/views/AuthView.d.ts.map +1 -1
  99. package/dist/simulator/views/ChecklistView.d.ts.map +1 -1
  100. package/dist/simulator/views/CheckpointsView.d.ts.map +1 -1
  101. package/dist/simulator/views/CtrlView.d.ts.map +1 -1
  102. package/dist/simulator/views/DataView.d.ts.map +1 -1
  103. package/dist/simulator/views/DoneView.d.ts.map +1 -1
  104. package/dist/simulator/views/FeaturesView.d.ts.map +1 -1
  105. package/dist/simulator/views/HostView.d.ts.map +1 -1
  106. package/dist/simulator/views/KeyboardView.d.ts.map +1 -1
  107. package/dist/simulator/views/MsgsView.d.ts.map +1 -1
  108. package/dist/simulator/views/PmmgView.d.ts +7 -0
  109. package/dist/simulator/views/PmmgView.d.ts.map +1 -0
  110. package/dist/simulator/views/SettingsView.d.ts.map +1 -1
  111. package/dist/simulator/views/SoundView.d.ts.map +1 -1
  112. package/dist/simulator/views/ThemeView.d.ts.map +1 -1
  113. package/dist/simulator/views/ThumbView.d.ts.map +1 -1
  114. package/dist/simulator/views/index.d.ts +1 -0
  115. package/dist/simulator/views/index.d.ts.map +1 -1
  116. package/dist/svgJSX.d.ts.map +1 -1
  117. package/dist/tableBoard-B0I9wVQq.js +635 -0
  118. package/dist/tableBoard-B0I9wVQq.js.map +1 -0
  119. package/dist/tableBoard-CLDBwRYs.cjs +2 -0
  120. package/dist/tableBoard-CLDBwRYs.cjs.map +1 -0
  121. package/dist/tableBoard.cjs +1 -0
  122. package/dist/tableBoard.d.ts +138 -0
  123. package/dist/tableBoard.d.ts.map +1 -0
  124. package/dist/tableBoard.js +2 -0
  125. package/dist/tableBoardScene.d.ts +21 -0
  126. package/dist/tableBoardScene.d.ts.map +1 -0
  127. package/dist/themes.d.ts +16 -16
  128. package/dist/themes.d.ts.map +1 -1
  129. package/dist/types.d.ts +161 -0
  130. package/dist/types.d.ts.map +1 -1
  131. package/dist/vite.cjs +9 -5
  132. package/dist/vite.cjs.map +1 -1
  133. package/dist/vite.d.ts +20 -0
  134. package/dist/vite.d.ts.map +1 -1
  135. package/dist/vite.js +249 -72
  136. package/dist/vite.js.map +1 -1
  137. package/package.json +5 -5
  138. package/dist/createSimulator-2M7vXzRZ.js.map +0 -1
  139. package/dist/createSimulator-B4QlohUV.cjs +0 -1930
  140. package/dist/createSimulator-B4QlohUV.cjs.map +0 -1
  141. package/dist/fonts.cjs.map +0 -1
  142. package/dist/fonts.js.map +0 -1
  143. package/dist/thumbnailMotion.cjs +0 -5
  144. package/dist/thumbnailMotion.cjs.map +0 -1
  145. package/dist/thumbnailMotion.d.ts +0 -119
  146. package/dist/thumbnailMotion.d.ts.map +0 -1
  147. package/dist/thumbnailMotion.js +0 -480
  148. package/dist/thumbnailMotion.js.map +0 -1
  149. package/dist/thumbnailMotion.spec.d.ts +0 -2
  150. package/dist/thumbnailMotion.spec.d.ts.map +0 -1
@@ -1,8 +1,9 @@
1
1
  import { t as e } from "./objectSpread2-BJrS9rM5.js";
2
2
  import { t } from "./asyncToGenerator-DSd3oTwb.js";
3
- import { createThumbnailMorpher as n } from "./thumbnailMotion.js";
4
- var r = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
5
- const i = [
3
+ import { a as n, i as r, t as i } from "./tableBoard-B0I9wVQq.js";
4
+ import { i as a, r as o } from "./fonts-CP_kAAac.js";
5
+ var s = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
6
+ const c = [
6
7
  {
7
8
  name: "Puzzmo (light)",
8
9
  type: "light",
@@ -308,7 +309,7 @@ const i = [
308
309
  a_infoBG: "#001900"
309
310
  }
310
311
  ];
311
- var a = {
312
+ var l = {
312
313
  collapsed: "simulator-collapsed",
313
314
  tab: "simulator-tab",
314
315
  theme: "simulator-theme",
@@ -319,43 +320,44 @@ var a = {
319
320
  previewKind: "simulator-preview-kind",
320
321
  gameSettings: "simulator-game-settings",
321
322
  hostContext: "simulator-host-context",
322
- keyboardDocked: "simulator-keyboard-docked"
323
- }, o = "simulator-override:";
323
+ keyboardDocked: "simulator-keyboard-docked",
324
+ pmmg: "simulator-pmmg"
325
+ }, u = "simulator-override:";
324
326
  /**
325
327
  * Overrides are scoped to the page that applied them. localStorage is per-origin but a dev server
326
328
  * commonly hosts many games from one origin (each at its own /games/<name>/ path), and an input
327
329
  * string is only meaningful to the game it came from.
328
330
  */
329
- function s(e) {
330
- return `${o}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
331
+ function d(e) {
332
+ return `${u}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
331
333
  }
332
334
  /** The applied override for this page, or null when nothing has been applied. "" is a real value. */
333
- function c(e) {
335
+ function f(e) {
334
336
  try {
335
- return localStorage.getItem(s(e));
337
+ return localStorage.getItem(d(e));
336
338
  } catch (e) {
337
339
  return null;
338
340
  }
339
341
  }
340
342
  /** False when the write failed — private-mode storage, or a board state over the origin's quota. */
341
- function l(e, t) {
343
+ function p(e, t) {
342
344
  try {
343
- return localStorage.setItem(s(e), t), !0;
345
+ return localStorage.setItem(d(e), t), !0;
344
346
  } catch (e) {
345
347
  return !1;
346
348
  }
347
349
  }
348
- function u(e) {
350
+ function m(e) {
349
351
  try {
350
- localStorage.removeItem(s(e));
352
+ localStorage.removeItem(d(e));
351
353
  } catch (e) {}
352
354
  }
353
- function d() {
354
- u("puzzle"), u("input");
355
+ function h() {
356
+ m("puzzle"), m("input");
355
357
  }
356
358
  /** The Host tab's persisted `hostContext` override, or null when the tab hasn't set one. */
357
- function f() {
358
- let e = localStorage.getItem(a.hostContext);
359
+ function g() {
360
+ let e = localStorage.getItem(l.hostContext);
359
361
  if (!e) return null;
360
362
  try {
361
363
  let t = JSON.parse(e);
@@ -363,21 +365,66 @@ function f() {
363
365
  } catch (e) {}
364
366
  return null;
365
367
  }
366
- function p(e) {
367
- localStorage.setItem(a.hostContext, JSON.stringify(e));
368
+ function _(e) {
369
+ localStorage.setItem(l.hostContext, JSON.stringify(e));
368
370
  }
369
- function m() {
370
- localStorage.removeItem(a.hostContext);
371
+ function v() {
372
+ localStorage.removeItem(l.hostContext);
371
373
  }
372
374
  /** The Kbd tab's "show keyboard under game" checkbox. Off until asked for: it takes space from the game. */
373
- function h() {
374
- return localStorage.getItem(a.keyboardDocked) === "true";
375
+ function y() {
376
+ return localStorage.getItem(l.keyboardDocked) === "true";
377
+ }
378
+ function b(e) {
379
+ localStorage.setItem(l.keyboardDocked, String(e));
380
+ }
381
+ var x = {
382
+ subtab: "layout",
383
+ follow: !0,
384
+ bounds: !0,
385
+ grid: !1,
386
+ boxes: !1,
387
+ anchors: !1,
388
+ keys: !1,
389
+ backdrop: "checker",
390
+ fidelity: "high",
391
+ backgroundStyle: "theme"
392
+ };
393
+ function S() {
394
+ let t = e({}, x);
395
+ try {
396
+ var n;
397
+ let e = JSON.parse((n = localStorage.getItem(l.pmmg)) == null ? "{}" : n);
398
+ [
399
+ "layout",
400
+ "sprites",
401
+ "scene"
402
+ ].includes(e.subtab) && (t.subtab = e.subtab), [
403
+ "checker",
404
+ "theme",
405
+ "black",
406
+ "white"
407
+ ].includes(e.backdrop) && (t.backdrop = e.backdrop), ["high", "low"].includes(e.fidelity) && (t.fidelity = e.fidelity), [
408
+ "theme",
409
+ "dark",
410
+ "light"
411
+ ].includes(e.backgroundStyle) && (t.backgroundStyle = e.backgroundStyle);
412
+ for (let n of [
413
+ "follow",
414
+ "bounds",
415
+ "grid",
416
+ "boxes",
417
+ "anchors",
418
+ "keys"
419
+ ]) typeof e[n] == "boolean" && (t[n] = e[n]);
420
+ } catch (e) {}
421
+ return t;
375
422
  }
376
- function g(e) {
377
- localStorage.setItem(a.keyboardDocked, String(e));
423
+ function C(e) {
424
+ localStorage.setItem(l.pmmg, JSON.stringify(e));
378
425
  }
379
- function _() {
380
- let e = localStorage.getItem(a.gameSettings);
426
+ function w() {
427
+ let e = localStorage.getItem(l.gameSettings);
381
428
  if (!e) return {};
382
429
  try {
383
430
  let t = JSON.parse(e);
@@ -385,36 +432,36 @@ function _() {
385
432
  } catch (e) {}
386
433
  return {};
387
434
  }
388
- function v() {
389
- let e = localStorage.getItem(a.theme);
435
+ function T() {
436
+ let e = localStorage.getItem(l.theme);
390
437
  if (e) {
391
- let t = i.find((t) => t.name === e);
438
+ let t = c.find((t) => t.name === e);
392
439
  if (t) return t;
393
440
  }
394
- return i[0];
441
+ return c[0];
395
442
  }
396
- function y(e) {
443
+ function E(e) {
397
444
  var t;
398
- let n = localStorage.getItem(a.tab);
445
+ let n = localStorage.getItem(l.tab);
399
446
  return n && e.includes(n) ? n : (t = e[0]) == null ? "ctrl" : t;
400
447
  }
401
- function b(e) {
402
- let t = localStorage.getItem(a.collapsed);
448
+ function D(e) {
449
+ let t = localStorage.getItem(l.collapsed);
403
450
  return t === null ? e : t === "true";
404
451
  }
405
- function x() {
406
- let e = localStorage.getItem(a.renderHost);
452
+ function O() {
453
+ let e = localStorage.getItem(l.renderHost);
407
454
  return e && [
408
455
  "game",
409
456
  "app",
410
457
  "opengraph"
411
458
  ].includes(e) ? e : "game";
412
459
  }
413
- function S() {
414
- return localStorage.getItem(a.previewKind) === "text" ? "text" : "image";
460
+ function k() {
461
+ return localStorage.getItem(l.previewKind) === "text" ? "text" : "image";
415
462
  }
416
- function C() {
417
- let e = localStorage.getItem(a.renderContext);
463
+ function A() {
464
+ let e = localStorage.getItem(l.renderContext);
418
465
  if (e && [
419
466
  "preview",
420
467
  "share",
@@ -422,72 +469,72 @@ function C() {
422
469
  "timeline"
423
470
  ].includes(e)) return e;
424
471
  }
425
- function ee(e, t, n) {
426
- var r, i, o;
427
- let s = localStorage.getItem(a.fixtureCategory), l = localStorage.getItem(a.fixturePuzzle), u = f(), d = c("puzzle"), p = c("input");
472
+ function j(e, t, n) {
473
+ var r, i, a;
474
+ let o = localStorage.getItem(l.fixtureCategory), s = localStorage.getItem(l.fixturePuzzle), c = g(), u = f("puzzle"), d = f("input");
428
475
  return {
429
- hostContext: (r = u == null ? e.hostContext : u) == null ? [{
476
+ hostContext: (r = c == null ? e.hostContext : c) == null ? [{
430
477
  type: "app",
431
478
  layout: "desktop",
432
479
  host: null
433
480
  }] : r,
434
- hostContextIsOverridden: u !== null,
435
- isCollapsed: b((i = e.collapsed) == null ? !0 : i),
481
+ hostContextIsOverridden: c !== null,
482
+ isCollapsed: D((i = e.collapsed) == null ? !0 : i),
436
483
  isPaused: !1,
437
484
  hasStarted: !1,
438
- activeTab: y(n),
439
- puzzleData: d,
440
- originalPuzzle: d == null ? "" : d,
441
- currentInputStr: p == null ? "" : p,
485
+ activeTab: E(n),
486
+ puzzleData: u,
487
+ originalPuzzle: u == null ? "" : u,
488
+ currentInputStr: d == null ? "" : d,
442
489
  userStorage: null,
443
- appliedPuzzleOverride: d,
444
- appliedInputOverride: p,
490
+ appliedPuzzleOverride: u,
491
+ appliedInputOverride: d,
445
492
  completionData: null,
446
- selectedTheme: v(),
447
- selectedCategory: s && t.includes(s) ? s : (o = t[0]) == null ? null : o,
448
- selectedPuzzle: l == null ? null : l,
449
- renderHost: x(),
450
- renderContext: C(),
451
- previewKind: S(),
452
- gameSettings: _(),
453
- keyboardDocked: h(),
493
+ selectedTheme: T(),
494
+ selectedCategory: o && t.includes(o) ? o : (a = t[0]) == null ? null : a,
495
+ selectedPuzzle: s == null ? null : s,
496
+ renderHost: O(),
497
+ renderContext: A(),
498
+ previewKind: k(),
499
+ gameSettings: w(),
500
+ keyboardDocked: y(),
454
501
  settingsComponents: null
455
502
  };
456
503
  }
457
- function w(e) {
458
- localStorage.setItem(a.gameSettings, JSON.stringify(e));
504
+ function M(e) {
505
+ localStorage.setItem(l.gameSettings, JSON.stringify(e));
459
506
  }
460
- function T() {
461
- localStorage.removeItem(a.gameSettings);
507
+ function N() {
508
+ localStorage.removeItem(l.gameSettings);
462
509
  }
463
- function te(e) {
464
- localStorage.setItem(a.collapsed, String(e));
510
+ function P(e) {
511
+ localStorage.setItem(l.collapsed, String(e));
465
512
  }
466
- function ne(e) {
467
- localStorage.setItem(a.tab, e);
513
+ function ee(e) {
514
+ localStorage.setItem(l.tab, e);
468
515
  }
469
- function E(e) {
470
- localStorage.setItem(a.theme, e);
516
+ function F(e) {
517
+ localStorage.setItem(l.theme, e);
471
518
  }
472
- function D(e) {
473
- localStorage.setItem(a.fixtureCategory, e);
519
+ function I(e) {
520
+ localStorage.setItem(l.fixtureCategory, e);
474
521
  }
475
- function O(e) {
476
- localStorage.setItem(a.fixturePuzzle, e);
522
+ function L(e) {
523
+ localStorage.setItem(l.fixturePuzzle, e);
477
524
  }
478
- function k() {
479
- localStorage.removeItem(a.fixturePuzzle);
525
+ function R() {
526
+ localStorage.removeItem(l.fixturePuzzle);
480
527
  }
481
- function A(e) {
482
- e ? localStorage.setItem(a.renderHost, e) : localStorage.removeItem(a.renderHost);
528
+ function z(e) {
529
+ e ? localStorage.setItem(l.renderHost, e) : localStorage.removeItem(l.renderHost);
483
530
  }
484
- function j(e) {
485
- localStorage.setItem(a.previewKind, e);
531
+ function B(e) {
532
+ localStorage.setItem(l.previewKind, e);
486
533
  }
487
- function M(e) {
488
- e ? localStorage.setItem(a.renderContext, e) : localStorage.removeItem(a.renderContext);
534
+ function V(e) {
535
+ e ? localStorage.setItem(l.renderContext, e) : localStorage.removeItem(l.renderContext);
489
536
  }
490
- function N(e) {
537
+ function te(e) {
491
538
  let t = [];
492
539
  return {
493
540
  log(n, r, i) {
@@ -512,7 +559,7 @@ function N(e) {
512
559
  }
513
560
  };
514
561
  }
515
- function P(e, t, n) {
562
+ function ne(e, t, n) {
516
563
  console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
517
564
  type: e,
518
565
  data: t
@@ -528,7 +575,7 @@ function re(e, t) {
528
575
  return window.addEventListener("message", n), () => window.removeEventListener("message", n);
529
576
  }
530
577
  /** Parse fixture imports into a structured format: { category: { filename: data } } */
531
- function ie(e) {
578
+ function H(e) {
532
579
  let t = /* @__PURE__ */ new Map();
533
580
  console.log("Simulator: Parsing fixtures", Object.keys(e));
534
581
  for (let [o, s] of Object.entries(e)) {
@@ -547,7 +594,7 @@ function ie(e) {
547
594
  }), t;
548
595
  }
549
596
  /** Render fixture selector HTML */
550
- function F(e, t) {
597
+ function ie(e, t) {
551
598
  return e.length === 0 ? "" : `
552
599
  <div class="simulator-fixtures">
553
600
  <div class="simulator-field">
@@ -564,7 +611,7 @@ function F(e, t) {
564
611
  `;
565
612
  }
566
613
  /** Update puzzle select options based on selected category */
567
- function I(e, t, n, r) {
614
+ function U(e, t, n, r) {
568
615
  let i = t.get(n);
569
616
  if (!i) return null;
570
617
  let a = Array.from(i.keys()), o = r;
@@ -575,7 +622,7 @@ function I(e, t, n, r) {
575
622
  return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
576
623
  }
577
624
  /** Get puzzle data from fixtures */
578
- function L(e, t, n) {
625
+ function W(e, t, n) {
579
626
  var r, i;
580
627
  return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
581
628
  }
@@ -603,19 +650,19 @@ function oe() {
603
650
  selectedCategory: e.state.selectedCategory,
604
651
  selectedPuzzle: e.state.selectedPuzzle
605
652
  }), e.fixtures && e.fixtureCategories.length > 0 && i) {
606
- i.innerHTML = F(e.fixtureCategories, e.state.selectedCategory);
653
+ i.innerHTML = ie(e.fixtureCategories, e.state.selectedCategory);
607
654
  let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
608
655
  if (t && n && e.state.selectedCategory) {
609
- e.state.selectedPuzzle = I(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
610
- let r = L(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
656
+ e.state.selectedPuzzle = U(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
657
+ let r = W(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
611
658
  console.log("Simulator: Loading fixture puzzle", {
612
659
  category: e.state.selectedCategory,
613
660
  puzzle: e.state.selectedPuzzle,
614
661
  hasPuzzleData: !!r
615
- }), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && D(e.state.selectedCategory), e.state.selectedPuzzle && O(e.state.selectedPuzzle)), t.addEventListener("change", () => {
616
- console.log("Simulator: Category changed, reloading...", t.value), d(), D(t.value), k(), window.location.reload();
662
+ }), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && I(e.state.selectedCategory), e.state.selectedPuzzle && L(e.state.selectedPuzzle)), t.addEventListener("change", () => {
663
+ console.log("Simulator: Category changed, reloading...", t.value), h(), I(t.value), R(), window.location.reload();
617
664
  }), n.addEventListener("change", () => {
618
- console.log("Simulator: Puzzle changed, reloading...", n.value), d(), O(n.value), window.location.reload();
665
+ console.log("Simulator: Puzzle changed, reloading...", n.value), h(), L(n.value), window.location.reload();
619
666
  });
620
667
  }
621
668
  }
@@ -641,10 +688,10 @@ function oe() {
641
688
  * Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
642
689
  * must stay self-contained.
643
690
  */
644
- function R(e) {
691
+ function se(e) {
645
692
  var t;
646
693
  if (typeof e != "string") return e;
647
- let n = (t = z(e)) == null ? {
694
+ let n = (t = ce(e)) == null ? {
648
695
  width: 800,
649
696
  height: 800
650
697
  } : t;
@@ -655,7 +702,7 @@ function R(e) {
655
702
  };
656
703
  }
657
704
  /** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
658
- function z(e) {
705
+ function ce(e) {
659
706
  var t, n, r, i;
660
707
  let a = e.indexOf("<svg");
661
708
  if (a === -1) return;
@@ -673,9 +720,9 @@ function z(e) {
673
720
  height: u
674
721
  };
675
722
  }
676
- var B = "simulator-saved-states";
723
+ var le = "simulator-saved-states";
677
724
  /** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
678
- function se() {
725
+ function ue() {
679
726
  let e = globalThis;
680
727
  for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
681
728
  name: t,
@@ -684,8 +731,8 @@ function se() {
684
731
  return null;
685
732
  }
686
733
  /** Generate a small thumbnail SVG for a given input string */
687
- function V(e, t) {
688
- let n = se();
734
+ function de(e, t) {
735
+ let n = ue();
689
736
  if (!n) return "";
690
737
  try {
691
738
  var r;
@@ -695,19 +742,19 @@ function V(e, t) {
695
742
  strict: !0,
696
743
  renderHost: "game"
697
744
  };
698
- return R(n.fn(i, t, a)).svg;
745
+ return se(n.fn(i, t, a)).svg;
699
746
  } catch (e) {
700
747
  return "";
701
748
  }
702
749
  }
703
- var H = [];
704
- function U(e, t = 8) {
750
+ var G = [];
751
+ function K(e, t = 8) {
705
752
  let n = 14 * t + 8 + 4;
706
753
  e.style.height = "auto";
707
754
  let r = Math.min(Math.max(e.scrollHeight, 40), n);
708
755
  e.style.height = `${r}px`;
709
756
  }
710
- function ce() {
757
+ function fe() {
711
758
  let e = "", t = "";
712
759
  return {
713
760
  id: "data",
@@ -725,132 +772,132 @@ function ce() {
725
772
  let i = n.getElement(".data-view-container");
726
773
  i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
727
774
  e.classList.toggle("active", e.id === `data-subtab-${t}`);
728
- }), t === "edit" ? de(n) : t === "history" ? W(n) : t === "saves" && G(n);
775
+ }), t === "edit" ? _e(n) : t === "history" ? me(n) : t === "saves" && he(n);
729
776
  });
730
777
  });
731
- let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), s = n.getElement("#simulator-puzzle-apply"), c = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
778
+ let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), s = n.getElement("#simulator-puzzle-apply"), c = n.getElement("#simulator-input-reset"), l = n.getElement("#simulator-input-apply");
732
779
  setTimeout(() => {
733
- i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, U(a)), fe(n);
780
+ i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, K(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, K(a)), ve(n);
734
781
  }, 0), i == null || i.addEventListener("input", () => {
735
- U(i);
782
+ K(i);
736
783
  let t = i.value !== e;
737
784
  s && (s.disabled = !t);
738
785
  }), a == null || a.addEventListener("input", () => {
739
- U(a);
786
+ K(a);
740
787
  let e = a.value !== t;
741
- d && (d.disabled = !e);
788
+ l && (l.disabled = !e);
742
789
  }), o == null || o.addEventListener("click", () => {
743
790
  if (n.state.appliedPuzzleOverride !== null) {
744
- u("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
791
+ m("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
745
792
  return;
746
793
  }
747
- i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i), s && (s.disabled = !0));
794
+ i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, K(i), s && (s.disabled = !0));
748
795
  }), s == null || s.addEventListener("click", () => {
749
796
  if (i) {
750
- if (!l("puzzle", i.value)) {
797
+ if (!p("puzzle", i.value)) {
751
798
  n.updateStatus("Could not store puzzle — storage unavailable", "paused");
752
799
  return;
753
800
  }
754
- u("input"), s.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
801
+ m("input"), s.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
755
802
  }
756
803
  }), c == null || c.addEventListener("click", () => {
757
804
  if (n.state.appliedInputOverride !== null) {
758
- u("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
805
+ m("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
759
806
  return;
760
807
  }
761
- a && (a.value = t, U(a), d && (d.disabled = !0));
762
- }), d == null || d.addEventListener("click", () => {
808
+ a && (a.value = t, K(a), l && (l.disabled = !0));
809
+ }), l == null || l.addEventListener("click", () => {
763
810
  if (a) {
764
- if (!l("input", a.value)) {
811
+ if (!p("input", a.value)) {
765
812
  n.updateStatus("Could not store input — storage unavailable", "paused");
766
813
  return;
767
814
  }
768
- d.disabled = !0, n.updateStatus("Applying input...", "waiting"), window.location.reload();
815
+ l.disabled = !0, n.updateStatus("Applying input...", "waiting"), window.location.reload();
769
816
  }
770
817
  });
771
- let f = n.getElement("#simulator-history-clear");
772
- f == null || f.addEventListener("click", () => {
773
- H = [], W(n);
818
+ let u = n.getElement("#simulator-history-clear");
819
+ u == null || u.addEventListener("click", () => {
820
+ G = [], me(n);
774
821
  });
775
- let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
776
- m == null || m.addEventListener("click", () => {
777
- if (!p || !p.value.trim()) return;
778
- let e = le(), t = {
779
- name: p.value.trim(),
822
+ let d = n.getElement("#simulator-save-name"), f = n.getElement("#simulator-save-btn");
823
+ f == null || f.addEventListener("click", () => {
824
+ if (!d || !d.value.trim()) return;
825
+ let e = pe(), t = {
826
+ name: d.value.trim(),
780
827
  puzzleStr: n.state.originalPuzzle,
781
828
  inputStr: n.state.currentInputStr,
782
829
  timestamp: Date.now()
783
830
  };
784
- e.push(t), localStorage.setItem(B, JSON.stringify(e)), p.value = "", G(n);
785
- }), G(n);
831
+ e.push(t), localStorage.setItem(le, JSON.stringify(e)), d.value = "", he(n);
832
+ }), he(n);
786
833
  },
787
834
  onActivate(n) {
788
- e = n.state.originalPuzzle, t = n.state.currentInputStr, de(n), W(n);
835
+ e = n.state.originalPuzzle, t = n.state.currentInputStr, _e(n), me(n);
789
836
  },
790
837
  onMessage(e, n, r) {
791
838
  var i, a;
792
839
  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;
793
840
  if (e === "UPLOAD_NEW_GAME_STATE" && c) {
794
- if (r.state.currentInputStr = c, H.length === 0 || H[H.length - 1].value !== c) {
795
- H.push({
841
+ if (r.state.currentInputStr = c, G.length === 0 || G[G.length - 1].value !== c) {
842
+ G.push({
796
843
  value: c,
797
844
  timestamp: Date.now()
798
- }), H.length > 100 && (H = H.slice(-100));
845
+ }), G.length > 100 && (G = G.slice(-100));
799
846
  let e = r.getElement("#data-subtab-history");
800
- e != null && e.classList.contains("active") && W(r);
847
+ e != null && e.classList.contains("active") && me(r);
801
848
  }
802
- o && document.activeElement !== o && (o.value !== c && (o.value = c, U(o)), t = c, s && (s.disabled = !0));
849
+ o && document.activeElement !== o && (o.value !== c && (o.value = c, K(o)), t = c, s && (s.disabled = !0));
803
850
  }
804
851
  }
805
852
  };
806
853
  }
807
- function le() {
854
+ function pe() {
808
855
  try {
809
- let e = localStorage.getItem(B);
856
+ let e = localStorage.getItem(le);
810
857
  return e ? JSON.parse(e) : [];
811
858
  } catch (e) {
812
859
  return [];
813
860
  }
814
861
  }
815
- function W(e) {
862
+ function me(e) {
816
863
  let t = e.getElement("#simulator-history-list");
817
864
  if (t) {
818
- if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), H.length === 0) {
865
+ if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), G.length === 0) {
819
866
  t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
820
867
  return;
821
868
  }
822
- t.innerHTML = [...H].reverse().map((t, n) => {
823
- let r = H.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
869
+ t.innerHTML = [...G].reverse().map((t, n) => {
870
+ let r = G.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
824
871
  return `
825
872
  <div class="history-item" data-history-idx="${r}">
826
- <div class="history-item-thumb">${V(e, t.value)}</div>
873
+ <div class="history-item-thumb">${de(e, t.value)}</div>
827
874
  <div class="history-item-content">
828
875
  <div class="history-item-header">
829
876
  <span class="history-item-num">#${r + 1}</span>
830
877
  <span class="history-item-time">${i}</span>
831
878
  <button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
832
879
  </div>
833
- <div class="history-item-preview">${ue(a)}</div>
880
+ <div class="history-item-preview">${ge(a)}</div>
834
881
  </div>
835
882
  </div>
836
883
  `;
837
884
  }).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
838
885
  t.addEventListener("click", (t) => {
839
- let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = H[n];
886
+ let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = G[n];
840
887
  if (r) {
841
888
  let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
842
889
  t == null || t.click();
843
890
  let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
844
- n && (n.value = r.value, U(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
891
+ n && (n.value = r.value, K(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
845
892
  }
846
893
  });
847
894
  });
848
895
  }
849
896
  }
850
- function G(e) {
897
+ function he(e) {
851
898
  let t = e.getElement("#simulator-saves-list");
852
899
  if (!t) return;
853
- let n = le();
900
+ let n = pe();
854
901
  if (n.length === 0) {
855
902
  t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
856
903
  return;
@@ -860,7 +907,7 @@ function G(e) {
860
907
  return `
861
908
  <div class="save-item">
862
909
  <div class="save-item-header">
863
- <span class="save-item-name">${ue(e.name)}</span>
910
+ <span class="save-item-name">${ge(e.name)}</span>
864
911
  <span class="save-item-time">${i} ${a}</span>
865
912
  </div>
866
913
  <div class="save-item-actions">
@@ -873,8 +920,8 @@ function G(e) {
873
920
  t.addEventListener("click", (t) => {
874
921
  let r = n[parseInt(t.target.getAttribute("data-save-idx") || "0")];
875
922
  if (r) {
876
- if (!l("puzzle", r.puzzleStr) || !l("input", r.inputStr)) {
877
- d(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
923
+ if (!p("puzzle", r.puzzleStr) || !p("input", r.inputStr)) {
924
+ h(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
878
925
  return;
879
926
  }
880
927
  e.updateStatus(`Loading: ${r.name}`, "waiting"), window.location.reload();
@@ -883,25 +930,25 @@ function G(e) {
883
930
  }), t.querySelectorAll(".save-delete-btn").forEach((t) => {
884
931
  t.addEventListener("click", (t) => {
885
932
  let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
886
- localStorage.setItem(B, JSON.stringify(i)), G(e);
933
+ localStorage.setItem(le, JSON.stringify(i)), he(e);
887
934
  });
888
935
  });
889
936
  }
890
- function ue(e) {
937
+ function ge(e) {
891
938
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
892
939
  }
893
- function de(e) {
940
+ function _e(e) {
894
941
  let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
895
- t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, U(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, U(n), i && (i.disabled = !0)), fe(e);
942
+ t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, K(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, K(n), i && (i.disabled = !0)), ve(e);
896
943
  }
897
- function fe(e) {
944
+ function ve(e) {
898
945
  let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
899
946
  t && (t.hidden = e.state.appliedPuzzleOverride === null), n && (n.hidden = e.state.appliedInputOverride === null);
900
947
  }
901
- function pe(e) {
948
+ function ye(e) {
902
949
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
903
950
  }
904
- function me() {
951
+ function be() {
905
952
  let e = 0;
906
953
  return {
907
954
  id: "msgs",
@@ -928,7 +975,7 @@ function me() {
928
975
  <span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
929
976
  <span class="simulator-msg-time">${t.time}</span>
930
977
  </div>
931
- ${a ? `<div class="simulator-msg-data">${pe(a)}</div>` : ""}
978
+ ${a ? `<div class="simulator-msg-data">${ye(a)}</div>` : ""}
932
979
  `;
933
980
  let o = i.querySelector(".simulator-msg-data");
934
981
  for (o && o.addEventListener("click", () => {
@@ -939,7 +986,7 @@ function me() {
939
986
  }
940
987
  };
941
988
  }
942
- function he() {
989
+ function xe() {
943
990
  return {
944
991
  id: "done",
945
992
  label: "Done",
@@ -976,7 +1023,7 @@ function he() {
976
1023
  }
977
1024
  };
978
1025
  }
979
- function ge() {
1026
+ function Se() {
980
1027
  let e = [], t = () => (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), n = (e) => {
981
1028
  let { checkpointName: t, augConfig: n, time: r } = e, i = n == null ? void 0 : n.deeds;
982
1029
  return `
@@ -1026,7 +1073,7 @@ function ge() {
1026
1073
  }
1027
1074
  };
1028
1075
  }
1029
- var _e = /* @__PURE__ */ r(((e) => {
1076
+ var Ce = /* @__PURE__ */ s(((e) => {
1030
1077
  var t = { document: {} }, n = Object.prototype.hasOwnProperty, r = function(e) {
1031
1078
  return v(e) ? e.toLowerCase() : e;
1032
1079
  }, i = Array.isArray;
@@ -1036,7 +1083,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1036
1083
  var n = e();
1037
1084
  return Function.prototype.constructor = t, n;
1038
1085
  }
1039
- var o, s = Object.prototype.toString, c = Object.getPrototypeOf, l = O("ng");
1086
+ var o, s = Object.prototype.toString, c = Object.getPrototypeOf, l = j("ng");
1040
1087
  /**
1041
1088
  * @private
1042
1089
  * @param {*} obj
@@ -1223,10 +1270,10 @@ var _e = /* @__PURE__ */ r(((e) => {
1223
1270
  return e && e.$evalAsync && e.$watch;
1224
1271
  }
1225
1272
  var C = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;
1226
- function ee(e) {
1273
+ function w(e) {
1227
1274
  return e && y(e.length) && C.test(s.call(e));
1228
1275
  }
1229
- function w(e) {
1276
+ function T(e) {
1230
1277
  return s.call(e) === "[object ArrayBuffer]";
1231
1278
  }
1232
1279
  /**
@@ -1294,10 +1341,10 @@ var _e = /* @__PURE__ */ r(((e) => {
1294
1341
  </file>
1295
1342
  </example>
1296
1343
  */
1297
- function T(e, t) {
1344
+ function E(e, t) {
1298
1345
  var r = [], a = [];
1299
1346
  if (t) {
1300
- if (ee(t) || w(t)) throw l("cpta", "Can't copy! TypedArray destination cannot be mutated.");
1347
+ if (w(t) || T(t)) throw l("cpta", "Can't copy! TypedArray destination cannot be mutated.");
1301
1348
  if (e === t) throw l("cpi", "Can't copy! Source and destination are identical.");
1302
1349
  return i(t) ? t.length = 0 : d(t, function(e, n) {
1303
1350
  n !== "$$hashKey" && delete t[n];
@@ -1366,7 +1413,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1366
1413
  * @param {...*} args Optional arguments to be prebound to the `fn` function call.
1367
1414
  * @returns {function()} Function that wraps the `fn` with all the specified bindings.
1368
1415
  */
1369
- function te(e, n) {
1416
+ function D(e, n) {
1370
1417
  var r = n;
1371
1418
  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;
1372
1419
  }
@@ -1381,21 +1428,21 @@ var _e = /* @__PURE__ */ r(((e) => {
1381
1428
  *
1382
1429
  * @returns {Object}
1383
1430
  */
1384
- function ne() {
1431
+ function O() {
1385
1432
  return Object.create(null);
1386
1433
  }
1387
- function E(e) {
1434
+ function k(e) {
1388
1435
  var t = [];
1389
1436
  return JSON.stringify(e, function(e, n) {
1390
- if (n = te(e, n), g(n)) {
1437
+ if (n = D(e, n), g(n)) {
1391
1438
  if (t.indexOf(n) >= 0) return "...";
1392
1439
  t.push(n);
1393
1440
  }
1394
1441
  return n;
1395
1442
  });
1396
1443
  }
1397
- function D(e) {
1398
- return typeof e == "function" ? e.toString().replace(/ \{[\s\S]*$/, "") : m(e) ? "undefined" : typeof e == "string" ? e : E(e);
1444
+ function A(e) {
1445
+ return typeof e == "function" ? e.toString().replace(/ \{[\s\S]*$/, "") : m(e) ? "undefined" : typeof e == "string" ? e : k(e);
1399
1446
  }
1400
1447
  /**
1401
1448
  * @description
@@ -1426,25 +1473,25 @@ var _e = /* @__PURE__ */ r(((e) => {
1426
1473
  * error from returned function, for cases when a particular type of error is useful.
1427
1474
  * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance
1428
1475
  */
1429
- function O(e, t) {
1476
+ function j(e, t) {
1430
1477
  return t = t || Error, function() {
1431
1478
  var n = 2, r = arguments, i = r[0], a = "[" + (e ? e + ":" : "") + i + "] ", o = r[1], s, c;
1432
1479
  for (a += o.replace(/\{\d+\}/g, function(e) {
1433
1480
  var t = +e.slice(1, -1) + n;
1434
- return t < r.length ? D(r[t]) : e;
1435
- }), 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]));
1481
+ return t < r.length ? A(r[t]) : e;
1482
+ }), 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(A(r[c]));
1436
1483
  return new t(a);
1437
1484
  };
1438
1485
  }
1439
- var k = O("$parse");
1440
- function A(e) {
1486
+ var M = j("$parse");
1487
+ function N(e) {
1441
1488
  return e + "";
1442
1489
  }
1443
- var j = ne();
1490
+ var P = O();
1444
1491
  d("+ - * / % === !== == != < > <= >= && || ?? ! = | ?".split(" "), function(e) {
1445
- j[e] = !0;
1492
+ P[e] = !0;
1446
1493
  });
1447
- var M = {
1494
+ var ee = {
1448
1495
  n: "\n",
1449
1496
  f: "\f",
1450
1497
  r: "\r",
@@ -1456,11 +1503,11 @@ var _e = /* @__PURE__ */ r(((e) => {
1456
1503
  /**
1457
1504
  * @constructor
1458
1505
  */
1459
- function N(e) {
1506
+ function F(e) {
1460
1507
  this.options = e || {};
1461
1508
  }
1462
- N.prototype = {
1463
- constructor: N,
1509
+ F.prototype = {
1510
+ constructor: F,
1464
1511
  lex: function(e) {
1465
1512
  for (this.text = e, this.index = 0, this.tokens = []; this.index < this.text.length;) {
1466
1513
  var t = this.text.charAt(this.index);
@@ -1473,7 +1520,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1473
1520
  }), this.index++;
1474
1521
  else if (this.isWhitespace(t)) this.index++;
1475
1522
  else {
1476
- var n = t + this.peek(), r = n + this.peek(2), i = j[t], a = j[n], o = j[r];
1523
+ var n = t + this.peek(), r = n + this.peek(2), i = P[t], a = P[n], o = P[r];
1477
1524
  if (i || a || o) {
1478
1525
  var s = o ? r : a ? n : t;
1479
1526
  this.tokens.push({
@@ -1524,7 +1571,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1524
1571
  return e === "-" || e === "+" || this.isNumber(e);
1525
1572
  },
1526
1573
  throwError: function(e, t, n) {
1527
- 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);
1574
+ throw n = n || this.index, M("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);
1528
1575
  },
1529
1576
  readNumber: function() {
1530
1577
  for (var e = "", t = this.index; this.index < this.text.length;) {
@@ -1577,7 +1624,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1577
1624
  text: "+",
1578
1625
  operator: !0
1579
1626
  });
1580
- for (var l = new N(this.options).lex(c), u = 0, d = l.length; u < d; u++) this.tokens.push(l[u]);
1627
+ for (var l = new F(this.options).lex(c), u = 0, d = l.length; u < d; u++) this.tokens.push(l[u]);
1581
1628
  this.tokens.push({
1582
1629
  index: this.index,
1583
1630
  text: "+",
@@ -1590,7 +1637,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1590
1637
  var f = this.text.substring(this.index + 1, this.index + 5);
1591
1638
  f.match(/[\da-f]{4}/i) || this.throwError("Invalid unicode escape [\\u" + f + "]"), this.index += 4, n += String.fromCharCode(parseInt(f, 16));
1592
1639
  } else {
1593
- var p = M[o];
1640
+ var p = ee[o];
1594
1641
  n += p || o;
1595
1642
  }
1596
1643
  a = !1;
@@ -1609,10 +1656,10 @@ var _e = /* @__PURE__ */ r(((e) => {
1609
1656
  this.throwError("Unterminated quote", t);
1610
1657
  }
1611
1658
  };
1612
- function P(e, t) {
1659
+ function I(e, t) {
1613
1660
  this.lexer = e, this.options = t;
1614
1661
  }
1615
- P.Program = "Program", P.ExpressionStatement = "ExpressionStatement", P.AssignmentExpression = "AssignmentExpression", P.ConditionalExpression = "ConditionalExpression", P.LogicalExpression = "LogicalExpression", P.BinaryExpression = "BinaryExpression", P.UnaryExpression = "UnaryExpression", P.CallExpression = "CallExpression", P.MemberExpression = "MemberExpression", P.Identifier = "Identifier", P.Literal = "Literal", P.ArrayExpression = "ArrayExpression", P.Property = "Property", P.ObjectExpression = "ObjectExpression", P.ThisExpression = "ThisExpression", P.LocalsExpression = "LocalsExpression", P.NGValueParameter = "NGValueParameter", P.prototype = {
1662
+ I.Program = "Program", I.ExpressionStatement = "ExpressionStatement", I.AssignmentExpression = "AssignmentExpression", I.ConditionalExpression = "ConditionalExpression", I.LogicalExpression = "LogicalExpression", I.BinaryExpression = "BinaryExpression", I.UnaryExpression = "UnaryExpression", I.CallExpression = "CallExpression", I.MemberExpression = "MemberExpression", I.Identifier = "Identifier", I.Literal = "Literal", I.ArrayExpression = "ArrayExpression", I.Property = "Property", I.ObjectExpression = "ObjectExpression", I.ThisExpression = "ThisExpression", I.LocalsExpression = "LocalsExpression", I.NGValueParameter = "NGValueParameter", I.prototype = {
1616
1663
  ast: function(e) {
1617
1664
  this.text = e, this.tokens = this.lexer.lex(e);
1618
1665
  var t = this.program();
@@ -1620,13 +1667,13 @@ var _e = /* @__PURE__ */ r(((e) => {
1620
1667
  },
1621
1668
  program: function() {
1622
1669
  for (var e = [];;) if (this.tokens.length > 0 && !this.peek("}", ")", ";", "]") && e.push(this.expressionStatement()), !this.expect(";")) return {
1623
- type: P.Program,
1670
+ type: I.Program,
1624
1671
  body: e
1625
1672
  };
1626
1673
  },
1627
1674
  expressionStatement: function() {
1628
1675
  return {
1629
- type: P.ExpressionStatement,
1676
+ type: I.ExpressionStatement,
1630
1677
  expression: this.filterChain()
1631
1678
  };
1632
1679
  },
@@ -1640,9 +1687,9 @@ var _e = /* @__PURE__ */ r(((e) => {
1640
1687
  assignment: function() {
1641
1688
  var e = this.ternary();
1642
1689
  if (this.expect("=")) {
1643
- if (!ae(e)) throw k("lval", "Trying to assign a value to a non l-value");
1690
+ if (!te(e)) throw M("lval", "Trying to assign a value to a non l-value");
1644
1691
  e = {
1645
- type: P.AssignmentExpression,
1692
+ type: I.AssignmentExpression,
1646
1693
  left: e,
1647
1694
  right: this.assignment(),
1648
1695
  operator: "="
@@ -1653,7 +1700,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1653
1700
  ternary: function() {
1654
1701
  var e = this.nullishCoalescing(), t, n;
1655
1702
  return this.expect("?") && (t = this.expression(), this.consume(":")) ? (n = this.expression(), {
1656
- type: P.ConditionalExpression,
1703
+ type: I.ConditionalExpression,
1657
1704
  test: e,
1658
1705
  alternate: t,
1659
1706
  consequent: n
@@ -1661,7 +1708,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1661
1708
  },
1662
1709
  nullishCoalescing: function() {
1663
1710
  for (var e = this.logicalOR(); this.expect("??");) e = {
1664
- type: P.LogicalExpression,
1711
+ type: I.LogicalExpression,
1665
1712
  operator: "??",
1666
1713
  left: e,
1667
1714
  right: this.logicalOR()
@@ -1670,7 +1717,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1670
1717
  },
1671
1718
  logicalOR: function() {
1672
1719
  for (var e = this.logicalAND(); this.expect("||");) e = {
1673
- type: P.LogicalExpression,
1720
+ type: I.LogicalExpression,
1674
1721
  operator: "||",
1675
1722
  left: e,
1676
1723
  right: this.logicalAND()
@@ -1679,7 +1726,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1679
1726
  },
1680
1727
  logicalAND: function() {
1681
1728
  for (var e = this.equality(); this.expect("&&");) e = {
1682
- type: P.LogicalExpression,
1729
+ type: I.LogicalExpression,
1683
1730
  operator: "&&",
1684
1731
  left: e,
1685
1732
  right: this.equality()
@@ -1688,7 +1735,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1688
1735
  },
1689
1736
  equality: function() {
1690
1737
  for (var e = this.relational(), t; t = this.expect("==", "!=", "===", "!==");) e = {
1691
- type: P.BinaryExpression,
1738
+ type: I.BinaryExpression,
1692
1739
  operator: t.text,
1693
1740
  left: e,
1694
1741
  right: this.relational()
@@ -1697,7 +1744,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1697
1744
  },
1698
1745
  relational: function() {
1699
1746
  for (var e = this.additive(), t; t = this.expect("<", ">", "<=", ">=");) e = {
1700
- type: P.BinaryExpression,
1747
+ type: I.BinaryExpression,
1701
1748
  operator: t.text,
1702
1749
  left: e,
1703
1750
  right: this.additive()
@@ -1706,7 +1753,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1706
1753
  },
1707
1754
  additive: function() {
1708
1755
  for (var e = this.multiplicative(), t; t = this.expect("+", "-");) e = {
1709
- type: P.BinaryExpression,
1756
+ type: I.BinaryExpression,
1710
1757
  operator: t.text,
1711
1758
  left: e,
1712
1759
  right: this.multiplicative()
@@ -1715,7 +1762,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1715
1762
  },
1716
1763
  multiplicative: function() {
1717
1764
  for (var e = this.unary(), t; t = this.expect("*", "/", "%");) e = {
1718
- type: P.BinaryExpression,
1765
+ type: I.BinaryExpression,
1719
1766
  operator: t.text,
1720
1767
  left: e,
1721
1768
  right: this.unary()
@@ -1725,7 +1772,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1725
1772
  unary: function() {
1726
1773
  var e;
1727
1774
  return (e = this.expect("+", "-", "!")) ? {
1728
- type: P.UnaryExpression,
1775
+ type: I.UnaryExpression,
1729
1776
  operator: e.text,
1730
1777
  prefix: !0,
1731
1778
  argument: this.unary()
@@ -1733,21 +1780,21 @@ var _e = /* @__PURE__ */ r(((e) => {
1733
1780
  },
1734
1781
  primary: function() {
1735
1782
  var e;
1736
- this.expect("(") ? (e = this.filterChain(), this.consume(")")) : this.expect("[") ? e = this.arrayDeclaration() : this.expect("{") ? e = this.object() : this.selfReferential.hasOwnProperty(this.peek().text) ? e = T(this.selfReferential[this.consume().text]) : this.options.literals.hasOwnProperty(this.peek().text) ? e = {
1737
- type: P.Literal,
1783
+ this.expect("(") ? (e = this.filterChain(), this.consume(")")) : this.expect("[") ? e = this.arrayDeclaration() : this.expect("{") ? e = this.object() : this.selfReferential.hasOwnProperty(this.peek().text) ? e = E(this.selfReferential[this.consume().text]) : this.options.literals.hasOwnProperty(this.peek().text) ? e = {
1784
+ type: I.Literal,
1738
1785
  value: this.options.literals[this.consume().text]
1739
1786
  } : this.peek().identifier ? e = this.identifier() : this.peek().constant ? e = this.constant() : this.throwError("not a primary expression", this.peek());
1740
1787
  for (var t; t = this.expect("(", "[", ".");) t.text === "(" ? (e = {
1741
- type: P.CallExpression,
1788
+ type: I.CallExpression,
1742
1789
  callee: e,
1743
1790
  arguments: this.parseArguments()
1744
1791
  }, this.consume(")")) : t.text === "[" ? (e = {
1745
- type: P.MemberExpression,
1792
+ type: I.MemberExpression,
1746
1793
  object: e,
1747
1794
  property: this.expression(),
1748
1795
  computed: !0
1749
1796
  }, this.consume("]")) : t.text === "." ? e = {
1750
- type: P.MemberExpression,
1797
+ type: I.MemberExpression,
1751
1798
  object: e,
1752
1799
  property: this.identifier(),
1753
1800
  computed: !1
@@ -1756,7 +1803,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1756
1803
  },
1757
1804
  filter: function(e) {
1758
1805
  for (var t = [e], n = {
1759
- type: P.CallExpression,
1806
+ type: I.CallExpression,
1760
1807
  callee: this.identifier(),
1761
1808
  arguments: t,
1762
1809
  filter: !0
@@ -1773,13 +1820,13 @@ var _e = /* @__PURE__ */ r(((e) => {
1773
1820
  identifier: function() {
1774
1821
  var e = this.consume();
1775
1822
  return e.identifier || this.throwError("is not a valid identifier", e), {
1776
- type: P.Identifier,
1823
+ type: I.Identifier,
1777
1824
  name: e.text
1778
1825
  };
1779
1826
  },
1780
1827
  constant: function() {
1781
1828
  return {
1782
- type: P.Literal,
1829
+ type: I.Literal,
1783
1830
  value: this.consume().value
1784
1831
  };
1785
1832
  },
@@ -1790,7 +1837,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1790
1837
  e.push(this.expression());
1791
1838
  } while (this.expect(","));
1792
1839
  return this.consume("]"), {
1793
- type: P.ArrayExpression,
1840
+ type: I.ArrayExpression,
1794
1841
  elements: e
1795
1842
  };
1796
1843
  },
@@ -1799,25 +1846,25 @@ var _e = /* @__PURE__ */ r(((e) => {
1799
1846
  if (this.peekToken().text !== "}") do {
1800
1847
  if (this.peek("}")) break;
1801
1848
  t = {
1802
- type: P.Property,
1849
+ type: I.Property,
1803
1850
  kind: "init"
1804
1851
  }, 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);
1805
1852
  } while (this.expect(","));
1806
1853
  return this.consume("}"), {
1807
- type: P.ObjectExpression,
1854
+ type: I.ObjectExpression,
1808
1855
  properties: e
1809
1856
  };
1810
1857
  },
1811
1858
  throwError: function(e, t) {
1812
- 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));
1859
+ throw M("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));
1813
1860
  },
1814
1861
  consume: function(e) {
1815
- if (this.tokens.length === 0) throw k("ueoe", "Unexpected end of expression: {0}", this.text);
1862
+ if (this.tokens.length === 0) throw M("ueoe", "Unexpected end of expression: {0}", this.text);
1816
1863
  var t = this.expect(e);
1817
1864
  return t || this.throwError("is unexpected, expecting [" + e + "]", this.peek()), t;
1818
1865
  },
1819
1866
  peekToken: function() {
1820
- if (this.tokens.length === 0) throw k("ueoe", "Unexpected end of expression: {0}", this.text);
1867
+ if (this.tokens.length === 0) throw M("ueoe", "Unexpected end of expression: {0}", this.text);
1821
1868
  return this.tokens[0];
1822
1869
  },
1823
1870
  peek: function(e, t, n, r) {
@@ -1835,99 +1882,99 @@ var _e = /* @__PURE__ */ r(((e) => {
1835
1882
  return i ? (this.tokens.shift(), i) : !1;
1836
1883
  }
1837
1884
  };
1838
- function re(e, t) {
1885
+ function L(e, t) {
1839
1886
  return e === void 0 ? t : e;
1840
1887
  }
1841
- function ie(e, t) {
1888
+ function R(e, t) {
1842
1889
  return e === void 0 ? t : t === void 0 ? e : e + t;
1843
1890
  }
1844
- function F(e, t) {
1891
+ function z(e, t) {
1845
1892
  var n = e(t);
1846
1893
  if (!n) throw Error("Filter '" + t + "' is not defined");
1847
1894
  return !n.$stateful;
1848
1895
  }
1849
- function I(e, t) {
1896
+ function B(e, t) {
1850
1897
  var n, r, i;
1851
1898
  switch (e.type) {
1852
- case P.Program:
1899
+ case I.Program:
1853
1900
  n = !0, d(e.body, function(e) {
1854
- I(e.expression, t), n = n && e.expression.constant;
1901
+ B(e.expression, t), n = n && e.expression.constant;
1855
1902
  }), e.constant = n;
1856
1903
  break;
1857
- case P.Literal:
1904
+ case I.Literal:
1858
1905
  e.constant = !0, e.toWatch = [];
1859
1906
  break;
1860
- case P.UnaryExpression:
1861
- I(e.argument, t), e.constant = e.argument.constant, e.toWatch = e.argument.toWatch;
1907
+ case I.UnaryExpression:
1908
+ B(e.argument, t), e.constant = e.argument.constant, e.toWatch = e.argument.toWatch;
1862
1909
  break;
1863
- case P.BinaryExpression:
1864
- I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.left.toWatch.concat(e.right.toWatch);
1910
+ case I.BinaryExpression:
1911
+ B(e.left, t), B(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.left.toWatch.concat(e.right.toWatch);
1865
1912
  break;
1866
- case P.LogicalExpression:
1867
- I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.constant ? [] : [e];
1913
+ case I.LogicalExpression:
1914
+ B(e.left, t), B(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.constant ? [] : [e];
1868
1915
  break;
1869
- case P.ConditionalExpression:
1870
- I(e.test, t), I(e.alternate, t), I(e.consequent, t), e.constant = e.test.constant && e.alternate.constant && e.consequent.constant, e.toWatch = e.constant ? [] : [e];
1916
+ case I.ConditionalExpression:
1917
+ B(e.test, t), B(e.alternate, t), B(e.consequent, t), e.constant = e.test.constant && e.alternate.constant && e.consequent.constant, e.toWatch = e.constant ? [] : [e];
1871
1918
  break;
1872
- case P.Identifier:
1919
+ case I.Identifier:
1873
1920
  e.constant = !1, e.toWatch = [e];
1874
1921
  break;
1875
- case P.MemberExpression:
1876
- I(e.object, t), e.computed && I(e.property, t), e.constant = e.object.constant && (!e.computed || e.property.constant), e.toWatch = [e];
1922
+ case I.MemberExpression:
1923
+ B(e.object, t), e.computed && B(e.property, t), e.constant = e.object.constant && (!e.computed || e.property.constant), e.toWatch = [e];
1877
1924
  break;
1878
- case P.CallExpression:
1879
- i = e.filter ? F(t, e.callee.name) : !1, n = i, r = [], d(e.arguments, function(e) {
1880
- I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1925
+ case I.CallExpression:
1926
+ i = e.filter ? z(t, e.callee.name) : !1, n = i, r = [], d(e.arguments, function(e) {
1927
+ B(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1881
1928
  }), e.constant = n, e.toWatch = i ? r : [e];
1882
1929
  break;
1883
- case P.AssignmentExpression:
1884
- I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = [e];
1930
+ case I.AssignmentExpression:
1931
+ B(e.left, t), B(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = [e];
1885
1932
  break;
1886
- case P.ArrayExpression:
1933
+ case I.ArrayExpression:
1887
1934
  n = !0, r = [], d(e.elements, function(e) {
1888
- I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1935
+ B(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
1889
1936
  }), e.constant = n, e.toWatch = r;
1890
1937
  break;
1891
- case P.ObjectExpression:
1938
+ case I.ObjectExpression:
1892
1939
  n = !0, r = [], d(e.properties, function(e) {
1893
- I(e.value, t), n = n && e.value.constant && !e.computed, e.value.constant || r.push.apply(r, e.value.toWatch);
1940
+ B(e.value, t), n = n && e.value.constant && !e.computed, e.value.constant || r.push.apply(r, e.value.toWatch);
1894
1941
  }), e.constant = n, e.toWatch = r;
1895
1942
  break;
1896
- case P.ThisExpression:
1943
+ case I.ThisExpression:
1897
1944
  e.constant = !1, e.toWatch = [];
1898
1945
  break;
1899
- case P.LocalsExpression:
1946
+ case I.LocalsExpression:
1900
1947
  e.constant = !1, e.toWatch = [];
1901
1948
  break;
1902
1949
  }
1903
1950
  }
1904
- function L(e) {
1951
+ function V(e) {
1905
1952
  if (e.length === 1) {
1906
1953
  var t = e[0].expression, n = t.toWatch;
1907
1954
  return n.length === 1 && n[0] === t ? void 0 : n;
1908
1955
  }
1909
1956
  }
1910
- function ae(e) {
1911
- return e.type === P.Identifier || e.type === P.MemberExpression;
1957
+ function te(e) {
1958
+ return e.type === I.Identifier || e.type === I.MemberExpression;
1912
1959
  }
1913
- function oe(e) {
1914
- if (e.body.length === 1 && ae(e.body[0].expression)) return {
1915
- type: P.AssignmentExpression,
1960
+ function ne(e) {
1961
+ if (e.body.length === 1 && te(e.body[0].expression)) return {
1962
+ type: I.AssignmentExpression,
1916
1963
  left: e.body[0].expression,
1917
- right: { type: P.NGValueParameter },
1964
+ right: { type: I.NGValueParameter },
1918
1965
  operator: "="
1919
1966
  };
1920
1967
  }
1921
- function R(e) {
1922
- return e.body.length === 0 || e.body.length === 1 && (e.body[0].expression.type === P.Literal || e.body[0].expression.type === P.ArrayExpression || e.body[0].expression.type === P.ObjectExpression);
1968
+ function re(e) {
1969
+ return e.body.length === 0 || e.body.length === 1 && (e.body[0].expression.type === I.Literal || e.body[0].expression.type === I.ArrayExpression || e.body[0].expression.type === I.ObjectExpression);
1923
1970
  }
1924
- function z(e) {
1971
+ function H(e) {
1925
1972
  return e.constant;
1926
1973
  }
1927
- function B(e, t) {
1974
+ function ie(e, t) {
1928
1975
  this.astBuilder = e, this.$filter = t;
1929
1976
  }
1930
- B.prototype = {
1977
+ ie.prototype = {
1931
1978
  compile: function(e) {
1932
1979
  var t = this, n = this.astBuilder.ast(e);
1933
1980
  this.state = {
@@ -1944,14 +1991,14 @@ var _e = /* @__PURE__ */ r(((e) => {
1944
1991
  own: {}
1945
1992
  },
1946
1993
  inputs: []
1947
- }, I(n, t.$filter);
1994
+ }, B(n, t.$filter);
1948
1995
  var r = "", i;
1949
- if (this.stage = "assign", i = oe(n)) {
1996
+ if (this.stage = "assign", i = ne(n)) {
1950
1997
  this.state.computing = "assign";
1951
1998
  var o = this.nextId();
1952
1999
  this.recurse(i, o), this.return_(o), r = "fn.assign=" + this.generateFunction("assign", "s,v,l");
1953
2000
  }
1954
- var s = L(n.body);
2001
+ var s = V(n.body);
1955
2002
  t.stage = "inputs", d(s, function(e, n) {
1956
2003
  var r = "fn" + n;
1957
2004
  t.state[r] = {
@@ -1962,7 +2009,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1962
2009
  var i = t.nextId();
1963
2010
  t.recurse(e, i), t.return_(i), t.state.inputs.push(r), e.watchId = n;
1964
2011
  }), this.state.computing = "fn", this.stage = "main", this.recurse(n);
1965
- var c = "\"" + this.USE + " " + this.STRICT + "\";\n" + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + r + this.watchFns() + "return fn;", l = Function("$filter", "getStringValue", "ifDefined", "plus", c)(this.$filter, A, re, ie), u = function(e, t, n, r) {
2012
+ 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, N, L, R), u = function(e, t, n, r) {
1966
2013
  return a(function() {
1967
2014
  return l(e, t, n, r);
1968
2015
  });
@@ -1971,7 +2018,7 @@ var _e = /* @__PURE__ */ r(((e) => {
1971
2018
  return a(function() {
1972
2019
  return l.assign(e, t, n);
1973
2020
  });
1974
- }, u.inputs = l.inputs, this.state = this.stage = void 0, u.ast = n, u.literal = R(n), u.constant = z(n), u;
2021
+ }, u.inputs = l.inputs, this.state = this.stage = void 0, u.ast = n, u.literal = re(n), u.constant = H(n), u;
1975
2022
  },
1976
2023
  USE: "use",
1977
2024
  STRICT: "strict",
@@ -2003,35 +2050,35 @@ var _e = /* @__PURE__ */ r(((e) => {
2003
2050
  return;
2004
2051
  }
2005
2052
  switch (e.type) {
2006
- case P.Program:
2053
+ case I.Program:
2007
2054
  d(e.body, function(t, n) {
2008
2055
  c.recurse(t.expression, void 0, void 0, function(e) {
2009
2056
  s = e;
2010
2057
  }), n === e.body.length - 1 ? c.return_(s) : c.current().body.push(s, ";");
2011
2058
  });
2012
2059
  break;
2013
- case P.Literal:
2060
+ case I.Literal:
2014
2061
  u = this.escape(e.value), this.assign(t, u), r(t || u);
2015
2062
  break;
2016
- case P.UnaryExpression:
2063
+ case I.UnaryExpression:
2017
2064
  this.recurse(e.argument, void 0, void 0, function(e) {
2018
2065
  s = e;
2019
2066
  }), u = e.operator + "(" + this.ifDefined(s, 0) + ")", this.assign(t, u), r(u);
2020
2067
  break;
2021
- case P.BinaryExpression:
2068
+ case I.BinaryExpression:
2022
2069
  this.recurse(e.left, void 0, void 0, function(e) {
2023
2070
  o = e;
2024
2071
  }), this.recurse(e.right, void 0, void 0, function(e) {
2025
2072
  s = e;
2026
2073
  }), 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);
2027
2074
  break;
2028
- case P.LogicalExpression:
2075
+ case I.LogicalExpression:
2029
2076
  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);
2030
2077
  break;
2031
- case P.ConditionalExpression:
2078
+ case I.ConditionalExpression:
2032
2079
  t = t || this.nextId(), c.recurse(e.test, t), c.if_(t, c.lazyRecurse(e.alternate, t), c.lazyRecurse(e.consequent, t)), r(t);
2033
2080
  break;
2034
- case P.Identifier:
2081
+ case I.Identifier:
2035
2082
  t = t || this.nextId();
2036
2083
  var m = c.current().inAssignment;
2037
2084
  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() {
@@ -2045,17 +2092,17 @@ var _e = /* @__PURE__ */ r(((e) => {
2045
2092
  c.if_(c.hasOwnProperty_("l", e.name), c.lazyAssign(t, c.nonComputedMember("l", e.name)));
2046
2093
  }), r(t);
2047
2094
  break;
2048
- case P.MemberExpression:
2095
+ case I.MemberExpression:
2049
2096
  o = n && (n.context = this.nextId()) || this.nextId(), t = t || this.nextId(), c.recurse(e.object, o, void 0, function() {
2050
2097
  var a = null, l = c.current().inAssignment;
2051
- e.computed ? (s = c.nextId(), a = l || c.state.computing === "assign" ? c.unsafeComputedMember(o, s) : c.computedMember(o, s)) : (a = l || c.state.computing === "assign" ? c.unsafeNonComputedMember(o, e.property.name) : c.nonComputedMember(o, e.property.name), s = e.property.name), e.computed && e.property.type === P.Literal && c.recurse(e.property, s), c.if_(c.and_(c.notNull(o), c.or_(c.isNull(a), c.hasOwnProperty_(o, s, e.computed))), function() {
2052
- e.computed ? (e.property.type !== P.Literal && c.recurse(e.property, s), i && i !== 1 && c.if_(c.not(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !0, n.name = s)) : (i && i !== 1 && c.if_(c.isNull(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !1, n.name = e.property.name));
2098
+ 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 === I.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() {
2099
+ e.computed ? (e.property.type !== I.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));
2053
2100
  }, function() {
2054
2101
  c.assign(t, "undefined");
2055
2102
  }), r(t);
2056
2103
  }, !!i);
2057
2104
  break;
2058
- case P.CallExpression:
2105
+ case I.CallExpression:
2059
2106
  t = t || this.nextId(), e.filter ? (s = c.filter(e.callee.name), l = [], d(e.arguments, function(e) {
2060
2107
  var t = c.nextId();
2061
2108
  c.recurse(e, t), l.push(t);
@@ -2071,38 +2118,38 @@ var _e = /* @__PURE__ */ r(((e) => {
2071
2118
  }), r(t);
2072
2119
  }));
2073
2120
  break;
2074
- case P.AssignmentExpression:
2121
+ case I.AssignmentExpression:
2075
2122
  s = this.nextId(), o = {}, c.current().inAssignment = !0, this.recurse(e.left, void 0, o, function() {
2076
2123
  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() {
2077
2124
  c.recurse(e.right, s), u = c.member(o.context, o.name, o.computed) + e.operator + s, c.assign(t, u), r(t || u);
2078
2125
  }), c.current().inAssignment = !1, c.recurse(e.right, s), c.current().inAssignment = !0;
2079
2126
  }, 1), c.current().inAssignment = !1;
2080
2127
  break;
2081
- case P.ArrayExpression:
2128
+ case I.ArrayExpression:
2082
2129
  l = [], d(e.elements, function(t) {
2083
2130
  c.recurse(t, e.constant ? void 0 : c.nextId(), void 0, function(e) {
2084
2131
  l.push(e);
2085
2132
  });
2086
2133
  }), u = "[" + l.join(",") + "]", this.assign(t, u), r(t || u);
2087
2134
  break;
2088
- case P.ObjectExpression:
2135
+ case I.ObjectExpression:
2089
2136
  l = [], f = !1, d(e.properties, function(e) {
2090
2137
  e.computed && (f = !0);
2091
2138
  }), f ? (t = t || this.nextId(), this.assign(t, "{}"), d(e.properties, function(e) {
2092
- e.computed ? (o = c.nextId(), c.recurse(e.key, o)) : o = e.key.type === P.Identifier ? e.key.name : "" + e.key.value, s = c.nextId(), c.recurse(e.value, s), c.assign(c.unsafeMember(t, o, e.computed), s);
2139
+ e.computed ? (o = c.nextId(), c.recurse(e.key, o)) : o = e.key.type === I.Identifier ? e.key.name : "" + e.key.value, s = c.nextId(), c.recurse(e.value, s), c.assign(c.unsafeMember(t, o, e.computed), s);
2093
2140
  })) : (d(e.properties, function(t) {
2094
2141
  c.recurse(t.value, e.constant ? void 0 : c.nextId(), void 0, function(e) {
2095
- l.push(c.escape(t.key.type === P.Identifier ? t.key.name : "" + t.key.value) + ":" + e);
2142
+ l.push(c.escape(t.key.type === I.Identifier ? t.key.name : "" + t.key.value) + ":" + e);
2096
2143
  });
2097
2144
  }), u = "{" + l.join(",") + "}", this.assign(t, u)), r(t || u);
2098
2145
  break;
2099
- case P.ThisExpression:
2146
+ case I.ThisExpression:
2100
2147
  this.assign(t, "s"), r(t || "s");
2101
2148
  break;
2102
- case P.LocalsExpression:
2149
+ case I.LocalsExpression:
2103
2150
  this.assign(t, "l"), r(t || "l");
2104
2151
  break;
2105
- case P.NGValueParameter:
2152
+ case I.NGValueParameter:
2106
2153
  this.assign(t, "v"), r(t || "v");
2107
2154
  break;
2108
2155
  }
@@ -2196,7 +2243,7 @@ var _e = /* @__PURE__ */ r(((e) => {
2196
2243
  if (e === !1) return "false";
2197
2244
  if (e === null) return "null";
2198
2245
  if (e === void 0) return "undefined";
2199
- throw k("esc", "IMPOSSIBLE");
2246
+ throw M("esc", "IMPOSSIBLE");
2200
2247
  },
2201
2248
  nextId: function(e, t) {
2202
2249
  var n = "v" + this.state.nextId++;
@@ -2206,16 +2253,16 @@ var _e = /* @__PURE__ */ r(((e) => {
2206
2253
  return this.state[this.state.computing];
2207
2254
  }
2208
2255
  };
2209
- function se(e, t) {
2256
+ function U(e, t) {
2210
2257
  this.astBuilder = e, this.$filter = t;
2211
2258
  }
2212
- se.prototype = {
2259
+ U.prototype = {
2213
2260
  compile: function(e) {
2214
2261
  var t = this, n = this.astBuilder.ast(e);
2215
- I(n, t.$filter);
2262
+ B(n, t.$filter);
2216
2263
  var r, i;
2217
- (r = oe(n)) && (i = this.recurse(r));
2218
- var o = L(n.body), s;
2264
+ (r = ne(n)) && (i = this.recurse(r));
2265
+ var o = V(n.body), s;
2219
2266
  o && (s = [], d(o, function(e, n) {
2220
2267
  var r = t.recurse(e);
2221
2268
  e.input = r, s.push(r), e.watchId = n;
@@ -2242,20 +2289,20 @@ var _e = /* @__PURE__ */ r(((e) => {
2242
2289
  return a(function() {
2243
2290
  return l.assign(e, t, n);
2244
2291
  });
2245
- }, s && (u.inputs = s), u.ast = n, u.literal = R(n), u.constant = z(n), u;
2292
+ }, s && (u.inputs = s), u.ast = n, u.literal = re(n), u.constant = H(n), u;
2246
2293
  },
2247
2294
  recurse: function(e, t, n) {
2248
2295
  var r, i, a = this, o;
2249
2296
  if (e.input) return this.inputs(e.input, e.watchId);
2250
2297
  switch (e.type) {
2251
- case P.Literal: return this.value(e.value, t);
2252
- case P.UnaryExpression: return i = this.recurse(e.argument), this["unary" + e.operator](i, t);
2253
- case P.BinaryExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2254
- case P.LogicalExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2255
- case P.ConditionalExpression: return this["ternary?:"](this.recurse(e.test), this.recurse(e.alternate), this.recurse(e.consequent), t);
2256
- case P.Identifier: return a.identifier(e.name, t, n);
2257
- case P.MemberExpression: return r = this.recurse(e.object, !1, !!n), e.computed || (i = e.property.name), e.computed && (i = this.recurse(e.property)), e.computed ? this.computedMember(r, i, t, n) : this.nonComputedMember(r, i, t, n);
2258
- case P.CallExpression: return o = [], d(e.arguments, function(e) {
2298
+ case I.Literal: return this.value(e.value, t);
2299
+ case I.UnaryExpression: return i = this.recurse(e.argument), this["unary" + e.operator](i, t);
2300
+ case I.BinaryExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2301
+ case I.LogicalExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
2302
+ case I.ConditionalExpression: return this["ternary?:"](this.recurse(e.test), this.recurse(e.alternate), this.recurse(e.consequent), t);
2303
+ case I.Identifier: return a.identifier(e.name, t, n);
2304
+ case I.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);
2305
+ case I.CallExpression: return o = [], d(e.arguments, function(e) {
2259
2306
  o.push(a.recurse(e));
2260
2307
  }), e.filter && (i = this.$filter(e.callee.name)), e.filter || (i = this.recurse(e.callee, !0)), e.filter ? function(e, n, r, a) {
2261
2308
  for (var s = [], c = 0; c < o.length; ++c) s.push(o[c](e, n, r, a));
@@ -2273,23 +2320,23 @@ var _e = /* @__PURE__ */ r(((e) => {
2273
2320
  }
2274
2321
  return t ? { value: c } : c;
2275
2322
  };
2276
- case P.AssignmentExpression: return r = this.recurse(e.left, !0, 1), i = this.recurse(e.right), function(e, n, a, o) {
2323
+ case I.AssignmentExpression: return r = this.recurse(e.left, !0, 1), i = this.recurse(e.right), function(e, n, a, o) {
2277
2324
  var s = r(e, !1, a, o), c = i(e, n, a, o);
2278
2325
  return s.context[s.name] = c, t ? { value: c } : c;
2279
2326
  };
2280
- case P.ArrayExpression: return o = [], d(e.elements, function(e) {
2327
+ case I.ArrayExpression: return o = [], d(e.elements, function(e) {
2281
2328
  o.push(a.recurse(e));
2282
2329
  }), function(e, n, r, i) {
2283
2330
  for (var a = [], s = 0; s < o.length; ++s) a.push(o[s](e, n, r, i));
2284
2331
  return t ? { value: a } : a;
2285
2332
  };
2286
- case P.ObjectExpression: return o = [], d(e.properties, function(e) {
2333
+ case I.ObjectExpression: return o = [], d(e.properties, function(e) {
2287
2334
  e.computed ? o.push({
2288
2335
  key: a.recurse(e.key),
2289
2336
  computed: !0,
2290
2337
  value: a.recurse(e.value)
2291
2338
  }) : o.push({
2292
- key: e.key.type === P.Identifier ? e.key.name : "" + e.key.value,
2339
+ key: e.key.type === I.Identifier ? e.key.name : "" + e.key.value,
2293
2340
  computed: !1,
2294
2341
  value: a.recurse(e.value)
2295
2342
  });
@@ -2297,13 +2344,13 @@ var _e = /* @__PURE__ */ r(((e) => {
2297
2344
  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);
2298
2345
  return t ? { value: a } : a;
2299
2346
  };
2300
- case P.ThisExpression: return function(e) {
2347
+ case I.ThisExpression: return function(e) {
2301
2348
  return t ? { value: e } : e;
2302
2349
  };
2303
- case P.LocalsExpression: return function(e, n) {
2350
+ case I.LocalsExpression: return function(e, n) {
2304
2351
  return t ? { value: n } : n;
2305
2352
  };
2306
- case P.NGValueParameter: return function(e, n, r) {
2353
+ case I.NGValueParameter: return function(e, n, r) {
2307
2354
  return t ? { value: r } : r;
2308
2355
  };
2309
2356
  }
@@ -2328,7 +2375,7 @@ var _e = /* @__PURE__ */ r(((e) => {
2328
2375
  },
2329
2376
  "binary+": function(e, t, n) {
2330
2377
  return function(r, i, a, o) {
2331
- var s = ie(e(r, i, a, o), t(r, i, a, o));
2378
+ var s = R(e(r, i, a, o), t(r, i, a, o));
2332
2379
  return n ? { value: s } : s;
2333
2380
  };
2334
2381
  },
@@ -2452,7 +2499,7 @@ var _e = /* @__PURE__ */ r(((e) => {
2452
2499
  computedMember: function(e, t, n, r) {
2453
2500
  return function(i, a, o, s) {
2454
2501
  var c = e(i, a, o, s), l, u;
2455
- 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 ? {
2502
+ return c != null && (l = t(i, a, o, s), l = N(l), r && r !== 1 && c && !c[l] && (c[l] = {}), Object.prototype.hasOwnProperty.call(c, l) && (u = c[l])), n ? {
2456
2503
  context: c,
2457
2504
  name: l,
2458
2505
  value: u
@@ -2480,17 +2527,17 @@ var _e = /* @__PURE__ */ r(((e) => {
2480
2527
  /**
2481
2528
  * @constructor
2482
2529
  */
2483
- var V = function(e, t, n) {
2484
- this.lexer = e, this.$filter = t, n = n || {}, n.handleThis = n.handleThis == null ? !0 : n.handleThis, this.options = n, this.ast = new P(e, n), this.ast.selfReferential = { $locals: { type: P.LocalsExpression } }, n.handleThis && (this.ast.selfReferential.this = { type: P.ThisExpression }), this.astCompiler = n.csp ? new se(this.ast, t) : new B(this.ast, t);
2530
+ var W = function(e, t, n) {
2531
+ this.lexer = e, this.$filter = t, n = n || {}, n.handleThis = n.handleThis == null ? !0 : n.handleThis, this.options = n, this.ast = new I(e, n), this.ast.selfReferential = { $locals: { type: I.LocalsExpression } }, n.handleThis && (this.ast.selfReferential.this = { type: I.ThisExpression }), this.astCompiler = n.csp ? new U(this.ast, t) : new ie(this.ast, t);
2485
2532
  };
2486
- V.prototype = {
2487
- constructor: V,
2533
+ W.prototype = {
2534
+ constructor: W,
2488
2535
  parse: function(e) {
2489
2536
  return this.astCompiler.compile(e);
2490
2537
  }
2491
- }, e.Lexer = N, e.Parser = V;
2492
- })), ve = (/* @__PURE__ */ r(((e) => {
2493
- var t = _e(), n = {}, r = t.Lexer, i = t.Parser;
2538
+ }, e.Lexer = F, e.Parser = W;
2539
+ })), we = (/* @__PURE__ */ s(((e) => {
2540
+ var t = Ce(), n = {}, r = t.Lexer, i = t.Parser;
2494
2541
  function a(e) {
2495
2542
  return e = e || {}, e.filters && (e.cache = e.cache || {}), e.cache = e.cache || s.cache, e.filters = e.filters || n, e;
2496
2543
  }
@@ -2528,7 +2575,7 @@ var _e = /* @__PURE__ */ r(((e) => {
2528
2575
  s.cache = Object.create(null), e.compile = s;
2529
2576
  })))();
2530
2577
  /** Cleans deeds the way puzzmo.com's PlayGameIframe and the API's `getDeedsFromCompletion` do, collecting what was dropped. */
2531
- const ye = (e, t) => {
2578
+ const Te = (e, t) => {
2532
2579
  let n = [];
2533
2580
  e !== void 0 && !Array.isArray(e) && n.push("deeds is not an array, the host ignores it");
2534
2581
  let r = [];
@@ -2562,17 +2609,17 @@ const ye = (e, t) => {
2562
2609
  })),
2563
2610
  warnings: n
2564
2611
  };
2565
- }, be = (e) => {
2612
+ }, Ee = (e) => {
2566
2613
  let t = {};
2567
- for (let n of e) n.value !== void 0 && (t[Ce(n.id)] = n.value);
2614
+ for (let n of e) n.value !== void 0 && (t[ke(n.id)] = n.value);
2568
2615
  return t;
2569
- }, xe = (e, t) => {
2616
+ }, De = (e, t) => {
2570
2617
  try {
2571
- if (e.filterExp && !(0, ve.compile)(e.filterExp)(t) || !e.incrementExp) return {
2618
+ if (e.filterExp && !(0, we.compile)(e.filterExp)(t) || !e.incrementExp) return {
2572
2619
  complete: !1,
2573
2620
  value: 0
2574
2621
  };
2575
- let n = (0, ve.compile)(e.incrementExp)(t);
2622
+ let n = (0, we.compile)(e.incrementExp)(t);
2576
2623
  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}`);
2577
2624
  let r = Math.floor(n);
2578
2625
  return {
@@ -2586,17 +2633,17 @@ const ye = (e, t) => {
2586
2633
  error: e.message
2587
2634
  };
2588
2635
  }
2589
- }, Se = (e) => {
2636
+ }, Oe = (e) => {
2590
2637
  let { items: t, scope: n, mode: r } = e, i = Math.min(Math.max(e.index, 0), t.length), a;
2591
- for (; i < t.length && (a = xe(t[i], n), !(!a.complete || r === "checkpoint" && !t[i].liveUpdate)); i++);
2638
+ for (; i < t.length && (a = De(t[i], n), !(!a.complete || r === "checkpoint" && !t[i].liveUpdate)); i++);
2592
2639
  return {
2593
2640
  index: i,
2594
2641
  head: i < t.length ? a : void 0
2595
2642
  };
2596
2643
  };
2597
- var Ce = (e) => e.replace(/-./g, (e) => e[1].toUpperCase());
2644
+ var ke = (e) => e.replace(/-./g, (e) => e[1].toUpperCase());
2598
2645
  /** A minimal take on puzzmo.com's tutorial checklist, driven by deeds from checkpoints and completion. */
2599
- function we(e) {
2646
+ function Ae(e) {
2600
2647
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = null, i = 0, a, o = [], s = (e) => {
2601
2648
  var t;
2602
2649
  return `simulator-checklist:${(t = r) == null ? "game" : t}:${e}`;
@@ -2620,15 +2667,15 @@ function we(e) {
2620
2667
  t.liveUpdate ? "liveUpdate: checkpoints + completion" : "completion only"
2621
2668
  ].filter(Boolean).join("\n");
2622
2669
  return `${e.instructionsVisibleFromItemIndex === r && r > 0 ? "<div class=\"checklist-divider\"><span>full instructions unlock</span></div>" : ""}
2623
- <div class="checklist-item ${o}" title="${K(f)}">
2670
+ <div class="checklist-item ${o}" title="${q(f)}">
2624
2671
  <div class="checklist-row">
2625
2672
  <span class="checklist-tick">${o === "done" ? "■" : "□"}</span>
2626
- <span class="checklist-title">${K((a = t.title) == null ? `Step ${r + 1}` : a)}</span>
2673
+ <span class="checklist-title">${q((a = t.title) == null ? `Step ${r + 1}` : a)}</span>
2627
2674
  ${d ? `<span class="checklist-count">${d}</span>` : ""}
2628
- ${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${K(s)}">?</button>` : ""}
2675
+ ${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${q(s)}">?</button>` : ""}
2629
2676
  </div>
2630
- ${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${K(t.subtitle)}</div>` : ""}
2631
- ${l && c ? `<pre class="checklist-expand">${K(t.expandMD)}</pre>` : ""}
2677
+ ${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${q(t.subtitle)}</div>` : ""}
2678
+ ${l && c ? `<pre class="checklist-expand">${q(t.expandMD)}</pre>` : ""}
2632
2679
  </div>`;
2633
2680
  }, d = (e) => {
2634
2681
  var n, r, i, s;
@@ -2638,24 +2685,24 @@ function we(e) {
2638
2685
  <div class="checklist-header">
2639
2686
  <span class="simulator-label">Checklist</span>
2640
2687
  <span class="checklist-progress${d === l ? " complete" : ""}">${d}/${l}</span>
2641
- <button class="simulator-btn subtle small" data-reset="${K(e.stableID)}">Reset</button>
2688
+ <button class="simulator-btn subtle small" data-reset="${q(e.stableID)}">Reset</button>
2642
2689
  </div>
2643
2690
  <div class="checklist-items">
2644
2691
  ${e.items.map((t, n) => u(e, t, n, c)).join("")}
2645
2692
  </div>
2646
- ${a ? `<div class="checklist-footer">last eval: ${K(a)}</div>` : ""}
2647
- ${f ? `<div class="checklist-error">${K(f)}</div>` : ""}
2648
- ${o.map((e) => `<div class="checklist-error">${K(e)}</div>`).join("")}
2693
+ ${a ? `<div class="checklist-footer">last eval: ${q(a)}</div>` : ""}
2694
+ ${f ? `<div class="checklist-error">${q(f)}</div>` : ""}
2695
+ ${o.map((e) => `<div class="checklist-error">${q(e)}</div>`).join("")}
2649
2696
  </div>`;
2650
2697
  }, 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) => {
2651
2698
  let t = e.getElement("#simulator-checklist-list");
2652
2699
  t && (t.innerHTML = f());
2653
2700
  }, m = (n, r, s, c) => {
2654
- let u = 0, d = ye(r, s), f = be(d.deeds);
2701
+ let u = 0, d = Te(r, s), f = Ee(d.deeds);
2655
2702
  a = c, o = d.warnings;
2656
2703
  for (let n of e) {
2657
2704
  var m, h;
2658
- let e = (m = (h = t.get(n.stableID)) == null ? void 0 : h.index) == null ? 0 : m, r = Se({
2705
+ let e = (m = (h = t.get(n.stableID)) == null ? void 0 : h.index) == null ? 0 : m, r = Oe({
2659
2706
  items: n.items,
2660
2707
  index: e,
2661
2708
  scope: f,
@@ -2693,9 +2740,9 @@ function we(e) {
2693
2740
  }
2694
2741
  };
2695
2742
  }
2696
- var K = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
2743
+ var q = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
2697
2744
  /** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
2698
- function Te() {
2745
+ function je() {
2699
2746
  let e = globalThis;
2700
2747
  for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
2701
2748
  name: t,
@@ -2704,26 +2751,23 @@ function Te() {
2704
2751
  return null;
2705
2752
  }
2706
2753
  /** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
2707
- function Ee() {
2754
+ function Me() {
2708
2755
  let e = globalThis.getShareString;
2709
2756
  return typeof e == "function" ? e : null;
2710
2757
  }
2711
- function De(e) {
2758
+ function Ne(e) {
2712
2759
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2713
2760
  }
2714
- function Oe() {
2761
+ function Pe() {
2715
2762
  let e = /* @__PURE__ */ new Date();
2716
2763
  return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
2717
2764
  }
2718
- function ke(e) {
2765
+ function Fe(e) {
2719
2766
  return e.charAt(0).toUpperCase() + e.slice(1);
2720
2767
  }
2721
2768
  /** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
2722
- var Ae = "\n <div class=\"simulator-share-missing\">\n <p>The app bundle doesn't export <code>getShareString</code>.</p>\n <p>Add it to your app bundle to preview share strings here:</p>\n <pre>export const getShareString: AppBundle[\"getShareString\"] = (\n inputStr, title, { puzzleString, dateKey, gameplaySlug },\n) =&gt; ({ str: `${title}: ...` })</pre>\n </div>\n";
2723
- function je() {
2724
- let e, t, r = () => {
2725
- e == null || e.dispose(), e = void 0, t = void 0;
2726
- };
2769
+ var Ie = "\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";
2770
+ function Le() {
2727
2771
  return {
2728
2772
  id: "thumb",
2729
2773
  label: "Thumb",
@@ -2745,64 +2789,776 @@ function je() {
2745
2789
  o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
2746
2790
  t.addEventListener("click", () => {
2747
2791
  let n = t.dataset.previewKind;
2748
- !n || n === e.state.previewKind || (e.state.previewKind = n, j(n), c(), s(), e.updateThumbnail());
2792
+ !n || n === e.state.previewKind || (e.state.previewKind = n, B(n), c(), s(), e.updateThumbnail());
2749
2793
  });
2750
- }), n && (e.state.renderHost || (e.state.renderHost = "game", A(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
2751
- e.state.renderHost = n.value, A(e.state.renderHost), s(), e.updateThumbnail();
2752
- })), r && (e.state.renderContext || (e.state.renderContext = "preview", M(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
2753
- e.state.renderContext = r.value, M(e.state.renderContext), e.updateThumbnail();
2794
+ }), n && (e.state.renderHost || (e.state.renderHost = "game", z(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
2795
+ e.state.renderHost = n.value, z(e.state.renderHost), s(), e.updateThumbnail();
2796
+ })), r && (e.state.renderContext || (e.state.renderContext = "preview", V(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
2797
+ e.state.renderContext = r.value, V(e.state.renderContext), e.updateThumbnail();
2754
2798
  })), c(), s();
2755
2799
  },
2756
2800
  onActivate(e) {
2757
2801
  setTimeout(() => e.updateThumbnail(), 0);
2758
2802
  },
2759
- updatePreview: (i) => {
2760
- let a = i.getElement("#simulator-thumb-preview"), o = i.getElement("#simulator-thumb-fn");
2761
- if (a == null || a.style.setProperty("--sim-thumb-bg", i.state.selectedTheme.g_bg), i.state.previewKind === "text") {
2762
- r();
2763
- let e = Ee();
2764
- if (!e) {
2765
- a && (a.innerHTML = Ae), o && (o.textContent = "");
2803
+ updatePreview: (e) => {
2804
+ let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
2805
+ if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
2806
+ let s = Me();
2807
+ if (!s) {
2808
+ t && (t.innerHTML = Ie), n && (n.textContent = "");
2766
2809
  return;
2767
2810
  }
2768
- o && (o.textContent = "Using: getShareString()");
2811
+ n && (n.textContent = "Using: getShareString()");
2769
2812
  try {
2770
- var s, c, l, u;
2771
- let t = (s = i.gameSlug) == null ? "game" : s, n = e((c = i.state.currentInputStr) == null ? "" : c, ke(t), {
2772
- puzzleString: (l = i.state.puzzleData) == null ? "" : l,
2773
- dateKey: Oe(),
2774
- gameplaySlug: `simulator:${t}`
2775
- }), r = (u = n == null ? void 0 : n.str) == null ? "" : u;
2776
- a && (a.innerHTML = `<pre class="simulator-share-preview" style="color: ${i.state.selectedTheme.fg}">${De(r)}</pre>`);
2813
+ var r, i, a, o;
2814
+ let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, Fe(n), {
2815
+ puzzleString: (a = e.state.puzzleData) == null ? "" : a,
2816
+ dateKey: Pe(),
2817
+ gameplaySlug: `simulator:${n}`
2818
+ }), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
2819
+ t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${Ne(l)}</pre>`);
2777
2820
  } catch (e) {
2778
- console.error("Simulator: Share string error", e), a && (a.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2821
+ console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2779
2822
  }
2780
2823
  return;
2781
2824
  }
2782
- let d = Te();
2783
- if (!d) {
2784
- r(), a && (a.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), o && (o.textContent = "");
2825
+ let s = je();
2826
+ if (!s) {
2827
+ t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
2785
2828
  return;
2786
2829
  }
2787
- o && (o.textContent = `Using: ${d.name}()`);
2830
+ n && (n.textContent = `Using: ${s.name}()`);
2788
2831
  try {
2789
- var f;
2790
- let o = (f = i.state.puzzleData) == null ? "" : f, s = {
2832
+ var c;
2833
+ let n = (c = e.state.puzzleData) == null ? "" : c, r = {
2791
2834
  viewerIsOwner: !0,
2792
- theme: i.state.selectedTheme,
2835
+ theme: e.state.selectedTheme,
2793
2836
  strict: !0,
2794
- renderHost: i.state.renderHost,
2795
- renderContext: i.state.renderContext
2796
- }, { svg: c } = R(d.fn(o, i.state.currentInputStr, s));
2797
- a && ((!e || t !== a) && (r(), a.innerHTML = "", e = n(a), t = a), e.show(c));
2837
+ renderHost: e.state.renderHost,
2838
+ renderContext: e.state.renderContext
2839
+ }, { svg: i } = se(s.fn(n, e.state.currentInputStr, r));
2840
+ t && (t.innerHTML = i);
2798
2841
  } catch (e) {
2799
- console.error("Simulator: Thumbnail error", e), r(), a && (a.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2842
+ console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
2800
2843
  }
2801
2844
  }
2802
2845
  };
2803
2846
  }
2847
+ var J = {
2848
+ bounds: "#ffd700",
2849
+ grid: "rgba(96, 165, 250, 0.35)",
2850
+ box: "rgba(34, 211, 238, 0.85)",
2851
+ exiting: "#f87171",
2852
+ hovered: "#ffd700",
2853
+ highlighted: "#f472b6",
2854
+ anchor: "#f472b6",
2855
+ group: "#a78bfa",
2856
+ label: "#e8e8e8",
2857
+ labelBackground: "rgba(15, 15, 26, 0.8)"
2858
+ };
2859
+ /** Draws the overlay over the frame the board just drew, in its canvas's device pixels */
2860
+ const Re = (e, t) => {
2861
+ let { ctx: n, scale: r, scene: i, nodes: a } = e, o = t.devicePixelRatio, s = ([e, t]) => [e * r, t * r];
2862
+ if (n.save(), n.lineWidth = o, t.grid && i.grid && i.width / i.grid + i.height / i.grid <= 400) {
2863
+ n.strokeStyle = J.grid, n.beginPath();
2864
+ for (let e = i.grid; e < i.width; e += i.grid) {
2865
+ let t = Math.round(e * r) + o / 2;
2866
+ n.moveTo(t, 0), n.lineTo(t, i.height * r);
2867
+ }
2868
+ for (let e = i.grid; e < i.height; e += i.grid) {
2869
+ let t = Math.round(e * r) + o / 2;
2870
+ n.moveTo(0, t), n.lineTo(i.width * r, t);
2871
+ }
2872
+ n.stroke();
2873
+ }
2874
+ t.bounds && (n.strokeStyle = J.bounds, n.setLineDash([4 * o, 3 * o]), n.strokeRect(o / 2, o / 2, i.width * r - o, i.height * r - o), n.setLineDash([]));
2875
+ for (let e of a) {
2876
+ let r = e.sprite ? t.boxOf(e.sprite) : void 0, i = e.key === t.hovered, a = !!e.sprite && e.sprite === t.highlighted;
2877
+ if (r && (t.boxes || i || a)) {
2878
+ let t = ze(e.matrix, r).map(s);
2879
+ n.strokeStyle = i ? J.hovered : a ? J.highlighted : e.exiting ? J.exiting : J.box, n.lineWidth = (i || a ? 2 : 1) * o, n.setLineDash(e.alpha <= 0 ? [3 * o, 3 * o] : []), n.beginPath(), t.forEach(([e, t], r) => r ? n.lineTo(e, t) : n.moveTo(e, t)), n.closePath(), n.stroke(), n.setLineDash([]), n.lineWidth = o;
2880
+ }
2881
+ if (t.anchors) {
2882
+ let [t, i] = s(Ve(e.matrix, [0, 0]));
2883
+ r ? (n.fillStyle = J.anchor, n.fillRect(t - 1.5 * o, i - 1.5 * o, 3 * o, 3 * o)) : (n.strokeStyle = J.group, n.beginPath(), n.moveTo(t, i - 4 * o), n.lineTo(t + 4 * o, i), n.lineTo(t, i + 4 * o), n.lineTo(t - 4 * o, i), n.closePath(), n.stroke());
2884
+ }
2885
+ }
2886
+ if (t.keys) {
2887
+ n.font = `${9 * o}px Menlo, Monaco, monospace`, n.textBaseline = "top";
2888
+ for (let e of a) {
2889
+ let r = e.sprite ? t.boxOf(e.sprite) : void 0, [i, a] = r ? Ue(ze(e.matrix, r).map(s)) : s(Ve(e.matrix, [0, 0])), c = n.measureText(e.key).width;
2890
+ n.fillStyle = J.labelBackground, n.fillRect(i, a, c + 4 * o, 11 * o), n.fillStyle = J.label, n.fillText(e.key, i + 2 * o, a + o);
2891
+ }
2892
+ }
2893
+ n.restore();
2894
+ }, ze = (e, t) => {
2895
+ let [n, r] = t.anchor;
2896
+ return [
2897
+ [-n, -r],
2898
+ [t.width - n, -r],
2899
+ [t.width - n, t.height - r],
2900
+ [-n, t.height - r]
2901
+ ].map((t) => Ve(e, t));
2902
+ }, Be = (e, t, n) => {
2903
+ for (let r = e.length - 1; r >= 0; r--) {
2904
+ let i = e[r];
2905
+ if (!i.sprite || i.alpha <= 0) continue;
2906
+ let a = n(i.sprite), o = a && He(i.matrix, t);
2907
+ if (!a || !o) continue;
2908
+ let s = o[0] + a.anchor[0], c = o[1] + a.anchor[1];
2909
+ if (s >= 0 && c >= 0 && s <= a.width && c <= a.height) return i;
2910
+ }
2911
+ return null;
2912
+ };
2913
+ var Ve = (e, [t, n]) => [e[0] * t + e[2] * n + e[4], e[1] * t + e[3] * n + e[5]], He = (e, [t, n]) => {
2914
+ let r = e[0] * e[3] - e[1] * e[2];
2915
+ if (Math.abs(r) < 1e-12) return null;
2916
+ let i = t - e[4], a = n - e[5];
2917
+ return [(e[3] * i - e[2] * a) / r, (-e[1] * i + e[0] * a) / r];
2918
+ }, Ue = (e) => [Math.min(...e.map((e) => e[0])), Math.min(...e.map((e) => e[1]))];
2919
+ /** Runs a table capability the way Puzzmo's sandbox does, keeping every sprite and what each render did */
2920
+ const We = (i, a = {}) => {
2921
+ var o, s;
2922
+ let c = (o = a.rasterise) == null ? Je : o, l = (s = a.fontFaces) == null ? "" : s, u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Set(), p = 0, m = !1, h = null, g = (e) => {
2923
+ _.warnings.includes(e) || _.warnings.push(e);
2924
+ }, _ = {
2925
+ render: function() {
2926
+ var a = t(function* (t) {
2927
+ let a = t.pixelsPerUnit, o = {
2928
+ render: ++p,
2929
+ update: t,
2930
+ renderMs: 0,
2931
+ spritesMs: 0,
2932
+ made: []
2933
+ };
2934
+ _.latest = o;
2935
+ let s = "render";
2936
+ try {
2937
+ var v, y;
2938
+ m && d.clear(), m = !1;
2939
+ let p = (v = d.get(a)) == null ? d.set(a, /* @__PURE__ */ new Set()).get(a) : v, _ = (y = u.get(a)) == null ? u.set(a, /* @__PURE__ */ new Map()).get(a) : y, x = /* @__PURE__ */ new Map(), S = [], C = [], w = [], T = (e, t, n) => {
2940
+ var r;
2941
+ let i = `${a}|${e}`, o = _.get(e), s = (r = x.get(e)) == null ? o && {
2942
+ box: o,
2943
+ svg: o.svg
2944
+ } : r;
2945
+ if (!s || f.has(i)) return;
2946
+ f.add(i);
2947
+ let c;
2948
+ try {
2949
+ c = Xe(t);
2950
+ } catch (e) {
2951
+ return;
2952
+ }
2953
+ c.width === s.box.width && c.height === s.box.height && c.anchor[0] === s.box.anchor[0] && c.anchor[1] === s.box.anchor[1] ? n !== void 0 && s.svg !== void 0 && n !== s.svg && g(`"${e}" was made again with different SVG. Puzzmo keeps the first, so put what differs into the ID`) : g(`"${e}" was made again with a different box. Puzzmo keeps the first, so put what differs into the ID`);
2954
+ }, E = {
2955
+ has: (e) => p.has(e) || x.has(e),
2956
+ draw(t, n, r) {
2957
+ if (E.has(t)) return T(t, n);
2958
+ let i = Xe(n);
2959
+ h != null || (h = new OffscreenCanvas(1, 1)), h.width = Math.max(1, Math.ceil(i.width * a)), h.height = Math.max(1, Math.ceil(i.height * a));
2960
+ let s = h.getContext("2d");
2961
+ s.setTransform(a, 0, 0, a, 0, 0), r(s), x.set(t, { box: i }), S.push(e(e({
2962
+ id: t,
2963
+ kind: "draw",
2964
+ bitmap: h.transferToImageBitmap()
2965
+ }, i), {}, {
2966
+ pixelsPerUnit: a,
2967
+ render: o.render
2968
+ }));
2969
+ },
2970
+ svg(e, t, n, r) {
2971
+ if (E.has(e)) return T(e, t, String(n));
2972
+ let i = Xe(t), a = r ? String(r) : "", o = w.indexOf(a);
2973
+ o < 0 && (o = w.push(a) - 1), x.set(e, {
2974
+ box: i,
2975
+ svg: String(n)
2976
+ }), C.push({
2977
+ id: e,
2978
+ box: i,
2979
+ svg: String(n),
2980
+ defs: o
2981
+ });
2982
+ }
2983
+ }, D = performance.now(), O = i.render(t, E);
2984
+ if (o.renderMs = performance.now() - D, O && typeof O.then == "function") throw Error("render returned a Promise. Puzzmo's sandbox doesn't wait for one, so build the scene and return it");
2985
+ for (let e of x.keys()) p.add(e);
2986
+ try {
2987
+ O = structuredClone(O);
2988
+ } catch (e) {
2989
+ throw Error(`The scene can't leave the sandbox: ${Qe(e)}`);
2990
+ }
2991
+ o.raw = O, s = "sprites";
2992
+ let k = performance.now(), A = C.length ? yield c(C, w, a, l) : [];
2993
+ o.spritesMs = performance.now() - k;
2994
+ for (let { id: t, bitmap: n } of A) {
2995
+ let r = C.find((e) => e.id === t);
2996
+ S.push(e(e({
2997
+ id: t,
2998
+ kind: "svg",
2999
+ bitmap: n
3000
+ }, r.box), {}, {
3001
+ svg: r.svg,
3002
+ pixelsPerUnit: a,
3003
+ render: o.render
3004
+ }));
3005
+ }
3006
+ for (let e of S) {
3007
+ var b;
3008
+ (b = _.get(e.id)) == null || b.bitmap.close(), _.set(e.id, e);
3009
+ }
3010
+ o.made = S.map((e) => e.id), s = "scene";
3011
+ let j = n(O), M = [...r(j)].filter((e) => !_.has(e));
3012
+ if (M.length) throw Error(`The scene names sprites it never made: ${M.slice(0, 5).join(", ")}`);
3013
+ return o.scene = j, j;
3014
+ } catch (e) {
3015
+ throw m = !0, o.error = {
3016
+ phase: s,
3017
+ message: Qe(e),
3018
+ stack: e instanceof Error ? e.stack : void 0
3019
+ }, e;
3020
+ } finally {
3021
+ var x;
3022
+ (x = _.onRender) == null || x.call(_, o);
3023
+ }
3024
+ });
3025
+ return function(e) {
3026
+ return a.apply(this, arguments);
3027
+ };
3028
+ }(),
3029
+ sprite: (e, t) => {
3030
+ var n;
3031
+ return (n = u.get(t)) == null ? void 0 : n.get(e);
3032
+ },
3033
+ spritesAt: (e) => {
3034
+ var t, n;
3035
+ return [...(t = (n = u.get(e)) == null ? void 0 : n.values()) == null ? [] : t];
3036
+ },
3037
+ anySprite: (e) => {
3038
+ let t;
3039
+ for (let n of u.values()) {
3040
+ let r = n.get(e);
3041
+ r && (!t || r.render > t.render) && (t = r);
3042
+ }
3043
+ return t;
3044
+ },
3045
+ resolutions: () => [...u.keys()],
3046
+ warnings: [],
3047
+ latest: null,
3048
+ clear() {
3049
+ for (let e of u.values()) for (let t of e.values()) t.bitmap.close();
3050
+ u.clear(), d.clear(), f.clear(), _.warnings.length = 0;
3051
+ }
3052
+ };
3053
+ return _;
3054
+ }, Ge = function() {
3055
+ var e = t(function* (e) {
3056
+ let t = [], n = [], r = Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
3057
+ for (let e of r) {
3058
+ if (!o.includes(e)) {
3059
+ t.push(`fonts names "${e}", which isn't a Puzzmo font, so the table won't load it`);
3060
+ continue;
3061
+ }
3062
+ try {
3063
+ let t = yield fetch(a(e));
3064
+ if (!t.ok) throw Error(`the CDN answered ${t.status}`);
3065
+ let r = yield t.arrayBuffer();
3066
+ document.fonts.add(yield new FontFace(e, r.slice(0)).load()), n.push(`@font-face{font-family:"${e.replace(/["\\]/g, "")}";src:url(data:font/woff2;base64,${Ze(r)})}`);
3067
+ } catch (n) {
3068
+ t.push(`The font ${e} didn't load: ${Qe(n)}`);
3069
+ }
3070
+ }
3071
+ return {
3072
+ fontFaces: n.join(""),
3073
+ warnings: t
3074
+ };
3075
+ });
3076
+ return function(t) {
3077
+ return e.apply(this, arguments);
3078
+ };
3079
+ }();
3080
+ /** At most this many sprites in one sheet, and a sheet no wider than this, as in the sandbox's frame */
3081
+ var Ke = 64, qe = 4096;
3082
+ /**
3083
+ * SVG sprites as bitmaps, many to one SVG sheet so each sheet decodes its fonts and shared definitions once. When a
3084
+ * sheet won't decode, each of its sprites is tried alone so the error can name the broken ones.
3085
+ */
3086
+ const Je = function() {
3087
+ var e = t(function* (e, t, n, r) {
3088
+ var i;
3089
+ let a = [], o = /* @__PURE__ */ new Map();
3090
+ for (let t of e) o.set(t.defs, [...(i = o.get(t.defs)) == null ? [] : i, t]);
3091
+ for (let [e, i] of o) for (let o = 0; o < i.length; o += Ke) {
3092
+ let s = i.slice(o, o + Ke);
3093
+ try {
3094
+ a.push(...yield Ye(s, t[e], n, r));
3095
+ } catch (i) {
3096
+ let a = [];
3097
+ for (let i of s) yield Ye([i], t[e], n, r).catch(() => a.push(i.id));
3098
+ let o = a.length ? `${a.slice(0, 5).join(", ")} won't decode` : Qe(i);
3099
+ throw Error(`An SVG sprite couldn't be drawn: ${o}`);
3100
+ }
3101
+ }
3102
+ return a;
3103
+ });
3104
+ return function(t, n, r, i) {
3105
+ return e.apply(this, arguments);
3106
+ };
3107
+ }();
3108
+ var Ye = function() {
3109
+ var e = t(function* (e, t, n, r) {
3110
+ let i = 0, a = 0, o = 0, s = 1, c = e.map((e) => {
3111
+ let t = Math.max(1, Math.ceil(e.box.width * n)), r = Math.max(1, Math.ceil(e.box.height * n));
3112
+ i > 0 && i + t > qe && (i = 0, a += o + 1, o = 0);
3113
+ let c = {
3114
+ sprite: e,
3115
+ x: i,
3116
+ y: a,
3117
+ w: t,
3118
+ h: r
3119
+ };
3120
+ return i += t + 1, s = Math.max(s, i), o = Math.max(o, r), c;
3121
+ }), l = a + o, u = c.map(({ sprite: e, x: t, y: n, w: r, h: i }) => `<svg x="${t}" y="${n}" width="${r}" height="${i}" viewBox="0 0 ${e.box.width} ${e.box.height}" preserveAspectRatio="none" overflow="hidden">${e.svg}</svg>`).join(""), d = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${s}" height="${l}" viewBox="0 0 ${s} ${l}"><style>${r}</style>${t}${u}</svg>`, f = URL.createObjectURL(new Blob([d], { type: "image/svg+xml" }));
3122
+ try {
3123
+ let e = new Image();
3124
+ e.src = f, yield e.decode();
3125
+ let t = [];
3126
+ for (let n of c) t.push({
3127
+ id: n.sprite.id,
3128
+ bitmap: yield createImageBitmap(e, n.x, n.y, n.w, n.h)
3129
+ });
3130
+ return t;
3131
+ } finally {
3132
+ URL.revokeObjectURL(f);
3133
+ }
3134
+ });
3135
+ return function(t, n, r, i) {
3136
+ return e.apply(this, arguments);
3137
+ };
3138
+ }(), Xe = (e) => {
3139
+ let t = e, n = Number(t == null ? void 0 : t.width), r = Number(t == null ? void 0 : t.height);
3140
+ if (!(n > 0 && r > 0 && n < 1e4 && r < 1e4)) throw Error(`A sprite's box must have a positive width and height, got ${JSON.stringify(e)}`);
3141
+ return {
3142
+ width: n,
3143
+ height: r,
3144
+ anchor: Array.isArray(t.anchor) ? [Number(t.anchor[0]), Number(t.anchor[1])] : [n / 2, r / 2]
3145
+ };
3146
+ }, Ze = (e) => {
3147
+ let t = new Uint8Array(e), n = "";
3148
+ for (let e = 0; e < t.length; e += 32768) n += String.fromCharCode(...t.subarray(e, e + 32768));
3149
+ return btoa(n);
3150
+ }, Qe = (e) => e instanceof Error ? e.message : String(e), $e = [
3151
+ [
3152
+ "bounds",
3153
+ "Bounds",
3154
+ "The scene's width and height"
3155
+ ],
3156
+ [
3157
+ "grid",
3158
+ "Grid",
3159
+ "Lines every grid step, for a scene that sets grid"
3160
+ ],
3161
+ [
3162
+ "boxes",
3163
+ "Boxes",
3164
+ "Each sprite's box, as it's turned and scaled"
3165
+ ],
3166
+ [
3167
+ "anchors",
3168
+ "Anchors",
3169
+ "Each node's anchor; hollow for a node with no sprite"
3170
+ ],
3171
+ [
3172
+ "keys",
3173
+ "Keys",
3174
+ "Each node's key"
3175
+ ]
3176
+ ], et = {
3177
+ render: "render threw",
3178
+ sprites: "A sprite couldn't be made",
3179
+ scene: "Puzzmo would refuse this scene"
3180
+ };
3181
+ /**
3182
+ * The Pmmg tab, shown when the game has a pmmg bundle: its table board drawn by Puzzmo's own renderer as the game is
3183
+ * played, with a debug overlay, every sprite it has made, and the scene it returned
3184
+ */
3185
+ function tt(e) {
3186
+ let n = S(), a, o = null, s = !1, c = null, l = null, u, d = [], f = [], p = null, m = !1, h = null, g = null, _ = null, v = "session", y = null, b = [], x = !1, w = (e) => a.getElement(`#sim-pmmg-${e}`), T = () => ({
3187
+ bounds: n.bounds,
3188
+ grid: n.grid,
3189
+ boxes: n.boxes,
3190
+ anchors: n.anchors,
3191
+ keys: n.keys,
3192
+ boxOf: (e) => l == null ? void 0 : l.anySprite(e),
3193
+ hovered: g,
3194
+ highlighted: _,
3195
+ devicePixelRatio: window.devicePixelRatio || 1
3196
+ }), E = () => ({
3197
+ fidelity: n.fidelity,
3198
+ backgroundStyle: n.backgroundStyle === "theme" ? void 0 : n.backgroundStyle
3199
+ }), D = () => {
3200
+ if (b.length) return b[b.length - 1];
3201
+ let e = a.state.puzzleData;
3202
+ return e === null ? null : {
3203
+ puzzle: e,
3204
+ input: a.state.currentInputStr
3205
+ };
3206
+ }, O = function() {
3207
+ var n = t(function* () {
3208
+ c = null, s = !0, P();
3209
+ try {
3210
+ var t;
3211
+ let n = yield e(), r = (t = n == null ? void 0 : n.default) == null ? n : t, i = r == null ? void 0 : r.table;
3212
+ if (!i || typeof i.render != "function") {
3213
+ c = "The pmmg bundle has no table capability: export default createPmmgBundle({ table: { contract: 1, render } })";
3214
+ return;
3215
+ }
3216
+ u = i.contract, d = Array.isArray(i.fonts) ? i.fonts.filter((e) => typeof e == "string") : [];
3217
+ let a = yield Ge(i.fonts);
3218
+ f = a.warnings, u !== 1 && f.push(`contract is ${JSON.stringify(u)}, and Puzzmo knows contract 1`), l = We(i, { fontFaces: a.fontFaces }), l.onRender = () => P();
3219
+ } catch (e) {
3220
+ c = `The pmmg bundle didn't load: ${it(e)}`, o = null;
3221
+ } finally {
3222
+ s = !1;
3223
+ }
3224
+ });
3225
+ return function() {
3226
+ return n.apply(this, arguments);
3227
+ };
3228
+ }(), k = function() {
3229
+ var e = t(function* () {
3230
+ var e;
3231
+ yield (e = o) == null ? o = O() : e, l && !p ? A(!1) : x && n.follow && j(), P();
3232
+ });
3233
+ return function() {
3234
+ return e.apply(this, arguments);
3235
+ };
3236
+ }(), A = (e) => {
3237
+ let t = D(), n = w("canvas"), r = w("stage");
3238
+ if (!l || !t || !n || !r) return P();
3239
+ p == null || p.dispose(), m = !1, h = null, g = null;
3240
+ let o = new i(n, l, "simulator", () => {
3241
+ p === o && (m = !0, P());
3242
+ });
3243
+ p = o, o.onDrawn = (e) => {
3244
+ p === o && (h = e, Re(e, T()));
3245
+ }, o.resize(r.clientWidth, r.clientHeight), o.setLook(E()), o.setTheme(a.state.selectedTheme);
3246
+ let s = e ? b[b.length - 2] : void 0;
3247
+ s && o.update(s), o.update(t), x = !1, P();
3248
+ }, j = () => {
3249
+ let e = D();
3250
+ p && e && p.update(e), x = !1;
3251
+ }, M = (e) => {
3252
+ let t = b[b.length - 1];
3253
+ if (t && t.puzzle === e.puzzle && t.input === e.input) return;
3254
+ b.push(e), b.length > 2 && b.shift();
3255
+ let r = a.state.activeTab === "pmmg";
3256
+ r && l && !p ? A(!1) : n.follow && r && p ? p.update(e) : n.follow && (x = !0), N();
3257
+ }, N = () => {
3258
+ let e = w("replay");
3259
+ e && (e.disabled = !l || b.length < 2);
3260
+ }, P = () => {
3261
+ if (!a) return;
3262
+ ee(), N(), F(), I();
3263
+ let e = w("sprite-count"), t = l == null ? void 0 : l.latest;
3264
+ e && (e.textContent = t ? ` ${l.spritesAt(t.update.pixelsPerUnit).length}` : ""), n.subtab === "sprites" && L(), n.subtab === "scene" && te();
3265
+ }, ee = () => {
3266
+ let e = w("status");
3267
+ if (!e) return;
3268
+ if (c) return void (e.innerHTML = `<span class="pmmg-error">${X(c)}</span>`);
3269
+ if (!l) return void (e.textContent = s ? "Loading the pmmg bundle…" : "Open this tab to load the pmmg bundle");
3270
+ let t = v === "table" ? "Drawing what neighbours see: the game's UPDATE_TABLE_GAME_STATE" : "Drawing the session's puzzle and saves, as the game hasn't sent UPDATE_TABLE_GAME_STATE (sdk.table.updateGameState)", n = D() ? "" : "<div class=\"pmmg-dim\">Waiting for the game's first state</div>";
3271
+ e.innerHTML = `
3272
+ <div>table · contract ${X(String(u))} · fonts: ${X(d.join(", ") || "none")}</div>
3273
+ <div class="pmmg-dim">${X(t)}</div>${n}`;
3274
+ }, F = () => {
3275
+ var e, t;
3276
+ let n = w("stats"), r = l == null ? void 0 : l.latest;
3277
+ if (!n) return;
3278
+ if (!r) return void (n.textContent = "");
3279
+ let i = r.scene, a = [i && [
3280
+ `${Y(i.width)}×${Y(i.height)} units`,
3281
+ `${i.nodes.length} nodes`,
3282
+ `${(e = (t = i.effects) == null ? void 0 : t.length) == null ? 0 : e} effects`,
3283
+ i.grid && `grid ${Y(i.grid)}`
3284
+ ], [
3285
+ `render #${r.render}: ${Y(r.renderMs)} ms`,
3286
+ r.spritesMs && `${Y(r.spritesMs)} ms of SVG`,
3287
+ `made ${r.made.length}`,
3288
+ `${Y(r.update.pixelsPerUnit)} px/unit`,
3289
+ r.update.skipped && `${r.update.skipped} skipped`
3290
+ ]].filter((e) => !!e).map((e) => e.filter(Boolean).join(" · ")).map((e) => `<div>${X(e)}</div>`);
3291
+ matchMedia("(prefers-reduced-motion: reduce)").matches && a.push("<div class=\"pmmg-dim\">Reduced motion is on, so changes show at once, as they do at the table</div>"), n.innerHTML = a.join("");
3292
+ }, I = () => {
3293
+ var e;
3294
+ let t = w("problems");
3295
+ if (!t) return;
3296
+ let n = l == null ? void 0 : l.latest, r = [];
3297
+ if (n != null && n.error) {
3298
+ let e = n.error.stack && n.error.stack !== n.error.message ? n.error.stack : "";
3299
+ r.push(`<div class="pmmg-problem error"><b>${et[n.error.phase]}</b> ${X(n.error.message)}
3300
+ ${e ? `<details><summary>Stack</summary><pre class="pmmg-json">${X(e)}</pre></details>` : ""}</div>`);
3301
+ }
3302
+ m && r.push("<div class=\"pmmg-problem error\">The board stopped, as a neighbour's does after its renders fail. Redraw to start again.</div>");
3303
+ for (let t of [...f, ...(e = l == null ? void 0 : l.warnings) == null ? [] : e]) r.push(`<div class="pmmg-problem warn">${X(t)}</div>`);
3304
+ l && r.push("<div class=\"pmmg-problem note\">The bundle runs in this page here. At the table it runs in a worker with no DOM and no network, so anything that reaches for window, document or fetch only works here.</div>"), t.innerHTML = r.join("");
3305
+ }, L = () => {
3306
+ var e, t;
3307
+ let n = w("sprites"), i = w("sprite-summary");
3308
+ if (!n || !i) return;
3309
+ let a = l == null ? void 0 : l.latest;
3310
+ if (!l || !a) {
3311
+ n.replaceChildren(), i.textContent = l ? "Nothing rendered yet" : "", z([]);
3312
+ return;
3313
+ }
3314
+ let o = a.update.pixelsPerUnit, s = l.spritesAt(o).sort((e, t) => e.id.localeCompare(t.id)), c = a.scene ? r(a.scene) : null, u = ((e = (t = w("filter")) == null ? void 0 : t.value) == null ? "" : e).trim().toLowerCase(), d = u ? s.filter((e) => e.id.toLowerCase().includes(u)) : s, f = c ? s.filter((e) => !c.has(e.id)).length : 0, p = l.resolutions().filter((e) => e !== o);
3315
+ i.textContent = [
3316
+ `${s.length} at ${Y(o)} px/unit`,
3317
+ f && `${f} not in this scene`,
3318
+ p.length && `also made at ${p.map(Y).join(", ")}`,
3319
+ u && `${d.length} match`
3320
+ ].filter(Boolean).join(" · "), n.replaceChildren(...d.map((e) => R(e, c))), z(s);
3321
+ }, R = (e, t) => {
3322
+ let n = document.createElement("button");
3323
+ n.type = "button", n.className = `pmmg-sprite${t && !t.has(e.id) ? " unused" : ""}${e.id === _ ? " selected" : ""}`, n.title = `${e.id}\n${Y(e.width)}×${Y(e.height)} units, ${e.kind}${t && !t.has(e.id) ? ", not in this scene" : ""}`;
3324
+ let r = document.createElement("span");
3325
+ r.className = "pmmg-sprite-picture", r.append(nt(e, 72, 64));
3326
+ let i = document.createElement("span");
3327
+ i.className = "pmmg-sprite-id", i.textContent = e.id;
3328
+ let a = document.createElement("span");
3329
+ return a.className = "pmmg-sprite-meta", a.textContent = `${Y(e.width)}×${Y(e.height)} ${e.kind}`, n.append(r, i, a), n.addEventListener("click", () => V(_ === e.id ? null : e.id)), n;
3330
+ }, z = (e) => {
3331
+ var t, n;
3332
+ let r = w("detail");
3333
+ if (!r) return;
3334
+ let i = _ ? e.find((e) => e.id === _) : void 0;
3335
+ if (!i) return void (r.innerHTML = "");
3336
+ let a = B(i.id);
3337
+ r.innerHTML = `
3338
+ <div class="pmmg-detail">
3339
+ <div class="pmmg-detail-head">
3340
+ <span class="pmmg-detail-id">${X(i.id)}</span>
3341
+ <button class="simulator-btn tiny" type="button" data-pmmg-deselect>Close</button>
3342
+ </div>
3343
+ <div class="pmmg-detail-picture"></div>
3344
+ <dl class="pmmg-facts">
3345
+ <dt>Kind</dt><dd>${i.kind === "svg" ? "SVG markup" : "Drawn on a canvas"}</dd>
3346
+ <dt>Box</dt><dd>${Y(i.width)}×${Y(i.height)} units, anchor ${Y(i.anchor[0])}, ${Y(i.anchor[1])}</dd>
3347
+ <dt>Pixels</dt><dd>${i.bitmap.width}×${i.bitmap.height} at ${Y(i.pixelsPerUnit)} px/unit</dd>
3348
+ <dt>Made</dt><dd>render #${i.render}</dd>
3349
+ <dt>Used by</dt><dd>${a.length ? X(a.slice(0, 24).join(", ") + (a.length > 24 ? `, and ${a.length - 24} more` : "")) : "nothing in this scene"}</dd>
3350
+ </dl>
3351
+ ${i.svg ? `<details><summary>SVG, ${i.svg.length.toLocaleString()} characters</summary><pre class="pmmg-json">${X(i.svg)}</pre></details>` : ""}
3352
+ </div>`, (t = r.querySelector(".pmmg-detail-picture")) == null || t.append(nt(i, 300, 160)), (n = r.querySelector("[data-pmmg-deselect]")) == null || n.addEventListener("click", () => V(null));
3353
+ }, B = (e) => {
3354
+ var t, n;
3355
+ let r = l == null || (t = l.latest) == null ? void 0 : t.scene;
3356
+ if (!r) return [];
3357
+ let i = (t) => [t.enter, t.exit].some((t) => t == null ? void 0 : t.keyframes.some((t) => t.sprite === e)), a = r.nodes.filter((t) => t.sprite === e || i(t)).map((e) => e.key), o = ((n = r.effects) == null ? [] : n).filter((t) => t.keyframes.some((t) => t.sprite === e)).map((e) => `${e.key} (effect)`);
3358
+ return [...a, ...o];
3359
+ }, V = (e) => {
3360
+ _ = e, n.subtab === "sprites" && L(), p == null || p.redraw();
3361
+ }, te = () => {
3362
+ var e;
3363
+ let t = w("update"), n = w("scene"), r = l == null ? void 0 : l.latest;
3364
+ if (!(!t || !n)) {
3365
+ if (!r) {
3366
+ t.textContent = "", n.textContent = l ? "Nothing rendered yet" : "";
3367
+ return;
3368
+ }
3369
+ t.textContent = [
3370
+ `render #${r.render}`,
3371
+ `puzzle ${r.update.puzzle.length.toLocaleString()} chars`,
3372
+ `input ${r.update.input.length.toLocaleString()} chars`,
3373
+ r.update.previous ? "animating from the board before" : "first draw",
3374
+ `${r.update.skipped} skipped`,
3375
+ `${r.update.fidelity} fidelity on ${r.update.backgroundStyle}`,
3376
+ r.scene ? "as Puzzmo keeps it" : "as returned, since Puzzmo refused it"
3377
+ ].join(" · "), n.textContent = rt((e = r.scene) == null ? r.raw : e);
3378
+ }
3379
+ }, ne = () => {
3380
+ let e = w("root");
3381
+ e == null || e.querySelectorAll("[data-pmmg-subtab]").forEach((e) => {
3382
+ e.classList.toggle("active", e.dataset.pmmgSubtab === n.subtab);
3383
+ }), e == null || e.querySelectorAll("[data-pmmg-pane]").forEach((e) => {
3384
+ e.classList.toggle("active", e.dataset.pmmgPane === n.subtab);
3385
+ }), P();
3386
+ }, re = (e) => {
3387
+ let t = w("canvas");
3388
+ if (!t || !h) return null;
3389
+ let n = t.getBoundingClientRect();
3390
+ if (!n.width) return null;
3391
+ let r = t.width / n.width;
3392
+ return [(e.clientX - n.left) * r / h.scale, (e.clientY - n.top) * r / h.scale];
3393
+ }, H = (e) => {
3394
+ var t;
3395
+ let n = w("hover");
3396
+ if (!n) return;
3397
+ let r = e && h ? Be(h.nodes, e, (e) => l == null ? void 0 : l.anySprite(e)) : null, i = r ? h.scene.nodes.find((e) => e.key === r.key) : void 0, a = (t = r == null ? void 0 : r.key) == null ? null : t;
3398
+ if (a !== g && (g = a, p == null || p.redraw()), !e) return void (n.textContent = "Hover the board to see a node, click one to pick its sprite");
3399
+ if (!r) return void (n.textContent = `${Y(e[0])}, ${Y(e[1])}`);
3400
+ n.textContent = [
3401
+ r.key,
3402
+ r.sprite,
3403
+ i && `at ${Y(i.x)}, ${Y(i.y)}`,
3404
+ (i == null ? void 0 : i.rotation) && `${Y(i.rotation)}°`,
3405
+ (i == null ? void 0 : i.scale) && `scale ${i.scale.map(Y).join(", ")}`,
3406
+ (i == null ? void 0 : i.opacity) !== void 0 && `opacity ${Y(i.opacity)}`,
3407
+ (i == null ? void 0 : i.tint) && `tint ${i.tint}`,
3408
+ (i == null ? void 0 : i.brightness) !== void 0 && `brightness ${Y(i.brightness)}`,
3409
+ (i == null ? void 0 : i.blend) && i.blend !== "normal" && i.blend,
3410
+ (i == null ? void 0 : i.parent) && `in ${i.parent}`,
3411
+ r.exiting && "exiting"
3412
+ ].filter(Boolean).join(" · ");
3413
+ };
3414
+ return {
3415
+ id: "pmmg",
3416
+ label: "Pmmg",
3417
+ render() {
3418
+ return `
3419
+ <div class="pmmg-view pmmg-backdrop-${n.backdrop}" id="sim-pmmg-root">
3420
+ <div class="pmmg-status" id="sim-pmmg-status">Open this tab to load the pmmg bundle</div>
3421
+ <div class="data-subtabs">
3422
+ <button class="data-subtab" type="button" data-pmmg-subtab="layout">Layout</button>
3423
+ <button class="data-subtab" type="button" data-pmmg-subtab="sprites">Sprites<span id="sim-pmmg-sprite-count"></span></button>
3424
+ <button class="data-subtab" type="button" data-pmmg-subtab="scene">Scene</button>
3425
+ </div>
3426
+ <div class="pmmg-pane" data-pmmg-pane="layout">
3427
+ <div class="pmmg-actions">
3428
+ <button class="simulator-btn tiny" type="button" id="sim-pmmg-replay" title="Draws the move before the last, then animates into the last" disabled>Replay last move</button>
3429
+ <button class="simulator-btn tiny" type="button" id="sim-pmmg-redraw" title="A new board, showing the latest move">Redraw</button>
3430
+ <label class="pmmg-check" title="Each new move animates in, as a neighbour's board would"><input type="checkbox" data-pmmg-pref="follow" /> Follow game</label>
3431
+ </div>
3432
+ <div class="pmmg-actions">
3433
+ <label class="pmmg-check" title="High for a neighbour beside the player, low for a board seen in passing, like an ambient table or the lobby's">
3434
+ Fidelity
3435
+ <select class="simulator-select" id="sim-pmmg-fidelity">
3436
+ <option value="high">High</option>
3437
+ <option value="low">Low</option>
3438
+ </select>
3439
+ </label>
3440
+ <label class="pmmg-check" title="Whether what's behind the board is dark or light: Puzzmo uses the game's felt when it has a scheme, and the theme's otherwise">
3441
+ Background
3442
+ <select class="simulator-select" id="sim-pmmg-background-style">
3443
+ <option value="theme">Theme's</option>
3444
+ <option value="dark">Dark</option>
3445
+ <option value="light">Light</option>
3446
+ </select>
3447
+ </label>
3448
+ </div>
3449
+ <div class="pmmg-stage" id="sim-pmmg-stage"><canvas class="pmmg-backdrop" id="sim-pmmg-canvas"></canvas></div>
3450
+ <div class="pmmg-hover" id="sim-pmmg-hover">Hover the board to see a node, click one to pick its sprite</div>
3451
+ <div class="pmmg-toggles">
3452
+ ${$e.map(([e, t, n]) => `<label class="pmmg-check" title="${n}"><input type="checkbox" data-pmmg-pref="${e}" /> ${t}</label>`).join("")}
3453
+ <select class="simulator-select pmmg-backdrop-select" id="sim-pmmg-backdrop" title="What's behind the board">
3454
+ <option value="checker">Checker</option>
3455
+ <option value="theme">Theme bg</option>
3456
+ <option value="black">Black</option>
3457
+ <option value="white">White</option>
3458
+ </select>
3459
+ </div>
3460
+ <div class="pmmg-stats" id="sim-pmmg-stats"></div>
3461
+ <div class="pmmg-problems" id="sim-pmmg-problems"></div>
3462
+ </div>
3463
+ <div class="pmmg-pane" data-pmmg-pane="sprites">
3464
+ <div class="pmmg-actions">
3465
+ <input class="simulator-input" id="sim-pmmg-filter" placeholder="Filter by ID" />
3466
+ <button class="simulator-btn tiny" type="button" id="sim-pmmg-clear" title="Forgets every sprite, as a new table would, and draws again">Clear sprites</button>
3467
+ </div>
3468
+ <div class="pmmg-stats" id="sim-pmmg-sprite-summary"></div>
3469
+ <div id="sim-pmmg-detail"></div>
3470
+ <div class="pmmg-sprites" id="sim-pmmg-sprites"></div>
3471
+ </div>
3472
+ <div class="pmmg-pane" data-pmmg-pane="scene">
3473
+ <div class="pmmg-stats" id="sim-pmmg-update"></div>
3474
+ <pre class="pmmg-json" id="sim-pmmg-scene"></pre>
3475
+ </div>
3476
+ </div>
3477
+ `;
3478
+ },
3479
+ bind(e) {
3480
+ var t, r, i, o;
3481
+ a = e;
3482
+ let s = w("root");
3483
+ if (!s) return;
3484
+ s.style.setProperty("--pmmg-theme-bg", a.state.selectedTheme.g_bg), s.querySelectorAll("[data-pmmg-subtab]").forEach((e) => {
3485
+ e.addEventListener("click", () => {
3486
+ n.subtab = e.dataset.pmmgSubtab, C(n), ne();
3487
+ });
3488
+ }), s.querySelectorAll("[data-pmmg-pref]").forEach((e) => {
3489
+ let t = e.dataset.pmmgPref;
3490
+ e.checked = n[t], e.addEventListener("change", () => {
3491
+ n[t] = e.checked, C(n), t === "follow" && e.checked && j(), p == null || p.redraw();
3492
+ });
3493
+ });
3494
+ let c = w("backdrop");
3495
+ c && (c.value = n.backdrop, c.addEventListener("change", () => {
3496
+ n.backdrop = c.value, C(n), s.className = `pmmg-view pmmg-backdrop-${n.backdrop}`;
3497
+ }));
3498
+ let u = w("fidelity");
3499
+ u && (u.value = n.fidelity, u.addEventListener("change", () => {
3500
+ n.fidelity = u.value, C(n), p == null || p.setLook(E());
3501
+ }));
3502
+ let d = w("background-style");
3503
+ d && (d.options[0].textContent = `Theme's (${a.state.selectedTheme.type})`, d.value = n.backgroundStyle, d.addEventListener("change", () => {
3504
+ n.backgroundStyle = d.value, C(n), p == null || p.setLook(E());
3505
+ })), (t = w("replay")) == null || t.addEventListener("click", () => A(!0)), (r = w("redraw")) == null || r.addEventListener("click", () => A(!1)), (i = w("clear")) == null || i.addEventListener("click", () => {
3506
+ l == null || l.clear(), A(!1);
3507
+ }), (o = w("filter")) == null || o.addEventListener("input", () => L());
3508
+ let f = w("canvas");
3509
+ f == null || f.addEventListener("mousemove", (e) => H(re(e))), f == null || f.addEventListener("mouseleave", () => H(null)), f == null || f.addEventListener("click", (e) => {
3510
+ let t = re(e), n = t && h ? Be(h.nodes, t, (e) => l == null ? void 0 : l.anySprite(e)) : null;
3511
+ n != null && n.sprite && V(_ === n.sprite ? null : n.sprite);
3512
+ });
3513
+ let m = w("stage");
3514
+ m && new ResizeObserver(([e]) => p == null ? void 0 : p.resize(e.contentRect.width, e.contentRect.height)).observe(m), ne();
3515
+ },
3516
+ onActivate() {
3517
+ k();
3518
+ },
3519
+ onMessage(e, t, n) {
3520
+ if (e === "UPDATE_TABLE_GAME_STATE" && typeof (t == null ? void 0 : t.inputString) == "string") {
3521
+ var r;
3522
+ typeof t.puzzleString == "string" && (y = t.puzzleString);
3523
+ let e = (r = y) == null ? n.state.puzzleData : r;
3524
+ if (e === null) return;
3525
+ v !== "table" && (v = "table", b.length = 0), M({
3526
+ puzzle: e,
3527
+ input: t.inputString
3528
+ });
3529
+ } else if (e === "UPLOAD_NEW_GAME_STATE" && v === "session") {
3530
+ var i, a;
3531
+ let e = (i = t == null || (a = t.input) == null ? void 0 : a.boardState) == null ? t == null ? void 0 : t.boardState : i, r = n.state.puzzleData;
3532
+ typeof e == "string" && r !== null && M({
3533
+ puzzle: r,
3534
+ input: e
3535
+ });
3536
+ } else e === "READY_GAME_LOADED" && n.state.activeTab === "pmmg" && k();
3537
+ }
3538
+ };
3539
+ }
3540
+ /** A sprite's picture on a canvas fitted inside a box, enlarged in whole pixels so its real pixels show, with its anchor */
3541
+ var nt = (e, t, n) => {
3542
+ let r = window.devicePixelRatio || 1, { bitmap: i } = e, a = Math.min(t / (i.width / r), n / (i.height / r), 8), o = Math.max(1, i.width / r * a), s = Math.max(1, i.height / r * a), c = document.createElement("canvas");
3543
+ c.className = "pmmg-backdrop", c.width = Math.max(1, Math.round(o * r)), c.height = Math.max(1, Math.round(s * r)), c.style.width = `${o}px`, c.style.height = `${s}px`;
3544
+ let l = c.getContext("2d");
3545
+ if (!l) return c;
3546
+ l.imageSmoothingEnabled = a < 1;
3547
+ try {
3548
+ l.drawImage(i, 0, 0, c.width, c.height);
3549
+ } catch (e) {}
3550
+ let u = e.anchor[0] / e.width * c.width, d = e.anchor[1] / e.height * c.height, f = 4 * r;
3551
+ return l.strokeStyle = "#f472b6", l.lineWidth = r, l.beginPath(), l.moveTo(u - f, d), l.lineTo(u + f, d), l.moveTo(u, d - f), l.lineTo(u, d + f), l.stroke(), c;
3552
+ }, Y = (e) => Number.isInteger(e) ? String(e) : e.toFixed(2).replace(/\.?0+$/, ""), rt = (e) => {
3553
+ try {
3554
+ var t;
3555
+ return (t = JSON.stringify(e, null, 2)) == null ? String(e) : t;
3556
+ } catch (t) {
3557
+ return String(e);
3558
+ }
3559
+ }, X = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), it = (e) => e instanceof Error ? e.message : String(e);
2804
3560
  /** Generate theme preview HTML showing key colors */
2805
- function Me(e) {
3561
+ function at(e) {
2806
3562
  let t = [
2807
3563
  e.key,
2808
3564
  e.subBrand,
@@ -2813,7 +3569,7 @@ function Me(e) {
2813
3569
  ].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
2814
3570
  return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
2815
3571
  }
2816
- function Ne() {
3572
+ function ot() {
2817
3573
  return {
2818
3574
  id: "theme",
2819
3575
  label: "Theme",
@@ -2822,20 +3578,20 @@ function Ne() {
2822
3578
  },
2823
3579
  bind(e) {
2824
3580
  let t = e.getElement("#simulator-themes");
2825
- t && i.forEach((n) => {
3581
+ t && c.forEach((n) => {
2826
3582
  let r = document.createElement("div");
2827
3583
  r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
2828
- ${Me(n)}
3584
+ ${at(n)}
2829
3585
  <div class="simulator-theme-name">${n.name}</div>
2830
3586
  <div class="simulator-theme-type">${n.type}</div>
2831
3587
  `, r.addEventListener("click", () => {
2832
- console.log("Simulator: Theme changed, reloading...", n.name), E(n.name), window.location.reload();
3588
+ console.log("Simulator: Theme changed, reloading...", n.name), F(n.name), window.location.reload();
2833
3589
  }), t.appendChild(r);
2834
3590
  });
2835
3591
  }
2836
3592
  };
2837
3593
  }
2838
- var Pe = [
3594
+ var st = [
2839
3595
  {
2840
3596
  name: "app (desktop)",
2841
3597
  context: [{
@@ -2882,8 +3638,8 @@ var Pe = [
2882
3638
  * The bootstrap is only read at game boot, so applying a change persists it to localStorage and
2883
3639
  * restarts (reloads) the page — the same flow as the Theme tab.
2884
3640
  */
2885
- function Fe(e = []) {
2886
- let t = [...Pe, ...e];
3641
+ function ct(e = []) {
3642
+ let t = [...st, ...e];
2887
3643
  return {
2888
3644
  id: "host",
2889
3645
  label: "Host",
@@ -2900,7 +3656,7 @@ function Fe(e = []) {
2900
3656
  <div class="host-note" id="host-source"></div>
2901
3657
  <select class="simulator-select" id="host-presets">
2902
3658
  <option value="">Preset…</option>
2903
- ${t.map((e, t) => `<option value="${t}">${Ie(e.name)}</option>`).join("")}
3659
+ ${t.map((e, t) => `<option value="${t}">${lt(e.name)}</option>`).join("")}
2904
3660
  </select>
2905
3661
  <textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
2906
3662
  <div class="host-actions">
@@ -2929,50 +3685,50 @@ function Fe(e = []) {
2929
3685
  o.textContent = "hostContext must be an array of { type: string, ... } objects";
2930
3686
  return;
2931
3687
  }
2932
- console.log("Simulator: hostContext changed, reloading...", e), p(e), window.location.reload();
3688
+ console.log("Simulator: hostContext changed, reloading...", e), _(e), window.location.reload();
2933
3689
  }), (r = e.getElement("#host-reset")) == null || r.addEventListener("click", () => {
2934
- m(), window.location.reload();
3690
+ v(), window.location.reload();
2935
3691
  }));
2936
3692
  }
2937
3693
  };
2938
3694
  }
2939
3695
  /** Minimal HTML-escape so preset names can't break the simulator markup. */
2940
- function Ie(e) {
3696
+ function lt(e) {
2941
3697
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2942
3698
  }
2943
- var Le = "puzzmo_sim_api_mode", Re = "http://localhost:8911", ze = "https://api.puzzmo.com", q = () => localStorage.getItem(Le) === "dev" ? "dev" : "prod", Be = (e) => {
2944
- localStorage.setItem(Le, e);
2945
- }, J = null, Ve = function() {
3699
+ var ut = "puzzmo_sim_api_mode", dt = "http://localhost:8911", ft = "https://api.puzzmo.com", pt = () => localStorage.getItem(ut) === "dev" ? "dev" : "prod", mt = (e) => {
3700
+ localStorage.setItem(ut, e);
3701
+ }, Z = null, ht = function() {
2946
3702
  var e = t(function* () {
2947
- if (J !== null) return J;
3703
+ if (Z !== null) return Z;
2948
3704
  try {
2949
- let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${Re}/healthz`, { signal: e.signal });
2950
- return clearTimeout(t), J = n.ok, J;
3705
+ let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${dt}/healthz`, { signal: e.signal });
3706
+ return clearTimeout(t), Z = n.ok, Z;
2951
3707
  } catch (e) {
2952
- return J = !1, !1;
3708
+ return Z = !1, !1;
2953
3709
  }
2954
3710
  });
2955
3711
  return function() {
2956
3712
  return e.apply(this, arguments);
2957
3713
  };
2958
- }(), He = () => ({
2959
- apiURL: q() === "dev" ? Re : ze,
3714
+ }(), gt = () => ({
3715
+ apiURL: pt() === "dev" ? dt : ft,
2960
3716
  clientID: "protosdk:oauthclient",
2961
3717
  redirectUri: `${window.location.origin}/oauth/callback`
2962
- }), Ue = () => {
3718
+ }), _t = () => {
2963
3719
  let e = new Uint8Array(32);
2964
3720
  return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
2965
- }, We = "puzzmo_sim_oauth_token", Ge = "puzzmo_sim_oauth_refresh_token", Ke = (e) => localStorage.setItem(We, e), qe = (e) => localStorage.setItem(Ge, e), Je = () => {
2966
- let e = localStorage.getItem(We);
3721
+ }, vt = "puzzmo_sim_oauth_token", yt = "puzzmo_sim_oauth_refresh_token", bt = (e) => localStorage.setItem(vt, e), xt = (e) => localStorage.setItem(yt, e), St = () => {
3722
+ let e = localStorage.getItem(vt);
2967
3723
  return e && `${e.substring(0, 20)}`, e;
2968
- }, Ye = () => localStorage.getItem(Ge), Xe = () => {
2969
- localStorage.removeItem(We), localStorage.removeItem(Ge);
2970
- }, Ze = () => {
2971
- let e = He(), t = Ue();
3724
+ }, Ct = () => localStorage.getItem(yt), wt = () => {
3725
+ localStorage.removeItem(vt), localStorage.removeItem(yt);
3726
+ }, Tt = () => {
3727
+ let e = gt(), t = _t();
2972
3728
  sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
2973
3729
  let n = new URL(`${e.apiURL}/oauth/auth`);
2974
3730
  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();
2975
- }, Qe = (e) => {
3731
+ }, Et = (e) => {
2976
3732
  try {
2977
3733
  let t = e.split(".");
2978
3734
  if (t.length !== 3) return !0;
@@ -2981,11 +3737,11 @@ var Le = "puzzmo_sim_api_mode", Re = "http://localhost:8911", ze = "https://api.
2981
3737
  } catch (e) {
2982
3738
  return !0;
2983
3739
  }
2984
- }, $e = function() {
3740
+ }, Dt = function() {
2985
3741
  var e = t(function* () {
2986
- let e = Ye();
3742
+ let e = Ct();
2987
3743
  if (!e) return !1;
2988
- let t = He();
3744
+ let t = gt();
2989
3745
  try {
2990
3746
  let n = new URLSearchParams({
2991
3747
  grant_type: "refresh_token",
@@ -2999,9 +3755,9 @@ var Le = "puzzmo_sim_api_mode", Re = "http://localhost:8911", ze = "https://api.
2999
3755
  if (!r.ok) return r.statusText, !1;
3000
3756
  let i = yield r.json(), a = i.access_token || i.accessToken;
3001
3757
  if (!a) return !1;
3002
- Ke(a);
3758
+ bt(a);
3003
3759
  let o = i.refresh_token || i.refreshToken;
3004
- return o && qe(o), !0;
3760
+ return o && xt(o), !0;
3005
3761
  } catch (e) {
3006
3762
  return !1;
3007
3763
  }
@@ -3009,9 +3765,9 @@ var Le = "puzzmo_sim_api_mode", Re = "http://localhost:8911", ze = "https://api.
3009
3765
  return function() {
3010
3766
  return e.apply(this, arguments);
3011
3767
  };
3012
- }(), et = function() {
3768
+ }(), Ot = function() {
3013
3769
  var e = t(function* (e, t) {
3014
- let n = He(), r = sessionStorage.getItem("oauth_state");
3770
+ let n = gt(), r = sessionStorage.getItem("oauth_state");
3015
3771
  if (!r || r !== t) return null;
3016
3772
  sessionStorage.removeItem("oauth_state");
3017
3773
  try {
@@ -3033,13 +3789,13 @@ var Le = "puzzmo_sim_api_mode", Re = "http://localhost:8911", ze = "https://api.
3033
3789
  return function(t, n) {
3034
3790
  return e.apply(this, arguments);
3035
3791
  };
3036
- }(), tt = function() {
3792
+ }(), kt = function() {
3037
3793
  var e = t(function* (e, t = {}) {
3038
- let n = He(), r = Je();
3794
+ let n = gt(), r = St();
3039
3795
  if (!r) throw Error("Not authenticated");
3040
- if (Qe(r)) if (yield $e()) {
3041
- if (r = Je(), !r) throw Error("Token refresh succeeded but no token available");
3042
- } else throw Xe(), Error("Session expired. Please log in again.");
3796
+ if (Et(r)) if (yield Dt()) {
3797
+ if (r = St(), !r) throw Error("Token refresh succeeded but no token available");
3798
+ } else throw wt(), Error("Session expired. Please log in again.");
3043
3799
  let i = yield fetch(`${n.apiURL}/graphql`, {
3044
3800
  method: "POST",
3045
3801
  headers: {
@@ -3058,7 +3814,7 @@ var Le = "puzzmo_sim_api_mode", Re = "http://localhost:8911", ze = "https://api.
3058
3814
  return function(t) {
3059
3815
  return e.apply(this, arguments);
3060
3816
  };
3061
- }(), nt = (e) => {
3817
+ }(), At = (e) => {
3062
3818
  try {
3063
3819
  let t = e.split(".");
3064
3820
  return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
@@ -3066,15 +3822,15 @@ var Le = "puzzmo_sim_api_mode", Re = "http://localhost:8911", ze = "https://api.
3066
3822
  return null;
3067
3823
  }
3068
3824
  };
3069
- function rt() {
3825
+ function jt() {
3070
3826
  let e = !1;
3071
3827
  return {
3072
3828
  id: "auth",
3073
3829
  label: "Auth",
3074
3830
  render() {
3075
- let e = Je(), t = !!e, n = q(), r = n === "dev" ? Re : ze, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
3831
+ let e = St(), t = !!e, n = pt(), r = n === "dev" ? dt : ft, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
3076
3832
  if (t) {
3077
- let t = nt(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!Ye(), o = a ? nt(Ye()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
3833
+ let t = At(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!Ct(), o = a ? At(Ct()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
3078
3834
  return `
3079
3835
  <div class="simulator-section">
3080
3836
  <div class="simulator-section-title auth-title-row">
@@ -3115,7 +3871,7 @@ function rt() {
3115
3871
  </div>
3116
3872
  <p class="auth-description">
3117
3873
  Login with your Puzzmo account to make authenticated API requests.
3118
- ${n === "dev" ? `<br><strong>Using local dev server:</strong> ${Re}` : ""}
3874
+ ${n === "dev" ? `<br><strong>Using local dev server:</strong> ${dt}` : ""}
3119
3875
  </p>
3120
3876
  <div class="simulator-row">
3121
3877
  <button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
@@ -3126,21 +3882,21 @@ function rt() {
3126
3882
  },
3127
3883
  bind(n) {
3128
3884
  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");
3129
- e ? J && c && (c.style.display = "", q() === "dev" && c.classList.add("active")) : (e = !0, Ve().then((e) => {
3130
- e && c && (c.style.display = "", q() === "dev" && c.classList.add("active"));
3885
+ e ? Z && c && (c.style.display = "", pt() === "dev" && c.classList.add("active")) : (e = !0, ht().then((e) => {
3886
+ e && c && (c.style.display = "", pt() === "dev" && c.classList.add("active"));
3131
3887
  })), c == null || c.addEventListener("click", () => {
3132
- Be(q() === "dev" ? "prod" : "dev"), Xe(), window.location.reload();
3888
+ mt(pt() === "dev" ? "prod" : "dev"), wt(), window.location.reload();
3133
3889
  }), r == null || r.addEventListener("click", () => {
3134
- Ze();
3890
+ Tt();
3135
3891
  }), i == null || i.addEventListener("click", () => {
3136
- Xe(), window.location.reload();
3892
+ wt(), window.location.reload();
3137
3893
  }), a == null || a.addEventListener("click", t(function* () {
3138
- a.disabled = !0, a.textContent = "Refreshing...", (yield $e()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
3894
+ a.disabled = !0, a.textContent = "Refreshing...", (yield Dt()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
3139
3895
  })), o == null || o.addEventListener("click", t(function* () {
3140
3896
  if (s) {
3141
3897
  s.innerHTML = "<div class=\"loading\">Loading...</div>";
3142
3898
  try {
3143
- let t = yield tt("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
3899
+ let t = yield kt("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
3144
3900
  if (t.errors) {
3145
3901
  var e;
3146
3902
  s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
@@ -3162,13 +3918,13 @@ function rt() {
3162
3918
  if (n && r) {
3163
3919
  let t = e.getElement("#auth-status");
3164
3920
  t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
3165
- let i = yield et(n, r);
3921
+ let i = yield Ot(n, r);
3166
3922
  if (window.history.replaceState({}, "", window.location.pathname), i) {
3167
3923
  let e = i.access_token || i.accessToken;
3168
3924
  if (e) {
3169
- Ke(e);
3925
+ bt(e);
3170
3926
  let t = i.refresh_token || i.refreshToken;
3171
- t && qe(t);
3927
+ t && xt(t);
3172
3928
  }
3173
3929
  window.location.reload();
3174
3930
  } else {
@@ -3180,9 +3936,9 @@ function rt() {
3180
3936
  }
3181
3937
  };
3182
3938
  }
3183
- var it = "puzzmo_sim_api_mode", at = "http://localhost:8911", ot = "https://api.puzzmo.com", st = "puzzmo_sim_oauth_token", ct = "puzzmo_sim_oauth_refresh_token", lt = () => localStorage.getItem(it) === "dev" ? "dev" : "prod", ut = () => localStorage.getItem(st), dt = () => localStorage.getItem(ct), ft = (e) => localStorage.setItem(st, e), pt = (e) => localStorage.setItem(ct, e), mt = () => {
3184
- localStorage.removeItem(st), localStorage.removeItem(ct);
3185
- }, ht = (e) => {
3939
+ var Mt = "puzzmo_sim_api_mode", Nt = "http://localhost:8911", Pt = "https://api.puzzmo.com", Ft = "puzzmo_sim_oauth_token", It = "puzzmo_sim_oauth_refresh_token", Lt = () => localStorage.getItem(Mt) === "dev" ? "dev" : "prod", Rt = () => localStorage.getItem(Ft), zt = () => localStorage.getItem(It), Bt = (e) => localStorage.setItem(Ft, e), Vt = (e) => localStorage.setItem(It, e), Ht = () => {
3940
+ localStorage.removeItem(Ft), localStorage.removeItem(It);
3941
+ }, Ut = (e) => {
3186
3942
  try {
3187
3943
  let t = e.split(".");
3188
3944
  if (t.length !== 3) return !0;
@@ -3191,11 +3947,11 @@ var it = "puzzmo_sim_api_mode", at = "http://localhost:8911", ot = "https://api.
3191
3947
  } catch (e) {
3192
3948
  return !0;
3193
3949
  }
3194
- }, gt = function() {
3950
+ }, Wt = function() {
3195
3951
  var e = t(function* () {
3196
- let e = dt();
3952
+ let e = zt();
3197
3953
  if (!e) return !1;
3198
- let t = lt() === "dev" ? at : ot;
3954
+ let t = Lt() === "dev" ? Nt : Pt;
3199
3955
  try {
3200
3956
  let n = new URLSearchParams({
3201
3957
  grant_type: "refresh_token",
@@ -3209,9 +3965,9 @@ var it = "puzzmo_sim_api_mode", at = "http://localhost:8911", ot = "https://api.
3209
3965
  if (!r.ok) return !1;
3210
3966
  let i = yield r.json(), a = i.access_token || i.accessToken;
3211
3967
  if (!a) return !1;
3212
- ft(a);
3968
+ Bt(a);
3213
3969
  let o = i.refresh_token || i.refreshToken;
3214
- return o && pt(o), !0;
3970
+ return o && Vt(o), !0;
3215
3971
  } catch (e) {
3216
3972
  return !1;
3217
3973
  }
@@ -3219,13 +3975,13 @@ var it = "puzzmo_sim_api_mode", at = "http://localhost:8911", ot = "https://api.
3219
3975
  return function() {
3220
3976
  return e.apply(this, arguments);
3221
3977
  };
3222
- }(), _t = function() {
3978
+ }(), Gt = function() {
3223
3979
  var e = t(function* (e, t = {}) {
3224
- let n = lt() === "dev" ? at : ot, r = ut();
3980
+ let n = Lt() === "dev" ? Nt : Pt, r = Rt();
3225
3981
  if (!r) throw Error("Not authenticated");
3226
- if (ht(r)) if (yield gt()) {
3227
- if (r = ut(), !r) throw Error("Token refresh succeeded but no token available");
3228
- } else throw mt(), Error("Session expired. Please log in again.");
3982
+ if (Ut(r)) if (yield Wt()) {
3983
+ if (r = Rt(), !r) throw Error("Token refresh succeeded but no token available");
3984
+ } else throw Ht(), Error("Session expired. Please log in again.");
3229
3985
  let i = yield fetch(`${n}/graphql`, {
3230
3986
  method: "POST",
3231
3987
  headers: {
@@ -3244,19 +4000,19 @@ var it = "puzzmo_sim_api_mode", at = "http://localhost:8911", ot = "https://api.
3244
4000
  return function(t) {
3245
4001
  return e.apply(this, arguments);
3246
4002
  };
3247
- }(), vt = "\n query GameFeaturesQuery($slug: ID!) {\n game(id: $slug) {\n id\n slug\n displayName\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", yt = "\n mutation ToggleFeatureMutation($gameSlug: ID!, $input: UpdateGameInput!) {\n updateGame(id: $gameSlug, input: $input) {\n id\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", bt = (e, t) => {
4003
+ }(), Kt = "\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", qt = "\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", Jt = (e, t) => {
3248
4004
  let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
3249
4005
  for (; a.length <= r;) a.push(0);
3250
4006
  return a[r] = a[r] ^ 1 << i, a;
3251
4007
  };
3252
- const xt = () => !!ut();
3253
- function St() {
4008
+ const Yt = () => !!Rt();
4009
+ function Xt() {
3254
4010
  let n = null, r = !1, i = null, a = function() {
3255
4011
  var e = t(function* (e) {
3256
4012
  r = !0, i = null;
3257
4013
  try {
3258
4014
  var t;
3259
- let r = yield _t(vt, { slug: e });
4015
+ let r = yield Gt(Kt, { slug: e });
3260
4016
  if (r.errors) {
3261
4017
  var a;
3262
4018
  i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
@@ -3273,10 +4029,10 @@ function St() {
3273
4029
  }(), o = function() {
3274
4030
  var r = t(function* (t) {
3275
4031
  if (!n) return;
3276
- let r = bt(n.featuresArr, t);
4032
+ let r = Jt(n.featuresArr, t);
3277
4033
  try {
3278
4034
  var i;
3279
- let t = yield _t(yt, {
4035
+ let t = yield Gt(qt, {
3280
4036
  gameSlug: n.slug,
3281
4037
  input: { featuresArr: r }
3282
4038
  });
@@ -3324,7 +4080,7 @@ function St() {
3324
4080
  id: "features",
3325
4081
  label: "Features",
3326
4082
  render() {
3327
- return xt() ? `
4083
+ return Yt() ? `
3328
4084
  <div class="features-view-container">
3329
4085
  <div class="simulator-section">
3330
4086
  <div class="simulator-section-title">Game Features</div>
@@ -3365,7 +4121,7 @@ function St() {
3365
4121
  e && (yield d(e));
3366
4122
  })), i == null || i.addEventListener("keypress", (e) => {
3367
4123
  e.key === "Enter" && (r == null || r.click());
3368
- }), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, xt() && !n && d(e.gameSlug)), u();
4124
+ }), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, Yt() && !n && d(e.gameSlug)), u();
3369
4125
  },
3370
4126
  onActivate(e) {
3371
4127
  let t = e.getElement("#simulator-tab-features");
@@ -3389,19 +4145,19 @@ function St() {
3389
4145
  * tuning it needs to see it.
3390
4146
  */
3391
4147
  /** Space the keys occupy. */
3392
- var Ct = 200, wt = 24;
4148
+ var Zt = 200, Qt = 24;
3393
4149
  /** What the keyboard takes off the bottom of the game, and what the game must lay out without. */
3394
- const Y = Ct + wt;
4150
+ const $t = Zt + Qt;
3395
4151
  /** Drag-cursor thresholds, from useKeyboardCursor in @puzzmo-com/keyboard. */
3396
- var Tt = 6, Et = 2.5, Dt = 100, Ot = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", X = (e, t) => {
4152
+ var en = 6, tn = 2.5, nn = 100, rn = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", Q = (e, t) => {
3397
4153
  let n = e.replace("#", ""), r = n.length === 3 ? [...n].map((e) => e + e).join("") : n, i = parseInt(r, 16);
3398
4154
  return r.length !== 6 || Number.isNaN(i) ? e : `rgba(${i >> 16 & 255}, ${i >> 8 & 255}, ${i & 255}, ${t})`;
3399
- }, kt = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), At = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3400
- function jt(e) {
4155
+ }, an = (e) => e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), on = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
4156
+ function sn(e) {
3401
4157
  let { theme: t, sendToGame: n } = e, r = !1, i = null, a = null, o = document.createElement("style");
3402
4158
  o.id = "sim-docked-kbd-page-style", o.textContent = `
3403
4159
  html.sim-kbd-docked #simulator {
3404
- bottom: ${Y + 4}px;
4160
+ bottom: ${$t + 4}px;
3405
4161
  }
3406
4162
  `;
3407
4163
  /** The element the game mounted into: `#root` per the SDK's page template, else the page's first element. */
@@ -3414,7 +4170,7 @@ function jt(e) {
3414
4170
  let { height: t, maxHeight: n, position: r } = e.style;
3415
4171
  c = () => {
3416
4172
  e.style.height = t, e.style.maxHeight = n, e.style.position = r, c = null;
3417
- }, e.style.height = `calc(100% - ${Y}px)`, e.style.maxHeight = `calc(100% - ${Y}px)`, getComputedStyle(e).position === "static" && (e.style.position = "relative");
4173
+ }, e.style.height = `calc(100% - ${$t}px)`, e.style.maxHeight = `calc(100% - ${$t}px)`, getComputedStyle(e).position === "static" && (e.style.position = "relative");
3418
4174
  }, u = (e, n) => {
3419
4175
  var r;
3420
4176
  let i = n.disabled.includes(e), a = n.highlight.includes(e);
@@ -3429,8 +4185,8 @@ function jt(e) {
3429
4185
  "overflow:hidden",
3430
4186
  "background:transparent",
3431
4187
  "pointer-events:none",
3432
- `border:${i ? `1px dashed ${X(t.fg, .25)}` : a ? `2px solid ${X(t.fg, .75)}` : `1px solid ${X(t.fg, .4)}`}`,
3433
- Z((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.background)
4188
+ `border:${i ? `1px dashed ${Q(t.fg, .25)}` : a ? `2px solid ${Q(t.fg, .75)}` : `1px solid ${Q(t.fg, .4)}`}`,
4189
+ ln((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.background)
3434
4190
  ].filter(Boolean).join(";");
3435
4191
  }, d = (e, n) => {
3436
4192
  var r;
@@ -3439,14 +4195,14 @@ function jt(e) {
3439
4195
  "letter-spacing:0.5px",
3440
4196
  "text-transform:uppercase",
3441
4197
  "white-space:nowrap",
3442
- `color:${X(t.fg, n.disabled.includes(e) ? .3 : .65)}`,
3443
- n.highlight.includes(e) ? "" : Z(n.keyStyles),
3444
- Z((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.text)
4198
+ `color:${Q(t.fg, n.disabled.includes(e) ? .3 : .65)}`,
4199
+ n.highlight.includes(e) ? "" : ln(n.keyStyles),
4200
+ ln((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.text)
3445
4201
  ].filter(Boolean).join(";");
3446
4202
  }, f = (e, t) => {
3447
4203
  var n, r;
3448
4204
  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 = [
3449
- `width:${Ot(t.l.includes(e), t.xl.includes(e))}`,
4205
+ `width:${rn(t.l.includes(e), t.xl.includes(e))}`,
3450
4206
  `flex:${o ? "1 0 auto" : "0 1 auto"}`,
3451
4207
  "height:100%",
3452
4208
  "display:flex",
@@ -3456,15 +4212,15 @@ function jt(e) {
3456
4212
  "position:relative",
3457
4213
  a ? "pointer-events:none" : ""
3458
4214
  ].filter(Boolean).join(";"), c = u(e, t), l = d(e, t);
3459
- return `<div class="sim-docked-kbd-key" data-key="${kt(e)}" style="${s}">
3460
- <div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${At(i)}</div></div>
4215
+ return `<div class="sim-docked-kbd-key" data-key="${an(e)}" style="${s}">
4216
+ <div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${on(i)}</div></div>
3461
4217
  </div>`;
3462
4218
  }, p = (e) => {
3463
4219
  let n = e.layout.filter((e) => !!e), r = `calc(100% / ${n.length})`;
3464
4220
  return `${n.map((t, n) => {
3465
4221
  var i, a;
3466
4222
  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>`;
3467
- }).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>`}`;
4223
+ }).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${Q(t.fg, .12)};opacity:0;transition:opacity 0.1s ease-in-out;pointer-events:none"></div>`}`;
3468
4224
  }, m = !1, h = [0, 0], g = null, _ = 0, v = null, y = null, b = (e) => {
3469
4225
  let t = a == null ? void 0 : a.querySelector("#sim-docked-kbd-cursor");
3470
4226
  t && (t.style.opacity = e ? "0.5" : "0");
@@ -3475,24 +4231,24 @@ function jt(e) {
3475
4231
  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;
3476
4232
  }, C = (e) => {
3477
4233
  y = S(e), a == null || a.setPointerCapture(e.pointerId);
3478
- }, ee = (e) => {
3479
- !(i != null && i.supportsDragCursor) || !y || g && g.clientX === e.clientX && g.clientY === e.clientY || (g && g.pointerId !== e.pointerId && (_ = 0, v = null), v || (v = Date.now()), m || (_ += 1, _ >= Tt && Date.now() - v >= Dt && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * Et, h[1] + (e.clientY - g.clientY) * Et]), g = {
4234
+ }, w = (e) => {
4235
+ !(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, _ >= en && Date.now() - v >= nn && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * tn, h[1] + (e.clientY - g.clientY) * tn]), g = {
3480
4236
  clientX: e.clientX,
3481
4237
  clientY: e.clientY,
3482
4238
  pointerId: e.pointerId
3483
4239
  }, m && n("KEYBOARD_CURSOR_CHANGE", { position: h }));
3484
- }, w = (e) => {
4240
+ }, T = (e) => {
3485
4241
  m ? n("KEYBOARD_CURSOR_END", {}) : y && S(e) === y && n("KEYBOARD_KEY_PRESS", { key: y }), x();
3486
- }, T = () => {
4242
+ }, E = () => {
3487
4243
  a || !i || (a = document.createElement("div"), a.id = "sim-docked-kbd", a.style.cssText = [
3488
4244
  "position:fixed",
3489
4245
  "left:0",
3490
4246
  "right:0",
3491
4247
  "bottom:0",
3492
- `height:${Y}px`,
4248
+ `height:${$t}px`,
3493
4249
  "box-sizing:border-box",
3494
4250
  "padding-top:8px",
3495
- `padding-bottom:${wt}px`,
4251
+ `padding-bottom:${Qt}px`,
3496
4252
  "display:flex",
3497
4253
  "flex-direction:column",
3498
4254
  "z-index:999998",
@@ -3500,33 +4256,33 @@ function jt(e) {
3500
4256
  "user-select:none",
3501
4257
  "-webkit-user-select:none",
3502
4258
  `background:${t.a_bg}`,
3503
- `border-top:1px solid ${X(t.fg, .2)}`
3504
- ].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", C), a.addEventListener("pointermove", ee), a.addEventListener("pointerup", w), a.addEventListener("pointercancel", () => x()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
3505
- }, te = () => {
4259
+ `border-top:1px solid ${Q(t.fg, .2)}`
4260
+ ].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", C), a.addEventListener("pointermove", w), a.addEventListener("pointerup", T), 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());
4261
+ }, D = () => {
3506
4262
  a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), x());
3507
- }, ne = () => {
4263
+ }, O = () => {
3508
4264
  let e = i;
3509
4265
  !a || !e || a.querySelectorAll(".sim-docked-kbd-key").forEach((t) => {
3510
4266
  let n = t.getAttribute("data-key"), r = t.firstElementChild, i = r == null ? void 0 : r.firstElementChild;
3511
4267
  !n || !r || !i || (r.style.cssText = u(n, e), i.style.cssText = d(n, e));
3512
4268
  });
3513
- }, E = () => {
3514
- if (!r || !i) return te();
3515
- if (!a) return T();
4269
+ }, k = () => {
4270
+ if (!r || !i) return D();
4271
+ if (!a) return E();
3516
4272
  a.innerHTML = p(i), b(m);
3517
4273
  };
3518
4274
  return {
3519
4275
  setEnabled(e) {
3520
- r = e, E();
4276
+ r = e, k();
3521
4277
  },
3522
4278
  setConfig(e) {
3523
- let t = a && e && i && Mt(e) === Mt(i);
3524
- i = e, t ? ne() : E();
4279
+ let t = a && e && i && cn(e) === cn(i);
4280
+ i = e, t ? O() : k();
3525
4281
  }
3526
4282
  };
3527
4283
  }
3528
4284
  /** Everything about a config except its per-key styling, so a styling-only update can be spotted. */
3529
- var Mt = (e) => JSON.stringify([
4285
+ var cn = (e) => JSON.stringify([
3530
4286
  e.layout,
3531
4287
  e.symbols,
3532
4288
  e.highlight,
@@ -3538,9 +4294,9 @@ var Mt = (e) => JSON.stringify([
3538
4294
  e.keyStyles
3539
4295
  ]);
3540
4296
  /** Serializes a style object into inline CSS, so `{ backgroundColor: "red" }` becomes `background-color:red`. */
3541
- const Z = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${kt(String(t))}`).join(";");
4297
+ const ln = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${an(String(t))}`).join(";");
3542
4298
  /** Renders a single keyboard key as an HTML button string */
3543
- var Nt = (e, t) => {
4299
+ var un = (e, t) => {
3544
4300
  var n, r, i, a;
3545
4301
  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 = [
3546
4302
  "sim-kb-key",
@@ -3549,11 +4305,11 @@ var Nt = (e, t) => {
3549
4305
  l ? "xl" : "",
3550
4306
  u ? "l" : "",
3551
4307
  d ? "grow" : ""
3552
- ].filter(Boolean).join(" "), p = Z((i = t.individualKeyStyles) == null || (i = i[e]) == null ? void 0 : i.background), m = Z((a = t.individualKeyStyles) == null || (a = a[e]) == null ? void 0 : a.text);
4308
+ ].filter(Boolean).join(" "), p = ln((i = t.individualKeyStyles) == null || (i = i[e]) == null ? void 0 : i.background), m = ln((a = t.individualKeyStyles) == null || (a = a[e]) == null ? void 0 : a.text);
3553
4309
  return `<button class="${f}" data-key="${e}" style="${p}" ${s ? "disabled" : ""}><span style="${m}">${o}</span></button>`;
3554
- }, Pt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => Nt(t, e)).join("")}</div>`).join("")}</div>`;
3555
- function Ft() {
3556
- let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${Y}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : Pt(e) : "<div class=\"sim-kb-empty\">No keyboard config received from game yet.<br>The game calls <code>sdk.keyboard.show(config)</code> to display a keyboard.</div>";
4310
+ }, dn = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => un(t, e)).join("")}</div>`).join("")}</div>`;
4311
+ function fn() {
4312
+ let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${$t}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : dn(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>";
3557
4313
  return {
3558
4314
  id: "kbd",
3559
4315
  label: "Kbd",
@@ -3573,14 +4329,14 @@ function Ft() {
3573
4329
  `;
3574
4330
  },
3575
4331
  bind(e) {
3576
- t != null || (t = jt({
4332
+ t != null || (t = sn({
3577
4333
  theme: e.state.selectedTheme,
3578
4334
  sendToGame: e.sendToGame
3579
4335
  })), t.setEnabled(e.state.keyboardDocked);
3580
4336
  let n = e.getElement("#sim-kb-dock");
3581
4337
  n && (n.checked = e.state.keyboardDocked, n.addEventListener("change", () => {
3582
- e.state.keyboardDocked = n.checked, g(n.checked), t == null || t.setEnabled(n.checked), r(e);
3583
- })), It(e);
4338
+ e.state.keyboardDocked = n.checked, b(n.checked), t == null || t.setEnabled(n.checked), r(e);
4339
+ })), pn(e);
3584
4340
  },
3585
4341
  onMessage(n, i, a) {
3586
4342
  var o;
@@ -3590,11 +4346,11 @@ function Ft() {
3590
4346
  /** Re-render the tab's own content (not the dock) and rebind its keys. */
3591
4347
  function r(e) {
3592
4348
  let t = e.getElement("#sim-kb-content");
3593
- t && (t.innerHTML = n(e.state.keyboardDocked), It(e));
4349
+ t && (t.innerHTML = n(e.state.keyboardDocked), pn(e));
3594
4350
  }
3595
4351
  }
3596
4352
  /** Attach click handlers to all rendered keys */
3597
- function It(e) {
4353
+ function pn(e) {
3598
4354
  var t;
3599
4355
  let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
3600
4356
  n == null || n.forEach((t) => {
@@ -3609,15 +4365,15 @@ function It(e) {
3609
4365
  * change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
3610
4366
  * production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
3611
4367
  */
3612
- function Lt() {
4368
+ function mn() {
3613
4369
  let t = (e) => {
3614
4370
  let t = e.state.settingsComponents;
3615
- return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) => Rt(t, e.state.gameSettings)).join("")}</div><div class="sim-settings-actions"><button class="simulator-btn tiny" id="sim-settings-reset">Reset to defaults</button></div>`;
4371
+ 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) => hn(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>`;
3616
4372
  }, n = (e) => {
3617
4373
  let n = e.getElement("#sim-settings-content");
3618
4374
  n && (n.innerHTML = t(e), i(e));
3619
4375
  }, r = (e) => {
3620
- w(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
4376
+ M(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
3621
4377
  }, i = (t) => {
3622
4378
  var i;
3623
4379
  let a = t.getElement("#sim-settings-content");
@@ -3633,7 +4389,7 @@ function Lt() {
3633
4389
  });
3634
4390
  }), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
3635
4391
  var e;
3636
- T(), t.state.gameSettings = Bt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
4392
+ N(), t.state.gameSettings = _n((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
3637
4393
  }));
3638
4394
  };
3639
4395
  return {
@@ -3648,30 +4404,30 @@ function Lt() {
3648
4404
  onMessage(t, r, i) {
3649
4405
  if (t === "INITIALIZE_SETTINGS") {
3650
4406
  var a;
3651
- i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings), w(i.state.gameSettings), n(i);
4407
+ 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), M(i.state.gameSettings), n(i);
3652
4408
  return;
3653
4409
  }
3654
- t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), w(i.state.gameSettings), n(i));
4410
+ t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), M(i.state.gameSettings), n(i));
3655
4411
  }
3656
4412
  };
3657
4413
  }
3658
4414
  /** Renders a single settings UI component as HTML, reading its current value from `settings` */
3659
- function Rt(e, t) {
4415
+ function hn(e, t) {
3660
4416
  if (e.hidden) return "";
3661
4417
  switch (e.type) {
3662
- case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
3663
- case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
3664
- case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
4418
+ case "title": return `<div class="sim-settings-heading">${$(e.value)}</div>`;
4419
+ case "subtitle": return `<div class="sim-settings-subheading">${$(e.value)}</div>`;
4420
+ case "paragraph": return `<p class="sim-settings-paragraph">${$(e.value)}</p>`;
3665
4421
  case "separator": return "<div class=\"simulator-divider\"></div>";
3666
- case "split": return `<div class="sim-settings-split">${e.content.map((e) => Rt(e, t)).join("")}</div>`;
4422
+ case "split": return `<div class="sim-settings-split">${e.content.map((e) => hn(e, t)).join("")}</div>`;
3667
4423
  case "boolean": {
3668
4424
  var n;
3669
- let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
4425
+ let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${$(e.subtitle)}</div>` : "";
3670
4426
  return `
3671
4427
  <div class="simulator-field">
3672
4428
  <label class="sim-settings-row">
3673
4429
  <input type="checkbox" data-setting="${e.name}" ${r} />
3674
- <span class="simulator-label">${Q(e.title)}</span>
4430
+ <span class="simulator-label">${$(e.title)}</span>
3675
4431
  </label>
3676
4432
  ${i}
3677
4433
  </div>`;
@@ -3680,11 +4436,11 @@ function Rt(e, t) {
3680
4436
  var r;
3681
4437
  let n = (r = t[e.name]) == null ? e.defaultValue : r, i = e.values.map((t, r) => {
3682
4438
  var i;
3683
- return `<option value="${Q(t)}" ${t === n ? "selected" : ""}>${Q((i = e.displays[r]) == null ? t : i)}</option>`;
4439
+ return `<option value="${$(t)}" ${t === n ? "selected" : ""}>${$((i = e.displays[r]) == null ? t : i)}</option>`;
3684
4440
  }).join("");
3685
4441
  return `
3686
4442
  <div class="simulator-field">
3687
- ${zt(e)}
4443
+ ${gn(e)}
3688
4444
  <select class="simulator-select" data-setting="${e.name}">${i}</select>
3689
4445
  </div>`;
3690
4446
  }
@@ -3694,13 +4450,13 @@ function Rt(e, t) {
3694
4450
  var i;
3695
4451
  return `
3696
4452
  <label class="sim-settings-row">
3697
- <input type="checkbox" data-setting="${e.name}" data-setting-type="multiselect" data-multiselect="${e.name}" value="${Q(t)}" ${r.includes(t) ? "checked" : ""} />
3698
- <span class="simulator-label">${Q((i = e.displays[n]) == null ? t : i)}</span>
4453
+ <input type="checkbox" data-setting="${e.name}" data-setting-type="multiselect" data-multiselect="${e.name}" value="${$(t)}" ${r.includes(t) ? "checked" : ""} />
4454
+ <span class="simulator-label">${$((i = e.displays[n]) == null ? t : i)}</span>
3699
4455
  </label>`;
3700
4456
  }).join("");
3701
4457
  return `
3702
4458
  <div class="simulator-field">
3703
- ${zt(e)}
4459
+ ${gn(e)}
3704
4460
  ${a}
3705
4461
  </div>`;
3706
4462
  }
@@ -3709,34 +4465,34 @@ function Rt(e, t) {
3709
4465
  let n = (a = t[e.name]) == null ? e.defaultValue : a, r = e.values.map((e) => `<option value="${e}" ${e === n ? "selected" : ""}>${e}</option>`).join("");
3710
4466
  return `
3711
4467
  <div class="simulator-field">
3712
- ${zt(e)}
4468
+ ${gn(e)}
3713
4469
  <select class="simulator-select" data-setting="${e.name}" data-setting-type="number">${r}</select>
3714
4470
  </div>`;
3715
4471
  }
3716
4472
  case "text": {
3717
4473
  var o, s;
3718
- 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)}" />`;
4474
+ 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}">${$(n)}</textarea>` : `<input class="simulator-input" type="text" data-setting="${e.name}" value="${$(n)}" />`;
3719
4475
  return `
3720
4476
  <div class="simulator-field">
3721
- ${zt(e)}
4477
+ ${gn(e)}
3722
4478
  ${r}
3723
4479
  </div>`;
3724
4480
  }
3725
- default: return `<div class="sim-settings-unsupported">Unsupported component type: ${Q(e.type)}</div>`;
4481
+ default: return `<div class="sim-settings-unsupported">Unsupported component type: ${$(e.type)}</div>`;
3726
4482
  }
3727
4483
  }
3728
4484
  /** Title + optional subtitle markup for a value-producing component */
3729
- function zt(e) {
3730
- let t = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
3731
- return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
4485
+ function gn(e) {
4486
+ let t = e.subtitle ? `<div class="sim-settings-subtitle">${$(e.subtitle)}</div>` : "";
4487
+ return `<span class="simulator-label">${$(e.title)}</span>${t}`;
3732
4488
  }
3733
4489
  /** Collects name → defaultValue pairs from components, recursing into split groups */
3734
- function Bt(e) {
4490
+ function _n(e) {
3735
4491
  let t = {};
3736
- for (let n of e) n.type === "split" ? Object.assign(t, Bt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
4492
+ for (let n of e) n.type === "split" ? Object.assign(t, _n(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
3737
4493
  return t;
3738
4494
  }
3739
- function Q(e) {
4495
+ function $(e) {
3740
4496
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3741
4497
  }
3742
4498
  /**
@@ -3744,8 +4500,8 @@ function Q(e) {
3744
4500
  * parts the host owns: the sound-enabled gate (games boot muted, so this is what lets you hear
3745
4501
  * anything) and a log of the cues the game asked us for, with any haptic it wanted.
3746
4502
  */
3747
- function Vt() {
3748
- let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No cues yet. Play the game to hear from it.</div>" : e.map((e) => `<div class="sound-row"><span class="sound-id">${Ut(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${Ut(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
4503
+ function vn() {
4504
+ 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">${bn(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${bn(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
3749
4505
  let r = t.getElement("#sound-events");
3750
4506
  r && (r.innerHTML = n()), t.updateBadge("sound", e.length);
3751
4507
  };
@@ -3792,13 +4548,13 @@ function Vt() {
3792
4548
  n === "SENSORY_EVENT" && (e.unshift({
3793
4549
  id: (o = i == null ? void 0 : i.id) == null ? JSON.stringify(i) : o,
3794
4550
  haptic: i == null ? void 0 : i.haptic,
3795
- time: Ht()
4551
+ time: yn()
3796
4552
  }), e.length > 100 && e.pop(), r(a));
3797
4553
  }
3798
4554
  };
3799
4555
  }
3800
4556
  /** Current wall-clock time as HH:MM:SS, matching the simulator's message log formatting. */
3801
- function Ht() {
4557
+ function yn() {
3802
4558
  return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
3803
4559
  hour12: !1,
3804
4560
  hour: "2-digit",
@@ -3807,16 +4563,16 @@ function Ht() {
3807
4563
  });
3808
4564
  }
3809
4565
  /** Minimal HTML-escape so event ids can't break the simulator markup. */
3810
- function Ut(e) {
4566
+ function bn(e) {
3811
4567
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3812
4568
  }
3813
- var $ = null;
4569
+ var xn = null;
3814
4570
  /** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
3815
- function Wt() {
4571
+ function Sn() {
3816
4572
  return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
3817
4573
  }
3818
4574
  /** Inert instance returned when the simulator declines to boot (the app is the host). */
3819
- var Gt = {
4575
+ var Cn = {
3820
4576
  updateFixtures: () => {},
3821
4577
  sendToGame: () => {},
3822
4578
  loadPuzzle: function() {
@@ -3865,30 +4621,31 @@ var Gt = {
3865
4621
  * Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
3866
4622
  * This will show dropdowns in the Ctrl tab to select category and puzzle.
3867
4623
  */
3868
- function Kt(n = {}) {
4624
+ function wn(n = {}) {
3869
4625
  var r, i, a, o, s;
3870
- if (Wt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Gt;
4626
+ if (Sn()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Cn;
3871
4627
  if (console.log("[Simulator] createSimulator called with config:", {
3872
4628
  slug: n.slug,
3873
4629
  hasFixtures: !!n.fixtures
3874
- }), $) return n.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(n.fixtures)), $;
3875
- let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ? ie(n.fixtures) : null, u = l ? Array.from(l.keys()).sort() : [], d = me(), f = je(), p = [
4630
+ }), xn) return n.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), xn.updateFixtures(n.fixtures)), xn;
4631
+ let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ? H(n.fixtures) : null, u = l ? Array.from(l.keys()).sort() : [], d = be(), f = Le(), p = [
3876
4632
  oe(),
3877
- ce(),
4633
+ fe(),
3878
4634
  d,
3879
- he(),
3880
- ge(),
3881
- we((i = (a = n.integrations) == null ? void 0 : a.checklists) == null ? [] : i),
4635
+ xe(),
4636
+ Se(),
4637
+ Ae((i = (a = n.integrations) == null ? void 0 : a.checklists) == null ? [] : i),
3882
4638
  f,
3883
- Ne(),
3884
- Fe(n.hostContextPresets),
3885
- rt(),
3886
- St(),
3887
- Ft(),
3888
- Lt(),
3889
- Vt(),
4639
+ ...n.pmmgBundle ? [tt(n.pmmgBundle)] : [],
4640
+ ot(),
4641
+ ct(n.hostContextPresets),
4642
+ jt(),
4643
+ Xt(),
4644
+ fn(),
4645
+ mn(),
4646
+ vn(),
3890
4647
  ...(o = n.views) == null ? [] : o
3891
- ], m = p.map((e) => e.id), h = ee(n, u, m), g = {
4648
+ ], m = p.map((e) => e.id), h = j(n, u, m), g = {
3892
4649
  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>",
3893
4650
  play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
3894
4651
  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>",
@@ -5335,6 +6092,232 @@ function Kt(n = {}) {
5335
6092
  padding-top: 8px;
5336
6093
  border-top: 2px solid var(--sim-border);
5337
6094
  }
6095
+ /* Pmmg tab */
6096
+ .pmmg-view {
6097
+ display: flex;
6098
+ flex-direction: column;
6099
+ gap: 6px;
6100
+ }
6101
+ .pmmg-status {
6102
+ font-size: 10px;
6103
+ color: var(--sim-text);
6104
+ }
6105
+ .pmmg-dim {
6106
+ color: var(--sim-text-dim);
6107
+ }
6108
+ .pmmg-error {
6109
+ color: var(--sim-error);
6110
+ }
6111
+ .pmmg-view .data-subtabs {
6112
+ margin-bottom: 0;
6113
+ }
6114
+ .pmmg-pane {
6115
+ display: none;
6116
+ flex-direction: column;
6117
+ gap: 6px;
6118
+ }
6119
+ .pmmg-pane.active {
6120
+ display: flex;
6121
+ }
6122
+ .pmmg-actions {
6123
+ display: flex;
6124
+ align-items: center;
6125
+ gap: 6px;
6126
+ }
6127
+ .pmmg-actions .simulator-btn.tiny {
6128
+ padding: 4px 6px;
6129
+ }
6130
+ .pmmg-actions .simulator-input {
6131
+ flex: 1;
6132
+ }
6133
+ .pmmg-check {
6134
+ display: inline-flex;
6135
+ align-items: center;
6136
+ gap: 3px;
6137
+ font-size: 10px;
6138
+ color: var(--sim-text);
6139
+ cursor: pointer;
6140
+ white-space: nowrap;
6141
+ }
6142
+ .pmmg-check input {
6143
+ margin: 0;
6144
+ }
6145
+ .pmmg-stage {
6146
+ display: flex;
6147
+ justify-content: center;
6148
+ align-items: flex-start;
6149
+ width: 100%;
6150
+ height: 300px;
6151
+ border: 2px solid var(--sim-border);
6152
+ border-radius: 2px;
6153
+ box-sizing: border-box;
6154
+ background: var(--sim-bg);
6155
+ }
6156
+ .pmmg-stage canvas {
6157
+ display: block;
6158
+ cursor: crosshair;
6159
+ }
6160
+ .pmmg-backdrop-checker .pmmg-backdrop {
6161
+ background-color: #2a2a40;
6162
+ background-image: linear-gradient(45deg, #34344e 25%, transparent 25%), linear-gradient(-45deg, #34344e 25%, transparent 25%),
6163
+ linear-gradient(45deg, transparent 75%, #34344e 75%), linear-gradient(-45deg, transparent 75%, #34344e 75%);
6164
+ background-size: 12px 12px;
6165
+ background-position: 0 0, 0 6px, 6px -6px, -6px 0;
6166
+ }
6167
+ .pmmg-backdrop-theme .pmmg-backdrop {
6168
+ background: var(--pmmg-theme-bg, #fff);
6169
+ }
6170
+ .pmmg-backdrop-black .pmmg-backdrop {
6171
+ background: #000;
6172
+ }
6173
+ .pmmg-backdrop-white .pmmg-backdrop {
6174
+ background: #fff;
6175
+ }
6176
+ .pmmg-hover {
6177
+ min-height: 14px;
6178
+ font-size: 10px;
6179
+ color: var(--sim-text-dim);
6180
+ overflow-wrap: anywhere;
6181
+ }
6182
+ .pmmg-toggles {
6183
+ display: flex;
6184
+ flex-wrap: wrap;
6185
+ align-items: center;
6186
+ gap: 4px 8px;
6187
+ }
6188
+ .pmmg-backdrop-select {
6189
+ width: auto;
6190
+ margin-left: auto;
6191
+ padding: 2px 4px;
6192
+ }
6193
+ .pmmg-stats {
6194
+ font-size: 10px;
6195
+ color: var(--sim-text);
6196
+ }
6197
+ .pmmg-problems {
6198
+ display: flex;
6199
+ flex-direction: column;
6200
+ gap: 4px;
6201
+ }
6202
+ .pmmg-problem {
6203
+ padding: 4px 6px;
6204
+ border: 1px solid var(--sim-border);
6205
+ border-left-width: 3px;
6206
+ border-radius: 2px;
6207
+ font-size: 10px;
6208
+ overflow-wrap: anywhere;
6209
+ }
6210
+ .pmmg-problem.error {
6211
+ border-left-color: var(--sim-error);
6212
+ color: var(--sim-error);
6213
+ }
6214
+ .pmmg-problem.warn {
6215
+ border-left-color: var(--sim-warning);
6216
+ color: var(--sim-warning);
6217
+ }
6218
+ .pmmg-problem.note {
6219
+ color: var(--sim-text-dim);
6220
+ }
6221
+ .pmmg-problem details {
6222
+ margin-top: 4px;
6223
+ color: var(--sim-text-dim);
6224
+ }
6225
+ .pmmg-json {
6226
+ margin: 0;
6227
+ padding: 6px;
6228
+ background: var(--sim-bg);
6229
+ border: 1px solid var(--sim-border);
6230
+ border-radius: 2px;
6231
+ color: var(--sim-text);
6232
+ font: 10px/1.4 "Menlo", monospace;
6233
+ white-space: pre-wrap;
6234
+ overflow-wrap: anywhere;
6235
+ user-select: text;
6236
+ max-height: 360px;
6237
+ overflow: auto;
6238
+ }
6239
+ .pmmg-sprites {
6240
+ display: grid;
6241
+ grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
6242
+ gap: 4px;
6243
+ }
6244
+ .pmmg-sprite {
6245
+ display: flex;
6246
+ flex-direction: column;
6247
+ align-items: stretch;
6248
+ gap: 2px;
6249
+ padding: 4px;
6250
+ min-width: 0;
6251
+ background: var(--sim-bg);
6252
+ border: 1px solid var(--sim-border);
6253
+ border-radius: 2px;
6254
+ color: var(--sim-text);
6255
+ font: inherit;
6256
+ text-align: left;
6257
+ cursor: pointer;
6258
+ }
6259
+ .pmmg-sprite:hover {
6260
+ border-color: var(--sim-border-light);
6261
+ }
6262
+ .pmmg-sprite.selected {
6263
+ border-color: #f472b6;
6264
+ }
6265
+ .pmmg-sprite.unused {
6266
+ opacity: 0.5;
6267
+ }
6268
+ .pmmg-sprite-picture {
6269
+ display: flex;
6270
+ align-items: center;
6271
+ justify-content: center;
6272
+ height: 64px;
6273
+ }
6274
+ .pmmg-sprite-id {
6275
+ font-size: 9px;
6276
+ overflow: hidden;
6277
+ text-overflow: ellipsis;
6278
+ white-space: nowrap;
6279
+ }
6280
+ .pmmg-sprite-meta {
6281
+ font-size: 8px;
6282
+ color: var(--sim-text-dim);
6283
+ }
6284
+ .pmmg-detail {
6285
+ display: flex;
6286
+ flex-direction: column;
6287
+ gap: 6px;
6288
+ padding: 6px;
6289
+ border: 1px solid #f472b6;
6290
+ border-radius: 2px;
6291
+ }
6292
+ .pmmg-detail-head {
6293
+ display: flex;
6294
+ align-items: center;
6295
+ justify-content: space-between;
6296
+ gap: 6px;
6297
+ }
6298
+ .pmmg-detail-id {
6299
+ font-weight: bold;
6300
+ overflow-wrap: anywhere;
6301
+ user-select: text;
6302
+ }
6303
+ .pmmg-detail-picture {
6304
+ display: flex;
6305
+ justify-content: center;
6306
+ }
6307
+ .pmmg-facts {
6308
+ display: grid;
6309
+ grid-template-columns: auto 1fr;
6310
+ gap: 2px 8px;
6311
+ margin: 0;
6312
+ font-size: 10px;
6313
+ }
6314
+ .pmmg-facts dt {
6315
+ color: var(--sim-text-dim);
6316
+ }
6317
+ .pmmg-facts dd {
6318
+ margin: 0;
6319
+ overflow-wrap: anywhere;
6320
+ }
5338
6321
  </style>
5339
6322
  <div id="simulator-panel" class="${h.isCollapsed ? "collapsed" : ""}">
5340
6323
  <div id="simulator-header">
@@ -5367,24 +6350,24 @@ function Kt(n = {}) {
5367
6350
  `, document.body.appendChild(_);
5368
6351
  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) => {
5369
6352
  S.innerHTML = e ? g.play : g.pause, S.title = e ? "Resume" : "Pause";
5370
- }, j = (e, t) => {
6353
+ }, M = (e, t) => {
5371
6354
  let n = k("#simulator-status .text"), r = k("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
5372
6355
  n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), b.className = t, b.textContent = i, x.textContent = e;
5373
- }, M = (e, t) => {
6356
+ }, N = (e, t) => {
5374
6357
  t && t !== "0" ? E.innerHTML = `${e}<span class="penalty">+${t}</span>` : E.textContent = e;
5375
6358
  }, F = (e) => {
5376
6359
  var t;
5377
- h.activeTab = e, O.classList.remove("hidden"), ne(e), D.querySelectorAll(".simulator-tab").forEach((t) => {
6360
+ h.activeTab = e, O.classList.remove("hidden"), ee(e), D.querySelectorAll(".simulator-tab").forEach((t) => {
5378
6361
  t.classList.toggle("active", t.getAttribute("data-tab") === e);
5379
6362
  }), _.querySelectorAll(".simulator-tab-content").forEach((t) => {
5380
6363
  t.classList.toggle("active", t.id === `simulator-tab-${e}`);
5381
6364
  }), w.classList.toggle("active", e === "auth");
5382
6365
  let n = p.find((t) => t.id === e);
5383
- n == null || (t = n.onActivate) == null || t.call(n, H);
6366
+ n == null || (t = n.onActivate) == null || t.call(n, U);
5384
6367
  }, I = (e) => {
5385
- 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);
6368
+ h.isCollapsed = e, v.classList.toggle("collapsed", e), P(e), e ? (O.classList.add("hidden"), D.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : F(h.activeTab);
5386
6369
  }, L = () => {
5387
- f.updatePreview(H);
6370
+ f.updatePreview(U);
5388
6371
  }, R = function() {
5389
6372
  var e = t(function* () {
5390
6373
  var e, t;
@@ -5405,11 +6388,11 @@ function Kt(n = {}) {
5405
6388
  return function() {
5406
6389
  return e.apply(this, arguments);
5407
6390
  };
5408
- }(), z = N((e) => {
5409
- d.addLogEntry(e, H);
6391
+ }(), z = te((e) => {
6392
+ d.addLogEntry(e, U);
5410
6393
  }), B = (e, t) => {
5411
- P(e, t, z);
5412
- }, se = (e) => {
6394
+ ne(e, t, z);
6395
+ }, V = (e) => {
5413
6396
  var t;
5414
6397
  let n = (t = e.buckets) != null && t.length ? e.buckets : u, r = n.find((e) => {
5415
6398
  var t;
@@ -5431,38 +6414,38 @@ function Kt(n = {}) {
5431
6414
  puzzle: l.get(c).get(d.join("/"))
5432
6415
  }
5433
6416
  };
5434
- }, V = (e, t) => {
6417
+ }, ie = (e, t) => {
5435
6418
  let n = _.querySelector(`[data-badge="${e}"]`);
5436
6419
  n && (n.textContent = t && t > 0 ? String(t) : "");
5437
- }, H = {
6420
+ }, U = {
5438
6421
  state: h,
5439
6422
  getElement: k,
5440
6423
  sendToGame: B,
5441
6424
  logMessage: z.log,
5442
6425
  loadPuzzle: R,
5443
- updateStatus: j,
5444
- updateTimer: M,
6426
+ updateStatus: M,
6427
+ updateTimer: N,
5445
6428
  setCollapsed: I,
5446
6429
  switchTab: F,
5447
6430
  updateThumbnail: L,
5448
- updateBadge: V,
6431
+ updateBadge: ie,
5449
6432
  fixtures: l,
5450
6433
  fixtureCategories: u,
5451
6434
  gameSlug: (s = n.slug) == null ? null : s
5452
6435
  };
5453
- console.log("[Simulator] Context created with gameSlug:", H.gameSlug), p.forEach((e) => e.bind(H)), D.querySelectorAll(".simulator-tab").forEach((e) => {
6436
+ console.log("[Simulator] Context created with gameSlug:", U.gameSlug), p.forEach((e) => e.bind(U)), D.querySelectorAll(".simulator-tab").forEach((e) => {
5454
6437
  e.addEventListener("click", () => {
5455
6438
  let t = e.getAttribute("data-tab");
5456
- F(t), V(t, 0);
6439
+ F(t), ie(t, 0);
5457
6440
  });
5458
6441
  }), T.addEventListener("click", (e) => {
5459
6442
  e.stopPropagation(), I(!0);
5460
6443
  }), S.addEventListener("click", (e) => {
5461
- 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"));
6444
+ e.stopPropagation(), h.isPaused ? (B("RESUME_GAME", {}), h.isPaused = !1, A(!1), M("Running", "ready")) : (B("PAUSE_GAME", {}), h.isPaused = !0, A(!0), M("Paused", "paused"));
5462
6445
  let t = k("#simulator-pause");
5463
6446
  t && (t.textContent = h.isPaused ? "Resume" : "Pause");
5464
6447
  }), C.addEventListener("click", (e) => {
5465
- e.stopPropagation(), B("RETRY_PUZZLE", {}), h.hasStarted = !1, h.isPaused = !1, A(!1), S.disabled = !0, j("Ready to retry", "ready");
6448
+ e.stopPropagation(), B("RETRY_PUZZLE", {}), h.hasStarted = !1, h.isPaused = !1, A(!1), S.disabled = !0, M("Ready to retry", "ready");
5466
6449
  let t = k("#simulator-pause"), n = k("#simulator-start");
5467
6450
  t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
5468
6451
  }), w.addEventListener("click", (e) => {
@@ -5470,13 +6453,13 @@ function Kt(n = {}) {
5470
6453
  }), y.addEventListener("click", (e) => {
5471
6454
  h.isCollapsed && e.target !== T && I(!1);
5472
6455
  }), h.isCollapsed || F(h.activeTab);
5473
- let U = new URLSearchParams(window.location.search);
5474
- (U.has("code") || U.has("error")) && (I(!1), F("auth"));
5475
- let le = (t) => {
5476
- let r = n.slug ? e(e({}, qt), {}, {
6456
+ let W = new URLSearchParams(window.location.search);
6457
+ (W.has("code") || W.has("error")) && (I(!1), F("auth"));
6458
+ let se = (t) => {
6459
+ let r = n.slug ? e(e({}, Tn), {}, {
5477
6460
  slug: n.slug,
5478
6461
  stableSlug: n.slug
5479
- }) : qt, i = {
6462
+ }) : Tn, i = {
5480
6463
  additionalTimeAddedSecs: 0,
5481
6464
  boardState: h.currentInputStr,
5482
6465
  combinedTimeSecs: 0,
@@ -5518,15 +6501,15 @@ function Kt(n = {}) {
5518
6501
  hostContext: h.hostContext,
5519
6502
  appRuntimeContract: "1.0"
5520
6503
  };
5521
- }, W = ["1.0", "1.1"], G = function() {
6504
+ }, ce = ["1.0", "1.1"], le = function() {
5522
6505
  var r = t(function* (t) {
5523
6506
  let r = n.session !== !1 || t === "1.0";
5524
- r ? n.session === !1 && console.warn("Simulator: `session: false` needs a game built on an SDK speaking runtime contract 1.1 or later") : console.log("Simulator: Sending READY_DATA without a session"), j(r ? "Loading puzzle..." : "Sending READY_DATA...", "waiting");
6507
+ r ? n.session === !1 && console.warn("Simulator: `session: false` needs a game built on an SDK speaking runtime contract 1.1 or later") : console.log("Simulator: Sending READY_DATA without a session"), M(r ? "Loading puzzle..." : "Sending READY_DATA...", "waiting");
5525
6508
  try {
5526
- let n = e(e({}, le(r ? yield R() : null)), {}, { appRuntimeContract: t });
5527
- j("Sending READY_DATA...", "waiting"), B("READY_DATA", n), j("Waiting for game to load...", "waiting");
6509
+ let n = e(e({}, se(r ? yield R() : null)), {}, { appRuntimeContract: t });
6510
+ M("Sending READY_DATA...", "waiting"), B("READY_DATA", n), M("Waiting for game to load...", "waiting");
5528
6511
  } catch (e) {
5529
- j(`Error: ${e}`, "paused");
6512
+ M(`Error: ${e}`, "paused");
5530
6513
  }
5531
6514
  });
5532
6515
  return function(e) {
@@ -5535,16 +6518,16 @@ function Kt(n = {}) {
5535
6518
  }(), ue = () => {
5536
6519
  console.log("Simulator: Game loaded, ready to start"), C.disabled = !1, p.forEach((e) => {
5537
6520
  var t;
5538
- return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, H);
6521
+ return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, U);
5539
6522
  }), c && !h.hasStarted && setTimeout(() => {
5540
6523
  let e = k("#simulator-start");
5541
- e == null || e.click(), S.disabled = !1, h.hasStarted = !0, j("Running", "ready");
6524
+ e == null || e.click(), S.disabled = !1, h.hasStarted = !0, M("Running", "ready");
5542
6525
  }, 100);
5543
6526
  };
5544
6527
  return re((e, t) => {
5545
6528
  var n, r;
5546
6529
  if (e === "READY") {
5547
- console.log("Simulator: Received READY from game"), G(W.includes(t == null ? void 0 : t.runtimeContract) ? t.runtimeContract : "1.0");
6530
+ console.log("Simulator: Received READY from game"), le(ce.includes(t == null ? void 0 : t.runtimeContract) ? t.runtimeContract : "1.0");
5548
6531
  return;
5549
6532
  }
5550
6533
  if (e === "READY_GAME_LOADED") {
@@ -5554,7 +6537,7 @@ function Kt(n = {}) {
5554
6537
  if (e === "TIMER_TICK") {
5555
6538
  if (t != null && t.display) {
5556
6539
  let [e, n] = t.display;
5557
- M(e, n);
6540
+ N(e, n);
5558
6541
  }
5559
6542
  return;
5560
6543
  }
@@ -5565,11 +6548,11 @@ function Kt(n = {}) {
5565
6548
  }
5566
6549
  p.forEach((n) => {
5567
6550
  var r;
5568
- return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, H);
6551
+ return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, U);
5569
6552
  });
5570
6553
  let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
5571
6554
  if (e === "UPLOAD_NEW_GAME_STATE" && i && (h.currentInputStr = i, h.activeTab === "thumb" && L(), console.log("Simulator: Game state uploaded", t)), e === "COMPLETE_REPEATABLE_RUN" && console.log("Simulator: Repeatable run completed", t), e === "START_REPEATABLE_ROUND" && console.log("Simulator: Repeatable round started", t), e === "RESUME_REPEATABLE_ROUND" && console.log("Simulator: Repeatable round resumed", t), e === "UPDATE_TABLE_GAME_STATE" && console.log("Simulator: Table game state", t), e === "REQUEST_PUZZLE") {
5572
- B("PUZZLE_DATA", se(t));
6555
+ B("PUZZLE_DATA", V(t));
5573
6556
  return;
5574
6557
  }
5575
6558
  if (e === "UPDATE_GAME_USER_STATE" && typeof (t == null ? void 0 : t.state) == "string") {
@@ -5579,27 +6562,27 @@ function Kt(n = {}) {
5579
6562
  stateVersion: (a = t.stateVersion) == null ? 1 : a
5580
6563
  }, console.log("Simulator: Game user storage updated", t);
5581
6564
  }
5582
- e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), S.disabled = !0, h.hasStarted = !1, j("Completed!", "complete"));
5583
- }, z), console.log("Simulator initialized"), $ = {
6565
+ e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), S.disabled = !0, h.hasStarted = !1, M("Completed!", "complete"));
6566
+ }, z), console.log("Simulator initialized"), xn = {
5584
6567
  updateFixtures: (e) => {
5585
- l = ie(e), u = Array.from(l.keys()).sort(), H.fixtures = l, H.fixtureCategories = u;
6568
+ l = H(e), u = Array.from(l.keys()).sort(), U.fixtures = l, U.fixtureCategories = u;
5586
6569
  let t = localStorage.getItem("simulator-fixture-category");
5587
6570
  if (!h.selectedCategory || !u.includes(h.selectedCategory)) {
5588
6571
  var n;
5589
6572
  h.selectedCategory = t && u.includes(t) ? t : (n = u[0]) == null ? null : n;
5590
6573
  }
5591
6574
  let r = p.find((e) => e.id === "ctrl");
5592
- r == null || r.bind(H), console.log("Simulator: Fixtures updated", {
6575
+ r == null || r.bind(U), console.log("Simulator: Fixtures updated", {
5593
6576
  categories: u,
5594
6577
  selectedCategory: h.selectedCategory
5595
6578
  });
5596
6579
  },
5597
6580
  sendToGame: B,
5598
6581
  loadPuzzle: R
5599
- }, $;
6582
+ }, xn;
5600
6583
  }
5601
6584
  /** The game the simulator stands in for, with placeholder IDs since nothing is stored */
5602
- var qt = {
6585
+ var Tn = {
5603
6586
  id: "simulator-game",
5604
6587
  slug: "proto-game",
5605
6588
  stableSlug: "proto-game",
@@ -5615,6 +6598,6 @@ var qt = {
5615
6598
  }
5616
6599
  }
5617
6600
  };
5618
- export { Vt as n, ae as r, Kt as t };
6601
+ export { vn as n, ae as r, wn as t };
5619
6602
 
5620
- //# sourceMappingURL=createSimulator-2M7vXzRZ.js.map
6603
+ //# sourceMappingURL=createSimulator-Dz1KYZ25.js.map