@buoy-gg/zustand 7.0.73 → 7.0.75
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.
- package/lib/commonjs/zustand/sync/zustandSyncAdapter.js +1 -1
- package/lib/commonjs/zustand/utils/buoyZustandMiddleware.js +1 -1
- package/lib/commonjs/zustand/utils/zustandStateStore.js +1 -1
- package/lib/module/zustand/sync/zustandSyncAdapter.js +1 -1
- package/lib/module/zustand/utils/buoyZustandMiddleware.js +1 -1
- package/lib/module/zustand/utils/zustandStateStore.js +1 -1
- package/lib/typescript/zustand/sync/zustandSyncAdapter.d.ts +5 -2
- package/lib/typescript/zustand/types/index.d.ts +4 -0
- package/lib/typescript/zustand/utils/zustandStateStore.d.ts +1 -0
- package/lib/web/index.mjs +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.zustandSyncAdapter=exports.STATE_ON_DEVICE=exports.PAYLOAD_ON_DEVICE=void 0;var _sharedUi=require("@buoy-gg/shared-ui");var _zustandStateStore=require("../utils/zustandStateStore");const isPlainRecord=e=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype;function deepMergeInto(e,r){if(!isPlainRecord(e)||!isPlainRecord(r))return r;const t={...e};for(const[
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.zustandSyncAdapter=exports.STATE_ON_DEVICE=exports.PAYLOAD_ON_DEVICE=void 0;var _sharedUi=require("@buoy-gg/shared-ui");var _zustandStateStore=require("../utils/zustandStateStore");const isPlainRecord=e=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype;function deepMergeInto(e,r){if(!isPlainRecord(e)||!isPlainRecord(r))return r;const t={...e};for(const[o,i]of Object.entries(r))t[o]=o in e?deepMergeInto(e[o],i):i;return t}const STATE_ON_DEVICE=exports.STATE_ON_DEVICE=(0,_sharedUi.onDeviceMarker)("State","State trees stay on the device \u2014 fetched on demand via getChangeDetail / getStoreState.");const PAYLOAD_ON_DEVICE=exports.PAYLOAD_ON_DEVICE=(0,_sharedUi.onDeviceMarker)("Payload","Partial stays on the device \u2014 fetched on demand via getChangeDetail.");const isPlainObject=e=>!!e&&typeof e==="object"&&!Array.isArray(e);function touchesList(e,r){let t=e;for(const o of r.split(".")){if(!t||typeof t!=="object"||Array.isArray(t))return false;if(!(o in t))return false;t=t[o]}return Array.isArray(t)?t.length>0:!!t&&typeof t==="object"}function topLevelKeys(e){return e&&typeof e==="object"&&!Array.isArray(e)?Object.keys(e):void 0}const toWireChange=(0,_sharedUi.memoByIdentity)(e=>({...e,prevState:STATE_ON_DEVICE,nextState:STATE_ON_DEVICE,partial:(0,_sharedUi.toWire)(e.partial,PAYLOAD_ON_DEVICE)}));const toWireState=e=>(0,_sharedUi.toWire)(e,STATE_ON_DEVICE);const zustandSyncAdapter=exports.zustandSyncAdapter=(0,_sharedUi.createSyncAdapter)({version:2,getSnapshot:()=>({changes:_zustandStateStore.zustandStateStore.getStateChanges().map(toWireChange),stores:_zustandStateStore.zustandStateStore.getStoreSnapshots().map(e=>({...e,currentState:toWireState(e.currentState)}))}),subscribe:[e=>_zustandStateStore.zustandStateStore.subscribe(e),e=>_zustandStateStore.zustandStateStore.subscribeToStores(e)],actions:{clearEvents:()=>{_zustandStateStore.zustandStateStore.clearStateChanges()},getChangeDetail:(0,_sharedUi.detailByIdAction)(e=>_zustandStateStore.zustandStateStore.getStateChangeById(e),(e,r)=>({prevState:r(e.prevState),nextState:r(e.nextState),partial:r(e.partial)})),getStoreState:e=>{const{storeName:r,path:t}=(0,_sharedUi.readParams)(e);if(!r)return{found:false,reason:"missing storeName"};const o=_zustandStateStore.zustandStateStore.getStore(r);if(!o)return{found:false,reason:"unknown storeName"};let i;try{i=o.api.getState()}catch{i=void 0}if(t){const s=(0,_sharedUi.readPath)(i,t);if(!s.ok)return{found:false,reason:s.error};return{found:true,storeName:r,path:t,shape:(0,_sharedUi.shapeSummary)(s.value),currentState:s.value}}const d=(0,_sharedUi.shapeSummary)(i);if(!(0,_sharedUi.isOverWireBudget)(i,_sharedUi.WIRE_DETAIL_LIMIT_BYTES)){return{found:true,storeName:r,...d?{shape:d}:{},currentState:i}}return{found:true,storeName:r,...d?{shape:d}:{},currentState:(0,_sharedUi.isJsonSerializable)(i)?(0,_sharedUi.truncatedNote)(_sharedUi.WIRE_DETAIL_LIMIT_BYTES):STATE_ON_DEVICE}},listStores:e=>{const{includeValues:r=false,limit:t}=(0,_sharedUi.readParams)(e);const o=_zustandStateStore.zustandStateStore.getStoreSnapshots();const i=typeof t==="number"&&t>0?o.slice(0,t):o;const d=i.map(s=>({name:s.name,...s.library?{library:s.library}:{},changes:s.stateChangeCount,isPersisted:s.isPersisted,persistName:s.persistName,canRehydrate:s.canRehydrate,...r?{currentState:s.currentState}:{keys:topLevelKeys(s.currentState)},...(0,_sharedUi.shapeSummary)(s.currentState)?{shape:(0,_sharedUi.shapeSummary)(s.currentState)}:{}}));return{stores:d,total:o.length,returned:d.length,includedValues:r}},setState:e=>{const{storeName:r,state:t,replace:o,force:i,path:d,value:s}=(0,_sharedUi.readParams)(e);let u=t;let f=[];let l=[];if(!r)return{ok:false,error:"Missing storeName."};const c=_zustandStateStore.zustandStateStore.getStore(r);if(!c)return{ok:false,error:`No store named "${r}".`};if(t===void 0&&d===void 0){return{ok:false,error:`Refused: no change was described. Send \`state\` with the fields to merge, or \`path\` and \`value\` to set one value.`}}let S=false;if(d!==void 0){if(s===void 0){return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${d}" to; if you mean to clear it, send value:null and the field must already be nullable.`}}let a;try{a=c.api.getState()}catch{a=void 0}const n=(0,_sharedUi.patchFromPath)(a,d,s);if(!n.ok)return{ok:false,error:`Refused: ${n.error}`};u=n.patch;S=true}if(!i&&(o===false||S)){let a;try{a=c.api.getState()}catch{a=void 0}if(a!==void 0){const n=(0,_sharedUi.expandKeyedArrays)(a,u);if(n.error){return{ok:false,error:`Refused: ${n.error}`}}u=n.patch;f=n.notes}if(a!==void 0){l=(0,_sharedUi.unshapedLists)(a).filter(n=>touchesList(u,n))}if(a!==void 0){const n=(0,_sharedUi.typedEditViolations)(a,u,{noun:"store"});if(n.length>0){return{ok:false,error:(0,_sharedUi.refusalText)(n,"store",(0,_sharedUi.suggestedPatch)(u,n)),...(0,_sharedUi.suggestedPatch)(u,n)?{suggestedState:(0,_sharedUi.suggestedPatch)(u,n)}:{},violations:n}}}}const h=S||o===false;if(h){let a;try{a=c.api.getState()}catch{a=void 0}if(isPlainRecord(a)&&isPlainRecord(u)){const n={};for(const[p,y]of Object.entries(u))n[p]=p in a?deepMergeInto(a[p],y):y;u=n}}c.api.setState(u,h?false:o??true);return{ok:true,...d!==void 0?{path:d}:{},...f.length?{keyed:f}:{},...l.length?{unchecked:l.map(a=>`\`${a}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the app renders a field you left out, it will render undefined \u2014 read the store back and compare against how the screen uses it.`)}:{}}},rehydrate:async e=>{const{storeName:r}=(0,_sharedUi.readParams)(e);if(!r)return{ok:false,error:"Missing storeName."};const t=_zustandStateStore.zustandStateStore.getStore(r);if(!t)return{ok:false,error:`No store named "${r}".`};if(!t.isPersisted){return{ok:false,error:`"${r}" is not a persisted store \u2014 it has no saved copy to re-read.`}}if(!t.rehydrate){return{ok:false,error:`"${r}" is persisted but Buoy has no rehydrate handle for it. It was probably registered before the app's persist middleware attached.`}}await t.rehydrate();return{ok:true,storeName:r,persistName:t.persistName}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.buoyDevTools=buoyDevTools;exports.isStoreInstrumented=isStoreInstrumented;exports.watchStores=watchStores;var _zustandStateStore=require("./zustandStateStore");const WATCHED_SYMBOL=Symbol.for("@@buoy-zustand/watched");function detectPersist(o){const e=o.persist;if(e&&typeof e.getOptions==="function"){const s=e.getOptions();return{isPersisted:true,persistName:s?.name,persistApi:e}}return{isPersisted:false}}function watchStores(o){const e=[];for(const[s,t]of Object.entries(o)){const r=t;if(r[WATCHED_SYMBOL])continue;r[WATCHED_SYMBOL]=true;const{isPersisted:a,persistName:f,persistApi:u}=detectPersist(t);_zustandStateStore.zustandStateStore.registerStore(s,{getState:t.getState,getInitialState:t.getInitialState,setState:t.setState,subscribe:t.subscribe},{isPersisted:a,persistName:f,rehydrate:typeof u?.rehydrate==="function"?()=>u.rehydrate():void 0});let c=false;const l=t.subscribe((n,i)=>{try{let d;if(!c&&a){let S=false;try{S=u?.hasHydrated?.()===false}catch{}if(S){c=true;d="persist"}}_zustandStateStore.zustandStateStore.addStateChange({storeName:s,partial:void 0,replace:false,prevState:i,nextState:n,duration:void 0,category:d,isPersisted:a})}catch{}});e.push(()=>{l();delete t[WATCHED_SYMBOL];_zustandStateStore.zustandStateStore.unregisterStore(s)})}return()=>{e.forEach(s=>s())}}let unnamedCounter=0;function buoyDevTools(o,e){return(s,t,r)=>{const a=e?.name??`store-${++unnamedCounter}`;const f=e?.enabled!==false;const u=s;const c=(n,i)=>{if(!f){return u(n,i)}const d=performance.now();const S=t();u(n,i);const b=t();const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.buoyDevTools=buoyDevTools;exports.isStoreInstrumented=isStoreInstrumented;exports.watchStores=watchStores;var _zustandStateStore=require("./zustandStateStore");const WATCHED_SYMBOL=Symbol.for("@@buoy-zustand/watched");function detectPersist(o){const e=o.persist;if(e&&typeof e.getOptions==="function"){const s=e.getOptions();return{isPersisted:true,persistName:s?.name,persistApi:e}}return{isPersisted:false}}function watchStores(o){const e=[];for(const[s,t]of Object.entries(o)){const r=t;if(r[WATCHED_SYMBOL])continue;r[WATCHED_SYMBOL]=true;const{isPersisted:a,persistName:f,persistApi:u}=detectPersist(t);_zustandStateStore.zustandStateStore.registerStore(s,{getState:t.getState,getInitialState:t.getInitialState,setState:t.setState,subscribe:t.subscribe},{isPersisted:a,persistName:f,rehydrate:typeof u?.rehydrate==="function"?()=>u.rehydrate():void 0,library:t.buoyLibrary});let c=false;const l=t.subscribe((n,i)=>{try{let d;if(!c&&a){let S=false;try{S=u?.hasHydrated?.()===false}catch{}if(S){c=true;d="persist"}}_zustandStateStore.zustandStateStore.addStateChange({storeName:s,partial:void 0,replace:false,prevState:i,nextState:n,duration:void 0,category:d,isPersisted:a})}catch{}});e.push(()=>{l();delete t[WATCHED_SYMBOL];_zustandStateStore.zustandStateStore.unregisterStore(s)})}return()=>{e.forEach(s=>s())}}let unnamedCounter=0;function buoyDevTools(o,e){return(s,t,r)=>{const a=e?.name??`store-${++unnamedCounter}`;const f=e?.enabled!==false;const u=s;const c=(n,i)=>{if(!f){return u(n,i)}const d=performance.now();const S=t();u(n,i);const b=t();const y=performance.now()-d;const p=typeof n==="function"?"(updater fn)":n;_zustandStateStore.zustandStateStore.addStateChange({storeName:a,partial:p,replace:i??false,prevState:S,nextState:b,duration:y,isPersisted:_zustandStateStore.zustandStateStore.getStore(a)?.isPersisted??false})};const l=o(c,t,r);setTimeout(()=>{if(r[WATCHED_SYMBOL])return;r[WATCHED_SYMBOL]=true;const{isPersisted:n,persistName:i}=detectPersist(r);_zustandStateStore.zustandStateStore.registerStore(a,{getState:t,getInitialState:r.getInitialState,setState:c,subscribe:r.subscribe},{isPersisted:n,persistName:i})},0);return l}}function isStoreInstrumented(o){return o[WATCHED_SYMBOL]===true}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.zustandStateStore=void 0;var _sharedUi=require("@buoy-gg/shared-ui");const STORE_COLORS={counter:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",navigation:"#F97316",form:"#EF4444"};function getStoreColor(u){return(0,_sharedUi.entityColor)(u,STORE_COLORS)}function formatPartialPreview(u,t=40){return(0,_sharedUi.formatValuePreview)(u,{maxLength:t,undefinedLabel:"",functionLabel:"(updater fn)"})}class ZustandStateStore extends _sharedUi.ChangeLog{stores=new Map;storeListeners=new Set;remoteSetStateHandler=null;addStateChange(t){if(!this.canRecord())return;const{storeName:s,partial:r,replace:a,prevState:o,nextState:e,duration:n,category:i,isPersisted:h=false}=t;const c=o!==e;const{summary:g,changedKeys:d,changedCount:l}=(0,_sharedUi.shallowDiffSummary)(o,e);const f=formatPartialPreview(r);const m=(n??0)>16;const C=i??(a?"replace":"setState");const y={id:this.nextId(),storeName:s,timestamp:Date.now(),prevState:o,nextState:e,partial:r,duration:n,hasStateChange:c,replace:a,category:C,changedKeys:d,changedKeysCount:l,diffSummary:g,partialPreview:f,isSlowUpdate:m,isPersisted:h};this.push(y);const S=this.stores.get(s);if(S){S.stateChangeCount++}this.notifyListeners()}getStateChanges(){return this.getAll()}getStateChangeById(t){return this.getById(t)}clearStateChanges(){for(const t of this.stores.values()){t.stateChangeCount=0}this.clear();this.notifyStoreListeners()}replaceStateChanges(t){if(!this.getEnabled())return;for(const r of this.stores.values()){r.stateChangeCount=0}const s=t.slice(0,this.max);for(const r of s){const a=this.stores.get(r.storeName);if(a)a.stateChangeCount++}this.setItems(s);this.notifyStoreListeners()}getStoreSnapshots(){return Array.from(this.stores.values()).map(t=>{let s;try{s=t.api.getState()}catch{s=void 0}return{name:t.name,stateChangeCount:t.stateChangeCount,isPersisted:t.isPersisted,persistName:t.persistName,canRehydrate:typeof t.rehydrate==="function",color:t.color,currentState:s}})}setRemoteSetStateHandler(t){this.remoteSetStateHandler=t}replaceFromSnapshot(t,s){if(!this.getEnabled())return;const r=new Map;for(const e of this.items){const n=e.prevState;if(!n||n.__buoyStateOnDevice!==true){r.set(e.id,e)}}const a=t.slice(0,this.max).map(e=>{const n=r.get(e.id);const i=e.prevState;return n&&i?.__buoyStateOnDevice===true?{...e,prevState:n.prevState,nextState:n.nextState,partial:n.partial}:e});const o=new Map;for(const[e,n]of this.stores){try{const i=n.api.getState();const h=i;if(!h||h.__buoyStateOnDevice!==true){o.set(e,i)}}catch{}}this.stores=new Map(s.map(e=>{const n=e.currentState;const i=o.get(e.name);const h=i!==void 0&&n?.__buoyStateOnDevice===true?i:e.currentState;return[e.name,{name:e.name,api:{getState:()=>h,setState:(c,g)=>{this.remoteSetStateHandler?.(e.name,c,g)},subscribe:()=>()=>{}},stateChangeCount:e.stateChangeCount,isPersisted:e.isPersisted,persistName:e.persistName,color:e.color}]}));this.setItems(a);this.notifyStoreListeners()}hydrateChange(t,s){this.hydrateById(t,s)}hydrateStoreState(t,s){const r=this.stores.get(t);if(!r)return;this.stores.set(t,{...r,api:{...r.api,getState:()=>s}});this.notifyStoreListeners()}registerStore(t,s,r){if(this.stores.has(t))return;const a={name:t,api:s,stateChangeCount:0,isPersisted:r?.isPersisted??false,persistName:r?.persistName,rehydrate:r?.rehydrate,color:getStoreColor(t)};this.stores.set(t,a);this.notifyStoreListeners()}unregisterStore(t){this.stores.delete(t);this.notifyStoreListeners()}getStores(){return Array.from(this.stores.values())}getStore(t){return this.stores.get(t)}getStoreColor(t){return this.stores.get(t)?.color??getStoreColor(t)}filterStateChanges(t){let s=this.getAll();if(t.searchText){const r=t.searchText.toLowerCase();s=s.filter(a=>a.storeName.toLowerCase().includes(r)||a.partialPreview.toLowerCase().includes(r)||a.changedKeys.some(o=>o.toLowerCase().includes(r)))}if(t.storeNames&&t.storeNames.length>0){s=s.filter(r=>t.storeNames.includes(r.storeName))}if(t.onlyWithChanges){s=s.filter(r=>r.hasStateChange)}return s}getStats(){const t=this.items.length;const s=this.items.filter(e=>e.hasStateChange).length;const r=this.stores.size;const a=this.items.filter(e=>e.duration!==void 0).map(e=>e.duration);const o=a.length>0?a.reduce((e,n)=>e+n,0)/a.length:0;return{totalChanges:t,changesWithStateChange:s,changesWithoutStateChange:t-s,storeCount:r,averageDuration:Math.round(o*100)/100}}getUniqueStoreNames(){return Array.from(this.stores.keys()).sort()}setMaxChanges(t){this.setMax(t)}subscribeToStores(t){this.storeListeners.add(t);return()=>{this.storeListeners.delete(t)}}notifyStoreListeners(){const t=this.getStores();this.storeListeners.forEach(s=>s(t))}}const zustandStateStore=exports.zustandStateStore=new ZustandStateStore;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.zustandStateStore=void 0;var _sharedUi=require("@buoy-gg/shared-ui");const STORE_COLORS={counter:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",navigation:"#F97316",form:"#EF4444"};function getStoreColor(u){return(0,_sharedUi.entityColor)(u,STORE_COLORS)}function formatPartialPreview(u,t=40){return(0,_sharedUi.formatValuePreview)(u,{maxLength:t,undefinedLabel:"",functionLabel:"(updater fn)"})}class ZustandStateStore extends _sharedUi.ChangeLog{stores=new Map;storeListeners=new Set;remoteSetStateHandler=null;addStateChange(t){if(!this.canRecord())return;const{storeName:s,partial:r,replace:a,prevState:o,nextState:e,duration:n,category:i,isPersisted:h=false}=t;const c=o!==e;const{summary:g,changedKeys:d,changedCount:l}=(0,_sharedUi.shallowDiffSummary)(o,e);const f=formatPartialPreview(r);const m=(n??0)>16;const C=i??(a?"replace":"setState");const y={id:this.nextId(),storeName:s,timestamp:Date.now(),prevState:o,nextState:e,partial:r,duration:n,hasStateChange:c,replace:a,category:C,changedKeys:d,changedKeysCount:l,diffSummary:g,partialPreview:f,isSlowUpdate:m,isPersisted:h};this.push(y);const S=this.stores.get(s);if(S){S.stateChangeCount++}this.notifyListeners()}getStateChanges(){return this.getAll()}getStateChangeById(t){return this.getById(t)}clearStateChanges(){for(const t of this.stores.values()){t.stateChangeCount=0}this.clear();this.notifyStoreListeners()}replaceStateChanges(t){if(!this.getEnabled())return;for(const r of this.stores.values()){r.stateChangeCount=0}const s=t.slice(0,this.max);for(const r of s){const a=this.stores.get(r.storeName);if(a)a.stateChangeCount++}this.setItems(s);this.notifyStoreListeners()}getStoreSnapshots(){return Array.from(this.stores.values()).map(t=>{let s;try{s=t.api.getState()}catch{s=void 0}return{name:t.name,stateChangeCount:t.stateChangeCount,isPersisted:t.isPersisted,persistName:t.persistName,canRehydrate:typeof t.rehydrate==="function",library:t.library,color:t.color,currentState:s}})}setRemoteSetStateHandler(t){this.remoteSetStateHandler=t}replaceFromSnapshot(t,s){if(!this.getEnabled())return;const r=new Map;for(const e of this.items){const n=e.prevState;if(!n||n.__buoyStateOnDevice!==true){r.set(e.id,e)}}const a=t.slice(0,this.max).map(e=>{const n=r.get(e.id);const i=e.prevState;return n&&i?.__buoyStateOnDevice===true?{...e,prevState:n.prevState,nextState:n.nextState,partial:n.partial}:e});const o=new Map;for(const[e,n]of this.stores){try{const i=n.api.getState();const h=i;if(!h||h.__buoyStateOnDevice!==true){o.set(e,i)}}catch{}}this.stores=new Map(s.map(e=>{const n=e.currentState;const i=o.get(e.name);const h=i!==void 0&&n?.__buoyStateOnDevice===true?i:e.currentState;return[e.name,{name:e.name,api:{getState:()=>h,setState:(c,g)=>{this.remoteSetStateHandler?.(e.name,c,g)},subscribe:()=>()=>{}},stateChangeCount:e.stateChangeCount,isPersisted:e.isPersisted,persistName:e.persistName,color:e.color}]}));this.setItems(a);this.notifyStoreListeners()}hydrateChange(t,s){this.hydrateById(t,s)}hydrateStoreState(t,s){const r=this.stores.get(t);if(!r)return;this.stores.set(t,{...r,api:{...r.api,getState:()=>s}});this.notifyStoreListeners()}registerStore(t,s,r){if(this.stores.has(t))return;const a={name:t,api:s,stateChangeCount:0,isPersisted:r?.isPersisted??false,persistName:r?.persistName,rehydrate:r?.rehydrate,library:r?.library,color:getStoreColor(t)};this.stores.set(t,a);this.notifyStoreListeners()}unregisterStore(t){this.stores.delete(t);this.notifyStoreListeners()}getStores(){return Array.from(this.stores.values())}getStore(t){return this.stores.get(t)}getStoreColor(t){return this.stores.get(t)?.color??getStoreColor(t)}filterStateChanges(t){let s=this.getAll();if(t.searchText){const r=t.searchText.toLowerCase();s=s.filter(a=>a.storeName.toLowerCase().includes(r)||a.partialPreview.toLowerCase().includes(r)||a.changedKeys.some(o=>o.toLowerCase().includes(r)))}if(t.storeNames&&t.storeNames.length>0){s=s.filter(r=>t.storeNames.includes(r.storeName))}if(t.onlyWithChanges){s=s.filter(r=>r.hasStateChange)}return s}getStats(){const t=this.items.length;const s=this.items.filter(e=>e.hasStateChange).length;const r=this.stores.size;const a=this.items.filter(e=>e.duration!==void 0).map(e=>e.duration);const o=a.length>0?a.reduce((e,n)=>e+n,0)/a.length:0;return{totalChanges:t,changesWithStateChange:s,changesWithoutStateChange:t-s,storeCount:r,averageDuration:Math.round(o*100)/100}}getUniqueStoreNames(){return Array.from(this.stores.keys()).sort()}setMaxChanges(t){this.setMax(t)}subscribeToStores(t){this.storeListeners.add(t);return()=>{this.storeListeners.delete(t)}}notifyStoreListeners(){const t=this.getStores();this.storeListeners.forEach(s=>s(t))}}const zustandStateStore=exports.zustandStateStore=new ZustandStateStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{expandKeyedArrays as I,patchFromPath as O,readPath as j,refusalText as C,shapeSummary as l,suggestedPatch as k,typedEditViolations as E,unshapedLists as x}from"@buoy-gg/shared-ui";import{zustandStateStore as f}from"../utils/zustandStateStore";import{WIRE_DETAIL_LIMIT_BYTES as A,createSyncAdapter as D,detailByIdAction as R,isJsonSerializable as T,isOverWireBudget as $,memoByIdentity as _,onDeviceMarker as N,readParams as p,toWire as w,truncatedNote as B}from"@buoy-gg/shared-ui";const h=e=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype;function P(e,r){if(!h(e)||!h(r))return r;const t={...e};for(const[
|
|
1
|
+
"use strict";import{expandKeyedArrays as I,patchFromPath as O,readPath as j,refusalText as C,shapeSummary as l,suggestedPatch as k,typedEditViolations as E,unshapedLists as x}from"@buoy-gg/shared-ui";import{zustandStateStore as f}from"../utils/zustandStateStore";import{WIRE_DETAIL_LIMIT_BYTES as A,createSyncAdapter as D,detailByIdAction as R,isJsonSerializable as T,isOverWireBudget as $,memoByIdentity as _,onDeviceMarker as N,readParams as p,toWire as w,truncatedNote as B}from"@buoy-gg/shared-ui";const h=e=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype;function P(e,r){if(!h(e)||!h(r))return r;const t={...e};for(const[s,i]of Object.entries(r))t[s]=s in e?P(e[s],i):i;return t}export const STATE_ON_DEVICE=N("State","State trees stay on the device \u2014 fetched on demand via getChangeDetail / getStoreState.");export const PAYLOAD_ON_DEVICE=N("Payload","Partial stays on the device \u2014 fetched on demand via getChangeDetail.");const Y=e=>!!e&&typeof e==="object"&&!Array.isArray(e);function L(e,r){let t=e;for(const s of r.split(".")){if(!t||typeof t!=="object"||Array.isArray(t))return false;if(!(s in t))return false;t=t[s]}return Array.isArray(t)?t.length>0:!!t&&typeof t==="object"}function M(e){return e&&typeof e==="object"&&!Array.isArray(e)?Object.keys(e):void 0}const V=_(e=>({...e,prevState:STATE_ON_DEVICE,nextState:STATE_ON_DEVICE,partial:w(e.partial,PAYLOAD_ON_DEVICE)}));const W=e=>w(e,STATE_ON_DEVICE);export const zustandSyncAdapter=D({version:2,getSnapshot:()=>({changes:f.getStateChanges().map(V),stores:f.getStoreSnapshots().map(e=>({...e,currentState:W(e.currentState)}))}),subscribe:[e=>f.subscribe(e),e=>f.subscribeToStores(e)],actions:{clearEvents:()=>{f.clearStateChanges()},getChangeDetail:R(e=>f.getStateChangeById(e),(e,r)=>({prevState:r(e.prevState),nextState:r(e.nextState),partial:r(e.partial)})),getStoreState:e=>{const{storeName:r,path:t}=p(e);if(!r)return{found:false,reason:"missing storeName"};const s=f.getStore(r);if(!s)return{found:false,reason:"unknown storeName"};let i;try{i=s.api.getState()}catch{i=void 0}if(t){const o=j(i,t);if(!o.ok)return{found:false,reason:o.error};return{found:true,storeName:r,path:t,shape:l(o.value),currentState:o.value}}const d=l(i);if(!$(i,A)){return{found:true,storeName:r,...d?{shape:d}:{},currentState:i}}return{found:true,storeName:r,...d?{shape:d}:{},currentState:T(i)?B(A):STATE_ON_DEVICE}},listStores:e=>{const{includeValues:r=false,limit:t}=p(e);const s=f.getStoreSnapshots();const i=typeof t==="number"&&t>0?s.slice(0,t):s;const d=i.map(o=>({name:o.name,...o.library?{library:o.library}:{},changes:o.stateChangeCount,isPersisted:o.isPersisted,persistName:o.persistName,canRehydrate:o.canRehydrate,...r?{currentState:o.currentState}:{keys:M(o.currentState)},...l(o.currentState)?{shape:l(o.currentState)}:{}}));return{stores:d,total:s.length,returned:d.length,includedValues:r}},setState:e=>{const{storeName:r,state:t,replace:s,force:i,path:d,value:o}=p(e);let u=t;let y=[];let S=[];if(!r)return{ok:false,error:"Missing storeName."};const c=f.getStore(r);if(!c)return{ok:false,error:`No store named "${r}".`};if(t===void 0&&d===void 0){return{ok:false,error:`Refused: no change was described. Send \`state\` with the fields to merge, or \`path\` and \`value\` to set one value.`}}let g=false;if(d!==void 0){if(o===void 0){return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${d}" to; if you mean to clear it, send value:null and the field must already be nullable.`}}let a;try{a=c.api.getState()}catch{a=void 0}const n=O(a,d,o);if(!n.ok)return{ok:false,error:`Refused: ${n.error}`};u=n.patch;g=true}if(!i&&(s===false||g)){let a;try{a=c.api.getState()}catch{a=void 0}if(a!==void 0){const n=I(a,u);if(n.error){return{ok:false,error:`Refused: ${n.error}`}}u=n.patch;y=n.notes}if(a!==void 0){S=x(a).filter(n=>L(u,n))}if(a!==void 0){const n=E(a,u,{noun:"store"});if(n.length>0){return{ok:false,error:C(n,"store",k(u,n)),...k(u,n)?{suggestedState:k(u,n)}:{},violations:n}}}}const b=g||s===false;if(b){let a;try{a=c.api.getState()}catch{a=void 0}if(h(a)&&h(u)){const n={};for(const[m,v]of Object.entries(u))n[m]=m in a?P(a[m],v):v;u=n}}c.api.setState(u,b?false:s??true);return{ok:true,...d!==void 0?{path:d}:{},...y.length?{keyed:y}:{},...S.length?{unchecked:S.map(a=>`\`${a}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the app renders a field you left out, it will render undefined \u2014 read the store back and compare against how the screen uses it.`)}:{}}},rehydrate:async e=>{const{storeName:r}=p(e);if(!r)return{ok:false,error:"Missing storeName."};const t=f.getStore(r);if(!t)return{ok:false,error:`No store named "${r}".`};if(!t.isPersisted){return{ok:false,error:`"${r}" is not a persisted store \u2014 it has no saved copy to re-read.`}}if(!t.rehydrate){return{ok:false,error:`"${r}" is persisted but Buoy has no rehydrate handle for it. It was probably registered before the app's persist middleware attached.`}}await t.rehydrate();return{ok:true,storeName:r,persistName:t.persistName}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{zustandStateStore as c}from"./zustandStateStore";const d=Symbol.for("@@buoy-zustand/watched");function
|
|
1
|
+
"use strict";import{zustandStateStore as c}from"./zustandStateStore";const d=Symbol.for("@@buoy-zustand/watched");function y(o){const e=o.persist;if(e&&typeof e.getOptions==="function"){const s=e.getOptions();return{isPersisted:true,persistName:s?.name,persistApi:e}}return{isPersisted:false}}export function watchStores(o){const e=[];for(const[s,t]of Object.entries(o)){const r=t;if(r[d])continue;r[d]=true;const{isPersisted:i,persistName:b,persistApi:u}=y(t);c.registerStore(s,{getState:t.getState,getInitialState:t.getInitialState,setState:t.setState,subscribe:t.subscribe},{isPersisted:i,persistName:b,rehydrate:typeof u?.rehydrate==="function"?()=>u.rehydrate():void 0,library:t.buoyLibrary});let f=false;const p=t.subscribe((n,a)=>{try{let S;if(!f&&i){let l=false;try{l=u?.hasHydrated?.()===false}catch{}if(l){f=true;S="persist"}}c.addStateChange({storeName:s,partial:void 0,replace:false,prevState:a,nextState:n,duration:void 0,category:S,isPersisted:i})}catch{}});e.push(()=>{p();delete t[d];c.unregisterStore(s)})}return()=>{e.forEach(s=>s())}}let P=0;export function buoyDevTools(o,e){return(s,t,r)=>{const i=e?.name??`store-${++P}`;const b=e?.enabled!==false;const u=s;const f=(n,a)=>{if(!b){return u(n,a)}const S=performance.now();const l=t();u(n,a);const m=t();const g=performance.now()-S;const h=typeof n==="function"?"(updater fn)":n;c.addStateChange({storeName:i,partial:h,replace:a??false,prevState:l,nextState:m,duration:g,isPersisted:c.getStore(i)?.isPersisted??false})};const p=o(f,t,r);setTimeout(()=>{if(r[d])return;r[d]=true;const{isPersisted:n,persistName:a}=y(r);c.registerStore(i,{getState:t,getInitialState:r.getInitialState,setState:f,subscribe:r.subscribe},{isPersisted:n,persistName:a})},0);return p}}export function isStoreInstrumented(o){return o[d]===true}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{ChangeLog as v,entityColor as L,formatValuePreview as w,shallowDiffSummary as
|
|
1
|
+
"use strict";import{ChangeLog as v,entityColor as L,formatValuePreview as w,shallowDiffSummary as b}from"@buoy-gg/shared-ui";const x={counter:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",navigation:"#F97316",form:"#EF4444"};function l(c){return L(c,x)}function N(c,t=40){return w(c,{maxLength:t,undefinedLabel:"",functionLabel:"(updater fn)"})}class P extends v{stores=new Map;storeListeners=new Set;remoteSetStateHandler=null;addStateChange(t){if(!this.canRecord())return;const{storeName:s,partial:r,replace:a,prevState:o,nextState:e,duration:n,category:i,isPersisted:h=false}=t;const u=o!==e;const{summary:g,changedKeys:d,changedCount:f}=b(o,e);const m=N(r);const C=(n??0)>16;const y=i??(a?"replace":"setState");const p={id:this.nextId(),storeName:s,timestamp:Date.now(),prevState:o,nextState:e,partial:r,duration:n,hasStateChange:u,replace:a,category:y,changedKeys:d,changedKeysCount:f,diffSummary:g,partialPreview:m,isSlowUpdate:C,isPersisted:h};this.push(p);const S=this.stores.get(s);if(S){S.stateChangeCount++}this.notifyListeners()}getStateChanges(){return this.getAll()}getStateChangeById(t){return this.getById(t)}clearStateChanges(){for(const t of this.stores.values()){t.stateChangeCount=0}this.clear();this.notifyStoreListeners()}replaceStateChanges(t){if(!this.getEnabled())return;for(const r of this.stores.values()){r.stateChangeCount=0}const s=t.slice(0,this.max);for(const r of s){const a=this.stores.get(r.storeName);if(a)a.stateChangeCount++}this.setItems(s);this.notifyStoreListeners()}getStoreSnapshots(){return Array.from(this.stores.values()).map(t=>{let s;try{s=t.api.getState()}catch{s=void 0}return{name:t.name,stateChangeCount:t.stateChangeCount,isPersisted:t.isPersisted,persistName:t.persistName,canRehydrate:typeof t.rehydrate==="function",library:t.library,color:t.color,currentState:s}})}setRemoteSetStateHandler(t){this.remoteSetStateHandler=t}replaceFromSnapshot(t,s){if(!this.getEnabled())return;const r=new Map;for(const e of this.items){const n=e.prevState;if(!n||n.__buoyStateOnDevice!==true){r.set(e.id,e)}}const a=t.slice(0,this.max).map(e=>{const n=r.get(e.id);const i=e.prevState;return n&&i?.__buoyStateOnDevice===true?{...e,prevState:n.prevState,nextState:n.nextState,partial:n.partial}:e});const o=new Map;for(const[e,n]of this.stores){try{const i=n.api.getState();const h=i;if(!h||h.__buoyStateOnDevice!==true){o.set(e,i)}}catch{}}this.stores=new Map(s.map(e=>{const n=e.currentState;const i=o.get(e.name);const h=i!==void 0&&n?.__buoyStateOnDevice===true?i:e.currentState;return[e.name,{name:e.name,api:{getState:()=>h,setState:(u,g)=>{this.remoteSetStateHandler?.(e.name,u,g)},subscribe:()=>()=>{}},stateChangeCount:e.stateChangeCount,isPersisted:e.isPersisted,persistName:e.persistName,color:e.color}]}));this.setItems(a);this.notifyStoreListeners()}hydrateChange(t,s){this.hydrateById(t,s)}hydrateStoreState(t,s){const r=this.stores.get(t);if(!r)return;this.stores.set(t,{...r,api:{...r.api,getState:()=>s}});this.notifyStoreListeners()}registerStore(t,s,r){if(this.stores.has(t))return;const a={name:t,api:s,stateChangeCount:0,isPersisted:r?.isPersisted??false,persistName:r?.persistName,rehydrate:r?.rehydrate,library:r?.library,color:l(t)};this.stores.set(t,a);this.notifyStoreListeners()}unregisterStore(t){this.stores.delete(t);this.notifyStoreListeners()}getStores(){return Array.from(this.stores.values())}getStore(t){return this.stores.get(t)}getStoreColor(t){return this.stores.get(t)?.color??l(t)}filterStateChanges(t){let s=this.getAll();if(t.searchText){const r=t.searchText.toLowerCase();s=s.filter(a=>a.storeName.toLowerCase().includes(r)||a.partialPreview.toLowerCase().includes(r)||a.changedKeys.some(o=>o.toLowerCase().includes(r)))}if(t.storeNames&&t.storeNames.length>0){s=s.filter(r=>t.storeNames.includes(r.storeName))}if(t.onlyWithChanges){s=s.filter(r=>r.hasStateChange)}return s}getStats(){const t=this.items.length;const s=this.items.filter(e=>e.hasStateChange).length;const r=this.stores.size;const a=this.items.filter(e=>e.duration!==void 0).map(e=>e.duration);const o=a.length>0?a.reduce((e,n)=>e+n,0)/a.length:0;return{totalChanges:t,changesWithStateChange:s,changesWithoutStateChange:t-s,storeCount:r,averageDuration:Math.round(o*100)/100}}getUniqueStoreNames(){return Array.from(this.stores.keys()).sort()}setMaxChanges(t){this.setMax(t)}subscribeToStores(t){this.storeListeners.add(t);return()=>{this.storeListeners.delete(t)}}notifyStoreListeners(){const t=this.getStores();this.storeListeners.forEach(s=>s(t))}}export const zustandStateStore=new P;
|
|
@@ -41,6 +41,7 @@ export declare const zustandSyncAdapter: import("@buoy-gg/shared-ui").SyncAdapte
|
|
|
41
41
|
isPersisted: boolean;
|
|
42
42
|
persistName?: string;
|
|
43
43
|
canRehydrate?: boolean;
|
|
44
|
+
library?: string;
|
|
44
45
|
color: string;
|
|
45
46
|
}[];
|
|
46
47
|
}, {
|
|
@@ -100,22 +101,24 @@ export declare const zustandSyncAdapter: import("@buoy-gg/shared-ui").SyncAdapte
|
|
|
100
101
|
lists?: import("@buoy-gg/shared-ui").ListShape[];
|
|
101
102
|
} | undefined;
|
|
102
103
|
currentState: unknown;
|
|
103
|
-
name: string;
|
|
104
104
|
changes: number;
|
|
105
105
|
isPersisted: boolean;
|
|
106
106
|
persistName: string | undefined;
|
|
107
107
|
canRehydrate: boolean | undefined;
|
|
108
|
+
library?: string | undefined;
|
|
109
|
+
name: string;
|
|
108
110
|
} | {
|
|
109
111
|
shape?: {
|
|
110
112
|
shape: string;
|
|
111
113
|
lists?: import("@buoy-gg/shared-ui").ListShape[];
|
|
112
114
|
} | undefined;
|
|
113
115
|
keys: string[] | undefined;
|
|
114
|
-
name: string;
|
|
115
116
|
changes: number;
|
|
116
117
|
isPersisted: boolean;
|
|
117
118
|
persistName: string | undefined;
|
|
118
119
|
canRehydrate: boolean | undefined;
|
|
120
|
+
library?: string | undefined;
|
|
121
|
+
name: string;
|
|
119
122
|
})[];
|
|
120
123
|
total: number;
|
|
121
124
|
returned: number;
|
|
@@ -40,6 +40,8 @@ export interface ZustandStoreInfo {
|
|
|
40
40
|
stateChangeCount: number;
|
|
41
41
|
isPersisted: boolean;
|
|
42
42
|
persistName?: string;
|
|
43
|
+
/** The state library behind it when it isn't Zustand, like "pinia". */
|
|
44
|
+
library?: string;
|
|
43
45
|
/**
|
|
44
46
|
* `persist.rehydrate()` for a persisted store — re-reads the saved value and
|
|
45
47
|
* merges it into the live store.
|
|
@@ -64,6 +66,8 @@ export interface ZustandStoreSnapshot {
|
|
|
64
66
|
persistName?: string;
|
|
65
67
|
/** True when Buoy holds a `persist.rehydrate()` handle for this store. */
|
|
66
68
|
canRehydrate?: boolean;
|
|
69
|
+
/** The state library behind it when it isn't Zustand, like "pinia". */
|
|
70
|
+
library?: string;
|
|
67
71
|
color: string;
|
|
68
72
|
currentState: unknown;
|
|
69
73
|
}
|
|
@@ -65,6 +65,7 @@ declare class ZustandStateStore extends ChangeLog<ZustandStateChange> {
|
|
|
65
65
|
isPersisted?: boolean;
|
|
66
66
|
persistName?: string;
|
|
67
67
|
rehydrate?: () => Promise<void> | void;
|
|
68
|
+
library?: string;
|
|
68
69
|
}): void;
|
|
69
70
|
unregisterStore(name: string): void;
|
|
70
71
|
getStores(): ZustandStoreInfo[];
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";var Tt=Object.defineProperty;var jr=Object.getOwnPropertyDescriptor;var Or=Object.getOwnPropertyNames;var Wr=Object.prototype.hasOwnProperty;var Fr=(e,t)=>{for(var r in t)Tt(e,r,{get:t[r],enumerable:true})},It=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Or(t))!Wr.call(e,n)&&n!==r&&Tt(e,n,{get:()=>t[n],enumerable:!(a=jr(t,n))||a.enumerable});return e},Mr=(e,t,r)=>(It(e,t,"default"),r&&It(r,t,"default"));var $s=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{classifyPreviewItem as Kr,createRestoreScope as Ur,emptyRestoreResult as _r,failedRestore as Zr,registerStateSnapshotProvider as Gr,unionKeys as Jr}from"@buoy-gg/shared-ui/web";import{ChangeLog as Yr,entityColor as qr,formatValuePreview as Qr,shallowDiffSummary as Xr}from"@buoy-gg/shared-ui/web";var ea={counter:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",navigation:"#F97316",form:"#EF4444"};function kt(e){return qr(e,ea)}function ta(e,t=40){return Qr(e,{maxLength:t,undefinedLabel:"",functionLabel:"(updater fn)"})}var ra=class extends Yr{constructor(){super(...arguments);this.stores=new Map;this.storeListeners=new Set;this.remoteSetStateHandler=null}addStateChange(e){if(!this.canRecord())return;let{storeName:t,partial:r,replace:a,prevState:n,nextState:o,duration:s,category:l,isPersisted:i=false}=e,p=n!==o,{summary:d,changedKeys:m,changedCount:b}=Xr(n,o),g=ta(r),y=(s??0)>16,$=l??(a?"replace":"setState"),D={id:this.nextId(),storeName:t,timestamp:Date.now(),prevState:n,nextState:o,partial:r,duration:s,hasStateChange:p,replace:a,category:$,changedKeys:m,changedKeysCount:b,diffSummary:d,partialPreview:g,isSlowUpdate:y,isPersisted:i};this.push(D);let j=this.stores.get(t);j&&j.stateChangeCount++,this.notifyListeners()}getStateChanges(){return this.getAll()}getStateChangeById(e){return this.getById(e)}clearStateChanges(){for(let e of this.stores.values())e.stateChangeCount=0;this.clear(),this.notifyStoreListeners()}replaceStateChanges(e){if(!this.getEnabled())return;for(let r of this.stores.values())r.stateChangeCount=0;let t=e.slice(0,this.max);for(let r of t){let a=this.stores.get(r.storeName);a&&a.stateChangeCount++}this.setItems(t),this.notifyStoreListeners()}getStoreSnapshots(){return Array.from(this.stores.values()).map(e=>{let t;try{t=e.api.getState()}catch{t=void 0}return{name:e.name,stateChangeCount:e.stateChangeCount,isPersisted:e.isPersisted,persistName:e.persistName,canRehydrate:typeof e.rehydrate=="function",color:e.color,currentState:t}})}setRemoteSetStateHandler(e){this.remoteSetStateHandler=e}replaceFromSnapshot(e,t){if(!this.getEnabled())return;let r=new Map;for(let o of this.items){let s=o.prevState;(!s||s.__buoyStateOnDevice!==true)&&r.set(o.id,o)}let a=e.slice(0,this.max).map(o=>{let s=r.get(o.id),l=o.prevState;return s&&l?.__buoyStateOnDevice===true?{...o,prevState:s.prevState,nextState:s.nextState,partial:s.partial}:o}),n=new Map;for(let[o,s]of this.stores)try{let l=s.api.getState(),i=l;(!i||i.__buoyStateOnDevice!==true)&&n.set(o,l)}catch{}this.stores=new Map(t.map(o=>{let s=o.currentState,l=n.get(o.name),i=l!==void 0&&s?.__buoyStateOnDevice===true?l:o.currentState;return[o.name,{name:o.name,api:{getState:()=>i,setState:(p,d)=>{this.remoteSetStateHandler?.(o.name,p,d)},subscribe:()=>()=>{}},stateChangeCount:o.stateChangeCount,isPersisted:o.isPersisted,persistName:o.persistName,color:o.color}]})),this.setItems(a),this.notifyStoreListeners()}hydrateChange(e,t){this.hydrateById(e,t)}hydrateStoreState(e,t){let r=this.stores.get(e);r&&(this.stores.set(e,{...r,api:{...r.api,getState:()=>t}}),this.notifyStoreListeners())}registerStore(e,t,r){if(this.stores.has(e))return;let a={name:e,api:t,stateChangeCount:0,isPersisted:r?.isPersisted??false,persistName:r?.persistName,rehydrate:r?.rehydrate,color:kt(e)};this.stores.set(e,a),this.notifyStoreListeners()}unregisterStore(e){this.stores.delete(e),this.notifyStoreListeners()}getStores(){return Array.from(this.stores.values())}getStore(e){return this.stores.get(e)}getStoreColor(e){return this.stores.get(e)?.color??kt(e)}filterStateChanges(e){let t=this.getAll();if(e.searchText){let r=e.searchText.toLowerCase();t=t.filter(a=>a.storeName.toLowerCase().includes(r)||a.partialPreview.toLowerCase().includes(r)||a.changedKeys.some(n=>n.toLowerCase().includes(r)))}return e.storeNames&&e.storeNames.length>0&&(t=t.filter(r=>e.storeNames.includes(r.storeName))),e.onlyWithChanges&&(t=t.filter(r=>r.hasStateChange)),t}getStats(){let e=this.items.length,t=this.items.filter(o=>o.hasStateChange).length,r=this.stores.size,a=this.items.filter(o=>o.duration!==void 0).map(o=>o.duration),n=a.length>0?a.reduce((o,s)=>o+s,0)/a.length:0;return{totalChanges:e,changesWithStateChange:t,changesWithoutStateChange:e-t,storeCount:r,averageDuration:Math.round(n*100)/100}}getUniqueStoreNames(){return Array.from(this.stores.keys()).sort()}setMaxChanges(e){this.setMax(e)}subscribeToStores(e){return this.storeListeners.add(e),()=>{this.storeListeners.delete(e)}}notifyStoreListeners(){let e=this.getStores();this.storeListeners.forEach(t=>t(e))}},S=new ra;function Z(e){if(typeof e!="object"||e===null||Array.isArray(e))return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ve(e,t,r,a,n){if(typeof e=="function"){r.push(t);return}if(typeof e!="object"||e===null||n>=8)return e;if(a.has(e))return;if(a.add(e),Array.isArray(e))return e.map((s,l)=>typeof s=="function"?(r.push(`${t}[${l}]`),null):ve(s,`${t}[${l}]`,r,a,n+1));if(!Z(e))return e;let o={};for(let[s,l]of Object.entries(e)){if(typeof l=="function"){r.push(t?`${t}.${s}`:s);continue}o[s]=ve(l,t?`${t}.${s}`:s,r,a,n+1)}return o}function Dt(e){if(Z(e)&&e.__buoyStateOnDevice===true)return{data:null,fnPaths:[],blockedReason:"Store state hasn't synced from the device yet."};if(!Z(e))return{data:null,fnPaths:[],blockedReason:"Only stores whose state is a plain object can be edited \u2014 a merge write has nothing to address in "+(Array.isArray(e)?"an array":`a ${typeof e}`)+"."};let t=[],r=ve(e,"",t,new WeakSet,0),a=t.filter(n=>n.includes(".")||n.includes("["));return a.length>0?{data:null,fnPaths:t,blockedReason:`State keeps a function inside "${a[0]}" \u2014 a merge write of that key would drop it, so this store can't be edited here.`}:{data:r,fnPaths:t,blockedReason:null}}function aa(e,t){if(!Z(t))throw new Error("The store's state must stay an object.");let r=Object.keys(e).filter(n=>!(n in t));if(r.length>0)throw new Error(`Can't remove top-level ${r.length===1?"key":"keys"} ${r.map(n=>`"${n}"`).join(", ")} \u2014 zustand merge writes can't delete. Edit the value instead.`);let a={};for(let n of Object.keys(t))(!(n in e)||JSON.stringify(t[n])!==JSON.stringify(e[n]))&&(a[n]=t[n]);return a}var Et=8;function Bt(e,t,r,a){if(!(!Z(t)||!Z(e))&&!(a>=Et||r.has(t))){r.add(t);for(let[n,o]of Object.entries(t))if(typeof o=="function")e[n]=o;else if(Z(o)){if(!Z(e[n])){if(!$t(o,new WeakSet,a+1))continue;e[n]={}}Bt(e[n],o,r,a+1)}}}function $t(e,t,r){if(r>=Et||t.has(e))return false;t.add(e);for(let a of Object.values(e))if(typeof a=="function"||Z(a)&&$t(a,t,r+1))return true;return false}function oa(){return S.getStores().length===0?{canCapture:false,canRestore:false,detail:"No Zustand stores registered \u2014 pass `zustandStores` to FloatingDevTools or add the buoyDevTools middleware"}:{canCapture:true,canRestore:true}}async function na(){let e=[],t={};for(let r of S.getStores()){let a=[],n;try{n=ve(r.api.getState(),"",a,new WeakSet,0)}catch(o){e.push(`store "${r.name}": capture failed (${String(o)})`);continue}t[r.name]={state:n,fnPaths:a}}return{data:{stores:t},warnings:e}}async function sa(e,t){let r=e,a=Ur(t),n=_r();if(!r?.stores)return Zr("empty zustand snapshot");for(let[s,l]of Object.entries(r.stores)){if(!a.allows(s))continue;let i=S.getStore(s);if(!i){n.skipped.push({id:s,reason:"store not registered (renamed, or created after snapshot?)"});continue}try{let p=l.state;Bt(p,i.api.getState(),new WeakSet,0),i.api.setState(p,true),i.api.getState()===p?n.applied+=1:(n.warnings.push(`store "${s}": setState did not take effect`),n.ok=false)}catch(p){n.skipped.push({id:s,reason:String(p)}),n.ok=false}}let o=a.excludedWarning("store(s)");return o&&n.warnings.push(o),n}async function ia(e,t){let r=e?.stores??{},a=t===void 0,n={};if(a)for(let i of S.getStores()){let p=[];try{n[i.name]={state:ve(i.api.getState(),"",p,new WeakSet,0),fnPaths:p}}catch{}}else Object.assign(n,t?.stores??{});let o=[],s=[],l=0;for(let i of Jr(n,r)){let p=i in r,d=i in n;if(!p){a?s.push(`store "${i}" not in snapshot \u2014 untouched`):o.push({key:i,label:i,verdict:"removed",oldValue:n[i].state});continue}if(l+=r[i].fnPaths?.length??0,a&&!S.getStore(i)){o.push({key:i,label:i,verdict:"wont-apply",reason:"store not registered (renamed, or created after snapshot?)"});continue}o.push(Kr({key:i,label:i,oldValue:n[i]?.state,newValue:r[i].state,inOld:d,inNew:true},{tooLargeReason:"store too large to render a diff \u2014 restore still applies it"}))}return l>0&&s.push(`${l} store action function${l===1?"":"s"} preserved on restore (not diffed)`),{items:o,notes:s}}Gr({id:"zustand",label:"Zustand",status:oa,capture:na,restore:sa,previewItems:ia});import{useState as Q,useMemo as te,useRef as $e,useCallback as N,useEffect as Pt}from"react";var Nt={};Fr(Nt,{AccessibilityInfo:()=>ua,ActivityIndicator:()=>ho,Alert:()=>fo,Animated:()=>ha,AppRegistry:()=>pa,AppState:()=>fa,Appearance:()=>ga,BackHandler:()=>ma,Button:()=>go,CheckBox:()=>Na,Clipboard:()=>ya,DeviceEventEmitter:()=>Za,Dimensions:()=>ba,Easing:()=>Sa,FlatList:()=>Ze,I18nManager:()=>Ca,Image:()=>Aa,ImageBackground:()=>La,InteractionManager:()=>xa,Keyboard:()=>wa,KeyboardAvoidingView:()=>Ra,LayoutAnimation:()=>va,Linking:()=>Ta,LogBox:()=>_a,Modal:()=>co,NativeEventEmitter:()=>Ia,NativeModules:()=>ca,PanResponder:()=>ka,Picker:()=>za,PixelRatio:()=>Da,Platform:()=>Ea,Pressable:()=>lo,ProgressBar:()=>Va,RefreshControl:()=>Ha,SafeAreaView:()=>ja,ScrollView:()=>Ie,SectionList:()=>Oa,Share:()=>Ba,StatusBar:()=>Wa,StyleSheet:()=>le,Switch:()=>uo,Text:()=>w,TextInput:()=>no,Touchable:()=>Fa,TouchableHighlight:()=>so,TouchableNativeFeedback:()=>Ma,TouchableOpacity:()=>re,TouchableWithoutFeedback:()=>io,UIManager:()=>$a,Vibration:()=>Pa,View:()=>u,VirtualizedList:()=>Ka,YellowBox:()=>Ua,findNodeHandle:()=>po,unstable_createElement:()=>da,useColorScheme:()=>Ga,useLocaleContext:()=>Ja,useWindowDimensions:()=>Ya});Mr(Nt,la);import*as la from"react-native-web";import{unstable_createElement as da,NativeModules as ca,AccessibilityInfo as ua,Animated as ha,Appearance as ga,AppRegistry as pa,AppState as fa,BackHandler as ma,Clipboard as ya,Dimensions as ba,Easing as Sa,I18nManager as Ca,Keyboard as wa,InteractionManager as xa,LayoutAnimation as va,Linking as Ta,NativeEventEmitter as Ia,PanResponder as ka,PixelRatio as Da,Platform as Ea,Share as Ba,StyleSheet as le,UIManager as $a,Vibration as Pa,CheckBox as Na,FlatList as Ze,Image as Aa,ImageBackground as La,KeyboardAvoidingView as Ra,Picker as za,ProgressBar as Va,RefreshControl as Ha,SafeAreaView as ja,SectionList as Oa,StatusBar as Wa,Touchable as Fa,TouchableNativeFeedback as Ma,VirtualizedList as Ka,YellowBox as Ua,LogBox as _a,DeviceEventEmitter as Za,useColorScheme as Ga,useLocaleContext as Ja,useWindowDimensions as Ya}from"react-native-web";import*as M from"react-native-web";import{createElement as Ge,forwardRef as At,useCallback as qa,useRef as Qa}from"react";import{useEffect as Xa,useState as eo}from"react";import{createPortal as to}from"react-dom";var ro='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as ao}from"react/jsx-runtime";var Te=Symbol.for("@buoy-gg/portal-host"),Lt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function Rt(){let e=document;if(e[Te])return e[Te].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:ro});let r=()=>{let d=document.fullscreenElement,m=d&&d.tagName!=="CANVAS"?d:document.body;t.parentElement!==m&&m.appendChild(t)},a=new Map,n=d=>{(!t.contains(d.target)||!Lt(d.target))&&a.set(d.code||d.key,{key:d.key,code:d.code,location:d.location,keyCode:d.keyCode,which:d.which,altKey:d.altKey,ctrlKey:d.ctrlKey,metaKey:d.metaKey,shiftKey:d.shiftKey})},o=d=>{a.delete(d.code||d.key)},s=()=>a.clear(),l=()=>{let d=[...a.values()];a.clear();for(let m of d)document.dispatchEvent(new KeyboardEvent("keyup",{...m,bubbles:true}))},i=d=>{Lt(d.target)&&d.stopPropagation()},p=d=>d.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",o,true),window.addEventListener("blur",s),t.addEventListener("focusin",l),t.addEventListener("keydown",i),t.addEventListener("keyup",i),t.addEventListener("keypress",i),t.addEventListener("wheel",p,{passive:true}),e[Te]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",o,true),window.removeEventListener("blur",s),t.remove(),delete e[Te]}},t}function oo({children:e}){let[t,r]=eo(null);return Xa(()=>{let a=Rt(),n=document[Te];return n.users++,r(a),()=>{--n.users===0&&n.dispose()}},[]),t?to(ao("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function K(e){let t=At((a,n)=>{let{accessibilityState:o,accessibilityValue:s,...l}=a;for(let i of["busy","checked","disabled","expanded","selected"])o?.[i]!==void 0&&l[`aria-${i}`]===void 0&&(l[`aria-${i}`]=o[i]);for(let[i,p]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[i]!==void 0&&l[`aria-${p}`]===void 0&&(l[`aria-${p}`]=s[i]);return Ge(e,{...l,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var u=K(M.View),w=K(M.Text),no=K(M.TextInput),re=K(M.TouchableOpacity),so=K(M.TouchableHighlight),io=K(M.TouchableWithoutFeedback),lo=K(M.Pressable),Ie=K(M.ScrollView),zt=At((e,t)=>{let r=Qa(null),a=qa(n=>{if(n){let o=n;for(;o.parentElement&&o.parentElement!==document.body;)o=o.parentElement;o.parentElement===document.body&&(r.current=o,Object.assign(o.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Rt().appendChild(o))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return Ge(oo,null,Ge(M.Modal,{...e,ref:a}))});zt.displayName="Modal";var co=K(zt),uo=K(M.Switch),ho=K(M.ActivityIndicator),go=K(M.Button),po=M.findNodeHandle,fo={alert(e,t,r,a){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let o=document.createElement("h2");if(o.textContent=e,o.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(o),t){let p=document.createElement("p");p.textContent=t,p.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(p)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=r?.length?r:[{text:"OK"}],i=()=>{n.close?.(),n.remove()};for(let p of l){let d=document.createElement("button");d.type="button",d.textContent=p.text??"OK",d.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${p.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,d.onclick=()=>{i(),p.onPress?.()},s.appendChild(d)}n.addEventListener("cancel",p=>{p.preventDefault(),a?.cancelable!==false&&(i(),a?.onDismiss?.())}),n.appendChild(s),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{JsModal as mo,ModalHeader as A,TabSelector as yo,macOSColors as bo,night as V,ToolEmptyState as Je,resolveListEmptyState as Vt,Search as So,Filter as Co,Power as wo,Lock as xo,devToolsStorageKeys as vo,ProUpgradeModal as To,PowerToggleButton as Io,ToolbarCopyButton as Ye,ToolbarClearButton as ko,truncatePayload as he,TickProvider as Ht,useLimit as Do,windowDragProps as Eo,EVENT_LIST_PRESET as jt}from"@buoy-gg/shared-ui/web";import{useIsPro as Bo}from"@buoy-gg/license/web";import{useCallback as $o,useMemo as Ot}from"react";import{useChangeLog as Po,useSubscribedValue as No}from"@buoy-gg/shared-ui/web";function Ao(e,t){let r=e;if(t.searchText){let a=t.searchText.toLowerCase();r=r.filter(n=>n.storeName.toLowerCase().includes(a)||n.partialPreview.toLowerCase().includes(a)||n.changedKeys.some(o=>o.toLowerCase().includes(a)))}return t.storeNames&&t.storeNames.length>0&&(r=r.filter(a=>t.storeNames.includes(a.storeName))),t.onlyWithChanges&&(r=r.filter(a=>a.hasStateChange)),r}var Lo=()=>S.getStores(),Ro=e=>S.subscribeToStores(e);function Wt(){let e=Po(S,{filterItems:Ao}),t=No(Lo,Ro),r=Ot(()=>{let o=e.items.length,s=e.items.filter(l=>l.hasStateChange).length;return{totalChanges:o,changesWithStateChange:s,changesWithoutStateChange:o-s,storeCount:t.length,averageDuration:0}},[e.items,t]),a=Ot(()=>S.getUniqueStoreNames(),[t]),n=$o(o=>S.getStateChangeById(o),[]);return{stateChanges:e.items,filteredChanges:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:r,stores:t,clearChanges:S.clearStateChanges.bind(S),isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,storeNames:a,getChangeById:n}}import{memo as zo}from"react";import{ChangeRow as Vo,buoyColors as Ft,night as Ho}from"@buoy-gg/shared-ui/web";import{jsx as jo}from"react/jsx-runtime";function Oo(e,t){switch(e){case"replace":return"Replace";case"persist":return"Hydrate";case"initial":return"Initial";default:return t.charAt(0).toUpperCase()+t.slice(1)}}function Wo(e,t){switch(e){case"replace":return Ft.warning;case"persist":return Ft.info;case"initial":return Ho.color.textTertiary;default:return S.getStoreColor(t)}}function Fo(e){let t=[];return e.duration!==void 0&&e.duration>=.1&&t.push(`${e.duration.toFixed(1)}ms`),e.hasStateChange?e.changedKeysCount>0?t.push(`${e.changedKeysCount} key${e.changedKeysCount>1?"s":""} changed`):t.push(e.diffSummary||"state changed"):t.push("no state change"),t.join(" \xB7 ")}function Mo(e){return e.category==="replace"?"REPLACE":e.category==="persist"?"HYDRATE":e.category==="initial"?"INIT":"SET"}function Ko(e){return e.changedKeys.length>0&&e.changedKeys.length<=3?e.changedKeys.join(", "):e.changedKeys.length>3?`${e.changedKeys.slice(0,2).join(", ")} +${e.changedKeys.length-2}`:e.partialPreview||"setState()"}var Mt=zo(function({change:e,onPress:t,testID:r}){let a=Wo(e.category,e.storeName),n=Oo(e.category,e.storeName),o=Fo(e),s=Ko(e),l=Mo(e);return jo(Vo,{statusColor:a,statusLabel:n,sublabel:o,primaryText:s,timestamp:e.timestamp,badgeText:l,changed:e.hasStateChange,slow:e.isSlowUpdate,onPress:()=>t(e),testID:r})});import{useState as Kt,useCallback as Pe,useMemo as Ut}from"react";import{night as ae,EventStepperFooter as _t,formatRelativeTime as Ne,parseValue as Ae,monoFont as ke}from"@buoy-gg/shared-ui/web";import{DataViewer as Uo,SplitDiffViewer as _o,TreeDiffViewer as Zo,diffThemes as Go}from"@buoy-gg/shared-ui/web/dataViewer";import{memo as Jo}from"react";import{DetailViewToggle as Yo,FileText as qo,Database as Qo,GitBranch as Xo}from"@buoy-gg/shared-ui/web";import{jsx as en}from"react/jsx-runtime";var tn=[{key:"change",label:"CHANGE",description:"View change details",icon:qo},{key:"state",label:"STATE",description:"View current state",icon:Qo},{key:"diff",label:"DIFF",description:"Compare changes",icon:Xo}],rn=["diff"],an=Jo(function({activeView:e,onViewChange:t,diffDisabled:r=false}){return en(Yo,{views:tn,activeView:e,onViewChange:t,disabledKeys:r?rn:void 0,testIDPrefix:"buoy-zustand"})});import{memo as on,useCallback as qe,useState as nn,useEffect as sn}from"react";import{buoyColors as H,night as I,Clock as ln,AlertTriangle as dn,Zap as Zt,Info as cn,Box as Gt,Database as un,parseValue as hn,ProUpgradeModal as gn,copyToClipboard as pn,InfoRow as Jt,monoFont as ge}from"@buoy-gg/shared-ui/web";import{useIsPro as fn}from"@buoy-gg/license/web";import{DataViewer as mn}from"@buoy-gg/shared-ui/web/dataViewer";import{night as B,monoFont as yn}from"@buoy-gg/shared-ui/web";import{jsx as Yt,jsxs as bn}from"react/jsx-runtime";var Sn={copy:{color:B.color.accent,backgroundColor:B.color.accentSoft,borderColor:B.color.accentBorder,textColor:B.color.accent},reset:{color:B.color.warning,backgroundColor:B.color.warningSoft,borderColor:B.color.warning+"40",textColor:B.color.warning},clear:{color:B.color.danger,backgroundColor:B.color.dangerSoft,borderColor:B.color.danger+"40",textColor:B.color.danger},jump:{color:B.color.warning,backgroundColor:B.color.warningSoft,borderColor:B.color.warning+"40",textColor:B.color.warning}};function Qe({onPress:e,text:t,type:r,disabled:a=false,testID:n}){let o=Sn[r];return bn(re,{disabled:a,onPress:e,style:[Xe.button,{backgroundColor:a?B.color.textTertiary+"1A":o.backgroundColor,borderColor:a?B.color.textTertiary+"33":o.borderColor,opacity:a?.5:1}],activeOpacity:.7,testID:n,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:a},children:[Yt(u,{style:[Xe.dot,{backgroundColor:a?B.color.textTertiary:o.color}]}),Yt(w,{style:[Xe.text,{color:a?B.color.textTertiary:o.textColor}],children:t})]})}var Xe=le.create({button:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:6,borderWidth:1,paddingHorizontal:12,paddingVertical:6,height:25,minWidth:80,shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2,elevation:2},dot:{width:5,height:5,borderRadius:3,marginRight:6,shadowColor:B.color.text,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:2},text:{fontSize:10,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:yn,height:12}});var h="buoy-zustand";function et(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Cn(e,t){return`${h}-row-${et(e)}-${t}`}function qt(e){return`${h}-store-${et(e)}`}function wn(e){let t=new Map,r=new Map;for(let a of e){let n=(t.get(a.storeName)??0)+1;t.set(a.storeName,n),r.set(a.id,Cn(a.storeName,n))}return r}import{jsx as x,jsxs as W}from"react/jsx-runtime";function xn(e){switch(e){case"replace":return{label:"REPLACE",color:H.warning,bgColor:H.warning+"26"};case"persist":return{label:"PERSIST",color:H.info,bgColor:H.info+"26"};case"initial":return{label:"INITIAL",color:I.color.textTertiary,bgColor:I.color.textTertiary+"26"};default:return{label:"SET STATE",color:H.success,bgColor:H.success+"26"}}}function vn(e){return e===void 0?"N/A":e<1?"<1ms":`${e.toFixed(1)}ms`}function Le({icon:e,title:t,badge:r,testID:a}){return W(u,{style:C.sectionHeader,testID:a,children:[W(u,{style:C.sectionHeaderLeft,children:[x(e,{size:14,color:I.color.accent}),x(w,{style:C.sectionTitle,children:t})]}),r]})}function Tn(e){let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0"),n=t.getSeconds().toString().padStart(2,"0"),o=t.getMilliseconds().toString().padStart(3,"0");return`${r}:${a}:${n}.${o}`}var In=on(function({change:e}){let t=fn(),[r,a]=nn(false);sn(()=>{r&&t&&a(false)},[r,t]);let n=xn(e.category),o=e.partial!==void 0&&e.partial!=="(updater fn)",s=e.changedKeys.length>0,l=S.getStoreColor(e.storeName),i=qe(async()=>{if(!t){a(true);return}await pn(e.nextState)},[e.nextState,t]),p=qe(()=>{let m=S.getStore(e.storeName);if(m?.api.getInitialState){let b=m.api.getInitialState();m.api.setState(b,true)}},[e.storeName]),d=qe(()=>{let m=S.getStore(e.storeName);m&&m.api.setState(e.nextState,true)},[e.storeName,e.nextState]);return W(Ie,{style:C.container,contentContainerStyle:C.contentContainer,showsVerticalScrollIndicator:false,testID:`${h}-detail-scroll`,children:[W(u,{style:C.card,testID:`${h}-info-card`,children:[x(Le,{icon:cn,title:"CHANGE INFO"}),W(u,{style:C.cardContent,children:[x(Jt,{label:"Store",value:e.storeName,mono:true,valueColor:l,testID:`${h}-info-store`}),x(Jt,{label:"Time",value:Tn(e.timestamp),mono:true,testID:`${h}-info-time`}),W(u,{style:C.badgeRow,children:[x(u,{style:[C.categoryBadge,{backgroundColor:n.bgColor}],children:x(w,{style:[C.categoryText,{color:n.color}],testID:`${h}-info-category`,children:n.label})}),W(u,{style:[C.durationBadge,e.isSlowUpdate&&C.durationBadgeSlow],children:[x(ln,{size:10,color:e.isSlowUpdate?H.error:I.color.textSecondary}),x(w,{style:[C.durationText,e.isSlowUpdate&&C.durationTextSlow],testID:`${h}-info-duration`,children:vn(e.duration)}),e.isSlowUpdate&&x(dn,{size:10,color:H.error})]}),e.hasStateChange?W(u,{style:C.changesBadge,children:[x(Zt,{size:10,color:H.success}),x(w,{style:C.changesText,testID:`${h}-info-changes`,children:e.diffSummary||"changed"})]}):x(u,{style:C.noChangesBadge,children:x(w,{style:C.noChangesText,testID:`${h}-info-no-changes`,children:"no change"})}),e.isPersisted&&W(u,{style:C.persistBadge,children:[x(un,{size:10,color:H.info}),x(w,{style:C.persistText,testID:`${h}-info-persisted`,children:"PERSISTED"})]})]})]})]}),s&&W(u,{style:C.card,testID:`${h}-keys-card`,children:[x(Le,{icon:Zt,title:"CHANGED KEYS",badge:x(u,{style:C.countBadge,children:x(w,{style:C.countText,testID:`${h}-keys-count`,children:e.changedKeys.length})})}),x(u,{style:C.cardContent,children:x(u,{style:C.keysContainer,children:e.changedKeys.map(m=>x(u,{style:C.keyBadge,children:x(w,{style:C.keyText,testID:`${h}-key-${m}`,children:m})},m))})})]}),o&&W(u,{style:C.card,testID:`${h}-partial-card`,children:[x(Le,{icon:Gt,title:"PARTIAL (setState argument)",badge:x(u,{style:C.typeBadge,children:x(w,{style:C.typeText,testID:`${h}-partial-type`,children:Array.isArray(e.partial)?"ARRAY":typeof e.partial=="object"?"OBJECT":(typeof e.partial).toUpperCase()})})}),x(u,{style:C.dataViewerContainer,children:x(mn,{title:"",data:hn(e.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),e.partial==="(updater fn)"&&W(u,{style:C.card,testID:`${h}-updater-card`,children:[x(Le,{icon:Gt,title:"SET STATE CALL"}),W(u,{style:C.cardContent,children:[x(w,{style:C.updaterText,children:"Called with an updater function: set((state) => ...)"}),x(w,{style:C.updaterSubtext,children:"The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."})]})]}),W(u,{style:C.actionsGrid,children:[x(Qe,{type:"jump",text:"JUMP",onPress:d,testID:`${h}-jump`}),x(Qe,{type:"reset",text:"RESET STORE",onPress:p,testID:`${h}-reset`}),x(Qe,{type:"copy",text:"COPY STATE",onPress:i,testID:`${h}-copy-state`})]}),x(gn,{visible:r,onClose:()=>a(false),featureName:"Copy"})]})}),C=le.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:I.color.surface,borderRadius:6,borderWidth:1,borderColor:I.color.accentBorderStrong,overflow:"hidden",shadowColor:I.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:I.color.accentBorder,backgroundColor:I.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:I.color.accent,fontFamily:ge},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:I.color.surfaceElevated},durationBadgeSlow:{backgroundColor:H.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:I.color.textSecondary,fontFamily:ge},durationTextSlow:{color:H.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:H.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:H.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:I.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:I.color.textTertiary},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:H.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:H.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:I.color.accentSoft,borderWidth:1,borderColor:I.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:I.color.accent,fontFamily:ge},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:I.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:I.color.accent,fontFamily:ge},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:I.color.surfaceElevated},typeText:{fontSize:8,fontWeight:"600",color:I.color.textTertiary,fontFamily:ge},dataViewerContainer:{backgroundColor:I.color.bg,minHeight:60},updaterText:{fontSize:12,color:I.color.text,fontFamily:ge},updaterSubtext:{fontSize:11,color:I.color.textTertiary,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});import{DiffModeTabs as kn,CompareBar as Dn}from"@buoy-gg/shared-ui/web";import{jsx as E,jsxs as pe}from"react/jsx-runtime";function tt(e){return S.getStoreColor(e.storeName)}function Qt(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function En(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Xt(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}var Bn=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];function er({change:e,changes:t,selectedIndex:r,onIndexChange:a,disableInternalFooter:n=false,initialView:o="change"}){let[s,l]=Kt(o),[i,p]=Kt("tree"),d=t.length,m=tt(e),b=Qt(e),g=En(Ae(e.nextState)),y=d-r,$=y-1,D=r<d-1?r+1:null,j=D!==null?t[D]:null,O=Ut(()=>({index:D??0,label:$>0?`#${$}`:"Initial",timestamp:j?Xt(j.timestamp):"",relativeTime:j?Ne(new Date(j.timestamp)):"state",badge:j?E(u,{style:[P.changeBadgeSmall,{backgroundColor:`${tt(j)}20`}],children:E(w,{style:[P.changeTextSmall,{color:tt(j)}],children:Qt(j)})}):void 0}),[D,j,$]),me=Ut(()=>({index:r,label:`#${y}`,timestamp:Xt(e.timestamp),relativeTime:Ne(new Date(e.timestamp)),badge:E(u,{style:[P.changeBadgeSmall,{backgroundColor:`${m}20`}],children:E(w,{style:[P.changeTextSmall,{color:m}],children:b})})}),[r,e.timestamp,m,b,y]),oe=Pe(()=>{let ne=Ae(e.nextState);return pe(u,{style:P.contentCard,testID:`${h}-state-card`,children:[pe(u,{style:P.valueHeader,children:[E(w,{style:P.valueLabel,children:"STATE AFTER CHANGE"}),pe(u,{style:P.valueHeaderBadges,children:[E(u,{style:[P.changeBadge,{backgroundColor:`${m}20`}],children:E(w,{style:[P.changeText,{color:m}],children:b})}),E(u,{style:P.typeBadge,children:E(w,{style:P.typeText,testID:`${h}-state-type`,children:g.toUpperCase()})})]})]}),E(u,{style:P.dataViewerContainer,children:E(Uo,{title:"",data:ne,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextState,m,b,g]),ye=Pe(()=>{let ne=Ae(e.prevState),ce=Ae(e.nextState);return i==="split"?E(Ie,{style:{flex:1},showsVerticalScrollIndicator:true,children:E(_o,{oldValue:ne,newValue:ce,theme:Go.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})}):E(Zo,{oldValue:ne,newValue:ce})},[e.prevState,e.nextState,i]),be=Pe(()=>{a(Math.min(d-1,r+1))},[r,d,a]),Se=Pe(()=>{a(Math.max(0,r-1))},[r,a]),J=e.prevState===void 0,Ce=!n&&d>1;return pe(u,{style:P.container,children:[E(an,{activeView:s,onViewChange:l,diffDisabled:J}),pe(u,{style:[P.contentArea,Ce&&P.contentAreaFooterPad],children:[s==="change"&&E(In,{change:e}),s==="state"&&E(u,{style:P.stateContainer,children:oe()}),s==="diff"&&pe(u,{style:P.diffContainer,testID:`${h}-diff`,children:[E(kn,{tabs:Bn,activeTab:i,onTabChange:p,testIDPrefix:`${h}-diff-tab`}),E(Dn,{leftEvent:O,rightEvent:me}),E(u,{style:P.diffContent,testID:`${h}-diff-content`,children:ye()})]})]}),Ce&&E(_t,{currentIndex:y-1,totalItems:d,onPrevious:be,onNext:Se,itemLabel:"Change",subtitle:Ne(new Date(e.timestamp)),absolute:true})]})}function tr({change:e,changes:t,selectedIndex:r,onIndexChange:a}){let n=t.length;if(n<=1)return null;let o=n-r;return E(_t,{currentIndex:o-1,totalItems:n,onPrevious:()=>a(Math.min(n-1,r+1)),onNext:()=>a(Math.max(0,r-1)),itemLabel:"Change",subtitle:Ne(new Date(e.timestamp))})}var P=le.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:ae.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:ae.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:ae.color.textSecondary,fontFamily:ke,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:ke,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:ae.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:ae.color.textTertiary,fontFamily:ke},valueBox:{backgroundColor:ae.color.bg,borderRadius:6,borderWidth:1,borderColor:ae.color.border,padding:8},valueText:{fontSize:12,color:ae.color.text,fontFamily:ke,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:ke},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as $n}from"react";import{CompactRow as Pn,night as rt,ToolEmptyState as at,resolveListEmptyState as Nn,monoFont as rr}from"@buoy-gg/shared-ui/web";import{jsx as G,jsxs as ot}from"react/jsx-runtime";function An(e){try{let t=e.api.getState();if(t&&typeof t=="object"&&t.__buoyStateOnDevice===true)return"on device";if(t&&typeof t=="object"){let r=Object.keys(t).filter(a=>typeof t[a]!="function");return r.length===0?"no data keys":r.length<=3?r.join(", "):`${r.slice(0,2).join(", ")} +${r.length-2}`}return""}catch{return""}}function Ln(){return G(at,{testID:`${h}-stores-loading`,otto:"loading",title:"Loading stores\u2026",message:"Waiting for the device to send its registered stores."})}function Rn(){return G(at,{testID:`${h}-stores-empty`,otto:"scanning",title:"No stores registered",message:`Use watchStores() to register your Zustand stores.
|
|
2
|
-
They will appear here with their current state.`})}function zn({stores:e,searchQuery:t,isLoading:r=false,onOpenStore:a}){let n=$n(()=>{if(!t)return e;let o=t.toLowerCase();return e.filter(s=>s.name.toLowerCase().includes(o)||s.persistName&&s.persistName.toLowerCase().includes(o))},[e,t]);return n.length===0&&!t?r?G(Ln,{}):G(Rn,{}):n.length===0&&t?G(at,{testID:`${h}-stores-no-match`,...Nn({subject:"stores",verb:"registered",search:t,total:e.length,waiting:{otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores."}})}):ot(Ie,{style:X.container,contentContainerStyle:X.scrollContent,showsVerticalScrollIndicator:true,testID:`${h}-stores-scroll`,children:[ot(u,{style:X.sectionHeader,children:[G(w,{style:X.sectionTitle,children:"STORES"}),G(u,{style:X.sectionCountBadge,children:G(w,{style:X.sectionCountText,testID:`${h}-stores-count`,children:n.length})})]}),n.map(o=>{let s=An(o),l=S.getStoreColor(o.name),i=qt(o.name);return ot(u,{style:X.storeRowWrapper,children:[G(Pn,{statusDotColor:l,statusLabel:o.isPersisted?"persisted":"in-memory",primaryText:o.name,secondaryText:s||void 0,showChevron:true,onPress:()=>a(o.name),testID:i,statusTestID:`${i}-backing`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-keys`}),o.stateChangeCount>0&&G(u,{style:[X.absCountBadge,{backgroundColor:l+"22",borderColor:l+"55"}],pointerEvents:"none",children:G(w,{style:[X.absCountText,{color:l}],testID:`${i}-count`,children:String(o.stateChangeCount)})})]},o.name)})]})}var X=le.create({container:{flex:1},storeRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:rr},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:rt.color.textTertiary},sectionCountBadge:{backgroundColor:rt.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:rt.color.accent,fontFamily:rr}});import{useCallback as Vn,useEffect as Hn,useMemo as nt,useState as Re}from"react";import{buoyColors as st,Database as jn,ExpandedInfoRow as ze,FileJson as On,night as L,PillBadge as it,parseValue as ar,monoFont as Ve}from"@buoy-gg/shared-ui/web";import{DataViewer as Wn,LiveExplorer as Fn,ValueEditModal as Mn,updateNestedDataByPath as Kn,deleteNestedDataByPath as Un}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as or,jsx as v,jsxs as U}from"react/jsx-runtime";var _n=300,de=`${h}-detail`;function Zn(e){let t=r=>r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${de}-explorer-root`:`${de}-explorer-${e.map(t).filter(Boolean).join("-")}`}function Gn({store:e,onViewHistory:t}){let r=qt(e.name),[a,n]=Re(0);Hn(()=>e.api.subscribe(()=>n(b=>b+1)),[e.api]);let o=e.api.getState(),s=nt(()=>Dt(o),[o,a]),[l,i]=Re(false),p=nt(()=>{if(s.data!==null)return{update:(b,g)=>{let y=e.api.getState();if(!Z(y)||b.length===0)return;let $=b[0],D=b.length===1?g:Kn(y[$],b.slice(1),g);e.api.setState({[$]:D},false)},remove:b=>{let g=e.api.getState();if(!Z(g)||b.length<=1)return;let y=b[0],$=Un(g[y],b.slice(1));e.api.setState({[y]:$},false)},canRemove:b=>b.length>1}},[e.api,s.data===null]),d=Vn(b=>{let g=Dt(e.api.getState());if(g.data===null)return;let y=aa(g.data,b);Object.keys(y).length>0&&e.api.setState(y,false),i(false)},[e.api]),m=nt(()=>{if(o&&typeof o=="object"){let b={};for(let[g,y]of Object.entries(o))typeof y!="function"&&(b[g]=y);return ar(b)}return ar(o)},[o,a]);return U(u,{style:T.root,children:[U(Ie,{testID:`${de}-scroll`,style:T.scroll,contentContainerStyle:T.scrollContent,keyboardShouldPersistTaps:"handled",children:[v(u,{style:T.section,children:U(u,{style:T.editorContainer,children:[U(u,{style:T.sectionHeaderRow,children:[v(w,{testID:`${de}-editor-header`,style:T.sectionHeaderText,children:"State Editor"}),s.data!==null?U(re,{onPress:()=>i(true),testID:`${de}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:T.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[v(On,{size:13,color:L.color.accent}),v(w,{style:T.rawButtonText,children:"Raw"})]}):null]}),v(u,{style:T.sectionBody,children:s.data!==null?U(or,{children:[v(Fn,{editable:true,label:"State",value:s.data,defaultExpanded:["State"],writer:p,dataVersion:a,testIDForPath:Zn,debounceMs:_n}),v(w,{style:T.editorHint,children:"Edits write into the live store as you make them \u2014 merged, so the store's actions and untouched keys survive."})]}):v(w,{style:T.blockedText,testID:`${de}-edit-blocked`,children:s.blockedReason})})]})}),v(u,{style:T.section,children:U(u,{style:T.infoContainer,children:[v(w,{style:T.sectionHeaderTextPlain,children:"Store Details"}),U(u,{style:T.infoBody,children:[v(ze,{label:"Type",children:v(it,{color:e.color,testID:`${r}-type`,children:"ZUSTAND"})}),U(ze,{label:"Backing",children:[v(it,{color:st.info,icon:e.isPersisted?v(jn,{size:9,color:st.info}):void 0,testID:`${r}-persist`,children:e.isPersisted?e.persistName||"persisted":"in-memory"}),e.isPersisted?v(Jn,{store:e,rowID:r}):null]}),e.stateChangeCount>0&&U(ze,{label:"Changes",children:[v(it,{color:st.warning,testID:`${r}-changes`,children:String(e.stateChangeCount)}),v(re,{onPress:()=>t(e.name),style:T.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${r}-history`,accessibilityRole:"button",accessibilityLabel:`View ${e.name} history`,children:v(w,{style:[T.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]}),s.fnPaths.length>0&&v(ze,{label:"Actions",children:v(w,{style:T.actionsText,testID:`${de}-actions`,numberOfLines:2,children:s.fnPaths.join(" \xB7 ")})})]})]})}),v(u,{style:T.section,children:U(u,{style:T.infoContainer,children:[v(w,{style:T.sectionHeaderTextPlain,children:"State Explorer"}),v(u,{style:T.viewerBody,testID:`${r}-state`,children:m&&typeof m=="object"?v(Wn,{title:"",data:m,showTypeFilter:true,rawMode:true,initialExpanded:false}):v(w,{style:T.blockedText,children:"Empty state"})})]})})]}),l&&s.data!==null?v(Mn,{path:[],value:s.data,onSave:b=>{try{d(b)}catch{}},onCancel:()=>i(false),saveLabel:"Apply",testIDPrefix:`${h}-value`}):null]})}function Jn({store:e,rowID:t}){let[r,a]=Re(false),[n,o]=Re(null);return e.rehydrate?U(or,{children:[v(re,{onPress:()=>{a(true),o(null),(async()=>{try{await e.rehydrate?.()}catch(s){o(s instanceof Error?s.message:String(s))}finally{a(false)}})()},disabled:r,style:T.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${t}-reread`,accessibilityRole:"button",accessibilityLabel:`Re-read ${e.name} from storage`,children:v(w,{style:[T.inlineLinkText,{color:e.color}],children:r?"re-reading\u2026":"re-read saved value \u2192"})}),n?v(w,{style:[T.inlineLinkText,{color:L.color.danger}],children:n}):null]}):null}var T=le.create({root:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8,paddingBottom:24},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:L.color.surface,borderRadius:6,borderWidth:1,borderColor:L.color.accent+"4D",overflow:"hidden",shadowColor:L.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:L.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:L.color.accent+"33"},sectionHeaderText:{fontWeight:"600",fontSize:12,color:L.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:Ve},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:L.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:L.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:L.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:L.color.surface,borderRadius:6,borderWidth:1,borderColor:L.color.border,overflow:"hidden"},sectionHeaderTextPlain:{backgroundColor:L.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:L.color.textSecondary,borderBottomWidth:1,borderBottomColor:L.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:Ve},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:L.color.bg,minHeight:60},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:Ve},actionsText:{flex:1,color:L.color.textSecondary,fontSize:10,fontFamily:Ve,lineHeight:15}});import{useMemo as Yn}from"react";import{EntityFilterView as qn}from"@buoy-gg/shared-ui/web";import{jsx as Qn}from"react/jsx-runtime";var Xn=["\u2022 auth \u2192 hides authStore from stores & events","\u2022 temp \u2192 hides tempStore, tempUserStore","\u2022 cart \u2192 hides cartStore from both tabs"];function es({ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,stores:a}){let n=Yn(()=>a.map(o=>({name:o.name,color:S.getStoreColor(o.name)})),[a]);return Qn(qn,{entities:n,ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,entityNoun:"STORES",entitySingular:"store",entityKey:"store",testIDPrefix:h,slug:et,howItWorks:"Patterns hide matching stores from both the Stores tab and the Events tab. Tap a store above to quickly add it as a filter.",examples:Xn})}import{Fragment as nr,jsx as f,jsxs as F}from"react/jsx-runtime";function ts({isEnabled:e,searchText:t,totalChanges:r}){let a=Vt({subject:"changes",search:t,total:r,capturing:e,waiting:{otto:"waiting",title:"No state changes",message:"State changes will appear here as stores update."},paused:{title:"No state changes",message:"Enable capture to start recording state changes"}});return f(Je,{...a,testID:`${h}-empty`})}function He({visible:e,onClose:t,onBack:r,onMinimize:a,enableSharedModalDimensions:n=false,inline:o=false,storesLoading:s=false,initialTab:l="stores",initialSelectedChangeId:i,initialDetailView:p,onChangeSelect:d,onStoreExpand:m}){let b=Bo(),g=Do("zustand.changes"),[y,$]=Q(false),[D,j]=Q(l),[O,me]=Q(null),[oe,ye]=Q(null),[be,Se]=Q(false),[J,Ce]=Q(new Set),{stateChanges:ne,filteredChanges:ce,filter:Es,setFilter:we,stats:hr,stores:xe,clearChanges:gr,isEnabled:De,toggleCapture:pr}=Wt(),Y=te(()=>J.size===0?ce:ce.filter(c=>!Array.from(J).some(k=>c.storeName.toLowerCase().includes(k.toLowerCase()))),[ce,J]),ue=te(()=>J.size===0?xe:xe.filter(c=>!Array.from(J).some(k=>c.name.toLowerCase().includes(k.toLowerCase()))),[xe,J]),fr=te(()=>O?ne.filter(c=>c.storeName===O).length:0,[ne,O]),Ee=te(()=>O?Y.filter(c=>c.storeName===O):Y,[Y,O]),Me=te(()=>Ee.slice(0,g),[Ee,g]),Ke=te(()=>Math.max(0,Ee.length-g),[Ee.length,g]),mr=Ke>0,z=Me,[Ue,se]=Q(null),ie=te(()=>{if(Ue===null)return null;let c=z.findIndex(k=>k.id===Ue);return c>=0?c:null},[Ue,z]),_=ie!==null?z[ie]:null,ct=$e(null);Pt(()=>{if(!d)return;let c=_?.id??null;c===null||c===ct.current||(ct.current=c,d(_))},[_,d]);let ut=$e(null);Pt(()=>{!i||ut.current===i||!z.some(c=>c.id===i)||(ut.current=i,se(i))},[i,z]);let[ee,_e]=Q(""),[yr,Be]=Q(false),Bs=$e(null),br=$e(null),Sr=N(c=>{},[]),Cr=c=>{_e(c),D==="events"&&we(k=>({...k,searchText:c}))},wr=N(()=>{_e(""),we(c=>({...c,searchText:""})),Be(false)},[we]),ht=N(c=>{se(c.id)},[]),xr=N(()=>{$(true)},[]),vr=N(()=>{se(null)},[]),gt=N(c=>{let k=z[c];k&&se(k.id)},[z]),Tr=N(c=>{me(c),se(null)},[]),Ir=N(()=>{me(null),se(null)},[]),kr=N(c=>{ye(c),m?.(c)},[m]),Dr=N(()=>{ye(null)},[]),Er=N(()=>ue.reduce((c,k)=>{try{let q=k.api.getState();if(q&&typeof q=="object"){let xt={};for(let[Hr,vt]of Object.entries(q))typeof vt!="function"&&(xt[Hr]=he(vt));c[k.name]=xt}else c[k.name]=he(q)}catch{c[k.name]=null}return c},{}),[ue]),Br=N(()=>Y.map(c=>({id:c.id,storeName:c.storeName,timestamp:c.timestamp,prevState:he(c.prevState),nextState:he(c.nextState),hasStateChange:c.hasStateChange,changedKeys:c.changedKeys})),[Y]),$r=N(()=>z.map(c=>({id:c.id,storeName:c.storeName,timestamp:c.timestamp,prevState:he(c.prevState),nextState:he(c.nextState),hasStateChange:c.hasStateChange,changedKeys:c.changedKeys})),[z]),Pr=N(c=>{Ce(k=>{let q=new Set(k);return q.has(c)?q.delete(c):q.add(c),q})},[]),Nr=N(c=>{Ce(k=>new Set([...k,c]))},[]),Ar=N(c=>{j(c),me(null),ye(null),se(null),Se(false),ee&&(_e(""),we(k=>({...k,searchText:""}))),Be(false)},[ee,we]),pt=N(c=>c.id,[]),ft=te(()=>wn(z),[z]),mt=N(({item:c})=>f(Mt,{change:c,onPress:ht,testID:ft.get(c.id)}),[ht,ft]),yt=J.size>0,bt=()=>be?F(A,{children:[f(A.Navigation,{onBack:()=>Se(false)}),f(A.Content,{title:"Filters",centered:true,testID:`${h}-filters-title`})]}):_?F(A,{children:[f(A.Navigation,{onBack:vr}),f(A.Content,{title:`${_.storeName}/setState`,centered:true,testID:`${h}-detail-title`})]}):O?F(A,{children:[f(A.Navigation,{onBack:Ir}),f(A.Content,{title:`${O} History`,centered:true,testID:`${h}-history-title`}),f(A.Actions,{children:f(Ye,{value:$r,disabled:z.length===0,buttonStyle:R.headerActionButton,testID:`${h}-copy`})})]}):oe?F(A,{children:[f(A.Navigation,{onBack:Dr}),f(A.Content,{title:oe,centered:true,testID:`${h}-store-detail-title`})]}):F(A,{children:[r&&f(A.Navigation,{onBack:r}),f(A.Content,{title:"",children:yr?f(A.Search,{value:ee,onChangeText:Cr,onCancel:wr,placeholder:D==="stores"?"Search stores...":"Search events...",accessibilityLabel:"Search Zustand stores and events",iconSize:14,testID:`${h}-search-field`,containerTestID:`${h}-search`,clearTestID:`${h}-search-clear`,onBlur:()=>{ee.length===0&&Be(false)}}):f(yo,{tabs:[{key:"stores",label:`Stores${ue.length>0?` (${ue.length})`:""}`},{key:"events",label:`Events${Y.length>0?` (${Y.length})`:""}`}],activeTab:D,onTabChange:Ar,testIDPrefix:`${h}-tab`})}),F(A.Actions,{children:[f(re,{onPress:()=>Be(true),style:R.headerActionButton,testID:`${h}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:f(So,{size:14,color:V.color.textSecondary})}),f(re,{onPress:()=>Se(true),style:[R.headerActionButton,yt&&R.headerActionButtonActive],testID:`${h}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:f(Co,{size:14,color:yt?V.color.accent:V.color.textSecondary})}),D==="stores"&&f(Ye,{value:Er,disabled:ue.length===0,buttonStyle:R.headerActionButton,testID:`${h}-copy`}),D==="events"&&F(nr,{children:[f(Ye,{value:Br,disabled:Y.length===0,buttonStyle:R.headerActionButton,testID:`${h}-copy`}),f(Io,{isEnabled:De,onToggle:pr,accessibilityLabel:"Toggle Zustand state capture",testID:`${h}-power`}),f(ko,{onPress:gr,disabled:Y.length===0,buttonStyle:R.headerActionButton,testID:`${h}-clear`})]})]})]}),Lr=()=>{if(be)return f(es,{ignoredPatterns:J,onTogglePattern:Pr,onAddPattern:Nr,stores:xe});if(_&&ie!==null)return f(er,{change:_,changes:z,selectedIndex:ie,onIndexChange:gt,disableInternalFooter:true,initialView:p});if(O)return z.length>0?f(Ze,{testID:`${h}-history-list`,data:z,renderItem:mt,keyExtractor:pt,contentContainerStyle:R.listContent,showsVerticalScrollIndicator:true,...jt}):f(Je,{testID:`${h}-history-empty`,...Vt({subject:"changes",search:ee,total:ee.trim()?fr:0,capturing:De,waiting:{otto:"waiting",title:"No history yet",message:`State changes for ${O} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${O}.`}})});if(oe){let c=xe.find(k=>k.name===oe)??null;return c?f(Gn,{store:c,onViewHistory:Tr}):f(Je,{testID:`${h}-store-detail-gone`,otto:"ghost",title:"Store no longer registered",message:`${oe} is not in the registry any more.`})}return D==="stores"?f(zn,{stores:ue,searchQuery:ee,isLoading:s,onOpenStore:kr}):F(nr,{children:[!De&&F(u,{style:R.disabledBanner,testID:`${h}-banner-disabled`,children:[f(wo,{size:14,color:V.color.warning}),f(w,{style:R.disabledText,children:"State capture is disabled"})]}),mr&&F(re,{style:R.lockedBanner,onPress:xr,activeOpacity:.8,testID:`${h}-locked`,accessibilityRole:"button",children:[f(xo,{size:14,color:V.color.accent}),F(w,{style:R.lockedText,testID:`${h}-locked-text`,children:[Ke," older"," ",Ke===1?"change":"changes"," locked"]}),f(u,{style:R.upgradeBadge,children:f(w,{style:R.upgradeBadgeText,children:"UPGRADE"})})]}),Me.length>0?f(Ze,{ref:br,testID:`${h}-list`,data:Me,renderItem:mt,keyExtractor:pt,contentContainerStyle:R.listContent,showsVerticalScrollIndicator:true,...jt}):f(ts,{isEnabled:De,searchText:ee,totalChanges:hr.totalChanges})]})},Rr=n?vo.modal.root():"buoy-zustand-modal";if(!e)return null;let St=_&&ie!==null?f(tr,{change:_,changes:z,selectedIndex:ie,onIndexChange:gt}):null,zr=_&&z.length>1?68:0,Vr=!be&&(_&&ie!==null||O!=null||D==="events"||D==="stores"),Ct=f(u,{style:R.container,children:Lr()}),wt=f(To,{visible:y,onClose:()=>$(false),featureName:"Full State History"});return o?F(Ht,{children:[F(u,{style:R.inlineRoot,children:[f(u,{style:R.inlineHeader,...Eo,children:bt()}),Ct,St]}),wt]}):F(Ht,{children:[f(mo,{visible:e,onClose:t,onMinimize:a,persistenceKey:Rr,header:{showToggleButton:true,customContent:bt()},onModeChange:Sr,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Vr,styles:{},footer:St,footerHeight:zr,children:Ct}),wt]})}function rs(e={}){return f(He,{...e,inline:true,visible:true,onClose:()=>{}})}var R=le.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:bo.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:V.color.buttonSurface,borderWidth:1,borderColor:V.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:V.color.accentSoft,borderColor:V.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:V.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:V.color.warning+"20"},disabledText:{color:V.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:V.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:V.color.accentBorder},lockedText:{color:V.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:V.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:V.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});import{ZustandIcon as lt,ZUSTAND_ICON_COLOR as as}from"@buoy-gg/shared-ui/web";import{jsx as sr}from"react/jsx-runtime";var os={id:"zustand",name:"ZUSTAND",description:"Zustand store & state inspector",slot:"both",icon:({size:e})=>sr(lt,{size:e}),component:He,props:{enableSharedModalDimensions:false}};function ns(e){return{id:e?.id||"zustand",name:e?.name||"ZUSTAND",description:e?.description||"Zustand store & state inspector",slot:"both",icon:({size:t})=>sr(lt,{size:t,color:e?.iconColor}),component:He,props:{enableSharedModalDimensions:e?.enableSharedModalDimensions!==void 0?e.enableSharedModalDimensions:false}}}var fe=Symbol.for("@@buoy-zustand/watched");function ir(e){let t=e.persist;return t&&typeof t.getOptions=="function"?{isPersisted:true,persistName:t.getOptions()?.name,persistApi:t}:{isPersisted:false}}function ss(e){let t=[];for(let[r,a]of Object.entries(e)){let n=a;if(n[fe])continue;n[fe]=true;let{isPersisted:o,persistName:s,persistApi:l}=ir(a);S.registerStore(r,{getState:a.getState,getInitialState:a.getInitialState,setState:a.setState,subscribe:a.subscribe},{isPersisted:o,persistName:s,rehydrate:typeof l?.rehydrate=="function"?()=>l.rehydrate():void 0});let i=false,p=a.subscribe((d,m)=>{try{let b;if(!i&&o){let g=false;try{g=l?.hasHydrated?.()===false}catch{}g&&(i=true,b="persist")}S.addStateChange({storeName:r,partial:void 0,replace:false,prevState:m,nextState:d,duration:void 0,category:b,isPersisted:o})}catch{}});t.push(()=>{p(),delete a[fe],S.unregisterStore(r)})}return()=>{t.forEach(r=>r())}}var is=0;function ls(e,t){return(r,a,n)=>{let o=t?.name??`store-${++is}`,s=t?.enabled!==false,l=r,i=(d,m)=>{if(!s)return l(d,m);let b=performance.now(),g=a();l(d,m);let y=a(),$=performance.now()-b,D=typeof d=="function"?"(updater fn)":d;S.addStateChange({storeName:o,partial:D,replace:m??false,prevState:g,nextState:y,duration:$,isPersisted:S.getStore(o)?.isPersisted??false})},p=e(i,a,n);return setTimeout(()=>{if(n[fe])return;n[fe]=true;let{isPersisted:d,persistName:m}=ir(n);S.registerStore(o,{getState:a,getInitialState:n.getInitialState,setState:i,subscribe:n.subscribe},{isPersisted:d,persistName:m})},0),p}}function ds(e){return e[fe]===true}import{expandKeyedArrays as cs,patchFromPath as us,readPath as hs,refusalText as gs,shapeSummary as je,suggestedPatch as dt,typedEditViolations as ps,unshapedLists as fs}from"@buoy-gg/shared-ui/web";import{WIRE_DETAIL_LIMIT_BYTES as lr,createSyncAdapter as ms,detailByIdAction as ys,isJsonSerializable as bs,isOverWireBudget as Ss,memoByIdentity as Cs,onDeviceMarker as dr,readParams as Oe,toWire as cr,truncatedNote as ws}from"@buoy-gg/shared-ui/web";var We=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype;function ur(e,t){if(!We(e)||!We(t))return t;let r={...e};for(let[a,n]of Object.entries(t))r[a]=a in e?ur(e[a],n):n;return r}var Fe=dr("State","State trees stay on the device \u2014 fetched on demand via getChangeDetail / getStoreState."),xs=dr("Payload","Partial stays on the device \u2014 fetched on demand via getChangeDetail.");function vs(e,t){let r=e;for(let a of t.split(".")){if(!r||typeof r!="object"||Array.isArray(r)||!(a in r))return false;r=r[a]}return Array.isArray(r)?r.length>0:!!r&&typeof r=="object"}function Ts(e){return e&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e):void 0}var Is=Cs(e=>({...e,prevState:Fe,nextState:Fe,partial:cr(e.partial,xs)})),ks=e=>cr(e,Fe),Ds=ms({version:2,getSnapshot:()=>({changes:S.getStateChanges().map(Is),stores:S.getStoreSnapshots().map(e=>({...e,currentState:ks(e.currentState)}))}),subscribe:[e=>S.subscribe(e),e=>S.subscribeToStores(e)],actions:{clearEvents:()=>{S.clearStateChanges()},getChangeDetail:ys(e=>S.getStateChangeById(e),(e,t)=>({prevState:t(e.prevState),nextState:t(e.nextState),partial:t(e.partial)})),getStoreState:e=>{let{storeName:t,path:r}=Oe(e);if(!t)return{found:false,reason:"missing storeName"};let a=S.getStore(t);if(!a)return{found:false,reason:"unknown storeName"};let n;try{n=a.api.getState()}catch{n=void 0}if(r){let s=hs(n,r);return s.ok?{found:true,storeName:t,path:r,shape:je(s.value),currentState:s.value}:{found:false,reason:s.error}}let o=je(n);return Ss(n,lr)?{found:true,storeName:t,...o?{shape:o}:{},currentState:bs(n)?ws(lr):Fe}:{found:true,storeName:t,...o?{shape:o}:{},currentState:n}},listStores:e=>{let{includeValues:t=false,limit:r}=Oe(e),a=S.getStoreSnapshots(),n=(typeof r=="number"&&r>0?a.slice(0,r):a).map(o=>({name:o.name,changes:o.stateChangeCount,isPersisted:o.isPersisted,persistName:o.persistName,canRehydrate:o.canRehydrate,...t?{currentState:o.currentState}:{keys:Ts(o.currentState)},...je(o.currentState)?{shape:je(o.currentState)}:{}}));return{stores:n,total:a.length,returned:n.length,includedValues:t}},setState:e=>{let{storeName:t,state:r,replace:a,force:n,path:o,value:s}=Oe(e),l=r,i=[],p=[];if(!t)return{ok:false,error:"Missing storeName."};let d=S.getStore(t);if(!d)return{ok:false,error:`No store named "${t}".`};if(r===void 0&&o===void 0)return{ok:false,error:"Refused: no change was described. Send `state` with the fields to merge, or `path` and `value` to set one value."};let m=false;if(o!==void 0){if(s===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${o}" to; if you mean to clear it, send value:null and the field must already be nullable.`};let g;try{g=d.api.getState()}catch{g=void 0}let y=us(g,o,s);if(!y.ok)return{ok:false,error:`Refused: ${y.error}`};l=y.patch,m=true}if(!n&&(a===false||m)){let g;try{g=d.api.getState()}catch{g=void 0}if(g!==void 0){let y=cs(g,l);if(y.error)return{ok:false,error:`Refused: ${y.error}`};l=y.patch,i=y.notes}if(g!==void 0&&(p=fs(g).filter(y=>vs(l,y))),g!==void 0){let y=ps(g,l,{noun:"store"});if(y.length>0)return{ok:false,error:gs(y,"store",dt(l,y)),...dt(l,y)?{suggestedState:dt(l,y)}:{},violations:y}}}let b=m||a===false;if(b){let g;try{g=d.api.getState()}catch{g=void 0}if(We(g)&&We(l)){let y={};for(let[$,D]of Object.entries(l))y[$]=$ in g?ur(g[$],D):D;l=y}}return d.api.setState(l,b?false:a??true),{ok:true,...o!==void 0?{path:o}:{},...i.length?{keyed:i}:{},...p.length?{unchecked:p.map(g=>`\`${g}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the app renders a field you left out, it will render undefined \u2014 read the store back and compare against how the screen uses it.`)}:{}}},rehydrate:async e=>{let{storeName:t}=Oe(e);if(!t)return{ok:false,error:"Missing storeName."};let r=S.getStore(t);return r?r.isPersisted?r.rehydrate?(await r.rehydrate(),{ok:true,storeName:t,persistName:r.persistName}):{ok:false,error:`"${t}" is persisted but Buoy has no rehydrate handle for it. It was probably registered before the app's persist middleware attached.`}:{ok:false,error:`"${t}" is not a persisted store \u2014 it has no saved copy to re-read.`}:{ok:false,error:`No store named "${t}".`}}}});export{as as ZUSTAND_ICON_COLOR,lt as ZustandIcon,He as ZustandModal,Mt as ZustandStateChangeItem,er as ZustandStateDetailContent,tr as ZustandStateDetailFooter,rs as ZustandToolView,ls as buoyDevTools,ns as createZustandTool,ds as isStoreInstrumented,Wt as useZustandStateChanges,ss as watchStores,S as zustandStateStore,Ds as zustandSyncAdapter,os as zustandToolPreset};
|
|
1
|
+
"use client";var Dt=Object.defineProperty;var Mr=Object.getOwnPropertyDescriptor;var Kr=Object.getOwnPropertyNames;var Ur=Object.prototype.hasOwnProperty;var Zr=(e,t)=>{for(var r in t)Dt(e,r,{get:t[r],enumerable:true})},$t=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Kr(t))!Ur.call(e,n)&&n!==r&&Dt(e,n,{get:()=>t[n],enumerable:!(a=Mr(t,n))||a.enumerable});return e},_r=(e,t,r)=>($t(e,t,"default"),r&&$t(r,t,"default"));var zs=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{classifyPreviewItem as Gr,createRestoreScope as Jr,emptyRestoreResult as Yr,failedRestore as qr,registerStateSnapshotProvider as Qr,unionKeys as Xr}from"@buoy-gg/shared-ui/web";import{ChangeLog as ea,entityColor as ta,formatValuePreview as ra,shallowDiffSummary as aa}from"@buoy-gg/shared-ui/web";var oa={counter:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",navigation:"#F97316",form:"#EF4444"};function Et(e){return ta(e,oa)}function na(e,t=40){return ra(e,{maxLength:t,undefinedLabel:"",functionLabel:"(updater fn)"})}var sa=class extends ea{constructor(){super(...arguments);this.stores=new Map;this.storeListeners=new Set;this.remoteSetStateHandler=null}addStateChange(e){if(!this.canRecord())return;let{storeName:t,partial:r,replace:a,prevState:n,nextState:o,duration:s,category:d,isPersisted:i=false}=e,f=n!==o,{summary:l,changedKeys:u,changedCount:b}=aa(n,o),p=na(r),y=(s??0)>16,B=d??(a?"replace":"setState"),D={id:this.nextId(),storeName:t,timestamp:Date.now(),prevState:n,nextState:o,partial:r,duration:s,hasStateChange:f,replace:a,category:B,changedKeys:u,changedKeysCount:b,diffSummary:l,partialPreview:p,isSlowUpdate:y,isPersisted:i};this.push(D);let j=this.stores.get(t);j&&j.stateChangeCount++,this.notifyListeners()}getStateChanges(){return this.getAll()}getStateChangeById(e){return this.getById(e)}clearStateChanges(){for(let e of this.stores.values())e.stateChangeCount=0;this.clear(),this.notifyStoreListeners()}replaceStateChanges(e){if(!this.getEnabled())return;for(let r of this.stores.values())r.stateChangeCount=0;let t=e.slice(0,this.max);for(let r of t){let a=this.stores.get(r.storeName);a&&a.stateChangeCount++}this.setItems(t),this.notifyStoreListeners()}getStoreSnapshots(){return Array.from(this.stores.values()).map(e=>{let t;try{t=e.api.getState()}catch{t=void 0}return{name:e.name,stateChangeCount:e.stateChangeCount,isPersisted:e.isPersisted,persistName:e.persistName,canRehydrate:typeof e.rehydrate=="function",library:e.library,color:e.color,currentState:t}})}setRemoteSetStateHandler(e){this.remoteSetStateHandler=e}replaceFromSnapshot(e,t){if(!this.getEnabled())return;let r=new Map;for(let o of this.items){let s=o.prevState;(!s||s.__buoyStateOnDevice!==true)&&r.set(o.id,o)}let a=e.slice(0,this.max).map(o=>{let s=r.get(o.id),d=o.prevState;return s&&d?.__buoyStateOnDevice===true?{...o,prevState:s.prevState,nextState:s.nextState,partial:s.partial}:o}),n=new Map;for(let[o,s]of this.stores)try{let d=s.api.getState(),i=d;(!i||i.__buoyStateOnDevice!==true)&&n.set(o,d)}catch{}this.stores=new Map(t.map(o=>{let s=o.currentState,d=n.get(o.name),i=d!==void 0&&s?.__buoyStateOnDevice===true?d:o.currentState;return[o.name,{name:o.name,api:{getState:()=>i,setState:(f,l)=>{this.remoteSetStateHandler?.(o.name,f,l)},subscribe:()=>()=>{}},stateChangeCount:o.stateChangeCount,isPersisted:o.isPersisted,persistName:o.persistName,color:o.color}]})),this.setItems(a),this.notifyStoreListeners()}hydrateChange(e,t){this.hydrateById(e,t)}hydrateStoreState(e,t){let r=this.stores.get(e);r&&(this.stores.set(e,{...r,api:{...r.api,getState:()=>t}}),this.notifyStoreListeners())}registerStore(e,t,r){if(this.stores.has(e))return;let a={name:e,api:t,stateChangeCount:0,isPersisted:r?.isPersisted??false,persistName:r?.persistName,rehydrate:r?.rehydrate,library:r?.library,color:Et(e)};this.stores.set(e,a),this.notifyStoreListeners()}unregisterStore(e){this.stores.delete(e),this.notifyStoreListeners()}getStores(){return Array.from(this.stores.values())}getStore(e){return this.stores.get(e)}getStoreColor(e){return this.stores.get(e)?.color??Et(e)}filterStateChanges(e){let t=this.getAll();if(e.searchText){let r=e.searchText.toLowerCase();t=t.filter(a=>a.storeName.toLowerCase().includes(r)||a.partialPreview.toLowerCase().includes(r)||a.changedKeys.some(n=>n.toLowerCase().includes(r)))}return e.storeNames&&e.storeNames.length>0&&(t=t.filter(r=>e.storeNames.includes(r.storeName))),e.onlyWithChanges&&(t=t.filter(r=>r.hasStateChange)),t}getStats(){let e=this.items.length,t=this.items.filter(o=>o.hasStateChange).length,r=this.stores.size,a=this.items.filter(o=>o.duration!==void 0).map(o=>o.duration),n=a.length>0?a.reduce((o,s)=>o+s,0)/a.length:0;return{totalChanges:e,changesWithStateChange:t,changesWithoutStateChange:e-t,storeCount:r,averageDuration:Math.round(n*100)/100}}getUniqueStoreNames(){return Array.from(this.stores.keys()).sort()}setMaxChanges(e){this.setMax(e)}subscribeToStores(e){return this.storeListeners.add(e),()=>{this.storeListeners.delete(e)}}notifyStoreListeners(){let e=this.getStores();this.storeListeners.forEach(t=>t(e))}},S=new sa;function _(e){if(typeof e!="object"||e===null||Array.isArray(e))return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ie(e,t,r,a,n){if(typeof e=="function"){r.push(t);return}if(typeof e!="object"||e===null||n>=8)return e;if(a.has(e))return;if(a.add(e),Array.isArray(e))return e.map((s,d)=>typeof s=="function"?(r.push(`${t}[${d}]`),null):Ie(s,`${t}[${d}]`,r,a,n+1));if(!_(e))return e;let o={};for(let[s,d]of Object.entries(e)){if(typeof d=="function"){r.push(t?`${t}.${s}`:s);continue}o[s]=Ie(d,t?`${t}.${s}`:s,r,a,n+1)}return o}function Bt(e){if(_(e)&&e.__buoyStateOnDevice===true)return{data:null,fnPaths:[],blockedReason:"Store state hasn't synced from the device yet."};if(!_(e))return{data:null,fnPaths:[],blockedReason:"Only stores whose state is a plain object can be edited \u2014 a merge write has nothing to address in "+(Array.isArray(e)?"an array":`a ${typeof e}`)+"."};let t=[],r=Ie(e,"",t,new WeakSet,0),a=t.filter(n=>n.includes(".")||n.includes("["));return a.length>0?{data:null,fnPaths:t,blockedReason:`State keeps a function inside "${a[0]}" \u2014 a merge write of that key would drop it, so this store can't be edited here.`}:{data:r,fnPaths:t,blockedReason:null}}function ia(e,t){if(!_(t))throw new Error("The store's state must stay an object.");let r=Object.keys(e).filter(n=>!(n in t));if(r.length>0)throw new Error(`Can't remove top-level ${r.length===1?"key":"keys"} ${r.map(n=>`"${n}"`).join(", ")} \u2014 zustand merge writes can't delete. Edit the value instead.`);let a={};for(let n of Object.keys(t))(!(n in e)||JSON.stringify(t[n])!==JSON.stringify(e[n]))&&(a[n]=t[n]);return a}var Pt=8;function Nt(e,t,r,a){if(!(!_(t)||!_(e))&&!(a>=Pt||r.has(t))){r.add(t);for(let[n,o]of Object.entries(t))if(typeof o=="function")e[n]=o;else if(_(o)){if(!_(e[n])){if(!At(o,new WeakSet,a+1))continue;e[n]={}}Nt(e[n],o,r,a+1)}}}function At(e,t,r){if(r>=Pt||t.has(e))return false;t.add(e);for(let a of Object.values(e))if(typeof a=="function"||_(a)&&At(a,t,r+1))return true;return false}function la(){return S.getStores().length===0?{canCapture:false,canRestore:false,detail:"No Zustand stores registered \u2014 pass `zustandStores` to FloatingDevTools or add the buoyDevTools middleware"}:{canCapture:true,canRestore:true}}async function da(){let e=[],t={};for(let r of S.getStores()){let a=[],n;try{n=Ie(r.api.getState(),"",a,new WeakSet,0)}catch(o){e.push(`store "${r.name}": capture failed (${String(o)})`);continue}t[r.name]={state:n,fnPaths:a}}return{data:{stores:t},warnings:e}}async function ca(e,t){let r=e,a=Jr(t),n=Yr();if(!r?.stores)return qr("empty zustand snapshot");for(let[s,d]of Object.entries(r.stores)){if(!a.allows(s))continue;let i=S.getStore(s);if(!i){n.skipped.push({id:s,reason:"store not registered (renamed, or created after snapshot?)"});continue}try{let f=d.state;Nt(f,i.api.getState(),new WeakSet,0),i.api.setState(f,true),i.api.getState()===f?n.applied+=1:(n.warnings.push(`store "${s}": setState did not take effect`),n.ok=false)}catch(f){n.skipped.push({id:s,reason:String(f)}),n.ok=false}}let o=a.excludedWarning("store(s)");return o&&n.warnings.push(o),n}async function ua(e,t){let r=e?.stores??{},a=t===void 0,n={};if(a)for(let i of S.getStores()){let f=[];try{n[i.name]={state:Ie(i.api.getState(),"",f,new WeakSet,0),fnPaths:f}}catch{}}else Object.assign(n,t?.stores??{});let o=[],s=[],d=0;for(let i of Xr(n,r)){let f=i in r,l=i in n;if(!f){a?s.push(`store "${i}" not in snapshot \u2014 untouched`):o.push({key:i,label:i,verdict:"removed",oldValue:n[i].state});continue}if(d+=r[i].fnPaths?.length??0,a&&!S.getStore(i)){o.push({key:i,label:i,verdict:"wont-apply",reason:"store not registered (renamed, or created after snapshot?)"});continue}o.push(Gr({key:i,label:i,oldValue:n[i]?.state,newValue:r[i].state,inOld:l,inNew:true},{tooLargeReason:"store too large to render a diff \u2014 restore still applies it"}))}return d>0&&s.push(`${d} store action function${d===1?"":"s"} preserved on restore (not diffed)`),{items:o,notes:s}}Qr({id:"zustand",label:"Zustand",status:la,capture:da,restore:ca,previewItems:ua});import{useState as Q,useMemo as te,useRef as Ne,useCallback as N,useEffect as Rt}from"react";var Lt={};Zr(Lt,{AccessibilityInfo:()=>fa,ActivityIndicator:()=>bo,Alert:()=>wo,Animated:()=>uo,AppRegistry:()=>ya,AppState:()=>ba,Appearance:()=>ma,BackHandler:()=>Sa,Button:()=>So,CheckBox:()=>La,Clipboard:()=>Ca,DeviceEventEmitter:()=>Ya,Dimensions:()=>wa,Easing:()=>xa,FlatList:()=>Je,I18nManager:()=>va,Image:()=>za,ImageBackground:()=>Va,InteractionManager:()=>Ia,Keyboard:()=>Ta,KeyboardAvoidingView:()=>Oa,LayoutAnimation:()=>ka,Linking:()=>Da,LogBox:()=>Ja,Modal:()=>mo,NativeEventEmitter:()=>$a,NativeModules:()=>pa,PanResponder:()=>Ea,Picker:()=>ja,PixelRatio:()=>Ba,Platform:()=>Pa,Pressable:()=>fo,ProgressBar:()=>Ha,RefreshControl:()=>Wa,SafeAreaView:()=>Fa,ScrollView:()=>De,SectionList:()=>Ma,Share:()=>Na,StatusBar:()=>Ka,StyleSheet:()=>le,Switch:()=>yo,Text:()=>C,TextInput:()=>ho,Touchable:()=>Ua,TouchableHighlight:()=>go,TouchableNativeFeedback:()=>Za,TouchableOpacity:()=>re,TouchableWithoutFeedback:()=>po,UIManager:()=>Aa,Vibration:()=>Ra,View:()=>h,VirtualizedList:()=>_a,YellowBox:()=>Ga,findNodeHandle:()=>Co,unstable_createElement:()=>ga,useColorScheme:()=>qa,useLocaleContext:()=>Qa,useWindowDimensions:()=>Xa});_r(Lt,ha);import*as ha from"react-native-web";import{unstable_createElement as ga,NativeModules as pa,AccessibilityInfo as fa,Appearance as ma,AppRegistry as ya,AppState as ba,BackHandler as Sa,Clipboard as Ca,Dimensions as wa,Easing as xa,I18nManager as va,Keyboard as Ta,InteractionManager as Ia,LayoutAnimation as ka,Linking as Da,NativeEventEmitter as $a,PanResponder as Ea,PixelRatio as Ba,Platform as Pa,Share as Na,UIManager as Aa,Vibration as Ra,CheckBox as La,FlatList as Je,Image as za,ImageBackground as Va,KeyboardAvoidingView as Oa,Picker as ja,ProgressBar as Ha,RefreshControl as Wa,SafeAreaView as Fa,SectionList as Ma,StatusBar as Ka,Touchable as Ua,TouchableNativeFeedback as Za,VirtualizedList as _a,YellowBox as Ga,LogBox as Ja,DeviceEventEmitter as Ya,useColorScheme as qa,useLocaleContext as Qa,useWindowDimensions as Xa}from"react-native-web";import*as W from"react-native-web";import{createElement as Ye,forwardRef as zt,useCallback as eo,useRef as to}from"react";import{useEffect as ro,useState as ao}from"react";import{createPortal as oo}from"react-dom";var no='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as so}from"react/jsx-runtime";var ke=Symbol.for("@buoy-gg/portal-host"),Vt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function Ot(){let e=document;if(e[ke])return e[ke].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:no});let r=()=>{let l=document.fullscreenElement,u=l&&l.tagName!=="CANVAS"?l:document.body;t.parentElement!==u&&u.appendChild(t)},a=new Map,n=l=>{(!t.contains(l.target)||!Vt(l.target))&&a.set(l.code||l.key,{key:l.key,code:l.code,location:l.location,keyCode:l.keyCode,which:l.which,altKey:l.altKey,ctrlKey:l.ctrlKey,metaKey:l.metaKey,shiftKey:l.shiftKey})},o=l=>{a.delete(l.code||l.key)},s=()=>a.clear(),d=()=>{let l=[...a.values()];a.clear();for(let u of l)document.dispatchEvent(new KeyboardEvent("keyup",{...u,bubbles:true}))},i=l=>{Vt(l.target)&&l.stopPropagation()},f=l=>l.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",o,true),window.addEventListener("blur",s),t.addEventListener("focusin",d),t.addEventListener("keydown",i),t.addEventListener("keyup",i),t.addEventListener("keypress",i),t.addEventListener("wheel",f,{passive:true}),e[ke]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",o,true),window.removeEventListener("blur",s),t.remove(),delete e[ke]}},t}function io({children:e}){let[t,r]=ao(null);return ro(()=>{let a=Ot(),n=document[ke];return n.users++,r(a),()=>{--n.users===0&&n.dispose()}},[]),t?oo(so("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var he=W,lo=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],ge=e=>typeof e=="number"?`${e}px`:e;function qe(e){if(Array.isArray(e)){let u=e.map(qe);return u.some((b,p)=>b!==e[p])?u:e}if(!e||typeof e!="object"||!lo.some(u=>e[u]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:a,shadowRadius:n,textShadowColor:o,textShadowOffset:s,textShadowRadius:d,...i}=e;if(t!=null||r!=null||a!=null||n!=null){let u=t??"black",b=a==null?u:`color-mix(in srgb, ${u} ${Math.min(a,1)*100}%, transparent)`,p=`${ge(r?.width??0)} ${ge(r?.height??0)} ${ge(n??0)} ${b}`;i.boxShadow=typeof i.boxShadow=="string"?`${i.boxShadow}, ${p}`:i.boxShadow??p}let{width:f=0,height:l=0}=s??{};if(o&&(f||l||d)){let u=`${ge(f)} ${ge(l)} ${ge(d??0)} ${o}`;i.textShadow=i.textShadow?`${i.textShadow}, ${u}`:u}return i}var co=he.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function jt(e,t){if(typeof e=="function")return a=>jt(e(a),t);let r=qe(e);return t?[r,co[t]]:r}var le={...he.StyleSheet,create:e=>he.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,qe(r)])))};function K(e){let t=zt((a,n)=>{let{accessibilityState:o,accessibilityValue:s,pointerEvents:d,...i}=a;for(let l of["busy","checked","disabled","expanded","selected"])o?.[l]!==void 0&&i[`aria-${l}`]===void 0&&(i[`aria-${l}`]=o[l]);for(let[l,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[l]!==void 0&&i[`aria-${u}`]===void 0&&(i[`aria-${u}`]=s[l]);let f=jt(i.style,d);return f!==i.style&&(i.style=f),Ye(e,{...i,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var h=K(W.View),C=K(W.Text),uo={...he.Animated,View:he.Animated.createAnimatedComponent(h),Text:he.Animated.createAnimatedComponent(C)},ho=K(W.TextInput),re=K(W.TouchableOpacity),go=K(W.TouchableHighlight),po=K(W.TouchableWithoutFeedback),fo=K(W.Pressable),De=K(W.ScrollView),Ht=zt((e,t)=>{let r=to(null),a=eo(n=>{if(n){let o=n;for(;o.parentElement&&o.parentElement!==document.body;)o=o.parentElement;o.parentElement===document.body&&(r.current=o,Object.assign(o.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Ot().appendChild(o))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return Ye(io,null,Ye(W.Modal,{...e,ref:a}))});Ht.displayName="Modal";var mo=K(Ht),yo=K(W.Switch),bo=K(W.ActivityIndicator),So=K(W.Button),Co=W.findNodeHandle,wo={alert(e,t,r,a){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let o=document.createElement("h2");if(o.textContent=e,o.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(o),t){let f=document.createElement("p");f.textContent=t,f.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(f)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let d=r?.length?r:[{text:"OK"}],i=()=>{n.close?.(),n.remove()};for(let f of d){let l=document.createElement("button");l.type="button",l.textContent=f.text??"OK",l.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${f.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,l.onclick=()=>{i(),f.onPress?.()},s.appendChild(l)}n.addEventListener("cancel",f=>{f.preventDefault(),a?.cancelable!==false&&(i(),a?.onDismiss?.())}),n.appendChild(s),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{JsModal as xo,ModalHeader as A,TabSelector as vo,macOSColors as To,night as V,ToolEmptyState as Qe,resolveListEmptyState as Wt,Search as Io,Filter as ko,Power as Do,Lock as $o,devToolsStorageKeys as Eo,ProUpgradeModal as Bo,PowerToggleButton as Po,ToolbarCopyButton as Xe,ToolbarClearButton as No,truncatePayload as pe,TickProvider as Ft,useLimit as Ao,windowDragProps as Ro,EVENT_LIST_PRESET as Mt}from"@buoy-gg/shared-ui/web";import{useIsPro as Lo}from"@buoy-gg/license/web";import{useCallback as zo,useMemo as Kt}from"react";import{useChangeLog as Vo,useSubscribedValue as Oo}from"@buoy-gg/shared-ui/web";function jo(e,t){let r=e;if(t.searchText){let a=t.searchText.toLowerCase();r=r.filter(n=>n.storeName.toLowerCase().includes(a)||n.partialPreview.toLowerCase().includes(a)||n.changedKeys.some(o=>o.toLowerCase().includes(a)))}return t.storeNames&&t.storeNames.length>0&&(r=r.filter(a=>t.storeNames.includes(a.storeName))),t.onlyWithChanges&&(r=r.filter(a=>a.hasStateChange)),r}var Ho=()=>S.getStores(),Wo=e=>S.subscribeToStores(e);function Ut(){let e=Vo(S,{filterItems:jo}),t=Oo(Ho,Wo),r=Kt(()=>{let o=e.items.length,s=e.items.filter(d=>d.hasStateChange).length;return{totalChanges:o,changesWithStateChange:s,changesWithoutStateChange:o-s,storeCount:t.length,averageDuration:0}},[e.items,t]),a=Kt(()=>S.getUniqueStoreNames(),[t]),n=zo(o=>S.getStateChangeById(o),[]);return{stateChanges:e.items,filteredChanges:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:r,stores:t,clearChanges:S.clearStateChanges.bind(S),isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,storeNames:a,getChangeById:n}}import{memo as Fo}from"react";import{ChangeRow as Mo,buoyColors as Zt,night as Ko}from"@buoy-gg/shared-ui/web";import{jsx as Uo}from"react/jsx-runtime";function Zo(e,t){switch(e){case"replace":return"Replace";case"persist":return"Hydrate";case"initial":return"Initial";default:return t.charAt(0).toUpperCase()+t.slice(1)}}function _o(e,t){switch(e){case"replace":return Zt.warning;case"persist":return Zt.info;case"initial":return Ko.color.textTertiary;default:return S.getStoreColor(t)}}function Go(e){let t=[];return e.duration!==void 0&&e.duration>=.1&&t.push(`${e.duration.toFixed(1)}ms`),e.hasStateChange?e.changedKeysCount>0?t.push(`${e.changedKeysCount} key${e.changedKeysCount>1?"s":""} changed`):t.push(e.diffSummary||"state changed"):t.push("no state change"),t.join(" \xB7 ")}function Jo(e){return e.category==="replace"?"REPLACE":e.category==="persist"?"HYDRATE":e.category==="initial"?"INIT":"SET"}function Yo(e){return e.changedKeys.length>0&&e.changedKeys.length<=3?e.changedKeys.join(", "):e.changedKeys.length>3?`${e.changedKeys.slice(0,2).join(", ")} +${e.changedKeys.length-2}`:e.partialPreview||"setState()"}var _t=Fo(function({change:e,onPress:t,testID:r}){let a=_o(e.category,e.storeName),n=Zo(e.category,e.storeName),o=Go(e),s=Yo(e),d=Jo(e);return Uo(Mo,{statusColor:a,statusLabel:n,sublabel:o,primaryText:s,timestamp:e.timestamp,badgeText:d,changed:e.hasStateChange,slow:e.isSlowUpdate,onPress:()=>t(e),testID:r})});import{useState as Gt,useCallback as Ae,useMemo as Jt}from"react";import{night as ae,EventStepperFooter as Yt,formatRelativeTime as Re,parseValue as Le,monoFont as $e}from"@buoy-gg/shared-ui/web";import{DataViewer as qo,SplitDiffViewer as Qo,TreeDiffViewer as Xo,diffThemes as en}from"@buoy-gg/shared-ui/web/dataViewer";import{memo as tn}from"react";import{DetailViewToggle as rn,FileText as an,Database as on,GitBranch as nn}from"@buoy-gg/shared-ui/web";import{jsx as sn}from"react/jsx-runtime";var ln=[{key:"change",label:"CHANGE",description:"View change details",icon:an},{key:"state",label:"STATE",description:"View current state",icon:on},{key:"diff",label:"DIFF",description:"Compare changes",icon:nn}],dn=["diff"],cn=tn(function({activeView:e,onViewChange:t,diffDisabled:r=false}){return sn(rn,{views:ln,activeView:e,onViewChange:t,disabledKeys:r?dn:void 0,testIDPrefix:"buoy-zustand"})});import{memo as un,useCallback as et,useState as hn,useEffect as gn}from"react";import{buoyColors as O,night as I,Clock as pn,AlertTriangle as fn,Zap as qt,Info as mn,Box as Qt,Database as yn,parseValue as bn,ProUpgradeModal as Sn,copyToClipboard as Cn,InfoRow as Xt,monoFont as fe}from"@buoy-gg/shared-ui/web";import{useIsPro as wn}from"@buoy-gg/license/web";import{DataViewer as xn}from"@buoy-gg/shared-ui/web/dataViewer";import{night as E,monoFont as vn}from"@buoy-gg/shared-ui/web";import{jsx as er,jsxs as Tn}from"react/jsx-runtime";var In={copy:{color:E.color.accent,backgroundColor:E.color.accentSoft,borderColor:E.color.accentBorder,textColor:E.color.accent},reset:{color:E.color.warning,backgroundColor:E.color.warningSoft,borderColor:E.color.warning+"40",textColor:E.color.warning},clear:{color:E.color.danger,backgroundColor:E.color.dangerSoft,borderColor:E.color.danger+"40",textColor:E.color.danger},jump:{color:E.color.warning,backgroundColor:E.color.warningSoft,borderColor:E.color.warning+"40",textColor:E.color.warning}};function tt({onPress:e,text:t,type:r,disabled:a=false,testID:n}){let o=In[r];return Tn(re,{disabled:a,onPress:e,style:[rt.button,{backgroundColor:a?E.color.textTertiary+"1A":o.backgroundColor,borderColor:a?E.color.textTertiary+"33":o.borderColor,opacity:a?.5:1}],activeOpacity:.7,testID:n,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:a},children:[er(h,{style:[rt.dot,{backgroundColor:a?E.color.textTertiary:o.color}]}),er(C,{style:[rt.text,{color:a?E.color.textTertiary:o.textColor}],children:t})]})}var rt=le.create({button:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:6,borderWidth:1,paddingHorizontal:12,paddingVertical:6,height:25,minWidth:80,shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2,elevation:2},dot:{width:5,height:5,borderRadius:3,marginRight:6,shadowColor:E.color.text,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:2},text:{fontSize:10,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:vn,height:12}});var g="buoy-zustand";function at(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function kn(e,t){return`${g}-row-${at(e)}-${t}`}function tr(e){return`${g}-store-${at(e)}`}function Dn(e){let t=new Map,r=new Map;for(let a of e){let n=(t.get(a.storeName)??0)+1;t.set(a.storeName,n),r.set(a.id,kn(a.storeName,n))}return r}import{jsx as x,jsxs as F}from"react/jsx-runtime";function $n(e){switch(e){case"replace":return{label:"REPLACE",color:O.warning,bgColor:O.warning+"26"};case"persist":return{label:"PERSIST",color:O.info,bgColor:O.info+"26"};case"initial":return{label:"INITIAL",color:I.color.textTertiary,bgColor:I.color.textTertiary+"26"};default:return{label:"SET STATE",color:O.success,bgColor:O.success+"26"}}}function En(e){return e===void 0?"N/A":e<1?"<1ms":`${e.toFixed(1)}ms`}function ze({icon:e,title:t,badge:r,testID:a}){return F(h,{style:w.sectionHeader,testID:a,children:[F(h,{style:w.sectionHeaderLeft,children:[x(e,{size:14,color:I.color.accent}),x(C,{style:w.sectionTitle,children:t})]}),r]})}function Bn(e){let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0"),n=t.getSeconds().toString().padStart(2,"0"),o=t.getMilliseconds().toString().padStart(3,"0");return`${r}:${a}:${n}.${o}`}var Pn=un(function({change:e}){let t=wn(),[r,a]=hn(false);gn(()=>{r&&t&&a(false)},[r,t]);let n=$n(e.category),o=e.partial!==void 0&&e.partial!=="(updater fn)",s=e.changedKeys.length>0,d=S.getStoreColor(e.storeName),i=et(async()=>{if(!t){a(true);return}await Cn(e.nextState)},[e.nextState,t]),f=et(()=>{let u=S.getStore(e.storeName);if(u?.api.getInitialState){let b=u.api.getInitialState();u.api.setState(b,true)}},[e.storeName]),l=et(()=>{let u=S.getStore(e.storeName);u&&u.api.setState(e.nextState,true)},[e.storeName,e.nextState]);return F(De,{style:w.container,contentContainerStyle:w.contentContainer,showsVerticalScrollIndicator:false,testID:`${g}-detail-scroll`,children:[F(h,{style:w.card,testID:`${g}-info-card`,children:[x(ze,{icon:mn,title:"CHANGE INFO"}),F(h,{style:w.cardContent,children:[x(Xt,{label:"Store",value:e.storeName,mono:true,valueColor:d,testID:`${g}-info-store`}),x(Xt,{label:"Time",value:Bn(e.timestamp),mono:true,testID:`${g}-info-time`}),F(h,{style:w.badgeRow,children:[x(h,{style:[w.categoryBadge,{backgroundColor:n.bgColor}],children:x(C,{style:[w.categoryText,{color:n.color}],testID:`${g}-info-category`,children:n.label})}),F(h,{style:[w.durationBadge,e.isSlowUpdate&&w.durationBadgeSlow],children:[x(pn,{size:10,color:e.isSlowUpdate?O.error:I.color.textSecondary}),x(C,{style:[w.durationText,e.isSlowUpdate&&w.durationTextSlow],testID:`${g}-info-duration`,children:En(e.duration)}),e.isSlowUpdate&&x(fn,{size:10,color:O.error})]}),e.hasStateChange?F(h,{style:w.changesBadge,children:[x(qt,{size:10,color:O.success}),x(C,{style:w.changesText,testID:`${g}-info-changes`,children:e.diffSummary||"changed"})]}):x(h,{style:w.noChangesBadge,children:x(C,{style:w.noChangesText,testID:`${g}-info-no-changes`,children:"no change"})}),e.isPersisted&&F(h,{style:w.persistBadge,children:[x(yn,{size:10,color:O.info}),x(C,{style:w.persistText,testID:`${g}-info-persisted`,children:"PERSISTED"})]})]})]})]}),s&&F(h,{style:w.card,testID:`${g}-keys-card`,children:[x(ze,{icon:qt,title:"CHANGED KEYS",badge:x(h,{style:w.countBadge,children:x(C,{style:w.countText,testID:`${g}-keys-count`,children:e.changedKeys.length})})}),x(h,{style:w.cardContent,children:x(h,{style:w.keysContainer,children:e.changedKeys.map(u=>x(h,{style:w.keyBadge,children:x(C,{style:w.keyText,testID:`${g}-key-${u}`,children:u})},u))})})]}),o&&F(h,{style:w.card,testID:`${g}-partial-card`,children:[x(ze,{icon:Qt,title:"PARTIAL (setState argument)",badge:x(h,{style:w.typeBadge,children:x(C,{style:w.typeText,testID:`${g}-partial-type`,children:Array.isArray(e.partial)?"ARRAY":typeof e.partial=="object"?"OBJECT":(typeof e.partial).toUpperCase()})})}),x(h,{style:w.dataViewerContainer,children:x(xn,{title:"",data:bn(e.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),e.partial==="(updater fn)"&&F(h,{style:w.card,testID:`${g}-updater-card`,children:[x(ze,{icon:Qt,title:"SET STATE CALL"}),F(h,{style:w.cardContent,children:[x(C,{style:w.updaterText,children:"Called with an updater function: set((state) => ...)"}),x(C,{style:w.updaterSubtext,children:"The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."})]})]}),F(h,{style:w.actionsGrid,children:[x(tt,{type:"jump",text:"JUMP",onPress:l,testID:`${g}-jump`}),x(tt,{type:"reset",text:"RESET STORE",onPress:f,testID:`${g}-reset`}),x(tt,{type:"copy",text:"COPY STATE",onPress:i,testID:`${g}-copy-state`})]}),x(Sn,{visible:r,onClose:()=>a(false),featureName:"Copy"})]})}),w=le.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:I.color.surface,borderRadius:6,borderWidth:1,borderColor:I.color.accentBorderStrong,overflow:"hidden",shadowColor:I.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:I.color.accentBorder,backgroundColor:I.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:I.color.accent,fontFamily:fe},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:I.color.surfaceElevated},durationBadgeSlow:{backgroundColor:O.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:I.color.textSecondary,fontFamily:fe},durationTextSlow:{color:O.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:O.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:O.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:I.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:I.color.textTertiary},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:O.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:O.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:I.color.accentSoft,borderWidth:1,borderColor:I.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:I.color.accent,fontFamily:fe},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:I.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:I.color.accent,fontFamily:fe},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:I.color.surfaceElevated},typeText:{fontSize:8,fontWeight:"600",color:I.color.textTertiary,fontFamily:fe},dataViewerContainer:{backgroundColor:I.color.bg,minHeight:60},updaterText:{fontSize:12,color:I.color.text,fontFamily:fe},updaterSubtext:{fontSize:11,color:I.color.textTertiary,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});import{DiffModeTabs as Nn,CompareBar as An}from"@buoy-gg/shared-ui/web";import{jsx as $,jsxs as me}from"react/jsx-runtime";function ot(e){return S.getStoreColor(e.storeName)}function rr(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function Rn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function ar(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}var Ln=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];function or({change:e,changes:t,selectedIndex:r,onIndexChange:a,disableInternalFooter:n=false,initialView:o="change"}){let[s,d]=Gt(o),[i,f]=Gt("tree"),l=t.length,u=ot(e),b=rr(e),p=Rn(Le(e.nextState)),y=l-r,B=y-1,D=r<l-1?r+1:null,j=D!==null?t[D]:null,H=Jt(()=>({index:D??0,label:B>0?`#${B}`:"Initial",timestamp:j?ar(j.timestamp):"",relativeTime:j?Re(new Date(j.timestamp)):"state",badge:j?$(h,{style:[P.changeBadgeSmall,{backgroundColor:`${ot(j)}20`}],children:$(C,{style:[P.changeTextSmall,{color:ot(j)}],children:rr(j)})}):void 0}),[D,j,B]),be=Jt(()=>({index:r,label:`#${y}`,timestamp:ar(e.timestamp),relativeTime:Re(new Date(e.timestamp)),badge:$(h,{style:[P.changeBadgeSmall,{backgroundColor:`${u}20`}],children:$(C,{style:[P.changeTextSmall,{color:u}],children:b})})}),[r,e.timestamp,u,b,y]),oe=Ae(()=>{let ne=Le(e.nextState);return me(h,{style:P.contentCard,testID:`${g}-state-card`,children:[me(h,{style:P.valueHeader,children:[$(C,{style:P.valueLabel,children:"STATE AFTER CHANGE"}),me(h,{style:P.valueHeaderBadges,children:[$(h,{style:[P.changeBadge,{backgroundColor:`${u}20`}],children:$(C,{style:[P.changeText,{color:u}],children:b})}),$(h,{style:P.typeBadge,children:$(C,{style:P.typeText,testID:`${g}-state-type`,children:p.toUpperCase()})})]})]}),$(h,{style:P.dataViewerContainer,children:$(qo,{title:"",data:ne,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextState,u,b,p]),Se=Ae(()=>{let ne=Le(e.prevState),ce=Le(e.nextState);return i==="split"?$(De,{style:{flex:1},showsVerticalScrollIndicator:true,children:$(Qo,{oldValue:ne,newValue:ce,theme:en.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})}):$(Xo,{oldValue:ne,newValue:ce})},[e.prevState,e.nextState,i]),Ce=Ae(()=>{a(Math.min(l-1,r+1))},[r,l,a]),we=Ae(()=>{a(Math.max(0,r-1))},[r,a]),J=e.prevState===void 0,xe=!n&&l>1;return me(h,{style:P.container,children:[$(cn,{activeView:s,onViewChange:d,diffDisabled:J}),me(h,{style:[P.contentArea,xe&&P.contentAreaFooterPad],children:[s==="change"&&$(Pn,{change:e}),s==="state"&&$(h,{style:P.stateContainer,children:oe()}),s==="diff"&&me(h,{style:P.diffContainer,testID:`${g}-diff`,children:[$(Nn,{tabs:Ln,activeTab:i,onTabChange:f,testIDPrefix:`${g}-diff-tab`}),$(An,{leftEvent:H,rightEvent:be}),$(h,{style:P.diffContent,testID:`${g}-diff-content`,children:Se()})]})]}),xe&&$(Yt,{currentIndex:y-1,totalItems:l,onPrevious:Ce,onNext:we,itemLabel:"Change",subtitle:Re(new Date(e.timestamp)),absolute:true})]})}function nr({change:e,changes:t,selectedIndex:r,onIndexChange:a}){let n=t.length;if(n<=1)return null;let o=n-r;return $(Yt,{currentIndex:o-1,totalItems:n,onPrevious:()=>a(Math.min(n-1,r+1)),onNext:()=>a(Math.max(0,r-1)),itemLabel:"Change",subtitle:Re(new Date(e.timestamp))})}var P=le.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:ae.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:ae.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:ae.color.textSecondary,fontFamily:$e,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:$e,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:ae.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:ae.color.textTertiary,fontFamily:$e},valueBox:{backgroundColor:ae.color.bg,borderRadius:6,borderWidth:1,borderColor:ae.color.border,padding:8},valueText:{fontSize:12,color:ae.color.text,fontFamily:$e,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:$e},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as zn}from"react";import{CompactRow as Vn,night as nt,ToolEmptyState as st,resolveListEmptyState as On,monoFont as sr}from"@buoy-gg/shared-ui/web";import{jsx as G,jsxs as it}from"react/jsx-runtime";function jn(e){try{let t=e.api.getState();if(t&&typeof t=="object"&&t.__buoyStateOnDevice===true)return"on device";if(t&&typeof t=="object"){let r=Object.keys(t).filter(a=>typeof t[a]!="function");return r.length===0?"no data keys":r.length<=3?r.join(", "):`${r.slice(0,2).join(", ")} +${r.length-2}`}return""}catch{return""}}function Hn(){return G(st,{testID:`${g}-stores-loading`,otto:"loading",title:"Loading stores\u2026",message:"Waiting for the device to send its registered stores."})}function Wn(){return G(st,{testID:`${g}-stores-empty`,otto:"scanning",title:"No stores registered",message:`Use watchStores() to register your Zustand stores.
|
|
2
|
+
They will appear here with their current state.`})}function Fn({stores:e,searchQuery:t,isLoading:r=false,onOpenStore:a}){let n=zn(()=>{if(!t)return e;let o=t.toLowerCase();return e.filter(s=>s.name.toLowerCase().includes(o)||s.persistName&&s.persistName.toLowerCase().includes(o))},[e,t]);return n.length===0&&!t?r?G(Hn,{}):G(Wn,{}):n.length===0&&t?G(st,{testID:`${g}-stores-no-match`,...On({subject:"stores",verb:"registered",search:t,total:e.length,waiting:{otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores."}})}):it(De,{style:X.container,contentContainerStyle:X.scrollContent,showsVerticalScrollIndicator:true,testID:`${g}-stores-scroll`,children:[it(h,{style:X.sectionHeader,children:[G(C,{style:X.sectionTitle,children:"STORES"}),G(h,{style:X.sectionCountBadge,children:G(C,{style:X.sectionCountText,testID:`${g}-stores-count`,children:n.length})})]}),n.map(o=>{let s=jn(o),d=S.getStoreColor(o.name),i=tr(o.name);return it(h,{style:X.storeRowWrapper,children:[G(Vn,{statusDotColor:d,statusLabel:o.isPersisted?"persisted":"in-memory",primaryText:o.name,secondaryText:s||void 0,showChevron:true,onPress:()=>a(o.name),testID:i,statusTestID:`${i}-backing`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-keys`}),o.stateChangeCount>0&&G(h,{style:[X.absCountBadge,{backgroundColor:d+"22",borderColor:d+"55"}],pointerEvents:"none",children:G(C,{style:[X.absCountText,{color:d}],testID:`${i}-count`,children:String(o.stateChangeCount)})})]},o.name)})]})}var X=le.create({container:{flex:1},storeRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:sr},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:nt.color.textTertiary},sectionCountBadge:{backgroundColor:nt.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:nt.color.accent,fontFamily:sr}});import{useCallback as Mn,useEffect as Kn,useMemo as lt,useState as Ve}from"react";import{buoyColors as dt,Database as Un,ExpandedInfoRow as Oe,FileJson as Zn,night as R,PillBadge as ct,parseValue as ir,monoFont as je}from"@buoy-gg/shared-ui/web";import{DataViewer as _n,LiveExplorer as Gn,ValueEditModal as Jn,updateNestedDataByPath as Yn,deleteNestedDataByPath as qn}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as lr,jsx as v,jsxs as U}from"react/jsx-runtime";var Qn=300,de=`${g}-detail`;function Xn(e){let t=r=>r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${de}-explorer-root`:`${de}-explorer-${e.map(t).filter(Boolean).join("-")}`}function es({store:e,onViewHistory:t}){let r=tr(e.name),[a,n]=Ve(0);Kn(()=>e.api.subscribe(()=>n(b=>b+1)),[e.api]);let o=e.api.getState(),s=lt(()=>Bt(o),[o,a]),[d,i]=Ve(false),f=lt(()=>{if(s.data!==null)return{update:(b,p)=>{let y=e.api.getState();if(!_(y)||b.length===0)return;let B=b[0],D=b.length===1?p:Yn(y[B],b.slice(1),p);e.api.setState({[B]:D},false)},remove:b=>{let p=e.api.getState();if(!_(p)||b.length<=1)return;let y=b[0],B=qn(p[y],b.slice(1));e.api.setState({[y]:B},false)},canRemove:b=>b.length>1}},[e.api,s.data===null]),l=Mn(b=>{let p=Bt(e.api.getState());if(p.data===null)return;let y=ia(p.data,b);Object.keys(y).length>0&&e.api.setState(y,false),i(false)},[e.api]),u=lt(()=>{if(o&&typeof o=="object"){let b={};for(let[p,y]of Object.entries(o))typeof y!="function"&&(b[p]=y);return ir(b)}return ir(o)},[o,a]);return U(h,{style:T.root,children:[U(De,{testID:`${de}-scroll`,style:T.scroll,contentContainerStyle:T.scrollContent,keyboardShouldPersistTaps:"handled",children:[v(h,{style:T.section,children:U(h,{style:T.editorContainer,children:[U(h,{style:T.sectionHeaderRow,children:[v(C,{testID:`${de}-editor-header`,style:T.sectionHeaderText,children:"State Editor"}),s.data!==null?U(re,{onPress:()=>i(true),testID:`${de}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:T.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[v(Zn,{size:13,color:R.color.accent}),v(C,{style:T.rawButtonText,children:"Raw"})]}):null]}),v(h,{style:T.sectionBody,children:s.data!==null?U(lr,{children:[v(Gn,{editable:true,label:"State",value:s.data,defaultExpanded:["State"],writer:f,dataVersion:a,testIDForPath:Xn,debounceMs:Qn}),v(C,{style:T.editorHint,children:"Edits write into the live store as you make them \u2014 merged, so the store's actions and untouched keys survive."})]}):v(C,{style:T.blockedText,testID:`${de}-edit-blocked`,children:s.blockedReason})})]})}),v(h,{style:T.section,children:U(h,{style:T.infoContainer,children:[v(C,{style:T.sectionHeaderTextPlain,children:"Store Details"}),U(h,{style:T.infoBody,children:[v(Oe,{label:"Type",children:v(ct,{color:e.color,testID:`${r}-type`,children:"ZUSTAND"})}),U(Oe,{label:"Backing",children:[v(ct,{color:dt.info,icon:e.isPersisted?v(Un,{size:9,color:dt.info}):void 0,testID:`${r}-persist`,children:e.isPersisted?e.persistName||"persisted":"in-memory"}),e.isPersisted?v(ts,{store:e,rowID:r}):null]}),e.stateChangeCount>0&&U(Oe,{label:"Changes",children:[v(ct,{color:dt.warning,testID:`${r}-changes`,children:String(e.stateChangeCount)}),v(re,{onPress:()=>t(e.name),style:T.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${r}-history`,accessibilityRole:"button",accessibilityLabel:`View ${e.name} history`,children:v(C,{style:[T.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]}),s.fnPaths.length>0&&v(Oe,{label:"Actions",children:v(C,{style:T.actionsText,testID:`${de}-actions`,numberOfLines:2,children:s.fnPaths.join(" \xB7 ")})})]})]})}),v(h,{style:T.section,children:U(h,{style:T.infoContainer,children:[v(C,{style:T.sectionHeaderTextPlain,children:"State Explorer"}),v(h,{style:T.viewerBody,testID:`${r}-state`,children:u&&typeof u=="object"?v(_n,{title:"",data:u,showTypeFilter:true,rawMode:true,initialExpanded:false}):v(C,{style:T.blockedText,children:"Empty state"})})]})})]}),d&&s.data!==null?v(Jn,{path:[],value:s.data,onSave:b=>{try{l(b)}catch{}},onCancel:()=>i(false),saveLabel:"Apply",testIDPrefix:`${g}-value`}):null]})}function ts({store:e,rowID:t}){let[r,a]=Ve(false),[n,o]=Ve(null);return e.rehydrate?U(lr,{children:[v(re,{onPress:()=>{a(true),o(null),(async()=>{try{await e.rehydrate?.()}catch(s){o(s instanceof Error?s.message:String(s))}finally{a(false)}})()},disabled:r,style:T.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${t}-reread`,accessibilityRole:"button",accessibilityLabel:`Re-read ${e.name} from storage`,children:v(C,{style:[T.inlineLinkText,{color:e.color}],children:r?"re-reading\u2026":"re-read saved value \u2192"})}),n?v(C,{style:[T.inlineLinkText,{color:R.color.danger}],children:n}):null]}):null}var T=le.create({root:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8,paddingBottom:24},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:R.color.surface,borderRadius:6,borderWidth:1,borderColor:R.color.accent+"4D",overflow:"hidden",shadowColor:R.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:R.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:R.color.accent+"33"},sectionHeaderText:{fontWeight:"600",fontSize:12,color:R.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:je},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:R.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:R.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:R.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:R.color.surface,borderRadius:6,borderWidth:1,borderColor:R.color.border,overflow:"hidden"},sectionHeaderTextPlain:{backgroundColor:R.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:R.color.textSecondary,borderBottomWidth:1,borderBottomColor:R.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:je},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:R.color.bg,minHeight:60},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:je},actionsText:{flex:1,color:R.color.textSecondary,fontSize:10,fontFamily:je,lineHeight:15}});import{useMemo as rs}from"react";import{EntityFilterView as as}from"@buoy-gg/shared-ui/web";import{jsx as os}from"react/jsx-runtime";var ns=["\u2022 auth \u2192 hides authStore from stores & events","\u2022 temp \u2192 hides tempStore, tempUserStore","\u2022 cart \u2192 hides cartStore from both tabs"];function ss({ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,stores:a}){let n=rs(()=>a.map(o=>({name:o.name,color:S.getStoreColor(o.name)})),[a]);return os(as,{entities:n,ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,entityNoun:"STORES",entitySingular:"store",entityKey:"store",testIDPrefix:g,slug:at,howItWorks:"Patterns hide matching stores from both the Stores tab and the Events tab. Tap a store above to quickly add it as a filter.",examples:ns})}import{Fragment as dr,jsx as m,jsxs as M}from"react/jsx-runtime";function is({isEnabled:e,searchText:t,totalChanges:r}){let a=Wt({subject:"changes",search:t,total:r,capturing:e,waiting:{otto:"waiting",title:"No state changes",message:"State changes will appear here as stores update."},paused:{title:"No state changes",message:"Enable capture to start recording state changes"}});return m(Qe,{...a,testID:`${g}-empty`})}function He({visible:e,onClose:t,onBack:r,onMinimize:a,enableSharedModalDimensions:n=false,inline:o=false,storesLoading:s=false,initialTab:d="stores",initialSelectedChangeId:i,initialDetailView:f,onChangeSelect:l,onStoreExpand:u}){let b=Lo(),p=Ao("zustand.changes"),[y,B]=Q(false),[D,j]=Q(d),[H,be]=Q(null),[oe,Se]=Q(null),[Ce,we]=Q(false),[J,xe]=Q(new Set),{stateChanges:ne,filteredChanges:ce,filter:Rs,setFilter:ve,stats:mr,stores:Te,clearChanges:yr,isEnabled:Ee,toggleCapture:br}=Ut(),Y=te(()=>J.size===0?ce:ce.filter(c=>!Array.from(J).some(k=>c.storeName.toLowerCase().includes(k.toLowerCase()))),[ce,J]),ue=te(()=>J.size===0?Te:Te.filter(c=>!Array.from(J).some(k=>c.name.toLowerCase().includes(k.toLowerCase()))),[Te,J]),Sr=te(()=>H?ne.filter(c=>c.storeName===H).length:0,[ne,H]),Be=te(()=>H?Y.filter(c=>c.storeName===H):Y,[Y,H]),Ue=te(()=>Be.slice(0,p),[Be,p]),Ze=te(()=>Math.max(0,Be.length-p),[Be.length,p]),Cr=Ze>0,z=Ue,[_e,se]=Q(null),ie=te(()=>{if(_e===null)return null;let c=z.findIndex(k=>k.id===_e);return c>=0?c:null},[_e,z]),Z=ie!==null?z[ie]:null,gt=Ne(null);Rt(()=>{if(!l)return;let c=Z?.id??null;c===null||c===gt.current||(gt.current=c,l(Z))},[Z,l]);let pt=Ne(null);Rt(()=>{!i||pt.current===i||!z.some(c=>c.id===i)||(pt.current=i,se(i))},[i,z]);let[ee,Ge]=Q(""),[wr,Pe]=Q(false),Ls=Ne(null),xr=Ne(null),vr=N(c=>{},[]),Tr=c=>{Ge(c),D==="events"&&ve(k=>({...k,searchText:c}))},Ir=N(()=>{Ge(""),ve(c=>({...c,searchText:""})),Pe(false)},[ve]),ft=N(c=>{se(c.id)},[]),kr=N(()=>{B(true)},[]),Dr=N(()=>{se(null)},[]),mt=N(c=>{let k=z[c];k&&se(k.id)},[z]),$r=N(c=>{be(c),se(null)},[]),Er=N(()=>{be(null),se(null)},[]),Br=N(c=>{Se(c),u?.(c)},[u]),Pr=N(()=>{Se(null)},[]),Nr=N(()=>ue.reduce((c,k)=>{try{let q=k.api.getState();if(q&&typeof q=="object"){let It={};for(let[Fr,kt]of Object.entries(q))typeof kt!="function"&&(It[Fr]=pe(kt));c[k.name]=It}else c[k.name]=pe(q)}catch{c[k.name]=null}return c},{}),[ue]),Ar=N(()=>Y.map(c=>({id:c.id,storeName:c.storeName,timestamp:c.timestamp,prevState:pe(c.prevState),nextState:pe(c.nextState),hasStateChange:c.hasStateChange,changedKeys:c.changedKeys})),[Y]),Rr=N(()=>z.map(c=>({id:c.id,storeName:c.storeName,timestamp:c.timestamp,prevState:pe(c.prevState),nextState:pe(c.nextState),hasStateChange:c.hasStateChange,changedKeys:c.changedKeys})),[z]),Lr=N(c=>{xe(k=>{let q=new Set(k);return q.has(c)?q.delete(c):q.add(c),q})},[]),zr=N(c=>{xe(k=>new Set([...k,c]))},[]),Vr=N(c=>{j(c),be(null),Se(null),se(null),we(false),ee&&(Ge(""),ve(k=>({...k,searchText:""}))),Pe(false)},[ee,ve]),yt=N(c=>c.id,[]),bt=te(()=>Dn(z),[z]),St=N(({item:c})=>m(_t,{change:c,onPress:ft,testID:bt.get(c.id)}),[ft,bt]),Ct=J.size>0,wt=()=>Ce?M(A,{children:[m(A.Navigation,{onBack:()=>we(false)}),m(A.Content,{title:"Filters",centered:true,testID:`${g}-filters-title`})]}):Z?M(A,{children:[m(A.Navigation,{onBack:Dr}),m(A.Content,{title:`${Z.storeName}/setState`,centered:true,testID:`${g}-detail-title`})]}):H?M(A,{children:[m(A.Navigation,{onBack:Er}),m(A.Content,{title:`${H} History`,centered:true,testID:`${g}-history-title`}),m(A.Actions,{children:m(Xe,{value:Rr,disabled:z.length===0,buttonStyle:L.headerActionButton,testID:`${g}-copy`})})]}):oe?M(A,{children:[m(A.Navigation,{onBack:Pr}),m(A.Content,{title:oe,centered:true,testID:`${g}-store-detail-title`})]}):M(A,{children:[r&&m(A.Navigation,{onBack:r}),m(A.Content,{title:"",children:wr?m(A.Search,{value:ee,onChangeText:Tr,onCancel:Ir,placeholder:D==="stores"?"Search stores...":"Search events...",accessibilityLabel:"Search Zustand stores and events",iconSize:14,testID:`${g}-search-field`,containerTestID:`${g}-search`,clearTestID:`${g}-search-clear`,onBlur:()=>{ee.length===0&&Pe(false)}}):m(vo,{tabs:[{key:"stores",label:`Stores${ue.length>0?` (${ue.length})`:""}`},{key:"events",label:`Events${Y.length>0?` (${Y.length})`:""}`}],activeTab:D,onTabChange:Vr,testIDPrefix:`${g}-tab`})}),M(A.Actions,{children:[m(re,{onPress:()=>Pe(true),style:L.headerActionButton,testID:`${g}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:m(Io,{size:14,color:V.color.textSecondary})}),m(re,{onPress:()=>we(true),style:[L.headerActionButton,Ct&&L.headerActionButtonActive],testID:`${g}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:m(ko,{size:14,color:Ct?V.color.accent:V.color.textSecondary})}),D==="stores"&&m(Xe,{value:Nr,disabled:ue.length===0,buttonStyle:L.headerActionButton,testID:`${g}-copy`}),D==="events"&&M(dr,{children:[m(Xe,{value:Ar,disabled:Y.length===0,buttonStyle:L.headerActionButton,testID:`${g}-copy`}),m(Po,{isEnabled:Ee,onToggle:br,accessibilityLabel:"Toggle Zustand state capture",testID:`${g}-power`}),m(No,{onPress:yr,disabled:Y.length===0,buttonStyle:L.headerActionButton,testID:`${g}-clear`})]})]})]}),Or=()=>{if(Ce)return m(ss,{ignoredPatterns:J,onTogglePattern:Lr,onAddPattern:zr,stores:Te});if(Z&&ie!==null)return m(or,{change:Z,changes:z,selectedIndex:ie,onIndexChange:mt,disableInternalFooter:true,initialView:f});if(H)return z.length>0?m(Je,{testID:`${g}-history-list`,data:z,renderItem:St,keyExtractor:yt,contentContainerStyle:L.listContent,showsVerticalScrollIndicator:true,...Mt}):m(Qe,{testID:`${g}-history-empty`,...Wt({subject:"changes",search:ee,total:ee.trim()?Sr:0,capturing:Ee,waiting:{otto:"waiting",title:"No history yet",message:`State changes for ${H} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${H}.`}})});if(oe){let c=Te.find(k=>k.name===oe)??null;return c?m(es,{store:c,onViewHistory:$r}):m(Qe,{testID:`${g}-store-detail-gone`,otto:"ghost",title:"Store no longer registered",message:`${oe} is not in the registry any more.`})}return D==="stores"?m(Fn,{stores:ue,searchQuery:ee,isLoading:s,onOpenStore:Br}):M(dr,{children:[!Ee&&M(h,{style:L.disabledBanner,testID:`${g}-banner-disabled`,children:[m(Do,{size:14,color:V.color.warning}),m(C,{style:L.disabledText,children:"State capture is disabled"})]}),Cr&&M(re,{style:L.lockedBanner,onPress:kr,activeOpacity:.8,testID:`${g}-locked`,accessibilityRole:"button",children:[m($o,{size:14,color:V.color.accent}),M(C,{style:L.lockedText,testID:`${g}-locked-text`,children:[Ze," older"," ",Ze===1?"change":"changes"," locked"]}),m(h,{style:L.upgradeBadge,children:m(C,{style:L.upgradeBadgeText,children:"UPGRADE"})})]}),Ue.length>0?m(Je,{ref:xr,testID:`${g}-list`,data:Ue,renderItem:St,keyExtractor:yt,contentContainerStyle:L.listContent,showsVerticalScrollIndicator:true,...Mt}):m(is,{isEnabled:Ee,searchText:ee,totalChanges:mr.totalChanges})]})},jr=n?Eo.modal.root():"buoy-zustand-modal";if(!e)return null;let xt=Z&&ie!==null?m(nr,{change:Z,changes:z,selectedIndex:ie,onIndexChange:mt}):null,Hr=Z&&z.length>1?68:0,Wr=!Ce&&(Z&&ie!==null||H!=null||D==="events"||D==="stores"),vt=m(h,{style:L.container,children:Or()}),Tt=m(Bo,{visible:y,onClose:()=>B(false),featureName:"Full State History"});return o?M(Ft,{children:[M(h,{style:L.inlineRoot,children:[m(h,{style:L.inlineHeader,...Ro,children:wt()}),vt,xt]}),Tt]}):M(Ft,{children:[m(xo,{visible:e,onClose:t,onMinimize:a,persistenceKey:jr,header:{showToggleButton:true,customContent:wt()},onModeChange:vr,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Wr,styles:{},footer:xt,footerHeight:Hr,children:vt}),Tt]})}function ls(e={}){return m(He,{...e,inline:true,visible:true,onClose:()=>{}})}var L=le.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:To.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:V.color.buttonSurface,borderWidth:1,borderColor:V.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:V.color.accentSoft,borderColor:V.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:V.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:V.color.warning+"20"},disabledText:{color:V.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:V.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:V.color.accentBorder},lockedText:{color:V.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:V.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:V.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});import{ZustandIcon as ut,ZUSTAND_ICON_COLOR as ds}from"@buoy-gg/shared-ui/web";import{jsx as cr}from"react/jsx-runtime";var cs={id:"zustand",name:"ZUSTAND",description:"Zustand store & state inspector",slot:"both",icon:({size:e})=>cr(ut,{size:e}),component:He,props:{enableSharedModalDimensions:false}};function us(e){return{id:e?.id||"zustand",name:e?.name||"ZUSTAND",description:e?.description||"Zustand store & state inspector",slot:"both",icon:({size:t})=>cr(ut,{size:t,color:e?.iconColor}),component:He,props:{enableSharedModalDimensions:e?.enableSharedModalDimensions!==void 0?e.enableSharedModalDimensions:false}}}var ye=Symbol.for("@@buoy-zustand/watched");function ur(e){let t=e.persist;return t&&typeof t.getOptions=="function"?{isPersisted:true,persistName:t.getOptions()?.name,persistApi:t}:{isPersisted:false}}function hs(e){let t=[];for(let[r,a]of Object.entries(e)){let n=a;if(n[ye])continue;n[ye]=true;let{isPersisted:o,persistName:s,persistApi:d}=ur(a);S.registerStore(r,{getState:a.getState,getInitialState:a.getInitialState,setState:a.setState,subscribe:a.subscribe},{isPersisted:o,persistName:s,rehydrate:typeof d?.rehydrate=="function"?()=>d.rehydrate():void 0,library:a.buoyLibrary});let i=false,f=a.subscribe((l,u)=>{try{let b;if(!i&&o){let p=false;try{p=d?.hasHydrated?.()===false}catch{}p&&(i=true,b="persist")}S.addStateChange({storeName:r,partial:void 0,replace:false,prevState:u,nextState:l,duration:void 0,category:b,isPersisted:o})}catch{}});t.push(()=>{f(),delete a[ye],S.unregisterStore(r)})}return()=>{t.forEach(r=>r())}}var gs=0;function ps(e,t){return(r,a,n)=>{let o=t?.name??`store-${++gs}`,s=t?.enabled!==false,d=r,i=(l,u)=>{if(!s)return d(l,u);let b=performance.now(),p=a();d(l,u);let y=a(),B=performance.now()-b,D=typeof l=="function"?"(updater fn)":l;S.addStateChange({storeName:o,partial:D,replace:u??false,prevState:p,nextState:y,duration:B,isPersisted:S.getStore(o)?.isPersisted??false})},f=e(i,a,n);return setTimeout(()=>{if(n[ye])return;n[ye]=true;let{isPersisted:l,persistName:u}=ur(n);S.registerStore(o,{getState:a,getInitialState:n.getInitialState,setState:i,subscribe:n.subscribe},{isPersisted:l,persistName:u})},0),f}}function fs(e){return e[ye]===true}import{expandKeyedArrays as ms,patchFromPath as ys,readPath as bs,refusalText as Ss,shapeSummary as We,suggestedPatch as ht,typedEditViolations as Cs,unshapedLists as ws}from"@buoy-gg/shared-ui/web";import{WIRE_DETAIL_LIMIT_BYTES as hr,createSyncAdapter as xs,detailByIdAction as vs,isJsonSerializable as Ts,isOverWireBudget as Is,memoByIdentity as ks,onDeviceMarker as gr,readParams as Fe,toWire as pr,truncatedNote as Ds}from"@buoy-gg/shared-ui/web";var Me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype;function fr(e,t){if(!Me(e)||!Me(t))return t;let r={...e};for(let[a,n]of Object.entries(t))r[a]=a in e?fr(e[a],n):n;return r}var Ke=gr("State","State trees stay on the device \u2014 fetched on demand via getChangeDetail / getStoreState."),$s=gr("Payload","Partial stays on the device \u2014 fetched on demand via getChangeDetail.");function Es(e,t){let r=e;for(let a of t.split(".")){if(!r||typeof r!="object"||Array.isArray(r)||!(a in r))return false;r=r[a]}return Array.isArray(r)?r.length>0:!!r&&typeof r=="object"}function Bs(e){return e&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e):void 0}var Ps=ks(e=>({...e,prevState:Ke,nextState:Ke,partial:pr(e.partial,$s)})),Ns=e=>pr(e,Ke),As=xs({version:2,getSnapshot:()=>({changes:S.getStateChanges().map(Ps),stores:S.getStoreSnapshots().map(e=>({...e,currentState:Ns(e.currentState)}))}),subscribe:[e=>S.subscribe(e),e=>S.subscribeToStores(e)],actions:{clearEvents:()=>{S.clearStateChanges()},getChangeDetail:vs(e=>S.getStateChangeById(e),(e,t)=>({prevState:t(e.prevState),nextState:t(e.nextState),partial:t(e.partial)})),getStoreState:e=>{let{storeName:t,path:r}=Fe(e);if(!t)return{found:false,reason:"missing storeName"};let a=S.getStore(t);if(!a)return{found:false,reason:"unknown storeName"};let n;try{n=a.api.getState()}catch{n=void 0}if(r){let s=bs(n,r);return s.ok?{found:true,storeName:t,path:r,shape:We(s.value),currentState:s.value}:{found:false,reason:s.error}}let o=We(n);return Is(n,hr)?{found:true,storeName:t,...o?{shape:o}:{},currentState:Ts(n)?Ds(hr):Ke}:{found:true,storeName:t,...o?{shape:o}:{},currentState:n}},listStores:e=>{let{includeValues:t=false,limit:r}=Fe(e),a=S.getStoreSnapshots(),n=(typeof r=="number"&&r>0?a.slice(0,r):a).map(o=>({name:o.name,...o.library?{library:o.library}:{},changes:o.stateChangeCount,isPersisted:o.isPersisted,persistName:o.persistName,canRehydrate:o.canRehydrate,...t?{currentState:o.currentState}:{keys:Bs(o.currentState)},...We(o.currentState)?{shape:We(o.currentState)}:{}}));return{stores:n,total:a.length,returned:n.length,includedValues:t}},setState:e=>{let{storeName:t,state:r,replace:a,force:n,path:o,value:s}=Fe(e),d=r,i=[],f=[];if(!t)return{ok:false,error:"Missing storeName."};let l=S.getStore(t);if(!l)return{ok:false,error:`No store named "${t}".`};if(r===void 0&&o===void 0)return{ok:false,error:"Refused: no change was described. Send `state` with the fields to merge, or `path` and `value` to set one value."};let u=false;if(o!==void 0){if(s===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${o}" to; if you mean to clear it, send value:null and the field must already be nullable.`};let p;try{p=l.api.getState()}catch{p=void 0}let y=ys(p,o,s);if(!y.ok)return{ok:false,error:`Refused: ${y.error}`};d=y.patch,u=true}if(!n&&(a===false||u)){let p;try{p=l.api.getState()}catch{p=void 0}if(p!==void 0){let y=ms(p,d);if(y.error)return{ok:false,error:`Refused: ${y.error}`};d=y.patch,i=y.notes}if(p!==void 0&&(f=ws(p).filter(y=>Es(d,y))),p!==void 0){let y=Cs(p,d,{noun:"store"});if(y.length>0)return{ok:false,error:Ss(y,"store",ht(d,y)),...ht(d,y)?{suggestedState:ht(d,y)}:{},violations:y}}}let b=u||a===false;if(b){let p;try{p=l.api.getState()}catch{p=void 0}if(Me(p)&&Me(d)){let y={};for(let[B,D]of Object.entries(d))y[B]=B in p?fr(p[B],D):D;d=y}}return l.api.setState(d,b?false:a??true),{ok:true,...o!==void 0?{path:o}:{},...i.length?{keyed:i}:{},...f.length?{unchecked:f.map(p=>`\`${p}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the app renders a field you left out, it will render undefined \u2014 read the store back and compare against how the screen uses it.`)}:{}}},rehydrate:async e=>{let{storeName:t}=Fe(e);if(!t)return{ok:false,error:"Missing storeName."};let r=S.getStore(t);return r?r.isPersisted?r.rehydrate?(await r.rehydrate(),{ok:true,storeName:t,persistName:r.persistName}):{ok:false,error:`"${t}" is persisted but Buoy has no rehydrate handle for it. It was probably registered before the app's persist middleware attached.`}:{ok:false,error:`"${t}" is not a persisted store \u2014 it has no saved copy to re-read.`}:{ok:false,error:`No store named "${t}".`}}}});export{ds as ZUSTAND_ICON_COLOR,ut as ZustandIcon,He as ZustandModal,_t as ZustandStateChangeItem,or as ZustandStateDetailContent,nr as ZustandStateDetailFooter,ls as ZustandToolView,ps as buoyDevTools,us as createZustandTool,fs as isStoreInstrumented,Ut as useZustandStateChanges,hs as watchStores,S as zustandStateStore,As as zustandSyncAdapter,cs as zustandToolPreset};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/zustand",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.75",
|
|
4
4
|
"description": "Inspect registered Zustand stores, compare captured state changes and use supported reset or state-update actions.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"./lib/web/**/*.mjs"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@buoy-gg/
|
|
42
|
-
"@buoy-gg/
|
|
41
|
+
"@buoy-gg/license": "^7.0.75",
|
|
42
|
+
"@buoy-gg/shared-ui": "^7.0.75"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "*",
|