tempest.games 0.2.41 → 0.2.42
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 +7 -0
- package/app/assets/{index-5PTtbPbo.js → index-IVY54Buk.js} +1 -1
- package/app/index.html +1 -1
- package/bin/backend.bun.js +1 -1
- package/bin/backend.worker.game.bun.js +1 -1
- package/bin/backend.worker.tribunal.bun.js +1 -1
- package/bin/frontend.bun.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,7 @@ function Nk(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var sS;function jk(){if(sS)return Ya;sS=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+o.key),"key"in o){c={};for(var d in o)d!=="key"&&(c[d]=o[d])}else c=o;return o=c.ref,{$$typeof:t,type:r,key:u,ref:o!==void 0?o:null,props:c}}return Ya.Fragment=e,Ya.jsx=n,Ya.jsxs=n,Ya}var oS;function Bk(){return oS||(oS=1,Kh.exports=jk()),Kh.exports}var Y=Bk();function Lk(t){return Object.entries(t)}const Yi=t=>JSON.parse(t),Ge=t=>JSON.stringify(t);function ct(t){return sf(mt.STORE,t,void 0)}function f1(t){return ny(mt.STORE,t,void 0)}function Ze(...t){return t.length===2?Un(mt.STORE,...t):Un(mt.STORE,...t)}function Vk(t,e){return MM(mt.STORE,t,e)}function Uk(t){return DM(t,mt.STORE)}const Br={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]"},qh=t=>(e,n,r,o,...c)=>{console[t](`${e} ${Br[n]} \`${r}\` ${o}`,...c)},zk={error:qh("error"),info:qh("info"),warn:qh("warn")};var Kk=class{logLevel;filter;logger;constructor(t,e,n=zk){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)}}},qk=class{store;constructor(t=mt.STORE){this.store=t,oM("root",t)}allocate(t,e,n){return vl(this.store,t,e,n)}fuse(t,e,n){return aM(this.store,t,e,n)}deallocate(t){Sl(this.store,t)}claim(t,e,n){return _u(this.store,t,e,n)}},Pk=class{store;realm;constructor(t=mt.STORE){this.store=t,this.realm=new qk(t)}allocate(t,e,n){vl(this.store,t,e,n)}deallocate(t){Sl(this.store,t)}claim(t,e,n){_u(this.store,t,e,n)}};function pi(t){return O1(mt.STORE,t)}function Ik(t){return EM(mt.STORE,t)}function De(...t){t.length===2?At(mt.STORE,...t):At(mt.STORE,...t)}function Hk(t,e,n=ef()){return RM(mt.STORE,t,e,n)}function Fk(t){return E1(mt.STORE,t)}function Gk(t,e=ef()){return Im(mt.STORE,t,e)}var Km=class du extends Set{mode="record";subject=new Qe;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(e,n=0){super(e),e instanceof du&&(this.parent=e,this.cacheUpdateNumber=e.cacheUpdateNumber),n&&(this.cacheLimit=n,this.cache=new Array(n),this.subscribe("auto cache",r=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=r}))}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(e){const n=new du(e.members,e.cacheLimit);return n.cache=e.cache,n.cacheIdx=e.cacheIdx,n.cacheUpdateNumber=e.cacheUpdateNumber,n}add(e){const n=super.add(e);return this.mode==="record"&&(this.cacheUpdateNumber++,this.emit(`add:${Ge(e)}`)),n}clear(){const e=this.mode==="record"?[...this]:null;super.clear(),e&&(this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(e)}`))}delete(e){const n=super.delete(e);return this.mode==="record"&&(this.cacheUpdateNumber++,this.emit(`del:${Ge(e)}`)),n}parent=null;child=null;transactionUpdates=null;transaction(e){this.mode="transaction",this.transactionUpdates=[],this.child=new du(this);const n=this.child._subscribe("transaction",r=>{this.transactionUpdates?.push(r)});try{if(e(this.child)){for(const o of this.transactionUpdates)this.doStep(o);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(r){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",r),r}finally{n(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(e,n){return this.subject.subscribe(e,n)}subscribe(e,n){return this.subject.subscribe(e,r=>{n(`${this.cacheUpdateNumber}=${r}`)})}emit(e){this.subject.next(e)}doStep(e){const n=e.indexOf(":"),r=e.substring(0,n),o=e.substring(n+1);switch(r){case"add":this.add(JSON.parse(o));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(o));break;case"tx":for(const c of o.split(";"))this.doStep(c)}}getUpdateNumber(e){const n=e.indexOf("=");return Number(e.substring(0,n))}do(e){const n=e.indexOf("="),r=Number(e.substring(0,n)),o=r-this.cacheUpdateNumber;if(o>0){if(o===1){this.mode="playback";const u=e.substring(n+1);return this.doStep(u),this.mode="record",this.cacheUpdateNumber=r,null}return this.cacheUpdateNumber+1}if(Math.abs(o)<this.cacheLimit){const u=this.cacheIdx+o;if(this.cache[u]===e)return null;this.mode="playback";let h=!1;for(;!h;){this.cacheIdx%=this.cacheLimit;const y=this.cache[this.cacheIdx];if(this.cacheIdx--,!y)return"OUT_OF_RANGE";this.undo(y),h=this.cacheIdx===u-1}const p=e.substring(n+1);return this.doStep(p),this.mode="record",this.cacheUpdateNumber=r,null}return"OUT_OF_RANGE"}undoStep(e){const n=e.indexOf(":"),r=e.substring(0,n),o=e.substring(n+1);switch(r){case"add":this.delete(JSON.parse(o));break;case"del":this.add(JSON.parse(o));break;case"clear":{const c=JSON.parse(o);for(const u of c)this.add(u);break}case"tx":{const c=o.split(";");for(let u=c.length-1;u>=0;u--)this.undoStep(c[u])}}}undo(e){const n=e.indexOf("=");if(Number(e.substring(0,n))===this.cacheUpdateNumber){this.mode="playback";const o=e.substring(n+1);return this.undoStep(o),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function ef(t=Math.random){return t().toString(36).slice(2)}function Re(t){for(;t.child!==null;)t=t.child;return t}var Yk=class d1{_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 d1([...this._buffer]);return e._index=this._index,e}};function Dr(t){const e={key:t.key,type:t.type};return"family"in t&&(e.family=t.family),e}const Xk=Symbol("counterfeit"),Jk={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"};function aS(t,e,n){const r=Ge(e),o=`${t.key}(${r})`,c=Jk[t.type],u={key:o,type:c,family:{key:t.key,subKey:r}};return n&&(u.counterfeit=!0),u}var Xt=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(t,e)=>`${t}:${e}`;warn;getRelatedKeys(t){return this.relations.get(t)}addRelation(t,e){let n=this.relations.get(t),r=this.relations.get(e);n?n.add(e):(n=new Set([e]),this.relations.set(t,n)),r?r.add(t):(r=new Set([t]),this.relations.set(e,r))}deleteRelation(t,e){const n=this.relations.get(t);if(n){n.delete(e),n.size===0&&this.relations.delete(t);const r=this.relations.get(e);r&&(r.delete(t),r.size===0&&this.relations.delete(e))}}replaceRelationsUnsafely(t,e){this.relations.set(t,new Set(e));for(const n of e){const r=new Set().add(t);this.relations.set(n,r)}}replaceRelationsSafely(t,e){const n=this.relations.get(t);let r=this.isAType?.(t)?t:void 0,o=r===void 0?t:void 0;if(n)for(const c of n){r??=c,o??=c;const u=this.relations.get(c);u&&(u.size===1?this.relations.delete(c):u.delete(t),this.contents.delete(this.makeContentKey(r,o)))}this.relations.set(t,new Set(e));for(const c of e){let u=this.relations.get(c);u?u.add(t):(u=new Set().add(t),this.relations.set(c,u))}}getContentInternal(t){return this.contents.get(t)}setContent(t,e){this.contents.set(t,e)}deleteContent(t){this.contents.delete(t)}constructor(t,e){if(this.a=t.between[0],this.b=t.between[1],this.cardinality=t.cardinality,e?.externalStore||(this.relations=new Map(t.relations?.map(([n,r])=>[n,new Set(r)])),this.contents=new Map(t.contents)),this.isAType=e?.isAType??null,this.isBType=e?.isBType??null,this.isContent=e?.isContent??null,e?.makeContentKey&&(this.makeContentKey=e.makeContentKey),e?.externalStore){const n=e.externalStore;this.has=(r,o)=>n.has(r,o),this.addRelation=(r,o)=>{n.addRelation(r,o)},this.deleteRelation=(r,o)=>{n.deleteRelation(r,o)},this.replaceRelationsSafely=(r,o)=>{n.replaceRelationsSafely(r,o)},this.replaceRelationsUnsafely=(r,o)=>{n.replaceRelationsUnsafely(r,o)},this.getRelatedKeys=(r=>n.getRelatedKeys(r)),n.getContent&&(this.getContentInternal=r=>n.getContent(r),this.setContent=(r,o)=>{n.setContent(r,o)},this.deleteContent=r=>{n.deleteContent(r)});for(const[r,o]of t.relations??[]){let c=this.isAType?.(r)?r:void 0,u=c===void 0?r:void 0;for(const d of o)c??=d,u??=d,this.addRelation(c,u)}for(const[r,o]of t.contents??[])this.setContent(r,o)}e?.warn&&(this.warn=e.warn)}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([t,e])=>[t,[...e]]),contents:[...this.contents.entries()]}}set(...t){let e,n,r;switch(t.length){case 1:{const o=t[0];e=o[this.a],n=o[this.b],r=void 0;break}case 2:{const o=t[0];typeof o=="string"?[e,n]=t:(e=o[this.a],n=o[this.b],r=t[1]);break}default:e=t[0],n=t[1],r=t[2];break}switch(this.cardinality){case"1:1":{const o=this.getRelatedKey(e);o&&o!==n&&this.delete(e,o)}case"1:n":{const o=this.getRelatedKey(n);o&&o!==e&&this.delete(o,n)}break}if(r){const o=this.makeContentKey(e,n);this.setContent(o,r)}return this.addRelation(e,n),this}delete(t,e){e=typeof e=="string"?e:t[this.b];const n=typeof t=="string"?t:t[this.a];if(n===void 0&&typeof e=="string"){const r=this.getRelatedKeys(e);if(r)for(const o of r)this.delete(o,e)}if(typeof n=="string"&&e===void 0){const r=this.getRelatedKeys(n);if(r)for(const o of r)this.delete(n,o)}if(typeof n=="string"&&typeof e=="string"){this.deleteRelation(n,e);const r=this.makeContentKey(n,e);this.deleteContent(r)}return this}getRelatedKey(t){const e=this.getRelatedKeys(t);if(e){e.size>1&&this.warn?.(`${e.size} related keys were found for key "${t}": (${[...e].map(r=>`"${r}"`).join(", ")}). Only one related key was expected.`);let n;for(const r of e){n=r;break}return n}}replaceRelations(t,e,n){const r=!Array.isArray(e),o=r?Object.keys(e):e;if(n?.reckless?this.replaceRelationsUnsafely(t,o):this.replaceRelationsSafely(t,o),r)for(const c of o){const u=this.makeContentKey(t,c),d=e[c];this.setContent(u,d)}return this}getContent(t,e){const n=this.makeContentKey(t,e);return this.getContentInternal(n)}getRelationEntries(t){const e=t[this.a],n=t[this.b];if(e!==void 0&&n===void 0){const r=this.getRelatedKeys(e);if(r)return[...r].map(o=>[o,this.getContent(e,o)])}if(e===void 0&&n!==void 0){const r=this.getRelatedKeys(n);if(r)return[...r].map(o=>[o,this.getContent(o,n)])}return[]}has(t,e){return e?this.getRelatedKeys(t)?.has(e)??!1:this.relations.has(t)}},Qe=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)}},Zk=class extends Qe{state;constructor(t){super(),this.state=t}next(t){this.state=t,super.next(t)}};const Qk=(t,e)=>{const n=Re(t);return n.operation.open?n.operation.prev.get(e.key):n.valueMap.get(e.key)};function h1(t,e,n,r){const o=t.disposalTraces.buffer.find(c=>c?.key===Ge(r));switch(t.logger.error("❌",e.type,e.key,"gets a fallback value because key",r,"is not allocated",o?`This key was previously disposed:
|
|
9
|
+
*/var sS;function jk(){if(sS)return Ya;sS=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+o.key),"key"in o){c={};for(var d in o)d!=="key"&&(c[d]=o[d])}else c=o;return o=c.ref,{$$typeof:t,type:r,key:u,ref:o!==void 0?o:null,props:c}}return Ya.Fragment=e,Ya.jsx=n,Ya.jsxs=n,Ya}var oS;function Bk(){return oS||(oS=1,Kh.exports=jk()),Kh.exports}var Y=Bk();function Lk(t){return Object.entries(t)}function Yi(t){return JSON.parse(t)}const Ge=t=>JSON.stringify(t);function ct(t){return sf(mt.STORE,t,void 0)}function f1(t){return ny(mt.STORE,t,void 0)}function Ze(...t){return t.length===2?Un(mt.STORE,...t):Un(mt.STORE,...t)}function Vk(t,e){return MM(mt.STORE,t,e)}function Uk(t){return DM(t,mt.STORE)}const Br={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]"},qh=t=>(e,n,r,o,...c)=>{console[t](`${e} ${Br[n]} \`${r}\` ${o}`,...c)},zk={error:qh("error"),info:qh("info"),warn:qh("warn")};var Kk=class{logLevel;filter;logger;constructor(t,e,n=zk){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)}}},qk=class{store;constructor(t=mt.STORE){this.store=t,oM("root",t)}allocate(t,e,n){return vl(this.store,t,e,n)}fuse(t,e,n){return aM(this.store,t,e,n)}deallocate(t){Sl(this.store,t)}claim(t,e,n){return _u(this.store,t,e,n)}},Pk=class{store;realm;constructor(t=mt.STORE){this.store=t,this.realm=new qk(t)}allocate(t,e,n){vl(this.store,t,e,n)}deallocate(t){Sl(this.store,t)}claim(t,e,n){_u(this.store,t,e,n)}};function pi(t){return O1(mt.STORE,t)}function Ik(t){return EM(mt.STORE,t)}function De(...t){t.length===2?At(mt.STORE,...t):At(mt.STORE,...t)}function Hk(t,e,n=ef()){return RM(mt.STORE,t,e,n)}function Fk(t){return E1(mt.STORE,t)}function Gk(t,e=ef()){return Im(mt.STORE,t,e)}var Km=class du extends Set{mode="record";subject=new Qe;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(e,n=0){super(e),e instanceof du&&(this.parent=e,this.cacheUpdateNumber=e.cacheUpdateNumber),n&&(this.cacheLimit=n,this.cache=new Array(n),this.subscribe("auto cache",r=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=r}))}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(e){const n=new du(e.members,e.cacheLimit);return n.cache=e.cache,n.cacheIdx=e.cacheIdx,n.cacheUpdateNumber=e.cacheUpdateNumber,n}add(e){const n=super.add(e);return this.mode==="record"&&(this.cacheUpdateNumber++,this.emit(`add:${Ge(e)}`)),n}clear(){const e=this.mode==="record"?[...this]:null;super.clear(),e&&(this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(e)}`))}delete(e){const n=super.delete(e);return this.mode==="record"&&(this.cacheUpdateNumber++,this.emit(`del:${Ge(e)}`)),n}parent=null;child=null;transactionUpdates=null;transaction(e){this.mode="transaction",this.transactionUpdates=[],this.child=new du(this);const n=this.child._subscribe("transaction",r=>{this.transactionUpdates?.push(r)});try{if(e(this.child)){for(const o of this.transactionUpdates)this.doStep(o);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(r){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",r),r}finally{n(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(e,n){return this.subject.subscribe(e,n)}subscribe(e,n){return this.subject.subscribe(e,r=>{n(`${this.cacheUpdateNumber}=${r}`)})}emit(e){this.subject.next(e)}doStep(e){const n=e.indexOf(":"),r=e.substring(0,n),o=e.substring(n+1);switch(r){case"add":this.add(JSON.parse(o));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(o));break;case"tx":for(const c of o.split(";"))this.doStep(c)}}getUpdateNumber(e){const n=e.indexOf("=");return Number(e.substring(0,n))}do(e){const n=e.indexOf("="),r=Number(e.substring(0,n)),o=r-this.cacheUpdateNumber;if(o>0){if(o===1){this.mode="playback";const u=e.substring(n+1);return this.doStep(u),this.mode="record",this.cacheUpdateNumber=r,null}return this.cacheUpdateNumber+1}if(Math.abs(o)<this.cacheLimit){const u=this.cacheIdx+o;if(this.cache[u]===e)return null;this.mode="playback";let h=!1;for(;!h;){this.cacheIdx%=this.cacheLimit;const y=this.cache[this.cacheIdx];if(this.cacheIdx--,!y)return"OUT_OF_RANGE";this.undo(y),h=this.cacheIdx===u-1}const p=e.substring(n+1);return this.doStep(p),this.mode="record",this.cacheUpdateNumber=r,null}return"OUT_OF_RANGE"}undoStep(e){const n=e.indexOf(":"),r=e.substring(0,n),o=e.substring(n+1);switch(r){case"add":this.delete(JSON.parse(o));break;case"del":this.add(JSON.parse(o));break;case"clear":{const c=JSON.parse(o);for(const u of c)this.add(u);break}case"tx":{const c=o.split(";");for(let u=c.length-1;u>=0;u--)this.undoStep(c[u])}}}undo(e){const n=e.indexOf("=");if(Number(e.substring(0,n))===this.cacheUpdateNumber){this.mode="playback";const o=e.substring(n+1);return this.undoStep(o),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function ef(t=Math.random){return t().toString(36).slice(2)}function Re(t){for(;t.child!==null;)t=t.child;return t}var Yk=class d1{_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 d1([...this._buffer]);return e._index=this._index,e}};function Dr(t){const e={key:t.key,type:t.type};return"family"in t&&(e.family=t.family),e}const Xk=Symbol("counterfeit"),Jk={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"};function aS(t,e,n){const r=Ge(e),o=`${t.key}(${r})`,c=Jk[t.type],u={key:o,type:c,family:{key:t.key,subKey:r}};return n&&(u.counterfeit=!0),u}var Xt=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(t,e)=>`${t}:${e}`;warn;getRelatedKeys(t){return this.relations.get(t)}addRelation(t,e){let n=this.relations.get(t),r=this.relations.get(e);n?n.add(e):(n=new Set([e]),this.relations.set(t,n)),r?r.add(t):(r=new Set([t]),this.relations.set(e,r))}deleteRelation(t,e){const n=this.relations.get(t);if(n){n.delete(e),n.size===0&&this.relations.delete(t);const r=this.relations.get(e);r&&(r.delete(t),r.size===0&&this.relations.delete(e))}}replaceRelationsUnsafely(t,e){this.relations.set(t,new Set(e));for(const n of e){const r=new Set().add(t);this.relations.set(n,r)}}replaceRelationsSafely(t,e){const n=this.relations.get(t);let r=this.isAType?.(t)?t:void 0,o=r===void 0?t:void 0;if(n)for(const c of n){r??=c,o??=c;const u=this.relations.get(c);u&&(u.size===1?this.relations.delete(c):u.delete(t),this.contents.delete(this.makeContentKey(r,o)))}this.relations.set(t,new Set(e));for(const c of e){let u=this.relations.get(c);u?u.add(t):(u=new Set().add(t),this.relations.set(c,u))}}getContentInternal(t){return this.contents.get(t)}setContent(t,e){this.contents.set(t,e)}deleteContent(t){this.contents.delete(t)}constructor(t,e){if(this.a=t.between[0],this.b=t.between[1],this.cardinality=t.cardinality,e?.externalStore||(this.relations=new Map(t.relations?.map(([n,r])=>[n,new Set(r)])),this.contents=new Map(t.contents)),this.isAType=e?.isAType??null,this.isBType=e?.isBType??null,this.isContent=e?.isContent??null,e?.makeContentKey&&(this.makeContentKey=e.makeContentKey),e?.externalStore){const n=e.externalStore;this.has=(r,o)=>n.has(r,o),this.addRelation=(r,o)=>{n.addRelation(r,o)},this.deleteRelation=(r,o)=>{n.deleteRelation(r,o)},this.replaceRelationsSafely=(r,o)=>{n.replaceRelationsSafely(r,o)},this.replaceRelationsUnsafely=(r,o)=>{n.replaceRelationsUnsafely(r,o)},this.getRelatedKeys=(r=>n.getRelatedKeys(r)),n.getContent&&(this.getContentInternal=r=>n.getContent(r),this.setContent=(r,o)=>{n.setContent(r,o)},this.deleteContent=r=>{n.deleteContent(r)});for(const[r,o]of t.relations??[]){let c=this.isAType?.(r)?r:void 0,u=c===void 0?r:void 0;for(const d of o)c??=d,u??=d,this.addRelation(c,u)}for(const[r,o]of t.contents??[])this.setContent(r,o)}e?.warn&&(this.warn=e.warn)}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([t,e])=>[t,[...e]]),contents:[...this.contents.entries()]}}set(...t){let e,n,r;switch(t.length){case 1:{const o=t[0];e=o[this.a],n=o[this.b],r=void 0;break}case 2:{const o=t[0];typeof o=="string"?[e,n]=t:(e=o[this.a],n=o[this.b],r=t[1]);break}default:e=t[0],n=t[1],r=t[2];break}switch(this.cardinality){case"1:1":{const o=this.getRelatedKey(e);o&&o!==n&&this.delete(e,o)}case"1:n":{const o=this.getRelatedKey(n);o&&o!==e&&this.delete(o,n)}break}if(r){const o=this.makeContentKey(e,n);this.setContent(o,r)}return this.addRelation(e,n),this}delete(t,e){e=typeof e=="string"?e:t[this.b];const n=typeof t=="string"?t:t[this.a];if(n===void 0&&typeof e=="string"){const r=this.getRelatedKeys(e);if(r)for(const o of r)this.delete(o,e)}if(typeof n=="string"&&e===void 0){const r=this.getRelatedKeys(n);if(r)for(const o of r)this.delete(n,o)}if(typeof n=="string"&&typeof e=="string"){this.deleteRelation(n,e);const r=this.makeContentKey(n,e);this.deleteContent(r)}return this}getRelatedKey(t){const e=this.getRelatedKeys(t);if(e){e.size>1&&this.warn?.(`${e.size} related keys were found for key "${t}": (${[...e].map(r=>`"${r}"`).join(", ")}). Only one related key was expected.`);let n;for(const r of e){n=r;break}return n}}replaceRelations(t,e,n){const r=!Array.isArray(e),o=r?Object.keys(e):e;if(n?.reckless?this.replaceRelationsUnsafely(t,o):this.replaceRelationsSafely(t,o),r)for(const c of o){const u=this.makeContentKey(t,c),d=e[c];this.setContent(u,d)}return this}getContent(t,e){const n=this.makeContentKey(t,e);return this.getContentInternal(n)}getRelationEntries(t){const e=t[this.a],n=t[this.b];if(e!==void 0&&n===void 0){const r=this.getRelatedKeys(e);if(r)return[...r].map(o=>[o,this.getContent(e,o)])}if(e===void 0&&n!==void 0){const r=this.getRelatedKeys(n);if(r)return[...r].map(o=>[o,this.getContent(o,n)])}return[]}has(t,e){return e?this.getRelatedKeys(t)?.has(e)??!1:this.relations.has(t)}},Qe=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)}},Zk=class extends Qe{state;constructor(t){super(),this.state=t}next(t){this.state=t,super.next(t)}};const Qk=(t,e)=>{const n=Re(t);return n.operation.open?n.operation.prev.get(e.key):n.valueMap.get(e.key)};function h1(t,e,n,r){const o=t.disposalTraces.buffer.find(c=>c?.key===Ge(r));switch(t.logger.error("❌",e.type,e.key,"gets a fallback value because key",r,"is not allocated",o?`This key was previously disposed:
|
|
10
10
|
${o.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 c=new n.class;return t.defaults.set(n.key,c),c}case"atom_family":{if(t.defaults.has(n.key))return t.defaults.get(n.key);const c=n.default,u=c(r);return t.defaults.set(n.key,u),u}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 c=n.default(r);return t.defaults.set(n.key,c),c}}}var Np=class extends Promise{fate;resolve;reject;done=!1;constructor(t){let e,n;super((r,o)=>{e=r,n=o}),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}};function Xi(t){return"epoch"in t.transactionMeta}function ln(t){return"phase"in t.transactionMeta}function p1(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},t.logger.info("⭕",e.type,e.key,`operation start in store "${t.config.name}"${ln(t)?` ${t.transactionMeta.phase} "${t.transactionMeta.update.token.key}"`:""}`),t}function m1(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 y1=(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),tf=(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 qm(t,e){const n=Re(t),{key:r,type:o}=e,c=n.selectorAtoms.getRelatedKeys(r);if(n.logger.info("🧹",o,r,c?`evicting ${c.size} states downstream:`:"no downstream states",c??"to evict"),c){n.operation.open&&n.logger.info("🧹",o,r,`[ ${[...n.operation.done].join(", ")} ] already done`);for(const u of c)y1(n,u)||(b1(n,u),tf(n,u))}}function g1(t,e){const n=Re(t),r=n.selectorGraph.getRelationEntries({upstreamSelectorKey:e}).filter(([o,{source:c}])=>c===e);for(const[o]of r)y1(n,o)||(b1(n,o),tf(n,o),g1(t,o))}function zi(t,e,n){const{key:r,subject:o,type:c}=e,u=t.valueMap.get(r);if(u instanceof Np&&!u.done){const d=u;return n instanceof Promise?(d.use(n),d):(t.valueMap.set(r,n),n)}if(n instanceof Promise){const d=new Np(n);return t.valueMap.set(r,d),d.then(function(p){if(t.valueMap.get(r)===d){switch(p1(t,e),zi(t,e,p),c){case"atom":case"mutable_atom":qm(t,e);break;case"readonly_pure_selector":case"writable_pure_selector":g1(t,r);break}m1(t),o.next({newValue:p,oldValue:d})}}).catch(h=>{t.logger.error("💥","state",r,"rejected:",h)}),d}return t.valueMap.set(r,n),n}function Wk(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"&&ln(t)){const c=e,{parent:u}=t;if(t.valueMap.hasOwn(c.key))return r;const d=u.valueMap.get(c.key);t.logger.info("📃","atom",c.key,"copying");const h=d.toJSON(),p=c.class.fromJSON(h);t.valueMap.set(c.key,p),new ty(c,u),r=p}return r}function b1(t,e){const n=t.valueMap.get(e);if(n instanceof Np){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 Po(t,e,n){if(t.valueMap.has(e.key))return Wk(t,e,n);const{key:r}=e;switch(e.type){case"readonly_held_selector":case"readonly_pure_selector":case"writable_held_selector":case"writable_pure_selector":return t.logger.info("🧮",e.type,r,"computing value"),e.getFrom(t);case"atom":{let o;e.default instanceof Function?o=e.default():o=e.default;const c=zi(t,e,o);return t.logger.info("💁","atom",e.key,"could not find cached value; using default",o),c}case"mutable_atom":{const o=new e.class,c=zi(t,e,o);return t.logger.info("💁","mutable_atom",e.key,"could not find cached value; using default",o),c}}}function Pm(t,e){return it(t,{key:e.family.key,type:`${e.type}_family`})}const eM=t=>{const e=Re(t);if(!ln(e)){t.logger.warn("🐞","transaction","???","abortTransaction called outside of a transaction. This is probably a bug in AtomIO.");return}t.logger.info("🪂","transaction",e.transactionMeta.update.token.key,"Aborting transaction"),e.parent.child=null};var v1=class extends Error{constructor(t,e){super(`${Br[t.type]} ${Ge(t.key)} not found in store "${e.config.name}".`)}};function Im(t,e,n){return(...r)=>{const o=it(t,e);if(o)return o.run(r,n);throw new v1(e,t)}}const $p=t=>e=>t instanceof Function?t(e):t;function S1(t,e,[n,r],o){const{key:c,subject:u,type:d}=e,h={oldValue:Ph(n)?n.READONLY_VIEW:n,newValue:Ph(r)?r.READONLY_VIEW:r};if(Xi(t)){switch(d){case"mutable_atom":t.logger.info("📢",d,c,"is now (",r,") subscribers:",u.subscribers);break;case"atom":case"writable_pure_selector":case"writable_held_selector":t.logger.info("📢",d,c,"went (",n,"->",r,") subscribers:",u.subscribers)}u.next(h)}if(ln(t)&&(d==="mutable_atom"||d==="atom")){if(t.on.transactionApplying.state===null){const p=Dr(e);if(Ph(r))return;const{timestamp:y}=t.operation,g={type:"atom_update",token:p,timestamp:y,update:h};t.transactionMeta.update.subEvents.push(g),t.logger.info("📁","atom",c,"stowed (",n,"->",r,")");return}if(kM(e,"tracker:signal")){const p=c.slice(1),y=t.atoms.get(p);Po(t,y,"mut").do(h.newValue)===null===!0&&qm(t,y)}}}const jp=(t,e,n)=>{const r=Po(t,e,"mut");let o=$p(n)(r);return t.logger.info("📝","atom",e.key,"set to",o),o=zi(t,e,o),tf(t,e.key),qm(t,e),[r,o]};function lS(t,e){switch(e.type){case"mutable_atom":return jp(t,e,new e.class);case"atom":{let n=e.default;return n instanceof Function&&(n=n()),jp(t,e,n)}}}function tM(t,e){let n;switch(e.type){case"atom":case"mutable_atom":n=lS(t,e);break;case"writable_pure_selector":case"writable_held_selector":{const r=e.getFrom(t),o=ku(t,e.key);for(const u of o.values()){const d=lS(t,u);S1(t,e,d)}const c=e.getFrom(t);n=[r,c]}break}return n}function At(t,...e){Gm(t,Bp,...e)}const Ou=Symbol("RESET");function Hm(t,...e){let n,r,o;e.length===1?(n=e[0],At(t,n,Ou)):(r=e[0],o=e[1],At(t,r,o,Ou))}function nM(t,e,n){let r,o,c;const{type:u,key:d}=e;switch(e.type){case"writable_pure_selector":r=e.getFrom(t),o=$p(n)(r),zi(t,e,o);break;case"writable_held_selector":c=e.const,$p(n)(c),r=c,o=c}return t.logger.info("📝",u,d,"setting to",o),tf(t,d),e.setSelf(o),[r,o]}const iM=(t,e,n)=>{let r;switch(e.type){case"atom":case"mutable_atom":r=jp(t,e,n);break;case"writable_pure_selector":case"writable_held_selector":r=nM(t,e,n);break}return r};function rM(t,e,n){const{token:r,update:{newValue:o,oldValue:c}}=e;At(n,r,t==="newValue"?o:c)}function sM(t){const{stack:e}=t;return e?`
|
|
11
11
|
`+e.split(`
|
|
12
12
|
`)?.slice(1)?.join(`
|
package/app/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>TEMPEST</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-IVY54Buk.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-ki_mruCb.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/bin/backend.bun.js
CHANGED
|
@@ -288,7 +288,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
288
288
|
`)}})).pipeThrough(new TextEncoderStream)}var pin={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform","X-Accel-Buffering":"no",Connection:"keep-alive"},din=Re(nb(),1),zD=Re(Ka(),1);function VT(n){return cl((0,din.default)(function*(){throw n}))}var fin={mutation:["POST"],query:["GET"],subscription:["GET"]},bin={mutation:["POST"],query:["GET","POST"],subscription:["GET","POST"]};function hE(n){var e,i,t;let{ctx:a,info:r,responseMeta:o,untransformedJSON:u,errors:s=[],headers:l}=n,c=u?B9(u):200,f=!u,b=f?[]:Array.isArray(u)?u:[u],m=(e=o===null||o===void 0?void 0:o({ctx:a,info:r,paths:r===null||r===void 0?void 0:r.calls.map((E)=>E.path),data:b,errors:s,eagerGeneration:f,type:(i=r===null||r===void 0||(t=r.calls.find((E)=>{var h;return(h=E.procedure)===null||h===void 0?void 0:h._def.type}))===null||t===void 0||(t=t.procedure)===null||t===void 0?void 0:t._def.type)!==null&&i!==void 0?i:"unknown"}))!==null&&e!==void 0?e:{};if(m.headers){if(m.headers instanceof Headers)for(let[E,h]of m.headers.entries())l.append(E,h);else for(let[E,h]of Object.entries(m.headers))if(Array.isArray(h))for(let D of h)l.append(E,D);else if(typeof h==="string")l.set(E,h)}if(m.status)c=m.status;return{status:c}}function gin(n,e){let{router:i,req:t,onError:a}=e.opts,r=ra(n);a===null||a===void 0||a({error:r,path:e.path,input:e.input,ctx:e.ctx,type:e.type,req:t});let o={error:pl({config:i._def._config,error:r,type:e.type,path:e.path,input:e.input,ctx:e.ctx})},u=Zp(i._def._config,o),s=JSON.stringify(u);return{error:r,untransformedJSON:o,body:s}}function sM(n){if(!Ht(n))return!1;if(gE(n))return!0;return Object.values(n).some(hM)||Object.values(n).some(gE)}async function AM(n){var e,i,t,a,r,o;let{router:u,req:s}=n,l=new Headers([["vary","trpc-accept"]]),c=u._def._config,f=new URL(s.url);if(s.method==="HEAD")return new Response(null,{status:204});let b=(e=(i=n.allowBatching)!==null&&i!==void 0?i:(t=n.batching)===null||t===void 0?void 0:t.enabled)!==null&&e!==void 0?e:!0,m=((a=n.allowMethodOverride)!==null&&a!==void 0?a:!1)&&s.method==="POST",E=await cl(async()=>{try{return[void 0,await Cen({req:s,path:decodeURIComponent(n.path),router:u,searchParams:f.searchParams,headers:n.req.headers,url:f})]}catch(F){return[ra(F),void 0]}}),h=cl(()=>{let F=void 0;return{valueOrUndefined:()=>{if(!F)return;return F[1]},value:()=>{let[x,I]=F;if(x)throw x;return I},create:async(x)=>{if(F)throw new Error("This should only be called once - report a bug in tRPC");try{F=[void 0,await n.createContext({info:x})]}catch(I){F=[ra(I),void 0]}}}}),D=m?bin:fin,T=s.headers.get("trpc-accept")==="application/jsonl",v=(r=(o=c.sse)===null||o===void 0?void 0:o.enabled)!==null&&r!==void 0?r:!0;try{let[F,x]=E;if(F)throw F;if(x.isBatchCall&&!b)throw new Vn({code:"BAD_REQUEST",message:"Batching is not enabled on the server"});if(T&&!x.isBatchCall)throw new Vn({message:"Streaming requests must be batched (you can do a batch of 1)",code:"BAD_REQUEST"});await h.create(x);let I=x.calls.map(async(K)=>{let Z=K.procedure;try{if(n.error)throw n.error;if(!Z)throw new Vn({code:"NOT_FOUND",message:`No procedure found on path "${K.path}"`});if(!D[Z._def.type].includes(s.method))throw new Vn({code:"METHOD_NOT_SUPPORTED",message:`Unsupported ${s.method}-request to ${Z._def.type} procedure at path "${K.path}"`});if(Z._def.type==="subscription"){if(x.isBatchCall)throw new Vn({code:"BAD_REQUEST",message:"Cannot batch subscription calls"})}return[void 0,{data:await Z({path:K.path,getRawInput:K.getRawInput,ctx:h.value(),type:Z._def.type,signal:n.req.signal})}]}catch(Dn){var J,an,on;let Ln=ra(Dn),Q=K.result();return(J=n.onError)===null||J===void 0||J.call(n,{error:Ln,path:K.path,input:Q,ctx:h.valueOrUndefined(),type:(an=(on=K.procedure)===null||on===void 0?void 0:on._def.type)!==null&&an!==void 0?an:"unknown",req:n.req}),[Ln,void 0]}});if(!x.isBatchCall){let[K]=x.calls,[Z,J]=await I[0];switch(x.type){case"unknown":case"mutation":case"query":{if(l.set("content-type","application/json"),sM(J===null||J===void 0?void 0:J.data))throw new Vn({code:"UNSUPPORTED_MEDIA_TYPE",message:"Cannot use stream-like response in non-streaming request - use httpBatchStreamLink"});let an=Z?{error:pl({config:c,ctx:h.valueOrUndefined(),error:Z,input:K.result(),path:K.path,type:x.type})}:{result:{data:J.data}},on=hE({ctx:h.valueOrUndefined(),info:x,responseMeta:n.responseMeta,errors:Z?[Z]:[],headers:l,untransformedJSON:[an]});return new Response(JSON.stringify(Zp(c,an)),{status:on.status,headers:l})}case"subscription":{let an=cl(()=>{if(Z)return VT(Z);if(!v)return VT(new Vn({code:"METHOD_NOT_SUPPORTED",message:'Missing experimental flag "sseSubscriptions"'}));if(!UD(J.data)&&!gE(J.data))return VT(new Vn({message:`Subscription ${K.path} did not return an observable or a AsyncGenerator`,code:"INTERNAL_SERVER_ERROR"}));return UD(J.data)?BT(J.data,n.req.signal):J.data}),on=cin((0,zD.default)((0,zD.default)({},c.sse),{},{data:an,serialize:(Ln)=>c.transformer.output.serialize(Ln),formatError(Ln){var Q,O,X;let pn=ra(Ln.error),_n=K===null||K===void 0?void 0:K.result(),vn=K===null||K===void 0?void 0:K.path,En=(Q=K===null||K===void 0||(O=K.procedure)===null||O===void 0?void 0:O._def.type)!==null&&Q!==void 0?Q:"unknown";return(X=n.onError)===null||X===void 0||X.call(n,{error:pn,path:vn,input:_n,ctx:h.valueOrUndefined(),req:n.req,type:En}),pl({config:c,ctx:h.valueOrUndefined(),error:pn,input:_n,path:vn,type:En})}}));for(let[Ln,Q]of Object.entries(pin))l.set(Ln,Q);let Dn=hE({ctx:h.valueOrUndefined(),info:x,responseMeta:n.responseMeta,errors:[],headers:l,untransformedJSON:null});return new Response(on,{headers:l,status:Dn.status})}}}if(x.accept==="application/jsonl"){l.set("content-type","application/json"),l.set("transfer-encoding","chunked");let K=hE({ctx:h.valueOrUndefined(),info:x,responseMeta:n.responseMeta,errors:[],headers:l,untransformedJSON:null}),Z=tin((0,zD.default)((0,zD.default)({},c.jsonl),{},{maxDepth:1/0,data:I.map(async(J)=>{let[an,on]=await J,Dn=x.calls[0];if(an){var Ln,Q;return{error:pl({config:c,ctx:h.valueOrUndefined(),error:an,input:Dn.result(),path:Dn.path,type:(Ln=(Q=Dn.procedure)===null||Q===void 0?void 0:Q._def.type)!==null&&Ln!==void 0?Ln:"unknown"})}}let O=UD(on.data)?BT(on.data,n.req.signal):Promise.resolve(on.data);return{result:Promise.resolve({data:O})}}),serialize:(J)=>c.transformer.output.serialize(J),onError:(J)=>{var an,on;(an=n.onError)===null||an===void 0||an.call(n,{error:ra(J),path:void 0,input:void 0,ctx:h.valueOrUndefined(),req:n.req,type:(on=x===null||x===void 0?void 0:x.type)!==null&&on!==void 0?on:"unknown"})},formatError(J){var an,on;let Dn=x===null||x===void 0?void 0:x.calls[J.path[0]],Ln=ra(J.error),Q=Dn===null||Dn===void 0?void 0:Dn.result(),O=Dn===null||Dn===void 0?void 0:Dn.path,X=(an=Dn===null||Dn===void 0||(on=Dn.procedure)===null||on===void 0?void 0:on._def.type)!==null&&an!==void 0?an:"unknown";return pl({config:c,ctx:h.valueOrUndefined(),error:Ln,input:Q,path:O,type:X})}}));return new Response(Z,{headers:l,status:K.status})}l.set("content-type","application/json");let U=(await Promise.all(I)).map((K)=>{let[Z,J]=K;if(Z)return K;if(sM(J.data))return[new Vn({code:"UNSUPPORTED_MEDIA_TYPE",message:"Cannot use stream-like response in non-streaming request - use httpBatchStreamLink"}),void 0];return K}),W=U.map(([K,Z],J)=>{let an=x.calls[J];if(K){var on,Dn;return{error:pl({config:c,ctx:h.valueOrUndefined(),error:K,input:an.result(),path:an.path,type:(on=(Dn=an.procedure)===null||Dn===void 0?void 0:Dn._def.type)!==null&&on!==void 0?on:"unknown"})}}return{result:{data:Z.data}}}),B=U.map(([K])=>K).filter(Boolean),H=hE({ctx:h.valueOrUndefined(),info:x,responseMeta:n.responseMeta,untransformedJSON:W,errors:B,headers:l});return new Response(JSON.stringify(Zp(c,W)),{status:H.status,headers:l})}catch(F){var N;let[x,I]=E,U=h.valueOrUndefined(),{error:W,untransformedJSON:B,body:H}=gin(F,{opts:n,ctx:h.valueOrUndefined(),type:(N=I===null||I===void 0?void 0:I.type)!==null&&N!==void 0?N:"unknown"}),K=hE({ctx:U,info:I,responseMeta:n.responseMeta,untransformedJSON:B,errors:[W],headers:l});return new Response(H,{status:K.status,headers:l})}}var BD=Re(Ka(),1),RM="middlewareMarker";function min(){function n(i){return{_middlewares:i,unstable_pipe(t){let a="_middlewares"in t?t._middlewares:[t];return n([...i,...a])}}}function e(i){return n([i])}return e}function Ein(n){let e=async function i(t){let a,r=await t.getRawInput();try{a=await n(r)}catch(u){throw new Vn({code:"BAD_REQUEST",cause:u})}let o=Ht(t.input)&&Ht(a)?(0,BD.default)((0,BD.default)({},t.input),a):a;return t.next({input:o})};return e._type="input",e}function hin(n){let e=async function i({next:t}){let a=await t();if(!a.ok)return a;try{let r=await n(a.data);return(0,BD.default)((0,BD.default)({},a),{},{data:r})}catch(r){throw new Vn({message:"Output validation failed",code:"INTERNAL_SERVER_ERROR",cause:r})}};return e._type="output",e}var Ain=Re(Xp(),1),TM=class extends Error{constructor(n){var e;super((e=n[0])===null||e===void 0?void 0:e.message);(0,Ain.default)(this,"issues",void 0),this.name="SchemaError",this.issues=n}};function DM(n){let e=n,i="~standard"in e;if(typeof e==="function"&&typeof e.assert==="function")return e.assert.bind(e);if(typeof e==="function"&&!i)return e;if(typeof e.parseAsync==="function")return e.parseAsync.bind(e);if(typeof e.parse==="function")return e.parse.bind(e);if(typeof e.validateSync==="function")return e.validateSync.bind(e);if(typeof e.create==="function")return e.create.bind(e);if(typeof e.assert==="function")return(t)=>{return e.assert(t),t};if(i)return async(t)=>{let a=await e["~standard"].validate(t);if(a.issues)throw new TM(a.issues);return a.value};throw new Error("Could not find a validator fn")}var Din=Qa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(n,e){function i(t,a){if(t==null)return{};var r={};for(var o in t)if({}.hasOwnProperty.call(t,o)){if(a.includes(o))continue;r[o]=t[o]}return r}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}}),win=Qa({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(n,e){var i=Din();function t(a,r){if(a==null)return{};var o,u,s=i(a,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(a);for(u=0;u<l.length;u++)o=l[u],r.includes(o)||{}.propertyIsEnumerable.call(a,o)&&(s[o]=a[o])}return s}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}}),vin=Re(win(),1),lt=Re(Ka(),1),Rin=["middlewares","inputs","meta"];function Dc(n,e){let{middlewares:i=[],inputs:t,meta:a}=e,r=(0,vin.default)(e,Rin);return SM((0,lt.default)((0,lt.default)({},LD(n,r)),{},{inputs:[...n.inputs,...t!==null&&t!==void 0?t:[]],middlewares:[...n.middlewares,...i],meta:n.meta&&a?(0,lt.default)((0,lt.default)({},n.meta),a):a!==null&&a!==void 0?a:n.meta}))}function SM(n={}){let e=(0,lt.default)({procedure:!0,inputs:[],middlewares:[]},n);return{_def:e,input(t){let a=DM(t);return Dc(e,{inputs:[t],middlewares:[Ein(a)]})},output(t){let a=DM(t);return Dc(e,{output:t,middlewares:[hin(a)]})},meta(t){return Dc(e,{meta:t})},use(t){let a="_middlewares"in t?t._middlewares:[t];return Dc(e,{middlewares:a})},unstable_concat(t){return Dc(e,t._def)},concat(t){return Dc(e,t._def)},query(t){return eS((0,lt.default)((0,lt.default)({},e),{},{type:"query"}),t)},mutation(t){return eS((0,lt.default)((0,lt.default)({},e),{},{type:"mutation"}),t)},subscription(t){return eS((0,lt.default)((0,lt.default)({},e),{},{type:"subscription"}),t)},experimental_caller(t){return Dc(e,{caller:t})}}}function eS(n,e){let i=Dc(n,{resolver:e,middlewares:[async function u(s){let l=await e(s);return{marker:RM,ok:!0,data:l,ctx:s.ctx}}]}),t=(0,lt.default)((0,lt.default)({},i._def),{},{type:n.type,experimental_caller:Boolean(i._def.caller),meta:i._def.meta,$types:null}),a=Sin(i._def),r=i._def.caller;if(!r)return a;let o=async(...u)=>{return await r({args:u,invoke:a,_def:t})};return o._def=t,o}var Tin=`
|
|
289
289
|
This is a client-only function.
|
|
290
290
|
If you want to call this function on the server, see https://trpc.io/docs/v11/server/server-side-calls
|
|
291
|
-
`.trim();async function xM(n,e,i){try{let t=e.middlewares[n];return await t((0,lt.default)((0,lt.default)({},i),{},{meta:e.meta,input:i.input,next(r){var o;let u=r;return xM(n+1,e,(0,lt.default)((0,lt.default)({},i),{},{ctx:(u===null||u===void 0?void 0:u.ctx)?(0,lt.default)((0,lt.default)({},i.ctx),u.ctx):i.ctx,input:u&&"input"in u?u.input:i.input,getRawInput:(o=u===null||u===void 0?void 0:u.getRawInput)!==null&&o!==void 0?o:i.getRawInput}))}}))}catch(t){return{ok:!1,error:ra(t),marker:RM}}}function Sin(n){async function e(i){if(!i||!("getRawInput"in i))throw new Error(Tin);let t=await xM(0,n,i);if(!t)throw new Vn({code:"INTERNAL_SERVER_ERROR",message:"No result from middlewares - did you forget to `return next()`?"});if(!t.ok)throw t.error;return t.data}return e._def=n,e.procedure=!0,e.meta=n.meta,e}var eb,ib,tb,wM=typeof window==="undefined"||"Deno"in window||((eb=globalThis.process)===null||eb===void 0||(eb=eb.env)===null||eb===void 0?void 0:eb.NODE_ENV)==="test"||!!((ib=globalThis.process)===null||ib===void 0||(ib=ib.env)===null||ib===void 0?void 0:ib.JEST_WORKER_ID)||!!((tb=globalThis.process)===null||tb===void 0||(tb=tb.env)===null||tb===void 0?void 0:tb.VITEST_WORKER_ID),vM=Re(Ka(),1),xin=class n{context(){return new n}meta(){return new n}create(e){var i,t,a,r,o,u;let s=(0,vM.default)((0,vM.default)({},e),{},{transformer:X9((i=e===null||e===void 0?void 0:e.transformer)!==null&&i!==void 0?i:qf),isDev:(t=e===null||e===void 0?void 0:e.isDev)!==null&&t!==void 0?t:((a=globalThis.process)===null||a===void 0?void 0:a.env.NODE_ENV)!=="production",allowOutsideOfServer:(r=e===null||e===void 0?void 0:e.allowOutsideOfServer)!==null&&r!==void 0?r:!1,errorFormatter:(o=e===null||e===void 0?void 0:e.errorFormatter)!==null&&o!==void 0?o:Jf,isServer:(u=e===null||e===void 0?void 0:e.isServer)!==null&&u!==void 0?u:wM,$types:null});{var l;if(!((l=e===null||e===void 0?void 0:e.isServer)!==null&&l!==void 0?l:wM)&&(e===null||e===void 0?void 0:e.allowOutsideOfServer)!==!0)throw new Error("You're trying to use @trpc/server in a non-server environment. This is not supported by default.")}return{_config:s,procedure:SM({meta:e===null||e===void 0?void 0:e.defaultMeta}),middleware:min(),router:HT(s),mergeRouters:Z9,createCallerFactory:kT()}}},iS=new xin;function _in(n,e){if("body"in n){if(n.body===void 0)return;if(typeof n.body==="string")return n.body;return JSON.stringify(n.body)}let i=0,t=!1;return new ReadableStream({start(a){let r=(u)=>{if(i+=u.length,!e.maxBodySize||i<=e.maxBodySize){a.enqueue(new Uint8Array(u.buffer,u.byteOffset,u.byteLength));return}a.error(new Vn({code:"PAYLOAD_TOO_LARGE"})),t=!0,n.off("data",r),n.off("end",o)},o=()=>{if(t)return;t=!0,n.off("data",r),n.off("end",o),a.close()};n.on("data",r),n.on("end",o)},cancel(){n.destroy()}})}function tS(n){try{var e,i;let t=n.headers[":scheme"]&&n.headers[":scheme"]==="https"||n.socket&&"encrypted"in n.socket&&n.socket.encrypted?"https:":"http:",a=(e=(i=n.headers.host)!==null&&i!==void 0?i:n.headers[":authority"])!==null&&e!==void 0?e:"localhost";return new URL(n.url,`${t}//${a}`)}catch(t){throw new Vn({code:"BAD_REQUEST",message:"Invalid URL",cause:t})}}function Nin(n){let e=new Headers;for(let i in n){let t=n[i];if(typeof i==="string"&&i.startsWith(":"))continue;if(Array.isArray(t))for(let a of t)e.append(i,a);else if(t!=null)e.append(i,t)}return e}function Fin(n,e,i){let t=new AbortController,a=()=>{e.off("close",a),n.off("aborted",a),t.abort()};e.once("close",a),n.once("aborted",a);let r=tS(n),o={headers:Nin(n.headers),method:n.method,signal:t.signal};if(n.method!=="GET"&&n.method!=="HEAD")o.body=_in(n,i),o.duplex="half";return new Request(r,o)}async function Cin(n,e){if(n.write(e)===!1)await new Promise((i,t)=>{let a=(u)=>{t(u),o()},r=()=>{i(),o()},o=()=>{n.off("error",a),n.off("drain",r)};n.once("error",a),n.once("drain",r)})}async function Oin(n){let{res:e}=n;try{let i=new WritableStream({async write(t){var a;await Cin(e,t),(a=e.flush)===null||a===void 0||a.call(e)}});await n.body.pipeTo(i,{signal:n.signal})}catch(i){if(JT(i))return;throw i}}async function Lin(n){let{response:e,rawResponse:i}=n;if(i.statusCode===200)i.statusCode=e.status;for(let[t,a]of e.headers)i.setHeader(t,a);try{if(e.body)await Oin({res:i,signal:n.request.signal,body:e.body})}catch(t){if(!i.headersSent)i.statusCode=500;throw t}finally{i.end()}}var ab=Re(Ka(),1);function aS(n){return(e)=>{var i;let{res:t,req:a}=n,r=ra(e),o=pl({config:n.router._def._config,error:r,type:"unknown",path:void 0,input:void 0,ctx:void 0});(i=n.onError)===null||i===void 0||i.call(n,{req:a,error:r,type:"unknown",path:void 0,input:void 0,ctx:void 0});let u=Zp(n.router._def._config,{error:o});t.statusCode=o.data.httpStatus,t.end(JSON.stringify(u))}}async function _M(n){return new Promise((e)=>{var i;let t=(i=n.middleware)!==null&&i!==void 0?i:(a,r,o)=>o();return n.res.once("finish",()=>{e()}),t(n.req,n.res,(a)=>{cl(async()=>{var r;let o=Fin(n.req,n.res,{maxBodySize:(r=n.maxBodySize)!==null&&r!==void 0?r:null}),u=async(l)=>{var c;return await((c=n.createContext)===null||c===void 0?void 0:c.call(n,(0,ab.default)((0,ab.default)({},n),l)))},s=await AM((0,ab.default)((0,ab.default)({},n),{},{req:o,error:a?ra(a):null,createContext:u,onError(l){var c;n===null||n===void 0||(c=n.onError)===null||c===void 0||c.call(n,(0,ab.default)((0,ab.default)({},l),{},{req:n.req}))}}));await Lin({request:o,response:s,rawResponse:n.res})}).catch(aS(n))})})}var rS=Re(Ka(),1);function Iin(n){var e;let t=((e=n.basePath)!==null&&e!==void 0?e:"/").length;return(a,r)=>{let o="";cl(async()=>{o=tS(a).pathname.slice(t),await _M((0,rS.default)((0,rS.default)({},n),{},{req:a,res:r,path:o}))}).catch(aS((0,rS.default)({req:a,res:r,path:o},n)))}}function NM(n){return Iin(n)}var oa=(n)=>JSON.parse(n),je=(n)=>JSON.stringify(n),UNn=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];var dl=class n extends Set{mode="record";subject=new We;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(e,i=0){super(e);if(e instanceof n)this.parent=e,this.cacheUpdateNumber=e.cacheUpdateNumber;if(i)this.cacheLimit=i,this.cache=new Array(i),this.subscribe("auto cache",(t)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=t})}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(e){let i=new n(e.members,e.cacheLimit);return i.cache=e.cache,i.cacheIdx=e.cacheIdx,i.cacheUpdateNumber=e.cacheUpdateNumber,i}add(e){let i=super.add(e);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${je(e)}`);return i}clear(){let e=this.mode==="record"?[...this]:null;if(super.clear(),e)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(e)}`)}delete(e){let i=super.delete(e);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${je(e)}`);return i}parent=null;child=null;transactionUpdates=null;transaction(e){this.mode="transaction",this.transactionUpdates=[],this.child=new n(this);let i=this.child._subscribe("transaction",(t)=>{this.transactionUpdates?.push(t)});try{if(e(this.child)){for(let a of this.transactionUpdates)this.doStep(a);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(t){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",t),t}finally{i(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(e,i){return this.subject.subscribe(e,i)}subscribe(e,i){return this.subject.subscribe(e,(t)=>{i(`${this.cacheUpdateNumber}=${t}`)})}emit(e){this.subject.next(e)}doStep(e){let i=e.indexOf(":"),t=e.substring(0,i),a=e.substring(i+1);switch(t){case"add":this.add(JSON.parse(a));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(a));break;case"tx":for(let r of a.split(";"))this.doStep(r)}}getUpdateNumber(e){let i=e.indexOf("=");return Number(e.substring(0,i))}do(e){let i=e.indexOf("="),t=Number(e.substring(0,i)),a=t-this.cacheUpdateNumber;if(a>0){if(a===1){this.mode="playback";let o=e.substring(i+1);return this.doStep(o),this.mode="record",this.cacheUpdateNumber=t,null}return this.cacheUpdateNumber+1}if(Math.abs(a)<this.cacheLimit){let o=this.cacheIdx+a;if(this.cache[o]===e)return null;this.mode="playback";let s=!1;while(!s){this.cacheIdx%=this.cacheLimit;let c=this.cache[this.cacheIdx];if(this.cacheIdx--,!c)return"OUT_OF_RANGE";this.undo(c),s=this.cacheIdx===o-1}let l=e.substring(i+1);return this.doStep(l),this.mode="record",this.cacheUpdateNumber=t,null}return"OUT_OF_RANGE"}undoStep(e){let i=e.indexOf(":"),t=e.substring(0,i),a=e.substring(i+1);switch(t){case"add":this.delete(JSON.parse(a));break;case"del":this.add(JSON.parse(a));break;case"clear":{let r=JSON.parse(a);for(let o of r)this.add(o);break}case"tx":{let r=a.split(";");for(let o=r.length-1;o>=0;o--)this.undoStep(r[o])}}}undo(e){let i=e.indexOf("=");if(Number(e.substring(0,i))===this.cacheUpdateNumber){this.mode="playback";let a=e.substring(i+1);return this.undoStep(a),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function MM(n=Math.random){return n().toString(36).slice(2)}function Ae(n){while(n.child!==null)n=n.child;return n}var yin=class n{_buffer;_index=0;constructor(e){let i;if(typeof e==="number")i=e;else i=e.length;this._buffer=Array.from({length:i})}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(){let e=new n([...this._buffer]);return e._index=this._index,e}};function wc(n){let e={key:n.key,type:n.type};if("family"in n)e.family=n.family;return e}var Min=Symbol("counterfeit"),Uin={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"};function FM(n,e,i){let t=je(e),a=`${n.key}(${t})`,r=Uin[n.type],o={key:a,type:r,family:{key:n.key,subKey:t}};if(i)o.counterfeit=!0;return o}var kt=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(n,e)=>`${n}:${e}`;warn;getRelatedKeys(n){return this.relations.get(n)}addRelation(n,e){let i=this.relations.get(n),t=this.relations.get(e);if(i)i.add(e);else i=new Set([e]),this.relations.set(n,i);if(t)t.add(n);else t=new Set([n]),this.relations.set(e,t)}deleteRelation(n,e){let i=this.relations.get(n);if(i){if(i.delete(e),i.size===0)this.relations.delete(n);let t=this.relations.get(e);if(t){if(t.delete(n),t.size===0)this.relations.delete(e)}}}replaceRelationsUnsafely(n,e){this.relations.set(n,new Set(e));for(let i of e){let t=new Set().add(n);this.relations.set(i,t)}}replaceRelationsSafely(n,e){let i=this.relations.get(n),t=this.isAType?.(n)?n:void 0,a=t===void 0?n:void 0;if(i)for(let r of i){t??=r,a??=r;let o=this.relations.get(r);if(o){if(o.size===1)this.relations.delete(r);else o.delete(n);this.contents.delete(this.makeContentKey(t,a))}}this.relations.set(n,new Set(e));for(let r of e){let o=this.relations.get(r);if(o)o.add(n);else o=new Set().add(n),this.relations.set(r,o)}}getContentInternal(n){return this.contents.get(n)}setContent(n,e){this.contents.set(n,e)}deleteContent(n){this.contents.delete(n)}constructor(n,e){if(this.a=n.between[0],this.b=n.between[1],this.cardinality=n.cardinality,!e?.externalStore)this.relations=new Map(n.relations?.map(([i,t])=>[i,new Set(t)])),this.contents=new Map(n.contents);if(this.isAType=e?.isAType??null,this.isBType=e?.isBType??null,this.isContent=e?.isContent??null,e?.makeContentKey)this.makeContentKey=e.makeContentKey;if(e?.externalStore){let i=e.externalStore;if(this.has=(t,a)=>i.has(t,a),this.addRelation=(t,a)=>{i.addRelation(t,a)},this.deleteRelation=(t,a)=>{i.deleteRelation(t,a)},this.replaceRelationsSafely=(t,a)=>{i.replaceRelationsSafely(t,a)},this.replaceRelationsUnsafely=(t,a)=>{i.replaceRelationsUnsafely(t,a)},this.getRelatedKeys=(t)=>i.getRelatedKeys(t),i.getContent)this.getContentInternal=(t)=>{return i.getContent(t)},this.setContent=(t,a)=>{i.setContent(t,a)},this.deleteContent=(t)=>{i.deleteContent(t)};for(let[t,a]of n.relations??[]){let r=this.isAType?.(t)?t:void 0,o=r===void 0?t:void 0;for(let u of a)r??=u,o??=u,this.addRelation(r,o)}for(let[t,a]of n.contents??[])this.setContent(t,a)}if(e?.warn)this.warn=e.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([n,e])=>[n,[...e]]),contents:[...this.contents.entries()]}}set(...n){let e,i,t;switch(n.length){case 1:{let a=n[0];e=a[this.a],i=a[this.b],t=void 0;break}case 2:{let a=n[0];if(typeof a==="string")[e,i]=n;else e=a[this.a],i=a[this.b],t=n[1];break}default:e=n[0],i=n[1],t=n[2];break}switch(this.cardinality){case"1:1":{let a=this.getRelatedKey(e);if(a&&a!==i)this.delete(e,a)}case"1:n":{let a=this.getRelatedKey(i);if(a&&a!==e)this.delete(a,i)}break;case"n:n":}if(t){let a=this.makeContentKey(e,i);this.setContent(a,t)}return this.addRelation(e,i),this}delete(n,e){e=typeof e==="string"?e:n[this.b];let i=typeof n==="string"?n:n[this.a];if(i===void 0&&typeof e==="string"){let t=this.getRelatedKeys(e);if(t)for(let a of t)this.delete(a,e)}if(typeof i==="string"&&e===void 0){let t=this.getRelatedKeys(i);if(t)for(let a of t)this.delete(i,a)}if(typeof i==="string"&&typeof e==="string"){this.deleteRelation(i,e);let t=this.makeContentKey(i,e);this.deleteContent(t)}return this}getRelatedKey(n){let e=this.getRelatedKeys(n);if(e){if(e.size>1)this.warn?.(`${e.size} related keys were found for key "${n}": (${[...e].map((t)=>`"${t}"`).join(", ")}). Only one related key was expected.`);let i;for(let t of e){i=t;break}return i}}replaceRelations(n,e,i){let t=!Array.isArray(e),a=t?Object.keys(e):e;if(i?.reckless)this.replaceRelationsUnsafely(n,a);else this.replaceRelationsSafely(n,a);if(t)for(let r of a){let o=this.makeContentKey(n,r),u=e[r];this.setContent(o,u)}return this}getContent(n,e){let i=this.makeContentKey(n,e);return this.getContentInternal(i)}getRelationEntries(n){let e=n[this.a],i=n[this.b];if(e!==void 0&&i===void 0){let t=this.getRelatedKeys(e);if(t)return[...t].map((a)=>{return[a,this.getContent(e,a)]})}if(e===void 0&&i!==void 0){let t=this.getRelatedKeys(i);if(t)return[...t].map((a)=>{return[a,this.getContent(a,i)]})}return[]}has(n,e){if(e)return this.getRelatedKeys(n)?.has(e)??!1;return this.relations.has(n)}},We=class{Subscriber;subscribers=new Map;subscribe(n,e){return this.subscribers.set(n,e),()=>{this.unsubscribe(n)}}unsubscribe(n){this.subscribers.delete(n)}next(n){let e=this.subscribers.values();for(let i of e)i(n)}},Gin=class extends We{state;constructor(n){super();this.state=n}next(n){this.state=n,super.next(n)}},zin=(n,e)=>{let i=Ae(n);if(i.operation.open)return i.operation.prev.get(e.key);return i.valueMap.get(e.key)};function UM(n,e,i,t){let a=n.disposalTraces.buffer.find((r)=>r?.key===je(t));switch(n.logger.error("\u274C",e.type,e.key,"gets a fallback value because key",t,"is not allocated",a?`This key was previously disposed:
|
|
291
|
+
`.trim();async function xM(n,e,i){try{let t=e.middlewares[n];return await t((0,lt.default)((0,lt.default)({},i),{},{meta:e.meta,input:i.input,next(r){var o;let u=r;return xM(n+1,e,(0,lt.default)((0,lt.default)({},i),{},{ctx:(u===null||u===void 0?void 0:u.ctx)?(0,lt.default)((0,lt.default)({},i.ctx),u.ctx):i.ctx,input:u&&"input"in u?u.input:i.input,getRawInput:(o=u===null||u===void 0?void 0:u.getRawInput)!==null&&o!==void 0?o:i.getRawInput}))}}))}catch(t){return{ok:!1,error:ra(t),marker:RM}}}function Sin(n){async function e(i){if(!i||!("getRawInput"in i))throw new Error(Tin);let t=await xM(0,n,i);if(!t)throw new Vn({code:"INTERNAL_SERVER_ERROR",message:"No result from middlewares - did you forget to `return next()`?"});if(!t.ok)throw t.error;return t.data}return e._def=n,e.procedure=!0,e.meta=n.meta,e}var eb,ib,tb,wM=typeof window==="undefined"||"Deno"in window||((eb=globalThis.process)===null||eb===void 0||(eb=eb.env)===null||eb===void 0?void 0:eb.NODE_ENV)==="test"||!!((ib=globalThis.process)===null||ib===void 0||(ib=ib.env)===null||ib===void 0?void 0:ib.JEST_WORKER_ID)||!!((tb=globalThis.process)===null||tb===void 0||(tb=tb.env)===null||tb===void 0?void 0:tb.VITEST_WORKER_ID),vM=Re(Ka(),1),xin=class n{context(){return new n}meta(){return new n}create(e){var i,t,a,r,o,u;let s=(0,vM.default)((0,vM.default)({},e),{},{transformer:X9((i=e===null||e===void 0?void 0:e.transformer)!==null&&i!==void 0?i:qf),isDev:(t=e===null||e===void 0?void 0:e.isDev)!==null&&t!==void 0?t:((a=globalThis.process)===null||a===void 0?void 0:a.env.NODE_ENV)!=="production",allowOutsideOfServer:(r=e===null||e===void 0?void 0:e.allowOutsideOfServer)!==null&&r!==void 0?r:!1,errorFormatter:(o=e===null||e===void 0?void 0:e.errorFormatter)!==null&&o!==void 0?o:Jf,isServer:(u=e===null||e===void 0?void 0:e.isServer)!==null&&u!==void 0?u:wM,$types:null});{var l;if(!((l=e===null||e===void 0?void 0:e.isServer)!==null&&l!==void 0?l:wM)&&(e===null||e===void 0?void 0:e.allowOutsideOfServer)!==!0)throw new Error("You're trying to use @trpc/server in a non-server environment. This is not supported by default.")}return{_config:s,procedure:SM({meta:e===null||e===void 0?void 0:e.defaultMeta}),middleware:min(),router:HT(s),mergeRouters:Z9,createCallerFactory:kT()}}},iS=new xin;function _in(n,e){if("body"in n){if(n.body===void 0)return;if(typeof n.body==="string")return n.body;return JSON.stringify(n.body)}let i=0,t=!1;return new ReadableStream({start(a){let r=(u)=>{if(i+=u.length,!e.maxBodySize||i<=e.maxBodySize){a.enqueue(new Uint8Array(u.buffer,u.byteOffset,u.byteLength));return}a.error(new Vn({code:"PAYLOAD_TOO_LARGE"})),t=!0,n.off("data",r),n.off("end",o)},o=()=>{if(t)return;t=!0,n.off("data",r),n.off("end",o),a.close()};n.on("data",r),n.on("end",o)},cancel(){n.destroy()}})}function tS(n){try{var e,i;let t=n.headers[":scheme"]&&n.headers[":scheme"]==="https"||n.socket&&"encrypted"in n.socket&&n.socket.encrypted?"https:":"http:",a=(e=(i=n.headers.host)!==null&&i!==void 0?i:n.headers[":authority"])!==null&&e!==void 0?e:"localhost";return new URL(n.url,`${t}//${a}`)}catch(t){throw new Vn({code:"BAD_REQUEST",message:"Invalid URL",cause:t})}}function Nin(n){let e=new Headers;for(let i in n){let t=n[i];if(typeof i==="string"&&i.startsWith(":"))continue;if(Array.isArray(t))for(let a of t)e.append(i,a);else if(t!=null)e.append(i,t)}return e}function Fin(n,e,i){let t=new AbortController,a=()=>{e.off("close",a),n.off("aborted",a),t.abort()};e.once("close",a),n.once("aborted",a);let r=tS(n),o={headers:Nin(n.headers),method:n.method,signal:t.signal};if(n.method!=="GET"&&n.method!=="HEAD")o.body=_in(n,i),o.duplex="half";return new Request(r,o)}async function Cin(n,e){if(n.write(e)===!1)await new Promise((i,t)=>{let a=(u)=>{t(u),o()},r=()=>{i(),o()},o=()=>{n.off("error",a),n.off("drain",r)};n.once("error",a),n.once("drain",r)})}async function Oin(n){let{res:e}=n;try{let i=new WritableStream({async write(t){var a;await Cin(e,t),(a=e.flush)===null||a===void 0||a.call(e)}});await n.body.pipeTo(i,{signal:n.signal})}catch(i){if(JT(i))return;throw i}}async function Lin(n){let{response:e,rawResponse:i}=n;if(i.statusCode===200)i.statusCode=e.status;for(let[t,a]of e.headers)i.setHeader(t,a);try{if(e.body)await Oin({res:i,signal:n.request.signal,body:e.body})}catch(t){if(!i.headersSent)i.statusCode=500;throw t}finally{i.end()}}var ab=Re(Ka(),1);function aS(n){return(e)=>{var i;let{res:t,req:a}=n,r=ra(e),o=pl({config:n.router._def._config,error:r,type:"unknown",path:void 0,input:void 0,ctx:void 0});(i=n.onError)===null||i===void 0||i.call(n,{req:a,error:r,type:"unknown",path:void 0,input:void 0,ctx:void 0});let u=Zp(n.router._def._config,{error:o});t.statusCode=o.data.httpStatus,t.end(JSON.stringify(u))}}async function _M(n){return new Promise((e)=>{var i;let t=(i=n.middleware)!==null&&i!==void 0?i:(a,r,o)=>o();return n.res.once("finish",()=>{e()}),t(n.req,n.res,(a)=>{cl(async()=>{var r;let o=Fin(n.req,n.res,{maxBodySize:(r=n.maxBodySize)!==null&&r!==void 0?r:null}),u=async(l)=>{var c;return await((c=n.createContext)===null||c===void 0?void 0:c.call(n,(0,ab.default)((0,ab.default)({},n),l)))},s=await AM((0,ab.default)((0,ab.default)({},n),{},{req:o,error:a?ra(a):null,createContext:u,onError(l){var c;n===null||n===void 0||(c=n.onError)===null||c===void 0||c.call(n,(0,ab.default)((0,ab.default)({},l),{},{req:n.req}))}}));await Lin({request:o,response:s,rawResponse:n.res})}).catch(aS(n))})})}var rS=Re(Ka(),1);function Iin(n){var e;let t=((e=n.basePath)!==null&&e!==void 0?e:"/").length;return(a,r)=>{let o="";cl(async()=>{o=tS(a).pathname.slice(t),await _M((0,rS.default)((0,rS.default)({},n),{},{req:a,res:r,path:o}))}).catch(aS((0,rS.default)({req:a,res:r,path:o},n)))}}function NM(n){return Iin(n)}function oa(n){return JSON.parse(n)}var je=(n)=>JSON.stringify(n),UNn=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];var dl=class n extends Set{mode="record";subject=new We;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(e,i=0){super(e);if(e instanceof n)this.parent=e,this.cacheUpdateNumber=e.cacheUpdateNumber;if(i)this.cacheLimit=i,this.cache=new Array(i),this.subscribe("auto cache",(t)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=t})}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(e){let i=new n(e.members,e.cacheLimit);return i.cache=e.cache,i.cacheIdx=e.cacheIdx,i.cacheUpdateNumber=e.cacheUpdateNumber,i}add(e){let i=super.add(e);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${je(e)}`);return i}clear(){let e=this.mode==="record"?[...this]:null;if(super.clear(),e)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(e)}`)}delete(e){let i=super.delete(e);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${je(e)}`);return i}parent=null;child=null;transactionUpdates=null;transaction(e){this.mode="transaction",this.transactionUpdates=[],this.child=new n(this);let i=this.child._subscribe("transaction",(t)=>{this.transactionUpdates?.push(t)});try{if(e(this.child)){for(let a of this.transactionUpdates)this.doStep(a);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(t){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",t),t}finally{i(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(e,i){return this.subject.subscribe(e,i)}subscribe(e,i){return this.subject.subscribe(e,(t)=>{i(`${this.cacheUpdateNumber}=${t}`)})}emit(e){this.subject.next(e)}doStep(e){let i=e.indexOf(":"),t=e.substring(0,i),a=e.substring(i+1);switch(t){case"add":this.add(JSON.parse(a));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(a));break;case"tx":for(let r of a.split(";"))this.doStep(r)}}getUpdateNumber(e){let i=e.indexOf("=");return Number(e.substring(0,i))}do(e){let i=e.indexOf("="),t=Number(e.substring(0,i)),a=t-this.cacheUpdateNumber;if(a>0){if(a===1){this.mode="playback";let o=e.substring(i+1);return this.doStep(o),this.mode="record",this.cacheUpdateNumber=t,null}return this.cacheUpdateNumber+1}if(Math.abs(a)<this.cacheLimit){let o=this.cacheIdx+a;if(this.cache[o]===e)return null;this.mode="playback";let s=!1;while(!s){this.cacheIdx%=this.cacheLimit;let c=this.cache[this.cacheIdx];if(this.cacheIdx--,!c)return"OUT_OF_RANGE";this.undo(c),s=this.cacheIdx===o-1}let l=e.substring(i+1);return this.doStep(l),this.mode="record",this.cacheUpdateNumber=t,null}return"OUT_OF_RANGE"}undoStep(e){let i=e.indexOf(":"),t=e.substring(0,i),a=e.substring(i+1);switch(t){case"add":this.delete(JSON.parse(a));break;case"del":this.add(JSON.parse(a));break;case"clear":{let r=JSON.parse(a);for(let o of r)this.add(o);break}case"tx":{let r=a.split(";");for(let o=r.length-1;o>=0;o--)this.undoStep(r[o])}}}undo(e){let i=e.indexOf("=");if(Number(e.substring(0,i))===this.cacheUpdateNumber){this.mode="playback";let a=e.substring(i+1);return this.undoStep(a),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function MM(n=Math.random){return n().toString(36).slice(2)}function Ae(n){while(n.child!==null)n=n.child;return n}var yin=class n{_buffer;_index=0;constructor(e){let i;if(typeof e==="number")i=e;else i=e.length;this._buffer=Array.from({length:i})}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(){let e=new n([...this._buffer]);return e._index=this._index,e}};function wc(n){let e={key:n.key,type:n.type};if("family"in n)e.family=n.family;return e}var Min=Symbol("counterfeit"),Uin={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"};function FM(n,e,i){let t=je(e),a=`${n.key}(${t})`,r=Uin[n.type],o={key:a,type:r,family:{key:n.key,subKey:t}};if(i)o.counterfeit=!0;return o}var kt=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(n,e)=>`${n}:${e}`;warn;getRelatedKeys(n){return this.relations.get(n)}addRelation(n,e){let i=this.relations.get(n),t=this.relations.get(e);if(i)i.add(e);else i=new Set([e]),this.relations.set(n,i);if(t)t.add(n);else t=new Set([n]),this.relations.set(e,t)}deleteRelation(n,e){let i=this.relations.get(n);if(i){if(i.delete(e),i.size===0)this.relations.delete(n);let t=this.relations.get(e);if(t){if(t.delete(n),t.size===0)this.relations.delete(e)}}}replaceRelationsUnsafely(n,e){this.relations.set(n,new Set(e));for(let i of e){let t=new Set().add(n);this.relations.set(i,t)}}replaceRelationsSafely(n,e){let i=this.relations.get(n),t=this.isAType?.(n)?n:void 0,a=t===void 0?n:void 0;if(i)for(let r of i){t??=r,a??=r;let o=this.relations.get(r);if(o){if(o.size===1)this.relations.delete(r);else o.delete(n);this.contents.delete(this.makeContentKey(t,a))}}this.relations.set(n,new Set(e));for(let r of e){let o=this.relations.get(r);if(o)o.add(n);else o=new Set().add(n),this.relations.set(r,o)}}getContentInternal(n){return this.contents.get(n)}setContent(n,e){this.contents.set(n,e)}deleteContent(n){this.contents.delete(n)}constructor(n,e){if(this.a=n.between[0],this.b=n.between[1],this.cardinality=n.cardinality,!e?.externalStore)this.relations=new Map(n.relations?.map(([i,t])=>[i,new Set(t)])),this.contents=new Map(n.contents);if(this.isAType=e?.isAType??null,this.isBType=e?.isBType??null,this.isContent=e?.isContent??null,e?.makeContentKey)this.makeContentKey=e.makeContentKey;if(e?.externalStore){let i=e.externalStore;if(this.has=(t,a)=>i.has(t,a),this.addRelation=(t,a)=>{i.addRelation(t,a)},this.deleteRelation=(t,a)=>{i.deleteRelation(t,a)},this.replaceRelationsSafely=(t,a)=>{i.replaceRelationsSafely(t,a)},this.replaceRelationsUnsafely=(t,a)=>{i.replaceRelationsUnsafely(t,a)},this.getRelatedKeys=(t)=>i.getRelatedKeys(t),i.getContent)this.getContentInternal=(t)=>{return i.getContent(t)},this.setContent=(t,a)=>{i.setContent(t,a)},this.deleteContent=(t)=>{i.deleteContent(t)};for(let[t,a]of n.relations??[]){let r=this.isAType?.(t)?t:void 0,o=r===void 0?t:void 0;for(let u of a)r??=u,o??=u,this.addRelation(r,o)}for(let[t,a]of n.contents??[])this.setContent(t,a)}if(e?.warn)this.warn=e.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([n,e])=>[n,[...e]]),contents:[...this.contents.entries()]}}set(...n){let e,i,t;switch(n.length){case 1:{let a=n[0];e=a[this.a],i=a[this.b],t=void 0;break}case 2:{let a=n[0];if(typeof a==="string")[e,i]=n;else e=a[this.a],i=a[this.b],t=n[1];break}default:e=n[0],i=n[1],t=n[2];break}switch(this.cardinality){case"1:1":{let a=this.getRelatedKey(e);if(a&&a!==i)this.delete(e,a)}case"1:n":{let a=this.getRelatedKey(i);if(a&&a!==e)this.delete(a,i)}break;case"n:n":}if(t){let a=this.makeContentKey(e,i);this.setContent(a,t)}return this.addRelation(e,i),this}delete(n,e){e=typeof e==="string"?e:n[this.b];let i=typeof n==="string"?n:n[this.a];if(i===void 0&&typeof e==="string"){let t=this.getRelatedKeys(e);if(t)for(let a of t)this.delete(a,e)}if(typeof i==="string"&&e===void 0){let t=this.getRelatedKeys(i);if(t)for(let a of t)this.delete(i,a)}if(typeof i==="string"&&typeof e==="string"){this.deleteRelation(i,e);let t=this.makeContentKey(i,e);this.deleteContent(t)}return this}getRelatedKey(n){let e=this.getRelatedKeys(n);if(e){if(e.size>1)this.warn?.(`${e.size} related keys were found for key "${n}": (${[...e].map((t)=>`"${t}"`).join(", ")}). Only one related key was expected.`);let i;for(let t of e){i=t;break}return i}}replaceRelations(n,e,i){let t=!Array.isArray(e),a=t?Object.keys(e):e;if(i?.reckless)this.replaceRelationsUnsafely(n,a);else this.replaceRelationsSafely(n,a);if(t)for(let r of a){let o=this.makeContentKey(n,r),u=e[r];this.setContent(o,u)}return this}getContent(n,e){let i=this.makeContentKey(n,e);return this.getContentInternal(i)}getRelationEntries(n){let e=n[this.a],i=n[this.b];if(e!==void 0&&i===void 0){let t=this.getRelatedKeys(e);if(t)return[...t].map((a)=>{return[a,this.getContent(e,a)]})}if(e===void 0&&i!==void 0){let t=this.getRelatedKeys(i);if(t)return[...t].map((a)=>{return[a,this.getContent(a,i)]})}return[]}has(n,e){if(e)return this.getRelatedKeys(n)?.has(e)??!1;return this.relations.has(n)}},We=class{Subscriber;subscribers=new Map;subscribe(n,e){return this.subscribers.set(n,e),()=>{this.unsubscribe(n)}}unsubscribe(n){this.subscribers.delete(n)}next(n){let e=this.subscribers.values();for(let i of e)i(n)}},Gin=class extends We{state;constructor(n){super();this.state=n}next(n){this.state=n,super.next(n)}},zin=(n,e)=>{let i=Ae(n);if(i.operation.open)return i.operation.prev.get(e.key);return i.valueMap.get(e.key)};function UM(n,e,i,t){let a=n.disposalTraces.buffer.find((r)=>r?.key===je(t));switch(n.logger.error("\u274C",e.type,e.key,"gets a fallback value because key",t,"is not allocated",a?`This key was previously disposed:
|
|
292
292
|
${a.trace}`:"(no previous disposal trace found)"),i.type){case"mutable_atom_family":{if(n.defaults.has(i.key))return n.defaults.get(i.key);let r=new i.class;return n.defaults.set(i.key,r),r}case"atom_family":{if(n.defaults.has(i.key))return n.defaults.get(i.key);let r=i.default,o=r(t);return n.defaults.set(i.key,o),o}case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if(n.defaults.has(i.key))return n.defaults.get(i.key);let r=i.default(t);return n.defaults.set(i.key,r),r}}}var uS=class extends Promise{fate;resolve;reject;done=!1;constructor(n){let e,i;super((t,a)=>{e=t,i=a});this.resolve=e,this.reject=i,this.use(n instanceof Promise?n:new Promise(n))}pass(n,e){if(n===this.fate)this.resolve(e),this.done=!0}fail(n,e){if(n===this.fate)this.reject(e),this.done=!0}use(n){if(this===n)return;if(n instanceof Promise){let e=n;this.fate=e,e.then((i)=>{this.pass(e,i)},(i)=>{this.fail(e,i)})}else this.resolve(n),this.fate=void 0}};function jp(n){return"epoch"in n.transactionMeta}function ja(n){return"phase"in n.transactionMeta}function GM(n,e){if(n.operation.open){let i=performance.now();return n.logger.info("\uD83D\uDEAB",e.type,e.key,`deferring setState at T-${i} until setState for "${n.operation.token.key}" is done`),i}return n.operation={open:!0,done:new Set,prev:new Map,timestamp:Date.now(),token:e},n.logger.info("\u2B55",e.type,e.key,`operation start in store "${n.config.name}"${ja(n)?` ${n.transactionMeta.phase} "${n.transactionMeta.update.token.key}"`:""}`),n}function zM(n){if(n.operation.open)n.logger.info("\uD83D\uDD34",n.operation.token.type,n.operation.token.key,`operation done in store "${n.config.name}"`);n.operation={open:!1},n.on.operationClose.next(n.operation)}var $M=(n,e)=>{if(!n.operation.open)return n.logger.error("\uD83D\uDC1E","unknown",e,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0;return n.operation.done.has(e)},XD=(n,e)=>{if(!n.operation.open){n.logger.error("\uD83D\uDC1E","unknown",e,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}n.operation.done.add(e)};function pS(n,e){let i=Ae(n),{key:t,type:a}=e,r=i.selectorAtoms.getRelatedKeys(t);if(i.logger.info("\uD83E\uDDF9",a,t,r?`evicting ${r.size} states downstream:`:"no downstream states",r??"to evict"),r){if(i.operation.open)i.logger.info("\uD83E\uDDF9",a,t,`[ ${[...i.operation.done].join(", ")} ] already done`);for(let o of r){if($M(i,o))continue;kM(i,o),XD(i,o)}}}function HM(n,e){let i=Ae(n),t=i.selectorGraph.getRelationEntries({upstreamSelectorKey:e}).filter(([a,{source:r}])=>r===e);for(let[a]of t){if($M(i,a))continue;kM(i,a),XD(i,a),HM(n,a)}}function fl(n,e,i){let{key:t,subject:a,type:r}=e,o=n.valueMap.get(t);if(o instanceof uS&&!o.done){let u=o;if(i instanceof Promise)return u.use(i),u;return n.valueMap.set(t,i),i}if(i instanceof Promise){let u=new uS(i);return n.valueMap.set(t,u),u.then(function s(l){if(n.valueMap.get(t)===u){switch(GM(n,e),fl(n,e,l),r){case"atom":case"mutable_atom":pS(n,e);break;case"readonly_pure_selector":case"writable_pure_selector":HM(n,t);break}zM(n),a.next({newValue:l,oldValue:u})}}).catch((s)=>{n.logger.error("\uD83D\uDCA5","state",t,"rejected:",s)}),u}return n.valueMap.set(t,i),i}function $in(n,e,i){n.logger.info("\uD83D\uDCD6",e.type,e.key,"reading cached value");let t=n.valueMap.get(e.key);if(i==="mut"&&e.type==="mutable_atom"&&ja(n)){let r=e,{parent:o}=n;if(n.valueMap.hasOwn(r.key))return t;let u=o.valueMap.get(r.key);n.logger.info("\uD83D\uDCC3","atom",r.key,"copying");let s=u.toJSON(),l=r.class.fromJSON(s);n.valueMap.set(r.key,l),new vS(r,o),t=l}return t}function kM(n,e){let i=n.valueMap.get(e);if(i instanceof uS){let t=n.writableSelectors.get(e)??n.readonlySelectors.get(e);if(t)t.getFrom(n);return}if(n.operation.open)n.operation.prev.set(e,i);n.valueMap.delete(e),n.logger.info("\uD83D\uDDD1","state",e,"evicted")}function ob(n,e,i){if(n.valueMap.has(e.key))return $in(n,e,i);let{key:t}=e;switch(e.type){case"readonly_held_selector":case"readonly_pure_selector":case"writable_held_selector":case"writable_pure_selector":return n.logger.info("\uD83E\uDDEE",e.type,t,"computing value"),e.getFrom(n);case"atom":{let a;if(e.default instanceof Function)a=e.default();else a=e.default;let r=fl(n,e,a);return n.logger.info("\uD83D\uDC81","atom",e.key,"could not find cached value; using default",a),r}case"mutable_atom":{let a=new e.class,r=fl(n,e,a);return n.logger.info("\uD83D\uDC81","mutable_atom",e.key,"could not find cached value; using default",a),r}}}function dS(n,e){return Hi(n,{key:e.family.key,type:`${e.type}_family`})}var Hin=(n)=>{let e=Ae(n);if(!ja(e)){n.logger.warn("\uD83D\uDC1E","transaction","???","abortTransaction called outside of a transaction. This is probably a bug in AtomIO.");return}n.logger.info("\uD83E\uDE82","transaction",e.transactionMeta.update.token.key,"Aborting transaction"),e.parent.child=null},PM=class extends Error{constructor(n,e){super(`${bl[n.type]} ${je(n.key)} not found in store "${e.config.name}".`)}};function fS(n,e,i){return(...t)=>{let a=Hi(n,e);if(a)return a.run(t,i);throw new PM(e,n)}}var sS=(n)=>(e)=>n instanceof Function?n(e):n;function BM(n,e,[i,t],a){let{key:r,subject:o,type:u}=e,s={oldValue:oS(i)?i.READONLY_VIEW:i,newValue:oS(t)?t.READONLY_VIEW:t};if(jp(n)){switch(u){case"mutable_atom":n.logger.info("\uD83D\uDCE2",u,r,"is now (",t,") subscribers:",o.subscribers);break;case"atom":case"writable_pure_selector":case"writable_held_selector":n.logger.info("\uD83D\uDCE2",u,r,"went (",i,"->",t,") subscribers:",o.subscribers)}o.next(s)}if(ja(n)&&(u==="mutable_atom"||u==="atom")){if(n.on.transactionApplying.state===null){let l=wc(e);if(oS(t))return;let{timestamp:c}=n.operation,f={type:"atom_update",token:l,timestamp:c,update:s};n.transactionMeta.update.subEvents.push(f),n.logger.info("\uD83D\uDCC1","atom",r,"stowed (",i,"->",t,")");return}if(dtn(e,"tracker:signal")){let l=r.slice(1),c=n.atoms.get(l);if(ob(n,c,"mut").do(s.newValue)===null===!0)pS(n,c)}}}var lS=(n,e,i)=>{let t=ob(n,e,"mut"),a=sS(i)(t);return n.logger.info("\uD83D\uDCDD","atom",e.key,"set to",a),a=fl(n,e,a),XD(n,e.key),pS(n,e),[t,a]};function CM(n,e){switch(e.type){case"mutable_atom":return lS(n,e,new e.class);case"atom":{let i=e.default;if(i instanceof Function)i=i();return lS(n,e,i)}}}function kin(n,e){let i;switch(e.type){case"atom":case"mutable_atom":i=CM(n,e);break;case"writable_pure_selector":case"writable_held_selector":{let t=e.getFrom(n),a=YD(n,e.key);for(let o of a.values()){let u=CM(n,o);BM(n,e,u,!1)}let r=e.getFrom(n);i=[t,r]}break}return i}function Tt(n,...e){gS(n,cS,...e)}var WD=Symbol("RESET");function ZD(n,...e){let i,t,a;if(e.length===1)i=e[0],Tt(n,i,WD);else t=e[0],a=e[1],Tt(n,t,a,WD)}function Pin(n,e,i){let t,a,r,{type:o,key:u}=e;switch(e.type){case"writable_pure_selector":t=e.getFrom(n),a=sS(i)(t),fl(n,e,a);break;case"writable_held_selector":r=e.const,sS(i)(r),t=r,a=r}return n.logger.info("\uD83D\uDCDD",o,u,"setting to",a),XD(n,u),e.setSelf(a),[t,a]}var Bin=(n,e,i)=>{let t;switch(e.type){case"atom":case"mutable_atom":t=lS(n,e,i);break;case"writable_pure_selector":case"writable_held_selector":t=Pin(n,e,i);break}return t};function Win(n,e,i){let{token:t,update:{newValue:a,oldValue:r}}=e;Tt(i,t,n==="newValue"?a:r)}function Yin(n){let{stack:e}=n;if(e)return`
|
|
293
293
|
`+e.split(`
|
|
294
294
|
`)?.slice(1)?.join(`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var fz=Object.create;var{getPrototypeOf:Sz,defineProperty:F0,getOwnPropertyNames:Kz}=Object;var bz=Object.prototype.hasOwnProperty;var wQ=(z,Q,Z)=>{Z=z!=null?fz(Sz(z)):{};let W=Q||!z||!z.__esModule?F0(Z,"default",{value:z,enumerable:!0}):Z;for(let G of Kz(z))if(!bz.call(W,G))F0(W,G,{get:()=>z[G],enumerable:!0});return W};var xQ=(z,Q)=>()=>(Q||z((Q={exports:{}}).exports,Q),Q.exports);var RQ=(z,Q)=>{for(var Z in Q)F0(z,Z,{get:Q[Z],enumerable:!0,configurable:!0,set:(W)=>Q[Z]=()=>W})};var AQ=(z,Q)=>()=>(z&&(Q=z(z=0)),Q);var vQ=import.meta.require;var I=(z)=>JSON.parse(z),C=(z)=>JSON.stringify(z),TQ=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function o(z){return L0(f.STORE,z,void 0)}function Y0(z){return _0(f.STORE,z)}function KQ(...z){if(z.length===2)return m(f.STORE,...z);return m(f.STORE,...z)}function E0(z,Q){return Yz(f.STORE,z,Q)}function o0(z){return $z(z,f.STORE)}var k={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]"};var w0=(z)=>(Q,Z,W,G,...H)=>{console[z](`${Q} ${k[Z]} \`${W}\` ${G}`,...H)},gz={error:w0("error"),info:w0("info"),warn:w0("warn")},t0=class{logLevel;filter;logger;constructor(z,Q,Z=gz){this.logLevel=z,this.filter=Q,this.logger=Z}error=(...z)=>{if(this.logLevel!==null){let Q=this.filter?.(...z)??!0;if(Q===!0)this.logger.error(...z);else if(Q)this.logger.error(...Q)}};info=(...z)=>{if(this.logLevel==="info"){let Q=this.filter?.(...z)??!0;if(Q===!0)this.logger.info(...z);else if(Q)this.logger.info(...Q)}};warn=(...z)=>{if(this.logLevel!=="error"&&this.logLevel!==null){let Q=this.filter?.(...z)??!0;if(Q===!0)this.logger.warn(...z);else if(Q)this.logger.warn(...Q)}}};var dz=class{store;constructor(z=f.STORE){this.store=z,Qz("root",z)}allocate(z,Q,Z){return t(this.store,z,Q,Z)}fuse(z,Q,Z){return Zz(this.store,z,Q,Z)}deallocate(z){e(this.store,z)}claim(z,Q,Z){return $0(this.store,z,Q,Z)}},e0=class{store;realm;constructor(z=f.STORE){this.store=z,this.realm=new dz(z)}allocate(z,Q,Z){t(this.store,z,Q,Z)}deallocate(z){e(this.store,z)}claim(z,Q,Z){$0(this.store,z,Q,Z)}};function M0(z){return Gz(f.STORE,z)}function X0(z){return R0(f.STORE,z)}var y=class z extends Set{mode="record";subject=new U;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(Q,Z=0){super(Q);if(Q instanceof z)this.parent=Q,this.cacheUpdateNumber=Q.cacheUpdateNumber;if(Z)this.cacheLimit=Z,this.cache=new Array(Z),this.subscribe("auto cache",(W)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=W})}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(Q){let Z=new z(Q.members,Q.cacheLimit);return Z.cache=Q.cache,Z.cacheIdx=Q.cacheIdx,Z.cacheUpdateNumber=Q.cacheUpdateNumber,Z}add(Q){let Z=super.add(Q);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${C(Q)}`);return Z}clear(){let Q=this.mode==="record"?[...this]:null;if(super.clear(),Q)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(Q)}`)}delete(Q){let Z=super.delete(Q);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${C(Q)}`);return Z}parent=null;child=null;transactionUpdates=null;transaction(Q){this.mode="transaction",this.transactionUpdates=[],this.child=new z(this);let Z=this.child._subscribe("transaction",(W)=>{this.transactionUpdates?.push(W)});try{if(Q(this.child)){for(let G of this.transactionUpdates)this.doStep(G);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(W){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",W),W}finally{Z(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(Q,Z){return this.subject.subscribe(Q,Z)}subscribe(Q,Z){return this.subject.subscribe(Q,(W)=>{Z(`${this.cacheUpdateNumber}=${W}`)})}emit(Q){this.subject.next(Q)}doStep(Q){let Z=Q.indexOf(":"),W=Q.substring(0,Z),G=Q.substring(Z+1);switch(W){case"add":this.add(JSON.parse(G));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(G));break;case"tx":for(let H of G.split(";"))this.doStep(H)}}getUpdateNumber(Q){let Z=Q.indexOf("=");return Number(Q.substring(0,Z))}do(Q){let Z=Q.indexOf("="),W=Number(Q.substring(0,Z)),G=W-this.cacheUpdateNumber;if(G>0){if(G===1){this.mode="playback";let Y=Q.substring(Z+1);return this.doStep(Y),this.mode="record",this.cacheUpdateNumber=W,null}return this.cacheUpdateNumber+1}if(Math.abs(G)<this.cacheLimit){let Y=this.cacheIdx+G;if(this.cache[Y]===Q)return null;this.mode="playback";let $=!1;while(!$){this.cacheIdx%=this.cacheLimit;let N=this.cache[this.cacheIdx];if(this.cacheIdx--,!N)return"OUT_OF_RANGE";this.undo(N),$=this.cacheIdx===Y-1}let _=Q.substring(Z+1);return this.doStep(_),this.mode="record",this.cacheUpdateNumber=W,null}return"OUT_OF_RANGE"}undoStep(Q){let Z=Q.indexOf(":"),W=Q.substring(0,Z),G=Q.substring(Z+1);switch(W){case"add":this.delete(JSON.parse(G));break;case"del":this.add(JSON.parse(G));break;case"clear":{let H=JSON.parse(G);for(let Y of H)this.add(Y);break}case"tx":{let H=G.split(";");for(let Y=H.length-1;Y>=0;Y--)this.undoStep(H[Y])}}}undo(Q){let Z=Q.indexOf("=");if(Number(Q.substring(0,Z))===this.cacheUpdateNumber){this.mode="playback";let G=Q.substring(Z+1);return this.undoStep(G),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function zz(z=Math.random){return z().toString(36).slice(2)}function L(z){while(z.child!==null)z=z.child;return z}var cz=class z{_buffer;_index=0;constructor(Q){let Z;if(typeof Q==="number")Z=Q;else Z=Q.length;this._buffer=Array.from({length:Z})}get buffer(){return this._buffer}get index(){return this._index}add(Q){this._buffer[this._index]=Q,this._index=(this._index+1)%this._buffer.length}copy(){let Q=new z([...this._buffer]);return Q._index=this._index,Q}};function i(z){let Q={key:z.key,type:z.type};if("family"in z)Q.family=z.family;return Q}var pz=Symbol("counterfeit"),kz={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"};function _z(z,Q,Z){let W=C(Q),G=`${z.key}(${W})`,H=kz[z.type],Y={key:G,type:H,family:{key:z.key,subKey:W}};if(Z)Y.counterfeit=!0;return Y}var S=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(z,Q)=>`${z}:${Q}`;warn;getRelatedKeys(z){return this.relations.get(z)}addRelation(z,Q){let Z=this.relations.get(z),W=this.relations.get(Q);if(Z)Z.add(Q);else Z=new Set([Q]),this.relations.set(z,Z);if(W)W.add(z);else W=new Set([z]),this.relations.set(Q,W)}deleteRelation(z,Q){let Z=this.relations.get(z);if(Z){if(Z.delete(Q),Z.size===0)this.relations.delete(z);let W=this.relations.get(Q);if(W){if(W.delete(z),W.size===0)this.relations.delete(Q)}}}replaceRelationsUnsafely(z,Q){this.relations.set(z,new Set(Q));for(let Z of Q){let W=new Set().add(z);this.relations.set(Z,W)}}replaceRelationsSafely(z,Q){let Z=this.relations.get(z),W=this.isAType?.(z)?z:void 0,G=W===void 0?z:void 0;if(Z)for(let H of Z){W??=H,G??=H;let Y=this.relations.get(H);if(Y){if(Y.size===1)this.relations.delete(H);else Y.delete(z);this.contents.delete(this.makeContentKey(W,G))}}this.relations.set(z,new Set(Q));for(let H of Q){let Y=this.relations.get(H);if(Y)Y.add(z);else Y=new Set().add(z),this.relations.set(H,Y)}}getContentInternal(z){return this.contents.get(z)}setContent(z,Q){this.contents.set(z,Q)}deleteContent(z){this.contents.delete(z)}constructor(z,Q){if(this.a=z.between[0],this.b=z.between[1],this.cardinality=z.cardinality,!Q?.externalStore)this.relations=new Map(z.relations?.map(([Z,W])=>[Z,new Set(W)])),this.contents=new Map(z.contents);if(this.isAType=Q?.isAType??null,this.isBType=Q?.isBType??null,this.isContent=Q?.isContent??null,Q?.makeContentKey)this.makeContentKey=Q.makeContentKey;if(Q?.externalStore){let Z=Q.externalStore;if(this.has=(W,G)=>Z.has(W,G),this.addRelation=(W,G)=>{Z.addRelation(W,G)},this.deleteRelation=(W,G)=>{Z.deleteRelation(W,G)},this.replaceRelationsSafely=(W,G)=>{Z.replaceRelationsSafely(W,G)},this.replaceRelationsUnsafely=(W,G)=>{Z.replaceRelationsUnsafely(W,G)},this.getRelatedKeys=(W)=>Z.getRelatedKeys(W),Z.getContent)this.getContentInternal=(W)=>{return Z.getContent(W)},this.setContent=(W,G)=>{Z.setContent(W,G)},this.deleteContent=(W)=>{Z.deleteContent(W)};for(let[W,G]of z.relations??[]){let H=this.isAType?.(W)?W:void 0,Y=H===void 0?W:void 0;for(let X of G)H??=X,Y??=X,this.addRelation(H,Y)}for(let[W,G]of z.contents??[])this.setContent(W,G)}if(Q?.warn)this.warn=Q.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([z,Q])=>[z,[...Q]]),contents:[...this.contents.entries()]}}set(...z){let Q,Z,W;switch(z.length){case 1:{let G=z[0];Q=G[this.a],Z=G[this.b],W=void 0;break}case 2:{let G=z[0];if(typeof G==="string")[Q,Z]=z;else Q=G[this.a],Z=G[this.b],W=z[1];break}default:Q=z[0],Z=z[1],W=z[2];break}switch(this.cardinality){case"1:1":{let G=this.getRelatedKey(Q);if(G&&G!==Z)this.delete(Q,G)}case"1:n":{let G=this.getRelatedKey(Z);if(G&&G!==Q)this.delete(G,Z)}break;case"n:n":}if(W){let G=this.makeContentKey(Q,Z);this.setContent(G,W)}return this.addRelation(Q,Z),this}delete(z,Q){Q=typeof Q==="string"?Q:z[this.b];let Z=typeof z==="string"?z:z[this.a];if(Z===void 0&&typeof Q==="string"){let W=this.getRelatedKeys(Q);if(W)for(let G of W)this.delete(G,Q)}if(typeof Z==="string"&&Q===void 0){let W=this.getRelatedKeys(Z);if(W)for(let G of W)this.delete(Z,G)}if(typeof Z==="string"&&typeof Q==="string"){this.deleteRelation(Z,Q);let W=this.makeContentKey(Z,Q);this.deleteContent(W)}return this}getRelatedKey(z){let Q=this.getRelatedKeys(z);if(Q){if(Q.size>1)this.warn?.(`${Q.size} related keys were found for key "${z}": (${[...Q].map((W)=>`"${W}"`).join(", ")}). Only one related key was expected.`);let Z;for(let W of Q){Z=W;break}return Z}}replaceRelations(z,Q,Z){let W=!Array.isArray(Q),G=W?Object.keys(Q):Q;if(Z?.reckless)this.replaceRelationsUnsafely(z,G);else this.replaceRelationsSafely(z,G);if(W)for(let H of G){let Y=this.makeContentKey(z,H),X=Q[H];this.setContent(Y,X)}return this}getContent(z,Q){let Z=this.makeContentKey(z,Q);return this.getContentInternal(Z)}getRelationEntries(z){let Q=z[this.a],Z=z[this.b];if(Q!==void 0&&Z===void 0){let W=this.getRelatedKeys(Q);if(W)return[...W].map((G)=>{return[G,this.getContent(Q,G)]})}if(Q===void 0&&Z!==void 0){let W=this.getRelatedKeys(Z);if(W)return[...W].map((G)=>{return[G,this.getContent(G,Z)]})}return[]}has(z,Q){if(Q)return this.getRelatedKeys(z)?.has(Q)??!1;return this.relations.has(z)}},U=class{Subscriber;subscribers=new Map;subscribe(z,Q){return this.subscribers.set(z,Q),()=>{this.unsubscribe(z)}}unsubscribe(z){this.subscribers.delete(z)}next(z){let Q=this.subscribers.values();for(let Z of Q)Z(z)}},yz=class extends U{state;constructor(z){super();this.state=z}next(z){this.state=z,super.next(z)}},uz=(z,Q)=>{let Z=L(z);if(Z.operation.open)return Z.operation.prev.get(Q.key);return Z.valueMap.get(Q.key)};function Vz(z,Q,Z,W){let G=z.disposalTraces.buffer.find((H)=>H?.key===C(W));switch(z.logger.error("\u274C",Q.type,Q.key,"gets a fallback value because key",W,"is not allocated",G?`This key was previously disposed:
|
|
3
|
+
var fz=Object.create;var{getPrototypeOf:Sz,defineProperty:F0,getOwnPropertyNames:Kz}=Object;var bz=Object.prototype.hasOwnProperty;var wQ=(z,Q,Z)=>{Z=z!=null?fz(Sz(z)):{};let W=Q||!z||!z.__esModule?F0(Z,"default",{value:z,enumerable:!0}):Z;for(let G of Kz(z))if(!bz.call(W,G))F0(W,G,{get:()=>z[G],enumerable:!0});return W};var xQ=(z,Q)=>()=>(Q||z((Q={exports:{}}).exports,Q),Q.exports);var RQ=(z,Q)=>{for(var Z in Q)F0(z,Z,{get:Q[Z],enumerable:!0,configurable:!0,set:(W)=>Q[Z]=()=>W})};var AQ=(z,Q)=>()=>(z&&(Q=z(z=0)),Q);var vQ=import.meta.require;function I(z){return JSON.parse(z)}var C=(z)=>JSON.stringify(z),TQ=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function o(z){return L0(f.STORE,z,void 0)}function Y0(z){return _0(f.STORE,z)}function KQ(...z){if(z.length===2)return m(f.STORE,...z);return m(f.STORE,...z)}function E0(z,Q){return Yz(f.STORE,z,Q)}function o0(z){return $z(z,f.STORE)}var k={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]"};var w0=(z)=>(Q,Z,W,G,...H)=>{console[z](`${Q} ${k[Z]} \`${W}\` ${G}`,...H)},gz={error:w0("error"),info:w0("info"),warn:w0("warn")},t0=class{logLevel;filter;logger;constructor(z,Q,Z=gz){this.logLevel=z,this.filter=Q,this.logger=Z}error=(...z)=>{if(this.logLevel!==null){let Q=this.filter?.(...z)??!0;if(Q===!0)this.logger.error(...z);else if(Q)this.logger.error(...Q)}};info=(...z)=>{if(this.logLevel==="info"){let Q=this.filter?.(...z)??!0;if(Q===!0)this.logger.info(...z);else if(Q)this.logger.info(...Q)}};warn=(...z)=>{if(this.logLevel!=="error"&&this.logLevel!==null){let Q=this.filter?.(...z)??!0;if(Q===!0)this.logger.warn(...z);else if(Q)this.logger.warn(...Q)}}};var dz=class{store;constructor(z=f.STORE){this.store=z,Qz("root",z)}allocate(z,Q,Z){return t(this.store,z,Q,Z)}fuse(z,Q,Z){return Zz(this.store,z,Q,Z)}deallocate(z){e(this.store,z)}claim(z,Q,Z){return $0(this.store,z,Q,Z)}},e0=class{store;realm;constructor(z=f.STORE){this.store=z,this.realm=new dz(z)}allocate(z,Q,Z){t(this.store,z,Q,Z)}deallocate(z){e(this.store,z)}claim(z,Q,Z){$0(this.store,z,Q,Z)}};function M0(z){return Gz(f.STORE,z)}function X0(z){return R0(f.STORE,z)}var y=class z extends Set{mode="record";subject=new U;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(Q,Z=0){super(Q);if(Q instanceof z)this.parent=Q,this.cacheUpdateNumber=Q.cacheUpdateNumber;if(Z)this.cacheLimit=Z,this.cache=new Array(Z),this.subscribe("auto cache",(W)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=W})}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(Q){let Z=new z(Q.members,Q.cacheLimit);return Z.cache=Q.cache,Z.cacheIdx=Q.cacheIdx,Z.cacheUpdateNumber=Q.cacheUpdateNumber,Z}add(Q){let Z=super.add(Q);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${C(Q)}`);return Z}clear(){let Q=this.mode==="record"?[...this]:null;if(super.clear(),Q)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(Q)}`)}delete(Q){let Z=super.delete(Q);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${C(Q)}`);return Z}parent=null;child=null;transactionUpdates=null;transaction(Q){this.mode="transaction",this.transactionUpdates=[],this.child=new z(this);let Z=this.child._subscribe("transaction",(W)=>{this.transactionUpdates?.push(W)});try{if(Q(this.child)){for(let G of this.transactionUpdates)this.doStep(G);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(W){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",W),W}finally{Z(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(Q,Z){return this.subject.subscribe(Q,Z)}subscribe(Q,Z){return this.subject.subscribe(Q,(W)=>{Z(`${this.cacheUpdateNumber}=${W}`)})}emit(Q){this.subject.next(Q)}doStep(Q){let Z=Q.indexOf(":"),W=Q.substring(0,Z),G=Q.substring(Z+1);switch(W){case"add":this.add(JSON.parse(G));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(G));break;case"tx":for(let H of G.split(";"))this.doStep(H)}}getUpdateNumber(Q){let Z=Q.indexOf("=");return Number(Q.substring(0,Z))}do(Q){let Z=Q.indexOf("="),W=Number(Q.substring(0,Z)),G=W-this.cacheUpdateNumber;if(G>0){if(G===1){this.mode="playback";let Y=Q.substring(Z+1);return this.doStep(Y),this.mode="record",this.cacheUpdateNumber=W,null}return this.cacheUpdateNumber+1}if(Math.abs(G)<this.cacheLimit){let Y=this.cacheIdx+G;if(this.cache[Y]===Q)return null;this.mode="playback";let $=!1;while(!$){this.cacheIdx%=this.cacheLimit;let N=this.cache[this.cacheIdx];if(this.cacheIdx--,!N)return"OUT_OF_RANGE";this.undo(N),$=this.cacheIdx===Y-1}let _=Q.substring(Z+1);return this.doStep(_),this.mode="record",this.cacheUpdateNumber=W,null}return"OUT_OF_RANGE"}undoStep(Q){let Z=Q.indexOf(":"),W=Q.substring(0,Z),G=Q.substring(Z+1);switch(W){case"add":this.delete(JSON.parse(G));break;case"del":this.add(JSON.parse(G));break;case"clear":{let H=JSON.parse(G);for(let Y of H)this.add(Y);break}case"tx":{let H=G.split(";");for(let Y=H.length-1;Y>=0;Y--)this.undoStep(H[Y])}}}undo(Q){let Z=Q.indexOf("=");if(Number(Q.substring(0,Z))===this.cacheUpdateNumber){this.mode="playback";let G=Q.substring(Z+1);return this.undoStep(G),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function zz(z=Math.random){return z().toString(36).slice(2)}function L(z){while(z.child!==null)z=z.child;return z}var cz=class z{_buffer;_index=0;constructor(Q){let Z;if(typeof Q==="number")Z=Q;else Z=Q.length;this._buffer=Array.from({length:Z})}get buffer(){return this._buffer}get index(){return this._index}add(Q){this._buffer[this._index]=Q,this._index=(this._index+1)%this._buffer.length}copy(){let Q=new z([...this._buffer]);return Q._index=this._index,Q}};function i(z){let Q={key:z.key,type:z.type};if("family"in z)Q.family=z.family;return Q}var pz=Symbol("counterfeit"),kz={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"};function _z(z,Q,Z){let W=C(Q),G=`${z.key}(${W})`,H=kz[z.type],Y={key:G,type:H,family:{key:z.key,subKey:W}};if(Z)Y.counterfeit=!0;return Y}var S=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(z,Q)=>`${z}:${Q}`;warn;getRelatedKeys(z){return this.relations.get(z)}addRelation(z,Q){let Z=this.relations.get(z),W=this.relations.get(Q);if(Z)Z.add(Q);else Z=new Set([Q]),this.relations.set(z,Z);if(W)W.add(z);else W=new Set([z]),this.relations.set(Q,W)}deleteRelation(z,Q){let Z=this.relations.get(z);if(Z){if(Z.delete(Q),Z.size===0)this.relations.delete(z);let W=this.relations.get(Q);if(W){if(W.delete(z),W.size===0)this.relations.delete(Q)}}}replaceRelationsUnsafely(z,Q){this.relations.set(z,new Set(Q));for(let Z of Q){let W=new Set().add(z);this.relations.set(Z,W)}}replaceRelationsSafely(z,Q){let Z=this.relations.get(z),W=this.isAType?.(z)?z:void 0,G=W===void 0?z:void 0;if(Z)for(let H of Z){W??=H,G??=H;let Y=this.relations.get(H);if(Y){if(Y.size===1)this.relations.delete(H);else Y.delete(z);this.contents.delete(this.makeContentKey(W,G))}}this.relations.set(z,new Set(Q));for(let H of Q){let Y=this.relations.get(H);if(Y)Y.add(z);else Y=new Set().add(z),this.relations.set(H,Y)}}getContentInternal(z){return this.contents.get(z)}setContent(z,Q){this.contents.set(z,Q)}deleteContent(z){this.contents.delete(z)}constructor(z,Q){if(this.a=z.between[0],this.b=z.between[1],this.cardinality=z.cardinality,!Q?.externalStore)this.relations=new Map(z.relations?.map(([Z,W])=>[Z,new Set(W)])),this.contents=new Map(z.contents);if(this.isAType=Q?.isAType??null,this.isBType=Q?.isBType??null,this.isContent=Q?.isContent??null,Q?.makeContentKey)this.makeContentKey=Q.makeContentKey;if(Q?.externalStore){let Z=Q.externalStore;if(this.has=(W,G)=>Z.has(W,G),this.addRelation=(W,G)=>{Z.addRelation(W,G)},this.deleteRelation=(W,G)=>{Z.deleteRelation(W,G)},this.replaceRelationsSafely=(W,G)=>{Z.replaceRelationsSafely(W,G)},this.replaceRelationsUnsafely=(W,G)=>{Z.replaceRelationsUnsafely(W,G)},this.getRelatedKeys=(W)=>Z.getRelatedKeys(W),Z.getContent)this.getContentInternal=(W)=>{return Z.getContent(W)},this.setContent=(W,G)=>{Z.setContent(W,G)},this.deleteContent=(W)=>{Z.deleteContent(W)};for(let[W,G]of z.relations??[]){let H=this.isAType?.(W)?W:void 0,Y=H===void 0?W:void 0;for(let X of G)H??=X,Y??=X,this.addRelation(H,Y)}for(let[W,G]of z.contents??[])this.setContent(W,G)}if(Q?.warn)this.warn=Q.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([z,Q])=>[z,[...Q]]),contents:[...this.contents.entries()]}}set(...z){let Q,Z,W;switch(z.length){case 1:{let G=z[0];Q=G[this.a],Z=G[this.b],W=void 0;break}case 2:{let G=z[0];if(typeof G==="string")[Q,Z]=z;else Q=G[this.a],Z=G[this.b],W=z[1];break}default:Q=z[0],Z=z[1],W=z[2];break}switch(this.cardinality){case"1:1":{let G=this.getRelatedKey(Q);if(G&&G!==Z)this.delete(Q,G)}case"1:n":{let G=this.getRelatedKey(Z);if(G&&G!==Q)this.delete(G,Z)}break;case"n:n":}if(W){let G=this.makeContentKey(Q,Z);this.setContent(G,W)}return this.addRelation(Q,Z),this}delete(z,Q){Q=typeof Q==="string"?Q:z[this.b];let Z=typeof z==="string"?z:z[this.a];if(Z===void 0&&typeof Q==="string"){let W=this.getRelatedKeys(Q);if(W)for(let G of W)this.delete(G,Q)}if(typeof Z==="string"&&Q===void 0){let W=this.getRelatedKeys(Z);if(W)for(let G of W)this.delete(Z,G)}if(typeof Z==="string"&&typeof Q==="string"){this.deleteRelation(Z,Q);let W=this.makeContentKey(Z,Q);this.deleteContent(W)}return this}getRelatedKey(z){let Q=this.getRelatedKeys(z);if(Q){if(Q.size>1)this.warn?.(`${Q.size} related keys were found for key "${z}": (${[...Q].map((W)=>`"${W}"`).join(", ")}). Only one related key was expected.`);let Z;for(let W of Q){Z=W;break}return Z}}replaceRelations(z,Q,Z){let W=!Array.isArray(Q),G=W?Object.keys(Q):Q;if(Z?.reckless)this.replaceRelationsUnsafely(z,G);else this.replaceRelationsSafely(z,G);if(W)for(let H of G){let Y=this.makeContentKey(z,H),X=Q[H];this.setContent(Y,X)}return this}getContent(z,Q){let Z=this.makeContentKey(z,Q);return this.getContentInternal(Z)}getRelationEntries(z){let Q=z[this.a],Z=z[this.b];if(Q!==void 0&&Z===void 0){let W=this.getRelatedKeys(Q);if(W)return[...W].map((G)=>{return[G,this.getContent(Q,G)]})}if(Q===void 0&&Z!==void 0){let W=this.getRelatedKeys(Z);if(W)return[...W].map((G)=>{return[G,this.getContent(G,Z)]})}return[]}has(z,Q){if(Q)return this.getRelatedKeys(z)?.has(Q)??!1;return this.relations.has(z)}},U=class{Subscriber;subscribers=new Map;subscribe(z,Q){return this.subscribers.set(z,Q),()=>{this.unsubscribe(z)}}unsubscribe(z){this.subscribers.delete(z)}next(z){let Q=this.subscribers.values();for(let Z of Q)Z(z)}},yz=class extends U{state;constructor(z){super();this.state=z}next(z){this.state=z,super.next(z)}},uz=(z,Q)=>{let Z=L(z);if(Z.operation.open)return Z.operation.prev.get(Q.key);return Z.valueMap.get(Q.key)};function Vz(z,Q,Z,W){let G=z.disposalTraces.buffer.find((H)=>H?.key===C(W));switch(z.logger.error("\u274C",Q.type,Q.key,"gets a fallback value because key",W,"is not allocated",G?`This key was previously disposed:
|
|
4
4
|
${G.trace}`:"(no previous disposal trace found)"),Z.type){case"mutable_atom_family":{if(z.defaults.has(Z.key))return z.defaults.get(Z.key);let H=new Z.class;return z.defaults.set(Z.key,H),H}case"atom_family":{if(z.defaults.has(Z.key))return z.defaults.get(Z.key);let H=Z.default,Y=H(W);return z.defaults.set(Z.key,Y),Y}case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if(z.defaults.has(Z.key))return z.defaults.get(Z.key);let H=Z.default(W);return z.defaults.set(Z.key,H),H}}}var I0=class extends Promise{fate;resolve;reject;done=!1;constructor(z){let Q,Z;super((W,G)=>{Q=W,Z=G});this.resolve=Q,this.reject=Z,this.use(z instanceof Promise?z:new Promise(z))}pass(z,Q){if(z===this.fate)this.resolve(Q),this.done=!0}fail(z,Q){if(z===this.fate)this.reject(Q),this.done=!0}use(z){if(this===z)return;if(z instanceof Promise){let Q=z;this.fate=Q,Q.then((Z)=>{this.pass(Q,Z)},(Z)=>{this.fail(Q,Z)})}else this.resolve(z),this.fate=void 0}};function n(z){return"epoch"in z.transactionMeta}function K(z){return"phase"in z.transactionMeta}function Jz(z,Q){if(z.operation.open){let Z=performance.now();return z.logger.info("\uD83D\uDEAB",Q.type,Q.key,`deferring setState at T-${Z} until setState for "${z.operation.token.key}" is done`),Z}return z.operation={open:!0,done:new Set,prev:new Map,timestamp:Date.now(),token:Q},z.logger.info("\u2B55",Q.type,Q.key,`operation start in store "${z.config.name}"${K(z)?` ${z.transactionMeta.phase} "${z.transactionMeta.update.token.key}"`:""}`),z}function Ez(z){if(z.operation.open)z.logger.info("\uD83D\uDD34",z.operation.token.type,z.operation.token.key,`operation done in store "${z.config.name}"`);z.operation={open:!1},z.on.operationClose.next(z.operation)}var Mz=(z,Q)=>{if(!z.operation.open)return z.logger.error("\uD83D\uDC1E","unknown",Q,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0;return z.operation.done.has(Q)},B0=(z,Q)=>{if(!z.operation.open){z.logger.error("\uD83D\uDC1E","unknown",Q,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}z.operation.done.add(Q)};function K0(z,Q){let Z=L(z),{key:W,type:G}=Q,H=Z.selectorAtoms.getRelatedKeys(W);if(Z.logger.info("\uD83E\uDDF9",G,W,H?`evicting ${H.size} states downstream:`:"no downstream states",H??"to evict"),H){if(Z.operation.open)Z.logger.info("\uD83E\uDDF9",G,W,`[ ${[...Z.operation.done].join(", ")} ] already done`);for(let Y of H){if(Mz(Z,Y))continue;Lz(Z,Y),B0(Z,Y)}}}function hz(z,Q){let Z=L(z),W=Z.selectorGraph.getRelationEntries({upstreamSelectorKey:Q}).filter(([G,{source:H}])=>H===Q);for(let[G]of W){if(Mz(Z,G))continue;Lz(Z,G),B0(Z,G),hz(z,G)}}function u(z,Q,Z){let{key:W,subject:G,type:H}=Q,Y=z.valueMap.get(W);if(Y instanceof I0&&!Y.done){let X=Y;if(Z instanceof Promise)return X.use(Z),X;return z.valueMap.set(W,Z),Z}if(Z instanceof Promise){let X=new I0(Z);return z.valueMap.set(W,X),X.then(function $(_){if(z.valueMap.get(W)===X){switch(Jz(z,Q),u(z,Q,_),H){case"atom":case"mutable_atom":K0(z,Q);break;case"readonly_pure_selector":case"writable_pure_selector":hz(z,W);break}Ez(z),G.next({newValue:_,oldValue:X})}}).catch(($)=>{z.logger.error("\uD83D\uDCA5","state",W,"rejected:",$)}),X}return z.valueMap.set(W,Z),Z}function lz(z,Q,Z){z.logger.info("\uD83D\uDCD6",Q.type,Q.key,"reading cached value");let W=z.valueMap.get(Q.key);if(Z==="mut"&&Q.type==="mutable_atom"&&K(z)){let H=Q,{parent:Y}=z;if(z.valueMap.hasOwn(H.key))return W;let X=Y.valueMap.get(H.key);z.logger.info("\uD83D\uDCC3","atom",H.key,"copying");let $=X.toJSON(),_=H.class.fromJSON($);z.valueMap.set(H.key,_),new u0(H,Y),W=_}return W}function Lz(z,Q){let Z=z.valueMap.get(Q);if(Z instanceof I0){let W=z.writableSelectors.get(Q)??z.readonlySelectors.get(Q);if(W)W.getFrom(z);return}if(z.operation.open)z.operation.prev.set(Q,Z);z.valueMap.delete(Q),z.logger.info("\uD83D\uDDD1","state",Q,"evicted")}function Q0(z,Q,Z){if(z.valueMap.has(Q.key))return lz(z,Q,Z);let{key:W}=Q;switch(Q.type){case"readonly_held_selector":case"readonly_pure_selector":case"writable_held_selector":case"writable_pure_selector":return z.logger.info("\uD83E\uDDEE",Q.type,W,"computing value"),Q.getFrom(z);case"atom":{let G;if(Q.default instanceof Function)G=Q.default();else G=Q.default;let H=u(z,Q,G);return z.logger.info("\uD83D\uDC81","atom",Q.key,"could not find cached value; using default",G),H}case"mutable_atom":{let G=new Q.class,H=u(z,Q,G);return z.logger.info("\uD83D\uDC81","mutable_atom",Q.key,"could not find cached value; using default",G),H}}}function b0(z,Q){return R(z,{key:Q.family.key,type:`${Q.type}_family`})}var iz=(z)=>{let Q=L(z);if(!K(Q)){z.logger.warn("\uD83D\uDC1E","transaction","???","abortTransaction called outside of a transaction. This is probably a bug in AtomIO.");return}z.logger.info("\uD83E\uDE82","transaction",Q.transactionMeta.update.token.key,"Aborting transaction"),Q.parent.child=null},Pz=class extends Error{constructor(z,Q){super(`${k[z.type]} ${C(z.key)} not found in store "${Q.config.name}".`)}};function x0(z,Q,Z){return(...W)=>{let G=R(z,Q);if(G)return G.run(W,Z);throw new Pz(Q,z)}}var T0=(z)=>(Q)=>z instanceof Function?z(Q):z;function Oz(z,Q,[Z,W],G){let{key:H,subject:Y,type:X}=Q,$={oldValue:v0(Z)?Z.READONLY_VIEW:Z,newValue:v0(W)?W.READONLY_VIEW:W};if(n(z)){switch(X){case"mutable_atom":z.logger.info("\uD83D\uDCE2",X,H,"is now (",W,") subscribers:",Y.subscribers);break;case"atom":case"writable_pure_selector":case"writable_held_selector":z.logger.info("\uD83D\uDCE2",X,H,"went (",Z,"->",W,") subscribers:",Y.subscribers)}Y.next($)}if(K(z)&&(X==="mutable_atom"||X==="atom")){if(z.on.transactionApplying.state===null){let _=i(Q);if(v0(W))return;let{timestamp:N}=z.operation,q={type:"atom_update",token:_,timestamp:N,update:$};z.transactionMeta.update.subEvents.push(q),z.logger.info("\uD83D\uDCC1","atom",H,"stowed (",Z,"->",W,")");return}if(hQ(Q,"tracker:signal")){let _=H.slice(1),N=z.atoms.get(_);if(Q0(z,N,"mut").do($.newValue)===null===!0)K0(z,N)}}}var f0=(z,Q,Z)=>{let W=Q0(z,Q,"mut"),G=T0(Z)(W);return z.logger.info("\uD83D\uDCDD","atom",Q.key,"set to",G),G=u(z,Q,G),B0(z,Q.key),K0(z,Q),[W,G]};function Nz(z,Q){switch(Q.type){case"mutable_atom":return f0(z,Q,new Q.class);case"atom":{let Z=Q.default;if(Z instanceof Function)Z=Z();return f0(z,Q,Z)}}}function rz(z,Q){let Z;switch(Q.type){case"atom":case"mutable_atom":Z=Nz(z,Q);break;case"writable_pure_selector":case"writable_held_selector":{let W=Q.getFrom(z),G=C0(z,Q.key);for(let Y of G.values()){let X=Nz(z,Y);Oz(z,Q,X,!1)}let H=Q.getFrom(z);Z=[W,H]}break}return Z}function g(z,...Q){g0(z,S0,...Q)}var O0=Symbol("RESET");function h0(z,...Q){let Z,W,G;if(Q.length===1)Z=Q[0],g(z,Z,O0);else W=Q[0],G=Q[1],g(z,W,G,O0)}function az(z,Q,Z){let W,G,H,{type:Y,key:X}=Q;switch(Q.type){case"writable_pure_selector":W=Q.getFrom(z),G=T0(Z)(W),u(z,Q,G);break;case"writable_held_selector":H=Q.const,T0(Z)(H),W=H,G=H}return z.logger.info("\uD83D\uDCDD",Y,X,"setting to",G),B0(z,X),Q.setSelf(G),[W,G]}var nz=(z,Q,Z)=>{let W;switch(Q.type){case"atom":case"mutable_atom":W=f0(z,Q,Z);break;case"writable_pure_selector":case"writable_held_selector":W=az(z,Q,Z);break}return W};function sz(z,Q,Z){let{token:W,update:{newValue:G,oldValue:H}}=Q;g(Z,W,z==="newValue"?G:H)}function oz(z){let{stack:Q}=z;if(Q)return`
|
|
5
5
|
`+Q.split(`
|
|
6
6
|
`)?.slice(1)?.join(`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var zj=Object.create;var{getPrototypeOf:Wj,defineProperty:MW,getOwnPropertyNames:Qj}=Object;var Zj=Object.prototype.hasOwnProperty;var RN=($,X,Y)=>{Y=$!=null?zj(Wj($)):{};let U=X||!$||!$.__esModule?MW(Y,"default",{value:$,enumerable:!0}):Y;for(let G of Qj($))if(!Zj.call(U,G))MW(U,G,{get:()=>$[G],enumerable:!0});return U};var TN=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var D2=($,X)=>{for(var Y in X)MW($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:(U)=>X[Y]=()=>U})};var gm=($,X)=>()=>($&&(X=$($=0)),X);var vN=import.meta.require;var jM=TN((Wd,BM)=>{var bY=vN("os"),fY=vN("path");function CM($){let X=process.env.XDG_CACHE_HOME||fY.join(bY.homedir(),".cache");return fY.join(X,$)}function ox($){return fY.join(bY.homedir(),"Library","Caches",$)}function nx($){let X=process.env.LOCALAPPDATA||fY.join(bY.homedir(),"AppData","Local");return fY.join(X,$,"Cache")}var tx=function(){switch(bY.platform()){case"darwin":return ox;case"win32":return nx;case"aix":case"android":case"freebsd":case"linux":case"netbsd":case"openbsd":case"sunos":return CM;default:return console.error(`(node:${process.pid}) [cachedir] Warning: the platform "${bY.platform()}" is not currently supported by node-cachedir, falling back to "posix". Please file an issue with your platform here: https://github.com/LinusU/node-cachedir/issues/new`),CM}}();BM.exports=function $(X){if(typeof X!=="string")throw new TypeError("id is not a string");if(X.length===0)throw new Error("id cannot be empty");if(/[^0-9a-zA-Z-]/.test(X))throw new Error("id cannot contain special characters");return tx(X)}});var GJ=TN((Sl,RO)=>{var y5=process||{},XJ=y5.argv||[],g5=y5.env||{},NS=!(!!g5.NO_COLOR||XJ.includes("--no-color"))&&(!!g5.FORCE_COLOR||XJ.includes("--color")||y5.platform==="win32"||(y5.stdout||{}).isTTY&&g5.TERM!=="dumb"||!!g5.CI),FS=($,X,Y=$)=>(U)=>{let G=""+U,z=G.indexOf(X,$.length);return~z?$+MS(G,X,Y,z)+X:$+G+X},MS=($,X,Y,U)=>{let G="",z=0;do G+=$.substring(z,U)+Y,z=U+X.length,U=$.indexOf(X,z);while(~U);return G+$.substring(z)},YJ=($=NS)=>{let X=$?FS:()=>String;return{isColorSupported:$,reset:X("\x1B[0m","\x1B[0m"),bold:X("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:X("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:X("\x1B[3m","\x1B[23m"),underline:X("\x1B[4m","\x1B[24m"),inverse:X("\x1B[7m","\x1B[27m"),hidden:X("\x1B[8m","\x1B[28m"),strikethrough:X("\x1B[9m","\x1B[29m"),black:X("\x1B[30m","\x1B[39m"),red:X("\x1B[31m","\x1B[39m"),green:X("\x1B[32m","\x1B[39m"),yellow:X("\x1B[33m","\x1B[39m"),blue:X("\x1B[34m","\x1B[39m"),magenta:X("\x1B[35m","\x1B[39m"),cyan:X("\x1B[36m","\x1B[39m"),white:X("\x1B[37m","\x1B[39m"),gray:X("\x1B[90m","\x1B[39m"),bgBlack:X("\x1B[40m","\x1B[49m"),bgRed:X("\x1B[41m","\x1B[49m"),bgGreen:X("\x1B[42m","\x1B[49m"),bgYellow:X("\x1B[43m","\x1B[49m"),bgBlue:X("\x1B[44m","\x1B[49m"),bgMagenta:X("\x1B[45m","\x1B[49m"),bgCyan:X("\x1B[46m","\x1B[49m"),bgWhite:X("\x1B[47m","\x1B[49m"),blackBright:X("\x1B[90m","\x1B[39m"),redBright:X("\x1B[91m","\x1B[39m"),greenBright:X("\x1B[92m","\x1B[39m"),yellowBright:X("\x1B[93m","\x1B[39m"),blueBright:X("\x1B[94m","\x1B[39m"),magentaBright:X("\x1B[95m","\x1B[39m"),cyanBright:X("\x1B[96m","\x1B[39m"),whiteBright:X("\x1B[97m","\x1B[39m"),bgBlackBright:X("\x1B[100m","\x1B[49m"),bgRedBright:X("\x1B[101m","\x1B[49m"),bgGreenBright:X("\x1B[102m","\x1B[49m"),bgYellowBright:X("\x1B[103m","\x1B[49m"),bgBlueBright:X("\x1B[104m","\x1B[49m"),bgMagentaBright:X("\x1B[105m","\x1B[49m"),bgCyanBright:X("\x1B[106m","\x1B[49m"),bgWhiteBright:X("\x1B[107m","\x1B[49m")}};RO.exports=YJ();RO.exports.createColors=YJ});var W6=($)=>JSON.parse($),p$=($)=>JSON.stringify($),mm=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function X8($){return T3(t4.STORE,$,void 0)}function d9($){return U8(t4.STORE,$)}function AW(...$){if($.length===2)return a1(t4.STORE,...$);return a1(t4.STORE,...$)}function _3($,X){return bN(t4.STORE,$,X)}function CN($){return hN($,t4.STORE)}var A0={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]"};var JW=($)=>(X,Y,U,G,...z)=>{console[$](`${X} ${A0[Y]} \`${U}\` ${G}`,...z)},Hj={error:JW("error"),info:JW("info"),warn:JW("warn")},BN=class{logLevel;filter;logger;constructor($,X,Y=Hj){this.logLevel=$,this.filter=X,this.logger=Y}error=(...$)=>{if(this.logLevel!==null){let X=this.filter?.(...$)??!0;if(X===!0)this.logger.error(...$);else if(X)this.logger.error(...X)}};info=(...$)=>{if(this.logLevel==="info"){let X=this.filter?.(...$)??!0;if(X===!0)this.logger.info(...$);else if(X)this.logger.info(...X)}};warn=(...$)=>{if(this.logLevel!=="error"&&this.logLevel!==null){let X=this.filter?.(...$)??!0;if(X===!0)this.logger.warn(...$);else if(X)this.logger.warn(...X)}}};var Vj=class{store;constructor($=t4.STORE){this.store=$,IN("root",$)}allocate($,X,Y){return Y8(this.store,$,X,Y)}fuse($,X,Y){return xN(this.store,$,X,Y)}deallocate($){G8(this.store,$)}claim($,X,Y){return r9(this.store,$,X,Y)}},jN=class{store;realm;constructor($=t4.STORE){this.store=$,this.realm=new Vj($)}allocate($,X,Y){Y8(this.store,$,X,Y)}deallocate($){G8(this.store,$)}claim($,X,Y){r9(this.store,$,X,Y)}};function q3($){return _W(t4.STORE,$)}function l9($){return KW(t4.STORE,$)}var L0=class $ extends Set{mode="record";subject=new g$;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(X,Y=0){super(X);if(X instanceof $)this.parent=X,this.cacheUpdateNumber=X.cacheUpdateNumber;if(Y)this.cacheLimit=Y,this.cache=new Array(Y),this.subscribe("auto cache",(U)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=U})}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(X){let Y=new $(X.members,X.cacheLimit);return Y.cache=X.cache,Y.cacheIdx=X.cacheIdx,Y.cacheUpdateNumber=X.cacheUpdateNumber,Y}add(X){let Y=super.add(X);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${p$(X)}`);return Y}clear(){let X=this.mode==="record"?[...this]:null;if(super.clear(),X)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(X)}`)}delete(X){let Y=super.delete(X);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${p$(X)}`);return Y}parent=null;child=null;transactionUpdates=null;transaction(X){this.mode="transaction",this.transactionUpdates=[],this.child=new $(this);let Y=this.child._subscribe("transaction",(U)=>{this.transactionUpdates?.push(U)});try{if(X(this.child)){for(let G of this.transactionUpdates)this.doStep(G);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(U){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",U),U}finally{Y(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(X,Y){return this.subject.subscribe(X,Y)}subscribe(X,Y){return this.subject.subscribe(X,(U)=>{Y(`${this.cacheUpdateNumber}=${U}`)})}emit(X){this.subject.next(X)}doStep(X){let Y=X.indexOf(":"),U=X.substring(0,Y),G=X.substring(Y+1);switch(U){case"add":this.add(JSON.parse(G));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(G));break;case"tx":for(let z of G.split(";"))this.doStep(z)}}getUpdateNumber(X){let Y=X.indexOf("=");return Number(X.substring(0,Y))}do(X){let Y=X.indexOf("="),U=Number(X.substring(0,Y)),G=U-this.cacheUpdateNumber;if(G>0){if(G===1){this.mode="playback";let W=X.substring(Y+1);return this.doStep(W),this.mode="record",this.cacheUpdateNumber=U,null}return this.cacheUpdateNumber+1}if(Math.abs(G)<this.cacheLimit){let W=this.cacheIdx+G;if(this.cache[W]===X)return null;this.mode="playback";let Z=!1;while(!Z){this.cacheIdx%=this.cacheLimit;let V=this.cache[this.cacheIdx];if(this.cacheIdx--,!V)return"OUT_OF_RANGE";this.undo(V),Z=this.cacheIdx===W-1}let H=X.substring(Y+1);return this.doStep(H),this.mode="record",this.cacheUpdateNumber=U,null}return"OUT_OF_RANGE"}undoStep(X){let Y=X.indexOf(":"),U=X.substring(0,Y),G=X.substring(Y+1);switch(U){case"add":this.delete(JSON.parse(G));break;case"del":this.add(JSON.parse(G));break;case"clear":{let z=JSON.parse(G);for(let W of z)this.add(W);break}case"tx":{let z=G.split(";");for(let W=z.length-1;W>=0;W--)this.undoStep(z[W])}}}undo(X){let Y=X.indexOf("=");if(Number(X.substring(0,Y))===this.cacheUpdateNumber){this.mode="playback";let G=X.substring(Y+1);return this.undoStep(G),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function PN($=Math.random){return $().toString(36).slice(2)}function T$($){while($.child!==null)$=$.child;return $}var wj=class ${_buffer;_index=0;constructor(X){let Y;if(typeof X==="number")Y=X;else Y=X.length;this._buffer=Array.from({length:Y})}get buffer(){return this._buffer}get index(){return this._index}add(X){this._buffer[this._index]=X,this._index=(this._index+1)%this._buffer.length}copy(){let X=new $([...this._buffer]);return X._index=this._index,X}};function b1($){let X={key:$.key,type:$.type};if("family"in $)X.family=$.family;return X}var Dj=Symbol("counterfeit"),Ej={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"};function gN($,X,Y){let U=p$(X),G=`${$.key}(${U})`,z=Ej[$.type],W={key:G,type:z,family:{key:$.key,subKey:U}};if(Y)W.counterfeit=!0;return W}var F6=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=($,X)=>`${$}:${X}`;warn;getRelatedKeys($){return this.relations.get($)}addRelation($,X){let Y=this.relations.get($),U=this.relations.get(X);if(Y)Y.add(X);else Y=new Set([X]),this.relations.set($,Y);if(U)U.add($);else U=new Set([$]),this.relations.set(X,U)}deleteRelation($,X){let Y=this.relations.get($);if(Y){if(Y.delete(X),Y.size===0)this.relations.delete($);let U=this.relations.get(X);if(U){if(U.delete($),U.size===0)this.relations.delete(X)}}}replaceRelationsUnsafely($,X){this.relations.set($,new Set(X));for(let Y of X){let U=new Set().add($);this.relations.set(Y,U)}}replaceRelationsSafely($,X){let Y=this.relations.get($),U=this.isAType?.($)?$:void 0,G=U===void 0?$:void 0;if(Y)for(let z of Y){U??=z,G??=z;let W=this.relations.get(z);if(W){if(W.size===1)this.relations.delete(z);else W.delete($);this.contents.delete(this.makeContentKey(U,G))}}this.relations.set($,new Set(X));for(let z of X){let W=this.relations.get(z);if(W)W.add($);else W=new Set().add($),this.relations.set(z,W)}}getContentInternal($){return this.contents.get($)}setContent($,X){this.contents.set($,X)}deleteContent($){this.contents.delete($)}constructor($,X){if(this.a=$.between[0],this.b=$.between[1],this.cardinality=$.cardinality,!X?.externalStore)this.relations=new Map($.relations?.map(([Y,U])=>[Y,new Set(U)])),this.contents=new Map($.contents);if(this.isAType=X?.isAType??null,this.isBType=X?.isBType??null,this.isContent=X?.isContent??null,X?.makeContentKey)this.makeContentKey=X.makeContentKey;if(X?.externalStore){let Y=X.externalStore;if(this.has=(U,G)=>Y.has(U,G),this.addRelation=(U,G)=>{Y.addRelation(U,G)},this.deleteRelation=(U,G)=>{Y.deleteRelation(U,G)},this.replaceRelationsSafely=(U,G)=>{Y.replaceRelationsSafely(U,G)},this.replaceRelationsUnsafely=(U,G)=>{Y.replaceRelationsUnsafely(U,G)},this.getRelatedKeys=(U)=>Y.getRelatedKeys(U),Y.getContent)this.getContentInternal=(U)=>{return Y.getContent(U)},this.setContent=(U,G)=>{Y.setContent(U,G)},this.deleteContent=(U)=>{Y.deleteContent(U)};for(let[U,G]of $.relations??[]){let z=this.isAType?.(U)?U:void 0,W=z===void 0?U:void 0;for(let Q of G)z??=Q,W??=Q,this.addRelation(z,W)}for(let[U,G]of $.contents??[])this.setContent(U,G)}if(X?.warn)this.warn=X.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([$,X])=>[$,[...X]]),contents:[...this.contents.entries()]}}set(...$){let X,Y,U;switch($.length){case 1:{let G=$[0];X=G[this.a],Y=G[this.b],U=void 0;break}case 2:{let G=$[0];if(typeof G==="string")[X,Y]=$;else X=G[this.a],Y=G[this.b],U=$[1];break}default:X=$[0],Y=$[1],U=$[2];break}switch(this.cardinality){case"1:1":{let G=this.getRelatedKey(X);if(G&&G!==Y)this.delete(X,G)}case"1:n":{let G=this.getRelatedKey(Y);if(G&&G!==X)this.delete(G,Y)}break;case"n:n":}if(U){let G=this.makeContentKey(X,Y);this.setContent(G,U)}return this.addRelation(X,Y),this}delete($,X){X=typeof X==="string"?X:$[this.b];let Y=typeof $==="string"?$:$[this.a];if(Y===void 0&&typeof X==="string"){let U=this.getRelatedKeys(X);if(U)for(let G of U)this.delete(G,X)}if(typeof Y==="string"&&X===void 0){let U=this.getRelatedKeys(Y);if(U)for(let G of U)this.delete(Y,G)}if(typeof Y==="string"&&typeof X==="string"){this.deleteRelation(Y,X);let U=this.makeContentKey(Y,X);this.deleteContent(U)}return this}getRelatedKey($){let X=this.getRelatedKeys($);if(X){if(X.size>1)this.warn?.(`${X.size} related keys were found for key "${$}": (${[...X].map((U)=>`"${U}"`).join(", ")}). Only one related key was expected.`);let Y;for(let U of X){Y=U;break}return Y}}replaceRelations($,X,Y){let U=!Array.isArray(X),G=U?Object.keys(X):X;if(Y?.reckless)this.replaceRelationsUnsafely($,G);else this.replaceRelationsSafely($,G);if(U)for(let z of G){let W=this.makeContentKey($,z),Q=X[z];this.setContent(W,Q)}return this}getContent($,X){let Y=this.makeContentKey($,X);return this.getContentInternal(Y)}getRelationEntries($){let X=$[this.a],Y=$[this.b];if(X!==void 0&&Y===void 0){let U=this.getRelatedKeys(X);if(U)return[...U].map((G)=>{return[G,this.getContent(X,G)]})}if(X===void 0&&Y!==void 0){let U=this.getRelatedKeys(Y);if(U)return[...U].map((G)=>{return[G,this.getContent(G,Y)]})}return[]}has($,X){if(X)return this.getRelatedKeys($)?.has(X)??!1;return this.relations.has($)}},g$=class{Subscriber;subscribers=new Map;subscribe($,X){return this.subscribers.set($,X),()=>{this.unsubscribe($)}}unsubscribe($){this.subscribers.delete($)}next($){let X=this.subscribers.values();for(let Y of X)Y($)}},Nj=class extends g${state;constructor($){super();this.state=$}next($){this.state=$,super.next($)}},Fj=($,X)=>{let Y=T$($);if(Y.operation.open)return Y.operation.prev.get(X.key);return Y.valueMap.get(X.key)};function pN($,X,Y,U){let G=$.disposalTraces.buffer.find((z)=>z?.key===p$(U));switch($.logger.error("\u274C",X.type,X.key,"gets a fallback value because key",U,"is not allocated",G?`This key was previously disposed:
|
|
3
|
+
var zj=Object.create;var{getPrototypeOf:Wj,defineProperty:MW,getOwnPropertyNames:Qj}=Object;var Zj=Object.prototype.hasOwnProperty;var RN=($,X,Y)=>{Y=$!=null?zj(Wj($)):{};let U=X||!$||!$.__esModule?MW(Y,"default",{value:$,enumerable:!0}):Y;for(let G of Qj($))if(!Zj.call(U,G))MW(U,G,{get:()=>$[G],enumerable:!0});return U};var TN=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var D2=($,X)=>{for(var Y in X)MW($,Y,{get:X[Y],enumerable:!0,configurable:!0,set:(U)=>X[Y]=()=>U})};var gm=($,X)=>()=>($&&(X=$($=0)),X);var vN=import.meta.require;var jM=TN((Wd,BM)=>{var bY=vN("os"),fY=vN("path");function CM($){let X=process.env.XDG_CACHE_HOME||fY.join(bY.homedir(),".cache");return fY.join(X,$)}function ox($){return fY.join(bY.homedir(),"Library","Caches",$)}function nx($){let X=process.env.LOCALAPPDATA||fY.join(bY.homedir(),"AppData","Local");return fY.join(X,$,"Cache")}var tx=function(){switch(bY.platform()){case"darwin":return ox;case"win32":return nx;case"aix":case"android":case"freebsd":case"linux":case"netbsd":case"openbsd":case"sunos":return CM;default:return console.error(`(node:${process.pid}) [cachedir] Warning: the platform "${bY.platform()}" is not currently supported by node-cachedir, falling back to "posix". Please file an issue with your platform here: https://github.com/LinusU/node-cachedir/issues/new`),CM}}();BM.exports=function $(X){if(typeof X!=="string")throw new TypeError("id is not a string");if(X.length===0)throw new Error("id cannot be empty");if(/[^0-9a-zA-Z-]/.test(X))throw new Error("id cannot contain special characters");return tx(X)}});var GJ=TN((Sl,RO)=>{var y5=process||{},XJ=y5.argv||[],g5=y5.env||{},NS=!(!!g5.NO_COLOR||XJ.includes("--no-color"))&&(!!g5.FORCE_COLOR||XJ.includes("--color")||y5.platform==="win32"||(y5.stdout||{}).isTTY&&g5.TERM!=="dumb"||!!g5.CI),FS=($,X,Y=$)=>(U)=>{let G=""+U,z=G.indexOf(X,$.length);return~z?$+MS(G,X,Y,z)+X:$+G+X},MS=($,X,Y,U)=>{let G="",z=0;do G+=$.substring(z,U)+Y,z=U+X.length,U=$.indexOf(X,z);while(~U);return G+$.substring(z)},YJ=($=NS)=>{let X=$?FS:()=>String;return{isColorSupported:$,reset:X("\x1B[0m","\x1B[0m"),bold:X("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:X("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:X("\x1B[3m","\x1B[23m"),underline:X("\x1B[4m","\x1B[24m"),inverse:X("\x1B[7m","\x1B[27m"),hidden:X("\x1B[8m","\x1B[28m"),strikethrough:X("\x1B[9m","\x1B[29m"),black:X("\x1B[30m","\x1B[39m"),red:X("\x1B[31m","\x1B[39m"),green:X("\x1B[32m","\x1B[39m"),yellow:X("\x1B[33m","\x1B[39m"),blue:X("\x1B[34m","\x1B[39m"),magenta:X("\x1B[35m","\x1B[39m"),cyan:X("\x1B[36m","\x1B[39m"),white:X("\x1B[37m","\x1B[39m"),gray:X("\x1B[90m","\x1B[39m"),bgBlack:X("\x1B[40m","\x1B[49m"),bgRed:X("\x1B[41m","\x1B[49m"),bgGreen:X("\x1B[42m","\x1B[49m"),bgYellow:X("\x1B[43m","\x1B[49m"),bgBlue:X("\x1B[44m","\x1B[49m"),bgMagenta:X("\x1B[45m","\x1B[49m"),bgCyan:X("\x1B[46m","\x1B[49m"),bgWhite:X("\x1B[47m","\x1B[49m"),blackBright:X("\x1B[90m","\x1B[39m"),redBright:X("\x1B[91m","\x1B[39m"),greenBright:X("\x1B[92m","\x1B[39m"),yellowBright:X("\x1B[93m","\x1B[39m"),blueBright:X("\x1B[94m","\x1B[39m"),magentaBright:X("\x1B[95m","\x1B[39m"),cyanBright:X("\x1B[96m","\x1B[39m"),whiteBright:X("\x1B[97m","\x1B[39m"),bgBlackBright:X("\x1B[100m","\x1B[49m"),bgRedBright:X("\x1B[101m","\x1B[49m"),bgGreenBright:X("\x1B[102m","\x1B[49m"),bgYellowBright:X("\x1B[103m","\x1B[49m"),bgBlueBright:X("\x1B[104m","\x1B[49m"),bgMagentaBright:X("\x1B[105m","\x1B[49m"),bgCyanBright:X("\x1B[106m","\x1B[49m"),bgWhiteBright:X("\x1B[107m","\x1B[49m")}};RO.exports=YJ();RO.exports.createColors=YJ});function W6($){return JSON.parse($)}var p$=($)=>JSON.stringify($),mm=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function X8($){return T3(t4.STORE,$,void 0)}function d9($){return U8(t4.STORE,$)}function AW(...$){if($.length===2)return a1(t4.STORE,...$);return a1(t4.STORE,...$)}function _3($,X){return bN(t4.STORE,$,X)}function CN($){return hN($,t4.STORE)}var A0={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]"};var JW=($)=>(X,Y,U,G,...z)=>{console[$](`${X} ${A0[Y]} \`${U}\` ${G}`,...z)},Hj={error:JW("error"),info:JW("info"),warn:JW("warn")},BN=class{logLevel;filter;logger;constructor($,X,Y=Hj){this.logLevel=$,this.filter=X,this.logger=Y}error=(...$)=>{if(this.logLevel!==null){let X=this.filter?.(...$)??!0;if(X===!0)this.logger.error(...$);else if(X)this.logger.error(...X)}};info=(...$)=>{if(this.logLevel==="info"){let X=this.filter?.(...$)??!0;if(X===!0)this.logger.info(...$);else if(X)this.logger.info(...X)}};warn=(...$)=>{if(this.logLevel!=="error"&&this.logLevel!==null){let X=this.filter?.(...$)??!0;if(X===!0)this.logger.warn(...$);else if(X)this.logger.warn(...X)}}};var Vj=class{store;constructor($=t4.STORE){this.store=$,IN("root",$)}allocate($,X,Y){return Y8(this.store,$,X,Y)}fuse($,X,Y){return xN(this.store,$,X,Y)}deallocate($){G8(this.store,$)}claim($,X,Y){return r9(this.store,$,X,Y)}},jN=class{store;realm;constructor($=t4.STORE){this.store=$,this.realm=new Vj($)}allocate($,X,Y){Y8(this.store,$,X,Y)}deallocate($){G8(this.store,$)}claim($,X,Y){r9(this.store,$,X,Y)}};function q3($){return _W(t4.STORE,$)}function l9($){return KW(t4.STORE,$)}var L0=class $ extends Set{mode="record";subject=new g$;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(X,Y=0){super(X);if(X instanceof $)this.parent=X,this.cacheUpdateNumber=X.cacheUpdateNumber;if(Y)this.cacheLimit=Y,this.cache=new Array(Y),this.subscribe("auto cache",(U)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=U})}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(X){let Y=new $(X.members,X.cacheLimit);return Y.cache=X.cache,Y.cacheIdx=X.cacheIdx,Y.cacheUpdateNumber=X.cacheUpdateNumber,Y}add(X){let Y=super.add(X);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${p$(X)}`);return Y}clear(){let X=this.mode==="record"?[...this]:null;if(super.clear(),X)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(X)}`)}delete(X){let Y=super.delete(X);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${p$(X)}`);return Y}parent=null;child=null;transactionUpdates=null;transaction(X){this.mode="transaction",this.transactionUpdates=[],this.child=new $(this);let Y=this.child._subscribe("transaction",(U)=>{this.transactionUpdates?.push(U)});try{if(X(this.child)){for(let G of this.transactionUpdates)this.doStep(G);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(U){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",U),U}finally{Y(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(X,Y){return this.subject.subscribe(X,Y)}subscribe(X,Y){return this.subject.subscribe(X,(U)=>{Y(`${this.cacheUpdateNumber}=${U}`)})}emit(X){this.subject.next(X)}doStep(X){let Y=X.indexOf(":"),U=X.substring(0,Y),G=X.substring(Y+1);switch(U){case"add":this.add(JSON.parse(G));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(G));break;case"tx":for(let z of G.split(";"))this.doStep(z)}}getUpdateNumber(X){let Y=X.indexOf("=");return Number(X.substring(0,Y))}do(X){let Y=X.indexOf("="),U=Number(X.substring(0,Y)),G=U-this.cacheUpdateNumber;if(G>0){if(G===1){this.mode="playback";let W=X.substring(Y+1);return this.doStep(W),this.mode="record",this.cacheUpdateNumber=U,null}return this.cacheUpdateNumber+1}if(Math.abs(G)<this.cacheLimit){let W=this.cacheIdx+G;if(this.cache[W]===X)return null;this.mode="playback";let Z=!1;while(!Z){this.cacheIdx%=this.cacheLimit;let V=this.cache[this.cacheIdx];if(this.cacheIdx--,!V)return"OUT_OF_RANGE";this.undo(V),Z=this.cacheIdx===W-1}let H=X.substring(Y+1);return this.doStep(H),this.mode="record",this.cacheUpdateNumber=U,null}return"OUT_OF_RANGE"}undoStep(X){let Y=X.indexOf(":"),U=X.substring(0,Y),G=X.substring(Y+1);switch(U){case"add":this.delete(JSON.parse(G));break;case"del":this.add(JSON.parse(G));break;case"clear":{let z=JSON.parse(G);for(let W of z)this.add(W);break}case"tx":{let z=G.split(";");for(let W=z.length-1;W>=0;W--)this.undoStep(z[W])}}}undo(X){let Y=X.indexOf("=");if(Number(X.substring(0,Y))===this.cacheUpdateNumber){this.mode="playback";let G=X.substring(Y+1);return this.undoStep(G),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function PN($=Math.random){return $().toString(36).slice(2)}function T$($){while($.child!==null)$=$.child;return $}var wj=class ${_buffer;_index=0;constructor(X){let Y;if(typeof X==="number")Y=X;else Y=X.length;this._buffer=Array.from({length:Y})}get buffer(){return this._buffer}get index(){return this._index}add(X){this._buffer[this._index]=X,this._index=(this._index+1)%this._buffer.length}copy(){let X=new $([...this._buffer]);return X._index=this._index,X}};function b1($){let X={key:$.key,type:$.type};if("family"in $)X.family=$.family;return X}var Dj=Symbol("counterfeit"),Ej={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"};function gN($,X,Y){let U=p$(X),G=`${$.key}(${U})`,z=Ej[$.type],W={key:G,type:z,family:{key:$.key,subKey:U}};if(Y)W.counterfeit=!0;return W}var F6=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=($,X)=>`${$}:${X}`;warn;getRelatedKeys($){return this.relations.get($)}addRelation($,X){let Y=this.relations.get($),U=this.relations.get(X);if(Y)Y.add(X);else Y=new Set([X]),this.relations.set($,Y);if(U)U.add($);else U=new Set([$]),this.relations.set(X,U)}deleteRelation($,X){let Y=this.relations.get($);if(Y){if(Y.delete(X),Y.size===0)this.relations.delete($);let U=this.relations.get(X);if(U){if(U.delete($),U.size===0)this.relations.delete(X)}}}replaceRelationsUnsafely($,X){this.relations.set($,new Set(X));for(let Y of X){let U=new Set().add($);this.relations.set(Y,U)}}replaceRelationsSafely($,X){let Y=this.relations.get($),U=this.isAType?.($)?$:void 0,G=U===void 0?$:void 0;if(Y)for(let z of Y){U??=z,G??=z;let W=this.relations.get(z);if(W){if(W.size===1)this.relations.delete(z);else W.delete($);this.contents.delete(this.makeContentKey(U,G))}}this.relations.set($,new Set(X));for(let z of X){let W=this.relations.get(z);if(W)W.add($);else W=new Set().add($),this.relations.set(z,W)}}getContentInternal($){return this.contents.get($)}setContent($,X){this.contents.set($,X)}deleteContent($){this.contents.delete($)}constructor($,X){if(this.a=$.between[0],this.b=$.between[1],this.cardinality=$.cardinality,!X?.externalStore)this.relations=new Map($.relations?.map(([Y,U])=>[Y,new Set(U)])),this.contents=new Map($.contents);if(this.isAType=X?.isAType??null,this.isBType=X?.isBType??null,this.isContent=X?.isContent??null,X?.makeContentKey)this.makeContentKey=X.makeContentKey;if(X?.externalStore){let Y=X.externalStore;if(this.has=(U,G)=>Y.has(U,G),this.addRelation=(U,G)=>{Y.addRelation(U,G)},this.deleteRelation=(U,G)=>{Y.deleteRelation(U,G)},this.replaceRelationsSafely=(U,G)=>{Y.replaceRelationsSafely(U,G)},this.replaceRelationsUnsafely=(U,G)=>{Y.replaceRelationsUnsafely(U,G)},this.getRelatedKeys=(U)=>Y.getRelatedKeys(U),Y.getContent)this.getContentInternal=(U)=>{return Y.getContent(U)},this.setContent=(U,G)=>{Y.setContent(U,G)},this.deleteContent=(U)=>{Y.deleteContent(U)};for(let[U,G]of $.relations??[]){let z=this.isAType?.(U)?U:void 0,W=z===void 0?U:void 0;for(let Q of G)z??=Q,W??=Q,this.addRelation(z,W)}for(let[U,G]of $.contents??[])this.setContent(U,G)}if(X?.warn)this.warn=X.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([$,X])=>[$,[...X]]),contents:[...this.contents.entries()]}}set(...$){let X,Y,U;switch($.length){case 1:{let G=$[0];X=G[this.a],Y=G[this.b],U=void 0;break}case 2:{let G=$[0];if(typeof G==="string")[X,Y]=$;else X=G[this.a],Y=G[this.b],U=$[1];break}default:X=$[0],Y=$[1],U=$[2];break}switch(this.cardinality){case"1:1":{let G=this.getRelatedKey(X);if(G&&G!==Y)this.delete(X,G)}case"1:n":{let G=this.getRelatedKey(Y);if(G&&G!==X)this.delete(G,Y)}break;case"n:n":}if(U){let G=this.makeContentKey(X,Y);this.setContent(G,U)}return this.addRelation(X,Y),this}delete($,X){X=typeof X==="string"?X:$[this.b];let Y=typeof $==="string"?$:$[this.a];if(Y===void 0&&typeof X==="string"){let U=this.getRelatedKeys(X);if(U)for(let G of U)this.delete(G,X)}if(typeof Y==="string"&&X===void 0){let U=this.getRelatedKeys(Y);if(U)for(let G of U)this.delete(Y,G)}if(typeof Y==="string"&&typeof X==="string"){this.deleteRelation(Y,X);let U=this.makeContentKey(Y,X);this.deleteContent(U)}return this}getRelatedKey($){let X=this.getRelatedKeys($);if(X){if(X.size>1)this.warn?.(`${X.size} related keys were found for key "${$}": (${[...X].map((U)=>`"${U}"`).join(", ")}). Only one related key was expected.`);let Y;for(let U of X){Y=U;break}return Y}}replaceRelations($,X,Y){let U=!Array.isArray(X),G=U?Object.keys(X):X;if(Y?.reckless)this.replaceRelationsUnsafely($,G);else this.replaceRelationsSafely($,G);if(U)for(let z of G){let W=this.makeContentKey($,z),Q=X[z];this.setContent(W,Q)}return this}getContent($,X){let Y=this.makeContentKey($,X);return this.getContentInternal(Y)}getRelationEntries($){let X=$[this.a],Y=$[this.b];if(X!==void 0&&Y===void 0){let U=this.getRelatedKeys(X);if(U)return[...U].map((G)=>{return[G,this.getContent(X,G)]})}if(X===void 0&&Y!==void 0){let U=this.getRelatedKeys(Y);if(U)return[...U].map((G)=>{return[G,this.getContent(G,Y)]})}return[]}has($,X){if(X)return this.getRelatedKeys($)?.has(X)??!1;return this.relations.has($)}},g$=class{Subscriber;subscribers=new Map;subscribe($,X){return this.subscribers.set($,X),()=>{this.unsubscribe($)}}unsubscribe($){this.subscribers.delete($)}next($){let X=this.subscribers.values();for(let Y of X)Y($)}},Nj=class extends g${state;constructor($){super();this.state=$}next($){this.state=$,super.next($)}},Fj=($,X)=>{let Y=T$($);if(Y.operation.open)return Y.operation.prev.get(X.key);return Y.valueMap.get(X.key)};function pN($,X,Y,U){let G=$.disposalTraces.buffer.find((z)=>z?.key===p$(U));switch($.logger.error("\u274C",X.type,X.key,"gets a fallback value because key",U,"is not allocated",G?`This key was previously disposed:
|
|
4
4
|
${G.trace}`:"(no previous disposal trace found)"),Y.type){case"mutable_atom_family":{if($.defaults.has(Y.key))return $.defaults.get(Y.key);let z=new Y.class;return $.defaults.set(Y.key,z),z}case"atom_family":{if($.defaults.has(Y.key))return $.defaults.get(Y.key);let z=Y.default,W=z(U);return $.defaults.set(Y.key,W),W}case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if($.defaults.has(Y.key))return $.defaults.get(Y.key);let z=Y.default(U);return $.defaults.set(Y.key,z),z}}}var TW=class extends Promise{fate;resolve;reject;done=!1;constructor($){let X,Y;super((U,G)=>{X=U,Y=G});this.resolve=X,this.reject=Y,this.use($ instanceof Promise?$:new Promise($))}pass($,X){if($===this.fate)this.resolve(X),this.done=!0}fail($,X){if($===this.fate)this.reject(X),this.done=!0}use($){if(this===$)return;if($ instanceof Promise){let X=$;this.fate=X,X.then((Y)=>{this.pass(X,Y)},(Y)=>{this.fail(X,Y)})}else this.resolve($),this.fate=void 0}};function $X($){return"epoch"in $.transactionMeta}function M6($){return"phase"in $.transactionMeta}function dN($,X){if($.operation.open){let Y=performance.now();return $.logger.info("\uD83D\uDEAB",X.type,X.key,`deferring setState at T-${Y} until setState for "${$.operation.token.key}" is done`),Y}return $.operation={open:!0,done:new Set,prev:new Map,timestamp:Date.now(),token:X},$.logger.info("\u2B55",X.type,X.key,`operation start in store "${$.config.name}"${M6($)?` ${$.transactionMeta.phase} "${$.transactionMeta.update.token.key}"`:""}`),$}function lN($){if($.operation.open)$.logger.info("\uD83D\uDD34",$.operation.token.type,$.operation.token.key,`operation done in store "${$.config.name}"`);$.operation={open:!1},$.on.operationClose.next($.operation)}var rN=($,X)=>{if(!$.operation.open)return $.logger.error("\uD83D\uDC1E","unknown",X,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0;return $.operation.done.has(X)},B3=($,X)=>{if(!$.operation.open){$.logger.error("\uD83D\uDC1E","unknown",X,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}$.operation.done.add(X)};function jW($,X){let Y=T$($),{key:U,type:G}=X,z=Y.selectorAtoms.getRelatedKeys(U);if(Y.logger.info("\uD83E\uDDF9",G,U,z?`evicting ${z.size} states downstream:`:"no downstream states",z??"to evict"),z){if(Y.operation.open)Y.logger.info("\uD83E\uDDF9",G,U,`[ ${[...Y.operation.done].join(", ")} ] already done`);for(let W of z){if(rN(Y,W))continue;oN(Y,W),B3(Y,W)}}}function iN($,X){let Y=T$($),U=Y.selectorGraph.getRelationEntries({upstreamSelectorKey:X}).filter(([G,{source:z}])=>z===X);for(let[G]of U){if(rN(Y,G))continue;oN(Y,G),B3(Y,G),iN($,G)}}function K0($,X,Y){let{key:U,subject:G,type:z}=X,W=$.valueMap.get(U);if(W instanceof TW&&!W.done){let Q=W;if(Y instanceof Promise)return Q.use(Y),Q;return $.valueMap.set(U,Y),Y}if(Y instanceof Promise){let Q=new TW(Y);return $.valueMap.set(U,Q),Q.then(function Z(H){if($.valueMap.get(U)===Q){switch(dN($,X),K0($,X,H),z){case"atom":case"mutable_atom":jW($,X);break;case"readonly_pure_selector":case"writable_pure_selector":iN($,U);break}lN($),G.next({newValue:H,oldValue:Q})}}).catch((Z)=>{$.logger.error("\uD83D\uDCA5","state",U,"rejected:",Z)}),Q}return $.valueMap.set(U,Y),Y}function Mj($,X,Y){$.logger.info("\uD83D\uDCD6",X.type,X.key,"reading cached value");let U=$.valueMap.get(X.key);if(Y==="mut"&&X.type==="mutable_atom"&&M6($)){let z=X,{parent:W}=$;if($.valueMap.hasOwn(z.key))return U;let Q=W.valueMap.get(z.key);$.logger.info("\uD83D\uDCC3","atom",z.key,"copying");let Z=Q.toJSON(),H=z.class.fromJSON(Z);$.valueMap.set(z.key,H),new gW(z,W),U=H}return U}function oN($,X){let Y=$.valueMap.get(X);if(Y instanceof TW){let U=$.writableSelectors.get(X)??$.readonlySelectors.get(X);if(U)U.getFrom($);return}if($.operation.open)$.operation.prev.set(X,Y);$.valueMap.delete(X),$.logger.info("\uD83D\uDDD1","state",X,"evicted")}function z8($,X,Y){if($.valueMap.has(X.key))return Mj($,X,Y);let{key:U}=X;switch(X.type){case"readonly_held_selector":case"readonly_pure_selector":case"writable_held_selector":case"writable_pure_selector":return $.logger.info("\uD83E\uDDEE",X.type,U,"computing value"),X.getFrom($);case"atom":{let G;if(X.default instanceof Function)G=X.default();else G=X.default;let z=K0($,X,G);return $.logger.info("\uD83D\uDC81","atom",X.key,"could not find cached value; using default",G),z}case"mutable_atom":{let G=new X.class,z=K0($,X,G);return $.logger.info("\uD83D\uDC81","mutable_atom",X.key,"could not find cached value; using default",G),z}}}function PW($,X){return A4($,{key:X.family.key,type:`${X.type}_family`})}var Jj=($)=>{let X=T$($);if(!M6(X)){$.logger.warn("\uD83D\uDC1E","transaction","???","abortTransaction called outside of a transaction. This is probably a bug in AtomIO.");return}$.logger.info("\uD83E\uDE82","transaction",X.transactionMeta.update.token.key,"Aborting transaction"),X.parent.child=null},nN=class extends Error{constructor($,X){super(`${A0[$.type]} ${p$($.key)} not found in store "${X.config.name}".`)}};function LW($,X,Y){return(...U)=>{let G=A4($,X);if(G)return G.run(U,Y);throw new nN(X,$)}}var vW=($)=>(X)=>$ instanceof Function?$(X):$;function tN($,X,[Y,U],G){let{key:z,subject:W,type:Q}=X,Z={oldValue:RW(Y)?Y.READONLY_VIEW:Y,newValue:RW(U)?U.READONLY_VIEW:U};if($X($)){switch(Q){case"mutable_atom":$.logger.info("\uD83D\uDCE2",Q,z,"is now (",U,") subscribers:",W.subscribers);break;case"atom":case"writable_pure_selector":case"writable_held_selector":$.logger.info("\uD83D\uDCE2",Q,z,"went (",Y,"->",U,") subscribers:",W.subscribers)}W.next(Z)}if(M6($)&&(Q==="mutable_atom"||Q==="atom")){if($.on.transactionApplying.state===null){let H=b1(X);if(RW(U))return;let{timestamp:V}=$.operation,O={type:"atom_update",token:H,timestamp:V,update:Z};$.transactionMeta.update.subEvents.push(O),$.logger.info("\uD83D\uDCC1","atom",z,"stowed (",Y,"->",U,")");return}if(dj(X,"tracker:signal")){let H=z.slice(1),V=$.atoms.get(H);if(z8($,V,"mut").do(Z.newValue)===null===!0)jW($,V)}}}var CW=($,X,Y)=>{let U=z8($,X,"mut"),G=vW(Y)(U);return $.logger.info("\uD83D\uDCDD","atom",X.key,"set to",G),G=K0($,X,G),B3($,X.key),jW($,X),[U,G]};function yN($,X){switch(X.type){case"mutable_atom":return CW($,X,new X.class);case"atom":{let Y=X.default;if(Y instanceof Function)Y=Y();return CW($,X,Y)}}}function Aj($,X){let Y;switch(X.type){case"atom":case"mutable_atom":Y=yN($,X);break;case"writable_pure_selector":case"writable_held_selector":{let U=X.getFrom($),G=C3($,X.key);for(let W of G.values()){let Q=yN($,W);tN($,X,Q,!1)}let z=X.getFrom($);Y=[U,z]}break}return Y}function A1($,...X){IW($,BW,...X)}var v3=Symbol("RESET");function R3($,...X){let Y,U,G;if(X.length===1)Y=X[0],A1($,Y,v3);else U=X[0],G=X[1],A1($,U,G,v3)}function Lj($,X,Y){let U,G,z,{type:W,key:Q}=X;switch(X.type){case"writable_pure_selector":U=X.getFrom($),G=vW(Y)(U),K0($,X,G);break;case"writable_held_selector":z=X.const,vW(Y)(z),U=z,G=z}return $.logger.info("\uD83D\uDCDD",W,Q,"setting to",G),B3($,Q),X.setSelf(G),[U,G]}var Kj=($,X,Y)=>{let U;switch(X.type){case"atom":case"mutable_atom":U=CW($,X,Y);break;case"writable_pure_selector":case"writable_held_selector":U=Lj($,X,Y);break}return U};function _j($,X,Y){let{token:U,update:{newValue:G,oldValue:z}}=X;A1(Y,U,$==="newValue"?G:z)}function qj($){let{stack:X}=$;if(X)return`
|
|
5
5
|
`+X.split(`
|
|
6
6
|
`)?.slice(1)?.join(`
|
package/bin/frontend.bun.js
CHANGED
|
@@ -44,7 +44,7 @@ Right: ${Z}`;var LQ=r({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUnd
|
|
|
44
44
|
${W},
|
|
45
45
|
`;if(!X.hasKind("union"))return H;let Q=new u4({kind:"Allows",optimistic:!0}).indent();X.compile(Q);let J=Q.write(`${X.id}Optimistic`);return`${H}${J},
|
|
46
46
|
`},`{
|
|
47
|
-
`)+"}");class Z6{config;resolvedConfig;name;get[X1](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(Y,Z){if(this.config=d4(N.config,Z),this.resolvedConfig=d4(N.resolvedConfig,Z),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys($Z).length}`,this.name in $Z)R(`A Scope already named ${this.name} already exists`);$Z[this.name]=this;let X=Object.entries(Y).map((_)=>this.preparseOwnAliasEntry(..._));for(let[_,G]of X){let $=_;if(_[0]==="#"){if($=_.slice(1),$ in this.aliases)R(l_($));this.aliases[$]=G}else{if($ in this.aliases)R(l_(_));this.aliases[$]=G,this.exportedNames.push($)}if(!y(G,"module")&&!y(G,"generic")&&!O2(G)){let W=this.preparseOwnDefinitionFormat(G,{alias:$});this.resolutions[$]=y(W,"root")?this.bindReference(W):this.createParseContext(W).id}}o_??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[o_.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=N.intrinsic?o(N.intrinsic,(_,G)=>_.startsWith("json")?[]:[_,this.bindReference(G)]):{}}cacheGetter(Y,Z){return Object.defineProperty(this,Y,{value:Z}),Z}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema(Y){return Y}generic=(...Y)=>{let Z=this;return(X,_)=>new A2(Y,_?new i8(X):X,Z,Z,_??null)};units=(Y,Z)=>{let X=[];for(let G of Y)if(!X.includes(G))X.push(G);let _=X.map((G)=>this.node("unit",{unit:G},Z));return this.node("union",_,{...Z,prereduced:!0})};lazyResolutions=[];lazilyResolve(Y,Z){let X=this.node("alias",{reference:Z??"synthetic",resolve:Y},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(X);return X}schema=(Y,Z)=>this.finalize(this.parseSchema(Y,Z));parseSchema=(Y,Z)=>this.node(i4(Y),Y,Z);preparseNode(Y,Z,X){let _=typeof Y==="string"?Y:i4(Z,Y);if(D0(Z)&&Z.kind===_)return Z;if(_==="alias"&&!X?.prereduced){let{reference:W}=e4.implementation.normalize(Z,this);if(W.startsWith("$")){let H=this.resolveRoot(W.slice(1));Z=H,_=H.kind}}else if(_==="union"&&Q1(Z,"object")){let W=kQ(Z);if(W?.length===1)Z=W[0],_=i4(Z)}if(D0(Z)&&Z.kind===_)return Z;let $=W4[_].normalize?.(Z,this)??Z;if(D0($))return $.kind===_?$:bQ(_,$.kind);return{...X,$:this,kind:_,def:$,prefix:X.alias??_}}bindReference(Y){let Z;if(D0(Y))Z=Y.$===this?Y:new Y.constructor(Y.attachments,this);else Z=Y.$===this?Y:new A2(Y.params,Y.bodyDef,Y.$,this,Y.hkt);if(!this.resolved)Object.assign(this.referencesById,Z.referencesById);return Z}resolveRoot(Y){return this.maybeResolveRoot(Y)??R(JZ(Y))}maybeResolveRoot(Y){let Z=this.maybeResolve(Y);if(y(Z,"generic"))return;return Z}maybeResolveSubalias(Y){return WZ(this.aliases,Y)??WZ(this.ambient,Y)}get ambient(){return N.ambient}maybeResolve(Y){let Z=this.resolutions[Y];if(Z){if(typeof Z!=="string")return this.bindReference(Z);let _=_1[Z];if(y(_,"root"))return this.resolutions[Y]=_;if(y(_,"context")){if(_.phase==="resolving")return this.node("alias",{reference:`$${Y}`},{prereduced:!0});if(_.phase==="resolved")return _0(`Unexpected resolved context for was uncached by its scope: ${i(_)}`);_.phase="resolving";let G=this.bindReference(this.parseOwnDefinitionFormat(_.def,_));return _.phase="resolved",_1[G.id]=G,_1[_.id]=G,this.resolutions[Y]=G}return _0(`Unexpected nodesById entry for ${Z}: ${i(_)}`)}let X=this.aliases[Y]??this.ambient?.[Y];if(!X)return this.maybeResolveSubalias(Y);if(X=this.normalizeRootScopeValue(X),y(X,"generic"))return this.resolutions[Y]=this.bindReference(X);if(y(X,"module")){if(!X.root)R(e_(Y));return this.resolutions[Y]=this.bindReference(X.root)}return this.resolutions[Y]=this.parse(X,{alias:Y})}createParseContext(Y){let Z=Y.id??uY(Y.prefix);return _1[Z]=Object.assign(Y,{[X1]:"context",$:this,id:Z,phase:"unresolved"})}traversal(Y){return new f1(Y,this.resolvedConfig)}import(...Y){return new Q4(o(this.export(...Y),(Z,X)=>[`#${Z}`,X]))}precompilation;_exportedResolutions;_exports;export(...Y){if(!this._exports){this._exports={};for(let X of this.exportedNames){let _=this.aliases[X];this._exports[X]=y(_,"module")?GZ(_,this):i_(this.maybeResolve(X))}for(let X of this.lazyResolutions)X.resolution;if(this._exportedResolutions=a_(this,this._exports),this._json=t_(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let X=s_(this.references);this.precompilation=X.write(r_,4),n_(this.references,X)}this.resolved=!0}let Z=Y.length?Y:this.exportedNames;return new Q4(o(Z,(X,_)=>[_,this._exports[_]]))}resolve(Y){return this.export()[Y]}node=(Y,Z,X={})=>{let _=this.preparseNode(Y,Z,X);if(D0(_))return this.bindReference(_);let G=this.createParseContext(_),$=dY(G),W=this.bindReference($);return _1[G.id]=W};parse=(Y,Z={})=>this.finalize(this.parseDefinition(Y,Z));parseDefinition(Y,Z={}){if(y(Y,"root"))return this.bindReference(Y);let X=this.preparseOwnDefinitionFormat(Y,Z);if(y(X,"root"))return this.bindReference(X);let _=this.createParseContext(X);_1[_.id]=_;let G=this.bindReference(this.parseOwnDefinitionFormat(Y,_));if(G.isCyclic)G=A_(G,_.id);return _1[_.id]=G,G}finalize(Y){if(i_(Y),!Y.precompilation&&!this.resolvedConfig.jitless)yQ(Y.references);return Y}}class HZ extends Z6{parseOwnDefinitionFormat(Y,Z){return dY(Z)}preparseOwnDefinitionFormat(Y,Z){return this.preparseNode(i4(Y),Y,Z)}preparseOwnAliasEntry(Y,Z){return[Y,Z]}normalizeRootScopeValue(Y){return Y}}var i_=(Y)=>{let Z=Y.references.filter((X)=>X.hasKind("alias"));for(let X of Z){Object.assign(X.referencesById,X.resolution.referencesById);for(let _ of Y.references)if(X.id in _.referencesById)Object.assign(_.referencesById,X.referencesById)}return Y},t_=(Y)=>o(Y,(Z,X)=>[Z,y(X,"root")||y(X,"generic")?X.json:y(X,"module")?t_(X):_0(`Unexpected resolution ${i(X)}`)]),WZ=(Y,Z)=>{let X=Z.indexOf(".");if(X===-1)return;let _=Z.slice(0,X),G=Y[_];if(G===void 0)return;if(!y(G,"module"))return R(gQ(_));let $=Z.slice(X+1),W=G[$];if(W===void 0)return WZ(G,$);if(y(W,"root")||y(W,"generic"))return W;if(y(W,"module"))return W.root??R(e_(Z));_0(`Unexpected resolution for alias '${Z}': ${i(W)}`)},X6=(Y,Z)=>new HZ(Y,Z),X8=new HZ({});var a_=(Y,Z)=>{let X={};for(let _ in Z){let G=Z[_];if(y(G,"module")){let $=a_(Y,G),W=o($,(H,Q)=>[`${_}.${H}`,Q]);Object.assign(X,W)}else if(y(G,"root")||y(G,"generic"))X[_]=G;else _0(`Unexpected scope resolution ${i(G)}`)}return X},JZ=(Y)=>`'${Y}' is unresolvable`,gQ=(Y)=>`'${Y}' must reference a module to be accessed using dot syntax`,e_=(Y)=>`Reference to submodule '${Y}' must specify an alias`;X8.export();var{schema:H0,node:U4,defineSchema:fw,generic:K1}=X8;var QZ="^(?:0|[1-9]\\d*)$",pQ=new RegExp(QZ),bw=B0(pQ);var YG=X6({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();N.intrinsic={...YG};var ZG=X6({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:QZ}},{prereducedAliases:!0}).export();Object.assign(N.intrinsic,ZG);var mQ=X6({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),d={...YG,...ZG,...mQ,emptyStructure:U4("structure",{},{prereduced:!0})};N.intrinsic={...d};var _G=(Y)=>typeof Y==="string"&&Y[0]==="d"&&(Y[1]==="'"||Y[1]==='"')&&Y.at(-1)===Y[1],XG=(Y)=>Y.toString()!=="Invalid Date",GG=(Y)=>Y.slice(2,-1),UZ=(Y)=>`'${Y}' could not be parsed by the Date constructor`,$G=(Y,Z)=>uQ(Y,Z),uQ=(Y,Z)=>{let X=new Date(Y);if(XG(X))return X;let _=bX(Y);if(_!==void 0){let G=new Date(_);if(XG(G))return G}return Z?R(Z===!0?UZ(Y):Z):void 0};var zZ=(Y,Z)=>{let X=Y.scanner.shiftUntil(dQ[HG[Z]]);if(Y.scanner.lookahead==="")return Y.error(lQ(X,Z));if(Y.scanner.shift(),Z==="/"){try{new RegExp(X)}catch(_){R(String(_))}Y.root=Y.ctx.$.node("intersection",{domain:"string",pattern:X},{prereduced:!0})}else if(g0(Z,FZ))Y.root=Y.ctx.$.node("unit",{unit:X});else{let _=$G(X,UZ(X));Y.root=Y.ctx.$.node("unit",{meta:X,unit:_})}},FZ={"'":1,'"':1},WG={"/":1,"'":1,'"':1},HG={"d'":"'",'d"':'"',"'":"'",'"':'"',"/":"/"},dQ={"'":(Y)=>Y.lookahead==="'",'"':(Y)=>Y.lookahead==='"',"/":(Y)=>Y.lookahead==="/"},cQ={'"':"double-quote","'":"single-quote","/":"forward slash"},lQ=(Y,Z)=>`${Z}${Y} requires a closing ${cQ[HG[Z]]}`;var JG=(Y)=>`Private type references should not include '#'. Use '${Y}' instead.`,_6="Optional definitions like 'string?' are only valid as properties in an object or tuple",G6="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var QG={">":!0,">=":!0},UG={"<":!0,"<=":!0};var z4={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},zG=(Y)=>`Unmatched )${Y===""?"":` before ${Y}`}`,$6=(Y)=>`Missing ${Y}`,FG=(Y,Z)=>`Left bounds are only valid when paired with right bounds (try ...${Z}${Y})`,W6=(Y)=>`Left-bounded expressions must specify their limits using < or <= (was ${Y})`,EG=(Y,Z,X,_)=>`An expression may have at most one left bound (parsed ${Y}${z4[Z]}, ${X}${z4[_]})`;var OG=(Y,Z,X)=>VG(Y,Z,X,[]),VG=(Y,Z,X,_)=>{let G=X.parseUntilFinalizer();if(_.push(G.root),G.finalizer===">"){if(_.length!==Z.params.length)return X.error(EZ(Y,Z.names,_.map(($)=>$.expression)));return _}if(G.finalizer===",")return VG(Y,Z,X,_);return G.error($6(">"))},EZ=(Y,Z,X)=>`${Y}<${Z.join(", ")}> requires exactly ${Z.length} args (got ${X.length}${X.length===0?"":`: ${X.join(", ")}`})`;var OZ=(Y)=>{let Z=Y.scanner.shiftUntilNextTerminator();if(Z==="keyof")Y.addPrefix("keyof");else Y.root=iQ(Y,Z)},oQ=(Y,Z,X)=>{if(X.scanner.shiftUntilNonWhitespace(),X.scanner.shift()!=="<")return X.error(EZ(Y,Z.names,[]));let G=OG(Y,Z,X);return Z(...G)},iQ=(Y,Z)=>rQ(Y,Z)??nQ(Y,Z)??Y.error(Z===""?Y.scanner.lookahead==="#"?JG(Y.shiftedByOne().scanner.shiftUntilNextTerminator()):VZ(Y):JZ(Z)),rQ=(Y,Z)=>{if(Y.ctx.args?.[Z]){let _=Y.ctx.args[Z];if(typeof _!=="string")return _;return Y.ctx.$.node("alias",{reference:_},{prereduced:!0})}let X=Y.ctx.$.maybeResolve(Z);if(y(X,"root"))return X;if(X===void 0)return;if(y(X,"generic"))return oQ(Z,X,Y);return R(`Unexpected resolution ${i(X)}`)},nQ=(Y,Z)=>{let X=yX(Z);if(X!==void 0)return Y.ctx.$.node("unit",{unit:X});let _=pX(Z);if(_!==void 0)return Y.ctx.$.node("unit",{unit:_})},VZ=(Y)=>{let Z=Y.previousOperator();return Z?DZ(Z,Y.scanner.unscanned):sQ(Y.scanner.unscanned)},DZ=(Y,Z="")=>`Token '${Y}' requires a right operand${Z?` before '${Z}'`:""}`,sQ=(Y)=>`Expected an expression${Y?` before '${Y}'`:""}`;var LZ=(Y)=>Y.scanner.lookahead===""?Y.error(VZ(Y)):Y.scanner.lookahead==="("?Y.shiftedByOne().reduceGroupOpen():Y.scanner.lookaheadIsIn(WG)?zZ(Y,Y.scanner.shift()):Y.scanner.lookaheadIsIn(V2)?LZ(Y.shiftedByOne()):Y.scanner.lookahead==="d"?Y.scanner.nextLookahead in FZ?zZ(Y,`${Y.scanner.shift()}${Y.scanner.shift()}`):OZ(Y):OZ(Y);class _2 extends NY{shiftUntilNextTerminator(){return this.shiftUntilNonWhitespace(),this.shiftUntil(()=>(this.lookahead in _2.terminatingChars))}static terminatingChars={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...V2};static finalizingLookaheads={">":1,",":1,"":1,"=":1,"?":1};static lookaheadIsFinalizing=(Y,Z)=>Y===">"?Z[0]==="="?Z[1]==="=":Z.trimStart()===""||g0(Z.trimStart()[0],_2.terminatingChars):Y==="="?Z[0]!=="=":Y===","||Y==="?"}var LG=(Y,Z)=>{let X=tQ(Y,Z);if(Y.root.hasKind("unit")){if(typeof Y.root.unit==="number"){Y.reduceLeftBound(Y.root.unit,X),Y.unsetRoot();return}if(Y.root.unit instanceof Date){let _=`d'${Y.root.description??Y.root.unit.toISOString()}'`;Y.unsetRoot(),Y.reduceLeftBound(_,X);return}}return eQ(Y,X)},MG={"<":1,">":1,"=":1},tQ=(Y,Z)=>Y.scanner.lookaheadIs("=")?`${Z}${Y.scanner.shift()}`:Z;var DG=(Y,Z,X,_)=>{if(X.extends(N.intrinsic.number)){if(typeof Z!=="number")return R(MZ(Y,Z,_));return Y==="=="?["min","max"]:Y[0]===">"?["min"]:["max"]}if(X.extends(N.intrinsic.lengthBoundable)){if(typeof Z!=="number")return R(MZ(Y,Z,_));return Y==="=="?["exactLength"]:Y[0]===">"?["minLength"]:["maxLength"]}if(X.extends(N.intrinsic.Date))return Y==="=="?["after","before"]:Y[0]===">"?["after"]:["before"];return R(W_(X.expression))},aQ=(Y)=>({rule:_G(Y.limit)?GG(Y.limit):Y.limit,exclusive:Y.comparator.length===1}),eQ=(Y,Z)=>{let X=Y.unsetRoot(),_=Y.scanner.location;Y.parseOperand();let G=Y.unsetRoot(),$=Y.scanner.sliceChars(_,Y.scanner.location);if(Y.root=X,!G.hasKind("unit")||typeof G.unit!=="number"&&!(G.unit instanceof Date))return Y.error(MZ(Z,$,"right"));let W=G.unit,H=Z.length===1,Q=DG(Z,typeof W==="number"?W:$,X,"right");for(let U of Q)Y.constrainRoot(U,Z==="=="?{rule:W}:{rule:W,exclusive:H});if(!Y.branches.leftBound)return;if(!g0(Z,UG))return Y.error(W6(Z));let J=DG(Y.branches.leftBound.comparator,Y.branches.leftBound.limit,X,"left");Y.constrainRoot(J[0],aQ(Y.branches.leftBound)),Y.branches.leftBound=null},MZ=(Y,Z,X)=>`Comparator ${X==="left"?z4[Y]:Y} must be ${X==="left"?"preceded":"followed"} by a corresponding literal (was ${Z})`;var AG=(Y)=>{Y.scanner.shiftUntilNonWhitespace();let Z=Y.scanner.shiftUntilNextTerminator();Y.root=Y.root.brand(Z)};var RG=(Y)=>{let Z=Y.scanner.shiftUntilNextTerminator(),X=gX(Z,{errorOnFail:wG(Z)});if(X===0)Y.error(wG(0));Y.root=Y.root.constrain("divisor",X)},wG=(Y)=>`% operator must be followed by a non-zero integer literal (was ${Y})`;var AZ=(Y)=>{let Z=Y.scanner.shift();return Z===""?Y.finalize(""):Z==="["?Y.scanner.shift()==="]"?Y.setRoot(Y.root.array()):Y.error(YU):Z==="|"?Y.scanner.lookahead===">"?Y.shiftedByOne().pushRootToBranch("|>"):Y.pushRootToBranch(Z):Z==="&"?Y.pushRootToBranch(Z):Z===")"?Y.finalizeGroup():_2.lookaheadIsFinalizing(Z,Y.scanner.unscanned)?Y.finalize(Z):g0(Z,MG)?LG(Y,Z):Z==="%"?RG(Y):Z==="#"?AG(Y):(Z in V2)?AZ(Y):Y.error(H6(Z))},H6=(Y,Z="")=>`'${Y}' is not allowed here${Z&&` (should be ${Z})`}`,YU="Missing expected ']'";var NG=(Y)=>{let Z=Y.unsetRoot();Y.parseOperand();let X=Y.unsetRoot();if(!X.hasKind("unit"))return Y.error(ZU(X.expression));let _=X.unit instanceof Date?()=>new Date(X.unit):X.unit;return[Z,"=",_]},ZU=(Y)=>`Default value '${Y}' must a literal value`;var wZ=(Y,Z)=>{let X=Z.$.maybeResolveRoot(Y);if(X)return X;if(Y.endsWith("[]")){let $=Z.$.maybeResolveRoot(Y.slice(0,-2));if($)return $.array()}let _=new F4(new _2(Y),Z),G=XU(_);if(_.finalizer===">")R(H6(">"));return G},XU=(Y)=>{Y.parseOperand();let Z=_8(Y).root;if(!Z)return _0(`Root was unexpectedly unset after parsing string '${Y.scanner.scanned}'`);if(Y.finalizer==="=")Z=NG(Y);else if(Y.finalizer==="?")Z=[Z,"?"];if(Y.scanner.shiftUntilNonWhitespace(),Y.scanner.lookahead)R(H6(Y.scanner.lookahead));return Z},_8=(Y)=>{while(Y.finalizer===void 0)_U(Y);return Y},_U=(Y)=>Y.hasRoot()?Y.parseOperator():Y.parseOperand();class F4{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor(Y,Z){this.scanner=Y,this.ctx=Z}error(Y){return R(Y)}hasRoot(){return this.root!==void 0}setRoot(Y){this.root=Y}unsetRoot(){let Y=this.root;return this.root=void 0,Y}constrainRoot(...Y){this.root=this.root.constrain(Y[0],Y[1])}finalize(Y){if(this.groups.length)return this.error($6(")"));this.finalizeBranches(),this.finalizer=Y}reduceLeftBound(Y,Z){let X=z4[Z];if(!g0(X,QG))return this.error(W6(Z));if(this.branches.leftBound)return this.error(EG(this.branches.leftBound.limit,this.branches.leftBound.comparator,Y,X));this.branches.leftBound={comparator:X,limit:Y}}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();let Y=this.groups.pop();if(!Y)return this.error(zG(this.scanner.unscanned));this.branches=Y}addPrefix(Y){this.branches.prefixes.push(Y)}applyPrefixes(){while(this.branches.prefixes.length){let Y=this.branches.prefixes.pop();this.root=Y==="keyof"?this.root.keyof():_0(`Unexpected prefix '${Y}'`)}}pushRootToBranch(Y){this.assertRangeUnset(),this.applyPrefixes();let Z=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(Z)??Z,Y==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,Y==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return _8(new F4(this.scanner,this.ctx))}parseOperator(){return AZ(this)}parseOperand(){return LZ(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(FG(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.at(-1)??(this.branches.intersection?"&":this.branches.union?"|":this.branches.pipe?"|>":void 0)}shiftedByOne(){return this.scanner.shift(),this}}var GU="An empty string is not a valid generic parameter name",J6=(Y,Z,X)=>{Y.shiftUntilNonWhitespace();let _=Y.shiftUntilNextTerminator();if(_===""){if(Y.lookahead===""&&Z.length)return Z;return R(GU)}return Y.shiftUntilNonWhitespace(),$U(Y,_,Z,X)},IG="extends ",$U=(Y,Z,X,_)=>{if(Y.shiftUntilNonWhitespace(),Y.unscanned.startsWith(IG))Y.jumpForward(IG.length);else{if(Y.lookahead===",")Y.shift();return X.push(Z),J6(Y,X,_)}let G=_8(new F4(Y,_));return X.push([Z,G.root]),J6(Y,X,_)};class RZ extends x1{$;constructor(Y){super((...Z)=>new G8(Y)(...Z),{bind:Y});this.$=Y}in(Y){return new G8(this.$,Y===void 0?void 0:this.$.parse(Y))}at(Y,Z){return new G8(this.$).at(Y,Z)}case(Y,Z){return new G8(this.$).case(Y,Z)}}class G8 extends x1{$;in;key;branches=[];constructor(Y,Z){super((X)=>this.caseEntries(Object.entries(X).map(([_,G])=>_==="default"?[_,G]:[this.$.parse(_),G])));this.$=Y,this.in=Z}at(Y,Z){if(this.key)R(HU);if(this.branches.length)R(WU);return this.key=Y,Z?this.match(Z):this}case(Y,Z){return this.caseEntry(this.$.parse(Y),Z)}caseEntry(Y,Z){let _=(this.key?this.$.parse({[this.key]:Y}):Y).pipe(Z);return this.branches.push(_),this}match(Y){return this(Y)}strings(Y){return this.caseEntries(Object.entries(Y).map(([Z,X])=>Z==="default"?[Z,X]:[this.$.node("unit",{unit:Z}),X]))}caseEntries(Y){for(let Z=0;Z<Y.length;Z++){let[X,_]=Y[Z];if(X==="default"){if(Z!==Y.length-1)R("default may only be specified as the last key of a switch definition");return this.default(_)}if(typeof _!=="function")return R(`Value for case "${X}" must be a function (was ${y0(_)})`);this.caseEntry(X,_)}return this}default(Y){if(typeof Y==="function")this.case(d.unknown,Y);let Z={branches:this.branches,ordered:!0};if(Y==="never"||Y==="assert")Z.meta={onFail:TG};let X=this.$.node("union",Z);if(!this.in)return this.$.finalize(X);let _=this.in.pipe(X);if(Y==="never"||Y==="assert")_=_.configureReferences({onFail:TG},"self");return this.$.finalize(_)}}var TG=(Y)=>Y.throw(),WU="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",HU="At most one key matcher may be specified per expression";var Q6=(Y,Z)=>{if(F0(Y)){if(Y[1]==="=")return[Z.$.parseOwnDefinitionFormat(Y[0],Z),"=",Y[2]];if(Y[1]==="?")return[Z.$.parseOwnDefinitionFormat(Y[0],Z),"?"]}return U6(Y,Z)},KG="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",BG="Only required keys may specify default values, e.g. { value: 'number = 0' }";var CG=(Y,Z)=>{let X,_={},G=j2(Y);for(let[W,H]of G){let Q=UU(W);if(Q.kind==="spread"){if(!d1(_))return R(QU);let L=Z.$.parseOwnDefinitionFormat(H,Z);if(L.equals(d.object))continue;if(!L.hasKind("intersection")||!L.basis?.equals(d.object))return R(zU(L.expression));X=L.structure;continue}if(Q.kind==="undeclared"){if(H!=="reject"&&H!=="delete"&&H!=="ignore")R(JU(H));_.undeclared=H;continue}let J=Q6(H,Z),U=Q;if(Q.kind==="required"){if(!F0(J))NZ(_,"required",{key:Q.normalized,value:J},Z);else NZ(_,"optional",J[1]==="="?{key:Q.normalized,value:J[0],default:J[2]}:{key:Q.normalized,value:J[0]},Z);continue}if(F0(J)){if(J[1]==="?")R(KG);if(J[1]==="=")R(BG)}if(Q.kind==="optional"){NZ(_,"optional",{key:Q.normalized,value:J},Z);continue}let E=Z.$.parseOwnDefinitionFormat(U.normalized,Z),V=Y6(E,J,Z.$);if(V.index)_.index=Z0(_.index,V.index);if(V.required)_.required=Z0(_.required,V.required)}let $=Z.$.node("structure",_);return Z.$.parseSchema({domain:"object",structure:X?.merge($)??$})},NZ=(Y,Z,X,_)=>{Y[Z]=Z0(Y[Z],_.$.node(Z,X))},JU=(Y)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${i(Y)})`,QU="Spread operator may only be used as the first key in an object",UU=(Y)=>typeof Y==="symbol"?{kind:"required",normalized:Y}:Y.at(-1)==="?"?Y.at(-2)===k4?{kind:"required",normalized:`${Y.slice(0,-2)}?`}:{kind:"optional",normalized:Y.slice(0,-1)}:Y[0]==="["&&Y.at(-1)==="]"?{kind:"index",normalized:Y.slice(1,-1)}:Y[0]===k4&&Y[1]==="["&&Y.at(-1)==="]"?{kind:"required",normalized:Y.slice(1)}:Y==="..."?{kind:"spread"}:Y==="+"?{kind:"undeclared"}:{kind:"required",normalized:Y==="\\..."?"...":Y==="\\+"?"+":Y},zU=(Y)=>`Spread operand must resolve to an object literal type (was ${Y})`;var jG=(Y,Z)=>RU(Y)?xG[Y[0]](Y,Z):AU(Y)?vG[Y[1]](Y,Z):null,FU=(Y,Z)=>Z.$.parseOwnDefinitionFormat(Y[1],Z).keyof(),IZ=(Y,Z)=>{if(Y[2]===void 0)return R(DZ(Y[1],""));let X=Z.$.parseOwnDefinitionFormat(Y[0],Z),_=Z.$.parseOwnDefinitionFormat(Y[2],Z);if(Y[1]==="|")return Z.$.node("union",{branches:[X,_]});let G=Y[1]==="&"?E1(X,_,Z.$):o4(X,_,Z.$);if(G instanceof P)return G.throw();return G},EU=(Y,Z)=>Z.$.parseOwnDefinitionFormat(Y[0],Z).array(),OU=(Y,Z)=>{if(typeof Y[2]!=="function")return R(SG("=>",Y[2]));return Z.$.parseOwnDefinitionFormat(Y[0],Z).pipe(Y[2])},SG=(Y,Z)=>`${Y===":"?"Narrow":"Morph"} expression requires a function following '${Y}' (was ${typeof Z})`,VU=(Y,Z)=>{if(typeof Y[2]!=="function")return R(SG(":",Y[2]));return Z.$.parseOwnDefinitionFormat(Y[0],Z).constrain("predicate",Y[2])},DU=(Y,Z)=>Z.$.parseOwnDefinitionFormat(Y[0],Z).configureReferences(Y[2],"shallow"),PG=(Y)=>Y,LU=PG({"[]":EU,"?":()=>R(_6)}),MU=PG({"|":IZ,"&":IZ,":":VU,"=>":OU,"|>":IZ,"@":DU,"=":()=>R(G6)}),vG={...LU,...MU},AU=(Y)=>vG[Y[1]]!==void 0,wU=(Y)=>Y,xG=wU({keyof:FU,instanceof:(Y,Z)=>{if(typeof Y[1]!=="function")return R(qG(f4(Y[1])));let X=Y.slice(1).map((_)=>typeof _==="function"?Z.$.node("proto",{proto:_}):R(qG(f4(_))));return X.length===1?X[0]:Z.$.node("union",{branches:X})},"===":(Y,Z)=>Z.$.units(Y.slice(1))}),RU=(Y)=>xG[Y[0]]!==void 0,qG=(Y)=>`Expected a constructor following 'instanceof' operator (was ${Y})`;var kG=(Y,Z)=>{let X=[{}],_=0;while(_<Y.length){let G=!1;if(Y[_]==="..."&&_<Y.length-1)G=!0,_++;let $=Q6(Y[_],Z),[W,H,Q]=!F0($)?[$]:$;if(_++,G){if(!W.extends(N.intrinsic.Array))return R(TU(W.expression));X=X.flatMap((J)=>W.distribute((U)=>IU(d8(J),U)))}else X=X.map((J)=>{if(H==="?")return bG(J,W);if(H==="=")return NU(J,W,Q);return TZ(J,W)})}return Z.$.parseSchema(X.map((G)=>d1(G)?{proto:Array,exactLength:0}:{proto:Array,sequence:G}))},TZ=(Y,Z)=>{if(Y.defaultables||Y.optionals)return R(Y.variadic?ZZ:KU);if(Y.variadic)Y.postfix=Z0(Y.postfix,Z);else Y.prefix=Z0(Y.prefix,Z);return Y},bG=(Y,Z)=>{if(Y.variadic)return R(yG);return Y.optionals=Z0(Y.optionals,Z),Y},NU=(Y,Z,X)=>{if(Y.variadic)return R(yG);if(Y.optionals)return R(BU);return Y.defaultables=Z0(Y.defaultables,[[Z,X]]),Y},fG=(Y,Z)=>{if(Y.postfix)R(hG);if(Y.variadic){if(!Y.variadic.equals(Z))R(hG)}else Y.variadic=Z.internal;return Y},IU=(Y,Z)=>{let X=Z.select({method:"find",kind:"sequence"});if(!X)return fG(Y,N.intrinsic.unknown);if(X.prefix)for(let _ of X.prefix)TZ(Y,_);if(X.optionals)for(let _ of X.optionals)bG(Y,_);if(X.variadic)fG(Y,X.variadic);if(X.postfix)for(let _ of X.postfix)TZ(Y,_);return Y},TU=(Y)=>`Spread element must be an array (was ${Y})`,hG="A tuple may have at most one variadic element",KU="A required element may not follow an optional element",yG="An optional element may not follow a variadic element";var BU="A defaultable element may not follow an optional element without a default";var CU={},U6=(Y,Z)=>{if(typeof Y==="string"){if(Z.args&&Object.keys(Z.args).some((_)=>Y.includes(_)))return wZ(Y,Z);let X=CU[Z.$.name]??={};return X[Y]??=wZ(Y,Z)}return Q1(Y,"object")?qU(Y,Z):R(KZ(y0(Y)))},qU=(Y,Z)=>{let X=x4(Y);switch(X){case void 0:if(y(Y,"root"))return Y;return CG(Y,Z);case"Array":return jU(Y,Z);case"RegExp":return Z.$.node("intersection",{domain:"string",pattern:Y},{prereduced:!0});case"Function":{let _=O2(Y)?Y():Y;if(y(_,"root"))return _;return R(KZ("Function"))}default:return R(KZ(X??i(Y)))}},jU=(Y,Z)=>jG(Y,Z)??kG(Y,Z),KZ=(Y)=>`Type definitions must be strings or objects (was ${Y})`;class BZ extends x1{constructor(Y){let Z=Object.assign({errors:z1,hkt:s0,$:Y,raw:Y.parse,module:Y.constructor.module,scope:Y.constructor.scope,define:Y.define,match:Y.match,generic:Y.generic,schema:Y.schema,keywords:Y.ambient,unit:Y.unit,enumerated:Y.enumerated,instanceOf:Y.instanceOf,valueOf:Y.valueOf,or:Y.or,and:Y.and,merge:Y.merge,pipe:Y.pipe},Y.ambientAttachments);super((...X)=>{if(X.length===1)return Y.parse(X[0]);if(X.length===2&&typeof X[0]==="string"&&X[0][0]==="<"&&X[0].at(-1)===">"){let _=X[0].slice(1,-1),G=Y.parseGenericParams(_,{});return new A2(G,X[1],Y,Y,null)}return Y.parse(X)},{bind:Y,attach:Z})}}var E4=N;class z6 extends Z6{get ambientAttachments(){if(!E4.typeAttachments)return;return this.cacheGetter("ambientAttachments",o(E4.typeAttachments,(Y,Z)=>[Y,this.bindReference(Z)]))}preparseOwnAliasEntry(Y,Z){let X=Y.indexOf("<");if(X===-1){if(y(Z,"module")||y(Z,"generic"))return[Y,Z];let $=this.name==="ark"?Y:Y==="root"?this.name:`${this.name}.${Y}`,W=this.resolvedConfig.keywords?.[$];if(W)Z=[Z,"@",W];return[Y,Z]}if(Y.at(-1)!==">")R("'>' must be the last character of a generic declaration in a scope");let _=Y.slice(0,X),G=Y.slice(X+1,-1);return[_,()=>{let $=this.parseGenericParams(G,{alias:_});return __($,Z,this)}]}parseGenericParams(Y,Z){return J6(new _2(Y),[],this.createParseContext({...Z,def:Y,prefix:"generic"}))}normalizeRootScopeValue(Y){if(O2(Y)&&!y(Y,"generic"))return Y();return Y}preparseOwnDefinitionFormat(Y,Z){return{...Z,def:Y,prefix:Z.alias??"type"}}parseOwnDefinitionFormat(Y,Z){if(!(Z.alias&&(Z.alias in this.aliases))&&!Z.args)Z.args={this:Z.id};let _=U6(Y,Z);if(F0(_)){if(_[1]==="=")return R(G6);if(_[1]==="?")return R(_6)}return _}unit=(Y)=>this.units([Y]);valueOf=(Y)=>this.units(IX(Y));enumerated=(...Y)=>this.units(Y);instanceOf=(Y)=>this.node("proto",{proto:Y},{prereduced:!0});or=(...Y)=>this.schema(Y.map((Z)=>this.parse(Z)));and=(...Y)=>Y.reduce((Z,X)=>Z.and(this.parse(X)),this.intrinsic.unknown);merge=(...Y)=>Y.reduce((Z,X)=>Z.merge(this.parse(X)),this.intrinsic.object);pipe=(...Y)=>this.intrinsic.unknown.pipe(...Y);match=new RZ(this);declare=()=>({type:this.type});define(Y){return Y}type=new BZ(this);static scope=(Y,Z={})=>new z6(Y,Z);static module=(Y,Z={})=>this.scope(Y,Z).export()}var CZ=Object.assign(z6.scope,{define:(Y)=>Y}),e=z6;class gG extends s0{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var SU=K1(["base",d.object],["props",d.object])((Y)=>Y.base.merge(Y.props),gG),pG=e.module({Key:d.key,Merge:SU});class mG extends s0{}var PU=K1("element")((Y)=>{let Z=Y.element.exclude(d.Array),X=Z.array();return Z.rawOr(X).pipe(E2).distribute((_)=>_.assertHasKind("morph").declareOut(X),H0)},mG),uG=e.module({root:d.Array,readonly:"root",index:d.nonNegativeIntegerString,liftFrom:PU},{name:"Array"});var qZ=H0(["string",P2.FileConstructor]),vU=qZ.rawOr(qZ.array()),dG=H0({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:vU}}),cG=e.module({root:["instanceof",FormData],value:qZ,parsed:dG,parse:H0({in:FormData,morphs:(Y)=>{let Z={};for(let[X,_]of Y)if(X in Z){let G=Z[X];if(typeof G==="string"||G instanceof P2.FileConstructor)Z[X]=[G,_];else G.push(_)}else Z[X]=_;return Z},declaredOut:dG})},{name:"FormData"});var lG=e.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"});var xU={Boolean:1,Number:1,String:1},oG=e.module({...o({...OY,...DY},(Y,Z)=>(Y in xU)?[]:[Y,["instanceof",Z]]),Array:uG,TypedArray:lG,FormData:cG});var fU=H0({domain:{domain:"number",meta:"a number representing a Unix timestamp"},divisor:{rule:1,meta:"an integer representing a Unix timestamp"},min:{rule:-8640000000000000,meta:"a Unix timestamp after -8640000000000000"},max:{rule:8640000000000000,meta:"a Unix timestamp before 8640000000000000"},meta:"an integer representing a safe Unix timestamp"}),hU=H0({domain:"number",divisor:1}),F6=e.module({root:d.number,integer:hU,epoch:fU,safe:H0({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"});var N0=(Y,Z,X)=>{let _={domain:"string",pattern:{rule:Y.source,flags:Y.flags,meta:Z}};if(X)_.meta={format:X};return U4("intersection",_)},iG=N0(b4,"a well-formed integer string"),$9=e.module({root:iG,parse:H0({in:iG,morphs:(Y,Z)=>{let X=Number.parseInt(Y);return Number.isSafeInteger(X)?X:Z.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:d.integer})},{name:"string.integer"}),kU=N0(/^[\dA-Fa-f]+$/,"hex characters only"),bU=e.module({root:N0(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:N0(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),rG=N0(/^[A-Z].*$/,"capitalized"),yU=e.module({root:H0({in:"string",morphs:(Y)=>Y.charAt(0).toUpperCase()+Y.slice(1),declaredOut:rG}),preformatted:rG},{name:"string.capitalize"}),gU=(Y)=>{let Z=Y.replaceAll(/[ -]+/g,""),X=0,_,G,$=!1;for(let W=Z.length-1;W>=0;W--){if(_=Z.substring(W,W+1),G=Number.parseInt(_,10),$)G*=2,X+=G>=10?G%10+1:G;else X+=G;$=!$}return!!(X%10===0?Z:!1)},pU=/^(?: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}))$/,mU=H0({domain:"string",pattern:{meta:"a credit card number",rule:pU.source},predicate:{meta:"a credit card number",predicate:gU}});var uU=/^([+-]?\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)?)?)?)?$/;var dU=(Y)=>!Number.isNaN(new Date(Y).valueOf()),nG=H0({domain:"string",predicate:{meta:"a parsable date",predicate:dU}}).assertHasKind("intersection"),sG=$9.root.internal.narrow((Y,Z)=>{let X=Number.parseInt(Y),_=F6.epoch(X);if(_ instanceof z1)return Z.errors.merge(_),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),cU=e.module({root:sG,parse:H0({in:sG,morphs:(Y)=>new Date(Y),declaredOut:d.Date})},{name:"string.date.epoch"}),tG=N0(uU,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),lU=e.module({root:tG,parse:H0({in:tG,morphs:(Y)=>new Date(Y),declaredOut:d.Date})},{name:"string.date.iso"}),oU=e.module({root:nG,parse:H0({declaredIn:nG,in:"string",morphs:(Y,Z)=>{let X=new Date(Y);if(Number.isNaN(X.valueOf()))return Z.error("a parsable date");return X},declaredOut:d.Date}),iso:lU,epoch:cU},{name:"string.date"}),iU=N0(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),aG="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",w2=`(${aG}[.]){3}${aG}`,rU=new RegExp(`^${w2}$`),x0="(?:[0-9a-fA-F]{1,4})",nU=new RegExp(`^((?:${x0}:){7}(?:${x0}|:)|(?:${x0}:){6}(?:${w2}|:${x0}|:)|(?:${x0}:){5}(?::${w2}|(:${x0}){1,2}|:)|(?:${x0}:){4}(?:(:${x0}){0,1}:${w2}|(:${x0}){1,3}|:)|(?:${x0}:){3}(?:(:${x0}){0,2}:${w2}|(:${x0}){1,4}|:)|(?:${x0}:){2}(?:(:${x0}){0,3}:${w2}|(:${x0}){1,5}|:)|(?:${x0}:){1}(?:(:${x0}){0,4}:${w2}|(:${x0}){1,6}|:)|(?::((?::${x0}){0,5}:${w2}|(?::${x0}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),sU=e.module({root:["v4 | v6","@","an IP address"],v4:N0(rU,"an IPv4 address","ipv4"),v6:N0(nU,"an IPv6 address","ipv6")},{name:"string.ip"}),O4="a JSON string",W9=(Y)=>{if(!(Y instanceof SyntaxError))throw Y;return`must be ${O4} (${Y})`},tU=H0({meta:O4,domain:"string",predicate:{meta:O4,predicate:(Y,Z)=>{try{return JSON.parse(Y),!0}catch(X){return Z.reject({code:"predicate",expected:O4,problem:W9(X)})}}}}),aU=(Y,Z)=>{if(Y.length===0)return Z.error({code:"predicate",expected:O4,actual:"empty"});try{return JSON.parse(Y)}catch(X){return Z.error({code:"predicate",expected:O4,problem:W9(X)})}},eU=e.module({root:tU,parse:H0({meta:"safe JSON string parser",in:"string",morphs:aU,declaredOut:d.jsonObject})},{name:"string.json"}),eG=N0(/^[a-z]*$/,"only lowercase letters"),Yz=e.module({root:H0({in:"string",morphs:(Y)=>Y.toLowerCase(),declaredOut:eG}),preformatted:eG},{name:"string.lower"}),H9=["NFC","NFD","NFKC","NFKD"],$8=o(H9,(Y,Z)=>[Z,H0({domain:"string",predicate:(X)=>X.normalize(Z)===X,meta:`${Z}-normalized unicode`})]),E6=o(H9,(Y,Z)=>[Z,H0({in:"string",morphs:(X)=>X.normalize(Z),declaredOut:$8[Z]})]),Zz=e.module({root:E6.NFC,preformatted:$8.NFC},{name:"string.normalize.NFC"}),Xz=e.module({root:E6.NFD,preformatted:$8.NFD},{name:"string.normalize.NFD"}),_z=e.module({root:E6.NFKC,preformatted:$8.NFKC},{name:"string.normalize.NFKC"}),Gz=e.module({root:E6.NFKD,preformatted:$8.NFKD},{name:"string.normalize.NFKD"}),$z=e.module({root:"NFC",NFC:Zz,NFD:Xz,NFKC:_z,NFKD:Gz},{name:"string.normalize"}),Y9=N0(p8,"a well-formed numeric string"),Wz=e.module({root:Y9,parse:H0({in:Y9,morphs:(Y)=>Number.parseFloat(Y),declaredOut:d.number})},{name:"string.numeric"}),Z9="a regex pattern",Hz=H0({domain:"string",predicate:{meta:Z9,predicate:(Y,Z)=>{try{return new RegExp(Y),!0}catch(X){return Z.reject({code:"predicate",expected:Z9,problem:String(X)})}}},meta:{format:"regex"}}),Jz=/^(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-]+)*))?$/,Qz=N0(Jz,"a semantic version (see https://semver.org/)"),X9=N0(/^\S.*\S$|^\S?$/,"trimmed"),Uz=e.module({root:H0({in:"string",morphs:(Y)=>Y.trim(),declaredOut:X9}),preformatted:X9},{name:"string.trim"}),_9=N0(/^[A-Z]*$/,"only uppercase letters"),zz=e.module({root:H0({in:"string",morphs:(Y)=>Y.toUpperCase(),declaredOut:_9}),preformatted:_9},{name:"string.upper"}),Fz=(Y)=>{if(URL.canParse)return URL.canParse(Y);try{return new URL(Y),!0}catch{return!1}},G9=H0({domain:"string",predicate:{meta:"a URL string",predicate:Fz},meta:{format:"uri"}}),Ez=e.module({root:G9,parse:H0({declaredIn:G9,in:"string",morphs:(Y,Z)=>{try{return new URL(Y)}catch{return Z.error("a URL string")}},declaredOut:H0(URL)})},{name:"string.url"}),Oz=e.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:N0(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:N0(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:N0(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:N0(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:N0(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:N0(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:N0(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:N0(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),J9=e.module({root:d.string,alpha:N0(/^[A-Za-z]*$/,"only letters"),alphanumeric:N0(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:kU,base64:bU,capitalize:yU,creditCard:mU,date:oU,digits:N0(/^\d*$/,"only digits 0-9"),email:iU,integer:$9,ip:sU,json:eU,lower:Yz,normalize:$z,numeric:Wz,regex:Hz,semver:Qz,trim:Uz,upper:zz,url:Ez,uuid:Oz},{name:"string"});var Q9=e.module({bigint:d.bigint,boolean:d.boolean,false:d.false,never:d.never,null:d.null,number:d.number,object:d.object,string:d.string,symbol:d.symbol,true:d.true,unknown:d.unknown,undefined:d.undefined}),U9=e.module({root:d.unknown,any:d.unknown},{name:"unknown"}),Vz=e.module({root:d.jsonObject,stringify:U4("morph",{in:d.jsonObject,morphs:(Y)=>JSON.stringify(Y),declaredOut:d.string})},{name:"object.json"}),z9=e.module({root:d.object,json:Vz},{name:"object"});class F9 extends s0{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var Dz=K1(["K",d.key],"V")((Y)=>({domain:"object",index:{signature:Y.K,value:Y.V}}),F9);class E9 extends s0{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var Lz=K1(["T",d.object],["K",d.key])((Y)=>Y.T.pick(Y.K),E9);class O9 extends s0{description='omit a set of properties from an object like `Omit(User, "age")`'}var Mz=K1(["T",d.object],["K",d.key])((Y)=>Y.T.omit(Y.K),O9);class V9 extends s0{description="make all named properties of an object optional like `Partial(User)`"}var Az=K1(["T",d.object])((Y)=>Y.T.partial(),V9);class D9 extends s0{description="make all named properties of an object required like `Required(User)`"}var wz=K1(["T",d.object])((Y)=>Y.T.required(),D9);class L9 extends s0{description='exclude branches of a union like `Exclude("boolean", "true")`'}var Rz=K1("T","U")((Y)=>Y.T.exclude(Y.U),L9);class M9 extends s0{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var Nz=K1("T","U")((Y)=>Y.T.extract(Y.U),M9),A9=e.module({Exclude:Rz,Extract:Nz,Omit:Mz,Partial:Az,Pick:Lz,Record:Dz,Required:wz});var R2=CZ({...Q9,...A9,...oG,...pG,string:J9,number:F6,object:z9,unknown:U9},{prereducedAliases:!0,name:"ark"}),p0=R2.export();Object.assign(E4.ambient,p0);E4.typeAttachments={string:p0.string.root,number:p0.number.root,bigint:p0.bigint,boolean:p0.boolean,symbol:p0.symbol,undefined:p0.undefined,null:p0.null,object:p0.object.root,unknown:p0.unknown.root,false:p0.false,true:p0.true,never:p0.never,arrayIndex:p0.Array.index,Key:p0.Key,Record:p0.Record,Array:p0.Array.root,Date:p0.Date};var O1=Object.assign(R2.type,E4.typeAttachments),Iz=R2.match,Tz=R2.generic,$T=R2.schema,Kz=R2.define,Bz=R2.declare;var a0=(Y)=>JSON.parse(Y),Q0=(Y)=>JSON.stringify(Y),RT=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function V4(Y){return L6(o0.STORE,Y,void 0)}function W8(Y){return M4(o0.STORE,Y)}function SZ(...Y){if(Y.length===2)return l1(o0.STORE,...Y);return l1(o0.STORE,...Y)}function O6(Y,Z){return q9(o0.STORE,Y,Z)}function w9(Y){return S9(Y,o0.STORE)}var G2={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]"};var jZ=(Y)=>(Z,X,_,G,...$)=>{console[Y](`${Z} ${G2[X]} \`${_}\` ${G}`,...$)},Cz={error:jZ("error"),info:jZ("info"),warn:jZ("warn")},R9=class{logLevel;filter;logger;constructor(Y,Z,X=Cz){this.logLevel=Y,this.filter=Z,this.logger=X}error=(...Y)=>{if(this.logLevel!==null){let Z=this.filter?.(...Y)??!0;if(Z===!0)this.logger.error(...Y);else if(Z)this.logger.error(...Z)}};info=(...Y)=>{if(this.logLevel==="info"){let Z=this.filter?.(...Y)??!0;if(Z===!0)this.logger.info(...Y);else if(Z)this.logger.info(...Z)}};warn=(...Y)=>{if(this.logLevel!=="error"&&this.logLevel!==null){let Z=this.filter?.(...Y)??!0;if(Z===!0)this.logger.warn(...Y);else if(Z)this.logger.warn(...Z)}}};var qz=class{store;constructor(Y=o0.STORE){this.store=Y,T9("root",Y)}allocate(Y,Z,X){return D4(this.store,Y,Z,X)}fuse(Y,Z,X){return K9(this.store,Y,Z,X)}deallocate(Y){L4(this.store,Y)}claim(Y,Z,X){return J8(this.store,Y,Z,X)}},N9=class{store;realm;constructor(Y=o0.STORE){this.store=Y,this.realm=new qz(Y)}allocate(Y,Z,X){D4(this.store,Y,Z,X)}deallocate(Y){L4(this.store,Y)}claim(Y,Z,X){J8(this.store,Y,Z,X)}};function V6(Y){return xZ(o0.STORE,Y)}function H8(Y){return vZ(o0.STORE,Y)}var $2=class Y extends Set{mode="record";subject=new W0;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(Z,X=0){super(Z);if(Z instanceof Y)this.parent=Z,this.cacheUpdateNumber=Z.cacheUpdateNumber;if(X)this.cacheLimit=X,this.cache=new Array(X),this.subscribe("auto cache",(_)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=_})}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(Z){let X=new Y(Z.members,Z.cacheLimit);return X.cache=Z.cache,X.cacheIdx=Z.cacheIdx,X.cacheUpdateNumber=Z.cacheUpdateNumber,X}add(Z){let X=super.add(Z);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${Q0(Z)}`);return X}clear(){let Z=this.mode==="record"?[...this]:null;if(super.clear(),Z)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(Z)}`)}delete(Z){let X=super.delete(Z);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${Q0(Z)}`);return X}parent=null;child=null;transactionUpdates=null;transaction(Z){this.mode="transaction",this.transactionUpdates=[],this.child=new Y(this);let X=this.child._subscribe("transaction",(_)=>{this.transactionUpdates?.push(_)});try{if(Z(this.child)){for(let G of this.transactionUpdates)this.doStep(G);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(_){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",_),_}finally{X(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(Z,X){return this.subject.subscribe(Z,X)}subscribe(Z,X){return this.subject.subscribe(Z,(_)=>{X(`${this.cacheUpdateNumber}=${_}`)})}emit(Z){this.subject.next(Z)}doStep(Z){let X=Z.indexOf(":"),_=Z.substring(0,X),G=Z.substring(X+1);switch(_){case"add":this.add(JSON.parse(G));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(G));break;case"tx":for(let $ of G.split(";"))this.doStep($)}}getUpdateNumber(Z){let X=Z.indexOf("=");return Number(Z.substring(0,X))}do(Z){let X=Z.indexOf("="),_=Number(Z.substring(0,X)),G=_-this.cacheUpdateNumber;if(G>0){if(G===1){this.mode="playback";let W=Z.substring(X+1);return this.doStep(W),this.mode="record",this.cacheUpdateNumber=_,null}return this.cacheUpdateNumber+1}if(Math.abs(G)<this.cacheLimit){let W=this.cacheIdx+G;if(this.cache[W]===Z)return null;this.mode="playback";let Q=!1;while(!Q){this.cacheIdx%=this.cacheLimit;let U=this.cache[this.cacheIdx];if(this.cacheIdx--,!U)return"OUT_OF_RANGE";this.undo(U),Q=this.cacheIdx===W-1}let J=Z.substring(X+1);return this.doStep(J),this.mode="record",this.cacheUpdateNumber=_,null}return"OUT_OF_RANGE"}undoStep(Z){let X=Z.indexOf(":"),_=Z.substring(0,X),G=Z.substring(X+1);switch(_){case"add":this.delete(JSON.parse(G));break;case"del":this.add(JSON.parse(G));break;case"clear":{let $=JSON.parse(G);for(let W of $)this.add(W);break}case"tx":{let $=G.split(";");for(let W=$.length-1;W>=0;W--)this.undoStep($[W])}}}undo(Z){let X=Z.indexOf("=");if(Number(Z.substring(0,X))===this.cacheUpdateNumber){this.mode="playback";let G=Z.substring(X+1);return this.undoStep(G),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function I9(Y=Math.random){return Y().toString(36).slice(2)}function Y0(Y){while(Y.child!==null)Y=Y.child;return Y}var Sz=class Y{_buffer;_index=0;constructor(Z){let X;if(typeof Z==="number")X=Z;else X=Z.length;this._buffer=Array.from({length:X})}get buffer(){return this._buffer}get index(){return this._index}add(Z){this._buffer[this._index]=Z,this._index=(this._index+1)%this._buffer.length}copy(){let Z=new Y([...this._buffer]);return Z._index=this._index,Z}};function k1(Y){let Z={key:Y.key,type:Y.type};if("family"in Y)Z.family=Y.family;return Z}var Pz=Symbol("counterfeit"),vz={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"};function P9(Y,Z,X){let _=Q0(Z),G=`${Y.key}(${_})`,$=vz[Y.type],W={key:G,type:$,family:{key:Y.key,subKey:_}};if(X)W.counterfeit=!0;return W}var G1=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(Y,Z)=>`${Y}:${Z}`;warn;getRelatedKeys(Y){return this.relations.get(Y)}addRelation(Y,Z){let X=this.relations.get(Y),_=this.relations.get(Z);if(X)X.add(Z);else X=new Set([Z]),this.relations.set(Y,X);if(_)_.add(Y);else _=new Set([Y]),this.relations.set(Z,_)}deleteRelation(Y,Z){let X=this.relations.get(Y);if(X){if(X.delete(Z),X.size===0)this.relations.delete(Y);let _=this.relations.get(Z);if(_){if(_.delete(Y),_.size===0)this.relations.delete(Z)}}}replaceRelationsUnsafely(Y,Z){this.relations.set(Y,new Set(Z));for(let X of Z){let _=new Set().add(Y);this.relations.set(X,_)}}replaceRelationsSafely(Y,Z){let X=this.relations.get(Y),_=this.isAType?.(Y)?Y:void 0,G=_===void 0?Y:void 0;if(X)for(let $ of X){_??=$,G??=$;let W=this.relations.get($);if(W){if(W.size===1)this.relations.delete($);else W.delete(Y);this.contents.delete(this.makeContentKey(_,G))}}this.relations.set(Y,new Set(Z));for(let $ of Z){let W=this.relations.get($);if(W)W.add(Y);else W=new Set().add(Y),this.relations.set($,W)}}getContentInternal(Y){return this.contents.get(Y)}setContent(Y,Z){this.contents.set(Y,Z)}deleteContent(Y){this.contents.delete(Y)}constructor(Y,Z){if(this.a=Y.between[0],this.b=Y.between[1],this.cardinality=Y.cardinality,!Z?.externalStore)this.relations=new Map(Y.relations?.map(([X,_])=>[X,new Set(_)])),this.contents=new Map(Y.contents);if(this.isAType=Z?.isAType??null,this.isBType=Z?.isBType??null,this.isContent=Z?.isContent??null,Z?.makeContentKey)this.makeContentKey=Z.makeContentKey;if(Z?.externalStore){let X=Z.externalStore;if(this.has=(_,G)=>X.has(_,G),this.addRelation=(_,G)=>{X.addRelation(_,G)},this.deleteRelation=(_,G)=>{X.deleteRelation(_,G)},this.replaceRelationsSafely=(_,G)=>{X.replaceRelationsSafely(_,G)},this.replaceRelationsUnsafely=(_,G)=>{X.replaceRelationsUnsafely(_,G)},this.getRelatedKeys=(_)=>X.getRelatedKeys(_),X.getContent)this.getContentInternal=(_)=>{return X.getContent(_)},this.setContent=(_,G)=>{X.setContent(_,G)},this.deleteContent=(_)=>{X.deleteContent(_)};for(let[_,G]of Y.relations??[]){let $=this.isAType?.(_)?_:void 0,W=$===void 0?_:void 0;for(let H of G)$??=H,W??=H,this.addRelation($,W)}for(let[_,G]of Y.contents??[])this.setContent(_,G)}if(Z?.warn)this.warn=Z.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([Y,Z])=>[Y,[...Z]]),contents:[...this.contents.entries()]}}set(...Y){let Z,X,_;switch(Y.length){case 1:{let G=Y[0];Z=G[this.a],X=G[this.b],_=void 0;break}case 2:{let G=Y[0];if(typeof G==="string")[Z,X]=Y;else Z=G[this.a],X=G[this.b],_=Y[1];break}default:Z=Y[0],X=Y[1],_=Y[2];break}switch(this.cardinality){case"1:1":{let G=this.getRelatedKey(Z);if(G&&G!==X)this.delete(Z,G)}case"1:n":{let G=this.getRelatedKey(X);if(G&&G!==Z)this.delete(G,X)}break;case"n:n":}if(_){let G=this.makeContentKey(Z,X);this.setContent(G,_)}return this.addRelation(Z,X),this}delete(Y,Z){Z=typeof Z==="string"?Z:Y[this.b];let X=typeof Y==="string"?Y:Y[this.a];if(X===void 0&&typeof Z==="string"){let _=this.getRelatedKeys(Z);if(_)for(let G of _)this.delete(G,Z)}if(typeof X==="string"&&Z===void 0){let _=this.getRelatedKeys(X);if(_)for(let G of _)this.delete(X,G)}if(typeof X==="string"&&typeof Z==="string"){this.deleteRelation(X,Z);let _=this.makeContentKey(X,Z);this.deleteContent(_)}return this}getRelatedKey(Y){let Z=this.getRelatedKeys(Y);if(Z){if(Z.size>1)this.warn?.(`${Z.size} related keys were found for key "${Y}": (${[...Z].map((_)=>`"${_}"`).join(", ")}). Only one related key was expected.`);let X;for(let _ of Z){X=_;break}return X}}replaceRelations(Y,Z,X){let _=!Array.isArray(Z),G=_?Object.keys(Z):Z;if(X?.reckless)this.replaceRelationsUnsafely(Y,G);else this.replaceRelationsSafely(Y,G);if(_)for(let $ of G){let W=this.makeContentKey(Y,$),H=Z[$];this.setContent(W,H)}return this}getContent(Y,Z){let X=this.makeContentKey(Y,Z);return this.getContentInternal(X)}getRelationEntries(Y){let Z=Y[this.a],X=Y[this.b];if(Z!==void 0&&X===void 0){let _=this.getRelatedKeys(Z);if(_)return[..._].map((G)=>{return[G,this.getContent(Z,G)]})}if(Z===void 0&&X!==void 0){let _=this.getRelatedKeys(X);if(_)return[..._].map((G)=>{return[G,this.getContent(G,X)]})}return[]}has(Y,Z){if(Z)return this.getRelatedKeys(Y)?.has(Z)??!1;return this.relations.has(Y)}},W0=class{Subscriber;subscribers=new Map;subscribe(Y,Z){return this.subscribers.set(Y,Z),()=>{this.unsubscribe(Y)}}unsubscribe(Y){this.subscribers.delete(Y)}next(Y){let Z=this.subscribers.values();for(let X of Z)X(Y)}},xz=class extends W0{state;constructor(Y){super();this.state=Y}next(Y){this.state=Y,super.next(Y)}},fz=(Y,Z)=>{let X=Y0(Y);if(X.operation.open)return X.operation.prev.get(Z.key);return X.valueMap.get(Z.key)};function k9(Y,Z,X,_){let G=Y.disposalTraces.buffer.find(($)=>$?.key===Q0(_));switch(Y.logger.error("\u274C",Z.type,Z.key,"gets a fallback value because key",_,"is not allocated",G?`This key was previously disposed:
|
|
47
|
+
`)+"}");class Z6{config;resolvedConfig;name;get[X1](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(Y,Z){if(this.config=d4(N.config,Z),this.resolvedConfig=d4(N.resolvedConfig,Z),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys($Z).length}`,this.name in $Z)R(`A Scope already named ${this.name} already exists`);$Z[this.name]=this;let X=Object.entries(Y).map((_)=>this.preparseOwnAliasEntry(..._));for(let[_,G]of X){let $=_;if(_[0]==="#"){if($=_.slice(1),$ in this.aliases)R(l_($));this.aliases[$]=G}else{if($ in this.aliases)R(l_(_));this.aliases[$]=G,this.exportedNames.push($)}if(!y(G,"module")&&!y(G,"generic")&&!O2(G)){let W=this.preparseOwnDefinitionFormat(G,{alias:$});this.resolutions[$]=y(W,"root")?this.bindReference(W):this.createParseContext(W).id}}o_??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[o_.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=N.intrinsic?o(N.intrinsic,(_,G)=>_.startsWith("json")?[]:[_,this.bindReference(G)]):{}}cacheGetter(Y,Z){return Object.defineProperty(this,Y,{value:Z}),Z}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema(Y){return Y}generic=(...Y)=>{let Z=this;return(X,_)=>new A2(Y,_?new i8(X):X,Z,Z,_??null)};units=(Y,Z)=>{let X=[];for(let G of Y)if(!X.includes(G))X.push(G);let _=X.map((G)=>this.node("unit",{unit:G},Z));return this.node("union",_,{...Z,prereduced:!0})};lazyResolutions=[];lazilyResolve(Y,Z){let X=this.node("alias",{reference:Z??"synthetic",resolve:Y},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(X);return X}schema=(Y,Z)=>this.finalize(this.parseSchema(Y,Z));parseSchema=(Y,Z)=>this.node(i4(Y),Y,Z);preparseNode(Y,Z,X){let _=typeof Y==="string"?Y:i4(Z,Y);if(D0(Z)&&Z.kind===_)return Z;if(_==="alias"&&!X?.prereduced){let{reference:W}=e4.implementation.normalize(Z,this);if(W.startsWith("$")){let H=this.resolveRoot(W.slice(1));Z=H,_=H.kind}}else if(_==="union"&&Q1(Z,"object")){let W=kQ(Z);if(W?.length===1)Z=W[0],_=i4(Z)}if(D0(Z)&&Z.kind===_)return Z;let $=W4[_].normalize?.(Z,this)??Z;if(D0($))return $.kind===_?$:bQ(_,$.kind);return{...X,$:this,kind:_,def:$,prefix:X.alias??_}}bindReference(Y){let Z;if(D0(Y))Z=Y.$===this?Y:new Y.constructor(Y.attachments,this);else Z=Y.$===this?Y:new A2(Y.params,Y.bodyDef,Y.$,this,Y.hkt);if(!this.resolved)Object.assign(this.referencesById,Z.referencesById);return Z}resolveRoot(Y){return this.maybeResolveRoot(Y)??R(JZ(Y))}maybeResolveRoot(Y){let Z=this.maybeResolve(Y);if(y(Z,"generic"))return;return Z}maybeResolveSubalias(Y){return WZ(this.aliases,Y)??WZ(this.ambient,Y)}get ambient(){return N.ambient}maybeResolve(Y){let Z=this.resolutions[Y];if(Z){if(typeof Z!=="string")return this.bindReference(Z);let _=_1[Z];if(y(_,"root"))return this.resolutions[Y]=_;if(y(_,"context")){if(_.phase==="resolving")return this.node("alias",{reference:`$${Y}`},{prereduced:!0});if(_.phase==="resolved")return _0(`Unexpected resolved context for was uncached by its scope: ${i(_)}`);_.phase="resolving";let G=this.bindReference(this.parseOwnDefinitionFormat(_.def,_));return _.phase="resolved",_1[G.id]=G,_1[_.id]=G,this.resolutions[Y]=G}return _0(`Unexpected nodesById entry for ${Z}: ${i(_)}`)}let X=this.aliases[Y]??this.ambient?.[Y];if(!X)return this.maybeResolveSubalias(Y);if(X=this.normalizeRootScopeValue(X),y(X,"generic"))return this.resolutions[Y]=this.bindReference(X);if(y(X,"module")){if(!X.root)R(e_(Y));return this.resolutions[Y]=this.bindReference(X.root)}return this.resolutions[Y]=this.parse(X,{alias:Y})}createParseContext(Y){let Z=Y.id??uY(Y.prefix);return _1[Z]=Object.assign(Y,{[X1]:"context",$:this,id:Z,phase:"unresolved"})}traversal(Y){return new f1(Y,this.resolvedConfig)}import(...Y){return new Q4(o(this.export(...Y),(Z,X)=>[`#${Z}`,X]))}precompilation;_exportedResolutions;_exports;export(...Y){if(!this._exports){this._exports={};for(let X of this.exportedNames){let _=this.aliases[X];this._exports[X]=y(_,"module")?GZ(_,this):i_(this.maybeResolve(X))}for(let X of this.lazyResolutions)X.resolution;if(this._exportedResolutions=a_(this,this._exports),this._json=t_(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let X=s_(this.references);this.precompilation=X.write(r_,4),n_(this.references,X)}this.resolved=!0}let Z=Y.length?Y:this.exportedNames;return new Q4(o(Z,(X,_)=>[_,this._exports[_]]))}resolve(Y){return this.export()[Y]}node=(Y,Z,X={})=>{let _=this.preparseNode(Y,Z,X);if(D0(_))return this.bindReference(_);let G=this.createParseContext(_),$=dY(G),W=this.bindReference($);return _1[G.id]=W};parse=(Y,Z={})=>this.finalize(this.parseDefinition(Y,Z));parseDefinition(Y,Z={}){if(y(Y,"root"))return this.bindReference(Y);let X=this.preparseOwnDefinitionFormat(Y,Z);if(y(X,"root"))return this.bindReference(X);let _=this.createParseContext(X);_1[_.id]=_;let G=this.bindReference(this.parseOwnDefinitionFormat(Y,_));if(G.isCyclic)G=A_(G,_.id);return _1[_.id]=G,G}finalize(Y){if(i_(Y),!Y.precompilation&&!this.resolvedConfig.jitless)yQ(Y.references);return Y}}class HZ extends Z6{parseOwnDefinitionFormat(Y,Z){return dY(Z)}preparseOwnDefinitionFormat(Y,Z){return this.preparseNode(i4(Y),Y,Z)}preparseOwnAliasEntry(Y,Z){return[Y,Z]}normalizeRootScopeValue(Y){return Y}}var i_=(Y)=>{let Z=Y.references.filter((X)=>X.hasKind("alias"));for(let X of Z){Object.assign(X.referencesById,X.resolution.referencesById);for(let _ of Y.references)if(X.id in _.referencesById)Object.assign(_.referencesById,X.referencesById)}return Y},t_=(Y)=>o(Y,(Z,X)=>[Z,y(X,"root")||y(X,"generic")?X.json:y(X,"module")?t_(X):_0(`Unexpected resolution ${i(X)}`)]),WZ=(Y,Z)=>{let X=Z.indexOf(".");if(X===-1)return;let _=Z.slice(0,X),G=Y[_];if(G===void 0)return;if(!y(G,"module"))return R(gQ(_));let $=Z.slice(X+1),W=G[$];if(W===void 0)return WZ(G,$);if(y(W,"root")||y(W,"generic"))return W;if(y(W,"module"))return W.root??R(e_(Z));_0(`Unexpected resolution for alias '${Z}': ${i(W)}`)},X6=(Y,Z)=>new HZ(Y,Z),X8=new HZ({});var a_=(Y,Z)=>{let X={};for(let _ in Z){let G=Z[_];if(y(G,"module")){let $=a_(Y,G),W=o($,(H,Q)=>[`${_}.${H}`,Q]);Object.assign(X,W)}else if(y(G,"root")||y(G,"generic"))X[_]=G;else _0(`Unexpected scope resolution ${i(G)}`)}return X},JZ=(Y)=>`'${Y}' is unresolvable`,gQ=(Y)=>`'${Y}' must reference a module to be accessed using dot syntax`,e_=(Y)=>`Reference to submodule '${Y}' must specify an alias`;X8.export();var{schema:H0,node:U4,defineSchema:fw,generic:K1}=X8;var QZ="^(?:0|[1-9]\\d*)$",pQ=new RegExp(QZ),bw=B0(pQ);var YG=X6({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();N.intrinsic={...YG};var ZG=X6({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:QZ}},{prereducedAliases:!0}).export();Object.assign(N.intrinsic,ZG);var mQ=X6({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),d={...YG,...ZG,...mQ,emptyStructure:U4("structure",{},{prereduced:!0})};N.intrinsic={...d};var _G=(Y)=>typeof Y==="string"&&Y[0]==="d"&&(Y[1]==="'"||Y[1]==='"')&&Y.at(-1)===Y[1],XG=(Y)=>Y.toString()!=="Invalid Date",GG=(Y)=>Y.slice(2,-1),UZ=(Y)=>`'${Y}' could not be parsed by the Date constructor`,$G=(Y,Z)=>uQ(Y,Z),uQ=(Y,Z)=>{let X=new Date(Y);if(XG(X))return X;let _=bX(Y);if(_!==void 0){let G=new Date(_);if(XG(G))return G}return Z?R(Z===!0?UZ(Y):Z):void 0};var zZ=(Y,Z)=>{let X=Y.scanner.shiftUntil(dQ[HG[Z]]);if(Y.scanner.lookahead==="")return Y.error(lQ(X,Z));if(Y.scanner.shift(),Z==="/"){try{new RegExp(X)}catch(_){R(String(_))}Y.root=Y.ctx.$.node("intersection",{domain:"string",pattern:X},{prereduced:!0})}else if(g0(Z,FZ))Y.root=Y.ctx.$.node("unit",{unit:X});else{let _=$G(X,UZ(X));Y.root=Y.ctx.$.node("unit",{meta:X,unit:_})}},FZ={"'":1,'"':1},WG={"/":1,"'":1,'"':1},HG={"d'":"'",'d"':'"',"'":"'",'"':'"',"/":"/"},dQ={"'":(Y)=>Y.lookahead==="'",'"':(Y)=>Y.lookahead==='"',"/":(Y)=>Y.lookahead==="/"},cQ={'"':"double-quote","'":"single-quote","/":"forward slash"},lQ=(Y,Z)=>`${Z}${Y} requires a closing ${cQ[HG[Z]]}`;var JG=(Y)=>`Private type references should not include '#'. Use '${Y}' instead.`,_6="Optional definitions like 'string?' are only valid as properties in an object or tuple",G6="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var QG={">":!0,">=":!0},UG={"<":!0,"<=":!0};var z4={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},zG=(Y)=>`Unmatched )${Y===""?"":` before ${Y}`}`,$6=(Y)=>`Missing ${Y}`,FG=(Y,Z)=>`Left bounds are only valid when paired with right bounds (try ...${Z}${Y})`,W6=(Y)=>`Left-bounded expressions must specify their limits using < or <= (was ${Y})`,EG=(Y,Z,X,_)=>`An expression may have at most one left bound (parsed ${Y}${z4[Z]}, ${X}${z4[_]})`;var OG=(Y,Z,X)=>VG(Y,Z,X,[]),VG=(Y,Z,X,_)=>{let G=X.parseUntilFinalizer();if(_.push(G.root),G.finalizer===">"){if(_.length!==Z.params.length)return X.error(EZ(Y,Z.names,_.map(($)=>$.expression)));return _}if(G.finalizer===",")return VG(Y,Z,X,_);return G.error($6(">"))},EZ=(Y,Z,X)=>`${Y}<${Z.join(", ")}> requires exactly ${Z.length} args (got ${X.length}${X.length===0?"":`: ${X.join(", ")}`})`;var OZ=(Y)=>{let Z=Y.scanner.shiftUntilNextTerminator();if(Z==="keyof")Y.addPrefix("keyof");else Y.root=iQ(Y,Z)},oQ=(Y,Z,X)=>{if(X.scanner.shiftUntilNonWhitespace(),X.scanner.shift()!=="<")return X.error(EZ(Y,Z.names,[]));let G=OG(Y,Z,X);return Z(...G)},iQ=(Y,Z)=>rQ(Y,Z)??nQ(Y,Z)??Y.error(Z===""?Y.scanner.lookahead==="#"?JG(Y.shiftedByOne().scanner.shiftUntilNextTerminator()):VZ(Y):JZ(Z)),rQ=(Y,Z)=>{if(Y.ctx.args?.[Z]){let _=Y.ctx.args[Z];if(typeof _!=="string")return _;return Y.ctx.$.node("alias",{reference:_},{prereduced:!0})}let X=Y.ctx.$.maybeResolve(Z);if(y(X,"root"))return X;if(X===void 0)return;if(y(X,"generic"))return oQ(Z,X,Y);return R(`Unexpected resolution ${i(X)}`)},nQ=(Y,Z)=>{let X=yX(Z);if(X!==void 0)return Y.ctx.$.node("unit",{unit:X});let _=pX(Z);if(_!==void 0)return Y.ctx.$.node("unit",{unit:_})},VZ=(Y)=>{let Z=Y.previousOperator();return Z?DZ(Z,Y.scanner.unscanned):sQ(Y.scanner.unscanned)},DZ=(Y,Z="")=>`Token '${Y}' requires a right operand${Z?` before '${Z}'`:""}`,sQ=(Y)=>`Expected an expression${Y?` before '${Y}'`:""}`;var LZ=(Y)=>Y.scanner.lookahead===""?Y.error(VZ(Y)):Y.scanner.lookahead==="("?Y.shiftedByOne().reduceGroupOpen():Y.scanner.lookaheadIsIn(WG)?zZ(Y,Y.scanner.shift()):Y.scanner.lookaheadIsIn(V2)?LZ(Y.shiftedByOne()):Y.scanner.lookahead==="d"?Y.scanner.nextLookahead in FZ?zZ(Y,`${Y.scanner.shift()}${Y.scanner.shift()}`):OZ(Y):OZ(Y);class _2 extends NY{shiftUntilNextTerminator(){return this.shiftUntilNonWhitespace(),this.shiftUntil(()=>(this.lookahead in _2.terminatingChars))}static terminatingChars={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...V2};static finalizingLookaheads={">":1,",":1,"":1,"=":1,"?":1};static lookaheadIsFinalizing=(Y,Z)=>Y===">"?Z[0]==="="?Z[1]==="=":Z.trimStart()===""||g0(Z.trimStart()[0],_2.terminatingChars):Y==="="?Z[0]!=="=":Y===","||Y==="?"}var LG=(Y,Z)=>{let X=tQ(Y,Z);if(Y.root.hasKind("unit")){if(typeof Y.root.unit==="number"){Y.reduceLeftBound(Y.root.unit,X),Y.unsetRoot();return}if(Y.root.unit instanceof Date){let _=`d'${Y.root.description??Y.root.unit.toISOString()}'`;Y.unsetRoot(),Y.reduceLeftBound(_,X);return}}return eQ(Y,X)},MG={"<":1,">":1,"=":1},tQ=(Y,Z)=>Y.scanner.lookaheadIs("=")?`${Z}${Y.scanner.shift()}`:Z;var DG=(Y,Z,X,_)=>{if(X.extends(N.intrinsic.number)){if(typeof Z!=="number")return R(MZ(Y,Z,_));return Y==="=="?["min","max"]:Y[0]===">"?["min"]:["max"]}if(X.extends(N.intrinsic.lengthBoundable)){if(typeof Z!=="number")return R(MZ(Y,Z,_));return Y==="=="?["exactLength"]:Y[0]===">"?["minLength"]:["maxLength"]}if(X.extends(N.intrinsic.Date))return Y==="=="?["after","before"]:Y[0]===">"?["after"]:["before"];return R(W_(X.expression))},aQ=(Y)=>({rule:_G(Y.limit)?GG(Y.limit):Y.limit,exclusive:Y.comparator.length===1}),eQ=(Y,Z)=>{let X=Y.unsetRoot(),_=Y.scanner.location;Y.parseOperand();let G=Y.unsetRoot(),$=Y.scanner.sliceChars(_,Y.scanner.location);if(Y.root=X,!G.hasKind("unit")||typeof G.unit!=="number"&&!(G.unit instanceof Date))return Y.error(MZ(Z,$,"right"));let W=G.unit,H=Z.length===1,Q=DG(Z,typeof W==="number"?W:$,X,"right");for(let U of Q)Y.constrainRoot(U,Z==="=="?{rule:W}:{rule:W,exclusive:H});if(!Y.branches.leftBound)return;if(!g0(Z,UG))return Y.error(W6(Z));let J=DG(Y.branches.leftBound.comparator,Y.branches.leftBound.limit,X,"left");Y.constrainRoot(J[0],aQ(Y.branches.leftBound)),Y.branches.leftBound=null},MZ=(Y,Z,X)=>`Comparator ${X==="left"?z4[Y]:Y} must be ${X==="left"?"preceded":"followed"} by a corresponding literal (was ${Z})`;var AG=(Y)=>{Y.scanner.shiftUntilNonWhitespace();let Z=Y.scanner.shiftUntilNextTerminator();Y.root=Y.root.brand(Z)};var RG=(Y)=>{let Z=Y.scanner.shiftUntilNextTerminator(),X=gX(Z,{errorOnFail:wG(Z)});if(X===0)Y.error(wG(0));Y.root=Y.root.constrain("divisor",X)},wG=(Y)=>`% operator must be followed by a non-zero integer literal (was ${Y})`;var AZ=(Y)=>{let Z=Y.scanner.shift();return Z===""?Y.finalize(""):Z==="["?Y.scanner.shift()==="]"?Y.setRoot(Y.root.array()):Y.error(YU):Z==="|"?Y.scanner.lookahead===">"?Y.shiftedByOne().pushRootToBranch("|>"):Y.pushRootToBranch(Z):Z==="&"?Y.pushRootToBranch(Z):Z===")"?Y.finalizeGroup():_2.lookaheadIsFinalizing(Z,Y.scanner.unscanned)?Y.finalize(Z):g0(Z,MG)?LG(Y,Z):Z==="%"?RG(Y):Z==="#"?AG(Y):(Z in V2)?AZ(Y):Y.error(H6(Z))},H6=(Y,Z="")=>`'${Y}' is not allowed here${Z&&` (should be ${Z})`}`,YU="Missing expected ']'";var NG=(Y)=>{let Z=Y.unsetRoot();Y.parseOperand();let X=Y.unsetRoot();if(!X.hasKind("unit"))return Y.error(ZU(X.expression));let _=X.unit instanceof Date?()=>new Date(X.unit):X.unit;return[Z,"=",_]},ZU=(Y)=>`Default value '${Y}' must a literal value`;var wZ=(Y,Z)=>{let X=Z.$.maybeResolveRoot(Y);if(X)return X;if(Y.endsWith("[]")){let $=Z.$.maybeResolveRoot(Y.slice(0,-2));if($)return $.array()}let _=new F4(new _2(Y),Z),G=XU(_);if(_.finalizer===">")R(H6(">"));return G},XU=(Y)=>{Y.parseOperand();let Z=_8(Y).root;if(!Z)return _0(`Root was unexpectedly unset after parsing string '${Y.scanner.scanned}'`);if(Y.finalizer==="=")Z=NG(Y);else if(Y.finalizer==="?")Z=[Z,"?"];if(Y.scanner.shiftUntilNonWhitespace(),Y.scanner.lookahead)R(H6(Y.scanner.lookahead));return Z},_8=(Y)=>{while(Y.finalizer===void 0)_U(Y);return Y},_U=(Y)=>Y.hasRoot()?Y.parseOperator():Y.parseOperand();class F4{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor(Y,Z){this.scanner=Y,this.ctx=Z}error(Y){return R(Y)}hasRoot(){return this.root!==void 0}setRoot(Y){this.root=Y}unsetRoot(){let Y=this.root;return this.root=void 0,Y}constrainRoot(...Y){this.root=this.root.constrain(Y[0],Y[1])}finalize(Y){if(this.groups.length)return this.error($6(")"));this.finalizeBranches(),this.finalizer=Y}reduceLeftBound(Y,Z){let X=z4[Z];if(!g0(X,QG))return this.error(W6(Z));if(this.branches.leftBound)return this.error(EG(this.branches.leftBound.limit,this.branches.leftBound.comparator,Y,X));this.branches.leftBound={comparator:X,limit:Y}}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();let Y=this.groups.pop();if(!Y)return this.error(zG(this.scanner.unscanned));this.branches=Y}addPrefix(Y){this.branches.prefixes.push(Y)}applyPrefixes(){while(this.branches.prefixes.length){let Y=this.branches.prefixes.pop();this.root=Y==="keyof"?this.root.keyof():_0(`Unexpected prefix '${Y}'`)}}pushRootToBranch(Y){this.assertRangeUnset(),this.applyPrefixes();let Z=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(Z)??Z,Y==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,Y==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return _8(new F4(this.scanner,this.ctx))}parseOperator(){return AZ(this)}parseOperand(){return LZ(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(FG(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.at(-1)??(this.branches.intersection?"&":this.branches.union?"|":this.branches.pipe?"|>":void 0)}shiftedByOne(){return this.scanner.shift(),this}}var GU="An empty string is not a valid generic parameter name",J6=(Y,Z,X)=>{Y.shiftUntilNonWhitespace();let _=Y.shiftUntilNextTerminator();if(_===""){if(Y.lookahead===""&&Z.length)return Z;return R(GU)}return Y.shiftUntilNonWhitespace(),$U(Y,_,Z,X)},IG="extends ",$U=(Y,Z,X,_)=>{if(Y.shiftUntilNonWhitespace(),Y.unscanned.startsWith(IG))Y.jumpForward(IG.length);else{if(Y.lookahead===",")Y.shift();return X.push(Z),J6(Y,X,_)}let G=_8(new F4(Y,_));return X.push([Z,G.root]),J6(Y,X,_)};class RZ extends x1{$;constructor(Y){super((...Z)=>new G8(Y)(...Z),{bind:Y});this.$=Y}in(Y){return new G8(this.$,Y===void 0?void 0:this.$.parse(Y))}at(Y,Z){return new G8(this.$).at(Y,Z)}case(Y,Z){return new G8(this.$).case(Y,Z)}}class G8 extends x1{$;in;key;branches=[];constructor(Y,Z){super((X)=>this.caseEntries(Object.entries(X).map(([_,G])=>_==="default"?[_,G]:[this.$.parse(_),G])));this.$=Y,this.in=Z}at(Y,Z){if(this.key)R(HU);if(this.branches.length)R(WU);return this.key=Y,Z?this.match(Z):this}case(Y,Z){return this.caseEntry(this.$.parse(Y),Z)}caseEntry(Y,Z){let _=(this.key?this.$.parse({[this.key]:Y}):Y).pipe(Z);return this.branches.push(_),this}match(Y){return this(Y)}strings(Y){return this.caseEntries(Object.entries(Y).map(([Z,X])=>Z==="default"?[Z,X]:[this.$.node("unit",{unit:Z}),X]))}caseEntries(Y){for(let Z=0;Z<Y.length;Z++){let[X,_]=Y[Z];if(X==="default"){if(Z!==Y.length-1)R("default may only be specified as the last key of a switch definition");return this.default(_)}if(typeof _!=="function")return R(`Value for case "${X}" must be a function (was ${y0(_)})`);this.caseEntry(X,_)}return this}default(Y){if(typeof Y==="function")this.case(d.unknown,Y);let Z={branches:this.branches,ordered:!0};if(Y==="never"||Y==="assert")Z.meta={onFail:TG};let X=this.$.node("union",Z);if(!this.in)return this.$.finalize(X);let _=this.in.pipe(X);if(Y==="never"||Y==="assert")_=_.configureReferences({onFail:TG},"self");return this.$.finalize(_)}}var TG=(Y)=>Y.throw(),WU="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",HU="At most one key matcher may be specified per expression";var Q6=(Y,Z)=>{if(F0(Y)){if(Y[1]==="=")return[Z.$.parseOwnDefinitionFormat(Y[0],Z),"=",Y[2]];if(Y[1]==="?")return[Z.$.parseOwnDefinitionFormat(Y[0],Z),"?"]}return U6(Y,Z)},KG="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",BG="Only required keys may specify default values, e.g. { value: 'number = 0' }";var CG=(Y,Z)=>{let X,_={},G=j2(Y);for(let[W,H]of G){let Q=UU(W);if(Q.kind==="spread"){if(!d1(_))return R(QU);let L=Z.$.parseOwnDefinitionFormat(H,Z);if(L.equals(d.object))continue;if(!L.hasKind("intersection")||!L.basis?.equals(d.object))return R(zU(L.expression));X=L.structure;continue}if(Q.kind==="undeclared"){if(H!=="reject"&&H!=="delete"&&H!=="ignore")R(JU(H));_.undeclared=H;continue}let J=Q6(H,Z),U=Q;if(Q.kind==="required"){if(!F0(J))NZ(_,"required",{key:Q.normalized,value:J},Z);else NZ(_,"optional",J[1]==="="?{key:Q.normalized,value:J[0],default:J[2]}:{key:Q.normalized,value:J[0]},Z);continue}if(F0(J)){if(J[1]==="?")R(KG);if(J[1]==="=")R(BG)}if(Q.kind==="optional"){NZ(_,"optional",{key:Q.normalized,value:J},Z);continue}let E=Z.$.parseOwnDefinitionFormat(U.normalized,Z),V=Y6(E,J,Z.$);if(V.index)_.index=Z0(_.index,V.index);if(V.required)_.required=Z0(_.required,V.required)}let $=Z.$.node("structure",_);return Z.$.parseSchema({domain:"object",structure:X?.merge($)??$})},NZ=(Y,Z,X,_)=>{Y[Z]=Z0(Y[Z],_.$.node(Z,X))},JU=(Y)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${i(Y)})`,QU="Spread operator may only be used as the first key in an object",UU=(Y)=>typeof Y==="symbol"?{kind:"required",normalized:Y}:Y.at(-1)==="?"?Y.at(-2)===k4?{kind:"required",normalized:`${Y.slice(0,-2)}?`}:{kind:"optional",normalized:Y.slice(0,-1)}:Y[0]==="["&&Y.at(-1)==="]"?{kind:"index",normalized:Y.slice(1,-1)}:Y[0]===k4&&Y[1]==="["&&Y.at(-1)==="]"?{kind:"required",normalized:Y.slice(1)}:Y==="..."?{kind:"spread"}:Y==="+"?{kind:"undeclared"}:{kind:"required",normalized:Y==="\\..."?"...":Y==="\\+"?"+":Y},zU=(Y)=>`Spread operand must resolve to an object literal type (was ${Y})`;var jG=(Y,Z)=>RU(Y)?xG[Y[0]](Y,Z):AU(Y)?vG[Y[1]](Y,Z):null,FU=(Y,Z)=>Z.$.parseOwnDefinitionFormat(Y[1],Z).keyof(),IZ=(Y,Z)=>{if(Y[2]===void 0)return R(DZ(Y[1],""));let X=Z.$.parseOwnDefinitionFormat(Y[0],Z),_=Z.$.parseOwnDefinitionFormat(Y[2],Z);if(Y[1]==="|")return Z.$.node("union",{branches:[X,_]});let G=Y[1]==="&"?E1(X,_,Z.$):o4(X,_,Z.$);if(G instanceof P)return G.throw();return G},EU=(Y,Z)=>Z.$.parseOwnDefinitionFormat(Y[0],Z).array(),OU=(Y,Z)=>{if(typeof Y[2]!=="function")return R(SG("=>",Y[2]));return Z.$.parseOwnDefinitionFormat(Y[0],Z).pipe(Y[2])},SG=(Y,Z)=>`${Y===":"?"Narrow":"Morph"} expression requires a function following '${Y}' (was ${typeof Z})`,VU=(Y,Z)=>{if(typeof Y[2]!=="function")return R(SG(":",Y[2]));return Z.$.parseOwnDefinitionFormat(Y[0],Z).constrain("predicate",Y[2])},DU=(Y,Z)=>Z.$.parseOwnDefinitionFormat(Y[0],Z).configureReferences(Y[2],"shallow"),PG=(Y)=>Y,LU=PG({"[]":EU,"?":()=>R(_6)}),MU=PG({"|":IZ,"&":IZ,":":VU,"=>":OU,"|>":IZ,"@":DU,"=":()=>R(G6)}),vG={...LU,...MU},AU=(Y)=>vG[Y[1]]!==void 0,wU=(Y)=>Y,xG=wU({keyof:FU,instanceof:(Y,Z)=>{if(typeof Y[1]!=="function")return R(qG(f4(Y[1])));let X=Y.slice(1).map((_)=>typeof _==="function"?Z.$.node("proto",{proto:_}):R(qG(f4(_))));return X.length===1?X[0]:Z.$.node("union",{branches:X})},"===":(Y,Z)=>Z.$.units(Y.slice(1))}),RU=(Y)=>xG[Y[0]]!==void 0,qG=(Y)=>`Expected a constructor following 'instanceof' operator (was ${Y})`;var kG=(Y,Z)=>{let X=[{}],_=0;while(_<Y.length){let G=!1;if(Y[_]==="..."&&_<Y.length-1)G=!0,_++;let $=Q6(Y[_],Z),[W,H,Q]=!F0($)?[$]:$;if(_++,G){if(!W.extends(N.intrinsic.Array))return R(TU(W.expression));X=X.flatMap((J)=>W.distribute((U)=>IU(d8(J),U)))}else X=X.map((J)=>{if(H==="?")return bG(J,W);if(H==="=")return NU(J,W,Q);return TZ(J,W)})}return Z.$.parseSchema(X.map((G)=>d1(G)?{proto:Array,exactLength:0}:{proto:Array,sequence:G}))},TZ=(Y,Z)=>{if(Y.defaultables||Y.optionals)return R(Y.variadic?ZZ:KU);if(Y.variadic)Y.postfix=Z0(Y.postfix,Z);else Y.prefix=Z0(Y.prefix,Z);return Y},bG=(Y,Z)=>{if(Y.variadic)return R(yG);return Y.optionals=Z0(Y.optionals,Z),Y},NU=(Y,Z,X)=>{if(Y.variadic)return R(yG);if(Y.optionals)return R(BU);return Y.defaultables=Z0(Y.defaultables,[[Z,X]]),Y},fG=(Y,Z)=>{if(Y.postfix)R(hG);if(Y.variadic){if(!Y.variadic.equals(Z))R(hG)}else Y.variadic=Z.internal;return Y},IU=(Y,Z)=>{let X=Z.select({method:"find",kind:"sequence"});if(!X)return fG(Y,N.intrinsic.unknown);if(X.prefix)for(let _ of X.prefix)TZ(Y,_);if(X.optionals)for(let _ of X.optionals)bG(Y,_);if(X.variadic)fG(Y,X.variadic);if(X.postfix)for(let _ of X.postfix)TZ(Y,_);return Y},TU=(Y)=>`Spread element must be an array (was ${Y})`,hG="A tuple may have at most one variadic element",KU="A required element may not follow an optional element",yG="An optional element may not follow a variadic element";var BU="A defaultable element may not follow an optional element without a default";var CU={},U6=(Y,Z)=>{if(typeof Y==="string"){if(Z.args&&Object.keys(Z.args).some((_)=>Y.includes(_)))return wZ(Y,Z);let X=CU[Z.$.name]??={};return X[Y]??=wZ(Y,Z)}return Q1(Y,"object")?qU(Y,Z):R(KZ(y0(Y)))},qU=(Y,Z)=>{let X=x4(Y);switch(X){case void 0:if(y(Y,"root"))return Y;return CG(Y,Z);case"Array":return jU(Y,Z);case"RegExp":return Z.$.node("intersection",{domain:"string",pattern:Y},{prereduced:!0});case"Function":{let _=O2(Y)?Y():Y;if(y(_,"root"))return _;return R(KZ("Function"))}default:return R(KZ(X??i(Y)))}},jU=(Y,Z)=>jG(Y,Z)??kG(Y,Z),KZ=(Y)=>`Type definitions must be strings or objects (was ${Y})`;class BZ extends x1{constructor(Y){let Z=Object.assign({errors:z1,hkt:s0,$:Y,raw:Y.parse,module:Y.constructor.module,scope:Y.constructor.scope,define:Y.define,match:Y.match,generic:Y.generic,schema:Y.schema,keywords:Y.ambient,unit:Y.unit,enumerated:Y.enumerated,instanceOf:Y.instanceOf,valueOf:Y.valueOf,or:Y.or,and:Y.and,merge:Y.merge,pipe:Y.pipe},Y.ambientAttachments);super((...X)=>{if(X.length===1)return Y.parse(X[0]);if(X.length===2&&typeof X[0]==="string"&&X[0][0]==="<"&&X[0].at(-1)===">"){let _=X[0].slice(1,-1),G=Y.parseGenericParams(_,{});return new A2(G,X[1],Y,Y,null)}return Y.parse(X)},{bind:Y,attach:Z})}}var E4=N;class z6 extends Z6{get ambientAttachments(){if(!E4.typeAttachments)return;return this.cacheGetter("ambientAttachments",o(E4.typeAttachments,(Y,Z)=>[Y,this.bindReference(Z)]))}preparseOwnAliasEntry(Y,Z){let X=Y.indexOf("<");if(X===-1){if(y(Z,"module")||y(Z,"generic"))return[Y,Z];let $=this.name==="ark"?Y:Y==="root"?this.name:`${this.name}.${Y}`,W=this.resolvedConfig.keywords?.[$];if(W)Z=[Z,"@",W];return[Y,Z]}if(Y.at(-1)!==">")R("'>' must be the last character of a generic declaration in a scope");let _=Y.slice(0,X),G=Y.slice(X+1,-1);return[_,()=>{let $=this.parseGenericParams(G,{alias:_});return __($,Z,this)}]}parseGenericParams(Y,Z){return J6(new _2(Y),[],this.createParseContext({...Z,def:Y,prefix:"generic"}))}normalizeRootScopeValue(Y){if(O2(Y)&&!y(Y,"generic"))return Y();return Y}preparseOwnDefinitionFormat(Y,Z){return{...Z,def:Y,prefix:Z.alias??"type"}}parseOwnDefinitionFormat(Y,Z){if(!(Z.alias&&(Z.alias in this.aliases))&&!Z.args)Z.args={this:Z.id};let _=U6(Y,Z);if(F0(_)){if(_[1]==="=")return R(G6);if(_[1]==="?")return R(_6)}return _}unit=(Y)=>this.units([Y]);valueOf=(Y)=>this.units(IX(Y));enumerated=(...Y)=>this.units(Y);instanceOf=(Y)=>this.node("proto",{proto:Y},{prereduced:!0});or=(...Y)=>this.schema(Y.map((Z)=>this.parse(Z)));and=(...Y)=>Y.reduce((Z,X)=>Z.and(this.parse(X)),this.intrinsic.unknown);merge=(...Y)=>Y.reduce((Z,X)=>Z.merge(this.parse(X)),this.intrinsic.object);pipe=(...Y)=>this.intrinsic.unknown.pipe(...Y);match=new RZ(this);declare=()=>({type:this.type});define(Y){return Y}type=new BZ(this);static scope=(Y,Z={})=>new z6(Y,Z);static module=(Y,Z={})=>this.scope(Y,Z).export()}var CZ=Object.assign(z6.scope,{define:(Y)=>Y}),e=z6;class gG extends s0{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var SU=K1(["base",d.object],["props",d.object])((Y)=>Y.base.merge(Y.props),gG),pG=e.module({Key:d.key,Merge:SU});class mG extends s0{}var PU=K1("element")((Y)=>{let Z=Y.element.exclude(d.Array),X=Z.array();return Z.rawOr(X).pipe(E2).distribute((_)=>_.assertHasKind("morph").declareOut(X),H0)},mG),uG=e.module({root:d.Array,readonly:"root",index:d.nonNegativeIntegerString,liftFrom:PU},{name:"Array"});var qZ=H0(["string",P2.FileConstructor]),vU=qZ.rawOr(qZ.array()),dG=H0({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:vU}}),cG=e.module({root:["instanceof",FormData],value:qZ,parsed:dG,parse:H0({in:FormData,morphs:(Y)=>{let Z={};for(let[X,_]of Y)if(X in Z){let G=Z[X];if(typeof G==="string"||G instanceof P2.FileConstructor)Z[X]=[G,_];else G.push(_)}else Z[X]=_;return Z},declaredOut:dG})},{name:"FormData"});var lG=e.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"});var xU={Boolean:1,Number:1,String:1},oG=e.module({...o({...OY,...DY},(Y,Z)=>(Y in xU)?[]:[Y,["instanceof",Z]]),Array:uG,TypedArray:lG,FormData:cG});var fU=H0({domain:{domain:"number",meta:"a number representing a Unix timestamp"},divisor:{rule:1,meta:"an integer representing a Unix timestamp"},min:{rule:-8640000000000000,meta:"a Unix timestamp after -8640000000000000"},max:{rule:8640000000000000,meta:"a Unix timestamp before 8640000000000000"},meta:"an integer representing a safe Unix timestamp"}),hU=H0({domain:"number",divisor:1}),F6=e.module({root:d.number,integer:hU,epoch:fU,safe:H0({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"});var N0=(Y,Z,X)=>{let _={domain:"string",pattern:{rule:Y.source,flags:Y.flags,meta:Z}};if(X)_.meta={format:X};return U4("intersection",_)},iG=N0(b4,"a well-formed integer string"),$9=e.module({root:iG,parse:H0({in:iG,morphs:(Y,Z)=>{let X=Number.parseInt(Y);return Number.isSafeInteger(X)?X:Z.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:d.integer})},{name:"string.integer"}),kU=N0(/^[\dA-Fa-f]+$/,"hex characters only"),bU=e.module({root:N0(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:N0(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),rG=N0(/^[A-Z].*$/,"capitalized"),yU=e.module({root:H0({in:"string",morphs:(Y)=>Y.charAt(0).toUpperCase()+Y.slice(1),declaredOut:rG}),preformatted:rG},{name:"string.capitalize"}),gU=(Y)=>{let Z=Y.replaceAll(/[ -]+/g,""),X=0,_,G,$=!1;for(let W=Z.length-1;W>=0;W--){if(_=Z.substring(W,W+1),G=Number.parseInt(_,10),$)G*=2,X+=G>=10?G%10+1:G;else X+=G;$=!$}return!!(X%10===0?Z:!1)},pU=/^(?: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}))$/,mU=H0({domain:"string",pattern:{meta:"a credit card number",rule:pU.source},predicate:{meta:"a credit card number",predicate:gU}});var uU=/^([+-]?\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)?)?)?)?$/;var dU=(Y)=>!Number.isNaN(new Date(Y).valueOf()),nG=H0({domain:"string",predicate:{meta:"a parsable date",predicate:dU}}).assertHasKind("intersection"),sG=$9.root.internal.narrow((Y,Z)=>{let X=Number.parseInt(Y),_=F6.epoch(X);if(_ instanceof z1)return Z.errors.merge(_),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),cU=e.module({root:sG,parse:H0({in:sG,morphs:(Y)=>new Date(Y),declaredOut:d.Date})},{name:"string.date.epoch"}),tG=N0(uU,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),lU=e.module({root:tG,parse:H0({in:tG,morphs:(Y)=>new Date(Y),declaredOut:d.Date})},{name:"string.date.iso"}),oU=e.module({root:nG,parse:H0({declaredIn:nG,in:"string",morphs:(Y,Z)=>{let X=new Date(Y);if(Number.isNaN(X.valueOf()))return Z.error("a parsable date");return X},declaredOut:d.Date}),iso:lU,epoch:cU},{name:"string.date"}),iU=N0(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),aG="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",w2=`(${aG}[.]){3}${aG}`,rU=new RegExp(`^${w2}$`),x0="(?:[0-9a-fA-F]{1,4})",nU=new RegExp(`^((?:${x0}:){7}(?:${x0}|:)|(?:${x0}:){6}(?:${w2}|:${x0}|:)|(?:${x0}:){5}(?::${w2}|(:${x0}){1,2}|:)|(?:${x0}:){4}(?:(:${x0}){0,1}:${w2}|(:${x0}){1,3}|:)|(?:${x0}:){3}(?:(:${x0}){0,2}:${w2}|(:${x0}){1,4}|:)|(?:${x0}:){2}(?:(:${x0}){0,3}:${w2}|(:${x0}){1,5}|:)|(?:${x0}:){1}(?:(:${x0}){0,4}:${w2}|(:${x0}){1,6}|:)|(?::((?::${x0}){0,5}:${w2}|(?::${x0}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),sU=e.module({root:["v4 | v6","@","an IP address"],v4:N0(rU,"an IPv4 address","ipv4"),v6:N0(nU,"an IPv6 address","ipv6")},{name:"string.ip"}),O4="a JSON string",W9=(Y)=>{if(!(Y instanceof SyntaxError))throw Y;return`must be ${O4} (${Y})`},tU=H0({meta:O4,domain:"string",predicate:{meta:O4,predicate:(Y,Z)=>{try{return JSON.parse(Y),!0}catch(X){return Z.reject({code:"predicate",expected:O4,problem:W9(X)})}}}}),aU=(Y,Z)=>{if(Y.length===0)return Z.error({code:"predicate",expected:O4,actual:"empty"});try{return JSON.parse(Y)}catch(X){return Z.error({code:"predicate",expected:O4,problem:W9(X)})}},eU=e.module({root:tU,parse:H0({meta:"safe JSON string parser",in:"string",morphs:aU,declaredOut:d.jsonObject})},{name:"string.json"}),eG=N0(/^[a-z]*$/,"only lowercase letters"),Yz=e.module({root:H0({in:"string",morphs:(Y)=>Y.toLowerCase(),declaredOut:eG}),preformatted:eG},{name:"string.lower"}),H9=["NFC","NFD","NFKC","NFKD"],$8=o(H9,(Y,Z)=>[Z,H0({domain:"string",predicate:(X)=>X.normalize(Z)===X,meta:`${Z}-normalized unicode`})]),E6=o(H9,(Y,Z)=>[Z,H0({in:"string",morphs:(X)=>X.normalize(Z),declaredOut:$8[Z]})]),Zz=e.module({root:E6.NFC,preformatted:$8.NFC},{name:"string.normalize.NFC"}),Xz=e.module({root:E6.NFD,preformatted:$8.NFD},{name:"string.normalize.NFD"}),_z=e.module({root:E6.NFKC,preformatted:$8.NFKC},{name:"string.normalize.NFKC"}),Gz=e.module({root:E6.NFKD,preformatted:$8.NFKD},{name:"string.normalize.NFKD"}),$z=e.module({root:"NFC",NFC:Zz,NFD:Xz,NFKC:_z,NFKD:Gz},{name:"string.normalize"}),Y9=N0(p8,"a well-formed numeric string"),Wz=e.module({root:Y9,parse:H0({in:Y9,morphs:(Y)=>Number.parseFloat(Y),declaredOut:d.number})},{name:"string.numeric"}),Z9="a regex pattern",Hz=H0({domain:"string",predicate:{meta:Z9,predicate:(Y,Z)=>{try{return new RegExp(Y),!0}catch(X){return Z.reject({code:"predicate",expected:Z9,problem:String(X)})}}},meta:{format:"regex"}}),Jz=/^(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-]+)*))?$/,Qz=N0(Jz,"a semantic version (see https://semver.org/)"),X9=N0(/^\S.*\S$|^\S?$/,"trimmed"),Uz=e.module({root:H0({in:"string",morphs:(Y)=>Y.trim(),declaredOut:X9}),preformatted:X9},{name:"string.trim"}),_9=N0(/^[A-Z]*$/,"only uppercase letters"),zz=e.module({root:H0({in:"string",morphs:(Y)=>Y.toUpperCase(),declaredOut:_9}),preformatted:_9},{name:"string.upper"}),Fz=(Y)=>{if(URL.canParse)return URL.canParse(Y);try{return new URL(Y),!0}catch{return!1}},G9=H0({domain:"string",predicate:{meta:"a URL string",predicate:Fz},meta:{format:"uri"}}),Ez=e.module({root:G9,parse:H0({declaredIn:G9,in:"string",morphs:(Y,Z)=>{try{return new URL(Y)}catch{return Z.error("a URL string")}},declaredOut:H0(URL)})},{name:"string.url"}),Oz=e.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:N0(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:N0(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:N0(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:N0(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:N0(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:N0(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:N0(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:N0(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),J9=e.module({root:d.string,alpha:N0(/^[A-Za-z]*$/,"only letters"),alphanumeric:N0(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:kU,base64:bU,capitalize:yU,creditCard:mU,date:oU,digits:N0(/^\d*$/,"only digits 0-9"),email:iU,integer:$9,ip:sU,json:eU,lower:Yz,normalize:$z,numeric:Wz,regex:Hz,semver:Qz,trim:Uz,upper:zz,url:Ez,uuid:Oz},{name:"string"});var Q9=e.module({bigint:d.bigint,boolean:d.boolean,false:d.false,never:d.never,null:d.null,number:d.number,object:d.object,string:d.string,symbol:d.symbol,true:d.true,unknown:d.unknown,undefined:d.undefined}),U9=e.module({root:d.unknown,any:d.unknown},{name:"unknown"}),Vz=e.module({root:d.jsonObject,stringify:U4("morph",{in:d.jsonObject,morphs:(Y)=>JSON.stringify(Y),declaredOut:d.string})},{name:"object.json"}),z9=e.module({root:d.object,json:Vz},{name:"object"});class F9 extends s0{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var Dz=K1(["K",d.key],"V")((Y)=>({domain:"object",index:{signature:Y.K,value:Y.V}}),F9);class E9 extends s0{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var Lz=K1(["T",d.object],["K",d.key])((Y)=>Y.T.pick(Y.K),E9);class O9 extends s0{description='omit a set of properties from an object like `Omit(User, "age")`'}var Mz=K1(["T",d.object],["K",d.key])((Y)=>Y.T.omit(Y.K),O9);class V9 extends s0{description="make all named properties of an object optional like `Partial(User)`"}var Az=K1(["T",d.object])((Y)=>Y.T.partial(),V9);class D9 extends s0{description="make all named properties of an object required like `Required(User)`"}var wz=K1(["T",d.object])((Y)=>Y.T.required(),D9);class L9 extends s0{description='exclude branches of a union like `Exclude("boolean", "true")`'}var Rz=K1("T","U")((Y)=>Y.T.exclude(Y.U),L9);class M9 extends s0{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var Nz=K1("T","U")((Y)=>Y.T.extract(Y.U),M9),A9=e.module({Exclude:Rz,Extract:Nz,Omit:Mz,Partial:Az,Pick:Lz,Record:Dz,Required:wz});var R2=CZ({...Q9,...A9,...oG,...pG,string:J9,number:F6,object:z9,unknown:U9},{prereducedAliases:!0,name:"ark"}),p0=R2.export();Object.assign(E4.ambient,p0);E4.typeAttachments={string:p0.string.root,number:p0.number.root,bigint:p0.bigint,boolean:p0.boolean,symbol:p0.symbol,undefined:p0.undefined,null:p0.null,object:p0.object.root,unknown:p0.unknown.root,false:p0.false,true:p0.true,never:p0.never,arrayIndex:p0.Array.index,Key:p0.Key,Record:p0.Record,Array:p0.Array.root,Date:p0.Date};var O1=Object.assign(R2.type,E4.typeAttachments),Iz=R2.match,Tz=R2.generic,$T=R2.schema,Kz=R2.define,Bz=R2.declare;function a0(Y){return JSON.parse(Y)}var Q0=(Y)=>JSON.stringify(Y),RT=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function V4(Y){return L6(o0.STORE,Y,void 0)}function W8(Y){return M4(o0.STORE,Y)}function SZ(...Y){if(Y.length===2)return l1(o0.STORE,...Y);return l1(o0.STORE,...Y)}function O6(Y,Z){return q9(o0.STORE,Y,Z)}function w9(Y){return S9(Y,o0.STORE)}var G2={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]"};var jZ=(Y)=>(Z,X,_,G,...$)=>{console[Y](`${Z} ${G2[X]} \`${_}\` ${G}`,...$)},Cz={error:jZ("error"),info:jZ("info"),warn:jZ("warn")},R9=class{logLevel;filter;logger;constructor(Y,Z,X=Cz){this.logLevel=Y,this.filter=Z,this.logger=X}error=(...Y)=>{if(this.logLevel!==null){let Z=this.filter?.(...Y)??!0;if(Z===!0)this.logger.error(...Y);else if(Z)this.logger.error(...Z)}};info=(...Y)=>{if(this.logLevel==="info"){let Z=this.filter?.(...Y)??!0;if(Z===!0)this.logger.info(...Y);else if(Z)this.logger.info(...Z)}};warn=(...Y)=>{if(this.logLevel!=="error"&&this.logLevel!==null){let Z=this.filter?.(...Y)??!0;if(Z===!0)this.logger.warn(...Y);else if(Z)this.logger.warn(...Z)}}};var qz=class{store;constructor(Y=o0.STORE){this.store=Y,T9("root",Y)}allocate(Y,Z,X){return D4(this.store,Y,Z,X)}fuse(Y,Z,X){return K9(this.store,Y,Z,X)}deallocate(Y){L4(this.store,Y)}claim(Y,Z,X){return J8(this.store,Y,Z,X)}},N9=class{store;realm;constructor(Y=o0.STORE){this.store=Y,this.realm=new qz(Y)}allocate(Y,Z,X){D4(this.store,Y,Z,X)}deallocate(Y){L4(this.store,Y)}claim(Y,Z,X){J8(this.store,Y,Z,X)}};function V6(Y){return xZ(o0.STORE,Y)}function H8(Y){return vZ(o0.STORE,Y)}var $2=class Y extends Set{mode="record";subject=new W0;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor(Z,X=0){super(Z);if(Z instanceof Y)this.parent=Z,this.cacheUpdateNumber=Z.cacheUpdateNumber;if(X)this.cacheLimit=X,this.cache=new Array(X),this.subscribe("auto cache",(_)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=_})}READONLY_VIEW=this;toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON(Z){let X=new Y(Z.members,Z.cacheLimit);return X.cache=Z.cache,X.cacheIdx=Z.cacheIdx,X.cacheUpdateNumber=Z.cacheUpdateNumber,X}add(Z){let X=super.add(Z);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${Q0(Z)}`);return X}clear(){let Z=this.mode==="record"?[...this]:null;if(super.clear(),Z)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify(Z)}`)}delete(Z){let X=super.delete(Z);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${Q0(Z)}`);return X}parent=null;child=null;transactionUpdates=null;transaction(Z){this.mode="transaction",this.transactionUpdates=[],this.child=new Y(this);let X=this.child._subscribe("transaction",(_)=>{this.transactionUpdates?.push(_)});try{if(Z(this.child)){for(let G of this.transactionUpdates)this.doStep(G);this.cacheUpdateNumber++,this.emit(`tx:${this.transactionUpdates.join(";")}`)}}catch(_){throw console.warn("Did not apply transaction to SetRTX; this error was thrown:",_),_}finally{X(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe(Z,X){return this.subject.subscribe(Z,X)}subscribe(Z,X){return this.subject.subscribe(Z,(_)=>{X(`${this.cacheUpdateNumber}=${_}`)})}emit(Z){this.subject.next(Z)}doStep(Z){let X=Z.indexOf(":"),_=Z.substring(0,X),G=Z.substring(X+1);switch(_){case"add":this.add(JSON.parse(G));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(G));break;case"tx":for(let $ of G.split(";"))this.doStep($)}}getUpdateNumber(Z){let X=Z.indexOf("=");return Number(Z.substring(0,X))}do(Z){let X=Z.indexOf("="),_=Number(Z.substring(0,X)),G=_-this.cacheUpdateNumber;if(G>0){if(G===1){this.mode="playback";let W=Z.substring(X+1);return this.doStep(W),this.mode="record",this.cacheUpdateNumber=_,null}return this.cacheUpdateNumber+1}if(Math.abs(G)<this.cacheLimit){let W=this.cacheIdx+G;if(this.cache[W]===Z)return null;this.mode="playback";let Q=!1;while(!Q){this.cacheIdx%=this.cacheLimit;let U=this.cache[this.cacheIdx];if(this.cacheIdx--,!U)return"OUT_OF_RANGE";this.undo(U),Q=this.cacheIdx===W-1}let J=Z.substring(X+1);return this.doStep(J),this.mode="record",this.cacheUpdateNumber=_,null}return"OUT_OF_RANGE"}undoStep(Z){let X=Z.indexOf(":"),_=Z.substring(0,X),G=Z.substring(X+1);switch(_){case"add":this.delete(JSON.parse(G));break;case"del":this.add(JSON.parse(G));break;case"clear":{let $=JSON.parse(G);for(let W of $)this.add(W);break}case"tx":{let $=G.split(";");for(let W=$.length-1;W>=0;W--)this.undoStep($[W])}}}undo(Z){let X=Z.indexOf("=");if(Number(Z.substring(0,X))===this.cacheUpdateNumber){this.mode="playback";let G=Z.substring(X+1);return this.undoStep(G),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}};function I9(Y=Math.random){return Y().toString(36).slice(2)}function Y0(Y){while(Y.child!==null)Y=Y.child;return Y}var Sz=class Y{_buffer;_index=0;constructor(Z){let X;if(typeof Z==="number")X=Z;else X=Z.length;this._buffer=Array.from({length:X})}get buffer(){return this._buffer}get index(){return this._index}add(Z){this._buffer[this._index]=Z,this._index=(this._index+1)%this._buffer.length}copy(){let Z=new Y([...this._buffer]);return Z._index=this._index,Z}};function k1(Y){let Z={key:Y.key,type:Y.type};if("family"in Y)Z.family=Y.family;return Z}var Pz=Symbol("counterfeit"),vz={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"};function P9(Y,Z,X){let _=Q0(Z),G=`${Y.key}(${_})`,$=vz[Y.type],W={key:G,type:$,family:{key:Y.key,subKey:_}};if(X)W.counterfeit=!0;return W}var G1=class{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=(Y,Z)=>`${Y}:${Z}`;warn;getRelatedKeys(Y){return this.relations.get(Y)}addRelation(Y,Z){let X=this.relations.get(Y),_=this.relations.get(Z);if(X)X.add(Z);else X=new Set([Z]),this.relations.set(Y,X);if(_)_.add(Y);else _=new Set([Y]),this.relations.set(Z,_)}deleteRelation(Y,Z){let X=this.relations.get(Y);if(X){if(X.delete(Z),X.size===0)this.relations.delete(Y);let _=this.relations.get(Z);if(_){if(_.delete(Y),_.size===0)this.relations.delete(Z)}}}replaceRelationsUnsafely(Y,Z){this.relations.set(Y,new Set(Z));for(let X of Z){let _=new Set().add(Y);this.relations.set(X,_)}}replaceRelationsSafely(Y,Z){let X=this.relations.get(Y),_=this.isAType?.(Y)?Y:void 0,G=_===void 0?Y:void 0;if(X)for(let $ of X){_??=$,G??=$;let W=this.relations.get($);if(W){if(W.size===1)this.relations.delete($);else W.delete(Y);this.contents.delete(this.makeContentKey(_,G))}}this.relations.set(Y,new Set(Z));for(let $ of Z){let W=this.relations.get($);if(W)W.add(Y);else W=new Set().add(Y),this.relations.set($,W)}}getContentInternal(Y){return this.contents.get(Y)}setContent(Y,Z){this.contents.set(Y,Z)}deleteContent(Y){this.contents.delete(Y)}constructor(Y,Z){if(this.a=Y.between[0],this.b=Y.between[1],this.cardinality=Y.cardinality,!Z?.externalStore)this.relations=new Map(Y.relations?.map(([X,_])=>[X,new Set(_)])),this.contents=new Map(Y.contents);if(this.isAType=Z?.isAType??null,this.isBType=Z?.isBType??null,this.isContent=Z?.isContent??null,Z?.makeContentKey)this.makeContentKey=Z.makeContentKey;if(Z?.externalStore){let X=Z.externalStore;if(this.has=(_,G)=>X.has(_,G),this.addRelation=(_,G)=>{X.addRelation(_,G)},this.deleteRelation=(_,G)=>{X.deleteRelation(_,G)},this.replaceRelationsSafely=(_,G)=>{X.replaceRelationsSafely(_,G)},this.replaceRelationsUnsafely=(_,G)=>{X.replaceRelationsUnsafely(_,G)},this.getRelatedKeys=(_)=>X.getRelatedKeys(_),X.getContent)this.getContentInternal=(_)=>{return X.getContent(_)},this.setContent=(_,G)=>{X.setContent(_,G)},this.deleteContent=(_)=>{X.deleteContent(_)};for(let[_,G]of Y.relations??[]){let $=this.isAType?.(_)?_:void 0,W=$===void 0?_:void 0;for(let H of G)$??=H,W??=H,this.addRelation($,W)}for(let[_,G]of Y.contents??[])this.setContent(_,G)}if(Z?.warn)this.warn=Z.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([Y,Z])=>[Y,[...Z]]),contents:[...this.contents.entries()]}}set(...Y){let Z,X,_;switch(Y.length){case 1:{let G=Y[0];Z=G[this.a],X=G[this.b],_=void 0;break}case 2:{let G=Y[0];if(typeof G==="string")[Z,X]=Y;else Z=G[this.a],X=G[this.b],_=Y[1];break}default:Z=Y[0],X=Y[1],_=Y[2];break}switch(this.cardinality){case"1:1":{let G=this.getRelatedKey(Z);if(G&&G!==X)this.delete(Z,G)}case"1:n":{let G=this.getRelatedKey(X);if(G&&G!==Z)this.delete(G,X)}break;case"n:n":}if(_){let G=this.makeContentKey(Z,X);this.setContent(G,_)}return this.addRelation(Z,X),this}delete(Y,Z){Z=typeof Z==="string"?Z:Y[this.b];let X=typeof Y==="string"?Y:Y[this.a];if(X===void 0&&typeof Z==="string"){let _=this.getRelatedKeys(Z);if(_)for(let G of _)this.delete(G,Z)}if(typeof X==="string"&&Z===void 0){let _=this.getRelatedKeys(X);if(_)for(let G of _)this.delete(X,G)}if(typeof X==="string"&&typeof Z==="string"){this.deleteRelation(X,Z);let _=this.makeContentKey(X,Z);this.deleteContent(_)}return this}getRelatedKey(Y){let Z=this.getRelatedKeys(Y);if(Z){if(Z.size>1)this.warn?.(`${Z.size} related keys were found for key "${Y}": (${[...Z].map((_)=>`"${_}"`).join(", ")}). Only one related key was expected.`);let X;for(let _ of Z){X=_;break}return X}}replaceRelations(Y,Z,X){let _=!Array.isArray(Z),G=_?Object.keys(Z):Z;if(X?.reckless)this.replaceRelationsUnsafely(Y,G);else this.replaceRelationsSafely(Y,G);if(_)for(let $ of G){let W=this.makeContentKey(Y,$),H=Z[$];this.setContent(W,H)}return this}getContent(Y,Z){let X=this.makeContentKey(Y,Z);return this.getContentInternal(X)}getRelationEntries(Y){let Z=Y[this.a],X=Y[this.b];if(Z!==void 0&&X===void 0){let _=this.getRelatedKeys(Z);if(_)return[..._].map((G)=>{return[G,this.getContent(Z,G)]})}if(Z===void 0&&X!==void 0){let _=this.getRelatedKeys(X);if(_)return[..._].map((G)=>{return[G,this.getContent(G,X)]})}return[]}has(Y,Z){if(Z)return this.getRelatedKeys(Y)?.has(Z)??!1;return this.relations.has(Y)}},W0=class{Subscriber;subscribers=new Map;subscribe(Y,Z){return this.subscribers.set(Y,Z),()=>{this.unsubscribe(Y)}}unsubscribe(Y){this.subscribers.delete(Y)}next(Y){let Z=this.subscribers.values();for(let X of Z)X(Y)}},xz=class extends W0{state;constructor(Y){super();this.state=Y}next(Y){this.state=Y,super.next(Y)}},fz=(Y,Z)=>{let X=Y0(Y);if(X.operation.open)return X.operation.prev.get(Z.key);return X.valueMap.get(Z.key)};function k9(Y,Z,X,_){let G=Y.disposalTraces.buffer.find(($)=>$?.key===Q0(_));switch(Y.logger.error("\u274C",Z.type,Z.key,"gets a fallback value because key",_,"is not allocated",G?`This key was previously disposed:
|
|
48
48
|
${G.trace}`:"(no previous disposal trace found)"),X.type){case"mutable_atom_family":{if(Y.defaults.has(X.key))return Y.defaults.get(X.key);let $=new X.class;return Y.defaults.set(X.key,$),$}case"atom_family":{if(Y.defaults.has(X.key))return Y.defaults.get(X.key);let $=X.default,W=$(_);return Y.defaults.set(X.key,W),W}case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if(Y.defaults.has(X.key))return Y.defaults.get(X.key);let $=X.default(_);return Y.defaults.set(X.key,$),$}}}var kZ=class extends Promise{fate;resolve;reject;done=!1;constructor(Y){let Z,X;super((_,G)=>{Z=_,X=G});this.resolve=Z,this.reject=X,this.use(Y instanceof Promise?Y:new Promise(Y))}pass(Y,Z){if(Y===this.fate)this.resolve(Z),this.done=!0}fail(Y,Z){if(Y===this.fate)this.reject(Z),this.done=!0}use(Y){if(this===Y)return;if(Y instanceof Promise){let Z=Y;this.fate=Z,Z.then((X)=>{this.pass(Z,X)},(X)=>{this.fail(Z,X)})}else this.resolve(Y),this.fate=void 0}};function y2(Y){return"epoch"in Y.transactionMeta}function $1(Y){return"phase"in Y.transactionMeta}function b9(Y,Z){if(Y.operation.open){let X=performance.now();return Y.logger.info("\uD83D\uDEAB",Z.type,Z.key,`deferring setState at T-${X} until setState for "${Y.operation.token.key}" is done`),X}return Y.operation={open:!0,done:new Set,prev:new Map,timestamp:Date.now(),token:Z},Y.logger.info("\u2B55",Z.type,Z.key,`operation start in store "${Y.config.name}"${$1(Y)?` ${Y.transactionMeta.phase} "${Y.transactionMeta.update.token.key}"`:""}`),Y}function y9(Y){if(Y.operation.open)Y.logger.info("\uD83D\uDD34",Y.operation.token.type,Y.operation.token.key,`operation done in store "${Y.config.name}"`);Y.operation={open:!1},Y.on.operationClose.next(Y.operation)}var g9=(Y,Z)=>{if(!Y.operation.open)return Y.logger.error("\uD83D\uDC1E","unknown",Z,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0;return Y.operation.done.has(Z)},w6=(Y,Z)=>{if(!Y.operation.open){Y.logger.error("\uD83D\uDC1E","unknown",Z,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}Y.operation.done.add(Z)};function pZ(Y,Z){let X=Y0(Y),{key:_,type:G}=Z,$=X.selectorAtoms.getRelatedKeys(_);if(X.logger.info("\uD83E\uDDF9",G,_,$?`evicting ${$.size} states downstream:`:"no downstream states",$??"to evict"),$){if(X.operation.open)X.logger.info("\uD83E\uDDF9",G,_,`[ ${[...X.operation.done].join(", ")} ] already done`);for(let W of $){if(g9(X,W))continue;m9(X,W),w6(X,W)}}}function p9(Y,Z){let X=Y0(Y),_=X.selectorGraph.getRelationEntries({upstreamSelectorKey:Z}).filter(([G,{source:$}])=>$===Z);for(let[G]of _){if(g9(X,G))continue;m9(X,G),w6(X,G),p9(Y,G)}}function W2(Y,Z,X){let{key:_,subject:G,type:$}=Z,W=Y.valueMap.get(_);if(W instanceof kZ&&!W.done){let H=W;if(X instanceof Promise)return H.use(X),H;return Y.valueMap.set(_,X),X}if(X instanceof Promise){let H=new kZ(X);return Y.valueMap.set(_,H),H.then(function Q(J){if(Y.valueMap.get(_)===H){switch(b9(Y,Z),W2(Y,Z,J),$){case"atom":case"mutable_atom":pZ(Y,Z);break;case"readonly_pure_selector":case"writable_pure_selector":p9(Y,_);break}y9(Y),G.next({newValue:J,oldValue:H})}}).catch((Q)=>{Y.logger.error("\uD83D\uDCA5","state",_,"rejected:",Q)}),H}return Y.valueMap.set(_,X),X}function hz(Y,Z,X){Y.logger.info("\uD83D\uDCD6",Z.type,Z.key,"reading cached value");let _=Y.valueMap.get(Z.key);if(X==="mut"&&Z.type==="mutable_atom"&&$1(Y)){let $=Z,{parent:W}=Y;if(Y.valueMap.hasOwn($.key))return _;let H=W.valueMap.get($.key);Y.logger.info("\uD83D\uDCC3","atom",$.key,"copying");let Q=H.toJSON(),J=$.class.fromJSON(Q);Y.valueMap.set($.key,J),new nZ($,W),_=J}return _}function m9(Y,Z){let X=Y.valueMap.get(Z);if(X instanceof kZ){let _=Y.writableSelectors.get(Z)??Y.readonlySelectors.get(Z);if(_)_.getFrom(Y);return}if(Y.operation.open)Y.operation.prev.set(Z,X);Y.valueMap.delete(Z),Y.logger.info("\uD83D\uDDD1","state",Z,"evicted")}function A4(Y,Z,X){if(Y.valueMap.has(Z.key))return hz(Y,Z,X);let{key:_}=Z;switch(Z.type){case"readonly_held_selector":case"readonly_pure_selector":case"writable_held_selector":case"writable_pure_selector":return Y.logger.info("\uD83E\uDDEE",Z.type,_,"computing value"),Z.getFrom(Y);case"atom":{let G;if(Z.default instanceof Function)G=Z.default();else G=Z.default;let $=W2(Y,Z,G);return Y.logger.info("\uD83D\uDC81","atom",Z.key,"could not find cached value; using default",G),$}case"mutable_atom":{let G=new Z.class,$=W2(Y,Z,G);return Y.logger.info("\uD83D\uDC81","mutable_atom",Z.key,"could not find cached value; using default",G),$}}}function mZ(Y,Z){return j0(Y,{key:Z.family.key,type:`${Z.type}_family`})}var kz=(Y)=>{let Z=Y0(Y);if(!$1(Z)){Y.logger.warn("\uD83D\uDC1E","transaction","???","abortTransaction called outside of a transaction. This is probably a bug in AtomIO.");return}Y.logger.info("\uD83E\uDE82","transaction",Z.transactionMeta.update.token.key,"Aborting transaction"),Z.parent.child=null},u9=class extends Error{constructor(Y,Z){super(`${G2[Y.type]} ${Q0(Y.key)} not found in store "${Z.config.name}".`)}};function PZ(Y,Z,X){return(..._)=>{let G=j0(Y,Z);if(G)return G.run(_,X);throw new u9(Z,Y)}}var bZ=(Y)=>(Z)=>Y instanceof Function?Y(Z):Y;function d9(Y,Z,[X,_],G){let{key:$,subject:W,type:H}=Z,Q={oldValue:hZ(X)?X.READONLY_VIEW:X,newValue:hZ(_)?_.READONLY_VIEW:_};if(y2(Y)){switch(H){case"mutable_atom":Y.logger.info("\uD83D\uDCE2",H,$,"is now (",_,") subscribers:",W.subscribers);break;case"atom":case"writable_pure_selector":case"writable_held_selector":Y.logger.info("\uD83D\uDCE2",H,$,"went (",X,"->",_,") subscribers:",W.subscribers)}W.next(Q)}if($1(Y)&&(H==="mutable_atom"||H==="atom")){if(Y.on.transactionApplying.state===null){let J=k1(Z);if(hZ(_))return;let{timestamp:U}=Y.operation,E={type:"atom_update",token:J,timestamp:U,update:Q};Y.transactionMeta.update.subEvents.push(E),Y.logger.info("\uD83D\uDCC1","atom",$,"stowed (",X,"->",_,")");return}if(JF(Z,"tracker:signal")){let J=$.slice(1),U=Y.atoms.get(J);if(A4(Y,U,"mut").do(Q.newValue)===null===!0)pZ(Y,U)}}}var yZ=(Y,Z,X)=>{let _=A4(Y,Z,"mut"),G=bZ(X)(_);return Y.logger.info("\uD83D\uDCDD","atom",Z.key,"set to",G),G=W2(Y,Z,G),w6(Y,Z.key),pZ(Y,Z),[_,G]};function v9(Y,Z){switch(Z.type){case"mutable_atom":return yZ(Y,Z,new Z.class);case"atom":{let X=Z.default;if(X instanceof Function)X=X();return yZ(Y,Z,X)}}}function bz(Y,Z){let X;switch(Z.type){case"atom":case"mutable_atom":X=v9(Y,Z);break;case"writable_pure_selector":case"writable_held_selector":{let _=Z.getFrom(Y),G=A6(Y,Z.key);for(let W of G.values()){let H=v9(Y,W);d9(Y,Z,H,!1)}let $=Z.getFrom(Y);X=[_,$]}break}return X}function B1(Y,...Z){uZ(Y,gZ,...Z)}var M6=Symbol("RESET");function D6(Y,...Z){let X,_,G;if(Z.length===1)X=Z[0],B1(Y,X,M6);else _=Z[0],G=Z[1],B1(Y,_,G,M6)}function yz(Y,Z,X){let _,G,$,{type:W,key:H}=Z;switch(Z.type){case"writable_pure_selector":_=Z.getFrom(Y),G=bZ(X)(_),W2(Y,Z,G);break;case"writable_held_selector":$=Z.const,bZ(X)($),_=$,G=$}return Y.logger.info("\uD83D\uDCDD",W,H,"setting to",G),w6(Y,H),Z.setSelf(G),[_,G]}var gz=(Y,Z,X)=>{let _;switch(Z.type){case"atom":case"mutable_atom":_=yZ(Y,Z,X);break;case"writable_pure_selector":case"writable_held_selector":_=yz(Y,Z,X);break}return _};function pz(Y,Z,X){let{token:_,update:{newValue:G,oldValue:$}}=Z;B1(X,_,Y==="newValue"?G:$)}function mz(Y){let{stack:Z}=Y;if(Z)return`
|
|
49
49
|
`+Z.split(`
|
|
50
50
|
`)?.slice(1)?.join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tempest.games",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.42",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"safegen": "0.7.0",
|
|
46
46
|
"socket.io": "4.8.1",
|
|
47
47
|
"socket.io-client": "4.8.1",
|
|
48
|
-
"atom.io": "0.38.0",
|
|
49
48
|
"safedeposit": "0.1.1",
|
|
50
|
-
"treetrunks": "0.1.3"
|
|
49
|
+
"treetrunks": "0.1.3",
|
|
50
|
+
"atom.io": "0.38.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@react-email/components": "0.5.1",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"vite": "7.1.3",
|
|
71
71
|
"vite-tsconfig-paths": "5.1.4",
|
|
72
72
|
"vitest": "3.2.4",
|
|
73
|
-
"flightdeck": "0.2.
|
|
73
|
+
"flightdeck": "0.2.64",
|
|
74
74
|
"varmint": "0.5.3"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|