@bloopjs/web 0.0.48 → 0.0.50

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 (42) hide show
  1. package/dist/App.d.ts +8 -1
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/debugui/DebugUi.d.ts +22 -0
  4. package/dist/debugui/DebugUi.d.ts.map +1 -0
  5. package/dist/debugui/components/DebugToggle.d.ts +6 -0
  6. package/dist/debugui/components/DebugToggle.d.ts.map +1 -0
  7. package/dist/debugui/components/Logs.d.ts +2 -0
  8. package/dist/debugui/components/Logs.d.ts.map +1 -0
  9. package/dist/debugui/components/Root.d.ts +7 -0
  10. package/dist/debugui/components/Root.d.ts.map +1 -0
  11. package/dist/debugui/components/Stats.d.ts +2 -0
  12. package/dist/debugui/components/Stats.d.ts.map +1 -0
  13. package/dist/debugui/hooks/useAutoScroll.d.ts +6 -0
  14. package/dist/debugui/hooks/useAutoScroll.d.ts.map +1 -0
  15. package/dist/debugui/mod.d.ts +3 -0
  16. package/dist/debugui/mod.d.ts.map +1 -0
  17. package/dist/debugui/state.d.ts +33 -0
  18. package/dist/debugui/state.d.ts.map +1 -0
  19. package/dist/debugui/styles.d.ts +2 -0
  20. package/dist/debugui/styles.d.ts.map +1 -0
  21. package/dist/mod.d.ts +2 -1
  22. package/dist/mod.d.ts.map +1 -1
  23. package/dist/mod.js +1868 -13
  24. package/dist/mod.js.map +20 -6
  25. package/dist/netcode/mod.d.ts +2 -0
  26. package/dist/netcode/mod.d.ts.map +1 -1
  27. package/dist/netcode/scaffold.d.ts +13 -0
  28. package/dist/netcode/scaffold.d.ts.map +1 -0
  29. package/package.json +7 -5
  30. package/src/App.ts +41 -2
  31. package/src/debugui/DebugUi.ts +111 -0
  32. package/src/debugui/components/DebugToggle.tsx +25 -0
  33. package/src/debugui/components/Logs.tsx +57 -0
  34. package/src/debugui/components/Root.tsx +54 -0
  35. package/src/debugui/components/Stats.tsx +68 -0
  36. package/src/debugui/hooks/useAutoScroll.ts +62 -0
  37. package/src/debugui/mod.ts +2 -0
  38. package/src/debugui/state.ts +127 -0
  39. package/src/debugui/styles.ts +200 -0
  40. package/src/mod.ts +2 -1
  41. package/src/netcode/mod.ts +2 -0
  42. package/src/netcode/scaffold.ts +169 -0
package/dist/mod.js CHANGED
@@ -1,4 +1,3 @@
1
- // ../bloop/dist/mod.js
2
1
  var __defProp = Object.defineProperty;
3
2
  var __export = (target, all) => {
4
3
  for (var name in all)
@@ -9,8 +8,20 @@ var __export = (target, all) => {
9
8
  set: (newValue) => all[name] = () => newValue
10
9
  });
11
10
  };
11
+
12
+ // ../bloop/dist/mod.js
13
+ var __defProp2 = Object.defineProperty;
14
+ var __export2 = (target, all) => {
15
+ for (var name in all)
16
+ __defProp2(target, name, {
17
+ get: all[name],
18
+ enumerable: true,
19
+ configurable: true,
20
+ set: (newValue) => all[name] = () => newValue
21
+ });
22
+ };
12
23
  var exports_util = {};
13
- __export(exports_util, {
24
+ __export2(exports_util, {
14
25
  unwrap: () => unwrap,
15
26
  toHexString: () => toHexString,
16
27
  logPerSecond: () => logPerSecond,
@@ -56,7 +67,7 @@ function unwrap(value, message) {
56
67
  return value;
57
68
  }
58
69
  var exports_engine = {};
59
- __export(exports_engine, {
70
+ __export2(exports_engine, {
60
71
  mouseButtonToMouseButtonCode: () => mouseButtonToMouseButtonCode,
61
72
  mouseButtonCodeToMouseButton: () => mouseButtonCodeToMouseButton,
62
73
  keyToKeyCode: () => keyToKeyCode,
@@ -86,10 +97,10 @@ __export(exports_engine, {
86
97
  EVENTS_OFFSET: () => EVENTS_OFFSET,
87
98
  DEFAULT_WASM_URL: () => DEFAULT_WASM_URL
88
99
  });
89
- var __defProp2 = Object.defineProperty;
90
- var __export2 = (target, all) => {
100
+ var __defProp22 = Object.defineProperty;
101
+ var __export22 = (target, all) => {
91
102
  for (var name in all)
92
- __defProp2(target, name, {
103
+ __defProp22(target, name, {
93
104
  get: all[name],
94
105
  enumerable: true,
95
106
  configurable: true,
@@ -97,7 +108,7 @@ var __export2 = (target, all) => {
97
108
  });
98
109
  };
99
110
  var exports_enums = {};
100
- __export2(exports_enums, {
111
+ __export22(exports_enums, {
101
112
  MouseButton: () => MouseButton,
102
113
  Key: () => Key,
103
114
  InputSource: () => InputSource,
@@ -1382,7 +1393,7 @@ async function mount(opts) {
1382
1393
  console.error(`Failed to fetch wasm at ${opts.wasmUrl ?? DEFAULT_WASM_URL}`, e);
1383
1394
  throw e;
1384
1395
  });
1385
- const memory = new WebAssembly.Memory({ initial: 30, maximum: 1000 });
1396
+ const memory = new WebAssembly.Memory({ initial: 236, maximum: 1000 });
1386
1397
  const wasmInstantiatedSource = await WebAssembly.instantiate(bytes, {
1387
1398
  env: {
1388
1399
  memory,
@@ -3357,6 +3368,1710 @@ function joinRoom(brokerUrl, _roomId, cbs) {
3357
3368
  }
3358
3369
  }
3359
3370
 
3371
+ // src/debugui/mod.ts
3372
+ var exports_mod = {};
3373
+ __export(exports_mod, {
3374
+ updatePeer: () => updatePeer,
3375
+ setRemoteId: () => setRemoteId,
3376
+ setLocalId: () => setLocalId,
3377
+ resetState: () => resetState,
3378
+ removePeer: () => removePeer,
3379
+ debugState: () => debugState,
3380
+ clearLogs: () => clearLogs,
3381
+ addPeer: () => addPeer,
3382
+ addLog: () => addLog,
3383
+ DebugUi: () => DebugUi
3384
+ });
3385
+
3386
+ // ../../node_modules/preact/dist/preact.module.js
3387
+ var n;
3388
+ var l;
3389
+ var u;
3390
+ var t;
3391
+ var i;
3392
+ var r;
3393
+ var o;
3394
+ var e;
3395
+ var f;
3396
+ var c;
3397
+ var s;
3398
+ var a;
3399
+ var h;
3400
+ var p = {};
3401
+ var v = [];
3402
+ var y = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
3403
+ var w = Array.isArray;
3404
+ function d(n2, l2) {
3405
+ for (var u2 in l2)
3406
+ n2[u2] = l2[u2];
3407
+ return n2;
3408
+ }
3409
+ function g(n2) {
3410
+ n2 && n2.parentNode && n2.parentNode.removeChild(n2);
3411
+ }
3412
+ function _(l2, u2, t2) {
3413
+ var i2, r2, o2, e2 = {};
3414
+ for (o2 in u2)
3415
+ o2 == "key" ? i2 = u2[o2] : o2 == "ref" ? r2 = u2[o2] : e2[o2] = u2[o2];
3416
+ if (arguments.length > 2 && (e2.children = arguments.length > 3 ? n.call(arguments, 2) : t2), typeof l2 == "function" && l2.defaultProps != null)
3417
+ for (o2 in l2.defaultProps)
3418
+ e2[o2] === undefined && (e2[o2] = l2.defaultProps[o2]);
3419
+ return m(l2, e2, i2, r2, null);
3420
+ }
3421
+ function m(n2, t2, i2, r2, o2) {
3422
+ var e2 = { type: n2, props: t2, key: i2, ref: r2, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: undefined, __v: o2 == null ? ++u : o2, __i: -1, __u: 0 };
3423
+ return o2 == null && l.vnode != null && l.vnode(e2), e2;
3424
+ }
3425
+ function k(n2) {
3426
+ return n2.children;
3427
+ }
3428
+ function x(n2, l2) {
3429
+ this.props = n2, this.context = l2;
3430
+ }
3431
+ function S(n2, l2) {
3432
+ if (l2 == null)
3433
+ return n2.__ ? S(n2.__, n2.__i + 1) : null;
3434
+ for (var u2;l2 < n2.__k.length; l2++)
3435
+ if ((u2 = n2.__k[l2]) != null && u2.__e != null)
3436
+ return u2.__e;
3437
+ return typeof n2.type == "function" ? S(n2) : null;
3438
+ }
3439
+ function C(n2) {
3440
+ var l2, u2;
3441
+ if ((n2 = n2.__) != null && n2.__c != null) {
3442
+ for (n2.__e = n2.__c.base = null, l2 = 0;l2 < n2.__k.length; l2++)
3443
+ if ((u2 = n2.__k[l2]) != null && u2.__e != null) {
3444
+ n2.__e = n2.__c.base = u2.__e;
3445
+ break;
3446
+ }
3447
+ return C(n2);
3448
+ }
3449
+ }
3450
+ function M(n2) {
3451
+ (!n2.__d && (n2.__d = true) && i.push(n2) && !$.__r++ || r != l.debounceRendering) && ((r = l.debounceRendering) || o)($);
3452
+ }
3453
+ function $() {
3454
+ for (var n2, u2, t2, r2, o2, f2, c2, s2 = 1;i.length; )
3455
+ i.length > s2 && i.sort(e), n2 = i.shift(), s2 = i.length, n2.__d && (t2 = undefined, r2 = undefined, o2 = (r2 = (u2 = n2).__v).__e, f2 = [], c2 = [], u2.__P && ((t2 = d({}, r2)).__v = r2.__v + 1, l.vnode && l.vnode(t2), O(u2.__P, t2, r2, u2.__n, u2.__P.namespaceURI, 32 & r2.__u ? [o2] : null, f2, o2 == null ? S(r2) : o2, !!(32 & r2.__u), c2), t2.__v = r2.__v, t2.__.__k[t2.__i] = t2, N(f2, t2, c2), r2.__e = r2.__ = null, t2.__e != o2 && C(t2)));
3456
+ $.__r = 0;
3457
+ }
3458
+ function I(n2, l2, u2, t2, i2, r2, o2, e2, f2, c2, s2) {
3459
+ var a2, h2, y2, w2, d2, g2, _2, m2 = t2 && t2.__k || v, b = l2.length;
3460
+ for (f2 = P(u2, l2, m2, f2, b), a2 = 0;a2 < b; a2++)
3461
+ (y2 = u2.__k[a2]) != null && (h2 = y2.__i == -1 ? p : m2[y2.__i] || p, y2.__i = a2, g2 = O(n2, y2, h2, i2, r2, o2, e2, f2, c2, s2), w2 = y2.__e, y2.ref && h2.ref != y2.ref && (h2.ref && B(h2.ref, null, y2), s2.push(y2.ref, y2.__c || w2, y2)), d2 == null && w2 != null && (d2 = w2), (_2 = !!(4 & y2.__u)) || h2.__k === y2.__k ? f2 = A(y2, f2, n2, _2) : typeof y2.type == "function" && g2 !== undefined ? f2 = g2 : w2 && (f2 = w2.nextSibling), y2.__u &= -7);
3462
+ return u2.__e = d2, f2;
3463
+ }
3464
+ function P(n2, l2, u2, t2, i2) {
3465
+ var r2, o2, e2, f2, c2, s2 = u2.length, a2 = s2, h2 = 0;
3466
+ for (n2.__k = new Array(i2), r2 = 0;r2 < i2; r2++)
3467
+ (o2 = l2[r2]) != null && typeof o2 != "boolean" && typeof o2 != "function" ? (typeof o2 == "string" || typeof o2 == "number" || typeof o2 == "bigint" || o2.constructor == String ? o2 = n2.__k[r2] = m(null, o2, null, null, null) : w(o2) ? o2 = n2.__k[r2] = m(k, { children: o2 }, null, null, null) : o2.constructor == null && o2.__b > 0 ? o2 = n2.__k[r2] = m(o2.type, o2.props, o2.key, o2.ref ? o2.ref : null, o2.__v) : n2.__k[r2] = o2, f2 = r2 + h2, o2.__ = n2, o2.__b = n2.__b + 1, (c2 = o2.__i = L(o2, u2, f2, a2)) != -1 && (a2--, (e2 = u2[c2]) && (e2.__u |= 2)), e2 == null || e2.__v == null ? (c2 == -1 && (i2 > s2 ? h2-- : i2 < s2 && h2++), typeof o2.type != "function" && (o2.__u |= 4)) : c2 != f2 && (c2 == f2 - 1 ? h2-- : c2 == f2 + 1 ? h2++ : (c2 > f2 ? h2-- : h2++, o2.__u |= 4))) : n2.__k[r2] = null;
3468
+ if (a2)
3469
+ for (r2 = 0;r2 < s2; r2++)
3470
+ (e2 = u2[r2]) != null && (2 & e2.__u) == 0 && (e2.__e == t2 && (t2 = S(e2)), D(e2, e2));
3471
+ return t2;
3472
+ }
3473
+ function A(n2, l2, u2, t2) {
3474
+ var i2, r2;
3475
+ if (typeof n2.type == "function") {
3476
+ for (i2 = n2.__k, r2 = 0;i2 && r2 < i2.length; r2++)
3477
+ i2[r2] && (i2[r2].__ = n2, l2 = A(i2[r2], l2, u2, t2));
3478
+ return l2;
3479
+ }
3480
+ n2.__e != l2 && (t2 && (l2 && n2.type && !l2.parentNode && (l2 = S(n2)), u2.insertBefore(n2.__e, l2 || null)), l2 = n2.__e);
3481
+ do {
3482
+ l2 = l2 && l2.nextSibling;
3483
+ } while (l2 != null && l2.nodeType == 8);
3484
+ return l2;
3485
+ }
3486
+ function L(n2, l2, u2, t2) {
3487
+ var i2, r2, o2, e2 = n2.key, f2 = n2.type, c2 = l2[u2], s2 = c2 != null && (2 & c2.__u) == 0;
3488
+ if (c2 === null && e2 == null || s2 && e2 == c2.key && f2 == c2.type)
3489
+ return u2;
3490
+ if (t2 > (s2 ? 1 : 0)) {
3491
+ for (i2 = u2 - 1, r2 = u2 + 1;i2 >= 0 || r2 < l2.length; )
3492
+ if ((c2 = l2[o2 = i2 >= 0 ? i2-- : r2++]) != null && (2 & c2.__u) == 0 && e2 == c2.key && f2 == c2.type)
3493
+ return o2;
3494
+ }
3495
+ return -1;
3496
+ }
3497
+ function T(n2, l2, u2) {
3498
+ l2[0] == "-" ? n2.setProperty(l2, u2 == null ? "" : u2) : n2[l2] = u2 == null ? "" : typeof u2 != "number" || y.test(l2) ? u2 : u2 + "px";
3499
+ }
3500
+ function j(n2, l2, u2, t2, i2) {
3501
+ var r2, o2;
3502
+ n:
3503
+ if (l2 == "style")
3504
+ if (typeof u2 == "string")
3505
+ n2.style.cssText = u2;
3506
+ else {
3507
+ if (typeof t2 == "string" && (n2.style.cssText = t2 = ""), t2)
3508
+ for (l2 in t2)
3509
+ u2 && l2 in u2 || T(n2.style, l2, "");
3510
+ if (u2)
3511
+ for (l2 in u2)
3512
+ t2 && u2[l2] == t2[l2] || T(n2.style, l2, u2[l2]);
3513
+ }
3514
+ else if (l2[0] == "o" && l2[1] == "n")
3515
+ r2 = l2 != (l2 = l2.replace(f, "$1")), o2 = l2.toLowerCase(), l2 = o2 in n2 || l2 == "onFocusOut" || l2 == "onFocusIn" ? o2.slice(2) : l2.slice(2), n2.l || (n2.l = {}), n2.l[l2 + r2] = u2, u2 ? t2 ? u2.u = t2.u : (u2.u = c, n2.addEventListener(l2, r2 ? a : s, r2)) : n2.removeEventListener(l2, r2 ? a : s, r2);
3516
+ else {
3517
+ if (i2 == "http://www.w3.org/2000/svg")
3518
+ l2 = l2.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
3519
+ else if (l2 != "width" && l2 != "height" && l2 != "href" && l2 != "list" && l2 != "form" && l2 != "tabIndex" && l2 != "download" && l2 != "rowSpan" && l2 != "colSpan" && l2 != "role" && l2 != "popover" && l2 in n2)
3520
+ try {
3521
+ n2[l2] = u2 == null ? "" : u2;
3522
+ break n;
3523
+ } catch (n3) {}
3524
+ typeof u2 == "function" || (u2 == null || u2 === false && l2[4] != "-" ? n2.removeAttribute(l2) : n2.setAttribute(l2, l2 == "popover" && u2 == 1 ? "" : u2));
3525
+ }
3526
+ }
3527
+ function F(n2) {
3528
+ return function(u2) {
3529
+ if (this.l) {
3530
+ var t2 = this.l[u2.type + n2];
3531
+ if (u2.t == null)
3532
+ u2.t = c++;
3533
+ else if (u2.t < t2.u)
3534
+ return;
3535
+ return t2(l.event ? l.event(u2) : u2);
3536
+ }
3537
+ };
3538
+ }
3539
+ function O(n2, u2, t2, i2, r2, o2, e2, f2, c2, s2) {
3540
+ var a2, h2, p2, v2, y2, _2, m2, b, S2, C2, M2, $2, P2, A2, H, L2, T2, j2 = u2.type;
3541
+ if (u2.constructor != null)
3542
+ return null;
3543
+ 128 & t2.__u && (c2 = !!(32 & t2.__u), o2 = [f2 = u2.__e = t2.__e]), (a2 = l.__b) && a2(u2);
3544
+ n:
3545
+ if (typeof j2 == "function")
3546
+ try {
3547
+ if (b = u2.props, S2 = "prototype" in j2 && j2.prototype.render, C2 = (a2 = j2.contextType) && i2[a2.__c], M2 = a2 ? C2 ? C2.props.value : a2.__ : i2, t2.__c ? m2 = (h2 = u2.__c = t2.__c).__ = h2.__E : (S2 ? u2.__c = h2 = new j2(b, M2) : (u2.__c = h2 = new x(b, M2), h2.constructor = j2, h2.render = E), C2 && C2.sub(h2), h2.state || (h2.state = {}), h2.__n = i2, p2 = h2.__d = true, h2.__h = [], h2._sb = []), S2 && h2.__s == null && (h2.__s = h2.state), S2 && j2.getDerivedStateFromProps != null && (h2.__s == h2.state && (h2.__s = d({}, h2.__s)), d(h2.__s, j2.getDerivedStateFromProps(b, h2.__s))), v2 = h2.props, y2 = h2.state, h2.__v = u2, p2)
3548
+ S2 && j2.getDerivedStateFromProps == null && h2.componentWillMount != null && h2.componentWillMount(), S2 && h2.componentDidMount != null && h2.__h.push(h2.componentDidMount);
3549
+ else {
3550
+ if (S2 && j2.getDerivedStateFromProps == null && b !== v2 && h2.componentWillReceiveProps != null && h2.componentWillReceiveProps(b, M2), u2.__v == t2.__v || !h2.__e && h2.shouldComponentUpdate != null && h2.shouldComponentUpdate(b, h2.__s, M2) === false) {
3551
+ for (u2.__v != t2.__v && (h2.props = b, h2.state = h2.__s, h2.__d = false), u2.__e = t2.__e, u2.__k = t2.__k, u2.__k.some(function(n3) {
3552
+ n3 && (n3.__ = u2);
3553
+ }), $2 = 0;$2 < h2._sb.length; $2++)
3554
+ h2.__h.push(h2._sb[$2]);
3555
+ h2._sb = [], h2.__h.length && e2.push(h2);
3556
+ break n;
3557
+ }
3558
+ h2.componentWillUpdate != null && h2.componentWillUpdate(b, h2.__s, M2), S2 && h2.componentDidUpdate != null && h2.__h.push(function() {
3559
+ h2.componentDidUpdate(v2, y2, _2);
3560
+ });
3561
+ }
3562
+ if (h2.context = M2, h2.props = b, h2.__P = n2, h2.__e = false, P2 = l.__r, A2 = 0, S2) {
3563
+ for (h2.state = h2.__s, h2.__d = false, P2 && P2(u2), a2 = h2.render(h2.props, h2.state, h2.context), H = 0;H < h2._sb.length; H++)
3564
+ h2.__h.push(h2._sb[H]);
3565
+ h2._sb = [];
3566
+ } else
3567
+ do {
3568
+ h2.__d = false, P2 && P2(u2), a2 = h2.render(h2.props, h2.state, h2.context), h2.state = h2.__s;
3569
+ } while (h2.__d && ++A2 < 25);
3570
+ h2.state = h2.__s, h2.getChildContext != null && (i2 = d(d({}, i2), h2.getChildContext())), S2 && !p2 && h2.getSnapshotBeforeUpdate != null && (_2 = h2.getSnapshotBeforeUpdate(v2, y2)), L2 = a2, a2 != null && a2.type === k && a2.key == null && (L2 = V(a2.props.children)), f2 = I(n2, w(L2) ? L2 : [L2], u2, t2, i2, r2, o2, e2, f2, c2, s2), h2.base = u2.__e, u2.__u &= -161, h2.__h.length && e2.push(h2), m2 && (h2.__E = h2.__ = null);
3571
+ } catch (n3) {
3572
+ if (u2.__v = null, c2 || o2 != null)
3573
+ if (n3.then) {
3574
+ for (u2.__u |= c2 ? 160 : 128;f2 && f2.nodeType == 8 && f2.nextSibling; )
3575
+ f2 = f2.nextSibling;
3576
+ o2[o2.indexOf(f2)] = null, u2.__e = f2;
3577
+ } else {
3578
+ for (T2 = o2.length;T2--; )
3579
+ g(o2[T2]);
3580
+ z(u2);
3581
+ }
3582
+ else
3583
+ u2.__e = t2.__e, u2.__k = t2.__k, n3.then || z(u2);
3584
+ l.__e(n3, u2, t2);
3585
+ }
3586
+ else
3587
+ o2 == null && u2.__v == t2.__v ? (u2.__k = t2.__k, u2.__e = t2.__e) : f2 = u2.__e = q(t2.__e, u2, t2, i2, r2, o2, e2, c2, s2);
3588
+ return (a2 = l.diffed) && a2(u2), 128 & u2.__u ? undefined : f2;
3589
+ }
3590
+ function z(n2) {
3591
+ n2 && n2.__c && (n2.__c.__e = true), n2 && n2.__k && n2.__k.forEach(z);
3592
+ }
3593
+ function N(n2, u2, t2) {
3594
+ for (var i2 = 0;i2 < t2.length; i2++)
3595
+ B(t2[i2], t2[++i2], t2[++i2]);
3596
+ l.__c && l.__c(u2, n2), n2.some(function(u3) {
3597
+ try {
3598
+ n2 = u3.__h, u3.__h = [], n2.some(function(n3) {
3599
+ n3.call(u3);
3600
+ });
3601
+ } catch (n3) {
3602
+ l.__e(n3, u3.__v);
3603
+ }
3604
+ });
3605
+ }
3606
+ function V(n2) {
3607
+ return typeof n2 != "object" || n2 == null || n2.__b && n2.__b > 0 ? n2 : w(n2) ? n2.map(V) : d({}, n2);
3608
+ }
3609
+ function q(u2, t2, i2, r2, o2, e2, f2, c2, s2) {
3610
+ var a2, h2, v2, y2, d2, _2, m2, b = i2.props || p, k2 = t2.props, x2 = t2.type;
3611
+ if (x2 == "svg" ? o2 = "http://www.w3.org/2000/svg" : x2 == "math" ? o2 = "http://www.w3.org/1998/Math/MathML" : o2 || (o2 = "http://www.w3.org/1999/xhtml"), e2 != null) {
3612
+ for (a2 = 0;a2 < e2.length; a2++)
3613
+ if ((d2 = e2[a2]) && "setAttribute" in d2 == !!x2 && (x2 ? d2.localName == x2 : d2.nodeType == 3)) {
3614
+ u2 = d2, e2[a2] = null;
3615
+ break;
3616
+ }
3617
+ }
3618
+ if (u2 == null) {
3619
+ if (x2 == null)
3620
+ return document.createTextNode(k2);
3621
+ u2 = document.createElementNS(o2, x2, k2.is && k2), c2 && (l.__m && l.__m(t2, e2), c2 = false), e2 = null;
3622
+ }
3623
+ if (x2 == null)
3624
+ b === k2 || c2 && u2.data == k2 || (u2.data = k2);
3625
+ else {
3626
+ if (e2 = e2 && n.call(u2.childNodes), !c2 && e2 != null)
3627
+ for (b = {}, a2 = 0;a2 < u2.attributes.length; a2++)
3628
+ b[(d2 = u2.attributes[a2]).name] = d2.value;
3629
+ for (a2 in b)
3630
+ if (d2 = b[a2], a2 == "children")
3631
+ ;
3632
+ else if (a2 == "dangerouslySetInnerHTML")
3633
+ v2 = d2;
3634
+ else if (!(a2 in k2)) {
3635
+ if (a2 == "value" && "defaultValue" in k2 || a2 == "checked" && "defaultChecked" in k2)
3636
+ continue;
3637
+ j(u2, a2, null, d2, o2);
3638
+ }
3639
+ for (a2 in k2)
3640
+ d2 = k2[a2], a2 == "children" ? y2 = d2 : a2 == "dangerouslySetInnerHTML" ? h2 = d2 : a2 == "value" ? _2 = d2 : a2 == "checked" ? m2 = d2 : c2 && typeof d2 != "function" || b[a2] === d2 || j(u2, a2, d2, b[a2], o2);
3641
+ if (h2)
3642
+ c2 || v2 && (h2.__html == v2.__html || h2.__html == u2.innerHTML) || (u2.innerHTML = h2.__html), t2.__k = [];
3643
+ else if (v2 && (u2.innerHTML = ""), I(t2.type == "template" ? u2.content : u2, w(y2) ? y2 : [y2], t2, i2, r2, x2 == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o2, e2, f2, e2 ? e2[0] : i2.__k && S(i2, 0), c2, s2), e2 != null)
3644
+ for (a2 = e2.length;a2--; )
3645
+ g(e2[a2]);
3646
+ c2 || (a2 = "value", x2 == "progress" && _2 == null ? u2.removeAttribute("value") : _2 != null && (_2 !== u2[a2] || x2 == "progress" && !_2 || x2 == "option" && _2 != b[a2]) && j(u2, a2, _2, b[a2], o2), a2 = "checked", m2 != null && m2 != u2[a2] && j(u2, a2, m2, b[a2], o2));
3647
+ }
3648
+ return u2;
3649
+ }
3650
+ function B(n2, u2, t2) {
3651
+ try {
3652
+ if (typeof n2 == "function") {
3653
+ var i2 = typeof n2.__u == "function";
3654
+ i2 && n2.__u(), i2 && u2 == null || (n2.__u = n2(u2));
3655
+ } else
3656
+ n2.current = u2;
3657
+ } catch (n3) {
3658
+ l.__e(n3, t2);
3659
+ }
3660
+ }
3661
+ function D(n2, u2, t2) {
3662
+ var i2, r2;
3663
+ if (l.unmount && l.unmount(n2), (i2 = n2.ref) && (i2.current && i2.current != n2.__e || B(i2, null, u2)), (i2 = n2.__c) != null) {
3664
+ if (i2.componentWillUnmount)
3665
+ try {
3666
+ i2.componentWillUnmount();
3667
+ } catch (n3) {
3668
+ l.__e(n3, u2);
3669
+ }
3670
+ i2.base = i2.__P = null;
3671
+ }
3672
+ if (i2 = n2.__k)
3673
+ for (r2 = 0;r2 < i2.length; r2++)
3674
+ i2[r2] && D(i2[r2], u2, t2 || typeof n2.type != "function");
3675
+ t2 || g(n2.__e), n2.__c = n2.__ = n2.__e = undefined;
3676
+ }
3677
+ function E(n2, l2, u2) {
3678
+ return this.constructor(n2, u2);
3679
+ }
3680
+ function G(u2, t2, i2) {
3681
+ var r2, o2, e2, f2;
3682
+ t2 == document && (t2 = document.documentElement), l.__ && l.__(u2, t2), o2 = (r2 = typeof i2 == "function") ? null : i2 && i2.__k || t2.__k, e2 = [], f2 = [], O(t2, u2 = (!r2 && i2 || t2).__k = _(k, null, [u2]), o2 || p, p, t2.namespaceURI, !r2 && i2 ? [i2] : o2 ? null : t2.firstChild ? n.call(t2.childNodes) : null, e2, !r2 && i2 ? i2 : o2 ? o2.__e : t2.firstChild, r2, f2), N(e2, u2, f2);
3683
+ }
3684
+ n = v.slice, l = { __e: function(n2, l2, u2, t2) {
3685
+ for (var i2, r2, o2;l2 = l2.__; )
3686
+ if ((i2 = l2.__c) && !i2.__)
3687
+ try {
3688
+ if ((r2 = i2.constructor) && r2.getDerivedStateFromError != null && (i2.setState(r2.getDerivedStateFromError(n2)), o2 = i2.__d), i2.componentDidCatch != null && (i2.componentDidCatch(n2, t2 || {}), o2 = i2.__d), o2)
3689
+ return i2.__E = i2;
3690
+ } catch (l3) {
3691
+ n2 = l3;
3692
+ }
3693
+ throw n2;
3694
+ } }, u = 0, t = function(n2) {
3695
+ return n2 != null && n2.constructor == null;
3696
+ }, x.prototype.setState = function(n2, l2) {
3697
+ var u2;
3698
+ u2 = this.__s != null && this.__s != this.state ? this.__s : this.__s = d({}, this.state), typeof n2 == "function" && (n2 = n2(d({}, u2), this.props)), n2 && d(u2, n2), n2 != null && this.__v && (l2 && this._sb.push(l2), M(this));
3699
+ }, x.prototype.forceUpdate = function(n2) {
3700
+ this.__v && (this.__e = true, n2 && this.__h.push(n2), M(this));
3701
+ }, x.prototype.render = k, i = [], o = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e = function(n2, l2) {
3702
+ return n2.__v.__b - l2.__v.__b;
3703
+ }, $.__r = 0, f = /(PointerCapture)$|Capture$/i, c = 0, s = F(false), a = F(true), h = 0;
3704
+
3705
+ // ../../node_modules/preact/hooks/dist/hooks.module.js
3706
+ var t2;
3707
+ var r2;
3708
+ var u2;
3709
+ var i2;
3710
+ var o2 = 0;
3711
+ var f2 = [];
3712
+ var c2 = l;
3713
+ var e2 = c2.__b;
3714
+ var a2 = c2.__r;
3715
+ var v2 = c2.diffed;
3716
+ var l2 = c2.__c;
3717
+ var m2 = c2.unmount;
3718
+ var s2 = c2.__;
3719
+ function p2(n2, t3) {
3720
+ c2.__h && c2.__h(r2, n2, o2 || t3), o2 = 0;
3721
+ var u3 = r2.__H || (r2.__H = { __: [], __h: [] });
3722
+ return n2 >= u3.__.length && u3.__.push({}), u3.__[n2];
3723
+ }
3724
+ function y2(n2, u3) {
3725
+ var i3 = p2(t2++, 3);
3726
+ !c2.__s && C2(i3.__H, u3) && (i3.__ = n2, i3.u = u3, r2.__H.__h.push(i3));
3727
+ }
3728
+ function A2(n2) {
3729
+ return o2 = 5, T2(function() {
3730
+ return { current: n2 };
3731
+ }, []);
3732
+ }
3733
+ function T2(n2, r3) {
3734
+ var u3 = p2(t2++, 7);
3735
+ return C2(u3.__H, r3) && (u3.__ = n2(), u3.__H = r3, u3.__h = n2), u3.__;
3736
+ }
3737
+ function q2(n2, t3) {
3738
+ return o2 = 8, T2(function() {
3739
+ return n2;
3740
+ }, t3);
3741
+ }
3742
+ function j2() {
3743
+ for (var n2;n2 = f2.shift(); )
3744
+ if (n2.__P && n2.__H)
3745
+ try {
3746
+ n2.__H.__h.forEach(z2), n2.__H.__h.forEach(B2), n2.__H.__h = [];
3747
+ } catch (t3) {
3748
+ n2.__H.__h = [], c2.__e(t3, n2.__v);
3749
+ }
3750
+ }
3751
+ c2.__b = function(n2) {
3752
+ r2 = null, e2 && e2(n2);
3753
+ }, c2.__ = function(n2, t3) {
3754
+ n2 && t3.__k && t3.__k.__m && (n2.__m = t3.__k.__m), s2 && s2(n2, t3);
3755
+ }, c2.__r = function(n2) {
3756
+ a2 && a2(n2), t2 = 0;
3757
+ var i3 = (r2 = n2.__c).__H;
3758
+ i3 && (u2 === r2 ? (i3.__h = [], r2.__h = [], i3.__.forEach(function(n3) {
3759
+ n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = undefined;
3760
+ })) : (i3.__h.forEach(z2), i3.__h.forEach(B2), i3.__h = [], t2 = 0)), u2 = r2;
3761
+ }, c2.diffed = function(n2) {
3762
+ v2 && v2(n2);
3763
+ var t3 = n2.__c;
3764
+ t3 && t3.__H && (t3.__H.__h.length && (f2.push(t3) !== 1 && i2 === c2.requestAnimationFrame || ((i2 = c2.requestAnimationFrame) || w2)(j2)), t3.__H.__.forEach(function(n3) {
3765
+ n3.u && (n3.__H = n3.u), n3.u = undefined;
3766
+ })), u2 = r2 = null;
3767
+ }, c2.__c = function(n2, t3) {
3768
+ t3.some(function(n3) {
3769
+ try {
3770
+ n3.__h.forEach(z2), n3.__h = n3.__h.filter(function(n4) {
3771
+ return !n4.__ || B2(n4);
3772
+ });
3773
+ } catch (r3) {
3774
+ t3.some(function(n4) {
3775
+ n4.__h && (n4.__h = []);
3776
+ }), t3 = [], c2.__e(r3, n3.__v);
3777
+ }
3778
+ }), l2 && l2(n2, t3);
3779
+ }, c2.unmount = function(n2) {
3780
+ m2 && m2(n2);
3781
+ var t3, r3 = n2.__c;
3782
+ r3 && r3.__H && (r3.__H.__.forEach(function(n3) {
3783
+ try {
3784
+ z2(n3);
3785
+ } catch (n4) {
3786
+ t3 = n4;
3787
+ }
3788
+ }), r3.__H = undefined, t3 && c2.__e(t3, r3.__v));
3789
+ };
3790
+ var k2 = typeof requestAnimationFrame == "function";
3791
+ function w2(n2) {
3792
+ var t3, r3 = function() {
3793
+ clearTimeout(u3), k2 && cancelAnimationFrame(t3), setTimeout(n2);
3794
+ }, u3 = setTimeout(r3, 35);
3795
+ k2 && (t3 = requestAnimationFrame(r3));
3796
+ }
3797
+ function z2(n2) {
3798
+ var t3 = r2, u3 = n2.__c;
3799
+ typeof u3 == "function" && (n2.__c = undefined, u3()), r2 = t3;
3800
+ }
3801
+ function B2(n2) {
3802
+ var t3 = r2;
3803
+ n2.__c = n2.__(), r2 = t3;
3804
+ }
3805
+ function C2(n2, t3) {
3806
+ return !n2 || n2.length !== t3.length || t3.some(function(t4, r3) {
3807
+ return t4 !== n2[r3];
3808
+ });
3809
+ }
3810
+
3811
+ // ../../node_modules/@preact/signals-core/dist/signals-core.module.js
3812
+ var i3 = Symbol.for("preact-signals");
3813
+ function t3() {
3814
+ if (!(s3 > 1)) {
3815
+ var i4, t4 = false;
3816
+ while (h2 !== undefined) {
3817
+ var r3 = h2;
3818
+ h2 = undefined;
3819
+ f3++;
3820
+ while (r3 !== undefined) {
3821
+ var o3 = r3.o;
3822
+ r3.o = undefined;
3823
+ r3.f &= -3;
3824
+ if (!(8 & r3.f) && c3(r3))
3825
+ try {
3826
+ r3.c();
3827
+ } catch (r4) {
3828
+ if (!t4) {
3829
+ i4 = r4;
3830
+ t4 = true;
3831
+ }
3832
+ }
3833
+ r3 = o3;
3834
+ }
3835
+ }
3836
+ f3 = 0;
3837
+ s3--;
3838
+ if (t4)
3839
+ throw i4;
3840
+ } else
3841
+ s3--;
3842
+ }
3843
+ var o3 = undefined;
3844
+ function n2(i4) {
3845
+ var t4 = o3;
3846
+ o3 = undefined;
3847
+ try {
3848
+ return i4();
3849
+ } finally {
3850
+ o3 = t4;
3851
+ }
3852
+ }
3853
+ var h2 = undefined;
3854
+ var s3 = 0;
3855
+ var f3 = 0;
3856
+ var v3 = 0;
3857
+ function e3(i4) {
3858
+ if (o3 !== undefined) {
3859
+ var t4 = i4.n;
3860
+ if (t4 === undefined || t4.t !== o3) {
3861
+ t4 = { i: 0, S: i4, p: o3.s, n: undefined, t: o3, e: undefined, x: undefined, r: t4 };
3862
+ if (o3.s !== undefined)
3863
+ o3.s.n = t4;
3864
+ o3.s = t4;
3865
+ i4.n = t4;
3866
+ if (32 & o3.f)
3867
+ i4.S(t4);
3868
+ return t4;
3869
+ } else if (t4.i === -1) {
3870
+ t4.i = 0;
3871
+ if (t4.n !== undefined) {
3872
+ t4.n.p = t4.p;
3873
+ if (t4.p !== undefined)
3874
+ t4.p.n = t4.n;
3875
+ t4.p = o3.s;
3876
+ t4.n = undefined;
3877
+ o3.s.n = t4;
3878
+ o3.s = t4;
3879
+ }
3880
+ return t4;
3881
+ }
3882
+ }
3883
+ }
3884
+ function u3(i4, t4) {
3885
+ this.v = i4;
3886
+ this.i = 0;
3887
+ this.n = undefined;
3888
+ this.t = undefined;
3889
+ this.W = t4 == null ? undefined : t4.watched;
3890
+ this.Z = t4 == null ? undefined : t4.unwatched;
3891
+ this.name = t4 == null ? undefined : t4.name;
3892
+ }
3893
+ u3.prototype.brand = i3;
3894
+ u3.prototype.h = function() {
3895
+ return true;
3896
+ };
3897
+ u3.prototype.S = function(i4) {
3898
+ var t4 = this, r3 = this.t;
3899
+ if (r3 !== i4 && i4.e === undefined) {
3900
+ i4.x = r3;
3901
+ this.t = i4;
3902
+ if (r3 !== undefined)
3903
+ r3.e = i4;
3904
+ else
3905
+ n2(function() {
3906
+ var i5;
3907
+ (i5 = t4.W) == null || i5.call(t4);
3908
+ });
3909
+ }
3910
+ };
3911
+ u3.prototype.U = function(i4) {
3912
+ var t4 = this;
3913
+ if (this.t !== undefined) {
3914
+ var { e: r3, x: o4 } = i4;
3915
+ if (r3 !== undefined) {
3916
+ r3.x = o4;
3917
+ i4.e = undefined;
3918
+ }
3919
+ if (o4 !== undefined) {
3920
+ o4.e = r3;
3921
+ i4.x = undefined;
3922
+ }
3923
+ if (i4 === this.t) {
3924
+ this.t = o4;
3925
+ if (o4 === undefined)
3926
+ n2(function() {
3927
+ var i5;
3928
+ (i5 = t4.Z) == null || i5.call(t4);
3929
+ });
3930
+ }
3931
+ }
3932
+ };
3933
+ u3.prototype.subscribe = function(i4) {
3934
+ var t4 = this;
3935
+ return E2(function() {
3936
+ var r3 = t4.value, n3 = o3;
3937
+ o3 = undefined;
3938
+ try {
3939
+ i4(r3);
3940
+ } finally {
3941
+ o3 = n3;
3942
+ }
3943
+ }, { name: "sub" });
3944
+ };
3945
+ u3.prototype.valueOf = function() {
3946
+ return this.value;
3947
+ };
3948
+ u3.prototype.toString = function() {
3949
+ return this.value + "";
3950
+ };
3951
+ u3.prototype.toJSON = function() {
3952
+ return this.value;
3953
+ };
3954
+ u3.prototype.peek = function() {
3955
+ var i4 = o3;
3956
+ o3 = undefined;
3957
+ try {
3958
+ return this.value;
3959
+ } finally {
3960
+ o3 = i4;
3961
+ }
3962
+ };
3963
+ Object.defineProperty(u3.prototype, "value", { get: function() {
3964
+ var i4 = e3(this);
3965
+ if (i4 !== undefined)
3966
+ i4.i = this.i;
3967
+ return this.v;
3968
+ }, set: function(i4) {
3969
+ if (i4 !== this.v) {
3970
+ if (f3 > 100)
3971
+ throw new Error("Cycle detected");
3972
+ this.v = i4;
3973
+ this.i++;
3974
+ v3++;
3975
+ s3++;
3976
+ try {
3977
+ for (var r3 = this.t;r3 !== undefined; r3 = r3.x)
3978
+ r3.t.N();
3979
+ } finally {
3980
+ t3();
3981
+ }
3982
+ }
3983
+ } });
3984
+ function d2(i4, t4) {
3985
+ return new u3(i4, t4);
3986
+ }
3987
+ function c3(i4) {
3988
+ for (var t4 = i4.s;t4 !== undefined; t4 = t4.n)
3989
+ if (t4.S.i !== t4.i || !t4.S.h() || t4.S.i !== t4.i)
3990
+ return true;
3991
+ return false;
3992
+ }
3993
+ function a3(i4) {
3994
+ for (var t4 = i4.s;t4 !== undefined; t4 = t4.n) {
3995
+ var r3 = t4.S.n;
3996
+ if (r3 !== undefined)
3997
+ t4.r = r3;
3998
+ t4.S.n = t4;
3999
+ t4.i = -1;
4000
+ if (t4.n === undefined) {
4001
+ i4.s = t4;
4002
+ break;
4003
+ }
4004
+ }
4005
+ }
4006
+ function l3(i4) {
4007
+ var t4 = i4.s, r3 = undefined;
4008
+ while (t4 !== undefined) {
4009
+ var o4 = t4.p;
4010
+ if (t4.i === -1) {
4011
+ t4.S.U(t4);
4012
+ if (o4 !== undefined)
4013
+ o4.n = t4.n;
4014
+ if (t4.n !== undefined)
4015
+ t4.n.p = o4;
4016
+ } else
4017
+ r3 = t4;
4018
+ t4.S.n = t4.r;
4019
+ if (t4.r !== undefined)
4020
+ t4.r = undefined;
4021
+ t4 = o4;
4022
+ }
4023
+ i4.s = r3;
4024
+ }
4025
+ function y3(i4, t4) {
4026
+ u3.call(this, undefined);
4027
+ this.x = i4;
4028
+ this.s = undefined;
4029
+ this.g = v3 - 1;
4030
+ this.f = 4;
4031
+ this.W = t4 == null ? undefined : t4.watched;
4032
+ this.Z = t4 == null ? undefined : t4.unwatched;
4033
+ this.name = t4 == null ? undefined : t4.name;
4034
+ }
4035
+ y3.prototype = new u3;
4036
+ y3.prototype.h = function() {
4037
+ this.f &= -3;
4038
+ if (1 & this.f)
4039
+ return false;
4040
+ if ((36 & this.f) == 32)
4041
+ return true;
4042
+ this.f &= -5;
4043
+ if (this.g === v3)
4044
+ return true;
4045
+ this.g = v3;
4046
+ this.f |= 1;
4047
+ if (this.i > 0 && !c3(this)) {
4048
+ this.f &= -2;
4049
+ return true;
4050
+ }
4051
+ var i4 = o3;
4052
+ try {
4053
+ a3(this);
4054
+ o3 = this;
4055
+ var t4 = this.x();
4056
+ if (16 & this.f || this.v !== t4 || this.i === 0) {
4057
+ this.v = t4;
4058
+ this.f &= -17;
4059
+ this.i++;
4060
+ }
4061
+ } catch (i5) {
4062
+ this.v = i5;
4063
+ this.f |= 16;
4064
+ this.i++;
4065
+ }
4066
+ o3 = i4;
4067
+ l3(this);
4068
+ this.f &= -2;
4069
+ return true;
4070
+ };
4071
+ y3.prototype.S = function(i4) {
4072
+ if (this.t === undefined) {
4073
+ this.f |= 36;
4074
+ for (var t4 = this.s;t4 !== undefined; t4 = t4.n)
4075
+ t4.S.S(t4);
4076
+ }
4077
+ u3.prototype.S.call(this, i4);
4078
+ };
4079
+ y3.prototype.U = function(i4) {
4080
+ if (this.t !== undefined) {
4081
+ u3.prototype.U.call(this, i4);
4082
+ if (this.t === undefined) {
4083
+ this.f &= -33;
4084
+ for (var t4 = this.s;t4 !== undefined; t4 = t4.n)
4085
+ t4.S.U(t4);
4086
+ }
4087
+ }
4088
+ };
4089
+ y3.prototype.N = function() {
4090
+ if (!(2 & this.f)) {
4091
+ this.f |= 6;
4092
+ for (var i4 = this.t;i4 !== undefined; i4 = i4.x)
4093
+ i4.t.N();
4094
+ }
4095
+ };
4096
+ Object.defineProperty(y3.prototype, "value", { get: function() {
4097
+ if (1 & this.f)
4098
+ throw new Error("Cycle detected");
4099
+ var i4 = e3(this);
4100
+ this.h();
4101
+ if (i4 !== undefined)
4102
+ i4.i = this.i;
4103
+ if (16 & this.f)
4104
+ throw this.v;
4105
+ return this.v;
4106
+ } });
4107
+ function w3(i4, t4) {
4108
+ return new y3(i4, t4);
4109
+ }
4110
+ function _2(i4) {
4111
+ var r3 = i4.u;
4112
+ i4.u = undefined;
4113
+ if (typeof r3 == "function") {
4114
+ s3++;
4115
+ var n3 = o3;
4116
+ o3 = undefined;
4117
+ try {
4118
+ r3();
4119
+ } catch (t4) {
4120
+ i4.f &= -2;
4121
+ i4.f |= 8;
4122
+ b(i4);
4123
+ throw t4;
4124
+ } finally {
4125
+ o3 = n3;
4126
+ t3();
4127
+ }
4128
+ }
4129
+ }
4130
+ function b(i4) {
4131
+ for (var t4 = i4.s;t4 !== undefined; t4 = t4.n)
4132
+ t4.S.U(t4);
4133
+ i4.x = undefined;
4134
+ i4.s = undefined;
4135
+ _2(i4);
4136
+ }
4137
+ function g2(i4) {
4138
+ if (o3 !== this)
4139
+ throw new Error("Out-of-order effect");
4140
+ l3(this);
4141
+ o3 = i4;
4142
+ this.f &= -2;
4143
+ if (8 & this.f)
4144
+ b(this);
4145
+ t3();
4146
+ }
4147
+ function p3(i4, t4) {
4148
+ this.x = i4;
4149
+ this.u = undefined;
4150
+ this.s = undefined;
4151
+ this.o = undefined;
4152
+ this.f = 32;
4153
+ this.name = t4 == null ? undefined : t4.name;
4154
+ }
4155
+ p3.prototype.c = function() {
4156
+ var i4 = this.S();
4157
+ try {
4158
+ if (8 & this.f)
4159
+ return;
4160
+ if (this.x === undefined)
4161
+ return;
4162
+ var t4 = this.x();
4163
+ if (typeof t4 == "function")
4164
+ this.u = t4;
4165
+ } finally {
4166
+ i4();
4167
+ }
4168
+ };
4169
+ p3.prototype.S = function() {
4170
+ if (1 & this.f)
4171
+ throw new Error("Cycle detected");
4172
+ this.f |= 1;
4173
+ this.f &= -9;
4174
+ _2(this);
4175
+ a3(this);
4176
+ s3++;
4177
+ var i4 = o3;
4178
+ o3 = this;
4179
+ return g2.bind(this, i4);
4180
+ };
4181
+ p3.prototype.N = function() {
4182
+ if (!(2 & this.f)) {
4183
+ this.f |= 2;
4184
+ this.o = h2;
4185
+ h2 = this;
4186
+ }
4187
+ };
4188
+ p3.prototype.d = function() {
4189
+ this.f |= 8;
4190
+ if (!(1 & this.f))
4191
+ b(this);
4192
+ };
4193
+ p3.prototype.dispose = function() {
4194
+ this.d();
4195
+ };
4196
+ function E2(i4, t4) {
4197
+ var r3 = new p3(i4, t4);
4198
+ try {
4199
+ r3.c();
4200
+ } catch (i5) {
4201
+ r3.d();
4202
+ throw i5;
4203
+ }
4204
+ var o4 = r3.d.bind(r3);
4205
+ o4[Symbol.dispose] = o4;
4206
+ return o4;
4207
+ }
4208
+
4209
+ // ../../node_modules/@preact/signals/dist/signals.module.js
4210
+ var v4;
4211
+ var s4;
4212
+ function l4(i4, n3) {
4213
+ l[i4] = n3.bind(null, l[i4] || function() {});
4214
+ }
4215
+ function d3(i4) {
4216
+ if (s4)
4217
+ s4();
4218
+ s4 = i4 && i4.S();
4219
+ }
4220
+ function h3(i4) {
4221
+ var r4 = this, f4 = i4.data, o4 = useSignal(f4);
4222
+ o4.value = f4;
4223
+ var e4 = T2(function() {
4224
+ var i5 = r4.__v;
4225
+ while (i5 = i5.__)
4226
+ if (i5.__c) {
4227
+ i5.__c.__$f |= 4;
4228
+ break;
4229
+ }
4230
+ r4.__$u.c = function() {
4231
+ var i6, t4 = r4.__$u.S(), f5 = e4.value;
4232
+ t4();
4233
+ if (t(f5) || ((i6 = r4.base) == null ? undefined : i6.nodeType) !== 3) {
4234
+ r4.__$f |= 1;
4235
+ r4.setState({});
4236
+ } else
4237
+ r4.base.data = f5;
4238
+ };
4239
+ return w3(function() {
4240
+ var i6 = o4.value.value;
4241
+ return i6 === 0 ? 0 : i6 === true ? "" : i6 || "";
4242
+ });
4243
+ }, []);
4244
+ return e4.value;
4245
+ }
4246
+ h3.displayName = "_st";
4247
+ Object.defineProperties(u3.prototype, { constructor: { configurable: true, value: undefined }, type: { configurable: true, value: h3 }, props: { configurable: true, get: function() {
4248
+ return { data: this };
4249
+ } }, __b: { configurable: true, value: 1 } });
4250
+ l4("__b", function(i4, r4) {
4251
+ if (typeof r4.type == "string") {
4252
+ var n3, t4 = r4.props;
4253
+ for (var f4 in t4)
4254
+ if (f4 !== "children") {
4255
+ var o4 = t4[f4];
4256
+ if (o4 instanceof u3) {
4257
+ if (!n3)
4258
+ r4.__np = n3 = {};
4259
+ n3[f4] = o4;
4260
+ t4[f4] = o4.peek();
4261
+ }
4262
+ }
4263
+ }
4264
+ i4(r4);
4265
+ });
4266
+ l4("__r", function(i4, r4) {
4267
+ d3();
4268
+ var n3, t4 = r4.__c;
4269
+ if (t4) {
4270
+ t4.__$f &= -2;
4271
+ if ((n3 = t4.__$u) === undefined)
4272
+ t4.__$u = n3 = function(i5) {
4273
+ var r5;
4274
+ E2(function() {
4275
+ r5 = this;
4276
+ });
4277
+ r5.c = function() {
4278
+ t4.__$f |= 1;
4279
+ t4.setState({});
4280
+ };
4281
+ return r5;
4282
+ }();
4283
+ }
4284
+ v4 = t4;
4285
+ d3(n3);
4286
+ i4(r4);
4287
+ });
4288
+ l4("__e", function(i4, r4, n3, t4) {
4289
+ d3();
4290
+ v4 = undefined;
4291
+ i4(r4, n3, t4);
4292
+ });
4293
+ l4("diffed", function(i4, r4) {
4294
+ d3();
4295
+ v4 = undefined;
4296
+ var n3;
4297
+ if (typeof r4.type == "string" && (n3 = r4.__e)) {
4298
+ var { __np: t4, props: f4 } = r4;
4299
+ if (t4) {
4300
+ var o4 = n3.U;
4301
+ if (o4)
4302
+ for (var e4 in o4) {
4303
+ var u4 = o4[e4];
4304
+ if (u4 !== undefined && !(e4 in t4)) {
4305
+ u4.d();
4306
+ o4[e4] = undefined;
4307
+ }
4308
+ }
4309
+ else
4310
+ n3.U = o4 = {};
4311
+ for (var a4 in t4) {
4312
+ var c4 = o4[a4], s5 = t4[a4];
4313
+ if (c4 === undefined) {
4314
+ c4 = p4(n3, a4, s5, f4);
4315
+ o4[a4] = c4;
4316
+ } else
4317
+ c4.o(s5, f4);
4318
+ }
4319
+ }
4320
+ }
4321
+ i4(r4);
4322
+ });
4323
+ function p4(i4, r4, n3, t4) {
4324
+ var f4 = r4 in i4 && i4.ownerSVGElement === undefined, o4 = d2(n3);
4325
+ return { o: function(i5, r5) {
4326
+ o4.value = i5;
4327
+ t4 = r5;
4328
+ }, d: E2(function() {
4329
+ var n4 = o4.value.value;
4330
+ if (t4[r4] !== n4) {
4331
+ t4[r4] = n4;
4332
+ if (f4)
4333
+ i4[r4] = n4;
4334
+ else if (n4)
4335
+ i4.setAttribute(r4, n4);
4336
+ else
4337
+ i4.removeAttribute(r4);
4338
+ }
4339
+ }) };
4340
+ }
4341
+ l4("unmount", function(i4, r4) {
4342
+ if (typeof r4.type == "string") {
4343
+ var n3 = r4.__e;
4344
+ if (n3) {
4345
+ var t4 = n3.U;
4346
+ if (t4) {
4347
+ n3.U = undefined;
4348
+ for (var f4 in t4) {
4349
+ var o4 = t4[f4];
4350
+ if (o4)
4351
+ o4.d();
4352
+ }
4353
+ }
4354
+ }
4355
+ } else {
4356
+ var e4 = r4.__c;
4357
+ if (e4) {
4358
+ var u4 = e4.__$u;
4359
+ if (u4) {
4360
+ e4.__$u = undefined;
4361
+ u4.d();
4362
+ }
4363
+ }
4364
+ }
4365
+ i4(r4);
4366
+ });
4367
+ l4("__h", function(i4, r4, n3, t4) {
4368
+ if (t4 < 3 || t4 === 9)
4369
+ r4.__$f |= 2;
4370
+ i4(r4, n3, t4);
4371
+ });
4372
+ x.prototype.shouldComponentUpdate = function(i4, r4) {
4373
+ var n3 = this.__$u, t4 = n3 && n3.s !== undefined;
4374
+ for (var f4 in r4)
4375
+ return true;
4376
+ if (this.__f || typeof this.u == "boolean" && this.u === true) {
4377
+ if (!(t4 || 2 & this.__$f || 4 & this.__$f))
4378
+ return true;
4379
+ if (1 & this.__$f)
4380
+ return true;
4381
+ } else {
4382
+ if (!(t4 || 4 & this.__$f))
4383
+ return true;
4384
+ if (3 & this.__$f)
4385
+ return true;
4386
+ }
4387
+ for (var o4 in i4)
4388
+ if (o4 !== "__source" && i4[o4] !== this.props[o4])
4389
+ return true;
4390
+ for (var e4 in this.props)
4391
+ if (!(e4 in i4))
4392
+ return true;
4393
+ return false;
4394
+ };
4395
+ function useSignal(i4) {
4396
+ return T2(function() {
4397
+ return d2(i4);
4398
+ }, []);
4399
+ }
4400
+ function useSignalEffect(i4) {
4401
+ var r4 = A2(i4);
4402
+ r4.current = i4;
4403
+ y2(function() {
4404
+ return E2(function() {
4405
+ return r4.current();
4406
+ });
4407
+ }, []);
4408
+ }
4409
+
4410
+ // src/debugui/state.ts
4411
+ var isVisible = d2(false);
4412
+ var netStatus = d2({
4413
+ ourId: null,
4414
+ remoteId: null,
4415
+ rtt: null,
4416
+ peers: []
4417
+ });
4418
+ var logs = d2([]);
4419
+ var debugState = {
4420
+ isVisible,
4421
+ netStatus,
4422
+ logs,
4423
+ peer: w3(() => netStatus.value.peers[0] ?? null),
4424
+ advantage: w3(() => {
4425
+ const peer = netStatus.value.peers[0];
4426
+ return peer ? peer.seq - peer.ack : null;
4427
+ })
4428
+ };
4429
+ function addLog(log) {
4430
+ debugState.logs.value = [...debugState.logs.value, log];
4431
+ }
4432
+ function updatePeer(id, updates) {
4433
+ const peers = [...debugState.netStatus.value.peers];
4434
+ const idx = peers.findIndex((p5) => p5.id === id);
4435
+ const existing = peers[idx];
4436
+ if (idx >= 0 && existing) {
4437
+ peers[idx] = {
4438
+ id: updates.id ?? existing.id,
4439
+ nickname: updates.nickname ?? existing.nickname,
4440
+ ack: updates.ack ?? existing.ack,
4441
+ seq: updates.seq ?? existing.seq,
4442
+ lastPacketTime: updates.lastPacketTime ?? existing.lastPacketTime
4443
+ };
4444
+ debugState.netStatus.value = {
4445
+ ...debugState.netStatus.value,
4446
+ peers
4447
+ };
4448
+ }
4449
+ }
4450
+ function addPeer(peer) {
4451
+ debugState.netStatus.value = {
4452
+ ...debugState.netStatus.value,
4453
+ peers: [...debugState.netStatus.value.peers, peer]
4454
+ };
4455
+ }
4456
+ function removePeer(id) {
4457
+ debugState.netStatus.value = {
4458
+ ...debugState.netStatus.value,
4459
+ peers: debugState.netStatus.value.peers.filter((p5) => p5.id !== id)
4460
+ };
4461
+ }
4462
+ function setLocalId(id) {
4463
+ debugState.netStatus.value = {
4464
+ ...debugState.netStatus.value,
4465
+ ourId: id
4466
+ };
4467
+ }
4468
+ function setRemoteId(id) {
4469
+ debugState.netStatus.value = {
4470
+ ...debugState.netStatus.value,
4471
+ remoteId: id
4472
+ };
4473
+ }
4474
+ function clearLogs() {
4475
+ debugState.logs.value = [];
4476
+ }
4477
+ function resetState() {
4478
+ debugState.isVisible.value = false;
4479
+ debugState.logs.value = [];
4480
+ debugState.netStatus.value = {
4481
+ ourId: null,
4482
+ remoteId: null,
4483
+ rtt: null,
4484
+ peers: []
4485
+ };
4486
+ }
4487
+ // ../../node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
4488
+ var f4 = 0;
4489
+ function u4(e4, t4, n3, o4, i4, u5) {
4490
+ t4 || (t4 = {});
4491
+ var a4, c4, p5 = t4;
4492
+ if ("ref" in p5)
4493
+ for (c4 in p5 = {}, t4)
4494
+ c4 == "ref" ? a4 = t4[c4] : p5[c4] = t4[c4];
4495
+ var l5 = { type: e4, props: p5, key: n3, ref: a4, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: undefined, __v: --f4, __i: -1, __u: 0, __source: i4, __self: u5 };
4496
+ if (typeof e4 == "function" && (a4 = e4.defaultProps))
4497
+ for (c4 in a4)
4498
+ p5[c4] === undefined && (p5[c4] = a4[c4]);
4499
+ return l.vnode && l.vnode(l5), l5;
4500
+ }
4501
+
4502
+ // src/debugui/components/Stats.tsx
4503
+ function Stats() {
4504
+ const peer = debugState.peer.value;
4505
+ const netStatus2 = debugState.netStatus.value;
4506
+ const lastPacketTime = useSignal(null);
4507
+ useSignalEffect(() => {
4508
+ const p5 = debugState.peer.value;
4509
+ if (!p5) {
4510
+ lastPacketTime.value = null;
4511
+ return;
4512
+ }
4513
+ const update = () => {
4514
+ lastPacketTime.value = (performance.now() - p5.lastPacketTime).toFixed(0);
4515
+ };
4516
+ update();
4517
+ const id = setInterval(update, 100);
4518
+ return () => clearInterval(id);
4519
+ });
4520
+ if (!peer) {
4521
+ return /* @__PURE__ */ u4("div", {
4522
+ className: "stats-panel",
4523
+ children: [
4524
+ /* @__PURE__ */ u4("h3", {
4525
+ children: "Network Stats"
4526
+ }, undefined, false, undefined, this),
4527
+ /* @__PURE__ */ u4("p", {
4528
+ children: "No peer connected"
4529
+ }, undefined, false, undefined, this)
4530
+ ]
4531
+ }, undefined, true, undefined, this);
4532
+ }
4533
+ return /* @__PURE__ */ u4("div", {
4534
+ className: "stats-panel",
4535
+ children: [
4536
+ /* @__PURE__ */ u4("h3", {
4537
+ children: [
4538
+ "Network Stats - ",
4539
+ peer.nickname
4540
+ ]
4541
+ }, undefined, true, undefined, this),
4542
+ /* @__PURE__ */ u4("table", {
4543
+ children: /* @__PURE__ */ u4("tbody", {
4544
+ children: [
4545
+ /* @__PURE__ */ u4("tr", {
4546
+ children: [
4547
+ /* @__PURE__ */ u4("td", {
4548
+ children: "Our Peer ID"
4549
+ }, undefined, false, undefined, this),
4550
+ /* @__PURE__ */ u4("td", {
4551
+ children: netStatus2.ourId
4552
+ }, undefined, false, undefined, this)
4553
+ ]
4554
+ }, undefined, true, undefined, this),
4555
+ /* @__PURE__ */ u4("tr", {
4556
+ children: [
4557
+ /* @__PURE__ */ u4("td", {
4558
+ children: "Remote Peer ID"
4559
+ }, undefined, false, undefined, this),
4560
+ /* @__PURE__ */ u4("td", {
4561
+ children: netStatus2.remoteId
4562
+ }, undefined, false, undefined, this)
4563
+ ]
4564
+ }, undefined, true, undefined, this),
4565
+ /* @__PURE__ */ u4("tr", {
4566
+ children: [
4567
+ /* @__PURE__ */ u4("td", {
4568
+ children: "Advantage"
4569
+ }, undefined, false, undefined, this),
4570
+ /* @__PURE__ */ u4("td", {
4571
+ children: peer.seq - peer.ack
4572
+ }, undefined, false, undefined, this)
4573
+ ]
4574
+ }, undefined, true, undefined, this),
4575
+ /* @__PURE__ */ u4("tr", {
4576
+ children: [
4577
+ /* @__PURE__ */ u4("td", {
4578
+ children: "Current Seq"
4579
+ }, undefined, false, undefined, this),
4580
+ /* @__PURE__ */ u4("td", {
4581
+ children: peer.seq
4582
+ }, undefined, false, undefined, this)
4583
+ ]
4584
+ }, undefined, true, undefined, this),
4585
+ /* @__PURE__ */ u4("tr", {
4586
+ children: [
4587
+ /* @__PURE__ */ u4("td", {
4588
+ children: "Current Ack"
4589
+ }, undefined, false, undefined, this),
4590
+ /* @__PURE__ */ u4("td", {
4591
+ children: peer.ack
4592
+ }, undefined, false, undefined, this)
4593
+ ]
4594
+ }, undefined, true, undefined, this),
4595
+ /* @__PURE__ */ u4("tr", {
4596
+ children: [
4597
+ /* @__PURE__ */ u4("td", {
4598
+ children: "Time since last packet"
4599
+ }, undefined, false, undefined, this),
4600
+ /* @__PURE__ */ u4("td", {
4601
+ children: [
4602
+ lastPacketTime.value,
4603
+ "ms"
4604
+ ]
4605
+ }, undefined, true, undefined, this)
4606
+ ]
4607
+ }, undefined, true, undefined, this)
4608
+ ]
4609
+ }, undefined, true, undefined, this)
4610
+ }, undefined, false, undefined, this)
4611
+ ]
4612
+ }, undefined, true, undefined, this);
4613
+ }
4614
+
4615
+ // src/debugui/hooks/useAutoScroll.ts
4616
+ function useAutoScroll(threshold = 80) {
4617
+ const containerRef = A2(null);
4618
+ const autoScrollRef = A2(true);
4619
+ const onScroll = q2(() => {
4620
+ const el = containerRef.current;
4621
+ if (!el)
4622
+ return;
4623
+ const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
4624
+ autoScrollRef.current = distanceFromBottom < threshold;
4625
+ }, [threshold]);
4626
+ const scrollToBottom = q2(() => {
4627
+ const el = containerRef.current;
4628
+ if (!el)
4629
+ return;
4630
+ requestAnimationFrame(() => {
4631
+ el.scrollTop = el.scrollHeight;
4632
+ });
4633
+ }, []);
4634
+ const onContentUpdated = q2(() => {
4635
+ if (autoScrollRef.current) {
4636
+ scrollToBottom();
4637
+ }
4638
+ }, [scrollToBottom]);
4639
+ y2(() => {
4640
+ const el = containerRef.current;
4641
+ if (el) {
4642
+ el.addEventListener("scroll", onScroll);
4643
+ return () => el.removeEventListener("scroll", onScroll);
4644
+ }
4645
+ }, [onScroll]);
4646
+ const setRef = q2((el) => {
4647
+ if (containerRef.current) {
4648
+ containerRef.current.removeEventListener("scroll", onScroll);
4649
+ }
4650
+ containerRef.current = el;
4651
+ if (el) {
4652
+ el.addEventListener("scroll", onScroll);
4653
+ }
4654
+ }, [onScroll]);
4655
+ return {
4656
+ containerRef: setRef,
4657
+ onContentUpdated,
4658
+ scrollToBottom
4659
+ };
4660
+ }
4661
+
4662
+ // src/debugui/components/Logs.tsx
4663
+ function formatTimestamp(ms) {
4664
+ const date = new Date(ms);
4665
+ const hours = date.getHours() % 12;
4666
+ const minutes = date.getMinutes().toString().padStart(2, "0");
4667
+ const seconds = date.getSeconds().toString().padStart(2, "0");
4668
+ const millis = date.getMilliseconds().toString().padStart(3, "0");
4669
+ return `${hours}:${minutes}:${seconds}.${millis}`;
4670
+ }
4671
+ function Logs() {
4672
+ const { containerRef, onContentUpdated } = useAutoScroll(80);
4673
+ const logs2 = debugState.logs.value;
4674
+ useSignalEffect(() => {
4675
+ const _3 = debugState.logs.value.length;
4676
+ onContentUpdated();
4677
+ });
4678
+ return /* @__PURE__ */ u4("ul", {
4679
+ className: "logs-list",
4680
+ ref: containerRef,
4681
+ children: logs2.map((log, index) => /* @__PURE__ */ u4(LogEntry, {
4682
+ log
4683
+ }, index, false, undefined, this))
4684
+ }, undefined, false, undefined, this);
4685
+ }
4686
+ function LogEntry({ log }) {
4687
+ return /* @__PURE__ */ u4("li", {
4688
+ className: `log ${log.source}`,
4689
+ children: /* @__PURE__ */ u4("div", {
4690
+ className: "contents",
4691
+ children: [
4692
+ /* @__PURE__ */ u4("h3", {
4693
+ className: log.source,
4694
+ children: [
4695
+ /* @__PURE__ */ u4("span", {
4696
+ className: "source",
4697
+ children: [
4698
+ log.source,
4699
+ " | "
4700
+ ]
4701
+ }, undefined, true, undefined, this),
4702
+ log.match_frame != null ? /* @__PURE__ */ u4("span", {
4703
+ className: "frame-number",
4704
+ children: [
4705
+ "m",
4706
+ log.match_frame,
4707
+ " | "
4708
+ ]
4709
+ }, undefined, true, undefined, this) : /* @__PURE__ */ u4("span", {
4710
+ className: "frame-number",
4711
+ children: [
4712
+ "f",
4713
+ log.frame_number,
4714
+ " | "
4715
+ ]
4716
+ }, undefined, true, undefined, this),
4717
+ /* @__PURE__ */ u4("span", {
4718
+ className: "timestamp",
4719
+ children: formatTimestamp(log.timestamp)
4720
+ }, undefined, false, undefined, this)
4721
+ ]
4722
+ }, undefined, true, undefined, this),
4723
+ /* @__PURE__ */ u4("div", {
4724
+ className: "content",
4725
+ children: [
4726
+ log.label && /* @__PURE__ */ u4("p", {
4727
+ children: log.label
4728
+ }, undefined, false, undefined, this),
4729
+ log.json && /* @__PURE__ */ u4("pre", {
4730
+ className: "json",
4731
+ children: JSON.stringify(log.json, null, 2)
4732
+ }, undefined, false, undefined, this),
4733
+ log.packet && /* @__PURE__ */ u4("div", {
4734
+ children: [
4735
+ log.packet.size,
4736
+ " bytes"
4737
+ ]
4738
+ }, undefined, true, undefined, this)
4739
+ ]
4740
+ }, undefined, true, undefined, this)
4741
+ ]
4742
+ }, undefined, true, undefined, this)
4743
+ }, undefined, false, undefined, this);
4744
+ }
4745
+
4746
+ // src/debugui/components/DebugToggle.tsx
4747
+ function DebugToggle({ hotkey = "Escape" }) {
4748
+ const isVisible2 = debugState.isVisible.value;
4749
+ const toggle = () => {
4750
+ debugState.isVisible.value = !debugState.isVisible.value;
4751
+ };
4752
+ return /* @__PURE__ */ u4("button", {
4753
+ className: "debug-toggle",
4754
+ onClick: toggle,
4755
+ onMouseDown: (e4) => e4.stopPropagation(),
4756
+ onMouseUp: (e4) => e4.stopPropagation(),
4757
+ title: isVisible2 ? `Hide debug (${hotkey})` : `Show debug (${hotkey})`,
4758
+ children: isVisible2 ? "✕" : "⚙"
4759
+ }, undefined, false, undefined, this);
4760
+ }
4761
+
4762
+ // src/debugui/components/Root.tsx
4763
+ function Root({ canvas, hotkey = "Escape" }) {
4764
+ const isVisible2 = debugState.isVisible.value;
4765
+ return /* @__PURE__ */ u4(k, {
4766
+ children: [
4767
+ isVisible2 ? /* @__PURE__ */ u4("main", {
4768
+ className: "layout",
4769
+ children: [
4770
+ /* @__PURE__ */ u4("section", {
4771
+ className: "game",
4772
+ children: /* @__PURE__ */ u4(GameCanvas, {
4773
+ canvas
4774
+ }, undefined, false, undefined, this)
4775
+ }, undefined, false, undefined, this),
4776
+ /* @__PURE__ */ u4("section", {
4777
+ className: "stats",
4778
+ children: /* @__PURE__ */ u4(Stats, {}, undefined, false, undefined, this)
4779
+ }, undefined, false, undefined, this),
4780
+ /* @__PURE__ */ u4("section", {
4781
+ className: "logs",
4782
+ children: /* @__PURE__ */ u4(Logs, {}, undefined, false, undefined, this)
4783
+ }, undefined, false, undefined, this)
4784
+ ]
4785
+ }, undefined, true, undefined, this) : /* @__PURE__ */ u4("main", {
4786
+ className: "fullscreen",
4787
+ children: /* @__PURE__ */ u4(GameCanvas, {
4788
+ canvas
4789
+ }, undefined, false, undefined, this)
4790
+ }, undefined, false, undefined, this),
4791
+ /* @__PURE__ */ u4(DebugToggle, {
4792
+ hotkey
4793
+ }, undefined, false, undefined, this)
4794
+ ]
4795
+ }, undefined, true, undefined, this);
4796
+ }
4797
+ function GameCanvas({ canvas }) {
4798
+ const containerRef = A2(null);
4799
+ y2(() => {
4800
+ const container = containerRef.current;
4801
+ if (container && !container.contains(canvas)) {
4802
+ container.appendChild(canvas);
4803
+ }
4804
+ return () => {};
4805
+ }, [canvas]);
4806
+ return /* @__PURE__ */ u4("div", {
4807
+ className: "canvas-container",
4808
+ ref: containerRef
4809
+ }, undefined, false, undefined, this);
4810
+ }
4811
+
4812
+ // src/debugui/styles.ts
4813
+ var styles = `
4814
+ /* Reset for shadow DOM */
4815
+ * {
4816
+ box-sizing: border-box;
4817
+ }
4818
+
4819
+ /* Layout */
4820
+ .fullscreen {
4821
+ width: 100%;
4822
+ height: 100%;
4823
+ margin: 0;
4824
+ padding: 0;
4825
+ overflow: hidden;
4826
+ }
4827
+
4828
+ .layout {
4829
+ display: grid;
4830
+ grid-template-areas:
4831
+ "game stats"
4832
+ "logs logs";
4833
+ grid-template-columns: calc(50% - 0.5rem) calc(50% - 0.5rem);
4834
+ grid-template-rows: calc(50% - 0.5rem) calc(50% - 0.5rem);
4835
+ gap: 1rem;
4836
+ width: 100%;
4837
+ height: 100%;
4838
+ padding: 1rem;
4839
+ }
4840
+
4841
+ .game {
4842
+ grid-area: game;
4843
+ border-radius: 8px;
4844
+ overflow: hidden;
4845
+ }
4846
+
4847
+ .stats {
4848
+ grid-area: stats;
4849
+ background-color: #f0f0f0;
4850
+ padding: 1rem;
4851
+ border-radius: 8px;
4852
+ overflow: hidden;
4853
+ }
4854
+
4855
+ .logs {
4856
+ grid-area: logs;
4857
+ background-color: #f0f0f0;
4858
+ padding: 1rem;
4859
+ border-radius: 8px;
4860
+ overflow: hidden;
4861
+ }
4862
+
4863
+ /* Canvas container */
4864
+ .canvas-container {
4865
+ width: 100%;
4866
+ height: 100%;
4867
+ display: flex;
4868
+ align-items: center;
4869
+ justify-content: center;
4870
+ }
4871
+
4872
+ .canvas-container canvas {
4873
+ max-width: 100%;
4874
+ max-height: 100%;
4875
+ }
4876
+
4877
+ /* Debug toggle button */
4878
+ .debug-toggle {
4879
+ position: fixed;
4880
+ bottom: 16px;
4881
+ right: 16px;
4882
+ width: 40px;
4883
+ height: 40px;
4884
+ border-radius: 50%;
4885
+ border: none;
4886
+ background-color: rgba(0, 0, 0, 0.5);
4887
+ color: white;
4888
+ font-size: 18px;
4889
+ cursor: pointer;
4890
+ z-index: 1000;
4891
+ display: flex;
4892
+ align-items: center;
4893
+ justify-content: center;
4894
+ transition: background-color 0.2s;
4895
+ }
4896
+
4897
+ .debug-toggle:hover {
4898
+ background-color: rgba(0, 0, 0, 0.7);
4899
+ }
4900
+
4901
+ /* Stats panel */
4902
+ .stats-panel {
4903
+ background: rgba(0, 0, 0, 0.7);
4904
+ color: white;
4905
+ padding: 12px;
4906
+ border-radius: 8px;
4907
+ font-family: monospace;
4908
+ font-size: 14px;
4909
+ max-width: 100%;
4910
+ overflow: hidden;
4911
+ }
4912
+
4913
+ .stats-panel h3 {
4914
+ margin: 0 0 8px 0;
4915
+ font-size: 14px;
4916
+ font-weight: 600;
4917
+ white-space: nowrap;
4918
+ overflow: hidden;
4919
+ text-overflow: ellipsis;
4920
+ }
4921
+
4922
+ .stats-panel table {
4923
+ width: 100%;
4924
+ border-collapse: collapse;
4925
+ table-layout: fixed;
4926
+ }
4927
+
4928
+ .stats-panel tr {
4929
+ border-bottom: 1px solid rgba(255, 255, 255, 0.2);
4930
+ }
4931
+
4932
+ .stats-panel tr:last-child {
4933
+ border-bottom: none;
4934
+ }
4935
+
4936
+ .stats-panel td {
4937
+ padding: 4px 0;
4938
+ overflow: hidden;
4939
+ text-overflow: ellipsis;
4940
+ white-space: nowrap;
4941
+ }
4942
+
4943
+ .stats-panel td:first-child {
4944
+ opacity: 0.7;
4945
+ width: 60%;
4946
+ }
4947
+
4948
+ .stats-panel td:last-child {
4949
+ text-align: right;
4950
+ font-weight: 600;
4951
+ width: 40%;
4952
+ }
4953
+
4954
+ .stats-panel p {
4955
+ margin: 0;
4956
+ opacity: 0.7;
4957
+ }
4958
+
4959
+ /* Logs panel */
4960
+ .logs-list {
4961
+ width: 100%;
4962
+ height: 100%;
4963
+ overflow: auto;
4964
+ margin: 0;
4965
+ padding: 0;
4966
+ }
4967
+
4968
+ .logs-list li {
4969
+ margin: 0 0 24px 0;
4970
+ list-style: none;
4971
+ }
4972
+
4973
+ .logs-list h3 {
4974
+ font-size: 16px;
4975
+ font-weight: 500;
4976
+ margin: 0;
4977
+ }
4978
+
4979
+ .logs-list .ws {
4980
+ color: darkolivegreen;
4981
+ }
4982
+
4983
+ .logs-list .webrtc {
4984
+ color: darkmagenta;
4985
+ }
4986
+
4987
+ .logs-list .rollback {
4988
+ color: darkblue;
4989
+ }
4990
+
4991
+ .logs-list .local {
4992
+ color: #333;
4993
+ }
4994
+
4995
+ .logs-list .content {
4996
+ font-size: 16px;
4997
+ }
4998
+
4999
+ .logs-list p {
5000
+ margin: 4px 0;
5001
+ }
5002
+
5003
+ .logs-list pre {
5004
+ margin: 0;
5005
+ white-space: pre-wrap;
5006
+ word-break: break-word;
5007
+ background-color: oldlace;
5008
+ padding: 8px;
5009
+ border-radius: 4px;
5010
+ border: 1px inset lavender;
5011
+ }
5012
+ `;
5013
+
5014
+ // src/debugui/DebugUi.ts
5015
+ class DebugUi {
5016
+ #host;
5017
+ #shadow;
5018
+ #canvas;
5019
+ #mountPoint;
5020
+ #cleanup = null;
5021
+ #hotkey;
5022
+ constructor(options = {}) {
5023
+ this.#hotkey = options.hotkey ?? "Escape";
5024
+ const container = options.container ?? document.body;
5025
+ const initiallyVisible = options.initiallyVisible ?? new URLSearchParams(window.location.search).has("debug");
5026
+ this.#host = document.createElement("bloop-debug-ui");
5027
+ this.#host.style.cssText = "display:block;width:100%;height:100%;position:absolute;top:0;left:0;";
5028
+ this.#shadow = this.#host.attachShadow({ mode: "open" });
5029
+ const styleEl = document.createElement("style");
5030
+ styleEl.textContent = styles;
5031
+ this.#shadow.appendChild(styleEl);
5032
+ this.#mountPoint = document.createElement("div");
5033
+ this.#mountPoint.id = "debug-root";
5034
+ this.#mountPoint.style.cssText = "width:100%;height:100%;";
5035
+ this.#shadow.appendChild(this.#mountPoint);
5036
+ debugState.isVisible.value = initiallyVisible;
5037
+ this.#canvas = document.createElement("canvas");
5038
+ this.#render();
5039
+ container.appendChild(this.#host);
5040
+ this.#cleanup = this.#setupHotkey();
5041
+ debugState.isVisible.subscribe(() => {
5042
+ this.#render();
5043
+ });
5044
+ }
5045
+ #render() {
5046
+ G(Root({ canvas: this.#canvas, hotkey: this.#hotkey }), this.#mountPoint);
5047
+ }
5048
+ #setupHotkey() {
5049
+ const handler = (e4) => {
5050
+ if (e4.key === this.#hotkey) {
5051
+ debugState.isVisible.value = !debugState.isVisible.value;
5052
+ }
5053
+ };
5054
+ window.addEventListener("keydown", handler);
5055
+ return () => window.removeEventListener("keydown", handler);
5056
+ }
5057
+ get canvas() {
5058
+ return this.#canvas;
5059
+ }
5060
+ get state() {
5061
+ return debugState;
5062
+ }
5063
+ get isVisible() {
5064
+ return debugState.isVisible.value;
5065
+ }
5066
+ set isVisible(value) {
5067
+ debugState.isVisible.value = value;
5068
+ }
5069
+ unmount() {
5070
+ this.#cleanup?.();
5071
+ G(null, this.#mountPoint);
5072
+ this.#host.remove();
5073
+ }
5074
+ }
3360
5075
  // src/App.ts
3361
5076
  var DEFAULT_BROKER_URL = "wss://webrtc-divine-glade-8064.fly.dev/ws";
3362
5077
  async function start(opts) {
@@ -3368,7 +5083,8 @@ async function start(opts) {
3368
5083
  });
3369
5084
  opts.sim = sim;
3370
5085
  }
3371
- const app = new App(opts.sim, opts.game, opts.brokerUrl ?? DEFAULT_BROKER_URL);
5086
+ const debugOpts = opts.debugUi ? typeof opts.debugUi === "boolean" ? {} : opts.debugUi : undefined;
5087
+ const app = new App(opts.sim, opts.game, opts.brokerUrl ?? DEFAULT_BROKER_URL, debugOpts);
3372
5088
  return app;
3373
5089
  }
3374
5090
 
@@ -3379,10 +5095,14 @@ class App {
3379
5095
  #rafHandle = null;
3380
5096
  #unsubscribe = null;
3381
5097
  #now = performance.now();
3382
- constructor(sim, game, brokerUrl) {
5098
+ #debugUi = null;
5099
+ constructor(sim, game, brokerUrl, debugUiOpts) {
3383
5100
  this.#sim = sim;
3384
5101
  this.game = game;
3385
5102
  this.brokerUrl = brokerUrl;
5103
+ if (debugUiOpts) {
5104
+ this.#initDebugUi(debugUiOpts);
5105
+ }
3386
5106
  this.game.hooks.beforeFrame = (frame) => {
3387
5107
  logger.frameNumber = this.#sim.time.frame;
3388
5108
  logger.matchFrame = this.#sim.wasm.get_match_frame();
@@ -3396,6 +5116,18 @@ class App {
3396
5116
  set sim(sim) {
3397
5117
  this.#sim = sim;
3398
5118
  }
5119
+ #initDebugUi(opts = {}) {
5120
+ if (this.#debugUi)
5121
+ return this.#debugUi;
5122
+ this.#debugUi = new DebugUi(opts);
5123
+ return this.#debugUi;
5124
+ }
5125
+ get debugUi() {
5126
+ return this.#debugUi;
5127
+ }
5128
+ get canvas() {
5129
+ return this.#debugUi?.canvas ?? null;
5130
+ }
3399
5131
  joinRoom(roomId, callbacks) {
3400
5132
  joinRoom(this.brokerUrl, roomId, callbacks);
3401
5133
  }
@@ -3469,8 +5201,8 @@ class App {
3469
5201
  if (!this.sim.isPaused) {
3470
5202
  try {
3471
5203
  this.afterFrame.notify(this.sim.time.frame);
3472
- } catch (e) {
3473
- console.error("Error in afterFrame listeners:", e);
5204
+ } catch (e4) {
5205
+ console.error("Error in afterFrame listeners:", e4);
3474
5206
  }
3475
5207
  }
3476
5208
  this.#now = performance.now();
@@ -3498,6 +5230,7 @@ class App {
3498
5230
  this.sim.unmount();
3499
5231
  this.beforeFrame.unsubscribeAll();
3500
5232
  this.afterFrame.unsubscribeAll();
5233
+ this.#debugUi?.unmount();
3501
5234
  }
3502
5235
  async acceptHmr(module, opts) {
3503
5236
  const game = module.game ?? module;
@@ -3541,12 +5274,134 @@ var PacketType;
3541
5274
  PacketType2[PacketType2["None"] = 0] = "None";
3542
5275
  PacketType2[PacketType2["Inputs"] = 1] = "Inputs";
3543
5276
  })(PacketType ||= {});
5277
+ // src/netcode/scaffold.ts
5278
+ function joinRollbackRoom(roomId, app, opts) {
5279
+ let udp = null;
5280
+ let sessionActive = false;
5281
+ let localPeerId = null;
5282
+ let remotePeerId = null;
5283
+ let localStringPeerId = null;
5284
+ let remoteStringPeerId = null;
5285
+ const incomingPackets = [];
5286
+ function assignPeerIds(localId, remoteId) {
5287
+ if (localId < remoteId) {
5288
+ return { local: 0, remote: 1 };
5289
+ } else {
5290
+ return { local: 1, remote: 0 };
5291
+ }
5292
+ }
5293
+ function receivePackets() {
5294
+ for (const packetData of incomingPackets) {
5295
+ app.sim.net.receivePacket(packetData);
5296
+ if (remotePeerId == null) {
5297
+ return;
5298
+ }
5299
+ const peerState = app.sim.net.getPeerState(remotePeerId);
5300
+ updatePeer(remoteStringPeerId, {
5301
+ ack: peerState.ack,
5302
+ seq: peerState.seq,
5303
+ lastPacketTime: performance.now()
5304
+ });
5305
+ }
5306
+ incomingPackets.length = 0;
5307
+ }
5308
+ function sendPacket() {
5309
+ if (!udp || remotePeerId === null) {
5310
+ console.warn("[netcode] Cannot send packet, udp or remotePeerId is null");
5311
+ return;
5312
+ }
5313
+ if (udp.readyState !== "open") {
5314
+ console.warn("[netcode] Data channel not open, cannot send packet. readyState=", udp.readyState);
5315
+ return;
5316
+ }
5317
+ const packet = app.sim.net.getOutboundPacket(remotePeerId);
5318
+ if (!packet) {
5319
+ console.warn("[netcode] No packet to send");
5320
+ return;
5321
+ }
5322
+ udp.send(packet);
5323
+ }
5324
+ logger.onLog = (log) => {
5325
+ addLog(log);
5326
+ };
5327
+ app.joinRoom(roomId, {
5328
+ onPeerIdAssign: (peerId) => {
5329
+ console.log(`Assigned peer ID: ${peerId}`);
5330
+ localStringPeerId = peerId;
5331
+ },
5332
+ onBrokerMessage: (_message) => {},
5333
+ onMessage(_peerId, data, _reliable) {
5334
+ incomingPackets.push(new Uint8Array(data));
5335
+ },
5336
+ onDataChannelClose(peerId, reliable) {
5337
+ console.log(`Data channel closed: ${peerId} (reliable: ${reliable})`);
5338
+ if (!reliable && remotePeerId !== null) {
5339
+ app.sim.net.disconnectPeer(remotePeerId);
5340
+ sessionActive = false;
5341
+ opts?.onSessionEnd?.();
5342
+ }
5343
+ },
5344
+ onDataChannelOpen(peerId, reliable, channel) {
5345
+ console.log(`Data channel opened: ${peerId} (reliable: ${reliable})`);
5346
+ if (!reliable) {
5347
+ udp = channel;
5348
+ if (localStringPeerId === null) {
5349
+ console.error("[netcode] Local peer ID not assigned yet!");
5350
+ return;
5351
+ }
5352
+ const ids = assignPeerIds(localStringPeerId, peerId);
5353
+ localPeerId = ids.local;
5354
+ setLocalId(localPeerId);
5355
+ remotePeerId = ids.remote;
5356
+ remoteStringPeerId = peerId;
5357
+ setRemoteId(remotePeerId);
5358
+ app.sim.sessionInit(2);
5359
+ app.sim.net.setLocalPeer(localPeerId);
5360
+ app.sim.net.connectPeer(remotePeerId);
5361
+ sessionActive = true;
5362
+ console.log(`[netcode] Session started at frame ${app.sim.time.frame}`);
5363
+ opts?.onSessionStart?.();
5364
+ }
5365
+ },
5366
+ onPeerConnected(peerId) {
5367
+ addPeer({
5368
+ id: peerId,
5369
+ nickname: peerId.substring(0, 6),
5370
+ ack: -1,
5371
+ seq: -1,
5372
+ lastPacketTime: performance.now()
5373
+ });
5374
+ console.log(`[netcode] Peer connected: ${peerId}. Total peers: ${debugState.netStatus.value.peers.length}`);
5375
+ },
5376
+ onPeerDisconnected(peerId) {
5377
+ removePeer(peerId);
5378
+ if (remotePeerId !== null && peerId === remoteStringPeerId) {
5379
+ app.sim.net.disconnectPeer(remotePeerId);
5380
+ sessionActive = false;
5381
+ opts?.onSessionEnd?.();
5382
+ }
5383
+ }
5384
+ });
5385
+ app.beforeFrame.subscribe((_frame) => {
5386
+ if (!sessionActive || !udp || remotePeerId === null) {
5387
+ return;
5388
+ }
5389
+ try {
5390
+ receivePackets();
5391
+ sendPacket();
5392
+ } catch (e4) {
5393
+ console.error("Error in beforeFrame:", e4);
5394
+ }
5395
+ });
5396
+ }
3544
5397
  export {
3545
5398
  start,
3546
5399
  logger,
5400
+ joinRollbackRoom,
3547
5401
  PacketType,
5402
+ exports_mod as Debug,
3548
5403
  App
3549
5404
  };
3550
5405
 
3551
- //# debugId=9F8E122AB076111B64756E2164756E21
5406
+ //# debugId=C0F22781B267720E64756E2164756E21
3552
5407
  //# sourceMappingURL=mod.js.map