@storesjs/stores 0.9.0 → 0.11.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.
Files changed (139) hide show
  1. package/README.md +55 -29
  2. package/dist/createBaseStore.d.ts +8 -8
  3. package/dist/createDerivedStore.d.ts +9 -17
  4. package/dist/createQueryStore.d.ts +11 -16
  5. package/dist/createVirtualStore.d.ts +1 -2
  6. package/dist/env.native.d.ts +0 -2
  7. package/dist/env.web.d.ts +0 -1
  8. package/dist/hooks/useListen.d.ts +2 -2
  9. package/dist/index.d.ts +1 -16
  10. package/dist/index.shared.d.ts +14 -0
  11. package/dist/index.vanilla.d.ts +2 -0
  12. package/dist/internal/baseStore.d.ts +2 -0
  13. package/dist/{config.d.ts → internal/config.d.ts} +5 -11
  14. package/dist/{utils → internal}/createStoreActions.d.ts +4 -5
  15. package/dist/{derivedStore → internal/derivedStore}/deriveProxy.d.ts +2 -2
  16. package/dist/{derivedStore → internal/derivedStore}/pathFinder.d.ts +1 -2
  17. package/dist/internal/derivedStore.d.ts +2 -0
  18. package/dist/{errors.d.ts → internal/errors.d.ts} +0 -4
  19. package/dist/{logger.d.ts → internal/logger.d.ts} +0 -2
  20. package/dist/internal/middleware/createHydrationGate.d.ts +20 -0
  21. package/dist/internal/queryStore/queryParams.d.ts +18 -0
  22. package/dist/internal/queryStore/queryStoreDefaults.d.ts +8 -0
  23. package/dist/internal/queryStore.d.ts +2 -0
  24. package/dist/internal/runtime.d.ts +12 -0
  25. package/dist/internal/storage/storageCreators.d.ts +12 -0
  26. package/dist/{utils → internal}/storeUtils.d.ts +3 -21
  27. package/dist/internal/sync/browserSyncEngine.d.ts +3 -0
  28. package/dist/internal/sync/noopSyncEngine.d.ts +3 -0
  29. package/dist/internal/sync/syncEnhancer.d.ts +26 -0
  30. package/dist/{sync → internal/sync}/syncUtils.d.ts +1 -1
  31. package/dist/internal/types/internalSubscribeTypes.d.ts +16 -0
  32. package/dist/internal/utils/persistUtils.d.ts +9 -0
  33. package/dist/internal/virtualStore.d.ts +2 -0
  34. package/dist/native/index.js +1 -1
  35. package/dist/native/index.mjs +1 -1
  36. package/dist/queryStore/classes/SubscriptionManager.d.ts +3 -31
  37. package/dist/queryStore/queryKey.d.ts +10 -0
  38. package/dist/queryStore/queryParam.d.ts +37 -0
  39. package/dist/queryStore/types.d.ts +12 -53
  40. package/dist/store/attachStoreHook.react.d.ts +5 -0
  41. package/dist/store/attachStoreHook.vanilla.d.ts +6 -0
  42. package/dist/store/batchStoreNotifications.native.d.ts +3 -0
  43. package/dist/store/batchStoreNotifications.web.d.ts +2 -0
  44. package/dist/store/cascadeScheduler.d.ts +38 -0
  45. package/dist/store/createStore.d.ts +6 -0
  46. package/dist/store/persist.d.ts +14 -0
  47. package/dist/store/stateUpdate.d.ts +10 -0
  48. package/dist/store/types.d.ts +108 -0
  49. package/dist/types/setState.d.ts +22 -0
  50. package/dist/types/subscribe.d.ts +27 -0
  51. package/dist/types/useStoreCallSignatures.d.ts +2 -0
  52. package/dist/types/useStoreCallSignatures.react.d.ts +6 -0
  53. package/dist/types/useStoreCallSignatures.vanilla.d.ts +2 -0
  54. package/dist/types/utils.d.ts +4 -0
  55. package/dist/types.d.ts +46 -94
  56. package/dist/utils/createMicrotaskScheduler.d.ts +2 -1
  57. package/dist/utils/time.d.ts +0 -7
  58. package/dist/vanilla/createBaseStore.d.ts +35 -0
  59. package/dist/vanilla/createDerivedStore.d.ts +62 -0
  60. package/dist/vanilla/createQueryStore.d.ts +110 -0
  61. package/dist/vanilla/createVirtualStore.d.ts +39 -0
  62. package/dist/vanilla/env.web.d.ts +6 -0
  63. package/dist/vanilla/index.d.ts +1 -0
  64. package/dist/vanilla/index.js +1 -0
  65. package/dist/vanilla/index.mjs +1 -0
  66. package/dist/vanilla/index.shared.d.ts +13 -0
  67. package/dist/vanilla/index.vanilla.d.ts +1 -0
  68. package/dist/vanilla/internal/baseStore.d.ts +1 -0
  69. package/dist/vanilla/internal/config.d.ts +63 -0
  70. package/dist/vanilla/internal/createStoreActions.d.ts +23 -0
  71. package/dist/vanilla/internal/derivedStore/deriveProxy.d.ts +14 -0
  72. package/dist/vanilla/internal/derivedStore/pathFinder.d.ts +25 -0
  73. package/dist/vanilla/internal/derivedStore.d.ts +1 -0
  74. package/dist/vanilla/internal/errors.d.ts +9 -0
  75. package/dist/vanilla/internal/logger.d.ts +9 -0
  76. package/dist/{middleware → vanilla/internal/middleware}/createHydrationGate.d.ts +1 -2
  77. package/dist/vanilla/internal/queryStore/queryParams.d.ts +17 -0
  78. package/dist/{queryStore → vanilla/internal/queryStore}/queryStoreDefaults.d.ts +1 -2
  79. package/dist/vanilla/internal/queryStore.d.ts +1 -0
  80. package/dist/vanilla/internal/runtime.d.ts +11 -0
  81. package/dist/vanilla/internal/storage/storageCreators.d.ts +11 -0
  82. package/dist/vanilla/internal/storeUtils.d.ts +45 -0
  83. package/dist/vanilla/internal/sync/browserSyncEngine.d.ts +2 -0
  84. package/dist/vanilla/internal/sync/noopSyncEngine.d.ts +2 -0
  85. package/dist/{sync → vanilla/internal/sync}/syncEnhancer.d.ts +2 -3
  86. package/dist/vanilla/internal/types/internalSubscribeTypes.d.ts +15 -0
  87. package/dist/{utils → vanilla/internal/utils}/persistUtils.d.ts +1 -2
  88. package/dist/vanilla/internal/virtualStore.d.ts +1 -0
  89. package/dist/vanilla/queryStore/classes/SubscriptionManager.d.ts +38 -0
  90. package/dist/vanilla/queryStore/queryKey.d.ts +9 -0
  91. package/dist/vanilla/queryStore/queryParam.d.ts +36 -0
  92. package/dist/vanilla/queryStore/types.d.ts +360 -0
  93. package/dist/vanilla/storage/storageTypes.d.ts +12 -0
  94. package/dist/vanilla/store/attachStoreHook.d.ts +5 -0
  95. package/dist/vanilla/store/attachStoreHook.vanilla.d.ts +5 -0
  96. package/dist/vanilla/store/batchStoreNotifications.web.d.ts +1 -0
  97. package/dist/{derivedStore → vanilla/store}/cascadeScheduler.d.ts +12 -6
  98. package/dist/vanilla/store/createStore.d.ts +5 -0
  99. package/dist/vanilla/store/persist.d.ts +13 -0
  100. package/dist/vanilla/store/stateUpdate.d.ts +9 -0
  101. package/dist/vanilla/store/types.d.ts +107 -0
  102. package/dist/vanilla/storesStorage.web.d.ts +2 -0
  103. package/dist/vanilla/sync/types.d.ts +114 -0
  104. package/dist/vanilla/types/functions.d.ts +23 -0
  105. package/dist/vanilla/types/objects.d.ts +10 -0
  106. package/dist/vanilla/types/setState.d.ts +21 -0
  107. package/dist/vanilla/types/subscribe.d.ts +26 -0
  108. package/dist/vanilla/types/useStoreCallSignatures.d.ts +1 -0
  109. package/dist/vanilla/types/useStoreCallSignatures.vanilla.d.ts +1 -0
  110. package/dist/vanilla/types/utils.d.ts +12 -0
  111. package/dist/vanilla/types.d.ts +287 -0
  112. package/dist/vanilla/utils/core.d.ts +25 -0
  113. package/dist/vanilla/utils/createAsyncMicrotaskScheduler.d.ts +34 -0
  114. package/dist/vanilla/utils/createMicrotaskScheduler.d.ts +28 -0
  115. package/dist/vanilla/utils/debounce.d.ts +21 -0
  116. package/dist/vanilla/utils/equality.d.ts +37 -0
  117. package/dist/vanilla/utils/hydrationCoordinator.d.ts +12 -0
  118. package/dist/vanilla/utils/promiseUtils.d.ts +1 -0
  119. package/dist/vanilla/utils/serialization.d.ts +13 -0
  120. package/dist/vanilla/utils/stringUtils.d.ts +6 -0
  121. package/dist/vanilla/utils/time.d.ts +36 -0
  122. package/dist/web/chrome.js +1 -1
  123. package/dist/web/chrome.mjs +1 -1
  124. package/dist/web/chunk-FENSEQ3V.mjs +1 -0
  125. package/dist/web/chunk-FPYZVFBM.mjs +1 -0
  126. package/dist/web/chunk-PLDNKWGX.mjs +1 -0
  127. package/dist/web/index.js +1 -1
  128. package/dist/web/index.mjs +1 -1
  129. package/dist/web/internal/runtime.js +1 -0
  130. package/dist/web/internal/runtime.mjs +1 -0
  131. package/package.json +13 -11
  132. package/dist/createStoreWithEqualityFn.d.ts +0 -5
  133. package/dist/hooks/compareHooks.d.ts +0 -50
  134. package/dist/queryStore/signalTypes.d.ts +0 -13
  135. package/dist/signal.d.ts +0 -11
  136. package/dist/storage/storageCreators.d.ts +0 -22
  137. package/dist/sync/browserSyncEngine.d.ts +0 -3
  138. package/dist/sync/noopSyncEngine.d.ts +0 -3
  139. package/dist/web/chunk-3U5A7HQV.mjs +0 -1
@@ -0,0 +1 @@
1
+ export declare function isPromiseLike<T>(value: T | Promise<T> | void): value is Promise<T>;
@@ -0,0 +1,13 @@
1
+ type SerializedMap = {
2
+ __type: 'Map';
3
+ entries: [unknown, unknown][];
4
+ };
5
+ export declare function isSerializedMap(value: unknown): value is SerializedMap;
6
+ type SerializedSet = {
7
+ __type: 'Set';
8
+ values: unknown[];
9
+ };
10
+ export declare function isSerializedSet(value: unknown): value is SerializedSet;
11
+ export declare function replacer(_: string, value: unknown): unknown;
12
+ export declare function reviver(_: string, value: unknown): unknown;
13
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns a pluralized (by default: `word` + `'s'`) string based on the count.
3
+ *
4
+ * `word` should be provided in singular form.
5
+ */
6
+ export declare function pluralize(word: string, count: number, pluralSuffix?: string): string;
@@ -0,0 +1,36 @@
1
+ type TimeInMs = number;
2
+ type TimeUtils = {
3
+ /** Returns the input value unchanged, in milliseconds */
4
+ ms: (ms: number) => TimeInMs;
5
+ /** Converts seconds to milliseconds */
6
+ seconds: (seconds: number) => TimeInMs;
7
+ /** Converts minutes to milliseconds */
8
+ minutes: (minutes: number) => TimeInMs;
9
+ /** Converts hours to milliseconds */
10
+ hours: (hours: number) => TimeInMs;
11
+ /** Converts days to milliseconds */
12
+ days: (days: number) => TimeInMs;
13
+ /** Converts weeks to milliseconds */
14
+ weeks: (weeks: number) => TimeInMs;
15
+ /** Represents infinite time */
16
+ infinity: typeof Infinity;
17
+ /** Represents zero time */
18
+ zero: 0;
19
+ };
20
+ /**
21
+ * Worklet-compatible utility object for defining time values.
22
+ *
23
+ * All methods convert the input unit to milliseconds.
24
+ *
25
+ * @example
26
+ * time.seconds(5) // 5 seconds
27
+ * time.minutes(2) // 2 minutes
28
+ * time.hours(1) // 1 hour
29
+ * time.days(5) // 5 days
30
+ * time.weeks(2) // 2 weeks
31
+ * ––
32
+ * time.infinity // Infinity
33
+ * time.zero // 0
34
+ */
35
+ export declare const time: TimeUtils;
36
+ export {};
@@ -1 +1 @@
1
- process.env.NODE_ENV,process.env.NODE_ENV;var e=Object.prototype.hasOwnProperty;function t(t,r){return e.call(t,r)}function r(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var s=Object.freeze(Object.create(null)),n="stores:";function o(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function i(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}var a=class{constructor(e){this.async=!0,this.deserializer=h,this.serializer=c,this.area=e?.area??"local",this.storageKeyPrefix=e?.storageKeyPrefix??n}async clearAll(){const e=this.ensureStorage();if(!e)return;if(!this.storageKeyPrefix)throw new Error("Cannot clear all storage with empty storageKeyPrefix. This would delete all storage entries.");const t=await this.listPrefixedKeys(e,this.storageKeyPrefix);t.length&&await this.execute(e,r=>e.remove(t,r))}async contains(e){const t=this.ensureStorage();if(!t)return!1;const r=this.toStorageKey(e),s=await this.getFromStorage(t,r);return Object.prototype.hasOwnProperty.call(s,r)}async delete(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e);await this.execute(t,e=>t.remove(r,e))}async getAllKeys(){const e=this.ensureStorage();if(!e)return[];const t=await this.getFromStorage(e,null),r=this.storageKeyPrefix;return r?Object.keys(t).filter(e=>e.startsWith(r)).map(e=>e.slice(r.length)):Object.keys(t)}async get(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e);return u((await this.getFromStorage(t,r))[r])||void 0}async set(e,t){const r=this.ensureStorage();if(!r)return;const s=this.toStorageKey(e);await this.execute(r,e=>r.set({[s]:t},e))}ensureStorage(){return e=this.area,"undefined"!=typeof chrome&&chrome.storage?chrome.storage[e]??null:null;var e}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}async listPrefixedKeys(e,t){const r=await this.getFromStorage(e,null);return Object.keys(r).filter(e=>e.startsWith(t))}async getFromStorage(e,t){return this.invokeWithCallbackSupport(r=>e.get(t,r))}async execute(e,t){await this.invokeWithCallbackSupport(t)}async invokeWithCallbackSupport(e){return new Promise((t,r)=>{let s=!1;function n(e){if(s)return;s=!0;const n="undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.lastError?new Error(chrome.runtime.lastError.message):null;n?r(n):t(e)}try{const t=e(n);(o=t)&&"object"==typeof o&&"then"in o&&"function"==typeof o.then&&t.then(n).catch(r)}catch(e){r(e)}var o})}};function c(e){return{state:g(e.state),syncMetadata:e.syncMetadata,version:e.version}}function h(e){const t=u(e);if(!t)throw new Error("[ChromeStorageAdapter] Invalid serialized state format");return{state:f(t.state),syncMetadata:t.syncMetadata,version:t.version}}function u(e){if(l(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);if(l(t))return t}catch{}return null}function l(e){return!(!e||"object"!=typeof e)&&Object.prototype.hasOwnProperty.call(e,"state")}function g(e,t=o){if(e instanceof Map||e instanceof Set)return t.call(void 0,"",e);if(!r(e))return e;const s={};for(const[r,n]of Object.entries(e))s[r]=t.call(e,r,n);return s}function f(e,t=i){const s=t.call(void 0,"",e);if(!r(s))return s;const n={};for(const e of Object.entries(s)){const r=e[0],o=e[1];n[r]=t.call(s,r,o)}return n}var y=class{constructor(e){this.injectStorageMetadata=!0,this.registrations=new Map,this.isListening=!1,this.onStorageChanged=async(e,t)=>{if(t===this.area)for(const t of this.registrations){const r=t[0],s=t[1];if(s.destroyed)continue;const n=e[this.toStorageKey(r)];if(n&&void 0!==n.newValue)try{const e=this.parsePersistValue(n.newValue);if(!e||e.syncMetadata?.origin===this.sessionId)continue;const t=e?.syncMetadata,r=this.extractChangedFields(s,e.state,t,n.oldValue);if(!Object.keys(r).length)continue;s.registration.apply({replace:!1,sessionId:t?.origin??"unknown",timestamp:t?.timestamp??Date.now(),values:r})}catch(e){continue}}},e&&"storage"in e?(this.area=e.storage.area,this.storageKeyPrefix=e.storage.storageKeyPrefix):(this.area=e?.area??"local",this.storageKeyPrefix=e?.storageKeyPrefix??n),this.sessionId=this.generateSessionId(),this.attachListener()}destroy(){for(const e of this.registrations.values())e.destroyed=!0,e.listeners.clear();this.detachListener()}register(e){this.attachListener();const t={destroyed:!1,hydrated:!0,listeners:new Set,registration:e};return this.setRegistration(e.key,t),{destroy:()=>{t.destroyed=!0,t.listeners.clear(),this.registrations.delete(e.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(e,r,n,o){const i=Object.create(s),a=n?.fields;if(a&&Object.keys(a).length>0){let s=!1;for(const n of e.registration.fields)t(a,String(n))&&(i[n]=r[n],s=!0);if(s)return i}const c=this.parsePersistValue(o);for(const t of e.registration.fields){const e=r[t],s=c?.state[t];Object.is(e,s)||(i[t]=e)}return i}setRegistration(e,t){this.registrations.set(e,t)}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}parsePersistValue(e){return h(e)}};exports.ChromeExtensionSyncEngine=y,exports.ChromeStorageAdapter=a,exports.createSyncedChromeStorage=function(e){const t=new a(e);return{storage:t,syncEngine:new y({storage:t})}};
1
+ var e=require("./internal/runtime.js"),t=Object.prototype.hasOwnProperty;function r(e,r){return t.call(e,r)}function s(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}process.env.NODE_ENV,process.env.NODE_ENV;var n=Object.freeze(Object.create(null));function i(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function o(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}var a=class{constructor(t){this.async=!0,this.deserializer=h,this.serializer=c,this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??e.DEFAULT_STORAGE_KEY_PREFIX}async clearAll(){const e=this.ensureStorage();if(!e)return;if(!this.storageKeyPrefix)throw new Error("Cannot clear all storage with empty storageKeyPrefix. This would delete all storage entries.");const t=await this.listPrefixedKeys(e,this.storageKeyPrefix);t.length&&await this.execute(e,r=>e.remove(t,r))}async contains(e){const t=this.ensureStorage();if(!t)return!1;const r=this.toStorageKey(e),s=await this.getFromStorage(t,r);return Object.prototype.hasOwnProperty.call(s,r)}async delete(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e);await this.execute(t,e=>t.remove(r,e))}async getAllKeys(){const e=this.ensureStorage();if(!e)return[];const t=await this.getFromStorage(e,null),r=this.storageKeyPrefix;return r?Object.keys(t).filter(e=>e.startsWith(r)).map(e=>e.slice(r.length)):Object.keys(t)}async get(e){const t=this.ensureStorage();if(!t)return;const r=this.toStorageKey(e);return u((await this.getFromStorage(t,r))[r])||void 0}async set(e,t){const r=this.ensureStorage();if(!r)return;const s=this.toStorageKey(e);await this.execute(r,e=>r.set({[s]:t},e))}ensureStorage(){return e=this.area,"undefined"!=typeof chrome&&chrome.storage?chrome.storage[e]??null:null;var e}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}async listPrefixedKeys(e,t){const r=await this.getFromStorage(e,null);return Object.keys(r).filter(e=>e.startsWith(t))}async getFromStorage(e,t){return this.invokeWithCallbackSupport(r=>e.get(t,r))}async execute(e,t){await this.invokeWithCallbackSupport(t)}async invokeWithCallbackSupport(e){return new Promise((t,r)=>{let s=!1;function n(e){if(s)return;s=!0;const n="undefined"!=typeof chrome&&chrome.runtime&&chrome.runtime.lastError?new Error(chrome.runtime.lastError.message):null;n?r(n):t(e)}try{const t=e(n);(i=t)&&"object"==typeof i&&"then"in i&&"function"==typeof i.then&&t.then(n).catch(r)}catch(e){r(e)}var i})}};function c(e){return{state:g(e.state),syncMetadata:e.syncMetadata,version:e.version}}function h(e){const t=u(e);if(!t)throw new Error("[ChromeStorageAdapter] Invalid serialized state format");return{state:f(t.state),syncMetadata:t.syncMetadata,version:t.version}}function u(e){if(l(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);if(l(t))return t}catch{}return null}function l(e){return!(!e||"object"!=typeof e)&&Object.prototype.hasOwnProperty.call(e,"state")}function g(e,t=i){if(e instanceof Map||e instanceof Set)return t.call(void 0,"",e);if(!s(e))return e;const r={};for(const[s,n]of Object.entries(e))r[s]=t.call(e,s,n);return r}function f(e,t=o){const r=t.call(void 0,"",e);if(!s(r))return r;const n={};for(const e of Object.entries(r)){const s=e[0],i=e[1];n[s]=t.call(r,s,i)}return n}var y=class{constructor(t){this.injectStorageMetadata=!0,this.registrations=new Map,this.isListening=!1,this.onStorageChanged=async(e,t)=>{if(t===this.area)for(const t of this.registrations){const r=t[0],s=t[1];if(s.destroyed)continue;const n=e[this.toStorageKey(r)];if(n&&void 0!==n.newValue)try{const e=this.parsePersistValue(n.newValue);if(!e||e.syncMetadata?.origin===this.sessionId)continue;const t=e?.syncMetadata,r=this.extractChangedFields(s,e.state,t,n.oldValue);if(!Object.keys(r).length)continue;s.registration.apply({replace:!1,sessionId:t?.origin??"unknown",timestamp:t?.timestamp??Date.now(),values:r})}catch(e){continue}}},t&&"storage"in t?(this.area=t.storage.area,this.storageKeyPrefix=t.storage.storageKeyPrefix):(this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??e.DEFAULT_STORAGE_KEY_PREFIX),this.sessionId=this.generateSessionId(),this.attachListener()}destroy(){for(const e of this.registrations.values())e.destroyed=!0,e.listeners.clear();this.detachListener()}register(e){this.attachListener();const t={destroyed:!1,hydrated:!0,listeners:new Set,registration:e};return this.setRegistration(e.key,t),{destroy:()=>{t.destroyed=!0,t.listeners.clear(),this.registrations.delete(e.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(e,t,s,i){const o=Object.create(n),a=s?.fields;if(a&&Object.keys(a).length>0){let s=!1;for(const n of e.registration.fields)r(a,String(n))&&(o[n]=t[n],s=!0);if(s)return o}const c=this.parsePersistValue(i);for(const r of e.registration.fields){const e=t[r],s=c?.state[r];Object.is(e,s)||(o[r]=e)}return o}setRegistration(e,t){this.registrations.set(e,t)}toStorageKey(e){return this.storageKeyPrefix?`${this.storageKeyPrefix}${e}`:e}parsePersistValue(e){return h(e)}};exports.ChromeExtensionSyncEngine=y,exports.ChromeStorageAdapter=a,exports.createSyncedChromeStorage=function(e){const t=new a(e);return{storage:t,syncEngine:new y({storage:t})}};
@@ -1 +1 @@
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};
1
+ import{isPromiseLike as t,replacer as e,reviver as r}from"./chunk-FENSEQ3V.mjs";import{isPlainObject as s,nullObject as i,hasOwn as n}from"./chunk-FPYZVFBM.mjs";import{DEFAULT_STORAGE_KEY_PREFIX as o}from"./internal/runtime.mjs";var a=class{constructor(t){this.async=!0,this.deserializer=h,this.serializer=c,this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??o}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(e){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=e(n);t(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,r=e){if(t instanceof Map||t instanceof Set)return r.call(void 0,"",t);if(!s(t))return t;const i={};for(const[e,s]of Object.entries(t))i[e]=r.call(t,e,s);return i}function f(t,e=r){const i=e.call(void 0,"",t);if(!s(i))return i;const n={};for(const t of Object.entries(i)){const r=t[0],s=t[1];n[r]=e.call(i,r,s)}return n}var y=class{constructor(t){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}}},t&&"storage"in t?(this.area=t.storage.area,this.storageKeyPrefix=t.storage.storageKeyPrefix):(this.area=t?.area??"local",this.storageKeyPrefix=t?.storageKeyPrefix??o),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 o=i(),a=r?.fields;if(a&&Object.keys(a).length>0){let r=!1;for(const s of t.registration.fields){const t=String(s);n(a,t)&&(o[s]=e[s],r=!0)}if(r)return o}const c=this.parsePersistValue(s);for(const r of t.registration.fields){const t=e[r],s=c?.state[r];Object.is(t,s)||(o[r]=t)}return o}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
+ function e(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function t(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 n(e){return!!e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then}export{n as isPromiseLike,e as replacer,t as reviver};
@@ -0,0 +1 @@
1
+ var e="undefined"!=typeof window&&"undefined"!=typeof document,t=!1,n="development"===process.env.NODE_ENV,r="test"===process.env.NODE_ENV,o=Object.freeze(Object.create(null));function c(e){return e}function u(){return Object.create(o)}function f(e,t){return void 0===t?Object.assign(u(),e):Object.assign(u(),e,t)}function i(){}var p=Object.prototype.hasOwnProperty;function s(e,t){return p.call(e,t)}function O(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function l(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}export{e as IS_BROWSER,n as IS_DEV,t as IS_IOS,r as IS_TEST,f as buildNullObject,s as hasOwn,c as identity,O as isPlainObject,l as isRecordLike,i as noop,u as nullObject};
@@ -0,0 +1 @@
1
+ import{isPlainObject as r,nullObject as n}from"./chunk-FPYZVFBM.mjs";function t(r){return JSON.stringify(o(r))}function e(r){return JSON.parse(r)}function o(t){return"object"!=typeof t||null===t?t:Object.keys(t).sort().reduce((n,e)=>{const u=t[e];return n[e]=r(u)?o(u):u,n},n())}var u=Symbol("stores.queryParamConfig");function c(r,n){return{[u]:!0,key:n.key,value:r}}function f(r){return!!r&&"object"==typeof r&&u in r}export{t as getQueryKey,f as isQueryParamConfig,e as parseQueryKey,c as queryParam};
package/dist/web/index.js CHANGED
@@ -1 +1 @@
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};
1
+ var e=require("react"),t=require("./internal/runtime.js");process.env.NODE_ENV,process.env.NODE_ENV;var r=Object.freeze(Object.create(null));function n(){}var o=Symbol("empty selection"),u=Object.is;function c(e,t){return r=>(function(e){e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedSource=e.source,e.committedValue=e.value===o?i(e):e.value}(e),t(n=>{e.latestSnapshot=n,e.latestSource=t;const c=e.committedValue;if(c===o||e.committedSource!==t)return void r();const i=e.committedSelector,s=e.committedEqualityFn;if(e.selector===i&&e.equalityFn===s){const t=i(n);if(s===u?u(c,t):s(c,t))return;return e.committedValue=t,e.value=t,e.valueEqualityFn=s,e.valueSelector=i,e.valueSnapshot=n,void r()}if(e.source!==t)return void r();const l=e.value;if(l===o)return;const f=e.selector(n),S=e.equalityFn(l,f);e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedValue=a(e,n,S?l:f),S||r()}))}function i(e){const t=function(e){if(e.latestSource===e.source&&e.latestSnapshot!==o)return e.latestSnapshot;const t=e.getStoreSnapshot();return e.latestSnapshot=t,e.latestSource=e.source,t}(e);return s(e,t)}function s(e,t){const r=e.value;if(r!==o&&u(e.valueSnapshot,t)&&e.valueSelector===e.selector&&e.valueEqualityFn===e.equalityFn)return r;const n=e.selector(t);if(r!==o&&(e.equalityFn===u?u(r,n):e.equalityFn(r,n)))return a(e,t,r);const c=e.committedValue;return c!==o&&c!==r&&e.committedSource===e.source&&(e.equalityFn===u?u(c,n):e.equalityFn(c,n))?a(e,t,c):a(e,t,n)}function a(e,t,r){return e.value=r,e.valueEqualityFn=e.equalityFn,e.valueSelector=e.selector,e.valueSnapshot=t,r}function l(t,r,a,l){return Object.assign(function(f,S){return function(t,r,a,l,f=u){const S=e.useRef(null);let b=t,p=r,y=a;if(l){let e=S.current;null===e&&(e=function(e,t,r,u,a){const l={committedEqualityFn:a,committedSelector:u,committedSource:e,committedValue:o,equalityFn:a,getSelectedServerSnapshot:()=>function(e){return s(e,(e.getServerStoreSnapshot??e.getStoreSnapshot)())}(l),getSelectedSnapshot:()=>i(l),getServerStoreSnapshot:r,getStoreSnapshot:t,latestSnapshot:o,latestSource:o,selector:u,selectedSource:e,selectedSubscribe:()=>n,source:e,value:o,valueEqualityFn:a,valueSelector:u,valueSnapshot:o};return l.selectedSubscribe=c(l,e),l}(t,r,a,l,f),S.current=e),function(e,t,r,n,u,i){e.source===t&&e.getStoreSnapshot===r||(e.latestSnapshot=o),e.source=t,e.getStoreSnapshot=r,e.getServerStoreSnapshot=n,e.selector=u,e.equalityFn=i,e.selectedSource!==t&&(e.selectedSource=t,e.selectedSubscribe=c(e,t))}(e,t,r,a,l,f),b=e.selectedSubscribe,p=e.getSelectedSnapshot,y=void 0===a?void 0:e.getSelectedServerSnapshot}const d=e.useSyncExternalStore(b,p,y);return e.useDebugValue(d),d}(t.subscribe,r,a,f,S??l)},t)}function f(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,r)=>{const n=e[r];return t[r]=function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}(n)?f(n):n,t},Object.create(r))}var S=Symbol("stores.queryParamConfig"),b=Symbol(),p=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1}),y=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function d(e,t,r=y){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=y)=>d(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 m(e){return"function"==typeof e?{equalityFn:e}:e??p}var g=Symbol();Object.defineProperty(exports,"QueryStatuses",{enumerable:!0,get:function(){return t.QueryStatuses}}),Object.defineProperty(exports,"StoresError",{enumerable:!0,get:function(){return t.StoresError}}),Object.defineProperty(exports,"applyStateUpdate",{enumerable:!0,get:function(){return t.applyStateUpdate}}),Object.defineProperty(exports,"configureStores",{enumerable:!0,get:function(){return t.configureStores}}),Object.defineProperty(exports,"createStoreActions",{enumerable:!0,get:function(){return t.createStoreActions}}),Object.defineProperty(exports,"deepEqual",{enumerable:!0,get:function(){return t.deepEqual}}),Object.defineProperty(exports,"defaultRetryDelay",{enumerable:!0,get:function(){return t.defaultRetryDelay}}),Object.defineProperty(exports,"destroyStore",{enumerable:!0,get:function(){return t.destroyStore}}),Object.defineProperty(exports,"destroyStores",{enumerable:!0,get:function(){return t.destroyStores}}),Object.defineProperty(exports,"getStoreName",{enumerable:!0,get:function(){return t.getStoreName}}),Object.defineProperty(exports,"hasGetSnapshot",{enumerable:!0,get:function(){return t.hasGetSnapshot}}),Object.defineProperty(exports,"identity",{enumerable:!0,get:function(){return t.identity}}),Object.defineProperty(exports,"isDerivedStore",{enumerable:!0,get:function(){return t.isDerivedStore}}),Object.defineProperty(exports,"isPersistedStore",{enumerable:!0,get:function(){return t.isPersistedStore}}),Object.defineProperty(exports,"isQueryStore",{enumerable:!0,get:function(){return t.isQueryStore}}),Object.defineProperty(exports,"isVirtualStore",{enumerable:!0,get:function(){return t.isVirtualStore}}),Object.defineProperty(exports,"nullObject",{enumerable:!0,get:function(){return t.nullObject}}),Object.defineProperty(exports,"replacer",{enumerable:!0,get:function(){return t.replacer}}),Object.defineProperty(exports,"reviver",{enumerable:!0,get:function(){return t.reviver}}),Object.defineProperty(exports,"shallowEqual",{enumerable:!0,get:function(){return t.shallowEqual}}),Object.defineProperty(exports,"time",{enumerable:!0,get:function(){return t.time}}),exports.createBaseStore=function(e,r){const n=t.baseStore(e,r);return l(n,n.getState,n.getInitialState,Object.is)},exports.createDerivedStore=function(e,r=Object.is){const n=t.derivedStore(e,r);return l(n,n.getSnapshot)},exports.createQueryStore=function(e,r,n){const o=t.queryStore(e,r,n);return l(o,o.getState,o.getInitialState,Object.is)},exports.createVirtualStore=function(e,r,n){const o=t.virtualStore(e,r,n);return l(o,o.getState,o.getInitialState)},exports.getQueryKey=function(e){return JSON.stringify(f(e))},exports.parseQueryKey=function(e){return JSON.parse(e)},exports.queryParam=function(e,t){return{[S]:!0,key:t.key,value:e}},exports.useListen=function(t,r,o,u=p){const c=function(){const t=e.useRef(b);return t.current===b&&(t.current=function(e,t,r){return{selector:e,react:t,isActive:!1,options:m(r),resubscribe:n,unsubscribe:n}}(r,o,u)),t}(),i=function(e){return"function"==typeof e?p.enabled:e?.enabled??p.enabled}(u);return c.current.react=o,c.current.selector=r,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??p)}(c,u),e.useLayoutEffect(()=>{if(i)return d(t,c),()=>function(e){e.current.options.debugMode&&console.log("[🗑️ useListen 🗑️] Detaching listener"),e.current.resubscribe=n,e.current.unsubscribe(),e.current.unsubscribe=n,e.current.isActive=!1}(c)},[i,t]),c},exports.useStableValue=function(t){const r=e.useRef(g);return r.current===g&&(r.current=t()),r.current};
@@ -1 +1 @@
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};
1
+ export{getQueryKey,parseQueryKey,queryParam}from"./chunk-PLDNKWGX.mjs";import{noop as e}from"./chunk-FPYZVFBM.mjs";import{useLayoutEffect as t,useRef as r,useSyncExternalStore as n,useDebugValue as o}from"react";import{baseStore as u,derivedStore as c,queryStore as i,virtualStore as s}from"./internal/runtime.mjs";export{QueryStatuses,StoresError,applyStateUpdate,configureStores,createStoreActions,deepEqual,defaultRetryDelay,destroyStore,destroyStores,getStoreName,hasGetSnapshot,identity,isDerivedStore,isPersistedStore,isQueryStore,isVirtualStore,nullObject,replacer,reviver,shallowEqual,time}from"./internal/runtime.mjs";var a=Symbol("empty selection"),l=Object.is;function S(e,t){return r=>(function(e){e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedSource=e.source,e.committedValue=e.value===a?m(e):e.value}(e),t(n=>{e.latestSnapshot=n,e.latestSource=t;const o=e.committedValue;if(o===a||e.committedSource!==t)return void r();const u=e.committedSelector,c=e.committedEqualityFn;if(e.selector===u&&e.equalityFn===c){const t=u(n);if(c===l?l(o,t):c(o,t))return;return e.committedValue=t,e.value=t,e.valueEqualityFn=c,e.valueSelector=u,e.valueSnapshot=n,void r()}if(e.source!==t)return void r();const i=e.value;if(i===a)return;const s=e.selector(n),S=e.equalityFn(i,s);e.committedEqualityFn=e.equalityFn,e.committedSelector=e.selector,e.committedValue=d(e,n,S?i:s),S||r()}))}function m(e){const t=function(e){if(e.latestSource===e.source&&e.latestSnapshot!==a)return e.latestSnapshot;const t=e.getStoreSnapshot();return e.latestSnapshot=t,e.latestSource=e.source,t}(e);return f(e,t)}function f(e,t){const r=e.value;if(r!==a&&l(e.valueSnapshot,t)&&e.valueSelector===e.selector&&e.valueEqualityFn===e.equalityFn)return r;const n=e.selector(t);if(r!==a&&(e.equalityFn===l?l(r,n):e.equalityFn(r,n)))return d(e,t,r);const o=e.committedValue;return o!==a&&o!==r&&e.committedSource===e.source&&(e.equalityFn===l?l(o,n):e.equalityFn(o,n))?d(e,t,o):d(e,t,n)}function d(e,t,r){return e.value=r,e.valueEqualityFn=e.equalityFn,e.valueSelector=e.selector,e.valueSnapshot=t,r}function b(t,u,c,i){return Object.assign(function(s,d){return function(t,u,c,i,s=l){const d=r(null);let b=t,p=u,y=c;if(i){let r=d.current;null===r&&(r=function(t,r,n,o,u){const c={committedEqualityFn:u,committedSelector:o,committedSource:t,committedValue:a,equalityFn:u,getSelectedServerSnapshot:()=>function(e){return f(e,(e.getServerStoreSnapshot??e.getStoreSnapshot)())}(c),getSelectedSnapshot:()=>m(c),getServerStoreSnapshot:n,getStoreSnapshot:r,latestSnapshot:a,latestSource:a,selector:o,selectedSource:t,selectedSubscribe:()=>e,source:t,value:a,valueEqualityFn:u,valueSelector:o,valueSnapshot:a};return c.selectedSubscribe=S(c,t),c}(t,u,c,i,s),d.current=r),function(e,t,r,n,o,u){e.source===t&&e.getStoreSnapshot===r||(e.latestSnapshot=a),e.source=t,e.getStoreSnapshot=r,e.getServerStoreSnapshot=n,e.selector=o,e.equalityFn=u,e.selectedSource!==t&&(e.selectedSource=t,e.selectedSubscribe=S(e,t))}(r,t,u,c,i,s),b=r.selectedSubscribe,p=r.getSelectedSnapshot,y=void 0===c?void 0:r.getSelectedServerSnapshot}const v=n(b,p,y);return o(v),v}(t.subscribe,u,c,s,d??i)},t)}function p(e,t){const r=u(e,t);return b(r,r.getState,r.getInitialState,Object.is)}function y(e,t=Object.is){const r=c(e,t);return b(r,r.getSnapshot)}function v(e,t,r){const n=i(e,t,r);return b(n,n.getState,n.getInitialState,Object.is)}function g(e,t,r){const n=s(e,t,r);return b(n,n.getState,n.getInitialState)}var h=Symbol(),q=Object.freeze({debugMode:!1,enabled:!0,equalityFn:Object.is,fireImmediately:!1});function F(n,o,u,c=q){const i=function(){const t=r(h);return t.current===h&&(t.current=function(t,r,n){return{selector:t,react:r,isActive:!1,options:A(n),resubscribe:e,unsubscribe:e}}(o,u,c)),t}(),s=function(e){return"function"==typeof e?q.enabled:e?.enabled??q.enabled}(c);return i.current.react=u,i.current.selector=o,function(e,t){"function"==typeof t?e.current.options.equalityFn=t:t&&(e.current.options=t??q)}(i,c),t(()=>{if(s)return E(n,i),()=>function(t){t.current.options.debugMode&&console.log("[🗑️ useListen 🗑️] Detaching listener"),t.current.resubscribe=e,t.current.unsubscribe(),t.current.unsubscribe=e,t.current.isActive=!1}(i)},[s,n]),i}var j=Object.freeze({fireImmediately:!1,forceResubscribe:!1});function E(e,t,r=j){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=j)=>E(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 A(e){return"function"==typeof e?{equalityFn:e}:e??q}var O=Symbol();function V(e){const t=r(O);return t.current===O&&(t.current=e()),t.current}export{p as createBaseStore,y as createDerivedStore,v as createQueryStore,g as createVirtualStore,F as useListen,V as useStableValue};
@@ -0,0 +1 @@
1
+ var e="undefined"!=typeof window&&"undefined"!=typeof document,t="development"===process.env.NODE_ENV,n="test"===process.env.NODE_ENV;function r(){return"undefined"!=typeof window?window.localStorage:null}function o(e){exports.logger=e}exports.logger={debug:(e,n)=>{t&&console.debug(e,n)},error:(e,r)=>{t&&!n&&console.error(e,r)},info:(e,n)=>{t&&console.info(e,n)},warn:(e,n)=>{t&&console.warn(e,n)}};var i=Object.prototype.hasOwnProperty;function s(e,t){return i.call(e,t)}function a(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}var u=Object.freeze(Object.create(null));function l(e){return e}function f(){return Object.create(u)}function d(){}var y=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 p(e){return e instanceof Error?e:new Error(String(e))}var g,h="stores/core/sync-channel",b=`${h}:storage:`,m=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=f();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)}},S=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(b))try{const t=JSON.parse(e.newValue);this.dispatch(t)}catch(e){exports.logger.error(new y("[sync] Failed to parse storage event payload",e))}},this.channel="undefined"==typeof BroadcastChannel?null:new BroadcastChannel(h),this.storage=v(),this.channel&&this.channel.addEventListener("message",this.onChannelMessage),e&&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=f();for(const r of e.fields)s(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 m({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){exports.logger.error(new y("[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=v()),!this.storage)return;const t=`${b}${e.storeKey}`;try{this.storage.setItem(t,JSON.stringify(e))}catch(e){exports.logger.error(new y("[sync] Failed to write broadcast payload to storage",e))}}};function v(){try{return"undefined"!=typeof window?window.localStorage:null}catch{return null}}var w,O,j,I=class{destroy(){}publish(){}},k=class{constructor(){this.sessionId="noop"}register(e){return new I}},C="stores:",F=!1;function q(){if(O)return O}function x(){return j??(j=T(void 0))}function A(){F=!0}function T(t){return{storage:t?.storage??(n=t?.storageKeyPrefix??C,{clearAll(){try{const e=r();if(!e)return;const t=[];for(let r=0;r<e.length;r++){const o=e.key(r);o?.startsWith(n)&&t.push(o)}for(const n of t)e.removeItem(n)}catch(e){console.error("Error clearing localStorage:",e)}},contains(e){const t=r();return null!==t?.getItem(`${n}${e}`)},delete(e){try{const t=r();t?.removeItem(`${n}${e}`)}catch(e){console.error("Error deleting from localStorage:",e)}},getAllKeys(){try{const e=r();return e?Array.from(e.keys()):[]}catch(e){return console.error("Error getting keys from localStorage:",e),[]}},get(e){try{const t=r();return t?t.getItem(`${n}${e}`)??void 0:void 0}catch(e){return void console.error("Error reading from localStorage:",e)}},set(e,t){try{const o=r();o?.setItem(`${n}${e}`,t)}catch(e){console.error("Error writing to localStorage:",e)}}}),syncEngine:t?.syncEngine??(e?(g||(g=new S),g):(w||(w=new k),w))};var n}var z,E={Error:"error",Idle:"idle",Loading:"loading",Success:"success"},D={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};function P(e,t){const n=t?.baseDelay??D.seconds(5),r=t?.maxDelay??D.minutes(5);return Math.min(n*Math.pow(2,e),r)}function K(e,t){return!0===t[1]?e(t[0],!0):e(t[0])}function M(e,t,n){if(!0===n)return $(t)?t(e):t;const r=$(t)?t(e):t;return Object.is(r,e)?e:c(e)&&c(r)?{...e,...r}:r}function $(e){return"function"==typeof e}function R(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function L(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}var N=Object.freeze({QueryStore:Symbol("queryStore"),VirtualStore:Symbol("virtualStore")});function H(e,t){return Object.assign(e,{[t]:!0})}function _(e,t){V(e)?e.getState().reset(t?.clearQueryCache):U(e)&&e.destroy()}function U(e){return"destroy"in e}function W(e){return"getSnapshot"in e}function V(e){return N.QueryStore in e}function J(e){return!(!("persist"in e)||!e.persist)&&"string"==typeof e.persist.getOptions().name}function B(e){return N.VirtualStore in e}function Q(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 G(e,t){return"function"==typeof e[t]}function X(e,t){const n=Object.prototype.hasOwnProperty;function r(e,t){for(const n of e.keys())if(X(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--&&X(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(!X(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)||!X(e[r],t[r]))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}function Y(e){return e()}var Z=!1,ee=!1,te=!1,ne=new Set,re=new Map,oe=new Map,ie=null,se=1/0;function ae(){return Z}function ce(){return ie}function ue(){Z||(Z=!0,te||(te=!0,queueMicrotask(()=>{te=!1,le()})))}function le(){if(Z)if(ee)de();else{ee=!0;try{Y(de)}finally{ge()}}}function fe(e){Z&&ne.add(e)}function de(){for(;re.size>0||ne.size>0;)ye(),pe()}function ye(){for(;re.size>0;){const e=se,t=oe.get(e);if(t){oe.delete(e);for(const e of t)re.delete(e);ie=e;for(const e of t)e();ie=null,se=1/0;for(const e of oe.keys())e<se&&(se=e)}else{se=1/0;for(const e of oe.keys())e<se&&(se=e)}}}function pe(){for(const e of ne)ne.delete(e),e()}function ge(){Z=!1,ee=!1,ie=null,ne.clear(),re.clear(),oe.clear(),se=1/0}function he(e){let t;const n=new Set;let r;function o(...e){const o=M(t,...e);if(Object.is(o,t))return;const i=t;if(t=o,r)for(const e of r)e(t,i);n.size&&le();for(const e of n)e(t,i)}function i(){return t}const s={getInitialState:function(){return a},getState:i,setState:o,subscribe:function(...e){return 1===e.length?c(e[0]):function(e,n,o){const i=o?.equalityFn??Object.is,s=o?.isCascadeParticipant??!1;let a=e(t);function u(t){const r=e(t);if(i(a,r))return;const o=a;a=r,s&&ue(),n(r,o)}return o?.fireImmediately&&n(a,a),s?function(e){return(r??(r=new Set)).add(e),()=>{r?.delete(e),0===r?.size&&(r=void 0)}}(u):c(u)}(e[0],e[1],e[2])}},a=t=e(o,i,s);return s;function c(e){return n.add(e),()=>{n.delete(e)}}}function be(e){return!!e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then}function me(e){return{...e,merge:e.merge??Se,skipHydration:e.skipHydration??!1}}function Se(e,t){return void 0===e?t:{...t,...e}}function ve(){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 we=Math.max,Oe=Math.min;function je(e,t=0,n={}){let r,o,i,s,a,c,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-(c??0);return void 0===c||n>=t||n<0||f&&void 0!==i&&e-u>=i}function g(){const e=Ie();if(p(e))return h(e);a=setTimeout(g,function(e){const n=t-(e-(c??0));return f&&void 0!==i?Oe(n,i-(e-u)):n}(e))}function h(e){return a=void 0,d&&r?y(e):(r=o=void 0,s)}function b(...e){const n=Ie(),i=p(n);if(r=e,o=this,c=n,i){if(void 0===a)return function(e){return u=e,a=setTimeout(g,t),l?y(e):s}(c);if(f)return clearTimeout(a),a=setTimeout(g,t),y(c)}return void 0===a&&(a=setTimeout(g,t)),s}return t=ke(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?we(ke(n.maxWait)||0,t):void 0,d="trailing"in n?!!n.trailing:d),b.cancel=function(){void 0!==a&&clearTimeout(a),u=0,r=c=o=a=void 0},b.flush=function(){return void 0===a?s:h(Ie())},b}function Ie(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function ke(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 Ce(e){if(!a(e))return e;const t=f(),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 Fe=n?0:e?D.ms(200):D.seconds(5);function qe(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??Ce,a=t.deserializer??e.deserializer??Ae(o),c=t.serializer??e.serializer??Te(o);function u(t,n,o){try{if(Pe(r))return;const a={state:s(n),version:o},u=Ee(r,i,a),l=c(a);try{e.set(t,l),De(r,u)}catch(e){exports.logger.error(new y("[createBaseStore]: Failed to persist store data",e))}}catch(e){exports.logger.error(new y("[createBaseStore]: Failed to persist store data",e))}}const l=void 0!==n?je(u,n,{leading:!1,maxWait:n,trailing:!0}):u;return{getItem:t=>{const n=e.get(t);return void 0===n?null:a(n)},setItem:(e,t,n)=>{r?.getIsApplyingRemote()||l(e,t,n)},removeItem:t=>{try{e.delete(t)}catch(e){exports.logger.error(new y("[createBaseStore]: Failed to delete persisted store data",e))}}}}function xe(e,t,n,r){const o=!(t.deserializer||t.serializer||e.deserializer||e.serializer),i="object"==typeof t.sync&&!0===(t.sync.injectStorageMetadata??t.sync.engine?.injectStorageMetadata),s=t.partialize??Ce,a=t.deserializer??e.deserializer??Ae(o),c=t.serializer??e.serializer??Te(o);async function u(t,n,o){try{if(Pe(r))return;const a={state:s(n),version:o},u=Ee(r,i,a),l=c(a);try{await e.set(t,l),De(r,u)}catch(e){exports.logger.error(new y("[createBaseStore]: Failed to persist store data",e))}}catch(e){exports.logger.error(new y("[createBaseStore]: Failed to serialize persisted store data",e))}}const l=void 0!==n?je(u,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}}(u);return{getItem:async t=>{const n=await e.get(t);return void 0===n?null:a(n)},setItem:async(e,t,n)=>{if(!r?.getIsApplyingRemote())return await l(e,t,n)},removeItem:async t=>{try{await e.delete(t)}catch(e){exports.logger.error(new y("[createBaseStore]: Failed to delete persisted store data",e))}}}}function Ae(e){return t=>{if("string"!=typeof t)throw new y("[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?L:void 0)}catch(e){throw exports.logger.error(new y("[createBaseStore]: Failed to deserialize persisted store data",e)),e}}(t,e)}}function Te(e){return t=>function(e,t){try{return JSON.stringify(e,t?R:void 0)}catch(e){throw exports.logger.error(new y("[createBaseStore]: Failed to serialize store data",e)),e}}(t,e)}var ze=Object.freeze({shouldClear:!1});function Ee(e,t,n){if(!t||!e)return ze;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 De(e,t){e&&t.shouldClear&&t.fieldSnapshot&&Object.keys(t.fieldSnapshot).length&&e.clearFieldTimestamps(t.fieldSnapshot)}function Pe(e){return!!e&&!!e.getIsApplyingRemote()}var[Ke,Me]=[0,1];function $e(e,t,n){if(!e)return!0;const r=e[Ke],o=e[Me];return!(t<r)&&(t>r||n>o)}function Re(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function Le(e,n){if(!t)return!0;if(null===e||null===n)return e===n;const r=typeof e;return r===typeof n&&("object"!==r||Object.prototype.toString.call(e)===Object.prototype.toString.call(n))}function Ne(e){if(null===e)return"null";const t=typeof e;return"object"===t?Object.prototype.toString.call(e):t}function He(e,t){if(A(),!t)return he(e);const n=t.storageKey,r="string"==typeof n,o=r?t.storage??x().storage:void 0,i=function(e,t){if(!e)return null;const n="object"==typeof e,r=n?e.key??t:!0===e?t:e;if(!r)throw new y("[createBaseStore]: sync requires a key to be specified either directly or via storageKey");return n?{...e,key:r}:{key:r}}(t.sync,n),s=i?function(e,t,n){const r=t.engine??x().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:(i,s,a)=>{const c=new Map,u=[],l=[];let d=null,p=!1,g=!1,h=0,b=null,m=[],S=Promise.resolve(),v=!n;function w(e,t){if(o?.setSessionId&&o?.setTimestamp&&r.sessionId&&(o.setSessionId(r.sessionId),o.setTimestamp(e),o.mergeFieldTimestamps&&t.length>0)){const n=f();for(const r of t)n[String(r)]=e;o.mergeFieldTimestamps(n)}}function O(e,t){if(p||!b)return t?i(e,t):i(e);const n=function(){const e=Date.now(),t=e>h?e:h+1;return h=t,t}();let o=[],s=f();const a=r=>{const i=M(r,e,t);for(const e of m)Object.is(i[e],r[e])||(o.push(e),s[e]=i[e]);return o.length&&w(n,o),i},u=t?i(a,!0):i(a);function y(){o.length&&function(e){const t=r.sessionId;for(const n of e.keys)c.set(n,[e.timestamp,t]);d&&g?d.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values}):l.push(e)}({keys:o,replace:t??!1,values:s,timestamp:n})}return be(u)?u.finally(y):(y(),u)}const j=a.setState;a.setState=O;const I=e(O,s,a);if(m=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}(I),!m.length)return I;async function k(e){h=Math.max(h,e.timestamp);const n=f(),r=s(),i=e.timestamp;let a;if(e.replace)for(const t of m)Re(t,e.values)||$e(c.get(t),i,e.sessionId)&&(a??(a=[])).push(t);for(const o of m){if(!Re(o,e.values))continue;if(!b?.has(o))continue;if(!$e(c.get(o),i,e.sessionId))continue;const s=t.merge?.[o];if(s){const t=e.values[o],a=r[o];if(void 0!==t){const u=s(t,a,r,e.values),l=void 0!==a?a:t;if(!Le(u,l))return void exports.logger.error(new y(`[sync] Merge function for field "${String(o)}" returned ${Ne(u)} but expected ${Ne(l)}`));n[o]=u,c.set(o,[i,e.sessionId])}}else n[o]=e.values[o],c.set(o,[i,e.sessionId])}if(Object.keys(n).length>0||a?.length){p=!0,o&&o.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],c.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 C(e){n?S=S.then(()=>k(e)):k(e)}if(b=new Set(m),d=r.register({apply:e=>{v?C(e):u.push(e)},fields:m,getState:s,key:t.key}),d?.onFirstSubscribe||d?.onLastUnsubscribe){let e=0;const t=a.subscribe;a.subscribe=(...n)=>{e||d.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||d.onLastUnsubscribe?.()})}}}function F(){g=!0,function(){if(d&&l.length){for(const e of l){const t=r.sessionId;for(const n of e.keys)c.set(n,[e.timestamp,t]);w(e.timestamp,e.keys),d.publish?.({replace:e.replace,sessionId:t,timestamp:e.timestamp,values:e.values})}l.length=0}}()}function q(){v=!0,function(){if(!u.length)return;const e=u.slice();u.length=0;for(const t of e)C(t)}()}return n?(o.onHydrationComplete=F,o.onHydrationFlushEnd=q):d.onHydrated?(d.onHydrated(F),q()):(F(),q()),I},syncContext:o}}(e,i,o?.async??!1):void 0,a=s?.stateCreator??e;if(!r)return he(a);const c=function(e,t,n){const r=t??e.storage??x().storage,o=(e.sync?void 0:e.persistThrottleMs??Fe)||void 0,i=e.version??0;return r.async?{async:!0,persistStorage:xe(r,e,o,n),version:i}:{async:!1,persistStorage:qe(r,e,o,n),version:i}}(t,o,s?.syncContext),u=c.async?function(e){let t,n,r,o=!1;return{hydrationPromise:()=>o?t?.promise??n??(n=Promise.resolve()):(t||(t=ve()),t.promise),stateCreator:(n,i,s)=>{let a;return r=()=>{if(a?.length){for(const e of a)K(s.setState,e);a=void 0}},e(function(...e){return o?K(n,e):(t||(t=ve()),a||(a=[]),a.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)}}}}(a):void 0,l=u?u.wrapOnRehydrateStorage(t.onRehydrateStorage,s?.syncContext):t.onRehydrateStorage,d=he(function(e,t){return(n,r,o)=>{let i,s,a,c=me(t),u=!1,l=0;function f(){return c.storage.setItem(c.name,r(),c.version)}const d=o.setState;o.setState=function(...e){return K(d,e),f()};const y=e(function(...e){return K(n,e),f()},r,o);function p(){const e=function(){const e=++l;return u=!1,s?.forEach(e=>e(r()??y)),e}(),t=c.onRehydrateStorage?.(r()??y);try{const n=c.storage.getItem(c.name);return be(n)?n.then(n=>g(e,n,t)).catch(n=>m(e,t,n)):g(e,n,t)}catch(n){m(e,t,n)}}return o.getInitialState=()=>y,Object.assign(o,{persist:{clearStorage:()=>{c.storage.removeItem(c.name)},getOptions:()=>c,hasHydrated:()=>u,onFinishHydration:e=>(a??(a=new Set),a.add(e),()=>{a?.delete(e),0===a?.size&&(a=void 0)}),onHydrate:e=>(s??(s=new Set),s.add(e),()=>{s?.delete(e),0===s?.size&&(s=void 0)}),rehydrate:p,setOptions:e=>{c=me({...c,...e,storage:e.storage??c.storage})}}}),c.skipHydration||p(),i??y;function g(e,t,n){const r=function(e,t){if(!t)return{migrated:!1,state:void 0};if("number"!=typeof t.version||t.version===e.version)return{migrated:!1,state:t.state};if(!e.migrate)return console.error("State loaded from storage couldn't be migrated since no migrate function was provided"),{migrated:!1,state:void 0};const n=e.migrate(t.state,t.version);return be(n)?n.then(e=>({migrated:!0,state:e})):{migrated:!0,state:n}}(c,t);return be(r)?r.then(t=>h(e,t,n)).catch(t=>m(e,n,t)):h(e,r,n)}function h(e,t,o){const s=function(e,t){if(e!==l)return;const o=c.merge(t.state,r()??y);return i=o,n(o,!0),t.migrated?f():void 0}(e,t);if(be(s))return s.then(()=>b(e,o));b(e,o)}function b(e,t){if(e!==l)return;t?.(i,void 0);const n=r();i=n,u=!0,a?.forEach(e=>e(n))}function m(e,t,n){e===l&&t?.(void 0,n)}}}(u?(e,t,n)=>(s&&(s.syncContext.setWithoutPersist=n.setState),u.stateCreator(e,t,n)):a,{merge:t.merge,migrate:t.migrate,name:n,onRehydrateStorage:l,storage:c.persistStorage,version:c.version}));return u?Object.assign(d,{persist:Object.assign(d.persist,{hydrationPromise:u.hydrationPromise})}):d}function _e(e,t,n="s"){return 1===t?e:`${e}${n}`}var Ue=Symbol("stores.deriveProxy.unwrap");function We(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?Ve(e,r,t,n,new WeakSet,new WeakMap):(n(t,r,!0),e)}(W(e)?e.getSnapshot():e.getState(),e,n);return t.set(e,o),o}function Ve(e,t,n,r,o,i){return new Proxy(e,{get(s,a,c){if(a===Ue)return r(n,t,!0),s;if(o.has(s))return Reflect.get(s,a,c);if("__proto__"===a||"symbol"==typeof a)return a===Symbol.iterator&&(r(n,t,!0),o.add(s)),Reflect.get(s,a,c);const u=Reflect.get(s,a,s),l=String(a),f=t.concat(l);if("function"==typeof u)return Object.prototype.hasOwnProperty.call(s,a)?function(...e){return r(n,f,!0,{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,Ve(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 Je(e,t){if(!e||"object"!=typeof e)return e;const n=function(e){const t=Reflect.get(e,Ue);return t&&"object"==typeof t?t:void 0}(e);return n||(Array.isArray(e)?function(e,t){const n=Qe(e,t);if(n)for(let t=0;t<e.length;t++)Be(e,String(t),n)}(e,t):a(e)&&function(e,t){const n=Qe(e,t);if(n)for(const t of Reflect.ownKeys(e))Be(e,t,n)}(e,t),e)}function Be(e,t,n){const r=Reflect.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r))return;const o=Je(r.value,n);o!==r.value&&(r.value=o,Reflect.defineProperty(e,t,r))}function Qe(e,t){const n=t??new WeakSet;return n.has(e)?null:(n.add(e),n)}var Ge=Object.freeze([]);function Xe(){const e=new Map;return{buildProxySubscriptions(t,n,r,o){const i=new Set;for(const t of e)et(t[1],t[0],[],0,i,r);!1!==o?.(i)&&function(e,t,n){for(const n of e){const e=n.invocation?ot(n.path,n.invocation):rt(n.path);t(n.store,e,n.path)}n&&function(e){const t=e.size;console.log(`[📡 ${t} ${_e("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}_${_e("arg",o)})`:"()"}`}),null,2))}(e)}(i,t,n)},reset(){e.clear()},trackPath(t,n,r,o){let i=e.get(t);i||(i=Ye(),e.set(t,i)),Ze(i,n,0,r,o)}}}function Ye(){return f()}function Ze(e,t,n,r,o){if(n===t.length)return r&&(e.isLeaf=!0),void(o&&function(e,t){const n=e.invocation;if(!n)return void(e.invocation=t);if(tt(n,t))return;const r=e.extraInvocations;if(r){for(let e=0;e<r.length;e++)if(tt(r[e],t))return;r.push(t)}else e.extraInvocations=[t]}(e,o));e.children||(e.children=Ye());const i=t[n];let s=e.children?.[i];s||(s=Ye(),e.children[i]=s),Ze(s,t,n+1,r,o)}function et(e,t,n,r,o,i=2){const s=e.children;if(!s)return void nt(e,t,n,o);const a=Object.keys(s),c=a.length;if(0!==c)if(e.isLeaf||r>=i&&c>1){nt(e,t,n,o);for(const e of a){const a=s[e];a.invocation&&et(a,t,[...n,e],r+1,o,i)}}else if(r<i&&c>1&&!e.isLeaf)for(const e of a)et(s[e],t,[...n,e],r+1,o,i);else{if(1===c){const e=a[0];return void et(s[e],t,[...n,e],r+1,o,i)}nt(e,t,n,o)}else nt(e,t,n,o)}function tt(e,t){const n=e.args,r=t.args,o=n?.length??0;if(o!==(r?.length??0))return!1;if(!n||!r)return!0;for(let e=0;e<o;e++)if(!Object.is(n[e],r[e]))return!1;return!0}function nt(e,t,n,r){const o=e.isLeaf??!1,i=e.invocation;if(!i)return void r.add({store:t,path:n,isLeaf:o});r.add({store:t,path:n,invocation:i,isLeaf:o});const s=e.extraInvocations;if(s)for(let e=0;e<s.length;e++)r.add({store:t,path:n,invocation:s[e],isLeaf:o})}function rt(e){return t=>it(t,e)}function ot(e,t){const n=e.slice(0,-1),r=e[e.length-1];return e=>{const o=it(e,n),i=o&&"object"==typeof o?Reflect.get(o,r):void 0;return"function"==typeof i?Reflect.apply(i,o,t.args??Ge):void 0}}function it(e,t){let n=e;for(const e of t){if(!n||"object"!=typeof n)return n;n=Reflect.get(n,e)}return n}var st=Symbol(),at=Object.freeze({equalityFn:Object.is,isCascadeParticipant:!0});function ct(e,n=Object.is){const{debounceOptions:r,debugMode:o,equalityFn:i,keepAlive:s,lockDependencies:a}="function"==typeof(u=n)?{debounceOptions:void 0,debugMode:!1,equalityFn:u,keepAlive:!1,lockDependencies:!1}:{debounceOptions:u.debounce,debugMode:(t&&u.debugMode)??!1,equalityFn:u.equalityFn??Object.is,keepAlive:u.keepAlive??!1,lockDependencies:u.lockDependencies??!1},c=new Set;var u;s&&c.add(ut);const f=new Set;let d,y,p=st,g=!1,h=!1,b=!0,m=!0,S=0,v=!1,w=null,O=st;function j(e,t,n){if(!m||!c.size)return(t??l)(e.getState());if(!t)return d||(d=new WeakMap),y||(y=Xe()),We(e,d,y.trackPath);const r=n?{equalityFn:n,isCascadeParticipant:!0}:at;return f.add(e.subscribe(t,D,r)),t(W(e)?e.getSnapshot():e.getState())}function I(e){for(const t of f)t(e);f.clear()}let k=!0;function C(){if(!b&&lt(p))return p;b=!1,m&&I(!0);const t=p,n=lt(t);h=!0;try{p=function(t){k=!0;const n=p,r=e(t),s=y?Je(r):r;return lt(n)&&i(n,s)?(o&&console.log("[🥷 Derive Complete 🥷]: No change detected"),k=!1,n):s}(j)}finally{h=!1}const r=o&&(!n||"verbose"===o&&m);if(r){n?"verbose"===o&&console.log("[🌀 Rebuilding Subscriptions 🌀]: Created…"):console.log("[🌀 Initial Derive Complete 🌀]: Created…");const e=f.size;console.log(`[🎯 ${e} ${_e("Selector Subscription",e)} 🎯]`)}return y&&m&&(y.buildProxySubscriptions((e,t)=>{f.add(e.subscribe(t,D,at))},r),d=void 0,y.reset(),a&&(y=void 0)),k&&n&&function(e,t){const n=function(){const e=c.has(ut)?c.size-1:c.size;return S>0&&S<e}(),r=(!S||n)&&(n||null!==ce()||ae());n&&ue(),o&&console.log(`[📻 Derive Complete 📻]: Notifying ${c.size} ${_e("watcher",c.size)}`);for(const t of c){if("function"==typeof t||!t.isCascadeParticipant)continue;const n=t.selector(e);if(!t.equalityFn(t.currentSlice,n)){const e=t.currentSlice;t.currentSlice=n,t.listener(n,e)}}if(r)return lt(O)||(O=t),void(v||(v=!0,fe(q)));F(e,t)}(p,t),a&&(m=!1),p}function F(e,t){for(const n of c)if("function"==typeof n)n(e,t);else if(!n.isCascadeParticipant){const t=n.selector(e);if(!n.equalityFn(n.currentSlice,t)){const e=n.currentSlice;n.currentSlice=t,n.listener(t,e)}}}function q(){c.size&&b&&!S&&C();const e=O;v=!1,O=st,c.size&&lt(p)&&lt(e)&&F(p,e)}const x=r?je(T,"number"==typeof r?r:r.delay,"number"==typeof r?{leading:!1,maxWait:r,trailing:!0}:r):void 0,A=x??(()=>{g||(g=!0,queueMicrotask(T))});function T(){g=!1,c.size?b&&C():M()}function z(e){e||x&&b?queueMicrotask(()=>{c.size||M()}):M()}function E(){T(),w=null}function D(){if(!h&&!b){if(b=!0,!x){if(S){ue();const e=ce(),t=null===e?0:e+1;if(null!==w&&t<=w)return;return w=t,void function(e,t){if(!Z)return;const n=t<0?0:0|t,r=re.get(e);if(void 0===r){re.set(e,n);let t=oe.get(n);return t||(t=new Set,oe.set(n,t)),t.add(e),void(n<se&&(se=n))}if(n>r){const t=oe.get(r);if(t&&(t.delete(e),0===t.size&&(oe.delete(r),r===se))){se=1/0;for(const e of oe.keys())e<se&&(se=e)}re.set(e,n);let o=oe.get(n);o||(o=new Set,oe.set(n,o)),o.add(e),n<se&&(se=n)}}(E,t)}if(ae())return void(v||(v=!0,fe(q)))}w=null,A()}}function P(e){c.add(ut);try{return e()}finally{c.delete(ut)}}function K(){return ae()&&function(){if(Z)if(ee)null===ie&&ye();else{ee=!0;try{ye()}catch(e){throw ge(),e}finally{ee=!1,ie=null}}}(),b||!lt(p)?c.size>0?C():e(j):p}function M(e=!0){s&&e||(x?.cancel(),I(),c.clear(),S=0,y=void 0,d=void 0,m=!0,g=!1,h=!1,b=!0,p=st,v=!1,O=st,w=null)}return{destroy:()=>M(!1),flushUpdates:function(){c.size&&(x?x.flush():b&&C())},getSnapshot:function(){return lt(p)?(g&&T(),p):c.size?C():P(C)},getState:K,subscribe:function(...e){if(1===e.length){const t=e[0];return c.add(t),lt(p)||K(),()=>{c.delete(t),c.size||z(!1)}}const[t,n,r]=e,o=r?.equalityFn??Object.is,i=r?.isCascadeParticipant??!1,s=function(e){return e(c.size?K():P(K))}(t),a={currentSlice:s,equalityFn:o,isCascadeParticipant:i,listener:n,selector:t};return c.add(a),i&&(S+=1),r?.fireImmediately&&n(s,s),()=>{c.delete(a),i&&(S-=1),c.size||z(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.")}}}function ut(){}function lt(e){return e!==st}var ft=class{constructor(e){this.count=0,this.lastSubscriptionTime=null,this.fetchThrottleMs=null,this.onSubscribe=null,this.onLastUnsubscribe=null,e&&(this.fetchThrottleMs=D.seconds(5))}init({onSubscribe:e,onLastUnsubscribe:t}){this.onSubscribe=e,this.onLastUnsubscribe=t}hasSubscribers(){return this.count>0}subscribe(){const e=0===this.count,t=null!==this.fetchThrottleMs,n=t&&null!==this.lastSubscriptionTime&&!e&&Date.now()-this.lastSubscriptionTime<=this.fetchThrottleMs;return this.count+=1,this.onSubscribe?.(e,n),t&&(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)}}},dt=Symbol("stores.queryParamConfig");function yt(e){return JSON.stringify(pt(e))}function pt(e){return"object"!=typeof e||null===e?e:Object.keys(e).sort().reduce((t,n)=>{const r=e[n];return t[n]=a(r)?pt(r):r,t},f())}var gt=Object.freeze({equalityFn:Object.is,isCascadeParticipant:!0});function ht(e,t,n){const r=f();let o=null,i=!1;if(e)for(const n in e){if(!s(e,n))continue;const a=bt(r,e[n],n,t);a&&((o??(o=f()))[n]=a,void 0!==a.key&&(i=!0))}return{buildKey:(e=r)=>yt(i?function(e,t){const n=f();for(const r in t){if(!s(t,r))continue;const o=e?.[r];if(!1===o?.key)continue;const i=t[r];n[r]=o?.key?o.key(i):i}return n}(o,e):e),complete:e=>e?function(e,t){for(const n of t)if(!(n in e))return!1;return!0}(e,n)?e:{...r,...e}:vt(r),get:()=>vt(r),subscribe:e=>function(e,t,n){if(!e)return d;let r;for(const o in e){const i=e[o]?.tracked;i&&(r??(r=[])).push(i.subscribe(e=>{const r=t[o];X(r,e)||(t[o]=e,n(o,r,e))}))}return r?e=>{for(const t of r)t(e)}:d}(o,r,e)}}function bt(e,t,n,r){return(o=t)&&"object"==typeof o&&dt in o?St(e,t.value,n,r,t.key):St(e,t,n,r);var o}function mt(e,t){const n=[];let r,o;function i(e,t=l){return t(wt(e))}const s=e(function(e,t,i){return t?(n.push(n=>e.subscribe(t,n,function(e){return e?{equalityFn:e,isCascadeParticipant:!0}:gt}(i))),t(wt(e))):(r??(r=Xe()),o??(o=new WeakMap),We(e,o,r.trackPath))},t),a=r?Je(s):s;return r&&(r.buildProxySubscriptions((e,t)=>{n.push(n=>e.subscribe(t,n,gt))},!1),r.reset()),o=void 0,{initialValue:a,subscribe(r){const o=()=>r(e(i,t)),s=n.map(e=>e(o));return e=>{for(const t of s)t(e)}}}}function St(e,t,n,r,o){if(function(e){return"function"==typeof e}(t)){const i=mt(t,r);return e[n]=i.initialValue,void 0===o?{tracked:i}:{key:o,tracked:i}}return e[n]=t,void 0===o?null:{key:o}}function vt(e){const t=f();for(const n in e)s(e,n)&&(t[n]=e[n]);return t}function wt(e){return W(e)?e.getSnapshot():e.getState()}var Ot={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},jt=Object.freeze({force:!0}),It=Object.freeze({once:!0}),kt=new Set,Ct=!1;function Ft(e){kt.add(e),Ct||(Ct=!0,queueMicrotask(()=>{Ct=!1,Y(qt)}))}function qt(){for(const e of kt)kt.delete(e),e()}function xt(e,t){return n=>{const r={...n},o=f();for(const e in r)s(r,e)&&e in Ot&&(Ot[e]&&(o[e]=r[e]),delete r[e]);return{...t?t(r):Ce(r),...At(e,null,o)}}}function At(e,t,n){if(!n.queryCache)return n;const r=Date.now(),o=t??(e&&n.queryKey||null),i=f();let a=!1;for(const e in n.queryCache){if(!s(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}},a=!0):i[e]=c:a=!0}return a?{...n,queryCache:i}:n}function Tt(){return Object.create(null)}function zt(e,t,n){return new y(`[createQueryStore: ${e}]: ${t} failed`,n)}function Et(e){return function(...t){return!0===t[1]?e().setState(t[0],!0):e().setState(t[0])}}exports.DEFAULT_STORAGE_KEY_PREFIX=C,exports.QueryStatuses=E,exports.StoreTags=N,exports.StoresError=y,exports.applyStateUpdate=M,exports.assignStoreTag=H,exports.baseStore=He,exports.configureStores=function(e){t&&function(){if(F)throw new Error("[stores]: configureStores() called after first store creation. Call it earlier before creating any stores.")}(),e.logger&&o(e.logger),O??(O=function(e){return e?.queryStoreDefaults?{queryStoreDefaults:e.queryStoreDefaults}:void 0}(e)),j??(j=T(e))},exports.createStoreActions=function(e,n){const r=function(e){const n=e.getState(),r=f(),o=r;if(t&&("object"!=typeof n||null===n))throw new Error("[createStoreActions]: State is not an object");if(B(e))for(const t in n)G(n,t)&&(o[t]=Q(e,t));else for(const e in n)G(n,e)&&(o[e]=n[e]);return r}(e);return n?Object.assign(r,n):r},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=P,exports.derivedStore=ct,exports.destroyStore=_,exports.destroyStores=function(e,t){for(const n of Array.isArray(e)?e:Object.values(e))n&&!t?.skipDestroy?.(n)&&_(n,t)},exports.ensureError=p,exports.getOptions=q,exports.getStorageConfig=x,exports.getStoreName=function(e){const t="function"==typeof(n=e)?n.name:"";var n;return J(e)?e.persist.getOptions().name??t:t},exports.hasDestroy=U,exports.hasGetSnapshot=W,exports.identity=l,exports.isDerivedStore=function(e){return"flushUpdates"in e},exports.isPersistedStore=J,exports.isQueryStore=V,exports.isVirtualStore=B,exports.markStoreCreated=A,exports.nullObject=f,exports.queryStore=function(e,r,o){A();const i="function"==typeof r?r:Tt,s="object"==typeof r?r:o,a=function(e){return"string"==typeof e?.storageKey}(s)?s:void 0,c=z??(z=function(){const e={abortInterruptedFetches:!0,cacheTime:D.days(7),debugMode:!1,disableAutoRefetching:!1,keepPreviousData:!1,maxRetries:5,minStaleTime:!1,paramChangeThrottle:!1,retryDelay:P,staleTime:D.minutes(2),suppressStaleTimeWarning:!1},t=q()?.queryStoreDefaults;return t?{...e,...t}:e}()),u=c.minStaleTime,{fetcher:l,onError:d,onFetched:g,setData:h,transform:b,abortInterruptedFetches:m=c.abortInterruptedFetches,cacheTime:S=c.cacheTime,debugMode:v=c.debugMode,disableAutoRefetching:w=c.disableAutoRefetching,disableCache:O=!1,enabled:j=!0,keepPreviousData:I=c.keepPreviousData,maxRetries:k=c.maxRetries,paramChangeThrottle:C=c.paramChangeThrottle,params:F,retryDelay:x=c.retryDelay,staleTime:T=c.staleTime,suppressStaleTimeWarning:K=c.suppressStaleTimeWarning}=e;let M="function"==typeof T?c.staleTime:T;t&&!1!==u&&!w&&!K&&M<u&&console.warn(`[createQueryStore${a?.storageKey?`: ${a.storageKey}`:""}] ❌ Stale times under ${u/1e3} seconds are not recommended. Provided staleTime: ${M/1e3} seconds`);const $=new Error("[createQueryStore: AbortError] Fetch interrupted"),R="function"==typeof S,L=t&&v,_=e.params?Object.keys(e.params):[];let U,W=!1,V=[],J=null,B=null,Q=null,G=null,X=null,Y=null,Z=null;const ee={enabled:"function"!=typeof j&&j,error:null,lastFetchedAt:null,queryCache:{},queryKey:"",status:E.Idle},te=new ft(w);function ne(){Q&&(G=null,Q.abort(),Q=null)}function re(){X&&(clearTimeout(X),X=null)}function oe(e,t,n){const r=n.setState;function o(e){const t="function"==typeof e;if(t||void 0!==e.enabled){let n;const o=r(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&&Z!==t&&(Z=t,t&&te.hasSubscribers()?queueMicrotask(()=>c.fetch(void 0,void 0,!0)):(X||m)&&(m&&ne(),re()))}(r.enabled,i)),o});return n?.(),o}return r(e)}function s(e){if(w||M<=0||M===1/0)return;if(!te.hasSubscribers())return;re();const n=t();if(!n.enabled)return;const r=U.buildKey(e),o=(O?Y===r&&n.lastFetchedAt:n.queryCache[r]?.lastFetchedAt)||null,i=o?M-(Date.now()-o):M;X=setTimeout(()=>{t().enabled&&c.fetch(e,jt,!0)},i)}n.setState=o,te.init({onSubscribe:(n,r)=>{const o=t();if(o.enabled)if(n){const t=U.get(),n=U.buildKey(t);o.queryKey!==n&&e({queryKey:n}),o.isStale()?c.fetch(t,void 0,!0):s(t)}else w&&!r&&c.fetch(void 0,void 0,!0)},onLastUnsubscribe:e=>{re(),m&&!e&&ne()}});const c={...i(o,t,n),...ee,async fetch(n,r,i=!1){const u=!!r?.skipStoreUpdates,f=t();if(!u){if(!f.enabled&&!r?.force)return null;if(i&&!te.hasSubscribers())return null}const v=f.error,w=f.queryKey,j=f.status===E.Loading,C=U.complete(n),F=U.buildKey(C);if(j&&G?.promise&&G.key===F)return L&&console.log("[🔄 Using Active Fetch 🔄] for params:",JSON.stringify(C)),G.promise;const q=r?.staleTime??M,A="boolean"==typeof r?.updateQueryKey?r.updateQueryKey:!!i&&I,T=(i||w===F||A)&&!u,z=null!==G;if(m&&T&&ne(),!r?.force){const t=f.lastFetchedAt,n=f.queryCache[F],r=n?.lastFetchedAt,o=n?.errorInfo,i=o&&o.retryCount>=k,a=(O?Y===F&&t:r)||null;if(a&&!(Date.now()-a>=q)&&(!o||i||u))return T&&!X&&0!==M&&M!==1/0&&s(C),A&&e(e=>e.queryKey!==F?{queryKey:F}:e),L&&console.log("[💾 Returning Cached Data 💾] for params:",JSON.stringify(C)),n?.data??null}const D=T?{key:F}:null,P=r?.cacheTime??(R?S(C):S);async function K(){const f=a?.storageKey||F;try{L&&(!i&&n&&_.some(e=>!(e in n))?console.log("[🔄 Fetching with Partial Params 🔄]\n","- Provided params:",`${JSON.stringify(n)}\n`,"- Filled in params:",`${JSON.stringify(Object.fromEntries(Object.keys(C).filter(e=>!(e in n)).map(e=>[e,C[e]])))}`):console.log("[🔄 Fetching 🔄] for params:",JSON.stringify(C)));const t=await(m&&T?async function(e){const t=new AbortController;Q=t;try{return await new Promise((n,r)=>{t.signal.addEventListener("abort",()=>r($),It),Promise.resolve(l(e,t)).then(n,r)})}finally{Q===t&&(Q=null)}}(C):l(C,null)),a=Date.now();let d;L&&console.log("[✅ Fetch Successful ✅] for params:",JSON.stringify(C));try{d=function(e,t,n){return n?n(e,t):e}(t,C,b)}catch(e){throw zt(f,"transform",e)}if(u)return L&&console.log("[🥷 Successful Parallel Fetch 🥷] for params:",JSON.stringify(C)),"withCache"===r.skipStoreUpdates&&e(e=>{if(!h)return O?e:{queryCache:{...e.queryCache,[F]:{cacheTime:P,data:d,errorInfo:null,lastFetchedAt:a}}};let t=e;const n=t.queryCache[F];try{h({data:d,params:C,queryKey:F,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw zt(f,"setData",e)}return!O&&Object.is(n,t.queryCache[F])&&(t={...t,queryCache:{...t.queryCache,[F]:{cacheTime:P,data:null,errorInfo:null,lastFetchedAt:a}}}),t}),d;if((h?o:e)(e=>{let t={...e,error:null,lastFetchedAt:a,queryKey:A?F:e.queryKey,status:E.Success};if(h||O){if(h){L&&console.log("[💾 Setting Data 💾] for params:",JSON.stringify(C));const e=t.queryCache[F];try{h({data:d,params:C,queryKey:F,set:e=>{t="function"==typeof e?{...t,...e(t)}:{...t,...e}}})}catch(e){throw zt(f,"setData",e)}!O&&Object.is(e,t.queryCache[F])&&(t.queryCache={...t.queryCache,[F]:{cacheTime:P,data:null,errorInfo:null,lastFetchedAt:a}})}}else L&&console.log("[💾 Setting Cache 💾] for params:",JSON.stringify(C),"| Has previous data?:",!!t.queryCache[F]?.data),t.queryCache={...t.queryCache,[F]:{cacheTime:P,data:d,errorInfo:null,lastFetchedAt:a}};return O||S===1/0?t:At(I,F,t)}),T&&(Y=F,s(C)),g)try{g({data:d,fetch:c.fetch,params:C,set:o})}catch(e){exports.logger.error(zt(f,"onFetched callback",e))}return d??null}catch(n){if(n===$)return L&&console.log("[❌ Fetch Aborted ❌] for params:",JSON.stringify(C)),null;const o=!i&&!0===r?.throwOnError,s=p(n);if(s instanceof y&&exports.logger.error(s),!T){if(o)throw s;return null}const a=O?void 0:t().queryCache[F],u=a?.errorInfo?.retryCount??0,l=u+1;try{d?.(s,u)}catch(e){exports.logger.error(zt(f,"onError callback",e))}if(u<k){if(t().enabled&&te.hasSubscribers()){const e="function"==typeof x?x(l,s):x;e!==1/0&&(re(),X=setTimeout(()=>{t().enabled&&c.fetch(C,jt,!0)},e))}e(e=>({error:s,queryCache:{...e.queryCache,[F]:{cacheTime:a?.cacheTime??P,data:a?.data??null,lastFetchedAt:a?.lastFetchedAt??null,errorInfo:{error:s,lastFailedAt:Date.now(),retryCount:l}}},queryKey:A?F:e.queryKey,status:E.Error}))}else e(e=>({error:s,queryCache:{...e.queryCache,[F]:{cacheTime:a?.cacheTime??P,data:a?.data??null,lastFetchedAt:a?.lastFetchedAt??null,errorInfo:{error:s,lastFailedAt:Date.now(),retryCount:k}}},queryKey:A?F:e.queryKey,status:E.Error}));if(o)throw s;return null}finally{G===D&&(G=null)}}return D&&(re(),A&&!z&&null===f.lastFetchedAt&&w!==F?e({error:null,queryKey:F,status:E.Loading}):!v&&j||e({error:null,status:E.Loading}),G=D),D?(D.promise=K(),D.promise):K()},getCacheEntry(e){if(O)return null;const n=t(),r=e?"string"==typeof e?e:U.buildKey(U.complete(e)):n.queryKey;return n.queryCache[r]??null},getData(e){if(O)return null;const n=t().getCacheEntry(e);return n&&null!==n.data?I?n.data:n.lastFetchedAt&&Date.now()-n.lastFetchedAt>=n.cacheTime?null:n.data:null},getStatus:function(e){const n=t(),r=n.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 t=n.queryKey,o=n.queryCache[t],i=O?r===E.Error:"number"==typeof o?.errorInfo?.lastFailedAt;if("isError"===e)return i;const s=null!==((O?Y===t&&n.lastFetchedAt:o?.lastFetchedAt)||null),a=!s&&!i&&n.enabled;if("isInitialLoad"===e)return a;const c=s&&!i;return"isSuccess"===e?c:{isError:i,isIdle:r===E.Idle,isLoading:r===E.Loading,isInitialLoad:a,isSuccess:c}}}},isDataExpired(e){const n=t(),r=n.queryCache[n.queryKey],o=n.queryKey,i=n.lastFetchedAt,s=(O?Y===o&&i:r?.lastFetchedAt)||null;if(!s)return!0;const a=e??r?.cacheTime;return void 0===a||Date.now()-s>=a},isStale(e){const n=t(),r=n.queryKey,o=(O?Y===r&&n.lastFetchedAt:n.queryCache[r]?.lastFetchedAt)||null;if(!o)return!0;const i=e??M;return Date.now()-o>=i},reset(t=!1){for(const e of V)e();V=[],U=ht(void 0,ie,_),J=null,B=null,ne(),re(),G=null,Y=null,t&&e(ee)}},u=n.subscribe;return n.subscribe=(...e)=>{const t=W?void 0:te.subscribe(),n=1===e.length?u(e[0]):u(e[0],e[1],e[2]);return e=>{t?.(e),n()}},c}const ie=a?.storageKey?He(oe,(se=a,void 0===(ae={partialize:xt(I,a.partialize)})?Object.assign(f(),se):Object.assign(f(),se,ae))):s&&!("storageKey"in s)?He(oe,s):He(oe);var se,ae;const ce=ie.getState(),ue=ce.error,le=ce.enabled,fe=ce.queryKey,de=ce.fetch;fe&&!ue&&(Y=fe),W=!0,U=ht(F,ie,_),"function"==typeof j&&(J=mt(j,ie)),"function"==typeof e.staleTime&&(B=mt(e.staleTime,ie),M=B.initialValue);const ye=function(e,t=queueMicrotask){let n,r=!1;function o(){r=!1,e(...n)}return function(...e){n=e,r||(r=!0,t(o))}}(e=>{de(e,void 0,!0)},Ft);function pe(){if(I)ye(void 0);else{const e=U.get();ie.setState({queryKey:U.buildKey(e)}),ye(e)}}const ge=n||!C?void 0:je(pe,"number"==typeof C?C:C.delay,"number"==typeof C?{leading:!1,maxWait:C,trailing:!0}:C);if(V.push(U.subscribe((e,t,n)=>{L&&console.log("[🌀 Param Change 🌀] -",e,"- [Old]:",`${t?.toString()},`,"[New]:",n?.toString()),function(){if(re(),ge){const e=ie.getState();return void(I&&G?.key===e.queryKey&&null===e.lastFetchedAt?pe():ge())}pe()}()})),B){let e=B.initialValue;L&&console.log("[🌀 StaleTime Subscription 🌀] Initial value:",e),V.push(B.subscribe(t=>{t!==e&&(L&&console.log("[🌀 StaleTime Change 🌀] - [Old]:",`${e},`,"[New]:",t),e=t,M=t,re(),de(void 0,void 0,!0))}))}let he;if(J){let e=J.initialValue;le!==e&&((he??(he={})).enabled=e),L&&console.log("[🌀 Enabled Subscription 🌀] Initial value:",e),V.push(J.subscribe(t=>{t!==e&&(L&&console.log("[🌀 Enabled Change 🌀] - [Old]:",`${e},`,"[New]:",t),e=t,ie.setState({enabled:t}))}))}else le!==ee.enabled&&((he??(he={})).enabled=ee.enabled);const be=U.buildKey();return be!==fe&&((he??(he={})).queryKey=be),he&&ie.setState(he),W=!1,H(ie,N.QueryStore)},exports.replacer=R,exports.reviver=L,exports.setLogger=o,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=D,exports.virtualStore=function(e,t,n){const r="function"==typeof t,o=r?t:void 0,i=r?n:t,s=new Set;let a;function c(e,t,n,r){u(e,t,n,r)&&ue()}function u(e,t,n,r){e.unsubscribe();const o=e.args;if(1===o.length){const i=o[0],s=t.subscribe(i);e.unsubscribe=s;const a=!Object.is(r,n);return a&&i(r,n),a}const i=o[0],s=o[1];let a=o[2];a?.fireImmediately&&(a={...a,fireImmediately:!1});const c=i(n),u=i(r),l=t.subscribe(i,s,a);return e.unsubscribe=l,!(a?.equalityFn??Object.is)(c,u)&&(s(u,c),!0)}function l(e,t){!function(e,t){const n=e.getState(),r=t.getState();if(a)for(const e of a)c(e,t,n,r);s.size&&le();for(const e of s)u(e,t,n,r)}(t,e),_(t)}const f=ct(e,{debugMode:i?.debugMode??!1,lockDependencies:i?.lockDependencies??!0});let y;function p(){return y??(y=f.subscribe(l)),f.getState()}var g;return Object.assign({[N.VirtualStore]:!0,destroy:()=>{y?.(),y=void 0,f.destroy()},getInitialState:()=>p().getInitialState(),getState:()=>p().getState(),persist:(g=p,{clearStorage:()=>g().persist?.clearStorage(),getOptions:()=>g().persist?.getOptions()??{},hasHydrated:()=>g().persist?.hasHydrated()??!0,hydrationPromise:()=>g().persist?.hydrationPromise?.()??Promise.resolve(),onFinishHydration:e=>g().persist?.onFinishHydration(e)??d,onHydrate:e=>g().persist?.onHydrate(e)??d,rehydrate:()=>g().persist?.rehydrate(),setOptions:e=>g().persist?.setOptions(e)}),setState:Et(p),subscribe:function(...e){const t=p(),n={args:e,unsubscribe:1===e.length?t.subscribe(e[0]):t.subscribe(e[0],e[1],e[2])},r=e[2]?.isCascadeParticipant??!1;return r?(a??(a=new Set)).add(n):s.add(n),()=>{n.unsubscribe(),r?a?.delete(n)&&0===a.size&&(a=void 0):s.delete(n)}}},o?.(p))};