@storesjs/stores 0.8.6 β 0.9.0
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/dist/config.d.ts +37 -7
- package/dist/createBaseStore.d.ts +2 -2
- package/dist/createQueryStore.d.ts +7 -23
- package/dist/createStoreWithEqualityFn.d.ts +5 -0
- package/dist/createVirtualStore.d.ts +4 -3
- package/dist/derivedStore/{globalDeriveScheduler.d.ts β cascadeScheduler.d.ts} +9 -1
- package/dist/derivedStore/deriveProxy.d.ts +6 -16
- package/dist/derivedStore/pathFinder.d.ts +27 -0
- package/dist/errors.d.ts +14 -0
- package/dist/hooks/useSyncExternalStoreWithSelector.d.ts +5 -0
- package/dist/index.d.ts +3 -1
- package/dist/logger.d.ts +0 -5
- package/dist/middleware/createHydrationGate.d.ts +1 -1
- package/dist/native/index.js +1 -1
- package/dist/native/index.mjs +1 -1
- package/dist/plugins/chrome/chromeExtensionSyncEngine.d.ts +3 -1
- package/dist/queryStore/queryStoreDefaults.d.ts +8 -0
- package/dist/queryStore/signalTypes.d.ts +13 -0
- package/dist/queryStore/types.d.ts +35 -30
- package/dist/signal.d.ts +2 -11
- package/dist/storage/storageCreators.d.ts +1 -1
- package/dist/sync/syncEnhancer.d.ts +4 -0
- package/dist/sync/types.d.ts +53 -128
- package/dist/types/functions.d.ts +19 -2
- package/dist/types/objects.d.ts +10 -3
- package/dist/types/utils.d.ts +1 -1
- package/dist/types.d.ts +35 -32
- package/dist/utils/core.d.ts +23 -4
- package/dist/utils/createStoreActions.d.ts +3 -3
- package/dist/utils/persistUtils.d.ts +2 -2
- package/dist/utils/storeUtils.d.ts +22 -15
- package/dist/utils/time.d.ts +0 -3
- package/dist/web/chrome.js +1 -1
- package/dist/web/chrome.mjs +1 -1
- package/dist/web/chunk-3U5A7HQV.mjs +1 -0
- package/dist/web/index.js +1 -1
- package/dist/web/index.mjs +1 -1
- package/package.json +17 -12
- package/dist/sync/transport.d.ts +0 -113
- package/dist/web/chunk-B3GRBY25.mjs +0 -1
package/dist/web/chrome.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_STORAGE_KEY_PREFIX as t,isPromiseLike as e,replacer as r,reviver as s,isPlainObject as n}from"./chunk-
|
|
1
|
+
import{DEFAULT_STORAGE_KEY_PREFIX as t,isPromiseLike as e,replacer as r,reviver as s,isPlainObject as i,nullObject as n,hasOwn as o}from"./chunk-3U5A7HQV.mjs";var a=class{constructor(e){this.async=!0,this.deserializer=h,this.serializer=c,this.area=e?.area??"local",this.storageKeyPrefix=e?.storageKeyPrefix??t}async clearAll(){const t=this.ensureStorage();if(!t)return;if(!this.storageKeyPrefix)throw new Error("Cannot clear all storage with empty storageKeyPrefix. This would delete all storage entries.");const e=await this.listPrefixedKeys(t,this.storageKeyPrefix);e.length&&await this.execute(t,r=>t.remove(e,r))}async contains(t){const e=this.ensureStorage();if(!e)return!1;const r=this.toStorageKey(t),s=await this.getFromStorage(e,r);return Object.prototype.hasOwnProperty.call(s,r)}async delete(t){const e=this.ensureStorage();if(!e)return;const r=this.toStorageKey(t);await this.execute(e,t=>e.remove(r,t))}async getAllKeys(){const t=this.ensureStorage();if(!t)return[];const e=await this.getFromStorage(t,null),r=this.storageKeyPrefix;return r?Object.keys(e).filter(t=>t.startsWith(r)).map(t=>t.slice(r.length)):Object.keys(e)}async get(t){const e=this.ensureStorage();if(!e)return;const r=this.toStorageKey(t);return g((await this.getFromStorage(e,r))[r])||void 0}async set(t,e){const r=this.ensureStorage();if(!r)return;const s=this.toStorageKey(t);await this.execute(r,t=>r.set({[s]:e},t))}ensureStorage(){return t=this.area,"undefined"!=typeof chrome&&chrome.storage?chrome.storage[t]??null:null;var t}toStorageKey(t){return this.storageKeyPrefix?`${this.storageKeyPrefix}${t}`:t}async listPrefixedKeys(t,e){const r=await this.getFromStorage(t,null);return Object.keys(r).filter(t=>t.startsWith(e))}async getFromStorage(t,e){return this.invokeWithCallbackSupport(r=>t.get(e,r))}async execute(t,e){await this.invokeWithCallbackSupport(e)}async invokeWithCallbackSupport(t){return new Promise((r,s)=>{let i=!1;function n(t){if(i)return;i=!0;const e="undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.lastError?new Error(chrome.runtime.lastError.message):null;e?s(e):r(t)}try{const r=t(n);e(r)&&r.then(n).catch(s)}catch(t){s(t)}})}};function c(t){return{state:u(t.state),syncMetadata:t.syncMetadata,version:t.version}}function h(t){const e=g(t);if(!e)throw new Error("[ChromeStorageAdapter] Invalid serialized state format");return{state:f(e.state),syncMetadata:e.syncMetadata,version:e.version}}function g(t){if(l(t))return t;if("string"==typeof t)try{const e=JSON.parse(t);if(l(e))return e}catch{}return null}function l(t){return!(!t||"object"!=typeof t)&&Object.prototype.hasOwnProperty.call(t,"state")}function u(t,e=r){if(t instanceof Map||t instanceof Set)return e.call(void 0,"",t);if(!i(t))return t;const s={};for(const[r,i]of Object.entries(t))s[r]=e.call(t,r,i);return s}function f(t,e=s){const r=e.call(void 0,"",t);if(!i(r))return r;const n={};for(const t of Object.entries(r)){const s=t[0],i=t[1];n[s]=e.call(r,s,i)}return n}var y=class{constructor(e){this.injectStorageMetadata=!0,this.registrations=new Map,this.isListening=!1,this.onStorageChanged=async(t,e)=>{if(e===this.area)for(const e of this.registrations){const r=e[0],s=e[1];if(s.destroyed)continue;const i=t[this.toStorageKey(r)];if(i&&void 0!==i.newValue)try{const t=this.parsePersistValue(i.newValue);if(!t||t.syncMetadata?.origin===this.sessionId)continue;const e=t?.syncMetadata,r=this.extractChangedFields(s,t.state,e,i.oldValue);if(!Object.keys(r).length)continue;s.registration.apply({replace:!1,sessionId:e?.origin??"unknown",timestamp:e?.timestamp??Date.now(),values:r})}catch(t){continue}}},e&&"storage"in e?(this.area=e.storage.area,this.storageKeyPrefix=e.storage.storageKeyPrefix):(this.area=e?.area??"local",this.storageKeyPrefix=e?.storageKeyPrefix??t),this.sessionId=this.generateSessionId(),this.attachListener()}destroy(){for(const t of this.registrations.values())t.destroyed=!0,t.listeners.clear();this.detachListener()}register(t){this.attachListener();const e={destroyed:!1,hydrated:!0,listeners:new Set,registration:t};return this.setRegistration(t.key,e),{destroy:()=>{e.destroyed=!0,e.listeners.clear(),this.registrations.delete(t.key),this.registrations.size||this.detachListener()},publish:null}}generateSessionId(){return"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Math.random().toString(36).slice(2)}:${Date.now().toString(36)}`}attachListener(){"undefined"!=typeof chrome&&chrome.storage&&!this.isListening&&(this.isListening=!0,chrome.storage.onChanged.addListener(this.onStorageChanged))}detachListener(){"undefined"!=typeof chrome&&chrome.storage&&this.isListening&&(chrome.storage.onChanged.removeListener(this.onStorageChanged),this.isListening=!1)}extractChangedFields(t,e,r,s){const i=n(),a=r?.fields;if(a&&Object.keys(a).length>0){let r=!1;for(const s of t.registration.fields){const t=String(s);o(a,t)&&(i[s]=e[s],r=!0)}if(r)return i}const c=this.parsePersistValue(s);for(const r of t.registration.fields){const t=e[r],s=c?.state[r];Object.is(t,s)||(i[r]=t)}return i}setRegistration(t,e){this.registrations.set(t,e)}toStorageKey(t){return this.storageKeyPrefix?`${this.storageKeyPrefix}${t}`:t}parsePersistValue(t){return h(t)}};function d(t){const e=new a(t);return{storage:e,syncEngine:new y({storage:e})}}export{y as ChromeExtensionSyncEngine,a as ChromeStorageAdapter,d as createSyncedChromeStorage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{constructor(e,t){super(e),this.name="StoresError",void 0!==t&&Object.defineProperty(this,"cause",{configurable:!0,value:t,writable:!0})}};function t(e){return e instanceof Error?e:new Error(String(e))}var r="undefined"!=typeof window&&"undefined"!=typeof document,n=!1,o="development"===process.env.NODE_ENV,s="test"===process.env.NODE_ENV,i=e=>e(),a=Object.freeze(Object.create(null));function c(e){return e}function l(){return Object.create(a)}function u(e,t){return void 0===t?Object.assign(l(),e):Object.assign(l(),e,t)}function f(){}function d(){return"undefined"!=typeof window?window.localStorage:null}var y={debug:(e,t)=>{o&&console.debug(e,t)},error:(e,t)=>{o&&!s&&console.error(e,t)},info:(e,t)=>{o&&console.info(e,t)},warn:(e,t)=>{o&&console.warn(e,t)}},h=Object.prototype.hasOwnProperty;function g(e,t){return h.call(e,t)}function p(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var w="stores/core/sync-channel",v=`${w}:storage:`;function m(){try{return"undefined"!=typeof window?window.localStorage:null}catch{return null}}var b,S,E,O,j=class{constructor(e){this.broadcast=e.broadcast,this.origin=e.origin,this.storeKey=e.storeKey,this.teardown=e.teardown}destroy(){this.teardown()}publish(e){const t=l();for(const r of Object.entries(e.values))t[r[0]]=r[1];const r={origin:this.origin,replace:e.replace,sessionId:e.sessionId,storeKey:this.storeKey,timestamp:e.timestamp,values:t};this.broadcast(r)}},I=class{constructor(){this.listeners=new Map,this.origin="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Math.random().toString(36).slice(2)}:${Date.now().toString(36)}`,this.onChannelMessage=e=>{e.data&&this.dispatch(e.data)},this.onStorageEvent=t=>{if(t.key&&t.newValue&&t.key.startsWith(v))try{const e=JSON.parse(t.newValue);this.dispatch(e)}catch(t){y.error(new e("[sync] Failed to parse storage event payload",t))}},this.channel="undefined"==typeof BroadcastChannel?null:new BroadcastChannel(w),this.storage=m(),this.channel&&this.channel.addEventListener("message",this.onChannelMessage),r&&window.addEventListener("storage",this.onStorageEvent)}get sessionId(){return this.origin}register(e){const t=t=>{if(t.origin===this.origin||t.storeKey!==e.key)return;const r=l();for(const n of e.fields)g(t.values,n)&&(r[n]=t.values[n]);Object.keys(r).length&&e.apply({replace:t.replace,sessionId:t.sessionId,timestamp:t.timestamp,values:r})};let r=this.listeners.get(e.key);return r||(r=new Set,this.listeners.set(e.key,r)),r.add(t),new j({broadcast:e=>this.broadcast(e),origin:this.origin,storeKey:e.key,teardown:()=>this.removeListener(e.key,t)})}broadcast(t){try{this.channel&&this.channel.postMessage(t),this.writeToStorage(t)}catch(t){y.error(new e("[sync] Failed to broadcast update",t))}}dispatch(e){if(!e.storeKey)return;const t=this.listeners.get(e.storeKey);if(t&&t.size)for(const r of t)r(e)}removeListener(e,t){const r=this.listeners.get(e);r&&(r.delete(t),r.size||this.listeners.delete(e))}writeToStorage(t){if(this.storage||(this.storage=m()),!this.storage)return;const r=`${v}${t.storeKey}`;try{this.storage.setItem(r,JSON.stringify(t))}catch(t){y.error(new e("[sync] Failed to write broadcast payload to storage",t))}}},_=class{destroy(){}publish(){}},$=class{constructor(){this.sessionId="noop"}register(e){return new _}},k="stores:",K=!1;function M(e){var t;o&&function(){if(K)throw new Error("[stores]: configureStores() called after first store creation. Call it earlier before creating any stores.")}(),e.logger&&(t=e.logger,y=t),E??(E=function(e){return e?.queryStoreDefaults?{queryStoreDefaults:e.queryStoreDefaults}:void 0}(e)),O??(O=C(e))}function D(){if(E)return E}function N(){return O??(O=C(void 0))}function A(){K=!0}function C(e){return{storage:e?.storage??(t=e?.storageKeyPrefix??k,{clearAll(){try{const e=d();if(!e)return;const r=[];for(let n=0;n<e.length;n++){const o=e.key(n);o?.startsWith(t)&&r.push(o)}for(const t of r)e.removeItem(t)}catch(e){console.error("Error clearing localStorage:",e)}},contains(e){const r=d();return null!==r?.getItem(`${t}${e}`)},delete(e){try{const r=d();r?.removeItem(`${t}${e}`)}catch(e){console.error("Error deleting from localStorage:",e)}},getAllKeys(){try{const e=d();return e?Array.from(e.keys()):[]}catch(e){return console.error("Error getting keys from localStorage:",e),[]}},get(e){try{const r=d();return r?r.getItem(`${t}${e}`)??void 0:void 0}catch(e){return void console.error("Error reading from localStorage:",e)}},set(e,r){try{const n=d();n?.setItem(`${t}${e}`,r)}catch(e){console.error("Error writing to localStorage:",e)}}}),syncEngine:e?.syncEngine??(r?(b||(b=new I),b):(S||(S=new $),S))};var t}function L(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function P(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}function U(e){return!!e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then}export{k as DEFAULT_STORAGE_KEY_PREFIX,r as IS_BROWSER,o as IS_DEV,n as IS_IOS,s as IS_TEST,e as StoresError,u as buildNullObject,M as configureStores,t as ensureError,D as getOptions,N as getStorageConfig,g as hasOwn,c as identity,p as isPlainObject,U as isPromiseLike,y as logger,A as markStoreCreated,f as noop,l as nullObject,L as replacer,P as reviver,i as unstable_batchedUpdates};
|
package/dist/web/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=require("zustand/middleware"),t=require("zustand/traditional"),r=require("use-sync-external-store/shim/with-selector"),n=require("react"),o="undefined"!=typeof window&&"undefined"!=typeof document,s="development"===process.env.NODE_ENV,i="test"===process.env.NODE_ENV;function a(){return"undefined"!=typeof window?window.localStorage:null}var c=class extends Error{constructor(e,t){super(e),this.name="StoresError",this.cause=l(t)}},u={debug:(e,t)=>{s&&console.debug(e,t)},error:(e,t)=>{s&&!i&&console.error(e,t)},info:(e,t)=>{s&&console.info(e,t)},warn:(e,t)=>{s&&console.warn(e,t)}};function l(e){return e instanceof Error?e:new Error(String(e))}var f="stores/core/sync-channel",d=`${f}:storage:`;function y(){try{return"undefined"!=typeof window?window.localStorage:null}catch{return null}}var p,h,g,b=class{constructor(e){this.broadcast=e.broadcast,this.origin=e.origin,this.storeKey=e.storeKey,this.teardown=e.teardown}destroy(){this.teardown()}publish(e){const t=Object.create(null);for(const r of Object.entries(e.values))t[r[0]]=r[1];const r={origin:this.origin,replace:e.replace,sessionId:e.sessionId,storeKey:this.storeKey,timestamp:e.timestamp,values:t};this.broadcast(r)}},m=class{constructor(){this.listeners=new Map,this.origin="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Math.random().toString(36).slice(2)}:${Date.now().toString(36)}`,this.onChannelMessage=e=>{e.data&&this.dispatch(e.data)},this.onStorageEvent=e=>{if(e.key&&e.newValue&&e.key.startsWith(d))try{const t=JSON.parse(e.newValue);this.dispatch(t)}catch(e){u.error(new c("[sync] Failed to parse storage event payload"),{error:e})}},this.channel="undefined"==typeof BroadcastChannel?null:new BroadcastChannel(f),this.storage=y(),this.channel&&this.channel.addEventListener("message",this.onChannelMessage),o&&window.addEventListener("storage",this.onStorageEvent)}get sessionId(){return this.origin}register(e){const t=t=>{if(t.origin===this.origin||t.storeKey!==e.key)return;const r=Object.create(null);for(const n of e.fields)Object.prototype.hasOwnProperty.call(t.values,n)&&(r[n]=t.values[n]);Object.keys(r).length&&e.apply({replace:t.replace,sessionId:t.sessionId,timestamp:t.timestamp,values:r})};let r=this.listeners.get(e.key);return r||(r=new Set,this.listeners.set(e.key,r)),r.add(t),new b({broadcast:e=>this.broadcast(e),origin:this.origin,storeKey:e.key,teardown:()=>this.removeListener(e.key,t)})}broadcast(e){try{this.channel&&this.channel.postMessage(e),this.writeToStorage(e)}catch(e){u.error(new c("[sync] Failed to broadcast update"),{error:e})}}dispatch(e){if(!e.storeKey)return;const t=this.listeners.get(e.storeKey);if(t&&t.size)for(const r of t)r(e)}removeListener(e,t){const r=this.listeners.get(e);r&&(r.delete(t),r.size||this.listeners.delete(e))}writeToStorage(e){if(this.storage||(this.storage=y()),!this.storage)return;const t=`${d}${e.storeKey}`;try{this.storage.setItem(t,JSON.stringify(e))}catch(e){u.error(new c("[sync] Failed to write broadcast payload to storage"),{error:e})}}},S=class{destroy(){}publish(){}},v=class{constructor(){this.sessionId="noop"}register(e){return new S}},w=!1;function O(){return g??(g=q(void 0))}function j(){w=!0}function q(e){return{storage:e?.storage??(t=e?.storageKeyPrefix??"stores:",{clearAll(){try{const e=a();if(!e)return;const r=[];for(let n=0;n<e.length;n++){const o=e.key(n);o?.startsWith(t)&&r.push(o)}for(const t of r)e.removeItem(t)}catch(e){console.error("Error clearing localStorage:",e)}},contains(e){const r=a();return null!==r?.getItem(`${t}${e}`)},delete(e){try{const r=a();r?.removeItem(`${t}${e}`)}catch(e){console.error("Error deleting from localStorage:",e)}},getAllKeys(){try{const e=a();return e?Array.from(e.keys()):[]}catch(e){return console.error("Error getting keys from localStorage:",e),[]}},get(e){try{const r=a();return r?r.getItem(`${t}${e}`)??void 0:void 0}catch(e){return void console.error("Error reading from localStorage:",e)}},set(e,r){try{const n=a();n?.setItem(`${t}${e}`,r)}catch(e){console.error("Error writing to localStorage:",e)}}}),syncEngine:e?.syncEngine??(o?(p||(p=new m),p):(h||(h=new v),h))};var t}function F(){let e,t,r=!1;return{complete:function(){!r&&e&&(r=!0,e(),e=void 0,t=void 0)},isHydrated:function(){return r},fail:function(n){!r&&t&&(r=!0,t(n),t=void 0,e=void 0)},promise:new Promise((r,n)=>{e=r,t=n})}}var C=Math.max,I=Math.min;function A(e,t=0,r={}){let n,o,s,i,a,c,u=0,l=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){const r=n,s=o;return n=o=void 0,u=t,i=r?e.apply(s,r):e.apply(s),i}function p(e){const r=e-(c??0);return void 0===c||r>=t||r<0||f&&void 0!==s&&e-u>=s}function h(){const e=k();if(p(e))return g(e);a=setTimeout(h,function(e){const r=t-(e-(c??0));return f&&void 0!==s?I(r,s-(e-u)):r}(e))}function g(e){return a=void 0,d&&n?y(e):(n=o=void 0,i)}function b(...e){const r=k(),s=p(r);if(n=e,o=this,c=r,s){if(void 0===a)return function(e){return u=e,a=setTimeout(h,t),l?y(e):i}(c);if(f)return clearTimeout(a),a=setTimeout(h,t),y(c)}return void 0===a&&(a=setTimeout(h,t)),i}return t=E(t)||0,function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}(r)&&(l=!!r.leading,f="maxWait"in r,s=f?C(E(r.maxWait)||0,t):void 0,d="trailing"in r?!!r.trailing:d),b.cancel=function(){void 0!==a&&clearTimeout(a),u=0,n=c=o=a=void 0},b.flush=function(){return void 0===a?i:g(k())},b}function k(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function E(e){if("number"==typeof e)return e;if("symbol"==typeof e||void 0===e)return NaN;if("object"==typeof e&&null!==e){const t="function"==typeof e.valueOf?e.valueOf():e;e="object"==typeof t?t+"":t}return"string"!=typeof e?0===e?e:+e:(e=e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),/^0b[01]+$/i.test(e)?parseInt(e.slice(2),2):/^0o[0-7]+$/i.test(e)?parseInt(e.slice(2),8):/^[-+]0x[0-9a-f]+$/i.test(e)?NaN:+e)}function T(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function K(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}function z(e){if(null!==e&&"object"==typeof e){const t={};for(const[r,n]of Object.entries(e))"function"!=typeof n&&(t[r]=n);return t}return e}var M={ms:e=>e,seconds:e=>1e3*e,minutes:e=>M.seconds(60*e),hours:e=>M.minutes(60*e),days:e=>M.hours(24*e),weeks:e=>M.days(7*e),infinity:1/0,zero:0},x=i?0:o?M.ms(200):M.seconds(5);function D(e){return t=>{if("string"!=typeof t)throw new c("[createBaseStore]: Received non-string serialized state without a custom deserializer. Provide a deserializer on the store or storage adapter.");return function(e,t){try{return JSON.parse(e,t?K:void 0)}catch(e){throw u.error(new c("[createBaseStore]: Failed to deserialize persisted Rainbow store data"),{error:e}),e}}(t,e)}}function $(e){return t=>function(e,t){try{return JSON.stringify(e,t?T:void 0)}catch(e){throw u.error(new c("[createBaseStore]: Failed to serialize Rainbow store data"),{error:e}),e}}(t,e)}var L=Object.freeze({shouldClear:!1});function P(e,t,r){if(!t||!e)return L;const n=e.getFieldTimestampSnapshot();return function(e,t){const r=e.getSessionId(),n=e.getTimestamp();void 0!==r&&void 0!==n&&(t.syncMetadata={origin:r,timestamp:n})}(e,r),r.syncMetadata?n&&Object.keys(n).length>0?(r.syncMetadata.fields=n,{fieldSnapshot:n,shouldClear:!0}):(delete r.syncMetadata.fields,{fieldSnapshot:n,shouldClear:!1}):{fieldSnapshot:n,shouldClear:!1}}function R(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function N(e){return!!e&&!!e.getIsApplyingRemote()}function W(e,...t){return!0===t[1]?H(t[0])?t[0](e):t[0]:{...e,...H(t[0])?t[0](e):t[0]}}function _(e,t){V(e)?e.getState().reset(t?.clearQueryCache):function(e){return"destroy"in e}(e)&&e.destroy()}function Q(e){return J(e)?e.persist.getOptions().name??e.name:e.name}function U(e){return"getSnapshot"in e}function V(e){return"_queryStore"in e}function J(e){return"persist"in e}function B(e){return"_virtualStore"in e}function H(e){return"function"==typeof e}var[G,X]=[0,1];function Y(e,t,r){if(!e)return!0;const n=e[G],o=e[X];return!(t<n)&&(t>n||r>o)}function Z(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function ee(e,t){if(!s)return!0;if(null===e||null===t)return e===t;const r=typeof e;return r===typeof t&&("object"!==r||Object.prototype.toString.call(e)===Object.prototype.toString.call(t))}function te(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function re(r,n){j();const o=void 0!==n&&"string"==typeof n.storageKey,s=o?n.storageKey:void 0,i=n?.sync?function(e,t){if(!e)return null;if(!0===e){if(!t)throw new c("[createBaseStore]: sync: true requires a storageKey to inherit the key from");return{key:t}}if("string"==typeof e)return{key:e};const r=e,n=r.key??t;if(!n)throw new c("[createBaseStore]: sync requires either a key in the config or a storageKey to inherit from");return{...r,key:n}}(n.sync,s):void 0,a=o?n.storage??O().storage:void 0,f=i?function(e,t,r){const n=t.engine??O().syncEngine,o=function(e){let t,r,n,o=!1;return{isAsync:e,clearFieldTimestamps:function(e){if(e&&n){for(const t of Object.entries(e)){const e=t[0],r=t[1];n[e]===r&&delete n[e]}Object.keys(n).length||(n=void 0)}},getFieldTimestampSnapshot:function(){if(n)return{...n}},getIsApplyingRemote:()=>o,getSessionId:()=>t,getTimestamp:()=>r,mergeFieldTimestamps:function(e){if(n)for(const t of Object.entries(e)){const e=t[0],r=t[1],o=n[e];(void 0===o||r>o)&&(n[e]=r)}else n={...e}},onHydrationComplete:void 0,onHydrationFlushEnd:void 0,setIsApplyingRemote:e=>o=e,setSessionId:e=>t=e,setTimestamp:e=>r=e,setWithoutPersist:void 0}}(r);return{stateCreator:(s,i,a)=>{const l=new Map,f=[],d=[];let y=null,p=!1,h=!1,g=0,b=null,m=[],S=Promise.resolve(),v=!r;const w=(e,t)=>{if(o?.setSessionId&&o?.setTimestamp&&n.sessionId&&(o.setSessionId(n.sessionId),o.setTimestamp(e),o.mergeFieldTimestamps&&t.length>0)){const r=Object.create(null);for(const n of t)r[String(n)]=e;o.mergeFieldTimestamps(r)}},O=function(e,t){if(p||!b)return t?s(e,t):s(e);const r=(()=>{const e=Date.now(),t=e>g?e:g+1;return g=t,t})();let o=[],i=Object.create(null);const a=n=>{const s=W(n,e,t);for(const e of m)Object.is(s[e],n[e])||(o.push(e),i[e]=s[e]);return o.length&&w(r,o),s},c=t?s(a,!0):s(a),u=()=>{o.length&&(e=>{const t=n.sessionId;for(const r of e.keys)l.set(r,[e.timestamp,t]);y&&h?y.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values}):d.push(e)})({keys:o,replace:t??!1,values:i,timestamp:r})};return(f=c)&&"object"==typeof f&&"then"in f&&"function"==typeof f.then?c.finally(u):(u(),c);var f},j=a.setState;a.setState=O;const q=e(O,i,a);if(m=t.fields??function(e){const t=[];for(const r of Object.entries(e)){if("function"==typeof r[1])continue;const e=r[0];t.push(e)}return t}(q),!m.length)return q;b=new Set(m);const F=async e=>{g=Math.max(g,e.timestamp);const r=Object.create(null),n=i(),s=e.timestamp;let a;if(e.replace)for(const t of m)Z(t,e.values)||Y(l.get(t),s,e.sessionId)&&(a??(a=[])).push(t);for(const o of m){if(!Z(o,e.values))continue;if(!b?.has(o))continue;if(!Y(l.get(o),s,e.sessionId))continue;const i=t.merge?.[o];if(i){const t=e.values[o],a=n[o];if(void 0!==t){const f=i(t,a,n,e.values),d=void 0!==a?a:t;if(!ee(f,d))return void u.error(new c(`[sync] Merge function for field "${String(o)}" returned ${te(f)} but expected ${te(d)}`));r[o]=f,l.set(o,[s,e.sessionId])}}else r[o]=e.values[o],l.set(o,[s,e.sessionId])}if(Object.keys(r).length>0||a?.length){p=!0,o&&o.setIsApplyingRemote(!0);try{if(e.replace){const e={...n};let t=!1;if(a?.length){t=!0;for(const t of a)delete e[t],l.delete(t)}for(const n in r){if(!Object.prototype.hasOwnProperty.call(r,n))continue;const o=r[n];void 0!==o&&(Object.is(e[n],o)||(t=!0),e[n]=o)}if(!t)return;await(o.setWithoutPersist??j)(e,!0)}else await(o.setWithoutPersist??j)(r)}finally{p=!1,o&&o.setIsApplyingRemote(!1)}}},C=e=>{r?S=S.then(()=>F(e)):F(e)};y=n.register({apply:e=>{v?C(e):f.push(e)},delta:t.delta,fields:m,getState:i,key:t.key});const I=()=>{h=!0,(()=>{if(y&&d.length){for(const e of d){const t=n.sessionId;for(const r of e.keys)l.set(r,[e.timestamp,t]);w(e.timestamp,e.keys),y.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values})}d.length=0}})()},A=()=>{v=!0,(()=>{if(!f.length)return;const e=f.slice();f.length=0;for(const t of e)C(t)})()};return r&&o?(o.onHydrationComplete=I,o.onHydrationFlushEnd=A):y.onHydrated?(y.onHydrated(I),A()):(I(),A()),q},syncContext:o}}(r,i,a?.async??!1):void 0,d=f?.stateCreator??r;if(!o)return t.createWithEqualityFn()(e.subscribeWithSelector(d),Object.is);const y=a?.async?function(e){let t,r,n,o=!1;return{hydrationPromise:()=>o?t?.promise??r??(r=Promise.resolve()):(t||(t=F()),t.promise),stateCreator:(r,s,i)=>{let a;return n=()=>{if(a?.length){for(const e of a)e[1]?i.setState(e[0],e[1]):i.setState(e[0]);a=void 0}},e((...e)=>o?!0===e[1]?r(e[0],e[1]):r(e[0]):(t||(t=F()),a||(a=[]),a.push(e),t.promise),s,i)},wrapOnRehydrateStorage:(e,r)=>s=>{const i=e?.(s);return(e,s)=>{o=!0,r?.onHydrationComplete?.(),n&&n(),r?.onHydrationFlushEnd?.(),s?t?.fail(l(s)):t?.complete(),i?.(e,s)}}}}(d):null,p=function(e,t,r){const n=t??e.storage??O().storage,o=(e.sync?void 0:e.persistThrottleMs??x)||void 0,s=e.version??0,i=n.async?function(e,t,r,n){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),s="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),i=t.partialize??z,a=t.deserializer??e.deserializer??D(o),l=t.serializer??e.serializer??$(o);async function f(t,r){try{if(N(n))return;r.state,r.state=i(r.state);const o=P(n,s,r),a=l(r);try{await e.set(t,a),R(n,o)}catch(e){u.error(new c("[createBaseStore]: Failed to persist store data"),{error:e})}}catch(e){u.error(new c("[createBaseStore]: Failed to serialize persisted store data"),{error:e})}}const d=void 0!==r?A(f,r,{leading:!1,maxWait:r,trailing:!0}):function(e){let t,r=null;return function(...n){return t=n,r||(r=new Promise(n=>{queueMicrotask(async()=>{try{await e(...t)}finally{r=null,n()}})})),r}}(f);return{getItem:async t=>{const r=await e.get(t);return void 0===r?null:a(r)},setItem:async(e,t)=>{if(!n?.getIsApplyingRemote())return await d(e,t)},removeItem:async t=>{try{await e.delete(t)}catch(e){u.error(new c("[createBaseStore]: Failed to delete persisted store data"),{error:e})}}}}(n,e,o,r):function(e,t,r,n){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),s="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),i=t.partialize??z,a=t.deserializer??e.deserializer??D(o),l=t.serializer??e.serializer??$(o);function f(t,r){try{if(N(n))return;r.state,r.state=i(r.state);const o=P(n,s,r),a=l(r);try{e.set(t,a),R(n,o)}catch(e){u.error(new c("[createBaseStore]: Failed to persist store data"),{error:e})}}catch(e){u.error(new c("[createBaseStore]: Failed to persist store data"),{error:e})}}const d=void 0!==r?A(f,r,{leading:!1,maxWait:r,trailing:!0}):f;return{getItem:t=>{const r=e.get(t);return void 0===r?null:a(r)},setItem:(e,t)=>{n?.getIsApplyingRemote()||d(e,t)},removeItem:t=>{try{e.delete(t)}catch(e){u.error(new c("[createBaseStore]: Failed to delete persisted store data"),{error:e})}}}}(n,e,o,r);return{persistStorage:i,version:s}}(n,a,f?.syncContext),h=y?y.wrapOnRehydrateStorage(n.onRehydrateStorage,f?.syncContext):n.onRehydrateStorage,g=y?(e,t,r)=>(f&&(f.syncContext.setWithoutPersist=r.setState),y.stateCreator(e,t,r)):d,b=t.createWithEqualityFn()(e.subscribeWithSelector(e.persist(g,function(e,t,r){const n={name:e.storageKey,onRehydrateStorage:r,storage:t.persistStorage,version:t.version};return void 0!==e.merge&&(n.merge=e.merge),void 0!==e.migrate&&(n.migrate=e.migrate),n}(n,p,h))),Object.is);return y?Object.assign(b,{persist:Object.assign(b.persist,{hydrationPromise:y.hydrationPromise})}):b}function ne(e,t,r="s"){return 1===t?e:`${e}${r}`}function oe(e,t,r){const n=t.get(e);if(!n){const n=function(e,t,r,n=[]){return e&&"object"==typeof e?se(e,n,t,r,new WeakSet,new WeakMap):(r(t,n,!0),e)}(U(e)?e.getSnapshot():e.getState(),e,r);return t.set(e,n),n}return n}function se(e,t,r,n,o,s){return new Proxy(e,{get(i,a,c){if(o.has(i))return Reflect.get(i,a,c);if("__proto__"===a||"symbol"==typeof a)return a===Symbol.iterator&&(n(r,t,!0),o.add(i)),Reflect.get(i,a,c);const u=Reflect.get(i,a,i),l=String(a),f=t.concat(l);if("function"==typeof u)return Object.prototype.hasOwnProperty.call(i,a)?function(...e){return n(r,f,!0,{method:l,args:e.length?e:void 0}),Reflect.apply(u,i,e)}:(n(r,t,!0),u.bind(e));const d=!!u&&"object"==typeof u;return n(r,f,!d),d?(s.has(u)||s.set(u,se(u,f,r,n,o,s)),s.get(u)):u},getOwnPropertyDescriptor:(e,s)=>(n(r,t,!0),o.add(e),Reflect.getOwnPropertyDescriptor(e,s)),has:(e,o)=>(n(r,t,!0),Reflect.has(e,o)),ownKeys:e=>(n(r,t,!0),o.add(e),Reflect.ownKeys(e))})}function ie(e){return t=>ce(t,e)}function ae(e,t){const r=e.slice(0,-1);return e=>{const n=ce(e,r),o=n?.[t.method];return"function"==typeof o?o.apply(n,t.args):void 0}}function ce(e,t){let r=e;for(const e of t){if(!r||"object"!=typeof r)return r;r=r[e]}return r}function ue(){const e=new Map;return{buildProxySubscriptions(t,r){const n=new Set;for(const[t,r]of e)de(r,t,[],0,n);!function(e,t,r){for(const r of e)t(r.store,r.invocation?ae(r.path,r.invocation):ie(r.path));r&&function(e){const t=e.size;console.log(`[π‘ ${t} ${ne("Proxy Subscription",t)} π‘]:`,JSON.stringify(Array.from(e).map(e=>{const t=Q(e.store),r=e.path.join(".");if(!e.invocation)return r?`$(${t}).${r}`:`$(${t})`;const n=e.invocation.args?.length??0;return`$(${t}).${r}${n?`(${n}_${ne("arg",n)})`:"()"}`}),null,2))}(e)}(n,t,r)},trackPath(t,r,n,o){let s=e.get(t);s||(s=le(),e.set(t,s)),fe(s,r,0,n,o)}}}function le(){return Object.create(null)}function fe(e,t,r,n,o){if(r===t.length)return n&&(e.isLeaf=!0),void(o&&(e.invocation=o));e.children||(e.children=le());const s=t[r];let i=e.children?.[s];i||(i=le(),e.children[s]=i),fe(i,t,r+1,n,o)}function de(e,t,r,n,o,s=1){const i=e.children;if(!i)return void o.add({store:t,path:r,invocation:e.invocation,isLeaf:e.isLeaf??!1});const a=Object.keys(i),c=a.length;if(0!==c)if(e.isLeaf||n>=s&&c>1){o.add({store:t,path:r,invocation:e.invocation,isLeaf:e.isLeaf??!1});for(const e of a){const a=i[e];a.invocation&&de(a,t,[...r,e],n+1,o,s)}}else if(n<s&&c>1&&!e.isLeaf)for(const e of a)de(i[e],t,[...r,e],n+1,o,s);else{if(1===c){const e=a[0];return void de(i[e],t,[...r,e],n+1,o,s)}o.add({store:t,path:r,invocation:e.invocation,isLeaf:e.isLeaf??!1})}else o.add({store:t,path:r,invocation:e.invocation,isLeaf:e.isLeaf??!1})}var ye=!1,pe=!1,he=new Map,ge=new Map,be=new Map,me=null,Se=1/0;function ve(){return ye}function we(){return me}function Oe(){ye||(ye=!0,pe||(pe=!0,queueMicrotask(()=>{pe=!1,(()=>{for(;ge.size>0;){const e=Se,t=be.get(e);if(t){be.delete(e);for(const e of t)ge.delete(e);me=e;for(const e of t)e();if(me=null,be.size>0){Se=1/0;for(const e of be.keys())e<Se&&(Se=e)}else Se=1/0}else{Se=1/0;for(const e of be.keys())e<Se&&(Se=e)}}for(;he.size>0;){const e=Array.from(he.values());he.clear();for(const t of e)t()}})(),ye=!1,me=null,ge.clear(),be.clear(),Se=1/0})))}function je(e,t){ye&&he.set(e,t)}var qe=e=>e;function Fe(e,t=Object.is){return n=function(e,t=Object.is){const{debounceOptions:r,debugMode:n,equalityFn:o,keepAlive:i,lockDependencies:a}="function"==typeof(l=t)?{debounceOptions:void 0,debugMode:!1,equalityFn:l,keepAlive:!1,lockDependencies:!1}:{debounceOptions:l.debounce,debugMode:(s&&l.debugMode)??!1,equalityFn:l.equalityFn??Object.is,keepAlive:l.keepAlive??!1,lockDependencies:l.lockDependencies??!1},c=String(Ie+=1),u=new Set;var l;i&&u.add(Ae);const f=new Set;let d,y,p=Ce,h=!1,g=!0,b=!0,m=!0,S=0,v=!1,w=null,O=Ce;function j(e,t,r){if(!m||!u.size)return(t??qe)(U(e)?e.getSnapshot():e.getState());if(!t)return d||(d=new WeakMap),y||(y=ue()),oe(e,d,y.trackPath);const n=e.subscribe(t,M,{equalityFn:r??Object.is,isDerivedStore:!0});return f.add(n),t(U(e)?e.getSnapshot():e.getState())}function q(e){for(const t of f)t(e);f.clear()}function F(){if(!b&&ke(p))return p;b=!1,m&&q(!0);const t=p,r=ke(t);p=function(t){g=!0;const r=p,s=e(t);return ke(r)&&o(r,s)?(n&&console.log("[π₯· Derive Complete π₯·]: No change detected"),g=!1,r):s}(j);const s=n&&(!r||"verbose"===n&&m);if(s){r?"verbose"===n&&console.log("[π Rebuilding Subscriptions π]: Createdβ¦"):console.log("[π Initial Derive Complete π]: Createdβ¦");const e=f.size;console.log(`[π― ${e} ${ne("Selector Subscription",e)} π―]`)}return y&&m&&(y.buildProxySubscriptions((e,t)=>{const r=e.subscribe(t,M,{equalityFn:Object.is,isDerivedStore:!0});f.add(r)},s),d=void 0,y=void 0),g&&r&&function(e,t){const r=function(){const e=u.has(Ae)?u.size-1:u.size;return S>0&&S<e}(),o=!S||r,s=r||null!==we()||ve()&&o;r&&Oe(),n&&console.log(`[π» Derive Complete π»]: Notifying ${u.size} ${ne("watcher",u.size)}`);for(const t of u){if("function"==typeof t||!t.isDerivedWatcher)continue;const r=t.selector(e);if(!t.equalityFn(t.currentSlice,r)){const e=t.currentSlice;t.currentSlice=r,t.listener(r,e)}}s?v||(v=!0,ke(O)||(O=t),je(c,I)):C(e,t)}(p,t),a&&(m=!1),p}function C(e,t){for(const r of u)if("function"==typeof r)r(e,t);else if(!r.isDerivedWatcher){const t=r.selector(e);if(!r.equalityFn(r.currentSlice,t)){const e=r.currentSlice;r.currentSlice=t,r.listener(t,e)}}}function I(){u.size&&(v&&function(){if(b&&!S&&F(),!ke(p))return;const e=ke(O)?O:p;C(p,e)}(),v=!1,O=Ce)}const k=r?A(T,"number"==typeof r?r:r.delay,"number"==typeof r?{leading:!1,maxWait:r,trailing:!0}:r):void 0,E=k??(()=>{h||(h=!0,queueMicrotask(T))});function T(){u.size&&(h=!1,b&&F())}function K(e){e?queueMicrotask(()=>{u.size||D()}):D()}function z(){T(),w=null}function M(){if(!b){if(b=!0,!k){if(S){Oe();const e=we(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!ye)return;const r=t<0?0:0|t,n=ge.get(e);if(void 0===n){ge.set(e,r);let t=be.get(r);return t||(t=new Set,be.set(r,t)),t.add(e),void(r<Se&&(Se=r))}if(r>n){const t=be.get(n);if(t&&(t.delete(e),0===t.size&&(be.delete(n),n===Se))){Se=1/0;for(const e of be.keys())e<Se&&(Se=e)}ge.set(e,r);let o=be.get(r);o||(o=new Set,be.set(r,o)),o.add(e),r<Se&&(Se=r)}}(z,t)}if(ve())return void(v||(v=!0,ke(p)&&(O=p),je(c,I)))}w=null,S&&!r?F():E()}}function x(){return b||!ke(p)?u.size>0?F():e(j):p}function D(e=!0){i&&e||(k?.cancel(),q(),u.clear(),S=0,y=void 0,d=void 0,m=!0,h=!1,b=!0,p=Ce,v=!1,O=Ce,w=null)}return{destroy:()=>D(!1),flushUpdates:function(){u.size&&(k?k.flush():b&&F())},getSnapshot:function(){if(!ke(p)){u.add(Ae);const e=F();return u.delete(Ae),e}return h&&T(),p},getState:x,subscribe:function(...e){if(1===e.length){const t=e[0];return u.add(t),1!==u.size||ke(p)||x(),()=>{u.delete(t),u.size||K(!1)}}const[t,r,n]=e,o=n?.equalityFn??Object.is,s=n?.isDerivedStore??!1,i={currentSlice:void 0,equalityFn:o,isDerivedWatcher:s,listener:r,selector:t};return u.add(i),i.currentSlice=t(x()),s&&(S+=1),n?.fireImmediately&&r(i.currentSlice,i.currentSlice),()=>{u.delete(i),s&&(S-=1),u.size||K(s)}},getInitialState:()=>{throw new Error("[createDerivedStore]: getInitialState() is not available on derived stores.")},setState:()=>{throw new Error("[createDerivedStore]: setState() is not available on derived stores.")}}}(e,t),Object.assign(function(e=qe,t=void 0){return r.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,void 0,e,t)},n);var n}var Ce=Symbol(),Ie=0;function Ae(){}function ke(e){return e!==Ce}var Ee=class{constructor({disableAutoRefetching:e,initialEnabled:t}){this.count=0,this.enabled=!1,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,this.enabled=t,e&&(this.fetchThrottleMs=M.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}get(){return{enabled:this.enabled,lastSubscriptionTime:this.lastSubscriptionTime,subscriptionCount:this.count}}setEnabled(e){this.enabled=e}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.onSubscribe?.(this.enabled,e,t),this.count+=1,this.lastSubscriptionTime=Date.now(),e=>{const t=1===this.count;this.count=Math.max(this.count-1,0),t&&(this.onLastUnsubscribe?.(e),this.lastSubscriptionTime=null)}}},Te={Error:"error",Idle:"idle",Loading:"loading",Success:"success"};function Ke(e,t){const r=Object.prototype.hasOwnProperty;function n(e,t){for(const r of e.keys())if(Ke(r,t))return r}let o,s,i;if(e===t)return!0;if(e&&t&&(o=e.constructor)===t.constructor){if(o===Date)return e.getTime()===t.getTime();if(o===RegExp)return e.toString()===t.toString();if(o===Array){if((s=e.length)===t.length)for(;s--&&Ke(e[s],t[s]););return-1===s}if(o===Set){if(e.size!==t.size)return!1;for(let r of e){if(i=r,i&&"object"==typeof i&&(i=n(t,i),!i))return!1;if(!t.has(i))return!1}return!0}if(o===Map){if(e.size!==t.size)return!1;for(let r of e){if(i=r[0],i&&"object"==typeof i&&(i=n(t,i),!i))return!1;if(!Ke(r[1],t.get(i)))return!1}return!0}if(o===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(o===DataView){if((s=e.byteLength)===t.byteLength)for(;s--&&e.getInt8(s)===t.getInt8(s););return-1===s}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){const r=e,n=t;if((s=r.byteLength)===n.byteLength)for(;s--&&r[s]===n[s];);return-1===s}if(!o||"object"==typeof e){s=0;for(const n in e){if(r.call(e,n)&&++s&&!r.call(t,n))return!1;if(!(n in t)||!Ke(e[n],t[n]))return!1}return Object.keys(t).length===s}}return e!=e&&t!=t}var ze=new WeakMap,Me=new WeakMap;function xe(e,t=De,r=Ke){return function(e,t,r){let n=Me.get(e);n||(n=new Map,Me.set(e,n));let o=n.get(t);o||(o=new Map,n.set(t,o));const s=o.get(r);if(s)return s;const[i,a,c]=Le(e,t,r),u=new Map,l=e=>{const t={get(t,r){if("value"===r){let t=a();const r=e.split(".");for(const e of r)e&&(t=t[e]);return t}const n="string"==typeof r?r:r.toString(),o=e?`${e}.${n}`:n,s=u.get(o);if(s)return s;const c=l(o);return ze.set(c,i),u.set(o,c),c},set(t,r,n){const o=e.split(".");return""===o[0]&&o.shift(),c(o,n),!0}};return new Proxy(Object.create(null),t)},f=l("");return i(()=>{}),ze.set(f,i),o.set(r,f),f}(e,t,r)}var De=e=>e,$e=(e,t,r)=>{if(!t.length)return r;const[n,...o]=t,s=e[n],i=$e(s,o,r);if(Ke(s,i))return e;const a=Array.isArray(e)?e.slice():{...e};return a[n]=i,a},Le=(e,t,r)=>{const n=new Set,o=U(e);let s,i=t(o?e.getSnapshot():e.getState());return[a=>(n.size||(s=e.subscribe(t,e=>{i=e,n.forEach(e=>e())},{equalityFn:r,isDerivedStore:o})),n.add(a),()=>{n.delete(a),!n.size&&s&&(s(),s=void 0)}),()=>(n.size||(i=t(e.getState())),i),(r,n)=>{if(t!==De)throw new Error("Cannot set a value with a selector");e.setState(e=>$e(e,r,n),!0)}]};function Pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var[Re,Ne]=[!0,!1],We={error:Re,lastFetchedAt:Re,queryCache:Re,queryKey:Re,status:Re,enabled:Ne,fetch:Ne,getCacheEntry:Ne,getData:Ne,getStatus:Ne,isDataExpired:Ne,isStale:Ne,reset:Ne},_e=M.seconds(5);function Qe(e,t){const r=t?.baseDelay??M.seconds(5),n=t?.maxDelay??M.minutes(5),o=Math.pow(2,e);return Math.min(r*o,n)}function Ue(e){return JSON.stringify(Object.keys(e).sort().map(t=>e[t]))}function Ve(e){return JSON.stringify(Je(e))}function Je(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,r)=>{const n=e[r];return t[r]=null!==n&&"object"==typeof n?Je(n):n,t},{})}function Be(e,t,r,n){return n?Xe(n,r)?n:{...He(e,t),...n}:He(e,t)}function He(e,t){const r=t?.params??Object.create(null);for(const t in e?.params){const n=e.params[t];n&&(r[t]=n.value)}return r}function Ge(){return Object.create(null)}function Xe(e,t){if(!e)return!1;for(const r of t)if(!(r in e))return!1;return!0}function Ye(e,t,r){if(!r.queryCache)return r;const n=Date.now(),o=t??(e&&r.queryKey||null);let s=!1;const i=Object.create(null);for(const e in r.queryCache){if(!Pe(r.queryCache,e))continue;const a=r.queryCache[e];a&&(n-(a.lastFetchedAt??a.errorInfo.lastFailedAt)<a.cacheTime||e===o)?!t&&a.errorInfo&&a.errorInfo.retryCount>0?(i[e]={...a,errorInfo:{...a.errorInfo,retryCount:0}},s=!0):i[e]=a:s=!0}return s?{...r,queryCache:i}:r}function Ze(e){return"function"==typeof e}function et(e){return!Ze(e)}function tt(e,t){return r=>{const n={...r},o={};for(const e in n)Pe(n,e)&&e in We&&(We[e]&&(o[e]=n[e]),delete n[e]);return{...t?t(n):z(n),...Ye(e,null,o)}}}var rt=Symbol(),nt=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1}),ot=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function st(e,t,r=ot){if(t.current.isActive){if(!r?.forceResubscribe)return;t.current.unsubscribe()}t.current.options.debugMode&&console.log("[π‘ useListen π‘] Attaching listener"),t.current.isActive=!0,t.current.resubscribe=(r=ot)=>st(e,t,r);const n=e.subscribe(e=>t.current.selector(e),(e,r)=>t.current.react(e,r,()=>{n(),t.current.isActive=!1}),r.fireImmediately?{...t.current.options,fireImmediately:!0}:t.current.options);t.current.unsubscribe=()=>{t.current.isActive&&(n(),t.current.isActive=!1)}}function it(e){return"function"==typeof e?{equalityFn:e}:e??nt}var at=Symbol();function ct(e,t){return function(...r){const n=e.getState()[t];if("function"==typeof n)return n(...r);throw new Error(`[createVirtualStoreAction]: Method ${String(t)} is not a function`)}}function ut(e,t){return"function"==typeof e[t]}exports.QueryStatuses=Te,exports.applyStateUpdate=W,exports.configureStores=function(e){var t;s&&function(){if(w)throw new Error("[stores]: configureStores() called after first store creation. Call it earlier before creating any stores.")}(),e.logger&&(t=e.logger,u=t),g??(g=q(e))},exports.createBaseStore=re,exports.createDerivedStore=Fe,exports.createQueryStore=function(e,t,r){j();const n="function"==typeof t?t:Ge,o="object"==typeof t?t:r,a=o&&"storageKey"in o?o:void 0,{fetcher:f,onError:d,onFetched:y,setData:p,transform:h,abortInterruptedFetches:g=!0,cacheTime:b=M.days(7),debugMode:m=!1,disableAutoRefetching:S=!1,disableCache:v=!1,enabled:w=!0,keepPreviousData:O=!1,maxRetries:q=5,paramChangeThrottle:F=!1,params:C,retryDelay:I=Qe,suppressStaleTimeWarning:k=!1,useParsableQueryKeys:E=!0}=e;let T="function"==typeof e.staleTime?M.minutes(2):e.staleTime??M.minutes(2);s&&!S&&!k&&T<_e&&console.warn(`[createQueryStore${a?.storageKey?`: ${a.storageKey}`:""}] β Stale times under ${_e/1e3} seconds are not recommended. Provided staleTime: ${T/1e3} seconds`);const K=E?Ve:Ue,z=new Error("[createQueryStore: AbortError] Fetch interrupted"),x="function"==typeof b,D=s&&m,$=Object.keys(e.params??Object.create(null));let L=null,P=null,R=null,N=[],W=!1,_=!1,Q=null,U=null,V=null,J=null,B=null;const H={enabled:"function"!=typeof w&&w,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:Te.Idle},G=new Ee({disableAutoRefetching:S,initialEnabled:H.enabled}),X=()=>{Q&&(U=null,Q.abort(),Q=null)},Y=(t,r,o)=>{const s=o.setState,i=(e,t)=>{const r="function"==typeof e;if(r||void 0!==e.enabled){let t;const n=s(n=>{const s=r?e(n):e,i=void 0!==s.enabled?s.enabled:n.enabled;return i!==n.enabled&&(t=()=>((e,t)=>{e!==t&&B!==t&&(B=t,G.setEnabled(t),t?queueMicrotask(()=>o.getState().fetch(void 0,{updateQueryKey:!0})):(V||g)&&(g&&X(),V&&(clearTimeout(V),V=null)))})(n.enabled,i)),s});return t?.(),n}return s(e)};o.setState=i,G.init({onSubscribe:(n,o,s)=>{if(P||L||!C&&"function"!=typeof e.enabled&&"function"!=typeof e.staleTime){if(n)if(o){const e=He(L,P),n=K(e),o=r();o.queryKey!==n&&t(e=>({...e,queryKey:n})),o.isStale()?w.fetch(e,void 0,!0):m(e,void 0)}else S&&!s&&w.fetch(void 0,void 0,!0)}else W=!0},onLastUnsubscribe:e=>{V&&(clearTimeout(V),V=null),g&&!e&&X()}});const m=(e,t)=>{if(S||t?.skipStoreUpdates)return;if(T<=0||T===1/0)return;V&&(clearTimeout(V),V=null);const n=K(e),o=r(),s=(v?J===n&&o.lastFetchedAt:o.queryCache[n]?.lastFetchedAt)||null,i=s?T-(Date.now()-s):T;V=setTimeout(()=>{const t=G.get();t.enabled&&t.subscriptionCount>0&&w.fetch(e,{force:!0},!0)},i)},w={...n(i,r,o),...H,async fetch(e,n,o=!1){const s=G.get();if(!n?.force&&!n?.skipStoreUpdates&&!s.enabled)return null;const S=r(),j=S.error,F=S.queryKey,C=S.status,A=Be(L,P,$,e),k=K(A),E=n?.staleTime??T,M=C===Te.Loading,R=!!n?.skipStoreUpdates,N="boolean"==typeof n?.updateQueryKey?n.updateQueryKey:o?O:!R,W=o||!R&&(N||F===k);if(U?.promise&&U.key===k&&M)return D&&console.log("[π Using Active Fetch π] for params:",JSON.stringify(A)),U.promise;if(g&&!R&&!1!==n?.updateQueryKey&&X(),!n?.force){const e=S.lastFetchedAt,r=S.queryCache[k],o=r?.lastFetchedAt,i=r?.errorInfo,a=i&&i.retryCount>=q,c=(v?J===k&&e:o)||null;if(c&&!(Date.now()-c>=E)&&(!i||a||R))return W&&!R&&!V&&s.subscriptionCount>0&&0!==T&&T!==1/0&&m(A,n),N&&t(e=>e.queryKey!==k?{...e,queryKey:k}:e),D&&console.log("[πΎ Returning Cached Data πΎ] for params:",JSON.stringify(A)),r?.data??null}!R&&W&&(V&&(clearTimeout(V),V=null),!j&&M||t(e=>({...e,error:null,status:Te.Loading})),U={key:k});const _=n?.cacheTime??(x?b(A):b),B=async()=>{try{D&&(o||!e||Xe(e,$)?console.log("[π Fetching π] for params:",JSON.stringify(A)):console.log("[π Fetching with Partial Params π]\n","- Provided params:",`${JSON.stringify(e)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(A).filter(t=>!(t in e)).map(e=>[e,A[e]])))}`));const r=await(g&&!R&&W?(async e=>{const t=new AbortController;Q=t;try{return await new Promise((r,n)=>{t.signal.addEventListener("abort",()=>n(z),{once:!0}),Promise.resolve(f(e,t)).then(r,n)})}finally{Q===t&&(Q=null)}})(A):f(A,null)),s=Date.now();let l;D&&console.log("[β
Fetch Successful β
] for params:",JSON.stringify(A));try{l=h?h(r,A):r}catch(e){throw new c(`[createQueryStore: ${a?.storageKey||k}]: transform failed`,e)}if(R)return D&&console.log("[π₯· Successful Parallel Fetch π₯·] for params:",JSON.stringify(A)),"withCache"===n.skipStoreUpdates&&t(e=>{if(!p)return v?{...e,queryCache:{...e.queryCache,[k]:{cacheTime:_,data:l,errorInfo:null,lastFetchedAt:s}}}:e;let t=e;const r=t.queryCache[k];return p({data:l,params:A,queryKey:k,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}}),!v&&Object.is(r,t.queryCache[k])&&(t={...t,queryCache:{...t.queryCache,[k]:{cacheTime:_,data:l,errorInfo:null,lastFetchedAt:s}}}),t}),l;if((p?i:t)(e=>{let t={...e,error:null,lastFetchedAt:s,queryKey:N?k:e.queryKey,status:Te.Success};if(p||v){if(p){D&&console.log("[πΎ Setting Data πΎ] for params:",JSON.stringify(A));const e=t.queryCache[k];p({data:l,params:A,queryKey:k,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}}),!v&&Object.is(e,t.queryCache[k])&&(t.queryCache={...t.queryCache,[k]:{cacheTime:_,data:null,errorInfo:null,lastFetchedAt:s}})}}else D&&console.log("[πΎ Setting Cache πΎ] for params:",JSON.stringify(A),"| Has previous data?:",!!t.queryCache[k]?.data),t.queryCache={...t.queryCache,[k]:{cacheTime:_,data:l,errorInfo:null,lastFetchedAt:s}};return v||b===1/0?t:Ye(O,k,t)}),W&&(J=k,m(A,n)),y)try{y({data:l,fetch:w.fetch,params:A,set:i})}catch(e){u.error(new c(`[createQueryStore: ${a?.storageKey||k}]: onFetched callback failed`,e))}return l??null}catch(s){if(s===z)return D&&console.log("[β Fetch Aborted β] for params:",JSON.stringify(A)),null;const i=!o&&!0===n?.throwOnError,f=l(s);if(R||!W){if(u.error(new c(`[createQueryStore: ${a?.storageKey||k}]: Failed to fetch data`,f)),i)throw f;return null}const y=v?void 0:r().queryCache[k],p=y?.errorInfo?.retryCount??0,h=p+1;if(d?.(f,p),p<q){if(G.get().subscriptionCount>0){const t="function"==typeof I?I(h,f):I;t!==1/0&&(V&&clearTimeout(V),V=setTimeout(()=>{const{enabled:t,subscriptionCount:r}=G.get();t&&r>0&&w.fetch(e,{force:!0},!0)},t))}t(e=>({...e,error:f,queryCache:{...e.queryCache,[k]:{cacheTime:y?.cacheTime??_,data:y?.data??null,lastFetchedAt:y?.lastFetchedAt??null,errorInfo:{error:f,lastFailedAt:Date.now(),retryCount:h}}},queryKey:N?k:e.queryKey,status:Te.Error}))}else t(e=>({...e,error:f,queryCache:{...e.queryCache,[k]:{cacheTime:y?.cacheTime??_,data:y?.data??null,lastFetchedAt:y?.lastFetchedAt??null,errorInfo:{error:f,lastFailedAt:Date.now(),retryCount:q}}},queryKey:N?k:e.queryKey,status:Te.Error}));if(u.error(new c(`[createQueryStore: ${a?.storageKey||k}]: Failed to fetch data`,f)),i)throw f;return null}finally{!R&&W&&(U=null)}};return R||!W?B():(U={key:k,promise:B()}).promise},getCacheEntry(e){if(v)return null;const t=r(),n=e?"string"==typeof e?e:K(Be(L,P,$,e)):t.queryKey;return t.queryCache[n]??null},getData(e){if(v)return null;const t=r().getCacheEntry(e);return t&&null!==t.data?O?t.data:t.lastFetchedAt&&Date.now()-t.lastFetchedAt>=t.cacheTime?null:t.data:null},getStatus:function(e){switch(e){case"isIdle":return r().status===Te.Idle;case"isLoading":return r().status===Te.Loading;case"isSuccess":{const e=r(),t=e.queryCache[e.queryKey]?.lastFetchedAt;return"number"==typeof t||e.status===Te.Success}case"isError":case"isInitialLoad":case void 0:{const t=r(),n=t.queryCache[t.queryKey],o=(v?J===t.queryKey&&t.lastFetchedAt:n?.lastFetchedAt)||null,s=t.status;switch(e){case"isError":{const e=t.queryCache[t.queryKey];return v?"error"!==s:"number"==typeof e?.errorInfo?.lastFailedAt}case"isInitialLoad":return!o&&s===Te.Loading}return{isError:s===Te.Error,isIdle:s===Te.Idle,isLoading:s===Te.Loading,isInitialLoad:!o&&s===Te.Loading,isSuccess:s===Te.Success}}}},isDataExpired(e){const t=r(),n=t.queryCache[t.queryKey],o=t.queryKey,s=t.lastFetchedAt,i=(v?J===o&&s:n?.lastFetchedAt)||null;if(!i)return!0;const a=e??n?.cacheTime;return void 0===a||Date.now()-i>=a},isStale(e){const t=r(),n=t.queryKey,o=(v?J===n&&t.lastFetchedAt:t.queryCache[n]?.lastFetchedAt)||null;if(!o)return!0;const s=e??T;return Date.now()-o>=s},reset(e=!1){for(const e of N)e();N=[],L=null,P=null,R=null,X(),V&&(clearTimeout(V),V=null),U=null,J=null,e&&t(e=>({...e,...H}))}},j=o.subscribe;return o.subscribe=(...e)=>{const t=_?()=>{}:G.subscribe(),r=1===e.length?j(e[0]):j(e[0],e[1],e[2]);return e=>{t(e),r()}},w},Z=a?.storageKey?re(Y,Object.assign(Object.create(null),a,{partialize:tt(O,a.partialize)})):o&&!("storageKey"in o)?re(Y,o):re(Y),ee=Z.getState(),te=ee.error,ne=ee.enabled,oe=ee.queryKey;if(oe&&!te&&(J=oe),_=!0,C||"function"==typeof e.enabled){const{directValues:e,enabledAttachVal:t,enabledDirectValue:r,attachVals:n}=function(e,t,r){const n=Object.create(null),o=Object.create(null),s=Object.create(null);for(const e in t){if(!Pe(t,e))continue;const i=t[e];if(Ze(i)){const t=i(xe,r);n[e]=t,s[e]=t.value}else et(i)&&(o[e]=i,s[e]=i)}let i,a=null,c=null;if(Ze(e)){const t=e(xe,r);i=t.value,a=t}else i=e,c=e;return{attachVals:n,directValues:o,enabledAttachVal:a,enabledDirectValue:c,resolvedEnabled:i,resolvedParams:s}}(w,C,Z);L={enabled:t,params:n},P={enabled:r,params:e}}"function"==typeof e.staleTime&&(R=e.staleTime(xe,Z),T=R.value);const se=function(){let e,t=!1;return function(...r){e=r,t||(t=!0,queueMicrotask(()=>{t=!1,(e=>{ee.fetch(e??He(L,P),{updateQueryKey:O})})(...e)}))}}();function ie(){let e;if(!O){e=He(L,P);const t=K(e);Z.setState(e=>({...e,queryKey:t}))}se(e)}const ae=i||!F?ie:A(ie,"number"==typeof F?F:F.delay,"number"==typeof F?{leading:!1,maxWait:F,trailing:!0}:F);if(L?.enabled){const e=L.enabled,t=ze.get(e);if(t){let r=e.value;ne!==r&&Z.setState(e=>({...e,enabled:r})),r&&G.setEnabled(r),D&&console.log("[π Enabled Subscription π] Initial value:",r);const n=t(()=>{const t=e.value;t!==r&&(D&&console.log("[π Enabled Change π] - [Old]:",`${r},`,"[New]:",t),r=t,Z.setState(e=>({...e,enabled:t})))});N.push(n)}}else ne!==H.enabled&&Z.setState(e=>({...e,enabled:H.enabled}));for(const e in L?.params){const t=L.params[e];if(!t)continue;const r=ze.get(t);if(D&&console.log("[π Param Subscription π] Subscribed to param:",e),r){let n=t.value;const o=r(()=>{const r=t.value;Ke(n,r)||(D&&console.log("[π Param Change π] -",e,"- [Old]:",`${n?.toString()},`,"[New]:",r?.toString()),n=r,ae())});N.push(o)}}if(R){const e=ze.get(R);if(e){const t=R;let r=t.value;D&&console.log("[π StaleTime Subscription π] Initial value:",r);const n=e(()=>{const e=t.value;e!==r&&(D&&console.log("[π StaleTime Change π] - [Old]:",`${r},`,"[New]:",e),r=e,T=e,Z.getState().fetch())});N.push(n)}}return _=!1,W&&queueMicrotask(ae),ce=Z,ue="_queryStore",Object.assign(ce,{[ue]:!0});var ce,ue},exports.createStoreActions=function(e,t){const r=function(e){const t=e.getState(),r=Object.create(null);if(s&&("object"!=typeof t||null===t))throw new Error("[createStoreActions]: State is not an object");if(B(e)){for(const n in t)ut(t,n)&&(r[n]=ct(e,n));return r}for(const e in t)ut(t,e)&&(r[e]=t[e]);return r}(e);return t?Object.assign(r,t):r},exports.createVirtualStore=function(e,t,r){const n="function"==typeof t,o=n?t:void 0,s=n?r:t,i=new Set,a=Fe(e,{debugMode:s?.debugMode??!1,equalityFn:function(e,t){const r=Object.is(e,t);return r||(function(e,t){for(const r of i){r.unsubscribe();const n=r.args;if(1===n.length){const o=n[0],s=e.getState(),i=t.getState(),a=t.subscribe(o);r.unsubscribe=a,Object.is(i,s)||o(i,s);continue}const o=n[0],s=n[1];let i=n[2];i?.fireImmediately&&(i={...i,fireImmediately:!1});const a=o(e.getState()),c=o(t.getState()),u=t.subscribe(o,s,i);r.unsubscribe=u,(i?.equalityFn??Object.is)(a,c)||s(c,a)}}(e,t),_(e)),r},keepAlive:!0,lockDependencies:s?.lockDependencies??!0}),c=a.getState().persist,u=(l=a.getState,function(e,t){return t?l().setState(e,t):l().setState(e)});var l;return Object.assign(function(e,t){const r=a();return e?r(e,t):r()},{_virtualStore:!0,destroy:()=>a.destroy(),getInitialState:()=>a.getState().getInitialState(),getState:()=>a.getState().getState(),persist:c,setState:u,subscribe:function(...e){const t={args:e,unsubscribe:1===e.length?a.getState().subscribe(e[0]):a.getState().subscribe(e[0],e[1],e[2])};return i.add(t),()=>{t.unsubscribe(),i.delete(t)}}},o?o(a.getState):void 0)},exports.deepEqual=function e(t,r){if("object"!=typeof t||null==t||"object"!=typeof r||null==r)return t===r;if(Object.is(t,r))return!0;const n=Object.keys(t);if(n.length!==Object.keys(r).length)return!1;for(const o of n)if(!(o in r)||!e(t[o],r[o]))return!1;return!0},exports.defaultRetryDelay=Qe,exports.destroyStore=_,exports.destroyStores=function(e,t){for(const r of Array.isArray(e)?e:Object.values(e))r&&!t?.skipDestroy?.(r)&&_(r,t)},exports.getLegacyQueryKey=Ue,exports.getQueryKey=Ve,exports.getStoreName=Q,exports.isDerivedStore=function(e){return"flushUpdates"in e},exports.isPersistedStore=J,exports.isQueryStore=V,exports.isVirtualStore=B,exports.parseQueryKey=function(e){return JSON.parse(e)},exports.replacer=T,exports.reviver=K,exports.shallowEqual=function(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const n of r)if(!Object.is(e[n],t[n]))return!1;return!0},exports.time=M,exports.useListen=function(e,t,r,o=nt){const s=function(){const e=n.useRef(rt);return e.current===rt&&(e.current=function(e,t,r){return{selector:e,react:t,isActive:!1,options:it(r),resubscribe:()=>{},unsubscribe:()=>{}}}(t,r,o)),e}(),i=function(e){return"function"==typeof e?nt.enabled:e?.enabled??nt.enabled}(o);return s.current.react=r,s.current.selector=t,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??nt)}(s,o),n.useLayoutEffect(()=>{if(i)return st(e,s),()=>function(e){e.current.options.debugMode&&console.log("[ποΈ useListen ποΈ] Detaching listener"),e.current.resubscribe=()=>{},e.current.unsubscribe(),e.current.unsubscribe=()=>{},e.current.isActive=!1}(s)},[i,e]),s},exports.useStableValue=function(e){const t=n.useRef(at);return t.current===at&&(t.current=e()),t.current};
|
|
1
|
+
var e=require("zustand/middleware"),t=require("zustand/vanilla"),n=require("react"),r="undefined"!=typeof window&&"undefined"!=typeof document,o="development"===process.env.NODE_ENV,s="test"===process.env.NODE_ENV;function i(){return"undefined"!=typeof window?window.localStorage:null}var c={debug:(e,t)=>{o&&console.debug(e,t)},error:(e,t)=>{o&&!s&&console.error(e,t)},info:(e,t)=>{o&&console.info(e,t)},warn:(e,t)=>{o&&console.warn(e,t)}},a=class extends Error{constructor(e,t){super(e),this.name="StoresError",void 0!==t&&Object.defineProperty(this,"cause",{configurable:!0,value:t,writable:!0})}};function u(e){return e instanceof Error?e:new Error(String(e))}var l=Object.prototype.hasOwnProperty;function f(e,t){return l.call(e,t)}function d(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var y=Object.freeze(Object.create(null));function p(e){return e}function h(){return Object.create(y)}function g(){}var b="stores/core/sync-channel",m=`${b}:storage:`;function S(){try{return"undefined"!=typeof window?window.localStorage:null}catch{return null}}var v,w,O,q,j=class{constructor(e){this.broadcast=e.broadcast,this.origin=e.origin,this.storeKey=e.storeKey,this.teardown=e.teardown}destroy(){this.teardown()}publish(e){const t=h();for(const n of Object.entries(e.values))t[n[0]]=n[1];const n={origin:this.origin,replace:e.replace,sessionId:e.sessionId,storeKey:this.storeKey,timestamp:e.timestamp,values:t};this.broadcast(n)}},F=class{constructor(){this.listeners=new Map,this.origin="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`${Math.random().toString(36).slice(2)}:${Date.now().toString(36)}`,this.onChannelMessage=e=>{e.data&&this.dispatch(e.data)},this.onStorageEvent=e=>{if(e.key&&e.newValue&&e.key.startsWith(m))try{const t=JSON.parse(e.newValue);this.dispatch(t)}catch(e){c.error(new a("[sync] Failed to parse storage event payload",e))}},this.channel="undefined"==typeof BroadcastChannel?null:new BroadcastChannel(b),this.storage=S(),this.channel&&this.channel.addEventListener("message",this.onChannelMessage),r&&window.addEventListener("storage",this.onStorageEvent)}get sessionId(){return this.origin}register(e){const t=t=>{if(t.origin===this.origin||t.storeKey!==e.key)return;const n=h();for(const r of e.fields)f(t.values,r)&&(n[r]=t.values[r]);Object.keys(n).length&&e.apply({replace:t.replace,sessionId:t.sessionId,timestamp:t.timestamp,values:n})};let n=this.listeners.get(e.key);return n||(n=new Set,this.listeners.set(e.key,n)),n.add(t),new j({broadcast:e=>this.broadcast(e),origin:this.origin,storeKey:e.key,teardown:()=>this.removeListener(e.key,t)})}broadcast(e){try{this.channel&&this.channel.postMessage(e),this.writeToStorage(e)}catch(e){c.error(new a("[sync] Failed to broadcast update",e))}}dispatch(e){if(!e.storeKey)return;const t=this.listeners.get(e.storeKey);if(t&&t.size)for(const n of t)n(e)}removeListener(e,t){const n=this.listeners.get(e);n&&(n.delete(t),n.size||this.listeners.delete(e))}writeToStorage(e){if(this.storage||(this.storage=S()),!this.storage)return;const t=`${m}${e.storeKey}`;try{this.storage.setItem(t,JSON.stringify(e))}catch(e){c.error(new a("[sync] Failed to write broadcast payload to storage",e))}}},I=class{destroy(){}publish(){}},A=class{constructor(){this.sessionId="noop"}register(e){return new I}},C=!1;function k(){return q??(q=E(void 0))}function T(){C=!0}function E(e){return{storage:e?.storage??(t=e?.storageKeyPrefix??"stores:",{clearAll(){try{const e=i();if(!e)return;const n=[];for(let r=0;r<e.length;r++){const o=e.key(r);o?.startsWith(t)&&n.push(o)}for(const t of n)e.removeItem(t)}catch(e){console.error("Error clearing localStorage:",e)}},contains(e){const n=i();return null!==n?.getItem(`${t}${e}`)},delete(e){try{const n=i();n?.removeItem(`${t}${e}`)}catch(e){console.error("Error deleting from localStorage:",e)}},getAllKeys(){try{const e=i();return e?Array.from(e.keys()):[]}catch(e){return console.error("Error getting keys from localStorage:",e),[]}},get(e){try{const n=i();return n?n.getItem(`${t}${e}`)??void 0:void 0}catch(e){return void console.error("Error reading from localStorage:",e)}},set(e,n){try{const r=i();r?.setItem(`${t}${e}`,n)}catch(e){console.error("Error writing to localStorage:",e)}}}),syncEngine:e?.syncEngine??(r?(v||(v=new F),v):(w||(w=new A),w))};var t}var D=Symbol("empty selection"),z=Object.is;function x(e,t,r,o,s=z){const i=n.useRef(null);let c=e,a=t,u=r;if(o){let n=i.current;null===n&&(n=function(e,t,n,r,o){const s={committedEqualityFn:o,committedSelector:r,committedSource:e,committedValue:D,equalityFn:o,getSelectedServerSnapshot:()=>function(e){return $(e,(e.getServerStoreSnapshot??e.getStoreSnapshot)())}(s),getSelectedSnapshot:()=>K(s),getServerStoreSnapshot:n,getStoreSnapshot:t,latestSnapshot:D,latestSource:D,selector:r,selectedSource:e,selectedSubscribe:()=>g,source:e,value:D,valueEqualityFn:o,valueSelector:r,valueSnapshot:D};return s.selectedSubscribe=M(s,e),s}(e,t,r,o,s),i.current=n),function(e,t,n,r,o,s){e.source===t&&e.getStoreSnapshot===n||(e.latestSnapshot=D),e.source=t,e.getStoreSnapshot=n,e.getServerStoreSnapshot=r,e.selector=o,e.equalityFn=s,e.selectedSource!==t&&(e.selectedSource=t,e.selectedSubscribe=M(e,t))}(n,e,t,r,o,s),c=n.selectedSubscribe,a=n.getSelectedSnapshot,u=void 0===r?void 0:n.getSelectedServerSnapshot}const l=n.useSyncExternalStore(c,a,u);return n.useDebugValue(l),l}function M(e,t){return n=>(function(e){e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedSource=e.source,e.committedValue=e.value===D?K(e):e.value}(e),t(r=>{e.latestSnapshot=r,e.latestSource=t;const o=e.committedValue;if(o===D||e.committedSource!==t)return void n();const s=e.committedSelector,i=e.committedEqualityFn;if(e.selector===s&&e.equalityFn===i){const t=s(r);if(i===z?z(o,t):i(o,t))return;return e.committedValue=t,e.value=t,e.valueEqualityFn=i,e.valueSelector=s,e.valueSnapshot=r,void n()}if(e.source!==t)return void n();const c=e.value;if(c===D)return;const a=e.selector(r),u=e.equalityFn(c,a);e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedValue=P(e,r,u?c:a),u||n()}))}function K(e){const t=function(e){if(e.latestSource===e.source&&e.latestSnapshot!==D)return e.latestSnapshot;const t=e.getStoreSnapshot();return e.latestSnapshot=t,e.latestSource=e.source,t}(e);return $(e,t)}function $(e,t){const n=e.value;if(n!==D&&z(e.valueSnapshot,t)&&e.valueSelector===e.selector&&e.valueEqualityFn===e.equalityFn)return n;const r=e.selector(t);if(n!==D&&(e.equalityFn===z?z(n,r):e.equalityFn(n,r)))return P(e,t,n);const o=e.committedValue;return o!==D&&o!==n&&e.committedSource===e.source&&(e.equalityFn===z?z(o,r):e.equalityFn(o,r))?P(e,t,o):P(e,t,r)}function P(e,t,n){return e.value=n,e.valueEqualityFn=e.equalityFn,e.valueSelector=e.selector,e.valueSnapshot=t,n}function R(e,n){return(e,n)=>function(e,n){const r=t.createStore(e);return Object.assign(function(e,t){return x(r.subscribe,r.getState,r.getInitialState,e,t??n)},r)}(e,n)}function L(){let e,t,n=!1;return{complete:function(){!n&&e&&(n=!0,e(),e=void 0,t=void 0)},isHydrated:function(){return n},fail:function(r){!n&&t&&(n=!0,t(r),t=void 0,e=void 0)},promise:new Promise((n,r)=>{e=n,t=r})}}var N=Math.max,V=Math.min;function W(e,t=0,n={}){let r,o,s,i,c,a,u=0,l=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){const n=r,s=o;return r=o=void 0,u=t,i=n?e.apply(s,n):e.apply(s),i}function p(e){const n=e-(a??0);return void 0===a||n>=t||n<0||f&&void 0!==s&&e-u>=s}function h(){const e=U();if(p(e))return g(e);c=setTimeout(h,function(e){const n=t-(e-(a??0));return f&&void 0!==s?V(n,s-(e-u)):n}(e))}function g(e){return c=void 0,d&&r?y(e):(r=o=void 0,i)}function b(...e){const n=U(),s=p(n);if(r=e,o=this,a=n,s){if(void 0===c)return function(e){return u=e,c=setTimeout(h,t),l?y(e):i}(a);if(f)return clearTimeout(c),c=setTimeout(h,t),y(a)}return void 0===c&&(c=setTimeout(h,t)),i}return t=_(t)||0,function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}(n)&&(l=!!n.leading,f="maxWait"in n,s=f?N(_(n.maxWait)||0,t):void 0,d="trailing"in n?!!n.trailing:d),b.cancel=function(){void 0!==c&&clearTimeout(c),u=0,r=a=o=c=void 0},b.flush=function(){return void 0===c?i:g(U())},b}function U(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function _(e){if("number"==typeof e)return e;if("symbol"==typeof e||void 0===e)return NaN;if("object"==typeof e&&null!==e){const t="function"==typeof e.valueOf?e.valueOf():e;e="object"==typeof t?t+"":t}return"string"!=typeof e?0===e?e:+e:(e=e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),/^0b[01]+$/i.test(e)?parseInt(e.slice(2),2):/^0o[0-7]+$/i.test(e)?parseInt(e.slice(2),8):/^[-+]0x[0-9a-f]+$/i.test(e)?NaN:+e)}function B(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function J(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}function H(e){if(!d(e))return e;const t=h(),n=Object.keys(e);for(let r=0;r<n.length;r++){const o=n[r],s=e[o];"function"!=typeof s&&(t[o]=s)}return t}var Q={ms:e=>e,seconds:e=>1e3*e,minutes:e=>6e4*e,hours:e=>36e5*e,days:e=>864e5*e,weeks:e=>6048e5*e,infinity:1/0,zero:0},G=s?0:r?Q.ms(200):Q.seconds(5);function X(e){return t=>{if("string"!=typeof t)throw new a("[createBaseStore]: Received non-string serialized state without a custom deserializer. Provide a deserializer on the store or storage adapter.");return function(e,t){try{return JSON.parse(e,t?J:void 0)}catch(e){throw c.error(new a("[createBaseStore]: Failed to deserialize persisted store data",e)),e}}(t,e)}}function Y(e){return t=>function(e,t){try{return JSON.stringify(e,t?B:void 0)}catch(e){throw c.error(new a("[createBaseStore]: Failed to serialize store data",e)),e}}(t,e)}var Z=Object.freeze({shouldClear:!1});function ee(e,t,n){if(!t||!e)return Z;const r=e.getFieldTimestampSnapshot();return function(e,t){const n=e.getSessionId(),r=e.getTimestamp();void 0!==n&&void 0!==r&&(t.syncMetadata={origin:n,timestamp:r})}(e,n),n.syncMetadata?r&&Object.keys(r).length>0?(n.syncMetadata.fields=r,{fieldSnapshot:r,shouldClear:!0}):(delete n.syncMetadata.fields,{fieldSnapshot:r,shouldClear:!1}):{fieldSnapshot:r,shouldClear:!1}}function te(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function ne(e){return!!e&&!!e.getIsApplyingRemote()}var re=Object.freeze({QueryStore:Symbol("queryStore"),VirtualStore:Symbol("virtualStore")});function oe(e,...t){if(!0===t[1])return le(t[0])?t[0](e):t[0];const n=le(t[0])?t[0](e):t[0];return function(e){return Array.isArray(e)}(e)?n:{...e,...n}}function se(e,t){ce(e)?e.getState().reset(t?.clearQueryCache):function(e){return"destroy"in e}(e)&&e.destroy()}function ie(e){return"getSnapshot"in e}function ce(e){return re.QueryStore in e}function ae(e){return!(!("persist"in e)||!e.persist)&&"string"==typeof e.persist.getOptions().name}function ue(e){return re.VirtualStore in e}function le(e){return"function"==typeof e}var[fe,de]=[0,1];function ye(e,t,n){if(!e)return!0;const r=e[fe],o=e[de];return!(t<r)&&(t>r||n>o)}function pe(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function he(e,t){if(!o)return!0;if(null===e||null===t)return e===t;const n=typeof e;return n===typeof t&&("object"!==n||Object.prototype.toString.call(e)===Object.prototype.toString.call(t))}function ge(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function be(t,n){T();const r=void 0!==n&&"string"==typeof n.storageKey,o=r?n.storageKey:void 0,s=n?.sync?function(e,t){if(!e)return null;if(!0===e){if(!t)throw new a("[createBaseStore]: sync: true requires a storageKey to inherit the key from");return{key:t}}if("string"==typeof e)return{key:e};const n=e,r=n.key??t;if(!r)throw new a("[createBaseStore]: sync requires either a key in the config or a storageKey to inherit from");return{...n,key:r}}(n.sync,o):void 0,i=r?n.storage??k().storage:void 0,l=s?function(e,t,n){const r=t.engine??k().syncEngine,o=function(e){let t,n,r,o=!1;return{isAsync:e,clearFieldTimestamps:function(e){if(e&&r){for(const t of Object.entries(e)){const e=t[0],n=t[1];r[e]===n&&delete r[e]}Object.keys(r).length||(r=void 0)}},getFieldTimestampSnapshot:function(){if(r)return{...r}},getIsApplyingRemote:()=>o,getSessionId:()=>t,getTimestamp:()=>n,mergeFieldTimestamps:function(e){if(r)for(const t of Object.entries(e)){const e=t[0],n=t[1],o=r[e];(void 0===o||n>o)&&(r[e]=n)}else r={...e}},onHydrationComplete:void 0,onHydrationFlushEnd:void 0,setIsApplyingRemote:e=>o=e,setSessionId:e=>t=e,setTimestamp:e=>n=e,setWithoutPersist:void 0}}(n);return{stateCreator:(s,i,u)=>{const l=new Map,f=[],d=[];let y=null,p=!1,g=!1,b=0,m=null,S=[],v=Promise.resolve(),w=!n;function O(e,t){if(o?.setSessionId&&o?.setTimestamp&&r.sessionId&&(o.setSessionId(r.sessionId),o.setTimestamp(e),o.mergeFieldTimestamps&&t.length>0)){const n=h();for(const r of t)n[String(r)]=e;o.mergeFieldTimestamps(n)}}function q(e,t){if(p||!m)return t?s(e,t):s(e);const n=function(){const e=Date.now(),t=e>b?e:b+1;return b=t,t}();let o=[],i=h();const c=r=>{const s=oe(r,e,t);for(const e of S)Object.is(s[e],r[e])||(o.push(e),i[e]=s[e]);return o.length&&O(n,o),s},a=t?s(c,!0):s(c);function u(){o.length&&function(e){const t=r.sessionId;for(const n of e.keys)l.set(n,[e.timestamp,t]);y&&g?y.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values}):d.push(e)}({keys:o,replace:t??!1,values:i,timestamp:n})}return(f=a)&&"object"==typeof f&&"then"in f&&"function"==typeof f.then?a.finally(u):(u(),a);var f}const j=u.setState;u.setState=q;const F=e(q,i,u);if(S=t.fields??function(e){const t=[];for(const n of Object.entries(e)){if("function"==typeof n[1])continue;const e=n[0];t.push(e)}return t}(F),!S.length)return F;async function I(e){b=Math.max(b,e.timestamp);const n=h(),r=i(),s=e.timestamp;let u;if(e.replace)for(const t of S)pe(t,e.values)||ye(l.get(t),s,e.sessionId)&&(u??(u=[])).push(t);for(const o of S){if(!pe(o,e.values))continue;if(!m?.has(o))continue;if(!ye(l.get(o),s,e.sessionId))continue;const i=t.merge?.[o];if(i){const t=e.values[o],u=r[o];if(void 0!==t){const f=i(t,u,r,e.values),d=void 0!==u?u:t;if(!he(f,d))return void c.error(new a(`[sync] Merge function for field "${String(o)}" returned ${ge(f)} but expected ${ge(d)}`));n[o]=f,l.set(o,[s,e.sessionId])}}else n[o]=e.values[o],l.set(o,[s,e.sessionId])}if(Object.keys(n).length>0||u?.length){p=!0,o&&o.setIsApplyingRemote(!0);try{if(e.replace){const e={...r};let t=!1;if(u?.length){t=!0;for(const t of u)delete e[t],l.delete(t)}for(const r in n){if(!Object.prototype.hasOwnProperty.call(n,r))continue;const o=n[r];void 0!==o&&(Object.is(e[r],o)||(t=!0),e[r]=o)}if(!t)return;await(o.setWithoutPersist??j)(e,!0)}else await(o.setWithoutPersist??j)(n)}finally{p=!1,o&&o.setIsApplyingRemote(!1)}}}function A(e){n?v=v.then(()=>I(e)):I(e)}if(m=new Set(S),y=r.register({apply:e=>{w?A(e):f.push(e)},fields:S,getState:i,key:t.key}),y?.onFirstSubscribe||y?.onLastUnsubscribe){let e=0;const t=u.subscribe;u.subscribe=(...n)=>{e||y.onFirstSubscribe?.(),e+=1;const r=1===n.length?t(n[0]):t(n[0],n[1],n[2]);return()=>{r(),e-=1,e||queueMicrotask(()=>{e||y.onLastUnsubscribe?.()})}}}function C(){g=!0,function(){if(y&&d.length){for(const e of d){const t=r.sessionId;for(const n of e.keys)l.set(n,[e.timestamp,t]);O(e.timestamp,e.keys),y.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values})}d.length=0}}()}function k(){w=!0,function(){if(!f.length)return;const e=f.slice();f.length=0;for(const t of e)A(t)}()}return n?(o.onHydrationComplete=C,o.onHydrationFlushEnd=k):y.onHydrated?(y.onHydrated(C),k()):(C(),k()),F},syncContext:o}}(t,s,i?.async??!1):void 0,f=l?.stateCreator??t;if(!r)return R()(e.subscribeWithSelector(f),Object.is);const d=i?.async?function(e){let t,n,r,o=!1;return{hydrationPromise:()=>o?t?.promise??n??(n=Promise.resolve()):(t||(t=L()),t.promise),stateCreator:(n,s,i)=>{let c;return r=()=>{if(c?.length){for(const e of c)e[1]?i.setState(e[0],e[1]):i.setState(e[0]);c=void 0}},e((...e)=>o?!0===e[1]?n(e[0],e[1]):n(e[0]):(t||(t=L()),c||(c=[]),c.push(e),t.promise),s,i)},wrapOnRehydrateStorage:(e,n)=>s=>{const i=e?.(s);return(e,s)=>{o=!0,n?.onHydrationComplete?.(),r&&r(),n?.onHydrationFlushEnd?.(),s?t?.fail(u(s)):t?.complete(),i?.(e,s)}}}}(f):null,y=function(e,t,n){const r=t??e.storage??k().storage,o=(e.sync?void 0:e.persistThrottleMs??G)||void 0,s=e.version??0,i=r.async?function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),s="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),i=t.partialize??H,u=t.deserializer??e.deserializer??X(o),l=t.serializer??e.serializer??Y(o);async function f(t,n){try{if(ne(r))return;n.state,n.state=i(n.state);const o=ee(r,s,n),u=l(n);try{await e.set(t,u),te(r,o)}catch(e){c.error(new a("[createBaseStore]: Failed to persist store data",e))}}catch(e){c.error(new a("[createBaseStore]: Failed to serialize persisted store data",e))}}const d=void 0!==n?W(f,n,{leading:!1,maxWait:n,trailing:!0}):function(e){let t,n=null;return function(...r){return t=r,n||(n=new Promise(r=>{queueMicrotask(async()=>{try{await e(...t)}finally{n=null,r()}})})),n}}(f);return{getItem:async t=>{const n=await e.get(t);return void 0===n?null:u(n)},setItem:async(e,t)=>{if(!r?.getIsApplyingRemote())return await d(e,t)},removeItem:async t=>{try{await e.delete(t)}catch(e){c.error(new a("[createBaseStore]: Failed to delete persisted store data",e))}}}}(r,e,o,n):function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),s="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),i=t.partialize??H,u=t.deserializer??e.deserializer??X(o),l=t.serializer??e.serializer??Y(o);function f(t,n){try{if(ne(r))return;n.state,n.state=i(n.state);const o=ee(r,s,n),u=l(n);try{e.set(t,u),te(r,o)}catch(e){c.error(new a("[createBaseStore]: Failed to persist store data",e))}}catch(e){c.error(new a("[createBaseStore]: Failed to persist store data",e))}}const d=void 0!==n?W(f,n,{leading:!1,maxWait:n,trailing:!0}):f;return{getItem:t=>{const n=e.get(t);return void 0===n?null:u(n)},setItem:(e,t)=>{r?.getIsApplyingRemote()||d(e,t)},removeItem:t=>{try{e.delete(t)}catch(e){c.error(new a("[createBaseStore]: Failed to delete persisted store data",e))}}}}(r,e,o,n);return{persistStorage:i,version:s}}(n,i,l?.syncContext),p=d?d.wrapOnRehydrateStorage(n.onRehydrateStorage,l?.syncContext):n.onRehydrateStorage,g=d?(e,t,n)=>(l&&(l.syncContext.setWithoutPersist=n.setState),d.stateCreator(e,t,n)):f,b=R()(e.subscribeWithSelector(e.persist(g,function(e,t,n){const r={name:e.storageKey,onRehydrateStorage:n,storage:t.persistStorage,version:t.version};return void 0!==e.merge&&(r.merge=e.merge),void 0!==e.migrate&&(r.migrate=e.migrate),r}(n,y,p))),Object.is);return d?Object.assign(b,{persist:Object.assign(b.persist,{hydrationPromise:d.hydrationPromise})}):b}var me=!1,Se=!1,ve=new Map,we=new Map,Oe=new Map,qe=null,je=1/0;function Fe(){return me}function Ie(){return qe}function Ae(){me||(me=!0,Se||(Se=!0,queueMicrotask(()=>{Se=!1,(()=>{for(;we.size>0;){const e=je,t=Oe.get(e);if(t){Oe.delete(e);for(const e of t)we.delete(e);qe=e;for(const e of t)e();if(qe=null,Oe.size>0){je=1/0;for(const e of Oe.keys())e<je&&(je=e)}else je=1/0}else{je=1/0;for(const e of Oe.keys())e<je&&(je=e)}}for(;ve.size>0;){const e=Array.from(ve.values());ve.clear();for(const t of e)t()}})(),me=!1,qe=null,we.clear(),Oe.clear(),je=1/0})))}function Ce(e,t){me&&ve.set(e,t)}var ke=Symbol("stores.deriveProxy.unwrap");function Te(e,t,n){const r=t.get(e);if(void 0!==r)return r;const o=function(e,t,n,r=[]){return e&&"object"==typeof e?Ee(e,r,t,n,new WeakSet,new WeakMap):(n(t,r,!0),e)}(ie(e)?e.getSnapshot():e.getState(),e,n);return t.set(e,o),o}function Ee(e,t,n,r,o,s){return new Proxy(e,{get(i,c,a){if(c===ke)return r(n,t,!0),i;if(o.has(i))return Reflect.get(i,c,a);if("__proto__"===c||"symbol"==typeof c)return c===Symbol.iterator&&(r(n,t,!0),o.add(i)),Reflect.get(i,c,a);const u=Reflect.get(i,c,i),l=String(c),f=t.concat(l);if("function"==typeof u)return Object.prototype.hasOwnProperty.call(i,c)?function(...e){return r(n,f,!0,{method:l,args:e.length?e:void 0}),Reflect.apply(u,i,e)}:(r(n,t,!0),u.bind(e));const d=!!u&&"object"==typeof u;return r(n,f,!d),d?(s.has(u)||s.set(u,Ee(u,f,n,r,o,s)),s.get(u)):u},getOwnPropertyDescriptor:(e,s)=>(r(n,t,!0),o.add(e),Reflect.getOwnPropertyDescriptor(e,s)),has:(e,o)=>(r(n,t,!0),Reflect.has(e,o)),ownKeys:e=>(r(n,t,!0),o.add(e),Reflect.ownKeys(e))})}function De(e,t){if(!e||"object"!=typeof e)return e;const n=function(e){const t=Reflect.get(e,ke);return t&&"object"==typeof t?t:void 0}(e);return n||(Array.isArray(e)?function(e,t){const n=xe(e,t);if(n)for(let t=0;t<e.length;t++)ze(e,String(t),n)}(e,t):d(e)&&function(e,t){const n=xe(e,t);if(n)for(const t of Reflect.ownKeys(e))ze(e,t,n)}(e,t),e)}function ze(e,t,n){const r=Reflect.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r))return;const o=De(r.value,n);o!==r.value&&(r.value=o,Reflect.defineProperty(e,t,r))}function xe(e,t){const n=t??new WeakSet;return n.has(e)?null:(n.add(e),n)}function Me(e,t,n="s"){return 1===t?e:`${e}${n}`}var Ke=Object.freeze([]);function $e(){const e=new Map;return{buildProxySubscriptions(t,n,r,o){const s=new Set;for(const t of e)Le(t[1],t[0],[],0,s,r);!1!==o?.(s)&&function(e,t,n){for(const n of e){const e=n.invocation?Ve(n.path,n.invocation):Ne(n.path);t(n.store,e,n.path)}n&&function(e){const t=e.size;console.log(`[π‘ ${t} ${Me("Proxy Subscription",t)} π‘]:`,JSON.stringify(Array.from(e).map(e=>{const t="name"in(n=e.store)&&"string"==typeof n.name?n.name:"store";var n;const r=e.path.join(".");if(!e.invocation)return r?`$(${t}).${r}`:`$(${t})`;const o=e.invocation.args?.length??0;return`$(${t}).${r}${o?`(${o}_${Me("arg",o)})`:"()"}`}),null,2))}(e)}(s,t,n)},reset(){e.clear()},trackPath(t,n,r,o){let s=e.get(t);s||(s=Pe(),e.set(t,s)),Re(s,n,0,r,o)}}}function Pe(){return h()}function Re(e,t,n,r,o){if(n===t.length)return r&&(e.isLeaf=!0),void(o&&(e.invocation=o));e.children||(e.children=Pe());const s=t[n];let i=e.children?.[s];i||(i=Pe(),e.children[s]=i),Re(i,t,n+1,r,o)}function Le(e,t,n,r,o,s=2){const i=e.children;if(!i)return void o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});const c=Object.keys(i),a=c.length;if(0!==a)if(e.isLeaf||r>=s&&a>1){o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});for(const e of c){const c=i[e];c.invocation&&Le(c,t,[...n,e],r+1,o,s)}}else if(r<s&&a>1&&!e.isLeaf)for(const e of c)Le(i[e],t,[...n,e],r+1,o,s);else{if(1===a){const e=c[0];return void Le(i[e],t,[...n,e],r+1,o,s)}o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}else o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}function Ne(e){return t=>We(t,e)}function Ve(e,t){const n=e.slice(0,-1);return e=>{const r=We(e,n),o=r&&"object"==typeof r?Reflect.get(r,t.method):void 0;return"function"==typeof o?Reflect.apply(o,r,t.args??Ke):void 0}}function We(e,t){let n=e;for(const e of t){if(!n||"object"!=typeof n)return n;n=Reflect.get(n,e)}return n}function Ue(e,t=Object.is){return n=function(e,t=Object.is){const{debounceOptions:n,debugMode:r,equalityFn:s,keepAlive:i,lockDependencies:c}="function"==typeof(l=t)?{debounceOptions:void 0,debugMode:!1,equalityFn:l,keepAlive:!1,lockDependencies:!1}:{debounceOptions:l.debounce,debugMode:(o&&l.debugMode)??!1,equalityFn:l.equalityFn??Object.is,keepAlive:l.keepAlive??!1,lockDependencies:l.lockDependencies??!1},a=String(Je+=1),u=new Set;var l;i&&u.add(He);const f=new Set;let d,y,h=_e,g=!1,b=!0,m=!0,S=0,v=!1,w=null,O=_e;function q(e,t,n){return m&&u.size?t?(f.add(e.subscribe(t,x,n?{equalityFn:n,isDerivedStore:!0}:Be)),t(ie(e)?e.getSnapshot():e.getState())):(d||(d=new WeakMap),y||(y=$e()),Te(e,d,y.trackPath)):(t??p)(ie(e)?e.getSnapshot():e.getState())}function j(e){for(const t of f)t(e);f.clear()}let F=!0;function I(){if(!b&&Qe(h))return h;b=!1,m&&j(!0);const t=h,n=Qe(t);h=function(t){F=!0;const n=h,o=e(t),i=y?De(o):o;return Qe(n)&&s(n,i)?(r&&console.log("[π₯· Derive Complete π₯·]: No change detected"),F=!1,n):i}(q);const o=r&&(!n||"verbose"===r&&m);if(o){n?"verbose"===r&&console.log("[π Rebuilding Subscriptions π]: Createdβ¦"):console.log("[π Initial Derive Complete π]: Createdβ¦");const e=f.size;console.log(`[π― ${e} ${Me("Selector Subscription",e)} π―]`)}return y&&m&&(y.buildProxySubscriptions((e,t)=>{f.add(e.subscribe(t,x,Be))},o),d=void 0,y.reset(),c&&(y=void 0)),F&&n&&function(e,t){const n=function(){const e=u.has(He)?u.size-1:u.size;return S>0&&S<e}(),o=!S||n,s=n||null!==Ie()||Fe()&&o;n&&Ae(),r&&console.log(`[π» Derive Complete π»]: Notifying ${u.size} ${Me("watcher",u.size)}`);for(const t of u){if("function"==typeof t||!t.isDerivedWatcher)continue;const n=t.selector(e);if(!t.equalityFn(t.currentSlice,n)){const e=t.currentSlice;t.currentSlice=n,t.listener(n,e)}}s?v||(v=!0,Qe(O)||(O=t),Ce(a,C)):A(e,t)}(h,t),c&&(m=!1),h}function A(e,t){for(const n of u)if("function"==typeof n)n(e,t);else if(!n.isDerivedWatcher){const t=n.selector(e);if(!n.equalityFn(n.currentSlice,t)){const e=n.currentSlice;n.currentSlice=t,n.listener(t,e)}}}function C(){if(!u.size)return;if(b&&!S&&I(),!Qe(h))return;const e=Qe(O)?O:h;A(h,e),v=!1,O=_e}const k=n?W(E,"number"==typeof n?n:n.delay,"number"==typeof n?{leading:!1,maxWait:n,trailing:!0}:n):void 0,T=k??(()=>{g||(g=!0,queueMicrotask(E))});function E(){g=!1,u.size?b&&I():K()}function D(e){e||k&&b?queueMicrotask(()=>{u.size||K()}):K()}function z(){E(),w=null}function x(){if(!b){if(b=!0,!k){if(S){Ae();const e=Ie(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!me)return;const n=t<0?0:0|t,r=we.get(e);if(void 0===r){we.set(e,n);let t=Oe.get(n);return t||(t=new Set,Oe.set(n,t)),t.add(e),void(n<je&&(je=n))}if(n>r){const t=Oe.get(r);if(t&&(t.delete(e),0===t.size&&(Oe.delete(r),r===je))){je=1/0;for(const e of Oe.keys())e<je&&(je=e)}we.set(e,n);let o=Oe.get(n);o||(o=new Set,Oe.set(n,o)),o.add(e),n<je&&(je=n)}}(z,t)}if(Fe())return void(v||(v=!0,Qe(h)&&(O=h),Ce(a,C)))}w=null,T()}}function M(){return b||!Qe(h)?u.size>0?I():e(q):h}function K(e=!0){i&&e||(k?.cancel(),j(),u.clear(),S=0,y=void 0,d=void 0,m=!0,g=!1,b=!0,h=_e,v=!1,O=_e,w=null)}return{destroy:()=>K(!1),flushUpdates:function(){u.size&&(k?k.flush():b&&I())},getSnapshot:function(){if(!Qe(h)){u.add(He);const e=I();return u.delete(He),e}return g&&E(),h},getState:M,subscribe:function(...e){if(1===e.length){const t=e[0];return u.add(t),1!==u.size||Qe(h)||M(),()=>{u.delete(t),u.size||D(!1)}}const[t,n,r]=e,o=r?.equalityFn??Object.is,s=r?.isDerivedStore??!1,i={currentSlice:void 0,equalityFn:o,isDerivedWatcher:s,listener:n,selector:t};return u.add(i),i.currentSlice=t(M()),s&&(S+=1),r?.fireImmediately&&n(i.currentSlice,i.currentSlice),()=>{u.delete(i),s&&(S-=1),u.size||D(s)}},getInitialState:()=>{throw new Error("[createDerivedStore]: getInitialState() is not available on derived stores.")},setState:()=>{throw new Error("[createDerivedStore]: setState() is not available on derived stores.")}}}(e,t),Object.assign(function(e=p,t){return x(n.subscribe,n.getSnapshot,void 0,e,t)},n);var n}var _e=Symbol(),Be=Object.freeze({equalityFn:Object.is,isDerivedStore:!0}),Je=0;function He(){}function Qe(e){return e!==_e}var Ge,Xe=class{constructor({disableAutoRefetching:e,initialEnabled:t}){this.count=0,this.enabled=!1,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,this.enabled=t,e&&(this.fetchThrottleMs=Q.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}get(){return{enabled:this.enabled,lastSubscriptionTime:this.lastSubscriptionTime,subscriptionCount:this.count}}setEnabled(e){this.enabled=e}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.onSubscribe?.(this.enabled,e,t),this.count+=1,this.lastSubscriptionTime=Date.now(),e=>{const t=1===this.count;this.count=Math.max(this.count-1,0),t&&(this.onLastUnsubscribe?.(e),this.lastSubscriptionTime=null)}}};function Ye(e,t){const n=t?.baseDelay??Q.seconds(5),r=t?.maxDelay??Q.minutes(5);return Math.min(n*Math.pow(2,e),r)}var Ze={Error:"error",Idle:"idle",Loading:"loading",Success:"success"};function et(e,t){const n=Object.prototype.hasOwnProperty;function r(e,t){for(const n of e.keys())if(et(n,t))return n}let o,s,i;if(e===t)return!0;if(e&&t&&(o=e.constructor)===t.constructor){if(o===Date)return e.getTime()===t.getTime();if(o===RegExp)return e.toString()===t.toString();if(o===Array){if((s=e.length)===t.length)for(;s--&&et(e[s],t[s]););return-1===s}if(o===Set){if(e.size!==t.size)return!1;for(let n of e){if(i=n,i&&"object"==typeof i&&(i=r(t,i),!i))return!1;if(!t.has(i))return!1}return!0}if(o===Map){if(e.size!==t.size)return!1;for(let n of e){if(i=n[0],i&&"object"==typeof i&&(i=r(t,i),!i))return!1;if(!et(n[1],t.get(i)))return!1}return!0}if(o===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(o===DataView){if((s=e.byteLength)===t.byteLength)for(;s--&&e.getInt8(s)===t.getInt8(s););return-1===s}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){const n=e,r=t;if((s=n.byteLength)===r.byteLength)for(;s--&&n[s]===r[s];);return-1===s}if(!o||"object"==typeof e){s=0;for(const r in e){if(n.call(e,r)&&++s&&!n.call(t,r))return!1;if(!(r in t)||!et(e[r],t[r]))return!1}return Object.keys(t).length===s}}return e!=e&&t!=t}var tt=new WeakMap,nt=new WeakMap;function rt(e,t=ot,n=et){return function(e,t,n){let r=nt.get(e);r||(r=new Map,nt.set(e,r));let o=r.get(t);o||(o=new Map,r.set(t,o));const s=o.get(n);if(s)return s;const[i,c,a]=it(e,t,n),u=new Map,l=e=>{const t={get(t,n){if("value"===n){let t=c();const n=e.split(".");for(const e of n)e&&(t=t[e]);return t}const r="string"==typeof n?n:n.toString(),o=e?`${e}.${r}`:r,s=u.get(o);if(s)return s;const a=l(o);return tt.set(a,i),u.set(o,a),a},set(t,n,r){const o=e.split(".");return""===o[0]&&o.shift(),a(o,r),!0}};return new Proxy(h(),t)},f=l("");return i(()=>{}),tt.set(f,i),o.set(n,f),f}(e,t,n)}var ot=e=>e,st=(e,t,n)=>{if(!t.length)return n;const[r,...o]=t,s=e[r],i=st(s,o,n);if(et(s,i))return e;const c=Array.isArray(e)?e.slice():{...e};return c[r]=i,c},it=(e,t,n)=>{const r=new Set,o=ie(e);let s,i=t(o?e.getSnapshot():e.getState());return[c=>(r.size||(s=e.subscribe(t,e=>{i=e,r.forEach(e=>e())},{equalityFn:n,isDerivedStore:o})),r.add(c),()=>{r.delete(c),!r.size&&s&&(s(),s=void 0)}),()=>(r.size||(i=t(e.getState())),i),(n,r)=>{if(t!==ot)throw new Error("Cannot set a value with a selector");e.setState(e=>st(e,n,r),!0)}]};function ct(e){return tt.get(e)}var at={error:!0,lastFetchedAt:!0,queryCache:!0,queryKey:!0,status:!0,enabled:!1,fetch:!1,getCacheEntry:!1,getData:!1,getStatus:!1,isDataExpired:!1,isStale:!1,reset:!1},ut=Object.freeze({force:!0}),lt=Object.freeze({once:!0}),ft=Object.freeze({updateQueryKey:!0});function dt(e){return JSON.stringify(yt(e))}function yt(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,n)=>{const r=e[n];return t[n]=d(r)?yt(r):r,t},h())}function pt(e,t,n,r){return r?gt(r,n)?r:{...ht(e,t),...r}:ht(e,t)}function ht(e,t){const n=Object.assign(h(),t?.params);for(const t in e?.params){const r=e.params[t];r&&(n[t]=r.value)}return n}function gt(e,t){if(!e)return!1;for(const n of t)if(!(n in e))return!1;return!0}function bt(e){return"function"==typeof e}function mt(e){return!bt(e)}function St(e,t){return n=>{const r={...n},o=h();for(const e in r)f(r,e)&&e in at&&(at[e]&&(o[e]=r[e]),delete r[e]);return{...t?t(r):H(r),...vt(e,null,o)}}}function vt(e,t,n){if(!n.queryCache)return n;const r=Date.now(),o=t??(e&&n.queryKey||null),s=h();let i=!1;for(const e in n.queryCache){if(!f(n.queryCache,e))continue;const c=n.queryCache[e];c&&(r-(c.lastFetchedAt??c.errorInfo.lastFailedAt)<c.cacheTime||e===o)?!t&&c.errorInfo&&c.errorInfo.retryCount>0?(s[e]={...c,errorInfo:{...c.errorInfo,retryCount:0}},i=!0):s[e]=c:i=!0}return i?{...n,queryCache:s}:n}function wt(){return Object.create(null)}function Ot(e,t,n){return new a(`[createQueryStore: ${e}]: ${t} failed`,n)}function qt(e){return function(t,n){return n?e().setState(t,n):e().setState(t)}}var jt=Symbol(),Ft=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1}),It=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function At(e,t,n=It){if(t.current.isActive){if(!n?.forceResubscribe)return;t.current.unsubscribe()}t.current.options.debugMode&&console.log("[π‘ useListen π‘] Attaching listener"),t.current.isActive=!0,t.current.resubscribe=(n=It)=>At(e,t,n);const r=e.subscribe(e=>t.current.selector(e),(e,n)=>t.current.react(e,n,()=>{r(),t.current.isActive=!1}),n.fireImmediately?{...t.current.options,fireImmediately:!0}:t.current.options);t.current.unsubscribe=()=>{t.current.isActive&&(r(),t.current.isActive=!1)}}function Ct(e){return"function"==typeof e?{equalityFn:e}:e??Ft}var kt=Symbol();function Tt(e,t){return function(...n){const r=e.getState()[t];if("function"==typeof r)return r(...n);throw new Error(`[createVirtualStoreAction]: Method ${String(t)} is not a function`)}}function Et(e,t){return"function"==typeof e[t]}exports.QueryStatuses=Ze,exports.StoresError=a,exports.applyStateUpdate=oe,exports.configureStores=function(e){var t;o&&function(){if(C)throw new Error("[stores]: configureStores() called after first store creation. Call it earlier before creating any stores.")}(),e.logger&&(t=e.logger,c=t),O??(O=function(e){return e?.queryStoreDefaults?{queryStoreDefaults:e.queryStoreDefaults}:void 0}(e)),q??(q=E(e))},exports.createBaseStore=be,exports.createDerivedStore=Ue,exports.createQueryStore=function(e,t,n){T();const r="function"==typeof t?t:wt,i="object"==typeof t?t:n,l=i&&"storageKey"in i?i:void 0,d=Ge??(Ge=function(){const e={abortInterruptedFetches:!0,cacheTime:Q.days(7),debugMode:!1,disableAutoRefetching:!1,keepPreviousData:!1,maxRetries:5,minStaleTime:!1,paramChangeThrottle:!1,retryDelay:Ye,staleTime:Q.minutes(2),suppressStaleTimeWarning:!1},t=function(){if(O)return O}()?.queryStoreDefaults;return t?{...e,...t}:e}()),y=d.minStaleTime,{fetcher:p,onError:g,onFetched:b,setData:m,transform:S,abortInterruptedFetches:v=d.abortInterruptedFetches,cacheTime:w=d.cacheTime,debugMode:q=d.debugMode,disableAutoRefetching:j=d.disableAutoRefetching,disableCache:F=!1,enabled:I=!0,keepPreviousData:A=d.keepPreviousData,maxRetries:C=d.maxRetries,paramChangeThrottle:k=d.paramChangeThrottle,params:E,retryDelay:D=d.retryDelay,staleTime:z=d.staleTime,suppressStaleTimeWarning:x=d.suppressStaleTimeWarning}=e;let M="function"==typeof z?d.staleTime:z;o&&!1!==y&&!j&&!x&&M<y&&console.warn(`[createQueryStore${l?.storageKey?`: ${l.storageKey}`:""}] β Stale times under ${y/1e3} seconds are not recommended. Provided staleTime: ${M/1e3} seconds`);const K=new Error("[createQueryStore: AbortError] Fetch interrupted"),$="function"==typeof w,P=o&&q,R=e.params?Object.keys(e.params):[];let L=null,N=null,V=null,U=[],_=!1,B=!1,J=null,H=null,G=null,X=null,Y=null;const Z={enabled:"function"!=typeof I&&I,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:Ze.Idle},ee=new Xe({disableAutoRefetching:j,initialEnabled:Z.enabled});function te(){J&&(H=null,J.abort(),J=null)}function ne(t,n,o){const s=o.setState;function i(e){const t="function"==typeof e;if(t||void 0!==e.enabled){let n;const r=s(r=>{const o=t?e(r):e,s=void 0!==o.enabled?o.enabled:r.enabled;return s!==r.enabled&&(n=()=>function(e,t){e!==t&&Y!==t&&(Y=t,ee.setEnabled(t),t?queueMicrotask(()=>d.fetch(void 0,ft)):(G||v)&&(v&&te(),G&&(clearTimeout(G),G=null)))}(r.enabled,s)),o});return n?.(),r}return s(e)}function f(e,t){if(j||t?.skipStoreUpdates)return;if(M<=0||M===1/0)return;G&&(clearTimeout(G),G=null);const r=dt(e),o=n(),s=(F?X===r&&o.lastFetchedAt:o.queryCache[r]?.lastFetchedAt)||null,i=s?M-(Date.now()-s):M;G=setTimeout(()=>{const t=ee.get();t.enabled&&t.subscriptionCount>0&&d.fetch(e,ut,!0)},i)}o.setState=i,ee.init({onSubscribe:(r,o,s)=>{if(N||L||!E&&"function"!=typeof e.enabled&&"function"!=typeof e.staleTime){if(r)if(o){const e=ht(L,N),r=dt(e),o=n();o.queryKey!==r&&t({queryKey:r}),o.isStale()?d.fetch(e,void 0,!0):f(e,void 0)}else j&&!s&&d.fetch(void 0,void 0,!0)}else _=!0},onLastUnsubscribe:e=>{G&&(clearTimeout(G),G=null),v&&!e&&te()}});const d={...r(i,n,o),...Z,async fetch(e,r,o=!1){const s=ee.get();if(!r?.force&&!r?.skipStoreUpdates&&!s.enabled)return null;const y=n(),h=y.error,O=y.queryKey,q=y.status===Ze.Loading,j=pt(L,N,R,e),I=dt(j);if(q&&H?.promise&&H.key===I)return P&&console.log("[π Using Active Fetch π] for params:",JSON.stringify(j)),H.promise;const k=r?.staleTime??M,T=!!r?.skipStoreUpdates,E="boolean"==typeof r?.updateQueryKey?r.updateQueryKey:!!o&&A,z=(o||O===I||E)&&!T;if(v&&z&&te(),!r?.force){const e=y.lastFetchedAt,n=y.queryCache[I],o=n?.lastFetchedAt,i=n?.errorInfo,c=i&&i.retryCount>=C,a=(F?X===I&&e:o)||null;if(a&&!(Date.now()-a>=k)&&(!i||c||T))return z&&!G&&s.subscriptionCount>0&&0!==M&&M!==1/0&&f(j,r),E&&t(e=>e.queryKey!==I?{queryKey:I}:e),P&&console.log("[πΎ Returning Cached Data πΎ] for params:",JSON.stringify(j)),n?.data??null}z&&(G&&(clearTimeout(G),G=null),!h&&q||t({error:null,status:Ze.Loading}),H={key:I});const x=r?.cacheTime??($?w(j):w);async function V(){const s=l?.storageKey||I;try{P&&(o||!e||gt(e,R)?console.log("[π Fetching π] for params:",JSON.stringify(j)):console.log("[π Fetching with Partial Params π]\n","- Provided params:",`${JSON.stringify(e)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(j).filter(t=>!(t in e)).map(e=>[e,j[e]])))}`));const n=await(v&&z?async function(e){const t=new AbortController;J=t;try{return await new Promise((n,r)=>{t.signal.addEventListener("abort",()=>r(K),lt),Promise.resolve(p(e,t)).then(n,r)})}finally{J===t&&(J=null)}}(j):p(j,null)),a=Date.now();let u;P&&console.log("[β
Fetch Successful β
] for params:",JSON.stringify(j));try{u=function(e,t,n){return n?n(e,t):e}(n,j,S)}catch(e){throw Ot(s,"transform",e)}if(T)return P&&console.log("[π₯· Successful Parallel Fetch π₯·] for params:",JSON.stringify(j)),"withCache"===r.skipStoreUpdates&&t(e=>{if(!m)return F?e:{queryCache:{...e.queryCache,[I]:{cacheTime:x,data:u,errorInfo:null,lastFetchedAt:a}}};let t=e;const n=t.queryCache[I];try{m({data:u,params:j,queryKey:I,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Ot(s,"setData",e)}return!F&&Object.is(n,t.queryCache[I])&&(t={...t,queryCache:{...t.queryCache,[I]:{cacheTime:x,data:null,errorInfo:null,lastFetchedAt:a}}}),t}),u;if((m?i:t)(e=>{let t={...e,error:null,lastFetchedAt:a,queryKey:E?I:e.queryKey,status:Ze.Success};if(m||F){if(m){P&&console.log("[πΎ Setting Data πΎ] for params:",JSON.stringify(j));const e=t.queryCache[I];try{m({data:u,params:j,queryKey:I,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Ot(s,"setData",e)}!F&&Object.is(e,t.queryCache[I])&&(t.queryCache={...t.queryCache,[I]:{cacheTime:x,data:null,errorInfo:null,lastFetchedAt:a}})}}else P&&console.log("[πΎ Setting Cache πΎ] for params:",JSON.stringify(j),"| Has previous data?:",!!t.queryCache[I]?.data),t.queryCache={...t.queryCache,[I]:{cacheTime:x,data:u,errorInfo:null,lastFetchedAt:a}};return F||w===1/0?t:vt(A,I,t)}),z&&(X=I,f(j,r)),b)try{b({data:u,fetch:d.fetch,params:j,set:i})}catch(e){c.error(Ot(s,"onFetched callback",e))}return u??null}catch(i){if(i===K)return P&&console.log("[β Fetch Aborted β] for params:",JSON.stringify(j)),null;const l=!o&&!0===r?.throwOnError,f=u(i);if(f instanceof a&&c.error(f),!z){if(l)throw f;return null}const y=F?void 0:n().queryCache[I],p=y?.errorInfo?.retryCount??0,h=p+1;try{g?.(f,p)}catch(e){c.error(Ot(s,"onError callback",e))}if(p<C){if(ee.get().subscriptionCount>0){const t="function"==typeof D?D(h,f):D;t!==1/0&&(G&&clearTimeout(G),G=setTimeout(()=>{const t=ee.get();t.enabled&&t.subscriptionCount>0&&d.fetch(e,ut,!0)},t))}t(e=>({error:f,queryCache:{...e.queryCache,[I]:{cacheTime:y?.cacheTime??x,data:y?.data??null,lastFetchedAt:y?.lastFetchedAt??null,errorInfo:{error:f,lastFailedAt:Date.now(),retryCount:h}}},queryKey:E?I:e.queryKey,status:Ze.Error}))}else t(e=>({error:f,queryCache:{...e.queryCache,[I]:{cacheTime:y?.cacheTime??x,data:y?.data??null,lastFetchedAt:y?.lastFetchedAt??null,errorInfo:{error:f,lastFailedAt:Date.now(),retryCount:C}}},queryKey:E?I:e.queryKey,status:Ze.Error}));if(l)throw f;return null}finally{z&&(H=null)}}return z?(H={key:I,promise:V()}).promise:V()},getCacheEntry(e){if(F)return null;const t=n(),r=e?"string"==typeof e?e:dt(pt(L,N,R,e)):t.queryKey;return t.queryCache[r]??null},getData(e){if(F)return null;const t=n().getCacheEntry(e);return t&&null!==t.data?A?t.data:t.lastFetchedAt&&Date.now()-t.lastFetchedAt>=t.cacheTime?null:t.data:null},getStatus:function(e){const t=n(),r=t.status;switch(e){case"isIdle":return r===Ze.Idle;case"isLoading":return r===Ze.Loading;case"isError":case"isInitialLoad":case"isSuccess":case void 0:{const n=t.queryKey,o=t.queryCache[n],s=F?r===Ze.Error:"number"==typeof o?.errorInfo?.lastFailedAt;if("isError"===e)return s;const i=null!==((F?X===n&&t.lastFetchedAt:o?.lastFetchedAt)||null),c=!i&&!s&&t.enabled;if("isInitialLoad"===e)return c;const a=i&&!s;return"isSuccess"===e?a:{isError:s,isIdle:r===Ze.Idle,isLoading:r===Ze.Loading,isInitialLoad:c,isSuccess:a}}}},isDataExpired(e){const t=n(),r=t.queryCache[t.queryKey],o=t.queryKey,s=t.lastFetchedAt,i=(F?X===o&&s:r?.lastFetchedAt)||null;if(!i)return!0;const c=e??r?.cacheTime;return void 0===c||Date.now()-i>=c},isStale(e){const t=n(),r=t.queryKey,o=(F?X===r&&t.lastFetchedAt:t.queryCache[r]?.lastFetchedAt)||null;if(!o)return!0;const s=e??M;return Date.now()-o>=s},reset(e=!1){for(const e of U)e();U=[],L=null,N=null,V=null,te(),G&&(clearTimeout(G),G=null),H=null,X=null,e&&t(Z)}},y=o.subscribe;return o.subscribe=(...e)=>{const t=B?()=>{}:ee.subscribe(),n=1===e.length?y(e[0]):y(e[0],e[1],e[2]);return e=>{t(e),n()}},d}const oe=l?.storageKey?be(ne,(se=l,void 0===(ie={partialize:St(A,l.partialize)})?Object.assign(h(),se):Object.assign(h(),se,ie))):i&&!("storageKey"in i)?be(ne,i):be(ne);var se,ie;const ce=oe.getState(),ae=ce.error,ue=ce.enabled,le=ce.queryKey,fe=ce.fetch;let de;if(le&&!ae&&(X=le),B=!0,E||"function"==typeof e.enabled){const{directValues:e,enabledAttachVal:t,enabledDirectValue:n,attachVals:r}=function(e,t,n){const r=h(),o=h(),s=h();for(const e in t){if(!f(t,e))continue;const i=t[e];if(bt(i)){const t=i(rt,n);r[e]=t,s[e]=t.value}else mt(i)&&(o[e]=i,s[e]=i)}let i,c=null,a=null;if(bt(e)){const t=e(rt,n);i=t.value,c=t}else i=e,a=e;return{attachVals:r,directValues:o,enabledAttachVal:c,enabledDirectValue:a,resolvedEnabled:i,resolvedParams:s}}(I,E,oe);L={enabled:t,params:r},N={enabled:n,params:e}}"function"==typeof e.staleTime&&(V=e.staleTime(rt,oe),M=V.value);const ye=Object.freeze({updateQueryKey:A}),pe=function(){let e,t=!1;return function(...n){e=n,t||(t=!0,queueMicrotask(()=>{t=!1,(e=>{fe(e??ht(L,N),ye)})(...e)}))}}();function he(){let e;if(!A){e=ht(L,N);const t=dt(e);oe.setState({queryKey:t})}pe(e)}const ge=s||!k?he:W(he,"number"==typeof k?k:k.delay,"number"==typeof k?{leading:!1,maxWait:k,trailing:!0}:k);for(const e in L?.params){const t=L.params[e];if(!t)continue;const n=ct(t);if(P&&console.log("[π Param Subscription π] Subscribed to param:",e),n){let r=t.value;const o=n(()=>{const n=t.value;et(r,n)||(P&&console.log("[π Param Change π] -",e,"- [Old]:",`${r?.toString()},`,"[New]:",n?.toString()),r=n,ge())});U.push(o)}}if(V){const e=ct(V);if(e){const t=V;let n=t.value;P&&console.log("[π StaleTime Subscription π] Initial value:",n);const r=e(()=>{const e=t.value;e!==n&&(P&&console.log("[π StaleTime Change π] - [Old]:",`${n},`,"[New]:",e),n=e,M=e,fe())});U.push(r)}}if(L?.enabled){const e=L.enabled,t=ct(e);if(t){let n=e.value;ue!==n&&((de??(de={})).enabled=n),n&&ee.setEnabled(n),P&&console.log("[π Enabled Subscription π] Initial value:",n);const r=t(()=>{const t=e.value;t!==n&&(P&&console.log("[π Enabled Change π] - [Old]:",`${n},`,"[New]:",t),n=t,oe.setState({enabled:t}))});U.push(r)}}else ue!==Z.enabled&&((de??(de={})).enabled=Z.enabled);const me=dt(ht(L,N));return me!==le&&((de??(de={})).queryKey=me),de&&oe.setState(de),B=!1,_&&queueMicrotask(ge),Se=oe,ve=re.QueryStore,Object.assign(Se,{[ve]:!0});var Se,ve},exports.createStoreActions=function(e,t){const n=function(e){const t=e.getState(),n=h(),r=n;if(o&&("object"!=typeof t||null===t))throw new Error("[createStoreActions]: State is not an object");if(ue(e))for(const n in t)Et(t,n)&&(r[n]=Tt(e,n));else for(const e in t)Et(t,e)&&(r[e]=t[e]);return n}(e);return t?Object.assign(n,t):n},exports.createVirtualStore=function(e,t,n){const r="function"==typeof t,o=r?t:void 0,s=r?n:t,i=new Set,c=Ue(e,{debugMode:s?.debugMode??!1,equalityFn:function(e,t){const n=Object.is(e,t);return n||(function(e,t){for(const n of i){n.unsubscribe();const r=n.args;if(1===r.length){const o=r[0],s=e.getState(),i=t.getState(),c=t.subscribe(o);n.unsubscribe=c,Object.is(i,s)||o(i,s);continue}const o=r[0],s=r[1];let i=r[2];i?.fireImmediately&&(i={...i,fireImmediately:!1});const c=o(e.getState()),a=o(t.getState()),u=t.subscribe(o,s,i);n.unsubscribe=u,(i?.equalityFn??Object.is)(c,a)||s(a,c)}}(e,t),se(e)),n},keepAlive:!0,lockDependencies:s?.lockDependencies??!0});return Object.assign(function(e,t){const n=c();return e?n(e,t):n()},{[re.VirtualStore]:!0,destroy:c.destroy,getInitialState:()=>c.getState().getInitialState(),getState:()=>c.getState().getState(),persist:(a=c.getState,{clearStorage:()=>a().persist?.clearStorage(),getOptions:()=>a().persist?.getOptions()??{},hasHydrated:()=>a().persist?.hasHydrated()??!0,hydrationPromise:()=>a().persist?.hydrationPromise?.()??Promise.resolve(),onFinishHydration:e=>a().persist?.onFinishHydration(e)??g,onHydrate:e=>a().persist?.onHydrate(e)??g,rehydrate:()=>a().persist?.rehydrate(),setOptions:e=>a().persist?.setOptions(e)}),setState:qt(c.getState),subscribe:function(...e){const t={args:e,unsubscribe:1===e.length?c.getState().subscribe(e[0]):c.getState().subscribe(e[0],e[1],e[2])};return i.add(t),()=>{t.unsubscribe(),i.delete(t)}}},o?.(c.getState));var a},exports.deepEqual=function e(t,n){if("object"!=typeof t||null==t||"object"!=typeof n||null==n)return t===n;if(Object.is(t,n))return!0;const r=Object.keys(t);if(r.length!==Object.keys(n).length)return!1;for(const o of r)if(!(o in n)||!e(t[o],n[o]))return!1;return!0},exports.defaultRetryDelay=Ye,exports.destroyStore=se,exports.destroyStores=function(e,t){for(const n of Array.isArray(e)?e:Object.values(e))n&&!t?.skipDestroy?.(n)&&se(n,t)},exports.getQueryKey=dt,exports.getStoreName=function(e){return ae(e)?e.persist.getOptions().name??e.name:e.name},exports.hasGetSnapshot=ie,exports.identity=p,exports.isDerivedStore=function(e){return"flushUpdates"in e},exports.isPersistedStore=ae,exports.isQueryStore=ce,exports.isVirtualStore=ue,exports.nullObject=h,exports.parseQueryKey=function(e){return JSON.parse(e)},exports.replacer=B,exports.reviver=J,exports.shallowEqual=function(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.is(e[r],t[r]))return!1;return!0},exports.time=Q,exports.useListen=function(e,t,r,o=Ft){const s=function(){const e=n.useRef(jt);return e.current===jt&&(e.current=function(e,t,n){return{selector:e,react:t,isActive:!1,options:Ct(n),resubscribe:()=>{},unsubscribe:()=>{}}}(t,r,o)),e}(),i=function(e){return"function"==typeof e?Ft.enabled:e?.enabled??Ft.enabled}(o);return s.current.react=r,s.current.selector=t,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??Ft)}(s,o),n.useLayoutEffect(()=>{if(i)return At(e,s),()=>function(e){e.current.options.debugMode&&console.log("[ποΈ useListen ποΈ] Detaching listener"),e.current.resubscribe=()=>{},e.current.unsubscribe(),e.current.unsubscribe=()=>{},e.current.isActive=!1}(s)},[i,e]),s},exports.useStableValue=function(e){const t=n.useRef(kt);return t.current===kt&&(t.current=e()),t.current};
|
package/dist/web/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_TEST as e,IS_BROWSER as t,IS_IOS as n,markStoreCreated as r,getStoresConfig as o,StoresError as i,IS_DEV as s,hasOwn as c,logger as a,ensureError as u,isPromiseLike as l,unstable_batchedUpdates as f,reviver as d,replacer as y}from"./chunk-B3GRBY25.mjs";export{configureStores,replacer,reviver}from"./chunk-B3GRBY25.mjs";import{subscribeWithSelector as p,persist as h}from"zustand/middleware";import{createWithEqualityFn as g}from"zustand/traditional";import{useSyncExternalStoreWithSelector as b}from"use-sync-external-store/shim/with-selector";import{useLayoutEffect as m,useRef as S}from"react";function v(){let e,t,n=!1;return{complete:function(){!n&&e&&(n=!0,e(),e=void 0,t=void 0)},isHydrated:function(){return n},fail:function(r){!n&&t&&(n=!0,t(r),t=void 0,e=void 0)},promise:new Promise((n,r)=>{e=n,t=r})}}var w=Math.max,O=Math.min;function j(e,t=0,n={}){let r,o,i,s,c,a,u=0,l=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){const n=r,i=o;return r=o=void 0,u=t,s=n?e.apply(i,n):e.apply(i),s}function p(e){const n=e-(a??0);return void 0===a||n>=t||n<0||f&&void 0!==i&&e-u>=i}function h(){const e=q();if(p(e))return g(e);c=setTimeout(h,function(e){const n=t-(e-(a??0));return f&&void 0!==i?O(n,i-(e-u)):n}(e))}function g(e){return c=void 0,d&&r?y(e):(r=o=void 0,s)}function b(...e){const n=q(),i=p(n);if(r=e,o=this,a=n,i){if(void 0===c)return function(e){return u=e,c=setTimeout(h,t),l?y(e):s}(a);if(f)return clearTimeout(c),c=setTimeout(h,t),y(a)}return void 0===c&&(c=setTimeout(h,t)),s}return t=F(t)||0,function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}(n)&&(l=!!n.leading,f="maxWait"in n,i=f?w(F(n.maxWait)||0,t):void 0,d="trailing"in n?!!n.trailing:d),b.cancel=function(){void 0!==c&&clearTimeout(c),u=0,r=a=o=c=void 0},b.flush=function(){return void 0===c?s:g(q())},b}function q(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function F(e){if("number"==typeof e)return e;if("symbol"==typeof e||void 0===e)return NaN;if("object"==typeof e&&null!==e){const t="function"==typeof e.valueOf?e.valueOf():e;e="object"==typeof t?t+"":t}return"string"!=typeof e?0===e?e:+e:(e=e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),/^0b[01]+$/i.test(e)?parseInt(e.slice(2),2):/^0o[0-7]+$/i.test(e)?parseInt(e.slice(2),8):/^[-+]0x[0-9a-f]+$/i.test(e)?NaN:+e)}function C(e){if(null!==e&&"object"==typeof e){const t={};for(const[n,r]of Object.entries(e))"function"!=typeof r&&(t[n]=r);return t}return e}var A={ms:e=>e,seconds:e=>1e3*e,minutes:e=>A.seconds(60*e),hours:e=>A.minutes(60*e),days:e=>A.hours(24*e),weeks:e=>A.days(7*e),infinity:1/0,zero:0},I=e?0:t?A.ms(200):n?A.seconds(3):A.seconds(5);function k(e){return t=>{if("string"!=typeof t)throw new i("[createBaseStore]: Received non-string serialized state without a custom deserializer. Provide a deserializer on the store or storage adapter.");return function(e,t){try{return JSON.parse(e,t?d:void 0)}catch(e){throw a.error(new i("[createBaseStore]: Failed to deserialize persisted Rainbow store data"),{error:e}),e}}(t,e)}}function T(e){return t=>function(e,t){try{return JSON.stringify(e,t?y:void 0)}catch(e){throw a.error(new i("[createBaseStore]: Failed to serialize Rainbow store data"),{error:e}),e}}(t,e)}var z=Object.freeze({shouldClear:!1});function M(e,t,n){if(!t||!e)return z;const r=e.getFieldTimestampSnapshot();return function(e,t){const n=e.getSessionId(),r=e.getTimestamp();void 0!==n&&void 0!==r&&(t.syncMetadata={origin:n,timestamp:r})}(e,n),n.syncMetadata?r&&Object.keys(r).length>0?(n.syncMetadata.fields=r,{fieldSnapshot:r,shouldClear:!0}):(delete n.syncMetadata.fields,{fieldSnapshot:r,shouldClear:!1}):{fieldSnapshot:r,shouldClear:!1}}function D(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function K(e){return!!e&&!!e.getIsApplyingRemote()}function $(e,...t){return!0===t[1]?J(t[0])?t[0](e):t[0]:{...e,...J(t[0])?t[0](e):t[0]}}function E(e,t){x(e)?e.getState().reset(t?.clearQueryCache):function(e){return"destroy"in e}(e)&&e.destroy()}function P(e,t){for(const n of Array.isArray(e)?e:Object.values(e))n&&!t?.skipDestroy?.(n)&&E(n,t)}function L(e){return W(e)?e.persist.getOptions().name??e.name:e.name}function R(e){return"getSnapshot"in e}function x(e){return"_queryStore"in e}function N(e){return"flushUpdates"in e}function W(e){return"persist"in e}function B(e){return"_virtualStore"in e}function J(e){return"function"==typeof e}var[U,Q]=[0,1];function V(e,t,n){if(!e)return!0;const r=e[U],o=e[Q];return!(t<r)&&(t>r||n>o)}function H(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function _(e,t){if(!s)return!0;if(null===e||null===t)return e===t;const n=typeof e;return n===typeof t&&("object"!==n||Object.prototype.toString.call(e)===Object.prototype.toString.call(t))}function G(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function Y(e,t){r();const n=void 0!==t&&"string"==typeof t.storageKey,s=n?t.storageKey:void 0,c=t?.sync?function(e,t){if(!e)return null;if(!0===e){if(!t)throw new i("[createBaseStore]: sync: true requires a storageKey to inherit the key from");return{key:t}}if("string"==typeof e)return{key:e};const n=e,r=n.key??t;if(!r)throw new i("[createBaseStore]: sync requires either a key in the config or a storageKey to inherit from");return{...n,key:r}}(t.sync,s):void 0,f=n?t.storage??o().storage:void 0,d=c?function(e,t,n){const r=t.engine??o().syncEngine,s=function(e){let t,n,r,o=!1;return{isAsync:e,clearFieldTimestamps:function(e){if(e&&r){for(const t of Object.entries(e)){const e=t[0],n=t[1];r[e]===n&&delete r[e]}Object.keys(r).length||(r=void 0)}},getFieldTimestampSnapshot:function(){if(r)return{...r}},getIsApplyingRemote:()=>o,getSessionId:()=>t,getTimestamp:()=>n,mergeFieldTimestamps:function(e){if(r)for(const t of Object.entries(e)){const e=t[0],n=t[1],o=r[e];(void 0===o||n>o)&&(r[e]=n)}else r={...e}},onHydrationComplete:void 0,onHydrationFlushEnd:void 0,setIsApplyingRemote:e=>o=e,setSessionId:e=>t=e,setTimestamp:e=>n=e,setWithoutPersist:void 0}}(n);return{stateCreator:(o,c,u)=>{const f=new Map,d=[],y=[];let p=null,h=!1,g=!1,b=0,m=null,S=[],v=Promise.resolve(),w=!n;const O=(e,t)=>{if(s?.setSessionId&&s?.setTimestamp&&r.sessionId&&(s.setSessionId(r.sessionId),s.setTimestamp(e),s.mergeFieldTimestamps&&t.length>0)){const n=Object.create(null);for(const r of t)n[String(r)]=e;s.mergeFieldTimestamps(n)}},j=function(e,t){if(h||!m)return t?o(e,t):o(e);const n=(()=>{const e=Date.now(),t=e>b?e:b+1;return b=t,t})();let i=[],s=Object.create(null);const c=r=>{const o=$(r,e,t);for(const e of S)Object.is(o[e],r[e])||(i.push(e),s[e]=o[e]);return i.length&&O(n,i),o},a=t?o(c,!0):o(c),u=()=>{i.length&&(e=>{const t=r.sessionId;for(const n of e.keys)f.set(n,[e.timestamp,t]);p&&g?p.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values}):y.push(e)})({keys:i,replace:t??!1,values:s,timestamp:n})};return l(a)?a.finally(u):(u(),a)},q=u.setState;u.setState=j;const F=e(j,c,u);if(S=t.fields??function(e){const t=[];for(const n of Object.entries(e)){if("function"==typeof n[1])continue;const e=n[0];t.push(e)}return t}(F),!S.length)return F;m=new Set(S);const C=async e=>{b=Math.max(b,e.timestamp);const n=Object.create(null),r=c(),o=e.timestamp;let u;if(e.replace)for(const t of S)H(t,e.values)||V(f.get(t),o,e.sessionId)&&(u??(u=[])).push(t);for(const s of S){if(!H(s,e.values))continue;if(!m?.has(s))continue;if(!V(f.get(s),o,e.sessionId))continue;const c=t.merge?.[s];if(c){const t=e.values[s],u=r[s];if(void 0!==t){const l=c(t,u,r,e.values),d=void 0!==u?u:t;if(!_(l,d))return void a.error(new i(`[sync] Merge function for field "${String(s)}" returned ${G(l)} but expected ${G(d)}`));n[s]=l,f.set(s,[o,e.sessionId])}}else n[s]=e.values[s],f.set(s,[o,e.sessionId])}if(Object.keys(n).length>0||u?.length){h=!0,s&&s.setIsApplyingRemote(!0);try{if(e.replace){const e={...r};let t=!1;if(u?.length){t=!0;for(const t of u)delete e[t],f.delete(t)}for(const r in n){if(!Object.prototype.hasOwnProperty.call(n,r))continue;const o=n[r];void 0!==o&&(Object.is(e[r],o)||(t=!0),e[r]=o)}if(!t)return;await(s.setWithoutPersist??q)(e,!0)}else await(s.setWithoutPersist??q)(n)}finally{h=!1,s&&s.setIsApplyingRemote(!1)}}},A=e=>{n?v=v.then(()=>C(e)):C(e)};p=r.register({apply:e=>{w?A(e):d.push(e)},delta:t.delta,fields:S,getState:c,key:t.key});const I=()=>{g=!0,(()=>{if(p&&y.length){for(const e of y){const t=r.sessionId;for(const n of e.keys)f.set(n,[e.timestamp,t]);O(e.timestamp,e.keys),p.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values})}y.length=0}})()},k=()=>{w=!0,(()=>{if(!d.length)return;const e=d.slice();d.length=0;for(const t of e)A(t)})()};return n&&s?(s.onHydrationComplete=I,s.onHydrationFlushEnd=k):p.onHydrated?(p.onHydrated(I),k()):(I(),k()),F},syncContext:s}}(e,c,f?.async??!1):void 0,y=d?.stateCreator??e;if(!n)return g()(p(y),Object.is);const b=f?.async?function(e){let t,n,r,o=!1;return{hydrationPromise:()=>o?t?.promise??n??(n=Promise.resolve()):(t||(t=v()),t.promise),stateCreator:(n,i,s)=>{let c;return r=()=>{if(c?.length){for(const e of c)e[1]?s.setState(e[0],e[1]):s.setState(e[0]);c=void 0}},e((...e)=>o?!0===e[1]?n(e[0],e[1]):n(e[0]):(t||(t=v()),c||(c=[]),c.push(e),t.promise),i,s)},wrapOnRehydrateStorage:(e,n)=>i=>{const s=e?.(i);return(e,i)=>{o=!0,n?.onHydrationComplete?.(),r&&r(),n?.onHydrationFlushEnd?.(),i?t?.fail(u(i)):t?.complete(),s?.(e,i)}}}}(y):null,m=function(e,t,n){const r=t??e.storage??o().storage,s=(e.sync?void 0:e.persistThrottleMs??I)||void 0,c=e.version??0,u=r.async?function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),s="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),c=t.partialize??C,u=t.deserializer??e.deserializer??k(o),l=t.serializer??e.serializer??T(o);async function f(t,n){try{if(K(r))return;n.state,n.state=c(n.state);const o=M(r,s,n),u=l(n);try{await e.set(t,u),D(r,o)}catch(e){a.error(new i("[createBaseStore]: Failed to persist store data"),{error:e})}}catch(e){a.error(new i("[createBaseStore]: Failed to serialize persisted store data"),{error:e})}}const d=void 0!==n?j(f,n,{leading:!1,maxWait:n,trailing:!0}):function(e){let t,n=null;return function(...r){return t=r,n||(n=new Promise(r=>{queueMicrotask(async()=>{try{await e(...t)}finally{n=null,r()}})})),n}}(f);return{getItem:async t=>{const n=await e.get(t);return void 0===n?null:u(n)},setItem:async(e,t)=>{if(!r?.getIsApplyingRemote())return await d(e,t)},removeItem:async t=>{try{await e.delete(t)}catch(e){a.error(new i("[createBaseStore]: Failed to delete persisted store data"),{error:e})}}}}(r,e,s,n):function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),s="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),c=t.partialize??C,u=t.deserializer??e.deserializer??k(o),l=t.serializer??e.serializer??T(o);function f(t,n){try{if(K(r))return;n.state,n.state=c(n.state);const o=M(r,s,n),u=l(n);try{e.set(t,u),D(r,o)}catch(e){a.error(new i("[createBaseStore]: Failed to persist store data"),{error:e})}}catch(e){a.error(new i("[createBaseStore]: Failed to persist store data"),{error:e})}}const d=void 0!==n?j(f,n,{leading:!1,maxWait:n,trailing:!0}):f;return{getItem:t=>{const n=e.get(t);return void 0===n?null:u(n)},setItem:(e,t)=>{r?.getIsApplyingRemote()||d(e,t)},removeItem:t=>{try{e.delete(t)}catch(e){a.error(new i("[createBaseStore]: Failed to delete persisted store data"),{error:e})}}}}(r,e,s,n);return{persistStorage:u,version:c}}(t,f,d?.syncContext),S=b?b.wrapOnRehydrateStorage(t.onRehydrateStorage,d?.syncContext):t.onRehydrateStorage,w=b?(e,t,n)=>(d&&(d.syncContext.setWithoutPersist=n.setState),b.stateCreator(e,t,n)):y,O=g()(p(h(w,function(e,t,n){const r={name:e.storageKey,onRehydrateStorage:n,storage:t.persistStorage,version:t.version};return void 0!==e.merge&&(r.merge=e.merge),void 0!==e.migrate&&(r.migrate=e.migrate),r}(t,m,S))),Object.is);return b?Object.assign(O,{persist:Object.assign(O.persist,{hydrationPromise:b.hydrationPromise})}):O}function X(e,t,n="s"){return 1===t?e:`${e}${n}`}function Z(e,t,n){const r=t.get(e);if(!r){const r=function(e,t,n,r=[]){return e&&"object"==typeof e?ee(e,r,t,n,new WeakSet,new WeakMap):(n(t,r,!0),e)}(R(e)?e.getSnapshot():e.getState(),e,n);return t.set(e,r),r}return r}function ee(e,t,n,r,o,i){return new Proxy(e,{get(s,c,a){if(o.has(s))return Reflect.get(s,c,a);if("__proto__"===c||"symbol"==typeof c)return c===Symbol.iterator&&(r(n,t,!0),o.add(s)),Reflect.get(s,c,a);const u=Reflect.get(s,c,s),l=String(c),f=t.concat(l);if("function"==typeof u)return Object.prototype.hasOwnProperty.call(s,c)?function(...e){return r(n,f,!0,{method:l,args:e.length?e:void 0}),Reflect.apply(u,s,e)}:(r(n,t,!0),u.bind(e));const d=!!u&&"object"==typeof u;return r(n,f,!d),d?(i.has(u)||i.set(u,ee(u,f,n,r,o,i)),i.get(u)):u},getOwnPropertyDescriptor:(e,i)=>(r(n,t,!0),o.add(e),Reflect.getOwnPropertyDescriptor(e,i)),has:(e,o)=>(r(n,t,!0),Reflect.has(e,o)),ownKeys:e=>(r(n,t,!0),o.add(e),Reflect.ownKeys(e))})}function te(e){return t=>re(t,e)}function ne(e,t){const n=e.slice(0,-1);return e=>{const r=re(e,n),o=r?.[t.method];return"function"==typeof o?o.apply(r,t.args):void 0}}function re(e,t){let n=e;for(const e of t){if(!n||"object"!=typeof n)return n;n=n[e]}return n}function oe(){const e=new Map;return{buildProxySubscriptions(t,n){const r=new Set;for(const[t,n]of e)ce(n,t,[],0,r);!function(e,t,n){for(const n of e)t(n.store,n.invocation?ne(n.path,n.invocation):te(n.path));n&&function(e){const t=e.size;console.log(`[π‘ ${t} ${X("Proxy Subscription",t)} π‘]:`,JSON.stringify(Array.from(e).map(e=>{const t=L(e.store),n=e.path.join(".");if(!e.invocation)return n?`$(${t}).${n}`:`$(${t})`;const r=e.invocation.args?.length??0;return`$(${t}).${n}${r?`(${r}_${X("arg",r)})`:"()"}`}),null,2))}(e)}(r,t,n)},trackPath(t,n,r,o){let i=e.get(t);i||(i=ie(),e.set(t,i)),se(i,n,0,r,o)}}}function ie(){return Object.create(null)}function se(e,t,n,r,o){if(n===t.length)return r&&(e.isLeaf=!0),void(o&&(e.invocation=o));e.children||(e.children=ie());const i=t[n];let s=e.children?.[i];s||(s=ie(),e.children[i]=s),se(s,t,n+1,r,o)}function ce(e,t,n,r,o,i=1){const s=e.children;if(!s)return void o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});const c=Object.keys(s),a=c.length;if(0!==a)if(e.isLeaf||r>=i&&a>1){o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});for(const e of c){const c=s[e];c.invocation&&ce(c,t,[...n,e],r+1,o,i)}}else if(r<i&&a>1&&!e.isLeaf)for(const e of c)ce(s[e],t,[...n,e],r+1,o,i);else{if(1===a){const e=c[0];return void ce(s[e],t,[...n,e],r+1,o,i)}o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}else o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}var ae=!1,ue=!1,le=new Map,fe=new Map,de=new Map,ye=null,pe=1/0;function he(){return ae}function ge(){return ye}function be(){ae||(ae=!0,ue||(ue=!0,queueMicrotask(()=>{ue=!1,f(()=>{for(;fe.size>0;){const e=pe,t=de.get(e);if(t){de.delete(e);for(const e of t)fe.delete(e);ye=e;for(const e of t)e();if(ye=null,de.size>0){pe=1/0;for(const e of de.keys())e<pe&&(pe=e)}else pe=1/0}else{pe=1/0;for(const e of de.keys())e<pe&&(pe=e)}}for(;le.size>0;){const e=Array.from(le.values());le.clear();for(const t of e)t()}}),ae=!1,ye=null,fe.clear(),de.clear(),pe=1/0})))}function me(e,t){ae&&le.set(e,t)}var Se=e=>e;function ve(e,t=Object.is){return n=function(e,t=Object.is){const{debounceOptions:n,debugMode:r,equalityFn:o,keepAlive:i,lockDependencies:c}="function"==typeof(l=t)?{debounceOptions:void 0,debugMode:!1,equalityFn:l,keepAlive:!1,lockDependencies:!1}:{debounceOptions:l.debounce,debugMode:(s&&l.debugMode)??!1,equalityFn:l.equalityFn??Object.is,keepAlive:l.keepAlive??!1,lockDependencies:l.lockDependencies??!1},a=String(Oe+=1),u=new Set;var l;i&&u.add(je);const f=new Set;let d,y,p=we,h=!1,g=!0,b=!0,m=!0,S=0,v=!1,w=null,O=we;function q(e,t,n){if(!m||!u.size)return(t??Se)(R(e)?e.getSnapshot():e.getState());if(!t)return d||(d=new WeakMap),y||(y=oe()),Z(e,d,y.trackPath);const r=e.subscribe(t,K,{equalityFn:n??Object.is,isDerivedStore:!0});return f.add(r),t(R(e)?e.getSnapshot():e.getState())}function F(e){for(const t of f)t(e);f.clear()}function C(){if(!b&&qe(p))return p;b=!1,m&&F(!0);const t=p,n=qe(t);p=function(t){g=!0;const n=p,i=e(t);return qe(n)&&o(n,i)?(r&&console.log("[π₯· Derive Complete π₯·]: No change detected"),g=!1,n):i}(q);const i=r&&(!n||"verbose"===r&&m);if(i){n?"verbose"===r&&console.log("[π Rebuilding Subscriptions π]: Createdβ¦"):console.log("[π Initial Derive Complete π]: Createdβ¦");const e=f.size;console.log(`[π― ${e} ${X("Selector Subscription",e)} π―]`)}return y&&m&&(y.buildProxySubscriptions((e,t)=>{const n=e.subscribe(t,K,{equalityFn:Object.is,isDerivedStore:!0});f.add(n)},i),d=void 0,y=void 0),g&&n&&function(e,t){const n=function(){const e=u.has(je)?u.size-1:u.size;return S>0&&S<e}(),o=!S||n,i=n||null!==ge()||he()&&o;n&&be(),r&&console.log(`[π» Derive Complete π»]: Notifying ${u.size} ${X("watcher",u.size)}`);for(const t of u){if("function"==typeof t||!t.isDerivedWatcher)continue;const n=t.selector(e);if(!t.equalityFn(t.currentSlice,n)){const e=t.currentSlice;t.currentSlice=n,t.listener(n,e)}}i?v||(v=!0,qe(O)||(O=t),me(a,I)):A(e,t)}(p,t),c&&(m=!1),p}function A(e,t){for(const n of u)if("function"==typeof n)n(e,t);else if(!n.isDerivedWatcher){const t=n.selector(e);if(!n.equalityFn(n.currentSlice,t)){const e=n.currentSlice;n.currentSlice=t,n.listener(t,e)}}}function I(){u.size&&(v&&function(){if(b&&!S&&C(),!qe(p))return;const e=qe(O)?O:p;A(p,e)}(),v=!1,O=we)}const k=n?j(z,"number"==typeof n?n:n.delay,"number"==typeof n?{leading:!1,maxWait:n,trailing:!0}:n):void 0,T=k??(()=>{h||(h=!0,queueMicrotask(z))});function z(){u.size&&(h=!1,b&&C())}function M(e){e?queueMicrotask(()=>{u.size||E()}):E()}function D(){z(),w=null}function K(){if(!b){if(b=!0,!k){if(S){be();const e=ge(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!ae)return;const n=t<0?0:0|t,r=fe.get(e);if(void 0===r){fe.set(e,n);let t=de.get(n);return t||(t=new Set,de.set(n,t)),t.add(e),void(n<pe&&(pe=n))}if(n>r){const t=de.get(r);if(t&&(t.delete(e),0===t.size&&(de.delete(r),r===pe))){pe=1/0;for(const e of de.keys())e<pe&&(pe=e)}fe.set(e,n);let o=de.get(n);o||(o=new Set,de.set(n,o)),o.add(e),n<pe&&(pe=n)}}(D,t)}if(he())return void(v||(v=!0,qe(p)&&(O=p),me(a,I)))}w=null,S&&!n?C():T()}}function $(){return b||!qe(p)?u.size>0?C():e(q):p}function E(e=!0){i&&e||(k?.cancel(),F(),u.clear(),S=0,y=void 0,d=void 0,m=!0,h=!1,b=!0,p=we,v=!1,O=we,w=null)}return{destroy:()=>E(!1),flushUpdates:function(){u.size&&(k?k.flush():b&&C())},getSnapshot:function(){if(!qe(p)){u.add(je);const e=C();return u.delete(je),e}return h&&z(),p},getState:$,subscribe:function(...e){if(1===e.length){const t=e[0];return u.add(t),1!==u.size||qe(p)||$(),()=>{u.delete(t),u.size||M(!1)}}const[t,n,r]=e,o=r?.equalityFn??Object.is,i=r?.isDerivedStore??!1,s={currentSlice:void 0,equalityFn:o,isDerivedWatcher:i,listener:n,selector:t};return u.add(s),s.currentSlice=t($()),i&&(S+=1),r?.fireImmediately&&n(s.currentSlice,s.currentSlice),()=>{u.delete(s),i&&(S-=1),u.size||M(i)}},getInitialState:()=>{throw new Error("[createDerivedStore]: getInitialState() is not available on derived stores.")},setState:()=>{throw new Error("[createDerivedStore]: setState() is not available on derived stores.")}}}(e,t),Object.assign(function(e=Se,t=void 0){return b(n.subscribe,n.getSnapshot,void 0,e,t)},n);var n}var we=Symbol(),Oe=0;function je(){}function qe(e){return e!==we}var Fe=class{constructor({disableAutoRefetching:e,initialEnabled:t}){this.count=0,this.enabled=!1,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,this.enabled=t,e&&(this.fetchThrottleMs=A.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}get(){return{enabled:this.enabled,lastSubscriptionTime:this.lastSubscriptionTime,subscriptionCount:this.count}}setEnabled(e){this.enabled=e}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.onSubscribe?.(this.enabled,e,t),this.count+=1,this.lastSubscriptionTime=Date.now(),e=>{const t=1===this.count;this.count=Math.max(this.count-1,0),t&&(this.onLastUnsubscribe?.(e),this.lastSubscriptionTime=null)}}},Ce={Error:"error",Idle:"idle",Loading:"loading",Success:"success"};function Ae(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!(r in t)||!Ae(e[r],t[r]))return!1;return!0}function Ie(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.is(e[r],t[r]))return!1;return!0}function ke(e,t){const n=Object.prototype.hasOwnProperty;function r(e,t){for(const n of e.keys())if(ke(n,t))return n}let o,i,s;if(e===t)return!0;if(e&&t&&(o=e.constructor)===t.constructor){if(o===Date)return e.getTime()===t.getTime();if(o===RegExp)return e.toString()===t.toString();if(o===Array){if((i=e.length)===t.length)for(;i--&&ke(e[i],t[i]););return-1===i}if(o===Set){if(e.size!==t.size)return!1;for(let n of e){if(s=n,s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!t.has(s))return!1}return!0}if(o===Map){if(e.size!==t.size)return!1;for(let n of e){if(s=n[0],s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!ke(n[1],t.get(s)))return!1}return!0}if(o===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(o===DataView){if((i=e.byteLength)===t.byteLength)for(;i--&&e.getInt8(i)===t.getInt8(i););return-1===i}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){const n=e,r=t;if((i=n.byteLength)===r.byteLength)for(;i--&&n[i]===r[i];);return-1===i}if(!o||"object"==typeof e){i=0;for(const r in e){if(n.call(e,r)&&++i&&!n.call(t,r))return!1;if(!(r in t)||!ke(e[r],t[r]))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}var Te=new WeakMap,ze=new WeakMap;function Me(e,t=De,n=ke){return function(e,t,n){let r=ze.get(e);r||(r=new Map,ze.set(e,r));let o=r.get(t);o||(o=new Map,r.set(t,o));const i=o.get(n);if(i)return i;const[s,c,a]=$e(e,t,n),u=new Map,l=e=>{const t={get(t,n){if("value"===n){let t=c();const n=e.split(".");for(const e of n)e&&(t=t[e]);return t}const r="string"==typeof n?n:n.toString(),o=e?`${e}.${r}`:r,i=u.get(o);if(i)return i;const a=l(o);return Te.set(a,s),u.set(o,a),a},set(t,n,r){const o=e.split(".");return""===o[0]&&o.shift(),a(o,r),!0}};return new Proxy(Object.create(null),t)},f=l("");return s(()=>{}),Te.set(f,s),o.set(n,f),f}(e,t,n)}var De=e=>e,Ke=(e,t,n)=>{if(!t.length)return n;const[r,...o]=t,i=e[r],s=Ke(i,o,n);if(ke(i,s))return e;const c=Array.isArray(e)?e.slice():{...e};return c[r]=s,c},$e=(e,t,n)=>{const r=new Set,o=R(e);let i,s=t(o?e.getSnapshot():e.getState());return[c=>(r.size||(i=e.subscribe(t,e=>{s=e,r.forEach(e=>e())},{equalityFn:n,isDerivedStore:o})),r.add(c),()=>{r.delete(c),!r.size&&i&&(i(),i=void 0)}),()=>(r.size||(s=t(e.getState())),s),(n,r)=>{if(t!==De)throw new Error("Cannot set a value with a selector");e.setState(e=>Ke(e,n,r),!0)}]},[Ee,Pe]=[!0,!1],Le={error:Ee,lastFetchedAt:Ee,queryCache:Ee,queryKey:Ee,status:Ee,enabled:Pe,fetch:Pe,getCacheEntry:Pe,getData:Pe,getStatus:Pe,isDataExpired:Pe,isStale:Pe,reset:Pe},Re=A.seconds(5);function xe(t,n,o){r();const l="function"==typeof n?n:He,f="object"==typeof n?n:o,d=f&&"storageKey"in f?f:void 0,{fetcher:y,onError:p,onFetched:h,setData:g,transform:b,abortInterruptedFetches:m=!0,cacheTime:S=A.days(7),debugMode:v=!1,disableAutoRefetching:w=!1,disableCache:O=!1,enabled:q=!0,keepPreviousData:F=!1,maxRetries:C=5,paramChangeThrottle:I=!1,params:k,retryDelay:T=Ne,suppressStaleTimeWarning:z=!1,useParsableQueryKeys:M=!0}=t;let D="function"==typeof t.staleTime?A.minutes(2):t.staleTime??A.minutes(2);s&&!w&&!z&&D<Re&&console.warn(`[createQueryStore${d?.storageKey?`: ${d.storageKey}`:""}] β Stale times under ${Re/1e3} seconds are not recommended. Provided staleTime: ${D/1e3} seconds`);const K=M?Be:We,$=new Error("[createQueryStore: AbortError] Fetch interrupted"),E="function"==typeof S,P=s&&v,L=Object.keys(t.params??Object.create(null));let R=null,x=null,N=null,W=[],B=!1,J=!1,U=null,Q=null,V=null,H=null,_=null;const G={enabled:"function"!=typeof q&&q,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:Ce.Idle},X=new Fe({disableAutoRefetching:w,initialEnabled:G.enabled}),Z=()=>{U&&(Q=null,U.abort(),U=null)},ee=(e,n,r)=>{const o=r.setState,s=(e,t)=>{const n="function"==typeof e;if(n||void 0!==e.enabled){let t;const i=o(o=>{const i=n?e(o):e,s=void 0!==i.enabled?i.enabled:o.enabled;return s!==o.enabled&&(t=()=>((e,t)=>{e!==t&&_!==t&&(_=t,X.setEnabled(t),t?queueMicrotask(()=>r.getState().fetch(void 0,{updateQueryKey:!0})):(V||m)&&(m&&Z(),V&&(clearTimeout(V),V=null)))})(o.enabled,s)),i});return t?.(),i}return o(e)};r.setState=s,X.init({onSubscribe:(r,o,i)=>{if(x||R||!k&&"function"!=typeof t.enabled&&"function"!=typeof t.staleTime){if(r)if(o){const t=Ve(R,x),r=K(t),o=n();o.queryKey!==r&&e(e=>({...e,queryKey:r})),o.isStale()?f.fetch(t,void 0,!0):c(t,void 0)}else w&&!i&&f.fetch(void 0,void 0,!0)}else B=!0},onLastUnsubscribe:e=>{V&&(clearTimeout(V),V=null),m&&!e&&Z()}});const c=(e,t)=>{if(w||t?.skipStoreUpdates)return;if(D<=0||D===1/0)return;V&&(clearTimeout(V),V=null);const r=K(e),o=n(),i=(O?H===r&&o.lastFetchedAt:o.queryCache[r]?.lastFetchedAt)||null,s=i?D-(Date.now()-i):D;V=setTimeout(()=>{const t=X.get();t.enabled&&t.subscriptionCount>0&&f.fetch(e,{force:!0},!0)},s)},f={...l(s,n,r),...G,async fetch(t,r,o=!1){const l=X.get();if(!r?.force&&!r?.skipStoreUpdates&&!l.enabled)return null;const v=n(),w=v.error,j=v.queryKey,q=v.status,A=Qe(R,x,L,t),I=K(A),k=r?.staleTime??D,z=q===Ce.Loading,M=!!r?.skipStoreUpdates,N="boolean"==typeof r?.updateQueryKey?r.updateQueryKey:o?F:!M,W=o||!M&&(N||j===I);if(Q?.promise&&Q.key===I&&z)return P&&console.log("[π Using Active Fetch π] for params:",JSON.stringify(A)),Q.promise;if(m&&!M&&!1!==r?.updateQueryKey&&Z(),!r?.force){const t=v.lastFetchedAt,n=v.queryCache[I],o=n?.lastFetchedAt,i=n?.errorInfo,s=i&&i.retryCount>=C,a=(O?H===I&&t:o)||null;if(a&&!(Date.now()-a>=k)&&(!i||s||M))return W&&!M&&!V&&l.subscriptionCount>0&&0!==D&&D!==1/0&&c(A,r),N&&e(e=>e.queryKey!==I?{...e,queryKey:I}:e),P&&console.log("[πΎ Returning Cached Data πΎ] for params:",JSON.stringify(A)),n?.data??null}!M&&W&&(V&&(clearTimeout(V),V=null),!w&&z||e(e=>({...e,error:null,status:Ce.Loading})),Q={key:I});const B=r?.cacheTime??(E?S(A):S),J=async()=>{try{P&&(o||!t||_e(t,L)?console.log("[π Fetching π] for params:",JSON.stringify(A)):console.log("[π Fetching with Partial Params π]\n","- Provided params:",`${JSON.stringify(t)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(A).filter(e=>!(e in t)).map(e=>[e,A[e]])))}`));const n=await(m&&!M&&W?(async e=>{const t=new AbortController;U=t;try{return await new Promise((n,r)=>{t.signal.addEventListener("abort",()=>r($),{once:!0}),Promise.resolve(y(e,t)).then(n,r)})}finally{U===t&&(U=null)}})(A):y(A,null)),u=Date.now();let l;P&&console.log("[β
Fetch Successful β
] for params:",JSON.stringify(A));try{l=b?b(n,A):n}catch(e){throw new i(`[createQueryStore: ${d?.storageKey||I}]: transform failed`,e)}if(M)return P&&console.log("[π₯· Successful Parallel Fetch π₯·] for params:",JSON.stringify(A)),"withCache"===r.skipStoreUpdates&&e(e=>{if(!g)return O?{...e,queryCache:{...e.queryCache,[I]:{cacheTime:B,data:l,errorInfo:null,lastFetchedAt:u}}}:e;let t=e;const n=t.queryCache[I];return g({data:l,params:A,queryKey:I,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}}),!O&&Object.is(n,t.queryCache[I])&&(t={...t,queryCache:{...t.queryCache,[I]:{cacheTime:B,data:l,errorInfo:null,lastFetchedAt:u}}}),t}),l;if((g?s:e)(e=>{let t={...e,error:null,lastFetchedAt:u,queryKey:N?I:e.queryKey,status:Ce.Success};if(g||O){if(g){P&&console.log("[πΎ Setting Data πΎ] for params:",JSON.stringify(A));const e=t.queryCache[I];g({data:l,params:A,queryKey:I,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}}),!O&&Object.is(e,t.queryCache[I])&&(t.queryCache={...t.queryCache,[I]:{cacheTime:B,data:null,errorInfo:null,lastFetchedAt:u}})}}else P&&console.log("[πΎ Setting Cache πΎ] for params:",JSON.stringify(A),"| Has previous data?:",!!t.queryCache[I]?.data),t.queryCache={...t.queryCache,[I]:{cacheTime:B,data:l,errorInfo:null,lastFetchedAt:u}};return O||S===1/0?t:Ge(F,I,t)}),W&&(H=I,c(A,r)),h)try{h({data:l,fetch:f.fetch,params:A,set:s})}catch(e){a.error(new i(`[createQueryStore: ${d?.storageKey||I}]: onFetched callback failed`,e))}return l??null}catch(s){if(s===$)return P&&console.log("[β Fetch Aborted β] for params:",JSON.stringify(A)),null;const c=!o&&!0===r?.throwOnError,l=u(s);if(M||!W){if(a.error(new i(`[createQueryStore: ${d?.storageKey||I}]: Failed to fetch data`,l)),c)throw l;return null}const y=O?void 0:n().queryCache[I],h=y?.errorInfo?.retryCount??0,g=h+1;if(p?.(l,h),h<C){if(X.get().subscriptionCount>0){const e="function"==typeof T?T(g,l):T;e!==1/0&&(V&&clearTimeout(V),V=setTimeout(()=>{const{enabled:e,subscriptionCount:n}=X.get();e&&n>0&&f.fetch(t,{force:!0},!0)},e))}e(e=>({...e,error:l,queryCache:{...e.queryCache,[I]:{cacheTime:y?.cacheTime??B,data:y?.data??null,lastFetchedAt:y?.lastFetchedAt??null,errorInfo:{error:l,lastFailedAt:Date.now(),retryCount:g}}},queryKey:N?I:e.queryKey,status:Ce.Error}))}else e(e=>({...e,error:l,queryCache:{...e.queryCache,[I]:{cacheTime:y?.cacheTime??B,data:y?.data??null,lastFetchedAt:y?.lastFetchedAt??null,errorInfo:{error:l,lastFailedAt:Date.now(),retryCount:C}}},queryKey:N?I:e.queryKey,status:Ce.Error}));if(a.error(new i(`[createQueryStore: ${d?.storageKey||I}]: Failed to fetch data`,l)),c)throw l;return null}finally{!M&&W&&(Q=null)}};return M||!W?J():(Q={key:I,promise:J()}).promise},getCacheEntry(e){if(O)return null;const t=n(),r=e?"string"==typeof e?e:K(Qe(R,x,L,e)):t.queryKey;return t.queryCache[r]??null},getData(e){if(O)return null;const t=n().getCacheEntry(e);return t&&null!==t.data?F?t.data:t.lastFetchedAt&&Date.now()-t.lastFetchedAt>=t.cacheTime?null:t.data:null},getStatus:function(e){switch(e){case"isIdle":return n().status===Ce.Idle;case"isLoading":return n().status===Ce.Loading;case"isSuccess":{const e=n(),t=e.queryCache[e.queryKey]?.lastFetchedAt;return"number"==typeof t||e.status===Ce.Success}case"isError":case"isInitialLoad":case void 0:{const t=n(),r=t.queryCache[t.queryKey],o=(O?H===t.queryKey&&t.lastFetchedAt:r?.lastFetchedAt)||null,i=t.status;switch(e){case"isError":{const e=t.queryCache[t.queryKey];return O?"error"!==i:"number"==typeof e?.errorInfo?.lastFailedAt}case"isInitialLoad":return!o&&i===Ce.Loading}return{isError:i===Ce.Error,isIdle:i===Ce.Idle,isLoading:i===Ce.Loading,isInitialLoad:!o&&i===Ce.Loading,isSuccess:i===Ce.Success}}}},isDataExpired(e){const t=n(),r=t.queryCache[t.queryKey],o=t.queryKey,i=t.lastFetchedAt,s=(O?H===o&&i:r?.lastFetchedAt)||null;if(!s)return!0;const c=e??r?.cacheTime;return void 0===c||Date.now()-s>=c},isStale(e){const t=n(),r=t.queryKey,o=(O?H===r&&t.lastFetchedAt:t.queryCache[r]?.lastFetchedAt)||null;if(!o)return!0;const i=e??D;return Date.now()-o>=i},reset(t=!1){for(const e of W)e();W=[],R=null,x=null,N=null,Z(),V&&(clearTimeout(V),V=null),Q=null,H=null,t&&e(e=>({...e,...G}))}},v=r.subscribe;return r.subscribe=(...e)=>{const t=J?()=>{}:X.subscribe(),n=1===e.length?v(e[0]):v(e[0],e[1],e[2]);return e=>{t(e),n()}},f},te=d?.storageKey?Y(ee,Object.assign(Object.create(null),d,{partialize:Ze(F,d.partialize)})):f&&!("storageKey"in f)?Y(ee,f):Y(ee),ne=te.getState(),re=ne.error,oe=ne.enabled,ie=ne.queryKey;if(ie&&!re&&(H=ie),J=!0,k||"function"==typeof t.enabled){const{directValues:e,enabledAttachVal:t,enabledDirectValue:n,attachVals:r}=function(e,t,n){const r=Object.create(null),o=Object.create(null),i=Object.create(null);for(const e in t){if(!c(t,e))continue;const s=t[e];if(Ye(s)){const t=s(Me,n);r[e]=t,i[e]=t.value}else Xe(s)&&(o[e]=s,i[e]=s)}let s,a=null,u=null;if(Ye(e)){const t=e(Me,n);s=t.value,a=t}else s=e,u=e;return{attachVals:r,directValues:o,enabledAttachVal:a,enabledDirectValue:u,resolvedEnabled:s,resolvedParams:i}}(q,k,te);R={enabled:t,params:r},x={enabled:n,params:e}}"function"==typeof t.staleTime&&(N=t.staleTime(Me,te),D=N.value);const se=function(){let e,t=!1;return function(...n){e=n,t||(t=!0,queueMicrotask(()=>{t=!1,(e=>{ne.fetch(e??Ve(R,x),{updateQueryKey:F})})(...e)}))}}();function ce(){let e;if(!F){e=Ve(R,x);const t=K(e);te.setState(e=>({...e,queryKey:t}))}se(e)}const ae=e||!I?ce:j(ce,"number"==typeof I?I:I.delay,"number"==typeof I?{leading:!1,maxWait:I,trailing:!0}:I);if(R?.enabled){const e=R.enabled,t=Te.get(e);if(t){let n=e.value;oe!==n&&te.setState(e=>({...e,enabled:n})),n&&X.setEnabled(n),P&&console.log("[π Enabled Subscription π] Initial value:",n);const r=t(()=>{const t=e.value;t!==n&&(P&&console.log("[π Enabled Change π] - [Old]:",`${n},`,"[New]:",t),n=t,te.setState(e=>({...e,enabled:t})))});W.push(r)}}else oe!==G.enabled&&te.setState(e=>({...e,enabled:G.enabled}));for(const e in R?.params){const t=R.params[e];if(!t)continue;const n=Te.get(t);if(P&&console.log("[π Param Subscription π] Subscribed to param:",e),n){let r=t.value;const o=n(()=>{const n=t.value;ke(r,n)||(P&&console.log("[π Param Change π] -",e,"- [Old]:",`${r?.toString()},`,"[New]:",n?.toString()),r=n,ae())});W.push(o)}}if(N){const e=Te.get(N);if(e){const t=N;let n=t.value;P&&console.log("[π StaleTime Subscription π] Initial value:",n);const r=e(()=>{const e=t.value;e!==n&&(P&&console.log("[π StaleTime Change π] - [Old]:",`${n},`,"[New]:",e),n=e,D=e,te.getState().fetch())});W.push(r)}}return J=!1,B&&queueMicrotask(ae),ue=te,le="_queryStore",Object.assign(ue,{[le]:!0});var ue,le}function Ne(e,t){const n=t?.baseDelay??A.seconds(5),r=t?.maxDelay??A.minutes(5),o=Math.pow(2,e);return Math.min(n*o,r)}function We(e){return JSON.stringify(Object.keys(e).sort().map(t=>e[t]))}function Be(e){return JSON.stringify(Ue(e))}function Je(e){return JSON.parse(e)}function Ue(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,n)=>{const r=e[n];return t[n]=null!==r&&"object"==typeof r?Ue(r):r,t},{})}function Qe(e,t,n,r){return r?_e(r,n)?r:{...Ve(e,t),...r}:Ve(e,t)}function Ve(e,t){const n=t?.params??Object.create(null);for(const t in e?.params){const r=e.params[t];r&&(n[t]=r.value)}return n}function He(){return Object.create(null)}function _e(e,t){if(!e)return!1;for(const n of t)if(!(n in e))return!1;return!0}function Ge(e,t,n){if(!n.queryCache)return n;const r=Date.now(),o=t??(e&&n.queryKey||null);let i=!1;const s=Object.create(null);for(const e in n.queryCache){if(!c(n.queryCache,e))continue;const a=n.queryCache[e];a&&(r-(a.lastFetchedAt??a.errorInfo.lastFailedAt)<a.cacheTime||e===o)?!t&&a.errorInfo&&a.errorInfo.retryCount>0?(s[e]={...a,errorInfo:{...a.errorInfo,retryCount:0}},i=!0):s[e]=a:i=!0}return i?{...n,queryCache:s}:n}function Ye(e){return"function"==typeof e}function Xe(e){return!Ye(e)}function Ze(e,t){return n=>{const r={...n},o={};for(const e in r)c(r,e)&&e in Le&&(Le[e]&&(o[e]=r[e]),delete r[e]);return{...t?t(r):C(r),...Ge(e,null,o)}}}function et(e,t,n){const r="function"==typeof t,o=r?t:void 0,i=r?n:t,s=new Set,c=ve(e,{debugMode:i?.debugMode??!1,equalityFn:function(e,t){const n=Object.is(e,t);return n||(function(e,t){for(const n of s){n.unsubscribe();const r=n.args;if(1===r.length){const o=r[0],i=e.getState(),s=t.getState(),c=t.subscribe(o);n.unsubscribe=c,Object.is(s,i)||o(s,i);continue}const o=r[0],i=r[1];let s=r[2];s?.fireImmediately&&(s={...s,fireImmediately:!1});const c=o(e.getState()),a=o(t.getState()),u=t.subscribe(o,i,s);n.unsubscribe=u,(s?.equalityFn??Object.is)(c,a)||i(a,c)}}(e,t),E(e)),n},keepAlive:!0,lockDependencies:i?.lockDependencies??!0}),a=c.getState().persist,u=(l=c.getState,function(e,t){return t?l().setState(e,t):l().setState(e)});var l;return Object.assign(function(e,t){const n=c();return e?n(e,t):n()},{_virtualStore:!0,destroy:()=>c.destroy(),getInitialState:()=>c.getState().getInitialState(),getState:()=>c.getState().getState(),persist:a,setState:u,subscribe:function(...e){const t={args:e,unsubscribe:1===e.length?c.getState().subscribe(e[0]):c.getState().subscribe(e[0],e[1],e[2])};return s.add(t),()=>{t.unsubscribe(),s.delete(t)}}},o?o(c.getState):void 0)}var tt=Symbol(),nt=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1});function rt(e,t,n,r=nt){const o=function(){const e=S(tt);return e.current===tt&&(e.current=function(e,t,n){return{selector:e,react:t,isActive:!1,options:st(n),resubscribe:()=>{},unsubscribe:()=>{}}}(t,n,r)),e}(),i=function(e){return"function"==typeof e?nt.enabled:e?.enabled??nt.enabled}(r);return o.current.react=n,o.current.selector=t,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??nt)}(o,r),m(()=>{if(i)return it(e,o),()=>function(e){e.current.options.debugMode&&console.log("[ποΈ useListen ποΈ] Detaching listener"),e.current.resubscribe=()=>{},e.current.unsubscribe(),e.current.unsubscribe=()=>{},e.current.isActive=!1}(o)},[i,e]),o}var ot=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function it(e,t,n=ot){if(t.current.isActive){if(!n?.forceResubscribe)return;t.current.unsubscribe()}t.current.options.debugMode&&console.log("[π‘ useListen π‘] Attaching listener"),t.current.isActive=!0,t.current.resubscribe=(n=ot)=>it(e,t,n);const r=e.subscribe(e=>t.current.selector(e),(e,n)=>t.current.react(e,n,()=>{r(),t.current.isActive=!1}),n.fireImmediately?{...t.current.options,fireImmediately:!0}:t.current.options);t.current.unsubscribe=()=>{t.current.isActive&&(r(),t.current.isActive=!1)}}function st(e){return"function"==typeof e?{equalityFn:e}:e??nt}var ct=Symbol();function at(e){const t=S(ct);return t.current===ct&&(t.current=e()),t.current}function ut(e,t){const n=function(e){const t=e.getState(),n=Object.create(null);if(s&&("object"!=typeof t||null===t))throw new Error("[createStoreActions]: State is not an object");if(B(e)){for(const r in t)ft(t,r)&&(n[r]=lt(e,r));return n}for(const e in t)ft(t,e)&&(n[e]=t[e]);return n}(e);return t?Object.assign(n,t):n}function lt(e,t){return function(...n){const r=e.getState()[t];if("function"==typeof r)return r(...n);throw new Error(`[createVirtualStoreAction]: Method ${String(t)} is not a function`)}}function ft(e,t){return"function"==typeof e[t]}export{Ce as QueryStatuses,$ as applyStateUpdate,Y as createBaseStore,ve as createDerivedStore,xe as createQueryStore,ut as createStoreActions,et as createVirtualStore,Ae as deepEqual,Ne as defaultRetryDelay,E as destroyStore,P as destroyStores,We as getLegacyQueryKey,Be as getQueryKey,L as getStoreName,N as isDerivedStore,W as isPersistedStore,x as isQueryStore,B as isVirtualStore,Je as parseQueryKey,Ie as shallowEqual,A as time,rt as useListen,at as useStableValue};
|
|
1
|
+
import{IS_TEST as e,IS_BROWSER as t,IS_IOS as n,markStoreCreated as r,getStorageConfig as o,StoresError as i,identity as s,IS_DEV as c,buildNullObject as a,isPlainObject as u,nullObject as l,hasOwn as f,noop as d,logger as y,ensureError as p,unstable_batchedUpdates as h,getOptions as g,isPromiseLike as b,reviver as m,replacer as S}from"./chunk-3U5A7HQV.mjs";export{StoresError,configureStores,identity,nullObject,replacer,reviver}from"./chunk-3U5A7HQV.mjs";import{subscribeWithSelector as v,persist as w}from"zustand/middleware";import{createStore as F}from"zustand/vanilla";import{useLayoutEffect as O,useRef as q,useSyncExternalStore as j,useDebugValue as A}from"react";var C=Symbol("empty selection"),T=Object.is;function k(e,t,n,r,o=T){const i=q(null);let s=e,c=t,a=n;if(r){let u=i.current;null===u&&(u=function(e,t,n,r,o){const i={committedEqualityFn:o,committedSelector:r,committedSource:e,committedValue:C,equalityFn:o,getSelectedServerSnapshot:()=>function(e){return D(e,(e.getServerStoreSnapshot??e.getStoreSnapshot)())}(i),getSelectedSnapshot:()=>z(i),getServerStoreSnapshot:n,getStoreSnapshot:t,latestSnapshot:C,latestSource:C,selector:r,selectedSource:e,selectedSubscribe:()=>d,source:e,value:C,valueEqualityFn:o,valueSelector:r,valueSnapshot:C};return i.selectedSubscribe=I(i,e),i}(e,t,n,r,o),i.current=u),function(e,t,n,r,o,i){e.source===t&&e.getStoreSnapshot===n||(e.latestSnapshot=C),e.source=t,e.getStoreSnapshot=n,e.getServerStoreSnapshot=r,e.selector=o,e.equalityFn=i,e.selectedSource!==t&&(e.selectedSource=t,e.selectedSubscribe=I(e,t))}(u,e,t,n,r,o),s=u.selectedSubscribe,c=u.getSelectedSnapshot,a=void 0===n?void 0:u.getSelectedServerSnapshot}const u=j(s,c,a);return A(u),u}function I(e,t){return n=>(function(e){e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedSource=e.source,e.committedValue=e.value===C?z(e):e.value}(e),t(r=>{e.latestSnapshot=r,e.latestSource=t;const o=e.committedValue;if(o===C||e.committedSource!==t)return void n();const i=e.committedSelector,s=e.committedEqualityFn;if(e.selector===i&&e.equalityFn===s){const t=i(r);if(s===T?T(o,t):s(o,t))return;return e.committedValue=t,e.value=t,e.valueEqualityFn=s,e.valueSelector=i,e.valueSnapshot=r,void n()}if(e.source!==t)return void n();const c=e.value;if(c===C)return;const a=e.selector(r),u=e.equalityFn(c,a);e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedValue=M(e,r,u?c:a),u||n()}))}function z(e){const t=function(e){if(e.latestSource===e.source&&e.latestSnapshot!==C)return e.latestSnapshot;const t=e.getStoreSnapshot();return e.latestSnapshot=t,e.latestSource=e.source,t}(e);return D(e,t)}function D(e,t){const n=e.value;if(n!==C&&T(e.valueSnapshot,t)&&e.valueSelector===e.selector&&e.valueEqualityFn===e.equalityFn)return n;const r=e.selector(t);if(n!==C&&(e.equalityFn===T?T(n,r):e.equalityFn(n,r)))return M(e,t,n);const o=e.committedValue;return o!==C&&o!==n&&e.committedSource===e.source&&(e.equalityFn===T?T(o,r):e.equalityFn(o,r))?M(e,t,o):M(e,t,r)}function M(e,t,n){return e.value=n,e.valueEqualityFn=e.equalityFn,e.valueSelector=e.selector,e.valueSnapshot=t,n}function E(e,t){return(e,t)=>function(e,t){const n=F(e);return Object.assign(function(e,r){return k(n.subscribe,n.getState,n.getInitialState,e,r??t)},n)}(e,t)}function P(){let e,t,n=!1;return{complete:function(){!n&&e&&(n=!0,e(),e=void 0,t=void 0)},isHydrated:function(){return n},fail:function(r){!n&&t&&(n=!0,t(r),t=void 0,e=void 0)},promise:new Promise((n,r)=>{e=n,t=r})}}var K=Math.max,R=Math.min;function $(e,t=0,n={}){let r,o,i,s,c,a,u=0,l=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){const n=r,i=o;return r=o=void 0,u=t,s=n?e.apply(i,n):e.apply(i),s}function p(e){const n=e-(a??0);return void 0===a||n>=t||n<0||f&&void 0!==i&&e-u>=i}function h(){const e=L();if(p(e))return g(e);c=setTimeout(h,function(e){const n=t-(e-(a??0));return f&&void 0!==i?R(n,i-(e-u)):n}(e))}function g(e){return c=void 0,d&&r?y(e):(r=o=void 0,s)}function b(...e){const n=L(),i=p(n);if(r=e,o=this,a=n,i){if(void 0===c)return function(e){return u=e,c=setTimeout(h,t),l?y(e):s}(a);if(f)return clearTimeout(c),c=setTimeout(h,t),y(a)}return void 0===c&&(c=setTimeout(h,t)),s}return t=x(t)||0,function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}(n)&&(l=!!n.leading,f="maxWait"in n,i=f?K(x(n.maxWait)||0,t):void 0,d="trailing"in n?!!n.trailing:d),b.cancel=function(){void 0!==c&&clearTimeout(c),u=0,r=a=o=c=void 0},b.flush=function(){return void 0===c?s:g(L())},b}function L(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function x(e){if("number"==typeof e)return e;if("symbol"==typeof e||void 0===e)return NaN;if("object"==typeof e&&null!==e){const t="function"==typeof e.valueOf?e.valueOf():e;e="object"==typeof t?t+"":t}return"string"!=typeof e?0===e?e:+e:(e=e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),/^0b[01]+$/i.test(e)?parseInt(e.slice(2),2):/^0o[0-7]+$/i.test(e)?parseInt(e.slice(2),8):/^[-+]0x[0-9a-f]+$/i.test(e)?NaN:+e)}function N(e){if(!u(e))return e;const t=l(),n=Object.keys(e);for(let r=0;r<n.length;r++){const o=n[r],i=e[o];"function"!=typeof i&&(t[o]=i)}return t}var V={ms:e=>e,seconds:e=>1e3*e,minutes:e=>6e4*e,hours:e=>36e5*e,days:e=>864e5*e,weeks:e=>6048e5*e,infinity:1/0,zero:0},W=e?0:t?V.ms(200):V.seconds(n?3:5);function H(e){return t=>{if("string"!=typeof t)throw new i("[createBaseStore]: Received non-string serialized state without a custom deserializer. Provide a deserializer on the store or storage adapter.");return function(e,t){try{return JSON.parse(e,t?m:void 0)}catch(e){throw y.error(new i("[createBaseStore]: Failed to deserialize persisted store data",e)),e}}(t,e)}}function U(e){return t=>function(e,t){try{return JSON.stringify(e,t?S:void 0)}catch(e){throw y.error(new i("[createBaseStore]: Failed to serialize store data",e)),e}}(t,e)}var J=Object.freeze({shouldClear:!1});function B(e,t,n){if(!t||!e)return J;const r=e.getFieldTimestampSnapshot();return function(e,t){const n=e.getSessionId(),r=e.getTimestamp();void 0!==n&&void 0!==r&&(t.syncMetadata={origin:n,timestamp:r})}(e,n),n.syncMetadata?r&&Object.keys(r).length>0?(n.syncMetadata.fields=r,{fieldSnapshot:r,shouldClear:!0}):(delete n.syncMetadata.fields,{fieldSnapshot:r,shouldClear:!1}):{fieldSnapshot:r,shouldClear:!1}}function Q(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function _(e){return!!e&&!!e.getIsApplyingRemote()}var G=Object.freeze({QueryStore:Symbol("queryStore"),VirtualStore:Symbol("virtualStore")});function X(e,...t){if(!0===t[1])return se(t[0])?t[0](e):t[0];const n=se(t[0])?t[0](e):t[0];return function(e){return Array.isArray(e)}(e)?n:{...e,...n}}function Y(e,t){ne(e)?e.getState().reset(t?.clearQueryCache):function(e){return"destroy"in e}(e)&&e.destroy()}function Z(e,t){for(const n of Array.isArray(e)?e:Object.values(e))n&&!t?.skipDestroy?.(n)&&Y(n,t)}function ee(e){return oe(e)?e.persist.getOptions().name??e.name:e.name}function te(e){return"getSnapshot"in e}function ne(e){return G.QueryStore in e}function re(e){return"flushUpdates"in e}function oe(e){return!(!("persist"in e)||!e.persist)&&"string"==typeof e.persist.getOptions().name}function ie(e){return G.VirtualStore in e}function se(e){return"function"==typeof e}var[ce,ae]=[0,1];function ue(e,t,n){if(!e)return!0;const r=e[ce],o=e[ae];return!(t<r)&&(t>r||n>o)}function le(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function fe(e,t){if(!c)return!0;if(null===e||null===t)return e===t;const n=typeof e;return n===typeof t&&("object"!==n||Object.prototype.toString.call(e)===Object.prototype.toString.call(t))}function de(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function ye(e,t){r();const n=void 0!==t&&"string"==typeof t.storageKey,s=n?t.storageKey:void 0,c=t?.sync?function(e,t){if(!e)return null;if(!0===e){if(!t)throw new i("[createBaseStore]: sync: true requires a storageKey to inherit the key from");return{key:t}}if("string"==typeof e)return{key:e};const n=e,r=n.key??t;if(!r)throw new i("[createBaseStore]: sync requires either a key in the config or a storageKey to inherit from");return{...n,key:r}}(t.sync,s):void 0,a=n?t.storage??o().storage:void 0,u=c?function(e,t,n){const r=t.engine??o().syncEngine,s=function(e){let t,n,r,o=!1;return{isAsync:e,clearFieldTimestamps:function(e){if(e&&r){for(const t of Object.entries(e)){const e=t[0],n=t[1];r[e]===n&&delete r[e]}Object.keys(r).length||(r=void 0)}},getFieldTimestampSnapshot:function(){if(r)return{...r}},getIsApplyingRemote:()=>o,getSessionId:()=>t,getTimestamp:()=>n,mergeFieldTimestamps:function(e){if(r)for(const t of Object.entries(e)){const e=t[0],n=t[1],o=r[e];(void 0===o||n>o)&&(r[e]=n)}else r={...e}},onHydrationComplete:void 0,onHydrationFlushEnd:void 0,setIsApplyingRemote:e=>o=e,setSessionId:e=>t=e,setTimestamp:e=>n=e,setWithoutPersist:void 0}}(n);return{stateCreator:(o,c,a)=>{const u=new Map,f=[],d=[];let p=null,h=!1,g=!1,m=0,S=null,v=[],w=Promise.resolve(),F=!n;function O(e,t){if(s?.setSessionId&&s?.setTimestamp&&r.sessionId&&(s.setSessionId(r.sessionId),s.setTimestamp(e),s.mergeFieldTimestamps&&t.length>0)){const n=l();for(const r of t)n[String(r)]=e;s.mergeFieldTimestamps(n)}}function q(e,t){if(h||!S)return t?o(e,t):o(e);const n=function(){const e=Date.now(),t=e>m?e:m+1;return m=t,t}();let i=[],s=l();const c=r=>{const o=X(r,e,t);for(const e of v)Object.is(o[e],r[e])||(i.push(e),s[e]=o[e]);return i.length&&O(n,i),o},a=t?o(c,!0):o(c);function f(){i.length&&function(e){const t=r.sessionId;for(const n of e.keys)u.set(n,[e.timestamp,t]);p&&g?p.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values}):d.push(e)}({keys:i,replace:t??!1,values:s,timestamp:n})}return b(a)?a.finally(f):(f(),a)}const j=a.setState;a.setState=q;const A=e(q,c,a);if(v=t.fields??function(e){const t=[];for(const n of Object.entries(e)){if("function"==typeof n[1])continue;const e=n[0];t.push(e)}return t}(A),!v.length)return A;async function C(e){m=Math.max(m,e.timestamp);const n=l(),r=c(),o=e.timestamp;let a;if(e.replace)for(const t of v)le(t,e.values)||ue(u.get(t),o,e.sessionId)&&(a??(a=[])).push(t);for(const s of v){if(!le(s,e.values))continue;if(!S?.has(s))continue;if(!ue(u.get(s),o,e.sessionId))continue;const c=t.merge?.[s];if(c){const t=e.values[s],a=r[s];if(void 0!==t){const l=c(t,a,r,e.values),f=void 0!==a?a:t;if(!fe(l,f))return void y.error(new i(`[sync] Merge function for field "${String(s)}" returned ${de(l)} but expected ${de(f)}`));n[s]=l,u.set(s,[o,e.sessionId])}}else n[s]=e.values[s],u.set(s,[o,e.sessionId])}if(Object.keys(n).length>0||a?.length){h=!0,s&&s.setIsApplyingRemote(!0);try{if(e.replace){const e={...r};let t=!1;if(a?.length){t=!0;for(const t of a)delete e[t],u.delete(t)}for(const r in n){if(!Object.prototype.hasOwnProperty.call(n,r))continue;const o=n[r];void 0!==o&&(Object.is(e[r],o)||(t=!0),e[r]=o)}if(!t)return;await(s.setWithoutPersist??j)(e,!0)}else await(s.setWithoutPersist??j)(n)}finally{h=!1,s&&s.setIsApplyingRemote(!1)}}}function T(e){n?w=w.then(()=>C(e)):C(e)}if(S=new Set(v),p=r.register({apply:e=>{F?T(e):f.push(e)},fields:v,getState:c,key:t.key}),p?.onFirstSubscribe||p?.onLastUnsubscribe){let e=0;const t=a.subscribe;a.subscribe=(...n)=>{e||p.onFirstSubscribe?.(),e+=1;const r=1===n.length?t(n[0]):t(n[0],n[1],n[2]);return()=>{r(),e-=1,e||queueMicrotask(()=>{e||p.onLastUnsubscribe?.()})}}}function k(){g=!0,function(){if(p&&d.length){for(const e of d){const t=r.sessionId;for(const n of e.keys)u.set(n,[e.timestamp,t]);O(e.timestamp,e.keys),p.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values})}d.length=0}}()}function I(){F=!0,function(){if(!f.length)return;const e=f.slice();f.length=0;for(const t of e)T(t)}()}return n?(s.onHydrationComplete=k,s.onHydrationFlushEnd=I):p.onHydrated?(p.onHydrated(k),I()):(k(),I()),A},syncContext:s}}(e,c,a?.async??!1):void 0,f=u?.stateCreator??e;if(!n)return E()(v(f),Object.is);const d=a?.async?function(e){let t,n,r,o=!1;return{hydrationPromise:()=>o?t?.promise??n??(n=Promise.resolve()):(t||(t=P()),t.promise),stateCreator:(n,i,s)=>{let c;return r=()=>{if(c?.length){for(const e of c)e[1]?s.setState(e[0],e[1]):s.setState(e[0]);c=void 0}},e((...e)=>o?!0===e[1]?n(e[0],e[1]):n(e[0]):(t||(t=P()),c||(c=[]),c.push(e),t.promise),i,s)},wrapOnRehydrateStorage:(e,n)=>i=>{const s=e?.(i);return(e,i)=>{o=!0,n?.onHydrationComplete?.(),r&&r(),n?.onHydrationFlushEnd?.(),i?t?.fail(p(i)):t?.complete(),s?.(e,i)}}}}(f):null,h=function(e,t,n){const r=t??e.storage??o().storage,s=(e.sync?void 0:e.persistThrottleMs??W)||void 0,c=e.version??0,a=r.async?function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),s="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),c=t.partialize??N,a=t.deserializer??e.deserializer??H(o),u=t.serializer??e.serializer??U(o);async function l(t,n){try{if(_(r))return;n.state,n.state=c(n.state);const o=B(r,s,n),a=u(n);try{await e.set(t,a),Q(r,o)}catch(e){y.error(new i("[createBaseStore]: Failed to persist store data",e))}}catch(e){y.error(new i("[createBaseStore]: Failed to serialize persisted store data",e))}}const f=void 0!==n?$(l,n,{leading:!1,maxWait:n,trailing:!0}):function(e){let t,n=null;return function(...r){return t=r,n||(n=new Promise(r=>{queueMicrotask(async()=>{try{await e(...t)}finally{n=null,r()}})})),n}}(l);return{getItem:async t=>{const n=await e.get(t);return void 0===n?null:a(n)},setItem:async(e,t)=>{if(!r?.getIsApplyingRemote())return await f(e,t)},removeItem:async t=>{try{await e.delete(t)}catch(e){y.error(new i("[createBaseStore]: Failed to delete persisted store data",e))}}}}(r,e,s,n):function(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),s="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),c=t.partialize??N,a=t.deserializer??e.deserializer??H(o),u=t.serializer??e.serializer??U(o);function l(t,n){try{if(_(r))return;n.state,n.state=c(n.state);const o=B(r,s,n),a=u(n);try{e.set(t,a),Q(r,o)}catch(e){y.error(new i("[createBaseStore]: Failed to persist store data",e))}}catch(e){y.error(new i("[createBaseStore]: Failed to persist store data",e))}}const f=void 0!==n?$(l,n,{leading:!1,maxWait:n,trailing:!0}):l;return{getItem:t=>{const n=e.get(t);return void 0===n?null:a(n)},setItem:(e,t)=>{r?.getIsApplyingRemote()||f(e,t)},removeItem:t=>{try{e.delete(t)}catch(e){y.error(new i("[createBaseStore]: Failed to delete persisted store data",e))}}}}(r,e,s,n);return{persistStorage:a,version:c}}(t,a,u?.syncContext),g=d?d.wrapOnRehydrateStorage(t.onRehydrateStorage,u?.syncContext):t.onRehydrateStorage,m=d?(e,t,n)=>(u&&(u.syncContext.setWithoutPersist=n.setState),d.stateCreator(e,t,n)):f,S=E()(v(w(m,function(e,t,n){const r={name:e.storageKey,onRehydrateStorage:n,storage:t.persistStorage,version:t.version};return void 0!==e.merge&&(r.merge=e.merge),void 0!==e.migrate&&(r.migrate=e.migrate),r}(t,h,g))),Object.is);return d?Object.assign(S,{persist:Object.assign(S.persist,{hydrationPromise:d.hydrationPromise})}):S}var pe=!1,he=!1,ge=new Map,be=new Map,me=new Map,Se=null,ve=1/0;function we(){return pe}function Fe(){return Se}function Oe(){pe||(pe=!0,he||(he=!0,queueMicrotask(()=>{he=!1,h(()=>{for(;be.size>0;){const e=ve,t=me.get(e);if(t){me.delete(e);for(const e of t)be.delete(e);Se=e;for(const e of t)e();if(Se=null,me.size>0){ve=1/0;for(const e of me.keys())e<ve&&(ve=e)}else ve=1/0}else{ve=1/0;for(const e of me.keys())e<ve&&(ve=e)}}for(;ge.size>0;){const e=Array.from(ge.values());ge.clear();for(const t of e)t()}}),pe=!1,Se=null,be.clear(),me.clear(),ve=1/0})))}function qe(e,t){pe&&ge.set(e,t)}var je=Symbol("stores.deriveProxy.unwrap");function Ae(e,t,n){const r=t.get(e);if(void 0!==r)return r;const o=function(e,t,n,r=[]){return e&&"object"==typeof e?Ce(e,r,t,n,new WeakSet,new WeakMap):(n(t,r,!0),e)}(te(e)?e.getSnapshot():e.getState(),e,n);return t.set(e,o),o}function Ce(e,t,n,r,o,i){return new Proxy(e,{get(s,c,a){if(c===je)return r(n,t,!0),s;if(o.has(s))return Reflect.get(s,c,a);if("__proto__"===c||"symbol"==typeof c)return c===Symbol.iterator&&(r(n,t,!0),o.add(s)),Reflect.get(s,c,a);const u=Reflect.get(s,c,s),l=String(c),f=t.concat(l);if("function"==typeof u)return Object.prototype.hasOwnProperty.call(s,c)?function(...e){return r(n,f,!0,{method:l,args:e.length?e:void 0}),Reflect.apply(u,s,e)}:(r(n,t,!0),u.bind(e));const d=!!u&&"object"==typeof u;return r(n,f,!d),d?(i.has(u)||i.set(u,Ce(u,f,n,r,o,i)),i.get(u)):u},getOwnPropertyDescriptor:(e,i)=>(r(n,t,!0),o.add(e),Reflect.getOwnPropertyDescriptor(e,i)),has:(e,o)=>(r(n,t,!0),Reflect.has(e,o)),ownKeys:e=>(r(n,t,!0),o.add(e),Reflect.ownKeys(e))})}function Te(e,t){if(!e||"object"!=typeof e)return e;const n=function(e){const t=Reflect.get(e,je);return t&&"object"==typeof t?t:void 0}(e);return n||(Array.isArray(e)?function(e,t){const n=Ie(e,t);if(n)for(let t=0;t<e.length;t++)ke(e,String(t),n)}(e,t):u(e)&&function(e,t){const n=Ie(e,t);if(n)for(const t of Reflect.ownKeys(e))ke(e,t,n)}(e,t),e)}function ke(e,t,n){const r=Reflect.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r))return;const o=Te(r.value,n);o!==r.value&&(r.value=o,Reflect.defineProperty(e,t,r))}function Ie(e,t){const n=t??new WeakSet;return n.has(e)?null:(n.add(e),n)}function ze(e,t,n="s"){return 1===t?e:`${e}${n}`}var De=Object.freeze([]);function Me(){const e=new Map;return{buildProxySubscriptions(t,n,r,o){const i=new Set;for(const t of e)Ke(t[1],t[0],[],0,i,r);!1!==o?.(i)&&function(e,t,n){for(const n of e){const e=n.invocation?$e(n.path,n.invocation):Re(n.path);t(n.store,e,n.path)}n&&function(e){const t=e.size;console.log(`[π‘ ${t} ${ze("Proxy Subscription",t)} π‘]:`,JSON.stringify(Array.from(e).map(e=>{const t="name"in(n=e.store)&&"string"==typeof n.name?n.name:"store";var n;const r=e.path.join(".");if(!e.invocation)return r?`$(${t}).${r}`:`$(${t})`;const o=e.invocation.args?.length??0;return`$(${t}).${r}${o?`(${o}_${ze("arg",o)})`:"()"}`}),null,2))}(e)}(i,t,n)},reset(){e.clear()},trackPath(t,n,r,o){let i=e.get(t);i||(i=Ee(),e.set(t,i)),Pe(i,n,0,r,o)}}}function Ee(){return l()}function Pe(e,t,n,r,o){if(n===t.length)return r&&(e.isLeaf=!0),void(o&&(e.invocation=o));e.children||(e.children=Ee());const i=t[n];let s=e.children?.[i];s||(s=Ee(),e.children[i]=s),Pe(s,t,n+1,r,o)}function Ke(e,t,n,r,o,i=2){const s=e.children;if(!s)return void o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});const c=Object.keys(s),a=c.length;if(0!==a)if(e.isLeaf||r>=i&&a>1){o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1});for(const e of c){const c=s[e];c.invocation&&Ke(c,t,[...n,e],r+1,o,i)}}else if(r<i&&a>1&&!e.isLeaf)for(const e of c)Ke(s[e],t,[...n,e],r+1,o,i);else{if(1===a){const e=c[0];return void Ke(s[e],t,[...n,e],r+1,o,i)}o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}else o.add({store:t,path:n,invocation:e.invocation,isLeaf:e.isLeaf??!1})}function Re(e){return t=>Le(t,e)}function $e(e,t){const n=e.slice(0,-1);return e=>{const r=Le(e,n),o=r&&"object"==typeof r?Reflect.get(r,t.method):void 0;return"function"==typeof o?Reflect.apply(o,r,t.args??De):void 0}}function Le(e,t){let n=e;for(const e of t){if(!n||"object"!=typeof n)return n;n=Reflect.get(n,e)}return n}function xe(e,t=Object.is){return n=function(e,t=Object.is){const{debounceOptions:n,debugMode:r,equalityFn:o,keepAlive:i,lockDependencies:a}="function"==typeof(f=t)?{debounceOptions:void 0,debugMode:!1,equalityFn:f,keepAlive:!1,lockDependencies:!1}:{debounceOptions:f.debounce,debugMode:(c&&f.debugMode)??!1,equalityFn:f.equalityFn??Object.is,keepAlive:f.keepAlive??!1,lockDependencies:f.lockDependencies??!1},u=String(We+=1),l=new Set;var f;i&&l.add(He);const d=new Set;let y,p,h=Ne,g=!1,b=!0,m=!0,S=0,v=!1,w=null,F=Ne;function O(e,t,n){return m&&l.size?t?(d.add(e.subscribe(t,E,n?{equalityFn:n,isDerivedStore:!0}:Ve)),t(te(e)?e.getSnapshot():e.getState())):(y||(y=new WeakMap),p||(p=Me()),Ae(e,y,p.trackPath)):(t??s)(te(e)?e.getSnapshot():e.getState())}function q(e){for(const t of d)t(e);d.clear()}let j=!0;function A(){if(!b&&Ue(h))return h;b=!1,m&&q(!0);const t=h,n=Ue(t);h=function(t){j=!0;const n=h,i=e(t),s=p?Te(i):i;return Ue(n)&&o(n,s)?(r&&console.log("[π₯· Derive Complete π₯·]: No change detected"),j=!1,n):s}(O);const i=r&&(!n||"verbose"===r&&m);if(i){n?"verbose"===r&&console.log("[π Rebuilding Subscriptions π]: Createdβ¦"):console.log("[π Initial Derive Complete π]: Createdβ¦");const e=d.size;console.log(`[π― ${e} ${ze("Selector Subscription",e)} π―]`)}return p&&m&&(p.buildProxySubscriptions((e,t)=>{d.add(e.subscribe(t,E,Ve))},i),y=void 0,p.reset(),a&&(p=void 0)),j&&n&&function(e,t){const n=function(){const e=l.has(He)?l.size-1:l.size;return S>0&&S<e}(),o=!S||n,i=n||null!==Fe()||we()&&o;n&&Oe(),r&&console.log(`[π» Derive Complete π»]: Notifying ${l.size} ${ze("watcher",l.size)}`);for(const t of l){if("function"==typeof t||!t.isDerivedWatcher)continue;const n=t.selector(e);if(!t.equalityFn(t.currentSlice,n)){const e=t.currentSlice;t.currentSlice=n,t.listener(n,e)}}i?v||(v=!0,Ue(F)||(F=t),qe(u,T)):C(e,t)}(h,t),a&&(m=!1),h}function C(e,t){for(const n of l)if("function"==typeof n)n(e,t);else if(!n.isDerivedWatcher){const t=n.selector(e);if(!n.equalityFn(n.currentSlice,t)){const e=n.currentSlice;n.currentSlice=t,n.listener(t,e)}}}function T(){if(!l.size)return;if(b&&!S&&A(),!Ue(h))return;const e=Ue(F)?F:h;C(h,e),v=!1,F=Ne}const k=n?$(z,"number"==typeof n?n:n.delay,"number"==typeof n?{leading:!1,maxWait:n,trailing:!0}:n):void 0,I=k??(()=>{g||(g=!0,queueMicrotask(z))});function z(){g=!1,l.size?b&&A():K()}function D(e){e||k&&b?queueMicrotask(()=>{l.size||K()}):K()}function M(){z(),w=null}function E(){if(!b){if(b=!0,!k){if(S){Oe();const e=Fe(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!pe)return;const n=t<0?0:0|t,r=be.get(e);if(void 0===r){be.set(e,n);let t=me.get(n);return t||(t=new Set,me.set(n,t)),t.add(e),void(n<ve&&(ve=n))}if(n>r){const t=me.get(r);if(t&&(t.delete(e),0===t.size&&(me.delete(r),r===ve))){ve=1/0;for(const e of me.keys())e<ve&&(ve=e)}be.set(e,n);let o=me.get(n);o||(o=new Set,me.set(n,o)),o.add(e),n<ve&&(ve=n)}}(M,t)}if(we())return void(v||(v=!0,Ue(h)&&(F=h),qe(u,T)))}w=null,I()}}function P(){return b||!Ue(h)?l.size>0?A():e(O):h}function K(e=!0){i&&e||(k?.cancel(),q(),l.clear(),S=0,p=void 0,y=void 0,m=!0,g=!1,b=!0,h=Ne,v=!1,F=Ne,w=null)}return{destroy:()=>K(!1),flushUpdates:function(){l.size&&(k?k.flush():b&&A())},getSnapshot:function(){if(!Ue(h)){l.add(He);const e=A();return l.delete(He),e}return g&&z(),h},getState:P,subscribe:function(...e){if(1===e.length){const t=e[0];return l.add(t),1!==l.size||Ue(h)||P(),()=>{l.delete(t),l.size||D(!1)}}const[t,n,r]=e,o=r?.equalityFn??Object.is,i=r?.isDerivedStore??!1,s={currentSlice:void 0,equalityFn:o,isDerivedWatcher:i,listener:n,selector:t};return l.add(s),s.currentSlice=t(P()),i&&(S+=1),r?.fireImmediately&&n(s.currentSlice,s.currentSlice),()=>{l.delete(s),i&&(S-=1),l.size||D(i)}},getInitialState:()=>{throw new Error("[createDerivedStore]: getInitialState() is not available on derived stores.")},setState:()=>{throw new Error("[createDerivedStore]: setState() is not available on derived stores.")}}}(e,t),Object.assign(function(e=s,t){return k(n.subscribe,n.getSnapshot,void 0,e,t)},n);var n}var Ne=Symbol(),Ve=Object.freeze({equalityFn:Object.is,isDerivedStore:!0}),We=0;function He(){}function Ue(e){return e!==Ne}var Je,Be=class{constructor({disableAutoRefetching:e,initialEnabled:t}){this.count=0,this.enabled=!1,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,this.enabled=t,e&&(this.fetchThrottleMs=V.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}get(){return{enabled:this.enabled,lastSubscriptionTime:this.lastSubscriptionTime,subscriptionCount:this.count}}setEnabled(e){this.enabled=e}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.onSubscribe?.(this.enabled,e,t),this.count+=1,this.lastSubscriptionTime=Date.now(),e=>{const t=1===this.count;this.count=Math.max(this.count-1,0),t&&(this.onLastUnsubscribe?.(e),this.lastSubscriptionTime=null)}}};function Qe(e,t){const n=t?.baseDelay??V.seconds(5),r=t?.maxDelay??V.minutes(5);return Math.min(n*Math.pow(2,e),r)}var _e={Error:"error",Idle:"idle",Loading:"loading",Success:"success"};function Ge(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!(r in t)||!Ge(e[r],t[r]))return!1;return!0}function Xe(e,t){if("object"!=typeof e||null==e||"object"!=typeof t||null==t)return e===t;if(Object.is(e,t))return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.is(e[r],t[r]))return!1;return!0}function Ye(e,t){const n=Object.prototype.hasOwnProperty;function r(e,t){for(const n of e.keys())if(Ye(n,t))return n}let o,i,s;if(e===t)return!0;if(e&&t&&(o=e.constructor)===t.constructor){if(o===Date)return e.getTime()===t.getTime();if(o===RegExp)return e.toString()===t.toString();if(o===Array){if((i=e.length)===t.length)for(;i--&&Ye(e[i],t[i]););return-1===i}if(o===Set){if(e.size!==t.size)return!1;for(let n of e){if(s=n,s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!t.has(s))return!1}return!0}if(o===Map){if(e.size!==t.size)return!1;for(let n of e){if(s=n[0],s&&"object"==typeof s&&(s=r(t,s),!s))return!1;if(!Ye(n[1],t.get(s)))return!1}return!0}if(o===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(o===DataView){if((i=e.byteLength)===t.byteLength)for(;i--&&e.getInt8(i)===t.getInt8(i););return-1===i}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){const n=e,r=t;if((i=n.byteLength)===r.byteLength)for(;i--&&n[i]===r[i];);return-1===i}if(!o||"object"==typeof e){i=0;for(const r in e){if(n.call(e,r)&&++i&&!n.call(t,r))return!1;if(!(r in t)||!Ye(e[r],t[r]))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}var Ze=new WeakMap,et=new WeakMap;function tt(e,t=nt,n=Ye){return function(e,t,n){let r=et.get(e);r||(r=new Map,et.set(e,r));let o=r.get(t);o||(o=new Map,r.set(t,o));const i=o.get(n);if(i)return i;const[s,c,a]=ot(e,t,n),u=new Map,f=e=>{const t={get(t,n){if("value"===n){let t=c();const n=e.split(".");for(const e of n)e&&(t=t[e]);return t}const r="string"==typeof n?n:n.toString(),o=e?`${e}.${r}`:r,i=u.get(o);if(i)return i;const a=f(o);return Ze.set(a,s),u.set(o,a),a},set(t,n,r){const o=e.split(".");return""===o[0]&&o.shift(),a(o,r),!0}};return new Proxy(l(),t)},d=f("");return s(()=>{}),Ze.set(d,s),o.set(n,d),d}(e,t,n)}var nt=e=>e,rt=(e,t,n)=>{if(!t.length)return n;const[r,...o]=t,i=e[r],s=rt(i,o,n);if(Ye(i,s))return e;const c=Array.isArray(e)?e.slice():{...e};return c[r]=s,c},ot=(e,t,n)=>{const r=new Set,o=te(e);let i,s=t(o?e.getSnapshot():e.getState());return[c=>(r.size||(i=e.subscribe(t,e=>{s=e,r.forEach(e=>e())},{equalityFn:n,isDerivedStore:o})),r.add(c),()=>{r.delete(c),!r.size&&i&&(i(),i=void 0)}),()=>(r.size||(s=t(e.getState())),s),(n,r)=>{if(t!==nt)throw new Error("Cannot set a value with a selector");e.setState(e=>rt(e,n,r),!0)}]};function it(e){return Ze.get(e)}var st={error:!0,lastFetchedAt:!0,queryCache:!0,queryKey:!0,status:!0,enabled:!1,fetch:!1,getCacheEntry:!1,getData:!1,getStatus:!1,isDataExpired:!1,isStale:!1,reset:!1},ct=Object.freeze({force:!0}),at=Object.freeze({once:!0}),ut=Object.freeze({updateQueryKey:!0});function lt(t,n,o){r();const s="function"==typeof n?n:wt,u="object"==typeof n?n:o,d=u&&"storageKey"in u?u:void 0,h=Je??(Je=function(){const e={abortInterruptedFetches:!0,cacheTime:V.days(7),debugMode:!1,disableAutoRefetching:!1,keepPreviousData:!1,maxRetries:5,minStaleTime:!1,paramChangeThrottle:!1,retryDelay:Qe,staleTime:V.minutes(2),suppressStaleTimeWarning:!1},t=g()?.queryStoreDefaults;return t?{...e,...t}:e}()),b=h.minStaleTime,{fetcher:m,onError:S,onFetched:v,setData:w,transform:F,abortInterruptedFetches:O=h.abortInterruptedFetches,cacheTime:q=h.cacheTime,debugMode:j=h.debugMode,disableAutoRefetching:A=h.disableAutoRefetching,disableCache:C=!1,enabled:T=!0,keepPreviousData:k=h.keepPreviousData,maxRetries:I=h.maxRetries,paramChangeThrottle:z=h.paramChangeThrottle,params:D,retryDelay:M=h.retryDelay,staleTime:E=h.staleTime,suppressStaleTimeWarning:P=h.suppressStaleTimeWarning}=t;let K="function"==typeof E?h.staleTime:E;c&&!1!==b&&!A&&!P&&K<b&&console.warn(`[createQueryStore${d?.storageKey?`: ${d.storageKey}`:""}] β Stale times under ${b/1e3} seconds are not recommended. Provided staleTime: ${K/1e3} seconds`);const R=new Error("[createQueryStore: AbortError] Fetch interrupted"),L="function"==typeof q,x=c&&j,N=t.params?Object.keys(t.params):[];let W=null,H=null,U=null,J=[],B=!1,Q=!1,_=null,X=null,Y=null,Z=null,ee=null;const te={enabled:"function"!=typeof T&&T,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:_e.Idle},ne=new Be({disableAutoRefetching:A,initialEnabled:te.enabled});function re(){_&&(X=null,_.abort(),_=null)}function oe(e,n,r){const o=r.setState;function c(e){const t="function"==typeof e;if(t||void 0!==e.enabled){let n;const r=o(r=>{const o=t?e(r):e,i=void 0!==o.enabled?o.enabled:r.enabled;return i!==r.enabled&&(n=()=>function(e,t){e!==t&&ee!==t&&(ee=t,ne.setEnabled(t),t?queueMicrotask(()=>u.fetch(void 0,ut)):(Y||O)&&(O&&re(),Y&&(clearTimeout(Y),Y=null)))}(r.enabled,i)),o});return n?.(),r}return o(e)}function a(e,t){if(A||t?.skipStoreUpdates)return;if(K<=0||K===1/0)return;Y&&(clearTimeout(Y),Y=null);const r=ft(e),o=n(),i=(C?Z===r&&o.lastFetchedAt:o.queryCache[r]?.lastFetchedAt)||null,s=i?K-(Date.now()-i):K;Y=setTimeout(()=>{const t=ne.get();t.enabled&&t.subscriptionCount>0&&u.fetch(e,ct,!0)},s)}r.setState=c,ne.init({onSubscribe:(r,o,i)=>{if(H||W||!D&&"function"!=typeof t.enabled&&"function"!=typeof t.staleTime){if(r)if(o){const t=ht(W,H),r=ft(t),o=n();o.queryKey!==r&&e({queryKey:r}),o.isStale()?u.fetch(t,void 0,!0):a(t,void 0)}else A&&!i&&u.fetch(void 0,void 0,!0)}else B=!0},onLastUnsubscribe:e=>{Y&&(clearTimeout(Y),Y=null),O&&!e&&re()}});const u={...s(c,n,r),...te,async fetch(t,r,o=!1){const s=ne.get();if(!r?.force&&!r?.skipStoreUpdates&&!s.enabled)return null;const l=n(),f=l.error,h=l.queryKey,g=l.status===_e.Loading,b=pt(W,H,N,t),j=ft(b);if(g&&X?.promise&&X.key===j)return x&&console.log("[π Using Active Fetch π] for params:",JSON.stringify(b)),X.promise;const A=r?.staleTime??K,T=!!r?.skipStoreUpdates,z="boolean"==typeof r?.updateQueryKey?r.updateQueryKey:!!o&&k,D=(o||h===j||z)&&!T;if(O&&D&&re(),!r?.force){const t=l.lastFetchedAt,n=l.queryCache[j],o=n?.lastFetchedAt,i=n?.errorInfo,c=i&&i.retryCount>=I,u=(C?Z===j&&t:o)||null;if(u&&!(Date.now()-u>=A)&&(!i||c||T))return D&&!Y&&s.subscriptionCount>0&&0!==K&&K!==1/0&&a(b,r),z&&e(e=>e.queryKey!==j?{queryKey:j}:e),x&&console.log("[πΎ Returning Cached Data πΎ] for params:",JSON.stringify(b)),n?.data??null}D&&(Y&&(clearTimeout(Y),Y=null),!f&&g||e({error:null,status:_e.Loading}),X={key:j});const E=r?.cacheTime??(L?q(b):q);async function P(){const s=d?.storageKey||j;try{x&&(o||!t||gt(t,N)?console.log("[π Fetching π] for params:",JSON.stringify(b)):console.log("[π Fetching with Partial Params π]\n","- Provided params:",`${JSON.stringify(t)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(b).filter(e=>!(e in t)).map(e=>[e,b[e]])))}`));const n=await(O&&D?async function(e){const t=new AbortController;_=t;try{return await new Promise((n,r)=>{t.signal.addEventListener("abort",()=>r(R),at),Promise.resolve(m(e,t)).then(n,r)})}finally{_===t&&(_=null)}}(b):m(b,null)),i=Date.now();let l;x&&console.log("[β
Fetch Successful β
] for params:",JSON.stringify(b));try{l=function(e,t,n){return n?n(e,t):e}(n,b,F)}catch(e){throw Ft(s,"transform",e)}if(T)return x&&console.log("[π₯· Successful Parallel Fetch π₯·] for params:",JSON.stringify(b)),"withCache"===r.skipStoreUpdates&&e(e=>{if(!w)return C?e:{queryCache:{...e.queryCache,[j]:{cacheTime:E,data:l,errorInfo:null,lastFetchedAt:i}}};let t=e;const n=t.queryCache[j];try{w({data:l,params:b,queryKey:j,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Ft(s,"setData",e)}return!C&&Object.is(n,t.queryCache[j])&&(t={...t,queryCache:{...t.queryCache,[j]:{cacheTime:E,data:null,errorInfo:null,lastFetchedAt:i}}}),t}),l;if((w?c:e)(e=>{let t={...e,error:null,lastFetchedAt:i,queryKey:z?j:e.queryKey,status:_e.Success};if(w||C){if(w){x&&console.log("[πΎ Setting Data πΎ] for params:",JSON.stringify(b));const e=t.queryCache[j];try{w({data:l,params:b,queryKey:j,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw Ft(s,"setData",e)}!C&&Object.is(e,t.queryCache[j])&&(t.queryCache={...t.queryCache,[j]:{cacheTime:E,data:null,errorInfo:null,lastFetchedAt:i}})}}else x&&console.log("[πΎ Setting Cache πΎ] for params:",JSON.stringify(b),"| Has previous data?:",!!t.queryCache[j]?.data),t.queryCache={...t.queryCache,[j]:{cacheTime:E,data:l,errorInfo:null,lastFetchedAt:i}};return C||q===1/0?t:vt(k,j,t)}),D&&(Z=j,a(b,r)),v)try{v({data:l,fetch:u.fetch,params:b,set:c})}catch(e){y.error(Ft(s,"onFetched callback",e))}return l??null}catch(c){if(c===R)return x&&console.log("[β Fetch Aborted β] for params:",JSON.stringify(b)),null;const a=!o&&!0===r?.throwOnError,l=p(c);if(l instanceof i&&y.error(l),!D){if(a)throw l;return null}const f=C?void 0:n().queryCache[j],d=f?.errorInfo?.retryCount??0,h=d+1;try{S?.(l,d)}catch(e){y.error(Ft(s,"onError callback",e))}if(d<I){if(ne.get().subscriptionCount>0){const e="function"==typeof M?M(h,l):M;e!==1/0&&(Y&&clearTimeout(Y),Y=setTimeout(()=>{const e=ne.get();e.enabled&&e.subscriptionCount>0&&u.fetch(t,ct,!0)},e))}e(e=>({error:l,queryCache:{...e.queryCache,[j]:{cacheTime:f?.cacheTime??E,data:f?.data??null,lastFetchedAt:f?.lastFetchedAt??null,errorInfo:{error:l,lastFailedAt:Date.now(),retryCount:h}}},queryKey:z?j:e.queryKey,status:_e.Error}))}else e(e=>({error:l,queryCache:{...e.queryCache,[j]:{cacheTime:f?.cacheTime??E,data:f?.data??null,lastFetchedAt:f?.lastFetchedAt??null,errorInfo:{error:l,lastFailedAt:Date.now(),retryCount:I}}},queryKey:z?j:e.queryKey,status:_e.Error}));if(a)throw l;return null}finally{D&&(X=null)}}return D?(X={key:j,promise:P()}).promise:P()},getCacheEntry(e){if(C)return null;const t=n(),r=e?"string"==typeof e?e:ft(pt(W,H,N,e)):t.queryKey;return t.queryCache[r]??null},getData(e){if(C)return null;const t=n().getCacheEntry(e);return t&&null!==t.data?k?t.data:t.lastFetchedAt&&Date.now()-t.lastFetchedAt>=t.cacheTime?null:t.data:null},getStatus:function(e){const t=n(),r=t.status;switch(e){case"isIdle":return r===_e.Idle;case"isLoading":return r===_e.Loading;case"isError":case"isInitialLoad":case"isSuccess":case void 0:{const n=t.queryKey,o=t.queryCache[n],i=C?r===_e.Error:"number"==typeof o?.errorInfo?.lastFailedAt;if("isError"===e)return i;const s=null!==((C?Z===n&&t.lastFetchedAt:o?.lastFetchedAt)||null),c=!s&&!i&&t.enabled;if("isInitialLoad"===e)return c;const a=s&&!i;return"isSuccess"===e?a:{isError:i,isIdle:r===_e.Idle,isLoading:r===_e.Loading,isInitialLoad:c,isSuccess:a}}}},isDataExpired(e){const t=n(),r=t.queryCache[t.queryKey],o=t.queryKey,i=t.lastFetchedAt,s=(C?Z===o&&i:r?.lastFetchedAt)||null;if(!s)return!0;const c=e??r?.cacheTime;return void 0===c||Date.now()-s>=c},isStale(e){const t=n(),r=t.queryKey,o=(C?Z===r&&t.lastFetchedAt:t.queryCache[r]?.lastFetchedAt)||null;if(!o)return!0;const i=e??K;return Date.now()-o>=i},reset(t=!1){for(const e of J)e();J=[],W=null,H=null,U=null,re(),Y&&(clearTimeout(Y),Y=null),X=null,Z=null,t&&e(te)}},l=r.subscribe;return r.subscribe=(...e)=>{const t=Q?()=>{}:ne.subscribe(),n=1===e.length?l(e[0]):l(e[0],e[1],e[2]);return e=>{t(e),n()}},u}const ie=d?.storageKey?ye(oe,a(d,{partialize:St(k,d.partialize)})):u&&!("storageKey"in u)?ye(oe,u):ye(oe),se=ie.getState(),ce=se.error,ae=se.enabled,ue=se.queryKey,le=se.fetch;let fe;if(ue&&!ce&&(Z=ue),Q=!0,D||"function"==typeof t.enabled){const{directValues:e,enabledAttachVal:t,enabledDirectValue:n,attachVals:r}=function(e,t,n){const r=l(),o=l(),i=l();for(const e in t){if(!f(t,e))continue;const s=t[e];if(bt(s)){const t=s(tt,n);r[e]=t,i[e]=t.value}else mt(s)&&(o[e]=s,i[e]=s)}let s,c=null,a=null;if(bt(e)){const t=e(tt,n);s=t.value,c=t}else s=e,a=e;return{attachVals:r,directValues:o,enabledAttachVal:c,enabledDirectValue:a,resolvedEnabled:s,resolvedParams:i}}(T,D,ie);W={enabled:t,params:r},H={enabled:n,params:e}}"function"==typeof t.staleTime&&(U=t.staleTime(tt,ie),K=U.value);const de=Object.freeze({updateQueryKey:k}),pe=function(){let e,t=!1;return function(...n){e=n,t||(t=!0,queueMicrotask(()=>{t=!1,(e=>{le(e??ht(W,H),de)})(...e)}))}}();function he(){let e;if(!k){e=ht(W,H);const t=ft(e);ie.setState({queryKey:t})}pe(e)}const ge=e||!z?he:$(he,"number"==typeof z?z:z.delay,"number"==typeof z?{leading:!1,maxWait:z,trailing:!0}:z);for(const e in W?.params){const t=W.params[e];if(!t)continue;const n=it(t);if(x&&console.log("[π Param Subscription π] Subscribed to param:",e),n){let r=t.value;const o=n(()=>{const n=t.value;Ye(r,n)||(x&&console.log("[π Param Change π] -",e,"- [Old]:",`${r?.toString()},`,"[New]:",n?.toString()),r=n,ge())});J.push(o)}}if(U){const e=it(U);if(e){const t=U;let n=t.value;x&&console.log("[π StaleTime Subscription π] Initial value:",n);const r=e(()=>{const e=t.value;e!==n&&(x&&console.log("[π StaleTime Change π] - [Old]:",`${n},`,"[New]:",e),n=e,K=e,le())});J.push(r)}}if(W?.enabled){const e=W.enabled,t=it(e);if(t){let n=e.value;ae!==n&&((fe??(fe={})).enabled=n),n&&ne.setEnabled(n),x&&console.log("[π Enabled Subscription π] Initial value:",n);const r=t(()=>{const t=e.value;t!==n&&(x&&console.log("[π Enabled Change π] - [Old]:",`${n},`,"[New]:",t),n=t,ie.setState({enabled:t}))});J.push(r)}}else ae!==te.enabled&&((fe??(fe={})).enabled=te.enabled);const be=ft(ht(W,H));return be!==ue&&((fe??(fe={})).queryKey=be),fe&&ie.setState(fe),Q=!1,B&&queueMicrotask(ge),me=ie,Se=G.QueryStore,Object.assign(me,{[Se]:!0});var me,Se}function ft(e){return JSON.stringify(yt(e))}function dt(e){return JSON.parse(e)}function yt(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,n)=>{const r=e[n];return t[n]=u(r)?yt(r):r,t},l())}function pt(e,t,n,r){return r?gt(r,n)?r:{...ht(e,t),...r}:ht(e,t)}function ht(e,t){const n=Object.assign(l(),t?.params);for(const t in e?.params){const r=e.params[t];r&&(n[t]=r.value)}return n}function gt(e,t){if(!e)return!1;for(const n of t)if(!(n in e))return!1;return!0}function bt(e){return"function"==typeof e}function mt(e){return!bt(e)}function St(e,t){return n=>{const r={...n},o=l();for(const e in r)f(r,e)&&e in st&&(st[e]&&(o[e]=r[e]),delete r[e]);return{...t?t(r):N(r),...vt(e,null,o)}}}function vt(e,t,n){if(!n.queryCache)return n;const r=Date.now(),o=t??(e&&n.queryKey||null),i=l();let s=!1;for(const e in n.queryCache){if(!f(n.queryCache,e))continue;const c=n.queryCache[e];c&&(r-(c.lastFetchedAt??c.errorInfo.lastFailedAt)<c.cacheTime||e===o)?!t&&c.errorInfo&&c.errorInfo.retryCount>0?(i[e]={...c,errorInfo:{...c.errorInfo,retryCount:0}},s=!0):i[e]=c:s=!0}return s?{...n,queryCache:i}:n}function wt(){return Object.create(null)}function Ft(e,t,n){return new i(`[createQueryStore: ${e}]: ${t} failed`,n)}function Ot(e,t,n){const r="function"==typeof t,o=r?t:void 0,i=r?n:t,s=new Set,c=xe(e,{debugMode:i?.debugMode??!1,equalityFn:function(e,t){const n=Object.is(e,t);return n||(function(e,t){for(const n of s){n.unsubscribe();const r=n.args;if(1===r.length){const o=r[0],i=e.getState(),s=t.getState(),c=t.subscribe(o);n.unsubscribe=c,Object.is(s,i)||o(s,i);continue}const o=r[0],i=r[1];let s=r[2];s?.fireImmediately&&(s={...s,fireImmediately:!1});const c=o(e.getState()),a=o(t.getState()),u=t.subscribe(o,i,s);n.unsubscribe=u,(s?.equalityFn??Object.is)(c,a)||i(a,c)}}(e,t),Y(e)),n},keepAlive:!0,lockDependencies:i?.lockDependencies??!0});return Object.assign(function(e,t){const n=c();return e?n(e,t):n()},{[G.VirtualStore]:!0,destroy:c.destroy,getInitialState:()=>c.getState().getInitialState(),getState:()=>c.getState().getState(),persist:(a=c.getState,{clearStorage:()=>a().persist?.clearStorage(),getOptions:()=>a().persist?.getOptions()??{},hasHydrated:()=>a().persist?.hasHydrated()??!0,hydrationPromise:()=>a().persist?.hydrationPromise?.()??Promise.resolve(),onFinishHydration:e=>a().persist?.onFinishHydration(e)??d,onHydrate:e=>a().persist?.onHydrate(e)??d,rehydrate:()=>a().persist?.rehydrate(),setOptions:e=>a().persist?.setOptions(e)}),setState:qt(c.getState),subscribe:function(...e){const t={args:e,unsubscribe:1===e.length?c.getState().subscribe(e[0]):c.getState().subscribe(e[0],e[1],e[2])};return s.add(t),()=>{t.unsubscribe(),s.delete(t)}}},o?.(c.getState));var a}function qt(e){return function(t,n){return n?e().setState(t,n):e().setState(t)}}var jt=Symbol(),At=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1});function Ct(e,t,n,r=At){const o=function(){const e=q(jt);return e.current===jt&&(e.current=function(e,t,n){return{selector:e,react:t,isActive:!1,options:It(n),resubscribe:()=>{},unsubscribe:()=>{}}}(t,n,r)),e}(),i=function(e){return"function"==typeof e?At.enabled:e?.enabled??At.enabled}(r);return o.current.react=n,o.current.selector=t,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??At)}(o,r),O(()=>{if(i)return kt(e,o),()=>function(e){e.current.options.debugMode&&console.log("[ποΈ useListen ποΈ] Detaching listener"),e.current.resubscribe=()=>{},e.current.unsubscribe(),e.current.unsubscribe=()=>{},e.current.isActive=!1}(o)},[i,e]),o}var Tt=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function kt(e,t,n=Tt){if(t.current.isActive){if(!n?.forceResubscribe)return;t.current.unsubscribe()}t.current.options.debugMode&&console.log("[π‘ useListen π‘] Attaching listener"),t.current.isActive=!0,t.current.resubscribe=(n=Tt)=>kt(e,t,n);const r=e.subscribe(e=>t.current.selector(e),(e,n)=>t.current.react(e,n,()=>{r(),t.current.isActive=!1}),n.fireImmediately?{...t.current.options,fireImmediately:!0}:t.current.options);t.current.unsubscribe=()=>{t.current.isActive&&(r(),t.current.isActive=!1)}}function It(e){return"function"==typeof e?{equalityFn:e}:e??At}var zt=Symbol();function Dt(e){const t=q(zt);return t.current===zt&&(t.current=e()),t.current}function Mt(e,t){const n=function(e){const t=e.getState(),n=l(),r=n;if(c&&("object"!=typeof t||null===t))throw new Error("[createStoreActions]: State is not an object");if(ie(e))for(const n in t)Pt(t,n)&&(r[n]=Et(e,n));else for(const e in t)Pt(t,e)&&(r[e]=t[e]);return n}(e);return t?Object.assign(n,t):n}function Et(e,t){return function(...n){const r=e.getState()[t];if("function"==typeof r)return r(...n);throw new Error(`[createVirtualStoreAction]: Method ${String(t)} is not a function`)}}function Pt(e,t){return"function"==typeof e[t]}export{_e as QueryStatuses,X as applyStateUpdate,ye as createBaseStore,xe as createDerivedStore,lt as createQueryStore,Mt as createStoreActions,Ot as createVirtualStore,Ge as deepEqual,Qe as defaultRetryDelay,Y as destroyStore,Z as destroyStores,ft as getQueryKey,ee as getStoreName,te as hasGetSnapshot,re as isDerivedStore,oe as isPersistedStore,ne as isQueryStore,ie as isVirtualStore,dt as parseQueryKey,Xe as shallowEqual,V as time,Ct as useListen,Dt as useStableValue};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storesjs/stores",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"repository": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"main": "dist/web/index.js",
|
|
22
22
|
"module": "dist/web/index.mjs",
|
|
23
|
-
"types": "dist/
|
|
23
|
+
"types": "dist/index.d.ts",
|
|
24
24
|
"react-native": "dist/native/index.js",
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
@@ -41,12 +41,11 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"
|
|
45
|
-
"zustand": "5.0.8"
|
|
44
|
+
"zustand": "5.0.10"
|
|
46
45
|
},
|
|
47
46
|
"peerDependencies": {
|
|
48
|
-
"react": ">=
|
|
49
|
-
"react-native": ">=0.
|
|
47
|
+
"react": ">=18.0.0",
|
|
48
|
+
"react-native": ">=0.69.0",
|
|
50
49
|
"react-native-mmkv": ">=2.0.0"
|
|
51
50
|
},
|
|
52
51
|
"peerDependenciesMeta": {
|
|
@@ -62,9 +61,12 @@
|
|
|
62
61
|
"@types/jest": "^29.5.14",
|
|
63
62
|
"@types/node": "^22.19.5",
|
|
64
63
|
"@types/react": "^19.1.1",
|
|
65
|
-
"@types/
|
|
64
|
+
"@types/react-dom": "^19.1.1",
|
|
66
65
|
"esbuild": "^0.25.10",
|
|
66
|
+
"happy-dom": "^20.9.0",
|
|
67
67
|
"jest": "^29.7.0",
|
|
68
|
+
"madge": "^8.0.0",
|
|
69
|
+
"react-dom": "^19.1.1",
|
|
68
70
|
"terser": "^5.44.0",
|
|
69
71
|
"ts-jest": "^29.3.4",
|
|
70
72
|
"tsup": "^8.5.0",
|
|
@@ -72,23 +74,26 @@
|
|
|
72
74
|
"vitest": "^2.0.0"
|
|
73
75
|
},
|
|
74
76
|
"scripts": {
|
|
75
|
-
"analyze": "pnpm run prebuild:web && tsx scripts/analyze-bundle.ts && pnpm run postbuild:web",
|
|
76
|
-
"build": "tsx scripts/build.ts",
|
|
77
|
+
"analyze": "pnpm run prebuild:web && tsx --tsconfig scripts/tsconfig.json scripts/analyze-bundle.ts && pnpm run postbuild:web",
|
|
78
|
+
"build": "tsx --tsconfig scripts/tsconfig.json scripts/build.ts",
|
|
77
79
|
"build:dev": "pnpm run build:types && NODE_ENV=development pnpm run build:web && NODE_ENV=development pnpm run build:native",
|
|
78
80
|
"build:native": "pnpm run -s prebuild:native && BUILD_TARGET=native tsup --config tsup.config.ts --out-dir dist/native && pnpm run -s postbuild:native",
|
|
79
81
|
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
80
82
|
"build:web": "pnpm run -s prebuild:web && tsup --config tsup.config.ts --out-dir dist/web && pnpm run -s postbuild:web",
|
|
81
|
-
"generate:exports": "tsx scripts/generate-exports.ts",
|
|
83
|
+
"generate:exports": "tsx --tsconfig scripts/tsconfig.json scripts/generate-exports.ts",
|
|
82
84
|
"lint": "pnpm -w run lint",
|
|
85
|
+
"lint:circular": "madge --circular --extensions ts,tsx src",
|
|
83
86
|
"lint:eslint": "pnpm -w run lint:eslint",
|
|
87
|
+
"lint:format": "prettier --write --log-level warn --ignore-path ../../.prettierignore .",
|
|
84
88
|
"lint:prettier": "pnpm -w run lint:prettier",
|
|
85
89
|
"postbuild:native": "rm -f src/storesStorage.ts src/env.ts",
|
|
86
90
|
"postbuild:web": "rm -f src/storesStorage.ts src/env.ts",
|
|
87
91
|
"prebuild:native": "cp src/storesStorage.native.ts src/storesStorage.ts && cp src/env.native.ts src/env.ts",
|
|
88
92
|
"prebuild:web": "cp src/storesStorage.web.ts src/storesStorage.ts && cp src/env.web.ts src/env.ts",
|
|
89
|
-
"test": "
|
|
93
|
+
"test": "tsx --tsconfig scripts/tsconfig.json scripts/test.ts",
|
|
90
94
|
"test:all": "pnpm run test && pnpm run test:chrome",
|
|
91
95
|
"test:chrome": "vitest run src/plugins/chrome",
|
|
92
|
-
"test:
|
|
96
|
+
"test:plugins": "vitest run src/plugins",
|
|
97
|
+
"test:treeshake": "tsx --tsconfig scripts/tsconfig.json scripts/treeshake.ts"
|
|
93
98
|
}
|
|
94
99
|
}
|