UNPKG

@revenuecat/purchases-js

Version:

Web subscriptions made easy. Powered by RevenueCat

1,822 lines 930 kB
var E_ = Object.create; var Vi = Object.defineProperty; var S_ = Object.getOwnPropertyDescriptor; var Jl = (e, r) => (r = Symbol[e]) ? r : Symbol.for("Symbol." + e), aa = (e) => { throw TypeError(e); }; var Ql = (e, r, t) => r in e ? Vi(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t; var Zl = (e, r) => Vi(e, "name", { value: r, configurable: !0 }); var $l = (e) => [, , , E_((e == null ? void 0 : e[Jl("metadata")]) ?? null)], ec = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Va = (e) => e !== void 0 && typeof e != "function" ? aa("Function expected") : e, I_ = (e, r, t, n, a) => ({ kind: ec[e], name: r, metadata: n, addInitializer: (i) => t._ ? aa("Already initialized") : a.push(Va(i || null)) }), Hi = (e, r) => Ql(r, Jl("metadata"), e[3]), rc = (e, r, t, n) => { for (var a = 0, i = e[r >> 1], s = i && i.length; a < s; a++) r & 1 ? i[a].call(t) : n = i[a].call(t, n); return n; }, Wi = (e, r, t, n, a, i) => { var s, l, c, u, d, p = r & 7, g = !!(r & 8), _ = !!(r & 16), f = p > 3 ? e.length + 1 : p ? g ? 1 : 2 : 0, v = ec[p + 5], y = p > 3 && (e[f - 1] = []), b = e[f] || (e[f] = []), w = p && (!_ && !g && (a = a.prototype), p < 5 && (p > 3 || !_) && S_(p < 4 ? a : { get [t]() { return W(this, i); }, set [t](h) { return Le(this, i, h); } }, t)); p ? _ && p < 4 && Zl(i, (p > 2 ? "set " : p > 1 ? "get " : "") + t) : Zl(a, t); for (var k = n.length - 1; k >= 0; k--) u = I_(p, t, c = {}, e[3], b), p && (u.static = g, u.private = _, d = u.access = { has: _ ? (h) => T_(a, h) : (h) => t in h }, p ^ 3 && (d.get = _ ? (h) => (p ^ 1 ? W : Sr)(h, a, p ^ 4 ? i : w.get) : (h) => h[t]), p > 2 && (d.set = _ ? (h, P) => Le(h, a, P, p ^ 4 ? i : w.set) : (h, P) => h[t] = P)), l = (0, n[k])(p ? p < 4 ? _ ? i : w[v] : p > 4 ? void 0 : { get: w.get, set: w.set } : a, u), c._ = 1, p ^ 4 || l === void 0 ? Va(l) && (p > 4 ? y.unshift(l) : p ? _ ? i = l : w[v] = l : a = l) : typeof l != "object" || l === null ? aa("Object expected") : (Va(s = l.get) && (w.get = s), Va(s = l.set) && (w.set = s), Va(s = l.init) && y.unshift(s)); return p || Hi(e, a), w && Vi(a, t, w), _ ? p ^ 4 ? i : w : a; }, $ = (e, r, t) => Ql(e, typeof r != "symbol" ? r + "" : r, t), Yi = (e, r, t) => r.has(e) || aa("Cannot " + t), T_ = (e, r) => Object(r) !== r ? aa('Cannot use the "in" operator on this value') : e.has(r), W = (e, r, t) => (Yi(e, r, "read from private field"), t ? t.call(e) : r.get(e)), je = (e, r, t) => r.has(e) ? aa("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(e) : r.set(e, t), Le = (e, r, t, n) => (Yi(e, r, "write to private field"), n ? n.call(e, t) : r.set(e, t), t), Sr = (e, r, t) => (Yi(e, r, "access private method"), t); const C_ = "5"; var ju; typeof window < "u" && ((ju = window.__svelte ?? (window.__svelte = {})).v ?? (ju.v = /* @__PURE__ */ new Set())).add(C_); const D_ = 1, A_ = 2, Uu = 4, q_ = 8, F_ = 16, M_ = 1, z_ = 2, O_ = 4, L_ = 8, N_ = 16, j_ = 1, B_ = 2, R_ = 4, Vu = 1, U_ = 2, Cr = Symbol(), V_ = "http://www.w3.org/1999/xhtml", H_ = "http://www.w3.org/2000/svg", W_ = "@attach", Ds = !1; var Ii = Array.isArray, Y_ = Array.prototype.indexOf, Ti = Array.from, Hu = Object.defineProperty, vn = Object.getOwnPropertyDescriptor, Wu = Object.getOwnPropertyDescriptors, G_ = Object.prototype, K_ = Array.prototype, ul = Object.getPrototypeOf, tc = Object.isExtensible; function la(e) { return typeof e == "function"; } const Ke = () => { }; function X_(e) { return e(); } function ri(e) { for (var r = 0; r < e.length; r++) e[r](); } function Yu() { var e, r, t = new Promise((n, a) => { e = n, r = a; }); return { promise: t, resolve: e, reject: r }; } function Ci(e, r) { if (Array.isArray(e)) return e; if (r === void 0 || !(Symbol.iterator in e)) return Array.from(e); const t = []; for (const n of e) if (t.push(n), t.length === r) break; return t; } const jr = 2, ti = 4, yo = 8, dl = 1 << 24, Yt = 16, sn = 32, Jn = 64, pl = 128, gt = 512, Lr = 1024, Yr = 2048, Gt = 4096, at = 8192, tn = 16384, Di = 32768, Ht = 65536, nc = 1 << 17, Gu = 1 << 18, Aa = 1 << 19, Ku = 1 << 20, Qt = 1 << 25, no = 32768, As = 1 << 21, _l = 1 << 22, yn = 1 << 23, Bt = Symbol("$state"), Xu = Symbol("legacy props"), Z_ = Symbol(""), ua = new class extends Error { constructor() { super(...arguments); $(this, "name", "StaleReactionError"); $(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed"); } }(); function gl(e) { throw new Error("https://svelte.dev/e/lifecycle_outside_component"); } function J_() { throw new Error("https://svelte.dev/e/async_derived_orphan"); } function Q_(e) { throw new Error("https://svelte.dev/e/effect_in_teardown"); } function $_() { throw new Error("https://svelte.dev/e/effect_in_unowned_derived"); } function eg(e) { throw new Error("https://svelte.dev/e/effect_orphan"); } function rg() { throw new Error("https://svelte.dev/e/effect_update_depth_exceeded"); } function tg(e) { throw new Error("https://svelte.dev/e/props_invalid_value"); } function ng() { throw new Error("https://svelte.dev/e/state_descriptors_fixed"); } function ag() { throw new Error("https://svelte.dev/e/state_prototype_fixed"); } function og() { throw new Error("https://svelte.dev/e/state_unsafe_mutation"); } function ig() { throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror"); } function sg() { console.warn("https://svelte.dev/e/select_multiple_invalid_value"); } function lg() { console.warn("https://svelte.dev/e/svelte_boundary_reset_noop"); } function Zu(e) { return e === this.v; } function fl(e, r) { return e != e ? r == r : e !== r || e !== null && typeof e == "object" || typeof e == "function"; } function Ju(e) { return !fl(e, this.v); } let qa = !1, cg = !1; function ug() { qa = !0; } let tr = null; function xa(e) { tr = e; } function He(e) { return ( /** @type {T} */ Qu().get(e) ); } function pr(e, r) { return Qu().set(e, r), r; } function pe(e, r = !1, t) { tr = { p: tr, i: !1, c: null, e: null, s: e, x: null, l: qa && !r ? { s: null, u: null, $: [] } : null }; } function _e(e) { var r = ( /** @type {ComponentContext} */ tr ), t = r.e; if (t !== null) { r.e = null; for (var n of t) bd(n); } return e !== void 0 && (r.x = e), r.i = !0, tr = r.p, e ?? /** @type {T} */ {}; } function Fa() { return !qa || tr !== null && tr.l === null; } function Qu(e) { return tr === null && gl(), tr.c ?? (tr.c = new Map(dg(tr) || void 0)); } function dg(e) { let r = e.p; for (; r !== null; ) { const t = r.c; if (t !== null) return t; r = r.p; } return null; } let Ln = []; function $u() { var e = Ln; Ln = [], ri(e); } function En(e) { if (Ln.length === 0 && !Qa) { var r = Ln; queueMicrotask(() => { r === Ln && $u(); }); } Ln.push(e); } function pg() { for (; Ln.length > 0; ) $u(); } function ed(e) { var r = Xe; if (r === null) return Ve.f |= yn, e; if ((r.f & Di) === 0) { if ((r.f & pl) === 0) throw e; r.b.error(e); } else Ea(e, r); } function Ea(e, r) { for (; r !== null; ) { if ((r.f & pl) !== 0) try { r.b.error(e); return; } catch (t) { e = t; } r = r.parent; } throw e; } const _g = -7169; function Tr(e, r) { e.f = e.f & _g | r; } function ml(e) { (e.f & gt) !== 0 || e.deps === null ? Tr(e, Lr) : Tr(e, Gt); } function rd(e) { if (e !== null) for (const r of e) (r.f & jr) === 0 || (r.f & no) === 0 || (r.f ^= no, rd( /** @type {Derived} */ r.deps )); } function td(e, r, t) { (e.f & Yr) !== 0 ? r.add(e) : (e.f & Gt) !== 0 && t.add(e), rd(e.deps), Tr(e, Lr); } const qo = /* @__PURE__ */ new Set(); let We = null, Ko = null, zr = null, _t = [], Ai = null, qs = !1, Qa = !1; var ma, ha, Nn, jn, _o, va, ya, mt, Fs, Ms, nd, ad; const wi = class wi { constructor() { je(this, mt); $(this, "committed", !1); /** * The current values of any sources that are updated in this batch * They keys of this map are identical to `this.#previous` * @type {Map<Source, any>} */ $(this, "current", /* @__PURE__ */ new Map()); /** * The values of any sources that are updated in this batch _before_ those updates took place. * They keys of this map are identical to `this.#current` * @type {Map<Source, any>} */ $(this, "previous", /* @__PURE__ */ new Map()); /** * When the batch is committed (and the DOM is updated), we need to remove old branches * and append new ones by calling the functions added inside (if/each/key/etc) blocks * @type {Set<() => void>} */ je(this, ma, /* @__PURE__ */ new Set()); /** * If a fork is discarded, we need to destroy any effects that are no longer needed * @type {Set<(batch: Batch) => void>} */ je(this, ha, /* @__PURE__ */ new Set()); /** * The number of async effects that are currently in flight */ je(this, Nn, 0); /** * The number of async effects that are currently in flight, _not_ inside a pending boundary */ je(this, jn, 0); /** * A deferred that resolves when the batch is committed, used with `settled()` * TODO replace with Promise.withResolvers once supported widely enough * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null} */ je(this, _o, null); /** * Deferred effects (which run after async work has completed) that are DIRTY * @type {Set<Effect>} */ je(this, va, /* @__PURE__ */ new Set()); /** * Deferred effects that are MAYBE_DIRTY * @type {Set<Effect>} */ je(this, ya, /* @__PURE__ */ new Set()); /** * A set of branches that still exist, but will be destroyed when this batch * is committed — we skip over these during `process` * @type {Set<Effect>} */ $(this, "skipped_effects", /* @__PURE__ */ new Set()); $(this, "is_fork", !1); } is_deferred() { return this.is_fork || W(this, jn) > 0; } /** * * @param {Effect[]} root_effects */ process(r) { var a; _t = [], Ko = null, this.apply(); var t = [], n = []; for (const i of r) Sr(this, mt, Fs).call(this, i, t, n); this.is_fork || Sr(this, mt, nd).call(this), this.is_deferred() ? (Sr(this, mt, Ms).call(this, n), Sr(this, mt, Ms).call(this, t)) : (Ko = this, We = null, ac(n), ac(t), Ko = null, (a = W(this, _o)) == null || a.resolve()), zr = null; } /** * Associate a change to a given source with the current * batch, noting its previous and current values * @param {Source} source * @param {any} value */ capture(r, t) { t !== Cr && !this.previous.has(r) && this.previous.set(r, t), (r.f & yn) === 0 && (this.current.set(r, r.v), zr == null || zr.set(r, r.v)); } activate() { We = this, this.apply(); } deactivate() { We === this && (We = null, zr = null); } flush() { if (this.activate(), _t.length > 0) { if (od(), We !== null && We !== this) return; } else W(this, Nn) === 0 && this.process([]); this.deactivate(); } discard() { for (const r of W(this, ha)) r(this); W(this, ha).clear(); } /** * * @param {boolean} blocking */ increment(r) { Le(this, Nn, W(this, Nn) + 1), r && Le(this, jn, W(this, jn) + 1); } /** * * @param {boolean} blocking */ decrement(r) { Le(this, Nn, W(this, Nn) - 1), r && Le(this, jn, W(this, jn) - 1), this.revive(); } revive() { for (const r of W(this, va)) W(this, ya).delete(r), Tr(r, Yr), on(r); for (const r of W(this, ya)) Tr(r, Gt), on(r); this.flush(); } /** @param {() => void} fn */ oncommit(r) { W(this, ma).add(r); } /** @param {(batch: Batch) => void} fn */ ondiscard(r) { W(this, ha).add(r); } settled() { return (W(this, _o) ?? Le(this, _o, Yu())).promise; } static ensure() { if (We === null) { const r = We = new wi(); qo.add(We), Qa || wi.enqueue(() => { We === r && r.flush(); }); } return We; } /** @param {() => void} task */ static enqueue(r) { En(r); } apply() { } }; ma = new WeakMap(), ha = new WeakMap(), Nn = new WeakMap(), jn = new WeakMap(), _o = new WeakMap(), va = new WeakMap(), ya = new WeakMap(), mt = new WeakSet(), /** * Traverse the effect tree, executing effects or stashing * them for later execution as appropriate * @param {Effect} root * @param {Effect[]} effects * @param {Effect[]} render_effects */ Fs = function(r, t, n) { r.f ^= Lr; for (var a = r.first, i = null; a !== null; ) { var s = a.f, l = (s & (sn | Jn)) !== 0, c = l && (s & Lr) !== 0, u = c || (s & at) !== 0 || this.skipped_effects.has(a); if (!u && a.fn !== null) { l ? a.f ^= Lr : i !== null && (s & (ti | yo | dl)) !== 0 ? i.b.defer_effect(a) : (s & ti) !== 0 ? t.push(a) : La(a) && ((s & Yt) !== 0 && W(this, va).add(a), Ia(a)); var d = a.first; if (d !== null) { a = d; continue; } } var p = a.parent; for (a = a.next; a === null && p !== null; ) p === i && (i = null), a = p.next, p = p.parent; } }, /** * @param {Effect[]} effects */ Ms = function(r) { for (var t = 0; t < r.length; t += 1) td(r[t], W(this, va), W(this, ya)); }, nd = function() { if (W(this, jn) === 0) { for (const r of W(this, ma)) r(); W(this, ma).clear(); } W(this, Nn) === 0 && Sr(this, mt, ad).call(this); }, ad = function() { var a; if (qo.size > 1) { this.previous.clear(); var r = zr, t = !0; for (const i of qo) { if (i === this) { t = !1; continue; } const s = []; for (const [c, u] of this.current) { if (i.current.has(c)) if (t && u !== i.current.get(c)) i.current.set(c, u); else continue; s.push(c); } if (s.length === 0) continue; const l = [...i.current.keys()].filter((c) => !this.current.has(c)); if (l.length > 0) { var n = _t; _t = []; const c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(); for (const d of s) id(d, l, c, u); if (_t.length > 0) { We = i, i.apply(); for (const d of _t) Sr(a = i, mt, Fs).call(a, d, [], []); i.deactivate(); } _t = n; } } We = null, zr = r; } this.committed = !0, qo.delete(this); }; let $t = wi; function gg(e) { var r = Qa; Qa = !0; try { for (var t; ; ) { if (pg(), _t.length === 0 && (We == null || We.flush(), _t.length === 0)) return Ai = null, /** @type {T} */ t; od(); } } finally { Qa = r; } } function od() { var e = Wn; qs = !0; var r = null; try { var t = 0; for (ai(!0); _t.length > 0; ) { var n = $t.ensure(); if (t++ > 1e3) { var a, i; fg(); } n.process(_t), bn.clear(); } } finally { qs = !1, ai(e), Ai = null; } } function fg() { try { rg(); } catch (e) { Ea(e, Ai); } } let yt = null; function ac(e) { var r = e.length; if (r !== 0) { for (var t = 0; t < r; ) { var n = e[t++]; if ((n.f & (tn | at)) === 0 && La(n) && (yt = /* @__PURE__ */ new Set(), Ia(n), n.deps === null && n.first === null && n.nodes === null && (n.teardown === null && n.ac === null ? Ed(n) : n.fn = null), (yt == null ? void 0 : yt.size) > 0)) { bn.clear(); for (const a of yt) { if ((a.f & (tn | at)) !== 0) continue; const i = [a]; let s = a.parent; for (; s !== null; ) yt.has(s) && (yt.delete(s), i.push(s)), s = s.parent; for (let l = i.length - 1; l >= 0; l--) { const c = i[l]; (c.f & (tn | at)) === 0 && Ia(c); } } yt.clear(); } } yt = null; } } function id(e, r, t, n) { if (!t.has(e) && (t.add(e), e.reactions !== null)) for (const a of e.reactions) { const i = a.f; (i & jr) !== 0 ? id( /** @type {Derived} */ a, r, t, n ) : (i & (_l | Yt)) !== 0 && (i & Yr) === 0 && sd(a, r, n) && (Tr(a, Yr), on( /** @type {Effect} */ a )); } } function sd(e, r, t) { const n = t.get(e); if (n !== void 0) return n; if (e.deps !== null) for (const a of e.deps) { if (r.includes(a)) return !0; if ((a.f & jr) !== 0 && sd( /** @type {Derived} */ a, r, t )) return t.set( /** @type {Derived} */ a, !0 ), !0; } return t.set(e, !1), !1; } function on(e) { for (var r = Ai = e; r.parent !== null; ) { r = r.parent; var t = r.f; if (qs && r === Xe && (t & Yt) !== 0 && (t & Gu) === 0) return; if ((t & (Jn | sn)) !== 0) { if ((t & Lr) === 0) return; r.f ^= Lr; } } _t.push(r); } function ld(e) { let r = 0, t = Gn(0), n; return () => { vl() && (o(t), Oa(() => (r === 0 && (n = Ne(() => e(() => $a(t)))), r += 1, () => { En(() => { r -= 1, r === 0 && (n == null || n(), n = void 0, $a(t)); }); }))); }; } var mg = Ht | Aa | pl; function cd(e, r, t) { new hg(e, r, t); } var ct, cl, Ot, Bn, Lt, ut, Kr, Nt, Xt, _n, Rn, gn, Un, ba, ka, fn, Pi, qr, vg, yg, zs, Xo, Zo, Os; class hg { /** * @param {TemplateNode} node * @param {BoundaryProps} props * @param {((anchor: Node) => void)} children */ constructor(r, t, n) { je(this, qr); /** @type {Boundary | null} */ $(this, "parent"); $(this, "is_pending", !1); /** @type {TemplateNode} */ je(this, ct); /** @type {TemplateNode | null} */ je(this, cl, null); /** @type {BoundaryProps} */ je(this, Ot); /** @type {((anchor: Node) => void)} */ je(this, Bn); /** @type {Effect} */ je(this, Lt); /** @type {Effect | null} */ je(this, ut, null); /** @type {Effect | null} */ je(this, Kr, null); /** @type {Effect | null} */ je(this, Nt, null); /** @type {DocumentFragment | null} */ je(this, Xt, null); /** @type {TemplateNode | null} */ je(this, _n, null); je(this, Rn, 0); je(this, gn, 0); je(this, Un, !1); /** @type {Set<Effect>} */ je(this, ba, /* @__PURE__ */ new Set()); /** @type {Set<Effect>} */ je(this, ka, /* @__PURE__ */ new Set()); /** * A source containing the number of pending async deriveds/expressions. * Only created if `$effect.pending()` is used inside the boundary, * otherwise updating the source results in needless `Batch.ensure()` * calls followed by no-op flushes * @type {Source<number> | null} */ je(this, fn, null); je(this, Pi, ld(() => (Le(this, fn, Gn(W(this, Rn))), () => { Le(this, fn, null); }))); Le(this, ct, r), Le(this, Ot, t), Le(this, Bn, n), this.parent = /** @type {Effect} */ Xe.b, this.is_pending = !!W(this, Ot).pending, Le(this, Lt, $n(() => { Xe.b = this; { var a = Sr(this, qr, zs).call(this); try { Le(this, ut, Xr(() => n(a))); } catch (i) { this.error(i); } W(this, gn) > 0 ? Sr(this, qr, Zo).call(this) : this.is_pending = !1; } return () => { var i; (i = W(this, _n)) == null || i.remove(); }; }, mg)); } /** * Defer an effect inside a pending boundary until the boundary resolves * @param {Effect} effect */ defer_effect(r) { td(r, W(this, ba), W(this, ka)); } /** * Returns `false` if the effect exists inside a boundary whose pending snippet is shown * @returns {boolean} */ is_rendered() { return !this.is_pending && (!this.parent || this.parent.is_rendered()); } has_pending_snippet() { return !!W(this, Ot).pending; } /** * Update the source that powers `$effect.pending()` inside this boundary, * and controls when the current `pending` snippet (if any) is removed. * Do not call from inside the class * @param {1 | -1} d */ update_pending_count(r) { Sr(this, qr, Os).call(this, r), Le(this, Rn, W(this, Rn) + r), W(this, fn) && Sa(W(this, fn), W(this, Rn)); } get_effect_pending() { return W(this, Pi).call(this), o( /** @type {Source<number>} */ W(this, fn) ); } /** @param {unknown} error */ error(r) { var t = W(this, Ot).onerror; let n = W(this, Ot).failed; if (W(this, Un) || !t && !n) throw r; W(this, ut) && (Nr(W(this, ut)), Le(this, ut, null)), W(this, Kr) && (Nr(W(this, Kr)), Le(this, Kr, null)), W(this, Nt) && (Nr(W(this, Nt)), Le(this, Nt, null)); var a = !1, i = !1; const s = () => { if (a) { lg(); return; } a = !0, i && ig(), $t.ensure(), Le(this, Rn, 0), W(this, Nt) !== null && Hn(W(this, Nt), () => { Le(this, Nt, null); }), this.is_pending = this.has_pending_snippet(), Le(this, ut, Sr(this, qr, Xo).call(this, () => (Le(this, Un, !1), Xr(() => W(this, Bn).call(this, W(this, ct)))))), W(this, gn) > 0 ? Sr(this, qr, Zo).call(this) : this.is_pending = !1; }; var l = Ve; try { Zr(null), i = !0, t == null || t(r, s), i = !1; } catch (c) { Ea(c, W(this, Lt) && W(this, Lt).parent); } finally { Zr(l); } n && En(() => { Le(this, Nt, Sr(this, qr, Xo).call(this, () => { $t.ensure(), Le(this, Un, !0); try { return Xr(() => { n( W(this, ct), () => r, () => s ); }); } catch (c) { return Ea( c, /** @type {Effect} */ W(this, Lt).parent ), null; } finally { Le(this, Un, !1); } })); }); } } ct = new WeakMap(), cl = new WeakMap(), Ot = new WeakMap(), Bn = new WeakMap(), Lt = new WeakMap(), ut = new WeakMap(), Kr = new WeakMap(), Nt = new WeakMap(), Xt = new WeakMap(), _n = new WeakMap(), Rn = new WeakMap(), gn = new WeakMap(), Un = new WeakMap(), ba = new WeakMap(), ka = new WeakMap(), fn = new WeakMap(), Pi = new WeakMap(), qr = new WeakSet(), vg = function() { try { Le(this, ut, Xr(() => W(this, Bn).call(this, W(this, ct)))); } catch (r) { this.error(r); } }, yg = function() { const r = W(this, Ot).pending; r && (Le(this, Kr, Xr(() => r(W(this, ct)))), $t.enqueue(() => { var t = Sr(this, qr, zs).call(this); Le(this, ut, Sr(this, qr, Xo).call(this, () => ($t.ensure(), Xr(() => W(this, Bn).call(this, t))))), W(this, gn) > 0 ? Sr(this, qr, Zo).call(this) : (Hn( /** @type {Effect} */ W(this, Kr), () => { Le(this, Kr, null); } ), this.is_pending = !1); })); }, zs = function() { var r = W(this, ct); return this.is_pending && (Le(this, _n, Ut()), W(this, ct).before(W(this, _n)), r = W(this, _n)), r; }, /** * @param {() => Effect | null} fn */ Xo = function(r) { var t = Xe, n = Ve, a = tr; Wt(W(this, Lt)), Zr(W(this, Lt)), xa(W(this, Lt).ctx); try { return r(); } catch (i) { return ed(i), null; } finally { Wt(t), Zr(n), xa(a); } }, Zo = function() { const r = ( /** @type {(anchor: Node) => void} */ W(this, Ot).pending ); W(this, ut) !== null && (Le(this, Xt, document.createDocumentFragment()), W(this, Xt).append( /** @type {TemplateNode} */ W(this, _n) ), Td(W(this, ut), W(this, Xt))), W(this, Kr) === null && Le(this, Kr, Xr(() => r(W(this, ct)))); }, /** * Updates the pending count associated with the currently visible pending snippet, * if any, such that we can replace the snippet with content once work is done * @param {1 | -1} d */ Os = function(r) { var t; if (!this.has_pending_snippet()) { this.parent && Sr(t = this.parent, qr, Os).call(t, r); return; } if (Le(this, gn, W(this, gn) + r), W(this, gn) === 0) { this.is_pending = !1; for (const n of W(this, ba)) Tr(n, Yr), on(n); for (const n of W(this, ka)) Tr(n, Gt), on(n); W(this, ba).clear(), W(this, ka).clear(), W(this, Kr) && Hn(W(this, Kr), () => { Le(this, Kr, null); }), W(this, Xt) && (W(this, ct).before(W(this, Xt)), Le(this, Xt, null)); } }; function ud(e, r, t, n) { const a = Fa() ? bo : Rt; if (t.length === 0 && e.length === 0) { n(r.map(a)); return; } var i = We, s = ( /** @type {Effect} */ Xe ), l = bg(); function c() { Promise.all(t.map((u) => /* @__PURE__ */ kg(u))).then((u) => { l(); try { n([...r.map(a), ...u]); } catch (d) { (s.f & tn) === 0 && Ea(d, s); } i == null || i.deactivate(), ni(); }).catch((u) => { Ea(u, s); }); } e.length > 0 ? Promise.all(e).then(() => { l(); try { return c(); } finally { i == null || i.deactivate(), ni(); } }) : c(); } function bg() { var e = Xe, r = Ve, t = tr, n = We; return function(i = !0) { Wt(e), Zr(r), xa(t), i && (n == null || n.activate()); }; } function ni() { Wt(null), Zr(null), xa(null); } // @__NO_SIDE_EFFECTS__ function bo(e) { var r = jr | Yr, t = Ve !== null && (Ve.f & jr) !== 0 ? ( /** @type {Derived} */ Ve ) : null; return Xe !== null && (Xe.f |= Aa), { ctx: tr, deps: null, effects: null, equals: Zu, f: r, fn: e, reactions: null, rv: 0, v: ( /** @type {V} */ Cr ), wv: 0, parent: t ?? Xe, ac: null }; } // @__NO_SIDE_EFFECTS__ function kg(e, r, t) { let n = ( /** @type {Effect | null} */ Xe ); n === null && J_(); var a = ( /** @type {Boundary} */ n.b ), i = ( /** @type {Promise<V>} */ /** @type {unknown} */ void 0 ), s = Gn( /** @type {V} */ Cr ), l = !Ve, c = /* @__PURE__ */ new Map(); return Fg(() => { var _; var u = Yu(); i = u.promise; try { Promise.resolve(e()).then(u.resolve, u.reject).then(() => { d === We && d.committed && d.deactivate(), ni(); }); } catch (f) { u.reject(f), ni(); } var d = ( /** @type {Batch} */ We ); if (l) { var p = a.is_rendered(); a.update_pending_count(1), d.increment(p), (_ = c.get(d)) == null || _.reject(ua), c.delete(d), c.set(d, u); } const g = (f, v = void 0) => { if (d.activate(), v) v !== ua && (s.f |= yn, Sa(s, v)); else { (s.f & yn) !== 0 && (s.f ^= yn), Sa(s, f); for (const [y, b] of c) { if (c.delete(y), y === d) break; b.reject(ua); } } l && (a.update_pending_count(-1), d.decrement(p)); }; u.promise.then(g, (f) => g(null, f || "unknown")); }), za(() => { for (const u of c.values()) u.reject(ua); }), new Promise((u) => { function d(p) { function g() { p === i ? u(s) : d(i); } p.then(g, g); } d(i); }); } // @__NO_SIDE_EFFECTS__ function m(e) { const r = /* @__PURE__ */ bo(e); return Cd(r), r; } // @__NO_SIDE_EFFECTS__ function Rt(e) { const r = /* @__PURE__ */ bo(e); return r.equals = Ju, r; } function dd(e) { var r = e.effects; if (r !== null) { e.effects = null; for (var t = 0; t < r.length; t += 1) Nr( /** @type {Effect} */ r[t] ); } } function wg(e) { for (var r = e.parent; r !== null; ) { if ((r.f & jr) === 0) return (r.f & tn) === 0 ? ( /** @type {Effect} */ r ) : null; r = r.parent; } return null; } function hl(e) { var r, t = Xe; Wt(wg(e)); try { e.f &= ~no, dd(e), r = Fd(e); } finally { Wt(t); } return r; } function pd(e) { var r = hl(e); if (!e.equals(r) && (e.wv = Ad(), (!(We != null && We.is_fork) || e.deps === null) && (e.v = r, e.deps === null))) { Tr(e, Lr); return; } kn || (zr !== null ? (vl() || We != null && We.is_fork) && zr.set(e, r) : ml(e)); } let Ls = /* @__PURE__ */ new Set(); const bn = /* @__PURE__ */ new Map(); let _d = !1; function Gn(e, r) { var t = { f: 0, // TODO ideally we could skip this altogether, but it causes type errors v: e, reactions: null, equals: Zu, rv: 0, wv: 0 }; return t; } // @__NO_SIDE_EFFECTS__ function re(e, r) { const t = Gn(e); return Cd(t), t; } // @__NO_SIDE_EFFECTS__ function rr(e, r = !1, t = !0) { var a; const n = Gn(e); return r || (n.equals = Ju), qa && t && tr !== null && tr.l !== null && ((a = tr.l).s ?? (a.s = [])).push(n), n; } function L(e, r, t = !1) { Ve !== null && // since we are untracking the function inside `$inspect.with` we need to add this check // to ensure we error if state is set inside an inspect effect (!kt || (Ve.f & nc) !== 0) && Fa() && (Ve.f & (jr | Yt | _l | nc)) !== 0 && !(Wr != null && Wr.includes(e)) && og(); let n = t ? Je(r) : r; return Sa(e, n); } function Sa(e, r) { if (!e.equals(r)) { var t = e.v; kn ? bn.set(e, r) : bn.set(e, t), e.v = r; var n = $t.ensure(); if (n.capture(e, t), (e.f & jr) !== 0) { const a = ( /** @type {Derived} */ e ); (e.f & Yr) !== 0 && hl(a), ml(a); } e.wv = Ad(), gd(e, Yr), Fa() && Xe !== null && (Xe.f & Lr) !== 0 && (Xe.f & (sn | Jn)) === 0 && (lt === null ? zg([e]) : lt.push(e)), !n.is_fork && Ls.size > 0 && !_d && Pg(); } return r; } function Pg() { _d = !1; var e = Wn; ai(!0); const r = Array.from(Ls); try { for (const t of r) (t.f & Lr) !== 0 && Tr(t, Gt), La(t) && Ia(t); } finally { ai(e); } Ls.clear(); } function $a(e) { L(e, e.v + 1); } function gd(e, r) { var t = e.reactions; if (t !== null) for (var n = Fa(), a = t.length, i = 0; i < a; i++) { var s = t[i], l = s.f; if (!(!n && s === Xe)) { var c = (l & Yr) === 0; if (c && Tr(s, r), (l & jr) !== 0) { var u = ( /** @type {Derived} */ s ); zr == null || zr.delete(u), (l & no) === 0 && (l & gt && (s.f |= no), gd(u, Gt)); } else c && ((l & Yt) !== 0 && yt !== null && yt.add( /** @type {Effect} */ s ), on( /** @type {Effect} */ s )); } } } function Je(e) { if (typeof e != "object" || e === null || Bt in e) return e; const r = ul(e); if (r !== G_ && r !== K_) return e; var t = /* @__PURE__ */ new Map(), n = Ii(e), a = /* @__PURE__ */ re(0), i = Yn, s = (l) => { if (Yn === i) return l(); var c = Ve, u = Yn; Zr(null), cc(i); var d = l(); return Zr(c), cc(u), d; }; return n && t.set("length", /* @__PURE__ */ re( /** @type {any[]} */ e.length )), new Proxy( /** @type {any} */ e, { defineProperty(l, c, u) { (!("value" in u) || u.configurable === !1 || u.enumerable === !1 || u.writable === !1) && ng(); var d = t.get(c); return d === void 0 ? d = s(() => { var p = /* @__PURE__ */ re(u.value); return t.set(c, p), p; }) : L(d, u.value, !0), !0; }, deleteProperty(l, c) { var u = t.get(c); if (u === void 0) { if (c in l) { const d = s(() => /* @__PURE__ */ re(Cr)); t.set(c, d), $a(a); } } else L(u, Cr), $a(a); return !0; }, get(l, c, u) { var _; if (c === Bt) return e; var d = t.get(c), p = c in l; if (d === void 0 && (!p || (_ = vn(l, c)) != null && _.writable) && (d = s(() => { var f = Je(p ? l[c] : Cr), v = /* @__PURE__ */ re(f); return v; }), t.set(c, d)), d !== void 0) { var g = o(d); return g === Cr ? void 0 : g; } return Reflect.get(l, c, u); }, getOwnPropertyDescriptor(l, c) { var u = Reflect.getOwnPropertyDescriptor(l, c); if (u && "value" in u) { var d = t.get(c); d && (u.value = o(d)); } else if (u === void 0) { var p = t.get(c), g = p == null ? void 0 : p.v; if (p !== void 0 && g !== Cr) return { enumerable: !0, configurable: !0, value: g, writable: !0 }; } return u; }, has(l, c) { var g; if (c === Bt) return !0; var u = t.get(c), d = u !== void 0 && u.v !== Cr || Reflect.has(l, c); if (u !== void 0 || Xe !== null && (!d || (g = vn(l, c)) != null && g.writable)) { u === void 0 && (u = s(() => { var _ = d ? Je(l[c]) : Cr, f = /* @__PURE__ */ re(_); return f; }), t.set(c, u)); var p = o(u); if (p === Cr) return !1; } return d; }, set(l, c, u, d) { var k; var p = t.get(c), g = c in l; if (n && c === "length") for (var _ = u; _ < /** @type {Source<number>} */ p.v; _ += 1) { var f = t.get(_ + ""); f !== void 0 ? L(f, Cr) : _ in l && (f = s(() => /* @__PURE__ */ re(Cr)), t.set(_ + "", f)); } if (p === void 0) (!g || (k = vn(l, c)) != null && k.writable) && (p = s(() => /* @__PURE__ */ re(void 0)), L(p, Je(u)), t.set(c, p)); else { g = p.v !== Cr; var v = s(() => Je(u)); L(p, v); } var y = Reflect.getOwnPropertyDescriptor(l, c); if (y != null && y.set && y.set.call(d, u), !g) { if (n && typeof c == "string") { var b = ( /** @type {Source<number>} */ t.get("length") ), w = Number(c); Number.isInteger(w) && w >= b.v && L(b, w + 1); } $a(a); } return !0; }, ownKeys(l) { o(a); var c = Reflect.ownKeys(l).filter((p) => { var g = t.get(p); return g === void 0 || g.v !== Cr; }); for (var [u, d] of t) d.v !== Cr && !(u in l) && c.push(u); return c; }, setPrototypeOf() { ag(); } } ); } function oc(e) { try { if (e !== null && typeof e == "object" && Bt in e) return e[Bt]; } catch { } return e; } function xg(e, r) { return Object.is(oc(e), oc(r)); } var ic, fd, md, hd; function Eg() { if (ic === void 0) { ic = window, fd = /Firefox/.test(navigator.userAgent); var e = Element.prototype, r = Node.prototype, t = Text.prototype; md = vn(r, "firstChild").get, hd = vn(r, "nextSibling").get, tc(e) && (e.__click = void 0, e.__className = void 0, e.__attributes = null, e.__style = void 0, e.__e = void 0), tc(t) && (t.__t = void 0); } } function Ut(e = "") { return document.createTextNode(e); } // @__NO_SIDE_EFFECTS__ function nt(e) { return ( /** @type {TemplateNode | null} */ md.call(e) ); } // @__NO_SIDE_EFFECTS__ function ko(e) { return ( /** @type {TemplateNode | null} */ hd.call(e) ); } function z(e, r) { return /* @__PURE__ */ nt(e); } function ae(e, r = !1) { { var t = /* @__PURE__ */ nt(e); return t instanceof Comment && t.data === "" ? /* @__PURE__ */ ko(t) : t; } } function Y(e, r = 1, t = !1) { let n = e; for (; r--; ) n = /** @type {TemplateNode} */ /* @__PURE__ */ ko(n); return n; } function Sg(e) { e.textContent = ""; } function vd() { return !1; } function Ig(e, r) { if (r) { const t = document.body; e.autofocus = !0, En(() => { document.activeElement === t && e.focus(); }); } } let sc = !1; function Tg() { sc || (sc = !0, document.addEventListener( "reset", (e) => { Promise.resolve().then(() => { var r; if (!e.defaultPrevented) for ( const t of /**@type {HTMLFormElement} */ e.target.elements ) (r = t.__on_r) == null || r.call(t); }); }, // In the capture phase to guarantee we get noticed of it (no possibility of stopPropagation) { capture: !0 } )); } function Ma(e) { var r = Ve, t = Xe; Zr(null), Wt(null); try { return e(); } finally { Zr(r), Wt(t); } } function Cg(e, r, t, n = t) { e.addEventListener(r, () => Ma(t)); const a = e.__on_r; a ? e.__on_r = () => { a(), n(!0); } : e.__on_r = () => n(!0), Tg(); } function yd(e) { Xe === null && (Ve === null && eg(), $_()), kn && Q_(); } function Dg(e, r) { var t = r.last; t === null ? r.last = r.first = e : (t.next = e, e.prev = t, r.last = e); } function xt(e, r, t) { var n = Xe; n !== null && (n.f & at) !== 0 && (e |= at); var a = { ctx: tr, deps: null, nodes: null, f: e | Yr | gt, first: null, fn: r, last: null, next: null, parent: n, b: n && n.b, prev: null, teardown: null, wv: 0, ac: null }; if (t) try { Ia(a), a.f |= Di; } catch (l) { throw Nr(a), l; } else r !== null && on(a); var i = a; if (t && i.deps === null && i.teardown === null && i.nodes === null && i.first === i.last && // either `null`, or a singular child (i.f & Aa) === 0 && (i = i.first, (e & Yt) !== 0 && (e & Ht) !== 0 && i !== null && (i.f |= Ht)), i !== null && (i.parent = n, n !== null && Dg(i, n), Ve !== null && (Ve.f & jr) !== 0 && (e & Jn) === 0)) { var s = ( /** @type {Derived} */ Ve ); (s.effects ?? (s.effects = [])).push(i); } return a; } function vl() { return Ve !== null && !kt; } function za(e) { const r = xt(yo, null, !1); return Tr(r, Lr), r.teardown = e, r; } function dr(e) { yd(); var r = ( /** @type {Effect} */ Xe.f ), t = !Ve && (r & sn) !== 0 && (r & Di) === 0; if (t) { var n = ( /** @type {ComponentContext} */ tr ); (n.e ?? (n.e = [])).push(e); } else return bd(e); } function bd(e) { return xt(ti | Ku, e, !1); } function Ag(e) { return yd(), xt(yo | Ku, e, !0); } function qg(e) { $t.ensure(); const r = xt(Jn | Aa, e, !0); return (t = {}) => new Promise((n) => { t.outro ? Hn(r, () => { Nr(r), n(void 0); }) : (Nr(r), n(void 0)); }); } function Qn(e) { return xt(ti, e, !1); } function lr(e, r) { var t = ( /** @type {ComponentContextLegacy} */ tr ), n = { effect: null, ran: !1, deps: e }; t.l.$.push(n), n.effect = Oa(() => { e(), !n.ran && (n.ran = !0, Ne(r)); }); } function yl() { var e = ( /** @type {ComponentContextLegacy} */ tr ); Oa(() => { for (var r of e.l.$) { r.deps(); var t = r.effect; (t.f & Lr) !== 0 && t.deps !== null && Tr(t, Gt), La(t) && Ia(t), r.ran = !1; } }); } function Fg(e) { return xt(_l | Aa, e, !0); } function Oa(e, r = 0) { return xt(yo | r, e, !0); } function K(e, r = [], t = [], n = []) { ud(n, r, t, (a) => { xt(yo, () => e(...a.map(o)), !0); }); } function $n(e, r = 0) { var t = xt(Yt | r, e, !0); return t; } function kd(e, r = 0) { var t = xt(dl | r, e, !0); return t; } function Xr(e) { return xt(sn | Aa, e, !0); } function wd(e) { var r = e.teardown; if (r !== null) { const t = kn, n = Ve; lc(!0), Zr(null); try { r.call(null); } finally { lc(t), Zr(n); } } } function Pd(e, r = !1) { var t = e.first; for (e.first = e.last = null; t !== null; ) { const a = t.ac; a !== null && Ma(() => { a.abort(ua); }); var n = t.next; (t.f & Jn) !== 0 ? t.parent = null : Nr(t, r), t = n; } } function Mg(e) { for (var r = e.first; r !== null; ) { var t = r.next; (r.f & sn) === 0 && Nr(r), r = t; } } function Nr(e, r = !0) { var t = !1; (r || (e.f & Gu) !== 0) && e.nodes !== null && e.nodes.end !== null && (xd( e.nodes.start, /** @type {TemplateNode} */ e.nodes.end ), t = !0), Pd(e, r && !t), oi(e, 0), Tr(e, tn); var n = e.nodes && e.nodes.t; if (n !== null) for (const i of n) i.stop(); wd(e); var a = e.parent; a !== null && a.first !== null && Ed(e), e.next = e.prev = e.teardown = e.ctx = e.deps = e.fn = e.nodes = e.ac = null; } function xd(e, r) { for (; e !== null; ) { var t = e === r ? null : /* @__PURE__ */ ko(e); e.remove(), e = t; } } function Ed(e) { var r = e.parent, t = e.prev, n = e.next; t !== null && (t.next = n), n !== null && (n.prev = t), r !== null && (r.first === e && (r.first = n), r.last === e && (r.last = t)); } function Hn(e, r, t = !0) { var n = []; Sd(e, n, !0); var a = () => { t && Nr(e), r && r(); }, i = n.length; if (i > 0) { var s = () => --i || a(); for (var l of n) l.out(s); } else a(); } function Sd(e, r, t) { if ((e.f & at) === 0) { e.f ^= at; var n = e.nodes && e.nodes.t; if (n !== null) for (const l of n) (l.is_global || t) && r.push(l); for (var a = e.first; a !== null; ) { var i = a.next, s = (a.f & Ht) !== 0 || // If this is a branch effect without a block effect parent, // it means the parent block effect was pruned. In that case, // transparency information was transferred to the branch effect. (a.f & sn) !== 0 && (e.f & Yt) !== 0; Sd(a, r, s ? t : !1), a = i; } } } function bl(e) { Id(e, !0); } function Id(e, r) { if ((e.f & at) !== 0) { e.f ^= at, (e.f & Lr) === 0 && (Tr(e, Yr), on(e)); for (var t = e.first; t !== null; ) { var n = t.next, a = (t.f & Ht) !== 0 || (t.f & sn) !== 0; Id(t, a ? r : !1), t = n; } var i = e.nodes && e.nodes.t; if (i !== null) for (const s of i) (s.is_global || r) && s.in(); } } function Td(e, r) { if (e.nodes) for (var t = e.nodes.start, n = e.nodes.end; t !== null; ) { var a = t === n ? null : /* @__PURE__ */ ko(t); r.append(t), t = a; } } let Wn = !1; function ai(e) { Wn = e; } let kn = !1; function lc(e) { kn = e; } let Ve = null, kt = !1; function Zr(e) { Ve = e; } let Xe = null; function Wt(e) { Xe = e; } let Wr = null; function Cd(e) { Ve !== null && (Wr === null ? Wr = [e] : Wr.push(e)); } let Vr = null, rt = 0, lt = null; function zg(e) { lt = e; } let Dd = 1, ao = 0, Yn = ao; function cc(e) { Yn = e; } function Ad() { return ++Dd; } function La(e) { var r = e.f; if ((r & Yr) !== 0) return !0; if (r & jr && (e.f &= -32769), (r & Gt) !== 0) { for (var t = ( /** @type {Value[]} */ e.deps ), n = t.length, a = 0; a < n; a++) { var i = t[a]; if (La( /** @type {Derived} */ i ) && pd( /** @type {Derived} */ i ), i.wv > e.wv) return !0; } (r & gt) !== 0 && // During time traveling we don't want to reset the status so that // traversal of the graph in the other batches still happens zr === null && Tr(e, Lr); } return !1; } function qd(e, r, t = !0) { var n = e.reactions; if (n !== null && !(Wr != null && Wr.includes(e))) for (var a = 0; a < n.length; a++) { var i = n[a]; (i.f & jr) !== 0 ? qd( /** @type {Derived} */ i, r, !1 ) : r === i && (t ? Tr(i, Yr) : (i.f & Lr) !== 0 && Tr(i, Gt), on( /** @type {Effect} */ i )); } } function Fd(e) { var f; var r = Vr, t = rt, n = lt, a = Ve, i = Wr, s = tr, l = kt, c = Yn, u = e.f; Vr = /** @type {null | Value[]} */ null, rt = 0, lt = null, Ve = (u & (sn | Jn)) === 0 ? e : null, Wr = null, xa(e.ctx), kt = !1, Yn = ++ao, e.ac !== null && (Ma(() => { e.ac.abort(ua); }), e.ac = null); try { e.f |= As; var d = ( /** @type {Function} */ e.fn ), p = d(), g = e.deps; if (Vr !== null) { var _; if (oi(e, rt), g !== null && rt > 0) for (g.length = rt + Vr.length, _ = 0; _ < Vr.length; _++) g[rt + _] = Vr[_]; else e.deps = g = Vr; if (vl() && (e.f & gt) !== 0) for (_ = rt; _ < g.length; _++) ((f = g[_]).reactions ?? (f.reactions = [])).push(e); } else g !== null && rt < g.length && (oi(e, rt), g.length = rt); if (Fa() && lt !== null && !kt && g !== null && (e.f & (jr | Gt | Yr)) === 0) for (_ = 0; _ < /** @type {Source[]} */ lt.length; _++) qd( lt[_], /** @type {Effect} */ e ); return a !== null && a !== e && (ao++, lt !== null && (n === null ? n = lt : n.push(.../** @type {Source[]} */ lt))), (e.f & yn) !== 0 && (e.f ^= yn), p; } catch (v) { return ed(v); } finally { e.f ^= As, Vr = r, rt = t, lt = n, Ve = a, Wr = i, xa(s), kt = l, Yn = c; } } function Og(e, r) { let t = r.reactions; if (t !== null) { var n = Y_.call(t, e); if (n !== -1) { var a = t.length - 1; a === 0 ? t = r.reactions = null : (t[n] = t[a], t.pop()); } } if (t === null && (r.f & jr) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps` // allows us to skip the expensive work of disconnecting and immediately reconnecting it (Vr === null || !Vr.includes(r))) { var i = ( /** @type {Derived} */ r ); (i.f & gt) !== 0 && (i.f ^= gt, i.f &= -32769), ml(i), dd(i), oi(i, 0); } } function oi(e, r) { var t = e.deps; if (t !== null) for (var n = r; n < t.length; n++) Og(e, t[n]); } function Ia(e) { var r = e.f; if ((r & tn) === 0) { Tr(e, Lr); var t = Xe, n = Wn; Xe = e, Wn = !0; try { (r & (Yt | dl)) !== 0 ? Mg(e) : Pd(e), wd(e); var a = Fd(e); e.teardown = typeof a == "function" ? a : null, e.wv = Dd; var i; Ds && cg && (e.f & Yr) !== 0 && e.deps; } finally { Wn = n, Xe = t; } } } async function Lg() { await Promise.resolve(), gg(); } function o(e) { var r = e.f, t = (r & jr) !== 0; if (Ve !== null && !kt) { var n = Xe !== null && (Xe.f & tn) !== 0; if (!n && !(Wr != null && Wr.includes(e))) { var a = Ve.deps; if ((Ve.f & As) !== 0) e.rv < ao && (e.rv = ao, Vr === null && a !== null && a[rt] === e ? rt++ : Vr === null ? Vr = [e] : Vr.includes(e) || Vr.push(e)); else { (Ve.deps ?? (Ve.deps = [])).push(e); var i = e.reactions; i === null ? e.reactions = [Ve] : i.includes(Ve) || i.push(Ve); } } } if (kn && bn.has(e)) return bn.get(e); if (t) { var s = ( /** @type {Derived} */ e ); if (kn) { var l = s.v; return ((s.f & Lr) === 0 && s.reactions !== null || zd(s)) && (l = hl(s)), bn.set(s, l), l; } var c = (s.f & gt) === 0 && !kt && Ve !== null && (Wn || (Ve.f & gt) !== 0), u = s.deps === null; La(s) && (c && (s.f |= gt), pd(s)), c && !u && Md(s); } if (zr != null && zr.has(e)) return zr.get(e); if ((e.f & yn) !== 0) throw e.v; return e.v; } function Md(e) { if (e.deps !== null) { e.f |= gt; for (const r of e.deps) (r.reactions ?? (r.reactions = [])).push(e), (r.f & jr) !== 0 && (r.f & gt) === 0 && Md( /** @type {Derived} */ r ); } } function zd(e) { if (e.v === Cr) return !0; if (e.deps === null) return !1; for (const r of e.deps) if (bn.has(r) || (r.f & jr) !== 0 && zd( /** @type {Derived} */ r )) return !0; return !1; } function Ne(e) { var r = kt; try { return kt = !0, e(); } finally { kt = r; } } function Ng(e, r) { var t = {}; for (var n in e) r.includes(n) || (t[n] = e[n]); for (var a of Object.getOwnPropertySymbols(e)) Object.propertyIsEnumerable.call(e, a) && !r.includes(a) && (t[a] = e[a]); return t; } function Re(e) { if (!(typeof e != "object" || !e || e instanceof EventTarget)) { if (Bt in e) Ns(e); else if (!Array.isArray(e)) for (let r in e) { const t = e[r]; typeof t == "object" && t && Bt in t && Ns(t); } } } function Ns(e, r = /* @__PURE__ */ new Set()) { if (typeof e == "object" && e !== null && // We don't want to traverse DOM elements !(e instanceof EventTarget) && !r.has(e)) { r.add(e), e instanceof Date && e.getTime(); for (let n in e) try { Ns(e[n], r); } catch { } const t = ul(e); if (t !== Object.prototype && t !== Array.prototype && t !== Map.prototype && t !== Set.prototype && t !== Date.prototype) { const n = Wu(t); for (let a in n) { const i = n[a].get; if (i) try { i.call(e); } catch { } } } } } const Od = /* @__PURE__ */ new Set(), js = /* @__PURE__ */ new Set(); function kl(e, r, t, n = {}) { function a(i) { if (n.capture || Ka.call(r, i), !i.cancelBubble) return Ma(() => t == null ? void 0 : t.call(this, i)); } return e.startsWith("pointer") || e.startsWith("touch") || e === "wheel" ? En(() => { r.addEventListener(e, a, n); }) : r.addEventListener(e, a, n), a; } function jg(e, r, t, n = {}) { var a = kl(r, e, t, n); return () => { e.removeEventListener(r, a, n); }; } function Dr(e, r, t, n, a) { var i = { capture: n, passive: a }, s = kl(e, r, t, i); (r === document.body || // @ts-ignore r === window || // @ts-ignore r === document || // Firefox has quirky behavior, it can happen that we still get "canplay" events when the element is already removed r instanceof HTMLMediaElement) && za(() => { r.removeEventListener(e, s, i); }); } function Sn(e) { for (var r = 0; r < e.length;