@fairfox/polly 0.79.0 → 0.81.0

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 (40) hide show
  1. package/dist/cli/polly.js +52 -1
  2. package/dist/cli/polly.js.map +3 -3
  3. package/dist/tools/mutate/src/args.d.ts +22 -0
  4. package/dist/tools/mutate/src/cli.d.ts +2 -0
  5. package/dist/tools/mutate/src/cli.js +743 -0
  6. package/dist/tools/mutate/src/cli.js.map +19 -0
  7. package/dist/tools/mutate/src/config.d.ts +13 -0
  8. package/dist/tools/mutate/src/decisions.d.ts +34 -0
  9. package/dist/tools/mutate/src/index.d.ts +13 -0
  10. package/dist/tools/mutate/src/index.js +471 -0
  11. package/dist/tools/mutate/src/index.js.map +14 -0
  12. package/dist/tools/mutate/src/ingest.d.ts +47 -0
  13. package/dist/tools/mutate/src/init.d.ts +12 -0
  14. package/dist/tools/mutate/src/report.d.ts +15 -0
  15. package/dist/tools/mutate/src/run.d.ts +11 -0
  16. package/dist/tools/mutate/src/verify-matrix.d.ts +49 -0
  17. package/dist/tools/test/src/coverage-policy/cli.d.ts +19 -0
  18. package/dist/tools/test/src/coverage-policy/cli.js +339 -0
  19. package/dist/tools/test/src/coverage-policy/cli.js.map +13 -0
  20. package/dist/tools/test/src/coverage-policy/discover.d.ts +23 -0
  21. package/dist/tools/test/src/coverage-policy/enforce.d.ts +54 -0
  22. package/dist/tools/test/src/coverage-policy/index.d.ts +10 -0
  23. package/dist/tools/test/src/coverage-policy/index.js +242 -0
  24. package/dist/tools/test/src/coverage-policy/index.js.map +13 -0
  25. package/dist/tools/test/src/coverage-policy/mutate-targets.d.ts +30 -0
  26. package/dist/tools/test/src/coverage-policy/types.d.ts +35 -0
  27. package/dist/tools/test/src/e2e-mesh/index.js +18 -2
  28. package/dist/tools/test/src/e2e-mesh/index.js.map +5 -4
  29. package/dist/tools/test/src/e2e-mesh/wait-for-convergence.d.ts +8 -0
  30. package/dist/tools/test/src/e2e-relay/index.d.ts +1 -1
  31. package/dist/tools/test/src/e2e-relay/index.js +1421 -0
  32. package/dist/tools/test/src/e2e-relay/index.js.map +30 -0
  33. package/dist/tools/test/src/e2e-relay/wait-for-relay-convergence.d.ts +8 -0
  34. package/dist/tools/test/src/e2e-relay/with-repo-server.d.ts +9 -0
  35. package/dist/tools/test/src/e2e-shared/index.d.ts +1 -0
  36. package/dist/tools/test/src/e2e-shared/timeout-context.d.ts +17 -0
  37. package/dist/tools/test/src/index.d.ts +1 -0
  38. package/dist/tools/test/src/index.js +16 -1
  39. package/dist/tools/test/src/index.js.map +5 -4
  40. package/package.json +15 -1
@@ -0,0 +1,1421 @@
1
+ import { createRequire } from "node:module";
2
+ var __defProp = Object.defineProperty;
3
+ var __returnValue = (v) => v;
4
+ function __exportSetter(name, newValue) {
5
+ this[name] = __returnValue.bind(null, newValue);
6
+ }
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true,
12
+ configurable: true,
13
+ set: __exportSetter.bind(all, name)
14
+ });
15
+ };
16
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
18
+
19
+ // src/shared/lib/sweep-sealed.ts
20
+ var exports_sweep_sealed = {};
21
+ __export(exports_sweep_sealed, {
22
+ sweepSealed: () => sweepSealed
23
+ });
24
+ import { Automerge as Automerge3 } from "@automerge/automerge-repo/slim";
25
+ function concat(parts) {
26
+ let total = 0;
27
+ for (const part of parts)
28
+ total += part.byteLength;
29
+ const out = new Uint8Array(total);
30
+ let offset = 0;
31
+ for (const part of parts) {
32
+ out.set(part, offset);
33
+ offset += part.byteLength;
34
+ }
35
+ return out;
36
+ }
37
+ function materialise(chunks) {
38
+ const content = chunks.filter((chunk) => chunk.key[1] !== "sync-state" && chunk.data !== undefined).sort((a4, b4) => (a4.key[1] === "snapshot" ? 0 : 1) - (b4.key[1] === "snapshot" ? 0 : 1));
39
+ if (content.length === 0)
40
+ return;
41
+ try {
42
+ return Automerge3.loadIncremental(Automerge3.init(), concat(content.map((chunk) => chunk.data)));
43
+ } catch {
44
+ return;
45
+ }
46
+ }
47
+ async function collectChunksByDocument(storage, documentIds) {
48
+ const chunks = [];
49
+ if (documentIds === undefined) {
50
+ chunks.push(...await storage.loadRange([]));
51
+ } else {
52
+ for (const documentId of documentIds) {
53
+ chunks.push(...await storage.loadRange([documentId]));
54
+ }
55
+ }
56
+ const byDocument = new Map;
57
+ for (const chunk of chunks) {
58
+ const documentId = chunk.key[0];
59
+ if (documentId === undefined)
60
+ continue;
61
+ const existing = byDocument.get(documentId);
62
+ if (existing)
63
+ existing.push(chunk);
64
+ else
65
+ byDocument.set(documentId, [chunk]);
66
+ }
67
+ return byDocument;
68
+ }
69
+ function classifyDocument(documentId, chunks, context) {
70
+ const doc = materialise(chunks);
71
+ if (doc === undefined)
72
+ return { action: "ignore" };
73
+ const sealedAt = context.isSealed(doc);
74
+ if (sealedAt === undefined)
75
+ return { action: "ignore" };
76
+ const id = documentId;
77
+ if (context.repo.handles[id] !== undefined) {
78
+ return { action: "keep", entry: { documentId: id, reason: "open-handle" } };
79
+ }
80
+ if (context.at - sealedAt < context.olderThan) {
81
+ return { action: "keep", entry: { documentId: id, reason: "too-recent" } };
82
+ }
83
+ const byteSize = chunks.reduce((sum, chunk) => sum + (chunk.data?.byteLength ?? 0), 0);
84
+ return { action: "sweep", entry: { documentId: id, sealedAt, byteSize } };
85
+ }
86
+ async function sweepSealed(options) {
87
+ const { repo, storage, isSealed, olderThan } = options;
88
+ const dryRun = options.dryRun ?? false;
89
+ const now = options.now ?? Date.now;
90
+ const byDocument = await collectChunksByDocument(storage, options.documentIds);
91
+ const swept = [];
92
+ const kept = [];
93
+ const at = now();
94
+ for (const [documentId, chunks] of byDocument) {
95
+ const verdict = classifyDocument(documentId, chunks, { repo, isSealed, olderThan, at });
96
+ if (verdict.action === "keep") {
97
+ kept.push(verdict.entry);
98
+ } else if (verdict.action === "sweep") {
99
+ swept.push(verdict.entry);
100
+ if (!dryRun)
101
+ await storage.removeRange([documentId]);
102
+ }
103
+ }
104
+ return { swept, kept, dryRun };
105
+ }
106
+ var init_sweep_sealed = () => {};
107
+
108
+ // tools/test/src/e2e-shared/timeout-context.ts
109
+ async function resolveContext(context) {
110
+ if (!context)
111
+ return "";
112
+ try {
113
+ return `
114
+
115
+ transport: ${await context()}`;
116
+ } catch (err) {
117
+ return `
118
+
119
+ transport: <context threw: ${err instanceof Error ? err.message : String(err)}>`;
120
+ }
121
+ }
122
+
123
+ // tools/test/src/e2e-relay/wait-for-relay-convergence.ts
124
+ async function waitForRelayConvergence(targets, predicate, options = {}) {
125
+ const { timeoutMs = 1e4, pollMs = 50 } = options;
126
+ const deadline = Date.now() + timeoutMs;
127
+ let last = [];
128
+ while (Date.now() < deadline) {
129
+ last = targets.map((t) => ({ peerId: t.peerId, value: t.read() }));
130
+ if (last.every(({ value, peerId }) => predicate(value, peerId)))
131
+ return;
132
+ await new Promise((r) => setTimeout(r, pollMs));
133
+ }
134
+ const summary = last.map(({ peerId, value }) => ` ${peerId}: ${JSON.stringify(value)}`).join(`
135
+ `);
136
+ const transport = await resolveContext(options.context);
137
+ throw new Error(`waitForRelayConvergence: predicate did not hold for every peer within ${timeoutMs}ms.
138
+ ${summary}${transport}`);
139
+ }
140
+ // tools/test/src/e2e-relay/with-repo-server.ts
141
+ import { mkdtempSync, rmSync } from "node:fs";
142
+ import { tmpdir } from "node:os";
143
+ import { join } from "node:path";
144
+ import { WebSocketServer } from "ws";
145
+
146
+ // src/shared/lib/wasm-init.ts
147
+ import wasmPath from "@automerge/automerge/automerge.wasm";
148
+ import { initializeWasm } from "@automerge/automerge-repo/slim";
149
+ var wasmUrl = new URL(wasmPath, import.meta.url).href;
150
+ await initializeWasm(wasmUrl);
151
+
152
+ // src/shared/lib/crdt-specialised.ts
153
+ import { Automerge, Counter, updateText } from "@automerge/automerge-repo/slim";
154
+
155
+ // ../../node_modules/.bun/preact@10.29.1/node_modules/preact/dist/preact.mjs
156
+ var n;
157
+ var l;
158
+ var u;
159
+ var t;
160
+ var i;
161
+ var r;
162
+ var o;
163
+ var e;
164
+ var f;
165
+ var c;
166
+ var s;
167
+ var a;
168
+ var h;
169
+ var p;
170
+ var v;
171
+ var y;
172
+ var d = {};
173
+ var w = [];
174
+ var _ = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
175
+ var g = Array.isArray;
176
+ function m(n2, l2) {
177
+ for (var u2 in l2)
178
+ n2[u2] = l2[u2];
179
+ return n2;
180
+ }
181
+ function b(n2) {
182
+ n2 && n2.parentNode && n2.parentNode.removeChild(n2);
183
+ }
184
+ function x(n2, t2, i2, r2, o2) {
185
+ 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 };
186
+ return o2 == null && l.vnode != null && l.vnode(e2), e2;
187
+ }
188
+ function S(n2) {
189
+ return n2.children;
190
+ }
191
+ function C(n2, l2) {
192
+ this.props = n2, this.context = l2;
193
+ }
194
+ function $(n2, l2) {
195
+ if (l2 == null)
196
+ return n2.__ ? $(n2.__, n2.__i + 1) : null;
197
+ for (var u2;l2 < n2.__k.length; l2++)
198
+ if ((u2 = n2.__k[l2]) != null && u2.__e != null)
199
+ return u2.__e;
200
+ return typeof n2.type == "function" ? $(n2) : null;
201
+ }
202
+ function I(n2) {
203
+ if (n2.__P && n2.__d) {
204
+ var u2 = n2.__v, t2 = u2.__e, i2 = [], r2 = [], o2 = m({}, u2);
205
+ o2.__v = u2.__v + 1, l.vnode && l.vnode(o2), q(n2.__P, o2, u2, n2.__n, n2.__P.namespaceURI, 32 & u2.__u ? [t2] : null, i2, t2 == null ? $(u2) : t2, !!(32 & u2.__u), r2), o2.__v = u2.__v, o2.__.__k[o2.__i] = o2, D(i2, o2, r2), u2.__e = u2.__ = null, o2.__e != t2 && P(o2);
206
+ }
207
+ }
208
+ function P(n2) {
209
+ if ((n2 = n2.__) != null && n2.__c != null)
210
+ return n2.__e = n2.__c.base = null, n2.__k.some(function(l2) {
211
+ if (l2 != null && l2.__e != null)
212
+ return n2.__e = n2.__c.base = l2.__e;
213
+ }), P(n2);
214
+ }
215
+ function A(n2) {
216
+ (!n2.__d && (n2.__d = true) && i.push(n2) && !H.__r++ || r != l.debounceRendering) && ((r = l.debounceRendering) || o)(H);
217
+ }
218
+ function H() {
219
+ try {
220
+ for (var n2, l2 = 1;i.length; )
221
+ i.length > l2 && i.sort(e), n2 = i.shift(), l2 = i.length, I(n2);
222
+ } finally {
223
+ i.length = H.__r = 0;
224
+ }
225
+ }
226
+ function L(n2, l2, u2, t2, i2, r2, o2, e2, f2, c2, s2) {
227
+ var a2, h2, p2, v2, y2, _2, g2, m2 = t2 && t2.__k || w, b2 = l2.length;
228
+ for (f2 = T(u2, l2, m2, f2, b2), a2 = 0;a2 < b2; a2++)
229
+ (p2 = u2.__k[a2]) != null && (h2 = p2.__i != -1 && m2[p2.__i] || d, p2.__i = a2, _2 = q(n2, p2, h2, i2, r2, o2, e2, f2, c2, s2), v2 = p2.__e, p2.ref && h2.ref != p2.ref && (h2.ref && J(h2.ref, null, p2), s2.push(p2.ref, p2.__c || v2, p2)), y2 == null && v2 != null && (y2 = v2), (g2 = !!(4 & p2.__u)) || h2.__k === p2.__k ? (f2 = j(p2, f2, n2, g2), g2 && h2.__e && (h2.__e = null)) : typeof p2.type == "function" && _2 !== undefined ? f2 = _2 : v2 && (f2 = v2.nextSibling), p2.__u &= -7);
230
+ return u2.__e = y2, f2;
231
+ }
232
+ function T(n2, l2, u2, t2, i2) {
233
+ var r2, o2, e2, f2, c2, s2 = u2.length, a2 = s2, h2 = 0;
234
+ for (n2.__k = new Array(i2), r2 = 0;r2 < i2; r2++)
235
+ (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] = x(null, o2, null, null, null) : g(o2) ? o2 = n2.__k[r2] = x(S, { children: o2 }, null, null, null) : o2.constructor === undefined && o2.__b > 0 ? o2 = n2.__k[r2] = x(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, e2 = null, (c2 = o2.__i = O(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;
236
+ if (a2)
237
+ for (r2 = 0;r2 < s2; r2++)
238
+ (e2 = u2[r2]) != null && (2 & e2.__u) == 0 && (e2.__e == t2 && (t2 = $(e2)), K(e2, e2));
239
+ return t2;
240
+ }
241
+ function j(n2, l2, u2, t2) {
242
+ var i2, r2;
243
+ if (typeof n2.type == "function") {
244
+ for (i2 = n2.__k, r2 = 0;i2 && r2 < i2.length; r2++)
245
+ i2[r2] && (i2[r2].__ = n2, l2 = j(i2[r2], l2, u2, t2));
246
+ return l2;
247
+ }
248
+ n2.__e != l2 && (t2 && (l2 && n2.type && !l2.parentNode && (l2 = $(n2)), u2.insertBefore(n2.__e, l2 || null)), l2 = n2.__e);
249
+ do {
250
+ l2 = l2 && l2.nextSibling;
251
+ } while (l2 != null && l2.nodeType == 8);
252
+ return l2;
253
+ }
254
+ function O(n2, l2, u2, t2) {
255
+ var i2, r2, o2, e2 = n2.key, f2 = n2.type, c2 = l2[u2], s2 = c2 != null && (2 & c2.__u) == 0;
256
+ if (c2 === null && e2 == null || s2 && e2 == c2.key && f2 == c2.type)
257
+ return u2;
258
+ if (t2 > (s2 ? 1 : 0)) {
259
+ for (i2 = u2 - 1, r2 = u2 + 1;i2 >= 0 || r2 < l2.length; )
260
+ if ((c2 = l2[o2 = i2 >= 0 ? i2-- : r2++]) != null && (2 & c2.__u) == 0 && e2 == c2.key && f2 == c2.type)
261
+ return o2;
262
+ }
263
+ return -1;
264
+ }
265
+ function z(n2, l2, u2) {
266
+ l2[0] == "-" ? n2.setProperty(l2, u2 == null ? "" : u2) : n2[l2] = u2 == null ? "" : typeof u2 != "number" || _.test(l2) ? u2 : u2 + "px";
267
+ }
268
+ function N(n2, l2, u2, t2, i2) {
269
+ var r2, o2;
270
+ n:
271
+ if (l2 == "style")
272
+ if (typeof u2 == "string")
273
+ n2.style.cssText = u2;
274
+ else {
275
+ if (typeof t2 == "string" && (n2.style.cssText = t2 = ""), t2)
276
+ for (l2 in t2)
277
+ u2 && l2 in u2 || z(n2.style, l2, "");
278
+ if (u2)
279
+ for (l2 in u2)
280
+ t2 && u2[l2] == t2[l2] || z(n2.style, l2, u2[l2]);
281
+ }
282
+ else if (l2[0] == "o" && l2[1] == "n")
283
+ r2 = l2 != (l2 = l2.replace(a, "$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[s] = t2[s] : (u2[s] = h, n2.addEventListener(l2, r2 ? v : p, r2)) : n2.removeEventListener(l2, r2 ? v : p, r2);
284
+ else {
285
+ if (i2 == "http://www.w3.org/2000/svg")
286
+ l2 = l2.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
287
+ 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)
288
+ try {
289
+ n2[l2] = u2 == null ? "" : u2;
290
+ break n;
291
+ } catch (n3) {}
292
+ typeof u2 == "function" || (u2 == null || u2 === false && l2[4] != "-" ? n2.removeAttribute(l2) : n2.setAttribute(l2, l2 == "popover" && u2 == 1 ? "" : u2));
293
+ }
294
+ }
295
+ function V(n2) {
296
+ return function(u2) {
297
+ if (this.l) {
298
+ var t2 = this.l[u2.type + n2];
299
+ if (u2[c] == null)
300
+ u2[c] = h++;
301
+ else if (u2[c] < t2[s])
302
+ return;
303
+ return t2(l.event ? l.event(u2) : u2);
304
+ }
305
+ };
306
+ }
307
+ function q(n2, u2, t2, i2, r2, o2, e2, f2, c2, s2) {
308
+ var a2, h2, p2, v2, y2, d2, _2, k, x2, M, $2, I2, P2, A2, H2, T2 = u2.type;
309
+ if (u2.constructor !== undefined)
310
+ return null;
311
+ 128 & t2.__u && (c2 = !!(32 & t2.__u), o2 = [f2 = u2.__e = t2.__e]), (a2 = l.__b) && a2(u2);
312
+ n:
313
+ if (typeof T2 == "function")
314
+ try {
315
+ if (k = u2.props, x2 = T2.prototype && T2.prototype.render, M = (a2 = T2.contextType) && i2[a2.__c], $2 = a2 ? M ? M.props.value : a2.__ : i2, t2.__c ? _2 = (h2 = u2.__c = t2.__c).__ = h2.__E : (x2 ? u2.__c = h2 = new T2(k, $2) : (u2.__c = h2 = new C(k, $2), h2.constructor = T2, h2.render = Q), M && M.sub(h2), h2.state || (h2.state = {}), h2.__n = i2, p2 = h2.__d = true, h2.__h = [], h2._sb = []), x2 && h2.__s == null && (h2.__s = h2.state), x2 && T2.getDerivedStateFromProps != null && (h2.__s == h2.state && (h2.__s = m({}, h2.__s)), m(h2.__s, T2.getDerivedStateFromProps(k, h2.__s))), v2 = h2.props, y2 = h2.state, h2.__v = u2, p2)
316
+ x2 && T2.getDerivedStateFromProps == null && h2.componentWillMount != null && h2.componentWillMount(), x2 && h2.componentDidMount != null && h2.__h.push(h2.componentDidMount);
317
+ else {
318
+ if (x2 && T2.getDerivedStateFromProps == null && k !== v2 && h2.componentWillReceiveProps != null && h2.componentWillReceiveProps(k, $2), u2.__v == t2.__v || !h2.__e && h2.shouldComponentUpdate != null && h2.shouldComponentUpdate(k, h2.__s, $2) === false) {
319
+ u2.__v != t2.__v && (h2.props = k, h2.state = h2.__s, h2.__d = false), u2.__e = t2.__e, u2.__k = t2.__k, u2.__k.some(function(n3) {
320
+ n3 && (n3.__ = u2);
321
+ }), w.push.apply(h2.__h, h2._sb), h2._sb = [], h2.__h.length && e2.push(h2);
322
+ break n;
323
+ }
324
+ h2.componentWillUpdate != null && h2.componentWillUpdate(k, h2.__s, $2), x2 && h2.componentDidUpdate != null && h2.__h.push(function() {
325
+ h2.componentDidUpdate(v2, y2, d2);
326
+ });
327
+ }
328
+ if (h2.context = $2, h2.props = k, h2.__P = n2, h2.__e = false, I2 = l.__r, P2 = 0, x2)
329
+ h2.state = h2.__s, h2.__d = false, I2 && I2(u2), a2 = h2.render(h2.props, h2.state, h2.context), w.push.apply(h2.__h, h2._sb), h2._sb = [];
330
+ else
331
+ do {
332
+ h2.__d = false, I2 && I2(u2), a2 = h2.render(h2.props, h2.state, h2.context), h2.state = h2.__s;
333
+ } while (h2.__d && ++P2 < 25);
334
+ h2.state = h2.__s, h2.getChildContext != null && (i2 = m(m({}, i2), h2.getChildContext())), x2 && !p2 && h2.getSnapshotBeforeUpdate != null && (d2 = h2.getSnapshotBeforeUpdate(v2, y2)), A2 = a2 != null && a2.type === S && a2.key == null ? E(a2.props.children) : a2, f2 = L(n2, g(A2) ? A2 : [A2], u2, t2, i2, r2, o2, e2, f2, c2, s2), h2.base = u2.__e, u2.__u &= -161, h2.__h.length && e2.push(h2), _2 && (h2.__E = h2.__ = null);
335
+ } catch (n3) {
336
+ if (u2.__v = null, c2 || o2 != null)
337
+ if (n3.then) {
338
+ for (u2.__u |= c2 ? 160 : 128;f2 && f2.nodeType == 8 && f2.nextSibling; )
339
+ f2 = f2.nextSibling;
340
+ o2[o2.indexOf(f2)] = null, u2.__e = f2;
341
+ } else {
342
+ for (H2 = o2.length;H2--; )
343
+ b(o2[H2]);
344
+ B(u2);
345
+ }
346
+ else
347
+ u2.__e = t2.__e, u2.__k = t2.__k, n3.then || B(u2);
348
+ l.__e(n3, u2, t2);
349
+ }
350
+ else
351
+ o2 == null && u2.__v == t2.__v ? (u2.__k = t2.__k, u2.__e = t2.__e) : f2 = u2.__e = G(t2.__e, u2, t2, i2, r2, o2, e2, c2, s2);
352
+ return (a2 = l.diffed) && a2(u2), 128 & u2.__u ? undefined : f2;
353
+ }
354
+ function B(n2) {
355
+ n2 && (n2.__c && (n2.__c.__e = true), n2.__k && n2.__k.some(B));
356
+ }
357
+ function D(n2, u2, t2) {
358
+ for (var i2 = 0;i2 < t2.length; i2++)
359
+ J(t2[i2], t2[++i2], t2[++i2]);
360
+ l.__c && l.__c(u2, n2), n2.some(function(u3) {
361
+ try {
362
+ n2 = u3.__h, u3.__h = [], n2.some(function(n3) {
363
+ n3.call(u3);
364
+ });
365
+ } catch (n3) {
366
+ l.__e(n3, u3.__v);
367
+ }
368
+ });
369
+ }
370
+ function E(n2) {
371
+ return typeof n2 != "object" || n2 == null || n2.__b > 0 ? n2 : g(n2) ? n2.map(E) : m({}, n2);
372
+ }
373
+ function G(u2, t2, i2, r2, o2, e2, f2, c2, s2) {
374
+ var a2, h2, p2, v2, y2, w2, _2, m2 = i2.props || d, k = t2.props, x2 = t2.type;
375
+ 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) {
376
+ for (a2 = 0;a2 < e2.length; a2++)
377
+ if ((y2 = e2[a2]) && "setAttribute" in y2 == !!x2 && (x2 ? y2.localName == x2 : y2.nodeType == 3)) {
378
+ u2 = y2, e2[a2] = null;
379
+ break;
380
+ }
381
+ }
382
+ if (u2 == null) {
383
+ if (x2 == null)
384
+ return document.createTextNode(k);
385
+ u2 = document.createElementNS(o2, x2, k.is && k), c2 && (l.__m && l.__m(t2, e2), c2 = false), e2 = null;
386
+ }
387
+ if (x2 == null)
388
+ m2 === k || c2 && u2.data == k || (u2.data = k);
389
+ else {
390
+ if (e2 = e2 && n.call(u2.childNodes), !c2 && e2 != null)
391
+ for (m2 = {}, a2 = 0;a2 < u2.attributes.length; a2++)
392
+ m2[(y2 = u2.attributes[a2]).name] = y2.value;
393
+ for (a2 in m2)
394
+ y2 = m2[a2], a2 == "dangerouslySetInnerHTML" ? p2 = y2 : a2 == "children" || (a2 in k) || a2 == "value" && ("defaultValue" in k) || a2 == "checked" && ("defaultChecked" in k) || N(u2, a2, null, y2, o2);
395
+ for (a2 in k)
396
+ y2 = k[a2], a2 == "children" ? v2 = y2 : a2 == "dangerouslySetInnerHTML" ? h2 = y2 : a2 == "value" ? w2 = y2 : a2 == "checked" ? _2 = y2 : c2 && typeof y2 != "function" || m2[a2] === y2 || N(u2, a2, y2, m2[a2], o2);
397
+ if (h2)
398
+ c2 || p2 && (h2.__html == p2.__html || h2.__html == u2.innerHTML) || (u2.innerHTML = h2.__html), t2.__k = [];
399
+ else if (p2 && (u2.innerHTML = ""), L(t2.type == "template" ? u2.content : u2, g(v2) ? v2 : [v2], t2, i2, r2, x2 == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o2, e2, f2, e2 ? e2[0] : i2.__k && $(i2, 0), c2, s2), e2 != null)
400
+ for (a2 = e2.length;a2--; )
401
+ b(e2[a2]);
402
+ c2 || (a2 = "value", x2 == "progress" && w2 == null ? u2.removeAttribute("value") : w2 != null && (w2 !== u2[a2] || x2 == "progress" && !w2 || x2 == "option" && w2 != m2[a2]) && N(u2, a2, w2, m2[a2], o2), a2 = "checked", _2 != null && _2 != u2[a2] && N(u2, a2, _2, m2[a2], o2));
403
+ }
404
+ return u2;
405
+ }
406
+ function J(n2, u2, t2) {
407
+ try {
408
+ if (typeof n2 == "function") {
409
+ var i2 = typeof n2.__u == "function";
410
+ i2 && n2.__u(), i2 && u2 == null || (n2.__u = n2(u2));
411
+ } else
412
+ n2.current = u2;
413
+ } catch (n3) {
414
+ l.__e(n3, t2);
415
+ }
416
+ }
417
+ function K(n2, u2, t2) {
418
+ var i2, r2;
419
+ if (l.unmount && l.unmount(n2), (i2 = n2.ref) && (i2.current && i2.current != n2.__e || J(i2, null, u2)), (i2 = n2.__c) != null) {
420
+ if (i2.componentWillUnmount)
421
+ try {
422
+ i2.componentWillUnmount();
423
+ } catch (n3) {
424
+ l.__e(n3, u2);
425
+ }
426
+ i2.base = i2.__P = null;
427
+ }
428
+ if (i2 = n2.__k)
429
+ for (r2 = 0;r2 < i2.length; r2++)
430
+ i2[r2] && K(i2[r2], u2, t2 || typeof n2.type != "function");
431
+ t2 || b(n2.__e), n2.__c = n2.__ = n2.__e = undefined;
432
+ }
433
+ function Q(n2, l2, u2) {
434
+ return this.constructor(n2, u2);
435
+ }
436
+ n = w.slice, l = { __e: function(n2, l2, u2, t2) {
437
+ for (var i2, r2, o2;l2 = l2.__; )
438
+ if ((i2 = l2.__c) && !i2.__)
439
+ try {
440
+ 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)
441
+ return i2.__E = i2;
442
+ } catch (l3) {
443
+ n2 = l3;
444
+ }
445
+ throw n2;
446
+ } }, u = 0, t = function(n2) {
447
+ return n2 != null && n2.constructor === undefined;
448
+ }, C.prototype.setState = function(n2, l2) {
449
+ var u2;
450
+ u2 = this.__s != null && this.__s != this.state ? this.__s : this.__s = m({}, this.state), typeof n2 == "function" && (n2 = n2(m({}, u2), this.props)), n2 && m(u2, n2), n2 != null && this.__v && (l2 && this._sb.push(l2), A(this));
451
+ }, C.prototype.forceUpdate = function(n2) {
452
+ this.__v && (this.__e = true, n2 && this.__h.push(n2), A(this));
453
+ }, C.prototype.render = S, i = [], o = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e = function(n2, l2) {
454
+ return n2.__v.__b - l2.__v.__b;
455
+ }, H.__r = 0, f = Math.random().toString(8), c = "__d" + f, s = "__a" + f, a = /(PointerCapture)$|Capture$/i, h = 0, p = V(false), v = V(true), y = 0;
456
+
457
+ // ../../node_modules/.bun/preact@10.29.1/node_modules/preact/hooks/dist/hooks.mjs
458
+ var t2;
459
+ var r2;
460
+ var u2;
461
+ var i2;
462
+ var o2 = 0;
463
+ var f2 = [];
464
+ var c2 = l;
465
+ var e2 = c2.__b;
466
+ var a2 = c2.__r;
467
+ var v2 = c2.diffed;
468
+ var l2 = c2.__c;
469
+ var m2 = c2.unmount;
470
+ var s2 = c2.__;
471
+ function p2(n2, t3) {
472
+ c2.__h && c2.__h(r2, n2, o2 || t3), o2 = 0;
473
+ var u3 = r2.__H || (r2.__H = { __: [], __h: [] });
474
+ return n2 >= u3.__.length && u3.__.push({}), u3.__[n2];
475
+ }
476
+ function T2(n2, r3) {
477
+ var u3 = p2(t2++, 7);
478
+ return C2(u3.__H, r3) && (u3.__ = n2(), u3.__H = r3, u3.__h = n2), u3.__;
479
+ }
480
+ function j2() {
481
+ for (var n2;n2 = f2.shift(); ) {
482
+ var t3 = n2.__H;
483
+ if (n2.__P && t3)
484
+ try {
485
+ t3.__h.some(z2), t3.__h.some(B2), t3.__h = [];
486
+ } catch (r3) {
487
+ t3.__h = [], c2.__e(r3, n2.__v);
488
+ }
489
+ }
490
+ }
491
+ c2.__b = function(n2) {
492
+ r2 = null, e2 && e2(n2);
493
+ }, c2.__ = function(n2, t3) {
494
+ n2 && t3.__k && t3.__k.__m && (n2.__m = t3.__k.__m), s2 && s2(n2, t3);
495
+ }, c2.__r = function(n2) {
496
+ a2 && a2(n2), t2 = 0;
497
+ var i3 = (r2 = n2.__c).__H;
498
+ i3 && (u2 === r2 ? (i3.__h = [], r2.__h = [], i3.__.some(function(n3) {
499
+ n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = undefined;
500
+ })) : (i3.__h.some(z2), i3.__h.some(B2), i3.__h = [], t2 = 0)), u2 = r2;
501
+ }, c2.diffed = function(n2) {
502
+ v2 && v2(n2);
503
+ var t3 = n2.__c;
504
+ t3 && t3.__H && (t3.__H.__h.length && (f2.push(t3) !== 1 && i2 === c2.requestAnimationFrame || ((i2 = c2.requestAnimationFrame) || w2)(j2)), t3.__H.__.some(function(n3) {
505
+ n3.u && (n3.__H = n3.u), n3.u = undefined;
506
+ })), u2 = r2 = null;
507
+ }, c2.__c = function(n2, t3) {
508
+ t3.some(function(n3) {
509
+ try {
510
+ n3.__h.some(z2), n3.__h = n3.__h.filter(function(n4) {
511
+ return !n4.__ || B2(n4);
512
+ });
513
+ } catch (r3) {
514
+ t3.some(function(n4) {
515
+ n4.__h && (n4.__h = []);
516
+ }), t3 = [], c2.__e(r3, n3.__v);
517
+ }
518
+ }), l2 && l2(n2, t3);
519
+ }, c2.unmount = function(n2) {
520
+ m2 && m2(n2);
521
+ var t3, r3 = n2.__c;
522
+ r3 && r3.__H && (r3.__H.__.some(function(n3) {
523
+ try {
524
+ z2(n3);
525
+ } catch (n4) {
526
+ t3 = n4;
527
+ }
528
+ }), r3.__H = undefined, t3 && c2.__e(t3, r3.__v));
529
+ };
530
+ var k = typeof requestAnimationFrame == "function";
531
+ function w2(n2) {
532
+ var t3, r3 = function() {
533
+ clearTimeout(u3), k && cancelAnimationFrame(t3), setTimeout(n2);
534
+ }, u3 = setTimeout(r3, 35);
535
+ k && (t3 = requestAnimationFrame(r3));
536
+ }
537
+ function z2(n2) {
538
+ var t3 = r2, u3 = n2.__c;
539
+ typeof u3 == "function" && (n2.__c = undefined, u3()), r2 = t3;
540
+ }
541
+ function B2(n2) {
542
+ var t3 = r2;
543
+ n2.__c = n2.__(), r2 = t3;
544
+ }
545
+ function C2(n2, t3) {
546
+ return !n2 || n2.length !== t3.length || t3.some(function(t4, r3) {
547
+ return t4 !== n2[r3];
548
+ });
549
+ }
550
+
551
+ // ../../node_modules/.bun/@preact+signals-core@1.14.2/node_modules/@preact/signals-core/dist/signals-core.mjs
552
+ var i3 = Symbol.for("preact-signals");
553
+ function t3() {
554
+ if (e3 > 1) {
555
+ e3--;
556
+ return;
557
+ }
558
+ let i4, t4 = false;
559
+ (function() {
560
+ let i5 = r3;
561
+ r3 = undefined;
562
+ while (i5 !== undefined) {
563
+ if (i5.S.v === i5.v)
564
+ i5.S.i = i5.i;
565
+ i5 = i5.o;
566
+ }
567
+ })();
568
+ while (s3 !== undefined) {
569
+ let n2 = s3;
570
+ s3 = undefined;
571
+ u3++;
572
+ while (n2 !== undefined) {
573
+ const o3 = n2.u;
574
+ n2.u = undefined;
575
+ n2.f &= -3;
576
+ if (!(8 & n2.f) && w3(n2))
577
+ try {
578
+ n2.c();
579
+ } catch (n3) {
580
+ if (!t4) {
581
+ i4 = n3;
582
+ t4 = true;
583
+ }
584
+ }
585
+ n2 = o3;
586
+ }
587
+ }
588
+ u3 = 0;
589
+ e3--;
590
+ if (t4)
591
+ throw i4;
592
+ }
593
+ function n2(i4) {
594
+ if (e3 > 0)
595
+ return i4();
596
+ d2 = ++c3;
597
+ e3++;
598
+ try {
599
+ return i4();
600
+ } finally {
601
+ t3();
602
+ }
603
+ }
604
+ var o3;
605
+ var s3;
606
+ function h2(i4) {
607
+ const t4 = o3;
608
+ o3 = undefined;
609
+ try {
610
+ return i4();
611
+ } finally {
612
+ o3 = t4;
613
+ }
614
+ }
615
+ var r3;
616
+ var f3;
617
+ var e3 = 0;
618
+ var u3 = 0;
619
+ var c3 = 0;
620
+ var d2 = 0;
621
+ var v3 = 0;
622
+ function l3(i4) {
623
+ if (o3 === undefined)
624
+ return;
625
+ let t4 = i4.n;
626
+ if (t4 === undefined || t4.t !== o3) {
627
+ t4 = { i: 0, S: i4, p: o3.s, n: undefined, t: o3, e: undefined, x: undefined, r: t4 };
628
+ if (o3.s !== undefined)
629
+ o3.s.n = t4;
630
+ o3.s = t4;
631
+ i4.n = t4;
632
+ if (32 & o3.f)
633
+ i4.S(t4);
634
+ return t4;
635
+ } else if (t4.i === -1) {
636
+ t4.i = 0;
637
+ if (t4.n !== undefined) {
638
+ t4.n.p = t4.p;
639
+ if (t4.p !== undefined)
640
+ t4.p.n = t4.n;
641
+ t4.p = o3.s;
642
+ t4.n = undefined;
643
+ o3.s.n = t4;
644
+ o3.s = t4;
645
+ }
646
+ return t4;
647
+ }
648
+ }
649
+ function y2(i4, t4) {
650
+ this.v = i4;
651
+ this.i = 0;
652
+ this.n = undefined;
653
+ this.t = undefined;
654
+ this.l = 0;
655
+ this.W = t4 == null ? undefined : t4.watched;
656
+ this.Z = t4 == null ? undefined : t4.unwatched;
657
+ this.name = t4 == null ? undefined : t4.name;
658
+ }
659
+ y2.prototype.brand = i3;
660
+ y2.prototype.h = function() {
661
+ return true;
662
+ };
663
+ y2.prototype.S = function(i4) {
664
+ const t4 = this.t;
665
+ if (t4 !== i4 && i4.e === undefined) {
666
+ i4.x = t4;
667
+ this.t = i4;
668
+ if (t4 !== undefined)
669
+ t4.e = i4;
670
+ else
671
+ h2(() => {
672
+ var i5;
673
+ (i5 = this.W) == null || i5.call(this);
674
+ });
675
+ }
676
+ };
677
+ y2.prototype.U = function(i4) {
678
+ if (this.t !== undefined) {
679
+ const { e: t4, x: n3 } = i4;
680
+ if (t4 !== undefined) {
681
+ t4.x = n3;
682
+ i4.e = undefined;
683
+ }
684
+ if (n3 !== undefined) {
685
+ n3.e = t4;
686
+ i4.x = undefined;
687
+ }
688
+ if (i4 === this.t) {
689
+ this.t = n3;
690
+ if (n3 === undefined)
691
+ h2(() => {
692
+ var i5;
693
+ (i5 = this.Z) == null || i5.call(this);
694
+ });
695
+ }
696
+ }
697
+ };
698
+ y2.prototype.subscribe = function(i4) {
699
+ return j3(() => {
700
+ const t4 = this.value, n3 = o3;
701
+ o3 = undefined;
702
+ try {
703
+ i4(t4);
704
+ } finally {
705
+ o3 = n3;
706
+ }
707
+ }, { name: "sub" });
708
+ };
709
+ y2.prototype.valueOf = function() {
710
+ return this.value;
711
+ };
712
+ y2.prototype.toString = function() {
713
+ return this.value + "";
714
+ };
715
+ y2.prototype.toJSON = function() {
716
+ return this.value;
717
+ };
718
+ y2.prototype.peek = function() {
719
+ return h2(() => this.value);
720
+ };
721
+ Object.defineProperty(y2.prototype, "value", { get() {
722
+ const i4 = l3(this);
723
+ if (i4 !== undefined)
724
+ i4.i = this.i;
725
+ return this.v;
726
+ }, set(i4) {
727
+ if (i4 !== this.v) {
728
+ if (u3 > 100)
729
+ throw new Error("Cycle detected");
730
+ (function(i5) {
731
+ if (e3 !== 0 && u3 === 0) {
732
+ if (i5.l !== d2) {
733
+ i5.l = d2;
734
+ r3 = { S: i5, v: i5.v, i: i5.i, o: r3 };
735
+ }
736
+ }
737
+ })(this);
738
+ this.v = i4;
739
+ this.i++;
740
+ v3++;
741
+ e3++;
742
+ try {
743
+ for (let i5 = this.t;i5 !== undefined; i5 = i5.x)
744
+ i5.t.N();
745
+ } finally {
746
+ t3();
747
+ }
748
+ }
749
+ } });
750
+ function a3(i4, t4) {
751
+ return new y2(i4, t4);
752
+ }
753
+ function w3(i4) {
754
+ for (let t4 = i4.s;t4 !== undefined; t4 = t4.n)
755
+ if (t4.S.i !== t4.i || !t4.S.h() || t4.S.i !== t4.i)
756
+ return true;
757
+ return false;
758
+ }
759
+ function _2(i4) {
760
+ for (let t4 = i4.s;t4 !== undefined; t4 = t4.n) {
761
+ const n3 = t4.S.n;
762
+ if (n3 !== undefined)
763
+ t4.r = n3;
764
+ t4.S.n = t4;
765
+ t4.i = -1;
766
+ if (t4.n === undefined) {
767
+ i4.s = t4;
768
+ break;
769
+ }
770
+ }
771
+ }
772
+ function b2(i4) {
773
+ let t4, n3 = i4.s;
774
+ while (n3 !== undefined) {
775
+ const i5 = n3.p;
776
+ if (n3.i === -1) {
777
+ n3.S.U(n3);
778
+ if (i5 !== undefined)
779
+ i5.n = n3.n;
780
+ if (n3.n !== undefined)
781
+ n3.n.p = i5;
782
+ } else
783
+ t4 = n3;
784
+ n3.S.n = n3.r;
785
+ if (n3.r !== undefined)
786
+ n3.r = undefined;
787
+ n3 = i5;
788
+ }
789
+ i4.s = t4;
790
+ }
791
+ function p3(i4, t4) {
792
+ y2.call(this, undefined);
793
+ this.x = i4;
794
+ this.s = undefined;
795
+ this.g = v3 - 1;
796
+ this.f = 4;
797
+ this.W = t4 == null ? undefined : t4.watched;
798
+ this.Z = t4 == null ? undefined : t4.unwatched;
799
+ this.name = t4 == null ? undefined : t4.name;
800
+ }
801
+ p3.prototype = new y2;
802
+ p3.prototype.h = function() {
803
+ this.f &= -3;
804
+ if (1 & this.f)
805
+ return false;
806
+ if ((36 & this.f) == 32)
807
+ return true;
808
+ this.f &= -5;
809
+ if (this.g === v3)
810
+ return true;
811
+ this.g = v3;
812
+ this.f |= 1;
813
+ if (this.i > 0 && !w3(this)) {
814
+ this.f &= -2;
815
+ return true;
816
+ }
817
+ const i4 = o3;
818
+ try {
819
+ _2(this);
820
+ o3 = this;
821
+ const i5 = this.x();
822
+ if (16 & this.f || this.v !== i5 || this.i === 0) {
823
+ this.v = i5;
824
+ this.f &= -17;
825
+ this.i++;
826
+ }
827
+ } catch (i5) {
828
+ this.v = i5;
829
+ this.f |= 16;
830
+ this.i++;
831
+ }
832
+ o3 = i4;
833
+ b2(this);
834
+ this.f &= -2;
835
+ return true;
836
+ };
837
+ p3.prototype.S = function(i4) {
838
+ if (this.t === undefined) {
839
+ this.f |= 36;
840
+ for (let i5 = this.s;i5 !== undefined; i5 = i5.n)
841
+ i5.S.S(i5);
842
+ }
843
+ y2.prototype.S.call(this, i4);
844
+ };
845
+ p3.prototype.U = function(i4) {
846
+ if (this.t !== undefined) {
847
+ y2.prototype.U.call(this, i4);
848
+ if (this.t === undefined) {
849
+ this.f &= -33;
850
+ for (let i5 = this.s;i5 !== undefined; i5 = i5.n)
851
+ i5.S.U(i5);
852
+ }
853
+ }
854
+ };
855
+ p3.prototype.N = function() {
856
+ if (!(2 & this.f)) {
857
+ this.f |= 6;
858
+ for (let i4 = this.t;i4 !== undefined; i4 = i4.x)
859
+ i4.t.N();
860
+ }
861
+ };
862
+ Object.defineProperty(p3.prototype, "value", { get() {
863
+ if (1 & this.f)
864
+ throw new Error("Cycle detected");
865
+ const i4 = l3(this);
866
+ this.h();
867
+ if (i4 !== undefined)
868
+ i4.i = this.i;
869
+ if (16 & this.f)
870
+ throw this.v;
871
+ return this.v;
872
+ } });
873
+ function g2(i4, t4) {
874
+ return new p3(i4, t4);
875
+ }
876
+ function S2(i4) {
877
+ const n3 = i4.m;
878
+ i4.m = undefined;
879
+ if (typeof n3 == "function") {
880
+ e3++;
881
+ const s4 = o3;
882
+ o3 = undefined;
883
+ try {
884
+ n3();
885
+ } catch (t4) {
886
+ i4.f &= -2;
887
+ i4.f |= 8;
888
+ m3(i4);
889
+ throw t4;
890
+ } finally {
891
+ o3 = s4;
892
+ t3();
893
+ }
894
+ }
895
+ }
896
+ function m3(i4) {
897
+ for (let t4 = i4.s;t4 !== undefined; t4 = t4.n)
898
+ t4.S.U(t4);
899
+ i4.x = undefined;
900
+ i4.s = undefined;
901
+ S2(i4);
902
+ }
903
+ function x2(i4) {
904
+ if (o3 !== this)
905
+ throw new Error("Out-of-order effect");
906
+ b2(this);
907
+ o3 = i4;
908
+ this.f &= -2;
909
+ if (8 & this.f)
910
+ m3(this);
911
+ t3();
912
+ }
913
+ function E2(i4, t4) {
914
+ this.x = i4;
915
+ this.m = undefined;
916
+ this.s = undefined;
917
+ this.u = undefined;
918
+ this.f = 32;
919
+ this.name = t4 == null ? undefined : t4.name;
920
+ if (f3)
921
+ f3.push(this);
922
+ }
923
+ E2.prototype.c = function() {
924
+ const i4 = this.S();
925
+ try {
926
+ if (8 & this.f)
927
+ return;
928
+ if (this.x === undefined)
929
+ return;
930
+ const t4 = this.x();
931
+ if (typeof t4 == "function")
932
+ this.m = t4;
933
+ } finally {
934
+ i4();
935
+ }
936
+ };
937
+ E2.prototype.S = function() {
938
+ if (1 & this.f)
939
+ throw new Error("Cycle detected");
940
+ this.f |= 1;
941
+ this.f &= -9;
942
+ S2(this);
943
+ _2(this);
944
+ e3++;
945
+ const i4 = o3;
946
+ o3 = this;
947
+ return x2.bind(this, i4);
948
+ };
949
+ E2.prototype.N = function() {
950
+ if (!(2 & this.f)) {
951
+ this.f |= 2;
952
+ this.u = s3;
953
+ s3 = this;
954
+ }
955
+ };
956
+ E2.prototype.d = function() {
957
+ this.f |= 8;
958
+ if (!(1 & this.f))
959
+ m3(this);
960
+ };
961
+ E2.prototype.dispose = function() {
962
+ this.d();
963
+ };
964
+ function j3(i4, t4) {
965
+ const n3 = new E2(i4, t4);
966
+ try {
967
+ n3.c();
968
+ } catch (i5) {
969
+ n3.d();
970
+ throw i5;
971
+ }
972
+ const o4 = n3.d.bind(n3);
973
+ o4[Symbol.dispose] = o4;
974
+ return o4;
975
+ }
976
+
977
+ // ../../node_modules/.bun/@preact+signals@2.9.0+8ade602ed6c36360/node_modules/@preact/signals/dist/signals.mjs
978
+ var d3 = typeof window != "undefined" && !!window.__PREACT_SIGNALS_DEVTOOLS__;
979
+ var h3;
980
+ var p4;
981
+ var v4;
982
+ var _3 = [];
983
+ j3(function() {
984
+ h3 = this.N;
985
+ })();
986
+ function g3(t4, e4) {
987
+ l[t4] = e4.bind(null, l[t4] || (() => {}));
988
+ }
989
+ function b3(t4) {
990
+ if (v4) {
991
+ const t5 = v4;
992
+ v4 = undefined;
993
+ t5();
994
+ }
995
+ v4 = t4 && t4.S();
996
+ }
997
+ function y4({ data: t4 }) {
998
+ const i4 = useSignal(t4);
999
+ i4.value = t4;
1000
+ const [n3, r4] = T2(() => {
1001
+ let t5 = this, n4 = this.__v;
1002
+ while (n4 = n4.__)
1003
+ if (n4.__c) {
1004
+ n4.__c.__$f |= 4;
1005
+ break;
1006
+ }
1007
+ const o4 = g2(() => {
1008
+ let t6 = i4.value.value;
1009
+ return t6 === 0 ? 0 : t6 === true ? "" : t6 || "";
1010
+ }), r5 = g2(() => !Array.isArray(o4.value) && !t(o4.value)), f4 = j3(function() {
1011
+ this.N = F;
1012
+ if (r5.value) {
1013
+ const i5 = o4.value;
1014
+ if (t5.__v && t5.__v.__e && t5.__v.__e.nodeType === 3)
1015
+ t5.__v.__e.data = i5;
1016
+ }
1017
+ }), s4 = this.__$u.d;
1018
+ this.__$u.d = function() {
1019
+ f4();
1020
+ s4.call(this);
1021
+ };
1022
+ return [r5, o4];
1023
+ }, []);
1024
+ return n3.value ? r4.peek() : r4.value;
1025
+ }
1026
+ y4.displayName = "ReactiveTextNode";
1027
+ Object.defineProperties(y2.prototype, { constructor: { configurable: true, value: undefined }, type: { configurable: true, value: y4 }, props: { configurable: true, get() {
1028
+ const t4 = this;
1029
+ return { data: { get value() {
1030
+ return t4.value;
1031
+ } } };
1032
+ } }, __b: { configurable: true, value: 1 } });
1033
+ g3("__b", (t4, i4) => {
1034
+ if (typeof i4.type == "string") {
1035
+ let t5, e4 = i4.props;
1036
+ for (let n3 in e4) {
1037
+ if (n3 === "children")
1038
+ continue;
1039
+ let o4 = e4[n3];
1040
+ if (o4 instanceof y2) {
1041
+ if (!t5)
1042
+ i4.__np = t5 = {};
1043
+ t5[n3] = o4;
1044
+ e4[n3] = o4.peek();
1045
+ }
1046
+ }
1047
+ }
1048
+ t4(i4);
1049
+ });
1050
+ g3("__r", (t4, i4) => {
1051
+ t4(i4);
1052
+ if (i4.type !== S) {
1053
+ b3();
1054
+ let t5, e4 = i4.__c;
1055
+ if (e4) {
1056
+ e4.__$f &= -2;
1057
+ t5 = e4.__$u;
1058
+ if (t5 === undefined)
1059
+ e4.__$u = t5 = function(t6, i5) {
1060
+ let e5;
1061
+ j3(function() {
1062
+ e5 = this;
1063
+ }, { name: i5 });
1064
+ e5.c = t6;
1065
+ return e5;
1066
+ }(() => {
1067
+ var i5;
1068
+ if (d3)
1069
+ (i5 = t5.y) == null || i5.call(t5);
1070
+ e4.__$f |= 1;
1071
+ e4.setState({});
1072
+ }, typeof i4.type == "function" ? i4.type.displayName || i4.type.name : "");
1073
+ }
1074
+ p4 = e4;
1075
+ b3(t5);
1076
+ }
1077
+ });
1078
+ g3("__e", (t4, i4, e4, n3) => {
1079
+ b3();
1080
+ p4 = undefined;
1081
+ t4(i4, e4, n3);
1082
+ });
1083
+ g3("diffed", (t4, i4) => {
1084
+ b3();
1085
+ p4 = undefined;
1086
+ let e4;
1087
+ if (typeof i4.type == "string" && (e4 = i4.__e)) {
1088
+ let { __np: t5, props: n3 } = i4;
1089
+ if (t5) {
1090
+ let i5 = e4.U;
1091
+ if (i5)
1092
+ for (let e5 in i5) {
1093
+ let n4 = i5[e5];
1094
+ if (n4 !== undefined && !(e5 in t5)) {
1095
+ n4.d();
1096
+ i5[e5] = undefined;
1097
+ }
1098
+ }
1099
+ else {
1100
+ i5 = {};
1101
+ e4.U = i5;
1102
+ }
1103
+ for (let o4 in t5) {
1104
+ let r4 = i5[o4], f4 = t5[o4];
1105
+ if (r4 === undefined) {
1106
+ r4 = w4(e4, o4, f4);
1107
+ i5[o4] = r4;
1108
+ } else
1109
+ r4.o(f4, n3);
1110
+ }
1111
+ for (let i6 in t5)
1112
+ n3[i6] = t5[i6];
1113
+ }
1114
+ }
1115
+ t4(i4);
1116
+ });
1117
+ function w4(t4, i4, e4, n3) {
1118
+ const o4 = i4 in t4 && t4.ownerSVGElement === undefined, r4 = a3(e4);
1119
+ let f4 = e4.peek();
1120
+ return { o: (t5, i5) => {
1121
+ r4.value = t5;
1122
+ f4 = t5.peek();
1123
+ }, d: j3(function() {
1124
+ this.N = F;
1125
+ const e5 = r4.value.value;
1126
+ if (f4 !== e5) {
1127
+ f4 = undefined;
1128
+ if (o4)
1129
+ t4[i4] = e5;
1130
+ else if (e5 != null && (e5 !== false || i4[4] === "-"))
1131
+ t4.setAttribute(i4, e5);
1132
+ else
1133
+ t4.removeAttribute(i4);
1134
+ } else
1135
+ f4 = undefined;
1136
+ }) };
1137
+ }
1138
+ g3("unmount", (t4, i4) => {
1139
+ if (typeof i4.type == "string") {
1140
+ let t5 = i4.__e;
1141
+ if (t5) {
1142
+ const i5 = t5.U;
1143
+ if (i5) {
1144
+ t5.U = undefined;
1145
+ for (let t6 in i5) {
1146
+ let e4 = i5[t6];
1147
+ if (e4)
1148
+ e4.d();
1149
+ }
1150
+ }
1151
+ }
1152
+ i4.__np = undefined;
1153
+ } else {
1154
+ let t5 = i4.__c;
1155
+ if (t5) {
1156
+ const i5 = t5.__$u;
1157
+ if (i5) {
1158
+ t5.__$u = undefined;
1159
+ i5.d();
1160
+ }
1161
+ }
1162
+ }
1163
+ t4(i4);
1164
+ });
1165
+ g3("__h", (t4, i4, e4, n3) => {
1166
+ if (n3 < 3 || n3 === 9)
1167
+ i4.__$f |= 2;
1168
+ t4(i4, e4, n3);
1169
+ });
1170
+ C.prototype.shouldComponentUpdate = function(t4, i4) {
1171
+ if (this.__R)
1172
+ return true;
1173
+ const e4 = this.__$u, n3 = e4 && e4.s !== undefined;
1174
+ for (let t5 in i4)
1175
+ return true;
1176
+ if (this.__f || typeof this.u == "boolean" && this.u === true) {
1177
+ const t5 = 2 & this.__$f;
1178
+ if (!(n3 || t5 || 4 & this.__$f))
1179
+ return true;
1180
+ if (1 & this.__$f)
1181
+ return true;
1182
+ } else {
1183
+ if (!(n3 || 4 & this.__$f))
1184
+ return true;
1185
+ if (3 & this.__$f)
1186
+ return true;
1187
+ }
1188
+ for (let i5 in t4)
1189
+ if (i5 !== "__source" && t4[i5] !== this.props[i5])
1190
+ return true;
1191
+ for (let i5 in this.props)
1192
+ if (!(i5 in t4))
1193
+ return true;
1194
+ return false;
1195
+ };
1196
+ function useSignal(t4, i4) {
1197
+ return T2(() => a3(t4, i4), []);
1198
+ }
1199
+ var q2 = (t4) => {
1200
+ queueMicrotask(() => {
1201
+ queueMicrotask(t4);
1202
+ });
1203
+ };
1204
+ function x3() {
1205
+ n2(() => {
1206
+ let t4;
1207
+ while (t4 = _3.shift())
1208
+ h3.call(t4);
1209
+ });
1210
+ }
1211
+ function F() {
1212
+ if (_3.push(this) === 1)
1213
+ (l.requestAnimationFrame || q2)(x3);
1214
+ }
1215
+
1216
+ // src/shared/lib/migrate-primitive.ts
1217
+ class MigrationRegistry {
1218
+ marks = new Set;
1219
+ entryKey(key, primitive) {
1220
+ return `${primitive}:${key}`;
1221
+ }
1222
+ mark(key, primitive) {
1223
+ this.marks.add(this.entryKey(key, primitive));
1224
+ }
1225
+ isMarked(key, primitive) {
1226
+ return this.marks.has(this.entryKey(key, primitive));
1227
+ }
1228
+ clear() {
1229
+ this.marks.clear();
1230
+ }
1231
+ get size() {
1232
+ return this.marks.size;
1233
+ }
1234
+ }
1235
+ var migrationRegistry = new MigrationRegistry;
1236
+
1237
+ // src/shared/lib/primitive-registry.ts
1238
+ class PrimitiveCollisionError extends Error {
1239
+ key;
1240
+ firstPrimitive;
1241
+ firstCallSite;
1242
+ secondPrimitive;
1243
+ secondCallSite;
1244
+ constructor(key, firstPrimitive, firstCallSite, secondPrimitive, secondCallSite) {
1245
+ const firstLocation = firstCallSite ? ` (at ${firstCallSite})` : "";
1246
+ const secondLocation = secondCallSite ? ` (at ${secondCallSite})` : "";
1247
+ super(`Polly primitive key collision: "${key}" is already registered as ` + `$${firstPrimitive}${firstLocation} and cannot also be registered ` + `as $${secondPrimitive}${secondLocation}. Pick a different key or ` + `use the same primitive in both places.`);
1248
+ this.name = "PrimitiveCollisionError";
1249
+ this.key = key;
1250
+ this.firstPrimitive = firstPrimitive;
1251
+ this.firstCallSite = firstCallSite;
1252
+ this.secondPrimitive = secondPrimitive;
1253
+ this.secondCallSite = secondCallSite;
1254
+ }
1255
+ }
1256
+
1257
+ class PrimitiveRegistry {
1258
+ entries = new Map;
1259
+ register(key, primitive, callSite) {
1260
+ const existing = this.entries.get(key);
1261
+ if (existing && existing.primitive !== primitive) {
1262
+ throw new PrimitiveCollisionError(key, existing.primitive, existing.callSite, primitive, callSite);
1263
+ }
1264
+ if (!existing) {
1265
+ this.entries.set(key, { primitive, callSite });
1266
+ }
1267
+ }
1268
+ has(key) {
1269
+ return this.entries.has(key);
1270
+ }
1271
+ kindOf(key) {
1272
+ return this.entries.get(key)?.primitive;
1273
+ }
1274
+ clear() {
1275
+ this.entries.clear();
1276
+ }
1277
+ get size() {
1278
+ return this.entries.size;
1279
+ }
1280
+ }
1281
+ var primitiveRegistry = new PrimitiveRegistry;
1282
+ // src/shared/lib/crdt-state.ts
1283
+ import { Automerge as Automerge2 } from "@automerge/automerge-repo/slim";
1284
+ // src/shared/lib/peer-relay-adapter.ts
1285
+ import { Repo } from "@automerge/automerge-repo/slim";
1286
+ import { WebSocketClientAdapter } from "@automerge/automerge-repo-network-websocket";
1287
+
1288
+ // src/shared/lib/mesh-network-adapter.ts
1289
+ import {
1290
+ NetworkAdapter
1291
+ } from "@automerge/automerge-repo/slim";
1292
+
1293
+ // src/shared/lib/encryption.ts
1294
+ import nacl from "tweetnacl";
1295
+
1296
+ // src/shared/lib/mesh-diagnostics.ts
1297
+ var listeners = new Set;
1298
+
1299
+ // src/shared/lib/signing.ts
1300
+ import nacl2 from "tweetnacl";
1301
+ // src/shared/lib/peer-repo-server.ts
1302
+ async function listNodeFSDocumentIds(baseDirectory) {
1303
+ const [{ readdir }, { join }] = await Promise.all([
1304
+ import("node:fs/promises"),
1305
+ import("node:path")
1306
+ ]);
1307
+ let shards;
1308
+ try {
1309
+ shards = await readdir(baseDirectory);
1310
+ } catch (error) {
1311
+ if (error instanceof Error && "code" in error && error.code === "ENOENT")
1312
+ return [];
1313
+ throw error;
1314
+ }
1315
+ const documentIds = [];
1316
+ for (const shard of shards) {
1317
+ const entries = await readdir(join(baseDirectory, shard), {
1318
+ withFileTypes: true
1319
+ }).catch(() => []);
1320
+ for (const entry of entries) {
1321
+ if (entry.isDirectory())
1322
+ documentIds.push(shard + entry.name);
1323
+ }
1324
+ }
1325
+ return documentIds;
1326
+ }
1327
+ async function createPeerRepoServer(options) {
1328
+ const [{ Repo: Repo2 }, { WebSocketServerAdapter }, { NodeFSStorageAdapter }, ws] = await Promise.all([
1329
+ import("@automerge/automerge-repo/slim"),
1330
+ import("@automerge/automerge-repo-network-websocket"),
1331
+ import("@automerge/automerge-repo-storage-nodefs"),
1332
+ import("ws")
1333
+ ]);
1334
+ const wss = await (options.webSocketServer ? Promise.resolve(options.webSocketServer) : new Promise((resolve, reject) => {
1335
+ const created = new ws.WebSocketServer({
1336
+ port: options.port,
1337
+ ...options.host !== undefined && { host: options.host }
1338
+ }, () => resolve(created));
1339
+ created.once("error", reject);
1340
+ }));
1341
+ const adapter = new WebSocketServerAdapter(wss);
1342
+ const storagePath = options.storagePath ?? "automerge-repo-data";
1343
+ const storage = new NodeFSStorageAdapter(storagePath);
1344
+ const repo = new Repo2({
1345
+ network: [adapter],
1346
+ storage
1347
+ });
1348
+ await repo.storageId();
1349
+ return {
1350
+ repo,
1351
+ webSocketServer: wss,
1352
+ adapter,
1353
+ storage,
1354
+ sweepSealed: async (sweepOptions) => {
1355
+ const documentIds = await listNodeFSDocumentIds(storagePath);
1356
+ const { sweepSealed: sweepSealed2 } = await Promise.resolve().then(() => (init_sweep_sealed(), exports_sweep_sealed));
1357
+ return sweepSealed2({ repo, storage, documentIds, ...sweepOptions });
1358
+ },
1359
+ close: async () => {
1360
+ for (const client of wss.clients) {
1361
+ try {
1362
+ client.terminate();
1363
+ } catch {}
1364
+ }
1365
+ try {
1366
+ await repo.shutdown();
1367
+ } catch {}
1368
+ try {
1369
+ wss.close();
1370
+ } catch {}
1371
+ }
1372
+ };
1373
+ }
1374
+ // src/shared/lib/peer-state.ts
1375
+ var keyMapsByRepo = new WeakMap;
1376
+ var signingEnabledRepos = new WeakSet;
1377
+
1378
+ // src/peer.ts
1379
+ init_sweep_sealed();
1380
+
1381
+ // tools/test/src/e2e-relay/with-repo-server.ts
1382
+ async function withRepoServer() {
1383
+ const storageDir = mkdtempSync(join(tmpdir(), "polly-e2e-relay-"));
1384
+ const wss = new WebSocketServer({ port: 0, host: "127.0.0.1" });
1385
+ await new Promise((resolve, reject) => {
1386
+ wss.once("listening", () => resolve());
1387
+ wss.once("error", reject);
1388
+ });
1389
+ const address = wss.address();
1390
+ if (typeof address === "string" || address === null) {
1391
+ throw new Error("withRepoServer: expected the server to be bound to a TCP address");
1392
+ }
1393
+ const port = address.port;
1394
+ const server = await createPeerRepoServer({
1395
+ port,
1396
+ webSocketServer: wss,
1397
+ storagePath: storageDir
1398
+ });
1399
+ return {
1400
+ url: `ws://127.0.0.1:${port}`,
1401
+ server,
1402
+ close: async () => {
1403
+ await server.close();
1404
+ try {
1405
+ rmSync(storageDir, { recursive: true, force: true });
1406
+ } catch {}
1407
+ }
1408
+ };
1409
+ }
1410
+ function relayStats(server) {
1411
+ const clients = server.webSocketServer.clients.size;
1412
+ const docs = Object.keys(server.repo.handles).length;
1413
+ return `clients=${clients} docs=${docs}`;
1414
+ }
1415
+ export {
1416
+ withRepoServer,
1417
+ waitForRelayConvergence,
1418
+ relayStats
1419
+ };
1420
+
1421
+ //# debugId=0148AE1FBCC40C5B64756E2164756E21