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AgB,SAAA,CAAAd,EAAA8B,EAAA7B,EAAA,EAEA4B,CACA,EACA,IAAAE,EAAiB,GAAAN,EAAAC,EAAA,EACjB,GAAAM,EAAAR,GACA,CAAAQ,EAAAC,EAAAC,IAAA,CACA,IAAAC,EAAA,mBAAAD,EAAAA,EAAAF,EAAAR,IAAAU,CAAA,QACA,IAAAjE,GACAgE,EAAAT,EAAAvB,GACAH,EAAAe,UAAA,CAAAb,IAEAmC,aAAAC,QACAD,EAAApD,IAAA,KACAkD,EAAAT,EAAAa,GACAvC,EAAAW,OAAA,CAAAT,EAAAqC,MAGAJ,EAAAT,EAAAW,GACArC,EAAAW,OAAA,CAAAT,EAAAmC,GARA,GAWA,OAAAJ,CACA,CA0GA,IAAA5D,QAgEA,IAAAA","sources":["webpack://_N_E/../../node_modules/jotai/esm/vanilla/utils.mjs","webpack://_N_E/"],"sourcesContent":["import { atom } from 'jotai/vanilla';\n\nconst RESET = Symbol(\n (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" ? \"RESET\" : \"\"\n);\n\nfunction atomWithReset(initialValue) {\n const anAtom = atom(\n initialValue,\n (get, set, update) => {\n const nextValue = typeof update === \"function\" ? update(get(anAtom)) : update;\n set(anAtom, nextValue === RESET ? initialValue : nextValue);\n }\n );\n return anAtom;\n}\n\nfunction atomWithReducer(initialValue, reducer) {\n return atom(initialValue, function(get, set, action) {\n set(this, reducer(get(this), action));\n });\n}\n\nfunction atomFamily(initializeAtom, areEqual) {\n let shouldRemove = null;\n const atoms = /* @__PURE__ */ new Map();\n const createAtom = (param) => {\n let item;\n if (areEqual === void 0) {\n item = atoms.get(param);\n } else {\n for (const [key, value] of atoms) {\n if (areEqual(key, param)) {\n item = value;\n break;\n }\n }\n }\n if (item !== void 0) {\n if (shouldRemove == null ? void 0 : shouldRemove(item[1], param)) {\n createAtom.remove(param);\n } else {\n return item[0];\n }\n }\n const newAtom = initializeAtom(param);\n atoms.set(param, [newAtom, Date.now()]);\n return newAtom;\n };\n createAtom.remove = (param) => {\n if (areEqual === void 0) {\n atoms.delete(param);\n } else {\n for (const [key] of atoms) {\n if (areEqual(key, param)) {\n atoms.delete(key);\n break;\n }\n }\n }\n };\n createAtom.setShouldRemove = (fn) => {\n shouldRemove = fn;\n if (!shouldRemove) return;\n for (const [key, value] of atoms) {\n if (shouldRemove(value[1], key)) {\n atoms.delete(key);\n }\n }\n };\n return createAtom;\n}\n\nconst getCached$2 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1$3 = /* @__PURE__ */ new WeakMap();\nconst memo3 = (create, dep1, dep2, dep3) => {\n const cache2 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache1$3, dep1);\n const cache3 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache2, dep2);\n return getCached$2(create, cache3, dep3);\n};\nfunction selectAtom(anAtom, selector, equalityFn = Object.is) {\n return memo3(\n () => {\n const EMPTY = Symbol();\n const selectValue = ([value, prevSlice]) => {\n if (prevSlice === EMPTY) {\n return selector(value);\n }\n const slice = selector(value, prevSlice);\n return equalityFn(prevSlice, slice) ? prevSlice : slice;\n };\n const derivedAtom = atom((get) => {\n const prev = get(derivedAtom);\n const value = get(anAtom);\n return selectValue([value, prev]);\n });\n derivedAtom.init = EMPTY;\n return derivedAtom;\n },\n anAtom,\n selector,\n equalityFn\n );\n}\n\nconst frozenAtoms = /* @__PURE__ */ new WeakSet();\nconst deepFreeze = (obj) => {\n if (typeof obj !== \"object\" || obj === null) return;\n Object.freeze(obj);\n const propNames = Object.getOwnPropertyNames(obj);\n for (const name of propNames) {\n const value = obj[name];\n deepFreeze(value);\n }\n return obj;\n};\nfunction freezeAtom(anAtom) {\n if (frozenAtoms.has(anAtom)) {\n return anAtom;\n }\n frozenAtoms.add(anAtom);\n const origRead = anAtom.read;\n anAtom.read = function(get, options) {\n return deepFreeze(origRead.call(this, get, options));\n };\n if (\"write\" in anAtom) {\n const origWrite = anAtom.write;\n anAtom.write = function(get, set, ...args) {\n return origWrite.call(\n this,\n get,\n (...setArgs) => {\n if (setArgs[0] === anAtom) {\n setArgs[1] = deepFreeze(setArgs[1]);\n }\n return set(...setArgs);\n },\n ...args\n );\n };\n }\n return anAtom;\n}\nfunction freezeAtomCreator(createAtom) {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n console.warn(\n \"[DEPRECATED] freezeAtomCreator is deprecated, define it on users end\"\n );\n }\n return (...args) => freezeAtom(createAtom(...args));\n}\n\nconst getCached$1 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1$2 = /* @__PURE__ */ new WeakMap();\nconst memo2$1 = (create, dep1, dep2) => {\n const cache2 = getCached$1(() => /* @__PURE__ */ new WeakMap(), cache1$2, dep1);\n return getCached$1(create, cache2, dep2);\n};\nconst cacheKeyForEmptyKeyExtractor = {};\nconst isWritable = (atom2) => !!atom2.write;\nconst isFunction = (x) => typeof x === \"function\";\nfunction splitAtom(arrAtom, keyExtractor) {\n return memo2$1(\n () => {\n const mappingCache = /* @__PURE__ */ new WeakMap();\n const getMapping = (arr, prev) => {\n let mapping = mappingCache.get(arr);\n if (mapping) {\n return mapping;\n }\n const prevMapping = prev && mappingCache.get(prev);\n const atomList = [];\n const keyList = [];\n arr.forEach((item, index) => {\n const key = keyExtractor ? keyExtractor(item) : index;\n keyList[index] = key;\n const cachedAtom = prevMapping && prevMapping.atomList[prevMapping.keyList.indexOf(key)];\n if (cachedAtom) {\n atomList[index] = cachedAtom;\n return;\n }\n const read = (get) => {\n const prev2 = get(mappingAtom);\n const currArr = get(arrAtom);\n const mapping2 = getMapping(currArr, prev2 == null ? void 0 : prev2.arr);\n const index2 = mapping2.keyList.indexOf(key);\n if (index2 < 0 || index2 >= currArr.length) {\n const prevItem = arr[getMapping(arr).keyList.indexOf(key)];\n if (prevItem) {\n return prevItem;\n }\n throw new Error(\"splitAtom: index out of bounds for read\");\n }\n return currArr[index2];\n };\n const write = (get, set, update) => {\n const prev2 = get(mappingAtom);\n const arr2 = get(arrAtom);\n const mapping2 = getMapping(arr2, prev2 == null ? void 0 : prev2.arr);\n const index2 = mapping2.keyList.indexOf(key);\n if (index2 < 0 || index2 >= arr2.length) {\n throw new Error(\"splitAtom: index out of bounds for write\");\n }\n const nextItem = isFunction(update) ? update(arr2[index2]) : update;\n if (!Object.is(arr2[index2], nextItem)) {\n set(arrAtom, [\n ...arr2.slice(0, index2),\n nextItem,\n ...arr2.slice(index2 + 1)\n ]);\n }\n };\n atomList[index] = isWritable(arrAtom) ? atom(read, write) : atom(read);\n });\n if (prevMapping && prevMapping.keyList.length === keyList.length && prevMapping.keyList.every((x, i) => x === keyList[i])) {\n mapping = prevMapping;\n } else {\n mapping = { arr, atomList, keyList };\n }\n mappingCache.set(arr, mapping);\n return mapping;\n };\n const mappingAtom = atom((get) => {\n const prev = get(mappingAtom);\n const arr = get(arrAtom);\n const mapping = getMapping(arr, prev == null ? void 0 : prev.arr);\n return mapping;\n });\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n mappingAtom.debugPrivate = true;\n }\n mappingAtom.init = void 0;\n const splittedAtom = isWritable(arrAtom) ? atom(\n (get) => get(mappingAtom).atomList,\n (get, set, action) => {\n switch (action.type) {\n case \"remove\": {\n const index = get(splittedAtom).indexOf(action.atom);\n if (index >= 0) {\n const arr = get(arrAtom);\n set(arrAtom, [\n ...arr.slice(0, index),\n ...arr.slice(index + 1)\n ]);\n }\n break;\n }\n case \"insert\": {\n const index = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length;\n if (index >= 0) {\n const arr = get(arrAtom);\n set(arrAtom, [\n ...arr.slice(0, index),\n action.value,\n ...arr.slice(index)\n ]);\n }\n break;\n }\n case \"move\": {\n const index1 = get(splittedAtom).indexOf(action.atom);\n const index2 = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length;\n if (index1 >= 0 && index2 >= 0) {\n const arr = get(arrAtom);\n if (index1 < index2) {\n set(arrAtom, [\n ...arr.slice(0, index1),\n ...arr.slice(index1 + 1, index2),\n arr[index1],\n ...arr.slice(index2)\n ]);\n } else {\n set(arrAtom, [\n ...arr.slice(0, index2),\n arr[index1],\n ...arr.slice(index2, index1),\n ...arr.slice(index1 + 1)\n ]);\n }\n }\n break;\n }\n }\n }\n ) : atom((get) => get(mappingAtom).atomList);\n return splittedAtom;\n },\n arrAtom,\n keyExtractor || cacheKeyForEmptyKeyExtractor\n );\n}\n\nfunction atomWithDefault(getDefault) {\n const EMPTY = Symbol();\n const overwrittenAtom = atom(EMPTY);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n overwrittenAtom.debugPrivate = true;\n }\n const anAtom = atom(\n (get, options) => {\n const overwritten = get(overwrittenAtom);\n if (overwritten !== EMPTY) {\n return overwritten;\n }\n return getDefault(get, options);\n },\n (get, set, update) => {\n if (update === RESET) {\n set(overwrittenAtom, EMPTY);\n } else if (typeof update === \"function\") {\n const prevValue = get(anAtom);\n set(overwrittenAtom, update(prevValue));\n } else {\n set(overwrittenAtom, update);\n }\n }\n );\n return anAtom;\n}\n\nconst isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === \"function\";\nfunction withStorageValidator(validator) {\n return (unknownStorage) => {\n const storage = {\n ...unknownStorage,\n getItem: (key, initialValue) => {\n const validate = (value2) => {\n if (!validator(value2)) {\n return initialValue;\n }\n return value2;\n };\n const value = unknownStorage.getItem(key, initialValue);\n if (isPromiseLike(value)) {\n return value.then(validate);\n }\n return validate(value);\n }\n };\n return storage;\n };\n}\nfunction createJSONStorage(getStringStorage = () => {\n try {\n return window.localStorage;\n } catch (e) {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n if (typeof window !== \"undefined\") {\n console.warn(e);\n }\n }\n return void 0;\n }\n}, options) {\n var _a;\n let lastStr;\n let lastValue;\n const storage = {\n getItem: (key, initialValue) => {\n var _a2, _b;\n const parse = (str2) => {\n str2 = str2 || \"\";\n if (lastStr !== str2) {\n try {\n lastValue = JSON.parse(str2, options == null ? void 0 : options.reviver);\n } catch (e) {\n return initialValue;\n }\n lastStr = str2;\n }\n return lastValue;\n };\n const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null;\n if (isPromiseLike(str)) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (key, newValue) => {\n var _a2;\n return (_a2 = getStringStorage()) == null ? void 0 : _a2.setItem(\n key,\n JSON.stringify(newValue, options == null ? void 0 : options.replacer)\n );\n },\n removeItem: (key) => {\n var _a2;\n return (_a2 = getStringStorage()) == null ? void 0 : _a2.removeItem(key);\n }\n };\n const createHandleSubscribe = (subscriber2) => (key, callback, initialValue) => subscriber2(key, (v) => {\n let newValue;\n try {\n newValue = JSON.parse(v || \"\");\n } catch (e) {\n newValue = initialValue;\n }\n callback(newValue);\n });\n let subscriber;\n try {\n subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe;\n } catch (e) {\n }\n if (!subscriber && typeof window !== \"undefined\" && typeof window.addEventListener === \"function\" && window.Storage) {\n subscriber = (key, callback) => {\n if (!(getStringStorage() instanceof window.Storage)) {\n return () => {\n };\n }\n const storageEventCallback = (e) => {\n if (e.storageArea === getStringStorage() && e.key === key) {\n callback(e.newValue);\n }\n };\n window.addEventListener(\"storage\", storageEventCallback);\n return () => {\n window.removeEventListener(\"storage\", storageEventCallback);\n };\n };\n }\n if (subscriber) {\n storage.subscribe = createHandleSubscribe(subscriber);\n }\n return storage;\n}\nconst defaultStorage = createJSONStorage();\nfunction atomWithStorage(key, initialValue, storage = defaultStorage, options) {\n const getOnInit = options == null ? void 0 : options.getOnInit;\n const baseAtom = atom(\n getOnInit ? storage.getItem(key, initialValue) : initialValue\n );\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n baseAtom.debugPrivate = true;\n }\n baseAtom.onMount = (setAtom) => {\n setAtom(storage.getItem(key, initialValue));\n let unsub;\n if (storage.subscribe) {\n unsub = storage.subscribe(key, setAtom, initialValue);\n }\n return unsub;\n };\n const anAtom = atom(\n (get) => get(baseAtom),\n (get, set, update) => {\n const nextValue = typeof update === \"function\" ? update(get(baseAtom)) : update;\n if (nextValue === RESET) {\n set(baseAtom, initialValue);\n return storage.removeItem(key);\n }\n if (nextValue instanceof Promise) {\n return nextValue.then((resolvedValue) => {\n set(baseAtom, resolvedValue);\n return storage.setItem(key, resolvedValue);\n });\n }\n set(baseAtom, nextValue);\n return storage.setItem(key, nextValue);\n }\n );\n return anAtom;\n}\n\nfunction atomWithObservable(getObservable, options) {\n const returnResultData = (result) => {\n if (\"e\" in result) {\n throw result.e;\n }\n return result.d;\n };\n const observableResultAtom = atom((get) => {\n var _a;\n let observable = getObservable(get);\n const itself = (_a = observable[Symbol.observable]) == null ? void 0 : _a.call(observable);\n if (itself) {\n observable = itself;\n }\n let resolve;\n const makePending = () => new Promise((r) => {\n resolve = r;\n });\n const initialResult = options && \"initialValue\" in options ? {\n d: typeof options.initialValue === \"function\" ? options.initialValue() : options.initialValue\n } : makePending();\n let setResult;\n let lastResult;\n const listener = (result) => {\n lastResult = result;\n resolve == null ? void 0 : resolve(result);\n setResult == null ? void 0 : setResult(result);\n };\n let subscription;\n let timer;\n const isNotMounted = () => !setResult;\n const start = () => {\n if (subscription) {\n clearTimeout(timer);\n subscription.unsubscribe();\n }\n subscription = observable.subscribe({\n next: (d) => listener({ d }),\n error: (e) => listener({ e }),\n complete: () => {\n }\n });\n if (isNotMounted() && (options == null ? void 0 : options.unstable_timeout)) {\n timer = setTimeout(() => {\n if (subscription) {\n subscription.unsubscribe();\n subscription = void 0;\n }\n }, options.unstable_timeout);\n }\n };\n start();\n const resultAtom = atom(lastResult || initialResult);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n resultAtom.debugPrivate = true;\n }\n resultAtom.onMount = (update) => {\n setResult = update;\n if (lastResult) {\n update(lastResult);\n }\n if (subscription) {\n clearTimeout(timer);\n } else {\n start();\n }\n return () => {\n setResult = void 0;\n if (subscription) {\n subscription.unsubscribe();\n subscription = void 0;\n }\n };\n };\n return [resultAtom, observable, makePending, start, isNotMounted];\n });\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n observableResultAtom.debugPrivate = true;\n }\n const observableAtom = atom(\n (get) => {\n const [resultAtom] = get(observableResultAtom);\n const result = get(resultAtom);\n if (result instanceof Promise) {\n return result.then(returnResultData);\n }\n return returnResultData(result);\n },\n (get, set, data) => {\n const [resultAtom, observable, makePending, start, isNotMounted] = get(observableResultAtom);\n if (\"next\" in observable) {\n if (isNotMounted()) {\n set(resultAtom, makePending());\n start();\n }\n observable.next(data);\n } else {\n throw new Error(\"observable is not subject\");\n }\n }\n );\n return observableAtom;\n}\n\nconst cache1$1 = /* @__PURE__ */ new WeakMap();\nconst memo1 = (create, dep1) => (cache1$1.has(dep1) ? cache1$1 : cache1$1.set(dep1, create())).get(dep1);\nconst isPromise$1 = (x) => x instanceof Promise;\nconst LOADING = { state: \"loading\" };\nfunction loadable(anAtom) {\n return memo1(() => {\n const loadableCache = /* @__PURE__ */ new WeakMap();\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n const derivedAtom = atom(\n (get, { setSelf }) => {\n get(refreshAtom);\n let value;\n try {\n value = get(anAtom);\n } catch (error) {\n return { state: \"hasError\", error };\n }\n if (!isPromise$1(value)) {\n return { state: \"hasData\", data: value };\n }\n const promise = value;\n const cached1 = loadableCache.get(promise);\n if (cached1) {\n return cached1;\n }\n if (promise.status === \"fulfilled\") {\n loadableCache.set(promise, { state: \"hasData\", data: promise.value });\n } else if (promise.status === \"rejected\") {\n loadableCache.set(promise, {\n state: \"hasError\",\n error: promise.reason\n });\n } else {\n promise.then(\n (data) => {\n loadableCache.set(promise, { state: \"hasData\", data });\n },\n (error) => {\n loadableCache.set(promise, { state: \"hasError\", error });\n }\n ).finally(setSelf);\n }\n const cached2 = loadableCache.get(promise);\n if (cached2) {\n return cached2;\n }\n loadableCache.set(promise, LOADING);\n return LOADING;\n },\n (_get, set) => {\n set(refreshAtom, (c) => c + 1);\n }\n );\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n derivedAtom.debugPrivate = true;\n }\n return atom((get) => get(derivedAtom));\n }, anAtom);\n}\n\nconst getCached = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1 = /* @__PURE__ */ new WeakMap();\nconst memo2 = (create, dep1, dep2) => {\n const cache2 = getCached(() => /* @__PURE__ */ new WeakMap(), cache1, dep1);\n return getCached(create, cache2, dep2);\n};\nconst isPromise = (x) => x instanceof Promise;\nconst defaultFallback = () => void 0;\nfunction unwrap(anAtom, fallback = defaultFallback) {\n return memo2(\n () => {\n const promiseErrorCache = /* @__PURE__ */ new WeakMap();\n const promiseResultCache = /* @__PURE__ */ new WeakMap();\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n const promiseAndValueAtom = atom(\n (get, { setSelf }) => {\n get(refreshAtom);\n const prev = get(promiseAndValueAtom);\n const promise = get(anAtom);\n if (!isPromise(promise)) {\n return { v: promise };\n }\n if (promise !== (prev == null ? void 0 : prev.p)) {\n if (promise.status === \"fulfilled\") {\n promiseResultCache.set(promise, promise.value);\n } else if (promise.status === \"rejected\") {\n promiseErrorCache.set(promise, promise.reason);\n } else {\n promise.then(\n (v) => promiseResultCache.set(promise, v),\n (e) => promiseErrorCache.set(promise, e)\n ).finally(setSelf);\n }\n }\n if (promiseErrorCache.has(promise)) {\n throw promiseErrorCache.get(promise);\n }\n if (promiseResultCache.has(promise)) {\n return {\n p: promise,\n v: promiseResultCache.get(promise)\n };\n }\n if (prev && \"v\" in prev) {\n return { p: promise, f: fallback(prev.v), v: prev.v };\n }\n return { p: promise, f: fallback() };\n },\n (_get, set) => {\n set(refreshAtom, (c) => c + 1);\n }\n );\n promiseAndValueAtom.init = void 0;\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n promiseAndValueAtom.debugPrivate = true;\n }\n return atom(\n (get) => {\n const state = get(promiseAndValueAtom);\n if (\"f\" in state) {\n return state.f;\n }\n return state.v;\n },\n (_get, set, ...args) => set(anAtom, ...args)\n );\n },\n anAtom,\n fallback\n );\n}\n\nfunction atomWithRefresh(read, write) {\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n return atom(\n (get, options) => {\n get(refreshAtom);\n return read(get, options);\n },\n (get, set, ...args) => {\n if (args.length === 0) {\n set(refreshAtom, (c) => c + 1);\n } else if (write) {\n return write(get, set, ...args);\n }\n }\n );\n}\n\nfunction atomWithLazy(makeInitial) {\n const a = atom(void 0);\n delete a.init;\n Object.defineProperty(a, \"init\", {\n get() {\n return makeInitial();\n }\n });\n return a;\n}\n\nexport { RESET, atomFamily, atomWithDefault, atomWithLazy, atomWithObservable, atomWithReducer, atomWithRefresh, atomWithReset, atomWithStorage, createJSONStorage, freezeAtom, freezeAtomCreator, loadable, selectAtom, splitAtom, withStorageValidator as unstable_withStorageValidator, unwrap };\n"],"names":["RESET","Symbol","WeakMap","WeakSet","deepFreeze","obj","Object","freeze","propNames","getOwnPropertyNames","name","value","isPromiseLike","x","then","defaultStorage","createJSONStorage","getStringStorage","window","localStorage","e","console","warn","options","_a","subscriber2","lastStr","lastValue","subscriber","storage","getItem","key","initialValue","_a2","_b","parse","str2","JSON","reviver","str","setItem","newValue","stringify","replacer","removeItem","subscribe","addEventListener","Storage","callback","storageEventCallback","storageArea","removeEventListener","v","atomWithStorage","getOnInit","baseAtom","jotai_vanilla__WEBPACK_IMPORTED_MODULE_0__","cn","debugPrivate","onMount","unsub","setAtom","anAtom","get","set","update","nextValue","Promise","resolvedValue"],"sourceRoot":""}