batchkit-devtools 0.2.0-beta.1 → 0.3.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.
@@ -0,0 +1,884 @@
1
+ import { delegateEvents as J, template as y, style as r, insert as v, createComponent as k, effect as C, memo as w, setAttribute as Y, setStyleProperty as te, addEventListener as Ae, className as ce, render as Ie } from "solid-js/web";
2
+ import { createRoot as De, createSignal as Q, createMemo as de, For as V, Show as ue, onMount as Oe } from "solid-js";
3
+ import { __setDevtoolsHook as Ee } from "batchkit";
4
+ let Re = 0;
5
+ function Ne(l) {
6
+ if (!l) return;
7
+ const t = l.split(`
8
+ `);
9
+ for (const o of t)
10
+ if (o.includes("batch") && !o.includes("batchkit") && !o.includes("node_modules")) {
11
+ const d = o.match(/at\s+.*?\s+\(?(.*?:\d+:\d+)\)?$/);
12
+ if (d) return d[1];
13
+ }
14
+ for (const o of t.slice(2))
15
+ if (!o.includes("batchkit") && !o.includes("node_modules")) {
16
+ const d = o.match(/at\s+.*?\s+\(?(.*?:\d+:\d+)\)?$/);
17
+ if (d) return d[1];
18
+ }
19
+ }
20
+ function je() {
21
+ const [l, t] = Q({
22
+ batchers: /* @__PURE__ */ new Map(),
23
+ events: [],
24
+ batches: /* @__PURE__ */ new Map(),
25
+ selectedBatcher: null,
26
+ isOpen: !1
27
+ }), o = /* @__PURE__ */ new Set();
28
+ function d() {
29
+ const c = l();
30
+ for (const h of o)
31
+ h(c);
32
+ }
33
+ function e(c) {
34
+ t((h) => {
35
+ const s = new Map(h.batchers);
36
+ return s.set(c.name, c), { ...h, batchers: s };
37
+ }), d();
38
+ }
39
+ function i(c, h) {
40
+ const s = { ...h, batcherName: c };
41
+ t(($) => {
42
+ const _ = [...$.events, s], p = new Map($.batches);
43
+ if (s.type === "schedule") {
44
+ const b = {
45
+ batchId: s.batchId,
46
+ batcherName: c,
47
+ keys: [],
48
+ status: "scheduled",
49
+ scheduledAt: s.timestamp
50
+ };
51
+ p.set(s.batchId, b);
52
+ }
53
+ if (s.type === "dispatch") {
54
+ const b = p.get(s.batchId);
55
+ b && p.set(s.batchId, {
56
+ ...b,
57
+ keys: s.keys,
58
+ status: "dispatching",
59
+ dispatchedAt: s.timestamp
60
+ });
61
+ }
62
+ if (s.type === "resolve") {
63
+ const b = p.get(s.batchId);
64
+ b && p.set(s.batchId, {
65
+ ...b,
66
+ status: "resolved",
67
+ completedAt: s.timestamp,
68
+ duration: s.duration
69
+ });
70
+ }
71
+ if (s.type === "error") {
72
+ const b = p.get(s.batchId);
73
+ b && p.set(s.batchId, {
74
+ ...b,
75
+ status: "error",
76
+ completedAt: s.timestamp,
77
+ error: s.error
78
+ });
79
+ }
80
+ if (s.type === "abort") {
81
+ const b = p.get(s.batchId);
82
+ b && p.set(s.batchId, {
83
+ ...b,
84
+ status: "aborted",
85
+ completedAt: s.timestamp
86
+ });
87
+ }
88
+ return { ...$, events: _, batches: p };
89
+ }), d();
90
+ }
91
+ function u(c) {
92
+ return o.add(c), c(l()), () => o.delete(c);
93
+ }
94
+ function a() {
95
+ return l();
96
+ }
97
+ function f() {
98
+ t((c) => ({
99
+ ...c,
100
+ events: [],
101
+ batches: /* @__PURE__ */ new Map()
102
+ })), d();
103
+ }
104
+ function g() {
105
+ t((c) => ({ ...c, isOpen: !0 })), d();
106
+ }
107
+ function x() {
108
+ t((c) => ({ ...c, isOpen: !1 })), d();
109
+ }
110
+ function m() {
111
+ t((c) => ({ ...c, isOpen: !c.isOpen })), d();
112
+ }
113
+ return Ee({
114
+ onBatcherCreated({ fn: c, name: h, stack: s }) {
115
+ const $ = !h, _ = h ?? `unnamed-${++Re}`, p = c.toString().slice(0, 500), b = Ne(s);
116
+ return e({
117
+ name: _,
118
+ registeredAt: performance.now(),
119
+ isUnnamed: $,
120
+ fnSource: p,
121
+ location: b
122
+ }), (T) => {
123
+ i(_, T);
124
+ };
125
+ }
126
+ }), {
127
+ subscribe: u,
128
+ getStore: a,
129
+ clear: f,
130
+ open: g,
131
+ close: x,
132
+ toggle: m,
133
+ _setStore: t,
134
+ _store: l
135
+ };
136
+ }
137
+ let z = null;
138
+ function Fe() {
139
+ if (typeof window > "u")
140
+ throw new Error("DevTools can only be used in browser environment");
141
+ return z || (z = De(() => je())), z;
142
+ }
143
+ function G() {
144
+ if (!z)
145
+ throw new Error(
146
+ "DevTools registry not initialized. Call initRegistry() first."
147
+ );
148
+ return z;
149
+ }
150
+ function Ke() {
151
+ const l = G();
152
+ if (l._store)
153
+ return l._store;
154
+ const [t, o] = Q(l.getStore());
155
+ return l.subscribe(o), t;
156
+ }
157
+ function Le(l) {
158
+ var t;
159
+ z && ((t = z._setStore) == null || t.call(z, (o) => ({
160
+ ...o,
161
+ selectedBatcher: l
162
+ })));
163
+ }
164
+ var Me = /* @__PURE__ */ y("<div>"), He = /* @__PURE__ */ y("<div><div></div><div><span> gets</span><span> batches"), Ge = /* @__PURE__ */ y("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No batchers yet</div><div style=font-size:11px;color:#57534e>Call batch() to see it here");
165
+ const Ue = {
166
+ flex: "1",
167
+ "overflow-y": "auto"
168
+ }, ve = {
169
+ padding: "8px 12px",
170
+ cursor: "pointer",
171
+ "border-bottom": "1px solid #292524",
172
+ "border-left": "2px solid transparent"
173
+ }, We = {
174
+ ...ve,
175
+ background: "#1c1917",
176
+ "border-left-color": "#a8a29e"
177
+ }, fe = {
178
+ "font-size": "13px",
179
+ color: "#d6d3d1",
180
+ "margin-bottom": "2px"
181
+ }, qe = {
182
+ ...fe,
183
+ color: "#78716c",
184
+ "font-style": "italic"
185
+ }, Pe = {
186
+ "font-size": "11px",
187
+ color: "#78716c"
188
+ }, ne = {
189
+ display: "inline-flex",
190
+ "align-items": "center",
191
+ gap: "4px",
192
+ "margin-right": "8px"
193
+ }, Xe = {
194
+ display: "flex",
195
+ "flex-direction": "column",
196
+ "align-items": "center",
197
+ "justify-content": "center",
198
+ height: "100%",
199
+ color: "#57534e",
200
+ "text-align": "center",
201
+ padding: "24px 12px"
202
+ }, Ye = (l) => {
203
+ const t = de(() => Array.from(l.batchers.values())), o = (e) => {
204
+ const i = l.events.filter((f) => f.batcherName === e), u = i.filter((f) => f.type === "get").length, a = i.filter((f) => f.type === "resolve").length;
205
+ return {
206
+ gets: u,
207
+ batches: a
208
+ };
209
+ }, d = (e) => {
210
+ l.selectedBatcher === e ? l.onSelect(null) : l.onSelect(e);
211
+ };
212
+ return (() => {
213
+ var e = Me();
214
+ return r(e, Ue), v(e, k(V, {
215
+ get each() {
216
+ return t();
217
+ },
218
+ children: (i) => {
219
+ const u = () => o(i.name), a = () => l.selectedBatcher === i.name;
220
+ return (() => {
221
+ var f = He(), g = f.firstChild, x = g.nextSibling, m = x.firstChild, S = m.firstChild, c = m.nextSibling, h = c.firstChild;
222
+ return f.$$click = () => d(i.name), v(g, () => i.name), r(x, Pe), v(m, () => u().gets, S), v(c, () => u().batches, h), C((s) => {
223
+ var $ = a() ? We : ve, _ = i.isUnnamed ? qe : fe, p = ne, b = ne;
224
+ return s.e = r(f, $, s.e), s.t = r(g, _, s.t), s.a = r(m, p, s.a), s.o = r(c, b, s.o), s;
225
+ }, {
226
+ e: void 0,
227
+ t: void 0,
228
+ a: void 0,
229
+ o: void 0
230
+ }), f;
231
+ })();
232
+ }
233
+ }), null), v(e, (() => {
234
+ var i = w(() => t().length === 0);
235
+ return () => i() && (() => {
236
+ var u = Ge(), a = u.firstChild;
237
+ return a.nextSibling, r(u, Xe), u;
238
+ })();
239
+ })(), null), e;
240
+ })();
241
+ };
242
+ J(["click"]);
243
+ var Je = /* @__PURE__ */ y("<div>"), Qe = /* @__PURE__ */ y("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No batches yet</div><div style=font-size:11px;color:#57534e>Batches appear as requests are processed"), Ve = /* @__PURE__ */ y("<div><div></div><div></div><div></div><div>");
244
+ const Ze = {
245
+ display: "flex",
246
+ "flex-direction": "column",
247
+ gap: "1px"
248
+ }, et = {
249
+ display: "flex",
250
+ "align-items": "center",
251
+ gap: "12px",
252
+ padding: "6px 8px",
253
+ background: "#1c1917",
254
+ "font-size": "11px"
255
+ }, tt = {
256
+ "font-size": "11px",
257
+ color: "#78716c",
258
+ "min-width": "80px"
259
+ }, j = {
260
+ padding: "2px 6px",
261
+ "font-size": "10px",
262
+ "font-weight": "500",
263
+ "text-transform": "uppercase",
264
+ "letter-spacing": "0.3px"
265
+ }, nt = {
266
+ scheduled: {
267
+ ...j,
268
+ background: "#422006",
269
+ color: "#fbbf24"
270
+ },
271
+ dispatching: {
272
+ ...j,
273
+ background: "#1e3a5f",
274
+ color: "#60a5fa"
275
+ },
276
+ resolved: {
277
+ ...j,
278
+ background: "#14532d",
279
+ color: "#4ade80"
280
+ },
281
+ error: {
282
+ ...j,
283
+ background: "#450a0a",
284
+ color: "#f87171"
285
+ },
286
+ aborted: {
287
+ ...j,
288
+ background: "#292524",
289
+ color: "#a8a29e"
290
+ }
291
+ }, rt = {
292
+ flex: "1",
293
+ "font-size": "11px",
294
+ color: "#a8a29e",
295
+ "white-space": "nowrap",
296
+ overflow: "hidden",
297
+ "text-overflow": "ellipsis"
298
+ }, it = {
299
+ "font-size": "11px",
300
+ color: "#57534e",
301
+ "min-width": "50px",
302
+ "text-align": "right"
303
+ }, ot = {
304
+ display: "flex",
305
+ "flex-direction": "column",
306
+ "align-items": "center",
307
+ "justify-content": "center",
308
+ height: "100%",
309
+ color: "#57534e",
310
+ "text-align": "center",
311
+ padding: "32px"
312
+ }, lt = (l) => {
313
+ const t = (e) => e === void 0 ? "-" : e < 1 ? "<1ms" : e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(2)}s`, o = (e) => {
314
+ if (e.length === 0) return "-";
315
+ const i = e.slice(0, 3).map((u) => String(u)).join(", ");
316
+ return e.length > 3 ? `${i} +${e.length - 3}` : i;
317
+ }, d = () => [...l.batches].sort((e, i) => i.scheduledAt - e.scheduledAt);
318
+ return (() => {
319
+ var e = Je();
320
+ return r(e, Ze), v(e, k(ue, {
321
+ get when() {
322
+ return d().length > 0;
323
+ },
324
+ get fallback() {
325
+ return (() => {
326
+ var i = Qe(), u = i.firstChild;
327
+ return u.nextSibling, r(i, ot), i;
328
+ })();
329
+ },
330
+ get children() {
331
+ return k(V, {
332
+ get each() {
333
+ return d();
334
+ },
335
+ children: (i) => (() => {
336
+ var u = Ve(), a = u.firstChild, f = a.nextSibling, g = f.nextSibling, x = g.nextSibling;
337
+ return r(u, et), r(a, tt), v(a, () => i.batchId), v(f, () => i.status), r(g, rt), v(g, () => o(i.keys)), r(x, it), v(x, () => t(i.duration)), C((m) => {
338
+ var S = nt[i.status] || j, c = i.keys.map(String).join(", ");
339
+ return m.e = r(f, S, m.e), c !== m.t && Y(g, "title", m.t = c), m;
340
+ }, {
341
+ e: void 0,
342
+ t: void 0
343
+ }), u;
344
+ })()
345
+ });
346
+ }
347
+ })), e;
348
+ })();
349
+ };
350
+ var st = /* @__PURE__ */ y("<div>"), at = /* @__PURE__ */ y("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No events</div><div style=font-size:11px;color:#57534e>Events appear as batchers process requests"), ct = /* @__PURE__ */ y("<div><span></span><span></span><span>");
351
+ const dt = {
352
+ display: "flex",
353
+ "flex-direction": "column",
354
+ gap: "1px",
355
+ "font-size": "11px"
356
+ }, ut = {
357
+ display: "flex",
358
+ gap: "12px",
359
+ padding: "4px 8px",
360
+ background: "#1c1917"
361
+ }, vt = {
362
+ color: "#57534e",
363
+ "min-width": "60px"
364
+ }, ft = {
365
+ "min-width": "60px",
366
+ "font-weight": "500"
367
+ }, ht = {
368
+ get: "#60a5fa",
369
+ dedup: "#c084fc",
370
+ schedule: "#fbbf24",
371
+ dispatch: "#22d3ee",
372
+ resolve: "#4ade80",
373
+ error: "#f87171",
374
+ abort: "#a8a29e"
375
+ }, gt = {
376
+ color: "#78716c",
377
+ flex: "1",
378
+ "white-space": "nowrap",
379
+ overflow: "hidden",
380
+ "text-overflow": "ellipsis"
381
+ }, bt = {
382
+ display: "flex",
383
+ "flex-direction": "column",
384
+ "align-items": "center",
385
+ "justify-content": "center",
386
+ height: "100%",
387
+ color: "#57534e",
388
+ "text-align": "center",
389
+ padding: "32px"
390
+ }, xt = (l) => {
391
+ const t = (e) => (e / 1e3).toFixed(3) + "s", o = (e) => {
392
+ switch (e.type) {
393
+ case "get":
394
+ return `key: ${String(e.key)}`;
395
+ case "dedup":
396
+ return `key: ${String(e.key)} (dedup)`;
397
+ case "schedule":
398
+ return `batch: ${e.batchId}, size: ${e.size}`;
399
+ case "dispatch":
400
+ return `batch: ${e.batchId}, keys: [${e.keys.map(String).join(", ")}]`;
401
+ case "resolve":
402
+ return `batch: ${e.batchId}, ${e.duration.toFixed(1)}ms`;
403
+ case "error":
404
+ return `batch: ${e.batchId}, ${e.error.message}`;
405
+ case "abort":
406
+ return `batch: ${e.batchId}`;
407
+ default:
408
+ return "";
409
+ }
410
+ }, d = () => [...l.events].reverse();
411
+ return (() => {
412
+ var e = st();
413
+ return r(e, dt), v(e, k(ue, {
414
+ get when() {
415
+ return d().length > 0;
416
+ },
417
+ get fallback() {
418
+ return (() => {
419
+ var i = at(), u = i.firstChild;
420
+ return u.nextSibling, r(i, bt), i;
421
+ })();
422
+ },
423
+ get children() {
424
+ return k(V, {
425
+ get each() {
426
+ return d();
427
+ },
428
+ children: (i) => (() => {
429
+ var u = ct(), a = u.firstChild, f = a.nextSibling, g = f.nextSibling;
430
+ return r(u, ut), r(a, vt), v(a, () => t(i.timestamp)), v(f, () => i.type), r(g, gt), v(g, () => o(i)), C((x) => r(f, {
431
+ ...ft,
432
+ color: ht[i.type]
433
+ }, x)), u;
434
+ })()
435
+ });
436
+ }
437
+ })), e;
438
+ })();
439
+ };
440
+ var mt = /* @__PURE__ */ y("<div><div><div>Gets</div><div></div></div><div><div>Batches</div><div></div></div><div><div>Deduped</div><div><span>(<!>%)</span></div></div><div><div>Avg Size</div><div></div></div><div><div>Avg Time</div><div><span>ms</span></div></div><div><div>Err / Abort</div><div><span></span><span style=color:#57534e> / </span><span>");
441
+ const pt = {
442
+ display: "grid",
443
+ "grid-template-columns": "repeat(auto-fit, minmax(120px, 1fr))",
444
+ gap: "1px",
445
+ background: "#292524"
446
+ }, E = {
447
+ padding: "12px",
448
+ background: "#1c1917"
449
+ }, R = {
450
+ "font-size": "11px",
451
+ "text-transform": "uppercase",
452
+ "letter-spacing": "0.5px",
453
+ color: "#78716c",
454
+ "margin-bottom": "4px"
455
+ }, N = {
456
+ "font-size": "20px",
457
+ "font-weight": "500",
458
+ color: "#f5f5f4"
459
+ }, re = {
460
+ "font-size": "11px",
461
+ color: "#57534e",
462
+ "margin-left": "2px"
463
+ }, yt = (l) => {
464
+ const t = de(() => {
465
+ const o = l.events, d = l.batches, e = o.filter((c) => c.type === "get").length, i = o.filter((c) => c.type === "dedup").length, u = d.filter((c) => c.status === "resolved"), a = u.length, f = a > 0 ? u.reduce((c, h) => c + h.keys.length, 0) / a : 0, g = a > 0 ? u.reduce((c, h) => c + (h.duration || 0), 0) / a : 0, x = d.filter((c) => c.status === "error").length, m = d.filter((c) => c.status === "aborted").length, S = e > 0 ? i / e * 100 : 0;
466
+ return {
467
+ totalGets: e,
468
+ totalBatches: a,
469
+ dedupedKeys: i,
470
+ avgBatchSize: f,
471
+ avgDuration: g,
472
+ errors: x,
473
+ aborts: m,
474
+ dedupRate: S
475
+ };
476
+ });
477
+ return (() => {
478
+ var o = mt(), d = o.firstChild, e = d.firstChild, i = e.nextSibling, u = d.nextSibling, a = u.firstChild, f = a.nextSibling, g = u.nextSibling, x = g.firstChild, m = x.nextSibling, S = m.firstChild, c = S.firstChild, h = c.nextSibling;
479
+ h.nextSibling;
480
+ var s = g.nextSibling, $ = s.firstChild, _ = $.nextSibling, p = s.nextSibling, b = p.firstChild, T = b.nextSibling, F = T.firstChild, I = p.nextSibling, D = I.firstChild, O = D.nextSibling, A = O.firstChild, L = A.nextSibling, B = L.nextSibling;
481
+ return r(o, pt), v(i, () => t().totalGets), v(f, () => t().totalBatches), v(m, () => t().dedupedKeys, S), v(S, () => t().dedupRate.toFixed(0), h), v(_, () => t().avgBatchSize.toFixed(1)), v(T, () => t().avgDuration.toFixed(0), F), v(A, () => t().errors), v(B, () => t().aborts), C((n) => {
482
+ var M = E, U = R, W = N, q = E, P = R, X = N, be = E, xe = R, me = N, pe = re, ye = E, Se = R, $e = N, we = E, _e = R, ke = N, Ce = re, ze = E, Be = R, Te = N, Z = t().errors > 0 ? "#f87171" : "#f5f5f4", ee = t().aborts > 0 ? "#fbbf24" : "#f5f5f4";
483
+ return n.e = r(d, M, n.e), n.t = r(e, U, n.t), n.a = r(i, W, n.a), n.o = r(u, q, n.o), n.i = r(a, P, n.i), n.n = r(f, X, n.n), n.s = r(g, be, n.s), n.h = r(x, xe, n.h), n.r = r(m, me, n.r), n.d = r(S, pe, n.d), n.l = r(s, ye, n.l), n.u = r($, Se, n.u), n.c = r(_, $e, n.c), n.w = r(p, we, n.w), n.m = r(b, _e, n.m), n.f = r(T, ke, n.f), n.y = r(F, Ce, n.y), n.g = r(I, ze, n.g), n.p = r(D, Be, n.p), n.b = r(O, Te, n.b), Z !== n.T && te(A, "color", n.T = Z), ee !== n.A && te(B, "color", n.A = ee), n;
484
+ }, {
485
+ e: void 0,
486
+ t: void 0,
487
+ a: void 0,
488
+ o: void 0,
489
+ i: void 0,
490
+ n: void 0,
491
+ s: void 0,
492
+ h: void 0,
493
+ r: void 0,
494
+ d: void 0,
495
+ l: void 0,
496
+ u: void 0,
497
+ c: void 0,
498
+ w: void 0,
499
+ m: void 0,
500
+ f: void 0,
501
+ y: void 0,
502
+ g: void 0,
503
+ p: void 0,
504
+ b: void 0,
505
+ T: void 0,
506
+ A: void 0
507
+ }), o;
508
+ })();
509
+ };
510
+ var ie = /* @__PURE__ */ y("<div>"), St = /* @__PURE__ */ y("<div><div style=font-size:11px;color:#78716c;margin-bottom:4px>No batcher selected</div><div style=font-size:11px;color:#57534e>Click a batcher to see its trace info"), $t = /* @__PURE__ */ y("<span style=color:#78716c;font-weight:normal;font-style:italic> (unnamed)"), wt = /* @__PURE__ */ y("<div><div>Location</div><div>"), _t = /* @__PURE__ */ y("<div><div>Function</div><div>"), kt = /* @__PURE__ */ y('<div style="height:auto;padding:24px 0"><div style=font-size:11px;color:#57534e>No trace metadata available');
511
+ const Ct = {
512
+ padding: "12px",
513
+ height: "100%",
514
+ "overflow-y": "auto"
515
+ }, oe = {
516
+ display: "flex",
517
+ "flex-direction": "column",
518
+ "align-items": "center",
519
+ "justify-content": "center",
520
+ height: "100%",
521
+ color: "#57534e",
522
+ "text-align": "center"
523
+ }, le = {
524
+ "margin-bottom": "16px"
525
+ }, se = {
526
+ color: "#78716c",
527
+ "margin-bottom": "6px",
528
+ "font-size": "10px",
529
+ "text-transform": "uppercase",
530
+ "letter-spacing": "0.5px"
531
+ }, he = {
532
+ background: "#1c1917",
533
+ padding: "8px 10px",
534
+ "font-size": "11px",
535
+ color: "#d6d3d1",
536
+ border: "1px solid #292524"
537
+ }, zt = {
538
+ ...he,
539
+ "white-space": "pre-wrap",
540
+ "word-break": "break-all",
541
+ "max-height": "300px",
542
+ "overflow-y": "auto",
543
+ "font-family": "ui-monospace, monospace"
544
+ }, Bt = {
545
+ "font-size": "14px",
546
+ "font-weight": "600",
547
+ color: "#f5f5f4",
548
+ "margin-bottom": "16px"
549
+ }, Tt = (l) => {
550
+ const t = () => l.batcher;
551
+ return (() => {
552
+ var o = ie();
553
+ return r(o, Ct), v(o, (() => {
554
+ var d = w(() => !t());
555
+ return () => d() ? (() => {
556
+ var e = St(), i = e.firstChild;
557
+ return i.nextSibling, C((u) => r(e, oe, u)), e;
558
+ })() : [(() => {
559
+ var e = ie();
560
+ return r(e, Bt), v(e, () => t().name, null), v(e, (() => {
561
+ var i = w(() => !!t().isUnnamed);
562
+ return () => i() && $t();
563
+ })(), null), e;
564
+ })(), w(() => w(() => !!t().location)() && (() => {
565
+ var e = wt(), i = e.firstChild, u = i.nextSibling;
566
+ return v(u, () => t().location), C((a) => {
567
+ var f = le, g = se, x = he;
568
+ return a.e = r(e, f, a.e), a.t = r(i, g, a.t), a.a = r(u, x, a.a), a;
569
+ }, {
570
+ e: void 0,
571
+ t: void 0,
572
+ a: void 0
573
+ }), e;
574
+ })()), w(() => w(() => !!t().fnSource)() && (() => {
575
+ var e = _t(), i = e.firstChild, u = i.nextSibling;
576
+ return v(u, () => t().fnSource), C((a) => {
577
+ var f = le, g = se, x = zt;
578
+ return a.e = r(e, f, a.e), a.t = r(i, g, a.t), a.a = r(u, x, a.a), a;
579
+ }, {
580
+ e: void 0,
581
+ t: void 0,
582
+ a: void 0
583
+ }), e;
584
+ })()), w(() => w(() => !t().location && !t().fnSource)() && (() => {
585
+ var e = kt();
586
+ return e.firstChild, C((i) => r(e, {
587
+ ...oe
588
+ }, i)), e;
589
+ })())];
590
+ })()), o;
591
+ })();
592
+ };
593
+ var At = /* @__PURE__ */ y("<button>");
594
+ const ge = {
595
+ position: "fixed",
596
+ bottom: "16px",
597
+ right: "16px",
598
+ width: "40px",
599
+ height: "40px",
600
+ border: "1px solid #44403c",
601
+ background: "#1c1917",
602
+ color: "#a8a29e",
603
+ cursor: "pointer",
604
+ display: "flex",
605
+ "align-items": "center",
606
+ "justify-content": "center",
607
+ "z-index": "99999",
608
+ "font-family": "ui-monospace, monospace"
609
+ }, It = {
610
+ ...ge,
611
+ background: "#292524",
612
+ color: "#f5f5f4",
613
+ "border-color": "#57534e"
614
+ }, Dt = (l) => {
615
+ const t = () => ({
616
+ ...l.isOpen ? It : ge,
617
+ ...l.style
618
+ });
619
+ return (() => {
620
+ var o = At();
621
+ return Ae(o, "click", l.onClick, !0), v(o, () => l.isOpen ? "[×]" : "[=]"), C((d) => {
622
+ var e = l.class, i = t(), u = l.isOpen ? "Close BatchKit DevTools" : "Open BatchKit DevTools", a = l.isOpen ? "Close BatchKit DevTools" : "Open BatchKit DevTools";
623
+ return e !== d.e && ce(o, d.e = e), d.t = r(o, i, d.t), u !== d.a && Y(o, "title", d.a = u), a !== d.o && Y(o, "aria-label", d.o = a), d;
624
+ }, {
625
+ e: void 0,
626
+ t: void 0,
627
+ a: void 0,
628
+ o: void 0
629
+ }), o;
630
+ })();
631
+ };
632
+ J(["click"]);
633
+ var Ot = /* @__PURE__ */ y("<div><div><div><span style=color:#78716c>[=]</span>Devtools</div><button>Clear</button></div><div><div><div>Batchers</div></div><div><div><button>Timeline</button><button>Events</button><button>Stats</button><button>Trace</button></div><div>");
634
+ const ae = "650px", Et = "350px", Rt = "0.2s";
635
+ function Nt(l) {
636
+ const t = {
637
+ position: "fixed",
638
+ background: "#0c0a09",
639
+ "border-color": "#44403c",
640
+ "border-style": "solid",
641
+ "border-width": "0",
642
+ display: "flex",
643
+ "flex-direction": "column",
644
+ overflow: "hidden",
645
+ "z-index": "99998",
646
+ "font-family": "ui-monospace, monospace",
647
+ color: "#d6d3d1",
648
+ transition: `transform ${Rt} ease-out`,
649
+ "box-shadow": "0 0 10px 0 rgba(0, 0, 0, 0.1)"
650
+ };
651
+ switch (l) {
652
+ case "right":
653
+ return {
654
+ ...t,
655
+ top: "0",
656
+ right: "0",
657
+ width: ae,
658
+ height: "100vh",
659
+ "border-left-width": "1px",
660
+ "box-shadow": "0 0 10px 0 rgba(0, 0, 0, 0.1)"
661
+ };
662
+ case "left":
663
+ return {
664
+ ...t,
665
+ top: "0",
666
+ left: "0",
667
+ width: ae,
668
+ height: "100vh",
669
+ "border-right-width": "1px",
670
+ "box-shadow": "0 0 10px 0 rgba(0, 0, 0, 0.1)"
671
+ };
672
+ case "bottom":
673
+ return {
674
+ ...t,
675
+ bottom: "0",
676
+ left: "0",
677
+ right: "0",
678
+ width: "100%",
679
+ height: Et,
680
+ "border-top-width": "1px",
681
+ "box-shadow": "0 0 10px 0 rgba(0, 0, 0, 0.1)"
682
+ };
683
+ }
684
+ }
685
+ function jt(l, t) {
686
+ if (t) return "translate(0, 0)";
687
+ switch (l) {
688
+ case "right":
689
+ return "translateX(100%)";
690
+ case "left":
691
+ return "translateX(-100%)";
692
+ case "bottom":
693
+ return "translateY(100%)";
694
+ }
695
+ }
696
+ const Ft = {
697
+ display: "flex",
698
+ "align-items": "center",
699
+ "justify-content": "space-between",
700
+ padding: "8px 12px",
701
+ background: "#1c1917",
702
+ "border-bottom": "1px solid #44403c",
703
+ "flex-shrink": "0",
704
+ "user-select": "none"
705
+ }, Kt = {
706
+ "font-size": "11px",
707
+ "font-weight": "500",
708
+ color: "#a8a29e",
709
+ display: "flex",
710
+ "align-items": "center",
711
+ gap: "8px",
712
+ "text-transform": "uppercase",
713
+ "letter-spacing": "0.5px"
714
+ }, Lt = {
715
+ padding: "4px 8px",
716
+ border: "1px solid #44403c",
717
+ background: "#1c1917",
718
+ color: "#78716c",
719
+ "font-size": "11px",
720
+ "font-family": "ui-monospace, monospace",
721
+ cursor: "pointer"
722
+ }, Mt = {
723
+ display: "flex",
724
+ flex: "1",
725
+ "min-height": "0"
726
+ }, Ht = {
727
+ width: "160px",
728
+ "border-right": "1px solid #44403c",
729
+ display: "flex",
730
+ "flex-direction": "column",
731
+ background: "#0c0a09",
732
+ "flex-shrink": "0",
733
+ "user-select": "none"
734
+ }, Gt = {
735
+ padding: "8px 12px",
736
+ "font-size": "11px",
737
+ "font-weight": "500",
738
+ "text-transform": "uppercase",
739
+ "letter-spacing": "0.5px",
740
+ color: "#78716c",
741
+ "border-bottom": "1px solid #292524"
742
+ }, Ut = {
743
+ flex: "1",
744
+ display: "flex",
745
+ "flex-direction": "column",
746
+ "min-width": "0"
747
+ }, Wt = {
748
+ display: "flex",
749
+ "border-bottom": "1px solid #44403c",
750
+ background: "#1c1917",
751
+ "flex-shrink": "0",
752
+ "user-select": "none"
753
+ }, K = {
754
+ padding: "8px 12px",
755
+ "font-size": "11px",
756
+ "font-weight": "500",
757
+ color: "#78716c",
758
+ cursor: "pointer",
759
+ "border-bottom": "1px solid transparent",
760
+ "margin-bottom": "-1px",
761
+ background: "transparent",
762
+ border: "none",
763
+ "font-family": "ui-monospace, monospace"
764
+ }, H = {
765
+ ...K,
766
+ color: "#f5f5f4",
767
+ "border-bottom": "1px solid #f5f5f4"
768
+ }, qt = {
769
+ flex: "1",
770
+ overflow: "auto",
771
+ padding: "12px",
772
+ background: "#0c0a09"
773
+ }, Pt = (l) => {
774
+ const t = Ke(), [o, d] = Q("timeline"), e = () => l.position ?? "right";
775
+ Oe(() => {
776
+ l.defaultOpen && G().open();
777
+ });
778
+ const i = () => {
779
+ G().toggle();
780
+ }, u = () => {
781
+ G().clear();
782
+ }, a = () => t().selectedBatcher, f = () => t().batchers, g = () => t().events, x = () => t().batches, m = () => {
783
+ const h = a();
784
+ return h ? g().filter((s) => s.batcherName === h) : g();
785
+ }, S = () => {
786
+ const h = a();
787
+ return h ? Array.from(x().values()).filter((s) => s.batcherName === h) : Array.from(x().values());
788
+ }, c = () => ({
789
+ ...Nt(e()),
790
+ transform: jt(e(), t().isOpen),
791
+ ...l.panelStyle
792
+ });
793
+ return [k(Dt, {
794
+ get isOpen() {
795
+ return t().isOpen;
796
+ },
797
+ onClick: i,
798
+ get style() {
799
+ return l.buttonStyle;
800
+ },
801
+ get class() {
802
+ return l.buttonClass;
803
+ }
804
+ }), (() => {
805
+ var h = Ot(), s = h.firstChild, $ = s.firstChild;
806
+ $.firstChild;
807
+ var _ = $.nextSibling, p = s.nextSibling, b = p.firstChild, T = b.firstChild, F = b.nextSibling, I = F.firstChild, D = I.firstChild, O = D.nextSibling, A = O.nextSibling, L = A.nextSibling, B = I.nextSibling;
808
+ return r(s, Ft), r($, Kt), _.$$click = u, r(_, Lt), r(p, Mt), r(b, Ht), r(T, Gt), v(b, k(Ye, {
809
+ get batchers() {
810
+ return f();
811
+ },
812
+ get events() {
813
+ return g();
814
+ },
815
+ get selectedBatcher() {
816
+ return a();
817
+ },
818
+ onSelect: Le
819
+ }), null), r(F, Ut), r(I, Wt), D.$$click = () => d("timeline"), O.$$click = () => d("events"), A.$$click = () => d("stats"), L.$$click = () => d("trace"), r(B, qt), v(B, (() => {
820
+ var n = w(() => o() === "timeline");
821
+ return () => n() && k(lt, {
822
+ get batches() {
823
+ return S();
824
+ }
825
+ });
826
+ })(), null), v(B, (() => {
827
+ var n = w(() => o() === "events");
828
+ return () => n() && k(xt, {
829
+ get events() {
830
+ return m();
831
+ }
832
+ });
833
+ })(), null), v(B, (() => {
834
+ var n = w(() => o() === "stats");
835
+ return () => n() && k(yt, {
836
+ get events() {
837
+ return m();
838
+ },
839
+ get batches() {
840
+ return S();
841
+ }
842
+ });
843
+ })(), null), v(B, (() => {
844
+ var n = w(() => o() === "trace");
845
+ return () => n() && k(Tt, {
846
+ get batcher() {
847
+ return w(() => !!a())() ? f().get(a()) ?? null : null;
848
+ }
849
+ });
850
+ })(), null), C((n) => {
851
+ var M = l.panelClass, U = c(), W = o() === "timeline" ? H : K, q = o() === "events" ? H : K, P = o() === "stats" ? H : K, X = o() === "trace" ? H : K;
852
+ return M !== n.e && ce(h, n.e = M), n.t = r(h, U, n.t), n.a = r(D, W, n.a), n.o = r(O, q, n.o), n.i = r(A, P, n.i), n.n = r(L, X, n.n), n;
853
+ }, {
854
+ e: void 0,
855
+ t: void 0,
856
+ a: void 0,
857
+ o: void 0,
858
+ i: void 0,
859
+ n: void 0
860
+ }), h;
861
+ })()];
862
+ };
863
+ J(["click"]);
864
+ function Qt(l, t) {
865
+ if (typeof window > "u")
866
+ return () => {
867
+ };
868
+ Fe();
869
+ const o = {
870
+ position: t == null ? void 0 : t.position,
871
+ defaultOpen: t == null ? void 0 : t.defaultOpen,
872
+ buttonStyle: t == null ? void 0 : t.buttonStyle,
873
+ buttonClass: t == null ? void 0 : t.buttonClass,
874
+ panelStyle: t == null ? void 0 : t.panelStyle,
875
+ panelClass: t == null ? void 0 : t.panelClass
876
+ };
877
+ return Ie(() => Pt(o), l);
878
+ }
879
+ export {
880
+ G as g,
881
+ Fe as i,
882
+ Qt as m,
883
+ Ke as u
884
+ };