@buoy-gg/zustand 7.0.63 → 7.0.64

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/web/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- "use client";var wt=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var Lr=Object.prototype.hasOwnProperty;var zr=(e,t)=>{for(var r in t)wt(e,r,{get:t[r],enumerable:true})},vt=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Rr(t))!Lr.call(e,n)&&n!==r&&wt(e,n,{get:()=>t[n],enumerable:!(a=Ar(t,n))||a.enumerable});return e},Vr=(e,t,r)=>(vt(e,t,"default"),r&&vt(r,t,"default"));var bi=(()=>{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 Hr,createRestoreScope as jr,emptyRestoreResult as Or,failedRestore as Wr,registerStateSnapshotProvider as Fr,unionKeys as Mr}from"@buoy-gg/shared-ui/web";import{ChangeLog as Kr,entityColor as Ur,formatValuePreview as _r,shallowDiffSummary as Zr}from"@buoy-gg/shared-ui/web";var Gr={counter:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",navigation:"#F97316",form:"#EF4444"};function Tt(e){return Ur(e,Gr)}function Jr(e,t=40){return _r(e,{maxLength:t,undefinedLabel:"",functionLabel:"(updater fn)"})}var Yr=class extends Kr{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:i,category:c,isPersisted:s=false}=e,p=n!==o,{summary:m,changedKeys:y,changedCount:b}=Zr(n,o),h=Jr(r),f=(i??0)>16,P=c??(a?"replace":"setState"),D={id:this.nextId(),storeName:t,timestamp:Date.now(),prevState:n,nextState:o,partial:r,duration:i,hasStateChange:p,replace:a,category:P,changedKeys:y,changedKeysCount:b,diffSummary:m,partialPreview:h,isSlowUpdate:f,isPersisted:s};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 i=o.prevState;(!i||i.__buoyStateOnDevice!==true)&&r.set(o.id,o)}let a=e.slice(0,this.max).map(o=>{let i=r.get(o.id),c=o.prevState;return i&&c?.__buoyStateOnDevice===true?{...o,prevState:i.prevState,nextState:i.nextState,partial:i.partial}:o}),n=new Map;for(let[o,i]of this.stores)try{let c=i.api.getState(),s=c;(!s||s.__buoyStateOnDevice!==true)&&n.set(o,c)}catch{}this.stores=new Map(t.map(o=>{let i=o.currentState,c=n.get(o.name),s=c!==void 0&&i?.__buoyStateOnDevice===true?c:o.currentState;return[o.name,{name:o.name,api:{getState:()=>s,setState:(p,m)=>{this.remoteSetStateHandler?.(o.name,p,m)},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:Tt(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??Tt(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,i)=>o+i,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 Yr;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((i,c)=>typeof i=="function"?(r.push(`${t}[${c}]`),null):ve(i,`${t}[${c}]`,r,a,n+1));if(!Z(e))return e;let o={};for(let[i,c]of Object.entries(e)){if(typeof c=="function"){r.push(t?`${t}.${i}`:i);continue}o[i]=ve(c,t?`${t}.${i}`:i,r,a,n+1)}return o}function It(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 qr(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 kt=8;function Dt(e,t,r,a){if(!(!Z(t)||!Z(e))&&!(a>=kt||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(!Bt(o,new WeakSet,a+1))continue;e[n]={}}Dt(e[n],o,r,a+1)}}}function Bt(e,t,r){if(r>=kt||t.has(e))return false;t.add(e);for(let a of Object.values(e))if(typeof a=="function"||Z(a)&&Bt(a,t,r+1))return true;return false}function Qr(){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 Xr(){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 ea(e,t){let r=e,a=jr(t),n=Or();if(!r?.stores)return Wr("empty zustand snapshot");for(let[i,c]of Object.entries(r.stores)){if(!a.allows(i))continue;let s=S.getStore(i);if(!s){n.skipped.push({id:i,reason:"store not registered (renamed, or created after snapshot?)"});continue}try{let p=c.state;Dt(p,s.api.getState(),new WeakSet,0),s.api.setState(p,true),s.api.getState()===p?n.applied+=1:(n.warnings.push(`store "${i}": setState did not take effect`),n.ok=false)}catch(p){n.skipped.push({id:i,reason:String(p)}),n.ok=false}}let o=a.excludedWarning("store(s)");return o&&n.warnings.push(o),n}async function ta(e,t){let r=e?.stores??{},a=t===void 0,n={};if(a)for(let s of S.getStores()){let p=[];try{n[s.name]={state:ve(s.api.getState(),"",p,new WeakSet,0),fnPaths:p}}catch{}}else Object.assign(n,t?.stores??{});let o=[],i=[],c=0;for(let s of Mr(n,r)){let p=s in r,m=s in n;if(!p){a?i.push(`store "${s}" not in snapshot \u2014 untouched`):o.push({key:s,label:s,verdict:"removed",oldValue:n[s].state});continue}if(c+=r[s].fnPaths?.length??0,a&&!S.getStore(s)){o.push({key:s,label:s,verdict:"wont-apply",reason:"store not registered (renamed, or created after snapshot?)"});continue}o.push(Hr({key:s,label:s,oldValue:n[s]?.state,newValue:r[s].state,inOld:m,inNew:true},{tooLargeReason:"store too large to render a diff \u2014 restore still applies it"}))}return c>0&&i.push(`${c} store action function${c===1?"":"s"} preserved on restore (not diffed)`),{items:o,notes:i}}Fr({id:"zustand",label:"Zustand",status:Qr,capture:Xr,restore:ea,previewItems:ta});import{useState as Q,useMemo as te,useRef as $e,useCallback as E,useEffect as $t}from"react";var Pt={};zr(Pt,{AccessibilityInfo:()=>na,ActivityIndicator:()=>Xa,Alert:()=>ro,Animated:()=>ia,AppRegistry:()=>la,AppState:()=>ca,Appearance:()=>sa,BackHandler:()=>da,Button:()=>eo,CheckBox:()=>ka,Clipboard:()=>ua,DeviceEventEmitter:()=>Wa,Dimensions:()=>ha,Easing:()=>ga,FlatList:()=>_e,I18nManager:()=>pa,Image:()=>Da,ImageBackground:()=>Ba,InteractionManager:()=>ma,Keyboard:()=>fa,KeyboardAvoidingView:()=>$a,LayoutAnimation:()=>ya,Linking:()=>ba,LogBox:()=>Oa,Modal:()=>qa,NativeEventEmitter:()=>Sa,NativeModules:()=>oa,PanResponder:()=>Ca,Picker:()=>Pa,PixelRatio:()=>xa,Platform:()=>wa,Pressable:()=>Ya,ProgressBar:()=>Na,RefreshControl:()=>Ea,SafeAreaView:()=>Aa,ScrollView:()=>Te,SectionList:()=>Ra,Share:()=>va,StatusBar:()=>La,StyleSheet:()=>le,Switch:()=>Qa,Text:()=>x,TextInput:()=>Za,Touchable:()=>za,TouchableHighlight:()=>Ga,TouchableNativeFeedback:()=>Va,TouchableOpacity:()=>re,TouchableWithoutFeedback:()=>Ja,UIManager:()=>Ta,Vibration:()=>Ia,View:()=>d,VirtualizedList:()=>Ha,YellowBox:()=>ja,findNodeHandle:()=>to,unstable_createElement:()=>aa,useColorScheme:()=>Fa,useLocaleContext:()=>Ma,useWindowDimensions:()=>Ka});Vr(Pt,ra);import*as ra from"react-native-web";import{unstable_createElement as aa,NativeModules as oa,AccessibilityInfo as na,Animated as ia,Appearance as sa,AppRegistry as la,AppState as ca,BackHandler as da,Clipboard as ua,Dimensions as ha,Easing as ga,I18nManager as pa,Keyboard as fa,InteractionManager as ma,LayoutAnimation as ya,Linking as ba,NativeEventEmitter as Sa,PanResponder as Ca,PixelRatio as xa,Platform as wa,Share as va,StyleSheet as le,UIManager as Ta,Vibration as Ia,CheckBox as ka,FlatList as _e,Image as Da,ImageBackground as Ba,KeyboardAvoidingView as $a,Picker as Pa,ProgressBar as Na,RefreshControl as Ea,SafeAreaView as Aa,SectionList as Ra,StatusBar as La,Touchable as za,TouchableNativeFeedback as Va,VirtualizedList as Ha,YellowBox as ja,LogBox as Oa,DeviceEventEmitter as Wa,useColorScheme as Fa,useLocaleContext as Ma,useWindowDimensions as Ka}from"react-native-web";import*as M from"react-native-web";import{createElement as Ua,forwardRef as _a}from"react";function K(e){let t=_a((a,n)=>{let{accessibilityState:o,accessibilityValue:i,...c}=a;for(let s of["busy","checked","disabled","expanded","selected"])o?.[s]!==void 0&&c[`aria-${s}`]===void 0&&(c[`aria-${s}`]=o[s]);for(let[s,p]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[s]!==void 0&&c[`aria-${p}`]===void 0&&(c[`aria-${p}`]=i[s]);return Ua(e,{...c,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var d=K(M.View),x=K(M.Text),Za=K(M.TextInput),re=K(M.TouchableOpacity),Ga=K(M.TouchableHighlight),Ja=K(M.TouchableWithoutFeedback),Ya=K(M.Pressable),Te=K(M.ScrollView),qa=K(M.Modal),Qa=K(M.Switch),Xa=K(M.ActivityIndicator),eo=K(M.Button),to=M.findNodeHandle,ro={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 i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let c=r?.length?r:[{text:"OK"}],s=()=>{n.close?.(),n.remove()};for(let p of c){let m=document.createElement("button");m.type="button",m.textContent=p.text??"OK",m.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${p.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,m.onclick=()=>{s(),p.onPress?.()},i.appendChild(m)}n.addEventListener("cancel",p=>{p.preventDefault(),a?.cancelable!==false&&(s(),a?.onDismiss?.())}),n.appendChild(i),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{JsModal as ao,ModalHeader as A,TabSelector as oo,macOSColors as no,night as V,ToolEmptyState as Ze,resolveListEmptyState as Nt,Search as io,Filter as so,Power as lo,Lock as co,devToolsStorageKeys as uo,ProUpgradeModal as ho,PowerToggleButton as go,ToolbarCopyButton as Ge,ToolbarClearButton as po,truncatePayload as he,TickProvider as Et,useLimit as fo,windowDragProps as mo,EVENT_LIST_PRESET as At}from"@buoy-gg/shared-ui/web";import{useIsPro as yo}from"@buoy-gg/license/web";import{useCallback as bo,useMemo as Rt}from"react";import{useChangeLog as So,useSubscribedValue as Co}from"@buoy-gg/shared-ui/web";function xo(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 wo=()=>S.getStores(),vo=e=>S.subscribeToStores(e);function Lt(){let e=So(S,{filterItems:xo}),t=Co(wo,vo),r=Rt(()=>{let o=e.items.length,i=e.items.filter(c=>c.hasStateChange).length;return{totalChanges:o,changesWithStateChange:i,changesWithoutStateChange:o-i,storeCount:t.length,averageDuration:0}},[e.items,t]),a=Rt(()=>S.getUniqueStoreNames(),[t]),n=bo(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 To}from"react";import{ChangeRow as Io,buoyColors as zt,night as ko}from"@buoy-gg/shared-ui/web";import{jsx as Do}from"react/jsx-runtime";function Bo(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 Po(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 No(e){return e.category==="replace"?"REPLACE":e.category==="persist"?"HYDRATE":e.category==="initial"?"INIT":"SET"}function Eo(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 Vt=To(function({change:e,onPress:t,testID:r}){let a=$o(e.category,e.storeName),n=Bo(e.category,e.storeName),o=Po(e),i=Eo(e),c=No(e);return Do(Io,{statusColor:a,statusLabel:n,sublabel:o,primaryText:i,timestamp:e.timestamp,badgeText:c,changed:e.hasStateChange,slow:e.isSlowUpdate,onPress:()=>t(e),testID:r})});import{useState as Ht,useCallback as Pe,useMemo as jt}from"react";import{night as ae,EventStepperFooter as Ot,formatRelativeTime as Ne,parseValue as Ee,monoFont as Ie}from"@buoy-gg/shared-ui/web";import{DataViewer as Ao,SplitDiffViewer as Ro,TreeDiffViewer as Lo,diffThemes as zo}from"@buoy-gg/shared-ui/web/dataViewer";import{memo as Vo}from"react";import{DetailViewToggle as Ho,FileText as jo,Database as Oo,GitBranch as Wo}from"@buoy-gg/shared-ui/web";import{jsx as Fo}from"react/jsx-runtime";var Mo=[{key:"change",label:"CHANGE",description:"View change details",icon:jo},{key:"state",label:"STATE",description:"View current state",icon:Oo},{key:"diff",label:"DIFF",description:"Compare changes",icon:Wo}],Ko=["diff"],Uo=Vo(function({activeView:e,onViewChange:t,diffDisabled:r=false}){return Fo(Ho,{views:Mo,activeView:e,onViewChange:t,disabledKeys:r?Ko:void 0,testIDPrefix:"buoy-zustand"})});import{memo as _o,useCallback as Je,useState as Zo,useEffect as Go}from"react";import{buoyColors as H,night as I,Clock as Jo,AlertTriangle as Yo,Zap as Wt,Info as qo,Box as Ft,Database as Qo,parseValue as Xo,ProUpgradeModal as en,copyToClipboard as tn,InfoRow as Mt,monoFont as ge}from"@buoy-gg/shared-ui/web";import{useIsPro as rn}from"@buoy-gg/license/web";import{DataViewer as an}from"@buoy-gg/shared-ui/web/dataViewer";import{night as $,monoFont as on}from"@buoy-gg/shared-ui/web";import{jsx as Kt,jsxs as nn}from"react/jsx-runtime";var sn={copy:{color:$.color.accent,backgroundColor:$.color.accentSoft,borderColor:$.color.accentBorder,textColor:$.color.accent},reset:{color:$.color.warning,backgroundColor:$.color.warningSoft,borderColor:$.color.warning+"40",textColor:$.color.warning},clear:{color:$.color.danger,backgroundColor:$.color.dangerSoft,borderColor:$.color.danger+"40",textColor:$.color.danger},jump:{color:$.color.warning,backgroundColor:$.color.warningSoft,borderColor:$.color.warning+"40",textColor:$.color.warning}};function Ye({onPress:e,text:t,type:r,disabled:a=false,testID:n}){let o=sn[r];return nn(re,{disabled:a,onPress:e,style:[qe.button,{backgroundColor:a?$.color.textTertiary+"1A":o.backgroundColor,borderColor:a?$.color.textTertiary+"33":o.borderColor,opacity:a?.5:1}],activeOpacity:.7,testID:n,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:a},children:[Kt(d,{style:[qe.dot,{backgroundColor:a?$.color.textTertiary:o.color}]}),Kt(x,{style:[qe.text,{color:a?$.color.textTertiary:o.textColor}],children:t})]})}var qe=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:$.color.text,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:2},text:{fontSize:10,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:on,height:12}});var u="buoy-zustand";function Qe(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function ln(e,t){return`${u}-row-${Qe(e)}-${t}`}function Ut(e){return`${u}-store-${Qe(e)}`}function cn(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,ln(a.storeName,n))}return r}import{jsx as w,jsxs as W}from"react/jsx-runtime";function dn(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 un(e){return e===void 0?"N/A":e<1?"<1ms":`${e.toFixed(1)}ms`}function Ae({icon:e,title:t,badge:r,testID:a}){return W(d,{style:C.sectionHeader,testID:a,children:[W(d,{style:C.sectionHeaderLeft,children:[w(e,{size:14,color:I.color.accent}),w(x,{style:C.sectionTitle,children:t})]}),r]})}function hn(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 gn=_o(function({change:e}){let t=rn(),[r,a]=Zo(false);Go(()=>{r&&t&&a(false)},[r,t]);let n=dn(e.category),o=e.partial!==void 0&&e.partial!=="(updater fn)",i=e.changedKeys.length>0,c=S.getStoreColor(e.storeName),s=Je(async()=>{if(!t){a(true);return}await tn(e.nextState)},[e.nextState,t]),p=Je(()=>{let y=S.getStore(e.storeName);if(y?.api.getInitialState){let b=y.api.getInitialState();y.api.setState(b,true)}},[e.storeName]),m=Je(()=>{let y=S.getStore(e.storeName);y&&y.api.setState(e.nextState,true)},[e.storeName,e.nextState]);return W(Te,{style:C.container,contentContainerStyle:C.contentContainer,showsVerticalScrollIndicator:false,testID:`${u}-detail-scroll`,children:[W(d,{style:C.card,testID:`${u}-info-card`,children:[w(Ae,{icon:qo,title:"CHANGE INFO"}),W(d,{style:C.cardContent,children:[w(Mt,{label:"Store",value:e.storeName,mono:true,valueColor:c,testID:`${u}-info-store`}),w(Mt,{label:"Time",value:hn(e.timestamp),mono:true,testID:`${u}-info-time`}),W(d,{style:C.badgeRow,children:[w(d,{style:[C.categoryBadge,{backgroundColor:n.bgColor}],children:w(x,{style:[C.categoryText,{color:n.color}],testID:`${u}-info-category`,children:n.label})}),W(d,{style:[C.durationBadge,e.isSlowUpdate&&C.durationBadgeSlow],children:[w(Jo,{size:10,color:e.isSlowUpdate?H.error:I.color.textSecondary}),w(x,{style:[C.durationText,e.isSlowUpdate&&C.durationTextSlow],testID:`${u}-info-duration`,children:un(e.duration)}),e.isSlowUpdate&&w(Yo,{size:10,color:H.error})]}),e.hasStateChange?W(d,{style:C.changesBadge,children:[w(Wt,{size:10,color:H.success}),w(x,{style:C.changesText,testID:`${u}-info-changes`,children:e.diffSummary||"changed"})]}):w(d,{style:C.noChangesBadge,children:w(x,{style:C.noChangesText,testID:`${u}-info-no-changes`,children:"no change"})}),e.isPersisted&&W(d,{style:C.persistBadge,children:[w(Qo,{size:10,color:H.info}),w(x,{style:C.persistText,testID:`${u}-info-persisted`,children:"PERSISTED"})]})]})]})]}),i&&W(d,{style:C.card,testID:`${u}-keys-card`,children:[w(Ae,{icon:Wt,title:"CHANGED KEYS",badge:w(d,{style:C.countBadge,children:w(x,{style:C.countText,testID:`${u}-keys-count`,children:e.changedKeys.length})})}),w(d,{style:C.cardContent,children:w(d,{style:C.keysContainer,children:e.changedKeys.map(y=>w(d,{style:C.keyBadge,children:w(x,{style:C.keyText,testID:`${u}-key-${y}`,children:y})},y))})})]}),o&&W(d,{style:C.card,testID:`${u}-partial-card`,children:[w(Ae,{icon:Ft,title:"PARTIAL (setState argument)",badge:w(d,{style:C.typeBadge,children:w(x,{style:C.typeText,testID:`${u}-partial-type`,children:Array.isArray(e.partial)?"ARRAY":typeof e.partial=="object"?"OBJECT":(typeof e.partial).toUpperCase()})})}),w(d,{style:C.dataViewerContainer,children:w(an,{title:"",data:Xo(e.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),e.partial==="(updater fn)"&&W(d,{style:C.card,testID:`${u}-updater-card`,children:[w(Ae,{icon:Ft,title:"SET STATE CALL"}),W(d,{style:C.cardContent,children:[w(x,{style:C.updaterText,children:"Called with an updater function: set((state) => ...)"}),w(x,{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(d,{style:C.actionsGrid,children:[w(Ye,{type:"jump",text:"JUMP",onPress:m,testID:`${u}-jump`}),w(Ye,{type:"reset",text:"RESET STORE",onPress:p,testID:`${u}-reset`}),w(Ye,{type:"copy",text:"COPY STATE",onPress:s,testID:`${u}-copy-state`})]}),w(en,{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 pn,CompareBar as fn}from"@buoy-gg/shared-ui/web";import{jsx as B,jsxs as pe}from"react/jsx-runtime";function Xe(e){return S.getStoreColor(e.storeName)}function _t(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function mn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Zt(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}var yn=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];function Gt({change:e,changes:t,selectedIndex:r,onIndexChange:a,disableInternalFooter:n=false,initialView:o="change"}){let[i,c]=Ht(o),[s,p]=Ht("tree"),m=t.length,y=Xe(e),b=_t(e),h=mn(Ee(e.nextState)),f=m-r,P=f-1,D=r<m-1?r+1:null,j=D!==null?t[D]:null,O=jt(()=>({index:D??0,label:P>0?`#${P}`:"Initial",timestamp:j?Zt(j.timestamp):"",relativeTime:j?Ne(new Date(j.timestamp)):"state",badge:j?B(d,{style:[N.changeBadgeSmall,{backgroundColor:`${Xe(j)}20`}],children:B(x,{style:[N.changeTextSmall,{color:Xe(j)}],children:_t(j)})}):void 0}),[D,j,P]),me=jt(()=>({index:r,label:`#${f}`,timestamp:Zt(e.timestamp),relativeTime:Ne(new Date(e.timestamp)),badge:B(d,{style:[N.changeBadgeSmall,{backgroundColor:`${y}20`}],children:B(x,{style:[N.changeTextSmall,{color:y}],children:b})})}),[r,e.timestamp,y,b,f]),oe=Pe(()=>{let ne=Ee(e.nextState);return pe(d,{style:N.contentCard,testID:`${u}-state-card`,children:[pe(d,{style:N.valueHeader,children:[B(x,{style:N.valueLabel,children:"STATE AFTER CHANGE"}),pe(d,{style:N.valueHeaderBadges,children:[B(d,{style:[N.changeBadge,{backgroundColor:`${y}20`}],children:B(x,{style:[N.changeText,{color:y}],children:b})}),B(d,{style:N.typeBadge,children:B(x,{style:N.typeText,testID:`${u}-state-type`,children:h.toUpperCase()})})]})]}),B(d,{style:N.dataViewerContainer,children:B(Ao,{title:"",data:ne,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextState,y,b,h]),ye=Pe(()=>{let ne=Ee(e.prevState),de=Ee(e.nextState);return s==="split"?B(Te,{style:{flex:1},showsVerticalScrollIndicator:true,children:B(Ro,{oldValue:ne,newValue:de,theme:zo.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})}):B(Lo,{oldValue:ne,newValue:de})},[e.prevState,e.nextState,s]),be=Pe(()=>{a(Math.min(m-1,r+1))},[r,m,a]),Se=Pe(()=>{a(Math.max(0,r-1))},[r,a]),J=e.prevState===void 0,Ce=!n&&m>1;return pe(d,{style:N.container,children:[B(Uo,{activeView:i,onViewChange:c,diffDisabled:J}),pe(d,{style:[N.contentArea,Ce&&N.contentAreaFooterPad],children:[i==="change"&&B(gn,{change:e}),i==="state"&&B(d,{style:N.stateContainer,children:oe()}),i==="diff"&&pe(d,{style:N.diffContainer,testID:`${u}-diff`,children:[B(pn,{tabs:yn,activeTab:s,onTabChange:p,testIDPrefix:`${u}-diff-tab`}),B(fn,{leftEvent:O,rightEvent:me}),B(d,{style:N.diffContent,testID:`${u}-diff-content`,children:ye()})]})]}),Ce&&B(Ot,{currentIndex:f-1,totalItems:m,onPrevious:be,onNext:Se,itemLabel:"Change",subtitle:Ne(new Date(e.timestamp)),absolute:true})]})}function Jt({change:e,changes:t,selectedIndex:r,onIndexChange:a}){let n=t.length;if(n<=1)return null;let o=n-r;return B(Ot,{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 N=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:Ie,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:Ie,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:ae.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:ae.color.textTertiary,fontFamily:Ie},valueBox:{backgroundColor:ae.color.bg,borderRadius:6,borderWidth:1,borderColor:ae.color.border,padding:8},valueText:{fontSize:12,color:ae.color.text,fontFamily:Ie,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:Ie},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as bn}from"react";import{CompactRow as Sn,night as et,ToolEmptyState as tt,resolveListEmptyState as Cn,monoFont as Yt}from"@buoy-gg/shared-ui/web";import{jsx as G,jsxs as rt}from"react/jsx-runtime";function xn(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 wn(){return G(tt,{testID:`${u}-stores-loading`,otto:"loading",title:"Loading stores\u2026",message:"Waiting for the device to send its registered stores."})}function vn(){return G(tt,{testID:`${u}-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 Tn({stores:e,searchQuery:t,isLoading:r=false,onOpenStore:a}){let n=bn(()=>{if(!t)return e;let o=t.toLowerCase();return e.filter(i=>i.name.toLowerCase().includes(o)||i.persistName&&i.persistName.toLowerCase().includes(o))},[e,t]);return n.length===0&&!t?r?G(wn,{}):G(vn,{}):n.length===0&&t?G(tt,{testID:`${u}-stores-no-match`,...Cn({subject:"stores",verb:"registered",search:t,total:e.length,waiting:{otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores."}})}):rt(Te,{style:X.container,contentContainerStyle:X.scrollContent,showsVerticalScrollIndicator:true,testID:`${u}-stores-scroll`,children:[rt(d,{style:X.sectionHeader,children:[G(x,{style:X.sectionTitle,children:"STORES"}),G(d,{style:X.sectionCountBadge,children:G(x,{style:X.sectionCountText,testID:`${u}-stores-count`,children:n.length})})]}),n.map(o=>{let i=xn(o),c=S.getStoreColor(o.name),s=Ut(o.name);return rt(d,{style:X.storeRowWrapper,children:[G(Sn,{statusDotColor:c,statusLabel:o.isPersisted?"persisted":"in-memory",primaryText:o.name,secondaryText:i||void 0,showChevron:true,onPress:()=>a(o.name),testID:s,statusTestID:`${s}-backing`,primaryTestID:`${s}-name`,secondaryTestID:`${s}-keys`}),o.stateChangeCount>0&&G(d,{style:[X.absCountBadge,{backgroundColor:c+"22",borderColor:c+"55"}],pointerEvents:"none",children:G(x,{style:[X.absCountText,{color:c}],testID:`${s}-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:Yt},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:et.color.textTertiary},sectionCountBadge:{backgroundColor:et.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:et.color.accent,fontFamily:Yt}});import{useCallback as In,useEffect as kn,useMemo as at,useState as Re}from"react";import{buoyColors as ot,Database as Dn,ExpandedInfoRow as Le,FileJson as Bn,night as R,PillBadge as nt,parseValue as qt,monoFont as ze}from"@buoy-gg/shared-ui/web";import{DataViewer as $n,LiveExplorer as Pn,ValueEditModal as Nn,updateNestedDataByPath as En,deleteNestedDataByPath as An}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as Qt,jsx as v,jsxs as U}from"react/jsx-runtime";var Rn=300,ce=`${u}-detail`;function Ln(e){let t=r=>r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${ce}-explorer-root`:`${ce}-explorer-${e.map(t).filter(Boolean).join("-")}`}function zn({store:e,onViewHistory:t}){let r=Ut(e.name),[a,n]=Re(0);kn(()=>e.api.subscribe(()=>n(b=>b+1)),[e.api]);let o=e.api.getState(),i=at(()=>It(o),[o,a]),[c,s]=Re(false),p=at(()=>{if(i.data!==null)return{update:(b,h)=>{let f=e.api.getState();if(!Z(f)||b.length===0)return;let P=b[0],D=b.length===1?h:En(f[P],b.slice(1),h);e.api.setState({[P]:D},false)},remove:b=>{let h=e.api.getState();if(!Z(h)||b.length<=1)return;let f=b[0],P=An(h[f],b.slice(1));e.api.setState({[f]:P},false)},canRemove:b=>b.length>1}},[e.api,i.data===null]),m=In(b=>{let h=It(e.api.getState());if(h.data===null)return;let f=qr(h.data,b);Object.keys(f).length>0&&e.api.setState(f,false),s(false)},[e.api]),y=at(()=>{if(o&&typeof o=="object"){let b={};for(let[h,f]of Object.entries(o))typeof f!="function"&&(b[h]=f);return qt(b)}return qt(o)},[o,a]);return U(d,{style:T.root,children:[U(Te,{testID:`${ce}-scroll`,style:T.scroll,contentContainerStyle:T.scrollContent,keyboardShouldPersistTaps:"handled",children:[v(d,{style:T.section,children:U(d,{style:T.editorContainer,children:[U(d,{style:T.sectionHeaderRow,children:[v(x,{testID:`${ce}-editor-header`,style:T.sectionHeaderText,children:"State Editor"}),i.data!==null?U(re,{onPress:()=>s(true),testID:`${ce}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:T.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[v(Bn,{size:13,color:R.color.accent}),v(x,{style:T.rawButtonText,children:"Raw"})]}):null]}),v(d,{style:T.sectionBody,children:i.data!==null?U(Qt,{children:[v(Pn,{editable:true,label:"State",value:i.data,defaultExpanded:["State"],writer:p,dataVersion:a,testIDForPath:Ln,debounceMs:Rn}),v(x,{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(x,{style:T.blockedText,testID:`${ce}-edit-blocked`,children:i.blockedReason})})]})}),v(d,{style:T.section,children:U(d,{style:T.infoContainer,children:[v(x,{style:T.sectionHeaderTextPlain,children:"Store Details"}),U(d,{style:T.infoBody,children:[v(Le,{label:"Type",children:v(nt,{color:e.color,testID:`${r}-type`,children:"ZUSTAND"})}),U(Le,{label:"Backing",children:[v(nt,{color:ot.info,icon:e.isPersisted?v(Dn,{size:9,color:ot.info}):void 0,testID:`${r}-persist`,children:e.isPersisted?e.persistName||"persisted":"in-memory"}),e.isPersisted?v(Vn,{store:e,rowID:r}):null]}),e.stateChangeCount>0&&U(Le,{label:"Changes",children:[v(nt,{color:ot.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(x,{style:[T.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]}),i.fnPaths.length>0&&v(Le,{label:"Actions",children:v(x,{style:T.actionsText,testID:`${ce}-actions`,numberOfLines:2,children:i.fnPaths.join(" \xB7 ")})})]})]})}),v(d,{style:T.section,children:U(d,{style:T.infoContainer,children:[v(x,{style:T.sectionHeaderTextPlain,children:"State Explorer"}),v(d,{style:T.viewerBody,testID:`${r}-state`,children:y&&typeof y=="object"?v($n,{title:"",data:y,showTypeFilter:true,rawMode:true,initialExpanded:false}):v(x,{style:T.blockedText,children:"Empty state"})})]})})]}),c&&i.data!==null?v(Nn,{path:[],value:i.data,onSave:b=>{try{m(b)}catch{}},onCancel:()=>s(false),saveLabel:"Apply",testIDPrefix:`${u}-value`}):null]})}function Vn({store:e,rowID:t}){let[r,a]=Re(false),[n,o]=Re(null);return e.rehydrate?U(Qt,{children:[v(re,{onPress:()=>{a(true),o(null),(async()=>{try{await e.rehydrate?.()}catch(i){o(i instanceof Error?i.message:String(i))}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(x,{style:[T.inlineLinkText,{color:e.color}],children:r?"re-reading\u2026":"re-read saved value \u2192"})}),n?v(x,{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:ze},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:ze},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:R.color.bg,minHeight:60},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:ze},actionsText:{flex:1,color:R.color.textSecondary,fontSize:10,fontFamily:ze,lineHeight:15}});import{useMemo as Hn}from"react";import{EntityFilterView as jn}from"@buoy-gg/shared-ui/web";import{jsx as On}from"react/jsx-runtime";var Wn=["\u2022 auth \u2192 hides authStore from stores & events","\u2022 temp \u2192 hides tempStore, tempUserStore","\u2022 cart \u2192 hides cartStore from both tabs"];function Fn({ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,stores:a}){let n=Hn(()=>a.map(o=>({name:o.name,color:S.getStoreColor(o.name)})),[a]);return On(jn,{entities:n,ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,entityNoun:"STORES",entitySingular:"store",entityKey:"store",testIDPrefix:u,slug:Qe,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:Wn})}import{Fragment as Xt,jsx as g,jsxs as F}from"react/jsx-runtime";function Mn({isEnabled:e,searchText:t,totalChanges:r}){let a=Nt({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 g(Ze,{...a,testID:`${u}-empty`})}function Ve({visible:e,onClose:t,onBack:r,onMinimize:a,enableSharedModalDimensions:n=false,inline:o=false,storesLoading:i=false,initialTab:c="stores",initialSelectedChangeId:s,initialDetailView:p,onChangeSelect:m,onStoreExpand:y}){let b=yo(),h=fo("zustand.changes"),[f,P]=Q(false),[D,j]=Q(c),[O,me]=Q(null),[oe,ye]=Q(null),[be,Se]=Q(false),[J,Ce]=Q(new Set),{stateChanges:ne,filteredChanges:de,filter:mi,setFilter:xe,stats:ir,stores:we,clearChanges:sr,isEnabled:ke,toggleCapture:lr}=Lt(),Y=te(()=>J.size===0?de:de.filter(l=>!Array.from(J).some(k=>l.storeName.toLowerCase().includes(k.toLowerCase()))),[de,J]),ue=te(()=>J.size===0?we:we.filter(l=>!Array.from(J).some(k=>l.name.toLowerCase().includes(k.toLowerCase()))),[we,J]),cr=te(()=>O?ne.filter(l=>l.storeName===O).length:0,[ne,O]),De=te(()=>O?Y.filter(l=>l.storeName===O):Y,[Y,O]),Fe=te(()=>De.slice(0,h),[De,h]),Me=te(()=>Math.max(0,De.length-h),[De.length,h]),dr=Me>0,z=Fe,[Ke,ie]=Q(null),se=te(()=>{if(Ke===null)return null;let l=z.findIndex(k=>k.id===Ke);return l>=0?l:null},[Ke,z]),_=se!==null?z[se]:null,lt=$e(null);$t(()=>{if(!m)return;let l=_?.id??null;l===null||l===lt.current||(lt.current=l,m(_))},[_,m]);let ct=$e(null);$t(()=>{!s||ct.current===s||!z.some(l=>l.id===s)||(ct.current=s,ie(s))},[s,z]);let[ee,Ue]=Q(""),[ur,Be]=Q(false),yi=$e(null),hr=$e(null),gr=E(l=>{},[]),pr=l=>{Ue(l),D==="events"&&xe(k=>({...k,searchText:l}))},fr=E(()=>{Ue(""),xe(l=>({...l,searchText:""})),Be(false)},[xe]),dt=E(l=>{ie(l.id)},[]),mr=E(()=>{P(true)},[]),yr=E(()=>{ie(null)},[]),ut=E(l=>{let k=z[l];k&&ie(k.id)},[z]),br=E(l=>{me(l),ie(null)},[]),Sr=E(()=>{me(null),ie(null)},[]),Cr=E(l=>{ye(l),y?.(l)},[y]),xr=E(()=>{ye(null)},[]),wr=E(()=>ue.reduce((l,k)=>{try{let q=k.api.getState();if(q&&typeof q=="object"){let Ct={};for(let[Er,xt]of Object.entries(q))typeof xt!="function"&&(Ct[Er]=he(xt));l[k.name]=Ct}else l[k.name]=he(q)}catch{l[k.name]=null}return l},{}),[ue]),vr=E(()=>Y.map(l=>({id:l.id,storeName:l.storeName,timestamp:l.timestamp,prevState:he(l.prevState),nextState:he(l.nextState),hasStateChange:l.hasStateChange,changedKeys:l.changedKeys})),[Y]),Tr=E(()=>z.map(l=>({id:l.id,storeName:l.storeName,timestamp:l.timestamp,prevState:he(l.prevState),nextState:he(l.nextState),hasStateChange:l.hasStateChange,changedKeys:l.changedKeys})),[z]),Ir=E(l=>{Ce(k=>{let q=new Set(k);return q.has(l)?q.delete(l):q.add(l),q})},[]),kr=E(l=>{Ce(k=>new Set([...k,l]))},[]),Dr=E(l=>{j(l),me(null),ye(null),ie(null),Se(false),ee&&(Ue(""),xe(k=>({...k,searchText:""}))),Be(false)},[ee,xe]),ht=E(l=>l.id,[]),gt=te(()=>cn(z),[z]),pt=E(({item:l})=>g(Vt,{change:l,onPress:dt,testID:gt.get(l.id)}),[dt,gt]),ft=J.size>0,mt=()=>be?F(A,{children:[g(A.Navigation,{onBack:()=>Se(false)}),g(A.Content,{title:"Filters",centered:true,testID:`${u}-filters-title`})]}):_?F(A,{children:[g(A.Navigation,{onBack:yr}),g(A.Content,{title:`${_.storeName}/setState`,centered:true,testID:`${u}-detail-title`})]}):O?F(A,{children:[g(A.Navigation,{onBack:Sr}),g(A.Content,{title:`${O} History`,centered:true,testID:`${u}-history-title`}),g(A.Actions,{children:g(Ge,{value:Tr,disabled:z.length===0,buttonStyle:L.headerActionButton,testID:`${u}-copy`})})]}):oe?F(A,{children:[g(A.Navigation,{onBack:xr}),g(A.Content,{title:oe,centered:true,testID:`${u}-store-detail-title`})]}):F(A,{children:[r&&g(A.Navigation,{onBack:r}),g(A.Content,{title:"",children:ur?g(A.Search,{value:ee,onChangeText:pr,onCancel:fr,placeholder:D==="stores"?"Search stores...":"Search events...",accessibilityLabel:"Search Zustand stores and events",iconSize:14,testID:`${u}-search-field`,containerTestID:`${u}-search`,clearTestID:`${u}-search-clear`,onBlur:()=>{ee.length===0&&Be(false)}}):g(oo,{tabs:[{key:"stores",label:`Stores${ue.length>0?` (${ue.length})`:""}`},{key:"events",label:`Events${Y.length>0?` (${Y.length})`:""}`}],activeTab:D,onTabChange:Dr,testIDPrefix:`${u}-tab`})}),F(A.Actions,{children:[g(re,{onPress:()=>Be(true),style:L.headerActionButton,testID:`${u}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:g(io,{size:14,color:V.color.textSecondary})}),g(re,{onPress:()=>Se(true),style:[L.headerActionButton,ft&&L.headerActionButtonActive],testID:`${u}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:g(so,{size:14,color:ft?V.color.accent:V.color.textSecondary})}),D==="stores"&&g(Ge,{value:wr,disabled:ue.length===0,buttonStyle:L.headerActionButton,testID:`${u}-copy`}),D==="events"&&F(Xt,{children:[g(Ge,{value:vr,disabled:Y.length===0,buttonStyle:L.headerActionButton,testID:`${u}-copy`}),g(go,{isEnabled:ke,onToggle:lr,accessibilityLabel:"Toggle Zustand state capture",testID:`${u}-power`}),g(po,{onPress:sr,disabled:Y.length===0,buttonStyle:L.headerActionButton,testID:`${u}-clear`})]})]})]}),Br=()=>{if(be)return g(Fn,{ignoredPatterns:J,onTogglePattern:Ir,onAddPattern:kr,stores:we});if(_&&se!==null)return g(Gt,{change:_,changes:z,selectedIndex:se,onIndexChange:ut,disableInternalFooter:true,initialView:p});if(O)return z.length>0?g(_e,{testID:`${u}-history-list`,data:z,renderItem:pt,keyExtractor:ht,contentContainerStyle:L.listContent,showsVerticalScrollIndicator:true,...At}):g(Ze,{testID:`${u}-history-empty`,...Nt({subject:"changes",search:ee,total:ee.trim()?cr:0,capturing:ke,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 l=we.find(k=>k.name===oe)??null;return l?g(zn,{store:l,onViewHistory:br}):g(Ze,{testID:`${u}-store-detail-gone`,otto:"ghost",title:"Store no longer registered",message:`${oe} is not in the registry any more.`})}return D==="stores"?g(Tn,{stores:ue,searchQuery:ee,isLoading:i,onOpenStore:Cr}):F(Xt,{children:[!ke&&F(d,{style:L.disabledBanner,testID:`${u}-banner-disabled`,children:[g(lo,{size:14,color:V.color.warning}),g(x,{style:L.disabledText,children:"State capture is disabled"})]}),dr&&F(re,{style:L.lockedBanner,onPress:mr,activeOpacity:.8,testID:`${u}-locked`,accessibilityRole:"button",children:[g(co,{size:14,color:V.color.accent}),F(x,{style:L.lockedText,testID:`${u}-locked-text`,children:[Me," older"," ",Me===1?"change":"changes"," locked"]}),g(d,{style:L.upgradeBadge,children:g(x,{style:L.upgradeBadgeText,children:"UPGRADE"})})]}),Fe.length>0?g(_e,{ref:hr,testID:`${u}-list`,data:Fe,renderItem:pt,keyExtractor:ht,contentContainerStyle:L.listContent,showsVerticalScrollIndicator:true,...At}):g(Mn,{isEnabled:ke,searchText:ee,totalChanges:ir.totalChanges})]})},$r=n?uo.modal.root():"buoy-zustand-modal";if(!e)return null;let yt=_&&se!==null?g(Jt,{change:_,changes:z,selectedIndex:se,onIndexChange:ut}):null,Pr=_&&z.length>1?68:0,Nr=!be&&(_&&se!==null||O!=null||D==="events"||D==="stores"),bt=g(d,{style:L.container,children:Br()}),St=g(ho,{visible:f,onClose:()=>P(false),featureName:"Full State History"});return o?F(Et,{children:[F(d,{style:L.inlineRoot,children:[g(d,{style:L.inlineHeader,...mo,children:mt()}),bt,yt]}),St]}):F(Et,{children:[g(ao,{visible:e,onClose:t,onMinimize:a,persistenceKey:$r,header:{showToggleButton:true,customContent:mt()},onModeChange:gr,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Nr,styles:{},footer:yt,footerHeight:Pr,children:bt}),St]})}function Kn(e={}){return g(Ve,{...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:no.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 it,ZUSTAND_ICON_COLOR as Un}from"@buoy-gg/shared-ui/web";import{jsx as er}from"react/jsx-runtime";var _n={id:"zustand",name:"ZUSTAND",description:"Zustand store & state inspector",slot:"both",icon:({size:e})=>er(it,{size:e}),component:Ve,props:{enableSharedModalDimensions:false}};function Zn(e){return{id:e?.id||"zustand",name:e?.name||"ZUSTAND",description:e?.description||"Zustand store & state inspector",slot:"both",icon:({size:t})=>er(it,{size:t,color:e?.iconColor}),component:Ve,props:{enableSharedModalDimensions:e?.enableSharedModalDimensions!==void 0?e.enableSharedModalDimensions:false}}}var fe=Symbol.for("@@buoy-zustand/watched");function tr(e){let t=e.persist;return t&&typeof t.getOptions=="function"?{isPersisted:true,persistName:t.getOptions()?.name,persistApi:t}:{isPersisted:false}}function Gn(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:i,persistApi:c}=tr(a);S.registerStore(r,{getState:a.getState,getInitialState:a.getInitialState,setState:a.setState,subscribe:a.subscribe},{isPersisted:o,persistName:i,rehydrate:typeof c?.rehydrate=="function"?()=>c.rehydrate():void 0});let s=false,p=a.subscribe((m,y)=>{try{let b;if(!s&&o){let h=false;try{h=c?.hasHydrated?.()===false}catch{}h&&(s=true,b="persist")}S.addStateChange({storeName:r,partial:void 0,replace:false,prevState:y,nextState:m,duration:void 0,category:b,isPersisted:o})}catch{}});t.push(()=>{p(),delete a[fe],S.unregisterStore(r)})}return()=>{t.forEach(r=>r())}}var Jn=0;function Yn(e,t){return(r,a,n)=>{let o=t?.name??`store-${++Jn}`,i=t?.enabled!==false,c=r,s=(m,y)=>{if(!i)return c(m,y);let b=performance.now(),h=a();c(m,y);let f=a(),P=performance.now()-b,D=typeof m=="function"?"(updater fn)":m;S.addStateChange({storeName:o,partial:D,replace:y??false,prevState:h,nextState:f,duration:P,isPersisted:S.getStore(o)?.isPersisted??false})},p=e(s,a,n);return setTimeout(()=>{if(n[fe])return;n[fe]=true;let{isPersisted:m,persistName:y}=tr(n);S.registerStore(o,{getState:a,getInitialState:n.getInitialState,setState:s,subscribe:n.subscribe},{isPersisted:m,persistName:y})},0),p}}function qn(e){return e[fe]===true}import{expandKeyedArrays as Qn,patchFromPath as Xn,readPath as ei,refusalText as ti,shapeSummary as He,suggestedPatch as st,typedEditViolations as ri,unshapedLists as ai}from"@buoy-gg/shared-ui/web";import{WIRE_DETAIL_LIMIT_BYTES as rr,createSyncAdapter as oi,detailByIdAction as ni,isJsonSerializable as ii,isOverWireBudget as si,memoByIdentity as li,onDeviceMarker as ar,readParams as je,toWire as or,truncatedNote as ci}from"@buoy-gg/shared-ui/web";var Oe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype;function nr(e,t){if(!Oe(e)||!Oe(t))return t;let r={...e};for(let[a,n]of Object.entries(t))r[a]=a in e?nr(e[a],n):n;return r}var We=ar("State","State trees stay on the device \u2014 fetched on demand via getChangeDetail / getStoreState."),di=ar("Payload","Partial stays on the device \u2014 fetched on demand via getChangeDetail.");function ui(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 hi(e){return e&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e):void 0}var gi=li(e=>({...e,prevState:We,nextState:We,partial:or(e.partial,di)})),pi=e=>or(e,We),fi=oi({version:2,getSnapshot:()=>({changes:S.getStateChanges().map(gi),stores:S.getStoreSnapshots().map(e=>({...e,currentState:pi(e.currentState)}))}),subscribe:[e=>S.subscribe(e),e=>S.subscribeToStores(e)],actions:{clearEvents:()=>{S.clearStateChanges()},getChangeDetail:ni(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}=je(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 i=ei(n,r);return i.ok?{found:true,storeName:t,path:r,shape:He(i.value),currentState:i.value}:{found:false,reason:i.error}}let o=He(n);return si(n,rr)?{found:true,storeName:t,...o?{shape:o}:{},currentState:ii(n)?ci(rr):We}:{found:true,storeName:t,...o?{shape:o}:{},currentState:n}},listStores:e=>{let{includeValues:t=false,limit:r}=je(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:hi(o.currentState)},...He(o.currentState)?{shape:He(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:i}=je(e),c=r,s=[],p=[];if(!t)return{ok:false,error:"Missing storeName."};let m=S.getStore(t);if(!m)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 y=false;if(o!==void 0){if(i===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 h;try{h=m.api.getState()}catch{h=void 0}let f=Xn(h,o,i);if(!f.ok)return{ok:false,error:`Refused: ${f.error}`};c=f.patch,y=true}if(!n&&(a===false||y)){let h;try{h=m.api.getState()}catch{h=void 0}if(h!==void 0){let f=Qn(h,c);if(f.error)return{ok:false,error:`Refused: ${f.error}`};c=f.patch,s=f.notes}if(h!==void 0&&(p=ai(h).filter(f=>ui(c,f))),h!==void 0){let f=ri(h,c,{noun:"store"});if(f.length>0)return{ok:false,error:ti(f,"store",st(c,f)),...st(c,f)?{suggestedState:st(c,f)}:{},violations:f}}}let b=y||a===false;if(b){let h;try{h=m.api.getState()}catch{h=void 0}if(Oe(h)&&Oe(c)){let f={};for(let[P,D]of Object.entries(c))f[P]=P in h?nr(h[P],D):D;c=f}}return m.api.setState(c,b?false:a??true),{ok:true,...o!==void 0?{path:o}:{},...s.length?{keyed:s}:{},...p.length?{unchecked:p.map(h=>`\`${h}\` 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}=je(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{Un as ZUSTAND_ICON_COLOR,it as ZustandIcon,Ve as ZustandModal,Vt as ZustandStateChangeItem,Gt as ZustandStateDetailContent,Jt as ZustandStateDetailFooter,Kn as ZustandToolView,Yn as buoyDevTools,Zn as createZustandTool,qn as isStoreInstrumented,Lt as useZustandStateChanges,Gn as watchStores,S as zustandStateStore,fi as zustandSyncAdapter,_n as zustandToolPreset};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/zustand",
3
- "version": "7.0.63",
3
+ "version": "7.0.64",
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/shared-ui": "^7.0.63",
42
- "@buoy-gg/license": "^7.0.63"
41
+ "@buoy-gg/license": "^7.0.64",
42
+ "@buoy-gg/shared-ui": "^7.0.64"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "*",