atomirx 0.0.8 → 0.1.1

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 (138) hide show
  1. package/README.md +198 -2234
  2. package/bin/cli.js +90 -0
  3. package/dist/core/derived.d.ts +2 -2
  4. package/dist/core/effect.d.ts +3 -2
  5. package/dist/core/onCreateHook.d.ts +15 -2
  6. package/dist/core/onErrorHook.d.ts +4 -1
  7. package/dist/core/pool.d.ts +78 -0
  8. package/dist/core/pool.test.d.ts +1 -0
  9. package/dist/core/select-boolean.test.d.ts +1 -0
  10. package/dist/core/select-pool.test.d.ts +1 -0
  11. package/dist/core/select.d.ts +278 -86
  12. package/dist/core/types.d.ts +233 -1
  13. package/dist/core/withAbort.d.ts +95 -0
  14. package/dist/core/withReady.d.ts +3 -3
  15. package/dist/devtools/constants.d.ts +41 -0
  16. package/dist/devtools/index.cjs +1 -0
  17. package/dist/devtools/index.d.ts +29 -0
  18. package/dist/devtools/index.js +429 -0
  19. package/dist/devtools/registry.d.ts +98 -0
  20. package/dist/devtools/registry.test.d.ts +1 -0
  21. package/dist/devtools/setup.d.ts +61 -0
  22. package/dist/devtools/types.d.ts +311 -0
  23. package/dist/index-BZEnfIcB.cjs +1 -0
  24. package/dist/index-BbPZhsDl.js +1653 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.d.ts +4 -3
  27. package/dist/index.js +18 -14
  28. package/dist/onDispatchHook-C8yLzr-o.cjs +1 -0
  29. package/dist/onDispatchHook-SKbiIUaJ.js +5 -0
  30. package/dist/onErrorHook-BGGy3tqK.js +38 -0
  31. package/dist/onErrorHook-DHBASmYw.cjs +1 -0
  32. package/dist/react/index.cjs +1 -1
  33. package/dist/react/index.js +191 -151
  34. package/dist/react/onDispatchHook.d.ts +106 -0
  35. package/dist/react/useAction.d.ts +4 -1
  36. package/dist/react-devtools/DevToolsPanel.d.ts +93 -0
  37. package/dist/react-devtools/EntityDetails.d.ts +10 -0
  38. package/dist/react-devtools/EntityList.d.ts +15 -0
  39. package/dist/react-devtools/LogList.d.ts +12 -0
  40. package/dist/react-devtools/hooks.d.ts +50 -0
  41. package/dist/react-devtools/index.cjs +1 -0
  42. package/dist/react-devtools/index.d.ts +31 -0
  43. package/dist/react-devtools/index.js +1589 -0
  44. package/dist/react-devtools/styles.d.ts +148 -0
  45. package/package.json +26 -2
  46. package/skills/atomirx/SKILL.md +456 -0
  47. package/skills/atomirx/references/async-patterns.md +188 -0
  48. package/skills/atomirx/references/atom-patterns.md +238 -0
  49. package/skills/atomirx/references/deferred-loading.md +191 -0
  50. package/skills/atomirx/references/derived-patterns.md +428 -0
  51. package/skills/atomirx/references/effect-patterns.md +426 -0
  52. package/skills/atomirx/references/error-handling.md +140 -0
  53. package/skills/atomirx/references/hooks.md +322 -0
  54. package/skills/atomirx/references/pool-patterns.md +229 -0
  55. package/skills/atomirx/references/react-integration.md +411 -0
  56. package/skills/atomirx/references/rules.md +407 -0
  57. package/skills/atomirx/references/select-context.md +309 -0
  58. package/skills/atomirx/references/service-template.md +172 -0
  59. package/skills/atomirx/references/store-template.md +205 -0
  60. package/skills/atomirx/references/testing-patterns.md +431 -0
  61. package/coverage/base.css +0 -224
  62. package/coverage/block-navigation.js +0 -87
  63. package/coverage/clover.xml +0 -1440
  64. package/coverage/coverage-final.json +0 -14
  65. package/coverage/favicon.png +0 -0
  66. package/coverage/index.html +0 -131
  67. package/coverage/prettify.css +0 -1
  68. package/coverage/prettify.js +0 -2
  69. package/coverage/sort-arrow-sprite.png +0 -0
  70. package/coverage/sorter.js +0 -210
  71. package/coverage/src/core/atom.ts.html +0 -889
  72. package/coverage/src/core/batch.ts.html +0 -223
  73. package/coverage/src/core/define.ts.html +0 -805
  74. package/coverage/src/core/emitter.ts.html +0 -919
  75. package/coverage/src/core/equality.ts.html +0 -631
  76. package/coverage/src/core/hook.ts.html +0 -460
  77. package/coverage/src/core/index.html +0 -281
  78. package/coverage/src/core/isAtom.ts.html +0 -100
  79. package/coverage/src/core/isPromiseLike.ts.html +0 -133
  80. package/coverage/src/core/onCreateHook.ts.html +0 -138
  81. package/coverage/src/core/scheduleNotifyHook.ts.html +0 -94
  82. package/coverage/src/core/types.ts.html +0 -523
  83. package/coverage/src/core/withUse.ts.html +0 -253
  84. package/coverage/src/index.html +0 -116
  85. package/coverage/src/index.ts.html +0 -106
  86. package/dist/index-CBVj1kSj.js +0 -1350
  87. package/dist/index-Cxk9v0um.cjs +0 -1
  88. package/scripts/publish.js +0 -198
  89. package/src/core/atom.test.ts +0 -633
  90. package/src/core/atom.ts +0 -311
  91. package/src/core/atomState.test.ts +0 -342
  92. package/src/core/atomState.ts +0 -256
  93. package/src/core/batch.test.ts +0 -257
  94. package/src/core/batch.ts +0 -172
  95. package/src/core/define.test.ts +0 -343
  96. package/src/core/define.ts +0 -243
  97. package/src/core/derived.test.ts +0 -1215
  98. package/src/core/derived.ts +0 -450
  99. package/src/core/effect.test.ts +0 -802
  100. package/src/core/effect.ts +0 -188
  101. package/src/core/emitter.test.ts +0 -364
  102. package/src/core/emitter.ts +0 -392
  103. package/src/core/equality.test.ts +0 -392
  104. package/src/core/equality.ts +0 -182
  105. package/src/core/getAtomState.ts +0 -69
  106. package/src/core/hook.test.ts +0 -227
  107. package/src/core/hook.ts +0 -177
  108. package/src/core/isAtom.ts +0 -27
  109. package/src/core/isPromiseLike.test.ts +0 -72
  110. package/src/core/isPromiseLike.ts +0 -16
  111. package/src/core/onCreateHook.ts +0 -107
  112. package/src/core/onErrorHook.test.ts +0 -350
  113. package/src/core/onErrorHook.ts +0 -52
  114. package/src/core/promiseCache.test.ts +0 -241
  115. package/src/core/promiseCache.ts +0 -284
  116. package/src/core/scheduleNotifyHook.ts +0 -53
  117. package/src/core/select.ts +0 -729
  118. package/src/core/selector.test.ts +0 -799
  119. package/src/core/types.ts +0 -389
  120. package/src/core/withReady.test.ts +0 -534
  121. package/src/core/withReady.ts +0 -191
  122. package/src/core/withUse.test.ts +0 -249
  123. package/src/core/withUse.ts +0 -56
  124. package/src/index.test.ts +0 -80
  125. package/src/index.ts +0 -65
  126. package/src/react/index.ts +0 -21
  127. package/src/react/rx.test.tsx +0 -571
  128. package/src/react/rx.tsx +0 -531
  129. package/src/react/strictModeTest.tsx +0 -71
  130. package/src/react/useAction.test.ts +0 -987
  131. package/src/react/useAction.ts +0 -607
  132. package/src/react/useSelector.test.ts +0 -182
  133. package/src/react/useSelector.ts +0 -292
  134. package/src/react/useStable.test.ts +0 -553
  135. package/src/react/useStable.ts +0 -288
  136. package/tsconfig.json +0 -9
  137. package/v2.md +0 -725
  138. package/vite.config.ts +0 -42
@@ -0,0 +1,1589 @@
1
+ import { jsxs as i, jsx as r, Fragment as z } from "react/jsx-runtime";
2
+ import { useCallback as h, useSyncExternalStore as V, useState as L, useEffect as S, memo as I, useMemo as M } from "react";
3
+ import { createRoot as me } from "react-dom/client";
4
+ import { STORAGE_KEY_PREFERENCES as j, DEFAULT_PREFERENCES as N, MIN_PANEL_SIZE as H, MAX_PANEL_SIZE as K, ANIMATION_DURATION as E, FLOATING_BUTTON_SIZE as O, DEVTOOLS_Z_INDEX as U, setupDevtools as X, getDevtoolsRegistry as _ } from "../devtools/index.js";
5
+ import { DEFAULT_MAX_HISTORY_SIZE as pt, DEFAULT_PANEL_SIZE as ht, ENTITY_ID_PREFIX as xt, STORAGE_VERSION as vt, _resetDevtools as gt, getRegistry as bt, isDevtoolsEnabled as yt, resetRegistry as St } from "../devtools/index.js";
6
+ function fe() {
7
+ try {
8
+ const e = localStorage.getItem(j);
9
+ if (e) {
10
+ const t = JSON.parse(e);
11
+ return { ...N, ...t };
12
+ }
13
+ } catch {
14
+ }
15
+ return N;
16
+ }
17
+ function pe(e) {
18
+ try {
19
+ localStorage.setItem(j, JSON.stringify(e));
20
+ } catch {
21
+ }
22
+ }
23
+ function he() {
24
+ const [e, t] = L(
25
+ () => fe()
26
+ );
27
+ S(() => {
28
+ pe(e);
29
+ }, [e]);
30
+ const n = h((c) => {
31
+ t((u) => ({ ...u, isOpen: c }));
32
+ }, []), o = h((c) => {
33
+ t((u) => ({ ...u, position: c }));
34
+ }, []), a = h((c) => {
35
+ t((u) => ({ ...u, activeTab: c }));
36
+ }, []), l = h((c) => {
37
+ const u = Math.max(H, Math.min(K, c));
38
+ t((b) => ({ ...b, panelSize: u }));
39
+ }, []), d = h((c, u) => {
40
+ t((b) => ({
41
+ ...b,
42
+ searchText: { ...b.searchText, [c]: u }
43
+ }));
44
+ }, []), m = h((c) => {
45
+ t((u) => ({ ...u, atomFilter: c }));
46
+ }, []), x = h((c) => {
47
+ t((u) => ({ ...u, selectedEntityId: c }));
48
+ }, []), s = h((c) => {
49
+ t((u) => ({ ...u, showAtomValues: c }));
50
+ }, []), f = h(() => {
51
+ t((c) => ({
52
+ ...c,
53
+ showAtomValues: !c.showAtomValues
54
+ }));
55
+ }, []), g = h(() => {
56
+ t((c) => ({ ...c, isOpen: !c.isOpen }));
57
+ }, []), D = h(() => {
58
+ t((c) => {
59
+ const u = ["bottom", "right", "left"], R = (u.indexOf(c.position) + 1) % u.length;
60
+ return { ...c, position: u[R] };
61
+ });
62
+ }, []);
63
+ return {
64
+ preferences: e,
65
+ setIsOpen: n,
66
+ setPosition: o,
67
+ setActiveTab: a,
68
+ setPanelSize: l,
69
+ setSearchText: d,
70
+ setAtomFilter: m,
71
+ setSelectedEntityId: x,
72
+ setShowAtomValues: s,
73
+ togglePanel: g,
74
+ cyclePosition: D,
75
+ toggleShowAtomValues: f
76
+ };
77
+ }
78
+ function xe(e) {
79
+ const t = h(
80
+ (o) => e ? e.subscribe(o) : () => {
81
+ },
82
+ [e]
83
+ ), n = h(() => e ? e.entities : null, [e]);
84
+ return V(t, n, n);
85
+ }
86
+ function ve(e) {
87
+ const t = h(
88
+ (o) => e ? e.subscribe(o) : () => {
89
+ },
90
+ [e]
91
+ ), n = h(() => e ? e.logs : null, [e]);
92
+ return V(t, n, n);
93
+ }
94
+ function ge(e, t = !0) {
95
+ S(() => {
96
+ if (!t) return;
97
+ const n = (o) => {
98
+ (o.ctrlKey || o.metaKey) && o.shiftKey && o.key.toLowerCase() === "d" && (o.preventDefault(), e());
99
+ };
100
+ return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
101
+ }, [e, t]);
102
+ }
103
+ function be(e, t, n) {
104
+ const [o, a] = L(!1), l = h((d) => {
105
+ d.preventDefault(), a(!0);
106
+ }, []);
107
+ return S(() => {
108
+ if (!o) return;
109
+ const d = (x) => {
110
+ let s;
111
+ switch (e) {
112
+ case "bottom":
113
+ s = window.innerHeight - x.clientY;
114
+ break;
115
+ case "right":
116
+ s = window.innerWidth - x.clientX;
117
+ break;
118
+ case "left":
119
+ s = x.clientX;
120
+ break;
121
+ }
122
+ n(Math.max(H, Math.min(K, s)));
123
+ }, m = () => {
124
+ a(!1);
125
+ };
126
+ return document.addEventListener("mousemove", d), document.addEventListener("mouseup", m), () => {
127
+ document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", m);
128
+ };
129
+ }, [o, e, n]), {
130
+ isResizing: o,
131
+ handleMouseDown: l
132
+ };
133
+ }
134
+ function k(e, t = 500) {
135
+ if (e === void 0) return "undefined";
136
+ if (e === null) return "null";
137
+ try {
138
+ const n = /* @__PURE__ */ new WeakSet(), o = JSON.stringify(
139
+ e,
140
+ (a, l) => {
141
+ if (typeof l == "object" && l !== null) {
142
+ if (n.has(l)) return "[Circular]";
143
+ n.add(l);
144
+ }
145
+ return typeof l == "function" ? "[Function]" : typeof l == "symbol" ? l.toString() : l instanceof Error ? `[Error: ${l.message}]` : l instanceof Map ? `[Map(${l.size})]` : l instanceof Set ? `[Set(${l.size})]` : l instanceof WeakMap ? "[WeakMap]" : l instanceof WeakSet ? "[WeakSet]" : l instanceof Promise ? "[Promise]" : l;
146
+ },
147
+ 2
148
+ );
149
+ return o.length > t ? o.slice(0, t) + "..." : o;
150
+ } catch {
151
+ return "[unserializable]";
152
+ }
153
+ }
154
+ function A(e) {
155
+ const t = new Date(e), n = t.toLocaleTimeString(void 0, {
156
+ hour: "2-digit",
157
+ minute: "2-digit",
158
+ second: "2-digit"
159
+ }), o = String(t.getMilliseconds()).padStart(3, "0");
160
+ return `${n}.${o}`;
161
+ }
162
+ const ye = {
163
+ // Colors
164
+ "--atomirx-bg-primary": "#1a1a2e",
165
+ "--atomirx-bg-secondary": "#16213e",
166
+ "--atomirx-bg-tertiary": "#0f3460",
167
+ "--atomirx-bg-hover": "#1f4287",
168
+ "--atomirx-text-primary": "#eaeaea",
169
+ "--atomirx-text-secondary": "#a0a0a0",
170
+ "--atomirx-text-muted": "#666666",
171
+ "--atomirx-border": "#2a2a4a",
172
+ "--atomirx-accent": "#e94560",
173
+ "--atomirx-accent-hover": "#ff6b6b",
174
+ "--atomirx-success": "#4ade80",
175
+ "--atomirx-warning": "#fbbf24",
176
+ "--atomirx-error": "#ef4444",
177
+ "--atomirx-info": "#3b82f6",
178
+ // Badges
179
+ "--atomirx-badge-mutable": "#3b82f6",
180
+ "--atomirx-badge-derived": "#8b5cf6",
181
+ "--atomirx-badge-effect": "#f59e0b",
182
+ "--atomirx-badge-pool": "#10b981",
183
+ "--atomirx-badge-module": "#ec4899",
184
+ // Sizing
185
+ "--atomirx-radius": "6px",
186
+ "--atomirx-radius-lg": "8px",
187
+ "--atomirx-font-size": "11px",
188
+ "--atomirx-font-size-sm": "9px",
189
+ "--atomirx-font-mono": "ui-monospace, SFMono-Regular, SF Mono, Menlo, monospace"
190
+ }, Se = {
191
+ ...Object.fromEntries(Object.entries(ye).map(([e, t]) => [e, t])),
192
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
193
+ fontSize: "var(--atomirx-font-size)",
194
+ color: "var(--atomirx-text-primary)",
195
+ boxSizing: "border-box"
196
+ }, we = {
197
+ position: "fixed",
198
+ bottom: 16,
199
+ left: 16,
200
+ width: O,
201
+ height: O,
202
+ borderRadius: "50%",
203
+ backgroundColor: "var(--atomirx-accent)",
204
+ color: "white",
205
+ border: "none",
206
+ cursor: "pointer",
207
+ display: "flex",
208
+ alignItems: "center",
209
+ justifyContent: "center",
210
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.3)",
211
+ zIndex: U + 1,
212
+ transition: `transform ${E}ms ease, background-color ${E}ms ease`
213
+ }, ke = (e, t, n) => {
214
+ const o = {
215
+ position: "fixed",
216
+ backgroundColor: "var(--atomirx-bg-primary)",
217
+ borderColor: "var(--atomirx-border)",
218
+ borderStyle: "solid",
219
+ borderTopWidth: 0,
220
+ borderRightWidth: 0,
221
+ borderBottomWidth: 0,
222
+ borderLeftWidth: 0,
223
+ zIndex: U,
224
+ display: "flex",
225
+ flexDirection: "column",
226
+ transition: `transform ${E}ms ease`,
227
+ overflow: "hidden"
228
+ };
229
+ switch (e) {
230
+ case "bottom":
231
+ return {
232
+ ...o,
233
+ left: 0,
234
+ right: 0,
235
+ bottom: 0,
236
+ height: t,
237
+ borderTopWidth: 1,
238
+ transform: n ? "translateY(0)" : "translateY(100%)"
239
+ };
240
+ case "right":
241
+ return {
242
+ ...o,
243
+ top: 0,
244
+ right: 0,
245
+ bottom: 0,
246
+ width: t,
247
+ borderLeftWidth: 1,
248
+ transform: n ? "translateX(0)" : "translateX(100%)"
249
+ };
250
+ case "left":
251
+ return {
252
+ ...o,
253
+ top: 0,
254
+ left: 0,
255
+ bottom: 0,
256
+ width: t,
257
+ borderRightWidth: 1,
258
+ transform: n ? "translateX(0)" : "translateX(-100%)"
259
+ };
260
+ }
261
+ }, Ce = {
262
+ display: "flex",
263
+ alignItems: "center",
264
+ gap: 0,
265
+ backgroundColor: "var(--atomirx-bg-secondary)",
266
+ borderBottom: "1px solid var(--atomirx-border)",
267
+ padding: "0 8px",
268
+ height: 40,
269
+ flexShrink: 0
270
+ }, ze = (e) => ({
271
+ padding: "8px 14px",
272
+ background: "none",
273
+ border: "none",
274
+ color: e ? "var(--atomirx-text-primary)" : "var(--atomirx-text-secondary)",
275
+ cursor: "pointer",
276
+ fontSize: "var(--atomirx-font-size)",
277
+ fontWeight: e ? 600 : 400,
278
+ borderBottom: e ? "2px solid var(--atomirx-accent)" : "2px solid transparent",
279
+ marginBottom: -1,
280
+ transition: `color ${E}ms ease, border-color ${E}ms ease`
281
+ }), Ee = {
282
+ display: "flex",
283
+ alignItems: "center",
284
+ gap: 8,
285
+ padding: "8px 12px",
286
+ backgroundColor: "var(--atomirx-bg-secondary)",
287
+ borderBottom: "1px solid var(--atomirx-border)",
288
+ flexShrink: 0
289
+ }, Ie = {
290
+ flex: 1,
291
+ padding: "6px 10px",
292
+ backgroundColor: "var(--atomirx-bg-tertiary)",
293
+ border: "1px solid var(--atomirx-border)",
294
+ borderRadius: "var(--atomirx-radius)",
295
+ color: "var(--atomirx-text-primary)",
296
+ fontSize: "var(--atomirx-font-size)",
297
+ outline: "none",
298
+ minWidth: 0
299
+ }, De = {
300
+ display: "flex",
301
+ gap: 0,
302
+ borderRadius: "var(--atomirx-radius)",
303
+ overflow: "hidden",
304
+ border: "1px solid var(--atomirx-border)"
305
+ }, $ = (e) => ({
306
+ padding: "4px 10px",
307
+ background: e ? "var(--atomirx-bg-hover)" : "var(--atomirx-bg-tertiary)",
308
+ border: "none",
309
+ color: e ? "var(--atomirx-text-primary)" : "var(--atomirx-text-secondary)",
310
+ cursor: "pointer",
311
+ fontSize: "var(--atomirx-font-size-sm)",
312
+ transition: `background-color ${E}ms ease`
313
+ }), G = {
314
+ flex: 1,
315
+ overflow: "auto",
316
+ padding: 0
317
+ }, Le = (e) => ({
318
+ display: "flex",
319
+ alignItems: "center",
320
+ gap: 8,
321
+ padding: "8px 12px",
322
+ borderBottom: "1px solid var(--atomirx-border)",
323
+ cursor: "pointer",
324
+ backgroundColor: e ? "var(--atomirx-bg-hover)" : "transparent",
325
+ transition: `background-color ${E}ms ease`
326
+ }), Y = (e) => ({
327
+ display: "inline-flex",
328
+ alignItems: "center",
329
+ justifyContent: "center",
330
+ width: 22,
331
+ height: 22,
332
+ borderRadius: "var(--atomirx-radius)",
333
+ backgroundColor: {
334
+ mutable: "var(--atomirx-badge-mutable)",
335
+ derived: "var(--atomirx-badge-derived)",
336
+ effect: "var(--atomirx-badge-effect)",
337
+ pool: "var(--atomirx-badge-pool)",
338
+ module: "var(--atomirx-badge-module)"
339
+ }[e],
340
+ color: "white",
341
+ fontSize: "var(--atomirx-font-size-sm)",
342
+ fontWeight: 600,
343
+ flexShrink: 0
344
+ }), Z = {
345
+ flex: 1,
346
+ overflow: "hidden",
347
+ textOverflow: "ellipsis",
348
+ whiteSpace: "nowrap",
349
+ fontFamily: "var(--atomirx-font-mono)",
350
+ fontSize: 11
351
+ }, J = {
352
+ color: "var(--atomirx-text-muted)",
353
+ fontSize: "var(--atomirx-font-size-sm)",
354
+ fontFamily: "var(--atomirx-font-mono)",
355
+ maxWidth: 150,
356
+ overflow: "hidden",
357
+ textOverflow: "ellipsis",
358
+ whiteSpace: "nowrap"
359
+ }, Me = {
360
+ position: "absolute",
361
+ top: 0,
362
+ left: 0,
363
+ right: 0,
364
+ bottom: 0,
365
+ backgroundColor: "var(--atomirx-bg-primary)",
366
+ display: "flex",
367
+ flexDirection: "column",
368
+ overflow: "hidden",
369
+ zIndex: 100
370
+ }, Te = {
371
+ padding: "10px",
372
+ borderBottom: "1px solid var(--atomirx-border)",
373
+ fontWeight: 600
374
+ }, Re = {
375
+ padding: "10px",
376
+ borderBottom: "1px solid var(--atomirx-border)"
377
+ }, Ae = {
378
+ fontSize: "var(--atomirx-font-size-sm)",
379
+ color: "var(--atomirx-text-secondary)",
380
+ marginBottom: 4,
381
+ textTransform: "uppercase",
382
+ letterSpacing: "0.5px"
383
+ }, y = {
384
+ fontFamily: "var(--atomirx-font-mono)",
385
+ fontSize: "var(--atomirx-font-size)",
386
+ wordBreak: "break-all"
387
+ }, T = {
388
+ backgroundColor: "var(--atomirx-bg-tertiary)",
389
+ padding: "6px 8px",
390
+ borderRadius: "var(--atomirx-radius)",
391
+ fontFamily: "var(--atomirx-font-mono)",
392
+ fontSize: "var(--atomirx-font-size-sm)",
393
+ whiteSpace: "pre-wrap",
394
+ wordBreak: "break-all"
395
+ }, Be = {
396
+ padding: "4px 0",
397
+ borderBottom: "1px solid var(--atomirx-border)",
398
+ fontSize: "var(--atomirx-font-size-sm)"
399
+ }, Pe = {
400
+ color: "var(--atomirx-text-muted)",
401
+ fontSize: "var(--atomirx-font-size-sm)"
402
+ }, We = {
403
+ padding: "4px 8px",
404
+ background: "var(--atomirx-bg-tertiary)",
405
+ border: "1px solid var(--atomirx-border)",
406
+ borderRadius: "var(--atomirx-radius)",
407
+ color: "var(--atomirx-text-secondary)",
408
+ cursor: "pointer",
409
+ fontSize: "var(--atomirx-font-size-sm)",
410
+ marginLeft: "auto"
411
+ }, q = {
412
+ padding: "4px 8px",
413
+ background: "none",
414
+ border: "none",
415
+ color: "var(--atomirx-text-secondary)",
416
+ cursor: "pointer",
417
+ fontSize: 18,
418
+ lineHeight: 1
419
+ }, Q = {
420
+ display: "flex",
421
+ alignItems: "center",
422
+ justifyContent: "center",
423
+ padding: 32,
424
+ color: "var(--atomirx-text-muted)",
425
+ fontStyle: "italic"
426
+ }, P = (e) => ({
427
+ display: "inline-block",
428
+ width: 8,
429
+ height: 8,
430
+ borderRadius: "50%",
431
+ backgroundColor: {
432
+ ready: "var(--atomirx-success)",
433
+ loading: "var(--atomirx-warning)",
434
+ error: "var(--atomirx-error)"
435
+ }[e],
436
+ marginRight: 6
437
+ }), Fe = (e) => {
438
+ const t = {
439
+ position: "absolute",
440
+ backgroundColor: "transparent",
441
+ zIndex: 1
442
+ };
443
+ switch (e) {
444
+ case "bottom":
445
+ return {
446
+ ...t,
447
+ top: 0,
448
+ left: 0,
449
+ right: 0,
450
+ height: 4,
451
+ cursor: "ns-resize"
452
+ };
453
+ case "right":
454
+ return {
455
+ ...t,
456
+ top: 0,
457
+ left: 0,
458
+ bottom: 0,
459
+ width: 4,
460
+ cursor: "ew-resize"
461
+ };
462
+ case "left":
463
+ return {
464
+ ...t,
465
+ top: 0,
466
+ right: 0,
467
+ bottom: 0,
468
+ width: 4,
469
+ cursor: "ew-resize"
470
+ };
471
+ }
472
+ }, Ne = {
473
+ display: "flex",
474
+ flex: 1,
475
+ overflow: "hidden"
476
+ };
477
+ function Oe(e, t) {
478
+ const n = e.instanceRef.deref();
479
+ if (!n) return "[disposed]";
480
+ switch (e.type) {
481
+ case "mutable":
482
+ return t ? k(n.get(), 50) : "—";
483
+ case "derived":
484
+ return t ? k(n.staleValue, 50) : "—";
485
+ case "effect":
486
+ return `runs: ${e.runCount}`;
487
+ case "pool":
488
+ return `entries: ${n.size()}`;
489
+ case "module":
490
+ return "[module]";
491
+ default:
492
+ return "";
493
+ }
494
+ }
495
+ function B(e) {
496
+ const t = e.instanceRef.deref();
497
+ return t ? t.state().status : "error";
498
+ }
499
+ const _e = I(function({
500
+ entity: t,
501
+ isSelected: n,
502
+ onClick: o,
503
+ showValues: a
504
+ }) {
505
+ const [l, d] = L(0);
506
+ S(() => {
507
+ const s = t.instanceRef.deref();
508
+ if (s) {
509
+ if (t.type === "mutable" || t.type === "derived")
510
+ return a ? s.on(() => {
511
+ d((g) => g + 1);
512
+ }) : void 0;
513
+ if (t.type === "pool")
514
+ return s.on(() => {
515
+ d((g) => g + 1);
516
+ });
517
+ }
518
+ }, [t, a]);
519
+ const m = M(
520
+ () => Oe(t, a),
521
+ // updateCount triggers recalculation on atom changes
522
+ // eslint-disable-next-line react-hooks/exhaustive-deps
523
+ [t, a, l]
524
+ ), x = t.key || `anonymous-${t.id.split("-").pop()}`;
525
+ return /* @__PURE__ */ i(
526
+ "div",
527
+ {
528
+ style: {
529
+ ...Le(n),
530
+ flexDirection: "column",
531
+ alignItems: "stretch",
532
+ gap: 4
533
+ },
534
+ onClick: o,
535
+ onMouseEnter: (s) => {
536
+ n || (s.currentTarget.style.backgroundColor = "var(--atomirx-bg-hover)");
537
+ },
538
+ onMouseLeave: (s) => {
539
+ n || (s.currentTarget.style.backgroundColor = "transparent");
540
+ },
541
+ children: [
542
+ /* @__PURE__ */ i("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
543
+ /* @__PURE__ */ r("span", { style: Y(t.type), children: t.type === "mutable" ? "M" : t.type === "derived" ? "D" : t.type === "pool" ? "P" : t.type === "effect" ? "E" : "M" }),
544
+ /* @__PURE__ */ r(
545
+ "span",
546
+ {
547
+ style: {
548
+ ...Z,
549
+ ...t.type === "derived" && {
550
+ color: B(t) === "ready" ? "var(--atomirx-success)" : B(t) === "loading" ? "var(--atomirx-warning)" : B(t) === "error" ? "var(--atomirx-error)" : void 0
551
+ }
552
+ },
553
+ title: x,
554
+ children: x
555
+ }
556
+ ),
557
+ /* @__PURE__ */ r(
558
+ "span",
559
+ {
560
+ style: {
561
+ color: "var(--atomirx-text-muted)",
562
+ fontSize: "var(--atomirx-font-size-sm)",
563
+ flexShrink: 0,
564
+ marginLeft: "auto"
565
+ },
566
+ children: A(t.lastUpdatedAt)
567
+ }
568
+ )
569
+ ] }),
570
+ a && m !== "—" && /* @__PURE__ */ r(
571
+ "div",
572
+ {
573
+ style: {
574
+ ...J,
575
+ marginLeft: 30,
576
+ // Align with text after badge
577
+ maxWidth: "none"
578
+ },
579
+ title: m,
580
+ children: m
581
+ }
582
+ )
583
+ ]
584
+ }
585
+ );
586
+ }), $e = I(function({
587
+ entities: t,
588
+ activeTab: n,
589
+ searchText: o,
590
+ atomFilter: a,
591
+ selectedEntityId: l,
592
+ onSelectEntity: d,
593
+ showValues: m
594
+ }) {
595
+ const x = M(() => {
596
+ var D;
597
+ const f = [], g = o.toLowerCase();
598
+ for (const c of t.values()) {
599
+ switch (n) {
600
+ case "atoms":
601
+ if (c.type !== "mutable" && c.type !== "derived" || a === "mutable" && c.type !== "mutable" || a === "derived" && c.type !== "derived") continue;
602
+ break;
603
+ case "effects":
604
+ if (c.type !== "effect") continue;
605
+ break;
606
+ case "pools":
607
+ if (c.type !== "pool") continue;
608
+ break;
609
+ case "modules":
610
+ if (c.type !== "module") continue;
611
+ break;
612
+ }
613
+ if (o) {
614
+ const u = (D = c.key) == null ? void 0 : D.toLowerCase().includes(g), b = c.id.toLowerCase().includes(g);
615
+ if (!u && !b) continue;
616
+ }
617
+ f.push(c);
618
+ }
619
+ return f.sort((c, u) => u.lastUpdatedAt - c.lastUpdatedAt), f;
620
+ }, [t, n, o, a]), s = h(
621
+ (f) => {
622
+ d(l === f ? null : f);
623
+ },
624
+ [l, d]
625
+ );
626
+ return x.length === 0 ? /* @__PURE__ */ r("div", { style: Q, children: o ? `No ${n} matching "${o}"` : `No ${n} registered` }) : /* @__PURE__ */ r("div", { style: G, children: x.map((f) => /* @__PURE__ */ r(
627
+ _e,
628
+ {
629
+ entity: f,
630
+ isSelected: f.id === l,
631
+ onClick: () => s(f.id),
632
+ showValues: m
633
+ },
634
+ f.id
635
+ )) });
636
+ });
637
+ function ee(e) {
638
+ const t = e.instanceRef.deref();
639
+ if (!t)
640
+ return { value: "[disposed]", status: "error" };
641
+ switch (e.type) {
642
+ case "mutable":
643
+ return { value: k(t.get()), status: "ready" };
644
+ case "derived": {
645
+ const o = t.state();
646
+ return o.status === "loading" ? { value: "[loading...]", status: "loading" } : o.status === "error" ? {
647
+ value: k(o.error),
648
+ status: "error"
649
+ } : { value: k(o.value), status: "ready" };
650
+ }
651
+ case "pool": {
652
+ const n = t, o = [];
653
+ return n.forEach((a, l) => {
654
+ o.push({ params: l, value: a });
655
+ }), { value: k(o), status: "ready" };
656
+ }
657
+ case "effect":
658
+ case "module":
659
+ return { value: "[N/A]", status: "ready" };
660
+ default:
661
+ return { value: "[unknown]" };
662
+ }
663
+ }
664
+ function v({
665
+ label: e,
666
+ children: t
667
+ }) {
668
+ return /* @__PURE__ */ i("div", { style: Re, children: [
669
+ /* @__PURE__ */ r("div", { style: Ae, children: e }),
670
+ t
671
+ ] });
672
+ }
673
+ function te({ entry: e }) {
674
+ return /* @__PURE__ */ i("div", { style: Be, children: [
675
+ /* @__PURE__ */ r("div", { style: Pe, children: A(e.timestamp) }),
676
+ /* @__PURE__ */ i("div", { style: { marginTop: 4 }, children: [
677
+ /* @__PURE__ */ r("span", { style: { color: "var(--atomirx-error)" }, children: "- " }),
678
+ /* @__PURE__ */ r("span", { style: { fontFamily: "var(--atomirx-font-mono)" }, children: e.previousValue.length > 100 ? e.previousValue.slice(0, 100) + "..." : e.previousValue })
679
+ ] }),
680
+ /* @__PURE__ */ i("div", { children: [
681
+ /* @__PURE__ */ r("span", { style: { color: "var(--atomirx-success)" }, children: "+ " }),
682
+ /* @__PURE__ */ r("span", { style: { fontFamily: "var(--atomirx-font-mono)" }, children: e.newValue.length > 100 ? e.newValue.slice(0, 100) + "..." : e.newValue })
683
+ ] })
684
+ ] });
685
+ }
686
+ function Ve({ entity: e }) {
687
+ const { value: t, status: n } = M(() => ee(e), [e]);
688
+ return /* @__PURE__ */ i(z, { children: [
689
+ /* @__PURE__ */ i(v, { label: "Current Value", children: [
690
+ /* @__PURE__ */ i("div", { style: { display: "flex", alignItems: "center", marginBottom: 8 }, children: [
691
+ /* @__PURE__ */ r("span", { style: P(n || "ready") }),
692
+ /* @__PURE__ */ r("span", { style: y, children: n })
693
+ ] }),
694
+ /* @__PURE__ */ r("div", { style: T, children: t })
695
+ ] }),
696
+ /* @__PURE__ */ r(v, { label: "Stats", children: /* @__PURE__ */ i("div", { style: y, children: [
697
+ /* @__PURE__ */ i("div", { children: [
698
+ "Changes: ",
699
+ e.changeCount
700
+ ] }),
701
+ /* @__PURE__ */ i("div", { children: [
702
+ "Subscribers: ",
703
+ e.subscriberCount
704
+ ] })
705
+ ] }) }),
706
+ e.history.length > 0 && /* @__PURE__ */ r(v, { label: `History (${e.history.length})`, children: e.history.map((o, a) => /* @__PURE__ */ r(te, { entry: o }, a)) })
707
+ ] });
708
+ }
709
+ function je({ entity: e }) {
710
+ const { value: t, status: n } = M(() => ee(e), [e]);
711
+ return /* @__PURE__ */ i(z, { children: [
712
+ /* @__PURE__ */ i(v, { label: "Current Value", children: [
713
+ /* @__PURE__ */ i("div", { style: { display: "flex", alignItems: "center", marginBottom: 8 }, children: [
714
+ /* @__PURE__ */ r("span", { style: P(n || "ready") }),
715
+ /* @__PURE__ */ r("span", { style: y, children: n })
716
+ ] }),
717
+ /* @__PURE__ */ r("div", { style: T, children: t })
718
+ ] }),
719
+ /* @__PURE__ */ r(v, { label: "Stats", children: /* @__PURE__ */ i("div", { style: y, children: [
720
+ /* @__PURE__ */ i("div", { children: [
721
+ "Changes: ",
722
+ e.changeCount
723
+ ] }),
724
+ /* @__PURE__ */ i("div", { children: [
725
+ "Subscribers: ",
726
+ e.subscriberCount
727
+ ] }),
728
+ /* @__PURE__ */ i("div", { children: [
729
+ "Dependencies: ",
730
+ e.dependencyIds.length || "unknown"
731
+ ] })
732
+ ] }) }),
733
+ e.dependencyIds.length > 0 && /* @__PURE__ */ r(v, { label: "Dependencies", children: /* @__PURE__ */ r("div", { style: T, children: e.dependencyIds.map((o) => /* @__PURE__ */ r("div", { children: o }, o)) }) }),
734
+ e.history.length > 0 && /* @__PURE__ */ r(v, { label: `History (${e.history.length})`, children: e.history.map((o, a) => /* @__PURE__ */ r(te, { entry: o }, a)) })
735
+ ] });
736
+ }
737
+ function He({ entity: e }) {
738
+ return /* @__PURE__ */ i(z, { children: [
739
+ /* @__PURE__ */ r(v, { label: "Status", children: /* @__PURE__ */ r("div", { style: y, children: /* @__PURE__ */ i("div", { style: { display: "flex", alignItems: "center" }, children: [
740
+ /* @__PURE__ */ r("span", { style: P(e.isActive ? "ready" : "error") }),
741
+ e.isActive ? "Active" : "Disposed"
742
+ ] }) }) }),
743
+ /* @__PURE__ */ r(v, { label: "Stats", children: /* @__PURE__ */ i("div", { style: y, children: [
744
+ /* @__PURE__ */ i("div", { children: [
745
+ "Run count: ",
746
+ e.runCount
747
+ ] }),
748
+ /* @__PURE__ */ i("div", { children: [
749
+ "Changes: ",
750
+ e.changeCount
751
+ ] })
752
+ ] }) }),
753
+ e.dependencyIds.length > 0 && /* @__PURE__ */ r(v, { label: "Dependencies", children: /* @__PURE__ */ r("div", { style: T, children: e.dependencyIds.map((t) => /* @__PURE__ */ r("div", { children: t }, t)) }) })
754
+ ] });
755
+ }
756
+ function Ke({ params: e, value: t }) {
757
+ return /* @__PURE__ */ i(
758
+ "div",
759
+ {
760
+ style: {
761
+ padding: "8px",
762
+ borderBottom: "1px solid var(--atomirx-border)"
763
+ },
764
+ children: [
765
+ /* @__PURE__ */ i("div", { style: { marginBottom: 4 }, children: [
766
+ /* @__PURE__ */ r(
767
+ "span",
768
+ {
769
+ style: {
770
+ fontSize: "var(--atomirx-font-size-sm)",
771
+ color: "var(--atomirx-text-secondary)",
772
+ marginRight: 6
773
+ },
774
+ children: "params:"
775
+ }
776
+ ),
777
+ /* @__PURE__ */ r(
778
+ "span",
779
+ {
780
+ style: {
781
+ fontFamily: "var(--atomirx-font-mono)",
782
+ fontSize: "var(--atomirx-font-size)",
783
+ color: "var(--atomirx-info)"
784
+ },
785
+ children: k(e, 100)
786
+ }
787
+ )
788
+ ] }),
789
+ /* @__PURE__ */ i("div", { children: [
790
+ /* @__PURE__ */ r(
791
+ "span",
792
+ {
793
+ style: {
794
+ fontSize: "var(--atomirx-font-size-sm)",
795
+ color: "var(--atomirx-text-secondary)",
796
+ marginRight: 6
797
+ },
798
+ children: "value:"
799
+ }
800
+ ),
801
+ /* @__PURE__ */ r(
802
+ "span",
803
+ {
804
+ style: {
805
+ fontFamily: "var(--atomirx-font-mono)",
806
+ fontSize: "var(--atomirx-font-size)"
807
+ },
808
+ children: k(t, 200)
809
+ }
810
+ )
811
+ ] })
812
+ ]
813
+ }
814
+ );
815
+ }
816
+ function Ue({ entity: e }) {
817
+ const [t, n] = L(0);
818
+ S(() => {
819
+ const a = e.instanceRef.deref();
820
+ return a ? a.on(() => {
821
+ n((d) => d + 1);
822
+ }) : void 0;
823
+ }, [e]);
824
+ const o = M(() => {
825
+ const a = e.instanceRef.deref();
826
+ if (!a) return [];
827
+ const l = a, d = [];
828
+ return l.forEach((m, x) => {
829
+ d.push({ params: x, value: m });
830
+ }), d;
831
+ }, [e, t]);
832
+ return /* @__PURE__ */ i(z, { children: [
833
+ /* @__PURE__ */ r(v, { label: "Config", children: /* @__PURE__ */ i("div", { style: y, children: [
834
+ /* @__PURE__ */ i("div", { children: [
835
+ "Entry count: ",
836
+ o.length
837
+ ] }),
838
+ /* @__PURE__ */ i("div", { children: [
839
+ "GC time: ",
840
+ e.gcTime,
841
+ "ms"
842
+ ] }),
843
+ /* @__PURE__ */ i("div", { children: [
844
+ "Changes: ",
845
+ e.changeCount
846
+ ] })
847
+ ] }) }),
848
+ /* @__PURE__ */ r(v, { label: `Entries (${o.length})`, children: o.length === 0 ? /* @__PURE__ */ r(
849
+ "div",
850
+ {
851
+ style: {
852
+ color: "var(--atomirx-text-muted)",
853
+ fontStyle: "italic",
854
+ padding: 8
855
+ },
856
+ children: "No entries"
857
+ }
858
+ ) : /* @__PURE__ */ r(
859
+ "div",
860
+ {
861
+ style: {
862
+ backgroundColor: "var(--atomirx-bg-tertiary)",
863
+ borderRadius: "var(--atomirx-radius)",
864
+ overflow: "hidden"
865
+ },
866
+ children: o.map((a, l) => /* @__PURE__ */ r(
867
+ Ke,
868
+ {
869
+ params: a.params,
870
+ value: a.value
871
+ },
872
+ l
873
+ ))
874
+ }
875
+ ) })
876
+ ] });
877
+ }
878
+ function Xe({ entity: e }) {
879
+ const t = e.instanceRef.deref(), n = t ? Object.keys(t) : [];
880
+ return /* @__PURE__ */ i(z, { children: [
881
+ /* @__PURE__ */ r(v, { label: "Exports", children: /* @__PURE__ */ r("div", { style: T, children: n.length > 0 ? n.join(", ") : "[empty or disposed]" }) }),
882
+ /* @__PURE__ */ r(v, { label: "Stats", children: /* @__PURE__ */ r("div", { style: y, children: /* @__PURE__ */ i("div", { children: [
883
+ "Changes: ",
884
+ e.changeCount
885
+ ] }) }) })
886
+ ] });
887
+ }
888
+ const Ge = I(function({
889
+ entity: t,
890
+ onClose: n
891
+ }) {
892
+ const o = t.key || `anonymous-${t.id.split("-").pop()}`;
893
+ return /* @__PURE__ */ i("div", { style: Me, children: [
894
+ /* @__PURE__ */ i(
895
+ "div",
896
+ {
897
+ style: {
898
+ ...Te,
899
+ display: "flex",
900
+ alignItems: "center",
901
+ gap: 8,
902
+ flexShrink: 0
903
+ },
904
+ children: [
905
+ /* @__PURE__ */ r("button", { style: q, onClick: n, title: "Back to list", children: "←" }),
906
+ /* @__PURE__ */ r("span", { style: Y(t.type), children: t.type === "mutable" ? "M" : t.type === "derived" ? "D" : t.type === "pool" ? "P" : t.type === "effect" ? "E" : "M" }),
907
+ /* @__PURE__ */ r(
908
+ "span",
909
+ {
910
+ style: {
911
+ flex: 1,
912
+ overflow: "hidden",
913
+ textOverflow: "ellipsis",
914
+ whiteSpace: "nowrap",
915
+ minWidth: 0,
916
+ fontSize: 12
917
+ },
918
+ title: o,
919
+ children: o
920
+ }
921
+ )
922
+ ]
923
+ }
924
+ ),
925
+ /* @__PURE__ */ i("div", { style: { flex: "1 1 0", overflow: "auto", minHeight: 0, height: 0 }, children: [
926
+ /* @__PURE__ */ r(v, { label: "ID", children: /* @__PURE__ */ r(
927
+ "div",
928
+ {
929
+ style: {
930
+ ...y,
931
+ fontSize: "var(--atomirx-font-size-sm)"
932
+ },
933
+ children: t.id
934
+ }
935
+ ) }),
936
+ /* @__PURE__ */ r(v, { label: "Created", children: /* @__PURE__ */ r("div", { style: y, children: A(t.createdAt) }) }),
937
+ t.type === "mutable" && /* @__PURE__ */ r(Ve, { entity: t }),
938
+ t.type === "derived" && /* @__PURE__ */ r(je, { entity: t }),
939
+ t.type === "effect" && /* @__PURE__ */ r(He, { entity: t }),
940
+ t.type === "pool" && /* @__PURE__ */ r(Ue, { entity: t }),
941
+ t.type === "module" && /* @__PURE__ */ r(Xe, { entity: t })
942
+ ] })
943
+ ] });
944
+ }), re = {
945
+ "action.dispatch": { color: "#3b82f6", label: "A" },
946
+ // blue - Action
947
+ error: { color: "#ef4444", label: "E" },
948
+ // red - Error
949
+ "mutable.change": { color: "#10b981", label: "M" },
950
+ // green - Mutable
951
+ "mutable.reset": { color: "#10b981", label: "M" },
952
+ // green - Mutable
953
+ "derived.change": { color: "#8b5cf6", label: "D" },
954
+ // purple - Derived
955
+ "derived.refresh": { color: "#8b5cf6", label: "D" },
956
+ // purple - Derived
957
+ "pool.create": { color: "#f97316", label: "P" },
958
+ // orange - Pool
959
+ "pool.set": { color: "#f97316", label: "P" },
960
+ // orange - Pool
961
+ "pool.remove": { color: "#f97316", label: "P" }
962
+ // orange - Pool
963
+ };
964
+ function Ye(e) {
965
+ return {
966
+ display: "inline-flex",
967
+ alignItems: "center",
968
+ justifyContent: "center",
969
+ width: 22,
970
+ height: 22,
971
+ borderRadius: "var(--atomirx-radius)",
972
+ backgroundColor: (re[e] ?? { color: "#6b7280" }).color,
973
+ color: "white",
974
+ fontSize: "var(--atomirx-font-size-sm)",
975
+ fontWeight: 600,
976
+ flexShrink: 0
977
+ };
978
+ }
979
+ function Ze(e) {
980
+ var t;
981
+ return ((t = re[e]) == null ? void 0 : t.label) ?? "?";
982
+ }
983
+ function oe(e) {
984
+ switch (e.type) {
985
+ case "action.dispatch":
986
+ return e.actionKey;
987
+ case "error":
988
+ return e.sourceKey || e.sourceType;
989
+ case "mutable.change":
990
+ case "mutable.reset":
991
+ case "derived.change":
992
+ case "derived.refresh":
993
+ return e.atomKey;
994
+ case "pool.create":
995
+ case "pool.set":
996
+ case "pool.remove":
997
+ return e.poolKey;
998
+ default:
999
+ return "unknown";
1000
+ }
1001
+ }
1002
+ function ne(e) {
1003
+ switch (e.type) {
1004
+ case "action.dispatch":
1005
+ return "dispatch";
1006
+ case "error":
1007
+ return "error";
1008
+ case "mutable.change":
1009
+ return "change";
1010
+ case "mutable.reset":
1011
+ return "reset";
1012
+ case "derived.change":
1013
+ return "change";
1014
+ case "derived.refresh":
1015
+ return "refresh";
1016
+ case "pool.create":
1017
+ return "create";
1018
+ case "pool.set":
1019
+ return "set";
1020
+ case "pool.remove":
1021
+ return "remove";
1022
+ default:
1023
+ return "";
1024
+ }
1025
+ }
1026
+ function ie(e) {
1027
+ switch (e.type) {
1028
+ case "action.dispatch":
1029
+ return e.deps;
1030
+ case "error":
1031
+ return e.error;
1032
+ case "pool.create":
1033
+ case "pool.set":
1034
+ case "pool.remove":
1035
+ return e.params;
1036
+ case "mutable.change":
1037
+ case "mutable.reset":
1038
+ case "derived.change":
1039
+ case "derived.refresh":
1040
+ return null;
1041
+ default:
1042
+ return null;
1043
+ }
1044
+ }
1045
+ const Je = I(function({
1046
+ log: t,
1047
+ showValues: n
1048
+ }) {
1049
+ const o = t.type === "error", a = ie(t);
1050
+ return /* @__PURE__ */ i(
1051
+ "div",
1052
+ {
1053
+ style: {
1054
+ display: "flex",
1055
+ flexDirection: "column",
1056
+ gap: 4,
1057
+ padding: "8px 12px",
1058
+ borderBottom: "1px solid var(--atomirx-border)",
1059
+ cursor: "default"
1060
+ },
1061
+ children: [
1062
+ /* @__PURE__ */ i("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
1063
+ /* @__PURE__ */ r("span", { style: Ye(t.type), children: Ze(t.type) }),
1064
+ /* @__PURE__ */ r(
1065
+ "span",
1066
+ {
1067
+ style: {
1068
+ ...Z,
1069
+ color: o ? "var(--atomirx-error)" : "var(--atomirx-text-primary)"
1070
+ },
1071
+ children: oe(t)
1072
+ }
1073
+ ),
1074
+ /* @__PURE__ */ r(
1075
+ "span",
1076
+ {
1077
+ style: {
1078
+ color: "var(--atomirx-text-secondary)",
1079
+ fontSize: "var(--atomirx-font-size-sm)"
1080
+ },
1081
+ children: ne(t)
1082
+ }
1083
+ ),
1084
+ /* @__PURE__ */ r(
1085
+ "span",
1086
+ {
1087
+ style: {
1088
+ color: "var(--atomirx-text-muted)",
1089
+ fontSize: "var(--atomirx-font-size-sm)",
1090
+ flexShrink: 0,
1091
+ marginLeft: "auto"
1092
+ },
1093
+ children: A(t.timestamp)
1094
+ }
1095
+ )
1096
+ ] }),
1097
+ n && a && /* @__PURE__ */ r(
1098
+ "div",
1099
+ {
1100
+ style: {
1101
+ ...J,
1102
+ marginLeft: 30,
1103
+ // Align with text after badge
1104
+ maxWidth: "none"
1105
+ },
1106
+ title: a,
1107
+ children: a
1108
+ }
1109
+ )
1110
+ ]
1111
+ }
1112
+ );
1113
+ }), qe = {
1114
+ padding: "4px 8px",
1115
+ fontSize: "var(--atomirx-font-size-sm)",
1116
+ backgroundColor: "var(--atomirx-bg-tertiary)",
1117
+ border: "1px solid var(--atomirx-border)",
1118
+ borderRadius: "var(--atomirx-radius)",
1119
+ color: "var(--atomirx-text-secondary)",
1120
+ cursor: "pointer",
1121
+ display: "flex",
1122
+ alignItems: "center",
1123
+ gap: 4
1124
+ }, Qe = I(function({
1125
+ logs: t,
1126
+ searchText: n,
1127
+ onClearLogs: o,
1128
+ showValues: a = !0
1129
+ }) {
1130
+ const l = M(() => {
1131
+ if (!n) return t;
1132
+ const d = n.toLowerCase();
1133
+ return t.filter((m) => {
1134
+ var g;
1135
+ const x = oe(m).toLowerCase(), s = ne(m).toLowerCase(), f = ((g = ie(m)) == null ? void 0 : g.toLowerCase()) ?? "";
1136
+ return x.includes(d) || s.includes(d) || f.includes(d);
1137
+ });
1138
+ }, [t, n]);
1139
+ return l.length === 0 ? /* @__PURE__ */ r("div", { style: { ...Q, width: "100%" }, children: n ? `No logs matching "${n}"` : "No logs yet. Dispatch actions or trigger errors to see logs." }) : /* @__PURE__ */ i(
1140
+ "div",
1141
+ {
1142
+ style: {
1143
+ display: "flex",
1144
+ flexDirection: "column",
1145
+ height: "100%",
1146
+ width: "100%"
1147
+ },
1148
+ children: [
1149
+ /* @__PURE__ */ i(
1150
+ "div",
1151
+ {
1152
+ style: {
1153
+ display: "flex",
1154
+ justifyContent: "flex-end",
1155
+ alignItems: "center",
1156
+ padding: "6px 12px",
1157
+ borderBottom: "1px solid var(--atomirx-border)",
1158
+ backgroundColor: "var(--atomirx-bg-secondary)",
1159
+ flexShrink: 0
1160
+ },
1161
+ children: [
1162
+ /* @__PURE__ */ i(
1163
+ "span",
1164
+ {
1165
+ style: {
1166
+ fontSize: "var(--atomirx-font-size-sm)",
1167
+ color: "var(--atomirx-text-muted)",
1168
+ marginRight: "auto"
1169
+ },
1170
+ children: [
1171
+ l.length,
1172
+ " log",
1173
+ l.length !== 1 ? "s" : ""
1174
+ ]
1175
+ }
1176
+ ),
1177
+ o && /* @__PURE__ */ i(
1178
+ "button",
1179
+ {
1180
+ style: qe,
1181
+ onClick: o,
1182
+ title: "Clear all logs",
1183
+ children: [
1184
+ /* @__PURE__ */ i(
1185
+ "svg",
1186
+ {
1187
+ width: "14",
1188
+ height: "14",
1189
+ viewBox: "0 0 24 24",
1190
+ fill: "none",
1191
+ stroke: "currentColor",
1192
+ strokeWidth: "2",
1193
+ strokeLinecap: "round",
1194
+ strokeLinejoin: "round",
1195
+ children: [
1196
+ /* @__PURE__ */ r("polyline", { points: "3,6 5,6 21,6" }),
1197
+ /* @__PURE__ */ r("path", { d: "M19,6v14a2,2,0,0,1-2,2H7a2,2,0,0,1-2-2V6m3,0V4a2,2,0,0,1,2-2h4a2,2,0,0,1,2,2v2" })
1198
+ ]
1199
+ }
1200
+ ),
1201
+ "Clear"
1202
+ ]
1203
+ }
1204
+ )
1205
+ ]
1206
+ }
1207
+ ),
1208
+ /* @__PURE__ */ r("div", { style: { ...G, flex: 1 }, children: l.map((d) => /* @__PURE__ */ r(Je, { log: d, showValues: a }, d.id)) })
1209
+ ]
1210
+ }
1211
+ );
1212
+ });
1213
+ function et() {
1214
+ return /* @__PURE__ */ i(
1215
+ "svg",
1216
+ {
1217
+ width: "24",
1218
+ height: "24",
1219
+ viewBox: "0 0 24 24",
1220
+ fill: "none",
1221
+ xmlns: "http://www.w3.org/2000/svg",
1222
+ children: [
1223
+ /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "3", fill: "currentColor" }),
1224
+ /* @__PURE__ */ r(
1225
+ "ellipse",
1226
+ {
1227
+ cx: "12",
1228
+ cy: "12",
1229
+ rx: "10",
1230
+ ry: "4",
1231
+ stroke: "currentColor",
1232
+ strokeWidth: "1.5",
1233
+ fill: "none"
1234
+ }
1235
+ ),
1236
+ /* @__PURE__ */ r(
1237
+ "ellipse",
1238
+ {
1239
+ cx: "12",
1240
+ cy: "12",
1241
+ rx: "10",
1242
+ ry: "4",
1243
+ stroke: "currentColor",
1244
+ strokeWidth: "1.5",
1245
+ fill: "none",
1246
+ transform: "rotate(60 12 12)"
1247
+ }
1248
+ ),
1249
+ /* @__PURE__ */ r(
1250
+ "ellipse",
1251
+ {
1252
+ cx: "12",
1253
+ cy: "12",
1254
+ rx: "10",
1255
+ ry: "4",
1256
+ stroke: "currentColor",
1257
+ strokeWidth: "1.5",
1258
+ fill: "none",
1259
+ transform: "rotate(120 12 12)"
1260
+ }
1261
+ )
1262
+ ]
1263
+ }
1264
+ );
1265
+ }
1266
+ function tt() {
1267
+ return /* @__PURE__ */ i(
1268
+ "svg",
1269
+ {
1270
+ width: "14",
1271
+ height: "14",
1272
+ viewBox: "0 0 24 24",
1273
+ fill: "none",
1274
+ stroke: "currentColor",
1275
+ strokeWidth: "2",
1276
+ strokeLinecap: "round",
1277
+ strokeLinejoin: "round",
1278
+ children: [
1279
+ /* @__PURE__ */ r("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
1280
+ /* @__PURE__ */ r("line", { x1: "9", y1: "3", x2: "9", y2: "21" })
1281
+ ]
1282
+ }
1283
+ );
1284
+ }
1285
+ const rt = [
1286
+ { id: "atoms", label: "Atoms" },
1287
+ { id: "effects", label: "Effects" },
1288
+ { id: "pools", label: "Pools" },
1289
+ { id: "modules", label: "Modules" },
1290
+ { id: "logs", label: "Logs" }
1291
+ ], ot = [
1292
+ { id: "all", label: "A" },
1293
+ { id: "mutable", label: "M" },
1294
+ { id: "derived", label: "D" }
1295
+ ], nt = I(function({
1296
+ defaultPosition: t,
1297
+ defaultOpen: n,
1298
+ autoSetup: o = !0,
1299
+ enableInProduction: a = !1
1300
+ }) {
1301
+ S(() => {
1302
+ if (o)
1303
+ return X({ enableInProduction: a });
1304
+ }, [o, a]);
1305
+ const [l, d] = L(() => _());
1306
+ S(() => {
1307
+ const p = () => {
1308
+ const F = _();
1309
+ F !== l && d(F);
1310
+ };
1311
+ p();
1312
+ const ue = setTimeout(p, 100);
1313
+ return () => clearTimeout(ue);
1314
+ }, [l]);
1315
+ const m = xe(l), x = ve(l), {
1316
+ preferences: s,
1317
+ setIsOpen: f,
1318
+ setActiveTab: g,
1319
+ setPanelSize: D,
1320
+ setSearchText: c,
1321
+ setAtomFilter: u,
1322
+ setSelectedEntityId: b,
1323
+ togglePanel: R,
1324
+ cyclePosition: ae,
1325
+ toggleShowAtomValues: se
1326
+ } = he();
1327
+ S(() => {
1328
+ t && s.position, n !== void 0 && !s.isOpen && n && f(!0);
1329
+ }, []), ge(R);
1330
+ const { handleMouseDown: le } = be(
1331
+ s.position,
1332
+ s.panelSize,
1333
+ D
1334
+ ), W = s.selectedEntityId ? m == null ? void 0 : m.get(s.selectedEntityId) : null, ce = h(
1335
+ (p) => {
1336
+ c(s.activeTab, p.target.value);
1337
+ },
1338
+ [s.activeTab, c]
1339
+ ), de = h(
1340
+ (p) => {
1341
+ g(p), b(null);
1342
+ },
1343
+ [g, b]
1344
+ );
1345
+ return l ? /* @__PURE__ */ i("div", { style: Se, children: [
1346
+ !s.isOpen && /* @__PURE__ */ r(
1347
+ "button",
1348
+ {
1349
+ style: we,
1350
+ onClick: R,
1351
+ title: "Toggle Atomirx DevTools (Ctrl+Shift+D)",
1352
+ onMouseEnter: (p) => {
1353
+ p.currentTarget.style.backgroundColor = "var(--atomirx-accent-hover)";
1354
+ },
1355
+ onMouseLeave: (p) => {
1356
+ p.currentTarget.style.backgroundColor = "var(--atomirx-accent)";
1357
+ },
1358
+ children: /* @__PURE__ */ r(et, {})
1359
+ }
1360
+ ),
1361
+ /* @__PURE__ */ i(
1362
+ "div",
1363
+ {
1364
+ style: ke(
1365
+ s.position,
1366
+ s.panelSize,
1367
+ s.isOpen
1368
+ ),
1369
+ children: [
1370
+ /* @__PURE__ */ r(
1371
+ "div",
1372
+ {
1373
+ style: Fe(s.position),
1374
+ onMouseDown: le
1375
+ }
1376
+ ),
1377
+ /* @__PURE__ */ i(
1378
+ "div",
1379
+ {
1380
+ style: {
1381
+ display: "flex",
1382
+ alignItems: "center",
1383
+ justifyContent: "space-between",
1384
+ padding: "8px 12px",
1385
+ backgroundColor: "var(--atomirx-bg-secondary)",
1386
+ borderBottom: "1px solid var(--atomirx-border)",
1387
+ flexShrink: 0
1388
+ },
1389
+ children: [
1390
+ /* @__PURE__ */ r(
1391
+ "span",
1392
+ {
1393
+ style: { fontWeight: 600, fontSize: "var(--atomirx-font-size)" },
1394
+ children: "Atomirx Devtools"
1395
+ }
1396
+ ),
1397
+ /* @__PURE__ */ i("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
1398
+ /* @__PURE__ */ r(
1399
+ "button",
1400
+ {
1401
+ style: We,
1402
+ onClick: ae,
1403
+ title: `Position: ${s.position} (click to change)`,
1404
+ children: /* @__PURE__ */ r(tt, {})
1405
+ }
1406
+ ),
1407
+ /* @__PURE__ */ r(
1408
+ "button",
1409
+ {
1410
+ style: q,
1411
+ onClick: () => f(!1),
1412
+ title: "Close panel",
1413
+ children: "×"
1414
+ }
1415
+ )
1416
+ ] })
1417
+ ]
1418
+ }
1419
+ ),
1420
+ /* @__PURE__ */ i(
1421
+ "div",
1422
+ {
1423
+ style: {
1424
+ flex: 1,
1425
+ display: "flex",
1426
+ flexDirection: "column",
1427
+ position: "relative",
1428
+ minHeight: 0
1429
+ },
1430
+ children: [
1431
+ /* @__PURE__ */ r("div", { style: Ce, children: rt.map((p) => /* @__PURE__ */ r(
1432
+ "button",
1433
+ {
1434
+ style: ze(s.activeTab === p.id),
1435
+ onClick: () => de(p.id),
1436
+ children: p.label
1437
+ },
1438
+ p.id
1439
+ )) }),
1440
+ /* @__PURE__ */ r(
1441
+ "div",
1442
+ {
1443
+ style: {
1444
+ padding: "8px 12px",
1445
+ borderBottom: "1px solid var(--atomirx-border)"
1446
+ },
1447
+ children: /* @__PURE__ */ r(
1448
+ "input",
1449
+ {
1450
+ type: "text",
1451
+ style: { ...Ie, width: "100%" },
1452
+ placeholder: `Search ${s.activeTab}...`,
1453
+ value: s.searchText[s.activeTab],
1454
+ onChange: ce
1455
+ }
1456
+ )
1457
+ }
1458
+ ),
1459
+ s.activeTab === "atoms" && /* @__PURE__ */ i("div", { style: { ...Ee, justifyContent: "space-between" }, children: [
1460
+ /* @__PURE__ */ r("div", { style: De, children: ot.map((p) => /* @__PURE__ */ r(
1461
+ "button",
1462
+ {
1463
+ style: $(
1464
+ s.atomFilter === p.id
1465
+ ),
1466
+ onClick: () => u(p.id),
1467
+ children: p.label
1468
+ },
1469
+ p.id
1470
+ )) }),
1471
+ /* @__PURE__ */ r(
1472
+ "button",
1473
+ {
1474
+ style: {
1475
+ ...$(s.showAtomValues),
1476
+ display: "inline-flex",
1477
+ alignItems: "center",
1478
+ justifyContent: "center",
1479
+ padding: "4px 8px"
1480
+ },
1481
+ onClick: se,
1482
+ title: s.showAtomValues ? "Hide values (single line)" : "Show values (two lines with data)",
1483
+ children: /* @__PURE__ */ r(
1484
+ "svg",
1485
+ {
1486
+ width: "16",
1487
+ height: "16",
1488
+ viewBox: "0 0 24 24",
1489
+ fill: "none",
1490
+ stroke: "currentColor",
1491
+ strokeWidth: "2",
1492
+ strokeLinecap: "round",
1493
+ strokeLinejoin: "round",
1494
+ children: s.showAtomValues ? /* @__PURE__ */ i(z, { children: [
1495
+ /* @__PURE__ */ r("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
1496
+ /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "3" })
1497
+ ] }) : /* @__PURE__ */ i(z, { children: [
1498
+ /* @__PURE__ */ r("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94" }),
1499
+ /* @__PURE__ */ r("path", { d: "M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19" }),
1500
+ /* @__PURE__ */ r("path", { d: "M1 1l22 22" })
1501
+ ] })
1502
+ }
1503
+ )
1504
+ }
1505
+ )
1506
+ ] }),
1507
+ /* @__PURE__ */ r("div", { style: Ne, children: s.activeTab === "logs" ? /* @__PURE__ */ r(
1508
+ Qe,
1509
+ {
1510
+ logs: x ?? [],
1511
+ searchText: s.searchText.logs,
1512
+ onClearLogs: () => l.clearLogs()
1513
+ }
1514
+ ) : /* @__PURE__ */ r(
1515
+ $e,
1516
+ {
1517
+ entities: m ?? /* @__PURE__ */ new Map(),
1518
+ activeTab: s.activeTab,
1519
+ searchText: s.searchText[s.activeTab],
1520
+ atomFilter: s.atomFilter,
1521
+ selectedEntityId: s.selectedEntityId,
1522
+ onSelectEntity: b,
1523
+ showValues: s.showAtomValues
1524
+ }
1525
+ ) }),
1526
+ W && s.activeTab !== "logs" && /* @__PURE__ */ r(
1527
+ Ge,
1528
+ {
1529
+ entity: W,
1530
+ onClose: () => b(null)
1531
+ }
1532
+ )
1533
+ ]
1534
+ }
1535
+ )
1536
+ ]
1537
+ }
1538
+ )
1539
+ ] }) : null;
1540
+ });
1541
+ let w = null, C = null;
1542
+ function it(e = {}) {
1543
+ return new Promise((t) => {
1544
+ const { containerId: n = "atomirx-devtools-root", ...o } = e;
1545
+ w && (w.unmount(), w = null), C && (C.remove(), C = null), o.autoSetup !== !1 && X({ enableInProduction: o.enableInProduction });
1546
+ const a = document.createElement("div");
1547
+ a.id = n, a.style.position = "fixed", a.style.top = "0", a.style.left = "0", a.style.width = "0", a.style.height = "0", a.style.overflow = "visible", a.style.zIndex = "999999", a.style.pointerEvents = "none", document.body.appendChild(a), C = a, w = e.root ?? me(a), w.render(
1548
+ /* @__PURE__ */ r("div", { style: { pointerEvents: "auto" }, children: /* @__PURE__ */ r(nt, { ...o, autoSetup: !1 }) })
1549
+ ), queueMicrotask(t);
1550
+ });
1551
+ }
1552
+ function at() {
1553
+ w && (w.unmount(), w = null), C && (C.remove(), C = null);
1554
+ }
1555
+ const ut = I(function(t) {
1556
+ const [n, o] = L(!1);
1557
+ return S(() => (it({ ...t, autoSetup: t.autoSetup }), o(!0), () => {
1558
+ at();
1559
+ }), []), null;
1560
+ });
1561
+ export {
1562
+ E as ANIMATION_DURATION,
1563
+ pt as DEFAULT_MAX_HISTORY_SIZE,
1564
+ ht as DEFAULT_PANEL_SIZE,
1565
+ N as DEFAULT_PREFERENCES,
1566
+ U as DEVTOOLS_Z_INDEX,
1567
+ ut as DevToolsPanel,
1568
+ xt as ENTITY_ID_PREFIX,
1569
+ O as FLOATING_BUTTON_SIZE,
1570
+ K as MAX_PANEL_SIZE,
1571
+ H as MIN_PANEL_SIZE,
1572
+ j as STORAGE_KEY_PREFERENCES,
1573
+ vt as STORAGE_VERSION,
1574
+ gt as _resetDevtools,
1575
+ A as formatTimestamp,
1576
+ _ as getDevtoolsRegistry,
1577
+ bt as getRegistry,
1578
+ yt as isDevtoolsEnabled,
1579
+ it as renderDevtools,
1580
+ St as resetRegistry,
1581
+ k as serializeValue,
1582
+ X as setupDevtools,
1583
+ at as unmountDevtools,
1584
+ ve as useDevtoolsLogs,
1585
+ he as useDevtoolsPreferences,
1586
+ xe as useDevtoolsRegistry,
1587
+ ge as useKeyboardShortcuts,
1588
+ be as usePanelResize
1589
+ };