tempest.games 0.2.77 → 0.2.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/app/assets/{index-B3RQO18a.js → index-DbvMRLrQ.js} +5 -5
- package/app/index.html +1 -1
- package/bin/backend.bun.js +94 -93
- package/bin/backend.worker.tribunal.bun.js +87 -87
- package/bin/frontend.bun.js +83 -83
- package/bin/setup-db.bun.js +52 -52
- package/package.json +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function yk(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in t)){const u=Object.getOwnPropertyDescriptor(r,a);u&&Object.defineProperty(t,a,u.get?u:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(a){if(a.ep)return;a.ep=!0;const u=n(a);fetch(a.href,u)}})();function gk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Jh={exports:{}},Fa={};var TS;function bk(){if(TS)return Fa;TS=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,a,u){var c=null;if(u!==void 0&&(c=""+u),a.key!==void 0&&(c=""+a.key),"key"in a){u={};for(var f in a)f!=="key"&&(u[f]=a[f])}else u=a;return a=u.ref,{$$typeof:t,type:r,key:c,ref:a!==void 0?a:null,props:u}}return Fa.Fragment=e,Fa.jsx=n,Fa.jsxs=n,Fa}var AS;function vk(){return AS||(AS=1,Jh.exports=bk()),Jh.exports}var F=vk();function ft(t){return ff(Jt.STORE,t,void 0)}function Sk(t){return uy(Jt.STORE,t,void 0)}function wk(t){return ey(Jt.STORE,t)}function nt(...t){return An(Jt.STORE,...t)}function xk(t){return hM(Jt.STORE,t)}function Tk(t,e){return mM(Jt.STORE,t)}const Kr={atom_family:"atom family",atom:"atom",continuity:"continuity",key:"key",mutable_atom_family:"atom family [m]",mutable_atom:"atom [m]",readonly_held_selector_family:"selector family [h]",readonly_held_selector:"selector [h]",readonly_pure_selector_family:"selector family",readonly_pure_selector:"selector",state:"state",timeline:"timeline",transaction:"transaction",unknown:"unknown",writable_held_selector_family:"selector family [wh]",writable_held_selector:"selector [wh]",writable_pure_selector_family:"selector family [w]",writable_pure_selector:"selector [w]"},Xh=t=>(e,n,r,a,...u)=>{console[t](`${e} ${Kr[n]} \`${r}\` ${a}`,...u)},Ak={error:Xh("error"),info:Xh("info"),warn:Xh("warn")};var Ek=class{logLevel;filter;logger;constructor(t,e,n=Ak){this.logLevel=t,this.filter=e,this.logger=n}error=(...t)=>{if(this.logLevel!==null){const e=this.filter?.(...t)??!0;e===!0?this.logger.error(...t):e&&this.logger.error(...e)}};info=(...t)=>{if(this.logLevel==="info"){const e=this.filter?.(...t)??!0;e===!0?this.logger.info(...t):e&&this.logger.info(...e)}};warn=(...t)=>{if(this.logLevel!=="error"&&this.logLevel!==null){const e=this.filter?.(...t)??!0;e===!0?this.logger.warn(...t):e&&this.logger.warn(...e)}}};function Sc(t,e){return[t,e].sort().join("")}function Ok(t){if(typeof t!="string")return null;const[e,n]=t.split("==");if(!n)return null;const r=e.slice(4),[a,u]=n.split("++");return r&&a&&u?[r,a,u]:null}function Wi(t){return rT(Jt.STORE,t)}function _k(t){return eM(Jt.STORE,t)}function De(...t){Lt(Jt.STORE,...t)}function Rk(t,e,n=af()){return cM(Jt.STORE,t,e,n)}function Ck(t){return Xx(Jt.STORE,t)}function kk(t,e=af()){return Jm(Jt.STORE,t,e)}function Mk(t){return Object.entries(t)}function qr(t){return JSON.parse(t)}const zt=t=>JSON.stringify(t);function Dk(t){const e={};let n=0;for(const r of t)e[r]=n,e[n]=r,++n;return e}const zx="",Lx="",Vx="",Ux="",ES=t=>{switch(typeof t){case"string":return Vx+t;case"number":return Ux+t;case"boolean":return zx+ +t;case"object":return Lx}},OS=t=>{switch(t[0]){case Vx:return t.slice(1);case Ux:return+t.slice(1);case zx:return t.slice(1)==="1";case Lx:return null}},_S=Dk(["add","delete","clear"]);var Kx=class Xa extends Set{mode="record";subject=new We;constructor(e){super(e)}READONLY_VIEW=this;toJSON(){return[...this]}static fromJSON(e){return new Xa(e)}add(e){const n=super.add(e);return this.mode==="record"&&this.emit({type:"add",value:e}),n}clear(){const e=this.mode==="record"?[...this]:null;super.clear(),e&&this.emit({type:"clear",values:e})}delete(e){const n=super.delete(e);return this.mode==="record"&&this.emit({type:"delete",value:e}),n}subscribe(e,n){return this.subject.subscribe(e,n)}emit(e){this.subject.next(Xa.packUpdate(e))}do(e){this.mode="playback";const n=Xa.unpackUpdate(e);switch(n.type){case"add":this.add(n.value);break;case"delete":this.delete(n.value);break;case"clear":this.clear()}return this.mode="record",null}undo(e){const n=Xa.unpackUpdate(e);switch(this.mode="playback",n.type){case"add":this.delete(n.value);break;case"delete":this.add(n.value);break;case"clear":{const r=n.values;for(const a of r)this.add(a)}}return this.mode="record",null}static packUpdate(e){const n=_S[e.type]+"";return e.type==="clear"?n+e.values.map(ES).join(""):n+ES(e.value)}static unpackUpdate(e){const[n,r]=e.split(""),a=_S[n];return a==="clear"?{type:"clear",values:r.split("").map(OS)}:{type:a,value:OS(r)}}};function af(t=Math.random){return t().toString(36).slice(2)}function Re(t){for(;t.child!==null;)t=t.child;return t}function Ym(t){for(;t.parent!==null;)t=t.parent;return t}const Nk=/^\[object (?:Async|Generator|AsyncGenerator)?Function\]$/;function Br(t){const e=Object.prototype.toString.call(t);return Nk.test(e)}function RS(t,e){return Br(t)?t(e):t}var Kp=class extends Promise{fate;resolve;reject;done=!1;constructor(t){let e,n;super((r,a)=>{e=r,n=a}),this.resolve=e,this.reject=n,this.use(t instanceof Promise?t:new Promise(t))}pass(t,e){t===this.fate&&(this.resolve(e),this.done=!0)}fail(t,e){t===this.fate&&(this.reject(e),this.done=!0)}use(t){if(this!==t)if(t instanceof Promise){const e=t;this.fate=e,e.then(n=>{this.pass(e,n)},n=>{this.fail(e,n)})}else this.resolve(t),this.fate=void 0}},We=class{Subscriber;subscribers=new Map;subscribe(t,e){return this.subscribers.set(t,e),()=>{this.unsubscribe(t)}}unsubscribe(t){this.subscribers.delete(t)}next(t){const e=this.subscribers.values();for(const n of e)n(t)}},$k=class extends We{state;constructor(t){super(),this.state=t}next(t){this.state=t,super.next(t)}},jk=class qx{_buffer;_index=0;constructor(e){let n;typeof e=="number"?n=e:n=e.length,this._buffer=Array.from({length:n})}get buffer(){return this._buffer}get index(){return this._index}add(e){this._buffer[this._index]=e,this._index=(this._index+1)%this._buffer.length}copy(){const e=new qx([...this._buffer]);return e._index=this._index,e}};function zr(t){const e={key:t.key,type:t.type};return"family"in t&&(e.family=t.family),e}var Xn=class extends Map{deleted=new Set;changed=new Set;source;constructor(t){super(),this.source=t}get(t){if(super.has(t))return super.get(t);if(!this.deleted.has(t)&&this.source.has(t))return this.source.get(t)}set(t,e){return this.deleted.delete(t),this.source.has(t)&&this.changed.add(t),super.set(t,e)}hasOwn(t){return super.has(t)}has(t){return!this.deleted.has(t)&&(super.has(t)||this.source.has(t))}delete(t){return this.source.has(t)&&(this.deleted.add(t),this.changed.delete(t)),super.delete(t)}clear(){this.deleted=new Set(this.source.keys()),this.changed.clear(),super.clear()}*[Symbol.iterator](){yield*super[Symbol.iterator]();for(const[t,e]of this.source)!this.deleted.has(t)&&!this.changed.has(t)&&(yield[t,e])}*entries(){yield*this[Symbol.iterator]()}*keys(){yield*super.keys();for(const t of this.source.keys())!this.deleted.has(t)&&!this.changed.has(t)&&(yield t)}*values(){for(const[,t]of this[Symbol.iterator]())yield t}forEach(t){for(const[e,n]of this[Symbol.iterator]())t(n,e,this)}get size(){return super.size+this.source.size-this.changed.size-this.deleted.size}},Px=class extends Set{deleted=new Set;source;constructor(t){super(),this.source=t}add(t){return this.source.has(t)?(this.deleted.delete(t),this):super.add(t)}hasOwn(t){return super.has(t)}has(t){return!this.deleted.has(t)&&(super.has(t)||this.source.has(t))}delete(t){return this.source.has(t)?(this.deleted.add(t),!0):super.delete(t)}clear(){this.deleted=new Set(this.source),super.clear()}*[Symbol.iterator](){yield*super[Symbol.iterator]();for(const t of this.source)this.deleted.has(t)||(yield t)}*iterateOwn(){yield*super[Symbol.iterator]()}get size(){return super.size+this.source.size-this.deleted.size}},Bk=class extends Map{deleted=new Set;source;constructor(t){super(),this.source=t}get(t){if(super.has(t))return super.get(t);if(!this.deleted.has(t)&&this.source.has(t)){const e=new Px(this.source.get(t));return super.set(t,e),e}}set(t,e){return this.deleted.delete(t),super.set(t,e)}has(t){return!this.deleted.has(t)&&(super.has(t)||this.source.has(t))}delete(t){return this.deleted.add(t),super.delete(t)}},qi=class Ix{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(e,n)=>`${e}:${n}`;warn;getRelatedKeys(e){return this.relations.get(e)}addRelation(e,n){let r=this.relations.get(e),a=this.relations.get(n);r?r.add(n):(r=new Set([n]),this.relations.set(e,r)),a?a.add(e):(a=new Set([e]),this.relations.set(n,a))}deleteRelation(e,n){const r=this.relations.get(e);if(r){r.delete(n),r.size===0&&this.relations.delete(e);const a=this.relations.get(n);a&&(a.delete(e),a.size===0&&this.relations.delete(n))}}replaceRelationsUnsafely(e,n){this.relations.set(e,new Set(n));for(const r of n){const a=new Set().add(e);this.relations.set(r,a)}}replaceRelationsSafely(e,n){const r=this.relations.get(e);let a=this.isAType?.(e)?e:void 0,u=a===void 0?e:void 0;if(r)for(const c of r){a??=c,u??=c;const f=this.relations.get(c);f&&(f.size===1?this.relations.delete(c):f.delete(e),this.contents.delete(this.makeContentKey(a,u)))}this.relations.set(e,new Set(n));for(const c of n){let f=this.relations.get(c);f?f.add(e):(f=new Set().add(e),this.relations.set(c,f))}}getContentInternal(e){return this.contents.get(e)}setContent(e,n){this.contents.set(e,n)}deleteContent(e){this.contents.delete(e)}constructor(e,n){if(this.a=e.between[0],this.b=e.between[1],this.cardinality=e.cardinality,this.isAType=n?.isAType??null,this.isBType=n?.isBType??null,this.isContent=n?.isContent??null,n?.makeContentKey&&(this.makeContentKey=n.makeContentKey),!n?.externalStore){const r=n?.source;r===void 0&&(this.relations=new Map(e.relations?.map(([a,u])=>[a,new Set(u)])),this.contents=new Map(e.contents)),r&&(this.relations=new Bk(r.relations),this.contents=new Xn(r.contents))}if(n?.externalStore){const r=n.externalStore;this.has=(a,u)=>r.has(a,u),this.addRelation=(a,u)=>{r.addRelation(a,u)},this.deleteRelation=(a,u)=>{r.deleteRelation(a,u)},this.replaceRelationsSafely=(a,u)=>{r.replaceRelationsSafely(a,u)},this.replaceRelationsUnsafely=(a,u)=>{r.replaceRelationsUnsafely(a,u)},this.getRelatedKeys=(a=>r.getRelatedKeys(a)),r.getContent&&(this.getContentInternal=a=>r.getContent(a),this.setContent=(a,u)=>{r.setContent(a,u)},this.deleteContent=a=>{r.deleteContent(a)});for(const[a,u]of e.relations??[]){let c=this.isAType?.(a)?a:void 0,f=c===void 0?a:void 0;for(const h of u)c??=h,f??=h,this.addRelation(c,f)}for(const[a,u]of e.contents??[])this.setContent(a,u)}n?.warn&&(this.warn=n.warn)}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([e,n])=>[e,[...n]]),contents:[...this.contents.entries()]}}set(...e){let n,r,a;switch(e.length){case 1:{const u=e[0];n=u[this.a],r=u[this.b],a=void 0;break}case 2:{const u=e[0];typeof u=="string"?[n,r]=e:(n=u[this.a],r=u[this.b],a=e[1]);break}default:n=e[0],r=e[1],a=e[2];break}switch(this.cardinality){case"1:1":{const u=this.getRelatedKey(n);u&&u!==r&&this.delete(n,u)}case"1:n":{const u=this.getRelatedKey(r);u&&u!==n&&this.delete(u,r)}break}if(a){const u=this.makeContentKey(n,r);this.setContent(u,a)}return this.addRelation(n,r),this}delete(e,n){n=typeof n=="string"?n:e[this.b];const r=typeof e=="string"?e:e[this.a];if(r===void 0&&typeof n=="string"){const a=this.getRelatedKeys(n);if(a)for(const u of a)this.delete(u,n)}else if(typeof r=="string"&&n===void 0){const a=this.getRelatedKeys(r);if(a)for(const u of a)this.delete(r,u)}else if(typeof r=="string"&&typeof n=="string"){this.deleteRelation(r,n);const a=this.makeContentKey(r,n);this.deleteContent(a)}return this}getRelatedKey(e){const n=this.getRelatedKeys(e);if(n){n.size>1&&this.warn?.(`${n.size} related keys were found for key "${e}": (${[...n].map(a=>`"${a}"`).join(", ")}). Only one related key was expected.`);let r;for(const a of n){r=a;break}return r}}replaceRelations(e,n,r){const a=!Array.isArray(n),u=a?Object.keys(n):n;if(r?.reckless?this.replaceRelationsUnsafely(e,u):this.replaceRelationsSafely(e,u),a)for(const c of u){const f=this.makeContentKey(e,c),h=n[c];this.setContent(f,h)}return this}getContent(e,n){const r=this.makeContentKey(e,n);return this.getContentInternal(r)}getRelationEntries(e){const n=e[this.a],r=e[this.b];if(n!==void 0&&r===void 0){const a=this.getRelatedKeys(n);if(a)return[...a].map(u=>[u,this.getContent(n,u)])}if(n===void 0&&r!==void 0){const a=this.getRelatedKeys(r);if(a)return[...a].map(u=>[u,this.getContent(u,r)])}return[]}has(e,n){return n?this.getRelatedKeys(e)?.has(n)??!1:this.relations.has(e)}overlay(){const e={source:this,makeContentKey:this.makeContentKey};return this.isAType&&(e.isAType=this.isAType),this.isBType&&(e.isBType=this.isBType),this.isContent&&(e.isContent=this.isContent),this.warn&&(e.warn=this.warn),new Ix({between:[this.a,this.b],cardinality:this.cardinality},e)}incorporate(e){const{relations:n,contents:r}=e;for(const[a,u]of n)if(u instanceof Px){const{source:c}=u;for(const f of u.iterateOwn())c.add(f)}else this.relations.set(a,u);for(const a of n.deleted)this.relations.delete(a);for(const[a,u]of r)this.contents.set(a,u);for(const a of r.deleted)this.contents.delete(a)}};function zk(t){return t.startsWith("🔍 ")}const Lk=t=>{t.logger.info("🪂","transaction",t.transactionMeta.update.token.key,"Aborting transaction"),t.parent.child=null};function Jm(t,e,n){return(...r)=>ct(t,e).run(r,n)}function Vk(t,e,n){const{token:r,update:{newValue:a,oldValue:u}}=e;Lt(t,r,n==="newValue"?a:u)}function Uk(t){const{stack:e}=t;return e?`
|
|
1
|
+
function yk(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in t)){const u=Object.getOwnPropertyDescriptor(r,a);u&&Object.defineProperty(t,a,u.get?u:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(a){if(a.ep)return;a.ep=!0;const u=n(a);fetch(a.href,u)}})();function gk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Jh={exports:{}},Fa={};var TS;function bk(){if(TS)return Fa;TS=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,a,u){var c=null;if(u!==void 0&&(c=""+u),a.key!==void 0&&(c=""+a.key),"key"in a){u={};for(var f in a)f!=="key"&&(u[f]=a[f])}else u=a;return a=u.ref,{$$typeof:t,type:r,key:c,ref:a!==void 0?a:null,props:u}}return Fa.Fragment=e,Fa.jsx=n,Fa.jsxs=n,Fa}var AS;function vk(){return AS||(AS=1,Jh.exports=bk()),Jh.exports}var F=vk();function ft(t){return ff(Jt.STORE,t,void 0)}function Sk(t){return uy(Jt.STORE,t,void 0)}function wk(t){return ey(Jt.STORE,t)}function nt(...t){return An(Jt.STORE,...t)}function xk(t){return hM(Jt.STORE,t)}function Tk(t,e){return mM(Jt.STORE,t)}const Kr={atom_family:"atom family",atom:"atom",continuity:"continuity",key:"key",mutable_atom_family:"atom family [m]",mutable_atom:"atom [m]",readonly_held_selector_family:"selector family [h]",readonly_held_selector:"selector [h]",readonly_pure_selector_family:"selector family",readonly_pure_selector:"selector",state:"state",timeline:"timeline",transaction:"transaction",unknown:"unknown",writable_held_selector_family:"selector family [wh]",writable_held_selector:"selector [wh]",writable_pure_selector_family:"selector family [w]",writable_pure_selector:"selector [w]"},Xh=t=>(e,n,r,a,...u)=>{console[t](`${e} ${Kr[n]} \`${r}\` ${a}`,...u)},Ak={error:Xh("error"),info:Xh("info"),warn:Xh("warn")};var Ek=class{logLevel;filter;logger;constructor(t,e,n=Ak){this.logLevel=t,this.filter=e,this.logger=n}error=(...t)=>{if(this.logLevel!==null){const e=this.filter?.(...t)??!0;e===!0?this.logger.error(...t):e&&this.logger.error(...e)}};info=(...t)=>{if(this.logLevel==="info"){const e=this.filter?.(...t)??!0;e===!0?this.logger.info(...t):e&&this.logger.info(...e)}};warn=(...t)=>{if(this.logLevel!=="error"&&this.logLevel!==null){const e=this.filter?.(...t)??!0;e===!0?this.logger.warn(...t):e&&this.logger.warn(...e)}}};function Sc(t,e){return[t,e].sort().join("")}function Ok(t){if(typeof t!="string")return null;const[e,n]=t.split("==");if(!n)return null;const r=e.slice(4),[a,u]=n.split("++");return r&&a&&u?[r,a,u]:null}function Wi(t){return rT(Jt.STORE,t)}function _k(t){return eM(Jt.STORE,t)}function De(...t){Lt(Jt.STORE,...t)}function Rk(t,e,n=af()){return cM(Jt.STORE,t,e,n)}function Ck(t){return X1(Jt.STORE,t)}function kk(t,e=af()){return Jm(Jt.STORE,t,e)}function Mk(t){return Object.entries(t)}function qr(t){return JSON.parse(t)}const zt=t=>JSON.stringify(t);function Dk(t){const e={};let n=0;for(const r of t)e[r]=n,e[n]=r,++n;return e}const z1="",L1="",V1="",U1="",ES=t=>{switch(typeof t){case"string":return V1+t;case"number":return U1+t;case"boolean":return z1+ +t;case"object":return L1}},OS=t=>{switch(t[0]){case V1:return t.slice(1);case U1:return+t.slice(1);case z1:return t.slice(1)==="1";case L1:return null}},_S=Dk(["add","delete","clear"]);var K1=class Xa extends Set{mode="record";subject=new We;constructor(e){super(e)}READONLY_VIEW=this;toJSON(){return[...this]}static fromJSON(e){return new Xa(e)}add(e){const n=super.add(e);return this.mode==="record"&&this.emit({type:"add",value:e}),n}clear(){const e=this.mode==="record"?[...this]:null;super.clear(),e&&this.emit({type:"clear",values:e})}delete(e){const n=super.delete(e);return this.mode==="record"&&this.emit({type:"delete",value:e}),n}subscribe(e,n){return this.subject.subscribe(e,n)}emit(e){this.subject.next(Xa.packUpdate(e))}do(e){this.mode="playback";const n=Xa.unpackUpdate(e);switch(n.type){case"add":this.add(n.value);break;case"delete":this.delete(n.value);break;case"clear":this.clear()}return this.mode="record",null}undo(e){const n=Xa.unpackUpdate(e);switch(this.mode="playback",n.type){case"add":this.delete(n.value);break;case"delete":this.add(n.value);break;case"clear":{const r=n.values;for(const a of r)this.add(a)}}return this.mode="record",null}static packUpdate(e){const n=_S[e.type]+"";return e.type==="clear"?n+e.values.map(ES).join(""):n+ES(e.value)}static unpackUpdate(e){const[n,r]=e.split(""),a=_S[n];return a==="clear"?{type:"clear",values:r.split("").map(OS)}:{type:a,value:OS(r)}}};function af(t=Math.random){return t().toString(36).slice(2)}function Re(t){for(;t.child!==null;)t=t.child;return t}function Ym(t){for(;t.parent!==null;)t=t.parent;return t}const Nk=/^\[object (?:Async|Generator|AsyncGenerator)?Function\]$/;function Br(t){const e=Object.prototype.toString.call(t);return Nk.test(e)}function RS(t,e){return Br(t)?t(e):t}var Kp=class extends Promise{fate;resolve;reject;done=!1;constructor(t){let e,n;super((r,a)=>{e=r,n=a}),this.resolve=e,this.reject=n,this.use(t instanceof Promise?t:new Promise(t))}pass(t,e){t===this.fate&&(this.resolve(e),this.done=!0)}fail(t,e){t===this.fate&&(this.reject(e),this.done=!0)}use(t){if(this!==t)if(t instanceof Promise){const e=t;this.fate=e,e.then(n=>{this.pass(e,n)},n=>{this.fail(e,n)})}else this.resolve(t),this.fate=void 0}},We=class{Subscriber;subscribers=new Map;subscribe(t,e){return this.subscribers.set(t,e),()=>{this.unsubscribe(t)}}unsubscribe(t){this.subscribers.delete(t)}next(t){const e=this.subscribers.values();for(const n of e)n(t)}},$k=class extends We{state;constructor(t){super(),this.state=t}next(t){this.state=t,super.next(t)}},jk=class q1{_buffer;_index=0;constructor(e){let n;typeof e=="number"?n=e:n=e.length,this._buffer=Array.from({length:n})}get buffer(){return this._buffer}get index(){return this._index}add(e){this._buffer[this._index]=e,this._index=(this._index+1)%this._buffer.length}copy(){const e=new q1([...this._buffer]);return e._index=this._index,e}};function zr(t){const e={key:t.key,type:t.type};return"family"in t&&(e.family=t.family),e}var Xn=class extends Map{deleted=new Set;changed=new Set;source;constructor(t){super(),this.source=t}get(t){if(super.has(t))return super.get(t);if(!this.deleted.has(t)&&this.source.has(t))return this.source.get(t)}set(t,e){return this.deleted.delete(t),this.source.has(t)&&this.changed.add(t),super.set(t,e)}hasOwn(t){return super.has(t)}has(t){return!this.deleted.has(t)&&(super.has(t)||this.source.has(t))}delete(t){return this.source.has(t)&&(this.deleted.add(t),this.changed.delete(t)),super.delete(t)}clear(){this.deleted=new Set(this.source.keys()),this.changed.clear(),super.clear()}*[Symbol.iterator](){yield*super[Symbol.iterator]();for(const[t,e]of this.source)!this.deleted.has(t)&&!this.changed.has(t)&&(yield[t,e])}*entries(){yield*this[Symbol.iterator]()}*keys(){yield*super.keys();for(const t of this.source.keys())!this.deleted.has(t)&&!this.changed.has(t)&&(yield t)}*values(){for(const[,t]of this[Symbol.iterator]())yield t}forEach(t){for(const[e,n]of this[Symbol.iterator]())t(n,e,this)}get size(){return super.size+this.source.size-this.changed.size-this.deleted.size}},P1=class extends Set{deleted=new Set;source;constructor(t){super(),this.source=t}add(t){return this.source.has(t)?(this.deleted.delete(t),this):super.add(t)}hasOwn(t){return super.has(t)}has(t){return!this.deleted.has(t)&&(super.has(t)||this.source.has(t))}delete(t){return this.source.has(t)?(this.deleted.add(t),!0):super.delete(t)}clear(){this.deleted=new Set(this.source),super.clear()}*[Symbol.iterator](){yield*super[Symbol.iterator]();for(const t of this.source)this.deleted.has(t)||(yield t)}*iterateOwn(){yield*super[Symbol.iterator]()}get size(){return super.size+this.source.size-this.deleted.size}},Bk=class extends Map{deleted=new Set;source;constructor(t){super(),this.source=t}get(t){if(super.has(t))return super.get(t);if(!this.deleted.has(t)&&this.source.has(t)){const e=new P1(this.source.get(t));return super.set(t,e),e}}set(t,e){return this.deleted.delete(t),super.set(t,e)}has(t){return!this.deleted.has(t)&&(super.has(t)||this.source.has(t))}delete(t){return this.deleted.add(t),super.delete(t)}},qi=class I1{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(e,n)=>`${e}:${n}`;warn;getRelatedKeys(e){return this.relations.get(e)}addRelation(e,n){let r=this.relations.get(e),a=this.relations.get(n);r?r.add(n):(r=new Set([n]),this.relations.set(e,r)),a?a.add(e):(a=new Set([e]),this.relations.set(n,a))}deleteRelation(e,n){const r=this.relations.get(e);if(r){r.delete(n),r.size===0&&this.relations.delete(e);const a=this.relations.get(n);a&&(a.delete(e),a.size===0&&this.relations.delete(n))}}replaceRelationsUnsafely(e,n){this.relations.set(e,new Set(n));for(const r of n){const a=new Set().add(e);this.relations.set(r,a)}}replaceRelationsSafely(e,n){const r=this.relations.get(e);let a=this.isAType?.(e)?e:void 0,u=a===void 0?e:void 0;if(r)for(const c of r){a??=c,u??=c;const f=this.relations.get(c);f&&(f.size===1?this.relations.delete(c):f.delete(e),this.contents.delete(this.makeContentKey(a,u)))}this.relations.set(e,new Set(n));for(const c of n){let f=this.relations.get(c);f?f.add(e):(f=new Set().add(e),this.relations.set(c,f))}}getContentInternal(e){return this.contents.get(e)}setContent(e,n){this.contents.set(e,n)}deleteContent(e){this.contents.delete(e)}constructor(e,n){if(this.a=e.between[0],this.b=e.between[1],this.cardinality=e.cardinality,this.isAType=n?.isAType??null,this.isBType=n?.isBType??null,this.isContent=n?.isContent??null,n?.makeContentKey&&(this.makeContentKey=n.makeContentKey),!n?.externalStore){const r=n?.source;r===void 0&&(this.relations=new Map(e.relations?.map(([a,u])=>[a,new Set(u)])),this.contents=new Map(e.contents)),r&&(this.relations=new Bk(r.relations),this.contents=new Xn(r.contents))}if(n?.externalStore){const r=n.externalStore;this.has=(a,u)=>r.has(a,u),this.addRelation=(a,u)=>{r.addRelation(a,u)},this.deleteRelation=(a,u)=>{r.deleteRelation(a,u)},this.replaceRelationsSafely=(a,u)=>{r.replaceRelationsSafely(a,u)},this.replaceRelationsUnsafely=(a,u)=>{r.replaceRelationsUnsafely(a,u)},this.getRelatedKeys=(a=>r.getRelatedKeys(a)),r.getContent&&(this.getContentInternal=a=>r.getContent(a),this.setContent=(a,u)=>{r.setContent(a,u)},this.deleteContent=a=>{r.deleteContent(a)});for(const[a,u]of e.relations??[]){let c=this.isAType?.(a)?a:void 0,f=c===void 0?a:void 0;for(const h of u)c??=h,f??=h,this.addRelation(c,f)}for(const[a,u]of e.contents??[])this.setContent(a,u)}n?.warn&&(this.warn=n.warn)}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([e,n])=>[e,[...n]]),contents:[...this.contents.entries()]}}set(...e){let n,r,a;switch(e.length){case 1:{const u=e[0];n=u[this.a],r=u[this.b],a=void 0;break}case 2:{const u=e[0];typeof u=="string"?[n,r]=e:(n=u[this.a],r=u[this.b],a=e[1]);break}default:n=e[0],r=e[1],a=e[2];break}switch(this.cardinality){case"1:1":{const u=this.getRelatedKey(n);u&&u!==r&&this.delete(n,u)}case"1:n":{const u=this.getRelatedKey(r);u&&u!==n&&this.delete(u,r)}break}if(a){const u=this.makeContentKey(n,r);this.setContent(u,a)}return this.addRelation(n,r),this}delete(e,n){n=typeof n=="string"?n:e[this.b];const r=typeof e=="string"?e:e[this.a];if(r===void 0&&typeof n=="string"){const a=this.getRelatedKeys(n);if(a)for(const u of a)this.delete(u,n)}else if(typeof r=="string"&&n===void 0){const a=this.getRelatedKeys(r);if(a)for(const u of a)this.delete(r,u)}else if(typeof r=="string"&&typeof n=="string"){this.deleteRelation(r,n);const a=this.makeContentKey(r,n);this.deleteContent(a)}return this}getRelatedKey(e){const n=this.getRelatedKeys(e);if(n){n.size>1&&this.warn?.(`${n.size} related keys were found for key "${e}": (${[...n].map(a=>`"${a}"`).join(", ")}). Only one related key was expected.`);let r;for(const a of n){r=a;break}return r}}replaceRelations(e,n,r){const a=!Array.isArray(n),u=a?Object.keys(n):n;if(r?.reckless?this.replaceRelationsUnsafely(e,u):this.replaceRelationsSafely(e,u),a)for(const c of u){const f=this.makeContentKey(e,c),h=n[c];this.setContent(f,h)}return this}getContent(e,n){const r=this.makeContentKey(e,n);return this.getContentInternal(r)}getRelationEntries(e){const n=e[this.a],r=e[this.b];if(n!==void 0&&r===void 0){const a=this.getRelatedKeys(n);if(a)return[...a].map(u=>[u,this.getContent(n,u)])}if(n===void 0&&r!==void 0){const a=this.getRelatedKeys(r);if(a)return[...a].map(u=>[u,this.getContent(u,r)])}return[]}has(e,n){return n?this.getRelatedKeys(e)?.has(n)??!1:this.relations.has(e)}overlay(){const e={source:this,makeContentKey:this.makeContentKey};return this.isAType&&(e.isAType=this.isAType),this.isBType&&(e.isBType=this.isBType),this.isContent&&(e.isContent=this.isContent),this.warn&&(e.warn=this.warn),new I1({between:[this.a,this.b],cardinality:this.cardinality},e)}incorporate(e){const{relations:n,contents:r}=e;for(const[a,u]of n)if(u instanceof P1){const{source:c}=u;for(const f of u.iterateOwn())c.add(f)}else this.relations.set(a,u);for(const a of n.deleted)this.relations.delete(a);for(const[a,u]of r)this.contents.set(a,u);for(const a of r.deleted)this.contents.delete(a)}};function zk(t){return t.startsWith("🔍 ")}const Lk=t=>{t.logger.info("🪂","transaction",t.transactionMeta.update.token.key,"Aborting transaction"),t.parent.child=null};function Jm(t,e,n){return(...r)=>ct(t,e).run(r,n)}function Vk(t,e,n){const{token:r,update:{newValue:a,oldValue:u}}=e;Lt(t,r,n==="newValue"?a:u)}function Uk(t){const{stack:e}=t;return e?`
|
|
2
2
|
`+e.split(`
|
|
3
3
|
`)?.slice(1)?.join(`
|
|
4
|
-
`):""}function
|
|
4
|
+
`):""}function H1(t,e,n,r="any"){const a=e,u=zt(n),c=[],f=Re(t);if(Array.isArray(a))for(const y of a){const g=zt(y);f.molecules.get(g)?t.moleculeGraph.set(g,u,{source:g}):c.push(g)}else{const y=zt(a);f.molecules.get(y)?t.moleculeGraph.set(y,u,{source:y}):c.push(y)}const h=new We;c.length===0&&f.molecules.set(u,{key:n,stringKey:u,dependsOn:r,subject:h});const m={type:"molecule_creation",key:n,provenance:a,timestamp:Date.now()};Tn(f)&&f.transactionMeta.phase==="building"?f.transactionMeta.update.subEvents.push(m):f.on.moleculeCreation.next(m);for(const y of c){const g=t.disposalTraces.buffer.find(v=>v?.key===y);t.logger.error("❌","key",n,"allocation failed:",`Could not allocate to ${y} in store "${t.config.name}".`,g?`
|
|
5
5
|
${y} was most recently disposed
|
|
6
6
|
${g.trace}`:`No previous disposal trace for ${y} was found.`)}return n}function Xm(t,e){const n=zt(e),r=t.molecules.get(n);if(!r){const v=t.disposalTraces.buffer.find(S=>S?.key===n);t.logger.error("❌","key",e,"deallocation failed:",`Could not find allocation for ${n} in store "${t.config.name}".`,v?`
|
|
7
7
|
This state was most recently deallocated
|
|
@@ -9,8 +9,8 @@ ${v.trace}`:`No previous disposal trace for ${n} was found.`);return}r.subject.n
|
|
|
9
9
|
${a} was most recently disposed
|
|
10
10
|
${g.trace}`:`No previous disposal trace for ${a} was found.`),n}const f=zt(e),h=u.molecules.get(f);if(!h){const g=t.disposalTraces.buffer.find(v=>v?.key===f);return t.logger.error("❌","key",n,"claim failed:",`Could not allocate to ${f} in store "${t.config.name}".`,g?`
|
|
11
11
|
${f} was most recently disposed
|
|
12
|
-
${g.trace}`:`No previous disposal trace for ${f} was found.`),n}const m=t.moleculeGraph.getRelationEntries({downstreamMoleculeKey:c.stringKey}).filter(([,{source:g}])=>g!==a).map(([g])=>qr(g));r&&u.moleculeGraph.delete(a),u.moleculeGraph.set({upstreamMoleculeKey:h.stringKey,downstreamMoleculeKey:c.stringKey},{source:h.stringKey});const y={type:"molecule_transfer",key:c.key,exclusive:!!r,from:m,to:[h.key],timestamp:Date.now()};return Tn(u)&&u.transactionMeta.phase==="building"&&u.transactionMeta.update.subEvents.push(y),n}function Kk(t,e,n){switch(n){case"newValue":
|
|
13
|
-
${a.trace}`:"(no previous disposal trace found)"),n.type){case"mutable_atom_family":{if(t.defaults.has(n.key))return t.defaults.get(n.key);const u=new n.class;return t.defaults.set(n.key,u),u.READONLY_VIEW}case"atom_family":{if(t.defaults.has(n.key))return t.defaults.get(n.key);const u=n.default,c=u(r);return t.defaults.set(n.key,c),c}case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if(t.defaults.has(n.key))return t.defaults.get(n.key);const u=n.default(r);return t.defaults.set(n.key,u),u}}}function jc(t,e){const{type:n,key:r,catch:a}=e;switch(n){case"readonly_pure_selector":case"writable_pure_selector":{let u;t.logger.info("🧮",n,r,"computing value");try{if(u=e.getFrom(t),u instanceof Promise)return u.catch(c=>{if(t.logger.error("💥",n,r,"rejected:",c),a){for(const f of a)if(c instanceof f)return c}throw c})}catch(c){if(t.logger.error("💥",n,r,"rejected:",c),a){for(const f of a)if(c instanceof f)return Kn(t,e,c)}throw c}return Kn(t,e,u)}case"atom":{let u;if(Br(e.default))try{u=e.default(),u instanceof Promise&&(u=u.catch(c=>{if(t.logger.error("💥",n,r,"rejected:",c),a){for(const f of a)if(c instanceof f)return c}throw c}))}catch(c){if(t.logger.error("💥",n,r,"rejected:",c),a){for(const f of a)if(c instanceof f)return u=Kn(t,e,c),t.logger.info("✨",e.type,r,"computed default",u),u}throw c}else u=e.default,t.logger.info("✨",e.type,r,"using static default",u);return Kn(t,e,u)}}}function _s(t,e,n){if(t.valueMap.has(e.key))return uT(t,e,n);t.logger.info("❔",e.type,e.key,"value not found in cache");const{key:r}=e;switch(e.type){case"readonly_held_selector":case"writable_held_selector":return t.logger.info("🧮",e.type,r,"computing value"),e.getFrom(t);case"writable_pure_selector":case"readonly_pure_selector":case"atom":return jc(t,e);case"mutable_atom":{const a=new e.class;return t.logger.info("✨",e.type,r,"created new instance",a),Kn(t,e,a)}}}function Qm(t,e){return ct(t,{key:e.family.key,type:`${e.type}_family`})}const kS={atom_family:"atom",molecule_family:"molecule",mutable_atom_family:"mutable_atom",readonly_held_selector_family:"readonly_held_selector",readonly_pure_selector_family:"readonly_pure_selector",writable_held_selector_family:"writable_held_selector",writable_pure_selector_family:"writable_pure_selector"},cl=Symbol("MUST_CREATE"),Wk=Symbol("DO_NOT_CREATE");function fl(t,e,n,r){const a=zt(r),u=e.molecules.get(a);if(!u&&e.config.lifespan==="immortal"){const{type:f,key:h}=n;return e.logger.warn("💣","key",a,"was used to mint a counterfeit token for",f,`"${h}"`),{counterfeit:!0,key:`${h}(${a})`,type:kS[f],family:{key:h,subKey:a}}}let c;if(t===cl)e.logger.info("👪",n.type,n.key,"adds member",typeof r=="string"?`\`${r}\``:r),c=n.create(r),u&&e.moleculeData.set(a,n.key);else{const{type:f,key:h}=n;return{key:`${h}(${a})`,type:kS[f],family:{key:h,subKey:a}}}return c}function Wm(t,...e){let n,r,a,u,c;if(e.length===1){if(c=e[0],"family"in c){const h=Qm(t,c);if(a=ct(t,h),u=qr(c.family.subKey),n=dl(t,h,u),"counterfeit"in c)return{token:c,family:a,subKey:u,isNew:!1};n?c=n:(r=fl(cl,t,h,u),c=r)}}else a=ct(t,e[0]),u=e[1],n=dl(t,a,u),n?c=n:(r=fl(cl,t,a,u),c=r);const f="counterfeit"in c;if(r&&f===!1&&a){let h;switch(c.type){case"readonly_pure_selector":case"readonly_held_selector":h="readable";break;case"atom":case"mutable_atom":case"writable_pure_selector":case"writable_held_selector":h="writable";break}const m={type:"state_creation",subType:h,token:c,timestamp:Date.now()};a.subject.next(m);const y=Re(t);if(c.family)if(ul(y))switch(c.type){case"atom":case"mutable_atom":t.on.atomCreation.next(c);break;case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":t.on.selectorCreation.next(c);break}else Tn(y)&&y.on.transactionApplying.state===null&&y.transactionMeta.update.subEvents.push(m)}return{token:c,family:a,subKey:u,isNew:!!r}}function An(t,...e){const{token:n,family:r,subKey:a}=Wm(t,...e);return"counterfeit"in n&&r&&a?Zx(t,n,r,a):_s(t,ct(t,n))}function dl(t,e,n){const r=zt(n),a=`${e.key}(${r})`,u=Re(t);let c;switch(e.type){case"atom_family":case"mutable_atom_family":c=u.atoms.get(a);break;case"writable_held_selector_family":case"writable_pure_selector_family":c=u.writableSelectors.get(a);break;case"readonly_held_selector_family":case"readonly_pure_selector_family":c=u.readonlySelectors.get(a);break}return c&&zr(c)}function Pr(t,e,n){const r=ct(t,e),a=dl(t,e,n);return a||fl(Wk,t,r,n)}function Bc(t,e,n){const r=e.key,a="readonly_pure_selector_family",u={key:r,type:a},c=t.families.get(r);c&&t.config.isProduction===!0&&t.logger.error("❗",a,r,`Overwriting an existing ${Kr[c.type]} "${c.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const f=new We,m={...u,create:y=>{const g=zt(y),v={key:r,subKey:g},S=`${r}(${g})`,x=Re(t),T={key:S,get:e.get(y)};return e.catch&&(T.catch=e.catch),sy(x,T,v)},internalRoles:n,subject:f,install:y=>Bc(y,e),default:y=>e.get(y)({get:((...g)=>An(t,...g)),find:((...g)=>Pr(t,...g)),json:g=>Rs(t,g)})};return t.families.set(r,m),u}function ey(t,e,n){const r={key:e.key,type:"atom_family"},a=t.families.get(e.key);a&&t.config.isProduction===!0&&t.logger.error("❗","atom_family",e.key,`Overwriting an existing ${Kr[a.type]} "${a.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const u=new We,f={...r,create:h=>{const m=zt(h),y={key:e.key,subKey:m},g=`${e.key}(${m})`,v=Re(t),S=e.default,x={key:g,default:Br(S)?()=>S(h):S};return e.effects&&(x.effects=e.effects(h)),e.catch&&(x.catch=e.catch),ff(v,x,y)},default:e.default,subject:u,install:h=>ey(h,e),internalRoles:n};return t.families.set(e.key,f),Br(e.default)===!1&&t.defaults.set(e.key,e.default),r}function Qx(t,e,n){const r=e.key,a="readonly_held_selector_family",u={key:r,type:a},c=t.families.get(r);c&&t.config.isProduction===!0&&t.logger.error("❗",a,r,`Overwriting an existing ${Kr[c.type]} "${c.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const f=new We,m={...u,create:y=>{const g=zt(y),v={key:r,subKey:g},S=`${r}(${g})`;return ry(Re(t),{key:S,const:e.const(y),get:e.get(y)},v)},internalRoles:n,subject:f,install:y=>Qx(y,e),default:e.const};return t.families.set(r,m),u}function Wx(t,e,n){const r=e.key,a="writable_held_selector_family",u={key:r,type:a},c=t.families.get(r);c&&t.config.isProduction===!0&&t.logger.error("❗",a,r,`Overwriting an existing ${Kr[c.type]} "${c.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const f=new We,m={...u,create:y=>{const g=zt(y),v={key:r,subKey:g},S=`${r}(${g})`;return oy(Re(t),{key:S,const:e.const(y),get:e.get(y),set:e.set(y)},v)},internalRoles:n,subject:f,install:y=>Wx(y,e),default:e.const};return t.families.set(r,m),u}function ty(t,e,n){const r=e.key,a="writable_pure_selector_family",u={key:r,type:a},c=t.families.get(r);c&&t.config.isProduction===!0&&t.logger.error("❗",a,r,`Overwriting an existing ${Kr[c.type]} "${c.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const f=new We,m={...u,create:y=>{const g=zt(y),v={key:r,subKey:g},S=`${r}(${g})`,x=Re(t),T={key:S,get:e.get(y),set:e.set(y)};return e.catch&&(T.catch=e.catch),ay(x,T,v)},internalRoles:n,subject:f,install:y=>ty(y,e),default:y=>e.get(y)({get:((...g)=>An(t,...g)),find:((...g)=>Pr(t,...g)),json:g=>Rs(t,g)})};return t.families.set(r,m),u}function eM(t,e){const n="set"in e,r="const"in e;return r&&n?Wx(t,e,void 0):r?Qx(t,e,void 0):n?ty(t,e):Bc(t,e)}function lf(t,...e){let n;if(e.length===1)n=e[0];else{const r=e[0],a=e[1];n=Pr(t,r,a)}try{ct(t,n)}catch{t.logger.error("❌",n.type,n.key,`could not be disposed because it was not found in the store "${t.config.name}".`);return}switch(n.type){case"atom":case"mutable_atom":dy(t,n);break;case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":lM(t,n);break}}function eT(t,e){if(t.operation.open){const n=performance.now();return t.logger.info("🚫",e.type,e.key,`deferring setState at T-${n} until setState for "${t.operation.token.key}" is done`),n}return t.operation={open:!0,done:new Set,prev:new Map,timestamp:Date.now(),token:e,subEvents:[]},t.logger.info("⭕",e.type,e.key,`operation start in store "${t.config.name}"${Tn(t)?` ${t.transactionMeta.phase} "${t.transactionMeta.update.token.key}"`:""}`),t}function tT(t){t.operation.open&&t.logger.info("🔴",t.operation.token.type,t.operation.token.key,`operation done in store "${t.config.name}"`),t.operation={open:!1},t.on.operationClose.next(t.operation)}const nT=(t,e)=>t.operation.open?t.operation.done.has(e):(t.logger.error("🐞","unknown",e,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0),uf=(t,e)=>{if(!t.operation.open){t.logger.error("🐞","unknown",e,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}t.operation.done.add(e)};function qp(t,e,n,r,a){const{oldValue:u,newValue:c}=n,f="oldValue"in n,h=zr(e);if(r&&a){e.subject.next({newValue:c});const S={checkpoint:!0,type:"state_creation",subType:"writable",token:h,timestamp:Date.now(),value:c};t.operation.subEvents.push(S),a.subject.next(S);const x=Re(t);if(h.family)if(ul(x))switch(h.type){case"atom":case"mutable_atom":t.on.atomCreation.next(h);break;case"writable_pure_selector":case"writable_held_selector":t.on.selectorCreation.next(h);break}else Tn(x)&&x.on.transactionApplying.state===null&&x.transactionMeta.update.subEvents.push(S);return}const{key:m,subject:y,type:g}=e;let v;if(f?v={oldValue:sc(u)?u.READONLY_VIEW:u,newValue:sc(c)?c.READONLY_VIEW:c}:v={newValue:sc(c)?c.READONLY_VIEW:c},ul(t)){switch(g){case"mutable_atom":t.logger.info("📢",g,m,"is now (",c,") subscribers:",y.subscribers.keys());break;case"atom":case"writable_pure_selector":case"writable_held_selector":t.logger.info("📢",g,m,"went (",u,"->",c,") subscribers:",y.subscribers.keys())}y.next(v)}if(Tn(t)&&(g==="mutable_atom"||g==="atom")){if(t.on.transactionApplying.state===null){if(sc(c))return;const{timestamp:S}=t.operation,x={type:"atom_update",token:h,timestamp:S,update:v};t.transactionMeta.update.subEvents.push(x),t.logger.info("📁","atom",m,"stowed (",u,"->",c,")");return}if(fy(e,"tracker:signal")){const S=m.slice(1),x=t.atoms.get(S);_s(t,x,"mut").do(v.newValue)===null&&cy(t,x)}}}const MS=Symbol("UNSET"),Pp=(t,e,n)=>{let r,a;if(Br(n)){const u=_s(t,e,"mut");r=u,a=n(u)}else t.valueMap.has(e.key)?r=uT(t,e,"mut"):e.type==="atom"&&!Br(e.default)?r=e.default:r=MS,a=n;return t.logger.info("⭐","atom",e.key,"setting value",a),a=Kn(t,e,a),uf(t,e.key),cy(t,e),r===MS?{newValue:a}:{oldValue:r,newValue:a}};function Zh(t,e){switch(e.type){case"mutable_atom":return Pp(t,e,new e.class);case"atom":{let n;return Br(e.default)?n=jc(t,e):n=e.default,Pp(t,e,n)}}}function tM(t,e){let n;switch(e.type){case"atom":case"mutable_atom":n=Zh(t,e);break;case"writable_held_selector":{const r=hl(t,e.key);for(const u of r.values())qp(t,e,Zh(t,u),!1);const a=e.getFrom(t);n={oldValue:a,newValue:a}}break;case"writable_pure_selector":{const r=jc(t,e),a=hl(t,e.key);for(const u of a.values())qp(t,e,Zh(t,u),!1);n={oldValue:r,newValue:jc(t,e)}}break}return n}function Lt(t,...e){El(Hp,t,...e)}const Ip=Symbol("RESET");function ny(t,...e){Lt(t,...e,Ip)}function nM(t,e,n){let r,a,u;const{type:c,key:f}=e;switch(e.type){case"writable_pure_selector":r=_s(t,e,"mut"),a=RS(n,r),a=Kn(t,e,a);break;case"writable_held_selector":u=e.const,RS(n,u),r=u,a=u}return t.logger.info("⭐",c,f,"setting to",a),uf(t,f),e.setSelf(a),{oldValue:r,newValue:a}}const iM=(t,e,n)=>{let r;switch(e.type){case"atom":case"mutable_atom":r=Pp(t,e,n);break;case"writable_pure_selector":case"writable_held_selector":r=nM(t,e,n);break}return r},Hp=Symbol("OWN_OP"),iy=Symbol("JOIN_OP");function El(t,e,...n){let r,a,u,c,f,h;n.length===2?(u=n[0],h=n[1],"family"in u&&(c=Qm(e,u),f=qr(u.family.subKey),r=dl(e,c,f),r?u=r:u=a=fl(cl,e,c,f))):(c=ct(e,n[0]),f=n[1],h=n[2],r=dl(e,c,f),r?u=r:u=a=fl(cl,e,c,f));const m=h===Ip?"reset":"set";let y;if(t===Hp){const S=eT(e,u);if(typeof S=="number"){const x=S,T=e.on.operationClose.subscribe(`waiting to ${m} "${u.key}" at T-${x}`,function(){T(),e.logger.info("🟢",u.type,u.key,"resuming deferred",m,`from T-${x}`),El(t,e,u,h)});return}y=S}else y=e;if("counterfeit"in u&&"family"in u){const S=u.family.subKey,x=e.disposalTraces.buffer.find(T=>T?.key===S);e.logger.error("❌",u.type,u.key,"could not be",m,"because key",S,"is not allocated.",x?`this key was previously disposed:${x.trace}`:"(no previous disposal trace found)");return}const g=ct(y,u);let v;h===Ip?v=tM(y,g):v=iM(y,g,h),qp(y,g,v,!!a,c),t===Hp&&tT(y)}const iT=(t,e)=>Re(t).atoms.has(e),rM=(t,e)=>Re(t).writableSelectors.has(e),sM=(t,e)=>Re(t).readonlySelectors.has(e),oM=(t,e)=>iT(t,e)||rM(t,e)||sM(t,e);function DS(t,e){return Re(t).selectorGraph.getRelationEntries({downstreamSelectorKey:e}).filter(([n,{source:r}])=>r!==e).map(([n,{source:r}])=>r).filter(n=>oM(t,n))}function hl(t,e,n=new Set){const r=DS(t,e),a=new Map;for(;r.length>0;){const u=r.pop();if(!n.has(u))if(n.add(u),iT(t,u)){const c=t.atoms.get(u);a.set(c.key,c)}else r.push(...DS(t,u))}return a}function aM(t,e,n,r,a){const u=Re(t),{type:c,key:f}=r;if(c==="atom"||c==="mutable_atom")u.selectorAtoms.set({selectorKey:n,atomKey:f}),t.logger.info("🔍",e,n,`discovers root atom "${f}"`);else{const h=hl(t,f,a);t.logger.info("🔍",e,n,`discovers root atoms: [ ${[...h.values()].map(m=>`"${m.key}"`).join(", ")} ]`);for(const{key:m}of h.values())u.selectorAtoms=u.selectorAtoms.set({selectorKey:n,atomKey:m})}a.add(f)}function cf(t,e,n,r){return{get:(...a)=>{const u=Re(t),{token:c,family:f,subKey:h}=Wm(t,...a);let m;return"counterfeit"in c&&f&&h?m=Zx(t,c,f,h):m=_s(t,ct(t,c)),t.logger.info("🔌",e,n,`registers dependency ( "${c.key}" =`,m,")"),u.selectorGraph.set({upstreamSelectorKey:c.key,downstreamSelectorKey:n},{source:c.key}),aM(t,e,n,c,r),m},set:((...a)=>{El(iy,Re(t),...a)}),find:((...a)=>Pr(t,...a)),json:a=>Rs(t,a)}}function ry(t,e,n){const r=Re(t),a=new We,u=new Set,{key:c,const:f}=e,h="readonly_held_selector";t.logger.info("🔨",h,c,"is being created");const{get:m,find:y,json:g}=cf(r,h,c,u),S={...e,type:h,subject:a,getFrom:T=>{const M=T.selectorGraph.getRelationEntries({downstreamSelectorKey:c});for(const[C,{source:_}]of M)_!==c&&T.selectorGraph.delete(C,c);return T.selectorAtoms.delete(c),e.get({get:m,find:y,json:g},f),Kn(T,S,f),t.logger.info("✨",h,c,"=",f),u.clear(),f},install:T=>ry(T,e,n)};n&&(S.family=n),r.readonlySelectors.set(c,S);const x={key:c,type:h};return n&&(x.family=n),x}function sy(t,e,n){const r=Re(t),a=new We,u=new Set,c=e.key,f="readonly_pure_selector";t.logger.info("🔨",f,c,"is being created");const{get:h,find:m,json:y}=cf(r,f,c,u),v={...e,type:f,subject:a,getFrom:()=>{const x=Re(t),T=x.selectorGraph.getRelationEntries({downstreamSelectorKey:c});for(const[C,{source:_}]of T)_!==c&&x.selectorGraph.delete(C,c);x.selectorAtoms.delete(c);const M=Kn(x,v,e.get({get:h,find:m,json:y}));return t.logger.info("✨",f,c,"=",M),u.clear(),M},install:x=>sy(x,e,n)};n&&(v.family=n),r.readonlySelectors.set(c,v);const S={key:c,type:f};return n&&(S.family=n),S}function oy(t,e,n){const r=Re(t),a=new We,u=new Set,{key:c,const:f}=e,h="writable_held_selector";t.logger.info("🔨",h,c,"is being created");const m=cf(r,h,c,u),{find:y,get:g,json:v}=m,S={find:y,get:g,json:v},M={...e,type:h,subject:a,getFrom:_=>{const R=_.selectorGraph.getRelationEntries({downstreamSelectorKey:c});for(const[G,{source:I}]of R)I!==c&&_.selectorGraph.delete(G,c);return _.selectorAtoms.delete(c),e.get(S,f),Kn(_,M,f),t.logger.info("✨",h,c,"=",f),u.clear(),f},setSelf:()=>{e.set(m,f)},install:_=>oy(_,e,n)};n&&(M.family=n),r.writableSelectors.set(c,M);const C={key:c,type:h};return n&&(C.family=n),C}function ay(t,e,n){const r=Re(t),a=new We,u=new Set,c=e.key,f="writable_pure_selector";t.logger.info("🔨",f,c,"is being created");const h=cf(r,f,c,u),{find:m,get:y,json:g}=h,v={find:m,get:y,json:g},T={...e,type:f,subject:a,getFrom:C=>{const _=C.selectorGraph.getRelationEntries({downstreamSelectorKey:c});for(const[G,{source:I}]of _)I!==c&&C.selectorGraph.delete(G,c);C.selectorAtoms.delete(c);const R=Kn(C,T,e.get(v));return t.logger.info("✨",f,c,"=",R),u.clear(),R},setSelf:C=>{e.set(h,C)},install:C=>ay(C,e,n)};n&&(T.family=n),r.writableSelectors.set(c,T);const M={key:c,type:f};return n&&(M.family=n),M}function rT(t,e){const n="set"in e,r="const"in e;if(r&&n){const u=oy(t,e,void 0);return t.on.selectorCreation.next(u),u}if(r){const u=ry(t,e,void 0);return t.on.selectorCreation.next(u),u}if(n){const u=ay(t,e,void 0);return t.on.selectorCreation.next(u),u}const a=sy(t,e,void 0);return t.on.selectorCreation.next(a),a}function lM(t,e){const n=Re(t),{key:r,type:a,family:u}=e;if(!u)t.logger.error("❌",a,r,"Standalone selectors cannot be disposed.");else{n.molecules.get(u.subKey)&&n.moleculeData.delete(u.subKey,u.key);let c;switch(e.type){case"writable_held_selector":n.writableSelectors.delete(r),c={key:u.key,type:"writable_held_selector_family"},ct(t,c).subject.next({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()});break;case"writable_pure_selector":n.writableSelectors.delete(r),c={key:u.key,type:"writable_pure_selector_family"},ct(t,c).subject.next({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()});break;case"readonly_held_selector":n.readonlySelectors.delete(r),c={key:u.key,type:"readonly_held_selector_family"},ct(t,c).subject.next({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()});break;case"readonly_pure_selector":n.readonlySelectors.delete(r),c={key:u.key,type:"readonly_pure_selector_family"},ct(t,c).subject.next({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()});break}n.valueMap.delete(r),n.selectorAtoms.delete(r),n.selectorGraph.delete(r),n.moleculeData.delete(u.key,u.subKey),t.logger.info("🔥",e.type,r,"deleted"),Tn(n)&&n.transactionMeta.phase==="building"?n.transactionMeta.update.subEvents.push({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()}):t.on.selectorDisposal.next(e)}}const uM=(t,e)=>{const n=Re(t);return n.operation.open?n.operation.prev.get(e.key):n.valueMap.get(e.key)},NS=(t,e,n)=>n.subject.subscribe(`${e.type}:${e.key}`,r=>{t.logger.info("📢",e.type,e.key,"root",n.key,"went",r.oldValue,"->",r.newValue);const a=uM(t,e),u=_s(t,e);t.logger.info("✨",e.type,e.key,"went",a,"->",u),e.subject.next({newValue:u,oldValue:a})});function Bo(t,e,n,r){function a(g){if(t.operation.open){if(u?.type==="atom"&&fy(u,"tracker:signal")&&"*"+t.operation.token.key===e.key&&"inboundTracker"in r)return;const v=t.on.operationClose.subscribe(`state subscription ${n}`,()=>{v(),r(g)})}else r(g)}Wm(t,e);const u=ct(t,e);t.logger.info("👀",u.type,u.key,`Adding subscription "${n}"`);const c=u.type==="writable_pure_selector"||u.type==="readonly_pure_selector",f=new Map;let h=a;if(c){_s(t,u);for(const[g,v]of hl(t,u.key))f.set(g,NS(t,u,v));h=function(v){const S=hl(t,u.key);for(const[x,T]of f)S.get(x)?S.delete(x):(T(),f.delete(x));for(const[x,T]of S)f.set(x,NS(t,u,T));a(v)}}const m=u.subject.subscribe(n,h);return()=>{t.logger.info("🙈",u.type,u.key,`Removing subscription "${n}"`),m();for(const g of f.values())g()}}const sT=(t,e,n,r)=>{const a=ct(t,e);t.logger.info("👀","timeline",e.key,`Adding subscription "${n}"`);const u=a.subject.subscribe(n,r);return()=>{t.logger.info("🙈","timeline",e.key,`Removing subscription "${n}" from timeline`),u()}},oT=(t,e,n,r)=>{const a=ct(t,e);t.logger.info("👀","transaction",e.key,`Adding subscription "${n}"`);const u=a.subject.subscribe(n,r);return()=>{t.logger.info("🙈","transaction",e.key,`Removing subscription "${n}"`),u()}};function cM(t,e,n,r=af()){switch(e.type){case"atom":case"mutable_atom":case"readonly_pure_selector":case"readonly_held_selector":case"writable_pure_selector":case"writable_held_selector":return Bo(t,e,r,n);case"transaction":return oT(t,e,r,n);case"timeline":return sT(t,e,r,n)}}var ly=class{initializeSignalAtom(t,e){const n=`*${t.key}`;e.atoms.delete(n),e.valueMap.delete(n);const r=t.family?{key:`*${t.family.key}`,subKey:t.family.subKey}:void 0,a=ff(e,{key:n,default:null},r,["tracker:signal"]);if(e.parent?.valueMap.has(n)){const u=e.parent.valueMap.get(n);e.valueMap.set(n,u)}return a}unsubscribeFromInnerValue;unsubscribeFromState;captureSignalsFromCore(t,e,n){const r=t.key,a=`tracker-from-core:${n.config.name}:${Tn(n)?n.transactionMeta.update.token.key:"main"}:${r}`,u=c=>{El(iy,n,e,c)};this.unsubscribeFromInnerValue=An(n,t).subscribe(a,u),this.unsubscribeFromState=Bo(n,t,a,(function(f){f.newValue!==f.oldValue&&(this.unsubscribeFromInnerValue(),this.unsubscribeFromInnerValue=f.newValue.subscribe(a,u))}).bind(this))}supplySignalsToCore(t,e,n){const r=t.key,a=`tracker-to-core:${n.config.name}:${Tn(n)?n.transactionMeta.update.token.key:"main"}:${r}`;Bo(n,e,a,Object.assign(function({newValue:c,oldValue:f}){const h=n.timelineTopics.getRelatedKey(e.key);if(h&&n.timelines.get(h)?.timeTraveling){const m=sT(n,{key:h,type:"timeline"},a,function(g){m(),Lt(n,t,v=>(g==="redo"&&c?v.do(c):g==="undo"&&f&&v.undo(f),v))});return}Lt(n,t,m=>(m.do(c),m))},{inboundTracker:!0}))}mutableAtomToken;latestSignalToken;[Symbol.dispose];constructor(t,e){const n=Re(e),r=this.initializeSignalAtom(t,n);this.mutableAtomToken=t,this.latestSignalToken=r,this.captureSignalsFromCore(t,r,n),this.supplySignalsToCore(t,r,n),n.trackers.set(t.key,this),this[Symbol.dispose]=()=>{this.unsubscribeFromInnerValue(),this.unsubscribeFromState(),n.trackers.delete(t.key)}}};function uy(t,e,n){t.logger.info("🔨","atom",e.key,`creating in store "${t.config.name}"`);const r=Re(t),{key:a}=e,u=r.atoms.get(a),c="mutable_atom";if(u?.type===c&&t.config.isProduction===!0)return t.logger.error("❌",c,a,"Tried to create atom, but it already exists in the store."),zr(u);const f=new We,h={...e,type:c,install:y=>(y.logger.info("🛠️","atom",a,`installing in store "${y.config.name}"`),uy(y,e,n)),subject:f};n&&(h.family=n),r.atoms.set(h.key,h);const m=zr(h);if(new ly(m,t),n||rT(t,{key:`${a}:JSON`,get:({get:y})=>y(m).toJSON(),set:({set:y},g)=>{y(m,e.class.fromJSON(g))}}),e.effects){let y=0;const g=[];for(const v of e.effects){const S=v({resetSelf:()=>{ny(t,m)},setSelf:x=>{Lt(t,m,x)},onSet:x=>Bo(t,m,`effect[${y}]`,x),token:m,store:Ym(t)});S&&g.push(S),++y}h.cleanup=()=>{for(const v of g)v()}}return t.on.atomCreation.next(m),m}var fM=class{trackers=new Map;latestSignalAtoms;mutableAtoms;constructor(t,e){this.latestSignalAtoms=ct(e,ey(e,{key:`*${t.key}`,default:null},["mutable","updates"])),this.mutableAtoms=t;const n=r=>{const{type:a,token:u}=r;if(u.family){const c=qr(u.family.subKey);switch(a){case"state_creation":this.trackers.set(c,new ly(u,e));break;case"state_disposal":{const f=this.trackers.get(c);f&&(f[Symbol.dispose](),this.trackers.delete(c))}}}};this.mutableAtoms.subject.subscribe(`store=${e.config.name}::tracker-atom-family`,n)}};function aT(t,e,n){const r={key:e.key,type:"mutable_atom_family"},a=t.families.get(e.key);a&&t.config.isProduction===!0&&t.logger.error("❗","mutable_atom_family",e.key,`Overwriting an existing ${Kr[a.type]} "${a.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const u=new We,f={...r,create:h=>{const m=zt(h),y={key:e.key,subKey:m},g=`${e.key}(${m})`,v=Re(t),S={key:g,class:e.class};return e.effects&&(S.effects=e.effects(h)),uy(v,S,y)},class:e.class,subject:u,install:h=>aT(h,e),internalRoles:n};return t.families.set(e.key,f),ty(t,{key:`${e.key}:JSON`,get:h=>({get:m})=>m(r,h).toJSON(),set:h=>({set:m},y)=>{m(r,h,e.class.fromJSON(y))}},["mutable","json"]),new fM(f,t),r}const dM=(t,e)=>{const n=Re(e),r=`${t.key}:JSON`;return n.families.get(r)},Rs=(t,e)=>e.family?Pr(t,ct(Re(t),{key:`${e.family.key}:JSON`,type:"writable_pure_selector_family"}),qr(e.family.subKey)):{type:"writable_pure_selector",key:`${e.key}:JSON`},lT=t=>{const e={type:"atom",key:`*${t.key}`};return t.family&&(e.family={key:`*${t.family.key}`,subKey:t.family.subKey}),e};function sc(t){return typeof t=="object"&&t!==null&&"do"in t&&"undo"in t&&"subscribe"in t&&"READONLY_VIEW"in t&&"toJSON"in t}function Kn(t,e,n){const{key:r,subject:a,type:u}=e,c=t.valueMap.get(r);if(c instanceof Kp&&!c.done){const f=c;return n instanceof Promise?(f.use(n),f):(t.valueMap.set(r,n),n)}if(n instanceof Promise){const f=new Kp(n);return t.valueMap.set(r,f),f.then(function(m){if(t.valueMap.get(r)===f){switch(eT(t,e),Kn(t,e,m),u){case"atom":cy(t,e);break;case"readonly_pure_selector":case"writable_pure_selector":fT(t,r);break}tT(t),a.next({newValue:m,oldValue:f})}}).catch(h=>{t.logger.error("💥",e.type,r,"rejected:",h)}),f}return t.logger.info("📝",e.type,e.key,"writing to cache",n),t.valueMap.set(r,n),n}function uT(t,e,n){t.logger.info("📖",e.type,e.key,"reading cached value");let r=t.valueMap.get(e.key);if(n==="mut"&&e.type==="mutable_atom"&&Tn(t)){const a=e,{parent:u}=t;if(t.valueMap.hasOwn(a.key))return r;const c=u.valueMap.get(a.key);t.logger.info("📃","atom",a.key,"copying");const f=c.toJSON(),h=a.class.fromJSON(f);t.valueMap.set(a.key,h),new ly(a,u),r=h}return r}function cT(t,e){const n=t.valueMap.get(e);if(n instanceof Kp){const r=t.writableSelectors.get(e)??t.readonlySelectors.get(e);r&&r.getFrom(t);return}t.operation.open&&t.operation.prev.set(e,n),t.valueMap.delete(e),t.logger.info("🗑","state",e,"evicted")}function cy(t,e){const n=Re(t),{key:r,type:a}=e,u=n.selectorAtoms.getRelatedKeys(r);if(n.logger.info("🧹",a,r,u?`evicting ${u.size} states downstream:`:"no downstream states",u??"to evict"),u){n.operation.open&&n.logger.info("🧹",a,r,`[ ${[...n.operation.done].join(", ")} ] already done`);for(const c of u)nT(n,c)||(cT(n,c),uf(n,c))}}function fT(t,e){const n=Re(t),r=n.selectorGraph.getRelationEntries({upstreamSelectorKey:e}).filter(([a,{source:u}])=>u===e);for(const[a]of r)nT(n,a)||(cT(n,a),uf(n,a),fT(t,a))}function ff(t,e,n,r){const a="atom",{key:u}=e;t.logger.info("🔨",a,u,"is being created");const c=Re(t),f=c.atoms.get(u);if(f?.type===a&&t.config.isProduction===!0)return t.logger.error("❌","atom",u,"Tried to create atom, but it already exists in the store."),zr(f);const h=new We,m={...e,type:a,install:g=>(g.logger.info("🛠️",a,u,`installing in store "${g.config.name}"`),ff(g,e,n)),subject:h};n&&(m.family=n),r&&(m.internalRoles=r),c.atoms.set(u,m);const y=zr(m);if(e.effects){let g=0;const v=[];for(const S of e.effects){const x=S({resetSelf:()=>{ny(t,y)},setSelf:T=>{Lt(t,y,T)},onSet:T=>Bo(t,y,`effect[${g}]`,T),token:y,store:Ym(t)});x&&v.push(x),++g}m.cleanup=()=>{for(const S of v)S()}}return t.on.atomCreation.next(y),y}function fy(t,e){return"internalRoles"in t?t.internalRoles.includes(e):!1}function dy(t,e){const n=Re(t),{key:r,family:a}=e,u=ct(n,e);if(!a)t.logger.error("❌","atom",r,"Standalone atoms cannot be disposed.");else{u.cleanup?.();const c=t.valueMap.get(u.key),f=ct(t,Qm(t,e)).subject,h={type:"state_disposal",subType:"atom",token:e,value:c,timestamp:Date.now()};f.next(h);const m=Tn(n);if(n.atoms.delete(r),n.valueMap.delete(r),n.selectorAtoms.delete(r),n.atomsThatAreDefault.delete(r),n.moleculeData.delete(a.key,a.subKey),t.timelineTopics.delete(r),e.type==="mutable_atom"&&(dy(t,lT(e)),t.trackers.delete(r)),t.logger.info("🔥","atom",r,"deleted"),m&&n.transactionMeta.phase==="building"){const y=n.transactionMeta.update.subEvents.at(-1),g=y?.type==="molecule_disposal"&&y.values.some(([S])=>S===u.family?.key),v=fy(u,"tracker:signal");!g&&!v&&n.transactionMeta.update.subEvents.push(h)}else t.on.atomDisposal.next(e)}}function hs(t){return t[0].toUpperCase()+t.slice(1)}var dT=class{toolkit;options;relations;states;relatedKeysAtoms;transact(t,e){const n=this.toolkit;this.toolkit=t,e(this),this.toolkit=n}store;[Symbol.dispose](){}constructor(t,e){this.store=t,this.options=e,this.store.miscResources.set(`join:${e.key}`,this),this.toolkit={get:((...y)=>An(t,...y)),set:((...y)=>{Lt(t,...y)}),find:((...y)=>Pr(t,...y)),json:y=>Rs(t,y)};const n=e.between[0],r=e.between[1],a=aT(t,{key:`${e.key}/relatedKeys`,class:Kx},["join","relations"]);this.relatedKeysAtoms=a;const u=(y,g,v)=>{const{find:S,get:x,set:T}=y,M=S(a,g),C=x(M);for(const _ of C)v.includes(_)||T(a,_,R=>(R.delete(g),R));T(M,_=>{_.clear();for(const R of v){const G=S(a,R),I=x(G),ee=I.has(g);if(this.relations.cardinality==="1:n"){const J=[];for(const X of I){if(X===g)continue;let he;El(iy,this.store,a,X,pe=>(pe.delete(R),he=pe.size,pe)),he===0&&J.push(X)}!ee&&I.size>0&&T(G,X=>(X.clear(),X));for(const X of J)t.keyRefsInJoins.delete(Sc(R,X))}ee||T(G,J=>(J.add(g),J)),_.add(R)}return _})},c=(y,g,v)=>{const{set:S}=y;S(a,g,x=>{for(const T of v)x.add(T);return x});for(const x of v)S(a,x,T=>(T.add(g),T));return!0},f=new qi(e,{externalStore:{getRelatedKeys:y=>this.toolkit.get(a,y),addRelation:(y,g)=>{this.store.keyRefsInJoins.set(`"${y}"`,e.key),this.store.keyRefsInJoins.set(`"${g}"`,e.key),this.store.keyRefsInJoins.set(Sc(y,g),e.key),this.toolkit.set(a,y,v=>v.add(g)),this.toolkit.set(a,g,v=>v.add(y))},deleteRelation:(y,g)=>{this.toolkit.set(a,y,S=>(S.delete(g),S)),this.toolkit.set(a,g,S=>(S.delete(y),S));const v=Sc(y,g);this.store.keyRefsInJoins.delete(v)},replaceRelationsSafely:(y,g)=>{u(this.toolkit,y,g)},replaceRelationsUnsafely:(y,g)=>{c(this.toolkit,y,g)},has:(y,g)=>{const v=this.toolkit.get(a,y);return g?v.has(g):v.size>0}},isAType:e.isAType,isBType:e.isBType}),h=()=>Bc(t,{key:`${e.key}/singleRelatedKey`,get:y=>({get:g})=>{const v=g(a,y);for(const S of v)return S;return null}},["join","keys"]),m=()=>Bc(t,{key:`${e.key}/multipleRelatedKeys`,get:y=>({get:g})=>g(dM(a,t),y)},["join","keys"]);switch(e.cardinality){case"1:1":{const y=h(),g=`${n}KeyOf${hs(r)}`,v=`${r}KeyOf${hs(n)}`;this.relations=f,this.states={[g]:y,[v]:y};break}case"1:n":{const y=h(),g=m(),v=`${n}KeyOf${hs(r)}`,S=`${r}KeysOf${hs(n)}`,x={[v]:y,[S]:g};this.relations=f,this.states=x;break}case"n:n":{const y=m(),g=`${n}KeysOf${hs(r)}`,v=`${r}KeysOf${hs(n)}`;this.relations=f,this.states={[g]:y,[v]:y}}}}};function hM(t,e){return t.joins.set(e.key,new dT(t,e)),{key:e.key,type:"join",a:e.between[0],b:e.between[1],cardinality:e.cardinality}}function pM(t,e){let n=t.joins.get(e.key);if(n===void 0){const r=Jt.STORE.joins.get(e.key);if(r===void 0)throw new Error(`Join "${e.key}" not found in store "${t.config.name}"`);n=new dT(Ym(t),r.options),t.joins.set(e.key,n)}return n}function mM(t,e,n){const r=pM(t,e);return[r.relatedKeysAtoms,r.relatedKeysAtoms]}var Qh={exports:{}},ye={};var $S;function yM(){if($S)return ye;$S=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.iterator;function S(E){return E===null||typeof E!="object"?null:(E=v&&E[v]||E["@@iterator"],typeof E=="function"?E:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,M={};function C(E,q,H){this.props=E,this.context=q,this.refs=M,this.updater=H||x}C.prototype.isReactComponent={},C.prototype.setState=function(E,q){if(typeof E!="object"&&typeof E!="function"&&E!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,E,q,"setState")},C.prototype.forceUpdate=function(E){this.updater.enqueueForceUpdate(this,E,"forceUpdate")};function _(){}_.prototype=C.prototype;function R(E,q,H){this.props=E,this.context=q,this.refs=M,this.updater=H||x}var G=R.prototype=new _;G.constructor=R,T(G,C.prototype),G.isPureReactComponent=!0;var I=Array.isArray;function ee(){}var J={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function he(E,q,H){var Q=H.ref;return{$$typeof:t,type:E,key:q,ref:Q!==void 0?Q:null,props:H}}function pe(E,q){return he(E.type,q,E.props)}function we(E){return typeof E=="object"&&E!==null&&E.$$typeof===t}function je(E){var q={"=":"=0",":":"=2"};return"$"+E.replace(/[=:]/g,function(H){return q[H]})}var ve=/\/+/g;function Z(E,q){return typeof E=="object"&&E!==null&&E.key!=null?je(""+E.key):q.toString(36)}function ne(E){switch(E.status){case"fulfilled":return E.value;case"rejected":throw E.reason;default:switch(typeof E.status=="string"?E.then(ee,ee):(E.status="pending",E.then(function(q){E.status==="pending"&&(E.status="fulfilled",E.value=q)},function(q){E.status==="pending"&&(E.status="rejected",E.reason=q)})),E.status){case"fulfilled":return E.value;case"rejected":throw E.reason}}throw E}function j(E,q,H,Q,re){var ce=typeof E;(ce==="undefined"||ce==="boolean")&&(E=null);var Te=!1;if(E===null)Te=!0;else switch(ce){case"bigint":case"string":case"number":Te=!0;break;case"object":switch(E.$$typeof){case t:case e:Te=!0;break;case y:return Te=E._init,j(Te(E._payload),q,H,Q,re)}}if(Te)return re=re(E),Te=Q===""?"."+Z(E,0):Q,I(re)?(H="",Te!=null&&(H=Te.replace(ve,"$&/")+"/"),j(re,q,H,"",function(ii){return ii})):re!=null&&(we(re)&&(re=pe(re,H+(re.key==null||E&&E.key===re.key?"":(""+re.key).replace(ve,"$&/")+"/")+Te)),q.push(re)),1;Te=0;var Ct=Q===""?".":Q+":";if(I(E))for(var Je=0;Je<E.length;Je++)Q=E[Je],ce=Ct+Z(Q,Je),Te+=j(Q,q,H,ce,re);else if(Je=S(E),typeof Je=="function")for(E=Je.call(E),Je=0;!(Q=E.next()).done;)Q=Q.value,ce=Ct+Z(Q,Je++),Te+=j(Q,q,H,ce,re);else if(ce==="object"){if(typeof E.then=="function")return j(ne(E),q,H,Q,re);throw q=String(E),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(E).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return Te}function U(E,q,H){if(E==null)return E;var Q=[],re=0;return j(E,Q,"","",function(ce){return q.call(H,ce,re++)}),Q}function L(E){if(E._status===-1){var q=E._result;q=q(),q.then(function(H){(E._status===0||E._status===-1)&&(E._status=1,E._result=H)},function(H){(E._status===0||E._status===-1)&&(E._status=2,E._result=H)}),E._status===-1&&(E._status=0,E._result=q)}if(E._status===1)return E._result.default;throw E._result}var te=typeof reportError=="function"?reportError:function(E){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof E=="object"&&E!==null&&typeof E.message=="string"?String(E.message):String(E),error:E});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",E);return}console.error(E)},oe={map:U,forEach:function(E,q,H){U(E,function(){q.apply(this,arguments)},H)},count:function(E){var q=0;return U(E,function(){q++}),q},toArray:function(E){return U(E,function(q){return q})||[]},only:function(E){if(!we(E))throw Error("React.Children.only expected to receive a single React element child.");return E}};return ye.Activity=g,ye.Children=oe,ye.Component=C,ye.Fragment=n,ye.Profiler=a,ye.PureComponent=R,ye.StrictMode=r,ye.Suspense=h,ye.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=J,ye.__COMPILER_RUNTIME={__proto__:null,c:function(E){return J.H.useMemoCache(E)}},ye.cache=function(E){return function(){return E.apply(null,arguments)}},ye.cacheSignal=function(){return null},ye.cloneElement=function(E,q,H){if(E==null)throw Error("The argument must be a React element, but you passed "+E+".");var Q=T({},E.props),re=E.key;if(q!=null)for(ce in q.key!==void 0&&(re=""+q.key),q)!X.call(q,ce)||ce==="key"||ce==="__self"||ce==="__source"||ce==="ref"&&q.ref===void 0||(Q[ce]=q[ce]);var ce=arguments.length-2;if(ce===1)Q.children=H;else if(1<ce){for(var Te=Array(ce),Ct=0;Ct<ce;Ct++)Te[Ct]=arguments[Ct+2];Q.children=Te}return he(E.type,re,Q)},ye.createContext=function(E){return E={$$typeof:c,_currentValue:E,_currentValue2:E,_threadCount:0,Provider:null,Consumer:null},E.Provider=E,E.Consumer={$$typeof:u,_context:E},E},ye.createElement=function(E,q,H){var Q,re={},ce=null;if(q!=null)for(Q in q.key!==void 0&&(ce=""+q.key),q)X.call(q,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(re[Q]=q[Q]);var Te=arguments.length-2;if(Te===1)re.children=H;else if(1<Te){for(var Ct=Array(Te),Je=0;Je<Te;Je++)Ct[Je]=arguments[Je+2];re.children=Ct}if(E&&E.defaultProps)for(Q in Te=E.defaultProps,Te)re[Q]===void 0&&(re[Q]=Te[Q]);return he(E,ce,re)},ye.createRef=function(){return{current:null}},ye.forwardRef=function(E){return{$$typeof:f,render:E}},ye.isValidElement=we,ye.lazy=function(E){return{$$typeof:y,_payload:{_status:-1,_result:E},_init:L}},ye.memo=function(E,q){return{$$typeof:m,type:E,compare:q===void 0?null:q}},ye.startTransition=function(E){var q=J.T,H={};J.T=H;try{var Q=E(),re=J.S;re!==null&&re(H,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(ee,te)}catch(ce){te(ce)}finally{q!==null&&H.types!==null&&(q.types=H.types),J.T=q}},ye.unstable_useCacheRefresh=function(){return J.H.useCacheRefresh()},ye.use=function(E){return J.H.use(E)},ye.useActionState=function(E,q,H){return J.H.useActionState(E,q,H)},ye.useCallback=function(E,q){return J.H.useCallback(E,q)},ye.useContext=function(E){return J.H.useContext(E)},ye.useDebugValue=function(){},ye.useDeferredValue=function(E,q){return J.H.useDeferredValue(E,q)},ye.useEffect=function(E,q){return J.H.useEffect(E,q)},ye.useEffectEvent=function(E){return J.H.useEffectEvent(E)},ye.useId=function(){return J.H.useId()},ye.useImperativeHandle=function(E,q,H){return J.H.useImperativeHandle(E,q,H)},ye.useInsertionEffect=function(E,q){return J.H.useInsertionEffect(E,q)},ye.useLayoutEffect=function(E,q){return J.H.useLayoutEffect(E,q)},ye.useMemo=function(E,q){return J.H.useMemo(E,q)},ye.useOptimistic=function(E,q){return J.H.useOptimistic(E,q)},ye.useReducer=function(E,q,H){return J.H.useReducer(E,q,H)},ye.useRef=function(E){return J.H.useRef(E)},ye.useState=function(E){return J.H.useState(E)},ye.useSyncExternalStore=function(E,q,H){return J.H.useSyncExternalStore(E,q,H)},ye.useTransition=function(){return J.H.useTransition()},ye.version="19.2.0",ye}var jS;function hy(){return jS||(jS=1,Qh.exports=yM()),Qh.exports}var $=hy();const gM=gk($),hT=yk({__proto__:null,default:gM},[$]),py=$.createContext(Jt.STORE);function pT(t,...e){let n;if(e.length===2){const r=e[0],a=e[1];n=Pr(t,r,a)}else n=e[0];return n}function Wn(...t){const e=$.useContext(py),n=pT(e,...t),r=$.useRef(null);return r.current??=a=>{Lt(e,n,a)},r.current}function Et(...t){const e=$.useContext(py),n=pT(e,...t),r=$.useId();return $.useSyncExternalStore(a=>Bo(e,n,`use-o:${r}`,a),()=>An(e,n),()=>An(e,n))}const mT=(t,{stringify:e,parse:n},r)=>({setSelf:a,onSet:u})=>{if(!t)return;const c=t.getItem(r);c!=null&&a(n(c)),u(({newValue:f})=>{if(f==null){t.removeItem(r);return}t.setItem(r,e(f))})};wk({key:"mutex",default:!1});var bM=class extends Map{set(t,e){return this.has(t)?(console.warn("Tried to set a key that already exists in an InvariantMap",{key:t,value:e}),this):super.set(t,e)}},vM=class Fp{type="continuity";globals=[];actions=[];perspectives=[];key;constructor(e){this.key=e}static existing=new bM;static create(e,n){const{type:r,globals:a,actions:u,perspectives:c}=n(new Fp(e)),f={type:r,key:e,globals:a,actions:u,perspectives:c};return Fp.existing.set(e,f),f}add(...e){switch(e[0].type){case"atom":case"mutable_atom":this.globals.push(...e);break;case"transaction":this.actions.push(...e);break;case"atom_family":case"mutable_atom_family":{const[n,r]=e;this.perspectives.push({type:"realtime_perspective",resourceAtoms:n,viewAtoms:r})}break}return this}};function SM(t){const{key:e,config:n}=t,r=vM.create(e,n),{actions:a}=r;for(const u of a)Jx(Jt.STORE,e,u.key);return Zm(Jt.STORE,e,-1),r}const wM=t=>t.startsWith("user::"),xM=t=>t.startsWith("room::");Sk({key:"roomIndex",class:Kx});const TM=xk({key:"usersInRooms",between:["room","user"],cardinality:"1:n",isAType:xM,isBType:wM});_k({key:"usersInMyRoomView",get:t=>({find:e})=>{const[,n]=Tk(TM);return[e(n,t)]}});const AM=(t,e,n,r,a)=>u=>{function c(h,m){if(t.logger.info("🧑⚖️","continuity",e,"reconciling updates"),Lt(t,wc,g=>(g.shift(),g)),h.id===m.id){if(JSON.stringify(h.subEvents)===JSON.stringify(m.subEvents)){t.logger.info("✅","continuity",e,`results for ${h.id} match between client and server`),n.emit(`ack:${e}`,m.epoch);return}}else t.logger.info("❌","continuity",e,`thought update #${m.epoch} was ${h.token.key}:${h.id}, but it was actually ${m.token.key}:${m.id}`);t.logger.info("🧑⚖️","continuity",e,"updates do not match",h,m);const y=r.toReversed();for(const g of y)wo(t,g,"oldValue");t.logger.info("⏪","continuity",e,"undid optimistic updates:",y),wo(t,h,"oldValue"),t.logger.info("⏪","continuity",e,"undid zeroth optimistic update",h),wo(t,m,"newValue"),t.logger.info("⏩","continuity",e,"applied confirmed update",m),n.emit(`ack:${e}`,m.epoch);for(const g of r){const v={type:"transaction",key:g.token.key},{id:S,params:x}=g;Jm(t,v,S)(...x)}t.logger.info("⏩","continuity",e,"reapplied subsequent optimistic updates:",r)}t.logger.info("🧑⚖️","continuity",e,"integrating confirmed update",{confirmedUpdate:u,confirmedUpdates:a,optimisticUpdates:r});const f=r[0];if(f)if(t.logger.info("🧑⚖️","continuity",e,"has optimistic updates to reconcile"),u.epoch===f.epoch){t.logger.info("🧑⚖️","continuity",e,`epoch of confirmed update #${u.epoch} matches zeroth optimistic update`),c(f,u);for(const h of a){const m=r[0];if(h.epoch===m?.epoch)c(m,h);else break}}else t.logger.info("🧑⚖️","continuity",e,`epoch of confirmed update #${u.epoch} does not match zeroth optimistic update #${f.epoch}`),a.some(h=>h.epoch===u.epoch)||(t.logger.info("👈","continuity",e,"pushing confirmed update to queue",u),Lt(t,Gp,h=>(h.push(u),h.sort((m,y)=>m.epoch-y.epoch),h)));else{t.logger.info("🧑⚖️","continuity",e,"has no optimistic updates to deal with");let h;h=Yx(t,e),h===u.epoch-1?(t.logger.info("✅","continuity",e,`integrating update #${u.epoch} (${u.token.key} ${u.id})`),wo(t,u,"newValue"),n.emit(`ack:${e}`,u.epoch),Zm(t,e,u.epoch)):h!==void 0&&(t.logger.info("🧑⚖️","continuity",e,`received update #${u.epoch} but still waiting for update #${h+1}`,{clientEpoch:h,serverEpoch:u.epoch}),a.some(m=>m.epoch===u.epoch)?t.logger.info("👍","continuity",e,`confirmed update #${u.epoch} is already enqueued`):(t.logger.info("👈","continuity",e,`pushing confirmed update #${u.epoch} to queue`),Lt(t,Gp,m=>(m.push(u),m.sort((y,g)=>y.epoch-g.epoch),m))))}};function EM(t){return e=>{for(const n of e)dy(t,n)}}function OM(t){return e=>{let n=0,r,a;for(const u of e)n%2===0?r=u:(a=u,Lt(t,r,a)),n++}}const _M=ft({key:"mySocketKey",default:void 0});ft({key:"myUserKey",default:null,effects:[mT(globalThis.localStorage,JSON,"myUserKey")]});const wc=ft({key:"optimisticUpdateQueue",default:()=>[]}),Gp=ft({key:"confirmedUpdateQueue",default:()=>[]});function RM(t,e,n){const r=n.key,a=An(t,wc),u=An(t,Gp),c=(g,v)=>{e.off(`continuity-init:${r}`,c);let S=0,x,T;for(const M of v)S%2===0?x=M:(T=M,"type"in x&&x.type==="mutable_atom"&&(x=Rs(t,x)),Lt(t,x,T)),S++;Zm(t,r,g)};e.off(`continuity-init:${r}`),e.on(`continuity-init:${r}`,c);const f=AM(t,r,e,a,u);e.off(`tx-new:${r}`),e.on(`tx-new:${r}`,f);const h=n.actions.map(g=>(Jx(t,r,g.key),oT(t,g,`tx-run:${r}`,v=>{t.logger.info("🤞","continuity",r,"enqueuing optimistic update");const S=a.findIndex(x=>x.id===v.id);S===-1?(t.logger.info("🤞","continuity",r,"enqueuing new optimistic update"),Lt(t,wc,x=>(x.push(v),x.sort((T,M)=>T.epoch-M.epoch),x))):(t.logger.info("🤞","continuity",r,`replacing existing optimistic update at index ${S}`),Lt(t,wc,x=>(x[S]=v,x))),e.emit(`tx-run:${r}`,{id:v.id,token:g,params:v.params})}))),m=OM(t),y=EM(t);return e.on(`reveal:${r}`,m),e.on(`conceal:${r}`,y),e.emit(`get:${r}`),()=>{e.off(`continuity-init:${r}`),e.off(`tx-new:${r}`);for(const g of h)g()}}const yT=$.createContext({socket:null,services:null}),CM=({children:t,socket:e})=>{const n=$.useRef(new Map).current,r=Wn(_M);return $.useEffect(()=>{r(e?.id?`socket::${e.id}`:void 0),e?.on("connect",()=>{r(e?.id?`socket::${e.id}`:void 0)}),e?.on("disconnect",()=>{r(void 0)})},[e,r]),F.jsx(yT.Provider,{value:{socket:e,services:n},children:t})};function kM(t,e){if(globalThis.env?.NODE_ENV==="development"){const n=$.useRef(!1);$.useEffect(()=>{let r=n.current;if(r===!1)r=t()??!0,n.current=r;else return()=>{Br(r)&&r(),n.current=!1}},e)}else $.useEffect(t,e)}function MM(t,e){const{socket:n,services:r}=$.useContext(yT);kM(()=>{let a=r?.get(t);return a?++a.consumerCount:n&&(a={consumerCount:1,dispose:e(n)},r?.set(t,a)),()=>{a&&(--a.consumerCount,a.consumerCount===0&&(a.dispose?.(),r?.delete(t)))}},[n,t])}function DM(t){const e=$.useContext(py);MM(`tx-sync:${t.key}`,n=>RM(e,n,t))}var Wh={exports:{}},Ga={},ep={exports:{}},tp={};var BS;function NM(){return BS||(BS=1,(function(t){function e(j,U){var L=j.length;j.push(U);e:for(;0<L;){var te=L-1>>>1,oe=j[te];if(0<a(oe,U))j[te]=U,j[L]=oe,L=te;else break e}}function n(j){return j.length===0?null:j[0]}function r(j){if(j.length===0)return null;var U=j[0],L=j.pop();if(L!==U){j[0]=L;e:for(var te=0,oe=j.length,E=oe>>>1;te<E;){var q=2*(te+1)-1,H=j[q],Q=q+1,re=j[Q];if(0>a(H,L))Q<oe&&0>a(re,H)?(j[te]=re,j[Q]=L,te=Q):(j[te]=H,j[q]=L,te=q);else if(Q<oe&&0>a(re,L))j[te]=re,j[Q]=L,te=Q;else break e}}return U}function a(j,U){var L=j.sortIndex-U.sortIndex;return L!==0?L:j.id-U.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,f=c.now();t.unstable_now=function(){return c.now()-f}}var h=[],m=[],y=1,g=null,v=3,S=!1,x=!1,T=!1,M=!1,C=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function G(j){for(var U=n(m);U!==null;){if(U.callback===null)r(m);else if(U.startTime<=j)r(m),U.sortIndex=U.expirationTime,e(h,U);else break;U=n(m)}}function I(j){if(T=!1,G(j),!x)if(n(h)!==null)x=!0,ee||(ee=!0,je());else{var U=n(m);U!==null&&ne(I,U.startTime-j)}}var ee=!1,J=-1,X=5,he=-1;function pe(){return M?!0:!(t.unstable_now()-he<X)}function we(){if(M=!1,ee){var j=t.unstable_now();he=j;var U=!0;try{e:{x=!1,T&&(T=!1,_(J),J=-1),S=!0;var L=v;try{t:{for(G(j),g=n(h);g!==null&&!(g.expirationTime>j&&pe());){var te=g.callback;if(typeof te=="function"){g.callback=null,v=g.priorityLevel;var oe=te(g.expirationTime<=j);if(j=t.unstable_now(),typeof oe=="function"){g.callback=oe,G(j),U=!0;break t}g===n(h)&&r(h),G(j)}else r(h);g=n(h)}if(g!==null)U=!0;else{var E=n(m);E!==null&&ne(I,E.startTime-j),U=!1}}break e}finally{g=null,v=L,S=!1}U=void 0}}finally{U?je():ee=!1}}}var je;if(typeof R=="function")je=function(){R(we)};else if(typeof MessageChannel<"u"){var ve=new MessageChannel,Z=ve.port2;ve.port1.onmessage=we,je=function(){Z.postMessage(null)}}else je=function(){C(we,0)};function ne(j,U){J=C(function(){j(t.unstable_now())},U)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(j){j.callback=null},t.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<j?Math.floor(1e3/j):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_next=function(j){switch(v){case 1:case 2:case 3:var U=3;break;default:U=v}var L=v;v=U;try{return j()}finally{v=L}},t.unstable_requestPaint=function(){M=!0},t.unstable_runWithPriority=function(j,U){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var L=v;v=j;try{return U()}finally{v=L}},t.unstable_scheduleCallback=function(j,U,L){var te=t.unstable_now();switch(typeof L=="object"&&L!==null?(L=L.delay,L=typeof L=="number"&&0<L?te+L:te):L=te,j){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=L+oe,j={id:y++,callback:U,priorityLevel:j,startTime:L,expirationTime:oe,sortIndex:-1},L>te?(j.sortIndex=L,e(m,j),n(h)===null&&j===n(m)&&(T?(_(J),J=-1):T=!0,ne(I,L-te))):(j.sortIndex=oe,e(h,j),x||S||(x=!0,ee||(ee=!0,je()))),j},t.unstable_shouldYield=pe,t.unstable_wrapCallback=function(j){var U=v;return function(){var L=v;v=U;try{return j.apply(this,arguments)}finally{v=L}}}})(tp)),tp}var zS;function $M(){return zS||(zS=1,ep.exports=NM()),ep.exports}var np={exports:{}},Gt={};var LS;function jM(){if(LS)return Gt;LS=1;var t=hy();function e(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function u(h,m,y){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:g==null?null:""+g,children:h,containerInfo:m,implementation:y}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(h,m){if(h==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return Gt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Gt.createPortal=function(h,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(e(299));return u(h,m,null,y)},Gt.flushSync=function(h){var m=c.T,y=r.p;try{if(c.T=null,r.p=2,h)return h()}finally{c.T=m,r.p=y,r.d.f()}},Gt.preconnect=function(h,m){typeof h=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,r.d.C(h,m))},Gt.prefetchDNS=function(h){typeof h=="string"&&r.d.D(h)},Gt.preinit=function(h,m){if(typeof h=="string"&&m&&typeof m.as=="string"){var y=m.as,g=f(y,m.crossOrigin),v=typeof m.integrity=="string"?m.integrity:void 0,S=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?r.d.S(h,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:g,integrity:v,fetchPriority:S}):y==="script"&&r.d.X(h,{crossOrigin:g,integrity:v,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},Gt.preinitModule=function(h,m){if(typeof h=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=f(m.as,m.crossOrigin);r.d.M(h,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&r.d.M(h)},Gt.preload=function(h,m){if(typeof h=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,g=f(y,m.crossOrigin);r.d.L(h,y,{crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},Gt.preloadModule=function(h,m){if(typeof h=="string")if(m){var y=f(m.as,m.crossOrigin);r.d.m(h,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else r.d.m(h)},Gt.requestFormReset=function(h){r.d.r(h)},Gt.unstable_batchedUpdates=function(h,m){return h(m)},Gt.useFormState=function(h,m,y){return c.H.useFormState(h,m,y)},Gt.useFormStatus=function(){return c.H.useHostTransitionStatus()},Gt.version="19.2.0",Gt}var VS;function gT(){if(VS)return np.exports;VS=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),np.exports=jM(),np.exports}var US;function BM(){if(US)return Ga;US=1;var t=$M(),e=hy(),n=gT();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)s+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function u(i){var s=i,o=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(o=s.return),i=s.return;while(i)}return s.tag===3?o:null}function c(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function f(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function h(i){if(u(i)!==i)throw Error(r(188))}function m(i){var s=i.alternate;if(!s){if(s=u(i),s===null)throw Error(r(188));return s!==i?null:i}for(var o=i,l=s;;){var d=o.return;if(d===null)break;var p=d.alternate;if(p===null){if(l=d.return,l!==null){o=l;continue}break}if(d.child===p.child){for(p=d.child;p;){if(p===o)return h(d),i;if(p===l)return h(d),s;p=p.sibling}throw Error(r(188))}if(o.return!==l.return)o=d,l=p;else{for(var b=!1,w=d.child;w;){if(w===o){b=!0,o=d,l=p;break}if(w===l){b=!0,l=d,o=p;break}w=w.sibling}if(!b){for(w=p.child;w;){if(w===o){b=!0,o=p,l=d;break}if(w===l){b=!0,l=p,o=d;break}w=w.sibling}if(!b)throw Error(r(189))}}if(o.alternate!==l)throw Error(r(190))}if(o.tag!==3)throw Error(r(188));return o.stateNode.current===o?i:s}function y(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=y(i),s!==null)return s;i=i.sibling}return null}var g=Object.assign,v=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),R=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),he=Symbol.for("react.activity"),pe=Symbol.for("react.memo_cache_sentinel"),we=Symbol.iterator;function je(i){return i===null||typeof i!="object"?null:(i=we&&i[we]||i["@@iterator"],typeof i=="function"?i:null)}var ve=Symbol.for("react.client.reference");function Z(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===ve?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case C:return"Profiler";case M:return"StrictMode";case I:return"Suspense";case ee:return"SuspenseList";case he:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case R:return i.displayName||"Context";case _:return(i._context.displayName||"Context")+".Consumer";case G:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case J:return s=i.displayName||null,s!==null?s:Z(i.type)||"Memo";case X:s=i._payload,i=i._init;try{return Z(i(s))}catch{}}return null}var ne=Array.isArray,j=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},te=[],oe=-1;function E(i){return{current:i}}function q(i){0>oe||(i.current=te[oe],te[oe]=null,oe--)}function H(i,s){oe++,te[oe]=i.current,i.current=s}var Q=E(null),re=E(null),ce=E(null),Te=E(null);function Ct(i,s){switch(H(ce,s),H(re,i),H(Q,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?F0(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=F0(s),i=G0(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}q(Q),H(Q,i)}function Je(){q(Q),q(re),q(ce)}function ii(i){i.memoizedState!==null&&H(Te,i);var s=Q.current,o=G0(s,i.type);s!==o&&(H(re,i),H(Q,o))}function xi(i){re.current===i&&(q(Q),q(re)),Te.current===i&&(q(Te),qa._currentValue=L)}var xe,Me;function ge(i){if(xe===void 0)try{throw Error()}catch(o){var s=o.stack.trim().match(/\n( *(at )?)/);xe=s&&s[1]||"",Me=-1<o.stack.indexOf(`
|
|
12
|
+
${g.trace}`:`No previous disposal trace for ${f} was found.`),n}const m=t.moleculeGraph.getRelationEntries({downstreamMoleculeKey:c.stringKey}).filter(([,{source:g}])=>g!==a).map(([g])=>qr(g));r&&u.moleculeGraph.delete(a),u.moleculeGraph.set({upstreamMoleculeKey:h.stringKey,downstreamMoleculeKey:c.stringKey},{source:h.stringKey});const y={type:"molecule_transfer",key:c.key,exclusive:!!r,from:m,to:[h.key],timestamp:Date.now()};return Tn(u)&&u.transactionMeta.phase==="building"&&u.transactionMeta.update.subEvents.push(y),n}function Kk(t,e,n){switch(n){case"newValue":F1(t,e);break;case"oldValue":lf(t,e.token);break}}function qk(t,e,n){switch(n){case"newValue":lf(t,e.token);break;case"oldValue":F1(t,e),e.subType==="atom"&&t.valueMap.set(e.token.key,e.value);break}}function F1(t,e){const{token:n}=e;e.subType==="writable"&&e.value?Lt(t,n,e.value):An(t,n)}function Pk(t,e,n){switch(n){case"newValue":H1(t,e.provenance,e.key);break;case"oldValue":Xm(t,e.key);break}}function Ik(t,e,n){switch(n){case"newValue":Xm(t,e.key);break;case"oldValue":H1(t,e.provenance.map(qr),e.key);for(const[r,a]of e.values){const u=t.families.get(r);if(u){An(t,u,e.key);const c=`${r}(${zt(e.key)})`;t.valueMap.set(c,a)}}break}}function Hk(t,e,n){switch(n){case"newValue":for(const r of e.to)CS(t,r,e.key,e.exclusive?"exclusive":void 0);break;case"oldValue":{let r="exclusive";for(const a of e.from)CS(t,a,e.key,r),r=void 0}break}}function wo(t,e,n){const r=n==="newValue"?e.subEvents:[...e.subEvents].reverse();for(const a of r)switch(a.type){case"atom_update":Vk(t,a,n);break;case"state_creation":Kk(t,a,n);break;case"state_disposal":qk(t,a,n);break;case"molecule_creation":Pk(t,a,n);break;case"molecule_disposal":Ik(t,a,n);break;case"molecule_transfer":Hk(t,a,n);break;case"transaction_outcome":wo(t,a,n);break}}function ul(t){return"epoch"in t.transactionMeta}function Tn(t){return"phase"in t.transactionMeta}function G1(t,e){return t.transactionMeta.actionContinuities.getRelatedKey(e)}function Y1(t,e){return t.transactionMeta.epoch.get(e)}function Fk(t,e){const n=G1(t,e);if(n!==void 0)return Y1(t,n)}function Zm(t,e,n){t.transactionMeta.epoch.set(e,n)}function Gk(t,e,n){const r=G1(t,e);r!==void 0&&t.transactionMeta.epoch.set(r,n)}function Yk(t,e){const n=Re(t),{parent:r}=n;n.transactionMeta.phase="applying",n.transactionMeta.update.output=e,r.child=null,r.on.transactionApplying.next(n.transactionMeta);const{subEvents:a}=n.transactionMeta.update;t.logger.info("🛄","transaction",n.transactionMeta.update.token.key,`applying ${a.length} subEvents:`,a),wo(r,n.transactionMeta.update,"newValue"),ul(r)?(Gk(r,n.transactionMeta.update.token.key,n.transactionMeta.update.epoch),ct(t,{key:n.transactionMeta.update.token.key,type:"transaction"})?.subject.next(n.transactionMeta.update),t.logger.info("🛬","transaction",n.transactionMeta.update.token.key,"applied")):Tn(r)&&r.transactionMeta.update.subEvents.push(n.transactionMeta.update),r.on.transactionApplying.next(null)}function J1(t,e,n){const{epoch:r,actionContinuities:a}=t.transactionMeta;a.set(e,n),r.has(e)||r.set(e,-1)}function Jk(t){return{store:t}}const Xk=(t,e,n,r)=>{const a=Re(t),u={parent:a,child:null,on:a.on,loggers:a.loggers,logger:a.logger,config:a.config,atoms:new Xn(a.atoms),atomsThatAreDefault:new Set(a.atomsThatAreDefault),families:new Xn(a.families),joins:new Xn(a.joins),operation:{open:!1},readonlySelectors:new Xn(a.readonlySelectors),timelines:new Xn(a.timelines),timelineTopics:a.timelineTopics.overlay(),trackers:new Map,transactions:new Xn(a.transactions),selectorAtoms:a.selectorAtoms.overlay(),selectorGraph:a.selectorGraph.overlay(),writableSelectors:new Xn(a.writableSelectors),valueMap:new Xn(a.valueMap),defaults:a.defaults,disposalTraces:t.disposalTraces.copy(),molecules:new Xn(a.molecules),moleculeGraph:a.moleculeGraph.overlay(),moleculeData:a.moleculeData.overlay(),keyRefsInJoins:a.keyRefsInJoins.overlay(),miscResources:new Xn(a.miscResources)},c=Fk(t,e.key),f={phase:"building",update:{type:"transaction_outcome",token:e,id:r,epoch:c===void 0?NaN:c+1,timestamp:Date.now(),subEvents:[],params:n,output:void 0},toolkit:{get:((...m)=>An(h,...m)),set:((...m)=>{Lt(h,...m)}),reset:((...m)=>{ny(h,...m)}),run:(m,y=af())=>Jm(h,m,y),find:((...m)=>Pr(t,...m)),json:m=>Rs(h,m),dispose:((...m)=>{lf(h,...m)}),env:()=>Jk(h)}},h=Object.assign(u,{transactionMeta:f});return a.child=h,t.logger.info("🛫","transaction",e.key,"building with params:",n),h};function X1(t,e){const{key:n}=e,r=t.transactions.has(n),a={key:n,type:"transaction",run:(c,f)=>{const h=Xk(t,zr(a),c,f);try{const{toolkit:m}=h.transactionMeta,y=e.do(m,...c);return Yk(h,y),y}catch(m){throw Lk(h),t.logger.warn("💥","transaction",n,"caught:",m),m}},install:c=>X1(c,e),subject:new We};Re(t).transactions.set(n,a);const u=zr(a);return r||t.on.transactionCreation.next(u),u}var Zk=class{parent=null;child=null;valueMap=new Map;defaults=new Map;atoms=new Map;writableSelectors=new Map;readonlySelectors=new Map;atomsThatAreDefault=new Set;selectorAtoms=new qi({between:["selectorKey","atomKey"],cardinality:"n:n"});selectorGraph=new qi({between:["upstreamSelectorKey","downstreamSelectorKey"],cardinality:"n:n"},{makeContentKey:(...t)=>t.sort().join(":")});trackers=new Map;families=new Map;joins=new Map;transactions=new Map;transactionMeta={epoch:new Map,actionContinuities:new qi({between:["continuity","action"],cardinality:"1:n"})};timelines=new Map;timelineTopics=new qi({between:["timelineKey","topicKey"],cardinality:"1:n"});disposalTraces=new jk(100);molecules=new Map;moleculeGraph=new qi({between:["upstreamMoleculeKey","downstreamMoleculeKey"],cardinality:"n:n"},{makeContentKey:(...t)=>t.sort().join(":")});moleculeData=new qi({between:["moleculeKey","stateFamilyKey"],cardinality:"n:n"},{makeContentKey:(...t)=>t.sort().join(":")});keyRefsInJoins=new qi({between:["moleculeKey","joinKey"],cardinality:"n:n"},{makeContentKey:(...t)=>t.sort().join(":")});miscResources=new Map;on={atomCreation:new We,atomDisposal:new We,selectorCreation:new We,selectorDisposal:new We,timelineCreation:new We,transactionCreation:new We,transactionApplying:new $k(null),operationClose:new We,moleculeCreation:new We,moleculeDisposal:new We};operation={open:!1};config={name:"IMPLICIT_STORE",lifespan:"ephemeral",isProduction:!0};loggers=[new Ek("warn",(t,e,n)=>!zk(n))];logger={error:(...t)=>{for(const e of this.loggers)e.error(...t)},info:(...t)=>{for(const e of this.loggers)e.info(...t)},warn:(...t)=>{for(const e of this.loggers)e.warn(...t)}};constructor(t,e=null){if(this.config={...e?.config,...t},e!==null){this.operation={...e?.operation},ul(e)&&(this.transactionMeta={epoch:new Map(e?.transactionMeta.epoch),actionContinuities:new qi(e?.transactionMeta.actionContinuities.toJSON())});for(const[,r]of e.families)r.internalRoles?.includes("mutable")||r.internalRoles?.includes("join")||r.install(this);const n=new Set;for(const[,r]of e.atoms)if(!n.has(r.key)&&(r.install(this),r.type==="mutable_atom")){const a=Rs(e,r),u=lT(r);n.add(a.key),n.add(u.key)}for(const[,r]of e.readonlySelectors)r.install(this);for(const[,r]of e.writableSelectors)n.has(r.key)||r.install(this);for(const[,r]of e.transactions)r.install(this);for(const[,r]of e.timelines)r.install(this)}}};const Jt={get STORE(){return globalThis.ATOM_IO_IMPLICIT_STORE??=new Zk({name:"IMPLICIT_STORE",lifespan:"ephemeral",isProduction:!0}),globalThis.ATOM_IO_IMPLICIT_STORE}};var Qk=class extends Error{constructor(t,e){super(`${Kr[t.type]} ${zt(t.key)} not found in store "${e.config.name}".`)}};function ct(t,e){let n,r=t;for(;r!==null;){switch(e.type){case"atom":case"mutable_atom":n=r.atoms.get(e.key);break;case"writable_pure_selector":case"writable_held_selector":n=r.writableSelectors.get(e.key);break;case"readonly_pure_selector":case"readonly_held_selector":n=r.readonlySelectors.get(e.key);break;case"atom_family":case"mutable_atom_family":case"writable_pure_selector_family":case"readonly_pure_selector_family":case"writable_held_selector_family":case"readonly_held_selector_family":n=r.families.get(e.key);break;case"timeline":n=r.timelines.get(e.key);break;case"transaction":n=r.transactions.get(e.key);break}if(n)return n;r=r.child}throw new Qk(e,t)}function Z1(t,e,n,r){const a=t.disposalTraces.buffer.find(u=>u?.key===zt(r));switch(t.logger.error("❌",e.type,e.key,"gets a fallback value because key",r,"is not allocated",a?`This key was previously disposed:
|
|
13
|
+
${a.trace}`:"(no previous disposal trace found)"),n.type){case"mutable_atom_family":{if(t.defaults.has(n.key))return t.defaults.get(n.key);const u=new n.class;return t.defaults.set(n.key,u),u.READONLY_VIEW}case"atom_family":{if(t.defaults.has(n.key))return t.defaults.get(n.key);const u=n.default,c=u(r);return t.defaults.set(n.key,c),c}case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if(t.defaults.has(n.key))return t.defaults.get(n.key);const u=n.default(r);return t.defaults.set(n.key,u),u}}}function jc(t,e){const{type:n,key:r,catch:a}=e;switch(n){case"readonly_pure_selector":case"writable_pure_selector":{let u;t.logger.info("🧮",n,r,"computing value");try{if(u=e.getFrom(t),u instanceof Promise)return u.catch(c=>{if(t.logger.error("💥",n,r,"rejected:",c),a){for(const f of a)if(c instanceof f)return c}throw c})}catch(c){if(t.logger.error("💥",n,r,"rejected:",c),a){for(const f of a)if(c instanceof f)return Kn(t,e,c)}throw c}return Kn(t,e,u)}case"atom":{let u;if(Br(e.default))try{u=e.default(),u instanceof Promise&&(u=u.catch(c=>{if(t.logger.error("💥",n,r,"rejected:",c),a){for(const f of a)if(c instanceof f)return c}throw c}))}catch(c){if(t.logger.error("💥",n,r,"rejected:",c),a){for(const f of a)if(c instanceof f)return u=Kn(t,e,c),t.logger.info("✨",e.type,r,"computed default",u),u}throw c}else u=e.default,t.logger.info("✨",e.type,r,"using static default",u);return Kn(t,e,u)}}}function _s(t,e,n){if(t.valueMap.has(e.key))return uT(t,e,n);t.logger.info("❔",e.type,e.key,"value not found in cache");const{key:r}=e;switch(e.type){case"readonly_held_selector":case"writable_held_selector":return t.logger.info("🧮",e.type,r,"computing value"),e.getFrom(t);case"writable_pure_selector":case"readonly_pure_selector":case"atom":return jc(t,e);case"mutable_atom":{const a=new e.class;return t.logger.info("✨",e.type,r,"created new instance",a),Kn(t,e,a)}}}function Qm(t,e){return ct(t,{key:e.family.key,type:`${e.type}_family`})}const kS={atom_family:"atom",molecule_family:"molecule",mutable_atom_family:"mutable_atom",readonly_held_selector_family:"readonly_held_selector",readonly_pure_selector_family:"readonly_pure_selector",writable_held_selector_family:"writable_held_selector",writable_pure_selector_family:"writable_pure_selector"},cl=Symbol("MUST_CREATE"),Wk=Symbol("DO_NOT_CREATE");function fl(t,e,n,r){const a=zt(r),u=e.molecules.get(a);if(!u&&e.config.lifespan==="immortal"){const{type:f,key:h}=n;return e.logger.warn("💣","key",a,"was used to mint a counterfeit token for",f,`"${h}"`),{counterfeit:!0,key:`${h}(${a})`,type:kS[f],family:{key:h,subKey:a}}}let c;if(t===cl)e.logger.info("👪",n.type,n.key,"adds member",typeof r=="string"?`\`${r}\``:r),c=n.create(r),u&&e.moleculeData.set(a,n.key);else{const{type:f,key:h}=n;return{key:`${h}(${a})`,type:kS[f],family:{key:h,subKey:a}}}return c}function Wm(t,...e){let n,r,a,u,c;if(e.length===1){if(c=e[0],"family"in c){const h=Qm(t,c);if(a=ct(t,h),u=qr(c.family.subKey),n=dl(t,h,u),"counterfeit"in c)return{token:c,family:a,subKey:u,isNew:!1};n?c=n:(r=fl(cl,t,h,u),c=r)}}else a=ct(t,e[0]),u=e[1],n=dl(t,a,u),n?c=n:(r=fl(cl,t,a,u),c=r);const f="counterfeit"in c;if(r&&f===!1&&a){let h;switch(c.type){case"readonly_pure_selector":case"readonly_held_selector":h="readable";break;case"atom":case"mutable_atom":case"writable_pure_selector":case"writable_held_selector":h="writable";break}const m={type:"state_creation",subType:h,token:c,timestamp:Date.now()};a.subject.next(m);const y=Re(t);if(c.family)if(ul(y))switch(c.type){case"atom":case"mutable_atom":t.on.atomCreation.next(c);break;case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":t.on.selectorCreation.next(c);break}else Tn(y)&&y.on.transactionApplying.state===null&&y.transactionMeta.update.subEvents.push(m)}return{token:c,family:a,subKey:u,isNew:!!r}}function An(t,...e){const{token:n,family:r,subKey:a}=Wm(t,...e);return"counterfeit"in n&&r&&a?Z1(t,n,r,a):_s(t,ct(t,n))}function dl(t,e,n){const r=zt(n),a=`${e.key}(${r})`,u=Re(t);let c;switch(e.type){case"atom_family":case"mutable_atom_family":c=u.atoms.get(a);break;case"writable_held_selector_family":case"writable_pure_selector_family":c=u.writableSelectors.get(a);break;case"readonly_held_selector_family":case"readonly_pure_selector_family":c=u.readonlySelectors.get(a);break}return c&&zr(c)}function Pr(t,e,n){const r=ct(t,e),a=dl(t,e,n);return a||fl(Wk,t,r,n)}function Bc(t,e,n){const r=e.key,a="readonly_pure_selector_family",u={key:r,type:a},c=t.families.get(r);c&&t.config.isProduction===!0&&t.logger.error("❗",a,r,`Overwriting an existing ${Kr[c.type]} "${c.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const f=new We,m={...u,create:y=>{const g=zt(y),v={key:r,subKey:g},S=`${r}(${g})`,x=Re(t),T={key:S,get:e.get(y)};return e.catch&&(T.catch=e.catch),sy(x,T,v)},internalRoles:n,subject:f,install:y=>Bc(y,e),default:y=>e.get(y)({get:((...g)=>An(t,...g)),find:((...g)=>Pr(t,...g)),json:g=>Rs(t,g)})};return t.families.set(r,m),u}function ey(t,e,n){const r={key:e.key,type:"atom_family"},a=t.families.get(e.key);a&&t.config.isProduction===!0&&t.logger.error("❗","atom_family",e.key,`Overwriting an existing ${Kr[a.type]} "${a.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const u=new We,f={...r,create:h=>{const m=zt(h),y={key:e.key,subKey:m},g=`${e.key}(${m})`,v=Re(t),S=e.default,x={key:g,default:Br(S)?()=>S(h):S};return e.effects&&(x.effects=e.effects(h)),e.catch&&(x.catch=e.catch),ff(v,x,y)},default:e.default,subject:u,install:h=>ey(h,e),internalRoles:n};return t.families.set(e.key,f),Br(e.default)===!1&&t.defaults.set(e.key,e.default),r}function Q1(t,e,n){const r=e.key,a="readonly_held_selector_family",u={key:r,type:a},c=t.families.get(r);c&&t.config.isProduction===!0&&t.logger.error("❗",a,r,`Overwriting an existing ${Kr[c.type]} "${c.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const f=new We,m={...u,create:y=>{const g=zt(y),v={key:r,subKey:g},S=`${r}(${g})`;return ry(Re(t),{key:S,const:e.const(y),get:e.get(y)},v)},internalRoles:n,subject:f,install:y=>Q1(y,e),default:e.const};return t.families.set(r,m),u}function W1(t,e,n){const r=e.key,a="writable_held_selector_family",u={key:r,type:a},c=t.families.get(r);c&&t.config.isProduction===!0&&t.logger.error("❗",a,r,`Overwriting an existing ${Kr[c.type]} "${c.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const f=new We,m={...u,create:y=>{const g=zt(y),v={key:r,subKey:g},S=`${r}(${g})`;return oy(Re(t),{key:S,const:e.const(y),get:e.get(y),set:e.set(y)},v)},internalRoles:n,subject:f,install:y=>W1(y,e),default:e.const};return t.families.set(r,m),u}function ty(t,e,n){const r=e.key,a="writable_pure_selector_family",u={key:r,type:a},c=t.families.get(r);c&&t.config.isProduction===!0&&t.logger.error("❗",a,r,`Overwriting an existing ${Kr[c.type]} "${c.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const f=new We,m={...u,create:y=>{const g=zt(y),v={key:r,subKey:g},S=`${r}(${g})`,x=Re(t),T={key:S,get:e.get(y),set:e.set(y)};return e.catch&&(T.catch=e.catch),ay(x,T,v)},internalRoles:n,subject:f,install:y=>ty(y,e),default:y=>e.get(y)({get:((...g)=>An(t,...g)),find:((...g)=>Pr(t,...g)),json:g=>Rs(t,g)})};return t.families.set(r,m),u}function eM(t,e){const n="set"in e,r="const"in e;return r&&n?W1(t,e,void 0):r?Q1(t,e,void 0):n?ty(t,e):Bc(t,e)}function lf(t,...e){let n;if(e.length===1)n=e[0];else{const r=e[0],a=e[1];n=Pr(t,r,a)}try{ct(t,n)}catch{t.logger.error("❌",n.type,n.key,`could not be disposed because it was not found in the store "${t.config.name}".`);return}switch(n.type){case"atom":case"mutable_atom":dy(t,n);break;case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":lM(t,n);break}}function eT(t,e){if(t.operation.open){const n=performance.now();return t.logger.info("🚫",e.type,e.key,`deferring setState at T-${n} until setState for "${t.operation.token.key}" is done`),n}return t.operation={open:!0,done:new Set,prev:new Map,timestamp:Date.now(),token:e,subEvents:[]},t.logger.info("⭕",e.type,e.key,`operation start in store "${t.config.name}"${Tn(t)?` ${t.transactionMeta.phase} "${t.transactionMeta.update.token.key}"`:""}`),t}function tT(t){t.operation.open&&t.logger.info("🔴",t.operation.token.type,t.operation.token.key,`operation done in store "${t.config.name}"`),t.operation={open:!1},t.on.operationClose.next(t.operation)}const nT=(t,e)=>t.operation.open?t.operation.done.has(e):(t.logger.error("🐞","unknown",e,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0),uf=(t,e)=>{if(!t.operation.open){t.logger.error("🐞","unknown",e,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}t.operation.done.add(e)};function qp(t,e,n,r,a){const{oldValue:u,newValue:c}=n,f="oldValue"in n,h=zr(e);if(r&&a){e.subject.next({newValue:c});const S={checkpoint:!0,type:"state_creation",subType:"writable",token:h,timestamp:Date.now(),value:c};t.operation.subEvents.push(S),a.subject.next(S);const x=Re(t);if(h.family)if(ul(x))switch(h.type){case"atom":case"mutable_atom":t.on.atomCreation.next(h);break;case"writable_pure_selector":case"writable_held_selector":t.on.selectorCreation.next(h);break}else Tn(x)&&x.on.transactionApplying.state===null&&x.transactionMeta.update.subEvents.push(S);return}const{key:m,subject:y,type:g}=e;let v;if(f?v={oldValue:sc(u)?u.READONLY_VIEW:u,newValue:sc(c)?c.READONLY_VIEW:c}:v={newValue:sc(c)?c.READONLY_VIEW:c},ul(t)){switch(g){case"mutable_atom":t.logger.info("📢",g,m,"is now (",c,") subscribers:",y.subscribers.keys());break;case"atom":case"writable_pure_selector":case"writable_held_selector":t.logger.info("📢",g,m,"went (",u,"->",c,") subscribers:",y.subscribers.keys())}y.next(v)}if(Tn(t)&&(g==="mutable_atom"||g==="atom")){if(t.on.transactionApplying.state===null){if(sc(c))return;const{timestamp:S}=t.operation,x={type:"atom_update",token:h,timestamp:S,update:v};t.transactionMeta.update.subEvents.push(x),t.logger.info("📁","atom",m,"stowed (",u,"->",c,")");return}if(fy(e,"tracker:signal")){const S=m.slice(1),x=t.atoms.get(S);_s(t,x,"mut").do(v.newValue)===null&&cy(t,x)}}}const MS=Symbol("UNSET"),Pp=(t,e,n)=>{let r,a;if(Br(n)){const u=_s(t,e,"mut");r=u,a=n(u)}else t.valueMap.has(e.key)?r=uT(t,e,"mut"):e.type==="atom"&&!Br(e.default)?r=e.default:r=MS,a=n;return t.logger.info("⭐","atom",e.key,"setting value",a),a=Kn(t,e,a),uf(t,e.key),cy(t,e),r===MS?{newValue:a}:{oldValue:r,newValue:a}};function Zh(t,e){switch(e.type){case"mutable_atom":return Pp(t,e,new e.class);case"atom":{let n;return Br(e.default)?n=jc(t,e):n=e.default,Pp(t,e,n)}}}function tM(t,e){let n;switch(e.type){case"atom":case"mutable_atom":n=Zh(t,e);break;case"writable_held_selector":{const r=hl(t,e.key);for(const u of r.values())qp(t,e,Zh(t,u),!1);const a=e.getFrom(t);n={oldValue:a,newValue:a}}break;case"writable_pure_selector":{const r=jc(t,e),a=hl(t,e.key);for(const u of a.values())qp(t,e,Zh(t,u),!1);n={oldValue:r,newValue:jc(t,e)}}break}return n}function Lt(t,...e){El(Hp,t,...e)}const Ip=Symbol("RESET");function ny(t,...e){Lt(t,...e,Ip)}function nM(t,e,n){let r,a,u;const{type:c,key:f}=e;switch(e.type){case"writable_pure_selector":r=_s(t,e,"mut"),a=RS(n,r),a=Kn(t,e,a);break;case"writable_held_selector":u=e.const,RS(n,u),r=u,a=u}return t.logger.info("⭐",c,f,"setting to",a),uf(t,f),e.setSelf(a),{oldValue:r,newValue:a}}const iM=(t,e,n)=>{let r;switch(e.type){case"atom":case"mutable_atom":r=Pp(t,e,n);break;case"writable_pure_selector":case"writable_held_selector":r=nM(t,e,n);break}return r},Hp=Symbol("OWN_OP"),iy=Symbol("JOIN_OP");function El(t,e,...n){let r,a,u,c,f,h;n.length===2?(u=n[0],h=n[1],"family"in u&&(c=Qm(e,u),f=qr(u.family.subKey),r=dl(e,c,f),r?u=r:u=a=fl(cl,e,c,f))):(c=ct(e,n[0]),f=n[1],h=n[2],r=dl(e,c,f),r?u=r:u=a=fl(cl,e,c,f));const m=h===Ip?"reset":"set";let y;if(t===Hp){const S=eT(e,u);if(typeof S=="number"){const x=S,T=e.on.operationClose.subscribe(`waiting to ${m} "${u.key}" at T-${x}`,function(){T(),e.logger.info("🟢",u.type,u.key,"resuming deferred",m,`from T-${x}`),El(t,e,u,h)});return}y=S}else y=e;if("counterfeit"in u&&"family"in u){const S=u.family.subKey,x=e.disposalTraces.buffer.find(T=>T?.key===S);e.logger.error("❌",u.type,u.key,"could not be",m,"because key",S,"is not allocated.",x?`this key was previously disposed:${x.trace}`:"(no previous disposal trace found)");return}const g=ct(y,u);let v;h===Ip?v=tM(y,g):v=iM(y,g,h),qp(y,g,v,!!a,c),t===Hp&&tT(y)}const iT=(t,e)=>Re(t).atoms.has(e),rM=(t,e)=>Re(t).writableSelectors.has(e),sM=(t,e)=>Re(t).readonlySelectors.has(e),oM=(t,e)=>iT(t,e)||rM(t,e)||sM(t,e);function DS(t,e){return Re(t).selectorGraph.getRelationEntries({downstreamSelectorKey:e}).filter(([n,{source:r}])=>r!==e).map(([n,{source:r}])=>r).filter(n=>oM(t,n))}function hl(t,e,n=new Set){const r=DS(t,e),a=new Map;for(;r.length>0;){const u=r.pop();if(!n.has(u))if(n.add(u),iT(t,u)){const c=t.atoms.get(u);a.set(c.key,c)}else r.push(...DS(t,u))}return a}function aM(t,e,n,r,a){const u=Re(t),{type:c,key:f}=r;if(c==="atom"||c==="mutable_atom")u.selectorAtoms.set({selectorKey:n,atomKey:f}),t.logger.info("🔍",e,n,`discovers root atom "${f}"`);else{const h=hl(t,f,a);t.logger.info("🔍",e,n,`discovers root atoms: [ ${[...h.values()].map(m=>`"${m.key}"`).join(", ")} ]`);for(const{key:m}of h.values())u.selectorAtoms=u.selectorAtoms.set({selectorKey:n,atomKey:m})}a.add(f)}function cf(t,e,n,r){return{get:(...a)=>{const u=Re(t),{token:c,family:f,subKey:h}=Wm(t,...a);let m;return"counterfeit"in c&&f&&h?m=Z1(t,c,f,h):m=_s(t,ct(t,c)),t.logger.info("🔌",e,n,`registers dependency ( "${c.key}" =`,m,")"),u.selectorGraph.set({upstreamSelectorKey:c.key,downstreamSelectorKey:n},{source:c.key}),aM(t,e,n,c,r),m},set:((...a)=>{El(iy,Re(t),...a)}),find:((...a)=>Pr(t,...a)),json:a=>Rs(t,a)}}function ry(t,e,n){const r=Re(t),a=new We,u=new Set,{key:c,const:f}=e,h="readonly_held_selector";t.logger.info("🔨",h,c,"is being created");const{get:m,find:y,json:g}=cf(r,h,c,u),S={...e,type:h,subject:a,getFrom:T=>{const M=T.selectorGraph.getRelationEntries({downstreamSelectorKey:c});for(const[C,{source:_}]of M)_!==c&&T.selectorGraph.delete(C,c);return T.selectorAtoms.delete(c),e.get({get:m,find:y,json:g},f),Kn(T,S,f),t.logger.info("✨",h,c,"=",f),u.clear(),f},install:T=>ry(T,e,n)};n&&(S.family=n),r.readonlySelectors.set(c,S);const x={key:c,type:h};return n&&(x.family=n),x}function sy(t,e,n){const r=Re(t),a=new We,u=new Set,c=e.key,f="readonly_pure_selector";t.logger.info("🔨",f,c,"is being created");const{get:h,find:m,json:y}=cf(r,f,c,u),v={...e,type:f,subject:a,getFrom:()=>{const x=Re(t),T=x.selectorGraph.getRelationEntries({downstreamSelectorKey:c});for(const[C,{source:_}]of T)_!==c&&x.selectorGraph.delete(C,c);x.selectorAtoms.delete(c);const M=Kn(x,v,e.get({get:h,find:m,json:y}));return t.logger.info("✨",f,c,"=",M),u.clear(),M},install:x=>sy(x,e,n)};n&&(v.family=n),r.readonlySelectors.set(c,v);const S={key:c,type:f};return n&&(S.family=n),S}function oy(t,e,n){const r=Re(t),a=new We,u=new Set,{key:c,const:f}=e,h="writable_held_selector";t.logger.info("🔨",h,c,"is being created");const m=cf(r,h,c,u),{find:y,get:g,json:v}=m,S={find:y,get:g,json:v},M={...e,type:h,subject:a,getFrom:_=>{const R=_.selectorGraph.getRelationEntries({downstreamSelectorKey:c});for(const[G,{source:I}]of R)I!==c&&_.selectorGraph.delete(G,c);return _.selectorAtoms.delete(c),e.get(S,f),Kn(_,M,f),t.logger.info("✨",h,c,"=",f),u.clear(),f},setSelf:()=>{e.set(m,f)},install:_=>oy(_,e,n)};n&&(M.family=n),r.writableSelectors.set(c,M);const C={key:c,type:h};return n&&(C.family=n),C}function ay(t,e,n){const r=Re(t),a=new We,u=new Set,c=e.key,f="writable_pure_selector";t.logger.info("🔨",f,c,"is being created");const h=cf(r,f,c,u),{find:m,get:y,json:g}=h,v={find:m,get:y,json:g},T={...e,type:f,subject:a,getFrom:C=>{const _=C.selectorGraph.getRelationEntries({downstreamSelectorKey:c});for(const[G,{source:I}]of _)I!==c&&C.selectorGraph.delete(G,c);C.selectorAtoms.delete(c);const R=Kn(C,T,e.get(v));return t.logger.info("✨",f,c,"=",R),u.clear(),R},setSelf:C=>{e.set(h,C)},install:C=>ay(C,e,n)};n&&(T.family=n),r.writableSelectors.set(c,T);const M={key:c,type:f};return n&&(M.family=n),M}function rT(t,e){const n="set"in e,r="const"in e;if(r&&n){const u=oy(t,e,void 0);return t.on.selectorCreation.next(u),u}if(r){const u=ry(t,e,void 0);return t.on.selectorCreation.next(u),u}if(n){const u=ay(t,e,void 0);return t.on.selectorCreation.next(u),u}const a=sy(t,e,void 0);return t.on.selectorCreation.next(a),a}function lM(t,e){const n=Re(t),{key:r,type:a,family:u}=e;if(!u)t.logger.error("❌",a,r,"Standalone selectors cannot be disposed.");else{n.molecules.get(u.subKey)&&n.moleculeData.delete(u.subKey,u.key);let c;switch(e.type){case"writable_held_selector":n.writableSelectors.delete(r),c={key:u.key,type:"writable_held_selector_family"},ct(t,c).subject.next({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()});break;case"writable_pure_selector":n.writableSelectors.delete(r),c={key:u.key,type:"writable_pure_selector_family"},ct(t,c).subject.next({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()});break;case"readonly_held_selector":n.readonlySelectors.delete(r),c={key:u.key,type:"readonly_held_selector_family"},ct(t,c).subject.next({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()});break;case"readonly_pure_selector":n.readonlySelectors.delete(r),c={key:u.key,type:"readonly_pure_selector_family"},ct(t,c).subject.next({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()});break}n.valueMap.delete(r),n.selectorAtoms.delete(r),n.selectorGraph.delete(r),n.moleculeData.delete(u.key,u.subKey),t.logger.info("🔥",e.type,r,"deleted"),Tn(n)&&n.transactionMeta.phase==="building"?n.transactionMeta.update.subEvents.push({type:"state_disposal",subType:"selector",token:e,timestamp:Date.now()}):t.on.selectorDisposal.next(e)}}const uM=(t,e)=>{const n=Re(t);return n.operation.open?n.operation.prev.get(e.key):n.valueMap.get(e.key)},NS=(t,e,n)=>n.subject.subscribe(`${e.type}:${e.key}`,r=>{t.logger.info("📢",e.type,e.key,"root",n.key,"went",r.oldValue,"->",r.newValue);const a=uM(t,e),u=_s(t,e);t.logger.info("✨",e.type,e.key,"went",a,"->",u),e.subject.next({newValue:u,oldValue:a})});function Bo(t,e,n,r){function a(g){if(t.operation.open){if(u?.type==="atom"&&fy(u,"tracker:signal")&&"*"+t.operation.token.key===e.key&&"inboundTracker"in r)return;const v=t.on.operationClose.subscribe(`state subscription ${n}`,()=>{v(),r(g)})}else r(g)}Wm(t,e);const u=ct(t,e);t.logger.info("👀",u.type,u.key,`Adding subscription "${n}"`);const c=u.type==="writable_pure_selector"||u.type==="readonly_pure_selector",f=new Map;let h=a;if(c){_s(t,u);for(const[g,v]of hl(t,u.key))f.set(g,NS(t,u,v));h=function(v){const S=hl(t,u.key);for(const[x,T]of f)S.get(x)?S.delete(x):(T(),f.delete(x));for(const[x,T]of S)f.set(x,NS(t,u,T));a(v)}}const m=u.subject.subscribe(n,h);return()=>{t.logger.info("🙈",u.type,u.key,`Removing subscription "${n}"`),m();for(const g of f.values())g()}}const sT=(t,e,n,r)=>{const a=ct(t,e);t.logger.info("👀","timeline",e.key,`Adding subscription "${n}"`);const u=a.subject.subscribe(n,r);return()=>{t.logger.info("🙈","timeline",e.key,`Removing subscription "${n}" from timeline`),u()}},oT=(t,e,n,r)=>{const a=ct(t,e);t.logger.info("👀","transaction",e.key,`Adding subscription "${n}"`);const u=a.subject.subscribe(n,r);return()=>{t.logger.info("🙈","transaction",e.key,`Removing subscription "${n}"`),u()}};function cM(t,e,n,r=af()){switch(e.type){case"atom":case"mutable_atom":case"readonly_pure_selector":case"readonly_held_selector":case"writable_pure_selector":case"writable_held_selector":return Bo(t,e,r,n);case"transaction":return oT(t,e,r,n);case"timeline":return sT(t,e,r,n)}}var ly=class{initializeSignalAtom(t,e){const n=`*${t.key}`;e.atoms.delete(n),e.valueMap.delete(n);const r=t.family?{key:`*${t.family.key}`,subKey:t.family.subKey}:void 0,a=ff(e,{key:n,default:null},r,["tracker:signal"]);if(e.parent?.valueMap.has(n)){const u=e.parent.valueMap.get(n);e.valueMap.set(n,u)}return a}unsubscribeFromInnerValue;unsubscribeFromState;captureSignalsFromCore(t,e,n){const r=t.key,a=`tracker-from-core:${n.config.name}:${Tn(n)?n.transactionMeta.update.token.key:"main"}:${r}`,u=c=>{El(iy,n,e,c)};this.unsubscribeFromInnerValue=An(n,t).subscribe(a,u),this.unsubscribeFromState=Bo(n,t,a,(function(f){f.newValue!==f.oldValue&&(this.unsubscribeFromInnerValue(),this.unsubscribeFromInnerValue=f.newValue.subscribe(a,u))}).bind(this))}supplySignalsToCore(t,e,n){const r=t.key,a=`tracker-to-core:${n.config.name}:${Tn(n)?n.transactionMeta.update.token.key:"main"}:${r}`;Bo(n,e,a,Object.assign(function({newValue:c,oldValue:f}){const h=n.timelineTopics.getRelatedKey(e.key);if(h&&n.timelines.get(h)?.timeTraveling){const m=sT(n,{key:h,type:"timeline"},a,function(g){m(),Lt(n,t,v=>(g==="redo"&&c?v.do(c):g==="undo"&&f&&v.undo(f),v))});return}Lt(n,t,m=>(m.do(c),m))},{inboundTracker:!0}))}mutableAtomToken;latestSignalToken;[Symbol.dispose];constructor(t,e){const n=Re(e),r=this.initializeSignalAtom(t,n);this.mutableAtomToken=t,this.latestSignalToken=r,this.captureSignalsFromCore(t,r,n),this.supplySignalsToCore(t,r,n),n.trackers.set(t.key,this),this[Symbol.dispose]=()=>{this.unsubscribeFromInnerValue(),this.unsubscribeFromState(),n.trackers.delete(t.key)}}};function uy(t,e,n){t.logger.info("🔨","atom",e.key,`creating in store "${t.config.name}"`);const r=Re(t),{key:a}=e,u=r.atoms.get(a),c="mutable_atom";if(u?.type===c&&t.config.isProduction===!0)return t.logger.error("❌",c,a,"Tried to create atom, but it already exists in the store."),zr(u);const f=new We,h={...e,type:c,install:y=>(y.logger.info("🛠️","atom",a,`installing in store "${y.config.name}"`),uy(y,e,n)),subject:f};n&&(h.family=n),r.atoms.set(h.key,h);const m=zr(h);if(new ly(m,t),n||rT(t,{key:`${a}:JSON`,get:({get:y})=>y(m).toJSON(),set:({set:y},g)=>{y(m,e.class.fromJSON(g))}}),e.effects){let y=0;const g=[];for(const v of e.effects){const S=v({resetSelf:()=>{ny(t,m)},setSelf:x=>{Lt(t,m,x)},onSet:x=>Bo(t,m,`effect[${y}]`,x),token:m,store:Ym(t)});S&&g.push(S),++y}h.cleanup=()=>{for(const v of g)v()}}return t.on.atomCreation.next(m),m}var fM=class{trackers=new Map;latestSignalAtoms;mutableAtoms;constructor(t,e){this.latestSignalAtoms=ct(e,ey(e,{key:`*${t.key}`,default:null},["mutable","updates"])),this.mutableAtoms=t;const n=r=>{const{type:a,token:u}=r;if(u.family){const c=qr(u.family.subKey);switch(a){case"state_creation":this.trackers.set(c,new ly(u,e));break;case"state_disposal":{const f=this.trackers.get(c);f&&(f[Symbol.dispose](),this.trackers.delete(c))}}}};this.mutableAtoms.subject.subscribe(`store=${e.config.name}::tracker-atom-family`,n)}};function aT(t,e,n){const r={key:e.key,type:"mutable_atom_family"},a=t.families.get(e.key);a&&t.config.isProduction===!0&&t.logger.error("❗","mutable_atom_family",e.key,`Overwriting an existing ${Kr[a.type]} "${a.key}" in store "${t.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);const u=new We,f={...r,create:h=>{const m=zt(h),y={key:e.key,subKey:m},g=`${e.key}(${m})`,v=Re(t),S={key:g,class:e.class};return e.effects&&(S.effects=e.effects(h)),uy(v,S,y)},class:e.class,subject:u,install:h=>aT(h,e),internalRoles:n};return t.families.set(e.key,f),ty(t,{key:`${e.key}:JSON`,get:h=>({get:m})=>m(r,h).toJSON(),set:h=>({set:m},y)=>{m(r,h,e.class.fromJSON(y))}},["mutable","json"]),new fM(f,t),r}const dM=(t,e)=>{const n=Re(e),r=`${t.key}:JSON`;return n.families.get(r)},Rs=(t,e)=>e.family?Pr(t,ct(Re(t),{key:`${e.family.key}:JSON`,type:"writable_pure_selector_family"}),qr(e.family.subKey)):{type:"writable_pure_selector",key:`${e.key}:JSON`},lT=t=>{const e={type:"atom",key:`*${t.key}`};return t.family&&(e.family={key:`*${t.family.key}`,subKey:t.family.subKey}),e};function sc(t){return typeof t=="object"&&t!==null&&"do"in t&&"undo"in t&&"subscribe"in t&&"READONLY_VIEW"in t&&"toJSON"in t}function Kn(t,e,n){const{key:r,subject:a,type:u}=e,c=t.valueMap.get(r);if(c instanceof Kp&&!c.done){const f=c;return n instanceof Promise?(f.use(n),f):(t.valueMap.set(r,n),n)}if(n instanceof Promise){const f=new Kp(n);return t.valueMap.set(r,f),f.then(function(m){if(t.valueMap.get(r)===f){switch(eT(t,e),Kn(t,e,m),u){case"atom":cy(t,e);break;case"readonly_pure_selector":case"writable_pure_selector":fT(t,r);break}tT(t),a.next({newValue:m,oldValue:f})}}).catch(h=>{t.logger.error("💥",e.type,r,"rejected:",h)}),f}return t.logger.info("📝",e.type,e.key,"writing to cache",n),t.valueMap.set(r,n),n}function uT(t,e,n){t.logger.info("📖",e.type,e.key,"reading cached value");let r=t.valueMap.get(e.key);if(n==="mut"&&e.type==="mutable_atom"&&Tn(t)){const a=e,{parent:u}=t;if(t.valueMap.hasOwn(a.key))return r;const c=u.valueMap.get(a.key);t.logger.info("📃","atom",a.key,"copying");const f=c.toJSON(),h=a.class.fromJSON(f);t.valueMap.set(a.key,h),new ly(a,u),r=h}return r}function cT(t,e){const n=t.valueMap.get(e);if(n instanceof Kp){const r=t.writableSelectors.get(e)??t.readonlySelectors.get(e);r&&r.getFrom(t);return}t.operation.open&&t.operation.prev.set(e,n),t.valueMap.delete(e),t.logger.info("🗑","state",e,"evicted")}function cy(t,e){const n=Re(t),{key:r,type:a}=e,u=n.selectorAtoms.getRelatedKeys(r);if(n.logger.info("🧹",a,r,u?`evicting ${u.size} states downstream:`:"no downstream states",u??"to evict"),u){n.operation.open&&n.logger.info("🧹",a,r,`[ ${[...n.operation.done].join(", ")} ] already done`);for(const c of u)nT(n,c)||(cT(n,c),uf(n,c))}}function fT(t,e){const n=Re(t),r=n.selectorGraph.getRelationEntries({upstreamSelectorKey:e}).filter(([a,{source:u}])=>u===e);for(const[a]of r)nT(n,a)||(cT(n,a),uf(n,a),fT(t,a))}function ff(t,e,n,r){const a="atom",{key:u}=e;t.logger.info("🔨",a,u,"is being created");const c=Re(t),f=c.atoms.get(u);if(f?.type===a&&t.config.isProduction===!0)return t.logger.error("❌","atom",u,"Tried to create atom, but it already exists in the store."),zr(f);const h=new We,m={...e,type:a,install:g=>(g.logger.info("🛠️",a,u,`installing in store "${g.config.name}"`),ff(g,e,n)),subject:h};n&&(m.family=n),r&&(m.internalRoles=r),c.atoms.set(u,m);const y=zr(m);if(e.effects){let g=0;const v=[];for(const S of e.effects){const x=S({resetSelf:()=>{ny(t,y)},setSelf:T=>{Lt(t,y,T)},onSet:T=>Bo(t,y,`effect[${g}]`,T),token:y,store:Ym(t)});x&&v.push(x),++g}m.cleanup=()=>{for(const S of v)S()}}return t.on.atomCreation.next(y),y}function fy(t,e){return"internalRoles"in t?t.internalRoles.includes(e):!1}function dy(t,e){const n=Re(t),{key:r,family:a}=e,u=ct(n,e);if(!a)t.logger.error("❌","atom",r,"Standalone atoms cannot be disposed.");else{u.cleanup?.();const c=t.valueMap.get(u.key),f=ct(t,Qm(t,e)).subject,h={type:"state_disposal",subType:"atom",token:e,value:c,timestamp:Date.now()};f.next(h);const m=Tn(n);if(n.atoms.delete(r),n.valueMap.delete(r),n.selectorAtoms.delete(r),n.atomsThatAreDefault.delete(r),n.moleculeData.delete(a.key,a.subKey),t.timelineTopics.delete(r),e.type==="mutable_atom"&&(dy(t,lT(e)),t.trackers.delete(r)),t.logger.info("🔥","atom",r,"deleted"),m&&n.transactionMeta.phase==="building"){const y=n.transactionMeta.update.subEvents.at(-1),g=y?.type==="molecule_disposal"&&y.values.some(([S])=>S===u.family?.key),v=fy(u,"tracker:signal");!g&&!v&&n.transactionMeta.update.subEvents.push(h)}else t.on.atomDisposal.next(e)}}function hs(t){return t[0].toUpperCase()+t.slice(1)}var dT=class{toolkit;options;relations;states;relatedKeysAtoms;transact(t,e){const n=this.toolkit;this.toolkit=t,e(this),this.toolkit=n}store;[Symbol.dispose](){}constructor(t,e){this.store=t,this.options=e,this.store.miscResources.set(`join:${e.key}`,this),this.toolkit={get:((...y)=>An(t,...y)),set:((...y)=>{Lt(t,...y)}),find:((...y)=>Pr(t,...y)),json:y=>Rs(t,y)};const n=e.between[0],r=e.between[1],a=aT(t,{key:`${e.key}/relatedKeys`,class:K1},["join","relations"]);this.relatedKeysAtoms=a;const u=(y,g,v)=>{const{find:S,get:x,set:T}=y,M=S(a,g),C=x(M);for(const _ of C)v.includes(_)||T(a,_,R=>(R.delete(g),R));T(M,_=>{_.clear();for(const R of v){const G=S(a,R),I=x(G),ee=I.has(g);if(this.relations.cardinality==="1:n"){const J=[];for(const X of I){if(X===g)continue;let he;El(iy,this.store,a,X,pe=>(pe.delete(R),he=pe.size,pe)),he===0&&J.push(X)}!ee&&I.size>0&&T(G,X=>(X.clear(),X));for(const X of J)t.keyRefsInJoins.delete(Sc(R,X))}ee||T(G,J=>(J.add(g),J)),_.add(R)}return _})},c=(y,g,v)=>{const{set:S}=y;S(a,g,x=>{for(const T of v)x.add(T);return x});for(const x of v)S(a,x,T=>(T.add(g),T));return!0},f=new qi(e,{externalStore:{getRelatedKeys:y=>this.toolkit.get(a,y),addRelation:(y,g)=>{this.store.keyRefsInJoins.set(`"${y}"`,e.key),this.store.keyRefsInJoins.set(`"${g}"`,e.key),this.store.keyRefsInJoins.set(Sc(y,g),e.key),this.toolkit.set(a,y,v=>v.add(g)),this.toolkit.set(a,g,v=>v.add(y))},deleteRelation:(y,g)=>{this.toolkit.set(a,y,S=>(S.delete(g),S)),this.toolkit.set(a,g,S=>(S.delete(y),S));const v=Sc(y,g);this.store.keyRefsInJoins.delete(v)},replaceRelationsSafely:(y,g)=>{u(this.toolkit,y,g)},replaceRelationsUnsafely:(y,g)=>{c(this.toolkit,y,g)},has:(y,g)=>{const v=this.toolkit.get(a,y);return g?v.has(g):v.size>0}},isAType:e.isAType,isBType:e.isBType}),h=()=>Bc(t,{key:`${e.key}/singleRelatedKey`,get:y=>({get:g})=>{const v=g(a,y);for(const S of v)return S;return null}},["join","keys"]),m=()=>Bc(t,{key:`${e.key}/multipleRelatedKeys`,get:y=>({get:g})=>g(dM(a,t),y)},["join","keys"]);switch(e.cardinality){case"1:1":{const y=h(),g=`${n}KeyOf${hs(r)}`,v=`${r}KeyOf${hs(n)}`;this.relations=f,this.states={[g]:y,[v]:y};break}case"1:n":{const y=h(),g=m(),v=`${n}KeyOf${hs(r)}`,S=`${r}KeysOf${hs(n)}`,x={[v]:y,[S]:g};this.relations=f,this.states=x;break}case"n:n":{const y=m(),g=`${n}KeysOf${hs(r)}`,v=`${r}KeysOf${hs(n)}`;this.relations=f,this.states={[g]:y,[v]:y}}}}};function hM(t,e){return t.joins.set(e.key,new dT(t,e)),{key:e.key,type:"join",a:e.between[0],b:e.between[1],cardinality:e.cardinality}}function pM(t,e){let n=t.joins.get(e.key);if(n===void 0){const r=Jt.STORE.joins.get(e.key);if(r===void 0)throw new Error(`Join "${e.key}" not found in store "${t.config.name}"`);n=new dT(Ym(t),r.options),t.joins.set(e.key,n)}return n}function mM(t,e,n){const r=pM(t,e);return[r.relatedKeysAtoms,r.relatedKeysAtoms]}var Qh={exports:{}},ye={};var $S;function yM(){if($S)return ye;$S=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.iterator;function S(E){return E===null||typeof E!="object"?null:(E=v&&E[v]||E["@@iterator"],typeof E=="function"?E:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,M={};function C(E,q,H){this.props=E,this.context=q,this.refs=M,this.updater=H||x}C.prototype.isReactComponent={},C.prototype.setState=function(E,q){if(typeof E!="object"&&typeof E!="function"&&E!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,E,q,"setState")},C.prototype.forceUpdate=function(E){this.updater.enqueueForceUpdate(this,E,"forceUpdate")};function _(){}_.prototype=C.prototype;function R(E,q,H){this.props=E,this.context=q,this.refs=M,this.updater=H||x}var G=R.prototype=new _;G.constructor=R,T(G,C.prototype),G.isPureReactComponent=!0;var I=Array.isArray;function ee(){}var J={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function he(E,q,H){var Q=H.ref;return{$$typeof:t,type:E,key:q,ref:Q!==void 0?Q:null,props:H}}function pe(E,q){return he(E.type,q,E.props)}function we(E){return typeof E=="object"&&E!==null&&E.$$typeof===t}function je(E){var q={"=":"=0",":":"=2"};return"$"+E.replace(/[=:]/g,function(H){return q[H]})}var ve=/\/+/g;function Z(E,q){return typeof E=="object"&&E!==null&&E.key!=null?je(""+E.key):q.toString(36)}function ne(E){switch(E.status){case"fulfilled":return E.value;case"rejected":throw E.reason;default:switch(typeof E.status=="string"?E.then(ee,ee):(E.status="pending",E.then(function(q){E.status==="pending"&&(E.status="fulfilled",E.value=q)},function(q){E.status==="pending"&&(E.status="rejected",E.reason=q)})),E.status){case"fulfilled":return E.value;case"rejected":throw E.reason}}throw E}function j(E,q,H,Q,re){var ce=typeof E;(ce==="undefined"||ce==="boolean")&&(E=null);var Te=!1;if(E===null)Te=!0;else switch(ce){case"bigint":case"string":case"number":Te=!0;break;case"object":switch(E.$$typeof){case t:case e:Te=!0;break;case y:return Te=E._init,j(Te(E._payload),q,H,Q,re)}}if(Te)return re=re(E),Te=Q===""?"."+Z(E,0):Q,I(re)?(H="",Te!=null&&(H=Te.replace(ve,"$&/")+"/"),j(re,q,H,"",function(ii){return ii})):re!=null&&(we(re)&&(re=pe(re,H+(re.key==null||E&&E.key===re.key?"":(""+re.key).replace(ve,"$&/")+"/")+Te)),q.push(re)),1;Te=0;var Ct=Q===""?".":Q+":";if(I(E))for(var Je=0;Je<E.length;Je++)Q=E[Je],ce=Ct+Z(Q,Je),Te+=j(Q,q,H,ce,re);else if(Je=S(E),typeof Je=="function")for(E=Je.call(E),Je=0;!(Q=E.next()).done;)Q=Q.value,ce=Ct+Z(Q,Je++),Te+=j(Q,q,H,ce,re);else if(ce==="object"){if(typeof E.then=="function")return j(ne(E),q,H,Q,re);throw q=String(E),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(E).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return Te}function U(E,q,H){if(E==null)return E;var Q=[],re=0;return j(E,Q,"","",function(ce){return q.call(H,ce,re++)}),Q}function L(E){if(E._status===-1){var q=E._result;q=q(),q.then(function(H){(E._status===0||E._status===-1)&&(E._status=1,E._result=H)},function(H){(E._status===0||E._status===-1)&&(E._status=2,E._result=H)}),E._status===-1&&(E._status=0,E._result=q)}if(E._status===1)return E._result.default;throw E._result}var te=typeof reportError=="function"?reportError:function(E){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof E=="object"&&E!==null&&typeof E.message=="string"?String(E.message):String(E),error:E});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",E);return}console.error(E)},oe={map:U,forEach:function(E,q,H){U(E,function(){q.apply(this,arguments)},H)},count:function(E){var q=0;return U(E,function(){q++}),q},toArray:function(E){return U(E,function(q){return q})||[]},only:function(E){if(!we(E))throw Error("React.Children.only expected to receive a single React element child.");return E}};return ye.Activity=g,ye.Children=oe,ye.Component=C,ye.Fragment=n,ye.Profiler=a,ye.PureComponent=R,ye.StrictMode=r,ye.Suspense=h,ye.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=J,ye.__COMPILER_RUNTIME={__proto__:null,c:function(E){return J.H.useMemoCache(E)}},ye.cache=function(E){return function(){return E.apply(null,arguments)}},ye.cacheSignal=function(){return null},ye.cloneElement=function(E,q,H){if(E==null)throw Error("The argument must be a React element, but you passed "+E+".");var Q=T({},E.props),re=E.key;if(q!=null)for(ce in q.key!==void 0&&(re=""+q.key),q)!X.call(q,ce)||ce==="key"||ce==="__self"||ce==="__source"||ce==="ref"&&q.ref===void 0||(Q[ce]=q[ce]);var ce=arguments.length-2;if(ce===1)Q.children=H;else if(1<ce){for(var Te=Array(ce),Ct=0;Ct<ce;Ct++)Te[Ct]=arguments[Ct+2];Q.children=Te}return he(E.type,re,Q)},ye.createContext=function(E){return E={$$typeof:c,_currentValue:E,_currentValue2:E,_threadCount:0,Provider:null,Consumer:null},E.Provider=E,E.Consumer={$$typeof:u,_context:E},E},ye.createElement=function(E,q,H){var Q,re={},ce=null;if(q!=null)for(Q in q.key!==void 0&&(ce=""+q.key),q)X.call(q,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(re[Q]=q[Q]);var Te=arguments.length-2;if(Te===1)re.children=H;else if(1<Te){for(var Ct=Array(Te),Je=0;Je<Te;Je++)Ct[Je]=arguments[Je+2];re.children=Ct}if(E&&E.defaultProps)for(Q in Te=E.defaultProps,Te)re[Q]===void 0&&(re[Q]=Te[Q]);return he(E,ce,re)},ye.createRef=function(){return{current:null}},ye.forwardRef=function(E){return{$$typeof:f,render:E}},ye.isValidElement=we,ye.lazy=function(E){return{$$typeof:y,_payload:{_status:-1,_result:E},_init:L}},ye.memo=function(E,q){return{$$typeof:m,type:E,compare:q===void 0?null:q}},ye.startTransition=function(E){var q=J.T,H={};J.T=H;try{var Q=E(),re=J.S;re!==null&&re(H,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(ee,te)}catch(ce){te(ce)}finally{q!==null&&H.types!==null&&(q.types=H.types),J.T=q}},ye.unstable_useCacheRefresh=function(){return J.H.useCacheRefresh()},ye.use=function(E){return J.H.use(E)},ye.useActionState=function(E,q,H){return J.H.useActionState(E,q,H)},ye.useCallback=function(E,q){return J.H.useCallback(E,q)},ye.useContext=function(E){return J.H.useContext(E)},ye.useDebugValue=function(){},ye.useDeferredValue=function(E,q){return J.H.useDeferredValue(E,q)},ye.useEffect=function(E,q){return J.H.useEffect(E,q)},ye.useEffectEvent=function(E){return J.H.useEffectEvent(E)},ye.useId=function(){return J.H.useId()},ye.useImperativeHandle=function(E,q,H){return J.H.useImperativeHandle(E,q,H)},ye.useInsertionEffect=function(E,q){return J.H.useInsertionEffect(E,q)},ye.useLayoutEffect=function(E,q){return J.H.useLayoutEffect(E,q)},ye.useMemo=function(E,q){return J.H.useMemo(E,q)},ye.useOptimistic=function(E,q){return J.H.useOptimistic(E,q)},ye.useReducer=function(E,q,H){return J.H.useReducer(E,q,H)},ye.useRef=function(E){return J.H.useRef(E)},ye.useState=function(E){return J.H.useState(E)},ye.useSyncExternalStore=function(E,q,H){return J.H.useSyncExternalStore(E,q,H)},ye.useTransition=function(){return J.H.useTransition()},ye.version="19.2.0",ye}var jS;function hy(){return jS||(jS=1,Qh.exports=yM()),Qh.exports}var $=hy();const gM=gk($),hT=yk({__proto__:null,default:gM},[$]),py=$.createContext(Jt.STORE);function pT(t,...e){let n;if(e.length===2){const r=e[0],a=e[1];n=Pr(t,r,a)}else n=e[0];return n}function Wn(...t){const e=$.useContext(py),n=pT(e,...t),r=$.useRef(null);return r.current??=a=>{Lt(e,n,a)},r.current}function Et(...t){const e=$.useContext(py),n=pT(e,...t),r=$.useId();return $.useSyncExternalStore(a=>Bo(e,n,`use-o:${r}`,a),()=>An(e,n),()=>An(e,n))}const mT=(t,{stringify:e,parse:n},r)=>({setSelf:a,onSet:u})=>{if(!t)return;const c=t.getItem(r);c!=null&&a(n(c)),u(({newValue:f})=>{if(f==null){t.removeItem(r);return}t.setItem(r,e(f))})};wk({key:"mutex",default:!1});var bM=class extends Map{set(t,e){return this.has(t)?(console.warn("Tried to set a key that already exists in an InvariantMap",{key:t,value:e}),this):super.set(t,e)}},vM=class Fp{type="continuity";globals=[];actions=[];perspectives=[];key;constructor(e){this.key=e}static existing=new bM;static create(e,n){const{type:r,globals:a,actions:u,perspectives:c}=n(new Fp(e)),f={type:r,key:e,globals:a,actions:u,perspectives:c};return Fp.existing.set(e,f),f}add(...e){switch(e[0].type){case"atom":case"mutable_atom":this.globals.push(...e);break;case"transaction":this.actions.push(...e);break;case"atom_family":case"mutable_atom_family":{const[n,r]=e;this.perspectives.push({type:"realtime_perspective",resourceAtoms:n,viewAtoms:r})}break}return this}};function SM(t){const{key:e,config:n}=t,r=vM.create(e,n),{actions:a}=r;for(const u of a)J1(Jt.STORE,e,u.key);return Zm(Jt.STORE,e,-1),r}const wM=t=>t.startsWith("user::"),xM=t=>t.startsWith("room::");Sk({key:"roomIndex",class:K1});const TM=xk({key:"usersInRooms",between:["room","user"],cardinality:"1:n",isAType:xM,isBType:wM});_k({key:"usersInMyRoomView",get:t=>({find:e})=>{const[,n]=Tk(TM);return[e(n,t)]}});const AM=(t,e,n,r,a)=>u=>{function c(h,m){if(t.logger.info("🧑⚖️","continuity",e,"reconciling updates"),Lt(t,wc,g=>(g.shift(),g)),h.id===m.id){if(JSON.stringify(h.subEvents)===JSON.stringify(m.subEvents)){t.logger.info("✅","continuity",e,`results for ${h.id} match between client and server`),n.emit(`ack:${e}`,m.epoch);return}}else t.logger.info("❌","continuity",e,`thought update #${m.epoch} was ${h.token.key}:${h.id}, but it was actually ${m.token.key}:${m.id}`);t.logger.info("🧑⚖️","continuity",e,"updates do not match",h,m);const y=r.toReversed();for(const g of y)wo(t,g,"oldValue");t.logger.info("⏪","continuity",e,"undid optimistic updates:",y),wo(t,h,"oldValue"),t.logger.info("⏪","continuity",e,"undid zeroth optimistic update",h),wo(t,m,"newValue"),t.logger.info("⏩","continuity",e,"applied confirmed update",m),n.emit(`ack:${e}`,m.epoch);for(const g of r){const v={type:"transaction",key:g.token.key},{id:S,params:x}=g;Jm(t,v,S)(...x)}t.logger.info("⏩","continuity",e,"reapplied subsequent optimistic updates:",r)}t.logger.info("🧑⚖️","continuity",e,"integrating confirmed update",{confirmedUpdate:u,confirmedUpdates:a,optimisticUpdates:r});const f=r[0];if(f)if(t.logger.info("🧑⚖️","continuity",e,"has optimistic updates to reconcile"),u.epoch===f.epoch){t.logger.info("🧑⚖️","continuity",e,`epoch of confirmed update #${u.epoch} matches zeroth optimistic update`),c(f,u);for(const h of a){const m=r[0];if(h.epoch===m?.epoch)c(m,h);else break}}else t.logger.info("🧑⚖️","continuity",e,`epoch of confirmed update #${u.epoch} does not match zeroth optimistic update #${f.epoch}`),a.some(h=>h.epoch===u.epoch)||(t.logger.info("👈","continuity",e,"pushing confirmed update to queue",u),Lt(t,Gp,h=>(h.push(u),h.sort((m,y)=>m.epoch-y.epoch),h)));else{t.logger.info("🧑⚖️","continuity",e,"has no optimistic updates to deal with");let h;h=Y1(t,e),h===u.epoch-1?(t.logger.info("✅","continuity",e,`integrating update #${u.epoch} (${u.token.key} ${u.id})`),wo(t,u,"newValue"),n.emit(`ack:${e}`,u.epoch),Zm(t,e,u.epoch)):h!==void 0&&(t.logger.info("🧑⚖️","continuity",e,`received update #${u.epoch} but still waiting for update #${h+1}`,{clientEpoch:h,serverEpoch:u.epoch}),a.some(m=>m.epoch===u.epoch)?t.logger.info("👍","continuity",e,`confirmed update #${u.epoch} is already enqueued`):(t.logger.info("👈","continuity",e,`pushing confirmed update #${u.epoch} to queue`),Lt(t,Gp,m=>(m.push(u),m.sort((y,g)=>y.epoch-g.epoch),m))))}};function EM(t){return e=>{for(const n of e)dy(t,n)}}function OM(t){return e=>{let n=0,r,a;for(const u of e)n%2===0?r=u:(a=u,Lt(t,r,a)),n++}}const _M=ft({key:"mySocketKey",default:void 0});ft({key:"myUserKey",default:null,effects:[mT(globalThis.localStorage,JSON,"myUserKey")]});const wc=ft({key:"optimisticUpdateQueue",default:()=>[]}),Gp=ft({key:"confirmedUpdateQueue",default:()=>[]});function RM(t,e,n){const r=n.key,a=An(t,wc),u=An(t,Gp),c=(g,v)=>{e.off(`continuity-init:${r}`,c);let S=0,x,T;for(const M of v)S%2===0?x=M:(T=M,"type"in x&&x.type==="mutable_atom"&&(x=Rs(t,x)),Lt(t,x,T)),S++;Zm(t,r,g)};e.off(`continuity-init:${r}`),e.on(`continuity-init:${r}`,c);const f=AM(t,r,e,a,u);e.off(`tx-new:${r}`),e.on(`tx-new:${r}`,f);const h=n.actions.map(g=>(J1(t,r,g.key),oT(t,g,`tx-run:${r}`,v=>{t.logger.info("🤞","continuity",r,"enqueuing optimistic update");const S=a.findIndex(x=>x.id===v.id);S===-1?(t.logger.info("🤞","continuity",r,"enqueuing new optimistic update"),Lt(t,wc,x=>(x.push(v),x.sort((T,M)=>T.epoch-M.epoch),x))):(t.logger.info("🤞","continuity",r,`replacing existing optimistic update at index ${S}`),Lt(t,wc,x=>(x[S]=v,x))),e.emit(`tx-run:${r}`,{id:v.id,token:g,params:v.params})}))),m=OM(t),y=EM(t);return e.on(`reveal:${r}`,m),e.on(`conceal:${r}`,y),e.emit(`get:${r}`),()=>{e.off(`continuity-init:${r}`),e.off(`tx-new:${r}`);for(const g of h)g()}}const yT=$.createContext({socket:null,services:null}),CM=({children:t,socket:e})=>{const n=$.useRef(new Map).current,r=Wn(_M);return $.useEffect(()=>{r(e?.id?`socket::${e.id}`:void 0),e?.on("connect",()=>{r(e?.id?`socket::${e.id}`:void 0)}),e?.on("disconnect",()=>{r(void 0)})},[e,r]),F.jsx(yT.Provider,{value:{socket:e,services:n},children:t})};function kM(t,e){if(globalThis.env?.NODE_ENV==="development"){const n=$.useRef(!1);$.useEffect(()=>{let r=n.current;if(r===!1)r=t()??!0,n.current=r;else return()=>{Br(r)&&r(),n.current=!1}},e)}else $.useEffect(t,e)}function MM(t,e){const{socket:n,services:r}=$.useContext(yT);kM(()=>{let a=r?.get(t);return a?++a.consumerCount:n&&(a={consumerCount:1,dispose:e(n)},r?.set(t,a)),()=>{a&&(--a.consumerCount,a.consumerCount===0&&(a.dispose?.(),r?.delete(t)))}},[n,t])}function DM(t){const e=$.useContext(py);MM(`tx-sync:${t.key}`,n=>RM(e,n,t))}var Wh={exports:{}},Ga={},ep={exports:{}},tp={};var BS;function NM(){return BS||(BS=1,(function(t){function e(j,U){var L=j.length;j.push(U);e:for(;0<L;){var te=L-1>>>1,oe=j[te];if(0<a(oe,U))j[te]=U,j[L]=oe,L=te;else break e}}function n(j){return j.length===0?null:j[0]}function r(j){if(j.length===0)return null;var U=j[0],L=j.pop();if(L!==U){j[0]=L;e:for(var te=0,oe=j.length,E=oe>>>1;te<E;){var q=2*(te+1)-1,H=j[q],Q=q+1,re=j[Q];if(0>a(H,L))Q<oe&&0>a(re,H)?(j[te]=re,j[Q]=L,te=Q):(j[te]=H,j[q]=L,te=q);else if(Q<oe&&0>a(re,L))j[te]=re,j[Q]=L,te=Q;else break e}}return U}function a(j,U){var L=j.sortIndex-U.sortIndex;return L!==0?L:j.id-U.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,f=c.now();t.unstable_now=function(){return c.now()-f}}var h=[],m=[],y=1,g=null,v=3,S=!1,x=!1,T=!1,M=!1,C=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function G(j){for(var U=n(m);U!==null;){if(U.callback===null)r(m);else if(U.startTime<=j)r(m),U.sortIndex=U.expirationTime,e(h,U);else break;U=n(m)}}function I(j){if(T=!1,G(j),!x)if(n(h)!==null)x=!0,ee||(ee=!0,je());else{var U=n(m);U!==null&&ne(I,U.startTime-j)}}var ee=!1,J=-1,X=5,he=-1;function pe(){return M?!0:!(t.unstable_now()-he<X)}function we(){if(M=!1,ee){var j=t.unstable_now();he=j;var U=!0;try{e:{x=!1,T&&(T=!1,_(J),J=-1),S=!0;var L=v;try{t:{for(G(j),g=n(h);g!==null&&!(g.expirationTime>j&&pe());){var te=g.callback;if(typeof te=="function"){g.callback=null,v=g.priorityLevel;var oe=te(g.expirationTime<=j);if(j=t.unstable_now(),typeof oe=="function"){g.callback=oe,G(j),U=!0;break t}g===n(h)&&r(h),G(j)}else r(h);g=n(h)}if(g!==null)U=!0;else{var E=n(m);E!==null&&ne(I,E.startTime-j),U=!1}}break e}finally{g=null,v=L,S=!1}U=void 0}}finally{U?je():ee=!1}}}var je;if(typeof R=="function")je=function(){R(we)};else if(typeof MessageChannel<"u"){var ve=new MessageChannel,Z=ve.port2;ve.port1.onmessage=we,je=function(){Z.postMessage(null)}}else je=function(){C(we,0)};function ne(j,U){J=C(function(){j(t.unstable_now())},U)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(j){j.callback=null},t.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<j?Math.floor(1e3/j):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_next=function(j){switch(v){case 1:case 2:case 3:var U=3;break;default:U=v}var L=v;v=U;try{return j()}finally{v=L}},t.unstable_requestPaint=function(){M=!0},t.unstable_runWithPriority=function(j,U){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var L=v;v=j;try{return U()}finally{v=L}},t.unstable_scheduleCallback=function(j,U,L){var te=t.unstable_now();switch(typeof L=="object"&&L!==null?(L=L.delay,L=typeof L=="number"&&0<L?te+L:te):L=te,j){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=L+oe,j={id:y++,callback:U,priorityLevel:j,startTime:L,expirationTime:oe,sortIndex:-1},L>te?(j.sortIndex=L,e(m,j),n(h)===null&&j===n(m)&&(T?(_(J),J=-1):T=!0,ne(I,L-te))):(j.sortIndex=oe,e(h,j),x||S||(x=!0,ee||(ee=!0,je()))),j},t.unstable_shouldYield=pe,t.unstable_wrapCallback=function(j){var U=v;return function(){var L=v;v=U;try{return j.apply(this,arguments)}finally{v=L}}}})(tp)),tp}var zS;function $M(){return zS||(zS=1,ep.exports=NM()),ep.exports}var np={exports:{}},Gt={};var LS;function jM(){if(LS)return Gt;LS=1;var t=hy();function e(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function u(h,m,y){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:g==null?null:""+g,children:h,containerInfo:m,implementation:y}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(h,m){if(h==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return Gt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Gt.createPortal=function(h,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(e(299));return u(h,m,null,y)},Gt.flushSync=function(h){var m=c.T,y=r.p;try{if(c.T=null,r.p=2,h)return h()}finally{c.T=m,r.p=y,r.d.f()}},Gt.preconnect=function(h,m){typeof h=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,r.d.C(h,m))},Gt.prefetchDNS=function(h){typeof h=="string"&&r.d.D(h)},Gt.preinit=function(h,m){if(typeof h=="string"&&m&&typeof m.as=="string"){var y=m.as,g=f(y,m.crossOrigin),v=typeof m.integrity=="string"?m.integrity:void 0,S=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?r.d.S(h,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:g,integrity:v,fetchPriority:S}):y==="script"&&r.d.X(h,{crossOrigin:g,integrity:v,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},Gt.preinitModule=function(h,m){if(typeof h=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=f(m.as,m.crossOrigin);r.d.M(h,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&r.d.M(h)},Gt.preload=function(h,m){if(typeof h=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,g=f(y,m.crossOrigin);r.d.L(h,y,{crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},Gt.preloadModule=function(h,m){if(typeof h=="string")if(m){var y=f(m.as,m.crossOrigin);r.d.m(h,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else r.d.m(h)},Gt.requestFormReset=function(h){r.d.r(h)},Gt.unstable_batchedUpdates=function(h,m){return h(m)},Gt.useFormState=function(h,m,y){return c.H.useFormState(h,m,y)},Gt.useFormStatus=function(){return c.H.useHostTransitionStatus()},Gt.version="19.2.0",Gt}var VS;function gT(){if(VS)return np.exports;VS=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),np.exports=jM(),np.exports}var US;function BM(){if(US)return Ga;US=1;var t=$M(),e=hy(),n=gT();function r(i){var s="https://react.dev/errors/"+i;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)s+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function u(i){var s=i,o=i;if(i.alternate)for(;s.return;)s=s.return;else{i=s;do s=i,(s.flags&4098)!==0&&(o=s.return),i=s.return;while(i)}return s.tag===3?o:null}function c(i){if(i.tag===13){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function f(i){if(i.tag===31){var s=i.memoizedState;if(s===null&&(i=i.alternate,i!==null&&(s=i.memoizedState)),s!==null)return s.dehydrated}return null}function h(i){if(u(i)!==i)throw Error(r(188))}function m(i){var s=i.alternate;if(!s){if(s=u(i),s===null)throw Error(r(188));return s!==i?null:i}for(var o=i,l=s;;){var d=o.return;if(d===null)break;var p=d.alternate;if(p===null){if(l=d.return,l!==null){o=l;continue}break}if(d.child===p.child){for(p=d.child;p;){if(p===o)return h(d),i;if(p===l)return h(d),s;p=p.sibling}throw Error(r(188))}if(o.return!==l.return)o=d,l=p;else{for(var b=!1,w=d.child;w;){if(w===o){b=!0,o=d,l=p;break}if(w===l){b=!0,l=d,o=p;break}w=w.sibling}if(!b){for(w=p.child;w;){if(w===o){b=!0,o=p,l=d;break}if(w===l){b=!0,l=p,o=d;break}w=w.sibling}if(!b)throw Error(r(189))}}if(o.alternate!==l)throw Error(r(190))}if(o.tag!==3)throw Error(r(188));return o.stateNode.current===o?i:s}function y(i){var s=i.tag;if(s===5||s===26||s===27||s===6)return i;for(i=i.child;i!==null;){if(s=y(i),s!==null)return s;i=i.sibling}return null}var g=Object.assign,v=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),R=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),he=Symbol.for("react.activity"),pe=Symbol.for("react.memo_cache_sentinel"),we=Symbol.iterator;function je(i){return i===null||typeof i!="object"?null:(i=we&&i[we]||i["@@iterator"],typeof i=="function"?i:null)}var ve=Symbol.for("react.client.reference");function Z(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===ve?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case C:return"Profiler";case M:return"StrictMode";case I:return"Suspense";case ee:return"SuspenseList";case he:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case R:return i.displayName||"Context";case _:return(i._context.displayName||"Context")+".Consumer";case G:var s=i.render;return i=i.displayName,i||(i=s.displayName||s.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case J:return s=i.displayName||null,s!==null?s:Z(i.type)||"Memo";case X:s=i._payload,i=i._init;try{return Z(i(s))}catch{}}return null}var ne=Array.isArray,j=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},te=[],oe=-1;function E(i){return{current:i}}function q(i){0>oe||(i.current=te[oe],te[oe]=null,oe--)}function H(i,s){oe++,te[oe]=i.current,i.current=s}var Q=E(null),re=E(null),ce=E(null),Te=E(null);function Ct(i,s){switch(H(ce,s),H(re,i),H(Q,null),s.nodeType){case 9:case 11:i=(i=s.documentElement)&&(i=i.namespaceURI)?F0(i):0;break;default:if(i=s.tagName,s=s.namespaceURI)s=F0(s),i=G0(s,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}q(Q),H(Q,i)}function Je(){q(Q),q(re),q(ce)}function ii(i){i.memoizedState!==null&&H(Te,i);var s=Q.current,o=G0(s,i.type);s!==o&&(H(re,i),H(Q,o))}function xi(i){re.current===i&&(q(Q),q(re)),Te.current===i&&(q(Te),qa._currentValue=L)}var xe,Me;function ge(i){if(xe===void 0)try{throw Error()}catch(o){var s=o.stack.trim().match(/\n( *(at )?)/);xe=s&&s[1]||"",Me=-1<o.stack.indexOf(`
|
|
14
14
|
at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
15
15
|
`+xe+i+Me}var Xe=!1;function ht(i,s){if(!i||Xe)return"";Xe=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(s){var P=function(){throw Error()};if(Object.defineProperty(P.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(P,[])}catch(z){var B=z}Reflect.construct(i,[],P)}else{try{P.call()}catch(z){B=z}i.call(P.prototype)}}else{try{throw Error()}catch(z){B=z}(P=i())&&typeof P.catch=="function"&&P.catch(function(){})}}catch(z){if(z&&B&&typeof z.stack=="string")return[z.stack,B.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var p=l.DetermineComponentFrameRoot(),b=p[0],w=p[1];if(b&&w){var A=b.split(`
|
|
16
16
|
`),N=w.split(`
|
|
@@ -63,4 +63,4 @@ ${c},
|
|
|
63
63
|
`;if(!n.hasKind("union"))return f;const h=new fp({kind:"Allows",optimistic:!0}).indent();n.compile(h);const m=h.write(`${n.id}Optimistic`);return`${f}${m},
|
|
64
64
|
`},`{
|
|
65
65
|
`)+"}");class nE{config;resolvedConfig;name;get[Yi](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(e,n){this.config=om(W.config,n),this.resolvedConfig=om(W.resolvedConfig,n),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(pp).length}`,this.name in pp&&Y(`A Scope already named ${this.name} already exists`),pp[this.name]=this;const r=Object.entries(e).map(a=>this.preparseOwnAliasEntry(...a));for(const[a,u]of r){let c=a;if(a[0]==="#"?(c=a.slice(1),c in this.aliases&&Y(Lw(c)),this.aliases[c]=u):(c in this.aliases&&Y(Lw(a)),this.aliases[c]=u,this.exportedNames.push(c)),!fe(u,"module")&&!fe(u,"generic")&&!Sf(u)){const f=this.preparseOwnDefinitionFormat(u,{alias:c});this.resolutions[c]=fe(f,"root")?this.bindReference(f):this.createParseContext(f).id}}Vw??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[Vw.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=W.intrinsic?Ge(W.intrinsic,(a,u)=>a.startsWith("json")?[]:[a,this.bindReference(u)]):{}}cacheGetter(e,n){return Object.defineProperty(this,e,{value:n}),n}get internal(){return this}_json;get json(){return this._json||this.export(),this._json}defineSchema(e){return e}generic=(...e)=>{const n=this;return(r,a)=>new Qc(e,a?new wA(r):r,n,n,a??null)};units=(e,n)=>{const r=[];for(const u of e)r.includes(u)||r.push(u);const a=r.map(u=>this.node("unit",{unit:u},n));return this.node("union",a,{...n,prereduced:!0})};lazyResolutions=[];lazilyResolve(e,n){const r=this.node("alias",{reference:n??"synthetic",resolve:e},{prereduced:!0});return this.resolved||this.lazyResolutions.push(r),r}schema=(e,n)=>this.finalize(this.parseSchema(e,n));parseSchema=(e,n)=>this.node(Ac(e),e,n);preparseNode(e,n,r){let a=typeof e=="string"?e:Ac(n,e);if(Qt(n)&&n.kind===a)return n;if(a==="alias"&&!r?.prereduced){const{reference:f}=Dy.implementation.normalize(n,this);if(f.startsWith("$")){const h=this.resolveRoot(f.slice(1));n=h,a=h.kind}}else if(a==="union"&&Cs(n,"object")){const f=Qj(n);f?.length===1&&(n=f[0],a=Ac(n))}if(Qt(n)&&n.kind===a)return n;const c=Of[a].normalize?.(n,this)??n;return Qt(c)?c.kind===a?c:Wj(a,c.kind):{...r,$:this,kind:a,def:c,prefix:r.alias??a}}bindReference(e){let n;return Qt(e)?n=e.$===this?e:new e.constructor(e.attachments,this):n=e.$===this?e:new Qc(e.params,e.bodyDef,e.$,this,e.hkt),this.resolved||Object.assign(this.referencesById,n.referencesById),n}resolveRoot(e){return this.maybeResolveRoot(e)??Y(oE(e))}maybeResolveRoot(e){const n=this.maybeResolve(e);if(!fe(n,"generic"))return n}maybeResolveSubalias(e){return hm(this.aliases,e)??hm(this.ambient,e)}get ambient(){return W.ambient}maybeResolve(e){const n=this.resolutions[e];if(n){if(typeof n!="string")return this.bindReference(n);const a=Vn[n];if(fe(a,"root"))return this.resolutions[e]=a;if(fe(a,"context")){if(a.phase==="resolving")return this.node("alias",{reference:`$${e}`},{prereduced:!0});if(a.phase==="resolved")return Rt(`Unexpected resolved context for was uncached by its scope: ${Ie(a)}`);a.phase="resolving";const u=this.bindReference(this.parseOwnDefinitionFormat(a.def,a));return a.phase="resolved",Vn[u.id]=u,Vn[a.id]=u,this.resolutions[e]=u}return Rt(`Unexpected nodesById entry for ${n}: ${Ie(a)}`)}let r=this.aliases[e]??this.ambient?.[e];return r?(r=this.normalizeRootScopeValue(r),fe(r,"generic")?this.resolutions[e]=this.bindReference(r):fe(r,"module")?(r.root||Y(aE(e)),this.resolutions[e]=this.bindReference(r.root)):this.resolutions[e]=this.parse(r,{alias:e})):this.maybeResolveSubalias(e)}createParseContext(e){const n=e.id??BA(e.prefix);return Vn[n]=Object.assign(e,{[Yi]:"context",$:this,id:n,phase:"unresolved"})}traversal(e){return new xo(e,this.resolvedConfig)}import(...e){return new dm(Ge(this.export(...e),(n,r)=>[`#${n}`,r]))}precompilation;_exportedResolutions;_exports;export(...e){if(!this._exports){this._exports={};for(const r of this.exportedNames){const a=this.aliases[r];this._exports[r]=fe(a,"module")?QA(a,this):Uw(this.maybeResolve(r))}for(const r of this.lazyResolutions)r.resolution;if(this._exportedResolutions=sE(this,this._exports),this._json=rE(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){const r=tE(this.references);this.precompilation=r.write(WA,4),eE(this.references,r)}this.resolved=!0}const n=e.length?e:this.exportedNames;return new dm(Ge(n,(r,a)=>[a,this._exports[a]]))}resolve(e){return this.export()[e]}node=(e,n,r={})=>{const a=this.preparseNode(e,n,r);if(Qt(a))return this.bindReference(a);const u=this.createParseContext(a),c=zA(u),f=this.bindReference(c);return Vn[u.id]=f};parse=(e,n={})=>this.finalize(this.parseDefinition(e,n));parseDefinition(e,n={}){if(fe(e,"root"))return this.bindReference(e);const r=this.preparseOwnDefinitionFormat(e,n);if(fe(r,"root"))return this.bindReference(r);const a=this.createParseContext(r);Vn[a.id]=a;let u=this.bindReference(this.parseOwnDefinitionFormat(e,a));return u.isCyclic&&(u=I$(u,a.id)),Vn[a.id]=u,u}finalize(e){return Uw(e),!e.precompilation&&!this.resolvedConfig.jitless&&e3(e.references),e}}class iE extends nE{parseOwnDefinitionFormat(e,n){return zA(n)}preparseOwnDefinitionFormat(e,n){return this.preparseNode(Ac(e),e,n)}preparseOwnAliasEntry(e,n){return[e,n]}normalizeRootScopeValue(e){return e}}const Uw=t=>{const e=t.references.filter(n=>n.hasKind("alias"));for(const n of e){Object.assign(n.referencesById,n.resolution.referencesById);for(const r of t.references)n.id in r.referencesById&&Object.assign(r.referencesById,n.referencesById)}return t},rE=t=>Ge(t,(e,n)=>[e,fe(n,"root")||fe(n,"generic")?n.json:fe(n,"module")?rE(n):Rt(`Unexpected resolution ${Ie(n)}`)]),hm=(t,e)=>{const n=e.indexOf(".");if(n===-1)return;const r=e.slice(0,n),a=t[r];if(a===void 0)return;if(!fe(a,"module"))return Y(t3(r));const u=e.slice(n+1),c=a[u];if(c===void 0)return hm(a,u);if(fe(c,"root")||fe(c,"generic"))return c;if(fe(c,"module"))return c.root??Y(aE(e));Rt(`Unexpected resolution for alias '${e}': ${Ie(c)}`)},jy=(t,e)=>new iE(t,e),$l=new iE({}),sE=(t,e)=>{const n={};for(const r in e){const a=e[r];if(fe(a,"module")){const u=sE(t,a),c=Ge(u,(f,h)=>[`${r}.${f}`,h]);Object.assign(n,c)}else fe(a,"root")||fe(a,"generic")?n[r]=a:Rt(`Unexpected scope resolution ${Ie(a)}`)}return n},oE=t=>`'${t}' is unresolvable`,t3=t=>`'${t}' must reference a module to be accessed using dot syntax`,aE=t=>`Reference to submodule '${t}' must specify an alias`;$l.export();const Ye=$l.schema,By=$l.node;$l.defineSchema;const er=$l.generic,lE="^(?:0|[1-9]\\d*)$",n3=new RegExp(lE);en(n3);const uE=jy({bigint:"bigint",boolean:[{unit:!1},{unit:!0}],false:{unit:!1},never:[],null:{unit:null},number:"number",object:"object",string:"string",symbol:"symbol",true:{unit:!0},unknown:{},undefined:{unit:void 0},Array,Date},{prereducedAliases:!0}).export();W.intrinsic={...uE};const cE=jy({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:lE}},{prereducedAliases:!0}).export();Object.assign(W.intrinsic,cE);const i3=jy({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),me={...uE,...cE,...i3,emptyStructure:By("structure",{},{prereduced:!0})};W.intrinsic={...me};const Kw=((t,e)=>new RegExp(t,e));Object.assign(Kw,{as:Kw});const r3=t=>typeof t=="string"&&t[0]==="d"&&(t[1]==="'"||t[1]==='"')&&t[t.length-1]===t[1],qw=t=>t.toString()!=="Invalid Date",s3=t=>t.slice(2,-1),fE=t=>`'${t}' could not be parsed by the Date constructor`,o3=(t,e)=>a3(t,e),a3=(t,e)=>{const n=new Date(t);if(qw(n))return n;const r=MN(t);if(r!==void 0){const a=new Date(r);if(qw(a))return a}return e?Y(e===!0?fE(t):e):void 0},Pw=(t,e)=>{const n=t.scanner.shiftUntilEscapable(c3[hE[e]]);if(t.scanner.lookahead==="")return t.error(d3(n,e));if(t.scanner.shift(),e==="/"){try{new RegExp(n)}catch(r){Y(String(r))}t.root=t.ctx.$.node("intersection",{domain:"string",pattern:n},{prereduced:!0})}else if(vi(e,dE))t.root=t.ctx.$.node("unit",{unit:n});else{const r=o3(n,fE(n));t.root=t.ctx.$.node("unit",{meta:n,unit:r})}},dE={"'":1,'"':1},l3={"/":1,"'":1,'"':1},u3={"d'":"'",'d"':'"',"'":"'",'"':'"'},hE={...u3,"/":"/"},c3={"'":t=>t.lookahead==="'",'"':t=>t.lookahead==='"',"/":t=>t.lookahead==="/"},f3={'"':"double-quote","'":"single-quote","/":"forward slash"},d3=(t,e)=>`${e}${t} requires a closing ${f3[hE[e]]}`,h3=t=>`Private type references should not include '#'. Use '${t}' instead.`,pE="Optional definitions like 'string?' are only valid as properties in an object or tuple",mE="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple",Jo={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...wf},p3=(t,e)=>t===">"?e[0]==="="?e[1]==="=":e.trimStart()===""||vi(e.trimStart()[0],Jo):t==="="?e[0]!=="=":t===","||t==="?",m3=(t,e,n)=>yE(t,e,n,[]),yE=(t,e,n,r)=>{const a=n.parseUntilFinalizer();return r.push(a.root),a.finalizer===">"?r.length!==e.params.length?n.error(gE(t,e.names,r.map(u=>u.expression))):r:a.finalizer===","?yE(t,e,n,r):a.error(aA(">"))},gE=(t,e,n)=>`${t}<${e.join(", ")}> requires exactly ${e.length} args (got ${n.length}${n.length===0?"":`: ${n.join(", ")}`})`,Iw=t=>{const e=t.scanner.shiftUntilLookahead(Jo);e==="keyof"?t.addPrefix("keyof"):t.root=g3(t,e)},y3=(t,e,n)=>{if(n.scanner.shiftUntilNonWhitespace(),n.scanner.shift()!=="<")return n.error(gE(t,e.names,[]));const a=m3(t,e,n);return e(...a)},g3=(t,e)=>b3(t,e)??v3(t,e)??t.error(e===""?t.scanner.lookahead==="#"?h3(t.shiftedByOne().scanner.shiftUntilLookahead(Jo)):bE(t):oE(e)),b3=(t,e)=>{if(t.ctx.args?.[e]){const r=t.ctx.args[e];return typeof r!="string"?r:t.ctx.$.node("alias",{reference:r},{prereduced:!0})}const n=t.ctx.$.maybeResolve(e);if(fe(n,"root"))return n;if(n!==void 0)return fe(n,"generic")?y3(e,n,t):Y(`Unexpected resolution ${Ie(n)}`)},v3=(t,e)=>{const n=DN(e);if(n!==void 0)return t.ctx.$.node("unit",{unit:n});const r=$N(e);if(r!==void 0)return t.ctx.$.node("unit",{unit:r})},bE=t=>{const e=t.previousOperator();return e?vE(e,t.scanner.unscanned):S3(t.scanner.unscanned)},vE=(t,e="")=>`Token '${t}' requires a right operand${e?` before '${e}'`:""}`,S3=t=>`Expected an expression${t?` before '${t}'`:""}`,SE=t=>t.scanner.lookahead===""?t.error(bE(t)):t.scanner.lookahead==="("?t.shiftedByOne().reduceGroupOpen():t.scanner.lookaheadIsIn(l3)?Pw(t,t.scanner.shift()):t.scanner.lookaheadIsIn(wf)?SE(t.shiftedByOne()):t.scanner.lookahead==="d"&&t.scanner.nextLookahead in dE?Pw(t,`${t.scanner.shift()}${t.scanner.shift()}`):Iw(t),w3={">":!0,">=":!0},x3={"<":!0,"<=":!0},ef={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},T3=(t,e)=>`Left bounds are only valid when paired with right bounds (try ...${e}${t})`,wE=t=>`Left-bounded expressions must specify their limits using < or <= (was ${t})`,A3=(t,e,n,r)=>`An expression may have at most one left bound (parsed ${t}${ef[e]}, ${n}${ef[r]})`,E3=(t,e)=>{const n=_3(t,e);if(t.root.hasKind("unit")){if(typeof t.root.unit=="number"){t.reduceLeftBound(t.root.unit,n),t.unsetRoot();return}if(t.root.unit instanceof Date){const r=`d'${t.root.description??t.root.unit.toISOString()}'`;t.unsetRoot(),t.reduceLeftBound(r,n);return}}return C3(t,n)},O3={"<":1,">":1,"=":1},_3=(t,e)=>t.scanner.lookaheadIs("=")?`${e}${t.scanner.shift()}`:e,Hw=(t,e,n,r)=>n.extends(W.intrinsic.number)?typeof e!="number"?Y(pm(t,e,r)):t==="=="?["min","max"]:t[0]===">"?["min"]:["max"]:n.extends(W.intrinsic.lengthBoundable)?typeof e!="number"?Y(pm(t,e,r)):t==="=="?["exactLength"]:t[0]===">"?["minLength"]:["maxLength"]:n.extends(W.intrinsic.Date)?t==="=="?["after","before"]:t[0]===">"?["after"]:["before"]:Y(T$(n.expression)),R3=t=>({rule:r3(t.limit)?s3(t.limit):t.limit,exclusive:t.comparator.length===1}),C3=(t,e)=>{const n=t.unsetRoot(),r=t.scanner.location;t.parseOperand();const a=t.unsetRoot(),u=t.scanner.sliceChars(r,t.scanner.location);if(t.root=n,!a.hasKind("unit")||typeof a.unit!="number"&&!(a.unit instanceof Date))return t.error(pm(e,u,"right"));const c=a.unit,f=e.length===1,h=Hw(e,typeof c=="number"?c:u,n,"right");for(const y of h)t.constrainRoot(y,e==="=="?{rule:c}:{rule:c,exclusive:f});if(!t.branches.leftBound)return;if(!vi(e,x3))return t.error(wE(e));const m=Hw(t.branches.leftBound.comparator,t.branches.leftBound.limit,n,"left");t.constrainRoot(m[0],R3(t.branches.leftBound)),t.branches.leftBound=null},pm=(t,e,n)=>`Comparator ${n==="left"?ef[t]:t} must be ${n==="left"?"preceded":"followed"} by a corresponding literal (was ${e})`,k3=t=>{t.scanner.shiftUntilNonWhitespace();const e=t.scanner.shiftUntilLookahead(Jo);t.root=t.root.brand(e)},M3=t=>{t.scanner.shiftUntilNonWhitespace();const e=t.scanner.shiftUntilLookahead(Jo),n=NN(e,{errorOnFail:Fw(e)});n===0&&t.error(Fw(0)),t.root=t.root.constrain("divisor",n)},Fw=t=>`% operator must be followed by a non-zero integer literal (was ${t})`,xE=t=>{const e=t.scanner.shift();return e===""?t.finalize(""):e==="["?t.scanner.shift()==="]"?t.setRoot(t.root.array()):t.error(D3):e==="|"?t.scanner.lookahead===">"?t.shiftedByOne().pushRootToBranch("|>"):t.pushRootToBranch(e):e==="&"?t.pushRootToBranch(e):e===")"?t.finalizeGroup():p3(e,t.scanner.unscanned)?t.finalize(e):vi(e,O3)?E3(t,e):e==="%"?M3(t):e==="#"?k3(t):e in wf?xE(t):t.error(zy(e))},zy=(t,e="")=>`'${t}' is not allowed here${e&&` (should be ${e})`}`,D3="Missing expected ']'",N3=t=>{const e=t.unsetRoot();t.parseOperand();const n=t.unsetRoot();if(!n.hasKind("unit"))return t.error($3(n.expression));const r=n.unit instanceof Date?()=>new Date(n.unit):n.unit;return[e,"=",r]},$3=t=>`Default value '${t}' must be a literal value`,Gw=(t,e)=>{const n=e.$.maybeResolveRoot(t);if(n)return n;if(t.endsWith("[]")){const u=e.$.maybeResolveRoot(t.slice(0,-2));if(u)return u.array()}const r=new _f(new oA(t),e),a=j3(r);return r.finalizer===">"&&Y(zy(">")),a},j3=t=>{t.parseOperand();let e=Ly(t).root;return e?(t.finalizer==="="?e=N3(t):t.finalizer==="?"&&(e=[e,"?"]),t.scanner.shiftUntilNonWhitespace(),t.scanner.lookahead&&Y(zy(t.scanner.lookahead)),e):Rt(`Root was unexpectedly unset after parsing string '${t.scanner.scanned}'`)},Ly=t=>{for(;t.finalizer===void 0;)B3(t);return t},B3=t=>t.hasRoot()?t.parseOperator():t.parseOperand();class _f{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor(e,n){this.scanner=e,this.ctx=n}error(e){return Y(e)}hasRoot(){return this.root!==void 0}setRoot(e){this.root=e}unsetRoot(){const e=this.root;return this.root=void 0,e}constrainRoot(...e){this.root=this.root.constrain(e[0],e[1])}finalize(e){if(this.groups.length)return this.error(aA(")"));this.finalizeBranches(),this.finalizer=e}reduceLeftBound(e,n){const r=ef[n];if(!vi(r,w3))return this.error(wE(n));if(this.branches.leftBound)return this.error(A3(this.branches.leftBound.limit,this.branches.leftBound.comparator,e,r));this.branches.leftBound={comparator:r,limit:e}}finalizeBranches(){if(this.assertRangeUnset(),this.branches.pipe){this.pushRootToBranch("|>"),this.root=this.branches.pipe;return}if(this.branches.union){this.pushRootToBranch("|"),this.root=this.branches.union;return}if(this.branches.intersection){this.pushRootToBranch("&"),this.root=this.branches.intersection;return}this.applyPrefixes()}finalizeGroup(){this.finalizeBranches();const e=this.groups.pop();if(!e)return this.error(qN(")",this.scanner.unscanned));this.branches=e}addPrefix(e){this.branches.prefixes.push(e)}applyPrefixes(){for(;this.branches.prefixes.length;){const e=this.branches.prefixes.pop();this.root=e==="keyof"?this.root.keyof():Rt(`Unexpected prefix '${e}'`)}}pushRootToBranch(e){this.assertRangeUnset(),this.applyPrefixes();const n=this.root;this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(n)??n,e!=="&"&&(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,e!=="|"&&(this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null))}parseUntilFinalizer(){return Ly(new _f(this.scanner,this.ctx))}parseOperator(){return xE(this)}parseOperand(){return SE(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(T3(this.branches.leftBound.limit,this.branches.leftBound.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={prefixes:[],leftBound:null,union:null,intersection:null,pipe:null}}previousOperator(){return this.branches.leftBound?.comparator??this.branches.prefixes[this.branches.prefixes.length-1]??(this.branches.intersection?"&":this.branches.union?"|":this.branches.pipe?"|>":void 0)}shiftedByOne(){return this.scanner.shift(),this}}const z3="An empty string is not a valid generic parameter name",mm=(t,e,n)=>{t.shiftUntilNonWhitespace();const r=t.shiftUntilLookahead(Jo);return r===""?t.lookahead===""&&e.length?e:Y(z3):(t.shiftUntilNonWhitespace(),L3(t,r,e,n))},Yw="extends ",L3=(t,e,n,r)=>{if(t.shiftUntilNonWhitespace(),t.unscanned.startsWith(Yw))t.jumpForward(Yw.length);else return t.lookahead===","&&t.shift(),n.push(e),mm(t,n,r);const a=Ly(new _f(t,r));return n.push([e,a.root]),mm(t,n,r)};class V3 extends Hr{constructor(e){const n={$:e,raw:e.fn};super((...r)=>{const a=r.indexOf(":"),u=a===-1?r.length-1:a-1,c=r.slice(0,u+1),f=e.parse(c).assertHasKind("intersection");let h=e.intrinsic.unknown;if(a!==-1){if(a!==r.length-2)return Y(K3);h=e.parse(r[a+1])}return m=>new U3(m,f,h)},{attach:n})}}class U3 extends Hr{raw;params;returns;expression;constructor(e,n,r){const a=`typed ${e.name}`,u={[a]:(...f)=>{const h=n.assert(f),m=e(...h);return r.assert(m)}}[a];super(u),this.raw=e,this.params=n,this.returns=r;let c=n.expression;c[0]==="["&&c[c.length-1]==="]"?c=c.slice(1,-1):c.endsWith("[]")&&(c=`...${c}`),this.expression=`(${c}) => ${r?.expression??"unknown"}`}}const K3=`":" must be followed by exactly one return type e.g:
|
|
66
|
-
fn("string", ":", "number")(s => s.length)`;class q3 extends Hr{$;constructor(e){super((...n)=>new fc(e)(...n),{bind:e}),this.$=e}in(e){return new fc(this.$,e===void 0?void 0:this.$.parse(e))}at(e,n){return new fc(this.$).at(e,n)}case(e,n){return new fc(this.$).case(e,n)}}class fc extends Hr{$;in;key;branches=[];constructor(e,n){super(r=>this.caseEntries(Object.entries(r).map(([a,u])=>a==="default"?[a,u]:[this.$.parse(a),u]))),this.$=e,this.in=n}at(e,n){return this.key&&Y(I3),this.branches.length&&Y(P3),this.key=e,n?this.match(n):this}case(e,n){return this.caseEntry(this.$.parse(e),n)}caseEntry(e,n){const a=(this.key?this.$.parse({[this.key]:e}):e).pipe(n);return this.branches.push(a),this}match(e){return this(e)}strings(e){return this.caseEntries(Object.entries(e).map(([n,r])=>n==="default"?[n,r]:[this.$.node("unit",{unit:n}),r]))}caseEntries(e){for(let n=0;n<e.length;n++){const[r,a]=e[n];if(r==="default")return n!==e.length-1&&Y("default may only be specified as the last key of a switch definition"),this.default(a);if(typeof a!="function")return Y(`Value for case "${r}" must be a function (was ${ti(a)})`);this.caseEntry(r,a)}return this}default(e){typeof e=="function"&&this.case(me.unknown,e);const n={branches:this.branches,ordered:!0};(e==="never"||e==="assert")&&(n.meta={onFail:Jw});const r=this.$.node("union",n);if(!this.in)return this.$.finalize(r);let a=this.in.pipe(r);return(e==="never"||e==="assert")&&(a=a.configureReferences({onFail:Jw},"self")),this.$.finalize(a)}}const Jw=t=>t.throw(),P3="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",I3="At most one key matcher may be specified per expression",TE=(t,e)=>{if(Xt(t)){if(t[1]==="=")return[e.$.parseOwnDefinitionFormat(t[0],e),"=",t[2]];if(t[1]==="?")return[e.$.parseOwnDefinitionFormat(t[0],e),"?"]}return kE(t,e)},H3="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",F3="Only required keys may specify default values, e.g. { value: 'number = 0' }",G3=(t,e)=>{let n;const r={},a=Fc(t);for(const[c,f]of a){const h=X3(c);if(h.kind==="spread"){if(!Rl(r))return Y(J3);const S=e.$.parseOwnDefinitionFormat(f,e);if(S.equals(me.object))continue;if(!S.hasKind("intersection")||!S.basis?.equals(me.object))return Y(Z3(S.expression));n=S.structure;continue}if(h.kind==="undeclared"){f!=="reject"&&f!=="delete"&&f!=="ignore"&&Y(Y3(f)),r.undeclared=f;continue}const m=TE(f,e),y=h;if(h.kind==="required"){Xt(m)?mp(r,"optional",m[1]==="="?{key:h.normalized,value:m[0],default:m[2]}:{key:h.normalized,value:m[0]},e):mp(r,"required",{key:h.normalized,value:m},e);continue}if(Xt(m)&&(m[1]==="?"&&Y(H3),m[1]==="="&&Y(F3)),h.kind==="optional"){mp(r,"optional",{key:h.normalized,value:m},e);continue}const g=e.$.parseOwnDefinitionFormat(y.normalized,e),v=fm(g,m,e.$);v.index&&(r.index=Fe(r.index,v.index)),v.required&&(r.required=Fe(r.required,v.required))}const u=e.$.node("structure",r);return e.$.parseSchema({domain:"object",structure:n?.merge(u)??u})},mp=(t,e,n,r)=>{t[e]=Fe(t[e],r.$.node(e,n))},Y3=t=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${Ie(t)})`,J3="Spread operator may only be used as the first key in an object",X3=t=>typeof t=="symbol"?{kind:"required",normalized:t}:t[t.length-1]==="?"?t[t.length-2]===tl?{kind:"required",normalized:`${t.slice(0,-2)}?`}:{kind:"optional",normalized:t.slice(0,-1)}:t[0]==="["&&t[t.length-1]==="]"?{kind:"index",normalized:t.slice(1,-1)}:t[0]===tl&&t[1]==="["&&t[t.length-1]==="]"?{kind:"required",normalized:t.slice(1)}:t==="..."?{kind:"spread"}:t==="+"?{kind:"undeclared"}:{kind:"required",normalized:t==="\\..."?"...":t==="\\+"?"+":t},Z3=t=>`Spread operand must resolve to an object literal type (was ${t})`,Q3=(t,e)=>lB(t)?_E[t[0]](t,e):oB(t)?OE[t[1]](t,e):null,W3=(t,e)=>e.$.parseOwnDefinitionFormat(t[1],e).keyof(),yp=(t,e)=>{if(t[2]===void 0)return Y(vE(t[1],""));const n=e.$.parseOwnDefinitionFormat(t[0],e),r=e.$.parseOwnDefinitionFormat(t[2],e);if(t[1]==="|")return e.$.node("union",{branches:[n,r]});const a=t[1]==="&"?Xi(n,r,e.$):lm(n,r,e.$);return a instanceof ae?a.throw():a},eB=(t,e)=>e.$.parseOwnDefinitionFormat(t[0],e).array(),tB=(t,e)=>typeof t[2]!="function"?Y(AE("=>",t[2])):e.$.parseOwnDefinitionFormat(t[0],e).pipe(t[2]),AE=(t,e)=>`${t===":"?"Narrow":"Morph"} expression requires a function following '${t}' (was ${typeof e})`,nB=(t,e)=>typeof t[2]!="function"?Y(AE(":",t[2])):e.$.parseOwnDefinitionFormat(t[0],e).constrain("predicate",t[2]),iB=(t,e)=>e.$.parseOwnDefinitionFormat(t[0],e).configure(t[2],t[3]),EE=t=>t,rB=EE({"[]":eB,"?":()=>Y(pE)}),sB=EE({"|":yp,"&":yp,":":nB,"=>":tB,"|>":yp,"@":iB,"=":()=>Y(mE)}),OE={...rB,...sB},oB=t=>OE[t[1]]!==void 0,aB=t=>t,_E=aB({keyof:W3,instanceof:(t,e)=>{if(typeof t[1]!="function")return Y(Xw(tm(t[1])));const n=t.slice(1).map(r=>typeof r=="function"?e.$.node("proto",{proto:r}):Y(Xw(tm(r))));return n.length===1?n[0]:e.$.node("union",{branches:n})},"===":(t,e)=>e.$.units(t.slice(1))}),lB=t=>_E[t[0]]!==void 0,Xw=t=>`Expected a constructor following 'instanceof' operator (was ${t})`,uB=(t,e)=>{let n=[{}],r=0;for(;r<t.length;){let a=!1;t[r]==="..."&&r<t.length-1&&(a=!0,r++);const u=TE(t[r],e),[c,f,h]=Xt(u)?u:[u];if(r++,a){if(!c.extends(W.intrinsic.Array))return Y(dB(c.expression));n=n.flatMap(m=>c.distribute(y=>fB(dA(m),y)))}else n=n.map(m=>f==="?"?RE(m,c):f==="="?cB(m,c,h):ym(m,c))}return e.$.parseSchema(n.map(a=>Rl(a)?{proto:Array,exactLength:0}:{proto:Array,sequence:a}))},ym=(t,e)=>t.defaultables||t.optionals?Y(t.variadic?JA:hB):(t.variadic?t.postfix=Fe(t.postfix,e):t.prefix=Fe(t.prefix,e),t),RE=(t,e)=>t.variadic?Y(CE):(t.optionals=Fe(t.optionals,e),t),cB=(t,e,n)=>t.variadic?Y(CE):t.optionals?Y(pB):(t.defaultables=Fe(t.defaultables,[[e,n]]),t),Zw=(t,e)=>(t.postfix&&Y(Qw),t.variadic?t.variadic.equals(e)||Y(Qw):t.variadic=e.internal,t),fB=(t,e)=>{const n=e.select({method:"find",kind:"sequence"});if(!n)return Zw(t,W.intrinsic.unknown);if(n.prefix)for(const r of n.prefix)ym(t,r);if(n.optionals)for(const r of n.optionals)RE(t,r);if(n.variadic&&Zw(t,n.variadic),n.postfix)for(const r of n.postfix)ym(t,r);return t},dB=t=>`Spread element must be an array (was ${t})`,Qw="A tuple may have at most one variadic element",hB="A required element may not follow an optional element",CE="An optional element may not follow a variadic element",pB="A defaultable element may not follow an optional element without a default",mB={},kE=(t,e)=>{if(typeof t=="string"){if(e.args&&Object.keys(e.args).some(r=>t.includes(r)))return Gw(t,e);const n=mB[e.$.name]??={};return n[t]??=Gw(t,e)}return Cs(t,"object")?yB(t,e):Y(gm(ti(t)))},yB=(t,e)=>{const n=xy(t);switch(n){case void 0:return fe(t,"root")?t:G3(t,e);case"Array":return gB(t,e);case"RegExp":return e.$.node("intersection",{domain:"string",pattern:t},{prereduced:!0});case"Function":{const r=Sf(t)?t():t;return fe(r,"root")?r:Y(gm("Function"))}default:return Y(gm(n??Ie(t)))}},gB=(t,e)=>Q3(t,e)??uB(t,e),gm=t=>`Type definitions must be strings or objects (was ${t})`;class bB extends Hr{constructor(e){const n=Object.assign({errors:Lr,hkt:Si,$:e,raw:e.parse,module:e.constructor.module,scope:e.constructor.scope,declare:e.declare,define:e.define,match:e.match,generic:e.generic,schema:e.schema,keywords:e.ambient,unit:e.unit,enumerated:e.enumerated,instanceOf:e.instanceOf,valueOf:e.valueOf,or:e.or,and:e.and,merge:e.merge,pipe:e.pipe,fn:e.fn},e.ambientAttachments);super((...r)=>{if(r.length===1)return e.parse(r[0]);if(r.length===2&&typeof r[0]=="string"&&r[0][0]==="<"&&r[0][r[0].length-1]===">"){const a=r[0].slice(1,-1),u=e.parseGenericParams(a,{});return new Qc(u,r[1],e,e,null)}return e.parse(r)},{attach:n})}}const yl=W;class Rf extends nE{get ambientAttachments(){if(yl.typeAttachments)return this.cacheGetter("ambientAttachments",Ge(yl.typeAttachments,(e,n)=>[e,this.bindReference(n)]))}preparseOwnAliasEntry(e,n){const r=e.indexOf("<");if(r===-1){if(fe(n,"module")||fe(n,"generic"))return[e,n];const c=this.name==="ark"?e:e==="root"?this.name:`${this.name}.${e}`,f=this.resolvedConfig.keywords?.[c];return f&&(n=[n,"@",f]),[e,n]}e[e.length-1]!==">"&&Y("'>' must be the last character of a generic declaration in a scope");const a=e.slice(0,r),u=e.slice(r+1,-1);return[a,()=>{const c=this.parseGenericParams(u,{alias:a});return u$(c,n,this)}]}parseGenericParams(e,n){return mm(new oA(e),[],this.createParseContext({...n,def:e,prefix:"generic"}))}normalizeRootScopeValue(e){return Sf(e)&&!fe(e,"generic")?e():e}preparseOwnDefinitionFormat(e,n){return{...n,def:e,prefix:n.alias??"type"}}parseOwnDefinitionFormat(e,n){!(n.alias&&n.alias in this.aliases)&&!n.args&&(n.args={this:n.id});const a=kE(e,n);if(Xt(a)){if(a[1]==="=")return Y(mE);if(a[1]==="?")return Y(pE)}return a}unit=e=>this.units([e]);valueOf=e=>this.units(rN(e));enumerated=(...e)=>this.units(e);instanceOf=e=>this.node("proto",{proto:e},{prereduced:!0});or=(...e)=>this.schema(e.map(n=>this.parse(n)));and=(...e)=>e.reduce((n,r)=>n.and(this.parse(r)),this.intrinsic.unknown);merge=(...e)=>e.reduce((n,r)=>n.merge(this.parse(r)),this.intrinsic.object);pipe=(...e)=>this.intrinsic.unknown.pipe(...e);fn=new V3(this);match=new q3(this);declare=()=>({type:this.type});define(e){return e}type=new bB(this);static scope=((e,n={})=>new Rf(e,n));static module=((e,n={})=>this.scope(e,n).export())}const vB=Object.assign(Rf.scope,{define:t=>t}),ze=Rf;class SB extends Si{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}const wB=er(["base",me.object],["props",me.object])(t=>t.base.merge(t.props),SB),xB=ze.module({Key:me.key,Merge:wB});class TB extends Si{}const AB=er("element")(t=>{const e=t.element.exclude(me.Array),n=e.array();return e.rawOr(n).pipe(_l).distribute(r=>r.assertHasKind("morph").declareOut(n),Ye)},TB),EB=ze.module({root:me.Array,readonly:"root",index:me.nonNegativeIntegerString,liftFrom:AB},{name:"Array"}),bm=Ye(["string",Cl.FileConstructor]),OB=bm.rawOr(bm.array()),Ww=Ye({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:OB}}),_B=ze.module({root:["instanceof",FormData],value:bm,parsed:Ww,parse:Ye({in:FormData,morphs:t=>{const e={};for(const[n,r]of t)if(n in e){const a=e[n];typeof a=="string"||a instanceof Cl.FileConstructor?e[n]=[a,r]:a.push(r)}else e[n]=r;return e},declaredOut:Ww})},{name:"FormData"}),RB=ze.module({Int8:["instanceof",Int8Array],Uint8:["instanceof",Uint8Array],Uint8Clamped:["instanceof",Uint8ClampedArray],Int16:["instanceof",Int16Array],Uint16:["instanceof",Uint16Array],Int32:["instanceof",Int32Array],Uint32:["instanceof",Uint32Array],Float32:["instanceof",Float32Array],Float64:["instanceof",Float64Array],BigInt64:["instanceof",BigInt64Array],BigUint64:["instanceof",BigUint64Array]},{name:"TypedArray"}),CB={Boolean:1,Number:1,String:1},kB=ze.module({...Ge({...JT,...ZT},(t,e)=>t in CB?[]:[t,["instanceof",e]]),Array:EB,TypedArray:RB,FormData:_B}),MB=Ye({domain:{domain:"number",meta:"a number representing a Unix timestamp"},divisor:{rule:1,meta:"an integer representing a Unix timestamp"},min:{rule:-864e13,meta:"a Unix timestamp after -8640000000000000"},max:{rule:864e13,meta:"a Unix timestamp before 8640000000000000"},meta:"an integer representing a safe Unix timestamp"}),DB=Ye({domain:"number",divisor:1}),ME=ze.module({root:me.number,integer:DB,epoch:MB,safe:Ye({domain:{domain:"number",numberAllowsNaN:!1},min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}),NaN:["===",Number.NaN],Infinity:["===",Number.POSITIVE_INFINITY],NegativeInfinity:["===",Number.NEGATIVE_INFINITY]},{name:"number"}),et=(t,e,n)=>{const r={domain:"string",pattern:{rule:t.source,flags:t.flags,meta:e}};return n&&(r.meta={format:n}),By("intersection",r)},e1=et(Gc,"a well-formed integer string"),DE=ze.module({root:e1,parse:Ye({in:e1,morphs:(t,e)=>{const n=Number.parseInt(t);return Number.isSafeInteger(n)?n:e.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:me.integer})},{name:"string.integer"}),NB=et(/^[\dA-Fa-f]+$/,"hex characters only"),$B=ze.module({root:et(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:et(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),t1=et(/^[A-Z].*$/,"capitalized"),jB=ze.module({root:Ye({in:"string",morphs:t=>t.charAt(0).toUpperCase()+t.slice(1),declaredOut:t1}),preformatted:t1},{name:"string.capitalize"}),BB=t=>{const e=t.replace(/[ -]+/g,"");let n=0,r,a,u=!1;for(let c=e.length-1;c>=0;c--)r=e.substring(c,c+1),a=Number.parseInt(r,10),u?(a*=2,n+=a>=10?a%10+1:a):n+=a,u=!u;return!!(n%10===0&&e)},zB=/^(?:4\d{12}(?:\d{3,6})?|5[1-5]\d{14}|(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}|6(?:011|5\d\d)\d{12,15}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|(?:2131|1800|35\d{3})\d{11}|6[27]\d{14}|^(81\d{14,17}))$/,LB=Ye({domain:"string",pattern:{meta:"a credit card number",rule:zB.source},predicate:{meta:"a credit card number",predicate:BB}}),VB=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([,.]\d+(?!:))?)?(\17[0-5]\d([,.]\d+)?)?([Zz]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,UB=t=>!Number.isNaN(new Date(t).valueOf()),n1=Ye({domain:"string",predicate:{meta:"a parsable date",predicate:UB}}).assertHasKind("intersection"),i1=DE.root.internal.narrow((t,e)=>{const n=Number.parseInt(t),r=ME.epoch(n);return r instanceof Lr?(e.errors.merge(r),!1):!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),KB=ze.module({root:i1,parse:Ye({in:i1,morphs:t=>new Date(t),declaredOut:me.Date})},{name:"string.date.epoch"}),r1=et(VB,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),qB=ze.module({root:r1,parse:Ye({in:r1,morphs:t=>new Date(t),declaredOut:me.Date})},{name:"string.date.iso"}),PB=ze.module({root:n1,parse:Ye({declaredIn:n1,in:"string",morphs:(t,e)=>{const n=new Date(t);return Number.isNaN(n.valueOf())?e.error("a parsable date"):n},declaredOut:me.Date}),iso:qB,epoch:KB},{name:"string.date"}),IB=et(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),s1="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",Or=`(${s1}[.]){3}${s1}`,HB=new RegExp(`^${Or}$`),Tt="(?:[0-9a-fA-F]{1,4})",FB=new RegExp(`^((?:${Tt}:){7}(?:${Tt}|:)|(?:${Tt}:){6}(?:${Or}|:${Tt}|:)|(?:${Tt}:){5}(?::${Or}|(:${Tt}){1,2}|:)|(?:${Tt}:){4}(?:(:${Tt}){0,1}:${Or}|(:${Tt}){1,3}|:)|(?:${Tt}:){3}(?:(:${Tt}){0,2}:${Or}|(:${Tt}){1,4}|:)|(?:${Tt}:){2}(?:(:${Tt}){0,3}:${Or}|(:${Tt}){1,5}|:)|(?:${Tt}:){1}(?:(:${Tt}){0,4}:${Or}|(:${Tt}){1,6}|:)|(?::((?::${Tt}){0,5}:${Or}|(?::${Tt}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),GB=ze.module({root:["v4 | v6","@","an IP address"],v4:et(HB,"an IPv4 address","ipv4"),v6:et(FB,"an IPv6 address","ipv6")},{name:"string.ip"}),Do="a JSON string",NE=t=>{if(!(t instanceof SyntaxError))throw t;return`must be ${Do} (${t})`},YB=Ye({meta:Do,domain:"string",predicate:{meta:Do,predicate:(t,e)=>{try{return JSON.parse(t),!0}catch(n){return e.reject({code:"predicate",expected:Do,problem:NE(n)})}}}}),JB=(t,e)=>{if(t.length===0)return e.error({code:"predicate",expected:Do,actual:"empty"});try{return JSON.parse(t)}catch(n){return e.error({code:"predicate",expected:Do,problem:NE(n)})}},XB=ze.module({root:YB,parse:Ye({meta:"safe JSON string parser",in:"string",morphs:JB,declaredOut:me.jsonObject})},{name:"string.json"}),o1=et(/^[a-z]*$/,"only lowercase letters"),ZB=ze.module({root:Ye({in:"string",morphs:t=>t.toLowerCase(),declaredOut:o1}),preformatted:o1},{name:"string.lower"}),$E=["NFC","NFD","NFKC","NFKD"],jl=Ge($E,(t,e)=>[e,Ye({domain:"string",predicate:n=>n.normalize(e)===n,meta:`${e}-normalized unicode`})]),Cf=Ge($E,(t,e)=>[e,Ye({in:"string",morphs:n=>n.normalize(e),declaredOut:jl[e]})]),QB=ze.module({root:Cf.NFC,preformatted:jl.NFC},{name:"string.normalize.NFC"}),WB=ze.module({root:Cf.NFD,preformatted:jl.NFD},{name:"string.normalize.NFD"}),ez=ze.module({root:Cf.NFKC,preformatted:jl.NFKC},{name:"string.normalize.NFKC"}),tz=ze.module({root:Cf.NFKD,preformatted:jl.NFKD},{name:"string.normalize.NFKD"}),nz=ze.module({root:"NFC",NFC:QB,NFD:WB,NFKC:ez,NFKD:tz},{name:"string.normalize"}),a1=et(nm,"a well-formed numeric string"),iz=ze.module({root:a1,parse:Ye({in:a1,morphs:t=>Number.parseFloat(t),declaredOut:me.number})},{name:"string.numeric"}),l1="a regex pattern",rz=Ye({domain:"string",predicate:{meta:l1,predicate:(t,e)=>{try{return new RegExp(t),!0}catch(n){return e.reject({code:"predicate",expected:l1,problem:String(n)})}}},meta:{format:"regex"}}),sz=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/,oz=et(sz,"a semantic version (see https://semver.org/)"),u1=et(/^\S.*\S$|^\S?$/,"trimmed"),az=ze.module({root:Ye({in:"string",morphs:t=>t.trim(),declaredOut:u1}),preformatted:u1},{name:"string.trim"}),c1=et(/^[A-Z]*$/,"only uppercase letters"),lz=ze.module({root:Ye({in:"string",morphs:t=>t.toUpperCase(),declaredOut:c1}),preformatted:c1},{name:"string.upper"}),uz=t=>URL.canParse(t),f1=Ye({domain:"string",predicate:{meta:"a URL string",predicate:uz},meta:{format:"uri"}}),cz=ze.module({root:f1,parse:Ye({declaredIn:f1,in:"string",morphs:(t,e)=>{try{return new URL(t)}catch{return e.error("a URL string")}},declaredOut:Ye(URL)})},{name:"string.url"}),fz=ze.module({root:["versioned | nil | max","@",{description:"a UUID",format:"uuid"}],"#nil":"'00000000-0000-0000-0000-000000000000'","#max":"'ffffffff-ffff-ffff-ffff-ffffffffffff'","#versioned":/[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}/i,v1:et(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:et(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:et(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:et(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:et(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:et(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:et(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:et(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),dz=ze.module({root:me.string,alpha:et(/^[A-Za-z]*$/,"only letters"),alphanumeric:et(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:NB,base64:$B,capitalize:jB,creditCard:LB,date:PB,digits:et(/^\d*$/,"only digits 0-9"),email:IB,integer:DE,ip:GB,json:XB,lower:ZB,normalize:nz,numeric:iz,regex:rz,semver:oz,trim:az,upper:lz,url:cz,uuid:fz},{name:"string"}),hz=ze.module({bigint:me.bigint,boolean:me.boolean,false:me.false,never:me.never,null:me.null,number:me.number,object:me.object,string:me.string,symbol:me.symbol,true:me.true,unknown:me.unknown,undefined:me.undefined}),pz=ze.module({root:me.unknown,any:me.unknown},{name:"unknown"}),mz=ze.module({root:me.jsonObject,stringify:By("morph",{in:me.jsonObject,morphs:t=>JSON.stringify(t),declaredOut:me.string})},{name:"object.json"}),yz=ze.module({root:me.object,json:mz},{name:"object"});class gz extends Si{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}const bz=er(["K",me.key],"V")(t=>({domain:"object",index:{signature:t.K,value:t.V}}),gz);class vz extends Si{description='pick a set of properties from an object like `Pick(User, "name | age")`'}const Sz=er(["T",me.object],["K",me.key])(t=>t.T.pick(t.K),vz);class wz extends Si{description='omit a set of properties from an object like `Omit(User, "age")`'}const xz=er(["T",me.object],["K",me.key])(t=>t.T.omit(t.K),wz);class Tz extends Si{description="make all named properties of an object optional like `Partial(User)`"}const Az=er(["T",me.object])(t=>t.T.partial(),Tz);class Ez extends Si{description="make all named properties of an object required like `Required(User)`"}const Oz=er(["T",me.object])(t=>t.T.required(),Ez);class _z extends Si{description='exclude branches of a union like `Exclude("boolean", "true")`'}const Rz=er("T","U")(t=>t.T.exclude(t.U),_z);class Cz extends Si{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}const kz=er("T","U")(t=>t.T.extract(t.U),Cz),Mz=ze.module({Exclude:Rz,Extract:kz,Omit:xz,Partial:Az,Pick:Sz,Record:bz,Required:Oz}),Fr=vB({...hz,...Mz,...kB,...xB,string:dz,number:ME,object:yz,unknown:pz},{prereducedAliases:!0,name:"ark"}),jt=Fr.export();Object.assign(yl.ambient,jt);yl.typeAttachments={string:jt.string.root,number:jt.number.root,bigint:jt.bigint,boolean:jt.boolean,symbol:jt.symbol,undefined:jt.undefined,null:jt.null,object:jt.object.root,unknown:jt.unknown.root,false:jt.false,true:jt.true,never:jt.never,arrayIndex:jt.Array.index,Key:jt.Key,Record:jt.Record,Array:jt.Array.root,Date:jt.Date};const Ot=Object.assign(Fr.type,yl.typeAttachments);Fr.match;Fr.fn;Fr.generic;Fr.schema;Fr.define;Fr.declare;const jE={100:'"Continue"',101:'"Switching Protocols"',102:'"Processing"',103:'"Early Hints"',200:'"OK"',201:'"Created"',202:'"Accepted"',203:'"Non-Authoritative Information"',204:'"No Content"',205:'"Reset Content"',206:'"Partial Content"',207:'"Multi-Status"',208:'"Already Reported"',226:'"IM Used"',300:'"Multiple Choices"',301:'"Moved Permanently"',302:'"Found"',303:'"See Other"',304:'"Not Modified"',305:'"Use Proxy"',306:'"Switch Proxy"',307:'"Temporary Redirect"',308:'"Permanent Redirect"',400:'"Bad Request"',401:'"Unauthorized"',402:'"Payment Required"',403:'"Forbidden"',404:'"Not Found"',405:'"Method Not Allowed"',406:'"Not Acceptable"',407:'"Proxy Authentication Required"',408:'"Request Timeout"',409:'"Conflict"',410:'"Gone"',411:'"Length Required"',412:'"Precondition Failed"',413:'"Payload Too Large"',414:'"URI Too Long"',415:'"Unsupported Media Type"',416:'"Range Not Satisfiable"',417:'"Expectation Failed"',418:`"I'm a teapot"`,421:'"Misdirected Request"',422:'"Unprocessable Entity"',423:'"Locked"',424:'"Failed Dependency"',425:'"Too Early"',426:'"Upgrade Required"',428:'"Precondition Required"',429:'"Too Many Requests"',431:'"Request Header Fields Too Large"',451:'"Unavailable For Legal Reasons"',500:'"Internal Server Error"',501:'"Not Implemented"',502:'"Bad Gateway"',503:'"Service Unavailable"',504:'"Gateway Timeout"',505:'"HTTP Version Not Supported"',506:'"Variant Also Negotiates"',507:'"Insufficient Storage"',508:'"Loop Detected"',510:'"Not Extended"',511:'"Network Authentication Required"'};function Dz(t){return Number.parseInt(t,10)}const Nz=Ot(jE),$z=Nz.keyof().pipe(t=>Dz(t));Ot([$z,"string"]);function jz(t){return F.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 500 101",...t,children:[F.jsx("title",{children:"Tempest Games Logo"}),F.jsx("path",{d:"M155.76.93v59.89h-17.11V7.78h-13.69V.93h30.8Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M202.91,7.86h-13.18v17.03h13.18v6.84h-13.18v22.24h13.18v6.84h-30.29V.93h30.29v6.93Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M289.49.93v59.89h-17.11V7.78h-.43c-8.21,0-11.21,5.82-11.21,17.03v36.02h-16.25V24.8c0-11.21-2.99-17.03-11.21-17.03h-.43v53.04h-17.11V.93h18.74c9.92,0,15.31,4.96,18.14,11.21,2.82-6.25,8.21-11.21,18.14-11.21h18.73Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M352.82,29.68c0,11.72-6.42,19.16-24.55,19.16h-4.53v11.98h-17.11V1.1l46.2-.17v28.75ZM323.73,7.78v34.22h2.48c7.36,0,9.5-4.11,9.5-12.15V7.78h-11.98Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M396.8,7.86h-13.17v17.03h13.17v6.84h-13.17v22.24h13.17v6.84h-30.28V.93h30.28v6.93Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M425.9,12.57v14.03h27.89v16.94c0,12.75-1.71,18.13-16.43,18.13h-14.54c-9.58,0-14.03-2.74-14.03-11.97v-5.99h15.4v5.13c0,4.53.77,5.99,4.62,5.99h1.71c5.05,0,6.16-1.46,6.16-6.84v-14.54h-27.89v-16.68c0-13.52,3.85-16.68,18.82-16.68h12.83c8.81,0,13.17,1.54,13.17,10.78v7.19h-15.4v-6.5c0-3.42-1.03-4.62-4.45-4.62h-1.45c-4.28,0-6.42,1.46-6.42,5.65Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M500,7.78h-13.69v53.04h-17.11V.93h30.8v6.84Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M155.96,93.78v-3.57h-5.58v-7.14h13.39v17.85h-24.76v-28.56h24.76v7.14h-16.96v14.28h9.15Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M224.26,100.92h-8.25v-10.71h-8.25v3.57h4.68v7.14h-12.94v-17.85h16.51v-3.57h-16.51v-7.14h24.76v28.56Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M259.99,72.36h30.57v28.56h-7.81v-21.42h-3.57v21.42h-7.81v-21.42h-3.57v21.42h-7.81v-28.56Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M343.24,83.08v-3.57h-9.14v14.28h16.96v7.14h-24.76v-28.56h24.76v17.85h-13.38v-7.14h5.57Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M394.59,79.5v3.57h16.96v17.85h-24.76v-7.14h16.96v-3.57h-16.96v-17.85h24.76v7.14h-16.96Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M0,63.42v-20.84h20.83L0,63.42ZM100,.92v32.29h-35.42v8.33h-8.33V14.46h-22.92l1.04,7.29h9.38v19.79h-8.33v-8.33H0V.92h100ZM0,100.92v-26.04l6.25-1.04,25-26.04,1.04,1.05-10.42,18.75-4.16,7.29h13.54l3.13-3.12,8.33-22.92h1.04v41.66h3.12l9.38-8.33v-33.33h1.04l8.33,22.92,3.12,3.12h13.54l-4.17-7.29-10.42-19.8,1.04-1.04,25,27.09,6.25,1.04v26.04H0ZM100,42.59v20.84l-20.83-20.84h20.83Z",style:{fill:"var(--logo-color)",strokeWidth:0}})]})}function BE(t){return F.jsx("a",{...t})}const Bz={class:"_class_1riwg_1"},gp=["⠋","⠙","⠸","⠴","⠦","⠇"];function zz({input:t}){const e=$.useRef(null),[n,r]=$.useState(typeof t=="string"?t:null);return $.useEffect(()=>{let a=!0,u;if(typeof t=="string")r(t);else{let c=0;u=setInterval(()=>{e.current&&(e.current.textContent=gp[c],c=(c+1)%gp.length)},100),t.then(f=>{a&&(clearInterval(u),r(f))})}return()=>{a=!1,u&&clearInterval(u)}},[t]),F.jsx("span",{ref:e,children:n??gp[0]})}var Lz=Object.create,zE=Object.defineProperty,Vz=Object.getOwnPropertyDescriptor,LE=Object.getOwnPropertyNames,Uz=Object.getPrototypeOf,Kz=Object.prototype.hasOwnProperty,wi=(t,e)=>function(){return e||(0,t[LE(t)[0]])((e={exports:{}}).exports,e),e.exports},qz=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(var a=LE(e),u=0,c=a.length,f;u<c;u++)f=a[u],!Kz.call(t,f)&&f!==n&&zE(t,f,{get:(h=>e[h]).bind(null,f),enumerable:!(r=Vz(e,f))||r.enumerable});return t},bt=(t,e,n)=>(n=t!=null?Lz(Uz(t)):{},qz(zE(n,"default",{value:t,enumerable:!0}),t)),VE=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(t,e){function n(r){"@babel/helpers - typeof";return e.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},e.exports.__esModule=!0,e.exports.default=e.exports,n(r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}}),Pz=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(t,e){var n=VE().default;function r(a,u){if(n(a)!="object"||!a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var f=c.call(a,u||"default");if(n(f)!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(u==="string"?String:Number)(a)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),Iz=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(t,e){var n=VE().default,r=Pz();function a(u){var c=r(u,"string");return n(c)=="symbol"?c:c+""}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}}),ks=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(t,e){var n=Iz();function r(a,u,c){return(u=n(u))in a?Object.defineProperty(a,u,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[u]=c,a}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),ni=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(t,e){var n=ks();function r(u,c){var f=Object.keys(u);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(u);c&&(h=h.filter(function(m){return Object.getOwnPropertyDescriptor(u,m).enumerable})),f.push.apply(f,h)}return f}function a(u){for(var c=1;c<arguments.length;c++){var f=arguments[c]!=null?arguments[c]:{};c%2?r(Object(f),!0).forEach(function(h){n(u,h,f[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(f)):r(Object(f)).forEach(function(h){Object.defineProperty(u,h,Object.getOwnPropertyDescriptor(f,h))})}return u}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}});function kf(t){const e={subscribe(n){let r=null,a=!1,u=!1,c=!1;function f(){if(r===null){c=!0;return}u||(u=!0,typeof r=="function"?r():r&&r.unsubscribe())}return r=t({next(h){var m;a||(m=n.next)===null||m===void 0||m.call(n,h)},error(h){var m;a||(a=!0,(m=n.error)===null||m===void 0||m.call(n,h),f())},complete(){var h;a||(a=!0,(h=n.complete)===null||h===void 0||h.call(n),f())}}),c&&f(),{unsubscribe:f}},pipe(...n){return n.reduce(Hz,e)}};return e}function Hz(t,e){return e(t)}function Fz(t){const e=new AbortController;return new Promise((r,a)=>{let u=!1;function c(){u||(u=!0,f.unsubscribe())}e.signal.addEventListener("abort",()=>{a(e.signal.reason)});const f=t.subscribe({next(h){u=!0,r(h),c()},error(h){a(h)},complete(){e.abort(),c()}})})}function Gz(t){return e=>{let n=0,r=null;const a=[];function u(){r||(r=e.subscribe({next(f){for(const m of a){var h;(h=m.next)===null||h===void 0||h.call(m,f)}},error(f){for(const m of a){var h;(h=m.error)===null||h===void 0||h.call(m,f)}},complete(){for(const h of a){var f;(f=h.complete)===null||f===void 0||f.call(h)}}}))}function c(){if(n===0&&r){const f=r;r=null,f.unsubscribe()}}return kf(f=>(n++,a.push(f),u(),{unsubscribe(){n--,c();const h=a.findIndex(m=>m===f);h>-1&&a.splice(h,1)}}))}}function Yz(t){let e=t;const n=[],r=c=>{e!==void 0&&c.next(e),n.push(c)},a=c=>{n.splice(n.indexOf(c),1)},u=kf(c=>(r(c),()=>{a(c)}));return u.next=c=>{if(e!==c){e=c;for(const f of n)f.next(c)}},u.get=()=>e,u}function Jz(t){return kf(e=>{function n(a=0,u=t.op){const c=t.links[a];if(!c)throw new Error("No more links to execute - did you forget to add an ending link?");return c({op:u,next(h){return n(a+1,h)}})}return n().subscribe(e)})}function gl(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}var Xz=Object.create,UE=Object.defineProperty,Zz=Object.getOwnPropertyDescriptor,KE=Object.getOwnPropertyNames,Qz=Object.getPrototypeOf,Wz=Object.prototype.hasOwnProperty,Bl=(t,e)=>function(){return e||(0,t[KE(t)[0]])((e={exports:{}}).exports,e),e.exports},eL=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(var a=KE(e),u=0,c=a.length,f;u<c;u++)f=a[u],!Wz.call(t,f)&&f!==n&&UE(t,f,{get:(h=>e[h]).bind(null,f),enumerable:!(r=Zz(e,f))||r.enumerable});return t},Mf=(t,e,n)=>(n=t!=null?Xz(Qz(t)):{},eL(UE(n,"default",{value:t,enumerable:!0}),t));const qE=()=>{},d1=t=>{Object.freeze&&Object.freeze(t)};function PE(t,e,n){var r;const a=e.join(".");return(r=n[a])!==null&&r!==void 0||(n[a]=new Proxy(qE,{get(u,c){if(!(typeof c!="string"||c==="then"))return PE(t,[...e,c],n)},apply(u,c,f){const h=e[e.length-1];let m={args:f,path:e};return h==="call"?m={args:f.length>=2?[f[1]]:[],path:e.slice(0,-1)}:h==="apply"&&(m={args:f.length>=2?f[1]:[],path:e.slice(0,-1)}),d1(m.args),d1(m.path),t(m)}})),n[a]}const tL=t=>PE(t,[],Object.create(null)),nL=t=>new Proxy(qE,{get(e,n){if(n!=="then")return t(n)}});var IE=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(t,e){function n(r){"@babel/helpers - typeof";return e.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},e.exports.__esModule=!0,e.exports.default=e.exports,n(r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}}),iL=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(t,e){var n=IE().default;function r(a,u){if(n(a)!="object"||!a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var f=c.call(a,u||"default");if(n(f)!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(u==="string"?String:Number)(a)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),rL=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(t,e){var n=IE().default,r=iL();function a(u){var c=r(u,"string");return n(c)=="symbol"?c:c+""}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}}),HE=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(t,e){var n=rL();function r(a,u,c){return(u=n(u))in a?Object.defineProperty(a,u,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[u]=c,a}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),Vy=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(t,e){var n=HE();function r(u,c){var f=Object.keys(u);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(u);c&&(h=h.filter(function(m){return Object.getOwnPropertyDescriptor(u,m).enumerable})),f.push.apply(f,h)}return f}function a(u){for(var c=1;c<arguments.length;c++){var f=arguments[c]!=null?arguments[c]:{};c%2?r(Object(f),!0).forEach(function(h){n(u,h,f[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(f)):r(Object(f)).forEach(function(h){Object.defineProperty(u,h,Object.getOwnPropertyDescriptor(f,h))})}return u}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}});Mf(Vy());Mf(HE());var dc=Mf(Vy());function sL(t,e){if("error"in t){const r=e.deserialize(t.error);return{ok:!1,error:(0,dc.default)((0,dc.default)({},t),{},{error:r})}}return{ok:!0,result:(0,dc.default)((0,dc.default)({},t.result),(!t.result.type||t.result.type==="data")&&{type:"data",data:e.deserialize(t.result.data)})}}var bp=class extends Error{constructor(){super("Unable to transform response from server")}};function oL(t,e){let n;try{n=sL(t,e)}catch{throw new bp}if(!n.ok&&(!gl(n.error.error)||typeof n.error.error.code!="number"))throw new bp;if(n.ok&&!gl(n.result))throw new bp;return n}Mf(Vy());var hc=bt(ks()),vo=bt(ni());function aL(t){return t instanceof bl}function lL(t){return gl(t)&&gl(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}function uL(t,e){return typeof t=="string"?t:gl(t)&&typeof t.message=="string"?t.message:e}var bl=class Ec extends Error{constructor(e,n){var r,a;const u=n?.cause;super(e,{cause:u}),(0,hc.default)(this,"cause",void 0),(0,hc.default)(this,"shape",void 0),(0,hc.default)(this,"data",void 0),(0,hc.default)(this,"meta",void 0),this.meta=n?.meta,this.cause=u,this.shape=n==null||(r=n.result)===null||r===void 0?void 0:r.error,this.data=n==null||(a=n.result)===null||a===void 0?void 0:a.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,Ec.prototype)}static from(e,n={}){const r=e;return aL(r)?(n.meta&&(r.meta=(0,vo.default)((0,vo.default)({},r.meta),n.meta)),r):lL(r)?new Ec(r.error.message,(0,vo.default)((0,vo.default)({},n),{},{result:r})):new Ec(uL(r,"Unknown error"),(0,vo.default)((0,vo.default)({},n),{},{cause:r}))}};function cL(t){const e=t;return e?"input"in e?e:{input:e,output:e}:{input:{serialize:n=>n,deserialize:n=>n},output:{serialize:n=>n,deserialize:n=>n}}}const h1=t=>typeof t=="function";function fL(t){if(t)return t;if(typeof window<"u"&&h1(window.fetch))return window.fetch;if(typeof globalThis<"u"&&h1(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}var il=bt(ni());function dL(t){return{url:t.url.toString(),fetch:t.fetch,transformer:cL(t.transformer),methodOverride:t.methodOverride}}function hL(t){const e={};for(let n=0;n<t.length;n++){const r=t[n];e[n]=r}return e}const pL={query:"GET",mutation:"POST",subscription:"PATCH"};function FE(t){return"input"in t?t.transformer.input.serialize(t.input):hL(t.inputs.map(e=>t.transformer.input.serialize(e)))}const GE=t=>{const e=t.url.split("?");let r=e[0].replace(/\/$/,"")+"/"+t.path;const a=[];if(e[1]&&a.push(e[1]),"inputs"in t&&a.push("batch=1"),t.type==="query"||t.type==="subscription"){const u=FE(t);u!==void 0&&t.methodOverride!=="POST"&&a.push(`input=${encodeURIComponent(JSON.stringify(u))}`)}return a.length&&(r+="?"+a.join("&")),r},mL=t=>{if(t.type==="query"&&t.methodOverride!=="POST")return;const e=FE(t);return e!==void 0?JSON.stringify(e):void 0},yL=t=>SL((0,il.default)((0,il.default)({},t),{},{contentTypeHeader:"application/json",getUrl:GE,getBody:mL}));var gL=class extends Error{constructor(){const t="AbortError";super(t),this.name=t,this.message=t}};const bL=t=>{var e;if(t?.aborted)throw(e=t.throwIfAborted)===null||e===void 0||e.call(t),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new gL};async function vL(t){var e;bL(t.signal);const n=t.getUrl(t),r=t.getBody(t),a=(e=t.methodOverride)!==null&&e!==void 0?e:pL[t.type],u=await(async()=>{const f=await t.headers();return Symbol.iterator in f?Object.fromEntries(f):f})(),c=(0,il.default)((0,il.default)((0,il.default)({},t.contentTypeHeader&&a!=="GET"?{"content-type":t.contentTypeHeader}:{}),t.trpcAcceptHeader?{"trpc-accept":t.trpcAcceptHeader}:void 0),u);return fL(t.fetch)(n,{method:a,signal:t.signal,body:r,headers:c})}async function SL(t){const e={},n=await vL(t);e.response=n;const r=await n.json();return e.responseJSON=r,{json:r,meta:e}}bt(ni());const p1=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function m1(t){let e=null,n=null;const r=()=>{clearTimeout(n),n=null,e=null};function a(f){const h=[[]];let m=0;for(;;){const v=f[m];if(!v)break;const S=h[h.length-1];if(v.aborted){var y;(y=v.reject)===null||y===void 0||y.call(v,new Error("Aborted")),m++;continue}if(t.validate(S.concat(v).map(T=>T.key))){S.push(v),m++;continue}if(S.length===0){var g;(g=v.reject)===null||g===void 0||g.call(v,new Error("Input is too big for a single dispatch")),m++;continue}h.push([])}return h}function u(){const f=a(e);r();for(const h of f){if(!h.length)continue;const m={items:h};for(const g of h)g.batch=m;t.fetch(m.items.map(g=>g.key)).then(async g=>{await Promise.all(g.map(async(S,x)=>{const T=m.items[x];try{var M;const _=await Promise.resolve(S);(M=T.resolve)===null||M===void 0||M.call(T,_)}catch(_){var C;(C=T.reject)===null||C===void 0||C.call(T,_)}T.batch=null,T.reject=null,T.resolve=null}));for(const S of m.items){var v;(v=S.reject)===null||v===void 0||v.call(S,new Error("Missing result")),S.batch=null}}).catch(g=>{for(const S of m.items){var v;(v=S.reject)===null||v===void 0||v.call(S,g),S.batch=null}})}}function c(f){var h;const m={aborted:!1,key:f,batch:null,resolve:p1,reject:p1},y=new Promise((g,v)=>{var S;m.reject=v,m.resolve=g,(S=e)!==null&&S!==void 0||(e=[]),e.push(m)});return(h=n)!==null&&h!==void 0||(n=setTimeout(u)),y}return{load:c}}function wL(...t){const e=new AbortController,n=t.length;let r=0;const a=()=>{++r===n&&e.abort()};for(const u of t)u?.aborted?a():u?.addEventListener("abort",a,{once:!0});return e.signal}var pc=bt(ni());function xL(t){var e,n;const r=dL(t),a=(e=t.maxURLLength)!==null&&e!==void 0?e:1/0,u=(n=t.maxItems)!==null&&n!==void 0?n:1/0;return()=>{const c=y=>({validate(g){if(a===1/0&&u===1/0)return!0;if(g.length>u)return!1;const v=g.map(T=>T.path).join(","),S=g.map(T=>T.input);return GE((0,pc.default)((0,pc.default)({},r),{},{type:y,path:v,inputs:S,signal:null})).length<=a},async fetch(g){const v=g.map(_=>_.path).join(","),S=g.map(_=>_.input),x=wL(...g.map(_=>_.signal)),T=await yL((0,pc.default)((0,pc.default)({},r),{},{path:v,inputs:S,type:y,headers(){return t.headers?typeof t.headers=="function"?t.headers({opList:g}):t.headers:{}},signal:x}));return(Array.isArray(T.json)?T.json:g.map(()=>T.json)).map(_=>({meta:T.meta,json:_}))}}),f=m1(c("query")),h=m1(c("mutation")),m={query:f,mutation:h};return({op:y})=>kf(g=>{if(y.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const S=m[y.type].load(y);let x;return S.then(T=>{x=T;const M=oL(T.json,r.transformer.output);if(!M.ok){g.error(bl.from(M.error,{meta:T.meta}));return}g.next({context:T.meta,result:M.result}),g.complete()}).catch(T=>{g.error(bl.from(T,{meta:x?.meta}))}),()=>{}})}}bt(ni());const YE=(t,...e)=>typeof t=="function"?t(...e):t;bt(ks());function TL(){let t,e;return{promise:new Promise((r,a)=>{t=r,e=a}),resolve:t,reject:e}}async function AL(t){const e=await YE(t.url);if(!t.connectionParams)return e;const r=`${e.includes("?")?"&":"?"}connectionParams=1`;return e+r}async function EL(t){const e={method:"connectionParams",data:await YE(t)};return JSON.stringify(e)}bt(ks());var ps=bt(ks());function OL(t){const{promise:e,resolve:n,reject:r}=TL();return t.addEventListener("open",()=>{t.removeEventListener("error",r),n()}),t.addEventListener("error",r),e}function _L(t,{intervalMs:e,pongTimeoutMs:n}){let r,a;function u(){r=setTimeout(()=>{t.send("PING"),a=setTimeout(()=>{t.close()},n)},e)}function c(){clearTimeout(r),u()}function f(){clearTimeout(a),c()}t.addEventListener("open",u),t.addEventListener("message",({data:h})=>{clearTimeout(r),u(),h==="PONG"&&f()}),t.addEventListener("close",()=>{clearTimeout(r),clearTimeout(a)})}var RL=class vm{constructor(e){var n;if((0,ps.default)(this,"id",++vm.connectCount),(0,ps.default)(this,"WebSocketPonyfill",void 0),(0,ps.default)(this,"urlOptions",void 0),(0,ps.default)(this,"keepAliveOpts",void 0),(0,ps.default)(this,"wsObservable",Yz(null)),(0,ps.default)(this,"openPromise",null),this.WebSocketPonyfill=(n=e.WebSocketPonyfill)!==null&&n!==void 0?n:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=e.urlOptions,this.keepAliveOpts=e.keepAlive}get ws(){return this.wsObservable.get()}set ws(e){this.wsObservable.next(e)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var e=this;if(e.openPromise)return e.openPromise;e.id=++vm.connectCount;const n=AL(e.urlOptions).then(r=>new e.WebSocketPonyfill(r));e.openPromise=n.then(async r=>{e.ws=r,r.addEventListener("message",function({data:a}){a==="PING"&&this.send("PONG")}),e.keepAliveOpts.enabled&&_L(r,e.keepAliveOpts),r.addEventListener("close",()=>{e.ws===r&&(e.ws=null)}),await OL(r),e.urlOptions.connectionParams&&r.send(await EL(e.urlOptions.connectionParams))});try{await e.openPromise}finally{e.openPromise=null}}async close(){var e=this;try{await e.openPromise}finally{var n;(n=e.ws)===null||n===void 0||n.close()}}};(0,ps.default)(RL,"connectCount",0);bt(ks());bt(ni());var vp=bt(ks()),y1=bt(ni()),CL=class{constructor(t){(0,vp.default)(this,"links",void 0),(0,vp.default)(this,"runtime",void 0),(0,vp.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=t.links.map(e=>e(this.runtime))}$request(t){var e;return Jz({links:this.links,op:(0,y1.default)((0,y1.default)({},t),{},{context:(e=t.context)!==null&&e!==void 0?e:{},id:++this.requestId})}).pipe(Gz())}async requestAsPromise(t){var e=this;try{const n=e.$request(t);return(await Fz(n)).result.data}catch(n){throw bl.from(n)}}query(t,e,n){return this.requestAsPromise({type:"query",path:t,input:e,context:n?.context,signal:n?.signal})}mutation(t,e,n){return this.requestAsPromise({type:"mutation",path:t,input:e,context:n?.context,signal:n?.signal})}subscription(t,e,n){return this.$request({type:"subscription",path:t,input:e,context:n.context,signal:n.signal}).subscribe({next(a){switch(a.result.type){case"state":{var u;(u=n.onConnectionStateChange)===null||u===void 0||u.call(n,a.result);break}case"started":{var c;(c=n.onStarted)===null||c===void 0||c.call(n,{context:a.context});break}case"stopped":{var f;(f=n.onStopped)===null||f===void 0||f.call(n);break}case"data":case void 0:{var h;(h=n.onData)===null||h===void 0||h.call(n,a.result.data);break}}},error(a){var u;(u=n.onError)===null||u===void 0||u.call(n,a)},complete(){var a;(a=n.onComplete)===null||a===void 0||a.call(n)}})}};const kL=Symbol.for("trpc_untypedClient"),ML={query:"query",mutate:"mutation",subscribe:"subscription"},DL=t=>ML[t];function NL(t){const e=tL(({path:n,args:r})=>{const a=[...n],u=DL(a.pop()),c=a.join(".");return t[u](c,...r)});return nL(n=>n===kL?t:e[n])}function $L(t){const e=new CL(t);return NL(e)}bt(ni());bt(ni());var jL=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(t,e){function n(a){var u,c,f,h=2;for(typeof Symbol<"u"&&(c=Symbol.asyncIterator,f=Symbol.iterator);h--;){if(c&&(u=a[c])!=null)return u.call(a);if(f&&(u=a[f])!=null)return new r(u.call(a));c="@@asyncIterator",f="@@iterator"}throw new TypeError("Object is not async iterable")}function r(a){function u(c){if(Object(c)!==c)return Promise.reject(new TypeError(c+" is not an object."));var f=c.done;return Promise.resolve(c.value).then(function(h){return{value:h,done:f}})}return r=function(f){this.s=f,this.n=f.next},r.prototype={s:null,n:null,next:function(){return u(this.n.apply(this.s,arguments))},return:function(f){var h=this.s.return;return h===void 0?Promise.resolve({value:f,done:!0}):u(h.apply(this.s,arguments))},throw:function(f){var h=this.s.return;return h===void 0?Promise.reject(f):u(h.apply(this.s,arguments))}},new r(a)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}});bt(jL());bt(ni());var BL=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(t,e){function n(){var r=typeof SuppressedError=="function"?SuppressedError:function(f,h){var m=Error();return m.name="SuppressedError",m.error=f,m.suppressed=h,m},a={},u=[];function c(f,h){if(h!=null){if(Object(h)!==h)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(f)var m=h[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(m===void 0&&(m=h[Symbol.dispose||Symbol.for("Symbol.dispose")],f))var y=m;if(typeof m!="function")throw new TypeError("Object is not disposable.");y&&(m=function(){try{y.call(h)}catch(v){return Promise.reject(v)}}),u.push({v:h,d:m,a:f})}else f&&u.push({d:h,a:f});return h}return{e:a,u:c.bind(null,!1),a:c.bind(null,!0),d:function(){var h,m=this.e,y=0;function g(){for(;h=u.pop();)try{if(!h.a&&y===1)return y=0,u.push(h),Promise.resolve().then(g);if(h.d){var S=h.d.call(h.v);if(h.a)return y|=2,Promise.resolve(S).then(g,v)}else y|=1}catch(x){return v(x)}if(y===1)return m!==a?Promise.reject(m):Promise.resolve();if(m!==a)throw m}function v(S){return m=m!==a?new r(S,m):S,g()}return g()}}}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}}),JE=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(t,e){function n(r,a){this.v=r,this.k=a}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}}),zL=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(t,e){var n=JE();function r(a){return new n(a,0)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),LL=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(t,e){var n=JE();function r(u){return function(){return new a(u.apply(this,arguments))}}function a(u){var c,f;function h(y,g){try{var v=u[y](g),S=v.value,x=S instanceof n;Promise.resolve(x?S.v:S).then(function(T){if(x){var M=y==="return"?"return":"next";if(!S.k||T.done)return h(M,T);T=u[M](T).value}m(v.done?"return":"normal",T)},function(T){h("throw",T)})}catch(T){m("throw",T)}}function m(y,g){switch(y){case"return":c.resolve({value:g,done:!0});break;case"throw":c.reject(g);break;default:c.resolve({value:g,done:!1})}(c=c.next)?h(c.key,c.arg):f=null}this._invoke=function(y,g){return new Promise(function(v,S){var x={key:y,arg:g,resolve:v,reject:S,next:null};f?f=f.next=x:(c=f=x,h(y,g))})},typeof u.return!="function"&&(this.return=void 0)}a.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},a.prototype.next=function(u){return this._invoke("next",u)},a.prototype.throw=function(u){return this._invoke("throw",u)},a.prototype.return=function(u){return this._invoke("return",u)},e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}});bt(BL());bt(zL());bt(LL());bt(ni());var VL={};function XE(t,e){if(t instanceof Promise)throw new Error(e)}function UL(t,e){const n={},r=[];for(const a in t){const u=t[a]["~standard"].validate(e[a]);if(XE(u,`Validation must be synchronous, but ${a} returned a Promise.`),u.issues){r.push(...u.issues.map(c=>({...c,message:c.message,path:[a,...c.path??[]]})));continue}n[a]=u.value}return r.length?{issues:r}:{value:n}}function KL(t){const e=t.runtimeEnvStrict??t.runtimeEnv??VL;if(t.emptyStringAsUndefined??!1)for(const[_,R]of Object.entries(e))R===""&&delete e[_];if(!!t.skipValidation)return e;const a=typeof t.client=="object"?t.client:{},u=typeof t.server=="object"?t.server:{},c=typeof t.shared=="object"?t.shared:{},f=t.isServer??(typeof window>"u"||"Deno"in window),h=f?{...u,...c,...a}:{...a,...c},m=t.createFinalSchema?.(h,f)["~standard"].validate(e)??UL(h,e);XE(m,"Validation must be synchronous");const y=t.onValidationError??(_=>{throw console.error("❌ Invalid environment variables:",_),new Error("Invalid environment variables")}),g=t.onInvalidAccess??(()=>{throw new Error("❌ Attempted to access a server-side environment variable on the client")});if(m.issues)return y(m.issues);const v=_=>t.clientPrefix?!_.startsWith(t.clientPrefix)&&!(_ in c):!0,S=_=>f||!v(_),x=_=>_==="__esModule"||_==="$$typeof",T=(t.extends??[]).reduce((_,R)=>Object.assign(_,R),{}),M=Object.assign(T,m.value);return new Proxy(M,{get(_,R){if(typeof R=="string"&&!x(R))return S(R)?Reflect.get(_,R):g(R)}})}const qL={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_BACKEND_ORIGIN:"https://realtime.tempest.games"},PL="__vite_start_time"in globalThis,IL=typeof window<"u",Ki=Ot("string"),g1=Ot('"true" | "false" | undefined'),ZE=KL({isServer:!PL&&!IL,server:{CI:Ot("string | undefined").pipe(Boolean),POSTGRES_USER:Ki,POSTGRES_PASSWORD:Ki,POSTGRES_DATABASE:Ki,POSTGRES_HOST:Ki,POSTGRES_PORT:Ki.pipe(t=>Number.parseInt(t,10)),BACKEND_PORT:Ki.pipe(t=>Number.parseInt(t,10)),RUN_WORKERS_FROM_SOURCE:g1.pipe(t=>t==="true"),FRONTEND_PORT:Ki.pipe(t=>Number.parseInt(t,10)),FRONTEND_ORIGINS:Ki.pipe.try(t=>JSON.parse(t),Ot("string[]")),API_KEY_OPENAI:Ot("string | undefined"),API_KEY_RESEND:Ot("string | undefined")},clientPrefix:"VITE_",client:{VITE_BACKEND_ORIGIN:Ki,VITE_DEV_FRONTEND_HOST:Ot("string | undefined"),VITE_DEV_HTTPS:g1.pipe(t=>t==="true")},runtimeEnv:qL,emptyStringAsUndefined:!0}),cn=$L({links:[xL({url:ZE.VITE_BACKEND_ORIGIN,fetch(t,e){return e?(Object.assign(e,{credentials:"include"}),fetch(t,e)):fetch(t)}})]}),HL=ft({key:"appVersionQuery",default:cn.version.query});ft({key:"lastKnownVersion",default:null,effects:[mT(localStorage,JSON,"lastKnownVersion")]});const FL=Wi({key:"appVersion",get:async({get:t})=>{const e=t(HL),{version:n}=await e;return n}});function Sp(t){return["optional",t]}function GL(t,e){let n=[t];for(const r of e){if(typeof r!="string")return!1;n=n.flatMap(a=>{if(a===null)return[];const u=[],c=a[1],f=c[r];f!==void 0&&u.push(f);const h=Object.keys(c).find(m=>m.startsWith("$"));if(h){const m=c[h];m&&u.push(m)}return u})}for(const r of n)if(r===null||r[0]==="optional")return!0;return!1}const yi=Object.create(null);yi.open="0";yi.close="1";yi.ping="2";yi.pong="3";yi.message="4";yi.upgrade="5";yi.noop="6";const Oc=Object.create(null);Object.keys(yi).forEach(t=>{Oc[yi[t]]=t});const Sm={type:"error",data:"parser error"},QE=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",WE=typeof ArrayBuffer=="function",eO=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,Uy=({type:t,data:e},n,r)=>QE&&e instanceof Blob?n?r(e):b1(e,r):WE&&(e instanceof ArrayBuffer||eO(e))?n?r(e):b1(new Blob([e]),r):r(yi[t]+(e||"")),b1=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function v1(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let wp;function YL(t,e){if(QE&&t.data instanceof Blob)return t.data.arrayBuffer().then(v1).then(e);if(WE&&(t.data instanceof ArrayBuffer||eO(t.data)))return e(v1(t.data));Uy(t,!1,n=>{wp||(wp=new TextEncoder),e(wp.encode(n))})}const S1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wa=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<S1.length;t++)Wa[S1.charCodeAt(t)]=t;const JL=t=>{let e=t.length*.75,n=t.length,r,a=0,u,c,f,h;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const m=new ArrayBuffer(e),y=new Uint8Array(m);for(r=0;r<n;r+=4)u=Wa[t.charCodeAt(r)],c=Wa[t.charCodeAt(r+1)],f=Wa[t.charCodeAt(r+2)],h=Wa[t.charCodeAt(r+3)],y[a++]=u<<2|c>>4,y[a++]=(c&15)<<4|f>>2,y[a++]=(f&3)<<6|h&63;return m},XL=typeof ArrayBuffer=="function",Ky=(t,e)=>{if(typeof t!="string")return{type:"message",data:tO(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:ZL(t.substring(1),e)}:Oc[n]?t.length>1?{type:Oc[n],data:t.substring(1)}:{type:Oc[n]}:Sm},ZL=(t,e)=>{if(XL){const n=JL(t);return tO(n,e)}else return{base64:!0,data:t}},tO=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},nO="",QL=(t,e)=>{const n=t.length,r=new Array(n);let a=0;t.forEach((u,c)=>{Uy(u,!1,f=>{r[c]=f,++a===n&&e(r.join(nO))})})},WL=(t,e)=>{const n=t.split(nO),r=[];for(let a=0;a<n.length;a++){const u=Ky(n[a],e);if(r.push(u),u.type==="error")break}return r};function eV(){return new TransformStream({transform(t,e){YL(t,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const u=new DataView(a.buffer);u.setUint8(0,126),u.setUint16(1,r)}else{a=new Uint8Array(9);const u=new DataView(a.buffer);u.setUint8(0,127),u.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(a[0]|=128),e.enqueue(a),e.enqueue(n)})}})}let xp;function mc(t){return t.reduce((e,n)=>e+n.length,0)}function yc(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let a=0;a<e;a++)n[a]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function tV(t,e){xp||(xp=new TextDecoder);const n=[];let r=0,a=-1,u=!1;return new TransformStream({transform(c,f){for(n.push(c);;){if(r===0){if(mc(n)<1)break;const h=yc(n,1);u=(h[0]&128)===128,a=h[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(mc(n)<2)break;const h=yc(n,2);a=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),r=3}else if(r===2){if(mc(n)<8)break;const h=yc(n,8),m=new DataView(h.buffer,h.byteOffset,h.length),y=m.getUint32(0);if(y>Math.pow(2,21)-1){f.enqueue(Sm);break}a=y*Math.pow(2,32)+m.getUint32(4),r=3}else{if(mc(n)<a)break;const h=yc(n,a);f.enqueue(Ky(u?h:xp.decode(h),e)),r=0}if(a===0||a>t){f.enqueue(Sm);break}}}})}const iO=4;function _t(t){if(t)return nV(t)}function nV(t){for(var e in _t.prototype)t[e]=_t.prototype[e];return t}_t.prototype.on=_t.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};_t.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};_t.prototype.off=_t.prototype.removeListener=_t.prototype.removeAllListeners=_t.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===e||r.fn===e){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+t],this};_t.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,e)}return this};_t.prototype.emitReserved=_t.prototype.emit;_t.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};_t.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Df=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),Un=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),iV="arraybuffer";function rO(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const rV=Un.setTimeout,sV=Un.clearTimeout;function Nf(t,e){e.useNativeTimers?(t.setTimeoutFn=rV.bind(Un),t.clearTimeoutFn=sV.bind(Un)):(t.setTimeoutFn=Un.setTimeout.bind(Un),t.clearTimeoutFn=Un.clearTimeout.bind(Un))}const oV=1.33;function aV(t){return typeof t=="string"?lV(t):Math.ceil((t.byteLength||t.size)*oV)}function lV(t){let e=0,n=0;for(let r=0,a=t.length;r<a;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function sO(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function uV(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function cV(t){let e={},n=t.split("&");for(let r=0,a=n.length;r<a;r++){let u=n[r].split("=");e[decodeURIComponent(u[0])]=decodeURIComponent(u[1])}return e}class fV extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class qy extends _t{constructor(e){super(),this.writable=!1,Nf(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,r){return super.emitReserved("error",new fV(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=Ky(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=uV(e);return n.length?"?"+n:""}}class dV extends qy{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};WL(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,QL(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=sO()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let oO=!1;try{oO=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const hV=oO;function pV(){}class mV extends dV{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(a,u)=>{this.onError("xhr post error",a,u)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}let No=class _c extends _t{constructor(e,n,r){super(),this.createRequest=e,Nf(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var e;const n=rO(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=_c.requestsCount++,_c.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=pV,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete _c.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};No.requestsCount=0;No.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",w1);else if(typeof addEventListener=="function"){const t="onpagehide"in Un?"pagehide":"unload";addEventListener(t,w1,!1)}}function w1(){for(let t in No.requests)No.requests.hasOwnProperty(t)&&No.requests[t].abort()}const yV=(function(){const t=aO({xdomain:!1});return t&&t.responseType!==null})();class gV extends mV{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=yV&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new No(aO,this.uri(),e)}}function aO(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||hV))return new XMLHttpRequest}catch{}if(!e)try{return new Un[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const lO=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class bV extends qy{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,r=lO?{}:rO(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],a=n===e.length-1;Uy(r,this.supportsBinary,u=>{try{this.doWrite(r,u)}catch{}a&&Df(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=sO()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const Tp=Un.WebSocket||Un.MozWebSocket;class vV extends bV{createSocket(e,n,r){return lO?new Tp(e,n,r):n?new Tp(e,n):new Tp(e)}doWrite(e,n){this.ws.send(n)}}class SV extends qy{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=tV(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),a=eV();a.readable.pipeTo(e.writable),this._writer=a.writable.getWriter();const u=()=>{r.read().then(({done:f,value:h})=>{f||(this.onPacket(h),u())}).catch(f=>{})};u();const c={type:"open"};this.query.sid&&(c.data=`{"sid":"${this.query.sid}"}`),this._writer.write(c).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],a=n===e.length-1;this._writer.write(r).then(()=>{a&&Df(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const wV={websocket:vV,webtransport:SV,polling:gV},xV=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,TV=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function wm(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let a=xV.exec(t||""),u={},c=14;for(;c--;)u[TV[c]]=a[c]||"";return n!=-1&&r!=-1&&(u.source=e,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=AV(u,u.path),u.queryKey=EV(u,u.query),u}function AV(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function EV(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,u){a&&(n[a]=u)}),n}const xm=typeof addEventListener=="function"&&typeof removeEventListener=="function",Rc=[];xm&&addEventListener("offline",()=>{Rc.forEach(t=>t())},!1);class jr extends _t{constructor(e,n){if(super(),this.binaryType=iV,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const r=wm(e);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=wm(n.host).host);Nf(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=cV(this.opts.query)),xm&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Rc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=iO,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&jr.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",jr.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=aV(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Df(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,r){return this._sendPacket("message",e,n,r),this}send(e,n,r){return this._sendPacket("message",e,n,r),this}_sendPacket(e,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const u={type:e,data:n,options:r};this.emitReserved("packetCreate",u),this.writeBuffer.push(u),a&&this.once("flush",a),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}_onError(e){if(jr.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),xm&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Rc.indexOf(this._offlineEventListener);r!==-1&&Rc.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}jr.protocol=iO;class OV extends jr{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),r=!1;jr.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",g=>{if(!r)if(g.type==="pong"&&g.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;jr.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(y(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=n.name,this.emitReserved("upgradeError",v)}}))};function u(){r||(r=!0,y(),n.close(),n=null)}const c=g=>{const v=new Error("probe error: "+g);v.transport=n.name,u(),this.emitReserved("upgradeError",v)};function f(){c("transport closed")}function h(){c("socket closed")}function m(g){n&&g.name!==n.name&&u()}const y=()=>{n.removeListener("open",a),n.removeListener("error",c),n.removeListener("close",f),this.off("close",h),this.off("upgrading",m)};n.once("open",a),n.once("error",c),n.once("close",f),this.once("close",h),this.once("upgrading",m),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}}let _V=class extends OV{constructor(e,n={}){const r=typeof e=="object"?e:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>wV[a]).filter(a=>!!a)),super(e,r)}};function RV(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=wm(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const u=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+u+":"+r.port+e,r.href=r.protocol+"://"+u+(n&&n.port===r.port?"":":"+r.port),r}const CV=typeof ArrayBuffer=="function",kV=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,uO=Object.prototype.toString,MV=typeof Blob=="function"||typeof Blob<"u"&&uO.call(Blob)==="[object BlobConstructor]",DV=typeof File=="function"||typeof File<"u"&&uO.call(File)==="[object FileConstructor]";function Py(t){return CV&&(t instanceof ArrayBuffer||kV(t))||MV&&t instanceof Blob||DV&&t instanceof File}function Cc(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(Cc(t[n]))return!0;return!1}if(Py(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Cc(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Cc(t[n]))return!0;return!1}function NV(t){const e=[],n=t.data,r=t;return r.data=Tm(n,e),r.attachments=e.length,{packet:r,buffers:e}}function Tm(t,e){if(!t)return t;if(Py(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=Tm(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=Tm(t[r],e));return n}return t}function $V(t,e){return t.data=Am(t.data,e),delete t.attachments,t}function Am(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=Am(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=Am(t[n],e));return t}const jV=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],BV=5;var ke;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(ke||(ke={}));class zV{constructor(e){this.replacer=e}encode(e){return(e.type===ke.EVENT||e.type===ke.ACK)&&Cc(e)?this.encodeAsBinary({type:e.type===ke.EVENT?ke.BINARY_EVENT:ke.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===ke.BINARY_EVENT||e.type===ke.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=NV(e),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}function x1(t){return Object.prototype.toString.call(t)==="[object Object]"}class Iy extends _t{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===ke.BINARY_EVENT;r||n.type===ke.BINARY_ACK?(n.type=r?ke.EVENT:ke.ACK,this.reconstructor=new LV(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Py(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(ke[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===ke.BINARY_EVENT||r.type===ke.BINARY_ACK){const u=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const c=e.substring(u,n);if(c!=Number(c)||e.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(c)}if(e.charAt(n+1)==="/"){const u=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(u,n)}else r.nsp="/";const a=e.charAt(n+1);if(a!==""&&Number(a)==a){const u=n+1;for(;++n;){const c=e.charAt(n);if(c==null||Number(c)!=c){--n;break}if(n===e.length)break}r.id=Number(e.substring(u,n+1))}if(e.charAt(++n)){const u=this.tryParse(e.substr(n));if(Iy.isPayloadValid(r.type,u))r.data=u;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case ke.CONNECT:return x1(n);case ke.DISCONNECT:return n===void 0;case ke.CONNECT_ERROR:return typeof n=="string"||x1(n);case ke.EVENT:case ke.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&jV.indexOf(n[0])===-1);case ke.ACK:case ke.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class LV{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=$V(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const VV=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Iy,Encoder:zV,get PacketType(){return ke},protocol:BV},Symbol.toStringTag,{value:"Module"}));function Qn(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const UV=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class cO extends _t{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Qn(e,"open",this.onopen.bind(this)),Qn(e,"packet",this.onpacket.bind(this)),Qn(e,"error",this.onerror.bind(this)),Qn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var r,a,u;if(UV.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const c={type:ke.EVENT,data:n};if(c.options={},c.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const y=this.ids++,g=n.pop();this._registerAckCallback(y,g),c.id=y}const f=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,h=this.connected&&!(!((u=this.io.engine)===null||u===void 0)&&u._hasPingExpired());return this.flags.volatile&&!f||(h?(this.notifyOutgoingListeners(c),this.packet(c)):this.sendBuffer.push(c)),this.flags={},this}_registerAckCallback(e,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[e]=n;return}const u=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let f=0;f<this.sendBuffer.length;f++)this.sendBuffer[f].id===e&&this.sendBuffer.splice(f,1);n.call(this,new Error("operation has timed out"))},a),c=(...f)=>{this.io.clearTimeoutFn(u),n.apply(this,f)};c.withError=!0,this.acks[e]=c}emitWithAck(e,...n){return new Promise((r,a)=>{const u=(c,f)=>c?a(c):r(f);u.withError=!0,n.push(u),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((a,...u)=>r!==this._queue[0]?void 0:(a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...u)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:ke.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case ke.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ke.EVENT:case ke.BINARY_EVENT:this.onevent(e);break;case ke.ACK:case ke.BINARY_ACK:this.onack(e);break;case ke.DISCONNECT:this.ondisconnect();break;case ke.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:ke.ACK,id:e,data:a}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ke.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function Xo(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Xo.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};Xo.prototype.reset=function(){this.attempts=0};Xo.prototype.setMin=function(t){this.ms=t};Xo.prototype.setMax=function(t){this.max=t};Xo.prototype.setJitter=function(t){this.jitter=t};class Em extends _t{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Nf(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Xo({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const a=n.parser||VV;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new _V(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=Qn(n,"open",function(){r.onopen(),e&&e()}),u=f=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",f),e?e(f):this.maybeReconnectOnOpen()},c=Qn(n,"error",u);if(this._timeout!==!1){const f=this._timeout,h=this.setTimeoutFn(()=>{a(),u(new Error("timeout")),n.close()},f);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(a),this.subs.push(c),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Qn(e,"ping",this.onping.bind(this)),Qn(e,"data",this.ondata.bind(this)),Qn(e,"error",this.onerror.bind(this)),Qn(e,"close",this.onclose.bind(this)),Qn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){Df(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new cO(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(a=>{a?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",a)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Ya={};function kc(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=RV(t,e.path||"/socket.io"),r=n.source,a=n.id,u=n.path,c=Ya[a]&&u in Ya[a].nsps,f=e.forceNew||e["force new connection"]||e.multiplex===!1||c;let h;return f?h=new Em(r,e):(Ya[a]||(Ya[a]=new Em(r,e)),h=Ya[a]),n.query&&!e.query&&(e.query=n.queryKey),h.socket(n.path,e)}Object.assign(kc,{Manager:Em,Socket:cO,io:kc,connect:kc});const KV=["123","321","abc","admin","adobe","alexander","amanda","andrea","andrew","angel","apple","asdf","ashley","baby","banana","baseball","batman","bear","biteme","blazer","blonde","boston","buster","butterfly","cameron","charlie","cheese","chelsea","chicken","chocolate","chris","compaq","computer","cookie","corvette","cowboys","dakota","dallas","daniel","david","diamond","dolphin","donald","dragon","eagle","flower","football","frank","freedom","friend","gateway","george","ginger","god","golf","hannah","hardcore","harley","heather","hello","hottie","hunter","internet","jasmine","jennifer","jessica","jesus","johnny","jordan","joshua","justin","justme","killer","knight","lakers","letmein","liverpool","login","london","love","lucky","mackenzie","maggie","master","matrix","matthew","maverick","melissa","mercedes","michael","michelle","mickey","miller","money","monkey","morgan","mother","muffin","mustang","natasha","nathan","nicole","ninja","orange","pass","password","patrick","peanut","pepper","phoenix","photoshop","pokemon","princess","purple","qazwsx","qwerty","rainbow","ranger","root","samantha","samsung","scooter","secret","shadow","simpson","smile","soccer","sparkle","starwars","summer","sunflower","sunshine","superman","taylor","temp","test","thomas","tigers","tigger","tinkerbell","trust","turtle","victoria","welcome","whatever","william","winter","yellow","zaq12wsx","zxcvbn"],qV=3,PV=15,IV=/^[a-zA-Z0-9_-]+$/,HV=Ot(IV).pipe(Ot(`string > ${qV} & string < ${PV}`)).brand("username"),T1=20,A1={0:"o",1:"l",3:"e",4:"a",5:"s",7:"t","@":"a",$:"s","!":"i"};function FV(t){let e="";for(const n of t)n in A1?e+=A1[n]:e+=n;return e}function GV(t){const e=t.toLocaleLowerCase(),n=FV(e);for(const r of KV)if(n.includes(r)||e.includes(r))return!0;return!1}function YV(t){const e=new Set(t).size;return t.length*Math.log2(e)}function JV(t){let e=0;return GV(t)&&(e-=100),e+=YV(t)*.5,Math.max(e,0)}const XV=Ot("string").narrow((t,e)=>{const n=JV(t);return n>=T1?!0:e.mustBe(`Of complexity ${T1} or more. Was ${n.toFixed(2)}.`)}).brand("password");Ot({"+":"delete",email:"string",password:"string"});const ZV=Ot("string").brand("email");Ot({"+":"delete",username:"string",password:"string",email:"string"});const QV=Ot({email:"string",userId:"string",username:"string",password:"boolean",verification:"'unverified' | 'verified'"}),gi=kc(ZE.VITE_BACKEND_ORIGIN,{auth:t=>{const e=nt(ut);e&&t(e)},withCredentials:!0,autoConnect:!1});gi.on("connect",()=>{console.log("connected")}).on("connect_error",()=>{console.log("connect_error"),De(ut,null)}).on("usernameChanged",t=>{De(ut,e=>e===null?null:{...e,username:t})});const ut=ft({key:"auth",default:function(){const e=localStorage.getItem("auth");if(e)try{const n=qr(e),r=QV(n);return r instanceof Ot.errors?(console.error("failed to parse auth data",r),null):(r.verification==="verified"&&(console.log("connecting..."),gi.connect()),r)}catch(n){return console.error("failed to parse auth data",n),null}return null},effects:[function({onSet:e}){e(({newValue:n})=>{console.log("setting auth",n),n?(console.log("setting auth",n),De($o,n.username),localStorage.setItem("auth",zt(n)),n.verification==="verified"?(console.log("connecting..."),gi.connect()):Os("/verify")):(console.log("clearing session..."),localStorage.removeItem("auth"))})}]}),$o=ft({key:"username",default:nt(ut)?.username??""}),Ap=ft({key:"usernameDebounce",default:!0}),WV=ft({key:"usernameDebounced100ms",default:window.localStorage.getItem("username")??"",effects:[({setSelf:t})=>{Rk($o,()=>{nt(Ap)&&(t(nt($o)),De(Ap,!1),setTimeout(()=>{De(Ap,!0),t(nt($o))},2e3))})}]}),e4=Wi({key:"isUsernameTakenQuery",get:({get:t})=>{const e=t(WV);if(!e)return!1;const n=nt(ut);return e===n?.username?!1:cn.isUsernameTaken.query({username:e})}}),fO=Wi({key:"usernameIssues",get:({get:t})=>{const e=t($o),n=HV(e);return n instanceof Ot.errors?n:null}}),di=ft({key:"password0",default:""}),dO=Wi({key:"password0Issues",get:({get:t})=>{const e=t(di),n=XV(e);return n instanceof Ot.errors?n:null}}),Po=ft({key:"email",default:""}),hO=Wi({key:"emailIssues",get:({get:t})=>{const e=t(Po),n=ZV(e);return n instanceof Ot.errors?n:null}});Wi({key:"signupReady",get:({get:t})=>{const e=t(fO),n=t(dO),r=t(hO);return!(e??n??r)}});const Hi=ft({key:"oneTimeCode",default:""}),Om=ft({key:"oneTimeCodeNewEmail",default:""}),ui=ft({key:"authTarget",default:null}),pO=Sp({verify:Sp({$token:null}),game:Sp({clicker:null}),account:null,admin:null});function t4(t){return GL(pO,t)}const n4=[[]];function i4(t){return n4.some(e=>e.join("/")===t.join("/"))}function Os(t){history.pushState(null,"",t),De(mO,t)}const mO=ft({key:"pathName",default:window.location.pathname,effects:[({onSet:t,setSelf:e})=>{const n=a=>{history.replaceState(null,"",a),e(a)},r=a=>{switch(a){case"/":{const u=nt(ut);switch(console.log("/","auth",u),u?.verification){case"verified":n("/game");break;case"unverified":n("/verify");break}break}case"/verify":{nt(ut)?.verification==="verified"&&n("/game");break}case"/game":case"/game/clicker":{nt(ut)?.verification==="unverified"&&n("/verify");break}case"/admin":break;case"/account":{const u=nt(ut);if(!u){n("/");break}u.verification==="unverified"&&n("/verify");break}}};r(window.location.pathname),t(({newValue:a})=>{r(a)})},({setSelf:t})=>{document.addEventListener("click",e=>{const n=e.target.closest("a");if(n&&n instanceof HTMLAnchorElement){const r=n.getAttribute("href");r?.startsWith("/")&&(e.preventDefault(),history.pushState(null,"",r),t(r))}}),window.addEventListener("popstate",()=>{t(window.location.pathname)})}]}),r4=Wi({key:"route",get:({get:t})=>{const n=t(mO).split("/").slice(1).filter(Boolean);return t4(n)?i4(n)||t(ut)?n:401:404}}),E1=ft({key:"buttonBlockActive",default:!1}),zn=ft({key:"editing",default:[],effects:[({onSet:t})=>{t(({newValue:e})=>{switch(e[0]){case"email":{nt(yO)?.focus();break}case"new-password":{nt(gO)?.focus();break}case"username":{nt(bO)?.focus();break}}})}]}),yO=ft({key:"emailInputElement",default:null}),gO=ft({key:"password0InputElement",default:null}),bO=ft({key:"usernameInputElement",default:null});function s4(t){const e=$.useRef(null);return $.useEffect(()=>{De(t,e.current)},[t]),e}const o4=Wi({key:"otcLoginFieldLabel",get:({get:t})=>{const e=t(ut);return e?`Code sent to ${e.email}`:""}}),a4=Wi({key:"otcVerifyFieldLabel",get:({get:t})=>{const e=t(Po);return e?`Code sent to ${e}`:""}});function Ep({label:t,inputToken:e,issuesToken:n,inputElementToken:r,initialState:a,onSubmit:u,onOpen:c,onCancel:f,extraIssues:h}){const m=Et(e),y=Wn(e),g=Et(Hi),v=Wn(Hi),S=Et(Om),x=Wn(Om),T=Et(di),M=Wn(di),C=Et(E1),_=Wn(E1),R=Et(zn),G=Wn(zn),I=Et(n),ee=Et(o4),J=Et(a4),X=s4(r),he=R[0]===t,pe=R.at(-1),[we,...je]=R;return F.jsxs("form",{onSubmit:async ve=>{if(ve.preventDefault(),C){_(!1);return}console.log(`submitted! changing ${t} to`,m);const Z=await u(m);Error.isError(Z)&&console.error(Z)},children:[he?F.jsx("button",{type:"button",onClick:async()=>{await f?.(),G([])},children:"x"}):null,F.jsxs("main",{children:[F.jsxs("label",{htmlFor:t,children:[I||h?F.jsxs("aside",{children:[h,I?.map(ve=>F.jsx("span",{children:ve.message},ve.path.join(".")))]}):null,F.jsx("span",{children:t==="new-password"?"Password":hs(t)}),F.jsx("input",{id:t,type:t==="new-password"?"password":"text",ref:X,value:m,onChange:ve=>{y(ve.target.value)},autoComplete:t,autoCapitalize:"none",disabled:pe!==t})]}),he?je.map(ve=>F.jsxs("label",{htmlFor:`${t}-${ve}`,children:[F.jsx("span",{children:(()=>{switch(ve){case"otcLogin":return ee;case"otcVerify":return J;case"passwordLogin":return"Password"}})()}),F.jsx("input",{id:`${t}-otc`,type:"text",ref:X,value:(()=>{switch(ve){case"otcLogin":return g;case"otcVerify":return t==="email"?S:g;case"passwordLogin":return T}})(),onChange:Z=>{switch(ve){case"otcLogin":v(Z.target.value);break;case"otcVerify":if(t==="email"){x(Z.target.value);break}v(Z.target.value);break;case"passwordLogin":M(Z.target.value)}},autoComplete:t.includes("otc")?"one-time-code":t.includes("password")?"password":"",autoCapitalize:"none",disabled:ve!==pe})]},`${t}-${ve}`)):null]}),R[0]===t?F.jsx("button",{type:"submit",children:"->"}):F.jsx("button",{type:"button",onMouseDown:async()=>{_(!0),await c?.(),G(a)},onMouseUp:()=>{_(!1)},children:"/"})]})}function l4(){const t=Et(ut),e=Et(e4);return $.useEffect(()=>{t&&De(Po,t.email),t?.password&&De(di,"••••••••••••")},[]),t?F.jsxs("article",{"data-css":"editor",children:[F.jsx(Ep,{label:"username",inputToken:$o,issuesToken:fO,inputElementToken:bO,initialState:["username"],onSubmit:async n=>(await new Promise(r=>{gi.once("usernameChanged",r),gi.emit("changeUsername",n)}),De(zn,[]),n),extraIssues:e?F.jsx("span",{children:"This username is taken."}):null}),F.jsx(Ep,{label:"email",inputToken:Po,issuesToken:hO,inputElementToken:yO,initialState:["email"],onSubmit:async n=>{const r=nt(zn);if(r[0]!=="email")return new Error("field not email");switch(r.length){case 1:{const{userKey:a,nextStep:u}=await cn.offerNewEmail.mutate({emailOffered:n});switch(console.log({authTarget:a,nextStep:u}),u){case"otc_login":{De(ui,a),De(zn,["email","otcLogin"]);break}case"password_login":{De(ui,a),De(zn,["email","passwordLogin"]);break}case"otc_verify":{De(ui,a),De(Hi,"not needed"),De(zn,["email","otcLogin","otcVerify"]);break}}return a}case 2:switch(console.log("case 2"),r[1]){case"otcLogin":{console.log("case 2.1");const a=nt(ui);if(!a)return new Error("No auth target");const u=nt(Hi),c=await cn.verifyAccountAction.mutate({oneTimeCode:u,userKey:a});return De(ut,c),De(zn,["email","otcLogin","otcVerify"]),a}case"passwordLogin":return new Error("not implemented")}break;case 3:{const a=nt(ui);if(!a)return new Error("No auth target");const u=nt(Om),c=await cn.verifyAccountAction.mutate({oneTimeCode:u,userKey:a});return De(ut,c),De(zn,[]),c.email}}}}),F.jsx(Ep,{label:"new-password",inputToken:di,issuesToken:dO,inputElementToken:gO,initialState:t.password?["new-password","otcVerify"]:["new-password"],onSubmit:async n=>{const r=nt(zn);if(r[0]!=="new-password")return new Error("field not new-password");switch(r.length){case 1:return await cn.setPassword.mutate({password:n}),De(di,"••••••••••••"),De(ut,a=>a&&{...a,password:!0}),De(zn,[]),"done";case 2:{const a=nt(ui);return a?(await cn.verifyAccountAction.mutate({oneTimeCode:nt(Hi),userKey:a}),De(ut,u=>u&&{...u,password:!1}),De(di,""),De(zn,["new-password"]),"done"):new Error("No userKey")}}},onCancel:()=>{t.password&&De(di,"••••••••••••")},onOpen:async()=>{if(t.password){const n=nt(ui);if(!n)return new Error("No userKey");await cn.startPasswordReset.mutate({userKey:n})}}})]}):F.jsx("p",{children:"You must be logged in to verify your account."})}function u4(){return F.jsx("article",{children:F.jsx("h1",{children:"admin"})})}const Hy=ft({key:"count",default:0}),vO=Ck({key:"incrementTX",do:({set:t})=>{t(Hy,e=>e+1)}}),c4=SM({key:"countContinuity",config:t=>t.add(Hy).add(vO)});function f4({route:[,t]}){return F.jsx("article",{children:t?F.jsx(h4,{gameId:t}):F.jsx(d4,{})})}function d4(){return F.jsx("nav",{children:F.jsx(BE,{href:"/game/clicker",children:"Clicker"})})}Mk(pO[1].game[1]);function h4({gameId:t}){console.log(t);const e=Et(Hy),n=kk(vO);return DM(c4),F.jsxs("article",{children:[F.jsxs("button",{type:"button",onClick:()=>{n()},children:["count is ",e]}),F.jsx("p",{children:"Let's see how high we can count!"})]})}const SO=$.createContext({});function p4(t){const e=$.useRef(null);return e.current===null&&(e.current=t()),e.current}const Fy=typeof window<"u",m4=Fy?$.useLayoutEffect:$.useEffect,Gy=$.createContext(null);function Yy(t,e){t.indexOf(e)===-1&&t.push(e)}function Jy(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Zi=(t,e,n)=>n>e?e:n<t?t:n;let Xy=()=>{};const Qi={},wO=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function xO(t){return typeof t=="object"&&t!==null}const TO=t=>/^0[^.\s]+$/u.test(t);function Zy(t){let e;return()=>(e===void 0&&(e=t()),e)}const Pn=t=>t,y4=(t,e)=>n=>e(t(n)),zl=(...t)=>t.reduce(y4),vl=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class Qy{constructor(){this.subscriptions=[]}add(e){return Yy(this.subscriptions,e),()=>Jy(this.subscriptions,e)}notify(e,n,r){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](e,n,r);else for(let u=0;u<a;u++){const c=this.subscriptions[u];c&&c(e,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const pi=t=>t*1e3,qn=t=>t/1e3;function AO(t,e){return e?t*(1e3/e):0}const EO=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,g4=1e-7,b4=12;function v4(t,e,n,r,a){let u,c,f=0;do c=e+(n-e)/2,u=EO(c,r,a)-t,u>0?n=c:e=c;while(Math.abs(u)>g4&&++f<b4);return c}function Ll(t,e,n,r){if(t===e&&n===r)return Pn;const a=u=>v4(u,0,1,t,n);return u=>u===0||u===1?u:EO(a(u),e,r)}const OO=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,_O=t=>e=>1-t(1-e),RO=Ll(.33,1.53,.69,.99),Wy=_O(RO),CO=OO(Wy),kO=t=>(t*=2)<1?.5*Wy(t):.5*(2-Math.pow(2,-10*(t-1))),eg=t=>1-Math.sin(Math.acos(t)),MO=_O(eg),DO=OO(eg),S4=Ll(.42,0,1,1),w4=Ll(0,0,.58,1),NO=Ll(.42,0,.58,1),x4=t=>Array.isArray(t)&&typeof t[0]!="number",$O=t=>Array.isArray(t)&&typeof t[0]=="number",T4={linear:Pn,easeIn:S4,easeInOut:NO,easeOut:w4,circIn:eg,circInOut:DO,circOut:MO,backIn:Wy,backInOut:CO,backOut:RO,anticipate:kO},A4=t=>typeof t=="string",O1=t=>{if($O(t)){Xy(t.length===4);const[e,n,r,a]=t;return Ll(e,n,r,a)}else if(A4(t))return T4[t];return t},gc=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function E4(t,e){let n=new Set,r=new Set,a=!1,u=!1;const c=new WeakSet;let f={delta:0,timestamp:0,isProcessing:!1};function h(y){c.has(y)&&(m.schedule(y),t()),y(f)}const m={schedule:(y,g=!1,v=!1)=>{const x=v&&a?n:r;return g&&c.add(y),x.has(y)||x.add(y),y},cancel:y=>{r.delete(y),c.delete(y)},process:y=>{if(f=y,a){u=!0;return}a=!0,[n,r]=[r,n],n.forEach(h),n.clear(),a=!1,u&&(u=!1,m.process(y))}};return m}const O4=40;function jO(t,e){let n=!1,r=!0;const a={delta:0,timestamp:0,isProcessing:!1},u=()=>n=!0,c=gc.reduce((R,G)=>(R[G]=E4(u),R),{}),{setup:f,read:h,resolveKeyframes:m,preUpdate:y,update:g,preRender:v,render:S,postRender:x}=c,T=()=>{const R=Qi.useManualTiming?a.timestamp:performance.now();n=!1,Qi.useManualTiming||(a.delta=r?1e3/60:Math.max(Math.min(R-a.timestamp,O4),1)),a.timestamp=R,a.isProcessing=!0,f.process(a),h.process(a),m.process(a),y.process(a),g.process(a),v.process(a),S.process(a),x.process(a),a.isProcessing=!1,n&&e&&(r=!1,t(T))},M=()=>{n=!0,r=!0,a.isProcessing||t(T)};return{schedule:gc.reduce((R,G)=>{const I=c[G];return R[G]=(ee,J=!1,X=!1)=>(n||M(),I.schedule(ee,J,X)),R},{}),cancel:R=>{for(let G=0;G<gc.length;G++)c[gc[G]].cancel(R)},state:a,steps:c}}const{schedule:it,cancel:Vr,state:Ht,steps:Op}=jO(typeof requestAnimationFrame<"u"?requestAnimationFrame:Pn,!0);let Mc;function _4(){Mc=void 0}const fn={now:()=>(Mc===void 0&&fn.set(Ht.isProcessing||Qi.useManualTiming?Ht.timestamp:performance.now()),Mc),set:t=>{Mc=t,queueMicrotask(_4)}},BO=t=>e=>typeof e=="string"&&e.startsWith(t),tg=BO("--"),R4=BO("var(--"),ng=t=>R4(t)?C4.test(t.split("/*")[0].trim()):!1,C4=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Zo={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Sl={...Zo,transform:t=>Zi(0,1,t)},bc={...Zo,default:1},rl=t=>Math.round(t*1e5)/1e5,ig=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function k4(t){return t==null}const M4=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,rg=(t,e)=>n=>!!(typeof n=="string"&&M4.test(n)&&n.startsWith(t)||e&&!k4(n)&&Object.prototype.hasOwnProperty.call(n,e)),zO=(t,e,n)=>r=>{if(typeof r!="string")return r;const[a,u,c,f]=r.match(ig);return{[t]:parseFloat(a),[e]:parseFloat(u),[n]:parseFloat(c),alpha:f!==void 0?parseFloat(f):1}},D4=t=>Zi(0,255,t),_p={...Zo,transform:t=>Math.round(D4(t))},gs={test:rg("rgb","red"),parse:zO("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+_p.transform(t)+", "+_p.transform(e)+", "+_p.transform(n)+", "+rl(Sl.transform(r))+")"};function N4(t){let e="",n="",r="",a="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),a=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),a=t.substring(4,5),e+=e,n+=n,r+=r,a+=a),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:a?parseInt(a,16)/255:1}}const _m={test:rg("#"),parse:N4,transform:gs.transform},Vl=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),_r=Vl("deg"),mi=Vl("%"),de=Vl("px"),$4=Vl("vh"),j4=Vl("vw"),_1={...mi,parse:t=>mi.parse(t)/100,transform:t=>mi.transform(t*100)},To={test:rg("hsl","hue"),parse:zO("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+mi.transform(rl(e))+", "+mi.transform(rl(n))+", "+rl(Sl.transform(r))+")"},At={test:t=>gs.test(t)||_m.test(t)||To.test(t),parse:t=>gs.test(t)?gs.parse(t):To.test(t)?To.parse(t):_m.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?gs.transform(t):To.transform(t),getAnimatableNone:t=>{const e=At.parse(t);return e.alpha=0,At.transform(e)}},B4=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function z4(t){return isNaN(t)&&typeof t=="string"&&(t.match(ig)?.length||0)+(t.match(B4)?.length||0)>0}const LO="number",VO="color",L4="var",V4="var(",R1="${}",U4=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function wl(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},a=[];let u=0;const f=e.replace(U4,h=>(At.test(h)?(r.color.push(u),a.push(VO),n.push(At.parse(h))):h.startsWith(V4)?(r.var.push(u),a.push(L4),n.push(h)):(r.number.push(u),a.push(LO),n.push(parseFloat(h))),++u,R1)).split(R1);return{values:n,split:f,indexes:r,types:a}}function UO(t){return wl(t).values}function KO(t){const{split:e,types:n}=wl(t),r=e.length;return a=>{let u="";for(let c=0;c<r;c++)if(u+=e[c],a[c]!==void 0){const f=n[c];f===LO?u+=rl(a[c]):f===VO?u+=At.transform(a[c]):u+=a[c]}return u}}const K4=t=>typeof t=="number"?0:At.test(t)?At.getAnimatableNone(t):t;function q4(t){const e=UO(t);return KO(t)(e.map(K4))}const Ur={test:z4,parse:UO,createTransformer:KO,getAnimatableNone:q4};function Rp(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function P4({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let a=0,u=0,c=0;if(!e)a=u=c=n;else{const f=n<.5?n*(1+e):n+e-n*e,h=2*n-f;a=Rp(h,f,t+1/3),u=Rp(h,f,t),c=Rp(h,f,t-1/3)}return{red:Math.round(a*255),green:Math.round(u*255),blue:Math.round(c*255),alpha:r}}function tf(t,e){return n=>n>0?e:t}const rt=(t,e,n)=>t+(e-t)*n,Cp=(t,e,n)=>{const r=t*t,a=n*(e*e-r)+r;return a<0?0:Math.sqrt(a)},I4=[_m,gs,To],H4=t=>I4.find(e=>e.test(t));function C1(t){const e=H4(t);if(!e)return!1;let n=e.parse(t);return e===To&&(n=P4(n)),n}const k1=(t,e)=>{const n=C1(t),r=C1(e);if(!n||!r)return tf(t,e);const a={...n};return u=>(a.red=Cp(n.red,r.red,u),a.green=Cp(n.green,r.green,u),a.blue=Cp(n.blue,r.blue,u),a.alpha=rt(n.alpha,r.alpha,u),gs.transform(a))},Rm=new Set(["none","hidden"]);function F4(t,e){return Rm.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function G4(t,e){return n=>rt(t,e,n)}function sg(t){return typeof t=="number"?G4:typeof t=="string"?ng(t)?tf:At.test(t)?k1:X4:Array.isArray(t)?qO:typeof t=="object"?At.test(t)?k1:Y4:tf}function qO(t,e){const n=[...t],r=n.length,a=t.map((u,c)=>sg(u)(u,e[c]));return u=>{for(let c=0;c<r;c++)n[c]=a[c](u);return n}}function Y4(t,e){const n={...t,...e},r={};for(const a in n)t[a]!==void 0&&e[a]!==void 0&&(r[a]=sg(t[a])(t[a],e[a]));return a=>{for(const u in r)n[u]=r[u](a);return n}}function J4(t,e){const n=[],r={color:0,var:0,number:0};for(let a=0;a<e.values.length;a++){const u=e.types[a],c=t.indexes[u][r[u]],f=t.values[c]??0;n[a]=f,r[u]++}return n}const X4=(t,e)=>{const n=Ur.createTransformer(e),r=wl(t),a=wl(e);return r.indexes.var.length===a.indexes.var.length&&r.indexes.color.length===a.indexes.color.length&&r.indexes.number.length>=a.indexes.number.length?Rm.has(t)&&!a.values.length||Rm.has(e)&&!r.values.length?F4(t,e):zl(qO(J4(r,a),a.values),n):tf(t,e)};function PO(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?rt(t,e,n):sg(t)(t,e)}const Z4=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>it.update(e,n),stop:()=>Vr(e),now:()=>Ht.isProcessing?Ht.timestamp:fn.now()}},IO=(t,e,n=10)=>{let r="";const a=Math.max(Math.round(e/n),2);for(let u=0;u<a;u++)r+=Math.round(t(u/(a-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},nf=2e4;function og(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<nf;)e+=n,r=t.next(e);return e>=nf?1/0:e}function Q4(t,e=100,n){const r=n({...t,keyframes:[0,e]}),a=Math.min(og(r),nf);return{type:"keyframes",ease:u=>r.next(a*u).value/e,duration:qn(a)}}const W4=5;function HO(t,e,n){const r=Math.max(e-W4,0);return AO(n-t(r),e-r)}const lt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},kp=.001;function eU({duration:t=lt.duration,bounce:e=lt.bounce,velocity:n=lt.velocity,mass:r=lt.mass}){let a,u,c=1-e;c=Zi(lt.minDamping,lt.maxDamping,c),t=Zi(lt.minDuration,lt.maxDuration,qn(t)),c<1?(a=m=>{const y=m*c,g=y*t,v=y-n,S=Cm(m,c),x=Math.exp(-g);return kp-v/S*x},u=m=>{const g=m*c*t,v=g*n+n,S=Math.pow(c,2)*Math.pow(m,2)*t,x=Math.exp(-g),T=Cm(Math.pow(m,2),c);return(-a(m)+kp>0?-1:1)*((v-S)*x)/T}):(a=m=>{const y=Math.exp(-m*t),g=(m-n)*t+1;return-kp+y*g},u=m=>{const y=Math.exp(-m*t),g=(n-m)*(t*t);return y*g});const f=5/t,h=nU(a,u,f);if(t=pi(t),isNaN(h))return{stiffness:lt.stiffness,damping:lt.damping,duration:t};{const m=Math.pow(h,2)*r;return{stiffness:m,damping:c*2*Math.sqrt(r*m),duration:t}}}const tU=12;function nU(t,e,n){let r=n;for(let a=1;a<tU;a++)r=r-t(r)/e(r);return r}function Cm(t,e){return t*Math.sqrt(1-e*e)}const iU=["duration","bounce"],rU=["stiffness","damping","mass"];function M1(t,e){return e.some(n=>t[n]!==void 0)}function sU(t){let e={velocity:lt.velocity,stiffness:lt.stiffness,damping:lt.damping,mass:lt.mass,isResolvedFromDuration:!1,...t};if(!M1(t,rU)&&M1(t,iU))if(t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),a=r*r,u=2*Zi(.05,1,1-(t.bounce||0))*Math.sqrt(a);e={...e,mass:lt.mass,stiffness:a,damping:u}}else{const n=eU(t);e={...e,...n,mass:lt.mass},e.isResolvedFromDuration=!0}return e}function rf(t=lt.visualDuration,e=lt.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:a}=n;const u=n.keyframes[0],c=n.keyframes[n.keyframes.length-1],f={done:!1,value:u},{stiffness:h,damping:m,mass:y,duration:g,velocity:v,isResolvedFromDuration:S}=sU({...n,velocity:-qn(n.velocity||0)}),x=v||0,T=m/(2*Math.sqrt(h*y)),M=c-u,C=qn(Math.sqrt(h/y)),_=Math.abs(M)<5;r||(r=_?lt.restSpeed.granular:lt.restSpeed.default),a||(a=_?lt.restDelta.granular:lt.restDelta.default);let R;if(T<1){const I=Cm(C,T);R=ee=>{const J=Math.exp(-T*C*ee);return c-J*((x+T*C*M)/I*Math.sin(I*ee)+M*Math.cos(I*ee))}}else if(T===1)R=I=>c-Math.exp(-C*I)*(M+(x+C*M)*I);else{const I=C*Math.sqrt(T*T-1);R=ee=>{const J=Math.exp(-T*C*ee),X=Math.min(I*ee,300);return c-J*((x+T*C*M)*Math.sinh(X)+I*M*Math.cosh(X))/I}}const G={calculatedDuration:S&&g||null,next:I=>{const ee=R(I);if(S)f.done=I>=g;else{let J=I===0?x:0;T<1&&(J=I===0?pi(x):HO(R,I,ee));const X=Math.abs(J)<=r,he=Math.abs(c-ee)<=a;f.done=X&&he}return f.value=f.done?c:ee,f},toString:()=>{const I=Math.min(og(G),nf),ee=IO(J=>G.next(I*J).value,I,30);return I+"ms "+ee},toTransition:()=>{}};return G}rf.applyToOptions=t=>{const e=Q4(t,100,rf);return t.ease=e.ease,t.duration=pi(e.duration),t.type="keyframes",t};function km({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:a=10,bounceStiffness:u=500,modifyTarget:c,min:f,max:h,restDelta:m=.5,restSpeed:y}){const g=t[0],v={done:!1,value:g},S=X=>f!==void 0&&X<f||h!==void 0&&X>h,x=X=>f===void 0?h:h===void 0||Math.abs(f-X)<Math.abs(h-X)?f:h;let T=n*e;const M=g+T,C=c===void 0?M:c(M);C!==M&&(T=C-g);const _=X=>-T*Math.exp(-X/r),R=X=>C+_(X),G=X=>{const he=_(X),pe=R(X);v.done=Math.abs(he)<=m,v.value=v.done?C:pe};let I,ee;const J=X=>{S(v.value)&&(I=X,ee=rf({keyframes:[v.value,x(v.value)],velocity:HO(R,X,v.value),damping:a,stiffness:u,restDelta:m,restSpeed:y}))};return J(0),{calculatedDuration:null,next:X=>{let he=!1;return!ee&&I===void 0&&(he=!0,G(X),J(X)),I!==void 0&&X>=I?ee.next(X-I):(!he&&G(X),v)}}}function oU(t,e,n){const r=[],a=n||Qi.mix||PO,u=t.length-1;for(let c=0;c<u;c++){let f=a(t[c],t[c+1]);if(e){const h=Array.isArray(e)?e[c]||Pn:e;f=zl(h,f)}r.push(f)}return r}function aU(t,e,{clamp:n=!0,ease:r,mixer:a}={}){const u=t.length;if(Xy(u===e.length),u===1)return()=>e[0];if(u===2&&e[0]===e[1])return()=>e[1];const c=t[0]===t[1];t[0]>t[u-1]&&(t=[...t].reverse(),e=[...e].reverse());const f=oU(e,r,a),h=f.length,m=y=>{if(c&&y<t[0])return e[0];let g=0;if(h>1)for(;g<t.length-2&&!(y<t[g+1]);g++);const v=vl(t[g],t[g+1],y);return f[g](v)};return n?y=>m(Zi(t[0],t[u-1],y)):m}function lU(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const a=vl(0,e,r);t.push(rt(n,1,a))}}function uU(t){const e=[0];return lU(e,t.length-1),e}function cU(t,e){return t.map(n=>n*e)}function fU(t,e){return t.map(()=>e||NO).splice(0,t.length-1)}function sl({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const a=x4(r)?r.map(O1):O1(r),u={done:!1,value:e[0]},c=cU(n&&n.length===e.length?n:uU(e),t),f=aU(c,e,{ease:Array.isArray(a)?a:fU(e,a)});return{calculatedDuration:t,next:h=>(u.value=f(h),u.done=h>=t,u)}}const dU=t=>t!==null;function ag(t,{repeat:e,repeatType:n="loop"},r,a=1){const u=t.filter(dU),f=a<0||e&&n!=="loop"&&e%2===1?0:u.length-1;return!f||r===void 0?u[f]:r}const hU={decay:km,inertia:km,tween:sl,keyframes:sl,spring:rf};function FO(t){typeof t.type=="string"&&(t.type=hU[t.type])}class lg{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const pU=t=>t/100;class ug extends lg{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==fn.now()&&this.tick(fn.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;FO(e);const{type:n=sl,repeat:r=0,repeatDelay:a=0,repeatType:u,velocity:c=0}=e;let{keyframes:f}=e;const h=n||sl;h!==sl&&typeof f[0]!="number"&&(this.mixKeyframes=zl(pU,PO(f[0],f[1])),f=[0,100]);const m=h({...e,keyframes:f});u==="mirror"&&(this.mirroredGenerator=h({...e,keyframes:[...f].reverse(),velocity:-c})),m.calculatedDuration===null&&(m.calculatedDuration=og(m));const{calculatedDuration:y}=m;this.calculatedDuration=y,this.resolvedDuration=y+a,this.totalDuration=this.resolvedDuration*(r+1)-a,this.generator=m}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:r,totalDuration:a,mixKeyframes:u,mirroredGenerator:c,resolvedDuration:f,calculatedDuration:h}=this;if(this.startTime===null)return r.next(0);const{delay:m=0,keyframes:y,repeat:g,repeatType:v,repeatDelay:S,type:x,onUpdate:T,finalKeyframe:M}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-a/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const C=this.currentTime-m*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?C<0:C>a;this.currentTime=Math.max(C,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let R=this.currentTime,G=r;if(g){const X=Math.min(this.currentTime,a)/f;let he=Math.floor(X),pe=X%1;!pe&&X>=1&&(pe=1),pe===1&&he--,he=Math.min(he,g+1),!!(he%2)&&(v==="reverse"?(pe=1-pe,S&&(pe-=S/f)):v==="mirror"&&(G=c)),R=Zi(0,1,pe)*f}const I=_?{done:!1,value:y[0]}:G.next(R);u&&(I.value=u(I.value));let{done:ee}=I;!_&&h!==null&&(ee=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const J=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&ee);return J&&x!==km&&(I.value=ag(y,this.options,M,this.speed)),T&&T(I.value),J&&this.finish(),I}then(e,n){return this.finished.then(e,n)}get duration(){return qn(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+qn(e)}get time(){return qn(this.currentTime)}set time(e){e=pi(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(fn.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=qn(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Z4,startTime:n}=this.options;this.driver||(this.driver=e(a=>this.tick(a))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(fn.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function mU(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const bs=t=>t*180/Math.PI,Mm=t=>{const e=bs(Math.atan2(t[1],t[0]));return Dm(e)},yU={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Mm,rotateZ:Mm,skewX:t=>bs(Math.atan(t[1])),skewY:t=>bs(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Dm=t=>(t=t%360,t<0&&(t+=360),t),D1=Mm,N1=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),$1=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),gU={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:N1,scaleY:$1,scale:t=>(N1(t)+$1(t))/2,rotateX:t=>Dm(bs(Math.atan2(t[6],t[5]))),rotateY:t=>Dm(bs(Math.atan2(-t[2],t[0]))),rotateZ:D1,rotate:D1,skewX:t=>bs(Math.atan(t[4])),skewY:t=>bs(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Nm(t){return t.includes("scale")?1:0}function $m(t,e){if(!t||t==="none")return Nm(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,a;if(n)r=gU,a=n;else{const f=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=yU,a=f}if(!a)return Nm(e);const u=r[e],c=a[1].split(",").map(vU);return typeof u=="function"?u(c):c[u]}const bU=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return $m(n,e)};function vU(t){return parseFloat(t.trim())}const Qo=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Wo=new Set(Qo),j1=t=>t===Zo||t===de,SU=new Set(["x","y","z"]),wU=Qo.filter(t=>!SU.has(t));function xU(t){const e=[];return wU.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const ws={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>$m(e,"x"),y:(t,{transform:e})=>$m(e,"y")};ws.translateX=ws.x;ws.translateY=ws.y;const xs=new Set;let jm=!1,Bm=!1,zm=!1;function GO(){if(Bm){const t=Array.from(xs).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const a=xU(r);a.length&&(n.set(r,a),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const a=n.get(r);a&&a.forEach(([u,c])=>{r.getValue(u)?.set(c)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}Bm=!1,jm=!1,xs.forEach(t=>t.complete(zm)),xs.clear()}function YO(){xs.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Bm=!0)})}function TU(){zm=!0,YO(),GO(),zm=!1}class cg{constructor(e,n,r,a,u,c=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=r,this.motionValue=a,this.element=u,this.isAsync=c}scheduleResolve(){this.state="scheduled",this.isAsync?(xs.add(this),jm||(jm=!0,it.read(YO),it.resolveKeyframes(GO))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:r,motionValue:a}=this;if(e[0]===null){const u=a?.get(),c=e[e.length-1];if(u!==void 0)e[0]=u;else if(r&&n){const f=r.readValue(n,c);f!=null&&(e[0]=f)}e[0]===void 0&&(e[0]=c),a&&u===void 0&&a.set(e[0])}mU(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),xs.delete(this)}cancel(){this.state==="scheduled"&&(xs.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const AU=t=>t.startsWith("--");function EU(t,e,n){AU(e)?t.style.setProperty(e,n):t.style[e]=n}const OU=Zy(()=>window.ScrollTimeline!==void 0),_U={};function RU(t,e){const n=Zy(t);return()=>_U[e]??n()}const JO=RU(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),el=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,B1={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:el([0,.65,.55,1]),circOut:el([.55,0,1,.45]),backIn:el([.31,.01,.66,-.59]),backOut:el([.33,1.53,.69,.99])};function XO(t,e){if(t)return typeof t=="function"?JO()?IO(t,e):"ease-out":$O(t)?el(t):Array.isArray(t)?t.map(n=>XO(n,e)||B1.easeOut):B1[t]}function CU(t,e,n,{delay:r=0,duration:a=300,repeat:u=0,repeatType:c="loop",ease:f="easeOut",times:h}={},m=void 0){const y={[e]:n};h&&(y.offset=h);const g=XO(f,a);Array.isArray(g)&&(y.easing=g);const v={delay:r,duration:a,easing:Array.isArray(g)?"linear":g,fill:"both",iterations:u+1,direction:c==="reverse"?"alternate":"normal"};return m&&(v.pseudoElement=m),t.animate(y,v)}function ZO(t){return typeof t=="function"&&"applyToOptions"in t}function kU({type:t,...e}){return ZO(t)&&JO()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class MU extends lg{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:r,keyframes:a,pseudoElement:u,allowFlatten:c=!1,finalKeyframe:f,onComplete:h}=e;this.isPseudoElement=!!u,this.allowFlatten=c,this.options=e,Xy(typeof e.type!="string");const m=kU(e);this.animation=CU(n,r,a,m,u),m.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!u){const y=ag(a,this.options,f,this.speed);this.updateMotionValue?this.updateMotionValue(y):EU(n,r,y),this.animation.cancel()}h?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return qn(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+qn(e)}get time(){return qn(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=pi(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&OU()?(this.animation.timeline=e,Pn):n(this)}}const QO={anticipate:kO,backInOut:CO,circInOut:DO};function DU(t){return t in QO}function NU(t){typeof t.ease=="string"&&DU(t.ease)&&(t.ease=QO[t.ease])}const z1=10;class $U extends MU{constructor(e){NU(e),FO(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:r,onComplete:a,element:u,...c}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const f=new ug({...c,autoplay:!1}),h=pi(this.finishedTime??this.time);n.setWithVelocity(f.sample(h-z1).value,f.sample(h).value,z1),f.stop()}}const L1=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Ur.test(t)||t==="0")&&!t.startsWith("url("));function jU(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function BU(t,e,n,r){const a=t[0];if(a===null)return!1;if(e==="display"||e==="visibility")return!0;const u=t[t.length-1],c=L1(a,e),f=L1(u,e);return!c||!f?!1:jU(t)||(n==="spring"||ZO(n))&&r}function Lm(t){t.duration=0,t.type="keyframes"}const zU=new Set(["opacity","clipPath","filter","transform"]),LU=Zy(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function VU(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:a,damping:u,type:c}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:h,transformTemplate:m}=e.owner.getProps();return LU()&&n&&zU.has(n)&&(n!=="transform"||!m)&&!h&&!r&&a!=="mirror"&&u!==0&&c!=="inertia"}const UU=40;class KU extends lg{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:a=0,repeatDelay:u=0,repeatType:c="loop",keyframes:f,name:h,motionValue:m,element:y,...g}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=fn.now();const v={autoplay:e,delay:n,type:r,repeat:a,repeatDelay:u,repeatType:c,name:h,motionValue:m,element:y,...g},S=y?.KeyframeResolver||cg;this.keyframeResolver=new S(f,(x,T,M)=>this.onKeyframesResolved(x,T,v,!M),h,m,y),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,r,a){this.keyframeResolver=void 0;const{name:u,type:c,velocity:f,delay:h,isHandoff:m,onUpdate:y}=r;this.resolvedAt=fn.now(),BU(e,u,c,f)||((Qi.instantAnimations||!h)&&y?.(ag(e,r,n)),e[0]=e[e.length-1],Lm(r),r.repeat=0);const v={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>UU?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},S=!m&&VU(v)?new $U({...v,element:v.motionValue.owner.current}):new ug(v);S.finished.then(()=>this.notifyFinished()).catch(Pn),this.pendingTimeline&&(this.stopTimeline=S.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=S}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),TU()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const qU=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function PU(t){const e=qU.exec(t);if(!e)return[,];const[,n,r,a]=e;return[`--${n??r}`,a]}function WO(t,e,n=1){const[r,a]=PU(t);if(!r)return;const u=window.getComputedStyle(e).getPropertyValue(r);if(u){const c=u.trim();return wO(c)?parseFloat(c):c}return ng(a)?WO(a,e,n+1):a}function fg(t,e){return t?.[e]??t?.default??t}const e_=new Set(["width","height","top","left","right","bottom",...Qo]),IU={test:t=>t==="auto",parse:t=>t},t_=t=>e=>e.test(t),n_=[Zo,de,mi,_r,j4,$4,IU],V1=t=>n_.find(t_(t));function HU(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||TO(t):!0}const FU=new Set(["brightness","contrast","saturate","opacity"]);function GU(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(ig)||[];if(!r)return t;const a=n.replace(r,"");let u=FU.has(e)?1:0;return r!==n&&(u*=100),e+"("+u+a+")"}const YU=/\b([a-z-]*)\(.*?\)/gu,Vm={...Ur,getAnimatableNone:t=>{const e=t.match(YU);return e?e.map(GU).join(" "):t}},U1={...Zo,transform:Math.round},JU={rotate:_r,rotateX:_r,rotateY:_r,rotateZ:_r,scale:bc,scaleX:bc,scaleY:bc,scaleZ:bc,skew:_r,skewX:_r,skewY:_r,distance:de,translateX:de,translateY:de,translateZ:de,x:de,y:de,z:de,perspective:de,transformPerspective:de,opacity:Sl,originX:_1,originY:_1,originZ:de},dg={borderWidth:de,borderTopWidth:de,borderRightWidth:de,borderBottomWidth:de,borderLeftWidth:de,borderRadius:de,radius:de,borderTopLeftRadius:de,borderTopRightRadius:de,borderBottomRightRadius:de,borderBottomLeftRadius:de,width:de,maxWidth:de,height:de,maxHeight:de,top:de,right:de,bottom:de,left:de,padding:de,paddingTop:de,paddingRight:de,paddingBottom:de,paddingLeft:de,margin:de,marginTop:de,marginRight:de,marginBottom:de,marginLeft:de,backgroundPositionX:de,backgroundPositionY:de,...JU,zIndex:U1,fillOpacity:Sl,strokeOpacity:Sl,numOctaves:U1},XU={...dg,color:At,backgroundColor:At,outlineColor:At,fill:At,stroke:At,borderColor:At,borderTopColor:At,borderRightColor:At,borderBottomColor:At,borderLeftColor:At,filter:Vm,WebkitFilter:Vm},i_=t=>XU[t];function r_(t,e){let n=i_(t);return n!==Vm&&(n=Ur),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const ZU=new Set(["auto","none","0"]);function QU(t,e,n){let r=0,a;for(;r<t.length&&!a;){const u=t[r];typeof u=="string"&&!ZU.has(u)&&wl(u).values.length&&(a=t[r]),r++}if(a&&n)for(const u of e)t[u]=r_(n,a)}class WU extends cg{constructor(e,n,r,a,u){super(e,n,r,a,u,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let h=0;h<e.length;h++){let m=e[h];if(typeof m=="string"&&(m=m.trim(),ng(m))){const y=WO(m,n.current);y!==void 0&&(e[h]=y),h===e.length-1&&(this.finalKeyframe=m)}}if(this.resolveNoneKeyframes(),!e_.has(r)||e.length!==2)return;const[a,u]=e,c=V1(a),f=V1(u);if(c!==f)if(j1(c)&&j1(f))for(let h=0;h<e.length;h++){const m=e[h];typeof m=="string"&&(e[h]=parseFloat(m))}else ws[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let a=0;a<e.length;a++)(e[a]===null||HU(e[a]))&&r.push(a);r.length&&QU(e,r,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ws[r](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const a=n[n.length-1];a!==void 0&&e.getValue(r,a).jump(a,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const a=e.getValue(n);a&&a.jump(this.measuredOrigin,!1);const u=r.length-1,c=r[u];r[u]=ws[n](e.measureViewportBox(),window.getComputedStyle(e.current)),c!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=c),this.removedTransforms?.length&&this.removedTransforms.forEach(([f,h])=>{e.getValue(f).set(h)}),this.resolveNoneKeyframes()}}function eK(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;const a=n?.[t]??r.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t)}const s_=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function tK(t){return xO(t)&&"offsetHeight"in t}const K1=30,nK=t=>!isNaN(parseFloat(t));class iK{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const a=fn.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const u of this.dependents)u.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=fn.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=nK(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Qy);const r=this.events[e].add(n);return e==="change"?()=>{r(),it.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=fn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>K1)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,K1);return AO(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Io(t,e){return new iK(t,e)}const{schedule:hg}=jO(queueMicrotask,!1),Zn={x:!1,y:!1};function o_(){return Zn.x||Zn.y}function rK(t){return t==="x"||t==="y"?Zn[t]?null:(Zn[t]=!0,()=>{Zn[t]=!1}):Zn.x||Zn.y?null:(Zn.x=Zn.y=!0,()=>{Zn.x=Zn.y=!1})}function a_(t,e){const n=eK(t),r=new AbortController,a={passive:!0,...e,signal:r.signal};return[n,a,()=>r.abort()]}function q1(t){return!(t.pointerType==="touch"||o_())}function sK(t,e,n={}){const[r,a,u]=a_(t,n),c=f=>{if(!q1(f))return;const{target:h}=f,m=e(h,f);if(typeof m!="function"||!h)return;const y=g=>{q1(g)&&(m(g),h.removeEventListener("pointerleave",y))};h.addEventListener("pointerleave",y,a)};return r.forEach(f=>{f.addEventListener("pointerenter",c,a)}),u}const l_=(t,e)=>e?t===e?!0:l_(t,e.parentElement):!1,pg=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,oK=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function aK(t){return oK.has(t.tagName)||t.tabIndex!==-1}const Dc=new WeakSet;function P1(t){return e=>{e.key==="Enter"&&t(e)}}function Mp(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const lK=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=P1(()=>{if(Dc.has(n))return;Mp(n,"down");const a=P1(()=>{Mp(n,"up")}),u=()=>Mp(n,"cancel");n.addEventListener("keyup",a,e),n.addEventListener("blur",u,e)});n.addEventListener("keydown",r,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),e)};function I1(t){return pg(t)&&!o_()}function uK(t,e,n={}){const[r,a,u]=a_(t,n),c=f=>{const h=f.currentTarget;if(!I1(f))return;Dc.add(h);const m=e(h,f),y=(S,x)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",v),Dc.has(h)&&Dc.delete(h),I1(S)&&typeof m=="function"&&m(S,{success:x})},g=S=>{y(S,h===window||h===document||n.useGlobalTarget||l_(h,S.target))},v=S=>{y(S,!1)};window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",v,a)};return r.forEach(f=>{(n.useGlobalTarget?window:f).addEventListener("pointerdown",c,a),tK(f)&&(f.addEventListener("focus",m=>lK(m,a)),!aK(f)&&!f.hasAttribute("tabindex")&&(f.tabIndex=0))}),u}function u_(t){return xO(t)&&"ownerSVGElement"in t}function cK(t){return u_(t)&&t.tagName==="svg"}const Yt=t=>!!(t&&t.getVelocity),fK=[...n_,At,Ur],dK=t=>fK.find(t_(t)),c_=$.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function hK(t=!0){const e=$.useContext(Gy);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:a}=e,u=$.useId();$.useEffect(()=>{if(t)return a(u)},[t]);const c=$.useCallback(()=>t&&r&&r(u),[u,r,t]);return!n&&r?[!1,c]:[!0]}const f_=$.createContext({strict:!1}),H1={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Ho={};for(const t in H1)Ho[t]={isEnabled:e=>H1[t].some(n=>!!e[n])};function pK(t){for(const e in t)Ho[e]={...Ho[e],...t[e]}}const mK=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function sf(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||mK.has(t)}let d_=t=>!sf(t);function yK(t){typeof t=="function"&&(d_=e=>e.startsWith("on")?!sf(e):t(e))}try{yK(require("@emotion/is-prop-valid").default)}catch{}function gK(t,e,n){const r={};for(const a in t)a==="values"&&typeof t.values=="object"||(d_(a)||n===!0&&sf(a)||!e&&!sf(a)||t.draggable&&a.startsWith("onDrag"))&&(r[a]=t[a]);return r}const $f=$.createContext({});function jf(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function xl(t){return typeof t=="string"||Array.isArray(t)}const mg=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],yg=["initial",...mg];function Bf(t){return jf(t.animate)||yg.some(e=>xl(t[e]))}function h_(t){return!!(Bf(t)||t.variants)}function bK(t,e){if(Bf(t)){const{initial:n,animate:r}=t;return{initial:n===!1||xl(n)?n:void 0,animate:xl(r)?r:void 0}}return t.inherit!==!1?e:{}}function vK(t){const{initial:e,animate:n}=bK(t,$.useContext($f));return $.useMemo(()=>({initial:e,animate:n}),[F1(e),F1(n)])}function F1(t){return Array.isArray(t)?t.join(" "):t}const Tl={};function SK(t){for(const e in t)Tl[e]=t[e],tg(e)&&(Tl[e].isCSSVariable=!0)}function p_(t,{layout:e,layoutId:n}){return Wo.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Tl[t]||t==="opacity")}const wK={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},xK=Qo.length;function TK(t,e,n){let r="",a=!0;for(let u=0;u<xK;u++){const c=Qo[u],f=t[c];if(f===void 0)continue;let h=!0;if(typeof f=="number"?h=f===(c.startsWith("scale")?1:0):h=parseFloat(f)===0,!h||n){const m=s_(f,dg[c]);if(!h){a=!1;const y=wK[c]||c;r+=`${y}(${m}) `}n&&(e[c]=m)}}return r=r.trim(),n?r=n(e,a?"":r):a&&(r="none"),r}function gg(t,e,n){const{style:r,vars:a,transformOrigin:u}=t;let c=!1,f=!1;for(const h in e){const m=e[h];if(Wo.has(h)){c=!0;continue}else if(tg(h)){a[h]=m;continue}else{const y=s_(m,dg[h]);h.startsWith("origin")?(f=!0,u[h]=y):r[h]=y}}if(e.transform||(c||n?r.transform=TK(e,t.transform,n):r.transform&&(r.transform="none")),f){const{originX:h="50%",originY:m="50%",originZ:y=0}=u;r.transformOrigin=`${h} ${m} ${y}`}}const bg=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function m_(t,e,n){for(const r in e)!Yt(e[r])&&!p_(r,n)&&(t[r]=e[r])}function AK({transformTemplate:t},e){return $.useMemo(()=>{const n=bg();return gg(n,e,t),Object.assign({},n.vars,n.style)},[e])}function EK(t,e){const n=t.style||{},r={};return m_(r,n,t),Object.assign(r,AK(t,e)),r}function OK(t,e){const n={},r=EK(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=r,n}const _K={offset:"stroke-dashoffset",array:"stroke-dasharray"},RK={offset:"strokeDashoffset",array:"strokeDasharray"};function CK(t,e,n=1,r=0,a=!0){t.pathLength=1;const u=a?_K:RK;t[u.offset]=de.transform(-r);const c=de.transform(e),f=de.transform(n);t[u.array]=`${c} ${f}`}function y_(t,{attrX:e,attrY:n,attrScale:r,pathLength:a,pathSpacing:u=1,pathOffset:c=0,...f},h,m,y){if(gg(t,f,m),h){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:g,style:v}=t;g.transform&&(v.transform=g.transform,delete g.transform),(v.transform||g.transformOrigin)&&(v.transformOrigin=g.transformOrigin??"50% 50%",delete g.transformOrigin),v.transform&&(v.transformBox=y?.transformBox??"fill-box",delete g.transformBox),e!==void 0&&(g.x=e),n!==void 0&&(g.y=n),r!==void 0&&(g.scale=r),a!==void 0&&CK(g,a,u,c,!1)}const g_=()=>({...bg(),attrs:{}}),b_=t=>typeof t=="string"&&t.toLowerCase()==="svg";function kK(t,e,n,r){const a=$.useMemo(()=>{const u=g_();return y_(u,e,b_(r),t.transformTemplate,t.style),{...u.attrs,style:{...u.style}}},[e]);if(t.style){const u={};m_(u,t.style,t),a.style={...u,...a.style}}return a}const MK=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function vg(t){return typeof t!="string"||t.includes("-")?!1:!!(MK.indexOf(t)>-1||/[A-Z]/u.test(t))}function DK(t,e,n,{latestValues:r},a,u=!1){const f=(vg(t)?kK:OK)(e,r,a,t),h=gK(e,typeof t=="string",u),m=t!==$.Fragment?{...h,...f,ref:n}:{},{children:y}=e,g=$.useMemo(()=>Yt(y)?y.get():y,[y]);return $.createElement(t,{...m,children:g})}function G1(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function Sg(t,e,n,r){if(typeof e=="function"){const[a,u]=G1(r);e=e(n!==void 0?n:t.custom,a,u)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[a,u]=G1(r);e=e(n!==void 0?n:t.custom,a,u)}return e}function Nc(t){return Yt(t)?t.get():t}function NK({scrapeMotionValuesFromProps:t,createRenderState:e},n,r,a){return{latestValues:$K(n,r,a,t),renderState:e()}}function $K(t,e,n,r){const a={},u=r(t,{});for(const v in u)a[v]=Nc(u[v]);let{initial:c,animate:f}=t;const h=Bf(t),m=h_(t);e&&m&&!h&&t.inherit!==!1&&(c===void 0&&(c=e.initial),f===void 0&&(f=e.animate));let y=n?n.initial===!1:!1;y=y||c===!1;const g=y?f:c;if(g&&typeof g!="boolean"&&!jf(g)){const v=Array.isArray(g)?g:[g];for(let S=0;S<v.length;S++){const x=Sg(t,v[S]);if(x){const{transitionEnd:T,transition:M,...C}=x;for(const _ in C){let R=C[_];if(Array.isArray(R)){const G=y?R.length-1:0;R=R[G]}R!==null&&(a[_]=R)}for(const _ in T)a[_]=T[_]}}}return a}const v_=t=>(e,n)=>{const r=$.useContext($f),a=$.useContext(Gy),u=()=>NK(t,e,r,a);return n?u():p4(u)};function wg(t,e,n){const{style:r}=t,a={};for(const u in r)(Yt(r[u])||e.style&&Yt(e.style[u])||p_(u,t)||n?.getValue(u)?.liveStyle!==void 0)&&(a[u]=r[u]);return a}const jK=v_({scrapeMotionValuesFromProps:wg,createRenderState:bg});function S_(t,e,n){const r=wg(t,e,n);for(const a in t)if(Yt(t[a])||Yt(e[a])){const u=Qo.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;r[u]=t[a]}return r}const BK=v_({scrapeMotionValuesFromProps:S_,createRenderState:g_}),zK=Symbol.for("motionComponentSymbol");function Ao(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function LK(t,e,n){return $.useCallback(r=>{r&&t.onMount&&t.onMount(r),e&&(r?e.mount(r):e.unmount()),n&&(typeof n=="function"?n(r):Ao(n)&&(n.current=r))},[e])}const xg=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),VK="framerAppearId",w_="data-"+xg(VK),x_=$.createContext({});function UK(t,e,n,r,a){const{visualElement:u}=$.useContext($f),c=$.useContext(f_),f=$.useContext(Gy),h=$.useContext(c_).reducedMotion,m=$.useRef(null);r=r||c.renderer,!m.current&&r&&(m.current=r(t,{visualState:e,parent:u,props:n,presenceContext:f,blockInitialAnimation:f?f.initial===!1:!1,reducedMotionConfig:h}));const y=m.current,g=$.useContext(x_);y&&!y.projection&&a&&(y.type==="html"||y.type==="svg")&&KK(m.current,n,a,g);const v=$.useRef(!1);$.useInsertionEffect(()=>{y&&v.current&&y.update(n,f)});const S=n[w_],x=$.useRef(!!S&&!window.MotionHandoffIsComplete?.(S)&&window.MotionHasOptimisedAnimation?.(S));return m4(()=>{y&&(v.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),y.scheduleRenderMicrotask(),x.current&&y.animationState&&y.animationState.animateChanges())}),$.useEffect(()=>{y&&(!x.current&&y.animationState&&y.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(S)}),x.current=!1),y.enteringChildren=void 0)}),y}function KK(t,e,n,r){const{layoutId:a,layout:u,drag:c,dragConstraints:f,layoutScroll:h,layoutRoot:m,layoutCrossfade:y}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:T_(t.parent)),t.projection.setOptions({layoutId:a,layout:u,alwaysMeasureLayout:!!c||f&&Ao(f),visualElement:t,animationType:typeof u=="string"?u:"both",initialPromotionConfig:r,crossfade:y,layoutScroll:h,layoutRoot:m})}function T_(t){if(t)return t.options.allowProjection!==!1?t.projection:T_(t.parent)}function Dp(t,{forwardMotionProps:e=!1}={},n,r){n&&pK(n);const a=vg(t)?BK:jK;function u(f,h){let m;const y={...$.useContext(c_),...f,layoutId:qK(f)},{isStatic:g}=y,v=vK(f),S=a(f,g);if(!g&&Fy){PK();const x=IK(y);m=x.MeasureLayout,v.visualElement=UK(t,S,y,r,x.ProjectionNode)}return F.jsxs($f.Provider,{value:v,children:[m&&v.visualElement?F.jsx(m,{visualElement:v.visualElement,...y}):null,DK(t,f,LK(S,v.visualElement,h),S,g,e)]})}u.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=$.forwardRef(u);return c[zK]=t,c}function qK({layoutId:t}){const e=$.useContext(SO).id;return e&&t!==void 0?e+"-"+t:t}function PK(t,e){$.useContext(f_).strict}function IK(t){const{drag:e,layout:n}=Ho;if(!e&&!n)return{};const r={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function HK(t,e){if(typeof Proxy>"u")return Dp;const n=new Map,r=(u,c)=>Dp(u,c,t,e),a=(u,c)=>r(u,c);return new Proxy(a,{get:(u,c)=>c==="create"?r:(n.has(c)||n.set(c,Dp(c,void 0,t,e)),n.get(c))})}function A_({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function FK({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function GK(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Np(t){return t===void 0||t===1}function Um({scale:t,scaleX:e,scaleY:n}){return!Np(t)||!Np(e)||!Np(n)}function ms(t){return Um(t)||E_(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function E_(t){return Y1(t.x)||Y1(t.y)}function Y1(t){return t&&t!=="0%"}function of(t,e,n){const r=t-n,a=e*r;return n+a}function J1(t,e,n,r,a){return a!==void 0&&(t=of(t,a,r)),of(t,n,r)+e}function Km(t,e=0,n=1,r,a){t.min=J1(t.min,e,n,r,a),t.max=J1(t.max,e,n,r,a)}function O_(t,{x:e,y:n}){Km(t.x,e.translate,e.scale,e.originPoint),Km(t.y,n.translate,n.scale,n.originPoint)}const X1=.999999999999,Z1=1.0000000000001;function YK(t,e,n,r=!1){const a=n.length;if(!a)return;e.x=e.y=1;let u,c;for(let f=0;f<a;f++){u=n[f],c=u.projectionDelta;const{visualElement:h}=u.options;h&&h.props.style&&h.props.style.display==="contents"||(r&&u.options.layoutScroll&&u.scroll&&u!==u.root&&Oo(t,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),c&&(e.x*=c.x.scale,e.y*=c.y.scale,O_(t,c)),r&&ms(u.latestValues)&&Oo(t,u.latestValues))}e.x<Z1&&e.x>X1&&(e.x=1),e.y<Z1&&e.y>X1&&(e.y=1)}function Eo(t,e){t.min=t.min+e,t.max=t.max+e}function Q1(t,e,n,r,a=.5){const u=rt(t.min,t.max,a);Km(t,e,n,u,r)}function Oo(t,e){Q1(t.x,e.x,e.scaleX,e.scale,e.originX),Q1(t.y,e.y,e.scaleY,e.scale,e.originY)}function __(t,e){return A_(GK(t.getBoundingClientRect(),e))}function JK(t,e,n){const r=__(t,n),{scroll:a}=e;return a&&(Eo(r.x,a.offset.x),Eo(r.y,a.offset.y)),r}const W1=()=>({translate:0,scale:1,origin:0,originPoint:0}),_o=()=>({x:W1(),y:W1()}),ex=()=>({min:0,max:0}),yt=()=>({x:ex(),y:ex()}),qm={current:null},R_={current:!1};function XK(){if(R_.current=!0,!!Fy)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>qm.current=t.matches;t.addEventListener("change",e),e()}else qm.current=!1}const ZK=new WeakMap;function QK(t,e,n){for(const r in e){const a=e[r],u=n[r];if(Yt(a))t.addValue(r,a);else if(Yt(u))t.addValue(r,Io(a,{owner:t}));else if(u!==a)if(t.hasValue(r)){const c=t.getValue(r);c.liveStyle===!0?c.jump(a):c.hasAnimated||c.set(a)}else{const c=t.getStaticValue(r);t.addValue(r,Io(c!==void 0?c:a,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const tx=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class WK{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:a,blockInitialAnimation:u,visualState:c},f={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=cg,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const v=fn.now();this.renderScheduledAt<v&&(this.renderScheduledAt=v,it.render(this.render,!1,!0))};const{latestValues:h,renderState:m}=c;this.latestValues=h,this.baseTarget={...h},this.initialValues=n.initial?{...h}:{},this.renderState=m,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=a,this.options=f,this.blockInitialAnimation=!!u,this.isControllingVariants=Bf(n),this.isVariantNode=h_(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:y,...g}=this.scrapeMotionValuesFromProps(n,{},this);for(const v in g){const S=g[v];h[v]!==void 0&&Yt(S)&&S.set(h[v])}}mount(e){this.current=e,ZK.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),R_.current||XK(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:qm.current,this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Vr(this.notifyUpdate),Vr(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const r=Wo.has(e);r&&this.onBindTransform&&this.onBindTransform();const a=n.on("change",c=>{this.latestValues[e]=c,this.props.onUpdate&&it.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let u;window.MotionCheckAppearSync&&(u=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{a(),u&&u(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ho){const n=Ho[e];if(!n)continue;const{isEnabled:r,Feature:a}=n;if(!this.features[e]&&a&&r(this.props)&&(this.features[e]=new a(this)),this.features[e]){const u=this.features[e];u.isMounted?u.update():(u.mount(),u.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):yt()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<tx.length;r++){const a=tx[r];this.propEventSubscriptions[a]&&(this.propEventSubscriptions[a](),delete this.propEventSubscriptions[a]);const u="on"+a,c=e[u];c&&(this.propEventSubscriptions[a]=this.on(a,c))}this.prevMotionValues=QK(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const r=this.values.get(e);n!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&n!==void 0&&(r=Io(n===null?void 0:n,{owner:this}),this.addValue(e,r)),r}readValue(e,n){let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(wO(r)||TO(r))?r=parseFloat(r):!dK(r)&&Ur.test(n)&&(r=r_(e,n)),this.setBaseTarget(e,Yt(r)?r.get():r)),Yt(r)?r.get():r}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const u=Sg(this.props,n,this.presenceContext?.custom);u&&(r=u[e])}if(n&&r!==void 0)return r;const a=this.getBaseTargetFromProps(this.props,e);return a!==void 0&&!Yt(a)?a:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Qy),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){hg.render(this.render)}}class C_ extends WK{constructor(){super(...arguments),this.KeyframeResolver=WU}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:r}){delete n[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Yt(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function k_(t,{style:e,vars:n},r,a){const u=t.style;let c;for(c in e)u[c]=e[c];a?.applyProjectionStyles(u,r);for(c in n)u.setProperty(c,n[c])}function eq(t){return window.getComputedStyle(t)}class tq extends C_{constructor(){super(...arguments),this.type="html",this.renderInstance=k_}readValueFromInstance(e,n){if(Wo.has(n))return this.projection?.isProjecting?Nm(n):bU(e,n);{const r=eq(e),a=(tg(n)?r.getPropertyValue(n):r[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(e,{transformPagePoint:n}){return __(e,n)}build(e,n,r){gg(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return wg(e,n,r)}}const M_=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function nq(t,e,n,r){k_(t,e,void 0,r);for(const a in e.attrs)t.setAttribute(M_.has(a)?a:xg(a),e.attrs[a])}class iq extends C_{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=yt}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Wo.has(n)){const r=i_(n);return r&&r.default||0}return n=M_.has(n)?n:xg(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return S_(e,n,r)}build(e,n,r){y_(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,a){nq(e,n,r,a)}mount(e){this.isSVGTag=b_(e.tagName),super.mount(e)}}const rq=(t,e)=>vg(t)?new iq(e):new tq(e,{allowProjection:t!==$.Fragment});function jo(t,e,n){const r=t.getProps();return Sg(r,e,n!==void 0?n:r.custom,t)}const Pm=t=>Array.isArray(t);function sq(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Io(n))}function oq(t){return Pm(t)?t[t.length-1]||0:t}function aq(t,e){const n=jo(t,e);let{transitionEnd:r={},transition:a={},...u}=n||{};u={...u,...r};for(const c in u){const f=oq(u[c]);sq(t,c,f)}}function lq(t){return!!(Yt(t)&&t.add)}function Im(t,e){const n=t.getValue("willChange");if(lq(n))return n.add(e);if(!n&&Qi.WillChange){const r=new Qi.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function D_(t){return t.props[w_]}const uq=t=>t!==null;function cq(t,{repeat:e,repeatType:n="loop"},r){const a=t.filter(uq),u=e&&n!=="loop"&&e%2===1?0:a.length-1;return a[u]}const fq={type:"spring",stiffness:500,damping:25,restSpeed:10},dq=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),hq={type:"keyframes",duration:.8},pq={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},mq=(t,{keyframes:e})=>e.length>2?hq:Wo.has(t)?t.startsWith("scale")?dq(e[1]):fq:pq;function yq({when:t,delay:e,delayChildren:n,staggerChildren:r,staggerDirection:a,repeat:u,repeatType:c,repeatDelay:f,from:h,elapsed:m,...y}){return!!Object.keys(y).length}const Tg=(t,e,n,r={},a,u)=>c=>{const f=fg(r,t)||{},h=f.delay||r.delay||0;let{elapsed:m=0}=r;m=m-pi(h);const y={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...f,delay:-m,onUpdate:v=>{e.set(v),f.onUpdate&&f.onUpdate(v)},onComplete:()=>{c(),f.onComplete&&f.onComplete()},name:t,motionValue:e,element:u?void 0:a};yq(f)||Object.assign(y,mq(t,y)),y.duration&&(y.duration=pi(y.duration)),y.repeatDelay&&(y.repeatDelay=pi(y.repeatDelay)),y.from!==void 0&&(y.keyframes[0]=y.from);let g=!1;if((y.type===!1||y.duration===0&&!y.repeatDelay)&&(Lm(y),y.delay===0&&(g=!0)),(Qi.instantAnimations||Qi.skipAnimations)&&(g=!0,Lm(y),y.delay=0),y.allowFlatten=!f.type&&!f.ease,g&&!u&&e.get()!==void 0){const v=cq(y.keyframes,f);if(v!==void 0){it.update(()=>{y.onUpdate(v),y.onComplete()});return}}return f.isSync?new ug(y):new KU(y)};function gq({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function N_(t,e,{delay:n=0,transitionOverride:r,type:a}={}){let{transition:u=t.getDefaultTransition(),transitionEnd:c,...f}=e;r&&(u=r);const h=[],m=a&&t.animationState&&t.animationState.getState()[a];for(const y in f){const g=t.getValue(y,t.latestValues[y]??null),v=f[y];if(v===void 0||m&&gq(m,y))continue;const S={delay:n,...fg(u||{},y)},x=g.get();if(x!==void 0&&!g.isAnimating&&!Array.isArray(v)&&v===x&&!S.velocity)continue;let T=!1;if(window.MotionHandoffAnimation){const C=D_(t);if(C){const _=window.MotionHandoffAnimation(C,y,it);_!==null&&(S.startTime=_,T=!0)}}Im(t,y),g.start(Tg(y,g,v,t.shouldReduceMotion&&e_.has(y)?{type:!1}:S,t,T));const M=g.animation;M&&h.push(M)}return c&&Promise.all(h).then(()=>{it.update(()=>{c&&aq(t,c)})}),h}function $_(t,e,n,r=0,a=1){const u=Array.from(t).sort((m,y)=>m.sortNodePosition(y)).indexOf(e),c=t.size,f=(c-1)*r;return typeof n=="function"?n(u,c):a===1?u*r:f-u*r}function Hm(t,e,n={}){const r=jo(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(a=n.transitionOverride);const u=r?()=>Promise.all(N_(t,r,n)):()=>Promise.resolve(),c=t.variantChildren&&t.variantChildren.size?(h=0)=>{const{delayChildren:m=0,staggerChildren:y,staggerDirection:g}=a;return bq(t,e,h,m,y,g,n)}:()=>Promise.resolve(),{when:f}=a;if(f){const[h,m]=f==="beforeChildren"?[u,c]:[c,u];return h().then(()=>m())}else return Promise.all([u(),c(n.delay)])}function bq(t,e,n=0,r=0,a=0,u=1,c){const f=[];for(const h of t.variantChildren)h.notify("AnimationStart",e),f.push(Hm(h,e,{...c,delay:n+(typeof r=="function"?0:r)+$_(t.variantChildren,h,r,a,u)}).then(()=>h.notify("AnimationComplete",e)));return Promise.all(f)}function vq(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const a=e.map(u=>Hm(t,u,n));r=Promise.all(a)}else if(typeof e=="string")r=Hm(t,e,n);else{const a=typeof e=="function"?jo(t,e,n.custom):e;r=Promise.all(N_(t,a,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}function j_(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const Sq=yg.length;function B_(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?B_(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Sq;n++){const r=yg[n],a=t.props[r];(xl(a)||a===!1)&&(e[r]=a)}return e}const wq=[...mg].reverse(),xq=mg.length;function Tq(t){return e=>Promise.all(e.map(({animation:n,options:r})=>vq(t,n,r)))}function Aq(t){let e=Tq(t),n=nx(),r=!0;const a=h=>(m,y)=>{const g=jo(t,y,h==="exit"?t.presenceContext?.custom:void 0);if(g){const{transition:v,transitionEnd:S,...x}=g;m={...m,...x,...S}}return m};function u(h){e=h(t)}function c(h){const{props:m}=t,y=B_(t.parent)||{},g=[],v=new Set;let S={},x=1/0;for(let M=0;M<xq;M++){const C=wq[M],_=n[C],R=m[C]!==void 0?m[C]:y[C],G=xl(R),I=C===h?_.isActive:null;I===!1&&(x=M);let ee=R===y[C]&&R!==m[C]&&G;if(ee&&r&&t.manuallyAnimateOnMount&&(ee=!1),_.protectedKeys={...S},!_.isActive&&I===null||!R&&!_.prevProp||jf(R)||typeof R=="boolean")continue;const J=Eq(_.prevProp,R);let X=J||C===h&&_.isActive&&!ee&&G||M>x&&G,he=!1;const pe=Array.isArray(R)?R:[R];let we=pe.reduce(a(C),{});I===!1&&(we={});const{prevResolvedValues:je={}}=_,ve={...je,...we},Z=U=>{X=!0,v.has(U)&&(he=!0,v.delete(U)),_.needsAnimating[U]=!0;const L=t.getValue(U);L&&(L.liveStyle=!1)};for(const U in ve){const L=we[U],te=je[U];if(S.hasOwnProperty(U))continue;let oe=!1;Pm(L)&&Pm(te)?oe=!j_(L,te):oe=L!==te,oe?L!=null?Z(U):v.add(U):L!==void 0&&v.has(U)?Z(U):_.protectedKeys[U]=!0}_.prevProp=R,_.prevResolvedValues=we,_.isActive&&(S={...S,...we}),r&&t.blockInitialAnimation&&(X=!1);const ne=ee&&J;X&&(!ne||he)&&g.push(...pe.map(U=>{const L={type:C};if(typeof U=="string"&&r&&!ne&&t.manuallyAnimateOnMount&&t.parent){const{parent:te}=t,oe=jo(te,U);if(te.enteringChildren&&oe){const{delayChildren:E}=oe.transition||{};L.delay=$_(te.enteringChildren,t,E)}}return{animation:U,options:L}}))}if(v.size){const M={};if(typeof m.initial!="boolean"){const C=jo(t,Array.isArray(m.initial)?m.initial[0]:m.initial);C&&C.transition&&(M.transition=C.transition)}v.forEach(C=>{const _=t.getBaseTarget(C),R=t.getValue(C);R&&(R.liveStyle=!0),M[C]=_??null}),g.push({animation:M})}let T=!!g.length;return r&&(m.initial===!1||m.initial===m.animate)&&!t.manuallyAnimateOnMount&&(T=!1),r=!1,T?e(g):Promise.resolve()}function f(h,m){if(n[h].isActive===m)return Promise.resolve();t.variantChildren?.forEach(g=>g.animationState?.setActive(h,m)),n[h].isActive=m;const y=c(h);for(const g in n)n[g].protectedKeys={};return y}return{animateChanges:c,setActive:f,setAnimateFunction:u,getState:()=>n,reset:()=>{n=nx()}}}function Eq(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!j_(e,t):!1}function ds(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function nx(){return{animate:ds(!0),whileInView:ds(),whileHover:ds(),whileTap:ds(),whileDrag:ds(),whileFocus:ds(),exit:ds()}}class Gr{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Oq extends Gr{constructor(e){super(e),e.animationState||(e.animationState=Aq(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();jf(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let _q=0;class Rq extends Gr{constructor(){super(...arguments),this.id=_q++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;const a=this.node.animationState.setActive("exit",!e);n&&!e&&a.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Cq={animation:{Feature:Oq},exit:{Feature:Rq}};function Al(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}function Ul(t){return{point:{x:t.pageX,y:t.pageY}}}const kq=t=>e=>pg(e)&&t(e,Ul(e));function ol(t,e,n,r){return Al(t,e,kq(n),r)}const z_=1e-4,Mq=1-z_,Dq=1+z_,L_=.01,Nq=0-L_,$q=0+L_;function Wt(t){return t.max-t.min}function jq(t,e,n){return Math.abs(t-e)<=n}function ix(t,e,n,r=.5){t.origin=r,t.originPoint=rt(e.min,e.max,t.origin),t.scale=Wt(n)/Wt(e),t.translate=rt(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Mq&&t.scale<=Dq||isNaN(t.scale))&&(t.scale=1),(t.translate>=Nq&&t.translate<=$q||isNaN(t.translate))&&(t.translate=0)}function al(t,e,n,r){ix(t.x,e.x,n.x,r?r.originX:void 0),ix(t.y,e.y,n.y,r?r.originY:void 0)}function rx(t,e,n){t.min=n.min+e.min,t.max=t.min+Wt(e)}function Bq(t,e,n){rx(t.x,e.x,n.x),rx(t.y,e.y,n.y)}function sx(t,e,n){t.min=e.min-n.min,t.max=t.min+Wt(e)}function ll(t,e,n){sx(t.x,e.x,n.x),sx(t.y,e.y,n.y)}function Ln(t){return[t("x"),t("y")]}const V_=({current:t})=>t?t.ownerDocument.defaultView:null,ox=(t,e)=>Math.abs(t-e);function zq(t,e){const n=ox(t.x,e.x),r=ox(t.y,e.y);return Math.sqrt(n**2+r**2)}class U_{constructor(e,n,{transformPagePoint:r,contextWindow:a=window,dragSnapToOrigin:u=!1,distanceThreshold:c=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=jp(this.lastMoveEventInfo,this.history),S=this.startEvent!==null,x=zq(v.offset,{x:0,y:0})>=this.distanceThreshold;if(!S&&!x)return;const{point:T}=v,{timestamp:M}=Ht;this.history.push({...T,timestamp:M});const{onStart:C,onMove:_}=this.handlers;S||(C&&C(this.lastMoveEvent,v),this.startEvent=this.lastMoveEvent),_&&_(this.lastMoveEvent,v)},this.handlePointerMove=(v,S)=>{this.lastMoveEvent=v,this.lastMoveEventInfo=$p(S,this.transformPagePoint),it.update(this.updatePoint,!0)},this.handlePointerUp=(v,S)=>{this.end();const{onEnd:x,onSessionEnd:T,resumeAnimation:M}=this.handlers;if(this.dragSnapToOrigin&&M&&M(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=jp(v.type==="pointercancel"?this.lastMoveEventInfo:$p(S,this.transformPagePoint),this.history);this.startEvent&&x&&x(v,C),T&&T(v,C)},!pg(e))return;this.dragSnapToOrigin=u,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=c,this.contextWindow=a||window;const f=Ul(e),h=$p(f,this.transformPagePoint),{point:m}=h,{timestamp:y}=Ht;this.history=[{...m,timestamp:y}];const{onSessionStart:g}=n;g&&g(e,jp(h,this.history)),this.removeListeners=zl(ol(this.contextWindow,"pointermove",this.handlePointerMove),ol(this.contextWindow,"pointerup",this.handlePointerUp),ol(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Vr(this.updatePoint)}}function $p(t,e){return e?{point:e(t.point)}:t}function ax(t,e){return{x:t.x-e.x,y:t.y-e.y}}function jp({point:t},e){return{point:t,delta:ax(t,K_(e)),offset:ax(t,Lq(e)),velocity:Vq(e,.1)}}function Lq(t){return t[0]}function K_(t){return t[t.length-1]}function Vq(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const a=K_(t);for(;n>=0&&(r=t[n],!(a.timestamp-r.timestamp>pi(e)));)n--;if(!r)return{x:0,y:0};const u=qn(a.timestamp-r.timestamp);if(u===0)return{x:0,y:0};const c={x:(a.x-r.x)/u,y:(a.y-r.y)/u};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}function Uq(t,{min:e,max:n},r){return e!==void 0&&t<e?t=r?rt(e,t,r.min):Math.max(t,e):n!==void 0&&t>n&&(t=r?rt(n,t,r.max):Math.min(t,n)),t}function lx(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Kq(t,{top:e,left:n,bottom:r,right:a}){return{x:lx(t.x,n,a),y:lx(t.y,e,r)}}function ux(t,e){let n=e.min-t.min,r=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,r]=[r,n]),{min:n,max:r}}function qq(t,e){return{x:ux(t.x,e.x),y:ux(t.y,e.y)}}function Pq(t,e){let n=.5;const r=Wt(t),a=Wt(e);return a>r?n=vl(e.min,e.max-r,t.min):r>a&&(n=vl(t.min,t.max-a,e.min)),Zi(0,1,n)}function Iq(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Fm=.35;function Hq(t=Fm){return t===!1?t=0:t===!0&&(t=Fm),{x:cx(t,"left","right"),y:cx(t,"top","bottom")}}function cx(t,e,n){return{min:fx(t,e),max:fx(t,n)}}function fx(t,e){return typeof t=="number"?t:t[e]||0}const Fq=new WeakMap;class Gq{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=yt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const u=g=>{const{dragSnapToOrigin:v}=this.getProps();v?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Ul(g).point)},c=(g,v)=>{const{drag:S,dragPropagation:x,onDragStart:T}=this.getProps();if(S&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=rK(S),!this.openDragLock))return;this.latestPointerEvent=g,this.latestPanInfo=v,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ln(C=>{let _=this.getAxisMotionValue(C).get()||0;if(mi.test(_)){const{projection:R}=this.visualElement;if(R&&R.layout){const G=R.layout.layoutBox[C];G&&(_=Wt(G)*(parseFloat(_)/100))}}this.originPoint[C]=_}),T&&it.postRender(()=>T(g,v)),Im(this.visualElement,"transform");const{animationState:M}=this.visualElement;M&&M.setActive("whileDrag",!0)},f=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v;const{dragPropagation:S,dragDirectionLock:x,onDirectionLock:T,onDrag:M}=this.getProps();if(!S&&!this.openDragLock)return;const{offset:C}=v;if(x&&this.currentDirection===null){this.currentDirection=Yq(C),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",v.point,C),this.updateAxis("y",v.point,C),this.visualElement.render(),M&&M(g,v)},h=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v,this.stop(g,v),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>Ln(g=>this.getAnimationState(g)==="paused"&&this.getAxisMotionValue(g).animation?.play()),{dragSnapToOrigin:y}=this.getProps();this.panSession=new U_(e,{onSessionStart:u,onStart:c,onMove:f,onSessionEnd:h,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:r,contextWindow:V_(this.visualElement)})}stop(e,n){const r=e||this.latestPointerEvent,a=n||this.latestPanInfo,u=this.isDragging;if(this.cancel(),!u||!a||!r)return;const{velocity:c}=a;this.startAnimation(c);const{onDragEnd:f}=this.getProps();f&&it.postRender(()=>f(r,a))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,r){const{drag:a}=this.getProps();if(!r||!vc(e,a,this.currentDirection))return;const u=this.getAxisMotionValue(e);let c=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(c=Uq(c,this.constraints[e],this.elastic[e])),u.set(c)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,a=this.constraints;e&&Ao(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&r?this.constraints=Kq(r.layoutBox,e):this.constraints=!1,this.elastic=Hq(n),a!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Ln(u=>{this.constraints!==!1&&this.getAxisMotionValue(u)&&(this.constraints[u]=Iq(r.layoutBox[u],this.constraints[u]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Ao(e))return!1;const r=e.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const u=JK(r,a.root,this.visualElement.getTransformPagePoint());let c=qq(a.layout.layoutBox,u);if(n){const f=n(FK(c));this.hasMutatedConstraints=!!f,f&&(c=A_(f))}return c}startAnimation(e){const{drag:n,dragMomentum:r,dragElastic:a,dragTransition:u,dragSnapToOrigin:c,onDragTransitionEnd:f}=this.getProps(),h=this.constraints||{},m=Ln(y=>{if(!vc(y,n,this.currentDirection))return;let g=h&&h[y]||{};c&&(g={min:0,max:0});const v=a?200:1e6,S=a?40:1e7,x={type:"inertia",velocity:r?e[y]:0,bounceStiffness:v,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...u,...g};return this.startAxisValueAnimation(y,x)});return Promise.all(m).then(f)}startAxisValueAnimation(e,n){const r=this.getAxisMotionValue(e);return Im(this.visualElement,e),r.start(Tg(e,r,0,n,this.visualElement,!1))}stopAnimation(){Ln(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Ln(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps(),a=r[n];return a||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){Ln(n=>{const{drag:r}=this.getProps();if(!vc(n,r,this.currentDirection))return;const{projection:a}=this.visualElement,u=this.getAxisMotionValue(n);if(a&&a.layout){const{min:c,max:f}=a.layout.layoutBox[n];u.set(e[n]-rt(c,f,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Ao(n)||!r||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Ln(c=>{const f=this.getAxisMotionValue(c);if(f&&this.constraints!==!1){const h=f.get();a[c]=Pq({min:h,max:h},this.constraints[c])}});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Ln(c=>{if(!vc(c,e,null))return;const f=this.getAxisMotionValue(c),{min:h,max:m}=this.constraints[c];f.set(rt(h,m,a[c]))})}addListeners(){if(!this.visualElement.current)return;Fq.set(this.visualElement,this);const e=this.visualElement.current,n=ol(e,"pointerdown",h=>{const{drag:m,dragListener:y=!0}=this.getProps();m&&y&&this.start(h)}),r=()=>{const{dragConstraints:h}=this.getProps();Ao(h)&&h.current&&(this.constraints=this.resolveRefConstraints())},{projection:a}=this.visualElement,u=a.addEventListener("measure",r);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),it.read(r);const c=Al(window,"resize",()=>this.scalePositionWithinConstraints()),f=a.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:m})=>{this.isDragging&&m&&(Ln(y=>{const g=this.getAxisMotionValue(y);g&&(this.originPoint[y]+=h[y].translate,g.set(g.get()+h[y].translate))}),this.visualElement.render())}));return()=>{c(),n(),u(),f&&f()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:a=!1,dragConstraints:u=!1,dragElastic:c=Fm,dragMomentum:f=!0}=e;return{...e,drag:n,dragDirectionLock:r,dragPropagation:a,dragConstraints:u,dragElastic:c,dragMomentum:f}}}function vc(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Yq(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class Jq extends Gr{constructor(e){super(e),this.removeGroupControls=Pn,this.removeListeners=Pn,this.controls=new Gq(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Pn}unmount(){this.removeGroupControls(),this.removeListeners()}}const dx=t=>(e,n)=>{t&&it.postRender(()=>t(e,n))};class Xq extends Gr{constructor(){super(...arguments),this.removePointerDownListener=Pn}onPointerDown(e){this.session=new U_(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:V_(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:r,onPanEnd:a}=this.node.getProps();return{onSessionStart:dx(e),onStart:dx(n),onMove:r,onEnd:(u,c)=>{delete this.session,a&&it.postRender(()=>a(u,c))}}}mount(){this.removePointerDownListener=ol(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const $c={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function hx(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ja={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(de.test(t))t=parseFloat(t);else return t;const n=hx(t,e.target.x),r=hx(t,e.target.y);return`${n}% ${r}%`}},Zq={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,a=Ur.parse(t);if(a.length>5)return r;const u=Ur.createTransformer(t),c=typeof a[0]!="number"?1:0,f=n.x.scale*e.x,h=n.y.scale*e.y;a[0+c]/=f,a[1+c]/=h;const m=rt(f,h,.5);return typeof a[2+c]=="number"&&(a[2+c]/=m),typeof a[3+c]=="number"&&(a[3+c]/=m),u(a)}};let Bp=!1;class Qq extends $.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r,layoutId:a}=this.props,{projection:u}=e;SK(Wq),u&&(n.group&&n.group.add(u),r&&r.register&&a&&r.register(u),Bp&&u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,onExitComplete:()=>this.safeToRemove()})),$c.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:r,drag:a,isPresent:u}=this.props,{projection:c}=r;return c&&(c.isPresent=u,Bp=!0,a||e.layoutDependency!==n||n===void 0||e.isPresent!==u?c.willUpdate():this.safeToRemove(),e.isPresent!==u&&(u?c.promote():c.relegate()||it.postRender(()=>{const f=c.getStack();(!f||!f.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),hg.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:a}=e;Bp=!0,a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),r&&r.deregister&&r.deregister(a))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function q_(t){const[e,n]=hK(),r=$.useContext(SO);return F.jsx(Qq,{...t,layoutGroup:r,switchLayoutGroup:$.useContext(x_),isPresent:e,safeToRemove:n})}const Wq={borderRadius:{...Ja,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ja,borderTopRightRadius:Ja,borderBottomLeftRadius:Ja,borderBottomRightRadius:Ja,boxShadow:Zq};function e6(t,e,n){const r=Yt(t)?t:Io(t);return r.start(Tg("",r,e,n)),r.animation}const t6=(t,e)=>t.depth-e.depth;class n6{constructor(){this.children=[],this.isDirty=!1}add(e){Yy(this.children,e),this.isDirty=!0}remove(e){Jy(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(t6),this.isDirty=!1,this.children.forEach(e)}}function i6(t,e){const n=fn.now(),r=({timestamp:a})=>{const u=a-n;u>=e&&(Vr(r),t(u-e))};return it.setup(r,!0),()=>Vr(r)}const P_=["TopLeft","TopRight","BottomLeft","BottomRight"],r6=P_.length,px=t=>typeof t=="string"?parseFloat(t):t,mx=t=>typeof t=="number"||de.test(t);function s6(t,e,n,r,a,u){a?(t.opacity=rt(0,n.opacity??1,o6(r)),t.opacityExit=rt(e.opacity??1,0,a6(r))):u&&(t.opacity=rt(e.opacity??1,n.opacity??1,r));for(let c=0;c<r6;c++){const f=`border${P_[c]}Radius`;let h=yx(e,f),m=yx(n,f);if(h===void 0&&m===void 0)continue;h||(h=0),m||(m=0),h===0||m===0||mx(h)===mx(m)?(t[f]=Math.max(rt(px(h),px(m),r),0),(mi.test(m)||mi.test(h))&&(t[f]+="%")):t[f]=m}(e.rotate||n.rotate)&&(t.rotate=rt(e.rotate||0,n.rotate||0,r))}function yx(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const o6=I_(0,.5,MO),a6=I_(.5,.95,Pn);function I_(t,e,n){return r=>r<t?0:r>e?1:n(vl(t,e,r))}function gx(t,e){t.min=e.min,t.max=e.max}function Bn(t,e){gx(t.x,e.x),gx(t.y,e.y)}function bx(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function vx(t,e,n,r,a){return t-=e,t=of(t,1/n,r),a!==void 0&&(t=of(t,1/a,r)),t}function l6(t,e=0,n=1,r=.5,a,u=t,c=t){if(mi.test(e)&&(e=parseFloat(e),e=rt(c.min,c.max,e/100)-c.min),typeof e!="number")return;let f=rt(u.min,u.max,r);t===u&&(f-=e),t.min=vx(t.min,e,n,f,a),t.max=vx(t.max,e,n,f,a)}function Sx(t,e,[n,r,a],u,c){l6(t,e[n],e[r],e[a],e.scale,u,c)}const u6=["x","scaleX","originX"],c6=["y","scaleY","originY"];function wx(t,e,n,r){Sx(t.x,e,u6,n?n.x:void 0,r?r.x:void 0),Sx(t.y,e,c6,n?n.y:void 0,r?r.y:void 0)}function xx(t){return t.translate===0&&t.scale===1}function H_(t){return xx(t.x)&&xx(t.y)}function Tx(t,e){return t.min===e.min&&t.max===e.max}function f6(t,e){return Tx(t.x,e.x)&&Tx(t.y,e.y)}function Ax(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function F_(t,e){return Ax(t.x,e.x)&&Ax(t.y,e.y)}function Ex(t){return Wt(t.x)/Wt(t.y)}function Ox(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class d6{constructor(){this.members=[]}add(e){Yy(this.members,e),e.scheduleRender()}remove(e){if(Jy(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(a=>e===a);if(n===0)return!1;let r;for(let a=n;a>=0;a--){const u=this.members[a];if(u.isPresent!==!1){r=u;break}}return r?(this.promote(r),!0):!1}promote(e,n){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender(),e.resumeFrom=r,n&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:a}=e.options;a===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:r}=e;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function h6(t,e,n){let r="";const a=t.x.translate/e.x,u=t.y.translate/e.y,c=n?.z||0;if((a||u||c)&&(r=`translate3d(${a}px, ${u}px, ${c}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:m,rotate:y,rotateX:g,rotateY:v,skewX:S,skewY:x}=n;m&&(r=`perspective(${m}px) ${r}`),y&&(r+=`rotate(${y}deg) `),g&&(r+=`rotateX(${g}deg) `),v&&(r+=`rotateY(${v}deg) `),S&&(r+=`skewX(${S}deg) `),x&&(r+=`skewY(${x}deg) `)}const f=t.x.scale*e.x,h=t.y.scale*e.y;return(f!==1||h!==1)&&(r+=`scale(${f}, ${h})`),r||"none"}const zp=["","X","Y","Z"],p6=1e3;let m6=0;function Lp(t,e,n,r){const{latestValues:a}=e;a[t]&&(n[t]=a[t],e.setStaticValue(t,0),r&&(r[t]=0))}function G_(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=D_(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:u}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",it,!(a||u))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&G_(r)}function Y_({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:a}){return class{constructor(c={},f=e?.()){this.id=m6++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(b6),this.nodes.forEach(x6),this.nodes.forEach(T6),this.nodes.forEach(v6)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,this.root=f?f.root||f:this,this.path=f?[...f.path,f]:[],this.parent=f,this.depth=f?f.depth+1:0;for(let h=0;h<this.path.length;h++)this.path[h].shouldResetTransform=!0;this.root===this&&(this.nodes=new n6)}addEventListener(c,f){return this.eventHandlers.has(c)||this.eventHandlers.set(c,new Qy),this.eventHandlers.get(c).add(f)}notifyListeners(c,...f){const h=this.eventHandlers.get(c);h&&h.notify(...f)}hasListeners(c){return this.eventHandlers.has(c)}mount(c){if(this.instance)return;this.isSVG=u_(c)&&!cK(c),this.instance=c;const{layoutId:f,layout:h,visualElement:m}=this.options;if(m&&!m.current&&m.mount(c),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(h||f)&&(this.isLayoutDirty=!0),t){let y,g=0;const v=()=>this.root.updateBlockedByResize=!1;it.read(()=>{g=window.innerWidth}),t(c,()=>{const S=window.innerWidth;S!==g&&(g=S,this.root.updateBlockedByResize=!0,y&&y(),y=i6(v,250),$c.hasAnimatedSinceResize&&($c.hasAnimatedSinceResize=!1,this.nodes.forEach(Cx)))})}f&&this.root.registerSharedNode(f,this),this.options.animate!==!1&&m&&(f||h)&&this.addEventListener("didUpdate",({delta:y,hasLayoutChanged:g,hasRelativeLayoutChanged:v,layout:S})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||m.getDefaultTransition()||R6,{onLayoutAnimationStart:T,onLayoutAnimationComplete:M}=m.getProps(),C=!this.targetLayout||!F_(this.targetLayout,S),_=!g&&v;if(this.options.layoutRoot||this.resumeFrom||_||g&&(C||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const R={...fg(x,"layout"),onPlay:T,onComplete:M};(m.shouldReduceMotion||this.options.layoutRoot)&&(R.delay=0,R.type=!1),this.startAnimation(R),this.setAnimationOrigin(y,_)}else g||Cx(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=S})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const c=this.getStack();c&&c.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Vr(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(A6),this.animationId++)}getTransformTemplate(){const{visualElement:c}=this.options;return c&&c.getProps().transformTemplate}willUpdate(c=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&G_(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let y=0;y<this.path.length;y++){const g=this.path[y];g.shouldResetTransform=!0,g.updateScroll("snapshot"),g.options.layoutRoot&&g.willUpdate(!1)}const{layoutId:f,layout:h}=this.options;if(f===void 0&&!h)return;const m=this.getTransformTemplate();this.prevTransformTemplateValue=m?m(this.latestValues,""):void 0,this.updateSnapshot(),c&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(_x);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Rx);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(w6),this.nodes.forEach(y6),this.nodes.forEach(g6)):this.nodes.forEach(Rx),this.clearAllSnapshots();const f=fn.now();Ht.delta=Zi(0,1e3/60,f-Ht.timestamp),Ht.timestamp=f,Ht.isProcessing=!0,Op.update.process(Ht),Op.preRender.process(Ht),Op.render.process(Ht),Ht.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,hg.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(S6),this.sharedNodes.forEach(E6)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,it.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){it.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Wt(this.snapshot.measuredBox.x)&&!Wt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h<this.path.length;h++)this.path[h].updateScroll();const c=this.layout;this.layout=this.measure(!1),this.layoutCorrected=yt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:f}=this.options;f&&f.notify("LayoutMeasure",this.layout.layoutBox,c?c.layoutBox:void 0)}updateScroll(c="measure"){let f=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===c&&(f=!1),f&&this.instance){const h=r(this.instance);this.scroll={animationId:this.root.animationId,phase:c,isRoot:h,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:h}}}resetTransform(){if(!a)return;const c=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,f=this.projectionDelta&&!H_(this.projectionDelta),h=this.getTransformTemplate(),m=h?h(this.latestValues,""):void 0,y=m!==this.prevTransformTemplateValue;c&&this.instance&&(f||ms(this.latestValues)||y)&&(a(this.instance,m),this.shouldResetTransform=!1,this.scheduleRender())}measure(c=!0){const f=this.measurePageBox();let h=this.removeElementScroll(f);return c&&(h=this.removeTransform(h)),C6(h),{animationId:this.root.animationId,measuredBox:f,layoutBox:h,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:c}=this.options;if(!c)return yt();const f=c.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(k6))){const{scroll:m}=this.root;m&&(Eo(f.x,m.offset.x),Eo(f.y,m.offset.y))}return f}removeElementScroll(c){const f=yt();if(Bn(f,c),this.scroll?.wasRoot)return f;for(let h=0;h<this.path.length;h++){const m=this.path[h],{scroll:y,options:g}=m;m!==this.root&&y&&g.layoutScroll&&(y.wasRoot&&Bn(f,c),Eo(f.x,y.offset.x),Eo(f.y,y.offset.y))}return f}applyTransform(c,f=!1){const h=yt();Bn(h,c);for(let m=0;m<this.path.length;m++){const y=this.path[m];!f&&y.options.layoutScroll&&y.scroll&&y!==y.root&&Oo(h,{x:-y.scroll.offset.x,y:-y.scroll.offset.y}),ms(y.latestValues)&&Oo(h,y.latestValues)}return ms(this.latestValues)&&Oo(h,this.latestValues),h}removeTransform(c){const f=yt();Bn(f,c);for(let h=0;h<this.path.length;h++){const m=this.path[h];if(!m.instance||!ms(m.latestValues))continue;Um(m.latestValues)&&m.updateSnapshot();const y=yt(),g=m.measurePageBox();Bn(y,g),wx(f,m.latestValues,m.snapshot?m.snapshot.layoutBox:void 0,y)}return ms(this.latestValues)&&wx(f,this.latestValues),f}setTargetDelta(c){this.targetDelta=c,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(c){this.options={...this.options,...c,crossfade:c.crossfade!==void 0?c.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ht.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(c=!1){const f=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=f.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=f.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=f.isSharedProjectionDirty);const h=!!this.resumingFrom||this!==f;if(!(c||h&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:y,layoutId:g}=this.options;if(!(!this.layout||!(y||g))){if(this.resolvedRelativeTargetAt=Ht.timestamp,!this.targetDelta&&!this.relativeTarget){const v=this.getClosestProjectingParent();v&&v.layout&&this.animationProgress!==1?(this.relativeParent=v,this.forceRelativeParentToResolveTarget(),this.relativeTarget=yt(),this.relativeTargetOrigin=yt(),ll(this.relativeTargetOrigin,this.layout.layoutBox,v.layout.layoutBox),Bn(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=yt(),this.targetWithTransforms=yt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Bq(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Bn(this.target,this.layout.layoutBox),O_(this.target,this.targetDelta)):Bn(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const v=this.getClosestProjectingParent();v&&!!v.resumingFrom==!!this.resumingFrom&&!v.options.layoutScroll&&v.target&&this.animationProgress!==1?(this.relativeParent=v,this.forceRelativeParentToResolveTarget(),this.relativeTarget=yt(),this.relativeTargetOrigin=yt(),ll(this.relativeTargetOrigin,this.target,v.target),Bn(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Um(this.parent.latestValues)||E_(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const c=this.getLead(),f=!!this.resumingFrom||this!==c;let h=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(h=!1),f&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(h=!1),this.resolvedRelativeTargetAt===Ht.timestamp&&(h=!1),h)return;const{layout:m,layoutId:y}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(m||y))return;Bn(this.layoutCorrected,this.layout.layoutBox);const g=this.treeScale.x,v=this.treeScale.y;YK(this.layoutCorrected,this.treeScale,this.path,f),c.layout&&!c.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(c.target=c.layout.layoutBox,c.targetWithTransforms=yt());const{target:S}=c;if(!S){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(bx(this.prevProjectionDelta.x,this.projectionDelta.x),bx(this.prevProjectionDelta.y,this.projectionDelta.y)),al(this.projectionDelta,this.layoutCorrected,S,this.latestValues),(this.treeScale.x!==g||this.treeScale.y!==v||!Ox(this.projectionDelta.x,this.prevProjectionDelta.x)||!Ox(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",S))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(c=!0){if(this.options.visualElement?.scheduleRender(),c){const f=this.getStack();f&&f.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=_o(),this.projectionDelta=_o(),this.projectionDeltaWithTransform=_o()}setAnimationOrigin(c,f=!1){const h=this.snapshot,m=h?h.latestValues:{},y={...this.latestValues},g=_o();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!f;const v=yt(),S=h?h.source:void 0,x=this.layout?this.layout.source:void 0,T=S!==x,M=this.getStack(),C=!M||M.members.length<=1,_=!!(T&&!C&&this.options.crossfade===!0&&!this.path.some(_6));this.animationProgress=0;let R;this.mixTargetDelta=G=>{const I=G/1e3;kx(g.x,c.x,I),kx(g.y,c.y,I),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ll(v,this.layout.layoutBox,this.relativeParent.layout.layoutBox),O6(this.relativeTarget,this.relativeTargetOrigin,v,I),R&&f6(this.relativeTarget,R)&&(this.isProjectionDirty=!1),R||(R=yt()),Bn(R,this.relativeTarget)),T&&(this.animationValues=y,s6(y,m,this.latestValues,I,_,C)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=I},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Vr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=it.update(()=>{$c.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Io(0)),this.currentAnimation=e6(this.motionValue,[0,1e3],{...c,velocity:0,isSync:!0,onUpdate:f=>{this.mixTargetDelta(f),c.onUpdate&&c.onUpdate(f)},onStop:()=>{},onComplete:()=>{c.onComplete&&c.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const c=this.getStack();c&&c.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(p6),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const c=this.getLead();let{targetWithTransforms:f,target:h,layout:m,latestValues:y}=c;if(!(!f||!h||!m)){if(this!==c&&this.layout&&m&&J_(this.options.animationType,this.layout.layoutBox,m.layoutBox)){h=this.target||yt();const g=Wt(this.layout.layoutBox.x);h.x.min=c.target.x.min,h.x.max=h.x.min+g;const v=Wt(this.layout.layoutBox.y);h.y.min=c.target.y.min,h.y.max=h.y.min+v}Bn(f,h),Oo(f,y),al(this.projectionDeltaWithTransform,this.layoutCorrected,f,y)}}registerSharedNode(c,f){this.sharedNodes.has(c)||this.sharedNodes.set(c,new d6),this.sharedNodes.get(c).add(f);const m=f.options.initialPromotionConfig;f.promote({transition:m?m.transition:void 0,preserveFollowOpacity:m&&m.shouldPreserveFollowOpacity?m.shouldPreserveFollowOpacity(f):void 0})}isLead(){const c=this.getStack();return c?c.lead===this:!0}getLead(){const{layoutId:c}=this.options;return c?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:c}=this.options;return c?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:c}=this.options;if(c)return this.root.sharedNodes.get(c)}promote({needsReset:c,transition:f,preserveFollowOpacity:h}={}){const m=this.getStack();m&&m.promote(this,h),c&&(this.projectionDelta=void 0,this.needsReset=!0),f&&this.setOptions({transition:f})}relegate(){const c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){const{visualElement:c}=this.options;if(!c)return;let f=!1;const{latestValues:h}=c;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(f=!0),!f)return;const m={};h.z&&Lp("z",c,m,this.animationValues);for(let y=0;y<zp.length;y++)Lp(`rotate${zp[y]}`,c,m,this.animationValues),Lp(`skew${zp[y]}`,c,m,this.animationValues);c.render();for(const y in m)c.setStaticValue(y,m[y]),this.animationValues&&(this.animationValues[y]=m[y]);c.scheduleRender()}applyProjectionStyles(c,f){if(!this.instance||this.isSVG)return;if(!this.isVisible){c.visibility="hidden";return}const h=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,c.visibility="",c.opacity="",c.pointerEvents=Nc(f?.pointerEvents)||"",c.transform=h?h(this.latestValues,""):"none";return}const m=this.getLead();if(!this.projectionDelta||!this.layout||!m.target){this.options.layoutId&&(c.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,c.pointerEvents=Nc(f?.pointerEvents)||""),this.hasProjected&&!ms(this.latestValues)&&(c.transform=h?h({},""):"none",this.hasProjected=!1);return}c.visibility="";const y=m.animationValues||m.latestValues;this.applyTransformsToTarget();let g=h6(this.projectionDeltaWithTransform,this.treeScale,y);h&&(g=h(y,g)),c.transform=g;const{x:v,y:S}=this.projectionDelta;c.transformOrigin=`${v.origin*100}% ${S.origin*100}% 0`,m.animationValues?c.opacity=m===this?y.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:y.opacityExit:c.opacity=m===this?y.opacity!==void 0?y.opacity:"":y.opacityExit!==void 0?y.opacityExit:0;for(const x in Tl){if(y[x]===void 0)continue;const{correct:T,applyTo:M,isCSSVariable:C}=Tl[x],_=g==="none"?y[x]:T(y[x],m);if(M){const R=M.length;for(let G=0;G<R;G++)c[M[G]]=_}else C?this.options.visualElement.renderState.vars[x]=_:c[x]=_}this.options.layoutId&&(c.pointerEvents=m===this?Nc(f?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(c=>c.currentAnimation?.stop()),this.root.nodes.forEach(_x),this.root.sharedNodes.clear()}}}function y6(t){t.updateLayout()}function g6(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:a}=t.options,u=e.source!==t.layout.source;a==="size"?Ln(y=>{const g=u?e.measuredBox[y]:e.layoutBox[y],v=Wt(g);g.min=n[y].min,g.max=g.min+v}):J_(a,e.layoutBox,n)&&Ln(y=>{const g=u?e.measuredBox[y]:e.layoutBox[y],v=Wt(n[y]);g.max=g.min+v,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[y].max=t.relativeTarget[y].min+v)});const c=_o();al(c,n,e.layoutBox);const f=_o();u?al(f,t.applyTransform(r,!0),e.measuredBox):al(f,n,e.layoutBox);const h=!H_(c);let m=!1;if(!t.resumeFrom){const y=t.getClosestProjectingParent();if(y&&!y.resumeFrom){const{snapshot:g,layout:v}=y;if(g&&v){const S=yt();ll(S,e.layoutBox,g.layoutBox);const x=yt();ll(x,n,v.layoutBox),F_(S,x)||(m=!0),y.options.layoutRoot&&(t.relativeTarget=x,t.relativeTargetOrigin=S,t.relativeParent=y)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:f,layoutDelta:c,hasLayoutChanged:h,hasRelativeLayoutChanged:m})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function b6(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function v6(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function S6(t){t.clearSnapshot()}function _x(t){t.clearMeasurements()}function Rx(t){t.isLayoutDirty=!1}function w6(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Cx(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function x6(t){t.resolveTargetDelta()}function T6(t){t.calcProjection()}function A6(t){t.resetSkewAndRotation()}function E6(t){t.removeLeadSnapshot()}function kx(t,e,n){t.translate=rt(e.translate,0,n),t.scale=rt(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Mx(t,e,n,r){t.min=rt(e.min,n.min,r),t.max=rt(e.max,n.max,r)}function O6(t,e,n,r){Mx(t.x,e.x,n.x,r),Mx(t.y,e.y,n.y,r)}function _6(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const R6={duration:.45,ease:[.4,0,.1,1]},Dx=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Nx=Dx("applewebkit/")&&!Dx("chrome/")?Math.round:Pn;function $x(t){t.min=Nx(t.min),t.max=Nx(t.max)}function C6(t){$x(t.x),$x(t.y)}function J_(t,e,n){return t==="position"||t==="preserve-aspect"&&!jq(Ex(e),Ex(n),.2)}function k6(t){return t!==t.root&&t.scroll?.wasRoot}const M6=Y_({attachResizeListener:(t,e)=>Al(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Vp={current:void 0},X_=Y_({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Vp.current){const t=new M6({});t.mount(window),t.setOptions({layoutScroll:!0}),Vp.current=t}return Vp.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),D6={pan:{Feature:Xq},drag:{Feature:Jq,ProjectionNode:X_,MeasureLayout:q_}};function jx(t,e,n){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,u=r[a];u&&it.postRender(()=>u(e,Ul(e)))}class N6 extends Gr{mount(){const{current:e}=this.node;e&&(this.unmount=sK(e,(n,r)=>(jx(this.node,r,"Start"),a=>jx(this.node,a,"End"))))}unmount(){}}class $6 extends Gr{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=zl(Al(this.node.current,"focus",()=>this.onFocus()),Al(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Bx(t,e,n){const{props:r}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),u=r[a];u&&it.postRender(()=>u(e,Ul(e)))}class j6 extends Gr{mount(){const{current:e}=this.node;e&&(this.unmount=uK(e,(n,r)=>(Bx(this.node,r,"Start"),(a,{success:u})=>Bx(this.node,a,u?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Gm=new WeakMap,Up=new WeakMap,B6=t=>{const e=Gm.get(t.target);e&&e(t)},z6=t=>{t.forEach(B6)};function L6({root:t,...e}){const n=t||document;Up.has(n)||Up.set(n,{});const r=Up.get(n),a=JSON.stringify(e);return r[a]||(r[a]=new IntersectionObserver(z6,{root:t,...e})),r[a]}function V6(t,e,n){const r=L6(e);return Gm.set(t,n),r.observe(t),()=>{Gm.delete(t),r.unobserve(t)}}const U6={some:0,all:1};class K6 extends Gr{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:r,amount:a="some",once:u}=e,c={root:n?n.current:void 0,rootMargin:r,threshold:typeof a=="number"?a:U6[a]},f=h=>{const{isIntersecting:m}=h;if(this.isInView===m||(this.isInView=m,u&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:y,onViewportLeave:g}=this.node.getProps(),v=m?y:g;v&&v(h)};return V6(this.node.current,c,f)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(q6(e,n))&&this.startObserver()}unmount(){}}function q6({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const P6={inView:{Feature:K6},tap:{Feature:j6},focus:{Feature:$6},hover:{Feature:N6}},I6={layout:{ProjectionNode:X_,MeasureLayout:q_}},H6={...Cq,...P6,...D6,...I6},F6=HK(H6,rq);function G6(){const t=Wn(Po),e=Wn(di),n=Wn(Hi),r=Et(Po),a=Et(di),u=Et(Hi),c=`email-${$.useId()}`,f=`password-${$.useId()}`,h=`one-time-code-${$.useId()}`,[m,y]=$.useState(null),[g,v]=$.useState("email"),S=`form-${$.useId()}`;return $.useEffect(()=>{if(u.length===6){const x=document.getElementById(S);x instanceof HTMLFormElement&&x.requestSubmit()}},[u]),F.jsx("form",{id:S,onSubmit:async x=>{x.preventDefault();const T=nt(ui);try{switch(g){case"email":{const{nextStep:M,userKey:C}=await cn.declareAuthTarget.query({email:r});switch(De(ui,C),M){case"otc_login":case"otc_verify":{v("otc");break}case"password_login":{v("password");break}}break}case"otc":{if(!T){console.error("somehow userKey is null");return}const M=await cn.verifyAccountAction.mutate({oneTimeCode:u,userKey:T});De(ut,M),gi.once("connect",()=>{Os("/game"),t(""),n("")});break}case"password":{const M=await cn.openSession.mutate({email:r,password:a});De(ut,M),gi.once("connect",()=>{Os("/game"),t(""),e("")});break}}}catch(M){M instanceof bl&&y(M.message)}},children:F.jsxs("main",{children:[m?F.jsx("aside",{children:m}):null,F.jsxs(F6.label,{htmlFor:c,children:[F.jsx("span",{children:"Email"}),F.jsx("input",{id:c,type:"text",value:r,onChange:x=>{t(x.target.value)},autoComplete:"email",autoCapitalize:"none",disabled:g!=="email"})]}),g==="password"?F.jsxs("label",{htmlFor:f,children:[F.jsx("span",{children:"Password"}),F.jsx("input",{id:f,type:"password",value:a,onChange:x=>{e(x.target.value)},autoComplete:"current-password",autoCapitalize:"none",autoFocus:g==="password"})]}):null,g==="otc"?F.jsxs("label",{htmlFor:h,children:[F.jsx("span",{children:"One-time Code"}),F.jsx("input",{id:h,type:"number",inputMode:"numeric",enterKeyHint:"go",value:u,onChange:x=>{n(x.target.value)},autoComplete:"one-time-code",autoCapitalize:"none",autoFocus:g==="otc"})]}):null,F.jsxs("footer",{children:[g==="password"?F.jsx("button",{type:"button",onClick:async()=>{const x=nt(ui);if(!x)return new Error("No userKey");await cn.startPasswordReset.mutate({userKey:x}),v("otc")},children:"Forgot Password?"}):null,F.jsx("span",{}),F.jsx("button",{type:"submit",disabled:!r&&g==="email"||!a&&g==="password"||!u&&g==="otc",children:">>->"})]})]})})}function Y6({route:[,t]}){const e=Et(ut),n=Et(Hi),r=Wn(Hi),a=`code-${$.useId()}`;return $.useEffect(()=>{t&&r(t)},[]),e?F.jsx("form",{onSubmit:async u=>{u.preventDefault();try{const c=await cn.verifyAccountAction.mutate({oneTimeCode:n,userKey:"CHANGEME"});De(ut,c),c.action==="resetPassword"?Os("/account"):Os("/game")}catch(c){console.error(c)}},children:F.jsxs("main",{children:[F.jsx("p",{children:"Check your email for a verification code."}),F.jsxs("label",{htmlFor:a,children:[F.jsx("span",{children:"Verification code"}),F.jsx("input",{id:a,type:"text",value:n,onChange:u=>{r(u.target.value)},placeholder:"Verification code",autoComplete:"one-time-code",autoCapitalize:"none"})]})]})}):F.jsx("p",{children:"You must be logged in to verify your account."})}function J6(){const t=Et(r4),e=Et(ut),[n,r]=$.useState(!1),{refs:a,floatingStyles:u,context:c}=K2({open:n,onOpenChange:r,placement:"bottom-end",middleware:[d2(5),p2(),h2()],whileElementsMounted:r2}),f=B2(c),h=V2(c),m=I2(c),{getReferenceProps:y,getFloatingProps:g}=q2([f,h,m]),v=Et(FL);return F.jsxs("main",{className:Bz.class,children:[F.jsxs("header",{children:[F.jsxs("main",{children:[F.jsx(jz,{}),F.jsx("span",{children:F.jsx(zz,{input:v})})]}),F.jsx("button",{"data-css":"profile",ref:a.setReference,...y(),children:e?.username?e.username.slice(0,2):""}),n&&e&&F.jsx($2,{context:c,modal:!1,children:F.jsxs("div",{"data-css":"profile-actions",ref:a.setFloating,style:u,...g(),children:[F.jsx("span",{children:e.username}),F.jsx("button",{type:"button",onClick:()=>{Os("/account")},children:"Account"}),F.jsx("button",{type:"button",onClick:async()=>{e&&(await cn.closeSession.mutate({username:e.username}),gi.once("disconnect",()=>{De(ut,null),Os("/")}),gi.disconnect())},children:"Sign out"})]})})]}),F.jsx("main",{children:typeof t=="number"?F.jsxs("article",{children:[F.jsx("h1",{children:t}),F.jsx("h2",{children:JSON.parse(jE[t])}),F.jsx(BE,{href:"/",children:"Return to Home Page"})]}):(()=>{switch(t[0]){case void 0:return F.jsx(G6,{});case"admin":return F.jsx(u4,{});case"game":return F.jsx(f4,{route:t});case"verify":return F.jsx(Y6,{route:t});case"account":return F.jsx(l4,{})}})()})]})}LM.createRoot(document.getElementById("root")).render(F.jsx($.StrictMode,{children:F.jsx(CM,{socket:gi,children:F.jsx(J6,{})})}));
|
|
66
|
+
fn("string", ":", "number")(s => s.length)`;class q3 extends Hr{$;constructor(e){super((...n)=>new fc(e)(...n),{bind:e}),this.$=e}in(e){return new fc(this.$,e===void 0?void 0:this.$.parse(e))}at(e,n){return new fc(this.$).at(e,n)}case(e,n){return new fc(this.$).case(e,n)}}class fc extends Hr{$;in;key;branches=[];constructor(e,n){super(r=>this.caseEntries(Object.entries(r).map(([a,u])=>a==="default"?[a,u]:[this.$.parse(a),u]))),this.$=e,this.in=n}at(e,n){return this.key&&Y(I3),this.branches.length&&Y(P3),this.key=e,n?this.match(n):this}case(e,n){return this.caseEntry(this.$.parse(e),n)}caseEntry(e,n){const a=(this.key?this.$.parse({[this.key]:e}):e).pipe(n);return this.branches.push(a),this}match(e){return this(e)}strings(e){return this.caseEntries(Object.entries(e).map(([n,r])=>n==="default"?[n,r]:[this.$.node("unit",{unit:n}),r]))}caseEntries(e){for(let n=0;n<e.length;n++){const[r,a]=e[n];if(r==="default")return n!==e.length-1&&Y("default may only be specified as the last key of a switch definition"),this.default(a);if(typeof a!="function")return Y(`Value for case "${r}" must be a function (was ${ti(a)})`);this.caseEntry(r,a)}return this}default(e){typeof e=="function"&&this.case(me.unknown,e);const n={branches:this.branches,ordered:!0};(e==="never"||e==="assert")&&(n.meta={onFail:Jw});const r=this.$.node("union",n);if(!this.in)return this.$.finalize(r);let a=this.in.pipe(r);return(e==="never"||e==="assert")&&(a=a.configureReferences({onFail:Jw},"self")),this.$.finalize(a)}}const Jw=t=>t.throw(),P3="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",I3="At most one key matcher may be specified per expression",TE=(t,e)=>{if(Xt(t)){if(t[1]==="=")return[e.$.parseOwnDefinitionFormat(t[0],e),"=",t[2]];if(t[1]==="?")return[e.$.parseOwnDefinitionFormat(t[0],e),"?"]}return kE(t,e)},H3="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",F3="Only required keys may specify default values, e.g. { value: 'number = 0' }",G3=(t,e)=>{let n;const r={},a=Fc(t);for(const[c,f]of a){const h=X3(c);if(h.kind==="spread"){if(!Rl(r))return Y(J3);const S=e.$.parseOwnDefinitionFormat(f,e);if(S.equals(me.object))continue;if(!S.hasKind("intersection")||!S.basis?.equals(me.object))return Y(Z3(S.expression));n=S.structure;continue}if(h.kind==="undeclared"){f!=="reject"&&f!=="delete"&&f!=="ignore"&&Y(Y3(f)),r.undeclared=f;continue}const m=TE(f,e),y=h;if(h.kind==="required"){Xt(m)?mp(r,"optional",m[1]==="="?{key:h.normalized,value:m[0],default:m[2]}:{key:h.normalized,value:m[0]},e):mp(r,"required",{key:h.normalized,value:m},e);continue}if(Xt(m)&&(m[1]==="?"&&Y(H3),m[1]==="="&&Y(F3)),h.kind==="optional"){mp(r,"optional",{key:h.normalized,value:m},e);continue}const g=e.$.parseOwnDefinitionFormat(y.normalized,e),v=fm(g,m,e.$);v.index&&(r.index=Fe(r.index,v.index)),v.required&&(r.required=Fe(r.required,v.required))}const u=e.$.node("structure",r);return e.$.parseSchema({domain:"object",structure:n?.merge(u)??u})},mp=(t,e,n,r)=>{t[e]=Fe(t[e],r.$.node(e,n))},Y3=t=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${Ie(t)})`,J3="Spread operator may only be used as the first key in an object",X3=t=>typeof t=="symbol"?{kind:"required",normalized:t}:t[t.length-1]==="?"?t[t.length-2]===tl?{kind:"required",normalized:`${t.slice(0,-2)}?`}:{kind:"optional",normalized:t.slice(0,-1)}:t[0]==="["&&t[t.length-1]==="]"?{kind:"index",normalized:t.slice(1,-1)}:t[0]===tl&&t[1]==="["&&t[t.length-1]==="]"?{kind:"required",normalized:t.slice(1)}:t==="..."?{kind:"spread"}:t==="+"?{kind:"undeclared"}:{kind:"required",normalized:t==="\\..."?"...":t==="\\+"?"+":t},Z3=t=>`Spread operand must resolve to an object literal type (was ${t})`,Q3=(t,e)=>lB(t)?_E[t[0]](t,e):oB(t)?OE[t[1]](t,e):null,W3=(t,e)=>e.$.parseOwnDefinitionFormat(t[1],e).keyof(),yp=(t,e)=>{if(t[2]===void 0)return Y(vE(t[1],""));const n=e.$.parseOwnDefinitionFormat(t[0],e),r=e.$.parseOwnDefinitionFormat(t[2],e);if(t[1]==="|")return e.$.node("union",{branches:[n,r]});const a=t[1]==="&"?Xi(n,r,e.$):lm(n,r,e.$);return a instanceof ae?a.throw():a},eB=(t,e)=>e.$.parseOwnDefinitionFormat(t[0],e).array(),tB=(t,e)=>typeof t[2]!="function"?Y(AE("=>",t[2])):e.$.parseOwnDefinitionFormat(t[0],e).pipe(t[2]),AE=(t,e)=>`${t===":"?"Narrow":"Morph"} expression requires a function following '${t}' (was ${typeof e})`,nB=(t,e)=>typeof t[2]!="function"?Y(AE(":",t[2])):e.$.parseOwnDefinitionFormat(t[0],e).constrain("predicate",t[2]),iB=(t,e)=>e.$.parseOwnDefinitionFormat(t[0],e).configure(t[2],t[3]),EE=t=>t,rB=EE({"[]":eB,"?":()=>Y(pE)}),sB=EE({"|":yp,"&":yp,":":nB,"=>":tB,"|>":yp,"@":iB,"=":()=>Y(mE)}),OE={...rB,...sB},oB=t=>OE[t[1]]!==void 0,aB=t=>t,_E=aB({keyof:W3,instanceof:(t,e)=>{if(typeof t[1]!="function")return Y(Xw(tm(t[1])));const n=t.slice(1).map(r=>typeof r=="function"?e.$.node("proto",{proto:r}):Y(Xw(tm(r))));return n.length===1?n[0]:e.$.node("union",{branches:n})},"===":(t,e)=>e.$.units(t.slice(1))}),lB=t=>_E[t[0]]!==void 0,Xw=t=>`Expected a constructor following 'instanceof' operator (was ${t})`,uB=(t,e)=>{let n=[{}],r=0;for(;r<t.length;){let a=!1;t[r]==="..."&&r<t.length-1&&(a=!0,r++);const u=TE(t[r],e),[c,f,h]=Xt(u)?u:[u];if(r++,a){if(!c.extends(W.intrinsic.Array))return Y(dB(c.expression));n=n.flatMap(m=>c.distribute(y=>fB(dA(m),y)))}else n=n.map(m=>f==="?"?RE(m,c):f==="="?cB(m,c,h):ym(m,c))}return e.$.parseSchema(n.map(a=>Rl(a)?{proto:Array,exactLength:0}:{proto:Array,sequence:a}))},ym=(t,e)=>t.defaultables||t.optionals?Y(t.variadic?JA:hB):(t.variadic?t.postfix=Fe(t.postfix,e):t.prefix=Fe(t.prefix,e),t),RE=(t,e)=>t.variadic?Y(CE):(t.optionals=Fe(t.optionals,e),t),cB=(t,e,n)=>t.variadic?Y(CE):t.optionals?Y(pB):(t.defaultables=Fe(t.defaultables,[[e,n]]),t),Zw=(t,e)=>(t.postfix&&Y(Qw),t.variadic?t.variadic.equals(e)||Y(Qw):t.variadic=e.internal,t),fB=(t,e)=>{const n=e.select({method:"find",kind:"sequence"});if(!n)return Zw(t,W.intrinsic.unknown);if(n.prefix)for(const r of n.prefix)ym(t,r);if(n.optionals)for(const r of n.optionals)RE(t,r);if(n.variadic&&Zw(t,n.variadic),n.postfix)for(const r of n.postfix)ym(t,r);return t},dB=t=>`Spread element must be an array (was ${t})`,Qw="A tuple may have at most one variadic element",hB="A required element may not follow an optional element",CE="An optional element may not follow a variadic element",pB="A defaultable element may not follow an optional element without a default",mB={},kE=(t,e)=>{if(typeof t=="string"){if(e.args&&Object.keys(e.args).some(r=>t.includes(r)))return Gw(t,e);const n=mB[e.$.name]??={};return n[t]??=Gw(t,e)}return Cs(t,"object")?yB(t,e):Y(gm(ti(t)))},yB=(t,e)=>{const n=xy(t);switch(n){case void 0:return fe(t,"root")?t:G3(t,e);case"Array":return gB(t,e);case"RegExp":return e.$.node("intersection",{domain:"string",pattern:t},{prereduced:!0});case"Function":{const r=Sf(t)?t():t;return fe(r,"root")?r:Y(gm("Function"))}default:return Y(gm(n??Ie(t)))}},gB=(t,e)=>Q3(t,e)??uB(t,e),gm=t=>`Type definitions must be strings or objects (was ${t})`;class bB extends Hr{constructor(e){const n=Object.assign({errors:Lr,hkt:Si,$:e,raw:e.parse,module:e.constructor.module,scope:e.constructor.scope,declare:e.declare,define:e.define,match:e.match,generic:e.generic,schema:e.schema,keywords:e.ambient,unit:e.unit,enumerated:e.enumerated,instanceOf:e.instanceOf,valueOf:e.valueOf,or:e.or,and:e.and,merge:e.merge,pipe:e.pipe,fn:e.fn},e.ambientAttachments);super((...r)=>{if(r.length===1)return e.parse(r[0]);if(r.length===2&&typeof r[0]=="string"&&r[0][0]==="<"&&r[0][r[0].length-1]===">"){const a=r[0].slice(1,-1),u=e.parseGenericParams(a,{});return new Qc(u,r[1],e,e,null)}return e.parse(r)},{attach:n})}}const yl=W;class Rf extends nE{get ambientAttachments(){if(yl.typeAttachments)return this.cacheGetter("ambientAttachments",Ge(yl.typeAttachments,(e,n)=>[e,this.bindReference(n)]))}preparseOwnAliasEntry(e,n){const r=e.indexOf("<");if(r===-1){if(fe(n,"module")||fe(n,"generic"))return[e,n];const c=this.name==="ark"?e:e==="root"?this.name:`${this.name}.${e}`,f=this.resolvedConfig.keywords?.[c];return f&&(n=[n,"@",f]),[e,n]}e[e.length-1]!==">"&&Y("'>' must be the last character of a generic declaration in a scope");const a=e.slice(0,r),u=e.slice(r+1,-1);return[a,()=>{const c=this.parseGenericParams(u,{alias:a});return u$(c,n,this)}]}parseGenericParams(e,n){return mm(new oA(e),[],this.createParseContext({...n,def:e,prefix:"generic"}))}normalizeRootScopeValue(e){return Sf(e)&&!fe(e,"generic")?e():e}preparseOwnDefinitionFormat(e,n){return{...n,def:e,prefix:n.alias??"type"}}parseOwnDefinitionFormat(e,n){!(n.alias&&n.alias in this.aliases)&&!n.args&&(n.args={this:n.id});const a=kE(e,n);if(Xt(a)){if(a[1]==="=")return Y(mE);if(a[1]==="?")return Y(pE)}return a}unit=e=>this.units([e]);valueOf=e=>this.units(rN(e));enumerated=(...e)=>this.units(e);instanceOf=e=>this.node("proto",{proto:e},{prereduced:!0});or=(...e)=>this.schema(e.map(n=>this.parse(n)));and=(...e)=>e.reduce((n,r)=>n.and(this.parse(r)),this.intrinsic.unknown);merge=(...e)=>e.reduce((n,r)=>n.merge(this.parse(r)),this.intrinsic.object);pipe=(...e)=>this.intrinsic.unknown.pipe(...e);fn=new V3(this);match=new q3(this);declare=()=>({type:this.type});define(e){return e}type=new bB(this);static scope=((e,n={})=>new Rf(e,n));static module=((e,n={})=>this.scope(e,n).export())}const vB=Object.assign(Rf.scope,{define:t=>t}),ze=Rf;class SB extends Si{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}const wB=er(["base",me.object],["props",me.object])(t=>t.base.merge(t.props),SB),xB=ze.module({Key:me.key,Merge:wB});class TB extends Si{}const AB=er("element")(t=>{const e=t.element.exclude(me.Array),n=e.array();return e.rawOr(n).pipe(_l).distribute(r=>r.assertHasKind("morph").declareOut(n),Ye)},TB),EB=ze.module({root:me.Array,readonly:"root",index:me.nonNegativeIntegerString,liftFrom:AB},{name:"Array"}),bm=Ye(["string",Cl.FileConstructor]),OB=bm.rawOr(bm.array()),Ww=Ye({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:OB}}),_B=ze.module({root:["instanceof",FormData],value:bm,parsed:Ww,parse:Ye({in:FormData,morphs:t=>{const e={};for(const[n,r]of t)if(n in e){const a=e[n];typeof a=="string"||a instanceof Cl.FileConstructor?e[n]=[a,r]:a.push(r)}else e[n]=r;return e},declaredOut:Ww})},{name:"FormData"}),RB=ze.module({Int8:["instanceof",Int8Array],Uint8:["instanceof",Uint8Array],Uint8Clamped:["instanceof",Uint8ClampedArray],Int16:["instanceof",Int16Array],Uint16:["instanceof",Uint16Array],Int32:["instanceof",Int32Array],Uint32:["instanceof",Uint32Array],Float32:["instanceof",Float32Array],Float64:["instanceof",Float64Array],BigInt64:["instanceof",BigInt64Array],BigUint64:["instanceof",BigUint64Array]},{name:"TypedArray"}),CB={Boolean:1,Number:1,String:1},kB=ze.module({...Ge({...JT,...ZT},(t,e)=>t in CB?[]:[t,["instanceof",e]]),Array:EB,TypedArray:RB,FormData:_B}),MB=Ye({domain:{domain:"number",meta:"a number representing a Unix timestamp"},divisor:{rule:1,meta:"an integer representing a Unix timestamp"},min:{rule:-864e13,meta:"a Unix timestamp after -8640000000000000"},max:{rule:864e13,meta:"a Unix timestamp before 8640000000000000"},meta:"an integer representing a safe Unix timestamp"}),DB=Ye({domain:"number",divisor:1}),ME=ze.module({root:me.number,integer:DB,epoch:MB,safe:Ye({domain:{domain:"number",numberAllowsNaN:!1},min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}),NaN:["===",Number.NaN],Infinity:["===",Number.POSITIVE_INFINITY],NegativeInfinity:["===",Number.NEGATIVE_INFINITY]},{name:"number"}),et=(t,e,n)=>{const r={domain:"string",pattern:{rule:t.source,flags:t.flags,meta:e}};return n&&(r.meta={format:n}),By("intersection",r)},ex=et(Gc,"a well-formed integer string"),DE=ze.module({root:ex,parse:Ye({in:ex,morphs:(t,e)=>{const n=Number.parseInt(t);return Number.isSafeInteger(n)?n:e.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:me.integer})},{name:"string.integer"}),NB=et(/^[\dA-Fa-f]+$/,"hex characters only"),$B=ze.module({root:et(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:et(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),tx=et(/^[A-Z].*$/,"capitalized"),jB=ze.module({root:Ye({in:"string",morphs:t=>t.charAt(0).toUpperCase()+t.slice(1),declaredOut:tx}),preformatted:tx},{name:"string.capitalize"}),BB=t=>{const e=t.replace(/[ -]+/g,"");let n=0,r,a,u=!1;for(let c=e.length-1;c>=0;c--)r=e.substring(c,c+1),a=Number.parseInt(r,10),u?(a*=2,n+=a>=10?a%10+1:a):n+=a,u=!u;return!!(n%10===0&&e)},zB=/^(?:4\d{12}(?:\d{3,6})?|5[1-5]\d{14}|(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}|6(?:011|5\d\d)\d{12,15}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|(?:2131|1800|35\d{3})\d{11}|6[27]\d{14}|^(81\d{14,17}))$/,LB=Ye({domain:"string",pattern:{meta:"a credit card number",rule:zB.source},predicate:{meta:"a credit card number",predicate:BB}}),VB=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([,.]\d+(?!:))?)?(\17[0-5]\d([,.]\d+)?)?([Zz]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,UB=t=>!Number.isNaN(new Date(t).valueOf()),nx=Ye({domain:"string",predicate:{meta:"a parsable date",predicate:UB}}).assertHasKind("intersection"),ix=DE.root.internal.narrow((t,e)=>{const n=Number.parseInt(t),r=ME.epoch(n);return r instanceof Lr?(e.errors.merge(r),!1):!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),KB=ze.module({root:ix,parse:Ye({in:ix,morphs:t=>new Date(t),declaredOut:me.Date})},{name:"string.date.epoch"}),rx=et(VB,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),qB=ze.module({root:rx,parse:Ye({in:rx,morphs:t=>new Date(t),declaredOut:me.Date})},{name:"string.date.iso"}),PB=ze.module({root:nx,parse:Ye({declaredIn:nx,in:"string",morphs:(t,e)=>{const n=new Date(t);return Number.isNaN(n.valueOf())?e.error("a parsable date"):n},declaredOut:me.Date}),iso:qB,epoch:KB},{name:"string.date"}),IB=et(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),sx="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",Or=`(${sx}[.]){3}${sx}`,HB=new RegExp(`^${Or}$`),Tt="(?:[0-9a-fA-F]{1,4})",FB=new RegExp(`^((?:${Tt}:){7}(?:${Tt}|:)|(?:${Tt}:){6}(?:${Or}|:${Tt}|:)|(?:${Tt}:){5}(?::${Or}|(:${Tt}){1,2}|:)|(?:${Tt}:){4}(?:(:${Tt}){0,1}:${Or}|(:${Tt}){1,3}|:)|(?:${Tt}:){3}(?:(:${Tt}){0,2}:${Or}|(:${Tt}){1,4}|:)|(?:${Tt}:){2}(?:(:${Tt}){0,3}:${Or}|(:${Tt}){1,5}|:)|(?:${Tt}:){1}(?:(:${Tt}){0,4}:${Or}|(:${Tt}){1,6}|:)|(?::((?::${Tt}){0,5}:${Or}|(?::${Tt}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),GB=ze.module({root:["v4 | v6","@","an IP address"],v4:et(HB,"an IPv4 address","ipv4"),v6:et(FB,"an IPv6 address","ipv6")},{name:"string.ip"}),Do="a JSON string",NE=t=>{if(!(t instanceof SyntaxError))throw t;return`must be ${Do} (${t})`},YB=Ye({meta:Do,domain:"string",predicate:{meta:Do,predicate:(t,e)=>{try{return JSON.parse(t),!0}catch(n){return e.reject({code:"predicate",expected:Do,problem:NE(n)})}}}}),JB=(t,e)=>{if(t.length===0)return e.error({code:"predicate",expected:Do,actual:"empty"});try{return JSON.parse(t)}catch(n){return e.error({code:"predicate",expected:Do,problem:NE(n)})}},XB=ze.module({root:YB,parse:Ye({meta:"safe JSON string parser",in:"string",morphs:JB,declaredOut:me.jsonObject})},{name:"string.json"}),ox=et(/^[a-z]*$/,"only lowercase letters"),ZB=ze.module({root:Ye({in:"string",morphs:t=>t.toLowerCase(),declaredOut:ox}),preformatted:ox},{name:"string.lower"}),$E=["NFC","NFD","NFKC","NFKD"],jl=Ge($E,(t,e)=>[e,Ye({domain:"string",predicate:n=>n.normalize(e)===n,meta:`${e}-normalized unicode`})]),Cf=Ge($E,(t,e)=>[e,Ye({in:"string",morphs:n=>n.normalize(e),declaredOut:jl[e]})]),QB=ze.module({root:Cf.NFC,preformatted:jl.NFC},{name:"string.normalize.NFC"}),WB=ze.module({root:Cf.NFD,preformatted:jl.NFD},{name:"string.normalize.NFD"}),ez=ze.module({root:Cf.NFKC,preformatted:jl.NFKC},{name:"string.normalize.NFKC"}),tz=ze.module({root:Cf.NFKD,preformatted:jl.NFKD},{name:"string.normalize.NFKD"}),nz=ze.module({root:"NFC",NFC:QB,NFD:WB,NFKC:ez,NFKD:tz},{name:"string.normalize"}),ax=et(nm,"a well-formed numeric string"),iz=ze.module({root:ax,parse:Ye({in:ax,morphs:t=>Number.parseFloat(t),declaredOut:me.number})},{name:"string.numeric"}),lx="a regex pattern",rz=Ye({domain:"string",predicate:{meta:lx,predicate:(t,e)=>{try{return new RegExp(t),!0}catch(n){return e.reject({code:"predicate",expected:lx,problem:String(n)})}}},meta:{format:"regex"}}),sz=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/,oz=et(sz,"a semantic version (see https://semver.org/)"),ux=et(/^\S.*\S$|^\S?$/,"trimmed"),az=ze.module({root:Ye({in:"string",morphs:t=>t.trim(),declaredOut:ux}),preformatted:ux},{name:"string.trim"}),cx=et(/^[A-Z]*$/,"only uppercase letters"),lz=ze.module({root:Ye({in:"string",morphs:t=>t.toUpperCase(),declaredOut:cx}),preformatted:cx},{name:"string.upper"}),uz=t=>URL.canParse(t),fx=Ye({domain:"string",predicate:{meta:"a URL string",predicate:uz},meta:{format:"uri"}}),cz=ze.module({root:fx,parse:Ye({declaredIn:fx,in:"string",morphs:(t,e)=>{try{return new URL(t)}catch{return e.error("a URL string")}},declaredOut:Ye(URL)})},{name:"string.url"}),fz=ze.module({root:["versioned | nil | max","@",{description:"a UUID",format:"uuid"}],"#nil":"'00000000-0000-0000-0000-000000000000'","#max":"'ffffffff-ffff-ffff-ffff-ffffffffffff'","#versioned":/[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}/i,v1:et(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:et(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:et(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:et(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:et(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:et(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:et(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:et(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),dz=ze.module({root:me.string,alpha:et(/^[A-Za-z]*$/,"only letters"),alphanumeric:et(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:NB,base64:$B,capitalize:jB,creditCard:LB,date:PB,digits:et(/^\d*$/,"only digits 0-9"),email:IB,integer:DE,ip:GB,json:XB,lower:ZB,normalize:nz,numeric:iz,regex:rz,semver:oz,trim:az,upper:lz,url:cz,uuid:fz},{name:"string"}),hz=ze.module({bigint:me.bigint,boolean:me.boolean,false:me.false,never:me.never,null:me.null,number:me.number,object:me.object,string:me.string,symbol:me.symbol,true:me.true,unknown:me.unknown,undefined:me.undefined}),pz=ze.module({root:me.unknown,any:me.unknown},{name:"unknown"}),mz=ze.module({root:me.jsonObject,stringify:By("morph",{in:me.jsonObject,morphs:t=>JSON.stringify(t),declaredOut:me.string})},{name:"object.json"}),yz=ze.module({root:me.object,json:mz},{name:"object"});class gz extends Si{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}const bz=er(["K",me.key],"V")(t=>({domain:"object",index:{signature:t.K,value:t.V}}),gz);class vz extends Si{description='pick a set of properties from an object like `Pick(User, "name | age")`'}const Sz=er(["T",me.object],["K",me.key])(t=>t.T.pick(t.K),vz);class wz extends Si{description='omit a set of properties from an object like `Omit(User, "age")`'}const xz=er(["T",me.object],["K",me.key])(t=>t.T.omit(t.K),wz);class Tz extends Si{description="make all named properties of an object optional like `Partial(User)`"}const Az=er(["T",me.object])(t=>t.T.partial(),Tz);class Ez extends Si{description="make all named properties of an object required like `Required(User)`"}const Oz=er(["T",me.object])(t=>t.T.required(),Ez);class _z extends Si{description='exclude branches of a union like `Exclude("boolean", "true")`'}const Rz=er("T","U")(t=>t.T.exclude(t.U),_z);class Cz extends Si{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}const kz=er("T","U")(t=>t.T.extract(t.U),Cz),Mz=ze.module({Exclude:Rz,Extract:kz,Omit:xz,Partial:Az,Pick:Sz,Record:bz,Required:Oz}),Fr=vB({...hz,...Mz,...kB,...xB,string:dz,number:ME,object:yz,unknown:pz},{prereducedAliases:!0,name:"ark"}),jt=Fr.export();Object.assign(yl.ambient,jt);yl.typeAttachments={string:jt.string.root,number:jt.number.root,bigint:jt.bigint,boolean:jt.boolean,symbol:jt.symbol,undefined:jt.undefined,null:jt.null,object:jt.object.root,unknown:jt.unknown.root,false:jt.false,true:jt.true,never:jt.never,arrayIndex:jt.Array.index,Key:jt.Key,Record:jt.Record,Array:jt.Array.root,Date:jt.Date};const Ot=Object.assign(Fr.type,yl.typeAttachments);Fr.match;Fr.fn;Fr.generic;Fr.schema;Fr.define;Fr.declare;const jE={100:'"Continue"',101:'"Switching Protocols"',102:'"Processing"',103:'"Early Hints"',200:'"OK"',201:'"Created"',202:'"Accepted"',203:'"Non-Authoritative Information"',204:'"No Content"',205:'"Reset Content"',206:'"Partial Content"',207:'"Multi-Status"',208:'"Already Reported"',226:'"IM Used"',300:'"Multiple Choices"',301:'"Moved Permanently"',302:'"Found"',303:'"See Other"',304:'"Not Modified"',305:'"Use Proxy"',306:'"Switch Proxy"',307:'"Temporary Redirect"',308:'"Permanent Redirect"',400:'"Bad Request"',401:'"Unauthorized"',402:'"Payment Required"',403:'"Forbidden"',404:'"Not Found"',405:'"Method Not Allowed"',406:'"Not Acceptable"',407:'"Proxy Authentication Required"',408:'"Request Timeout"',409:'"Conflict"',410:'"Gone"',411:'"Length Required"',412:'"Precondition Failed"',413:'"Payload Too Large"',414:'"URI Too Long"',415:'"Unsupported Media Type"',416:'"Range Not Satisfiable"',417:'"Expectation Failed"',418:`"I'm a teapot"`,421:'"Misdirected Request"',422:'"Unprocessable Entity"',423:'"Locked"',424:'"Failed Dependency"',425:'"Too Early"',426:'"Upgrade Required"',428:'"Precondition Required"',429:'"Too Many Requests"',431:'"Request Header Fields Too Large"',451:'"Unavailable For Legal Reasons"',500:'"Internal Server Error"',501:'"Not Implemented"',502:'"Bad Gateway"',503:'"Service Unavailable"',504:'"Gateway Timeout"',505:'"HTTP Version Not Supported"',506:'"Variant Also Negotiates"',507:'"Insufficient Storage"',508:'"Loop Detected"',510:'"Not Extended"',511:'"Network Authentication Required"'};function Dz(t){return Number.parseInt(t,10)}const Nz=Ot(jE),$z=Nz.keyof().pipe(t=>Dz(t));Ot([$z,"string"]);function jz(t){return F.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 500 101",...t,children:[F.jsx("title",{children:"Tempest Games Logo"}),F.jsx("path",{d:"M155.76.93v59.89h-17.11V7.78h-13.69V.93h30.8Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M202.91,7.86h-13.18v17.03h13.18v6.84h-13.18v22.24h13.18v6.84h-30.29V.93h30.29v6.93Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M289.49.93v59.89h-17.11V7.78h-.43c-8.21,0-11.21,5.82-11.21,17.03v36.02h-16.25V24.8c0-11.21-2.99-17.03-11.21-17.03h-.43v53.04h-17.11V.93h18.74c9.92,0,15.31,4.96,18.14,11.21,2.82-6.25,8.21-11.21,18.14-11.21h18.73Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M352.82,29.68c0,11.72-6.42,19.16-24.55,19.16h-4.53v11.98h-17.11V1.1l46.2-.17v28.75ZM323.73,7.78v34.22h2.48c7.36,0,9.5-4.11,9.5-12.15V7.78h-11.98Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M396.8,7.86h-13.17v17.03h13.17v6.84h-13.17v22.24h13.17v6.84h-30.28V.93h30.28v6.93Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M425.9,12.57v14.03h27.89v16.94c0,12.75-1.71,18.13-16.43,18.13h-14.54c-9.58,0-14.03-2.74-14.03-11.97v-5.99h15.4v5.13c0,4.53.77,5.99,4.62,5.99h1.71c5.05,0,6.16-1.46,6.16-6.84v-14.54h-27.89v-16.68c0-13.52,3.85-16.68,18.82-16.68h12.83c8.81,0,13.17,1.54,13.17,10.78v7.19h-15.4v-6.5c0-3.42-1.03-4.62-4.45-4.62h-1.45c-4.28,0-6.42,1.46-6.42,5.65Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M500,7.78h-13.69v53.04h-17.11V.93h30.8v6.84Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M155.96,93.78v-3.57h-5.58v-7.14h13.39v17.85h-24.76v-28.56h24.76v7.14h-16.96v14.28h9.15Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M224.26,100.92h-8.25v-10.71h-8.25v3.57h4.68v7.14h-12.94v-17.85h16.51v-3.57h-16.51v-7.14h24.76v28.56Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M259.99,72.36h30.57v28.56h-7.81v-21.42h-3.57v21.42h-7.81v-21.42h-3.57v21.42h-7.81v-28.56Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M343.24,83.08v-3.57h-9.14v14.28h16.96v7.14h-24.76v-28.56h24.76v17.85h-13.38v-7.14h5.57Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M394.59,79.5v3.57h16.96v17.85h-24.76v-7.14h16.96v-3.57h-16.96v-17.85h24.76v7.14h-16.96Z",style:{fill:"var(--logo-color)",strokeWidth:0}}),F.jsx("path",{d:"M0,63.42v-20.84h20.83L0,63.42ZM100,.92v32.29h-35.42v8.33h-8.33V14.46h-22.92l1.04,7.29h9.38v19.79h-8.33v-8.33H0V.92h100ZM0,100.92v-26.04l6.25-1.04,25-26.04,1.04,1.05-10.42,18.75-4.16,7.29h13.54l3.13-3.12,8.33-22.92h1.04v41.66h3.12l9.38-8.33v-33.33h1.04l8.33,22.92,3.12,3.12h13.54l-4.17-7.29-10.42-19.8,1.04-1.04,25,27.09,6.25,1.04v26.04H0ZM100,42.59v20.84l-20.83-20.84h20.83Z",style:{fill:"var(--logo-color)",strokeWidth:0}})]})}function BE(t){return F.jsx("a",{...t})}const Bz={class:"_class_1riwg_1"},gp=["⠋","⠙","⠸","⠴","⠦","⠇"];function zz({input:t}){const e=$.useRef(null),[n,r]=$.useState(typeof t=="string"?t:null);return $.useEffect(()=>{let a=!0,u;if(typeof t=="string")r(t);else{let c=0;u=setInterval(()=>{e.current&&(e.current.textContent=gp[c],c=(c+1)%gp.length)},100),t.then(f=>{a&&(clearInterval(u),r(f))})}return()=>{a=!1,u&&clearInterval(u)}},[t]),F.jsx("span",{ref:e,children:n??gp[0]})}var Lz=Object.create,zE=Object.defineProperty,Vz=Object.getOwnPropertyDescriptor,LE=Object.getOwnPropertyNames,Uz=Object.getPrototypeOf,Kz=Object.prototype.hasOwnProperty,wi=(t,e)=>function(){return e||(0,t[LE(t)[0]])((e={exports:{}}).exports,e),e.exports},qz=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(var a=LE(e),u=0,c=a.length,f;u<c;u++)f=a[u],!Kz.call(t,f)&&f!==n&&zE(t,f,{get:(h=>e[h]).bind(null,f),enumerable:!(r=Vz(e,f))||r.enumerable});return t},bt=(t,e,n)=>(n=t!=null?Lz(Uz(t)):{},qz(zE(n,"default",{value:t,enumerable:!0}),t)),VE=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(t,e){function n(r){"@babel/helpers - typeof";return e.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},e.exports.__esModule=!0,e.exports.default=e.exports,n(r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}}),Pz=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(t,e){var n=VE().default;function r(a,u){if(n(a)!="object"||!a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var f=c.call(a,u||"default");if(n(f)!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(u==="string"?String:Number)(a)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),Iz=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(t,e){var n=VE().default,r=Pz();function a(u){var c=r(u,"string");return n(c)=="symbol"?c:c+""}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}}),ks=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(t,e){var n=Iz();function r(a,u,c){return(u=n(u))in a?Object.defineProperty(a,u,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[u]=c,a}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),ni=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(t,e){var n=ks();function r(u,c){var f=Object.keys(u);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(u);c&&(h=h.filter(function(m){return Object.getOwnPropertyDescriptor(u,m).enumerable})),f.push.apply(f,h)}return f}function a(u){for(var c=1;c<arguments.length;c++){var f=arguments[c]!=null?arguments[c]:{};c%2?r(Object(f),!0).forEach(function(h){n(u,h,f[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(f)):r(Object(f)).forEach(function(h){Object.defineProperty(u,h,Object.getOwnPropertyDescriptor(f,h))})}return u}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}});function kf(t){const e={subscribe(n){let r=null,a=!1,u=!1,c=!1;function f(){if(r===null){c=!0;return}u||(u=!0,typeof r=="function"?r():r&&r.unsubscribe())}return r=t({next(h){var m;a||(m=n.next)===null||m===void 0||m.call(n,h)},error(h){var m;a||(a=!0,(m=n.error)===null||m===void 0||m.call(n,h),f())},complete(){var h;a||(a=!0,(h=n.complete)===null||h===void 0||h.call(n),f())}}),c&&f(),{unsubscribe:f}},pipe(...n){return n.reduce(Hz,e)}};return e}function Hz(t,e){return e(t)}function Fz(t){const e=new AbortController;return new Promise((r,a)=>{let u=!1;function c(){u||(u=!0,f.unsubscribe())}e.signal.addEventListener("abort",()=>{a(e.signal.reason)});const f=t.subscribe({next(h){u=!0,r(h),c()},error(h){a(h)},complete(){e.abort(),c()}})})}function Gz(t){return e=>{let n=0,r=null;const a=[];function u(){r||(r=e.subscribe({next(f){for(const m of a){var h;(h=m.next)===null||h===void 0||h.call(m,f)}},error(f){for(const m of a){var h;(h=m.error)===null||h===void 0||h.call(m,f)}},complete(){for(const h of a){var f;(f=h.complete)===null||f===void 0||f.call(h)}}}))}function c(){if(n===0&&r){const f=r;r=null,f.unsubscribe()}}return kf(f=>(n++,a.push(f),u(),{unsubscribe(){n--,c();const h=a.findIndex(m=>m===f);h>-1&&a.splice(h,1)}}))}}function Yz(t){let e=t;const n=[],r=c=>{e!==void 0&&c.next(e),n.push(c)},a=c=>{n.splice(n.indexOf(c),1)},u=kf(c=>(r(c),()=>{a(c)}));return u.next=c=>{if(e!==c){e=c;for(const f of n)f.next(c)}},u.get=()=>e,u}function Jz(t){return kf(e=>{function n(a=0,u=t.op){const c=t.links[a];if(!c)throw new Error("No more links to execute - did you forget to add an ending link?");return c({op:u,next(h){return n(a+1,h)}})}return n().subscribe(e)})}function gl(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}var Xz=Object.create,UE=Object.defineProperty,Zz=Object.getOwnPropertyDescriptor,KE=Object.getOwnPropertyNames,Qz=Object.getPrototypeOf,Wz=Object.prototype.hasOwnProperty,Bl=(t,e)=>function(){return e||(0,t[KE(t)[0]])((e={exports:{}}).exports,e),e.exports},eL=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(var a=KE(e),u=0,c=a.length,f;u<c;u++)f=a[u],!Wz.call(t,f)&&f!==n&&UE(t,f,{get:(h=>e[h]).bind(null,f),enumerable:!(r=Zz(e,f))||r.enumerable});return t},Mf=(t,e,n)=>(n=t!=null?Xz(Qz(t)):{},eL(UE(n,"default",{value:t,enumerable:!0}),t));const qE=()=>{},dx=t=>{Object.freeze&&Object.freeze(t)};function PE(t,e,n){var r;const a=e.join(".");return(r=n[a])!==null&&r!==void 0||(n[a]=new Proxy(qE,{get(u,c){if(!(typeof c!="string"||c==="then"))return PE(t,[...e,c],n)},apply(u,c,f){const h=e[e.length-1];let m={args:f,path:e};return h==="call"?m={args:f.length>=2?[f[1]]:[],path:e.slice(0,-1)}:h==="apply"&&(m={args:f.length>=2?f[1]:[],path:e.slice(0,-1)}),dx(m.args),dx(m.path),t(m)}})),n[a]}const tL=t=>PE(t,[],Object.create(null)),nL=t=>new Proxy(qE,{get(e,n){if(n!=="then")return t(n)}});var IE=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(t,e){function n(r){"@babel/helpers - typeof";return e.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},e.exports.__esModule=!0,e.exports.default=e.exports,n(r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}}),iL=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(t,e){var n=IE().default;function r(a,u){if(n(a)!="object"||!a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var f=c.call(a,u||"default");if(n(f)!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(u==="string"?String:Number)(a)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),rL=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(t,e){var n=IE().default,r=iL();function a(u){var c=r(u,"string");return n(c)=="symbol"?c:c+""}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}}),HE=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(t,e){var n=rL();function r(a,u,c){return(u=n(u))in a?Object.defineProperty(a,u,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[u]=c,a}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),Vy=Bl({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(t,e){var n=HE();function r(u,c){var f=Object.keys(u);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(u);c&&(h=h.filter(function(m){return Object.getOwnPropertyDescriptor(u,m).enumerable})),f.push.apply(f,h)}return f}function a(u){for(var c=1;c<arguments.length;c++){var f=arguments[c]!=null?arguments[c]:{};c%2?r(Object(f),!0).forEach(function(h){n(u,h,f[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(f)):r(Object(f)).forEach(function(h){Object.defineProperty(u,h,Object.getOwnPropertyDescriptor(f,h))})}return u}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}});Mf(Vy());Mf(HE());var dc=Mf(Vy());function sL(t,e){if("error"in t){const r=e.deserialize(t.error);return{ok:!1,error:(0,dc.default)((0,dc.default)({},t),{},{error:r})}}return{ok:!0,result:(0,dc.default)((0,dc.default)({},t.result),(!t.result.type||t.result.type==="data")&&{type:"data",data:e.deserialize(t.result.data)})}}var bp=class extends Error{constructor(){super("Unable to transform response from server")}};function oL(t,e){let n;try{n=sL(t,e)}catch{throw new bp}if(!n.ok&&(!gl(n.error.error)||typeof n.error.error.code!="number"))throw new bp;if(n.ok&&!gl(n.result))throw new bp;return n}Mf(Vy());var hc=bt(ks()),vo=bt(ni());function aL(t){return t instanceof bl}function lL(t){return gl(t)&&gl(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}function uL(t,e){return typeof t=="string"?t:gl(t)&&typeof t.message=="string"?t.message:e}var bl=class Ec extends Error{constructor(e,n){var r,a;const u=n?.cause;super(e,{cause:u}),(0,hc.default)(this,"cause",void 0),(0,hc.default)(this,"shape",void 0),(0,hc.default)(this,"data",void 0),(0,hc.default)(this,"meta",void 0),this.meta=n?.meta,this.cause=u,this.shape=n==null||(r=n.result)===null||r===void 0?void 0:r.error,this.data=n==null||(a=n.result)===null||a===void 0?void 0:a.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,Ec.prototype)}static from(e,n={}){const r=e;return aL(r)?(n.meta&&(r.meta=(0,vo.default)((0,vo.default)({},r.meta),n.meta)),r):lL(r)?new Ec(r.error.message,(0,vo.default)((0,vo.default)({},n),{},{result:r})):new Ec(uL(r,"Unknown error"),(0,vo.default)((0,vo.default)({},n),{},{cause:r}))}};function cL(t){const e=t;return e?"input"in e?e:{input:e,output:e}:{input:{serialize:n=>n,deserialize:n=>n},output:{serialize:n=>n,deserialize:n=>n}}}const hx=t=>typeof t=="function";function fL(t){if(t)return t;if(typeof window<"u"&&hx(window.fetch))return window.fetch;if(typeof globalThis<"u"&&hx(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}var il=bt(ni());function dL(t){return{url:t.url.toString(),fetch:t.fetch,transformer:cL(t.transformer),methodOverride:t.methodOverride}}function hL(t){const e={};for(let n=0;n<t.length;n++){const r=t[n];e[n]=r}return e}const pL={query:"GET",mutation:"POST",subscription:"PATCH"};function FE(t){return"input"in t?t.transformer.input.serialize(t.input):hL(t.inputs.map(e=>t.transformer.input.serialize(e)))}const GE=t=>{const e=t.url.split("?");let r=e[0].replace(/\/$/,"")+"/"+t.path;const a=[];if(e[1]&&a.push(e[1]),"inputs"in t&&a.push("batch=1"),t.type==="query"||t.type==="subscription"){const u=FE(t);u!==void 0&&t.methodOverride!=="POST"&&a.push(`input=${encodeURIComponent(JSON.stringify(u))}`)}return a.length&&(r+="?"+a.join("&")),r},mL=t=>{if(t.type==="query"&&t.methodOverride!=="POST")return;const e=FE(t);return e!==void 0?JSON.stringify(e):void 0},yL=t=>SL((0,il.default)((0,il.default)({},t),{},{contentTypeHeader:"application/json",getUrl:GE,getBody:mL}));var gL=class extends Error{constructor(){const t="AbortError";super(t),this.name=t,this.message=t}};const bL=t=>{var e;if(t?.aborted)throw(e=t.throwIfAborted)===null||e===void 0||e.call(t),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new gL};async function vL(t){var e;bL(t.signal);const n=t.getUrl(t),r=t.getBody(t),a=(e=t.methodOverride)!==null&&e!==void 0?e:pL[t.type],u=await(async()=>{const f=await t.headers();return Symbol.iterator in f?Object.fromEntries(f):f})(),c=(0,il.default)((0,il.default)((0,il.default)({},t.contentTypeHeader&&a!=="GET"?{"content-type":t.contentTypeHeader}:{}),t.trpcAcceptHeader?{"trpc-accept":t.trpcAcceptHeader}:void 0),u);return fL(t.fetch)(n,{method:a,signal:t.signal,body:r,headers:c})}async function SL(t){const e={},n=await vL(t);e.response=n;const r=await n.json();return e.responseJSON=r,{json:r,meta:e}}bt(ni());const px=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function mx(t){let e=null,n=null;const r=()=>{clearTimeout(n),n=null,e=null};function a(f){const h=[[]];let m=0;for(;;){const v=f[m];if(!v)break;const S=h[h.length-1];if(v.aborted){var y;(y=v.reject)===null||y===void 0||y.call(v,new Error("Aborted")),m++;continue}if(t.validate(S.concat(v).map(T=>T.key))){S.push(v),m++;continue}if(S.length===0){var g;(g=v.reject)===null||g===void 0||g.call(v,new Error("Input is too big for a single dispatch")),m++;continue}h.push([])}return h}function u(){const f=a(e);r();for(const h of f){if(!h.length)continue;const m={items:h};for(const g of h)g.batch=m;t.fetch(m.items.map(g=>g.key)).then(async g=>{await Promise.all(g.map(async(S,x)=>{const T=m.items[x];try{var M;const _=await Promise.resolve(S);(M=T.resolve)===null||M===void 0||M.call(T,_)}catch(_){var C;(C=T.reject)===null||C===void 0||C.call(T,_)}T.batch=null,T.reject=null,T.resolve=null}));for(const S of m.items){var v;(v=S.reject)===null||v===void 0||v.call(S,new Error("Missing result")),S.batch=null}}).catch(g=>{for(const S of m.items){var v;(v=S.reject)===null||v===void 0||v.call(S,g),S.batch=null}})}}function c(f){var h;const m={aborted:!1,key:f,batch:null,resolve:px,reject:px},y=new Promise((g,v)=>{var S;m.reject=v,m.resolve=g,(S=e)!==null&&S!==void 0||(e=[]),e.push(m)});return(h=n)!==null&&h!==void 0||(n=setTimeout(u)),y}return{load:c}}function wL(...t){const e=new AbortController,n=t.length;let r=0;const a=()=>{++r===n&&e.abort()};for(const u of t)u?.aborted?a():u?.addEventListener("abort",a,{once:!0});return e.signal}var pc=bt(ni());function xL(t){var e,n;const r=dL(t),a=(e=t.maxURLLength)!==null&&e!==void 0?e:1/0,u=(n=t.maxItems)!==null&&n!==void 0?n:1/0;return()=>{const c=y=>({validate(g){if(a===1/0&&u===1/0)return!0;if(g.length>u)return!1;const v=g.map(T=>T.path).join(","),S=g.map(T=>T.input);return GE((0,pc.default)((0,pc.default)({},r),{},{type:y,path:v,inputs:S,signal:null})).length<=a},async fetch(g){const v=g.map(_=>_.path).join(","),S=g.map(_=>_.input),x=wL(...g.map(_=>_.signal)),T=await yL((0,pc.default)((0,pc.default)({},r),{},{path:v,inputs:S,type:y,headers(){return t.headers?typeof t.headers=="function"?t.headers({opList:g}):t.headers:{}},signal:x}));return(Array.isArray(T.json)?T.json:g.map(()=>T.json)).map(_=>({meta:T.meta,json:_}))}}),f=mx(c("query")),h=mx(c("mutation")),m={query:f,mutation:h};return({op:y})=>kf(g=>{if(y.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const S=m[y.type].load(y);let x;return S.then(T=>{x=T;const M=oL(T.json,r.transformer.output);if(!M.ok){g.error(bl.from(M.error,{meta:T.meta}));return}g.next({context:T.meta,result:M.result}),g.complete()}).catch(T=>{g.error(bl.from(T,{meta:x?.meta}))}),()=>{}})}}bt(ni());const YE=(t,...e)=>typeof t=="function"?t(...e):t;bt(ks());function TL(){let t,e;return{promise:new Promise((r,a)=>{t=r,e=a}),resolve:t,reject:e}}async function AL(t){const e=await YE(t.url);if(!t.connectionParams)return e;const r=`${e.includes("?")?"&":"?"}connectionParams=1`;return e+r}async function EL(t){const e={method:"connectionParams",data:await YE(t)};return JSON.stringify(e)}bt(ks());var ps=bt(ks());function OL(t){const{promise:e,resolve:n,reject:r}=TL();return t.addEventListener("open",()=>{t.removeEventListener("error",r),n()}),t.addEventListener("error",r),e}function _L(t,{intervalMs:e,pongTimeoutMs:n}){let r,a;function u(){r=setTimeout(()=>{t.send("PING"),a=setTimeout(()=>{t.close()},n)},e)}function c(){clearTimeout(r),u()}function f(){clearTimeout(a),c()}t.addEventListener("open",u),t.addEventListener("message",({data:h})=>{clearTimeout(r),u(),h==="PONG"&&f()}),t.addEventListener("close",()=>{clearTimeout(r),clearTimeout(a)})}var RL=class vm{constructor(e){var n;if((0,ps.default)(this,"id",++vm.connectCount),(0,ps.default)(this,"WebSocketPonyfill",void 0),(0,ps.default)(this,"urlOptions",void 0),(0,ps.default)(this,"keepAliveOpts",void 0),(0,ps.default)(this,"wsObservable",Yz(null)),(0,ps.default)(this,"openPromise",null),this.WebSocketPonyfill=(n=e.WebSocketPonyfill)!==null&&n!==void 0?n:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=e.urlOptions,this.keepAliveOpts=e.keepAlive}get ws(){return this.wsObservable.get()}set ws(e){this.wsObservable.next(e)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var e=this;if(e.openPromise)return e.openPromise;e.id=++vm.connectCount;const n=AL(e.urlOptions).then(r=>new e.WebSocketPonyfill(r));e.openPromise=n.then(async r=>{e.ws=r,r.addEventListener("message",function({data:a}){a==="PING"&&this.send("PONG")}),e.keepAliveOpts.enabled&&_L(r,e.keepAliveOpts),r.addEventListener("close",()=>{e.ws===r&&(e.ws=null)}),await OL(r),e.urlOptions.connectionParams&&r.send(await EL(e.urlOptions.connectionParams))});try{await e.openPromise}finally{e.openPromise=null}}async close(){var e=this;try{await e.openPromise}finally{var n;(n=e.ws)===null||n===void 0||n.close()}}};(0,ps.default)(RL,"connectCount",0);bt(ks());bt(ni());var vp=bt(ks()),yx=bt(ni()),CL=class{constructor(t){(0,vp.default)(this,"links",void 0),(0,vp.default)(this,"runtime",void 0),(0,vp.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=t.links.map(e=>e(this.runtime))}$request(t){var e;return Jz({links:this.links,op:(0,yx.default)((0,yx.default)({},t),{},{context:(e=t.context)!==null&&e!==void 0?e:{},id:++this.requestId})}).pipe(Gz())}async requestAsPromise(t){var e=this;try{const n=e.$request(t);return(await Fz(n)).result.data}catch(n){throw bl.from(n)}}query(t,e,n){return this.requestAsPromise({type:"query",path:t,input:e,context:n?.context,signal:n?.signal})}mutation(t,e,n){return this.requestAsPromise({type:"mutation",path:t,input:e,context:n?.context,signal:n?.signal})}subscription(t,e,n){return this.$request({type:"subscription",path:t,input:e,context:n.context,signal:n.signal}).subscribe({next(a){switch(a.result.type){case"state":{var u;(u=n.onConnectionStateChange)===null||u===void 0||u.call(n,a.result);break}case"started":{var c;(c=n.onStarted)===null||c===void 0||c.call(n,{context:a.context});break}case"stopped":{var f;(f=n.onStopped)===null||f===void 0||f.call(n);break}case"data":case void 0:{var h;(h=n.onData)===null||h===void 0||h.call(n,a.result.data);break}}},error(a){var u;(u=n.onError)===null||u===void 0||u.call(n,a)},complete(){var a;(a=n.onComplete)===null||a===void 0||a.call(n)}})}};const kL=Symbol.for("trpc_untypedClient"),ML={query:"query",mutate:"mutation",subscribe:"subscription"},DL=t=>ML[t];function NL(t){const e=tL(({path:n,args:r})=>{const a=[...n],u=DL(a.pop()),c=a.join(".");return t[u](c,...r)});return nL(n=>n===kL?t:e[n])}function $L(t){const e=new CL(t);return NL(e)}bt(ni());bt(ni());var jL=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(t,e){function n(a){var u,c,f,h=2;for(typeof Symbol<"u"&&(c=Symbol.asyncIterator,f=Symbol.iterator);h--;){if(c&&(u=a[c])!=null)return u.call(a);if(f&&(u=a[f])!=null)return new r(u.call(a));c="@@asyncIterator",f="@@iterator"}throw new TypeError("Object is not async iterable")}function r(a){function u(c){if(Object(c)!==c)return Promise.reject(new TypeError(c+" is not an object."));var f=c.done;return Promise.resolve(c.value).then(function(h){return{value:h,done:f}})}return r=function(f){this.s=f,this.n=f.next},r.prototype={s:null,n:null,next:function(){return u(this.n.apply(this.s,arguments))},return:function(f){var h=this.s.return;return h===void 0?Promise.resolve({value:f,done:!0}):u(h.apply(this.s,arguments))},throw:function(f){var h=this.s.return;return h===void 0?Promise.reject(f):u(h.apply(this.s,arguments))}},new r(a)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}});bt(jL());bt(ni());var BL=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(t,e){function n(){var r=typeof SuppressedError=="function"?SuppressedError:function(f,h){var m=Error();return m.name="SuppressedError",m.error=f,m.suppressed=h,m},a={},u=[];function c(f,h){if(h!=null){if(Object(h)!==h)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(f)var m=h[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(m===void 0&&(m=h[Symbol.dispose||Symbol.for("Symbol.dispose")],f))var y=m;if(typeof m!="function")throw new TypeError("Object is not disposable.");y&&(m=function(){try{y.call(h)}catch(v){return Promise.reject(v)}}),u.push({v:h,d:m,a:f})}else f&&u.push({d:h,a:f});return h}return{e:a,u:c.bind(null,!1),a:c.bind(null,!0),d:function(){var h,m=this.e,y=0;function g(){for(;h=u.pop();)try{if(!h.a&&y===1)return y=0,u.push(h),Promise.resolve().then(g);if(h.d){var S=h.d.call(h.v);if(h.a)return y|=2,Promise.resolve(S).then(g,v)}else y|=1}catch(x){return v(x)}if(y===1)return m!==a?Promise.reject(m):Promise.resolve();if(m!==a)throw m}function v(S){return m=m!==a?new r(S,m):S,g()}return g()}}}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}}),JE=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(t,e){function n(r,a){this.v=r,this.k=a}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}}),zL=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(t,e){var n=JE();function r(a){return new n(a,0)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}}),LL=wi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(t,e){var n=JE();function r(u){return function(){return new a(u.apply(this,arguments))}}function a(u){var c,f;function h(y,g){try{var v=u[y](g),S=v.value,x=S instanceof n;Promise.resolve(x?S.v:S).then(function(T){if(x){var M=y==="return"?"return":"next";if(!S.k||T.done)return h(M,T);T=u[M](T).value}m(v.done?"return":"normal",T)},function(T){h("throw",T)})}catch(T){m("throw",T)}}function m(y,g){switch(y){case"return":c.resolve({value:g,done:!0});break;case"throw":c.reject(g);break;default:c.resolve({value:g,done:!1})}(c=c.next)?h(c.key,c.arg):f=null}this._invoke=function(y,g){return new Promise(function(v,S){var x={key:y,arg:g,resolve:v,reject:S,next:null};f?f=f.next=x:(c=f=x,h(y,g))})},typeof u.return!="function"&&(this.return=void 0)}a.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},a.prototype.next=function(u){return this._invoke("next",u)},a.prototype.throw=function(u){return this._invoke("throw",u)},a.prototype.return=function(u){return this._invoke("return",u)},e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}});bt(BL());bt(zL());bt(LL());bt(ni());var VL={};function XE(t,e){if(t instanceof Promise)throw new Error(e)}function UL(t,e){const n={},r=[];for(const a in t){const u=t[a]["~standard"].validate(e[a]);if(XE(u,`Validation must be synchronous, but ${a} returned a Promise.`),u.issues){r.push(...u.issues.map(c=>({...c,message:c.message,path:[a,...c.path??[]]})));continue}n[a]=u.value}return r.length?{issues:r}:{value:n}}function KL(t){const e=t.runtimeEnvStrict??t.runtimeEnv??VL;if(t.emptyStringAsUndefined??!1)for(const[_,R]of Object.entries(e))R===""&&delete e[_];if(!!t.skipValidation)return e;const a=typeof t.client=="object"?t.client:{},u=typeof t.server=="object"?t.server:{},c=typeof t.shared=="object"?t.shared:{},f=t.isServer??(typeof window>"u"||"Deno"in window),h=f?{...u,...c,...a}:{...a,...c},m=t.createFinalSchema?.(h,f)["~standard"].validate(e)??UL(h,e);XE(m,"Validation must be synchronous");const y=t.onValidationError??(_=>{throw console.error("❌ Invalid environment variables:",_),new Error("Invalid environment variables")}),g=t.onInvalidAccess??(()=>{throw new Error("❌ Attempted to access a server-side environment variable on the client")});if(m.issues)return y(m.issues);const v=_=>t.clientPrefix?!_.startsWith(t.clientPrefix)&&!(_ in c):!0,S=_=>f||!v(_),x=_=>_==="__esModule"||_==="$$typeof",T=(t.extends??[]).reduce((_,R)=>Object.assign(_,R),{}),M=Object.assign(T,m.value);return new Proxy(M,{get(_,R){if(typeof R=="string"&&!x(R))return S(R)?Reflect.get(_,R):g(R)}})}const qL={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_BACKEND_ORIGIN:"https://realtime.tempest.games"},PL="__vite_start_time"in globalThis,IL=typeof window<"u",Ki=Ot("string"),gx=Ot('"true" | "false" | undefined'),ZE=KL({isServer:!PL&&!IL,server:{CI:Ot("string | undefined").pipe(Boolean),POSTGRES_USER:Ki,POSTGRES_PASSWORD:Ki,POSTGRES_DATABASE:Ki,POSTGRES_HOST:Ki,POSTGRES_PORT:Ki.pipe(t=>Number.parseInt(t,10)),BACKEND_PORT:Ki.pipe(t=>Number.parseInt(t,10)),RUN_WORKERS_FROM_SOURCE:gx.pipe(t=>t==="true"),FRONTEND_PORT:Ki.pipe(t=>Number.parseInt(t,10)),FRONTEND_ORIGINS:Ki.pipe.try(t=>JSON.parse(t),Ot("string[]")),API_KEY_OPENAI:Ot("string | undefined"),API_KEY_RESEND:Ot("string | undefined")},clientPrefix:"VITE_",client:{VITE_BACKEND_ORIGIN:Ki,VITE_DEV_FRONTEND_HOST:Ot("string | undefined"),VITE_DEV_HTTPS:gx.pipe(t=>t==="true")},runtimeEnv:qL,emptyStringAsUndefined:!0}),cn=$L({links:[xL({url:ZE.VITE_BACKEND_ORIGIN,fetch(t,e){return e?(Object.assign(e,{credentials:"include"}),fetch(t,e)):fetch(t)}})]}),HL=ft({key:"appVersionQuery",default:cn.version.query});ft({key:"lastKnownVersion",default:null,effects:[mT(localStorage,JSON,"lastKnownVersion")]});const FL=Wi({key:"appVersion",get:async({get:t})=>{const e=t(HL),{version:n}=await e;return n}});function Sp(t){return["optional",t]}function GL(t,e){let n=[t];for(const r of e){if(typeof r!="string")return!1;n=n.flatMap(a=>{if(a===null)return[];const u=[],c=a[1],f=c[r];f!==void 0&&u.push(f);const h=Object.keys(c).find(m=>m.startsWith("$"));if(h){const m=c[h];m&&u.push(m)}return u})}for(const r of n)if(r===null||r[0]==="optional")return!0;return!1}const yi=Object.create(null);yi.open="0";yi.close="1";yi.ping="2";yi.pong="3";yi.message="4";yi.upgrade="5";yi.noop="6";const Oc=Object.create(null);Object.keys(yi).forEach(t=>{Oc[yi[t]]=t});const Sm={type:"error",data:"parser error"},QE=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",WE=typeof ArrayBuffer=="function",eO=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,Uy=({type:t,data:e},n,r)=>QE&&e instanceof Blob?n?r(e):bx(e,r):WE&&(e instanceof ArrayBuffer||eO(e))?n?r(e):bx(new Blob([e]),r):r(yi[t]+(e||"")),bx=(t,e)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];e("b"+(r||""))},n.readAsDataURL(t)};function vx(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let wp;function YL(t,e){if(QE&&t.data instanceof Blob)return t.data.arrayBuffer().then(vx).then(e);if(WE&&(t.data instanceof ArrayBuffer||eO(t.data)))return e(vx(t.data));Uy(t,!1,n=>{wp||(wp=new TextEncoder),e(wp.encode(n))})}const Sx="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wa=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Sx.length;t++)Wa[Sx.charCodeAt(t)]=t;const JL=t=>{let e=t.length*.75,n=t.length,r,a=0,u,c,f,h;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const m=new ArrayBuffer(e),y=new Uint8Array(m);for(r=0;r<n;r+=4)u=Wa[t.charCodeAt(r)],c=Wa[t.charCodeAt(r+1)],f=Wa[t.charCodeAt(r+2)],h=Wa[t.charCodeAt(r+3)],y[a++]=u<<2|c>>4,y[a++]=(c&15)<<4|f>>2,y[a++]=(f&3)<<6|h&63;return m},XL=typeof ArrayBuffer=="function",Ky=(t,e)=>{if(typeof t!="string")return{type:"message",data:tO(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:ZL(t.substring(1),e)}:Oc[n]?t.length>1?{type:Oc[n],data:t.substring(1)}:{type:Oc[n]}:Sm},ZL=(t,e)=>{if(XL){const n=JL(t);return tO(n,e)}else return{base64:!0,data:t}},tO=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},nO="",QL=(t,e)=>{const n=t.length,r=new Array(n);let a=0;t.forEach((u,c)=>{Uy(u,!1,f=>{r[c]=f,++a===n&&e(r.join(nO))})})},WL=(t,e)=>{const n=t.split(nO),r=[];for(let a=0;a<n.length;a++){const u=Ky(n[a],e);if(r.push(u),u.type==="error")break}return r};function eV(){return new TransformStream({transform(t,e){YL(t,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const u=new DataView(a.buffer);u.setUint8(0,126),u.setUint16(1,r)}else{a=new Uint8Array(9);const u=new DataView(a.buffer);u.setUint8(0,127),u.setBigUint64(1,BigInt(r))}t.data&&typeof t.data!="string"&&(a[0]|=128),e.enqueue(a),e.enqueue(n)})}})}let xp;function mc(t){return t.reduce((e,n)=>e+n.length,0)}function yc(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let r=0;for(let a=0;a<e;a++)n[a]=t[0][r++],r===t[0].length&&(t.shift(),r=0);return t.length&&r<t[0].length&&(t[0]=t[0].slice(r)),n}function tV(t,e){xp||(xp=new TextDecoder);const n=[];let r=0,a=-1,u=!1;return new TransformStream({transform(c,f){for(n.push(c);;){if(r===0){if(mc(n)<1)break;const h=yc(n,1);u=(h[0]&128)===128,a=h[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(mc(n)<2)break;const h=yc(n,2);a=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),r=3}else if(r===2){if(mc(n)<8)break;const h=yc(n,8),m=new DataView(h.buffer,h.byteOffset,h.length),y=m.getUint32(0);if(y>Math.pow(2,21)-1){f.enqueue(Sm);break}a=y*Math.pow(2,32)+m.getUint32(4),r=3}else{if(mc(n)<a)break;const h=yc(n,a);f.enqueue(Ky(u?h:xp.decode(h),e)),r=0}if(a===0||a>t){f.enqueue(Sm);break}}}})}const iO=4;function _t(t){if(t)return nV(t)}function nV(t){for(var e in _t.prototype)t[e]=_t.prototype[e];return t}_t.prototype.on=_t.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this};_t.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this};_t.prototype.off=_t.prototype.removeListener=_t.prototype.removeAllListeners=_t.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===e||r.fn===e){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+t],this};_t.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,e)}return this};_t.prototype.emitReserved=_t.prototype.emit;_t.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]};_t.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Df=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),Un=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),iV="arraybuffer";function rO(t,...e){return e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{})}const rV=Un.setTimeout,sV=Un.clearTimeout;function Nf(t,e){e.useNativeTimers?(t.setTimeoutFn=rV.bind(Un),t.clearTimeoutFn=sV.bind(Un)):(t.setTimeoutFn=Un.setTimeout.bind(Un),t.clearTimeoutFn=Un.clearTimeout.bind(Un))}const oV=1.33;function aV(t){return typeof t=="string"?lV(t):Math.ceil((t.byteLength||t.size)*oV)}function lV(t){let e=0,n=0;for(let r=0,a=t.length;r<a;r++)e=t.charCodeAt(r),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);return n}function sO(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function uV(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function cV(t){let e={},n=t.split("&");for(let r=0,a=n.length;r<a;r++){let u=n[r].split("=");e[decodeURIComponent(u[0])]=decodeURIComponent(u[1])}return e}class fV extends Error{constructor(e,n,r){super(e),this.description=n,this.context=r,this.type="TransportError"}}class qy extends _t{constructor(e){super(),this.writable=!1,Nf(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,n,r){return super.emitReserved("error",new fV(e,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=Ky(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=uV(e);return n.length?"?"+n:""}}class dV extends qy{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};WL(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,QL(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=sO()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}}let oO=!1;try{oO=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const hV=oO;function pV(){}class mV extends dV{constructor(e){if(super(e),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,n){const r=this.request({method:"POST",data:e});r.on("success",n),r.on("error",(a,u)=>{this.onError("xhr post error",a,u)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=e}}let No=class _c extends _t{constructor(e,n,r){super(),this.createRequest=e,Nf(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var e;const n=rO(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=_c.requestsCount++,_c.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=pV,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete _c.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};No.requestsCount=0;No.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",wx);else if(typeof addEventListener=="function"){const t="onpagehide"in Un?"pagehide":"unload";addEventListener(t,wx,!1)}}function wx(){for(let t in No.requests)No.requests.hasOwnProperty(t)&&No.requests[t].abort()}const yV=(function(){const t=aO({xdomain:!1});return t&&t.responseType!==null})();class gV extends mV{constructor(e){super(e);const n=e&&e.forceBase64;this.supportsBinary=yV&&!n}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new No(aO,this.uri(),e)}}function aO(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||hV))return new XMLHttpRequest}catch{}if(!e)try{return new Un[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const lO=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class bV extends qy{get name(){return"websocket"}doOpen(){const e=this.uri(),n=this.opts.protocols,r=lO?{}:rO(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],a=n===e.length-1;Uy(r,this.supportsBinary,u=>{try{this.doWrite(r,u)}catch{}a&&Df(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=sO()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}}const Tp=Un.WebSocket||Un.MozWebSocket;class vV extends bV{createSocket(e,n,r){return lO?new Tp(e,n,r):n?new Tp(e,n):new Tp(e)}doWrite(e,n){this.ws.send(n)}}class SV extends qy{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const n=tV(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(n).getReader(),a=eV();a.readable.pipeTo(e.writable),this._writer=a.writable.getWriter();const u=()=>{r.read().then(({done:f,value:h})=>{f||(this.onPacket(h),u())}).catch(f=>{})};u();const c={type:"open"};this.query.sid&&(c.data=`{"sid":"${this.query.sid}"}`),this._writer.write(c).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const r=e[n],a=n===e.length-1;this._writer.write(r).then(()=>{a&&Df(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const wV={websocket:vV,webtransport:SV,polling:gV},xV=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,TV=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function wm(t){if(t.length>8e3)throw"URI too long";const e=t,n=t.indexOf("["),r=t.indexOf("]");n!=-1&&r!=-1&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));let a=xV.exec(t||""),u={},c=14;for(;c--;)u[TV[c]]=a[c]||"";return n!=-1&&r!=-1&&(u.source=e,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=AV(u,u.path),u.queryKey=EV(u,u.query),u}function AV(t,e){const n=/\/{2,9}/g,r=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function EV(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,u){a&&(n[a]=u)}),n}const xm=typeof addEventListener=="function"&&typeof removeEventListener=="function",Rc=[];xm&&addEventListener("offline",()=>{Rc.forEach(t=>t())},!1);class jr extends _t{constructor(e,n){if(super(),this.binaryType=iV,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(n=e,e=null),e){const r=wm(e);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=wm(n.host).host);Nf(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=cV(this.opts.query)),xm&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Rc.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=iO,n.transport=e,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&jr.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(e);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",jr.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=e.data,this._onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=aV(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Df(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,n,r){return this._sendPacket("message",e,n,r),this}send(e,n,r){return this._sendPacket("message",e,n,r),this}_sendPacket(e,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const u={type:e,data:n,options:r};this.emitReserved("packetCreate",u),this.writeBuffer.push(u),a&&this.once("flush",a),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}_onError(e){if(jr.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),xm&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Rc.indexOf(this._offlineEventListener);r!==-1&&Rc.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this._prevBufferLen=0}}}jr.protocol=iO;class OV extends jr{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let n=this.createTransport(e),r=!1;jr.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",g=>{if(!r)if(g.type==="pong"&&g.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;jr.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(y(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=n.name,this.emitReserved("upgradeError",v)}}))};function u(){r||(r=!0,y(),n.close(),n=null)}const c=g=>{const v=new Error("probe error: "+g);v.transport=n.name,u(),this.emitReserved("upgradeError",v)};function f(){c("transport closed")}function h(){c("socket closed")}function m(g){n&&g.name!==n.name&&u()}const y=()=>{n.removeListener("open",a),n.removeListener("error",c),n.removeListener("close",f),this.off("close",h),this.off("upgrading",m)};n.once("open",a),n.once("error",c),n.once("close",f),this.once("close",h),this.once("upgrading",m),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const n=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&n.push(e[r]);return n}}let _V=class extends OV{constructor(e,n={}){const r=typeof e=="object"?e:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>wV[a]).filter(a=>!!a)),super(e,r)}};function RV(t,e="",n){let r=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),r=wm(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const u=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+u+":"+r.port+e,r.href=r.protocol+"://"+u+(n&&n.port===r.port?"":":"+r.port),r}const CV=typeof ArrayBuffer=="function",kV=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,uO=Object.prototype.toString,MV=typeof Blob=="function"||typeof Blob<"u"&&uO.call(Blob)==="[object BlobConstructor]",DV=typeof File=="function"||typeof File<"u"&&uO.call(File)==="[object FileConstructor]";function Py(t){return CV&&(t instanceof ArrayBuffer||kV(t))||MV&&t instanceof Blob||DV&&t instanceof File}function Cc(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(Cc(t[n]))return!0;return!1}if(Py(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Cc(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Cc(t[n]))return!0;return!1}function NV(t){const e=[],n=t.data,r=t;return r.data=Tm(n,e),r.attachments=e.length,{packet:r,buffers:e}}function Tm(t,e){if(!t)return t;if(Py(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=Tm(t[r],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=Tm(t[r],e));return n}return t}function $V(t,e){return t.data=Am(t.data,e),delete t.attachments,t}function Am(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=Am(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=Am(t[n],e));return t}const jV=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],BV=5;var ke;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(ke||(ke={}));class zV{constructor(e){this.replacer=e}encode(e){return(e.type===ke.EVENT||e.type===ke.ACK)&&Cc(e)?this.encodeAsBinary({type:e.type===ke.EVENT?ke.BINARY_EVENT:ke.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===ke.BINARY_EVENT||e.type===ke.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=NV(e),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}function xx(t){return Object.prototype.toString.call(t)==="[object Object]"}class Iy extends _t{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const r=n.type===ke.BINARY_EVENT;r||n.type===ke.BINARY_ACK?(n.type=r?ke.EVENT:ke.ACK,this.reconstructor=new LV(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Py(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const r={type:Number(e.charAt(0))};if(ke[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===ke.BINARY_EVENT||r.type===ke.BINARY_ACK){const u=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const c=e.substring(u,n);if(c!=Number(c)||e.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(c)}if(e.charAt(n+1)==="/"){const u=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););r.nsp=e.substring(u,n)}else r.nsp="/";const a=e.charAt(n+1);if(a!==""&&Number(a)==a){const u=n+1;for(;++n;){const c=e.charAt(n);if(c==null||Number(c)!=c){--n;break}if(n===e.length)break}r.id=Number(e.substring(u,n+1))}if(e.charAt(++n)){const u=this.tryParse(e.substr(n));if(Iy.isPayloadValid(r.type,u))r.data=u;else throw new Error("invalid payload")}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case ke.CONNECT:return xx(n);case ke.DISCONNECT:return n===void 0;case ke.CONNECT_ERROR:return typeof n=="string"||xx(n);case ke.EVENT:case ke.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&jV.indexOf(n[0])===-1);case ke.ACK:case ke.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class LV{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=$V(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const VV=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Iy,Encoder:zV,get PacketType(){return ke},protocol:BV},Symbol.toStringTag,{value:"Module"}));function Qn(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const UV=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class cO extends _t{constructor(e,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Qn(e,"open",this.onopen.bind(this)),Qn(e,"packet",this.onpacket.bind(this)),Qn(e,"error",this.onerror.bind(this)),Qn(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){var r,a,u;if(UV.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const c={type:ke.EVENT,data:n};if(c.options={},c.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const y=this.ids++,g=n.pop();this._registerAckCallback(y,g),c.id=y}const f=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,h=this.connected&&!(!((u=this.io.engine)===null||u===void 0)&&u._hasPingExpired());return this.flags.volatile&&!f||(h?(this.notifyOutgoingListeners(c),this.packet(c)):this.sendBuffer.push(c)),this.flags={},this}_registerAckCallback(e,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[e]=n;return}const u=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let f=0;f<this.sendBuffer.length;f++)this.sendBuffer[f].id===e&&this.sendBuffer.splice(f,1);n.call(this,new Error("operation has timed out"))},a),c=(...f)=>{this.io.clearTimeoutFn(u),n.apply(this,f)};c.withError=!0,this.acks[e]=c}emitWithAck(e,...n){return new Promise((r,a)=>{const u=(c,f)=>c?a(c):r(f);u.withError=!0,n.push(u),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((a,...u)=>r!==this._queue[0]?void 0:(a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...u)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:ke.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(r=>String(r.id)===e)){const r=this.acks[e];delete this.acks[e],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case ke.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ke.EVENT:case ke.BINARY_EVENT:this.onevent(e);break;case ke.ACK:case ke.BINARY_ACK:this.onack(e);break;case ke.DISCONNECT:this.ondisconnect();break;case ke.CONNECT_ERROR:this.destroy();const r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:ke.ACK,id:e,data:a}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(delete this.acks[e.id],n.withError&&e.data.unshift(null),n.apply(this,e.data))}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ke.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(e===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,e.data)}}}function Xo(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Xo.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0};Xo.prototype.reset=function(){this.attempts=0};Xo.prototype.setMin=function(t){this.ms=t};Xo.prototype.setMax=function(t){this.max=t};Xo.prototype.setJitter=function(t){this.jitter=t};class Em extends _t{constructor(e,n){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Nf(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Xo({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const a=n.parser||VV;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new _V(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=Qn(n,"open",function(){r.onopen(),e&&e()}),u=f=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",f),e?e(f):this.maybeReconnectOnOpen()},c=Qn(n,"error",u);if(this._timeout!==!1){const f=this._timeout,h=this.setTimeoutFn(()=>{a(),u(new Error("timeout")),n.close()},f);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(a),this.subs.push(c),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Qn(e,"ping",this.onping.bind(this)),Qn(e,"data",this.ondata.bind(this)),Qn(e,"error",this.onerror.bind(this)),Qn(e,"close",this.onclose.bind(this)),Qn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){Df(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new cO(this,e,n),this.nsps[e]=r),r}_destroy(e){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let r=0;r<n.length;r++)this.engine.write(n[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(a=>{a?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",a)):e.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Ya={};function kc(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=RV(t,e.path||"/socket.io"),r=n.source,a=n.id,u=n.path,c=Ya[a]&&u in Ya[a].nsps,f=e.forceNew||e["force new connection"]||e.multiplex===!1||c;let h;return f?h=new Em(r,e):(Ya[a]||(Ya[a]=new Em(r,e)),h=Ya[a]),n.query&&!e.query&&(e.query=n.queryKey),h.socket(n.path,e)}Object.assign(kc,{Manager:Em,Socket:cO,io:kc,connect:kc});const KV=["123","321","abc","admin","adobe","alexander","amanda","andrea","andrew","angel","apple","asdf","ashley","baby","banana","baseball","batman","bear","biteme","blazer","blonde","boston","buster","butterfly","cameron","charlie","cheese","chelsea","chicken","chocolate","chris","compaq","computer","cookie","corvette","cowboys","dakota","dallas","daniel","david","diamond","dolphin","donald","dragon","eagle","flower","football","frank","freedom","friend","gateway","george","ginger","god","golf","hannah","hardcore","harley","heather","hello","hottie","hunter","internet","jasmine","jennifer","jessica","jesus","johnny","jordan","joshua","justin","justme","killer","knight","lakers","letmein","liverpool","login","london","love","lucky","mackenzie","maggie","master","matrix","matthew","maverick","melissa","mercedes","michael","michelle","mickey","miller","money","monkey","morgan","mother","muffin","mustang","natasha","nathan","nicole","ninja","orange","pass","password","patrick","peanut","pepper","phoenix","photoshop","pokemon","princess","purple","qazwsx","qwerty","rainbow","ranger","root","samantha","samsung","scooter","secret","shadow","simpson","smile","soccer","sparkle","starwars","summer","sunflower","sunshine","superman","taylor","temp","test","thomas","tigers","tigger","tinkerbell","trust","turtle","victoria","welcome","whatever","william","winter","yellow","zaq12wsx","zxcvbn"],qV=3,PV=15,IV=/^[a-zA-Z0-9_-]+$/,HV=Ot(IV).pipe(Ot(`string > ${qV} & string < ${PV}`)).brand("username"),Tx=20,Ax={0:"o",1:"l",3:"e",4:"a",5:"s",7:"t","@":"a",$:"s","!":"i"};function FV(t){let e="";for(const n of t)n in Ax?e+=Ax[n]:e+=n;return e}function GV(t){const e=t.toLocaleLowerCase(),n=FV(e);for(const r of KV)if(n.includes(r)||e.includes(r))return!0;return!1}function YV(t){const e=new Set(t).size;return t.length*Math.log2(e)}function JV(t){let e=0;return GV(t)&&(e-=100),e+=YV(t)*.5,Math.max(e,0)}const XV=Ot("string").narrow((t,e)=>{const n=JV(t);return n>=Tx?!0:e.mustBe(`Of complexity ${Tx} or more. Was ${n.toFixed(2)}.`)}).brand("password");Ot({"+":"delete",email:"string",password:"string"});const ZV=Ot("string").brand("email");Ot({"+":"delete",username:"string",password:"string",email:"string"});const QV=Ot({email:"string",userId:"string",username:"string",password:"boolean",verification:"'unverified' | 'verified'"}),gi=kc(ZE.VITE_BACKEND_ORIGIN,{auth:t=>{const e=nt(ut);e&&t(e)},withCredentials:!0,autoConnect:!1});gi.on("connect",()=>{console.log("connected")}).on("connect_error",()=>{console.log("connect_error"),De(ut,null)}).on("usernameChanged",t=>{De(ut,e=>e===null?null:{...e,username:t})});const ut=ft({key:"auth",default:function(){const e=localStorage.getItem("auth");if(e)try{const n=qr(e),r=QV(n);return r instanceof Ot.errors?(console.error("failed to parse auth data",r),null):(r.verification==="verified"&&(console.log("connecting..."),gi.connect()),r)}catch(n){return console.error("failed to parse auth data",n),null}return null},effects:[function({onSet:e}){e(({newValue:n})=>{console.log("setting auth",n),n?(console.log("setting auth",n),De($o,n.username),localStorage.setItem("auth",zt(n)),n.verification==="verified"?(console.log("connecting..."),gi.connect()):Os("/verify")):(console.log("clearing session..."),localStorage.removeItem("auth"))})}]}),$o=ft({key:"username",default:nt(ut)?.username??""}),Ap=ft({key:"usernameDebounce",default:!0}),WV=ft({key:"usernameDebounced100ms",default:window.localStorage.getItem("username")??"",effects:[({setSelf:t})=>{Rk($o,()=>{nt(Ap)&&(t(nt($o)),De(Ap,!1),setTimeout(()=>{De(Ap,!0),t(nt($o))},2e3))})}]}),e4=Wi({key:"isUsernameTakenQuery",get:({get:t})=>{const e=t(WV);if(!e)return!1;const n=nt(ut);return e===n?.username?!1:cn.isUsernameTaken.query({username:e})}}),fO=Wi({key:"usernameIssues",get:({get:t})=>{const e=t($o),n=HV(e);return n instanceof Ot.errors?n:null}}),di=ft({key:"password0",default:""}),dO=Wi({key:"password0Issues",get:({get:t})=>{const e=t(di),n=XV(e);return n instanceof Ot.errors?n:null}}),Po=ft({key:"email",default:""}),hO=Wi({key:"emailIssues",get:({get:t})=>{const e=t(Po),n=ZV(e);return n instanceof Ot.errors?n:null}});Wi({key:"signupReady",get:({get:t})=>{const e=t(fO),n=t(dO),r=t(hO);return!(e??n??r)}});const Hi=ft({key:"oneTimeCode",default:""}),Om=ft({key:"oneTimeCodeNewEmail",default:""}),ui=ft({key:"authTarget",default:null}),pO=Sp({verify:Sp({$token:null}),game:Sp({clicker:null}),account:null,admin:null});function t4(t){return GL(pO,t)}const n4=[[]];function i4(t){return n4.some(e=>e.join("/")===t.join("/"))}function Os(t){history.pushState(null,"",t),De(mO,t)}const mO=ft({key:"pathName",default:window.location.pathname,effects:[({onSet:t,setSelf:e})=>{const n=a=>{history.replaceState(null,"",a),e(a)},r=a=>{switch(a){case"/":{const u=nt(ut);switch(console.log("/","auth",u),u?.verification){case"verified":n("/game");break;case"unverified":n("/verify");break}break}case"/verify":{nt(ut)?.verification==="verified"&&n("/game");break}case"/game":case"/game/clicker":{nt(ut)?.verification==="unverified"&&n("/verify");break}case"/admin":break;case"/account":{const u=nt(ut);if(!u){n("/");break}u.verification==="unverified"&&n("/verify");break}}};r(window.location.pathname),t(({newValue:a})=>{r(a)})},({setSelf:t})=>{document.addEventListener("click",e=>{const n=e.target.closest("a");if(n&&n instanceof HTMLAnchorElement){const r=n.getAttribute("href");r?.startsWith("/")&&(e.preventDefault(),history.pushState(null,"",r),t(r))}}),window.addEventListener("popstate",()=>{t(window.location.pathname)})}]}),r4=Wi({key:"route",get:({get:t})=>{const n=t(mO).split("/").slice(1).filter(Boolean);return t4(n)?i4(n)||t(ut)?n:401:404}}),Ex=ft({key:"buttonBlockActive",default:!1}),zn=ft({key:"editing",default:[],effects:[({onSet:t})=>{t(({newValue:e})=>{switch(e[0]){case"email":{nt(yO)?.focus();break}case"new-password":{nt(gO)?.focus();break}case"username":{nt(bO)?.focus();break}}})}]}),yO=ft({key:"emailInputElement",default:null}),gO=ft({key:"password0InputElement",default:null}),bO=ft({key:"usernameInputElement",default:null});function s4(t){const e=$.useRef(null);return $.useEffect(()=>{De(t,e.current)},[t]),e}const o4=Wi({key:"otcLoginFieldLabel",get:({get:t})=>{const e=t(ut);return e?`Code sent to ${e.email}`:""}}),a4=Wi({key:"otcVerifyFieldLabel",get:({get:t})=>{const e=t(Po);return e?`Code sent to ${e}`:""}});function Ep({label:t,inputToken:e,issuesToken:n,inputElementToken:r,initialState:a,onSubmit:u,onOpen:c,onCancel:f,extraIssues:h}){const m=Et(e),y=Wn(e),g=Et(Hi),v=Wn(Hi),S=Et(Om),x=Wn(Om),T=Et(di),M=Wn(di),C=Et(Ex),_=Wn(Ex),R=Et(zn),G=Wn(zn),I=Et(n),ee=Et(o4),J=Et(a4),X=s4(r),he=R[0]===t,pe=R.at(-1),[we,...je]=R;return F.jsxs("form",{onSubmit:async ve=>{if(ve.preventDefault(),C){_(!1);return}console.log(`submitted! changing ${t} to`,m);const Z=await u(m);Error.isError(Z)&&console.error(Z)},children:[he?F.jsx("button",{type:"button",onClick:async()=>{await f?.(),G([])},children:"x"}):null,F.jsxs("main",{children:[F.jsxs("label",{htmlFor:t,children:[I||h?F.jsxs("aside",{children:[h,I?.map(ve=>F.jsx("span",{children:ve.message},ve.path.join(".")))]}):null,F.jsx("span",{children:t==="new-password"?"Password":hs(t)}),F.jsx("input",{id:t,type:t==="new-password"?"password":"text",ref:X,value:m,onChange:ve=>{y(ve.target.value)},autoComplete:t,autoCapitalize:"none",disabled:pe!==t})]}),he?je.map(ve=>F.jsxs("label",{htmlFor:`${t}-${ve}`,children:[F.jsx("span",{children:(()=>{switch(ve){case"otcLogin":return ee;case"otcVerify":return J;case"passwordLogin":return"Password"}})()}),F.jsx("input",{id:`${t}-otc`,type:"text",ref:X,value:(()=>{switch(ve){case"otcLogin":return g;case"otcVerify":return t==="email"?S:g;case"passwordLogin":return T}})(),onChange:Z=>{switch(ve){case"otcLogin":v(Z.target.value);break;case"otcVerify":if(t==="email"){x(Z.target.value);break}v(Z.target.value);break;case"passwordLogin":M(Z.target.value)}},autoComplete:t.includes("otc")?"one-time-code":t.includes("password")?"password":"",autoCapitalize:"none",disabled:ve!==pe})]},`${t}-${ve}`)):null]}),R[0]===t?F.jsx("button",{type:"submit",children:"->"}):F.jsx("button",{type:"button",onMouseDown:async()=>{_(!0),await c?.(),G(a)},onMouseUp:()=>{_(!1)},children:"/"})]})}function l4(){const t=Et(ut),e=Et(e4);return $.useEffect(()=>{t&&De(Po,t.email),t?.password&&De(di,"••••••••••••")},[]),t?F.jsxs("article",{"data-css":"editor",children:[F.jsx(Ep,{label:"username",inputToken:$o,issuesToken:fO,inputElementToken:bO,initialState:["username"],onSubmit:async n=>(await new Promise(r=>{gi.once("usernameChanged",r),gi.emit("changeUsername",n)}),De(zn,[]),n),extraIssues:e?F.jsx("span",{children:"This username is taken."}):null}),F.jsx(Ep,{label:"email",inputToken:Po,issuesToken:hO,inputElementToken:yO,initialState:["email"],onSubmit:async n=>{const r=nt(zn);if(r[0]!=="email")return new Error("field not email");switch(r.length){case 1:{const{userKey:a,nextStep:u}=await cn.offerNewEmail.mutate({emailOffered:n});switch(console.log({authTarget:a,nextStep:u}),u){case"otc_login":{De(ui,a),De(zn,["email","otcLogin"]);break}case"password_login":{De(ui,a),De(zn,["email","passwordLogin"]);break}case"otc_verify":{De(ui,a),De(Hi,"not needed"),De(zn,["email","otcLogin","otcVerify"]);break}}return a}case 2:switch(console.log("case 2"),r[1]){case"otcLogin":{console.log("case 2.1");const a=nt(ui);if(!a)return new Error("No auth target");const u=nt(Hi),c=await cn.verifyAccountAction.mutate({oneTimeCode:u,userKey:a});return De(ut,c),De(zn,["email","otcLogin","otcVerify"]),a}case"passwordLogin":return new Error("not implemented")}break;case 3:{const a=nt(ui);if(!a)return new Error("No auth target");const u=nt(Om),c=await cn.verifyAccountAction.mutate({oneTimeCode:u,userKey:a});return De(ut,c),De(zn,[]),c.email}}}}),F.jsx(Ep,{label:"new-password",inputToken:di,issuesToken:dO,inputElementToken:gO,initialState:t.password?["new-password","otcVerify"]:["new-password"],onSubmit:async n=>{const r=nt(zn);if(r[0]!=="new-password")return new Error("field not new-password");switch(r.length){case 1:return await cn.setPassword.mutate({password:n}),De(di,"••••••••••••"),De(ut,a=>a&&{...a,password:!0}),De(zn,[]),"done";case 2:{const a=nt(ui);return a?(await cn.verifyAccountAction.mutate({oneTimeCode:nt(Hi),userKey:a}),De(ut,u=>u&&{...u,password:!1}),De(di,""),De(zn,["new-password"]),"done"):new Error("No userKey")}}},onCancel:()=>{t.password&&De(di,"••••••••••••")},onOpen:async()=>{if(t.password){const n=nt(ui);if(!n)return new Error("No userKey");await cn.startPasswordReset.mutate({userKey:n})}}})]}):F.jsx("p",{children:"You must be logged in to verify your account."})}function u4(){return F.jsx("article",{children:F.jsx("h1",{children:"admin"})})}const Hy=ft({key:"count",default:0}),vO=Ck({key:"incrementTX",do:({set:t})=>{t(Hy,e=>e+1)}}),c4=SM({key:"countContinuity",config:t=>t.add(Hy).add(vO)});function f4({route:[,t]}){return F.jsx("article",{children:t?F.jsx(h4,{gameId:t}):F.jsx(d4,{})})}function d4(){return F.jsx("nav",{children:F.jsx(BE,{href:"/game/clicker",children:"Clicker"})})}Mk(pO[1].game[1]);function h4({gameId:t}){console.log(t);const e=Et(Hy),n=kk(vO);return DM(c4),F.jsxs("article",{children:[F.jsxs("button",{type:"button",onClick:()=>{n()},children:["count is ",e]}),F.jsx("p",{children:"Let's see how high we can count!"})]})}const SO=$.createContext({});function p4(t){const e=$.useRef(null);return e.current===null&&(e.current=t()),e.current}const Fy=typeof window<"u",m4=Fy?$.useLayoutEffect:$.useEffect,Gy=$.createContext(null);function Yy(t,e){t.indexOf(e)===-1&&t.push(e)}function Jy(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Zi=(t,e,n)=>n>e?e:n<t?t:n;let Xy=()=>{};const Qi={},wO=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function xO(t){return typeof t=="object"&&t!==null}const TO=t=>/^0[^.\s]+$/u.test(t);function Zy(t){let e;return()=>(e===void 0&&(e=t()),e)}const Pn=t=>t,y4=(t,e)=>n=>e(t(n)),zl=(...t)=>t.reduce(y4),vl=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class Qy{constructor(){this.subscriptions=[]}add(e){return Yy(this.subscriptions,e),()=>Jy(this.subscriptions,e)}notify(e,n,r){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](e,n,r);else for(let u=0;u<a;u++){const c=this.subscriptions[u];c&&c(e,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const pi=t=>t*1e3,qn=t=>t/1e3;function AO(t,e){return e?t*(1e3/e):0}const EO=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,g4=1e-7,b4=12;function v4(t,e,n,r,a){let u,c,f=0;do c=e+(n-e)/2,u=EO(c,r,a)-t,u>0?n=c:e=c;while(Math.abs(u)>g4&&++f<b4);return c}function Ll(t,e,n,r){if(t===e&&n===r)return Pn;const a=u=>v4(u,0,1,t,n);return u=>u===0||u===1?u:EO(a(u),e,r)}const OO=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,_O=t=>e=>1-t(1-e),RO=Ll(.33,1.53,.69,.99),Wy=_O(RO),CO=OO(Wy),kO=t=>(t*=2)<1?.5*Wy(t):.5*(2-Math.pow(2,-10*(t-1))),eg=t=>1-Math.sin(Math.acos(t)),MO=_O(eg),DO=OO(eg),S4=Ll(.42,0,1,1),w4=Ll(0,0,.58,1),NO=Ll(.42,0,.58,1),x4=t=>Array.isArray(t)&&typeof t[0]!="number",$O=t=>Array.isArray(t)&&typeof t[0]=="number",T4={linear:Pn,easeIn:S4,easeInOut:NO,easeOut:w4,circIn:eg,circInOut:DO,circOut:MO,backIn:Wy,backInOut:CO,backOut:RO,anticipate:kO},A4=t=>typeof t=="string",Ox=t=>{if($O(t)){Xy(t.length===4);const[e,n,r,a]=t;return Ll(e,n,r,a)}else if(A4(t))return T4[t];return t},gc=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function E4(t,e){let n=new Set,r=new Set,a=!1,u=!1;const c=new WeakSet;let f={delta:0,timestamp:0,isProcessing:!1};function h(y){c.has(y)&&(m.schedule(y),t()),y(f)}const m={schedule:(y,g=!1,v=!1)=>{const x=v&&a?n:r;return g&&c.add(y),x.has(y)||x.add(y),y},cancel:y=>{r.delete(y),c.delete(y)},process:y=>{if(f=y,a){u=!0;return}a=!0,[n,r]=[r,n],n.forEach(h),n.clear(),a=!1,u&&(u=!1,m.process(y))}};return m}const O4=40;function jO(t,e){let n=!1,r=!0;const a={delta:0,timestamp:0,isProcessing:!1},u=()=>n=!0,c=gc.reduce((R,G)=>(R[G]=E4(u),R),{}),{setup:f,read:h,resolveKeyframes:m,preUpdate:y,update:g,preRender:v,render:S,postRender:x}=c,T=()=>{const R=Qi.useManualTiming?a.timestamp:performance.now();n=!1,Qi.useManualTiming||(a.delta=r?1e3/60:Math.max(Math.min(R-a.timestamp,O4),1)),a.timestamp=R,a.isProcessing=!0,f.process(a),h.process(a),m.process(a),y.process(a),g.process(a),v.process(a),S.process(a),x.process(a),a.isProcessing=!1,n&&e&&(r=!1,t(T))},M=()=>{n=!0,r=!0,a.isProcessing||t(T)};return{schedule:gc.reduce((R,G)=>{const I=c[G];return R[G]=(ee,J=!1,X=!1)=>(n||M(),I.schedule(ee,J,X)),R},{}),cancel:R=>{for(let G=0;G<gc.length;G++)c[gc[G]].cancel(R)},state:a,steps:c}}const{schedule:it,cancel:Vr,state:Ht,steps:Op}=jO(typeof requestAnimationFrame<"u"?requestAnimationFrame:Pn,!0);let Mc;function _4(){Mc=void 0}const fn={now:()=>(Mc===void 0&&fn.set(Ht.isProcessing||Qi.useManualTiming?Ht.timestamp:performance.now()),Mc),set:t=>{Mc=t,queueMicrotask(_4)}},BO=t=>e=>typeof e=="string"&&e.startsWith(t),tg=BO("--"),R4=BO("var(--"),ng=t=>R4(t)?C4.test(t.split("/*")[0].trim()):!1,C4=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Zo={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Sl={...Zo,transform:t=>Zi(0,1,t)},bc={...Zo,default:1},rl=t=>Math.round(t*1e5)/1e5,ig=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function k4(t){return t==null}const M4=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,rg=(t,e)=>n=>!!(typeof n=="string"&&M4.test(n)&&n.startsWith(t)||e&&!k4(n)&&Object.prototype.hasOwnProperty.call(n,e)),zO=(t,e,n)=>r=>{if(typeof r!="string")return r;const[a,u,c,f]=r.match(ig);return{[t]:parseFloat(a),[e]:parseFloat(u),[n]:parseFloat(c),alpha:f!==void 0?parseFloat(f):1}},D4=t=>Zi(0,255,t),_p={...Zo,transform:t=>Math.round(D4(t))},gs={test:rg("rgb","red"),parse:zO("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+_p.transform(t)+", "+_p.transform(e)+", "+_p.transform(n)+", "+rl(Sl.transform(r))+")"};function N4(t){let e="",n="",r="",a="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),a=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),a=t.substring(4,5),e+=e,n+=n,r+=r,a+=a),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:a?parseInt(a,16)/255:1}}const _m={test:rg("#"),parse:N4,transform:gs.transform},Vl=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),_r=Vl("deg"),mi=Vl("%"),de=Vl("px"),$4=Vl("vh"),j4=Vl("vw"),_x={...mi,parse:t=>mi.parse(t)/100,transform:t=>mi.transform(t*100)},To={test:rg("hsl","hue"),parse:zO("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+mi.transform(rl(e))+", "+mi.transform(rl(n))+", "+rl(Sl.transform(r))+")"},At={test:t=>gs.test(t)||_m.test(t)||To.test(t),parse:t=>gs.test(t)?gs.parse(t):To.test(t)?To.parse(t):_m.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?gs.transform(t):To.transform(t),getAnimatableNone:t=>{const e=At.parse(t);return e.alpha=0,At.transform(e)}},B4=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function z4(t){return isNaN(t)&&typeof t=="string"&&(t.match(ig)?.length||0)+(t.match(B4)?.length||0)>0}const LO="number",VO="color",L4="var",V4="var(",Rx="${}",U4=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function wl(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},a=[];let u=0;const f=e.replace(U4,h=>(At.test(h)?(r.color.push(u),a.push(VO),n.push(At.parse(h))):h.startsWith(V4)?(r.var.push(u),a.push(L4),n.push(h)):(r.number.push(u),a.push(LO),n.push(parseFloat(h))),++u,Rx)).split(Rx);return{values:n,split:f,indexes:r,types:a}}function UO(t){return wl(t).values}function KO(t){const{split:e,types:n}=wl(t),r=e.length;return a=>{let u="";for(let c=0;c<r;c++)if(u+=e[c],a[c]!==void 0){const f=n[c];f===LO?u+=rl(a[c]):f===VO?u+=At.transform(a[c]):u+=a[c]}return u}}const K4=t=>typeof t=="number"?0:At.test(t)?At.getAnimatableNone(t):t;function q4(t){const e=UO(t);return KO(t)(e.map(K4))}const Ur={test:z4,parse:UO,createTransformer:KO,getAnimatableNone:q4};function Rp(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function P4({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let a=0,u=0,c=0;if(!e)a=u=c=n;else{const f=n<.5?n*(1+e):n+e-n*e,h=2*n-f;a=Rp(h,f,t+1/3),u=Rp(h,f,t),c=Rp(h,f,t-1/3)}return{red:Math.round(a*255),green:Math.round(u*255),blue:Math.round(c*255),alpha:r}}function tf(t,e){return n=>n>0?e:t}const rt=(t,e,n)=>t+(e-t)*n,Cp=(t,e,n)=>{const r=t*t,a=n*(e*e-r)+r;return a<0?0:Math.sqrt(a)},I4=[_m,gs,To],H4=t=>I4.find(e=>e.test(t));function Cx(t){const e=H4(t);if(!e)return!1;let n=e.parse(t);return e===To&&(n=P4(n)),n}const kx=(t,e)=>{const n=Cx(t),r=Cx(e);if(!n||!r)return tf(t,e);const a={...n};return u=>(a.red=Cp(n.red,r.red,u),a.green=Cp(n.green,r.green,u),a.blue=Cp(n.blue,r.blue,u),a.alpha=rt(n.alpha,r.alpha,u),gs.transform(a))},Rm=new Set(["none","hidden"]);function F4(t,e){return Rm.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function G4(t,e){return n=>rt(t,e,n)}function sg(t){return typeof t=="number"?G4:typeof t=="string"?ng(t)?tf:At.test(t)?kx:X4:Array.isArray(t)?qO:typeof t=="object"?At.test(t)?kx:Y4:tf}function qO(t,e){const n=[...t],r=n.length,a=t.map((u,c)=>sg(u)(u,e[c]));return u=>{for(let c=0;c<r;c++)n[c]=a[c](u);return n}}function Y4(t,e){const n={...t,...e},r={};for(const a in n)t[a]!==void 0&&e[a]!==void 0&&(r[a]=sg(t[a])(t[a],e[a]));return a=>{for(const u in r)n[u]=r[u](a);return n}}function J4(t,e){const n=[],r={color:0,var:0,number:0};for(let a=0;a<e.values.length;a++){const u=e.types[a],c=t.indexes[u][r[u]],f=t.values[c]??0;n[a]=f,r[u]++}return n}const X4=(t,e)=>{const n=Ur.createTransformer(e),r=wl(t),a=wl(e);return r.indexes.var.length===a.indexes.var.length&&r.indexes.color.length===a.indexes.color.length&&r.indexes.number.length>=a.indexes.number.length?Rm.has(t)&&!a.values.length||Rm.has(e)&&!r.values.length?F4(t,e):zl(qO(J4(r,a),a.values),n):tf(t,e)};function PO(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?rt(t,e,n):sg(t)(t,e)}const Z4=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>it.update(e,n),stop:()=>Vr(e),now:()=>Ht.isProcessing?Ht.timestamp:fn.now()}},IO=(t,e,n=10)=>{let r="";const a=Math.max(Math.round(e/n),2);for(let u=0;u<a;u++)r+=Math.round(t(u/(a-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},nf=2e4;function og(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<nf;)e+=n,r=t.next(e);return e>=nf?1/0:e}function Q4(t,e=100,n){const r=n({...t,keyframes:[0,e]}),a=Math.min(og(r),nf);return{type:"keyframes",ease:u=>r.next(a*u).value/e,duration:qn(a)}}const W4=5;function HO(t,e,n){const r=Math.max(e-W4,0);return AO(n-t(r),e-r)}const lt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},kp=.001;function eU({duration:t=lt.duration,bounce:e=lt.bounce,velocity:n=lt.velocity,mass:r=lt.mass}){let a,u,c=1-e;c=Zi(lt.minDamping,lt.maxDamping,c),t=Zi(lt.minDuration,lt.maxDuration,qn(t)),c<1?(a=m=>{const y=m*c,g=y*t,v=y-n,S=Cm(m,c),x=Math.exp(-g);return kp-v/S*x},u=m=>{const g=m*c*t,v=g*n+n,S=Math.pow(c,2)*Math.pow(m,2)*t,x=Math.exp(-g),T=Cm(Math.pow(m,2),c);return(-a(m)+kp>0?-1:1)*((v-S)*x)/T}):(a=m=>{const y=Math.exp(-m*t),g=(m-n)*t+1;return-kp+y*g},u=m=>{const y=Math.exp(-m*t),g=(n-m)*(t*t);return y*g});const f=5/t,h=nU(a,u,f);if(t=pi(t),isNaN(h))return{stiffness:lt.stiffness,damping:lt.damping,duration:t};{const m=Math.pow(h,2)*r;return{stiffness:m,damping:c*2*Math.sqrt(r*m),duration:t}}}const tU=12;function nU(t,e,n){let r=n;for(let a=1;a<tU;a++)r=r-t(r)/e(r);return r}function Cm(t,e){return t*Math.sqrt(1-e*e)}const iU=["duration","bounce"],rU=["stiffness","damping","mass"];function Mx(t,e){return e.some(n=>t[n]!==void 0)}function sU(t){let e={velocity:lt.velocity,stiffness:lt.stiffness,damping:lt.damping,mass:lt.mass,isResolvedFromDuration:!1,...t};if(!Mx(t,rU)&&Mx(t,iU))if(t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),a=r*r,u=2*Zi(.05,1,1-(t.bounce||0))*Math.sqrt(a);e={...e,mass:lt.mass,stiffness:a,damping:u}}else{const n=eU(t);e={...e,...n,mass:lt.mass},e.isResolvedFromDuration=!0}return e}function rf(t=lt.visualDuration,e=lt.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:a}=n;const u=n.keyframes[0],c=n.keyframes[n.keyframes.length-1],f={done:!1,value:u},{stiffness:h,damping:m,mass:y,duration:g,velocity:v,isResolvedFromDuration:S}=sU({...n,velocity:-qn(n.velocity||0)}),x=v||0,T=m/(2*Math.sqrt(h*y)),M=c-u,C=qn(Math.sqrt(h/y)),_=Math.abs(M)<5;r||(r=_?lt.restSpeed.granular:lt.restSpeed.default),a||(a=_?lt.restDelta.granular:lt.restDelta.default);let R;if(T<1){const I=Cm(C,T);R=ee=>{const J=Math.exp(-T*C*ee);return c-J*((x+T*C*M)/I*Math.sin(I*ee)+M*Math.cos(I*ee))}}else if(T===1)R=I=>c-Math.exp(-C*I)*(M+(x+C*M)*I);else{const I=C*Math.sqrt(T*T-1);R=ee=>{const J=Math.exp(-T*C*ee),X=Math.min(I*ee,300);return c-J*((x+T*C*M)*Math.sinh(X)+I*M*Math.cosh(X))/I}}const G={calculatedDuration:S&&g||null,next:I=>{const ee=R(I);if(S)f.done=I>=g;else{let J=I===0?x:0;T<1&&(J=I===0?pi(x):HO(R,I,ee));const X=Math.abs(J)<=r,he=Math.abs(c-ee)<=a;f.done=X&&he}return f.value=f.done?c:ee,f},toString:()=>{const I=Math.min(og(G),nf),ee=IO(J=>G.next(I*J).value,I,30);return I+"ms "+ee},toTransition:()=>{}};return G}rf.applyToOptions=t=>{const e=Q4(t,100,rf);return t.ease=e.ease,t.duration=pi(e.duration),t.type="keyframes",t};function km({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:a=10,bounceStiffness:u=500,modifyTarget:c,min:f,max:h,restDelta:m=.5,restSpeed:y}){const g=t[0],v={done:!1,value:g},S=X=>f!==void 0&&X<f||h!==void 0&&X>h,x=X=>f===void 0?h:h===void 0||Math.abs(f-X)<Math.abs(h-X)?f:h;let T=n*e;const M=g+T,C=c===void 0?M:c(M);C!==M&&(T=C-g);const _=X=>-T*Math.exp(-X/r),R=X=>C+_(X),G=X=>{const he=_(X),pe=R(X);v.done=Math.abs(he)<=m,v.value=v.done?C:pe};let I,ee;const J=X=>{S(v.value)&&(I=X,ee=rf({keyframes:[v.value,x(v.value)],velocity:HO(R,X,v.value),damping:a,stiffness:u,restDelta:m,restSpeed:y}))};return J(0),{calculatedDuration:null,next:X=>{let he=!1;return!ee&&I===void 0&&(he=!0,G(X),J(X)),I!==void 0&&X>=I?ee.next(X-I):(!he&&G(X),v)}}}function oU(t,e,n){const r=[],a=n||Qi.mix||PO,u=t.length-1;for(let c=0;c<u;c++){let f=a(t[c],t[c+1]);if(e){const h=Array.isArray(e)?e[c]||Pn:e;f=zl(h,f)}r.push(f)}return r}function aU(t,e,{clamp:n=!0,ease:r,mixer:a}={}){const u=t.length;if(Xy(u===e.length),u===1)return()=>e[0];if(u===2&&e[0]===e[1])return()=>e[1];const c=t[0]===t[1];t[0]>t[u-1]&&(t=[...t].reverse(),e=[...e].reverse());const f=oU(e,r,a),h=f.length,m=y=>{if(c&&y<t[0])return e[0];let g=0;if(h>1)for(;g<t.length-2&&!(y<t[g+1]);g++);const v=vl(t[g],t[g+1],y);return f[g](v)};return n?y=>m(Zi(t[0],t[u-1],y)):m}function lU(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const a=vl(0,e,r);t.push(rt(n,1,a))}}function uU(t){const e=[0];return lU(e,t.length-1),e}function cU(t,e){return t.map(n=>n*e)}function fU(t,e){return t.map(()=>e||NO).splice(0,t.length-1)}function sl({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const a=x4(r)?r.map(Ox):Ox(r),u={done:!1,value:e[0]},c=cU(n&&n.length===e.length?n:uU(e),t),f=aU(c,e,{ease:Array.isArray(a)?a:fU(e,a)});return{calculatedDuration:t,next:h=>(u.value=f(h),u.done=h>=t,u)}}const dU=t=>t!==null;function ag(t,{repeat:e,repeatType:n="loop"},r,a=1){const u=t.filter(dU),f=a<0||e&&n!=="loop"&&e%2===1?0:u.length-1;return!f||r===void 0?u[f]:r}const hU={decay:km,inertia:km,tween:sl,keyframes:sl,spring:rf};function FO(t){typeof t.type=="string"&&(t.type=hU[t.type])}class lg{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const pU=t=>t/100;class ug extends lg{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==fn.now()&&this.tick(fn.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;FO(e);const{type:n=sl,repeat:r=0,repeatDelay:a=0,repeatType:u,velocity:c=0}=e;let{keyframes:f}=e;const h=n||sl;h!==sl&&typeof f[0]!="number"&&(this.mixKeyframes=zl(pU,PO(f[0],f[1])),f=[0,100]);const m=h({...e,keyframes:f});u==="mirror"&&(this.mirroredGenerator=h({...e,keyframes:[...f].reverse(),velocity:-c})),m.calculatedDuration===null&&(m.calculatedDuration=og(m));const{calculatedDuration:y}=m;this.calculatedDuration=y,this.resolvedDuration=y+a,this.totalDuration=this.resolvedDuration*(r+1)-a,this.generator=m}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:r,totalDuration:a,mixKeyframes:u,mirroredGenerator:c,resolvedDuration:f,calculatedDuration:h}=this;if(this.startTime===null)return r.next(0);const{delay:m=0,keyframes:y,repeat:g,repeatType:v,repeatDelay:S,type:x,onUpdate:T,finalKeyframe:M}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-a/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const C=this.currentTime-m*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?C<0:C>a;this.currentTime=Math.max(C,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let R=this.currentTime,G=r;if(g){const X=Math.min(this.currentTime,a)/f;let he=Math.floor(X),pe=X%1;!pe&&X>=1&&(pe=1),pe===1&&he--,he=Math.min(he,g+1),!!(he%2)&&(v==="reverse"?(pe=1-pe,S&&(pe-=S/f)):v==="mirror"&&(G=c)),R=Zi(0,1,pe)*f}const I=_?{done:!1,value:y[0]}:G.next(R);u&&(I.value=u(I.value));let{done:ee}=I;!_&&h!==null&&(ee=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const J=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&ee);return J&&x!==km&&(I.value=ag(y,this.options,M,this.speed)),T&&T(I.value),J&&this.finish(),I}then(e,n){return this.finished.then(e,n)}get duration(){return qn(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+qn(e)}get time(){return qn(this.currentTime)}set time(e){e=pi(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(fn.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=qn(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Z4,startTime:n}=this.options;this.driver||(this.driver=e(a=>this.tick(a))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(fn.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function mU(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const bs=t=>t*180/Math.PI,Mm=t=>{const e=bs(Math.atan2(t[1],t[0]));return Dm(e)},yU={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Mm,rotateZ:Mm,skewX:t=>bs(Math.atan(t[1])),skewY:t=>bs(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Dm=t=>(t=t%360,t<0&&(t+=360),t),Dx=Mm,Nx=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),$x=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),gU={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Nx,scaleY:$x,scale:t=>(Nx(t)+$x(t))/2,rotateX:t=>Dm(bs(Math.atan2(t[6],t[5]))),rotateY:t=>Dm(bs(Math.atan2(-t[2],t[0]))),rotateZ:Dx,rotate:Dx,skewX:t=>bs(Math.atan(t[4])),skewY:t=>bs(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Nm(t){return t.includes("scale")?1:0}function $m(t,e){if(!t||t==="none")return Nm(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,a;if(n)r=gU,a=n;else{const f=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=yU,a=f}if(!a)return Nm(e);const u=r[e],c=a[1].split(",").map(vU);return typeof u=="function"?u(c):c[u]}const bU=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return $m(n,e)};function vU(t){return parseFloat(t.trim())}const Qo=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Wo=new Set(Qo),jx=t=>t===Zo||t===de,SU=new Set(["x","y","z"]),wU=Qo.filter(t=>!SU.has(t));function xU(t){const e=[];return wU.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const ws={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>$m(e,"x"),y:(t,{transform:e})=>$m(e,"y")};ws.translateX=ws.x;ws.translateY=ws.y;const xs=new Set;let jm=!1,Bm=!1,zm=!1;function GO(){if(Bm){const t=Array.from(xs).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const a=xU(r);a.length&&(n.set(r,a),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const a=n.get(r);a&&a.forEach(([u,c])=>{r.getValue(u)?.set(c)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}Bm=!1,jm=!1,xs.forEach(t=>t.complete(zm)),xs.clear()}function YO(){xs.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Bm=!0)})}function TU(){zm=!0,YO(),GO(),zm=!1}class cg{constructor(e,n,r,a,u,c=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=r,this.motionValue=a,this.element=u,this.isAsync=c}scheduleResolve(){this.state="scheduled",this.isAsync?(xs.add(this),jm||(jm=!0,it.read(YO),it.resolveKeyframes(GO))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:r,motionValue:a}=this;if(e[0]===null){const u=a?.get(),c=e[e.length-1];if(u!==void 0)e[0]=u;else if(r&&n){const f=r.readValue(n,c);f!=null&&(e[0]=f)}e[0]===void 0&&(e[0]=c),a&&u===void 0&&a.set(e[0])}mU(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),xs.delete(this)}cancel(){this.state==="scheduled"&&(xs.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const AU=t=>t.startsWith("--");function EU(t,e,n){AU(e)?t.style.setProperty(e,n):t.style[e]=n}const OU=Zy(()=>window.ScrollTimeline!==void 0),_U={};function RU(t,e){const n=Zy(t);return()=>_U[e]??n()}const JO=RU(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),el=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,Bx={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:el([0,.65,.55,1]),circOut:el([.55,0,1,.45]),backIn:el([.31,.01,.66,-.59]),backOut:el([.33,1.53,.69,.99])};function XO(t,e){if(t)return typeof t=="function"?JO()?IO(t,e):"ease-out":$O(t)?el(t):Array.isArray(t)?t.map(n=>XO(n,e)||Bx.easeOut):Bx[t]}function CU(t,e,n,{delay:r=0,duration:a=300,repeat:u=0,repeatType:c="loop",ease:f="easeOut",times:h}={},m=void 0){const y={[e]:n};h&&(y.offset=h);const g=XO(f,a);Array.isArray(g)&&(y.easing=g);const v={delay:r,duration:a,easing:Array.isArray(g)?"linear":g,fill:"both",iterations:u+1,direction:c==="reverse"?"alternate":"normal"};return m&&(v.pseudoElement=m),t.animate(y,v)}function ZO(t){return typeof t=="function"&&"applyToOptions"in t}function kU({type:t,...e}){return ZO(t)&&JO()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class MU extends lg{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:r,keyframes:a,pseudoElement:u,allowFlatten:c=!1,finalKeyframe:f,onComplete:h}=e;this.isPseudoElement=!!u,this.allowFlatten=c,this.options=e,Xy(typeof e.type!="string");const m=kU(e);this.animation=CU(n,r,a,m,u),m.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!u){const y=ag(a,this.options,f,this.speed);this.updateMotionValue?this.updateMotionValue(y):EU(n,r,y),this.animation.cancel()}h?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return qn(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+qn(e)}get time(){return qn(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=pi(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&OU()?(this.animation.timeline=e,Pn):n(this)}}const QO={anticipate:kO,backInOut:CO,circInOut:DO};function DU(t){return t in QO}function NU(t){typeof t.ease=="string"&&DU(t.ease)&&(t.ease=QO[t.ease])}const zx=10;class $U extends MU{constructor(e){NU(e),FO(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:r,onComplete:a,element:u,...c}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const f=new ug({...c,autoplay:!1}),h=pi(this.finishedTime??this.time);n.setWithVelocity(f.sample(h-zx).value,f.sample(h).value,zx),f.stop()}}const Lx=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Ur.test(t)||t==="0")&&!t.startsWith("url("));function jU(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function BU(t,e,n,r){const a=t[0];if(a===null)return!1;if(e==="display"||e==="visibility")return!0;const u=t[t.length-1],c=Lx(a,e),f=Lx(u,e);return!c||!f?!1:jU(t)||(n==="spring"||ZO(n))&&r}function Lm(t){t.duration=0,t.type="keyframes"}const zU=new Set(["opacity","clipPath","filter","transform"]),LU=Zy(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function VU(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:a,damping:u,type:c}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:h,transformTemplate:m}=e.owner.getProps();return LU()&&n&&zU.has(n)&&(n!=="transform"||!m)&&!h&&!r&&a!=="mirror"&&u!==0&&c!=="inertia"}const UU=40;class KU extends lg{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:a=0,repeatDelay:u=0,repeatType:c="loop",keyframes:f,name:h,motionValue:m,element:y,...g}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=fn.now();const v={autoplay:e,delay:n,type:r,repeat:a,repeatDelay:u,repeatType:c,name:h,motionValue:m,element:y,...g},S=y?.KeyframeResolver||cg;this.keyframeResolver=new S(f,(x,T,M)=>this.onKeyframesResolved(x,T,v,!M),h,m,y),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,r,a){this.keyframeResolver=void 0;const{name:u,type:c,velocity:f,delay:h,isHandoff:m,onUpdate:y}=r;this.resolvedAt=fn.now(),BU(e,u,c,f)||((Qi.instantAnimations||!h)&&y?.(ag(e,r,n)),e[0]=e[e.length-1],Lm(r),r.repeat=0);const v={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>UU?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},S=!m&&VU(v)?new $U({...v,element:v.motionValue.owner.current}):new ug(v);S.finished.then(()=>this.notifyFinished()).catch(Pn),this.pendingTimeline&&(this.stopTimeline=S.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=S}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),TU()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const qU=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function PU(t){const e=qU.exec(t);if(!e)return[,];const[,n,r,a]=e;return[`--${n??r}`,a]}function WO(t,e,n=1){const[r,a]=PU(t);if(!r)return;const u=window.getComputedStyle(e).getPropertyValue(r);if(u){const c=u.trim();return wO(c)?parseFloat(c):c}return ng(a)?WO(a,e,n+1):a}function fg(t,e){return t?.[e]??t?.default??t}const e_=new Set(["width","height","top","left","right","bottom",...Qo]),IU={test:t=>t==="auto",parse:t=>t},t_=t=>e=>e.test(t),n_=[Zo,de,mi,_r,j4,$4,IU],Vx=t=>n_.find(t_(t));function HU(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||TO(t):!0}const FU=new Set(["brightness","contrast","saturate","opacity"]);function GU(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(ig)||[];if(!r)return t;const a=n.replace(r,"");let u=FU.has(e)?1:0;return r!==n&&(u*=100),e+"("+u+a+")"}const YU=/\b([a-z-]*)\(.*?\)/gu,Vm={...Ur,getAnimatableNone:t=>{const e=t.match(YU);return e?e.map(GU).join(" "):t}},Ux={...Zo,transform:Math.round},JU={rotate:_r,rotateX:_r,rotateY:_r,rotateZ:_r,scale:bc,scaleX:bc,scaleY:bc,scaleZ:bc,skew:_r,skewX:_r,skewY:_r,distance:de,translateX:de,translateY:de,translateZ:de,x:de,y:de,z:de,perspective:de,transformPerspective:de,opacity:Sl,originX:_x,originY:_x,originZ:de},dg={borderWidth:de,borderTopWidth:de,borderRightWidth:de,borderBottomWidth:de,borderLeftWidth:de,borderRadius:de,radius:de,borderTopLeftRadius:de,borderTopRightRadius:de,borderBottomRightRadius:de,borderBottomLeftRadius:de,width:de,maxWidth:de,height:de,maxHeight:de,top:de,right:de,bottom:de,left:de,padding:de,paddingTop:de,paddingRight:de,paddingBottom:de,paddingLeft:de,margin:de,marginTop:de,marginRight:de,marginBottom:de,marginLeft:de,backgroundPositionX:de,backgroundPositionY:de,...JU,zIndex:Ux,fillOpacity:Sl,strokeOpacity:Sl,numOctaves:Ux},XU={...dg,color:At,backgroundColor:At,outlineColor:At,fill:At,stroke:At,borderColor:At,borderTopColor:At,borderRightColor:At,borderBottomColor:At,borderLeftColor:At,filter:Vm,WebkitFilter:Vm},i_=t=>XU[t];function r_(t,e){let n=i_(t);return n!==Vm&&(n=Ur),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const ZU=new Set(["auto","none","0"]);function QU(t,e,n){let r=0,a;for(;r<t.length&&!a;){const u=t[r];typeof u=="string"&&!ZU.has(u)&&wl(u).values.length&&(a=t[r]),r++}if(a&&n)for(const u of e)t[u]=r_(n,a)}class WU extends cg{constructor(e,n,r,a,u){super(e,n,r,a,u,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let h=0;h<e.length;h++){let m=e[h];if(typeof m=="string"&&(m=m.trim(),ng(m))){const y=WO(m,n.current);y!==void 0&&(e[h]=y),h===e.length-1&&(this.finalKeyframe=m)}}if(this.resolveNoneKeyframes(),!e_.has(r)||e.length!==2)return;const[a,u]=e,c=Vx(a),f=Vx(u);if(c!==f)if(jx(c)&&jx(f))for(let h=0;h<e.length;h++){const m=e[h];typeof m=="string"&&(e[h]=parseFloat(m))}else ws[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let a=0;a<e.length;a++)(e[a]===null||HU(e[a]))&&r.push(a);r.length&&QU(e,r,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ws[r](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const a=n[n.length-1];a!==void 0&&e.getValue(r,a).jump(a,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const a=e.getValue(n);a&&a.jump(this.measuredOrigin,!1);const u=r.length-1,c=r[u];r[u]=ws[n](e.measureViewportBox(),window.getComputedStyle(e.current)),c!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=c),this.removedTransforms?.length&&this.removedTransforms.forEach(([f,h])=>{e.getValue(f).set(h)}),this.resolveNoneKeyframes()}}function eK(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;const a=n?.[t]??r.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t)}const s_=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function tK(t){return xO(t)&&"offsetHeight"in t}const Kx=30,nK=t=>!isNaN(parseFloat(t));class iK{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const a=fn.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const u of this.dependents)u.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=fn.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=nK(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Qy);const r=this.events[e].add(n);return e==="change"?()=>{r(),it.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=fn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Kx)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Kx);return AO(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Io(t,e){return new iK(t,e)}const{schedule:hg}=jO(queueMicrotask,!1),Zn={x:!1,y:!1};function o_(){return Zn.x||Zn.y}function rK(t){return t==="x"||t==="y"?Zn[t]?null:(Zn[t]=!0,()=>{Zn[t]=!1}):Zn.x||Zn.y?null:(Zn.x=Zn.y=!0,()=>{Zn.x=Zn.y=!1})}function a_(t,e){const n=eK(t),r=new AbortController,a={passive:!0,...e,signal:r.signal};return[n,a,()=>r.abort()]}function qx(t){return!(t.pointerType==="touch"||o_())}function sK(t,e,n={}){const[r,a,u]=a_(t,n),c=f=>{if(!qx(f))return;const{target:h}=f,m=e(h,f);if(typeof m!="function"||!h)return;const y=g=>{qx(g)&&(m(g),h.removeEventListener("pointerleave",y))};h.addEventListener("pointerleave",y,a)};return r.forEach(f=>{f.addEventListener("pointerenter",c,a)}),u}const l_=(t,e)=>e?t===e?!0:l_(t,e.parentElement):!1,pg=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,oK=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function aK(t){return oK.has(t.tagName)||t.tabIndex!==-1}const Dc=new WeakSet;function Px(t){return e=>{e.key==="Enter"&&t(e)}}function Mp(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const lK=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=Px(()=>{if(Dc.has(n))return;Mp(n,"down");const a=Px(()=>{Mp(n,"up")}),u=()=>Mp(n,"cancel");n.addEventListener("keyup",a,e),n.addEventListener("blur",u,e)});n.addEventListener("keydown",r,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),e)};function Ix(t){return pg(t)&&!o_()}function uK(t,e,n={}){const[r,a,u]=a_(t,n),c=f=>{const h=f.currentTarget;if(!Ix(f))return;Dc.add(h);const m=e(h,f),y=(S,x)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",v),Dc.has(h)&&Dc.delete(h),Ix(S)&&typeof m=="function"&&m(S,{success:x})},g=S=>{y(S,h===window||h===document||n.useGlobalTarget||l_(h,S.target))},v=S=>{y(S,!1)};window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",v,a)};return r.forEach(f=>{(n.useGlobalTarget?window:f).addEventListener("pointerdown",c,a),tK(f)&&(f.addEventListener("focus",m=>lK(m,a)),!aK(f)&&!f.hasAttribute("tabindex")&&(f.tabIndex=0))}),u}function u_(t){return xO(t)&&"ownerSVGElement"in t}function cK(t){return u_(t)&&t.tagName==="svg"}const Yt=t=>!!(t&&t.getVelocity),fK=[...n_,At,Ur],dK=t=>fK.find(t_(t)),c_=$.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function hK(t=!0){const e=$.useContext(Gy);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:a}=e,u=$.useId();$.useEffect(()=>{if(t)return a(u)},[t]);const c=$.useCallback(()=>t&&r&&r(u),[u,r,t]);return!n&&r?[!1,c]:[!0]}const f_=$.createContext({strict:!1}),Hx={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Ho={};for(const t in Hx)Ho[t]={isEnabled:e=>Hx[t].some(n=>!!e[n])};function pK(t){for(const e in t)Ho[e]={...Ho[e],...t[e]}}const mK=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function sf(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||mK.has(t)}let d_=t=>!sf(t);function yK(t){typeof t=="function"&&(d_=e=>e.startsWith("on")?!sf(e):t(e))}try{yK(require("@emotion/is-prop-valid").default)}catch{}function gK(t,e,n){const r={};for(const a in t)a==="values"&&typeof t.values=="object"||(d_(a)||n===!0&&sf(a)||!e&&!sf(a)||t.draggable&&a.startsWith("onDrag"))&&(r[a]=t[a]);return r}const $f=$.createContext({});function jf(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function xl(t){return typeof t=="string"||Array.isArray(t)}const mg=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],yg=["initial",...mg];function Bf(t){return jf(t.animate)||yg.some(e=>xl(t[e]))}function h_(t){return!!(Bf(t)||t.variants)}function bK(t,e){if(Bf(t)){const{initial:n,animate:r}=t;return{initial:n===!1||xl(n)?n:void 0,animate:xl(r)?r:void 0}}return t.inherit!==!1?e:{}}function vK(t){const{initial:e,animate:n}=bK(t,$.useContext($f));return $.useMemo(()=>({initial:e,animate:n}),[Fx(e),Fx(n)])}function Fx(t){return Array.isArray(t)?t.join(" "):t}const Tl={};function SK(t){for(const e in t)Tl[e]=t[e],tg(e)&&(Tl[e].isCSSVariable=!0)}function p_(t,{layout:e,layoutId:n}){return Wo.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Tl[t]||t==="opacity")}const wK={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},xK=Qo.length;function TK(t,e,n){let r="",a=!0;for(let u=0;u<xK;u++){const c=Qo[u],f=t[c];if(f===void 0)continue;let h=!0;if(typeof f=="number"?h=f===(c.startsWith("scale")?1:0):h=parseFloat(f)===0,!h||n){const m=s_(f,dg[c]);if(!h){a=!1;const y=wK[c]||c;r+=`${y}(${m}) `}n&&(e[c]=m)}}return r=r.trim(),n?r=n(e,a?"":r):a&&(r="none"),r}function gg(t,e,n){const{style:r,vars:a,transformOrigin:u}=t;let c=!1,f=!1;for(const h in e){const m=e[h];if(Wo.has(h)){c=!0;continue}else if(tg(h)){a[h]=m;continue}else{const y=s_(m,dg[h]);h.startsWith("origin")?(f=!0,u[h]=y):r[h]=y}}if(e.transform||(c||n?r.transform=TK(e,t.transform,n):r.transform&&(r.transform="none")),f){const{originX:h="50%",originY:m="50%",originZ:y=0}=u;r.transformOrigin=`${h} ${m} ${y}`}}const bg=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function m_(t,e,n){for(const r in e)!Yt(e[r])&&!p_(r,n)&&(t[r]=e[r])}function AK({transformTemplate:t},e){return $.useMemo(()=>{const n=bg();return gg(n,e,t),Object.assign({},n.vars,n.style)},[e])}function EK(t,e){const n=t.style||{},r={};return m_(r,n,t),Object.assign(r,AK(t,e)),r}function OK(t,e){const n={},r=EK(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=r,n}const _K={offset:"stroke-dashoffset",array:"stroke-dasharray"},RK={offset:"strokeDashoffset",array:"strokeDasharray"};function CK(t,e,n=1,r=0,a=!0){t.pathLength=1;const u=a?_K:RK;t[u.offset]=de.transform(-r);const c=de.transform(e),f=de.transform(n);t[u.array]=`${c} ${f}`}function y_(t,{attrX:e,attrY:n,attrScale:r,pathLength:a,pathSpacing:u=1,pathOffset:c=0,...f},h,m,y){if(gg(t,f,m),h){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:g,style:v}=t;g.transform&&(v.transform=g.transform,delete g.transform),(v.transform||g.transformOrigin)&&(v.transformOrigin=g.transformOrigin??"50% 50%",delete g.transformOrigin),v.transform&&(v.transformBox=y?.transformBox??"fill-box",delete g.transformBox),e!==void 0&&(g.x=e),n!==void 0&&(g.y=n),r!==void 0&&(g.scale=r),a!==void 0&&CK(g,a,u,c,!1)}const g_=()=>({...bg(),attrs:{}}),b_=t=>typeof t=="string"&&t.toLowerCase()==="svg";function kK(t,e,n,r){const a=$.useMemo(()=>{const u=g_();return y_(u,e,b_(r),t.transformTemplate,t.style),{...u.attrs,style:{...u.style}}},[e]);if(t.style){const u={};m_(u,t.style,t),a.style={...u,...a.style}}return a}const MK=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function vg(t){return typeof t!="string"||t.includes("-")?!1:!!(MK.indexOf(t)>-1||/[A-Z]/u.test(t))}function DK(t,e,n,{latestValues:r},a,u=!1){const f=(vg(t)?kK:OK)(e,r,a,t),h=gK(e,typeof t=="string",u),m=t!==$.Fragment?{...h,...f,ref:n}:{},{children:y}=e,g=$.useMemo(()=>Yt(y)?y.get():y,[y]);return $.createElement(t,{...m,children:g})}function Gx(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function Sg(t,e,n,r){if(typeof e=="function"){const[a,u]=Gx(r);e=e(n!==void 0?n:t.custom,a,u)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[a,u]=Gx(r);e=e(n!==void 0?n:t.custom,a,u)}return e}function Nc(t){return Yt(t)?t.get():t}function NK({scrapeMotionValuesFromProps:t,createRenderState:e},n,r,a){return{latestValues:$K(n,r,a,t),renderState:e()}}function $K(t,e,n,r){const a={},u=r(t,{});for(const v in u)a[v]=Nc(u[v]);let{initial:c,animate:f}=t;const h=Bf(t),m=h_(t);e&&m&&!h&&t.inherit!==!1&&(c===void 0&&(c=e.initial),f===void 0&&(f=e.animate));let y=n?n.initial===!1:!1;y=y||c===!1;const g=y?f:c;if(g&&typeof g!="boolean"&&!jf(g)){const v=Array.isArray(g)?g:[g];for(let S=0;S<v.length;S++){const x=Sg(t,v[S]);if(x){const{transitionEnd:T,transition:M,...C}=x;for(const _ in C){let R=C[_];if(Array.isArray(R)){const G=y?R.length-1:0;R=R[G]}R!==null&&(a[_]=R)}for(const _ in T)a[_]=T[_]}}}return a}const v_=t=>(e,n)=>{const r=$.useContext($f),a=$.useContext(Gy),u=()=>NK(t,e,r,a);return n?u():p4(u)};function wg(t,e,n){const{style:r}=t,a={};for(const u in r)(Yt(r[u])||e.style&&Yt(e.style[u])||p_(u,t)||n?.getValue(u)?.liveStyle!==void 0)&&(a[u]=r[u]);return a}const jK=v_({scrapeMotionValuesFromProps:wg,createRenderState:bg});function S_(t,e,n){const r=wg(t,e,n);for(const a in t)if(Yt(t[a])||Yt(e[a])){const u=Qo.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;r[u]=t[a]}return r}const BK=v_({scrapeMotionValuesFromProps:S_,createRenderState:g_}),zK=Symbol.for("motionComponentSymbol");function Ao(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function LK(t,e,n){return $.useCallback(r=>{r&&t.onMount&&t.onMount(r),e&&(r?e.mount(r):e.unmount()),n&&(typeof n=="function"?n(r):Ao(n)&&(n.current=r))},[e])}const xg=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),VK="framerAppearId",w_="data-"+xg(VK),x_=$.createContext({});function UK(t,e,n,r,a){const{visualElement:u}=$.useContext($f),c=$.useContext(f_),f=$.useContext(Gy),h=$.useContext(c_).reducedMotion,m=$.useRef(null);r=r||c.renderer,!m.current&&r&&(m.current=r(t,{visualState:e,parent:u,props:n,presenceContext:f,blockInitialAnimation:f?f.initial===!1:!1,reducedMotionConfig:h}));const y=m.current,g=$.useContext(x_);y&&!y.projection&&a&&(y.type==="html"||y.type==="svg")&&KK(m.current,n,a,g);const v=$.useRef(!1);$.useInsertionEffect(()=>{y&&v.current&&y.update(n,f)});const S=n[w_],x=$.useRef(!!S&&!window.MotionHandoffIsComplete?.(S)&&window.MotionHasOptimisedAnimation?.(S));return m4(()=>{y&&(v.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),y.scheduleRenderMicrotask(),x.current&&y.animationState&&y.animationState.animateChanges())}),$.useEffect(()=>{y&&(!x.current&&y.animationState&&y.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(S)}),x.current=!1),y.enteringChildren=void 0)}),y}function KK(t,e,n,r){const{layoutId:a,layout:u,drag:c,dragConstraints:f,layoutScroll:h,layoutRoot:m,layoutCrossfade:y}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:T_(t.parent)),t.projection.setOptions({layoutId:a,layout:u,alwaysMeasureLayout:!!c||f&&Ao(f),visualElement:t,animationType:typeof u=="string"?u:"both",initialPromotionConfig:r,crossfade:y,layoutScroll:h,layoutRoot:m})}function T_(t){if(t)return t.options.allowProjection!==!1?t.projection:T_(t.parent)}function Dp(t,{forwardMotionProps:e=!1}={},n,r){n&&pK(n);const a=vg(t)?BK:jK;function u(f,h){let m;const y={...$.useContext(c_),...f,layoutId:qK(f)},{isStatic:g}=y,v=vK(f),S=a(f,g);if(!g&&Fy){PK();const x=IK(y);m=x.MeasureLayout,v.visualElement=UK(t,S,y,r,x.ProjectionNode)}return F.jsxs($f.Provider,{value:v,children:[m&&v.visualElement?F.jsx(m,{visualElement:v.visualElement,...y}):null,DK(t,f,LK(S,v.visualElement,h),S,g,e)]})}u.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=$.forwardRef(u);return c[zK]=t,c}function qK({layoutId:t}){const e=$.useContext(SO).id;return e&&t!==void 0?e+"-"+t:t}function PK(t,e){$.useContext(f_).strict}function IK(t){const{drag:e,layout:n}=Ho;if(!e&&!n)return{};const r={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function HK(t,e){if(typeof Proxy>"u")return Dp;const n=new Map,r=(u,c)=>Dp(u,c,t,e),a=(u,c)=>r(u,c);return new Proxy(a,{get:(u,c)=>c==="create"?r:(n.has(c)||n.set(c,Dp(c,void 0,t,e)),n.get(c))})}function A_({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function FK({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function GK(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Np(t){return t===void 0||t===1}function Um({scale:t,scaleX:e,scaleY:n}){return!Np(t)||!Np(e)||!Np(n)}function ms(t){return Um(t)||E_(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function E_(t){return Yx(t.x)||Yx(t.y)}function Yx(t){return t&&t!=="0%"}function of(t,e,n){const r=t-n,a=e*r;return n+a}function Jx(t,e,n,r,a){return a!==void 0&&(t=of(t,a,r)),of(t,n,r)+e}function Km(t,e=0,n=1,r,a){t.min=Jx(t.min,e,n,r,a),t.max=Jx(t.max,e,n,r,a)}function O_(t,{x:e,y:n}){Km(t.x,e.translate,e.scale,e.originPoint),Km(t.y,n.translate,n.scale,n.originPoint)}const Xx=.999999999999,Zx=1.0000000000001;function YK(t,e,n,r=!1){const a=n.length;if(!a)return;e.x=e.y=1;let u,c;for(let f=0;f<a;f++){u=n[f],c=u.projectionDelta;const{visualElement:h}=u.options;h&&h.props.style&&h.props.style.display==="contents"||(r&&u.options.layoutScroll&&u.scroll&&u!==u.root&&Oo(t,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),c&&(e.x*=c.x.scale,e.y*=c.y.scale,O_(t,c)),r&&ms(u.latestValues)&&Oo(t,u.latestValues))}e.x<Zx&&e.x>Xx&&(e.x=1),e.y<Zx&&e.y>Xx&&(e.y=1)}function Eo(t,e){t.min=t.min+e,t.max=t.max+e}function Qx(t,e,n,r,a=.5){const u=rt(t.min,t.max,a);Km(t,e,n,u,r)}function Oo(t,e){Qx(t.x,e.x,e.scaleX,e.scale,e.originX),Qx(t.y,e.y,e.scaleY,e.scale,e.originY)}function __(t,e){return A_(GK(t.getBoundingClientRect(),e))}function JK(t,e,n){const r=__(t,n),{scroll:a}=e;return a&&(Eo(r.x,a.offset.x),Eo(r.y,a.offset.y)),r}const Wx=()=>({translate:0,scale:1,origin:0,originPoint:0}),_o=()=>({x:Wx(),y:Wx()}),e1=()=>({min:0,max:0}),yt=()=>({x:e1(),y:e1()}),qm={current:null},R_={current:!1};function XK(){if(R_.current=!0,!!Fy)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>qm.current=t.matches;t.addEventListener("change",e),e()}else qm.current=!1}const ZK=new WeakMap;function QK(t,e,n){for(const r in e){const a=e[r],u=n[r];if(Yt(a))t.addValue(r,a);else if(Yt(u))t.addValue(r,Io(a,{owner:t}));else if(u!==a)if(t.hasValue(r)){const c=t.getValue(r);c.liveStyle===!0?c.jump(a):c.hasAnimated||c.set(a)}else{const c=t.getStaticValue(r);t.addValue(r,Io(c!==void 0?c:a,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const t1=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class WK{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:a,blockInitialAnimation:u,visualState:c},f={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=cg,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const v=fn.now();this.renderScheduledAt<v&&(this.renderScheduledAt=v,it.render(this.render,!1,!0))};const{latestValues:h,renderState:m}=c;this.latestValues=h,this.baseTarget={...h},this.initialValues=n.initial?{...h}:{},this.renderState=m,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=a,this.options=f,this.blockInitialAnimation=!!u,this.isControllingVariants=Bf(n),this.isVariantNode=h_(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:y,...g}=this.scrapeMotionValuesFromProps(n,{},this);for(const v in g){const S=g[v];h[v]!==void 0&&Yt(S)&&S.set(h[v])}}mount(e){this.current=e,ZK.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),R_.current||XK(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:qm.current,this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Vr(this.notifyUpdate),Vr(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const r=Wo.has(e);r&&this.onBindTransform&&this.onBindTransform();const a=n.on("change",c=>{this.latestValues[e]=c,this.props.onUpdate&&it.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let u;window.MotionCheckAppearSync&&(u=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{a(),u&&u(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ho){const n=Ho[e];if(!n)continue;const{isEnabled:r,Feature:a}=n;if(!this.features[e]&&a&&r(this.props)&&(this.features[e]=new a(this)),this.features[e]){const u=this.features[e];u.isMounted?u.update():(u.mount(),u.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):yt()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<t1.length;r++){const a=t1[r];this.propEventSubscriptions[a]&&(this.propEventSubscriptions[a](),delete this.propEventSubscriptions[a]);const u="on"+a,c=e[u];c&&(this.propEventSubscriptions[a]=this.on(a,c))}this.prevMotionValues=QK(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const r=this.values.get(e);n!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&n!==void 0&&(r=Io(n===null?void 0:n,{owner:this}),this.addValue(e,r)),r}readValue(e,n){let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(wO(r)||TO(r))?r=parseFloat(r):!dK(r)&&Ur.test(n)&&(r=r_(e,n)),this.setBaseTarget(e,Yt(r)?r.get():r)),Yt(r)?r.get():r}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const u=Sg(this.props,n,this.presenceContext?.custom);u&&(r=u[e])}if(n&&r!==void 0)return r;const a=this.getBaseTargetFromProps(this.props,e);return a!==void 0&&!Yt(a)?a:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Qy),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){hg.render(this.render)}}class C_ extends WK{constructor(){super(...arguments),this.KeyframeResolver=WU}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:r}){delete n[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Yt(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function k_(t,{style:e,vars:n},r,a){const u=t.style;let c;for(c in e)u[c]=e[c];a?.applyProjectionStyles(u,r);for(c in n)u.setProperty(c,n[c])}function eq(t){return window.getComputedStyle(t)}class tq extends C_{constructor(){super(...arguments),this.type="html",this.renderInstance=k_}readValueFromInstance(e,n){if(Wo.has(n))return this.projection?.isProjecting?Nm(n):bU(e,n);{const r=eq(e),a=(tg(n)?r.getPropertyValue(n):r[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(e,{transformPagePoint:n}){return __(e,n)}build(e,n,r){gg(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return wg(e,n,r)}}const M_=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function nq(t,e,n,r){k_(t,e,void 0,r);for(const a in e.attrs)t.setAttribute(M_.has(a)?a:xg(a),e.attrs[a])}class iq extends C_{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=yt}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Wo.has(n)){const r=i_(n);return r&&r.default||0}return n=M_.has(n)?n:xg(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return S_(e,n,r)}build(e,n,r){y_(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,a){nq(e,n,r,a)}mount(e){this.isSVGTag=b_(e.tagName),super.mount(e)}}const rq=(t,e)=>vg(t)?new iq(e):new tq(e,{allowProjection:t!==$.Fragment});function jo(t,e,n){const r=t.getProps();return Sg(r,e,n!==void 0?n:r.custom,t)}const Pm=t=>Array.isArray(t);function sq(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Io(n))}function oq(t){return Pm(t)?t[t.length-1]||0:t}function aq(t,e){const n=jo(t,e);let{transitionEnd:r={},transition:a={},...u}=n||{};u={...u,...r};for(const c in u){const f=oq(u[c]);sq(t,c,f)}}function lq(t){return!!(Yt(t)&&t.add)}function Im(t,e){const n=t.getValue("willChange");if(lq(n))return n.add(e);if(!n&&Qi.WillChange){const r=new Qi.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function D_(t){return t.props[w_]}const uq=t=>t!==null;function cq(t,{repeat:e,repeatType:n="loop"},r){const a=t.filter(uq),u=e&&n!=="loop"&&e%2===1?0:a.length-1;return a[u]}const fq={type:"spring",stiffness:500,damping:25,restSpeed:10},dq=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),hq={type:"keyframes",duration:.8},pq={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},mq=(t,{keyframes:e})=>e.length>2?hq:Wo.has(t)?t.startsWith("scale")?dq(e[1]):fq:pq;function yq({when:t,delay:e,delayChildren:n,staggerChildren:r,staggerDirection:a,repeat:u,repeatType:c,repeatDelay:f,from:h,elapsed:m,...y}){return!!Object.keys(y).length}const Tg=(t,e,n,r={},a,u)=>c=>{const f=fg(r,t)||{},h=f.delay||r.delay||0;let{elapsed:m=0}=r;m=m-pi(h);const y={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...f,delay:-m,onUpdate:v=>{e.set(v),f.onUpdate&&f.onUpdate(v)},onComplete:()=>{c(),f.onComplete&&f.onComplete()},name:t,motionValue:e,element:u?void 0:a};yq(f)||Object.assign(y,mq(t,y)),y.duration&&(y.duration=pi(y.duration)),y.repeatDelay&&(y.repeatDelay=pi(y.repeatDelay)),y.from!==void 0&&(y.keyframes[0]=y.from);let g=!1;if((y.type===!1||y.duration===0&&!y.repeatDelay)&&(Lm(y),y.delay===0&&(g=!0)),(Qi.instantAnimations||Qi.skipAnimations)&&(g=!0,Lm(y),y.delay=0),y.allowFlatten=!f.type&&!f.ease,g&&!u&&e.get()!==void 0){const v=cq(y.keyframes,f);if(v!==void 0){it.update(()=>{y.onUpdate(v),y.onComplete()});return}}return f.isSync?new ug(y):new KU(y)};function gq({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function N_(t,e,{delay:n=0,transitionOverride:r,type:a}={}){let{transition:u=t.getDefaultTransition(),transitionEnd:c,...f}=e;r&&(u=r);const h=[],m=a&&t.animationState&&t.animationState.getState()[a];for(const y in f){const g=t.getValue(y,t.latestValues[y]??null),v=f[y];if(v===void 0||m&&gq(m,y))continue;const S={delay:n,...fg(u||{},y)},x=g.get();if(x!==void 0&&!g.isAnimating&&!Array.isArray(v)&&v===x&&!S.velocity)continue;let T=!1;if(window.MotionHandoffAnimation){const C=D_(t);if(C){const _=window.MotionHandoffAnimation(C,y,it);_!==null&&(S.startTime=_,T=!0)}}Im(t,y),g.start(Tg(y,g,v,t.shouldReduceMotion&&e_.has(y)?{type:!1}:S,t,T));const M=g.animation;M&&h.push(M)}return c&&Promise.all(h).then(()=>{it.update(()=>{c&&aq(t,c)})}),h}function $_(t,e,n,r=0,a=1){const u=Array.from(t).sort((m,y)=>m.sortNodePosition(y)).indexOf(e),c=t.size,f=(c-1)*r;return typeof n=="function"?n(u,c):a===1?u*r:f-u*r}function Hm(t,e,n={}){const r=jo(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(a=n.transitionOverride);const u=r?()=>Promise.all(N_(t,r,n)):()=>Promise.resolve(),c=t.variantChildren&&t.variantChildren.size?(h=0)=>{const{delayChildren:m=0,staggerChildren:y,staggerDirection:g}=a;return bq(t,e,h,m,y,g,n)}:()=>Promise.resolve(),{when:f}=a;if(f){const[h,m]=f==="beforeChildren"?[u,c]:[c,u];return h().then(()=>m())}else return Promise.all([u(),c(n.delay)])}function bq(t,e,n=0,r=0,a=0,u=1,c){const f=[];for(const h of t.variantChildren)h.notify("AnimationStart",e),f.push(Hm(h,e,{...c,delay:n+(typeof r=="function"?0:r)+$_(t.variantChildren,h,r,a,u)}).then(()=>h.notify("AnimationComplete",e)));return Promise.all(f)}function vq(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const a=e.map(u=>Hm(t,u,n));r=Promise.all(a)}else if(typeof e=="string")r=Hm(t,e,n);else{const a=typeof e=="function"?jo(t,e,n.custom):e;r=Promise.all(N_(t,a,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}function j_(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const Sq=yg.length;function B_(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?B_(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Sq;n++){const r=yg[n],a=t.props[r];(xl(a)||a===!1)&&(e[r]=a)}return e}const wq=[...mg].reverse(),xq=mg.length;function Tq(t){return e=>Promise.all(e.map(({animation:n,options:r})=>vq(t,n,r)))}function Aq(t){let e=Tq(t),n=n1(),r=!0;const a=h=>(m,y)=>{const g=jo(t,y,h==="exit"?t.presenceContext?.custom:void 0);if(g){const{transition:v,transitionEnd:S,...x}=g;m={...m,...x,...S}}return m};function u(h){e=h(t)}function c(h){const{props:m}=t,y=B_(t.parent)||{},g=[],v=new Set;let S={},x=1/0;for(let M=0;M<xq;M++){const C=wq[M],_=n[C],R=m[C]!==void 0?m[C]:y[C],G=xl(R),I=C===h?_.isActive:null;I===!1&&(x=M);let ee=R===y[C]&&R!==m[C]&&G;if(ee&&r&&t.manuallyAnimateOnMount&&(ee=!1),_.protectedKeys={...S},!_.isActive&&I===null||!R&&!_.prevProp||jf(R)||typeof R=="boolean")continue;const J=Eq(_.prevProp,R);let X=J||C===h&&_.isActive&&!ee&&G||M>x&&G,he=!1;const pe=Array.isArray(R)?R:[R];let we=pe.reduce(a(C),{});I===!1&&(we={});const{prevResolvedValues:je={}}=_,ve={...je,...we},Z=U=>{X=!0,v.has(U)&&(he=!0,v.delete(U)),_.needsAnimating[U]=!0;const L=t.getValue(U);L&&(L.liveStyle=!1)};for(const U in ve){const L=we[U],te=je[U];if(S.hasOwnProperty(U))continue;let oe=!1;Pm(L)&&Pm(te)?oe=!j_(L,te):oe=L!==te,oe?L!=null?Z(U):v.add(U):L!==void 0&&v.has(U)?Z(U):_.protectedKeys[U]=!0}_.prevProp=R,_.prevResolvedValues=we,_.isActive&&(S={...S,...we}),r&&t.blockInitialAnimation&&(X=!1);const ne=ee&&J;X&&(!ne||he)&&g.push(...pe.map(U=>{const L={type:C};if(typeof U=="string"&&r&&!ne&&t.manuallyAnimateOnMount&&t.parent){const{parent:te}=t,oe=jo(te,U);if(te.enteringChildren&&oe){const{delayChildren:E}=oe.transition||{};L.delay=$_(te.enteringChildren,t,E)}}return{animation:U,options:L}}))}if(v.size){const M={};if(typeof m.initial!="boolean"){const C=jo(t,Array.isArray(m.initial)?m.initial[0]:m.initial);C&&C.transition&&(M.transition=C.transition)}v.forEach(C=>{const _=t.getBaseTarget(C),R=t.getValue(C);R&&(R.liveStyle=!0),M[C]=_??null}),g.push({animation:M})}let T=!!g.length;return r&&(m.initial===!1||m.initial===m.animate)&&!t.manuallyAnimateOnMount&&(T=!1),r=!1,T?e(g):Promise.resolve()}function f(h,m){if(n[h].isActive===m)return Promise.resolve();t.variantChildren?.forEach(g=>g.animationState?.setActive(h,m)),n[h].isActive=m;const y=c(h);for(const g in n)n[g].protectedKeys={};return y}return{animateChanges:c,setActive:f,setAnimateFunction:u,getState:()=>n,reset:()=>{n=n1()}}}function Eq(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!j_(e,t):!1}function ds(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function n1(){return{animate:ds(!0),whileInView:ds(),whileHover:ds(),whileTap:ds(),whileDrag:ds(),whileFocus:ds(),exit:ds()}}class Gr{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Oq extends Gr{constructor(e){super(e),e.animationState||(e.animationState=Aq(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();jf(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let _q=0;class Rq extends Gr{constructor(){super(...arguments),this.id=_q++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;const a=this.node.animationState.setActive("exit",!e);n&&!e&&a.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Cq={animation:{Feature:Oq},exit:{Feature:Rq}};function Al(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}function Ul(t){return{point:{x:t.pageX,y:t.pageY}}}const kq=t=>e=>pg(e)&&t(e,Ul(e));function ol(t,e,n,r){return Al(t,e,kq(n),r)}const z_=1e-4,Mq=1-z_,Dq=1+z_,L_=.01,Nq=0-L_,$q=0+L_;function Wt(t){return t.max-t.min}function jq(t,e,n){return Math.abs(t-e)<=n}function i1(t,e,n,r=.5){t.origin=r,t.originPoint=rt(e.min,e.max,t.origin),t.scale=Wt(n)/Wt(e),t.translate=rt(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Mq&&t.scale<=Dq||isNaN(t.scale))&&(t.scale=1),(t.translate>=Nq&&t.translate<=$q||isNaN(t.translate))&&(t.translate=0)}function al(t,e,n,r){i1(t.x,e.x,n.x,r?r.originX:void 0),i1(t.y,e.y,n.y,r?r.originY:void 0)}function r1(t,e,n){t.min=n.min+e.min,t.max=t.min+Wt(e)}function Bq(t,e,n){r1(t.x,e.x,n.x),r1(t.y,e.y,n.y)}function s1(t,e,n){t.min=e.min-n.min,t.max=t.min+Wt(e)}function ll(t,e,n){s1(t.x,e.x,n.x),s1(t.y,e.y,n.y)}function Ln(t){return[t("x"),t("y")]}const V_=({current:t})=>t?t.ownerDocument.defaultView:null,o1=(t,e)=>Math.abs(t-e);function zq(t,e){const n=o1(t.x,e.x),r=o1(t.y,e.y);return Math.sqrt(n**2+r**2)}class U_{constructor(e,n,{transformPagePoint:r,contextWindow:a=window,dragSnapToOrigin:u=!1,distanceThreshold:c=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=jp(this.lastMoveEventInfo,this.history),S=this.startEvent!==null,x=zq(v.offset,{x:0,y:0})>=this.distanceThreshold;if(!S&&!x)return;const{point:T}=v,{timestamp:M}=Ht;this.history.push({...T,timestamp:M});const{onStart:C,onMove:_}=this.handlers;S||(C&&C(this.lastMoveEvent,v),this.startEvent=this.lastMoveEvent),_&&_(this.lastMoveEvent,v)},this.handlePointerMove=(v,S)=>{this.lastMoveEvent=v,this.lastMoveEventInfo=$p(S,this.transformPagePoint),it.update(this.updatePoint,!0)},this.handlePointerUp=(v,S)=>{this.end();const{onEnd:x,onSessionEnd:T,resumeAnimation:M}=this.handlers;if(this.dragSnapToOrigin&&M&&M(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=jp(v.type==="pointercancel"?this.lastMoveEventInfo:$p(S,this.transformPagePoint),this.history);this.startEvent&&x&&x(v,C),T&&T(v,C)},!pg(e))return;this.dragSnapToOrigin=u,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=c,this.contextWindow=a||window;const f=Ul(e),h=$p(f,this.transformPagePoint),{point:m}=h,{timestamp:y}=Ht;this.history=[{...m,timestamp:y}];const{onSessionStart:g}=n;g&&g(e,jp(h,this.history)),this.removeListeners=zl(ol(this.contextWindow,"pointermove",this.handlePointerMove),ol(this.contextWindow,"pointerup",this.handlePointerUp),ol(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Vr(this.updatePoint)}}function $p(t,e){return e?{point:e(t.point)}:t}function a1(t,e){return{x:t.x-e.x,y:t.y-e.y}}function jp({point:t},e){return{point:t,delta:a1(t,K_(e)),offset:a1(t,Lq(e)),velocity:Vq(e,.1)}}function Lq(t){return t[0]}function K_(t){return t[t.length-1]}function Vq(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,r=null;const a=K_(t);for(;n>=0&&(r=t[n],!(a.timestamp-r.timestamp>pi(e)));)n--;if(!r)return{x:0,y:0};const u=qn(a.timestamp-r.timestamp);if(u===0)return{x:0,y:0};const c={x:(a.x-r.x)/u,y:(a.y-r.y)/u};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}function Uq(t,{min:e,max:n},r){return e!==void 0&&t<e?t=r?rt(e,t,r.min):Math.max(t,e):n!==void 0&&t>n&&(t=r?rt(n,t,r.max):Math.min(t,n)),t}function l1(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Kq(t,{top:e,left:n,bottom:r,right:a}){return{x:l1(t.x,n,a),y:l1(t.y,e,r)}}function u1(t,e){let n=e.min-t.min,r=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,r]=[r,n]),{min:n,max:r}}function qq(t,e){return{x:u1(t.x,e.x),y:u1(t.y,e.y)}}function Pq(t,e){let n=.5;const r=Wt(t),a=Wt(e);return a>r?n=vl(e.min,e.max-r,t.min):r>a&&(n=vl(t.min,t.max-a,e.min)),Zi(0,1,n)}function Iq(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Fm=.35;function Hq(t=Fm){return t===!1?t=0:t===!0&&(t=Fm),{x:c1(t,"left","right"),y:c1(t,"top","bottom")}}function c1(t,e,n){return{min:f1(t,e),max:f1(t,n)}}function f1(t,e){return typeof t=="number"?t:t[e]||0}const Fq=new WeakMap;class Gq{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=yt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const u=g=>{const{dragSnapToOrigin:v}=this.getProps();v?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Ul(g).point)},c=(g,v)=>{const{drag:S,dragPropagation:x,onDragStart:T}=this.getProps();if(S&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=rK(S),!this.openDragLock))return;this.latestPointerEvent=g,this.latestPanInfo=v,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ln(C=>{let _=this.getAxisMotionValue(C).get()||0;if(mi.test(_)){const{projection:R}=this.visualElement;if(R&&R.layout){const G=R.layout.layoutBox[C];G&&(_=Wt(G)*(parseFloat(_)/100))}}this.originPoint[C]=_}),T&&it.postRender(()=>T(g,v)),Im(this.visualElement,"transform");const{animationState:M}=this.visualElement;M&&M.setActive("whileDrag",!0)},f=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v;const{dragPropagation:S,dragDirectionLock:x,onDirectionLock:T,onDrag:M}=this.getProps();if(!S&&!this.openDragLock)return;const{offset:C}=v;if(x&&this.currentDirection===null){this.currentDirection=Yq(C),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",v.point,C),this.updateAxis("y",v.point,C),this.visualElement.render(),M&&M(g,v)},h=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v,this.stop(g,v),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>Ln(g=>this.getAnimationState(g)==="paused"&&this.getAxisMotionValue(g).animation?.play()),{dragSnapToOrigin:y}=this.getProps();this.panSession=new U_(e,{onSessionStart:u,onStart:c,onMove:f,onSessionEnd:h,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:r,contextWindow:V_(this.visualElement)})}stop(e,n){const r=e||this.latestPointerEvent,a=n||this.latestPanInfo,u=this.isDragging;if(this.cancel(),!u||!a||!r)return;const{velocity:c}=a;this.startAnimation(c);const{onDragEnd:f}=this.getProps();f&&it.postRender(()=>f(r,a))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,r){const{drag:a}=this.getProps();if(!r||!vc(e,a,this.currentDirection))return;const u=this.getAxisMotionValue(e);let c=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(c=Uq(c,this.constraints[e],this.elastic[e])),u.set(c)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,a=this.constraints;e&&Ao(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&r?this.constraints=Kq(r.layoutBox,e):this.constraints=!1,this.elastic=Hq(n),a!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Ln(u=>{this.constraints!==!1&&this.getAxisMotionValue(u)&&(this.constraints[u]=Iq(r.layoutBox[u],this.constraints[u]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Ao(e))return!1;const r=e.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const u=JK(r,a.root,this.visualElement.getTransformPagePoint());let c=qq(a.layout.layoutBox,u);if(n){const f=n(FK(c));this.hasMutatedConstraints=!!f,f&&(c=A_(f))}return c}startAnimation(e){const{drag:n,dragMomentum:r,dragElastic:a,dragTransition:u,dragSnapToOrigin:c,onDragTransitionEnd:f}=this.getProps(),h=this.constraints||{},m=Ln(y=>{if(!vc(y,n,this.currentDirection))return;let g=h&&h[y]||{};c&&(g={min:0,max:0});const v=a?200:1e6,S=a?40:1e7,x={type:"inertia",velocity:r?e[y]:0,bounceStiffness:v,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...u,...g};return this.startAxisValueAnimation(y,x)});return Promise.all(m).then(f)}startAxisValueAnimation(e,n){const r=this.getAxisMotionValue(e);return Im(this.visualElement,e),r.start(Tg(e,r,0,n,this.visualElement,!1))}stopAnimation(){Ln(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Ln(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps(),a=r[n];return a||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){Ln(n=>{const{drag:r}=this.getProps();if(!vc(n,r,this.currentDirection))return;const{projection:a}=this.visualElement,u=this.getAxisMotionValue(n);if(a&&a.layout){const{min:c,max:f}=a.layout.layoutBox[n];u.set(e[n]-rt(c,f,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!Ao(n)||!r||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Ln(c=>{const f=this.getAxisMotionValue(c);if(f&&this.constraints!==!1){const h=f.get();a[c]=Pq({min:h,max:h},this.constraints[c])}});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Ln(c=>{if(!vc(c,e,null))return;const f=this.getAxisMotionValue(c),{min:h,max:m}=this.constraints[c];f.set(rt(h,m,a[c]))})}addListeners(){if(!this.visualElement.current)return;Fq.set(this.visualElement,this);const e=this.visualElement.current,n=ol(e,"pointerdown",h=>{const{drag:m,dragListener:y=!0}=this.getProps();m&&y&&this.start(h)}),r=()=>{const{dragConstraints:h}=this.getProps();Ao(h)&&h.current&&(this.constraints=this.resolveRefConstraints())},{projection:a}=this.visualElement,u=a.addEventListener("measure",r);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),it.read(r);const c=Al(window,"resize",()=>this.scalePositionWithinConstraints()),f=a.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:m})=>{this.isDragging&&m&&(Ln(y=>{const g=this.getAxisMotionValue(y);g&&(this.originPoint[y]+=h[y].translate,g.set(g.get()+h[y].translate))}),this.visualElement.render())}));return()=>{c(),n(),u(),f&&f()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:a=!1,dragConstraints:u=!1,dragElastic:c=Fm,dragMomentum:f=!0}=e;return{...e,drag:n,dragDirectionLock:r,dragPropagation:a,dragConstraints:u,dragElastic:c,dragMomentum:f}}}function vc(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Yq(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class Jq extends Gr{constructor(e){super(e),this.removeGroupControls=Pn,this.removeListeners=Pn,this.controls=new Gq(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Pn}unmount(){this.removeGroupControls(),this.removeListeners()}}const d1=t=>(e,n)=>{t&&it.postRender(()=>t(e,n))};class Xq extends Gr{constructor(){super(...arguments),this.removePointerDownListener=Pn}onPointerDown(e){this.session=new U_(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:V_(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:r,onPanEnd:a}=this.node.getProps();return{onSessionStart:d1(e),onStart:d1(n),onMove:r,onEnd:(u,c)=>{delete this.session,a&&it.postRender(()=>a(u,c))}}}mount(){this.removePointerDownListener=ol(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const $c={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function h1(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ja={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(de.test(t))t=parseFloat(t);else return t;const n=h1(t,e.target.x),r=h1(t,e.target.y);return`${n}% ${r}%`}},Zq={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,a=Ur.parse(t);if(a.length>5)return r;const u=Ur.createTransformer(t),c=typeof a[0]!="number"?1:0,f=n.x.scale*e.x,h=n.y.scale*e.y;a[0+c]/=f,a[1+c]/=h;const m=rt(f,h,.5);return typeof a[2+c]=="number"&&(a[2+c]/=m),typeof a[3+c]=="number"&&(a[3+c]/=m),u(a)}};let Bp=!1;class Qq extends $.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r,layoutId:a}=this.props,{projection:u}=e;SK(Wq),u&&(n.group&&n.group.add(u),r&&r.register&&a&&r.register(u),Bp&&u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,onExitComplete:()=>this.safeToRemove()})),$c.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:r,drag:a,isPresent:u}=this.props,{projection:c}=r;return c&&(c.isPresent=u,Bp=!0,a||e.layoutDependency!==n||n===void 0||e.isPresent!==u?c.willUpdate():this.safeToRemove(),e.isPresent!==u&&(u?c.promote():c.relegate()||it.postRender(()=>{const f=c.getStack();(!f||!f.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),hg.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:a}=e;Bp=!0,a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),r&&r.deregister&&r.deregister(a))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function q_(t){const[e,n]=hK(),r=$.useContext(SO);return F.jsx(Qq,{...t,layoutGroup:r,switchLayoutGroup:$.useContext(x_),isPresent:e,safeToRemove:n})}const Wq={borderRadius:{...Ja,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ja,borderTopRightRadius:Ja,borderBottomLeftRadius:Ja,borderBottomRightRadius:Ja,boxShadow:Zq};function e6(t,e,n){const r=Yt(t)?t:Io(t);return r.start(Tg("",r,e,n)),r.animation}const t6=(t,e)=>t.depth-e.depth;class n6{constructor(){this.children=[],this.isDirty=!1}add(e){Yy(this.children,e),this.isDirty=!0}remove(e){Jy(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(t6),this.isDirty=!1,this.children.forEach(e)}}function i6(t,e){const n=fn.now(),r=({timestamp:a})=>{const u=a-n;u>=e&&(Vr(r),t(u-e))};return it.setup(r,!0),()=>Vr(r)}const P_=["TopLeft","TopRight","BottomLeft","BottomRight"],r6=P_.length,p1=t=>typeof t=="string"?parseFloat(t):t,m1=t=>typeof t=="number"||de.test(t);function s6(t,e,n,r,a,u){a?(t.opacity=rt(0,n.opacity??1,o6(r)),t.opacityExit=rt(e.opacity??1,0,a6(r))):u&&(t.opacity=rt(e.opacity??1,n.opacity??1,r));for(let c=0;c<r6;c++){const f=`border${P_[c]}Radius`;let h=y1(e,f),m=y1(n,f);if(h===void 0&&m===void 0)continue;h||(h=0),m||(m=0),h===0||m===0||m1(h)===m1(m)?(t[f]=Math.max(rt(p1(h),p1(m),r),0),(mi.test(m)||mi.test(h))&&(t[f]+="%")):t[f]=m}(e.rotate||n.rotate)&&(t.rotate=rt(e.rotate||0,n.rotate||0,r))}function y1(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const o6=I_(0,.5,MO),a6=I_(.5,.95,Pn);function I_(t,e,n){return r=>r<t?0:r>e?1:n(vl(t,e,r))}function g1(t,e){t.min=e.min,t.max=e.max}function Bn(t,e){g1(t.x,e.x),g1(t.y,e.y)}function b1(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function v1(t,e,n,r,a){return t-=e,t=of(t,1/n,r),a!==void 0&&(t=of(t,1/a,r)),t}function l6(t,e=0,n=1,r=.5,a,u=t,c=t){if(mi.test(e)&&(e=parseFloat(e),e=rt(c.min,c.max,e/100)-c.min),typeof e!="number")return;let f=rt(u.min,u.max,r);t===u&&(f-=e),t.min=v1(t.min,e,n,f,a),t.max=v1(t.max,e,n,f,a)}function S1(t,e,[n,r,a],u,c){l6(t,e[n],e[r],e[a],e.scale,u,c)}const u6=["x","scaleX","originX"],c6=["y","scaleY","originY"];function w1(t,e,n,r){S1(t.x,e,u6,n?n.x:void 0,r?r.x:void 0),S1(t.y,e,c6,n?n.y:void 0,r?r.y:void 0)}function x1(t){return t.translate===0&&t.scale===1}function H_(t){return x1(t.x)&&x1(t.y)}function T1(t,e){return t.min===e.min&&t.max===e.max}function f6(t,e){return T1(t.x,e.x)&&T1(t.y,e.y)}function A1(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function F_(t,e){return A1(t.x,e.x)&&A1(t.y,e.y)}function E1(t){return Wt(t.x)/Wt(t.y)}function O1(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class d6{constructor(){this.members=[]}add(e){Yy(this.members,e),e.scheduleRender()}remove(e){if(Jy(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(a=>e===a);if(n===0)return!1;let r;for(let a=n;a>=0;a--){const u=this.members[a];if(u.isPresent!==!1){r=u;break}}return r?(this.promote(r),!0):!1}promote(e,n){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender(),e.resumeFrom=r,n&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:a}=e.options;a===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:r}=e;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function h6(t,e,n){let r="";const a=t.x.translate/e.x,u=t.y.translate/e.y,c=n?.z||0;if((a||u||c)&&(r=`translate3d(${a}px, ${u}px, ${c}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:m,rotate:y,rotateX:g,rotateY:v,skewX:S,skewY:x}=n;m&&(r=`perspective(${m}px) ${r}`),y&&(r+=`rotate(${y}deg) `),g&&(r+=`rotateX(${g}deg) `),v&&(r+=`rotateY(${v}deg) `),S&&(r+=`skewX(${S}deg) `),x&&(r+=`skewY(${x}deg) `)}const f=t.x.scale*e.x,h=t.y.scale*e.y;return(f!==1||h!==1)&&(r+=`scale(${f}, ${h})`),r||"none"}const zp=["","X","Y","Z"],p6=1e3;let m6=0;function Lp(t,e,n,r){const{latestValues:a}=e;a[t]&&(n[t]=a[t],e.setStaticValue(t,0),r&&(r[t]=0))}function G_(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=D_(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:u}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",it,!(a||u))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&G_(r)}function Y_({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:a}){return class{constructor(c={},f=e?.()){this.id=m6++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(b6),this.nodes.forEach(x6),this.nodes.forEach(T6),this.nodes.forEach(v6)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,this.root=f?f.root||f:this,this.path=f?[...f.path,f]:[],this.parent=f,this.depth=f?f.depth+1:0;for(let h=0;h<this.path.length;h++)this.path[h].shouldResetTransform=!0;this.root===this&&(this.nodes=new n6)}addEventListener(c,f){return this.eventHandlers.has(c)||this.eventHandlers.set(c,new Qy),this.eventHandlers.get(c).add(f)}notifyListeners(c,...f){const h=this.eventHandlers.get(c);h&&h.notify(...f)}hasListeners(c){return this.eventHandlers.has(c)}mount(c){if(this.instance)return;this.isSVG=u_(c)&&!cK(c),this.instance=c;const{layoutId:f,layout:h,visualElement:m}=this.options;if(m&&!m.current&&m.mount(c),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(h||f)&&(this.isLayoutDirty=!0),t){let y,g=0;const v=()=>this.root.updateBlockedByResize=!1;it.read(()=>{g=window.innerWidth}),t(c,()=>{const S=window.innerWidth;S!==g&&(g=S,this.root.updateBlockedByResize=!0,y&&y(),y=i6(v,250),$c.hasAnimatedSinceResize&&($c.hasAnimatedSinceResize=!1,this.nodes.forEach(C1)))})}f&&this.root.registerSharedNode(f,this),this.options.animate!==!1&&m&&(f||h)&&this.addEventListener("didUpdate",({delta:y,hasLayoutChanged:g,hasRelativeLayoutChanged:v,layout:S})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||m.getDefaultTransition()||R6,{onLayoutAnimationStart:T,onLayoutAnimationComplete:M}=m.getProps(),C=!this.targetLayout||!F_(this.targetLayout,S),_=!g&&v;if(this.options.layoutRoot||this.resumeFrom||_||g&&(C||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const R={...fg(x,"layout"),onPlay:T,onComplete:M};(m.shouldReduceMotion||this.options.layoutRoot)&&(R.delay=0,R.type=!1),this.startAnimation(R),this.setAnimationOrigin(y,_)}else g||C1(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=S})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const c=this.getStack();c&&c.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Vr(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(A6),this.animationId++)}getTransformTemplate(){const{visualElement:c}=this.options;return c&&c.getProps().transformTemplate}willUpdate(c=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&G_(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let y=0;y<this.path.length;y++){const g=this.path[y];g.shouldResetTransform=!0,g.updateScroll("snapshot"),g.options.layoutRoot&&g.willUpdate(!1)}const{layoutId:f,layout:h}=this.options;if(f===void 0&&!h)return;const m=this.getTransformTemplate();this.prevTransformTemplateValue=m?m(this.latestValues,""):void 0,this.updateSnapshot(),c&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(_1);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(R1);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(w6),this.nodes.forEach(y6),this.nodes.forEach(g6)):this.nodes.forEach(R1),this.clearAllSnapshots();const f=fn.now();Ht.delta=Zi(0,1e3/60,f-Ht.timestamp),Ht.timestamp=f,Ht.isProcessing=!0,Op.update.process(Ht),Op.preRender.process(Ht),Op.render.process(Ht),Ht.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,hg.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(S6),this.sharedNodes.forEach(E6)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,it.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){it.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Wt(this.snapshot.measuredBox.x)&&!Wt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h<this.path.length;h++)this.path[h].updateScroll();const c=this.layout;this.layout=this.measure(!1),this.layoutCorrected=yt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:f}=this.options;f&&f.notify("LayoutMeasure",this.layout.layoutBox,c?c.layoutBox:void 0)}updateScroll(c="measure"){let f=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===c&&(f=!1),f&&this.instance){const h=r(this.instance);this.scroll={animationId:this.root.animationId,phase:c,isRoot:h,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:h}}}resetTransform(){if(!a)return;const c=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,f=this.projectionDelta&&!H_(this.projectionDelta),h=this.getTransformTemplate(),m=h?h(this.latestValues,""):void 0,y=m!==this.prevTransformTemplateValue;c&&this.instance&&(f||ms(this.latestValues)||y)&&(a(this.instance,m),this.shouldResetTransform=!1,this.scheduleRender())}measure(c=!0){const f=this.measurePageBox();let h=this.removeElementScroll(f);return c&&(h=this.removeTransform(h)),C6(h),{animationId:this.root.animationId,measuredBox:f,layoutBox:h,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:c}=this.options;if(!c)return yt();const f=c.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(k6))){const{scroll:m}=this.root;m&&(Eo(f.x,m.offset.x),Eo(f.y,m.offset.y))}return f}removeElementScroll(c){const f=yt();if(Bn(f,c),this.scroll?.wasRoot)return f;for(let h=0;h<this.path.length;h++){const m=this.path[h],{scroll:y,options:g}=m;m!==this.root&&y&&g.layoutScroll&&(y.wasRoot&&Bn(f,c),Eo(f.x,y.offset.x),Eo(f.y,y.offset.y))}return f}applyTransform(c,f=!1){const h=yt();Bn(h,c);for(let m=0;m<this.path.length;m++){const y=this.path[m];!f&&y.options.layoutScroll&&y.scroll&&y!==y.root&&Oo(h,{x:-y.scroll.offset.x,y:-y.scroll.offset.y}),ms(y.latestValues)&&Oo(h,y.latestValues)}return ms(this.latestValues)&&Oo(h,this.latestValues),h}removeTransform(c){const f=yt();Bn(f,c);for(let h=0;h<this.path.length;h++){const m=this.path[h];if(!m.instance||!ms(m.latestValues))continue;Um(m.latestValues)&&m.updateSnapshot();const y=yt(),g=m.measurePageBox();Bn(y,g),w1(f,m.latestValues,m.snapshot?m.snapshot.layoutBox:void 0,y)}return ms(this.latestValues)&&w1(f,this.latestValues),f}setTargetDelta(c){this.targetDelta=c,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(c){this.options={...this.options,...c,crossfade:c.crossfade!==void 0?c.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ht.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(c=!1){const f=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=f.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=f.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=f.isSharedProjectionDirty);const h=!!this.resumingFrom||this!==f;if(!(c||h&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:y,layoutId:g}=this.options;if(!(!this.layout||!(y||g))){if(this.resolvedRelativeTargetAt=Ht.timestamp,!this.targetDelta&&!this.relativeTarget){const v=this.getClosestProjectingParent();v&&v.layout&&this.animationProgress!==1?(this.relativeParent=v,this.forceRelativeParentToResolveTarget(),this.relativeTarget=yt(),this.relativeTargetOrigin=yt(),ll(this.relativeTargetOrigin,this.layout.layoutBox,v.layout.layoutBox),Bn(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=yt(),this.targetWithTransforms=yt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Bq(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Bn(this.target,this.layout.layoutBox),O_(this.target,this.targetDelta)):Bn(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const v=this.getClosestProjectingParent();v&&!!v.resumingFrom==!!this.resumingFrom&&!v.options.layoutScroll&&v.target&&this.animationProgress!==1?(this.relativeParent=v,this.forceRelativeParentToResolveTarget(),this.relativeTarget=yt(),this.relativeTargetOrigin=yt(),ll(this.relativeTargetOrigin,this.target,v.target),Bn(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Um(this.parent.latestValues)||E_(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const c=this.getLead(),f=!!this.resumingFrom||this!==c;let h=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(h=!1),f&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(h=!1),this.resolvedRelativeTargetAt===Ht.timestamp&&(h=!1),h)return;const{layout:m,layoutId:y}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(m||y))return;Bn(this.layoutCorrected,this.layout.layoutBox);const g=this.treeScale.x,v=this.treeScale.y;YK(this.layoutCorrected,this.treeScale,this.path,f),c.layout&&!c.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(c.target=c.layout.layoutBox,c.targetWithTransforms=yt());const{target:S}=c;if(!S){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(b1(this.prevProjectionDelta.x,this.projectionDelta.x),b1(this.prevProjectionDelta.y,this.projectionDelta.y)),al(this.projectionDelta,this.layoutCorrected,S,this.latestValues),(this.treeScale.x!==g||this.treeScale.y!==v||!O1(this.projectionDelta.x,this.prevProjectionDelta.x)||!O1(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",S))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(c=!0){if(this.options.visualElement?.scheduleRender(),c){const f=this.getStack();f&&f.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=_o(),this.projectionDelta=_o(),this.projectionDeltaWithTransform=_o()}setAnimationOrigin(c,f=!1){const h=this.snapshot,m=h?h.latestValues:{},y={...this.latestValues},g=_o();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!f;const v=yt(),S=h?h.source:void 0,x=this.layout?this.layout.source:void 0,T=S!==x,M=this.getStack(),C=!M||M.members.length<=1,_=!!(T&&!C&&this.options.crossfade===!0&&!this.path.some(_6));this.animationProgress=0;let R;this.mixTargetDelta=G=>{const I=G/1e3;k1(g.x,c.x,I),k1(g.y,c.y,I),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ll(v,this.layout.layoutBox,this.relativeParent.layout.layoutBox),O6(this.relativeTarget,this.relativeTargetOrigin,v,I),R&&f6(this.relativeTarget,R)&&(this.isProjectionDirty=!1),R||(R=yt()),Bn(R,this.relativeTarget)),T&&(this.animationValues=y,s6(y,m,this.latestValues,I,_,C)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=I},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Vr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=it.update(()=>{$c.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Io(0)),this.currentAnimation=e6(this.motionValue,[0,1e3],{...c,velocity:0,isSync:!0,onUpdate:f=>{this.mixTargetDelta(f),c.onUpdate&&c.onUpdate(f)},onStop:()=>{},onComplete:()=>{c.onComplete&&c.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const c=this.getStack();c&&c.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(p6),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const c=this.getLead();let{targetWithTransforms:f,target:h,layout:m,latestValues:y}=c;if(!(!f||!h||!m)){if(this!==c&&this.layout&&m&&J_(this.options.animationType,this.layout.layoutBox,m.layoutBox)){h=this.target||yt();const g=Wt(this.layout.layoutBox.x);h.x.min=c.target.x.min,h.x.max=h.x.min+g;const v=Wt(this.layout.layoutBox.y);h.y.min=c.target.y.min,h.y.max=h.y.min+v}Bn(f,h),Oo(f,y),al(this.projectionDeltaWithTransform,this.layoutCorrected,f,y)}}registerSharedNode(c,f){this.sharedNodes.has(c)||this.sharedNodes.set(c,new d6),this.sharedNodes.get(c).add(f);const m=f.options.initialPromotionConfig;f.promote({transition:m?m.transition:void 0,preserveFollowOpacity:m&&m.shouldPreserveFollowOpacity?m.shouldPreserveFollowOpacity(f):void 0})}isLead(){const c=this.getStack();return c?c.lead===this:!0}getLead(){const{layoutId:c}=this.options;return c?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:c}=this.options;return c?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:c}=this.options;if(c)return this.root.sharedNodes.get(c)}promote({needsReset:c,transition:f,preserveFollowOpacity:h}={}){const m=this.getStack();m&&m.promote(this,h),c&&(this.projectionDelta=void 0,this.needsReset=!0),f&&this.setOptions({transition:f})}relegate(){const c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){const{visualElement:c}=this.options;if(!c)return;let f=!1;const{latestValues:h}=c;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(f=!0),!f)return;const m={};h.z&&Lp("z",c,m,this.animationValues);for(let y=0;y<zp.length;y++)Lp(`rotate${zp[y]}`,c,m,this.animationValues),Lp(`skew${zp[y]}`,c,m,this.animationValues);c.render();for(const y in m)c.setStaticValue(y,m[y]),this.animationValues&&(this.animationValues[y]=m[y]);c.scheduleRender()}applyProjectionStyles(c,f){if(!this.instance||this.isSVG)return;if(!this.isVisible){c.visibility="hidden";return}const h=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,c.visibility="",c.opacity="",c.pointerEvents=Nc(f?.pointerEvents)||"",c.transform=h?h(this.latestValues,""):"none";return}const m=this.getLead();if(!this.projectionDelta||!this.layout||!m.target){this.options.layoutId&&(c.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,c.pointerEvents=Nc(f?.pointerEvents)||""),this.hasProjected&&!ms(this.latestValues)&&(c.transform=h?h({},""):"none",this.hasProjected=!1);return}c.visibility="";const y=m.animationValues||m.latestValues;this.applyTransformsToTarget();let g=h6(this.projectionDeltaWithTransform,this.treeScale,y);h&&(g=h(y,g)),c.transform=g;const{x:v,y:S}=this.projectionDelta;c.transformOrigin=`${v.origin*100}% ${S.origin*100}% 0`,m.animationValues?c.opacity=m===this?y.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:y.opacityExit:c.opacity=m===this?y.opacity!==void 0?y.opacity:"":y.opacityExit!==void 0?y.opacityExit:0;for(const x in Tl){if(y[x]===void 0)continue;const{correct:T,applyTo:M,isCSSVariable:C}=Tl[x],_=g==="none"?y[x]:T(y[x],m);if(M){const R=M.length;for(let G=0;G<R;G++)c[M[G]]=_}else C?this.options.visualElement.renderState.vars[x]=_:c[x]=_}this.options.layoutId&&(c.pointerEvents=m===this?Nc(f?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(c=>c.currentAnimation?.stop()),this.root.nodes.forEach(_1),this.root.sharedNodes.clear()}}}function y6(t){t.updateLayout()}function g6(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:a}=t.options,u=e.source!==t.layout.source;a==="size"?Ln(y=>{const g=u?e.measuredBox[y]:e.layoutBox[y],v=Wt(g);g.min=n[y].min,g.max=g.min+v}):J_(a,e.layoutBox,n)&&Ln(y=>{const g=u?e.measuredBox[y]:e.layoutBox[y],v=Wt(n[y]);g.max=g.min+v,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[y].max=t.relativeTarget[y].min+v)});const c=_o();al(c,n,e.layoutBox);const f=_o();u?al(f,t.applyTransform(r,!0),e.measuredBox):al(f,n,e.layoutBox);const h=!H_(c);let m=!1;if(!t.resumeFrom){const y=t.getClosestProjectingParent();if(y&&!y.resumeFrom){const{snapshot:g,layout:v}=y;if(g&&v){const S=yt();ll(S,e.layoutBox,g.layoutBox);const x=yt();ll(x,n,v.layoutBox),F_(S,x)||(m=!0),y.options.layoutRoot&&(t.relativeTarget=x,t.relativeTargetOrigin=S,t.relativeParent=y)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:f,layoutDelta:c,hasLayoutChanged:h,hasRelativeLayoutChanged:m})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function b6(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function v6(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function S6(t){t.clearSnapshot()}function _1(t){t.clearMeasurements()}function R1(t){t.isLayoutDirty=!1}function w6(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function C1(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function x6(t){t.resolveTargetDelta()}function T6(t){t.calcProjection()}function A6(t){t.resetSkewAndRotation()}function E6(t){t.removeLeadSnapshot()}function k1(t,e,n){t.translate=rt(e.translate,0,n),t.scale=rt(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function M1(t,e,n,r){t.min=rt(e.min,n.min,r),t.max=rt(e.max,n.max,r)}function O6(t,e,n,r){M1(t.x,e.x,n.x,r),M1(t.y,e.y,n.y,r)}function _6(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const R6={duration:.45,ease:[.4,0,.1,1]},D1=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),N1=D1("applewebkit/")&&!D1("chrome/")?Math.round:Pn;function $1(t){t.min=N1(t.min),t.max=N1(t.max)}function C6(t){$1(t.x),$1(t.y)}function J_(t,e,n){return t==="position"||t==="preserve-aspect"&&!jq(E1(e),E1(n),.2)}function k6(t){return t!==t.root&&t.scroll?.wasRoot}const M6=Y_({attachResizeListener:(t,e)=>Al(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Vp={current:void 0},X_=Y_({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Vp.current){const t=new M6({});t.mount(window),t.setOptions({layoutScroll:!0}),Vp.current=t}return Vp.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),D6={pan:{Feature:Xq},drag:{Feature:Jq,ProjectionNode:X_,MeasureLayout:q_}};function j1(t,e,n){const{props:r}=t;t.animationState&&r.whileHover&&t.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,u=r[a];u&&it.postRender(()=>u(e,Ul(e)))}class N6 extends Gr{mount(){const{current:e}=this.node;e&&(this.unmount=sK(e,(n,r)=>(j1(this.node,r,"Start"),a=>j1(this.node,a,"End"))))}unmount(){}}class $6 extends Gr{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=zl(Al(this.node.current,"focus",()=>this.onFocus()),Al(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function B1(t,e,n){const{props:r}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&r.whileTap&&t.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),u=r[a];u&&it.postRender(()=>u(e,Ul(e)))}class j6 extends Gr{mount(){const{current:e}=this.node;e&&(this.unmount=uK(e,(n,r)=>(B1(this.node,r,"Start"),(a,{success:u})=>B1(this.node,a,u?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Gm=new WeakMap,Up=new WeakMap,B6=t=>{const e=Gm.get(t.target);e&&e(t)},z6=t=>{t.forEach(B6)};function L6({root:t,...e}){const n=t||document;Up.has(n)||Up.set(n,{});const r=Up.get(n),a=JSON.stringify(e);return r[a]||(r[a]=new IntersectionObserver(z6,{root:t,...e})),r[a]}function V6(t,e,n){const r=L6(e);return Gm.set(t,n),r.observe(t),()=>{Gm.delete(t),r.unobserve(t)}}const U6={some:0,all:1};class K6 extends Gr{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:r,amount:a="some",once:u}=e,c={root:n?n.current:void 0,rootMargin:r,threshold:typeof a=="number"?a:U6[a]},f=h=>{const{isIntersecting:m}=h;if(this.isInView===m||(this.isInView=m,u&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:y,onViewportLeave:g}=this.node.getProps(),v=m?y:g;v&&v(h)};return V6(this.node.current,c,f)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(q6(e,n))&&this.startObserver()}unmount(){}}function q6({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const P6={inView:{Feature:K6},tap:{Feature:j6},focus:{Feature:$6},hover:{Feature:N6}},I6={layout:{ProjectionNode:X_,MeasureLayout:q_}},H6={...Cq,...P6,...D6,...I6},F6=HK(H6,rq);function G6(){const t=Wn(Po),e=Wn(di),n=Wn(Hi),r=Et(Po),a=Et(di),u=Et(Hi),c=`email-${$.useId()}`,f=`password-${$.useId()}`,h=`one-time-code-${$.useId()}`,[m,y]=$.useState(null),[g,v]=$.useState("email"),S=`form-${$.useId()}`;return $.useEffect(()=>{if(u.length===6){const x=document.getElementById(S);x instanceof HTMLFormElement&&x.requestSubmit()}},[u]),F.jsx("form",{id:S,onSubmit:async x=>{x.preventDefault();const T=nt(ui);try{switch(g){case"email":{const{nextStep:M,userKey:C}=await cn.declareAuthTarget.query({email:r});switch(De(ui,C),M){case"otc_login":case"otc_verify":{v("otc");break}case"password_login":{v("password");break}}break}case"otc":{if(!T){console.error("somehow userKey is null");return}const M=await cn.verifyAccountAction.mutate({oneTimeCode:u,userKey:T});De(ut,M),gi.once("connect",()=>{Os("/game"),t(""),n("")});break}case"password":{const M=await cn.openSession.mutate({email:r,password:a});De(ut,M),gi.once("connect",()=>{Os("/game"),t(""),e("")});break}}}catch(M){M instanceof bl&&y(M.message)}},children:F.jsxs("main",{children:[m?F.jsx("aside",{children:m}):null,F.jsxs(F6.label,{htmlFor:c,children:[F.jsx("span",{children:"Email"}),F.jsx("input",{id:c,type:"text",value:r,onChange:x=>{t(x.target.value)},autoComplete:"email",autoCapitalize:"none",disabled:g!=="email"})]}),g==="password"?F.jsxs("label",{htmlFor:f,children:[F.jsx("span",{children:"Password"}),F.jsx("input",{id:f,type:"password",value:a,onChange:x=>{e(x.target.value)},autoComplete:"current-password",autoCapitalize:"none",autoFocus:g==="password"})]}):null,g==="otc"?F.jsxs("label",{htmlFor:h,children:[F.jsx("span",{children:"One-time Code"}),F.jsx("input",{id:h,type:"number",inputMode:"numeric",enterKeyHint:"go",value:u,onChange:x=>{n(x.target.value)},autoComplete:"one-time-code",autoCapitalize:"none",autoFocus:g==="otc"})]}):null,F.jsxs("footer",{children:[g==="password"?F.jsx("button",{type:"button",onClick:async()=>{const x=nt(ui);if(!x)return new Error("No userKey");await cn.startPasswordReset.mutate({userKey:x}),v("otc")},children:"Forgot Password?"}):null,F.jsx("span",{}),F.jsx("button",{type:"submit",disabled:!r&&g==="email"||!a&&g==="password"||!u&&g==="otc",children:">>->"})]})]})})}function Y6({route:[,t]}){const e=Et(ut),n=Et(Hi),r=Wn(Hi),a=`code-${$.useId()}`;return $.useEffect(()=>{t&&r(t)},[]),e?F.jsx("form",{onSubmit:async u=>{u.preventDefault();try{const c=await cn.verifyAccountAction.mutate({oneTimeCode:n,userKey:"CHANGEME"});De(ut,c),c.action==="resetPassword"?Os("/account"):Os("/game")}catch(c){console.error(c)}},children:F.jsxs("main",{children:[F.jsx("p",{children:"Check your email for a verification code."}),F.jsxs("label",{htmlFor:a,children:[F.jsx("span",{children:"Verification code"}),F.jsx("input",{id:a,type:"text",value:n,onChange:u=>{r(u.target.value)},placeholder:"Verification code",autoComplete:"one-time-code",autoCapitalize:"none"})]})]})}):F.jsx("p",{children:"You must be logged in to verify your account."})}function J6(){const t=Et(r4),e=Et(ut),[n,r]=$.useState(!1),{refs:a,floatingStyles:u,context:c}=K2({open:n,onOpenChange:r,placement:"bottom-end",middleware:[d2(5),p2(),h2()],whileElementsMounted:r2}),f=B2(c),h=V2(c),m=I2(c),{getReferenceProps:y,getFloatingProps:g}=q2([f,h,m]),v=Et(FL);return F.jsxs("main",{className:Bz.class,children:[F.jsxs("header",{children:[F.jsxs("main",{children:[F.jsx(jz,{}),F.jsx("span",{children:F.jsx(zz,{input:v})})]}),F.jsx("button",{"data-css":"profile",ref:a.setReference,...y(),children:e?.username?e.username.slice(0,2):""}),n&&e&&F.jsx($2,{context:c,modal:!1,children:F.jsxs("div",{"data-css":"profile-actions",ref:a.setFloating,style:u,...g(),children:[F.jsx("span",{children:e.username}),F.jsx("button",{type:"button",onClick:()=>{Os("/account")},children:"Account"}),F.jsx("button",{type:"button",onClick:async()=>{e&&(await cn.closeSession.mutate({username:e.username}),gi.once("disconnect",()=>{De(ut,null),Os("/")}),gi.disconnect())},children:"Sign out"})]})})]}),F.jsx("main",{children:typeof t=="number"?F.jsxs("article",{children:[F.jsx("h1",{children:t}),F.jsx("h2",{children:JSON.parse(jE[t])}),F.jsx(BE,{href:"/",children:"Return to Home Page"})]}):(()=>{switch(t[0]){case void 0:return F.jsx(G6,{});case"admin":return F.jsx(u4,{});case"game":return F.jsx(f4,{route:t});case"verify":return F.jsx(Y6,{route:t});case"account":return F.jsx(l4,{})}})()})]})}LM.createRoot(document.getElementById("root")).render(F.jsx($.StrictMode,{children:F.jsx(CM,{socket:gi,children:F.jsx(J6,{})})}));
|