import{R as e,u as t}from"./vendor-react-Dp9pL_Wn.js";const n=e=>(t,n,r)=>{const o=r.subscribe;r.subscribe=(e,t,n)=>{let s=e;if(t){const o=(null==n?void 0:n.equalityFn)||Object.is;let a=e(r.getState());s=n=>{const r=e(n);if(!o(a,r)){const e=a;t(a=r,e)}},(null==n?void 0:n.fireImmediately)&&t(a,a)}return o(s)};return e(t,n,r)};function r(e,t){let n;try{n=e()}catch(r){return}return{getItem:e=>{var t;const r=e=>null===e?null:JSON.parse(e,void 0),o=null!=(t=n.getItem(e))?t:null;return o instanceof Promise?o.then(r):r(o)},setItem:(e,t)=>n.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>n.removeItem(e)}}const o=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>o(e)(n),catch(e){return this}}}catch(n){return{then(e){return this},catch:e=>o(e)(n)}}},s=(e,t)=>(n,s,a)=>{let i={storage:r(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},c=!1,u=0;const l=new Set,d=new Set;let f=i.storage;if(!f)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...e)},s,a);const b=()=>{const e=i.partialize({...s()});return f.setItem(i.name,{state:e,version:i.version})},g=a.setState;a.setState=(e,t)=>(g(e,t),b());const m=e((...e)=>(n(...e),b()),s,a);let v;a.getInitialState=()=>m;const S=()=>{var e,t;if(!f)return;const r=++u;c=!1,l.forEach(e=>{var t;return e(null!=(t=s())?t:m)});const a=(null==(t=i.onRehydrateStorage)?void 0:t.call(i,null!=(e=s())?e:m))||void 0;return o(f.getItem.bind(f))(i.name).then(e=>{if(e){if("number"!=typeof e.version||e.version===i.version)return[!1,e.state];if(i.migrate){const t=i.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;if(r!==u)return;const[o,a]=e;return v=i.merge(a,null!=(t=s())?t:m),n(v,!0),o?b():void 0}).then(()=>{r===u&&(null==a||a(v,void 0),v=s(),c=!0,d.forEach(e=>e(v)))}).catch(e=>{r===u&&(null==a||a(void 0,e))})};return a.persist={setOptions:e=>{i={...i,...e},e.storage&&(f=e.storage)},clearStorage:()=>{null==f||f.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>S(),hasHydrated:()=>c,onHydrate:e=>(l.add(e),()=>{l.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},i.skipHydration||S(),v||m},a=e=>{let t;const n=new Set,r=(e,r)=>{const o="function"==typeof e?e(t):e;if(!Object.is(o,t)){const e=t;t=(null!=r?r:"object"!=typeof o||null===o)?o:Object.assign({},t,o),n.forEach(n=>n(t,e))}},o=()=>t,s={setState:r,getState:o,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e))},a=t=e(r,o,s);return s},i=e=>e?a(e):a,c=e=>e;function u(t,n=c){const r=e.useSyncExternalStore(t.subscribe,e.useCallback(()=>n(t.getState()),[t,n]),e.useCallback(()=>n(t.getInitialState()),[t,n]));return e.useDebugValue(r),r}const l=e=>{const t=i(e),n=e=>u(t,e);return Object.assign(n,t),n},d=e=>e?l(e):l,f=e=>Symbol.iterator in e,b=e=>"entries"in e,g=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[o,s]of n)if(!r.has(o)||!Object.is(s,r.get(o)))return!1;return!0};function m(e,t){return!!Object.is(e,t)||"object"==typeof e&&null!==e&&"object"==typeof t&&null!==t&&(Object.getPrototypeOf(e)===Object.getPrototypeOf(t)&&(f(e)&&f(t)?b(e)&&b(t)?g(e,t):((e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let o=n.next(),s=r.next();for(;!o.done&&!s.done;){if(!Object.is(o.value,s.value))return!1;o=n.next(),s=r.next()}return!!o.done&&!!s.done})(e,t):g({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})))}const{useSyncExternalStoreWithSelector:v}=t,S=e=>e;function h(t,n=S,r){const o=v(t.subscribe,t.getState,t.getInitialState,n,r);return e.useDebugValue(o),o}function p(t){const n=e.useRef(void 0);return e=>{const r=t(e);return m(n.current,r)?n.current:n.current=r}}export{r as a,i as b,d as c,u as d,h as e,n as f,s as p,m as s,p as u};
