1import { R as Z } from "./queryClient-DpZpBkWP.js"; 2import { R as Yo } from "./emotion-react.browser.esm-MfU6wlAJ.js"; 3var In = {}; 4function Xo(e) { 5 const t = new Error(e); 6 if (t.stack === void 0) 7 try { 8 throw t; 9 } catch { 10 } 11 return t; 12} 13var Jo = Xo, M = Jo; 14function Qo(e) { 15 return !!e && typeof e.then == "function"; 16} 17var K = Qo; 18function er(e, t) { 19 if (e != null) 20 return e; 21 throw M(t ?? "Got unexpected null or undefined"); 22} 23var j = er; 24function V(e, t, n) { 25 return t in e ? Object.defineProperty(e, t, { 26 value: n, 27 enumerable: !0, 28 configurable: !0, 29 writable: !0 30 }) : e[t] = n, e; 31} 32class ft { 33 getValue() { 34 throw M("BaseLoadable"); 35 } 36 toPromise() { 37 throw M("BaseLoadable"); 38 } 39 valueMaybe() { 40 throw M("BaseLoadable"); 41 } 42 valueOrThrow() { 43 throw M(`Loadable expected value, but in "${this.state}" state`); 44 } 45 promiseMaybe() { 46 throw M("BaseLoadable"); 47 } 48 promiseOrThrow() { 49 throw M(`Loadable expected promise, but in "${this.state}" state`); 50 } 51 errorMaybe() { 52 throw M("BaseLoadable"); 53 } 54 errorOrThrow() { 55 throw M(`Loadable expected error, but in "${this.state}" state`); 56 } 57 is(t) { 58 return t.state === this.state && t.contents === this.contents; 59 } 60 map(t) { 61 throw M("BaseLoadable"); 62 } 63} 64class tr extends ft { 65 constructor(t) { 66 super(), V(this, "state", "hasValue"), V(this, "contents", void 0), this.contents = t; 67 } 68 getValue() { 69 return this.contents; 70 } 71 toPromise() { 72 return Promise.resolve(this.contents); 73 } 74 valueMaybe() { 75 return this.contents; 76 } 77 valueOrThrow() { 78 return this.contents; 79 } 80 promiseMaybe() { 81 } 82 errorMaybe() { 83 } 84 map(t) { 85 try { 86 const n = t(this.contents); 87 return K(n) ? Te(n) : xe(n) ? n : Ye(n); 88 } catch (n) { 89 return K(n) ? ( 90 // If we "suspended", then try again. 91 // errors and subsequent retries will be handled in 'loading' case 92 // $FlowFixMe[prop-missing] 93 Te(n.next(() => this.map(t))) 94 ) : ht(n); 95 } 96 } 97} 98class nr extends ft { 99 constructor(t) { 100 super(), V(this, "state", "hasError"), V(this, "contents", void 0), this.contents = t; 101 } 102 getValue() { 103 throw this.contents; 104 } 105 toPromise() { 106 return Promise.reject(this.contents); 107 } 108 valueMaybe() { 109 } 110 promiseMaybe() { 111 } 112 errorMaybe() { 113 return this.contents; 114 } 115 errorOrThrow() { 116 return this.contents; 117 } 118 map(t) { 119 return this; 120 } 121} 122class Un extends ft { 123 constructor(t) { 124 super(), V(this, "state", "loading"), V(this, "contents", void 0), this.contents = t; 125 } 126 getValue() { 127 throw this.contents; 128 } 129 toPromise() { 130 return this.contents; 131 } 132 valueMaybe() { 133 } 134 promiseMaybe() { 135 return this.contents; 136 } 137 promiseOrThrow() { 138 return this.contents; 139 } 140 errorMaybe() { 141 } 142 map(t) { 143 return Te(this.contents.then((n) => { 144 const o = t(n); 145 if (xe(o)) { 146 const r = o; 147 switch (r.state) { 148 case "hasValue": 149 return r.contents; 150 case "hasError": 151 throw r.contents; 152 case "loading": 153 return r.contents; 154 } 155 } 156 return o; 157 }).catch((n) => { 158 if (K(n)) 159 return n.then(() => this.map(t).contents); 160 throw n; 161 })); 162 } 163} 164function Ye(e) { 165 return Object.freeze(new tr(e)); 166} 167function ht(e) { 168 return Object.freeze(new nr(e)); 169} 170function Te(e) { 171 return Object.freeze(new Un(e)); 172} 173function xn() { 174 return Object.freeze(new Un(new Promise(() => { 175 }))); 176} 177function or(e) { 178 return e.every((t) => t.state === "hasValue") ? Ye(e.map((t) => t.contents)) : e.some((t) => t.state === "hasError") ? ht(j(e.find((t) => t.state === "hasError"), "Invalid loadable passed to loadableAll").contents) : Te(Promise.all(e.map((t) => t.contents))); 179} 180function Pn(e) { 181 const n = (Array.isArray(e) ? e : Object.getOwnPropertyNames(e).map((r) => e[r])).map((r) => xe(r) ? r : K(r) ? Te(r) : Ye(r)), o = or(n); 182 return Array.isArray(e) ? ( 183 // $FlowIssue[incompatible-return] 184 o 185 ) : ( 186 // Object.getOwnPropertyNames() has consistent key ordering with ES6 187 // $FlowIssue[incompatible-call] 188 o.map((r) => Object.getOwnPropertyNames(e).reduce(
189 // $FlowFixMe[invalid-computed-prop] 190 (a, i, u) => ({ 191 ...a, 192 [i]: r[u] 193 }), 194 {} 195 )) 196 ); 197} 198function xe(e) { 199 return e instanceof ft; 200} 201const rr = { 202 of: (e) => K(e) ? Te(e) : xe(e) ? e : Ye(e), 203 error: (e) => ht(e), 204 // $FlowIssue[incompatible-return] 205 loading: () => xn(), 206 // $FlowIssue[unclear-type] 207 all: Pn, 208 isLoadable: xe 209}; 210var Le = { 211 loadableWithValue: Ye, 212 loadableWithError: ht, 213 loadableWithPromise: Te, 214 loadableLoading: xn, 215 loadableAll: Pn, 216 isLoadable: xe, 217 RecoilLoadable: rr 218}, ar = Le.loadableWithValue, sr = Le.loadableWithError, ir = Le.loadableWithPromise, lr = Le.loadableLoading, cr = Le.loadableAll, ur = Le.isLoadable, dr = Le.RecoilLoadable, Xe = /* @__PURE__ */ Object.freeze({ 219 __proto__: null, 220 loadableWithValue: ar, 221 loadableWithError: sr, 222 loadableWithPromise: ir, 223 loadableLoading: lr, 224 loadableAll: cr, 225 isLoadable: ur, 226 RecoilLoadable: dr 227}); 228const Pt = { 229 RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED: !0, 230 // Note: RECOIL_GKS_ENABLED settings will only be honored in OSS builds of Recoil 231 RECOIL_GKS_ENABLED: /* @__PURE__ */ new Set(["recoil_hamt_2020", "recoil_sync_external_store", "recoil_suppress_rerender_in_callback", "recoil_memory_managament_2020"]) 232}; 233function fr(e, t) { 234 var n, o; 235 const r = (n = In[e]) === null || n === void 0 || (o = n.toLowerCase()) === null || o === void 0 ? void 0 : o.trim(); 236 if (r == null || r === "") 237 return; 238 if (!["true", "false"].includes(r)) 239 throw M(`process.env.${e} value must be 'true', 'false', or empty: ${r}`); 240 t(r === "true"); 241} 242function hr(e, t) { 243 var n; 244 const o = (n = In[e]) === null || n === void 0 ? void 0 : n.trim(); 245 o == null || o === "" || t(o.split(/\s*,\s*|\s+/)); 246} 247function vr() { 248 var e; 249 typeof process > "u" || ((e = process) === null || e === void 0 ? void 0 : e.env) != null && (fr("RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED", (t) => { 250 Pt.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED = t; 251 }), hr("RECOIL_GKS_ENABLED", (t) => { 252 t.forEach((n) => { 253 Pt.RECOIL_GKS_ENABLED.add(n); 254 }); 255 })); 256} 257vr(); 258var Je = Pt; 259function vt(e) { 260 return Je.RECOIL_GKS_ENABLED.has(e); 261} 262vt.setPass = (e) => { 263 Je.RECOIL_GKS_ENABLED.add(e); 264}; 265vt.setFail = (e) => { 266 Je.RECOIL_GKS_ENABLED.delete(e); 267}; 268vt.clear = () => { 269 Je.RECOIL_GKS_ENABLED.clear(); 270}; 271var F = vt; 272function pr(e, t, { 273 error: n 274} = {}) { 275 return null; 276} 277var _r = pr, ie = _r, Vt, $t, Mt; 278const mr = ( 279 // flowlint-next-line unclear-type:off 280 (Vt = Z.createMutableSource) !== null && Vt !== void 0 ? Vt : Z.unstable_createMutableSource 281), On = ( 282 // flowlint-next-line unclear-type:off 283 ($t = Z.useMutableSource) !== null && $t !== void 0 ? $t : Z.unstable_useMutableSource 284), Gt = ( 285 // flowlint-next-line unclear-type:off 286 (Mt = Z.useSyncExternalStore) !== null && Mt !== void 0 ? Mt : ( 287 // flowlint-next-line unclear-type:off 288 Z.unstable_useSyncExternalStore 289 ) 290); 291let fn = !1; 292function yr() { 293 var e; 294 const { 295 ReactCurrentDispatcher: t, 296 ReactCurrentOwner: n 297 } = ( 298 /* $FlowFixMe[prop-missing] This workaround was approved as a safer mechanism 299 * to detect if the current renderer supports useSyncExternalStore() 300 * https://fb.workplace.com/groups/reactjs/posts/9558682330846963/ */ 301 Z.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED 302 ), r = ((e = t == null ? void 0 : t.current) !== null && e !== void 0 ? e : n.currentDispatcher).useSyncExternalStore != null; 303 return Gt && !r && !fn && (fn = !0, ie()), r; 304} 305function Sr() { 306 return F("recoil_transition_support") ? { 307 mode: "TRANSITION_SUPPORT", 308 early: !0, 309 concurrent: !0 310 } : F("recoil_sync_external_store") && Gt != null ? { 311 mode: "SYNC_EXTERNAL_STORE", 312 early: !0, 313 concurrent: !1 314 } : F("recoil_mutable_source") && On != null && typeof window < "u" && !window.$disableRecoilValueMutableSource_TEMP_HACK_DO_NOT_USE ? F("recoil_suppress_rerender_in_callback") ? { 315 mode: "MUTABLE_SOURCE", 316 early: !0, 317 concurrent: !0 318 } : { 319 mode: "MUTABLE_SOURCE", 320 early: !1, 321 concurrent: !1 322 } : F("recoil_suppress_rerender_in_callback") ? { 323 mode: "LEGACY", 324 early: !0, 325 concurrent: !1 326 } : { 327 mode: "LEGACY", 328 early: !1, 329 concurrent: !1 330 }; 331} 332var Ht = { 333 createMutableSource: mr, 334 useMutableSource: On, 335 useSyncExternalStore: Gt, 336 currentRendererSupportsUseSyncExternalStore: yr, 337 reactMode: Sr 338}; 339class jt { 340 constructor(t) { 341 V(this, "key", void 0), this.key = t; 342 } 343 toJSON() { 344 return { 345 key: this.key 346 }; 347 } 348} 349class Bn extends jt { 350} 351class zn extends jt { 352} 353function gr(e) { 354 return e instanceof Bn || e instanceof zn; 355} 356var pt = { 357 AbstractRecoilValue: jt, 358 RecoilState: Bn, 359 RecoilValueReadOnly: zn, 360 isRecoilValue: gr 361}, Rr = pt.AbstractRecoilValue, br = pt.RecoilState, wr = pt.RecoilValueReadOnly, Er = pt.isRecoilValue, Ae = /* @__PURE__ */ Object.freeze({ 362 __proto__: null, 363 AbstractRecoilValue: Rr, 364 RecoilState: br, 365 RecoilValueReadOnly: wr, 366 isRecoilValue: Er 367}); 368function Tr(e, ...t) { 369} 370var Ar = Tr, Fn = Ar; 371function Lr(e, t) { 372 return function* () { 373 let n = 0; 374 for (const o of e) 375 yield t(o, n++); 376 }(); 377} 378var _t = Lr;
379class Wn { 380} 381const Nr = new Wn(), Pe = /* @__PURE__ */ new Map(), qt = /* @__PURE__ */ new Map(); 382function Cr(e) { 383 return _t(e, (t) => j(qt.get(t))); 384} 385function Vr(e) { 386 if (Pe.has(e)) { 387 const t = `Duplicate atom key "${e}". This is a FATAL ERROR in 388 production. But it is safe to ignore this warning if it occurred because of 389 hot module replacement.`; 390 console.warn(t); 391 } 392} 393function $r(e) { 394 Je.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED && Vr(e.key), Pe.set(e.key, e); 395 const t = e.set == null ? new Ae.RecoilValueReadOnly(e.key) : new Ae.RecoilState(e.key); 396 return qt.set(e.key, t), t; 397} 398class Mr extends Error { 399} 400function kr(e) { 401 const t = Pe.get(e); 402 if (t == null) 403 throw new Mr(`Missing definition for RecoilValue: "${e}""`); 404 return t; 405} 406function Dr(e) { 407 return Pe.get(e); 408} 409const ut = /* @__PURE__ */ new Map(); 410function Ir(e) { 411 var t; 412 if (!F("recoil_memory_managament_2020")) 413 return; 414 const n = Pe.get(e); 415 if (n != null && (t = n.shouldDeleteConfigOnRelease) !== null && t !== void 0 && t.call(n)) { 416 var o; 417 Pe.delete(e), (o = Kn(e)) === null || o === void 0 || o(), ut.delete(e); 418 } 419} 420function Ur(e, t) { 421 F("recoil_memory_managament_2020") && (t === void 0 ? ut.delete(e) : ut.set(e, t)); 422} 423function Kn(e) { 424 return ut.get(e); 425} 426var ue = { 427 recoilValues: qt, 428 registerNode: $r, 429 getNode: kr, 430 getNodeMaybe: Dr, 431 deleteNodeConfigIfPossible: Ir, 432 setConfigDeletionHandler: Ur, 433 getConfigDeletionHandler: Kn, 434 recoilValuesForKeys: Cr, 435 DefaultValue: Wn, 436 DEFAULT_VALUE: Nr 437}; 438function xr(e, t) { 439 t(); 440} 441var Pr = { 442 enqueueExecution: xr 443}; 444function Or(e, t) { 445 return t = { exports: {} }, e(t, t.exports), t.exports; 446} 447var Br = Or(function(e) { 448 var t = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(l) { 449 return typeof l; 450 } : function(l) { 451 return l && typeof Symbol == "function" && l.constructor === Symbol && l !== Symbol.prototype ? "symbol" : typeof l; 452 }, n = {}, o = 5, r = Math.pow(2, o), a = r - 1, i = r / 2, u = r / 4, d = {}, f = function(s) { 453 return function() { 454 return s; 455 }; 456 }, p = n.hash = function(l) { 457 var s = typeof l > "u" ? "undefined" : t(l); 458 if (s === "number") 459 return l; 460 s !== "string" && (l += ""); 461 for (var h = 0, m = 0, y = l.length; m < y; ++m) { 462 var S = l.charCodeAt(m); 463 h = (h << 5) - h + S | 0; 464 } 465 return h; 466 }, g = function(s) { 467 return s -= s >> 1 & 1431655765, s = (s & 858993459) + (s >> 2 & 858993459), s = s + (s >> 4) & 252645135, s += s >> 8, s += s >> 16, s & 127; 468 }, I = function(s, h) { 469 return h >>> s & a; 470 }, N = function(s) { 471 return 1 << s; 472 }, E = function(s, h) { 473 return g(s & h - 1); 474 }, $ = function(s, h, m, y) { 475 var S = y; 476 if (!s) { 477 var L = y.length; 478 S = new Array(L); 479 for (var T = 0; T < L; ++T) 480 S[T] = y[T]; 481 } 482 return S[h] = m, S; 483 }, Q = function(s, h, m) { 484 var y = m.length - 1, S = 0, L = 0, T = m; 485 if (s) 486 S = L = h; 487 else 488 for (T = new Array(y); S < h; ) 489 T[L++] = m[S++]; 490 for (++S; S <= y; ) 491 T[L++] = m[S++]; 492 return s && (T.length = y), T; 493 }, te = function(s, h, m, y) { 494 var S = y.length; 495 if (s) { 496 for (var L = S; L >= h; ) 497 y[L--] = y[L]; 498 return y[h] = m, y; 499 } 500 for (var T = 0, A = 0, D = new Array(S + 1); T < h; ) 501 D[A++] = y[T++]; 502 for (D[h] = m; T < S; ) 503 D[++A] = y[T++]; 504 return D; 505 }, w = 1, U = 2, Y = 3, z = 4, G = { 506 __hamt_isEmpty: !0 507 }, q = function(s) { 508 return s === G || s && s.__hamt_isEmpty; 509 }, re = function(s, h, m, y) { 510 return { 511 type: w, 512 edit: s, 513 hash: h, 514 key: m, 515 value: y, 516 _modify: Me 517 }; 518 }, ye = function(s, h, m) { 519 return { 520 type: U, 521 edit: s, 522 hash: h, 523 children: m, 524 _modify: ke 525 }; 526 }, J = function(s, h, m) { 527 return { 528 type: Y, 529 edit: s, 530 mask: h, 531 children: m, 532 _modify: x 533 }; 534 }, de = function(s, h, m) { 535 return { 536 type: z, 537 edit: s, 538 size: h, 539 children: m, 540 _modify: B 541 }; 542 }, $e = function(s) { 543 return s === G || s.type === w || s.type === U; 544 }, X = function(s, h, m, y, S) { 545 for (var L = [], T = y, A = 0, D = 0; T; ++D) 546 T & 1 && (L[D] = S[A++]), T >>>= 1; 547 return L[h] = m, de(s, A + 1, L); 548 }, le = function(s, h, m, y) { 549 for (var S = new Array(h - 1), L = 0, T = 0, A = 0, D = y.length; A < D; ++A) 550 if (A !== m) { 551 var H = y[A]; 552 H && !q(H) && (S[L++] = H, T |= 1 << A); 553 } 554 return J(s, T, S); 555 }, we = function l(s, h, m, y, S, L) { 556 if (m === S) 557 return ye(s, m, [L, y]); 558 var T = I(h, m), A = I(h, S); 559 return J(s, N(T) | N(A), T === A ? [l(s, h + o, m, y, S, L)] : T < A ? [y, L] : [L, y]); 560 }, fe = function(s, h, m, y, S, L, T, A) { 561 for (var D = S.length, H = 0; H < D; ++H) { 562 var se = S[H]; 563 if (m(T, se.key)) { 564 var oe = se.value, he = L(oe); 565 return he === oe ? S : he === d ? (--A.value, Q(s, H, S)) : $(s, H, re(h, y, T, he), S); 566 } 567 } 568 var pe = L(); 569 return pe === d ? S : (++A.value, $(s, D, re(h, y, T, pe), S)); 570 }, Se = function(s, h) { 571 return s === h.edit; 572 }, Me = function(s, h, m, y, S, L, T) { 573 if (h(L, this.key)) { 574 var A = y(this.value); 575 return A === this.value ? this : A === d ? (--T.value, G) : Se(s, this) ? (this.value = A, this) : re(s, S, L, A); 576 } 577 var D = y();
578 return D === d ? this : (++T.value, we(s, m, this.hash, this, S, re(s, S, L, D))); 579 }, ke = function(s, h, m, y, S, L, T) { 580 if (S === this.hash) { 581 var A = Se(s, this), D = fe(A, s, h, this.hash, this.children, y, L, T); 582 return D === this.children ? this : D.length > 1 ? ye(s, this.hash, D) : D[0]; 583 } 584 var H = y(); 585 return H === d ? this : (++T.value, we(s, m, this.hash, this, S, re(s, S, L, H))); 586 }, x = function(s, h, m, y, S, L, T) { 587 var A = this.mask, D = this.children, H = I(m, S), se = N(H), oe = E(A, se), he = A & se, pe = he ? D[oe] : G, De = pe._modify(s, h, m + o, y, S, L, T); 588 if (pe === De) 589 return this; 590 var ot = Se(s, this), ze = A, Fe = void 0; 591 if (he && q(De)) { 592 if (ze &= ~se, !ze) 593 return G; 594 if (D.length <= 2 && $e(D[oe ^ 1])) 595 return D[oe ^ 1]; 596 Fe = Q(ot, oe, D); 597 } else if (!he && !q(De)) { 598 if (D.length >= i) 599 return X(s, H, De, A, D); 600 ze |= se, Fe = te(ot, oe, De, D); 601 } else 602 Fe = $(ot, oe, De, D); 603 return ot ? (this.mask = ze, this.children = Fe, this) : J(s, ze, Fe); 604 }, B = function(s, h, m, y, S, L, T) { 605 var A = this.size, D = this.children, H = I(m, S), se = D[H], oe = (se || G)._modify(s, h, m + o, y, S, L, T); 606 if (se === oe) 607 return this; 608 var he = Se(s, this), pe = void 0; 609 if (q(se) && !q(oe)) 610 ++A, pe = $(he, H, oe, D); 611 else if (!q(se) && q(oe)) { 612 if (--A, A <= u) 613 return le(s, A, H, D); 614 pe = $(he, H, G, D); 615 } else 616 pe = $(he, H, oe, D); 617 return he ? (this.size = A, this.children = pe, this) : de(s, A, pe); 618 }; 619 G._modify = function(l, s, h, m, y, S, L) { 620 var T = m(); 621 return T === d ? G : (++L.value, re(l, y, S, T)); 622 }; 623 function c(l, s, h, m, y) { 624 this._editable = l, this._edit = s, this._config = h, this._root = m, this._size = y; 625 } 626 c.prototype.setTree = function(l, s) { 627 return this._editable ? (this._root = l, this._size = s, this) : l === this._root ? this : new c(this._editable, this._edit, this._config, l, s); 628 }; 629 var v = n.tryGetHash = function(l, s, h, m) { 630 for (var y = m._root, S = 0, L = m._config.keyEq; ; ) 631 switch (y.type) { 632 case w: 633 return L(h, y.key) ? y.value : l; 634 case U: { 635 if (s === y.hash) 636 for (var T = y.children, A = 0, D = T.length; A < D; ++A) { 637 var H = T[A]; 638 if (L(h, H.key)) 639 return H.value; 640 } 641 return l; 642 } 643 case Y: { 644 var se = I(S, s), oe = N(se); 645 if (y.mask & oe) { 646 y = y.children[E(y.mask, oe)], S += o; 647 break; 648 } 649 return l; 650 } 651 case z: { 652 if (y = y.children[I(S, s)], y) { 653 S += o; 654 break; 655 } 656 return l; 657 } 658 default: 659 return l; 660 } 661 }; 662 c.prototype.tryGetHash = function(l, s, h) { 663 return v(l, s, h, this); 664 }; 665 var _ = n.tryGet = function(l, s, h) { 666 return v(l, h._config.hash(s), s, h); 667 }; 668 c.prototype.tryGet = function(l, s) { 669 return _(l, s, this); 670 }; 671 var C = n.getHash = function(l, s, h) { 672 return v(void 0, l, s, h); 673 }; 674 c.prototype.getHash = function(l, s) { 675 return C(l, s, this); 676 }, n.get = function(l, s) { 677 return v(void 0, s._config.hash(l), l, s); 678 }, c.prototype.get = function(l, s) { 679 return _(s, l, this); 680 }; 681 var R = n.has = function(l, s, h) { 682 return v(d, l, s, h) !== d; 683 }; 684 c.prototype.hasHash = function(l, s) { 685 return R(l, s, this); 686 }; 687 var k = n.has = function(l, s) { 688 return R(s._config.hash(l), l, s); 689 }; 690 c.prototype.has = function(l) { 691 return k(l, this); 692 }; 693 var b = function(s, h) { 694 return s === h; 695 }; 696 n.make = function(l) { 697 return new c(0, 0, { 698 keyEq: l && l.keyEq || b, 699 hash: l && l.hash || p 700 }, G, 0); 701 }, n.empty = n.make(); 702 var P = n.isEmpty = function(l) { 703 return l && !!q(l._root); 704 }; 705 c.prototype.isEmpty = function() { 706 return P(this); 707 }; 708 var W = n.modifyHash = function(l, s, h, m) { 709 var y = { 710 value: m._size 711 }, S = m._root._modify(m._editable ? m._edit : NaN, m._config.keyEq, 0, l, s, h, y); 712 return m.setTree(S, y.value); 713 }; 714 c.prototype.modifyHash = function(l, s, h) { 715 return W(h, l, s, this); 716 }; 717 var ee = n.modify = function(l, s, h) { 718 return W(l, h._config.hash(s), s, h); 719 }; 720 c.prototype.modify = function(l, s) { 721 return ee(s, l, this); 722 }; 723 var O = n.setHash = function(l, s, h, m) { 724 return W(f(h), l, s, m); 725 }; 726 c.prototype.setHash = function(l, s, h) { 727 return O(l, s, h, this); 728 }; 729 var ne = n.set = function(l, s, h) { 730 return O(h._config.hash(l), l, s, h); 731 }; 732 c.prototype.set = function(l, s) { 733 return ne(l, s, this); 734 }; 735 var me = f(d), ce = n.removeHash = function(l, s, h) { 736 return W(me, l, s, h); 737 }; 738 c.prototype.removeHash = c.prototype.deleteHash = function(l, s) { 739 return ce(l, s, this); 740 }; 741 var ae = n.remove = function(l, s) { 742 return ce(s._config.hash(l), l, s); 743 }; 744 c.prototype.remove = c.prototype.delete = function(l) { 745 return ae(l, this); 746 }; 747 var nt = n.beginMutation = function(l) {
748 return new c(l._editable + 1, l._edit + 1, l._config, l._root, l._size); 749 }; 750 c.prototype.beginMutation = function() { 751 return nt(this); 752 }; 753 var ln = n.endMutation = function(l) { 754 return l._editable = l._editable && l._editable - 1, l; 755 }; 756 c.prototype.endMutation = function() { 757 return ln(this); 758 }; 759 var Bo = n.mutate = function(l, s) { 760 var h = nt(s); 761 return l(h), ln(h); 762 }; 763 c.prototype.mutate = function(l) { 764 return Bo(l, this); 765 }; 766 var Lt = function(s) { 767 return s && cn(s[0], s[1], s[2], s[3], s[4]); 768 }, cn = function(s, h, m, y, S) { 769 for (; m < s; ) { 770 var L = h[m++]; 771 if (L && !q(L)) 772 return un(L, y, [s, h, m, y, S]); 773 } 774 return Lt(S); 775 }, un = function(s, h, m) { 776 switch (s.type) { 777 case w: 778 return { 779 value: h(s), 780 rest: m 781 }; 782 case U: 783 case z: 784 case Y: 785 var y = s.children; 786 return cn(y.length, y, 0, h, m); 787 default: 788 return Lt(m); 789 } 790 }, zo = { 791 done: !0 792 }; 793 function Nt(l) { 794 this.v = l; 795 } 796 Nt.prototype.next = function() { 797 if (!this.v) 798 return zo; 799 var l = this.v; 800 return this.v = Lt(l.rest), l; 801 }, Nt.prototype[Symbol.iterator] = function() { 802 return this; 803 }; 804 var Ct = function(s, h) { 805 return new Nt(un(s._root, h)); 806 }, Fo = function(s) { 807 return [s.key, s.value]; 808 }, Wo = n.entries = function(l) { 809 return Ct(l, Fo); 810 }; 811 c.prototype.entries = c.prototype[Symbol.iterator] = function() { 812 return Wo(this); 813 }; 814 var Ko = function(s) { 815 return s.key; 816 }, Go = n.keys = function(l) { 817 return Ct(l, Ko); 818 }; 819 c.prototype.keys = function() { 820 return Go(this); 821 }; 822 var Ho = function(s) { 823 return s.value; 824 }, jo = n.values = c.prototype.values = function(l) { 825 return Ct(l, Ho); 826 }; 827 c.prototype.values = function() { 828 return jo(this); 829 }; 830 var dn = n.fold = function(l, s, h) { 831 var m = h._root; 832 if (m.type === w) 833 return l(s, m.value, m.key); 834 for (var y = [m.children], S = void 0; S = y.pop(); ) 835 for (var L = 0, T = S.length; L < T; ) { 836 var A = S[L++]; 837 A && A.type && (A.type === w ? s = l(s, A.value, A.key) : y.push(A.children)); 838 } 839 return s; 840 }; 841 c.prototype.fold = function(l, s) { 842 return dn(l, s, this); 843 }; 844 var qo = n.forEach = function(l, s) { 845 return dn(function(h, m, y) { 846 return l(m, y, s); 847 }, null, s); 848 }; 849 c.prototype.forEach = function(l) { 850 return qo(l, this); 851 }; 852 var Zo = n.count = function(l) { 853 return l._size; 854 }; 855 c.prototype.count = function() { 856 return Zo(this); 857 }, Object.defineProperty(c.prototype, "size", { 858 get: c.prototype.count 859 }), e.exports ? e.exports = n : (void 0).hamt = n; 860}); 861class zr { 862 constructor(t) { 863 V(this, "_map", void 0), this._map = new Map(t == null ? void 0 : t.entries()); 864 } 865 keys() { 866 return this._map.keys(); 867 } 868 entries() { 869 return this._map.entries(); 870 } 871 get(t) { 872 return this._map.get(t); 873 } 874 has(t) { 875 return this._map.has(t); 876 } 877 set(t, n) { 878 return this._map.set(t, n), this; 879 } 880 delete(t) { 881 return this._map.delete(t), this; 882 } 883 clone() { 884 return Yt(this); 885 } 886 toMap() { 887 return new Map(this._map); 888 } 889} 890class Zt { 891 // Because hamt.empty is not a function there is no way to introduce type 892 // parameters on it, so empty is typed as HAMTPlusMap<string, mixed>. 893 // $FlowIssue 894 constructor(t) { 895 if (V(this, "_hamt", Br.empty.beginMutation()), t instanceof Zt) { 896 const n = t._hamt.endMutation(); 897 t._hamt = n.beginMutation(), this._hamt = n.beginMutation(); 898 } else if (t) 899 for (const [n, o] of t.entries()) 900 this._hamt.set(n, o); 901 } 902 keys() { 903 return this._hamt.keys(); 904 } 905 entries() { 906 return this._hamt.entries(); 907 } 908 get(t) { 909 return this._hamt.get(t); 910 } 911 has(t) { 912 return this._hamt.has(t); 913 } 914 set(t, n) { 915 return this._hamt.set(t, n), this; 916 } 917 delete(t) { 918 return this._hamt.delete(t), this; 919 } 920 clone() { 921 return Yt(this); 922 } 923 toMap() { 924 return new Map(this._hamt); 925 } 926} 927function Yt(e) { 928 return F("recoil_hamt_2020") ? new Zt(e) : new zr(e); 929} 930var Fr = { 931 persistentMap: Yt 932}, Wr = Fr.persistentMap, Kr = /* @__PURE__ */ Object.freeze({ 933 __proto__: null, 934 persistentMap: Wr 935}); 936function Gr(e, ...t) { 937 const n = /* @__PURE__ */ new Set(); 938 e: 939 for (const o of e) { 940 for (const r of t) 941 if (r.has(o)) 942 continue e; 943 n.add(o); 944 } 945 return n; 946} 947var hn = Gr; 948function Hr(e, t) { 949 const n = /* @__PURE__ */ new Map(); 950 return e.forEach((o, r) => { 951 n.set(r, t(o, r)); 952 }), n; 953} 954var vn = Hr; 955function jr() { 956 return { 957 nodeDeps: /* @__PURE__ */ new Map(), 958 nodeToNodeSubscriptions: /* @__PURE__ */ new Map() 959 }; 960} 961function qr(e) { 962 return { 963 nodeDeps: vn(e.nodeDeps, (t) => new Set(t)), 964 nodeToNodeSubscriptions: vn(e.nodeToNodeSubscriptions, (t) => new Set(t)) 965 }; 966} 967function kt(e, t, n, o) { 968 const { 969 nodeDeps: r, 970 nodeToNodeSubscriptions: a 971 } = n, i = r.get(e); 972 if (i && o && i !== o.nodeDeps.get(e)) 973 return; 974 r.set(e, t); 975 const u = i == null ? t : hn(t, i); 976 for (const d of u)
977 a.has(d) || a.set(d, /* @__PURE__ */ new Set()), j(a.get(d)).add(e); 978 if (i) { 979 const d = hn(i, t); 980 for (const f of d) { 981 if (!a.has(f)) 982 return; 983 const p = j(a.get(f)); 984 p.delete(e), p.size === 0 && a.delete(f); 985 } 986 } 987} 988function Zr(e, t, n, o) { 989 var r, a, i, u; 990 const d = n.getState(); 991 o === d.currentTree.version || o === ((r = d.nextTree) === null || r === void 0 ? void 0 : r.version) || o === ((a = d.previousTree) === null || a === void 0 ? void 0 : a.version) || ie(); 992 const f = n.getGraph(o); 993 if (kt(e, t, f), o === ((i = d.previousTree) === null || i === void 0 ? void 0 : i.version)) { 994 const g = n.getGraph(d.currentTree.version); 995 kt(e, t, g, f); 996 } 997 if (o === ((u = d.previousTree) === null || u === void 0 ? void 0 : u.version) || o === d.currentTree.version) { 998 var p; 999 const g = (p = d.nextTree) === null || p === void 0 ? void 0 : p.version; 1000 if (g !== void 0) { 1001 const I = n.getGraph(g); 1002 kt(e, t, I, f); 1003 } 1004 } 1005} 1006var Qe = { 1007 cloneGraph: qr, 1008 graph: jr, 1009 saveDepsToStore: Zr 1010}; 1011let Yr = 0; 1012const Xr = () => Yr++; 1013let Jr = 0; 1014const Qr = () => Jr++; 1015let ea = 0; 1016const ta = () => ea++; 1017var mt = { 1018 getNextTreeStateVersion: Xr, 1019 getNextStoreID: Qr, 1020 getNextComponentID: ta 1021}; 1022const { 1023 persistentMap: pn 1024} = Kr, { 1025 graph: na 1026} = Qe, { 1027 getNextTreeStateVersion: Gn 1028} = mt; 1029function oa() { 1030 const e = Gn(); 1031 return { 1032 version: e, 1033 stateID: e, 1034 transactionMetadata: {}, 1035 dirtyAtoms: /* @__PURE__ */ new Set(), 1036 atomValues: pn(), 1037 nonvalidatedAtoms: pn() 1038 }; 1039} 1040function ra() { 1041 const e = oa(); 1042 return { 1043 currentTree: e, 1044 nextTree: null, 1045 previousTree: null, 1046 commitDepth: 0, 1047 knownAtoms: /* @__PURE__ */ new Set(), 1048 knownSelectors: /* @__PURE__ */ new Set(), 1049 transactionSubscriptions: /* @__PURE__ */ new Map(), 1050 nodeTransactionSubscriptions: /* @__PURE__ */ new Map(), 1051 nodeToComponentSubscriptions: /* @__PURE__ */ new Map(), 1052 queuedComponentCallbacks_DEPRECATED: [], 1053 suspendedComponentResolvers: /* @__PURE__ */ new Set(), 1054 graphsByVersion: (/* @__PURE__ */ new Map()).set(e.version, na()), 1055 retention: { 1056 referenceCounts: /* @__PURE__ */ new Map(), 1057 nodesRetainedByZone: /* @__PURE__ */ new Map(), 1058 retainablesToCheckForRelease: /* @__PURE__ */ new Set() 1059 }, 1060 nodeCleanupFunctions: /* @__PURE__ */ new Map() 1061 }; 1062} 1063var Hn = { 1064 makeEmptyStoreState: ra, 1065 getNextTreeStateVersion: Gn 1066}; 1067class aa { 1068} 1069var Xt = { 1070 RetentionZone: aa 1071}; 1072function sa(e, t) { 1073 const n = new Set(e); 1074 return n.add(t), n; 1075} 1076var ia = { 1077 setByAddingToSet: sa 1078}; 1079function* la(e, t) { 1080 let n = 0; 1081 for (const o of e) 1082 t(o, n++) && (yield o); 1083} 1084var Jt = la; 1085function ca(e, t) { 1086 return new Proxy(e, { 1087 // Compute and cache lazy property if not already done. 1088 get: (o, r) => (!(r in o) && r in t && (o[r] = t[r]()), o[r]), 1089 // This method allows user to iterate keys as normal 1090 ownKeys: (o) => Object.keys(o) 1091 }); 1092} 1093var jn = ca; 1094const { 1095 getNode: et, 1096 getNodeMaybe: ua, 1097 recoilValuesForKeys: _n 1098} = ue, { 1099 RetentionZone: mn 1100} = Xt, { 1101 setByAddingToSet: da 1102} = ia, fa = Object.freeze(/* @__PURE__ */ new Set()); 1103class ha extends Error { 1104} 1105function va(e, t, n) { 1106 if (!F("recoil_memory_managament_2020")) 1107 return () => { 1108 }; 1109 const { 1110 nodesRetainedByZone: o 1111 } = e.getState().retention; 1112 function r(a) { 1113 let i = o.get(a); 1114 i || o.set(a, i = /* @__PURE__ */ new Set()), i.add(t); 1115 } 1116 if (n instanceof mn) 1117 r(n); 1118 else if (Array.isArray(n)) 1119 for (const a of n) 1120 r(a); 1121 return () => { 1122 if (!F("recoil_memory_managament_2020")) 1123 return; 1124 const { 1125 retention: a 1126 } = e.getState(); 1127 function i(u) { 1128 const d = a.nodesRetainedByZone.get(u); 1129 d == null || d.delete(t), d && d.size === 0 && a.nodesRetainedByZone.delete(u); 1130 } 1131 if (n instanceof mn) 1132 i(n); 1133 else if (Array.isArray(n)) 1134 for (const u of n) 1135 i(u); 1136 }; 1137} 1138function Qt(e, t, n, o) { 1139 const r = e.getState(); 1140 if (r.nodeCleanupFunctions.has(n)) 1141 return; 1142 const a = et(n), i = va(e, n, a.retainedBy), u = a.init(e, t, o); 1143 r.nodeCleanupFunctions.set(n, () => { 1144 u(), i(); 1145 }); 1146} 1147function pa(e, t, n) { 1148 Qt(e, e.getState().currentTree, t, n); 1149} 1150function _a(e, t) { 1151 var n; 1152 const o = e.getState(); 1153 (n = o.nodeCleanupFunctions.get(t)) === null || n === void 0 || n(), o.nodeCleanupFunctions.delete(t); 1154} 1155function ma(e, t, n) { 1156 return Qt(e, t, n, "get"), et(n).get(e, t); 1157} 1158function qn(e, t, n) { 1159 return et(n).peek(e, t); 1160} 1161function ya(e, t, n) { 1162 var o; 1163 const r = ua(t); 1164 return r == null || (o = r.invalidate) === null || o === void 0 || o.call(r, e), { 1165 ...e, 1166 atomValues: e.atomValues.clone().delete(t),
1167 nonvalidatedAtoms: e.nonvalidatedAtoms.clone().set(t, n), 1168 dirtyAtoms: da(e.dirtyAtoms, t) 1169 }; 1170} 1171function Sa(e, t, n, o) { 1172 const r = et(n); 1173 if (r.set == null) 1174 throw new ha(`Attempt to set read-only RecoilValue: ${n}`); 1175 const a = r.set; 1176 return Qt(e, t, n, "set"), a(e, t, o); 1177} 1178function ga(e, t, n) { 1179 const o = e.getState(), r = e.getGraph(t.version), a = et(n).nodeType; 1180 return jn({ 1181 type: a 1182 }, { 1183 // $FlowFixMe[underconstrained-implicit-instantiation] 1184 loadable: () => qn(e, t, n), 1185 isActive: () => o.knownAtoms.has(n) || o.knownSelectors.has(n), 1186 isSet: () => a === "selector" ? !1 : t.atomValues.has(n), 1187 isModified: () => t.dirtyAtoms.has(n), 1188 // Report current dependencies. If the node hasn't been evaluated, then 1189 // dependencies may be missing based on the current state. 1190 deps: () => { 1191 var i; 1192 return _n((i = r.nodeDeps.get(n)) !== null && i !== void 0 ? i : []); 1193 }, 1194 // Reports all "current" subscribers. Evaluating other nodes or 1195 // previous in-progress async evaluations may introduce new subscribers. 1196 subscribers: () => { 1197 var i, u; 1198 return { 1199 nodes: _n(Jt(Zn(e, t, /* @__PURE__ */ new Set([n])), (d) => d !== n)), 1200 components: _t((i = (u = o.nodeToComponentSubscriptions.get(n)) === null || u === void 0 ? void 0 : u.values()) !== null && i !== void 0 ? i : [], ([d]) => ({ 1201 name: d 1202 })) 1203 }; 1204 } 1205 }); 1206} 1207function Zn(e, t, n) { 1208 const o = /* @__PURE__ */ new Set(), r = Array.from(n), a = e.getGraph(t.version); 1209 for (let u = r.pop(); u; u = r.pop()) { 1210 var i; 1211 o.add(u); 1212 const d = (i = a.nodeToNodeSubscriptions.get(u)) !== null && i !== void 0 ? i : fa; 1213 for (const f of d) 1214 o.has(f) || r.push(f); 1215 } 1216 return o; 1217} 1218var Ne = { 1219 getNodeLoadable: ma, 1220 peekNodeLoadable: qn, 1221 setNodeValue: Sa, 1222 initializeNode: pa, 1223 cleanUpNode: _a, 1224 setUnvalidatedAtomValue_DEPRECATED: ya, 1225 peekNodeInfo: ga, 1226 getDownstreamNodes: Zn 1227}; 1228let Yn = null; 1229function Ra(e) { 1230 Yn = e; 1231} 1232function ba() { 1233 var e; 1234 (e = Yn) === null || e === void 0 || e(); 1235} 1236var Xn = { 1237 setInvalidateMemoizedSnapshot: Ra, 1238 invalidateMemoizedSnapshot: ba 1239}; 1240const { 1241 getDownstreamNodes: wa, 1242 getNodeLoadable: Jn, 1243 setNodeValue: Ea 1244} = Ne, { 1245 getNextComponentID: Ta 1246} = mt, { 1247 getNode: Aa, 1248 getNodeMaybe: Qn 1249} = ue, { 1250 DefaultValue: en 1251} = ue, { 1252 reactMode: La 1253} = Ht, { 1254 AbstractRecoilValue: Na, 1255 RecoilState: Sc, 1256 RecoilValueReadOnly: gc, 1257 isRecoilValue: Rc 1258} = Ae, { 1259 invalidateMemoizedSnapshot: Ca 1260} = Xn; 1261function Va(e, { 1262 key: t 1263}, n = e.getState().currentTree) { 1264 var o, r; 1265 const a = e.getState(); 1266 n.version === a.currentTree.version || n.version === ((o = a.nextTree) === null || o === void 0 ? void 0 : o.version) || n.version === ((r = a.previousTree) === null || r === void 0 ? void 0 : r.version) || ie(); 1267 const i = Jn(e, n, t); 1268 return i.state === "loading" && i.contents.catch(() => { 1269 }), i; 1270} 1271function $a(e, t) { 1272 const n = e.clone(); 1273 return t.forEach((o, r) => { 1274 o.state === "hasValue" && o.contents instanceof en ? n.delete(r) : n.set(r, o); 1275 }), n; 1276} 1277function Ma(e, t, { 1278 key: n 1279}, o) { 1280 if (typeof o == "function") { 1281 const r = Jn(e, t, n); 1282 if (r.state === "loading") { 1283 const a = `Tried to set atom or selector "${n}" using an updater function while the current state is pending, this is not currently supported.`; 1284 throw ie(), M(a); 1285 } else if (r.state === "hasError") 1286 throw r.contents; 1287 return o(r.contents); 1288 } else 1289 return o; 1290} 1291function ka(e, t, n) { 1292 if (n.type === "set") { 1293 const { 1294 recoilValue: r, 1295 valueOrUpdater: a 1296 } = n, i = Ma(e, t, r, a), u = Ea(e, t, r.key, i); 1297 for (const [d, f] of u.entries()) 1298 Ot(t, d, f); 1299 } else if (n.type === "setLoadable") { 1300 const { 1301 recoilValue: { 1302 key: r 1303 }, 1304 loadable: a 1305 } = n; 1306 Ot(t, r, a); 1307 } else if (n.type === "markModified") { 1308 const { 1309 recoilValue: { 1310 key: r 1311 } 1312 } = n; 1313 t.dirtyAtoms.add(r); 1314 } else if (n.type === "setUnvalidated") { 1315 var o; 1316 const { 1317 recoilValue: { 1318 key: r 1319 }, 1320 unvalidatedValue: a 1321 } = n, i = Qn(r); 1322 i == null || (o = i.invalidate) === null || o === void 0 || o.call(i, t), t.atomValues.delete(r), t.nonvali
1322datedAtoms.set(r, a), t.dirtyAtoms.add(r); 1323 } else 1324 ie(`Unknown action ${n.type}`); 1325} 1326function Ot(e, t, n) { 1327 n.state === "hasValue" && n.contents instanceof en ? e.atomValues.delete(t) : e.atomValues.set(t, n), e.dirtyAtoms.add(t), e.nonvalidatedAtoms.delete(t); 1328} 1329function eo(e, t) { 1330 e.replaceState((n) => { 1331 const o = to(n); 1332 for (const r of t) 1333 ka(e, o, r); 1334 return no(e, o), Ca(), o; 1335 }); 1336} 1337function yt(e, t) { 1338 if (Ze.length) { 1339 const n = Ze[Ze.length - 1]; 1340 let o = n.get(e); 1341 o || n.set(e, o = []), o.push(t); 1342 } else 1343 eo(e, [t]); 1344} 1345const Ze = []; 1346function Da() { 1347 const e = /* @__PURE__ */ new Map(); 1348 return Ze.push(e), () => { 1349 for (const [n, o] of e) 1350 eo(n, o); 1351 Ze.pop() !== e && ie(); 1352 }; 1353} 1354function to(e) { 1355 return { 1356 ...e, 1357 atomValues: e.atomValues.clone(), 1358 nonvalidatedAtoms: e.nonvalidatedAtoms.clone(), 1359 dirtyAtoms: new Set(e.dirtyAtoms) 1360 }; 1361} 1362function no(e, t) { 1363 const n = wa(e, t, t.dirtyAtoms); 1364 for (const a of n) { 1365 var o, r; 1366 (o = Qn(a)) === null || o === void 0 || (r = o.invalidate) === null || r === void 0 || r.call(o, t); 1367 } 1368} 1369function oo(e, t, n) { 1370 yt(e, { 1371 type: "set", 1372 recoilValue: t, 1373 valueOrUpdater: n 1374 }); 1375} 1376function Ia(e, t, n) { 1377 if (n instanceof en) 1378 return oo(e, t, n); 1379 yt(e, { 1380 type: "setLoadable", 1381 recoilValue: t, 1382 loadable: n 1383 }); 1384} 1385function Ua(e, t) {
1386 yt(e, { 1387 type: "markModified", 1388 recoilValue: t 1389 }); 1390} 1391function xa(e, t, n) { 1392 yt(e, { 1393 type: "setUnvalidated", 1394 recoilValue: t, 1395 unvalidatedValue: n 1396 }); 1397} 1398function Pa(e, { 1399 key: t 1400}, n, o = null) { 1401 const r = Ta(), a = e.getState(); 1402 a.nodeToComponentSubscriptions.has(t) || a.nodeToComponentSubscriptions.set(t, /* @__PURE__ */ new Map()), j(a.nodeToComponentSubscriptions.get(t)).set(r, [o ?? "<not captured>", n]); 1403 const i = La(); 1404 if (i.early && (i.mode === "LEGACY" || i.mode === "MUTABLE_SOURCE")) { 1405 const u = e.getState().nextTree; 1406 u && u.dirtyAtoms.has(t) && n(u); 1407 } 1408 return { 1409 release: () => { 1410 const u = e.getState(), d = u.nodeToComponentSubscriptions.get(t); 1411 if (d === void 0 || !d.has(r)) { 1412 ie(); 1413 return; 1414 } 1415 d.delete(r), d.size === 0 && u.nodeToComponentSubscriptions.delete(t); 1416 } 1417 }; 1418} 1419function Oa(e, t) { 1420 var n; 1421 const { 1422 currentTree: o 1423 } = e.getState(), r = Aa(t.key); 1424 (n = r.clearCache) === null || n === void 0 || n.call(r, e, o); 1425} 1426var ge = { 1427 AbstractRecoilValue: Na, 1428 getRecoilValueAsLoadable: Va, 1429 setRecoilValue: oo,
1430 setRecoilValueLoadable: Ia, 1431 markRecoilValueModified: Ua, 1432 setUnvalidatedRecoilValue: xa, 1433 subscribeToRecoilValue: Pa, 1434 applyAtomValueWrites: $a, 1435 // TODO Remove export when deprecating initialStoreState_DEPRECATED in RecoilRoot 1436 batchStart: Da, 1437 writeLoadableToTreeState: Ot, 1438 invalidateDownstreams: no, 1439 copyTreeState: to, 1440 refreshRecoilValue: Oa 1441}; 1442function Ba(e, t, n) { 1443 const o = e.entries(); 1444 let r = o.next(); 1445 for (; !r.done; ) { 1446 const a = r.value; 1447 if (t.call(n, a[1], a[0], e)) 1448 return !0; 1449 r = o.next(); 1450 } 1451 return !1; 1452} 1453var za = Ba; 1454const { 1455 cleanUpNode: Fa 1456} = Ne, { 1457 deleteNodeConfigIfPossible: Wa, 1458 getNode: ro 1459} = ue, { 1460 RetentionZone: ao 1461} = Xt, Ka = 12e4, so = /* @__PURE__ */ new Set(); 1462function io(e, t) { 1463 const n = e.getState(), o = n.currentTree; 1464 if (n.nextTree) { 1465 ie(); 1466 return; 1467 } 1468 const r = /* @__PURE__ */ new Set(); 1469 for (const i of t) 1470 if (i instanceof ao) 1471 for (const u of qa(n, i)) 1472 r.add(u); 1473 else 1474 r.add(i); 1475 const a = Ga(e, r); 1476 for (const i of a) 1477 ja(e, o, i); 1478} 1479function Ga(e, t) { 1480 const n = e.getState(), o = n.currentTree, r = e.getGraph(o.version), a = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(); 1481 return u(t), a; 1482 function u(d) { 1483 const f = /* @__PURE__ */ new Set(), p = Ha( 1484 e, 1485 o, 1486 d, 1487 a, 1488 // don't descend into these 1489 i 1490 // don't descend into these 1491 ); 1492 for (const E of p) { 1493 var g; 1494 if (ro(E).retainedBy === "recoilRoot") { 1495 i.add(E); 1496 continue; 1497 } 1498 if (((g = n.retention.referenceCounts.get(E)) !== null && g !== void 0 ? g : 0) > 0) { 1499 i.add(E); 1500 continue; 1501 } 1502 if (lo(E).some((Q) => n.retention.referenceCounts.get(Q))) { 1503 i.add(E); 1504 continue; 1505 } 1506 const $ = r.nodeToNodeSubscriptions.get(E); 1507 if ($ && za($, (Q) => i.has(Q))) { 1508 i.add(E); 1509 continue; 1510 } 1511 a.add(E), f.add(E); 1512 } 1513 const I = /* @__PURE__ */ new Set(); 1514 for (const E of f) 1515 for (const $ of (N = r.nodeDeps.get(E)) !== null && N !== void 0 ? N : so) { 1516 var N; 1517 a.has($) || I.add($); 1518 } 1519 I.size && u(I); 1520 } 1521} 1522function Ha(e, t, n, o, r) { 1523 const a = e.getGraph(t.version), i = [], u = /* @__PURE__ */ new Set(); 1524 for (; n.size > 0; ) 1525 d(j(n.values().next().value)); 1526 return i; 1527 function d(f) { 1528 if (o.has(f) || r.has(f)) { 1529 n.delete(f); 1530 return; 1531 } 1532 if (u.has(f)) 1533 return; 1534 const p = a.nodeToNodeSubscriptions.get(f); 1535 if (p) 1536 for (const g of p) 1537 d(g); 1538 u.add(f), n.delete(f), i.push(f); 1539 } 1540} 1541function ja(e, t, n) { 1542 if (!F("recoil_memory_managament_2020")) 1543 return; 1544 Fa(e, n); 1545 const o = e.getState(); 1546 o.knownAtoms.delete(n), o.knownSelectors.delete(n), o.nodeTransactionSubscriptions.delete(n), o.retention.referenceCounts.delete(n); 1547 const r = lo(n); 1548 for (const d of r) { 1549 var a; 1550 (a = o.retention.nodesRetainedByZone.get(d)) === null || a === void 0 || a.delete(n); 1551 } 1552 t.atomValues.delete(n), t.dirtyAtoms.delete(n), t.nonvalidatedAtoms.delete(n); 1553 const i = o.graphsByVersion.get(t.version); 1554 if (i) { 1555 const d = i.nodeDeps.get(n); 1556 if (d !== void 0) { 1557 i.nodeDeps.delete(n); 1558 for (const f of d) { 1559 var u; 1560 (u = i.nodeToNodeSubscriptions.get(f)) === null || u === void 0 || u.delete(n); 1561 } 1562 } 1563 i.nodeToNodeSubscriptions.delete(n); 1564 } 1565 Wa(n); 1566} 1567function qa(e, t) { 1568 var n; 1569 return (n = e.retention.nodesRetainedByZone.get(t)) !== null && n !== void 0 ? n : so; 1570} 1571function lo(e) { 1572 const t = ro(e).retainedBy; 1573 return t === void 0 || t === "components" || t === "recoilRoot" ? [] : t instanceof ao ? [t] : t; 1574} 1575function Za(e, t) { 1576 const n = e.getState(); 1577 n.nextTree ? n.retention.retainablesToCheckForRelease.add(t) : io(e, /* @__PURE__ */ new Set([t])); 1578} 1579function Ya(e, t, n) { 1580 var o; 1581 if (!F("recoil_memory_managament_2020")) 1582 return; 1583 const r = e.getState().retention.referenceCounts, a = ((o = r.get(t)) !== null && o !== void 0 ? o : 0) + n; 1584 a === 0 ? Xa(e, t) : r.set(t, a); 1585} 1586function Xa(e, t) { 1587 if (!F("recoil_memory_managament_2020")) 1588 return; 1589 e.getState().retention.referenceCounts.delete(t), Za(e, t); 1590} 1591function Ja(e) { 1592 if (!F("recoil_memory_managament_2020")) 1593 return; 1594 const t = e.getState(); 1595 io(e, t.retention.retainablesToCheckForRelease), t.retention.retainablesToCheckForRelease.clear(); 1596} 1597function Qa(e) { 1598 return e === void 0 ? "recoilRoot" : e; 1599} 1600var Be = { 1601 SUSPENSE_TIMEOUT_MS: Ka, 1602 updateRetainCount: Ya, 1603 releaseScheduledRetainablesNow: Ja, 1604 retainedByOptionWithDefault: Qa 1605}; 1606const { 1607 unstable_batchedUpdates: es 1608} = Yo; 1609var ts = { 1610 unstable_batchedUpdates: es 1611}; 1612const { 1613 unstable_batchedUpdates: ns 1614} = ts; 1615var os = { 1616 unstable_batchedUpdates: ns 1617}; 1618const { 1619 batchStart: rs 1620} = ge, { 1621 unstable_batchedUpdates: as 1622} = os; 1623let ss = as || ((e) => e()); 1624const is = (e) => { 1625 ss(() => { 1626 let t = () => { 1627 }; 1628 try { 1629 t = rs(), e(); 1630 } finally { 1631 t(); 1632 } 1633 }); 1634}; 1635var tn = { 1636 batchUpdates: is 1637}; 1638function* ls(e) { 1639 for (const t of e) 1640 for (const n of t) 1641 yield n; 1642}
1643var co = ls; 1644const cs = ( 1645 // $FlowFixMe(site=recoil) Window does not have a FlowType definition https://github.com/facebook/flow/issues/6709 1646 typeof Window > "u" || typeof window > "u" 1647); 1648var nn = { 1649 isSSR: cs 1650}; 1651function us(e, t) { 1652 let n, o; 1653 return [(...i) => { 1654 const u = t(...i); 1655 return n === u || (n = u, o = e(...i)), o; 1656 }, () => { 1657 n = null; 1658 }]; 1659} 1660var ds = { 1661 memoizeOneWithArgsHashAndInvalidation: us 1662}; 1663const { 1664 batchUpdates: Bt 1665} = tn, { 1666 initializeNode: fs, 1667 peekNodeInfo: hs 1668} = Ne, { 1669 graph: vs 1670} = Qe, { 1671 getNextStoreID: ps 1672} = mt, { 1673 DEFAULT_VALUE: _s, 1674 recoilValues: yn, 1675 recoilValuesForKeys: Sn 1676} = ue, { 1677 AbstractRecoilValue: ms, 1678 getRecoilValueAsLoadable: ys, 1679 setRecoilValue: gn, 1680 setUnvalidatedRecoilValue: Ss 1681} = ge, { 1682 updateRetainCount: ct 1683} = Be, { 1684 setInvalidateMemoizedSnapshot: gs 1685} = Xn, { 1686 getNextTreeStateVersion: Rs, 1687 makeEmptyStoreState: bs 1688} = Hn, { 1689 isSSR: ws 1690} = nn, { 1691 memoizeOneWithArgsHashAndInvalidation: Es 1692} = ds; 1693class St { 1694 // eslint-disable-next-line fb-www/no-uninitialized-properties 1695 constructor(t, n) { 1696 V(this, "_store", void 0), V(this, "_refCount", 1), V(this, "getLoadable", (o) => (this.checkRefCount_INTERNAL(), ys(this._store, o))), V(this, "getPromise", (o) => (this.checkRefCount_INTERNAL(), this.getLoadable(o).toPromise())), V(this, "getNodes_UNSTABLE", (o) => { 1697 if (this.checkRefCount_INTERNAL(), (o == null ? void 0 : o.isModified) === !0) { 1698 if ((o == null ? void 0 : o.isInitialized) === !1) 1699 return []; 1700 const i = this._store.getState().currentTree; 1701 return Sn(i.dirtyAtoms); 1702 } 1703 const r = this._store.getState().knownAtoms, a = this._store.getState().knownSelectors; 1704 return (o == null ? void 0 : o.isInitialized) == null ? yn.values() : o.isInitialized === !0 ? Sn(co([r, a])) : Jt(yn.values(), ({ 1705 key: i 1706 }) => !r.has(i) && !a.has(i)); 1707 }), V(this, "getInfo_UNSTABLE", ({ 1708 key: o 1709 }) => (this.checkRefCount_INTERNAL(), hs(this._store, this._store.getState().currentTree, o))), V(this, "map", (o) => { 1710 this.checkRefCount_INTERNAL(); 1711 const r = new zt(this, Bt); 1712 return o(r), r; 1713 }), V(this, "asyncMap", async (o) => { 1714 this.checkRefCount_INTERNAL(); 1715 const r = new zt(this, Bt); 1716 return r.retain(), await o(r), r.autoRelease_INTERNAL(), r; 1717 }), this._store = { 1718 storeID: ps(), 1719 parentStoreID: n, 1720 getState: () => t, 1721 replaceState: (o) => { 1722 t.currentTree = o(t.currentTree); 1723 }, 1724 getGraph: (o) => { 1725 const r = t.graphsByVersion; 1726 if (r.has(o)) 1727 return j(r.get(o)); 1728 const a = vs(); 1729 return r.set(o, a), a; 1730 }, 1731 subscribeToTransactions: () => ({ 1732 release: () => { 1733 } 1734 }), 1735 addTransactionMetadata: () => { 1736 throw M("Cannot subscribe to Snapshots"); 1737 } 1738 }; 1739 for (const o of this._store.getState().knownAtoms) 1740 fs(this._store, o, "get"), ct(this._store, o, 1); 1741 this.autoRelease_INTERNAL(); 1742 } 1743 retain() { 1744 this._refCount <= 0 && ie(), this._refCount++; 1745 let t = !1; 1746 return () => { 1747 t || (t = !0, this._release()); 1748 }; 1749 } 1750 /** 1751 * Release the snapshot on the next tick. This means the snapshot is retained 1752 * during the execution of the current function using it. 1753 */ 1754 autoRelease_INTERNAL() { 1755 ws || window.setTimeout(() => this._release(), 10); 1756 } 1757 _release() { 1758 if (this._refCount--, this._refCount === 0) { 1759 if (this._store.getState().nodeCleanupFunctions.forEach((t) => t()), this._store.getState().nodeCleanupFunctions.clear(), !F("recoil_memory_managament_2020")) 1760 return; 1761 } else 1762 this._refCount < 0; 1763 } 1764 isRetained() { 1765 return this._refCount > 0; 1766 } 1767 checkRefCount_INTERNAL() { 1768 F("recoil_memory_managament_2020") && this._refCount <= 0; 1769 } 1770 getStore_INTERNAL() { 1771 return this.checkRefCount_INTERNAL(), this._store; 1772 } 1773 getID() { 1774 return this.checkRefCount_INTERNAL(), this._store.getState().currentTree.stateID; 1775 } 1776 getStoreID() { 1777 return this.checkRefCount_INTERNAL(), this._store.storeID; 1778 } 1779 // We want to allow the methods to be destructured and used as accessors 1780 /* eslint-disable fb-www/extra-arrow-initializer */ 1781 /* eslint-enable fb-www/extra-arrow-initializer */ 1782} 1783function uo(e, t, n = !1) { 1784 const o = e.getState(), r = n ? Rs() : t.version; 1785 return { 1786 // Always clone the TreeState to isolate stores from accidental mutations. 1787 // For example, reading a selector from a cloned snapshot shouldn't cache 1788 // in the original treestate which may cause the original to skip 1789 // initialization of upstream atoms. 1790 currentTree: { 1791 // TODO snapshots shouldn't really have versions because a new version number 1792 // is always assigned when the snapshot is gone to. 1793 version: n ? r : t.version, 1794 stateID: n ? r : t.stateID, 1795 transactionMetadata: { 1796 ...t.transactionMetadata 1797 }, 1798 dirtyAtoms: new Set(t.dirtyAtoms), 1799 atomValues: t.atomValues.clone(),
1800 nonvalidatedAtoms: t.nonvalidatedAtoms.clone() 1801 }, 1802 commitDepth: 0, 1803 nextTree: null, 1804 previousTree: null, 1805 knownAtoms: new Set(o.knownAtoms), 1806 // FIXME here's a copy 1807 knownSelectors: new Set(o.knownSelectors), 1808 // FIXME here's a copy 1809 transactionSubscriptions: /* @__PURE__ */ new Map(), 1810 nodeTransactionSubscriptions: /* @__PURE__ */ new Map(), 1811 nodeToComponentSubscriptions: /* @__PURE__ */ new Map(), 1812 queuedComponentCallbacks_DEPRECATED: [], 1813 suspendedComponentResolvers: /* @__PURE__ */ new Set(), 1814 graphsByVersion: (/* @__PURE__ */ new Map()).set(r, e.getGraph(t.version)), 1815 retention: { 1816 referenceCounts: /* @__PURE__ */ new Map(), 1817 nodesRetainedByZone: /* @__PURE__ */ new Map(), 1818 retainablesToCheckForRelease: /* @__PURE__ */ new Set() 1819 }, 1820 // FIXME here's a copy 1821 // Create blank cleanup handlers for atoms so snapshots don't re-run 1822 // atom effects. 1823 nodeCleanupFunctions: new Map(_t(o.nodeCleanupFunctions.entries(), ([a]) => [a, () => { 1824 }])) 1825 }; 1826} 1827function Ts(e) { 1828 const t = new St(bs()); 1829 return e != null ? t.map(e) : t; 1830} 1831const [Rn, fo] = Es( 1832 // $FlowFixMe[missing-local-annot] 1833 (e, t) => { 1834 var n; 1835 const o = e.getState(), r = t === "latest" ? (n = o.nextTree) !== null && n !== void 0 ? n : o.currentTree : j(o.previousTree); 1836 return new St(uo(e, r), e.storeID); 1837 }, 1838 (e, t) => { 1839 var n, o; 1840 return String(t) + String(e.storeID) + String((n = e.getState().nextTree) === null || n === void 0 ? void 0 : n.version) + String(e.getState().currentTree.version) + String((o = e.getState().previousTree) === null || o === void 0 ? void 0 : o.version); 1841 } 1842); 1843gs(fo); 1844function As(e, t = "latest") { 1845 const n = Rn(e, t); 1846 return n.isRetained() ? n : (fo(), Rn(e, t)); 1847} 1848class zt extends St { 1849 constructor(t, n) { 1850 super(uo(t.getStore_INTERNAL(), t.getStore_INTERNAL().getState().currentTree, !0), t.getStoreID()), V(this, "_batch", void 0), V(this, "set", (o, r) => { 1851 this.checkRefCount_INTERNAL(); 1852 const a = this.getStore_INTERNAL(); 1853 this._batch(() => { 1854 ct(a, o.key, 1), gn(this.getStore_INTERNAL(), o, r); 1855 }); 1856 }), V(this, "reset", (o) => { 1857 this.checkRefCount_INTERNAL(); 1858 const r = this.getStore_INTERNAL(); 1859 this._batch(() => { 1860 ct(r, o.key, 1), gn(this.getStore_INTERNAL(), o, _s); 1861 }); 1862 }), V(this, "setUnvalidatedAtomValues_DEPRECATED", (o) => { 1863 this.checkRefCount_INTERNAL(); 1864 const r = this.getStore_INTERNAL(); 1865 Bt(() => { 1866 for (const [a, i] of o.entries()) 1867 ct(r, a, 1), Ss(r, new ms(a), i); 1868 }); 1869 }), this._batch = n; 1870 } 1871} 1872var gt = { 1873 Snapshot: St, 1874 MutableSnapshot: zt, 1875 freshSnapshot: Ts, 1876 cloneSnapshot: As 1877}, Ls = gt.Snapshot, Ns = gt.MutableSnapshot, Cs = gt.freshSnapshot, Vs = gt.cloneSnapshot, Rt = /* @__PURE__ */ Object.freeze({ 1878 __proto__: null, 1879 Snapshot: Ls, 1880 MutableSnapshot: Ns, 1881 freshSnapshot: Cs, 1882 cloneSnapshot: Vs 1883}); 1884function $s(...e) { 1885 const t = /* @__PURE__ */ new Set(); 1886 for (const n of e) 1887 for (const o of n) 1888 t.add(o); 1889 return t; 1890} 1891var Ms = $s; 1892const { 1893 useRef: ks 1894} = Z; 1895function Ds(e) { 1896 const t = ks(e); 1897 return t.current === e && typeof e == "function" && (t.current = e()), t; 1898} 1899var bn = Ds; 1900const { 1901 getNextTreeStateVersion: Is, 1902 makeEmptyStoreState: ho 1903} = Hn, { 1904 cleanUpNode: Us, 1905 getDownstreamNodes: xs, 1906 initializeNode: Ps, 1907 setNodeValue: Os, 1908 setUnvalidatedAtomValue_DEPRECATED: Bs 1909} = Ne, { 1910 graph: zs 1911} = Qe, { 1912 cloneGraph: Fs 1913} = Qe, { 1914 getNextStoreID: vo 1915} = mt, { 1916 createMutableSource: Dt, 1917 reactMode: po 1918} = Ht, { 1919 applyAtomValueWrites: Ws 1920} = ge, { 1921 releaseScheduledRetainablesNow: _o 1922} = Be, { 1923 freshSnapshot: Ks 1924} = Rt, { 1925 useCallback: Gs, 1926 useContext: mo, 1927 useEffect: Ft, 1928 useMemo: Hs, 1929 useRef: js, 1930 useState: qs 1931} = Z; 1932function We() { 1933 throw M("This component must be used inside a <RecoilRoot> component."); 1934} 1935const yo = Object.freeze({ 1936 storeID: vo(), 1937 getState: We, 1938 replaceState: We, 1939 getGraph: We, 1940 subscribeToTransactions: We, 1941 addTransactionMetadata: We 1942}); 1943let Wt = !1; 1944function wn(e) { 1945 if (Wt) 1946 throw M("An atom update was triggered within the execution of a state updater function. State updater functions provided to Recoil must be pure functions."); 1947 const t = e.getState(); 1948 if (t.nextTree === null) { 1949 F("recoil_memory_managament_2020") && F("recoil_release_on_cascading_update_killswitch_2021") && t.commitDepth > 0 && _o(e); 1950 const n = t.currentTree.version, o = Is(); 1951 t.nextTree = { 1952 ...t.currentTree, 1953 version: o, 1954 stateID: o, 1955 dirtyAtoms: /* @__PURE__ */ new Set(), 1956 transactionMetadata: {} 1957 }, t.graphsByVersion.set(o, Fs(j(t.graphsByVersion.get(n)))); 1958 } 1959} 1960const So = Z.createContext({ 1961 current: yo 1962}), on = () => mo(So), go = Z.createContext(null); 1963function Zs() { 1964 const e = mo(go); 1965 return e == null && Fn(), e; 1966} 1967function Ro(e, t, n) { 1968 const o = xs(e, n, n.dirtyAtoms); 1969 for (const r of o) { 1970 const a = t.nodeToComponentSubscriptions.get(r); 1971 if (a) 1972 for (const [i, [u, d]] of a) 1973 d(n); 1974 } 1975} 1976function Ys(e) { 1977 const t = e.getState(), n = t.currentTree, o = n.dirtyAtoms; 1978 if (o.size) { 1979 for (const [r, a] of t.nodeTransactionSubscriptions) 1980 if (o.has(r)) 1981 for (const [i, u] of a) 1982 u(e); 1983 for (const [r, a] of t.transactionSubscriptions) 1984 a(e); 1985 (!po().early || t.suspendedComponentResolvers.size >
1985 0) && (Ro(e, t, n), t.suspendedComponentResolvers.forEach((r) => r()), t.suspendedComponentResolvers.clear()); 1986 } 1987 t.queuedComponentCallbacks_DEPRECATED.forEach((r) => r(n)), t.queuedComponentCallbacks_DEPRECATED.splice(0, t.queuedComponentCallbacks_DEPRECATED.length); 1988} 1989function Xs(e) { 1990 const t = e.getState(); 1991 t.commitDepth++; 1992 try { 1993 const { 1994 nextTree: n 1995 } = t; 1996 if (n == null) 1997 return; 1998 t.previousTree = t.currentTree, t.currentTree = n, t.nextTree = null, Ys(e), t.previousTree != null ? t.graphsByVersion.delete(t.previousTree.version) : ie("Ended batch with no previous state, which is unexpected", "recoil"), t.previousTree = null, F("recoil_memory_managament_2020") && n == null && _o(e); 1999 } finally { 2000 t.commitDepth--; 2001 } 2002} 2003function Js({ 2004 setNotifyBatcherOfChange: e 2005}) { 2006 const t = on(), [, n] = qs([]); 2007 return e(() => n({})), Ft(() => (e(() => n({})), () => { 2008 e(() => { 2009 }); 2010 }), [e]), Ft(() => { 2011 Pr.enqueueExecution("Batcher", () => { 2012 Xs(t.current); 2013 }); 2014 }), null; 2015} 2016function Qs(e, t) { 2017 const n = ho(); 2018 return t({ 2019 set: (o, r) => { 2020 const a = n.currentTree, i = Os(e, a, o.key, r), u = new Set(i.keys()), d = a.nonvalidatedAtoms.clone(); 2021 for (const f of u) 2022 d.delete(f); 2023 n.currentTree = { 2024 ...a, 2025 dirtyAtoms: Ms(a.dirtyAtoms, u), 2026 atomValues: Ws(a.atomValues, i), 2027 // NB: PLEASE un-export applyAtomValueWrites when deleting this code 2028 nonvalidatedAtoms: d 2029 }; 2030 }, 2031 setUnvalidatedAtomValues: (o) => { 2032 o.forEach((r, a) => { 2033 n.currentTree = Bs(n.currentTree, a, r); 2034 }); 2035 } 2036 }), n; 2037} 2038function ei(e) { 2039 const t = Ks(e), n = t.getStore_INTERNAL().getState(); 2040 return t.retain(), n.nodeCleanupFunctions.forEach((o) => o()), n.nodeCleanupFunctions.clear(), n; 2041} 2042let En = 0; 2043function ti({ 2044 initializeState_DEPRECATED: e, 2045 initializeState: t, 2046 store_INTERNAL: n, 2047 // For use with React "context bridging" 2048 children: o 2049}) { 2050 let r; 2051 const a = (N) => { 2052 const E = r.current.graphsByVersion; 2053 if (E.has(N)) 2054 return j(E.get(N)); 2055 const $ = zs(); 2056 return E.set(N, $), $; 2057 }, i = (N, E) => { 2058 if (E == null) { 2059 const { 2060 transactionSubscriptions: $ 2061 } = g.current.getState(), Q = En++; 2062 return $.set(Q, N), { 2063 release: () => { 2064 $.delete(Q); 2065 } 2066 }; 2067 } else { 2068 const { 2069 nodeTransactionSubscriptions: $ 2070 } = g.current.getState(); 2071 $.has(E) || $.set(E, /* @__PURE__ */ new Map()); 2072 const Q = En++; 2073 return j($.get(E)).set(Q, N), { 2074 release: () => { 2075 const te = $.get(E); 2076 te && (te.delete(Q), te.size === 0 && $.delete(E)); 2077 } 2078 }; 2079 } 2080 }, u = (N) => { 2081 wn(g.current); 2082 for (const E of Object.keys(N)) 2083 j(g.current.getState().nextTree).transactionMetadata[E] = N[E]; 2084 }, d = (N) => { 2085 wn(g.current); 2086 const E = j(r.current.nextTree); 2087 let $; 2088 try { 2089 Wt = !0, $ = N(E); 2090 } finally { 2091 Wt = !1; 2092 } 2093 $ !== E && (r.current.nextTree = $, po().early && Ro(g.current, r.current, $), j(f.current)()); 2094 }, f = js(null), p = Gs((N) => { 2095 f.current = N; 2096 }, [f]), g = bn(() => n ?? { 2097 storeID: vo(), 2098 getState: () => r.current, 2099 replaceState: d, 2100 getGraph: a, 2101 subscribeToTransactions: i, 2102 addTransactionMetadata: u 2103 }); 2104 n != null && (g.current = n), r = bn(() => e != null ? Qs(g.current, e) : t != null ? ei(t) : ho()); 2105 const I = Hs(() => Dt == null ? void 0 : Dt(r, () => r.current.currentTree.version), [r]); 2106 return Ft(() => { 2107 const N = g.current; 2108 for (const E of new Set(N.getState().knownAtoms)) 2109 Ps(N, E, "get"); 2110 return () => { 2111 for (const E of N.getState().knownAtoms) 2112 Us(N, E); 2113 }; 2114 }
2114, [g]), /* @__PURE__ */ Z.createElement(So.Provider, { 2115 value: g 2116 }, /* @__PURE__ */ Z.createElement(go.Provider, { 2117 value: I 2118 }, /* @__PURE__ */ Z.createElement(Js, { 2119 setNotifyBatcherOfChange: p 2120 }), o)); 2121} 2122function ni(e) { 2123 const { 2124 override: t, 2125 ...n 2126 } = e, o = on(); 2127 return t === !1 && o.current !== yo ? e.children : /* @__PURE__ */ Z.createElement(ti, n); 2128} 2129var rn = { 2130 RecoilRoot: ni, 2131 useStoreRef: on, 2132 useRecoilMutableSource: Zs 2133}; 2134function oi(e, t) { 2135 if (e === t) 2136 return !0; 2137 if (e.length !== t.length) 2138 return !1; 2139 for (let n = 0, o = e.length; n < o; n++) 2140 if (e[n] !== t[n]) 2141 return !1; 2142 return !0; 2143} 2144var ri = oi; 2145const { 2146 useEffect: ai, 2147 useRef: si 2148} = Z; 2149function ii(e) { 2150 const t = si(); 2151 return ai(() => { 2152 t.current = e; 2153 }), t.current; 2154} 2155var li = ii; 2156const { 2157 useStoreRef: ci 2158} = rn, { 2159 SUSPENSE_TIMEOUT_MS: ui 2160} = Be, { 2161 updateRetainCount: Ke 2162} = Be, { 2163 RetentionZone: di 2164} = Xt, { 2165 useEffect: fi, 2166 useRef: hi 2167} = Z, { 2168 isSSR: Tn 2169} = nn; 2170function vi(e) { 2171 if (F("recoil_memory_managament_2020")) 2172 return pi(e); 2173} 2174function pi(e) { 2175 const n = (Array.isArray(e) ? e : [e]).map((i) => i instanceof di ? i : i.key), o = ci(); 2176 fi(() => { 2177 if (!F("recoil_memory_managament_2020")) 2178 return; 2179 const i = o.current; 2180 if (r.current && !Tn) 2181 window.clearTimeout(r.current), r.current = null; 2182 else 2183 for (const u of n) 2184 Ke(i, u, 1); 2185 return () => { 2186 for (const u of n) 2187 Ke(i, u, -1); 2188 }; 2189 }, [o, ...n]); 2190 const r = hi(), a = li(n); 2191 if (!Tn && (a === void 0 || !ri(a, n))) { 2192 const i = o.current; 2193 for (const u of n) 2194 Ke(i, u, 1); 2195 if (a) 2196 for (const u of a) 2197 Ke(i, u, -1); 2198 r.current && window.clearTimeout(r.current), r.current = window.setTimeout(() => { 2199 r.current = null; 2200 for (const u of n) 2201 Ke(i, u, -1); 2202 }, ui); 2203 } 2204} 2205var _i = vi; 2206function mi() { 2207 return "<component name not available>"; 2208} 2209var bt = mi; 2210const { 2211 DEFAULT_VALUE: yi 2212} = ue, { 2213 currentRendererSupportsUseSyncExternalStore: Si, 2214 reactMode: tt, 2215 useMutableSource: gi, 2216 useSyncExternalStore: Ri 2217} = Ht, { 2218 useRecoilMutableSource: bi, 2219 useStoreRef: Ce 2220} = rn, { 2221 isRecoilValue: bc 2222} = Ae, { 2223 getRecoilValueAsLoadable: wt, 2224 setRecoilValue: bo, 2225 subscribeToRecoilValue: Et 2226} = ge, { 2227 useCallback: ve, 2228 useEffect: dt, 2229 useMemo: wi, 2230 useRef: wo, 2231 useState: Eo 2232} = Z, { 2233 isSSR: Ei 2234} = nn; 2235function Ti(e, t, n) { 2236 if (e.state === "hasValue") 2237 return e.contents; 2238 throw e.state === "loading" ? new Promise((r) => { 2239 const a = n.current.getState().suspendedComponentResolvers; 2240 a.add(r), Ei && K(e.contents) && e.contents.finally(() => { 2241 a.delete(r); 2242 }); 2243 }) : e.state === "hasError" ? e.contents : M(`Invalid value of loadable atom "${t.key}"`); 2244} 2245function Ai(e) { 2246 const t = Ce(), n = bt(), o = ve(() => { 2247 var u; 2248 const d = t.current, f = d.getState(), p = tt().early && (u = f.nextTree) !== null && u !== void 0 ? u : f.currentTree; 2249 return { 2250 loadable: wt(d, e, p), 2251 key: e.key 2252 }; 2253 }, [t, e]), r = ve((u) => { 2254 let d; 2255 return () => { 2256 var f, p; 2257 const g = u(); 2258 return (f = d) !== null && f !== void 0 && f.loadable.is(g.loadable) && ((p = d) === null || p === void 0 ? void 0 : p.key) === g.key ? d : (d = g, g); 2259 }; 2260 }, []), a = wi(() => r(o), [o, r]), i = ve((u) => { 2261 const d = t.current; 2262 return Et(d, e, u, n).release; 2263 }, [t, e, n]); 2264 return Ri( 2265 i, 2266 a, 2267 // getSnapshot() 2268 a 2269 // getServerSnapshot() for SSR support 2270 ).loadable; 2271} 2272function Li(e) { 2273 const t = Ce(), n = ve(() => { 2274 var f; 2275 const p = t.current, g = p.getState(), I = tt().early && (f = g.nextTree) !== null && f !== void 0 ? f : g.currentTree; 2276 return wt(p, e, I); 2277 }, [t, e]), o = ve(() => n(), [n]), r = bt(), a = ve((f, p) => { 2278 const g = t.current; 2279 return Et(g, e, () => { 2280 if (!F("recoil_suppress_rerender_in_callback")) 2281 return p(); 2282 const N = n(); 2283 d.current.is(N) || p(), d.current = N; 2284 }, r).release; 2285 }, [t, e, r, n]), i = bi(); 2286 if (i == null) 2287 throw M("Recoil hooks must be used in components contained within a <RecoilRoot> component."); 2288 const u = gi(i, o, a), d = wo(u); 2289 return dt(() => { 2290 d.current = u; 2291 }), u; 2292} 2293function An(e) { 2294 const t = Ce(), n = bt(), o = ve(() => { 2295 var d; 2296 const f = t.current, p = f.getState(), g = tt().early && (d = p.nextTree) !== null && d !== void 0 ? d : p.currentTree; 2297 return wt(f, e, g); 2298 }, [t, e]), r = ve(() => ({ 2299 loadable: o(), 2300 key: e.key 2301 }), [o, e.key]), a = ve((d) => { 2302 const f = r();
2303 return d.loadable.is(f.loadable) && d.key === f.key ? d : f; 2304 }, [r]); 2305 dt(() => { 2306 const d = Et(t.current, e, (f) => { 2307 u(a); 2308 }, n); 2309 return u(a), d.release; 2310 }, [n, e, t, a]); 2311 const [i, u] = Eo(r); 2312 return i.key !== e.key ? r().loadable : i.loadable; 2313} 2314function Ni(e) { 2315 const t = Ce(), [, n] = Eo([]), o = bt(), r = ve(() => { 2316 var u; 2317 const d = t.current, f = d.getState(), p = tt().early && (u = f.nextTree) !== null && u !== void 0 ? u : f.currentTree; 2318 return wt(d, e, p); 2319 }, [t, e]), a = r(), i = wo(a); 2320 return dt(() => { 2321 i.current = a; 2322 }), dt(() => { 2323 const u = t.current, d = u.getState(), f = Et(u, e, (g) => { 2324 var I; 2325 if (!F("recoil_suppress_rerender_in_callback")) 2326 return n([]); 2327 const N = r(); 2328 (I = i.current) !== null && I !== void 0 && I.is(N) || n(N), i.current = N; 2329 }, o); 2330 if (d.nextTree) 2331 u.getState().queuedComponentCallbacks_DEPRECATED.push(() => { 2332 i.current = null, n([]); 2333 }); 2334 else { 2335 var p; 2336 if (!F("recoil_suppress_rerender_in_callback")) 2337 return n([]); 2338 const g = r(); 2339 (p = i.current) !== null && p !== void 0 && p.is(g) || n(g), i.current = g; 2340 } 2341 return f.release; 2342 }, [o, r, e, t]), a; 2343} 2344function Ci(e) { 2345 return F("recoil_memory_managament_2020") && _i(e), { 2346 TRANSITION_SUPPORT: An, 2347 // Recoil will attemp to detect if `useSyncExternalStore()` is supported with 2348 // `reactMode()` before calling it. However, sometimes the host React 2349 // environment supports it but uses additional React renderers (such as with 2350 // `react-three-fiber`) which do not. While this is technically a user issue 2351 // by using a renderer with React 18+ that doesn't fully support React 18 we 2352 // don't want to break users if it can be avoided. As the current renderer can 2353 // change at runtime, we need to dynamically check and fallback if necessary. 2354 SYNC_EXTERNAL_STORE: Si() ? Ai : An, 2355 MUTABLE_SOURCE: Li, 2356 LEGACY: Ni 2357 }[tt().mode](e); 2358} 2359function To(e) { 2360 const t = Ce(), n = Ci(e); 2361 return Ti(n, e, t); 2362} 2363function Ao(e) { 2364 const t = Ce(); 2365 return ve((n) => { 2366 bo(t.current, e, n); 2367 }, [t, e]); 2368} 2369function Vi(e) { 2370 const t = Ce(); 2371 return ve(() => { 2372 bo(t.current, e, yi); 2373 }, [t, e]); 2374} 2375function $i(e) { 2376 return [To(e), Ao(e)]; 2377} 2378var Mi = { 2379 useRecoilState: $i, 2380 useRecoilValue: To, 2381 useResetRecoilState: Vi, 2382 useSetRecoilState: Ao 2383}; 2384const { 2385 batchUpdates: ki 2386} = tn, { 2387 DEFAULT_VALUE: Di, 2388 getNode: Ii 2389} = ue, { 2390 AbstractRecoilValue: Ui,
2391 setRecoilValueLoadable: xi 2392} = ge, { 2393 cloneSnapshot: wc 2394} = Rt, { 2395 useCallback: Ec, 2396 useEffect: Tc, 2397 useRef: Ac, 2398 useState: Lc 2399} = Z; 2400function Pi(e, t) { 2401 var n; 2402 const o = e.getState(), r = (n = o.nextTree) !== null && n !== void 0 ? n : o.currentTree, a = t.getStore_INTERNAL().getState().currentTree; 2403 ki(() => { 2404 const i = /* @__PURE__ */ new Set(); 2405 for (const f of [r.atomValues.keys(), a.atomValues.keys()]) 2406 for (const p of f) { 2407 var u, d; 2408 ((u = r.atomValues.get(p)) === null || u === void 0 ? void 0 : u.contents) !== ((d = a.atomValues.get(p)) === null || d === void 0 ? void 0 : d.contents) && Ii(p).shouldRestoreFromSnapshots && i.add(p); 2409 } 2410 i.forEach((f) => { 2411 xi(e, new Ui(f), a.atomValues.has(f) ? j(a.atomValues.get(f)) : Di); 2412 }), e.replaceState((f) => ({ 2413 ...f, 2414 stateID: t.getID() 2415 })); 2416 }); 2417} 2418var Oi = { 2419 gotoSnapshot: Pi 2420}; 2421const { 2422 useMemo: Nc 2423} = Z, { 2424 loadableWithValue: Bi 2425} = Xe, { 2426 initializeNode: zi 2427} = Ne, { 2428 DEFAULT_VALUE: Fi, 2429 getNode: Wi 2430} = ue, { 2431 copyTreeState: Ki, 2432 getRecoilValueAsLoadable: Gi, 2433 invalidateDownstreams: Hi, 2434 writeLoadableToTreeState: ji 2435} = ge; 2436function Ln(e) { 2437 return Wi(e.key).nodeType === "atom"; 2438} 2439class qi { 2440 constructor(t, n) { 2441 V(this, "_store", void 0), V(this, "_treeState", void 0), V(this, "_changes", void 0), V(this, "get", (o) => { 2442 if (this._changes.has(o.key)) 2443 return this._changes.get(o.key); 2444 if (!Ln(o)) 2445 throw M("Reading selectors within atomicUpdate is not supported"); 2446 const r = Gi(this._store, o, this._treeState); 2447 if (r.state === "hasValue") 2448 return r.contents; 2449 throw r.state === "hasError" ? r.contents : M(`Expected Recoil atom ${o.key} to have a value, but it is in a loading state.`); 2450 }), V(this, "set", (o, r) => { 2451 if (!Ln(o)) 2452 throw M("Setting selectors within atomicUpdate is not supported"); 2453 if (typeof r == "function") { 2454 const a = this.get(o); 2455 this._changes.set(o.key, r(a)); 2456 } else 2457 zi(this._store, o.key, "set"), this._changes.set(o.key, r); 2458 }), V(this, "reset", (o) => { 2459 this.set(o, Fi); 2460 }), this._store = t, this._treeState = n, this._changes = /* @__PURE__ */ new Map(); 2461 } 2462 // Allow destructing 2463 // eslint-disable-next-line fb-www/extra-arrow-initializer 2464 newTreeState_INTERNAL() { 2465 if (this._changes.size === 0) 2466 return this._treeState; 2467 const t = Ki(this._treeState); 2468 for (const [n, o] of this._changes) 2469 ji(t, n, Bi(o)); 2470 return Hi(this._store, t), t; 2471 } 2472} 2473function Zi(e) { 2474 return (t) => { 2475 e.replaceState((n) => { 2476 const o = new qi(e, n); 2477 return t(o), o.newTreeState_INTERNAL(); 2478 }); 2479 }; 2480} 2481var Yi = { 2482 atomicUpdater: Zi 2483}, Xi = Yi.atomicUpdater, Lo = /* @__PURE__ */ Object.freeze({ 2484 __proto__: null, 2485 atomicUpdater: Xi 2486}); 2487function Ji(e, t) { 2488 if (!e) 2489 throw new Error(t); 2490} 2491var Qi = Ji, qe = Qi; 2492const { 2493 atomicUpdater: el 2494} = Lo, { 2495 batchUpdates: tl 2496} = tn, { 2497 DEFAULT_VALUE: nl 2498} = ue, { 2499 refreshRecoilValue: ol, 2500 setRecoilValue: Nn 2501} = ge, { 2502 cloneSnapshot: rl 2503} = Rt, { 2504 gotoSnapshot: al 2505} = Oi, { 2506 useCallback: Cc 2507} = Z; 2508class No { 2509} 2510const sl = new No(); 2511function il(e, t, n, o) { 2512 let r = sl, a; 2513 if (tl(() => { 2514 const u = "useRecoilCallback() expects a function that returns a function: it accepts a function of the type (RecoilInterface) => (Args) => ReturnType and returns a callback function (Args) => ReturnType, where RecoilInterface is an object {snapshot, set, ...} and Args and ReturnType are the argument and return types of the callback you want to create. Please see the docs at recoiljs.org for details."; 2515 if (typeof t != "function") 2516 throw M(u); 2517 const d = jn({ 2518 ...o ?? {}, 2519 // flowlint-line unclear-type:off 2520 // $FlowFixMe[missing-local-annot] 2521 set: (p, g) => Nn(e, p, g), 2522 // $FlowFixMe[missing-local-annot] 2523 reset: (p) => Nn(e, p, nl), 2524 // $FlowFixMe[missing-local-annot] 2525 refresh: (p) => ol(e, p), 2526 gotoSnapshot: (p) => al(e, p), 2527 transact_UNSTABLE: (p) => el(e)(p) 2528 }, {
2529 snapshot: () => { 2530 const p = rl(e); 2531 return a = p.retain(), p; 2532 } 2533 }), f = t(d); 2534 if (typeof f != "function") 2535 throw M(u); 2536 r = f(...n); 2537 }), r instanceof No && qe(!1), K(r)) 2538 r = r.finally(() => { 2539 var u; 2540 (u = a) === null || u === void 0 || u(); 2541 }); 2542 else { 2543 var i; 2544 (i = a) === null || i === void 0 || i(); 2545 } 2546 return r; 2547} 2548var ll = { 2549 recoilCallback: il 2550}; 2551const { 2552 useCallback: Vc 2553} = Z, { 2554 atomicUpdater: $c 2555} = Lo, { 2556 useMemo: Mc 2557} = Z; 2558class cl { 2559 constructor(t) { 2560 V(this, "value", void 0), this.value = t; 2561 } 2562} 2563var ul = { 2564 WrappedValue: cl 2565}, dl = ul.WrappedValue, Co = /* @__PURE__ */ Object.freeze({ 2566 __proto__: null, 2567 WrappedValue: dl 2568}); 2569class Cn extends Error { 2570} 2571class fl { 2572 // $FlowIssue[unclear-type] 2573 constructor(t) { 2574 var n, o, r; 2575 V(this, "_name", void 0), V(this, "_numLeafs", void 0), V(this, "_root", void 0), V(this, "_onHit", void 0), V(this, "_onSet", void 0), V(this, "_mapNodeValue", void 0), this._name = t == null ? void 0 : t.name, this._numLeafs = 0, this._root = null, this._onHit = (n = t == null ? void 0 : t.onHit) !== null && n !== void 0 ? n : () => { 2576 }, this._onSet = (o = t == null ? void 0 : t.onSet) !== null && o !== void 0 ? o : () => { 2577 }, this._mapNodeValue = (r = t == null ? void 0 : t.mapNodeValue) !== null && r !== void 0 ? r : (a) => a; 2578 } 2579 size() { 2580 return this._numLeafs; 2581 } 2582 // $FlowIssue[unclear-type] 2583 root() { 2584 return this._root; 2585 } 2586 get(t, n) { 2587 var o; 2588 return (o = this.getLeafNode(t, n)) === null || o === void 0 ? void 0 : o.value; 2589 } 2590 getLeafNode(t, n) { 2591 if (this._root == null) 2592 return; 2593 let o = this._root; 2594 for (; o; ) { 2595 if (n == null || n.onNodeVisit(o), o.type === "leaf") 2596 return this._onHit(o), o; 2597 const r = this._mapNodeValue(t(o.nodeKey)); 2598 o = o.branches.get(r); 2599 } 2600 } 2601 set(t, n, o) { 2602 const r = () => { 2603 var a, i, u, d; 2604 let f, p; 2605 for (const [Q, te] of t) { 2606 var g, I, N; 2607 const w = this._root; 2608 if ((w == null ? void 0 : w.type) === "leaf") 2609 throw this.invalidCacheError(); 2610 const U = f; 2611 if (f = U ? U.branches.get(p) : w, f = (g = f) !== null && g !== void 0 ? g : { 2612 type: "branch", 2613 nodeKey: Q, 2614 parent: U, 2615 branches: /* @__PURE__ */ new Map(), 2616 branchKey: p 2617 }, f.type !== "branch" || f.nodeKey !== Q) 2618 throw this.invalidCacheError(); 2619 U == null || U.branches.set(p, f), o == null || (I = o.onNodeVisit) === null || I === void 0 || I.call(o, f), p = this._mapNodeValue(te), this._root = (N = this._root) !== null && N !== void 0 ? N : f; 2620 } 2621 const E = f ? (a = f) === null || a === void 0 ? void 0 : a.branches.get(p) : this._root; 2622 if (E != null && (E.type !== "leaf" || E.branchKey !== p)) 2623 throw this.invalidCacheError(); 2624 const $ = { 2625 type: "leaf", 2626 value: n, 2627 parent: f, 2628 branchKey: p 2629 }; 2630 (i = f) === null || i === void 0 || i.branches.set(p, $), this._root = (u = this._root) !== null && u !== void 0 ? u : $, this._numLeafs++, this._onSet($), o == null || (d = o.onNodeVisit) === null || d === void 0 || d.call(o, $); 2631 }; 2632 try { 2633 r(); 2634 } catch (a) { 2635 if (a instanceof Cn) 2636 this.clear(), r(); 2637 else 2638 throw a; 2639 } 2640 } 2641 // Returns true if leaf was actually deleted from the tree 2642 delete(t) { 2643 const n = this.root(); 2644 if (!n) 2645 return !1; 2646 if (t === n) 2647 return this._root = null, this._numLeafs = 0, !0; 2648 let o = t.parent, r = t.branchKey; 2649 for (; o; ) { 2650 var a; 2651 if (o.branches.delete(r), o === n) 2652 return o.branches.size === 0 ? (this._root = null, this._numLeafs = 0) : this._numLeafs--, !0; 2653 if (o.branches.size > 0) 2654 break; 2655 r = (a = o) === null || a === void 0 ? void 0 : a.branchKey, o = o.parent; 2656 } 2657 for (; o !== n; o = o.parent) 2658 if (o == null) 2659 return !1; 2660 return this._numLeafs--, !0; 2661 } 2662 clear() { 2663 this._numLeafs = 0, this._root = null; 2664 } 2665 invalidCacheError() {
2666 throw ie("Invalid cache values. This happens when selectors do not return consistent values for the same input dependency values. That may also be caused when using Fast Refresh to change a selector implementation. Resetting cache." + (this._name != null ? ` - ${this._name}` : "")), new Cn(); 2667 } 2668} 2669var hl = { 2670 TreeCache: fl 2671}, vl = hl.TreeCache, Vo = /* @__PURE__ */ Object.freeze({ 2672 __proto__: null, 2673 TreeCache: vl 2674}); 2675class pl { 2676 constructor(t) { 2677 var n; 2678 V(this, "_maxSize", void 0), V(this, "_size", void 0), V(this, "_head", void 0), V(this, "_tail", void 0), V(this, "_map", void 0), V(this, "_keyMapper", void 0), this._maxSize = t.maxSize, this._size = 0, this._head = null, this._tail = null, this._map = /* @__PURE__ */ new Map(), this._keyMapper = (n = t.mapKey) !== null && n !== void 0 ? n : (o) => o; 2679 } 2680 head() { 2681 return this._head; 2682 } 2683 tail() { 2684 return this._tail; 2685 } 2686 size() { 2687 return this._size; 2688 } 2689 maxSize() { 2690 return this._maxSize; 2691 } 2692 has(t) { 2693 return this._map.has(this._keyMapper(t)); 2694 } 2695 get(t) { 2696 const n = this._keyMapper(t), o = this._map.get(n); 2697 if (o) 2698 return this.set(t, o.value), o.value; 2699 } 2700 set(t, n) { 2701 const o = this._keyMapper(t); 2702 this._map.get(o) && this.delete(t); 2703 const a = this.head(), i = { 2704 key: t, 2705 right: a, 2706 left: null, 2707 value: n 2708 }; 2709 a ? a.left = i : this._tail = i, this._map.set(o, i), this._head = i, this._size++, this._maybeDeleteLRU(); 2710 } 2711 _maybeDeleteLRU() { 2712 this.size() > this.maxSize() && this.deleteLru(); 2713 } 2714 deleteLru() { 2715 const t = this.tail(); 2716 t && this.delete(t.key); 2717 } 2718 delete(t) { 2719 const n = this._keyMapper(t); 2720 if (!this._size || !this._map.has(n)) 2721 return; 2722 const o = j(this._map.get(n)), r = o.right, a = o.left; 2723 r && (r.left = o.left), a && (a.right = o.right), o === this.head() && (this._head = r), o === this.tail() && (this._tail = a), this._map.delete(n), this._size--; 2724 } 2725 clear() { 2726 this._size = 0, this._head = null, this._tail = null, this._map = /* @__PURE__ */ new Map(); 2727 } 2728} 2729var _l = { 2730 LRUCache: pl 2731}, ml = _l.LRUCache, $o = /* @__PURE__ */ Object.freeze({ 2732 __proto__: null, 2733 LRUCache: ml 2734}); 2735const { 2736 LRUCache: yl 2737} = $o, { 2738 TreeCache: Sl 2739} = Vo; 2740function gl({ 2741 name: e, 2742 maxSize: t, 2743 mapNodeValue: n = (o) => o 2744}) { 2745 const o = new yl({ 2746 maxSize: t 2747 }), r = new Sl({ 2748 name: e, 2749 mapNodeValue: n, 2750 onHit: (a) => { 2751 o.set(a, !0); 2752 }, 2753 onSet: (a) => { 2754 const i = o.tail(); 2755 o.set(a, !0), i && r.size() > t && r.delete(i.key); 2756 } 2757 }); 2758 return r; 2759} 2760var Vn = gl; 2761function _e(e, t, n) { 2762 if (typeof e == "string" && !e.includes('"') && !e.includes("\\")) 2763 return `"${e}"`; 2764 switch (typeof e) { 2765 case "undefined": 2766 return ""; 2767 case "boolean": 2768 return e ? "true" : "false"; 2769 case "number": 2770 case "symbol": 2771 return String(e); 2772 case "string": 2773 return JSON.stringify(e); 2774 case "function": 2775 if ((t == null ? void 0 : t.allowFunctions) !== !0) 2776 throw M("Attempt to serialize function in a Recoil cache key"); 2777 return `__FUNCTION(${e.name})__`; 2778 } 2779 if (e === null) 2780 return "null"; 2781 if (typeof e != "object") { 2782 var o; 2783 return (o = JSON.stringify(e)) !== null && o !== void 0 ? o : ""; 2784 } 2785 if (K(e)) 2786 return "__PROMISE__"; 2787 if (Array.isArray(e)) 2788 return `[${e.map((r, a) => _e(r, t, a.toString()))}]`; 2789 if (typeof e.toJSON == "function") 2790 return _e(e.toJSON(n), t, n); 2791 if (e instanceof Map) { 2792 const r = {}; 2793 for (const [a, i] of e) 2794 r[typeof a == "string" ? a : _e(a, t)] = i; 2795 return _e(r, t, n); 2796 } 2797 return e instanceof Set ? _e( 2798 // $FlowFixMe[missing-local-annot] 2799 Array.from(e).sort((r, a) => _e(r, t).localeCompare(_e(a, t))), 2800 t, 2801 n 2802 ) : Symbol !== void 0 && e[Symbol.iterator] != null && typeof e[Symbol.iterator] == "function" ? _e(Array.from(e), t, n) : `{${Object.keys(e).filter((r) => e[r] !== void 0).sort().map((r) => `${_e(r, t)}:${_e(e[r], t, r)}`).join(",")}}`; 2803} 2804function Rl(e, t = { 2805 allowFunctions: !1 2806}) { 2807 return _e(e, t); 2808} 2809var an = Rl; 2810const { 2811 TreeCache: bl 2812} = Vo, rt = { 2813 equality: "reference", 2814 eviction: "keep-all", 2815 maxSize: 1 / 0 2816}; 2817function wl({
2818 equality: e = rt.equality, 2819 eviction: t = rt.eviction, 2820 maxSize: n = rt.maxSize 2821} = rt, o) { 2822 const r = El(e); 2823 return Tl(t, n, r, o); 2824} 2825function El(e) { 2826 switch (e) { 2827 case "reference": 2828 return (t) => t; 2829 case "value": 2830 return (t) => an(t); 2831 } 2832 throw M(`Unrecognized equality policy ${e}`); 2833} 2834function Tl(e, t, n, o) { 2835 switch (e) { 2836 case "keep-all": 2837 return new bl({ 2838 name: o, 2839 mapNodeValue: n 2840 }); 2841 case "lru": 2842 return Vn({ 2843 name: o, 2844 maxSize: j(t), 2845 mapNodeValue: n 2846 }); 2847 case "most-recent": 2848 return Vn({ 2849 name: o, 2850 maxSize: 1, 2851 mapNodeValue: n 2852 }); 2853 } 2854 throw M(`Unrecognized eviction policy ${e}`); 2855} 2856var Al = wl; 2857const { 2858 isLoadable: Ll, 2859 loadableWithError: at, 2860 loadableWithPromise: Nl, 2861 loadableWithValue: It 2862} = Xe, { 2863 WrappedValue: Mo 2864} = Co, { 2865 getNodeLoadable: st, 2866 peekNodeLoadable: Cl, 2867 setNodeValue: Vl 2868} = Ne, { 2869 saveDepsToStore: $l 2870} = Qe, { 2871 DEFAULT_VALUE: Ml, 2872 getConfigDeletionHandler: kl, 2873 getNode: Dl, 2874 registerNode: $n 2875} = ue, { 2876 isRecoilValue: Il 2877} = Ae, { 2878 markRecoilValueModified: Mn 2879} = ge, { 2880 retainedByOptionWithDefault: Ul 2881} = Be, { 2882 recoilCallback: xl 2883} = ll; 2884class ko { 2885} 2886const Ge = new ko(), He = [], it = /* @__PURE__ */ new Map(), Pl = /* @__PURE__ */ (() => { 2887 let e = 0; 2888 return () => e++; 2889})(); 2890function Do(e) { 2891 let t = null; 2892 const { 2893 key: n, 2894 get: o, 2895 cachePolicy_UNSTABLE: r 2896 } = e, a = e.set != null ? e.set : void 0, i = /* @__PURE__ */ new Set(), u = Al(r ?? { 2897 equality: "reference", 2898 eviction: "keep-all" 2899 }, n), d = Ul(e.retainedBy_UNSTABLE), f = /* @__PURE__ */ new Map(); 2900 let p = 0; 2901 function g() { 2902 return !F("recoil_memory_managament_2020") || p > 0; 2903 } 2904 function I(c) { 2905 return c.getState().knownSelectors.add(n), p++, () => { 2906 p--; 2907 }; 2908 } 2909 function N() { 2910 return kl(n) !== void 0 && !g(); 2911 } 2912 function E(c, v, _, C, R) { 2913 fe(v, C, R), $(c, _); 2914 } 2915 function $(c, v) { 2916 le(c, v) && X(c), te(v, !0); 2917 } 2918 function Q(c, v) { 2919 le(c, v) && (j(J(c)).stateVersions.clear(), te(v, !1)); 2920 } 2921 function te(c, v) { 2922 const _ = it.get(c); 2923 if (_ != null) { 2924 for (const C of _) 2925 Mn(C, j(t)); 2926 v && it.delete(c); 2927 } 2928 } 2929 function w(c, v) { 2930 let _ = it.get(v); 2931 _ == null && it.set(v, _ = /* @__PURE__ */ new Set()), _.add(c); 2932 } 2933 function U(c, v, _, C, R, k) { 2934 return v.then((b) => { 2935 if (!g()) 2936 throw X(c), Ge; 2937 const P = It(b); 2938 return E(c, _, R, P, C), b; 2939 }).catch((b) => { 2940 if (!g()) 2941 throw X(c), Ge; 2942 if (K(b)) 2943 return Y(c, b, _, C, R, k); 2944 const P = at(b); 2945 throw E(c, _, R, P, C), b; 2946 }); 2947 } 2948 function Y(c, v, _, C, R, k) { 2949 return v.then((b) => { 2950 if (!g()) 2951 throw X(c), Ge; 2952 k.loadingDepKey != null && k.loadingDepPromise === v ? _.atomValues.set(k.loadingDepKey, It(b)) : c.getState().knownSelectors.forEach((O) => { 2953 _.atomValues.delete(O); 2954 }); 2955 const P = q(c, _); 2956 if (P && P.state !== "loading") { 2957 if ((le(c, R) || J(c) == null) && $(c, R), P.state === "hasValue") 2958 return P.contents; 2959 throw P.contents; 2960 } 2961 if (!le(c, R)) { 2962 const O = ye(c, _); 2963 if (O != null) 2964 return O.loadingLoadable.contents; 2965 } 2966 const [W, ee] = G(c, _, R); 2967 if (W.state !== "loading" && E(c, _, R, W, ee), W.state === "hasError") 2968 throw W.contents; 2969 return W.contents; 2970 }).catch((b) => { 2971 if (b instanceof ko) 2972 throw Ge; 2973 if (!g()) 2974 throw X(c), Ge; 2975 const P = at(b); 2976 throw E(c, _, R, P, C), b; 2977 }); 2978 } 2979 function z(c, v, _, C) { 2980 var R, k, b, P; 2981 if (le(c, C) || v.version === ((R = c.getState()) === null || R === void 0 || (k = R.currentTree) === null || k === void 0 ? void 0 : k.version) || v.version === ((b = c.getState()) === null || b === void 0 || (P = b.nextTree) === null || P === void 0 ? void 0 : P.version)) { 2982 var W, ee, O; 2983 $l(n, _, c, (W = (ee = c.getState()) === null || ee === void 0 || (O = ee.nextTree) === null || O === void 0 ? void 0 : O.version) !== null && W !== void 0 ? W : c.getState().currentTree.version); 2984 } 2985 for (const ne of _) 2986 i.add(ne); 2987 } 2988 function G(c, v, _) { 2989 let C = !0, R = !0;
2990 const k = () => { 2991 R = !1; 2992 }; 2993 let b, P = !1, W; 2994 const ee = { 2995 loadingDepKey: null, 2996 loadingDepPromise: null 2997 }, O = /* @__PURE__ */ new Map(); 2998 function ne({ 2999 key: ce 3000 }) { 3001 const ae = st(c, v, ce); 3002 switch (O.set(ce, ae), C || (z(c, v, new Set(O.keys()), _), Q(c, _)), ae.state) { 3003 case "hasValue": 3004 return ae.contents; 3005 case "hasError": 3006 throw ae.contents; 3007 case "loading": 3008 throw ee.loadingDepKey = ce, ee.loadingDepPromise = ae.contents, ae.contents; 3009 } 3010 throw M("Invalid Loadable state"); 3011 } 3012 const me = (ce) => (...ae) => { 3013 if (R) 3014 throw M("Callbacks from getCallback() should only be called asynchronously after the selector is evalutated. It can be used for selectors to return objects with callbacks that can work with Recoil state without a subscription."); 3015 return t == null && qe(!1), xl( 3016 c, 3017 ce, 3018 ae, 3019 { 3020 node: t 3021 } 3022 // flowlint-line unclear-type:off 3023 ); 3024 }; 3025 try { 3026 b = o({ 3027 get: ne, 3028 getCallback: me 3029 }), b = Il(b) ? ne(b) : b, Ll(b) && (b.state === "hasError" && (P = !0), b = b.contents), K(b) ? b = U(c, b, v, O, _, ee).finally(k) : k(), b = b instanceof Mo ? b.value : b; 3030 } catch (ce) { 3031 b = ce, K(b) ? b = Y(c, b, v, O, _, ee).finally(k) : (P = !0, k()); 3032 } 3033 return P ? W = at(b) : K(b) ? W = Nl(b) : W = It(b), C = !1, $e(c, _, O), z(c, v, new Set(O.keys()), _), [W, O]; 3034 } 3035 function q(c, v) { 3036 let _ = v.atomValues.get(n); 3037 if (_ != null) 3038 return _; 3039 const C = /* @__PURE__ */ new Set(); 3040 try { 3041 _ = u.get((k) => (typeof k != "string" && qe(!1), st(c, v, k).contents), { 3042 onNodeVisit: (k) => { 3043 k.type === "branch" && k.nodeKey !== n && C.add(k.nodeKey); 3044 } 3045 }); 3046 } catch (k) { 3047 throw M(`Problem with cache lookup for selector "${n}": ${k.message}`); 3048 } 3049 if (_) { 3050 var R; 3051 v.atomValues.set(n, _), z(c, v, C, (R = J(c)) === null || R === void 0 ? void 0 : R.executionID); 3052 } 3053 return _; 3054 } 3055 function re(c, v) { 3056 const _ = q(c, v); 3057 if (_ != null) 3058 return X(c), _; 3059 const C = ye(c, v); 3060 if (C != null) { 3061 var R; 3062 return ((R = C.loadingLoadable) === null || R === void 0 ? void 0 : R.state) === "loading" && w(c, C.executionID), C.loadingLoadable; 3063 } 3064 const k = Pl(), [b, P] = G(c, v, k); 3065 return b.state === "loading" ? (de(c, k, b, P, v), w(c, k)) : (X(c), fe(v, b, P)), b; 3066 } 3067 function ye(c, v) { 3068 const _ = co([f.has(c) ? [j(f.get(c))] : [], _t(Jt(f, ([R]) => R !== c), ([, R]) => R)]); 3069 function C(R) { 3070 for (const [k, b] of R) 3071 if (!st(c, v, k).is(b)) 3072 return !0; 3073 return !1; 3074 } 3075 for (const R of _) { 3076 if ( 3077 // If this execution was already checked to be valid with this version 3078 // of state, then let's use it! 3079 R.stateVersions.get(v.version) || // If the deps for the execution match our current state, then it's valid 3080 !C(R.depValuesDiscoveredSoFarDuringAsyncWork) 3081 ) 3082 return R.stateVersions.set(v.version, !0), R; 3083 R.stateVersions.set(v.version, !1); 3084 } 3085 } 3086 function J(c) { 3087 return f.get(c); 3088 } 3089 function de(c, v, _, C, R) { 3090 f.set(c, { 3091 depValuesDiscoveredSoFarDuringAsyncWork: C, 3092 executionID: v, 3093 loadingLoadable: _, 3094 stateVersions: /* @__PURE__ */ new Map([[R.version, !0]]) 3095 }); 3096 } 3097 function $e(c, v, _) { 3098 if (le(c, v)) { 3099 const C = J(c); 3100 C != null && (C.depValuesDiscoveredSoFarDuringAsyncWork = _); 3101 } 3102 } 3103 function X(c) { 3104 f.delete(c); 3105 } 3106 function le(c, v) { 3107 var _; 3108 return v === ((_ = J(c)) === null || _ === void 0 ? void 0 : _.executionID); 3109 } 3110 function we(c) { 3111 return Array.from(c.entries()).map(([v, _]) => [v, _.contents]); 3112 } 3113 function fe(c, v, _) { 3114 c.atomValues.set(n, v); 3115 try { 3116 u.set(we(_), v); 3117 } catch (C) { 3118 throw M(`Problem with setting cache for selector "${n}": ${C.message}`); 3119 } 3120 } 3121 function Se(c) { 3122 if (He.includes(n)) { 3123 const v = `Recoil selector has circular dependencies: ${He.slice(He.indexOf(n)).join(" → ")}`; 3124 return at(M(v)); 3125 } 3126 He.push(n); 3127 try { 3128 return c(); 3129 } finally { 3130 He.pop(); 3131 } 3132 } 3133 function Me(c, v) { 3134 const _ = v.atomValues.get(n); 3135 return _ ?? u.get((C) => { 3136 var R; 3137 return typeof C != "string" && qe(!1), (R = Cl(c, v, C)) === null || R === void 0 ? void 0 : R.contents; 3138 }); 3139 } 3140 function ke(c, v) { 3141 return Se(() => re(c, v)); 3142 } 3143 function x(c) { 3144 c.atomValues.delete(n); 3145 } 3146 function B(c, v) { 3147 t == null && qe(!1); 3148 for (const C of i) { 3149 var _; 3150 const R = Dl(C); 3151 (_ = R.clearCache) === null || _ === void 0 || _.call(R, c, v); 3152 } 3153 i.clear(), x(v), u.clear(), Mn(c, t); 3154 } 3155 return a != null ? t = $n({ 3156 key: n, 3157 nodeType: "selector", 3158 peek: Me, 3159 get: ke, 3160 set: (v, _, C) => { 3161 let R = !1;
3162 const k = /* @__PURE__ */ new Map(); 3163 function b({ 3164 key: O 3165 }) { 3166 if (R) 3167 throw M("Recoil: Async selector sets are not currently supported."); 3168 const ne = st(v, _, O); 3169 if (ne.state === "hasValue") 3170 return ne.contents; 3171 if (ne.state === "loading") { 3172 const me = `Getting value of asynchronous atom or selector "${O}" in a pending state while setting selector "${n}" is not yet supported.`; 3173 throw ie(), M(me); 3174 } else 3175 throw ne.contents; 3176 } 3177 function P(O, ne) { 3178 if (R) { 3179 const ae = "Recoil: Async selector sets are not currently supported."; 3180 throw ie(), M(ae); 3181 } 3182 const me = typeof ne == "function" ? ( 3183 // cast to any because we can't restrict type S from being a function itself without losing support for opaque types 3184 // flowlint-next-line unclear-type:off 3185 ne(b(O)) 3186 ) : ne; 3187 Vl(v, _, O.key, me).forEach((ae, nt) => k.set(nt, ae)); 3188 } 3189 function W(O) { 3190 P(O, Ml); 3191 } 3192 const ee = a({ 3193 set: P, 3194 get: b, 3195 reset: W 3196 }, C); 3197 if (ee !== void 0) 3198 throw K(ee) ? M("Recoil: Async selector sets are not currently supported.") : M("Recoil: selector set should be a void function."); 3199 return R = !0, k; 3200 }, 3201 init: I, 3202 invalidate: x, 3203 clearCache: B, 3204 shouldDeleteConfigOnRelease: N, 3205 dangerouslyAllowMutability: e.dangerouslyAllowMutability, 3206 shouldRestoreFromSnapshots: !1, 3207 retainedBy: d 3208 }) : t = $n({ 3209 key: n, 3210 nodeType: "selector", 3211 peek: Me, 3212 get: ke, 3213 init: I, 3214 invalidate: x, 3215 clearCache: B, 3216 shouldDeleteConfigOnRelease: N, 3217 dangerouslyAllowMutability: e.dangerouslyAllowMutability, 3218 shouldRestoreFromSnapshots: !1, 3219 retainedBy: d 3220 }); 3221} 3222Do.value = (e) => new Mo(e); 3223var Oe = Do; 3224const { 3225 isLoadable: Ol, 3226 loadableWithError: Ut, 3227 loadableWithPromise: xt, 3228 loadableWithValue: Ie 3229} = Xe, { 3230 WrappedValue: Io 3231} = Co, { 3232 peekNodeInfo: Bl 3233} = Ne, { 3234 DEFAULT_VALUE: Ee, 3235 DefaultValue: Re, 3236 getConfigDeletionHandler: Uo, 3237 registerNode: zl, 3238 setConfigDeletionHandler: Fl 3239} = ue, { 3240 isRecoilValue: Wl 3241} = Ae, { 3242 getRecoilValueAsLoadable: Kl, 3243 markRecoilValueModified: Gl, 3244 setRecoilValue: kn,
3245 setRecoilValueLoadable: Hl 3246} = ge, { 3247 retainedByOptionWithDefault: jl 3248} = Be, je = (e) => e instanceof Io ? e.value : e; 3249function ql(e) { 3250 const { 3251 key: t, 3252 persistence_UNSTABLE: n 3253 } = e, o = jl(e.retainedBy_UNSTABLE); 3254 let r = 0; 3255 function a(w) { 3256 return xt(w.then((U) => (i = Ie(U), U)).catch((U) => { 3257 throw i = Ut(U), U; 3258 })); 3259 } 3260 let i = K(e.default) ? a(e.default) : Ol(e.default) ? e.default.state === "loading" ? a(e.default.contents) : e.default : ( 3261 // $FlowFixMe[incompatible-call] 3262 Ie(je(e.default)) 3263 ); 3264 i.contents; 3265 let u; 3266 const d = /* @__PURE__ */ new Map(); 3267 function f(w) { 3268 return w; 3269 } 3270 function p(w, U) { 3271 const Y = U.then((z) => { 3272 var G, q; 3273 return ((q = ((G = w.getState().nextTree) !== null && G !== void 0 ? G : w.getState().currentTree).atomValues.get(t)) === null || q === void 0 ? void 0 : q.contents) === Y && kn(w, te, z), z; 3274 }).catch((z) => { 3275 var G, q; 3276 throw ((q = ((G = w.getState().nextTree) !== null && G !== void 0 ? G : w.getState().currentTree).atomValues.get(t)) === null || q === void 0 ? void 0 : q.contents) === Y && Hl(w, te, Ut(z)), z; 3277 }); 3278 return Y; 3279 } 3280 function g(w, U, Y) { 3281 var z; 3282 r++; 3283 const G = () => { 3284 var J; 3285 r--, (J = d.get(w)) === null || J === void 0 || J.forEach((de) => de()), d.delete(w); 3286 }; 3287 if (w.getState().knownAtoms.add(t), i.state === "loading") { 3288 const J = () => { 3289 var de; 3290 ((de = w.getState().nextTree) !== null && de !== void 0 ? de : w.getState().currentTree).atomValues.has(t) || Gl(w, te); 3291 }; 3292 i.contents.finally(J); 3293 } 3294 const q = (z = e.effects) !== null && z !== void 0 ? z : e.effects_UNSTABLE; 3295 if (q != null) { 3296 let J = function(x) { 3297 if (le && x.key === t) { 3298 const B = X; 3299 return B instanceof Re ? I(w, U) : K(B) ? xt(B.then((c) => c instanceof Re ? ( 3300 // Cast T to S 3301 i.toPromise() 3302 ) : c)) : ( 3303 // $FlowFixMe[incompatible-call] 3304 Ie(B) 3305 ); 3306 } 3307 return Kl(w, x); 3308 }, de = function(x) { 3309 return J(x).toPromise(); 3310 }, $e = function(x) { 3311 var B; 3312 const c = Bl(w, (B = w.getState().nextTree) !== null && B !== void 0 ? B : w.getState().currentTree, x.key); 3313 return le && x.key === t && !(X instanceof Re) ? { 3314 ...c, 3315 isSet: !0, 3316 loadable: J(x) 3317 } : c; 3318 }, X = Ee, le = !0, we = !1, fe = null; 3319 const Se = (x) => (B) => { 3320 if (le) { 3321 const c = J(te), v = c.state === "hasValue" ? c.contents : Ee; 3322 X = typeof B == "function" ? ( 3323 // cast to any because we can't restrict T from being a function without losing support for opaque types 3324 B(v) 3325 ) : B, K(X) && (X = X.then((_) => (fe = { 3326 effect: x, 3327 value: _ 3328 }, _))); 3329 } else { 3330 if (K(B)) 3331 throw M("Setting atoms to async values is not implemented."); 3332 typeof B != "function" && (fe = { 3333 effect: x, 3334 value: je(B) 3335 }), kn(w, te, typeof B == "function" ? (c) => { 3336 const v = je( 3337 // cast to any because we can't restrict T from being a function without losing support for opaque types 3338 B(c) 3339 // flowlint-line unclear-type:off 3340 ); 3341 return fe = { 3342 effect: x, 3343 value: v 3344 }, v; 3345 } : je(B)); 3346 } 3347 }, Me = (x) => () => Se(x)(Ee), ke = (x) => (B) => { 3348 var c; 3349 const { 3350 release: v 3351 } = w.subscribeToTransactions((_) => { 3352 var C; 3353 let { 3354 currentTree: R, 3355 previousTree: k 3356 } = _.getState(); 3357 k || (ie(), k = R); 3358 const b = (C = R.atomValues.get(t)) !== null && C !== void 0 ? C : i; 3359 if (b.state === "hasValue") { 3360 var P, W, ee, O; 3361 const ne = b.contents, me = (P = k.atomValues.get(t)) !== null && P !== void 0 ? P : i, ce = me.state === "hasValue" ? me.contents : Ee; 3362 ((W = fe) === null || W === void 0 ? void 0 : W.effect) !== x || ((ee = fe) === null || ee === void 0 ? void 0 : ee.value) !== ne ? B(ne, ce, !R.atomValues.has(t)) : ((O = fe) === null || O === void 0 ? void 0 : O.effect) === x && (fe = null); 3363 } 3364 }, t); 3365 d.set(w, [...(c = d.get(w)) !== null && c !== void 0 ? c : [], v]); 3366 }; 3367 for (const x of q) 3368 try { 3369 const B = x({ 3370 node: te, 3371 storeID: w.storeID, 3372 parentStoreID_UNSTABLE: w.parentStoreID, 3373 trigger: Y, 3374 setSelf: Se(x), 3375 resetSelf: Me(x), 3376 onSet: ke(x), 3377 getPromise: de, 3378 getLoadable: J, 3379 getInfo_UNSTABLE: $e 3380 }); 3381 if (B != null) { 3382 var re; 3383 d.set(w, [...(re = d.get(w)) !== null && re !== void 0 ? re : [], B]); 3384 } 3385 } catch (B) { 3386 X = B, we = !0; 3387 } 3388 if (le = !1, !(X instanceof Re)) { 3389 var ye; 3390 const x = we ? Ut(X) : K(X) ? xt(p(w, X)) : Ie(je(X)); 3391 x.contents, U.atomValues.set(t, x), (ye = w.getState().nextTree) === null || ye === void 0 || ye.atomValues.set(t, x); 3392 } 3393 } 3394 return G; 3395 } 3396 function I(w, U) { 3397 var Y, z; 3398 return (Y = (z = U.atomValues.get(t)) !== null && z !== void 0 ? z : u) !== null && Y !== void 0 ? Y : i; 3399 } 3400 function N(w, U) { 3401 if (U.atomValues.has(t)) 3402 return j(U.atomValues.get(t)); 3403 if (U.nonvalidatedAtoms.has(t)) { 3404 if (u != null) 3405 return u; 3406 if (n == null) 3407 return Fn(), i; 3408 const Y = U.nonvalidatedAtoms.get(t), z = n.validator(Y, Ee); 3409 return u = z instanceof Re ? i : Ie(z), u; 3410 } else 3411 return i; 3412 } 3413 function E() { 3414 u = void 0; 3415 } 3416 function $(w, U, Y) { 3417 if (U.atomValues.has(t)) { 3418 const z = j(U.atomValues.get(t)); 3419 if (z.state === "hasValue" && Y === z.contents) 3420 return /* @__PURE__ */ new Map(); 3421 } else if (!U.nonvalidatedAtoms.has(t) && Y instanceof Re) 3422 return /* @__PURE__ */ new Map(); 3423 return u = void 0, (/* @__PURE__ */ new Map()).set(t, Ie(Y)); 3424 } 3425 function Q() { 3426 return Uo(t) !== void 0 && r <= 0; 3427 } 3428 const te = zl({ 3429 key: t, 3430 nodeType: "atom", 3431 peek: I, 3432 get: N, 3433 set: $, 3434 init: g, 3435 invalidate: E, 3436 shouldDeleteConfigOnRelease: Q, 3437 dangerouslyAllowMutability: e.dangerouslyAllowMutability, 3438 persistence_UNSTABLE: e.persistence_UNSTABLE ? { 3439 type: e.persistence_UNSTABLE.type, 3440 backButton: e.persistence_UNSTABLE.backButton 3441 } : void 0, 3442 shouldRestoreFromSnapshots: !0, 3443 retainedBy: o 3444 }); 3445 return te; 3446} 3447function sn(e) { 3448 const { 3449 // @fb-only: scopeRules_APPEND_ONLY_READ_THE_DOCS, 3450 ...t 3451 } = e, n = "default" in e ? ( 3452 // $FlowIssue[incompatible-type] No way to refine in Flow that property is not defined 3453 e.default 3454 ) : new Promise(() => { 3455 }); 3456 return Wl(n) ? Zl({ 3457 ...t, 3458 default: n 3459 // @fb-only: scopeRules_APPEND_ONLY_READ_THE_DOCS, 3460 }) : ql({ 3461 ...t, 3462 default: n 3463 }); 3464} 3465function Zl(e) { 3466 const t = sn({ 3467 ...e, 3468 default: Ee, 3469 persistence_UNSTABLE: e.persistence_UNSTABLE === void 0 ? void 0 : { 3470 ...e.persistence_UNSTABLE, 3471 validator: (o) =>
3471 o instanceof Re ? o : j(e.persistence_UNSTABLE).validator(o, Ee) 3472 }, 3473 // TODO Hack for now. 3474 effects: e.effects, 3475 // flowlint-line unclear-type: off 3476 effects_UNSTABLE: e.effects_UNSTABLE 3477 // flowlint-line unclear-type: off 3478 }), n = Oe({ 3479 key: `${e.key}__withFallback`, 3480 get: ({ 3481 get: o 3482 }) => { 3483 const r = o(t); 3484 return r instanceof Re ? e.default : r; 3485 }, 3486 // $FlowFixMe[incompatible-call] 3487 set: ({ 3488 set: o 3489 }, r) => o(t, r), 3490 // This selector does not need to cache as it is a wrapper selector 3491 // and the selector within the wrapper selector will have a cache 3492 // option by default 3493 cachePolicy_UNSTABLE: { 3494 eviction: "most-recent" 3495 }, 3496 dangerouslyAllowMutability: e.dangerouslyAllowMutability 3497 }); 3498 return Fl(n.key, Uo(e.key)), n; 3499} 3500sn.value = (e) => new Io(e); 3501var Yl = sn; 3502class Xl { 3503 constructor(t) { 3504 var n; 3505 V(this, "_map", void 0), V(this, "_keyMapper", void 0), this._map = /* @__PURE__ */ new Map(), this._keyMapper = (n = t == null ? void 0 : t.mapKey) !== null && n !== void 0 ? n : (o) => o; 3506 } 3507 size() { 3508 return this._map.size; 3509 } 3510 has(t) { 3511 return this._map.has(this._keyMapper(t)); 3512 } 3513 get(t) { 3514 return this._map.get(this._keyMapper(t)); 3515 } 3516 set(t, n) { 3517 this._map.set(this._keyMapper(t), n); 3518 } 3519 delete(t) { 3520 this._map.delete(this._keyMapper(t)); 3521 } 3522 clear() { 3523 this._map.clear(); 3524 } 3525} 3526var Jl = { 3527 MapCache: Xl 3528}, Ql = Jl.MapCache, ec = /* @__PURE__ */ Object.freeze({ 3529 __proto__: null, 3530 MapCache: Ql 3531}); 3532const { 3533 LRUCache: Dn 3534} = $o, { 3535 MapCache: tc 3536} = ec, lt = { 3537 equality: "reference", 3538 eviction: "none", 3539 maxSize: 1 / 0 3540}; 3541function nc({ 3542 equality: e = lt.equality, 3543 eviction: t = lt.eviction, 3544 maxSize: n = lt.maxSize 3545} = lt) { 3546 const o = oc(e); 3547 return rc(t, n, o); 3548} 3549function oc(e) { 3550 switch (e) { 3551 case "reference": 3552 return (t) => t; 3553 case "value": 3554 return (t) => an(t); 3555 } 3556 throw M(`Unrecognized equality policy ${e}`); 3557} 3558function rc(e, t, n) { 3559 switch (e) { 3560 case "keep-all": 3561 return new tc({ 3562 mapKey: n 3563 }); 3564 case "lru": 3565 return new Dn({ 3566 mapKey: n, 3567 maxSize: j(t) 3568 }); 3569 case "most-recent": 3570 return new Dn({ 3571 mapKey: n, 3572 maxSize: 1 3573 }); 3574 } 3575 throw M(`Unrecognized eviction policy ${e}`); 3576} 3577var ac = nc; 3578const { 3579 setConfigDeletionHandler: sc 3580} = ue; 3581let ic = 0; 3582function lc(e) { 3583 var t, n; 3584 const o = ac({ 3585 equality: (t = (n = e.cachePolicyForParams_UNSTABLE) === null || n === void 0 ? void 0 : n.equality) !== null && t !== void 0 ? t : "value", 3586 eviction: "keep-all" 3587 }); 3588 return (r) => { 3589 var a; 3590 let i; 3591 try { 3592 i = o.get(r); 3593 } catch (I) { 3594 throw M(`Problem with cache lookup for selector ${e.key}: ${I.message}`); 3595 } 3596 if (i != null) 3597 return i; 3598 const u = `${e.key}__selectorFamily/${(a = an(r, { 3599 // It is possible to use functions in parameters if the user uses 3600 // a cache with reference equality thanks to the incrementing index. 3601 allowFunctions: !0 3602 })) !== null && a !== void 0 ? a : "void"}/${ic++}`, d = (I) => e.get(r)(I), f = e.cachePolicy_UNSTABLE, p = typeof e.retainedBy_UNSTABLE == "function" ? e.retainedBy_UNSTABLE(r) : e.retainedBy_UNSTABLE; 3603 let g; 3604 if (e.set != null) { 3605 const I = e.set; 3606 g = Oe({ 3607 key: u, 3608 get: d, 3609 set: (E, $) => I(r)(E, $), 3610 cachePolicy_UNSTABLE: f, 3611 dangerouslyAllowMutability: e.dangerouslyAllowMutability, 3612 retainedBy_UNSTABLE: p 3613 }); 3614 } else 3615 g = Oe({ 3616 key: u, 3617 get: d, 3618 cachePolicy_UNSTABLE: f, 3619 dangerouslyAllowMutability: e.dangerouslyAllowMutability, 3620 retainedBy_UNSTABLE: p 3621 }); 3622 return o.set(r, g), sc(g.key, () => { 3623 o.delete(r); 3624 }), g; 3625 }; 3626} 3627var Ve = lc; 3628Ve({ 3629 key: "__constant", 3630 get: (e) => () => e, 3631 cachePolicyForParams_UNSTABLE: { 3632 equality: "reference" 3633 } 3634}); 3635Ve({ 3636 key: "__error", 3637 get: (e) => () => { 3638 throw M(e); 3639 }, 3640 // TODO Why? 3641 cachePolicyForParams_UNSTABLE: { 3642 equality: "reference" 3643 } 3644}); 3645const { 3646 loadableWithError: xo, 3647 loadableWithPromise: Po, 3648 loadableWithValue: Oo 3649} = Xe; 3650function Tt(e, t) { 3651 const n = Array(t.length).fill(void 0), o = Array(t.length).fill(void 0); 3652 for (const [r, a] of t.entries()) 3653 try { 3654 n[r] = e(a); 3655 } catch (i) { 3656 o[r] = i; 3657 } 3658 return [n, o]; 3659} 3660function cc(e) { 3661 return e != null && !K(e); 3662} 3663function At(e) { 3664 return Array.isArray(e) ? e : Object.getOwnPropertyNames(e).map((t) => e[t]); 3665} 3666function Kt(e, t) { 3667 return Array.isArray(e) ? t : ( 3668 // Object.getOwnPropertyNames() has consistent key ordering with ES6 3669 Object.getOwnPropertyNames(e).reduce((n, o, r) => ({ 3670 ...n, 3671 [o]: t[r] 3672 }), {}) 3673 ); 3674} 3675function Ue(e, t, n) { 3676 const o = n.map((r, a) => r == null ? Oo(t[a]) : K(r) ? Po(r) : xo(r)); 3677 return Kt(e, o); 3678} 3679function uc(e, t) { 3680 return t.map((n, o) => ( 3681 /** 3682 * it's important we use === undefined as opposed to == null, because the 3683 * resolved value of the async promise could be `null`, in which case we 3684 * don't want to use syncResults[idx], which would be undefined. If async 3685 * promise resolves to `undefined`, that's ok because `syncResults[idx]` 3686 * will also be `undefined`. That's a little hacky, but it works. 3687 */
3688 n === void 0 ? e[o] : n 3689 )); 3690} 3691Ve({ 3692 key: "__waitForNone", 3693 get: (e) => ({ 3694 get: t 3695 }) => { 3696 const n = At(e), [o, r] = Tt(t, n); 3697 return Ue(e, o, r); 3698 }, 3699 dangerouslyAllowMutability: !0 3700}); 3701Ve({ 3702 key: "__waitForAny", 3703 get: (e) => ({ 3704 get: t 3705 }) => { 3706 const n = At(e), [o, r] = Tt(t, n); 3707 return r.some((a) => !K(a)) ? Ue(e, o, r) : new Promise((a) => { 3708 for (const [i, u] of r.entries()) 3709 K(u) && u.then((d) => { 3710 o[i] = d, r[i] = void 0, a(Ue(e, o, r)); 3711 }).catch((d) => { 3712 r[i] = d, a(Ue(e, o, r)); 3713 }); 3714 }); 3715 }, 3716 dangerouslyAllowMutability: !0 3717}); 3718Ve({ 3719 key: "__waitForAll", 3720 get: (e) => ({ 3721 get: t 3722 }) => { 3723 const n = At(e), [o, r] = Tt(t, n); 3724 if (r.every((i) => i == null)) 3725 return Kt(e, o); 3726 const a = r.find(cc); 3727 if (a != null) 3728 throw a; 3729 return Promise.all(r).then((i) => Kt(e, uc(o, i))); 3730 }, 3731 dangerouslyAllowMutability: !0 3732}); 3733Ve({ 3734 key: "__waitForAllSettled", 3735 get: (e) => ({ 3736 get: t 3737 }) => { 3738 const n = At(e), [o, r] = Tt(t, n); 3739 return r.every((a) => !K(a)) ? Ue(e, o, r) : Promise.all(r.map((a, i) => K(a) ? a.then((u) => { 3740 o[i] = u, r[i] = void 0; 3741 }).catch((u) => { 3742 o[i] = void 0, r[i] = u; 3743 }) : null)).then(() => Ue(e, o, r)); 3744 }, 3745 dangerouslyAllowMutability: !0 3746}); 3747Ve({ 3748 key: "__noWait", 3749 get: (e) => ({ 3750 get: t 3751 }) => { 3752 try { 3753 return Oe.value(Oo(t(e))); 3754 } catch (n) { 3755 return Oe.value(K(n) ? Po(n) : xo(n)); 3756 } 3757 }, 3758 dangerouslyAllowMutability: !0 3759}); 3760const { 3761 RecoilLoadable: kc 3762} = Xe, { 3763 DefaultValue: dc 3764} = ue, { 3765 RecoilRoot: fc 3766} = rn, { 3767 isRecoilValue: Dc 3768} = Ae, { 3769 freshSnapshot: Ic 3770} = Rt, { 3771 useRecoilState: hc, 3772 useRecoilValue: vc, 3773 useResetRecoilState: pc, 3774 useSetRecoilState: _c 3775} = Mi; 3776var be = { 3777 // Types 3778 DefaultValue: dc, 3779 // Recoil Root 3780 RecoilRoot: fc, 3781 // Atoms/Selectors 3782 atom: Yl, 3783 selector: Oe, 3784 // Hooks for Atoms/Selectors 3785 useRecoilValue: vc, 3786 useRecoilState: hc, 3787 useSetRecoilState: _c, 3788 useResetRecoilState: pc 3789}, Uc = be.DefaultValue, xc = be.RecoilRoot, Pc = be.atom, Oc = be.selector, Bc = be.useRecoilValue, zc = be.useRecoilState, Fc = be.useSetRecoilState, Wc = be.useResetRecoilState; 3790export { 3791 Pc as R, 3792 Oc as a, 3793 Uc as b, 3794 zc as c, 3795 Bc as d, 3796 Wc as e, 3797 Fc as f, 3798 xc as g 3799}; 3800//# sourceMappingURL=index-scI6IY0O.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.