@buoy-gg/zustand 7.0.41 → 7.0.42

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 (63) hide show
  1. package/README.md +11 -76
  2. package/lib/commonjs/index.js +1 -105
  3. package/lib/commonjs/preset.js +1 -102
  4. package/lib/commonjs/zustand/components/ZustandActionButton.js +1 -118
  5. package/lib/commonjs/zustand/components/ZustandDetailViewToggle.js +1 -48
  6. package/lib/commonjs/zustand/components/ZustandEventFilterView.js +1 -43
  7. package/lib/commonjs/zustand/components/ZustandIcon.js +1 -18
  8. package/lib/commonjs/zustand/components/ZustandModal.js +1 -772
  9. package/lib/commonjs/zustand/components/ZustandStateChangeItem.js +1 -117
  10. package/lib/commonjs/zustand/components/ZustandStateDetailContent.js +1 -372
  11. package/lib/commonjs/zustand/components/ZustandStateInfoView.js +1 -488
  12. package/lib/commonjs/zustand/components/ZustandStoreBrowser.js +1 -204
  13. package/lib/commonjs/zustand/components/ZustandStoreDetailContent.js +1 -471
  14. package/lib/commonjs/zustand/hooks/useZustandStateChanges.js +1 -74
  15. package/lib/commonjs/zustand/sync/zustandSyncAdapter.js +1 -418
  16. package/lib/commonjs/zustand/types/index.js +1 -1
  17. package/lib/commonjs/zustand/utils/buoyZustandMiddleware.js +1 -284
  18. package/lib/commonjs/zustand/utils/editableState.js +1 -146
  19. package/lib/commonjs/zustand/utils/snapshotProvider.js +1 -209
  20. package/lib/commonjs/zustand/utils/testIDs.js +1 -82
  21. package/lib/commonjs/zustand/utils/zustandStateStore.js +1 -379
  22. package/lib/module/index.js +1 -90
  23. package/lib/module/preset.js +1 -98
  24. package/lib/module/zustand/components/ZustandActionButton.js +1 -114
  25. package/lib/module/zustand/components/ZustandDetailViewToggle.js +1 -43
  26. package/lib/module/zustand/components/ZustandEventFilterView.js +1 -39
  27. package/lib/module/zustand/components/ZustandIcon.js +1 -11
  28. package/lib/module/zustand/components/ZustandModal.js +1 -767
  29. package/lib/module/zustand/components/ZustandStateChangeItem.js +1 -113
  30. package/lib/module/zustand/components/ZustandStateDetailContent.js +1 -368
  31. package/lib/module/zustand/components/ZustandStateInfoView.js +1 -483
  32. package/lib/module/zustand/components/ZustandStoreBrowser.js +1 -200
  33. package/lib/module/zustand/components/ZustandStoreDetailContent.js +1 -469
  34. package/lib/module/zustand/hooks/useZustandStateChanges.js +1 -70
  35. package/lib/module/zustand/sync/zustandSyncAdapter.js +1 -415
  36. package/lib/module/zustand/types/index.js +1 -1
  37. package/lib/module/zustand/utils/buoyZustandMiddleware.js +1 -278
  38. package/lib/module/zustand/utils/editableState.js +1 -138
  39. package/lib/module/zustand/utils/snapshotProvider.js +1 -209
  40. package/lib/module/zustand/utils/testIDs.js +1 -74
  41. package/lib/module/zustand/utils/zustandStateStore.js +1 -375
  42. package/lib/web/index.mjs +2 -3
  43. package/package.json +3 -3
  44. package/lib/typescript/index.d.ts.map +0 -1
  45. package/lib/typescript/preset.d.ts.map +0 -1
  46. package/lib/typescript/zustand/components/ZustandActionButton.d.ts.map +0 -1
  47. package/lib/typescript/zustand/components/ZustandDetailViewToggle.d.ts.map +0 -1
  48. package/lib/typescript/zustand/components/ZustandEventFilterView.d.ts.map +0 -1
  49. package/lib/typescript/zustand/components/ZustandIcon.d.ts.map +0 -1
  50. package/lib/typescript/zustand/components/ZustandModal.d.ts.map +0 -1
  51. package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts.map +0 -1
  52. package/lib/typescript/zustand/components/ZustandStateDetailContent.d.ts.map +0 -1
  53. package/lib/typescript/zustand/components/ZustandStateInfoView.d.ts.map +0 -1
  54. package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts.map +0 -1
  55. package/lib/typescript/zustand/components/ZustandStoreDetailContent.d.ts.map +0 -1
  56. package/lib/typescript/zustand/hooks/useZustandStateChanges.d.ts.map +0 -1
  57. package/lib/typescript/zustand/sync/zustandSyncAdapter.d.ts.map +0 -1
  58. package/lib/typescript/zustand/types/index.d.ts.map +0 -1
  59. package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts.map +0 -1
  60. package/lib/typescript/zustand/utils/editableState.d.ts.map +0 -1
  61. package/lib/typescript/zustand/utils/snapshotProvider.d.ts.map +0 -1
  62. package/lib/typescript/zustand/utils/testIDs.d.ts.map +0 -1
  63. package/lib/typescript/zustand/utils/zustandStateStore.d.ts.map +0 -1
@@ -1,483 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * ZustandStateInfoView
5
- *
6
- * Displays comprehensive state change information including:
7
- * - Change metadata (store, category, duration)
8
- * - Partial data passed to setState
9
- * - Changed keys list
10
- *
11
- * Mirrors ReduxActionInfoView.tsx
12
- */
13
-
14
- import React, { memo, useCallback, useState, useEffect } from "react";
15
- import { View, Text, StyleSheet, ScrollView } from "react-native";
16
- import { buoyColors, night, Clock, AlertTriangle, Zap, Info, Box, Database, parseValue, ProUpgradeModal, copyToClipboard, InfoRow, monoFont } from "@buoy-gg/shared-ui";
17
- import { useIsPro } from "@buoy-gg/license";
18
- import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
19
- import { ZustandActionButton } from "./ZustandActionButton";
20
- import { zustandStateStore } from "../utils/zustandStateStore";
21
- import { ZUSTAND_TEST_ID } from "../utils/testIDs";
22
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
- function getCategoryInfo(category) {
24
- switch (category) {
25
- case "replace":
26
- return {
27
- label: "REPLACE",
28
- color: buoyColors.warning,
29
- bgColor: buoyColors.warning + "26"
30
- };
31
- case "persist":
32
- return {
33
- label: "PERSIST",
34
- color: buoyColors.info,
35
- bgColor: buoyColors.info + "26"
36
- };
37
- case "initial":
38
- return {
39
- label: "INITIAL",
40
- color: night.color.textTertiary,
41
- bgColor: night.color.textTertiary + "26"
42
- };
43
- default:
44
- return {
45
- label: "SET STATE",
46
- color: buoyColors.success,
47
- bgColor: buoyColors.success + "26"
48
- };
49
- }
50
- }
51
- function formatDuration(duration) {
52
- if (duration === undefined) return "N/A";
53
- if (duration < 1) return "<1ms";
54
- return `${duration.toFixed(1)}ms`;
55
- }
56
- function SectionHeader({
57
- icon: Icon,
58
- title,
59
- badge,
60
- testID
61
- }) {
62
- return /*#__PURE__*/_jsxs(View, {
63
- style: styles.sectionHeader,
64
- testID: testID,
65
- children: [/*#__PURE__*/_jsxs(View, {
66
- style: styles.sectionHeaderLeft,
67
- children: [/*#__PURE__*/_jsx(Icon, {
68
- size: 14,
69
- color: night.color.accent
70
- }), /*#__PURE__*/_jsx(Text, {
71
- style: styles.sectionTitle,
72
- children: title
73
- })]
74
- }), badge]
75
- });
76
- }
77
- function formatTime(timestamp) {
78
- const date = new Date(timestamp);
79
- const hours = date.getHours().toString().padStart(2, "0");
80
- const minutes = date.getMinutes().toString().padStart(2, "0");
81
- const seconds = date.getSeconds().toString().padStart(2, "0");
82
- const ms = date.getMilliseconds().toString().padStart(3, "0");
83
- return `${hours}:${minutes}:${seconds}.${ms}`;
84
- }
85
- export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoView({
86
- change
87
- }) {
88
- const isPro = useIsPro();
89
- const [showProModal, setShowProModal] = useState(false);
90
- useEffect(() => {
91
- if (showProModal && isPro) {
92
- setShowProModal(false);
93
- }
94
- }, [showProModal, isPro]);
95
- const categoryInfo = getCategoryInfo(change.category);
96
- const hasPartial = change.partial !== undefined && change.partial !== "(updater fn)";
97
- const hasChangedKeys = change.changedKeys.length > 0;
98
- const storeColor = zustandStateStore.getStoreColor(change.storeName);
99
- const handleCopyState = useCallback(async () => {
100
- if (!isPro) {
101
- setShowProModal(true);
102
- return;
103
- }
104
- await copyToClipboard(change.nextState);
105
- }, [change.nextState, isPro]);
106
- const handleResetStore = useCallback(() => {
107
- const storeInfo = zustandStateStore.getStore(change.storeName);
108
- if (storeInfo?.api.getInitialState) {
109
- const initialState = storeInfo.api.getInitialState();
110
- storeInfo.api.setState(initialState, true);
111
- }
112
- }, [change.storeName]);
113
- const handleJumpToState = useCallback(() => {
114
- const storeInfo = zustandStateStore.getStore(change.storeName);
115
- if (storeInfo) {
116
- storeInfo.api.setState(change.nextState, true);
117
- }
118
- }, [change.storeName, change.nextState]);
119
- return /*#__PURE__*/_jsxs(ScrollView, {
120
- style: styles.container,
121
- contentContainerStyle: styles.contentContainer,
122
- showsVerticalScrollIndicator: false,
123
- testID: `${ZUSTAND_TEST_ID}-detail-scroll`,
124
- children: [/*#__PURE__*/_jsxs(View, {
125
- style: styles.card,
126
- testID: `${ZUSTAND_TEST_ID}-info-card`,
127
- children: [/*#__PURE__*/_jsx(SectionHeader, {
128
- icon: Info,
129
- title: "CHANGE INFO"
130
- }), /*#__PURE__*/_jsxs(View, {
131
- style: styles.cardContent,
132
- children: [/*#__PURE__*/_jsx(InfoRow, {
133
- label: "Store",
134
- value: change.storeName,
135
- mono: true,
136
- valueColor: storeColor,
137
- testID: `${ZUSTAND_TEST_ID}-info-store`
138
- }), /*#__PURE__*/_jsx(InfoRow, {
139
- label: "Time",
140
- value: formatTime(change.timestamp),
141
- mono: true,
142
- testID: `${ZUSTAND_TEST_ID}-info-time`
143
- }), /*#__PURE__*/_jsxs(View, {
144
- style: styles.badgeRow,
145
- children: [/*#__PURE__*/_jsx(View, {
146
- style: [styles.categoryBadge, {
147
- backgroundColor: categoryInfo.bgColor
148
- }],
149
- children: /*#__PURE__*/_jsx(Text, {
150
- style: [styles.categoryText, {
151
- color: categoryInfo.color
152
- }],
153
- testID: `${ZUSTAND_TEST_ID}-info-category`,
154
- children: categoryInfo.label
155
- })
156
- }), /*#__PURE__*/_jsxs(View, {
157
- style: [styles.durationBadge, change.isSlowUpdate && styles.durationBadgeSlow],
158
- children: [/*#__PURE__*/_jsx(Clock, {
159
- size: 10,
160
- color: change.isSlowUpdate ? buoyColors.error : night.color.textSecondary
161
- }), /*#__PURE__*/_jsx(Text, {
162
- style: [styles.durationText, change.isSlowUpdate && styles.durationTextSlow],
163
- testID: `${ZUSTAND_TEST_ID}-info-duration`,
164
- children: formatDuration(change.duration)
165
- }), change.isSlowUpdate && /*#__PURE__*/_jsx(AlertTriangle, {
166
- size: 10,
167
- color: buoyColors.error
168
- })]
169
- }), change.hasStateChange ? /*#__PURE__*/_jsxs(View, {
170
- style: styles.changesBadge,
171
- children: [/*#__PURE__*/_jsx(Zap, {
172
- size: 10,
173
- color: buoyColors.success
174
- }), /*#__PURE__*/_jsx(Text, {
175
- style: styles.changesText,
176
- testID: `${ZUSTAND_TEST_ID}-info-changes`,
177
- children: change.diffSummary || "changed"
178
- })]
179
- }) : /*#__PURE__*/_jsx(View, {
180
- style: styles.noChangesBadge,
181
- children: /*#__PURE__*/_jsx(Text, {
182
- style: styles.noChangesText,
183
- testID: `${ZUSTAND_TEST_ID}-info-no-changes`,
184
- children: "no change"
185
- })
186
- }), change.isPersisted && /*#__PURE__*/_jsxs(View, {
187
- style: styles.persistBadge,
188
- children: [/*#__PURE__*/_jsx(Database, {
189
- size: 10,
190
- color: buoyColors.info
191
- }), /*#__PURE__*/_jsx(Text, {
192
- style: styles.persistText,
193
- testID: `${ZUSTAND_TEST_ID}-info-persisted`,
194
- children: "PERSISTED"
195
- })]
196
- })]
197
- })]
198
- })]
199
- }), hasChangedKeys && /*#__PURE__*/_jsxs(View, {
200
- style: styles.card,
201
- testID: `${ZUSTAND_TEST_ID}-keys-card`,
202
- children: [/*#__PURE__*/_jsx(SectionHeader, {
203
- icon: Zap,
204
- title: "CHANGED KEYS",
205
- badge: /*#__PURE__*/_jsx(View, {
206
- style: styles.countBadge,
207
- children: /*#__PURE__*/_jsx(Text, {
208
- style: styles.countText,
209
- testID: `${ZUSTAND_TEST_ID}-keys-count`,
210
- children: change.changedKeys.length
211
- })
212
- })
213
- }), /*#__PURE__*/_jsx(View, {
214
- style: styles.cardContent,
215
- children: /*#__PURE__*/_jsx(View, {
216
- style: styles.keysContainer,
217
- children: change.changedKeys.map(key => /*#__PURE__*/_jsx(View, {
218
- style: styles.keyBadge,
219
- children: /*#__PURE__*/_jsx(Text, {
220
- style: styles.keyText,
221
- testID: `${ZUSTAND_TEST_ID}-key-${key}`,
222
- children: key
223
- })
224
- }, key))
225
- })
226
- })]
227
- }), hasPartial && /*#__PURE__*/_jsxs(View, {
228
- style: styles.card,
229
- testID: `${ZUSTAND_TEST_ID}-partial-card`,
230
- children: [/*#__PURE__*/_jsx(SectionHeader, {
231
- icon: Box,
232
- title: "PARTIAL (setState argument)",
233
- badge: /*#__PURE__*/_jsx(View, {
234
- style: styles.typeBadge,
235
- children: /*#__PURE__*/_jsx(Text, {
236
- style: styles.typeText,
237
- testID: `${ZUSTAND_TEST_ID}-partial-type`,
238
- children: Array.isArray(change.partial) ? "ARRAY" : typeof change.partial === "object" ? "OBJECT" : String(typeof change.partial).toUpperCase()
239
- })
240
- })
241
- }), /*#__PURE__*/_jsx(View, {
242
- style: styles.dataViewerContainer,
243
- children: /*#__PURE__*/_jsx(DataViewer, {
244
- title: "",
245
- data: parseValue(change.partial),
246
- showTypeFilter: true,
247
- rawMode: true,
248
- initialExpanded: true
249
- })
250
- })]
251
- }), change.partial === "(updater fn)" && /*#__PURE__*/_jsxs(View, {
252
- style: styles.card,
253
- testID: `${ZUSTAND_TEST_ID}-updater-card`,
254
- children: [/*#__PURE__*/_jsx(SectionHeader, {
255
- icon: Box,
256
- title: "SET STATE CALL"
257
- }), /*#__PURE__*/_jsxs(View, {
258
- style: styles.cardContent,
259
- children: [/*#__PURE__*/_jsx(Text, {
260
- style: styles.updaterText,
261
- children: "Called with an updater function: set((state) => ...)"
262
- }), /*#__PURE__*/_jsx(Text, {
263
- style: styles.updaterSubtext,
264
- children: "The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."
265
- })]
266
- })]
267
- }), /*#__PURE__*/_jsxs(View, {
268
- style: styles.actionsGrid,
269
- children: [/*#__PURE__*/_jsx(ZustandActionButton, {
270
- type: "jump",
271
- text: "JUMP",
272
- onPress: handleJumpToState,
273
- testID: `${ZUSTAND_TEST_ID}-jump`
274
- }), /*#__PURE__*/_jsx(ZustandActionButton, {
275
- type: "reset",
276
- text: "RESET STORE",
277
- onPress: handleResetStore,
278
- testID: `${ZUSTAND_TEST_ID}-reset`
279
- }), /*#__PURE__*/_jsx(ZustandActionButton, {
280
- type: "copy",
281
- text: "COPY STATE",
282
- onPress: handleCopyState,
283
- testID: `${ZUSTAND_TEST_ID}-copy-state`
284
- })]
285
- }), /*#__PURE__*/_jsx(ProUpgradeModal, {
286
- visible: showProModal,
287
- onClose: () => setShowProModal(false),
288
- featureName: "Copy"
289
- })]
290
- });
291
- });
292
- const styles = StyleSheet.create({
293
- container: {
294
- flex: 1
295
- },
296
- contentContainer: {
297
- padding: 8,
298
- paddingBottom: 100,
299
- gap: 16
300
- },
301
- card: {
302
- backgroundColor: night.color.surface,
303
- borderRadius: 6,
304
- borderWidth: 1,
305
- borderColor: night.color.accentBorderStrong,
306
- overflow: "hidden",
307
- shadowColor: night.color.accent,
308
- shadowOffset: {
309
- width: 0,
310
- height: 0
311
- },
312
- shadowOpacity: 0.1,
313
- shadowRadius: 6
314
- },
315
- sectionHeader: {
316
- flexDirection: "row",
317
- alignItems: "center",
318
- justifyContent: "space-between",
319
- paddingHorizontal: 12,
320
- paddingVertical: 10,
321
- borderBottomWidth: 1,
322
- borderBottomColor: night.color.accentBorder,
323
- backgroundColor: night.color.accentSoft
324
- },
325
- sectionHeaderLeft: {
326
- flexDirection: "row",
327
- alignItems: "center",
328
- gap: 6
329
- },
330
- sectionTitle: {
331
- fontSize: 12,
332
- fontWeight: "600",
333
- letterSpacing: 0.5,
334
- color: night.color.accent,
335
- fontFamily: monoFont
336
- },
337
- cardContent: {
338
- padding: 14,
339
- gap: 10
340
- },
341
- badgeRow: {
342
- flexDirection: "row",
343
- flexWrap: "wrap",
344
- gap: 8,
345
- marginTop: 6
346
- },
347
- categoryBadge: {
348
- paddingHorizontal: 8,
349
- paddingVertical: 3,
350
- borderRadius: 4
351
- },
352
- categoryText: {
353
- fontSize: 9,
354
- fontWeight: "700",
355
- letterSpacing: 0.3
356
- },
357
- durationBadge: {
358
- flexDirection: "row",
359
- alignItems: "center",
360
- gap: 4,
361
- paddingHorizontal: 8,
362
- paddingVertical: 3,
363
- borderRadius: 4,
364
- backgroundColor: night.color.surfaceElevated
365
- },
366
- durationBadgeSlow: {
367
- backgroundColor: buoyColors.error + "26"
368
- },
369
- durationText: {
370
- fontSize: 9,
371
- fontWeight: "600",
372
- color: night.color.textSecondary,
373
- fontFamily: monoFont
374
- },
375
- durationTextSlow: {
376
- color: buoyColors.error
377
- },
378
- changesBadge: {
379
- flexDirection: "row",
380
- alignItems: "center",
381
- gap: 4,
382
- paddingHorizontal: 8,
383
- paddingVertical: 3,
384
- borderRadius: 4,
385
- backgroundColor: buoyColors.success + "26"
386
- },
387
- changesText: {
388
- fontSize: 9,
389
- fontWeight: "600",
390
- color: buoyColors.success
391
- },
392
- noChangesBadge: {
393
- paddingHorizontal: 8,
394
- paddingVertical: 3,
395
- borderRadius: 4,
396
- backgroundColor: night.color.surfaceElevated
397
- },
398
- noChangesText: {
399
- fontSize: 9,
400
- fontWeight: "600",
401
- color: night.color.textTertiary
402
- },
403
- persistBadge: {
404
- flexDirection: "row",
405
- alignItems: "center",
406
- gap: 4,
407
- paddingHorizontal: 8,
408
- paddingVertical: 3,
409
- borderRadius: 4,
410
- backgroundColor: buoyColors.info + "26"
411
- },
412
- persistText: {
413
- fontSize: 9,
414
- fontWeight: "700",
415
- color: buoyColors.info,
416
- letterSpacing: 0.3
417
- },
418
- keysContainer: {
419
- flexDirection: "row",
420
- flexWrap: "wrap",
421
- gap: 6
422
- },
423
- keyBadge: {
424
- paddingHorizontal: 8,
425
- paddingVertical: 4,
426
- borderRadius: 4,
427
- backgroundColor: night.color.accentSoft,
428
- borderWidth: 1,
429
- borderColor: night.color.accentBorder
430
- },
431
- keyText: {
432
- fontSize: 11,
433
- fontWeight: "600",
434
- color: night.color.accent,
435
- fontFamily: monoFont
436
- },
437
- countBadge: {
438
- paddingHorizontal: 8,
439
- paddingVertical: 3,
440
- borderRadius: 4,
441
- backgroundColor: night.color.accentFill
442
- },
443
- countText: {
444
- fontSize: 9,
445
- fontWeight: "700",
446
- color: night.color.accent,
447
- fontFamily: monoFont
448
- },
449
- typeBadge: {
450
- paddingHorizontal: 6,
451
- paddingVertical: 2,
452
- borderRadius: 3,
453
- backgroundColor: night.color.surfaceElevated
454
- },
455
- typeText: {
456
- fontSize: 8,
457
- fontWeight: "600",
458
- color: night.color.textTertiary,
459
- fontFamily: monoFont
460
- },
461
- dataViewerContainer: {
462
- // Inset display panel — darker than the card, the night track color.
463
- backgroundColor: night.color.bg,
464
- minHeight: 60
465
- },
466
- updaterText: {
467
- fontSize: 12,
468
- color: night.color.text,
469
- fontFamily: monoFont
470
- },
471
- updaterSubtext: {
472
- fontSize: 11,
473
- color: night.color.textTertiary,
474
- lineHeight: 16,
475
- marginTop: 4
476
- },
477
- actionsGrid: {
478
- flexDirection: "row",
479
- flexWrap: "wrap",
480
- gap: 12,
481
- justifyContent: "flex-start"
482
- }
483
- });
1
+ "use strict";import _,{memo as R,useCallback as m,useState as k,useEffect as H}from"react";import{View as a,Text as s,StyleSheet as A,ScrollView as V}from"react-native";import{buoyColors as i,night as r,Clock as P,AlertTriangle as W,Zap as C,Info as F,Box as T,Database as N,parseValue as v,ProUpgradeModal as j,copyToClipboard as U,InfoRow as b,monoFont as g}from"@buoy-gg/shared-ui";import{useIsPro as L}from"@buoy-gg/license";import{DataViewer as M}from"@buoy-gg/shared-ui/dataViewer";import{ZustandActionButton as h}from"./ZustandActionButton";import{zustandStateStore as x}from"../utils/zustandStateStore";import{ZUSTAND_TEST_ID as n}from"../utils/testIDs";import{jsx as o,jsxs as l}from"react/jsx-runtime";function O(d){switch(d){case"replace":return{label:"REPLACE",color:i.warning,bgColor:i.warning+"26"};case"persist":return{label:"PERSIST",color:i.info,bgColor:i.info+"26"};case"initial":return{label:"INITIAL",color:r.color.textTertiary,bgColor:r.color.textTertiary+"26"};default:return{label:"SET STATE",color:i.success,bgColor:i.success+"26"}}}function K(d){if(d===void 0)return"N/A";if(d<1)return"<1ms";return`${d.toFixed(1)}ms`}function S({icon:d,title:t,badge:p,testID:u}){return l(a,{style:e.sectionHeader,testID:u,children:[l(a,{style:e.sectionHeaderLeft,children:[o(d,{size:14,color:r.color.accent}),o(s,{style:e.sectionTitle,children:t})]}),p]})}function Z(d){const t=new Date(d);const p=t.getHours().toString().padStart(2,"0");const u=t.getMinutes().toString().padStart(2,"0");const f=t.getSeconds().toString().padStart(2,"0");const y=t.getMilliseconds().toString().padStart(3,"0");return`${p}:${u}:${f}.${y}`}export const ZustandStateInfoView=R(function d({change:t}){const p=L();const[u,f]=k(false);H(()=>{if(u&&p){f(false)}},[u,p]);const y=O(t.category);const w=t.partial!==void 0&&t.partial!=="(updater fn)";const I=t.changedKeys.length>0;const D=x.getStoreColor(t.storeName);const B=m(async()=>{if(!p){f(true);return}await U(t.nextState)},[t.nextState,p]);const z=m(()=>{const c=x.getStore(t.storeName);if(c?.api.getInitialState){const E=c.api.getInitialState();c.api.setState(E,true)}},[t.storeName]);const $=m(()=>{const c=x.getStore(t.storeName);if(c){c.api.setState(t.nextState,true)}},[t.storeName,t.nextState]);return l(V,{style:e.container,contentContainerStyle:e.contentContainer,showsVerticalScrollIndicator:false,testID:`${n}-detail-scroll`,children:[l(a,{style:e.card,testID:`${n}-info-card`,children:[o(S,{icon:F,title:"CHANGE INFO"}),l(a,{style:e.cardContent,children:[o(b,{label:"Store",value:t.storeName,mono:true,valueColor:D,testID:`${n}-info-store`}),o(b,{label:"Time",value:Z(t.timestamp),mono:true,testID:`${n}-info-time`}),l(a,{style:e.badgeRow,children:[o(a,{style:[e.categoryBadge,{backgroundColor:y.bgColor}],children:o(s,{style:[e.categoryText,{color:y.color}],testID:`${n}-info-category`,children:y.label})}),l(a,{style:[e.durationBadge,t.isSlowUpdate&&e.durationBadgeSlow],children:[o(P,{size:10,color:t.isSlowUpdate?i.error:r.color.textSecondary}),o(s,{style:[e.durationText,t.isSlowUpdate&&e.durationTextSlow],testID:`${n}-info-duration`,children:K(t.duration)}),t.isSlowUpdate&&o(W,{size:10,color:i.error})]}),t.hasStateChange?l(a,{style:e.changesBadge,children:[o(C,{size:10,color:i.success}),o(s,{style:e.changesText,testID:`${n}-info-changes`,children:t.diffSummary||"changed"})]}):o(a,{style:e.noChangesBadge,children:o(s,{style:e.noChangesText,testID:`${n}-info-no-changes`,children:"no change"})}),t.isPersisted&&l(a,{style:e.persistBadge,children:[o(N,{size:10,color:i.info}),o(s,{style:e.persistText,testID:`${n}-info-persisted`,children:"PERSISTED"})]})]})]})]}),I&&l(a,{style:e.card,testID:`${n}-keys-card`,children:[o(S,{icon:C,title:"CHANGED KEYS",badge:o(a,{style:e.countBadge,children:o(s,{style:e.countText,testID:`${n}-keys-count`,children:t.changedKeys.length})})}),o(a,{style:e.cardContent,children:o(a,{style:e.keysContainer,children:t.changedKeys.map(c=>o(a,{style:e.keyBadge,children:o(s,{style:e.keyText,testID:`${n}-key-${c}`,children:c})},c))})})]}),w&&l(a,{style:e.card,testID:`${n}-partial-card`,children:[o(S,{icon:T,title:"PARTIAL (setState argument)",badge:o(a,{style:e.typeBadge,children:o(s,{style:e.typeText,testID:`${n}-partial-type`,children:Array.isArray(t.partial)?"ARRAY":typeof t.partial==="object"?"OBJECT":String(typeof t.partial).toUpperCase()})})}),o(a,{style:e.dataViewerContainer,children:o(M,{title:"",data:v(t.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),t.partial==="(updater fn)"&&l(a,{style:e.card,testID:`${n}-updater-card`,children:[o(S,{icon:T,title:"SET STATE CALL"}),l(a,{style:e.cardContent,children:[o(s,{style:e.updaterText,children:"Called with an updater function: set((state) => ...)"}),o(s,{style:e.updaterSubtext,children:"The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."})]})]}),l(a,{style:e.actionsGrid,children:[o(h,{type:"jump",text:"JUMP",onPress:$,testID:`${n}-jump`}),o(h,{type:"reset",text:"RESET STORE",onPress:z,testID:`${n}-reset`}),o(h,{type:"copy",text:"COPY STATE",onPress:B,testID:`${n}-copy-state`})]}),o(j,{visible:u,onClose:()=>f(false),featureName:"Copy"})]})});const e=A.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:r.color.surface,borderRadius:6,borderWidth:1,borderColor:r.color.accentBorderStrong,overflow:"hidden",shadowColor:r.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:r.color.accentBorder,backgroundColor:r.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:r.color.accent,fontFamily:g},cardContent:{padding:14,gap:10},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},durationBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:r.color.surfaceElevated},durationBadgeSlow:{backgroundColor:i.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:r.color.textSecondary,fontFamily:g},durationTextSlow:{color:i.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:i.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:i.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:r.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:r.color.textTertiary},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:i.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:i.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:r.color.accentSoft,borderWidth:1,borderColor:r.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:r.color.accent,fontFamily:g},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:r.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:r.color.accent,fontFamily:g},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:r.color.surfaceElevated},typeText:{fontSize:8,fontWeight:"600",color:r.color.textTertiary,fontFamily:g},dataViewerContainer:{backgroundColor:r.color.bg,minHeight:60},updaterText:{fontSize:12,color:r.color.text,fontFamily:g},updaterSubtext:{fontSize:11,color:r.color.textTertiary,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});