tempest.games 0.2.11 → 0.2.13

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.
@@ -1,73 +1,75 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var NM=Object.create;var{getPrototypeOf:LM,defineProperty:r8,getOwnPropertyNames:SM}=Object;var BM=Object.prototype.hasOwnProperty;var RM=($,T,W)=>{W=$!=null?NM(LM($)):{};let U=T||!$||!$.__esModule?r8(W,"default",{value:$,enumerable:!0}):W;for(let X of SM($))if(!BM.call(U,X))r8(U,X,{get:()=>$[X],enumerable:!0});return U};var IM=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports);var N1=($,T)=>{for(var W in T)r8($,W,{get:T[W],enumerable:!0,configurable:!0,set:(U)=>T[W]=()=>U})};var Rj=($,T)=>()=>($&&(T=$($=0)),T);var o5=import.meta.require;var SF=IM((Zg,LF)=>{var iW=o5("os"),nW=o5("path");function NF($){let T=process.env.XDG_CACHE_HOME||nW.join(iW.homedir(),".cache");return nW.join(T,$)}function CR($){return nW.join(iW.homedir(),"Library","Caches",$)}function jR($){let T=process.env.LOCALAPPDATA||nW.join(iW.homedir(),"AppData","Local");return nW.join(T,$,"Cache")}var xR=function(){switch(iW.platform()){case"darwin":return CR;case"win32":return jR;case"aix":case"android":case"freebsd":case"linux":case"netbsd":case"openbsd":case"sunos":return NF;default:return console.error(`(node:${process.pid}) [cachedir] Warning: the platform "${iW.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`),NF}}();LF.exports=function $(T){if(typeof T!=="string")throw new TypeError("id is not a string");if(T.length===0)throw new Error("id cannot be empty");if(/[^0-9a-zA-Z-]/.test(T))throw new Error("id cannot contain special characters");return xR(T)}});class XW extends Promise{fate;resolve;reject;done=!1;constructor($){let T,W;super((U,X)=>{T=U,W=X});this.resolve=T,this.reject=W,this.use($ instanceof Promise?$:new Promise($))}pass($,T){if($===this.fate)this.resolve(T),this.done=!0}fail($,T){if($===this.fate)this.reject(T),this.done=!0}use($){if($ instanceof Promise){let T=$;this.fate=T,T.then((W)=>{this.pass(T,W)},(W)=>{this.fail(T,W)})}else this.resolve($),this.fate=void 0}}var qj=($,T,W=l5.STORE)=>{return d5(W,{key:`${$.key}:JSON`,get:({get:U})=>T.toJson(U($)),set:({set:U},X)=>{U($,T.fromJson(X))}})};function jj($,T,W){return i8($,{key:`${T.key}:JSON`,get:(X)=>({get:Y})=>{let _=Y(T,X);return W.toJson(_)},set:(X)=>({set:Y},_)=>{Y(T,X,W.fromJson(_))}},["mutable","json"])}var YW=($)=>JSON.parse($),R4=($)=>JSON.stringify($),bj=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function s($){while($.child!==null)$=$.child;return $}class gU{_buffer;_index=0;constructor($){let T;if(typeof $==="number")T=$;else T=$.length;this._buffer=Array.from({length:T})}get buffer(){return this._buffer}get index(){return this._index}add($){this._buffer[this._index]=$,this._index=(this._index+1)%this._buffer.length}copy(){let $=new gU([...this._buffer]);return $._index=this._index,$}}var kM={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 r5($,T){let W=R4(T),U=`${$.key}(${W})`,X=kM[$.type],Y={key:U,type:X};return Object.assign(Y,{family:{key:$.key,subKey:W}}),Object.assign(Y,{counterfeit:!0}),Y}function _W($){let T={key:$.key,type:$.type};if("family"in $)T.family=$.family;return T}var n8=($)=>(T,W,U,X,...Y)=>{console[$](`${T} ${W} "${U}" ${X}`,...Y)},vM={error:n8("error"),info:n8("info"),warn:n8("warn")};class t8{logLevel;filter;logger;constructor($,T,W=vM){this.logLevel=$,this.filter=T,this.logger=W}error=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel!==null){if(T===!0)this.logger.error(...$);else if(T!==!1)this.logger.error(...T)}};info=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel==="info"){if(T===!0)this.logger.info(...$);else if(T!==!1)this.logger.info(...T)}};warn=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel!=="error"&&this.logLevel!==null){if(T===!0)this.logger.warn(...$);else if(T!==!1)this.logger.warn(...T)}}}class P6{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=($,T)=>`${$}:${T}`;warn;getRelatedKeys($){return this.relations.get($)}addRelation($,T){let W=this.relations.get($),U=this.relations.get(T);if(W)W.add(T);else W=new Set([T]),this.relations.set($,W);if(U)U.add($);else U=new Set([$]),this.relations.set(T,U)}deleteRelation($,T){let W=this.relations.get($);if(W){if(W.delete(T),W.size===0)this.relations.delete($);let U=this.relations.get(T);if(U){if(U.delete($),U.size===0)this.relations.delete(T)}}}replaceRelationsUnsafely($,T){this.relations.set($,new Set(T));for(let W of T){let U=new Set().add($);this.relations.set(W,U)}}replaceRelationsSafely($,T){let W=this.relations.get($),U=this.isAType?.($)?$:void 0,X=U===void 0?$:void 0;if(W)for(let Y of W){U??=Y,X??=Y;let _=this.relations.get(Y);if(_){if(_.size===1)this.relations.delete(Y);else _.delete($);this.contents.delete(this.makeContentKey(U,X))}}this.relations.set($,new Set(T));for(let Y of T){let _=this.relations.get(Y);if(_)_.add($);else _=new Set().add($),this.relations.set(Y,_)}}getContentInternal($){return this.contents.get($)}setContent($,T){this.contents.set($,T)}deleteContent($){this.contents.delete($)}constructor($,T){if(this.a=$.between[0],this.b=$.between[1],this.cardinality=$.cardinality,!T?.externalStore)this.relations=new Map($.relations?.map(([W,U])=>[W,new Set(U)])),this.contents=new Map($.contents);if(this.isAType=T?.isAType??null,this.isBType=T?.isBType??null,this.isContent=T?.isContent??null,T?.makeContentKey)this.makeContentKey=T.makeContentKey;if(T?.externalStore){let W=T.externalStore;if(this.has=(U,X)=>W.has(U,X),this.addRelation=(U,X)=>{W.addRelation(U,X)},this.deleteRelation=(U,X)=>{W.deleteRelation(U,X)},this.replaceRelationsSafely=(U,X)=>{W.replaceRelationsSafely(U,X)},this.replaceRelationsUnsafely=(U,X)=>{W.replaceRelationsUnsafely(U,X)},this.getRelatedKeys=(U)=>W.getRelatedKeys(U),W.getContent)this.getContentInternal=(U)=>{return W.getContent(U)},this.setContent=(U,X)=>{W.setContent(U,X)},this.deleteContent=(U)=>{W.deleteContent(U)};for(let[U,X]of $.relations??[]){let Y=this.isAType?.(U)?U:void 0,_=Y===void 0?U:void 0;for(let w of X)Y??=w,_??=w,this.addRelation(Y,_)}for(let[U,X]of $.contents??[])this.setContent(U,X)}if(T?.warn)this.warn=T.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([$,T])=>[$,[...T]]),contents:[...this.contents.entries()]}}set(...$){let T,W,U;switch($.length){case 1:{let X=$[0];T=X[this.a],W=X[this.b],U=void 0;break}case 2:{let X=$[0];if(typeof X==="string")[T,W]=$;else T=X[this.a],W=X[this.b],U=$[1];break}default:{T=$[0],W=$[1],U=$[2];break}}switch(this.cardinality){case"1:1":{let X=this.getRelatedKey(T);if(X&&X!==W)this.delete(T,X)}case"1:n":{let X=this.getRelatedKey(W);if(X&&X!==T)this.delete(X,W)}break;case"n:n":}if(U){let X=this.makeContentKey(T,W);this.setContent(X,U)}return this.addRelation(T,W),this}delete($,T){T=typeof T==="string"?T:$[this.b];let W=typeof $==="string"?$:$[this.a];if(W===void 0&&typeof T==="string"){let U=this.getRelatedKeys(T);if(U)for(let X of U)this.delete(X,T)}if(typeof W==="string"&&T===void 0){let U=this.getRelatedKeys(W);if(U)for(let X of U)this.delete(W,X)}if(typeof W==="string"&&typeof T==="string"){this.deleteRelation(W,T);let U=this.makeContentKey(W,T);this.deleteContent(U)}return this}getRelatedKey($){let T=this.getRelatedKeys($);if(T){if(T.size>1)this.warn?.(`${T.size} related keys were found for key "${$}": (${[...T].map((U)=>`"${U}"`).join(", ")}). Only one related key was expected.`);let W;for(let U of T){W=U;break}return W}}replaceRelations($,T,W){let U=!Array.isArray(T),X=U?Object.keys(T):T;if(W?.reckless)this.replaceRelationsUnsafely($,X);else this.replaceRelationsSafely($,X);if(U)for(let Y of X){let _=this.makeContentKey($,Y),w=T[Y];this.setContent(_,w)}return this}getContent($,T){let W=this.makeContentKey($,T);return this.getContentInternal(W)}getRelationEntries($){let T=$[this.a],W=$[this.b];if(T!==void 0&&W===void 0){let U=this.getRelatedKeys(T);if(U)return[...U].map((X)=>{return[X,this.getContent(T,X)]})}if(T===void 0&&W!==void 0){let U=this.getRelatedKeys(W);if(U)return[...U].map((X)=>{return[X,this.getContent(X,W)]})}return[]}has($,T){if(T)return this.getRelatedKeys($)?.has(T)??!1;return this.relations.has($)}}class K${Subscriber;subscribers=new Map;subscribe($,T){return this.subscribers.set($,T),()=>{this.unsubscribe($)}}unsubscribe($){this.subscribers.delete($)}next($){let T=this.subscribers.values();for(let W of T)W($)}}class a8 extends K${state;constructor($){super();this.state=$}next($){this.state=$,super.next($)}}function L1($){return"epoch"in $.transactionMeta}function l4($){return"phase"in $.transactionMeta}function i5($){return $[0].toUpperCase()+$.slice(1)}function mU($){return $.type.split("_").map(i5).join(" ")}class wW extends Error{constructor($,T){super(`${mU($)} ${R4($.key)} not found in store "${T.config.name}".`)}}var d0=($)=>(T)=>$ instanceof Function?$(T):$;var S1=($,T)=>{if($.valueMap.has(T.key))return $.logger.info("\uD83D\uDCD6",T.type,T.key,"reading cached value"),n5(T,$);switch(T.type){case"readonly_held_selector":case"readonly_pure_selector":case"writable_held_selector":case"writable_pure_selector":return $.logger.info("\uD83E\uDDEE",T.type,T.key,"computing value"),T.get();case"atom":case"mutable_atom":{let W=T.default,U;if(W instanceof Function)U=W();else U=W;return $.logger.info("\uD83D\uDC81","atom",T.key,"could not find cached value; using default",U),U}}};var t5=($,T)=>{if($.operation.open){let W=performance.now();return $.logger.info("\u2757",T.type,T.key,`deferring setState at T-${W} until setState for "${$.operation.token.key}" is done`),W}$.operation={open:!0,done:new Set,prev:new Map,time:Date.now(),token:T},$.logger.info("\u2B55",T.type,T.key,`operation start in store "${$.config.name}"${!l4($)?"":` ${$.transactionMeta.phase} "${$.transactionMeta.update.key}"`}`)},a5=($)=>{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)},s5=($,T)=>{if(!$.operation.open)return $.logger.error("\uD83D\uDC1E","unknown",T,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0;return $.operation.done.has(T)},B1=($,T)=>{if(!$.operation.open){$.logger.error("\uD83D\uDC1E","unknown",T,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}$.operation.done.add(T)};var e5=($,T,W)=>{switch(T.type){case"mutable_atom":$.logger.info("\uD83D\uDCE2",T.type,T.key,"is now (",W.newValue,") subscribers:",T.subject.subscribers);break;case"atom":case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":$.logger.info("\uD83D\uDCE2",T.type,T.key,"went (",W.oldValue,"->",W.newValue,") subscribers:",T.subject.subscribers)}T.subject.next(W)};var s8=($,T)=>{let W=s($),U=W.selectorAtoms.getRelatedKeys(T.key);if(W.logger.info("\uD83E\uDDF9",T.type,T.key,U?`evicting ${U.size} states downstream:`:"no downstream states",U??"to evict"),U){if(W.operation.open)W.logger.info("\uD83E\uDDF9",T.type,T.key,`[ ${[...W.operation.done].join(", ")} ] already done`);for(let X of U){if(s5(W,X))continue;$3(X,W),B1(W,X)}}};var T3=($,T,W)=>{let U=S1($,T),X=U;if(T.type==="mutable_atom"&&l4($)){let{parent:_}=$;X=JW($,T,_)}if(X=d0(W)(X),$.logger.info("\uD83D\uDCDD","atom",T.key,"set to",X),X=I4($,T.key,X,T.subject),U3($,T.key))X3($,T.key);B1($,T.key),s8($,T);let Y={oldValue:U,newValue:X};if(!l4($)){e5($,T,Y);return}if($.on.transactionApplying.state===null){let{key:_}=T;if(W3(Y.newValue))return;let w={type:"atom_update",key:_,...Y};if(T.family)w.family=T.family;$.transactionMeta.update.updates.push(w),$.logger.info("\uD83D\uDCC1","atom",_,"stowed (",Y.oldValue,"->",Y.newValue,")")}else if(T.key.startsWith("*")){let _=T.key.slice(1),w=$.atoms.get(_),G=$.valueMap.get(_);if(w.type==="mutable_atom"&&l4($)){let{parent:H}=$;G=JW($,w,H)}if(G.do(Y.newValue)===null)s8($,w)}};var cU=($,T,W)=>{switch(T.type){case"atom":case"mutable_atom":T3($,T,W);break;case"writable_pure_selector":case"writable_held_selector":T.set(W);break}};var uU=($,T)=>s($).atoms.has(T),qM=($,T)=>s($).writableSelectors.has(T),PM=($,T)=>s($).readonlySelectors.has(T),Y3=($,T)=>uU($,T)||qM($,T)||PM($,T);var pU=($,T)=>{return s($).selectorGraph.getRelationEntries({downstreamSelectorKey:T}).filter(([U,{source:X}])=>X!==T).map(([U,{source:X}])=>X).filter((U)=>Y3($,U))};var e8=($,T,W)=>{let U=[],X=pU($,T);while(X.length>0){let Y=X.shift();if(W.has(Y))continue;if(W.add(Y),!uU($,Y))X.push(...pU($,Y));else if(!U.includes(Y))U.push(Y)}return U},_3=($,T)=>{let W=$.key,U=pU(T,W),X=new Set;return U.flatMap((Y)=>uU(T,Y)?Y:e8(T,Y,X))};var w3=($,T,W,U,X)=>{let Y=s($),{type:_,key:w}=U;if(_==="atom"||_==="mutable_atom")Y.selectorAtoms.set({selectorKey:W,atomKey:w}),$.logger.info("\uD83D\uDD0D",T,W,`discovers root atom "${w}"`);else{let G=e8($,w,X);$.logger.info("\uD83D\uDD0D",T,W,`discovers root atoms: [ ${G.map((J)=>`"${J}"`).join(", ")} ]`);for(let J of G)Y.selectorAtoms=Y.selectorAtoms.set({selectorKey:W,atomKey:J})}X.add(w)};var R1=($,T,W,U)=>({get:(...X)=>{let Y=s($),_;if(X.length===2){let[H,z]=X;_=r4($,H,z)}else[_]=X;let w=j4($,_),G=S1($,w),J=_.key;return $.logger.info("\uD83D\uDD0C",T,W,`registers dependency ( "${J}" =`,G,")"),Y.selectorGraph.set({upstreamSelectorKey:J,downstreamSelectorKey:W},{source:_.key}),w3($,T,W,_,U),G},set:(...X)=>{let Y,_;if(X.length===2)Y=X[0],_=X[1];else{let J=X[0],H=X[1];_=X[2],Y=r4($,J,H)}let w=s($),G=j4(w,Y);cU(w,G,_)},find:(...X)=>r4($,...X),json:(X)=>l0($,X)});var $_=($,T,W)=>{let U=s($),X=new K$,Y=new Set,{key:_,const:w}=T,G="readonly_held_selector",{get:J,find:H,json:z}=R1(U,"readonly_held_selector",_,Y),Q={...T,type:"readonly_held_selector",subject:X,install:(K)=>$_(K,T,W),get:()=>{return T.get({get:J,find:H,json:z},w),I4(s($),_,w,X),Y.clear(),w},...W&&{family:W}};U.readonlySelectors.set(_,Q),$.logger.info("\u2728","readonly_held_selector",_,"=",w);let V={key:_,type:"readonly_held_selector"};if(W)V.family=W;return V};var T_=($,T,W)=>{let U=s($),X=new K$,Y=new Set,_=T.key,w="readonly_pure_selector",{get:G,find:J,json:H}=R1(U,"readonly_pure_selector",_,Y),z=()=>{let K=T.get({get:G,find:J,json:H});return I4(s($),_,K,X),Y.clear(),K},F={...T,type:"readonly_pure_selector",subject:X,install:(K)=>T_(K,T,W),get:z,...W&&{family:W}};U.readonlySelectors.set(_,F);let Q=z();$.logger.info("\u2728","readonly_pure_selector",_,"=",Q);let V={key:_,type:"readonly_pure_selector"};if(W)V.family=W;return V};var W_=($,T,W)=>{let U=s($),X=new K$,Y=new Set,{key:_,const:w}=T,G="writable_held_selector",J=R1(U,"writable_held_selector",_,Y),{find:H,get:z,json:F}=J,Q={find:H,get:z,json:F},V=(L=T.get,q=s($))=>{return L(Q,w),I4(q,_,w,X),Y.clear(),w},I={...T,type:"writable_held_selector",subject:X,install:(L)=>W_(L,T,W),get:V,set:(L)=>{let q=s($),y=V(T.get,q),x=d0(L)(y);if($.logger.info("\uD83D\uDCDD","writable_held_selector",_,"set (",y,"->",x,")"),I4(q,_,x,X),B1(q,_),L1(q))X.next({newValue:x,oldValue:y});T.set(J,x)},...W&&{family:W}};U.writableSelectors.set(_,I);let k=V();$.logger.info("\u2728","writable_held_selector",_,"=",k);let N={key:_,type:"writable_held_selector"};if(W)N.family=W;return N};var GW=($,T,W)=>{let U=s($),X=new K$,Y=new Set,_=T.key,w="writable_pure_selector",G=R1(U,"writable_pure_selector",_,Y),{find:J,get:H,json:z}=G,F={find:J,get:H,json:z},Q=(N=T.get,L=s($))=>{let q=N(F);return I4(L,_,q,X),Y.clear(),q},K={...T,type:"writable_pure_selector",subject:X,install:(N)=>GW(N,T,W),get:Q,set:(N)=>{let L=s($),q=Q(T.get,L),y=d0(N)(q);if($.logger.info("\uD83D\uDCDD","writable_pure_selector",_,"set (",q,"->",y,")"),I4(L,T.key,y,X),B1(L,T.key),L1(L))X.next({newValue:y,oldValue:q});T.set(G,y)},...W&&{family:W}};U.writableSelectors.set(_,K);let I=Q();$.logger.info("\u2728",K.type,K.key,"=",I);let k={key:_,type:"writable_pure_selector"};if(W)k.family=W;return k};function d5($,T){let W="set"in T,U="const"in T;if(U&&W){let Y=W_($,T,void 0);return $.on.selectorCreation.next(Y),Y}if(U){let Y=$_($,T,void 0);return $.on.selectorCreation.next(Y),Y}if(W){let Y=GW($,T,void 0);return $.on.selectorCreation.next(Y),Y}let X=T_($,T,void 0);return $.on.selectorCreation.next(X),X}function i8($,T,W){let U=T.key,X="writable_pure_selector_family",Y={key:U,type:"writable_pure_selector_family"},_=$.families.get(U);if(_)$.logger.error("\u2757","writable_pure_selector_family",U,`Overwriting an existing ${mU(_)} "${_.key}" in store "${$.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);let w=new K$,J=Object.assign((H)=>{let z=R4(H),F={key:U,subKey:z},Q=`${U}(${z})`,V=s($),K=GW(V,{key:Q,get:T.get(H),set:T.set(H)},F);return w.next({type:"state_creation",token:K}),K},Y,{internalRoles:W,subject:w,install:(H)=>i8(H,T),default:(H)=>{return T.get(H)({get:(...F)=>zW($,...F),find:(...F)=>r4($,...F),json:(F)=>l0($,F)})}});return $.families.set(U,J),Y}function J3($,T,W){let U=$.families.get(T.key);if(U===void 0)throw new wW(T,$);let X=U(W),Y=s($);if(X.family){if(L1(Y))switch(X.type){case"atom":case"mutable_atom":$.on.atomCreation.next(X);break;case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":$.on.selectorCreation.next(X);break}else if(l4(Y)&&Y.on.transactionApplying.state===null)Y.transactionMeta.update.updates.push({type:"state_creation",token:X})}return X}function G3($,T,W){let U=R4(W),X=`${T.key}(${U})`,Y=s($),_;switch(T.type){case"atom_family":case"mutable_atom_family":_=Y.atoms.get(X);break;case"writable_held_selector_family":case"writable_pure_selector_family":_=Y.writableSelectors.get(X);break;case"readonly_held_selector_family":case"readonly_pure_selector_family":_=Y.readonlySelectors.get(X);break}if(_)return _W(_);return _}function r4($,T,W){let U=G3($,T,W);if(U)return U;let X=R4(W),Y=$.molecules.get(X);if(!Y&&$.config.lifespan==="immortal"){let _=r5(T,W);return $.logger.error("\u274C",_.type,_.key,`was not found in store "${$.config.name}"; returned a counterfeit token.`),_}if(U=J3($,T,W),Y)s($).moleculeData.set(X,T.key);return U}function z3($,T){if(T.family){let W=$.families.get(T.family.key);if(W)return W}}function I1($,...T){let W,U,X,Y;if(T.length===2){if(W=T[0],Y=T[1],U=z3($,W)??null,U)X=W.family?YW(W.family.subKey):null,W=r4($,U,X)}else U=T[0],X=T[1],Y=T[2],W=r4($,U,X);if("counterfeit"in W&&"family"in W){let G=W.family.subKey,J=$.disposalTraces.buffer.find((H)=>H?.key===G);$.logger.error("\u274C",W.type,W.key,`could not be set because it was not found in the store "${$.config.name}".`,J?`This state was previously disposed:
4
- ${J.trace}`:"No previous disposal trace was found.");return}let _=t5($,W);if(_){let G=$.on.operationClose.subscribe(`waiting to set "${W.key}" at T-${_}`,()=>{G(),$.logger.info("\uD83D\uDFE2",W.type,W.key,`resuming deferred setState from T-${_}`),I1($,W,Y)});return}let w=j4($,W);cU($,w,Y),a5($)}function zW($,...T){let W,U,X;if(T.length===1)W=T[0];else U=T[0],X=T[1],W=r4($,U,X);if("counterfeit"in W&&"family"in W){U=$.families.get(W.family.key);let Y=W.family.subKey,_=$.disposalTraces.buffer.find((w)=>w?.key===Y);switch($.logger.error("\u274C",W.type,W.key,`could not be retrieved because it was not found in the store "${$.config.name}".`,_?`This state was previously disposed:
5
- ${_.trace}`:"No previous disposal trace was found."),U.type){case"atom_family":case"mutable_atom_family":return $.defaults.get(U.key);case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if($.defaults.has(U.key))return $.defaults.get(W.family.key);let w=j4($,U).default(Y);return $.defaults.set(U.key,w),w}}}return S1($,j4($,W))}class H3{parent=null;child=null;valueMap=new Map;defaults=new Map;atoms=new Map;writableSelectors=new Map;readonlySelectors=new Map;atomsThatAreDefault=new Set;selectorAtoms=new P6({between:["selectorKey","atomKey"],cardinality:"n:n"});selectorGraph=new P6({between:["upstreamSelectorKey","downstreamSelectorKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});trackers=new Map;families=new Map;joins=new Map;transactions=new Map;transactionMeta={epoch:new Map,actionContinuities:new P6({between:["continuity","action"],cardinality:"1:n"})};timelines=new Map;timelineTopics=new P6({between:["timelineKey","topicKey"],cardinality:"1:n"});disposalTraces=new gU(100);molecules=new Map;moleculeJoins=new P6({between:["moleculeKey","joinKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});moleculeGraph=new P6({between:["upstreamMoleculeKey","downstreamMoleculeKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});moleculeData=new P6({between:["moleculeKey","stateFamilyKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});miscResources=new Map;on={atomCreation:new K$,atomDisposal:new K$,selectorCreation:new K$,selectorDisposal:new K$,timelineCreation:new K$,transactionCreation:new K$,transactionApplying:new a8(null),operationClose:new K$,moleculeCreation:new K$,moleculeDisposal:new K$};operation={open:!1};config={name:"IMPLICIT_STORE",lifespan:"ephemeral"};loggers=[new t8("warn",($,T,W)=>!O3(W))];logger={error:(...$)=>{for(let T of this.loggers)T.error(...$)},info:(...$)=>{for(let T of this.loggers)T.info(...$)},warn:(...$)=>{for(let T of this.loggers)T.warn(...$)}};constructor($,T=null){if(this.config={...T?.config,...$},T!==null){if(this.valueMap=new Map(T?.valueMap),this.operation={...T?.operation},L1(T))this.transactionMeta={epoch:new Map(T?.transactionMeta.epoch),actionContinuities:new P6(T?.transactionMeta.actionContinuities.toJSON())};for(let[,U]of T.families){if(U.internalRoles?.includes("mutable")||U.internalRoles?.includes("join"))continue;U.install(this)}let W=new Set;for(let[,U]of T.atoms){if(W.has(U.key))continue;if(U.install(this),U.type==="mutable_atom"){let X=l0(T,U),Y=F3(U);W.add(X.key),W.add(Y.key)}}for(let[,U]of T.readonlySelectors)U.install(this);for(let[,U]of T.writableSelectors){if(W.has(U.key))continue;U.install(this)}for(let[,U]of T.transactions)U.install(this);for(let[,U]of T.timelines)U.install(this)}}}var l5={get STORE(){return globalThis.ATOM_IO_IMPLICIT_STORE??=new H3({name:"IMPLICIT_STORE",lifespan:"ephemeral"}),globalThis.ATOM_IO_IMPLICIT_STORE}};function j4($,T){let W,U=$;while(U!==null){switch(T.type){case"atom":case"mutable_atom":W=U.atoms.get(T.key);break;case"writable_pure_selector":case"writable_held_selector":W=U.writableSelectors.get(T.key);break;case"readonly_pure_selector":case"readonly_held_selector":W=U.readonlySelectors.get(T.key);break;case"atom_family":case"mutable_atom_family":case"writable_pure_selector_family":case"readonly_pure_selector_family":case"writable_held_selector_family":case"readonly_held_selector_family":W=U.families.get(T.key);break;case"timeline":W=U.timelines.get(T.key);break;case"transaction":W=U.transactions.get(T.key);break}if(W)return W;U=U.child}throw new wW(T,$)}var D3=($,T)=>{let W=s($);if(W.operation.open)return W.operation.prev.get(T.key);return W.valueMap.get(T.key)};var U_=($,T)=>{let W=s($);return _3(T,$).map((X)=>{let Y=W.atoms.get(X);if(Y===void 0)throw new Error(`Atom "${X}", a dependency of selector "${T.key}", not found in store "${$.config.name}".`);return Y.subject.subscribe(`${T.type}:${T.key}`,(_)=>{$.logger.info("\uD83D\uDCE2",T.type,T.key,"root",X,"went",_.oldValue,"->",_.newValue);let w=D3(W,T),G=S1(W,T);$.logger.info("\u2728",T.type,T.key,"went",w,"->",G),T.subject.next({newValue:G,oldValue:w})})})};function HW($,T,W,U){function X(z){if($.operation.open){let F=$.on.operationClose.subscribe(`state subscription ${W}`,()=>{F(),U(z)})}else U(z)}let Y=j4($,T);$.logger.info("\uD83D\uDC40",Y.type,Y.key,`Adding subscription "${W}"`);let _=Y.type==="writable_pure_selector"||Y.type==="readonly_pure_selector",w=null,G=X;if(_)w=U_($,Y),G=(z)=>{if(w)w.length=0,w.push(...U_($,Y));X(z)};let J=Y.subject.subscribe(W,G);return()=>{if($.logger.info("\uD83D\uDE48",Y.type,Y.key,`Removing subscription "${W}"`),J(),w)for(let z of w)z()}}var Q3=($,T,W,U)=>{let X=j4($,T);$.logger.info("\uD83D\uDC40","timeline",T.key,`Adding subscription "${W}"`);let Y=X.subject.subscribe(W,U);return()=>{$.logger.info("\uD83D\uDE48","timeline",T.key,`Removing subscription "${W}" from timeline`),Y()}};class X_{initializeState($,T){let W=`*${$.key}`;T.atoms.delete(W),T.valueMap.delete(W);let U=$.family?{key:`*${$.family.key}`,subKey:$.family.subKey}:void 0,X=Y_(T,{key:W,default:null},U);if(T.parent?.valueMap.has(W)){let Y=T.parent.valueMap.get(W);T.valueMap.set(W,Y)}return X}unsubscribeFromInnerValue;unsubscribeFromState;observeCore($,T,W){let U=`tracker:${W.config.name}:${l4(W)?W.transactionMeta.update.key:"main"}:${$.key}`,X=zW(W,$);this.unsubscribeFromInnerValue=X.subscribe(U,(Y)=>{I1(W,T,Y)}),this.unsubscribeFromState=HW(W,$,U,(Y)=>{if(Y.newValue!==Y.oldValue)this.unsubscribeFromInnerValue(),this.unsubscribeFromInnerValue=Y.newValue.subscribe(U,(_)=>{I1(W,T,_)})})}updateCore($,T,W){let U=`tracker:${W.config.name}:${l4(W)?W.transactionMeta.update.key:"main"}:${$.key}`;HW(W,T,U,({newValue:X,oldValue:Y})=>{let _=W.timelineTopics.getRelatedKey(T.key);if(_){if(W.timelines.get(_)?.timeTraveling){let J=Q3(W,{key:_,type:"timeline"},U,(H)=>{J(),I1(W,$,(z)=>{if(H==="redo"&&X)z.do(X);else if(H==="undo"&&Y)z.undo(Y);return z})});return}}let w=W.on.operationClose.subscribe(U,()=>{w();let G=zW(W,$),J=X===null?-1:G.getUpdateNumber(X),H=J-G.cacheUpdateNumber;if(X&&H===1)I1(W,$,(z)=>(z.do(X),z));else W.logger.info("\u274C","mutable_atom",$.key,`could not be updated. Expected update number ${G.cacheUpdateNumber+1}, but got ${J}`)})})}mutableState;latestUpdateState;[Symbol.dispose];constructor($,T){this.mutableState=$;let W=s(T);this.latestUpdateState=this.initializeState($,W),this.observeCore($,this.latestUpdateState,W),this.updateCore($,this.latestUpdateState,W),W.trackers.set($.key,this),this[Symbol.dispose]=()=>{this.unsubscribeFromInnerValue(),this.unsubscribeFromState(),W.trackers.delete($.key)}}}var l0=($,T)=>{if(T.family){let U=s($),Y={key:`${T.family.key}:JSON`,type:"writable_pure_selector_family"},_=j4(U,Y),w=JSON.parse(T.family.subKey);return r4($,_,w)}return{type:"writable_pure_selector",key:`${T.key}:JSON`}};var F3=($)=>{let W={type:"atom",key:`*${$.key}`};if($.family)W.family={key:`*${$.family.key}`,subKey:$.family.subKey};return W};function W3($){return typeof $==="object"&&$!==null&&"do"in $&&"undo"in $&&"subscribe"in $}function JW($,T,W){let U=W.valueMap.get(T.key),X=$.valueMap.get(T.key);if(U!==X)return X;if(U===void 0)return T.default();W.logger.info("\uD83D\uDCC3","atom",T.key,"copying");let Y=T.toJson(U),_=T.fromJson(Y);return $.valueMap.set(T.key,_),new X_(T,W),_}function I4($,T,W,U){let X=$.valueMap.get(T);if(X instanceof XW)X.use(W);if(W instanceof Promise){let Y=new XW(W);return $.valueMap.set(T,Y),Y.then((_)=>{I4($,T,_,U),U.next({newValue:_,oldValue:Y})}).catch((_)=>{$.logger.error("\uD83D\uDCA5","state",T,"rejected:",_)}),Y}return $.valueMap.set(T,W),W}var n5=($,T)=>{let W=T.valueMap.get($.key);if($.type==="mutable_atom"&&l4(T)){let{parent:U}=T;W=JW(T,$,U)}return W},$3=($,T)=>{let W=T.valueMap.get($);if(W instanceof XW){let U=W,X=T.writableSelectors.get($)??T.readonlySelectors.get($);if(X)U.use(X.get());return}if(T.operation.open)T.operation.prev.set($,W);T.valueMap.delete($),T.logger.info("\uD83D\uDDD1","state",$,"evicted")};var U3=($,T)=>{return s($).atomsThatAreDefault.has(T)},Z3=($,T)=>{let W=s($);W.atomsThatAreDefault=new Set(W.atomsThatAreDefault).add(T)},X3=($,T)=>{let W=s($);W.atomsThatAreDefault=new Set(s($).atomsThatAreDefault),W.atomsThatAreDefault.delete(T)};function Y_($,T,W){let{key:X,default:Y}=T;$.logger.info("\uD83D\uDD28","atom",X,`creating in store "${$.config.name}"`);let _=s($),w=_.atoms.get(X);if(w&&w.type==="atom")return $.logger.error("\u274C","atom",X,"Tried to create atom, but it already exists in the store."),_W(w);let G=new K$,J={...T,type:"atom",install:(F)=>{return F.logger.info("\uD83D\uDEE0\uFE0F","atom",X,`installing in store "${F.config.name}"`),Y_(F,T,W)},subject:G};if(W)J.family=W;let H=Y;if(Y instanceof Function)H=Y();_.atoms.set(X,J),Z3($,X),I4(_,X,H,G);let z=_W(J);if(T.effects){let F=0,Q=[];for(let V of T.effects){let K=V({setSelf:(I)=>{I1($,z,I)},onSet:(I)=>HW($,z,`effect[${F}]`,I)});if(K)Q.push(K);++F}J.cleanup=()=>{for(let V of Q)V()}}return z}class r0 extends Set{mode="record";subject=new K$;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor($,T=0){super($);if($ instanceof r0)this.parent=$,this.cacheUpdateNumber=$.cacheUpdateNumber;if(T)this.cacheLimit=T,this.cache=new Array(T),this.subscribe("auto cache",(W)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=W})}toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON($){let T=new r0($.members,$.cacheLimit);return T.cache=$.cache,T.cacheIdx=$.cacheIdx,T.cacheUpdateNumber=$.cacheUpdateNumber,T}add($){let T=super.add($);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${R4($)}`);return T}clear(){let $=this.mode==="record"?[...this]:null;if(super.clear(),$)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify($)}`)}delete($){let T=super.delete($);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${R4($)}`);return T}parent=null;child=null;transactionUpdates=null;transaction($){this.mode="transaction",this.transactionUpdates=[],this.child=new r0(this);let T=this.child._subscribe("transaction",(W)=>{this.transactionUpdates?.push(W)});try{if($(this.child)){for(let U of this.transactionUpdates)this.doStep(U);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{T(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe($,T){return this.subject.subscribe($,T)}subscribe($,T){return this.subject.subscribe($,(W)=>{T(`${this.cacheUpdateNumber}=${W}`)})}emit($){this.subject.next($)}doStep($){let T=$.indexOf(":"),W=$.substring(0,T),U=$.substring(T+1);switch(W){case"add":this.add(JSON.parse(U));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(U));break;case"tx":for(let X of U.split(";"))this.doStep(X)}}getUpdateNumber($){let T=$.indexOf("=");return Number($.substring(0,T))}do($){let T=$.indexOf("="),W=Number($.substring(0,T)),U=W-this.cacheUpdateNumber;if(U>0){if(U===1){this.mode="playback";let Y=$.substring(T+1);return this.doStep(Y),this.mode="record",this.cacheUpdateNumber=W,null}return this.cacheUpdateNumber+1}if(Math.abs(U)<this.cacheLimit){let Y=this.cacheIdx+U;if(this.cache[Y]===$)return null;this.mode="playback";let w=!1;while(!w){this.cacheIdx%=this.cacheLimit;let J=this.cache[this.cacheIdx];if(this.cacheIdx--,!J)return"OUT_OF_RANGE";this.undo(J),w=this.cacheIdx===Y-1}let G=$.substring(T+1);return this.doStep(G),this.mode="record",this.cacheUpdateNumber=W,null}return"OUT_OF_RANGE"}undoStep($){let T=$.indexOf(":"),W=$.substring(0,T),U=$.substring(T+1);switch(W){case"add":this.delete(JSON.parse(U));break;case"del":this.add(JSON.parse(U));break;case"clear":{let X=JSON.parse(U);for(let Y of X)this.add(Y);break}case"tx":{let X=U.split(";");for(let Y=X.length-1;Y>=0;Y--)this.undoStep(X[Y])}}}undo($){let T=$.indexOf("=");if(Number($.substring(0,T))===this.cacheUpdateNumber){this.mode="playback";let U=$.substring(T+1);return this.undoStep(U),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}}function O3($){return $.startsWith("\uD83D\uDD0D ")}class oU{listeners;globalListeners;handleEvent($,...T){for(let U of this.globalListeners)U($,...T);let W=this.listeners.get($);if(W)for(let U of W)U(...T)}id="no_id_retrieved";emit;constructor($){this.emit=$,this.listeners=new Map,this.globalListeners=new Set}on($,T){let W=this.listeners.get($);if(W)W.add(T);else this.listeners.set($,new Set([T]));return this}onAny($){return this.globalListeners.add($),this}off($,T){let W=this.listeners.get($);if(W)if(T)W.delete(T);else this.listeners.delete($);return this}offAny($){return this.globalListeners.delete($),this}}class V3 extends oU{in;out;id="no_id_retrieved";disposalFunctions=[];constructor($){super((...T)=>{return this.out.next(T),this});this.id=$,this.in=new K$,this.out=new K$,this.in.subscribe("socket",(T)=>{this.handleEvent(...T)})}dispose(){for(let $ of this.disposalFunctions)$()}}class __ extends oU{incompleteData="";unprocessedEvents=[];relays;relayServices;process;id="#####";log(...$){this.process.stderr.write(R4($.map((T)=>T instanceof r0?`{ ${T.toJSON().members.join(" | ")} }`:T))+"\x03")}logger={info:(...$)=>{this.log("i",...$)},warn:(...$)=>{this.log("w",...$)},error:(...$)=>{this.log("e",...$)}};constructor(){super(($,...T)=>{let W=JSON.stringify([$,...T]);return this.process.stdout.write(W+"\x03"),this});if(this.process=process,this.process.stdin.resume(),this.relays=new Map,this.relayServices=[],this.process.stdin.on("data",($)=>{let T=$.toString();this.unprocessedEvents.push(...T.split("\x03"));let W=this.unprocessedEvents.shift();this.incompleteData+=W??"";try{let U=YW(this.incompleteData);this.logger.info("\uD83C\uDFB0","received",U),this.handleEvent(...U);while(this.unprocessedEvents.length>0){let X=this.unprocessedEvents.shift();if(X){if(this.unprocessedEvents.length===0)this.incompleteData=X;let Y=YW(X);this.handleEvent(...Y)}}this.incompleteData=""}catch(U){if(U instanceof Error)this.logger.error("\u2757",U.message,U.cause,U.stack)}}),this.on("exit",()=>{this.logger.info("\uD83D\uDD25",this.id,'received "exit"'),process.exit(0)}),process.on("exit",($)=>{this.logger.info("\uD83D\uDD25",this.id,`exited with code ${$}`)}),process.on("end",()=>{this.logger.info("\uD83D\uDD25",this.id,"ended"),process.exit(0)}),process.on("SIGTERM",()=>{this.logger.error("\uD83D\uDD25",this.id,"terminated"),process.exit(0)}),process.on("SIGINT",()=>{this.logger.error("\uD83D\uDD25",this.id,"interrupted"),process.exit(0)}),process.pid)this.id=process.pid?.toString();this.on("user-joins",($)=>{this.logger.info("\uD83D\uDC64","user",$,"joined");let T=new V3(`user:${$}`);this.relays.set($,T),this.logger.info("\uD83D\uDD17","attaching services:",`[${[...this.relayServices.keys()].join(", ")}]`);for(let W of this.relayServices){let U=W(T);if(U)T.disposalFunctions.push(U)}this.on(`user:${$}`,(...W)=>{T.in.next(W)}),T.out.subscribe("socket",(W)=>{this.emit(...W)})}),this.on("user-leaves",($)=>{let T=this.relays.get($);if(this.off(`relay:${$}`),T)T.dispose(),this.relays.delete($)}),process.stdout.write("ALIVE")}relay($){this.logger.info("\uD83D\uDD17","running relay method"),this.relayServices.push($)}}var dX={};N1(dX,{xid:()=>hB,void:()=>XR,uuidv7:()=>PB,uuidv6:()=>qB,uuidv4:()=>vB,uuid:()=>kB,url:()=>CB,uppercase:()=>xW,unknown:()=>yX,union:()=>pX,undefined:()=>WR,ulid:()=>yB,uint64:()=>$R,uint32:()=>aB,tuple:()=>HR,trim:()=>mW,treeifyError:()=>K_,transform:()=>N9,toUpperCase:()=>uW,toLowerCase:()=>cW,toJSONSchema:()=>cG,templateLiteral:()=>AR,symbol:()=>TR,superRefine:()=>EF,success:()=>KR,stringbool:()=>SR,string:()=>aG,strictObject:()=>JR,startsWith:()=>fW,size:()=>PW,setErrorMap:()=>qR,set:()=>DR,safeParseAsync:()=>nG,safeParse:()=>iG,registry:()=>zX,regexes:()=>$0,regex:()=>CW,refine:()=>KF,record:()=>rH,readonly:()=>FF,property:()=>bG,promise:()=>MR,prettifyError:()=>E_,preprocess:()=>RR,prefault:()=>YF,positive:()=>PG,pipe:()=>mX,partialRecord:()=>FR,parseAsync:()=>rG,parse:()=>lG,overwrite:()=>l6,optional:()=>hX,object:()=>wR,number:()=>jH,nullish:()=>VR,nullable:()=>gX,null:()=>hH,normalize:()=>gW,nonpositive:()=>jG,nonoptional:()=>_F,nonnegative:()=>xG,never:()=>cX,negative:()=>CG,nativeEnum:()=>QR,nanoid:()=>xB,nan:()=>ER,multipleOf:()=>W0,minSize:()=>U0,minLength:()=>v1,mime:()=>hW,maxSize:()=>t0,maxLength:()=>a0,map:()=>OR,lte:()=>Y6,lt:()=>o6,lowercase:()=>jW,looseObject:()=>GR,locales:()=>kW,literal:()=>sH,length:()=>s0,lazy:()=>QF,ksuid:()=>gB,keyof:()=>_R,jwt:()=>rB,json:()=>BR,iso:()=>jX,ipv6:()=>cB,ipv4:()=>mB,intersection:()=>dH,int64:()=>eB,int32:()=>tB,int:()=>sG,instanceof:()=>LR,includes:()=>bW,guid:()=>IB,gte:()=>b4,gt:()=>d6,globalRegistry:()=>C6,getErrorMap:()=>PR,function:()=>mG,formatError:()=>NW,float64:()=>nB,float32:()=>iB,flattenError:()=>MW,file:()=>ZR,enum:()=>tH,endsWith:()=>yW,emoji:()=>jB,email:()=>RB,e164:()=>lB,discriminatedUnion:()=>zR,date:()=>YR,custom:()=>NR,cuid2:()=>fB,cuid:()=>bB,core:()=>r6,config:()=>t$,coerce:()=>tG,clone:()=>i4,cidrv6:()=>pB,cidrv4:()=>uB,check:()=>VF,catch:()=>GF,boolean:()=>xH,bigint:()=>sB,base64url:()=>dB,base64:()=>oB,array:()=>E9,any:()=>UR,_default:()=>UF,_ZodString:()=>eG,ZodXID:()=>w9,ZodVoid:()=>cH,ZodUnknown:()=>K9,ZodUnion:()=>A9,ZodUndefined:()=>fH,ZodUUID:()=>i6,ZodURL:()=>T9,ZodULID:()=>_9,ZodType:()=>G$,ZodTuple:()=>lH,ZodTransform:()=>$F,ZodTemplateLiteral:()=>OF,ZodSymbol:()=>bH,ZodSuccess:()=>wF,ZodStringFormat:()=>f$,ZodString:()=>xX,ZodSet:()=>nH,ZodRecord:()=>M9,ZodRealError:()=>$T,ZodReadonly:()=>HF,ZodPromise:()=>ZF,ZodPrefault:()=>XF,ZodPipe:()=>B9,ZodOptional:()=>L9,ZodObject:()=>uX,ZodNumberFormat:()=>TT,ZodNumber:()=>oW,ZodNullable:()=>TF,ZodNull:()=>yH,ZodNonOptional:()=>S9,ZodNever:()=>mH,ZodNanoID:()=>U9,ZodNaN:()=>zF,ZodMap:()=>iH,ZodLiteral:()=>aH,ZodLazy:()=>DF,ZodKSUID:()=>J9,ZodJWT:()=>Z9,ZodIssueCode:()=>IR,ZodIntersection:()=>oH,ZodIPv6:()=>z9,ZodIPv4:()=>G9,ZodGUID:()=>fX,ZodFile:()=>eH,ZodError:()=>EB,ZodEnum:()=>rW,ZodEmoji:()=>W9,ZodEmail:()=>$9,ZodE164:()=>Q9,ZodDiscriminatedUnion:()=>pH,ZodDefault:()=>WF,ZodDate:()=>bX,ZodCustom:()=>oX,ZodCatch:()=>JF,ZodCUID2:()=>Y9,ZodCUID:()=>X9,ZodCIDRv6:()=>F9,ZodCIDRv4:()=>H9,ZodBoolean:()=>dW,ZodBigIntFormat:()=>V9,ZodBigInt:()=>lW,ZodBase64URL:()=>D9,ZodBase64:()=>O9,ZodArray:()=>uH,ZodAny:()=>gH,NEVER:()=>vR,$output:()=>$G,$input:()=>TG,$brand:()=>w_});var r6={};N1(r6,{version:()=>Ow,util:()=>h,treeifyError:()=>K_,toJSONSchema:()=>cG,toDotPath:()=>A3,safeParseAsync:()=>M_,safeParse:()=>A_,registry:()=>zX,regexes:()=>$0,prettifyError:()=>E_,parseAsync:()=>tU,parse:()=>iU,locales:()=>kW,isValidJWT:()=>h3,isValidBase64URL:()=>y3,isValidBase64:()=>xw,globalRegistry:()=>C6,globalConfig:()=>FW,function:()=>mG,formatError:()=>NW,flattenError:()=>MW,config:()=>t$,clone:()=>i4,_xid:()=>NX,_void:()=>IG,_uuidv7:()=>QX,_uuidv6:()=>DX,_uuidv4:()=>OX,_uuid:()=>FX,_url:()=>ZX,_uppercase:()=>xW,_unknown:()=>BG,_union:()=>nS,_undefined:()=>NG,_ulid:()=>MX,_uint64:()=>AG,_uint32:()=>DG,_tuple:()=>yG,_trim:()=>mW,_transform:()=>XB,_toUpperCase:()=>uW,_toLowerCase:()=>cW,_templateLiteral:()=>OB,_symbol:()=>MG,_success:()=>GB,_stringbool:()=>gG,_string:()=>WG,_startsWith:()=>fW,_size:()=>PW,_set:()=>$B,_safeParseAsync:()=>sU,_safeParse:()=>aU,_regex:()=>CW,_refine:()=>ZB,_record:()=>sS,_readonly:()=>FB,_property:()=>bG,_promise:()=>QB,_positive:()=>PG,_pipe:()=>HB,_parseAsync:()=>nU,_parse:()=>rU,_overwrite:()=>l6,_optional:()=>YB,_number:()=>JG,_nullable:()=>_B,_null:()=>LG,_normalize:()=>gW,_nonpositive:()=>jG,_nonoptional:()=>JB,_nonnegative:()=>xG,_never:()=>RG,_negative:()=>CG,_nativeEnum:()=>WB,_nanoid:()=>KX,_nan:()=>qG,_multipleOf:()=>W0,_minSize:()=>U0,_minLength:()=>v1,_min:()=>b4,_mime:()=>hW,_maxSize:()=>t0,_maxLength:()=>a0,_max:()=>Y6,_map:()=>eS,_lte:()=>Y6,_lt:()=>o6,_lowercase:()=>jW,_literal:()=>UB,_length:()=>s0,_lazy:()=>DB,_ksuid:()=>LX,_jwt:()=>PX,_isoTime:()=>_G,_isoDuration:()=>wG,_isoDateTime:()=>XG,_isoDate:()=>YG,_ipv6:()=>BX,_ipv4:()=>SX,_intersection:()=>aS,_int64:()=>EG,_int32:()=>OG,_int:()=>zG,_includes:()=>bW,_guid:()=>qW,_gte:()=>b4,_gt:()=>d6,_float64:()=>FG,_float32:()=>HG,_file:()=>hG,_enum:()=>TB,_endsWith:()=>yW,_emoji:()=>VX,_email:()=>HX,_e164:()=>qX,_discriminatedUnion:()=>tS,_default:()=>wB,_date:()=>kG,_custom:()=>pW,_cuid2:()=>AX,_cuid:()=>EX,_coercedString:()=>UG,_coercedNumber:()=>GG,_coercedDate:()=>vG,_coercedBoolean:()=>ZG,_coercedBigint:()=>KG,_cidrv6:()=>IX,_cidrv4:()=>RX,_catch:()=>zB,_boolean:()=>QG,_bigint:()=>VG,_base64url:()=>vX,_base64:()=>kX,_array:()=>fG,_any:()=>SG,JSONSchemaGenerator:()=>CX,JSONSchema:()=>RH,Doc:()=>XX,$output:()=>$G,$input:()=>TG,$constructor:()=>E,$brand:()=>w_,$ZodXID:()=>Sw,$ZodVoid:()=>lw,$ZodUnknown:()=>BW,$ZodUnion:()=>GX,$ZodUndefined:()=>uw,$ZodUUID:()=>Zw,$ZodURL:()=>Kw,$ZodULID:()=>Lw,$ZodType:()=>T$,$ZodTuple:()=>T0,$ZodTransform:()=>XJ,$ZodTemplateLiteral:()=>DJ,$ZodSymbol:()=>cw,$ZodSuccess:()=>zJ,$ZodStringFormat:()=>v$,$ZodString:()=>LW,$ZodSet:()=>$J,$ZodRegistry:()=>vW,$ZodRecord:()=>sw,$ZodRealError:()=>i0,$ZodReadonly:()=>OJ,$ZodPromise:()=>QJ,$ZodPrefault:()=>JJ,$ZodPipe:()=>RW,$ZodOptional:()=>YJ,$ZodObject:()=>nw,$ZodNumberFormat:()=>gw,$ZodNumber:()=>wX,$ZodNullable:()=>_J,$ZodNull:()=>pw,$ZodNonOptional:()=>GJ,$ZodNever:()=>dw,$ZodNanoID:()=>Aw,$ZodNaN:()=>FJ,$ZodMap:()=>ew,$ZodLiteral:()=>WJ,$ZodLazy:()=>ZJ,$ZodKSUID:()=>Bw,$ZodJWT:()=>hw,$ZodIntersection:()=>aw,$ZodISOTime:()=>kw,$ZodISODuration:()=>vw,$ZodISODateTime:()=>Rw,$ZodISODate:()=>Iw,$ZodIPv6:()=>Pw,$ZodIPv4:()=>qw,$ZodGUID:()=>Qw,$ZodFunction:()=>e0,$ZodFile:()=>UJ,$ZodError:()=>AW,$ZodEnum:()=>TJ,$ZodEmoji:()=>Ew,$ZodEmail:()=>Vw,$ZodE164:()=>yw,$ZodDiscriminatedUnion:()=>tw,$ZodDefault:()=>wJ,$ZodDate:()=>rw,$ZodCustom:()=>VJ,$ZodCheckUpperCase:()=>_w,$ZodCheckStringFormat:()=>n0,$ZodCheckStartsWith:()=>Jw,$ZodCheckSizeEquals:()=>$w,$ZodCheckRegex:()=>Xw,$ZodCheckProperty:()=>zw,$ZodCheckOverwrite:()=>Fw,$ZodCheckNumberFormat:()=>t_,$ZodCheckMultipleOf:()=>n_,$ZodCheckMinSize:()=>e_,$ZodCheckMinLength:()=>Ww,$ZodCheckMimeType:()=>Hw,$ZodCheckMaxSize:()=>s_,$ZodCheckMaxLength:()=>Tw,$ZodCheckLowerCase:()=>Yw,$ZodCheckLessThan:()=>WX,$ZodCheckLengthEquals:()=>Uw,$ZodCheckIncludes:()=>ww,$ZodCheckGreaterThan:()=>UX,$ZodCheckEndsWith:()=>Gw,$ZodCheckBigIntFormat:()=>a_,$ZodCheck:()=>u$,$ZodCatch:()=>HJ,$ZodCUID2:()=>Nw,$ZodCUID:()=>Mw,$ZodCIDRv6:()=>jw,$ZodCIDRv4:()=>Cw,$ZodBoolean:()=>SW,$ZodBigIntFormat:()=>mw,$ZodBigInt:()=>JX,$ZodBase64URL:()=>fw,$ZodBase64:()=>bw,$ZodAsyncError:()=>u6,$ZodArray:()=>iw,$ZodAny:()=>ow});function E($,T,W){function U(w,G){var J;Object.defineProperty(w,"_zod",{value:w._zod??{},enumerable:!1}),(J=w._zod).traits??(J.traits=new Set),w._zod.traits.add($),T(w,G);for(let H in _.prototype)Object.defineProperty(w,H,{value:_.prototype[H].bind(w)});w._zod.constr=_,w._zod.def=G}let X=W?.Parent??Object;class Y extends X{}Object.defineProperty(Y,"name",{value:$});function _(w){var G;let J=W?.Parent?new Y:this;U(J,w),(G=J._zod).deferred??(G.deferred=[]);for(let H of J._zod.deferred)H();return J}return Object.defineProperty(_,"init",{value:U}),Object.defineProperty(_,Symbol.hasInstance,{value:(w)=>{if(W?.Parent&&w instanceof W.Parent)return!0;return w?._zod?.traits?.has($)}}),Object.defineProperty(_,"name",{value:$}),_}var w_=Symbol("zod_brand");class u6 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}var FW={};function t$($){if($)Object.assign(FW,$);return FW}var h={};N1(h,{unwrapMessage:()=>OW,stringifyPrimitive:()=>c,required:()=>iM,randomString:()=>dU,propertyKeyTypes:()=>VW,promiseAllObject:()=>gM,primitiveTypes:()=>O_,prefixIssues:()=>x4,pick:()=>pM,partial:()=>rM,optionalKeys:()=>D_,omit:()=>oM,numKeys:()=>mM,nullish:()=>k1,normalizeParams:()=>j,merge:()=>lM,jsonStringifyReplacer:()=>G_,joinValues:()=>R,issue:()=>V_,isPlainObject:()=>ZW,isObject:()=>lU,getValidEnumValues:()=>yM,getSizableOrigin:()=>KW,getParsedType:()=>cM,getLengthableOrigin:()=>EW,getElementAtPath:()=>hM,floatSafeRemainder:()=>z_,finalizeIssue:()=>n4,extend:()=>dM,escapeRegex:()=>p6,esc:()=>a1,defineLazy:()=>N$,createTransparentProxy:()=>uM,clone:()=>i4,cleanRegex:()=>QW,cleanEnum:()=>nM,cached:()=>DW,assignProp:()=>H_,assertNotEqual:()=>jM,assertNever:()=>bM,assertIs:()=>xM,assertEqual:()=>CM,assert:()=>fM,allowsEval:()=>F_,aborted:()=>s1,NUMBER_FORMAT_RANGES:()=>Q_,Class:()=>K3,BIGINT_FORMAT_RANGES:()=>Z_});function CM($){return $}function jM($){return $}function xM($){}function bM($){throw new Error}function fM($){}function yM($){let T=Object.keys($).filter((U)=>typeof $[$[U]]!=="number"),W={};for(let U of T)W[U]=$[U];return Object.values(W)}function R($,T="|"){return $.map((W)=>c(W)).join(T)}function G_($,T){if(typeof T==="bigint")return T.toString();return T}function DW($){return{get value(){{let W=$();return Object.defineProperty(this,"value",{value:W}),W}throw new Error("cached value already set")}}}function k1($){return $===null||$===void 0}function QW($){let T=$.startsWith("^")?1:0,W=$.endsWith("$")?$.length-1:$.length;return $.slice(T,W)}function z_($,T){let W=($.toString().split(".")[1]||"").length,U=(T.toString().split(".")[1]||"").length,X=W>U?W:U,Y=Number.parseInt($.toFixed(X).replace(".","")),_=Number.parseInt(T.toFixed(X).replace(".",""));return Y%_/10**X}function N$($,T,W){Object.defineProperty($,T,{get(){{let X=W();return $[T]=X,X}throw new Error("cached value already set")},set(X){Object.defineProperty($,T,{value:X})},configurable:!0})}function H_($,T,W){Object.defineProperty($,T,{value:W,writable:!0,enumerable:!0,configurable:!0})}function hM($,T){if(!T)return $;return T.reduce((W,U)=>W?.[U],$)}function gM($){let T=Object.keys($),W=T.map((U)=>$[U]);return Promise.all(W).then((U)=>{let X={};for(let Y=0;Y<T.length;Y++)X[T[Y]]=U[Y];return X})}function dU($=10){let W="";for(let U=0;U<$;U++)W+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return W}function a1($){return JSON.stringify($)}function lU($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var F_=DW(()=>{try{return new Function(""),!0}catch($){return!1}});function ZW($){return typeof $==="object"&&$!==null&&Object.getPrototypeOf($)===Object.prototype}function mM($){let T=0;for(let W in $)if(Object.prototype.hasOwnProperty.call($,W))T++;return T}var cM=($)=>{let T=typeof $;switch(T){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN($)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray($))return"array";if($===null)return"null";if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return"promise";if(typeof Map!=="undefined"&&$ instanceof Map)return"map";if(typeof Set!=="undefined"&&$ instanceof Set)return"set";if(typeof Date!=="undefined"&&$ instanceof Date)return"date";if(typeof File!=="undefined"&&$ instanceof File)return"file";return"object";default:throw new Error(`Unknown data type: ${T}`)}},VW=new Set(["string","number","symbol"]),O_=new Set(["string","number","bigint","boolean","symbol","undefined"]);function p6($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i4($,T,W){let U=new $._zod.constr(T??$._zod.def);if(!T||W?.parent)U._zod.parent=$;return U}function j($){let T=$;if(!T)return{};if(typeof T==="string")return{error:()=>T};if(T?.message!==void 0){if(T?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");T.error=T.message}if(delete T.message,typeof T.error==="string")return{...T,error:()=>T.error};return T}function uM($){let T;return new Proxy({},{get(W,U,X){return T??(T=$()),Reflect.get(T,U,X)},set(W,U,X,Y){return T??(T=$()),Reflect.set(T,U,X,Y)},has(W,U){return T??(T=$()),Reflect.has(T,U)},deleteProperty(W,U){return T??(T=$()),Reflect.deleteProperty(T,U)},ownKeys(W){return T??(T=$()),Reflect.ownKeys(T)},getOwnPropertyDescriptor(W,U){return T??(T=$()),Reflect.getOwnPropertyDescriptor(T,U)},defineProperty(W,U,X){return T??(T=$()),Reflect.defineProperty(T,U,X)}})}function c($){if(typeof $==="bigint")return $.toString()+"n";if(typeof $==="string")return`"${$}"`;return`${$}`}function D_($){return Object.keys($).filter((T)=>{return $[T]._zod.optin==="optional"&&$[T]._zod.optout==="optional"})}var Q_={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Z_={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function pM($,T){let W={},U=$._zod.def;for(let X in T){if(!(X in U.shape))throw new Error(`Unrecognized key: "${X}"`);if(!T[X])continue;W[X]=U.shape[X]}return i4($,{...$._zod.def,shape:W,checks:[]})}function oM($,T){let W={...$._zod.def.shape},U=$._zod.def;for(let X in T){if(!(X in U.shape))throw new Error(`Unrecognized key: "${X}"`);if(!T[X])continue;delete W[X]}return i4($,{...$._zod.def,shape:W,checks:[]})}function dM($,T){let W={...$._zod.def,get shape(){let U={...$._zod.def.shape,...T};return H_(this,"shape",U),U},checks:[]};return i4($,W)}function lM($,T){return i4($,{...$._zod.def,get shape(){let W={...$._zod.def.shape,...T._zod.def.shape};return H_(this,"shape",W),W},catchall:T._zod.def.catchall,checks:[]})}function rM($,T,W){let U=T._zod.def.shape,X={...U};if(W)for(let Y in W){if(!(Y in U))throw new Error(`Unrecognized key: "${Y}"`);if(!W[Y])continue;X[Y]=$?new $({type:"optional",innerType:U[Y]}):U[Y]}else for(let Y in U)X[Y]=$?new $({type:"optional",innerType:U[Y]}):U[Y];return i4(T,{...T._zod.def,shape:X,checks:[]})}function iM($,T,W){let U=T._zod.def.shape,X={...U};if(W)for(let Y in W){if(!(Y in X))throw new Error(`Unrecognized key: "${Y}"`);if(!W[Y])continue;X[Y]=new $({type:"nonoptional",innerType:U[Y]})}else for(let Y in U)X[Y]=new $({type:"nonoptional",innerType:U[Y]});return i4(T,{...T._zod.def,shape:X,checks:[]})}function s1($,T=0){for(let W=T;W<$.issues.length;W++)if($.issues[W].continue!==!0)return!0;return!1}function x4($,T){return T.map((W)=>{var U;return(U=W).path??(U.path=[]),W.path.unshift($),W})}function OW($){return typeof $==="string"?$:$?.message}function n4($,T,W){let U={...$,path:$.path??[]};if(!$.message){let X=OW($.inst?._zod.def?.error?.($))??OW(T?.error?.($))??OW(W.customError?.($))??OW(W.localeError?.($))??"Invalid input";U.message=X}if(delete U.inst,delete U.continue,!T?.reportInput)delete U.input;return U}function KW($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function EW($){if(Array.isArray($))return"array";if(typeof $==="string")return"string";return"unknown"}function V_(...$){let[T,W,U]=$;if(typeof T==="string")return{message:T,code:"custom",input:W,inst:U};return{...T}}function nM($){return Object.entries($).filter(([T,W])=>{return Number.isNaN(Number.parseInt(T,10))}).map((T)=>T[1])}class K3{constructor(...$){}}var E3=($,T)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:T,enumerable:!1}),Object.defineProperty($,"message",{get(){return JSON.stringify(T,G_,2)},enumerable:!0})},AW=E("$ZodError",E3),i0=E("$ZodError",E3,{Parent:Error});function MW($,T=(W)=>W.message){let W={},U=[];for(let X of $.issues)if(X.path.length>0)W[X.path[0]]=W[X.path[0]]||[],W[X.path[0]].push(T(X));else U.push(T(X));return{formErrors:U,fieldErrors:W}}function NW($,T){let W=T||function(Y){return Y.message},U={_errors:[]},X=(Y)=>{for(let _ of Y.issues)if(_.code==="invalid_union")_.errors.map((w)=>X({issues:w}));else if(_.code==="invalid_key")X({issues:_.issues});else if(_.code==="invalid_element")X({issues:_.issues});else if(_.path.length===0)U._errors.push(W(_));else{let w=U,G=0;while(G<_.path.length){let J=_.path[G];if(G!==_.path.length-1)w[J]=w[J]||{_errors:[]};else w[J]=w[J]||{_errors:[]},w[J]._errors.push(W(_));w=w[J],G++}}};return X($),U}function K_($,T){let W=T||function(Y){return Y.message},U={errors:[]},X=(Y,_=[])=>{var w,G;for(let J of Y.issues)if(J.code==="invalid_union")J.errors.map((H)=>X({issues:H},J.path));else if(J.code==="invalid_key")X({issues:J.issues},J.path);else if(J.code==="invalid_element")X({issues:J.issues},J.path);else{let H=[..._,...J.path];if(H.length===0){U.errors.push(W(J));continue}let z=U,F=0;while(F<H.length){let Q=H[F],V=F===H.length-1;if(typeof Q==="string")z.properties??(z.properties={}),(w=z.properties)[Q]??(w[Q]={errors:[]}),z=z.properties[Q];else z.items??(z.items=[]),(G=z.items)[Q]??(G[Q]={errors:[]}),z=z.items[Q];if(V)z.errors.push(W(J));F++}}};return X($),U}function A3($){let T=[];for(let W of $)if(typeof W==="number")T.push(`[${W}]`);else if(typeof W==="symbol")T.push(`[${JSON.stringify(String(W))}]`);else if(/[^\w$]/.test(W))T.push(`[${JSON.stringify(W)}]`);else{if(T.length)T.push(".");T.push(W)}return T.join("")}function E_($){let T=[],W=[...$.issues].sort((U,X)=>U.path.length-X.path.length);for(let U of W)if(T.push(`\u2716 ${U.message}`),U.path?.length)T.push(` \u2192 at ${A3(U.path)}`);return T.join(`
6
- `)}var rU=($)=>(T,W,U,X)=>{let Y=U?Object.assign(U,{async:!1}):{async:!1},_=T._zod.run({value:W,issues:[]},Y);if(_ instanceof Promise)throw new u6;if(_.issues.length){let w=new(X?.Err??$)(_.issues.map((G)=>n4(G,Y,t$())));throw Error.captureStackTrace(w,X?.callee),w}return _.value},iU=rU(i0),nU=($)=>async(T,W,U,X)=>{let Y=U?Object.assign(U,{async:!0}):{async:!0},_=T._zod.run({value:W,issues:[]},Y);if(_ instanceof Promise)_=await _;if(_.issues.length){let w=new(X?.Err??$)(_.issues.map((G)=>n4(G,Y,t$())));throw Error.captureStackTrace(w,X?.callee),w}return _.value},tU=nU(i0),aU=($)=>(T,W,U)=>{let X=U?{...U,async:!1}:{async:!1},Y=T._zod.run({value:W,issues:[]},X);if(Y instanceof Promise)throw new u6;return Y.issues.length?{success:!1,error:new($??AW)(Y.issues.map((_)=>n4(_,X,t$())))}:{success:!0,data:Y.value}},A_=aU(i0),sU=($)=>async(T,W,U)=>{let X=U?Object.assign(U,{async:!0}):{async:!0},Y=T._zod.run({value:W,issues:[]},X);if(Y instanceof Promise)Y=await Y;return Y.issues.length?{success:!1,error:new $(Y.issues.map((_)=>n4(_,X,t$())))}:{success:!0,data:Y.value}},M_=sU(i0);var $0={};N1($0,{xid:()=>B_,uuid7:()=>$N,uuid6:()=>eM,uuid4:()=>sM,uuid:()=>e1,uppercase:()=>i_,unicodeEmail:()=>UN,undefined:()=>l_,ulid:()=>S_,time:()=>h_,string:()=>m_,rfc5322Email:()=>WN,number:()=>p_,null:()=>d_,nanoid:()=>I_,lowercase:()=>r_,ksuid:()=>R_,ipv6:()=>$X,ipv4:()=>eU,ip:()=>_N,integer:()=>u_,html5Email:()=>TN,hostname:()=>b_,guid:()=>v_,extendedDuration:()=>aM,emoji:()=>P_,email:()=>q_,e164:()=>f_,duration:()=>k_,domain:()=>wN,datetime:()=>g_,date:()=>y_,cuid2:()=>L_,cuid:()=>N_,cidrv6:()=>j_,cidrv4:()=>C_,browserEmail:()=>XN,boolean:()=>o_,bigint:()=>c_,base64url:()=>TX,base64:()=>x_,_emoji:()=>YN});var N_=/^[cC][^\s-]{8,}$/,L_=/^[0-9a-z]+$/,S_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,B_=/^[0-9a-vA-V]{20}$/,R_=/^[A-Za-z0-9]{27}$/,I_=/^[a-zA-Z0-9_-]{21}$/,k_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,aM=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,v_=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,e1=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},sM=e1(4),eM=e1(6),$N=e1(7),q_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,TN=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,WN=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,UN=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,XN=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,YN="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function P_(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var eU=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$X=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,C_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,j_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_N=new RegExp(`(${eU.source})|(${$X.source})`),x_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,TX=/^[A-Za-z0-9_-]*$/,b_=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,wN=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,f_=/^\+(?:[0-9]){6,14}[0-9]$/,M3="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",y_=new RegExp(`^${M3}$`);function N3($){let T="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)T=`${T}\\.\\d{${$.precision}}`;else if($.precision==null)T=`${T}(\\.\\d+)?`;return T}function h_($){return new RegExp(`^${N3($)}$`)}function g_($){let T=`${M3}T${N3($)}`,W=[];if(W.push($.local?"Z?":"Z"),$.offset)W.push("([+-]\\d{2}:?\\d{2})");return T=`${T}(${W.join("|")})`,new RegExp(`^${T}$`)}var m_=($)=>{let T=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${T}$`)},c_=/^\d+n?$/,u_=/^\d+$/,p_=/^-?\d+(?:\.\d+)?/i,o_=/true|false/i,d_=/null/i;var l_=/undefined/i;var r_=/^[^A-Z]*$/,i_=/^[^a-z]*$/;var u$=E("$ZodCheck",($,T)=>{var W;$._zod??($._zod={}),$._zod.def=T,(W=$._zod).onattach??(W.onattach=[])}),S3={number:"number",bigint:"bigint",object:"date"},WX=E("$ZodCheckLessThan",($,T)=>{u$.init($,T);let W=S3[typeof T.value];$._zod.onattach.push((U)=>{let X=U._zod.bag,Y=(T.inclusive?X.maximum:X.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(T.value<Y)if(T.inclusive)X.maximum=T.value;else X.exclusiveMaximum=T.value}),$._zod.check=(U)=>{if(T.inclusive?U.value<=T.value:U.value<T.value)return;U.issues.push({origin:W,code:"too_big",maximum:T.value,input:U.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),UX=E("$ZodCheckGreaterThan",($,T)=>{u$.init($,T);let W=S3[typeof T.value];$._zod.onattach.push((U)=>{let X=U._zod.bag,Y=(T.inclusive?X.minimum:X.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(T.value>Y)if(T.inclusive)X.minimum=T.value;else X.exclusiveMinimum=T.value}),$._zod.check=(U)=>{if(T.inclusive?U.value>=T.value:U.value>T.value)return;U.issues.push({origin:W,code:"too_small",minimum:T.value,input:U.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),n_=E("$ZodCheckMultipleOf",($,T)=>{u$.init($,T),$._zod.onattach.push((W)=>{var U;(U=W._zod.bag).multipleOf??(U.multipleOf=T.value)}),$._zod.check=(W)=>{if(typeof W.value!==typeof T.value)throw new Error("Cannot mix number and bigint in multiple_of check.");if(typeof W.value==="bigint"?W.value%T.value===BigInt(0):z_(W.value,T.value)===0)return;W.issues.push({origin:typeof W.value,code:"not_multiple_of",divisor:T.value,input:W.value,inst:$,continue:!T.abort})}}),t_=E("$ZodCheckNumberFormat",($,T)=>{u$.init($,T),T.format=T.format||"float64";let W=T.format?.includes("int"),U=W?"int":"number",[X,Y]=Q_[T.format];$._zod.onattach.push((_)=>{let w=_._zod.bag;if(w.format=T.format,w.minimum=X,w.maximum=Y,W)w.pattern=u_}),$._zod.check=(_)=>{let w=_.value;if(W){if(!Number.isInteger(w)){_.issues.push({expected:U,format:T.format,code:"invalid_type",input:w,inst:$});return}if(!Number.isSafeInteger(w)){if(w>0)_.issues.push({input:w,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:U,continue:!T.abort});else _.issues.push({input:w,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:U,continue:!T.abort});return}}if(w<X)_.issues.push({origin:"number",input:w,code:"too_small",minimum:X,inclusive:!0,inst:$,continue:!T.abort});if(w>Y)_.issues.push({origin:"number",input:w,code:"too_big",maximum:Y,inst:$})}}),a_=E("$ZodCheckBigIntFormat",($,T)=>{u$.init($,T);let[W,U]=Z_[T.format];$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.format=T.format,Y.minimum=W,Y.maximum=U}),$._zod.check=(X)=>{let Y=X.value;if(Y<W)X.issues.push({origin:"bigint",input:Y,code:"too_small",minimum:W,inclusive:!0,inst:$,continue:!T.abort});if(Y>U)X.issues.push({origin:"bigint",input:Y,code:"too_big",maximum:U,inst:$})}}),s_=E("$ZodCheckMaxSize",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let U=W.value;return!k1(U)&&U.size!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<U)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let U=W.value;if(U.size<=T.maximum)return;W.issues.push({origin:KW(U),code:"too_big",maximum:T.maximum,input:U,inst:$,continue:!T.abort})}}),e_=E("$ZodCheckMinSize",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let U=W.value;return!k1(U)&&U.size!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>U)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let U=W.value;if(U.size>=T.minimum)return;W.issues.push({origin:KW(U),code:"too_small",minimum:T.minimum,input:U,inst:$,continue:!T.abort})}}),$w=E("$ZodCheckSizeEquals",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let U=W.value;return!k1(U)&&U.size!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag;U.minimum=T.size,U.maximum=T.size,U.size=T.size}),$._zod.check=(W)=>{let U=W.value,X=U.size;if(X===T.size)return;let Y=X>T.size;W.issues.push({origin:KW(U),...Y?{code:"too_big",maximum:T.size}:{code:"too_small",minimum:T.size},input:W.value,inst:$,continue:!T.abort})}}),Tw=E("$ZodCheckMaxLength",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let U=W.value;return!k1(U)&&U.length!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<U)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let U=W.value;if(U.length<=T.maximum)return;let Y=EW(U);W.issues.push({origin:Y,code:"too_big",maximum:T.maximum,input:U,inst:$,continue:!T.abort})}}),Ww=E("$ZodCheckMinLength",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let U=W.value;return!k1(U)&&U.length!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>U)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let U=W.value;if(U.length>=T.minimum)return;let Y=EW(U);W.issues.push({origin:Y,code:"too_small",minimum:T.minimum,input:U,inst:$,continue:!T.abort})}}),Uw=E("$ZodCheckLengthEquals",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let U=W.value;return!k1(U)&&U.length!==void 0},$._zod.onattach.push((W)=>{let U=W._zod.bag;U.minimum=T.length,U.maximum=T.length,U.length=T.length}),$._zod.check=(W)=>{let U=W.value,X=U.length;if(X===T.length)return;let Y=EW(U),_=X>T.length;W.issues.push({origin:Y,..._?{code:"too_big",maximum:T.length}:{code:"too_small",minimum:T.length},input:W.value,inst:$,continue:!T.abort})}}),n0=E("$ZodCheckStringFormat",($,T)=>{var W;u$.init($,T),$._zod.onattach.push((U)=>{let X=U._zod.bag;if(X.format=T.format,T.pattern)X.patterns??(X.patterns=new Set),X.patterns.add(T.pattern)}),(W=$._zod).check??(W.check=(U)=>{if(!T.pattern)throw new Error("Not implemented.");if(T.pattern.lastIndex=0,T.pattern.test(U.value))return;U.issues.push({origin:"string",code:"invalid_format",format:T.format,input:U.value,...T.pattern?{pattern:T.pattern.toString()}:{},inst:$,continue:!T.abort})})}),Xw=E("$ZodCheckRegex",($,T)=>{n0.init($,T),$._zod.check=(W)=>{if(T.pattern.lastIndex=0,T.pattern.test(W.value))return;W.issues.push({origin:"string",code:"invalid_format",format:"regex",input:W.value,pattern:T.pattern.toString(),inst:$,continue:!T.abort})}}),Yw=E("$ZodCheckLowerCase",($,T)=>{T.pattern??(T.pattern=r_),n0.init($,T)}),_w=E("$ZodCheckUpperCase",($,T)=>{T.pattern??(T.pattern=i_),n0.init($,T)}),ww=E("$ZodCheckIncludes",($,T)=>{u$.init($,T);let W=new RegExp(p6(T.includes));T.pattern=W,$._zod.onattach.push((U)=>{let X=U._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(W)}),$._zod.check=(U)=>{if(U.value.includes(T.includes,T.position))return;U.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:T.includes,input:U.value,inst:$,continue:!T.abort})}}),Jw=E("$ZodCheckStartsWith",($,T)=>{u$.init($,T);let W=new RegExp(`^${p6(T.prefix)}.*`);T.pattern??(T.pattern=W),$._zod.onattach.push((U)=>{let X=U._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(W)}),$._zod.check=(U)=>{if(U.value.startsWith(T.prefix))return;U.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:T.prefix,input:U.value,inst:$,continue:!T.abort})}}),Gw=E("$ZodCheckEndsWith",($,T)=>{u$.init($,T);let W=new RegExp(`.*${p6(T.suffix)}$`);T.pattern??(T.pattern=W),$._zod.onattach.push((U)=>{let X=U._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(W)}),$._zod.check=(U)=>{if(U.value.endsWith(T.suffix))return;U.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:T.suffix,input:U.value,inst:$,continue:!T.abort})}});function L3($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues))}var zw=E("$ZodCheckProperty",($,T)=>{u$.init($,T),$._zod.check=(W)=>{let U=T.schema._zod.run({value:W.value[T.property],issues:[]},{});if(U instanceof Promise)return U.then((X)=>L3(X,W,T.property));L3(U,W,T.property);return}}),Hw=E("$ZodCheckMimeType",($,T)=>{u$.init($,T);let W=new Set(T.mime);$._zod.onattach.push((U)=>{U._zod.bag.mime=T.mime}),$._zod.check=(U)=>{if(W.has(U.value.type))return;U.issues.push({code:"invalid_value",values:T.mime,input:U.value.type,path:["type"],inst:$})}}),Fw=E("$ZodCheckOverwrite",($,T)=>{u$.init($,T),$._zod.check=(W)=>{W.value=T.tx(W.value)}});class XX{constructor($=[]){if(this.content=[],this.indent=0,this)this.args=$}indented($){this.indent+=1,$(this),this.indent-=1}write($){if(typeof $==="function"){$(this,{execution:"sync"}),$(this,{execution:"async"});return}let W=$.split(`
7
- `).filter((Y)=>Y),U=Math.min(...W.map((Y)=>Y.length-Y.trimStart().length)),X=W.map((Y)=>Y.slice(U)).map((Y)=>" ".repeat(this.indent*2)+Y);for(let Y of X)this.content.push(Y)}compile(){let $=Function,T=this?.args,U=[...(this?.content??[""]).map((X)=>` ${X}`)];return new $(...T,U.join(`
8
- `))}}var Ow={major:4,minor:0,patch:0};var T$=E("$ZodType",($,T)=>{var W;$??($={}),$._zod.id=T.type+"_"+dU(10),$._zod.def=T,$._zod.bag=$._zod.bag||{},$._zod.version=Ow;let U=[...$._zod.def.checks??[]];if($._zod.traits.has("$ZodCheck"))U.unshift($);for(let X of U)for(let Y of X._zod.onattach)Y($);if(U.length===0)(W=$._zod).deferred??(W.deferred=[]),$._zod.deferred?.push(()=>{$._zod.run=$._zod.parse});else{let X=(Y,_,w)=>{let G=s1(Y),J;for(let H of _){if(H._zod.when){if(!H._zod.when(Y))continue}else if(G)continue;let z=Y.issues.length,F=H._zod.check(Y);if(F instanceof Promise&&w?.async===!1)throw new u6;if(J||F instanceof Promise)J=(J??Promise.resolve()).then(async()=>{if(await F,Y.issues.length===z)return;if(!G)G=s1(Y,z)});else{if(Y.issues.length===z)continue;if(!G)G=s1(Y,z)}}if(J)return J.then(()=>{return Y});return Y};$._zod.run=(Y,_)=>{let w=$._zod.parse(Y,_);if(w instanceof Promise){if(_.async===!1)throw new u6;return w.then((G)=>X(G,U,_))}return X(w,U,_)}}$["~standard"]={validate:(X)=>{try{let Y=A_($,X);return Y.success?{value:Y.data}:{issues:Y.error?.issues}}catch(Y){return M_($,X).then((_)=>_.success?{value:_.data}:{issues:_.error?.issues})}},vendor:"zod",version:1}}),LW=E("$ZodString",($,T)=>{T$.init($,T),$._zod.pattern=[...$?._zod.bag?.patterns??[]].pop()??m_($._zod.bag),$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=String(W.value)}catch(X){}if(typeof W.value==="string")return W;return W.issues.push({expected:"string",code:"invalid_type",input:W.value,inst:$}),W}}),v$=E("$ZodStringFormat",($,T)=>{n0.init($,T),LW.init($,T)}),Qw=E("$ZodGUID",($,T)=>{T.pattern??(T.pattern=v_),v$.init($,T)}),Zw=E("$ZodUUID",($,T)=>{if(T.version){let U={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[T.version];if(U===void 0)throw new Error(`Invalid UUID version: "${T.version}"`);T.pattern??(T.pattern=e1(U))}else T.pattern??(T.pattern=e1());v$.init($,T)}),Vw=E("$ZodEmail",($,T)=>{T.pattern??(T.pattern=q_),v$.init($,T)}),Kw=E("$ZodURL",($,T)=>{v$.init($,T),$._zod.check=(W)=>{try{let U=new URL(W.value);if(T.hostname){if(T.hostname.lastIndex=0,!T.hostname.test(U.hostname))W.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:b_.source,input:W.value,inst:$})}if(T.protocol){if(T.protocol.lastIndex=0,!T.protocol.test(U.protocol.endsWith(":")?U.protocol.slice(0,-1):U.protocol))W.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:T.protocol.source,input:W.value,inst:$})}return}catch(U){W.issues.push({code:"invalid_format",format:"url",input:W.value,inst:$})}}}),Ew=E("$ZodEmoji",($,T)=>{T.pattern??(T.pattern=P_()),v$.init($,T)}),Aw=E("$ZodNanoID",($,T)=>{T.pattern??(T.pattern=I_),v$.init($,T)}),Mw=E("$ZodCUID",($,T)=>{T.pattern??(T.pattern=N_),v$.init($,T)}),Nw=E("$ZodCUID2",($,T)=>{T.pattern??(T.pattern=L_),v$.init($,T)}),Lw=E("$ZodULID",($,T)=>{T.pattern??(T.pattern=S_),v$.init($,T)}),Sw=E("$ZodXID",($,T)=>{T.pattern??(T.pattern=B_),v$.init($,T)}),Bw=E("$ZodKSUID",($,T)=>{T.pattern??(T.pattern=R_),v$.init($,T)}),Rw=E("$ZodISODateTime",($,T)=>{T.pattern??(T.pattern=g_(T)),v$.init($,T)}),Iw=E("$ZodISODate",($,T)=>{T.pattern??(T.pattern=y_),v$.init($,T)}),kw=E("$ZodISOTime",($,T)=>{T.pattern??(T.pattern=h_(T)),v$.init($,T)}),vw=E("$ZodISODuration",($,T)=>{T.pattern??(T.pattern=k_),v$.init($,T)}),qw=E("$ZodIPv4",($,T)=>{T.pattern??(T.pattern=eU),v$.init($,T),$._zod.onattach.push((W)=>{let U=W._zod.bag;U.format="ipv4"})}),Pw=E("$ZodIPv6",($,T)=>{T.pattern??(T.pattern=$X),v$.init($,T),$._zod.onattach.push((W)=>{let U=W._zod.bag;U.format="ipv6"}),$._zod.check=(W)=>{try{new URL(`http://[${W.value}]`)}catch{W.issues.push({code:"invalid_format",format:"ipv6",input:W.value,inst:$})}}}),Cw=E("$ZodCIDRv4",($,T)=>{T.pattern??(T.pattern=C_),v$.init($,T)}),jw=E("$ZodCIDRv6",($,T)=>{T.pattern??(T.pattern=j_),v$.init($,T),$._zod.check=(W)=>{let[U,X]=W.value.split("/");try{if(!X)throw new Error;let Y=Number(X);if(`${Y}`!==X)throw new Error;if(Y<0||Y>128)throw new Error;new URL(`http://[${U}]`)}catch{W.issues.push({code:"invalid_format",format:"cidrv6",input:W.value,inst:$})}}});function xw($){if($==="")return!0;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}var bw=E("$ZodBase64",($,T)=>{T.pattern??(T.pattern=x_),v$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.contentEncoding="base64"}),$._zod.check=(W)=>{if(xw(W.value))return;W.issues.push({code:"invalid_format",format:"base64",input:W.value,inst:$})}});function y3($){if(!TX.test($))return!1;let T=$.replace(/[-_]/g,(U)=>U==="-"?"+":"/"),W=T.padEnd(Math.ceil(T.length/4)*4,"=");return xw(W)}var fw=E("$ZodBase64URL",($,T)=>{T.pattern??(T.pattern=TX),v$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.contentEncoding="base64url"}),$._zod.check=(W)=>{if(y3(W.value))return;W.issues.push({code:"invalid_format",format:"base64url",input:W.value,inst:$})}}),yw=E("$ZodE164",($,T)=>{T.pattern??(T.pattern=f_),v$.init($,T)});function h3($,T=null){try{let W=$.split(".");if(W.length!==3)return!1;let[U]=W,X=JSON.parse(atob(U));if("typ"in X&&X?.typ!=="JWT")return!1;if(!X.alg)return!1;if(T&&(!("alg"in X)||X.alg!==T))return!1;return!0}catch{return!1}}var hw=E("$ZodJWT",($,T)=>{v$.init($,T),$._zod.check=(W)=>{if(h3(W.value,T.alg))return;W.issues.push({code:"invalid_format",format:"jwt",input:W.value,inst:$})}}),wX=E("$ZodNumber",($,T)=>{T$.init($,T),$._zod.pattern=$._zod.bag.pattern??p_,$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=Number(W.value)}catch(_){}let X=W.value;if(typeof X==="number"&&!Number.isNaN(X)&&Number.isFinite(X))return W;let Y=typeof X==="number"?Number.isNaN(X)?"NaN":!Number.isFinite(X)?"Infinity":void 0:void 0;return W.issues.push({expected:"number",code:"invalid_type",input:X,inst:$,...Y?{received:Y}:{}}),W}}),gw=E("$ZodNumber",($,T)=>{t_.init($,T),wX.init($,T)}),SW=E("$ZodBoolean",($,T)=>{T$.init($,T),$._zod.pattern=o_,$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=Boolean(W.value)}catch(Y){}let X=W.value;if(typeof X==="boolean")return W;return W.issues.push({expected:"boolean",code:"invalid_type",input:X,inst:$}),W}}),JX=E("$ZodBigInt",($,T)=>{T$.init($,T),$._zod.pattern=c_,$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=BigInt(W.value)}catch(Y){}let{value:X}=W;if(typeof X==="bigint")return W;return W.issues.push({expected:"bigint",code:"invalid_type",input:X,inst:$}),W}}),mw=E("$ZodBigInt",($,T)=>{a_.init($,T),JX.init($,T)}),cw=E("$ZodSymbol",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let{value:X}=W;if(typeof X==="symbol")return W;return W.issues.push({expected:"symbol",code:"invalid_type",input:X,inst:$}),W}}),uw=E("$ZodUndefined",($,T)=>{T$.init($,T),$._zod.pattern=l_,$._zod.values=new Set([void 0]),$._zod.parse=(W,U)=>{let{value:X}=W;if(typeof X==="undefined")return W;return W.issues.push({expected:"undefined",code:"invalid_type",input:X,inst:$}),W}}),pw=E("$ZodNull",($,T)=>{T$.init($,T),$._zod.pattern=d_,$._zod.values=new Set([null]),$._zod.parse=(W,U)=>{let{value:X}=W;if(X===null)return W;return W.issues.push({expected:"null",code:"invalid_type",input:X,inst:$}),W}}),ow=E("$ZodAny",($,T)=>{T$.init($,T),$._zod.parse=(W)=>W}),BW=E("$ZodUnknown",($,T)=>{T$.init($,T),$._zod.parse=(W)=>W}),dw=E("$ZodNever",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{return W.issues.push({expected:"never",code:"invalid_type",input:W.value,inst:$}),W}}),lw=E("$ZodVoid",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let{value:X}=W;if(typeof X==="undefined")return W;return W.issues.push({expected:"void",code:"invalid_type",input:X,inst:$}),W}}),rw=E("$ZodDate",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{if(T.coerce)try{W.value=new Date(W.value)}catch(w){}let X=W.value,Y=X instanceof Date;if(Y&&!Number.isNaN(X.getTime()))return W;return W.issues.push({expected:"date",code:"invalid_type",input:X,...Y?{received:"Invalid Date"}:{},inst:$}),W}});function R3($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues));T.value[W]=$.value}var iw=E("$ZodArray",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(!Array.isArray(X))return W.issues.push({expected:"array",code:"invalid_type",input:X,inst:$}),W;W.value=Array(X.length);let Y=[];for(let _=0;_<X.length;_++){let w=X[_],G=T.element._zod.run({value:w,issues:[]},U);if(G instanceof Promise)Y.push(G.then((J)=>R3(J,W,_)));else R3(G,W,_)}if(Y.length)return Promise.all(Y).then(()=>W);return W}});function YX($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues));T.value[W]=$.value}function I3($,T,W,U){if($.issues.length)if(U[W]===void 0)if(W in U)T.value[W]=void 0;else T.value[W]=$.value;else T.issues.push(...x4(W,$.issues));else if($.value===void 0){if(W in U)T.value[W]=void 0}else T.value[W]=$.value}var nw=E("$ZodObject",($,T)=>{T$.init($,T);let W=DW(()=>{let z=Object.keys(T.shape);for(let Q of z)if(!(T.shape[Q]instanceof T$))throw new Error(`Invalid element at key "${Q}": expected a Zod schema`);let F=D_(T.shape);return{shape:T.shape,keys:z,keySet:new Set(z),numKeys:z.length,optionalKeys:new Set(F)}});N$($._zod,"disc",()=>{let z=T.shape,F=new Map,Q=!1;for(let V in z){let K=z[V]._zod;if(K.values||K.disc){Q=!0;let I={values:new Set(K.values??[]),maps:K.disc?[K.disc]:[]};F.set(V,I)}}if(!Q)return;return F});let U=(z)=>{let F=new XX(["shape","payload","ctx"]),{keys:Q,optionalKeys:V}=W.value,K=(N)=>{let L=a1(N);return`shape[${L}]._zod.run({ value: input[${L}], issues: [] }, ctx)`};F.write("const input = payload.value;");let I=Object.create(null);for(let N of Q)I[N]=dU(15);F.write("const newResult = {}");for(let N of Q)if(V.has(N)){let L=I[N];F.write(`const ${L} = ${K(N)};`);let q=a1(N);F.write(`
9
- if (${L}.issues.length) {
10
- if (input[${q}] === undefined) {
11
- if (${q} in input) {
12
- newResult[${q}] = undefined;
3
+ var Uq=Object.create;var{getPrototypeOf:Yq,defineProperty:Iz,getOwnPropertyNames:Gq}=Object;var zq=Object.prototype.hasOwnProperty;var Hq=($,T,W)=>{W=$!=null?Uq(Yq($)):{};let w=T||!$||!$.__esModule?Iz(W,"default",{value:$,enumerable:!0}):W;for(let X of Gq($))if(!zq.call(w,X))Iz(w,X,{get:()=>$[X],enumerable:!0});return w};var Fq=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports);var e0=($,T)=>{for(var W in T)Iz($,W,{get:T[W],enumerable:!0,configurable:!0,set:(w)=>T[W]=()=>w})};var gy=($,T)=>()=>($&&(T=$($=0)),T);var FV=import.meta.require;var WA=Fq((Sp,TA)=>{var O8=FV("os"),Q8=FV("path");function $A($){let T=process.env.XDG_CACHE_HOME||Q8.join(O8.homedir(),".cache");return Q8.join(T,$)}function FS($){return Q8.join(O8.homedir(),"Library","Caches",$)}function OS($){let T=process.env.LOCALAPPDATA||Q8.join(O8.homedir(),"AppData","Local");return Q8.join(T,$,"Cache")}var QS=function(){switch(O8.platform()){case"darwin":return FS;case"win32":return OS;case"aix":case"android":case"freebsd":case"linux":case"netbsd":case"openbsd":case"sunos":return $A;default:return console.error(`(node:${process.pid}) [cachedir] Warning: the platform "${O8.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`),$A}}();TA.exports=function $(T){if(typeof T!=="string")throw new TypeError("id is not a string");if(T.length===0)throw new Error("id cannot be empty");if(/[^0-9a-zA-Z-]/.test(T))throw new Error("id cannot contain special characters");return QS(T)}});class DX extends Promise{fate;resolve;reject;done=!1;constructor($){let T,W;super((w,X)=>{T=w,W=X});this.resolve=T,this.reject=W,this.use($ instanceof Promise?$:new Promise($))}pass($,T){if($===this.fate)this.resolve(T),this.done=!0}fail($,T){if($===this.fate)this.reject(T),this.done=!0}use($){if($ instanceof Promise){let T=$;this.fate=T,T.then((W)=>{this.pass(T,W)},(W)=>{this.fail(T,W)})}else this.resolve($),this.fate=void 0}}var py=($,T,W=QV.STORE)=>{return OV(W,{key:`${$.key}:JSON`,get:({get:w})=>T.toJson(w($)),set:({set:w},X)=>{w($,T.fromJson(X))}})};function ly($,T,W){return Bz($,{key:`${T.key}:JSON`,get:(X)=>({get:U})=>{let Y=U(T,X);return W.toJson(Y)},set:(X)=>({set:U},Y)=>{U(T,X,W.fromJson(Y))}},["mutable","json"])}var NX=($)=>JSON.parse($),G6=($)=>JSON.stringify($),ny=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function Q$($){while($.child!==null)$=$.child;return $}class aU{_buffer;_index=0;constructor($){let T;if(typeof $==="number")T=$;else T=$.length;this._buffer=Array.from({length:T})}get buffer(){return this._buffer}get index(){return this._index}add($){this._buffer[this._index]=$,this._index=(this._index+1)%this._buffer.length}copy(){let $=new aU([...this._buffer]);return $._index=this._index,$}}var Oq={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 ZV($,T){let W=G6(T),w=`${$.key}(${W})`,X=Oq[$.type],U={key:w,type:X};return Object.assign(U,{family:{key:$.key,subKey:W}}),Object.assign(U,{counterfeit:!0}),U}function LX($){let T={key:$.key,type:$.type};if("family"in $)T.family=$.family;return T}var xz=($)=>(T,W,w,X,...U)=>{console[$](`${T} ${W} "${w}" ${X}`,...U)},Qq={error:xz("error"),info:xz("info"),warn:xz("warn")};class fz{logLevel;filter;logger;constructor($,T,W=Qq){this.logLevel=$,this.filter=T,this.logger=W}error=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel!==null){if(T===!0)this.logger.error(...$);else if(T!==!1)this.logger.error(...T)}};info=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel==="info"){if(T===!0)this.logger.info(...$);else if(T!==!1)this.logger.info(...T)}};warn=(...$)=>{let T=this.filter?.(...$)??!0;if(this.logLevel!=="error"&&this.logLevel!==null){if(T===!0)this.logger.warn(...$);else if(T!==!1)this.logger.warn(...T)}}}class d1{a;b;cardinality;relations=new Map;contents=new Map;isAType;isBType;isContent;makeContentKey=($,T)=>`${$}:${T}`;warn;getRelatedKeys($){return this.relations.get($)}addRelation($,T){let W=this.relations.get($),w=this.relations.get(T);if(W)W.add(T);else W=new Set([T]),this.relations.set($,W);if(w)w.add($);else w=new Set([$]),this.relations.set(T,w)}deleteRelation($,T){let W=this.relations.get($);if(W){if(W.delete(T),W.size===0)this.relations.delete($);let w=this.relations.get(T);if(w){if(w.delete($),w.size===0)this.relations.delete(T)}}}replaceRelationsUnsafely($,T){this.relations.set($,new Set(T));for(let W of T){let w=new Set().add($);this.relations.set(W,w)}}replaceRelationsSafely($,T){let W=this.relations.get($),w=this.isAType?.($)?$:void 0,X=w===void 0?$:void 0;if(W)for(let U of W){w??=U,X??=U;let Y=this.relations.get(U);if(Y){if(Y.size===1)this.relations.delete(U);else Y.delete($);this.contents.delete(this.makeContentKey(w,X))}}this.relations.set($,new Set(T));for(let U of T){let Y=this.relations.get(U);if(Y)Y.add($);else Y=new Set().add($),this.relations.set(U,Y)}}getContentInternal($){return this.contents.get($)}setContent($,T){this.contents.set($,T)}deleteContent($){this.contents.delete($)}constructor($,T){if(this.a=$.between[0],this.b=$.between[1],this.cardinality=$.cardinality,!T?.externalStore)this.relations=new Map($.relations?.map(([W,w])=>[W,new Set(w)])),this.contents=new Map($.contents);if(this.isAType=T?.isAType??null,this.isBType=T?.isBType??null,this.isContent=T?.isContent??null,T?.makeContentKey)this.makeContentKey=T.makeContentKey;if(T?.externalStore){let W=T.externalStore;if(this.has=(w,X)=>W.has(w,X),this.addRelation=(w,X)=>{W.addRelation(w,X)},this.deleteRelation=(w,X)=>{W.deleteRelation(w,X)},this.replaceRelationsSafely=(w,X)=>{W.replaceRelationsSafely(w,X)},this.replaceRelationsUnsafely=(w,X)=>{W.replaceRelationsUnsafely(w,X)},this.getRelatedKeys=(w)=>W.getRelatedKeys(w),W.getContent)this.getContentInternal=(w)=>{return W.getContent(w)},this.setContent=(w,X)=>{W.setContent(w,X)},this.deleteContent=(w)=>{W.deleteContent(w)};for(let[w,X]of $.relations??[]){let U=this.isAType?.(w)?w:void 0,Y=U===void 0?w:void 0;for(let G of X)U??=G,Y??=G,this.addRelation(U,Y)}for(let[w,X]of $.contents??[])this.setContent(w,X)}if(T?.warn)this.warn=T.warn}toJSON(){return{between:[this.a,this.b],cardinality:this.cardinality,relations:[...this.relations.entries()].map(([$,T])=>[$,[...T]]),contents:[...this.contents.entries()]}}set(...$){let T,W,w;switch($.length){case 1:{let X=$[0];T=X[this.a],W=X[this.b],w=void 0;break}case 2:{let X=$[0];if(typeof X==="string")[T,W]=$;else T=X[this.a],W=X[this.b],w=$[1];break}default:{T=$[0],W=$[1],w=$[2];break}}switch(this.cardinality){case"1:1":{let X=this.getRelatedKey(T);if(X&&X!==W)this.delete(T,X)}case"1:n":{let X=this.getRelatedKey(W);if(X&&X!==T)this.delete(X,W)}break;case"n:n":}if(w){let X=this.makeContentKey(T,W);this.setContent(X,w)}return this.addRelation(T,W),this}delete($,T){T=typeof T==="string"?T:$[this.b];let W=typeof $==="string"?$:$[this.a];if(W===void 0&&typeof T==="string"){let w=this.getRelatedKeys(T);if(w)for(let X of w)this.delete(X,T)}if(typeof W==="string"&&T===void 0){let w=this.getRelatedKeys(W);if(w)for(let X of w)this.delete(W,X)}if(typeof W==="string"&&typeof T==="string"){this.deleteRelation(W,T);let w=this.makeContentKey(W,T);this.deleteContent(w)}return this}getRelatedKey($){let T=this.getRelatedKeys($);if(T){if(T.size>1)this.warn?.(`${T.size} related keys were found for key "${$}": (${[...T].map((w)=>`"${w}"`).join(", ")}). Only one related key was expected.`);let W;for(let w of T){W=w;break}return W}}replaceRelations($,T,W){let w=!Array.isArray(T),X=w?Object.keys(T):T;if(W?.reckless)this.replaceRelationsUnsafely($,X);else this.replaceRelationsSafely($,X);if(w)for(let U of X){let Y=this.makeContentKey($,U),G=T[U];this.setContent(Y,G)}return this}getContent($,T){let W=this.makeContentKey($,T);return this.getContentInternal(W)}getRelationEntries($){let T=$[this.a],W=$[this.b];if(T!==void 0&&W===void 0){let w=this.getRelatedKeys(T);if(w)return[...w].map((X)=>{return[X,this.getContent(T,X)]})}if(T===void 0&&W!==void 0){let w=this.getRelatedKeys(W);if(w)return[...w].map((X)=>{return[X,this.getContent(X,W)]})}return[]}has($,T){if(T)return this.getRelatedKeys($)?.has(T)??!1;return this.relations.has($)}}class b${Subscriber;subscribers=new Map;subscribe($,T){return this.subscribers.set($,T),()=>{this.unsubscribe($)}}unsubscribe($){this.subscribers.delete($)}next($){let T=this.subscribers.values();for(let W of T)W($)}}class bz extends b${state;constructor($){super();this.state=$}next($){this.state=$,super.next($)}}function $T($){return"epoch"in $.transactionMeta}function i6($){return"phase"in $.transactionMeta}function VV($){return $[0].toUpperCase()+$.slice(1)}function sU($){return $.type.split("_").map(VV).join(" ")}class JX extends Error{constructor($,T){super(`${sU($)} ${G6($.key)} not found in store "${T.config.name}".`)}}var mW=($)=>(T)=>$ instanceof Function?$(T):$;var TT=($,T)=>{if($.valueMap.has(T.key))return $.logger.info("\uD83D\uDCD6",T.type,T.key,"reading cached value"),KV(T,$);switch(T.type){case"readonly_held_selector":case"readonly_pure_selector":case"writable_held_selector":case"writable_pure_selector":return $.logger.info("\uD83E\uDDEE",T.type,T.key,"computing value"),T.get();case"atom":case"mutable_atom":{let W=T.default,w;if(W instanceof Function)w=W();else w=W;return $.logger.info("\uD83D\uDC81","atom",T.key,"could not find cached value; using default",w),w}}};var AV=($,T)=>{if($.operation.open){let W=performance.now();return $.logger.info("\u2757",T.type,T.key,`deferring setState at T-${W} until setState for "${$.operation.token.key}" is done`),W}$.operation={open:!0,done:new Set,prev:new Map,time:Date.now(),token:T},$.logger.info("\u2B55",T.type,T.key,`operation start in store "${$.config.name}"${!i6($)?"":` ${$.transactionMeta.phase} "${$.transactionMeta.update.key}"`}`)},EV=($)=>{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)},MV=($,T)=>{if(!$.operation.open)return $.logger.error("\uD83D\uDC1E","unknown",T,"isDone called outside of an operation. This is probably a bug in AtomIO."),!0;return $.operation.done.has(T)},WT=($,T)=>{if(!$.operation.open){$.logger.error("\uD83D\uDC1E","unknown",T,"markDone called outside of an operation. This is probably a bug in AtomIO.");return}$.operation.done.add(T)};var DV=($,T,W)=>{switch(T.type){case"mutable_atom":$.logger.info("\uD83D\uDCE2",T.type,T.key,"is now (",W.newValue,") subscribers:",T.subject.subscribers);break;case"atom":case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":$.logger.info("\uD83D\uDCE2",T.type,T.key,"went (",W.oldValue,"->",W.newValue,") subscribers:",T.subject.subscribers)}T.subject.next(W)};var yz=($,T)=>{let W=Q$($),w=W.selectorAtoms.getRelatedKeys(T.key);if(W.logger.info("\uD83E\uDDF9",T.type,T.key,w?`evicting ${w.size} states downstream:`:"no downstream states",w??"to evict"),w){if(W.operation.open)W.logger.info("\uD83E\uDDF9",T.type,T.key,`[ ${[...W.operation.done].join(", ")} ] already done`);for(let X of w){if(MV(W,X))continue;NV(X,W),WT(W,X)}}};var LV=($,T,W)=>{let w=TT($,T),X=w;if(T.type==="mutable_atom"&&i6($)){let{parent:Y}=$;X=RX($,T,Y)}if(X=mW(W)(X),$.logger.info("\uD83D\uDCDD","atom",T.key,"set to",X),X=z6($,T.key,X,T.subject),RV($,T.key))_V($,T.key);WT($,T.key),yz($,T);let U={oldValue:w,newValue:X};if(!i6($)){DV($,T,U);return}if($.on.transactionApplying.state===null){let{key:Y}=T;if(JV(U.newValue))return;let G={type:"atom_update",key:Y,...U};if(T.family)G.family=T.family;$.transactionMeta.update.updates.push(G),$.logger.info("\uD83D\uDCC1","atom",Y,"stowed (",U.oldValue,"->",U.newValue,")")}else if(T.key.startsWith("*")){let Y=T.key.slice(1),G=$.atoms.get(Y),H=$.valueMap.get(Y);if(G.type==="mutable_atom"&&i6($)){let{parent:F}=$;H=RX($,G,F)}if(H.do(U.newValue)===null)yz($,G)}};var eU=($,T,W)=>{switch(T.type){case"atom":case"mutable_atom":LV($,T,W);break;case"writable_pure_selector":case"writable_held_selector":T.set(W);break}};var $Y=($,T)=>Q$($).atoms.has(T),Zq=($,T)=>Q$($).writableSelectors.has(T),Vq=($,T)=>Q$($).readonlySelectors.has(T),kV=($,T)=>$Y($,T)||Zq($,T)||Vq($,T);var TY=($,T)=>{return Q$($).selectorGraph.getRelationEntries({downstreamSelectorKey:T}).filter(([w,{source:X}])=>X!==T).map(([w,{source:X}])=>X).filter((w)=>kV($,w))};var hz=($,T,W)=>{let w=[],X=TY($,T);while(X.length>0){let U=X.shift();if(W.has(U))continue;if(W.add(U),!$Y($,U))X.push(...TY($,U));else if(!w.includes(U))w.push(U)}return w},vV=($,T)=>{let W=$.key,w=TY(T,W),X=new Set;return w.flatMap((U)=>$Y(T,U)?U:hz(T,U,X))};var qV=($,T,W,w,X)=>{let U=Q$($),{type:Y,key:G}=w;if(Y==="atom"||Y==="mutable_atom")U.selectorAtoms.set({selectorKey:W,atomKey:G}),$.logger.info("\uD83D\uDD0D",T,W,`discovers root atom "${G}"`);else{let H=hz($,G,X);$.logger.info("\uD83D\uDD0D",T,W,`discovers root atoms: [ ${H.map((z)=>`"${z}"`).join(", ")} ]`);for(let z of H)U.selectorAtoms=U.selectorAtoms.set({selectorKey:W,atomKey:z})}X.add(G)};var XT=($,T,W,w)=>({get:(...X)=>{let U=Q$($),Y;if(X.length===2){let[F,O]=X;Y=t6($,F,O)}else[Y]=X;let G=j6($,Y),H=TT($,G),z=Y.key;return $.logger.info("\uD83D\uDD0C",T,W,`registers dependency ( "${z}" =`,H,")"),U.selectorGraph.set({upstreamSelectorKey:z,downstreamSelectorKey:W},{source:Y.key}),qV($,T,W,Y,w),H},set:(...X)=>{let U,Y;if(X.length===2)U=X[0],Y=X[1];else{let z=X[0],F=X[1];Y=X[2],U=t6($,z,F)}let G=Q$($),H=j6(G,U);eU(G,H,Y)},find:(...X)=>t6($,...X),json:(X)=>cW($,X)});var gz=($,T,W)=>{let w=Q$($),X=new b$,U=new Set,{key:Y,const:G}=T,H="readonly_held_selector",{get:z,find:F,json:O}=XT(w,"readonly_held_selector",Y,U),Z={...T,type:"readonly_held_selector",subject:X,install:(E)=>gz(E,T,W),get:()=>{return T.get({get:z,find:F,json:O},G),z6(Q$($),Y,G,X),U.clear(),G},...W&&{family:W}};w.readonlySelectors.set(Y,Z),$.logger.info("\u2728","readonly_held_selector",Y,"=",G);let K={key:Y,type:"readonly_held_selector"};if(W)K.family=W;return K};var mz=($,T,W)=>{let w=Q$($),X=new b$,U=new Set,Y=T.key,G="readonly_pure_selector",{get:H,find:z,json:F}=XT(w,"readonly_pure_selector",Y,U),O=()=>{let E=T.get({get:H,find:z,json:F});return z6(Q$($),Y,E,X),U.clear(),E},Q={...T,type:"readonly_pure_selector",subject:X,install:(E)=>mz(E,T,W),get:O,...W&&{family:W}};w.readonlySelectors.set(Y,Q);let Z=O();$.logger.info("\u2728","readonly_pure_selector",Y,"=",Z);let K={key:Y,type:"readonly_pure_selector"};if(W)K.family=W;return K};var cz=($,T,W)=>{let w=Q$($),X=new b$,U=new Set,{key:Y,const:G}=T,H="writable_held_selector",z=XT(w,"writable_held_selector",Y,U),{find:F,get:O,json:Q}=z,Z={find:F,get:O,json:Q},K=(_=T.get,S=Q$($))=>{return _(Z,G),z6(S,Y,G,X),U.clear(),G},M={...T,type:"writable_held_selector",subject:X,install:(_)=>cz(_,T,W),get:K,set:(_)=>{let S=Q$($),x=K(T.get,S),b=mW(_)(x);if($.logger.info("\uD83D\uDCDD","writable_held_selector",Y,"set (",x,"->",b,")"),z6(S,Y,b,X),WT(S,Y),$T(S))X.next({newValue:b,oldValue:x});T.set(z,b)},...W&&{family:W}};w.writableSelectors.set(Y,M);let L=K();$.logger.info("\u2728","writable_held_selector",Y,"=",L);let R={key:Y,type:"writable_held_selector"};if(W)R.family=W;return R};var _X=($,T,W)=>{let w=Q$($),X=new b$,U=new Set,Y=T.key,G="writable_pure_selector",H=XT(w,"writable_pure_selector",Y,U),{find:z,get:F,json:O}=H,Q={find:z,get:F,json:O},Z=(R=T.get,_=Q$($))=>{let S=R(Q);return z6(_,Y,S,X),U.clear(),S},E={...T,type:"writable_pure_selector",subject:X,install:(R)=>_X(R,T,W),get:Z,set:(R)=>{let _=Q$($),S=Z(T.get,_),x=mW(R)(S);if($.logger.info("\uD83D\uDCDD","writable_pure_selector",Y,"set (",S,"->",x,")"),z6(_,T.key,x,X),WT(_,T.key),$T(_))X.next({newValue:x,oldValue:S});T.set(H,x)},...W&&{family:W}};w.writableSelectors.set(Y,E);let M=Z();$.logger.info("\u2728",E.type,E.key,"=",M);let L={key:Y,type:"writable_pure_selector"};if(W)L.family=W;return L};function OV($,T){let W="set"in T,w="const"in T;if(w&&W){let U=cz($,T,void 0);return $.on.selectorCreation.next(U),U}if(w){let U=gz($,T,void 0);return $.on.selectorCreation.next(U),U}if(W){let U=_X($,T,void 0);return $.on.selectorCreation.next(U),U}let X=mz($,T,void 0);return $.on.selectorCreation.next(X),X}function Bz($,T,W){let w=T.key,X="writable_pure_selector_family",U={key:w,type:"writable_pure_selector_family"},Y=$.families.get(w);if(Y)$.logger.error("\u2757","writable_pure_selector_family",w,`Overwriting an existing ${sU(Y)} "${Y.key}" in store "${$.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);let G=new b$,z=Object.assign((F)=>{let O=G6(F),Q={key:w,subKey:O},Z=`${w}(${O})`,K=Q$($),E=_X(K,{key:Z,get:T.get(F),set:T.set(F)},Q);return G.next({type:"state_creation",token:E}),E},U,{internalRoles:W,subject:G,install:(F)=>Bz(F,T),default:(F)=>{return T.get(F)({get:(...Q)=>kX($,...Q),find:(...Q)=>t6($,...Q),json:(Q)=>cW($,Q)})}});return $.families.set(w,z),U}function PV($,T,W){let w=$.families.get(T.key);if(w===void 0)throw new JX(T,$);let X=w(W),U=Q$($);if(X.family){if($T(U))switch(X.type){case"atom":case"mutable_atom":$.on.atomCreation.next(X);break;case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":$.on.selectorCreation.next(X);break}else if(i6(U)&&U.on.transactionApplying.state===null)U.transactionMeta.update.updates.push({type:"state_creation",token:X})}return X}function CV($,T,W){let w=G6(W),X=`${T.key}(${w})`,U=Q$($),Y;switch(T.type){case"atom_family":case"mutable_atom_family":Y=U.atoms.get(X);break;case"writable_held_selector_family":case"writable_pure_selector_family":Y=U.writableSelectors.get(X);break;case"readonly_held_selector_family":case"readonly_pure_selector_family":Y=U.readonlySelectors.get(X);break}if(Y)return LX(Y);return Y}function t6($,T,W){let w=CV($,T,W);if(w)return w;let X=G6(W),U=$.molecules.get(X);if(!U&&$.config.lifespan==="immortal"){let Y=ZV(T,W);return $.logger.error("\u274C",Y.type,Y.key,`was not found in store "${$.config.name}"; returned a counterfeit token.`),Y}if(w=PV($,T,W),U)Q$($).moleculeData.set(X,T.key);return w}function SV($,T){if(T.family){let W=$.families.get(T.family.key);if(W)return W}}function wT($,...T){let W,w,X,U;if(T.length===2){if(W=T[0],U=T[1],w=SV($,W)??null,w)X=W.family?NX(W.family.subKey):null,W=t6($,w,X)}else w=T[0],X=T[1],U=T[2],W=t6($,w,X);if("counterfeit"in W&&"family"in W){let H=W.family.subKey,z=$.disposalTraces.buffer.find((F)=>F?.key===H);$.logger.error("\u274C",W.type,W.key,`could not be set because it was not found in the store "${$.config.name}".`,z?`This state was previously disposed:
4
+ ${z.trace}`:"No previous disposal trace was found.");return}let Y=AV($,W);if(Y){let H=$.on.operationClose.subscribe(`waiting to set "${W.key}" at T-${Y}`,()=>{H(),$.logger.info("\uD83D\uDFE2",W.type,W.key,`resuming deferred setState from T-${Y}`),wT($,W,U)});return}let G=j6($,W);eU($,G,U),EV($)}function kX($,...T){let W,w,X;if(T.length===1)W=T[0];else w=T[0],X=T[1],W=t6($,w,X);if("counterfeit"in W&&"family"in W){w=$.families.get(W.family.key);let U=W.family.subKey,Y=$.disposalTraces.buffer.find((G)=>G?.key===U);switch($.logger.error("\u274C",W.type,W.key,`could not be retrieved because it was not found in the store "${$.config.name}".`,Y?`This state was previously disposed:
5
+ ${Y.trace}`:"No previous disposal trace was found."),w.type){case"atom_family":case"mutable_atom_family":return $.defaults.get(w.key);case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if($.defaults.has(w.key))return $.defaults.get(W.family.key);let G=j6($,w).default(U);return $.defaults.set(w.key,G),G}}}return TT($,j6($,W))}class jV{parent=null;child=null;valueMap=new Map;defaults=new Map;atoms=new Map;writableSelectors=new Map;readonlySelectors=new Map;atomsThatAreDefault=new Set;selectorAtoms=new d1({between:["selectorKey","atomKey"],cardinality:"n:n"});selectorGraph=new d1({between:["upstreamSelectorKey","downstreamSelectorKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});trackers=new Map;families=new Map;joins=new Map;transactions=new Map;transactionMeta={epoch:new Map,actionContinuities:new d1({between:["continuity","action"],cardinality:"1:n"})};timelines=new Map;timelineTopics=new d1({between:["timelineKey","topicKey"],cardinality:"1:n"});disposalTraces=new aU(100);molecules=new Map;moleculeJoins=new d1({between:["moleculeKey","joinKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});moleculeGraph=new d1({between:["upstreamMoleculeKey","downstreamMoleculeKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});moleculeData=new d1({between:["moleculeKey","stateFamilyKey"],cardinality:"n:n"},{makeContentKey:(...$)=>$.sort().join(":")});miscResources=new Map;on={atomCreation:new b$,atomDisposal:new b$,selectorCreation:new b$,selectorDisposal:new b$,timelineCreation:new b$,transactionCreation:new b$,transactionApplying:new bz(null),operationClose:new b$,moleculeCreation:new b$,moleculeDisposal:new b$};operation={open:!1};config={name:"IMPLICIT_STORE",lifespan:"ephemeral"};loggers=[new fz("warn",($,T,W)=>!BV(W))];logger={error:(...$)=>{for(let T of this.loggers)T.error(...$)},info:(...$)=>{for(let T of this.loggers)T.info(...$)},warn:(...$)=>{for(let T of this.loggers)T.warn(...$)}};constructor($,T=null){if(this.config={...T?.config,...$},T!==null){if(this.valueMap=new Map(T?.valueMap),this.operation={...T?.operation},$T(T))this.transactionMeta={epoch:new Map(T?.transactionMeta.epoch),actionContinuities:new d1(T?.transactionMeta.actionContinuities.toJSON())};for(let[,w]of T.families){if(w.internalRoles?.includes("mutable")||w.internalRoles?.includes("join"))continue;w.install(this)}let W=new Set;for(let[,w]of T.atoms){if(W.has(w.key))continue;if(w.install(this),w.type==="mutable_atom"){let X=cW(T,w),U=IV(w);W.add(X.key),W.add(U.key)}}for(let[,w]of T.readonlySelectors)w.install(this);for(let[,w]of T.writableSelectors){if(W.has(w.key))continue;w.install(this)}for(let[,w]of T.transactions)w.install(this);for(let[,w]of T.timelines)w.install(this)}}}var QV={get STORE(){return globalThis.ATOM_IO_IMPLICIT_STORE??=new jV({name:"IMPLICIT_STORE",lifespan:"ephemeral"}),globalThis.ATOM_IO_IMPLICIT_STORE}};function j6($,T){let W,w=$;while(w!==null){switch(T.type){case"atom":case"mutable_atom":W=w.atoms.get(T.key);break;case"writable_pure_selector":case"writable_held_selector":W=w.writableSelectors.get(T.key);break;case"readonly_pure_selector":case"readonly_held_selector":W=w.readonlySelectors.get(T.key);break;case"atom_family":case"mutable_atom_family":case"writable_pure_selector_family":case"readonly_pure_selector_family":case"writable_held_selector_family":case"readonly_held_selector_family":W=w.families.get(T.key);break;case"timeline":W=w.timelines.get(T.key);break;case"transaction":W=w.transactions.get(T.key);break}if(W)return W;w=w.child}throw new JX(T,$)}var xV=($,T)=>{let W=Q$($);if(W.operation.open)return W.operation.prev.get(T.key);return W.valueMap.get(T.key)};var uz=($,T)=>{let W=Q$($);return vV(T,$).map((X)=>{let U=W.atoms.get(X);if(U===void 0)throw new Error(`Atom "${X}", a dependency of selector "${T.key}", not found in store "${$.config.name}".`);return U.subject.subscribe(`${T.type}:${T.key}`,(Y)=>{$.logger.info("\uD83D\uDCE2",T.type,T.key,"root",X,"went",Y.oldValue,"->",Y.newValue);let G=xV(W,T),H=TT(W,T);$.logger.info("\u2728",T.type,T.key,"went",G,"->",H),T.subject.next({newValue:H,oldValue:G})})})};function vX($,T,W,w){function X(O){if($.operation.open){let Q=$.on.operationClose.subscribe(`state subscription ${W}`,()=>{Q(),w(O)})}else w(O)}let U=j6($,T);$.logger.info("\uD83D\uDC40",U.type,U.key,`Adding subscription "${W}"`);let Y=U.type==="writable_pure_selector"||U.type==="readonly_pure_selector",G=null,H=X;if(Y)G=uz($,U),H=(O)=>{if(G)G.length=0,G.push(...uz($,U));X(O)};let z=U.subject.subscribe(W,H);return()=>{if($.logger.info("\uD83D\uDE48",U.type,U.key,`Removing subscription "${W}"`),z(),G)for(let O of G)O()}}var fV=($,T,W,w)=>{let X=j6($,T);$.logger.info("\uD83D\uDC40","timeline",T.key,`Adding subscription "${W}"`);let U=X.subject.subscribe(W,w);return()=>{$.logger.info("\uD83D\uDE48","timeline",T.key,`Removing subscription "${W}" from timeline`),U()}};class pz{initializeState($,T){let W=`*${$.key}`;T.atoms.delete(W),T.valueMap.delete(W);let w=$.family?{key:`*${$.family.key}`,subKey:$.family.subKey}:void 0,X=dz(T,{key:W,default:null},w);if(T.parent?.valueMap.has(W)){let U=T.parent.valueMap.get(W);T.valueMap.set(W,U)}return X}unsubscribeFromInnerValue;unsubscribeFromState;observeCore($,T,W){let w=`tracker:${W.config.name}:${i6(W)?W.transactionMeta.update.key:"main"}:${$.key}`,X=kX(W,$);this.unsubscribeFromInnerValue=X.subscribe(w,(U)=>{wT(W,T,U)}),this.unsubscribeFromState=vX(W,$,w,(U)=>{if(U.newValue!==U.oldValue)this.unsubscribeFromInnerValue(),this.unsubscribeFromInnerValue=U.newValue.subscribe(w,(Y)=>{wT(W,T,Y)})})}updateCore($,T,W){let w=`tracker:${W.config.name}:${i6(W)?W.transactionMeta.update.key:"main"}:${$.key}`;vX(W,T,w,({newValue:X,oldValue:U})=>{let Y=W.timelineTopics.getRelatedKey(T.key);if(Y){if(W.timelines.get(Y)?.timeTraveling){let z=fV(W,{key:Y,type:"timeline"},w,(F)=>{z(),wT(W,$,(O)=>{if(F==="redo"&&X)O.do(X);else if(F==="undo"&&U)O.undo(U);return O})});return}}let G=W.on.operationClose.subscribe(w,()=>{G();let H=kX(W,$),z=X===null?-1:H.getUpdateNumber(X),F=z-H.cacheUpdateNumber;if(X&&F===1)wT(W,$,(O)=>(O.do(X),O));else W.logger.info("\u274C","mutable_atom",$.key,`could not be updated. Expected update number ${H.cacheUpdateNumber+1}, but got ${z}`)})})}mutableState;latestUpdateState;[Symbol.dispose];constructor($,T){this.mutableState=$;let W=Q$(T);this.latestUpdateState=this.initializeState($,W),this.observeCore($,this.latestUpdateState,W),this.updateCore($,this.latestUpdateState,W),W.trackers.set($.key,this),this[Symbol.dispose]=()=>{this.unsubscribeFromInnerValue(),this.unsubscribeFromState(),W.trackers.delete($.key)}}}var cW=($,T)=>{if(T.family){let w=Q$($),U={key:`${T.family.key}:JSON`,type:"writable_pure_selector_family"},Y=j6(w,U),G=JSON.parse(T.family.subKey);return t6($,Y,G)}return{type:"writable_pure_selector",key:`${T.key}:JSON`}};var IV=($)=>{let W={type:"atom",key:`*${$.key}`};if($.family)W.family={key:`*${$.family.key}`,subKey:$.family.subKey};return W};function JV($){return typeof $==="object"&&$!==null&&"do"in $&&"undo"in $&&"subscribe"in $}function RX($,T,W){let w=W.valueMap.get(T.key),X=$.valueMap.get(T.key);if(w!==X)return X;if(w===void 0)return T.default();W.logger.info("\uD83D\uDCC3","atom",T.key,"copying");let U=T.toJson(w),Y=T.fromJson(U);return $.valueMap.set(T.key,Y),new pz(T,W),Y}function z6($,T,W,w){let X=$.valueMap.get(T);if(X instanceof DX)X.use(W);if(W instanceof Promise){let U=new DX(W);return $.valueMap.set(T,U),U.then((Y)=>{z6($,T,Y,w),w.next({newValue:Y,oldValue:U})}).catch((Y)=>{$.logger.error("\uD83D\uDCA5","state",T,"rejected:",Y)}),U}return $.valueMap.set(T,W),W}var KV=($,T)=>{let W=T.valueMap.get($.key);if($.type==="mutable_atom"&&i6(T)){let{parent:w}=T;W=RX(T,$,w)}return W},NV=($,T)=>{let W=T.valueMap.get($);if(W instanceof DX){let w=W,X=T.writableSelectors.get($)??T.readonlySelectors.get($);if(X)w.use(X.get());return}if(T.operation.open)T.operation.prev.set($,W);T.valueMap.delete($),T.logger.info("\uD83D\uDDD1","state",$,"evicted")};var RV=($,T)=>{return Q$($).atomsThatAreDefault.has(T)},bV=($,T)=>{let W=Q$($);W.atomsThatAreDefault=new Set(W.atomsThatAreDefault).add(T)},_V=($,T)=>{let W=Q$($);W.atomsThatAreDefault=new Set(Q$($).atomsThatAreDefault),W.atomsThatAreDefault.delete(T)};function dz($,T,W){let{key:X,default:U}=T;$.logger.info("\uD83D\uDD28","atom",X,`creating in store "${$.config.name}"`);let Y=Q$($),G=Y.atoms.get(X);if(G&&G.type==="atom")return $.logger.error("\u274C","atom",X,"Tried to create atom, but it already exists in the store."),LX(G);let H=new b$,z={...T,type:"atom",install:(Q)=>{return Q.logger.info("\uD83D\uDEE0\uFE0F","atom",X,`installing in store "${Q.config.name}"`),dz(Q,T,W)},subject:H};if(W)z.family=W;let F=U;if(U instanceof Function)F=U();Y.atoms.set(X,z),bV($,X),z6(Y,X,F,H);let O=LX(z);if(T.effects){let Q=0,Z=[];for(let K of T.effects){let E=K({setSelf:(M)=>{wT($,O,M)},onSet:(M)=>vX($,O,`effect[${Q}]`,M)});if(E)Z.push(E);++Q}z.cleanup=()=>{for(let K of Z)K()}}return O}class uW extends Set{mode="record";subject=new b$;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor($,T=0){super($);if($ instanceof uW)this.parent=$,this.cacheUpdateNumber=$.cacheUpdateNumber;if(T)this.cacheLimit=T,this.cache=new Array(T),this.subscribe("auto cache",(W)=>{this.cacheIdx++,this.cacheIdx%=this.cacheLimit,this.cache[this.cacheIdx]=W})}toJSON(){return{members:[...this],cache:this.cache,cacheLimit:this.cacheLimit,cacheIdx:this.cacheIdx,cacheUpdateNumber:this.cacheUpdateNumber}}static fromJSON($){let T=new uW($.members,$.cacheLimit);return T.cache=$.cache,T.cacheIdx=$.cacheIdx,T.cacheUpdateNumber=$.cacheUpdateNumber,T}add($){let T=super.add($);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`add:${G6($)}`);return T}clear(){let $=this.mode==="record"?[...this]:null;if(super.clear(),$)this.cacheUpdateNumber++,this.emit(`clear:${JSON.stringify($)}`)}delete($){let T=super.delete($);if(this.mode==="record")this.cacheUpdateNumber++,this.emit(`del:${G6($)}`);return T}parent=null;child=null;transactionUpdates=null;transaction($){this.mode="transaction",this.transactionUpdates=[],this.child=new uW(this);let T=this.child._subscribe("transaction",(W)=>{this.transactionUpdates?.push(W)});try{if($(this.child)){for(let w of this.transactionUpdates)this.doStep(w);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{T(),this.child=null,this.transactionUpdates=null,this.mode="record"}}_subscribe($,T){return this.subject.subscribe($,T)}subscribe($,T){return this.subject.subscribe($,(W)=>{T(`${this.cacheUpdateNumber}=${W}`)})}emit($){this.subject.next($)}doStep($){let T=$.indexOf(":"),W=$.substring(0,T),w=$.substring(T+1);switch(W){case"add":this.add(JSON.parse(w));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(w));break;case"tx":for(let X of w.split(";"))this.doStep(X)}}getUpdateNumber($){let T=$.indexOf("=");return Number($.substring(0,T))}do($){let T=$.indexOf("="),W=Number($.substring(0,T)),w=W-this.cacheUpdateNumber;if(w>0){if(w===1){this.mode="playback";let U=$.substring(T+1);return this.doStep(U),this.mode="record",this.cacheUpdateNumber=W,null}return this.cacheUpdateNumber+1}if(Math.abs(w)<this.cacheLimit){let U=this.cacheIdx+w;if(this.cache[U]===$)return null;this.mode="playback";let G=!1;while(!G){this.cacheIdx%=this.cacheLimit;let z=this.cache[this.cacheIdx];if(this.cacheIdx--,!z)return"OUT_OF_RANGE";this.undo(z),G=this.cacheIdx===U-1}let H=$.substring(T+1);return this.doStep(H),this.mode="record",this.cacheUpdateNumber=W,null}return"OUT_OF_RANGE"}undoStep($){let T=$.indexOf(":"),W=$.substring(0,T),w=$.substring(T+1);switch(W){case"add":this.delete(JSON.parse(w));break;case"del":this.add(JSON.parse(w));break;case"clear":{let X=JSON.parse(w);for(let U of X)this.add(U);break}case"tx":{let X=w.split(";");for(let U=X.length-1;U>=0;U--)this.undoStep(X[U])}}}undo($){let T=$.indexOf("=");if(Number($.substring(0,T))===this.cacheUpdateNumber){this.mode="playback";let w=$.substring(T+1);return this.undoStep(w),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}}function BV($){return $.startsWith("\uD83D\uDD0D ")}class WY{listeners;globalListeners;handleEvent($,...T){for(let w of this.globalListeners)w($,...T);let W=this.listeners.get($);if(W)for(let w of W)w(...T)}id="no_id_retrieved";emit;constructor($){this.emit=$,this.listeners=new Map,this.globalListeners=new Set}on($,T){let W=this.listeners.get($);if(W)W.add(T);else this.listeners.set($,new Set([T]));return this}onAny($){return this.globalListeners.add($),this}off($,T){let W=this.listeners.get($);if(W)if(T)W.delete(T);else this.listeners.delete($);return this}offAny($){return this.globalListeners.delete($),this}}class yV extends WY{in;out;id="no_id_retrieved";disposalFunctions=[];constructor($){super((...T)=>{return this.out.next(T),this});this.id=$,this.in=new b$,this.out=new b$,this.in.subscribe("socket",(T)=>{this.handleEvent(...T)})}dispose(){for(let $ of this.disposalFunctions)$()}}class oz extends WY{incompleteData="";unprocessedEvents=[];relays;relayServices;process;id="#####";log(...$){this.process.stderr.write(G6($.map((T)=>T instanceof uW?`{ ${T.toJSON().members.join(" | ")} }`:T))+"\x03")}logger={info:(...$)=>{this.log("i",...$)},warn:(...$)=>{this.log("w",...$)},error:(...$)=>{this.log("e",...$)}};constructor(){super(($,...T)=>{let W=JSON.stringify([$,...T]);return this.process.stdout.write(W+"\x03"),this});if(this.process=process,this.process.stdin.resume(),this.relays=new Map,this.relayServices=[],this.process.stdin.on("data",($)=>{let T=$.toString();this.unprocessedEvents.push(...T.split("\x03"));let W=this.unprocessedEvents.shift();this.incompleteData+=W??"";try{let w=NX(this.incompleteData);this.logger.info("\uD83C\uDFB0","received",w),this.handleEvent(...w);while(this.unprocessedEvents.length>0){let X=this.unprocessedEvents.shift();if(X){if(this.unprocessedEvents.length===0)this.incompleteData=X;let U=NX(X);this.handleEvent(...U)}}this.incompleteData=""}catch(w){if(w instanceof Error)this.logger.error("\u2757",w.message,w.cause,w.stack)}}),this.on("exit",()=>{this.logger.info("\uD83D\uDD25",this.id,'received "exit"'),process.exit(0)}),process.on("exit",($)=>{this.logger.info("\uD83D\uDD25",this.id,`exited with code ${$}`)}),process.on("end",()=>{this.logger.info("\uD83D\uDD25",this.id,"ended"),process.exit(0)}),process.on("SIGTERM",()=>{this.logger.error("\uD83D\uDD25",this.id,"terminated"),process.exit(0)}),process.on("SIGINT",()=>{this.logger.error("\uD83D\uDD25",this.id,"interrupted"),process.exit(0)}),process.pid)this.id=process.pid?.toString();this.on("user-joins",($)=>{this.logger.info("\uD83D\uDC64","user",$,"joined");let T=new yV(`user:${$}`);this.relays.set($,T),this.logger.info("\uD83D\uDD17","attaching services:",`[${[...this.relayServices.keys()].join(", ")}]`);for(let W of this.relayServices){let w=W(T);if(w)T.disposalFunctions.push(w)}this.on(`user:${$}`,(...W)=>{T.in.next(W)}),T.out.subscribe("socket",(W)=>{this.emit(...W)})}),this.on("user-leaves",($)=>{let T=this.relays.get($);if(this.off(`relay:${$}`),T)T.dispose(),this.relays.delete($)}),process.stdout.write("ALIVE")}relay($){this.logger.info("\uD83D\uDD17","running relay method"),this.relayServices.push($)}}var UG={};e0(UG,{xid:()=>OC,void:()=>jC,uuidv7:()=>wC,uuidv6:()=>XC,uuidv4:()=>WC,uuid:()=>TC,url:()=>UC,uppercase:()=>tX,unknown:()=>iY,union:()=>XG,undefined:()=>CC,ulid:()=>FC,uint64:()=>qC,uint32:()=>_C,tuple:()=>hC,trim:()=>W8,treeifyError:()=>X5,transform:()=>YF,toUpperCase:()=>w8,toLowerCase:()=>X8,toJSONSchema:()=>vH,templateLiteral:()=>rC,symbol:()=>PC,superRefine:()=>aK,success:()=>oC,stringbool:()=>aC,string:()=>fH,strictObject:()=>fC,startsWith:()=>sX,size:()=>rX,setErrorMap:()=>XS,set:()=>cC,safeParseAsync:()=>xH,safeParse:()=>BH,registry:()=>NY,regexes:()=>dT,regex:()=>nX,refine:()=>tK,record:()=>kK,readonly:()=>dK,property:()=>NH,promise:()=>nC,prettifyError:()=>w5,preprocess:()=>eC,prefault:()=>yK,positive:()=>AH,pipe:()=>sY,partialRecord:()=>gC,parseAsync:()=>IH,parse:()=>jH,overwrite:()=>K0,optional:()=>tY,object:()=>xC,number:()=>OK,nullish:()=>dC,nullable:()=>aY,null:()=>AK,normalize:()=>T8,nonpositive:()=>MH,nonoptional:()=>hK,nonnegative:()=>DH,never:()=>$G,negative:()=>EH,nativeEnum:()=>uC,nanoid:()=>GC,nan:()=>lC,multipleOf:()=>lT,minSize:()=>rT,minLength:()=>GT,mime:()=>$8,maxSize:()=>lW,maxLength:()=>rW,map:()=>mC,lte:()=>V1,lt:()=>Z0,lowercase:()=>iX,looseObject:()=>bC,locales:()=>dX,literal:()=>SK,length:()=>nW,lazy:()=>rK,ksuid:()=>QC,keyof:()=>BC,jwt:()=>NC,json:()=>sC,iso:()=>rY,ipv6:()=>VC,ipv4:()=>ZC,intersection:()=>RK,int64:()=>vC,int32:()=>RC,int:()=>bH,instanceof:()=>tC,includes:()=>aX,guid:()=>$C,gte:()=>B6,gt:()=>V0,globalRegistry:()=>o1,getErrorMap:()=>wS,function:()=>kH,formatError:()=>hX,float64:()=>JC,float32:()=>LC,flattenError:()=>yX,file:()=>pC,enum:()=>PK,endsWith:()=>eX,emoji:()=>YC,email:()=>eP,e164:()=>DC,discriminatedUnion:()=>yC,date:()=>IC,custom:()=>iC,cuid2:()=>HC,cuid:()=>zC,core:()=>A0,config:()=>N4,coerce:()=>FF,clone:()=>a6,cidrv6:()=>AC,cidrv4:()=>KC,check:()=>iK,catch:()=>cK,boolean:()=>QK,bigint:()=>kC,base64url:()=>MC,base64:()=>EC,array:()=>XF,any:()=>SC,_default:()=>fK,_ZodString:()=>yH,ZodXID:()=>oH,ZodVoid:()=>DK,ZodUnknown:()=>WF,ZodUnion:()=>wF,ZodUndefined:()=>VK,ZodUUID:()=>E0,ZodURL:()=>gH,ZodULID:()=>dH,ZodType:()=>k$,ZodTuple:()=>_K,ZodTransform:()=>IK,ZodTemplateLiteral:()=>oK,ZodSymbol:()=>ZK,ZodSuccess:()=>gK,ZodStringFormat:()=>W4,ZodString:()=>eY,ZodSet:()=>qK,ZodRecord:()=>UF,ZodRealError:()=>iW,ZodReadonly:()=>pK,ZodPromise:()=>nK,ZodPrefault:()=>bK,ZodPipe:()=>HF,ZodOptional:()=>GF,ZodObject:()=>WG,ZodNumberFormat:()=>tW,ZodNumber:()=>z8,ZodNullable:()=>BK,ZodNull:()=>KK,ZodNonOptional:()=>zF,ZodNever:()=>MK,ZodNanoID:()=>cH,ZodNaN:()=>uK,ZodMap:()=>vK,ZodLiteral:()=>CK,ZodLazy:()=>lK,ZodKSUID:()=>lH,ZodJWT:()=>$F,ZodIssueCode:()=>$S,ZodIntersection:()=>JK,ZodISOTime:()=>oY,ZodISODuration:()=>lY,ZodISODateTime:()=>pY,ZodISODate:()=>dY,ZodIPv6:()=>nH,ZodIPv4:()=>rH,ZodGUID:()=>nY,ZodFile:()=>jK,ZodError:()=>aP,ZodEnum:()=>G8,ZodEmoji:()=>mH,ZodEmail:()=>hH,ZodE164:()=>eH,ZodDiscriminatedUnion:()=>LK,ZodDefault:()=>xK,ZodDate:()=>TG,ZodCustom:()=>wG,ZodCatch:()=>mK,ZodCUID2:()=>pH,ZodCUID:()=>uH,ZodCIDRv6:()=>tH,ZodCIDRv4:()=>iH,ZodBoolean:()=>H8,ZodBigIntFormat:()=>TF,ZodBigInt:()=>F8,ZodBase64URL:()=>sH,ZodBase64:()=>aH,ZodArray:()=>NK,ZodAny:()=>EK,NEVER:()=>WS,$output:()=>m3,$input:()=>c3,$brand:()=>lz});var A0={};e0(A0,{version:()=>$7,util:()=>l,treeifyError:()=>X5,toJSONSchema:()=>vH,toDotPath:()=>mV,safeParseAsync:()=>Y5,safeParse:()=>U5,registry:()=>NY,regexes:()=>dT,prettifyError:()=>w5,parseAsync:()=>zY,parse:()=>YY,locales:()=>dX,isValidJWT:()=>wK,isValidBase64URL:()=>XK,isValidBase64:()=>L7,globalRegistry:()=>o1,globalConfig:()=>qX,function:()=>kH,formatError:()=>hX,flattenError:()=>yX,config:()=>N4,clone:()=>a6,_xid:()=>IY,_void:()=>QH,_uuidv7:()=>kY,_uuidv6:()=>_Y,_uuidv4:()=>RY,_uuid:()=>JY,_url:()=>vY,_uppercase:()=>tX,_unknown:()=>oW,_union:()=>PP,_undefined:()=>zH,_ulid:()=>jY,_uint64:()=>YH,_uint32:()=>$H,_tuple:()=>LH,_trim:()=>W8,_transform:()=>yP,_toUpperCase:()=>w8,_toLowerCase:()=>X8,_templateLiteral:()=>lP,_symbol:()=>GH,_success:()=>uP,_stringbool:()=>RH,_string:()=>u3,_startsWith:()=>sX,_size:()=>rX,_set:()=>BP,_safeParseAsync:()=>FY,_safeParse:()=>HY,_regex:()=>nX,_refine:()=>iP,_record:()=>jP,_readonly:()=>oP,_property:()=>NH,_promise:()=>nP,_positive:()=>AH,_pipe:()=>dP,_parseAsync:()=>GY,_parse:()=>UY,_overwrite:()=>K0,_optional:()=>hP,_number:()=>n3,_nullable:()=>gP,_null:()=>HH,_normalize:()=>T8,_nonpositive:()=>MH,_nonoptional:()=>cP,_nonnegative:()=>DH,_never:()=>OH,_negative:()=>EH,_nativeEnum:()=>fP,_nanoid:()=>PY,_nan:()=>KH,_multipleOf:()=>lT,_minSize:()=>rT,_minLength:()=>GT,_min:()=>B6,_mime:()=>$8,_maxSize:()=>lW,_maxLength:()=>rW,_max:()=>V1,_map:()=>IP,_lte:()=>V1,_lt:()=>Z0,_lowercase:()=>iX,_literal:()=>bP,_length:()=>nW,_lazy:()=>rP,_ksuid:()=>BY,_jwt:()=>cY,_isoTime:()=>l3,_isoDuration:()=>r3,_isoDateTime:()=>d3,_isoDate:()=>o3,_ipv6:()=>fY,_ipv4:()=>xY,_intersection:()=>SP,_int64:()=>UH,_int32:()=>e3,_int:()=>t3,_includes:()=>aX,_guid:()=>lX,_gte:()=>B6,_gt:()=>V0,_float64:()=>s3,_float32:()=>a3,_file:()=>JH,_enum:()=>xP,_endsWith:()=>eX,_emoji:()=>qY,_email:()=>LY,_e164:()=>mY,_discriminatedUnion:()=>CP,_default:()=>mP,_date:()=>ZH,_custom:()=>Y8,_cuid2:()=>SY,_cuid:()=>CY,_coercedString:()=>p3,_coercedNumber:()=>i3,_coercedDate:()=>VH,_coercedBoolean:()=>WH,_coercedBigint:()=>wH,_cidrv6:()=>yY,_cidrv4:()=>bY,_catch:()=>pP,_boolean:()=>TH,_bigint:()=>XH,_base64url:()=>gY,_base64:()=>hY,_array:()=>U8,_any:()=>FH,JSONSchemaGenerator:()=>uY,JSONSchema:()=>zK,Doc:()=>VY,$output:()=>m3,$input:()=>c3,$constructor:()=>k,$brand:()=>lz,$ZodXID:()=>O7,$ZodVoid:()=>B7,$ZodUnknown:()=>YT,$ZodUnion:()=>DY,$ZodUndefined:()=>C7,$ZodUUID:()=>X7,$ZodURL:()=>U7,$ZodULID:()=>F7,$ZodType:()=>K$,$ZodTuple:()=>oT,$ZodTransform:()=>d7,$ZodTemplateLiteral:()=>$3,$ZodSymbol:()=>P7,$ZodSuccess:()=>t7,$ZodStringFormat:()=>r$,$ZodString:()=>gX,$ZodSet:()=>m7,$ZodRegistry:()=>oX,$ZodRecord:()=>h7,$ZodRealError:()=>pW,$ZodReadonly:()=>e7,$ZodPromise:()=>T3,$ZodPrefault:()=>n7,$ZodPipe:()=>uX,$ZodOptional:()=>o7,$ZodObject:()=>f7,$ZodNumberFormat:()=>v7,$ZodNumber:()=>EY,$ZodNullable:()=>l7,$ZodNull:()=>S7,$ZodNonOptional:()=>i7,$ZodNever:()=>I7,$ZodNanoID:()=>G7,$ZodNaN:()=>s7,$ZodMap:()=>g7,$ZodLiteral:()=>u7,$ZodLazy:()=>W3,$ZodKSUID:()=>Q7,$ZodJWT:()=>k7,$ZodIntersection:()=>y7,$ZodISOTime:()=>K7,$ZodISODuration:()=>A7,$ZodISODateTime:()=>Z7,$ZodISODate:()=>V7,$ZodIPv6:()=>M7,$ZodIPv4:()=>E7,$ZodGUID:()=>W7,$ZodFunction:()=>_H,$ZodFile:()=>p7,$ZodError:()=>bX,$ZodEnum:()=>c7,$ZodEmoji:()=>Y7,$ZodEmail:()=>w7,$ZodE164:()=>_7,$ZodDiscriminatedUnion:()=>b7,$ZodDefault:()=>r7,$ZodDate:()=>x7,$ZodCustom:()=>X3,$ZodCheckUpperCase:()=>r5,$ZodCheckStringFormat:()=>dW,$ZodCheckStartsWith:()=>i5,$ZodCheckSizeEquals:()=>c5,$ZodCheckRegex:()=>o5,$ZodCheckProperty:()=>a5,$ZodCheckOverwrite:()=>e5,$ZodCheckNumberFormat:()=>y5,$ZodCheckMultipleOf:()=>b5,$ZodCheckMinSize:()=>m5,$ZodCheckMinLength:()=>p5,$ZodCheckMimeType:()=>s5,$ZodCheckMaxSize:()=>g5,$ZodCheckMaxLength:()=>u5,$ZodCheckLowerCase:()=>l5,$ZodCheckLessThan:()=>QY,$ZodCheckLengthEquals:()=>d5,$ZodCheckIncludes:()=>n5,$ZodCheckGreaterThan:()=>ZY,$ZodCheckEndsWith:()=>t5,$ZodCheckBigIntFormat:()=>h5,$ZodCheck:()=>z4,$ZodCatch:()=>a7,$ZodCUID2:()=>H7,$ZodCUID:()=>z7,$ZodCIDRv6:()=>N7,$ZodCIDRv4:()=>D7,$ZodBoolean:()=>mX,$ZodBigIntFormat:()=>q7,$ZodBigInt:()=>MY,$ZodBase64URL:()=>R7,$ZodBase64:()=>J7,$ZodAsyncError:()=>O0,$ZodArray:()=>cX,$ZodAny:()=>j7});function k($,T,W){function w(G,H){var z;Object.defineProperty(G,"_zod",{value:G._zod??{},enumerable:!1}),(z=G._zod).traits??(z.traits=new Set),G._zod.traits.add($),T(G,H);for(let F in Y.prototype)Object.defineProperty(G,F,{value:Y.prototype[F].bind(G)});G._zod.constr=Y,G._zod.def=H}let X=W?.Parent??Object;class U extends X{}Object.defineProperty(U,"name",{value:$});function Y(G){var H;let z=W?.Parent?new U:this;w(z,G),(H=z._zod).deferred??(H.deferred=[]);for(let F of z._zod.deferred)F();return z}return Object.defineProperty(Y,"init",{value:w}),Object.defineProperty(Y,Symbol.hasInstance,{value:(G)=>{if(W?.Parent&&G instanceof W.Parent)return!0;return G?._zod?.traits?.has($)}}),Object.defineProperty(Y,"name",{value:$}),Y}var lz=Symbol("zod_brand");class O0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}var qX={};function N4($){if($)Object.assign(qX,$);return qX}var l={};e0(l,{unwrapMessage:()=>PX,stringifyPrimitive:()=>i,required:()=>Sq,randomString:()=>XY,propertyKeyTypes:()=>BX,promiseAllObject:()=>Lq,primitiveTypes:()=>sz,prefixIssues:()=>I6,pick:()=>kq,partial:()=>Cq,optionalKeys:()=>ez,omit:()=>vq,numKeys:()=>Jq,nullish:()=>UT,normalizeParams:()=>p,merge:()=>Pq,jsonStringifyReplacer:()=>nz,joinValues:()=>f,issue:()=>W5,isPlainObject:()=>IX,isObject:()=>wY,getSizableOrigin:()=>xX,getParsedType:()=>Rq,getLengthableOrigin:()=>fX,getEnumValues:()=>CX,getElementAtPath:()=>Nq,floatSafeRemainder:()=>iz,finalizeIssue:()=>s6,extend:()=>qq,escapeRegex:()=>Q0,esc:()=>cT,defineLazy:()=>c$,createTransparentProxy:()=>_q,clone:()=>a6,cleanRegex:()=>jX,cleanEnum:()=>jq,cached:()=>SX,assignProp:()=>tz,assertNotEqual:()=>Aq,assertNever:()=>Mq,assertIs:()=>Eq,assertEqual:()=>Kq,assert:()=>Dq,allowsEval:()=>az,aborted:()=>uT,NUMBER_FORMAT_RANGES:()=>$5,Class:()=>hV,BIGINT_FORMAT_RANGES:()=>T5});function Kq($){return $}function Aq($){return $}function Eq($){}function Mq($){throw new Error}function Dq($){}function CX($){let T=Object.values($).filter((w)=>typeof w==="number");return Object.entries($).filter(([w,X])=>T.indexOf(+w)===-1).map(([w,X])=>X)}function f($,T="|"){return $.map((W)=>i(W)).join(T)}function nz($,T){if(typeof T==="bigint")return T.toString();return T}function SX($){return{get value(){{let W=$();return Object.defineProperty(this,"value",{value:W}),W}throw new Error("cached value already set")}}}function UT($){return $===null||$===void 0}function jX($){let T=$.startsWith("^")?1:0,W=$.endsWith("$")?$.length-1:$.length;return $.slice(T,W)}function iz($,T){let W=($.toString().split(".")[1]||"").length,w=(T.toString().split(".")[1]||"").length,X=W>w?W:w,U=Number.parseInt($.toFixed(X).replace(".","")),Y=Number.parseInt(T.toFixed(X).replace(".",""));return U%Y/10**X}function c$($,T,W){Object.defineProperty($,T,{get(){{let X=W();return $[T]=X,X}throw new Error("cached value already set")},set(X){Object.defineProperty($,T,{value:X})},configurable:!0})}function tz($,T,W){Object.defineProperty($,T,{value:W,writable:!0,enumerable:!0,configurable:!0})}function Nq($,T){if(!T)return $;return T.reduce((W,w)=>W?.[w],$)}function Lq($){let T=Object.keys($),W=T.map((w)=>$[w]);return Promise.all(W).then((w)=>{let X={};for(let U=0;U<T.length;U++)X[T[U]]=w[U];return X})}function XY($=10){let W="";for(let w=0;w<$;w++)W+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return W}function cT($){return JSON.stringify($)}function wY($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var az=SX(()=>{try{return new Function(""),!0}catch($){return!1}});function IX($){return typeof $==="object"&&$!==null&&(Object.getPrototypeOf($)===Object.prototype||Object.getPrototypeOf($)===null)}function Jq($){let T=0;for(let W in $)if(Object.prototype.hasOwnProperty.call($,W))T++;return T}var Rq=($)=>{let T=typeof $;switch(T){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN($)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray($))return"array";if($===null)return"null";if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return"promise";if(typeof Map!=="undefined"&&$ instanceof Map)return"map";if(typeof Set!=="undefined"&&$ instanceof Set)return"set";if(typeof Date!=="undefined"&&$ instanceof Date)return"date";if(typeof File!=="undefined"&&$ instanceof File)return"file";return"object";default:throw new Error(`Unknown data type: ${T}`)}},BX=new Set(["string","number","symbol"]),sz=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Q0($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function a6($,T,W){let w=new $._zod.constr(T??$._zod.def);if(!T||W?.parent)w._zod.parent=$;return w}function p($){let T=$;if(!T)return{};if(typeof T==="string")return{error:()=>T};if(T?.message!==void 0){if(T?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");T.error=T.message}if(delete T.message,typeof T.error==="string")return{...T,error:()=>T.error};return T}function _q($){let T;return new Proxy({},{get(W,w,X){return T??(T=$()),Reflect.get(T,w,X)},set(W,w,X,U){return T??(T=$()),Reflect.set(T,w,X,U)},has(W,w){return T??(T=$()),Reflect.has(T,w)},deleteProperty(W,w){return T??(T=$()),Reflect.deleteProperty(T,w)},ownKeys(W){return T??(T=$()),Reflect.ownKeys(T)},getOwnPropertyDescriptor(W,w){return T??(T=$()),Reflect.getOwnPropertyDescriptor(T,w)},defineProperty(W,w,X){return T??(T=$()),Reflect.defineProperty(T,w,X)}})}function i($){if(typeof $==="bigint")return $.toString()+"n";if(typeof $==="string")return`"${$}"`;return`${$}`}function ez($){return Object.keys($).filter((T)=>{return $[T]._zod.optin==="optional"&&$[T]._zod.optout==="optional"})}var $5={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},T5={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function kq($,T){let W={},w=$._zod.def;for(let X in T){if(!(X in w.shape))throw new Error(`Unrecognized key: "${X}"`);if(!T[X])continue;W[X]=w.shape[X]}return a6($,{...$._zod.def,shape:W,checks:[]})}function vq($,T){let W={...$._zod.def.shape},w=$._zod.def;for(let X in T){if(!(X in w.shape))throw new Error(`Unrecognized key: "${X}"`);if(!T[X])continue;delete W[X]}return a6($,{...$._zod.def,shape:W,checks:[]})}function qq($,T){let W={...$._zod.def,get shape(){let w={...$._zod.def.shape,...T};return tz(this,"shape",w),w},checks:[]};return a6($,W)}function Pq($,T){return a6($,{...$._zod.def,get shape(){let W={...$._zod.def.shape,...T._zod.def.shape};return tz(this,"shape",W),W},catchall:T._zod.def.catchall,checks:[]})}function Cq($,T,W){let w=T._zod.def.shape,X={...w};if(W)for(let U in W){if(!(U in w))throw new Error(`Unrecognized key: "${U}"`);if(!W[U])continue;X[U]=$?new $({type:"optional",innerType:w[U]}):w[U]}else for(let U in w)X[U]=$?new $({type:"optional",innerType:w[U]}):w[U];return a6(T,{...T._zod.def,shape:X,checks:[]})}function Sq($,T,W){let w=T._zod.def.shape,X={...w};if(W)for(let U in W){if(!(U in X))throw new Error(`Unrecognized key: "${U}"`);if(!W[U])continue;X[U]=new $({type:"nonoptional",innerType:w[U]})}else for(let U in w)X[U]=new $({type:"nonoptional",innerType:w[U]});return a6(T,{...T._zod.def,shape:X,checks:[]})}function uT($,T=0){for(let W=T;W<$.issues.length;W++)if($.issues[W].continue!==!0)return!0;return!1}function I6($,T){return T.map((W)=>{var w;return(w=W).path??(w.path=[]),W.path.unshift($),W})}function PX($){return typeof $==="string"?$:$?.message}function s6($,T,W){let w={...$,path:$.path??[]};if(!$.message){let X=PX($.inst?._zod.def?.error?.($))??PX(T?.error?.($))??PX(W.customError?.($))??PX(W.localeError?.($))??"Invalid input";w.message=X}if(delete w.inst,delete w.continue,!T?.reportInput)delete w.input;return w}function xX($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function fX($){if(Array.isArray($))return"array";if(typeof $==="string")return"string";return"unknown"}function W5(...$){let[T,W,w]=$;if(typeof T==="string")return{message:T,code:"custom",input:W,inst:w};return{...T}}function jq($){return Object.entries($).filter(([T,W])=>{return Number.isNaN(Number.parseInt(T,10))}).map((T)=>T[1])}class hV{constructor(...$){}}var gV=($,T)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:T,enumerable:!1}),Object.defineProperty($,"message",{get(){return JSON.stringify(T,nz,2)},enumerable:!0})},bX=k("$ZodError",gV),pW=k("$ZodError",gV,{Parent:Error});function yX($,T=(W)=>W.message){let W={},w=[];for(let X of $.issues)if(X.path.length>0)W[X.path[0]]=W[X.path[0]]||[],W[X.path[0]].push(T(X));else w.push(T(X));return{formErrors:w,fieldErrors:W}}function hX($,T){let W=T||function(U){return U.message},w={_errors:[]},X=(U)=>{for(let Y of U.issues)if(Y.code==="invalid_union"&&Y.errors.length)Y.errors.map((G)=>X({issues:G}));else if(Y.code==="invalid_key")X({issues:Y.issues});else if(Y.code==="invalid_element")X({issues:Y.issues});else if(Y.path.length===0)w._errors.push(W(Y));else{let G=w,H=0;while(H<Y.path.length){let z=Y.path[H];if(H!==Y.path.length-1)G[z]=G[z]||{_errors:[]};else G[z]=G[z]||{_errors:[]},G[z]._errors.push(W(Y));G=G[z],H++}}};return X($),w}function X5($,T){let W=T||function(U){return U.message},w={errors:[]},X=(U,Y=[])=>{var G,H;for(let z of U.issues)if(z.code==="invalid_union"&&z.errors.length)z.errors.map((F)=>X({issues:F},z.path));else if(z.code==="invalid_key")X({issues:z.issues},z.path);else if(z.code==="invalid_element")X({issues:z.issues},z.path);else{let F=[...Y,...z.path];if(F.length===0){w.errors.push(W(z));continue}let O=w,Q=0;while(Q<F.length){let Z=F[Q],K=Q===F.length-1;if(typeof Z==="string")O.properties??(O.properties={}),(G=O.properties)[Z]??(G[Z]={errors:[]}),O=O.properties[Z];else O.items??(O.items=[]),(H=O.items)[Z]??(H[Z]={errors:[]}),O=O.items[Z];if(K)O.errors.push(W(z));Q++}}};return X($),w}function mV($){let T=[];for(let W of $)if(typeof W==="number")T.push(`[${W}]`);else if(typeof W==="symbol")T.push(`[${JSON.stringify(String(W))}]`);else if(/[^\w$]/.test(W))T.push(`[${JSON.stringify(W)}]`);else{if(T.length)T.push(".");T.push(W)}return T.join("")}function w5($){let T=[],W=[...$.issues].sort((w,X)=>w.path.length-X.path.length);for(let w of W)if(T.push(`\u2716 ${w.message}`),w.path?.length)T.push(` \u2192 at ${mV(w.path)}`);return T.join(`
6
+ `)}var UY=($)=>(T,W,w,X)=>{let U=w?Object.assign(w,{async:!1}):{async:!1},Y=T._zod.run({value:W,issues:[]},U);if(Y instanceof Promise)throw new O0;if(Y.issues.length){let G=new(X?.Err??$)(Y.issues.map((H)=>s6(H,U,N4())));throw Error.captureStackTrace(G,X?.callee),G}return Y.value},YY=UY(pW),GY=($)=>async(T,W,w,X)=>{let U=w?Object.assign(w,{async:!0}):{async:!0},Y=T._zod.run({value:W,issues:[]},U);if(Y instanceof Promise)Y=await Y;if(Y.issues.length){let G=new(X?.Err??$)(Y.issues.map((H)=>s6(H,U,N4())));throw Error.captureStackTrace(G,X?.callee),G}return Y.value},zY=GY(pW),HY=($)=>(T,W,w)=>{let X=w?{...w,async:!1}:{async:!1},U=T._zod.run({value:W,issues:[]},X);if(U instanceof Promise)throw new O0;return U.issues.length?{success:!1,error:new($??bX)(U.issues.map((Y)=>s6(Y,X,N4())))}:{success:!0,data:U.value}},U5=HY(pW),FY=($)=>async(T,W,w)=>{let X=w?Object.assign(w,{async:!0}):{async:!0},U=T._zod.run({value:W,issues:[]},X);if(U instanceof Promise)U=await U;return U.issues.length?{success:!1,error:new $(U.issues.map((Y)=>s6(Y,X,N4())))}:{success:!0,data:U.value}},Y5=FY(pW);var dT={};e0(dT,{xid:()=>F5,uuid7:()=>bq,uuid6:()=>fq,uuid4:()=>xq,uuid:()=>pT,uppercase:()=>f5,unicodeEmail:()=>gq,undefined:()=>B5,ulid:()=>H5,time:()=>k5,string:()=>q5,rfc5322Email:()=>hq,number:()=>S5,null:()=>I5,nanoid:()=>Q5,lowercase:()=>x5,ksuid:()=>O5,ipv6:()=>M5,ipv4:()=>E5,integer:()=>C5,html5Email:()=>yq,hostname:()=>J5,guid:()=>V5,extendedDuration:()=>Bq,emoji:()=>A5,email:()=>K5,e164:()=>R5,duration:()=>Z5,domain:()=>uq,datetime:()=>v5,date:()=>_5,cuid2:()=>z5,cuid:()=>G5,cidrv6:()=>N5,cidrv4:()=>D5,browserEmail:()=>mq,boolean:()=>j5,bigint:()=>P5,base64url:()=>OY,base64:()=>L5,_emoji:()=>cq});var G5=/^[cC][^\s-]{8,}$/,z5=/^[0-9a-z]+$/,H5=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,F5=/^[0-9a-vA-V]{20}$/,O5=/^[A-Za-z0-9]{27}$/,Q5=/^[a-zA-Z0-9_-]{21}$/,Z5=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Bq=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,V5=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pT=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},xq=pT(4),fq=pT(6),bq=pT(7),K5=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,yq=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,hq=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,gq=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,mq=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,cq="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function A5(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var E5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,M5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,D5=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,N5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,L5=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,OY=/^[A-Za-z0-9_-]*$/,J5=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,uq=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,R5=/^\+(?:[0-9]){6,14}[0-9]$/,cV="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",_5=new RegExp(`^${cV}$`);function uV($){let T="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)T=`${T}\\.\\d{${$.precision}}`;else if($.precision==null)T=`${T}(\\.\\d+)?`;return T}function k5($){return new RegExp(`^${uV($)}$`)}function v5($){let T=`${cV}T${uV($)}`,W=[];if(W.push($.local?"Z?":"Z"),$.offset)W.push("([+-]\\d{2}:?\\d{2})");return T=`${T}(${W.join("|")})`,new RegExp(`^${T}$`)}var q5=($)=>{let T=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${T}$`)},P5=/^\d+n?$/,C5=/^\d+$/,S5=/^-?\d+(?:\.\d+)?/i,j5=/true|false/i,I5=/null/i;var B5=/undefined/i;var x5=/^[^A-Z]*$/,f5=/^[^a-z]*$/;var z4=k("$ZodCheck",($,T)=>{var W;$._zod??($._zod={}),$._zod.def=T,(W=$._zod).onattach??(W.onattach=[])}),dV={number:"number",bigint:"bigint",object:"date"},QY=k("$ZodCheckLessThan",($,T)=>{z4.init($,T);let W=dV[typeof T.value];$._zod.onattach.push((w)=>{let X=w._zod.bag,U=(T.inclusive?X.maximum:X.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(T.value<U)if(T.inclusive)X.maximum=T.value;else X.exclusiveMaximum=T.value}),$._zod.check=(w)=>{if(T.inclusive?w.value<=T.value:w.value<T.value)return;w.issues.push({origin:W,code:"too_big",maximum:T.value,input:w.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),ZY=k("$ZodCheckGreaterThan",($,T)=>{z4.init($,T);let W=dV[typeof T.value];$._zod.onattach.push((w)=>{let X=w._zod.bag,U=(T.inclusive?X.minimum:X.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(T.value>U)if(T.inclusive)X.minimum=T.value;else X.exclusiveMinimum=T.value}),$._zod.check=(w)=>{if(T.inclusive?w.value>=T.value:w.value>T.value)return;w.issues.push({origin:W,code:"too_small",minimum:T.value,input:w.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),b5=k("$ZodCheckMultipleOf",($,T)=>{z4.init($,T),$._zod.onattach.push((W)=>{var w;(w=W._zod.bag).multipleOf??(w.multipleOf=T.value)}),$._zod.check=(W)=>{if(typeof W.value!==typeof T.value)throw new Error("Cannot mix number and bigint in multiple_of check.");if(typeof W.value==="bigint"?W.value%T.value===BigInt(0):iz(W.value,T.value)===0)return;W.issues.push({origin:typeof W.value,code:"not_multiple_of",divisor:T.value,input:W.value,inst:$,continue:!T.abort})}}),y5=k("$ZodCheckNumberFormat",($,T)=>{z4.init($,T),T.format=T.format||"float64";let W=T.format?.includes("int"),w=W?"int":"number",[X,U]=$5[T.format];$._zod.onattach.push((Y)=>{let G=Y._zod.bag;if(G.format=T.format,G.minimum=X,G.maximum=U,W)G.pattern=C5}),$._zod.check=(Y)=>{let G=Y.value;if(W){if(!Number.isInteger(G)){Y.issues.push({expected:w,format:T.format,code:"invalid_type",input:G,inst:$});return}if(!Number.isSafeInteger(G)){if(G>0)Y.issues.push({input:G,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:w,continue:!T.abort});else Y.issues.push({input:G,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:w,continue:!T.abort});return}}if(G<X)Y.issues.push({origin:"number",input:G,code:"too_small",minimum:X,inclusive:!0,inst:$,continue:!T.abort});if(G>U)Y.issues.push({origin:"number",input:G,code:"too_big",maximum:U,inst:$})}}),h5=k("$ZodCheckBigIntFormat",($,T)=>{z4.init($,T);let[W,w]=T5[T.format];$._zod.onattach.push((X)=>{let U=X._zod.bag;U.format=T.format,U.minimum=W,U.maximum=w}),$._zod.check=(X)=>{let U=X.value;if(U<W)X.issues.push({origin:"bigint",input:U,code:"too_small",minimum:W,inclusive:!0,inst:$,continue:!T.abort});if(U>w)X.issues.push({origin:"bigint",input:U,code:"too_big",maximum:w,inst:$})}}),g5=k("$ZodCheckMaxSize",($,T)=>{z4.init($,T),$._zod.when=(W)=>{let w=W.value;return!UT(w)&&w.size!==void 0},$._zod.onattach.push((W)=>{let w=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<w)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let w=W.value;if(w.size<=T.maximum)return;W.issues.push({origin:xX(w),code:"too_big",maximum:T.maximum,input:w,inst:$,continue:!T.abort})}}),m5=k("$ZodCheckMinSize",($,T)=>{z4.init($,T),$._zod.when=(W)=>{let w=W.value;return!UT(w)&&w.size!==void 0},$._zod.onattach.push((W)=>{let w=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>w)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let w=W.value;if(w.size>=T.minimum)return;W.issues.push({origin:xX(w),code:"too_small",minimum:T.minimum,input:w,inst:$,continue:!T.abort})}}),c5=k("$ZodCheckSizeEquals",($,T)=>{z4.init($,T),$._zod.when=(W)=>{let w=W.value;return!UT(w)&&w.size!==void 0},$._zod.onattach.push((W)=>{let w=W._zod.bag;w.minimum=T.size,w.maximum=T.size,w.size=T.size}),$._zod.check=(W)=>{let w=W.value,X=w.size;if(X===T.size)return;let U=X>T.size;W.issues.push({origin:xX(w),...U?{code:"too_big",maximum:T.size}:{code:"too_small",minimum:T.size},input:W.value,inst:$,continue:!T.abort})}}),u5=k("$ZodCheckMaxLength",($,T)=>{z4.init($,T),$._zod.when=(W)=>{let w=W.value;return!UT(w)&&w.length!==void 0},$._zod.onattach.push((W)=>{let w=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<w)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let w=W.value;if(w.length<=T.maximum)return;let U=fX(w);W.issues.push({origin:U,code:"too_big",maximum:T.maximum,input:w,inst:$,continue:!T.abort})}}),p5=k("$ZodCheckMinLength",($,T)=>{z4.init($,T),$._zod.when=(W)=>{let w=W.value;return!UT(w)&&w.length!==void 0},$._zod.onattach.push((W)=>{let w=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>w)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let w=W.value;if(w.length>=T.minimum)return;let U=fX(w);W.issues.push({origin:U,code:"too_small",minimum:T.minimum,input:w,inst:$,continue:!T.abort})}}),d5=k("$ZodCheckLengthEquals",($,T)=>{z4.init($,T),$._zod.when=(W)=>{let w=W.value;return!UT(w)&&w.length!==void 0},$._zod.onattach.push((W)=>{let w=W._zod.bag;w.minimum=T.length,w.maximum=T.length,w.length=T.length}),$._zod.check=(W)=>{let w=W.value,X=w.length;if(X===T.length)return;let U=fX(w),Y=X>T.length;W.issues.push({origin:U,...Y?{code:"too_big",maximum:T.length}:{code:"too_small",minimum:T.length},input:W.value,inst:$,continue:!T.abort})}}),dW=k("$ZodCheckStringFormat",($,T)=>{var W;z4.init($,T),$._zod.onattach.push((w)=>{let X=w._zod.bag;if(X.format=T.format,T.pattern)X.patterns??(X.patterns=new Set),X.patterns.add(T.pattern)}),(W=$._zod).check??(W.check=(w)=>{if(!T.pattern)throw new Error("Not implemented.");if(T.pattern.lastIndex=0,T.pattern.test(w.value))return;w.issues.push({origin:"string",code:"invalid_format",format:T.format,input:w.value,...T.pattern?{pattern:T.pattern.toString()}:{},inst:$,continue:!T.abort})})}),o5=k("$ZodCheckRegex",($,T)=>{dW.init($,T),$._zod.check=(W)=>{if(T.pattern.lastIndex=0,T.pattern.test(W.value))return;W.issues.push({origin:"string",code:"invalid_format",format:"regex",input:W.value,pattern:T.pattern.toString(),inst:$,continue:!T.abort})}}),l5=k("$ZodCheckLowerCase",($,T)=>{T.pattern??(T.pattern=x5),dW.init($,T)}),r5=k("$ZodCheckUpperCase",($,T)=>{T.pattern??(T.pattern=f5),dW.init($,T)}),n5=k("$ZodCheckIncludes",($,T)=>{z4.init($,T);let W=new RegExp(Q0(T.includes));T.pattern=W,$._zod.onattach.push((w)=>{let X=w._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(W)}),$._zod.check=(w)=>{if(w.value.includes(T.includes,T.position))return;w.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:T.includes,input:w.value,inst:$,continue:!T.abort})}}),i5=k("$ZodCheckStartsWith",($,T)=>{z4.init($,T);let W=new RegExp(`^${Q0(T.prefix)}.*`);T.pattern??(T.pattern=W),$._zod.onattach.push((w)=>{let X=w._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(W)}),$._zod.check=(w)=>{if(w.value.startsWith(T.prefix))return;w.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:T.prefix,input:w.value,inst:$,continue:!T.abort})}}),t5=k("$ZodCheckEndsWith",($,T)=>{z4.init($,T);let W=new RegExp(`.*${Q0(T.suffix)}$`);T.pattern??(T.pattern=W),$._zod.onattach.push((w)=>{let X=w._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(W)}),$._zod.check=(w)=>{if(w.value.endsWith(T.suffix))return;w.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:T.suffix,input:w.value,inst:$,continue:!T.abort})}});function pV($,T,W){if($.issues.length)T.issues.push(...I6(W,$.issues))}var a5=k("$ZodCheckProperty",($,T)=>{z4.init($,T),$._zod.check=(W)=>{let w=T.schema._zod.run({value:W.value[T.property],issues:[]},{});if(w instanceof Promise)return w.then((X)=>pV(X,W,T.property));pV(w,W,T.property);return}}),s5=k("$ZodCheckMimeType",($,T)=>{z4.init($,T);let W=new Set(T.mime);$._zod.onattach.push((w)=>{w._zod.bag.mime=T.mime}),$._zod.check=(w)=>{if(W.has(w.value.type))return;w.issues.push({code:"invalid_value",values:T.mime,input:w.value.type,path:["type"],inst:$})}}),e5=k("$ZodCheckOverwrite",($,T)=>{z4.init($,T),$._zod.check=(W)=>{W.value=T.tx(W.value)}});class VY{constructor($=[]){if(this.content=[],this.indent=0,this)this.args=$}indented($){this.indent+=1,$(this),this.indent-=1}write($){if(typeof $==="function"){$(this,{execution:"sync"}),$(this,{execution:"async"});return}let W=$.split(`
7
+ `).filter((U)=>U),w=Math.min(...W.map((U)=>U.length-U.trimStart().length)),X=W.map((U)=>U.slice(w)).map((U)=>" ".repeat(this.indent*2)+U);for(let U of X)this.content.push(U)}compile(){let $=Function,T=this?.args,w=[...(this?.content??[""]).map((X)=>` ${X}`)];return new $(...T,w.join(`
8
+ `))}}var $7={major:4,minor:0,patch:0};var K$=k("$ZodType",($,T)=>{var W;$??($={}),$._zod.id=T.type+"_"+XY(10),$._zod.def=T,$._zod.bag=$._zod.bag||{},$._zod.version=$7;let w=[...$._zod.def.checks??[]];if($._zod.traits.has("$ZodCheck"))w.unshift($);for(let X of w)for(let U of X._zod.onattach)U($);if(w.length===0)(W=$._zod).deferred??(W.deferred=[]),$._zod.deferred?.push(()=>{$._zod.run=$._zod.parse});else{let X=(U,Y,G)=>{let H=uT(U),z;for(let F of Y){if(F._zod.when){if(!F._zod.when(U))continue}else if(H)continue;let O=U.issues.length,Q=F._zod.check(U);if(Q instanceof Promise&&G?.async===!1)throw new O0;if(z||Q instanceof Promise)z=(z??Promise.resolve()).then(async()=>{if(await Q,U.issues.length===O)return;if(!H)H=uT(U,O)});else{if(U.issues.length===O)continue;if(!H)H=uT(U,O)}}if(z)return z.then(()=>{return U});return U};$._zod.run=(U,Y)=>{let G=$._zod.parse(U,Y);if(G instanceof Promise){if(Y.async===!1)throw new O0;return G.then((H)=>X(H,w,Y))}return X(G,w,Y)}}$["~standard"]={validate:(X)=>{try{let U=U5($,X);return U.success?{value:U.data}:{issues:U.error?.issues}}catch(U){return Y5($,X).then((Y)=>Y.success?{value:Y.data}:{issues:Y.error?.issues})}},vendor:"zod",version:1}}),gX=k("$ZodString",($,T)=>{K$.init($,T),$._zod.pattern=[...$?._zod.bag?.patterns??[]].pop()??q5($._zod.bag),$._zod.parse=(W,w)=>{if(T.coerce)try{W.value=String(W.value)}catch(X){}if(typeof W.value==="string")return W;return W.issues.push({expected:"string",code:"invalid_type",input:W.value,inst:$}),W}}),r$=k("$ZodStringFormat",($,T)=>{dW.init($,T),gX.init($,T)}),W7=k("$ZodGUID",($,T)=>{T.pattern??(T.pattern=V5),r$.init($,T)}),X7=k("$ZodUUID",($,T)=>{if(T.version){let w={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[T.version];if(w===void 0)throw new Error(`Invalid UUID version: "${T.version}"`);T.pattern??(T.pattern=pT(w))}else T.pattern??(T.pattern=pT());r$.init($,T)}),w7=k("$ZodEmail",($,T)=>{T.pattern??(T.pattern=K5),r$.init($,T)}),U7=k("$ZodURL",($,T)=>{r$.init($,T),$._zod.check=(W)=>{try{let w=new URL(W.value);if(T.hostname){if(T.hostname.lastIndex=0,!T.hostname.test(w.hostname))W.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:J5.source,input:W.value,inst:$})}if(T.protocol){if(T.protocol.lastIndex=0,!T.protocol.test(w.protocol.endsWith(":")?w.protocol.slice(0,-1):w.protocol))W.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:T.protocol.source,input:W.value,inst:$})}return}catch(w){W.issues.push({code:"invalid_format",format:"url",input:W.value,inst:$})}}}),Y7=k("$ZodEmoji",($,T)=>{T.pattern??(T.pattern=A5()),r$.init($,T)}),G7=k("$ZodNanoID",($,T)=>{T.pattern??(T.pattern=Q5),r$.init($,T)}),z7=k("$ZodCUID",($,T)=>{T.pattern??(T.pattern=G5),r$.init($,T)}),H7=k("$ZodCUID2",($,T)=>{T.pattern??(T.pattern=z5),r$.init($,T)}),F7=k("$ZodULID",($,T)=>{T.pattern??(T.pattern=H5),r$.init($,T)}),O7=k("$ZodXID",($,T)=>{T.pattern??(T.pattern=F5),r$.init($,T)}),Q7=k("$ZodKSUID",($,T)=>{T.pattern??(T.pattern=O5),r$.init($,T)}),Z7=k("$ZodISODateTime",($,T)=>{T.pattern??(T.pattern=v5(T)),r$.init($,T)}),V7=k("$ZodISODate",($,T)=>{T.pattern??(T.pattern=_5),r$.init($,T)}),K7=k("$ZodISOTime",($,T)=>{T.pattern??(T.pattern=k5(T)),r$.init($,T)}),A7=k("$ZodISODuration",($,T)=>{T.pattern??(T.pattern=Z5),r$.init($,T)}),E7=k("$ZodIPv4",($,T)=>{T.pattern??(T.pattern=E5),r$.init($,T),$._zod.onattach.push((W)=>{let w=W._zod.bag;w.format="ipv4"})}),M7=k("$ZodIPv6",($,T)=>{T.pattern??(T.pattern=M5),r$.init($,T),$._zod.onattach.push((W)=>{let w=W._zod.bag;w.format="ipv6"}),$._zod.check=(W)=>{try{new URL(`http://[${W.value}]`)}catch{W.issues.push({code:"invalid_format",format:"ipv6",input:W.value,inst:$})}}}),D7=k("$ZodCIDRv4",($,T)=>{T.pattern??(T.pattern=D5),r$.init($,T)}),N7=k("$ZodCIDRv6",($,T)=>{T.pattern??(T.pattern=N5),r$.init($,T),$._zod.check=(W)=>{let[w,X]=W.value.split("/");try{if(!X)throw new Error;let U=Number(X);if(`${U}`!==X)throw new Error;if(U<0||U>128)throw new Error;new URL(`http://[${w}]`)}catch{W.issues.push({code:"invalid_format",format:"cidrv6",input:W.value,inst:$})}}});function L7($){if($==="")return!0;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}var J7=k("$ZodBase64",($,T)=>{T.pattern??(T.pattern=L5),r$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.contentEncoding="base64"}),$._zod.check=(W)=>{if(L7(W.value))return;W.issues.push({code:"invalid_format",format:"base64",input:W.value,inst:$})}});function XK($){if(!OY.test($))return!1;let T=$.replace(/[-_]/g,(w)=>w==="-"?"+":"/"),W=T.padEnd(Math.ceil(T.length/4)*4,"=");return L7(W)}var R7=k("$ZodBase64URL",($,T)=>{T.pattern??(T.pattern=OY),r$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.contentEncoding="base64url"}),$._zod.check=(W)=>{if(XK(W.value))return;W.issues.push({code:"invalid_format",format:"base64url",input:W.value,inst:$})}}),_7=k("$ZodE164",($,T)=>{T.pattern??(T.pattern=R5),r$.init($,T)});function wK($,T=null){try{let W=$.split(".");if(W.length!==3)return!1;let[w]=W,X=JSON.parse(atob(w));if("typ"in X&&X?.typ!=="JWT")return!1;if(!X.alg)return!1;if(T&&(!("alg"in X)||X.alg!==T))return!1;return!0}catch{return!1}}var k7=k("$ZodJWT",($,T)=>{r$.init($,T),$._zod.check=(W)=>{if(wK(W.value,T.alg))return;W.issues.push({code:"invalid_format",format:"jwt",input:W.value,inst:$})}}),EY=k("$ZodNumber",($,T)=>{K$.init($,T),$._zod.pattern=$._zod.bag.pattern??S5,$._zod.parse=(W,w)=>{if(T.coerce)try{W.value=Number(W.value)}catch(Y){}let X=W.value;if(typeof X==="number"&&!Number.isNaN(X)&&Number.isFinite(X))return W;let U=typeof X==="number"?Number.isNaN(X)?"NaN":!Number.isFinite(X)?"Infinity":void 0:void 0;return W.issues.push({expected:"number",code:"invalid_type",input:X,inst:$,...U?{received:U}:{}}),W}}),v7=k("$ZodNumber",($,T)=>{y5.init($,T),EY.init($,T)}),mX=k("$ZodBoolean",($,T)=>{K$.init($,T),$._zod.pattern=j5,$._zod.parse=(W,w)=>{if(T.coerce)try{W.value=Boolean(W.value)}catch(U){}let X=W.value;if(typeof X==="boolean")return W;return W.issues.push({expected:"boolean",code:"invalid_type",input:X,inst:$}),W}}),MY=k("$ZodBigInt",($,T)=>{K$.init($,T),$._zod.pattern=P5,$._zod.parse=(W,w)=>{if(T.coerce)try{W.value=BigInt(W.value)}catch(U){}let{value:X}=W;if(typeof X==="bigint")return W;return W.issues.push({expected:"bigint",code:"invalid_type",input:X,inst:$}),W}}),q7=k("$ZodBigInt",($,T)=>{h5.init($,T),MY.init($,T)}),P7=k("$ZodSymbol",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let{value:X}=W;if(typeof X==="symbol")return W;return W.issues.push({expected:"symbol",code:"invalid_type",input:X,inst:$}),W}}),C7=k("$ZodUndefined",($,T)=>{K$.init($,T),$._zod.pattern=B5,$._zod.values=new Set([void 0]),$._zod.parse=(W,w)=>{let{value:X}=W;if(typeof X==="undefined")return W;return W.issues.push({expected:"undefined",code:"invalid_type",input:X,inst:$}),W}}),S7=k("$ZodNull",($,T)=>{K$.init($,T),$._zod.pattern=I5,$._zod.values=new Set([null]),$._zod.parse=(W,w)=>{let{value:X}=W;if(X===null)return W;return W.issues.push({expected:"null",code:"invalid_type",input:X,inst:$}),W}}),j7=k("$ZodAny",($,T)=>{K$.init($,T),$._zod.parse=(W)=>W}),YT=k("$ZodUnknown",($,T)=>{K$.init($,T),$._zod.parse=(W)=>W}),I7=k("$ZodNever",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{return W.issues.push({expected:"never",code:"invalid_type",input:W.value,inst:$}),W}}),B7=k("$ZodVoid",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let{value:X}=W;if(typeof X==="undefined")return W;return W.issues.push({expected:"void",code:"invalid_type",input:X,inst:$}),W}}),x7=k("$ZodDate",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{if(T.coerce)try{W.value=new Date(W.value)}catch(G){}let X=W.value,U=X instanceof Date;if(U&&!Number.isNaN(X.getTime()))return W;return W.issues.push({expected:"date",code:"invalid_type",input:X,...U?{received:"Invalid Date"}:{},inst:$}),W}});function lV($,T,W){if($.issues.length)T.issues.push(...I6(W,$.issues));T.value[W]=$.value}var cX=k("$ZodArray",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let X=W.value;if(!Array.isArray(X))return W.issues.push({expected:"array",code:"invalid_type",input:X,inst:$}),W;W.value=Array(X.length);let U=[];for(let Y=0;Y<X.length;Y++){let G=X[Y],H=T.element._zod.run({value:G,issues:[]},w);if(H instanceof Promise)U.push(H.then((z)=>lV(z,W,Y)));else lV(H,W,Y)}if(U.length)return Promise.all(U).then(()=>W);return W}});function KY($,T,W){if($.issues.length)T.issues.push(...I6(W,$.issues));T.value[W]=$.value}function rV($,T,W,w){if($.issues.length)if(w[W]===void 0)if(W in w)T.value[W]=void 0;else T.value[W]=$.value;else T.issues.push(...I6(W,$.issues));else if($.value===void 0){if(W in w)T.value[W]=void 0}else T.value[W]=$.value}var f7=k("$ZodObject",($,T)=>{K$.init($,T);let W=SX(()=>{let O=Object.keys(T.shape);for(let Z of O)if(!(T.shape[Z]instanceof K$))throw new Error(`Invalid element at key "${Z}": expected a Zod schema`);let Q=ez(T.shape);return{shape:T.shape,keys:O,keySet:new Set(O),numKeys:O.length,optionalKeys:new Set(Q)}});c$($._zod,"propValues",()=>{let O=T.shape,Q={};for(let Z in O){let K=O[Z]._zod;if(K.values){Q[Z]??(Q[Z]=new Set);for(let E of K.values)Q[Z].add(E)}}return Q});let w=(O)=>{let Q=new VY(["shape","payload","ctx"]),{keys:Z,optionalKeys:K}=W.value,E=(R)=>{let _=cT(R);return`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`};Q.write("const input = payload.value;");let M=Object.create(null);for(let R of Z)M[R]=XY(15);Q.write("const newResult = {}");for(let R of Z)if(K.has(R)){let _=M[R];Q.write(`const ${_} = ${E(R)};`);let S=cT(R);Q.write(`
9
+ if (${_}.issues.length) {
10
+ if (input[${S}] === undefined) {
11
+ if (${S} in input) {
12
+ newResult[${S}] = undefined;
13
13
  }
14
14
  } else {
15
15
  payload.issues = payload.issues.concat(
16
- ${L}.issues.map((iss) => ({
16
+ ${_}.issues.map((iss) => ({
17
17
  ...iss,
18
- path: iss.path ? [${q}, ...iss.path] : [${q}],
18
+ path: iss.path ? [${S}, ...iss.path] : [${S}],
19
19
  }))
20
20
  );
21
21
  }
22
- } else if (${L}.value === undefined) {
23
- if (${q} in input) newResult[${q}] = undefined;
22
+ } else if (${_}.value === undefined) {
23
+ if (${S} in input) newResult[${S}] = undefined;
24
24
  } else {
25
- newResult[${q}] = ${L}.value;
25
+ newResult[${S}] = ${_}.value;
26
26
  }
27
- `)}else{let L=I[N];F.write(`const ${L} = ${K(N)};`),F.write(`
28
- if (${L}.issues.length) payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
27
+ `)}else{let _=M[R];Q.write(`const ${_} = ${E(R)};`),Q.write(`
28
+ if (${_}.issues.length) payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
29
29
  ...iss,
30
- path: iss.path ? [${a1(N)}, ...iss.path] : [${a1(N)}]
31
- })));`),F.write(`newResult[${a1(N)}] = ${L}.value`)}F.write("payload.value = newResult;"),F.write("return payload;");let k=F.compile();return(N,L)=>k(z,N,L)},X,Y=lU,_=!FW.jitless,G=_&&F_.value,{catchall:J}=T,H;$._zod.parse=(z,F)=>{H??(H=W.value);let Q=z.value;if(!Y(Q))return z.issues.push({expected:"object",code:"invalid_type",input:Q,inst:$}),z;let V=[];if(_&&G&&F?.async===!1&&F.jitless!==!0){if(!X)X=U(T.shape);z=X(z,F)}else{z.value={};let L=H.shape;for(let q of H.keys){let y=L[q],x=y._zod.run({value:Q[q],issues:[]},F),u=y._zod.optin==="optional"&&y._zod.optout==="optional";if(x instanceof Promise)V.push(x.then((w$)=>u?I3(w$,z,q,Q):YX(w$,z,q)));else if(u)I3(x,z,q,Q);else YX(x,z,q)}}if(!J)return V.length?Promise.all(V).then(()=>z):z;let K=[],I=H.keySet,k=J._zod,N=k.def.type;for(let L of Object.keys(Q)){if(I.has(L))continue;if(N==="never"){K.push(L);continue}let q=k.run({value:Q[L],issues:[]},F);if(q instanceof Promise)V.push(q.then((y)=>YX(y,z,L)));else YX(q,z,L)}if(K.length)z.issues.push({code:"unrecognized_keys",keys:K,input:Q,inst:$});if(!V.length)return z;return Promise.all(V).then(()=>{return z})}});function k3($,T,W,U){for(let X of $)if(X.issues.length===0)return T.value=X.value,T;return T.issues.push({code:"invalid_union",input:T.value,inst:W,errors:$.map((X)=>X.issues.map((Y)=>n4(Y,U,t$())))}),T}var GX=E("$ZodUnion",($,T)=>{T$.init($,T),N$($._zod,"values",()=>{if(T.options.every((W)=>W._zod.values))return new Set(T.options.flatMap((W)=>Array.from(W._zod.values)));return}),N$($._zod,"pattern",()=>{if(T.options.every((W)=>W._zod.pattern)){let W=T.options.map((U)=>U._zod.pattern);return new RegExp(`^(${W.map((U)=>QW(U.source)).join("|")})$`)}return}),$._zod.parse=(W,U)=>{let X=!1,Y=[];for(let _ of T.options){let w=_._zod.run({value:W.value,issues:[]},U);if(w instanceof Promise)Y.push(w),X=!0;else{if(w.issues.length===0)return w;Y.push(w)}}if(!X)return k3(Y,W,$,U);return Promise.all(Y).then((_)=>{return k3(_,W,$,U)})}});function g3($,T,W){let U=!0,X=$?.[T];if(W.values.size&&!W.values.has(X))U=!1;if(W.maps.length>0){for(let Y of W.maps)if(!JN(X,Y))U=!1}return U}function JN($,T){let W=!0;for(let[U,X]of T)if(!g3($,U,X))W=!1;return W}var tw=E("$ZodDiscriminatedUnion",($,T)=>{GX.init($,T);let W=$._zod.parse;N$($._zod,"disc",()=>{let X=new Map;for(let Y of T.options){let _=Y._zod.disc;if(!_)throw new Error(`Invalid discriminated union option at index "${T.options.indexOf(Y)}"`);for(let[w,G]of _){if(!X.has(w))X.set(w,{values:new Set,maps:[]});let J=X.get(w);for(let H of G.values)J.values.add(H);for(let H of G.maps)J.maps.push(H)}}return X});let U=DW(()=>{let X=new Map;for(let Y of T.options){let _=Y._zod.disc?.get(T.discriminator);if(!_)throw new Error("Invalid discriminated union option");X.set(Y,_)}return X});$._zod.parse=(X,Y)=>{let _=X.value;if(!lU(_))return X.issues.push({code:"invalid_type",expected:"object",input:_,inst:$}),X;let w=[],G=U.value;for(let J of T.options){let H=G.get(J);if(g3(_,T.discriminator,H))w.push(J)}if(w.length===1)return w[0]._zod.run(X,Y);if(T.unionFallback)return W(X,Y);return X.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:_,path:[T.discriminator],inst:$}),X}}),aw=E("$ZodIntersection",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let{value:X}=W,Y=T.left._zod.run({value:X,issues:[]},U),_=T.right._zod.run({value:X,issues:[]},U);if(Y instanceof Promise||_ instanceof Promise)return Promise.all([Y,_]).then(([G,J])=>{return v3(W,G,J)});return v3(W,Y,_)}});function Dw($,T){if($===T)return{valid:!0,data:$};if($ instanceof Date&&T instanceof Date&&+$===+T)return{valid:!0,data:$};if(ZW($)&&ZW(T)){let W=Object.keys(T),U=Object.keys($).filter((Y)=>W.indexOf(Y)!==-1),X={...$,...T};for(let Y of U){let _=Dw($[Y],T[Y]);if(!_.valid)return{valid:!1,mergeErrorPath:[Y,..._.mergeErrorPath]};X[Y]=_.data}return{valid:!0,data:X}}if(Array.isArray($)&&Array.isArray(T)){if($.length!==T.length)return{valid:!1,mergeErrorPath:[]};let W=[];for(let U=0;U<$.length;U++){let X=$[U],Y=T[U],_=Dw(X,Y);if(!_.valid)return{valid:!1,mergeErrorPath:[U,..._.mergeErrorPath]};W.push(_.data)}return{valid:!0,data:W}}return{valid:!1,mergeErrorPath:[]}}function v3($,T,W){if(T.issues.length)$.issues.push(...T.issues);if(W.issues.length)$.issues.push(...W.issues);if(s1($))return $;let U=Dw(T.value,W.value);if(!U.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(U.mergeErrorPath)}`);return $.value=U.data,$}var T0=E("$ZodTuple",($,T)=>{T$.init($,T);let W=T.items,U=W.length-[...W].reverse().findIndex((X)=>X._zod.optin!=="optional");$._zod.parse=(X,Y)=>{let _=X.value;if(!Array.isArray(_))return X.issues.push({input:_,inst:$,expected:"tuple",code:"invalid_type"}),X;X.value=[];let w=[];if(!T.rest){let J=_.length>W.length,H=_.length<U-1;if(J||H)return X.issues.push({input:_,inst:$,origin:"array",...J?{code:"too_big",maximum:W.length}:{code:"too_small",minimum:W.length}}),X}let G=-1;for(let J of W){if(G++,G>=_.length){if(G>=U)continue}let H=J._zod.run({value:_[G],issues:[]},Y);if(H instanceof Promise)w.push(H.then((z)=>_X(z,X,G)));else _X(H,X,G)}if(T.rest){let J=_.slice(W.length);for(let H of J){G++;let z=T.rest._zod.run({value:H,issues:[]},Y);if(z instanceof Promise)w.push(z.then((F)=>_X(F,X,G)));else _X(z,X,G)}}if(w.length)return Promise.all(w).then(()=>X);return X}});function _X($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues));T.value[W]=$.value}var sw=E("$ZodRecord",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(!ZW(X))return W.issues.push({expected:"record",code:"invalid_type",input:X,inst:$}),W;let Y=[];if(T.keyType._zod.values){let _=T.keyType._zod.values;W.value={};for(let G of _)if(typeof G==="string"||typeof G==="number"||typeof G==="symbol"){let J=T.valueType._zod.run({value:X[G],issues:[]},U);if(J instanceof Promise)Y.push(J.then((H)=>{if(H.issues.length)W.issues.push(...x4(G,H.issues));W.value[G]=H.value}));else{if(J.issues.length)W.issues.push(...x4(G,J.issues));W.value[G]=J.value}}let w;for(let G in X)if(!_.has(G))w=w??[],w.push(G);if(w&&w.length>0)W.issues.push({code:"unrecognized_keys",input:X,inst:$,keys:w})}else{W.value={};for(let _ of Reflect.ownKeys(X)){if(_==="__proto__")continue;let w=T.keyType._zod.run({value:_,issues:[]},U);if(w instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(w.issues.length){W.issues.push({origin:"record",code:"invalid_key",issues:w.issues.map((J)=>n4(J,U,t$())),input:_,path:[_],inst:$}),W.value[w.value]=w.value;continue}let G=T.valueType._zod.run({value:X[_],issues:[]},U);if(G instanceof Promise)Y.push(G.then((J)=>{if(J.issues.length)W.issues.push(...x4(_,J.issues));W.value[w.value]=J.value}));else{if(G.issues.length)W.issues.push(...x4(_,G.issues));W.value[w.value]=G.value}}}if(Y.length)return Promise.all(Y).then(()=>W);return W}}),ew=E("$ZodMap",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(!(X instanceof Map))return W.issues.push({expected:"map",code:"invalid_type",input:X,inst:$}),W;let Y=[];W.value=new Map;for(let[_,w]of X){let G=T.keyType._zod.run({value:_,issues:[]},U),J=T.valueType._zod.run({value:w,issues:[]},U);if(G instanceof Promise||J instanceof Promise)Y.push(Promise.all([G,J]).then(([H,z])=>{q3(H,z,W,_,X,$,U)}));else q3(G,J,W,_,X,$,U)}if(Y.length)return Promise.all(Y).then(()=>W);return W}});function q3($,T,W,U,X,Y,_){if($.issues.length)if(VW.has(typeof U))W.issues.push(...x4(U,$.issues));else W.issues.push({origin:"map",code:"invalid_key",input:X,inst:Y,issues:$.issues.map((w)=>n4(w,_,t$()))});if(T.issues.length)if(VW.has(typeof U))W.issues.push(...x4(U,T.issues));else W.issues.push({origin:"map",code:"invalid_element",input:X,inst:Y,key:U,issues:T.issues.map((w)=>n4(w,_,t$()))});W.value.set($.value,T.value)}var $J=E("$ZodSet",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(!(X instanceof Set))return W.issues.push({input:X,inst:$,expected:"set",code:"invalid_type"}),W;let Y=[];W.value=new Set;for(let _ of X){let w=T.valueType._zod.run({value:_,issues:[]},U);if(w instanceof Promise)Y.push(w.then((G)=>P3(G,W)));else P3(w,W)}if(Y.length)return Promise.all(Y).then(()=>W);return W}});function P3($,T){if($.issues.length)T.issues.push(...$.issues);T.value.add($.value)}var TJ=E("$ZodEnum",($,T)=>{T$.init($,T);let W=Object.values(T.entries).filter((X)=>typeof X==="number"),U=Object.entries(T.entries).filter(([X,Y])=>W.indexOf(+X)===-1).map(([X,Y])=>Y);$._zod.values=new Set(U),$._zod.pattern=new RegExp(`^(${U.filter((X)=>VW.has(typeof X)).map((X)=>typeof X==="string"?p6(X):X.toString()).join("|")})$`),$._zod.parse=(X,Y)=>{let _=X.value;if($._zod.values.has(_))return X;return X.issues.push({code:"invalid_value",values:U,input:_,inst:$}),X}}),WJ=E("$ZodLiteral",($,T)=>{T$.init($,T),$._zod.values=new Set(T.values),$._zod.pattern=new RegExp(`^(${T.values.map((W)=>typeof W==="string"?p6(W):W?W.toString():String(W)).join("|")})$`),$._zod.parse=(W,U)=>{let X=W.value;if($._zod.values.has(X))return W;return W.issues.push({code:"invalid_value",values:T.values,input:X,inst:$}),W}}),UJ=E("$ZodFile",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let X=W.value;if(X instanceof File)return W;return W.issues.push({expected:"file",code:"invalid_type",input:X,inst:$}),W}}),XJ=E("$ZodTransform",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let X=T.transform(W.value,W);if(U.async)return(X instanceof Promise?X:Promise.resolve(X)).then((_)=>{return W.value=_,W});if(X instanceof Promise)throw new u6;return W.value=X,W}}),YJ=E("$ZodOptional",($,T)=>{T$.init($,T),$._zod.optin="optional",$._zod.optout="optional",N$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,void 0]):void 0}),N$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${QW(W.source)})?$`):void 0}),$._zod.parse=(W,U)=>{if(W.value===void 0)return W;return T.innerType._zod.run(W,U)}}),_J=E("$ZodNullable",($,T)=>{T$.init($,T),N$($._zod,"optin",()=>T.innerType._zod.optin),N$($._zod,"optout",()=>T.innerType._zod.optout),N$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${QW(W.source)}|null)$`):void 0}),N$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,null]):void 0}),$._zod.parse=(W,U)=>{if(W.value===null)return W;return T.innerType._zod.run(W,U)}}),wJ=E("$ZodDefault",($,T)=>{T$.init($,T),$._zod.optin="optional",N$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,U)=>{if(W.value===void 0)return W.value=T.defaultValue,W;let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>C3(Y,T));return C3(X,T)}});function C3($,T){if($.value===void 0)$.value=T.defaultValue;return $}var JJ=E("$ZodPrefault",($,T)=>{T$.init($,T),$._zod.optin="optional",N$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,U)=>{if(W.value===void 0)W.value=T.defaultValue;return T.innerType._zod.run(W,U)}}),GJ=E("$ZodNonOptional",($,T)=>{T$.init($,T),N$($._zod,"values",()=>{let W=T.innerType._zod.values;return W?new Set([...W].filter((U)=>U!==void 0)):void 0}),$._zod.parse=(W,U)=>{let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>j3(Y,$));return j3(X,$)}});function j3($,T){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:T});return $}var zJ=E("$ZodSuccess",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>{return W.value=Y.issues.length===0,W});return W.value=X.issues.length===0,W}}),HJ=E("$ZodCatch",($,T)=>{T$.init($,T),N$($._zod,"optin",()=>T.innerType._zod.optin),N$($._zod,"optout",()=>T.innerType._zod.optout),N$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,U)=>{let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>{if(W.value=Y.value,Y.issues.length)W.value=T.catchValue({...W,error:{issues:Y.issues.map((_)=>n4(_,U,t$()))},input:W.value}),W.issues=[];return W});if(W.value=X.value,X.issues.length)W.value=T.catchValue({...W,error:{issues:X.issues.map((Y)=>n4(Y,U,t$()))},input:W.value}),W.issues=[];return W}}),FJ=E("$ZodNaN",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{if(typeof W.value!=="number"||!Number.isNaN(W.value))return W.issues.push({input:W.value,inst:$,expected:"nan",code:"invalid_type"}),W;return W}}),RW=E("$ZodPipe",($,T)=>{T$.init($,T),N$($._zod,"values",()=>T.in._zod.values),N$($._zod,"optin",()=>T.in._zod.optin),N$($._zod,"optout",()=>T.out._zod.optout),$._zod.parse=(W,U)=>{let X=T.in._zod.run(W,U);if(X instanceof Promise)return X.then((Y)=>x3(Y,T,U));return x3(X,T,U)}});function x3($,T,W){if(s1($))return $;return T.out._zod.run({value:$.value,issues:$.issues},W)}var OJ=E("$ZodReadonly",($,T)=>{T$.init($,T),N$($._zod,"disc",()=>T.innerType._zod.disc),N$($._zod,"optin",()=>T.innerType._zod.optin),N$($._zod,"optout",()=>T.innerType._zod.optout),$._zod.parse=(W,U)=>{let X=T.innerType._zod.run(W,U);if(X instanceof Promise)return X.then(b3);return b3(X)}});function b3($){return $.value=Object.freeze($.value),$}var DJ=E("$ZodTemplateLiteral",($,T)=>{T$.init($,T);let W=[];for(let U of T.parts)if(U instanceof T$){if(!U._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...U._zod.traits].shift()}`);let X=U._zod.pattern instanceof RegExp?U._zod.pattern.source:U._zod.pattern;if(!X)throw new Error(`Invalid template literal part: ${U._zod.traits}`);let Y=X.startsWith("^")?1:0,_=X.endsWith("$")?X.length-1:X.length;W.push(X.slice(Y,_))}else if(U===null||O_.has(typeof U))W.push(p6(`${U}`));else throw new Error(`Invalid template literal part: ${U}`);$._zod.pattern=new RegExp(`^${W.join("")}$`),$._zod.parse=(U,X)=>{if(typeof U.value!=="string")return U.issues.push({input:U.value,inst:$,expected:"template_literal",code:"invalid_type"}),U;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(U.value))return U.issues.push({input:U.value,inst:$,code:"invalid_format",format:"template_literal",pattern:$._zod.pattern.source}),U;return U}}),QJ=E("$ZodPromise",($,T)=>{T$.init($,T),$._zod.parse=(W,U)=>{return Promise.resolve(W.value).then((X)=>T.innerType._zod.run({value:X,issues:[]},U))}}),ZJ=E("$ZodLazy",($,T)=>{T$.init($,T),N$($._zod,"innerType",()=>T.getter()),N$($._zod,"pattern",()=>$._zod.innerType._zod.pattern),N$($._zod,"disc",()=>$._zod.innerType._zod.disc),N$($._zod,"optin",()=>$._zod.innerType._zod.optin),N$($._zod,"optout",()=>$._zod.innerType._zod.optout),$._zod.parse=(W,U)=>{return $._zod.innerType._zod.run(W,U)}}),VJ=E("$ZodCustom",($,T)=>{u$.init($,T),T$.init($,T),$._zod.parse=(W,U)=>{return W},$._zod.check=(W)=>{let U=W.value,X=T.fn(U);if(X instanceof Promise)return X.then((Y)=>f3(Y,W,U,$));f3(X,W,U,$);return}});function f3($,T,W,U){if(!$){let X={code:"custom",input:W,inst:U,path:[...U._zod.def.path??[]],continue:!U._zod.def.abort};if(U._zod.def.params)X.params=U._zod.def.params;T.issues.push(V_(X))}}var kW={};N1(kW,{zhTW:()=>eJ,zhCN:()=>sJ,vi:()=>aJ,ur:()=>tJ,ua:()=>nJ,tr:()=>iJ,th:()=>rJ,ta:()=>lJ,sv:()=>dJ,sl:()=>oJ,ru:()=>pJ,pt:()=>uJ,pl:()=>cJ,ota:()=>mJ,no:()=>gJ,nl:()=>hJ,ms:()=>yJ,mk:()=>fJ,ko:()=>bJ,kh:()=>xJ,ja:()=>jJ,it:()=>CJ,id:()=>PJ,hu:()=>qJ,he:()=>vJ,frCA:()=>kJ,fr:()=>IJ,fi:()=>RJ,fa:()=>BJ,es:()=>SJ,en:()=>IW,de:()=>LJ,cs:()=>NJ,ca:()=>MJ,be:()=>AJ,az:()=>EJ,ar:()=>KJ});var GN={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function c3($){return GN[$]??null}var zN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},HN={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},FN=($)=>{switch($.code){case"invalid_type":return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${$.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${zN($.input)}`;case"invalid_value":if($.values.length===1)return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${c($.values[0])}`;return`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=c3($.origin);if(W)return` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${$.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${T} ${$.maximum.toString()} ${W.unit??"\u0639\u0646\u0635\u0631"}`;return`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${$.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=c3($.origin);if(W)return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${$.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${T} ${$.minimum.toString()} ${W.unit}`;return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${$.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${$.prefix}"`;if(T.format==="ends_with")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${T.suffix}"`;if(T.format==="includes")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${T.includes}"`;if(T.format==="regex")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${T.pattern}`;return`${HN[T.format]??$.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${$.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${$.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${$.keys.length>1?"\u0629":""}: ${R($.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${$.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${$.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}};function KJ(){return{localeError:FN}}var ON={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function u3($){return ON[$]??null}var DN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},QN={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},ZN=($)=>{switch($.code){case"invalid_type":return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${$.expected}, daxil olan ${DN($.input)}`;case"invalid_value":if($.values.length===1)return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${c($.values[0])}`;return`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=u3($.origin);if(W)return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${$.origin??"d\u0259y\u0259r"} ${T}${$.maximum.toString()} ${W.unit??"element"}`;return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${$.origin??"d\u0259y\u0259r"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=u3($.origin);if(W)return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${$.origin} ${T}${$.minimum.toString()} ${W.unit}`;return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Yanl\u0131\u015F m\u0259tn: "${T.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`;if(T.format==="ends_with")return`Yanl\u0131\u015F m\u0259tn: "${T.suffix}" il\u0259 bitm\u0259lidir`;if(T.format==="includes")return`Yanl\u0131\u015F m\u0259tn: "${T.includes}" daxil olmal\u0131d\u0131r`;if(T.format==="regex")return`Yanl\u0131\u015F m\u0259tn: ${T.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`;return`Yanl\u0131\u015F ${QN[T.format]??$.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${$.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${$.keys.length>1?"lar":""}: ${R($.keys,", ")}`;case"invalid_key":return`${$.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${$.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}};function EJ(){return{localeError:ZN}}function p3($,T,W,U){let X=Math.abs($),Y=X%10,_=X%100;if(_>=11&&_<=19)return U;if(Y===1)return T;if(Y>=2&&Y<=4)return W;return U}var VN={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function o3($){return VN[$]??null}var KN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u043B\u0456\u043A";case"object":{if(Array.isArray($))return"\u043C\u0430\u0441\u0456\u045E";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},EN={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},AN=($)=>{switch($.code){case"invalid_type":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${$.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${KN($.input)}`;case"invalid_value":if($.values.length===1)return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${c($.values[0])}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=o3($.origin);if(W){let U=Number($.maximum),X=p3(U,W.unit.one,W.unit.few,W.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${$.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${W.verb} ${T}${$.maximum.toString()} ${X}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${$.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=o3($.origin);if(W){let U=Number($.minimum),X=p3(U,W.unit.one,W.unit.few,W.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${$.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${W.verb} ${T}${$.minimum.toString()} ${X}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${$.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${T.prefix}"`;if(T.format==="ends_with")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${T.suffix}"`;if(T.format==="includes")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${T.includes}"`;if(T.format==="regex")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${T.pattern}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${EN[T.format]??$.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${$.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${$.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${R($.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${$.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${$.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}};function AJ(){return{localeError:AN}}var MN={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function d3($){return MN[$]??null}var NN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},LN={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},SN=($)=>{switch($.code){case"invalid_type":return`Tipus inv\xE0lid: s'esperava ${$.expected}, s'ha rebut ${NN($.input)}`;case"invalid_value":if($.values.length===1)return`Valor inv\xE0lid: s'esperava ${c($.values[0])}`;return`Opci\xF3 inv\xE0lida: s'esperava una de ${R($.values," o ")}`;case"too_big":{let T=$.inclusive?"com a m\xE0xim":"menys de",W=d3($.origin);if(W)return`Massa gran: s'esperava que ${$.origin??"el valor"} contingu\xE9s ${T} ${$.maximum.toString()} ${W.unit??"elements"}`;return`Massa gran: s'esperava que ${$.origin??"el valor"} fos ${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?"com a m\xEDnim":"m\xE9s de",W=d3($.origin);if(W)return`Massa petit: s'esperava que ${$.origin} contingu\xE9s ${T} ${$.minimum.toString()} ${W.unit}`;return`Massa petit: s'esperava que ${$.origin} fos ${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Format inv\xE0lid: ha de comen\xE7ar amb "${T.prefix}"`;if(T.format==="ends_with")return`Format inv\xE0lid: ha d'acabar amb "${T.suffix}"`;if(T.format==="includes")return`Format inv\xE0lid: ha d'incloure "${T.includes}"`;if(T.format==="regex")return`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${T.pattern}`;return`Format inv\xE0lid per a ${LN[T.format]??$.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${$.divisor}`;case"unrecognized_keys":return`Clau${$.keys.length>1?"s":""} no reconeguda${$.keys.length>1?"s":""}: ${R($.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${$.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${$.origin}`;default:return"Entrada inv\xE0lida"}};function MJ(){return{localeError:SN}}var BN={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function l3($){return BN[$]??null}var RN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u010D\xEDslo";case"string":return"\u0159et\u011Bzec";case"boolean":return"boolean";case"bigint":return"bigint";case"function":return"funkce";case"symbol":return"symbol";case"undefined":return"undefined";case"object":{if(Array.isArray($))return"pole";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},IN={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},kN=($)=>{switch($.code){case"invalid_type":return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${$.expected}, obdr\u017Eeno ${RN($.input)}`;case"invalid_value":if($.values.length===1)return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${c($.values[0])}`;return`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=l3($.origin);if(W)return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${$.origin??"hodnota"} mus\xED m\xEDt ${T}${$.maximum.toString()} ${W.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${$.origin??"hodnota"} mus\xED b\xFDt ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=l3($.origin);if(W)return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${$.origin??"hodnota"} mus\xED m\xEDt ${T}${$.minimum.toString()} ${W.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${$.origin??"hodnota"} mus\xED b\xFDt ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${T.prefix}"`;if(T.format==="ends_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${T.suffix}"`;if(T.format==="includes")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${T.includes}"`;if(T.format==="regex")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${T.pattern}`;return`Neplatn\xFD form\xE1t ${IN[T.format]??$.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${$.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${R($.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${$.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${$.origin}`;default:return"Neplatn\xFD vstup"}};function NJ(){return{localeError:kN}}var vN={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function r3($){return vN[$]??null}var qN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"Zahl";case"object":{if(Array.isArray($))return"Array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},PN={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},CN=($)=>{switch($.code){case"invalid_type":return`Ung\xFCltige Eingabe: erwartet ${$.expected}, erhalten ${qN($.input)}`;case"invalid_value":if($.values.length===1)return`Ung\xFCltige Eingabe: erwartet ${c($.values[0])}`;return`Ung\xFCltige Option: erwartet eine von ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=r3($.origin);if(W)return`Zu gro\xDF: erwartet, dass ${$.origin??"Wert"} ${T}${$.maximum.toString()} ${W.unit??"Elemente"} hat`;return`Zu gro\xDF: erwartet, dass ${$.origin??"Wert"} ${T}${$.maximum.toString()} ist`}case"too_small":{let T=$.inclusive?">=":">",W=r3($.origin);if(W)return`Zu klein: erwartet, dass ${$.origin} ${T}${$.minimum.toString()} ${W.unit} hat`;return`Zu klein: erwartet, dass ${$.origin} ${T}${$.minimum.toString()} ist`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ung\xFCltiger String: muss mit "${T.prefix}" beginnen`;if(T.format==="ends_with")return`Ung\xFCltiger String: muss mit "${T.suffix}" enden`;if(T.format==="includes")return`Ung\xFCltiger String: muss "${T.includes}" enthalten`;if(T.format==="regex")return`Ung\xFCltiger String: muss dem Muster ${T.pattern} entsprechen`;return`Ung\xFCltig: ${PN[T.format]??$.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${$.divisor} sein`;case"unrecognized_keys":return`${$.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${R($.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${$.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${$.origin}`;default:return"Ung\xFCltige Eingabe"}};function LJ(){return{localeError:CN}}var jN={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function i3($){return jN[$]??null}var xN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},bN={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},fN=($)=>{switch($.code){case"invalid_type":return`Invalid input: expected ${$.expected}, received ${xN($.input)}`;case"invalid_value":if($.values.length===1)return`Invalid input: expected ${c($.values[0])}`;return`Invalid option: expected one of ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=i3($.origin);if(W)return`Too big: expected ${$.origin??"value"} to have ${T}${$.maximum.toString()} ${W.unit??"elements"}`;return`Too big: expected ${$.origin??"value"} to be ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=i3($.origin);if(W)return`Too small: expected ${$.origin} to have ${T}${$.minimum.toString()} ${W.unit}`;return`Too small: expected ${$.origin} to be ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Invalid string: must start with "${T.prefix}"`;if(T.format==="ends_with")return`Invalid string: must end with "${T.suffix}"`;if(T.format==="includes")return`Invalid string: must include "${T.includes}"`;if(T.format==="regex")return`Invalid string: must match pattern ${T.pattern}`;return`Invalid ${bN[T.format]??$.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${$.divisor}`;case"unrecognized_keys":return`Unrecognized key${$.keys.length>1?"s":""}: ${R($.keys,", ")}`;case"invalid_key":return`Invalid key in ${$.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${$.origin}`;default:return"Invalid input"}};function IW(){return{localeError:fN}}var yN={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function n3($){return yN[$]??null}var hN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"n\xFAmero";case"object":{if(Array.isArray($))return"arreglo";if($===null)return"nulo";if(Object.getPrototypeOf($)!==Object.prototype)return $.constructor.name}}return T},gN={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},mN=($)=>{switch($.code){case"invalid_type":return`Entrada inv\xE1lida: se esperaba ${$.expected}, recibido ${hN($.input)}`;case"invalid_value":if($.values.length===1)return`Entrada inv\xE1lida: se esperaba ${c($.values[0])}`;return`Opci\xF3n inv\xE1lida: se esperaba una de ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=n3($.origin);if(W)return`Demasiado grande: se esperaba que ${$.origin??"valor"} tuviera ${T}${$.maximum.toString()} ${W.unit??"elementos"}`;return`Demasiado grande: se esperaba que ${$.origin??"valor"} fuera ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=n3($.origin);if(W)return`Demasiado peque\xF1o: se esperaba que ${$.origin} tuviera ${T}${$.minimum.toString()} ${W.unit}`;return`Demasiado peque\xF1o: se esperaba que ${$.origin} fuera ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Cadena inv\xE1lida: debe comenzar con "${T.prefix}"`;if(T.format==="ends_with")return`Cadena inv\xE1lida: debe terminar en "${T.suffix}"`;if(T.format==="includes")return`Cadena inv\xE1lida: debe incluir "${T.includes}"`;if(T.format==="regex")return`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${T.pattern}`;return`Inv\xE1lido ${gN[T.format]??$.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${$.divisor}`;case"unrecognized_keys":return`Llave${$.keys.length>1?"s":""} desconocida${$.keys.length>1?"s":""}: ${R($.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${$.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${$.origin}`;default:return"Entrada inv\xE1lida"}};function SJ(){return{localeError:mN}}var cN={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t3($){return cN[$]??null}var uN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0639\u062F\u062F";case"object":{if(Array.isArray($))return"\u0622\u0631\u0627\u06CC\u0647";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},pN={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},oN=($)=>{switch($.code){case"invalid_type":return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${$.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${uN($.input)} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`;case"invalid_value":if($.values.length===1)return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${c($.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`;return`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${R($.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let T=$.inclusive?"<=":"<",W=t3($.origin);if(W)return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${$.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${T}${$.maximum.toString()} ${W.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${$.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${T}${$.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let T=$.inclusive?">=":">",W=t3($.origin);if(W)return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${$.origin} \u0628\u0627\u06CC\u062F ${T}${$.minimum.toString()} ${W.unit} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${$.origin} \u0628\u0627\u06CC\u062F ${T}${$.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${T.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`;if(T.format==="ends_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${T.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`;if(T.format==="includes")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${T.includes}" \u0628\u0627\u0634\u062F`;if(T.format==="regex")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${T.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`;return`${pN[T.format]??$.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${$.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${$.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${R($.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${$.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${$.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}};function BJ(){return{localeError:oN}}var dN={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function a3($){return dN[$]??null}var lN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},rN={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},iN=($)=>{switch($.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${$.expected}, oli ${lN($.input)}`;case"invalid_value":if($.values.length===1)return`Virheellinen sy\xF6te: t\xE4ytyy olla ${c($.values[0])}`;return`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=a3($.origin);if(W)return`Liian suuri: ${W.subject} t\xE4ytyy olla ${T}${$.maximum.toString()} ${W.unit}`.trim();return`Liian suuri: arvon t\xE4ytyy olla ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=a3($.origin);if(W)return`Liian pieni: ${W.subject} t\xE4ytyy olla ${T}${$.minimum.toString()} ${W.unit}`.trim();return`Liian pieni: arvon t\xE4ytyy olla ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${T.prefix}"`;if(T.format==="ends_with")return`Virheellinen sy\xF6te: t\xE4ytyy loppua "${T.suffix}"`;if(T.format==="includes")return`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${T.includes}"`;if(T.format==="regex")return`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${T.pattern}`;return`Virheellinen ${rN[T.format]??$.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${$.divisor} monikerta`;case"unrecognized_keys":return`${$.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${R($.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}};function RJ(){return{localeError:iN}}var nN={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function s3($){return nN[$]??null}var tN=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"nombre";case"object":{if(Array.isArray($))return"tableau";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},aN={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},sN=($)=>{switch($.code){case"invalid_type":return`Entr\xE9e invalide : ${$.expected} attendu, ${tN($.input)} re\xE7u`;case"invalid_value":if($.values.length===1)return`Entr\xE9e invalide : ${c($.values[0])} attendu`;return`Option invalide : une valeur parmi ${R($.values,"|")} attendue`;case"too_big":{let T=$.inclusive?"<=":"<",W=s3($.origin);if(W)return`Trop grand : ${$.origin??"valeur"} doit ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"\xE9l\xE9ment(s)"}`;return`Trop grand : ${$.origin??"valeur"} doit \xEAtre ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=s3($.origin);if(W)return`Trop petit : ${$.origin} doit ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`Trop petit : ${$.origin} doit \xEAtre ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${T.prefix}"`;if(T.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${T.suffix}"`;if(T.format==="includes")return`Cha\xEEne invalide : doit inclure "${T.includes}"`;if(T.format==="regex")return`Cha\xEEne invalide : doit correspondre au mod\xE8le ${T.pattern}`;return`${aN[T.format]??$.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${$.divisor}`;case"unrecognized_keys":return`Cl\xE9${$.keys.length>1?"s":""} non reconnue${$.keys.length>1?"s":""} : ${R($.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${$.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${$.origin}`;default:return"Entr\xE9e invalide"}};function IJ(){return{localeError:sN}}var eN={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function e3($){return eN[$]??null}var $L=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},TL={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},WL=($)=>{switch($.code){case"invalid_type":return`Entr\xE9e invalide : attendu ${$.expected}, re\xE7u ${$L($.input)}`;case"invalid_value":if($.values.length===1)return`Entr\xE9e invalide : attendu ${c($.values[0])}`;return`Option invalide : attendu l'une des valeurs suivantes ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"\u2264":"<",W=e3($.origin);if(W)return`Trop grand : attendu que ${$.origin??"la valeur"} ait ${T}${$.maximum.toString()} ${W.unit}`;return`Trop grand : attendu que ${$.origin??"la valeur"} soit ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?"\u2265":">",W=e3($.origin);if(W)return`Trop petit : attendu que ${$.origin} ait ${T}${$.minimum.toString()} ${W.unit}`;return`Trop petit : attendu que ${$.origin} soit ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${T.prefix}"`;if(T.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${T.suffix}"`;if(T.format==="includes")return`Cha\xEEne invalide : doit inclure "${T.includes}"`;if(T.format==="regex")return`Cha\xEEne invalide : doit correspondre au motif ${T.pattern}`;return`${TL[T.format]??$.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${$.divisor}`;case"unrecognized_keys":return`Cl\xE9${$.keys.length>1?"s":""} non reconnue${$.keys.length>1?"s":""} : ${R($.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${$.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${$.origin}`;default:return"Entr\xE9e invalide"}};function kJ(){return{localeError:WL}}var UL={string:{unit:"\u05D0\u05D5\u05EA\u05D9\u05D5\u05EA",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"}};function $H($){return UL[$]??null}var XL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},YL={regex:"\u05E7\u05DC\u05D8",email:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",url:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",emoji:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",date:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",time:"\u05D6\u05DE\u05DF ISO",duration:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",ipv4:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",ipv6:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",cidrv4:"\u05D8\u05D5\u05D5\u05D7 IPv4",cidrv6:"\u05D8\u05D5\u05D5\u05D7 IPv6",base64:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",base64url:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",json_string:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",e164:"\u05DE\u05E1\u05E4\u05E8 E.164",jwt:"JWT",template_literal:"\u05E7\u05DC\u05D8"},_L=($)=>{switch($.code){case"invalid_type":return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${$.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${XL($.input)}`;case"invalid_value":if($.values.length===1)return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${c($.values[0])}`;return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05D0\u05D7\u05EA \u05DE\u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=$H($.origin);if(W)return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${$.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.maximum.toString()} ${W.unit??"elements"}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${$.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=$H($.origin);if(W)return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${$.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.minimum.toString()} ${W.unit}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${$.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1"${T.prefix}"`;if(T.format==="ends_with")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${T.suffix}"`;if(T.format==="includes")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${T.includes}"`;if(T.format==="regex")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${T.pattern}`;return`${YL[T.format]??$.format} \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${$.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${$.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${$.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${R($.keys,", ")}`;case"invalid_key":return`\u05DE\u05E4\u05EA\u05D7 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${$.origin}`;case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${$.origin}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}};function vJ(){return{localeError:_L}}var wL={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function TH($){return wL[$]??null}var JL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"sz\xE1m";case"object":{if(Array.isArray($))return"t\xF6mb";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},GL={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},zL=($)=>{switch($.code){case"invalid_type":return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${$.expected}, a kapott \xE9rt\xE9k ${JL($.input)}`;case"invalid_value":if($.values.length===1)return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${c($.values[0])}`;return`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=TH($.origin);if(W)return`T\xFAl nagy: ${$.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${T}${$.maximum.toString()} ${W.unit??"elem"}`;return`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${$.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=TH($.origin);if(W)return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${$.origin} m\xE9rete t\xFAl kicsi ${T}${$.minimum.toString()} ${W.unit}`;return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${$.origin} t\xFAl kicsi ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\xC9rv\xE9nytelen string: "${T.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`;if(T.format==="ends_with")return`\xC9rv\xE9nytelen string: "${T.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`;if(T.format==="includes")return`\xC9rv\xE9nytelen string: "${T.includes}" \xE9rt\xE9ket kell tartalmaznia`;if(T.format==="regex")return`\xC9rv\xE9nytelen string: ${T.pattern} mint\xE1nak kell megfelelnie`;return`\xC9rv\xE9nytelen ${GL[T.format]??$.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${$.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${$.keys.length>1?"s":""}: ${R($.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${$.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${$.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}};function qJ(){return{localeError:zL}}var HL={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function WH($){return HL[$]??null}var FL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},OL={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},DL=($)=>{switch($.code){case"invalid_type":return`Input tidak valid: diharapkan ${$.expected}, diterima ${FL($.input)}`;case"invalid_value":if($.values.length===1)return`Input tidak valid: diharapkan ${c($.values[0])}`;return`Pilihan tidak valid: diharapkan salah satu dari ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=WH($.origin);if(W)return`Terlalu besar: diharapkan ${$.origin??"value"} memiliki ${T}${$.maximum.toString()} ${W.unit??"elemen"}`;return`Terlalu besar: diharapkan ${$.origin??"value"} menjadi ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=WH($.origin);if(W)return`Terlalu kecil: diharapkan ${$.origin} memiliki ${T}${$.minimum.toString()} ${W.unit}`;return`Terlalu kecil: diharapkan ${$.origin} menjadi ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`String tidak valid: harus dimulai dengan "${T.prefix}"`;if(T.format==="ends_with")return`String tidak valid: harus berakhir dengan "${T.suffix}"`;if(T.format==="includes")return`String tidak valid: harus menyertakan "${T.includes}"`;if(T.format==="regex")return`String tidak valid: harus sesuai pola ${T.pattern}`;return`${OL[T.format]??$.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${$.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${$.keys.length>1?"s":""}: ${R($.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${$.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${$.origin}`;default:return"Input tidak valid"}};function PJ(){return{localeError:DL}}var QL={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function UH($){return QL[$]??null}var ZL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"numero";case"object":{if(Array.isArray($))return"vettore";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},VL={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},KL=($)=>{switch($.code){case"invalid_type":return`Input non valido: atteso ${$.expected}, ricevuto ${ZL($.input)}`;case"invalid_value":if($.values.length===1)return`Input non valido: atteso ${c($.values[0])}`;return`Opzione non valida: atteso uno tra ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=UH($.origin);if(W)return`Troppo grande: ${$.origin??"valore"} deve avere ${T}${$.maximum.toString()} ${W.unit??"elementi"}`;return`Troppo grande: ${$.origin??"valore"} deve essere ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=UH($.origin);if(W)return`Troppo piccolo: ${$.origin} deve avere ${T}${$.minimum.toString()} ${W.unit}`;return`Troppo piccolo: ${$.origin} deve essere ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Stringa non valida: deve iniziare con "${T.prefix}"`;if(T.format==="ends_with")return`Stringa non valida: deve terminare con "${T.suffix}"`;if(T.format==="includes")return`Stringa non valida: deve includere "${T.includes}"`;if(T.format==="regex")return`Stringa non valida: deve corrispondere al pattern ${T.pattern}`;return`Invalid ${VL[T.format]??$.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${$.divisor}`;case"unrecognized_keys":return`Chiav${$.keys.length>1?"i":"e"} non riconosciut${$.keys.length>1?"e":"a"}: ${R($.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${$.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${$.origin}`;default:return"Input non valido"}};function CJ(){return{localeError:KL}}var EL={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function XH($){return EL[$]??null}var AL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u6570\u5024";case"object":{if(Array.isArray($))return"\u914D\u5217";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},ML={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},NL=($)=>{switch($.code){case"invalid_type":return`\u7121\u52B9\u306A\u5165\u529B: ${$.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${AL($.input)}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`;case"invalid_value":if($.values.length===1)return`\u7121\u52B9\u306A\u5165\u529B: ${c($.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`;return`\u7121\u52B9\u306A\u9078\u629E: ${R($.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let T=$.inclusive?"<=":"<",W=XH($.origin);if(W)return`\u5927\u304D\u3059\u304E\u308B\u5024: ${$.origin??"\u5024"}\u306F${$.maximum.toString()}${W.unit??"\u8981\u7D20"}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5927\u304D\u3059\u304E\u308B\u5024: ${$.origin??"\u5024"}\u306F${$.maximum.toString()}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let T=$.inclusive?">=":">",W=XH($.origin);if(W)return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${$.origin}\u306F${$.minimum.toString()}${W.unit}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${$.origin}\u306F${$.minimum.toString()}${T}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${T.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(T.format==="ends_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${T.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(T.format==="includes")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${T.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(T.format==="regex")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${T.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u7121\u52B9\u306A${ML[T.format]??$.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${$.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${$.keys.length>1?"\u7FA4":""}: ${R($.keys,"\u3001")}`;case"invalid_key":return`${$.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${$.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}};function jJ(){return{localeError:NL}}var LL={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function YH($){return LL[$]??null}var SL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u1798\u17B7\u1793\u1798\u17C2\u1793\u1787\u17B6\u179B\u17C1\u1781 (NaN)":"\u179B\u17C1\u1781";case"object":{if(Array.isArray($))return"\u17A2\u17B6\u179A\u17C1 (Array)";if($===null)return"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},BL={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},RL=($)=>{switch($.code){case"invalid_type":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${$.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${SL($.input)}`;case"invalid_value":if($.values.length===1)return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${c($.values[0])}`;return`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=YH($.origin);if(W)return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${$.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${T} ${$.maximum.toString()} ${W.unit??"\u1792\u17B6\u178F\u17BB"}`;return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${$.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=YH($.origin);if(W)return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${$.origin} ${T} ${$.minimum.toString()} ${W.unit}`;return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${$.origin} ${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${T.prefix}"`;if(T.format==="ends_with")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${T.suffix}"`;if(T.format==="includes")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${T.includes}"`;if(T.format==="regex")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${T.pattern}`;return`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${BL[T.format]??$.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${$.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${R($.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${$.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${$.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}};function xJ(){return{localeError:RL}}var IL={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function _H($){return IL[$]??null}var kL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},vL={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},qL=($)=>{switch($.code){case"invalid_type":return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${$.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${kL($.input)}\uC785\uB2C8\uB2E4`;case"invalid_value":if($.values.length===1)return`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${c($.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C \uC635\uC158: ${R($.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let T=$.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",W=T==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",U=_H($.origin),X=U?.unit??"\uC694\uC18C";if(U)return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${$.maximum.toString()}${X} ${T}${W}`;return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${$.maximum.toString()} ${T}${W}`}case"too_small":{let T=$.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",W=T==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",U=_H($.origin),X=U?.unit??"\uC694\uC18C";if(U)return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${$.minimum.toString()}${X} ${T}${W}`;return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${$.minimum.toString()} ${T}${W}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${T.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`;if(T.format==="ends_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${T.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`;if(T.format==="includes")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${T.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`;if(T.format==="regex")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${T.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C ${vL[T.format]??$.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${$.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${R($.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${$.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${$.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}};function bJ(){return{localeError:qL}}var PL={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function wH($){return PL[$]??null}var CL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0431\u0440\u043E\u0458";case"object":{if(Array.isArray($))return"\u043D\u0438\u0437\u0430";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},jL={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},xL=($)=>{switch($.code){case"invalid_type":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${CL($.input)}`;case"invalid_value":if($.values.length===1)return`Invalid input: expected ${c($.values[0])}`;return`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=wH($.origin);if(W)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${T}${$.maximum.toString()} ${W.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=wH($.origin);if(W)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin} \u0434\u0430 \u0438\u043C\u0430 ${T}${$.minimum.toString()} ${W.unit}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${$.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${T.prefix}"`;if(T.format==="ends_with")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${T.suffix}"`;if(T.format==="includes")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${T.includes}"`;if(T.format==="regex")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${T.pattern}`;return`Invalid ${jL[T.format]??$.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${$.divisor}`;case"unrecognized_keys":return`${$.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${R($.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${$.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${$.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}};function fJ(){return{localeError:xL}}var bL={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function JH($){return bL[$]??null}var fL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"nombor";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},yL={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},hL=($)=>{switch($.code){case"invalid_type":return`Input tidak sah: dijangka ${$.expected}, diterima ${fL($.input)}`;case"invalid_value":if($.values.length===1)return`Input tidak sah: dijangka ${c($.values[0])}`;return`Pilihan tidak sah: dijangka salah satu daripada ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=JH($.origin);if(W)return`Terlalu besar: dijangka ${$.origin??"nilai"} ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"elemen"}`;return`Terlalu besar: dijangka ${$.origin??"nilai"} adalah ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=JH($.origin);if(W)return`Terlalu kecil: dijangka ${$.origin} ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`Terlalu kecil: dijangka ${$.origin} adalah ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`String tidak sah: mesti bermula dengan "${T.prefix}"`;if(T.format==="ends_with")return`String tidak sah: mesti berakhir dengan "${T.suffix}"`;if(T.format==="includes")return`String tidak sah: mesti mengandungi "${T.includes}"`;if(T.format==="regex")return`String tidak sah: mesti sepadan dengan corak ${T.pattern}`;return`${yL[T.format]??$.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${$.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${R($.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${$.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${$.origin}`;default:return"Input tidak sah"}};function yJ(){return{localeError:hL}}var gL={string:{unit:"tekens"},file:{unit:"bytes"},array:{unit:"elementen"},set:{unit:"elementen"}};function GH($){return gL[$]??null}var mL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"getal";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},cL={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},uL=($)=>{switch($.code){case"invalid_type":return`Ongeldige invoer: verwacht ${$.expected}, ontving ${mL($.input)}`;case"invalid_value":if($.values.length===1)return`Ongeldige invoer: verwacht ${c($.values[0])}`;return`Ongeldige optie: verwacht \xE9\xE9n van ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=GH($.origin);if(W)return`Te lang: verwacht dat ${$.origin??"waarde"} ${T}${$.maximum.toString()} ${W.unit??"elementen"} bevat`;return`Te lang: verwacht dat ${$.origin??"waarde"} ${T}${$.maximum.toString()} is`}case"too_small":{let T=$.inclusive?">=":">",W=GH($.origin);if(W)return`Te kort: verwacht dat ${$.origin} ${T}${$.minimum.toString()} ${W.unit} bevat`;return`Te kort: verwacht dat ${$.origin} ${T}${$.minimum.toString()} is`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ongeldige tekst: moet met "${T.prefix}" beginnen`;if(T.format==="ends_with")return`Ongeldige tekst: moet op "${T.suffix}" eindigen`;if(T.format==="includes")return`Ongeldige tekst: moet "${T.includes}" bevatten`;if(T.format==="regex")return`Ongeldige tekst: moet overeenkomen met patroon ${T.pattern}`;return`Ongeldig: ${cL[T.format]??$.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${$.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${$.keys.length>1?"s":""}: ${R($.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${$.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${$.origin}`;default:return"Ongeldige invoer"}};function hJ(){return{localeError:uL}}var pL={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function zH($){return pL[$]??null}var oL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"tall";case"object":{if(Array.isArray($))return"liste";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},dL={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},lL=($)=>{switch($.code){case"invalid_type":return`Ugyldig input: forventet ${$.expected}, fikk ${oL($.input)}`;case"invalid_value":if($.values.length===1)return`Ugyldig verdi: forventet ${c($.values[0])}`;return`Ugyldig valg: forventet en av ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=zH($.origin);if(W)return`For stor(t): forventet ${$.origin??"value"} til \xE5 ha ${T}${$.maximum.toString()} ${W.unit??"elementer"}`;return`For stor(t): forventet ${$.origin??"value"} til \xE5 ha ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=zH($.origin);if(W)return`For lite(n): forventet ${$.origin} til \xE5 ha ${T}${$.minimum.toString()} ${W.unit}`;return`For lite(n): forventet ${$.origin} til \xE5 ha ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ugyldig streng: m\xE5 starte med "${T.prefix}"`;if(T.format==="ends_with")return`Ugyldig streng: m\xE5 ende med "${T.suffix}"`;if(T.format==="includes")return`Ugyldig streng: m\xE5 inneholde "${T.includes}"`;if(T.format==="regex")return`Ugyldig streng: m\xE5 matche m\xF8nsteret ${T.pattern}`;return`Ugyldig ${dL[T.format]??$.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${$.divisor}`;case"unrecognized_keys":return`${$.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${R($.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${$.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${$.origin}`;default:return"Ugyldig input"}};function gJ(){return{localeError:lL}}var rL={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function HH($){return rL[$]??null}var iL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"numara";case"object":{if(Array.isArray($))return"saf";if($===null)return"gayb";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},nL={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},tL=($)=>{switch($.code){case"invalid_type":return`F\xE2sit giren: umulan ${$.expected}, al\u0131nan ${iL($.input)}`;case"invalid_value":if($.values.length===1)return`F\xE2sit giren: umulan ${c($.values[0])}`;return`F\xE2sit tercih: m\xFBteberler ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=HH($.origin);if(W)return`Fazla b\xFCy\xFCk: ${$.origin??"value"}, ${T}${$.maximum.toString()} ${W.unit??"elements"} sahip olmal\u0131yd\u0131.`;return`Fazla b\xFCy\xFCk: ${$.origin??"value"}, ${T}${$.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let T=$.inclusive?">=":">",W=HH($.origin);if(W)return`Fazla k\xFC\xE7\xFCk: ${$.origin}, ${T}${$.minimum.toString()} ${W.unit} sahip olmal\u0131yd\u0131.`;return`Fazla k\xFC\xE7\xFCk: ${$.origin}, ${T}${$.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`F\xE2sit metin: "${T.prefix}" ile ba\u015Flamal\u0131.`;if(T.format==="ends_with")return`F\xE2sit metin: "${T.suffix}" ile bitmeli.`;if(T.format==="includes")return`F\xE2sit metin: "${T.includes}" ihtiv\xE2 etmeli.`;if(T.format==="regex")return`F\xE2sit metin: ${T.pattern} nak\u015F\u0131na uymal\u0131.`;return`F\xE2sit ${nL[T.format]??$.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${$.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${$.keys.length>1?"s":""}: ${R($.keys,", ")}`;case"invalid_key":return`${$.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${$.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}};function mJ(){return{localeError:tL}}var aL={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function FH($){return aL[$]??null}var sL=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"liczba";case"object":{if(Array.isArray($))return"tablica";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},eL={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},$S=($)=>{switch($.code){case"invalid_type":return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${$.expected}, otrzymano ${sL($.input)}`;case"invalid_value":if($.values.length===1)return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${c($.values[0])}`;return`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=FH($.origin);if(W)return`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${T}${$.maximum.toString()} ${W.unit??"element\xF3w"}`;return`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=FH($.origin);if(W)return`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${T}${$.minimum.toString()} ${W.unit??"element\xF3w"}`;return`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${$.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${T.prefix}"`;if(T.format==="ends_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${T.suffix}"`;if(T.format==="includes")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${T.includes}"`;if(T.format==="regex")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${T.pattern}`;return`Nieprawid\u0142ow(y/a/e) ${eL[T.format]??$.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${$.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${$.keys.length>1?"s":""}: ${R($.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${$.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${$.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}};function cJ(){return{localeError:$S}}var TS={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function OH($){return TS[$]??null}var WS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"n\xFAmero";case"object":{if(Array.isArray($))return"array";if($===null)return"nulo";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},US={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},XS=($)=>{switch($.code){case"invalid_type":return`Tipo inv\xE1lido: esperado ${$.expected}, recebido ${WS($.input)}`;case"invalid_value":if($.values.length===1)return`Entrada inv\xE1lida: esperado ${c($.values[0])}`;return`Op\xE7\xE3o inv\xE1lida: esperada uma das ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=OH($.origin);if(W)return`Muito grande: esperado que ${$.origin??"valor"} tivesse ${T}${$.maximum.toString()} ${W.unit??"elementos"}`;return`Muito grande: esperado que ${$.origin??"valor"} fosse ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=OH($.origin);if(W)return`Muito pequeno: esperado que ${$.origin} tivesse ${T}${$.minimum.toString()} ${W.unit}`;return`Muito pequeno: esperado que ${$.origin} fosse ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Texto inv\xE1lido: deve come\xE7ar com "${T.prefix}"`;if(T.format==="ends_with")return`Texto inv\xE1lido: deve terminar com "${T.suffix}"`;if(T.format==="includes")return`Texto inv\xE1lido: deve incluir "${T.includes}"`;if(T.format==="regex")return`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${T.pattern}`;return`${US[T.format]??$.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${$.divisor}`;case"unrecognized_keys":return`Chave${$.keys.length>1?"s":""} desconhecida${$.keys.length>1?"s":""}: ${R($.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${$.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${$.origin}`;default:return"Campo inv\xE1lido"}};function uJ(){return{localeError:XS}}function DH($,T,W,U){let X=Math.abs($),Y=X%10,_=X%100;if(_>=11&&_<=19)return U;if(Y===1)return T;if(Y>=2&&Y<=4)return W;return U}var YS={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function QH($){return YS[$]??null}var _S=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray($))return"\u043C\u0430\u0441\u0441\u0438\u0432";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},wS={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},JS=($)=>{switch($.code){case"invalid_type":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${$.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${_S($.input)}`;case"invalid_value":if($.values.length===1)return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${c($.values[0])}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=QH($.origin);if(W){let U=Number($.maximum),X=DH(U,W.unit.one,W.unit.few,W.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${T}${$.maximum.toString()} ${X}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=QH($.origin);if(W){let U=Number($.minimum),X=DH(U,W.unit.one,W.unit.few,W.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${$.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${T}${$.minimum.toString()} ${X}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${$.origin} \u0431\u0443\u0434\u0435\u0442 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${T.prefix}"`;if(T.format==="ends_with")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${T.suffix}"`;if(T.format==="includes")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${T.includes}"`;if(T.format==="regex")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${T.pattern}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${wS[T.format]??$.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${$.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${$.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${$.keys.length>1?"\u0438":""}: ${R($.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${$.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${$.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}};function pJ(){return{localeError:JS}}var GS={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function ZH($){return GS[$]??null}var zS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0161tevilo";case"object":{if(Array.isArray($))return"tabela";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},HS={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},FS=($)=>{switch($.code){case"invalid_type":return`Neveljaven vnos: pri\u010Dakovano ${$.expected}, prejeto ${zS($.input)}`;case"invalid_value":if($.values.length===1)return`Neveljaven vnos: pri\u010Dakovano ${c($.values[0])}`;return`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=ZH($.origin);if(W)return`Preveliko: pri\u010Dakovano, da bo ${$.origin??"vrednost"} imelo ${T}${$.maximum.toString()} ${W.unit??"elementov"}`;return`Preveliko: pri\u010Dakovano, da bo ${$.origin??"vrednost"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=ZH($.origin);if(W)return`Premajhno: pri\u010Dakovano, da bo ${$.origin} imelo ${T}${$.minimum.toString()} ${W.unit}`;return`Premajhno: pri\u010Dakovano, da bo ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Neveljaven niz: mora se za\u010Deti z "${T.prefix}"`;if(T.format==="ends_with")return`Neveljaven niz: mora se kon\u010Dati z "${T.suffix}"`;if(T.format==="includes")return`Neveljaven niz: mora vsebovati "${T.includes}"`;if(T.format==="regex")return`Neveljaven niz: mora ustrezati vzorcu ${T.pattern}`;return`Neveljaven ${HS[T.format]??$.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${$.divisor}`;case"unrecognized_keys":return`Neprepoznan${$.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${R($.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${$.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${$.origin}`;default:return"Neveljaven vnos"}};function oJ(){return{localeError:FS}}var OS={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function VH($){return OS[$]??null}var DS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"antal";case"object":{if(Array.isArray($))return"lista";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},QS={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},ZS=($)=>{switch($.code){case"invalid_type":return`Ogiltig inmatning: f\xF6rv\xE4ntat ${$.expected}, fick ${DS($.input)}`;case"invalid_value":if($.values.length===1)return`Ogiltig inmatning: f\xF6rv\xE4ntat ${c($.values[0])}`;return`Ogiltigt val: f\xF6rv\xE4ntade en av ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=VH($.origin);if(W)return`F\xF6r stor(t): f\xF6rv\xE4ntade ${$.origin??"v\xE4rdet"} att ha ${T}${$.maximum.toString()} ${W.unit??"element"}`;return`F\xF6r stor(t): f\xF6rv\xE4ntat ${$.origin??"v\xE4rdet"} att ha ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=VH($.origin);if(W)return`F\xF6r lite(t): f\xF6rv\xE4ntade ${$.origin??"v\xE4rdet"} att ha ${T}${$.minimum.toString()} ${W.unit}`;return`F\xF6r lite(t): f\xF6rv\xE4ntade ${$.origin??"v\xE4rdet"} att ha ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${T.prefix}"`;if(T.format==="ends_with")return`Ogiltig str\xE4ng: m\xE5ste sluta med "${T.suffix}"`;if(T.format==="includes")return`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${T.includes}"`;if(T.format==="regex")return`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${T.pattern}"`;return`Ogiltig(t) ${QS[T.format]??$.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${$.divisor}`;case"unrecognized_keys":return`${$.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${R($.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${$.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${$.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}};function dJ(){return{localeError:ZS}}var VS={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function KH($){return VS[$]??null}var KS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u0B8E\u0BA3\u0BCD \u0B85\u0BB2\u0BCD\u0BB2\u0BBE\u0BA4\u0BA4\u0BC1":"\u0B8E\u0BA3\u0BCD";case"object":{if(Array.isArray($))return"\u0B85\u0BA3\u0BBF";if($===null)return"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},ES={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},AS=($)=>{switch($.code){case"invalid_type":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${$.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${KS($.input)}`;case"invalid_value":if($.values.length===1)return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${c($.values[0])}`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${R($.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let T=$.inclusive?"<=":"<",W=KH($.origin);if(W)return`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${$.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${T}${$.maximum.toString()} ${W.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${$.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${T}${$.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let T=$.inclusive?">=":">",W=KH($.origin);if(W)return`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${$.origin} ${T}${$.minimum.toString()} ${W.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${$.origin} ${T}${$.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${T.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(T.format==="ends_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${T.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(T.format==="includes")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${T.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(T.format==="regex")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${T.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${ES[T.format]??$.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${$.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${$.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${R($.keys,", ")}`;case"invalid_key":return`${$.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${$.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}};function lJ(){return{localeError:AS}}var MS={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function EH($){return MS[$]??null}var NS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u0E44\u0E21\u0E48\u0E43\u0E0A\u0E48\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02 (NaN)":"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02";case"object":{if(Array.isArray($))return"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)";if($===null)return"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},LS={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},SS=($)=>{switch($.code){case"invalid_type":return`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${$.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${NS($.input)}`;case"invalid_value":if($.values.length===1)return`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${c($.values[0])}`;return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",W=EH($.origin);if(W)return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.maximum.toString()} ${W.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`;return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",W=EH($.origin);if(W)return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.minimum.toString()} ${W.unit}`;return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${$.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${T} ${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${T.prefix}"`;if(T.format==="ends_with")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${T.suffix}"`;if(T.format==="includes")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${T.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`;if(T.format==="regex")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${T.pattern}`;return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${LS[T.format]??$.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${$.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${R($.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${$.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${$.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}};function rJ(){return{localeError:SS}}var BS={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function AH($){return BS[$]??null}var RS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},IS={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},kS=($)=>{switch($.code){case"invalid_type":return`Ge\xE7ersiz de\u011Fer: beklenen ${$.expected}, al\u0131nan ${RS($.input)}`;case"invalid_value":if($.values.length===1)return`Ge\xE7ersiz de\u011Fer: beklenen ${c($.values[0])}`;return`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=AH($.origin);if(W)return`\xC7ok b\xFCy\xFCk: beklenen ${$.origin??"de\u011Fer"} ${T}${$.maximum.toString()} ${W.unit??"\xF6\u011Fe"}`;return`\xC7ok b\xFCy\xFCk: beklenen ${$.origin??"de\u011Fer"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=AH($.origin);if(W)return`\xC7ok k\xFC\xE7\xFCk: beklenen ${$.origin} ${T}${$.minimum.toString()} ${W.unit}`;return`\xC7ok k\xFC\xE7\xFCk: beklenen ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Ge\xE7ersiz metin: "${T.prefix}" ile ba\u015Flamal\u0131`;if(T.format==="ends_with")return`Ge\xE7ersiz metin: "${T.suffix}" ile bitmeli`;if(T.format==="includes")return`Ge\xE7ersiz metin: "${T.includes}" i\xE7ermeli`;if(T.format==="regex")return`Ge\xE7ersiz metin: ${T.pattern} desenine uymal\u0131`;return`Ge\xE7ersiz ${IS[T.format]??$.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${$.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${$.keys.length>1?"lar":""}: ${R($.keys,", ")}`;case"invalid_key":return`${$.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${$.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}};function iJ(){return{localeError:kS}}var vS={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function MH($){return vS[$]??null}var qS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray($))return"\u043C\u0430\u0441\u0438\u0432";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},PS={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},CS=($)=>{switch($.code){case"invalid_type":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${$.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${qS($.input)}`;case"invalid_value":if($.values.length===1)return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${c($.values[0])}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=MH($.origin);if(W)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`;return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${$.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=MH($.origin);if(W)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${$.origin} ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${$.origin} \u0431\u0443\u0434\u0435 ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${T.prefix}"`;if(T.format==="ends_with")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${T.suffix}"`;if(T.format==="includes")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${T.includes}"`;if(T.format==="regex")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${T.pattern}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${PS[T.format]??$.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${$.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${$.keys.length>1?"\u0456":""}: ${R($.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${$.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${$.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}};function nJ(){return{localeError:CS}}var jS={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function NH($){return jS[$]??null}var xS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"\u0646\u0645\u0628\u0631";case"object":{if(Array.isArray($))return"\u0622\u0631\u06D2";if($===null)return"\u0646\u0644";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},bS={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},fS=($)=>{switch($.code){case"invalid_type":return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${$.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${xS($.input)} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`;case"invalid_value":if($.values.length===1)return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${c($.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;return`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${R($.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let T=$.inclusive?"<=":"<",W=NH($.origin);if(W)return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${$.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${T}${$.maximum.toString()} ${W.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${$.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${T}${$.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let T=$.inclusive?">=":">",W=NH($.origin);if(W)return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${$.origin} \u06A9\u06D2 ${T}${$.minimum.toString()} ${W.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${$.origin} \u06A9\u0627 ${T}${$.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${T.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(T.format==="ends_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${T.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(T.format==="includes")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${T.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(T.format==="regex")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${T.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;return`\u063A\u0644\u0637 ${bS[T.format]??$.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${$.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${$.keys.length>1?"\u0632":""}: ${R($.keys,"\u060C ")}`;case"invalid_key":return`${$.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${$.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}};function tJ(){return{localeError:fS}}var yS={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function LH($){return yS[$]??null}var hS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"s\u1ED1";case"object":{if(Array.isArray($))return"m\u1EA3ng";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},gS={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},mS=($)=>{switch($.code){case"invalid_type":return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${$.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${hS($.input)}`;case"invalid_value":if($.values.length===1)return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${c($.values[0])}`;return`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=LH($.origin);if(W)return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${$.origin??"gi\xE1 tr\u1ECB"} ${W.verb} ${T}${$.maximum.toString()} ${W.unit??"ph\u1EA7n t\u1EED"}`;return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${$.origin??"gi\xE1 tr\u1ECB"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=LH($.origin);if(W)return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${$.origin} ${W.verb} ${T}${$.minimum.toString()} ${W.unit}`;return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${T.prefix}"`;if(T.format==="ends_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${T.suffix}"`;if(T.format==="includes")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${T.includes}"`;if(T.format==="regex")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${T.pattern}`;return`${gS[T.format]??$.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${$.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${R($.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${$.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${$.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}};function aJ(){return{localeError:mS}}var cS={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function SH($){return cS[$]??null}var uS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"\u975E\u6570\u5B57(NaN)":"\u6570\u5B57";case"object":{if(Array.isArray($))return"\u6570\u7EC4";if($===null)return"\u7A7A\u503C(null)";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},pS={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},oS=($)=>{switch($.code){case"invalid_type":return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${$.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${uS($.input)}`;case"invalid_value":if($.values.length===1)return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${c($.values[0])}`;return`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=SH($.origin);if(W)return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${$.origin??"\u503C"} ${T}${$.maximum.toString()} ${W.unit??"\u4E2A\u5143\u7D20"}`;return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${$.origin??"\u503C"} ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=SH($.origin);if(W)return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${$.origin} ${T}${$.minimum.toString()} ${W.unit}`;return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${$.origin} ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${T.prefix}" \u5F00\u5934`;if(T.format==="ends_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${T.suffix}" \u7ED3\u5C3E`;if(T.format==="includes")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${T.includes}"`;if(T.format==="regex")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${T.pattern}`;return`\u65E0\u6548${pS[T.format]??$.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${$.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${R($.keys,", ")}`;case"invalid_key":return`${$.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${$.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}};function sJ(){return{localeError:oS}}var dS={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function BH($){return dS[$]??null}var lS=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},rS={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},iS=($)=>{switch($.code){case"invalid_type":return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${$.expected}\uFF0C\u4F46\u6536\u5230 ${lS($.input)}`;case"invalid_value":if($.values.length===1)return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${c($.values[0])}`;return`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${R($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=BH($.origin);if(W)return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${$.origin??"\u503C"} \u61C9\u70BA ${T}${$.maximum.toString()} ${W.unit??"\u500B\u5143\u7D20"}`;return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${$.origin??"\u503C"} \u61C9\u70BA ${T}${$.maximum.toString()}`}case"too_small":{let T=$.inclusive?">=":">",W=BH($.origin);if(W)return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${$.origin} \u61C9\u70BA ${T}${$.minimum.toString()} ${W.unit}`;return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${$.origin} \u61C9\u70BA ${T}${$.minimum.toString()}`}case"invalid_format":{let T=$;if(T.format==="starts_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${T.prefix}" \u958B\u982D`;if(T.format==="ends_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${T.suffix}" \u7D50\u5C3E`;if(T.format==="includes")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${T.includes}"`;if(T.format==="regex")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${T.pattern}`;return`\u7121\u6548\u7684 ${rS[T.format]??$.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${$.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${$.keys.length>1?"\u5011":""}\uFF1A${R($.keys,"\u3001")}`;case"invalid_key":return`${$.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${$.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}};function eJ(){return{localeError:iS}}var $G=Symbol("ZodOutput"),TG=Symbol("ZodInput");class vW{constructor(){this._map=new WeakMap,this._idmap=new Map}add($,...T){let W=T[0];if(this._map.set($,W),W&&typeof W==="object"&&"id"in W){if(this._idmap.has(W.id))throw new Error(`ID ${W.id} already exists in the registry`);this._idmap.set(W.id,$)}return this}remove($){return this._map.delete($),this}get($){let T=$._zod.parent;if(T){let W={...this.get(T)??{}};return delete W.id,{...W,...this._map.get($)}}return this._map.get($)}has($){return this._map.has($)}}function zX(){return new vW}var C6=zX();function WG($,T){return new $({type:"string",...j(T)})}function UG($,T){return new $({type:"string",coerce:!0,...j(T)})}function HX($,T){return new $({type:"string",format:"email",check:"string_format",abort:!1,...j(T)})}function qW($,T){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...j(T)})}function FX($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...j(T)})}function OX($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(T)})}function DX($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(T)})}function QX($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(T)})}function ZX($,T){return new $({type:"string",format:"url",check:"string_format",abort:!1,...j(T)})}function VX($,T){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...j(T)})}function KX($,T){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(T)})}function EX($,T){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...j(T)})}function AX($,T){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(T)})}function MX($,T){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...j(T)})}function NX($,T){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...j(T)})}function LX($,T){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(T)})}function SX($,T){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(T)})}function BX($,T){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(T)})}function RX($,T){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(T)})}function IX($,T){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(T)})}function kX($,T){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...j(T)})}function vX($,T){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...j(T)})}function qX($,T){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...j(T)})}function PX($,T){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...j(T)})}function XG($,T){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(T)})}function YG($,T){return new $({type:"string",format:"date",check:"string_format",...j(T)})}function _G($,T){return new $({type:"string",format:"time",check:"string_format",precision:null,...j(T)})}function wG($,T){return new $({type:"string",format:"duration",check:"string_format",...j(T)})}function JG($,T){return new $({type:"number",checks:[],...j(T)})}function GG($,T){return new $({type:"number",coerce:!0,checks:[],...j(T)})}function zG($,T){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...j(T)})}function HG($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...j(T)})}function FG($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...j(T)})}function OG($,T){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...j(T)})}function DG($,T){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...j(T)})}function QG($,T){return new $({type:"boolean",...j(T)})}function ZG($,T){return new $({type:"boolean",coerce:!0,...j(T)})}function VG($,T){return new $({type:"bigint",...j(T)})}function KG($,T){return new $({type:"bigint",coerce:!0,...j(T)})}function EG($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...j(T)})}function AG($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...j(T)})}function MG($,T){return new $({type:"symbol",...j(T)})}function NG($,T){return new $({type:"undefined",...j(T)})}function LG($,T){return new $({type:"null",...j(T)})}function SG($){return new $({type:"any"})}function BG($){return new $({type:"unknown"})}function RG($,T){return new $({type:"never",...j(T)})}function IG($,T){return new $({type:"void",...j(T)})}function kG($,T){return new $({type:"date",...j(T)})}function vG($,T){return new $({type:"date",coerce:!0,...j(T)})}function qG($,T){return new $({type:"nan",...j(T)})}function o6($,T){return new WX({check:"less_than",...j(T),value:$,inclusive:!1})}function Y6($,T){return new WX({check:"less_than",...j(T),value:$,inclusive:!0})}function d6($,T){return new UX({check:"greater_than",...j(T),value:$,inclusive:!1})}function b4($,T){return new UX({check:"greater_than",...j(T),value:$,inclusive:!0})}function PG($){return d6(0,$)}function CG($){return o6(0,$)}function jG($){return Y6(0,$)}function xG($){return b4(0,$)}function W0($,T){return new n_({check:"multiple_of",...j(T),value:$})}function t0($,T){return new s_({check:"max_size",...j(T),maximum:$})}function U0($,T){return new e_({check:"min_size",...j(T),minimum:$})}function PW($,T){return new $w({check:"size_equals",...j(T),size:$})}function a0($,T){return new Tw({check:"max_length",...j(T),maximum:$})}function v1($,T){return new Ww({check:"min_length",...j(T),minimum:$})}function s0($,T){return new Uw({check:"length_equals",...j(T),length:$})}function CW($,T){return new Xw({check:"string_format",format:"regex",...j(T),pattern:$})}function jW($){return new Yw({check:"string_format",format:"lowercase",...j($)})}function xW($){return new _w({check:"string_format",format:"uppercase",...j($)})}function bW($,T){return new ww({check:"string_format",format:"includes",...j(T),includes:$})}function fW($,T){return new Jw({check:"string_format",format:"starts_with",...j(T),prefix:$})}function yW($,T){return new Gw({check:"string_format",format:"ends_with",...j(T),suffix:$})}function bG($,T,W){return new zw({check:"property",property:$,schema:T,...j(W)})}function hW($,T){return new Hw({check:"mime_type",mime:$,...j(T)})}function l6($){return new Fw({check:"overwrite",tx:$})}function gW($){return l6((T)=>T.normalize($))}function mW(){return l6(($)=>$.trim())}function cW(){return l6(($)=>$.toLowerCase())}function uW(){return l6(($)=>$.toUpperCase())}function fG($,T,W){return new $({type:"array",element:T,...j(W)})}function nS($,T,W){return new $({type:"union",options:T,...j(W)})}function tS($,T,W,U){return new $({type:"union",options:W,discriminator:T,...j(U)})}function aS($,T,W){return new $({type:"intersection",left:T,right:W})}function yG($,T,W,U){let X=W instanceof T$;return new $({type:"tuple",items:T,rest:X?W:null,...j(X?U:W)})}function sS($,T,W,U){return new $({type:"record",keyType:T,valueType:W,...j(U)})}function eS($,T,W,U){return new $({type:"map",keyType:T,valueType:W,...j(U)})}function $B($,T,W){return new $({type:"set",valueType:T,...j(W)})}function TB($,T,W){let U=Array.isArray(T)?Object.fromEntries(T.map((X)=>[X,X])):T;return new $({type:"enum",entries:U,...j(W)})}function WB($,T,W){return new $({type:"enum",entries:T,...j(W)})}function UB($,T,W){return new $({type:"literal",values:Array.isArray(T)?T:[T],...j(W)})}function hG($,T){return new $({type:"file",...j(T)})}function XB($,T){return new $({type:"transform",transform:T})}function YB($,T){return new $({type:"optional",innerType:T})}function _B($,T){return new $({type:"nullable",innerType:T})}function wB($,T,W){return new $({type:"default",innerType:T,get defaultValue(){return typeof W==="function"?W():W}})}function JB($,T,W){return new $({type:"nonoptional",innerType:T,...j(W)})}function GB($,T){return new $({type:"success",innerType:T})}function zB($,T,W){return new $({type:"catch",innerType:T,catchValue:typeof W==="function"?W:()=>W})}function HB($,T,W){return new $({type:"pipe",in:T,out:W})}function FB($,T){return new $({type:"readonly",innerType:T})}function OB($,T,W){return new $({type:"template_literal",parts:T,...j(W)})}function DB($,T){return new $({type:"lazy",getter:T})}function QB($,T){return new $({type:"promise",innerType:T})}function pW($,T,W){return new $({type:"custom",check:"custom",fn:T,...j(W)})}function ZB($,T,W={}){return pW($,T,W)}function gG($,T){let{case:W,error:U,truthy:X,falsy:Y}=j(T),_=new Set(X??["true","1","yes","on","y","enabled"]),w=new Set(Y??["false","0","no","off","n","disabled"]),G=$.Pipe??RW,J=$.Boolean??SW,z=new($.Unknown??BW)({type:"unknown",checks:[{_zod:{check:(F)=>{if(typeof F.value==="string"){let Q=F.value;if(W!=="sensitive")Q=Q.toLowerCase();if(_.has(Q))F.value=!0;else if(w.has(Q))F.value=!1;else F.issues.push({code:"invalid_value",expected:"stringbool",values:[..._,...w],input:F.value,inst:z})}else F.issues.push({code:"invalid_type",expected:"string",input:F.value})},def:{check:"custom"},onattach:[]}}],error:U});return new G({type:"pipe",in:z,out:new J({type:"boolean",error:U}),error:U})}class e0{constructor($){this._def=$,this.def=$}implement($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=(...W)=>{let U=this._def.input?iU(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(U))throw new Error("Invalid arguments schema: not an array or tuple schema.");let X=$(...U);return this._def.output?iU(this._def.output,X,void 0,{callee:T}):X};return T}implementAsync($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=async(...W)=>{let U=this._def.input?await tU(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(U))throw new Error("Invalid arguments schema: not an array or tuple schema.");let X=await $(...U);return this._def.output?tU(this._def.output,X,void 0,{callee:T}):X};return T}input(...$){if(Array.isArray($[0]))return new e0({type:"function",input:new T0({type:"tuple",items:$[0],rest:$[1]}),output:this._def.output});return new e0({type:"function",input:$[0],output:this._def.output})}output($){return new e0({type:"function",input:this._def.input,output:$})}}function mG($){return new e0({type:"function",input:Array.isArray($?.input)?yG(T0,$?.input):$?.input??null,output:$?.output??null})}var VB={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""};class CX{constructor($){this.counter=0,this.metadataRegistry=$?.metadata??C6,this.target=$?.target??"draft-2020-12",this.unrepresentable=$?.unrepresentable??"throw",this.override=$?.override??(()=>{}),this.io=$?.io??"output",this.seen=new Map}process($,T={path:[],schemaPath:[]}){var W;let U=$._zod.def,X=this.seen.get($);if(X){if(X.count++,T.schemaPath.includes($))X.cycle=T.path;return X.count++,X.schema}let Y={schema:{},count:1,cycle:void 0};if(this.seen.set($,Y),$._zod.toJSONSchema)Y.schema=$._zod.toJSONSchema();let _={...T,schemaPath:[...T.schemaPath,$],path:T.path},w=$._zod.parent;if(w)Y.ref=w,this.process(w,_),this.seen.get(w).isParent=!0;else{let H=Y.schema;switch(U.type){case"string":{let z=H;z.type="string";let{minimum:F,maximum:Q,format:V,patterns:K,contentEncoding:I}=$._zod.bag;if(typeof F==="number")z.minLength=F;if(typeof Q==="number")z.maxLength=Q;if(V){if(z.format=VB[V]??V,z.format==="")delete z.format}if(I)z.contentEncoding=I;if(K&&K.size>0){let k=[...K];if(k.length===1)z.pattern=k[0].source;else if(k.length>1)Y.schema.allOf=[...k.map((N)=>({...this.target==="draft-7"?{type:"string"}:{},pattern:N.source}))]}break}case"number":{let z=H,{minimum:F,maximum:Q,format:V,multipleOf:K,exclusiveMaximum:I,exclusiveMinimum:k}=$._zod.bag;if(typeof V==="string"&&V.includes("int"))z.type="integer";else z.type="number";if(typeof k==="number")z.exclusiveMinimum=k;if(typeof F==="number"){if(z.minimum=F,typeof k==="number")if(k>=F)delete z.minimum;else delete z.exclusiveMinimum}if(typeof I==="number")z.exclusiveMaximum=I;if(typeof Q==="number"){if(z.maximum=Q,typeof I==="number")if(I<=Q)delete z.maximum;else delete z.exclusiveMaximum}if(typeof K==="number")z.multipleOf=K;break}case"boolean":{let z=H;z.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"undefined":{let z=H;z.type="null";break}case"null":{H.type="null";break}case"any":break;case"unknown":break;case"never":{H.not={};break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let z=H,{minimum:F,maximum:Q}=$._zod.bag;if(typeof F==="number")z.minItems=F;if(typeof Q==="number")z.maxItems=Q;z.type="array",z.items=this.process(U.element,{..._,path:[..._.path,"items"]});break}case"object":{let z=H;z.type="object",z.properties={};let F=U.shape;for(let K in F)z.properties[K]=this.process(F[K],{..._,path:[..._.path,"properties",K]});let Q=new Set(Object.keys(F)),V=new Set([...Q].filter((K)=>{let I=U.shape[K]._zod;if(this.io==="input")return I.optin===void 0;else return I.optout===void 0}));if(V.size>0)z.required=Array.from(V);if(U.catchall?._zod.def.type==="never")z.additionalProperties=!1;else if(!U.catchall){if(this.io==="output")z.additionalProperties=!1}else if(U.catchall)z.additionalProperties=this.process(U.catchall,{..._,path:[..._.path,"additionalProperties"]});break}case"union":{let z=H;z.anyOf=U.options.map((F,Q)=>this.process(F,{..._,path:[..._.path,"anyOf",Q]}));break}case"intersection":{let z=H;z.allOf=[this.process(U.left,{..._,path:[..._.path,"allOf",0]}),this.process(U.right,{..._,path:[..._.path,"allOf",1]})];break}case"tuple":{let z=H;z.type="array";let F=U.items.map((K,I)=>this.process(K,{..._,path:[..._.path,"prefixItems",I]}));if(this.target==="draft-2020-12")z.prefixItems=F;else z.items=F;if(U.rest){let K=this.process(U.rest,{..._,path:[..._.path,"items"]});if(this.target==="draft-2020-12")z.items=K;else z.additionalItems=K}if(U.rest)z.items=this.process(U.rest,{..._,path:[..._.path,"items"]});let{minimum:Q,maximum:V}=$._zod.bag;if(typeof Q==="number")z.minItems=Q;if(typeof V==="number")z.maxItems=V;break}case"record":{let z=H;z.type="object",z.propertyNames=this.process(U.keyType,{..._,path:[..._.path,"propertyNames"]}),z.additionalProperties=this.process(U.valueType,{..._,path:[..._.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let z=H;z.enum=Object.values(U.entries);break}case"literal":{let z=H,F=[];for(let Q of U.values)if(Q===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof Q==="bigint")if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");else F.push(Number(Q));else F.push(Q);if(F.length===0);else if(F.length===1){let Q=F[0];z.const=Q}else z.enum=F;break}case"file":{if(this.unrepresentable==="throw")throw new Error("File cannot be represented in JSON Schema");break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let z=this.process(U.innerType,_);H.anyOf=[z,{type:"null"}];break}case"nonoptional":{this.process(U.innerType,_),Y.ref=U.innerType;break}case"success":{let z=H;z.type="boolean";break}case"default":{this.process(U.innerType,_),Y.ref=U.innerType,H.default=U.defaultValue;break}case"prefault":{if(this.process(U.innerType,_),Y.ref=U.innerType,this.io==="input")H._prefault=U.defaultValue;break}case"catch":{this.process(U.innerType,_),Y.ref=U.innerType;let z;try{z=U.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}H.default=z;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let z=H,F=$._zod.pattern;if(!F)throw new Error("Pattern not found in template literal");z.type="string",z.pattern=F.source;break}case"pipe":{let z=this.io==="input"?U.in._zod.def.type==="transform"?U.out:U.in:U.out;this.process(z,_),Y.ref=z;break}case"readonly":{this.process(U.innerType,_),Y.ref=U.innerType,H.readOnly=!0;break}case"promise":{this.process(U.innerType,_),Y.ref=U.innerType;break}case"optional":{this.process(U.innerType,_),Y.ref=U.innerType;break}case"lazy":{let z=$._zod.innerType;this.process(z,_),Y.ref=z;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}let G=this.metadataRegistry.get($);if(G)Object.assign(Y.schema,G);if(this.io==="input"&&U.type==="pipe"){if(delete Y.schema.examples,delete Y.schema.default,Y.schema._prefault)Y.schema.default=Y.schema._prefault}if(this.io==="input"&&Y.schema._prefault)(W=Y.schema).default??(W.default=Y.schema._prefault);return delete Y.schema._prefault,this.seen.get($).schema}emit($,T){let W={cycles:T?.cycles??"ref",reused:T?.reused??"inline",external:T?.external??void 0},U=this.seen.get($);if(!U)throw new Error("Unprocessed schema. This is a bug in Zod.");let X=(J)=>{let H=this.target==="draft-2020-12"?"$defs":"definitions";if(W.external){let V=W.external.registry.get(J[0])?.id;if(V)return{ref:W.external.uri(V)};let K=J[1].defId??J[1].schema.id??`schema${this.counter++}`;return J[1].defId=K,{defId:K,ref:`${W.external.uri("__shared")}#/${H}/${K}`}}if(J[1]===U)return{ref:"#"};let F=`${"#"}/${H}/`,Q=J[1].schema.id??`__schema${this.counter++}`;return{defId:Q,ref:F+Q}},Y=(J)=>{if(J[1].schema.$ref)return;let H=J[1],{ref:z,defId:F}=X(J);if(H.def={...H.schema},F)H.defId=F;let Q=H.schema;for(let V in Q)delete Q[V];Q.$ref=z};for(let J of this.seen.entries()){let H=J[1];if($===J[0]){Y(J);continue}if(W.external){let F=W.external.registry.get(J[0])?.id;if($!==J[0]&&F){Y(J);continue}}if(this.metadataRegistry.get(J[0])?.id){Y(J);continue}if(H.cycle){if(W.cycles==="throw")throw new Error(`Cycle detected: #/${H.cycle?.join("/")}/<root>
30
+ path: iss.path ? [${cT(R)}, ...iss.path] : [${cT(R)}]
31
+ })));`),Q.write(`newResult[${cT(R)}] = ${_}.value`)}Q.write("payload.value = newResult;"),Q.write("return payload;");let L=Q.compile();return(R,_)=>L(O,R,_)},X,U=wY,Y=!qX.jitless,H=Y&&az.value,{catchall:z}=T,F;$._zod.parse=(O,Q)=>{F??(F=W.value);let Z=O.value;if(!U(Z))return O.issues.push({expected:"object",code:"invalid_type",input:Z,inst:$}),O;let K=[];if(Y&&H&&Q?.async===!1&&Q.jitless!==!0){if(!X)X=w(T.shape);O=X(O,Q)}else{O.value={};let _=F.shape;for(let S of F.keys){let x=_[S],b=x._zod.run({value:Z[S],issues:[]},Q),g=x._zod.optin==="optional"&&x._zod.optout==="optional";if(b instanceof Promise)K.push(b.then((T$)=>g?rV(T$,O,S,Z):KY(T$,O,S)));else if(g)rV(b,O,S,Z);else KY(b,O,S)}}if(!z)return K.length?Promise.all(K).then(()=>O):O;let E=[],M=F.keySet,L=z._zod,R=L.def.type;for(let _ of Object.keys(Z)){if(M.has(_))continue;if(R==="never"){E.push(_);continue}let S=L.run({value:Z[_],issues:[]},Q);if(S instanceof Promise)K.push(S.then((x)=>KY(x,O,_)));else KY(S,O,_)}if(E.length)O.issues.push({code:"unrecognized_keys",keys:E,input:Z,inst:$});if(!K.length)return O;return Promise.all(K).then(()=>{return O})}});function nV($,T,W,w){for(let X of $)if(X.issues.length===0)return T.value=X.value,T;return T.issues.push({code:"invalid_union",input:T.value,inst:W,errors:$.map((X)=>X.issues.map((U)=>s6(U,w,N4())))}),T}var DY=k("$ZodUnion",($,T)=>{K$.init($,T),c$($._zod,"values",()=>{if(T.options.every((W)=>W._zod.values))return new Set(T.options.flatMap((W)=>Array.from(W._zod.values)));return}),c$($._zod,"pattern",()=>{if(T.options.every((W)=>W._zod.pattern)){let W=T.options.map((w)=>w._zod.pattern);return new RegExp(`^(${W.map((w)=>jX(w.source)).join("|")})$`)}return}),$._zod.parse=(W,w)=>{let X=!1,U=[];for(let Y of T.options){let G=Y._zod.run({value:W.value,issues:[]},w);if(G instanceof Promise)U.push(G),X=!0;else{if(G.issues.length===0)return G;U.push(G)}}if(!X)return nV(U,W,$,w);return Promise.all(U).then((Y)=>{return nV(Y,W,$,w)})}}),b7=k("$ZodDiscriminatedUnion",($,T)=>{DY.init($,T);let W=$._zod.parse;c$($._zod,"propValues",()=>{let X={};for(let U of T.options){let Y=U._zod.propValues;if(console.dir(Y,{depth:null}),!Y||Object.keys(Y).length===0)throw new Error(`Invalid discriminated union option at index "${T.options.indexOf(U)}"`);for(let[G,H]of Object.entries(Y)){if(!X[G])X[G]=new Set;for(let z of H)X[G].add(z)}}return X});let w=SX(()=>{let X=T.options,U=new Map;for(let Y of X){let G=Y._zod.propValues[T.discriminator];if(!G||G.size===0)throw new Error(`Invalid discriminated union option at index "${T.options.indexOf(Y)}"`);for(let H of G){if(U.has(H))throw new Error(`Duplicate discriminator value "${String(H)}"`);U.set(H,Y)}}return U});$._zod.parse=(X,U)=>{let Y=X.value;if(!wY(Y))return X.issues.push({code:"invalid_type",expected:"object",input:Y,inst:$}),X;let G=w.value.get(Y?.[T.discriminator]);if(G)return G._zod.run(X,U);if(T.unionFallback)return W(X,U);return X.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:Y,path:[T.discriminator],inst:$}),X}}),y7=k("$ZodIntersection",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let{value:X}=W,U=T.left._zod.run({value:X,issues:[]},w),Y=T.right._zod.run({value:X,issues:[]},w);if(U instanceof Promise||Y instanceof Promise)return Promise.all([U,Y]).then(([H,z])=>{return iV(W,H,z)});return iV(W,U,Y)}});function T7($,T){if($===T)return{valid:!0,data:$};if($ instanceof Date&&T instanceof Date&&+$===+T)return{valid:!0,data:$};if(IX($)&&IX(T)){let W=Object.keys(T),w=Object.keys($).filter((U)=>W.indexOf(U)!==-1),X={...$,...T};for(let U of w){let Y=T7($[U],T[U]);if(!Y.valid)return{valid:!1,mergeErrorPath:[U,...Y.mergeErrorPath]};X[U]=Y.data}return{valid:!0,data:X}}if(Array.isArray($)&&Array.isArray(T)){if($.length!==T.length)return{valid:!1,mergeErrorPath:[]};let W=[];for(let w=0;w<$.length;w++){let X=$[w],U=T[w],Y=T7(X,U);if(!Y.valid)return{valid:!1,mergeErrorPath:[w,...Y.mergeErrorPath]};W.push(Y.data)}return{valid:!0,data:W}}return{valid:!1,mergeErrorPath:[]}}function iV($,T,W){if(T.issues.length)$.issues.push(...T.issues);if(W.issues.length)$.issues.push(...W.issues);if(uT($))return $;let w=T7(T.value,W.value);if(!w.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(w.mergeErrorPath)}`);return $.value=w.data,$}var oT=k("$ZodTuple",($,T)=>{K$.init($,T);let W=T.items,w=W.length-[...W].reverse().findIndex((X)=>X._zod.optin!=="optional");$._zod.parse=(X,U)=>{let Y=X.value;if(!Array.isArray(Y))return X.issues.push({input:Y,inst:$,expected:"tuple",code:"invalid_type"}),X;X.value=[];let G=[];if(!T.rest){let z=Y.length>W.length,F=Y.length<w-1;if(z||F)return X.issues.push({input:Y,inst:$,origin:"array",...z?{code:"too_big",maximum:W.length}:{code:"too_small",minimum:W.length}}),X}let H=-1;for(let z of W){if(H++,H>=Y.length){if(H>=w)continue}let F=z._zod.run({value:Y[H],issues:[]},U);if(F instanceof Promise)G.push(F.then((O)=>AY(O,X,H)));else AY(F,X,H)}if(T.rest){let z=Y.slice(W.length);for(let F of z){H++;let O=T.rest._zod.run({value:F,issues:[]},U);if(O instanceof Promise)G.push(O.then((Q)=>AY(Q,X,H)));else AY(O,X,H)}}if(G.length)return Promise.all(G).then(()=>X);return X}});function AY($,T,W){if($.issues.length)T.issues.push(...I6(W,$.issues));T.value[W]=$.value}var h7=k("$ZodRecord",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let X=W.value;if(!IX(X))return W.issues.push({expected:"record",code:"invalid_type",input:X,inst:$}),W;let U=[];if(T.keyType._zod.values){let Y=T.keyType._zod.values;W.value={};for(let H of Y)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let z=T.valueType._zod.run({value:X[H],issues:[]},w);if(z instanceof Promise)U.push(z.then((F)=>{if(F.issues.length)W.issues.push(...I6(H,F.issues));W.value[H]=F.value}));else{if(z.issues.length)W.issues.push(...I6(H,z.issues));W.value[H]=z.value}}let G;for(let H in X)if(!Y.has(H))G=G??[],G.push(H);if(G&&G.length>0)W.issues.push({code:"unrecognized_keys",input:X,inst:$,keys:G})}else{W.value={};for(let Y of Reflect.ownKeys(X)){if(Y==="__proto__")continue;let G=T.keyType._zod.run({value:Y,issues:[]},w);if(G instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(G.issues.length){W.issues.push({origin:"record",code:"invalid_key",issues:G.issues.map((z)=>s6(z,w,N4())),input:Y,path:[Y],inst:$}),W.value[G.value]=G.value;continue}let H=T.valueType._zod.run({value:X[Y],issues:[]},w);if(H instanceof Promise)U.push(H.then((z)=>{if(z.issues.length)W.issues.push(...I6(Y,z.issues));W.value[G.value]=z.value}));else{if(H.issues.length)W.issues.push(...I6(Y,H.issues));W.value[G.value]=H.value}}}if(U.length)return Promise.all(U).then(()=>W);return W}}),g7=k("$ZodMap",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let X=W.value;if(!(X instanceof Map))return W.issues.push({expected:"map",code:"invalid_type",input:X,inst:$}),W;let U=[];W.value=new Map;for(let[Y,G]of X){let H=T.keyType._zod.run({value:Y,issues:[]},w),z=T.valueType._zod.run({value:G,issues:[]},w);if(H instanceof Promise||z instanceof Promise)U.push(Promise.all([H,z]).then(([F,O])=>{tV(F,O,W,Y,X,$,w)}));else tV(H,z,W,Y,X,$,w)}if(U.length)return Promise.all(U).then(()=>W);return W}});function tV($,T,W,w,X,U,Y){if($.issues.length)if(BX.has(typeof w))W.issues.push(...I6(w,$.issues));else W.issues.push({origin:"map",code:"invalid_key",input:X,inst:U,issues:$.issues.map((G)=>s6(G,Y,N4()))});if(T.issues.length)if(BX.has(typeof w))W.issues.push(...I6(w,T.issues));else W.issues.push({origin:"map",code:"invalid_element",input:X,inst:U,key:w,issues:T.issues.map((G)=>s6(G,Y,N4()))});W.value.set($.value,T.value)}var m7=k("$ZodSet",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let X=W.value;if(!(X instanceof Set))return W.issues.push({input:X,inst:$,expected:"set",code:"invalid_type"}),W;let U=[];W.value=new Set;for(let Y of X){let G=T.valueType._zod.run({value:Y,issues:[]},w);if(G instanceof Promise)U.push(G.then((H)=>aV(H,W)));else aV(G,W)}if(U.length)return Promise.all(U).then(()=>W);return W}});function aV($,T){if($.issues.length)T.issues.push(...$.issues);T.value.add($.value)}var c7=k("$ZodEnum",($,T)=>{K$.init($,T);let W=CX(T.entries);$._zod.values=new Set(W),$._zod.pattern=new RegExp(`^(${W.filter((w)=>BX.has(typeof w)).map((w)=>typeof w==="string"?Q0(w):w.toString()).join("|")})$`),$._zod.parse=(w,X)=>{let U=w.value;if($._zod.values.has(U))return w;return w.issues.push({code:"invalid_value",values:W,input:U,inst:$}),w}}),u7=k("$ZodLiteral",($,T)=>{K$.init($,T),$._zod.values=new Set(T.values),$._zod.pattern=new RegExp(`^(${T.values.map((W)=>typeof W==="string"?Q0(W):W?W.toString():String(W)).join("|")})$`),$._zod.parse=(W,w)=>{let X=W.value;if($._zod.values.has(X))return W;return W.issues.push({code:"invalid_value",values:T.values,input:X,inst:$}),W}}),p7=k("$ZodFile",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let X=W.value;if(X instanceof File)return W;return W.issues.push({expected:"file",code:"invalid_type",input:X,inst:$}),W}}),d7=k("$ZodTransform",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let X=T.transform(W.value,W);if(w.async)return(X instanceof Promise?X:Promise.resolve(X)).then((Y)=>{return W.value=Y,W});if(X instanceof Promise)throw new O0;return W.value=X,W}}),o7=k("$ZodOptional",($,T)=>{K$.init($,T),$._zod.optin="optional",$._zod.optout="optional",c$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,void 0]):void 0}),c$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${jX(W.source)})?$`):void 0}),$._zod.parse=(W,w)=>{if(W.value===void 0)return W;return T.innerType._zod.run(W,w)}}),l7=k("$ZodNullable",($,T)=>{K$.init($,T),c$($._zod,"optin",()=>T.innerType._zod.optin),c$($._zod,"optout",()=>T.innerType._zod.optout),c$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${jX(W.source)}|null)$`):void 0}),c$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,null]):void 0}),$._zod.parse=(W,w)=>{if(W.value===null)return W;return T.innerType._zod.run(W,w)}}),r7=k("$ZodDefault",($,T)=>{K$.init($,T),$._zod.optin="optional",c$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,w)=>{if(W.value===void 0)return W.value=T.defaultValue,W;let X=T.innerType._zod.run(W,w);if(X instanceof Promise)return X.then((U)=>sV(U,T));return sV(X,T)}});function sV($,T){if($.value===void 0)$.value=T.defaultValue;return $}var n7=k("$ZodPrefault",($,T)=>{K$.init($,T),$._zod.optin="optional",c$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,w)=>{if(W.value===void 0)W.value=T.defaultValue;return T.innerType._zod.run(W,w)}}),i7=k("$ZodNonOptional",($,T)=>{K$.init($,T),c$($._zod,"values",()=>{let W=T.innerType._zod.values;return W?new Set([...W].filter((w)=>w!==void 0)):void 0}),$._zod.parse=(W,w)=>{let X=T.innerType._zod.run(W,w);if(X instanceof Promise)return X.then((U)=>eV(U,$));return eV(X,$)}});function eV($,T){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:T});return $}var t7=k("$ZodSuccess",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{let X=T.innerType._zod.run(W,w);if(X instanceof Promise)return X.then((U)=>{return W.value=U.issues.length===0,W});return W.value=X.issues.length===0,W}}),a7=k("$ZodCatch",($,T)=>{K$.init($,T),c$($._zod,"optin",()=>T.innerType._zod.optin),c$($._zod,"optout",()=>T.innerType._zod.optout),c$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,w)=>{let X=T.innerType._zod.run(W,w);if(X instanceof Promise)return X.then((U)=>{if(W.value=U.value,U.issues.length)W.value=T.catchValue({...W,error:{issues:U.issues.map((Y)=>s6(Y,w,N4()))},input:W.value}),W.issues=[];return W});if(W.value=X.value,X.issues.length)W.value=T.catchValue({...W,error:{issues:X.issues.map((U)=>s6(U,w,N4()))},input:W.value}),W.issues=[];return W}}),s7=k("$ZodNaN",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{if(typeof W.value!=="number"||!Number.isNaN(W.value))return W.issues.push({input:W.value,inst:$,expected:"nan",code:"invalid_type"}),W;return W}}),uX=k("$ZodPipe",($,T)=>{K$.init($,T),c$($._zod,"values",()=>T.in._zod.values),c$($._zod,"optin",()=>T.in._zod.optin),c$($._zod,"optout",()=>T.out._zod.optout),$._zod.parse=(W,w)=>{let X=T.in._zod.run(W,w);if(X instanceof Promise)return X.then((U)=>$K(U,T,w));return $K(X,T,w)}});function $K($,T,W){if(uT($))return $;return T.out._zod.run({value:$.value,issues:$.issues},W)}var e7=k("$ZodReadonly",($,T)=>{K$.init($,T),c$($._zod,"propValues",()=>T.innerType._zod.propValues),c$($._zod,"optin",()=>T.innerType._zod.optin),c$($._zod,"optout",()=>T.innerType._zod.optout),$._zod.parse=(W,w)=>{let X=T.innerType._zod.run(W,w);if(X instanceof Promise)return X.then(TK);return TK(X)}});function TK($){return $.value=Object.freeze($.value),$}var $3=k("$ZodTemplateLiteral",($,T)=>{K$.init($,T);let W=[];for(let w of T.parts)if(w instanceof K$){if(!w._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...w._zod.traits].shift()}`);let X=w._zod.pattern instanceof RegExp?w._zod.pattern.source:w._zod.pattern;if(!X)throw new Error(`Invalid template literal part: ${w._zod.traits}`);let U=X.startsWith("^")?1:0,Y=X.endsWith("$")?X.length-1:X.length;W.push(X.slice(U,Y))}else if(w===null||sz.has(typeof w))W.push(Q0(`${w}`));else throw new Error(`Invalid template literal part: ${w}`);$._zod.pattern=new RegExp(`^${W.join("")}$`),$._zod.parse=(w,X)=>{if(typeof w.value!=="string")return w.issues.push({input:w.value,inst:$,expected:"template_literal",code:"invalid_type"}),w;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(w.value))return w.issues.push({input:w.value,inst:$,code:"invalid_format",format:"template_literal",pattern:$._zod.pattern.source}),w;return w}}),T3=k("$ZodPromise",($,T)=>{K$.init($,T),$._zod.parse=(W,w)=>{return Promise.resolve(W.value).then((X)=>T.innerType._zod.run({value:X,issues:[]},w))}}),W3=k("$ZodLazy",($,T)=>{K$.init($,T),c$($._zod,"innerType",()=>T.getter()),c$($._zod,"pattern",()=>$._zod.innerType._zod.pattern),c$($._zod,"propValues",()=>$._zod.innerType._zod.propValues),c$($._zod,"optin",()=>$._zod.innerType._zod.optin),c$($._zod,"optout",()=>$._zod.innerType._zod.optout),$._zod.parse=(W,w)=>{return $._zod.innerType._zod.run(W,w)}}),X3=k("$ZodCustom",($,T)=>{z4.init($,T),K$.init($,T),$._zod.parse=(W,w)=>{return W},$._zod.check=(W)=>{let w=W.value,X=T.fn(w);if(X instanceof Promise)return X.then((U)=>WK(U,W,w,$));WK(X,W,w,$);return}});function WK($,T,W,w){if(!$){let X={code:"custom",input:W,inst:w,path:[...w._zod.def.path??[]],continue:!w._zod.def.abort};if(w._zod.def.params)X.params=w._zod.def.params;T.issues.push(W5(X))}}var dX={};e0(dX,{zhTW:()=>g3,zhCN:()=>h3,vi:()=>y3,ur:()=>b3,ua:()=>f3,tr:()=>x3,th:()=>B3,ta:()=>I3,sv:()=>j3,sl:()=>S3,ru:()=>C3,pt:()=>P3,pl:()=>q3,ota:()=>v3,no:()=>k3,nl:()=>_3,ms:()=>R3,mk:()=>J3,ko:()=>L3,kh:()=>N3,ja:()=>D3,it:()=>M3,id:()=>E3,hu:()=>A3,he:()=>K3,frCA:()=>V3,fr:()=>Z3,fi:()=>Q3,fa:()=>O3,es:()=>F3,en:()=>pX,de:()=>H3,cs:()=>z3,ca:()=>G3,be:()=>Y3,az:()=>U3,ar:()=>w3});var pq=()=>{let $={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"number";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"};return(X)=>{switch(X.code){case"invalid_type":return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${X.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${i(X.values[0])}`;return`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${X.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${U} ${X.maximum.toString()} ${Y.unit??"\u0639\u0646\u0635\u0631"}`;return`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${X.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${U} ${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${X.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${U} ${X.minimum.toString()} ${Y.unit}`;return`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${X.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${U} ${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${X.prefix}"`;if(U.format==="ends_with")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${U.suffix}"`;if(U.format==="includes")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${U.includes}"`;if(U.format==="regex")return`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${U.pattern}`;return`${w[U.format]??X.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${X.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${X.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${X.keys.length>1?"\u0629":""}: ${f(X.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${X.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${X.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function w3(){return{localeError:pq()}}var dq=()=>{let $={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"number";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(X)=>{switch(X.code){case"invalid_type":return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${X.expected}, daxil olan ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${i(X.values[0])}`;return`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${X.origin??"d\u0259y\u0259r"} ${U}${X.maximum.toString()} ${Y.unit??"element"}`;return`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${X.origin??"d\u0259y\u0259r"} ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${X.origin} ${U}${X.minimum.toString()} ${Y.unit}`;return`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${X.origin} ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Yanl\u0131\u015F m\u0259tn: "${U.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`;if(U.format==="ends_with")return`Yanl\u0131\u015F m\u0259tn: "${U.suffix}" il\u0259 bitm\u0259lidir`;if(U.format==="includes")return`Yanl\u0131\u015F m\u0259tn: "${U.includes}" daxil olmal\u0131d\u0131r`;if(U.format==="regex")return`Yanl\u0131\u015F m\u0259tn: ${U.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`;return`Yanl\u0131\u015F ${w[U.format]??X.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${X.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${X.keys.length>1?"lar":""}: ${f(X.keys,", ")}`;case"invalid_key":return`${X.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${X.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function U3(){return{localeError:dq()}}function YK($,T,W,w){let X=Math.abs($),U=X%10,Y=X%100;if(Y>=11&&Y<=19)return w;if(U===1)return T;if(U>=2&&U<=4)return W;return w}var oq=()=>{let $={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"\u043B\u0456\u043A";case"object":{if(Array.isArray(X))return"\u043C\u0430\u0441\u0456\u045E";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"};return(X)=>{switch(X.code){case"invalid_type":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${X.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${i(X.values[0])}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y){let G=Number(X.maximum),H=YK(G,Y.unit.one,Y.unit.few,Y.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${X.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${Y.verb} ${U}${X.maximum.toString()} ${H}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${X.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y){let G=Number(X.minimum),H=YK(G,Y.unit.one,Y.unit.few,Y.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${X.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${Y.verb} ${U}${X.minimum.toString()} ${H}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${X.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${U.prefix}"`;if(U.format==="ends_with")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${U.suffix}"`;if(U.format==="includes")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${U.includes}"`;if(U.format==="regex")return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${U.pattern}`;return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${w[U.format]??X.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${X.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${X.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${f(X.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${X.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${X.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function Y3(){return{localeError:oq()}}var lq=()=>{let $={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"number";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"};return(X)=>{switch(X.code){case"invalid_type":return`Tipus inv\xE0lid: s'esperava ${X.expected}, s'ha rebut ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Valor inv\xE0lid: s'esperava ${i(X.values[0])}`;return`Opci\xF3 inv\xE0lida: s'esperava una de ${f(X.values," o ")}`;case"too_big":{let U=X.inclusive?"com a m\xE0xim":"menys de",Y=T(X.origin);if(Y)return`Massa gran: s'esperava que ${X.origin??"el valor"} contingu\xE9s ${U} ${X.maximum.toString()} ${Y.unit??"elements"}`;return`Massa gran: s'esperava que ${X.origin??"el valor"} fos ${U} ${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?"com a m\xEDnim":"m\xE9s de",Y=T(X.origin);if(Y)return`Massa petit: s'esperava que ${X.origin} contingu\xE9s ${U} ${X.minimum.toString()} ${Y.unit}`;return`Massa petit: s'esperava que ${X.origin} fos ${U} ${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Format inv\xE0lid: ha de comen\xE7ar amb "${U.prefix}"`;if(U.format==="ends_with")return`Format inv\xE0lid: ha d'acabar amb "${U.suffix}"`;if(U.format==="includes")return`Format inv\xE0lid: ha d'incloure "${U.includes}"`;if(U.format==="regex")return`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${U.pattern}`;return`Format inv\xE0lid per a ${w[U.format]??X.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${X.divisor}`;case"unrecognized_keys":return`Clau${X.keys.length>1?"s":""} no reconeguda${X.keys.length>1?"s":""}: ${f(X.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${X.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${X.origin}`;default:return"Entrada inv\xE0lida"}}};function G3(){return{localeError:lq()}}var rq=()=>{let $={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"\u010D\xEDslo";case"string":return"\u0159et\u011Bzec";case"boolean":return"boolean";case"bigint":return"bigint";case"function":return"funkce";case"symbol":return"symbol";case"undefined":return"undefined";case"object":{if(Array.isArray(X))return"pole";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"};return(X)=>{switch(X.code){case"invalid_type":return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${X.expected}, obdr\u017Eeno ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${i(X.values[0])}`;return`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${X.origin??"hodnota"} mus\xED m\xEDt ${U}${X.maximum.toString()} ${Y.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${X.origin??"hodnota"} mus\xED b\xFDt ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${X.origin??"hodnota"} mus\xED m\xEDt ${U}${X.minimum.toString()} ${Y.unit??"prvk\u016F"}`;return`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${X.origin??"hodnota"} mus\xED b\xFDt ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${U.prefix}"`;if(U.format==="ends_with")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${U.suffix}"`;if(U.format==="includes")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${U.includes}"`;if(U.format==="regex")return`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${U.pattern}`;return`Neplatn\xFD form\xE1t ${w[U.format]??X.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${X.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${f(X.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${X.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${X.origin}`;default:return"Neplatn\xFD vstup"}}};function z3(){return{localeError:rq()}}var nq=()=>{let $={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"Zahl";case"object":{if(Array.isArray(X))return"Array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"};return(X)=>{switch(X.code){case"invalid_type":return`Ung\xFCltige Eingabe: erwartet ${X.expected}, erhalten ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Ung\xFCltige Eingabe: erwartet ${i(X.values[0])}`;return`Ung\xFCltige Option: erwartet eine von ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Zu gro\xDF: erwartet, dass ${X.origin??"Wert"} ${U}${X.maximum.toString()} ${Y.unit??"Elemente"} hat`;return`Zu gro\xDF: erwartet, dass ${X.origin??"Wert"} ${U}${X.maximum.toString()} ist`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Zu klein: erwartet, dass ${X.origin} ${U}${X.minimum.toString()} ${Y.unit} hat`;return`Zu klein: erwartet, dass ${X.origin} ${U}${X.minimum.toString()} ist`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Ung\xFCltiger String: muss mit "${U.prefix}" beginnen`;if(U.format==="ends_with")return`Ung\xFCltiger String: muss mit "${U.suffix}" enden`;if(U.format==="includes")return`Ung\xFCltiger String: muss "${U.includes}" enthalten`;if(U.format==="regex")return`Ung\xFCltiger String: muss dem Muster ${U.pattern} entsprechen`;return`Ung\xFCltig: ${w[U.format]??X.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${X.divisor} sein`;case"unrecognized_keys":return`${X.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${f(X.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${X.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${X.origin}`;default:return"Ung\xFCltige Eingabe"}}};function H3(){return{localeError:nq()}}var iq=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},tq=()=>{let $={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function T(w){return $[w]??null}let W={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(w)=>{switch(w.code){case"invalid_type":return`Invalid input: expected ${w.expected}, received ${iq(w.input)}`;case"invalid_value":if(w.values.length===1)return`Invalid input: expected ${i(w.values[0])}`;return`Invalid option: expected one of ${f(w.values,"|")}`;case"too_big":{let X=w.inclusive?"<=":"<",U=T(w.origin);if(U)return`Too big: expected ${w.origin??"value"} to have ${X}${w.maximum.toString()} ${U.unit??"elements"}`;return`Too big: expected ${w.origin??"value"} to be ${X}${w.maximum.toString()}`}case"too_small":{let X=w.inclusive?">=":">",U=T(w.origin);if(U)return`Too small: expected ${w.origin} to have ${X}${w.minimum.toString()} ${U.unit}`;return`Too small: expected ${w.origin} to be ${X}${w.minimum.toString()}`}case"invalid_format":{let X=w;if(X.format==="starts_with")return`Invalid string: must start with "${X.prefix}"`;if(X.format==="ends_with")return`Invalid string: must end with "${X.suffix}"`;if(X.format==="includes")return`Invalid string: must include "${X.includes}"`;if(X.format==="regex")return`Invalid string: must match pattern ${X.pattern}`;return`Invalid ${W[X.format]??w.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${w.divisor}`;case"unrecognized_keys":return`Unrecognized key${w.keys.length>1?"s":""}: ${f(w.keys,", ")}`;case"invalid_key":return`Invalid key in ${w.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${w.origin}`;default:return"Invalid input"}}};function pX(){return{localeError:tq()}}var aq=()=>{let $={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"n\xFAmero";case"object":{if(Array.isArray(X))return"arreglo";if(X===null)return"nulo";if(Object.getPrototypeOf(X)!==Object.prototype)return X.constructor.name}}return U},w={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"};return(X)=>{switch(X.code){case"invalid_type":return`Entrada inv\xE1lida: se esperaba ${X.expected}, recibido ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Entrada inv\xE1lida: se esperaba ${i(X.values[0])}`;return`Opci\xF3n inv\xE1lida: se esperaba una de ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Demasiado grande: se esperaba que ${X.origin??"valor"} tuviera ${U}${X.maximum.toString()} ${Y.unit??"elementos"}`;return`Demasiado grande: se esperaba que ${X.origin??"valor"} fuera ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Demasiado peque\xF1o: se esperaba que ${X.origin} tuviera ${U}${X.minimum.toString()} ${Y.unit}`;return`Demasiado peque\xF1o: se esperaba que ${X.origin} fuera ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Cadena inv\xE1lida: debe comenzar con "${U.prefix}"`;if(U.format==="ends_with")return`Cadena inv\xE1lida: debe terminar en "${U.suffix}"`;if(U.format==="includes")return`Cadena inv\xE1lida: debe incluir "${U.includes}"`;if(U.format==="regex")return`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${U.pattern}`;return`Inv\xE1lido ${w[U.format]??X.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${X.divisor}`;case"unrecognized_keys":return`Llave${X.keys.length>1?"s":""} desconocida${X.keys.length>1?"s":""}: ${f(X.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${X.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${X.origin}`;default:return"Entrada inv\xE1lida"}}};function F3(){return{localeError:aq()}}var sq=()=>{let $={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"\u0639\u062F\u062F";case"object":{if(Array.isArray(X))return"\u0622\u0631\u0627\u06CC\u0647";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"};return(X)=>{switch(X.code){case"invalid_type":return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${X.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${W(X.input)} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`;case"invalid_value":if(X.values.length===1)return`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${i(X.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`;return`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${f(X.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${X.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${U}${X.maximum.toString()} ${Y.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${X.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${U}${X.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${X.origin} \u0628\u0627\u06CC\u062F ${U}${X.minimum.toString()} ${Y.unit} \u0628\u0627\u0634\u062F`;return`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${X.origin} \u0628\u0627\u06CC\u062F ${U}${X.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${U.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`;if(U.format==="ends_with")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${U.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`;if(U.format==="includes")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${U.includes}" \u0628\u0627\u0634\u062F`;if(U.format==="regex")return`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${U.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`;return`${w[U.format]??X.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${X.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${X.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${f(X.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${X.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${X.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function O3(){return{localeError:sq()}}var eq=()=>{let $={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"number";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"};return(X)=>{switch(X.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${X.expected}, oli ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Virheellinen sy\xF6te: t\xE4ytyy olla ${i(X.values[0])}`;return`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Liian suuri: ${Y.subject} t\xE4ytyy olla ${U}${X.maximum.toString()} ${Y.unit}`.trim();return`Liian suuri: arvon t\xE4ytyy olla ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Liian pieni: ${Y.subject} t\xE4ytyy olla ${U}${X.minimum.toString()} ${Y.unit}`.trim();return`Liian pieni: arvon t\xE4ytyy olla ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${U.prefix}"`;if(U.format==="ends_with")return`Virheellinen sy\xF6te: t\xE4ytyy loppua "${U.suffix}"`;if(U.format==="includes")return`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${U.includes}"`;if(U.format==="regex")return`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${U.pattern}`;return`Virheellinen ${w[U.format]??X.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${X.divisor} monikerta`;case"unrecognized_keys":return`${X.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${f(X.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function Q3(){return{localeError:eq()}}var $P=()=>{let $={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"nombre";case"object":{if(Array.isArray(X))return"tableau";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"};return(X)=>{switch(X.code){case"invalid_type":return`Entr\xE9e invalide : ${X.expected} attendu, ${W(X.input)} re\xE7u`;case"invalid_value":if(X.values.length===1)return`Entr\xE9e invalide : ${i(X.values[0])} attendu`;return`Option invalide : une valeur parmi ${f(X.values,"|")} attendue`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Trop grand : ${X.origin??"valeur"} doit ${Y.verb} ${U}${X.maximum.toString()} ${Y.unit??"\xE9l\xE9ment(s)"}`;return`Trop grand : ${X.origin??"valeur"} doit \xEAtre ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Trop petit : ${X.origin} doit ${Y.verb} ${U}${X.minimum.toString()} ${Y.unit}`;return`Trop petit : ${X.origin} doit \xEAtre ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${U.prefix}"`;if(U.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${U.suffix}"`;if(U.format==="includes")return`Cha\xEEne invalide : doit inclure "${U.includes}"`;if(U.format==="regex")return`Cha\xEEne invalide : doit correspondre au mod\xE8le ${U.pattern}`;return`${w[U.format]??X.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${X.divisor}`;case"unrecognized_keys":return`Cl\xE9${X.keys.length>1?"s":""} non reconnue${X.keys.length>1?"s":""} : ${f(X.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${X.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${X.origin}`;default:return"Entr\xE9e invalide"}}};function Z3(){return{localeError:$P()}}var TP=()=>{let $={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"number";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"};return(X)=>{switch(X.code){case"invalid_type":return`Entr\xE9e invalide : attendu ${X.expected}, re\xE7u ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Entr\xE9e invalide : attendu ${i(X.values[0])}`;return`Option invalide : attendu l'une des valeurs suivantes ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"\u2264":"<",Y=T(X.origin);if(Y)return`Trop grand : attendu que ${X.origin??"la valeur"} ait ${U}${X.maximum.toString()} ${Y.unit}`;return`Trop grand : attendu que ${X.origin??"la valeur"} soit ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?"\u2265":">",Y=T(X.origin);if(Y)return`Trop petit : attendu que ${X.origin} ait ${U}${X.minimum.toString()} ${Y.unit}`;return`Trop petit : attendu que ${X.origin} soit ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Cha\xEEne invalide : doit commencer par "${U.prefix}"`;if(U.format==="ends_with")return`Cha\xEEne invalide : doit se terminer par "${U.suffix}"`;if(U.format==="includes")return`Cha\xEEne invalide : doit inclure "${U.includes}"`;if(U.format==="regex")return`Cha\xEEne invalide : doit correspondre au motif ${U.pattern}`;return`${w[U.format]??X.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${X.divisor}`;case"unrecognized_keys":return`Cl\xE9${X.keys.length>1?"s":""} non reconnue${X.keys.length>1?"s":""} : ${f(X.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${X.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${X.origin}`;default:return"Entr\xE9e invalide"}}};function V3(){return{localeError:TP()}}var WP=()=>{let $={string:{unit:"\u05D0\u05D5\u05EA\u05D9\u05D5\u05EA",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",verb:"\u05DC\u05DB\u05DC\u05D5\u05DC"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"number";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u05E7\u05DC\u05D8",email:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",url:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",emoji:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",date:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",time:"\u05D6\u05DE\u05DF ISO",duration:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",ipv4:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",ipv6:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",cidrv4:"\u05D8\u05D5\u05D5\u05D7 IPv4",cidrv6:"\u05D8\u05D5\u05D5\u05D7 IPv6",base64:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",base64url:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",json_string:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",e164:"\u05DE\u05E1\u05E4\u05E8 E.164",jwt:"JWT",template_literal:"\u05E7\u05DC\u05D8"};return(X)=>{switch(X.code){case"invalid_type":return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${X.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${i(X.values[0])}`;return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05D0\u05D7\u05EA \u05DE\u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${X.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${U}${X.maximum.toString()} ${Y.unit??"elements"}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${X.origin??"value"} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${X.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${U}${X.minimum.toString()} ${Y.unit}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${X.origin} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1"${U.prefix}"`;if(U.format==="ends_with")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${U.suffix}"`;if(U.format==="includes")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${U.includes}"`;if(U.format==="regex")return`\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4: \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${U.pattern}`;return`${w[U.format]??X.format} \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${X.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${X.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${X.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${f(X.keys,", ")}`;case"invalid_key":return`\u05DE\u05E4\u05EA\u05D7 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${X.origin}`;case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${X.origin}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function K3(){return{localeError:WP()}}var XP=()=>{let $={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"sz\xE1m";case"object":{if(Array.isArray(X))return"t\xF6mb";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"};return(X)=>{switch(X.code){case"invalid_type":return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${X.expected}, a kapott \xE9rt\xE9k ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${i(X.values[0])}`;return`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`T\xFAl nagy: ${X.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${U}${X.maximum.toString()} ${Y.unit??"elem"}`;return`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${X.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${X.origin} m\xE9rete t\xFAl kicsi ${U}${X.minimum.toString()} ${Y.unit}`;return`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${X.origin} t\xFAl kicsi ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\xC9rv\xE9nytelen string: "${U.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`;if(U.format==="ends_with")return`\xC9rv\xE9nytelen string: "${U.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`;if(U.format==="includes")return`\xC9rv\xE9nytelen string: "${U.includes}" \xE9rt\xE9ket kell tartalmaznia`;if(U.format==="regex")return`\xC9rv\xE9nytelen string: ${U.pattern} mint\xE1nak kell megfelelnie`;return`\xC9rv\xE9nytelen ${w[U.format]??X.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${X.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${X.keys.length>1?"s":""}: ${f(X.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${X.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${X.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function A3(){return{localeError:XP()}}var wP=()=>{let $={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"number";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"};return(X)=>{switch(X.code){case"invalid_type":return`Input tidak valid: diharapkan ${X.expected}, diterima ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Input tidak valid: diharapkan ${i(X.values[0])}`;return`Pilihan tidak valid: diharapkan salah satu dari ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Terlalu besar: diharapkan ${X.origin??"value"} memiliki ${U}${X.maximum.toString()} ${Y.unit??"elemen"}`;return`Terlalu besar: diharapkan ${X.origin??"value"} menjadi ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Terlalu kecil: diharapkan ${X.origin} memiliki ${U}${X.minimum.toString()} ${Y.unit}`;return`Terlalu kecil: diharapkan ${X.origin} menjadi ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`String tidak valid: harus dimulai dengan "${U.prefix}"`;if(U.format==="ends_with")return`String tidak valid: harus berakhir dengan "${U.suffix}"`;if(U.format==="includes")return`String tidak valid: harus menyertakan "${U.includes}"`;if(U.format==="regex")return`String tidak valid: harus sesuai pola ${U.pattern}`;return`${w[U.format]??X.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${X.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${X.keys.length>1?"s":""}: ${f(X.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${X.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${X.origin}`;default:return"Input tidak valid"}}};function E3(){return{localeError:wP()}}var UP=()=>{let $={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"numero";case"object":{if(Array.isArray(X))return"vettore";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"};return(X)=>{switch(X.code){case"invalid_type":return`Input non valido: atteso ${X.expected}, ricevuto ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Input non valido: atteso ${i(X.values[0])}`;return`Opzione non valida: atteso uno tra ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Troppo grande: ${X.origin??"valore"} deve avere ${U}${X.maximum.toString()} ${Y.unit??"elementi"}`;return`Troppo grande: ${X.origin??"valore"} deve essere ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Troppo piccolo: ${X.origin} deve avere ${U}${X.minimum.toString()} ${Y.unit}`;return`Troppo piccolo: ${X.origin} deve essere ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Stringa non valida: deve iniziare con "${U.prefix}"`;if(U.format==="ends_with")return`Stringa non valida: deve terminare con "${U.suffix}"`;if(U.format==="includes")return`Stringa non valida: deve includere "${U.includes}"`;if(U.format==="regex")return`Stringa non valida: deve corrispondere al pattern ${U.pattern}`;return`Invalid ${w[U.format]??X.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${X.divisor}`;case"unrecognized_keys":return`Chiav${X.keys.length>1?"i":"e"} non riconosciut${X.keys.length>1?"e":"a"}: ${f(X.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${X.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${X.origin}`;default:return"Input non valido"}}};function M3(){return{localeError:UP()}}var YP=()=>{let $={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"\u6570\u5024";case"object":{if(Array.isArray(X))return"\u914D\u5217";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"};return(X)=>{switch(X.code){case"invalid_type":return`\u7121\u52B9\u306A\u5165\u529B: ${X.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${W(X.input)}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`;case"invalid_value":if(X.values.length===1)return`\u7121\u52B9\u306A\u5165\u529B: ${i(X.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`;return`\u7121\u52B9\u306A\u9078\u629E: ${f(X.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u5927\u304D\u3059\u304E\u308B\u5024: ${X.origin??"\u5024"}\u306F${X.maximum.toString()}${Y.unit??"\u8981\u7D20"}${U}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5927\u304D\u3059\u304E\u308B\u5024: ${X.origin??"\u5024"}\u306F${X.maximum.toString()}${U}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${X.origin}\u306F${X.minimum.toString()}${Y.unit}${U}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${X.origin}\u306F${X.minimum.toString()}${U}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${U.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(U.format==="ends_with")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${U.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(U.format==="includes")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${U.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;if(U.format==="regex")return`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${U.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;return`\u7121\u52B9\u306A${w[U.format]??X.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${X.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${X.keys.length>1?"\u7FA4":""}: ${f(X.keys,"\u3001")}`;case"invalid_key":return`${X.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${X.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function D3(){return{localeError:YP()}}var GP=()=>{let $={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"\u1798\u17B7\u1793\u1798\u17C2\u1793\u1787\u17B6\u179B\u17C1\u1781 (NaN)":"\u179B\u17C1\u1781";case"object":{if(Array.isArray(X))return"\u17A2\u17B6\u179A\u17C1 (Array)";if(X===null)return"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"};return(X)=>{switch(X.code){case"invalid_type":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${X.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${i(X.values[0])}`;return`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${X.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${U} ${X.maximum.toString()} ${Y.unit??"\u1792\u17B6\u178F\u17BB"}`;return`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${X.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${U} ${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${X.origin} ${U} ${X.minimum.toString()} ${Y.unit}`;return`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${X.origin} ${U} ${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${U.prefix}"`;if(U.format==="ends_with")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${U.suffix}"`;if(U.format==="includes")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${U.includes}"`;if(U.format==="regex")return`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${U.pattern}`;return`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${w[U.format]??X.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${X.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${f(X.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${X.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${X.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function N3(){return{localeError:GP()}}var zP=()=>{let $={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"number";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"};return(X)=>{switch(X.code){case"invalid_type":return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${X.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${W(X.input)}\uC785\uB2C8\uB2E4`;case"invalid_value":if(X.values.length===1)return`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${i(X.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C \uC635\uC158: ${f(X.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let U=X.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",Y=U==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",G=T(X.origin),H=G?.unit??"\uC694\uC18C";if(G)return`${X.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${X.maximum.toString()}${H} ${U}${Y}`;return`${X.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${X.maximum.toString()} ${U}${Y}`}case"too_small":{let U=X.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",Y=U==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",G=T(X.origin),H=G?.unit??"\uC694\uC18C";if(G)return`${X.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${X.minimum.toString()}${H} ${U}${Y}`;return`${X.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${X.minimum.toString()} ${U}${Y}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${U.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`;if(U.format==="ends_with")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${U.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`;if(U.format==="includes")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${U.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`;if(U.format==="regex")return`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${U.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C ${w[U.format]??X.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${X.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${f(X.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${X.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${X.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function L3(){return{localeError:zP()}}var HP=()=>{let $={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"\u0431\u0440\u043E\u0458";case"object":{if(Array.isArray(X))return"\u043D\u0438\u0437\u0430";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"};return(X)=>{switch(X.code){case"invalid_type":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${X.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Invalid input: expected ${i(X.values[0])}`;return`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${X.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${U}${X.maximum.toString()} ${Y.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${X.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${X.origin} \u0434\u0430 \u0438\u043C\u0430 ${U}${X.minimum.toString()} ${Y.unit}`;return`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${X.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${U.prefix}"`;if(U.format==="ends_with")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${U.suffix}"`;if(U.format==="includes")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${U.includes}"`;if(U.format==="regex")return`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${U.pattern}`;return`Invalid ${w[U.format]??X.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${X.divisor}`;case"unrecognized_keys":return`${X.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${f(X.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${X.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${X.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function J3(){return{localeError:HP()}}var FP=()=>{let $={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"nombor";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"};return(X)=>{switch(X.code){case"invalid_type":return`Input tidak sah: dijangka ${X.expected}, diterima ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Input tidak sah: dijangka ${i(X.values[0])}`;return`Pilihan tidak sah: dijangka salah satu daripada ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Terlalu besar: dijangka ${X.origin??"nilai"} ${Y.verb} ${U}${X.maximum.toString()} ${Y.unit??"elemen"}`;return`Terlalu besar: dijangka ${X.origin??"nilai"} adalah ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Terlalu kecil: dijangka ${X.origin} ${Y.verb} ${U}${X.minimum.toString()} ${Y.unit}`;return`Terlalu kecil: dijangka ${X.origin} adalah ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`String tidak sah: mesti bermula dengan "${U.prefix}"`;if(U.format==="ends_with")return`String tidak sah: mesti berakhir dengan "${U.suffix}"`;if(U.format==="includes")return`String tidak sah: mesti mengandungi "${U.includes}"`;if(U.format==="regex")return`String tidak sah: mesti sepadan dengan corak ${U.pattern}`;return`${w[U.format]??X.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${X.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${f(X.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${X.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${X.origin}`;default:return"Input tidak sah"}}};function R3(){return{localeError:FP()}}var OP=()=>{let $={string:{unit:"tekens"},file:{unit:"bytes"},array:{unit:"elementen"},set:{unit:"elementen"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"getal";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"};return(X)=>{switch(X.code){case"invalid_type":return`Ongeldige invoer: verwacht ${X.expected}, ontving ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Ongeldige invoer: verwacht ${i(X.values[0])}`;return`Ongeldige optie: verwacht \xE9\xE9n van ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Te lang: verwacht dat ${X.origin??"waarde"} ${U}${X.maximum.toString()} ${Y.unit??"elementen"} bevat`;return`Te lang: verwacht dat ${X.origin??"waarde"} ${U}${X.maximum.toString()} is`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Te kort: verwacht dat ${X.origin} ${U}${X.minimum.toString()} ${Y.unit} bevat`;return`Te kort: verwacht dat ${X.origin} ${U}${X.minimum.toString()} is`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Ongeldige tekst: moet met "${U.prefix}" beginnen`;if(U.format==="ends_with")return`Ongeldige tekst: moet op "${U.suffix}" eindigen`;if(U.format==="includes")return`Ongeldige tekst: moet "${U.includes}" bevatten`;if(U.format==="regex")return`Ongeldige tekst: moet overeenkomen met patroon ${U.pattern}`;return`Ongeldig: ${w[U.format]??X.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${X.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${X.keys.length>1?"s":""}: ${f(X.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${X.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${X.origin}`;default:return"Ongeldige invoer"}}};function _3(){return{localeError:OP()}}var QP=()=>{let $={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"tall";case"object":{if(Array.isArray(X))return"liste";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return(X)=>{switch(X.code){case"invalid_type":return`Ugyldig input: forventet ${X.expected}, fikk ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Ugyldig verdi: forventet ${i(X.values[0])}`;return`Ugyldig valg: forventet en av ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`For stor(t): forventet ${X.origin??"value"} til \xE5 ha ${U}${X.maximum.toString()} ${Y.unit??"elementer"}`;return`For stor(t): forventet ${X.origin??"value"} til \xE5 ha ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`For lite(n): forventet ${X.origin} til \xE5 ha ${U}${X.minimum.toString()} ${Y.unit}`;return`For lite(n): forventet ${X.origin} til \xE5 ha ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Ugyldig streng: m\xE5 starte med "${U.prefix}"`;if(U.format==="ends_with")return`Ugyldig streng: m\xE5 ende med "${U.suffix}"`;if(U.format==="includes")return`Ugyldig streng: m\xE5 inneholde "${U.includes}"`;if(U.format==="regex")return`Ugyldig streng: m\xE5 matche m\xF8nsteret ${U.pattern}`;return`Ugyldig ${w[U.format]??X.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${X.divisor}`;case"unrecognized_keys":return`${X.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${f(X.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${X.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${X.origin}`;default:return"Ugyldig input"}}};function k3(){return{localeError:QP()}}var ZP=()=>{let $={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"numara";case"object":{if(Array.isArray(X))return"saf";if(X===null)return"gayb";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"};return(X)=>{switch(X.code){case"invalid_type":return`F\xE2sit giren: umulan ${X.expected}, al\u0131nan ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`F\xE2sit giren: umulan ${i(X.values[0])}`;return`F\xE2sit tercih: m\xFBteberler ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Fazla b\xFCy\xFCk: ${X.origin??"value"}, ${U}${X.maximum.toString()} ${Y.unit??"elements"} sahip olmal\u0131yd\u0131.`;return`Fazla b\xFCy\xFCk: ${X.origin??"value"}, ${U}${X.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Fazla k\xFC\xE7\xFCk: ${X.origin}, ${U}${X.minimum.toString()} ${Y.unit} sahip olmal\u0131yd\u0131.`;return`Fazla k\xFC\xE7\xFCk: ${X.origin}, ${U}${X.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`F\xE2sit metin: "${U.prefix}" ile ba\u015Flamal\u0131.`;if(U.format==="ends_with")return`F\xE2sit metin: "${U.suffix}" ile bitmeli.`;if(U.format==="includes")return`F\xE2sit metin: "${U.includes}" ihtiv\xE2 etmeli.`;if(U.format==="regex")return`F\xE2sit metin: ${U.pattern} nak\u015F\u0131na uymal\u0131.`;return`F\xE2sit ${w[U.format]??X.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${X.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${X.keys.length>1?"s":""}: ${f(X.keys,", ")}`;case"invalid_key":return`${X.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${X.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function v3(){return{localeError:ZP()}}var VP=()=>{let $={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"liczba";case"object":{if(Array.isArray(X))return"tablica";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"};return(X)=>{switch(X.code){case"invalid_type":return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${X.expected}, otrzymano ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${i(X.values[0])}`;return`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${X.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${U}${X.maximum.toString()} ${Y.unit??"element\xF3w"}`;return`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${X.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${X.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${U}${X.minimum.toString()} ${Y.unit??"element\xF3w"}`;return`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${X.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${U.prefix}"`;if(U.format==="ends_with")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${U.suffix}"`;if(U.format==="includes")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${U.includes}"`;if(U.format==="regex")return`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${U.pattern}`;return`Nieprawid\u0142ow(y/a/e) ${w[U.format]??X.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${X.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${X.keys.length>1?"s":""}: ${f(X.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${X.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${X.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function q3(){return{localeError:VP()}}var KP=()=>{let $={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"n\xFAmero";case"object":{if(Array.isArray(X))return"array";if(X===null)return"nulo";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"};return(X)=>{switch(X.code){case"invalid_type":return`Tipo inv\xE1lido: esperado ${X.expected}, recebido ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Entrada inv\xE1lida: esperado ${i(X.values[0])}`;return`Op\xE7\xE3o inv\xE1lida: esperada uma das ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Muito grande: esperado que ${X.origin??"valor"} tivesse ${U}${X.maximum.toString()} ${Y.unit??"elementos"}`;return`Muito grande: esperado que ${X.origin??"valor"} fosse ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Muito pequeno: esperado que ${X.origin} tivesse ${U}${X.minimum.toString()} ${Y.unit}`;return`Muito pequeno: esperado que ${X.origin} fosse ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Texto inv\xE1lido: deve come\xE7ar com "${U.prefix}"`;if(U.format==="ends_with")return`Texto inv\xE1lido: deve terminar com "${U.suffix}"`;if(U.format==="includes")return`Texto inv\xE1lido: deve incluir "${U.includes}"`;if(U.format==="regex")return`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${U.pattern}`;return`${w[U.format]??X.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${X.divisor}`;case"unrecognized_keys":return`Chave${X.keys.length>1?"s":""} desconhecida${X.keys.length>1?"s":""}: ${f(X.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${X.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${X.origin}`;default:return"Campo inv\xE1lido"}}};function P3(){return{localeError:KP()}}function GK($,T,W,w){let X=Math.abs($),U=X%10,Y=X%100;if(Y>=11&&Y<=19)return w;if(U===1)return T;if(U>=2&&U<=4)return W;return w}var AP=()=>{let $={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray(X))return"\u043C\u0430\u0441\u0441\u0438\u0432";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"};return(X)=>{switch(X.code){case"invalid_type":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${X.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${i(X.values[0])}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y){let G=Number(X.maximum),H=GK(G,Y.unit.one,Y.unit.few,Y.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${X.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${U}${X.maximum.toString()} ${H}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${X.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y){let G=Number(X.minimum),H=GK(G,Y.unit.one,Y.unit.few,Y.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${X.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${U}${X.minimum.toString()} ${H}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${X.origin} \u0431\u0443\u0434\u0435\u0442 ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${U.prefix}"`;if(U.format==="ends_with")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${U.suffix}"`;if(U.format==="includes")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${U.includes}"`;if(U.format==="regex")return`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${U.pattern}`;return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${w[U.format]??X.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${X.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${X.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${X.keys.length>1?"\u0438":""}: ${f(X.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${X.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${X.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function C3(){return{localeError:AP()}}var EP=()=>{let $={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"\u0161tevilo";case"object":{if(Array.isArray(X))return"tabela";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"};return(X)=>{switch(X.code){case"invalid_type":return`Neveljaven vnos: pri\u010Dakovano ${X.expected}, prejeto ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Neveljaven vnos: pri\u010Dakovano ${i(X.values[0])}`;return`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Preveliko: pri\u010Dakovano, da bo ${X.origin??"vrednost"} imelo ${U}${X.maximum.toString()} ${Y.unit??"elementov"}`;return`Preveliko: pri\u010Dakovano, da bo ${X.origin??"vrednost"} ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Premajhno: pri\u010Dakovano, da bo ${X.origin} imelo ${U}${X.minimum.toString()} ${Y.unit}`;return`Premajhno: pri\u010Dakovano, da bo ${X.origin} ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Neveljaven niz: mora se za\u010Deti z "${U.prefix}"`;if(U.format==="ends_with")return`Neveljaven niz: mora se kon\u010Dati z "${U.suffix}"`;if(U.format==="includes")return`Neveljaven niz: mora vsebovati "${U.includes}"`;if(U.format==="regex")return`Neveljaven niz: mora ustrezati vzorcu ${U.pattern}`;return`Neveljaven ${w[U.format]??X.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${X.divisor}`;case"unrecognized_keys":return`Neprepoznan${X.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${f(X.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${X.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${X.origin}`;default:return"Neveljaven vnos"}}};function S3(){return{localeError:EP()}}var MP=()=>{let $={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"antal";case"object":{if(Array.isArray(X))return"lista";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"};return(X)=>{switch(X.code){case"invalid_type":return`Ogiltig inmatning: f\xF6rv\xE4ntat ${X.expected}, fick ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`Ogiltig inmatning: f\xF6rv\xE4ntat ${i(X.values[0])}`;return`Ogiltigt val: f\xF6rv\xE4ntade en av ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`F\xF6r stor(t): f\xF6rv\xE4ntade ${X.origin??"v\xE4rdet"} att ha ${U}${X.maximum.toString()} ${Y.unit??"element"}`;return`F\xF6r stor(t): f\xF6rv\xE4ntat ${X.origin??"v\xE4rdet"} att ha ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`F\xF6r lite(t): f\xF6rv\xE4ntade ${X.origin??"v\xE4rdet"} att ha ${U}${X.minimum.toString()} ${Y.unit}`;return`F\xF6r lite(t): f\xF6rv\xE4ntade ${X.origin??"v\xE4rdet"} att ha ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${U.prefix}"`;if(U.format==="ends_with")return`Ogiltig str\xE4ng: m\xE5ste sluta med "${U.suffix}"`;if(U.format==="includes")return`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${U.includes}"`;if(U.format==="regex")return`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${U.pattern}"`;return`Ogiltig(t) ${w[U.format]??X.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${X.divisor}`;case"unrecognized_keys":return`${X.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${f(X.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${X.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${X.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function j3(){return{localeError:MP()}}var DP=()=>{let $={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"\u0B8E\u0BA3\u0BCD \u0B85\u0BB2\u0BCD\u0BB2\u0BBE\u0BA4\u0BA4\u0BC1":"\u0B8E\u0BA3\u0BCD";case"object":{if(Array.isArray(X))return"\u0B85\u0BA3\u0BBF";if(X===null)return"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"};return(X)=>{switch(X.code){case"invalid_type":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${X.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${i(X.values[0])}`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${f(X.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${X.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${U}${X.maximum.toString()} ${Y.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${X.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${U}${X.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${X.origin} ${U}${X.minimum.toString()} ${Y.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${X.origin} ${U}${X.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${U.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(U.format==="ends_with")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${U.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(U.format==="includes")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${U.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;if(U.format==="regex")return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${U.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${w[U.format]??X.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${X.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${X.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${f(X.keys,", ")}`;case"invalid_key":return`${X.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${X.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function I3(){return{localeError:DP()}}var NP=()=>{let $={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"\u0E44\u0E21\u0E48\u0E43\u0E0A\u0E48\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02 (NaN)":"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02";case"object":{if(Array.isArray(X))return"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)";if(X===null)return"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"};return(X)=>{switch(X.code){case"invalid_type":return`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${X.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${i(X.values[0])}`;return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",Y=T(X.origin);if(Y)return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${X.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${U} ${X.maximum.toString()} ${Y.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`;return`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${X.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${U} ${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",Y=T(X.origin);if(Y)return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${X.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${U} ${X.minimum.toString()} ${Y.unit}`;return`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${X.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${U} ${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${U.prefix}"`;if(U.format==="ends_with")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${U.suffix}"`;if(U.format==="includes")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${U.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`;if(U.format==="regex")return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${U.pattern}`;return`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${w[U.format]??X.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${X.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${f(X.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${X.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${X.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function B3(){return{localeError:NP()}}var LP=($)=>{let T=typeof $;switch(T){case"number":return Number.isNaN($)?"NaN":"number";case"object":{if(Array.isArray($))return"array";if($===null)return"null";if(Object.getPrototypeOf($)!==Object.prototype&&$.constructor)return $.constructor.name}}return T},JP=()=>{let $={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function T(w){return $[w]??null}let W={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"};return(w)=>{switch(w.code){case"invalid_type":return`Ge\xE7ersiz de\u011Fer: beklenen ${w.expected}, al\u0131nan ${LP(w.input)}`;case"invalid_value":if(w.values.length===1)return`Ge\xE7ersiz de\u011Fer: beklenen ${i(w.values[0])}`;return`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${f(w.values,"|")}`;case"too_big":{let X=w.inclusive?"<=":"<",U=T(w.origin);if(U)return`\xC7ok b\xFCy\xFCk: beklenen ${w.origin??"de\u011Fer"} ${X}${w.maximum.toString()} ${U.unit??"\xF6\u011Fe"}`;return`\xC7ok b\xFCy\xFCk: beklenen ${w.origin??"de\u011Fer"} ${X}${w.maximum.toString()}`}case"too_small":{let X=w.inclusive?">=":">",U=T(w.origin);if(U)return`\xC7ok k\xFC\xE7\xFCk: beklenen ${w.origin} ${X}${w.minimum.toString()} ${U.unit}`;return`\xC7ok k\xFC\xE7\xFCk: beklenen ${w.origin} ${X}${w.minimum.toString()}`}case"invalid_format":{let X=w;if(X.format==="starts_with")return`Ge\xE7ersiz metin: "${X.prefix}" ile ba\u015Flamal\u0131`;if(X.format==="ends_with")return`Ge\xE7ersiz metin: "${X.suffix}" ile bitmeli`;if(X.format==="includes")return`Ge\xE7ersiz metin: "${X.includes}" i\xE7ermeli`;if(X.format==="regex")return`Ge\xE7ersiz metin: ${X.pattern} desenine uymal\u0131`;return`Ge\xE7ersiz ${W[X.format]??w.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${w.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${w.keys.length>1?"lar":""}: ${f(w.keys,", ")}`;case"invalid_key":return`${w.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${w.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function x3(){return{localeError:JP()}}var RP=()=>{let $={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"\u0447\u0438\u0441\u043B\u043E";case"object":{if(Array.isArray(X))return"\u043C\u0430\u0441\u0438\u0432";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"};return(X)=>{switch(X.code){case"invalid_type":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${X.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${i(X.values[0])}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${X.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${Y.verb} ${U}${X.maximum.toString()} ${Y.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`;return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${X.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${X.origin} ${Y.verb} ${U}${X.minimum.toString()} ${Y.unit}`;return`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${X.origin} \u0431\u0443\u0434\u0435 ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${U.prefix}"`;if(U.format==="ends_with")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${U.suffix}"`;if(U.format==="includes")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${U.includes}"`;if(U.format==="regex")return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${U.pattern}`;return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${w[U.format]??X.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${X.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${X.keys.length>1?"\u0456":""}: ${f(X.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${X.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${X.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function f3(){return{localeError:RP()}}var _P=()=>{let $={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"\u0646\u0645\u0628\u0631";case"object":{if(Array.isArray(X))return"\u0622\u0631\u06D2";if(X===null)return"\u0646\u0644";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"};return(X)=>{switch(X.code){case"invalid_type":return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${X.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${W(X.input)} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`;case"invalid_value":if(X.values.length===1)return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${i(X.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;return`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${f(X.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${X.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${U}${X.maximum.toString()} ${Y.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0628\u0691\u0627: ${X.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${U}${X.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${X.origin} \u06A9\u06D2 ${U}${X.minimum.toString()} ${Y.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`;return`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${X.origin} \u06A9\u0627 ${U}${X.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${U.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(U.format==="ends_with")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${U.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(U.format==="includes")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${U.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;if(U.format==="regex")return`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${U.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;return`\u063A\u0644\u0637 ${w[U.format]??X.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${X.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${X.keys.length>1?"\u0632":""}: ${f(X.keys,"\u060C ")}`;case"invalid_key":return`${X.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${X.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function b3(){return{localeError:_P()}}var kP=()=>{let $={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"s\u1ED1";case"object":{if(Array.isArray(X))return"m\u1EA3ng";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"};return(X)=>{switch(X.code){case"invalid_type":return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${X.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${i(X.values[0])}`;return`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${X.origin??"gi\xE1 tr\u1ECB"} ${Y.verb} ${U}${X.maximum.toString()} ${Y.unit??"ph\u1EA7n t\u1EED"}`;return`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${X.origin??"gi\xE1 tr\u1ECB"} ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${X.origin} ${Y.verb} ${U}${X.minimum.toString()} ${Y.unit}`;return`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${X.origin} ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${U.prefix}"`;if(U.format==="ends_with")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${U.suffix}"`;if(U.format==="includes")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${U.includes}"`;if(U.format==="regex")return`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${U.pattern}`;return`${w[U.format]??X.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${X.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${f(X.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${X.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${X.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function y3(){return{localeError:kP()}}var vP=()=>{let $={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"\u975E\u6570\u5B57(NaN)":"\u6570\u5B57";case"object":{if(Array.isArray(X))return"\u6570\u7EC4";if(X===null)return"\u7A7A\u503C(null)";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"};return(X)=>{switch(X.code){case"invalid_type":return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${X.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${i(X.values[0])}`;return`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${X.origin??"\u503C"} ${U}${X.maximum.toString()} ${Y.unit??"\u4E2A\u5143\u7D20"}`;return`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${X.origin??"\u503C"} ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${X.origin} ${U}${X.minimum.toString()} ${Y.unit}`;return`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${X.origin} ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${U.prefix}" \u5F00\u5934`;if(U.format==="ends_with")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${U.suffix}" \u7ED3\u5C3E`;if(U.format==="includes")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${U.includes}"`;if(U.format==="regex")return`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${U.pattern}`;return`\u65E0\u6548${w[U.format]??X.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${X.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${f(X.keys,", ")}`;case"invalid_key":return`${X.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${X.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function h3(){return{localeError:vP()}}var qP=()=>{let $={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function T(X){return $[X]??null}let W=(X)=>{let U=typeof X;switch(U){case"number":return Number.isNaN(X)?"NaN":"number";case"object":{if(Array.isArray(X))return"array";if(X===null)return"null";if(Object.getPrototypeOf(X)!==Object.prototype&&X.constructor)return X.constructor.name}}return U},w={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"};return(X)=>{switch(X.code){case"invalid_type":return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${X.expected}\uFF0C\u4F46\u6536\u5230 ${W(X.input)}`;case"invalid_value":if(X.values.length===1)return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${i(X.values[0])}`;return`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${f(X.values,"|")}`;case"too_big":{let U=X.inclusive?"<=":"<",Y=T(X.origin);if(Y)return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${X.origin??"\u503C"} \u61C9\u70BA ${U}${X.maximum.toString()} ${Y.unit??"\u500B\u5143\u7D20"}`;return`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${X.origin??"\u503C"} \u61C9\u70BA ${U}${X.maximum.toString()}`}case"too_small":{let U=X.inclusive?">=":">",Y=T(X.origin);if(Y)return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${X.origin} \u61C9\u70BA ${U}${X.minimum.toString()} ${Y.unit}`;return`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${X.origin} \u61C9\u70BA ${U}${X.minimum.toString()}`}case"invalid_format":{let U=X;if(U.format==="starts_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${U.prefix}" \u958B\u982D`;if(U.format==="ends_with")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${U.suffix}" \u7D50\u5C3E`;if(U.format==="includes")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${U.includes}"`;if(U.format==="regex")return`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${U.pattern}`;return`\u7121\u6548\u7684 ${w[U.format]??X.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${X.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${X.keys.length>1?"\u5011":""}\uFF1A${f(X.keys,"\u3001")}`;case"invalid_key":return`${X.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${X.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function g3(){return{localeError:qP()}}var m3=Symbol("ZodOutput"),c3=Symbol("ZodInput");class oX{constructor(){this._map=new WeakMap,this._idmap=new Map}add($,...T){let W=T[0];if(this._map.set($,W),W&&typeof W==="object"&&"id"in W){if(this._idmap.has(W.id))throw new Error(`ID ${W.id} already exists in the registry`);this._idmap.set(W.id,$)}return this}remove($){return this._map.delete($),this}get($){let T=$._zod.parent;if(T){let W={...this.get(T)??{}};return delete W.id,{...W,...this._map.get($)}}return this._map.get($)}has($){return this._map.has($)}}function NY(){return new oX}var o1=NY();function u3($,T){return new $({type:"string",...p(T)})}function p3($,T){return new $({type:"string",coerce:!0,...p(T)})}function LY($,T){return new $({type:"string",format:"email",check:"string_format",abort:!1,...p(T)})}function lX($,T){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...p(T)})}function JY($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...p(T)})}function RY($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...p(T)})}function _Y($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...p(T)})}function kY($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...p(T)})}function vY($,T){return new $({type:"string",format:"url",check:"string_format",abort:!1,...p(T)})}function qY($,T){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...p(T)})}function PY($,T){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...p(T)})}function CY($,T){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...p(T)})}function SY($,T){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...p(T)})}function jY($,T){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...p(T)})}function IY($,T){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...p(T)})}function BY($,T){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...p(T)})}function xY($,T){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...p(T)})}function fY($,T){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...p(T)})}function bY($,T){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...p(T)})}function yY($,T){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...p(T)})}function hY($,T){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...p(T)})}function gY($,T){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...p(T)})}function mY($,T){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...p(T)})}function cY($,T){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...p(T)})}function d3($,T){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...p(T)})}function o3($,T){return new $({type:"string",format:"date",check:"string_format",...p(T)})}function l3($,T){return new $({type:"string",format:"time",check:"string_format",precision:null,...p(T)})}function r3($,T){return new $({type:"string",format:"duration",check:"string_format",...p(T)})}function n3($,T){return new $({type:"number",checks:[],...p(T)})}function i3($,T){return new $({type:"number",coerce:!0,checks:[],...p(T)})}function t3($,T){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...p(T)})}function a3($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...p(T)})}function s3($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...p(T)})}function e3($,T){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...p(T)})}function $H($,T){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...p(T)})}function TH($,T){return new $({type:"boolean",...p(T)})}function WH($,T){return new $({type:"boolean",coerce:!0,...p(T)})}function XH($,T){return new $({type:"bigint",...p(T)})}function wH($,T){return new $({type:"bigint",coerce:!0,...p(T)})}function UH($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...p(T)})}function YH($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...p(T)})}function GH($,T){return new $({type:"symbol",...p(T)})}function zH($,T){return new $({type:"undefined",...p(T)})}function HH($,T){return new $({type:"null",...p(T)})}function FH($){return new $({type:"any"})}function oW($){return new $({type:"unknown"})}function OH($,T){return new $({type:"never",...p(T)})}function QH($,T){return new $({type:"void",...p(T)})}function ZH($,T){return new $({type:"date",...p(T)})}function VH($,T){return new $({type:"date",coerce:!0,...p(T)})}function KH($,T){return new $({type:"nan",...p(T)})}function Z0($,T){return new QY({check:"less_than",...p(T),value:$,inclusive:!1})}function V1($,T){return new QY({check:"less_than",...p(T),value:$,inclusive:!0})}function V0($,T){return new ZY({check:"greater_than",...p(T),value:$,inclusive:!1})}function B6($,T){return new ZY({check:"greater_than",...p(T),value:$,inclusive:!0})}function AH($){return V0(0,$)}function EH($){return Z0(0,$)}function MH($){return V1(0,$)}function DH($){return B6(0,$)}function lT($,T){return new b5({check:"multiple_of",...p(T),value:$})}function lW($,T){return new g5({check:"max_size",...p(T),maximum:$})}function rT($,T){return new m5({check:"min_size",...p(T),minimum:$})}function rX($,T){return new c5({check:"size_equals",...p(T),size:$})}function rW($,T){return new u5({check:"max_length",...p(T),maximum:$})}function GT($,T){return new p5({check:"min_length",...p(T),minimum:$})}function nW($,T){return new d5({check:"length_equals",...p(T),length:$})}function nX($,T){return new o5({check:"string_format",format:"regex",...p(T),pattern:$})}function iX($){return new l5({check:"string_format",format:"lowercase",...p($)})}function tX($){return new r5({check:"string_format",format:"uppercase",...p($)})}function aX($,T){return new n5({check:"string_format",format:"includes",...p(T),includes:$})}function sX($,T){return new i5({check:"string_format",format:"starts_with",...p(T),prefix:$})}function eX($,T){return new t5({check:"string_format",format:"ends_with",...p(T),suffix:$})}function NH($,T,W){return new a5({check:"property",property:$,schema:T,...p(W)})}function $8($,T){return new s5({check:"mime_type",mime:$,...p(T)})}function K0($){return new e5({check:"overwrite",tx:$})}function T8($){return K0((T)=>T.normalize($))}function W8(){return K0(($)=>$.trim())}function X8(){return K0(($)=>$.toLowerCase())}function w8(){return K0(($)=>$.toUpperCase())}function U8($,T,W){return new $({type:"array",element:T,...p(W)})}function PP($,T,W){return new $({type:"union",options:T,...p(W)})}function CP($,T,W,w){return new $({type:"union",options:W,discriminator:T,...p(w)})}function SP($,T,W){return new $({type:"intersection",left:T,right:W})}function LH($,T,W,w){let X=W instanceof K$;return new $({type:"tuple",items:T,rest:X?W:null,...p(X?w:W)})}function jP($,T,W,w){return new $({type:"record",keyType:T,valueType:W,...p(w)})}function IP($,T,W,w){return new $({type:"map",keyType:T,valueType:W,...p(w)})}function BP($,T,W){return new $({type:"set",valueType:T,...p(W)})}function xP($,T,W){let w=Array.isArray(T)?Object.fromEntries(T.map((X)=>[X,X])):T;return new $({type:"enum",entries:w,...p(W)})}function fP($,T,W){return new $({type:"enum",entries:T,...p(W)})}function bP($,T,W){return new $({type:"literal",values:Array.isArray(T)?T:[T],...p(W)})}function JH($,T){return new $({type:"file",...p(T)})}function yP($,T){return new $({type:"transform",transform:T})}function hP($,T){return new $({type:"optional",innerType:T})}function gP($,T){return new $({type:"nullable",innerType:T})}function mP($,T,W){return new $({type:"default",innerType:T,get defaultValue(){return typeof W==="function"?W():W}})}function cP($,T,W){return new $({type:"nonoptional",innerType:T,...p(W)})}function uP($,T){return new $({type:"success",innerType:T})}function pP($,T,W){return new $({type:"catch",innerType:T,catchValue:typeof W==="function"?W:()=>W})}function dP($,T,W){return new $({type:"pipe",in:T,out:W})}function oP($,T){return new $({type:"readonly",innerType:T})}function lP($,T,W){return new $({type:"template_literal",parts:T,...p(W)})}function rP($,T){return new $({type:"lazy",getter:T})}function nP($,T){return new $({type:"promise",innerType:T})}function Y8($,T,W){return new $({type:"custom",check:"custom",fn:T,...p(W)})}function iP($,T,W={}){return Y8($,T,W)}function RH($,T){let{case:W,error:w,truthy:X,falsy:U}=p(T),Y=new Set(X??["true","1","yes","on","y","enabled"]),G=new Set(U??["false","0","no","off","n","disabled"]),H=$.Pipe??uX,z=$.Boolean??mX,O=new($.Unknown??YT)({type:"unknown",checks:[{_zod:{check:(Q)=>{if(typeof Q.value==="string"){let Z=Q.value;if(W!=="sensitive")Z=Z.toLowerCase();if(Y.has(Z))Q.value=!0;else if(G.has(Z))Q.value=!1;else Q.issues.push({code:"invalid_value",expected:"stringbool",values:[...Y,...G],input:Q.value,inst:O})}else Q.issues.push({code:"invalid_type",expected:"string",input:Q.value})},def:{check:"custom"},onattach:[]}}],error:w});return new H({type:"pipe",in:O,out:new z({type:"boolean",error:w}),error:w})}class _H{constructor($){this._def=$,this.def=$}implement($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=(...W)=>{let w=this._def.input?YY(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(w))throw new Error("Invalid arguments schema: not an array or tuple schema.");let X=$(...w);return this._def.output?YY(this._def.output,X,void 0,{callee:T}):X};return T}implementAsync($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=async(...W)=>{let w=this._def.input?await zY(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(w))throw new Error("Invalid arguments schema: not an array or tuple schema.");let X=await $(...w);return this._def.output?zY(this._def.output,X,void 0,{callee:T}):X};return T}input(...$){let T=this.constructor;if(Array.isArray($[0]))return new T({type:"function",input:new oT({type:"tuple",items:$[0],rest:$[1]}),output:this._def.output});return new T({type:"function",input:$[0],output:this._def.output})}output($){return new this.constructor({type:"function",input:this._def.input,output:$})}}function kH($){return new _H({type:"function",input:Array.isArray($?.input)?LH(oT,$?.input):$?.input??U8(cX,oW(YT)),output:$?.output??oW(YT)})}class uY{constructor($){this.counter=0,this.metadataRegistry=$?.metadata??o1,this.target=$?.target??"draft-2020-12",this.unrepresentable=$?.unrepresentable??"throw",this.override=$?.override??(()=>{}),this.io=$?.io??"output",this.seen=new Map}process($,T={path:[],schemaPath:[]}){var W;let w=$._zod.def,X={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},U=this.seen.get($);if(U){if(U.count++,T.schemaPath.includes($))U.cycle=T.path;return U.schema}let Y={schema:{},count:1,cycle:void 0};if(this.seen.set($,Y),$._zod.toJSONSchema)Y.schema=$._zod.toJSONSchema();let G={...T,schemaPath:[...T.schemaPath,$],path:T.path},H=$._zod.parent;if(H)Y.ref=H,this.process(H,G),this.seen.get(H).isParent=!0;else{let O=Y.schema;switch(w.type){case"string":{let Q=O;Q.type="string";let{minimum:Z,maximum:K,format:E,patterns:M,contentEncoding:L}=$._zod.bag;if(typeof Z==="number")Q.minLength=Z;if(typeof K==="number")Q.maxLength=K;if(E){if(Q.format=X[E]??E,Q.format==="")delete Q.format}if(L)Q.contentEncoding=L;if(M&&M.size>0){let R=[...M];if(R.length===1)Q.pattern=R[0].source;else if(R.length>1)Y.schema.allOf=[...R.map((_)=>({...this.target==="draft-7"?{type:"string"}:{},pattern:_.source}))]}break}case"number":{let Q=O,{minimum:Z,maximum:K,format:E,multipleOf:M,exclusiveMaximum:L,exclusiveMinimum:R}=$._zod.bag;if(typeof E==="string"&&E.includes("int"))Q.type="integer";else Q.type="number";if(typeof R==="number")Q.exclusiveMinimum=R;if(typeof Z==="number"){if(Q.minimum=Z,typeof R==="number")if(R>=Z)delete Q.minimum;else delete Q.exclusiveMinimum}if(typeof L==="number")Q.exclusiveMaximum=L;if(typeof K==="number"){if(Q.maximum=K,typeof L==="number")if(L<=K)delete Q.maximum;else delete Q.exclusiveMaximum}if(typeof M==="number")Q.multipleOf=M;break}case"boolean":{let Q=O;Q.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"undefined":{let Q=O;Q.type="null";break}case"null":{O.type="null";break}case"any":break;case"unknown":break;case"never":{O.not={};break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let Q=O,{minimum:Z,maximum:K}=$._zod.bag;if(typeof Z==="number")Q.minItems=Z;if(typeof K==="number")Q.maxItems=K;Q.type="array",Q.items=this.process(w.element,{...G,path:[...G.path,"items"]});break}case"object":{let Q=O;Q.type="object",Q.properties={};let Z=w.shape;for(let M in Z)Q.properties[M]=this.process(Z[M],{...G,path:[...G.path,"properties",M]});let K=new Set(Object.keys(Z)),E=new Set([...K].filter((M)=>{let L=w.shape[M]._zod;if(this.io==="input")return L.optin===void 0;else return L.optout===void 0}));if(E.size>0)Q.required=Array.from(E);if(w.catchall?._zod.def.type==="never")Q.additionalProperties=!1;else if(!w.catchall){if(this.io==="output")Q.additionalProperties=!1}else if(w.catchall)Q.additionalProperties=this.process(w.catchall,{...G,path:[...G.path,"additionalProperties"]});break}case"union":{let Q=O;Q.anyOf=w.options.map((Z,K)=>this.process(Z,{...G,path:[...G.path,"anyOf",K]}));break}case"intersection":{let Q=O,Z=this.process(w.left,{...G,path:[...G.path,"allOf",0]}),K=this.process(w.right,{...G,path:[...G.path,"allOf",1]}),E=(L)=>("allOf"in L)&&Object.keys(L).length===1,M=[...E(Z)?Z.allOf:[Z],...E(K)?K.allOf:[K]];Q.allOf=M;break}case"tuple":{let Q=O;Q.type="array";let Z=w.items.map((M,L)=>this.process(M,{...G,path:[...G.path,"prefixItems",L]}));if(this.target==="draft-2020-12")Q.prefixItems=Z;else Q.items=Z;if(w.rest){let M=this.process(w.rest,{...G,path:[...G.path,"items"]});if(this.target==="draft-2020-12")Q.items=M;else Q.additionalItems=M}if(w.rest)Q.items=this.process(w.rest,{...G,path:[...G.path,"items"]});let{minimum:K,maximum:E}=$._zod.bag;if(typeof K==="number")Q.minItems=K;if(typeof E==="number")Q.maxItems=E;break}case"record":{let Q=O;Q.type="object",Q.propertyNames=this.process(w.keyType,{...G,path:[...G.path,"propertyNames"]}),Q.additionalProperties=this.process(w.valueType,{...G,path:[...G.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let Q=O,Z=CX(w.entries);if(Z.every((K)=>typeof K==="number"))Q.type="number";if(Z.every((K)=>typeof K==="string"))Q.type="string";Q.enum=Z;break}case"literal":{let Q=O,Z=[];for(let K of w.values)if(K===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof K==="bigint")if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");else Z.push(Number(K));else Z.push(K);if(Z.length===0);else if(Z.length===1){let K=Z[0];Q.const=K}else Q.enum=Z;break}case"file":{let Q=O,Z={type:"string",format:"binary",contentEncoding:"binary"},{minimum:K,maximum:E,mime:M}=$._zod.bag;if(K!==void 0)Z.minLength=K;if(E!==void 0)Z.maxLength=E;if(M)if(M.length===1)Z.contentMediaType=M[0],Object.assign(Q,Z);else Q.anyOf=M.map((L)=>{return{...Z,contentMediaType:L}});else Object.assign(Q,Z);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let Q=this.process(w.innerType,G);O.anyOf=[Q,{type:"null"}];break}case"nonoptional":{this.process(w.innerType,G),Y.ref=w.innerType;break}case"success":{let Q=O;Q.type="boolean";break}case"default":{this.process(w.innerType,G),Y.ref=w.innerType,O.default=w.defaultValue;break}case"prefault":{if(this.process(w.innerType,G),Y.ref=w.innerType,this.io==="input")O._prefault=w.defaultValue;break}case"catch":{this.process(w.innerType,G),Y.ref=w.innerType;let Q;try{Q=w.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}O.default=Q;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let Q=O,Z=$._zod.pattern;if(!Z)throw new Error("Pattern not found in template literal");Q.type="string",Q.pattern=Z.source;break}case"pipe":{let Q=this.io==="input"?w.in._zod.def.type==="transform"?w.out:w.in:w.out;this.process(Q,G),Y.ref=Q;break}case"readonly":{this.process(w.innerType,G),Y.ref=w.innerType,O.readOnly=!0;break}case"promise":{this.process(w.innerType,G),Y.ref=w.innerType;break}case"optional":{this.process(w.innerType,G),Y.ref=w.innerType;break}case"lazy":{let Q=$._zod.innerType;this.process(Q,G),Y.ref=Q;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}let z=this.metadataRegistry.get($);if(z)Object.assign(Y.schema,z);if(this.io==="input"&&v4($))delete Y.schema.examples,delete Y.schema.default;if(this.io==="input"&&Y.schema._prefault)(W=Y.schema).default??(W.default=Y.schema._prefault);return delete Y.schema._prefault,this.seen.get($).schema}emit($,T){let W={cycles:T?.cycles??"ref",reused:T?.reused??"inline",external:T?.external??void 0},w=this.seen.get($);if(!w)throw new Error("Unprocessed schema. This is a bug in Zod.");let X=(z)=>{let F=this.target==="draft-2020-12"?"$defs":"definitions";if(W.external){let K=W.external.registry.get(z[0])?.id;if(K)return{ref:W.external.uri(K)};let E=z[1].defId??z[1].schema.id??`schema${this.counter++}`;return z[1].defId=E,{defId:E,ref:`${W.external.uri("__shared")}#/${F}/${E}`}}if(z[1]===w)return{ref:"#"};let Q=`${"#"}/${F}/`,Z=z[1].schema.id??`__schema${this.counter++}`;return{defId:Z,ref:Q+Z}},U=(z)=>{if(z[1].schema.$ref)return;let F=z[1],{ref:O,defId:Q}=X(z);if(F.def={...F.schema},Q)F.defId=Q;let Z=F.schema;for(let K in Z)delete Z[K];Z.$ref=O};for(let z of this.seen.entries()){let F=z[1];if($===z[0]){U(z);continue}if(W.external){let Q=W.external.registry.get(z[0])?.id;if($!==z[0]&&Q){U(z);continue}}if(this.metadataRegistry.get(z[0])?.id){U(z);continue}if(F.cycle){if(W.cycles==="throw")throw new Error(`Cycle detected: #/${F.cycle?.join("/")}/<root>
32
32
 
33
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);else if(W.cycles==="ref")Y(J);continue}if(H.count>1){if(W.reused==="ref"){Y(J);continue}}}let _=(J,H)=>{let z=this.seen.get(J),F=z.def??z.schema,Q={...F};if(z.ref===null)return;let V=z.ref;if(z.ref=null,V){_(V,H);let K=this.seen.get(V).schema;if(K.$ref&&H.target==="draft-7")F.allOf=F.allOf??[],F.allOf.push(K);else Object.assign(F,K),Object.assign(F,Q)}if(!z.isParent)this.override({zodSchema:J,jsonSchema:F})};for(let J of[...this.seen.entries()].reverse())_(J[0],{target:this.target});let w={};if(this.target==="draft-2020-12")w.$schema="https://json-schema.org/draft/2020-12/schema";else if(this.target==="draft-7")w.$schema="http://json-schema.org/draft-07/schema#";else console.warn(`Invalid target: ${this.target}`);Object.assign(w,U.def);let G=W.external?.defs??{};for(let J of this.seen.entries()){let H=J[1];if(H.def&&H.defId)G[H.defId]=H.def}if(!W.external&&Object.keys(G).length>0)if(this.target==="draft-2020-12")w.$defs=G;else w.definitions=G;try{return JSON.parse(JSON.stringify(w))}catch(J){throw new Error("Error converting schema to JSON.")}}}function cG($,T){if($ instanceof vW){let U=new CX(T),X={};for(let w of $._idmap.entries()){let[G,J]=w;U.process(J)}let Y={},_={registry:$,uri:T?.uri||((w)=>w),defs:X};for(let w of $._idmap.entries()){let[G,J]=w;Y[G]=U.emit(J,{...T,external:_})}if(Object.keys(X).length>0){let w=U.target==="draft-2020-12"?"$defs":"definitions";Y.__shared={[w]:X}}return{schemas:Y}}let W=new CX(T);return W.process($),W.emit($,T)}var RH={};var jX={};N1(jX,{time:()=>oG,duration:()=>dG,datetime:()=>uG,date:()=>pG,ZodISOTime:()=>vH,ZodISODuration:()=>qH,ZodISODateTime:()=>IH,ZodISODate:()=>kH});var IH=E("ZodISODateTime",($,T)=>{Rw.init($,T),f$.init($,T)});function uG($){return XG(IH,$)}var kH=E("ZodISODate",($,T)=>{Iw.init($,T),f$.init($,T)});function pG($){return YG(kH,$)}var vH=E("ZodISOTime",($,T)=>{kw.init($,T),f$.init($,T)});function oG($){return _G(vH,$)}var qH=E("ZodISODuration",($,T)=>{vw.init($,T),f$.init($,T)});function dG($){return wG(qH,$)}var CH=($,T)=>{AW.init($,T),$.name="ZodError",Object.defineProperties($,{format:{value:(W)=>NW($,W)},flatten:{value:(W)=>MW($,W)},addIssue:{value:(W)=>$.issues.push(W)},addIssues:{value:(W)=>$.issues.push(...W)},isEmpty:{get(){return $.issues.length===0}}})},EB=E("ZodError",CH),$T=E("ZodError",CH,{Parent:Error});var lG=rU($T),rG=nU($T),iG=aU($T),nG=sU($T);var tG={};N1(tG,{string:()=>MB,number:()=>NB,date:()=>BB,boolean:()=>LB,bigint:()=>SB});function MB($){return UG(xX,$)}function NB($){return GG(oW,$)}function LB($){return ZG(dW,$)}function SB($){return KG(lW,$)}function BB($){return vG(bX,$)}var G$=E("ZodType",($,T)=>{return T$.init($,T),$.def=T,Object.defineProperty($,"_def",{value:T}),$.check=(...W)=>{return $.clone({...T,checks:[...T.checks??[],...W.map((U)=>typeof U==="function"?{_zod:{check:U,def:{check:"custom"},onattach:[]}}:U)]})},$.clone=(W,U)=>i4($,W,U),$.brand=()=>$,$.register=(W,U)=>{return W.add($,U),$},$.parse=(W,U)=>lG($,W,U,{callee:$.parse}),$.safeParse=(W,U)=>iG($,W,U),$.parseAsync=async(W,U)=>rG($,W,U,{callee:$.parseAsync}),$.safeParseAsync=async(W,U)=>nG($,W,U),$.spa=$.safeParseAsync,$.refine=(W,U)=>$.check(KF(W,U)),$.superRefine=(W)=>$.check(EF(W)),$.overwrite=(W)=>$.check(l6(W)),$.optional=()=>hX($),$.nullable=()=>gX($),$.nullish=()=>hX(gX($)),$.nonoptional=(W)=>_F($,W),$.array=()=>E9($),$.or=(W)=>pX([$,W]),$.and=(W)=>dH($,W),$.transform=(W)=>mX($,N9(W)),$.default=(W)=>UF($,W),$.prefault=(W)=>YF($,W),$.catch=(W)=>GF($,W),$.pipe=(W)=>mX($,W),$.readonly=()=>FF($),$.describe=(W)=>{let U=$.clone();return C6.add(U,{description:W}),U},Object.defineProperty($,"description",{get(){return C6.get($)?.description},configurable:!0}),$.meta=(...W)=>{if(W.length===0)return C6.get($);let U=$.clone();return C6.add(U,W[0]),U},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$}),eG=E("_ZodString",($,T)=>{LW.init($,T),G$.init($,T);let W=$._zod.bag;$.format=W.format??null,$.minLength=W.minimum??null,$.maxLength=W.maximum??null,$.regex=(...U)=>$.check(CW(...U)),$.includes=(...U)=>$.check(bW(...U)),$.startsWith=(...U)=>$.check(fW(...U)),$.endsWith=(...U)=>$.check(yW(...U)),$.min=(...U)=>$.check(v1(...U)),$.max=(...U)=>$.check(a0(...U)),$.length=(...U)=>$.check(s0(...U)),$.nonempty=(...U)=>$.check(v1(1,...U)),$.lowercase=(U)=>$.check(jW(U)),$.uppercase=(U)=>$.check(xW(U)),$.trim=()=>$.check(mW()),$.normalize=(...U)=>$.check(gW(...U)),$.toLowerCase=()=>$.check(cW()),$.toUpperCase=()=>$.check(uW())}),xX=E("ZodString",($,T)=>{LW.init($,T),eG.init($,T),$.email=(W)=>$.check(HX($9,W)),$.url=(W)=>$.check(ZX(T9,W)),$.jwt=(W)=>$.check(PX(Z9,W)),$.emoji=(W)=>$.check(VX(W9,W)),$.guid=(W)=>$.check(qW(fX,W)),$.uuid=(W)=>$.check(FX(i6,W)),$.uuidv4=(W)=>$.check(OX(i6,W)),$.uuidv6=(W)=>$.check(DX(i6,W)),$.uuidv7=(W)=>$.check(QX(i6,W)),$.nanoid=(W)=>$.check(KX(U9,W)),$.guid=(W)=>$.check(qW(fX,W)),$.cuid=(W)=>$.check(EX(X9,W)),$.cuid2=(W)=>$.check(AX(Y9,W)),$.ulid=(W)=>$.check(MX(_9,W)),$.base64=(W)=>$.check(kX(O9,W)),$.base64url=(W)=>$.check(vX(D9,W)),$.xid=(W)=>$.check(NX(w9,W)),$.ksuid=(W)=>$.check(LX(J9,W)),$.ipv4=(W)=>$.check(SX(G9,W)),$.ipv6=(W)=>$.check(BX(z9,W)),$.cidrv4=(W)=>$.check(RX(H9,W)),$.cidrv6=(W)=>$.check(IX(F9,W)),$.e164=(W)=>$.check(qX(Q9,W)),$.datetime=(W)=>$.check(uG(W)),$.date=(W)=>$.check(pG(W)),$.time=(W)=>$.check(oG(W)),$.duration=(W)=>$.check(dG(W))});function aG($){return WG(xX,$)}var f$=E("ZodStringFormat",($,T)=>{v$.init($,T),eG.init($,T)}),$9=E("ZodEmail",($,T)=>{Vw.init($,T),f$.init($,T)});function RB($){return HX($9,$)}var fX=E("ZodGUID",($,T)=>{Qw.init($,T),f$.init($,T)});function IB($){return qW(fX,$)}var i6=E("ZodUUID",($,T)=>{Zw.init($,T),f$.init($,T)});function kB($){return FX(i6,$)}function vB($){return OX(i6,$)}function qB($){return DX(i6,$)}function PB($){return QX(i6,$)}var T9=E("ZodURL",($,T)=>{Kw.init($,T),f$.init($,T)});function CB($){return ZX(T9,$)}var W9=E("ZodEmoji",($,T)=>{Ew.init($,T),f$.init($,T)});function jB($){return VX(W9,$)}var U9=E("ZodNanoID",($,T)=>{Aw.init($,T),f$.init($,T)});function xB($){return KX(U9,$)}var X9=E("ZodCUID",($,T)=>{Mw.init($,T),f$.init($,T)});function bB($){return EX(X9,$)}var Y9=E("ZodCUID2",($,T)=>{Nw.init($,T),f$.init($,T)});function fB($){return AX(Y9,$)}var _9=E("ZodULID",($,T)=>{Lw.init($,T),f$.init($,T)});function yB($){return MX(_9,$)}var w9=E("ZodXID",($,T)=>{Sw.init($,T),f$.init($,T)});function hB($){return NX(w9,$)}var J9=E("ZodKSUID",($,T)=>{Bw.init($,T),f$.init($,T)});function gB($){return LX(J9,$)}var G9=E("ZodIPv4",($,T)=>{qw.init($,T),f$.init($,T)});function mB($){return SX(G9,$)}var z9=E("ZodIPv6",($,T)=>{Pw.init($,T),f$.init($,T)});function cB($){return BX(z9,$)}var H9=E("ZodCIDRv4",($,T)=>{Cw.init($,T),f$.init($,T)});function uB($){return RX(H9,$)}var F9=E("ZodCIDRv6",($,T)=>{jw.init($,T),f$.init($,T)});function pB($){return IX(F9,$)}var O9=E("ZodBase64",($,T)=>{bw.init($,T),f$.init($,T)});function oB($){return kX(O9,$)}var D9=E("ZodBase64URL",($,T)=>{fw.init($,T),f$.init($,T)});function dB($){return vX(D9,$)}var Q9=E("ZodE164",($,T)=>{yw.init($,T),f$.init($,T)});function lB($){return qX(Q9,$)}var Z9=E("ZodJWT",($,T)=>{hw.init($,T),f$.init($,T)});function rB($){return PX(Z9,$)}var oW=E("ZodNumber",($,T)=>{wX.init($,T),G$.init($,T),$.gt=(U,X)=>$.check(d6(U,X)),$.gte=(U,X)=>$.check(b4(U,X)),$.min=(U,X)=>$.check(b4(U,X)),$.lt=(U,X)=>$.check(o6(U,X)),$.lte=(U,X)=>$.check(Y6(U,X)),$.max=(U,X)=>$.check(Y6(U,X)),$.int=(U)=>$.check(sG(U)),$.safe=(U)=>$.check(sG(U)),$.positive=(U)=>$.check(d6(0,U)),$.nonnegative=(U)=>$.check(b4(0,U)),$.negative=(U)=>$.check(o6(0,U)),$.nonpositive=(U)=>$.check(Y6(0,U)),$.multipleOf=(U,X)=>$.check(W0(U,X)),$.step=(U,X)=>$.check(W0(U,X)),$.finite=()=>$;let W=$._zod.bag;$.minValue=Math.max(W.minimum??Number.NEGATIVE_INFINITY,W.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,$.maxValue=Math.min(W.maximum??Number.POSITIVE_INFINITY,W.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,$.isInt=(W.format??"").includes("int")||Number.isSafeInteger(W.multipleOf??0.5),$.isFinite=!0,$.format=W.format??null});function jH($){return JG(oW,$)}var TT=E("ZodNumberFormat",($,T)=>{gw.init($,T),oW.init($,T)});function sG($){return zG(TT,$)}function iB($){return HG(TT,$)}function nB($){return FG(TT,$)}function tB($){return OG(TT,$)}function aB($){return DG(TT,$)}var dW=E("ZodBoolean",($,T)=>{SW.init($,T),G$.init($,T)});function xH($){return QG(dW,$)}var lW=E("ZodBigInt",($,T)=>{JX.init($,T),G$.init($,T),$.gte=(U,X)=>$.check(b4(U,X)),$.min=(U,X)=>$.check(b4(U,X)),$.gt=(U,X)=>$.check(d6(U,X)),$.gte=(U,X)=>$.check(b4(U,X)),$.min=(U,X)=>$.check(b4(U,X)),$.lt=(U,X)=>$.check(o6(U,X)),$.lte=(U,X)=>$.check(Y6(U,X)),$.max=(U,X)=>$.check(Y6(U,X)),$.positive=(U)=>$.check(d6(BigInt(0),U)),$.negative=(U)=>$.check(o6(BigInt(0),U)),$.nonpositive=(U)=>$.check(Y6(BigInt(0),U)),$.nonnegative=(U)=>$.check(b4(BigInt(0),U)),$.multipleOf=(U,X)=>$.check(W0(U,X));let W=$._zod.bag;$.minValue=W.minimum??null,$.maxValue=W.maximum??null,$.format=W.format??null});function sB($){return VG(lW,$)}var V9=E("ZodBigIntFormat",($,T)=>{mw.init($,T),lW.init($,T)});function eB($){return EG(V9,$)}function $R($){return AG(V9,$)}var bH=E("ZodSymbol",($,T)=>{cw.init($,T),G$.init($,T)});function TR($){return MG(bH,$)}var fH=E("ZodUndefined",($,T)=>{uw.init($,T),G$.init($,T)});function WR($){return NG(fH,$)}var yH=E("ZodNull",($,T)=>{pw.init($,T),G$.init($,T)});function hH($){return LG(yH,$)}var gH=E("ZodAny",($,T)=>{ow.init($,T),G$.init($,T)});function UR(){return SG(gH)}var K9=E("ZodUnknown",($,T)=>{BW.init($,T),G$.init($,T)});function yX(){return BG(K9)}var mH=E("ZodNever",($,T)=>{dw.init($,T),G$.init($,T)});function cX($){return RG(mH,$)}var cH=E("ZodVoid",($,T)=>{lw.init($,T),G$.init($,T)});function XR($){return IG(cH,$)}var bX=E("ZodDate",($,T)=>{rw.init($,T),G$.init($,T),$.min=(U,X)=>$.check(b4(U,X)),$.max=(U,X)=>$.check(Y6(U,X));let W=$._zod.bag;$.minDate=W.minimum?new Date(W.minimum):null,$.maxDate=W.maximum?new Date(W.maximum):null});function YR($){return kG(bX,$)}var uH=E("ZodArray",($,T)=>{iw.init($,T),G$.init($,T),$.element=T.element,$.min=(W,U)=>$.check(v1(W,U)),$.nonempty=(W)=>$.check(v1(1,W)),$.max=(W,U)=>$.check(a0(W,U)),$.length=(W,U)=>$.check(s0(W,U)),$.unwrap=()=>$.element});function E9($,T){return fG(uH,$,T)}function _R($){let T=$._zod.def.shape;return sH(Object.keys(T))}var uX=E("ZodObject",($,T)=>{nw.init($,T),G$.init($,T),h.defineLazy($,"shape",()=>{return Object.fromEntries(Object.entries($._zod.def.shape))}),$.keyof=()=>tH(Object.keys($._zod.def.shape)),$.catchall=(W)=>$.clone({...$._zod.def,catchall:W}),$.passthrough=()=>$.clone({...$._zod.def,catchall:yX()}),$.loose=()=>$.clone({...$._zod.def,catchall:yX()}),$.strict=()=>$.clone({...$._zod.def,catchall:cX()}),$.strip=()=>$.clone({...$._zod.def,catchall:void 0}),$.extend=(W)=>{return h.extend($,W)},$.merge=(W)=>h.merge($,W),$.pick=(W)=>h.pick($,W),$.omit=(W)=>h.omit($,W),$.partial=(...W)=>h.partial(L9,$,W[0]),$.required=(...W)=>h.required(S9,$,W[0])});function wR($,T){let W={type:"object",get shape(){return h.assignProp(this,"shape",{...$}),this.shape},...h.normalizeParams(T)};return new uX(W)}function JR($,T){return new uX({type:"object",get shape(){return h.assignProp(this,"shape",{...$}),this.shape},catchall:cX(),...h.normalizeParams(T)})}function GR($,T){return new uX({type:"object",get shape(){return h.assignProp(this,"shape",{...$}),this.shape},catchall:yX(),...h.normalizeParams(T)})}var A9=E("ZodUnion",($,T)=>{GX.init($,T),G$.init($,T),$.options=T.options});function pX($,T){return new A9({type:"union",options:$,...h.normalizeParams(T)})}var pH=E("ZodDiscriminatedUnion",($,T)=>{A9.init($,T),tw.init($,T)});function zR($,T,W){return new pH({type:"union",options:T,discriminator:$,...h.normalizeParams(W)})}var oH=E("ZodIntersection",($,T)=>{aw.init($,T),G$.init($,T)});function dH($,T){return new oH({type:"intersection",left:$,right:T})}var lH=E("ZodTuple",($,T)=>{T0.init($,T),G$.init($,T),$.rest=(W)=>$.clone({...$._zod.def,rest:W})});function HR($,T,W){let U=T instanceof T$,X=U?W:T;return new lH({type:"tuple",items:$,rest:U?T:null,...h.normalizeParams(X)})}var M9=E("ZodRecord",($,T)=>{sw.init($,T),G$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function rH($,T,W){return new M9({type:"record",keyType:$,valueType:T,...h.normalizeParams(W)})}function FR($,T,W){return new M9({type:"record",keyType:pX([$,cX()]),valueType:T,...h.normalizeParams(W)})}var iH=E("ZodMap",($,T)=>{ew.init($,T),G$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function OR($,T,W){return new iH({type:"map",keyType:$,valueType:T,...h.normalizeParams(W)})}var nH=E("ZodSet",($,T)=>{$J.init($,T),G$.init($,T),$.min=(...W)=>$.check(U0(...W)),$.nonempty=(W)=>$.check(U0(1,W)),$.max=(...W)=>$.check(t0(...W)),$.size=(...W)=>$.check(PW(...W))});function DR($,T){return new nH({type:"set",valueType:$,...h.normalizeParams(T)})}var rW=E("ZodEnum",($,T)=>{TJ.init($,T),G$.init($,T),$.enum=T.entries,$.options=Object.values(T.entries);let W=new Set(Object.keys(T.entries));$.extract=(U,X)=>{let Y={};for(let _ of U)if(W.has(_))Y[_]=T.entries[_];else throw new Error(`Key ${_} not found in enum`);return new rW({...T,checks:[],...h.normalizeParams(X),entries:Y})},$.exclude=(U,X)=>{let Y={...T.entries};for(let _ of U)if(W.has(_))delete Y[_];else throw new Error(`Key ${_} not found in enum`);return new rW({...T,checks:[],...h.normalizeParams(X),entries:Y})}});function tH($,T){let W=Array.isArray($)?Object.fromEntries($.map((U)=>[U,U])):$;return new rW({type:"enum",entries:W,...h.normalizeParams(T)})}function QR($,T){return new rW({type:"enum",entries:$,...h.normalizeParams(T)})}var aH=E("ZodLiteral",($,T)=>{WJ.init($,T),G$.init($,T),$.values=new Set(T.values),Object.defineProperty($,"value",{get(){if(T.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return T.values[0]}})});function sH($,T){return new aH({type:"literal",values:Array.isArray($)?$:[$],...h.normalizeParams(T)})}var eH=E("ZodFile",($,T)=>{UJ.init($,T),G$.init($,T),$.min=(W,U)=>$.check(U0(W,U)),$.max=(W,U)=>$.check(t0(W,U)),$.mime=(W,U)=>$.check(hW(W,U))});function ZR($){return hG(eH,$)}var $F=E("ZodTransform",($,T)=>{XJ.init($,T),G$.init($,T),$._zod.parse=(W,U)=>{W.addIssue=(Y)=>{if(typeof Y==="string")W.issues.push(h.issue(Y,W.value,T));else{let _=Y;if(_.fatal)_.continue=!1;_.code??(_.code="custom"),_.input??(_.input=W.value),_.inst??(_.inst=$),_.continue??(_.continue=!0),W.issues.push(h.issue(_))}};let X=T.transform(W.value,W);if(X instanceof Promise)return X.then((Y)=>{return W.value=Y,W});return W.value=X,W}});function N9($){return new $F({type:"transform",transform:$})}var L9=E("ZodOptional",($,T)=>{YJ.init($,T),G$.init($,T),$.unwrap=()=>$._zod.def.innerType});function hX($){return new L9({type:"optional",innerType:$})}var TF=E("ZodNullable",($,T)=>{_J.init($,T),G$.init($,T),$.unwrap=()=>$._zod.def.innerType});function gX($){return new TF({type:"nullable",innerType:$})}function VR($){return hX(gX($))}var WF=E("ZodDefault",($,T)=>{wJ.init($,T),G$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function UF($,T){return new WF({type:"default",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var XF=E("ZodPrefault",($,T)=>{JJ.init($,T),G$.init($,T),$.unwrap=()=>$._zod.def.innerType});function YF($,T){return new XF({type:"prefault",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var S9=E("ZodNonOptional",($,T)=>{GJ.init($,T),G$.init($,T),$.unwrap=()=>$._zod.def.innerType});function _F($,T){return new S9({type:"nonoptional",innerType:$,...h.normalizeParams(T)})}var wF=E("ZodSuccess",($,T)=>{zJ.init($,T),G$.init($,T),$.unwrap=()=>$._zod.def.innerType});function KR($){return new wF({type:"success",innerType:$})}var JF=E("ZodCatch",($,T)=>{HJ.init($,T),G$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function GF($,T){return new JF({type:"catch",innerType:$,catchValue:typeof T==="function"?T:()=>T})}var zF=E("ZodNaN",($,T)=>{FJ.init($,T),G$.init($,T)});function ER($){return qG(zF,$)}var B9=E("ZodPipe",($,T)=>{RW.init($,T),G$.init($,T),$.in=T.in,$.out=T.out});function mX($,T){return new B9({type:"pipe",in:$,out:T})}var HF=E("ZodReadonly",($,T)=>{OJ.init($,T),G$.init($,T)});function FF($){return new HF({type:"readonly",innerType:$})}var OF=E("ZodTemplateLiteral",($,T)=>{DJ.init($,T),G$.init($,T)});function AR($,T){return new OF({type:"template_literal",parts:$,...h.normalizeParams(T)})}var DF=E("ZodLazy",($,T)=>{ZJ.init($,T),G$.init($,T),$.unwrap=()=>$._zod.def.getter()});function QF($){return new DF({type:"lazy",getter:$})}var ZF=E("ZodPromise",($,T)=>{QJ.init($,T),G$.init($,T),$.unwrap=()=>$._zod.def.innerType});function MR($){return new ZF({type:"promise",innerType:$})}var oX=E("ZodCustom",($,T)=>{VJ.init($,T),G$.init($,T)});function VF($,T){let W=new u$({check:"custom",...h.normalizeParams(T)});return W._zod.check=$,W}function NR($,T){return pW(oX,$??(()=>!0),T)}function KF($,T={}){return pW(oX,$,T)}function EF($,T){let W=VF((U)=>{return U.addIssue=(X)=>{if(typeof X==="string")U.issues.push(h.issue(X,U.value,W._zod.def));else{let Y=X;if(Y.fatal)Y.continue=!1;Y.code??(Y.code="custom"),Y.input??(Y.input=U.value),Y.inst??(Y.inst=W),Y.continue??(Y.continue=!W._zod.def.abort),U.issues.push(h.issue(Y))}},$(U.value,U)},T);return W}function LR($,T={error:`Input not instance of ${$.name}`}){let W=new oX({type:"custom",check:"custom",fn:(U)=>U instanceof $,abort:!0,...h.normalizeParams(T)});return W._zod.bag.Class=$,W}var SR=gG.bind(null,{Pipe:B9,Boolean:dW,Unknown:K9});function BR($){let T=QF(()=>{return pX([aG($),jH(),xH(),hH(),E9(T),rH(aG(),T)])});return T}function RR($,T){return mX(N9($),T)}var IR={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"},kR=Object.freeze({status:"aborted"}),vR=kR;function qR($){t$({customError:$})}function PR(){return t$().customError}t$(IW());function AF($,T){return function W({schema:U,fallback:X,toJsonSchema:Y=dX.toJSONSchema}){let _=Y(U);return async function w(G,J=3){let H,z=[];while(z.length<J){H=await $(G,_,X,z);let F=await U["~standard"].validate(H);if("value"in F)return F.value;T?.warn(`safegen failed to generate well-formed data.
33
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);else if(W.cycles==="ref")U(z);continue}if(F.count>1){if(W.reused==="ref"){U(z);continue}}}let Y=(z,F)=>{let O=this.seen.get(z),Q=O.def??O.schema,Z={...Q};if(O.ref===null)return;let K=O.ref;if(O.ref=null,K){Y(K,F);let E=this.seen.get(K).schema;if(E.$ref&&F.target==="draft-7")Q.allOf=Q.allOf??[],Q.allOf.push(E);else Object.assign(Q,E),Object.assign(Q,Z)}if(!O.isParent)this.override({zodSchema:z,jsonSchema:Q})};for(let z of[...this.seen.entries()].reverse())Y(z[0],{target:this.target});let G={};if(this.target==="draft-2020-12")G.$schema="https://json-schema.org/draft/2020-12/schema";else if(this.target==="draft-7")G.$schema="http://json-schema.org/draft-07/schema#";else console.warn(`Invalid target: ${this.target}`);Object.assign(G,w.def);let H=W.external?.defs??{};for(let z of this.seen.entries()){let F=z[1];if(F.def&&F.defId)H[F.defId]=F.def}if(!W.external&&Object.keys(H).length>0)if(this.target==="draft-2020-12")G.$defs=H;else G.definitions=H;try{return JSON.parse(JSON.stringify(G))}catch(z){throw new Error("Error converting schema to JSON.")}}}function vH($,T){if($ instanceof oX){let w=new uY(T),X={};for(let G of $._idmap.entries()){let[H,z]=G;w.process(z)}let U={},Y={registry:$,uri:T?.uri||((G)=>G),defs:X};for(let G of $._idmap.entries()){let[H,z]=G;U[H]=w.emit(z,{...T,external:Y})}if(Object.keys(X).length>0){let G=w.target==="draft-2020-12"?"$defs":"definitions";U.__shared={[G]:X}}return{schemas:U}}let W=new uY(T);return W.process($),W.emit($,T)}function v4($,T){let W=T??{seen:new Set};if(W.seen.has($))return!1;W.seen.add($);let X=$._zod.def;switch(X.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return v4(X.element,W);case"object":{for(let U in X.shape)if(v4(X.shape[U],W))return!0;return!1}case"union":{for(let U of X.options)if(v4(U,W))return!0;return!1}case"intersection":return v4(X.left,W)||v4(X.right,W);case"tuple":{for(let U of X.items)if(v4(U,W))return!0;if(X.rest&&v4(X.rest,W))return!0;return!1}case"record":return v4(X.keyType,W)||v4(X.valueType,W);case"map":return v4(X.keyType,W)||v4(X.valueType,W);case"set":return v4(X.valueType,W);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return v4(X.innerType,W);case"lazy":return v4(X.getter(),W);case"default":return v4(X.innerType,W);case"prefault":return v4(X.innerType,W);case"custom":return!1;case"transform":return!0;case"pipe":return v4(X.in,W)||v4(X.out,W);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${X.type}`)}var zK={};var rY={};e0(rY,{time:()=>CH,duration:()=>SH,datetime:()=>qH,date:()=>PH,ZodISOTime:()=>oY,ZodISODuration:()=>lY,ZodISODateTime:()=>pY,ZodISODate:()=>dY});var pY=k("ZodISODateTime",($,T)=>{Z7.init($,T),W4.init($,T)});function qH($){return d3(pY,$)}var dY=k("ZodISODate",($,T)=>{V7.init($,T),W4.init($,T)});function PH($){return o3(dY,$)}var oY=k("ZodISOTime",($,T)=>{K7.init($,T),W4.init($,T)});function CH($){return l3(oY,$)}var lY=k("ZodISODuration",($,T)=>{A7.init($,T),W4.init($,T)});function SH($){return r3(lY,$)}var FK=($,T)=>{bX.init($,T),$.name="ZodError",Object.defineProperties($,{format:{value:(W)=>hX($,W)},flatten:{value:(W)=>yX($,W)},addIssue:{value:(W)=>$.issues.push(W)},addIssues:{value:(W)=>$.issues.push(...W)},isEmpty:{get(){return $.issues.length===0}}})},aP=k("ZodError",FK),iW=k("ZodError",FK,{Parent:Error});var jH=UY(iW),IH=GY(iW),BH=HY(iW),xH=FY(iW);var k$=k("ZodType",($,T)=>{return K$.init($,T),$.def=T,Object.defineProperty($,"_def",{value:T}),$.check=(...W)=>{return $.clone({...T,checks:[...T.checks??[],...W.map((w)=>typeof w==="function"?{_zod:{check:w,def:{check:"custom"},onattach:[]}}:w)]})},$.clone=(W,w)=>a6($,W,w),$.brand=()=>$,$.register=(W,w)=>{return W.add($,w),$},$.parse=(W,w)=>jH($,W,w,{callee:$.parse}),$.safeParse=(W,w)=>BH($,W,w),$.parseAsync=async(W,w)=>IH($,W,w,{callee:$.parseAsync}),$.safeParseAsync=async(W,w)=>xH($,W,w),$.spa=$.safeParseAsync,$.refine=(W,w)=>$.check(tK(W,w)),$.superRefine=(W)=>$.check(aK(W)),$.overwrite=(W)=>$.check(K0(W)),$.optional=()=>tY($),$.nullable=()=>aY($),$.nullish=()=>tY(aY($)),$.nonoptional=(W)=>hK($,W),$.array=()=>XF($),$.or=(W)=>XG([$,W]),$.and=(W)=>RK($,W),$.transform=(W)=>sY($,YF(W)),$.default=(W)=>fK($,W),$.prefault=(W)=>yK($,W),$.catch=(W)=>cK($,W),$.pipe=(W)=>sY($,W),$.readonly=()=>dK($),$.describe=(W)=>{let w=$.clone();return o1.add(w,{description:W}),w},Object.defineProperty($,"description",{get(){return o1.get($)?.description},configurable:!0}),$.meta=(...W)=>{if(W.length===0)return o1.get($);let w=$.clone();return o1.add(w,W[0]),w},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$}),yH=k("_ZodString",($,T)=>{gX.init($,T),k$.init($,T);let W=$._zod.bag;$.format=W.format??null,$.minLength=W.minimum??null,$.maxLength=W.maximum??null,$.regex=(...w)=>$.check(nX(...w)),$.includes=(...w)=>$.check(aX(...w)),$.startsWith=(...w)=>$.check(sX(...w)),$.endsWith=(...w)=>$.check(eX(...w)),$.min=(...w)=>$.check(GT(...w)),$.max=(...w)=>$.check(rW(...w)),$.length=(...w)=>$.check(nW(...w)),$.nonempty=(...w)=>$.check(GT(1,...w)),$.lowercase=(w)=>$.check(iX(w)),$.uppercase=(w)=>$.check(tX(w)),$.trim=()=>$.check(W8()),$.normalize=(...w)=>$.check(T8(...w)),$.toLowerCase=()=>$.check(X8()),$.toUpperCase=()=>$.check(w8())}),eY=k("ZodString",($,T)=>{gX.init($,T),yH.init($,T),$.email=(W)=>$.check(LY(hH,W)),$.url=(W)=>$.check(vY(gH,W)),$.jwt=(W)=>$.check(cY($F,W)),$.emoji=(W)=>$.check(qY(mH,W)),$.guid=(W)=>$.check(lX(nY,W)),$.uuid=(W)=>$.check(JY(E0,W)),$.uuidv4=(W)=>$.check(RY(E0,W)),$.uuidv6=(W)=>$.check(_Y(E0,W)),$.uuidv7=(W)=>$.check(kY(E0,W)),$.nanoid=(W)=>$.check(PY(cH,W)),$.guid=(W)=>$.check(lX(nY,W)),$.cuid=(W)=>$.check(CY(uH,W)),$.cuid2=(W)=>$.check(SY(pH,W)),$.ulid=(W)=>$.check(jY(dH,W)),$.base64=(W)=>$.check(hY(aH,W)),$.base64url=(W)=>$.check(gY(sH,W)),$.xid=(W)=>$.check(IY(oH,W)),$.ksuid=(W)=>$.check(BY(lH,W)),$.ipv4=(W)=>$.check(xY(rH,W)),$.ipv6=(W)=>$.check(fY(nH,W)),$.cidrv4=(W)=>$.check(bY(iH,W)),$.cidrv6=(W)=>$.check(yY(tH,W)),$.e164=(W)=>$.check(mY(eH,W)),$.datetime=(W)=>$.check(qH(W)),$.date=(W)=>$.check(PH(W)),$.time=(W)=>$.check(CH(W)),$.duration=(W)=>$.check(SH(W))});function fH($){return u3(eY,$)}var W4=k("ZodStringFormat",($,T)=>{r$.init($,T),yH.init($,T)}),hH=k("ZodEmail",($,T)=>{w7.init($,T),W4.init($,T)});function eP($){return LY(hH,$)}var nY=k("ZodGUID",($,T)=>{W7.init($,T),W4.init($,T)});function $C($){return lX(nY,$)}var E0=k("ZodUUID",($,T)=>{X7.init($,T),W4.init($,T)});function TC($){return JY(E0,$)}function WC($){return RY(E0,$)}function XC($){return _Y(E0,$)}function wC($){return kY(E0,$)}var gH=k("ZodURL",($,T)=>{U7.init($,T),W4.init($,T)});function UC($){return vY(gH,$)}var mH=k("ZodEmoji",($,T)=>{Y7.init($,T),W4.init($,T)});function YC($){return qY(mH,$)}var cH=k("ZodNanoID",($,T)=>{G7.init($,T),W4.init($,T)});function GC($){return PY(cH,$)}var uH=k("ZodCUID",($,T)=>{z7.init($,T),W4.init($,T)});function zC($){return CY(uH,$)}var pH=k("ZodCUID2",($,T)=>{H7.init($,T),W4.init($,T)});function HC($){return SY(pH,$)}var dH=k("ZodULID",($,T)=>{F7.init($,T),W4.init($,T)});function FC($){return jY(dH,$)}var oH=k("ZodXID",($,T)=>{O7.init($,T),W4.init($,T)});function OC($){return IY(oH,$)}var lH=k("ZodKSUID",($,T)=>{Q7.init($,T),W4.init($,T)});function QC($){return BY(lH,$)}var rH=k("ZodIPv4",($,T)=>{E7.init($,T),W4.init($,T)});function ZC($){return xY(rH,$)}var nH=k("ZodIPv6",($,T)=>{M7.init($,T),W4.init($,T)});function VC($){return fY(nH,$)}var iH=k("ZodCIDRv4",($,T)=>{D7.init($,T),W4.init($,T)});function KC($){return bY(iH,$)}var tH=k("ZodCIDRv6",($,T)=>{N7.init($,T),W4.init($,T)});function AC($){return yY(tH,$)}var aH=k("ZodBase64",($,T)=>{J7.init($,T),W4.init($,T)});function EC($){return hY(aH,$)}var sH=k("ZodBase64URL",($,T)=>{R7.init($,T),W4.init($,T)});function MC($){return gY(sH,$)}var eH=k("ZodE164",($,T)=>{_7.init($,T),W4.init($,T)});function DC($){return mY(eH,$)}var $F=k("ZodJWT",($,T)=>{k7.init($,T),W4.init($,T)});function NC($){return cY($F,$)}var z8=k("ZodNumber",($,T)=>{EY.init($,T),k$.init($,T),$.gt=(w,X)=>$.check(V0(w,X)),$.gte=(w,X)=>$.check(B6(w,X)),$.min=(w,X)=>$.check(B6(w,X)),$.lt=(w,X)=>$.check(Z0(w,X)),$.lte=(w,X)=>$.check(V1(w,X)),$.max=(w,X)=>$.check(V1(w,X)),$.int=(w)=>$.check(bH(w)),$.safe=(w)=>$.check(bH(w)),$.positive=(w)=>$.check(V0(0,w)),$.nonnegative=(w)=>$.check(B6(0,w)),$.negative=(w)=>$.check(Z0(0,w)),$.nonpositive=(w)=>$.check(V1(0,w)),$.multipleOf=(w,X)=>$.check(lT(w,X)),$.step=(w,X)=>$.check(lT(w,X)),$.finite=()=>$;let W=$._zod.bag;$.minValue=Math.max(W.minimum??Number.NEGATIVE_INFINITY,W.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,$.maxValue=Math.min(W.maximum??Number.POSITIVE_INFINITY,W.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,$.isInt=(W.format??"").includes("int")||Number.isSafeInteger(W.multipleOf??0.5),$.isFinite=!0,$.format=W.format??null});function OK($){return n3(z8,$)}var tW=k("ZodNumberFormat",($,T)=>{v7.init($,T),z8.init($,T)});function bH($){return t3(tW,$)}function LC($){return a3(tW,$)}function JC($){return s3(tW,$)}function RC($){return e3(tW,$)}function _C($){return $H(tW,$)}var H8=k("ZodBoolean",($,T)=>{mX.init($,T),k$.init($,T)});function QK($){return TH(H8,$)}var F8=k("ZodBigInt",($,T)=>{MY.init($,T),k$.init($,T),$.gte=(w,X)=>$.check(B6(w,X)),$.min=(w,X)=>$.check(B6(w,X)),$.gt=(w,X)=>$.check(V0(w,X)),$.gte=(w,X)=>$.check(B6(w,X)),$.min=(w,X)=>$.check(B6(w,X)),$.lt=(w,X)=>$.check(Z0(w,X)),$.lte=(w,X)=>$.check(V1(w,X)),$.max=(w,X)=>$.check(V1(w,X)),$.positive=(w)=>$.check(V0(BigInt(0),w)),$.negative=(w)=>$.check(Z0(BigInt(0),w)),$.nonpositive=(w)=>$.check(V1(BigInt(0),w)),$.nonnegative=(w)=>$.check(B6(BigInt(0),w)),$.multipleOf=(w,X)=>$.check(lT(w,X));let W=$._zod.bag;$.minValue=W.minimum??null,$.maxValue=W.maximum??null,$.format=W.format??null});function kC($){return XH(F8,$)}var TF=k("ZodBigIntFormat",($,T)=>{q7.init($,T),F8.init($,T)});function vC($){return UH(TF,$)}function qC($){return YH(TF,$)}var ZK=k("ZodSymbol",($,T)=>{P7.init($,T),k$.init($,T)});function PC($){return GH(ZK,$)}var VK=k("ZodUndefined",($,T)=>{C7.init($,T),k$.init($,T)});function CC($){return zH(VK,$)}var KK=k("ZodNull",($,T)=>{S7.init($,T),k$.init($,T)});function AK($){return HH(KK,$)}var EK=k("ZodAny",($,T)=>{j7.init($,T),k$.init($,T)});function SC(){return FH(EK)}var WF=k("ZodUnknown",($,T)=>{YT.init($,T),k$.init($,T)});function iY(){return oW(WF)}var MK=k("ZodNever",($,T)=>{I7.init($,T),k$.init($,T)});function $G($){return OH(MK,$)}var DK=k("ZodVoid",($,T)=>{B7.init($,T),k$.init($,T)});function jC($){return QH(DK,$)}var TG=k("ZodDate",($,T)=>{x7.init($,T),k$.init($,T),$.min=(w,X)=>$.check(B6(w,X)),$.max=(w,X)=>$.check(V1(w,X));let W=$._zod.bag;$.minDate=W.minimum?new Date(W.minimum):null,$.maxDate=W.maximum?new Date(W.maximum):null});function IC($){return ZH(TG,$)}var NK=k("ZodArray",($,T)=>{cX.init($,T),k$.init($,T),$.element=T.element,$.min=(W,w)=>$.check(GT(W,w)),$.nonempty=(W)=>$.check(GT(1,W)),$.max=(W,w)=>$.check(rW(W,w)),$.length=(W,w)=>$.check(nW(W,w)),$.unwrap=()=>$.element});function XF($,T){return U8(NK,$,T)}function BC($){let T=$._zod.def.shape;return SK(Object.keys(T))}var WG=k("ZodObject",($,T)=>{f7.init($,T),k$.init($,T),l.defineLazy($,"shape",()=>{return Object.fromEntries(Object.entries($._zod.def.shape))}),$.keyof=()=>PK(Object.keys($._zod.def.shape)),$.catchall=(W)=>$.clone({...$._zod.def,catchall:W}),$.passthrough=()=>$.clone({...$._zod.def,catchall:iY()}),$.loose=()=>$.clone({...$._zod.def,catchall:iY()}),$.strict=()=>$.clone({...$._zod.def,catchall:$G()}),$.strip=()=>$.clone({...$._zod.def,catchall:void 0}),$.extend=(W)=>{return l.extend($,W)},$.merge=(W)=>l.merge($,W),$.pick=(W)=>l.pick($,W),$.omit=(W)=>l.omit($,W),$.partial=(...W)=>l.partial(GF,$,W[0]),$.required=(...W)=>l.required(zF,$,W[0])});function xC($,T){let W={type:"object",get shape(){return l.assignProp(this,"shape",{...$}),this.shape},...l.normalizeParams(T)};return new WG(W)}function fC($,T){return new WG({type:"object",get shape(){return l.assignProp(this,"shape",{...$}),this.shape},catchall:$G(),...l.normalizeParams(T)})}function bC($,T){return new WG({type:"object",get shape(){return l.assignProp(this,"shape",{...$}),this.shape},catchall:iY(),...l.normalizeParams(T)})}var wF=k("ZodUnion",($,T)=>{DY.init($,T),k$.init($,T),$.options=T.options});function XG($,T){return new wF({type:"union",options:$,...l.normalizeParams(T)})}var LK=k("ZodDiscriminatedUnion",($,T)=>{wF.init($,T),b7.init($,T)});function yC($,T,W){return new LK({type:"union",options:T,discriminator:$,...l.normalizeParams(W)})}var JK=k("ZodIntersection",($,T)=>{y7.init($,T),k$.init($,T)});function RK($,T){return new JK({type:"intersection",left:$,right:T})}var _K=k("ZodTuple",($,T)=>{oT.init($,T),k$.init($,T),$.rest=(W)=>$.clone({...$._zod.def,rest:W})});function hC($,T,W){let w=T instanceof K$,X=w?W:T;return new _K({type:"tuple",items:$,rest:w?T:null,...l.normalizeParams(X)})}var UF=k("ZodRecord",($,T)=>{h7.init($,T),k$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function kK($,T,W){return new UF({type:"record",keyType:$,valueType:T,...l.normalizeParams(W)})}function gC($,T,W){return new UF({type:"record",keyType:XG([$,$G()]),valueType:T,...l.normalizeParams(W)})}var vK=k("ZodMap",($,T)=>{g7.init($,T),k$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function mC($,T,W){return new vK({type:"map",keyType:$,valueType:T,...l.normalizeParams(W)})}var qK=k("ZodSet",($,T)=>{m7.init($,T),k$.init($,T),$.min=(...W)=>$.check(rT(...W)),$.nonempty=(W)=>$.check(rT(1,W)),$.max=(...W)=>$.check(lW(...W)),$.size=(...W)=>$.check(rX(...W))});function cC($,T){return new qK({type:"set",valueType:$,...l.normalizeParams(T)})}var G8=k("ZodEnum",($,T)=>{c7.init($,T),k$.init($,T),$.enum=T.entries,$.options=Object.values(T.entries);let W=new Set(Object.keys(T.entries));$.extract=(w,X)=>{let U={};for(let Y of w)if(W.has(Y))U[Y]=T.entries[Y];else throw new Error(`Key ${Y} not found in enum`);return new G8({...T,checks:[],...l.normalizeParams(X),entries:U})},$.exclude=(w,X)=>{let U={...T.entries};for(let Y of w)if(W.has(Y))delete U[Y];else throw new Error(`Key ${Y} not found in enum`);return new G8({...T,checks:[],...l.normalizeParams(X),entries:U})}});function PK($,T){let W=Array.isArray($)?Object.fromEntries($.map((w)=>[w,w])):$;return new G8({type:"enum",entries:W,...l.normalizeParams(T)})}function uC($,T){return new G8({type:"enum",entries:$,...l.normalizeParams(T)})}var CK=k("ZodLiteral",($,T)=>{u7.init($,T),k$.init($,T),$.values=new Set(T.values),Object.defineProperty($,"value",{get(){if(T.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return T.values[0]}})});function SK($,T){return new CK({type:"literal",values:Array.isArray($)?$:[$],...l.normalizeParams(T)})}var jK=k("ZodFile",($,T)=>{p7.init($,T),k$.init($,T),$.min=(W,w)=>$.check(rT(W,w)),$.max=(W,w)=>$.check(lW(W,w)),$.mime=(W,w)=>$.check($8(Array.isArray(W)?W:[W],w))});function pC($){return JH(jK,$)}var IK=k("ZodTransform",($,T)=>{d7.init($,T),k$.init($,T),$._zod.parse=(W,w)=>{W.addIssue=(U)=>{if(typeof U==="string")W.issues.push(l.issue(U,W.value,T));else{let Y=U;if(Y.fatal)Y.continue=!1;Y.code??(Y.code="custom"),Y.input??(Y.input=W.value),Y.inst??(Y.inst=$),Y.continue??(Y.continue=!0),W.issues.push(l.issue(Y))}};let X=T.transform(W.value,W);if(X instanceof Promise)return X.then((U)=>{return W.value=U,W});return W.value=X,W}});function YF($){return new IK({type:"transform",transform:$})}var GF=k("ZodOptional",($,T)=>{o7.init($,T),k$.init($,T),$.unwrap=()=>$._zod.def.innerType});function tY($){return new GF({type:"optional",innerType:$})}var BK=k("ZodNullable",($,T)=>{l7.init($,T),k$.init($,T),$.unwrap=()=>$._zod.def.innerType});function aY($){return new BK({type:"nullable",innerType:$})}function dC($){return tY(aY($))}var xK=k("ZodDefault",($,T)=>{r7.init($,T),k$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function fK($,T){return new xK({type:"default",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var bK=k("ZodPrefault",($,T)=>{n7.init($,T),k$.init($,T),$.unwrap=()=>$._zod.def.innerType});function yK($,T){return new bK({type:"prefault",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var zF=k("ZodNonOptional",($,T)=>{i7.init($,T),k$.init($,T),$.unwrap=()=>$._zod.def.innerType});function hK($,T){return new zF({type:"nonoptional",innerType:$,...l.normalizeParams(T)})}var gK=k("ZodSuccess",($,T)=>{t7.init($,T),k$.init($,T),$.unwrap=()=>$._zod.def.innerType});function oC($){return new gK({type:"success",innerType:$})}var mK=k("ZodCatch",($,T)=>{a7.init($,T),k$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function cK($,T){return new mK({type:"catch",innerType:$,catchValue:typeof T==="function"?T:()=>T})}var uK=k("ZodNaN",($,T)=>{s7.init($,T),k$.init($,T)});function lC($){return KH(uK,$)}var HF=k("ZodPipe",($,T)=>{uX.init($,T),k$.init($,T),$.in=T.in,$.out=T.out});function sY($,T){return new HF({type:"pipe",in:$,out:T})}var pK=k("ZodReadonly",($,T)=>{e7.init($,T),k$.init($,T)});function dK($){return new pK({type:"readonly",innerType:$})}var oK=k("ZodTemplateLiteral",($,T)=>{$3.init($,T),k$.init($,T)});function rC($,T){return new oK({type:"template_literal",parts:$,...l.normalizeParams(T)})}var lK=k("ZodLazy",($,T)=>{W3.init($,T),k$.init($,T),$.unwrap=()=>$._zod.def.getter()});function rK($){return new lK({type:"lazy",getter:$})}var nK=k("ZodPromise",($,T)=>{T3.init($,T),k$.init($,T),$.unwrap=()=>$._zod.def.innerType});function nC($){return new nK({type:"promise",innerType:$})}var wG=k("ZodCustom",($,T)=>{X3.init($,T),k$.init($,T)});function iK($,T){let W=new z4({check:"custom",...l.normalizeParams(T)});return W._zod.check=$,W}function iC($,T){return Y8(wG,$??(()=>!0),T)}function tK($,T={}){return Y8(wG,$,T)}function aK($,T){let W=iK((w)=>{return w.addIssue=(X)=>{if(typeof X==="string")w.issues.push(l.issue(X,w.value,W._zod.def));else{let U=X;if(U.fatal)U.continue=!1;U.code??(U.code="custom"),U.input??(U.input=w.value),U.inst??(U.inst=W),U.continue??(U.continue=!W._zod.def.abort),w.issues.push(l.issue(U))}},$(w.value,w)},T);return W}function tC($,T={error:`Input not instance of ${$.name}`}){let W=new wG({type:"custom",check:"custom",fn:(w)=>w instanceof $,abort:!0,...l.normalizeParams(T)});return W._zod.bag.Class=$,W}var aC=(...$)=>RH({Pipe:HF,Boolean:H8,Unknown:WF},...$);function sC($){let T=rK(()=>{return XG([fH($),OK(),QK(),AK(),XF(T),kK(fH(),T)])});return T}function eC($,T){return sY(YF($),T)}var $S={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"},TS=Object.freeze({status:"aborted"}),WS=TS;function XS($){N4({customError:$})}function wS(){return N4().customError}var FF={};e0(FF,{string:()=>US,number:()=>YS,date:()=>HS,boolean:()=>GS,bigint:()=>zS});function US($){return p3(eY,$)}function YS($){return i3(z8,$)}function GS($){return WH(H8,$)}function zS($){return wH(F8,$)}function HS($){return VH(TG,$)}N4(pX());function sK($,T){return function W({schema:w,fallback:X,toJsonSchema:U=UG.toJSONSchema}){let Y=U(w);return async function G(H,z=3){let F,O=[];while(O.length<z){F=await $(H,Y,X,O);let Q=await w["~standard"].validate(F);if("value"in Q)return Q.value;T?.warn(`safegen failed to generate well-formed data.
34
34
  `,`Here's what was returned last time:
35
- `,JSON.stringify(H,null,"\t"),`
35
+ `,JSON.stringify(F,null,"\t"),`
36
36
  `,`Here are the issues returned from our validation:
37
- `,JSON.stringify(F.issues,null,"\t")),z.push({response:H,error:F})}return T?.error(`safegen was unable to generate well-formed data after ${J} failed attempts.`),X}}}function MF($){return["Please generate a response in JSON that conforms to the following JSON Schema:",JSON.stringify($,null,2)].join(`
38
- `)}var qF=RM(SF(),1);import*as f4 from"fs";import*as WT from"path";import{resolve as yR}from"path";import{createHash as hR}from"crypto";import{copyFile as gR}from"fs/promises";import{existsSync as R9,mkdirSync as BF,readFileSync as bR,readdirSync as RF,rmSync as IF,statSync as kF,writeFileSync as fR}from"fs";import{resolve as I9}from"path";var vF=class{rootDir;get initialized(){return R9(this.rootDir)}initialize(){if(!this.initialized)BF(this.rootDir,{recursive:!0})}constructor($){if(this.rootDir=$.path,$.eagerInit)this.initialize()}getItem($){let T=I9(this.rootDir,$);if(R9(T))return bR(T,"utf-8");return null}setItem($,T){this.initialize();let W=I9(this.rootDir,$);fR(W,T)}removeItem($){let T=I9(this.rootDir,$);if(R9(T))this.initialize(),IF(T)}key($){return RF(this.rootDir).sort((U,X)=>{let Y=kF(U);return kF(X).ctimeMs-Y.ctimeMs})[$]??null}clear(){IF(this.rootDir,{recursive:!0}),BF(this.rootDir,{recursive:!0})}get length(){return RF(this.rootDir).length}};var PF=/[^a-zA-Z0-9\-._]/g;function aW($,T=64){if(T%2===1)T+=1;let W=$.replace(PF,"-");if(W.length<=T)return W;let U=hR("sha256").update($).digest("base64").slice(0,8).replaceAll("/","_"),X=W;if(X.length>T){let Y=X.slice(0,T/2),_=X.slice(-T/2);X=Y+"_"+_}return X+"+"+U}var mR=qF.default("varmint"),tW=aW(process.cwd(),150),k9=yR(mR,tW),U4="_-$-_-$-_",CF=`file${U4}`,jF=`list${U4}`,xF=`root${U4}`,cR=`unmatched${U4}`,q$={storage:new vF({path:k9,eagerInit:!1}),startGlobalTracking(){if(console.log(`\uD83D\uDC3F\uFE0F Starting global tracking of varmint files using project identifier "${tW}"`),q$.storage.initialized)console.error(`\uD83D\uDCA5 The global cache for the project "${tW}" was found already initialized. Clearing it and starting fresh.`),q$.storage.clear();q$.storage.initialize()},async prepareUploads($){console.log(`\uD83D\uDC3F\uFE0F Moving unmatched inputs to /tmp/varmint-uploads using project identifier "${tW}"`);let T=[];for(let W of f4.readdirSync(q$.storage.rootDir))if(lX(`unmatched${U4}`,W))T.push(W);if(T.length===0){console.log("\uD83D\uDC3F\uFE0F ","No unmatched input files found.");return}if(console.log("\uD83D\uDC3F\uFE0F ","Found the following unmatched files:",`
37
+ `,JSON.stringify(Q.issues,null,"\t")),O.push({response:F,error:Q})}return T?.error(`safegen was unable to generate well-formed data after ${z} failed attempts.`),X}}}function eK($){return["Please generate a response in JSON that conforms to the following JSON Schema:",JSON.stringify($,null,2)].join(`
38
+ `)}var zA=Hq(WA(),1);import*as x6 from"fs";import*as aW from"path";import{resolve as KS}from"path";import{createHash as AS}from"crypto";import{copyFile as ES}from"fs/promises";import{existsSync as OF,mkdirSync as XA,readFileSync as ZS,readdirSync as wA,rmSync as UA,statSync as YA,writeFileSync as VS}from"fs";import{resolve as QF}from"path";var GA=class{rootDir;get initialized(){return OF(this.rootDir)}initialize(){if(!this.initialized)XA(this.rootDir,{recursive:!0})}constructor($){if(this.rootDir=$.path,$.eagerInit)this.initialize()}getItem($){let T=QF(this.rootDir,$);if(OF(T))return ZS(T,"utf-8");return null}setItem($,T){this.initialize();let W=QF(this.rootDir,$);VS(W,T)}removeItem($){let T=QF(this.rootDir,$);if(OF(T))this.initialize(),UA(T)}key($){return wA(this.rootDir).sort((w,X)=>{let U=YA(w);return YA(X).ctimeMs-U.ctimeMs})[$]??null}clear(){UA(this.rootDir,{recursive:!0}),XA(this.rootDir,{recursive:!0})}get length(){return wA(this.rootDir).length}};var HA=/[^a-zA-Z0-9\-._]/g;function V8($,T=64){if(T%2===1)T+=1;let W=$.replace(HA,"-");if(W.length<=T)return W;let w=AS("sha256").update($).digest("base64").slice(0,8).replaceAll("/","_"),X=W;if(X.length>T){let U=X.slice(0,T/2),Y=X.slice(-T/2);X=U+"_"+Y}return X+"+"+w}var MS=zA.default("varmint"),Z8=V8(process.cwd(),150),ZF=KS(MS,Z8),q4="_-$-_-$-_",FA=`file${q4}`,OA=`list${q4}`,QA=`root${q4}`,DS=`unmatched${q4}`,n$={storage:new GA({path:ZF,eagerInit:!1}),startGlobalTracking(){if(console.log(`\uD83D\uDC3F\uFE0F Starting global tracking of varmint files using project identifier "${Z8}"`),n$.storage.initialized)console.error(`\uD83D\uDCA5 The global cache for the project "${Z8}" was found already initialized. Clearing it and starting fresh.`),n$.storage.clear();n$.storage.initialize()},async prepareUploads($){console.log(`\uD83D\uDC3F\uFE0F Moving unmatched inputs to /tmp/varmint-uploads using project identifier "${Z8}"`);let T=[];for(let W of x6.readdirSync(n$.storage.rootDir))if(YG(`unmatched${q4}`,W))T.push(W);if(T.length===0){console.log("\uD83D\uDC3F\uFE0F ","No unmatched input files found.");return}if(console.log("\uD83D\uDC3F\uFE0F ","Found the following unmatched files:",`
39
39
  - ${T.join(`
40
40
  `)}
41
41
  `,`in root folder:
42
- `,k9),process.env[$])f4.mkdirSync("/tmp/varmint-uploads",{recursive:!0}),await Promise.all(T.map(async(W)=>{let U=WT.join(k9,W),X=WT.join("/tmp/varmint-uploads",W);await gR(U,X)}));else console.warn("\uD83D\uDCA5 Skipping artifact upload because process.env.CI is not set.")},endGlobalTrackingAndFlushUnusedFiles(){if(console.log(`\uD83D\uDC3F\uFE0F Ending global tracking of varmint files using project identifier "${tW}" and starting cleanup of untouched files.`),!q$.storage.initialized){console.error("\uD83D\uDCA5 called flushGlobal, but the global cache wasn't initialized with startGlobalTracking");return}let $=f4.readdirSync(q$.storage.rootDir),T=new Map,W=[],U=[],X=[];for(let _ of $)if(lX(`root${U4}`,_))W.push(_);else if(lX(`list${U4}`,_))U.push(_);else if(lX(`file${U4}`,_))X.push(_);if(q$.storage.getItem("DID_CACHE_MISS"))console.log("\uD83D\uDC3F\uFE0F ","Cache miss detected. Since this likely prevented the cache from being fully utilized, we will not attempt to flush unused files.");else{let _=new Map;for(let w of W){let G=w.replace(xF,"");_.set(G,new Map);let J=q$.storage.getItem(w);if(J)T.set(G,J);else console.error(`\uD83D\uDCA5 Could not find folder ${J} referenced in the global cache`)}for(let w of U){let G=w.replace(jF,""),[J,H]=G.split(U4),z=_.get(J);if(z)z.set(H,new Set);else console.error(`\uD83D\uDCA5 Could not find root ${J} for list ${H}`)}for(let w of X){let G=w.replace(CF,""),[J,H,z]=G.split(U4),F=_.get(J);if(F){let Q=F.get(H);if(Q)Q.add(z);else console.error(`\uD83D\uDCA5 Could not find list ${H} for file ${G}`)}else console.error(`\uD83D\uDCA5 Could not find root ${J} for file ${G}`)}console.log("\uD83D\uDC3F\uFE0F ",_);for(let[w,G]of _.entries()){let J=T.get(w);if(!J){console.error(`\uD83D\uDCA5 Could not find root ${w}`);continue}if(!f4.existsSync(J)){console.warn(`\uD83D\uDCA5 Root folder ${J}, identified as being used during tracking, no longer exists during cleanup.`);continue}let z=f4.readdirSync(J);for(let F of z)if(F!==".ferret"&&!G.has(F)){let Q=WT.join(J,F);console.log(`\uD83E\uDDF9 globalFlush: removing directory ${Q}`),f4.rmSync(Q,{recursive:!0})}for(let[F,Q]of G.entries()){let V=WT.join(J,F);if(!f4.existsSync(V)){console.warn(`\uD83D\uDCA5 List folder ${V}, identified as being used during tracking, no longer exists.`);continue}let I=f4.readdirSync(V);for(let k of I){let N=k.replace(".input.json","").replace(".output.json","").replace(".stream.txt","");if(!Q.has(N)){let L=WT.join(V,k);console.log(`\uD83E\uDDF9 globalFlush: removing file ${L}`),f4.rmSync(L)}}}}}f4.rmSync(q$.storage.rootDir,{recursive:!0})}};function lX($,T){return T.startsWith($)}import*as l$ from"fs";import*as K6 from"path";import{inspect as bF}from"util";var fF=class{filenameCache=new Map;filesTouched=new Map;mode;baseDir;rootName;constructor($="off",T=K6.join(process.cwd(),".varmint")){if(this.mode=$,this.baseDir=T,this.rootName=aW(this.baseDir),q$.storage.initialized&&!q$.storage.getItem(`root${U4}${this.rootName}`))q$.storage.setItem(`root${U4}${this.rootName}`,this.baseDir)}read($,T,W){let U=K6.join(this.baseDir,$),X=`${T}.input.json`,Y=K6.join(U,X);if(!l$.existsSync(Y)){if(!l$.existsSync(U)){if(q$.storage.initialized&&this.mode==="read")q$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: input file for key "${$}" with "${T}" was not found. Directory "${U}" does not exist.`)}let z=l$.readdirSync(U).map((V)=>[V,l$.readFileSync(K6.join(U,V),"utf-8")]).filter(([V])=>V.endsWith(".input.json")),F=[];for(let[V,K]of z){let I=` ${V}`,k=` ${bF(JSON.parse(K),{depth:Number.POSITIVE_INFINITY,colors:!0}).split(`
42
+ `,ZF),process.env[$])x6.mkdirSync("/tmp/varmint-uploads",{recursive:!0}),await Promise.all(T.map(async(W)=>{let w=aW.join(ZF,W),X=aW.join("/tmp/varmint-uploads",W);await ES(w,X)}));else console.warn("\uD83D\uDCA5 Skipping artifact upload because process.env.CI is not set.")},endGlobalTrackingAndFlushUnusedFiles(){if(console.log(`\uD83D\uDC3F\uFE0F Ending global tracking of varmint files using project identifier "${Z8}" and starting cleanup of untouched files.`),!n$.storage.initialized){console.error("\uD83D\uDCA5 called flushGlobal, but the global cache wasn't initialized with startGlobalTracking");return}let $=x6.readdirSync(n$.storage.rootDir),T=new Map,W=[],w=[],X=[];for(let Y of $)if(YG(`root${q4}`,Y))W.push(Y);else if(YG(`list${q4}`,Y))w.push(Y);else if(YG(`file${q4}`,Y))X.push(Y);if(n$.storage.getItem("DID_CACHE_MISS"))console.log("\uD83D\uDC3F\uFE0F ","Cache miss detected. Since this likely prevented the cache from being fully utilized, we will not attempt to flush unused files.");else{let Y=new Map;for(let G of W){let H=G.replace(QA,"");Y.set(H,new Map);let z=n$.storage.getItem(G);if(z)T.set(H,z);else console.error(`\uD83D\uDCA5 Could not find folder ${z} referenced in the global cache`)}for(let G of w){let H=G.replace(OA,""),[z,F]=H.split(q4),O=Y.get(z);if(O)O.set(F,new Set);else console.error(`\uD83D\uDCA5 Could not find root ${z} for list ${F}`)}for(let G of X){let H=G.replace(FA,""),[z,F,O]=H.split(q4),Q=Y.get(z);if(Q){let Z=Q.get(F);if(Z)Z.add(O);else console.error(`\uD83D\uDCA5 Could not find list ${F} for file ${H}`)}else console.error(`\uD83D\uDCA5 Could not find root ${z} for file ${H}`)}console.log("\uD83D\uDC3F\uFE0F ",Y);for(let[G,H]of Y.entries()){let z=T.get(G);if(!z){console.error(`\uD83D\uDCA5 Could not find root ${G}`);continue}if(!x6.existsSync(z)){console.warn(`\uD83D\uDCA5 Root folder ${z}, identified as being used during tracking, no longer exists during cleanup.`);continue}let O=x6.readdirSync(z);for(let Q of O)if(Q!==".ferret"&&!H.has(Q)){let Z=aW.join(z,Q);console.log(`\uD83E\uDDF9 globalFlush: removing directory ${Z}`),x6.rmSync(Z,{recursive:!0})}for(let[Q,Z]of H.entries()){let K=aW.join(z,Q);if(!x6.existsSync(K)){console.warn(`\uD83D\uDCA5 List folder ${K}, identified as being used during tracking, no longer exists.`);continue}let M=x6.readdirSync(K);for(let L of M){let R=L.replace(".input.json","").replace(".output.json","").replace(".stream.txt","");if(!Z.has(R)){let _=aW.join(K,L);console.log(`\uD83E\uDDF9 globalFlush: removing file ${_}`),x6.rmSync(_)}}}}}x6.rmSync(n$.storage.rootDir,{recursive:!0})}};function YG($,T){return T.startsWith($)}import*as K4 from"fs";import*as C1 from"path";import{inspect as ZA}from"util";var VA=class{filenameCache=new Map;filesTouched=new Map;mode;baseDir;rootName;constructor($="off",T=C1.join(process.cwd(),".varmint")){if(this.mode=$,this.baseDir=T,this.rootName=V8(this.baseDir),n$.storage.initialized&&!n$.storage.getItem(`root${q4}${this.rootName}`))n$.storage.setItem(`root${q4}${this.rootName}`,this.baseDir)}read($,T,W){let w=C1.join(this.baseDir,$),X=`${T}.input.json`,U=C1.join(w,X);if(!K4.existsSync(U)){if(!K4.existsSync(w)){if(n$.storage.initialized&&this.mode==="read")n$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: input file for key "${$}" with "${T}" was not found. Directory "${w}" does not exist.`)}let O=K4.readdirSync(w).map((K)=>[K,K4.readFileSync(C1.join(w,K),"utf-8")]).filter(([K])=>K.endsWith(".input.json")),Q=[];for(let[K,E]of O){let M=` ${K}`,L=` ${ZA(JSON.parse(E),{depth:Number.POSITIVE_INFINITY,colors:!0}).split(`
43
43
  `).join(`
44
- `)}`;F.push(I,k)}let Q=` ${X}
45
- ${bF(W,{depth:Number.POSITIVE_INFINITY,colors:!0}).split(`
44
+ `)}`;Q.push(M,L)}let Z=` ${X}
45
+ ${ZA(W,{depth:Number.POSITIVE_INFINITY,colors:!0}).split(`
46
46
  `).join(`
47
- `)}`;if(q$.storage.initialized&&this.mode==="read")q$.storage.setItem(`unmatched${U4}${X}`,JSON.stringify(W,null,"\t")),q$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: input file for key "${$}" with subKey "${T}" (${Y}) was not found. Directory "${U}" exists, but the file does not. Below is a list of CACHED INPUT FILES from that directory and their contents, followed by YOUR INPUT DATA.
47
+ `)}`;if(n$.storage.initialized&&this.mode==="read")n$.storage.setItem(`unmatched${q4}${X}`,JSON.stringify(W,null,"\t")),n$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: input file for key "${$}" with subKey "${T}" (${U}) was not found. Directory "${w}" exists, but the file does not. Below is a list of CACHED INPUT FILES from that directory and their contents, followed by YOUR INPUT DATA.
48
48
 
49
49
  CACHED INPUT FILES:
50
- ${F.join(`
50
+ ${Q.join(`
51
51
  `)}
52
52
 
53
53
  YOUR INPUT DATA:
54
- ${Q}
55
- `)}let _=l$.readFileSync(Y,"utf-8"),w=JSON.stringify(W,null,"\t");if(w!==_){if(q$.storage.initialized&&this.mode==="read")q$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: the content of the cached input file ${Y} does not match the input provided.
54
+ ${Z}
55
+ `)}let Y=K4.readFileSync(U,"utf-8"),G=JSON.stringify(W,null,"\t");if(G!==Y){if(n$.storage.initialized&&this.mode==="read")n$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: the content of the cached input file ${U} does not match the input provided.
56
56
 
57
57
  Provided:
58
- ${w}
58
+ ${G}
59
59
 
60
60
  Cached:
61
- ${_}`)}let G=K6.join(this.baseDir,`${$}/${T}.output.json`);return JSON.parse(l$.readFileSync(G,"utf-8"))}async write($,T,W,U){let X=K6.join(this.baseDir,$),Y=K6.join(X,`${T}.input.json`),_=K6.join(X,`${T}.output.json`),w=JSON.stringify(W,null,"\t");if(!l$.existsSync(this.baseDir))l$.mkdirSync(this.baseDir,{recursive:!0});if(!l$.existsSync(X))l$.mkdirSync(X);if(l$.writeFileSync(Y,w),l$.existsSync(_))l$.unlinkSync(_);let G=await U(...W),J=JSON.stringify(G,null,"\t");return l$.writeFileSync(_,J),G}add($,T){let W=`${this.rootName}${U4}${aW($)}`;return{flush:()=>{this.flush($)},for:(U)=>{if(this.mode!=="off"){if(this.filesTouched.set($,new Set),q$.storage.initialized&&!q$.storage.getItem(`list${U4}${W}`))q$.storage.setItem(`list${U4}${W}`,"true")}return{get:async(...X)=>{let Y=U;if(this.mode!=="off"){let _=this.filenameCache.get(U);if(!_)_=aW(U),this.filenameCache.set(U,_);Y=_,this.filesTouched.get($)?.add(Y);let w=`${W}${U4}${Y}`,G=`file${U4}${w}`;if(q$.storage.initialized&&!q$.storage.getItem(G))q$.storage.setItem(G,"true")}switch(this.mode){case"off":return T(...X);case"read":return this.read($,Y,X);case"write":return this.write($,Y,X,T);case"read-write":try{return this.read($,Y,X)}catch(_){if(_ instanceof Error)return this.write($,Y,X,T);throw _}}}}}}}flush(...$){console.log(this.filesTouched);for(let[T,W]of this.filesTouched.entries())if($.length===0||$.includes(T)){let U=K6.join(this.baseDir,T),X=l$.readdirSync(U);for(let Y of X){let _=Y.replace(".input.json","").replace(".output.json","");if(!W.has(_))console.info(`\uD83E\uDDF9 Flushing ${_}`),l$.unlinkSync(K6.join(U,Y))}}}};var rX="RFC3986",iX={RFC1738:($)=>String($).replace(/%20/g,"+"),RFC3986:($)=>String($)},yF="RFC1738";var uR=Array.isArray,j6=(()=>{let $=[];for(let T=0;T<256;++T)$.push("%"+((T<16?"0":"")+T.toString(16)).toUpperCase());return $})();var v9=1024,hF=($,T,W,U,X)=>{if($.length===0)return $;let Y=$;if(typeof $==="symbol")Y=Symbol.prototype.toString.call($);else if(typeof $!=="string")Y=String($);if(W==="iso-8859-1")return escape(Y).replace(/%u[0-9a-f]{4}/gi,function(w){return"%26%23"+parseInt(w.slice(2),16)+"%3B"});let _="";for(let w=0;w<Y.length;w+=v9){let G=Y.length>=v9?Y.slice(w,w+v9):Y,J=[];for(let H=0;H<G.length;++H){let z=G.charCodeAt(H);if(z===45||z===46||z===95||z===126||z>=48&&z<=57||z>=65&&z<=90||z>=97&&z<=122||X===yF&&(z===40||z===41)){J[J.length]=G.charAt(H);continue}if(z<128){J[J.length]=j6[z];continue}if(z<2048){J[J.length]=j6[192|z>>6]+j6[128|z&63];continue}if(z<55296||z>=57344){J[J.length]=j6[224|z>>12]+j6[128|z>>6&63]+j6[128|z&63];continue}H+=1,z=65536+((z&1023)<<10|G.charCodeAt(H)&1023),J[J.length]=j6[240|z>>18]+j6[128|z>>12&63]+j6[128|z>>6&63]+j6[128|z&63]}_+=J.join("")}return _};function gF($){if(!$||typeof $!=="object")return!1;return!!($.constructor&&$.constructor.isBuffer&&$.constructor.isBuffer($))}function q9($,T){if(uR($)){let W=[];for(let U=0;U<$.length;U+=1)W.push(T($[U]));return W}return T($)}var pR=Object.prototype.hasOwnProperty,mF={brackets($){return String($)+"[]"},comma:"comma",indices($,T){return String($)+"["+T+"]"},repeat($){return String($)}},x6=Array.isArray,oR=Array.prototype.push,cF=function($,T){oR.apply($,x6(T)?T:[T])},dR=Date.prototype.toISOString,X4={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:hF,encodeValuesOnly:!1,format:rX,formatter:iX[rX],indices:!1,serializeDate($){return dR.call($)},skipNulls:!1,strictNullHandling:!1};function lR($){return typeof $==="string"||typeof $==="number"||typeof $==="boolean"||typeof $==="symbol"||typeof $==="bigint"}var P9={};function uF($,T,W,U,X,Y,_,w,G,J,H,z,F,Q,V,K,I,k){let N=$,L=k,q=0,y=!1;while((L=L.get(P9))!==void 0&&!y){let B=L.get($);if(q+=1,typeof B!=="undefined")if(B===q)throw new RangeError("Cyclic object value");else y=!0;if(typeof L.get(P9)==="undefined")q=0}if(typeof J==="function")N=J(T,N);else if(N instanceof Date)N=F?.(N);else if(W==="comma"&&x6(N))N=q9(N,function(B){if(B instanceof Date)return F?.(B);return B});if(N===null){if(Y)return G&&!K?G(T,X4.encoder,I,"key",Q):T;N=""}if(lR(N)||gF(N)){if(G){let B=K?T:G(T,X4.encoder,I,"key",Q);return[V?.(B)+"="+V?.(G(N,X4.encoder,I,"value",Q))]}return[V?.(T)+"="+V?.(String(N))]}let x=[];if(typeof N==="undefined")return x;let u;if(W==="comma"&&x6(N)){if(K&&G)N=q9(N,G);u=[{value:N.length>0?N.join(",")||null:void 0}]}else if(x6(J))u=J;else{let B=Object.keys(N);u=H?B.sort(H):B}let w$=w?String(T).replace(/\./g,"%2E"):String(T),m$=U&&x6(N)&&N.length===1?w$+"[]":w$;if(X&&x6(N)&&N.length===0)return m$+"[]";for(let B=0;B<u.length;++B){let D$=u[B],$$=typeof D$==="object"&&typeof D$.value!=="undefined"?D$.value:N[D$];if(_&&$$===null)continue;let H$=z&&w?D$.replace(/\./g,"%2E"):D$,$4=x6(N)?typeof W==="function"?W(m$,H$):m$:m$+(z?"."+H$:"["+H$+"]");k.set($,q);let V4=new WeakMap;V4.set(P9,k),cF(x,uF($$,$4,W,U,X,Y,_,w,W==="comma"&&K&&x6(N)?null:G,J,H,z,F,Q,V,K,I,V4))}return x}function rR($=X4){if(typeof $.allowEmptyArrays!=="undefined"&&typeof $.allowEmptyArrays!=="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof $.encodeDotInKeys!=="undefined"&&typeof $.encodeDotInKeys!=="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if($.encoder!==null&&typeof $.encoder!=="undefined"&&typeof $.encoder!=="function")throw new TypeError("Encoder has to be a function.");let T=$.charset||X4.charset;if(typeof $.charset!=="undefined"&&$.charset!=="utf-8"&&$.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let W=rX;if(typeof $.format!=="undefined"){if(!pR.call(iX,$.format))throw new TypeError("Unknown format option provided.");W=$.format}let U=iX[W],X=X4.filter;if(typeof $.filter==="function"||x6($.filter))X=$.filter;let Y;if($.arrayFormat&&$.arrayFormat in mF)Y=$.arrayFormat;else if("indices"in $)Y=$.indices?"indices":"repeat";else Y=X4.arrayFormat;if("commaRoundTrip"in $&&typeof $.commaRoundTrip!=="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let _=typeof $.allowDots==="undefined"?!!$.encodeDotInKeys===!0?!0:X4.allowDots:!!$.allowDots;return{addQueryPrefix:typeof $.addQueryPrefix==="boolean"?$.addQueryPrefix:X4.addQueryPrefix,allowDots:_,allowEmptyArrays:typeof $.allowEmptyArrays==="boolean"?!!$.allowEmptyArrays:X4.allowEmptyArrays,arrayFormat:Y,charset:T,charsetSentinel:typeof $.charsetSentinel==="boolean"?$.charsetSentinel:X4.charsetSentinel,commaRoundTrip:!!$.commaRoundTrip,delimiter:typeof $.delimiter==="undefined"?X4.delimiter:$.delimiter,encode:typeof $.encode==="boolean"?$.encode:X4.encode,encodeDotInKeys:typeof $.encodeDotInKeys==="boolean"?$.encodeDotInKeys:X4.encodeDotInKeys,encoder:typeof $.encoder==="function"?$.encoder:X4.encoder,encodeValuesOnly:typeof $.encodeValuesOnly==="boolean"?$.encodeValuesOnly:X4.encodeValuesOnly,filter:X,format:W,formatter:U,serializeDate:typeof $.serializeDate==="function"?$.serializeDate:X4.serializeDate,skipNulls:typeof $.skipNulls==="boolean"?$.skipNulls:X4.skipNulls,sort:typeof $.sort==="function"?$.sort:null,strictNullHandling:typeof $.strictNullHandling==="boolean"?$.strictNullHandling:X4.strictNullHandling}}function C9($,T={}){let W=$,U=rR(T),X,Y;if(typeof U.filter==="function")Y=U.filter,W=Y("",W);else if(x6(U.filter))Y=U.filter,X=Y;let _=[];if(typeof W!=="object"||W===null)return"";let w=mF[U.arrayFormat],G=w==="comma"&&U.commaRoundTrip;if(!X)X=Object.keys(W);if(U.sort)X.sort(U.sort);let J=new WeakMap;for(let F=0;F<X.length;++F){let Q=X[F];if(U.skipNulls&&W[Q]===null)continue;cF(_,uF(W[Q],Q,w,G,U.allowEmptyArrays,U.strictNullHandling,U.skipNulls,U.encodeDotInKeys,U.encode?U.encoder:null,U.filter,U.sort,U.allowDots,U.serializeDate,U.format,U.formatter,U.encodeValuesOnly,U.charset,J))}let H=_.join(U.delimiter),z=U.addQueryPrefix===!0?"?":"";if(U.charsetSentinel)if(U.charset==="iso-8859-1")z+="utf8=%26%2310003%3B&";else z+="utf8=%E2%9C%93&";return H.length>0?z+H:""}var X0="4.103.0";var pF=!1,Y0=void 0,j9=void 0,nR=void 0,tR=void 0,aR=void 0,x9=void 0,sR=void 0,nX=void 0,b9=void 0,f9=void 0,y9=void 0,tX=void 0,h9=void 0;function oF($,T={auto:!1}){if(pF)throw new Error(`you must \`import 'openai/shims/${$.kind}'\` before importing anything else from openai`);if(Y0)throw new Error(`can't \`import 'openai/shims/${$.kind}'\` after \`import 'openai/shims/${Y0}'\``);pF=T.auto,Y0=$.kind,j9=$.fetch,nR=$.Request,tR=$.Response,aR=$.Headers,x9=$.FormData,sR=$.Blob,nX=$.File,b9=$.ReadableStream,f9=$.getMultipartRequestOptions,y9=$.getDefaultAgent,tX=$.fileFromPath,h9=$.isFsReadStream}class g9{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function dF({manuallyImported:$}={}){let T=$?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n",W,U,X,Y;try{W=fetch,U=Request,X=Response,Y=Headers}catch(_){throw new Error(`this environment is missing the following Web Fetch API type: ${_.message}. ${T}`)}return{kind:"web",fetch:W,Request:U,Response:X,Headers:Y,FormData:typeof FormData!=="undefined"?FormData:class _{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${T}`)}},Blob:typeof Blob!=="undefined"?Blob:class _{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${T}`)}},File:typeof File!=="undefined"?File:class _{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${T}`)}},ReadableStream:typeof ReadableStream!=="undefined"?ReadableStream:class _{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${T}`)}},getMultipartRequestOptions:async(_,w)=>({...w,body:new g9(_)}),getDefaultAgent:(_)=>{return},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:(_)=>!1}}import{ReadStream as $I}from"fs";function lF(){let $=dF();function T(W){return W instanceof $I}return{...$,isFsReadStream:T}}var m9=()=>{if(!Y0)oF(lF(),{auto:!0})};m9();class l extends Error{}class a$ extends l{constructor($,T,W,U){super(`${a$.makeMessage($,T,W)}`);this.status=$,this.headers=U,this.request_id=U?.["x-request-id"],this.error=T;let X=T;this.code=X?.code,this.param=X?.param,this.type=X?.type}static makeMessage($,T,W){let U=T?.message?typeof T.message==="string"?T.message:JSON.stringify(T.message):T?JSON.stringify(T):W;if($&&U)return`${$} ${U}`;if($)return`${$} status code (no body)`;if(U)return U;return"(no status code or body)"}static generate($,T,W,U){if(!$||!U)return new _0({message:W,cause:YY(T)});let X=T?.error;if($===400)return new aX($,X,W,U);if($===401)return new sX($,X,W,U);if($===403)return new eX($,X,W,U);if($===404)return new $Y($,X,W,U);if($===409)return new TY($,X,W,U);if($===422)return new WY($,X,W,U);if($===429)return new UY($,X,W,U);if($>=500)return new XY($,X,W,U);return new a$($,X,W,U)}}class Y4 extends a${constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class _0 extends a${constructor({message:$,cause:T}){super(void 0,void 0,$||"Connection error.",void 0);if(T)this.cause=T}}class w0 extends _0{constructor({message:$}={}){super({message:$??"Request timed out."})}}class aX extends a${}class sX extends a${}class eX extends a${}class $Y extends a${}class TY extends a${}class WY extends a${}class UY extends a${}class XY extends a${}class sW extends l{constructor(){super("Could not parse response content as the length limit was reached")}}class eW extends l{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var _Y=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},J0=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},t4;class UT{constructor(){t4.set(this,void 0),this.buffer=new Uint8Array,_Y(this,t4,null,"f")}decode($){if($==null)return[];let T=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?new TextEncoder().encode($):$,W=new Uint8Array(this.buffer.length+T.length);W.set(this.buffer),W.set(T,this.buffer.length),this.buffer=W;let U=[],X;while((X=WI(this.buffer,J0(this,t4,"f")))!=null){if(X.carriage&&J0(this,t4,"f")==null){_Y(this,t4,X.index,"f");continue}if(J0(this,t4,"f")!=null&&(X.index!==J0(this,t4,"f")+1||X.carriage)){U.push(this.decodeText(this.buffer.slice(0,J0(this,t4,"f")-1))),this.buffer=this.buffer.slice(J0(this,t4,"f")),_Y(this,t4,null,"f");continue}let Y=J0(this,t4,"f")!==null?X.preceding-1:X.preceding,_=this.decodeText(this.buffer.slice(0,Y));U.push(_),this.buffer=this.buffer.slice(X.index),_Y(this,t4,null,"f")}return U}decodeText($){if($==null)return"";if(typeof $==="string")return $;if(typeof Buffer!=="undefined"){if($ instanceof Buffer)return $.toString();if($ instanceof Uint8Array)return Buffer.from($).toString();throw new l(`Unexpected: received non-Uint8Array (${$.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder!=="undefined"){if($ instanceof Uint8Array||$ instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode($);throw new l(`Unexpected: received non-Uint8Array/ArrayBuffer (${$.constructor.name}) in a web platform. Please report this error.`)}throw new l("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
62
- `)}}t4=new WeakMap;UT.NEWLINE_CHARS=new Set([`
63
- `,"\r"]);UT.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function WI($,T){for(let X=T??0;X<$.length;X++){if($[X]===10)return{preceding:X,index:X+1,carriage:!1};if($[X]===13)return{preceding:X,index:X+1,carriage:!0}}return null}function rF($){for(let U=0;U<$.length-1;U++){if($[U]===10&&$[U+1]===10)return U+2;if($[U]===13&&$[U+1]===13)return U+2;if($[U]===13&&$[U+1]===10&&U+3<$.length&&$[U+2]===13&&$[U+3]===10)return U+4}return-1}function c9($){if($[Symbol.asyncIterator])return $;let T=$.getReader();return{async next(){try{let W=await T.read();if(W?.done)T.releaseLock();return W}catch(W){throw T.releaseLock(),W}},async return(){let W=T.cancel();return T.releaseLock(),await W,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}class a4{constructor($,T){this.iterator=$,this.controller=T}static fromSSEResponse($,T){let W=!1;async function*U(){if(W)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");W=!0;let X=!1;try{for await(let Y of UI($,T)){if(X)continue;if(Y.data.startsWith("[DONE]")){X=!0;continue}if(Y.event===null||Y.event.startsWith("response.")||Y.event.startsWith("transcript.")){let _;try{_=JSON.parse(Y.data)}catch(w){throw console.error("Could not parse message into JSON:",Y.data),console.error("From chunk:",Y.raw),w}if(_&&_.error)throw new a$(void 0,_.error,void 0,u9($.headers));yield _}else{let _;try{_=JSON.parse(Y.data)}catch(w){throw console.error("Could not parse message into JSON:",Y.data),console.error("From chunk:",Y.raw),w}if(Y.event=="error")throw new a$(void 0,_.error,_.message,void 0);yield{event:Y.event,data:_}}}X=!0}catch(Y){if(Y instanceof Error&&Y.name==="AbortError")return;throw Y}finally{if(!X)T.abort()}}return new a4(U,T)}static fromReadableStream($,T){let W=!1;async function*U(){let Y=new UT,_=c9($);for await(let w of _)for(let G of Y.decode(w))yield G;for(let w of Y.flush())yield w}async function*X(){if(W)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");W=!0;let Y=!1;try{for await(let _ of U()){if(Y)continue;if(_)yield JSON.parse(_)}Y=!0}catch(_){if(_ instanceof Error&&_.name==="AbortError")return;throw _}finally{if(!Y)T.abort()}}return new a4(X,T)}[Symbol.asyncIterator](){return this.iterator()}tee(){let $=[],T=[],W=this.iterator(),U=(X)=>{return{next:()=>{if(X.length===0){let Y=W.next();$.push(Y),T.push(Y)}return X.shift()}}};return[new a4(()=>U($),this.controller),new a4(()=>U(T),this.controller)]}toReadableStream(){let $=this,T,W=new TextEncoder;return new b9({async start(){T=$[Symbol.asyncIterator]()},async pull(U){try{let{value:X,done:Y}=await T.next();if(Y)return U.close();let _=W.encode(JSON.stringify(X)+`
64
- `);U.enqueue(_)}catch(X){U.error(X)}},async cancel(){await T.return?.()}})}}async function*UI($,T){if(!$.body)throw T.abort(),new l("Attempted to iterate over a response with no body");let W=new iF,U=new UT,X=c9($.body);for await(let Y of XI(X))for(let _ of U.decode(Y)){let w=W.decode(_);if(w)yield w}for(let Y of U.flush()){let _=W.decode(Y);if(_)yield _}}async function*XI($){let T=new Uint8Array;for await(let W of $){if(W==null)continue;let U=W instanceof ArrayBuffer?new Uint8Array(W):typeof W==="string"?new TextEncoder().encode(W):W,X=new Uint8Array(T.length+U.length);X.set(T),X.set(U,T.length),T=X;let Y;while((Y=rF(T))!==-1)yield T.slice(0,Y),T=T.slice(Y)}if(T.length>0)yield T}class iF{constructor(){this.event=null,this.data=[],this.chunks=[]}decode($){if($.endsWith("\r"))$=$.substring(0,$.length-1);if(!$){if(!this.event&&!this.data.length)return null;let X={event:this.event,data:this.data.join(`
65
- `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],X}if(this.chunks.push($),$.startsWith(":"))return null;let[T,W,U]=YI($,":");if(U.startsWith(" "))U=U.substring(1);if(T==="event")this.event=U;else if(T==="data")this.data.push(U);return null}}function YI($,T){let W=$.indexOf(T);if(W!==-1)return[$.substring(0,W),T,$.substring(W+T.length)];return[$,"",""]}var nF=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",tF=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&$2($),$2=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function",_I=($)=>{return tF($)||nF($)||h9($)};async function d9($,T,W){if($=await $,tF($))return $;if(nF($)){let X=await $.blob();T||(T=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let Y=$2(X)?[await X.arrayBuffer()]:[X];return new nX(Y,T,W)}let U=await wI($);if(T||(T=GI($)??"unknown_file"),!W?.type){let X=U[0]?.type;if(typeof X==="string")W={...W,type:X}}return new nX(U,T,W)}async function wI($){let T=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)T.push($);else if($2($))T.push(await $.arrayBuffer());else if(zI($))for await(let W of $)T.push(W);else throw new Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${JI($)}`);return T}function JI($){return`[${Object.getOwnPropertyNames($).map((W)=>`"${W}"`).join(", ")}]`}function GI($){return p9($.name)||p9($.filename)||p9($.path)?.split(/[\\/]/).pop()}var p9=($)=>{if(typeof $==="string")return $;if(typeof Buffer!=="undefined"&&$ instanceof Buffer)return String($);return},zI=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",l9=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var y4=async($)=>{let T=await aF($.body);return f9(T,$)},aF=async($)=>{let T=new x9;return await Promise.all(Object.entries($||{}).map(([W,U])=>o9(T,W,U))),T};var o9=async($,T,W)=>{if(W===void 0)return;if(W==null)throw new TypeError(`Received null for "${T}"; to pass null in FormData, you must use the string 'null'`);if(typeof W==="string"||typeof W==="number"||typeof W==="boolean")$.append(T,String(W));else if(_I(W)){let U=await d9(W);$.append(T,U)}else if(Array.isArray(W))await Promise.all(W.map((U)=>o9($,T+"[]",U)));else if(typeof W==="object")await Promise.all(Object.entries(W).map(([U,X])=>o9($,`${T}[${U}]`,X)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${W} instead`)};var FI=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},OI=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},wY;m9();async function UO($){let{response:T}=$;if($.options.stream){if(n6("response",T.status,T.url,T.headers,T.body),$.options.__streamClass)return $.options.__streamClass.fromSSEResponse(T,$.controller);return a4.fromSSEResponse(T,$.controller)}if(T.status===204)return null;if($.options.__binaryResponse)return T;let U=T.headers.get("content-type")?.split(";")[0]?.trim();if(U?.includes("application/json")||U?.endsWith("+json")){let _=await T.json();return n6("response",T.status,T.url,T.headers,_),XO(_,T)}let Y=await T.text();return n6("response",T.status,T.url,T.headers,Y),Y}function XO($,T){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:T.headers.get("x-request-id"),enumerable:!1})}class GY extends Promise{constructor($,T=UO){super((W)=>{W(null)});this.responsePromise=$,this.parseResponse=T}_thenUnwrap($){return new GY(this.responsePromise,async(T)=>XO($(await this.parseResponse(T),T),T.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,T]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:T,request_id:T.headers.get("x-request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(this.parseResponse);return this.parsedPromise}then($,T){return this.parse().then($,T)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}class i9{constructor({baseURL:$,maxRetries:T=2,timeout:W=600000,httpAgent:U,fetch:X}){this.baseURL=$,this.maxRetries=r9("maxRetries",T),this.timeout=r9("timeout",W),this.httpAgent=U,this.fetch=X??j9}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...VI(),...this.authHeaders($)}}validateHeaders($,T){}defaultIdempotencyKey(){return`stainless-node-retry-${MI()}`}get($,T){return this.methodRequest("get",$,T)}post($,T){return this.methodRequest("post",$,T)}patch($,T){return this.methodRequest("patch",$,T)}put($,T){return this.methodRequest("put",$,T)}delete($,T){return this.methodRequest("delete",$,T)}methodRequest($,T,W){return this.request(Promise.resolve(W).then(async(U)=>{let X=U&&$2(U?.body)?new DataView(await U.body.arrayBuffer()):U?.body instanceof DataView?U.body:U?.body instanceof ArrayBuffer?new DataView(U.body):U&&ArrayBuffer.isView(U?.body)?new DataView(U.body.buffer):U?.body;return{method:$,path:T,...U,body:X}}))}getAPIList($,T,W){return this.requestAPIList(T,{method:"get",path:$,...W})}calculateContentLength($){if(typeof $==="string"){if(typeof Buffer!=="undefined")return Buffer.byteLength($,"utf8").toString();if(typeof TextEncoder!=="undefined")return new TextEncoder().encode($).length.toString()}else if(ArrayBuffer.isView($))return $.byteLength.toString();return null}buildRequest($,{retryCount:T=0}={}){let W={...$},{method:U,path:X,query:Y,headers:_={}}=W,w=ArrayBuffer.isView(W.body)||W.__binaryRequest&&typeof W.body==="string"?W.body:l9(W.body)?W.body.body:W.body?JSON.stringify(W.body,null,2):null,G=this.calculateContentLength(w),J=this.buildURL(X,Y);if("timeout"in W)r9("timeout",W.timeout);W.timeout=W.timeout??this.timeout;let H=W.httpAgent??this.httpAgent??y9(J),z=W.timeout+1000;if(typeof H?.options?.timeout==="number"&&z>(H.options.timeout??0))H.options.timeout=z;if(this.idempotencyHeader&&U!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();_[this.idempotencyHeader]=$.idempotencyKey}let F=this.buildHeaders({options:W,headers:_,contentLength:G,retryCount:T});return{req:{method:U,...w&&{body:w},headers:F,...H&&{agent:H},signal:W.signal??null},url:J,timeout:W.timeout}}buildHeaders({options:$,headers:T,contentLength:W,retryCount:U}){let X={};if(W)X["content-length"]=W;let Y=this.defaultHeaders($);if(TO(X,Y),TO(X,T),l9($.body)&&Y0!=="node")delete X["content-type"];if(JY(Y,"x-stainless-retry-count")===void 0&&JY(T,"x-stainless-retry-count")===void 0)X["x-stainless-retry-count"]=String(U);if(JY(Y,"x-stainless-timeout")===void 0&&JY(T,"x-stainless-timeout")===void 0&&$.timeout)X["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(X,T),X}async prepareOptions($){}async prepareRequest($,{url:T,options:W}){}parseHeaders($){return!$?{}:(Symbol.iterator in $)?Object.fromEntries(Array.from($).map((T)=>[...T])):{...$}}makeStatusError($,T,W,U){return a$.generate($,T,W,U)}request($,T=null){return new GY(this.makeRequest($,T))}async makeRequest($,T){let W=await $,U=W.maxRetries??this.maxRetries;if(T==null)T=U;await this.prepareOptions(W);let{req:X,url:Y,timeout:_}=this.buildRequest(W,{retryCount:U-T});if(await this.prepareRequest(X,{url:Y,options:W}),n6("request",Y,W,X.headers),W.signal?.aborted)throw new Y4;let w=new AbortController,G=await this.fetchWithTimeout(Y,X,_,w).catch(YY);if(G instanceof Error){if(W.signal?.aborted)throw new Y4;if(T)return this.retryRequest(W,T);if(G.name==="AbortError")throw new w0;throw new _0({cause:G})}let J=u9(G.headers);if(!G.ok){if(T&&this.shouldRetry(G)){let K=`retrying, ${T} attempts remaining`;return n6(`response (error; ${K})`,G.status,Y,J),this.retryRequest(W,T,J)}let H=await G.text().catch((K)=>YY(K).message),z=KI(H),F=z?void 0:H;throw n6(`response (error; ${T?"(error; no more retries left)":"(error; not retryable)"})`,G.status,Y,J,F),this.makeStatusError(G.status,z,F,J)}return{response:G,options:W,controller:w}}requestAPIList($,T){let W=this.makeRequest(T,null);return new YO(this,W,$)}buildURL($,T){let W=AI($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),U=this.defaultQuery();if(!_O(U))T={...U,...T};if(typeof T==="object"&&T&&!Array.isArray(T))W.search=this.stringifyQuery(T);return W.toString()}stringifyQuery($){return Object.entries($).filter(([T,W])=>typeof W!=="undefined").map(([T,W])=>{if(typeof W==="string"||typeof W==="number"||typeof W==="boolean")return`${encodeURIComponent(T)}=${encodeURIComponent(W)}`;if(W===null)return`${encodeURIComponent(T)}=`;throw new l(`Cannot stringify type ${typeof W}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout($,T,W,U){let{signal:X,...Y}=T||{};if(X)X.addEventListener("abort",()=>U.abort());let _=setTimeout(()=>U.abort(),W),w={signal:U.signal,...Y};if(w.method)w.method=w.method.toUpperCase();return this.fetch.call(void 0,$,w).finally(()=>{clearTimeout(_)})}shouldRetry($){let T=$.headers.get("x-should-retry");if(T==="true")return!0;if(T==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,T,W){let U,X=W?.["retry-after-ms"];if(X){let _=parseFloat(X);if(!Number.isNaN(_))U=_}let Y=W?.["retry-after"];if(Y&&!U){let _=parseFloat(Y);if(!Number.isNaN(_))U=_*1000;else U=Date.parse(Y)-Date.now()}if(!(U&&0<=U&&U<60000)){let _=$.maxRetries??this.maxRetries;U=this.calculateDefaultRetryTimeoutMillis(T,_)}return await t6(U),this.makeRequest($,T-1)}calculateDefaultRetryTimeoutMillis($,T){let X=T-$,Y=Math.min(0.5*Math.pow(2,X),8),_=1-Math.random()*0.25;return Y*_*1000}getUserAgent(){return`${this.constructor.name}/JS ${X0}`}}class zY{constructor($,T,W,U){wY.set(this,void 0),FI(this,wY,$,"f"),this.options=U,this.response=T,this.body=W}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageInfo()!=null}async getNextPage(){let $=this.nextPageInfo();if(!$)throw new l("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let T={...this.options};if("params"in $&&typeof T.query==="object")T.query={...T.query,...$.params};else if("url"in $){let W=[...Object.entries(T.query||{}),...$.url.searchParams.entries()];for(let[U,X]of W)$.url.searchParams.set(U,X);T.query=void 0,T.path=$.url.toString()}return await OI(this,wY,"f").requestAPIList(this.constructor,T)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(wY=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let T of $.getPaginatedItems())yield T}}class YO extends GY{constructor($,T,W){super(T,async(U)=>new W($,U.response,await UO(U),U.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let T of $)yield T}}var u9=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(T,W){let U=W.toString();return T[U.toLowerCase()]||T[U]}})},DI={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__metadata:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},W$=($)=>{return typeof $==="object"&&$!==null&&!_O($)&&Object.keys($).every((T)=>wO(DI,T))},QI=()=>{if(typeof Deno!=="undefined"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":X0,"X-Stainless-OS":eF(Deno.build.os),"X-Stainless-Arch":sF(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime!=="undefined")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":X0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process!=="undefined"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":X0,"X-Stainless-OS":eF(process.platform),"X-Stainless-Arch":sF(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let $=ZI();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":X0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":X0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ZI(){if(typeof navigator==="undefined"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:T,pattern:W}of $){let U=W.exec(navigator.userAgent);if(U){let X=U[1]||0,Y=U[2]||0,_=U[3]||0;return{browser:T,version:`${X}.${Y}.${_}`}}}return null}var sF=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},eF=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},$O,VI=()=>{return $O??($O=QI())},KI=($)=>{try{return JSON.parse($)}catch(T){return}},EI=/^[a-z][a-z0-9+.-]*:/i,AI=($)=>{return EI.test($)},t6=($)=>new Promise((T)=>setTimeout(T,$)),r9=($,T)=>{if(typeof T!=="number"||!Number.isInteger(T))throw new l(`${$} must be an integer`);if(T<0)throw new l(`${$} must be a positive integer`);return T},YY=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null)try{return new Error(JSON.stringify($))}catch{}return new Error($)};var T2=($)=>{if(typeof process!=="undefined")return process.env?.[$]?.trim()??void 0;if(typeof Deno!=="undefined")return Deno.env?.get?.($)?.trim();return};function _O($){if(!$)return!0;for(let T in $)return!1;return!0}function wO($,T){return Object.prototype.hasOwnProperty.call($,T)}function TO($,T){for(let W in T){if(!wO(T,W))continue;let U=W.toLowerCase();if(!U)continue;let X=T[W];if(X===null)delete $[U];else if(X!==void 0)$[U]=X}}var WO=new Set(["authorization","api-key"]);function n6($,...T){if(typeof process!=="undefined"&&process?.env?.DEBUG==="true"){let W=T.map((U)=>{if(!U)return U;if(U.headers){let Y={...U,headers:{...U.headers}};for(let _ in U.headers)if(WO.has(_.toLowerCase()))Y.headers[_]="REDACTED";return Y}let X=null;for(let Y in U)if(WO.has(Y.toLowerCase()))X??(X={...U}),X[Y]="REDACTED";return X??U});console.log(`OpenAI:DEBUG:${$}`,...W)}}var MI=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let T=Math.random()*16|0;return($==="x"?T:T&3|8).toString(16)})},JO=()=>{return typeof window!=="undefined"&&typeof window.document!=="undefined"&&typeof navigator!=="undefined"},NI=($)=>{return typeof $?.get==="function"};var JY=($,T)=>{let W=T.toLowerCase();if(NI($)){let U=T[0]?.toUpperCase()+T.substring(1).replace(/([^\w])(\w)/g,(X,Y,_)=>Y+_.toUpperCase());for(let X of[T,W,T.toUpperCase(),U]){let Y=$.get(X);if(Y)return Y}}for(let[U,X]of Object.entries($))if(U.toLowerCase()===W){if(Array.isArray(X)){if(X.length<=1)return X[0];return console.warn(`Received ${X.length} entries for the ${T} header, using the first entry.`),X[0]}return X}return};var GO=($)=>{if(typeof Buffer!=="undefined"){let T=Buffer.from($,"base64");return Array.from(new Float32Array(T.buffer,T.byteOffset,T.length/Float32Array.BYTES_PER_ELEMENT))}else{let T=atob($),W=T.length,U=new Uint8Array(W);for(let X=0;X<W;X++)U[X]=T.charCodeAt(X);return Array.from(new Float32Array(U.buffer))}};function W2($){return $!=null&&typeof $==="object"&&!Array.isArray($)}class s6 extends zY{constructor($,T,W,U){super($,T,W,U);this.data=W.data||[],this.object=W.object}getPaginatedItems(){return this.data??[]}nextPageParams(){return null}nextPageInfo(){return null}}class F$ extends zY{constructor($,T,W,U){super($,T,W,U);this.data=W.data||[],this.has_more=W.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageParams(){let $=this.nextPageInfo();if(!$)return null;if("params"in $)return $.params;let T=Object.fromEntries($.url.searchParams);if(!Object.keys(T).length)return null;return T}nextPageInfo(){let $=this.getPaginatedItems();if(!$.length)return null;let T=$[$.length-1]?.id;if(!T)return null;return{params:{after:T}}}}class P{constructor($){this._client=$}}class U2 extends P{list($,T={},W){if(W$(T))return this.list($,{},T);return this._client.getAPIList(`/chat/completions/${$}/messages`,n9,{query:T,...W})}}class G0 extends P{constructor(){super(...arguments);this.messages=new U2(this._client)}create($,T){return this._client.post("/chat/completions",{body:$,...T,stream:$.stream??!1})}retrieve($,T){return this._client.get(`/chat/completions/${$}`,T)}update($,T,W){return this._client.post(`/chat/completions/${$}`,{body:T,...W})}list($={},T){if(W$($))return this.list({},$);return this._client.getAPIList("/chat/completions",z0,{query:$,...T})}del($,T){return this._client.delete(`/chat/completions/${$}`,T)}}class z0 extends F${}class n9 extends F${}G0.ChatCompletionsPage=z0;G0.Messages=U2;class q1 extends P{constructor(){super(...arguments);this.completions=new G0(this._client)}}q1.Completions=G0;q1.ChatCompletionsPage=z0;class X2 extends P{create($,T){return this._client.post("/audio/speech",{body:$,...T,headers:{Accept:"application/octet-stream",...T?.headers},__binaryResponse:!0})}}class Y2 extends P{create($,T){return this._client.post("/audio/transcriptions",y4({body:$,...T,stream:$.stream??!1,__metadata:{model:$.model}}))}}class _2 extends P{create($,T){return this._client.post("/audio/translations",y4({body:$,...T,__metadata:{model:$.model}}))}}class e6 extends P{constructor(){super(...arguments);this.transcriptions=new Y2(this._client),this.translations=new _2(this._client),this.speech=new X2(this._client)}}e6.Transcriptions=Y2;e6.Translations=_2;e6.Speech=X2;class H0 extends P{create($,T){return this._client.post("/batches",{body:$,...T})}retrieve($,T){return this._client.get(`/batches/${$}`,T)}list($={},T){if(W$($))return this.list({},$);return this._client.getAPIList("/batches",XT,{query:$,...T})}cancel($,T){return this._client.post(`/batches/${$}/cancel`,T)}}class XT extends F${}H0.BatchesPage=XT;var E6=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},p$=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},t9,HY,FY,w2,J2,OY,G2,$1,z2,DY,QY,YT,zO;class F0{constructor(){t9.add(this),this.controller=new AbortController,HY.set(this,void 0),FY.set(this,()=>{}),w2.set(this,()=>{}),J2.set(this,void 0),OY.set(this,()=>{}),G2.set(this,()=>{}),$1.set(this,{}),z2.set(this,!1),DY.set(this,!1),QY.set(this,!1),YT.set(this,!1),E6(this,HY,new Promise(($,T)=>{E6(this,FY,$,"f"),E6(this,w2,T,"f")}),"f"),E6(this,J2,new Promise(($,T)=>{E6(this,OY,$,"f"),E6(this,G2,T,"f")}),"f"),p$(this,HY,"f").catch(()=>{}),p$(this,J2,"f").catch(()=>{})}_run($){setTimeout(()=>{$().then(()=>{this._emitFinal(),this._emit("end")},p$(this,t9,"m",zO).bind(this))},0)}_connected(){if(this.ended)return;p$(this,FY,"f").call(this),this._emit("connect")}get ended(){return p$(this,z2,"f")}get errored(){return p$(this,DY,"f")}get aborted(){return p$(this,QY,"f")}abort(){this.controller.abort()}on($,T){return(p$(this,$1,"f")[$]||(p$(this,$1,"f")[$]=[])).push({listener:T}),this}off($,T){let W=p$(this,$1,"f")[$];if(!W)return this;let U=W.findIndex((X)=>X.listener===T);if(U>=0)W.splice(U,1);return this}once($,T){return(p$(this,$1,"f")[$]||(p$(this,$1,"f")[$]=[])).push({listener:T,once:!0}),this}emitted($){return new Promise((T,W)=>{if(E6(this,YT,!0,"f"),$!=="error")this.once("error",W);this.once($,T)})}async done(){E6(this,YT,!0,"f"),await p$(this,J2,"f")}_emit($,...T){if(p$(this,z2,"f"))return;if($==="end")E6(this,z2,!0,"f"),p$(this,OY,"f").call(this);let W=p$(this,$1,"f")[$];if(W)p$(this,$1,"f")[$]=W.filter((U)=>!U.once),W.forEach(({listener:U})=>U(...T));if($==="abort"){let U=T[0];if(!p$(this,YT,"f")&&!W?.length)Promise.reject(U);p$(this,w2,"f").call(this,U),p$(this,G2,"f").call(this,U),this._emit("end");return}if($==="error"){let U=T[0];if(!p$(this,YT,"f")&&!W?.length)Promise.reject(U);p$(this,w2,"f").call(this,U),p$(this,G2,"f").call(this,U),this._emit("end")}}_emitFinal(){}}HY=new WeakMap,FY=new WeakMap,w2=new WeakMap,J2=new WeakMap,OY=new WeakMap,G2=new WeakMap,$1=new WeakMap,z2=new WeakMap,DY=new WeakMap,QY=new WeakMap,YT=new WeakMap,t9=new WeakSet,zO=function $(T){if(E6(this,DY,!0,"f"),T instanceof Error&&T.name==="AbortError")T=new Y4;if(T instanceof Y4)return E6(this,QY,!0,"f"),this._emit("abort",T);if(T instanceof l)return this._emit("error",T);if(T instanceof Error){let W=new l(T.message);return W.cause=T,this._emit("error",W)}return this._emit("error",new l(String(T)))};var r=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},s4=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},Z4,a9,b6,ZY,A6,D0,_T,O0,EY,e4,VY,KY,O2,H2,F2,HO,FO,OO,DO,QO,ZO,VO;class $6 extends F0{constructor(){super(...arguments);Z4.add(this),a9.set(this,[]),b6.set(this,{}),ZY.set(this,{}),A6.set(this,void 0),D0.set(this,void 0),_T.set(this,void 0),O0.set(this,void 0),EY.set(this,void 0),e4.set(this,void 0),VY.set(this,void 0),KY.set(this,void 0),O2.set(this,void 0)}[(a9=new WeakMap,b6=new WeakMap,ZY=new WeakMap,A6=new WeakMap,D0=new WeakMap,_T=new WeakMap,O0=new WeakMap,EY=new WeakMap,e4=new WeakMap,VY=new WeakMap,KY=new WeakMap,O2=new WeakMap,Z4=new WeakSet,Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(U)=>{let X=T.shift();if(X)X.resolve(U);else $.push(U)}),this.on("end",()=>{W=!0;for(let U of T)U.resolve(void 0);T.length=0}),this.on("abort",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),this.on("error",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((X,Y)=>T.push({resolve:X,reject:Y})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream($){let T=new $6;return T._run(()=>T._fromReadableStream($)),T}async _fromReadableStream($,T){let W=T?.signal;if(W){if(W.aborted)this.controller.abort();W.addEventListener("abort",()=>this.controller.abort())}this._connected();let U=a4.fromReadableStream($,this.controller);for await(let X of U)r(this,Z4,"m",H2).call(this,X);if(U.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,Z4,"m",F2).call(this))}toReadableStream(){return new a4(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream($,T,W,U,X){let Y=new $6;return Y._run(()=>Y._runToolAssistantStream($,T,W,U,{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),Y}async _createToolAssistantStream($,T,W,U,X){let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}let _={...U,stream:!0},w=await $.submitToolOutputs(T,W,_,{...X,signal:this.controller.signal});this._connected();for await(let G of w)r(this,Z4,"m",H2).call(this,G);if(w.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,Z4,"m",F2).call(this))}static createThreadAssistantStream($,T,W){let U=new $6;return U._run(()=>U._threadAssistantStream($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),U}static createAssistantStream($,T,W,U){let X=new $6;return X._run(()=>X._runAssistantStream($,T,W,{...U,headers:{...U?.headers,"X-Stainless-Helper-Method":"stream"}})),X}currentEvent(){return r(this,VY,"f")}currentRun(){return r(this,KY,"f")}currentMessageSnapshot(){return r(this,A6,"f")}currentRunStepSnapshot(){return r(this,O2,"f")}async finalRunSteps(){return await this.done(),Object.values(r(this,b6,"f"))}async finalMessages(){return await this.done(),Object.values(r(this,ZY,"f"))}async finalRun(){if(await this.done(),!r(this,D0,"f"))throw Error("Final run was not received.");return r(this,D0,"f")}async _createThreadAssistantStream($,T,W){let U=W?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}let X={...T,stream:!0},Y=await $.createAndRun(X,{...W,signal:this.controller.signal});this._connected();for await(let _ of Y)r(this,Z4,"m",H2).call(this,_);if(Y.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,Z4,"m",F2).call(this))}async _createAssistantStream($,T,W,U){let X=U?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}let Y={...W,stream:!0},_=await $.create(T,Y,{...U,signal:this.controller.signal});this._connected();for await(let w of _)r(this,Z4,"m",H2).call(this,w);if(_.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,Z4,"m",F2).call(this))}static accumulateDelta($,T){for(let[W,U]of Object.entries(T)){if(!$.hasOwnProperty(W)){$[W]=U;continue}let X=$[W];if(X===null||X===void 0){$[W]=U;continue}if(W==="index"||W==="type"){$[W]=U;continue}if(typeof X==="string"&&typeof U==="string")X+=U;else if(typeof X==="number"&&typeof U==="number")X+=U;else if(W2(X)&&W2(U))X=this.accumulateDelta(X,U);else if(Array.isArray(X)&&Array.isArray(U)){if(X.every((Y)=>typeof Y==="string"||typeof Y==="number")){X.push(...U);continue}for(let Y of U){if(!W2(Y))throw new Error(`Expected array delta entry to be an object but got: ${Y}`);let _=Y.index;if(_==null)throw console.error(Y),new Error("Expected array delta entry to have an `index` property");if(typeof _!=="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${_}`);let w=X[_];if(w==null)X.push(Y);else X[_]=this.accumulateDelta(w,Y)}continue}else throw Error(`Unhandled record type: ${W}, deltaValue: ${U}, accValue: ${X}`);$[W]=X}return $}_addRun($){return $}async _threadAssistantStream($,T,W){return await this._createThreadAssistantStream(T,$,W)}async _runAssistantStream($,T,W,U){return await this._createAssistantStream(T,$,W,U)}async _runToolAssistantStream($,T,W,U,X){return await this._createToolAssistantStream(W,$,T,U,X)}}H2=function $(T){if(this.ended)return;switch(s4(this,VY,T,"f"),r(this,Z4,"m",OO).call(this,T),T.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":r(this,Z4,"m",VO).call(this,T);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":r(this,Z4,"m",FO).call(this,T);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":r(this,Z4,"m",HO).call(this,T);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");default:kI(T)}},F2=function $(){if(this.ended)throw new l("stream has ended, this shouldn't happen");if(!r(this,D0,"f"))throw Error("Final run has not been received");return r(this,D0,"f")},HO=function $(T){let[W,U]=r(this,Z4,"m",QO).call(this,T,r(this,A6,"f"));s4(this,A6,W,"f"),r(this,ZY,"f")[W.id]=W;for(let X of U){let Y=W.content[X.index];if(Y?.type=="text")this._emit("textCreated",Y.text)}switch(T.event){case"thread.message.created":this._emit("messageCreated",T.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",T.data.delta,W),T.data.delta.content)for(let X of T.data.delta.content){if(X.type=="text"&&X.text){let Y=X.text,_=W.content[X.index];if(_&&_.type=="text")this._emit("textDelta",Y,_.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(X.index!=r(this,_T,"f")){if(r(this,O0,"f"))switch(r(this,O0,"f").type){case"text":this._emit("textDone",r(this,O0,"f").text,r(this,A6,"f"));break;case"image_file":this._emit("imageFileDone",r(this,O0,"f").image_file,r(this,A6,"f"));break}s4(this,_T,X.index,"f")}s4(this,O0,W.content[X.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(r(this,_T,"f")!==void 0){let X=T.data.content[r(this,_T,"f")];if(X)switch(X.type){case"image_file":this._emit("imageFileDone",X.image_file,r(this,A6,"f"));break;case"text":this._emit("textDone",X.text,r(this,A6,"f"));break}}if(r(this,A6,"f"))this._emit("messageDone",T.data);s4(this,A6,void 0,"f")}},FO=function $(T){let W=r(this,Z4,"m",DO).call(this,T);switch(s4(this,O2,W,"f"),T.event){case"thread.run.step.created":this._emit("runStepCreated",T.data);break;case"thread.run.step.delta":let U=T.data.delta;if(U.step_details&&U.step_details.type=="tool_calls"&&U.step_details.tool_calls&&W.step_details.type=="tool_calls")for(let Y of U.step_details.tool_calls)if(Y.index==r(this,EY,"f"))this._emit("toolCallDelta",Y,W.step_details.tool_calls[Y.index]);else{if(r(this,e4,"f"))this._emit("toolCallDone",r(this,e4,"f"));if(s4(this,EY,Y.index,"f"),s4(this,e4,W.step_details.tool_calls[Y.index],"f"),r(this,e4,"f"))this._emit("toolCallCreated",r(this,e4,"f"))}this._emit("runStepDelta",T.data.delta,W);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":if(s4(this,O2,void 0,"f"),T.data.step_details.type=="tool_calls"){if(r(this,e4,"f"))this._emit("toolCallDone",r(this,e4,"f")),s4(this,e4,void 0,"f")}this._emit("runStepDone",T.data,W);break;case"thread.run.step.in_progress":break}},OO=function $(T){r(this,a9,"f").push(T),this._emit("event",T)},DO=function $(T){switch(T.event){case"thread.run.step.created":return r(this,b6,"f")[T.data.id]=T.data,T.data;case"thread.run.step.delta":let W=r(this,b6,"f")[T.data.id];if(!W)throw Error("Received a RunStepDelta before creation of a snapshot");let U=T.data;if(U.delta){let X=$6.accumulateDelta(W,U.delta);r(this,b6,"f")[T.data.id]=X}return r(this,b6,"f")[T.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":r(this,b6,"f")[T.data.id]=T.data;break}if(r(this,b6,"f")[T.data.id])return r(this,b6,"f")[T.data.id];throw new Error("No snapshot available")},QO=function $(T,W){let U=[];switch(T.event){case"thread.message.created":return[T.data,U];case"thread.message.delta":if(!W)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let X=T.data;if(X.delta.content)for(let Y of X.delta.content)if(Y.index in W.content){let _=W.content[Y.index];W.content[Y.index]=r(this,Z4,"m",ZO).call(this,Y,_)}else W.content[Y.index]=Y,U.push(Y);return[W,U];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(W)return[W,U];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},ZO=function $(T,W){return $6.accumulateDelta(W,T)},VO=function $(T){switch(s4(this,KY,T.data,"f"),T.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":if(s4(this,D0,T.data,"f"),r(this,e4,"f"))this._emit("toolCallDone",r(this,e4,"f")),s4(this,e4,void 0,"f");break;case"thread.run.cancelling":break}};function kI($){}class wT extends P{create($,T){return this._client.post("/assistants",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}retrieve($,T){return this._client.get(`/assistants/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}update($,T,W){return this._client.post(`/assistants/${$}`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}list($={},T){if(W$($))return this.list({},$);return this._client.getAPIList("/assistants",D2,{query:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}del($,T){return this._client.delete(`/assistants/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class D2 extends F${}wT.AssistantsPage=D2;function s9($){return typeof $.parse==="function"}var P1=($)=>{return $?.role==="assistant"},e9=($)=>{return $?.role==="function"},$z=($)=>{return $?.role==="tool"};function Q2($){return $?.$brand==="auto-parseable-response-format"}function Q0($){return $?.$brand==="auto-parseable-tool"}function KO($,T){if(!T||!Tz(T))return{...$,choices:$.choices.map((W)=>({...W,message:{...W.message,parsed:null,...W.message.tool_calls?{tool_calls:W.message.tool_calls}:void 0}}))};return Z2($,T)}function Z2($,T){let W=$.choices.map((U)=>{if(U.finish_reason==="length")throw new sW;if(U.finish_reason==="content_filter")throw new eW;return{...U,message:{...U.message,...U.message.tool_calls?{tool_calls:U.message.tool_calls?.map((X)=>PI(T,X))??void 0}:void 0,parsed:U.message.content&&!U.message.refusal?qI(T,U.message.content):null}}});return{...$,choices:W}}function qI($,T){if($.response_format?.type!=="json_schema")return null;if($.response_format?.type==="json_schema"){if("$parseRaw"in $.response_format)return $.response_format.$parseRaw(T);return JSON.parse(T)}return null}function PI($,T){let W=$.tools?.find((U)=>U.function?.name===T.function.name);return{...T,function:{...T.function,parsed_arguments:Q0(W)?W.$parseRaw(T.function.arguments):W?.function.strict?JSON.parse(T.function.arguments):null}}}function EO($,T){if(!$)return!1;let W=$.tools?.find((U)=>U.function?.name===T.function.name);return Q0(W)||W?.function.strict||!1}function Tz($){if(Q2($.response_format))return!0;return $.tools?.some((T)=>Q0(T)||T.type==="function"&&T.function.strict===!0)??!1}function AO($){for(let T of $??[]){if(T.type!=="function")throw new l(`Currently only \`function\` tool types support auto-parsing; Received \`${T.type}\``);if(T.function.strict!==!0)throw new l(`The \`${T.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var h4=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},M4,Wz,AY,Uz,Xz,Yz,NO,_z,MO=10;class V2 extends F0{constructor(){super(...arguments);M4.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion($){this._chatCompletions.push($),this._emit("chatCompletion",$);let T=$.choices[0]?.message;if(T)this._addMessage(T);return $}_addMessage($,T=!0){if(!("content"in $))$.content=null;if(this.messages.push($),T){if(this._emit("message",$),(e9($)||$z($))&&$.content)this._emit("functionCallResult",$.content);else if(P1($)&&$.function_call)this._emit("functionCall",$.function_call);else if(P1($)&&$.tool_calls){for(let W of $.tool_calls)if(W.type==="function")this._emit("functionCall",W.function)}}}async finalChatCompletion(){await this.done();let $=this._chatCompletions[this._chatCompletions.length-1];if(!$)throw new l("stream ended without producing a ChatCompletion");return $}async finalContent(){return await this.done(),h4(this,M4,"m",Wz).call(this)}async finalMessage(){return await this.done(),h4(this,M4,"m",AY).call(this)}async finalFunctionCall(){return await this.done(),h4(this,M4,"m",Uz).call(this)}async finalFunctionCallResult(){return await this.done(),h4(this,M4,"m",Xz).call(this)}async totalUsage(){return await this.done(),h4(this,M4,"m",Yz).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let $=this._chatCompletions[this._chatCompletions.length-1];if($)this._emit("finalChatCompletion",$);let T=h4(this,M4,"m",AY).call(this);if(T)this._emit("finalMessage",T);let W=h4(this,M4,"m",Wz).call(this);if(W)this._emit("finalContent",W);let U=h4(this,M4,"m",Uz).call(this);if(U)this._emit("finalFunctionCall",U);let X=h4(this,M4,"m",Xz).call(this);if(X!=null)this._emit("finalFunctionCallResult",X);if(this._chatCompletions.some((Y)=>Y.usage))this._emit("totalUsage",h4(this,M4,"m",Yz).call(this))}async _createChatCompletion($,T,W){let U=W?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}h4(this,M4,"m",NO).call(this,T);let X=await $.chat.completions.create({...T,stream:!1},{...W,signal:this.controller.signal});return this._connected(),this._addChatCompletion(Z2(X,T))}async _runChatCompletion($,T,W){for(let U of T.messages)this._addMessage(U,!1);return await this._createChatCompletion($,T,W)}async _runFunctions($,T,W){let{function_call:X="auto",stream:Y,..._}=T,w=typeof X!=="string"&&X?.name,{maxChatCompletions:G=MO}=W||{},J={};for(let z of T.functions)J[z.name||z.function.name]=z;let H=T.functions.map((z)=>({name:z.name||z.function.name,parameters:z.parameters,description:z.description}));for(let z of T.messages)this._addMessage(z,!1);for(let z=0;z<G;++z){let Q=(await this._createChatCompletion($,{..._,function_call:X,functions:H,messages:[...this.messages]},W)).choices[0]?.message;if(!Q)throw new l("missing message in ChatCompletion response");if(!Q.function_call)return;let{name:V,arguments:K}=Q.function_call,I=J[V];if(!I){let q=`Invalid function_call: ${JSON.stringify(V)}. Available options are: ${H.map((y)=>JSON.stringify(y.name)).join(", ")}. Please try again`;this._addMessage({role:"function",name:V,content:q});continue}else if(w&&w!==V){let q=`Invalid function_call: ${JSON.stringify(V)}. ${JSON.stringify(w)} requested. Please try again`;this._addMessage({role:"function",name:V,content:q});continue}let k;try{k=s9(I)?await I.parse(K):K}catch(q){this._addMessage({role:"function",name:V,content:q instanceof Error?q.message:String(q)});continue}let N=await I.function(k,this),L=h4(this,M4,"m",_z).call(this,N);if(this._addMessage({role:"function",name:V,content:L}),w)return}}async _runTools($,T,W){let{tool_choice:X="auto",stream:Y,..._}=T,w=typeof X!=="string"&&X?.function?.name,{maxChatCompletions:G=MO}=W||{},J=T.tools.map((F)=>{if(Q0(F)){if(!F.$callback)throw new l("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:F.$callback,name:F.function.name,description:F.function.description||"",parameters:F.function.parameters,parse:F.$parseRaw,strict:!0}}}return F}),H={};for(let F of J)if(F.type==="function")H[F.function.name||F.function.function.name]=F.function;let z="tools"in T?J.map((F)=>F.type==="function"?{type:"function",function:{name:F.function.name||F.function.function.name,parameters:F.function.parameters,description:F.function.description,strict:F.function.strict}}:F):void 0;for(let F of T.messages)this._addMessage(F,!1);for(let F=0;F<G;++F){let V=(await this._createChatCompletion($,{..._,tool_choice:X,tools:z,messages:[...this.messages]},W)).choices[0]?.message;if(!V)throw new l("missing message in ChatCompletion response");if(!V.tool_calls?.length)return;for(let K of V.tool_calls){if(K.type!=="function")continue;let I=K.id,{name:k,arguments:N}=K.function,L=H[k];if(!L){let u=`Invalid tool_call: ${JSON.stringify(k)}. Available options are: ${Object.keys(H).map((w$)=>JSON.stringify(w$)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:I,content:u});continue}else if(w&&w!==k){let u=`Invalid tool_call: ${JSON.stringify(k)}. ${JSON.stringify(w)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:I,content:u});continue}let q;try{q=s9(L)?await L.parse(N):N}catch(u){let w$=u instanceof Error?u.message:String(u);this._addMessage({role:"tool",tool_call_id:I,content:w$});continue}let y=await L.function(q,this),x=h4(this,M4,"m",_z).call(this,y);if(this._addMessage({role:"tool",tool_call_id:I,content:x}),w)return}}return}}M4=new WeakSet,Wz=function $(){return h4(this,M4,"m",AY).call(this).content??null},AY=function $(){let T=this.messages.length;while(T-- >0){let W=this.messages[T];if(P1(W)){let{function_call:U,...X}=W,Y={...X,content:W.content??null,refusal:W.refusal??null};if(U)Y.function_call=U;return Y}}throw new l("stream ended without producing a ChatCompletionMessage with role=assistant")},Uz=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(P1(W)&&W?.function_call)return W.function_call;if(P1(W)&&W?.tool_calls?.length)return W.tool_calls.at(-1)?.function}return},Xz=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(e9(W)&&W.content!=null)return W.content;if($z(W)&&W.content!=null&&typeof W.content==="string"&&this.messages.some((U)=>U.role==="assistant"&&U.tool_calls?.some((X)=>X.type==="function"&&X.id===W.tool_call_id)))return W.content}return},Yz=function $(){let T={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:W}of this._chatCompletions)if(W)T.completion_tokens+=W.completion_tokens,T.prompt_tokens+=W.prompt_tokens,T.total_tokens+=W.total_tokens;return T},NO=function $(T){if(T.n!=null&&T.n>1)throw new l("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},_z=function $(T){return typeof T==="string"?T:T===void 0?"undefined":JSON.stringify(T)};class JT extends V2{static runFunctions($,T,W){let U=new JT,X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return U._run(()=>U._runFunctions($,T,X)),U}static runTools($,T,W){let U=new JT,X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return U._run(()=>U._runTools($,T,X)),U}_addMessage($,T=!0){if(super._addMessage($,T),P1($)&&$.content)this._emit("content",$.content)}}var F4={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511};class LO extends Error{}class SO extends Error{}function CI($,T=F4.ALL){if(typeof $!=="string")throw new TypeError(`expecting str, got ${typeof $}`);if(!$.trim())throw new Error(`${$} is empty`);return jI($.trim(),T)}var jI=($,T)=>{let W=$.length,U=0,X=(F)=>{throw new LO(`${F} at position ${U}`)},Y=(F)=>{throw new SO(`${F} at position ${U}`)},_=()=>{if(z(),U>=W)X("Unexpected end of input");if($[U]==='"')return w();if($[U]==="{")return G();if($[U]==="[")return J();if($.substring(U,U+4)==="null"||F4.NULL&T&&W-U<4&&"null".startsWith($.substring(U)))return U+=4,null;if($.substring(U,U+4)==="true"||F4.BOOL&T&&W-U<4&&"true".startsWith($.substring(U)))return U+=4,!0;if($.substring(U,U+5)==="false"||F4.BOOL&T&&W-U<5&&"false".startsWith($.substring(U)))return U+=5,!1;if($.substring(U,U+8)==="Infinity"||F4.INFINITY&T&&W-U<8&&"Infinity".startsWith($.substring(U)))return U+=8,1/0;if($.substring(U,U+9)==="-Infinity"||F4.MINUS_INFINITY&T&&1<W-U&&W-U<9&&"-Infinity".startsWith($.substring(U)))return U+=9,-1/0;if($.substring(U,U+3)==="NaN"||F4.NAN&T&&W-U<3&&"NaN".startsWith($.substring(U)))return U+=3,NaN;return H()},w=()=>{let F=U,Q=!1;U++;while(U<W&&($[U]!=='"'||Q&&$[U-1]==="\\"))Q=$[U]==="\\"?!Q:!1,U++;if($.charAt(U)=='"')try{return JSON.parse($.substring(F,++U-Number(Q)))}catch(V){Y(String(V))}else if(F4.STR&T)try{return JSON.parse($.substring(F,U-Number(Q))+'"')}catch(V){return JSON.parse($.substring(F,$.lastIndexOf("\\"))+'"')}X("Unterminated string literal")},G=()=>{U++,z();let F={};try{while($[U]!=="}"){if(z(),U>=W&&F4.OBJ&T)return F;let Q=w();z(),U++;try{let V=_();Object.defineProperty(F,Q,{value:V,writable:!0,enumerable:!0,configurable:!0})}catch(V){if(F4.OBJ&T)return F;else throw V}if(z(),$[U]===",")U++}}catch(Q){if(F4.OBJ&T)return F;else X("Expected '}' at end of object")}return U++,F},J=()=>{U++;let F=[];try{while($[U]!=="]")if(F.push(_()),z(),$[U]===",")U++}catch(Q){if(F4.ARR&T)return F;X("Expected ']' at end of array")}return U++,F},H=()=>{if(U===0){if($==="-"&&F4.NUM&T)X("Not sure what '-' is");try{return JSON.parse($)}catch(Q){if(F4.NUM&T)try{if($[$.length-1]===".")return JSON.parse($.substring(0,$.lastIndexOf(".")));return JSON.parse($.substring(0,$.lastIndexOf("e")))}catch(V){}Y(String(Q))}}let F=U;if($[U]==="-")U++;while($[U]&&!",]}".includes($[U]))U++;if(U==W&&!(F4.NUM&T))X("Unterminated number literal");try{return JSON.parse($.substring(F,U))}catch(Q){if($.substring(F,U)==="-"&&F4.NUM&T)X("Not sure what '-' is");try{return JSON.parse($.substring(F,$.lastIndexOf("e")))}catch(V){Y(String(V))}}},z=()=>{while(U<W&&`
66
- \r `.includes($[U]))U++};return _()},wz=($)=>CI($,F4.ALL^F4.NUM);var GT=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},L$=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},_4,T1,zT,C1,Jz,MY,Gz,zz,Hz,NY,Fz,BO;class Z0 extends V2{constructor($){super();_4.add(this),T1.set(this,void 0),zT.set(this,void 0),C1.set(this,void 0),GT(this,T1,$,"f"),GT(this,zT,[],"f")}get currentChatCompletionSnapshot(){return L$(this,C1,"f")}static fromReadableStream($){let T=new Z0(null);return T._run(()=>T._fromReadableStream($)),T}static createChatCompletion($,T,W){let U=new Z0(T);return U._run(()=>U._runChatCompletion($,{...T,stream:!0},{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),U}async _createChatCompletion($,T,W){super._createChatCompletion;let U=W?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}L$(this,_4,"m",Jz).call(this);let X=await $.chat.completions.create({...T,stream:!0},{...W,signal:this.controller.signal});this._connected();for await(let Y of X)L$(this,_4,"m",Gz).call(this,Y);if(X.controller.signal?.aborted)throw new Y4;return this._addChatCompletion(L$(this,_4,"m",NY).call(this))}async _fromReadableStream($,T){let W=T?.signal;if(W){if(W.aborted)this.controller.abort();W.addEventListener("abort",()=>this.controller.abort())}L$(this,_4,"m",Jz).call(this),this._connected();let U=a4.fromReadableStream($,this.controller),X;for await(let Y of U){if(X&&X!==Y.id)this._addChatCompletion(L$(this,_4,"m",NY).call(this));L$(this,_4,"m",Gz).call(this,Y),X=Y.id}if(U.controller.signal?.aborted)throw new Y4;return this._addChatCompletion(L$(this,_4,"m",NY).call(this))}[(T1=new WeakMap,zT=new WeakMap,C1=new WeakMap,_4=new WeakSet,Jz=function $(){if(this.ended)return;GT(this,C1,void 0,"f")},MY=function $(T){let W=L$(this,zT,"f")[T.index];if(W)return W;return W={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},L$(this,zT,"f")[T.index]=W,W},Gz=function $(T){if(this.ended)return;let W=L$(this,_4,"m",BO).call(this,T);this._emit("chunk",T,W);for(let U of T.choices){let X=W.choices[U.index];if(U.delta.content!=null&&X.message?.role==="assistant"&&X.message?.content)this._emit("content",U.delta.content,X.message.content),this._emit("content.delta",{delta:U.delta.content,snapshot:X.message.content,parsed:X.message.parsed});if(U.delta.refusal!=null&&X.message?.role==="assistant"&&X.message?.refusal)this._emit("refusal.delta",{delta:U.delta.refusal,snapshot:X.message.refusal});if(U.logprobs?.content!=null&&X.message?.role==="assistant")this._emit("logprobs.content.delta",{content:U.logprobs?.content,snapshot:X.logprobs?.content??[]});if(U.logprobs?.refusal!=null&&X.message?.role==="assistant")this._emit("logprobs.refusal.delta",{refusal:U.logprobs?.refusal,snapshot:X.logprobs?.refusal??[]});let Y=L$(this,_4,"m",MY).call(this,X);if(X.finish_reason){if(L$(this,_4,"m",Hz).call(this,X),Y.current_tool_call_index!=null)L$(this,_4,"m",zz).call(this,X,Y.current_tool_call_index)}for(let _ of U.delta.tool_calls??[]){if(Y.current_tool_call_index!==_.index){if(L$(this,_4,"m",Hz).call(this,X),Y.current_tool_call_index!=null)L$(this,_4,"m",zz).call(this,X,Y.current_tool_call_index)}Y.current_tool_call_index=_.index}for(let _ of U.delta.tool_calls??[]){let w=X.message.tool_calls?.[_.index];if(!w?.type)continue;if(w?.type==="function")this._emit("tool_calls.function.arguments.delta",{name:w.function?.name,index:_.index,arguments:w.function.arguments,parsed_arguments:w.function.parsed_arguments,arguments_delta:_.function?.arguments??""});else IO(w?.type)}}},zz=function $(T,W){if(L$(this,_4,"m",MY).call(this,T).done_tool_calls.has(W))return;let X=T.message.tool_calls?.[W];if(!X)throw new Error("no tool call snapshot");if(!X.type)throw new Error("tool call snapshot missing `type`");if(X.type==="function"){let Y=L$(this,T1,"f")?.tools?.find((_)=>_.type==="function"&&_.function.name===X.function.name);this._emit("tool_calls.function.arguments.done",{name:X.function.name,index:W,arguments:X.function.arguments,parsed_arguments:Q0(Y)?Y.$parseRaw(X.function.arguments):Y?.function.strict?JSON.parse(X.function.arguments):null})}else IO(X.type)},Hz=function $(T){let W=L$(this,_4,"m",MY).call(this,T);if(T.message.content&&!W.content_done){W.content_done=!0;let U=L$(this,_4,"m",Fz).call(this);this._emit("content.done",{content:T.message.content,parsed:U?U.$parseRaw(T.message.content):null})}if(T.message.refusal&&!W.refusal_done)W.refusal_done=!0,this._emit("refusal.done",{refusal:T.message.refusal});if(T.logprobs?.content&&!W.logprobs_content_done)W.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:T.logprobs.content});if(T.logprobs?.refusal&&!W.logprobs_refusal_done)W.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:T.logprobs.refusal})},NY=function $(){if(this.ended)throw new l("stream has ended, this shouldn't happen");let T=L$(this,C1,"f");if(!T)throw new l("request ended without sending any chunks");return GT(this,C1,void 0,"f"),GT(this,zT,[],"f"),xI(T,L$(this,T1,"f"))},Fz=function $(){let T=L$(this,T1,"f")?.response_format;if(Q2(T))return T;return null},BO=function $(T){var W,U,X,Y;let _=L$(this,C1,"f"),{choices:w,...G}=T;if(!_)_=GT(this,C1,{...G,choices:[]},"f");else Object.assign(_,G);for(let{delta:J,finish_reason:H,index:z,logprobs:F=null,...Q}of T.choices){let V=_.choices[z];if(!V)V=_.choices[z]={finish_reason:H,index:z,message:{},logprobs:F,...Q};if(F)if(!V.logprobs)V.logprobs=Object.assign({},F);else{let{content:y,refusal:x,...u}=F;if(RO(u),Object.assign(V.logprobs,u),y)(W=V.logprobs).content??(W.content=[]),V.logprobs.content.push(...y);if(x)(U=V.logprobs).refusal??(U.refusal=[]),V.logprobs.refusal.push(...x)}if(H){if(V.finish_reason=H,L$(this,T1,"f")&&Tz(L$(this,T1,"f"))){if(H==="length")throw new sW;if(H==="content_filter")throw new eW}}if(Object.assign(V,Q),!J)continue;let{content:K,refusal:I,function_call:k,role:N,tool_calls:L,...q}=J;if(RO(q),Object.assign(V.message,q),I)V.message.refusal=(V.message.refusal||"")+I;if(N)V.message.role=N;if(k)if(!V.message.function_call)V.message.function_call=k;else{if(k.name)V.message.function_call.name=k.name;if(k.arguments)(X=V.message.function_call).arguments??(X.arguments=""),V.message.function_call.arguments+=k.arguments}if(K){if(V.message.content=(V.message.content||"")+K,!V.message.refusal&&L$(this,_4,"m",Fz).call(this))V.message.parsed=wz(V.message.content)}if(L){if(!V.message.tool_calls)V.message.tool_calls=[];for(let{index:y,id:x,type:u,function:w$,...m$}of L){let B=(Y=V.message.tool_calls)[y]??(Y[y]={});if(Object.assign(B,m$),x)B.id=x;if(u)B.type=u;if(w$)B.function??(B.function={name:w$.name??"",arguments:""});if(w$?.name)B.function.name=w$.name;if(w$?.arguments){if(B.function.arguments+=w$.arguments,EO(L$(this,T1,"f"),B))B.function.parsed_arguments=wz(B.function.arguments)}}}}return _},Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("chunk",(U)=>{let X=T.shift();if(X)X.resolve(U);else $.push(U)}),this.on("end",()=>{W=!0;for(let U of T)U.resolve(void 0);T.length=0}),this.on("abort",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),this.on("error",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((X,Y)=>T.push({resolve:X,reject:Y})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new a4(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function xI($,T){let{id:W,choices:U,created:X,model:Y,system_fingerprint:_,...w}=$,G={...w,id:W,choices:U.map(({message:J,finish_reason:H,index:z,logprobs:F,...Q})=>{if(!H)throw new l(`missing finish_reason for choice ${z}`);let{content:V=null,function_call:K,tool_calls:I,...k}=J,N=J.role;if(!N)throw new l(`missing role for choice ${z}`);if(K){let{arguments:L,name:q}=K;if(L==null)throw new l(`missing function_call.arguments for choice ${z}`);if(!q)throw new l(`missing function_call.name for choice ${z}`);return{...Q,message:{content:V,function_call:{arguments:L,name:q},role:N,refusal:J.refusal??null},finish_reason:H,index:z,logprobs:F}}if(I)return{...Q,index:z,finish_reason:H,logprobs:F,message:{...k,role:N,content:V,refusal:J.refusal??null,tool_calls:I.map((L,q)=>{let{function:y,type:x,id:u,...w$}=L,{arguments:m$,name:B,...D$}=y||{};if(u==null)throw new l(`missing choices[${z}].tool_calls[${q}].id
67
- ${LY($)}`);if(x==null)throw new l(`missing choices[${z}].tool_calls[${q}].type
68
- ${LY($)}`);if(B==null)throw new l(`missing choices[${z}].tool_calls[${q}].function.name
69
- ${LY($)}`);if(m$==null)throw new l(`missing choices[${z}].tool_calls[${q}].function.arguments
70
- ${LY($)}`);return{...w$,id:u,type:x,function:{...D$,name:B,arguments:m$}}})}};return{...Q,message:{...k,content:V,role:N,refusal:J.refusal??null},finish_reason:H,index:z,logprobs:F}}),created:X,model:Y,object:"chat.completion",..._?{system_fingerprint:_}:{}};return KO(G,T)}function LY($){return JSON.stringify($)}function RO($){return}function IO($){}class V0 extends Z0{static fromReadableStream($){let T=new V0(null);return T._run(()=>T._fromReadableStream($)),T}static runFunctions($,T,W){let U=new V0(null),X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return U._run(()=>U._runFunctions($,T,X)),U}static runTools($,T,W){let U=new V0(T),X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return U._run(()=>U._runTools($,T,X)),U}}class SY extends P{parse($,T){return AO($.tools),this._client.chat.completions.create($,{...T,headers:{...T?.headers,"X-Stainless-Helper-Method":"beta.chat.completions.parse"}})._thenUnwrap((W)=>Z2(W,$))}runFunctions($,T){if($.stream)return V0.runFunctions(this._client,$,T);return JT.runFunctions(this._client,$,T)}runTools($,T){if($.stream)return V0.runTools(this._client,$,T);return JT.runTools(this._client,$,T)}stream($,T){return Z0.createChatCompletion(this._client,$,T)}}class K2 extends P{constructor(){super(...arguments);this.completions=new SY(this._client)}}(function($){$.Completions=SY})(K2||(K2={}));class E2 extends P{create($,T){return this._client.post("/realtime/sessions",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class A2 extends P{create($,T){return this._client.post("/realtime/transcription_sessions",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class K0 extends P{constructor(){super(...arguments);this.sessions=new E2(this._client),this.transcriptionSessions=new A2(this._client)}}K0.Sessions=E2;K0.TranscriptionSessions=A2;class HT extends P{create($,T,W){return this._client.post(`/threads/${$}/messages`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}retrieve($,T,W){return this._client.get(`/threads/${$}/messages/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}update($,T,W,U){return this._client.post(`/threads/${$}/messages/${T}`,{body:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}list($,T={},W){if(W$(T))return this.list($,{},T);return this._client.getAPIList(`/threads/${$}/messages`,M2,{query:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}del($,T,W){return this._client.delete(`/threads/${$}/messages/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class M2 extends F${}HT.MessagesPage=M2;class FT extends P{retrieve($,T,W,U={},X){if(W$(U))return this.retrieve($,T,W,{},U);return this._client.get(`/threads/${$}/runs/${T}/steps/${W}`,{query:U,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}list($,T,W={},U){if(W$(W))return this.list($,T,{},W);return this._client.getAPIList(`/threads/${$}/runs/${T}/steps`,N2,{query:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}}class N2 extends F${}FT.RunStepsPage=N2;class j1 extends P{constructor(){super(...arguments);this.steps=new FT(this._client)}create($,T,W){let{include:U,...X}=T;return this._client.post(`/threads/${$}/runs`,{query:{include:U},body:X,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers},stream:T.stream??!1})}retrieve($,T,W){return this._client.get(`/threads/${$}/runs/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}update($,T,W,U){return this._client.post(`/threads/${$}/runs/${T}`,{body:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}list($,T={},W){if(W$(T))return this.list($,{},T);return this._client.getAPIList(`/threads/${$}/runs`,L2,{query:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}cancel($,T,W){return this._client.post(`/threads/${$}/runs/${T}/cancel`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}async createAndPoll($,T,W){let U=await this.create($,T,W);return await this.poll($,U.id,W)}createAndStream($,T,W){return $6.createAssistantStream($,this._client.beta.threads.runs,T,W)}async poll($,T,W){let U={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)U["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let{data:X,response:Y}=await this.retrieve($,T,{...W,headers:{...W?.headers,...U}}).withResponse();switch(X.status){case"queued":case"in_progress":case"cancelling":let _=5000;if(W?.pollIntervalMs)_=W.pollIntervalMs;else{let w=Y.headers.get("openai-poll-after-ms");if(w){let G=parseInt(w);if(!isNaN(G))_=G}}await t6(_);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return X}}}stream($,T,W){return $6.createAssistantStream($,this._client.beta.threads.runs,T,W)}submitToolOutputs($,T,W,U){return this._client.post(`/threads/${$}/runs/${T}/submit_tool_outputs`,{body:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers},stream:W.stream??!1})}async submitToolOutputsAndPoll($,T,W,U){let X=await this.submitToolOutputs($,T,W,U);return await this.poll($,X.id,U)}submitToolOutputsStream($,T,W,U){return $6.createToolAssistantStream($,T,this._client.beta.threads.runs,W,U)}}class L2 extends F${}j1.RunsPage=L2;j1.Steps=FT;j1.RunStepsPage=N2;class W1 extends P{constructor(){super(...arguments);this.runs=new j1(this._client),this.messages=new HT(this._client)}create($={},T){if(W$($))return this.create({},$);return this._client.post("/threads",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}retrieve($,T){return this._client.get(`/threads/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}update($,T,W){return this._client.post(`/threads/${$}`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}del($,T){return this._client.delete(`/threads/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}createAndRun($,T){return this._client.post("/threads/runs",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers},stream:$.stream??!1})}async createAndRunPoll($,T){let W=await this.createAndRun($,T);return await this.runs.poll(W.thread_id,W.id,T)}createAndRunStream($,T){return $6.createThreadAssistantStream($,this._client.beta.threads,T)}}W1.Runs=j1;W1.RunsPage=L2;W1.Messages=HT;W1.MessagesPage=M2;class f6 extends P{constructor(){super(...arguments);this.realtime=new K0(this._client),this.chat=new K2(this._client),this.assistants=new wT(this._client),this.threads=new W1(this._client)}}f6.Realtime=K0;f6.Assistants=wT;f6.AssistantsPage=D2;f6.Threads=W1;class OT extends P{create($,T){return this._client.post("/completions",{body:$,...T,stream:$.stream??!1})}}class S2 extends P{retrieve($,T,W){return this._client.get(`/containers/${$}/files/${T}/content`,{...W,headers:{Accept:"*/*",...W?.headers}})}}class E0 extends P{constructor(){super(...arguments);this.content=new S2(this._client)}create($,T,W){return this._client.post(`/containers/${$}/files`,y4({body:T,...W}))}retrieve($,T,W){return this._client.get(`/containers/${$}/files/${T}`,W)}list($,T={},W){if(W$(T))return this.list($,{},T);return this._client.getAPIList(`/containers/${$}/files`,B2,{query:T,...W})}del($,T,W){return this._client.delete(`/containers/${$}/files/${T}`,{...W,headers:{Accept:"*/*",...W?.headers}})}}class B2 extends F${}E0.FileListResponsesPage=B2;E0.Content=S2;class U1 extends P{constructor(){super(...arguments);this.files=new E0(this._client)}create($,T){return this._client.post("/containers",{body:$,...T})}retrieve($,T){return this._client.get(`/containers/${$}`,T)}list($={},T){if(W$($))return this.list({},$);return this._client.getAPIList("/containers",DT,{query:$,...T})}del($,T){return this._client.delete(`/containers/${$}`,{...T,headers:{Accept:"*/*",...T?.headers}})}}class DT extends F${}U1.ContainerListResponsesPage=DT;U1.Files=E0;U1.FileListResponsesPage=B2;class QT extends P{create($,T){let W=!!$.encoding_format,U=W?$.encoding_format:"base64";if(W)n6("Request","User defined encoding_format:",$.encoding_format);let X=this._client.post("/embeddings",{body:{...$,encoding_format:U},...T});if(W)return X;return n6("response","Decoding base64 embeddings to float32 array"),X._thenUnwrap((Y)=>{if(Y&&Y.data)Y.data.forEach((_)=>{let w=_.embedding;_.embedding=GO(w)});return Y})}}class ZT extends P{retrieve($,T,W,U){return this._client.get(`/evals/${$}/runs/${T}/output_items/${W}`,U)}list($,T,W={},U){if(W$(W))return this.list($,T,{},W);return this._client.getAPIList(`/evals/${$}/runs/${T}/output_items`,R2,{query:W,...U})}}class R2 extends F${}ZT.OutputItemListResponsesPage=R2;class x1 extends P{constructor(){super(...arguments);this.outputItems=new ZT(this._client)}create($,T,W){return this._client.post(`/evals/${$}/runs`,{body:T,...W})}retrieve($,T,W){return this._client.get(`/evals/${$}/runs/${T}`,W)}list($,T={},W){if(W$(T))return this.list($,{},T);return this._client.getAPIList(`/evals/${$}/runs`,I2,{query:T,...W})}del($,T,W){return this._client.delete(`/evals/${$}/runs/${T}`,W)}cancel($,T,W){return this._client.post(`/evals/${$}/runs/${T}`,W)}}class I2 extends F${}x1.RunListResponsesPage=I2;x1.OutputItems=ZT;x1.OutputItemListResponsesPage=R2;class X1 extends P{constructor(){super(...arguments);this.runs=new x1(this._client)}create($,T){return this._client.post("/evals",{body:$,...T})}retrieve($,T){return this._client.get(`/evals/${$}`,T)}update($,T,W){return this._client.post(`/evals/${$}`,{body:T,...W})}list($={},T){if(W$($))return this.list({},$);return this._client.getAPIList("/evals",VT,{query:$,...T})}del($,T){return this._client.delete(`/evals/${$}`,T)}}class VT extends F${}X1.EvalListResponsesPage=VT;X1.Runs=x1;X1.RunListResponsesPage=I2;class A0 extends P{create($,T){return this._client.post("/files",y4({body:$,...T}))}retrieve($,T){return this._client.get(`/files/${$}`,T)}list($={},T){if(W$($))return this.list({},$);return this._client.getAPIList("/files",KT,{query:$,...T})}del($,T){return this._client.delete(`/files/${$}`,T)}content($,T){return this._client.get(`/files/${$}/content`,{...T,headers:{Accept:"application/binary",...T?.headers},__binaryResponse:!0})}retrieveContent($,T){return this._client.get(`/files/${$}/content`,T)}async waitForProcessing($,{pollInterval:T=5000,maxWait:W=1800000}={}){let U=new Set(["processed","error","deleted"]),X=Date.now(),Y=await this.retrieve($);while(!Y.status||!U.has(Y.status))if(await t6(T),Y=await this.retrieve($),Date.now()-X>W)throw new w0({message:`Giving up on waiting for file ${$} to finish processing after ${W} milliseconds.`});return Y}}class KT extends F${}A0.FileObjectsPage=KT;class k2 extends P{}class v2 extends P{run($,T){return this._client.post("/fine_tuning/alpha/graders/run",{body:$,...T})}validate($,T){return this._client.post("/fine_tuning/alpha/graders/validate",{body:$,...T})}}class ET extends P{constructor(){super(...arguments);this.graders=new v2(this._client)}}ET.Graders=v2;class AT extends P{create($,T,W){return this._client.getAPIList(`/fine_tuning/checkpoints/${$}/permissions`,q2,{body:T,method:"post",...W})}retrieve($,T={},W){if(W$(T))return this.retrieve($,{},T);return this._client.get(`/fine_tuning/checkpoints/${$}/permissions`,{query:T,...W})}del($,T,W){return this._client.delete(`/fine_tuning/checkpoints/${$}/permissions/${T}`,W)}}class q2 extends s6{}AT.PermissionCreateResponsesPage=q2;class M0 extends P{constructor(){super(...arguments);this.permissions=new AT(this._client)}}M0.Permissions=AT;M0.PermissionCreateResponsesPage=q2;class MT extends P{list($,T={},W){if(W$(T))return this.list($,{},T);return this._client.getAPIList(`/fine_tuning/jobs/${$}/checkpoints`,P2,{query:T,...W})}}class P2 extends F${}MT.FineTuningJobCheckpointsPage=P2;class Y1 extends P{constructor(){super(...arguments);this.checkpoints=new MT(this._client)}create($,T){return this._client.post("/fine_tuning/jobs",{body:$,...T})}retrieve($,T){return this._client.get(`/fine_tuning/jobs/${$}`,T)}list($={},T){if(W$($))return this.list({},$);return this._client.getAPIList("/fine_tuning/jobs",C2,{query:$,...T})}cancel($,T){return this._client.post(`/fine_tuning/jobs/${$}/cancel`,T)}listEvents($,T={},W){if(W$(T))return this.listEvents($,{},T);return this._client.getAPIList(`/fine_tuning/jobs/${$}/events`,j2,{query:T,...W})}pause($,T){return this._client.post(`/fine_tuning/jobs/${$}/pause`,T)}resume($,T){return this._client.post(`/fine_tuning/jobs/${$}/resume`,T)}}class C2 extends F${}class j2 extends F${}Y1.FineTuningJobsPage=C2;Y1.FineTuningJobEventsPage=j2;Y1.Checkpoints=MT;Y1.FineTuningJobCheckpointsPage=P2;class _6 extends P{constructor(){super(...arguments);this.methods=new k2(this._client),this.jobs=new Y1(this._client),this.checkpoints=new M0(this._client),this.alpha=new ET(this._client)}}_6.Methods=k2;_6.Jobs=Y1;_6.FineTuningJobsPage=C2;_6.FineTuningJobEventsPage=j2;_6.Checkpoints=M0;_6.Alpha=ET;class x2 extends P{}class N0 extends P{constructor(){super(...arguments);this.graderModels=new x2(this._client)}}N0.GraderModels=x2;class NT extends P{createVariation($,T){return this._client.post("/images/variations",y4({body:$,...T}))}edit($,T){return this._client.post("/images/edits",y4({body:$,...T}))}generate($,T){return this._client.post("/images/generations",{body:$,...T})}}class L0 extends P{retrieve($,T){return this._client.get(`/models/${$}`,T)}list($){return this._client.getAPIList("/models",LT,$)}del($,T){return this._client.delete(`/models/${$}`,T)}}class LT extends s6{}L0.ModelsPage=LT;class ST extends P{create($,T){return this._client.post("/moderations",{body:$,...T})}}function kO($,T){if(!T||!Uk(T))return{...$,output_parsed:null,output:$.output.map((W)=>{if(W.type==="function_call")return{...W,parsed_arguments:null};if(W.type==="message")return{...W,content:W.content.map((U)=>({...U,parsed:null}))};else return W})};return Oz($,T)}function Oz($,T){let W=$.output.map((X)=>{if(X.type==="function_call")return{...X,parsed_arguments:_k(T,X)};if(X.type==="message"){let Y=X.content.map((_)=>{if(_.type==="output_text")return{..._,parsed:Wk(T,_.text)};return _});return{...X,content:Y}}return X}),U=Object.assign({},$,{output:W});if(!Object.getOwnPropertyDescriptor($,"output_text"))BY(U);return Object.defineProperty(U,"output_parsed",{enumerable:!0,get(){for(let X of U.output){if(X.type!=="message")continue;for(let Y of X.content)if(Y.type==="output_text"&&Y.parsed!==null)return Y.parsed}return null}}),U}function Wk($,T){if($.text?.format?.type!=="json_schema")return null;if("$parseRaw"in $.text?.format)return($.text?.format).$parseRaw(T);return JSON.parse(T)}function Uk($){if(Q2($.text?.format))return!0;return!1}function Xk($){return $?.$brand==="auto-parseable-tool"}function Yk($,T){return $.find((W)=>W.type==="function"&&W.name===T)}function _k($,T){let W=Yk($.tools??[],T.name);return{...T,...T,parsed_arguments:Xk(W)?W.$parseRaw(T.arguments):W?.strict?JSON.parse(T.arguments):null}}function BY($){let T=[];for(let W of $.output){if(W.type!=="message")continue;for(let U of W.content)if(U.type==="output_text")T.push(U.text)}$.output_text=T.join("")}class b2 extends P{list($,T={},W){if(W$(T))return this.list($,{},T);return this._client.getAPIList(`/responses/${$}/input_items`,Dz,{query:T,...W})}}var BT=function($,T,W,U,X){if(U==="m")throw new TypeError("Private method is not writable");if(U==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return U==="a"?X.call($,W):X?X.value=W:T.set($,W),W},b1=function($,T,W,U){if(W==="a"&&!U)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!U:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?U:W==="a"?U.call($):U?U.value:T.get($)},RT,RY,f1,IY,vO,qO,PO,CO;class kY extends F0{constructor($){super();RT.add(this),RY.set(this,void 0),f1.set(this,void 0),IY.set(this,void 0),BT(this,RY,$,"f")}static createResponse($,T,W){let U=new kY(T);return U._run(()=>U._createOrRetrieveResponse($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),U}async _createOrRetrieveResponse($,T,W){let U=W?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}b1(this,RT,"m",vO).call(this);let X,Y=null;if("response_id"in T)X=await $.responses.retrieve(T.response_id,{stream:!0},{...W,signal:this.controller.signal,stream:!0}),Y=T.starting_after??null;else X=await $.responses.create({...T,stream:!0},{...W,signal:this.controller.signal});this._connected();for await(let _ of X)b1(this,RT,"m",qO).call(this,_,Y);if(X.controller.signal?.aborted)throw new Y4;return b1(this,RT,"m",PO).call(this)}[(RY=new WeakMap,f1=new WeakMap,IY=new WeakMap,RT=new WeakSet,vO=function $(){if(this.ended)return;BT(this,f1,void 0,"f")},qO=function $(T,W){if(this.ended)return;let U=(Y,_)=>{if(W==null||_.sequence_number>W)this._emit(Y,_)},X=b1(this,RT,"m",CO).call(this,T);switch(U("event",T),T.type){case"response.output_text.delta":{let Y=X.output[T.output_index];if(!Y)throw new l(`missing output at index ${T.output_index}`);if(Y.type==="message"){let _=Y.content[T.content_index];if(!_)throw new l(`missing content at index ${T.content_index}`);if(_.type!=="output_text")throw new l(`expected content to be 'output_text', got ${_.type}`);U("response.output_text.delta",{...T,snapshot:_.text})}break}case"response.function_call_arguments.delta":{let Y=X.output[T.output_index];if(!Y)throw new l(`missing output at index ${T.output_index}`);if(Y.type==="function_call")U("response.function_call_arguments.delta",{...T,snapshot:Y.arguments});break}default:U(T.type,T);break}},PO=function $(){if(this.ended)throw new l("stream has ended, this shouldn't happen");let T=b1(this,f1,"f");if(!T)throw new l("request ended without sending any events");BT(this,f1,void 0,"f");let W=Jk(T,b1(this,RY,"f"));return BT(this,IY,W,"f"),W},CO=function $(T){let W=b1(this,f1,"f");if(!W){if(T.type!=="response.created")throw new l(`When snapshot hasn't been set yet, expected 'response.created' event, got ${T.type}`);return W=BT(this,f1,T.response,"f"),W}switch(T.type){case"response.output_item.added":{W.output.push(T.item);break}case"response.content_part.added":{let U=W.output[T.output_index];if(!U)throw new l(`missing output at index ${T.output_index}`);if(U.type==="message")U.content.push(T.part);break}case"response.output_text.delta":{let U=W.output[T.output_index];if(!U)throw new l(`missing output at index ${T.output_index}`);if(U.type==="message"){let X=U.content[T.content_index];if(!X)throw new l(`missing content at index ${T.content_index}`);if(X.type!=="output_text")throw new l(`expected content to be 'output_text', got ${X.type}`);X.text+=T.delta}break}case"response.function_call_arguments.delta":{let U=W.output[T.output_index];if(!U)throw new l(`missing output at index ${T.output_index}`);if(U.type==="function_call")U.arguments+=T.delta;break}case"response.completed":{BT(this,f1,T.response,"f");break}}return W},Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(U)=>{let X=T.shift();if(X)X.resolve(U);else $.push(U)}),this.on("end",()=>{W=!0;for(let U of T)U.resolve(void 0);T.length=0}),this.on("abort",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),this.on("error",(U)=>{W=!0;for(let X of T)X.reject(U);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((X,Y)=>T.push({resolve:X,reject:Y})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let $=b1(this,IY,"f");if(!$)throw new l("stream ended without producing a ChatCompletion");return $}}function Jk($,T){return kO($,T)}class S0 extends P{constructor(){super(...arguments);this.inputItems=new b2(this._client)}create($,T){return this._client.post("/responses",{body:$,...T,stream:$.stream??!1})._thenUnwrap((W)=>{if("object"in W&&W.object==="response")BY(W);return W})}retrieve($,T={},W){if(W$(T)&&W===void 0)return this.retrieve($,{},T);return this._client.get(`/responses/${$}`,{query:T,...W,stream:T.stream??!1})._thenUnwrap((U)=>{if("object"in U&&U.object==="response")BY(U);return U})}del($,T){return this._client.delete(`/responses/${$}`,{...T,headers:{Accept:"*/*",...T?.headers}})}parse($,T){return this._client.responses.create($,T)._thenUnwrap((W)=>Oz(W,$))}stream($,T){return kY.createResponse(this._client,$,T)}cancel($,T){return this._client.post(`/responses/${$}/cancel`,{...T,headers:{Accept:"*/*",...T?.headers}})}}class Dz extends F${}S0.InputItems=b2;class f2 extends P{create($,T,W){return this._client.post(`/uploads/${$}/parts`,y4({body:T,...W}))}}class B0 extends P{constructor(){super(...arguments);this.parts=new f2(this._client)}create($,T){return this._client.post("/uploads",{body:$,...T})}cancel($,T){return this._client.post(`/uploads/${$}/cancel`,T)}complete($,T,W){return this._client.post(`/uploads/${$}/complete`,{body:T,...W})}}B0.Parts=f2;var jO=async($)=>{let T=await Promise.allSettled($),W=T.filter((X)=>X.status==="rejected");if(W.length){for(let X of W)console.error(X.reason);throw new Error(`${W.length} promise(s) failed - see the above errors`)}let U=[];for(let X of T)if(X.status==="fulfilled")U.push(X.value);return U};class R0 extends P{create($,T,W){return this._client.post(`/vector_stores/${$}/files`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}retrieve($,T,W){return this._client.get(`/vector_stores/${$}/files/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}update($,T,W,U){return this._client.post(`/vector_stores/${$}/files/${T}`,{body:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}list($,T={},W){if(W$(T))return this.list($,{},T);return this._client.getAPIList(`/vector_stores/${$}/files`,I0,{query:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}del($,T,W){return this._client.delete(`/vector_stores/${$}/files/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}async createAndPoll($,T,W){let U=await this.create($,T,W);return await this.poll($,U.id,W)}async poll($,T,W){let U={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)U["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let X=await this.retrieve($,T,{...W,headers:U}).withResponse(),Y=X.data;switch(Y.status){case"in_progress":let _=5000;if(W?.pollIntervalMs)_=W.pollIntervalMs;else{let w=X.response.headers.get("openai-poll-after-ms");if(w){let G=parseInt(w);if(!isNaN(G))_=G}}await t6(_);break;case"failed":case"completed":return Y}}}async upload($,T,W){let U=await this._client.files.create({file:T,purpose:"assistants"},W);return this.create($,{file_id:U.id},W)}async uploadAndPoll($,T,W){let U=await this.upload($,T,W);return await this.poll($,U.id,W)}content($,T,W){return this._client.getAPIList(`/vector_stores/${$}/files/${T}/content`,y2,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class I0 extends F${}class y2 extends s6{}R0.VectorStoreFilesPage=I0;R0.FileContentResponsesPage=y2;class h2 extends P{create($,T,W){return this._client.post(`/vector_stores/${$}/file_batches`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}retrieve($,T,W){return this._client.get(`/vector_stores/${$}/file_batches/${T}`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}cancel($,T,W){return this._client.post(`/vector_stores/${$}/file_batches/${T}/cancel`,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}async createAndPoll($,T,W){let U=await this.create($,T);return await this.poll($,U.id,W)}listFiles($,T,W={},U){if(W$(W))return this.listFiles($,T,{},W);return this._client.getAPIList(`/vector_stores/${$}/file_batches/${T}/files`,I0,{query:W,...U,headers:{"OpenAI-Beta":"assistants=v2",...U?.headers}})}async poll($,T,W){let U={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)U["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let{data:X,response:Y}=await this.retrieve($,T,{...W,headers:U}).withResponse();switch(X.status){case"in_progress":let _=5000;if(W?.pollIntervalMs)_=W.pollIntervalMs;else{let w=Y.headers.get("openai-poll-after-ms");if(w){let G=parseInt(w);if(!isNaN(G))_=G}}await t6(_);break;case"failed":case"cancelled":case"completed":return X}}}async uploadAndPoll($,{files:T,fileIds:W=[]},U){if(T==null||T.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let X=U?.maxConcurrency??5,Y=Math.min(X,T.length),_=this._client,w=T.values(),G=[...W];async function J(z){for(let F of z){let Q=await _.files.create({file:F,purpose:"assistants"},U);G.push(Q.id)}}let H=Array(Y).fill(w).map(J);return await jO(H),await this.createAndPoll($,{file_ids:G})}}class w6 extends P{constructor(){super(...arguments);this.files=new R0(this._client),this.fileBatches=new h2(this._client)}create($,T){return this._client.post("/vector_stores",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}retrieve($,T){return this._client.get(`/vector_stores/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}update($,T,W){return this._client.post(`/vector_stores/${$}`,{body:T,...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}list($={},T){if(W$($))return this.list({},$);return this._client.getAPIList("/vector_stores",IT,{query:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}del($,T){return this._client.delete(`/vector_stores/${$}`,{...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}search($,T,W){return this._client.getAPIList(`/vector_stores/${$}/search`,kT,{body:T,method:"post",...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class IT extends F${}class kT extends s6{}w6.VectorStoresPage=IT;w6.VectorStoreSearchResponsesPage=kT;w6.Files=R0;w6.VectorStoreFilesPage=I0;w6.FileContentResponsesPage=y2;w6.FileBatches=h2;var xO;class U$ extends i9{constructor({baseURL:$=T2("OPENAI_BASE_URL"),apiKey:T=T2("OPENAI_API_KEY"),organization:W=T2("OPENAI_ORG_ID")??null,project:U=T2("OPENAI_PROJECT_ID")??null,...X}={}){if(T===void 0)throw new l("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");let Y={apiKey:T,organization:W,project:U,...X,baseURL:$||"https://api.openai.com/v1"};if(!Y.dangerouslyAllowBrowser&&JO())throw new l(`It looks like you're running in a browser-like environment.
61
+ ${Y}`)}let H=C1.join(this.baseDir,`${$}/${T}.output.json`);return JSON.parse(K4.readFileSync(H,"utf-8"))}async write($,T,W,w){let X=C1.join(this.baseDir,$),U=C1.join(X,`${T}.input.json`),Y=C1.join(X,`${T}.output.json`),G=JSON.stringify(W,null,"\t");if(!K4.existsSync(this.baseDir))K4.mkdirSync(this.baseDir,{recursive:!0});if(!K4.existsSync(X))K4.mkdirSync(X);if(K4.writeFileSync(U,G),K4.existsSync(Y))K4.unlinkSync(Y);let H=await w(...W),z=JSON.stringify(H,null,"\t");return K4.writeFileSync(Y,z),H}add($,T){let W=`${this.rootName}${q4}${V8($)}`;return{flush:()=>{this.flush($)},for:(w)=>{if(this.mode!=="off"){if(this.filesTouched.set($,new Set),n$.storage.initialized&&!n$.storage.getItem(`list${q4}${W}`))n$.storage.setItem(`list${q4}${W}`,"true")}return{get:async(...X)=>{let U=w;if(this.mode!=="off"){let Y=this.filenameCache.get(w);if(!Y)Y=V8(w),this.filenameCache.set(w,Y);U=Y,this.filesTouched.get($)?.add(U);let G=`${W}${q4}${U}`,H=`file${q4}${G}`;if(n$.storage.initialized&&!n$.storage.getItem(H))n$.storage.setItem(H,"true")}switch(this.mode){case"off":return T(...X);case"read":return this.read($,U,X);case"write":return this.write($,U,X,T);case"read-write":try{return this.read($,U,X)}catch(Y){if(Y instanceof Error)return this.write($,U,X,T);throw Y}}}}}}}flush(...$){console.log(this.filesTouched);for(let[T,W]of this.filesTouched.entries())if($.length===0||$.includes(T)){let w=C1.join(this.baseDir,T),X=K4.readdirSync(w);for(let U of X){let Y=U.replace(".input.json","").replace(".output.json","");if(!W.has(Y))console.info(`\uD83E\uDDF9 Flushing ${Y}`),K4.unlinkSync(C1.join(w,U))}}}};function w$($,T,W,w,X){if(w==="m")throw new TypeError("Private method is not writable");if(w==="a"&&!X)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return w==="a"?X.call($,W):X?X.value=W:T.set($,W),W}function v($,T,W,w){if(W==="a"&&!w)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!w:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?w:W==="a"?w.call($):w?w.value:T.get($)}var VF=function(){let{crypto:$}=globalThis;if($?.randomUUID)return VF=$.randomUUID.bind($),$.randomUUID();let T=new Uint8Array(1),W=$?()=>$.getRandomValues(T)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(w)=>(+w^W()&15>>+w/4).toString(16))};function K8($){return typeof $==="object"&&$!==null&&(("name"in $)&&$.name==="AbortError"||("message"in $)&&String($.message).includes("FetchRequestCanceledException"))}var A8=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null){try{if(Object.prototype.toString.call($)==="[object Error]"){let T=new Error($.message,$.cause?{cause:$.cause}:{});if($.stack)T.stack=$.stack;if($.cause&&!T.cause)T.cause=$.cause;if($.name)T.name=$.name;return T}}catch{}try{return new Error(JSON.stringify($))}catch{}}return new Error($)};class $$ extends Error{}class L4 extends $${constructor($,T,W,w){super(`${L4.makeMessage($,T,W)}`);this.status=$,this.headers=w,this.requestID=w?.get("x-request-id"),this.error=T;let X=T;this.code=X?.code,this.param=X?.param,this.type=X?.type}static makeMessage($,T,W){let w=T?.message?typeof T.message==="string"?T.message:JSON.stringify(T.message):T?JSON.stringify(T):W;if($&&w)return`${$} ${w}`;if($)return`${$} status code (no body)`;if(w)return w;return"(no status code or body)"}static generate($,T,W,w){if(!$||!w)return new nT({message:W,cause:A8(T)});let X=T?.error;if($===400)return new E8($,X,W,w);if($===401)return new M8($,X,W,w);if($===403)return new D8($,X,W,w);if($===404)return new N8($,X,W,w);if($===409)return new L8($,X,W,w);if($===422)return new J8($,X,W,w);if($===429)return new R8($,X,W,w);if($>=500)return new _8($,X,W,w);return new L4($,X,W,w)}}class P4 extends L4{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class nT extends L4{constructor({message:$,cause:T}){super(void 0,void 0,$||"Connection error.",void 0);if(T)this.cause=T}}class iT extends nT{constructor({message:$}={}){super({message:$??"Request timed out."})}}class E8 extends L4{}class M8 extends L4{}class D8 extends L4{}class N8 extends L4{}class L8 extends L4{}class J8 extends L4{}class R8 extends L4{}class _8 extends L4{}class k8 extends $${constructor(){super("Could not parse response content as the length limit was reached")}}class v8 extends $${constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var LS=/^[a-z][a-z0-9+.-]*:/i,KA=($)=>{return LS.test($)};function AA($){if(typeof $!=="object")return{};return $??{}}function EA($){if(!$)return!0;for(let T in $)return!1;return!0}function MA($,T){return Object.prototype.hasOwnProperty.call($,T)}function q8($){return $!=null&&typeof $==="object"&&!Array.isArray($)}var DA=($,T)=>{if(typeof T!=="number"||!Number.isInteger(T))throw new $$(`${$} must be an integer`);if(T<0)throw new $$(`${$} must be a positive integer`);return T};var NA=($)=>{try{return JSON.parse($)}catch(T){return}};var l1=($)=>new Promise((T)=>setTimeout(T,$));var zG={off:0,error:200,warn:300,info:400,debug:500},KF=($,T,W)=>{if(!$)return;if(MA(zG,$))return $;C4(W).warn(`${T} was set to ${JSON.stringify($)}, expected one of ${JSON.stringify(Object.keys(zG))}`);return};function P8(){}function GG($,T,W){if(!T||zG[$]>zG[W])return P8;else return T[$].bind(T)}var JS={error:P8,warn:P8,info:P8,debug:P8},LA=new WeakMap;function C4($){let T=$.logger,W=$.logLevel??"off";if(!T)return JS;let w=LA.get(T);if(w&&w[0]===W)return w[1];let X={error:GG("error",T,W),warn:GG("warn",T,W),info:GG("info",T,W),debug:GG("debug",T,W)};return LA.set(T,[W,X]),X}var M0=($)=>{if($.options)$.options={...$.options},delete $.options.headers;if($.headers)$.headers=Object.fromEntries(($.headers instanceof Headers?[...$.headers]:Object.entries($.headers)).map(([T,W])=>[T,T.toLowerCase()==="authorization"||T.toLowerCase()==="cookie"||T.toLowerCase()==="set-cookie"?"***":W]));if("retryOfRequestLogID"in $){if($.retryOfRequestLogID)$.retryOf=$.retryOfRequestLogID;delete $.retryOfRequestLogID}return $};var zT="5.0.1";var kA=()=>{return typeof window!=="undefined"&&typeof window.document!=="undefined"&&typeof navigator!=="undefined"};function RS(){if(typeof Deno!=="undefined"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime!=="undefined")return"edge";if(Object.prototype.toString.call(typeof globalThis.process!=="undefined"?globalThis.process:0)==="[object process]")return"node";return"unknown"}var _S=()=>{let $=RS();if($==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":zT,"X-Stainless-OS":RA(Deno.build.os),"X-Stainless-Arch":JA(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime!=="undefined")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":zT,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if($==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":zT,"X-Stainless-OS":RA(globalThis.process.platform??"unknown"),"X-Stainless-Arch":JA(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let T=kS();if(T)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":zT,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${T.browser}`,"X-Stainless-Runtime-Version":T.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":zT,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function kS(){if(typeof navigator==="undefined"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:T,pattern:W}of $){let w=W.exec(navigator.userAgent);if(w){let X=w[1]||0,U=w[2]||0,Y=w[3]||0;return{browser:T,version:`${X}.${U}.${Y}`}}}return null}var JA=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},RA=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},_A,vA=()=>{return _A??(_A=_S())};function qA(){if(typeof fetch!=="undefined")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function AF(...$){let T=globalThis.ReadableStream;if(typeof T==="undefined")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new T(...$)}function HG($){let T=Symbol.asyncIterator in $?$[Symbol.asyncIterator]():$[Symbol.iterator]();return AF({start(){},async pull(W){let{done:w,value:X}=await T.next();if(w)W.close();else W.enqueue(X)},async cancel(){await T.return?.()}})}function EF($){if($[Symbol.asyncIterator])return $;let T=$.getReader();return{async next(){try{let W=await T.read();if(W?.done)T.releaseLock();return W}catch(W){throw T.releaseLock(),W}},async return(){let W=T.cancel();return T.releaseLock(),await W,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function PA($){if($===null||typeof $!=="object")return;if($[Symbol.asyncIterator]){await $[Symbol.asyncIterator]().return?.();return}let T=$.getReader(),W=T.cancel();T.releaseLock(),await W}var CA=({headers:$,body:T})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(T)}};var C8="RFC3986",S8={RFC1738:($)=>String($).replace(/%20/g,"+"),RFC3986:($)=>String($)},MF="RFC1738";var PS=Array.isArray,r1=(()=>{let $=[];for(let T=0;T<256;++T)$.push("%"+((T<16?"0":"")+T.toString(16)).toUpperCase());return $})();var DF=1024,SA=($,T,W,w,X)=>{if($.length===0)return $;let U=$;if(typeof $==="symbol")U=Symbol.prototype.toString.call($);else if(typeof $!=="string")U=String($);if(W==="iso-8859-1")return escape(U).replace(/%u[0-9a-f]{4}/gi,function(G){return"%26%23"+parseInt(G.slice(2),16)+"%3B"});let Y="";for(let G=0;G<U.length;G+=DF){let H=U.length>=DF?U.slice(G,G+DF):U,z=[];for(let F=0;F<H.length;++F){let O=H.charCodeAt(F);if(O===45||O===46||O===95||O===126||O>=48&&O<=57||O>=65&&O<=90||O>=97&&O<=122||X===MF&&(O===40||O===41)){z[z.length]=H.charAt(F);continue}if(O<128){z[z.length]=r1[O];continue}if(O<2048){z[z.length]=r1[192|O>>6]+r1[128|O&63];continue}if(O<55296||O>=57344){z[z.length]=r1[224|O>>12]+r1[128|O>>6&63]+r1[128|O&63];continue}F+=1,O=65536+((O&1023)<<10|H.charCodeAt(F)&1023),z[z.length]=r1[240|O>>18]+r1[128|O>>12&63]+r1[128|O>>6&63]+r1[128|O&63]}Y+=z.join("")}return Y};function jA($){if(!$||typeof $!=="object")return!1;return!!($.constructor&&$.constructor.isBuffer&&$.constructor.isBuffer($))}function NF($,T){if(PS($)){let W=[];for(let w=0;w<$.length;w+=1)W.push(T($[w]));return W}return T($)}var CS=Object.prototype.hasOwnProperty,IA={brackets($){return String($)+"[]"},comma:"comma",indices($,T){return String($)+"["+T+"]"},repeat($){return String($)}},n1=Array.isArray,SS=Array.prototype.push,BA=function($,T){SS.apply($,n1(T)?T:[T])},jS=Date.prototype.toISOString,S4={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:SA,encodeValuesOnly:!1,format:C8,formatter:S8[C8],indices:!1,serializeDate($){return jS.call($)},skipNulls:!1,strictNullHandling:!1};function IS($){return typeof $==="string"||typeof $==="number"||typeof $==="boolean"||typeof $==="symbol"||typeof $==="bigint"}var LF={};function xA($,T,W,w,X,U,Y,G,H,z,F,O,Q,Z,K,E,M,L){let R=$,_=L,S=0,x=!1;while((_=_.get(LF))!==void 0&&!x){let j=_.get($);if(S+=1,typeof j!=="undefined")if(j===S)throw new RangeError("Cyclic object value");else x=!0;if(typeof _.get(LF)==="undefined")S=0}if(typeof z==="function")R=z(T,R);else if(R instanceof Date)R=Q?.(R);else if(W==="comma"&&n1(R))R=NF(R,function(j){if(j instanceof Date)return Q?.(j);return j});if(R===null){if(U)return H&&!E?H(T,S4.encoder,M,"key",Z):T;R=""}if(IS(R)||jA(R)){if(H){let j=E?T:H(T,S4.encoder,M,"key",Z);return[K?.(j)+"="+K?.(H(R,S4.encoder,M,"value",Z))]}return[K?.(T)+"="+K?.(String(R))]}let b=[];if(typeof R==="undefined")return b;let g;if(W==="comma"&&n1(R)){if(E&&H)R=NF(R,H);g=[{value:R.length>0?R.join(",")||null:void 0}]}else if(n1(z))g=z;else{let j=Object.keys(R);g=F?j.sort(F):j}let T$=G?String(T).replace(/\./g,"%2E"):String(T),N$=w&&n1(R)&&R.length===1?T$+"[]":T$;if(X&&n1(R)&&R.length===0)return N$+"[]";for(let j=0;j<g.length;++j){let U$=g[j],t=typeof U$==="object"&&typeof U$.value!=="undefined"?U$.value:R[U$];if(Y&&t===null)continue;let z$=O&&G?U$.replace(/\./g,"%2E"):U$,B$=n1(R)?typeof W==="function"?W(N$,z$):N$:N$+(O?"."+z$:"["+z$+"]");L.set($,S);let e$=new WeakMap;e$.set(LF,L),BA(b,xA(t,B$,W,w,X,U,Y,G,W==="comma"&&E&&n1(R)?null:H,z,F,O,Q,Z,K,E,M,e$))}return b}function BS($=S4){if(typeof $.allowEmptyArrays!=="undefined"&&typeof $.allowEmptyArrays!=="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof $.encodeDotInKeys!=="undefined"&&typeof $.encodeDotInKeys!=="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if($.encoder!==null&&typeof $.encoder!=="undefined"&&typeof $.encoder!=="function")throw new TypeError("Encoder has to be a function.");let T=$.charset||S4.charset;if(typeof $.charset!=="undefined"&&$.charset!=="utf-8"&&$.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let W=C8;if(typeof $.format!=="undefined"){if(!CS.call(S8,$.format))throw new TypeError("Unknown format option provided.");W=$.format}let w=S8[W],X=S4.filter;if(typeof $.filter==="function"||n1($.filter))X=$.filter;let U;if($.arrayFormat&&$.arrayFormat in IA)U=$.arrayFormat;else if("indices"in $)U=$.indices?"indices":"repeat";else U=S4.arrayFormat;if("commaRoundTrip"in $&&typeof $.commaRoundTrip!=="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let Y=typeof $.allowDots==="undefined"?!!$.encodeDotInKeys===!0?!0:S4.allowDots:!!$.allowDots;return{addQueryPrefix:typeof $.addQueryPrefix==="boolean"?$.addQueryPrefix:S4.addQueryPrefix,allowDots:Y,allowEmptyArrays:typeof $.allowEmptyArrays==="boolean"?!!$.allowEmptyArrays:S4.allowEmptyArrays,arrayFormat:U,charset:T,charsetSentinel:typeof $.charsetSentinel==="boolean"?$.charsetSentinel:S4.charsetSentinel,commaRoundTrip:!!$.commaRoundTrip,delimiter:typeof $.delimiter==="undefined"?S4.delimiter:$.delimiter,encode:typeof $.encode==="boolean"?$.encode:S4.encode,encodeDotInKeys:typeof $.encodeDotInKeys==="boolean"?$.encodeDotInKeys:S4.encodeDotInKeys,encoder:typeof $.encoder==="function"?$.encoder:S4.encoder,encodeValuesOnly:typeof $.encodeValuesOnly==="boolean"?$.encodeValuesOnly:S4.encodeValuesOnly,filter:X,format:W,formatter:w,serializeDate:typeof $.serializeDate==="function"?$.serializeDate:S4.serializeDate,skipNulls:typeof $.skipNulls==="boolean"?$.skipNulls:S4.skipNulls,sort:typeof $.sort==="function"?$.sort:null,strictNullHandling:typeof $.strictNullHandling==="boolean"?$.strictNullHandling:S4.strictNullHandling}}function JF($,T={}){let W=$,w=BS(T),X,U;if(typeof w.filter==="function")U=w.filter,W=U("",W);else if(n1(w.filter))U=w.filter,X=U;let Y=[];if(typeof W!=="object"||W===null)return"";let G=IA[w.arrayFormat],H=G==="comma"&&w.commaRoundTrip;if(!X)X=Object.keys(W);if(w.sort)X.sort(w.sort);let z=new WeakMap;for(let Q=0;Q<X.length;++Q){let Z=X[Q];if(w.skipNulls&&W[Z]===null)continue;BA(Y,xA(W[Z],Z,G,H,w.allowEmptyArrays,w.strictNullHandling,w.skipNulls,w.encodeDotInKeys,w.encode?w.encoder:null,w.filter,w.sort,w.allowDots,w.serializeDate,w.format,w.formatter,w.encodeValuesOnly,w.charset,z))}let F=Y.join(w.delimiter),O=w.addQueryPrefix===!0?"?":"";if(w.charsetSentinel)if(w.charset==="iso-8859-1")O+="utf8=%26%2310003%3B&";else O+="utf8=%E2%9C%93&";return F.length>0?O+F:""}function yA($){let T=0;for(let X of $)T+=X.length;let W=new Uint8Array(T),w=0;for(let X of $)W.set(X,w),w+=X.length;return W}var fA;function sW($){let T;return(fA??(T=new globalThis.TextEncoder,fA=T.encode.bind(T)))($)}var bA;function RF($){let T;return(bA??(T=new globalThis.TextDecoder,bA=T.decode.bind(T)))($)}var e6,$1;class eW{constructor(){e6.set(this,void 0),$1.set(this,void 0),w$(this,e6,new Uint8Array,"f"),w$(this,$1,null,"f")}decode($){if($==null)return[];let T=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?sW($):$;w$(this,e6,yA([v(this,e6,"f"),T]),"f");let W=[],w;while((w=fS(v(this,e6,"f"),v(this,$1,"f")))!=null){if(w.carriage&&v(this,$1,"f")==null){w$(this,$1,w.index,"f");continue}if(v(this,$1,"f")!=null&&(w.index!==v(this,$1,"f")+1||w.carriage)){W.push(RF(v(this,e6,"f").subarray(0,v(this,$1,"f")-1))),w$(this,e6,v(this,e6,"f").subarray(v(this,$1,"f")),"f"),w$(this,$1,null,"f");continue}let X=v(this,$1,"f")!==null?w.preceding-1:w.preceding,U=RF(v(this,e6,"f").subarray(0,X));W.push(U),w$(this,e6,v(this,e6,"f").subarray(w.index),"f"),w$(this,$1,null,"f")}return W}flush(){if(!v(this,e6,"f").length)return[];return this.decode(`
62
+ `)}}e6=new WeakMap,$1=new WeakMap;eW.NEWLINE_CHARS=new Set([`
63
+ `,"\r"]);eW.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function fS($,T){for(let X=T??0;X<$.length;X++){if($[X]===10)return{preceding:X,index:X+1,carriage:!1};if($[X]===13)return{preceding:X,index:X+1,carriage:!0}}return null}function hA($){for(let w=0;w<$.length-1;w++){if($[w]===10&&$[w+1]===10)return w+2;if($[w]===13&&$[w+1]===13)return w+2;if($[w]===13&&$[w+1]===10&&w+3<$.length&&$[w+2]===13&&$[w+3]===10)return w+4}return-1}class T1{constructor($,T){this.iterator=$,this.controller=T}static fromSSEResponse($,T){let W=!1;async function*w(){if(W)throw new $$("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");W=!0;let X=!1;try{for await(let U of bS($,T)){if(X)continue;if(U.data.startsWith("[DONE]")){X=!0;continue}if(U.event===null||U.event.startsWith("response.")||U.event.startsWith("transcript.")){let Y;try{Y=JSON.parse(U.data)}catch(G){throw console.error("Could not parse message into JSON:",U.data),console.error("From chunk:",U.raw),G}if(Y&&Y.error)throw new L4(void 0,Y.error,void 0,$.headers);yield Y}else{let Y;try{Y=JSON.parse(U.data)}catch(G){throw console.error("Could not parse message into JSON:",U.data),console.error("From chunk:",U.raw),G}if(U.event=="error")throw new L4(void 0,Y.error,Y.message,void 0);yield{event:U.event,data:Y}}}X=!0}catch(U){if(K8(U))return;throw U}finally{if(!X)T.abort()}}return new T1(w,T)}static fromReadableStream($,T){let W=!1;async function*w(){let U=new eW,Y=EF($);for await(let G of Y)for(let H of U.decode(G))yield H;for(let G of U.flush())yield G}async function*X(){if(W)throw new $$("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");W=!0;let U=!1;try{for await(let Y of w()){if(U)continue;if(Y)yield JSON.parse(Y)}U=!0}catch(Y){if(K8(Y))return;throw Y}finally{if(!U)T.abort()}}return new T1(X,T)}[Symbol.asyncIterator](){return this.iterator()}tee(){let $=[],T=[],W=this.iterator(),w=(X)=>{return{next:()=>{if(X.length===0){let U=W.next();$.push(U),T.push(U)}return X.shift()}}};return[new T1(()=>w($),this.controller),new T1(()=>w(T),this.controller)]}toReadableStream(){let $=this,T;return AF({async start(){T=$[Symbol.asyncIterator]()},async pull(W){try{let{value:w,done:X}=await T.next();if(X)return W.close();let U=sW(JSON.stringify(w)+`
64
+ `);W.enqueue(U)}catch(w){W.error(w)}},async cancel(){await T.return?.()}})}}async function*bS($,T){if(!$.body){if(T.abort(),typeof globalThis.navigator!=="undefined"&&globalThis.navigator.product==="ReactNative")throw new $$("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new $$("Attempted to iterate over a response with no body")}let W=new gA,w=new eW,X=EF($.body);for await(let U of yS(X))for(let Y of w.decode(U)){let G=W.decode(Y);if(G)yield G}for(let U of w.flush()){let Y=W.decode(U);if(Y)yield Y}}async function*yS($){let T=new Uint8Array;for await(let W of $){if(W==null)continue;let w=W instanceof ArrayBuffer?new Uint8Array(W):typeof W==="string"?sW(W):W,X=new Uint8Array(T.length+w.length);X.set(T),X.set(w,T.length),T=X;let U;while((U=hA(T))!==-1)yield T.slice(0,U),T=T.slice(U)}if(T.length>0)yield T}class gA{constructor(){this.event=null,this.data=[],this.chunks=[]}decode($){if($.endsWith("\r"))$=$.substring(0,$.length-1);if(!$){if(!this.event&&!this.data.length)return null;let X={event:this.event,data:this.data.join(`
65
+ `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],X}if(this.chunks.push($),$.startsWith(":"))return null;let[T,W,w]=hS($,":");if(w.startsWith(" "))w=w.substring(1);if(T==="event")this.event=w;else if(T==="data")this.data.push(w);return null}}function hS($,T){let W=$.indexOf(T);if(W!==-1)return[$.substring(0,W),T,$.substring(W+T.length)];return[$,"",""]}async function FG($,T){let{response:W,requestLogID:w,retryOfRequestLogID:X,startTime:U}=T,Y=await(async()=>{if(T.options.stream){if(C4($).debug("response",W.status,W.url,W.headers,W.body),T.options.__streamClass)return T.options.__streamClass.fromSSEResponse(W,T.controller);return T1.fromSSEResponse(W,T.controller)}if(W.status===204)return null;if(T.options.__binaryResponse)return W;let H=W.headers.get("content-type")?.split(";")[0]?.trim();if(H?.includes("application/json")||H?.endsWith("+json")){let O=await W.json();return _F(O,W)}return await W.text()})();return C4($).debug(`[${w}] response parsed`,M0({retryOfRequestLogID:X,url:W.url,status:W.status,body:Y,durationMs:Date.now()-U})),Y}function _F($,T){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:T.headers.get("x-request-id"),enumerable:!1})}var j8;class tT extends Promise{constructor($,T,W=FG){super((w)=>{w(null)});this.responsePromise=T,this.parseResponse=W,j8.set(this,void 0),w$(this,j8,$,"f")}_thenUnwrap($){return new tT(v(this,j8,"f"),this.responsePromise,async(T,W)=>_F($(await this.parseResponse(T,W),W),W.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,T]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:T,request_id:T.headers.get("x-request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(($)=>this.parseResponse(v(this,j8,"f"),$));return this.parsedPromise}then($,T){return this.parse().then($,T)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}j8=new WeakMap;var OG;class kF{constructor($,T,W,w){OG.set(this,void 0),w$(this,OG,$,"f"),this.options=w,this.response=T,this.body=W}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageRequestOptions()!=null}async getNextPage(){let $=this.nextPageRequestOptions();if(!$)throw new $$("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await v(this,OG,"f").requestAPIList(this.constructor,$)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(OG=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let T of $.getPaginatedItems())yield T}}class QG extends tT{constructor($,T,W){super($,T,async(w,X)=>new W(w,X.response,await FG(w,X),X.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let T of $)yield T}}class D0 extends kF{constructor($,T,W,w){super($,T,W,w);this.data=W.data||[],this.object=W.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}}class J$ extends kF{constructor($,T,W,w){super($,T,W,w);this.data=W.data||[],this.has_more=W.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let $=this.getPaginatedItems(),T=$[$.length-1]?.id;if(!T)return null;return{...this.options,query:{...AA(this.options.query),after:T}}}}var qF=()=>{if(typeof File==="undefined"){let{process:$}=globalThis,T=typeof $?.versions?.node==="string"&&parseInt($.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(T?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function $2($,T,W){return qF(),new File($,T??"unknown_file",W)}function I8($){return(typeof $==="object"&&$!==null&&(("name"in $)&&$.name&&String($.name)||("url"in $)&&$.url&&String($.url)||("filename"in $)&&$.filename&&String($.filename)||("path"in $)&&$.path&&String($.path))||"").split(/[\\/]/).pop()||void 0}var PF=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function";var W1=async($,T)=>{return{...$,body:await cS($.body,T)}},mA=new WeakMap;function mS($){let T=typeof $==="function"?$:$.fetch,W=mA.get(T);if(W)return W;let w=(async()=>{try{let X="Response"in T?T.Response:(await T("data:,")).constructor,U=new FormData;if(U.toString()===await new X(U).text())return!1;return!0}catch{return!0}})();return mA.set(T,w),w}var cS=async($,T)=>{if(!await mS(T))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let W=new FormData;return await Promise.all(Object.entries($||{}).map(([w,X])=>vF(W,w,X))),W},uS=($)=>$ instanceof Blob&&("name"in $);var vF=async($,T,W)=>{if(W===void 0)return;if(W==null)throw new TypeError(`Received null for "${T}"; to pass null in FormData, you must use the string 'null'`);if(typeof W==="string"||typeof W==="number"||typeof W==="boolean")$.append(T,String(W));else if(W instanceof Response)$.append(T,$2([await W.blob()],I8(W)));else if(PF(W))$.append(T,$2([await new Response(HG(W)).blob()],I8(W)));else if(uS(W))$.append(T,W,I8(W));else if(Array.isArray(W))await Promise.all(W.map((w)=>vF($,T+"[]",w)));else if(typeof W==="object")await Promise.all(Object.entries(W).map(([w,X])=>vF($,`${T}[${w}]`,X)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${W} instead`)};var cA=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function",pS=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&cA($),dS=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function";async function ZG($,T,W){if(qF(),$=await $,pS($)){if($ instanceof File)return $;return $2([await $.arrayBuffer()],$.name)}if(dS($)){let X=await $.blob();return T||(T=new URL($.url).pathname.split(/[\\/]/).pop()),$2(await CF(X),T,W)}let w=await CF($);if(T||(T=I8($)),!W?.type){let X=w.find((U)=>typeof U==="object"&&("type"in U)&&U.type);if(typeof X==="string")W={...W,type:X}}return $2(w,T,W)}async function CF($){let T=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)T.push($);else if(cA($))T.push($ instanceof Blob?$:await $.arrayBuffer());else if(PF($))for await(let W of $)T.push(...await CF(W));else{let W=$?.constructor?.name;throw new Error(`Unexpected data type: ${typeof $}${W?`; constructor: ${W}`:""}${oS($)}`)}return T}function oS($){if(typeof $!=="object"||$===null)return"";return`; props: [${Object.getOwnPropertyNames($).map((W)=>`"${W}"`).join(", ")}]`}class m{constructor($){this._client=$}}function uA($){return $.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var rS=($=uA)=>function T(W,...w){if(W.length===1)return W[0];let X=!1,U=W.reduce((F,O,Q)=>{if(/[?#]/.test(O))X=!0;return F+O+(Q===w.length?"":(X?encodeURIComponent:$)(String(w[Q])))},""),Y=U.split(/[?#]/,1)[0],G=[],H=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,z;while((z=H.exec(Y))!==null)G.push({start:z.index,length:z[0].length});if(G.length>0){let F=0,O=G.reduce((Q,Z)=>{let K=" ".repeat(Z.start-F),E="^".repeat(Z.length);return F=Z.start+Z.length,Q+K+E},"");throw new $$(`Path parameters result in path with invalid segments:
66
+ ${U}
67
+ ${O}`)}return U},h=rS(uA);class T2 extends m{list($,T={},W){return this._client.getAPIList(h`/chat/completions/${$}/messages`,J$,{query:T,...W})}}function pA($){return typeof $.parse==="function"}var W2=($)=>{return $?.role==="assistant"},SF=($)=>{return $?.role==="tool"};var jF,VG,KG,B8,x8,AG,f8,N0,b8,EG,MG,X2,dA;class aT{constructor(){jF.add(this),this.controller=new AbortController,VG.set(this,void 0),KG.set(this,()=>{}),B8.set(this,()=>{}),x8.set(this,void 0),AG.set(this,()=>{}),f8.set(this,()=>{}),N0.set(this,{}),b8.set(this,!1),EG.set(this,!1),MG.set(this,!1),X2.set(this,!1),w$(this,VG,new Promise(($,T)=>{w$(this,KG,$,"f"),w$(this,B8,T,"f")}),"f"),w$(this,x8,new Promise(($,T)=>{w$(this,AG,$,"f"),w$(this,f8,T,"f")}),"f"),v(this,VG,"f").catch(()=>{}),v(this,x8,"f").catch(()=>{})}_run($){setTimeout(()=>{$().then(()=>{this._emitFinal(),this._emit("end")},v(this,jF,"m",dA).bind(this))},0)}_connected(){if(this.ended)return;v(this,KG,"f").call(this),this._emit("connect")}get ended(){return v(this,b8,"f")}get errored(){return v(this,EG,"f")}get aborted(){return v(this,MG,"f")}abort(){this.controller.abort()}on($,T){return(v(this,N0,"f")[$]||(v(this,N0,"f")[$]=[])).push({listener:T}),this}off($,T){let W=v(this,N0,"f")[$];if(!W)return this;let w=W.findIndex((X)=>X.listener===T);if(w>=0)W.splice(w,1);return this}once($,T){return(v(this,N0,"f")[$]||(v(this,N0,"f")[$]=[])).push({listener:T,once:!0}),this}emitted($){return new Promise((T,W)=>{if(w$(this,X2,!0,"f"),$!=="error")this.once("error",W);this.once($,T)})}async done(){w$(this,X2,!0,"f"),await v(this,x8,"f")}_emit($,...T){if(v(this,b8,"f"))return;if($==="end")w$(this,b8,!0,"f"),v(this,AG,"f").call(this);let W=v(this,N0,"f")[$];if(W)v(this,N0,"f")[$]=W.filter((w)=>!w.once),W.forEach(({listener:w})=>w(...T));if($==="abort"){let w=T[0];if(!v(this,X2,"f")&&!W?.length)Promise.reject(w);v(this,B8,"f").call(this,w),v(this,f8,"f").call(this,w),this._emit("end");return}if($==="error"){let w=T[0];if(!v(this,X2,"f")&&!W?.length)Promise.reject(w);v(this,B8,"f").call(this,w),v(this,f8,"f").call(this,w),this._emit("end")}}_emitFinal(){}}VG=new WeakMap,KG=new WeakMap,B8=new WeakMap,x8=new WeakMap,AG=new WeakMap,f8=new WeakMap,N0=new WeakMap,b8=new WeakMap,EG=new WeakMap,MG=new WeakMap,X2=new WeakMap,jF=new WeakSet,dA=function $(T){if(w$(this,EG,!0,"f"),T instanceof Error&&T.name==="AbortError")T=new P4;if(T instanceof P4)return w$(this,MG,!0,"f"),this._emit("abort",T);if(T instanceof $$)return this._emit("error",T);if(T instanceof Error){let W=new $$(T.message);return W.cause=T,this._emit("error",W)}return this._emit("error",new $$(String(T)))};function y8($){return $?.$brand==="auto-parseable-response-format"}function sT($){return $?.$brand==="auto-parseable-tool"}function oA($,T){if(!T||!IF(T))return{...$,choices:$.choices.map((W)=>({...W,message:{...W.message,parsed:null,...W.message.tool_calls?{tool_calls:W.message.tool_calls}:void 0}}))};return h8($,T)}function h8($,T){let W=$.choices.map((w)=>{if(w.finish_reason==="length")throw new k8;if(w.finish_reason==="content_filter")throw new v8;return{...w,message:{...w.message,...w.message.tool_calls?{tool_calls:w.message.tool_calls?.map((X)=>aS(T,X))??void 0}:void 0,parsed:w.message.content&&!w.message.refusal?tS(T,w.message.content):null}}});return{...$,choices:W}}function tS($,T){if($.response_format?.type!=="json_schema")return null;if($.response_format?.type==="json_schema"){if("$parseRaw"in $.response_format)return $.response_format.$parseRaw(T);return JSON.parse(T)}return null}function aS($,T){let W=$.tools?.find((w)=>w.function?.name===T.function.name);return{...T,function:{...T.function,parsed_arguments:sT(W)?W.$parseRaw(T.function.arguments):W?.function.strict?JSON.parse(T.function.arguments):null}}}function lA($,T){if(!$)return!1;let W=$.tools?.find((w)=>w.function?.name===T.function.name);return sT(W)||W?.function.strict||!1}function IF($){if(y8($.response_format))return!0;return $.tools?.some((T)=>sT(T)||T.type==="function"&&T.function.strict===!0)??!1}function rA($){for(let T of $??[]){if(T.type!=="function")throw new $$(`Currently only \`function\` tool types support auto-parsing; Received \`${T.type}\``);if(T.function.strict!==!0)throw new $$(`The \`${T.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var H6,BF,DG,xF,fF,bF,nA,iA,sS=10;class g8 extends aT{constructor(){super(...arguments);H6.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion($){this._chatCompletions.push($),this._emit("chatCompletion",$);let T=$.choices[0]?.message;if(T)this._addMessage(T);return $}_addMessage($,T=!0){if(!("content"in $))$.content=null;if(this.messages.push($),T){if(this._emit("message",$),SF($)&&$.content)this._emit("functionToolCallResult",$.content);else if(W2($)&&$.tool_calls){for(let W of $.tool_calls)if(W.type==="function")this._emit("functionToolCall",W.function)}}}async finalChatCompletion(){await this.done();let $=this._chatCompletions[this._chatCompletions.length-1];if(!$)throw new $$("stream ended without producing a ChatCompletion");return $}async finalContent(){return await this.done(),v(this,H6,"m",BF).call(this)}async finalMessage(){return await this.done(),v(this,H6,"m",DG).call(this)}async finalFunctionToolCall(){return await this.done(),v(this,H6,"m",xF).call(this)}async finalFunctionToolCallResult(){return await this.done(),v(this,H6,"m",fF).call(this)}async totalUsage(){return await this.done(),v(this,H6,"m",bF).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let $=this._chatCompletions[this._chatCompletions.length-1];if($)this._emit("finalChatCompletion",$);let T=v(this,H6,"m",DG).call(this);if(T)this._emit("finalMessage",T);let W=v(this,H6,"m",BF).call(this);if(W)this._emit("finalContent",W);let w=v(this,H6,"m",xF).call(this);if(w)this._emit("finalFunctionToolCall",w);let X=v(this,H6,"m",fF).call(this);if(X!=null)this._emit("finalFunctionToolCallResult",X);if(this._chatCompletions.some((U)=>U.usage))this._emit("totalUsage",v(this,H6,"m",bF).call(this))}async _createChatCompletion($,T,W){let w=W?.signal;if(w){if(w.aborted)this.controller.abort();w.addEventListener("abort",()=>this.controller.abort())}v(this,H6,"m",nA).call(this,T);let X=await $.chat.completions.create({...T,stream:!1},{...W,signal:this.controller.signal});return this._connected(),this._addChatCompletion(h8(X,T))}async _runChatCompletion($,T,W){for(let w of T.messages)this._addMessage(w,!1);return await this._createChatCompletion($,T,W)}async _runTools($,T,W){let{tool_choice:X="auto",stream:U,...Y}=T,G=typeof X!=="string"&&X?.function?.name,{maxChatCompletions:H=sS}=W||{},z=T.tools.map((Q)=>{if(sT(Q)){if(!Q.$callback)throw new $$("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:Q.$callback,name:Q.function.name,description:Q.function.description||"",parameters:Q.function.parameters,parse:Q.$parseRaw,strict:!0}}}return Q}),F={};for(let Q of z)if(Q.type==="function")F[Q.function.name||Q.function.function.name]=Q.function;let O="tools"in T?z.map((Q)=>Q.type==="function"?{type:"function",function:{name:Q.function.name||Q.function.function.name,parameters:Q.function.parameters,description:Q.function.description,strict:Q.function.strict}}:Q):void 0;for(let Q of T.messages)this._addMessage(Q,!1);for(let Q=0;Q<H;++Q){let K=(await this._createChatCompletion($,{...Y,tool_choice:X,tools:O,messages:[...this.messages]},W)).choices[0]?.message;if(!K)throw new $$("missing message in ChatCompletion response");if(!K.tool_calls?.length)return;for(let E of K.tool_calls){if(E.type!=="function")continue;let M=E.id,{name:L,arguments:R}=E.function,_=F[L];if(!_){let g=`Invalid tool_call: ${JSON.stringify(L)}. Available options are: ${Object.keys(F).map((T$)=>JSON.stringify(T$)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:M,content:g});continue}else if(G&&G!==L){let g=`Invalid tool_call: ${JSON.stringify(L)}. ${JSON.stringify(G)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:M,content:g});continue}let S;try{S=pA(_)?await _.parse(R):R}catch(g){let T$=g instanceof Error?g.message:String(g);this._addMessage({role:"tool",tool_call_id:M,content:T$});continue}let x=await _.function(S,this),b=v(this,H6,"m",iA).call(this,x);if(this._addMessage({role:"tool",tool_call_id:M,content:b}),G)return}}return}}H6=new WeakSet,BF=function $(){return v(this,H6,"m",DG).call(this).content??null},DG=function $(){let T=this.messages.length;while(T-- >0){let W=this.messages[T];if(W2(W))return{...W,content:W.content??null,refusal:W.refusal??null}}throw new $$("stream ended without producing a ChatCompletionMessage with role=assistant")},xF=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(W2(W)&&W?.tool_calls?.length)return W.tool_calls.at(-1)?.function}return},fF=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(SF(W)&&W.content!=null&&typeof W.content==="string"&&this.messages.some((w)=>w.role==="assistant"&&w.tool_calls?.some((X)=>X.type==="function"&&X.id===W.tool_call_id)))return W.content}return},bF=function $(){let T={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:W}of this._chatCompletions)if(W)T.completion_tokens+=W.completion_tokens,T.prompt_tokens+=W.prompt_tokens,T.total_tokens+=W.total_tokens;return T},nA=function $(T){if(T.n!=null&&T.n>1)throw new $$("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},iA=function $(T){return typeof T==="string"?T:T===void 0?"undefined":JSON.stringify(T)};class m8 extends g8{static runTools($,T,W){let w=new m8,X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return w._run(()=>w._runTools($,T,X)),w}_addMessage($,T=!0){if(super._addMessage($,T),W2($)&&$.content)this._emit("content",$.content)}}var g4={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511};class tA extends Error{}class aA extends Error{}function eS($,T=g4.ALL){if(typeof $!=="string")throw new TypeError(`expecting str, got ${typeof $}`);if(!$.trim())throw new Error(`${$} is empty`);return $j($.trim(),T)}var $j=($,T)=>{let W=$.length,w=0,X=(Q)=>{throw new tA(`${Q} at position ${w}`)},U=(Q)=>{throw new aA(`${Q} at position ${w}`)},Y=()=>{if(O(),w>=W)X("Unexpected end of input");if($[w]==='"')return G();if($[w]==="{")return H();if($[w]==="[")return z();if($.substring(w,w+4)==="null"||g4.NULL&T&&W-w<4&&"null".startsWith($.substring(w)))return w+=4,null;if($.substring(w,w+4)==="true"||g4.BOOL&T&&W-w<4&&"true".startsWith($.substring(w)))return w+=4,!0;if($.substring(w,w+5)==="false"||g4.BOOL&T&&W-w<5&&"false".startsWith($.substring(w)))return w+=5,!1;if($.substring(w,w+8)==="Infinity"||g4.INFINITY&T&&W-w<8&&"Infinity".startsWith($.substring(w)))return w+=8,1/0;if($.substring(w,w+9)==="-Infinity"||g4.MINUS_INFINITY&T&&1<W-w&&W-w<9&&"-Infinity".startsWith($.substring(w)))return w+=9,-1/0;if($.substring(w,w+3)==="NaN"||g4.NAN&T&&W-w<3&&"NaN".startsWith($.substring(w)))return w+=3,NaN;return F()},G=()=>{let Q=w,Z=!1;w++;while(w<W&&($[w]!=='"'||Z&&$[w-1]==="\\"))Z=$[w]==="\\"?!Z:!1,w++;if($.charAt(w)=='"')try{return JSON.parse($.substring(Q,++w-Number(Z)))}catch(K){U(String(K))}else if(g4.STR&T)try{return JSON.parse($.substring(Q,w-Number(Z))+'"')}catch(K){return JSON.parse($.substring(Q,$.lastIndexOf("\\"))+'"')}X("Unterminated string literal")},H=()=>{w++,O();let Q={};try{while($[w]!=="}"){if(O(),w>=W&&g4.OBJ&T)return Q;let Z=G();O(),w++;try{let K=Y();Object.defineProperty(Q,Z,{value:K,writable:!0,enumerable:!0,configurable:!0})}catch(K){if(g4.OBJ&T)return Q;else throw K}if(O(),$[w]===",")w++}}catch(Z){if(g4.OBJ&T)return Q;else X("Expected '}' at end of object")}return w++,Q},z=()=>{w++;let Q=[];try{while($[w]!=="]")if(Q.push(Y()),O(),$[w]===",")w++}catch(Z){if(g4.ARR&T)return Q;X("Expected ']' at end of array")}return w++,Q},F=()=>{if(w===0){if($==="-"&&g4.NUM&T)X("Not sure what '-' is");try{return JSON.parse($)}catch(Z){if(g4.NUM&T)try{if($[$.length-1]===".")return JSON.parse($.substring(0,$.lastIndexOf(".")));return JSON.parse($.substring(0,$.lastIndexOf("e")))}catch(K){}U(String(Z))}}let Q=w;if($[w]==="-")w++;while($[w]&&!",]}".includes($[w]))w++;if(w==W&&!(g4.NUM&T))X("Unterminated number literal");try{return JSON.parse($.substring(Q,w))}catch(Z){if($.substring(Q,w)==="-"&&g4.NUM&T)X("Not sure what '-' is");try{return JSON.parse($.substring(Q,$.lastIndexOf("e")))}catch(K){U(String(K))}}},O=()=>{while(w<W&&`
68
+ \r `.includes($[w]))w++};return Y()},yF=($)=>eS($,g4.ALL^g4.NUM);var j4,L0,w2,HT,hF,NG,gF,mF,cF,LG,uF,sA;class FT extends g8{constructor($){super();j4.add(this),L0.set(this,void 0),w2.set(this,void 0),HT.set(this,void 0),w$(this,L0,$,"f"),w$(this,w2,[],"f")}get currentChatCompletionSnapshot(){return v(this,HT,"f")}static fromReadableStream($){let T=new FT(null);return T._run(()=>T._fromReadableStream($)),T}static createChatCompletion($,T,W){let w=new FT(T);return w._run(()=>w._runChatCompletion($,{...T,stream:!0},{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),w}async _createChatCompletion($,T,W){super._createChatCompletion;let w=W?.signal;if(w){if(w.aborted)this.controller.abort();w.addEventListener("abort",()=>this.controller.abort())}v(this,j4,"m",hF).call(this);let X=await $.chat.completions.create({...T,stream:!0},{...W,signal:this.controller.signal});this._connected();for await(let U of X)v(this,j4,"m",gF).call(this,U);if(X.controller.signal?.aborted)throw new P4;return this._addChatCompletion(v(this,j4,"m",LG).call(this))}async _fromReadableStream($,T){let W=T?.signal;if(W){if(W.aborted)this.controller.abort();W.addEventListener("abort",()=>this.controller.abort())}v(this,j4,"m",hF).call(this),this._connected();let w=T1.fromReadableStream($,this.controller),X;for await(let U of w){if(X&&X!==U.id)this._addChatCompletion(v(this,j4,"m",LG).call(this));v(this,j4,"m",gF).call(this,U),X=U.id}if(w.controller.signal?.aborted)throw new P4;return this._addChatCompletion(v(this,j4,"m",LG).call(this))}[(L0=new WeakMap,w2=new WeakMap,HT=new WeakMap,j4=new WeakSet,hF=function $(){if(this.ended)return;w$(this,HT,void 0,"f")},NG=function $(T){let W=v(this,w2,"f")[T.index];if(W)return W;return W={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},v(this,w2,"f")[T.index]=W,W},gF=function $(T){if(this.ended)return;let W=v(this,j4,"m",sA).call(this,T);this._emit("chunk",T,W);for(let w of T.choices){let X=W.choices[w.index];if(w.delta.content!=null&&X.message?.role==="assistant"&&X.message?.content)this._emit("content",w.delta.content,X.message.content),this._emit("content.delta",{delta:w.delta.content,snapshot:X.message.content,parsed:X.message.parsed});if(w.delta.refusal!=null&&X.message?.role==="assistant"&&X.message?.refusal)this._emit("refusal.delta",{delta:w.delta.refusal,snapshot:X.message.refusal});if(w.logprobs?.content!=null&&X.message?.role==="assistant")this._emit("logprobs.content.delta",{content:w.logprobs?.content,snapshot:X.logprobs?.content??[]});if(w.logprobs?.refusal!=null&&X.message?.role==="assistant")this._emit("logprobs.refusal.delta",{refusal:w.logprobs?.refusal,snapshot:X.logprobs?.refusal??[]});let U=v(this,j4,"m",NG).call(this,X);if(X.finish_reason){if(v(this,j4,"m",cF).call(this,X),U.current_tool_call_index!=null)v(this,j4,"m",mF).call(this,X,U.current_tool_call_index)}for(let Y of w.delta.tool_calls??[]){if(U.current_tool_call_index!==Y.index){if(v(this,j4,"m",cF).call(this,X),U.current_tool_call_index!=null)v(this,j4,"m",mF).call(this,X,U.current_tool_call_index)}U.current_tool_call_index=Y.index}for(let Y of w.delta.tool_calls??[]){let G=X.message.tool_calls?.[Y.index];if(!G?.type)continue;if(G?.type==="function")this._emit("tool_calls.function.arguments.delta",{name:G.function?.name,index:Y.index,arguments:G.function.arguments,parsed_arguments:G.function.parsed_arguments,arguments_delta:Y.function?.arguments??""});else $E(G?.type)}}},mF=function $(T,W){if(v(this,j4,"m",NG).call(this,T).done_tool_calls.has(W))return;let X=T.message.tool_calls?.[W];if(!X)throw new Error("no tool call snapshot");if(!X.type)throw new Error("tool call snapshot missing `type`");if(X.type==="function"){let U=v(this,L0,"f")?.tools?.find((Y)=>Y.type==="function"&&Y.function.name===X.function.name);this._emit("tool_calls.function.arguments.done",{name:X.function.name,index:W,arguments:X.function.arguments,parsed_arguments:sT(U)?U.$parseRaw(X.function.arguments):U?.function.strict?JSON.parse(X.function.arguments):null})}else $E(X.type)},cF=function $(T){let W=v(this,j4,"m",NG).call(this,T);if(T.message.content&&!W.content_done){W.content_done=!0;let w=v(this,j4,"m",uF).call(this);this._emit("content.done",{content:T.message.content,parsed:w?w.$parseRaw(T.message.content):null})}if(T.message.refusal&&!W.refusal_done)W.refusal_done=!0,this._emit("refusal.done",{refusal:T.message.refusal});if(T.logprobs?.content&&!W.logprobs_content_done)W.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:T.logprobs.content});if(T.logprobs?.refusal&&!W.logprobs_refusal_done)W.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:T.logprobs.refusal})},LG=function $(){if(this.ended)throw new $$("stream has ended, this shouldn't happen");let T=v(this,HT,"f");if(!T)throw new $$("request ended without sending any chunks");return w$(this,HT,void 0,"f"),w$(this,w2,[],"f"),Tj(T,v(this,L0,"f"))},uF=function $(){let T=v(this,L0,"f")?.response_format;if(y8(T))return T;return null},sA=function $(T){var W,w,X,U;let Y=v(this,HT,"f"),{choices:G,...H}=T;if(!Y)Y=w$(this,HT,{...H,choices:[]},"f");else Object.assign(Y,H);for(let{delta:z,finish_reason:F,index:O,logprobs:Q=null,...Z}of T.choices){let K=Y.choices[O];if(!K)K=Y.choices[O]={finish_reason:F,index:O,message:{},logprobs:Q,...Z};if(Q)if(!K.logprobs)K.logprobs=Object.assign({},Q);else{let{content:x,refusal:b,...g}=Q;if(eA(g),Object.assign(K.logprobs,g),x)(W=K.logprobs).content??(W.content=[]),K.logprobs.content.push(...x);if(b)(w=K.logprobs).refusal??(w.refusal=[]),K.logprobs.refusal.push(...b)}if(F){if(K.finish_reason=F,v(this,L0,"f")&&IF(v(this,L0,"f"))){if(F==="length")throw new k8;if(F==="content_filter")throw new v8}}if(Object.assign(K,Z),!z)continue;let{content:E,refusal:M,function_call:L,role:R,tool_calls:_,...S}=z;if(eA(S),Object.assign(K.message,S),M)K.message.refusal=(K.message.refusal||"")+M;if(R)K.message.role=R;if(L)if(!K.message.function_call)K.message.function_call=L;else{if(L.name)K.message.function_call.name=L.name;if(L.arguments)(X=K.message.function_call).arguments??(X.arguments=""),K.message.function_call.arguments+=L.arguments}if(E){if(K.message.content=(K.message.content||"")+E,!K.message.refusal&&v(this,j4,"m",uF).call(this))K.message.parsed=yF(K.message.content)}if(_){if(!K.message.tool_calls)K.message.tool_calls=[];for(let{index:x,id:b,type:g,function:T$,...N$}of _){let j=(U=K.message.tool_calls)[x]??(U[x]={});if(Object.assign(j,N$),b)j.id=b;if(g)j.type=g;if(T$)j.function??(j.function={name:T$.name??"",arguments:""});if(T$?.name)j.function.name=T$.name;if(T$?.arguments){if(j.function.arguments+=T$.arguments,lA(v(this,L0,"f"),j))j.function.parsed_arguments=yF(j.function.arguments)}}}}return Y},Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("chunk",(w)=>{let X=T.shift();if(X)X.resolve(w);else $.push(w)}),this.on("end",()=>{W=!0;for(let w of T)w.resolve(void 0);T.length=0}),this.on("abort",(w)=>{W=!0;for(let X of T)X.reject(w);T.length=0}),this.on("error",(w)=>{W=!0;for(let X of T)X.reject(w);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((X,U)=>T.push({resolve:X,reject:U})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new T1(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function Tj($,T){let{id:W,choices:w,created:X,model:U,system_fingerprint:Y,...G}=$,H={...G,id:W,choices:w.map(({message:z,finish_reason:F,index:O,logprobs:Q,...Z})=>{if(!F)throw new $$(`missing finish_reason for choice ${O}`);let{content:K=null,function_call:E,tool_calls:M,...L}=z,R=z.role;if(!R)throw new $$(`missing role for choice ${O}`);if(E){let{arguments:_,name:S}=E;if(_==null)throw new $$(`missing function_call.arguments for choice ${O}`);if(!S)throw new $$(`missing function_call.name for choice ${O}`);return{...Z,message:{content:K,function_call:{arguments:_,name:S},role:R,refusal:z.refusal??null},finish_reason:F,index:O,logprobs:Q}}if(M)return{...Z,index:O,finish_reason:F,logprobs:Q,message:{...L,role:R,content:K,refusal:z.refusal??null,tool_calls:M.map((_,S)=>{let{function:x,type:b,id:g,...T$}=_,{arguments:N$,name:j,...U$}=x||{};if(g==null)throw new $$(`missing choices[${O}].tool_calls[${S}].id
69
+ ${JG($)}`);if(b==null)throw new $$(`missing choices[${O}].tool_calls[${S}].type
70
+ ${JG($)}`);if(j==null)throw new $$(`missing choices[${O}].tool_calls[${S}].function.name
71
+ ${JG($)}`);if(N$==null)throw new $$(`missing choices[${O}].tool_calls[${S}].function.arguments
72
+ ${JG($)}`);return{...T$,id:g,type:b,function:{...U$,name:j,arguments:N$}}})}};return{...Z,message:{...L,content:K,role:R,refusal:z.refusal??null},finish_reason:F,index:O,logprobs:Q}}),created:X,model:U,object:"chat.completion",...Y?{system_fingerprint:Y}:{}};return oA(H,T)}function JG($){return JSON.stringify($)}function eA($){return}function $E($){}class U2 extends FT{static fromReadableStream($){let T=new U2(null);return T._run(()=>T._fromReadableStream($)),T}static runTools($,T,W){let w=new U2(T),X={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return w._run(()=>w._runTools($,T,X)),w}}class OT extends m{constructor(){super(...arguments);this.messages=new T2(this._client)}create($,T){return this._client.post("/chat/completions",{body:$,...T,stream:$.stream??!1})}retrieve($,T){return this._client.get(h`/chat/completions/${$}`,T)}update($,T,W){return this._client.post(h`/chat/completions/${$}`,{body:T,...W})}list($={},T){return this._client.getAPIList("/chat/completions",J$,{query:$,...T})}delete($,T){return this._client.delete(h`/chat/completions/${$}`,T)}parse($,T){return rA($.tools),this._client.chat.completions.create($,{...T,headers:{...T?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap((W)=>h8(W,$))}runTools($,T){if($.stream)return U2.runTools(this._client,$,T);return m8.runTools(this._client,$,T)}stream($,T){return FT.createChatCompletion(this._client,$,T)}}OT.Messages=T2;class eT extends m{constructor(){super(...arguments);this.completions=new OT(this._client)}}eT.Completions=OT;var WE=Symbol("brand.privateNullableHeaders"),TE=Array.isArray;function*Xj($){if(!$)return;if(WE in $){let{values:w,nulls:X}=$;yield*w.entries();for(let U of X)yield[U,null];return}let T=!1,W;if($ instanceof Headers)W=$.entries();else if(TE($))W=$;else T=!0,W=Object.entries($??{});for(let w of W){let X=w[0];if(typeof X!=="string")throw new TypeError("expected header name to be a string");let U=TE(w[1])?w[1]:[w[1]],Y=!1;for(let G of U){if(G===void 0)continue;if(T&&!Y)Y=!0,yield[X,null];yield[X,G]}}}var a=($)=>{let T=new Headers,W=new Set;for(let w of $){let X=new Set;for(let[U,Y]of Xj(w)){let G=U.toLowerCase();if(!X.has(G))T.delete(U),X.add(G);if(Y===null)T.delete(U),W.add(G);else T.append(U,Y),W.delete(G)}}return{[WE]:!0,values:T,nulls:W}};class c8 extends m{create($,T){return this._client.post("/audio/speech",{body:$,...T,headers:a([{Accept:"application/octet-stream"},T?.headers]),__binaryResponse:!0})}}class u8 extends m{create($,T){return this._client.post("/audio/transcriptions",W1({body:$,...T,stream:$.stream??!1,__metadata:{model:$.model}},this._client))}}class p8 extends m{create($,T){return this._client.post("/audio/translations",W1({body:$,...T,__metadata:{model:$.model}},this._client))}}class J0 extends m{constructor(){super(...arguments);this.transcriptions=new u8(this._client),this.translations=new p8(this._client),this.speech=new c8(this._client)}}J0.Transcriptions=u8;J0.Translations=p8;J0.Speech=c8;class Y2 extends m{create($,T){return this._client.post("/batches",{body:$,...T})}retrieve($,T){return this._client.get(h`/batches/${$}`,T)}list($={},T){return this._client.getAPIList("/batches",J$,{query:$,...T})}cancel($,T){return this._client.post(h`/batches/${$}/cancel`,T)}}class d8 extends m{create($,T){return this._client.post("/assistants",{body:$,...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}retrieve($,T){return this._client.get(h`/assistants/${$}`,{...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}update($,T,W){return this._client.post(h`/assistants/${$}`,{body:T,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}list($={},T){return this._client.getAPIList("/assistants",J$,{query:$,...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}delete($,T){return this._client.delete(h`/assistants/${$}`,{...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}}class o8 extends m{create($,T){return this._client.post("/realtime/sessions",{body:$,...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}}class l8 extends m{create($,T){return this._client.post("/realtime/transcription_sessions",{body:$,...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}}class $W extends m{constructor(){super(...arguments);this.sessions=new o8(this._client),this.transcriptionSessions=new l8(this._client)}}$W.Sessions=o8;$W.TranscriptionSessions=l8;class r8 extends m{create($,T,W){return this._client.post(h`/threads/${$}/messages`,{body:T,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}retrieve($,T,W){let{thread_id:w}=T;return this._client.get(h`/threads/${w}/messages/${$}`,{...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}update($,T,W){let{thread_id:w,...X}=T;return this._client.post(h`/threads/${w}/messages/${$}`,{body:X,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}list($,T={},W){return this._client.getAPIList(h`/threads/${$}/messages`,J$,{query:T,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}delete($,T,W){let{thread_id:w}=T;return this._client.delete(h`/threads/${w}/messages/${$}`,{...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}}class n8 extends m{retrieve($,T,W){let{thread_id:w,run_id:X,...U}=T;return this._client.get(h`/threads/${w}/runs/${X}/steps/${$}`,{query:U,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}list($,T,W){let{thread_id:w,...X}=T;return this._client.getAPIList(h`/threads/${w}/runs/${$}/steps`,J$,{query:X,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}}var XE=($)=>{if(typeof Buffer!=="undefined"){let T=Buffer.from($,"base64");return Array.from(new Float32Array(T.buffer,T.byteOffset,T.length/Float32Array.BYTES_PER_ELEMENT))}else{let T=atob($),W=T.length,w=new Uint8Array(W);for(let X=0;X<W;X++)w[X]=T.charCodeAt(X);return Array.from(new Float32Array(w.buffer))}};var TW=($)=>{if(typeof globalThis.process!=="undefined")return globalThis.process.env?.[$]?.trim()??void 0;if(typeof globalThis.Deno!=="undefined")return globalThis.Deno.env?.get?.($)?.trim();return};var o4,XW,pF,i1,RG,S1,wW,G2,WW,vG,X1,_G,kG,a8,i8,t8,wE,UE,YE,GE,zE,HE,FE;class QT extends aT{constructor(){super(...arguments);o4.add(this),pF.set(this,[]),i1.set(this,{}),RG.set(this,{}),S1.set(this,void 0),wW.set(this,void 0),G2.set(this,void 0),WW.set(this,void 0),vG.set(this,void 0),X1.set(this,void 0),_G.set(this,void 0),kG.set(this,void 0),a8.set(this,void 0)}[(pF=new WeakMap,i1=new WeakMap,RG=new WeakMap,S1=new WeakMap,wW=new WeakMap,G2=new WeakMap,WW=new WeakMap,vG=new WeakMap,X1=new WeakMap,_G=new WeakMap,kG=new WeakMap,a8=new WeakMap,o4=new WeakSet,Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(w)=>{let X=T.shift();if(X)X.resolve(w);else $.push(w)}),this.on("end",()=>{W=!0;for(let w of T)w.resolve(void 0);T.length=0}),this.on("abort",(w)=>{W=!0;for(let X of T)X.reject(w);T.length=0}),this.on("error",(w)=>{W=!0;for(let X of T)X.reject(w);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((X,U)=>T.push({resolve:X,reject:U})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream($){let T=new XW;return T._run(()=>T._fromReadableStream($)),T}async _fromReadableStream($,T){let W=T?.signal;if(W){if(W.aborted)this.controller.abort();W.addEventListener("abort",()=>this.controller.abort())}this._connected();let w=T1.fromReadableStream($,this.controller);for await(let X of w)v(this,o4,"m",i8).call(this,X);if(w.controller.signal?.aborted)throw new P4;return this._addRun(v(this,o4,"m",t8).call(this))}toReadableStream(){return new T1(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream($,T,W,w){let X=new XW;return X._run(()=>X._runToolAssistantStream($,T,W,{...w,headers:{...w?.headers,"X-Stainless-Helper-Method":"stream"}})),X}async _createToolAssistantStream($,T,W,w){let X=w?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}let U={...W,stream:!0},Y=await $.submitToolOutputs(T,U,{...w,signal:this.controller.signal});this._connected();for await(let G of Y)v(this,o4,"m",i8).call(this,G);if(Y.controller.signal?.aborted)throw new P4;return this._addRun(v(this,o4,"m",t8).call(this))}static createThreadAssistantStream($,T,W){let w=new XW;return w._run(()=>w._threadAssistantStream($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),w}static createAssistantStream($,T,W,w){let X=new XW;return X._run(()=>X._runAssistantStream($,T,W,{...w,headers:{...w?.headers,"X-Stainless-Helper-Method":"stream"}})),X}currentEvent(){return v(this,_G,"f")}currentRun(){return v(this,kG,"f")}currentMessageSnapshot(){return v(this,S1,"f")}currentRunStepSnapshot(){return v(this,a8,"f")}async finalRunSteps(){return await this.done(),Object.values(v(this,i1,"f"))}async finalMessages(){return await this.done(),Object.values(v(this,RG,"f"))}async finalRun(){if(await this.done(),!v(this,wW,"f"))throw Error("Final run was not received.");return v(this,wW,"f")}async _createThreadAssistantStream($,T,W){let w=W?.signal;if(w){if(w.aborted)this.controller.abort();w.addEventListener("abort",()=>this.controller.abort())}let X={...T,stream:!0},U=await $.createAndRun(X,{...W,signal:this.controller.signal});this._connected();for await(let Y of U)v(this,o4,"m",i8).call(this,Y);if(U.controller.signal?.aborted)throw new P4;return this._addRun(v(this,o4,"m",t8).call(this))}async _createAssistantStream($,T,W,w){let X=w?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}let U={...W,stream:!0},Y=await $.create(T,U,{...w,signal:this.controller.signal});this._connected();for await(let G of Y)v(this,o4,"m",i8).call(this,G);if(Y.controller.signal?.aborted)throw new P4;return this._addRun(v(this,o4,"m",t8).call(this))}static accumulateDelta($,T){for(let[W,w]of Object.entries(T)){if(!$.hasOwnProperty(W)){$[W]=w;continue}let X=$[W];if(X===null||X===void 0){$[W]=w;continue}if(W==="index"||W==="type"){$[W]=w;continue}if(typeof X==="string"&&typeof w==="string")X+=w;else if(typeof X==="number"&&typeof w==="number")X+=w;else if(q8(X)&&q8(w))X=this.accumulateDelta(X,w);else if(Array.isArray(X)&&Array.isArray(w)){if(X.every((U)=>typeof U==="string"||typeof U==="number")){X.push(...w);continue}for(let U of w){if(!q8(U))throw new Error(`Expected array delta entry to be an object but got: ${U}`);let Y=U.index;if(Y==null)throw console.error(U),new Error("Expected array delta entry to have an `index` property");if(typeof Y!=="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${Y}`);let G=X[Y];if(G==null)X.push(U);else X[Y]=this.accumulateDelta(G,U)}continue}else throw Error(`Unhandled record type: ${W}, deltaValue: ${w}, accValue: ${X}`);$[W]=X}return $}_addRun($){return $}async _threadAssistantStream($,T,W){return await this._createThreadAssistantStream(T,$,W)}async _runAssistantStream($,T,W,w){return await this._createAssistantStream(T,$,W,w)}async _runToolAssistantStream($,T,W,w){return await this._createToolAssistantStream(T,$,W,w)}}XW=QT,i8=function $(T){if(this.ended)return;switch(w$(this,_G,T,"f"),v(this,o4,"m",YE).call(this,T),T.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":v(this,o4,"m",FE).call(this,T);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":v(this,o4,"m",UE).call(this,T);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":v(this,o4,"m",wE).call(this,T);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");default:Zj(T)}},t8=function $(){if(this.ended)throw new $$("stream has ended, this shouldn't happen");if(!v(this,wW,"f"))throw Error("Final run has not been received");return v(this,wW,"f")},wE=function $(T){let[W,w]=v(this,o4,"m",zE).call(this,T,v(this,S1,"f"));w$(this,S1,W,"f"),v(this,RG,"f")[W.id]=W;for(let X of w){let U=W.content[X.index];if(U?.type=="text")this._emit("textCreated",U.text)}switch(T.event){case"thread.message.created":this._emit("messageCreated",T.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",T.data.delta,W),T.data.delta.content)for(let X of T.data.delta.content){if(X.type=="text"&&X.text){let U=X.text,Y=W.content[X.index];if(Y&&Y.type=="text")this._emit("textDelta",U,Y.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(X.index!=v(this,G2,"f")){if(v(this,WW,"f"))switch(v(this,WW,"f").type){case"text":this._emit("textDone",v(this,WW,"f").text,v(this,S1,"f"));break;case"image_file":this._emit("imageFileDone",v(this,WW,"f").image_file,v(this,S1,"f"));break}w$(this,G2,X.index,"f")}w$(this,WW,W.content[X.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(v(this,G2,"f")!==void 0){let X=T.data.content[v(this,G2,"f")];if(X)switch(X.type){case"image_file":this._emit("imageFileDone",X.image_file,v(this,S1,"f"));break;case"text":this._emit("textDone",X.text,v(this,S1,"f"));break}}if(v(this,S1,"f"))this._emit("messageDone",T.data);w$(this,S1,void 0,"f")}},UE=function $(T){let W=v(this,o4,"m",GE).call(this,T);switch(w$(this,a8,W,"f"),T.event){case"thread.run.step.created":this._emit("runStepCreated",T.data);break;case"thread.run.step.delta":let w=T.data.delta;if(w.step_details&&w.step_details.type=="tool_calls"&&w.step_details.tool_calls&&W.step_details.type=="tool_calls")for(let U of w.step_details.tool_calls)if(U.index==v(this,vG,"f"))this._emit("toolCallDelta",U,W.step_details.tool_calls[U.index]);else{if(v(this,X1,"f"))this._emit("toolCallDone",v(this,X1,"f"));if(w$(this,vG,U.index,"f"),w$(this,X1,W.step_details.tool_calls[U.index],"f"),v(this,X1,"f"))this._emit("toolCallCreated",v(this,X1,"f"))}this._emit("runStepDelta",T.data.delta,W);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":if(w$(this,a8,void 0,"f"),T.data.step_details.type=="tool_calls"){if(v(this,X1,"f"))this._emit("toolCallDone",v(this,X1,"f")),w$(this,X1,void 0,"f")}this._emit("runStepDone",T.data,W);break;case"thread.run.step.in_progress":break}},YE=function $(T){v(this,pF,"f").push(T),this._emit("event",T)},GE=function $(T){switch(T.event){case"thread.run.step.created":return v(this,i1,"f")[T.data.id]=T.data,T.data;case"thread.run.step.delta":let W=v(this,i1,"f")[T.data.id];if(!W)throw Error("Received a RunStepDelta before creation of a snapshot");let w=T.data;if(w.delta){let X=XW.accumulateDelta(W,w.delta);v(this,i1,"f")[T.data.id]=X}return v(this,i1,"f")[T.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":v(this,i1,"f")[T.data.id]=T.data;break}if(v(this,i1,"f")[T.data.id])return v(this,i1,"f")[T.data.id];throw new Error("No snapshot available")},zE=function $(T,W){let w=[];switch(T.event){case"thread.message.created":return[T.data,w];case"thread.message.delta":if(!W)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let X=T.data;if(X.delta.content)for(let U of X.delta.content)if(U.index in W.content){let Y=W.content[U.index];W.content[U.index]=v(this,o4,"m",HE).call(this,U,Y)}else W.content[U.index]=U,w.push(U);return[W,w];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(W)return[W,w];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},HE=function $(T,W){return XW.accumulateDelta(W,T)},FE=function $(T){switch(w$(this,kG,T.data,"f"),T.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":if(w$(this,wW,T.data,"f"),v(this,X1,"f"))this._emit("toolCallDone",v(this,X1,"f")),w$(this,X1,void 0,"f");break;case"thread.run.cancelling":break}};function Zj($){}class z2 extends m{constructor(){super(...arguments);this.steps=new n8(this._client)}create($,T,W){let{include:w,...X}=T;return this._client.post(h`/threads/${$}/runs`,{query:{include:w},body:X,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers]),stream:T.stream??!1})}retrieve($,T,W){let{thread_id:w}=T;return this._client.get(h`/threads/${w}/runs/${$}`,{...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}update($,T,W){let{thread_id:w,...X}=T;return this._client.post(h`/threads/${w}/runs/${$}`,{body:X,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}list($,T={},W){return this._client.getAPIList(h`/threads/${$}/runs`,J$,{query:T,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}cancel($,T,W){let{thread_id:w}=T;return this._client.post(h`/threads/${w}/runs/${$}/cancel`,{...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}async createAndPoll($,T,W){let w=await this.create($,T,W);return await this.poll(w.id,{thread_id:$},W)}createAndStream($,T,W){return QT.createAssistantStream($,this._client.beta.threads.runs,T,W)}async poll($,T,W){let w=a([W?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":W?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:X,response:U}=await this.retrieve($,T,{...W,headers:{...W?.headers,...w}}).withResponse();switch(X.status){case"queued":case"in_progress":case"cancelling":let Y=5000;if(W?.pollIntervalMs)Y=W.pollIntervalMs;else{let G=U.headers.get("openai-poll-after-ms");if(G){let H=parseInt(G);if(!isNaN(H))Y=H}}await l1(Y);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return X}}}stream($,T,W){return QT.createAssistantStream($,this._client.beta.threads.runs,T,W)}submitToolOutputs($,T,W){let{thread_id:w,...X}=T;return this._client.post(h`/threads/${w}/runs/${$}/submit_tool_outputs`,{body:X,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers]),stream:T.stream??!1})}async submitToolOutputsAndPoll($,T,W){let w=await this.submitToolOutputs($,T,W);return await this.poll(w.id,T,W)}submitToolOutputsStream($,T,W){return QT.createToolAssistantStream($,this._client.beta.threads.runs,T,W)}}z2.Steps=n8;class UW extends m{constructor(){super(...arguments);this.runs=new z2(this._client),this.messages=new r8(this._client)}create($={},T){return this._client.post("/threads",{body:$,...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}retrieve($,T){return this._client.get(h`/threads/${$}`,{...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}update($,T,W){return this._client.post(h`/threads/${$}`,{body:T,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}delete($,T){return this._client.delete(h`/threads/${$}`,{...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}createAndRun($,T){return this._client.post("/threads/runs",{body:$,...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers]),stream:$.stream??!1})}async createAndRunPoll($,T){let W=await this.createAndRun($,T);return await this.runs.poll(W.id,{thread_id:W.thread_id},T)}createAndRunStream($,T){return QT.createThreadAssistantStream($,this._client.beta.threads,T)}}UW.Runs=z2;UW.Messages=r8;class R0 extends m{constructor(){super(...arguments);this.realtime=new $W(this._client),this.assistants=new d8(this._client),this.threads=new UW(this._client)}}R0.Realtime=$W;R0.Assistants=d8;R0.Threads=UW;class H2 extends m{create($,T){return this._client.post("/completions",{body:$,...T,stream:$.stream??!1})}}class s8 extends m{retrieve($,T,W){let{container_id:w}=T;return this._client.get(h`/containers/${w}/files/${$}/content`,{...W,headers:a([{Accept:"application/binary"},W?.headers]),__binaryResponse:!0})}}class F2 extends m{constructor(){super(...arguments);this.content=new s8(this._client)}create($,T,W){return this._client.post(h`/containers/${$}/files`,W1({body:T,...W},this._client))}retrieve($,T,W){let{container_id:w}=T;return this._client.get(h`/containers/${w}/files/${$}`,W)}list($,T={},W){return this._client.getAPIList(h`/containers/${$}/files`,J$,{query:T,...W})}delete($,T,W){let{container_id:w}=T;return this._client.delete(h`/containers/${w}/files/${$}`,{...W,headers:a([{Accept:"*/*"},W?.headers])})}}F2.Content=s8;class YW extends m{constructor(){super(...arguments);this.files=new F2(this._client)}create($,T){return this._client.post("/containers",{body:$,...T})}retrieve($,T){return this._client.get(h`/containers/${$}`,T)}list($={},T){return this._client.getAPIList("/containers",J$,{query:$,...T})}delete($,T){return this._client.delete(h`/containers/${$}`,{...T,headers:a([{Accept:"*/*"},T?.headers])})}}YW.Files=F2;class O2 extends m{create($,T){let W=!!$.encoding_format,w=W?$.encoding_format:"base64";if(W)C4(this._client).debug("embeddings/user defined encoding_format:",$.encoding_format);let X=this._client.post("/embeddings",{body:{...$,encoding_format:w},...T});if(W)return X;return C4(this._client).debug("embeddings/decoding base64 embeddings from base64"),X._thenUnwrap((U)=>{if(U&&U.data)U.data.forEach((Y)=>{let G=Y.embedding;Y.embedding=XE(G)});return U})}}class e8 extends m{retrieve($,T,W){let{eval_id:w,run_id:X}=T;return this._client.get(h`/evals/${w}/runs/${X}/output_items/${$}`,W)}list($,T,W){let{eval_id:w,...X}=T;return this._client.getAPIList(h`/evals/${w}/runs/${$}/output_items`,J$,{query:X,...W})}}class Q2 extends m{constructor(){super(...arguments);this.outputItems=new e8(this._client)}create($,T,W){return this._client.post(h`/evals/${$}/runs`,{body:T,...W})}retrieve($,T,W){let{eval_id:w}=T;return this._client.get(h`/evals/${w}/runs/${$}`,W)}list($,T={},W){return this._client.getAPIList(h`/evals/${$}/runs`,J$,{query:T,...W})}delete($,T,W){let{eval_id:w}=T;return this._client.delete(h`/evals/${w}/runs/${$}`,W)}cancel($,T,W){let{eval_id:w}=T;return this._client.post(h`/evals/${w}/runs/${$}`,W)}}Q2.OutputItems=e8;class GW extends m{constructor(){super(...arguments);this.runs=new Q2(this._client)}create($,T){return this._client.post("/evals",{body:$,...T})}retrieve($,T){return this._client.get(h`/evals/${$}`,T)}update($,T,W){return this._client.post(h`/evals/${$}`,{body:T,...W})}list($={},T){return this._client.getAPIList("/evals",J$,{query:$,...T})}delete($,T){return this._client.delete(h`/evals/${$}`,T)}}GW.Runs=Q2;class Z2 extends m{create($,T){return this._client.post("/files",W1({body:$,...T},this._client))}retrieve($,T){return this._client.get(h`/files/${$}`,T)}list($={},T){return this._client.getAPIList("/files",J$,{query:$,...T})}delete($,T){return this._client.delete(h`/files/${$}`,T)}content($,T){return this._client.get(h`/files/${$}/content`,{...T,headers:a([{Accept:"application/binary"},T?.headers]),__binaryResponse:!0})}async waitForProcessing($,{pollInterval:T=5000,maxWait:W=1800000}={}){let w=new Set(["processed","error","deleted"]),X=Date.now(),U=await this.retrieve($);while(!U.status||!w.has(U.status))if(await l1(T),U=await this.retrieve($),Date.now()-X>W)throw new iT({message:`Giving up on waiting for file ${$} to finish processing after ${W} milliseconds.`});return U}}class $w extends m{}class Tw extends m{run($,T){return this._client.post("/fine_tuning/alpha/graders/run",{body:$,...T})}validate($,T){return this._client.post("/fine_tuning/alpha/graders/validate",{body:$,...T})}}class V2 extends m{constructor(){super(...arguments);this.graders=new Tw(this._client)}}V2.Graders=Tw;class Ww extends m{create($,T,W){return this._client.getAPIList(h`/fine_tuning/checkpoints/${$}/permissions`,D0,{body:T,method:"post",...W})}retrieve($,T={},W){return this._client.get(h`/fine_tuning/checkpoints/${$}/permissions`,{query:T,...W})}delete($,T,W){let{fine_tuned_model_checkpoint:w}=T;return this._client.delete(h`/fine_tuning/checkpoints/${w}/permissions/${$}`,W)}}class K2 extends m{constructor(){super(...arguments);this.permissions=new Ww(this._client)}}K2.Permissions=Ww;class Xw extends m{list($,T={},W){return this._client.getAPIList(h`/fine_tuning/jobs/${$}/checkpoints`,J$,{query:T,...W})}}class A2 extends m{constructor(){super(...arguments);this.checkpoints=new Xw(this._client)}create($,T){return this._client.post("/fine_tuning/jobs",{body:$,...T})}retrieve($,T){return this._client.get(h`/fine_tuning/jobs/${$}`,T)}list($={},T){return this._client.getAPIList("/fine_tuning/jobs",J$,{query:$,...T})}cancel($,T){return this._client.post(h`/fine_tuning/jobs/${$}/cancel`,T)}listEvents($,T={},W){return this._client.getAPIList(h`/fine_tuning/jobs/${$}/events`,J$,{query:T,...W})}pause($,T){return this._client.post(h`/fine_tuning/jobs/${$}/pause`,T)}resume($,T){return this._client.post(h`/fine_tuning/jobs/${$}/resume`,T)}}A2.Checkpoints=Xw;class t1 extends m{constructor(){super(...arguments);this.methods=new $w(this._client),this.jobs=new A2(this._client),this.checkpoints=new K2(this._client),this.alpha=new V2(this._client)}}t1.Methods=$w;t1.Jobs=A2;t1.Checkpoints=K2;t1.Alpha=V2;class ww extends m{}class zW extends m{constructor(){super(...arguments);this.graderModels=new ww(this._client)}}zW.GraderModels=ww;class E2 extends m{createVariation($,T){return this._client.post("/images/variations",W1({body:$,...T},this._client))}edit($,T){return this._client.post("/images/edits",W1({body:$,...T},this._client))}generate($,T){return this._client.post("/images/generations",{body:$,...T})}}class M2 extends m{retrieve($,T){return this._client.get(h`/models/${$}`,T)}list($){return this._client.getAPIList("/models",D0,$)}delete($,T){return this._client.delete(h`/models/${$}`,T)}}class D2 extends m{create($,T){return this._client.post("/moderations",{body:$,...T})}}function OE($,T){if(!T||!Cj(T))return{...$,output_parsed:null,output:$.output.map((W)=>{if(W.type==="function_call")return{...W,parsed_arguments:null};if(W.type==="message")return{...W,content:W.content.map((w)=>({...w,parsed:null}))};else return W})};return dF($,T)}function dF($,T){let W=$.output.map((X)=>{if(X.type==="function_call")return{...X,parsed_arguments:Ij(T,X)};if(X.type==="message"){let U=X.content.map((Y)=>{if(Y.type==="output_text")return{...Y,parsed:Pj(T,Y.text)};return Y});return{...X,content:U}}return X}),w=Object.assign({},$,{output:W});if(!Object.getOwnPropertyDescriptor($,"output_text"))oF(w);return Object.defineProperty(w,"output_parsed",{enumerable:!0,get(){for(let X of w.output){if(X.type!=="message")continue;for(let U of X.content)if(U.type==="output_text"&&U.parsed!==null)return U.parsed}return null}}),w}function Pj($,T){if($.text?.format?.type!=="json_schema")return null;if("$parseRaw"in $.text?.format)return($.text?.format).$parseRaw(T);return JSON.parse(T)}function Cj($){if(y8($.text?.format))return!0;return!1}function Sj($){return $?.$brand==="auto-parseable-tool"}function jj($,T){return $.find((W)=>W.type==="function"&&W.name===T)}function Ij($,T){let W=jj($.tools??[],T.name);return{...T,...T,parsed_arguments:Sj(W)?W.$parseRaw(T.arguments):W?.strict?JSON.parse(T.arguments):null}}function oF($){let T=[];for(let W of $.output){if(W.type!=="message")continue;for(let w of W.content)if(w.type==="output_text")T.push(w.text)}$.output_text=T.join("")}var N2,qG,ZT,PG,QE,ZE,VE,KE;class CG extends aT{constructor($){super();N2.add(this),qG.set(this,void 0),ZT.set(this,void 0),PG.set(this,void 0),w$(this,qG,$,"f")}static createResponse($,T,W){let w=new CG(T);return w._run(()=>w._createOrRetrieveResponse($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),w}async _createOrRetrieveResponse($,T,W){let w=W?.signal;if(w){if(w.aborted)this.controller.abort();w.addEventListener("abort",()=>this.controller.abort())}v(this,N2,"m",QE).call(this);let X,U=null;if("response_id"in T)X=await $.responses.retrieve(T.response_id,{stream:!0},{...W,signal:this.controller.signal,stream:!0}),U=T.starting_after??null;else X=await $.responses.create({...T,stream:!0},{...W,signal:this.controller.signal});this._connected();for await(let Y of X)v(this,N2,"m",ZE).call(this,Y,U);if(X.controller.signal?.aborted)throw new P4;return v(this,N2,"m",VE).call(this)}[(qG=new WeakMap,ZT=new WeakMap,PG=new WeakMap,N2=new WeakSet,QE=function $(){if(this.ended)return;w$(this,ZT,void 0,"f")},ZE=function $(T,W){if(this.ended)return;let w=(U,Y)=>{if(W==null||Y.sequence_number>W)this._emit(U,Y)},X=v(this,N2,"m",KE).call(this,T);switch(w("event",T),T.type){case"response.output_text.delta":{let U=X.output[T.output_index];if(!U)throw new $$(`missing output at index ${T.output_index}`);if(U.type==="message"){let Y=U.content[T.content_index];if(!Y)throw new $$(`missing content at index ${T.content_index}`);if(Y.type!=="output_text")throw new $$(`expected content to be 'output_text', got ${Y.type}`);w("response.output_text.delta",{...T,snapshot:Y.text})}break}case"response.function_call_arguments.delta":{let U=X.output[T.output_index];if(!U)throw new $$(`missing output at index ${T.output_index}`);if(U.type==="function_call")w("response.function_call_arguments.delta",{...T,snapshot:U.arguments});break}default:w(T.type,T);break}},VE=function $(){if(this.ended)throw new $$("stream has ended, this shouldn't happen");let T=v(this,ZT,"f");if(!T)throw new $$("request ended without sending any events");w$(this,ZT,void 0,"f");let W=Bj(T,v(this,qG,"f"));return w$(this,PG,W,"f"),W},KE=function $(T){let W=v(this,ZT,"f");if(!W){if(T.type!=="response.created")throw new $$(`When snapshot hasn't been set yet, expected 'response.created' event, got ${T.type}`);return W=w$(this,ZT,T.response,"f"),W}switch(T.type){case"response.output_item.added":{W.output.push(T.item);break}case"response.content_part.added":{let w=W.output[T.output_index];if(!w)throw new $$(`missing output at index ${T.output_index}`);if(w.type==="message")w.content.push(T.part);break}case"response.output_text.delta":{let w=W.output[T.output_index];if(!w)throw new $$(`missing output at index ${T.output_index}`);if(w.type==="message"){let X=w.content[T.content_index];if(!X)throw new $$(`missing content at index ${T.content_index}`);if(X.type!=="output_text")throw new $$(`expected content to be 'output_text', got ${X.type}`);X.text+=T.delta}break}case"response.function_call_arguments.delta":{let w=W.output[T.output_index];if(!w)throw new $$(`missing output at index ${T.output_index}`);if(w.type==="function_call")w.arguments+=T.delta;break}case"response.completed":{w$(this,ZT,T.response,"f");break}}return W},Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(w)=>{let X=T.shift();if(X)X.resolve(w);else $.push(w)}),this.on("end",()=>{W=!0;for(let w of T)w.resolve(void 0);T.length=0}),this.on("abort",(w)=>{W=!0;for(let X of T)X.reject(w);T.length=0}),this.on("error",(w)=>{W=!0;for(let X of T)X.reject(w);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((X,U)=>T.push({resolve:X,reject:U})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let $=v(this,PG,"f");if(!$)throw new $$("stream ended without producing a ChatCompletion");return $}}function Bj($,T){return OE($,T)}class Uw extends m{list($,T={},W){return this._client.getAPIList(h`/responses/${$}/input_items`,J$,{query:T,...W})}}class HW extends m{constructor(){super(...arguments);this.inputItems=new Uw(this._client)}create($,T){return this._client.post("/responses",{body:$,...T,stream:$.stream??!1})._thenUnwrap((W)=>{if("object"in W&&W.object==="response")oF(W);return W})}retrieve($,T={},W){return this._client.get(h`/responses/${$}`,{query:T,...W,stream:T?.stream??!1})}delete($,T){return this._client.delete(h`/responses/${$}`,{...T,headers:a([{Accept:"*/*"},T?.headers])})}parse($,T){return this._client.responses.create($,T)._thenUnwrap((W)=>dF(W,$))}stream($,T){return CG.createResponse(this._client,$,T)}cancel($,T){return this._client.post(h`/responses/${$}/cancel`,{...T,headers:a([{Accept:"*/*"},T?.headers])})}}HW.InputItems=Uw;class Yw extends m{create($,T,W){return this._client.post(h`/uploads/${$}/parts`,W1({body:T,...W},this._client))}}class FW extends m{constructor(){super(...arguments);this.parts=new Yw(this._client)}create($,T){return this._client.post("/uploads",{body:$,...T})}cancel($,T){return this._client.post(h`/uploads/${$}/cancel`,T)}complete($,T,W){return this._client.post(h`/uploads/${$}/complete`,{body:T,...W})}}FW.Parts=Yw;var AE=async($)=>{let T=await Promise.allSettled($),W=T.filter((X)=>X.status==="rejected");if(W.length){for(let X of W)console.error(X.reason);throw new Error(`${W.length} promise(s) failed - see the above errors`)}let w=[];for(let X of T)if(X.status==="fulfilled")w.push(X.value);return w};class Gw extends m{create($,T,W){return this._client.post(h`/vector_stores/${$}/file_batches`,{body:T,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}retrieve($,T,W){let{vector_store_id:w}=T;return this._client.get(h`/vector_stores/${w}/file_batches/${$}`,{...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}cancel($,T,W){let{vector_store_id:w}=T;return this._client.post(h`/vector_stores/${w}/file_batches/${$}/cancel`,{...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}async createAndPoll($,T,W){let w=await this.create($,T);return await this.poll($,w.id,W)}listFiles($,T,W){let{vector_store_id:w,...X}=T;return this._client.getAPIList(h`/vector_stores/${w}/file_batches/${$}/files`,J$,{query:X,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}async poll($,T,W){let w=a([W?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":W?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:X,response:U}=await this.retrieve(T,{vector_store_id:$},{...W,headers:w}).withResponse();switch(X.status){case"in_progress":let Y=5000;if(W?.pollIntervalMs)Y=W.pollIntervalMs;else{let G=U.headers.get("openai-poll-after-ms");if(G){let H=parseInt(G);if(!isNaN(H))Y=H}}await l1(Y);break;case"failed":case"cancelled":case"completed":return X}}}async uploadAndPoll($,{files:T,fileIds:W=[]},w){if(T==null||T.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let X=w?.maxConcurrency??5,U=Math.min(X,T.length),Y=this._client,G=T.values(),H=[...W];async function z(O){for(let Q of O){let Z=await Y.files.create({file:Q,purpose:"assistants"},w);H.push(Z.id)}}let F=Array(U).fill(G).map(z);return await AE(F),await this.createAndPoll($,{file_ids:H})}}class zw extends m{create($,T,W){return this._client.post(h`/vector_stores/${$}/files`,{body:T,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}retrieve($,T,W){let{vector_store_id:w}=T;return this._client.get(h`/vector_stores/${w}/files/${$}`,{...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}update($,T,W){let{vector_store_id:w,...X}=T;return this._client.post(h`/vector_stores/${w}/files/${$}`,{body:X,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}list($,T={},W){return this._client.getAPIList(h`/vector_stores/${$}/files`,J$,{query:T,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}delete($,T,W){let{vector_store_id:w}=T;return this._client.delete(h`/vector_stores/${w}/files/${$}`,{...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}async createAndPoll($,T,W){let w=await this.create($,T,W);return await this.poll($,w.id,W)}async poll($,T,W){let w=a([W?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":W?.pollIntervalMs?.toString()??void 0}]);while(!0){let X=await this.retrieve(T,{vector_store_id:$},{...W,headers:w}).withResponse(),U=X.data;switch(U.status){case"in_progress":let Y=5000;if(W?.pollIntervalMs)Y=W.pollIntervalMs;else{let G=X.response.headers.get("openai-poll-after-ms");if(G){let H=parseInt(G);if(!isNaN(H))Y=H}}await l1(Y);break;case"failed":case"completed":return U}}}async upload($,T,W){let w=await this._client.files.create({file:T,purpose:"assistants"},W);return this.create($,{file_id:w.id},W)}async uploadAndPoll($,T,W){let w=await this.upload($,T,W);return await this.poll($,w.id,W)}content($,T,W){let{vector_store_id:w}=T;return this._client.getAPIList(h`/vector_stores/${w}/files/${$}/content`,D0,{...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}}class VT extends m{constructor(){super(...arguments);this.files=new zw(this._client),this.fileBatches=new Gw(this._client)}create($,T){return this._client.post("/vector_stores",{body:$,...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}retrieve($,T){return this._client.get(h`/vector_stores/${$}`,{...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}update($,T,W){return this._client.post(h`/vector_stores/${$}`,{body:T,...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}list($={},T){return this._client.getAPIList("/vector_stores",J$,{query:$,...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}delete($,T){return this._client.delete(h`/vector_stores/${$}`,{...T,headers:a([{"OpenAI-Beta":"assistants=v2"},T?.headers])})}search($,T,W){return this._client.getAPIList(h`/vector_stores/${$}/search`,D0,{body:T,method:"post",...W,headers:a([{"OpenAI-Beta":"assistants=v2"},W?.headers])})}}VT.Files=zw;VT.FileBatches=Gw;var lF,SG;class R${constructor({baseURL:$=TW("OPENAI_BASE_URL"),apiKey:T=TW("OPENAI_API_KEY"),organization:W=TW("OPENAI_ORG_ID")??null,project:w=TW("OPENAI_PROJECT_ID")??null,...X}={}){if(SG.set(this,void 0),this.completions=new H2(this),this.chat=new eT(this),this.embeddings=new O2(this),this.files=new Z2(this),this.images=new E2(this),this.audio=new J0(this),this.moderations=new D2(this),this.models=new M2(this),this.fineTuning=new t1(this),this.graders=new zW(this),this.vectorStores=new VT(this),this.beta=new R0(this),this.batches=new Y2(this),this.uploads=new FW(this),this.responses=new HW(this),this.evals=new GW(this),this.containers=new YW(this),T===void 0)throw new $$("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");let U={apiKey:T,organization:W,project:w,...X,baseURL:$||"https://api.openai.com/v1"};if(!U.dangerouslyAllowBrowser&&kA())throw new $$(`It looks like you're running in a browser-like environment.
71
73
 
72
74
  This is disabled by default, as it risks exposing your secret API credentials to attackers.
73
75
  If you understand the risks and have appropriate mitigations in place,
@@ -76,21 +78,21 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
76
78
  new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
77
79
 
78
80
  https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
79
- `);super({baseURL:Y.baseURL,timeout:Y.timeout??600000,httpAgent:Y.httpAgent,maxRetries:Y.maxRetries,fetch:Y.fetch});this.completions=new OT(this),this.chat=new q1(this),this.embeddings=new QT(this),this.files=new A0(this),this.images=new NT(this),this.audio=new e6(this),this.moderations=new ST(this),this.models=new L0(this),this.fineTuning=new _6(this),this.graders=new N0(this),this.vectorStores=new w6(this),this.beta=new f6(this),this.batches=new H0(this),this.uploads=new B0(this),this.responses=new S0(this),this.evals=new X1(this),this.containers=new U1(this),this._options=Y,this.apiKey=T,this.organization=W,this.project=U}defaultQuery(){return this._options.defaultQuery}defaultHeaders($){return{...super.defaultHeaders($),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project,...this._options.defaultHeaders}}authHeaders($){return{Authorization:`Bearer ${this.apiKey}`}}stringifyQuery($){return C9($,{arrayFormat:"brackets"})}}xO=U$;U$.OpenAI=xO;U$.DEFAULT_TIMEOUT=600000;U$.OpenAIError=l;U$.APIError=a$;U$.APIConnectionError=_0;U$.APIConnectionTimeoutError=w0;U$.APIUserAbortError=Y4;U$.NotFoundError=$Y;U$.ConflictError=TY;U$.RateLimitError=UY;U$.BadRequestError=aX;U$.AuthenticationError=sX;U$.InternalServerError=XY;U$.PermissionDeniedError=eX;U$.UnprocessableEntityError=WY;U$.toFile=d9;U$.fileFromPath=tX;U$.Completions=OT;U$.Chat=q1;U$.ChatCompletionsPage=z0;U$.Embeddings=QT;U$.Files=A0;U$.FileObjectsPage=KT;U$.Images=NT;U$.Audio=e6;U$.Moderations=ST;U$.Models=L0;U$.ModelsPage=LT;U$.FineTuning=_6;U$.Graders=N0;U$.VectorStores=w6;U$.VectorStoresPage=IT;U$.VectorStoreSearchResponsesPage=kT;U$.Beta=f6;U$.Batches=H0;U$.BatchesPage=XT;U$.Uploads=B0;U$.Responses=S0;U$.Evals=X1;U$.EvalListResponsesPage=VT;U$.Containers=U1;U$.ContainerListResponsesPage=DT;var bO=U$;function Ok($,...T){let[W,U,X,Y]=T,_=[{role:"user",content:MF(U)},{role:"user",content:W}],w=Y.at(-1);if(w)_.push({role:"user",content:["Oops! That didn't work. Here's what was returned last time:",JSON.stringify(w.response,null,2),"Here's the error message:",JSON.stringify(w.error.issues,null,2)].join(`
80
- `)});return{model:$,messages:_}}var a=1e6,fO={"gpt-4.1":{promptPricePerToken:2/a,promptPricePerTokenCached:0.5/a,completionPricePerToken:8/a},"gpt-4.1-mini":{promptPricePerToken:0.4/a,promptPricePerTokenCached:0.1/a,completionPricePerToken:1.6/a},"gpt-4.1-nano":{promptPricePerToken:0.1/a,promptPricePerTokenCached:0.025/a,completionPricePerToken:0.4/a},"gpt-4o":{promptPricePerToken:2.5/a,promptPricePerTokenCached:1.25/a,completionPricePerToken:10/a},"gpt-4o-mini":{promptPricePerToken:0.15/a,promptPricePerTokenCached:0.075/a,completionPricePerToken:0.6/a},o1:{promptPricePerToken:15/a,promptPricePerTokenCached:7.5/a,completionPricePerToken:60/a},"o1-mini":{promptPricePerToken:1.1/a,promptPricePerTokenCached:0.55/a,completionPricePerToken:4.4/a},o3:{promptPricePerToken:10/a,promptPricePerTokenCached:2.5/a,completionPricePerToken:40/a},"o3-mini":{promptPricePerToken:1.1/a,promptPricePerTokenCached:0.55/a,completionPricePerToken:4.4/a},"o4-mini":{promptPricePerToken:1.1/a,promptPricePerTokenCached:0.275/a,completionPricePerToken:4.4/a},"codex-mini-latest":{promptPricePerToken:1.5/a,promptPricePerTokenCached:0.375/a,completionPricePerToken:6/a},"chatgpt-4o-latest":{promptPricePerToken:5/a,promptPricePerTokenCached:5/a,completionPricePerToken:15/a},"gpt-4":{promptPricePerToken:30/a,promptPricePerTokenCached:30/a,completionPricePerToken:60/a},"gpt-4-turbo":{promptPricePerToken:10/a,promptPricePerTokenCached:10/a,completionPricePerToken:30/a},"gpt-3.5-turbo":{promptPricePerToken:0.5/a,promptPricePerTokenCached:0.5/a,completionPricePerToken:1.5/a},"gpt-4-32k":{promptPricePerToken:60/a,promptPricePerTokenCached:60/a,completionPricePerToken:120/a},"gpt-3.5-turbo-16k":{promptPricePerToken:3/a,promptPricePerTokenCached:3/a,completionPricePerToken:4/a}};function Dk($){let W=Object.keys(fO).filter((U)=>$.startsWith(U)).sort((U,X)=>X.length-U.length)[0];if(!W)return;return fO[W]}function Qk($){return async function T(W,U){if(!$)throw new Error("This is a bug in safegen. OpenAI client not available to the json generator.");let X=await $.chat.completions.create({...W,stream:!1,response_format:{type:"json_object"}},U),Y=X.choices[0].message?.content,{usage:_}=X;if(Y&&_){let w=_.prompt_tokens,G=_.prompt_tokens_details?.cached_tokens??0,J=w-G,H=_.completion_tokens,z=Dk(W.model),F=0;if(z)F=w*z.promptPricePerToken+J*(z.promptPricePerTokenCached??0)+H*z.completionPricePerToken;else console.warn(`No pricing facts found for model ${W.model}. Giving a price of 0.`);return{data:JSON.parse(Y),usage:_,usdPrice:F}}if(!Y&&!_)throw new Error("No content or usage found in completion");if(!Y)throw new Error("No content found in completion");throw new Error("No usage found in completion")}}var yO=new Map,hO=class{usdBudget;usdMinimum;getUnknownJsonFromOpenAi;getUnknownJsonFromOpenAiSquirreled;squirrel;client;lastUsage;constructor({model:$,usdBudget:T,usdMinimum:W,apiKey:U,cachingMode:X,cacheKey:Y="openai-safegen",logger:_}){this.usdBudget=T,this.usdMinimum=W,this.squirrel=new fF(X);let w=yO.get(U);if(X!=="read"){if(!w)w=new bO({apiKey:U,dangerouslyAllowBrowser:!1}),yO.set(U,w);this.client=w}this.getUnknownJsonFromOpenAi=Qk(this.client),this.getUnknownJsonFromOpenAiSquirreled=this.squirrel.add(Y,this.getUnknownJsonFromOpenAi),this.from=AF(async(...G)=>{if(this.usdBudget<this.usdMinimum)return _?.warn("SafeGen budget exhausted"),G[2];let J=Ok($,...G),H=G[0],z=G[3],{data:F,usage:Q,usdPrice:V}=await this.getUnknownJsonFromOpenAiSquirreled.for(`${H.replace(/[^a-zA-Z0-9-_. ]/g,"_")}-${z.length}`).get(J);return this.lastUsage=Q,this.usdBudget-=V,F},_)}from};import{exec as Lj}from"child_process";class vY{supported;constructor($){this.supported=$}refine($){for(let[T,W]of Object.entries(this.supported))try{if(W($)===!0&&W!==Boolean)return{type:T,data:$}}catch(U){try{if($ instanceof W)return{type:T,data:$}}catch(X){}}return null}}var Zk=new vY({number:($)=>typeof $==="number",string:($)=>typeof $==="string",boolean:($)=>typeof $==="boolean",null:($)=>$===null});function Vk($){if(!$)return!1;return Object.getPrototypeOf($)===Object.prototype}var Kk=new vY({object:Vk,array:($)=>Array.isArray($)}),Ek=new vY({...Zk.supported,...Kk.supported}),gO=($)=>{if($===void 0)return"undefined";let T=Ek.refine($);if(T)return T.type;return Object.getPrototypeOf($).constructor.name};var D=Symbol.for("drizzle:entityKind"),Po=Symbol.for("drizzle:hasOwnEntityKind");function M($,T){if(!$||typeof $!=="object")return!1;if($ instanceof T)return!0;if(!Object.prototype.hasOwnProperty.call(T,D))throw new Error(`Class "${T.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let W=Object.getPrototypeOf($).constructor;if(W)while(W){if(D in W&&W[D]===T[D])return!0;W=Object.getPrototypeOf(W)}return!1}class B${constructor($,T){this.table=$,this.config=T,this.name=T.name,this.keyAsName=T.keyAsName,this.notNull=T.notNull,this.default=T.default,this.defaultFn=T.defaultFn,this.onUpdateFn=T.onUpdateFn,this.hasDefault=T.hasDefault,this.primary=T.primaryKey,this.isUnique=T.isUnique,this.uniqueName=T.uniqueName,this.uniqueType=T.uniqueType,this.dataType=T.dataType,this.columnType=T.columnType,this.generated=T.generated,this.generatedIdentity=T.generatedIdentity}static[D]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class Qz{static[D]="ColumnBuilder";config;constructor($,T,W){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:T,columnType:W,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var M6=Symbol.for("drizzle:Name");class Zz{static[D]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor($,T){if(this.reference=()=>{let{name:W,columns:U,foreignColumns:X}=$();return{name:W,columns:U,foreignTable:X[0].table,foreignColumns:X}},T)this._onUpdate=T.onUpdate,this._onDelete=T.onDelete}onUpdate($){return this._onUpdate=$===void 0?"no action":$,this}onDelete($){return this._onDelete=$===void 0?"no action":$,this}build($){return new mO($,this)}}class mO{constructor($,T){this.table=$,this.reference=T.reference,this.onUpdate=T._onUpdate,this.onDelete=T._onDelete}static[D]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:T,foreignColumns:W}=this.reference(),U=T.map((_)=>_.name),X=W.map((_)=>_.name),Y=[this.table[M6],...U,W[0].table[M6],...X];return $??`${Y.join("_")}_fk`}}function qY($,...T){return $(...T)}function cO($,T){return`${$[M6]}_${T.join("_")}_unique`}function uO($,T,W){for(let U=T;U<$.length;U++){let X=$[U];if(X==="\\"){U++;continue}if(X==='"')return[$.slice(T,U).replace(/\\/g,""),U+1];if(W)continue;if(X===","||X==="}")return[$.slice(T,U).replace(/\\/g,""),U]}return[$.slice(T).replace(/\\/g,""),$.length]}function pO($,T=0){let W=[],U=T,X=!1;while(U<$.length){let Y=$[U];if(Y===","){if(X||U===T)W.push("");X=!0,U++;continue}if(X=!1,Y==="\\"){U+=2;continue}if(Y==='"'){let[G,J]=uO($,U+1,!0);W.push(G),U=J;continue}if(Y==="}")return[W,U+1];if(Y==="{"){let[G,J]=pO($,U+1);W.push(G),U=J;continue}let[_,w]=uO($,U,!1);W.push(_),U=w}return[W,U]}function oO($){let[T]=pO($,1);return T}function Vz($){return`{${$.map((T)=>{if(Array.isArray(T))return Vz(T);if(typeof T==="string")return`"${T.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${T}`}).join(",")}}`}class o extends Qz{foreignKeyConfigs=[];static[D]="PgColumnBuilder";array($){return new lO(this.config.name,this,$)}references($,T={}){return this.foreignKeyConfigs.push({ref:$,actions:T}),this}unique($,T){return this.config.isUnique=!0,this.config.uniqueName=$,this.config.uniqueType=T?.nulls,this}generatedAlwaysAs($){return this.config.generated={as:$,type:"always",mode:"stored"},this}buildForeignKeys($,T){return this.foreignKeyConfigs.map(({ref:W,actions:U})=>{return qY((X,Y)=>{let _=new Zz(()=>{let w=X();return{columns:[$],foreignColumns:[w]}});if(Y.onUpdate)_.onUpdate(Y.onUpdate);if(Y.onDelete)_.onDelete(Y.onDelete);return _.build(T)},W,U)})}buildExtraConfigColumn($){return new dO($,this.config)}}class b extends B${constructor($,T){if(!T.uniqueName)T.uniqueName=cO($,[T.name]);super($,T);this.table=$}static[D]="PgColumn"}class dO extends b{static[D]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}class g2{static[D]="IndexedColumn";constructor($,T,W,U){this.name=$,this.keyAsName=T,this.type=W,this.indexConfig=U}name;keyAsName;type;indexConfig}class lO extends o{static[D]="PgArrayBuilder";constructor($,T,W){super($,"array","PgArray");this.config.baseBuilder=T,this.config.size=W}build($){let T=this.config.baseBuilder.build($);return new Kz($,this.config,T)}}class Kz extends b{constructor($,T,W,U){super($,T);this.baseColumn=W,this.range=U,this.size=T.size}size;static[D]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue($){if(typeof $==="string")$=oO($);return $.map((T)=>this.baseColumn.mapFromDriverValue(T))}mapToDriverValue($,T=!1){let W=$.map((U)=>U===null?null:M(this.baseColumn,Kz)?this.baseColumn.mapToDriverValue(U,!0):this.baseColumn.mapToDriverValue(U));if(T)return W;return Vz(W)}}class rO extends o{static[D]="PgEnumObjectColumnBuilder";constructor($,T){super($,"string","PgEnumObjectColumn");this.config.enum=T}build($){return new iO($,this.config)}}class iO extends b{static[D]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}var PY=Symbol.for("drizzle:isPgEnum");function nO($){return!!$&&typeof $==="function"&&PY in $&&$[PY]===!0}class tO extends o{static[D]="PgEnumColumnBuilder";constructor($,T){super($,"string","PgEnumColumn");this.config.enum=T}build($){return new aO($,this.config)}}class aO extends b{static[D]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}function m2($,T){return Array.isArray(T)?Ak($,[...T],void 0):Mk($,T,void 0)}function Ak($,T,W){let U=Object.assign((X)=>new tO(X??"",U),{enumName:$,enumValues:T,schema:W,[PY]:!0});return U}function Mk($,T,W){let U=Object.assign((X)=>new rO(X??"",U),{enumName:$,enumValues:Object.values(T),schema:W,[PY]:!0});return U}class i${static[D]="Subquery";constructor($,T,W,U=!1,X=[]){this._={brand:"Subquery",sql:$,selectedFields:T,alias:W,isWith:U,usedTables:X}}}class c2 extends i${static[D]="WithSubquery"}var sO="0.44.0";var Ez,Az,R$={startActiveSpan($,T){if(!Ez)return T();if(!Az)Az=Ez.trace.getTracer("drizzle-orm",sO);return qY((W,U)=>U.startActiveSpan($,(X)=>{try{return T(X)}catch(Y){throw X.setStatus({code:W.SpanStatusCode.ERROR,message:Y instanceof Error?Y.message:"Unknown error"}),Y}finally{X.end()}}),Ez,Az)}};var P$=Symbol.for("drizzle:ViewBaseConfig");var k0=Symbol.for("drizzle:Schema"),CY=Symbol.for("drizzle:Columns"),eO=Symbol.for("drizzle:ExtraConfigColumns"),Mz=Symbol.for("drizzle:OriginalName"),Nz=Symbol.for("drizzle:BaseName"),u2=Symbol.for("drizzle:IsAlias"),$D=Symbol.for("drizzle:ExtraConfigBuilder"),Nk=Symbol.for("drizzle:IsDrizzleTable");class f{static[D]="Table";static Symbol={Name:M6,Schema:k0,OriginalName:Mz,Columns:CY,ExtraConfigColumns:eO,BaseName:Nz,IsAlias:u2,ExtraConfigBuilder:$D};[M6];[Mz];[k0];[CY];[eO];[Nz];[u2]=!1;[Nk]=!0;[$D]=void 0;constructor($,T,W){this[M6]=this[Mz]=$,this[k0]=T,this[Nz]=W}}function O4($){return $[M6]}function v0($){return`${$[k0]??"public"}.${$[M6]}`}function Lz($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function Lk($){let T={sql:"",params:[]};for(let W of $)if(T.sql+=W.sql,T.params.push(...W.params),W.typings?.length){if(!T.typings)T.typings=[];T.typings.push(...W.typings)}return T}class w4{static[D]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new p([this])}}class p{constructor($){this.queryChunks=$;for(let T of $)if(M(T,f)){let W=T[f.Symbol.Schema];this.usedTables.push(W===void 0?T[f.Symbol.Name]:W+"."+T[f.Symbol.Name])}}static[D]="SQL";decoder=WD;shouldInlineParams=!1;usedTables=[];append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return R$.startActiveSpan("drizzle.buildSQL",(T)=>{let W=this.buildQueryFromSourceParams(this.queryChunks,$);return T?.setAttributes({"drizzle.query.text":W.sql,"drizzle.query.params":JSON.stringify(W.params)}),W})}buildQueryFromSourceParams($,T){let W=Object.assign({},T,{inlineParams:T.inlineParams||this.shouldInlineParams,paramStartIndex:T.paramStartIndex||{value:0}}),{casing:U,escapeName:X,escapeParam:Y,prepareTyping:_,inlineParams:w,paramStartIndex:G}=W;return Lk($.map((J)=>{if(M(J,w4))return{sql:J.value.join(""),params:[]};if(M(J,jY))return{sql:X(J.value),params:[]};if(J===void 0)return{sql:"",params:[]};if(Array.isArray(J)){let H=[new w4("(")];for(let[z,F]of J.entries())if(H.push(F),z<J.length-1)H.push(new w4(", "));return H.push(new w4(")")),this.buildQueryFromSourceParams(H,W)}if(M(J,p))return this.buildQueryFromSourceParams(J.queryChunks,{...W,inlineParams:w||J.shouldInlineParams});if(M(J,f)){let H=J[f.Symbol.Schema],z=J[f.Symbol.Name];return{sql:H===void 0||J[u2]?X(z):X(H)+"."+X(z),params:[]}}if(M(J,B$)){let H=U.getColumnCasing(J);if(T.invokeSource==="indexes")return{sql:X(H),params:[]};let z=J.table[f.Symbol.Schema];return{sql:J.table[u2]||z===void 0?X(J.table[f.Symbol.Name])+"."+X(H):X(z)+"."+X(J.table[f.Symbol.Name])+"."+X(H),params:[]}}if(M(J,g4)){let H=J[P$].schema,z=J[P$].name;return{sql:H===void 0||J[P$].isAlias?X(z):X(H)+"."+X(z),params:[]}}if(M(J,T6)){if(M(J.value,y1))return{sql:Y(G.value++,J),params:[J],typings:["none"]};let H=J.value===null?null:J.encoder.mapToDriverValue(J.value);if(M(H,p))return this.buildQueryFromSourceParams([H],W);if(w)return{sql:this.mapInlineParam(H,W),params:[]};let z=["none"];if(_)z=[_(J.encoder)];return{sql:Y(G.value++,H),params:[H],typings:z}}if(M(J,y1))return{sql:Y(G.value++,J),params:[J],typings:["none"]};if(M(J,p.Aliased)&&J.fieldAlias!==void 0)return{sql:X(J.fieldAlias),params:[]};if(M(J,i$)){if(J._.isWith)return{sql:X(J._.alias),params:[]};return this.buildQueryFromSourceParams([new w4("("),J._.sql,new w4(") "),new jY(J._.alias)],W)}if(nO(J)){if(J.schema)return{sql:X(J.schema)+"."+X(J.enumName),params:[]};return{sql:X(J.enumName),params:[]}}if(Lz(J)){if(J.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([J.getSQL()],W);return this.buildQueryFromSourceParams([new w4("("),J.getSQL(),new w4(")")],W)}if(w)return{sql:this.mapInlineParam(J,W),params:[]};return{sql:Y(G.value++,J),params:[J],typings:["none"]}}))}mapInlineParam($,{escapeString:T}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return T($);if(typeof $==="object"){let W=$.toString();if(W==="[object Object]")return T(JSON.stringify($));return T(W)}throw new Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new p.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}}class jY{constructor($){this.value=$}static[D]="Name";brand;getSQL(){return new p([this])}}function TD($){return typeof $==="object"&&$!==null&&"mapToDriverValue"in $&&typeof $.mapToDriverValue==="function"}var WD={mapFromDriverValue:($)=>$},UD={mapToDriverValue:($)=>$},Ad={...WD,...UD};class T6{constructor($,T=UD){this.value=$,this.encoder=T}static[D]="Param";brand;getSQL(){return new p([this])}}function Z($,...T){let W=[];if(T.length>0||$.length>0&&$[0]!=="")W.push(new w4($[0]));for(let[U,X]of T.entries())W.push(X,new w4($[U+1]));return new p(W)}(($)=>{function T(){return new p([])}$.empty=T;function W(G){return new p(G)}$.fromList=W;function U(G){return new p([new w4(G)])}$.raw=U;function X(G,J){let H=[];for(let[z,F]of G.entries()){if(z>0&&J!==void 0)H.push(J);H.push(F)}return new p(H)}$.join=X;function Y(G){return new jY(G)}$.identifier=Y;function _(G){return new y1(G)}$.placeholder=_;function w(G,J){return new T6(G,J)}$.param=w})(Z||(Z={}));(($)=>{class T{constructor(W,U){this.sql=W,this.fieldAlias=U}static[D]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new T(this.sql,this.fieldAlias)}}$.Aliased=T})(p||(p={}));class y1{constructor($){this.name=$}static[D]="Placeholder";getSQL(){return new p([this])}}function Sz($,T){return $.map((W)=>{if(M(W,y1)){if(!(W.name in T))throw new Error(`No value for placeholder "${W.name}" was provided`);return T[W.name]}if(M(W,T6)&&M(W.value,y1)){if(!(W.value.name in T))throw new Error(`No value for placeholder "${W.value.name}" was provided`);return W.encoder.mapToDriverValue(T[W.value.name])}return W})}var Sk=Symbol.for("drizzle:IsDrizzleView");class g4{static[D]="View";[P$];[Sk]=!0;constructor({name:$,schema:T,selectedFields:W,query:U}){this[P$]={name:$,originalName:$,schema:T,selectedFields:W,query:U,isExisting:!U,isAlias:!1}}getSQL(){return new p([this])}}B$.prototype.getSQL=function(){return new p([this])};f.prototype.getSQL=function(){return new p([this])};i$.prototype.getSQL=function(){return new p([this])};class vT{constructor($){this.table=$}static[D]="ColumnAliasProxyHandler";get($,T){if(T==="table")return this.table;return $[T]}}class p2{constructor($,T){this.alias=$,this.replaceOriginalName=T}static[D]="TableAliasProxyHandler";get($,T){if(T===f.Symbol.IsAlias)return!0;if(T===f.Symbol.Name)return this.alias;if(this.replaceOriginalName&&T===f.Symbol.OriginalName)return this.alias;if(T===P$)return{...$[P$],name:this.alias,isAlias:!0};if(T===f.Symbol.Columns){let U=$[f.Symbol.Columns];if(!U)return U;let X={};return Object.keys(U).map((Y)=>{X[Y]=new Proxy(U[Y],new vT(new Proxy($,this)))}),X}let W=$[T];if(M(W,B$))return new Proxy(W,new vT(new Proxy($,this)));return W}}function xY($,T){return new Proxy($,new p2(T,!1))}function y6($,T){return new Proxy($,new vT(new Proxy($.table,new p2(T,!1))))}function Bz($,T){return new p.Aliased(o2($.sql,T),$.fieldAlias)}function o2($,T){return Z.join($.queryChunks.map((W)=>{if(M(W,B$))return y6(W,T);if(M(W,p))return o2(W,T);if(M(W,p.Aliased))return Bz(W,T);return W}))}class bY extends Error{static[D]="DrizzleError";constructor({message:$,cause:T}){super($);this.name="DrizzleError",this.cause=T}}class Rz extends bY{static[D]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class XD{static[D]="ConsoleLogWriter";write($){console.log($)}}class Iz{static[D]="DefaultLogger";writer;constructor($){this.writer=$?.writer??new XD}logQuery($,T){let W=T.map((X)=>{try{return JSON.stringify(X)}catch{return String(X)}}),U=W.length?` -- params: [${W.join(", ")}]`:"";this.writer.write(`Query: ${$}${U}`)}}class kz{static[D]="NoopLogger";logQuery(){}}class k4{static[D]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch($){return this.then(void 0,$)}finally($){return this.then((T)=>{return $?.(),T},(T)=>{throw $?.(),T})}then($,T){return this.execute().then($,T)}}function YD($,T,W){let U={},X=$.reduce((Y,{path:_,field:w},G)=>{let J;if(M(w,B$))J=w;else if(M(w,p))J=w.decoder;else J=w.sql.decoder;let H=Y;for(let[z,F]of _.entries())if(z<_.length-1){if(!(F in H))H[F]={};H=H[F]}else{let Q=T[G],V=H[F]=Q===null?null:J.mapFromDriverValue(Q);if(W&&M(w,B$)&&_.length===2){let K=_[0];if(!(K in U))U[K]=V===null?O4(w.table):!1;else if(typeof U[K]==="string"&&U[K]!==O4(w.table))U[K]=!1}}return Y},{});if(W&&Object.keys(U).length>0){for(let[Y,_]of Object.entries(U))if(typeof _==="string"&&!W[_])X[Y]=null}return X}function J6($,T){return Object.entries($).reduce((W,[U,X])=>{if(typeof U!=="string")return W;let Y=T?[...T,U]:[U];if(M(X,B$)||M(X,p)||M(X,p.Aliased))W.push({path:Y,field:X});else if(M(X,f))W.push(...J6(X[f.Symbol.Columns],Y));else W.push(...J6(X,Y));return W},[])}function d2($,T){let W=Object.keys($),U=Object.keys(T);if(W.length!==U.length)return!1;for(let[X,Y]of W.entries())if(Y!==U[X])return!1;return!0}function fY($,T){let W=Object.entries(T).filter(([,U])=>U!==void 0).map(([U,X])=>{if(M(X,p)||M(X,B$))return[U,X];else return[U,new T6(X,$[f.Symbol.Columns][U])]});if(W.length===0)throw new Error("No values to set");return Object.fromEntries(W)}function _D($,T){for(let W of T)for(let U of Object.getOwnPropertyNames(W.prototype)){if(U==="constructor")continue;Object.defineProperty($.prototype,U,Object.getOwnPropertyDescriptor(W.prototype,U)||Object.create(null))}}function wD($){return $[f.Symbol.Columns]}function _1($){return M($,i$)?$._.alias:M($,g4)?$[P$].name:M($,p)?void 0:$[f.Symbol.IsAlias]?$[f.Symbol.Name]:$[f.Symbol.BaseName]}function Q$($,T){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:T}}function JD($){if(typeof $!=="object"||$===null)return!1;if($.constructor.name!=="Object")return!1;if("logger"in $){let T=typeof $.logger;if(T!=="boolean"&&(T!=="object"||typeof $.logger.logQuery!=="function")&&T!=="undefined")return!1;return!0}if("schema"in $){let T=typeof $.schema;if(T!=="object"&&T!=="undefined")return!1;return!0}if("casing"in $){let T=typeof $.casing;if(T!=="string"&&T!=="undefined")return!1;return!0}if("mode"in $){if($.mode!=="default"||$.mode!=="planetscale"||$.mode!==void 0)return!1;return!0}if("connection"in $){let T=typeof $.connection;if(T!=="string"&&T!=="object"&&T!=="undefined")return!1;return!0}if("client"in $){let T=typeof $.client;if(T!=="object"&&T!=="function"&&T!=="undefined")return!1;return!0}if(Object.keys($).length===0)return!0;return!1}class h1 extends o{static[D]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity($){if($){let{name:T,...W}=$;this.config.generatedIdentity={type:"always",sequenceName:T,sequenceOptions:W}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity($){if($){let{name:T,...W}=$;this.config.generatedIdentity={type:"byDefault",sequenceName:T,sequenceOptions:W}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class GD extends h1{static[D]="PgBigInt53Builder";constructor($){super($,"number","PgBigInt53")}build($){return new zD($,this.config)}}class zD extends b{static[D]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class HD extends h1{static[D]="PgBigInt64Builder";constructor($){super($,"bigint","PgBigInt64")}build($){return new FD($,this.config)}}class FD extends b{static[D]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue($){return BigInt($)}}function OD($,T){let{name:W,config:U}=Q$($,T);if(U.mode==="number")return new GD(W);return new HD(W)}class DD extends o{static[D]="PgBigSerial53Builder";constructor($){super($,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new QD($,this.config)}}class QD extends b{static[D]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class ZD extends o{static[D]="PgBigSerial64Builder";constructor($){super($,"bigint","PgBigSerial64");this.config.hasDefault=!0}build($){return new VD($,this.config)}}class VD extends b{static[D]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue($){return BigInt($)}}function KD($,T){let{name:W,config:U}=Q$($,T);if(U.mode==="number")return new DD(W);return new ZD(W)}class ED extends o{static[D]="PgBooleanBuilder";constructor($){super($,"boolean","PgBoolean")}build($){return new AD($,this.config)}}class AD extends b{static[D]="PgBoolean";getSQLType(){return"boolean"}}function l2($){return new ED($??"")}class MD extends o{static[D]="PgCharBuilder";constructor($,T){super($,"string","PgChar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new ND($,this.config)}}class ND extends b{static[D]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function LD($,T={}){let{name:W,config:U}=Q$($,T);return new MD(W,U)}class SD extends o{static[D]="PgCidrBuilder";constructor($){super($,"string","PgCidr")}build($){return new BD($,this.config)}}class BD extends b{static[D]="PgCidr";getSQLType(){return"cidr"}}function RD($){return new SD($??"")}class ID extends o{static[D]="PgCustomColumnBuilder";constructor($,T,W){super($,"custom","PgCustomColumn");this.config.fieldConfig=T,this.config.customTypeParams=W}build($){return new kD($,this.config)}}class kD extends b{static[D]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor($,T){super($,T);this.sqlName=T.customTypeParams.dataType(T.fieldConfig),this.mapTo=T.customTypeParams.toDriver,this.mapFrom=T.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function vD($){return(T,W)=>{let{name:U,config:X}=Q$(T,W);return new ID(U,X,$)}}class w1 extends o{static[D]="PgDateColumnBaseBuilder";defaultNow(){return this.default(Z`now()`)}}class qD extends w1{static[D]="PgDateBuilder";constructor($){super($,"date","PgDate")}build($){return new yY($,this.config)}}class yY extends b{static[D]="PgDate";getSQLType(){return"date"}mapFromDriverValue($){return new Date($)}mapToDriverValue($){return $.toISOString()}}class PD extends w1{static[D]="PgDateStringBuilder";constructor($){super($,"string","PgDateString")}build($){return new hY($,this.config)}}class hY extends b{static[D]="PgDateString";getSQLType(){return"date"}}function CD($,T){let{name:W,config:U}=Q$($,T);if(U?.mode==="date")return new qD(W);return new PD(W)}class jD extends o{static[D]="PgDoublePrecisionBuilder";constructor($){super($,"number","PgDoublePrecision")}build($){return new xD($,this.config)}}class xD extends b{static[D]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue($){if(typeof $==="string")return Number.parseFloat($);return $}}function bD($){return new jD($??"")}class fD extends o{static[D]="PgInetBuilder";constructor($){super($,"string","PgInet")}build($){return new yD($,this.config)}}class yD extends b{static[D]="PgInet";getSQLType(){return"inet"}}function hD($){return new fD($??"")}class gD extends h1{static[D]="PgIntegerBuilder";constructor($){super($,"number","PgInteger")}build($){return new mD($,this.config)}}class mD extends b{static[D]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue($){if(typeof $==="string")return Number.parseInt($);return $}}function r2($){return new gD($??"")}class cD extends o{static[D]="PgIntervalBuilder";constructor($,T){super($,"string","PgInterval");this.config.intervalConfig=T}build($){return new uD($,this.config)}}class uD extends b{static[D]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let $=this.fields?` ${this.fields}`:"",T=this.precision?`(${this.precision})`:"";return`interval${$}${T}`}}function pD($,T={}){let{name:W,config:U}=Q$($,T);return new cD(W,U)}class oD extends o{static[D]="PgJsonBuilder";constructor($){super($,"json","PgJson")}build($){return new gY($,this.config)}}class gY extends b{static[D]="PgJson";constructor($,T){super($,T)}getSQLType(){return"json"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function dD($){return new oD($??"")}class lD extends o{static[D]="PgJsonbBuilder";constructor($){super($,"json","PgJsonb")}build($){return new mY($,this.config)}}class mY extends b{static[D]="PgJsonb";constructor($,T){super($,T)}getSQLType(){return"jsonb"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function rD($){return new lD($??"")}class iD extends o{static[D]="PgLineBuilder";constructor($){super($,"array","PgLine")}build($){return new nD($,this.config)}}class nD extends b{static[D]="PgLine";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,U]=$.slice(1,-1).split(",");return[Number.parseFloat(T),Number.parseFloat(W),Number.parseFloat(U)]}mapToDriverValue($){return`{${$[0]},${$[1]},${$[2]}}`}}class tD extends o{static[D]="PgLineABCBuilder";constructor($){super($,"json","PgLineABC")}build($){return new aD($,this.config)}}class aD extends b{static[D]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,U]=$.slice(1,-1).split(",");return{a:Number.parseFloat(T),b:Number.parseFloat(W),c:Number.parseFloat(U)}}mapToDriverValue($){return`{${$.a},${$.b},${$.c}}`}}function sD($,T){let{name:W,config:U}=Q$($,T);if(!U?.mode||U.mode==="tuple")return new iD(W);return new tD(W)}class eD extends o{static[D]="PgMacaddrBuilder";constructor($){super($,"string","PgMacaddr")}build($){return new $Q($,this.config)}}class $Q extends b{static[D]="PgMacaddr";getSQLType(){return"macaddr"}}function TQ($){return new eD($??"")}class WQ extends o{static[D]="PgMacaddr8Builder";constructor($){super($,"string","PgMacaddr8")}build($){return new UQ($,this.config)}}class UQ extends b{static[D]="PgMacaddr8";getSQLType(){return"macaddr8"}}function XQ($){return new WQ($??"")}class YQ extends o{static[D]="PgNumericBuilder";constructor($,T,W){super($,"string","PgNumeric");this.config.precision=T,this.config.scale=W}build($){return new cY($,this.config)}}class cY extends b{static[D]="PgNumeric";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class _Q extends o{static[D]="PgNumericNumberBuilder";constructor($,T,W){super($,"number","PgNumericNumber");this.config.precision=T,this.config.scale=W}build($){return new wQ($,this.config)}}class wQ extends b{static[D]="PgNumericNumber";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class JQ extends o{static[D]="PgNumericBigIntBuilder";constructor($,T,W){super($,"bigint","PgNumericBigInt");this.config.precision=T,this.config.scale=W}build($){return new GQ($,this.config)}}class GQ extends b{static[D]="PgNumericBigInt";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function zQ($,T){let{name:W,config:U}=Q$($,T),X=U?.mode;return X==="number"?new _Q(W,U?.precision,U?.scale):X==="bigint"?new JQ(W,U?.precision,U?.scale):new YQ(W,U?.precision,U?.scale)}class HQ extends o{static[D]="PgPointTupleBuilder";constructor($){super($,"array","PgPointTuple")}build($){return new FQ($,this.config)}}class FQ extends b{static[D]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[T,W]=$.slice(1,-1).split(",");return[Number.parseFloat(T),Number.parseFloat(W)]}return[$.x,$.y]}mapToDriverValue($){return`(${$[0]},${$[1]})`}}class OQ extends o{static[D]="PgPointObjectBuilder";constructor($){super($,"json","PgPointObject")}build($){return new DQ($,this.config)}}class DQ extends b{static[D]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[T,W]=$.slice(1,-1).split(",");return{x:Number.parseFloat(T),y:Number.parseFloat(W)}}return $}mapToDriverValue($){return`(${$.x},${$.y})`}}function QQ($,T){let{name:W,config:U}=Q$($,T);if(!U?.mode||U.mode==="tuple")return new HQ(W);return new OQ(W)}function Bk($){let T=[];for(let W=0;W<$.length;W+=2)T.push(Number.parseInt($.slice(W,W+2),16));return new Uint8Array(T)}function ZQ($,T){let W=new ArrayBuffer(8),U=new DataView(W);for(let X=0;X<8;X++)U.setUint8(X,$[T+X]);return U.getFloat64(0,!0)}function vz($){let T=Bk($),W=0,U=T[W];W+=1;let X=new DataView(T.buffer),Y=X.getUint32(W,U===1);W+=4;let _;if(Y&536870912)_=X.getUint32(W,U===1),W+=4;if((Y&65535)===1){let w=ZQ(T,W);W+=8;let G=ZQ(T,W);return W+=8,[w,G]}throw new Error("Unsupported geometry type")}class VQ extends o{static[D]="PgGeometryBuilder";constructor($){super($,"array","PgGeometry")}build($){return new KQ($,this.config)}}class KQ extends b{static[D]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue($){return vz($)}mapToDriverValue($){return`point(${$[0]} ${$[1]})`}}class EQ extends o{static[D]="PgGeometryObjectBuilder";constructor($){super($,"json","PgGeometryObject")}build($){return new AQ($,this.config)}}class AQ extends b{static[D]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue($){let T=vz($);return{x:T[0],y:T[1]}}mapToDriverValue($){return`point(${$.x} ${$.y})`}}function MQ($,T){let{name:W,config:U}=Q$($,T);if(!U?.mode||U.mode==="tuple")return new VQ(W);return new EQ(W)}class NQ extends o{static[D]="PgRealBuilder";constructor($,T){super($,"number","PgReal");this.config.length=T}build($){return new LQ($,this.config)}}class LQ extends b{static[D]="PgReal";constructor($,T){super($,T)}getSQLType(){return"real"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number.parseFloat($);return $}}function SQ($){return new NQ($??"")}class BQ extends o{static[D]="PgSerialBuilder";constructor($){super($,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new RQ($,this.config)}}class RQ extends b{static[D]="PgSerial";getSQLType(){return"serial"}}function IQ($){return new BQ($??"")}class kQ extends h1{static[D]="PgSmallIntBuilder";constructor($){super($,"number","PgSmallInt")}build($){return new vQ($,this.config)}}class vQ extends b{static[D]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number($);return $}}function qQ($){return new kQ($??"")}class PQ extends o{static[D]="PgSmallSerialBuilder";constructor($){super($,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new CQ($,this.config)}}class CQ extends b{static[D]="PgSmallSerial";getSQLType(){return"smallserial"}}function jQ($){return new PQ($??"")}class xQ extends o{static[D]="PgTextBuilder";constructor($,T){super($,"string","PgText");this.config.enumValues=T.enum}build($){return new bQ($,this.config)}}class bQ extends b{static[D]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function fQ($,T={}){let{name:W,config:U}=Q$($,T);return new xQ(W,U)}class yQ extends w1{constructor($,T,W){super($,"string","PgTime");this.withTimezone=T,this.precision=W,this.config.withTimezone=T,this.config.precision=W}static[D]="PgTimeBuilder";build($){return new uY($,this.config)}}class uY extends b{static[D]="PgTime";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function hQ($,T={}){let{name:W,config:U}=Q$($,T);return new yQ(W,U.withTimezone??!1,U.precision)}class gQ extends w1{static[D]="PgTimestampBuilder";constructor($,T,W){super($,"date","PgTimestamp");this.config.withTimezone=T,this.config.precision=W}build($){return new pY($,this.config)}}class pY extends b{static[D]="PgTimestamp";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=($)=>{return new Date(this.withTimezone?$:$+"+0000")};mapToDriverValue=($)=>{return $.toISOString()}}class mQ extends w1{static[D]="PgTimestampStringBuilder";constructor($,T,W){super($,"string","PgTimestampString");this.config.withTimezone=T,this.config.precision=W}build($){return new oY($,this.config)}}class oY extends b{static[D]="PgTimestampString";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function N6($,T={}){let{name:W,config:U}=Q$($,T);if(U?.mode==="string")return new mQ(W,U.withTimezone??!1,U.precision);return new gQ(W,U?.withTimezone??!1,U?.precision)}class cQ extends o{static[D]="PgUUIDBuilder";constructor($){super($,"string","PgUUID")}defaultRandom(){return this.default(Z`gen_random_uuid()`)}build($){return new dY($,this.config)}}class dY extends b{static[D]="PgUUID";getSQLType(){return"uuid"}}function G6($){return new cQ($??"")}class uQ extends o{static[D]="PgVarcharBuilder";constructor($,T){super($,"string","PgVarchar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new pQ($,this.config)}}class pQ extends b{static[D]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function v4($,T={}){let{name:W,config:U}=Q$($,T);return new uQ(W,U)}class oQ extends o{static[D]="PgBinaryVectorBuilder";constructor($,T){super($,"string","PgBinaryVector");this.config.dimensions=T.dimensions}build($){return new dQ($,this.config)}}class dQ extends b{static[D]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function lQ($,T){let{name:W,config:U}=Q$($,T);return new oQ(W,U)}class rQ extends o{static[D]="PgHalfVectorBuilder";constructor($,T){super($,"array","PgHalfVector");this.config.dimensions=T.dimensions}build($){return new iQ($,this.config)}}class iQ extends b{static[D]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((T)=>Number.parseFloat(T))}}function nQ($,T){let{name:W,config:U}=Q$($,T);return new rQ(W,U)}class tQ extends o{static[D]="PgSparseVectorBuilder";constructor($,T){super($,"string","PgSparseVector");this.config.dimensions=T.dimensions}build($){return new aQ($,this.config)}}class aQ extends b{static[D]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function sQ($,T){let{name:W,config:U}=Q$($,T);return new tQ(W,U)}class eQ extends o{static[D]="PgVectorBuilder";constructor($,T){super($,"array","PgVector");this.config.dimensions=T.dimensions}build($){return new $Z($,this.config)}}class $Z extends b{static[D]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((T)=>Number.parseFloat(T))}}function TZ($,T){let{name:W,config:U}=Q$($,T);return new eQ(W,U)}function WZ(){return{bigint:OD,bigserial:KD,boolean:l2,char:LD,cidr:RD,customType:vD,date:CD,doublePrecision:bD,inet:hD,integer:r2,interval:pD,json:dD,jsonb:rD,line:sD,macaddr:TQ,macaddr8:XQ,numeric:zQ,point:QQ,geometry:MQ,real:SQ,serial:IQ,smallint:qQ,smallserial:jQ,text:fQ,time:hQ,timestamp:N6,uuid:G6,varchar:v4,bit:lQ,halfvec:nQ,sparsevec:sQ,vector:TZ}}var qz=Symbol.for("drizzle:PgInlineForeignKeys"),UZ=Symbol.for("drizzle:EnableRLS");class J4 extends f{static[D]="PgTable";static Symbol=Object.assign({},f.Symbol,{InlineForeignKeys:qz,EnableRLS:UZ});[qz]=[];[UZ]=!1;[f.Symbol.ExtraConfigBuilder]=void 0;[f.Symbol.ExtraConfigColumns]={}}function Rk($,T,W,U,X=$){let Y=new J4($,U,X),_=typeof T==="function"?T(WZ()):T,w=Object.fromEntries(Object.entries(_).map(([H,z])=>{let F=z;F.setName(H);let Q=F.build(Y);return Y[qz].push(...F.buildForeignKeys(Q,Y)),[H,Q]})),G=Object.fromEntries(Object.entries(_).map(([H,z])=>{let F=z;F.setName(H);let Q=F.buildExtraConfigColumn(Y);return[H,Q]})),J=Object.assign(Y,w);if(J[f.Symbol.Columns]=w,J[f.Symbol.ExtraConfigColumns]=G,W)J[J4.Symbol.ExtraConfigBuilder]=W;return Object.assign(J,{enableRLS:()=>{return J[J4.Symbol.EnableRLS]=!0,J}})}var g1=($,T,W)=>{return Rk($,T,W,void 0)};function XZ(...$){if($[0].columns)return new i2($[0].columns,$[0].name);return new i2($)}class i2{static[D]="PgPrimaryKeyBuilder";columns;name;constructor($,T){this.columns=$,this.name=T}build($){return new YZ($,this.columns,this.name)}}class YZ{constructor($,T,W){this.table=$,this.columns=T,this.name=W}static[D]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[J4.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}function m4($,T){if(TD(T)&&!Lz($)&&!M($,T6)&&!M($,y1)&&!M($,B$)&&!M($,f)&&!M($,g4))return new T6($,T);return $}var lY=($,T)=>{return Z`${$} = ${m4(T,$)}`},_Z=($,T)=>{return Z`${$} <> ${m4(T,$)}`};function n2(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new p(T);return new p([new w4("("),Z.join(T,new w4(" and ")),new w4(")")])}function wZ(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new p(T);return new p([new w4("("),Z.join(T,new w4(" or ")),new w4(")")])}function JZ($){return Z`not ${$}`}var rY=($,T)=>{return Z`${$} > ${m4(T,$)}`},GZ=($,T)=>{return Z`${$} >= ${m4(T,$)}`},zZ=($,T)=>{return Z`${$} < ${m4(T,$)}`},HZ=($,T)=>{return Z`${$} <= ${m4(T,$)}`};function FZ($,T){if(Array.isArray(T)){if(T.length===0)return Z`false`;return Z`${$} in ${T.map((W)=>m4(W,$))}`}return Z`${$} in ${m4(T,$)}`}function OZ($,T){if(Array.isArray(T)){if(T.length===0)return Z`true`;return Z`${$} not in ${T.map((W)=>m4(W,$))}`}return Z`${$} not in ${m4(T,$)}`}function DZ($){return Z`${$} is null`}function QZ($){return Z`${$} is not null`}function ZZ($){return Z`exists ${$}`}function VZ($){return Z`not exists ${$}`}function KZ($,T,W){return Z`${$} between ${m4(T,$)} and ${m4(W,$)}`}function EZ($,T,W){return Z`${$} not between ${m4(T,$)} and ${m4(W,$)}`}function AZ($,T){return Z`${$} like ${T}`}function MZ($,T){return Z`${$} not like ${T}`}function NZ($,T){return Z`${$} ilike ${T}`}function LZ($,T){return Z`${$} not ilike ${T}`}function SZ($){return Z`${$} asc`}function BZ($){return Z`${$} desc`}class Pz{constructor($,T,W){this.sourceTable=$,this.referencedTable=T,this.relationName=W,this.referencedTableName=T[f.Symbol.Name]}static[D]="Relation";referencedTableName;fieldName}class RZ{constructor($,T){this.table=$,this.config=T}static[D]="Relations"}class m1 extends Pz{constructor($,T,W,U){super($,T,W?.relationName);this.config=W,this.isNullable=U}static[D]="One";withFieldName($){let T=new m1(this.sourceTable,this.referencedTable,this.config,this.isNullable);return T.fieldName=$,T}}class t2 extends Pz{constructor($,T,W){super($,T,W?.relationName);this.config=W}static[D]="Many";withFieldName($){let T=new t2(this.sourceTable,this.referencedTable,this.config);return T.fieldName=$,T}}function IZ(){return{and:n2,between:KZ,eq:lY,exists:ZZ,gt:rY,gte:GZ,ilike:NZ,inArray:FZ,isNull:DZ,isNotNull:QZ,like:AZ,lt:zZ,lte:HZ,ne:_Z,not:JZ,notBetween:EZ,notExists:VZ,notLike:MZ,notIlike:LZ,notInArray:OZ,or:wZ,sql:Z}}function kZ(){return{sql:Z,asc:SZ,desc:BZ}}function vZ($,T){if(Object.keys($).length===1&&"default"in $&&!M($.default,f))$=$.default;let W={},U={},X={};for(let[Y,_]of Object.entries($))if(M(_,f)){let w=v0(_),G=U[w];W[w]=Y,X[Y]={tsName:Y,dbName:_[f.Symbol.Name],schema:_[f.Symbol.Schema],columns:_[f.Symbol.Columns],relations:G?.relations??{},primaryKey:G?.primaryKey??[]};for(let H of Object.values(_[f.Symbol.Columns]))if(H.primary)X[Y].primaryKey.push(H);let J=_[f.Symbol.ExtraConfigBuilder]?.(_[f.Symbol.ExtraConfigColumns]);if(J){for(let H of Object.values(J))if(M(H,i2))X[Y].primaryKey.push(...H.columns)}}else if(M(_,RZ)){let w=v0(_.table),G=W[w],J=_.config(T(_.table)),H;for(let[z,F]of Object.entries(J))if(G){let Q=X[G];if(Q.relations[z]=F,H)Q.primaryKey.push(...H)}else{if(!(w in U))U[w]={relations:{},primaryKey:H};U[w].relations[z]=F}}return{tables:X,tableNamesMap:W}}function Ik($){return function T(W,U){return new m1($,W,U,U?.fields.reduce((X,Y)=>X&&Y.notNull,!0)??!1)}}function kk($){return function T(W,U){return new t2($,W,U)}}function qZ($,T,W){if(M(W,m1)&&W.config)return{fields:W.config.fields,references:W.config.references};let U=T[v0(W.referencedTable)];if(!U)throw new Error(`Table "${W.referencedTable[f.Symbol.Name]}" not found in schema`);let X=$[U];if(!X)throw new Error(`Table "${U}" not found in schema`);let Y=W.sourceTable,_=T[v0(Y)];if(!_)throw new Error(`Table "${Y[f.Symbol.Name]}" not found in schema`);let w=[];for(let G of Object.values(X.relations))if(W.relationName&&W!==G&&G.relationName===W.relationName||!W.relationName&&G.referencedTable===W.sourceTable)w.push(G);if(w.length>1)throw W.relationName?new Error(`There are multiple relations with name "${W.relationName}" in table "${U}"`):new Error(`There are multiple relations between "${U}" and "${W.sourceTable[f.Symbol.Name]}". Please specify relation name`);if(w[0]&&M(w[0],m1)&&w[0].config)return{fields:w[0].config.references,references:w[0].config.fields};throw new Error(`There is not enough information to infer relation "${_}.${W.fieldName}"`)}function PZ($){return{one:Ik($),many:kk($)}}function iY($,T,W,U,X=(Y)=>Y){let Y={};for(let[_,w]of U.entries())if(w.isJson){let G=T.relations[w.tsKey],J=W[_],H=typeof J==="string"?JSON.parse(J):J;Y[w.tsKey]=M(G,m1)?H&&iY($,$[w.relationTableTsKey],H,w.selection,X):H.map((z)=>iY($,$[w.relationTableTsKey],z,w.selection,X))}else{let G=X(W[_]),J=w.field,H;if(M(J,B$))H=J;else if(M(J,p))H=J.decoder;else H=J.sql.decoder;Y[w.tsKey]=G===null?null:H.mapFromDriverValue(G)}return Y}import Vj from"path";import sk from"os";import ek from"fs";var nY=new Map,Cz=new Map,jz=Symbol("OriginError"),qT={};class z6 extends Promise{constructor($,T,W,U,X={}){let Y,_;super((w,G)=>{Y=w,_=G});this.tagged=Array.isArray($.raw),this.strings=$,this.args=T,this.handler=W,this.canceller=U,this.options=X,this.state=null,this.statement=null,this.resolve=(w)=>(this.active=!1,Y(w)),this.reject=(w)=>(this.active=!1,_(w)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[jz]=this.handler.debug?new Error:this.tagged&&vk(this.strings)}get origin(){return(this.handler.debug?this[jz].stack:this.tagged&&Cz.has(this.strings)?Cz.get(this.strings):Cz.set(this.strings,this[jz].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=!0,this.options.prepare=!1,this}async readable(){return this.simple(),this.streaming=!0,this}async writable(){return this.simple(),this.streaming=!0,this}cursor($=1,T){if(this.options.simple=!1,typeof $==="function")T=$,$=1;if(this.cursorRows=$,typeof T==="function")return this.cursorFn=T,this;let W;return{[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return{done:!0};W&&W();let U=new Promise((X,Y)=>{this.cursorFn=(_)=>{return X({value:_,done:!1}),new Promise((w)=>W=w)},this.resolve=()=>(this.active=!1,X({done:!0})),this.reject=(_)=>(this.active=!1,Y(_))});return this.execute(),U},return(){return W&&W(qT),{done:!0}}})}}describe(){return this.options.simple=!1,this.onlyDescribe=this.options.prepare=!0,this}stream(){throw new Error(".stream has been renamed to .forEach")}forEach($){return this.forEachFn=$,this.handle(),this}raw(){return this.isRaw=!0,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=!0)&&await 1&&this.handler(this)}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}}function vk($){if(nY.has($))return nY.get($);let T=Error.stackTraceLimit;return Error.stackTraceLimit=4,nY.set($,new Error),Error.stackTraceLimit=T,nY.get($)}class PT extends Error{constructor($){super($.message);this.name=this.constructor.name,Object.assign(this,$)}}var s$={connection:CZ,postgres:jZ,generic:xZ,notSupported:bZ};function CZ($,T,W){let{host:U,port:X}=W||T,Y=Object.assign(new Error("write "+$+" "+(T.path||U+":"+X)),{code:$,errno:$,address:T.path||U},T.path?{}:{port:X});return Error.captureStackTrace(Y,CZ),Y}function jZ($){let T=new PT($);return Error.captureStackTrace(T,jZ),T}function xZ($,T){let W=Object.assign(new Error($+": "+T),{code:$});return Error.captureStackTrace(W,xZ),W}function bZ($){let T=Object.assign(new Error($+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:$});return Error.captureStackTrace(T,bZ),T}var qk={string:{to:25,from:null,serialize:($)=>""+$},number:{to:0,from:[21,23,26,700,701],serialize:($)=>""+$,parse:($)=>+$},json:{to:114,from:[114,3802],serialize:($)=>JSON.stringify($),parse:($)=>JSON.parse($)},boolean:{to:16,from:16,serialize:($)=>$===!0?"t":"f",parse:($)=>$==="t"},date:{to:1184,from:[1082,1114,1184],serialize:($)=>($ instanceof Date?$:new Date($)).toISOString(),parse:($)=>new Date($)},bytea:{to:17,from:17,serialize:($)=>"\\x"+Buffer.from($).toString("hex"),parse:($)=>Buffer.from($.slice(2),"hex")}};class sY{then(){xz()}catch(){xz()}finally(){xz()}}class $U extends sY{constructor($){super();this.value=T8($)}}class h6 extends sY{constructor($,T,W){super();this.value=$,this.type=T,this.array=W}}class eY extends sY{constructor($,T){super();this.first=$,this.rest=T}build($,T,W,U){let X=Pk.map(([Y,_])=>({fn:_,i:$.search(Y)})).sort((Y,_)=>Y.i-_.i).pop();return X.i===-1?gz(this.first,U):X.fn(this.first,this.rest,T,W,U)}}function $8($,T,W,U){let X=$ instanceof h6?$.value:$;if(X===void 0){if($ instanceof h6?$.value=U.transform.undefined:X=$=U.transform.undefined,X===void 0)throw s$.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return"$"+W.push($ instanceof h6?(T.push($.value),$.array?$.array[$.type||aY($.value)]||$.type||gZ($.value):$.type):(T.push($),aY($)))}var yZ=cZ(qk);function yz($,T,W,U,X,Y){for(let _=1;_<$.strings.length;_++)T+=hz(T,W,U,X,Y)+$.strings[_],W=$.args[_];return T}function hz($,T,W,U,X){return T instanceof eY?T.build($,W,U,X):T instanceof z6?fz(T,W,U,X):T instanceof $U?T.value:T&&T[0]instanceof z6?T.reduce((Y,_)=>Y+" "+fz(_,W,U,X),""):$8(T,W,U,X)}function fz($,T,W,U){return $.fragment=!0,yz($,$.strings[0],$.args[0],T,W,U)}function hZ($,T,W,U,X){return $.map((Y)=>"("+U.map((_)=>hz("values",Y[_],T,W,X)).join(",")+")").join(",")}function fZ($,T,W,U,X){let Y=Array.isArray($[0]),_=T.length?T.flat():Object.keys(Y?$[0]:$);return hZ(Y?$:[$],W,U,_,X)}function tY($,T,W,U,X){if(typeof $==="string"&&($=[$].concat(T)),Array.isArray($))return gz($,X);let Y;return(T.length?T.flat():Object.keys($)).map((w)=>{return Y=$[w],(Y instanceof z6?fz(Y,W,U,X):Y instanceof $U?Y.value:$8(Y,W,U,X))+" as "+T8(X.transform.column.to?X.transform.column.to(w):w)}).join(",")}var Pk=Object.entries({values:fZ,in:(...$)=>{let T=fZ(...$);return T==="()"?"(null)":T},select:tY,as:tY,returning:tY,"\\(":tY,update($,T,W,U,X){return(T.length?T.flat():Object.keys($)).map((Y)=>T8(X.transform.column.to?X.transform.column.to(Y):Y)+"="+hz("values",$[Y],W,U,X))},insert($,T,W,U,X){let Y=T.length?T.flat():Object.keys(Array.isArray($)?$[0]:$);return"("+gz(Y,X)+")values"+hZ(Array.isArray($)?$:[$],W,U,Y,X)}}).map(([$,T])=>[new RegExp("((?:^|[\\s(])"+$+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),T]);function xz(){throw s$.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var{serializers:Ck,parsers:jk}=yZ;function gZ($){if(Array.isArray($))return gZ($[0]);return typeof $==="string"?1009:0}var mZ=function($){let T=cZ($||{});return{serializers:Object.assign({},Ck,T.serializers),parsers:Object.assign({},jk,T.parsers)}};function cZ($){return Object.keys($).reduce((T,W)=>{if($[W].from&&[].concat($[W].from).forEach((U)=>T.parsers[U]=$[W].parse),$[W].serialize)T.serializers[$[W].to]=$[W].serialize,$[W].from&&[].concat($[W].from).forEach((U)=>T.serializers[U]=$[W].serialize);return T},{parsers:{},serializers:{}})}function gz($,{transform:{column:T}}){return $.map((W)=>T8(T.to?T.to(W):W)).join(",")}var T8=function $(T){return'"'+T.replace(/"/g,'""').replace(/\./g,'"."')+'"'},aY=function $(T){return T instanceof h6?T.type:T instanceof Date?1184:T instanceof Uint8Array?17:T===!0||T===!1?16:typeof T==="bigint"?20:Array.isArray(T)?$(T[0]):0},xk=/\\/g,bk=/"/g;function fk($){return $.replace(xk,"\\\\").replace(bk,"\\\"")}var uZ=function $(T,W,U,X){if(Array.isArray(T)===!1)return T;if(!T.length)return"{}";let Y=T[0],_=X===1020?";":",";if(Array.isArray(Y)&&!Y.type)return"{"+T.map((w)=>$(w,W,U,X)).join(_)+"}";return"{"+T.map((w)=>{if(w===void 0){if(w=U.transform.undefined,w===void 0)throw s$.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return w===null?"null":'"'+fk(W?W(w.type?w.value:w):""+w)+'"'}).join(_)+"}"},bz={i:0,char:null,str:"",quoted:!1,last:0},pZ=function $(T,W,U){return bz.i=bz.last=0,oZ(bz,T,W,U)};function oZ($,T,W,U){let X=[],Y=U===1020?";":",";for(;$.i<T.length;$.i++){if($.char=T[$.i],$.quoted)if($.char==="\\")$.str+=T[++$.i];else if($.char==='"')X.push(W?W($.str):$.str),$.str="",$.quoted=T[$.i+1]==='"',$.last=$.i+2;else $.str+=$.char;else if($.char==='"')$.quoted=!0;else if($.char==="{")$.last=++$.i,X.push(oZ($,T,W,U));else if($.char==="}"){$.quoted=!1,$.last<$.i&&X.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;break}else if($.char===Y&&$.p!=="}"&&$.p!=='"')X.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;$.p=$.char}return $.last<$.i&&X.push(W?W(T.slice($.last,$.i+1)):T.slice($.last,$.i+1)),X}var q0=($)=>{let T=$[0];for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},P0=($)=>{let T=$[0].toUpperCase();for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},C0=($)=>$.replace(/_/g,"-"),a2=($)=>$.replace(/([A-Z])/g,"_$1").toLowerCase(),s2=($)=>($.slice(0,1)+$.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),e2=($)=>$.replace(/-/g,"_");function mz($){return function T(W,U){return typeof W==="object"&&W!==null&&(U.type===114||U.type===3802)?Array.isArray(W)?W.map((X)=>T(X,U)):Object.entries(W).reduce((X,[Y,_])=>Object.assign(X,{[$(Y)]:T(_,U)}),{}):W}}q0.column={from:q0};q0.value={from:mz(q0)};a2.column={to:a2};var cz={...q0};cz.column.to=a2;P0.column={from:P0};P0.value={from:mz(P0)};s2.column={to:s2};var uz={...P0};uz.column.to=s2;C0.column={from:C0};C0.value={from:mz(C0)};e2.column={to:e2};var pz={...C0};pz.column.to=e2;import dZ from"net";import mk from"tls";import TU from"crypto";import oz from"stream";import{performance as lZ}from"perf_hooks";class j0 extends Array{constructor(){super();Object.defineProperties(this,{count:{value:null,writable:!0},state:{value:null,writable:!0},command:{value:null,writable:!0},columns:{value:null,writable:!0},statement:{value:null,writable:!0}})}static get[Symbol.species](){return Array}}var W6=yk;function yk($=[]){let T=$.slice(),W=0;return{get length(){return T.length-W},remove:(U)=>{let X=T.indexOf(U);return X===-1?null:(T.splice(X,1),U)},push:(U)=>(T.push(U),U),shift:()=>{let U=T[W++];if(W===T.length)W=0,T=[];else T[W-1]=void 0;return U}}}var N4=Buffer.allocUnsafe(256),hk="BCcDdEFfHPpQSX".split("").reduce(($,T)=>{let W=T.charCodeAt(0);return $[T]=()=>{return N4[0]=W,S$.i=5,S$},$},{}),S$=Object.assign(gk,hk,{N:String.fromCharCode(0),i:0,inc($){return S$.i+=$,S$},str($){let T=Buffer.byteLength($);return W8(T),S$.i+=N4.write($,S$.i,T,"utf8"),S$},i16($){return W8(2),N4.writeUInt16BE($,S$.i),S$.i+=2,S$},i32($,T){if(T||T===0)return N4.writeUInt32BE($,T),S$;return W8(4),N4.writeUInt32BE($,S$.i),S$.i+=4,S$},z($){return W8($),N4.fill(0,S$.i,S$.i+$),S$.i+=$,S$},raw($){return N4=Buffer.concat([N4.subarray(0,S$.i),$]),S$.i=N4.length,S$},end($=1){N4.writeUInt32BE(S$.i-$,$);let T=N4.subarray(0,S$.i);return S$.i=0,N4=Buffer.allocUnsafe(256),T}}),i=S$;function W8($){if(N4.length-S$.i<$){let T=N4,W=T.length;N4=Buffer.allocUnsafe(W+(W>>1)+$),T.copy(N4)}}function gk(){return S$.i=0,S$}var rz=nZ,ck=1,c1=i().S().end(),rZ=i().H().end(),uk=i().i32(8).i32(80877103).end(8),pk=Buffer.concat([i().E().str(i.N).i32(0).end(),c1]),ok=i().D().str("S").str(i.N).end(),CT=()=>{},dk=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),lk={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function nZ($,T={},{onopen:W=CT,onend:U=CT,onclose:X=CT}={}){let{ssl:Y,max:_,user:w,host:G,port:J,database:H,parsers:z,transform:F,onnotice:Q,onnotify:V,onparameter:K,max_pipeline:I,keep_alive:k,backoff:N,target_session_attrs:L}=$,q=W6(),y=ck++,x={pid:null,secret:null},u=lz(d8,$.idle_timeout),w$=lz(d8,$.max_lifetime),m$=lz(bA,$.connect_timeout),B=null,D$,$$=new j0,H$=Buffer.alloc(0),$4=$.fetch_types,V4={},Q6={},u0=Math.random().toString(36).slice(2),C=1,e=0,A$=0,g$=0,T4=0,J$=0,M$=0,n$=0,c$=null,x$=null,K4=!1,k$=null,Z6=null,D4=null,A1=null,W4=null,b$=null,V6=null,v6=null,m=null,TW=null,E4={queue:T.closed,idleTimer:u,connect(O){D4=O,g5()},terminate:UW,execute:WW,cancel:PA,end:d8,count:0,id:y};return T.closed&&T.closed.push(E4),E4;async function qA(){let O;try{O=$.socket?await Promise.resolve($.socket($)):new dZ.Socket}catch(A){o0(A);return}return O.on("error",o0),O.on("close",m5),O.on("drain",y5),O}async function PA({pid:O,secret:A},t,V$){try{D$=i().i32(16).i32(80877102).i32(O).i32(A).end(16),await h5(),B.once("error",V$),B.once("close",t)}catch(d$){V$(d$)}}function WW(O){if(K4)return hU(O,s$.connection("CONNECTION_DESTROYED",$));if(O.cancelled)return;try{return O.state=x,m?q.push(O):(m=O,m.active=!0),xA(O),Q4(CA(O))&&!O.describeFirst&&!O.cursorFn&&q.length<I&&(!O.options.onexecute||O.options.onexecute(E4))}catch(A){return q.length===0&&Q4(c1),q6(A),!0}}function CA(O){if(O.parameters.length>=65534)throw s$.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return O.options.simple?i().Q().str(O.statement.string+i.N).end():O.describeFirst?Buffer.concat([x5(O),rZ]):O.prepare?O.prepared?yU(O):Buffer.concat([x5(O),yU(O)]):jA(O)}function x5(O){return Buffer.concat([u5(O.statement.string,O.parameters,O.statement.types,O.statement.name),EM("S",O.statement.name)])}function yU(O){return Buffer.concat([KM(O.parameters,O.statement.types,O.statement.name,O.cursorName),O.cursorFn?p5("",O.cursorRows):pk])}function jA(O){return Buffer.concat([u5(O.statement.string,O.parameters,O.statement.types),ok,yU(O)])}function xA(O){let A=[],t=[],V$=yz(O,O.strings[0],O.args[0],A,t,$);!O.tagged&&O.args.forEach((d$)=>$8(d$,A,t,$)),O.prepare=$.prepare&&("prepare"in O.options?O.options.prepare:!0),O.string=V$,O.signature=O.prepare&&t+V$,O.onlyDescribe&&delete Q6[O.signature],O.parameters=O.parameters||A,O.prepared=O.prepare&&O.signature in Q6,O.describeFirst=O.onlyDescribe||A.length&&!O.prepared,O.statement=O.prepared?Q6[O.signature]:{string:V$,types:t,name:O.prepare?u0+C++:""},typeof $.debug==="function"&&$.debug(y,V$,A,t)}function Q4(O,A){if(b$=b$?Buffer.concat([b$,O]):Buffer.from(O),A||b$.length>=1024)return b5(A);return x$===null&&(x$=setImmediate(b5)),!0}function b5(O){let A=B.write(b$,O);return x$!==null&&clearImmediate(x$),b$=x$=null,A}function bA(){q6(s$.connection("CONNECT_TIMEOUT",$,B)),B.destroy()}async function f5(){if(Q4(uk),!await new Promise((A)=>B.once("data",(t)=>A(t[0]===83)))&&Y==="prefer")return p0();B.removeAllListeners(),B=mk.connect({socket:B,servername:dZ.isIP(B.host)?void 0:B.host,...Y==="require"||Y==="allow"||Y==="prefer"?{rejectUnauthorized:!1}:Y==="verify-full"?{}:typeof Y==="object"?Y:{}}),B.on("secureConnect",p0),B.on("error",o0),B.on("close",m5),B.on("drain",y5)}function y5(){!m&&W(E4)}function o8(O){if(k$){if(k$.push(O),A$-=O.length,A$>0)return}H$=k$?Buffer.concat(k$,J$-A$):H$.length===0?O:Buffer.concat([H$,O],H$.length+O.length);while(H$.length>4){if(J$=H$.readUInt32BE(1),J$>=H$.length){A$=J$-H$.length,k$=[H$];break}try{fA(H$.subarray(0,J$+1))}catch(A){m&&(m.cursorFn||m.describeFirst)&&Q4(c1),q6(A)}H$=H$.subarray(J$+1),A$=0,k$=null}}async function h5(){if(K4=!1,V4={},B||(B=await qA()),!B)return;if(m$.start(),$.socket)return Y?f5():p0();if(B.on("connect",Y?f5:p0),$.path)return B.connect($.path);B.ssl=Y,B.connect(J[g$],G[g$]),B.host=G[g$],B.port=J[g$],g$=(g$+1)%J.length}function g5(){setTimeout(h5,e?e+M$-lZ.now():0)}function p0(){try{Q6={},$4=$.fetch_types,u0=Math.random().toString(36).slice(2),C=1,w$.start(),B.on("data",o8),k&&B.setKeepAlive&&B.setKeepAlive(!0,1000*k);let O=MM();Q4(O)}catch(O){o0(O)}}function o0(O){if(E4.queue===T.connecting&&$.host[T4+1])return;q6(O);while(q.length)hU(q.shift(),O)}function q6(O){W4&&(W4.destroy(O),W4=null),m&&hU(m,O),D4&&(hU(D4,O),D4=null)}function hU(O,A){if(O.reserve)return O.reject(A);if(!A||typeof A!=="object")A=new Error(A);"query"in A||"parameters"in A||Object.defineProperties(A,{stack:{value:A.stack+O.origin.replace(/.*\n/,`
81
- `),enumerable:$.debug},query:{value:O.string,enumerable:$.debug},parameters:{value:O.parameters,enumerable:$.debug},args:{value:O.args,enumerable:$.debug},types:{value:O.statement&&O.statement.types,enumerable:$.debug}}),O.reject(A)}function d8(){return A1||(!E4.reserved&&U(E4),!E4.reserved&&!D4&&!m&&q.length===0?(UW(),new Promise((O)=>B&&B.readyState!=="closed"?B.once("close",O):O())):A1=new Promise((O)=>V6=O))}function UW(){if(K4=!0,W4||m||D4||q.length)o0(s$.connection("CONNECTION_DESTROYED",$));if(clearImmediate(x$),B)B.removeListener("data",o8),B.removeListener("connect",p0),B.readyState==="open"&&B.end(i().X().end());V6&&(V6(),A1=V6=null)}async function m5(O){if(H$=Buffer.alloc(0),A$=0,k$=null,clearImmediate(x$),B.removeListener("data",o8),B.removeListener("connect",p0),u.cancel(),w$.cancel(),m$.cancel(),B.removeAllListeners(),B=null,D4)return g5();!O&&(m||q.length)&&o0(s$.connection("CONNECTION_CLOSED",$,B)),e=lZ.now(),O&&$.shared.retries++,M$=(typeof N==="function"?N($.shared.retries):N)*1000,X(E4,s$.connection("CONNECTION_CLOSED",$,B))}function fA(O,A=O[0]){(A===68?yA:A===100?zM:A===65?XM:A===83?hA:A===90?gA:A===67?mA:A===50?c5:A===49?cA:A===116?uA:A===84?pA:A===82?oA:A===110?tA:A===75?aA:A===69?WM:A===115?YM:A===51?_M:A===71?wM:A===78?FM:A===72?JM:A===99?HM:A===73?OM:A===86?DM:A===118?QM:A===87?GM:ZM)(O)}function yA(O){let A=7,t,V$,d$,A4=m.isRaw?new Array(m.statement.columns.length):{};for(let B4=0;B4<m.statement.columns.length;B4++)V$=m.statement.columns[B4],t=O.readInt32BE(A),A+=4,d$=t===-1?null:m.isRaw===!0?O.subarray(A,A+=t):V$.parser===void 0?O.toString("utf8",A,A+=t):V$.parser.array===!0?V$.parser(O.toString("utf8",A+1,A+=t)):V$.parser(O.toString("utf8",A,A+=t)),m.isRaw?A4[B4]=m.isRaw===!0?d$:F.value.from?F.value.from(d$,V$):d$:A4[V$.name]=F.value.from?F.value.from(d$,V$):d$;m.forEachFn?m.forEachFn(F.row.from?F.row.from(A4):A4,$$):$$[n$++]=F.row.from?F.row.from(A4):A4}function hA(O){let[A,t]=O.toString("utf8",5,O.length-1).split(i.N);if(V4[A]=t,$.parameters[A]!==t)$.parameters[A]=t,K&&K(A,t)}function gA(O){if(m&&m.options.simple&&m.resolve(Z6||$$),m=Z6=null,$$=new j0,m$.cancel(),D4){if(L){if(!V4.in_hot_standby||!V4.default_transaction_read_only)return TM();else if($M(L,V4))return UW()}if($4)return D4.reserve&&(D4=null),sA();D4&&!D4.reserve&&WW(D4),$.shared.retries=T4=0,D4=null;return}while(q.length&&(m=q.shift())&&(m.active=!0,m.cancelled))nZ($).cancel(m.state,m.cancelled.resolve,m.cancelled.reject);if(m)return;E4.reserved?!E4.reserved.release&&O[5]===73?A1?UW():(E4.reserved=null,W(E4)):E4.reserved():A1?UW():W(E4)}function mA(O){n$=0;for(let A=O.length-1;A>0;A--){if(O[A]===32&&O[A+1]<58&&$$.count===null)$$.count=+O.toString("utf8",A+1,O.length-1);if(O[A-1]>=65){$$.command=O.toString("utf8",5,A),$$.state=x;break}}if(TW&&(TW(),TW=null),$$.command==="BEGIN"&&_!==1&&!E4.reserved)return q6(s$.generic("UNSAFE_TRANSACTION","Only use sql.begin, sql.reserved or max: 1"));if(m.options.simple)return c5();if(m.cursorFn)$$.count&&m.cursorFn($$),Q4(c1);m.resolve($$)}function cA(){m.parsing=!1}function c5(){!$$.statement&&($$.statement=m.statement),$$.columns=m.statement.columns}function uA(O){let A=O.readUInt16BE(5);for(let t=0;t<A;++t)!m.statement.types[t]&&(m.statement.types[t]=O.readUInt32BE(7+t*4));m.prepare&&(Q6[m.signature]=m.statement),m.describeFirst&&!m.onlyDescribe&&(Q4(yU(m)),m.describeFirst=!1)}function pA(O){if($$.command)Z6=Z6||[$$],Z6.push($$=new j0),$$.count=null,m.statement.columns=null;let A=O.readUInt16BE(5),t=7,V$;m.statement.columns=Array(A);for(let d$=0;d$<A;++d$){V$=t;while(O[t++]!==0);let A4=O.readUInt32BE(t),B4=O.readUInt16BE(t+4),M1=O.readUInt32BE(t+6);m.statement.columns[d$]={name:F.column.from?F.column.from(O.toString("utf8",V$,t-1)):O.toString("utf8",V$,t-1),parser:z[M1],table:A4,number:B4,type:M1},t+=18}if($$.statement=m.statement,m.onlyDescribe)return m.resolve(m.statement),Q4(c1)}async function oA(O,A=O.readUInt32BE(5)){(A===3?dA:A===5?lA:A===10?rA:A===11?iA:A===12?nA:A!==0?VM:CT)(O,A)}async function dA(){let O=await l8();Q4(i().p().str(O).z(1).end())}async function lA(O){let A="md5"+await iZ(Buffer.concat([Buffer.from(await iZ(await l8()+w)),O.subarray(9)]));Q4(i().p().str(A).z(1).end())}async function rA(){v6=(await TU.randomBytes(18)).toString("base64"),i().p().str("SCRAM-SHA-256"+i.N);let O=i.i;Q4(i.inc(4).str("n,,n=*,r="+v6).i32(i.i-O-4,O).end())}async function iA(O){let A=O.toString("utf8",9).split(",").reduce((B4,M1)=>(B4[M1[0]]=M1.slice(2),B4),{}),t=await TU.pbkdf2Sync(await l8(),Buffer.from(A.s,"base64"),parseInt(A.i),32,"sha256"),V$=await U8(t,"Client Key"),d$="n=*,r="+v6+",r="+A.r+",s="+A.s+",i="+A.i+",c=biws,r="+A.r;c$=(await U8(await U8(t,"Server Key"),d$)).toString("base64");let A4="c=biws,r="+A.r+",p="+ik(V$,Buffer.from(await U8(await rk(V$),d$))).toString("base64");Q4(i().p().str(A4).end())}function nA(O){if(O.toString("utf8",9).split(i.N,1)[0].slice(2)===c$)return;q6(s$.generic("SASL_SIGNATURE_MISMATCH","The server did not return the correct signature")),B.destroy()}function l8(){return Promise.resolve(typeof $.pass==="function"?$.pass():$.pass)}function tA(){if($$.statement=m.statement,$$.statement.columns=[],m.onlyDescribe)return m.resolve(m.statement),Q4(c1)}function aA(O){x.pid=O.readUInt32BE(5),x.secret=O.readUInt32BE(9)}async function sA(){$4=!1,(await new z6([`
81
+ `);this.baseURL=U.baseURL,this.timeout=U.timeout??lF.DEFAULT_TIMEOUT,this.logger=U.logger??console;let Y="warn";this.logLevel=Y,this.logLevel=KF(U.logLevel,"ClientOptions.logLevel",this)??KF(TW("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??Y,this.fetchOptions=U.fetchOptions,this.maxRetries=U.maxRetries??2,this.fetch=U.fetch??qA(),w$(this,SG,CA,"f"),this._options=U,this.apiKey=T,this.organization=W,this.project=w}withOptions($){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,...$})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:$,nulls:T}){return}authHeaders($){return a([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery($){return JF($,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${zT}`}defaultIdempotencyKey(){return`stainless-node-retry-${VF()}`}makeStatusError($,T,W,w){return L4.generate($,T,W,w)}buildURL($,T){let W=KA($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),w=this.defaultQuery();if(!EA(w))T={...w,...T};if(typeof T==="object"&&T&&!Array.isArray(T))W.search=this.stringifyQuery(T);return W.toString()}async prepareOptions($){}async prepareRequest($,{url:T,options:W}){}get($,T){return this.methodRequest("get",$,T)}post($,T){return this.methodRequest("post",$,T)}patch($,T){return this.methodRequest("patch",$,T)}put($,T){return this.methodRequest("put",$,T)}delete($,T){return this.methodRequest("delete",$,T)}methodRequest($,T,W){return this.request(Promise.resolve(W).then((w)=>{return{method:$,path:T,...w}}))}request($,T=null){return new tT(this,this.makeRequest($,T,void 0))}async makeRequest($,T,W){let w=await $,X=w.maxRetries??this.maxRetries;if(T==null)T=X;await this.prepareOptions(w);let{req:U,url:Y,timeout:G}=this.buildRequest(w,{retryCount:X-T});await this.prepareRequest(U,{url:Y,options:w});let H="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),z=W===void 0?"":`, retryOf: ${W}`,F=Date.now();if(C4(this).debug(`[${H}] sending request`,M0({retryOfRequestLogID:W,method:w.method,url:Y,options:w,headers:U.headers})),w.signal?.aborted)throw new P4;let O=new AbortController,Q=await this.fetchWithTimeout(Y,U,G,O).catch(A8),Z=Date.now();if(Q instanceof Error){let M=`retrying, ${T} attempts remaining`;if(w.signal?.aborted)throw new P4;let L=K8(Q)||/timed? ?out/i.test(String(Q)+("cause"in Q?String(Q.cause):""));if(T)return C4(this).info(`[${H}] connection ${L?"timed out":"failed"} - ${M}`),C4(this).debug(`[${H}] connection ${L?"timed out":"failed"} (${M})`,M0({retryOfRequestLogID:W,url:Y,durationMs:Z-F,message:Q.message})),this.retryRequest(w,T,W??H);if(C4(this).info(`[${H}] connection ${L?"timed out":"failed"} - error; no more retries left`),C4(this).debug(`[${H}] connection ${L?"timed out":"failed"} (error; no more retries left)`,M0({retryOfRequestLogID:W,url:Y,durationMs:Z-F,message:Q.message})),L)throw new iT;throw new nT({cause:Q})}let K=[...Q.headers.entries()].filter(([M])=>M==="x-request-id").map(([M,L])=>", "+M+": "+JSON.stringify(L)).join(""),E=`[${H}${z}${K}] ${U.method} ${Y} ${Q.ok?"succeeded":"failed"} with status ${Q.status} in ${Z-F}ms`;if(!Q.ok){let M=this.shouldRetry(Q);if(T&&M){let b=`retrying, ${T} attempts remaining`;return await PA(Q.body),C4(this).info(`${E} - ${b}`),C4(this).debug(`[${H}] response error (${b})`,M0({retryOfRequestLogID:W,url:Q.url,status:Q.status,headers:Q.headers,durationMs:Z-F})),this.retryRequest(w,T,W??H,Q.headers)}let L=M?"error; no more retries left":"error; not retryable";C4(this).info(`${E} - ${L}`);let R=await Q.text().catch((b)=>A8(b).message),_=NA(R),S=_?void 0:R;throw C4(this).debug(`[${H}] response error (${L})`,M0({retryOfRequestLogID:W,url:Q.url,status:Q.status,headers:Q.headers,message:S,durationMs:Date.now()-F})),this.makeStatusError(Q.status,_,S,Q.headers)}return C4(this).info(E),C4(this).debug(`[${H}] response start`,M0({retryOfRequestLogID:W,url:Q.url,status:Q.status,headers:Q.headers,durationMs:Z-F})),{response:Q,options:w,controller:O,requestLogID:H,retryOfRequestLogID:W,startTime:F}}getAPIList($,T,W){return this.requestAPIList(T,{method:"get",path:$,...W})}requestAPIList($,T){let W=this.makeRequest(T,null,void 0);return new QG(this,W,$)}async fetchWithTimeout($,T,W,w){let{signal:X,method:U,...Y}=T||{};if(X)X.addEventListener("abort",()=>w.abort());let G=setTimeout(()=>w.abort(),W),H=globalThis.ReadableStream&&Y.body instanceof globalThis.ReadableStream||typeof Y.body==="object"&&Y.body!==null&&Symbol.asyncIterator in Y.body,z={signal:w.signal,...H?{duplex:"half"}:{},method:"GET",...Y};if(U)z.method=U.toUpperCase();try{return await this.fetch.call(void 0,$,z)}finally{clearTimeout(G)}}shouldRetry($){let T=$.headers.get("x-should-retry");if(T==="true")return!0;if(T==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,T,W,w){let X,U=w?.get("retry-after-ms");if(U){let G=parseFloat(U);if(!Number.isNaN(G))X=G}let Y=w?.get("retry-after");if(Y&&!X){let G=parseFloat(Y);if(!Number.isNaN(G))X=G*1000;else X=Date.parse(Y)-Date.now()}if(!(X&&0<=X&&X<60000)){let G=$.maxRetries??this.maxRetries;X=this.calculateDefaultRetryTimeoutMillis(T,G)}return await l1(X),this.makeRequest($,T-1,W)}calculateDefaultRetryTimeoutMillis($,T){let X=T-$,U=Math.min(0.5*Math.pow(2,X),8),Y=1-Math.random()*0.25;return U*Y*1000}buildRequest($,{retryCount:T=0}={}){let W={...$},{method:w,path:X,query:U}=W,Y=this.buildURL(X,U);if("timeout"in W)DA("timeout",W.timeout);W.timeout=W.timeout??this.timeout;let{bodyHeaders:G,body:H}=this.buildBody({options:W}),z=this.buildHeaders({options:$,method:w,bodyHeaders:G,retryCount:T});return{req:{method:w,headers:z,...W.signal&&{signal:W.signal},...globalThis.ReadableStream&&H instanceof globalThis.ReadableStream&&{duplex:"half"},...H&&{body:H},...this.fetchOptions??{},...W.fetchOptions??{}},url:Y,timeout:W.timeout}}buildHeaders({options:$,method:T,bodyHeaders:W,retryCount:w}){let X={};if(this.idempotencyHeader&&T!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();X[this.idempotencyHeader]=$.idempotencyKey}let U=a([X,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(w),...$.timeout?{"X-Stainless-Timeout":String(Math.trunc($.timeout/1000))}:{},...vA(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},this.authHeaders($),this._options.defaultHeaders,W,$.headers]);return this.validateHeaders(U),U.values}buildBody({options:{body:$,headers:T}}){if(!$)return{bodyHeaders:void 0,body:void 0};let W=a([T]);if(ArrayBuffer.isView($)||$ instanceof ArrayBuffer||$ instanceof DataView||typeof $==="string"&&W.values.has("content-type")||$ instanceof Blob||$ instanceof FormData||$ instanceof URLSearchParams||globalThis.ReadableStream&&$ instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:$};else if(typeof $==="object"&&((Symbol.asyncIterator in $)||(Symbol.iterator in $)&&("next"in $)&&typeof $.next==="function"))return{bodyHeaders:void 0,body:HG($)};else return v(this,SG,"f").call(this,{body:$,headers:W})}}lF=R$,SG=new WeakMap;R$.OpenAI=lF;R$.DEFAULT_TIMEOUT=600000;R$.OpenAIError=$$;R$.APIError=L4;R$.APIConnectionError=nT;R$.APIConnectionTimeoutError=iT;R$.APIUserAbortError=P4;R$.NotFoundError=N8;R$.ConflictError=L8;R$.RateLimitError=R8;R$.BadRequestError=E8;R$.AuthenticationError=M8;R$.InternalServerError=_8;R$.PermissionDeniedError=D8;R$.UnprocessableEntityError=J8;R$.toFile=ZG;R$.Completions=H2;R$.Chat=eT;R$.Embeddings=O2;R$.Files=Z2;R$.Images=E2;R$.Audio=J0;R$.Moderations=D2;R$.Models=M2;R$.FineTuning=t1;R$.Graders=zW;R$.VectorStores=VT;R$.Beta=R0;R$.Batches=Y2;R$.Uploads=FW;R$.Responses=HW;R$.Evals=GW;R$.Containers=YW;function gj($,...T){let[W,w,X,U]=T,Y=[{role:"user",content:eK(w)},{role:"user",content:W}],G=U.at(-1);if(G)Y.push({role:"user",content:["Oops! That didn't work. Here's what was returned last time:",JSON.stringify(G.response,null,2),"Here's the error message:",JSON.stringify(G.error.issues,null,2)].join(`
82
+ `)});return{model:$,messages:Y}}var O$=1e6,EE={"gpt-4.1":{promptPricePerToken:2/O$,promptPricePerTokenCached:0.5/O$,completionPricePerToken:8/O$},"gpt-4.1-mini":{promptPricePerToken:0.4/O$,promptPricePerTokenCached:0.1/O$,completionPricePerToken:1.6/O$},"gpt-4.1-nano":{promptPricePerToken:0.1/O$,promptPricePerTokenCached:0.025/O$,completionPricePerToken:0.4/O$},"gpt-4o":{promptPricePerToken:2.5/O$,promptPricePerTokenCached:1.25/O$,completionPricePerToken:10/O$},"gpt-4o-mini":{promptPricePerToken:0.15/O$,promptPricePerTokenCached:0.075/O$,completionPricePerToken:0.6/O$},o1:{promptPricePerToken:15/O$,promptPricePerTokenCached:7.5/O$,completionPricePerToken:60/O$},"o1-mini":{promptPricePerToken:1.1/O$,promptPricePerTokenCached:0.55/O$,completionPricePerToken:4.4/O$},o3:{promptPricePerToken:10/O$,promptPricePerTokenCached:2.5/O$,completionPricePerToken:40/O$},"o3-mini":{promptPricePerToken:1.1/O$,promptPricePerTokenCached:0.55/O$,completionPricePerToken:4.4/O$},"o4-mini":{promptPricePerToken:1.1/O$,promptPricePerTokenCached:0.275/O$,completionPricePerToken:4.4/O$},"codex-mini-latest":{promptPricePerToken:1.5/O$,promptPricePerTokenCached:0.375/O$,completionPricePerToken:6/O$},"chatgpt-4o-latest":{promptPricePerToken:5/O$,promptPricePerTokenCached:5/O$,completionPricePerToken:15/O$},"gpt-4":{promptPricePerToken:30/O$,promptPricePerTokenCached:30/O$,completionPricePerToken:60/O$},"gpt-4-turbo":{promptPricePerToken:10/O$,promptPricePerTokenCached:10/O$,completionPricePerToken:30/O$},"gpt-3.5-turbo":{promptPricePerToken:0.5/O$,promptPricePerTokenCached:0.5/O$,completionPricePerToken:1.5/O$},"gpt-4-32k":{promptPricePerToken:60/O$,promptPricePerTokenCached:60/O$,completionPricePerToken:120/O$},"gpt-3.5-turbo-16k":{promptPricePerToken:3/O$,promptPricePerTokenCached:3/O$,completionPricePerToken:4/O$}};function mj($){let W=Object.keys(EE).filter((w)=>$.startsWith(w)).sort((w,X)=>X.length-w.length)[0];if(!W)return;return EE[W]}function cj($){return async function T(W,w){if(!$)throw new Error("This is a bug in safegen. OpenAI client not available to the json generator.");let X=await $.chat.completions.create({...W,stream:!1,response_format:{type:"json_object"}},w),U=X.choices[0].message?.content,{usage:Y}=X;if(U&&Y){let G=Y.prompt_tokens,H=Y.prompt_tokens_details?.cached_tokens??0,z=G-H,F=Y.completion_tokens,O=mj(W.model),Q=0;if(O)Q=G*O.promptPricePerToken+z*(O.promptPricePerTokenCached??0)+F*O.completionPricePerToken;else console.warn(`No pricing facts found for model ${W.model}. Giving a price of 0.`);return{data:JSON.parse(U),usage:Y,usdPrice:Q}}if(!U&&!Y)throw new Error("No content or usage found in completion");if(!U)throw new Error("No content found in completion");throw new Error("No usage found in completion")}}var ME=new Map,DE=class{usdBudget;usdMinimum;getUnknownJsonFromOpenAi;getUnknownJsonFromOpenAiSquirreled;squirrel;client;lastUsage;constructor({model:$,usdBudget:T,usdMinimum:W,apiKey:w,cachingMode:X,cacheKey:U="openai-safegen",logger:Y}){this.usdBudget=T,this.usdMinimum=W,this.squirrel=new VA(X);let G=ME.get(w);if(X!=="read"){if(!G)G=new R$({apiKey:w,dangerouslyAllowBrowser:!1}),ME.set(w,G);this.client=G}this.getUnknownJsonFromOpenAi=cj(this.client),this.getUnknownJsonFromOpenAiSquirreled=this.squirrel.add(U,this.getUnknownJsonFromOpenAi),this.from=sK(async(...H)=>{if(this.usdBudget<this.usdMinimum)return Y?.warn("SafeGen budget exhausted"),H[2];let z=gj($,...H),F=H[0],O=H[3],{data:Q,usage:Z,usdPrice:K}=await this.getUnknownJsonFromOpenAiSquirreled.for(`${F.replace(/[^a-zA-Z0-9-_. ]/g,"_")}-${O.length}`).get(z);return this.lastUsage=Z,this.usdBudget-=K,Q},Y)}from};import{exec as by}from"child_process";class A extends Array{constructor($,T){if(super($),this.sign=T,Object.setPrototypeOf(this,A.prototype),$>A.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded")}static BigInt($){var T=Math.floor,W=Number.isFinite;if(typeof $=="number"){if($===0)return A.__zero();if(A.__isOneDigitInt($))return 0>$?A.__oneDigit(-$,!0):A.__oneDigit($,!1);if(!W($)||T($)!==$)throw new RangeError("The number "+$+" cannot be converted to BigInt because it is not an integer");return A.__fromDouble($)}if(typeof $=="string"){let w=A.__fromString($);if(w===null)throw new SyntaxError("Cannot convert "+$+" to a BigInt");return w}if(typeof $=="boolean")return $===!0?A.__oneDigit(1,!1):A.__zero();if(typeof $=="object"){if($.constructor===A)return $;let w=A.__toPrimitive($);return A.BigInt(w)}throw new TypeError("Cannot convert "+$+" to a BigInt")}toDebugString(){let $=["BigInt["];for(let T of this)$.push((T?(T>>>0).toString(16):T)+", ");return $.push("]"),$.join("")}toString($=10){if(2>$||36<$)throw new RangeError("toString() radix argument must be between 2 and 36");return this.length===0?"0":($&$-1)==0?A.__toStringBasePowerOfTwo(this,$):A.__toStringGeneric(this,$,!1)}valueOf(){throw new Error("Convert JSBI instances to native numbers using `toNumber`.")}static toNumber($){let T=$.length;if(T===0)return 0;if(T===1){let E=$.__unsignedDigit(0);return $.sign?-E:E}let W=$.__digit(T-1),w=A.__clz30(W),X=30*T-w;if(1024<X)return $.sign?-1/0:1/0;let U=X-1,Y=W,G=T-1,H=w+3,z=H===32?0:Y<<H;z>>>=12;let F=H-12,O=12<=H?0:Y<<20+H,Q=20+H;for(0<F&&0<G&&(G--,Y=$.__digit(G),z|=Y>>>30-F,O=Y<<F+2,Q=F+2);0<Q&&0<G;)G--,Y=$.__digit(G),O|=30<=Q?Y<<Q-30:Y>>>30-Q,Q-=30;let Z=A.__decideRounding($,Q,G,Y);if((Z===1||Z===0&&(1&O)==1)&&(O=O+1>>>0,O===0&&(z++,z>>>20!=0&&(z=0,U++,1023<U))))return $.sign?-1/0:1/0;let K=$.sign?-2147483648:0;return U=U+1023<<20,A.__kBitConversionInts[A.__kBitConversionIntHigh]=K|U|z,A.__kBitConversionInts[A.__kBitConversionIntLow]=O,A.__kBitConversionDouble[0]}static unaryMinus($){if($.length===0)return $;let T=$.__copy();return T.sign=!$.sign,T}static bitwiseNot($){return $.sign?A.__absoluteSubOne($).__trim():A.__absoluteAddOne($,!0)}static exponentiate($,T){if(T.sign)throw new RangeError("Exponent must be positive");if(T.length===0)return A.__oneDigit(1,!1);if($.length===0)return $;if($.length===1&&$.__digit(0)===1)return $.sign&&(1&T.__digit(0))==0?A.unaryMinus($):$;if(1<T.length)throw new RangeError("BigInt too big");let W=T.__unsignedDigit(0);if(W===1)return $;if(W>=A.__kMaxLengthBits)throw new RangeError("BigInt too big");if($.length===1&&$.__digit(0)===2){let U=1+(0|W/30),Y=$.sign&&(1&W)!=0,G=new A(U,Y);G.__initializeDigits();let H=1<<W%30;return G.__setDigit(U-1,H),G}let w=null,X=$;for((1&W)!=0&&(w=$),W>>=1;W!==0;W>>=1)X=A.multiply(X,X),(1&W)!=0&&(w===null?w=X:w=A.multiply(w,X));return w}static multiply($,T){if($.length===0)return $;if(T.length===0)return T;let W=$.length+T.length;30<=$.__clzmsd()+T.__clzmsd()&&W--;let w=new A(W,$.sign!==T.sign);w.__initializeDigits();for(let X=0;X<$.length;X++)A.__multiplyAccumulate(T,$.__digit(X),w,X);return w.__trim()}static divide($,T){if(T.length===0)throw new RangeError("Division by zero");if(0>A.__absoluteCompare($,T))return A.__zero();let W=$.sign!==T.sign,w=T.__unsignedDigit(0),X;if(T.length===1&&32767>=w){if(w===1)return W===$.sign?$:A.unaryMinus($);X=A.__absoluteDivSmall($,w,null)}else X=A.__absoluteDivLarge($,T,!0,!1);return X.sign=W,X.__trim()}static remainder($,T){if(T.length===0)throw new RangeError("Division by zero");if(0>A.__absoluteCompare($,T))return $;let W=T.__unsignedDigit(0);if(T.length===1&&32767>=W){if(W===1)return A.__zero();let X=A.__absoluteModSmall($,W);return X===0?A.__zero():A.__oneDigit(X,$.sign)}let w=A.__absoluteDivLarge($,T,!1,!0);return w.sign=$.sign,w.__trim()}static add($,T){let W=$.sign;return W===T.sign?A.__absoluteAdd($,T,W):0<=A.__absoluteCompare($,T)?A.__absoluteSub($,T,W):A.__absoluteSub(T,$,!W)}static subtract($,T){let W=$.sign;return W===T.sign?0<=A.__absoluteCompare($,T)?A.__absoluteSub($,T,W):A.__absoluteSub(T,$,!W):A.__absoluteAdd($,T,W)}static leftShift($,T){return T.length===0||$.length===0?$:T.sign?A.__rightShiftByAbsolute($,T):A.__leftShiftByAbsolute($,T)}static signedRightShift($,T){return T.length===0||$.length===0?$:T.sign?A.__leftShiftByAbsolute($,T):A.__rightShiftByAbsolute($,T)}static unsignedRightShift(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}static lessThan($,T){return 0>A.__compareToBigInt($,T)}static lessThanOrEqual($,T){return 0>=A.__compareToBigInt($,T)}static greaterThan($,T){return 0<A.__compareToBigInt($,T)}static greaterThanOrEqual($,T){return 0<=A.__compareToBigInt($,T)}static equal($,T){if($.sign!==T.sign)return!1;if($.length!==T.length)return!1;for(let W=0;W<$.length;W++)if($.__digit(W)!==T.__digit(W))return!1;return!0}static notEqual($,T){return!A.equal($,T)}static bitwiseAnd($,T){var W=Math.max;if(!$.sign&&!T.sign)return A.__absoluteAnd($,T).__trim();if($.sign&&T.sign){let w=W($.length,T.length)+1,X=A.__absoluteSubOne($,w),U=A.__absoluteSubOne(T);return X=A.__absoluteOr(X,U,X),A.__absoluteAddOne(X,!0,X).__trim()}return $.sign&&([$,T]=[T,$]),A.__absoluteAndNot($,A.__absoluteSubOne(T)).__trim()}static bitwiseXor($,T){var W=Math.max;if(!$.sign&&!T.sign)return A.__absoluteXor($,T).__trim();if($.sign&&T.sign){let U=W($.length,T.length),Y=A.__absoluteSubOne($,U),G=A.__absoluteSubOne(T);return A.__absoluteXor(Y,G,Y).__trim()}let w=W($.length,T.length)+1;$.sign&&([$,T]=[T,$]);let X=A.__absoluteSubOne(T,w);return X=A.__absoluteXor(X,$,X),A.__absoluteAddOne(X,!0,X).__trim()}static bitwiseOr($,T){var W=Math.max;let w=W($.length,T.length);if(!$.sign&&!T.sign)return A.__absoluteOr($,T).__trim();if($.sign&&T.sign){let U=A.__absoluteSubOne($,w),Y=A.__absoluteSubOne(T);return U=A.__absoluteAnd(U,Y,U),A.__absoluteAddOne(U,!0,U).__trim()}$.sign&&([$,T]=[T,$]);let X=A.__absoluteSubOne(T,w);return X=A.__absoluteAndNot(X,$,X),A.__absoluteAddOne(X,!0,X).__trim()}static asIntN($,T){var W=Math.floor;if(T.length===0)return T;if($=W($),0>$)throw new RangeError("Invalid value: not (convertible to) a safe integer");if($===0)return A.__zero();if($>=A.__kMaxLengthBits)return T;let w=0|($+29)/30;if(T.length<w)return T;let X=T.__unsignedDigit(w-1),U=1<<($-1)%30;if(T.length===w&&X<U)return T;if((X&U)!==U)return A.__truncateToNBits($,T);if(!T.sign)return A.__truncateAndSubFromPowerOfTwo($,T,!0);if((X&U-1)==0){for(let Y=w-2;0<=Y;Y--)if(T.__digit(Y)!==0)return A.__truncateAndSubFromPowerOfTwo($,T,!1);return T.length===w&&X===U?T:A.__truncateToNBits($,T)}return A.__truncateAndSubFromPowerOfTwo($,T,!1)}static asUintN($,T){var W=Math.floor;if(T.length===0)return T;if($=W($),0>$)throw new RangeError("Invalid value: not (convertible to) a safe integer");if($===0)return A.__zero();if(T.sign){if($>A.__kMaxLengthBits)throw new RangeError("BigInt too big");return A.__truncateAndSubFromPowerOfTwo($,T,!1)}if($>=A.__kMaxLengthBits)return T;let w=0|($+29)/30;if(T.length<w)return T;let X=$%30;if(T.length==w){if(X===0)return T;if(T.__digit(w-1)>>>X==0)return T}return A.__truncateToNBits($,T)}static ADD($,T){if($=A.__toPrimitive($),T=A.__toPrimitive(T),typeof $=="string")return typeof T!="string"&&(T=T.toString()),$+T;if(typeof T=="string")return $.toString()+T;if($=A.__toNumeric($),T=A.__toNumeric(T),A.__isBigInt($)&&A.__isBigInt(T))return A.add($,T);if(typeof $=="number"&&typeof T=="number")return $+T;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}static LT($,T){return A.__compare($,T,0)}static LE($,T){return A.__compare($,T,1)}static GT($,T){return A.__compare($,T,2)}static GE($,T){return A.__compare($,T,3)}static EQ($,T){for(;;){if(A.__isBigInt($))return A.__isBigInt(T)?A.equal($,T):A.EQ(T,$);if(typeof $=="number"){if(A.__isBigInt(T))return A.__equalToNumber(T,$);if(typeof T!="object")return $==T;T=A.__toPrimitive(T)}else if(typeof $=="string"){if(A.__isBigInt(T))return $=A.__fromString($),$!==null&&A.equal($,T);if(typeof T!="object")return $==T;T=A.__toPrimitive(T)}else if(typeof $=="boolean"){if(A.__isBigInt(T))return A.__equalToNumber(T,+$);if(typeof T!="object")return $==T;T=A.__toPrimitive(T)}else if(typeof $=="symbol"){if(A.__isBigInt(T))return!1;if(typeof T!="object")return $==T;T=A.__toPrimitive(T)}else if(typeof $=="object"){if(typeof T=="object"&&T.constructor!==A)return $==T;$=A.__toPrimitive($)}else return $==T}}static NE($,T){return!A.EQ($,T)}static DataViewGetBigInt64($,T,W=!1){return A.asIntN(64,A.DataViewGetBigUint64($,T,W))}static DataViewGetBigUint64($,T,W=!1){let[w,X]=W?[4,0]:[0,4],U=$.getUint32(T+w,W),Y=$.getUint32(T+X,W),G=new A(3,!1);return G.__setDigit(0,1073741823&Y),G.__setDigit(1,(268435455&U)<<2|Y>>>30),G.__setDigit(2,U>>>28),G.__trim()}static DataViewSetBigInt64($,T,W,w=!1){A.DataViewSetBigUint64($,T,W,w)}static DataViewSetBigUint64($,T,W,w=!1){W=A.asUintN(64,W);let X=0,U=0;if(0<W.length&&(U=W.__digit(0),1<W.length)){let H=W.__digit(1);U|=H<<30,X=H>>>2,2<W.length&&(X|=W.__digit(2)<<28)}let[Y,G]=w?[4,0]:[0,4];$.setUint32(T+Y,X,w),$.setUint32(T+G,U,w)}static __zero(){return new A(0,!1)}static __oneDigit($,T){let W=new A(1,T);return W.__setDigit(0,$),W}__copy(){let $=new A(this.length,this.sign);for(let T=0;T<this.length;T++)$[T]=this[T];return $}__trim(){let $=this.length,T=this[$-1];for(;T===0;)$--,T=this[$-1],this.pop();return $===0&&(this.sign=!1),this}__initializeDigits(){for(let $=0;$<this.length;$++)this[$]=0}static __decideRounding($,T,W,w){if(0<T)return-1;let X;if(0>T)X=-T-1;else{if(W===0)return-1;W--,w=$.__digit(W),X=29}let U=1<<X;if((w&U)==0)return-1;if(U-=1,(w&U)!=0)return 1;for(;0<W;)if(W--,$.__digit(W)!==0)return 1;return 0}static __fromDouble($){A.__kBitConversionDouble[0]=$;let T=2047&A.__kBitConversionInts[A.__kBitConversionIntHigh]>>>20,W=T-1023,w=(0|W/30)+1,X=new A(w,0>$),U=1048575&A.__kBitConversionInts[A.__kBitConversionIntHigh]|1048576,Y=A.__kBitConversionInts[A.__kBitConversionIntLow],G=20,H=W%30,z,F=0;if(H<20){let O=G-H;F=O+32,z=U>>>O,U=U<<32-O|Y>>>O,Y<<=32-O}else if(H===20)F=32,z=U,U=Y,Y=0;else{let O=H-G;F=32-O,z=U<<O|Y>>>32-O,U=Y<<O,Y=0}X.__setDigit(w-1,z);for(let O=w-2;0<=O;O--)0<F?(F-=30,z=U>>>2,U=U<<30|Y>>>2,Y<<=30):z=0,X.__setDigit(O,z);return X.__trim()}static __isWhitespace($){return 13>=$&&9<=$||(159>=$?$==32:131071>=$?$==160||$==5760:196607>=$?($&=131071,10>=$||$==40||$==41||$==47||$==95||$==4096):$==65279)}static __fromString($,T=0){let W=0,w=$.length,X=0;if(X===w)return A.__zero();let U=$.charCodeAt(X);for(;A.__isWhitespace(U);){if(++X===w)return A.__zero();U=$.charCodeAt(X)}if(U===43){if(++X===w)return null;U=$.charCodeAt(X),W=1}else if(U===45){if(++X===w)return null;U=$.charCodeAt(X),W=-1}if(T===0){if(T=10,U===48){if(++X===w)return A.__zero();if(U=$.charCodeAt(X),U===88||U===120){if(T=16,++X===w)return null;U=$.charCodeAt(X)}else if(U===79||U===111){if(T=8,++X===w)return null;U=$.charCodeAt(X)}else if(U===66||U===98){if(T=2,++X===w)return null;U=$.charCodeAt(X)}}}else if(T===16&&U===48){if(++X===w)return A.__zero();if(U=$.charCodeAt(X),U===88||U===120){if(++X===w)return null;U=$.charCodeAt(X)}}if(W!=0&&T!==10)return null;for(;U===48;){if(++X===w)return A.__zero();U=$.charCodeAt(X)}let Y=w-X,G=A.__kMaxBitsPerChar[T],H=A.__kBitsPerCharTableMultiplier-1;if(Y>1073741824/G)return null;let z=G*Y+H>>>A.__kBitsPerCharTableShift,F=new A(0|(z+29)/30,!1),O=10>T?T:10,Q=10<T?T-10:0;if((T&T-1)==0){G>>=A.__kBitsPerCharTableShift;let Z=[],K=[],E=!1;do{let M=0,L=0;for(;;){let R;if(U-48>>>0<O)R=U-48;else if((32|U)-97>>>0<Q)R=(32|U)-87;else{E=!0;break}if(L+=G,M=M<<G|R,++X===w){E=!0;break}if(U=$.charCodeAt(X),30<L+G)break}Z.push(M),K.push(L)}while(!E);A.__fillFromParts(F,Z,K)}else{F.__initializeDigits();let Z=!1,K=0;do{let E=0,M=1;for(;;){let R;if(U-48>>>0<O)R=U-48;else if((32|U)-97>>>0<Q)R=(32|U)-87;else{Z=!0;break}let _=M*T;if(1073741823<_)break;if(M=_,E=E*T+R,K++,++X===w){Z=!0;break}U=$.charCodeAt(X)}H=30*A.__kBitsPerCharTableMultiplier-1;let L=0|(G*K+H>>>A.__kBitsPerCharTableShift)/30;F.__inplaceMultiplyAdd(M,E,L)}while(!Z)}if(X!==w){if(!A.__isWhitespace(U))return null;for(X++;X<w;X++)if(U=$.charCodeAt(X),!A.__isWhitespace(U))return null}return F.sign=W==-1,F.__trim()}static __fillFromParts($,T,W){let w=0,X=0,U=0;for(let Y=T.length-1;0<=Y;Y--){let G=T[Y],H=W[Y];X|=G<<U,U+=H,U===30?($.__setDigit(w++,X),U=0,X=0):30<U&&($.__setDigit(w++,1073741823&X),U-=30,X=G>>>H-U)}if(X!==0){if(w>=$.length)throw new Error("implementation bug");$.__setDigit(w++,X)}for(;w<$.length;w++)$.__setDigit(w,0)}static __toStringBasePowerOfTwo($,T){let W=$.length,w=T-1;w=(85&w>>>1)+(85&w),w=(51&w>>>2)+(51&w),w=(15&w>>>4)+(15&w);let X=w,U=T-1,Y=$.__digit(W-1),G=A.__clz30(Y),H=0|(30*W-G+X-1)/X;if($.sign&&H++,268435456<H)throw new Error("string too long");let z=Array(H),F=H-1,O=0,Q=0;for(let K=0;K<W-1;K++){let E=$.__digit(K),M=(O|E<<Q)&U;z[F--]=A.__kConversionChars[M];let L=X-Q;for(O=E>>>L,Q=30-L;Q>=X;)z[F--]=A.__kConversionChars[O&U],O>>>=X,Q-=X}let Z=(O|Y<<Q)&U;for(z[F--]=A.__kConversionChars[Z],O=Y>>>X-Q;O!==0;)z[F--]=A.__kConversionChars[O&U],O>>>=X;if($.sign&&(z[F--]="-"),F!=-1)throw new Error("implementation bug");return z.join("")}static __toStringGeneric($,T,W){let w=$.length;if(w===0)return"";if(w===1){let K=$.__unsignedDigit(0).toString(T);return W===!1&&$.sign&&(K="-"+K),K}let X=30*w-A.__clz30($.__digit(w-1)),U=A.__kMaxBitsPerChar[T],Y=U-1,G=X*A.__kBitsPerCharTableMultiplier;G+=Y-1,G=0|G/Y;let H=G+1>>1,z=A.exponentiate(A.__oneDigit(T,!1),A.__oneDigit(H,!1)),F,O,Q=z.__unsignedDigit(0);if(z.length===1&&32767>=Q){F=new A($.length,!1),F.__initializeDigits();let K=0;for(let E=2*$.length-1;0<=E;E--){let M=K<<15|$.__halfDigit(E);F.__setHalfDigit(E,0|M/Q),K=0|M%Q}O=K.toString(T)}else{let K=A.__absoluteDivLarge($,z,!0,!0);F=K.quotient;let E=K.remainder.__trim();O=A.__toStringGeneric(E,T,!0)}F.__trim();let Z=A.__toStringGeneric(F,T,!0);for(;O.length<H;)O="0"+O;return W===!1&&$.sign&&(Z="-"+Z),Z+O}static __unequalSign($){return $?-1:1}static __absoluteGreater($){return $?-1:1}static __absoluteLess($){return $?1:-1}static __compareToBigInt($,T){let W=$.sign;if(W!==T.sign)return A.__unequalSign(W);let w=A.__absoluteCompare($,T);return 0<w?A.__absoluteGreater(W):0>w?A.__absoluteLess(W):0}static __compareToNumber($,T){if(A.__isOneDigitInt(T)){let W=$.sign,w=0>T;if(W!==w)return A.__unequalSign(W);if($.length===0){if(w)throw new Error("implementation bug");return T===0?0:-1}if(1<$.length)return A.__absoluteGreater(W);let X=Math.abs(T),U=$.__unsignedDigit(0);return U>X?A.__absoluteGreater(W):U<X?A.__absoluteLess(W):0}return A.__compareToDouble($,T)}static __compareToDouble($,T){if(T!==T)return T;if(T===1/0)return-1;if(T===-1/0)return 1;let W=$.sign;if(W!==0>T)return A.__unequalSign(W);if(T===0)throw new Error("implementation bug: should be handled elsewhere");if($.length===0)return-1;A.__kBitConversionDouble[0]=T;let w=2047&A.__kBitConversionInts[A.__kBitConversionIntHigh]>>>20;if(w==2047)throw new Error("implementation bug: handled elsewhere");let X=w-1023;if(0>X)return A.__absoluteGreater(W);let U=$.length,Y=$.__digit(U-1),G=A.__clz30(Y),H=30*U-G,z=X+1;if(H<z)return A.__absoluteLess(W);if(H>z)return A.__absoluteGreater(W);let F=1048576|1048575&A.__kBitConversionInts[A.__kBitConversionIntHigh],O=A.__kBitConversionInts[A.__kBitConversionIntLow],Q=20,Z=29-G;if(Z!==(0|(H-1)%30))throw new Error("implementation bug");let K,E=0;if(20>Z){let M=Q-Z;E=M+32,K=F>>>M,F=F<<32-M|O>>>M,O<<=32-M}else if(Z===20)E=32,K=F,F=O,O=0;else{let M=Z-Q;E=32-M,K=F<<M|O>>>32-M,F=O<<M,O=0}if(Y>>>=0,K>>>=0,Y>K)return A.__absoluteGreater(W);if(Y<K)return A.__absoluteLess(W);for(let M=U-2;0<=M;M--){0<E?(E-=30,K=F>>>2,F=F<<30|O>>>2,O<<=30):K=0;let L=$.__unsignedDigit(M);if(L>K)return A.__absoluteGreater(W);if(L<K)return A.__absoluteLess(W)}if(F!==0||O!==0){if(E===0)throw new Error("implementation bug");return A.__absoluteLess(W)}return 0}static __equalToNumber($,T){var W=Math.abs;return A.__isOneDigitInt(T)?T===0?$.length===0:$.length===1&&$.sign===0>T&&$.__unsignedDigit(0)===W(T):A.__compareToDouble($,T)===0}static __comparisonResultToBool($,T){return T===0?0>$:T===1?0>=$:T===2?0<$:T===3?0<=$:void 0}static __compare($,T,W){if($=A.__toPrimitive($),T=A.__toPrimitive(T),typeof $=="string"&&typeof T=="string")switch(W){case 0:return $<T;case 1:return $<=T;case 2:return $>T;case 3:return $>=T}if(A.__isBigInt($)&&typeof T=="string")return T=A.__fromString(T),T!==null&&A.__comparisonResultToBool(A.__compareToBigInt($,T),W);if(typeof $=="string"&&A.__isBigInt(T))return $=A.__fromString($),$!==null&&A.__comparisonResultToBool(A.__compareToBigInt($,T),W);if($=A.__toNumeric($),T=A.__toNumeric(T),A.__isBigInt($)){if(A.__isBigInt(T))return A.__comparisonResultToBool(A.__compareToBigInt($,T),W);if(typeof T!="number")throw new Error("implementation bug");return A.__comparisonResultToBool(A.__compareToNumber($,T),W)}if(typeof $!="number")throw new Error("implementation bug");if(A.__isBigInt(T))return A.__comparisonResultToBool(A.__compareToNumber(T,$),2^W);if(typeof T!="number")throw new Error("implementation bug");return W===0?$<T:W===1?$<=T:W===2?$>T:W===3?$>=T:void 0}__clzmsd(){return A.__clz30(this.__digit(this.length-1))}static __absoluteAdd($,T,W){if($.length<T.length)return A.__absoluteAdd(T,$,W);if($.length===0)return $;if(T.length===0)return $.sign===W?$:A.unaryMinus($);let w=$.length;($.__clzmsd()===0||T.length===$.length&&T.__clzmsd()===0)&&w++;let X=new A(w,W),U=0,Y=0;for(;Y<T.length;Y++){let G=$.__digit(Y)+T.__digit(Y)+U;U=G>>>30,X.__setDigit(Y,1073741823&G)}for(;Y<$.length;Y++){let G=$.__digit(Y)+U;U=G>>>30,X.__setDigit(Y,1073741823&G)}return Y<X.length&&X.__setDigit(Y,U),X.__trim()}static __absoluteSub($,T,W){if($.length===0)return $;if(T.length===0)return $.sign===W?$:A.unaryMinus($);let w=new A($.length,W),X=0,U=0;for(;U<T.length;U++){let Y=$.__digit(U)-T.__digit(U)-X;X=1&Y>>>30,w.__setDigit(U,1073741823&Y)}for(;U<$.length;U++){let Y=$.__digit(U)-X;X=1&Y>>>30,w.__setDigit(U,1073741823&Y)}return w.__trim()}static __absoluteAddOne($,T,W=null){let w=$.length;W===null?W=new A(w,T):W.sign=T;let X=1;for(let U=0;U<w;U++){let Y=$.__digit(U)+X;X=Y>>>30,W.__setDigit(U,1073741823&Y)}return X!=0&&W.__setDigitGrow(w,1),W}static __absoluteSubOne($,T){let W=$.length;T=T||W;let w=new A(T,!1),X=1;for(let U=0;U<W;U++){let Y=$.__digit(U)-X;X=1&Y>>>30,w.__setDigit(U,1073741823&Y)}if(X!=0)throw new Error("implementation bug");for(let U=W;U<T;U++)w.__setDigit(U,0);return w}static __absoluteAnd($,T,W=null){let w=$.length,X=T.length,U=X;if(w<X){U=w;let H=$,z=w;$=T,w=X,T=H,X=z}let Y=U;W===null?W=new A(Y,!1):Y=W.length;let G=0;for(;G<U;G++)W.__setDigit(G,$.__digit(G)&T.__digit(G));for(;G<Y;G++)W.__setDigit(G,0);return W}static __absoluteAndNot($,T,W=null){let w=$.length,X=T.length,U=X;w<X&&(U=w);let Y=w;W===null?W=new A(Y,!1):Y=W.length;let G=0;for(;G<U;G++)W.__setDigit(G,$.__digit(G)&~T.__digit(G));for(;G<w;G++)W.__setDigit(G,$.__digit(G));for(;G<Y;G++)W.__setDigit(G,0);return W}static __absoluteOr($,T,W=null){let w=$.length,X=T.length,U=X;if(w<X){U=w;let H=$,z=w;$=T,w=X,T=H,X=z}let Y=w;W===null?W=new A(Y,!1):Y=W.length;let G=0;for(;G<U;G++)W.__setDigit(G,$.__digit(G)|T.__digit(G));for(;G<w;G++)W.__setDigit(G,$.__digit(G));for(;G<Y;G++)W.__setDigit(G,0);return W}static __absoluteXor($,T,W=null){let w=$.length,X=T.length,U=X;if(w<X){U=w;let H=$,z=w;$=T,w=X,T=H,X=z}let Y=w;W===null?W=new A(Y,!1):Y=W.length;let G=0;for(;G<U;G++)W.__setDigit(G,$.__digit(G)^T.__digit(G));for(;G<w;G++)W.__setDigit(G,$.__digit(G));for(;G<Y;G++)W.__setDigit(G,0);return W}static __absoluteCompare($,T){let W=$.length-T.length;if(W!=0)return W;let w=$.length-1;for(;0<=w&&$.__digit(w)===T.__digit(w);)w--;return 0>w?0:$.__unsignedDigit(w)>T.__unsignedDigit(w)?1:-1}static __multiplyAccumulate($,T,W,w){if(T===0)return;let X=32767&T,U=T>>>15,Y=0,G=0;for(let H,z=0;z<$.length;z++,w++){H=W.__digit(w);let F=$.__digit(z),O=32767&F,Q=F>>>15,Z=A.__imul(O,X),K=A.__imul(O,U),E=A.__imul(Q,X),M=A.__imul(Q,U);H+=G+Z+Y,Y=H>>>30,H&=1073741823,H+=((32767&K)<<15)+((32767&E)<<15),Y+=H>>>30,G=M+(K>>>15)+(E>>>15),W.__setDigit(w,1073741823&H)}for(;Y!=0||G!==0;w++){let H=W.__digit(w);H+=Y+G,G=0,Y=H>>>30,W.__setDigit(w,1073741823&H)}}static __internalMultiplyAdd($,T,W,w,X){let U=W,Y=0;for(let G=0;G<w;G++){let H=$.__digit(G),z=A.__imul(32767&H,T),F=A.__imul(H>>>15,T),O=z+((32767&F)<<15)+Y+U;U=O>>>30,Y=F>>>15,X.__setDigit(G,1073741823&O)}if(X.length>w)for(X.__setDigit(w++,U+Y);w<X.length;)X.__setDigit(w++,0);else if(U+Y!==0)throw new Error("implementation bug")}__inplaceMultiplyAdd($,T,W){W>this.length&&(W=this.length);let w=32767&$,X=$>>>15,U=0,Y=T;for(let G=0;G<W;G++){let H=this.__digit(G),z=32767&H,F=H>>>15,O=A.__imul(z,w),Q=A.__imul(z,X),Z=A.__imul(F,w),K=A.__imul(F,X),E=Y+O+U;U=E>>>30,E&=1073741823,E+=((32767&Q)<<15)+((32767&Z)<<15),U+=E>>>30,Y=K+(Q>>>15)+(Z>>>15),this.__setDigit(G,1073741823&E)}if(U!=0||Y!==0)throw new Error("implementation bug")}static __absoluteDivSmall($,T,W=null){W===null&&(W=new A($.length,!1));let w=0;for(let X,U=2*$.length-1;0<=U;U-=2){X=(w<<15|$.__halfDigit(U))>>>0;let Y=0|X/T;w=0|X%T,X=(w<<15|$.__halfDigit(U-1))>>>0;let G=0|X/T;w=0|X%T,W.__setDigit(U>>>1,Y<<15|G)}return W}static __absoluteModSmall($,T){let W=0;for(let w=2*$.length-1;0<=w;w--)W=0|((W<<15|$.__halfDigit(w))>>>0)%T;return W}static __absoluteDivLarge($,T,W,w){let X=T.__halfDigitLength(),U=T.length,Y=$.__halfDigitLength()-X,G=null;W&&(G=new A(Y+2>>>1,!1),G.__initializeDigits());let H=new A(X+2>>>1,!1);H.__initializeDigits();let z=A.__clz15(T.__halfDigit(X-1));0<z&&(T=A.__specialLeftShift(T,z,0));let F=A.__specialLeftShift($,z,1),O=T.__halfDigit(X-1),Q=0;for(let Z,K=Y;0<=K;K--){Z=32767;let E=F.__halfDigit(K+X);if(E!==O){let L=(E<<15|F.__halfDigit(K+X-1))>>>0;Z=0|L/O;let R=0|L%O,_=T.__halfDigit(X-2),S=F.__halfDigit(K+X-2);for(;A.__imul(Z,_)>>>0>(R<<16|S)>>>0&&(Z--,R+=O,!(32767<R)););}A.__internalMultiplyAdd(T,Z,0,U,H);let M=F.__inplaceSub(H,K,X+1);M!==0&&(M=F.__inplaceAdd(T,K,X),F.__setHalfDigit(K+X,32767&F.__halfDigit(K+X)+M),Z--),W&&(1&K?Q=Z<<15:G.__setDigit(K>>>1,Q|Z))}if(w)return F.__inplaceRightShift(z),W?{quotient:G,remainder:F}:F;if(W)return G;throw new Error("unreachable")}static __clz15($){return A.__clz30($)-15}__inplaceAdd($,T,W){let w=0;for(let X=0;X<W;X++){let U=this.__halfDigit(T+X)+$.__halfDigit(X)+w;w=U>>>15,this.__setHalfDigit(T+X,32767&U)}return w}__inplaceSub($,T,W){let w=0;if(1&T){T>>=1;let X=this.__digit(T),U=32767&X,Y=0;for(;Y<W-1>>>1;Y++){let z=$.__digit(Y),F=(X>>>15)-(32767&z)-w;w=1&F>>>15,this.__setDigit(T+Y,(32767&F)<<15|32767&U),X=this.__digit(T+Y+1),U=(32767&X)-(z>>>15)-w,w=1&U>>>15}let G=$.__digit(Y),H=(X>>>15)-(32767&G)-w;if(w=1&H>>>15,this.__setDigit(T+Y,(32767&H)<<15|32767&U),T+Y+1>=this.length)throw new RangeError("out of bounds");(1&W)==0&&(X=this.__digit(T+Y+1),U=(32767&X)-(G>>>15)-w,w=1&U>>>15,this.__setDigit(T+$.length,1073709056&X|32767&U))}else{T>>=1;let X=0;for(;X<$.length-1;X++){let z=this.__digit(T+X),F=$.__digit(X),O=(32767&z)-(32767&F)-w;w=1&O>>>15;let Q=(z>>>15)-(F>>>15)-w;w=1&Q>>>15,this.__setDigit(T+X,(32767&Q)<<15|32767&O)}let U=this.__digit(T+X),Y=$.__digit(X),G=(32767&U)-(32767&Y)-w;w=1&G>>>15;let H=0;(1&W)==0&&(H=(U>>>15)-(Y>>>15)-w,w=1&H>>>15),this.__setDigit(T+X,(32767&H)<<15|32767&G)}return w}__inplaceRightShift($){if($===0)return;let T=this.__digit(0)>>>$,W=this.length-1;for(let w=0;w<W;w++){let X=this.__digit(w+1);this.__setDigit(w,1073741823&X<<30-$|T),T=X>>>$}this.__setDigit(W,T)}static __specialLeftShift($,T,W){let w=$.length,X=new A(w+W,!1);if(T===0){for(let Y=0;Y<w;Y++)X.__setDigit(Y,$.__digit(Y));return 0<W&&X.__setDigit(w,0),X}let U=0;for(let Y=0;Y<w;Y++){let G=$.__digit(Y);X.__setDigit(Y,1073741823&G<<T|U),U=G>>>30-T}return 0<W&&X.__setDigit(w,U),X}static __leftShiftByAbsolute($,T){let W=A.__toShiftAmount(T);if(0>W)throw new RangeError("BigInt too big");let w=0|W/30,X=W%30,U=$.length,Y=X!==0&&$.__digit(U-1)>>>30-X!=0,G=U+w+(Y?1:0),H=new A(G,$.sign);if(X===0){let z=0;for(;z<w;z++)H.__setDigit(z,0);for(;z<G;z++)H.__setDigit(z,$.__digit(z-w))}else{let z=0;for(let F=0;F<w;F++)H.__setDigit(F,0);for(let F=0;F<U;F++){let O=$.__digit(F);H.__setDigit(F+w,1073741823&O<<X|z),z=O>>>30-X}if(Y)H.__setDigit(U+w,z);else if(z!==0)throw new Error("implementation bug")}return H.__trim()}static __rightShiftByAbsolute($,T){let{length:W,sign:w}=$,X=A.__toShiftAmount(T);if(0>X)return A.__rightShiftByMaximum(w);let U=0|X/30,Y=X%30,G=W-U;if(0>=G)return A.__rightShiftByMaximum(w);let H=!1;if(w){if(($.__digit(U)&(1<<Y)-1)!=0)H=!0;else for(let F=0;F<U;F++)if($.__digit(F)!==0){H=!0;break}}if(H&&Y===0)~$.__digit(W-1)==0&&G++;let z=new A(G,w);if(Y===0){z.__setDigit(G-1,0);for(let F=U;F<W;F++)z.__setDigit(F-U,$.__digit(F))}else{let F=$.__digit(U)>>>Y,O=W-U-1;for(let Q=0;Q<O;Q++){let Z=$.__digit(Q+U+1);z.__setDigit(Q,1073741823&Z<<30-Y|F),F=Z>>>Y}z.__setDigit(O,F)}return H&&(z=A.__absoluteAddOne(z,!0,z)),z.__trim()}static __rightShiftByMaximum($){return $?A.__oneDigit(1,!0):A.__zero()}static __toShiftAmount($){if(1<$.length)return-1;let T=$.__unsignedDigit(0);return T>A.__kMaxLengthBits?-1:T}static __toPrimitive($,T="default"){if(typeof $!="object")return $;if($.constructor===A)return $;if(typeof Symbol!="undefined"&&typeof Symbol.toPrimitive=="symbol"&&$[Symbol.toPrimitive]){let X=$[Symbol.toPrimitive](T);if(typeof X!="object")return X;throw new TypeError("Cannot convert object to primitive value")}let W=$.valueOf;if(W){let X=W.call($);if(typeof X!="object")return X}let w=$.toString;if(w){let X=w.call($);if(typeof X!="object")return X}throw new TypeError("Cannot convert object to primitive value")}static __toNumeric($){return A.__isBigInt($)?$:+$}static __isBigInt($){return typeof $=="object"&&$!==null&&$.constructor===A}static __truncateToNBits($,T){let W=0|($+29)/30,w=new A(W,T.sign),X=W-1;for(let Y=0;Y<X;Y++)w.__setDigit(Y,T.__digit(Y));let U=T.__digit(X);if($%30!=0){let Y=32-$%30;U=U<<Y>>>Y}return w.__setDigit(X,U),w.__trim()}static __truncateAndSubFromPowerOfTwo($,T,W){var w=Math.min;let X=0|($+29)/30,U=new A(X,W),Y=0,G=X-1,H=0;for(let Q=w(G,T.length);Y<Q;Y++){let Z=0-T.__digit(Y)-H;H=1&Z>>>30,U.__setDigit(Y,1073741823&Z)}for(;Y<G;Y++)U.__setDigit(Y,0|1073741823&-H);let z=G<T.length?T.__digit(G):0,F=$%30,O;if(F==0)O=0-z-H,O&=1073741823;else{let Q=32-F;z=z<<Q>>>Q;let Z=1<<32-Q;O=Z-z-H,O&=Z-1}return U.__setDigit(G,O),U.__trim()}__digit($){return this[$]}__unsignedDigit($){return this[$]>>>0}__setDigit($,T){this[$]=0|T}__setDigitGrow($,T){this[$]=0|T}__halfDigitLength(){let $=this.length;return 32767>=this.__unsignedDigit($-1)?2*$-1:2*$}__halfDigit($){return 32767&this[$>>>1]>>>15*(1&$)}__setHalfDigit($,T){let W=$>>>1,w=this.__digit(W),X=1&$?32767&w|T<<15:1073709056&w|32767&T;this.__setDigit(W,X)}static __digitPow($,T){let W=1;for(;0<T;)1&T&&(W*=$),T>>>=1,$*=$;return W}static __detectBigEndian(){return A.__kBitConversionDouble[0]=-0,A.__kBitConversionInts[0]!==0}static __isOneDigitInt($){return(1073741823&$)===$}}A.__kMaxLength=33554432,A.__kMaxLengthBits=A.__kMaxLength<<5,A.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],A.__kBitsPerCharTableShift=5,A.__kBitsPerCharTableMultiplier=1<<A.__kBitsPerCharTableShift,A.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],A.__kBitConversionBuffer=new ArrayBuffer(8),A.__kBitConversionDouble=new Float64Array(A.__kBitConversionBuffer),A.__kBitConversionInts=new Int32Array(A.__kBitConversionBuffer),A.__kBitConversionIntHigh=A.__detectBigEndian()?0:1,A.__kBitConversionIntLow=A.__detectBigEndian()?1:0,A.__clz30=Math.clz32?function($){return Math.clz32($)-2}:function($){return $===0?30:0|29-(0|Math.log($>>>0)/Math.LN2)},A.__imul=Math.imul||function($,T){return 0|$*T};var P=A;var U1=P.BigInt(0),vw=P.BigInt(1),MO=P.BigInt(2),uj=P.BigInt(10),pj=P.BigInt(24),dj=P.BigInt(60),oj=P.BigInt(1000),fw=P.BigInt(1e6),Nw=P.BigInt(1e9),$M=P.multiply(P.BigInt(3600),Nw),lj=P.multiply(dj,Nw),NT=P.multiply($M,pj);function k0($){return typeof $=="bigint"?P.BigInt($.toString(10)):$}function TM($){return P.equal(P.remainder($,MO),U1)}function OW($){return P.lessThan($,U1)?P.unaryMinus($):$}function BG($,T){return P.lessThan($,T)?-1:P.greaterThan($,T)?1:0}function Qw($,T){return{quotient:P.divide($,T),remainder:P.remainder($,T)}}var NE,LE,Z$="slot-epochNanoSeconds",V$="slot-iso-date",X4="slot-iso-date-time",O4="slot-time",u="slot-calendar",WM="slot-date-brand",XM="slot-year-month-brand",wM="slot-month-day-brand",y$="slot-time-zone",Z6="slot-years",V6="slot-months",f6="slot-weeks",K6="slot-days",A6="slot-hours",E6="slot-minutes",M6="slot-seconds",D6="slot-milliseconds",N6="slot-microseconds",b6="slot-nanoseconds",UM="date",YM="ym",GM="md",zM="time",HM="datetime",FM="instant",LW="original",_2="timezone-canonical",sF="timezone-original",Zw="calendar-id",OM="locale",eF="options",QM=new WeakMap,$O=Symbol.for("@@Temporal__GetSlots");(NE=globalThis)[$O]||(NE[$O]=function($){return QM.get($)});var oG=globalThis[$O],TO=Symbol.for("@@Temporal__CreateSlots");(LE=globalThis)[TO]||(LE[TO]=function($){QM.set($,Object.create(null))});var f0=globalThis[TO];function k6($,...T){if(!$||typeof $!="object")return!1;let W=oG($);return!!W&&T.every((w)=>(w in W))}function V($,T){let W=oG($)?.[T];if(W===void 0)throw new TypeError(`Missing internal slot ${T}`);return W}function _$($,T,W){let w=oG($);if(w===void 0)throw new TypeError("Missing slots for the given container");if(w[T])throw new TypeError(`${T} already has set`);w[T]=W}var WO={};function b0($,T){Object.defineProperty($.prototype,Symbol.toStringTag,{value:T,writable:!1,enumerable:!1,configurable:!0});let W=Object.getOwnPropertyNames($);for(let X=0;X<W.length;X++){let U=W[X],Y=Object.getOwnPropertyDescriptor($,U);Y.configurable&&Y.enumerable&&(Y.enumerable=!1,Object.defineProperty($,U,Y))}let w=Object.getOwnPropertyNames($.prototype);for(let X=0;X<w.length;X++){let U=w[X],Y=Object.getOwnPropertyDescriptor($.prototype,U);Y.configurable&&Y.enumerable&&(Y.enumerable=!1,Object.defineProperty($.prototype,U,Y))}XO(T,$),XO(`${T}.prototype`,$.prototype)}function XO($,T){let W=`%${$}%`;if(WO[W]!==void 0)throw new Error(`intrinsic ${$} already exists`);WO[W]=T}function i4($){return WO[$]}function v2($,T){let W=$;if(W===0)return{div:W,mod:W};let w=Math.sign(W);W=Math.abs(W);let X=Math.trunc(1+Math.log10(W));if(T>=X)return{div:0*w,mod:w*W};if(T===0)return{div:w*W,mod:0*w};let U=W.toPrecision(X);return{div:w*Number.parseInt(U.slice(0,X-T),10),mod:w*Number.parseInt(U.slice(X-T),10)}}function rF($,T,W){let w=$,X=W;if(w===0)return X;let U=Math.sign(w)||Math.sign(X);w=Math.abs(w),X=Math.abs(X);let Y=w.toPrecision(Math.trunc(1+Math.log10(w)));if(X===0)return U*Number.parseInt(Y+"0".repeat(T),10);let G=Y+X.toPrecision(Math.trunc(1+Math.log10(X))).padStart(T,"0");return U*Number.parseInt(G,10)}function lG($,T){let W=T==="negative";switch($){case"ceil":return W?"zero":"infinity";case"floor":return W?"infinity":"zero";case"expand":return"infinity";case"trunc":return"zero";case"halfCeil":return W?"half-zero":"half-infinity";case"halfFloor":return W?"half-infinity":"half-zero";case"halfExpand":return"half-infinity";case"halfTrunc":return"half-zero";case"halfEven":return"half-even"}}function rG($,T,W,w,X){return X==="zero"?$:X==="infinity"?T:W<0?$:W>0?T:X==="half-zero"?$:X==="half-infinity"?T:w?$:T}class q${constructor($){this.totalNs=k0($),this.sec=P.toNumber(P.divide(this.totalNs,Nw)),this.subsec=P.toNumber(P.remainder(this.totalNs,Nw))}static validateNew($,T){if(P.greaterThan(OW($),q$.MAX))throw new RangeError(`${T} of duration time units cannot exceed ${q$.MAX} s`);return new q$($)}static fromEpochNsDiff($,T){let W=P.subtract(k0($),k0(T));return new q$(W)}static fromComponents($,T,W,w,X,U){let Y=P.add(P.add(P.add(P.add(P.add(P.BigInt(U),P.multiply(P.BigInt(X),oj)),P.multiply(P.BigInt(w),fw)),P.multiply(P.BigInt(W),Nw)),P.multiply(P.BigInt(T),lj)),P.multiply(P.BigInt($),$M));return q$.validateNew(Y,"total")}abs(){return new q$(OW(this.totalNs))}add($){return q$.validateNew(P.add(this.totalNs,$.totalNs),"sum")}add24HourDays($){return q$.validateNew(P.add(this.totalNs,P.multiply(P.BigInt($),NT)),"sum")}addToEpochNs($){return P.add(k0($),this.totalNs)}cmp($){return BG(this.totalNs,$.totalNs)}divmod($){let{quotient:T,remainder:W}=Qw(this.totalNs,P.BigInt($));return{quotient:P.toNumber(T),remainder:new q$(W)}}fdiv($){let T=k0($),W=P.BigInt(T),{quotient:w,remainder:X}=Qw(this.totalNs,W),U=[],Y,G=(P.lessThan(this.totalNs,U1)?-1:1)*Math.sign(P.toNumber(T));for(;!P.equal(X,U1)&&U.length<50;)X=P.multiply(X,uj),{quotient:Y,remainder:X}=Qw(X,W),U.push(Math.abs(P.toNumber(Y)));return G*Number(OW(w).toString()+"."+U.join(""))}isZero(){return P.equal(this.totalNs,U1)}round($,T){let W=k0($);if(P.equal(W,vw))return this;let{quotient:w,remainder:X}=Qw(this.totalNs,W),U=P.lessThan(this.totalNs,U1)?"negative":"positive",Y=P.multiply(OW(w),W),G=P.add(Y,W),H=BG(OW(P.multiply(X,MO)),W),z=lG(T,U),F=P.equal(OW(this.totalNs),Y)?Y:rG(Y,G,H,TM(w),z),O=U==="positive"?F:P.unaryMinus(F);return q$.validateNew(O,"rounding")}sign(){return this.cmp(new q$(U1))}subtract($){return q$.validateNew(P.subtract(this.totalNs,$.totalNs),"difference")}}q$.MAX=P.BigInt("9007199254740991999999999"),q$.ZERO=new q$(U1);var JE=/[A-Za-z._][A-Za-z._0-9+-]*/,bw=new RegExp(`(?:${/(?:[+-](?:[01][0-9]|2[0-3])(?::?[0-5][0-9])?)/.source}|(?:${JE.source})(?:\\/(?:${JE.source}))*)`),ZM=/(?:[+-]\d{6}|\d{4})/,xG=/(?:0[1-9]|1[0-2])/,wO=/(?:0[1-9]|[12]\d|3[01])/,rj=new RegExp(`(${ZM.source})(?:-(${xG.source})-(${wO.source})|(${xG.source})(${wO.source}))`),VM=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,KM=/((?:[+-])(?:[01][0-9]|2[0-3])(?::?(?:[0-5][0-9])(?::?(?:[0-5][0-9])(?:[.,](?:\d{1,9}))?)?)?)/,AM=new RegExp(`([zZ])|${KM.source}?`),S2=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,nj=new RegExp([`^${rj.source}`,`(?:(?:[tT]|\\s+)${VM.source}(?:${AM.source})?)?`,`(?:\\[!?(${bw.source})\\])?`,`((?:${S2.source})*)$`].join("")),ij=new RegExp([`^[tT]?${VM.source}`,`(?:${AM.source})?`,`(?:\\[!?${bw.source}\\])?`,`((?:${S2.source})*)$`].join("")),tj=new RegExp(`^(${ZM.source})-?(${xG.source})(?:\\[!?${bw.source}\\])?((?:${S2.source})*)$`),aj=new RegExp(`^(?:--)?(${xG.source})-?(${wO.source})(?:\\[!?${bw.source}\\])?((?:${S2.source})*)$`),nF=/(\d+)(?:[.,](\d{1,9}))?/,sj=new RegExp(`(?:${nF.source}H)?(?:${nF.source}M)?(?:${nF.source}S)?`),ej=new RegExp(`^([+-])?P${/(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/.source}(?:T(?!$)${sj.source})?$`,"i"),LT=86400000,fG=1e6*LT,$I=60000000000,EM=1e8*LT,j2=B1(EM),qw=P.unaryMinus(j2),TI=P.add(P.subtract(qw,NT),vw),WI=P.subtract(P.add(j2,NT),vw),XI=146097*LT,RE=-271821,_E=275760,Lw=Date.UTC(1847,0,1),wI=["iso8601","hebrew","islamic","islamic-umalqura","islamic-tbla","islamic-civil","islamic-rgsa","islamicc","persian","ethiopic","ethioaa","ethiopic-amete-alem","coptic","chinese","dangi","roc","indian","buddhist","japanese","gregory"],UI=new Set(["ACT","AET","AGT","ART","AST","BET","BST","CAT","CNT","CST","CTT","EAT","ECT","IET","IST","JST","MIT","NET","NST","PLT","PNT","PRT","PST","SST","VST"]);function Q4($){return typeof $=="object"&&$!==null||typeof $=="function"}function nG($){if(typeof $=="bigint")throw new TypeError("Cannot convert BigInt to number");return Number($)}function iG($){if(typeof $=="symbol")throw new TypeError("Cannot convert a Symbol value to a String");return String($)}function A$($){let T=nG($);if(T===0)return 0;if(Number.isNaN(T)||T===1/0||T===-1/0)throw new RangeError("invalid number value");let W=Math.trunc(T);return W===0?0:W}function kE($,T){let W=A$($);if(W<=0){if(T!==void 0)throw new RangeError(`property '${T}' cannot be a a number less than one`);throw new RangeError("Cannot convert a number less than one to a positive integer")}return W}function j1($){let T=nG($);if(Number.isNaN(T))throw new RangeError("not a number");if(T===1/0||T===-1/0)throw new RangeError("infinity is out of range");if(!function(W){if(typeof W!="number"||Number.isNaN(W)||W===1/0||W===-1/0)return!1;let w=Math.abs(W);return Math.floor(w)===w}(T))throw new RangeError(`unsupported fractional value ${$}`);return T===0?0:T}function Pw($,T){return String($).padStart(T,"0")}function I4($){if(typeof $!="string")throw new TypeError(`expected a string, not ${String($)}`);return $}function UO($,T){if(Q4($)){let W=$?.toString();if(typeof W=="string"||typeof W=="number")return W;throw new TypeError("Cannot convert object to primitive value")}return $}var YO=["era","eraYear","year","month","monthCode","day","hour","minute","second","millisecond","microsecond","nanosecond","offset","timeZone"],YI={era:iG,eraYear:A$,year:A$,month:kE,monthCode:function($){let T=I4(UO($));if(T.length<3||T.length>4||T[0]!=="M"||"0123456789".indexOf(T[1])===-1||"0123456789".indexOf(T[2])===-1||T[1]+T[2]==="00"&&T[3]!=="L"||T[3]!=="L"&&T[3]!==void 0)throw new RangeError(`bad month code ${T}; must match M01-M99 or M00L-M99L`);return T},day:kE,hour:A$,minute:A$,second:A$,millisecond:A$,microsecond:A$,nanosecond:A$,offset:function($){let T=I4(UO($));return u2(T),T},timeZone:R6},GI={hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},I2=[["years","year","date"],["months","month","date"],["weeks","week","date"],["days","day","date"],["hours","hour","time"],["minutes","minute","time"],["seconds","second","time"],["milliseconds","millisecond","time"],["microseconds","microsecond","time"],["nanoseconds","nanosecond","time"]],vE=Object.fromEntries(I2.map(($)=>[$[0],$[1]])),zI=Object.fromEntries(I2.map(([$,T])=>[T,$])),Jw=I2.map(([,$])=>$),B2={day:fG,hour:3600000000000,minute:60000000000,second:1e9,millisecond:1e6,microsecond:1000,nanosecond:1},bG=["days","hours","microseconds","milliseconds","minutes","months","nanoseconds","seconds","weeks","years"],HI=Intl.DateTimeFormat,qE=new Map;function MM($){let T=Bw($),W=qE.get(T);return W===void 0&&(W=new HI("en-us",{timeZone:T,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),qE.set(T,W)),W}function l4($){return k6($,Z$)&&!k6($,y$,u)}function H4($){return k6($,Z6,V6,K6,A6,E6,M6,D6,N6,b6)}function F4($){return k6($,WM)}function A4($){return k6($,O4)}function i$($){return k6($,X4)}function r4($){return k6($,XM)}function w1($){return k6($,wM)}function v$($){return k6($,Z$,y$,u)}function C($,T){if(!T($))throw new TypeError("invalid receiver: method called with the wrong type of this-object")}function g2($){if(k6($,u)||k6($,y$))throw new TypeError("with() does not support a calendar or timeZone property");if(A4($))throw new TypeError("with() does not accept Temporal.PlainTime, use withPlainTime() instead");if($.calendar!==void 0)throw new TypeError("with() does not support a calendar property");if($.timeZone!==void 0)throw new TypeError("with() does not support a timeZone property")}function yw($,T){return T==="never"||T==="auto"&&$==="iso8601"?"":`[${T==="critical"?"!":""}u-ca=${$}]`}function tG($){let T,W,w=!1;for(S2.lastIndex=0;W=S2.exec($);){let{1:X,2:U,3:Y}=W;if(U==="u-ca"){if(T===void 0)T=Y,w=X==="!";else if(X==="!"||w)throw new RangeError(`Invalid annotations in ${$}: more than one u-ca present with critical flag`)}else if(X==="!")throw new RangeError(`Unrecognized annotation: !${U}=${Y}`)}return T}function U0($){let T=nj.exec($);if(!T)throw new RangeError(`invalid RFC 9557 string: ${$}`);let W=tG(T[16]),w=T[1];if(w==="-000000")throw new RangeError(`invalid RFC 9557 string: ${$}`);let X=+w,U=+(T[2]??T[4]??1),Y=+(T[3]??T[5]??1),G=T[6]!==void 0,H=+(T[6]??0),z=+(T[7]??T[10]??0),F=+(T[8]??T[11]??0);F===60&&(F=59);let O=(T[9]??T[12]??"")+"000000000",Q=+O.slice(0,3),Z=+O.slice(3,6),K=+O.slice(6,9),E,M=!1;T[13]?(E=void 0,M=!0):T[14]&&(E=T[14]);let L=T[15];return _O(X,U,Y,H,z,F,Q,Z,K),{year:X,month:U,day:Y,time:G?{hour:H,minute:z,second:F,millisecond:Q,microsecond:Z,nanosecond:K}:"start-of-day",tzAnnotation:L,offset:E,z:M,calendar:W}}function DM($){let T=ij.exec($),W,w,X,U,Y,G,H;if(T){H=tG(T[10]),W=+(T[1]??0),w=+(T[2]??T[5]??0),X=+(T[3]??T[6]??0),X===60&&(X=59);let z=(T[4]??T[7]??"")+"000000000";if(U=+z.slice(0,3),Y=+z.slice(3,6),G=+z.slice(6,9),T[8])throw new RangeError("Z designator not supported for PlainTime")}else{let z,F;if({time:z,z:F,calendar:H}=U0($),z==="start-of-day")throw new RangeError(`time is missing in string: ${$}`);if(F)throw new RangeError("Z designator not supported for PlainTime");({hour:W,minute:w,second:X,millisecond:U,microsecond:Y,nanosecond:G}=z)}if($9(W,w,X,U,Y,G),/[tT ][0-9][0-9]/.test($))return{hour:W,minute:w,second:X,millisecond:U,microsecond:Y,nanosecond:G,calendar:H};try{let{month:z,day:F}=NO($);AW(1972,z,F)}catch{try{let{year:z,month:F}=DO($);AW(z,F,1)}catch{return{hour:W,minute:w,second:X,millisecond:U,microsecond:Y,nanosecond:G,calendar:H}}}throw new RangeError(`invalid RFC 9557 time-only string ${$}; may need a T prefix`)}function DO($){let T=tj.exec($),W,w,X,U;if(T){X=tG(T[3]);let Y=T[1];if(Y==="-000000")throw new RangeError(`invalid RFC 9557 string: ${$}`);if(W=+Y,w=+T[2],U=1,X!==void 0&&X!=="iso8601")throw new RangeError("YYYY-MM format is only valid with iso8601 calendar")}else{let Y;if({year:W,month:w,calendar:X,day:U,z:Y}=U0($),Y)throw new RangeError("Z designator not supported for PlainYearMonth")}return{year:W,month:w,calendar:X,referenceISODay:U}}function NO($){let T=aj.exec($),W,w,X,U;if(T){if(X=tG(T[3]),W=+T[1],w=+T[2],X!==void 0&&X!=="iso8601")throw new RangeError("MM-DD format is only valid with iso8601 calendar")}else{let Y;if({month:W,day:w,calendar:X,year:U,z:Y}=U0($),Y)throw new RangeError("Z designator not supported for PlainMonthDay")}return{month:W,day:w,calendar:X,referenceISOYear:U}}var NM=new RegExp(`^${bw.source}$`,"i"),LM=new RegExp(`^${/([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])?)?/.source}$`);function JM($){let T=OI.test($)?"Seconds not allowed in offset time zone":"Invalid time zone";throw new RangeError(`${T}: ${$}`)}function DT($){return NM.test($)||JM($),LM.test($)?{offsetMinutes:u2($)/60000000000}:{tzName:$}}function Rw($,T,W,w){let X=$,U=T,Y=W;switch(w){case"reject":AW(X,U,Y);break;case"constrain":({year:X,month:U,day:Y}=gM(X,U,Y))}return{year:X,month:U,day:Y}}function aG($,T,W,w,X,U,Y){let G=$,H=T,z=W,F=w,O=X,Q=U;switch(Y){case"reject":$9(G,H,z,F,O,Q);break;case"constrain":G=L6(G,0,23),H=L6(H,0,59),z=L6(z,0,59),F=L6(F,0,999),O=L6(O,0,999),Q=L6(Q,0,999)}return{hour:G,minute:H,second:z,millisecond:F,microsecond:O,nanosecond:Q}}function RM($){if(!Q4($))throw new TypeError("invalid duration-like");let T={years:void 0,months:void 0,weeks:void 0,days:void 0,hours:void 0,minutes:void 0,seconds:void 0,milliseconds:void 0,microseconds:void 0,nanoseconds:void 0},W=!1;for(let w=0;w<bG.length;w++){let X=bG[w],U=$[X];U!==void 0&&(W=!0,T[X]=j1(U))}if(!W)throw new TypeError("invalid duration-like");return T}function $6({years:$,months:T,weeks:W,days:w},X,U,Y){return{years:$,months:Y??T,weeks:U??W,days:X??w}}function x$($,T){return{isoDate:$,time:T}}function j$($){return I0($,"overflow",["constrain","reject"],"constrain")}function _w($){return I0($,"disambiguation",["compatible","earlier","later","reject"],"compatible")}function x1($,T){return I0($,"roundingMode",["ceil","floor","expand","trunc","halfCeil","halfFloor","halfExpand","halfTrunc","halfEven"],T)}function IG($,T){return I0($,"offset",["prefer","use","ignore","reject"],T)}function hw($){return I0($,"calendarName",["auto","always","never","critical"],"auto")}function m2($){let T=$.roundingIncrement;if(T===void 0)return 1;let W=A$(T);if(W<1||W>1e9)throw new RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${T}`);return W}function c2($,T,W){let w=W?T:T-1;if($>w)throw new RangeError(`roundingIncrement must be at least 1 and less than ${w}, not ${$}`);if(T%$!=0)throw new RangeError(`Rounding increment must divide evenly into ${T}`)}function gw($){let T=$.fractionalSecondDigits;if(T===void 0)return"auto";if(typeof T!="number"){if(iG(T)!=="auto")throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${T}`);return"auto"}let W=Math.floor(T);if(!Number.isFinite(W)||W<0||W>9)throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${T}`);return W}function mw($,T){switch($){case"minute":return{precision:"minute",unit:"minute",increment:1};case"second":return{precision:0,unit:"second",increment:1};case"millisecond":return{precision:3,unit:"millisecond",increment:1};case"microsecond":return{precision:6,unit:"microsecond",increment:1};case"nanosecond":return{precision:9,unit:"nanosecond",increment:1}}switch(T){case"auto":return{precision:T,unit:"nanosecond",increment:1};case 0:return{precision:T,unit:"second",increment:1};case 1:case 2:case 3:return{precision:T,unit:"millisecond",increment:10**(3-T)};case 4:case 5:case 6:return{precision:T,unit:"microsecond",increment:10**(6-T)};case 7:case 8:case 9:return{precision:T,unit:"nanosecond",increment:10**(9-T)};default:throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${T}`)}}var x0=Symbol("~required~");function h6($,T,W,w,X=[]){let U=[];for(let z=0;z<I2.length;z++){let F=I2[z],O=F[1],Q=F[2];W!=="datetime"&&W!==Q||U.push(O)}U=U.concat(X);let Y=w;Y===x0?Y=void 0:Y!==void 0&&U.push(Y);let G=[];G=G.concat(U);for(let z=0;z<U.length;z++){let F=U[z],O=zI[F];O!==void 0&&G.push(O)}let H=I0($,T,G,Y);if(H===void 0&&w===x0)throw new RangeError(`${T} is required`);return H&&H in vE?vE[H]:H}function iF($){let T=$.relativeTo;if(T===void 0)return{};let W,w,X,U,Y,G="option",H=!1;if(Q4(T)){if(v$(T))return{zonedRelativeTo:T};if(F4(T))return{plainRelativeTo:T};if(i$(T))return{plainRelativeTo:J6(V(T,X4).isoDate,V(T,u))};X=ow(T);let z=H1(X,T,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond","offset","timeZone"],[]);({isoDate:W,time:w}=uw(X,z,"constrain")),{offset:Y,timeZone:U}=z,Y===void 0&&(G="wall")}else{let z,F,O,Q,Z;if({year:O,month:Q,day:Z,time:w,calendar:X,tzAnnotation:z,offset:Y,z:F}=U0(I4(T)),z)U=R6(z),F?G="exact":Y||(G="wall"),H=!0;else if(F)throw new RangeError("Z designator not supported for PlainDate relativeTo; either remove the Z or add a bracketed time zone");X||(X="iso8601"),X=v6(X),W={year:O,month:Q,day:Z}}return U===void 0?{plainRelativeTo:J6(W,X)}:{zonedRelativeTo:e4(yG(W,w,G,G==="option"?u2(Y):0,U,"compatible","reject",H),U,X)}}function v0($){return V($,Z6)!==0?"year":V($,V6)!==0?"month":V($,f6)!==0?"week":V($,K6)!==0?"day":V($,A6)!==0?"hour":V($,E6)!==0?"minute":V($,M6)!==0?"second":V($,D6)!==0?"millisecond":V($,N6)!==0?"microsecond":"nanosecond"}function S0($,T){return Jw.indexOf($)>Jw.indexOf(T)?T:$}function s1($){return $==="year"||$==="month"||$==="week"}function q0($){return s1($)||$==="day"?"date":"time"}function RT($){return i4("%calendarImpl%")($)}function cw($){return i4("%calendarImpl%")(V($,u))}function _6($,T,W="date"){let w=Object.create(null),X=RT($).isoToDate(T,{year:!0,monthCode:!0,day:!0});return w.monthCode=X.monthCode,W!=="month-day"&&W!=="date"||(w.day=X.day),W!=="year-month"&&W!=="date"||(w.year=X.year),w}function H1($,T,W,w,X){let U=RT($).extraFields(W),Y=W.concat(w,U),G=Object.create(null),H=!1;Y.sort();for(let z=0;z<Y.length;z++){let F=Y[z],O=T[F];if(O!==void 0)H=!0,G[F]=YI[F](O);else if(X!=="partial"){if(X.includes(F))throw new TypeError(`required property '${F}' missing or undefined`);G[F]=GI[F]}}if(X==="partial"&&!H)throw new TypeError("no supported properties found");return G}function GO($,T="complete"){let W=["hour","microsecond","millisecond","minute","nanosecond","second"],w=!1,X=Object.create(null);for(let U=0;U<W.length;U++){let Y=W[U],G=$[Y];G!==void 0?(X[Y]=A$(G),w=!0):T==="complete"&&(X[Y]=0)}if(!w)throw new TypeError("invalid time-like");return X}function Vw($,T){if(Q4($)){if(F4($))return j$(X$(T)),J6(V($,V$),V($,u));if(v$($)){let H=M1(V($,y$),V($,Z$));return j$(X$(T)),J6(H.isoDate,V($,u))}if(i$($))return j$(X$(T)),J6(V($,X4).isoDate,V($,u));let G=ow($);return J6(JT(G,H1(G,$,["year","month","monthCode","day"],[],[]),j$(X$(T))),G)}let{year:W,month:w,day:X,calendar:U,z:Y}=U0(I4($));if(Y)throw new RangeError("Z designator not supported for PlainDate");return U||(U="iso8601"),U=v6(U),j$(X$(T)),J6({year:W,month:w,day:X},U)}function uw($,T,W){return x$(JT($,T,W),aG(T.hour,T.minute,T.second,T.millisecond,T.microsecond,T.nanosecond,W))}function Kw($,T){let W,w,X;if(Q4($)){if(i$($))return j$(X$(T)),K1(V($,X4),V($,u));if(v$($)){let G=M1(V($,y$),V($,Z$));return j$(X$(T)),K1(G,V($,u))}if(F4($))return j$(X$(T)),K1(x$(V($,V$),{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),V($,u));X=ow($);let U=H1(X,$,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond"],[]),Y=j$(X$(T));({isoDate:W,time:w}=uw(X,U,Y))}else{let U,Y,G,H;if({year:Y,month:G,day:H,time:w,calendar:X,z:U}=U0(I4($)),U)throw new RangeError("Z designator not supported for PlainDateTime");w==="start-of-day"&&(w={deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),_O(Y,G,H,w.hour,w.minute,w.second,w.millisecond,w.microsecond,w.nanosecond),X||(X="iso8601"),X=v6(X),j$(X$(T)),W={year:Y,month:G,day:H}}return K1(x$(W,w),X)}function E1($){let T=i4("%Temporal.Duration%");if(H4($))return new T(V($,Z6),V($,V6),V($,f6),V($,K6),V($,A6),V($,E6),V($,M6),V($,D6),V($,N6),V($,b6));if(!Q4($))return function(X){let{years:U,months:Y,weeks:G,days:H,hours:z,minutes:F,seconds:O,milliseconds:Q,microseconds:Z,nanoseconds:K}=function(E){let M=ej.exec(E);if(!M)throw new RangeError(`invalid duration: ${E}`);if(M.every((c,F$)=>F$<2||c===void 0))throw new RangeError(`invalid duration: ${E}`);let L=M[1]==="-"?-1:1,R=M[2]===void 0?0:A$(M[2])*L,_=M[3]===void 0?0:A$(M[3])*L,S=M[4]===void 0?0:A$(M[4])*L,x=M[5]===void 0?0:A$(M[5])*L,b=M[6]===void 0?0:A$(M[6])*L,g=M[7],T$=M[8],N$=M[9],j=M[10],U$=M[11],t=0,z$=0,B$=0;if(g!==void 0){if(T$??N$??j??U$)throw new RangeError("only the smallest unit can be fractional");B$=3600*A$((g+"000000000").slice(0,9))*L}else if(t=T$===void 0?0:A$(T$)*L,N$!==void 0){if(j??U$)throw new RangeError("only the smallest unit can be fractional");B$=60*A$((N$+"000000000").slice(0,9))*L}else z$=j===void 0?0:A$(j)*L,U$!==void 0&&(B$=A$((U$+"000000000").slice(0,9))*L);let e$=B$%1000,h4=Math.trunc(B$/1000)%1000,n6=Math.trunc(B$/1e6)%1000;return z$+=Math.trunc(B$/1e9)%60,t+=Math.trunc(B$/60000000000),T9(R,_,S,x,b,t,z$,n6,h4,e$),{years:R,months:_,weeks:S,days:x,hours:b,minutes:t,seconds:z$,milliseconds:n6,microseconds:h4,nanoseconds:e$}}(X);return new(i4("%Temporal.Duration%"))(U,Y,G,H,z,F,O,Q,Z,K)}(I4($));let W={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},w=RM($);for(let X=0;X<bG.length;X++){let U=bG[X],Y=w[U];Y!==void 0&&(W[U]=Y)}return new T(W.years,W.months,W.weeks,W.days,W.hours,W.minutes,W.seconds,W.milliseconds,W.microseconds,W.nanoseconds)}function Aw($){let T;if(Q4($)){if(l4($)||v$($))return I1(V($,Z$));T=UO($)}else T=$;let{year:W,month:w,day:X,time:U,offset:Y,z:G}=function(E){let M=U0(E);if(!M.z&&!M.offset)throw new RangeError("Temporal.Instant requires a time zone offset");return M}(I4(T)),{hour:H=0,minute:z=0,second:F=0,millisecond:O=0,microsecond:Q=0,nanosecond:Z=0}=U==="start-of-day"?{}:U,K=Iw(W,w,X,H,z,F,O,Q,Z-(G?0:u2(Y)));return C2(K.isoDate),I1(n4(K))}function PE($,T){if(Q4($)){if(w1($))return j$(X$(T)),q2(V($,V$),V($,u));let G;return k6($,u)?G=V($,u):(G=$.calendar,G===void 0&&(G="iso8601"),G=dw(G)),q2(hG(G,H1(G,$,["year","month","monthCode","day"],[],[]),j$(X$(T))),G)}let{month:W,day:w,referenceISOYear:X,calendar:U}=NO(I4($));if(U===void 0&&(U="iso8601"),U=v6(U),j$(X$(T)),U==="iso8601")return q2({year:1972,month:W,day:w},U);let Y={year:X,month:W,day:w};return JW(Y),Y=hG(U,_6(U,Y,"month-day"),"constrain"),q2(Y,U)}function ET($,T){let W;if(Q4($)){if(A4($))return j$(X$(T)),P0(V($,O4));if(i$($))return j$(X$(T)),P0(V($,X4).time);if(v$($)){let z=M1(V($,y$),V($,Z$));return j$(X$(T)),P0(z.time)}let{hour:w,minute:X,second:U,millisecond:Y,microsecond:G,nanosecond:H}=GO($);W=aG(w,X,U,Y,G,H,j$(X$(T)))}else W=DM(I4($)),j$(X$(T));return P0(W)}function _M($){return $===void 0?{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}:V(ET($),O4)}function Ew($,T){if(Q4($)){if(r4($))return j$(X$(T)),P2(V($,V$),V($,u));let G=ow($);return P2(Cw(G,H1(G,$,["year","month","monthCode"],[],[]),j$(X$(T))),G)}let{year:W,month:w,referenceISODay:X,calendar:U}=DO(I4($));U===void 0&&(U="iso8601"),U=v6(U),j$(X$(T));let Y={year:W,month:w,day:X};return kO(Y),Y=Cw(U,_6(U,Y,"year-month"),"constrain"),P2(Y,U)}function yG($,T,W,w,X,U,Y,G){if(T==="start-of-day")return KT(X,$);let H=x$($,T);if(W==="wall"||Y==="ignore")return T6(X,H,U);if(W==="exact"||Y==="use"){let O=Iw($.year,$.month,$.day,T.hour,T.minute,T.second,T.millisecond,T.microsecond,T.nanosecond-w);C2(O.isoDate);let Q=n4(O);return X0(Q),Q}C2($);let z=n4(H),F=Sw(X,H);for(let O=0;O<F.length;O++){let Q=F[O],Z=P.toNumber(P.subtract(z,Q)),K=MT(Z,60000000000,"halfExpand");if(Z===w||G&&K===w)return Q}if(Y==="reject"){let O=zO(w),Q=jw(H,"iso8601","auto");throw new RangeError(`Offset ${O} is invalid for ${Q} in ${X}`)}return BM(F,X,H,U)}function Mw($,T){let W,w,X,U,Y,G,H,z=!1,F="option";if(Q4($)){if(v$($)){let E=X$(T);return _w(E),IG(E,"reject"),j$(E),e4(V($,Z$),V($,y$),V($,u))}Y=ow($);let Q=H1(Y,$,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond","offset","timeZone"],["timeZone"]);({offset:U,timeZone:X}=Q),U===void 0&&(F="wall");let Z=X$(T);G=_w(Z),H=IG(Z,"reject");let K=j$(Z);({isoDate:W,time:w}=uw(Y,Q,K))}else{let Q,Z,K,E,M;({year:K,month:E,day:M,time:w,tzAnnotation:Q,offset:U,z:Z,calendar:Y}=function(R){let _=U0(R);if(!_.tzAnnotation)throw new RangeError("Temporal.ZonedDateTime requires a time zone ID in brackets");return _}(I4($))),X=R6(Q),Z?F="exact":U||(F="wall"),Y||(Y="iso8601"),Y=v6(Y),z=!0;let L=X$(T);G=_w(L),H=IG(L,"reject"),j$(L),W={year:K,month:E,day:M}}let O=0;return F==="option"&&(O=u2(U)),e4(yG(W,w,F,O,X,G,H,z),X,Y)}function kM($,T,W){JW(T),f0($),_$($,V$,T),_$($,u,W),_$($,WM,!0)}function J6($,T){let W=i4("%Temporal.PlainDate%"),w=Object.create(W.prototype);return kM(w,$,T),w}function vM($,T,W){EW(T),f0($),_$($,X4,T),_$($,u,W)}function K1($,T){let W=i4("%Temporal.PlainDateTime%"),w=Object.create(W.prototype);return vM(w,$,T),w}function qM($,T,W){JW(T),f0($),_$($,V$,T),_$($,u,W),_$($,wM,!0)}function q2($,T){let W=i4("%Temporal.PlainMonthDay%"),w=Object.create(W.prototype);return qM(w,$,T),w}function PM($,T){f0($),_$($,O4,T)}function P0($){let T=i4("%Temporal.PlainTime%"),W=Object.create(T.prototype);return PM(W,$),W}function CM($,T,W){kO(T),f0($),_$($,V$,T),_$($,u,W),_$($,XM,!0)}function P2($,T){let W=i4("%Temporal.PlainYearMonth%"),w=Object.create(W.prototype);return CM(w,$,T),w}function SM($,T){X0(T),f0($),_$($,Z$,T)}function I1($){let T=i4("%Temporal.Instant%"),W=Object.create(T.prototype);return SM(W,$),W}function jM($,T,W,w){X0(T),f0($),_$($,Z$,T),_$($,y$,W),_$($,u,w)}function e4($,T,W="iso8601"){let w=i4("%Temporal.ZonedDateTime%"),X=Object.create(w.prototype);return jM(X,$,T,W),X}function CE($){return YO.filter((T)=>$[T]!==void 0)}function KW($,T,W){let w=CE(W),X=RT($).fieldKeysToIgnore(w),U=Object.create(null),Y=CE(T);for(let G=0;G<YO.length;G++){let H,z=YO[G];Y.includes(z)&&!X.includes(z)&&(H=T[z]),w.includes(z)&&(H=W[z]),H!==void 0&&(U[z]=H)}return U}function G1($,T,W,w){let X=RT($).dateAdd(T,W,w);return JW(X),X}function pw($,T,W,w){return RT($).dateUntil(T,W,w)}function dw($){if(Q4($)&&k6($,u))return V($,u);let T=I4($);try{return v6(T)}catch{}let W;try{({calendar:W}=U0(T))}catch{try{({calendar:W}=DM(T))}catch{try{({calendar:W}=DO(T))}catch{({calendar:W}=NO(T))}}}return W||(W="iso8601"),v6(W)}function ow($){if(k6($,u))return V($,u);let{calendar:T}=$;return T===void 0?"iso8601":dw(T)}function W0($,T){return v6($)===v6(T)}function JT($,T,W){let w=RT($);w.resolveFields(T,"date");let X=w.dateToISO(T,W);return JW(X),X}function Cw($,T,W){let w=RT($);w.resolveFields(T,"year-month"),T.day=1;let X=w.dateToISO(T,W);return kO(X),X}function hG($,T,W){let w=RT($);w.resolveFields(T,"month-day");let X=w.monthDayToISOReferenceDate(T,W);return JW(X),X}function R6($){if(Q4($)&&v$($))return V($,y$);let T=I4($);if(T==="UTC")return"UTC";let{tzName:W,offsetMinutes:w}=function(U){let{tzAnnotation:Y,offset:G,z:H}=function(z){if(NM.test(z))return{tzAnnotation:z,offset:void 0,z:!1};try{let{tzAnnotation:F,offset:O,z:Q}=U0(z);if(Q||F||O)return{tzAnnotation:F,offset:O,z:Q}}catch{}JM(z)}(U);return Y?DT(Y):H?DT("UTC"):G?DT(G):void 0}(T);if(w!==void 0)return LO(w);let X=gG(W);if(!X)throw new RangeError(`Unrecognized time zone ${W}`);return X.identifier}function IM($,T){if($===T)return!0;let W=DT($).offsetMinutes,w=DT(T).offsetMinutes;if(W===void 0&&w===void 0){let X=gG(T);if(!X)return!1;let U=gG($);return!!U&&U.primaryIdentifier===X.primaryIdentifier}return W===w}function C0($,T){let W=DT($).offsetMinutes;return W!==void 0?60000000000*W:HO($,T)}function zO($){let T=$<0?"-":"+",W=Math.abs($),w=Math.floor(W/3600000000000),X=Math.floor(W/60000000000)%60,U=Math.floor(W/1e9)%60,Y=W%1e9;return`${T}${sG(w,X,U,Y,U===0&&Y===0?"minute":"auto")}`}function M1($,T){let W=C0($,T),{isoDate:{year:w,month:X,day:U},time:{hour:Y,minute:G,second:H,millisecond:z,microsecond:F,nanosecond:O}}=bM(T);return Iw(w,X,U,Y,G,H,z,F,O+W)}function T6($,T,W){return BM(Sw($,T),$,T,W)}function BM($,T,W,w){let X=$.length;if(X===1)return $[0];if(X)switch(w){case"compatible":case"earlier":return $[0];case"later":return $[X-1];case"reject":throw new RangeError("multiple instants found")}if(w==="reject")throw new RangeError("multiple instants found");let U=n4(W),Y=P.subtract(U,NT);X0(Y);let G=C0(T,Y),H=P.add(U,NT);X0(H);let z=C0(T,H)-G;switch(w){case"earlier":{let F=q$.fromComponents(0,0,0,0,0,-z),O=x2(W.time,F);return Sw(T,x$(g6(W.isoDate.year,W.isoDate.month,W.isoDate.day+O.deltaDays),O))[0]}case"compatible":case"later":{let F=q$.fromComponents(0,0,0,0,0,z),O=x2(W.time,F),Q=Sw(T,x$(g6(W.isoDate.year,W.isoDate.month,W.isoDate.day+O.deltaDays),O));return Q[Q.length-1]}}}function Sw($,T){if($==="UTC")return C2(T.isoDate),[n4(T)];let W=DT($).offsetMinutes;if(W!==void 0){let w=Iw(T.isoDate.year,T.isoDate.month,T.isoDate.day,T.time.hour,T.time.minute-W,T.time.second,T.time.millisecond,T.time.microsecond,T.time.nanosecond);C2(w.isoDate);let X=n4(w);return X0(X),[X]}return C2(T.isoDate),function(w,X){let U=n4(X),Y=P.subtract(U,NT);P.lessThan(Y,qw)&&(Y=U);let G=P.add(U,NT);P.greaterThan(G,j2)&&(G=U);let H=HO(w,Y),z=HO(w,G);return(H===z?[H]:[H,z]).map((O)=>{let Q=P.subtract(U,P.BigInt(O)),Z=function(K,E){let{epochMilliseconds:M,time:{millisecond:L,microsecond:R,nanosecond:_}}=bM(E),{year:S,month:x,day:b,hour:g,minute:T$,second:N$}=yM(K,M);return Iw(S,x,b,g,T$,N$,L,R,_)}(w,Q);if(f2(X,Z)===0)return X0(Q),Q}).filter((O)=>O!==void 0)}($,T)}function KT($,T){let W=x$(T,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),w=Sw($,W);if(w.length)return w[0];let X=n4(W),U=P.subtract(X,NT);return X0(U),RO($,U)}function lw($){let T;return T=$<0||$>9999?($<0?"-":"+")+Pw(Math.abs($),6):Pw($,4),T}function z1($){return Pw($,2)}function xM($,T){let W;if(T==="auto"){if($===0)return"";W=Pw($,9).replace(/0+$/,"")}else{if(T===0)return"";W=Pw($,9).slice(0,T)}return`.${W}`}function sG($,T,W,w,X){let U=`${z1($)}:${z1(T)}`;return X==="minute"||(U+=`:${z1(W)}`,U+=xM(w,X)),U}function SE($,T,W){let w=T;w===void 0&&(w="UTC");let X=V($,Z$),U=jw(M1(w,X),"iso8601",W,"never"),Y="Z";return T!==void 0&&(Y=fM(C0(w,X))),`${U}${Y}`}function jG($,T){let W=V($,Z6),w=V($,V6),X=V($,f6),U=V($,K6),Y=V($,A6),G=V($,E6),H=cG($),z="";W!==0&&(z+=`${Math.abs(W)}Y`),w!==0&&(z+=`${Math.abs(w)}M`),X!==0&&(z+=`${Math.abs(X)}W`),U!==0&&(z+=`${Math.abs(U)}D`);let F="";Y!==0&&(F+=`${Math.abs(Y)}H`),G!==0&&(F+=`${Math.abs(G)}M`);let O=q$.fromComponents(0,0,V($,M6),V($,D6),V($,N6),V($,b6));O.isZero()&&!["second","millisecond","microsecond","nanosecond"].includes(v0($))&&T==="auto"||(F+=`${Math.abs(O.sec)}${xM(Math.abs(O.subsec),T)}S`);let Q=`${H<0?"-":""}P${z}`;return F&&(Q=`${Q}T${F}`),Q}function jE($,T="auto"){let{year:W,month:w,day:X}=V($,V$);return`${lw(W)}-${z1(w)}-${z1(X)}${yw(V($,u),T)}`}function IE({hour:$,minute:T,second:W,millisecond:w,microsecond:X,nanosecond:U},Y){return sG($,T,W,1e6*w+1000*X+U,Y)}function jw($,T,W,w="auto"){let{isoDate:{year:X,month:U,day:Y},time:{hour:G,minute:H,second:z,millisecond:F,microsecond:O,nanosecond:Q}}=$;return`${lw(X)}-${z1(U)}-${z1(Y)}T${sG(G,H,z,1e6*F+1000*O+Q,W)}${yw(T,w)}`}function BE($,T="auto"){let{year:W,month:w,day:X}=V($,V$),U=`${z1(w)}-${z1(X)}`,Y=V($,u);T!=="always"&&T!=="critical"&&Y==="iso8601"||(U=`${lw(W)}-${U}`);let G=yw(Y,T);return G&&(U+=G),U}function xE($,T="auto"){let{year:W,month:w,day:X}=V($,V$),U=`${lw(W)}-${z1(w)}`,Y=V($,u);T!=="always"&&T!=="critical"&&Y==="iso8601"||(U+=`-${z1(X)}`);let G=yw(Y,T);return G&&(U+=G),U}function fE($,T,W="auto",w="auto",X="auto",U=void 0){let Y=V($,Z$);if(U){let{unit:F,increment:O,roundingMode:Q}=U;Y=ZO(Y,O,F,Q)}let G=V($,y$),H=C0(G,Y),z=jw(M1(G,Y),"iso8601",T,"never");return X!=="never"&&(z+=fM(H)),w!=="never"&&(z+=`[${w==="critical"?"!":""}${G}]`),z+=yw(V($,u),W),z}function bE($){return LM.test($)}function u2($){let T=QI.exec($);if(!T)throw new RangeError(`invalid time zone offset: ${$}; must match \xB1HH:MM[:SS.SSSSSSSSS]`);return(T[1]==="-"?-1:1)*(1e9*(60*(60*+T[2]+ +(T[3]||0))+ +(T[4]||0))+ +((T[5]||0)+"000000000").slice(0,9))}var Hw,FI=Object.assign(Object.create(null),{"/":!0,"-":!0,_:!0});function gG($){if(Hw===void 0){let U=Intl.supportedValuesOf?.("timeZone");if(U){Hw=new Map;for(let Y=0;Y<U.length;Y++){let G=U[Y];Hw.set(Bw(G),G)}}else Hw=null}let T=Bw($),W=Hw?.get(T);if(W)return{identifier:W,primaryIdentifier:W};try{W=MM($).resolvedOptions().timeZone}catch{return}if(T==="antarctica/south_pole"&&(W="Antarctica/McMurdo"),UI.has($))throw new RangeError(`${$} is a legacy time zone identifier from ICU. Use ${W} instead`);let w=[...T].map((U,Y)=>Y===0||FI[T[Y-1]]?U.toUpperCase():U).join("").split("/");if(w.length===1)return T==="gb-eire"?{identifier:"GB-Eire",primaryIdentifier:W}:{identifier:T.length<=3||/[-0-9]/.test(T)?T.toUpperCase():w[0],primaryIdentifier:W};if(w[0]==="Etc")return{identifier:`Etc/${["Zulu","Greenwich","Universal"].includes(w[1])?w[1]:w[1].toUpperCase()}`,primaryIdentifier:W};if(w[0]==="Us")return{identifier:`US/${w[1]}`,primaryIdentifier:W};let X=new Map([["Act","ACT"],["Lhi","LHI"],["Nsw","NSW"],["Dar_Es_Salaam","Dar_es_Salaam"],["Port_Of_Spain","Port_of_Spain"],["Port-Au-Prince","Port-au-Prince"],["Isle_Of_Man","Isle_of_Man"],["Comodrivadavia","ComodRivadavia"],["Knox_In","Knox_IN"],["Dumontdurville","DumontDUrville"],["Mcmurdo","McMurdo"],["Denoronha","DeNoronha"],["Easterisland","EasterIsland"],["Bajanorte","BajaNorte"],["Bajasur","BajaSur"]]);return w[1]=X.get(w[1])??w[1],w.length>2&&(w[2]=X.get(w[2])??w[2]),{identifier:w.join("/"),primaryIdentifier:W}}function ZW($,T){let{year:W,month:w,day:X,hour:U,minute:Y,second:G}=yM($,T),H=T%1000;return H<0&&(H+=1000),1e6*(JO({isoDate:{year:W,month:w,day:X},time:{hour:U,minute:Y,second:G,millisecond:H}})-T)}function HO($,T){return ZW($,D1(T,"floor"))}function LO($){let T=$<0?"-":"+",W=Math.abs($);return`${T}${sG(Math.floor(W/60),W%60,0,0,"minute")}`}function fM($){return LO(MT($,$I,"halfExpand")/60000000000)}function JO({isoDate:{year:$,month:T,day:W},time:{hour:w,minute:X,second:U,millisecond:Y}}){let G=$%400,H=($-G)/400,z=new Date;return z.setUTCHours(w,X,U,Y),z.setUTCFullYear(G,T-1,W),z.getTime()+XI*H}function n4($){let T=JO($),W=1000*$.time.microsecond+$.time.nanosecond;return P.add(B1(T),P.BigInt(W))}function bM($){let T=D1($,"trunc"),W=P.toNumber(P.remainder($,fw));W<0&&(W+=1e6,T-=1);let w=Math.floor(W/1000)%1000,X=W%1000,U=new Date(T);return{epochMilliseconds:T,isoDate:{year:U.getUTCFullYear(),month:U.getUTCMonth()+1,day:U.getUTCDate()},time:{hour:U.getUTCHours(),minute:U.getUTCMinutes(),second:U.getUTCSeconds(),millisecond:U.getUTCMilliseconds(),microsecond:w,nanosecond:X}}}function RO($,T){if($==="UTC")return null;let W=D1(T,"floor");if(W<Lw)return RO($,B1(Lw));let w=Date.now(),X=Math.max(W,w)+366*LT*3,U=W,Y=ZW($,U),G=U,H=Y;for(;Y===H&&U<X;){if(G=U+2*LT*7,G>EM)return null;H=ZW($,G),Y===H&&(U=G)}return Y===H?null:B1(rM((z)=>ZW($,z),U,G,Y,H))}function FO($,T){if($==="UTC")return null;let W=D1(T,"ceil"),w=Date.now(),X=w+366*LT*3;if(W>X){let z=FO($,B1(X));if(z===null||P.lessThan(z,B1(w)))return z}if($==="Africa/Casablanca"||$==="Africa/El_Aaiun"){let z=Date.UTC(2088,0,1);if(z<W)return FO($,B1(z))}let U=W-1;if(U<Lw)return null;let Y=ZW($,U),G=U,H=Y;for(;Y===H&&U>Lw;){if(G=U-2*LT*7,G<Lw)return null;H=ZW($,G),Y===H&&(U=G)}return Y===H?null:B1(rM((z)=>ZW($,z),G,U,H,Y))}function yM($,T){return function(W){let w=W.split(/[^\w]+/);if(w.length!==7)throw new RangeError(`expected 7 parts in "${W}`);let X=+w[0],U=+w[1],Y=+w[2],G=w[3];if(G[0]==="b"||G[0]==="B")Y=1-Y;else if(G[0]!=="a"&&G[0]!=="A")throw new RangeError(`Unknown era ${G} in "${W}`);let H=w[4]==="24"?0:+w[4],z=+w[5],F=+w[6];if(!(Number.isFinite(Y)&&Number.isFinite(X)&&Number.isFinite(U)&&Number.isFinite(H)&&Number.isFinite(z)&&Number.isFinite(F)))throw new RangeError(`Invalid number in "${W}`);return{year:Y,month:X,day:U,hour:H,minute:z,second:F}}(MM($).format(T))}function mG($){return $!==void 0&&!($%4!=0||$%100==0&&$%400!=0)}function VW($,T){return{standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]}[mG($)?"leapyear":"standard"][T-1]}function cG($){let T=[V($,Z6),V($,V6),V($,f6),V($,K6),V($,A6),V($,E6),V($,M6),V($,D6),V($,N6),V($,b6)];for(let W=0;W<T.length;W++){let w=T[W];if(w!==0)return w<0?-1:1}return 0}function eG($){let T=["years","months","weeks","days"];for(let W=0;W<T.length;W++){let w=$[T[W]];if(w!==0)return w<0?-1:1}return 0}function hM($){let T=eG($.date);return T!==0?T:$.time.sign()}function QW($,T){let W=$,w=T;if(!Number.isFinite(W)||!Number.isFinite(w))throw new RangeError("infinity is out of range");return w-=1,W+=Math.floor(w/12),w%=12,w<0&&(w+=12),w+=1,{year:W,month:w}}function g6($,T,W){let w=$,X=T,U=W;if(!Number.isFinite(U))throw new RangeError("infinity is out of range");({year:w,month:X}=QW(w,X));let Y=146097;if(Math.abs(U)>Y){let z=Math.trunc(U/Y);w+=400*z,U-=z*Y}let G=0,H=X>2?w:w-1;for(;G=mG(H)?366:365,U<-G;)w-=1,H-=1,U+=G;for(H+=1;G=mG(H)?366:365,U>G;)w+=1,H+=1,U-=G;for(;U<1;)({year:w,month:X}=QW(w,X-1)),U+=VW(w,X);for(;U>VW(w,X);)U-=VW(w,X),{year:w,month:X}=QW(w,X+1);return{year:w,month:X,day:U}}function Iw($,T,W,w,X,U,Y,G,H){let z=AT(w,X,U,Y,G,H);return x$(g6($,T,W+z.deltaDays),z)}function AT($,T,W,w,X,U){let Y,G=$,H=T,z=W,F=w,O=X,Q=U;({div:Y,mod:Q}=v2(Q,3)),O+=Y,Q<0&&(O-=1,Q+=1000),{div:Y,mod:O}=v2(O,3),F+=Y,O<0&&(F-=1,O+=1000),z+=Math.trunc(F/1000),F%=1000,F<0&&(z-=1,F+=1000),H+=Math.trunc(z/60),z%=60,z<0&&(H-=1,z+=60),G+=Math.trunc(H/60),H%=60,H<0&&(G-=1,H+=60);let Z=Math.trunc(G/24);return G%=24,G<0&&(Z-=1,G+=24),Z+=0,G+=0,H+=0,z+=0,F+=0,O+=0,Q+=0,{deltaDays:Z,hour:G,minute:H,second:z,millisecond:F,microsecond:O,nanosecond:Q}}function yE($,T){let W=$6($,0);if(eG(W)===0)return $.days;let w=V(T,V$),X=G1(V(T,u),w,W,"constrain"),U=MW(w.year,w.month-1,w.day),Y=MW(X.year,X.month-1,X.day)-U;return $.days+Y}function m6($){return new(i4("%Temporal.Duration%"))(-V($,Z6),-V($,V6),-V($,f6),-V($,K6),-V($,A6),-V($,E6),-V($,M6),-V($,D6),-V($,N6),-V($,b6))}function L6($,T,W){return Math.min(W,Math.max(T,$))}function gM($,T,W){let w=L6(T,1,12);return{year:$,month:w,day:L6(W,1,VW($,w))}}function c4($,T,W){if($<T||$>W)throw new RangeError(`value out of range: ${T} <= ${$} <= ${W}`)}function AW($,T,W){c4(T,1,12),c4(W,1,VW($,T))}function JW($){EW(x$($,{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}))}function $9($,T,W,w,X,U){c4($,0,23),c4(T,0,59),c4(W,0,59),c4(w,0,999),c4(X,0,999),c4(U,0,999)}function _O($,T,W,w,X,U,Y,G,H){AW($,T,W),$9(w,X,U,Y,G,H)}function EW($){let T=n4($);(P.lessThan(T,TI)||P.greaterThan(T,WI))&&X0(T)}function OO($){n4($)}function X0($){if(P.lessThan($,qw)||P.greaterThan($,j2))throw new RangeError("date/time value is outside of supported range")}function kO({year:$,month:T}){c4($,RE,_E),$===RE?c4(T,4,12):$===_E&&c4(T,1,9)}function T9($,T,W,w,X,U,Y,G,H,z){let F=0,O=[$,T,W,w,X,U,Y,G,H,z];for(let L=0;L<O.length;L++){let R=O[L];if(R===1/0||R===-1/0)throw new RangeError("infinite values not allowed as duration fields");if(R!==0){let _=R<0?-1:1;if(F!==0&&_!==F)throw new RangeError("mixed-sign values not allowed as duration fields");F=_}}if(Math.abs($)>=4294967296||Math.abs(T)>=4294967296||Math.abs(W)>=4294967296)throw new RangeError("years, months, and weeks must be < 2\xB3\xB2");let Q=v2(G,3),Z=v2(H,6),K=v2(z,9),E=v2(1e6*Q.mod+1000*Z.mod+K.mod,9).div,M=86400*w+3600*X+60*U+Y+Q.div+Z.div+K.div+E;if(!Number.isSafeInteger(M))throw new RangeError("total of duration time units cannot exceed 9007199254740991.999999999 s")}function k2($){return{date:{years:V($,Z6),months:V($,V6),weeks:V($,f6),days:V($,K6)},time:q$.fromComponents(V($,A6),V($,E6),V($,M6),V($,D6),V($,N6),V($,b6))}}function $0($){let T=q$.fromComponents(V($,A6),V($,E6),V($,M6),V($,D6),V($,N6),V($,b6)).add24HourDays(V($,K6));return{date:{years:V($,Z6),months:V($,V6),weeks:V($,f6),days:0},time:T}}function mM($){let T=$0($),W=Math.trunc(T.time.sec/86400);return T9(T.date.years,T.date.months,T.date.weeks,W,0,0,0,0,0,0),{...T.date,days:W}}function A1($,T){let W=$.time.sign(),w=$.time.abs().subsec,X=0,U=0,Y=$.time.abs().sec,G=0,H=0,z=0;switch(T){case"year":case"month":case"week":case"day":X=Math.trunc(w/1000),w%=1000,U=Math.trunc(X/1000),X%=1000,Y+=Math.trunc(U/1000),U%=1000,G=Math.trunc(Y/60),Y%=60,H=Math.trunc(G/60),G%=60,z=Math.trunc(H/24),H%=24;break;case"hour":X=Math.trunc(w/1000),w%=1000,U=Math.trunc(X/1000),X%=1000,Y+=Math.trunc(U/1000),U%=1000,G=Math.trunc(Y/60),Y%=60,H=Math.trunc(G/60),G%=60;break;case"minute":X=Math.trunc(w/1000),w%=1000,U=Math.trunc(X/1000),X%=1000,Y+=Math.trunc(U/1000),U%=1000,G=Math.trunc(Y/60),Y%=60;break;case"second":X=Math.trunc(w/1000),w%=1000,U=Math.trunc(X/1000),X%=1000,Y+=Math.trunc(U/1000),U%=1000;break;case"millisecond":X=Math.trunc(w/1000),w%=1000,U=rF(Y,3,Math.trunc(X/1000)),X%=1000,Y=0;break;case"microsecond":X=rF(Y,6,Math.trunc(w/1000)),w%=1000,Y=0;break;case"nanosecond":w=rF(Y,9,w),Y=0}return new(i4("%Temporal.Duration%"))($.date.years,$.date.months,$.date.weeks,$.date.days+W*z,W*H,W*G,W*Y,W*U,W*X,W*w)}function j0($,T){return eG($),T.sign(),{date:$,time:T}}function MW($,T,W){return JO({isoDate:{year:$,month:T+1,day:W},time:{hour:0,minute:0,second:0,millisecond:0}})/LT}function C2({year:$,month:T,day:W}){if(Math.abs(MW($,T-1,W))>1e8)throw new RangeError("date/time value is outside the supported range")}function vO($,T){let W=T.hour-$.hour,w=T.minute-$.minute,X=T.second-$.second,U=T.millisecond-$.millisecond,Y=T.microsecond-$.microsecond,G=T.nanosecond-$.nanosecond;return q$.fromComponents(W,w,X,U,Y,G)}function qO($,T,W,w,X){let U=q$.fromEpochNsDiff(T,$);return U=uG(U,W,w,X),j0({years:0,months:0,weeks:0,days:0},U)}function cM($,T,W,w){OO($),OO(T);let X=vO($.time,T.time),U=X.sign(),Y=w0($.isoDate,T.isoDate),G=T.isoDate;Y===U&&(G=g6(G.year,G.month,G.day+U),X=X.add24HourDays(-U));let H=S0("day",w),z=pw(W,$.isoDate,G,H);return w!==H&&(X=X.add24HourDays(z.days),z.days=0),j0(z,X)}function uM($,T,W,w,X){let U=P.subtract(T,$);if(P.equal(U,U1))return{date:{years:0,months:0,weeks:0,days:0},time:q$.ZERO};let Y=P.lessThan(U,U1)?-1:1,G=M1(W,$),H=M1(W,T),z,F=0,O=Y===1?2:1,Q=vO(G.time,H.time);for(Q.sign()===-Y&&F++;F<=O;F++){z=x$(g6(H.isoDate.year,H.isoDate.month,H.isoDate.day-F*Y),G.time);let K=T6(W,z,"compatible");if(Q=q$.fromEpochNsDiff(T,K),Q.sign()!==-Y)break}let Z=S0("day",X);return j0(pw(w,G.isoDate,z.isoDate,Z),Q)}function pM($,T,W,w,X,U,Y,G,H){let z,F,O,Q,Z=T;switch(G){case"year":{let t=MT(Z.date.years,Y,"trunc");z=t,F=t+Y*$,O={years:z,months:0,weeks:0,days:0},Q={...O,years:F};break}case"month":{let t=MT(Z.date.months,Y,"trunc");z=t,F=t+Y*$,O=$6(Z.date,0,0,z),Q=$6(Z.date,0,0,F);break}case"week":{let t=$6(Z.date,0,0),z$=G1(U,w.isoDate,t,"constrain"),B$=pw(U,z$,g6(z$.year,z$.month,z$.day+Z.date.days),"week"),e$=MT(Z.date.weeks+B$.weeks,Y,"trunc");z=e$,F=e$+Y*$,O=$6(Z.date,0,z),Q=$6(Z.date,0,F);break}case"day":{let t=MT(Z.date.days,Y,"trunc");z=t,F=t+Y*$,O=$6(Z.date,z),Q=$6(Z.date,F);break}}let K=G1(U,w.isoDate,O,"constrain"),E=G1(U,w.isoDate,Q,"constrain"),M,L,R=x$(K,w.time),_=x$(E,w.time);X?(M=T6(X,R,"compatible"),L=T6(X,_,"compatible")):(M=n4(R),L=n4(_));let S=q$.fromEpochNsDiff(W,M),x=q$.fromEpochNsDiff(L,M),b=lG(H,$<0?"negative":"positive"),g=S.add(S).abs().subtract(x.abs()).sign(),T$=Math.abs(z)/Y%2==0,N$=S.isZero()?Math.abs(z):S.cmp(x)?rG(Math.abs(z),Math.abs(F),g,T$,b):Math.abs(F),j=new q$(P.add(P.multiply(x.totalNs,P.BigInt(z)),P.multiply(S.totalNs,P.BigInt(Y*$)))).fdiv(x.totalNs),U$=N$===Math.abs(F);return Z={date:U$?Q:O,time:q$.ZERO},{nudgeResult:{duration:Z,nudgedEpochNs:U$?L:M,didExpandCalendarUnit:U$},total:j}}function W9($,T,W,w,X,U,Y,G,H){let z=$,F=s1(G)||w&&G==="day",O=hM(z)<0?-1:1,Q;return F?{nudgeResult:Q}=pM(O,z,T,W,w,X,Y,G,H):Q=w?function(Z,K,E,M,L,R,_,S){let x=K,b=G1(L,E.isoDate,x.date,"constrain"),g=x$(b,E.time),T$=x$(g6(b.year,b.month,b.day+Z),E.time),N$=T6(M,g,"compatible"),j=T6(M,T$,"compatible"),U$=q$.fromEpochNsDiff(j,N$);if(U$.sign()!==Z)throw new RangeError("time zone returned inconsistent Instants");let t=P.BigInt(B2[_]*R),z$=x.time.round(t,S),B$=z$.subtract(U$),e$=B$.sign()!==-Z,h4,n6;return e$?(h4=Z,z$=B$.round(t,S),n6=z$.addToEpochNs(j)):(h4=0,n6=z$.addToEpochNs(N$)),{duration:j0($6(x.date,x.date.days+h4),z$),nudgedEpochNs:n6,didExpandCalendarUnit:e$}}(O,z,W,w,X,Y,G,H):function(Z,K,E,M,L,R){let _=Z,S=_.time.add24HourDays(_.date.days),x=S.round(P.BigInt(M*B2[L]),R),b=x.subtract(S),{quotient:g}=S.divmod(fG),{quotient:T$}=x.divmod(fG),N$=Math.sign(T$-g)===S.sign(),j=b.addToEpochNs(K),U$=0,t=x;return q0(E)==="date"&&(U$=T$,t=x.add(q$.fromComponents(24*-T$,0,0,0,0,0))),{duration:{date:$6(_.date,U$),time:t},nudgedEpochNs:j,didExpandCalendarUnit:N$}}(z,T,U,Y,G,H),z=Q.duration,Q.didExpandCalendarUnit&&G!=="week"&&(z=function(Z,K,E,M,L,R,_,S){let x=K;if(S===_)return x;let b=Jw.indexOf(_);for(let g=Jw.indexOf(S)-1;g>=b;g--){let T$=Jw[g];if(T$==="week"&&_!=="week")continue;let N$;switch(T$){case"year":N$={years:x.date.years+Z,months:0,weeks:0,days:0};break;case"month":{let t=x.date.months+Z;N$=$6(x.date,0,0,t);break}case"week":{let t=x.date.weeks+Z;N$=$6(x.date,0,t);break}}let j=x$(G1(R,M.isoDate,N$,"constrain"),M.time),U$;if(U$=L?T6(L,j,"compatible"):n4(j),BG(E,U$)===-Z)break;x={date:N$,time:q$.ZERO}}return x}(O,z,Q.nudgedEpochNs,W,w,X,U,S0(G,"day"))),z}function hE($,T,W,w,X,U){return s1(U)||w&&U==="day"?pM(hM($)<0?-1:1,$,T,W,w,X,1,U,"trunc").total:kw($.time.add24HourDays($.date.days),U)}function dM($,T,W,w,X,U,Y){if(f2($,T)==0)return{date:{years:0,months:0,weeks:0,days:0},time:q$.ZERO};EW($),EW(T);let G=cM($,T,W,w);return U==="nanosecond"&&X===1?G:W9(G,n4(T),$,null,W,w,X,U,Y)}function oM($,T,W,w,X,U,Y,G){if(q0(X)==="time")return qO($,T,U,Y,G);let H=uM($,T,W,w,X);return Y==="nanosecond"&&U===1?H:W9(H,T,M1(W,$),W,w,X,U,Y,G)}function p2($,T,W,w,X,U){let Y=I2.reduce((Z,K)=>{let E=K[0],M=K[1],L=K[2];return W!=="datetime"&&L!==W||w.includes(M)||Z.push(M,E),Z},[]),G=h6(T,"largestUnit",W,"auto");if(w.includes(G))throw new RangeError(`largestUnit must be one of ${Y.join(", ")}, not ${G}`);let H=m2(T),z=x1(T,"trunc");$==="since"&&(z=function(Z){switch(Z){case"ceil":return"floor";case"floor":return"ceil";case"halfCeil":return"halfFloor";case"halfFloor":return"halfCeil";default:return Z}}(z));let F=h6(T,"smallestUnit",W,X);if(w.includes(F))throw new RangeError(`smallestUnit must be one of ${Y.join(", ")}, not ${F}`);let O=S0(U,F);if(G==="auto"&&(G=O),S0(G,F)!==G)throw new RangeError(`largestUnit ${G} cannot be smaller than smallestUnit ${F}`);let Q={hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[F];return Q!==void 0&&c2(H,Q,!1),{largestUnit:G,roundingIncrement:H,roundingMode:z,smallestUnit:F}}function gE($,T,W,w){let X=Aw(W),U=p2($,X$(w),"time",[],"nanosecond","second"),Y=A1(qO(V(T,Z$),V(X,Z$),U.roundingIncrement,U.smallestUnit,U.roundingMode),U.largestUnit);return $==="since"&&(Y=m6(Y)),Y}function mE($,T,W,w){let X=Vw(W),U=V(T,u),Y=V(X,u);if(!W0(U,Y))throw new RangeError(`cannot compute difference between dates of ${U} and ${Y} calendars`);let G=p2($,X$(w),"date",[],"day","day"),H=i4("%Temporal.Duration%"),z=V(T,V$),F=V(X,V$);if(w0(z,F)===0)return new H;let O={date:pw(U,z,F,G.largestUnit),time:q$.ZERO};if(G.smallestUnit!=="day"||G.roundingIncrement!==1){let Z=x$(z,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});O=W9(O,n4(x$(F,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0})),Z,null,U,G.largestUnit,G.roundingIncrement,G.smallestUnit,G.roundingMode)}let Q=A1(O,"day");return $==="since"&&(Q=m6(Q)),Q}function cE($,T,W,w){let X=Kw(W),U=V(T,u),Y=V(X,u);if(!W0(U,Y))throw new RangeError(`cannot compute difference between dates of ${U} and ${Y} calendars`);let G=p2($,X$(w),"datetime",[],"nanosecond","day"),H=i4("%Temporal.Duration%"),z=V(T,X4),F=V(X,X4);if(f2(z,F)===0)return new H;let O=A1(dM(z,F,U,G.largestUnit,G.roundingIncrement,G.smallestUnit,G.roundingMode),G.largestUnit);return $==="since"&&(O=m6(O)),O}function uE($,T,W,w){let X=ET(W),U=p2($,X$(w),"time",[],"nanosecond","hour"),Y=vO(V(T,O4),V(X,O4));Y=uG(Y,U.roundingIncrement,U.smallestUnit,U.roundingMode);let G=A1(j0({years:0,months:0,weeks:0,days:0},Y),U.largestUnit);return $==="since"&&(G=m6(G)),G}function pE($,T,W,w){let X=Ew(W),U=V(T,u),Y=V(X,u);if(!W0(U,Y))throw new RangeError(`cannot compute difference between months of ${U} and ${Y} calendars`);let G=p2($,X$(w),"date",["week","day"],"month","year"),H=i4("%Temporal.Duration%");if(w0(V(T,V$),V(X,V$))==0)return new H;let z=_6(U,V(T,V$),"year-month");z.day=1;let F=JT(U,z,"constrain"),O=_6(U,V(X,V$),"year-month");O.day=1;let Q=JT(U,O,"constrain"),Z={date:$6(pw(U,F,Q,G.largestUnit),0,0),time:q$.ZERO};if(G.smallestUnit!=="month"||G.roundingIncrement!==1){let E=x$(F,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});Z=W9(Z,n4(x$(Q,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0})),E,null,U,G.largestUnit,G.roundingIncrement,G.smallestUnit,G.roundingMode)}let K=A1(Z,"day");return $==="since"&&(K=m6(K)),K}function dE($,T,W,w){let X=Mw(W),U=V(T,u),Y=V(X,u);if(!W0(U,Y))throw new RangeError(`cannot compute difference between dates of ${U} and ${Y} calendars`);let G=p2($,X$(w),"datetime",[],"nanosecond","hour"),H=V(T,Z$),z=V(X,Z$),F=i4("%Temporal.Duration%"),O;if(q0(G.largestUnit)!=="date")O=A1(qO(H,z,G.roundingIncrement,G.smallestUnit,G.roundingMode),G.largestUnit);else{let Q=V(T,y$);if(!IM(Q,V(X,y$)))throw new RangeError("When calculating difference between time zones, largestUnit must be 'hours' or smaller because day lengths can vary between time zones due to DST or time zone offset changes.");if(P.equal(H,z))return new F;O=A1(oM(H,z,Q,U,G.largestUnit,G.roundingIncrement,G.smallestUnit,G.roundingMode),"hour")}return $==="since"&&(O=m6(O)),O}function x2({hour:$,minute:T,second:W,millisecond:w,microsecond:X,nanosecond:U},Y){let G=W,H=U;return G+=Y.sec,H+=Y.subsec,AT($,T,G,w,X,H)}function QO($,T){let W=T.addToEpochNs($);return X0(W),W}function Dw($,T,W,w,X="constrain"){if(eG(w.date)===0)return QO($,w.time);let U=M1(T,$);return QO(T6(T,x$(G1(W,U.isoDate,w.date,X),U.time),"compatible"),w.time)}function oE($,T,W){let w=E1(W);$==="subtract"&&(w=m6(w));let X=S0(v0(T),v0(w));if(s1(X))throw new RangeError("For years, months, or weeks arithmetic, use date arithmetic relative to a starting point");let U=$0(T),Y=$0(w);return A1(j0({years:0,months:0,weeks:0,days:0},U.time.add(Y.time)),X)}function lE($,T,W){let w=E1(W);$==="subtract"&&(w=m6(w));let X=v0(w);if(q0(X)==="date")throw new RangeError(`Duration field ${X} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);let U=$0(w);return I1(QO(V(T,Z$),U.time))}function rE($,T,W,w){let X=V(T,u),U=E1(W);$==="subtract"&&(U=m6(U));let Y=mM(U),G=j$(X$(w));return J6(G1(X,V(T,V$),Y,G),X)}function nE($,T,W,w){let X=E1(W);$==="subtract"&&(X=m6(X));let U=j$(X$(w)),Y=V(T,u),G=$0(X),H=V(T,X4),z=x2(H.time,G.time),F=$6(G.date,z.deltaDays);return T9(F.years,F.months,F.weeks,F.days,0,0,0,0,0,0),K1(x$(G1(Y,H.isoDate,F,U),z),Y)}function iE($,T,W){let w=E1(W);$==="subtract"&&(w=m6(w));let X=$0(w),{hour:U,minute:Y,second:G,millisecond:H,microsecond:z,nanosecond:F}=x2(V(T,O4),X.time);return P0(aG(U,Y,G,H,z,F,"reject"))}function tE($,T,W,w){let X=E1(W);$==="subtract"&&(X=m6(X));let U=j$(X$(w)),Y=cG(X),G=V(T,u),H=_6(G,V(T,V$),"year-month");H.day=1;let z=JT(G,H,"constrain");if(Y<0){let O=G1(G,z,{months:1},"constrain");z=g6(O.year,O.month,O.day-1)}let F=mM(X);return JW(z),P2(Cw(G,_6(G,G1(G,z,F,U),"year-month"),U),G)}function aE($,T,W,w){let X=E1(W);$==="subtract"&&(X=m6(X));let U=j$(X$(w)),Y=V(T,y$),G=V(T,u),H=k2(X);return e4(Dw(V(T,Z$),Y,G,H,U),Y,G)}function MT($,T,W){let w=Math.trunc($/T),X=$%T,U=$<0?"negative":"positive",Y=Math.abs(w),G=Y+1,H=y6(Math.abs(2*X)-T),z=Y%2==0,F=lG(W,U),O=X===0?Y:rG(Y,G,H,z,F);return T*(U==="positive"?O:-O)}function ZO($,T,W,w){let X=B2[W]*T;return function(U,Y,G){let H=k0(U),z=k0(Y),F=P.divide(H,z),O=P.remainder(H,z),Q=lG(G,"positive"),Z,K;P.lessThan(H,U1)?(Z=P.subtract(F,vw),K=F):(Z=F,K=P.add(F,vw));let E=BG(OW(P.multiply(O,MO)),z)*(P.lessThan(H,U1)?-1:1)+0,M=P.equal(O,U1)?F:rG(Z,K,E,TM(Z),Q);return P.multiply(M,z)}($,P.BigInt(X),w)}function VO($,T,W,w){OO($);let{year:X,month:U,day:Y}=$.isoDate,G=KO($.time,T,W,w);return x$(g6(X,U,Y+G.deltaDays),G)}function KO({hour:$,minute:T,second:W,millisecond:w,microsecond:X,nanosecond:U},Y,G,H){let z;switch(G){case"day":case"hour":z=1000*(1000*(1000*(60*(60*$+T)+W)+w)+X)+U;break;case"minute":z=1000*(1000*(1000*(60*T+W)+w)+X)+U;break;case"second":z=1000*(1000*(1000*W+w)+X)+U;break;case"millisecond":z=1000*(1000*w+X)+U;break;case"microsecond":z=1000*X+U;break;case"nanosecond":z=U}let F=B2[G],O=MT(z,F*Y,H)/F;switch(G){case"day":return{deltaDays:O,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0};case"hour":return AT(O,0,0,0,0,0);case"minute":return AT($,O,0,0,0,0);case"second":return AT($,T,O,0,0,0);case"millisecond":return AT($,T,W,O,0,0);case"microsecond":return AT($,T,W,w,O,0);case"nanosecond":return AT($,T,W,w,X,O);default:throw new Error(`Invalid unit ${G}`)}}function uG($,T,W,w){let X=B2[W];return $.round(P.BigInt(X*T),w)}function kw($,T){let W=B2[T];return $.fdiv(P.BigInt(W))}function w0($,T){return $.year!==T.year?y6($.year-T.year):$.month!==T.month?y6($.month-T.month):$.day!==T.day?y6($.day-T.day):0}function AO($,T){return $.hour!==T.hour?y6($.hour-T.hour):$.minute!==T.minute?y6($.minute-T.minute):$.second!==T.second?y6($.second-T.second):$.millisecond!==T.millisecond?y6($.millisecond-T.millisecond):$.microsecond!==T.microsecond?y6($.microsecond-T.microsecond):$.nanosecond!==T.nanosecond?y6($.nanosecond-T.nanosecond):0}function f2($,T){let W=w0($.isoDate,T.isoDate);return W!==0?W:AO($.time,T.time)}function lM($){let T=pG($);return globalThis.BigInt!==void 0?globalThis.BigInt(T.toString(10)):T}function D1($,T){let W=k0($),{quotient:w,remainder:X}=Qw(W,fw),U=P.toNumber(w);return T==="floor"&&P.toNumber(X)<0&&(U-=1),T==="ceil"&&P.toNumber(X)>0&&(U+=1),U}function B1($){if(!Number.isInteger($))throw new RangeError("epoch milliseconds must be an integer");return P.multiply(P.BigInt($),fw)}function pG($){let T=$;if(typeof $=="object"){let W=$[Symbol.toPrimitive];W&&typeof W=="function"&&(T=W.call($,"number"))}if(typeof T=="number")throw new TypeError("cannot convert number to bigint");return typeof T=="bigint"?P.BigInt(T.toString(10)):P.BigInt(T)}var EO=(()=>{let $=P.BigInt(Date.now()%1e6);return()=>{let T=Date.now(),W=P.BigInt(T),w=P.add(B1(T),$);return $=P.remainder(W,fw),P.greaterThan(w,j2)?j2:P.lessThan(w,qw)?qw:w}})();function Fw(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}function y6($){return $<0?-1:$>0?1:$}function X$($){if($===void 0)return Object.create(null);if(Q4($)&&$!==null)return $;throw new TypeError("Options parameter must be an object, not "+($===null?"null":typeof $))}function DW($,T){let W=Object.create(null);return W[$]=T,W}function I0($,T,W,w){let X=$[T];if(X!==void 0){if(X=iG(X),!W.includes(X))throw new RangeError(`${T} must be one of ${W.join(", ")}, not ${X}`);return X}if(w===x0)throw new RangeError(`${T} option is required`);return w}function v6($){let T=Bw($);if(!wI.includes(Bw(T)))throw new RangeError(`invalid calendar identifier ${T}`);switch(T){case"ethiopic-amete-alem":return"ethioaa";case"islamicc":return"islamic-civil"}return T}function Bw($){let T="";for(let W=0;W<$.length;W++){let w=$.charCodeAt(W);T+=w>=65&&w<=90?String.fromCharCode(w+32):String.fromCharCode(w)}return T}function _T($){throw new TypeError(`Do not use built-in arithmetic operators with Temporal objects. When comparing, use ${$==="PlainMonthDay"?"Temporal.PlainDate.compare(obj1.toPlainDate(year), obj2.toPlainDate(year))":`Temporal.${$}.compare(obj1, obj2)`}, not obj1 > obj2. When coercing to strings, use \`\${obj}\` or String(obj), not '' + obj. When coercing to numbers, use properties or methods of the object, not \`+obj\`. When concatenating with strings, use \`\${str}\${obj}\` or str.concat(obj), not str + obj. In React, coerce to a string before rendering a Temporal object.`)}var OI=new RegExp(`^${KM.source}$`),QI=new RegExp(`^${/([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\d{1,9}))?)?)?/.source}$`);function rM($,T,W,w=$(T),X=$(W)){let U=T,Y=W,G=w,H=X;for(;Y-U>1;){let z=Math.trunc((U+Y)/2),F=$(z);F===G?(U=z,G=F):F===H&&(Y=z,H=F)}return Y}function nM($){return[...$]}function iM($,T){if($!=="gregory"&&$!=="iso8601")return;let W=rw[$],w=T.year,{dayOfWeek:X,dayOfYear:U,daysInYear:Y}=W.isoToDate(T,{dayOfWeek:!0,dayOfYear:!0,daysInYear:!0}),G=W.getFirstDayOfWeek(),H=W.getMinimalDaysInFirstWeek(),z=(X+7-G)%7,F=(X-U+7001-G)%7,O=Math.floor((U-1+F)/7);if(7-F>=H&&++O,O==0)O=function(Q,Z,K,E){let M=(E-Q-K+1)%7;M<0&&(M+=7);let L=Math.floor((K+M-1)/7);return 7-M>=Z&&++L,L}(G,H,U+W.isoToDate(W.dateAdd(T,{years:-1},"constrain"),{daysInYear:!0}).daysInYear,X),w--;else if(U>=Y-5){let Q=(z+Y-U)%7;Q<0&&(Q+=7),6-Q>=H&&U+7-z>Y&&(O=1,w++)}return{week:O,year:w}}function sE($,T,W,w,X){if(T!==X.year){if($*(T-X.year)>0)return!0}else if(W!==X.month){if($*(W-X.month)>0)return!0}else if(w!==X.day&&$*(w-X.day)>0)return!0;return!1}var rw={};function NW($){if(!$.startsWith("M"))throw new RangeError(`Invalid month code: ${$}. Month codes must start with M.`);let T=+$.slice(1);if(Number.isNaN(T))throw new RangeError(`Invalid month code: ${$}`);return T}function T0($,T=!1){return`M${`${$}`.padStart(2,"0")}${T?"L":""}`}function PO($,T=void 0,W=12){let{month:w,monthCode:X}=$;if(X===void 0){if(w===void 0)throw new TypeError("Either month or monthCode are required");T==="reject"&&c4(w,1,W),T==="constrain"&&(w=L6(w,1,W)),X=T0(w)}else{let U=NW(X);if(X!==T0(U))throw new RangeError(`Invalid month code: ${X}`);if(w!==void 0&&w!==U)throw new RangeError(`monthCode ${X} and month ${w} must match if both are present`);if(w=U,w<1||w>W)throw new RangeError(`Invalid monthCode: ${X}`)}return{...$,month:w,monthCode:X}}rw.iso8601={resolveFields($,T){if((T==="date"||T==="year-month")&&$.year===void 0)throw new TypeError("year is required");if((T==="date"||T==="month-day")&&$.day===void 0)throw new TypeError("day is required");Object.assign($,PO($))},dateToISO:($,T)=>Rw($.year,$.month,$.day,T),monthDayToISOReferenceDate($,T){let{month:W,day:w}=Rw($.year??1972,$.month,$.day,T);return{month:W,day:w,year:1972}},extraFields:()=>[],fieldKeysToIgnore($){let T=new Set;for(let W=0;W<$.length;W++){let w=$[W];T.add(w),w==="month"?T.add("monthCode"):w==="monthCode"&&T.add("month")}return nM(T)},dateAdd($,{years:T=0,months:W=0,weeks:w=0,days:X=0},U){let{year:Y,month:G,day:H}=$;return Y+=T,G+=W,{year:Y,month:G}=QW(Y,G),{year:Y,month:G,day:H}=Rw(Y,G,H,U),H+=X+7*w,g6(Y,G,H)},dateUntil($,T,W){let w=-w0($,T);if(w===0)return{years:0,months:0,weeks:0,days:0};let X,U=0,Y=0;if(W==="year"||W==="month"){let F=T.year-$.year;for(F!==0&&(F-=w);!sE(w,$.year+F,$.month,$.day,T);)U=F,F+=w;let O=w;for(X=QW($.year+U,$.month+O);!sE(w,X.year,X.month,$.day,T);)Y=O,O+=w,X=QW(X.year,X.month+w);W==="month"&&(Y+=12*U,U=0)}X=QW($.year+U,$.month+Y);let G=gM(X.year,X.month,$.day),H=0,z=MW(T.year,T.month-1,T.day)-MW(G.year,G.month-1,G.day);return W==="week"&&(H=Math.trunc(z/7),z%=7),{years:U,months:Y,weeks:H,days:z}},isoToDate({year:$,month:T,day:W},w){let X={era:void 0,eraYear:void 0,year:$,month:T,day:W,daysInWeek:7,monthsInYear:12};if(w.monthCode&&(X.monthCode=T0(T)),w.dayOfWeek){let U=T+(T<3?10:-2),Y=$-(T<3?1:0),G=Math.floor(Y/100),H=Y-100*G,z=(W+Math.floor(2.6*U-0.2)+(H+Math.floor(H/4))+(Math.floor(G/4)-2*G))%7;X.dayOfWeek=z+(z<=0?7:0)}if(w.dayOfYear){let U=W;for(let Y=T-1;Y>0;Y--)U+=VW($,Y);X.dayOfYear=U}return w.weekOfYear&&(X.weekOfYear=iM("iso8601",{year:$,month:T,day:W})),w.daysInMonth&&(X.daysInMonth=VW($,T)),(w.daysInYear||w.inLeapYear)&&(X.inLeapYear=mG($),X.daysInYear=X.inLeapYear?366:365),X},getFirstDayOfWeek:()=>1,getMinimalDaysInFirstWeek:()=>4};class m4{constructor($){if(this.map=new Map,this.calls=0,this.hits=0,this.misses=0,$!==void 0){let T=0;for(let W of $.map.entries()){if(++T>m4.MAX_CACHE_ENTRIES)break;this.map.set(...W)}}}get($){let T=this.map.get($);return T&&(this.hits++,this.report()),this.calls++,T}set($,T){this.map.set($,T),this.misses++,this.report()}report(){}setObject($){if(m4.objectMap.get($))throw new RangeError("object already cached");m4.objectMap.set($,this),this.report()}static getCacheForObject($){let T=m4.objectMap.get($);return T||(T=new m4,m4.objectMap.set($,T)),T}}function tM({isoYear:$,isoMonth:T,isoDay:W}){return`${lw($)}-${z1(T)}-${z1(W)}T00:00Z`}function tF($,T){return{years:$.year-T.year,months:$.month-T.month,days:$.day-T.day}}m4.objectMap=new WeakMap,m4.MAX_CACHE_ENTRIES=1000;class kT{constructor(){this.eras=[],this.hasEra=!1,this.erasBeginMidYear=!1}getFormatter(){return this.formatter===void 0&&(this.formatter=new Intl.DateTimeFormat(`en-US-u-ca-${this.id}`,{day:"numeric",month:"numeric",year:"numeric",era:"short",timeZone:"UTC"})),this.formatter}getCalendarParts($){let T=this.getFormatter(),W=new Date($);if($==="-271821-04-19T00:00Z"){let w=T.resolvedOptions();T=new Intl.DateTimeFormat(w.locale,{...w,timeZone:"Etc/GMT+1"}),W=new Date("-271821-04-20T00:00Z")}try{return T.formatToParts(W)}catch(w){throw new RangeError(`Invalid ISO date: ${$}`)}}isoToCalendarDate($,T){let{year:W,month:w,day:X}=$,U=JSON.stringify({func:"isoToCalendarDate",isoYear:W,isoMonth:w,isoDay:X,id:this.id}),Y=T.get(U);if(Y)return Y;let G=tM({isoYear:W,isoMonth:w,isoDay:X}),H=this.getCalendarParts(G),z={};for(let O=0;O<H.length;O++){let{type:Q,value:Z}=H[O];if(Q!=="year"&&Q!=="relatedYear"||(this.hasEra?z.eraYear=+Z:z.year=+Z),Q==="month"){let K=/^([0-9]*)(.*?)$/.exec(Z);if(!K||K.length!=3||!K[1]&&!K[2])throw new RangeError(`Unexpected month: ${Z}`);if(z.month=K[1]?+K[1]:1,z.month<1)throw new RangeError(`Invalid month ${Z} from ${G}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10527)`);if(z.month>13)throw new RangeError(`Invalid month ${Z} from ${G}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10529)`);K[2]&&(z.monthExtra=K[2])}Q==="day"&&(z.day=+Z),this.hasEra&&Q==="era"&&Z!=null&&Z!==""&&(z.era=Z.split(" (")[0].normalize("NFD").replace(/[^-0-9 \p{L}]/gu,"").replace(/ /g,"-").toLowerCase())}if(this.hasEra&&z.eraYear===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);if(this.hasEra){let O=this.eras.find((Q)=>z.era===Q.genericName);O&&(z.era=O.code)}if(this.reviseIntlEra){let{era:O,eraYear:Q}=this.reviseIntlEra(z,$);z.era=O,z.eraYear=Q}this.checkIcuBugs&&this.checkIcuBugs($);let F=this.adjustCalendarDate(z,T,"constrain",!0);if(F.year===void 0)throw new RangeError(`Missing year converting ${JSON.stringify($)}`);if(F.month===void 0)throw new RangeError(`Missing month converting ${JSON.stringify($)}`);if(F.day===void 0)throw new RangeError(`Missing day converting ${JSON.stringify($)}`);return T.set(U,F),["constrain","reject"].forEach((O)=>{let Q=JSON.stringify({func:"calendarToIsoDate",year:F.year,month:F.month,day:F.day,overflow:O,id:this.id});T.set(Q,$)}),F}validateCalendarDate($){let{month:T,year:W,day:w,eraYear:X,monthCode:U,monthExtra:Y}=$;if(Y!==void 0)throw new RangeError("Unexpected `monthExtra` value");if(W===void 0&&X===void 0)throw new TypeError("year or eraYear is required");if(T===void 0&&U===void 0)throw new TypeError("month or monthCode is required");if(w===void 0)throw new RangeError("Missing day");if(U!==void 0){if(typeof U!="string")throw new RangeError("monthCode must be a string, not "+typeof U);if(!/^M([01]?\d)(L?)$/.test(U))throw new RangeError(`Invalid monthCode: ${U}`)}if(this.hasEra&&$.era===void 0!=($.eraYear===void 0))throw new TypeError("properties era and eraYear must be provided together")}adjustCalendarDate($,T=void 0,W="constrain",w=!1){if(this.calendarType==="lunisolar")throw new RangeError("Override required for lunisolar calendars");let X=$;this.validateCalendarDate(X);let U=this.monthsInYear(X,T),{month:Y,monthCode:G}=X;return{month:Y,monthCode:G}=PO(X,W,U),{...X,month:Y,monthCode:G}}regulateMonthDayNaive($,T,W){let w=this.monthsInYear($,W),{month:X,day:U}=$;return T==="reject"?(c4(X,1,w),c4(U,1,this.maximumMonthLength($))):(X=L6(X,1,w),U=L6(U,1,this.maximumMonthLength({...$,month:X}))),{...$,month:X,day:U}}calendarToIsoDate($,T="constrain",W){let w=$,X=this.adjustCalendarDate($,W,T,!1);X=this.regulateMonthDayNaive(X,T,W);let{year:U,month:Y,day:G}=X,H=JSON.stringify({func:"calendarToIsoDate",year:U,month:Y,day:G,overflow:T,id:this.id}),z,F=W.get(H);if(F)return F;if(w.year!==void 0&&w.month!==void 0&&w.day!==void 0&&(w.year!==X.year||w.month!==X.month||w.day!==X.day)&&(z=JSON.stringify({func:"calendarToIsoDate",year:w.year,month:w.month,day:w.day,overflow:T,id:this.id}),F=W.get(z),F))return F;let O=this.estimateIsoDate({year:U,month:Y,day:G}),Q=(L)=>{let R=this.addDaysIso(O,L);if(X.day>this.minimumMonthLength(X)){let _=this.isoToCalendarDate(R,W);for(;_.month!==Y||_.year!==U;){if(T==="reject")throw new RangeError(`day ${G} does not exist in month ${Y} of year ${U}`);R=this.addDaysIso(R,-1),_=this.isoToCalendarDate(R,W)}}return R},Z=0,K=this.isoToCalendarDate(O,W),E=tF(X,K);if(E.years!==0||E.months!==0||E.days!==0){let L=365*E.years+30*E.months+E.days;O=this.addDaysIso(O,L),K=this.isoToCalendarDate(O,W),E=tF(X,K),E.years===0&&E.months===0?O=Q(E.days):Z=this.compareCalendarDates(X,K)}let M=8;for(;Z;){O=this.addDaysIso(O,Z*M);let L=K;K=this.isoToCalendarDate(O,W);let R=Z;if(Z=this.compareCalendarDates(X,K),Z){if(E=tF(X,K),E.years===0&&E.months===0)O=Q(E.days),Z=0;else if(R&&Z!==R)if(M>1)M/=2;else{if(T==="reject")throw new RangeError(`Can't find ISO date from calendar date: ${JSON.stringify({...w})}`);this.compareCalendarDates(K,L)>0&&(O=this.addDaysIso(O,-1)),Z=0}}}if(W.set(H,O),z&&W.set(z,O),X.year===void 0||X.month===void 0||X.day===void 0||X.monthCode===void 0||this.hasEra&&(X.era===void 0||X.eraYear===void 0))throw new RangeError("Unexpected missing property");return O}compareCalendarDates($,T){return $.year!==T.year?y6($.year-T.year):$.month!==T.month?y6($.month-T.month):$.day!==T.day?y6($.day-T.day):0}regulateDate($,T="constrain",W){let w=this.calendarToIsoDate($,T,W);return this.isoToCalendarDate(w,W)}addDaysIso($,T){return g6($.year,$.month,$.day+T)}addDaysCalendar($,T,W){let w=this.calendarToIsoDate($,"constrain",W),X=this.addDaysIso(w,T);return this.isoToCalendarDate(X,W)}addMonthsCalendar($,T,W,w){let X=$,{day:U}=X;for(let Y=0,G=Math.abs(T);Y<G;Y++){let{month:H}=X,z=X,F=T<0?-Math.max(U,this.daysInPreviousMonth(X,w)):this.daysInMonth(X,w),O=this.calendarToIsoDate(X,"constrain",w),Q=this.addDaysIso(O,F);if(X=this.isoToCalendarDate(Q,w),T>0){let Z=this.monthsInYear(z,w);for(;X.month-1!=H%Z;)Q=this.addDaysIso(Q,-1),X=this.isoToCalendarDate(Q,w)}X.day!==U&&(X=this.regulateDate({...X,day:U},"constrain",w))}if(W==="reject"&&X.day!==U)throw new RangeError(`Day ${U} does not exist in resulting calendar month`);return X}addCalendar($,{years:T=0,months:W=0,weeks:w=0,days:X=0},U,Y){let{year:G,day:H,monthCode:z}=$,F=this.adjustCalendarDate({year:G+T,monthCode:z,day:H},Y),O=this.addMonthsCalendar(F,W,U,Y),Q=X+7*w;return this.addDaysCalendar(O,Q,Y)}untilCalendar($,T,W,w){let X=0,U=0,Y=0,G=0;switch(W){case"day":X=this.calendarDaysUntil($,T,w);break;case"week":{let H=this.calendarDaysUntil($,T,w);X=H%7,U=(H-X)/7;break}case"month":case"year":{let H=this.compareCalendarDates(T,$);if(!H)return{years:0,months:0,weeks:0,days:0};let z=T.year-$.year,F=T.day-$.day;if(W==="year"&&z){let Z=0;T.monthCode>$.monthCode&&(Z=1),T.monthCode<$.monthCode&&(Z=-1),Z||(Z=Math.sign(F)),G=Z*H<0?z-H:z}let O,Q=G?this.addCalendar($,{years:G},"constrain",w):$;do Y+=H,O=Q,Q=this.addMonthsCalendar(O,H,"constrain",w),Q.day!==$.day&&(Q=this.regulateDate({...Q,day:$.day},"constrain",w));while(this.compareCalendarDates(T,Q)*H>=0);Y-=H,X=this.calendarDaysUntil(O,T,w);break}}return{years:G,months:Y,weeks:U,days:X}}daysInMonth($,T){let{day:W}=$,w=this.maximumMonthLength($),X=this.minimumMonthLength($);if(X===w)return X;let U=W<=w-X?w:X,Y=this.calendarToIsoDate($,"constrain",T),G=this.addDaysIso(Y,U),H=this.isoToCalendarDate(G,T),z=this.addDaysIso(G,-H.day);return this.isoToCalendarDate(z,T).day}daysInPreviousMonth($,T){let{day:W,month:w,year:X}=$,U={year:w>1?X:X-1,month:w,day:1},Y=w>1?w-1:this.monthsInYear(U,T);U={...U,month:Y};let G=this.minimumMonthLength(U),H=this.maximumMonthLength(U);if(G===H)return H;let z=this.calendarToIsoDate($,"constrain",T),F=this.addDaysIso(z,-W);return this.isoToCalendarDate(F,T).day}startOfCalendarYear($){return{year:$.year,month:1,monthCode:"M01",day:1}}startOfCalendarMonth($){return{year:$.year,month:$.month,day:1}}calendarDaysUntil($,T,W){let w=this.calendarToIsoDate($,"constrain",W),X=this.calendarToIsoDate(T,"constrain",W);return MW(X.year,X.month-1,X.day)-MW(w.year,w.month-1,w.day)}monthDaySearchStartYear($,T){return 1972}monthDayFromFields($,T,W){let w,X,U,Y,G,{era:H,eraYear:z,year:F,month:O,monthCode:Q,day:Z}=$;if(O!==void 0&&F===void 0&&(!this.hasEra||H===void 0||z===void 0))throw new TypeError("when month is present, year (or era and eraYear) are required");(Q===void 0||F!==void 0||this.hasEra&&z!==void 0)&&({monthCode:Q,day:Z}=this.isoToCalendarDate(this.calendarToIsoDate($,T,W),W));let K={year:this.monthDaySearchStartYear(Q,Z),month:12,day:31},E=this.isoToCalendarDate(K,W),M=E.monthCode>Q||E.monthCode===Q&&E.day>=Z?E.year:E.year-1;for(let L=0;L<20;L++){let R=this.adjustCalendarDate({day:Z,monthCode:Q,year:M-L},W),_=this.calendarToIsoDate(R,"constrain",W),S=this.isoToCalendarDate(_,W);if({year:w,month:X,day:U}=_,S.monthCode===Q&&S.day===Z)return{month:X,day:U,year:w};if(T==="constrain"){let x=this.maxLengthOfMonthCodeInAnyYear(S.monthCode);if(S.monthCode===Q&&S.day===x&&Z>x)return{month:X,day:U,year:w};(Y===void 0||S.monthCode===Y.monthCode&&S.day>Y.day)&&(Y=S,G=_)}}if(T==="constrain"&&G!==void 0)return G;throw new RangeError(`No recent ${this.id} year with monthCode ${Q} and day ${Z}`)}getFirstDayOfWeek(){}getMinimalDaysInFirstWeek(){}}class aM extends kT{constructor(){super(...arguments),this.id="hebrew",this.calendarType="lunisolar",this.months={Tishri:{leap:1,regular:1,monthCode:"M01",days:30},Heshvan:{leap:2,regular:2,monthCode:"M02",days:{min:29,max:30}},Kislev:{leap:3,regular:3,monthCode:"M03",days:{min:29,max:30}},Tevet:{leap:4,regular:4,monthCode:"M04",days:29},Shevat:{leap:5,regular:5,monthCode:"M05",days:30},Adar:{leap:void 0,regular:6,monthCode:"M06",days:29},"Adar I":{leap:6,regular:void 0,monthCode:"M05L",days:30},"Adar II":{leap:7,regular:void 0,monthCode:"M06",days:29},Nisan:{leap:8,regular:7,monthCode:"M07",days:30},Iyar:{leap:9,regular:8,monthCode:"M08",days:29},Sivan:{leap:10,regular:9,monthCode:"M09",days:30},Tamuz:{leap:11,regular:10,monthCode:"M10",days:29},Av:{leap:12,regular:11,monthCode:"M11",days:30},Elul:{leap:13,regular:12,monthCode:"M12",days:29}}}inLeapYear($){let{year:T}=$;return(7*T+1)%19<7}monthsInYear($){return this.inLeapYear($)?13:12}minimumMonthLength($){return this.minMaxMonthLength($,"min")}maximumMonthLength($){return this.minMaxMonthLength($,"max")}minMaxMonthLength($,T){let{month:W,year:w}=$,X=this.getMonthCode(w,W),U=Object.entries(this.months).find((G)=>G[1].monthCode===X);if(U===void 0)throw new RangeError(`unmatched Hebrew month: ${W}`);let Y=U[1].days;return typeof Y=="number"?Y:Y[T]}maxLengthOfMonthCodeInAnyYear($){return["M04","M06","M08","M10","M12"].includes($)?29:30}estimateIsoDate($){let{year:T}=$;return{year:T-3760,month:1,day:1}}getMonthCode($,T){return this.inLeapYear({year:$})?T===6?T0(5,!0):T0(T<6?T:T-1):T0(T)}adjustCalendarDate($,T,W="constrain",w=!1){let{year:X,month:U,monthCode:Y,day:G,monthExtra:H}=$;if(X===void 0)throw new TypeError("Missing property: year");if(w){if(H){let z=this.months[H];if(!z)throw new RangeError(`Unrecognized month from formatToParts: ${H}`);U=this.inLeapYear({year:X})?z.leap:z.regular}return Y=this.getMonthCode(X,U),{year:X,month:U,day:G,monthCode:Y}}if(this.validateCalendarDate($),U===void 0)if(Y.endsWith("L")){if(Y!=="M05L")throw new RangeError(`Hebrew leap month must have monthCode M05L, not ${Y}`);if(U=6,!this.inLeapYear({year:X})){if(W==="reject")throw new RangeError(`Hebrew monthCode M05L is invalid in year ${X} which is not a leap year`);U=6,Y="M06"}}else{U=NW(Y),this.inLeapYear({year:X})&&U>=6&&U++;let z=this.monthsInYear({year:X});if(U<1||U>z)throw new RangeError(`Invalid monthCode: ${Y}`)}else if(W==="reject"?(c4(U,1,this.monthsInYear({year:X})),c4(G,1,this.maximumMonthLength({year:X,month:U}))):(U=L6(U,1,this.monthsInYear({year:X})),G=L6(G,1,this.maximumMonthLength({year:X,month:U}))),Y===void 0)Y=this.getMonthCode(X,U);else if(this.getMonthCode(X,U)!==Y)throw new RangeError(`monthCode ${Y} doesn't correspond to month ${U} in Hebrew year ${X}`);return{...$,day:G,month:U,monthCode:Y,year:X}}}class RW extends kT{constructor(){super(...arguments),this.calendarType="lunar",this.DAYS_PER_ISLAMIC_YEAR=354.3666666666667,this.DAYS_PER_ISO_YEAR=365.2425}inLeapYear($,T){let W={year:$.year,month:1,monthCode:"M01",day:1},w={year:$.year+1,month:1,monthCode:"M01",day:1};return this.calendarDaysUntil(W,w,T)===355}monthsInYear(){return 12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}maxLengthOfMonthCodeInAnyYear(){return 30}estimateIsoDate($){let{year:T}=this.adjustCalendarDate($);return{year:Math.floor(T*this.DAYS_PER_ISLAMIC_YEAR/this.DAYS_PER_ISO_YEAR)+622,month:1,day:1}}}class sM extends RW{constructor(){super(...arguments),this.id="islamic"}}class eM extends RW{constructor(){super(...arguments),this.id="islamic-umalqura"}}class $D extends RW{constructor(){super(...arguments),this.id="islamic-tbla"}}class TD extends RW{constructor(){super(...arguments),this.id="islamic-civil"}}class WD extends RW{constructor(){super(...arguments),this.id="islamic-rgsa"}}class XD extends RW{constructor(){super(...arguments),this.id="islamicc"}}class wD extends kT{constructor(){super(...arguments),this.id="persian",this.calendarType="solar"}inLeapYear($,T){return this.daysInMonth({year:$.year,month:12,day:1},T)===30}monthsInYear(){return 12}minimumMonthLength($){let{month:T}=$;return T===12?29:T<=6?31:30}maximumMonthLength($){let{month:T}=$;return T===12?30:T<=6?31:30}maxLengthOfMonthCodeInAnyYear($){return NW($)<=6?31:30}estimateIsoDate($){let{year:T}=this.adjustCalendarDate($);return{year:T+621,month:1,day:1}}}class UD extends kT{constructor(){super(...arguments),this.id="indian",this.calendarType="solar",this.months={1:{length:30,month:3,day:22,leap:{length:31,month:3,day:21}},2:{length:31,month:4,day:21},3:{length:31,month:5,day:22},4:{length:31,month:6,day:22},5:{length:31,month:7,day:23},6:{length:31,month:8,day:23},7:{length:30,month:9,day:23},8:{length:30,month:10,day:23},9:{length:30,month:11,day:22},10:{length:30,month:12,day:22},11:{length:30,month:1,nextYear:!0,day:21},12:{length:30,month:2,nextYear:!0,day:20}},this.vulnerableToBceBug=new Date("0000-01-01T00:00Z").toLocaleDateString("en-US-u-ca-indian",{timeZone:"UTC"})!=="10/11/-79 Saka"}inLeapYear($){return CO($.year+78)}monthsInYear(){return 12}minimumMonthLength($){return this.getMonthInfo($).length}maximumMonthLength($){return this.getMonthInfo($).length}maxLengthOfMonthCodeInAnyYear($){let T=NW($),W=this.months[T];return W=W.leap??W,W.length}getMonthInfo($){let{month:T}=$,W=this.months[T];if(W===void 0)throw new RangeError(`Invalid month: ${T}`);return this.inLeapYear($)&&W.leap&&(W=W.leap),W}estimateIsoDate($){let T=this.adjustCalendarDate($),W=this.getMonthInfo(T);return g6(T.year+78+(W.nextYear?1:0),W.month,W.day+T.day-1)}checkIcuBugs($){if(this.vulnerableToBceBug&&$.year<1)throw new RangeError(`calendar '${this.id}' is broken for ISO dates before 0001-01-01 (see https://bugs.chromium.org/p/v8/issues/detail?id=10529)`)}}function CO($){return $%4==0&&($%100!=0||$%400==0)}class SO extends kT{constructor($,T){super(),this.calendarType="solar",this.id=$,this.isoEpoch=T}inLeapYear($){let{year:T}=this.estimateIsoDate({month:1,day:1,year:$.year});return CO(T)}monthsInYear(){return 12}minimumMonthLength($){let{month:T}=$;return T===2?this.inLeapYear($)?29:28:[4,6,9,11].indexOf(T)>=0?30:31}maximumMonthLength($){return this.minimumMonthLength($)}maxLengthOfMonthCodeInAnyYear($){return[31,29,31,30,31,30,31,31,30,31,30,31][NW($)-1]}estimateIsoDate($){let T=this.adjustCalendarDate($);return Rw(T.year+this.isoEpoch.year,T.month+this.isoEpoch.month,T.day+this.isoEpoch.day,"constrain")}}class jO extends kT{constructor($,T){super(),this.hasEra=!0,this.calendarType="solar",this.id=$;let{eras:W,anchorEra:w}=function(X){let U,Y=X;if(Y.length===0)throw new RangeError("Invalid era data: eras are required");if(Y.length===1&&Y[0].reverseOf)throw new RangeError("Invalid era data: anchor era cannot count years backwards");if(Y.length===1&&!Y[0].code)throw new RangeError("Invalid era data: at least one named era is required");if(Y.filter((H)=>H.reverseOf!=null).length>1)throw new RangeError("Invalid era data: only one era can count years backwards");Y.forEach((H)=>{if(H.isAnchor||!H.anchorEpoch&&!H.reverseOf){if(U)throw new RangeError("Invalid era data: cannot have multiple anchor eras");U=H,H.anchorEpoch={year:H.hasYearZero?0:1}}else if(!H.code)throw new RangeError("If era name is blank, it must be the anchor era")}),Y=Y.filter((H)=>H.code),Y.forEach((H)=>{let{reverseOf:z}=H;if(z){let F=Y.find((O)=>O.code===z);if(F===void 0)throw new RangeError(`Invalid era data: unmatched reverseOf era: ${z}`);H.reverseOf=F,H.anchorEpoch=F.anchorEpoch,H.isoEpoch=F.isoEpoch}H.anchorEpoch.month===void 0&&(H.anchorEpoch.month=1),H.anchorEpoch.day===void 0&&(H.anchorEpoch.day=1)}),Y.sort((H,z)=>{if(H.reverseOf)return 1;if(z.reverseOf)return-1;if(!H.isoEpoch||!z.isoEpoch)throw new RangeError("Invalid era data: missing ISO epoch");return z.isoEpoch.year-H.isoEpoch.year});let G=Y[Y.length-1].reverseOf;if(G&&G!==Y[Y.length-2])throw new RangeError("Invalid era data: invalid reverse-sign era");return Y.forEach((H,z)=>{H.genericName="era"+(Y.length-1-z)}),{eras:Y,anchorEra:U||Y[0]}}(T);this.anchorEra=w,this.eras=W}inLeapYear($){let{year:T}=this.estimateIsoDate({month:1,day:1,year:$.year});return CO(T)}monthsInYear(){return 12}minimumMonthLength($){let{month:T}=$;return T===2?this.inLeapYear($)?29:28:[4,6,9,11].indexOf(T)>=0?30:31}maximumMonthLength($){return this.minimumMonthLength($)}maxLengthOfMonthCodeInAnyYear($){return[31,29,31,30,31,30,31,31,30,31,30,31][NW($)-1]}completeEraYear($){let T=(Y,G,H)=>{let z=$[Y];if(z!=null&&z!=G&&!(H||[]).includes(z)){let F=H?.[0];throw new RangeError(`Input ${Y} ${z} doesn't match calculated value ${F?`${G} (also called ${F})`:G}`)}},W=(Y)=>{let G,H={...$,year:Y},z=this.eras.find((F,O)=>{if(O===this.eras.length-1){if(F.reverseOf){if(Y>0)throw new RangeError(`Signed year ${Y} is invalid for era ${F.code}`);return G=F.anchorEpoch.year-Y,!0}return G=Y-F.anchorEpoch.year+(F.hasYearZero?0:1),!0}return this.compareCalendarDates(H,F.anchorEpoch)>=0&&(G=Y-F.anchorEpoch.year+(F.hasYearZero?0:1),!0)});if(!z)throw new RangeError(`Year ${Y} was not matched by any era`);return{eraYear:G,era:z.code,eraNames:z.names}},{year:w,eraYear:X,era:U}=$;if(w!=null){let Y=W(w);({eraYear:X,era:U}=Y),T("era",U,Y?.eraNames),T("eraYear",X)}else{if(X==null)throw new RangeError("Either year or eraYear and era are required");{if(U===void 0)throw new RangeError("era and eraYear must be provided together");let Y=this.eras.find(({code:G,names:H=[]})=>G===U||H.includes(U));if(!Y)throw new RangeError(`Era ${U} (ISO year ${X}) was not matched by any era`);w=Y.reverseOf?Y.anchorEpoch.year-X:X+Y.anchorEpoch.year-(Y.hasYearZero?0:1),T("year",w),{eraYear:X,era:U}=W(w)}}return{...$,year:w,eraYear:X,era:U}}adjustCalendarDate($,T,W="constrain"){let w=$,{month:X,monthCode:U}=w;return X===void 0&&(w={...w,month:NW(U)}),this.validateCalendarDate(w),w=this.completeEraYear(w),super.adjustCalendarDate(w,T,W)}estimateIsoDate($){let T=this.adjustCalendarDate($),{year:W,month:w,day:X}=T,{anchorEra:U}=this;return Rw(W+U.isoEpoch.year-(U.hasYearZero?0:1),w,X,"constrain")}}class X9 extends jO{constructor($,T){super($,T)}isoToCalendarDate($){let{year:T,month:W,day:w}=$,X=T0(W),U=T-this.anchorEra.isoEpoch.year+1;return this.completeEraYear({year:U,month:W,monthCode:X,day:w})}}var e1={inLeapYear($){let{year:T}=$;return(T+1)%4==0},monthsInYear:()=>13,minimumMonthLength($){let{month:T}=$;return T===13?this.inLeapYear($)?6:5:30},maximumMonthLength($){return this.minimumMonthLength($)},maxLengthOfMonthCodeInAnyYear:($)=>$==="M13"?6:30};class YD extends SO{constructor($,T){super($,T),this.inLeapYear=e1.inLeapYear,this.monthsInYear=e1.monthsInYear,this.minimumMonthLength=e1.minimumMonthLength,this.maximumMonthLength=e1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=e1.maxLengthOfMonthCodeInAnyYear}}class IO extends jO{constructor($,T){super($,T),this.inLeapYear=e1.inLeapYear,this.monthsInYear=e1.monthsInYear,this.minimumMonthLength=e1.minimumMonthLength,this.maximumMonthLength=e1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=e1.maxLengthOfMonthCodeInAnyYear}}class GD extends YD{constructor(){super("ethioaa",{year:-5492,month:7,day:17})}}class zD extends IO{constructor(){super("coptic",[{code:"coptic",isoEpoch:{year:284,month:8,day:29}},{code:"coptic-inverse",reverseOf:"coptic"}])}}class HD extends IO{constructor(){super("ethiopic",[{code:"ethioaa",names:["ethiopic-amete-alem","mundi"],isoEpoch:{year:-5492,month:7,day:17}},{code:"ethiopic",names:["incar"],isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}}class FD extends X9{constructor(){super("roc",[{code:"roc",names:["minguo"],isoEpoch:{year:1912,month:1,day:1}},{code:"roc-inverse",names:["before-roc"],reverseOf:"roc"}])}}class OD extends SO{constructor(){super("buddhist",{year:-543,month:1,day:1})}}class QD extends X9{constructor(){super("gregory",[{code:"gregory",names:["ad","ce"],isoEpoch:{year:1,month:1,day:1}},{code:"gregory-inverse",names:["be","bce"],reverseOf:"gregory"}])}reviseIntlEra($){let{era:T,eraYear:W}=$;return T==="b"&&(T="gregory-inverse"),T==="a"&&(T="gregory"),{era:T,eraYear:W}}getFirstDayOfWeek(){return 1}getMinimalDaysInFirstWeek(){return 1}}class ZD extends X9{constructor(){super("japanese",[{code:"reiwa",isoEpoch:{year:2019,month:5,day:1},anchorEpoch:{year:2019,month:5,day:1}},{code:"heisei",isoEpoch:{year:1989,month:1,day:8},anchorEpoch:{year:1989,month:1,day:8}},{code:"showa",isoEpoch:{year:1926,month:12,day:25},anchorEpoch:{year:1926,month:12,day:25}},{code:"taisho",isoEpoch:{year:1912,month:7,day:30},anchorEpoch:{year:1912,month:7,day:30}},{code:"meiji",isoEpoch:{year:1868,month:9,day:8},anchorEpoch:{year:1868,month:9,day:8}},{code:"japanese",names:["japanese","gregory","ad","ce"],isoEpoch:{year:1,month:1,day:1}},{code:"japanese-inverse",names:["japanese-inverse","gregory-inverse","bc","bce"],reverseOf:"japanese"}]),this.erasBeginMidYear=!0}reviseIntlEra($,T){let{era:W,eraYear:w}=$,{year:X}=T;return this.eras.find((U)=>U.code===W)?{era:W,eraYear:w}:X<1?{era:"japanese-inverse",eraYear:1-X}:{era:"japanese",eraYear:X}}}class BO extends kT{constructor(){super(...arguments),this.calendarType="lunisolar"}inLeapYear($,T){let W=this.getMonthList($.year,T);return Object.entries(W).length===13}monthsInYear($,T){return this.inLeapYear($,T)?13:12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}maxLengthOfMonthCodeInAnyYear($){return["M01L","M09L","M10L","M11L","M12L"].includes($)?29:30}monthDaySearchStartYear($,T){let W={M01L:[1651,1651],M02L:[1947,1765],M03L:[1966,1955],M04L:[1963,1944],M05L:[1971,1952],M06L:[1960,1941],M07L:[1968,1938],M08L:[1957,1718],M09L:[1832,1832],M10L:[1870,1870],M11L:[1814,1814],M12L:[1890,1890]}[$]??[1972,1972];return T<30?W[0]:W[1]}getMonthList($,T){if($===void 0)throw new TypeError("Missing year");let W=JSON.stringify({func:"getMonthList",calendarYear:$,id:this.id}),w=T.get(W);if(w)return w;let X=this.getFormatter(),U=(E,M)=>{let L=tM({isoYear:E,isoMonth:2,isoDay:1}),R=new Date(L);R.setUTCDate(M+1);let _=X.formatToParts(R),S=_.find((T$)=>T$.type==="month").value,x=+_.find((T$)=>T$.type==="day").value,b=_.find((T$)=>T$.type==="relatedYear"),g;if(b===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);return g=+b.value,{calendarMonthString:S,calendarDay:x,calendarYearToVerify:g}},Y=17,{calendarMonthString:G,calendarDay:H,calendarYearToVerify:z}=U($,Y);G!=="1"&&(Y+=29,{calendarMonthString:G,calendarDay:H}=U($,Y)),Y-=H-5;let F={},O,Q,Z=1,K=!1;do({calendarMonthString:G,calendarDay:H,calendarYearToVerify:z}=U($,Y)),O&&(F[Q].daysInMonth=O+30-H),z!==$?K=!0:(F[G]={monthIndex:Z++},Y+=30),O=H,Q=G;while(!K);return F[Q].daysInMonth=O+30-H,T.set(W,F),F}estimateIsoDate($){let{year:T,month:W}=$;return{year:T,month:W>=12?12:W+1,day:1}}adjustCalendarDate($,T,W="constrain",w=!1){let{year:X,month:U,monthExtra:Y,day:G,monthCode:H}=$;if(X===void 0)throw new TypeError("Missing property: year");if(w){if(Y&&Y!=="bis")throw new RangeError(`Unexpected leap month suffix: ${Y}`);let z=T0(U,Y!==void 0),F=`${U}${Y||""}`,O=this.getMonthList(X,T)[F];if(O===void 0)throw new RangeError(`Unmatched month ${F} in Chinese year ${X}`);return U=O.monthIndex,{year:X,month:U,day:G,monthCode:z}}if(this.validateCalendarDate($),U===void 0){let z=this.getMonthList(X,T),F=H.replace(/^M|L$/g,(Q)=>Q==="L"?"bis":"");F[0]==="0"&&(F=F.slice(1));let O=z[F];if(U=O&&O.monthIndex,U===void 0&&H.endsWith("L")&&H!="M13L"&&W==="constrain"){let Q=+H.replace(/^M0?|L$/g,"");O=z[Q],O&&(U=O.monthIndex,H=T0(Q))}if(U===void 0)throw new RangeError(`Unmatched month ${H} in Chinese year ${X}`)}else if(H===void 0){let z=this.getMonthList(X,T),F=Object.entries(z),O=F.length;W==="reject"?(c4(U,1,O),c4(G,1,this.maximumMonthLength())):(U=L6(U,1,O),G=L6(G,1,this.maximumMonthLength()));let Q=F.find((Z)=>Z[1].monthIndex===U);if(Q===void 0)throw new RangeError(`Invalid month ${U} in Chinese year ${X}`);H=T0(+Q[0].replace("bis",""),Q[0].indexOf("bis")!==-1)}else{let z=this.getMonthList(X,T),F=H.replace(/^M|L$/g,(Q)=>Q==="L"?"bis":"");F[0]==="0"&&(F=F.slice(1));let O=z[F];if(!O)throw new RangeError(`Unmatched monthCode ${H} in Chinese year ${X}`);if(U!==O.monthIndex)throw new RangeError(`monthCode ${H} doesn't correspond to month ${U} in Chinese year ${X}`)}return{...$,year:X,month:U,monthCode:H,day:G}}}class VD extends BO{constructor(){super(...arguments),this.id="chinese"}}class KD extends BO{constructor(){super(...arguments),this.id="dangi"}}class AD{constructor($){this.helper=$}extraFields($){return this.helper.hasEra&&$.includes("year")?["era","eraYear"]:[]}resolveFields($){if(this.helper.calendarType!=="lunisolar"){let T=new m4;PO($,void 0,this.helper.monthsInYear({year:$.year??1972},T))}}dateToISO($,T){let W=new m4,w=this.helper.calendarToIsoDate($,T,W);return W.setObject(w),w}monthDayToISOReferenceDate($,T){let W=new m4,w=this.helper.monthDayFromFields($,T,W);return W.setObject(w),w}fieldKeysToIgnore($){let T=new Set;for(let W=0;W<$.length;W++){let w=$[W];switch(T.add(w),w){case"era":T.add("eraYear"),T.add("year");break;case"eraYear":T.add("era"),T.add("year");break;case"year":T.add("era"),T.add("eraYear");break;case"month":T.add("monthCode"),this.helper.erasBeginMidYear&&(T.add("era"),T.add("eraYear"));break;case"monthCode":T.add("month"),this.helper.erasBeginMidYear&&(T.add("era"),T.add("eraYear"));break;case"day":this.helper.erasBeginMidYear&&(T.add("era"),T.add("eraYear"))}}return nM(T)}dateAdd($,{years:T,months:W,weeks:w,days:X},U){let Y=m4.getCacheForObject($),G=this.helper.isoToCalendarDate($,Y),H=this.helper.addCalendar(G,{years:T,months:W,weeks:w,days:X},U,Y),z=this.helper.calendarToIsoDate(H,"constrain",Y);return m4.getCacheForObject(z)||new m4(Y).setObject(z),z}dateUntil($,T,W){let w=m4.getCacheForObject($),X=m4.getCacheForObject(T),U=this.helper.isoToCalendarDate($,w),Y=this.helper.isoToCalendarDate(T,X);return this.helper.untilCalendar(U,Y,W,w)}isoToDate($,T){let W=m4.getCacheForObject($),w=this.helper.isoToCalendarDate($,W);if(T.dayOfWeek&&(w.dayOfWeek=rw.iso8601.isoToDate($,{dayOfWeek:!0}).dayOfWeek),T.dayOfYear){let X=this.helper.startOfCalendarYear(w),U=this.helper.calendarDaysUntil(X,w,W);w.dayOfYear=U+1}if(T.weekOfYear&&(w.weekOfYear=iM(this.helper.id,$)),w.daysInWeek=7,T.daysInMonth&&(w.daysInMonth=this.helper.daysInMonth(w,W)),T.daysInYear){let X=this.helper.startOfCalendarYear(w),U=this.helper.addCalendar(X,{years:1},"constrain",W);w.daysInYear=this.helper.calendarDaysUntil(X,U,W)}return T.monthsInYear&&(w.monthsInYear=this.helper.monthsInYear(w,W)),T.inLeapYear&&(w.inLeapYear=this.helper.inLeapYear(w,W)),w}getFirstDayOfWeek(){return this.helper.getFirstDayOfWeek()}getMinimalDaysInFirstWeek(){return this.helper.getMinimalDaysInFirstWeek()}}for(let $ of[aM,wD,HD,GD,zD,VD,KD,FD,UD,OD,QD,ZD,sM,eM,$D,TD,WD,XD]){let T=new $;rw[T.id]=new AD(T)}XO("calendarImpl",function($){return rw[$]});var xw=Intl.DateTimeFormat;function L2($,T){let W=V($,T);return typeof W=="function"&&(W=new xw(V($,OM),W(V($,eF))),function(w,X,U){let Y=oG(w);if(Y===void 0)throw new TypeError("Missing slots for the given container");if(Y[X]===void 0)throw new TypeError(`tried to reset ${X} which was not set`);Y[X]=U}($,T,W)),W}function Ow($){return k6($,LW)}class b2{constructor($=void 0,T=void 0){(function(W,w,X){let U=X!==void 0,Y;if(U){let F=["localeMatcher","calendar","numberingSystem","hour12","hourCycle","timeZone","weekday","era","year","month","day","dayPeriod","hour","minute","second","fractionalSecondDigits","timeZoneName","formatMatcher","dateStyle","timeStyle"];Y=function(Q){if(Q==null)throw new TypeError(`Expected object not ${Q}`);return Object(Q)}(X);let O=Object.create(null);for(let Q=0;Q<F.length;Q++){let Z=F[Q];Object.prototype.hasOwnProperty.call(Y,Z)&&(O[Z]=Y[Z])}Y=O}else Y=Object.create(null);let G=new xw(w,Y),H=G.resolvedOptions();if(f0(W),U){let F=Object.assign(Object.create(null),H);for(let O in F)Object.prototype.hasOwnProperty.call(Y,O)||delete F[O];F.hour12=Y.hour12,F.hourCycle=Y.hourCycle,_$(W,eF,F)}else _$(W,eF,Y);_$(W,OM,H.locale),_$(W,LW,G),_$(W,_2,H.timeZone),_$(W,Zw,H.calendar),_$(W,UM,LI),_$(W,YM,DI),_$(W,GM,NI),_$(W,zM,MI),_$(W,HM,JI),_$(W,FM,RI);let z=U?Y.timeZone:void 0;if(z===void 0)_$(W,sF,H.timeZone);else{let F=iG(z);if(F.startsWith("\u2212"))throw new RangeError("Unicode minus (U+2212) is not supported in time zone offsets");_$(W,sF,R6(F))}})(this,$,T)}get format(){C(this,Ow);let $=VI.bind(this);return Object.defineProperties($,{length:{value:1,enumerable:!1,writable:!1,configurable:!0},name:{value:"",enumerable:!1,writable:!1,configurable:!0}}),$}formatRange($,T){return C(this,Ow),AI.call(this,$,T)}formatToParts($,...T){return C(this,Ow),KI.call(this,$,...T)}formatRangeToParts($,T){return C(this,Ow),EI.call(this,$,T)}resolvedOptions(){return C(this,Ow),ZI.call(this)}}"formatToParts"in xw.prototype||delete b2.prototype.formatToParts,"formatRangeToParts"in xw.prototype||delete b2.prototype.formatRangeToParts;var Y1=function($=void 0,T=void 0){return new b2($,T)};function ZI(){let $=V(this,LW).resolvedOptions();return $.timeZone=V(this,sF),$}function VI($,...T){let W,w,X=y2($,this);return X.formatter?(W=X.formatter,w=[D1(X.epochNs,"floor")]):(W=V(this,LW),w=[$,...T]),W.format(...w)}function KI($,...T){let W,w,X=y2($,this);return X.formatter?(W=X.formatter,w=[D1(X.epochNs,"floor")]):(W=V(this,LW),w=[$,...T]),W.formatToParts(...w)}function AI($,T){if($===void 0||T===void 0)throw new TypeError("Intl.DateTimeFormat.formatRange requires two values");let W=dG($),w=dG(T),X,U=[W,w];if(B0(W)!==B0(w))throw new TypeError("Intl.DateTimeFormat.formatRange accepts two values of the same type");if(B0(W)){if(!ED(W,w))throw new TypeError("Intl.DateTimeFormat.formatRange accepts two values of the same type");let{epochNs:Y,formatter:G}=y2(W,this),{epochNs:H,formatter:z}=y2(w,this);G&&(X=G,U=[D1(Y,"floor"),D1(H,"floor")])}return X||(X=V(this,LW)),X.formatRange(...U)}function EI($,T){if($===void 0||T===void 0)throw new TypeError("Intl.DateTimeFormat.formatRange requires two values");let W=dG($),w=dG(T),X,U=[W,w];if(B0(W)!==B0(w))throw new TypeError("Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type");if(B0(W)){if(!ED(W,w))throw new TypeError("Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type");let{epochNs:Y,formatter:G}=y2(W,this),{epochNs:H,formatter:z}=y2(w,this);G&&(X=G,U=[D1(Y,"floor"),D1(H,"floor")])}return X||(X=V(this,LW)),X.formatRangeToParts(...U)}function nw($={},T={}){let W=Object.assign({},$),w=["year","month","day","hour","minute","second","weekday","dayPeriod","timeZoneName","dateStyle","timeStyle"];for(let X=0;X<w.length;X++){let U=w[X];W[U]=U in T?T[U]:W[U],W[U]!==!1&&W[U]!==void 0||delete W[U]}return W}function MI($){let T=nw($,{year:!1,month:!1,day:!1,weekday:!1,timeZoneName:!1,dateStyle:!1});if(T.timeStyle!=="long"&&T.timeStyle!=="full"||(delete T.timeStyle,Object.assign(T,{hour:"numeric",minute:"2-digit",second:"2-digit"})),!U9(T)){if(iw($))throw new TypeError(`cannot format Temporal.PlainTime with options [${Object.keys($)}]`);Object.assign(T,{hour:"numeric",minute:"numeric",second:"numeric"})}return T}function DI($){let T={short:{year:"2-digit",month:"numeric"},medium:{year:"numeric",month:"short"},long:{year:"numeric",month:"long"},full:{year:"numeric",month:"long"}},W=nw($,{day:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if("dateStyle"in W&&W.dateStyle){let w=W.dateStyle;delete W.dateStyle,Object.assign(W,T[w])}if(!(("year"in W)||("month"in W)||("era"in W))){if(iw($))throw new TypeError(`cannot format PlainYearMonth with options [${Object.keys($)}]`);Object.assign(W,{year:"numeric",month:"numeric"})}return W}function NI($){let T={short:{month:"numeric",day:"numeric"},medium:{month:"short",day:"numeric"},long:{month:"long",day:"numeric"},full:{month:"long",day:"numeric"}},W=nw($,{year:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if("dateStyle"in W&&W.dateStyle){let w=W.dateStyle;delete W.dateStyle,Object.assign(W,T[w])}if(!("month"in W)&&!("day"in W)){if(iw($))throw new TypeError(`cannot format PlainMonthDay with options [${Object.keys($)}]`);Object.assign(W,{month:"numeric",day:"numeric"})}return W}function LI($){let T=nw($,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if(!w9(T)){if(iw($))throw new TypeError(`cannot format PlainDate with options [${Object.keys($)}]`);Object.assign(T,{year:"numeric",month:"numeric",day:"numeric"})}return T}function JI($){let T=nw($,{timeZoneName:!1});if((T.timeStyle==="long"||T.timeStyle==="full")&&(delete T.timeStyle,Object.assign(T,{hour:"numeric",minute:"2-digit",second:"2-digit"}),T.dateStyle))Object.assign(T,{short:{year:"numeric",month:"numeric",day:"numeric"},medium:{year:"numeric",month:"short",day:"numeric"},long:{year:"numeric",month:"long",day:"numeric"},full:{year:"numeric",month:"long",day:"numeric",weekday:"long"}}[T.dateStyle]),delete T.dateStyle;if(!U9(T)&&!w9(T)){if(iw($))throw new TypeError(`cannot format PlainDateTime with options [${Object.keys($)}]`);Object.assign(T,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}return T}function RI($){let T=$;return U9(T)||w9(T)||(T=Object.assign({},T,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),T}function w9($){return"year"in $||"month"in $||"day"in $||"weekday"in $||"dateStyle"in $||"era"in $}function U9($){return"hour"in $||"minute"in $||"second"in $||"timeStyle"in $||"dayPeriod"in $||"fractionalSecondDigits"in $}function iw($){return w9($)||U9($)||"dateStyle"in $||"timeStyle"in $||"timeZoneName"in $}function B0($){return F4($)||A4($)||i$($)||v$($)||r4($)||w1($)||l4($)}function dG($){return B0($)?$:nG($)}function ED($,T){return!(!B0($)||!B0(T)||A4($)&&!A4(T)||F4($)&&!F4(T)||i$($)&&!i$(T)||v$($)&&!v$(T)||r4($)&&!r4(T)||w1($)&&!w1(T)||l4($)&&!l4(T))}function y2($,T){if(A4($)){let W={isoDate:{year:1970,month:1,day:1},time:V($,O4)};return{epochNs:T6(V(T,_2),W,"compatible"),formatter:L2(T,zM)}}if(r4($)){let W=V($,u),w=V(T,Zw);if(W!==w)throw new RangeError(`cannot format PlainYearMonth with calendar ${W} in locale with calendar ${w}`);let X=x$(V($,V$),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:T6(V(T,_2),X,"compatible"),formatter:L2(T,YM)}}if(w1($)){let W=V($,u),w=V(T,Zw);if(W!==w)throw new RangeError(`cannot format PlainMonthDay with calendar ${W} in locale with calendar ${w}`);let X=x$(V($,V$),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:T6(V(T,_2),X,"compatible"),formatter:L2(T,GM)}}if(F4($)){let W=V($,u),w=V(T,Zw);if(W!=="iso8601"&&W!==w)throw new RangeError(`cannot format PlainDate with calendar ${W} in locale with calendar ${w}`);let X=x$(V($,V$),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:T6(V(T,_2),X,"compatible"),formatter:L2(T,UM)}}if(i$($)){let W=V($,u),w=V(T,Zw);if(W!=="iso8601"&&W!==w)throw new RangeError(`cannot format PlainDateTime with calendar ${W} in locale with calendar ${w}`);let X=V($,X4);return{epochNs:T6(V(T,_2),X,"compatible"),formatter:L2(T,HM)}}if(v$($))throw new TypeError("Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.");return l4($)?{epochNs:V($,Z$),formatter:L2(T,FM)}:{}}function MD($){let T=Object.create(null);return T.years=V($,Z6),T.months=V($,V6),T.weeks=V($,f6),T.days=V($,K6),T.hours=V($,A6),T.minutes=V($,E6),T.seconds=V($,M6),T.milliseconds=V($,D6),T.microseconds=V($,N6),T.nanoseconds=V($,b6),T}b2.prototype.constructor=Y1,Object.defineProperty(Y1,"prototype",{value:b2.prototype,writable:!1,enumerable:!1,configurable:!1}),Y1.supportedLocalesOf=xw.supportedLocalesOf,b0(Y1,"Intl.DateTimeFormat");var{format:_I,formatToParts:kI}=Intl.DurationFormat?.prototype??Object.create(null);function xO($){Intl.DurationFormat.prototype.resolvedOptions.call(this);let T=MD(E1($));return _I.call(this,T)}Intl.DurationFormat?.prototype&&(Intl.DurationFormat.prototype.format=xO,Intl.DurationFormat.prototype.formatToParts=function($){Intl.DurationFormat.prototype.resolvedOptions.call(this);let T=MD(E1($));return kI.call(this,T)});var bt=Object.freeze({__proto__:null,DateTimeFormat:Y1,ModifiedIntlDurationFormatPrototypeFormat:xO});class Y9{constructor($){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");SM(this,pG($))}get epochMilliseconds(){return C(this,l4),D1(V(this,Z$),"floor")}get epochNanoseconds(){return C(this,l4),lM(P.BigInt(V(this,Z$)))}add($){return C(this,l4),lE("add",this,$)}subtract($){return C(this,l4),lE("subtract",this,$)}until($,T=void 0){return C(this,l4),gE("until",this,$,T)}since($,T=void 0){return C(this,l4),gE("since",this,$,T)}round($){if(C(this,l4),$===void 0)throw new TypeError("options parameter is required");let T=typeof $=="string"?DW("smallestUnit",$):X$($),W=m2(T),w=x1(T,"halfExpand"),X=h6(T,"smallestUnit","time",x0);return c2(W,{hour:24,minute:1440,second:86400,millisecond:86400000,microsecond:86400000000,nanosecond:86400000000000}[X],!0),I1(ZO(V(this,Z$),W,X,w))}equals($){C(this,l4);let T=Aw($),W=V(this,Z$),w=V(T,Z$);return P.equal(P.BigInt(W),P.BigInt(w))}toString($=void 0){C(this,l4);let T=X$($),W=gw(T),w=x1(T,"trunc"),X=h6(T,"smallestUnit","time",void 0);if(X==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let U=T.timeZone;U!==void 0&&(U=R6(U));let{precision:Y,unit:G,increment:H}=mw(X,W);return SE(I1(ZO(V(this,Z$),H,G,w)),U,Y)}toJSON(){return C(this,l4),SE(this,void 0,"auto")}toLocaleString($=void 0,T=void 0){return C(this,l4),new Y1($,T).format(this)}valueOf(){_T("Instant")}toZonedDateTimeISO($){C(this,l4);let T=R6($);return e4(V(this,Z$),T,"iso8601")}static fromEpochMilliseconds($){return I1(B1(nG($)))}static fromEpochNanoseconds($){return I1(pG($))}static from($){return Aw($)}static compare($,T){let W=Aw($),w=Aw(T),X=V(W,Z$),U=V(w,Z$);return P.lessThan(X,U)?-1:P.greaterThan(X,U)?1:0}}b0(Y9,"Temporal.Instant");class G9{constructor($,T,W,w="iso8601"){let X=A$($),U=A$(T),Y=A$(W),G=v6(w===void 0?"iso8601":I4(w));AW(X,U,Y),kM(this,{year:X,month:U,day:Y},G)}get calendarId(){return C(this,F4),V(this,u)}get era(){return F6(this,"era")}get eraYear(){return F6(this,"eraYear")}get year(){return F6(this,"year")}get month(){return F6(this,"month")}get monthCode(){return F6(this,"monthCode")}get day(){return F6(this,"day")}get dayOfWeek(){return F6(this,"dayOfWeek")}get dayOfYear(){return F6(this,"dayOfYear")}get weekOfYear(){return F6(this,"weekOfYear")?.week}get yearOfWeek(){return F6(this,"weekOfYear")?.year}get daysInWeek(){return F6(this,"daysInWeek")}get daysInMonth(){return F6(this,"daysInMonth")}get daysInYear(){return F6(this,"daysInYear")}get monthsInYear(){return F6(this,"monthsInYear")}get inLeapYear(){return F6(this,"inLeapYear")}with($,T=void 0){if(C(this,F4),!Q4($))throw new TypeError("invalid argument");g2($);let W=V(this,u),w=_6(W,V(this,V$));return w=KW(W,w,H1(W,$,["year","month","monthCode","day"],[],"partial")),J6(JT(W,w,j$(X$(T))),W)}withCalendar($){C(this,F4);let T=dw($);return J6(V(this,V$),T)}add($,T=void 0){return C(this,F4),rE("add",this,$,T)}subtract($,T=void 0){return C(this,F4),rE("subtract",this,$,T)}until($,T=void 0){return C(this,F4),mE("until",this,$,T)}since($,T=void 0){return C(this,F4),mE("since",this,$,T)}equals($){C(this,F4);let T=Vw($);return w0(V(this,V$),V(T,V$))===0&&W0(V(this,u),V(T,u))}toString($=void 0){return C(this,F4),jE(this,hw(X$($)))}toJSON(){return C(this,F4),jE(this)}toLocaleString($=void 0,T=void 0){return C(this,F4),new Y1($,T).format(this)}valueOf(){_T("PlainDate")}toPlainDateTime($=void 0){C(this,F4);let T=_M($);return K1(x$(V(this,V$),T),V(this,u))}toZonedDateTime($){let T,W;if(C(this,F4),Q4($)){let U=$.timeZone;U===void 0?T=R6($):(T=R6(U),W=$.plainTime)}else T=R6($);let w=V(this,V$),X;return W===void 0?X=KT(T,w):(W=ET(W),X=T6(T,x$(w,V(W,O4)),"compatible")),e4(X,T,V(this,u))}toPlainYearMonth(){C(this,F4);let $=V(this,u);return P2(Cw($,_6($,V(this,V$)),"constrain"),$)}toPlainMonthDay(){C(this,F4);let $=V(this,u);return q2(hG($,_6($,V(this,V$)),"constrain"),$)}static from($,T=void 0){return Vw($,T)}static compare($,T){let W=Vw($),w=Vw(T);return w0(V(W,V$),V(w,V$))}}function F6($,T){C($,F4);let W=V($,V$);return cw($).isoToDate(W,{[T]:!0})[T]}b0(G9,"Temporal.PlainDate");class z9{constructor($,T,W,w=0,X=0,U=0,Y=0,G=0,H=0,z="iso8601"){let F=A$($),O=A$(T),Q=A$(W),Z=w===void 0?0:A$(w),K=X===void 0?0:A$(X),E=U===void 0?0:A$(U),M=Y===void 0?0:A$(Y),L=G===void 0?0:A$(G),R=H===void 0?0:A$(H),_=v6(z===void 0?"iso8601":I4(z));_O(F,O,Q,Z,K,E,M,L,R),vM(this,{isoDate:{year:F,month:O,day:Q},time:{hour:Z,minute:K,second:E,millisecond:M,microsecond:L,nanosecond:R}},_)}get calendarId(){return C(this,i$),V(this,u)}get year(){return O6(this,"year")}get month(){return O6(this,"month")}get monthCode(){return O6(this,"monthCode")}get day(){return O6(this,"day")}get hour(){return J2(this,"hour")}get minute(){return J2(this,"minute")}get second(){return J2(this,"second")}get millisecond(){return J2(this,"millisecond")}get microsecond(){return J2(this,"microsecond")}get nanosecond(){return J2(this,"nanosecond")}get era(){return O6(this,"era")}get eraYear(){return O6(this,"eraYear")}get dayOfWeek(){return O6(this,"dayOfWeek")}get dayOfYear(){return O6(this,"dayOfYear")}get weekOfYear(){return O6(this,"weekOfYear")?.week}get yearOfWeek(){return O6(this,"weekOfYear")?.year}get daysInWeek(){return O6(this,"daysInWeek")}get daysInYear(){return O6(this,"daysInYear")}get daysInMonth(){return O6(this,"daysInMonth")}get monthsInYear(){return O6(this,"monthsInYear")}get inLeapYear(){return O6(this,"inLeapYear")}with($,T=void 0){if(C(this,i$),!Q4($))throw new TypeError("invalid argument");g2($);let W=V(this,u),w=V(this,X4),X={..._6(W,w.isoDate),...w.time};return X=KW(W,X,H1(W,$,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond"],"partial")),K1(uw(W,X,j$(X$(T))),W)}withPlainTime($=void 0){C(this,i$);let T=_M($);return K1(x$(V(this,X4).isoDate,T),V(this,u))}withCalendar($){C(this,i$);let T=dw($);return K1(V(this,X4),T)}add($,T=void 0){return C(this,i$),nE("add",this,$,T)}subtract($,T=void 0){return C(this,i$),nE("subtract",this,$,T)}until($,T=void 0){return C(this,i$),cE("until",this,$,T)}since($,T=void 0){return C(this,i$),cE("since",this,$,T)}round($){if(C(this,i$),$===void 0)throw new TypeError("options parameter is required");let T=typeof $=="string"?DW("smallestUnit",$):X$($),W=m2(T),w=x1(T,"halfExpand"),X=h6(T,"smallestUnit","time",x0,["day"]),U={day:1,hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[X];c2(W,U,U===1);let Y=V(this,X4);return K1(W===1&&X==="nanosecond"?Y:VO(Y,W,X,w),V(this,u))}equals($){C(this,i$);let T=Kw($);return f2(V(this,X4),V(T,X4))===0&&W0(V(this,u),V(T,u))}toString($=void 0){C(this,i$);let T=X$($),W=hw(T),w=gw(T),X=x1(T,"trunc"),U=h6(T,"smallestUnit","time",void 0);if(U==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let{precision:Y,unit:G,increment:H}=mw(U,w),z=VO(V(this,X4),H,G,X);return EW(z),jw(z,V(this,u),Y,W)}toJSON(){return C(this,i$),jw(V(this,X4),V(this,u),"auto")}toLocaleString($=void 0,T=void 0){return C(this,i$),new Y1($,T).format(this)}valueOf(){_T("PlainDateTime")}toZonedDateTime($,T=void 0){C(this,i$);let W=R6($),w=_w(X$(T));return e4(T6(W,V(this,X4),w),W,V(this,u))}toPlainDate(){return C(this,i$),J6(V(this,X4).isoDate,V(this,u))}toPlainTime(){return C(this,i$),P0(V(this,X4).time)}static from($,T=void 0){return Kw($,T)}static compare($,T){let W=Kw($),w=Kw(T);return f2(V(W,X4),V(w,X4))}}function O6($,T){C($,i$);let W=V($,X4).isoDate;return cw($).isoToDate(W,{[T]:!0})[T]}function J2($,T){return C($,i$),V($,X4).time[T]}b0(z9,"Temporal.PlainDateTime");class h2{constructor($=0,T=0,W=0,w=0,X=0,U=0,Y=0,G=0,H=0,z=0){let F=$===void 0?0:j1($),O=T===void 0?0:j1(T),Q=W===void 0?0:j1(W),Z=w===void 0?0:j1(w),K=X===void 0?0:j1(X),E=U===void 0?0:j1(U),M=Y===void 0?0:j1(Y),L=G===void 0?0:j1(G),R=H===void 0?0:j1(H),_=z===void 0?0:j1(z);T9(F,O,Q,Z,K,E,M,L,R,_),f0(this),_$(this,Z6,F),_$(this,V6,O),_$(this,f6,Q),_$(this,K6,Z),_$(this,A6,K),_$(this,E6,E),_$(this,M6,M),_$(this,D6,L),_$(this,N6,R),_$(this,b6,_)}get years(){return C(this,H4),V(this,Z6)}get months(){return C(this,H4),V(this,V6)}get weeks(){return C(this,H4),V(this,f6)}get days(){return C(this,H4),V(this,K6)}get hours(){return C(this,H4),V(this,A6)}get minutes(){return C(this,H4),V(this,E6)}get seconds(){return C(this,H4),V(this,M6)}get milliseconds(){return C(this,H4),V(this,D6)}get microseconds(){return C(this,H4),V(this,N6)}get nanoseconds(){return C(this,H4),V(this,b6)}get sign(){return C(this,H4),cG(this)}get blank(){return C(this,H4),cG(this)===0}with($){C(this,H4);let T=RM($),{years:W=V(this,Z6),months:w=V(this,V6),weeks:X=V(this,f6),days:U=V(this,K6),hours:Y=V(this,A6),minutes:G=V(this,E6),seconds:H=V(this,M6),milliseconds:z=V(this,D6),microseconds:F=V(this,N6),nanoseconds:O=V(this,b6)}=T;return new h2(W,w,X,U,Y,G,H,z,F,O)}negated(){return C(this,H4),m6(this)}abs(){return C(this,H4),new h2(Math.abs(V(this,Z6)),Math.abs(V(this,V6)),Math.abs(V(this,f6)),Math.abs(V(this,K6)),Math.abs(V(this,A6)),Math.abs(V(this,E6)),Math.abs(V(this,M6)),Math.abs(V(this,D6)),Math.abs(V(this,N6)),Math.abs(V(this,b6)))}add($){return C(this,H4),oE("add",this,$)}subtract($){return C(this,H4),oE("subtract",this,$)}round($){if(C(this,H4),$===void 0)throw new TypeError("options parameter is required");let T=v0(this),W=typeof $=="string"?DW("smallestUnit",$):X$($),w=h6(W,"largestUnit","datetime",void 0,["auto"]),{plainRelativeTo:X,zonedRelativeTo:U}=iF(W),Y=m2(W),G=x1(W,"halfExpand"),H=h6(W,"smallestUnit","datetime",void 0),z=!0;H||(z=!1,H="nanosecond");let F=S0(T,H),O=!0;if(w||(O=!1,w=F),w==="auto"&&(w=F),!z&&!O)throw new RangeError("at least one of smallestUnit or largestUnit is required");if(S0(w,H)!==w)throw new RangeError(`largestUnit ${w} cannot be smaller than smallestUnit ${H}`);let Q={hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[H];if(Q!==void 0&&c2(Y,Q,!1),Y>1&&q0(H)==="date"&&w!==H)throw new RangeError("For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit");if(U){let K=k2(this),E=V(U,y$),M=V(U,u),L=V(U,Z$);return K=oM(L,Dw(L,E,M,K),E,M,w,Y,H,G),q0(w)==="date"&&(w="hour"),A1(K,w)}if(X){let K=$0(this),E=x2({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},K.time),M=V(X,V$),L=V(X,u),R=G1(L,M,$6(K.date,E.deltaDays),"constrain");return K=dM(x$(M,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),x$(R,E),L,w,Y,H,G),A1(K,w)}if(s1(T))throw new RangeError(`a starting point is required for ${T}s balancing`);if(s1(w))throw new RangeError(`a starting point is required for ${w}s balancing`);let Z=$0(this);if(H==="day"){let{quotient:K,remainder:E}=Z.time.divmod(fG),M=Z.date.days+K+kw(E,"day");M=MT(M,Y,G),Z=j0({years:0,months:0,weeks:0,days:M},q$.ZERO)}else Z=j0({years:0,months:0,weeks:0,days:0},uG(Z.time,Y,H,G));return A1(Z,w)}total($){if(C(this,H4),$===void 0)throw new TypeError("options argument is required");let T=typeof $=="string"?DW("unit",$):X$($),{plainRelativeTo:W,zonedRelativeTo:w}=iF(T),X=h6(T,"unit","datetime",x0);if(w){let Y=k2(this),G=V(w,y$),H=V(w,u),z=V(w,Z$);return function(F,O,Q,Z,K){return q0(K)==="time"?kw(q$.fromEpochNsDiff(O,F),K):hE(uM(F,O,Q,Z,K),O,M1(Q,F),Q,Z,K)}(z,Dw(z,G,H,Y),G,H,X)}if(W){let Y=$0(this),G=x2({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},Y.time),H=V(W,V$),z=V(W,u),F=G1(z,H,$6(Y.date,G.deltaDays),"constrain");return function(O,Q,Z,K){if(f2(O,Q)==0)return 0;EW(O),EW(Q);let E=cM(O,Q,Z,K);return K==="nanosecond"?P.toNumber(E.time.totalNs):hE(E,n4(Q),O,null,Z,K)}(x$(H,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),x$(F,G),z,X)}let U=v0(this);if(s1(U))throw new RangeError(`a starting point is required for ${U}s total`);if(s1(X))throw new RangeError(`a starting point is required for ${X}s total`);return kw($0(this).time,X)}toString($=void 0){C(this,H4);let T=X$($),W=gw(T),w=x1(T,"trunc"),X=h6(T,"smallestUnit","time",void 0);if(X==="hour"||X==="minute")throw new RangeError('smallestUnit must be a time unit other than "hours" or "minutes"');let{precision:U,unit:Y,increment:G}=mw(X,W);if(Y==="nanosecond"&&G===1)return jG(this,U);let H=v0(this),z=k2(this),F=uG(z.time,G,Y,w);return z=j0(z.date,F),jG(A1(z,S0(H,"second")),U)}toJSON(){return C(this,H4),jG(this,"auto")}toLocaleString($=void 0,T=void 0){if(C(this,H4),typeof Intl.DurationFormat=="function"){let W=new Intl.DurationFormat($,T);return xO.call(W,this)}return console.warn("Temporal.Duration.prototype.toLocaleString() requires Intl.DurationFormat."),jG(this,"auto")}valueOf(){_T("Duration")}static from($){return E1($)}static compare($,T,W=void 0){let w=E1($),X=E1(T),U=X$(W),{plainRelativeTo:Y,zonedRelativeTo:G}=iF(U);if(V(w,Z6)===V(X,Z6)&&V(w,V6)===V(X,V6)&&V(w,f6)===V(X,f6)&&V(w,K6)===V(X,K6)&&V(w,A6)===V(X,A6)&&V(w,E6)===V(X,E6)&&V(w,M6)===V(X,M6)&&V(w,D6)===V(X,D6)&&V(w,N6)===V(X,N6)&&V(w,b6)===V(X,b6))return 0;let H=v0(w),z=v0(X),F=k2(w),O=k2(X);if(G&&(q0(H)==="date"||q0(z)==="date")){let M=V(G,y$),L=V(G,u),R=V(G,Z$),_=Dw(R,M,L,F),S=Dw(R,M,L,O);return y6(P.toNumber(P.subtract(_,S)))}let Q=F.date.days,Z=O.date.days;if(s1(H)||s1(z)){if(!Y)throw new RangeError("A starting point is required for years, months, or weeks comparison");Q=yE(F.date,Y),Z=yE(O.date,Y)}let K=F.time.add24HourDays(Q),E=O.time.add24HourDays(Z);return K.cmp(E)}}b0(h2,"Temporal.Duration");class H9{constructor($,T,W="iso8601",w=1972){let X=A$($),U=A$(T),Y=v6(W===void 0?"iso8601":I4(W)),G=A$(w);AW(G,X,U),qM(this,{year:G,month:X,day:U},Y)}get monthCode(){return eE(this,"monthCode")}get day(){return eE(this,"day")}get calendarId(){return C(this,w1),V(this,u)}with($,T=void 0){if(C(this,w1),!Q4($))throw new TypeError("invalid argument");g2($);let W=V(this,u),w=_6(W,V(this,V$),"month-day");return w=KW(W,w,H1(W,$,["year","month","monthCode","day"],[],"partial")),q2(hG(W,w,j$(X$(T))),W)}equals($){C(this,w1);let T=PE($);return w0(V(this,V$),V(T,V$))===0&&W0(V(this,u),V(T,u))}toString($=void 0){return C(this,w1),BE(this,hw(X$($)))}toJSON(){return C(this,w1),BE(this)}toLocaleString($=void 0,T=void 0){return C(this,w1),new Y1($,T).format(this)}valueOf(){_T("PlainMonthDay")}toPlainDate($){if(C(this,w1),!Q4($))throw new TypeError("argument should be an object");let T=V(this,u);return J6(JT(T,KW(T,_6(T,V(this,V$),"month-day"),H1(T,$,["year"],[],[])),"constrain"),T)}static from($,T=void 0){return PE($,T)}}function eE($,T){C($,w1);let W=V($,V$);return cw($).isoToDate(W,{[T]:!0})[T]}function aF($){return M1($,EO())}b0(H9,"Temporal.PlainMonthDay");var DD={instant:()=>I1(EO()),plainDateTimeISO:($=Fw())=>K1(aF(R6($)),"iso8601"),plainDateISO:($=Fw())=>J6(aF(R6($)).isoDate,"iso8601"),plainTimeISO:($=Fw())=>P0(aF(R6($)).time),timeZoneId:()=>Fw(),zonedDateTimeISO:($=Fw())=>{let T=R6($);return e4(EO(),T,"iso8601")},[Symbol.toStringTag]:"Temporal.Now"};Object.defineProperty(DD,Symbol.toStringTag,{value:"Temporal.Now",writable:!1,enumerable:!1,configurable:!0});class tw{constructor($=0,T=0,W=0,w=0,X=0,U=0){let Y=$===void 0?0:A$($),G=T===void 0?0:A$(T),H=W===void 0?0:A$(W),z=w===void 0?0:A$(w),F=X===void 0?0:A$(X),O=U===void 0?0:A$(U);$9(Y,G,H,z,F,O),PM(this,{hour:Y,minute:G,second:H,millisecond:z,microsecond:F,nanosecond:O})}get hour(){return C(this,A4),V(this,O4).hour}get minute(){return C(this,A4),V(this,O4).minute}get second(){return C(this,A4),V(this,O4).second}get millisecond(){return C(this,A4),V(this,O4).millisecond}get microsecond(){return C(this,A4),V(this,O4).microsecond}get nanosecond(){return C(this,A4),V(this,O4).nanosecond}with($,T=void 0){if(C(this,A4),!Q4($))throw new TypeError("invalid argument");g2($);let W=GO($,"partial"),w=GO(this),{hour:X,minute:U,second:Y,millisecond:G,microsecond:H,nanosecond:z}=Object.assign(w,W),F=j$(X$(T));return{hour:X,minute:U,second:Y,millisecond:G,microsecond:H,nanosecond:z}=aG(X,U,Y,G,H,z,F),new tw(X,U,Y,G,H,z)}add($){return C(this,A4),iE("add",this,$)}subtract($){return C(this,A4),iE("subtract",this,$)}until($,T=void 0){return C(this,A4),uE("until",this,$,T)}since($,T=void 0){return C(this,A4),uE("since",this,$,T)}round($){if(C(this,A4),$===void 0)throw new TypeError("options parameter is required");let T=typeof $=="string"?DW("smallestUnit",$):X$($),W=m2(T),w=x1(T,"halfExpand"),X=h6(T,"smallestUnit","time",x0);return c2(W,{hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[X],!1),P0(KO(V(this,O4),W,X,w))}equals($){C(this,A4);let T=ET($);return AO(V(this,O4),V(T,O4))===0}toString($=void 0){C(this,A4);let T=X$($),W=gw(T),w=x1(T,"trunc"),X=h6(T,"smallestUnit","time",void 0);if(X==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let{precision:U,unit:Y,increment:G}=mw(X,W);return IE(KO(V(this,O4),G,Y,w),U)}toJSON(){return C(this,A4),IE(V(this,O4),"auto")}toLocaleString($=void 0,T=void 0){return C(this,A4),new Y1($,T).format(this)}valueOf(){_T("PlainTime")}static from($,T=void 0){return ET($,T)}static compare($,T){let W=ET($),w=ET(T);return AO(V(W,O4),V(w,O4))}}b0(tw,"Temporal.PlainTime");class F9{constructor($,T,W="iso8601",w=1){let X=A$($),U=A$(T),Y=v6(W===void 0?"iso8601":I4(W)),G=A$(w);AW(X,U,G),CM(this,{year:X,month:U,day:G},Y)}get year(){return _0(this,"year")}get month(){return _0(this,"month")}get monthCode(){return _0(this,"monthCode")}get calendarId(){return C(this,r4),V(this,u)}get era(){return _0(this,"era")}get eraYear(){return _0(this,"eraYear")}get daysInMonth(){return _0(this,"daysInMonth")}get daysInYear(){return _0(this,"daysInYear")}get monthsInYear(){return _0(this,"monthsInYear")}get inLeapYear(){return _0(this,"inLeapYear")}with($,T=void 0){if(C(this,r4),!Q4($))throw new TypeError("invalid argument");g2($);let W=V(this,u),w=_6(W,V(this,V$),"year-month");return w=KW(W,w,H1(W,$,["year","month","monthCode"],[],"partial")),P2(Cw(W,w,j$(X$(T))),W)}add($,T=void 0){return C(this,r4),tE("add",this,$,T)}subtract($,T=void 0){return C(this,r4),tE("subtract",this,$,T)}until($,T=void 0){return C(this,r4),pE("until",this,$,T)}since($,T=void 0){return C(this,r4),pE("since",this,$,T)}equals($){C(this,r4);let T=Ew($);return w0(V(this,V$),V(T,V$))===0&&W0(V(this,u),V(T,u))}toString($=void 0){return C(this,r4),xE(this,hw(X$($)))}toJSON(){return C(this,r4),xE(this)}toLocaleString($=void 0,T=void 0){return C(this,r4),new Y1($,T).format(this)}valueOf(){_T("PlainYearMonth")}toPlainDate($){if(C(this,r4),!Q4($))throw new TypeError("argument should be an object");let T=V(this,u);return J6(JT(T,KW(T,_6(T,V(this,V$),"year-month"),H1(T,$,["day"],[],[])),"constrain"),T)}static from($,T=void 0){return Ew($,T)}static compare($,T){let W=Ew($),w=Ew(T);return w0(V(W,V$),V(w,V$))}}function _0($,T){C($,r4);let W=V($,V$);return cw($).isoToDate(W,{[T]:!0})[T]}b0(F9,"Temporal.PlainYearMonth");var vI=Y1.prototype.resolvedOptions;class O9{constructor($,T,W="iso8601"){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");let w=pG($),X=I4(T),{tzName:U,offsetMinutes:Y}=DT(X);if(Y===void 0){let G=gG(U);if(!G)throw new RangeError(`unknown time zone ${U}`);X=G.identifier}else X=LO(Y);jM(this,w,X,v6(W===void 0?"iso8601":I4(W)))}get calendarId(){return C(this,v$),V(this,u)}get timeZoneId(){return C(this,v$),V(this,y$)}get year(){return Q6(this,"year")}get month(){return Q6(this,"month")}get monthCode(){return Q6(this,"monthCode")}get day(){return Q6(this,"day")}get hour(){return R2(this,"hour")}get minute(){return R2(this,"minute")}get second(){return R2(this,"second")}get millisecond(){return R2(this,"millisecond")}get microsecond(){return R2(this,"microsecond")}get nanosecond(){return R2(this,"nanosecond")}get era(){return Q6(this,"era")}get eraYear(){return Q6(this,"eraYear")}get epochMilliseconds(){return C(this,v$),D1(V(this,Z$),"floor")}get epochNanoseconds(){return C(this,v$),lM(V(this,Z$))}get dayOfWeek(){return Q6(this,"dayOfWeek")}get dayOfYear(){return Q6(this,"dayOfYear")}get weekOfYear(){return Q6(this,"weekOfYear")?.week}get yearOfWeek(){return Q6(this,"weekOfYear")?.year}get hoursInDay(){C(this,v$);let $=V(this,y$),T=a1(this).isoDate,W=g6(T.year,T.month,T.day+1),w=KT($,T),X=KT($,W);return kw(q$.fromEpochNsDiff(X,w),"hour")}get daysInWeek(){return Q6(this,"daysInWeek")}get daysInMonth(){return Q6(this,"daysInMonth")}get daysInYear(){return Q6(this,"daysInYear")}get monthsInYear(){return Q6(this,"monthsInYear")}get inLeapYear(){return Q6(this,"inLeapYear")}get offset(){return C(this,v$),zO(C0(V(this,y$),V(this,Z$)))}get offsetNanoseconds(){return C(this,v$),C0(V(this,y$),V(this,Z$))}with($,T=void 0){if(C(this,v$),!Q4($))throw new TypeError("invalid zoned-date-time-like");g2($);let W=V(this,u),w=V(this,y$),X=C0(w,V(this,Z$)),U=a1(this),Y={..._6(W,U.isoDate),...U.time,offset:zO(X)};Y=KW(W,Y,H1(W,$,["year","month","monthCode","day"],["hour","minute","second","millisecond","microsecond","nanosecond","offset"],"partial"));let G=X$(T),H=_w(G),z=IG(G,"prefer"),F=uw(W,Y,j$(G)),O=u2(Y.offset);return e4(yG(F.isoDate,F.time,"option",O,w,H,z,!1),w,W)}withPlainTime($=void 0){C(this,v$);let T=V(this,y$),W=V(this,u),w=a1(this).isoDate,X;return X=$===void 0?KT(T,w):T6(T,x$(w,V(ET($),O4)),"compatible"),e4(X,T,W)}withTimeZone($){C(this,v$);let T=R6($);return e4(V(this,Z$),T,V(this,u))}withCalendar($){C(this,v$);let T=dw($);return e4(V(this,Z$),V(this,y$),T)}add($,T=void 0){return C(this,v$),aE("add",this,$,T)}subtract($,T=void 0){return C(this,v$),aE("subtract",this,$,T)}until($,T=void 0){return C(this,v$),dE("until",this,$,T)}since($,T=void 0){return C(this,v$),dE("since",this,$,T)}round($){if(C(this,v$),$===void 0)throw new TypeError("options parameter is required");let T=typeof $=="string"?DW("smallestUnit",$):X$($),W=m2(T),w=x1(T,"halfExpand"),X=h6(T,"smallestUnit","time",x0,["day"]),U={day:1,hour:24,minute:60,second:60,millisecond:1000,microsecond:1000,nanosecond:1000}[X];if(c2(W,U,U===1),X==="nanosecond"&&W===1)return e4(V(this,Z$),V(this,y$),V(this,u));let Y=V(this,y$),G=V(this,Z$),H=a1(this),z;if(X==="day"){let F=H.isoDate,O=g6(F.year,F.month,F.day+1),Q=KT(Y,F),Z=KT(Y,O),K=P.subtract(Z,Q);z=q$.fromEpochNsDiff(G,Q).round(K,w).addToEpochNs(Q)}else{let F=VO(H,W,X,w),O=C0(Y,G);z=yG(F.isoDate,F.time,"option",O,Y,"compatible","prefer",!1)}return e4(z,Y,V(this,u))}equals($){C(this,v$);let T=Mw($),W=V(this,Z$),w=V(T,Z$);return!!P.equal(P.BigInt(W),P.BigInt(w))&&!!IM(V(this,y$),V(T,y$))&&W0(V(this,u),V(T,u))}toString($=void 0){C(this,v$);let T=X$($),W=hw(T),w=gw(T),X=function(O){return I0(O,"offset",["auto","never"],"auto")}(T),U=x1(T,"trunc"),Y=h6(T,"smallestUnit","time",void 0);if(Y==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let G=function(O){return I0(O,"timeZoneName",["auto","never","critical"],"auto")}(T),{precision:H,unit:z,increment:F}=mw(Y,w);return fE(this,H,W,G,X,{unit:z,increment:F,roundingMode:U})}toLocaleString($=void 0,T=void 0){C(this,v$);let W=X$(T),w=Object.create(null);if(function(G,H,z,F){if(H==null)return;let O=Reflect.ownKeys(H);for(let Q=0;Q<O.length;Q++){let Z=O[Q];if(!z.some((K)=>Object.is(K,Z))&&Object.prototype.propertyIsEnumerable.call(H,Z)){let K=H[Z];G[Z]=K}}}(w,W,["timeZone"]),W.timeZone!==void 0)throw new TypeError("ZonedDateTime toLocaleString does not accept a timeZone option");if(w.year===void 0&&w.month===void 0&&w.day===void 0&&w.era===void 0&&w.weekday===void 0&&w.dateStyle===void 0&&w.hour===void 0&&w.minute===void 0&&w.second===void 0&&w.fractionalSecondDigits===void 0&&w.timeStyle===void 0&&w.dayPeriod===void 0&&w.timeZoneName===void 0&&(w.timeZoneName="short"),w.timeZone=V(this,y$),bE(w.timeZone))throw new RangeError("toLocaleString does not currently support offset time zones");let X=new Y1($,w),U=vI.call(X).calendar,Y=V(this,u);if(Y!=="iso8601"&&U!=="iso8601"&&!W0(U,Y))throw new RangeError(`cannot format ZonedDateTime with calendar ${Y} in locale with calendar ${U}`);return X.format(I1(V(this,Z$)))}toJSON(){return C(this,v$),fE(this,"auto")}valueOf(){_T("ZonedDateTime")}startOfDay(){C(this,v$);let $=V(this,y$);return e4(KT($,a1(this).isoDate),$,V(this,u))}getTimeZoneTransition($){C(this,v$);let T=V(this,y$);if($===void 0)throw new TypeError("options parameter is required");let W=I0(typeof $=="string"?DW("direction",$):X$($),"direction",["next","previous"],x0);if(W===void 0)throw new TypeError("direction option is required");if(bE(T)||T==="UTC")return null;let w=V(this,Z$),X=W==="next"?RO(T,w):FO(T,w);return X===null?null:e4(X,T,V(this,u))}toInstant(){return C(this,v$),I1(V(this,Z$))}toPlainDate(){return C(this,v$),J6(a1(this).isoDate,V(this,u))}toPlainTime(){return C(this,v$),P0(a1(this).time)}toPlainDateTime(){return C(this,v$),K1(a1(this),V(this,u))}static from($,T=void 0){return Mw($,T)}static compare($,T){let W=Mw($),w=Mw(T),X=V(W,Z$),U=V(w,Z$);return P.lessThan(P.BigInt(X),P.BigInt(U))?-1:P.greaterThan(P.BigInt(X),P.BigInt(U))?1:0}}function a1($){return M1(V($,y$),V($,Z$))}function Q6($,T){C($,v$);let W=a1($).isoDate;return cw($).isoToDate(W,{[T]:!0})[T]}function R2($,T){return C($,v$),a1($).time[T]}b0(O9,"Temporal.ZonedDateTime");var Q9=Object.freeze({__proto__:null,Duration:h2,Instant:Y9,Now:DD,PlainDate:G9,PlainDateTime:z9,PlainMonthDay:H9,PlainTime:tw,PlainYearMonth:F9,ZonedDateTime:O9}),yt=class ${toTemporalInstant(){return I1(B1(Date.prototype.valueOf.call(this)))}}.prototype.toTemporalInstant,qI=[Y9,G9,z9,h2,H9,tw,F9,O9];for(let $ of qI){let T=Object.getOwnPropertyDescriptor($,"prototype");(T.configurable||T.enumerable||T.writable)&&(T.configurable=!1,T.enumerable=!1,T.writable=!1,Object.defineProperty($,"prototype",T))}class Z9{supported;constructor($){this.supported=$}refine($){for(let[T,W]of Object.entries(this.supported))try{if(W($)===!0&&W!==Boolean)return{type:T,data:$}}catch(w){try{if($ instanceof W)return{type:T,data:$}}catch(X){}}return null}}var PI=new Z9({number:($)=>typeof $==="number",string:($)=>typeof $==="string",boolean:($)=>typeof $==="boolean",null:($)=>$===null});function CI($){if(!$)return!1;return Object.getPrototypeOf($)===Object.prototype}var SI=new Z9({object:CI,array:($)=>Array.isArray($)}),jI=new Z9({...PI.supported,...SI.supported}),ND=($)=>{if($===void 0)return"undefined";let T=jI.refine($);if(T)return T.type;return Object.getPrototypeOf($).constructor.name};var N=Symbol.for("drizzle:entityKind"),mt=Symbol.for("drizzle:hasOwnEntityKind");function I($,T){if(!$||typeof $!=="object")return!1;if($ instanceof T)return!0;if(!Object.prototype.hasOwnProperty.call(T,N))throw new Error(`Class "${T.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let W=Object.getPrototypeOf($).constructor;if(W)while(W){if(N in W&&W[N]===T[N])return!0;W=Object.getPrototypeOf(W)}return!1}class p${constructor($,T){this.table=$,this.config=T,this.name=T.name,this.keyAsName=T.keyAsName,this.notNull=T.notNull,this.default=T.default,this.defaultFn=T.defaultFn,this.onUpdateFn=T.onUpdateFn,this.hasDefault=T.hasDefault,this.primary=T.primaryKey,this.isUnique=T.isUnique,this.uniqueName=T.uniqueName,this.uniqueType=T.uniqueType,this.dataType=T.dataType,this.columnType=T.columnType,this.generated=T.generated,this.generatedIdentity=T.generatedIdentity}static[N]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class fO{static[N]="ColumnBuilder";config;constructor($,T,W){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:T,columnType:W,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}var f1=Symbol.for("drizzle:Name");class bO{static[N]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor($,T){if(this.reference=()=>{let{name:W,columns:w,foreignColumns:X}=$();return{name:W,columns:w,foreignTable:X[0].table,foreignColumns:X}},T)this._onUpdate=T.onUpdate,this._onDelete=T.onDelete}onUpdate($){return this._onUpdate=$===void 0?"no action":$,this}onDelete($){return this._onDelete=$===void 0?"no action":$,this}build($){return new LD($,this)}}class LD{constructor($,T){this.table=$,this.reference=T.reference,this.onUpdate=T._onUpdate,this.onDelete=T._onDelete}static[N]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:T,foreignColumns:W}=this.reference(),w=T.map((Y)=>Y.name),X=W.map((Y)=>Y.name),U=[this.table[f1],...w,W[0].table[f1],...X];return $??`${U.join("_")}_fk`}}function V9($,...T){return $(...T)}function JD($,T){return`${$[f1]}_${T.join("_")}_unique`}function RD($,T,W){for(let w=T;w<$.length;w++){let X=$[w];if(X==="\\"){w++;continue}if(X==='"')return[$.slice(T,w).replace(/\\/g,""),w+1];if(W)continue;if(X===","||X==="}")return[$.slice(T,w).replace(/\\/g,""),w]}return[$.slice(T).replace(/\\/g,""),$.length]}function _D($,T=0){let W=[],w=T,X=!1;while(w<$.length){let U=$[w];if(U===","){if(X||w===T)W.push("");X=!0,w++;continue}if(X=!1,U==="\\"){w+=2;continue}if(U==='"'){let[H,z]=RD($,w+1,!0);W.push(H),w=z;continue}if(U==="}")return[W,w+1];if(U==="{"){let[H,z]=_D($,w+1);W.push(H),w=z;continue}let[Y,G]=RD($,w,!1);W.push(Y),w=G}return[W,w]}function kD($){let[T]=_D($,1);return T}function yO($){return`{${$.map((T)=>{if(Array.isArray(T))return yO(T);if(typeof T==="string")return`"${T.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${T}`}).join(",")}}`}class e extends fO{foreignKeyConfigs=[];static[N]="PgColumnBuilder";array($){return new qD(this.config.name,this,$)}references($,T={}){return this.foreignKeyConfigs.push({ref:$,actions:T}),this}unique($,T){return this.config.isUnique=!0,this.config.uniqueName=$,this.config.uniqueType=T?.nulls,this}generatedAlwaysAs($){return this.config.generated={as:$,type:"always",mode:"stored"},this}buildForeignKeys($,T){return this.foreignKeyConfigs.map(({ref:W,actions:w})=>{return V9((X,U)=>{let Y=new bO(()=>{let G=X();return{columns:[$],foreignColumns:[G]}});if(U.onUpdate)Y.onUpdate(U.onUpdate);if(U.onDelete)Y.onDelete(U.onDelete);return Y.build(T)},W,w)})}buildExtraConfigColumn($){return new vD($,this.config)}}class d extends p${constructor($,T){if(!T.uniqueName)T.uniqueName=JD($,[T.name]);super($,T);this.table=$}static[N]="PgColumn"}class vD extends d{static[N]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}class aw{static[N]="IndexedColumn";constructor($,T,W,w){this.name=$,this.keyAsName=T,this.type=W,this.indexConfig=w}name;keyAsName;type;indexConfig}class qD extends e{static[N]="PgArrayBuilder";constructor($,T,W){super($,"array","PgArray");this.config.baseBuilder=T,this.config.size=W}build($){let T=this.config.baseBuilder.build($);return new hO($,this.config,T)}}class hO extends d{constructor($,T,W,w){super($,T);this.baseColumn=W,this.range=w,this.size=T.size}size;static[N]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue($){if(typeof $==="string")$=kD($);return $.map((T)=>this.baseColumn.mapFromDriverValue(T))}mapToDriverValue($,T=!1){let W=$.map((w)=>w===null?null:I(this.baseColumn,hO)?this.baseColumn.mapToDriverValue(w,!0):this.baseColumn.mapToDriverValue(w));if(T)return W;return yO(W)}}class PD extends e{static[N]="PgEnumObjectColumnBuilder";constructor($,T){super($,"string","PgEnumObjectColumn");this.config.enum=T}build($){return new CD($,this.config)}}class CD extends d{static[N]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}var K9=Symbol.for("drizzle:isPgEnum");function SD($){return!!$&&typeof $==="function"&&K9 in $&&$[K9]===!0}class jD extends e{static[N]="PgEnumColumnBuilder";constructor($,T){super($,"string","PgEnumColumn");this.config.enum=T}build($){return new ID($,this.config)}}class ID extends d{static[N]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}function sw($,T){return Array.isArray(T)?II($,[...T],void 0):BI($,T,void 0)}function II($,T,W){let w=Object.assign((X)=>new jD(X??"",w),{enumName:$,enumValues:T,schema:W,[K9]:!0});return w}function BI($,T,W){let w=Object.assign((X)=>new PD(X??"",w),{enumName:$,enumValues:Object.values(T),schema:W,[K9]:!0});return w}class M4{static[N]="Subquery";constructor($,T,W,w=!1,X=[]){this._={brand:"Subquery",sql:$,selectedFields:T,alias:W,isWith:w,usedTables:X}}}class ew extends M4{static[N]="WithSubquery"}var BD="0.44.1";var gO,mO,d$={startActiveSpan($,T){if(!gO)return T();if(!mO)mO=gO.trace.getTracer("drizzle-orm",BD);return V9((W,w)=>w.startActiveSpan($,(X)=>{try{return T(X)}catch(U){throw X.setStatus({code:W.SpanStatusCode.ERROR,message:U instanceof Error?U.message:"Unknown error"}),U}finally{X.end()}}),gO,mO)}};var t$=Symbol.for("drizzle:ViewBaseConfig");var _W=Symbol.for("drizzle:Schema"),A9=Symbol.for("drizzle:Columns"),xD=Symbol.for("drizzle:ExtraConfigColumns"),cO=Symbol.for("drizzle:OriginalName"),uO=Symbol.for("drizzle:BaseName"),$U=Symbol.for("drizzle:IsAlias"),fD=Symbol.for("drizzle:ExtraConfigBuilder"),xI=Symbol.for("drizzle:IsDrizzleTable");class o{static[N]="Table";static Symbol={Name:f1,Schema:_W,OriginalName:cO,Columns:A9,ExtraConfigColumns:xD,BaseName:uO,IsAlias:$U,ExtraConfigBuilder:fD};[f1];[cO];[_W];[A9];[xD];[uO];[$U]=!1;[xI]=!0;[fD]=void 0;constructor($,T,W){this[f1]=this[cO]=$,this[_W]=T,this[uO]=W}}function u4($){return $[f1]}function kW($){return`${$[_W]??"public"}.${$[f1]}`}function pO($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function fI($){let T={sql:"",params:[]};for(let W of $)if(T.sql+=W.sql,T.params.push(...W.params),W.typings?.length){if(!T.typings)T.typings=[];T.typings.push(...W.typings)}return T}class B4{static[N]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new s([this])}}class s{constructor($){this.queryChunks=$;for(let T of $)if(I(T,o)){let W=T[o.Symbol.Schema];this.usedTables.push(W===void 0?T[o.Symbol.Name]:W+"."+T[o.Symbol.Name])}}static[N]="SQL";decoder=yD;shouldInlineParams=!1;usedTables=[];append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return d$.startActiveSpan("drizzle.buildSQL",(T)=>{let W=this.buildQueryFromSourceParams(this.queryChunks,$);return T?.setAttributes({"drizzle.query.text":W.sql,"drizzle.query.params":JSON.stringify(W.params)}),W})}buildQueryFromSourceParams($,T){let W=Object.assign({},T,{inlineParams:T.inlineParams||this.shouldInlineParams,paramStartIndex:T.paramStartIndex||{value:0}}),{casing:w,escapeName:X,escapeParam:U,prepareTyping:Y,inlineParams:G,paramStartIndex:H}=W;return fI($.map((z)=>{if(I(z,B4))return{sql:z.value.join(""),params:[]};if(I(z,E9))return{sql:X(z.value),params:[]};if(z===void 0)return{sql:"",params:[]};if(Array.isArray(z)){let F=[new B4("(")];for(let[O,Q]of z.entries())if(F.push(Q),O<z.length-1)F.push(new B4(", "));return F.push(new B4(")")),this.buildQueryFromSourceParams(F,W)}if(I(z,s))return this.buildQueryFromSourceParams(z.queryChunks,{...W,inlineParams:G||z.shouldInlineParams});if(I(z,o)){let F=z[o.Symbol.Schema],O=z[o.Symbol.Name];return{sql:F===void 0||z[$U]?X(O):X(F)+"."+X(O),params:[]}}if(I(z,p$)){let F=w.getColumnCasing(z);if(T.invokeSource==="indexes")return{sql:X(F),params:[]};let O=z.table[o.Symbol.Schema];return{sql:z.table[$U]||O===void 0?X(z.table[o.Symbol.Name])+"."+X(F):X(O)+"."+X(z.table[o.Symbol.Name])+"."+X(F),params:[]}}if(I(z,c6)){let F=z[t$].schema,O=z[t$].name;return{sql:F===void 0||z[t$].isAlias?X(O):X(F)+"."+X(O),params:[]}}if(I(z,F1)){if(I(z.value,vT))return{sql:U(H.value++,z),params:[z],typings:["none"]};let F=z.value===null?null:z.encoder.mapToDriverValue(z.value);if(I(F,s))return this.buildQueryFromSourceParams([F],W);if(G)return{sql:this.mapInlineParam(F,W),params:[]};let O=["none"];if(Y)O=[Y(z.encoder)];return{sql:U(H.value++,F),params:[F],typings:O}}if(I(z,vT))return{sql:U(H.value++,z),params:[z],typings:["none"]};if(I(z,s.Aliased)&&z.fieldAlias!==void 0)return{sql:X(z.fieldAlias),params:[]};if(I(z,M4)){if(z._.isWith)return{sql:X(z._.alias),params:[]};return this.buildQueryFromSourceParams([new B4("("),z._.sql,new B4(") "),new E9(z._.alias)],W)}if(SD(z)){if(z.schema)return{sql:X(z.schema)+"."+X(z.enumName),params:[]};return{sql:X(z.enumName),params:[]}}if(pO(z)){if(z.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([z.getSQL()],W);return this.buildQueryFromSourceParams([new B4("("),z.getSQL(),new B4(")")],W)}if(G)return{sql:this.mapInlineParam(z,W),params:[]};return{sql:U(H.value++,z),params:[z],typings:["none"]}}))}mapInlineParam($,{escapeString:T}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return T($);if(typeof $==="object"){let W=$.toString();if(W==="[object Object]")return T(JSON.stringify($));return T(W)}throw new Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new s.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}}class E9{constructor($){this.value=$}static[N]="Name";brand;getSQL(){return new s([this])}}function bD($){return typeof $==="object"&&$!==null&&"mapToDriverValue"in $&&typeof $.mapToDriverValue==="function"}var yD={mapFromDriverValue:($)=>$},hD={mapToDriverValue:($)=>$},Pa={...yD,...hD};class F1{constructor($,T=hD){this.value=$,this.encoder=T}static[N]="Param";brand;getSQL(){return new s([this])}}function J($,...T){let W=[];if(T.length>0||$.length>0&&$[0]!=="")W.push(new B4($[0]));for(let[w,X]of T.entries())W.push(X,new B4($[w+1]));return new s(W)}(($)=>{function T(){return new s([])}$.empty=T;function W(H){return new s(H)}$.fromList=W;function w(H){return new s([new B4(H)])}$.raw=w;function X(H,z){let F=[];for(let[O,Q]of H.entries()){if(O>0&&z!==void 0)F.push(z);F.push(Q)}return new s(F)}$.join=X;function U(H){return new E9(H)}$.identifier=U;function Y(H){return new vT(H)}$.placeholder=Y;function G(H,z){return new F1(H,z)}$.param=G})(J||(J={}));(($)=>{class T{constructor(W,w){this.sql=W,this.fieldAlias=w}static[N]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new T(this.sql,this.fieldAlias)}}$.Aliased=T})(s||(s={}));class vT{constructor($){this.name=$}static[N]="Placeholder";getSQL(){return new s([this])}}function dO($,T){return $.map((W)=>{if(I(W,vT)){if(!(W.name in T))throw new Error(`No value for placeholder "${W.name}" was provided`);return T[W.name]}if(I(W,F1)&&I(W.value,vT)){if(!(W.value.name in T))throw new Error(`No value for placeholder "${W.value.name}" was provided`);return W.encoder.mapToDriverValue(T[W.value.name])}return W})}var bI=Symbol.for("drizzle:IsDrizzleView");class c6{static[N]="View";[t$];[bI]=!0;constructor({name:$,schema:T,selectedFields:W,query:w}){this[t$]={name:$,originalName:$,schema:T,selectedFields:W,query:w,isExisting:!w,isAlias:!1}}getSQL(){return new s([this])}}p$.prototype.getSQL=function(){return new s([this])};o.prototype.getSQL=function(){return new s([this])};M4.prototype.getSQL=function(){return new s([this])};class d2{constructor($){this.table=$}static[N]="ColumnAliasProxyHandler";get($,T){if(T==="table")return this.table;return $[T]}}class TU{constructor($,T){this.alias=$,this.replaceOriginalName=T}static[N]="TableAliasProxyHandler";get($,T){if(T===o.Symbol.IsAlias)return!0;if(T===o.Symbol.Name)return this.alias;if(this.replaceOriginalName&&T===o.Symbol.OriginalName)return this.alias;if(T===t$)return{...$[t$],name:this.alias,isAlias:!0};if(T===o.Symbol.Columns){let w=$[o.Symbol.Columns];if(!w)return w;let X={};return Object.keys(w).map((U)=>{X[U]=new Proxy(w[U],new d2(new Proxy($,this)))}),X}let W=$[T];if(I(W,p$))return new Proxy(W,new d2(new Proxy($,this)));return W}}function M9($,T){return new Proxy($,new TU(T,!1))}function Y0($,T){return new Proxy($,new d2(new Proxy($.table,new TU(T,!1))))}function oO($,T){return new s.Aliased(WU($.sql,T),$.fieldAlias)}function WU($,T){return J.join($.queryChunks.map((W)=>{if(I(W,p$))return Y0(W,T);if(I(W,s))return WU(W,T);if(I(W,s.Aliased))return oO(W,T);return W}))}class D9 extends Error{static[N]="DrizzleError";constructor({message:$,cause:T}){super($);this.name="DrizzleError",this.cause=T}}class lO extends D9{static[N]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class gD{static[N]="ConsoleLogWriter";write($){console.log($)}}class rO{static[N]="DefaultLogger";writer;constructor($){this.writer=$?.writer??new gD}logQuery($,T){let W=T.map((X)=>{try{return JSON.stringify(X)}catch{return String(X)}}),w=W.length?` -- params: [${W.join(", ")}]`:"";this.writer.write(`Query: ${$}${w}`)}}class nO{static[N]="NoopLogger";logQuery(){}}class q6{static[N]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch($){return this.then(void 0,$)}finally($){return this.then((T)=>{return $?.(),T},(T)=>{throw $?.(),T})}then($,T){return this.execute().then($,T)}}function mD($,T,W){let w={},X=$.reduce((U,{path:Y,field:G},H)=>{let z;if(I(G,p$))z=G;else if(I(G,s))z=G.decoder;else z=G.sql.decoder;let F=U;for(let[O,Q]of Y.entries())if(O<Y.length-1){if(!(Q in F))F[Q]={};F=F[Q]}else{let Z=T[H],K=F[Q]=Z===null?null:z.mapFromDriverValue(Z);if(W&&I(G,p$)&&Y.length===2){let E=Y[0];if(!(E in w))w[E]=K===null?u4(G.table):!1;else if(typeof w[E]==="string"&&w[E]!==u4(G.table))w[E]=!1}}return U},{});if(W&&Object.keys(w).length>0){for(let[U,Y]of Object.entries(w))if(typeof Y==="string"&&!W[Y])X[U]=null}return X}function N1($,T){return Object.entries($).reduce((W,[w,X])=>{if(typeof w!=="string")return W;let U=T?[...T,w]:[w];if(I(X,p$)||I(X,s)||I(X,s.Aliased))W.push({path:U,field:X});else if(I(X,o))W.push(...N1(X[o.Symbol.Columns],U));else W.push(...N1(X,U));return W},[])}function XU($,T){let W=Object.keys($),w=Object.keys(T);if(W.length!==w.length)return!1;for(let[X,U]of W.entries())if(U!==w[X])return!1;return!0}function N9($,T){let W=Object.entries(T).filter(([,w])=>w!==void 0).map(([w,X])=>{if(I(X,s)||I(X,p$))return[w,X];else return[w,new F1(X,$[o.Symbol.Columns][w])]});if(W.length===0)throw new Error("No values to set");return Object.fromEntries(W)}function cD($,T){for(let W of T)for(let w of Object.getOwnPropertyNames(W.prototype)){if(w==="constructor")continue;Object.defineProperty($.prototype,w,Object.getOwnPropertyDescriptor(W.prototype,w)||Object.create(null))}}function uD($){return $[o.Symbol.Columns]}function y0($){return I($,M4)?$._.alias:I($,c6)?$[t$].name:I($,s)?void 0:$[o.Symbol.IsAlias]?$[o.Symbol.Name]:$[o.Symbol.BaseName]}function S$($,T){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:T}}function pD($){if(typeof $!=="object"||$===null)return!1;if($.constructor.name!=="Object")return!1;if("logger"in $){let T=typeof $.logger;if(T!=="boolean"&&(T!=="object"||typeof $.logger.logQuery!=="function")&&T!=="undefined")return!1;return!0}if("schema"in $){let T=typeof $.schema;if(T!=="object"&&T!=="undefined")return!1;return!0}if("casing"in $){let T=typeof $.casing;if(T!=="string"&&T!=="undefined")return!1;return!0}if("mode"in $){if($.mode!=="default"||$.mode!=="planetscale"||$.mode!==void 0)return!1;return!0}if("connection"in $){let T=typeof $.connection;if(T!=="string"&&T!=="object"&&T!=="undefined")return!1;return!0}if("client"in $){let T=typeof $.client;if(T!=="object"&&T!=="function"&&T!=="undefined")return!1;return!0}if(Object.keys($).length===0)return!0;return!1}class qT extends e{static[N]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity($){if($){let{name:T,...W}=$;this.config.generatedIdentity={type:"always",sequenceName:T,sequenceOptions:W}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity($){if($){let{name:T,...W}=$;this.config.generatedIdentity={type:"byDefault",sequenceName:T,sequenceOptions:W}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class dD extends qT{static[N]="PgBigInt53Builder";constructor($){super($,"number","PgBigInt53")}build($){return new oD($,this.config)}}class oD extends d{static[N]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class lD extends qT{static[N]="PgBigInt64Builder";constructor($){super($,"bigint","PgBigInt64")}build($){return new rD($,this.config)}}class rD extends d{static[N]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue($){return BigInt($)}}function nD($,T){let{name:W,config:w}=S$($,T);if(w.mode==="number")return new dD(W);return new lD(W)}class iD extends e{static[N]="PgBigSerial53Builder";constructor($){super($,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new tD($,this.config)}}class tD extends d{static[N]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class aD extends e{static[N]="PgBigSerial64Builder";constructor($){super($,"bigint","PgBigSerial64");this.config.hasDefault=!0}build($){return new sD($,this.config)}}class sD extends d{static[N]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue($){return BigInt($)}}function eD($,T){let{name:W,config:w}=S$($,T);if(w.mode==="number")return new iD(W);return new aD(W)}class $N extends e{static[N]="PgBooleanBuilder";constructor($){super($,"boolean","PgBoolean")}build($){return new TN($,this.config)}}class TN extends d{static[N]="PgBoolean";getSQLType(){return"boolean"}}function wU($){return new $N($??"")}class WN extends e{static[N]="PgCharBuilder";constructor($,T){super($,"string","PgChar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new XN($,this.config)}}class XN extends d{static[N]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function wN($,T={}){let{name:W,config:w}=S$($,T);return new WN(W,w)}class UN extends e{static[N]="PgCidrBuilder";constructor($){super($,"string","PgCidr")}build($){return new YN($,this.config)}}class YN extends d{static[N]="PgCidr";getSQLType(){return"cidr"}}function GN($){return new UN($??"")}class zN extends e{static[N]="PgCustomColumnBuilder";constructor($,T,W){super($,"custom","PgCustomColumn");this.config.fieldConfig=T,this.config.customTypeParams=W}build($){return new HN($,this.config)}}class HN extends d{static[N]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor($,T){super($,T);this.sqlName=T.customTypeParams.dataType(T.fieldConfig),this.mapTo=T.customTypeParams.toDriver,this.mapFrom=T.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}function FN($){return(T,W)=>{let{name:w,config:X}=S$(T,W);return new zN(w,X,$)}}class h0 extends e{static[N]="PgDateColumnBaseBuilder";defaultNow(){return this.default(J`now()`)}}class ON extends h0{static[N]="PgDateBuilder";constructor($){super($,"date","PgDate")}build($){return new L9($,this.config)}}class L9 extends d{static[N]="PgDate";getSQLType(){return"date"}mapFromDriverValue($){return new Date($)}mapToDriverValue($){return $.toISOString()}}class QN extends h0{static[N]="PgDateStringBuilder";constructor($){super($,"string","PgDateString")}build($){return new J9($,this.config)}}class J9 extends d{static[N]="PgDateString";getSQLType(){return"date"}}function ZN($,T){let{name:W,config:w}=S$($,T);if(w?.mode==="date")return new ON(W);return new QN(W)}class VN extends e{static[N]="PgDoublePrecisionBuilder";constructor($){super($,"number","PgDoublePrecision")}build($){return new KN($,this.config)}}class KN extends d{static[N]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue($){if(typeof $==="string")return Number.parseFloat($);return $}}function AN($){return new VN($??"")}class EN extends e{static[N]="PgInetBuilder";constructor($){super($,"string","PgInet")}build($){return new MN($,this.config)}}class MN extends d{static[N]="PgInet";getSQLType(){return"inet"}}function DN($){return new EN($??"")}class NN extends qT{static[N]="PgIntegerBuilder";constructor($){super($,"number","PgInteger")}build($){return new LN($,this.config)}}class LN extends d{static[N]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue($){if(typeof $==="string")return Number.parseInt($);return $}}function UU($){return new NN($??"")}class JN extends e{static[N]="PgIntervalBuilder";constructor($,T){super($,"string","PgInterval");this.config.intervalConfig=T}build($){return new RN($,this.config)}}class RN extends d{static[N]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){let $=this.fields?` ${this.fields}`:"",T=this.precision?`(${this.precision})`:"";return`interval${$}${T}`}}function _N($,T={}){let{name:W,config:w}=S$($,T);return new JN(W,w)}class kN extends e{static[N]="PgJsonBuilder";constructor($){super($,"json","PgJson")}build($){return new R9($,this.config)}}class R9 extends d{static[N]="PgJson";constructor($,T){super($,T)}getSQLType(){return"json"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function vN($){return new kN($??"")}class qN extends e{static[N]="PgJsonbBuilder";constructor($){super($,"json","PgJsonb")}build($){return new _9($,this.config)}}class _9 extends d{static[N]="PgJsonb";constructor($,T){super($,T)}getSQLType(){return"jsonb"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function PN($){return new qN($??"")}class CN extends e{static[N]="PgLineBuilder";constructor($){super($,"array","PgLine")}build($){return new SN($,this.config)}}class SN extends d{static[N]="PgLine";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,w]=$.slice(1,-1).split(",");return[Number.parseFloat(T),Number.parseFloat(W),Number.parseFloat(w)]}mapToDriverValue($){return`{${$[0]},${$[1]},${$[2]}}`}}class jN extends e{static[N]="PgLineABCBuilder";constructor($){super($,"json","PgLineABC")}build($){return new IN($,this.config)}}class IN extends d{static[N]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,w]=$.slice(1,-1).split(",");return{a:Number.parseFloat(T),b:Number.parseFloat(W),c:Number.parseFloat(w)}}mapToDriverValue($){return`{${$.a},${$.b},${$.c}}`}}function BN($,T){let{name:W,config:w}=S$($,T);if(!w?.mode||w.mode==="tuple")return new CN(W);return new jN(W)}class xN extends e{static[N]="PgMacaddrBuilder";constructor($){super($,"string","PgMacaddr")}build($){return new fN($,this.config)}}class fN extends d{static[N]="PgMacaddr";getSQLType(){return"macaddr"}}function bN($){return new xN($??"")}class yN extends e{static[N]="PgMacaddr8Builder";constructor($){super($,"string","PgMacaddr8")}build($){return new hN($,this.config)}}class hN extends d{static[N]="PgMacaddr8";getSQLType(){return"macaddr8"}}function gN($){return new yN($??"")}class mN extends e{static[N]="PgNumericBuilder";constructor($,T,W){super($,"string","PgNumeric");this.config.precision=T,this.config.scale=W}build($){return new k9($,this.config)}}class k9 extends d{static[N]="PgNumeric";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class cN extends e{static[N]="PgNumericNumberBuilder";constructor($,T,W){super($,"number","PgNumericNumber");this.config.precision=T,this.config.scale=W}build($){return new uN($,this.config)}}class uN extends d{static[N]="PgNumericNumber";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}class pN extends e{static[N]="PgNumericBigIntBuilder";constructor($,T,W){super($,"bigint","PgNumericBigInt");this.config.precision=T,this.config.scale=W}build($){return new dN($,this.config)}}class dN extends d{static[N]="PgNumericBigInt";precision;scale;constructor($,T){super($,T);this.precision=T.precision,this.scale=T.scale}mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){if(this.precision!==void 0&&this.scale!==void 0)return`numeric(${this.precision}, ${this.scale})`;else if(this.precision===void 0)return"numeric";else return`numeric(${this.precision})`}}function oN($,T){let{name:W,config:w}=S$($,T),X=w?.mode;return X==="number"?new cN(W,w?.precision,w?.scale):X==="bigint"?new pN(W,w?.precision,w?.scale):new mN(W,w?.precision,w?.scale)}class lN extends e{static[N]="PgPointTupleBuilder";constructor($){super($,"array","PgPointTuple")}build($){return new rN($,this.config)}}class rN extends d{static[N]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[T,W]=$.slice(1,-1).split(",");return[Number.parseFloat(T),Number.parseFloat(W)]}return[$.x,$.y]}mapToDriverValue($){return`(${$[0]},${$[1]})`}}class nN extends e{static[N]="PgPointObjectBuilder";constructor($){super($,"json","PgPointObject")}build($){return new iN($,this.config)}}class iN extends d{static[N]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue($){if(typeof $==="string"){let[T,W]=$.slice(1,-1).split(",");return{x:Number.parseFloat(T),y:Number.parseFloat(W)}}return $}mapToDriverValue($){return`(${$.x},${$.y})`}}function tN($,T){let{name:W,config:w}=S$($,T);if(!w?.mode||w.mode==="tuple")return new lN(W);return new nN(W)}function yI($){let T=[];for(let W=0;W<$.length;W+=2)T.push(Number.parseInt($.slice(W,W+2),16));return new Uint8Array(T)}function aN($,T){let W=new ArrayBuffer(8),w=new DataView(W);for(let X=0;X<8;X++)w.setUint8(X,$[T+X]);return w.getFloat64(0,!0)}function iO($){let T=yI($),W=0,w=T[W];W+=1;let X=new DataView(T.buffer),U=X.getUint32(W,w===1);W+=4;let Y;if(U&536870912)Y=X.getUint32(W,w===1),W+=4;if((U&65535)===1){let G=aN(T,W);W+=8;let H=aN(T,W);return W+=8,[G,H]}throw new Error("Unsupported geometry type")}class sN extends e{static[N]="PgGeometryBuilder";constructor($){super($,"array","PgGeometry")}build($){return new eN($,this.config)}}class eN extends d{static[N]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue($){return iO($)}mapToDriverValue($){return`point(${$[0]} ${$[1]})`}}class $L extends e{static[N]="PgGeometryObjectBuilder";constructor($){super($,"json","PgGeometryObject")}build($){return new TL($,this.config)}}class TL extends d{static[N]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue($){let T=iO($);return{x:T[0],y:T[1]}}mapToDriverValue($){return`point(${$.x} ${$.y})`}}function WL($,T){let{name:W,config:w}=S$($,T);if(!w?.mode||w.mode==="tuple")return new sN(W);return new $L(W)}class XL extends e{static[N]="PgRealBuilder";constructor($,T){super($,"number","PgReal");this.config.length=T}build($){return new wL($,this.config)}}class wL extends d{static[N]="PgReal";constructor($,T){super($,T)}getSQLType(){return"real"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number.parseFloat($);return $}}function UL($){return new XL($??"")}class YL extends e{static[N]="PgSerialBuilder";constructor($){super($,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new GL($,this.config)}}class GL extends d{static[N]="PgSerial";getSQLType(){return"serial"}}function zL($){return new YL($??"")}class HL extends qT{static[N]="PgSmallIntBuilder";constructor($){super($,"number","PgSmallInt")}build($){return new FL($,this.config)}}class FL extends d{static[N]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number($);return $}}function OL($){return new HL($??"")}class QL extends e{static[N]="PgSmallSerialBuilder";constructor($){super($,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new ZL($,this.config)}}class ZL extends d{static[N]="PgSmallSerial";getSQLType(){return"smallserial"}}function VL($){return new QL($??"")}class KL extends e{static[N]="PgTextBuilder";constructor($,T){super($,"string","PgText");this.config.enumValues=T.enum}build($){return new AL($,this.config)}}class AL extends d{static[N]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function EL($,T={}){let{name:W,config:w}=S$($,T);return new KL(W,w)}class ML extends h0{constructor($,T,W){super($,"string","PgTime");this.withTimezone=T,this.precision=W,this.config.withTimezone=T,this.config.precision=W}static[N]="PgTimeBuilder";build($){return new v9($,this.config)}}class v9 extends d{static[N]="PgTime";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function DL($,T={}){let{name:W,config:w}=S$($,T);return new ML(W,w.withTimezone??!1,w.precision)}class NL extends h0{static[N]="PgTimestampBuilder";constructor($,T,W){super($,"date","PgTimestamp");this.config.withTimezone=T,this.config.precision=W}build($){return new q9($,this.config)}}class q9 extends d{static[N]="PgTimestamp";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=($)=>{return new Date(this.withTimezone?$:$+"+0000")};mapToDriverValue=($)=>{return $.toISOString()}}class LL extends h0{static[N]="PgTimestampStringBuilder";constructor($,T,W){super($,"string","PgTimestampString");this.config.withTimezone=T,this.config.precision=W}build($){return new P9($,this.config)}}class P9 extends d{static[N]="PgTimestampString";withTimezone;precision;constructor($,T){super($,T);this.withTimezone=T.withTimezone,this.precision=T.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function JL($,T={}){let{name:W,config:w}=S$($,T);if(w?.mode==="string")return new LL(W,w.withTimezone??!1,w.precision);return new NL(W,w?.withTimezone??!1,w?.precision)}class RL extends e{static[N]="PgUUIDBuilder";constructor($){super($,"string","PgUUID")}defaultRandom(){return this.default(J`gen_random_uuid()`)}build($){return new C9($,this.config)}}class C9 extends d{static[N]="PgUUID";getSQLType(){return"uuid"}}function L1($){return new RL($??"")}class _L extends e{static[N]="PgVarcharBuilder";constructor($,T){super($,"string","PgVarchar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new kL($,this.config)}}class kL extends d{static[N]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function W6($,T={}){let{name:W,config:w}=S$($,T);return new _L(W,w)}class vL extends e{static[N]="PgBinaryVectorBuilder";constructor($,T){super($,"string","PgBinaryVector");this.config.dimensions=T.dimensions}build($){return new qL($,this.config)}}class qL extends d{static[N]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function PL($,T){let{name:W,config:w}=S$($,T);return new vL(W,w)}class CL extends e{static[N]="PgHalfVectorBuilder";constructor($,T){super($,"array","PgHalfVector");this.config.dimensions=T.dimensions}build($){return new SL($,this.config)}}class SL extends d{static[N]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((T)=>Number.parseFloat(T))}}function jL($,T){let{name:W,config:w}=S$($,T);return new CL(W,w)}class IL extends e{static[N]="PgSparseVectorBuilder";constructor($,T){super($,"string","PgSparseVector");this.config.dimensions=T.dimensions}build($){return new BL($,this.config)}}class BL extends d{static[N]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function xL($,T){let{name:W,config:w}=S$($,T);return new IL(W,w)}class fL extends e{static[N]="PgVectorBuilder";constructor($,T){super($,"array","PgVector");this.config.dimensions=T.dimensions}build($){return new bL($,this.config)}}class bL extends d{static[N]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){return $.slice(1,-1).split(",").map((T)=>Number.parseFloat(T))}}function yL($,T){let{name:W,config:w}=S$($,T);return new fL(W,w)}function hL(){return{bigint:nD,bigserial:eD,boolean:wU,char:wN,cidr:GN,customType:FN,date:ZN,doublePrecision:AN,inet:DN,integer:UU,interval:_N,json:vN,jsonb:PN,line:BN,macaddr:bN,macaddr8:gN,numeric:oN,point:tN,geometry:WL,real:UL,serial:zL,smallint:OL,smallserial:VL,text:EL,time:DL,timestamp:JL,uuid:L1,varchar:W6,bit:PL,halfvec:jL,sparsevec:xL,vector:yL}}var tO=Symbol.for("drizzle:PgInlineForeignKeys"),gL=Symbol.for("drizzle:EnableRLS");class x4 extends o{static[N]="PgTable";static Symbol=Object.assign({},o.Symbol,{InlineForeignKeys:tO,EnableRLS:gL});[tO]=[];[gL]=!1;[o.Symbol.ExtraConfigBuilder]=void 0;[o.Symbol.ExtraConfigColumns]={}}function hI($,T,W,w,X=$){let U=new x4($,w,X),Y=typeof T==="function"?T(hL()):T,G=Object.fromEntries(Object.entries(Y).map(([F,O])=>{let Q=O;Q.setName(F);let Z=Q.build(U);return U[tO].push(...Q.buildForeignKeys(Z,U)),[F,Z]})),H=Object.fromEntries(Object.entries(Y).map(([F,O])=>{let Q=O;Q.setName(F);let Z=Q.buildExtraConfigColumn(U);return[F,Z]})),z=Object.assign(U,G);if(z[o.Symbol.Columns]=G,z[o.Symbol.ExtraConfigColumns]=H,W)z[x4.Symbol.ExtraConfigBuilder]=W;return Object.assign(z,{enableRLS:()=>{return z[x4.Symbol.EnableRLS]=!0,z}})}var PT=($,T,W)=>{return hI($,T,W,void 0)};function mL(...$){if($[0].columns)return new YU($[0].columns,$[0].name);return new YU($)}class YU{static[N]="PgPrimaryKeyBuilder";columns;name;constructor($,T){this.columns=$,this.name=T}build($){return new cL($,this.columns,this.name)}}class cL{constructor($,T,W){this.table=$,this.columns=T,this.name=W}static[N]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[x4.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}function u6($,T){if(bD(T)&&!pO($)&&!I($,F1)&&!I($,vT)&&!I($,p$)&&!I($,o)&&!I($,c6))return new F1($,T);return $}var S9=($,T)=>{return J`${$} = ${u6(T,$)}`},uL=($,T)=>{return J`${$} <> ${u6(T,$)}`};function GU(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new s(T);return new s([new B4("("),J.join(T,new B4(" and ")),new B4(")")])}function pL(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new s(T);return new s([new B4("("),J.join(T,new B4(" or ")),new B4(")")])}function dL($){return J`not ${$}`}var j9=($,T)=>{return J`${$} > ${u6(T,$)}`},oL=($,T)=>{return J`${$} >= ${u6(T,$)}`},lL=($,T)=>{return J`${$} < ${u6(T,$)}`},rL=($,T)=>{return J`${$} <= ${u6(T,$)}`};function nL($,T){if(Array.isArray(T)){if(T.length===0)return J`false`;return J`${$} in ${T.map((W)=>u6(W,$))}`}return J`${$} in ${u6(T,$)}`}function iL($,T){if(Array.isArray(T)){if(T.length===0)return J`true`;return J`${$} not in ${T.map((W)=>u6(W,$))}`}return J`${$} not in ${u6(T,$)}`}function tL($){return J`${$} is null`}function aL($){return J`${$} is not null`}function sL($){return J`exists ${$}`}function eL($){return J`not exists ${$}`}function $J($,T,W){return J`${$} between ${u6(T,$)} and ${u6(W,$)}`}function TJ($,T,W){return J`${$} not between ${u6(T,$)} and ${u6(W,$)}`}function WJ($,T){return J`${$} like ${T}`}function XJ($,T){return J`${$} not like ${T}`}function wJ($,T){return J`${$} ilike ${T}`}function UJ($,T){return J`${$} not ilike ${T}`}function YJ($){return J`${$} asc`}function GJ($){return J`${$} desc`}class aO{constructor($,T,W){this.sourceTable=$,this.referencedTable=T,this.relationName=W,this.referencedTableName=T[o.Symbol.Name]}static[N]="Relation";referencedTableName;fieldName}class zJ{constructor($,T){this.table=$,this.config=T}static[N]="Relations"}class CT extends aO{constructor($,T,W,w){super($,T,W?.relationName);this.config=W,this.isNullable=w}static[N]="One";withFieldName($){let T=new CT(this.sourceTable,this.referencedTable,this.config,this.isNullable);return T.fieldName=$,T}}class zU extends aO{constructor($,T,W){super($,T,W?.relationName);this.config=W}static[N]="Many";withFieldName($){let T=new zU(this.sourceTable,this.referencedTable,this.config);return T.fieldName=$,T}}function HJ(){return{and:GU,between:$J,eq:S9,exists:sL,gt:j9,gte:oL,ilike:wJ,inArray:nL,isNull:tL,isNotNull:aL,like:WJ,lt:lL,lte:rL,ne:uL,not:dL,notBetween:TJ,notExists:eL,notLike:XJ,notIlike:UJ,notInArray:iL,or:pL,sql:J}}function FJ(){return{sql:J,asc:YJ,desc:GJ}}function OJ($,T){if(Object.keys($).length===1&&"default"in $&&!I($.default,o))$=$.default;let W={},w={},X={};for(let[U,Y]of Object.entries($))if(I(Y,o)){let G=kW(Y),H=w[G];W[G]=U,X[U]={tsName:U,dbName:Y[o.Symbol.Name],schema:Y[o.Symbol.Schema],columns:Y[o.Symbol.Columns],relations:H?.relations??{},primaryKey:H?.primaryKey??[]};for(let F of Object.values(Y[o.Symbol.Columns]))if(F.primary)X[U].primaryKey.push(F);let z=Y[o.Symbol.ExtraConfigBuilder]?.(Y[o.Symbol.ExtraConfigColumns]);if(z){for(let F of Object.values(z))if(I(F,YU))X[U].primaryKey.push(...F.columns)}}else if(I(Y,zJ)){let G=kW(Y.table),H=W[G],z=Y.config(T(Y.table)),F;for(let[O,Q]of Object.entries(z))if(H){let Z=X[H];if(Z.relations[O]=Q,F)Z.primaryKey.push(...F)}else{if(!(G in w))w[G]={relations:{},primaryKey:F};w[G].relations[O]=Q}}return{tables:X,tableNamesMap:W}}function gI($){return function T(W,w){return new CT($,W,w,w?.fields.reduce((X,U)=>X&&U.notNull,!0)??!1)}}function mI($){return function T(W,w){return new zU($,W,w)}}function QJ($,T,W){if(I(W,CT)&&W.config)return{fields:W.config.fields,references:W.config.references};let w=T[kW(W.referencedTable)];if(!w)throw new Error(`Table "${W.referencedTable[o.Symbol.Name]}" not found in schema`);let X=$[w];if(!X)throw new Error(`Table "${w}" not found in schema`);let U=W.sourceTable,Y=T[kW(U)];if(!Y)throw new Error(`Table "${U[o.Symbol.Name]}" not found in schema`);let G=[];for(let H of Object.values(X.relations))if(W.relationName&&W!==H&&H.relationName===W.relationName||!W.relationName&&H.referencedTable===W.sourceTable)G.push(H);if(G.length>1)throw W.relationName?new Error(`There are multiple relations with name "${W.relationName}" in table "${w}"`):new Error(`There are multiple relations between "${w}" and "${W.sourceTable[o.Symbol.Name]}". Please specify relation name`);if(G[0]&&I(G[0],CT)&&G[0].config)return{fields:G[0].config.references,references:G[0].config.fields};throw new Error(`There is not enough information to infer relation "${Y}.${W.fieldName}"`)}function ZJ($){return{one:gI($),many:mI($)}}function I9($,T,W,w,X=(U)=>U){let U={};for(let[Y,G]of w.entries())if(G.isJson){let H=T.relations[G.tsKey],z=W[Y],F=typeof z==="string"?JSON.parse(z):z;U[G.tsKey]=I(H,CT)?F&&I9($,$[G.relationTableTsKey],F,G.selection,X):F.map((O)=>I9($,$[G.relationTableTsKey],O,G.selection,X))}else{let H=X(W[Y]),z=G.field,F;if(I(z,p$))F=z;else if(I(z,s))F=z.decoder;else F=z.sql.decoder;U[G.tsKey]=H===null?null:F.mapFromDriverValue(H)}return U}import Sy from"path";import FB from"os";import OB from"fs";var B9=new Map,sO=new Map,eO=Symbol("OriginError"),o2={};class J1 extends Promise{constructor($,T,W,w,X={}){let U,Y;super((G,H)=>{U=G,Y=H});this.tagged=Array.isArray($.raw),this.strings=$,this.args=T,this.handler=W,this.canceller=w,this.options=X,this.state=null,this.statement=null,this.resolve=(G)=>(this.active=!1,U(G)),this.reject=(G)=>(this.active=!1,Y(G)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[eO]=this.handler.debug?new Error:this.tagged&&cI(this.strings)}get origin(){return(this.handler.debug?this[eO].stack:this.tagged&&sO.has(this.strings)?sO.get(this.strings):sO.set(this.strings,this[eO].stack).get(this.strings))||""}static get[Symbol.species](){return Promise}cancel(){return this.canceller&&(this.canceller(this),this.canceller=null)}simple(){return this.options.simple=!0,this.options.prepare=!1,this}async readable(){return this.simple(),this.streaming=!0,this}async writable(){return this.simple(),this.streaming=!0,this}cursor($=1,T){if(this.options.simple=!1,typeof $==="function")T=$,$=1;if(this.cursorRows=$,typeof T==="function")return this.cursorFn=T,this;let W;return{[Symbol.asyncIterator]:()=>({next:()=>{if(this.executed&&!this.active)return{done:!0};W&&W();let w=new Promise((X,U)=>{this.cursorFn=(Y)=>{return X({value:Y,done:!1}),new Promise((G)=>W=G)},this.resolve=()=>(this.active=!1,X({done:!0})),this.reject=(Y)=>(this.active=!1,U(Y))});return this.execute(),w},return(){return W&&W(o2),{done:!0}}})}}describe(){return this.options.simple=!1,this.onlyDescribe=this.options.prepare=!0,this}stream(){throw new Error(".stream has been renamed to .forEach")}forEach($){return this.forEachFn=$,this.handle(),this}raw(){return this.isRaw=!0,this}values(){return this.isRaw="values",this}async handle(){!this.executed&&(this.executed=!0)&&await 1&&this.handler(this)}execute(){return this.handle(),this}then(){return this.handle(),super.then.apply(this,arguments)}catch(){return this.handle(),super.catch.apply(this,arguments)}finally(){return this.handle(),super.finally.apply(this,arguments)}}function cI($){if(B9.has($))return B9.get($);let T=Error.stackTraceLimit;return Error.stackTraceLimit=4,B9.set($,new Error),Error.stackTraceLimit=T,B9.get($)}class l2 extends Error{constructor($){super($.message);this.name=this.constructor.name,Object.assign(this,$)}}var J4={connection:VJ,postgres:KJ,generic:AJ,notSupported:EJ};function VJ($,T,W){let{host:w,port:X}=W||T,U=Object.assign(new Error("write "+$+" "+(T.path||w+":"+X)),{code:$,errno:$,address:T.path||w},T.path?{}:{port:X});return Error.captureStackTrace(U,VJ),U}function KJ($){let T=new l2($);return Error.captureStackTrace(T,KJ),T}function AJ($,T){let W=Object.assign(new Error($+": "+T),{code:$});return Error.captureStackTrace(W,AJ),W}function EJ($){let T=Object.assign(new Error($+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:$});return Error.captureStackTrace(T,EJ),T}var uI={string:{to:25,from:null,serialize:($)=>""+$},number:{to:0,from:[21,23,26,700,701],serialize:($)=>""+$,parse:($)=>+$},json:{to:114,from:[114,3802],serialize:($)=>JSON.stringify($),parse:($)=>JSON.parse($)},boolean:{to:16,from:16,serialize:($)=>$===!0?"t":"f",parse:($)=>$==="t"},date:{to:1184,from:[1082,1114,1184],serialize:($)=>($ instanceof Date?$:new Date($)).toISOString(),parse:($)=>new Date($)},bytea:{to:17,from:17,serialize:($)=>"\\x"+Buffer.from($).toString("hex"),parse:($)=>Buffer.from($.slice(2),"hex")}};class b9{then(){$Q()}catch(){$Q()}finally(){$Q()}}class QU extends b9{constructor($){super();this.value=g9($)}}class G0 extends b9{constructor($,T,W){super();this.value=$,this.type=T,this.array=W}}class y9 extends b9{constructor($,T){super();this.first=$,this.rest=T}build($,T,W,w){let X=pI.map(([U,Y])=>({fn:Y,i:$.search(U)})).sort((U,Y)=>U.i-Y.i).pop();return X.i===-1?UQ(this.first,w):X.fn(this.first,this.rest,T,W,w)}}function h9($,T,W,w){let X=$ instanceof G0?$.value:$;if(X===void 0){if($ instanceof G0?$.value=w.transform.undefined:X=$=w.transform.undefined,X===void 0)throw J4.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return"$"+W.push($ instanceof G0?(T.push($.value),$.array?$.array[$.type||f9($.value)]||$.type||LJ($.value):$.type):(T.push($),f9($)))}var DJ=RJ(uI);function XQ($,T,W,w,X,U){for(let Y=1;Y<$.strings.length;Y++)T+=wQ(T,W,w,X,U)+$.strings[Y],W=$.args[Y];return T}function wQ($,T,W,w,X){return T instanceof y9?T.build($,W,w,X):T instanceof J1?WQ(T,W,w,X):T instanceof QU?T.value:T&&T[0]instanceof J1?T.reduce((U,Y)=>U+" "+WQ(Y,W,w,X),""):h9(T,W,w,X)}function WQ($,T,W,w){return $.fragment=!0,XQ($,$.strings[0],$.args[0],T,W,w)}function NJ($,T,W,w,X){return $.map((U)=>"("+w.map((Y)=>wQ("values",U[Y],T,W,X)).join(",")+")").join(",")}function MJ($,T,W,w,X){let U=Array.isArray($[0]),Y=T.length?T.flat():Object.keys(U?$[0]:$);return NJ(U?$:[$],W,w,Y,X)}function x9($,T,W,w,X){if(typeof $==="string"&&($=[$].concat(T)),Array.isArray($))return UQ($,X);let U;return(T.length?T.flat():Object.keys($)).map((G)=>{return U=$[G],(U instanceof J1?WQ(U,W,w,X):U instanceof QU?U.value:h9(U,W,w,X))+" as "+g9(X.transform.column.to?X.transform.column.to(G):G)}).join(",")}var pI=Object.entries({values:MJ,in:(...$)=>{let T=MJ(...$);return T==="()"?"(null)":T},select:x9,as:x9,returning:x9,"\\(":x9,update($,T,W,w,X){return(T.length?T.flat():Object.keys($)).map((U)=>g9(X.transform.column.to?X.transform.column.to(U):U)+"="+wQ("values",$[U],W,w,X))},insert($,T,W,w,X){let U=T.length?T.flat():Object.keys(Array.isArray($)?$[0]:$);return"("+UQ(U,X)+")values"+NJ(Array.isArray($)?$:[$],W,w,U,X)}}).map(([$,T])=>[new RegExp("((?:^|[\\s(])"+$+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),T]);function $Q(){throw J4.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var{serializers:dI,parsers:oI}=DJ;function LJ($){if(Array.isArray($))return LJ($[0]);return typeof $==="string"?1009:0}var JJ=function($){let T=RJ($||{});return{serializers:Object.assign({},dI,T.serializers),parsers:Object.assign({},oI,T.parsers)}};function RJ($){return Object.keys($).reduce((T,W)=>{if($[W].from&&[].concat($[W].from).forEach((w)=>T.parsers[w]=$[W].parse),$[W].serialize)T.serializers[$[W].to]=$[W].serialize,$[W].from&&[].concat($[W].from).forEach((w)=>T.serializers[w]=$[W].serialize);return T},{parsers:{},serializers:{}})}function UQ($,{transform:{column:T}}){return $.map((W)=>g9(T.to?T.to(W):W)).join(",")}var g9=function $(T){return'"'+T.replace(/"/g,'""').replace(/\./g,'"."')+'"'},f9=function $(T){return T instanceof G0?T.type:T instanceof Date?1184:T instanceof Uint8Array?17:T===!0||T===!1?16:typeof T==="bigint"?20:Array.isArray(T)?$(T[0]):0},lI=/\\/g,rI=/"/g;function nI($){return $.replace(lI,"\\\\").replace(rI,"\\\"")}var _J=function $(T,W,w,X){if(Array.isArray(T)===!1)return T;if(!T.length)return"{}";let U=T[0],Y=X===1020?";":",";if(Array.isArray(U)&&!U.type)return"{"+T.map((G)=>$(G,W,w,X)).join(Y)+"}";return"{"+T.map((G)=>{if(G===void 0){if(G=w.transform.undefined,G===void 0)throw J4.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return G===null?"null":'"'+nI(W?W(G.type?G.value:G):""+G)+'"'}).join(Y)+"}"},TQ={i:0,char:null,str:"",quoted:!1,last:0},kJ=function $(T,W,w){return TQ.i=TQ.last=0,vJ(TQ,T,W,w)};function vJ($,T,W,w){let X=[],U=w===1020?";":",";for(;$.i<T.length;$.i++){if($.char=T[$.i],$.quoted)if($.char==="\\")$.str+=T[++$.i];else if($.char==='"')X.push(W?W($.str):$.str),$.str="",$.quoted=T[$.i+1]==='"',$.last=$.i+2;else $.str+=$.char;else if($.char==='"')$.quoted=!0;else if($.char==="{")$.last=++$.i,X.push(vJ($,T,W,w));else if($.char==="}"){$.quoted=!1,$.last<$.i&&X.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;break}else if($.char===U&&$.p!=="}"&&$.p!=='"')X.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;$.p=$.char}return $.last<$.i&&X.push(W?W(T.slice($.last,$.i+1)):T.slice($.last,$.i+1)),X}var vW=($)=>{let T=$[0];for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},qW=($)=>{let T=$[0].toUpperCase();for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},PW=($)=>$.replace(/_/g,"-"),HU=($)=>$.replace(/([A-Z])/g,"_$1").toLowerCase(),FU=($)=>($.slice(0,1)+$.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),OU=($)=>$.replace(/-/g,"_");function YQ($){return function T(W,w){return typeof W==="object"&&W!==null&&(w.type===114||w.type===3802)?Array.isArray(W)?W.map((X)=>T(X,w)):Object.entries(W).reduce((X,[U,Y])=>Object.assign(X,{[$(U)]:T(Y,w)}),{}):W}}vW.column={from:vW};vW.value={from:YQ(vW)};HU.column={to:HU};var GQ={...vW};GQ.column.to=HU;qW.column={from:qW};qW.value={from:YQ(qW)};FU.column={to:FU};var zQ={...qW};zQ.column.to=FU;PW.column={from:PW};PW.value={from:YQ(PW)};OU.column={to:OU};var HQ={...PW};HQ.column.to=OU;import qJ from"net";import sI from"tls";import ZU from"crypto";import FQ from"stream";import{performance as PJ}from"perf_hooks";class CW extends Array{constructor(){super();Object.defineProperties(this,{count:{value:null,writable:!0},state:{value:null,writable:!0},command:{value:null,writable:!0},columns:{value:null,writable:!0},statement:{value:null,writable:!0}})}static get[Symbol.species](){return Array}}var O1=iI;function iI($=[]){let T=$.slice(),W=0;return{get length(){return T.length-W},remove:(w)=>{let X=T.indexOf(w);return X===-1?null:(T.splice(X,1),w)},push:(w)=>(T.push(w),w),shift:()=>{let w=T[W++];if(W===T.length)W=0,T=[];else T[W-1]=void 0;return w}}}var X6=Buffer.allocUnsafe(256),tI="BCcDdEFfHPpQSX".split("").reduce(($,T)=>{let W=T.charCodeAt(0);return $[T]=()=>{return X6[0]=W,u$.i=5,u$},$},{}),u$=Object.assign(aI,tI,{N:String.fromCharCode(0),i:0,inc($){return u$.i+=$,u$},str($){let T=Buffer.byteLength($);return m9(T),u$.i+=X6.write($,u$.i,T,"utf8"),u$},i16($){return m9(2),X6.writeUInt16BE($,u$.i),u$.i+=2,u$},i32($,T){if(T||T===0)return X6.writeUInt32BE($,T),u$;return m9(4),X6.writeUInt32BE($,u$.i),u$.i+=4,u$},z($){return m9($),X6.fill(0,u$.i,u$.i+$),u$.i+=$,u$},raw($){return X6=Buffer.concat([X6.subarray(0,u$.i),$]),u$.i=X6.length,u$},end($=1){X6.writeUInt32BE(u$.i-$,$);let T=X6.subarray(0,u$.i);return u$.i=0,X6=Buffer.allocUnsafe(256),T}}),Y$=u$;function m9($){if(X6.length-u$.i<$){let T=X6,W=T.length;X6=Buffer.allocUnsafe(W+(W>>1)+$),T.copy(X6)}}function aI(){return u$.i=0,u$}var ZQ=jJ,eI=1,ST=Y$().S().end(),CJ=Y$().H().end(),$B=Y$().i32(8).i32(80877103).end(8),TB=Buffer.concat([Y$().E().str(Y$.N).i32(0).end(),ST]),WB=Y$().D().str("S").str(Y$.N).end(),r2=()=>{},XB=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),wB={83:"severity_local",86:"severity",67:"code",77:"message",68:"detail",72:"hint",80:"position",112:"internal_position",113:"internal_query",87:"where",115:"schema_name",116:"table_name",99:"column_name",100:"data type_name",110:"constraint_name",70:"file",76:"line",82:"routine"};function jJ($,T={},{onopen:W=r2,onend:w=r2,onclose:X=r2}={}){let{ssl:U,max:Y,user:G,host:H,port:z,database:F,parsers:O,transform:Q,onnotice:Z,onnotify:K,onparameter:E,max_pipeline:M,keep_alive:L,backoff:R,target_session_attrs:_}=$,S=O1(),x=eI++,b={pid:null,secret:null},g=QQ(Sz,$.idle_timeout),T$=QQ(Sz,$.max_lifetime),N$=QQ(Mv,$.connect_timeout),j=null,U$,t=new CW,z$=Buffer.alloc(0),B$=$.fetch_types,e$={},h4={},n6=Math.random().toString(36).slice(2),c=1,F$=0,g$=0,Y4=0,_4=0,L$=0,m$=0,D4=0,G4=null,$4=null,t4=!1,l$=null,q1=null,p4=null,a0=null,k4=null,T4=null,P1=null,u1=null,n=null,AX=null,a4={queue:T.closed,idleTimer:g,connect(D){p4=D,UV()},terminate:MX,execute:EX,cancel:Vv,end:Sz,count:0,id:x};return T.closed&&T.closed.push(a4),a4;async function Zv(){let D;try{D=$.socket?await Promise.resolve($.socket($)):new qJ.Socket}catch(q){gW(q);return}return D.on("error",gW),D.on("close",YV),D.on("drain",XV),D}async function Vv({pid:D,secret:q},H$,f$){try{U$=Y$().i32(16).i32(80877102).i32(D).i32(q).end(16),await wV(),j.once("error",f$),j.once("close",H$)}catch(V4){f$(V4)}}function EX(D){if(t4)return tU(D,J4.connection("CONNECTION_DESTROYED",$));if(D.cancelled)return;try{return D.state=b,n?S.push(D):(n=D,n.active=!0),Ev(D),d4(Kv(D))&&!D.describeFirst&&!D.cursorFn&&S.length<M&&(!D.options.onexecute||D.options.onexecute(a4))}catch(q){return S.length===0&&d4(ST),p1(q),!0}}function Kv(D){if(D.parameters.length>=65534)throw J4.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return D.options.simple?Y$().Q().str(D.statement.string+Y$.N).end():D.describeFirst?Buffer.concat([$V(D),CJ]):D.prepare?D.prepared?iU(D):Buffer.concat([$V(D),iU(D)]):Av(D)}function $V(D){return Buffer.concat([zV(D.statement.string,D.parameters,D.statement.types,D.statement.name),Wq("S",D.statement.name)])}function iU(D){return Buffer.concat([Tq(D.parameters,D.statement.types,D.statement.name,D.cursorName),D.cursorFn?HV("",D.cursorRows):TB])}function Av(D){return Buffer.concat([zV(D.statement.string,D.parameters,D.statement.types),WB,iU(D)])}function Ev(D){let q=[],H$=[],f$=XQ(D,D.strings[0],D.args[0],q,H$,$);!D.tagged&&D.args.forEach((V4)=>h9(V4,q,H$,$)),D.prepare=$.prepare&&("prepare"in D.options?D.options.prepare:!0),D.string=f$,D.signature=D.prepare&&H$+f$,D.onlyDescribe&&delete h4[D.signature],D.parameters=D.parameters||q,D.prepared=D.prepare&&D.signature in h4,D.describeFirst=D.onlyDescribe||q.length&&!D.prepared,D.statement=D.prepared?h4[D.signature]:{string:f$,types:H$,name:D.prepare?n6+c++:""},typeof $.debug==="function"&&$.debug(x,f$,q,H$)}function d4(D,q){if(T4=T4?Buffer.concat([T4,D]):Buffer.from(D),q||T4.length>=1024)return TV(q);return $4===null&&($4=setImmediate(TV)),!0}function TV(D){let q=j.write(T4,D);return $4!==null&&clearImmediate($4),T4=$4=null,q}function Mv(){p1(J4.connection("CONNECT_TIMEOUT",$,j)),j.destroy()}async function WV(){if(d4($B),!await new Promise((q)=>j.once("data",(H$)=>q(H$[0]===83)))&&U==="prefer")return hW();j.removeAllListeners(),j=sI.connect({socket:j,servername:qJ.isIP(j.host)?void 0:j.host,...U==="require"||U==="allow"||U==="prefer"?{rejectUnauthorized:!1}:U==="verify-full"?{}:typeof U==="object"?U:{}}),j.on("secureConnect",hW),j.on("error",gW),j.on("close",YV),j.on("drain",XV)}function XV(){!n&&W(a4)}function Cz(D){if(l$){if(l$.push(D),g$-=D.length,g$>0)return}z$=l$?Buffer.concat(l$,L$-g$):z$.length===0?D:Buffer.concat([z$,D],z$.length+D.length);while(z$.length>4){if(L$=z$.readUInt32BE(1),L$>=z$.length){g$=L$-z$.length,l$=[z$];break}try{Dv(z$.subarray(0,L$+1))}catch(q){n&&(n.cursorFn||n.describeFirst)&&d4(ST),p1(q)}z$=z$.subarray(L$+1),g$=0,l$=null}}async function wV(){if(t4=!1,e$={},j||(j=await Zv()),!j)return;if(N$.start(),$.socket)return U?WV():hW();if(j.on("connect",U?WV:hW),$.path)return j.connect($.path);j.ssl=U,j.connect(z[Y4],H[Y4]),j.host=H[Y4],j.port=z[Y4],Y4=(Y4+1)%z.length}function UV(){setTimeout(wV,F$?F$+m$-PJ.now():0)}function hW(){try{h4={},B$=$.fetch_types,n6=Math.random().toString(36).slice(2),c=1,T$.start(),j.on("data",Cz),L&&j.setKeepAlive&&j.setKeepAlive(!0,1000*L);let D=wq();d4(D)}catch(D){gW(D)}}function gW(D){if(a4.queue===T.connecting&&$.host[_4+1])return;p1(D);while(S.length)tU(S.shift(),D)}function p1(D){k4&&(k4.destroy(D),k4=null),n&&tU(n,D),p4&&(tU(p4,D),p4=null)}function tU(D,q){if(D.reserve)return D.reject(q);if(!q||typeof q!=="object")q=new Error(q);"query"in q||"parameters"in q||Object.defineProperties(q,{stack:{value:q.stack+D.origin.replace(/.*\n/,`
83
+ `),enumerable:$.debug},query:{value:D.string,enumerable:$.debug},parameters:{value:D.parameters,enumerable:$.debug},args:{value:D.args,enumerable:$.debug},types:{value:D.statement&&D.statement.types,enumerable:$.debug}}),D.reject(q)}function Sz(){return a0||(!a4.reserved&&w(a4),!a4.reserved&&!p4&&!n&&S.length===0?(MX(),new Promise((D)=>j&&j.readyState!=="closed"?j.once("close",D):D())):a0=new Promise((D)=>P1=D))}function MX(){if(t4=!0,k4||n||p4||S.length)gW(J4.connection("CONNECTION_DESTROYED",$));if(clearImmediate($4),j)j.removeListener("data",Cz),j.removeListener("connect",hW),j.readyState==="open"&&j.end(Y$().X().end());P1&&(P1(),a0=P1=null)}async function YV(D){if(z$=Buffer.alloc(0),g$=0,l$=null,clearImmediate($4),j.removeListener("data",Cz),j.removeListener("connect",hW),g.cancel(),T$.cancel(),N$.cancel(),j.removeAllListeners(),j=null,p4)return UV();!D&&(n||S.length)&&gW(J4.connection("CONNECTION_CLOSED",$,j)),F$=PJ.now(),D&&$.shared.retries++,m$=(typeof R==="function"?R($.shared.retries):R)*1000,X(a4,J4.connection("CONNECTION_CLOSED",$,j))}function Dv(D,q=D[0]){(q===68?Nv:q===100?rv:q===65?cv:q===83?Lv:q===90?Jv:q===67?Rv:q===50?GV:q===49?_v:q===116?kv:q===84?vv:q===82?qv:q===110?Bv:q===75?xv:q===69?gv:q===115?uv:q===51?pv:q===71?dv:q===78?iv:q===72?ov:q===99?nv:q===73?tv:q===86?av:q===118?sv:q===87?lv:ev)(D)}function Nv(D){let q=7,H$,f$,V4,s4=n.isRaw?new Array(n.statement.columns.length):{};for(let Y6=0;Y6<n.statement.columns.length;Y6++)f$=n.statement.columns[Y6],H$=D.readInt32BE(q),q+=4,V4=H$===-1?null:n.isRaw===!0?D.subarray(q,q+=H$):f$.parser===void 0?D.toString("utf8",q,q+=H$):f$.parser.array===!0?f$.parser(D.toString("utf8",q+1,q+=H$)):f$.parser(D.toString("utf8",q,q+=H$)),n.isRaw?s4[Y6]=n.isRaw===!0?V4:Q.value.from?Q.value.from(V4,f$):V4:s4[f$.name]=Q.value.from?Q.value.from(V4,f$):V4;n.forEachFn?n.forEachFn(Q.row.from?Q.row.from(s4):s4,t):t[D4++]=Q.row.from?Q.row.from(s4):s4}function Lv(D){let[q,H$]=D.toString("utf8",5,D.length-1).split(Y$.N);if(e$[q]=H$,$.parameters[q]!==H$)$.parameters[q]=H$,E&&E(q,H$)}function Jv(D){if(n&&n.options.simple&&n.resolve(q1||t),n=q1=null,t=new CW,N$.cancel(),p4){if(_){if(!e$.in_hot_standby||!e$.default_transaction_read_only)return hv();else if(yv(_,e$))return MX()}if(B$)return p4.reserve&&(p4=null),fv();p4&&!p4.reserve&&EX(p4),$.shared.retries=_4=0,p4=null;return}while(S.length&&(n=S.shift())&&(n.active=!0,n.cancelled))jJ($).cancel(n.state,n.cancelled.resolve,n.cancelled.reject);if(n)return;a4.reserved?!a4.reserved.release&&D[5]===73?a0?MX():(a4.reserved=null,W(a4)):a4.reserved():a0?MX():W(a4)}function Rv(D){D4=0;for(let q=D.length-1;q>0;q--){if(D[q]===32&&D[q+1]<58&&t.count===null)t.count=+D.toString("utf8",q+1,D.length-1);if(D[q-1]>=65){t.command=D.toString("utf8",5,q),t.state=b;break}}if(AX&&(AX(),AX=null),t.command==="BEGIN"&&Y!==1&&!a4.reserved)return p1(J4.generic("UNSAFE_TRANSACTION","Only use sql.begin, sql.reserved or max: 1"));if(n.options.simple)return GV();if(n.cursorFn)t.count&&n.cursorFn(t),d4(ST);n.resolve(t)}function _v(){n.parsing=!1}function GV(){!t.statement&&(t.statement=n.statement),t.columns=n.statement.columns}function kv(D){let q=D.readUInt16BE(5);for(let H$=0;H$<q;++H$)!n.statement.types[H$]&&(n.statement.types[H$]=D.readUInt32BE(7+H$*4));n.prepare&&(h4[n.signature]=n.statement),n.describeFirst&&!n.onlyDescribe&&(d4(iU(n)),n.describeFirst=!1)}function vv(D){if(t.command)q1=q1||[t],q1.push(t=new CW),t.count=null,n.statement.columns=null;let q=D.readUInt16BE(5),H$=7,f$;n.statement.columns=Array(q);for(let V4=0;V4<q;++V4){f$=H$;while(D[H$++]!==0);let s4=D.readUInt32BE(H$),Y6=D.readUInt16BE(H$+4),s0=D.readUInt32BE(H$+6);n.statement.columns[V4]={name:Q.column.from?Q.column.from(D.toString("utf8",f$,H$-1)):D.toString("utf8",f$,H$-1),parser:O[s0],table:s4,number:Y6,type:s0},H$+=18}if(t.statement=n.statement,n.onlyDescribe)return n.resolve(n.statement),d4(ST)}async function qv(D,q=D.readUInt32BE(5)){(q===3?Pv:q===5?Cv:q===10?Sv:q===11?jv:q===12?Iv:q!==0?$q:r2)(D,q)}async function Pv(){let D=await jz();d4(Y$().p().str(D).z(1).end())}async function Cv(D){let q="md5"+await SJ(Buffer.concat([Buffer.from(await SJ(await jz()+G)),D.subarray(9)]));d4(Y$().p().str(q).z(1).end())}async function Sv(){u1=(await ZU.randomBytes(18)).toString("base64"),Y$().p().str("SCRAM-SHA-256"+Y$.N);let D=Y$.i;d4(Y$.inc(4).str("n,,n=*,r="+u1).i32(Y$.i-D-4,D).end())}async function jv(D){let q=D.toString("utf8",9).split(",").reduce((Y6,s0)=>(Y6[s0[0]]=s0.slice(2),Y6),{}),H$=await ZU.pbkdf2Sync(await jz(),Buffer.from(q.s,"base64"),parseInt(q.i),32,"sha256"),f$=await c9(H$,"Client Key"),V4="n=*,r="+u1+",r="+q.r+",s="+q.s+",i="+q.i+",c=biws,r="+q.r;G4=(await c9(await c9(H$,"Server Key"),V4)).toString("base64");let s4="c=biws,r="+q.r+",p="+YB(f$,Buffer.from(await c9(await UB(f$),V4))).toString("base64");d4(Y$().p().str(s4).end())}function Iv(D){if(D.toString("utf8",9).split(Y$.N,1)[0].slice(2)===G4)return;p1(J4.generic("SASL_SIGNATURE_MISMATCH","The server did not return the correct signature")),j.destroy()}function jz(){return Promise.resolve(typeof $.pass==="function"?$.pass():$.pass)}function Bv(){if(t.statement=n.statement,t.statement.columns=[],n.onlyDescribe)return n.resolve(n.statement),d4(ST)}function xv(D){b.pid=D.readUInt32BE(5),b.secret=D.readUInt32BE(9)}async function fv(){B$=!1,(await new J1([`
82
84
  select b.oid, b.typarray
83
85
  from pg_catalog.pg_type a
84
86
  left join pg_catalog.pg_type b on b.oid = a.typelem
85
87
  where a.typcategory = 'A'
86
88
  group by b.oid, b.typarray
87
89
  order by b.oid
88
- `],[],WW)).forEach(({oid:A,typarray:t})=>eA(A,t))}function eA(O,A){if(!!$.parsers[A]&&!!$.serializers[A])return;let t=$.parsers[O];$.shared.typeArrayMap[O]=A,$.parsers[A]=(V$)=>pZ(V$,t,A),$.parsers[A].array=!0,$.serializers[A]=(V$)=>uZ(V$,$.serializers[O],$,A)}function $M(O,A){return O==="read-write"&&A.default_transaction_read_only==="on"||O==="read-only"&&A.default_transaction_read_only==="off"||O==="primary"&&A.in_hot_standby==="on"||O==="standby"&&A.in_hot_standby==="off"||O==="prefer-standby"&&A.in_hot_standby==="off"&&$.host[T4]}function TM(){let O=new z6([`
90
+ `],[],EX)).forEach(({oid:q,typarray:H$})=>bv(q,H$))}function bv(D,q){if(!!$.parsers[q]&&!!$.serializers[q])return;let H$=$.parsers[D];$.shared.typeArrayMap[D]=q,$.parsers[q]=(f$)=>kJ(f$,H$,q),$.parsers[q].array=!0,$.serializers[q]=(f$)=>_J(f$,$.serializers[D],$,q)}function yv(D,q){return D==="read-write"&&q.default_transaction_read_only==="on"||D==="read-only"&&q.default_transaction_read_only==="off"||D==="primary"&&q.in_hot_standby==="on"||D==="standby"&&q.in_hot_standby==="off"||D==="prefer-standby"&&q.in_hot_standby==="off"&&$.host[_4]}function hv(){let D=new J1([`
89
91
  show transaction_read_only;
90
92
  select pg_catalog.pg_is_in_recovery()
91
- `],[],WW,null,{simple:!0});O.resolve=([[A],[t]])=>{V4.default_transaction_read_only=A.transaction_read_only,V4.in_hot_standby=t.pg_is_in_recovery?"on":"off"},O.execute()}function WM(O){m&&(m.cursorFn||m.describeFirst)&&Q4(c1);let A=s$.postgres(dz(O));m&&m.retried?q6(m.retried):m&&m.prepared&&dk.has(A.routine)?UM(m,A):q6(A)}function UM(O,A){delete Q6[O.signature],O.retried=A,WW(O)}function XM(O){if(!V)return;let A=9;while(O[A++]!==0);V(O.toString("utf8",9,A-1),O.toString("utf8",A,O.length-1))}async function YM(){try{let O=await Promise.resolve(m.cursorFn($$));n$=0,O===qT?Q4(AM(m.portal)):($$=new j0,Q4(p5("",m.cursorRows)))}catch(O){Q4(c1),m.reject(O)}}function _M(){$$.count&&m.cursorFn($$),m.resolve($$)}function wM(){W4=new oz.Writable({autoDestroy:!0,write(O,A,t){B.write(i().d().raw(O).end(),t)},destroy(O,A){A(O),B.write(i().f().str(O+i.N).end()),W4=null},final(O){B.write(i().c().end()),TW=O}}),m.resolve(W4)}function JM(){W4=new oz.Readable({read(){B.resume()}}),m.resolve(W4)}function GM(){W4=new oz.Duplex({autoDestroy:!0,read(){B.resume()},write(O,A,t){B.write(i().d().raw(O).end(),t)},destroy(O,A){A(O),B.write(i().f().str(O+i.N).end()),W4=null},final(O){B.write(i().c().end()),TW=O}}),m.resolve(W4)}function zM(O){W4&&(W4.push(O.subarray(5))||B.pause())}function HM(){W4&&W4.push(null),W4=null}function FM(O){Q?Q(dz(O)):console.log(dz(O))}function OM(){}function DM(){q6(s$.notSupported("FunctionCallResponse"))}function QM(){q6(s$.notSupported("NegotiateProtocolVersion"))}function ZM(O){console.error("Postgres.js : Unknown Message:",O[0])}function VM(O,A){console.error("Postgres.js : Unknown Auth:",A)}function KM(O,A,t="",V$=""){let d$,A4;return i().B().str(V$+i.N).str(t+i.N).i16(0).i16(O.length),O.forEach((B4,M1)=>{if(B4===null)return i.i32(4294967295);A4=A[M1],O[M1]=B4=A4 in $.serializers?$.serializers[A4](B4):""+B4,d$=i.i,i.inc(4).str(B4).i32(i.i-d$-4,d$)}),i.i16(0),i.end()}function u5(O,A,t,V$=""){return i().P().str(V$+i.N).str(O+i.N).i16(A.length),A.forEach((d$,A4)=>i.i32(t[A4]||0)),i.end()}function EM(O,A=""){return i().D().str(O).str(A+i.N).end()}function p5(O="",A=0){return Buffer.concat([i().E().str(O+i.N).i32(A).end(),rZ])}function AM(O=""){return Buffer.concat([i().C().str("P").str(O+i.N).end(),i().S().end()])}function MM(){return D$||i().inc(4).i16(3).z(2).str(Object.entries(Object.assign({user:w,database:H,client_encoding:"UTF8"},$.connection)).filter(([,O])=>O).map(([O,A])=>O+i.N+A).join(i.N)).z(2).end(0)}}function dz($){let T={},W=5;for(let U=5;U<$.length-1;U++)if($[U]===0)T[lk[$[W]]]=$.toString("utf8",W+1,U),W=U+1;return T}function iZ($){return TU.createHash("md5").update($).digest("hex")}function U8($,T){return TU.createHmac("sha256",$).update(T).digest()}function rk($){return TU.createHash("sha256").update($).digest()}function ik($,T){let W=Math.max($.length,T.length),U=Buffer.allocUnsafe(W);for(let X=0;X<W;X++)U[X]=$[X]^T[X];return U}function lz($,T){if(T=typeof T==="function"?T():T,!T)return{cancel:CT,start:CT};let W;return{cancel(){W&&(clearTimeout(W),W=null)},start(){W&&clearTimeout(W),W=setTimeout(U,T*1000,arguments)}};function U(X){$.apply(null,X),W=null}}var tZ=()=>{};function iz($,T){let W=new Map,U="postgresjs_"+Math.random().toString(36).slice(2),X={},Y,_,w=!1,G=z.sql=$({...T,transform:{column:{},value:{},row:{}},max:1,fetch_types:!1,idle_timeout:null,max_lifetime:null,connection:{...T.connection,replication:"database"},onclose:async function(){if(w)return;_=null,X.pid=X.secret=void 0,F(await Q(G,U,T.publications)),W.forEach((K)=>K.forEach(({onsubscribe:I})=>I()))},no_subscribe:!0}),J=G.end,H=G.close;return G.end=async()=>{return w=!0,_&&await new Promise((K)=>(_.once("close",K),_.end())),J()},G.close=async()=>{return _&&await new Promise((K)=>(_.once("close",K),_.end())),H()},z;async function z(K,I,k=tZ,N=tZ){if(K=ak(K),!Y)Y=Q(G,U,T.publications);let L={fn:I,onsubscribe:k},q=W.has(K)?W.get(K).add(L):W.set(K,new Set([L])).get(K),y=()=>{q.delete(L),q.size===0&&W.delete(K)};return Y.then((x)=>{return F(x),k(),_&&_.on("error",N),{unsubscribe:y,state:X,sql:G}})}function F(K){_=K.stream,X.pid=K.state.pid,X.secret=K.state.secret}async function Q(K,I,k){if(!k)throw new Error("Missing publication names");let N=await K.unsafe(`CREATE_REPLICATION_SLOT ${I} TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`),[L]=N,q=await K.unsafe(`START_REPLICATION SLOT ${I} LOGICAL ${L.consistent_point} (proto_version '1', publication_names '${k}')`).writable(),y={lsn:Buffer.concat(L.consistent_point.split("/").map((B)=>Buffer.from(("00000000"+B).slice(-8),"hex")))};return q.on("data",u),q.on("error",x),q.on("close",K.close),{stream:q,state:N.state};function x(B){console.error("Unexpected error during logical streaming - reconnecting",B)}function u(B){if(B[0]===119)tk(B.subarray(25),y,K.options.parsers,w$,T.transform);else if(B[0]===107&&B[17])y.lsn=B.subarray(1,9),m$()}function w$(B,D$){let $$=D$.relation.schema+"."+D$.relation.table;V("*",B,D$),V("*:"+$$,B,D$),D$.relation.keys.length&&V("*:"+$$+"="+D$.relation.keys.map((H$)=>B[H$.name]),B,D$),V(D$.command,B,D$),V(D$.command+":"+$$,B,D$),D$.relation.keys.length&&V(D$.command+":"+$$+"="+D$.relation.keys.map((H$)=>B[H$.name]),B,D$)}function m$(){let B=Buffer.alloc(34);B[0]=114,B.fill(y.lsn,1),B.writeBigInt64BE(BigInt(Date.now()-Date.UTC(2000,0,1))*BigInt(1000),25),q.write(B)}}function V(K,I,k){W.has(K)&&W.get(K).forEach(({fn:N})=>N(I,k,K))}}function nk($){return new Date(Date.UTC(2000,0,1)+Number($/BigInt(1000)))}function tk($,T,W,U,X){let Y=(_,[w,G])=>(_[w.charCodeAt(0)]=G,_);Object.entries({R:(_)=>{let w=1,G=T[_.readUInt32BE(w)]={schema:_.toString("utf8",w+=4,w=_.indexOf(0,w))||"pg_catalog",table:_.toString("utf8",w+1,w=_.indexOf(0,w+1)),columns:Array(_.readUInt16BE(w+=2)),keys:[]};w+=2;let J=0,H;while(w<_.length)H=G.columns[J++]={key:_[w++],name:X.column.from?X.column.from(_.toString("utf8",w,w=_.indexOf(0,w))):_.toString("utf8",w,w=_.indexOf(0,w)),type:_.readUInt32BE(w+=1),parser:W[_.readUInt32BE(w)],atttypmod:_.readUInt32BE(w+=4)},H.key&&G.keys.push(H),w+=4},Y:()=>{},O:()=>{},B:(_)=>{T.date=nk(_.readBigInt64BE(9)),T.lsn=_.subarray(1,9)},I:(_)=>{let w=1,G=T[_.readUInt32BE(w)],{row:J}=X8(_,G.columns,w+=7,X);U(J,{command:"insert",relation:G})},D:(_)=>{let w=1,G=T[_.readUInt32BE(w)];w+=4;let J=_[w]===75;U(J||_[w]===79?X8(_,G.columns,w+=3,X).row:null,{command:"delete",relation:G,key:J})},U:(_)=>{let w=1,G=T[_.readUInt32BE(w)];w+=4;let J=_[w]===75,H=J||_[w]===79?X8(_,G.columns,w+=3,X):null;H&&(w=H.i);let{row:z}=X8(_,G.columns,w+3,X);U(z,{command:"update",relation:G,key:J,old:H&&H.row})},T:()=>{},C:()=>{}}).reduce(Y,{})[$[0]]($)}function X8($,T,W,U){let X,Y,_,w=U.raw?new Array(T.length):{};for(let G=0;G<T.length;G++)X=$[W++],Y=T[G],_=X===110?null:X===117?void 0:Y.parser===void 0?$.toString("utf8",W+4,W+=4+$.readUInt32BE(W)):Y.parser.array===!0?Y.parser($.toString("utf8",W+5,W+=4+$.readUInt32BE(W))):Y.parser($.toString("utf8",W+4,W+=4+$.readUInt32BE(W))),U.raw?w[G]=U.raw===!0?_:U.value.from?U.value.from(_,Y):_:w[Y.name]=U.value.from?U.value.from(_,Y):_;return{i:W,row:U.row.from?U.row.from(w):w}}function ak($){let T=$.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i)||[];if(!T)throw new Error("Malformed subscribe pattern: "+$);let[,W,U,X]=T;return(W||"*")+(U?":"+(U.indexOf(".")===-1?"public."+U:U):"")+(X?"="+X:"")}import aZ from"stream";function nz($,T,W=393216){return new Promise(async(U,X)=>{await $.begin(async(Y)=>{let _;!T&&([{oid:T}]=await Y`select lo_creat(-1) as oid`);let[{fd:w}]=await Y`select lo_open(${T}, ${W}) as fd`,G={writable:H,readable:J,close:()=>Y`select lo_close(${w})`.then(_),tell:()=>Y`select lo_tell64(${w})`,read:(z)=>Y`select loread(${w}, ${z}) as data`,write:(z)=>Y`select lowrite(${w}, ${z})`,truncate:(z)=>Y`select lo_truncate64(${w}, ${z})`,seek:(z,F=0)=>Y`select lo_lseek64(${w}, ${z}, ${F})`,size:()=>Y`
93
+ `],[],EX,null,{simple:!0});D.resolve=([[q],[H$]])=>{e$.default_transaction_read_only=q.transaction_read_only,e$.in_hot_standby=H$.pg_is_in_recovery?"on":"off"},D.execute()}function gv(D){n&&(n.cursorFn||n.describeFirst)&&d4(ST);let q=J4.postgres(OQ(D));n&&n.retried?p1(n.retried):n&&n.prepared&&XB.has(q.routine)?mv(n,q):p1(q)}function mv(D,q){delete h4[D.signature],D.retried=q,EX(D)}function cv(D){if(!K)return;let q=9;while(D[q++]!==0);K(D.toString("utf8",9,q-1),D.toString("utf8",q,D.length-1))}async function uv(){try{let D=await Promise.resolve(n.cursorFn(t));D4=0,D===o2?d4(Xq(n.portal)):(t=new CW,d4(HV("",n.cursorRows)))}catch(D){d4(ST),n.reject(D)}}function pv(){t.count&&n.cursorFn(t),n.resolve(t)}function dv(){k4=new FQ.Writable({autoDestroy:!0,write(D,q,H$){j.write(Y$().d().raw(D).end(),H$)},destroy(D,q){q(D),j.write(Y$().f().str(D+Y$.N).end()),k4=null},final(D){j.write(Y$().c().end()),AX=D}}),n.resolve(k4)}function ov(){k4=new FQ.Readable({read(){j.resume()}}),n.resolve(k4)}function lv(){k4=new FQ.Duplex({autoDestroy:!0,read(){j.resume()},write(D,q,H$){j.write(Y$().d().raw(D).end(),H$)},destroy(D,q){q(D),j.write(Y$().f().str(D+Y$.N).end()),k4=null},final(D){j.write(Y$().c().end()),AX=D}}),n.resolve(k4)}function rv(D){k4&&(k4.push(D.subarray(5))||j.pause())}function nv(){k4&&k4.push(null),k4=null}function iv(D){Z?Z(OQ(D)):console.log(OQ(D))}function tv(){}function av(){p1(J4.notSupported("FunctionCallResponse"))}function sv(){p1(J4.notSupported("NegotiateProtocolVersion"))}function ev(D){console.error("Postgres.js : Unknown Message:",D[0])}function $q(D,q){console.error("Postgres.js : Unknown Auth:",q)}function Tq(D,q,H$="",f$=""){let V4,s4;return Y$().B().str(f$+Y$.N).str(H$+Y$.N).i16(0).i16(D.length),D.forEach((Y6,s0)=>{if(Y6===null)return Y$.i32(4294967295);s4=q[s0],D[s0]=Y6=s4 in $.serializers?$.serializers[s4](Y6):""+Y6,V4=Y$.i,Y$.inc(4).str(Y6).i32(Y$.i-V4-4,V4)}),Y$.i16(0),Y$.end()}function zV(D,q,H$,f$=""){return Y$().P().str(f$+Y$.N).str(D+Y$.N).i16(q.length),q.forEach((V4,s4)=>Y$.i32(H$[s4]||0)),Y$.end()}function Wq(D,q=""){return Y$().D().str(D).str(q+Y$.N).end()}function HV(D="",q=0){return Buffer.concat([Y$().E().str(D+Y$.N).i32(q).end(),CJ])}function Xq(D=""){return Buffer.concat([Y$().C().str("P").str(D+Y$.N).end(),Y$().S().end()])}function wq(){return U$||Y$().inc(4).i16(3).z(2).str(Object.entries(Object.assign({user:G,database:F,client_encoding:"UTF8"},$.connection)).filter(([,D])=>D).map(([D,q])=>D+Y$.N+q).join(Y$.N)).z(2).end(0)}}function OQ($){let T={},W=5;for(let w=5;w<$.length-1;w++)if($[w]===0)T[wB[$[W]]]=$.toString("utf8",W+1,w),W=w+1;return T}function SJ($){return ZU.createHash("md5").update($).digest("hex")}function c9($,T){return ZU.createHmac("sha256",$).update(T).digest()}function UB($){return ZU.createHash("sha256").update($).digest()}function YB($,T){let W=Math.max($.length,T.length),w=Buffer.allocUnsafe(W);for(let X=0;X<W;X++)w[X]=$[X]^T[X];return w}function QQ($,T){if(T=typeof T==="function"?T():T,!T)return{cancel:r2,start:r2};let W;return{cancel(){W&&(clearTimeout(W),W=null)},start(){W&&clearTimeout(W),W=setTimeout(w,T*1000,arguments)}};function w(X){$.apply(null,X),W=null}}var IJ=()=>{};function VQ($,T){let W=new Map,w="postgresjs_"+Math.random().toString(36).slice(2),X={},U,Y,G=!1,H=O.sql=$({...T,transform:{column:{},value:{},row:{}},max:1,fetch_types:!1,idle_timeout:null,max_lifetime:null,connection:{...T.connection,replication:"database"},onclose:async function(){if(G)return;Y=null,X.pid=X.secret=void 0,Q(await Z(H,w,T.publications)),W.forEach((E)=>E.forEach(({onsubscribe:M})=>M()))},no_subscribe:!0}),z=H.end,F=H.close;return H.end=async()=>{return G=!0,Y&&await new Promise((E)=>(Y.once("close",E),Y.end())),z()},H.close=async()=>{return Y&&await new Promise((E)=>(Y.once("close",E),Y.end())),F()},O;async function O(E,M,L=IJ,R=IJ){if(E=HB(E),!U)U=Z(H,w,T.publications);let _={fn:M,onsubscribe:L},S=W.has(E)?W.get(E).add(_):W.set(E,new Set([_])).get(E),x=()=>{S.delete(_),S.size===0&&W.delete(E)};return U.then((b)=>{return Q(b),L(),Y&&Y.on("error",R),{unsubscribe:x,state:X,sql:H}})}function Q(E){Y=E.stream,X.pid=E.state.pid,X.secret=E.state.secret}async function Z(E,M,L){if(!L)throw new Error("Missing publication names");let R=await E.unsafe(`CREATE_REPLICATION_SLOT ${M} TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`),[_]=R,S=await E.unsafe(`START_REPLICATION SLOT ${M} LOGICAL ${_.consistent_point} (proto_version '1', publication_names '${L}')`).writable(),x={lsn:Buffer.concat(_.consistent_point.split("/").map((j)=>Buffer.from(("00000000"+j).slice(-8),"hex")))};return S.on("data",g),S.on("error",b),S.on("close",E.close),{stream:S,state:R.state};function b(j){console.error("Unexpected error during logical streaming - reconnecting",j)}function g(j){if(j[0]===119)zB(j.subarray(25),x,E.options.parsers,T$,T.transform);else if(j[0]===107&&j[17])x.lsn=j.subarray(1,9),N$()}function T$(j,U$){let t=U$.relation.schema+"."+U$.relation.table;K("*",j,U$),K("*:"+t,j,U$),U$.relation.keys.length&&K("*:"+t+"="+U$.relation.keys.map((z$)=>j[z$.name]),j,U$),K(U$.command,j,U$),K(U$.command+":"+t,j,U$),U$.relation.keys.length&&K(U$.command+":"+t+"="+U$.relation.keys.map((z$)=>j[z$.name]),j,U$)}function N$(){let j=Buffer.alloc(34);j[0]=114,j.fill(x.lsn,1),j.writeBigInt64BE(BigInt(Date.now()-Date.UTC(2000,0,1))*BigInt(1000),25),S.write(j)}}function K(E,M,L){W.has(E)&&W.get(E).forEach(({fn:R})=>R(M,L,E))}}function GB($){return new Date(Date.UTC(2000,0,1)+Number($/BigInt(1000)))}function zB($,T,W,w,X){let U=(Y,[G,H])=>(Y[G.charCodeAt(0)]=H,Y);Object.entries({R:(Y)=>{let G=1,H=T[Y.readUInt32BE(G)]={schema:Y.toString("utf8",G+=4,G=Y.indexOf(0,G))||"pg_catalog",table:Y.toString("utf8",G+1,G=Y.indexOf(0,G+1)),columns:Array(Y.readUInt16BE(G+=2)),keys:[]};G+=2;let z=0,F;while(G<Y.length)F=H.columns[z++]={key:Y[G++],name:X.column.from?X.column.from(Y.toString("utf8",G,G=Y.indexOf(0,G))):Y.toString("utf8",G,G=Y.indexOf(0,G)),type:Y.readUInt32BE(G+=1),parser:W[Y.readUInt32BE(G)],atttypmod:Y.readUInt32BE(G+=4)},F.key&&H.keys.push(F),G+=4},Y:()=>{},O:()=>{},B:(Y)=>{T.date=GB(Y.readBigInt64BE(9)),T.lsn=Y.subarray(1,9)},I:(Y)=>{let G=1,H=T[Y.readUInt32BE(G)],{row:z}=u9(Y,H.columns,G+=7,X);w(z,{command:"insert",relation:H})},D:(Y)=>{let G=1,H=T[Y.readUInt32BE(G)];G+=4;let z=Y[G]===75;w(z||Y[G]===79?u9(Y,H.columns,G+=3,X).row:null,{command:"delete",relation:H,key:z})},U:(Y)=>{let G=1,H=T[Y.readUInt32BE(G)];G+=4;let z=Y[G]===75,F=z||Y[G]===79?u9(Y,H.columns,G+=3,X):null;F&&(G=F.i);let{row:O}=u9(Y,H.columns,G+3,X);w(O,{command:"update",relation:H,key:z,old:F&&F.row})},T:()=>{},C:()=>{}}).reduce(U,{})[$[0]]($)}function u9($,T,W,w){let X,U,Y,G=w.raw?new Array(T.length):{};for(let H=0;H<T.length;H++)X=$[W++],U=T[H],Y=X===110?null:X===117?void 0:U.parser===void 0?$.toString("utf8",W+4,W+=4+$.readUInt32BE(W)):U.parser.array===!0?U.parser($.toString("utf8",W+5,W+=4+$.readUInt32BE(W))):U.parser($.toString("utf8",W+4,W+=4+$.readUInt32BE(W))),w.raw?G[H]=w.raw===!0?Y:w.value.from?w.value.from(Y,U):Y:G[U.name]=w.value.from?w.value.from(Y,U):Y;return{i:W,row:w.row.from?w.row.from(G):G}}function HB($){let T=$.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i)||[];if(!T)throw new Error("Malformed subscribe pattern: "+$);let[,W,w,X]=T;return(W||"*")+(w?":"+(w.indexOf(".")===-1?"public."+w:w):"")+(X?"="+X:"")}import BJ from"stream";function KQ($,T,W=393216){return new Promise(async(w,X)=>{await $.begin(async(U)=>{let Y;!T&&([{oid:T}]=await U`select lo_creat(-1) as oid`);let[{fd:G}]=await U`select lo_open(${T}, ${W}) as fd`,H={writable:F,readable:z,close:()=>U`select lo_close(${G})`.then(Y),tell:()=>U`select lo_tell64(${G})`,read:(O)=>U`select loread(${G}, ${O}) as data`,write:(O)=>U`select lowrite(${G}, ${O})`,truncate:(O)=>U`select lo_truncate64(${G}, ${O})`,seek:(O,Q=0)=>U`select lo_lseek64(${G}, ${O}, ${Q})`,size:()=>U`
92
94
  select
93
- lo_lseek64(${w}, location, 0) as position,
95
+ lo_lseek64(${G}, location, 0) as position,
94
96
  seek.size
95
97
  from (
96
98
  select
@@ -98,63 +100,63 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
98
100
  tell.location
99
101
  from (select lo_tell64($1) as location) tell
100
102
  ) seek
101
- `};return U(G),new Promise(async(z)=>_=z);async function J({highWaterMark:z=16384,start:F=0,end:Q=1/0}={}){let V=Q-F;return F&&await G.seek(F),new aZ.Readable({highWaterMark:z,async read(K){let I=K>V?K-V:K;V-=K;let[{data:k}]=await G.read(I);if(this.push(k),k.length<K)this.push(null)}})}async function H({highWaterMark:z=16384,start:F=0}={}){return F&&await G.seek(F),new aZ.Writable({highWaterMark:z,write(Q,V,K){G.write(Q).then(()=>K(),K)}})}}).catch(X)})}Object.assign(Y8,{PostgresError:PT,toPascal:P0,pascal:uz,toCamel:q0,camel:cz,toKebab:C0,kebab:pz,fromPascal:s2,fromCamel:a2,fromKebab:e2,BigInt:{to:20,from:[20],parse:($)=>BigInt($),serialize:($)=>$.toString()}});var jT=Y8;function Y8($,T){let W=$v($,T),U=W.no_subscribe||iz(Y8,{...W}),X=!1,Y=W6(),_=W6(),w=W6(),G=W6(),J=W6(),H=W6(),z=W6(),F=W6(),Q={connecting:_,reserved:w,closed:G,ended:J,open:H,busy:z,full:F},V=[...Array(W.max)].map(()=>rz(W,Q,{onopen:Q6,onend:V4,onclose:u0})),K=I(w$);return Object.assign(K,{get parameters(){return W.parameters},largeObject:nz.bind(null,K),subscribe:U,CLOSE:qT,END:qT,PostgresError:PT,options:W,reserve:L,listen:k,begin:q,close:$$,end:D$}),K;function I(C){return C.debug=W.debug,Object.entries(W.types).reduce((J$,[M$,n$])=>{return J$[M$]=(c$)=>new h6(c$,n$.to),J$},e),Object.assign(A$,{types:e,typed:e,unsafe:g$,notify:N,array:u,json:x,file:T4}),A$;function e(J$,M$){return new h6(J$,M$)}function A$(J$,...M$){return J$&&Array.isArray(J$.raw)?new z6(J$,M$,C,B):typeof J$==="string"&&!M$.length?new $U(W.transform.column.to?W.transform.column.to(J$):J$):new eY(J$,M$)}function g$(J$,M$=[],n$={}){return arguments.length===2&&!Array.isArray(M$)&&(n$=M$,M$=[]),new z6([J$],M$,C,B,{prepare:!1,...n$,simple:"simple"in n$?n$.simple:M$.length===0})}function T4(J$,M$=[],n$={}){return arguments.length===2&&!Array.isArray(M$)&&(n$=M$,M$=[]),new z6([],M$,(x$)=>{ek.readFile(J$,"utf8",(K4,k$)=>{if(K4)return x$.reject(K4);x$.strings=[k$],C(x$)})},B,{...n$,simple:"simple"in n$?n$.simple:M$.length===0})}}async function k(C,e,A$){let g$={fn:e,onlisten:A$},T4=k.sql||(k.sql=Y8({...W,max:1,idle_timeout:null,max_lifetime:null,fetch_types:!1,onclose(){Object.entries(k.channels).forEach(([x$,{listeners:K4}])=>{delete k.channels[x$],Promise.all(K4.map((k$)=>k(x$,k$.fn,k$.onlisten).catch(()=>{})))})},onnotify(x$,K4){x$ in k.channels&&k.channels[x$].listeners.forEach((k$)=>k$.fn(K4))}})),J$=k.channels||(k.channels={});if(C in J$){J$[C].listeners.push(g$);let x$=await J$[C].result;return g$.onlisten&&g$.onlisten(),{state:x$.state,unlisten:c$}}J$[C]={result:T4`listen ${T4.unsafe('"'+C.replace(/"/g,'""')+'"')}`,listeners:[g$]};let n$=await J$[C].result;return g$.onlisten&&g$.onlisten(),{state:n$.state,unlisten:c$};async function c$(){if(C in J$===!1)return;if(J$[C].listeners=J$[C].listeners.filter((x$)=>x$!==g$),J$[C].listeners.length)return;return delete J$[C],T4`unlisten ${T4.unsafe('"'+C.replace(/"/g,'""')+'"')}`}}async function N(C,e){return await K`select pg_notify(${C}, ${""+e})`}async function L(){let C=W6(),e=H.length?H.shift():await new Promise((T4,J$)=>{let M$={reserve:T4,reject:J$};Y.push(M$),G.length&&$4(G.shift(),M$)});y(e,w),e.reserved=()=>C.length?e.execute(C.shift()):y(e,w),e.reserved.release=!0;let A$=I(g$);return A$.release=()=>{e.reserved=null,Q6(e)},A$;function g$(T4){e.queue===F?C.push(T4):e.execute(T4)||y(e,F)}}async function q(C,e){!e&&(e=C,C="");let A$=W6(),g$=0,T4,J$=null;try{return await K.unsafe("begin "+C.replace(/[^a-z ]/ig,""),[],{onexecute:n$}).execute(),await Promise.race([M$(T4,e),new Promise((c$,x$)=>T4.onclose=x$)])}catch(c$){throw c$}async function M$(c$,x$,K4){let k$=I(W4);k$.savepoint=A1,k$.prepare=(b$)=>J$=b$.replace(/[^a-z0-9$-_. ]/gi);let Z6,D4;K4&&await k$`savepoint ${k$(K4)}`;try{if(D4=await new Promise((b$,V6)=>{let v6=x$(k$);Promise.resolve(Array.isArray(v6)?Promise.all(v6):v6).then(b$,V6)}),Z6)throw Z6}catch(b$){throw await(K4?k$`rollback to ${k$(K4)}`:k$`rollback`),b$ instanceof PT&&b$.code==="25P02"&&Z6||b$}if(!K4)J$?await k$`prepare transaction '${k$.unsafe(J$)}'`:await k$`commit`;return D4;function A1(b$,V6){if(b$&&Array.isArray(b$.raw))return A1((v6)=>v6.apply(v6,arguments));return arguments.length===1&&(V6=b$,b$=null),M$(c$,V6,"s"+g$+++(b$?"_"+b$:""))}function W4(b$){b$.catch((V6)=>Z6||(Z6=V6)),c$.queue===F?A$.push(b$):c$.execute(b$)||y(c$,F)}}function n$(c$){T4=c$,y(c$,w),c$.reserved=()=>A$.length?c$.execute(A$.shift()):y(c$,w)}}function y(C,e){return C.queue.remove(C),e.push(C),C.queue=e,e===H?C.idleTimer.start():C.idleTimer.cancel(),C}function x(C){return new h6(C,3802)}function u(C,e){if(!Array.isArray(C))return u(Array.from(arguments));return new h6(C,e||(C.length?aY(C)||25:0),W.shared.typeArrayMap)}function w$(C){if(X)return C.reject(s$.connection("CONNECTION_ENDED",W,W));if(H.length)return m$(H.shift(),C);if(G.length)return $4(G.shift(),C);z.length?m$(z.shift(),C):Y.push(C)}function m$(C,e){return C.execute(e)?y(C,z):y(C,F)}function B(C){return new Promise((e,A$)=>{C.state?C.active?rz(W).cancel(C.state,e,A$):C.cancelled={resolve:e,reject:A$}:(Y.remove(C),C.cancelled=!0,C.reject(s$.generic("57014","canceling statement due to user request")),e())})}async function D$({timeout:C=null}={}){if(X)return X;await 1;let e;return X=Promise.race([new Promise((A$)=>C!==null&&(e=setTimeout(H$,C*1000,A$))),Promise.all(V.map((A$)=>A$.end()).concat(k.sql?k.sql.end({timeout:0}):[],U.sql?U.sql.end({timeout:0}):[]))]).then(()=>clearTimeout(e))}async function $$(){await Promise.all(V.map((C)=>C.end()))}async function H$(C){await Promise.all(V.map((e)=>e.terminate()));while(Y.length)Y.shift().reject(s$.connection("CONNECTION_DESTROYED",W));C()}function $4(C,e){return y(C,_),C.connect(e),C}function V4(C){y(C,J)}function Q6(C){if(Y.length===0)return y(C,H);let e=Math.ceil(Y.length/(_.length+1)),A$=!0;while(A$&&Y.length&&e-- >0){let g$=Y.shift();if(g$.reserve)return g$.reserve(C);A$=C.execute(g$)}A$?y(C,z):y(C,F)}function u0(C,e){y(C,G),C.reserved=null,C.onclose&&(C.onclose(e),C.onclose=null),W.onclose&&W.onclose(C.id),Y.length&&$4(C,Y.shift())}}function $v($,T){if($&&$.shared)return $;let W=process.env,U=(!$||typeof $==="string"?T:$)||{},{url:X,multihost:Y}=Yv($),_=[...X.searchParams].reduce((F,[Q,V])=>(F[Q]=V,F),{}),w=U.hostname||U.host||Y||X.hostname||W.PGHOST||"localhost",G=U.port||X.port||W.PGPORT||5432,J=U.user||U.username||X.username||W.PGUSERNAME||W.PGUSER||_v();U.no_prepare&&(U.prepare=!1),_.sslmode&&(_.ssl=_.sslmode,delete _.sslmode),"timeout"in U&&(console.log("The timeout option is deprecated, use idle_timeout instead"),U.idle_timeout=U.timeout),_.sslrootcert==="system"&&(_.ssl="verify-full");let H=["idle_timeout","connect_timeout","max_lifetime","max_pipeline","backoff","keep_alive"],z={max:10,ssl:!1,idle_timeout:null,connect_timeout:30,max_lifetime:Uv,max_pipeline:100,backoff:Wv,keep_alive:60,prepare:!0,debug:!1,fetch_types:!0,publications:"alltables",target_session_attrs:null};return{host:Array.isArray(w)?w:w.split(",").map((F)=>F.split(":")[0]),port:Array.isArray(G)?G:w.split(",").map((F)=>parseInt(F.split(":")[1]||G)),path:U.path||w.indexOf("/")>-1&&w+"/.s.PGSQL."+G,database:U.database||U.db||(X.pathname||"").slice(1)||W.PGDATABASE||J,user:J,pass:U.pass||U.password||X.password||W.PGPASSWORD||"",...Object.entries(z).reduce((F,[Q,V])=>{let K=Q in U?U[Q]:(Q in _)?_[Q]==="disable"||_[Q]==="false"?!1:_[Q]:W["PG"+Q.toUpperCase()]||V;return F[Q]=typeof K==="string"&&H.includes(Q)?+K:K,F},{}),connection:{application_name:W.PGAPPNAME||"postgres.js",...U.connection,...Object.entries(_).reduce((F,[Q,V])=>((Q in z)||(F[Q]=V),F),{})},types:U.types||{},target_session_attrs:Tv(U,X,W),onnotice:U.onnotice,onnotify:U.onnotify,onclose:U.onclose,onparameter:U.onparameter,socket:U.socket,transform:Xv(U.transform||{undefined:void 0}),parameters:{},shared:{retries:0,typeArrayMap:{}},...mZ(U.types)}}function Tv($,T,W){let U=$.target_session_attrs||T.searchParams.get("target_session_attrs")||W.PGTARGETSESSIONATTRS;if(!U||["read-write","read-only","primary","standby","prefer-standby"].includes(U))return U;throw new Error("target_session_attrs "+U+" is not supported")}function Wv($){return(0.5+Math.random()/2)*Math.min(3**$/100,20)}function Uv(){return 60*(30+Math.random()*30)}function Xv($){return{undefined:$.undefined,column:{from:typeof $.column==="function"?$.column:$.column&&$.column.from,to:$.column&&$.column.to},value:{from:typeof $.value==="function"?$.value:$.value&&$.value.from,to:$.value&&$.value.to},row:{from:typeof $.row==="function"?$.row:$.row&&$.row.from,to:$.row&&$.row.to}}}function Yv($){if(!$||typeof $!=="string")return{url:{searchParams:new Map}};let T=$;T=T.slice(T.indexOf("://")+3).split(/[?/]/)[0],T=decodeURIComponent(T.slice(T.indexOf("@")+1));let W=new URL($.replace(T,T.split(",")[0]));return{url:{username:decodeURIComponent(W.username),password:decodeURIComponent(W.password),host:W.host,hostname:W.hostname,port:W.port,pathname:W.pathname,searchParams:W.searchParams},multihost:T.indexOf(",")>-1&&T}}function _v(){try{return sk.userInfo().username}catch($){return process.env.USERNAME||process.env.USER||process.env.LOGNAME}}class r${static[D]="SelectionProxyHandler";config;constructor($){this.config={...$}}get($,T){if(T==="_")return{...$._,selectedFields:new Proxy($._.selectedFields,this)};if(T===P$)return{...$[P$],selectedFields:new Proxy($[P$].selectedFields,this)};if(typeof T==="symbol")return $[T];let U=(M($,i$)?$._.selectedFields:M($,g4)?$[P$].selectedFields:$)[T];if(M(U,p.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!U.isSelectionField)return U.sql;let X=U.clone();return X.isSelectionField=!0,X}if(M(U,p)){if(this.config.sqlBehavior==="sql")return U;throw new Error(`You tried to reference "${T}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(M(U,B$)){if(this.config.alias)return new Proxy(U,new vT(new Proxy(U.table,new p2(this.config.alias,this.config.replaceOriginalName??!1))));return U}if(typeof U!=="object"||U===null)return U;return new Proxy(U,new r$(this.config))}}class sZ{constructor($,T){this.unique=$,this.name=T}static[D]="PgIndexBuilderOn";on(...$){return new _8($.map((T)=>{if(M(T,p))return T;T=T;let W=new g2(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=JSON.parse(JSON.stringify(T.defaultConfig)),W}),this.unique,!1,this.name)}onOnly(...$){return new _8($.map((T)=>{if(M(T,p))return T;T=T;let W=new g2(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=T.defaultConfig,W}),this.unique,!0,this.name)}using($,...T){return new _8(T.map((W)=>{if(M(W,p))return W;W=W;let U=new g2(W.name,!!W.keyAsName,W.columnType,W.indexConfig);return W.indexConfig=JSON.parse(JSON.stringify(W.defaultConfig)),U}),this.unique,!0,this.name,$)}}class _8{static[D]="PgIndexBuilder";config;constructor($,T,W,U,X="btree"){this.config={name:U,columns:$,unique:T,only:W,method:X}}concurrently(){return this.config.concurrently=!0,this}with($){return this.config.with=$,this}where($){return this.config.where=$,this}build($){return new eZ(this.config,$)}}class eZ{static[D]="PgIndex";config;constructor($,T){this.config={...$,table:T}}}function tz($){return new sZ(!0,$)}function wv($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((W)=>W.toLowerCase()).join("_")}function Jv($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((W,U,X)=>{let Y=X===0?U.toLowerCase():`${U[0].toUpperCase()}${U.slice(1)}`;return W+Y},"")}function Gv($){return $}class az{static[D]="CasingCache";cache={};cachedTables={};convert;constructor($){this.convert=$==="snake_case"?wv:$==="camelCase"?Jv:Gv}getColumnCasing($){if(!$.keyAsName)return $.name;let T=$.table[f.Symbol.Schema]??"public",W=$.table[f.Symbol.OriginalName],U=`${T}.${W}.${$.name}`;if(!this.cache[U])this.cacheTable($.table);return this.cache[U]}cacheTable($){let T=$[f.Symbol.Schema]??"public",W=$[f.Symbol.OriginalName],U=`${T}.${W}`;if(!this.cachedTables[U]){for(let X of Object.values($[f.Symbol.Columns])){let Y=`${U}.${X.name}`;this.cache[Y]=this.convert(X.name)}this.cachedTables[U]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class WU extends g4{static[D]="PgViewBase"}class x0{static[D]="PgDialect";casing;constructor($){this.casing=new az($?.casing)}async migrate($,T,W){let U=typeof W==="string"?"__drizzle_migrations":W.migrationsTable??"__drizzle_migrations",X=typeof W==="string"?"drizzle":W.migrationsSchema??"drizzle",Y=Z`
102
- CREATE TABLE IF NOT EXISTS ${Z.identifier(X)}.${Z.identifier(U)} (
103
+ `};return w(H),new Promise(async(O)=>Y=O);async function z({highWaterMark:O=16384,start:Q=0,end:Z=1/0}={}){let K=Z-Q;return Q&&await H.seek(Q),new BJ.Readable({highWaterMark:O,async read(E){let M=E>K?E-K:E;K-=E;let[{data:L}]=await H.read(M);if(this.push(L),L.length<E)this.push(null)}})}async function F({highWaterMark:O=16384,start:Q=0}={}){return Q&&await H.seek(Q),new BJ.Writable({highWaterMark:O,write(Z,K,E){H.write(Z).then(()=>E(),E)}})}}).catch(X)})}Object.assign(p9,{PostgresError:l2,toPascal:qW,pascal:zQ,toCamel:vW,camel:GQ,toKebab:PW,kebab:HQ,fromPascal:FU,fromCamel:HU,fromKebab:OU,BigInt:{to:20,from:[20],parse:($)=>BigInt($),serialize:($)=>$.toString()}});var n2=p9;function p9($,T){let W=QB($,T),w=W.no_subscribe||VQ(p9,{...W}),X=!1,U=O1(),Y=O1(),G=O1(),H=O1(),z=O1(),F=O1(),O=O1(),Q=O1(),Z={connecting:Y,reserved:G,closed:H,ended:z,open:F,busy:O,full:Q},K=[...Array(W.max)].map(()=>ZQ(W,Z,{onopen:h4,onend:e$,onclose:n6})),E=M(T$);return Object.assign(E,{get parameters(){return W.parameters},largeObject:KQ.bind(null,E),subscribe:w,CLOSE:o2,END:o2,PostgresError:l2,options:W,reserve:_,listen:L,begin:S,close:t,end:U$}),E;function M(c){return c.debug=W.debug,Object.entries(W.types).reduce((L$,[m$,D4])=>{return L$[m$]=(G4)=>new G0(G4,D4.to),L$},F$),Object.assign(g$,{types:F$,typed:F$,unsafe:Y4,notify:R,array:g,json:b,file:_4}),g$;function F$(L$,m$){return new G0(L$,m$)}function g$(L$,...m$){return L$&&Array.isArray(L$.raw)?new J1(L$,m$,c,j):typeof L$==="string"&&!m$.length?new QU(W.transform.column.to?W.transform.column.to(L$):L$):new y9(L$,m$)}function Y4(L$,m$=[],D4={}){return arguments.length===2&&!Array.isArray(m$)&&(D4=m$,m$=[]),new J1([L$],m$,c,j,{prepare:!1,...D4,simple:"simple"in D4?D4.simple:m$.length===0})}function _4(L$,m$=[],D4={}){return arguments.length===2&&!Array.isArray(m$)&&(D4=m$,m$=[]),new J1([],m$,($4)=>{OB.readFile(L$,"utf8",(t4,l$)=>{if(t4)return $4.reject(t4);$4.strings=[l$],c($4)})},j,{...D4,simple:"simple"in D4?D4.simple:m$.length===0})}}async function L(c,F$,g$){let Y4={fn:F$,onlisten:g$},_4=L.sql||(L.sql=p9({...W,max:1,idle_timeout:null,max_lifetime:null,fetch_types:!1,onclose(){Object.entries(L.channels).forEach(([$4,{listeners:t4}])=>{delete L.channels[$4],Promise.all(t4.map((l$)=>L($4,l$.fn,l$.onlisten).catch(()=>{})))})},onnotify($4,t4){$4 in L.channels&&L.channels[$4].listeners.forEach((l$)=>l$.fn(t4))}})),L$=L.channels||(L.channels={});if(c in L$){L$[c].listeners.push(Y4);let $4=await L$[c].result;return Y4.onlisten&&Y4.onlisten(),{state:$4.state,unlisten:G4}}L$[c]={result:_4`listen ${_4.unsafe('"'+c.replace(/"/g,'""')+'"')}`,listeners:[Y4]};let D4=await L$[c].result;return Y4.onlisten&&Y4.onlisten(),{state:D4.state,unlisten:G4};async function G4(){if(c in L$===!1)return;if(L$[c].listeners=L$[c].listeners.filter(($4)=>$4!==Y4),L$[c].listeners.length)return;return delete L$[c],_4`unlisten ${_4.unsafe('"'+c.replace(/"/g,'""')+'"')}`}}async function R(c,F$){return await E`select pg_notify(${c}, ${""+F$})`}async function _(){let c=O1(),F$=F.length?F.shift():await new Promise((_4,L$)=>{let m$={reserve:_4,reject:L$};U.push(m$),H.length&&B$(H.shift(),m$)});x(F$,G),F$.reserved=()=>c.length?F$.execute(c.shift()):x(F$,G),F$.reserved.release=!0;let g$=M(Y4);return g$.release=()=>{F$.reserved=null,h4(F$)},g$;function Y4(_4){F$.queue===Q?c.push(_4):F$.execute(_4)||x(F$,Q)}}async function S(c,F$){!F$&&(F$=c,c="");let g$=O1(),Y4=0,_4,L$=null;try{return await E.unsafe("begin "+c.replace(/[^a-z ]/ig,""),[],{onexecute:D4}).execute(),await Promise.race([m$(_4,F$),new Promise((G4,$4)=>_4.onclose=$4)])}catch(G4){throw G4}async function m$(G4,$4,t4){let l$=M(k4);l$.savepoint=a0,l$.prepare=(T4)=>L$=T4.replace(/[^a-z0-9$-_. ]/gi);let q1,p4;t4&&await l$`savepoint ${l$(t4)}`;try{if(p4=await new Promise((T4,P1)=>{let u1=$4(l$);Promise.resolve(Array.isArray(u1)?Promise.all(u1):u1).then(T4,P1)}),q1)throw q1}catch(T4){throw await(t4?l$`rollback to ${l$(t4)}`:l$`rollback`),T4 instanceof l2&&T4.code==="25P02"&&q1||T4}if(!t4)L$?await l$`prepare transaction '${l$.unsafe(L$)}'`:await l$`commit`;return p4;function a0(T4,P1){if(T4&&Array.isArray(T4.raw))return a0((u1)=>u1.apply(u1,arguments));return arguments.length===1&&(P1=T4,T4=null),m$(G4,P1,"s"+Y4+++(T4?"_"+T4:""))}function k4(T4){T4.catch((P1)=>q1||(q1=P1)),G4.queue===Q?g$.push(T4):G4.execute(T4)||x(G4,Q)}}function D4(G4){_4=G4,x(G4,G),G4.reserved=()=>g$.length?G4.execute(g$.shift()):x(G4,G)}}function x(c,F$){return c.queue.remove(c),F$.push(c),c.queue=F$,F$===F?c.idleTimer.start():c.idleTimer.cancel(),c}function b(c){return new G0(c,3802)}function g(c,F$){if(!Array.isArray(c))return g(Array.from(arguments));return new G0(c,F$||(c.length?f9(c)||25:0),W.shared.typeArrayMap)}function T$(c){if(X)return c.reject(J4.connection("CONNECTION_ENDED",W,W));if(F.length)return N$(F.shift(),c);if(H.length)return B$(H.shift(),c);O.length?N$(O.shift(),c):U.push(c)}function N$(c,F$){return c.execute(F$)?x(c,O):x(c,Q)}function j(c){return new Promise((F$,g$)=>{c.state?c.active?ZQ(W).cancel(c.state,F$,g$):c.cancelled={resolve:F$,reject:g$}:(U.remove(c),c.cancelled=!0,c.reject(J4.generic("57014","canceling statement due to user request")),F$())})}async function U$({timeout:c=null}={}){if(X)return X;await 1;let F$;return X=Promise.race([new Promise((g$)=>c!==null&&(F$=setTimeout(z$,c*1000,g$))),Promise.all(K.map((g$)=>g$.end()).concat(L.sql?L.sql.end({timeout:0}):[],w.sql?w.sql.end({timeout:0}):[]))]).then(()=>clearTimeout(F$))}async function t(){await Promise.all(K.map((c)=>c.end()))}async function z$(c){await Promise.all(K.map((F$)=>F$.terminate()));while(U.length)U.shift().reject(J4.connection("CONNECTION_DESTROYED",W));c()}function B$(c,F$){return x(c,Y),c.connect(F$),c}function e$(c){x(c,z)}function h4(c){if(U.length===0)return x(c,F);let F$=Math.ceil(U.length/(Y.length+1)),g$=!0;while(g$&&U.length&&F$-- >0){let Y4=U.shift();if(Y4.reserve)return Y4.reserve(c);g$=c.execute(Y4)}g$?x(c,O):x(c,Q)}function n6(c,F$){x(c,H),c.reserved=null,c.onclose&&(c.onclose(F$),c.onclose=null),W.onclose&&W.onclose(c.id),U.length&&B$(c,U.shift())}}function QB($,T){if($&&$.shared)return $;let W=process.env,w=(!$||typeof $==="string"?T:$)||{},{url:X,multihost:U}=EB($),Y=[...X.searchParams].reduce((Q,[Z,K])=>(Q[Z]=K,Q),{}),G=w.hostname||w.host||U||X.hostname||W.PGHOST||"localhost",H=w.port||X.port||W.PGPORT||5432,z=w.user||w.username||X.username||W.PGUSERNAME||W.PGUSER||MB();w.no_prepare&&(w.prepare=!1),Y.sslmode&&(Y.ssl=Y.sslmode,delete Y.sslmode),"timeout"in w&&(console.log("The timeout option is deprecated, use idle_timeout instead"),w.idle_timeout=w.timeout),Y.sslrootcert==="system"&&(Y.ssl="verify-full");let F=["idle_timeout","connect_timeout","max_lifetime","max_pipeline","backoff","keep_alive"],O={max:10,ssl:!1,idle_timeout:null,connect_timeout:30,max_lifetime:KB,max_pipeline:100,backoff:VB,keep_alive:60,prepare:!0,debug:!1,fetch_types:!0,publications:"alltables",target_session_attrs:null};return{host:Array.isArray(G)?G:G.split(",").map((Q)=>Q.split(":")[0]),port:Array.isArray(H)?H:G.split(",").map((Q)=>parseInt(Q.split(":")[1]||H)),path:w.path||G.indexOf("/")>-1&&G+"/.s.PGSQL."+H,database:w.database||w.db||(X.pathname||"").slice(1)||W.PGDATABASE||z,user:z,pass:w.pass||w.password||X.password||W.PGPASSWORD||"",...Object.entries(O).reduce((Q,[Z,K])=>{let E=Z in w?w[Z]:(Z in Y)?Y[Z]==="disable"||Y[Z]==="false"?!1:Y[Z]:W["PG"+Z.toUpperCase()]||K;return Q[Z]=typeof E==="string"&&F.includes(Z)?+E:E,Q},{}),connection:{application_name:W.PGAPPNAME||"postgres.js",...w.connection,...Object.entries(Y).reduce((Q,[Z,K])=>((Z in O)||(Q[Z]=K),Q),{})},types:w.types||{},target_session_attrs:ZB(w,X,W),onnotice:w.onnotice,onnotify:w.onnotify,onclose:w.onclose,onparameter:w.onparameter,socket:w.socket,transform:AB(w.transform||{undefined:void 0}),parameters:{},shared:{retries:0,typeArrayMap:{}},...JJ(w.types)}}function ZB($,T,W){let w=$.target_session_attrs||T.searchParams.get("target_session_attrs")||W.PGTARGETSESSIONATTRS;if(!w||["read-write","read-only","primary","standby","prefer-standby"].includes(w))return w;throw new Error("target_session_attrs "+w+" is not supported")}function VB($){return(0.5+Math.random()/2)*Math.min(3**$/100,20)}function KB(){return 60*(30+Math.random()*30)}function AB($){return{undefined:$.undefined,column:{from:typeof $.column==="function"?$.column:$.column&&$.column.from,to:$.column&&$.column.to},value:{from:typeof $.value==="function"?$.value:$.value&&$.value.from,to:$.value&&$.value.to},row:{from:typeof $.row==="function"?$.row:$.row&&$.row.from,to:$.row&&$.row.to}}}function EB($){if(!$||typeof $!=="string")return{url:{searchParams:new Map}};let T=$;T=T.slice(T.indexOf("://")+3).split(/[?/]/)[0],T=decodeURIComponent(T.slice(T.indexOf("@")+1));let W=new URL($.replace(T,T.split(",")[0]));return{url:{username:decodeURIComponent(W.username),password:decodeURIComponent(W.password),host:W.host,hostname:W.hostname,port:W.port,pathname:W.pathname,searchParams:W.searchParams},multihost:T.indexOf(",")>-1&&T}}function MB(){try{return FB.userInfo().username}catch($){return process.env.USERNAME||process.env.USER||process.env.LOGNAME}}class E4{static[N]="SelectionProxyHandler";config;constructor($){this.config={...$}}get($,T){if(T==="_")return{...$._,selectedFields:new Proxy($._.selectedFields,this)};if(T===t$)return{...$[t$],selectedFields:new Proxy($[t$].selectedFields,this)};if(typeof T==="symbol")return $[T];let w=(I($,M4)?$._.selectedFields:I($,c6)?$[t$].selectedFields:$)[T];if(I(w,s.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!w.isSelectionField)return w.sql;let X=w.clone();return X.isSelectionField=!0,X}if(I(w,s)){if(this.config.sqlBehavior==="sql")return w;throw new Error(`You tried to reference "${T}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(I(w,p$)){if(this.config.alias)return new Proxy(w,new d2(new Proxy(w.table,new TU(this.config.alias,this.config.replaceOriginalName??!1))));return w}if(typeof w!=="object"||w===null)return w;return new Proxy(w,new E4(this.config))}}class xJ{constructor($,T){this.unique=$,this.name=T}static[N]="PgIndexBuilderOn";on(...$){return new d9($.map((T)=>{if(I(T,s))return T;T=T;let W=new aw(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=JSON.parse(JSON.stringify(T.defaultConfig)),W}),this.unique,!1,this.name)}onOnly(...$){return new d9($.map((T)=>{if(I(T,s))return T;T=T;let W=new aw(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=T.defaultConfig,W}),this.unique,!0,this.name)}using($,...T){return new d9(T.map((W)=>{if(I(W,s))return W;W=W;let w=new aw(W.name,!!W.keyAsName,W.columnType,W.indexConfig);return W.indexConfig=JSON.parse(JSON.stringify(W.defaultConfig)),w}),this.unique,!0,this.name,$)}}class d9{static[N]="PgIndexBuilder";config;constructor($,T,W,w,X="btree"){this.config={name:w,columns:$,unique:T,only:W,method:X}}concurrently(){return this.config.concurrently=!0,this}with($){return this.config.with=$,this}where($){return this.config.where=$,this}build($){return new fJ(this.config,$)}}class fJ{static[N]="PgIndex";config;constructor($,T){this.config={...$,table:T}}}function AQ($){return new xJ(!0,$)}function DB($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((W)=>W.toLowerCase()).join("_")}function NB($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((W,w,X)=>{let U=X===0?w.toLowerCase():`${w[0].toUpperCase()}${w.slice(1)}`;return W+U},"")}function LB($){return $}class EQ{static[N]="CasingCache";cache={};cachedTables={};convert;constructor($){this.convert=$==="snake_case"?DB:$==="camelCase"?NB:LB}getColumnCasing($){if(!$.keyAsName)return $.name;let T=$.table[o.Symbol.Schema]??"public",W=$.table[o.Symbol.OriginalName],w=`${T}.${W}.${$.name}`;if(!this.cache[w])this.cacheTable($.table);return this.cache[w]}cacheTable($){let T=$[o.Symbol.Schema]??"public",W=$[o.Symbol.OriginalName],w=`${T}.${W}`;if(!this.cachedTables[w]){for(let X of Object.values($[o.Symbol.Columns])){let U=`${w}.${X.name}`;this.cache[U]=this.convert(X.name)}this.cachedTables[w]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class VU extends c6{static[N]="PgViewBase"}class SW{static[N]="PgDialect";casing;constructor($){this.casing=new EQ($?.casing)}async migrate($,T,W){let w=typeof W==="string"?"__drizzle_migrations":W.migrationsTable??"__drizzle_migrations",X=typeof W==="string"?"drizzle":W.migrationsSchema??"drizzle",U=J`
104
+ CREATE TABLE IF NOT EXISTS ${J.identifier(X)}.${J.identifier(w)} (
103
105
  id SERIAL PRIMARY KEY,
104
106
  hash text NOT NULL,
105
107
  created_at bigint
106
108
  )
107
- `;await T.execute(Z`CREATE SCHEMA IF NOT EXISTS ${Z.identifier(X)}`),await T.execute(Y);let w=(await T.all(Z`select id, hash, created_at from ${Z.identifier(X)}.${Z.identifier(U)} order by created_at desc limit 1`))[0];await T.transaction(async(G)=>{for await(let J of $)if(!w||Number(w.created_at)<J.folderMillis){for(let H of J.sql)await G.execute(Z.raw(H));await G.execute(Z`insert into ${Z.identifier(X)}.${Z.identifier(U)} ("hash", "created_at") values(${J.hash}, ${J.folderMillis})`)}})}escapeName($){return`"${$}"`}escapeParam($){return`$${$+1}`}escapeString($){return`'${$.replace(/'/g,"''")}'`}buildWithCTE($){if(!$?.length)return;let T=[Z`with `];for(let[W,U]of $.entries())if(T.push(Z`${Z.identifier(U._.alias)} as (${U._.sql})`),W<$.length-1)T.push(Z`, `);return T.push(Z` `),Z.join(T)}buildDeleteQuery({table:$,where:T,returning:W,withList:U}){let X=this.buildWithCTE(U),Y=W?Z` returning ${this.buildSelection(W,{isSingleTable:!0})}`:void 0,_=T?Z` where ${T}`:void 0;return Z`${X}delete from ${$}${_}${Y}`}buildUpdateSet($,T){let W=$[f.Symbol.Columns],U=Object.keys(W).filter((Y)=>T[Y]!==void 0||W[Y]?.onUpdateFn!==void 0),X=U.length;return Z.join(U.flatMap((Y,_)=>{let w=W[Y],G=T[Y]??Z.param(w.onUpdateFn(),w),J=Z`${Z.identifier(this.casing.getColumnCasing(w))} = ${G}`;if(_<X-1)return[J,Z.raw(", ")];return[J]}))}buildUpdateQuery({table:$,set:T,where:W,returning:U,withList:X,from:Y,joins:_}){let w=this.buildWithCTE(X),G=$[J4.Symbol.Name],J=$[J4.Symbol.Schema],H=$[J4.Symbol.OriginalName],z=G===H?void 0:G,F=Z`${J?Z`${Z.identifier(J)}.`:void 0}${Z.identifier(H)}${z&&Z` ${Z.identifier(z)}`}`,Q=this.buildUpdateSet($,T),V=Y&&Z.join([Z.raw(" from "),this.buildFromTable(Y)]),K=this.buildJoins(_),I=U?Z` returning ${this.buildSelection(U,{isSingleTable:!Y})}`:void 0,k=W?Z` where ${W}`:void 0;return Z`${w}update ${F} set ${Q}${V}${K}${k}${I}`}buildSelection($,{isSingleTable:T=!1}={}){let W=$.length,U=$.flatMap(({field:X},Y)=>{let _=[];if(M(X,p.Aliased)&&X.isSelectionField)_.push(Z.identifier(X.fieldAlias));else if(M(X,p.Aliased)||M(X,p)){let w=M(X,p.Aliased)?X.sql:X;if(T)_.push(new p(w.queryChunks.map((G)=>{if(M(G,b))return Z.identifier(this.casing.getColumnCasing(G));return G})));else _.push(w);if(M(X,p.Aliased))_.push(Z` as ${Z.identifier(X.fieldAlias)}`)}else if(M(X,B$))if(T)_.push(Z.identifier(this.casing.getColumnCasing(X)));else _.push(X);if(Y<W-1)_.push(Z`, `);return _});return Z.join(U)}buildJoins($){if(!$||$.length===0)return;let T=[];for(let[W,U]of $.entries()){if(W===0)T.push(Z` `);let X=U.table,Y=U.lateral?Z` lateral`:void 0,_=U.on?Z` on ${U.on}`:void 0;if(M(X,J4)){let w=X[J4.Symbol.Name],G=X[J4.Symbol.Schema],J=X[J4.Symbol.OriginalName],H=w===J?void 0:U.alias;T.push(Z`${Z.raw(U.joinType)} join${Y} ${G?Z`${Z.identifier(G)}.`:void 0}${Z.identifier(J)}${H&&Z` ${Z.identifier(H)}`}${_}`)}else if(M(X,g4)){let w=X[P$].name,G=X[P$].schema,J=X[P$].originalName,H=w===J?void 0:U.alias;T.push(Z`${Z.raw(U.joinType)} join${Y} ${G?Z`${Z.identifier(G)}.`:void 0}${Z.identifier(J)}${H&&Z` ${Z.identifier(H)}`}${_}`)}else T.push(Z`${Z.raw(U.joinType)} join${Y} ${X}${_}`);if(W<$.length-1)T.push(Z` `)}return Z.join(T)}buildFromTable($){if(M($,f)&&$[f.Symbol.IsAlias]){let T=Z`${Z.identifier($[f.Symbol.OriginalName])}`;if($[f.Symbol.Schema])T=Z`${Z.identifier($[f.Symbol.Schema])}.${T}`;return Z`${T} ${Z.identifier($[f.Symbol.Name])}`}return $}buildSelectQuery({withList:$,fields:T,fieldsFlat:W,where:U,having:X,table:Y,joins:_,orderBy:w,groupBy:G,limit:J,offset:H,lockingClause:z,distinct:F,setOperators:Q}){let V=W??J6(T);for(let H$ of V)if(M(H$.field,B$)&&O4(H$.field.table)!==(M(Y,i$)?Y._.alias:M(Y,WU)?Y[P$].name:M(Y,p)?void 0:O4(Y))&&!(($4)=>_?.some(({alias:V4})=>V4===($4[f.Symbol.IsAlias]?O4($4):$4[f.Symbol.BaseName])))(H$.field.table)){let $4=O4(H$.field.table);throw new Error(`Your "${H$.path.join("->")}" field references a column "${$4}"."${H$.field.name}", but the table "${$4}" is not part of the query! Did you forget to join it?`)}let K=!_||_.length===0,I=this.buildWithCTE($),k;if(F)k=F===!0?Z` distinct`:Z` distinct on (${Z.join(F.on,Z`, `)})`;let N=this.buildSelection(V,{isSingleTable:K}),L=this.buildFromTable(Y),q=this.buildJoins(_),y=U?Z` where ${U}`:void 0,x=X?Z` having ${X}`:void 0,u;if(w&&w.length>0)u=Z` order by ${Z.join(w,Z`, `)}`;let w$;if(G&&G.length>0)w$=Z` group by ${Z.join(G,Z`, `)}`;let m$=typeof J==="object"||typeof J==="number"&&J>=0?Z` limit ${J}`:void 0,B=H?Z` offset ${H}`:void 0,D$=Z.empty();if(z){let H$=Z` for ${Z.raw(z.strength)}`;if(z.config.of)H$.append(Z` of ${Z.join(Array.isArray(z.config.of)?z.config.of:[z.config.of],Z`, `)}`);if(z.config.noWait)H$.append(Z` nowait`);else if(z.config.skipLocked)H$.append(Z` skip locked`);D$.append(H$)}let $$=Z`${I}select${k} ${N} from ${L}${q}${y}${w$}${x}${u}${m$}${B}${D$}`;if(Q.length>0)return this.buildSetOperations($$,Q);return $$}buildSetOperations($,T){let[W,...U]=T;if(!W)throw new Error("Cannot pass undefined values to any set operator");if(U.length===0)return this.buildSetOperationQuery({leftSelect:$,setOperator:W});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:$,setOperator:W}),U)}buildSetOperationQuery({leftSelect:$,setOperator:{type:T,isAll:W,rightSelect:U,limit:X,orderBy:Y,offset:_}}){let w=Z`(${$.getSQL()}) `,G=Z`(${U.getSQL()})`,J;if(Y&&Y.length>0){let Q=[];for(let V of Y)if(M(V,b))Q.push(Z.identifier(V.name));else if(M(V,p)){for(let K=0;K<V.queryChunks.length;K++){let I=V.queryChunks[K];if(M(I,b))V.queryChunks[K]=Z.identifier(I.name)}Q.push(Z`${V}`)}else Q.push(Z`${V}`);J=Z` order by ${Z.join(Q,Z`, `)} `}let H=typeof X==="object"||typeof X==="number"&&X>=0?Z` limit ${X}`:void 0,z=Z.raw(`${T} ${W?"all ":""}`),F=_?Z` offset ${_}`:void 0;return Z`${w}${z}${G}${J}${H}${F}`}buildInsertQuery({table:$,values:T,onConflict:W,returning:U,withList:X,select:Y,overridingSystemValue_:_}){let w=[],G=$[f.Symbol.Columns],J=Object.entries(G).filter(([I,k])=>!k.shouldDisableInsert()),H=J.map(([,I])=>Z.identifier(this.casing.getColumnCasing(I)));if(Y){let I=T;if(M(I,p))w.push(I);else w.push(I.getSQL())}else{let I=T;w.push(Z.raw("values "));for(let[k,N]of I.entries()){let L=[];for(let[q,y]of J){let x=N[q];if(x===void 0||M(x,T6)&&x.value===void 0)if(y.defaultFn!==void 0){let u=y.defaultFn(),w$=M(u,p)?u:Z.param(u,y);L.push(w$)}else if(!y.default&&y.onUpdateFn!==void 0){let u=y.onUpdateFn(),w$=M(u,p)?u:Z.param(u,y);L.push(w$)}else L.push(Z`default`);else L.push(x)}if(w.push(L),k<I.length-1)w.push(Z`, `)}}let z=this.buildWithCTE(X),F=Z.join(w),Q=U?Z` returning ${this.buildSelection(U,{isSingleTable:!0})}`:void 0,V=W?Z` on conflict ${W}`:void 0,K=_===!0?Z`overriding system value `:void 0;return Z`${z}insert into ${$} ${H} ${K}${F}${V}${Q}`}buildRefreshMaterializedViewQuery({view:$,concurrently:T,withNoData:W}){let U=T?Z` concurrently`:void 0,X=W?Z` with no data`:void 0;return Z`refresh materialized view${U} ${$}${X}`}prepareTyping($){if(M($,mY)||M($,gY))return"json";else if(M($,cY))return"decimal";else if(M($,uY))return"time";else if(M($,pY)||M($,oY))return"timestamp";else if(M($,yY)||M($,hY))return"date";else if(M($,dY))return"uuid";else return"none"}sqlToQuery($,T){return $.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,prepareTyping:this.prepareTyping,invokeSource:T})}buildRelationalQueryWithoutPK({fullSchema:$,schema:T,tableNamesMap:W,table:U,tableConfig:X,queryConfig:Y,tableAlias:_,nestedQueryRelation:w,joinOn:G}){let J=[],H,z,F=[],Q,V=[];if(Y===!0)J=Object.entries(X.columns).map(([k,N])=>({dbKey:N.name,tsKey:k,field:y6(N,_),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let I=Object.fromEntries(Object.entries(X.columns).map(([x,u])=>[x,y6(u,_)]));if(Y.where){let x=typeof Y.where==="function"?Y.where(I,IZ()):Y.where;Q=x&&o2(x,_)}let k=[],N=[];if(Y.columns){let x=!1;for(let[u,w$]of Object.entries(Y.columns)){if(w$===void 0)continue;if(u in X.columns){if(!x&&w$===!0)x=!0;N.push(u)}}if(N.length>0)N=x?N.filter((u)=>Y.columns?.[u]===!0):Object.keys(X.columns).filter((u)=>!N.includes(u))}else N=Object.keys(X.columns);for(let x of N){let u=X.columns[x];k.push({tsKey:x,value:u})}let L=[];if(Y.with)L=Object.entries(Y.with).filter((x)=>!!x[1]).map(([x,u])=>({tsKey:x,queryConfig:u,relation:X.relations[x]}));let q;if(Y.extras){q=typeof Y.extras==="function"?Y.extras(I,{sql:Z}):Y.extras;for(let[x,u]of Object.entries(q))k.push({tsKey:x,value:Bz(u,_)})}for(let{tsKey:x,value:u}of k)J.push({dbKey:M(u,p.Aliased)?u.fieldAlias:X.columns[x].name,tsKey:x,field:M(u,B$)?y6(u,_):u,relationTableTsKey:void 0,isJson:!1,selection:[]});let y=typeof Y.orderBy==="function"?Y.orderBy(I,kZ()):Y.orderBy??[];if(!Array.isArray(y))y=[y];F=y.map((x)=>{if(M(x,B$))return y6(x,_);return o2(x,_)}),H=Y.limit,z=Y.offset;for(let{tsKey:x,queryConfig:u,relation:w$}of L){let m$=qZ(T,W,w$),B=v0(w$.referencedTable),D$=W[B],$$=`${_}_${x}`,H$=n2(...m$.fields.map((Q6,u0)=>lY(y6(m$.references[u0],$$),y6(Q6,_)))),$4=this.buildRelationalQueryWithoutPK({fullSchema:$,schema:T,tableNamesMap:W,table:$[D$],tableConfig:T[D$],queryConfig:M(w$,m1)?u===!0?{limit:1}:{...u,limit:1}:u,tableAlias:$$,joinOn:H$,nestedQueryRelation:w$}),V4=Z`${Z.identifier($$)}.${Z.identifier("data")}`.as(x);V.push({on:Z`true`,table:new i$($4.sql,{},$$),alias:$$,joinType:"left",lateral:!0}),J.push({dbKey:x,tsKey:x,field:V4,relationTableTsKey:D$,isJson:!0,selection:$4.selection})}}if(J.length===0)throw new bY({message:`No fields selected for table "${X.tsName}" ("${_}")`});let K;if(Q=n2(G,Q),w){let I=Z`json_build_array(${Z.join(J.map(({field:L,tsKey:q,isJson:y})=>y?Z`${Z.identifier(`${_}_${q}`)}.${Z.identifier("data")}`:M(L,p.Aliased)?L.sql:L),Z`, `)})`;if(M(w,t2))I=Z`coalesce(json_agg(${I}${F.length>0?Z` order by ${Z.join(F,Z`, `)}`:void 0}), '[]'::json)`;let k=[{dbKey:"data",tsKey:"data",field:I.as("data"),isJson:!0,relationTableTsKey:X.tsName,selection:J}];if(H!==void 0||z!==void 0||F.length>0)K=this.buildSelectQuery({table:xY(U,_),fields:{},fieldsFlat:[{path:[],field:Z.raw("*")}],where:Q,limit:H,offset:z,orderBy:F,setOperators:[]}),Q=void 0,H=void 0,z=void 0,F=[];else K=xY(U,_);K=this.buildSelectQuery({table:M(K,J4)?K:new i$(K,{},_),fields:{},fieldsFlat:k.map(({field:L})=>({path:[],field:M(L,B$)?y6(L,_):L})),joins:V,where:Q,limit:H,offset:z,orderBy:F,setOperators:[]})}else K=this.buildSelectQuery({table:xY(U,_),fields:{},fieldsFlat:J.map(({field:I})=>({path:[],field:M(I,B$)?y6(I,_):I})),joins:V,where:Q,limit:H,offset:z,orderBy:F,setOperators:[]});return{tableTsKey:X.tsName,sql:K,selection:J}}}class sz{static[D]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class q4{static[D]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor($){if(this.fields=$.fields,this.session=$.session,this.dialect=$.dialect,$.withList)this.withList=$.withList;this.distinct=$.distinct}authToken;setToken($){return this.authToken=$,this}from($){let T=!!this.fields,W=$,U;if(this.fields)U=this.fields;else if(M(W,i$))U=Object.fromEntries(Object.keys(W._.selectedFields).map((X)=>[X,W[X]]));else if(M(W,WU))U=W[P$].selectedFields;else if(M(W,p))U={};else U=wD(W);return new ez({table:W,fields:U,isPartialSelect:T,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class $V extends sz{static[D]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:$,fields:T,isPartialSelect:W,session:U,dialect:X,withList:Y,distinct:_}){super();this.config={withList:Y,table:$,fields:{...T},distinct:_,setOperators:[]},this.isPartialSelect=W,this.session=U,this.dialect=X,this._={selectedFields:T,config:this.config},this.tableName=_1($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let w of L6($))this.usedTables.add(w)}getUsedTables(){return[...this.usedTables]}createJoin($,T){return(W,U)=>{let X=this.tableName,Y=_1(W);for(let _ of L6(W))this.usedTables.add(_);if(typeof Y==="string"&&this.config.joins?.some((_)=>_.alias===Y))throw new Error(`Alias "${Y}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof X==="string")this.config.fields={[X]:this.config.fields};if(typeof Y==="string"&&!M(W,p)){let _=M(W,i$)?W._.selectedFields:M(W,g4)?W[P$].selectedFields:W[f.Symbol.Columns];this.config.fields[Y]=_}}if(typeof U==="function")U=U(new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:U,table:W,joinType:$,alias:Y,lateral:T}),typeof Y==="string")switch($){case"left":{this.joinsNotNullableMap[Y]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([_])=>[_,!1])),this.joinsNotNullableMap[Y]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[Y]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([_])=>[_,!1])),this.joinsNotNullableMap[Y]=!1;break}}return this}}leftJoin=this.createJoin("left",!1);leftJoinLateral=this.createJoin("left",!0);rightJoin=this.createJoin("right",!1);innerJoin=this.createJoin("inner",!1);innerJoinLateral=this.createJoin("inner",!0);fullJoin=this.createJoin("full",!1);crossJoin=this.createJoin("cross",!1);crossJoinLateral=this.createJoin("cross",!0);createSetOperator($,T){return(W)=>{let U=typeof W==="function"?W(zv()):W;if(!d2(this.getSelectedFields(),U.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:$,isAll:T,rightSelect:U}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators($){return this.config.setOperators.push(...$),this}where($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=$,this}having($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=$,this}groupBy(...$){if(typeof $[0]==="function"){let T=$[0](new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(T)?T:[T]}else this.config.groupBy=$;return this}orderBy(...$){if(typeof $[0]==="function"){let T=$[0](new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),W=Array.isArray(T)?T:[T];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=W;else this.config.orderBy=W}else{let T=$;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=T;else this.config.orderBy=T}return this}limit($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=$;else this.config.limit=$;return this}offset($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=$;else this.config.offset=$;return this}for($,T={}){return this.config.lockingClause={strength:$,config:T},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}as($){let T=[];if(T.push(...L6(this.config.table)),this.config.joins)for(let W of this.config.joins)T.push(...L6(W.table));return new Proxy(new i$(this.getSQL(),this.config.fields,$,!1,[...new Set(T)]),new r$({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new r$({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}$withCache($){return this.cacheConfig=$===void 0?{config:{},enable:!0,autoInvalidate:!0}:$===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...$},this}}class ez extends $V{static[D]="PgSelect";_prepare($){let{session:T,config:W,dialect:U,joinsNotNullableMap:X,authToken:Y,cacheConfig:_,usedTables:w}=this;if(!T)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");let{fields:G}=W;return R$.startActiveSpan("drizzle.prepareQuery",()=>{let J=J6(G),H=T.prepareQuery(U.sqlToQuery(this.getSQL()),J,$,!0,void 0,{type:"select",tables:[...w]},_);return H.joinsNotNullableMap=X,H.setToken(Y)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}_D(ez,[k4]);function xT($,T){return(W,U,...X)=>{let Y=[U,...X].map((_)=>({type:$,isAll:T,rightSelect:_}));for(let _ of Y)if(!d2(W.getSelectedFields(),_.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return W.addSetOperators(Y)}}var zv=()=>({union:Hv,unionAll:Fv,intersect:Ov,intersectAll:Dv,except:Qv,exceptAll:Zv}),Hv=xT("union",!1),Fv=xT("union",!0),Ov=xT("intersect",!1),Dv=xT("intersect",!0),Qv=xT("except",!1),Zv=xT("except",!0);class UU{static[D]="PgQueryBuilder";dialect;dialectConfig;constructor($){this.dialect=M($,x0)?$:void 0,this.dialectConfig=M($,x0)?void 0:$}$with=($,T)=>{let W=this;return{as:(X)=>{if(typeof X==="function")X=X(W);return new Proxy(new c2(X.getSQL(),T??("getSelectedFields"in X?X.getSelectedFields()??{}:{}),$,!0),new r$({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...$){let T=this;function W(Y){return new q4({fields:Y??void 0,session:void 0,dialect:T.getDialect(),withList:$})}function U(Y){return new q4({fields:Y??void 0,session:void 0,dialect:T.getDialect(),distinct:!0})}function X(Y,_){return new q4({fields:_??void 0,session:void 0,dialect:T.getDialect(),distinct:{on:Y}})}return{select:W,selectDistinct:U,selectDistinctOn:X}}select($){return new q4({fields:$??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct($){return new q4({fields:$??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn($,T){return new q4({fields:T??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:$}})}getDialect(){if(!this.dialect)this.dialect=new x0(this.dialectConfig);return this.dialect}}function L6($){if(M($,J4))return[$[k0]?`${$[k0]}.${$[f.Symbol.BaseName]}`:$[f.Symbol.BaseName]];if(M($,i$))return $._.usedTables??[];if(M($,p))return $.usedTables??[];return[]}class w8 extends k4{constructor($,T,W,U){super();this.session=T,this.dialect=W,this.config={table:$,withList:U}}static[D]="PgDelete";config;cacheConfig;where($){return this.config.where=$,this}returning($=this.config.table[f.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=J6($),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return R$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0,void 0,{type:"delete",tables:L6(this.config.table)},this.cacheConfig)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new r$({alias:O4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class J8{constructor($,T,W,U,X){this.table=$,this.session=T,this.dialect=W,this.withList=U,this.overridingSystemValue_=X}static[D]="PgInsertBuilder";authToken;setToken($){return this.authToken=$,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values($){if($=Array.isArray($)?$:[$],$.length===0)throw new Error("values() must be called with at least one value");let T=$.map((W)=>{let U={},X=this.table[f.Symbol.Columns];for(let Y of Object.keys(W)){let _=W[Y];U[Y]=M(_,p)?_:new T6(_,X[Y])}return U});return new $7(this.table,T,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select($){let T=typeof $==="function"?$(new UU):$;if(!M(T,p)&&!d2(this.table[CY],T._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new $7(this.table,T,this.session,this.dialect,this.withList,!0)}}class $7 extends k4{constructor($,T,W,U,X,Y,_){super();this.session=W,this.dialect=U,this.config={table:$,values:T,withList:X,select:Y,overridingSystemValue_:_}}static[D]="PgInsert";config;cacheConfig;returning($=this.config.table[f.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=J6($),this}onConflictDoNothing($={}){if($.target===void 0)this.config.onConflict=Z`do nothing`;else{let T="";T=Array.isArray($.target)?$.target.map((U)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(U))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target));let W=$.where?Z` where ${$.where}`:void 0;this.config.onConflict=Z`(${Z.raw(T)})${W} do nothing`}return this}onConflictDoUpdate($){if($.where&&($.targetWhere||$.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let T=$.where?Z` where ${$.where}`:void 0,W=$.targetWhere?Z` where ${$.targetWhere}`:void 0,U=$.setWhere?Z` where ${$.setWhere}`:void 0,X=this.dialect.buildUpdateSet(this.config.table,fY(this.config.table,$.set)),Y="";return Y=Array.isArray($.target)?$.target.map((_)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(_))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target)),this.config.onConflict=Z`(${Z.raw(Y)})${W} do update set ${X}${T}${U}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return R$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0,void 0,{type:"insert",tables:L6(this.config.table)},this.cacheConfig)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new r$({alias:O4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class T7 extends k4{constructor($,T,W){super();this.session=T,this.dialect=W,this.config={view:$}}static[D]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return R$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}class G8{constructor($,T,W,U){this.table=$,this.session=T,this.dialect=W,this.withList=U}static[D]="PgUpdateBuilder";authToken;setToken($){return this.authToken=$,this}set($){return new TV(this.table,fY(this.table,$),this.session,this.dialect,this.withList).setToken(this.authToken)}}class TV extends k4{constructor($,T,W,U,X){super();this.session=W,this.dialect=U,this.config={set:T,table:$,withList:X,joins:[]},this.tableName=_1($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[D]="PgUpdate";config;tableName;joinsNotNullableMap;cacheConfig;from($){let T=$,W=_1(T);if(typeof W==="string")this.joinsNotNullableMap[W]=!0;return this.config.from=T,this}getTableLikeFields($){if(M($,J4))return $[f.Symbol.Columns];else if(M($,i$))return $._.selectedFields;return $[P$].selectedFields}createJoin($){return(T,W)=>{let U=_1(T);if(typeof U==="string"&&this.config.joins.some((X)=>X.alias===U))throw new Error(`Alias "${U}" is already used in this query`);if(typeof W==="function"){let X=this.config.from&&!M(this.config.from,p)?this.getTableLikeFields(this.config.from):void 0;W=W(new Proxy(this.config.table[f.Symbol.Columns],new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),X&&new Proxy(X,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:W,table:T,joinType:$,alias:U}),typeof U==="string")switch($){case"left":{this.joinsNotNullableMap[U]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([X])=>[X,!1])),this.joinsNotNullableMap[U]=!0;break}case"inner":{this.joinsNotNullableMap[U]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([X])=>[X,!1])),this.joinsNotNullableMap[U]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where($){return this.config.where=$,this}returning($){if(!$){if($=Object.assign({},this.config.table[f.Symbol.Columns]),this.config.from){let T=_1(this.config.from);if(typeof T==="string"&&this.config.from&&!M(this.config.from,p)){let W=this.getTableLikeFields(this.config.from);$[T]=W}for(let W of this.config.joins){let U=_1(W.table);if(typeof U==="string"&&!M(W.table,p)){let X=this.getTableLikeFields(W.table);$[U]=X}}}}return this.config.returningFields=$,this.config.returning=J6($),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){let T=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0,void 0,{type:"insert",tables:L6(this.config.table)},this.cacheConfig);return T.joinsNotNullableMap=this.joinsNotNullableMap,T}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return this._prepare().execute($,this.authToken)};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new r$({alias:O4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class XU extends p{constructor($){super(XU.buildEmbeddedCount($.source,$.filters).queryChunks);this.params=$,this.mapWith(Number),this.session=$.session,this.sql=XU.buildCount($.source,$.filters)}sql;token;static[D]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount($,T){return Z`(select count(*) from ${$}${Z.raw(" where ").if(T)}${T})`}static buildCount($,T){return Z`select count(*) as count from ${$}${Z.raw(" where ").if(T)}${T};`}setToken($){return this.token=$,this}then($,T){return Promise.resolve(this.session.count(this.sql,this.token)).then($,T)}catch($){return this.then(void 0,$)}finally($){return this.then((T)=>{return $?.(),T},(T)=>{throw $?.(),T})}}class U7{constructor($,T,W,U,X,Y,_){this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=U,this.tableConfig=X,this.dialect=Y,this.session=_}static[D]="PgRelationalQueryBuilder";findMany($){return new W7(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?$:{},"many")}findFirst($){return new W7(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?{...$,limit:1}:{limit:1},"first")}}class W7 extends k4{constructor($,T,W,U,X,Y,_,w,G){super();this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=U,this.tableConfig=X,this.dialect=Y,this.session=_,this.config=w,this.mode=G}static[D]="PgRelationalQuery";_prepare($){return R$.startActiveSpan("drizzle.prepareQuery",()=>{let{query:T,builtQuery:W}=this._toSQL();return this.session.prepareQuery(W,void 0,$,!0,(U,X)=>{let Y=U.map((_)=>iY(this.schema,this.tableConfig,_,T.selection,X));if(this.mode==="first")return Y[0];return Y})})}prepare($){return this._prepare($)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let $=this._getQuery(),T=this.dialect.sqlToQuery($.sql);return{query:$,builtQuery:T}}toSQL(){return this._toSQL().builtQuery}authToken;setToken($){return this.authToken=$,this}execute(){return R$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class X7 extends k4{constructor($,T,W,U){super();this.execute=$,this.sql=T,this.query=W,this.mapBatchResult=U}static[D]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult($,T){return T?this.mapBatchResult($):$}_prepare(){return this}isResponseInArrayMode(){return!1}}class YU{constructor($,T,W){if(this.dialect=$,this.session=T,this._=W?{schema:W.schema,fullSchema:W.fullSchema,tableNamesMap:W.tableNamesMap,session:T}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:T},this.query={},this._.schema)for(let[U,X]of Object.entries(this._.schema))this.query[U]=new U7(W.fullSchema,this._.schema,this._.tableNamesMap,W.fullSchema[U],X,$,T);this.$cache={invalidate:async(U)=>{}}}static[D]="PgDatabase";query;$with=($,T)=>{let W=this;return{as:(X)=>{if(typeof X==="function")X=X(new UU(W.dialect));return new Proxy(new c2(X.getSQL(),T??("getSelectedFields"in X?X.getSelectedFields()??{}:{}),$,!0),new r$({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count($,T){return new XU({source:$,filters:T,session:this.session})}$cache;with(...$){let T=this;function W(G){return new q4({fields:G??void 0,session:T.session,dialect:T.dialect,withList:$})}function U(G){return new q4({fields:G??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:!0})}function X(G,J){return new q4({fields:J??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:{on:G}})}function Y(G){return new G8(G,T.session,T.dialect,$)}function _(G){return new J8(G,T.session,T.dialect,$)}function w(G){return new w8(G,T.session,T.dialect,$)}return{select:W,selectDistinct:U,selectDistinctOn:X,update:Y,insert:_,delete:w}}select($){return new q4({fields:$??void 0,session:this.session,dialect:this.dialect})}selectDistinct($){return new q4({fields:$??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn($,T){return new q4({fields:T??void 0,session:this.session,dialect:this.dialect,distinct:{on:$}})}update($){return new G8($,this.session,this.dialect)}insert($){return new J8($,this.session,this.dialect)}delete($){return new w8($,this.session,this.dialect)}refreshMaterializedView($){return new T7($,this.session,this.dialect)}authToken;execute($){let T=typeof $==="string"?Z.raw($):$.getSQL(),W=this.dialect.sqlToQuery(T),U=this.session.prepareQuery(W,void 0,void 0,!1);return new X7(()=>U.execute(void 0,this.authToken),T,W,(X)=>U.mapResult(X,!0))}transaction($,T){return this.session.transaction($,T)}}class WV{static[D]="Cache"}class _U extends WV{strategy(){return"all"}static[D]="NoopCache";async get($){return}async put($,T,W,U){}async onMutate($){}}async function Y7($,T){let W=`${$}-${JSON.stringify(T)}`,X=new TextEncoder().encode(W),Y=await crypto.subtle.digest("SHA-256",X);return[...new Uint8Array(Y)].map((G)=>G.toString(16).padStart(2,"0")).join("")}class J1 extends Error{constructor($,T,W){super(`Failed query: ${$}
108
- params: ${T}`);if(this.query=$,this.params=T,this.cause=W,Error.captureStackTrace(this,J1),W)this.cause=W}}class _7{constructor($,T,W,U){if(this.query=$,this.cache=T,this.queryMetadata=W,this.cacheConfig=U,T&&T.strategy()==="all"&&U===void 0)this.cacheConfig={enable:!0,autoInvalidate:!0};if(!this.cacheConfig?.enable)this.cacheConfig=void 0}authToken;getQuery(){return this.query}mapResult($,T){return $}setToken($){return this.authToken=$,this}static[D]="PgPreparedQuery";joinsNotNullableMap;async queryWithCache($,T,W){if(this.cache===void 0||M(this.cache,_U)||this.queryMetadata===void 0)try{return await W()}catch(U){throw new J1($,T,U)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await W()}catch(U){throw new J1($,T,U)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[U]=await Promise.all([W(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return U}catch(U){throw new J1($,T,U)}if(!this.cacheConfig)try{return await W()}catch(U){throw new J1($,T,U)}if(this.queryMetadata.type==="select"){let U=await this.cache.get(this.cacheConfig.tag??await Y7($,T),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(U===void 0){let X;try{X=await W()}catch(Y){throw new J1($,T,Y)}return await this.cache.put(this.cacheConfig.tag??await Y7($,T),X,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),X}return U}try{return await W()}catch(U){throw new J1($,T,U)}}}class w7{constructor($){this.dialect=$}static[D]="PgSession";execute($,T){return R$.startActiveSpan("drizzle.operation",()=>{return R$.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1)}).setToken(T).execute(void 0,T)})}all($){return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1).all()}async count($,T){let W=await this.execute($,T);return Number(W[0].count)}}class J7 extends YU{constructor($,T,W,U=0){super($,T,W);this.schema=W,this.nestedIndex=U}static[D]="PgTransaction";rollback(){throw new Rz}getTransactionConfigSQL($){let T=[];if($.isolationLevel)T.push(`isolation level ${$.isolationLevel}`);if($.accessMode)T.push($.accessMode);if(typeof $.deferrable==="boolean")T.push($.deferrable?"deferrable":"not deferrable");return Z.raw(T.join(" "))}setTransaction($){return this.session.execute(Z`set transaction ${this.getTransactionConfigSQL($)}`)}}class UV extends _7{constructor($,T,W,U,X,Y,_,w,G,J){super({sql:T,params:W},X,Y,_);this.client=$,this.queryString=T,this.params=W,this.logger=U,this.fields=w,this._isResponseInArrayMode=G,this.customResultMapper=J}static[D]="PostgresJsPreparedQuery";async execute($={}){return R$.startActiveSpan("drizzle.execute",async(T)=>{let W=Sz(this.params,$);T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W);let{fields:U,queryString:X,client:Y,joinsNotNullableMap:_,customResultMapper:w}=this;if(!U&&!w)return R$.startActiveSpan("drizzle.driver.execute",()=>{return this.queryWithCache(X,W,async()=>{return await Y.unsafe(X,W)})});let G=await R$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":X,"drizzle.query.params":JSON.stringify(W)}),this.queryWithCache(X,W,async()=>{return await Y.unsafe(X,W).values()})});return R$.startActiveSpan("drizzle.mapResponse",()=>{return w?w(G):G.map((J)=>YD(U,J,_))})})}all($={}){return R$.startActiveSpan("drizzle.execute",async(T)=>{let W=Sz(this.params,$);return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W),R$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.queryWithCache(this.queryString,W,async()=>{return this.client.unsafe(this.queryString,W)})})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class wU extends w7{constructor($,T,W,U={}){super(T);this.client=$,this.schema=W,this.options=U,this.logger=U.logger??new kz,this.cache=U.cache??new _U}static[D]="PostgresJsSession";logger;cache;prepareQuery($,T,W,U,X,Y,_){return new UV(this.client,$.sql,$.params,this.logger,this.cache,Y,_,T,U,X)}query($,T){return this.logger.logQuery($,T),this.client.unsafe($,T).values()}queryObjects($,T){return this.client.unsafe($,T)}transaction($,T){return this.client.begin(async(W)=>{let U=new wU(W,this.dialect,this.schema,this.options),X=new G7(this.dialect,U,this.schema);if(T)await X.setTransaction(T);return $(X)})}}class G7 extends J7{constructor($,T,W,U=0){super($,T,W,U);this.session=T}static[D]="PostgresJsTransaction";transaction($){return this.session.client.savepoint((T)=>{let W=new wU(T,this.dialect,this.schema,this.session.options),U=new G7(this.dialect,W,this.schema);return $(U)})}}class XV extends YU{static[D]="PostgresJsDatabase"}function bT($,T={}){let W=(G)=>G;for(let G of["1184","1082","1083","1114","1182","1185","1115","1231"])$.options.parsers[G]=W,$.options.serializers[G]=W;$.options.serializers["114"]=W,$.options.serializers["3802"]=W;let U=new x0({casing:T.casing}),X;if(T.logger===!0)X=new Iz;else if(T.logger!==!1)X=T.logger;let Y;if(T.schema){let G=vZ(T.schema,PZ);Y={fullSchema:T.schema,schema:G.tables,tableNamesMap:G.tableNamesMap}}let _=new wU($,U,Y,{logger:X,cache:T.cache}),w=new XV(U,_,Y);if(w.$client=$,w.$cache=T.cache,w.$cache)w.$cache.invalidate=T.cache?.onMutate;return w}function z8(...$){if(typeof $[0]==="string"){let T=jT($[0]);return bT(T,$[1])}if(JD($[0])){let{connection:T,client:W,...U}=$[0];if(W)return bT(W,U);if(typeof T==="object"&&T.url!==void 0){let{url:Y,..._}=T,w=jT(Y,_);return bT(w,U)}let X=jT(T);return bT(X,U)}return bT($[0],$[1])}(($)=>{function T(W){return bT({options:{parsers:{},serializers:{}}},W)}$.mock=T})(z8||(z8={}));function YV($,T){if($ instanceof Promise)throw new Error(T)}function Vv($,T){let W={},U=[];for(let X in $){let Y=$[X]["~standard"].validate(T[X]);if(YV(Y,`Validation must be synchronous, but ${X} returned a Promise.`),Y.issues){U.push(...Y.issues.map((_)=>({..._,message:_.message,path:[X,..._.path??[]]})));continue}W[X]=Y.value}if(U.length)return{issues:U};return{value:W}}function z7($){let T=$.runtimeEnvStrict??$.runtimeEnv??process.env;if($.emptyStringAsUndefined??!1){for(let[N,L]of Object.entries(T))if(L==="")delete T[N]}if(!!$.skipValidation)return T;let X=typeof $.client==="object"?$.client:{},Y=typeof $.server==="object"?$.server:{},_=typeof $.shared==="object"?$.shared:{},w=$.isServer??(typeof window==="undefined"||("Deno"in window)),G=w?{...Y,..._,...X}:{...X,..._},J=$.createFinalSchema?.(G,w)["~standard"].validate(T)??Vv(G,T);YV(J,"Validation must be synchronous");let H=$.onValidationError??((N)=>{throw console.error("\u274C Invalid environment variables:",N),new Error("Invalid environment variables")}),z=$.onInvalidAccess??(()=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")});if(J.issues)return H(J.issues);let F=(N)=>{if(!$.clientPrefix)return!0;return!N.startsWith($.clientPrefix)&&!(N in _)},Q=(N)=>{return w||!F(N)},V=(N)=>{return N==="__esModule"||N==="$$typeof"},K=($.extends??[]).reduce((N,L)=>{return Object.assign(N,L)},{}),I=Object.assign(K,J.value);return new Proxy(I,{get(N,L){if(typeof L!=="string")return;if(V(L))return;if(!Q(L))return z(L);return Reflect.get(N,L)}})}var u1=($)=>Array.isArray($)?$:[$],_V=($,T)=>{let W=[[],[]];for(let U of $)if(T(U))W[0].push(U);else W[1].push(U);return W},H8=Array,G1=($,T)=>$.includes(T),wV=($,T=0)=>[...new Array($)].map((W,U)=>U+T),O$=($,T,W)=>{if($===void 0)return T===void 0?[]:Array.isArray(T)?T:[T];if(W?.prepend)if(Array.isArray(T))$.unshift(...T);else $.unshift(T);else if(Array.isArray(T))$.push(...T);else $.push(T);return $},z1=($,T)=>{if(T===void 0||T===null)return $??[];if($===void 0||$===null)return u1(T);return $.concat(T)},JV=(...$)=>$.reduce(z1,[]),g6=($,T,W)=>{if($===void 0)return Array.isArray(T)?T:[T];let U=W?.isEqual??((X,Y)=>X===Y);for(let X of u1(T))if(!$.some((Y)=>U(Y,X)))$.push(X);return $},GV=($,T)=>$.reduce((W,U)=>{let X=U[T];return W[X]=O$(W[X],U),W},{}),H1=($,T,W)=>$.length===T.length&&$.every(W?.isEqual?(U,X)=>W.isEqual(U,T[X]):(U,X)=>U===T[X]);var c4=($,T)=>G4($)===T,G4=($)=>{let T=typeof $;return T==="object"?$===null?"null":"object":T==="function"?"object":T},u4={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},zV={...u4,function:"a function"};class HV extends Error{}var Z$=($)=>b0($,HV),b0=($,T=Error)=>{throw new T($)};class JU extends Error{name="ParseError"}var S=($)=>b0($,JU),S6=($)=>` ${$}`;var X$=($,T)=>{let W={},U=Array.isArray($),X=!1;for(let[Y,_]of Object.entries($).entries()){let w=U?T(Y,_[1]):T(..._,Y);X||=typeof w[0]==="number";let G=Array.isArray(w[0])||w.length===0?w:[w];for(let[J,H]of G)if(typeof J==="object")W[J.group]=O$(W[J.group],H);else W[J]=H}return X?Object.values(W):W};var H7=Object.entries;var z4=($,T)=>($ in T),fT=($,T)=>(T in $);class F7{constructor($){Object.assign(this,$)}}var FV=class{};class GU extends FV{}var Kv=($,T)=>{let W={},U={},X;for(X in $)if(X in T)W[X]=$[X];else U[X]=$[X];return[W,U]};var OV=($,T)=>Kv($,T)[1],m6=($)=>Object.keys($).length===0,f0=($)=>[...Object.entries($),...Object.getOwnPropertySymbols($).map((T)=>[T,$[T]])],DV=($,T)=>Object.defineProperties($,Object.getOwnPropertyDescriptors(T)),QV=($)=>{let T=Object.keys($).sort(),W={};for(let U=0;U<T.length;U++)W[T[U]]=$[T[U]];return W};var U6=S6("represents an uninitialized value"),ZV=($)=>Object.values($).filter((T)=>{if(typeof T==="number")return!0;return typeof $[T]!=="number"});var O7={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},D7=globalThis.File??Blob,Q7={ArrayBuffer,Blob,File:D7,FormData,Headers,Request,Response,URL},Ev={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},y0={...O7,...Q7,...Ev,String,Number,Boolean},zU=($)=>{let T=Object.getPrototypeOf($);while(T?.constructor&&(!z4(T.constructor.name,y0)||!($ instanceof y0[T.constructor.name])))T=Object.getPrototypeOf(T);let W=T?.constructor?.name;if(W===void 0||W==="Object")return;return W},HU=($)=>typeof $==="object"&&$!==null?zU($)??"object":G4($);var I$=Array.isArray,Av={Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},Mv={ArrayBuffer:"an ArrayBuffer instance",Blob:"a Blob instance",File:"a File instance",FormData:"a FormData instance",Headers:"a Headers instance",Request:"a Request instance",Response:"a Response instance",URL:"a URL instance"},Nv={Int8Array:"an Int8Array",Uint8Array:"a Uint8Array",Uint8ClampedArray:"a Uint8ClampedArray",Int16Array:"an Int16Array",Uint16Array:"a Uint16Array",Int32Array:"an Int32Array",Uint32Array:"a Uint32Array",Float32Array:"a Float32Array",Float64Array:"a Float64Array",BigInt64Array:"a BigInt64Array",BigUint64Array:"a BigUint64Array"},VV={...Av,...Mv,...Nv},FU=($)=>{let T=Object($).name??null;return T&&z4(T,y0)&&y0[T]===$?T:null};var Z7=($,T)=>{let W=$.prototype;while(W!==null){if(W===T.prototype)return!0;W=Object.getPrototypeOf(W)}return!1};var KV=($)=>EV($,new Map),EV=($,T)=>{if(typeof $!=="object"||$===null)return $;if(T?.has($))return T.get($);let W=FU($.constructor);if(W==="Date")return new Date($.getTime());if(W&&W!=="Array")return $;let U=Array.isArray($)?$.slice():Object.create(Object.getPrototypeOf($)),X=Object.getOwnPropertyDescriptors($);if(T){T.set($,U);for(let Y in X){let _=X[Y];if("get"in _||"set"in _)continue;_.value=EV(_.value,T)}}return Object.defineProperties(U,X),U};var Lv=($)=>{let T=U6;return()=>T===U6?T=$():T},p1=($)=>typeof $==="function"&&$.length===0;var AV=class extends Function{constructor(...$){let T=$.slice(0,-1),W=$.at(-1);try{super(...T,W)}catch(U){return Z$(`Encountered an unexpected error while compiling your definition:
109
- Message: ${U}
109
+ `;await T.execute(J`CREATE SCHEMA IF NOT EXISTS ${J.identifier(X)}`),await T.execute(U);let G=(await T.all(J`select id, hash, created_at from ${J.identifier(X)}.${J.identifier(w)} order by created_at desc limit 1`))[0];await T.transaction(async(H)=>{for await(let z of $)if(!G||Number(G.created_at)<z.folderMillis){for(let F of z.sql)await H.execute(J.raw(F));await H.execute(J`insert into ${J.identifier(X)}.${J.identifier(w)} ("hash", "created_at") values(${z.hash}, ${z.folderMillis})`)}})}escapeName($){return`"${$}"`}escapeParam($){return`$${$+1}`}escapeString($){return`'${$.replace(/'/g,"''")}'`}buildWithCTE($){if(!$?.length)return;let T=[J`with `];for(let[W,w]of $.entries())if(T.push(J`${J.identifier(w._.alias)} as (${w._.sql})`),W<$.length-1)T.push(J`, `);return T.push(J` `),J.join(T)}buildDeleteQuery({table:$,where:T,returning:W,withList:w}){let X=this.buildWithCTE(w),U=W?J` returning ${this.buildSelection(W,{isSingleTable:!0})}`:void 0,Y=T?J` where ${T}`:void 0;return J`${X}delete from ${$}${Y}${U}`}buildUpdateSet($,T){let W=$[o.Symbol.Columns],w=Object.keys(W).filter((U)=>T[U]!==void 0||W[U]?.onUpdateFn!==void 0),X=w.length;return J.join(w.flatMap((U,Y)=>{let G=W[U],H=T[U]??J.param(G.onUpdateFn(),G),z=J`${J.identifier(this.casing.getColumnCasing(G))} = ${H}`;if(Y<X-1)return[z,J.raw(", ")];return[z]}))}buildUpdateQuery({table:$,set:T,where:W,returning:w,withList:X,from:U,joins:Y}){let G=this.buildWithCTE(X),H=$[x4.Symbol.Name],z=$[x4.Symbol.Schema],F=$[x4.Symbol.OriginalName],O=H===F?void 0:H,Q=J`${z?J`${J.identifier(z)}.`:void 0}${J.identifier(F)}${O&&J` ${J.identifier(O)}`}`,Z=this.buildUpdateSet($,T),K=U&&J.join([J.raw(" from "),this.buildFromTable(U)]),E=this.buildJoins(Y),M=w?J` returning ${this.buildSelection(w,{isSingleTable:!U})}`:void 0,L=W?J` where ${W}`:void 0;return J`${G}update ${Q} set ${Z}${K}${E}${L}${M}`}buildSelection($,{isSingleTable:T=!1}={}){let W=$.length,w=$.flatMap(({field:X},U)=>{let Y=[];if(I(X,s.Aliased)&&X.isSelectionField)Y.push(J.identifier(X.fieldAlias));else if(I(X,s.Aliased)||I(X,s)){let G=I(X,s.Aliased)?X.sql:X;if(T)Y.push(new s(G.queryChunks.map((H)=>{if(I(H,d))return J.identifier(this.casing.getColumnCasing(H));return H})));else Y.push(G);if(I(X,s.Aliased))Y.push(J` as ${J.identifier(X.fieldAlias)}`)}else if(I(X,p$))if(T)Y.push(J.identifier(this.casing.getColumnCasing(X)));else Y.push(X);if(U<W-1)Y.push(J`, `);return Y});return J.join(w)}buildJoins($){if(!$||$.length===0)return;let T=[];for(let[W,w]of $.entries()){if(W===0)T.push(J` `);let X=w.table,U=w.lateral?J` lateral`:void 0,Y=w.on?J` on ${w.on}`:void 0;if(I(X,x4)){let G=X[x4.Symbol.Name],H=X[x4.Symbol.Schema],z=X[x4.Symbol.OriginalName],F=G===z?void 0:w.alias;T.push(J`${J.raw(w.joinType)} join${U} ${H?J`${J.identifier(H)}.`:void 0}${J.identifier(z)}${F&&J` ${J.identifier(F)}`}${Y}`)}else if(I(X,c6)){let G=X[t$].name,H=X[t$].schema,z=X[t$].originalName,F=G===z?void 0:w.alias;T.push(J`${J.raw(w.joinType)} join${U} ${H?J`${J.identifier(H)}.`:void 0}${J.identifier(z)}${F&&J` ${J.identifier(F)}`}${Y}`)}else T.push(J`${J.raw(w.joinType)} join${U} ${X}${Y}`);if(W<$.length-1)T.push(J` `)}return J.join(T)}buildFromTable($){if(I($,o)&&$[o.Symbol.IsAlias]){let T=J`${J.identifier($[o.Symbol.OriginalName])}`;if($[o.Symbol.Schema])T=J`${J.identifier($[o.Symbol.Schema])}.${T}`;return J`${T} ${J.identifier($[o.Symbol.Name])}`}return $}buildSelectQuery({withList:$,fields:T,fieldsFlat:W,where:w,having:X,table:U,joins:Y,orderBy:G,groupBy:H,limit:z,offset:F,lockingClause:O,distinct:Q,setOperators:Z}){let K=W??N1(T);for(let z$ of K)if(I(z$.field,p$)&&u4(z$.field.table)!==(I(U,M4)?U._.alias:I(U,VU)?U[t$].name:I(U,s)?void 0:u4(U))&&!((B$)=>Y?.some(({alias:e$})=>e$===(B$[o.Symbol.IsAlias]?u4(B$):B$[o.Symbol.BaseName])))(z$.field.table)){let B$=u4(z$.field.table);throw new Error(`Your "${z$.path.join("->")}" field references a column "${B$}"."${z$.field.name}", but the table "${B$}" is not part of the query! Did you forget to join it?`)}let E=!Y||Y.length===0,M=this.buildWithCTE($),L;if(Q)L=Q===!0?J` distinct`:J` distinct on (${J.join(Q.on,J`, `)})`;let R=this.buildSelection(K,{isSingleTable:E}),_=this.buildFromTable(U),S=this.buildJoins(Y),x=w?J` where ${w}`:void 0,b=X?J` having ${X}`:void 0,g;if(G&&G.length>0)g=J` order by ${J.join(G,J`, `)}`;let T$;if(H&&H.length>0)T$=J` group by ${J.join(H,J`, `)}`;let N$=typeof z==="object"||typeof z==="number"&&z>=0?J` limit ${z}`:void 0,j=F?J` offset ${F}`:void 0,U$=J.empty();if(O){let z$=J` for ${J.raw(O.strength)}`;if(O.config.of)z$.append(J` of ${J.join(Array.isArray(O.config.of)?O.config.of:[O.config.of],J`, `)}`);if(O.config.noWait)z$.append(J` nowait`);else if(O.config.skipLocked)z$.append(J` skip locked`);U$.append(z$)}let t=J`${M}select${L} ${R} from ${_}${S}${x}${T$}${b}${g}${N$}${j}${U$}`;if(Z.length>0)return this.buildSetOperations(t,Z);return t}buildSetOperations($,T){let[W,...w]=T;if(!W)throw new Error("Cannot pass undefined values to any set operator");if(w.length===0)return this.buildSetOperationQuery({leftSelect:$,setOperator:W});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:$,setOperator:W}),w)}buildSetOperationQuery({leftSelect:$,setOperator:{type:T,isAll:W,rightSelect:w,limit:X,orderBy:U,offset:Y}}){let G=J`(${$.getSQL()}) `,H=J`(${w.getSQL()})`,z;if(U&&U.length>0){let Z=[];for(let K of U)if(I(K,d))Z.push(J.identifier(K.name));else if(I(K,s)){for(let E=0;E<K.queryChunks.length;E++){let M=K.queryChunks[E];if(I(M,d))K.queryChunks[E]=J.identifier(M.name)}Z.push(J`${K}`)}else Z.push(J`${K}`);z=J` order by ${J.join(Z,J`, `)} `}let F=typeof X==="object"||typeof X==="number"&&X>=0?J` limit ${X}`:void 0,O=J.raw(`${T} ${W?"all ":""}`),Q=Y?J` offset ${Y}`:void 0;return J`${G}${O}${H}${z}${F}${Q}`}buildInsertQuery({table:$,values:T,onConflict:W,returning:w,withList:X,select:U,overridingSystemValue_:Y}){let G=[],H=$[o.Symbol.Columns],z=Object.entries(H).filter(([M,L])=>!L.shouldDisableInsert()),F=z.map(([,M])=>J.identifier(this.casing.getColumnCasing(M)));if(U){let M=T;if(I(M,s))G.push(M);else G.push(M.getSQL())}else{let M=T;G.push(J.raw("values "));for(let[L,R]of M.entries()){let _=[];for(let[S,x]of z){let b=R[S];if(b===void 0||I(b,F1)&&b.value===void 0)if(x.defaultFn!==void 0){let g=x.defaultFn(),T$=I(g,s)?g:J.param(g,x);_.push(T$)}else if(!x.default&&x.onUpdateFn!==void 0){let g=x.onUpdateFn(),T$=I(g,s)?g:J.param(g,x);_.push(T$)}else _.push(J`default`);else _.push(b)}if(G.push(_),L<M.length-1)G.push(J`, `)}}let O=this.buildWithCTE(X),Q=J.join(G),Z=w?J` returning ${this.buildSelection(w,{isSingleTable:!0})}`:void 0,K=W?J` on conflict ${W}`:void 0,E=Y===!0?J`overriding system value `:void 0;return J`${O}insert into ${$} ${F} ${E}${Q}${K}${Z}`}buildRefreshMaterializedViewQuery({view:$,concurrently:T,withNoData:W}){let w=T?J` concurrently`:void 0,X=W?J` with no data`:void 0;return J`refresh materialized view${w} ${$}${X}`}prepareTyping($){if(I($,_9)||I($,R9))return"json";else if(I($,k9))return"decimal";else if(I($,v9))return"time";else if(I($,q9)||I($,P9))return"timestamp";else if(I($,L9)||I($,J9))return"date";else if(I($,C9))return"uuid";else return"none"}sqlToQuery($,T){return $.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,prepareTyping:this.prepareTyping,invokeSource:T})}buildRelationalQueryWithoutPK({fullSchema:$,schema:T,tableNamesMap:W,table:w,tableConfig:X,queryConfig:U,tableAlias:Y,nestedQueryRelation:G,joinOn:H}){let z=[],F,O,Q=[],Z,K=[];if(U===!0)z=Object.entries(X.columns).map(([L,R])=>({dbKey:R.name,tsKey:L,field:Y0(R,Y),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let M=Object.fromEntries(Object.entries(X.columns).map(([b,g])=>[b,Y0(g,Y)]));if(U.where){let b=typeof U.where==="function"?U.where(M,HJ()):U.where;Z=b&&WU(b,Y)}let L=[],R=[];if(U.columns){let b=!1;for(let[g,T$]of Object.entries(U.columns)){if(T$===void 0)continue;if(g in X.columns){if(!b&&T$===!0)b=!0;R.push(g)}}if(R.length>0)R=b?R.filter((g)=>U.columns?.[g]===!0):Object.keys(X.columns).filter((g)=>!R.includes(g))}else R=Object.keys(X.columns);for(let b of R){let g=X.columns[b];L.push({tsKey:b,value:g})}let _=[];if(U.with)_=Object.entries(U.with).filter((b)=>!!b[1]).map(([b,g])=>({tsKey:b,queryConfig:g,relation:X.relations[b]}));let S;if(U.extras){S=typeof U.extras==="function"?U.extras(M,{sql:J}):U.extras;for(let[b,g]of Object.entries(S))L.push({tsKey:b,value:oO(g,Y)})}for(let{tsKey:b,value:g}of L)z.push({dbKey:I(g,s.Aliased)?g.fieldAlias:X.columns[b].name,tsKey:b,field:I(g,p$)?Y0(g,Y):g,relationTableTsKey:void 0,isJson:!1,selection:[]});let x=typeof U.orderBy==="function"?U.orderBy(M,FJ()):U.orderBy??[];if(!Array.isArray(x))x=[x];Q=x.map((b)=>{if(I(b,p$))return Y0(b,Y);return WU(b,Y)}),F=U.limit,O=U.offset;for(let{tsKey:b,queryConfig:g,relation:T$}of _){let N$=QJ(T,W,T$),j=kW(T$.referencedTable),U$=W[j],t=`${Y}_${b}`,z$=GU(...N$.fields.map((h4,n6)=>S9(Y0(N$.references[n6],t),Y0(h4,Y)))),B$=this.buildRelationalQueryWithoutPK({fullSchema:$,schema:T,tableNamesMap:W,table:$[U$],tableConfig:T[U$],queryConfig:I(T$,CT)?g===!0?{limit:1}:{...g,limit:1}:g,tableAlias:t,joinOn:z$,nestedQueryRelation:T$}),e$=J`${J.identifier(t)}.${J.identifier("data")}`.as(b);K.push({on:J`true`,table:new M4(B$.sql,{},t),alias:t,joinType:"left",lateral:!0}),z.push({dbKey:b,tsKey:b,field:e$,relationTableTsKey:U$,isJson:!0,selection:B$.selection})}}if(z.length===0)throw new D9({message:`No fields selected for table "${X.tsName}" ("${Y}")`});let E;if(Z=GU(H,Z),G){let M=J`json_build_array(${J.join(z.map(({field:_,tsKey:S,isJson:x})=>x?J`${J.identifier(`${Y}_${S}`)}.${J.identifier("data")}`:I(_,s.Aliased)?_.sql:_),J`, `)})`;if(I(G,zU))M=J`coalesce(json_agg(${M}${Q.length>0?J` order by ${J.join(Q,J`, `)}`:void 0}), '[]'::json)`;let L=[{dbKey:"data",tsKey:"data",field:M.as("data"),isJson:!0,relationTableTsKey:X.tsName,selection:z}];if(F!==void 0||O!==void 0||Q.length>0)E=this.buildSelectQuery({table:M9(w,Y),fields:{},fieldsFlat:[{path:[],field:J.raw("*")}],where:Z,limit:F,offset:O,orderBy:Q,setOperators:[]}),Z=void 0,F=void 0,O=void 0,Q=[];else E=M9(w,Y);E=this.buildSelectQuery({table:I(E,x4)?E:new M4(E,{},Y),fields:{},fieldsFlat:L.map(({field:_})=>({path:[],field:I(_,p$)?Y0(_,Y):_})),joins:K,where:Z,limit:F,offset:O,orderBy:Q,setOperators:[]})}else E=this.buildSelectQuery({table:M9(w,Y),fields:{},fieldsFlat:z.map(({field:M})=>({path:[],field:I(M,p$)?Y0(M,Y):M})),joins:K,where:Z,limit:F,offset:O,orderBy:Q,setOperators:[]});return{tableTsKey:X.tsName,sql:E,selection:z}}}class MQ{static[N]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class P6{static[N]="PgSelectBuilder";fields;session;dialect;withList=[];distinct;constructor($){if(this.fields=$.fields,this.session=$.session,this.dialect=$.dialect,$.withList)this.withList=$.withList;this.distinct=$.distinct}authToken;setToken($){return this.authToken=$,this}from($){let T=!!this.fields,W=$,w;if(this.fields)w=this.fields;else if(I(W,M4))w=Object.fromEntries(Object.keys(W._.selectedFields).map((X)=>[X,W[X]]));else if(I(W,VU))w=W[t$].selectedFields;else if(I(W,s))w={};else w=uD(W);return new DQ({table:W,fields:w,isPartialSelect:T,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class bJ extends MQ{static[N]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:$,fields:T,isPartialSelect:W,session:w,dialect:X,withList:U,distinct:Y}){super();this.config={withList:U,table:$,fields:{...T},distinct:Y,setOperators:[]},this.isPartialSelect=W,this.session=w,this.dialect=X,this._={selectedFields:T,config:this.config},this.tableName=y0($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let G of b1($))this.usedTables.add(G)}getUsedTables(){return[...this.usedTables]}createJoin($,T){return(W,w)=>{let X=this.tableName,U=y0(W);for(let Y of b1(W))this.usedTables.add(Y);if(typeof U==="string"&&this.config.joins?.some((Y)=>Y.alias===U))throw new Error(`Alias "${U}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof X==="string")this.config.fields={[X]:this.config.fields};if(typeof U==="string"&&!I(W,s)){let Y=I(W,M4)?W._.selectedFields:I(W,c6)?W[t$].selectedFields:W[o.Symbol.Columns];this.config.fields[U]=Y}}if(typeof w==="function")w=w(new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:w,table:W,joinType:$,alias:U,lateral:T}),typeof U==="string")switch($){case"left":{this.joinsNotNullableMap[U]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([Y])=>[Y,!1])),this.joinsNotNullableMap[U]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[U]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([Y])=>[Y,!1])),this.joinsNotNullableMap[U]=!1;break}}return this}}leftJoin=this.createJoin("left",!1);leftJoinLateral=this.createJoin("left",!0);rightJoin=this.createJoin("right",!1);innerJoin=this.createJoin("inner",!1);innerJoinLateral=this.createJoin("inner",!0);fullJoin=this.createJoin("full",!1);crossJoin=this.createJoin("cross",!1);crossJoinLateral=this.createJoin("cross",!0);createSetOperator($,T){return(W)=>{let w=typeof W==="function"?W(JB()):W;if(!XU(this.getSelectedFields(),w.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:$,isAll:T,rightSelect:w}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);intersectAll=this.createSetOperator("intersect",!0);except=this.createSetOperator("except",!1);exceptAll=this.createSetOperator("except",!0);addSetOperators($){return this.config.setOperators.push(...$),this}where($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=$,this}having($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=$,this}groupBy(...$){if(typeof $[0]==="function"){let T=$[0](new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(T)?T:[T]}else this.config.groupBy=$;return this}orderBy(...$){if(typeof $[0]==="function"){let T=$[0](new Proxy(this.config.fields,new E4({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),W=Array.isArray(T)?T:[T];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=W;else this.config.orderBy=W}else{let T=$;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=T;else this.config.orderBy=T}return this}limit($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=$;else this.config.limit=$;return this}offset($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=$;else this.config.offset=$;return this}for($,T={}){return this.config.lockingClause={strength:$,config:T},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}as($){let T=[];if(T.push(...b1(this.config.table)),this.config.joins)for(let W of this.config.joins)T.push(...b1(W.table));return new Proxy(new M4(this.getSQL(),this.config.fields,$,!1,[...new Set(T)]),new E4({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new E4({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}$withCache($){return this.cacheConfig=$===void 0?{config:{},enable:!0,autoInvalidate:!0}:$===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...$},this}}class DQ extends bJ{static[N]="PgSelect";_prepare($){let{session:T,config:W,dialect:w,joinsNotNullableMap:X,authToken:U,cacheConfig:Y,usedTables:G}=this;if(!T)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");let{fields:H}=W;return d$.startActiveSpan("drizzle.prepareQuery",()=>{let z=N1(H),F=T.prepareQuery(w.sqlToQuery(this.getSQL()),z,$,!0,void 0,{type:"select",tables:[...G]},Y);return F.joinsNotNullableMap=X,F.setToken(U)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return d$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}cD(DQ,[q6]);function i2($,T){return(W,w,...X)=>{let U=[w,...X].map((Y)=>({type:$,isAll:T,rightSelect:Y}));for(let Y of U)if(!XU(W.getSelectedFields(),Y.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return W.addSetOperators(U)}}var JB=()=>({union:RB,unionAll:_B,intersect:kB,intersectAll:vB,except:qB,exceptAll:PB}),RB=i2("union",!1),_B=i2("union",!0),kB=i2("intersect",!1),vB=i2("intersect",!0),qB=i2("except",!1),PB=i2("except",!0);class KU{static[N]="PgQueryBuilder";dialect;dialectConfig;constructor($){this.dialect=I($,SW)?$:void 0,this.dialectConfig=I($,SW)?void 0:$}$with=($,T)=>{let W=this;return{as:(X)=>{if(typeof X==="function")X=X(W);return new Proxy(new ew(X.getSQL(),T??("getSelectedFields"in X?X.getSelectedFields()??{}:{}),$,!0),new E4({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...$){let T=this;function W(U){return new P6({fields:U??void 0,session:void 0,dialect:T.getDialect(),withList:$})}function w(U){return new P6({fields:U??void 0,session:void 0,dialect:T.getDialect(),distinct:!0})}function X(U,Y){return new P6({fields:Y??void 0,session:void 0,dialect:T.getDialect(),distinct:{on:U}})}return{select:W,selectDistinct:w,selectDistinctOn:X}}select($){return new P6({fields:$??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct($){return new P6({fields:$??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn($,T){return new P6({fields:T??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:$}})}getDialect(){if(!this.dialect)this.dialect=new SW(this.dialectConfig);return this.dialect}}function b1($){if(I($,x4))return[$[_W]?`${$[_W]}.${$[o.Symbol.BaseName]}`:$[o.Symbol.BaseName]];if(I($,M4))return $._.usedTables??[];if(I($,s))return $.usedTables??[];return[]}class o9 extends q6{constructor($,T,W,w){super();this.session=T,this.dialect=W,this.config={table:$,withList:w}}static[N]="PgDelete";config;cacheConfig;where($){return this.config.where=$,this}returning($=this.config.table[o.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=N1($),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return d$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0,void 0,{type:"delete",tables:b1(this.config.table)},this.cacheConfig)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return d$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new E4({alias:u4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class l9{constructor($,T,W,w,X){this.table=$,this.session=T,this.dialect=W,this.withList=w,this.overridingSystemValue_=X}static[N]="PgInsertBuilder";authToken;setToken($){return this.authToken=$,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values($){if($=Array.isArray($)?$:[$],$.length===0)throw new Error("values() must be called with at least one value");let T=$.map((W)=>{let w={},X=this.table[o.Symbol.Columns];for(let U of Object.keys(W)){let Y=W[U];w[U]=I(Y,s)?Y:new F1(Y,X[U])}return w});return new NQ(this.table,T,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select($){let T=typeof $==="function"?$(new KU):$;if(!I(T,s)&&!XU(this.table[A9],T._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new NQ(this.table,T,this.session,this.dialect,this.withList,!0)}}class NQ extends q6{constructor($,T,W,w,X,U,Y){super();this.session=W,this.dialect=w,this.config={table:$,values:T,withList:X,select:U,overridingSystemValue_:Y}}static[N]="PgInsert";config;cacheConfig;returning($=this.config.table[o.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=N1($),this}onConflictDoNothing($={}){if($.target===void 0)this.config.onConflict=J`do nothing`;else{let T="";T=Array.isArray($.target)?$.target.map((w)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(w))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target));let W=$.where?J` where ${$.where}`:void 0;this.config.onConflict=J`(${J.raw(T)})${W} do nothing`}return this}onConflictDoUpdate($){if($.where&&($.targetWhere||$.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');let T=$.where?J` where ${$.where}`:void 0,W=$.targetWhere?J` where ${$.targetWhere}`:void 0,w=$.setWhere?J` where ${$.setWhere}`:void 0,X=this.dialect.buildUpdateSet(this.config.table,N9(this.config.table,$.set)),U="";return U=Array.isArray($.target)?$.target.map((Y)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(Y))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target)),this.config.onConflict=J`(${J.raw(U)})${W} do update set ${X}${T}${w}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return d$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0,void 0,{type:"insert",tables:b1(this.config.table)},this.cacheConfig)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return d$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new E4({alias:u4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class LQ extends q6{constructor($,T,W){super();this.session=T,this.dialect=W,this.config={view:$}}static[N]="PgRefreshMaterializedView";config;concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return d$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return d$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}class r9{constructor($,T,W,w){this.table=$,this.session=T,this.dialect=W,this.withList=w}static[N]="PgUpdateBuilder";authToken;setToken($){return this.authToken=$,this}set($){return new yJ(this.table,N9(this.table,$),this.session,this.dialect,this.withList).setToken(this.authToken)}}class yJ extends q6{constructor($,T,W,w,X){super();this.session=W,this.dialect=w,this.config={set:T,table:$,withList:X,joins:[]},this.tableName=y0($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[N]="PgUpdate";config;tableName;joinsNotNullableMap;cacheConfig;from($){let T=$,W=y0(T);if(typeof W==="string")this.joinsNotNullableMap[W]=!0;return this.config.from=T,this}getTableLikeFields($){if(I($,x4))return $[o.Symbol.Columns];else if(I($,M4))return $._.selectedFields;return $[t$].selectedFields}createJoin($){return(T,W)=>{let w=y0(T);if(typeof w==="string"&&this.config.joins.some((X)=>X.alias===w))throw new Error(`Alias "${w}" is already used in this query`);if(typeof W==="function"){let X=this.config.from&&!I(this.config.from,s)?this.getTableLikeFields(this.config.from):void 0;W=W(new Proxy(this.config.table[o.Symbol.Columns],new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),X&&new Proxy(X,new E4({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:W,table:T,joinType:$,alias:w}),typeof w==="string")switch($){case"left":{this.joinsNotNullableMap[w]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([X])=>[X,!1])),this.joinsNotNullableMap[w]=!0;break}case"inner":{this.joinsNotNullableMap[w]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([X])=>[X,!1])),this.joinsNotNullableMap[w]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where($){return this.config.where=$,this}returning($){if(!$){if($=Object.assign({},this.config.table[o.Symbol.Columns]),this.config.from){let T=y0(this.config.from);if(typeof T==="string"&&this.config.from&&!I(this.config.from,s)){let W=this.getTableLikeFields(this.config.from);$[T]=W}for(let W of this.config.joins){let w=y0(W.table);if(typeof w==="string"&&!I(W.table,s)){let X=this.getTableLikeFields(W.table);$[w]=X}}}}return this.config.returningFields=$,this.config.returning=N1($),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){let T=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0,void 0,{type:"insert",tables:b1(this.config.table)},this.cacheConfig);return T.joinsNotNullableMap=this.joinsNotNullableMap,T}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return this._prepare().execute($,this.authToken)};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new E4({alias:u4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class AU extends s{constructor($){super(AU.buildEmbeddedCount($.source,$.filters).queryChunks);this.params=$,this.mapWith(Number),this.session=$.session,this.sql=AU.buildCount($.source,$.filters)}sql;token;static[N]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount($,T){return J`(select count(*) from ${$}${J.raw(" where ").if(T)}${T})`}static buildCount($,T){return J`select count(*) as count from ${$}${J.raw(" where ").if(T)}${T};`}setToken($){return this.token=$,this}then($,T){return Promise.resolve(this.session.count(this.sql,this.token)).then($,T)}catch($){return this.then(void 0,$)}finally($){return this.then((T)=>{return $?.(),T},(T)=>{throw $?.(),T})}}class RQ{constructor($,T,W,w,X,U,Y){this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=w,this.tableConfig=X,this.dialect=U,this.session=Y}static[N]="PgRelationalQueryBuilder";findMany($){return new JQ(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?$:{},"many")}findFirst($){return new JQ(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?{...$,limit:1}:{limit:1},"first")}}class JQ extends q6{constructor($,T,W,w,X,U,Y,G,H){super();this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=w,this.tableConfig=X,this.dialect=U,this.session=Y,this.config=G,this.mode=H}static[N]="PgRelationalQuery";_prepare($){return d$.startActiveSpan("drizzle.prepareQuery",()=>{let{query:T,builtQuery:W}=this._toSQL();return this.session.prepareQuery(W,void 0,$,!0,(w,X)=>{let U=w.map((Y)=>I9(this.schema,this.tableConfig,Y,T.selection,X));if(this.mode==="first")return U[0];return U})})}prepare($){return this._prepare($)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let $=this._getQuery(),T=this.dialect.sqlToQuery($.sql);return{query:$,builtQuery:T}}toSQL(){return this._toSQL().builtQuery}authToken;setToken($){return this.authToken=$,this}execute(){return d$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class _Q extends q6{constructor($,T,W,w){super();this.execute=$,this.sql=T,this.query=W,this.mapBatchResult=w}static[N]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult($,T){return T?this.mapBatchResult($):$}_prepare(){return this}isResponseInArrayMode(){return!1}}class EU{constructor($,T,W){if(this.dialect=$,this.session=T,this._=W?{schema:W.schema,fullSchema:W.fullSchema,tableNamesMap:W.tableNamesMap,session:T}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:T},this.query={},this._.schema)for(let[w,X]of Object.entries(this._.schema))this.query[w]=new RQ(W.fullSchema,this._.schema,this._.tableNamesMap,W.fullSchema[w],X,$,T);this.$cache={invalidate:async(w)=>{}}}static[N]="PgDatabase";query;$with=($,T)=>{let W=this;return{as:(X)=>{if(typeof X==="function")X=X(new KU(W.dialect));return new Proxy(new ew(X.getSQL(),T??("getSelectedFields"in X?X.getSelectedFields()??{}:{}),$,!0),new E4({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count($,T){return new AU({source:$,filters:T,session:this.session})}$cache;with(...$){let T=this;function W(H){return new P6({fields:H??void 0,session:T.session,dialect:T.dialect,withList:$})}function w(H){return new P6({fields:H??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:!0})}function X(H,z){return new P6({fields:z??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:{on:H}})}function U(H){return new r9(H,T.session,T.dialect,$)}function Y(H){return new l9(H,T.session,T.dialect,$)}function G(H){return new o9(H,T.session,T.dialect,$)}return{select:W,selectDistinct:w,selectDistinctOn:X,update:U,insert:Y,delete:G}}select($){return new P6({fields:$??void 0,session:this.session,dialect:this.dialect})}selectDistinct($){return new P6({fields:$??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn($,T){return new P6({fields:T??void 0,session:this.session,dialect:this.dialect,distinct:{on:$}})}update($){return new r9($,this.session,this.dialect)}insert($){return new l9($,this.session,this.dialect)}delete($){return new o9($,this.session,this.dialect)}refreshMaterializedView($){return new LQ($,this.session,this.dialect)}authToken;execute($){let T=typeof $==="string"?J.raw($):$.getSQL(),W=this.dialect.sqlToQuery(T),w=this.session.prepareQuery(W,void 0,void 0,!1);return new _Q(()=>w.execute(void 0,this.authToken),T,W,(X)=>w.mapResult(X,!0))}transaction($,T){return this.session.transaction($,T)}}class hJ{static[N]="Cache"}class MU extends hJ{strategy(){return"all"}static[N]="NoopCache";async get($){return}async put($,T,W,w){}async onMutate($){}}async function kQ($,T){let W=`${$}-${JSON.stringify(T)}`,X=new TextEncoder().encode(W),U=await crypto.subtle.digest("SHA-256",X);return[...new Uint8Array(U)].map((H)=>H.toString(16).padStart(2,"0")).join("")}class g0 extends Error{constructor($,T,W){super(`Failed query: ${$}
110
+ params: ${T}`);if(this.query=$,this.params=T,this.cause=W,Error.captureStackTrace(this,g0),W)this.cause=W}}class vQ{constructor($,T,W,w){if(this.query=$,this.cache=T,this.queryMetadata=W,this.cacheConfig=w,T&&T.strategy()==="all"&&w===void 0)this.cacheConfig={enable:!0,autoInvalidate:!0};if(!this.cacheConfig?.enable)this.cacheConfig=void 0}authToken;getQuery(){return this.query}mapResult($,T){return $}setToken($){return this.authToken=$,this}static[N]="PgPreparedQuery";joinsNotNullableMap;async queryWithCache($,T,W){if(this.cache===void 0||I(this.cache,MU)||this.queryMetadata===void 0)try{return await W()}catch(w){throw new g0($,T,w)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await W()}catch(w){throw new g0($,T,w)}if((this.queryMetadata.type==="insert"||this.queryMetadata.type==="update"||this.queryMetadata.type==="delete")&&this.queryMetadata.tables.length>0)try{let[w]=await Promise.all([W(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return w}catch(w){throw new g0($,T,w)}if(!this.cacheConfig)try{return await W()}catch(w){throw new g0($,T,w)}if(this.queryMetadata.type==="select"){let w=await this.cache.get(this.cacheConfig.tag??await kQ($,T),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(w===void 0){let X;try{X=await W()}catch(U){throw new g0($,T,U)}return await this.cache.put(this.cacheConfig.tag??await kQ($,T),X,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),X}return w}try{return await W()}catch(w){throw new g0($,T,w)}}}class qQ{constructor($){this.dialect=$}static[N]="PgSession";execute($,T){return d$.startActiveSpan("drizzle.operation",()=>{return d$.startActiveSpan("drizzle.prepareQuery",()=>{return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1)}).setToken(T).execute(void 0,T)})}all($){return this.prepareQuery(this.dialect.sqlToQuery($),void 0,void 0,!1).all()}async count($,T){let W=await this.execute($,T);return Number(W[0].count)}}class PQ extends EU{constructor($,T,W,w=0){super($,T,W);this.schema=W,this.nestedIndex=w}static[N]="PgTransaction";rollback(){throw new lO}getTransactionConfigSQL($){let T=[];if($.isolationLevel)T.push(`isolation level ${$.isolationLevel}`);if($.accessMode)T.push($.accessMode);if(typeof $.deferrable==="boolean")T.push($.deferrable?"deferrable":"not deferrable");return J.raw(T.join(" "))}setTransaction($){return this.session.execute(J`set transaction ${this.getTransactionConfigSQL($)}`)}}class gJ extends vQ{constructor($,T,W,w,X,U,Y,G,H,z){super({sql:T,params:W},X,U,Y);this.client=$,this.queryString=T,this.params=W,this.logger=w,this.fields=G,this._isResponseInArrayMode=H,this.customResultMapper=z}static[N]="PostgresJsPreparedQuery";async execute($={}){return d$.startActiveSpan("drizzle.execute",async(T)=>{let W=dO(this.params,$);T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W);let{fields:w,queryString:X,client:U,joinsNotNullableMap:Y,customResultMapper:G}=this;if(!w&&!G)return d$.startActiveSpan("drizzle.driver.execute",()=>{return this.queryWithCache(X,W,async()=>{return await U.unsafe(X,W)})});let H=await d$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":X,"drizzle.query.params":JSON.stringify(W)}),this.queryWithCache(X,W,async()=>{return await U.unsafe(X,W).values()})});return d$.startActiveSpan("drizzle.mapResponse",()=>{return G?G(H):H.map((z)=>mD(w,z,Y))})})}all($={}){return d$.startActiveSpan("drizzle.execute",async(T)=>{let W=dO(this.params,$);return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W),d$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.queryWithCache(this.queryString,W,async()=>{return this.client.unsafe(this.queryString,W)})})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class DU extends qQ{constructor($,T,W,w={}){super(T);this.client=$,this.schema=W,this.options=w,this.logger=w.logger??new nO,this.cache=w.cache??new MU}static[N]="PostgresJsSession";logger;cache;prepareQuery($,T,W,w,X,U,Y){return new gJ(this.client,$.sql,$.params,this.logger,this.cache,U,Y,T,w,X)}query($,T){return this.logger.logQuery($,T),this.client.unsafe($,T).values()}queryObjects($,T){return this.client.unsafe($,T)}transaction($,T){return this.client.begin(async(W)=>{let w=new DU(W,this.dialect,this.schema,this.options),X=new CQ(this.dialect,w,this.schema);if(T)await X.setTransaction(T);return $(X)})}}class CQ extends PQ{constructor($,T,W,w=0){super($,T,W,w);this.session=T}static[N]="PostgresJsTransaction";transaction($){return this.session.client.savepoint((T)=>{let W=new DU(T,this.dialect,this.schema,this.session.options),w=new CQ(this.dialect,W,this.schema);return $(w)})}}class mJ extends EU{static[N]="PostgresJsDatabase"}function t2($,T={}){let W=(H)=>H;for(let H of["1184","1082","1083","1114","1182","1185","1115","1231"])$.options.parsers[H]=W,$.options.serializers[H]=W;$.options.serializers["114"]=W,$.options.serializers["3802"]=W;let w=new SW({casing:T.casing}),X;if(T.logger===!0)X=new rO;else if(T.logger!==!1)X=T.logger;let U;if(T.schema){let H=OJ(T.schema,ZJ);U={fullSchema:T.schema,schema:H.tables,tableNamesMap:H.tableNamesMap}}let Y=new DU($,w,U,{logger:X,cache:T.cache}),G=new mJ(w,Y,U);if(G.$client=$,G.$cache=T.cache,G.$cache)G.$cache.invalidate=T.cache?.onMutate;return G}function n9(...$){if(typeof $[0]==="string"){let T=n2($[0]);return t2(T,$[1])}if(pD($[0])){let{connection:T,client:W,...w}=$[0];if(W)return t2(W,w);if(typeof T==="object"&&T.url!==void 0){let{url:U,...Y}=T,G=n2(U,Y);return t2(G,w)}let X=n2(T);return t2(X,w)}return t2($[0],$[1])}(($)=>{function T(W){return t2({options:{parsers:{},serializers:{}}},W)}$.mock=T})(n9||(n9={}));function cJ($,T){if($ instanceof Promise)throw new Error(T)}function CB($,T){let W={},w=[];for(let X in $){let U=$[X]["~standard"].validate(T[X]);if(cJ(U,`Validation must be synchronous, but ${X} returned a Promise.`),U.issues){w.push(...U.issues.map((Y)=>({...Y,message:Y.message,path:[X,...Y.path??[]]})));continue}W[X]=U.value}if(w.length)return{issues:w};return{value:W}}function SQ($){let T=$.runtimeEnvStrict??$.runtimeEnv??process.env;if($.emptyStringAsUndefined??!1){for(let[R,_]of Object.entries(T))if(_==="")delete T[R]}if(!!$.skipValidation)return T;let X=typeof $.client==="object"?$.client:{},U=typeof $.server==="object"?$.server:{},Y=typeof $.shared==="object"?$.shared:{},G=$.isServer??(typeof window==="undefined"||("Deno"in window)),H=G?{...U,...Y,...X}:{...X,...Y},z=$.createFinalSchema?.(H,G)["~standard"].validate(T)??CB(H,T);cJ(z,"Validation must be synchronous");let F=$.onValidationError??((R)=>{throw console.error("\u274C Invalid environment variables:",R),new Error("Invalid environment variables")}),O=$.onInvalidAccess??(()=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")});if(z.issues)return F(z.issues);let Q=(R)=>{if(!$.clientPrefix)return!0;return!R.startsWith($.clientPrefix)&&!(R in Y)},Z=(R)=>{return G||!Q(R)},K=(R)=>{return R==="__esModule"||R==="$$typeof"},E=($.extends??[]).reduce((R,_)=>{return Object.assign(R,_)},{}),M=Object.assign(E,z.value);return new Proxy(M,{get(R,_){if(typeof _!=="string")return;if(K(_))return;if(!Z(_))return O(_);return Reflect.get(R,_)}})}var jT=($)=>Array.isArray($)?$:[$],uJ=($,T)=>{let W=[[],[]];for(let w of $)if(T(w))W[0].push(w);else W[1].push(w);return W},i9=Array,m0=($,T)=>$.includes(T),pJ=($,T=0)=>[...new Array($)].map((W,w)=>w+T),C$=($,T,W)=>{if($===void 0)return T===void 0?[]:Array.isArray(T)?T:[T];if(W?.prepend)if(Array.isArray(T))$.unshift(...T);else $.unshift(T);else if(Array.isArray(T))$.push(...T);else $.push(T);return $},c0=($,T)=>{if(T===void 0||T===null)return $??[];if($===void 0||$===null)return jT(T);return $.concat(T)},dJ=(...$)=>$.reduce(c0,[]),z0=($,T,W)=>{if($===void 0)return Array.isArray(T)?T:[T];let w=W?.isEqual??((X,U)=>X===U);for(let X of jT(T))if(!$.some((U)=>w(U,X)))$.push(X);return $},oJ=($,T)=>$.reduce((W,w)=>{let X=w[T];return W[X]=C$(W[X],w),W},{}),u0=($,T,W)=>$.length===T.length&&$.every(W?.isEqual?(w,X)=>W.isEqual(w,T[X]):(w,X)=>w===T[X]);var p6=($,T)=>f4($)===T,f4=($)=>{let T=typeof $;return T==="object"?$===null?"null":"object":T==="function"?"object":T},d6={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},lJ={...d6,function:"a function"};class rJ extends Error{}var I$=($)=>jW($,rJ),jW=($,T=Error)=>{throw new T($)};class NU extends Error{name="ParseError"}var B=($)=>jW($,NU),y1=($)=>` ${$}`;var E$=($,T)=>{let W={},w=Array.isArray($),X=!1;for(let[U,Y]of Object.entries($).entries()){let G=w?T(U,Y[1]):T(...Y,U);X||=typeof G[0]==="number";let H=Array.isArray(G[0])||G.length===0?G:[G];for(let[z,F]of H)if(typeof z==="object")W[z.group]=C$(W[z.group],F);else W[z]=F}return X?Object.values(W):W};var jQ=Object.entries;var b4=($,T)=>($ in T),a2=($,T)=>(T in $);class IQ{constructor($){Object.assign(this,$)}}var nJ=class{};class LU extends nJ{}var SB=($,T)=>{let W={},w={},X;for(X in $)if(X in T)W[X]=$[X];else w[X]=$[X];return[W,w]};var iJ=($,T)=>SB($,T)[1],H0=($)=>Object.keys($).length===0,IW=($)=>[...Object.entries($),...Object.getOwnPropertySymbols($).map((T)=>[T,$[T]])],tJ=($,T)=>Object.defineProperties($,Object.getOwnPropertyDescriptors(T)),aJ=($)=>{let T=Object.keys($).sort(),W={};for(let w=0;w<T.length;w++)W[T[w]]=$[T[w]];return W};var Q1=y1("represents an uninitialized value"),sJ=($)=>Object.values($).filter((T)=>{if(typeof T==="number")return!0;return typeof $[T]!=="number"});var BQ={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},xQ=globalThis.File??Blob,fQ={ArrayBuffer,Blob,File:xQ,FormData,Headers,Request,Response,URL},jB={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},BW={...BQ,...fQ,...jB,String,Number,Boolean},JU=($)=>{let T=Object.getPrototypeOf($);while(T?.constructor&&(!b4(T.constructor.name,BW)||!($ instanceof BW[T.constructor.name])))T=Object.getPrototypeOf(T);let W=T?.constructor?.name;if(W===void 0||W==="Object")return;return W},RU=($)=>typeof $==="object"&&$!==null?JU($)??"object":f4($);var o$=Array.isArray,IB={Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},BB={ArrayBuffer:"an ArrayBuffer instance",Blob:"a Blob instance",File:"a File instance",FormData:"a FormData instance",Headers:"a Headers instance",Request:"a Request instance",Response:"a Response instance",URL:"a URL instance"},xB={Int8Array:"an Int8Array",Uint8Array:"a Uint8Array",Uint8ClampedArray:"a Uint8ClampedArray",Int16Array:"an Int16Array",Uint16Array:"a Uint16Array",Int32Array:"an Int32Array",Uint32Array:"a Uint32Array",Float32Array:"a Float32Array",Float64Array:"a Float64Array",BigInt64Array:"a BigInt64Array",BigUint64Array:"a BigUint64Array"},eJ={...IB,...BB,...xB},_U=($)=>{let T=Object($).name??null;return T&&b4(T,BW)&&BW[T]===$?T:null};var bQ=($,T)=>{let W=$.prototype;while(W!==null){if(W===T.prototype)return!0;W=Object.getPrototypeOf(W)}return!1};var $R=($)=>TR($,new Map),TR=($,T)=>{if(typeof $!=="object"||$===null)return $;if(T?.has($))return T.get($);let W=_U($.constructor);if(W==="Date")return new Date($.getTime());if(W&&W!=="Array")return $;let w=Array.isArray($)?$.slice():Object.create(Object.getPrototypeOf($)),X=Object.getOwnPropertyDescriptors($);if(T){T.set($,w);for(let U in X){let Y=X[U];if("get"in Y||"set"in Y)continue;Y.value=TR(Y.value,T)}}return Object.defineProperties(w,X),w};var fB=($)=>{let T=Q1;return()=>T===Q1?T=$():T},IT=($)=>typeof $==="function"&&$.length===0;var WR=class extends Function{constructor(...$){let T=$.slice(0,-1),W=$.at(-1);try{super(...T,W)}catch(w){return I$(`Encountered an unexpected error while compiling your definition:
111
+ Message: ${w}
110
112
  Source: (${$.slice(0,-1)}) => {
111
113
  ${$.at(-1)}
112
- }`)}}};class B6{constructor($,...[T]){return Object.assign(Object.setPrototypeOf($.bind(T?.bind??this),this.constructor.prototype),T?.attach)}}var MV=Lv(()=>{try{return new Function("return false")()}catch{return!0}});var rs=S6("brand");var NV=S6("arkInferred");var ts=S6("args");class L4{constructor(){}}var Sv=()=>{try{return((new Error().stack?.split(`
113
- `)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},Bv=globalThis.process?.env??{},LV={fileName:Sv,env:Bv};var SV=($)=>$[0].toUpperCase()+$.slice(1);var V7=($)=>new RegExp(Rv($),typeof $==="string"?"":$.flags);var Rv=($)=>{return`^(?:${typeof $==="string"?$:$.source})$`};var F1={negativeLookahead:($)=>`(?!${$})`,nonCapturingGroup:($)=>`(?:${$})`},OU="\\",o1={" ":1,"\n":1,"\t":1};var Iv=/^-0\.?0*$/.source,RV=/[1-9]\d*/.source,kv=/\.\d+/.source,vv=/\.\d*[1-9]/.source,IV=($)=>V7(F1.negativeLookahead(Iv)+F1.nonCapturingGroup("-?"+F1.nonCapturingGroup(F1.nonCapturingGroup("0|"+RV)+F1.nonCapturingGroup($.decimalPattern)+"?")+($.allowDecimalOnly?"|"+$.decimalPattern:"")+"?")),BV=IV({decimalPattern:vv,allowDecimalOnly:!1}),qv=BV.test.bind(BV),F8=IV({decimalPattern:kv,allowDecimalOnly:!0}),Ue=F8.test.bind(F8),Pv=/^-?\d*\.?\d*$/,Cv=($)=>$.length!==0&&Pv.test($),DU=V7(F1.negativeLookahead("^-0$")+"-?"+F1.nonCapturingGroup(F1.nonCapturingGroup("0|"+RV))),jv=DU.test.bind(DU),K7=/^-?\d+$/,xv=K7.test.bind(K7),kV={number:"a number",bigint:"a bigint",integer:"an integer"},vV=($,T)=>`'${$}' was parsed as ${kV[T]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,bv=($,T)=>T==="number"?qv($):jv($),fv=($,T)=>T==="number"?Number($):Number.parseInt($),yv=($,T)=>T==="number"?Cv($):xv($),qV=($,T)=>E7($,"number",T),PV=($,T)=>E7($,"number",{...T,strict:!0}),CV=($,T)=>E7($,"integer",T),E7=($,T,W)=>{let U=fv($,T);if(!Number.isNaN(U)){if(yv($,T)){if(W?.strict)return bv($,T)?U:S(vV($,T));return U}}return W?.errorOnFail?S(W?.errorOnFail===!0?`Failed to parse ${kV[T]} from '${$}'`:W?.errorOnFail):void 0},jV=($)=>{if($[$.length-1]!=="n")return;let T=$.slice(0,-1),W;try{W=BigInt(T)}catch{return}if(DU.test(T))return W;if(K7.test(T))return S(vV($,"bigint"))};var hv="0.46.0",gv={version:hv,filename:LV.fileName(),FileConstructor:D7},h0=gv,xV=new Map,A7=Object.create(null),QU=($)=>{let T=xV.get($);if(T)return T;let W=mv($);if(A7[W])W=`${W}${A7[W]++}`;else A7[W]=1;return h0[W]=$,xV.set($,W),W},d1=($)=>/^[$A-Z_a-z][\w$]*$/.test($),mv=($)=>{switch(typeof $){case"object":{if($===null)break;let T=zU($)??"object";return T[0].toLowerCase()+T.slice(1)}case"function":return d1($.name)?$.name:"fn";case"symbol":return $.description&&d1($.description)?$.description:"symbol"}return Z$(`Unexpected attempt to register serializable value of type ${G4($)}`)};var ZU=($)=>typeof $==="string"?JSON.stringify($):typeof $==="bigint"?`${$}n`:`${$}`;var bV=($,T={})=>VU($,{onUndefined:"$ark.undefined",onBigInt:(W)=>`$ark.bigint-${W}`,...T},[]);var Y$=($,T)=>{switch(G4($)){case"object":let W=$,U=W.constructor.name;return U==="Object"||U==="Array"?T?.quoteKeys===!1?O8(W,T?.indent??0,""):JSON.stringify(VU(W,yT,[]),null,T?.indent):O8(W,T?.indent??0,"");case"symbol":return yT.onSymbol($);default:return ZU($)}},O8=($,T,W)=>{if(typeof $==="function")return yT.onFunction($);if(typeof $!=="object"||$===null)return ZU($);let U=W+" ".repeat(T);if(Array.isArray($)){if($.length===0)return"[]";let Y=$.map((_)=>O8(_,T,U)).join(`,
114
- `+U);return T?`[
115
- ${U}${Y}
116
- ${W}]`:`[${Y}]`}let X=$.constructor.name;if(X==="Object"){let Y=f0($).map(([_,w])=>{let G=typeof _==="symbol"?yT.onSymbol(_):d1(_)?_:JSON.stringify(_),J=O8(w,T,U);return`${U}${G}: ${J}`});if(Y.length===0)return"{}";return T?`{
117
- ${Y.join(`,
114
+ }`)}}};class h1{constructor($,...[T]){return Object.assign(Object.setPrototypeOf($.bind(T?.bind??this),this.constructor.prototype),T?.attach)}}var XR=fB(()=>{try{return new Function("return false")()}catch{return!0}});var $T$=y1("brand");var wR=y1("arkInferred");var XT$=y1("args");class w6{constructor(){}}var bB=()=>{try{return((new Error().stack?.split(`
115
+ `)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},yB=globalThis.process?.env??{},UR={fileName:bB,env:yB};var YR=($)=>$[0].toUpperCase()+$.slice(1);var yQ=($)=>new RegExp(hB($),typeof $==="string"?"":$.flags);var hB=($)=>{return`^(?:${typeof $==="string"?$:$.source})$`};var p0={negativeLookahead:($)=>`(?!${$})`,nonCapturingGroup:($)=>`(?:${$})`},kU="\\",BT={" ":1,"\n":1,"\t":1};var gB=/^-0\.?0*$/.source,zR=/[1-9]\d*/.source,mB=/\.\d+/.source,cB=/\.\d*[1-9]/.source,HR=($)=>yQ(p0.negativeLookahead(gB)+p0.nonCapturingGroup("-?"+p0.nonCapturingGroup(p0.nonCapturingGroup("0|"+zR)+p0.nonCapturingGroup($.decimalPattern)+"?")+($.allowDecimalOnly?"|"+$.decimalPattern:"")+"?")),GR=HR({decimalPattern:cB,allowDecimalOnly:!1}),uB=GR.test.bind(GR),t9=HR({decimalPattern:mB,allowDecimalOnly:!0}),FT$=t9.test.bind(t9),pB=/^-?\d*\.?\d*$/,dB=($)=>$.length!==0&&pB.test($),vU=yQ(p0.negativeLookahead("^-0$")+"-?"+p0.nonCapturingGroup(p0.nonCapturingGroup("0|"+zR))),oB=vU.test.bind(vU),hQ=/^-?\d+$/,lB=hQ.test.bind(hQ),FR={number:"a number",bigint:"a bigint",integer:"an integer"},OR=($,T)=>`'${$}' was parsed as ${FR[T]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,rB=($,T)=>T==="number"?uB($):oB($),nB=($,T)=>T==="number"?Number($):Number.parseInt($),iB=($,T)=>T==="number"?dB($):lB($),QR=($,T)=>gQ($,"number",T),ZR=($,T)=>gQ($,"number",{...T,strict:!0}),VR=($,T)=>gQ($,"integer",T),gQ=($,T,W)=>{let w=nB($,T);if(!Number.isNaN(w)){if(iB($,T)){if(W?.strict)return rB($,T)?w:B(OR($,T));return w}}return W?.errorOnFail?B(W?.errorOnFail===!0?`Failed to parse ${FR[T]} from '${$}'`:W?.errorOnFail):void 0},KR=($)=>{if($[$.length-1]!=="n")return;let T=$.slice(0,-1),W;try{W=BigInt(T)}catch{return}if(vU.test(T))return W;if(hQ.test(T))return B(OR($,"bigint"))};var tB="0.46.0",aB={version:tB,filename:UR.fileName(),FileConstructor:xQ},xW=aB,AR=new Map,mQ=Object.create(null),qU=($)=>{let T=AR.get($);if(T)return T;let W=sB($);if(mQ[W])W=`${W}${mQ[W]++}`;else mQ[W]=1;return xW[W]=$,AR.set($,W),W},xT=($)=>/^[$A-Z_a-z][\w$]*$/.test($),sB=($)=>{switch(typeof $){case"object":{if($===null)break;let T=JU($)??"object";return T[0].toLowerCase()+T.slice(1)}case"function":return xT($.name)?$.name:"fn";case"symbol":return $.description&&xT($.description)?$.description:"symbol"}return I$(`Unexpected attempt to register serializable value of type ${f4($)}`)};var PU=($)=>typeof $==="string"?JSON.stringify($):typeof $==="bigint"?`${$}n`:`${$}`;var ER=($,T={})=>CU($,{onUndefined:"$ark.undefined",onBigInt:(W)=>`$ark.bigint-${W}`,...T},[]);var M$=($,T)=>{switch(f4($)){case"object":let W=$,w=W.constructor.name;return w==="Object"||w==="Array"?T?.quoteKeys===!1?a9(W,T?.indent??0,""):JSON.stringify(CU(W,s2,[]),null,T?.indent):a9(W,T?.indent??0,"");case"symbol":return s2.onSymbol($);default:return PU($)}},a9=($,T,W)=>{if(typeof $==="function")return s2.onFunction($);if(typeof $!=="object"||$===null)return PU($);let w=W+" ".repeat(T);if(Array.isArray($)){if($.length===0)return"[]";let U=$.map((Y)=>a9(Y,T,w)).join(`,
116
+ `+w);return T?`[
117
+ ${w}${U}
118
+ ${W}]`:`[${U}]`}let X=$.constructor.name;if(X==="Object"){let U=IW($).map(([Y,G])=>{let H=typeof Y==="symbol"?s2.onSymbol(Y):xT(Y)?Y:JSON.stringify(Y),z=a9(G,T,w);return`${w}${H}: ${z}`});if(U.length===0)return"{}";return T?`{
119
+ ${U.join(`,
118
120
  `)}
119
- ${W}}`:`{${Y.join(", ")}}`}if($ instanceof Date)return g0($);if("expression"in $&&typeof $.expression==="string")return $.expression;return X},yT={onCycle:()=>"(cycle)",onSymbol:($)=>`Symbol(${QU($)})`,onFunction:($)=>`Function(${QU($)})`},VU=($,T,W)=>{switch(G4($)){case"object":{let U=$;if("toJSON"in U&&typeof U.toJSON==="function")return U.toJSON();if(typeof U==="function")return yT.onFunction(U);if(W.includes(U))return"(cycle)";let X=[...W,U];if(Array.isArray(U))return U.map((_)=>VU(_,T,X));if(U instanceof Date)return U.toDateString();let Y={};for(let _ in U)Y[_]=VU(U[_],T,X);for(let _ of Object.getOwnPropertySymbols(U))Y[T.onSymbol?.(_)??_.toString()]=VU(U[_],T,X);return Y}case"symbol":return yT.onSymbol($);case"bigint":return T.onBigInt?.($)??`${$}n`;case"undefined":return T.onUndefined??"undefined";case"string":return $.replaceAll("\\","\\\\");default:return $}},g0=($)=>{let T=$.getFullYear(),W=$.getMonth(),U=$.getDate(),X=$.getHours(),Y=$.getMinutes(),_=$.getSeconds(),w=$.getMilliseconds();if(W===0&&U===1&&X===0&&Y===0&&_===0&&w===0)return`${T}`;let G=`${cv[W]} ${U}, ${T}`;if(X===0&&Y===0&&_===0&&w===0)return G;let J=$.toLocaleTimeString(),H=J.endsWith(" AM")||J.endsWith(" PM")?J.slice(-3):"";if(H)J=J.slice(0,-H.length);if(w)J+=`.${pv(w,3)}`;else if(uv.test(J))J=J.slice(0,-3);return`${J+H}, ${G}`},cv=["January","February","March","April","May","June","July","August","September","October","November","December"],uv=/:\d\d:00$/,pv=($,T)=>String($).padStart(T,"0");var fV=($,T,...[W])=>{let U=W?.stringifySymbol??Y$,X=$;switch(typeof T){case"string":X=d1(T)?$===""?T:`${$}.${T}`:`${$}[${JSON.stringify(T)}]`;break;case"number":X=`${$}[${T}]`;break;case"symbol":X=`${$}[${U(T)}]`;break;default:if(W?.stringifyNonKey)X=`${$}[${W.stringifyNonKey(T)}]`;else S(`${Y$(T)} must be a PropertyKey or stringifyNonKey must be passed to options`)}return X},O1=($,...T)=>$.reduce((W,U)=>fV(W,U,...T),"");class KU extends H8{cache={};constructor(...$){super();this.push(...$)}toJSON(){if(this.cache.json)return this.cache.json;this.cache.json=[];for(let $=0;$<this.length;$++)this.cache.json.push(typeof this[$]==="symbol"?Y$(this[$]):this[$]);return this.cache.json}stringify(){if(this.cache.stringify)return this.cache.stringify;return this.cache.stringify=O1(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let $="",T=[$];for(let W of this)$=fV($,W),T.push($);return this.cache.stringifyAncestors=T}}class M7{chars;i;def;constructor($){this.def=$,this.chars=[...$],this.i=0}shift(){return this.chars[this.i++]??""}get lookahead(){return this.chars[this.i]??""}get nextLookahead(){return this.chars[this.i+1]??""}get length(){return this.chars.length}shiftUntil($){let T="";while(this.lookahead){if($(this,T))if(T[T.length-1]===OU)T=T.slice(0,-1);else break;T+=this.shift()}return T}shiftUntilLookahead($){return typeof $==="string"?this.shiftUntil((T)=>T.lookahead===$):this.shiftUntil((T)=>(T.lookahead in $))}shiftUntilNonWhitespace(){return this.shiftUntil(()=>!(this.lookahead in o1))}jumpToIndex($){this.i=$<0?this.length+$:$}jumpForward($){this.i+=$}get location(){return this.i}get unscanned(){return this.chars.slice(this.i,this.length).join("")}get scanned(){return this.chars.slice(0,this.i).join("")}sliceChars($,T){return this.chars.slice($,T).join("")}lookaheadIs($){return this.lookahead===$}lookaheadIsIn($){return this.lookahead in $}}var ke=S6("implementedTraits");var N7="$ark",ov=2;while(N7 in globalThis)N7=`$ark${ov++}`;var yV=N7;globalThis[yV]=h0;var v=h0,dv=($)=>`${yV}.${$}`,o$=($)=>dv(QU($));class D8 extends GU{argNames;body="";constructor(...$){super();this.argNames=$;for(let T of $){if(T in this)throw new Error(`Arg name '${T}' would overwrite an existing property on FunctionBody`);this[T]=T}}indentation=0;indent(){return this.indentation+=4,this}dedent(){return this.indentation-=4,this}prop($,T=!1){return L7($,T)}index($,T=!1){return hV(`${$}`,T)}line($){return this.body+=`${" ".repeat(this.indentation)}${$}
121
+ ${W}}`:`{${U.join(", ")}}`}if($ instanceof Date)return fW($);if("expression"in $&&typeof $.expression==="string")return $.expression;return X},s2={onCycle:()=>"(cycle)",onSymbol:($)=>`Symbol(${qU($)})`,onFunction:($)=>`Function(${qU($)})`},CU=($,T,W)=>{switch(f4($)){case"object":{let w=$;if("toJSON"in w&&typeof w.toJSON==="function")return w.toJSON();if(typeof w==="function")return s2.onFunction(w);if(W.includes(w))return"(cycle)";let X=[...W,w];if(Array.isArray(w))return w.map((Y)=>CU(Y,T,X));if(w instanceof Date)return w.toDateString();let U={};for(let Y in w)U[Y]=CU(w[Y],T,X);for(let Y of Object.getOwnPropertySymbols(w))U[T.onSymbol?.(Y)??Y.toString()]=CU(w[Y],T,X);return U}case"symbol":return s2.onSymbol($);case"bigint":return T.onBigInt?.($)??`${$}n`;case"undefined":return T.onUndefined??"undefined";case"string":return $.replaceAll("\\","\\\\");default:return $}},fW=($)=>{let T=$.getFullYear(),W=$.getMonth(),w=$.getDate(),X=$.getHours(),U=$.getMinutes(),Y=$.getSeconds(),G=$.getMilliseconds();if(W===0&&w===1&&X===0&&U===0&&Y===0&&G===0)return`${T}`;let H=`${eB[W]} ${w}, ${T}`;if(X===0&&U===0&&Y===0&&G===0)return H;let z=$.toLocaleTimeString(),F=z.endsWith(" AM")||z.endsWith(" PM")?z.slice(-3):"";if(F)z=z.slice(0,-F.length);if(G)z+=`.${Tx(G,3)}`;else if($x.test(z))z=z.slice(0,-3);return`${z+F}, ${H}`},eB=["January","February","March","April","May","June","July","August","September","October","November","December"],$x=/:\d\d:00$/,Tx=($,T)=>String($).padStart(T,"0");var MR=($,T,...[W])=>{let w=W?.stringifySymbol??M$,X=$;switch(typeof T){case"string":X=xT(T)?$===""?T:`${$}.${T}`:`${$}[${JSON.stringify(T)}]`;break;case"number":X=`${$}[${T}]`;break;case"symbol":X=`${$}[${w(T)}]`;break;default:if(W?.stringifyNonKey)X=`${$}[${W.stringifyNonKey(T)}]`;else B(`${M$(T)} must be a PropertyKey or stringifyNonKey must be passed to options`)}return X},d0=($,...T)=>$.reduce((W,w)=>MR(W,w,...T),"");class SU extends i9{cache={};constructor(...$){super();this.push(...$)}toJSON(){if(this.cache.json)return this.cache.json;this.cache.json=[];for(let $=0;$<this.length;$++)this.cache.json.push(typeof this[$]==="symbol"?M$(this[$]):this[$]);return this.cache.json}stringify(){if(this.cache.stringify)return this.cache.stringify;return this.cache.stringify=d0(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let $="",T=[$];for(let W of this)$=MR($,W),T.push($);return this.cache.stringifyAncestors=T}}class cQ{chars;i;def;constructor($){this.def=$,this.chars=[...$],this.i=0}shift(){return this.chars[this.i++]??""}get lookahead(){return this.chars[this.i]??""}get nextLookahead(){return this.chars[this.i+1]??""}get length(){return this.chars.length}shiftUntil($){let T="";while(this.lookahead){if($(this,T))if(T[T.length-1]===kU)T=T.slice(0,-1);else break;T+=this.shift()}return T}shiftUntilLookahead($){return typeof $==="string"?this.shiftUntil((T)=>T.lookahead===$):this.shiftUntil((T)=>(T.lookahead in $))}shiftUntilNonWhitespace(){return this.shiftUntil(()=>!(this.lookahead in BT))}jumpToIndex($){this.i=$<0?this.length+$:$}jumpForward($){this.i+=$}get location(){return this.i}get unscanned(){return this.chars.slice(this.i,this.length).join("")}get scanned(){return this.chars.slice(0,this.i).join("")}sliceChars($,T){return this.chars.slice($,T).join("")}lookaheadIs($){return this.lookahead===$}lookaheadIsIn($){return this.lookahead in $}}var fT$=y1("implementedTraits");var uQ="$ark",Wx=2;while(uQ in globalThis)uQ=`$ark${Wx++}`;var DR=uQ;globalThis[DR]=xW;var y=xW,Xx=($)=>`${DR}.${$}`,Z4=($)=>Xx(qU($));class s9 extends LU{argNames;body="";constructor(...$){super();this.argNames=$;for(let T of $){if(T in this)throw new Error(`Arg name '${T}' would overwrite an existing property on FunctionBody`);this[T]=T}}indentation=0;indent(){return this.indentation+=4,this}dedent(){return this.indentation-=4,this}prop($,T=!1){return pQ($,T)}index($,T=!1){return NR(`${$}`,T)}line($){return this.body+=`${" ".repeat(this.indentation)}${$}
120
122
  `,this}const($,T){return this.line(`const ${$} = ${T}`),this}let($,T){return this.line(`let ${$} = ${T}`)}set($,T){return this.line(`${$} = ${T}`)}if($,T){return this.block(`if (${$})`,T)}elseIf($,T){return this.block(`else if (${$})`,T)}else($){return this.block("else",$)}for($,T,W=0){return this.block(`for (let i = ${W}; ${$}; i++)`,T)}forIn($,T){return this.block(`for (const k in ${$})`,T)}block($,T,W=""){return this.line(`${$} {`),this.indent(),T(this),this.dedent(),this.line(`}${W}`)}return($=""){return this.line(`return ${$}`)}write($="anonymous",T=0){return`${$}(${this.argNames.join(", ")}) { ${T?this.body.split(`
121
123
  `).map((W)=>" ".repeat(T)+`${W}`).join(`
122
- `):this.body} }`}compile(){return new AV(...this.argNames,this.body)}}var D1=($)=>c4($,"object")||typeof $==="symbol"?o$($):ZU($),L7=($,T=!1)=>{if(typeof $==="string"&&d1($))return`${T?"?":""}.${$}`;return hV(lv($),T)},lv=($)=>typeof $==="symbol"?o$($):JSON.stringify($),hV=($,T=!1)=>`${T?"?.":""}[${$}]`;class EU extends D8{traversalKind;optimistic;constructor($){super("data","ctx");this.traversalKind=$.kind,this.optimistic=$.optimistic===!0}invoke($,T){let W=T?.arg??this.data,U=typeof $==="string"?!0:this.requiresContextFor($),X=typeof $==="string"?$:$.id;if(U)return`${this.referenceToId(X,T)}(${W}, ${this.ctx})`;return`${this.referenceToId(X,T)}(${W})`}referenceToId($,T){let W=T?.kind??this.traversalKind,U=`this.${$}${W}`;return T?.bind?`${U}.bind(${T?.bind})`:U}requiresContextFor($){return this.traversalKind==="Apply"||$.allowsRequiresContext}initializeErrorCount(){return this.const("errorCount","ctx.currentErrorCount")}returnIfFail(){return this.if("ctx.currentErrorCount > errorCount",()=>this.return())}returnIfFailFast(){return this.if("ctx.failFast && ctx.currentErrorCount > errorCount",()=>this.return())}traverseKey($,T,W){let U=this.requiresContextFor(W);if(U)this.line(`${this.ctx}.path.push(${$})`);if(this.check(W,{arg:T}),U)this.line(`${this.ctx}.path.pop()`);return this}check($,T){return this.traversalKind==="Allows"?this.if(`!${this.invoke($,T)}`,()=>this.return(!1)):this.line(this.invoke($,T))}}var Q8=($)=>X$($,(T,W)=>[T,I$(W)?[...W]:W]),P4=S6("arkKind"),d=($,T)=>$?.[P4]===T,C$=($)=>d($,"root")||d($,"constraint");var gV=["unit","proto","domain"],hT=["required","optional","index","sequence"],S7=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],Z8=[...S7,...hT,"structure","predicate"],gT=["alias","union","morph","unit","intersection","proto","domain"],rv=[...gT,...Z8],V8=X$(Z8,($,T)=>[T,1]),mV=X$([...hT,"undeclared"],($,T)=>[T,1]),cV=X$(rv,($,T)=>[T,$]),mT=($)=>typeof $==="string"&&($ in cV);var cT=($)=>cV[$],K8=($)=>gT.slice(cT($)+1),H$$=[...K8("union"),"alias"],F$$=[...K8("morph"),"alias"],H6=($)=>{if(typeof $==="string"||typeof $==="boolean"||$===null)return $;if(typeof $==="number"){if(Number.isNaN($))return"NaN";if($===Number.POSITIVE_INFINITY)return"Infinity";if($===Number.NEGATIVE_INFINITY)return"-Infinity";return $}return D1($)},l1=($)=>{let T="{ ";for(let[W,U]of Object.entries($))T+=`${W}: ${D1(U)}, `;return T+" }"},_$=($)=>{let T=$;if(T.hasAssociatedError)T.defaults.expected??=(W)=>("description"in W)?W.description:T.defaults.description(W),T.defaults.actual??=(W)=>Y$(W),T.defaults.problem??=(W)=>`must be ${W.expected}${W.actual?` (was ${W.actual})`:""}`,T.defaults.message??=(W)=>{if(W.path.length===0)return W.problem;let U=`${W.propString} ${W.problem}`;if(U[0]==="[")return`value at ${U}`;return U};return T};class uV extends Error{name="ToJsonSchemaError";code;context;constructor($,T){super(Y$(T,{quoteKeys:!1,indent:4}));this.code=$,this.context=T}hasCode($){return this.code===$}}var iv={dialect:"https://json-schema.org/draft/2020-12/schema",useRefs:!1,fallback:{arrayObject:($)=>y$.throw("arrayObject",$),arrayPostfix:($)=>y$.throw("arrayPostfix",$),defaultValue:($)=>y$.throw("defaultValue",$),domain:($)=>y$.throw("domain",$),morph:($)=>y$.throw("morph",$),patternIntersection:($)=>y$.throw("patternIntersection",$),predicate:($)=>y$.throw("predicate",$),proto:($)=>y$.throw("proto",$),symbolKey:($)=>y$.throw("symbolKey",$),unit:($)=>y$.throw("unit",$),date:($)=>y$.throw("date",$)}},y$={Error:uV,throw:(...$)=>{throw new y$.Error(...$)},throwInternalOperandError:($,T)=>Z$(`Unexpected JSON Schema input for ${$}: ${Y$(T)}`),defaultConfig:iv};v.config??={};var AU=($,T)=>{if(!T)return $;let W={...$},U;for(U in T){let X={...$.keywords};if(U==="keywords"){for(let Y in T[U]){let _=T.keywords[Y];if(_===void 0)continue;X[Y]=typeof _==="string"?{description:_}:_}W.keywords=X}else if(U==="toJsonSchema")W[U]=B7($.toJsonSchema,T.toJsonSchema);else if(mT(U))W[U]={...$[U],...T[U]};else W[U]=T[U]}return W},B7=($,T)=>{if(!$)return T??{};if(!T)return $;let W={...$},U;for(U in T)if(U==="fallback")W.fallback=nv($.fallback,T.fallback);else W[U]=T[U];return W},nv=($,T)=>{$=pV($),T=pV(T);let W={},U;for(U in y$.defaultConfig.fallback)W[U]=T[U]??T.default??$[U]??$.default??y$.defaultConfig.fallback[U];return W},pV=($)=>typeof $==="function"?{default:$}:$??{};class r1 extends GU{[P4]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:$,relativePath:T,...W},U){super();this.input=W,this.ctx=U,DV(this,W);let X=U.data;if(W.code==="union")W.errors=W.errors.flatMap((_)=>{let w=_.hasCode("union")?_.errors:[_];if(!$&&!T)return w;return w.map((G)=>G.transform((J)=>({...J,path:JV($,J.path,T)})))});this.nodeConfig=U.config[this.code];let Y=[...W.path??U.path];if(T)Y.push(...T);if($)Y.unshift(...$);this.path=new KU(...Y),this.data="data"in W?W.data:X}transform($){return new r1($({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode($){return this.code===$}get propString(){return O1(this.path)}get expected(){if(this.input.expected)return this.input.expected;let $=this.meta?.expected??this.nodeConfig.expected;return typeof $==="function"?$(this.input):$}get actual(){if(this.input.actual)return this.input.actual;let $=this.meta?.actual??this.nodeConfig.actual;return typeof $==="function"?$(this.data):$}get problem(){if(this.input.problem)return this.input.problem;let $=this.meta?.problem??this.nodeConfig.problem;return typeof $==="function"?$(this):$}get message(){if(this.input.message)return this.input.message;let $=this.meta?.message??this.nodeConfig.message;return typeof $==="function"?$(this):$}get flat(){return this.hasCode("intersection")?[...this.errors]:[this]}toJSON(){return{data:this.data,path:this.path,...this.input,expected:this.expected,actual:this.actual,problem:this.problem,message:this.message}}toString(){return this.message}throw(){throw this}}class p4 extends H8{[P4]="errors";ctx;constructor($){super();this.ctx=$}byPath=Object.create(null);get flatByPath(){return X$(this.byPath,($,T)=>[$,T.flat])}get flatProblemsByPath(){return X$(this.byPath,($,T)=>[$,T.flat.map((W)=>W.problem)])}byAncestorPath=Object.create(null);count=0;mutable=this;throw(){throw this.toTraversalError()}toTraversalError(){return new R7(this)}add($){if(this.includes($))return;this._add($)}transform($){let T=new p4(this.ctx);for(let W of this)T.add($(W));return T}merge($){for(let T of $){if(this.includes(T))continue;this._add(new r1({...T,path:[...this.ctx.path,...T.path]},this.ctx))}}affectsPath($){if(this.length===0)return!1;return $.stringifyAncestors().some((T)=>(T in this.byPath))||$.stringify()in this.byAncestorPath}get summary(){return this.toString()}get issues(){return this}toJSON(){return[...this.map(($)=>$.toJSON())]}toString(){return this.join(`
123
- `)}_add($){let T=this.byPath[$.propString];if(T){if(T.hasCode("union")&&T.errors.length===0)return;let W=$.hasCode("union")&&$.errors.length===0?$:new r1({code:"intersection",errors:T.hasCode("intersection")?[...T.errors,$]:[T,$]},this.ctx),U=this.indexOf(T);this.mutable[U===-1?this.length:U]=W,this.byPath[$.propString]=W,this.addAncestorPaths($)}else this.byPath[$.propString]=$,this.addAncestorPaths($),this.mutable.push($);this.count++}addAncestorPaths($){for(let T of $.path.stringifyAncestors())this.byAncestorPath[T]=O$(this.byAncestorPath[T],$)}}class R7 extends Error{name="TraversalError";constructor($){if($.length===1)super($.summary);else super(`
124
- `+$.map((T)=>` \u2022 ${tv(T)}`).join(`
125
- `));Object.defineProperty(this,"arkErrors",{value:$,enumerable:!1})}}var tv=($)=>$.toString().split(`
124
+ `):this.body} }`}compile(){return new WR(...this.argNames,this.body)}}var o0=($)=>p6($,"object")||typeof $==="symbol"?Z4($):PU($),pQ=($,T=!1)=>{if(typeof $==="string"&&xT($))return`${T?"?":""}.${$}`;return NR(wx($),T)},wx=($)=>typeof $==="symbol"?Z4($):JSON.stringify($),NR=($,T=!1)=>`${T?"?.":""}[${$}]`;class jU extends s9{traversalKind;optimistic;constructor($){super("data","ctx");this.traversalKind=$.kind,this.optimistic=$.optimistic===!0}invoke($,T){let W=T?.arg??this.data,w=typeof $==="string"?!0:this.requiresContextFor($),X=typeof $==="string"?$:$.id;if(w)return`${this.referenceToId(X,T)}(${W}, ${this.ctx})`;return`${this.referenceToId(X,T)}(${W})`}referenceToId($,T){let W=T?.kind??this.traversalKind,w=`this.${$}${W}`;return T?.bind?`${w}.bind(${T?.bind})`:w}requiresContextFor($){return this.traversalKind==="Apply"||$.allowsRequiresContext}initializeErrorCount(){return this.const("errorCount","ctx.currentErrorCount")}returnIfFail(){return this.if("ctx.currentErrorCount > errorCount",()=>this.return())}returnIfFailFast(){return this.if("ctx.failFast && ctx.currentErrorCount > errorCount",()=>this.return())}traverseKey($,T,W){let w=this.requiresContextFor(W);if(w)this.line(`${this.ctx}.path.push(${$})`);if(this.check(W,{arg:T}),w)this.line(`${this.ctx}.path.pop()`);return this}check($,T){return this.traversalKind==="Allows"?this.if(`!${this.invoke($,T)}`,()=>this.return(!1)):this.line(this.invoke($,T))}}var e9=($)=>E$($,(T,W)=>[T,o$(W)?[...W]:W]),C6=y1("arkKind"),W$=($,T)=>$?.[C6]===T,a$=($)=>W$($,"root")||W$($,"constraint");var LR=["unit","proto","domain"],e2=["required","optional","index","sequence"],dQ=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],$z=[...dQ,...e2,"structure","predicate"],$X=["alias","union","morph","unit","intersection","proto","domain"],Ux=[...$X,...$z],Tz=E$($z,($,T)=>[T,1]),JR=E$([...e2,"undeclared"],($,T)=>[T,1]),RR=E$(Ux,($,T)=>[T,$]),TX=($)=>typeof $==="string"&&($ in RR);var WX=($)=>RR[$],Wz=($)=>$X.slice(WX($)+1),MW$=[...Wz("union"),"alias"],DW$=[...Wz("morph"),"alias"],R1=($)=>{if(typeof $==="string"||typeof $==="boolean"||$===null)return $;if(typeof $==="number"){if(Number.isNaN($))return"NaN";if($===Number.POSITIVE_INFINITY)return"Infinity";if($===Number.NEGATIVE_INFINITY)return"-Infinity";return $}return o0($)},fT=($)=>{let T="{ ";for(let[W,w]of Object.entries($))T+=`${W}: ${o0(w)}, `;return T+" }"},D$=($)=>{let T=$;if(T.hasAssociatedError)T.defaults.expected??=(W)=>("description"in W)?W.description:T.defaults.description(W),T.defaults.actual??=(W)=>M$(W),T.defaults.problem??=(W)=>`must be ${W.expected}${W.actual?` (was ${W.actual})`:""}`,T.defaults.message??=(W)=>{if(W.path.length===0)return W.problem;let w=`${W.propString} ${W.problem}`;if(w[0]==="[")return`value at ${w}`;return w};return T};class _R extends Error{name="ToJsonSchemaError";code;context;constructor($,T){super(M$(T,{quoteKeys:!1,indent:4}));this.code=$,this.context=T}hasCode($){return this.code===$}}var Yx={dialect:"https://json-schema.org/draft/2020-12/schema",useRefs:!1,fallback:{arrayObject:($)=>w4.throw("arrayObject",$),arrayPostfix:($)=>w4.throw("arrayPostfix",$),defaultValue:($)=>w4.throw("defaultValue",$),domain:($)=>w4.throw("domain",$),morph:($)=>w4.throw("morph",$),patternIntersection:($)=>w4.throw("patternIntersection",$),predicate:($)=>w4.throw("predicate",$),proto:($)=>w4.throw("proto",$),symbolKey:($)=>w4.throw("symbolKey",$),unit:($)=>w4.throw("unit",$),date:($)=>w4.throw("date",$)}},w4={Error:_R,throw:(...$)=>{throw new w4.Error(...$)},throwInternalOperandError:($,T)=>I$(`Unexpected JSON Schema input for ${$}: ${M$(T)}`),defaultConfig:Yx};y.config??={};var IU=($,T)=>{if(!T)return $;let W={...$},w;for(w in T){let X={...$.keywords};if(w==="keywords"){for(let U in T[w]){let Y=T.keywords[U];if(Y===void 0)continue;X[U]=typeof Y==="string"?{description:Y}:Y}W.keywords=X}else if(w==="toJsonSchema")W[w]=oQ($.toJsonSchema,T.toJsonSchema);else if(TX(w))W[w]={...$[w],...T[w]};else W[w]=T[w]}return W},oQ=($,T)=>{if(!$)return T??{};if(!T)return $;let W={...$},w;for(w in T)if(w==="fallback")W.fallback=Gx($.fallback,T.fallback);else W[w]=T[w];return W},Gx=($,T)=>{$=kR($),T=kR(T);let W={},w;for(w in w4.defaultConfig.fallback)W[w]=T[w]??T.default??$[w]??$.default??w4.defaultConfig.fallback[w];return W},kR=($)=>typeof $==="function"?{default:$}:$??{};class bT extends LU{[C6]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:$,relativePath:T,...W},w){super();this.input=W,this.ctx=w,tJ(this,W);let X=w.data;if(W.code==="union")W.errors=W.errors.flatMap((Y)=>{let G=Y.hasCode("union")?Y.errors:[Y];if(!$&&!T)return G;return G.map((H)=>H.transform((z)=>({...z,path:dJ($,z.path,T)})))});this.nodeConfig=w.config[this.code];let U=[...W.path??w.path];if(T)U.push(...T);if($)U.unshift(...$);this.path=new SU(...U),this.data="data"in W?W.data:X}transform($){return new bT($({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode($){return this.code===$}get propString(){return d0(this.path)}get expected(){if(this.input.expected)return this.input.expected;let $=this.meta?.expected??this.nodeConfig.expected;return typeof $==="function"?$(this.input):$}get actual(){if(this.input.actual)return this.input.actual;let $=this.meta?.actual??this.nodeConfig.actual;return typeof $==="function"?$(this.data):$}get problem(){if(this.input.problem)return this.input.problem;let $=this.meta?.problem??this.nodeConfig.problem;return typeof $==="function"?$(this):$}get message(){if(this.input.message)return this.input.message;let $=this.meta?.message??this.nodeConfig.message;return typeof $==="function"?$(this):$}get flat(){return this.hasCode("intersection")?[...this.errors]:[this]}toJSON(){return{data:this.data,path:this.path,...this.input,expected:this.expected,actual:this.actual,problem:this.problem,message:this.message}}toString(){return this.message}throw(){throw this}}class o6 extends i9{[C6]="errors";ctx;constructor($){super();this.ctx=$}byPath=Object.create(null);get flatByPath(){return E$(this.byPath,($,T)=>[$,T.flat])}get flatProblemsByPath(){return E$(this.byPath,($,T)=>[$,T.flat.map((W)=>W.problem)])}byAncestorPath=Object.create(null);count=0;mutable=this;throw(){throw this.toTraversalError()}toTraversalError(){return new lQ(this)}add($){if(this.includes($))return;this._add($)}transform($){let T=new o6(this.ctx);for(let W of this)T.add($(W));return T}merge($){for(let T of $){if(this.includes(T))continue;this._add(new bT({...T,path:[...this.ctx.path,...T.path]},this.ctx))}}affectsPath($){if(this.length===0)return!1;return $.stringifyAncestors().some((T)=>(T in this.byPath))||$.stringify()in this.byAncestorPath}get summary(){return this.toString()}get issues(){return this}toJSON(){return[...this.map(($)=>$.toJSON())]}toString(){return this.join(`
125
+ `)}_add($){let T=this.byPath[$.propString];if(T){if(T.hasCode("union")&&T.errors.length===0)return;let W=$.hasCode("union")&&$.errors.length===0?$:new bT({code:"intersection",errors:T.hasCode("intersection")?[...T.errors,$]:[T,$]},this.ctx),w=this.indexOf(T);this.mutable[w===-1?this.length:w]=W,this.byPath[$.propString]=W,this.addAncestorPaths($)}else this.byPath[$.propString]=$,this.addAncestorPaths($),this.mutable.push($);this.count++}addAncestorPaths($){for(let T of $.path.stringifyAncestors())this.byAncestorPath[T]=C$(this.byAncestorPath[T],$)}}class lQ extends Error{name="TraversalError";constructor($){if($.length===1)super($.summary);else super(`
126
+ `+$.map((T)=>` \u2022 ${zx(T)}`).join(`
127
+ `));Object.defineProperty(this,"arkErrors",{value:$,enumerable:!1})}}var zx=($)=>$.toString().split(`
126
128
  `).join(`
127
- `);class R6{path=[];errors=new p4(this);root;config;queuedMorphs=[];branches=[];seen={};constructor($,T){this.root=$,this.config=T}get data(){let $=this.root;for(let T of this.path)$=$?.[T];return $}get propString(){return O1(this.path)}reject($){return this.error($),!1}mustBe($){return this.error($),!1}error($){let T=typeof $==="object"?$.code?$:{...$,code:"predicate"}:{code:"predicate",expected:$};return this.errorFromContext(T)}hasError(){return this.currentErrorCount!==0}get currentBranch(){return this.branches.at(-1)}queueMorphs($){let T={path:new KU(...this.path),morphs:$};if(this.currentBranch)this.currentBranch.queuedMorphs.push(T);else this.queuedMorphs.push(T)}finalize($){if(this.queuedMorphs.length){if(typeof this.root==="object"&&this.root!==null&&this.config.clone)this.root=this.config.clone(this.root);this.applyQueuedMorphs()}if(this.hasError())return $?$(this.errors):this.errors;return this.root}get currentErrorCount(){return this.currentBranch?this.currentBranch.error?1:0:this.errors.count}get failFast(){return this.branches.length!==0}pushBranch(){this.branches.push({error:void 0,queuedMorphs:[]})}popBranch(){return this.branches.pop()}get external(){return this}errorFromNodeContext($){return this.errorFromContext($)}errorFromContext($){let T=new r1($,this);if(this.currentBranch)this.currentBranch.error=T;else this.errors.add(T);return T}applyQueuedMorphs(){while(this.queuedMorphs.length){let $=this.queuedMorphs;this.queuedMorphs=[];for(let{path:T,morphs:W}of $){if(this.errors.affectsPath(T))continue;this.applyMorphsAtPath(T,W)}}}applyMorphsAtPath($,T){let W=$.at(-1),U;if(W!==void 0){U=this.root;for(let X=0;X<$.length-1;X++)U=U[$[X]]}this.path=[...$];for(let X of T){let Y=C$(X),_=X(U===void 0?this.root:U[W],this);if(_ instanceof r1){this.errors.add(_);break}if(_ instanceof p4){if(!Y)this.errors.merge(_);break}if(U===void 0)this.root=_;else U[W]=_;this.applyQueuedMorphs()}}}var o4=($,T,W)=>{if(!W)return T();W.path.push($);let U=T();return W.path.pop(),U};class NU extends B6{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor($,T){super((U,X,Y=this.onFail)=>{if(X)return this.traverseApply(U,X),X.hasError()?X.errors:X.data;return this.rootApply(U,Y)},{attach:$});this.attachments=$,this.$=T,this.onFail=this.meta.onFail??this.$.resolvedConfig.onFail,this.includesTransform=this.hasKind("morph")||this.hasKind("structure")&&this.structuralMorph!==void 0,this.includesContextualPredicate=this.hasKind("predicate")&&this.inner.predicate.length!==1,this.isCyclic=this.kind==="alias",this.referencesById={[this.id]:this},this.shallowReferences=this.hasKind("structure")?[this,...this.children]:this.children.reduce((U,X)=>$q(U,X.shallowReferences),[this]);let W=this.isStructural();this.flatRefs=[],this.flatMorphs=[];for(let U=0;U<this.children.length;U++){if(this.includesTransform||=this.children[U].includesTransform,this.includesContextualPredicate||=this.children[U].includesContextualPredicate,this.isCyclic||=this.children[U].isCyclic,!W){let X=this.children[U].flatRefs;for(let Y=0;Y<X.length;Y++){let _=X[Y];if(!this.flatRefs.some((w)=>dV(w,_))){this.flatRefs.push(_);for(let w of _.node.branches)if(w.hasKind("morph")||w.hasKind("intersection")&&w.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:_.path,propString:_.propString,node:w})}}}Object.assign(this.referencesById,this.children[U].referencesById)}this.flatRefs.sort((U,X)=>U.path.length>X.path.length?1:U.path.length<X.path.length?-1:U.propString>X.propString?1:U.propString<X.propString?-1:U.node.expression<X.node.expression?-1:1),this.allowsRequiresContext=this.includesContextualPredicate||this.isCyclic,this.rootApplyStrategy=!this.allowsRequiresContext&&this.flatMorphs.length===0?this.shallowMorphs.length===0?"allows":this.shallowMorphs.every((U)=>U.length===1||U.name==="$arkStructuralMorph")?this.hasKind("union")?this.branches.some((U)=>U.shallowMorphs.length>1)?"contextual":"branchedOptimistic":this.shallowMorphs.length>1?"contextual":"optimistic":"contextual":"contextual",this.rootApply=this.createRootApply(),this.allows=this.allowsRequiresContext?(U)=>this.traverseAllows(U,new R6(U,this.$.resolvedConfig)):(U)=>this.traverseAllows(U)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(T,W)=>{if(this.allows(T))return T;let U=new R6(T,this.$.resolvedConfig);return this.traverseApply(T,U),U.finalize(W)};case"contextual":return(T,W)=>{let U=new R6(T,this.$.resolvedConfig);return this.traverseApply(T,U),U.finalize(W)};case"optimistic":this.contextFreeMorph=this.shallowMorphs[0];let $=this.$.resolvedConfig.clone;return(T,W)=>{if(this.allows(T))return this.contextFreeMorph($&&(typeof T==="object"&&T!==null||typeof T==="function")?$(T):T);let U=new R6(T,this.$.resolvedConfig);return this.traverseApply(T,U),U.finalize(W)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,Z$(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=ev(this.metaJson);cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get description(){return this.cacheGetter("description",this.meta?.description??this.$.resolvedConfig[this.kind].description(this))}get references(){return Object.values(this.referencesById)}precedence=cT(this.kind);precompilation;assert=($,T)=>this($,T,(W)=>W.throw());traverse($,T){return this($,T,null)}get in(){return this.cacheGetter("in",this.getIo("in"))}get out(){return this.cacheGetter("out",this.getIo("out"))}getIo($){if(!this.includesTransform)return this;let T={};for(let[W,U]of this.innerEntries){let X=this.impl.keys[W];if(X.reduceIo)X.reduceIo($,T,U);else if(X.child){let Y=U;T[W]=I$(Y)?Y.map((_)=>_[$]):Y[$]}else T[W]=U}return this.$.node(this.kind,T)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals($){let T=C$($)?$:this.$.parseDefinition($);return this.innerHash===T.innerHash}ifEquals($){return this.equals($)?this:void 0}hasKind($){return this.kind===$}assertHasKind($){if(this.kind!==$)b0(`${this.kind} node was not of asserted kind ${$}`);return this}hasKindIn(...$){return $.includes(this.kind)}assertHasKindIn(...$){if(!G1($,this.kind))b0(`${this.kind} node was not one of asserted kinds ${$}`);return this}isBasis(){return G1(gV,this.kind)}isConstraint(){return G1(Z8,this.kind)}isStructural(){return G1(hT,this.kind)}isRefinement(){return G1(S7,this.kind)}isRoot(){return G1(gT,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit($){return this.hasKind("unit")&&this.allows($)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select($){let T=MU.normalize($);return this._select(T)}_select($){let T=MU.applyBoundary[$.boundary??"references"](this);if($.kind)T=T.filter((W)=>W.kind===$.kind);if($.where)T=T.filter($.where);return MU.applyMethod[$.method??"filter"](T,this,$)}transform($,T){return this._transform($,this._createTransformContext(T))}_createTransformContext($){return{root:this,selected:void 0,seen:{},path:[],parseOptions:{prereduced:$?.prereduced??!1},undeclaredKeyHandling:void 0,...$}}_transform($,T){let W=T.bindScope??this.$;if(T.seen[this.id])return this.$.lazilyResolve(T.seen[this.id]);if(T.shouldTransform?.(this,T)===!1)return this;let U;if(T.seen[this.id]=()=>U,this.hasKind("structure")&&this.undeclared!==T.undeclaredKeyHandling)T={...T,undeclaredKeyHandling:this.undeclared};let X=X$(this.inner,(J,H)=>{if(!this.impl.keys[J].child)return[J,H];let z=H;if(!I$(z)){let Q=z._transform($,T);return Q?[J,Q]:[]}if(z.length===0)return[J,H];let F=z.flatMap((Q)=>{return Q._transform($,T)??[]});return F.length?[J,F]:[]});delete T.seen[this.id];let Y=Object.assign(X,{meta:this.meta}),_=T.selected&&!T.selected.includes(this)?Y:$(this.kind,Y,T);if(_===null)return null;if(C$(_))return U=_;let w=Object.keys(_);if((w.length===0||w.length===1&&w[0]==="meta")&&!m6(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in _))return T.undeclaredKeyHandling?{..._,value:v.intrinsic.unknown}:null;if(this.kind==="morph")_.in??=v.intrinsic.unknown;return U=W.node(this.kind,_,T.parseOptions)}configureReferences($,T="references"){let W=MU.normalize(T),U=typeof $==="string"?(w,G)=>({...G,meta:{...G.meta,description:$}}):typeof $==="function"?(w,G)=>({...G,meta:$(G.meta)}):(w,G)=>({...G,meta:{...G.meta,...$}});if(W.boundary==="self")return this.$.node(this.kind,U(this.kind,{...this.inner,meta:this.meta}));let X=this._select(W),Y=X&&u1(X),_=W.boundary==="child"?(w,G)=>G.root.children.includes(w):W.boundary==="shallow"?(w)=>w.kind!=="structure":()=>!0;return this.$.finalize(this.transform(U,{shouldTransform:_,selected:Y}))}}var MU={applyBoundary:{self:($)=>[$],child:($)=>[...$.children],shallow:($)=>[...$.shallowReferences],references:($)=>[...$.references]},applyMethod:{filter:($)=>$,assertFilter:($,T,W)=>{if($.length===0)b0(oV(T,W));return $},find:($)=>$[0],assertFind:($,T,W)=>{if($.length===0)b0(oV(T,W));return $[0]}},normalize:($)=>typeof $==="function"?{boundary:"references",method:"filter",where:$}:typeof $==="string"?z4($,MU.applyBoundary)?{method:"filter",boundary:$}:{boundary:"references",method:"filter",kind:$}:{boundary:"references",method:"filter",...$}},oV=($,T)=>`${$} had no references matching ${Y$(T)}.`,av=($)=>O1($,{stringifyNonKey:(T)=>T.expression}),sv=/"(\$ark\.[^"]+)"/g,ev=($)=>JSON.stringify($).replaceAll(sv,"$1"),I6=($,T)=>({path:$,node:T,propString:av($)}),dV=($,T)=>$.propString===T.propString&&$.node.equals(T.node),I7=($,T)=>g6($,T,{isEqual:dV}),$q=($,T)=>g6($,T,{isEqual:(W,U)=>W.equals(U)});class g extends Array{static init($,T,W,U){return new g({kind:$,l:T,r:W,path:U?.path??[],optional:U?.optional??!1})}add($,T,W,U){return this.push({kind:$,l:T,r:W,path:U?.path??[],optional:U?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:$,l:T,r:W}=this[0],U=O1($);return v7(`Intersection${U&&` at ${U}`} of ${lV(T,W)}`)}return`The following intersections result in unsatisfiable types:
128
- \u2022 ${this.map(({path:$,l:T,r:W})=>`${$}: ${lV(T,W)}`).join(`
129
- \u2022 `)}`}throw(){return S(this.describeReasons())}invert(){let $=this.map((T)=>({...T,l:T.r,r:T.l}));if(!($ instanceof g))return new g(...$);return $}withPrefixKey($,T){return this.map((W)=>({...W,path:[$,...W.path],optional:W.optional||T==="optional"}))}toNeverIfDisjoint(){return v.intrinsic.never}}var lV=($,T)=>`${k7($)} and ${k7(T)}`,k7=($)=>C$($)?$.expression:I$($)?$.map(k7).join(" | ")||"never":String($),v7=($)=>`${$} results in an unsatisfiable type`;var uT={},d4=($,T,W)=>j$($,T,{$:W,invert:!1,pipe:!1}),LU=($,T,W)=>j$($,T,{$:W,invert:!1,pipe:!0}),j$=($,T,W)=>{let U=W.pipe?"|>":"&",X=`${$.hash}${U}${T.hash}`;if(uT[X]!==void 0)return uT[X];if(!W.pipe){let w=`${T.hash}${U}${$.hash}`;if(uT[w]!==void 0){let G=uT[w],J=G instanceof g?G.invert():G;return uT[X]=J,J}}let Y=!W.pipe||!$.includesTransform&&!T.includesTransform;if(Y&&$.equals(T))return $;let _=Y?q7($,T,W):$.hasKindIn(...gT)?Tq($,T,W):q7($,T,W);if(C$(_)){if($.equals(_))_=$;else if(T.equals(_))_=T}return uT[X]=_,_},q7=($,T,W)=>{let U=$.precedence<T.precedence?$.kind:T.kind,X=$.impl.intersections[T.kind]??T.impl.intersections[$.kind];if(X===void 0)return null;else if(U===$.kind)return X($,T,W);else{let Y=X(T,$,{...W,invert:!W.invert});if(Y instanceof g)Y=Y.invert();return Y}},Tq=($,T,W)=>$.includesTransform||T.includesTransform?W.invert?rV(T,$,W):rV($,T,W):q7($,T,W),rV=($,T,W)=>$.distribute((U)=>Wq(U,T,W),(U)=>{let X=U.filter(C$);if(X.length===0)return g.init("union",$.branches,T.branches);if(X.length<$.branches.length||!$.branches.every((w,G)=>w.in.equals(X[G].in)))return W.$.parseSchema(X);let Y;if(X.length===1){let w=X[0];if(!Y)return w;return W.$.node("morph",{...w.inner,in:w.in.configure(Y,"self")})}let _={branches:X};if(Y)_.meta=Y;return W.$.parseSchema(_)}),Wq=($,T,W)=>{if($.hasKind("morph")){let X=[...$.morphs];if($.lastMorphIfNode){let Y=j$($.lastMorphIfNode,T,W);if(Y instanceof g)return Y;X[X.length-1]=Y}else X.push(T);return W.$.node("morph",{morphs:X,in:$.inner.in})}if(T.hasKind("morph")){let X=j$($,T.in,W);if(X instanceof g)return X;return W.$.node("morph",{morphs:[T],in:X})}return W.$.node("morph",{morphs:[T],in:$})};class F6 extends NU{constructor($,T){super($,T);Object.defineProperty(this,P4,{value:"constraint",enumerable:!1})}impliedSiblings;intersect($){return d4(this,$,this.$)}}class Q1 extends F6{traverseApply=($,T)=>{if(!this.traverseAllows($,T))T.errorFromNodeContext(this.errorContext)};compile($){if($.traversalKind==="Allows")$.return(this.compiledCondition);else $.if(this.compiledNegation,()=>$.line(`${$.ctx}.errorFromNodeContext(${this.compiledErrorContext})`))}get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return l1(this.errorContext)}}var S4=($)=>(T,W)=>{if(I$(T)){if(T.length===0)return;let X=T.map((Y)=>W.$.node($,Y));if($==="predicate")return X;return X.sort((Y,_)=>Y.hash<_.hash?-1:1)}let U=W.$.node($,T);return U.hasOpenIntersection()?[U]:U},pT=($)=>{let T=$.r.shift();if(!T){let U=$.l.length===0&&$.kind==="structure"?v.intrinsic.unknown.internal:$.ctx.$.node($.kind,Object.assign($.baseInner,Uq($.l)),{prereduced:!0});for(let X of $.roots){if(U instanceof g)return U;U=j$(X,U,$.ctx)}return U}let W=!1;for(let U=0;U<$.l.length;U++){let X=j$($.l[U],T,$.ctx);if(X===null)continue;if(X instanceof g)return X;if(!W){if(X.isRoot())return $.roots.push(X),$.l.splice(U),pT($);$.l[U]=X,W=!0}else if(!$.l.includes(X))return Z$(`Unexpectedly encountered multiple distinct intersection results for refinement ${X}`)}if(!W)$.l.push(T);if($.kind==="intersection"){if(T.impliedSiblings)for(let U of T.impliedSiblings)g6($.r,U)}return pT($)},oT=($)=>{return Object.entries($).flatMap(([W,U])=>(W in V8)?U:[]).sort((W,U)=>W.precedence<U.precedence?-1:W.precedence>U.precedence?1:W.kind==="predicate"&&U.kind==="predicate"?0:W.hash<U.hash?-1:1)},Uq=($)=>{let T={};for(let W of $)if(W.hasOpenIntersection())T[W.kind]=O$(T[W.kind],W);else{if(T[W.kind])return Z$(`Unexpected intersection of closed refinements of kind ${W.kind}`);T[W.kind]=W}return T},iV=(...$)=>S(nV(...$)),nV=($,T,W)=>{let U=W.hasKind("morph")?"a morph":W.isUnknown()?"unknown":W.exclude(T).defaultShortDescription;return`${SV($)} operand must be ${T.description} (was ${U})`};var tV=($,T,W)=>new i1($,T,W,W,null);class E8 extends B6{}class i1 extends B6{[P4]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor($,T,W,U,X){super((...Y)=>{let _=X$(this.names,(w,G)=>{let J=this.arg$.parse(Y[w]);if(!J.extends(this.constraints[w]))S(Xq(G,this.constraints[w].expression,J.expression));return[G,J]});if(this.defIsLazy()){let w=this.bodyDef(_);return this.$.parse(w)}return this.$.parse(T,{args:_})});this.paramDefs=$,this.bodyDef=T,this.$=W,this.arg$=U,this.hkt=X,this.description=X?new X().description??`a generic type for ${X.constructor.name}`:"a generic type",this.baseInstantiation=this(...this.constraints)}defIsLazy(){return this.bodyDef instanceof E8}cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get json(){return this.cacheGetter("json",{params:this.params.map(($)=>$[1].isUnknown()?$[0]:[$[0],$[1].json]),body:bV(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map(($)=>typeof $==="string"?[$,v.intrinsic.unknown]:[$[0],this.$.parse($[1])]))}get names(){return this.cacheGetter("names",this.params.map(($)=>$[0]))}get constraints(){return this.cacheGetter("constraints",this.params.map(($)=>$[1]))}get internal(){return this}get referencesById(){return this.baseInstantiation.internal.referencesById}get references(){return this.baseInstantiation.internal.references}}var Xq=($,T,W)=>`${$} must be assignable to ${T} (was ${W})`;var Yq=_$({kind:"predicate",hasAssociatedError:!0,collapsibleKey:"predicate",keys:{predicate:{}},normalize:($)=>typeof $==="function"?{predicate:$}:$,defaults:{description:($)=>`valid according to ${$.predicate.name||"an anonymous predicate"}`},intersectionIsOpen:!0,intersections:{predicate:()=>null}});class aV extends F6{serializedPredicate=o$(this.predicate);compiledCondition=`${this.serializedPredicate}(data, ctx)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=null;expression=this.serializedPredicate;traverseAllows=this.predicate;errorContext={code:"predicate",description:this.description,meta:this.meta};compiledErrorContext=l1(this.errorContext);traverseApply=($,T)=>{if(!this.predicate($,T.external)&&!T.hasError())T.errorFromNodeContext(this.errorContext)};compile($){if($.traversalKind==="Allows"){$.return(this.compiledCondition);return}$.if(`${this.compiledNegation} && !ctx.hasError()`,()=>$.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}reduceJsonSchema($,T){return T.fallback.predicate({code:"predicate",base:$,predicate:this.predicate})}}var P7={implementation:Yq,Node:aV};var _q=_$({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:($)=>Number.isInteger($)?$:S(wq($))}},normalize:($)=>typeof $==="number"?{rule:$}:$,hasAssociatedError:!0,defaults:{description:($)=>$.rule===1?"an integer":$.rule===2?"even":`a multiple of ${$.rule}`},intersections:{divisor:($,T,W)=>W.$.node("divisor",{rule:Math.abs($.rule*T.rule/Jq($.rule,T.rule))})},obviatesBasisDescription:!0});class sV extends Q1{traverseAllows=($)=>$%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=v.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema($){if($.type="integer",this.rule===1)return $;return $.multipleOf=this.rule,$}}var C7={implementation:_q,Node:sV};var wq=($)=>`divisor must be an integer (was ${$})`,Jq=($,T)=>{let W,U=$,X=T;while(X!==0)W=X,X=U%X,U=W;return U};class X6 extends Q1{boundOperandKind=Fq[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=Oq(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${Gq[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?Dq(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan($){return(this.limitKind==="upper"?this.numericLimit<$.numericLimit:this.numericLimit>$.numericLimit)||this.numericLimit===$.numericLimit&&this.exclusive===!0&&!$.exclusive}overlapsRange($){if(this.isStricterThan($))return!1;if(this.numericLimit===$.numericLimit&&(this.exclusive||$.exclusive))return!1;return!0}overlapIsUnit($){return this.numericLimit===$.numericLimit&&!this.exclusive&&!$.exclusive}}var Gq={"<":">=","<=":">",">":"<=",">=":"<"},zq={min:"max",minLength:"maxLength",after:"before"},A8={parse:($)=>$||void 0},M8=($)=>(T)=>{if(typeof T==="number")return{rule:T};let{exclusive:W,...U}=T;return W?{...U,rule:$==="minLength"?U.rule+1:U.rule-1}:U},N8=($)=>(T)=>{if(typeof T==="number"||typeof T==="string"||T instanceof Date)return{rule:T};let{exclusive:W,...U}=T;if(!W)return U;let X=typeof U.rule==="number"?U.rule:typeof U.rule==="string"?new Date(U.rule).valueOf():U.rule.valueOf();return W?{...U,rule:$==="after"?X+1:X-1}:U},L8=($)=>typeof $==="string"||typeof $==="number"?new Date($):$,Hq=($,T)=>`${$} bound must be a positive integer (was ${T})`,dT=($)=>(T)=>{if(!Number.isInteger(T)||T<0)S(Hq($,T));return T},Fq={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},Oq=($,T)=>`${z4($,zq)?">":"<"}${T?"":"="}`,Dq=($)=>typeof $==="string"?$:new Date($).toLocaleString(),eV=($)=>`Bounded expression ${$} must be exactly one of number, string, Array, or Date`;var Qq=_$({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:L8,serialize:($)=>$.toISOString()}},normalize:N8("after"),defaults:{description:($)=>`${$.collapsibleLimitString} or later`,actual:g0},intersections:{after:($,T)=>$.isStricterThan(T)?$:T}});class $K extends X6{impliedBasis=v.intrinsic.Date.internal;collapsibleLimitString=g0(this.rule);traverseAllows=($)=>$>=this.rule;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,after:this.rule})}}var j7={implementation:Qq,Node:$K};var Zq=_$({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:L8,serialize:($)=>$.toISOString()}},normalize:N8("before"),defaults:{description:($)=>`${$.collapsibleLimitString} or earlier`,actual:g0},intersections:{before:($,T)=>$.isStricterThan(T)?$:T,after:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("unit",{unit:$.rule}):null:g.init("range",$,T)}});class TK extends X6{collapsibleLimitString=g0(this.rule);traverseAllows=($)=>$<=this.rule;impliedBasis=v.intrinsic.Date.internal;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,before:this.rule})}}var x7={implementation:Zq,Node:TK};var Vq=_$({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:dT("exactLength")}},normalize:($)=>typeof $==="number"?{rule:$}:$,hasAssociatedError:!0,defaults:{description:($)=>`exactly length ${$.rule}`,actual:($)=>`${$.length}`},intersections:{exactLength:($,T,W)=>g.init("unit",W.$.node("unit",{unit:$.rule}),W.$.node("unit",{unit:T.rule}),{path:["length"]}),minLength:($,T)=>$.rule>=T.rule?$:g.init("range",$,T),maxLength:($,T)=>$.rule<=T.rule?$:g.init("range",$,T)}});class WK extends Q1{traverseAllows=($)=>$.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=v.intrinsic.lengthBoundable.internal;expression=`== ${this.rule}`;reduceJsonSchema($){switch($.type){case"string":return $.minLength=this.rule,$.maxLength=this.rule,$;case"array":return $.minItems=this.rule,$.maxItems=this.rule,$;default:return y$.throwInternalOperandError("exactLength",$)}}}var b7={implementation:Vq,Node:WK};var Kq=_$({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:A8},normalize:($)=>typeof $==="number"?{rule:$}:$,defaults:{description:($)=>{if($.rule===0)return $.exclusive?"negative":"non-positive";return`${$.exclusive?"less than":"at most"} ${$.rule}`}},intersections:{max:($,T)=>$.isStricterThan(T)?$:T,min:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("unit",{unit:$.rule}):null:g.init("range",$,T)},obviatesBasisDescription:!0});class UK extends X6{impliedBasis=v.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$<this.rule:($)=>$<=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMaximum=this.rule;else $.maximum=this.rule;return $}}var f7={implementation:Kq,Node:UK};var Eq=_$({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:dT("maxLength")}},reduce:($,T)=>$.rule===0?T.node("exactLength",$):void 0,normalize:M8("maxLength"),defaults:{description:($)=>`at most length ${$.rule}`,actual:($)=>`${$.length}`},intersections:{maxLength:($,T)=>$.isStricterThan(T)?$:T,minLength:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("exactLength",{rule:$.rule}):null:g.init("range",$,T)}});class XK extends X6{impliedBasis=v.intrinsic.lengthBoundable.internal;traverseAllows=($)=>$.length<=this.rule;reduceJsonSchema($){switch($.type){case"string":return $.maxLength=this.rule,$;case"array":return $.maxItems=this.rule,$;default:return y$.throwInternalOperandError("maxLength",$)}}}var y7={implementation:Eq,Node:XK};var Aq=_$({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:A8},normalize:($)=>typeof $==="number"?{rule:$}:$,defaults:{description:($)=>{if($.rule===0)return $.exclusive?"positive":"non-negative";return`${$.exclusive?"more than":"at least"} ${$.rule}`}},intersections:{min:($,T)=>$.isStricterThan(T)?$:T},obviatesBasisDescription:!0});class YK extends X6{impliedBasis=v.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$>this.rule:($)=>$>=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMinimum=this.rule;else $.minimum=this.rule;return $}}var h7={implementation:Aq,Node:YK};var Mq=_$({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:dT("minLength")}},reduce:($)=>$.rule===0?v.intrinsic.unknown:void 0,normalize:M8("minLength"),defaults:{description:($)=>$.rule===1?"non-empty":`at least length ${$.rule}`,actual:($)=>$.length===0?"":`${$.length}`},intersections:{minLength:($,T)=>$.isStricterThan(T)?$:T}});class _K extends X6{impliedBasis=v.intrinsic.lengthBoundable.internal;traverseAllows=($)=>$.length>=this.rule;reduceJsonSchema($){switch($.type){case"string":return $.minLength=this.rule,$;case"array":return $.minItems=this.rule,$;default:return y$.throwInternalOperandError("minLength",$)}}}var g7={implementation:Mq,Node:_K};var wK={min:h7.implementation,max:f7.implementation,minLength:g7.implementation,maxLength:y7.implementation,exactLength:b7.implementation,after:j7.implementation,before:x7.implementation},JK={min:h7.Node,max:f7.Node,minLength:g7.Node,maxLength:y7.Node,exactLength:b7.Node,after:j7.Node,before:x7.Node};var Nq=_$({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:($)=>typeof $==="string"?{rule:$}:$ instanceof RegExp?$.flags?{rule:$.source,flags:$.flags}:{rule:$.source}:$,obviatesBasisDescription:!0,obviatesBasisExpression:!0,hasAssociatedError:!0,intersectionIsOpen:!0,defaults:{description:($)=>`matched by ${$.rule}`},intersections:{pattern:()=>null}});class GK extends Q1{instance=new RegExp(this.rule,this.flags);expression=`${this.instance}`;traverseAllows=this.instance.test.bind(this.instance);compiledCondition=`${this.expression}.test(data)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=v.intrinsic.string.internal;reduceJsonSchema($,T){if($.pattern)return T.fallback.patternIntersection({code:"patternIntersection",base:$,pattern:this.rule});return $.pattern=this.rule,$}}var m7={implementation:Nq,Node:GK};var SU=($,T)=>{let W=Lq($);if(T&&!T.includes(W))return S(`Root of kind ${W} should be one of ${T}`);return W},Lq=($)=>{if(d($,"root"))return $.kind;if(typeof $==="string")return $[0]==="$"?"alias":($ in u4)?"domain":"proto";if(typeof $==="function")return"proto";if(typeof $!=="object"||$===null)return S(zK($));if("morphs"in $)return"morph";if("branches"in $||I$($))return"union";if("unit"in $)return"unit";if("reference"in $)return"alias";let T=Object.keys($);if(T.length===0||T.some((W)=>(W in V8)))return"intersection";if("proto"in $)return"proto";if("domain"in $)return"domain";return S(zK($))},zK=($)=>`${Y$($)} is not a valid type schema`,HK={},Sq=($)=>I$($)?$.map((T)=>T.collapsibleJson):$.collapsibleJson,C4={};v.nodesByRegisteredId=C4;var c7=($)=>{return HK[$]??=0,`${$}${++HK[$]}`},u7=($)=>{let T=lT[$.kind],W=T.applyConfig?.($.def,$.$.resolvedConfig)??$.def,U={},{meta:X,...Y}=W,_=X===void 0?{}:typeof X==="string"?{description:X}:X,w=H7(Y).sort(([J],[H])=>mT(J)?mT(H)?cT(J)-cT(H):1:mT(H)?-1:J<H?-1:1).filter(([J,H])=>{if(J.startsWith("meta.")){let z=J.slice(5);return _[z]=H,!1}return!0});for(let J of w){let H=J[0],z=T.keys[H];if(!z)return S(`Key ${H} is not valid on ${$.kind} schema`);let F=z.parse?z.parse(J[1],$):J[1];if(F!==U6&&(F!==void 0||z.preserveUndefined))U[H]=F}if(T.reduce&&!$.prereduced){let J=T.reduce(U,$.$);if(J){if(J instanceof g)return J.throw();return Bq(J,_)}}return p7({id:$.id,kind:$.kind,inner:U,meta:_,$:$.$})},p7=({id:$,kind:T,inner:W,meta:U,$:X,ignoreCache:Y})=>{let _=lT[T],w=H7(W),G=[],J={};for(let[k,N]of w){let L=_.keys[k],q=L.serialize??(L.child?Sq:H6);if(J[k]=q(N),L.child===!0){let y=N;if(I$(y))G.push(...y);else G.push(y)}else if(typeof L.child==="function")G.push(...L.child(N))}if(_.finalizeInnerJson)J=_.finalizeInnerJson(J);let H={...J},z={};if(!m6(U))z=X$(U,(k,N)=>[k,k==="examples"?N:H6(N)]),H.meta=S8(z,"description",!0);J=S8(J,_.collapsibleKey,!1);let F=JSON.stringify({kind:T,...J});H=S8(H,_.collapsibleKey,!1);let Q=S8(H,_.collapsibleKey,!0),V=JSON.stringify({kind:T,...H});if(X.nodesByHash[V]&&!Y)return X.nodesByHash[V];let K={id:$,kind:T,impl:_,inner:W,innerEntries:w,innerJson:J,innerHash:F,meta:U,metaJson:z,json:H,hash:V,collapsibleJson:Q,children:G};if(T!=="intersection"){for(let k in W)if(k!=="in"&&k!=="out")K[k]=W[k]}let I=new OK[T](K,X);return X.nodesByHash[V]=I},FK=($,T)=>{if($.id===T)return $;if(C$(C4[T]))Z$(`Unexpected attempt to overwrite node id ${T}`);return p7({id:T,kind:$.kind,inner:$.inner,meta:$.meta,$:$.$,ignoreCache:!0})},Bq=($,T,W)=>{if(W&&C$(C4[W]))Z$(`Unexpected attempt to overwrite node id ${W}`);return p7({id:W??c7(T.alias??$.kind),kind:$.kind,inner:$.inner,meta:T,$:$.$})},S8=($,T,W)=>{let U=Object.keys($);if(U.length===1&&U[0]===T){let X=$[T];if(W)return X;if(c4(X,"object")&&(Object.keys(X).length===1||Array.isArray(X)))return X}return $};var BU=($,T,W)=>{if($.key!==T.key)return null;let U=$.key,X=j$($.value,T.value,W),Y=$.required||T.required?"required":"optional";if(X instanceof g)if(Y==="optional")X=v.intrinsic.never.internal;else return X.withPrefixKey($.key,$.required&&T.required?"required":"optional");if(Y==="required")return W.$.node("required",{key:U,value:X});let _=$.hasDefault()?T.hasDefault()?$.default===T.default?$.default:S(o7($.default,T.default)):$.default:T.hasDefault()?T.default:U6;return W.$.node("optional",{key:U,value:X,default:_})};class RU extends F6{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=v.intrinsic.object.internal;serializedKey=D1(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=O$(this.value.flatRefs.map(($)=>I6([this.key,...$.path],$.node)),I6([this.key],this.value));_transform($,T){T.path.push(this.key);let W=super._transform($,T);return T.path.pop(),W}hasDefault(){return"default"in this.inner}traverseAllows=($,T)=>{if(this.key in $)return o4(this.key,()=>this.value.traverseAllows($[this.key],T),T);return this.optional};traverseApply=($,T)=>{if(this.key in $)o4(this.key,()=>this.value.traverseApply($[this.key],T),T);else if(this.hasKind("required"))T.errorFromNodeContext(this.errorContext)};compile($){if($.if(`${this.serializedKey} in data`,()=>$.traverseKey(this.serializedKey,`data${$.prop(this.key)}`,this.value)),this.hasKind("required"))$.else(()=>$.traversalKind==="Apply"?$.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`):$.return(!1));if($.traversalKind==="Allows")$.return(!0)}}var o7=($,T)=>`Invalid intersection of default values ${Y$($)} & ${Y$(T)}`;var Rq=_$({kind:"optional",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:($,T)=>T.$.parseSchema($)},default:{preserveUndefined:!0}},normalize:($)=>$,reduce:($,T)=>{if(T.resolvedConfig.exactOptionalPropertyTypes===!1){if(!$.value.allows(void 0))return T.node("optional",{...$,value:$.value.or(n.undefined)},{prereduced:!0})}},defaults:{description:($)=>`${$.compiledKey}?: ${$.value.description}`},intersections:{optional:BU}});class DK extends RU{constructor(...$){super(...$);if("default"in this.inner)kU(this.value,this.inner.default,this.key)}get outProp(){if(!this.hasDefault())return this;let{default:$,...T}=this.inner;return this.cacheGetter("outProp",this.$.node("required",T,{prereduced:!0}))}expression=this.hasDefault()?`${this.compiledKey}: ${this.value.expression} = ${Y$(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=kq(this);defaultValueMorphRef=this.defaultValueMorph&&o$(this.defaultValueMorph)}var IU={implementation:Rq,Node:DK},Iq={},kq=($)=>{if(!$.hasDefault())return;let T=`{${$.compiledKey}: ${$.value.id} = ${H6($.default)}}`;return Iq[T]??=d7($.key,$.value,$.default)},d7=($,T,W)=>{if(typeof W==="function")return T.includesTransform?(X,Y)=>{return o4($,()=>T(X[$]=W(),Y),Y),X}:(X)=>{return X[$]=W(),X};let U=T.includesTransform?T.assert(W):W;return c4(U,"object")?(X,Y)=>{return o4($,()=>T(X[$]=W,Y),Y),X}:(X)=>{return X[$]=U,X}},kU=($,T,W)=>{let U=p1(T);if(c4(T,"object")&&!U)S(vq(W));let X=$.in(U?T():T);if(X instanceof p4){if(W===null)S(`Default ${X.summary}`);let Y=X.transform((_)=>_.transform((w)=>({...w,prefixPath:[W]})));S(`Default for ${Y.summary}`)}return T},vq=($)=>{return`Non-primitive default ${$===null?"":typeof $==="number"?`for value at [${$}] `:`for ${D1($)} `}must be specified as a function like () => ({my: 'object'})`};class O6 extends NU{constructor($,T){super($,T);Object.defineProperty(this,P4,{value:"root",enumerable:!1})}get internal(){return this}get "~standard"(){return{vendor:"arktype",version:1,validate:($)=>{let T=this($);if(T instanceof p4)return T;return{value:T}}}}as(){return this}brand($){if($==="")return S(qq);return this}readonly(){return this}branches=this.hasKind("union")?this.inner.branches:[this];distribute($,T){let W=this.branches.map($);return T?.(W)??W}get shortDescription(){return this.meta.description??this.defaultShortDescription}toJsonSchema($={}){let T=B7(this.$.resolvedConfig.toJsonSchema,$);T.useRefs||=this.isCyclic;let W=typeof T.dialect==="string"?{$schema:T.dialect}:{};if(Object.assign(W,this.toJsonSchemaRecurse(T)),T.useRefs)W.$defs=X$(this.references,(U,X)=>X.isRoot()&&!X.alwaysExpandJsonSchema?[X.id,X.toResolvedJsonSchema(T)]:[]);return W}toJsonSchemaRecurse($){if($.useRefs&&!this.alwaysExpandJsonSchema)return{$ref:`#/$defs/${this.id}`};return this.toResolvedJsonSchema($)}get alwaysExpandJsonSchema(){return this.isBasis()||this.kind==="alias"||this.hasKind("union")&&this.isBoolean}toResolvedJsonSchema($){let T=this.innerToJsonSchema($);return Object.assign(T,this.metaJson)}intersect($){let T=this.$.parseDefinition($),W=this.rawIntersect(T);if(W instanceof g)return W;return this.$.finalize(W)}rawIntersect($){return d4(this,$,this.$)}toNeverIfDisjoint(){return this}and($){let T=this.intersect($);return T instanceof g?T.throw():T}rawAnd($){let T=this.rawIntersect($);return T instanceof g?T.throw():T}or($){let T=this.$.parseDefinition($);return this.$.finalize(this.rawOr(T))}rawOr($){let T=[...this.branches,...$.branches];return this.$.node("union",T)}map($){return this.$.schema(this.applyStructuralOperation("map",[$]))}pick(...$){return this.$.schema(this.applyStructuralOperation("pick",$))}omit(...$){return this.$.schema(this.applyStructuralOperation("omit",$))}required(){return this.$.schema(this.applyStructuralOperation("required",[]))}partial(){return this.$.schema(this.applyStructuralOperation("partial",[]))}_keyof;keyof(){if(this._keyof)return this._keyof;let $=this.applyStructuralOperation("keyof",[]).reduce((T,W)=>T.intersect(W).toNeverIfDisjoint(),v.intrinsic.unknown.internal);if($.branches.length===0)S(v7(`keyof ${this.expression}`));return this._keyof=this.$.finalize($)}get props(){if(this.branches.length!==1)return S(Pq(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge($){let T=this.$.parseDefinition($);return this.$.schema(T.distribute((W)=>this.applyStructuralOperation("merge",[QK(W)??S(ZK("merge",W.expression))])))}applyStructuralOperation($,T){return this.distribute((W)=>{if(W.equals(v.intrinsic.object)&&$!=="merge")return W;let U=QK(W);if(!U)S(ZK($,W.expression));if($==="keyof")return U.keyof();if($==="get")return U.get(...T);if($==="props")return U.props;let X=$==="required"?"require":$==="partial"?"optionalize":$;return this.$.node("intersection",{...W.inner,structure:U[X](...T)})})}get(...$){if($[0]===void 0)return this;return this.$.schema(this.applyStructuralOperation("get",$))}extract($){let T=this.$.parseDefinition($);return this.$.schema(this.branches.filter((W)=>W.extends(T)))}exclude($){let T=this.$.parseDefinition($);return this.$.schema(this.branches.filter((W)=>!W.extends(T)))}array(){return this.$.schema(this.isUnknown()?{proto:Array}:{proto:Array,sequence:this},{prereduced:!0})}overlaps($){return!(this.intersect($)instanceof g)}extends($){let T=this.intersect($);return!(T instanceof g)&&this.equals(T)}ifExtends($){return this.extends($)?this:void 0}subsumes($){return this.$.parseDefinition($).extends(this)}configure($,T="shallow"){return this.configureReferences($,T)}describe($,T="shallow"){return this.configure({description:$},T)}optional(){return[this,"?"]}default($){return kU(this,$,null),[this,"=",$]}from($){return this.assert($)}_pipe(...$){let T=$.reduce((W,U)=>W.rawPipeOnce(U),this);return this.$.finalize(T)}tryPipe(...$){let T=$.reduce((W,U)=>W.rawPipeOnce(d(U,"root")?U:(X,Y)=>{try{return U(X,Y)}catch(_){return Y.error({code:"predicate",predicate:U,actual:`aborted due to error:
130
- ${_}
131
- `})}}),this);return this.$.finalize(T)}pipe=Object.assign(this._pipe.bind(this),{try:this.tryPipe.bind(this)});to($){return this.$.finalize(this.toNode(this.$.parseDefinition($)))}toNode($){let T=LU(this,$,this.$);if(T instanceof g)return T.throw();return T}rawPipeOnce($){if(d($,"root"))return this.toNode($);return this.distribute((T)=>T.hasKind("morph")?this.$.node("morph",{in:T.inner.in,morphs:[...T.morphs,$]}):this.$.node("morph",{in:T,morphs:[$]}),this.$.parseSchema)}narrow($){return this.constrainOut("predicate",$)}constrain($,T){return this._constrain("root",$,T)}constrainIn($,T){return this._constrain("in",$,T)}constrainOut($,T){return this._constrain("out",$,T)}_constrain($,T,W){let U=this.$.node(T,W);if(U.isRoot())return U.isUnknown()?this:Z$(`Unexpected constraint node ${U}`);let X=$==="root"?this:this[$];if(X.hasKind("morph")||U.impliedBasis&&!X.extends(U.impliedBasis))return iV(T,U.impliedBasis,this);let Y=this.$.node("intersection",{[U.kind]:U}),_=$==="out"?LU(this,Y,this.$):d4(this,Y,this.$);if(_ instanceof g)_.throw();return this.$.finalize(_)}onUndeclaredKey($){let T=typeof $==="string"?$:$.rule,W=typeof $==="string"?!1:$.deep;return this.$.finalize(this.transform((U,X)=>U==="structure"?T==="ignore"?OV(X,{undeclared:1}):{...X,undeclared:T}:X,W?void 0:{shouldTransform:(U)=>!G1(hT,U.kind)}))}hasEqualMorphs($){if(!this.includesTransform&&!$.includesTransform)return!0;if(!H1(this.shallowMorphs,$.shallowMorphs))return!1;if(!H1(this.flatMorphs,$.flatMorphs,{isEqual:(T,W)=>T.propString===W.propString&&(T.node.hasKind("morph")&&W.node.hasKind("morph")?T.node.hasEqualMorphs(W.node):T.node.hasKind("intersection")&&W.node.hasKind("intersection")?T.node.structure?.structuralMorphRef===W.node.structure?.structuralMorphRef:!1)}))return!1;return!0}onDeepUndeclaredKey($){return this.onUndeclaredKey({rule:$,deep:!0})}filter($){return this.constrainIn("predicate",$)}divisibleBy($){return this.constrain("divisor",$)}matching($){return this.constrain("pattern",$)}atLeast($){return this.constrain("min",$)}atMost($){return this.constrain("max",$)}moreThan($){return this.constrain("min",rT($))}lessThan($){return this.constrain("max",rT($))}atLeastLength($){return this.constrain("minLength",$)}atMostLength($){return this.constrain("maxLength",$)}moreThanLength($){return this.constrain("minLength",rT($))}lessThanLength($){return this.constrain("maxLength",rT($))}exactlyLength($){return this.constrain("exactLength",$)}atOrAfter($){return this.constrain("after",$)}atOrBefore($){return this.constrain("before",$)}laterThan($){return this.constrain("after",rT($))}earlierThan($){return this.constrain("before",rT($))}}var qq="Expected a non-empty brand name after #",rT=($)=>typeof $==="object"&&!($ instanceof Date)?{...$,exclusive:!0}:{rule:$,exclusive:!0},vU=($,T)=>d(T,"root")?d($,"root")?$.extends(T):T.allows($):d($,"root")?$.hasUnit(T):T===$,QK=($)=>{if($.hasKind("morph"))return null;if($.hasKind("intersection"))return $.inner.structure??($.basis?.domain==="object"?$.$.bindReference(v.intrinsic.emptyStructure):null);if($.isBasis()&&$.domain==="object")return $.$.bindReference(v.intrinsic.emptyStructure);return null},Pq=($)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
132
- ${$}`,ZK=($,T)=>`${$} operand must be an object (was ${T})`;var c6=($,T)=>X$(K8($),(W,U)=>[U,T]);var Cq=($)=>typeof $==="string"?{reference:$}:$,VK=($)=>$ instanceof g?v.intrinsic.never.internal:$,jq=_$({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:($)=>$.startsWith("$")?$:`$ark.${$}`},resolve:{}},normalize:Cq,defaults:{description:($)=>$.reference},intersections:{alias:($,T,W)=>W.$.lazilyResolve(()=>VK(j$($.resolution,T.resolution,W)),`${$.reference}${W.pipe?"=>":"&"}${T.reference}`),...c6("alias",($,T,W)=>{if(T.isUnknown())return $;if(T.isNever())return T;if(T.isBasis()&&!T.overlaps(v.intrinsic.object))return g.init("assignability",v.intrinsic.object,T);return W.$.lazilyResolve(()=>VK(j$($.resolution,T,W)),`${$.reference}${W.pipe?"=>":"&"}${T.id}`)})}});class KK extends O6{expression=this.reference;structure=void 0;get resolution(){let $=this._resolve();return C4[this.id]=$}_resolve(){if(this.resolve)return this.resolve();if(this.reference[0]==="$")return this.$.resolveRoot(this.reference.slice(1));let $=this.reference,T=C4[$],W=[];while(d(T,"context")){if(W.includes(T.id))return S(xq(T.id,W));W.push(T.id),T=C4[T.id]}if(!d(T,"root"))return Z$(`Unexpected resolution for reference ${this.reference}
129
+ `);class g1{path=[];errors=new o6(this);root;config;queuedMorphs=[];branches=[];seen={};constructor($,T){this.root=$,this.config=T}get data(){let $=this.root;for(let T of this.path)$=$?.[T];return $}get propString(){return d0(this.path)}reject($){return this.error($),!1}mustBe($){return this.error($),!1}error($){let T=typeof $==="object"?$.code?$:{...$,code:"predicate"}:{code:"predicate",expected:$};return this.errorFromContext(T)}hasError(){return this.currentErrorCount!==0}get currentBranch(){return this.branches.at(-1)}queueMorphs($){let T={path:new SU(...this.path),morphs:$};if(this.currentBranch)this.currentBranch.queuedMorphs.push(T);else this.queuedMorphs.push(T)}finalize($){if(this.queuedMorphs.length){if(typeof this.root==="object"&&this.root!==null&&this.config.clone)this.root=this.config.clone(this.root);this.applyQueuedMorphs()}if(this.hasError())return $?$(this.errors):this.errors;return this.root}get currentErrorCount(){return this.currentBranch?this.currentBranch.error?1:0:this.errors.count}get failFast(){return this.branches.length!==0}pushBranch(){this.branches.push({error:void 0,queuedMorphs:[]})}popBranch(){return this.branches.pop()}get external(){return this}errorFromNodeContext($){return this.errorFromContext($)}errorFromContext($){let T=new bT($,this);if(this.currentBranch)this.currentBranch.error=T;else this.errors.add(T);return T}applyQueuedMorphs(){while(this.queuedMorphs.length){let $=this.queuedMorphs;this.queuedMorphs=[];for(let{path:T,morphs:W}of $){if(this.errors.affectsPath(T))continue;this.applyMorphsAtPath(T,W)}}}applyMorphsAtPath($,T){let W=$.at(-1),w;if(W!==void 0){w=this.root;for(let X=0;X<$.length-1;X++)w=w[$[X]]}this.path=[...$];for(let X of T){let U=a$(X),Y=X(w===void 0?this.root:w[W],this);if(Y instanceof bT){this.errors.add(Y);break}if(Y instanceof o6){if(!U)this.errors.merge(Y);break}if(w===void 0)this.root=Y;else w[W]=Y;this.applyQueuedMorphs()}}}var l6=($,T,W)=>{if(!W)return T();W.path.push($);let w=T();return W.path.pop(),w};class xU extends h1{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor($,T){super((w,X,U=this.onFail)=>{if(X)return this.traverseApply(w,X),X.hasError()?X.errors:X.data;return this.rootApply(w,U)},{attach:$});this.attachments=$,this.$=T,this.onFail=this.meta.onFail??this.$.resolvedConfig.onFail,this.includesTransform=this.hasKind("morph")||this.hasKind("structure")&&this.structuralMorph!==void 0,this.includesContextualPredicate=this.hasKind("predicate")&&this.inner.predicate.length!==1,this.isCyclic=this.kind==="alias",this.referencesById={[this.id]:this},this.shallowReferences=this.hasKind("structure")?[this,...this.children]:this.children.reduce((w,X)=>Qx(w,X.shallowReferences),[this]);let W=this.isStructural();this.flatRefs=[],this.flatMorphs=[];for(let w=0;w<this.children.length;w++){if(this.includesTransform||=this.children[w].includesTransform,this.includesContextualPredicate||=this.children[w].includesContextualPredicate,this.isCyclic||=this.children[w].isCyclic,!W){let X=this.children[w].flatRefs;for(let U=0;U<X.length;U++){let Y=X[U];if(!this.flatRefs.some((G)=>qR(G,Y))){this.flatRefs.push(Y);for(let G of Y.node.branches)if(G.hasKind("morph")||G.hasKind("intersection")&&G.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:Y.path,propString:Y.propString,node:G})}}}Object.assign(this.referencesById,this.children[w].referencesById)}this.flatRefs.sort((w,X)=>w.path.length>X.path.length?1:w.path.length<X.path.length?-1:w.propString>X.propString?1:w.propString<X.propString?-1:w.node.expression<X.node.expression?-1:1),this.allowsRequiresContext=this.includesContextualPredicate||this.isCyclic,this.rootApplyStrategy=!this.allowsRequiresContext&&this.flatMorphs.length===0?this.shallowMorphs.length===0?"allows":this.shallowMorphs.every((w)=>w.length===1||w.name==="$arkStructuralMorph")?this.hasKind("union")?this.branches.some((w)=>w.shallowMorphs.length>1)?"contextual":"branchedOptimistic":this.shallowMorphs.length>1?"contextual":"optimistic":"contextual":"contextual",this.rootApply=this.createRootApply(),this.allows=this.allowsRequiresContext?(w)=>this.traverseAllows(w,new g1(w,this.$.resolvedConfig)):(w)=>this.traverseAllows(w)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(T,W)=>{if(this.allows(T))return T;let w=new g1(T,this.$.resolvedConfig);return this.traverseApply(T,w),w.finalize(W)};case"contextual":return(T,W)=>{let w=new g1(T,this.$.resolvedConfig);return this.traverseApply(T,w),w.finalize(W)};case"optimistic":this.contextFreeMorph=this.shallowMorphs[0];let $=this.$.resolvedConfig.clone;return(T,W)=>{if(this.allows(T))return this.contextFreeMorph($&&(typeof T==="object"&&T!==null||typeof T==="function")?$(T):T);let w=new g1(T,this.$.resolvedConfig);return this.traverseApply(T,w),w.finalize(W)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,I$(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=Ox(this.metaJson);cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get description(){return this.cacheGetter("description",this.meta?.description??this.$.resolvedConfig[this.kind].description(this))}get references(){return Object.values(this.referencesById)}precedence=WX(this.kind);precompilation;assert=($,T)=>this($,T,(W)=>W.throw());traverse($,T){return this($,T,null)}get in(){return this.cacheGetter("in",this.getIo("in"))}get out(){return this.cacheGetter("out",this.getIo("out"))}getIo($){if(!this.includesTransform)return this;let T={};for(let[W,w]of this.innerEntries){let X=this.impl.keys[W];if(X.reduceIo)X.reduceIo($,T,w);else if(X.child){let U=w;T[W]=o$(U)?U.map((Y)=>Y[$]):U[$]}else T[W]=w}return this.$.node(this.kind,T)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals($){let T=a$($)?$:this.$.parseDefinition($);return this.innerHash===T.innerHash}ifEquals($){return this.equals($)?this:void 0}hasKind($){return this.kind===$}assertHasKind($){if(this.kind!==$)jW(`${this.kind} node was not of asserted kind ${$}`);return this}hasKindIn(...$){return $.includes(this.kind)}assertHasKindIn(...$){if(!m0($,this.kind))jW(`${this.kind} node was not one of asserted kinds ${$}`);return this}isBasis(){return m0(LR,this.kind)}isConstraint(){return m0($z,this.kind)}isStructural(){return m0(e2,this.kind)}isRefinement(){return m0(dQ,this.kind)}isRoot(){return m0($X,this.kind)}isUnknown(){return this.hasKind("intersection")&&this.children.length===0}isNever(){return this.hasKind("union")&&this.children.length===0}hasUnit($){return this.hasKind("unit")&&this.allows($)}hasOpenIntersection(){return this.impl.intersectionIsOpen}get nestableExpression(){return this.expression}select($){let T=BU.normalize($);return this._select(T)}_select($){let T=BU.applyBoundary[$.boundary??"references"](this);if($.kind)T=T.filter((W)=>W.kind===$.kind);if($.where)T=T.filter($.where);return BU.applyMethod[$.method??"filter"](T,this,$)}transform($,T){return this._transform($,this._createTransformContext(T))}_createTransformContext($){return{root:this,selected:void 0,seen:{},path:[],parseOptions:{prereduced:$?.prereduced??!1},undeclaredKeyHandling:void 0,...$}}_transform($,T){let W=T.bindScope??this.$;if(T.seen[this.id])return this.$.lazilyResolve(T.seen[this.id]);if(T.shouldTransform?.(this,T)===!1)return this;let w;if(T.seen[this.id]=()=>w,this.hasKind("structure")&&this.undeclared!==T.undeclaredKeyHandling)T={...T,undeclaredKeyHandling:this.undeclared};let X=E$(this.inner,(z,F)=>{if(!this.impl.keys[z].child)return[z,F];let O=F;if(!o$(O)){let Z=O._transform($,T);return Z?[z,Z]:[]}if(O.length===0)return[z,F];let Q=O.flatMap((Z)=>{return Z._transform($,T)??[]});return Q.length?[z,Q]:[]});delete T.seen[this.id];let U=Object.assign(X,{meta:this.meta}),Y=T.selected&&!T.selected.includes(this)?U:$(this.kind,U,T);if(Y===null)return null;if(a$(Y))return w=Y;let G=Object.keys(Y);if((G.length===0||G.length===1&&G[0]==="meta")&&!H0(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in Y))return T.undeclaredKeyHandling?{...Y,value:y.intrinsic.unknown}:null;if(this.kind==="morph")Y.in??=y.intrinsic.unknown;return w=W.node(this.kind,Y,T.parseOptions)}configureReferences($,T="references"){let W=BU.normalize(T),w=typeof $==="string"?(G,H)=>({...H,meta:{...H.meta,description:$}}):typeof $==="function"?(G,H)=>({...H,meta:$(H.meta)}):(G,H)=>({...H,meta:{...H.meta,...$}});if(W.boundary==="self")return this.$.node(this.kind,w(this.kind,{...this.inner,meta:this.meta}));let X=this._select(W),U=X&&jT(X),Y=W.boundary==="child"?(G,H)=>H.root.children.includes(G):W.boundary==="shallow"?(G)=>G.kind!=="structure":()=>!0;return this.$.finalize(this.transform(w,{shouldTransform:Y,selected:U}))}}var BU={applyBoundary:{self:($)=>[$],child:($)=>[...$.children],shallow:($)=>[...$.shallowReferences],references:($)=>[...$.references]},applyMethod:{filter:($)=>$,assertFilter:($,T,W)=>{if($.length===0)jW(vR(T,W));return $},find:($)=>$[0],assertFind:($,T,W)=>{if($.length===0)jW(vR(T,W));return $[0]}},normalize:($)=>typeof $==="function"?{boundary:"references",method:"filter",where:$}:typeof $==="string"?b4($,BU.applyBoundary)?{method:"filter",boundary:$}:{boundary:"references",method:"filter",kind:$}:{boundary:"references",method:"filter",...$}},vR=($,T)=>`${$} had no references matching ${M$(T)}.`,Hx=($)=>d0($,{stringifyNonKey:(T)=>T.expression}),Fx=/"(\$ark\.[^"]+)"/g,Ox=($)=>JSON.stringify($).replaceAll(Fx,"$1"),m1=($,T)=>({path:$,node:T,propString:Hx($)}),qR=($,T)=>$.propString===T.propString&&$.node.equals(T.node),rQ=($,T)=>z0($,T,{isEqual:qR}),Qx=($,T)=>z0($,T,{isEqual:(W,w)=>W.equals(w)});class r extends Array{static init($,T,W,w){return new r({kind:$,l:T,r:W,path:w?.path??[],optional:w?.optional??!1})}add($,T,W,w){return this.push({kind:$,l:T,r:W,path:w?.path??[],optional:w?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:$,l:T,r:W}=this[0],w=d0($);return iQ(`Intersection${w&&` at ${w}`} of ${PR(T,W)}`)}return`The following intersections result in unsatisfiable types:
130
+ \u2022 ${this.map(({path:$,l:T,r:W})=>`${$}: ${PR(T,W)}`).join(`
131
+ \u2022 `)}`}throw(){return B(this.describeReasons())}invert(){let $=this.map((T)=>({...T,l:T.r,r:T.l}));if(!($ instanceof r))return new r(...$);return $}withPrefixKey($,T){return this.map((W)=>({...W,path:[$,...W.path],optional:W.optional||T==="optional"}))}toNeverIfDisjoint(){return y.intrinsic.never}}var PR=($,T)=>`${nQ($)} and ${nQ(T)}`,nQ=($)=>a$($)?$.expression:o$($)?$.map(nQ).join(" | ")||"never":String($),iQ=($)=>`${$} results in an unsatisfiable type`;var XX={},r6=($,T,W)=>s$($,T,{$:W,invert:!1,pipe:!1}),fU=($,T,W)=>s$($,T,{$:W,invert:!1,pipe:!0}),s$=($,T,W)=>{let w=W.pipe?"|>":"&",X=`${$.hash}${w}${T.hash}`;if(XX[X]!==void 0)return XX[X];if(!W.pipe){let G=`${T.hash}${w}${$.hash}`;if(XX[G]!==void 0){let H=XX[G],z=H instanceof r?H.invert():H;return XX[X]=z,z}}let U=!W.pipe||!$.includesTransform&&!T.includesTransform;if(U&&$.equals(T))return $;let Y=U?tQ($,T,W):$.hasKindIn(...$X)?Zx($,T,W):tQ($,T,W);if(a$(Y)){if($.equals(Y))Y=$;else if(T.equals(Y))Y=T}return XX[X]=Y,Y},tQ=($,T,W)=>{let w=$.precedence<T.precedence?$.kind:T.kind,X=$.impl.intersections[T.kind]??T.impl.intersections[$.kind];if(X===void 0)return null;else if(w===$.kind)return X($,T,W);else{let U=X(T,$,{...W,invert:!W.invert});if(U instanceof r)U=U.invert();return U}},Zx=($,T,W)=>$.includesTransform||T.includesTransform?W.invert?CR(T,$,W):CR($,T,W):tQ($,T,W),CR=($,T,W)=>$.distribute((w)=>Vx(w,T,W),(w)=>{let X=w.filter(a$);if(X.length===0)return r.init("union",$.branches,T.branches);if(X.length<$.branches.length||!$.branches.every((G,H)=>G.in.equals(X[H].in)))return W.$.parseSchema(X);let U;if(X.length===1){let G=X[0];if(!U)return G;return W.$.node("morph",{...G.inner,in:G.in.configure(U,"self")})}let Y={branches:X};if(U)Y.meta=U;return W.$.parseSchema(Y)}),Vx=($,T,W)=>{if($.hasKind("morph")){let X=[...$.morphs];if($.lastMorphIfNode){let U=s$($.lastMorphIfNode,T,W);if(U instanceof r)return U;X[X.length-1]=U}else X.push(T);return W.$.node("morph",{morphs:X,in:$.inner.in})}if(T.hasKind("morph")){let X=s$($,T.in,W);if(X instanceof r)return X;return W.$.node("morph",{morphs:[T],in:X})}return W.$.node("morph",{morphs:[T],in:$})};class _1 extends xU{constructor($,T){super($,T);Object.defineProperty(this,C6,{value:"constraint",enumerable:!1})}impliedSiblings;intersect($){return r6(this,$,this.$)}}class l0 extends _1{traverseApply=($,T)=>{if(!this.traverseAllows($,T))T.errorFromNodeContext(this.errorContext)};compile($){if($.traversalKind==="Allows")$.return(this.compiledCondition);else $.if(this.compiledNegation,()=>$.line(`${$.ctx}.errorFromNodeContext(${this.compiledErrorContext})`))}get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return fT(this.errorContext)}}var U6=($)=>(T,W)=>{if(o$(T)){if(T.length===0)return;let X=T.map((U)=>W.$.node($,U));if($==="predicate")return X;return X.sort((U,Y)=>U.hash<Y.hash?-1:1)}let w=W.$.node($,T);return w.hasOpenIntersection()?[w]:w},wX=($)=>{let T=$.r.shift();if(!T){let w=$.l.length===0&&$.kind==="structure"?y.intrinsic.unknown.internal:$.ctx.$.node($.kind,Object.assign($.baseInner,Kx($.l)),{prereduced:!0});for(let X of $.roots){if(w instanceof r)return w;w=s$(X,w,$.ctx)}return w}let W=!1;for(let w=0;w<$.l.length;w++){let X=s$($.l[w],T,$.ctx);if(X===null)continue;if(X instanceof r)return X;if(!W){if(X.isRoot())return $.roots.push(X),$.l.splice(w),wX($);$.l[w]=X,W=!0}else if(!$.l.includes(X))return I$(`Unexpectedly encountered multiple distinct intersection results for refinement ${X}`)}if(!W)$.l.push(T);if($.kind==="intersection"){if(T.impliedSiblings)for(let w of T.impliedSiblings)z0($.r,w)}return wX($)},UX=($)=>{return Object.entries($).flatMap(([W,w])=>(W in Tz)?w:[]).sort((W,w)=>W.precedence<w.precedence?-1:W.precedence>w.precedence?1:W.kind==="predicate"&&w.kind==="predicate"?0:W.hash<w.hash?-1:1)},Kx=($)=>{let T={};for(let W of $)if(W.hasOpenIntersection())T[W.kind]=C$(T[W.kind],W);else{if(T[W.kind])return I$(`Unexpected intersection of closed refinements of kind ${W.kind}`);T[W.kind]=W}return T},SR=(...$)=>B(jR(...$)),jR=($,T,W)=>{let w=W.hasKind("morph")?"a morph":W.isUnknown()?"unknown":W.exclude(T).defaultShortDescription;return`${YR($)} operand must be ${T.description} (was ${w})`};var IR=($,T,W)=>new yT($,T,W,W,null);class Xz extends h1{}class yT extends h1{[C6]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor($,T,W,w,X){super((...U)=>{let Y=E$(this.names,(G,H)=>{let z=this.arg$.parse(U[G]);if(!z.extends(this.constraints[G]))B(Ax(H,this.constraints[G].expression,z.expression));return[H,z]});if(this.defIsLazy()){let G=this.bodyDef(Y);return this.$.parse(G)}return this.$.parse(T,{args:Y})});this.paramDefs=$,this.bodyDef=T,this.$=W,this.arg$=w,this.hkt=X,this.description=X?new X().description??`a generic type for ${X.constructor.name}`:"a generic type",this.baseInstantiation=this(...this.constraints)}defIsLazy(){return this.bodyDef instanceof Xz}cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get json(){return this.cacheGetter("json",{params:this.params.map(($)=>$[1].isUnknown()?$[0]:[$[0],$[1].json]),body:ER(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map(($)=>typeof $==="string"?[$,y.intrinsic.unknown]:[$[0],this.$.parse($[1])]))}get names(){return this.cacheGetter("names",this.params.map(($)=>$[0]))}get constraints(){return this.cacheGetter("constraints",this.params.map(($)=>$[1]))}get internal(){return this}get referencesById(){return this.baseInstantiation.internal.referencesById}get references(){return this.baseInstantiation.internal.references}}var Ax=($,T,W)=>`${$} must be assignable to ${T} (was ${W})`;var Ex=D$({kind:"predicate",hasAssociatedError:!0,collapsibleKey:"predicate",keys:{predicate:{}},normalize:($)=>typeof $==="function"?{predicate:$}:$,defaults:{description:($)=>`valid according to ${$.predicate.name||"an anonymous predicate"}`},intersectionIsOpen:!0,intersections:{predicate:()=>null}});class BR extends _1{serializedPredicate=Z4(this.predicate);compiledCondition=`${this.serializedPredicate}(data, ctx)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=null;expression=this.serializedPredicate;traverseAllows=this.predicate;errorContext={code:"predicate",description:this.description,meta:this.meta};compiledErrorContext=fT(this.errorContext);traverseApply=($,T)=>{if(!this.predicate($,T.external)&&!T.hasError())T.errorFromNodeContext(this.errorContext)};compile($){if($.traversalKind==="Allows"){$.return(this.compiledCondition);return}$.if(`${this.compiledNegation} && !ctx.hasError()`,()=>$.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`))}reduceJsonSchema($,T){return T.fallback.predicate({code:"predicate",base:$,predicate:this.predicate})}}var aQ={implementation:Ex,Node:BR};var Mx=D$({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:($)=>Number.isInteger($)?$:B(Dx($))}},normalize:($)=>typeof $==="number"?{rule:$}:$,hasAssociatedError:!0,defaults:{description:($)=>$.rule===1?"an integer":$.rule===2?"even":`a multiple of ${$.rule}`},intersections:{divisor:($,T,W)=>W.$.node("divisor",{rule:Math.abs($.rule*T.rule/Nx($.rule,T.rule))})},obviatesBasisDescription:!0});class xR extends l0{traverseAllows=($)=>$%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=y.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema($){if($.type="integer",this.rule===1)return $;return $.multipleOf=this.rule,$}}var sQ={implementation:Mx,Node:xR};var Dx=($)=>`divisor must be an integer (was ${$})`,Nx=($,T)=>{let W,w=$,X=T;while(X!==0)W=X,X=w%X,w=W;return w};class Z1 extends l0{boundOperandKind=_x[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=kx(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${Lx[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?vx(this.numericLimit):`${this.numericLimit}`;limitKind=this.comparator["0"]==="<"?"upper":"lower";isStricterThan($){return(this.limitKind==="upper"?this.numericLimit<$.numericLimit:this.numericLimit>$.numericLimit)||this.numericLimit===$.numericLimit&&this.exclusive===!0&&!$.exclusive}overlapsRange($){if(this.isStricterThan($))return!1;if(this.numericLimit===$.numericLimit&&(this.exclusive||$.exclusive))return!1;return!0}overlapIsUnit($){return this.numericLimit===$.numericLimit&&!this.exclusive&&!$.exclusive}}var Lx={"<":">=","<=":">",">":"<=",">=":"<"},Jx={min:"max",minLength:"maxLength",after:"before"},wz={parse:($)=>$||void 0},Uz=($)=>(T)=>{if(typeof T==="number")return{rule:T};let{exclusive:W,...w}=T;return W?{...w,rule:$==="minLength"?w.rule+1:w.rule-1}:w},Yz=($)=>(T)=>{if(typeof T==="number"||typeof T==="string"||T instanceof Date)return{rule:T};let{exclusive:W,...w}=T;if(!W)return w;let X=typeof w.rule==="number"?w.rule:typeof w.rule==="string"?new Date(w.rule).valueOf():w.rule.valueOf();return W?{...w,rule:$==="after"?X+1:X-1}:w},Gz=($)=>typeof $==="string"||typeof $==="number"?new Date($):$,Rx=($,T)=>`${$} bound must be a positive integer (was ${T})`,YX=($)=>(T)=>{if(!Number.isInteger(T)||T<0)B(Rx($,T));return T},_x={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},kx=($,T)=>`${b4($,Jx)?">":"<"}${T?"":"="}`,vx=($)=>typeof $==="string"?$:new Date($).toLocaleString(),fR=($)=>`Bounded expression ${$} must be exactly one of number, string, Array, or Date`;var qx=D$({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:Gz,serialize:($)=>$.toISOString()}},normalize:Yz("after"),defaults:{description:($)=>`${$.collapsibleLimitString} or later`,actual:fW},intersections:{after:($,T)=>$.isStricterThan(T)?$:T}});class bR extends Z1{impliedBasis=y.intrinsic.Date.internal;collapsibleLimitString=fW(this.rule);traverseAllows=($)=>$>=this.rule;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,after:this.rule})}}var eQ={implementation:qx,Node:bR};var Px=D$({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:Gz,serialize:($)=>$.toISOString()}},normalize:Yz("before"),defaults:{description:($)=>`${$.collapsibleLimitString} or earlier`,actual:fW},intersections:{before:($,T)=>$.isStricterThan(T)?$:T,after:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("unit",{unit:$.rule}):null:r.init("range",$,T)}});class yR extends Z1{collapsibleLimitString=fW(this.rule);traverseAllows=($)=>$<=this.rule;impliedBasis=y.intrinsic.Date.internal;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,before:this.rule})}}var $Z={implementation:Px,Node:yR};var Cx=D$({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:YX("exactLength")}},normalize:($)=>typeof $==="number"?{rule:$}:$,hasAssociatedError:!0,defaults:{description:($)=>`exactly length ${$.rule}`,actual:($)=>`${$.length}`},intersections:{exactLength:($,T,W)=>r.init("unit",W.$.node("unit",{unit:$.rule}),W.$.node("unit",{unit:T.rule}),{path:["length"]}),minLength:($,T)=>$.rule>=T.rule?$:r.init("range",$,T),maxLength:($,T)=>$.rule<=T.rule?$:r.init("range",$,T)}});class hR extends l0{traverseAllows=($)=>$.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=y.intrinsic.lengthBoundable.internal;expression=`== ${this.rule}`;reduceJsonSchema($){switch($.type){case"string":return $.minLength=this.rule,$.maxLength=this.rule,$;case"array":return $.minItems=this.rule,$.maxItems=this.rule,$;default:return w4.throwInternalOperandError("exactLength",$)}}}var TZ={implementation:Cx,Node:hR};var Sx=D$({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:wz},normalize:($)=>typeof $==="number"?{rule:$}:$,defaults:{description:($)=>{if($.rule===0)return $.exclusive?"negative":"non-positive";return`${$.exclusive?"less than":"at most"} ${$.rule}`}},intersections:{max:($,T)=>$.isStricterThan(T)?$:T,min:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("unit",{unit:$.rule}):null:r.init("range",$,T)},obviatesBasisDescription:!0});class gR extends Z1{impliedBasis=y.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$<this.rule:($)=>$<=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMaximum=this.rule;else $.maximum=this.rule;return $}}var WZ={implementation:Sx,Node:gR};var jx=D$({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:YX("maxLength")}},reduce:($,T)=>$.rule===0?T.node("exactLength",$):void 0,normalize:Uz("maxLength"),defaults:{description:($)=>`at most length ${$.rule}`,actual:($)=>`${$.length}`},intersections:{maxLength:($,T)=>$.isStricterThan(T)?$:T,minLength:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("exactLength",{rule:$.rule}):null:r.init("range",$,T)}});class mR extends Z1{impliedBasis=y.intrinsic.lengthBoundable.internal;traverseAllows=($)=>$.length<=this.rule;reduceJsonSchema($){switch($.type){case"string":return $.maxLength=this.rule,$;case"array":return $.maxItems=this.rule,$;default:return w4.throwInternalOperandError("maxLength",$)}}}var XZ={implementation:jx,Node:mR};var Ix=D$({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:wz},normalize:($)=>typeof $==="number"?{rule:$}:$,defaults:{description:($)=>{if($.rule===0)return $.exclusive?"positive":"non-negative";return`${$.exclusive?"more than":"at least"} ${$.rule}`}},intersections:{min:($,T)=>$.isStricterThan(T)?$:T},obviatesBasisDescription:!0});class cR extends Z1{impliedBasis=y.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$>this.rule:($)=>$>=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMinimum=this.rule;else $.minimum=this.rule;return $}}var wZ={implementation:Ix,Node:cR};var Bx=D$({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:YX("minLength")}},reduce:($)=>$.rule===0?y.intrinsic.unknown:void 0,normalize:Uz("minLength"),defaults:{description:($)=>$.rule===1?"non-empty":`at least length ${$.rule}`,actual:($)=>$.length===0?"":`${$.length}`},intersections:{minLength:($,T)=>$.isStricterThan(T)?$:T}});class uR extends Z1{impliedBasis=y.intrinsic.lengthBoundable.internal;traverseAllows=($)=>$.length>=this.rule;reduceJsonSchema($){switch($.type){case"string":return $.minLength=this.rule,$;case"array":return $.minItems=this.rule,$;default:return w4.throwInternalOperandError("minLength",$)}}}var UZ={implementation:Bx,Node:uR};var pR={min:wZ.implementation,max:WZ.implementation,minLength:UZ.implementation,maxLength:XZ.implementation,exactLength:TZ.implementation,after:eQ.implementation,before:$Z.implementation},dR={min:wZ.Node,max:WZ.Node,minLength:UZ.Node,maxLength:XZ.Node,exactLength:TZ.Node,after:eQ.Node,before:$Z.Node};var xx=D$({kind:"pattern",collapsibleKey:"rule",keys:{rule:{},flags:{}},normalize:($)=>typeof $==="string"?{rule:$}:$ instanceof RegExp?$.flags?{rule:$.source,flags:$.flags}:{rule:$.source}:$,obviatesBasisDescription:!0,obviatesBasisExpression:!0,hasAssociatedError:!0,intersectionIsOpen:!0,defaults:{description:($)=>`matched by ${$.rule}`},intersections:{pattern:()=>null}});class oR extends l0{instance=new RegExp(this.rule,this.flags);expression=`${this.instance}`;traverseAllows=this.instance.test.bind(this.instance);compiledCondition=`${this.expression}.test(data)`;compiledNegation=`!${this.compiledCondition}`;impliedBasis=y.intrinsic.string.internal;reduceJsonSchema($,T){if($.pattern)return T.fallback.patternIntersection({code:"patternIntersection",base:$,pattern:this.rule});return $.pattern=this.rule,$}}var YZ={implementation:xx,Node:oR};var bU=($,T)=>{let W=fx($);if(T&&!T.includes(W))return B(`Root of kind ${W} should be one of ${T}`);return W},fx=($)=>{if(W$($,"root"))return $.kind;if(typeof $==="string")return $[0]==="$"?"alias":($ in d6)?"domain":"proto";if(typeof $==="function")return"proto";if(typeof $!=="object"||$===null)return B(lR($));if("morphs"in $)return"morph";if("branches"in $||o$($))return"union";if("unit"in $)return"unit";if("reference"in $)return"alias";let T=Object.keys($);if(T.length===0||T.some((W)=>(W in Tz)))return"intersection";if("proto"in $)return"proto";if("domain"in $)return"domain";return B(lR($))},lR=($)=>`${M$($)} is not a valid type schema`,rR={},bx=($)=>o$($)?$.map((T)=>T.collapsibleJson):$.collapsibleJson,S6={};y.nodesByRegisteredId=S6;var GZ=($)=>{return rR[$]??=0,`${$}${++rR[$]}`},zZ=($)=>{let T=GX[$.kind],W=T.applyConfig?.($.def,$.$.resolvedConfig)??$.def,w={},{meta:X,...U}=W,Y=X===void 0?{}:typeof X==="string"?{description:X}:X,G=jQ(U).sort(([z],[F])=>TX(z)?TX(F)?WX(z)-WX(F):1:TX(F)?-1:z<F?-1:1).filter(([z,F])=>{if(z.startsWith("meta.")){let O=z.slice(5);return Y[O]=F,!1}return!0});for(let z of G){let F=z[0],O=T.keys[F];if(!O)return B(`Key ${F} is not valid on ${$.kind} schema`);let Q=O.parse?O.parse(z[1],$):z[1];if(Q!==Q1&&(Q!==void 0||O.preserveUndefined))w[F]=Q}if(T.reduce&&!$.prereduced){let z=T.reduce(w,$.$);if(z){if(z instanceof r)return z.throw();return yx(z,Y)}}return HZ({id:$.id,kind:$.kind,inner:w,meta:Y,$:$.$})},HZ=({id:$,kind:T,inner:W,meta:w,$:X,ignoreCache:U})=>{let Y=GX[T],G=jQ(W),H=[],z={};for(let[L,R]of G){let _=Y.keys[L],S=_.serialize??(_.child?bx:R1);if(z[L]=S(R),_.child===!0){let x=R;if(o$(x))H.push(...x);else H.push(x)}else if(typeof _.child==="function")H.push(..._.child(R))}if(Y.finalizeInnerJson)z=Y.finalizeInnerJson(z);let F={...z},O={};if(!H0(w))O=E$(w,(L,R)=>[L,L==="examples"?R:R1(R)]),F.meta=zz(O,"description",!0);z=zz(z,Y.collapsibleKey,!1);let Q=JSON.stringify({kind:T,...z});F=zz(F,Y.collapsibleKey,!1);let Z=zz(F,Y.collapsibleKey,!0),K=JSON.stringify({kind:T,...F});if(X.nodesByHash[K]&&!U)return X.nodesByHash[K];let E={id:$,kind:T,impl:Y,inner:W,innerEntries:G,innerJson:z,innerHash:Q,meta:w,metaJson:O,json:F,hash:K,collapsibleJson:Z,children:H};if(T!=="intersection"){for(let L in W)if(L!=="in"&&L!=="out")E[L]=W[L]}let M=new iR[T](E,X);return X.nodesByHash[K]=M},nR=($,T)=>{if($.id===T)return $;if(a$(S6[T]))I$(`Unexpected attempt to overwrite node id ${T}`);return HZ({id:T,kind:$.kind,inner:$.inner,meta:$.meta,$:$.$,ignoreCache:!0})},yx=($,T,W)=>{if(W&&a$(S6[W]))I$(`Unexpected attempt to overwrite node id ${W}`);return HZ({id:W??GZ(T.alias??$.kind),kind:$.kind,inner:$.inner,meta:T,$:$.$})},zz=($,T,W)=>{let w=Object.keys($);if(w.length===1&&w[0]===T){let X=$[T];if(W)return X;if(p6(X,"object")&&(Object.keys(X).length===1||Array.isArray(X)))return X}return $};var yU=($,T,W)=>{if($.key!==T.key)return null;let w=$.key,X=s$($.value,T.value,W),U=$.required||T.required?"required":"optional";if(X instanceof r)if(U==="optional")X=y.intrinsic.never.internal;else return X.withPrefixKey($.key,$.required&&T.required?"required":"optional");if(U==="required")return W.$.node("required",{key:w,value:X});let Y=$.hasDefault()?T.hasDefault()?$.default===T.default?$.default:B(FZ($.default,T.default)):$.default:T.hasDefault()?T.default:Q1;return W.$.node("optional",{key:w,value:X,default:Y})};class hU extends _1{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=y.intrinsic.object.internal;serializedKey=o0(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=C$(this.value.flatRefs.map(($)=>m1([this.key,...$.path],$.node)),m1([this.key],this.value));_transform($,T){T.path.push(this.key);let W=super._transform($,T);return T.path.pop(),W}hasDefault(){return"default"in this.inner}traverseAllows=($,T)=>{if(this.key in $)return l6(this.key,()=>this.value.traverseAllows($[this.key],T),T);return this.optional};traverseApply=($,T)=>{if(this.key in $)l6(this.key,()=>this.value.traverseApply($[this.key],T),T);else if(this.hasKind("required"))T.errorFromNodeContext(this.errorContext)};compile($){if($.if(`${this.serializedKey} in data`,()=>$.traverseKey(this.serializedKey,`data${$.prop(this.key)}`,this.value)),this.hasKind("required"))$.else(()=>$.traversalKind==="Apply"?$.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`):$.return(!1));if($.traversalKind==="Allows")$.return(!0)}}var FZ=($,T)=>`Invalid intersection of default values ${M$($)} & ${M$(T)}`;var hx=D$({kind:"optional",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:($,T)=>T.$.parseSchema($)},default:{preserveUndefined:!0}},normalize:($)=>$,reduce:($,T)=>{if(T.resolvedConfig.exactOptionalPropertyTypes===!1){if(!$.value.allows(void 0))return T.node("optional",{...$,value:$.value.or(G$.undefined)},{prereduced:!0})}},defaults:{description:($)=>`${$.compiledKey}?: ${$.value.description}`},intersections:{optional:yU}});class tR extends hU{constructor(...$){super(...$);if("default"in this.inner)mU(this.value,this.inner.default,this.key)}get outProp(){if(!this.hasDefault())return this;let{default:$,...T}=this.inner;return this.cacheGetter("outProp",this.$.node("required",T,{prereduced:!0}))}expression=this.hasDefault()?`${this.compiledKey}: ${this.value.expression} = ${M$(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=mx(this);defaultValueMorphRef=this.defaultValueMorph&&Z4(this.defaultValueMorph)}var gU={implementation:hx,Node:tR},gx={},mx=($)=>{if(!$.hasDefault())return;let T=`{${$.compiledKey}: ${$.value.id} = ${R1($.default)}}`;return gx[T]??=OZ($.key,$.value,$.default)},OZ=($,T,W)=>{if(typeof W==="function")return T.includesTransform?(X,U)=>{return l6($,()=>T(X[$]=W(),U),U),X}:(X)=>{return X[$]=W(),X};let w=T.includesTransform?T.assert(W):W;return p6(w,"object")?(X,U)=>{return l6($,()=>T(X[$]=W,U),U),X}:(X)=>{return X[$]=w,X}},mU=($,T,W)=>{let w=IT(T);if(p6(T,"object")&&!w)B(cx(W));let X=$.in(w?T():T);if(X instanceof o6){if(W===null)B(`Default ${X.summary}`);let U=X.transform((Y)=>Y.transform((G)=>({...G,prefixPath:[W]})));B(`Default for ${U.summary}`)}return T},cx=($)=>{return`Non-primitive default ${$===null?"":typeof $==="number"?`for value at [${$}] `:`for ${o0($)} `}must be specified as a function like () => ({my: 'object'})`};class k1 extends xU{constructor($,T){super($,T);Object.defineProperty(this,C6,{value:"root",enumerable:!1})}get internal(){return this}get "~standard"(){return{vendor:"arktype",version:1,validate:($)=>{let T=this($);if(T instanceof o6)return T;return{value:T}}}}as(){return this}brand($){if($==="")return B(ux);return this}readonly(){return this}branches=this.hasKind("union")?this.inner.branches:[this];distribute($,T){let W=this.branches.map($);return T?.(W)??W}get shortDescription(){return this.meta.description??this.defaultShortDescription}toJsonSchema($={}){let T=oQ(this.$.resolvedConfig.toJsonSchema,$);T.useRefs||=this.isCyclic;let W=typeof T.dialect==="string"?{$schema:T.dialect}:{};if(Object.assign(W,this.toJsonSchemaRecurse(T)),T.useRefs)W.$defs=E$(this.references,(w,X)=>X.isRoot()&&!X.alwaysExpandJsonSchema?[X.id,X.toResolvedJsonSchema(T)]:[]);return W}toJsonSchemaRecurse($){if($.useRefs&&!this.alwaysExpandJsonSchema)return{$ref:`#/$defs/${this.id}`};return this.toResolvedJsonSchema($)}get alwaysExpandJsonSchema(){return this.isBasis()||this.kind==="alias"||this.hasKind("union")&&this.isBoolean}toResolvedJsonSchema($){let T=this.innerToJsonSchema($);return Object.assign(T,this.metaJson)}intersect($){let T=this.$.parseDefinition($),W=this.rawIntersect(T);if(W instanceof r)return W;return this.$.finalize(W)}rawIntersect($){return r6(this,$,this.$)}toNeverIfDisjoint(){return this}and($){let T=this.intersect($);return T instanceof r?T.throw():T}rawAnd($){let T=this.rawIntersect($);return T instanceof r?T.throw():T}or($){let T=this.$.parseDefinition($);return this.$.finalize(this.rawOr(T))}rawOr($){let T=[...this.branches,...$.branches];return this.$.node("union",T)}map($){return this.$.schema(this.applyStructuralOperation("map",[$]))}pick(...$){return this.$.schema(this.applyStructuralOperation("pick",$))}omit(...$){return this.$.schema(this.applyStructuralOperation("omit",$))}required(){return this.$.schema(this.applyStructuralOperation("required",[]))}partial(){return this.$.schema(this.applyStructuralOperation("partial",[]))}_keyof;keyof(){if(this._keyof)return this._keyof;let $=this.applyStructuralOperation("keyof",[]).reduce((T,W)=>T.intersect(W).toNeverIfDisjoint(),y.intrinsic.unknown.internal);if($.branches.length===0)B(iQ(`keyof ${this.expression}`));return this._keyof=this.$.finalize($)}get props(){if(this.branches.length!==1)return B(px(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge($){let T=this.$.parseDefinition($);return this.$.schema(T.distribute((W)=>this.applyStructuralOperation("merge",[aR(W)??B(sR("merge",W.expression))])))}applyStructuralOperation($,T){return this.distribute((W)=>{if(W.equals(y.intrinsic.object)&&$!=="merge")return W;let w=aR(W);if(!w)B(sR($,W.expression));if($==="keyof")return w.keyof();if($==="get")return w.get(...T);if($==="props")return w.props;let X=$==="required"?"require":$==="partial"?"optionalize":$;return this.$.node("intersection",{...W.inner,structure:w[X](...T)})})}get(...$){if($[0]===void 0)return this;return this.$.schema(this.applyStructuralOperation("get",$))}extract($){let T=this.$.parseDefinition($);return this.$.schema(this.branches.filter((W)=>W.extends(T)))}exclude($){let T=this.$.parseDefinition($);return this.$.schema(this.branches.filter((W)=>!W.extends(T)))}array(){return this.$.schema(this.isUnknown()?{proto:Array}:{proto:Array,sequence:this},{prereduced:!0})}overlaps($){return!(this.intersect($)instanceof r)}extends($){let T=this.intersect($);return!(T instanceof r)&&this.equals(T)}ifExtends($){return this.extends($)?this:void 0}subsumes($){return this.$.parseDefinition($).extends(this)}configure($,T="shallow"){return this.configureReferences($,T)}describe($,T="shallow"){return this.configure({description:$},T)}optional(){return[this,"?"]}default($){return mU(this,$,null),[this,"=",$]}from($){return this.assert($)}_pipe(...$){let T=$.reduce((W,w)=>W.rawPipeOnce(w),this);return this.$.finalize(T)}tryPipe(...$){let T=$.reduce((W,w)=>W.rawPipeOnce(W$(w,"root")?w:(X,U)=>{try{return w(X,U)}catch(Y){return U.error({code:"predicate",predicate:w,actual:`aborted due to error:
132
+ ${Y}
133
+ `})}}),this);return this.$.finalize(T)}pipe=Object.assign(this._pipe.bind(this),{try:this.tryPipe.bind(this)});to($){return this.$.finalize(this.toNode(this.$.parseDefinition($)))}toNode($){let T=fU(this,$,this.$);if(T instanceof r)return T.throw();return T}rawPipeOnce($){if(W$($,"root"))return this.toNode($);return this.distribute((T)=>T.hasKind("morph")?this.$.node("morph",{in:T.inner.in,morphs:[...T.morphs,$]}):this.$.node("morph",{in:T,morphs:[$]}),this.$.parseSchema)}narrow($){return this.constrainOut("predicate",$)}constrain($,T){return this._constrain("root",$,T)}constrainIn($,T){return this._constrain("in",$,T)}constrainOut($,T){return this._constrain("out",$,T)}_constrain($,T,W){let w=this.$.node(T,W);if(w.isRoot())return w.isUnknown()?this:I$(`Unexpected constraint node ${w}`);let X=$==="root"?this:this[$];if(X.hasKind("morph")||w.impliedBasis&&!X.extends(w.impliedBasis))return SR(T,w.impliedBasis,this);let U=this.$.node("intersection",{[w.kind]:w}),Y=$==="out"?fU(this,U,this.$):r6(this,U,this.$);if(Y instanceof r)Y.throw();return this.$.finalize(Y)}onUndeclaredKey($){let T=typeof $==="string"?$:$.rule,W=typeof $==="string"?!1:$.deep;return this.$.finalize(this.transform((w,X)=>w==="structure"?T==="ignore"?iJ(X,{undeclared:1}):{...X,undeclared:T}:X,W?void 0:{shouldTransform:(w)=>!m0(e2,w.kind)}))}hasEqualMorphs($){if(!this.includesTransform&&!$.includesTransform)return!0;if(!u0(this.shallowMorphs,$.shallowMorphs))return!1;if(!u0(this.flatMorphs,$.flatMorphs,{isEqual:(T,W)=>T.propString===W.propString&&(T.node.hasKind("morph")&&W.node.hasKind("morph")?T.node.hasEqualMorphs(W.node):T.node.hasKind("intersection")&&W.node.hasKind("intersection")?T.node.structure?.structuralMorphRef===W.node.structure?.structuralMorphRef:!1)}))return!1;return!0}onDeepUndeclaredKey($){return this.onUndeclaredKey({rule:$,deep:!0})}filter($){return this.constrainIn("predicate",$)}divisibleBy($){return this.constrain("divisor",$)}matching($){return this.constrain("pattern",$)}atLeast($){return this.constrain("min",$)}atMost($){return this.constrain("max",$)}moreThan($){return this.constrain("min",zX($))}lessThan($){return this.constrain("max",zX($))}atLeastLength($){return this.constrain("minLength",$)}atMostLength($){return this.constrain("maxLength",$)}moreThanLength($){return this.constrain("minLength",zX($))}lessThanLength($){return this.constrain("maxLength",zX($))}exactlyLength($){return this.constrain("exactLength",$)}atOrAfter($){return this.constrain("after",$)}atOrBefore($){return this.constrain("before",$)}laterThan($){return this.constrain("after",zX($))}earlierThan($){return this.constrain("before",zX($))}}var ux="Expected a non-empty brand name after #",zX=($)=>typeof $==="object"&&!($ instanceof Date)?{...$,exclusive:!0}:{rule:$,exclusive:!0},cU=($,T)=>W$(T,"root")?W$($,"root")?$.extends(T):T.allows($):W$($,"root")?$.hasUnit(T):T===$,aR=($)=>{if($.hasKind("morph"))return null;if($.hasKind("intersection"))return $.inner.structure??($.basis?.domain==="object"?$.$.bindReference(y.intrinsic.emptyStructure):null);if($.isBasis()&&$.domain==="object")return $.$.bindReference(y.intrinsic.emptyStructure);return null},px=($)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
134
+ ${$}`,sR=($,T)=>`${$} operand must be an object (was ${T})`;var F0=($,T)=>E$(Wz($),(W,w)=>[w,T]);var dx=($)=>typeof $==="string"?{reference:$}:$,eR=($)=>$ instanceof r?y.intrinsic.never.internal:$,ox=D$({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:($)=>$.startsWith("$")?$:`$ark.${$}`},resolve:{}},normalize:dx,defaults:{description:($)=>$.reference},intersections:{alias:($,T,W)=>W.$.lazilyResolve(()=>eR(s$($.resolution,T.resolution,W)),`${$.reference}${W.pipe?"=>":"&"}${T.reference}`),...F0("alias",($,T,W)=>{if(T.isUnknown())return $;if(T.isNever())return T;if(T.isBasis()&&!T.overlaps(y.intrinsic.object))return r.init("assignability",y.intrinsic.object,T);return W.$.lazilyResolve(()=>eR(s$($.resolution,T,W)),`${$.reference}${W.pipe?"=>":"&"}${T.id}`)})}});class $_ extends k1{expression=this.reference;structure=void 0;get resolution(){let $=this._resolve();return S6[this.id]=$}_resolve(){if(this.resolve)return this.resolve();if(this.reference[0]==="$")return this.$.resolveRoot(this.reference.slice(1));let $=this.reference,T=S6[$],W=[];while(W$(T,"context")){if(W.includes(T.id))return B(lx(T.id,W));W.push(T.id),T=S6[T.id]}if(!W$(T,"root"))return I$(`Unexpected resolution for reference ${this.reference}
133
135
  Seen: [${W.join("->")}]
134
- Resolution: ${Y$(T)}`);return T}get resolutionId(){if(this.reference.includes("&")||this.reference.includes("=>"))return this.resolution.id;if(this.reference[0]!=="$")return this.reference;let $=this.reference.slice(1),T=this.$.resolutions[$];if(typeof T==="string")return T;if(d(T,"root"))return T.id;return Z$(`Unexpected resolution for reference ${this.reference}: ${Y$(T)}`)}get defaultShortDescription(){return u4.object}innerToJsonSchema($){return this.resolution.toJsonSchemaRecurse($)}traverseAllows=($,T)=>{let W=T.seen[this.reference];if(W?.includes($))return!0;return T.seen[this.reference]=O$(W,$),this.resolution.traverseAllows($,T)};traverseApply=($,T)=>{let W=T.seen[this.reference];if(W?.includes($))return;T.seen[this.reference]=O$(W,$),this.resolution.traverseApply($,T)};compile($){let T=this.resolutionId;$.if(`ctx.seen.${T} && ctx.seen.${T}.includes(data)`,()=>$.return(!0)),$.if(`!ctx.seen.${T}`,()=>$.line(`ctx.seen.${T} = []`)),$.line(`ctx.seen.${T}.push(data)`),$.return($.invoke(T))}}var xq=($,T)=>`Alias '${$}' has a shallow resolution cycle: ${[...T,$].join("->")}`,qU={implementation:jq,Node:KK};class m0 extends O6{traverseApply=($,T)=>{if(!this.traverseAllows($,T))T.errorFromNodeContext(this.errorContext)};get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return l1(this.errorContext)}compile($){if($.traversalKind==="Allows")$.return(this.compiledCondition);else $.if(this.compiledNegation,()=>$.line(`${$.ctx}.errorFromNodeContext(${this.compiledErrorContext})`))}}var bq=_$({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:($)=>typeof $==="string"?{domain:$}:fT($,"numberAllowsNaN")&&$.domain!=="number"?S(B8.writeBadAllowNanMessage($.domain)):$,applyConfig:($,T)=>$.numberAllowsNaN===void 0&&$.domain==="number"&&T.numberAllowsNaN?{...$,numberAllowsNaN:!0}:$,defaults:{description:($)=>u4[$.domain],actual:($)=>Number.isNaN($)?"NaN":u4[G4($)]},intersections:{domain:($,T)=>$.domain==="number"&&T.domain==="number"?$.numberAllowsNaN?T:$:g.init("domain",$,T)}});class EK extends m0{requiresNaNCheck=this.domain==="number"&&!this.numberAllowsNaN;traverseAllows=this.requiresNaNCheck?($)=>typeof $==="number"&&!Number.isNaN($):($)=>G4($)===this.domain;compiledCondition=this.domain==="object"?'((typeof data === "object" && data !== null) || typeof data === "function")':`typeof data === "${this.domain}"${this.requiresNaNCheck?" && !Number.isNaN(data)":""}`;compiledNegation=this.domain==="object"?'((typeof data !== "object" || data === null) && typeof data !== "function")':`typeof data !== "${this.domain}"${this.requiresNaNCheck?" || Number.isNaN(data)":""}`;expression=this.numberAllowsNaN?"number | NaN":this.domain;get nestableExpression(){return this.numberAllowsNaN?`(${this.expression})`:this.expression}get defaultShortDescription(){return u4[this.domain]}innerToJsonSchema($){if(this.domain==="bigint"||this.domain==="symbol")return $.fallback.domain({code:"domain",base:{},domain:this.domain});return{type:this.domain}}}var B8={implementation:bq,Node:EK,writeBadAllowNanMessage:($)=>`numberAllowsNaN may only be specified with domain "number" (was ${$})`};var fq=_$({kind:"intersection",hasAssociatedError:!0,normalize:($)=>{if(C$($))return $;let{structure:T,...W}=$,U=!!T,X=T??{},Y=X$(W,(_,w)=>{if(z4(_,mV)){if(U)S(`Flattened structure key ${_} cannot be specified alongside a root 'structure' key.`);return X[_]=w,[]}return[_,w]});if(d(X,"constraint")||!m6(X))Y.structure=X;return Y},finalizeInnerJson:({structure:$,...T})=>c4($,"object")?{...$,...T}:T,keys:{domain:{child:!0,parse:($,T)=>T.$.node("domain",$)},proto:{child:!0,parse:($,T)=>T.$.node("proto",$)},structure:{child:!0,parse:($,T)=>T.$.node("structure",$),serialize:($)=>{if(!$.sequence?.minLength)return $.collapsibleJson;let{sequence:T,...W}=$.collapsibleJson,{minVariadicLength:U,...X}=T,Y=X.variadic&&Object.keys(X).length===1?X.variadic:X;return{...W,sequence:Y}}},divisor:{child:!0,parse:S4("divisor")},max:{child:!0,parse:S4("max")},min:{child:!0,parse:S4("min")},maxLength:{child:!0,parse:S4("maxLength")},minLength:{child:!0,parse:S4("minLength")},exactLength:{child:!0,parse:S4("exactLength")},before:{child:!0,parse:S4("before")},after:{child:!0,parse:S4("after")},pattern:{child:!0,parse:S4("pattern")},predicate:{child:!0,parse:S4("predicate")}},reduce:($,T)=>AK({},$,{$:T,invert:!1,pipe:!1}),defaults:{description:($)=>{if($.children.length===0)return"unknown";if($.structure)return $.structure.description;let T=[];if($.basis&&!$.refinements.some((W)=>W.impl.obviatesBasisDescription))T.push($.basis.description);if($.refinements.length){let W=$.refinements.toSorted((U,X)=>U.kind==="min"&&X.kind==="max"?-1:0).map((U)=>U.description);T.push(...W)}if($.inner.predicate)T.push(...$.inner.predicate.map((W)=>W.description));return T.join(" and ")},expected:($)=>` \u25E6 ${$.errors.map((T)=>T.expected).join(`
136
+ Resolution: ${M$(T)}`);return T}get resolutionId(){if(this.reference.includes("&")||this.reference.includes("=>"))return this.resolution.id;if(this.reference[0]!=="$")return this.reference;let $=this.reference.slice(1),T=this.$.resolutions[$];if(typeof T==="string")return T;if(W$(T,"root"))return T.id;return I$(`Unexpected resolution for reference ${this.reference}: ${M$(T)}`)}get defaultShortDescription(){return d6.object}innerToJsonSchema($){return this.resolution.toJsonSchemaRecurse($)}traverseAllows=($,T)=>{let W=T.seen[this.reference];if(W?.includes($))return!0;return T.seen[this.reference]=C$(W,$),this.resolution.traverseAllows($,T)};traverseApply=($,T)=>{let W=T.seen[this.reference];if(W?.includes($))return;T.seen[this.reference]=C$(W,$),this.resolution.traverseApply($,T)};compile($){let T=this.resolutionId;$.if(`ctx.seen.${T} && ctx.seen.${T}.includes(data)`,()=>$.return(!0)),$.if(`!ctx.seen.${T}`,()=>$.line(`ctx.seen.${T} = []`)),$.line(`ctx.seen.${T}.push(data)`),$.return($.invoke(T))}}var lx=($,T)=>`Alias '${$}' has a shallow resolution cycle: ${[...T,$].join("->")}`,uU={implementation:ox,Node:$_};class bW extends k1{traverseApply=($,T)=>{if(!this.traverseAllows($,T))T.errorFromNodeContext(this.errorContext)};get errorContext(){return{code:this.kind,description:this.description,meta:this.meta,...this.inner}}get compiledErrorContext(){return fT(this.errorContext)}compile($){if($.traversalKind==="Allows")$.return(this.compiledCondition);else $.if(this.compiledNegation,()=>$.line(`${$.ctx}.errorFromNodeContext(${this.compiledErrorContext})`))}}var rx=D$({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:($)=>typeof $==="string"?{domain:$}:a2($,"numberAllowsNaN")&&$.domain!=="number"?B(Hz.writeBadAllowNanMessage($.domain)):$,applyConfig:($,T)=>$.numberAllowsNaN===void 0&&$.domain==="number"&&T.numberAllowsNaN?{...$,numberAllowsNaN:!0}:$,defaults:{description:($)=>d6[$.domain],actual:($)=>Number.isNaN($)?"NaN":d6[f4($)]},intersections:{domain:($,T)=>$.domain==="number"&&T.domain==="number"?$.numberAllowsNaN?T:$:r.init("domain",$,T)}});class T_ extends bW{requiresNaNCheck=this.domain==="number"&&!this.numberAllowsNaN;traverseAllows=this.requiresNaNCheck?($)=>typeof $==="number"&&!Number.isNaN($):($)=>f4($)===this.domain;compiledCondition=this.domain==="object"?'((typeof data === "object" && data !== null) || typeof data === "function")':`typeof data === "${this.domain}"${this.requiresNaNCheck?" && !Number.isNaN(data)":""}`;compiledNegation=this.domain==="object"?'((typeof data !== "object" || data === null) && typeof data !== "function")':`typeof data !== "${this.domain}"${this.requiresNaNCheck?" || Number.isNaN(data)":""}`;expression=this.numberAllowsNaN?"number | NaN":this.domain;get nestableExpression(){return this.numberAllowsNaN?`(${this.expression})`:this.expression}get defaultShortDescription(){return d6[this.domain]}innerToJsonSchema($){if(this.domain==="bigint"||this.domain==="symbol")return $.fallback.domain({code:"domain",base:{},domain:this.domain});return{type:this.domain}}}var Hz={implementation:rx,Node:T_,writeBadAllowNanMessage:($)=>`numberAllowsNaN may only be specified with domain "number" (was ${$})`};var nx=D$({kind:"intersection",hasAssociatedError:!0,normalize:($)=>{if(a$($))return $;let{structure:T,...W}=$,w=!!T,X=T??{},U=E$(W,(Y,G)=>{if(b4(Y,JR)){if(w)B(`Flattened structure key ${Y} cannot be specified alongside a root 'structure' key.`);return X[Y]=G,[]}return[Y,G]});if(W$(X,"constraint")||!H0(X))U.structure=X;return U},finalizeInnerJson:({structure:$,...T})=>p6($,"object")?{...$,...T}:T,keys:{domain:{child:!0,parse:($,T)=>T.$.node("domain",$)},proto:{child:!0,parse:($,T)=>T.$.node("proto",$)},structure:{child:!0,parse:($,T)=>T.$.node("structure",$),serialize:($)=>{if(!$.sequence?.minLength)return $.collapsibleJson;let{sequence:T,...W}=$.collapsibleJson,{minVariadicLength:w,...X}=T,U=X.variadic&&Object.keys(X).length===1?X.variadic:X;return{...W,sequence:U}}},divisor:{child:!0,parse:U6("divisor")},max:{child:!0,parse:U6("max")},min:{child:!0,parse:U6("min")},maxLength:{child:!0,parse:U6("maxLength")},minLength:{child:!0,parse:U6("minLength")},exactLength:{child:!0,parse:U6("exactLength")},before:{child:!0,parse:U6("before")},after:{child:!0,parse:U6("after")},pattern:{child:!0,parse:U6("pattern")},predicate:{child:!0,parse:U6("predicate")}},reduce:($,T)=>W_({},$,{$:T,invert:!1,pipe:!1}),defaults:{description:($)=>{if($.children.length===0)return"unknown";if($.structure)return $.structure.description;let T=[];if($.basis&&!$.refinements.some((W)=>W.impl.obviatesBasisDescription))T.push($.basis.description);if($.refinements.length){let W=$.refinements.toSorted((w,X)=>w.kind==="min"&&X.kind==="max"?-1:0).map((w)=>w.description);T.push(...W)}if($.inner.predicate)T.push(...$.inner.predicate.map((W)=>W.description));return T.join(" and ")},expected:($)=>` \u25E6 ${$.errors.map((T)=>T.expected).join(`
135
137
  \u25E6 `)}`,problem:($)=>`(${$.actual}) must be...
136
- ${$.expected}`},intersections:{intersection:($,T,W)=>AK($.inner,T.inner,W),...c6("intersection",($,T,W)=>{if($.children.length===0)return T;let{domain:U,proto:X,...Y}=$.inner,_=X??U,w=_?j$(_,T,W):T;return w instanceof g?w:$?.basis?.equals(w)?$:$.$.node("intersection",{...Y,[w.kind]:w},{prereduced:!0})})}});class MK extends O6{basis=this.inner.domain??this.inner.proto??null;refinements=this.children.filter(($)=>$.isRefinement());structure=this.inner.structure;expression=yq(this);get shallowMorphs(){return this.inner.structure?.structuralMorph?[this.inner.structure.structuralMorph]:[]}get defaultShortDescription(){return this.basis?.defaultShortDescription??"present"}innerToJsonSchema($){return this.children.reduce((T,W)=>W.isBasis()?W.toJsonSchemaRecurse($):W.reduceJsonSchema(T,$),{})}traverseAllows=($,T)=>this.children.every((W)=>W.traverseAllows($,T));traverseApply=($,T)=>{let W=T.currentErrorCount;if(this.basis){if(this.basis.traverseApply($,T),T.currentErrorCount>W)return}if(this.refinements.length){for(let U=0;U<this.refinements.length-1;U++)if(this.refinements[U].traverseApply($,T),T.failFast&&T.currentErrorCount>W)return;if(this.refinements.at(-1).traverseApply($,T),T.currentErrorCount>W)return}if(this.structure){if(this.structure.traverseApply($,T),T.currentErrorCount>W)return}if(this.inner.predicate){for(let U=0;U<this.inner.predicate.length-1;U++)if(this.inner.predicate[U].traverseApply($,T),T.failFast&&T.currentErrorCount>W)return;this.inner.predicate.at(-1).traverseApply($,T)}};compile($){if($.traversalKind==="Allows"){for(let T of this.children)$.check(T);$.return(!0);return}if($.initializeErrorCount(),this.basis){if($.check(this.basis),this.children.length>1)$.returnIfFail()}if(this.refinements.length){for(let T=0;T<this.refinements.length-1;T++)$.check(this.refinements[T]),$.returnIfFailFast();if($.check(this.refinements.at(-1)),this.structure||this.inner.predicate)$.returnIfFail()}if(this.structure){if($.check(this.structure),this.inner.predicate)$.returnIfFail()}if(this.inner.predicate){for(let T=0;T<this.inner.predicate.length-1;T++)$.check(this.inner.predicate[T]),$.returnIfFail();$.check(this.inner.predicate.at(-1))}}}var l7={implementation:fq,Node:MK},yq=($)=>{let T=$.structure?.expression||`${$.basis&&!$.refinements.some((W)=>W.impl.obviatesBasisExpression)?$.basis.nestableExpression+" ":""}${$.refinements.map((W)=>W.expression).join(" & ")}`||"unknown";if(T==="Array == 0")T="[]";return T},AK=($,T,W)=>{let U={},X=$.proto??$.domain,Y=T.proto??T.domain,_=X?Y?j$(X,Y,W):X:Y;if(_ instanceof g)return _;if(_)U[_.kind]=_;return pT({kind:"intersection",baseInner:U,l:oT($),r:oT(T),roots:[],ctx:W})};var hq=_$({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:($,T)=>T.$.parseSchema($)},morphs:{parse:u1,serialize:($)=>$.map((T)=>d(T,"root")?T.json:o$(T))},declaredIn:{child:!1,serialize:($)=>$.json},declaredOut:{child:!1,serialize:($)=>$.json}},normalize:($)=>$,defaults:{description:($)=>`a morph from ${$.in.description} to ${$.out?.description??"unknown"}`},intersections:{morph:($,T,W)=>{if(!$.hasEqualMorphs(T))return S(gq($.expression,T.expression));let U=j$($.in,T.in,W);if(U instanceof g)return U;let X={morphs:$.morphs};if($.declaredIn||T.declaredIn){let Y=j$($.in,T.in,W);if(Y instanceof g)return Y.throw();else X.declaredIn=Y}if($.declaredOut||T.declaredOut){let Y=j$($.out,T.out,W);if(Y instanceof g)return Y.throw();else X.declaredOut=Y}return U.distribute((Y)=>W.$.node("morph",{...X,in:Y}),W.$.parseSchema)},...c6("morph",($,T,W)=>{let U=$.inner.in?j$($.inner.in,T,W):T;return U instanceof g?U:U.equals($.inner.in)?$:W.$.node("morph",{...$.inner,in:U})})}});class NK extends O6{serializedMorphs=this.morphs.map(o$);compiledMorphs=`[${this.serializedMorphs}]`;lastMorph=this.inner.morphs.at(-1);lastMorphIfNode=d(this.lastMorph,"root")?this.lastMorph:void 0;introspectableIn=this.inner.in;introspectableOut=this.lastMorphIfNode?Object.assign(this.referencesById,this.lastMorphIfNode.referencesById)&&this.lastMorphIfNode.out:void 0;get shallowMorphs(){return Array.isArray(this.inner.in?.shallowMorphs)?[...this.inner.in.shallowMorphs,...this.morphs]:this.morphs}get in(){return this.declaredIn??this.inner.in?.in??v.intrinsic.unknown.internal}get out(){return this.declaredOut??this.introspectableOut??v.intrinsic.unknown.internal}declareIn($){return this.$.node("morph",{...this.inner,declaredIn:$})}declareOut($){return this.$.node("morph",{...this.inner,declaredOut:$})}expression=`(In: ${this.in.expression}) => ${this.lastMorphIfNode?"To":"Out"}<${this.out.expression}>`;get defaultShortDescription(){return this.in.meta.description??this.in.defaultShortDescription}innerToJsonSchema($){return $.fallback.morph({code:"morph",base:this.in.toJsonSchemaRecurse($),out:this.introspectableOut?.toJsonSchemaRecurse($)??null})}compile($){if($.traversalKind==="Allows"){if(!this.introspectableIn)return;$.return($.invoke(this.introspectableIn));return}if(this.introspectableIn)$.line($.invoke(this.introspectableIn));$.line(`ctx.queueMorphs(${this.compiledMorphs})`)}traverseAllows=($,T)=>!this.introspectableIn||this.introspectableIn.traverseAllows($,T);traverseApply=($,T)=>{if(this.introspectableIn)this.introspectableIn.traverseApply($,T);T.queueMorphs(this.morphs)};hasEqualMorphs($){return H1(this.morphs,$.morphs,{isEqual:(T,W)=>T===W||d(T,"root")&&d(W,"root")&&T.equals(W)})}}var r7={implementation:hq,Node:NK},gq=($,T)=>`The intersection of distinct morphs at a single path is indeterminate:
138
+ ${$.expected}`},intersections:{intersection:($,T,W)=>W_($.inner,T.inner,W),...F0("intersection",($,T,W)=>{if($.children.length===0)return T;let{domain:w,proto:X,...U}=$.inner,Y=X??w,G=Y?s$(Y,T,W):T;return G instanceof r?G:$?.basis?.equals(G)?$:$.$.node("intersection",{...U,[G.kind]:G},{prereduced:!0})})}});class X_ extends k1{basis=this.inner.domain??this.inner.proto??null;refinements=this.children.filter(($)=>$.isRefinement());structure=this.inner.structure;expression=ix(this);get shallowMorphs(){return this.inner.structure?.structuralMorph?[this.inner.structure.structuralMorph]:[]}get defaultShortDescription(){return this.basis?.defaultShortDescription??"present"}innerToJsonSchema($){return this.children.reduce((T,W)=>W.isBasis()?W.toJsonSchemaRecurse($):W.reduceJsonSchema(T,$),{})}traverseAllows=($,T)=>this.children.every((W)=>W.traverseAllows($,T));traverseApply=($,T)=>{let W=T.currentErrorCount;if(this.basis){if(this.basis.traverseApply($,T),T.currentErrorCount>W)return}if(this.refinements.length){for(let w=0;w<this.refinements.length-1;w++)if(this.refinements[w].traverseApply($,T),T.failFast&&T.currentErrorCount>W)return;if(this.refinements.at(-1).traverseApply($,T),T.currentErrorCount>W)return}if(this.structure){if(this.structure.traverseApply($,T),T.currentErrorCount>W)return}if(this.inner.predicate){for(let w=0;w<this.inner.predicate.length-1;w++)if(this.inner.predicate[w].traverseApply($,T),T.failFast&&T.currentErrorCount>W)return;this.inner.predicate.at(-1).traverseApply($,T)}};compile($){if($.traversalKind==="Allows"){for(let T of this.children)$.check(T);$.return(!0);return}if($.initializeErrorCount(),this.basis){if($.check(this.basis),this.children.length>1)$.returnIfFail()}if(this.refinements.length){for(let T=0;T<this.refinements.length-1;T++)$.check(this.refinements[T]),$.returnIfFailFast();if($.check(this.refinements.at(-1)),this.structure||this.inner.predicate)$.returnIfFail()}if(this.structure){if($.check(this.structure),this.inner.predicate)$.returnIfFail()}if(this.inner.predicate){for(let T=0;T<this.inner.predicate.length-1;T++)$.check(this.inner.predicate[T]),$.returnIfFail();$.check(this.inner.predicate.at(-1))}}}var QZ={implementation:nx,Node:X_},ix=($)=>{let T=$.structure?.expression||`${$.basis&&!$.refinements.some((W)=>W.impl.obviatesBasisExpression)?$.basis.nestableExpression+" ":""}${$.refinements.map((W)=>W.expression).join(" & ")}`||"unknown";if(T==="Array == 0")T="[]";return T},W_=($,T,W)=>{let w={},X=$.proto??$.domain,U=T.proto??T.domain,Y=X?U?s$(X,U,W):X:U;if(Y instanceof r)return Y;if(Y)w[Y.kind]=Y;return wX({kind:"intersection",baseInner:w,l:UX($),r:UX(T),roots:[],ctx:W})};var tx=D$({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:($,T)=>T.$.parseSchema($)},morphs:{parse:jT,serialize:($)=>$.map((T)=>W$(T,"root")?T.json:Z4(T))},declaredIn:{child:!1,serialize:($)=>$.json},declaredOut:{child:!1,serialize:($)=>$.json}},normalize:($)=>$,defaults:{description:($)=>`a morph from ${$.in.description} to ${$.out?.description??"unknown"}`},intersections:{morph:($,T,W)=>{if(!$.hasEqualMorphs(T))return B(ax($.expression,T.expression));let w=s$($.in,T.in,W);if(w instanceof r)return w;let X={morphs:$.morphs};if($.declaredIn||T.declaredIn){let U=s$($.in,T.in,W);if(U instanceof r)return U.throw();else X.declaredIn=U}if($.declaredOut||T.declaredOut){let U=s$($.out,T.out,W);if(U instanceof r)return U.throw();else X.declaredOut=U}return w.distribute((U)=>W.$.node("morph",{...X,in:U}),W.$.parseSchema)},...F0("morph",($,T,W)=>{let w=$.inner.in?s$($.inner.in,T,W):T;return w instanceof r?w:w.equals($.inner.in)?$:W.$.node("morph",{...$.inner,in:w})})}});class w_ extends k1{serializedMorphs=this.morphs.map(Z4);compiledMorphs=`[${this.serializedMorphs}]`;lastMorph=this.inner.morphs.at(-1);lastMorphIfNode=W$(this.lastMorph,"root")?this.lastMorph:void 0;introspectableIn=this.inner.in;introspectableOut=this.lastMorphIfNode?Object.assign(this.referencesById,this.lastMorphIfNode.referencesById)&&this.lastMorphIfNode.out:void 0;get shallowMorphs(){return Array.isArray(this.inner.in?.shallowMorphs)?[...this.inner.in.shallowMorphs,...this.morphs]:this.morphs}get in(){return this.declaredIn??this.inner.in?.in??y.intrinsic.unknown.internal}get out(){return this.declaredOut??this.introspectableOut??y.intrinsic.unknown.internal}declareIn($){return this.$.node("morph",{...this.inner,declaredIn:$})}declareOut($){return this.$.node("morph",{...this.inner,declaredOut:$})}expression=`(In: ${this.in.expression}) => ${this.lastMorphIfNode?"To":"Out"}<${this.out.expression}>`;get defaultShortDescription(){return this.in.meta.description??this.in.defaultShortDescription}innerToJsonSchema($){return $.fallback.morph({code:"morph",base:this.in.toJsonSchemaRecurse($),out:this.introspectableOut?.toJsonSchemaRecurse($)??null})}compile($){if($.traversalKind==="Allows"){if(!this.introspectableIn)return;$.return($.invoke(this.introspectableIn));return}if(this.introspectableIn)$.line($.invoke(this.introspectableIn));$.line(`ctx.queueMorphs(${this.compiledMorphs})`)}traverseAllows=($,T)=>!this.introspectableIn||this.introspectableIn.traverseAllows($,T);traverseApply=($,T)=>{if(this.introspectableIn)this.introspectableIn.traverseApply($,T);T.queueMorphs(this.morphs)};hasEqualMorphs($){return u0(this.morphs,$.morphs,{isEqual:(T,W)=>T===W||W$(T,"root")&&W$(W,"root")&&T.equals(W)})}}var ZZ={implementation:tx,Node:w_},ax=($,T)=>`The intersection of distinct morphs at a single path is indeterminate:
137
139
  Left: ${$}
138
- Right: ${T}`;var mq=_$({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:($)=>FU($)??H6($)},dateAllowsInvalid:{}},normalize:($)=>{let T=typeof $==="string"?{proto:y0[$]}:typeof $==="function"?C$($)?$:{proto:$}:typeof $.proto==="string"?{...$,proto:y0[$.proto]}:$;if(typeof T.proto!=="function")S(PU.writeInvalidSchemaMessage(T.proto));if(fT(T,"dateAllowsInvalid")&&T.proto!==Date)S(PU.writeBadInvalidDateMessage(T.proto));return T},applyConfig:($,T)=>{if($.dateAllowsInvalid===void 0&&$.proto===Date&&T.dateAllowsInvalid)return{...$,dateAllowsInvalid:!0};return $},defaults:{description:($)=>$.builtinName?VV[$.builtinName]:`an instance of ${$.proto.name}`,actual:($)=>$ instanceof Date&&$.toString()==="Invalid Date"?"an invalid Date":HU($)},intersections:{proto:($,T)=>$.proto===Date&&T.proto===Date?$.dateAllowsInvalid?T:$:Z7($.proto,T.proto)?$:Z7(T.proto,$.proto)?T:g.init("proto",$,T),domain:($,T)=>T.domain==="object"?$:g.init("domain",v.intrinsic.object.internal,T)}});class LK extends m0{builtinName=FU(this.proto);serializedConstructor=this.json.proto;requiresInvalidDateCheck=this.proto===Date&&!this.dateAllowsInvalid;traverseAllows=this.requiresInvalidDateCheck?($)=>$ instanceof Date&&$.toString()!=="Invalid Date":($)=>$ instanceof this.proto;compiledCondition=`data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck?' && data.toString() !== "Invalid Date"':""}`;compiledNegation=`!(${this.compiledCondition})`;innerToJsonSchema($){switch(this.builtinName){case"Array":return{type:"array"};case"Date":return $.fallback.date?.({code:"date",base:{}})??$.fallback.proto({code:"proto",base:{},proto:this.proto});default:return $.fallback.proto({code:"proto",base:{},proto:this.proto})}}expression=this.dateAllowsInvalid?"Date | InvalidDate":this.proto.name;get nestableExpression(){return this.dateAllowsInvalid?`(${this.expression})`:this.expression}domain="object";get defaultShortDescription(){return this.description}}var PU={implementation:mq,Node:LK,writeBadInvalidDateMessage:($)=>`dateAllowsInvalid may only be specified with constructor Date (was ${$.name})`,writeInvalidSchemaMessage:($)=>`instanceOf operand must be a function (was ${G4($)})`};var cq=_$({kind:"union",hasAssociatedError:!0,collapsibleKey:"branches",keys:{ordered:{},branches:{child:!0,parse:($,T)=>{let W=[];for(let U of $){let X=d(U,"root")?U.branches:T.$.parseSchema(U).branches;for(let Y of X)if(Y.hasKind("morph")){let _=W.findIndex((w)=>w.hasKind("morph")&&w.hasEqualMorphs(Y));if(_===-1)W.push(Y);else{let w=W[_];W[_]=T.$.node("morph",{...w.inner,in:w.in.rawOr(Y.in)})}}else W.push(Y)}if(!T.def.ordered)W.sort((U,X)=>U.hash<X.hash?-1:1);return W}}},normalize:($)=>I$($)?{branches:$}:$,reduce:($,T)=>{let W=aq($);if(W.length===1)return W[0];if(W.length===$.branches.length)return;return T.node("union",{...$,branches:W},{prereduced:!0})},defaults:{description:($)=>$.distribute((T)=>T.description,iT),expected:($)=>{let T=GV($.errors,"propString"),W=Object.entries(T).map(([U,X])=>{let Y=[];for(let G of X)g6(Y,G.expected);let _=iT(Y),w=X.every((G)=>G.actual===X[0].actual)?X[0].actual:Y$(X[0].data);return`${U&&`${U} `}must be ${_}${w&&` (was ${w})`}`});return iT(W)},problem:($)=>$.expected,message:($)=>$.problem},intersections:{union:($,T,W)=>{if($.isNever!==T.isNever)return g.init("presence",$,T);let U;if($.ordered){if(T.ordered)S(eq($.expression,T.expression));if(U=i7(T.branches,$.branches,W),U instanceof g)U.invert()}else U=i7($.branches,T.branches,W);if(U instanceof g)return U;return W.$.parseSchema($.ordered||T.ordered?{branches:U,ordered:!0}:{branches:U})},...c6("union",($,T,W)=>{let U=i7($.branches,[T],W);if(U instanceof g)return U;if(U.length===1)return U[0];return W.$.parseSchema($.ordered?{branches:U,ordered:!0}:{branches:U})})}});class RK extends O6{isBoolean=this.branches.length===2&&this.branches[0].hasUnit(!1)&&this.branches[1].hasUnit(!0);get branchGroups(){let $=[],T=-1;for(let W of this.branches){if(W.hasKind("unit")&&W.domain==="boolean"){if(T===-1)T=$.length,$.push(W);else $[T]=v.intrinsic.boolean;continue}$.push(W)}return $}unitBranches=this.branches.filter(($)=>$.in.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?iq(this.discriminant):null;expression=this.distribute(($)=>$.nestableExpression,tq);createBranchedOptimisticRootApply(){return($,T)=>{let W=this.traverseOptimistic($);if(W!==U6)return W;let U=new R6($,this.$.resolvedConfig);return this.traverseApply($,U),U.finalize(T)}}get shallowMorphs(){return this.branches.reduce(($,T)=>g6($,T.shallowMorphs),[])}get defaultShortDescription(){return this.distribute(($)=>$.defaultShortDescription,iT)}innerToJsonSchema($){if(this.branchGroups.length===1&&this.branchGroups[0].equals(v.intrinsic.boolean))return{type:"boolean"};let T=this.branchGroups.map((W)=>W.toJsonSchemaRecurse($));if(T.every((W)=>Object.keys(W).length===1&&fT(W,"const")))return{enum:T.map((W)=>W.const)};return{anyOf:T}}traverseAllows=($,T)=>this.branches.some((W)=>W.traverseAllows($,T));traverseApply=($,T)=>{let W=[];for(let U=0;U<this.branches.length;U++){if(T.pushBranch(),this.branches[U].traverseApply($,T),!T.hasError()){if(this.branches[U].includesTransform)return T.queuedMorphs.push(...T.popBranch().queuedMorphs);return T.popBranch()}W.push(T.popBranch().error)}T.errorFromNodeContext({code:"union",errors:W,meta:this.meta})};traverseOptimistic=($)=>{for(let T=0;T<this.branches.length;T++){let W=this.branches[T];if(W.traverseAllows($)){if(W.contextFreeMorph)return W.contextFreeMorph($);return $}}return U6};compile($){if(!this.discriminant||this.unitBranches.length===this.branches.length&&this.branches.length===2)return this.compileIndiscriminable($);let T=this.discriminant.optionallyChainedPropString;if(this.discriminant.kind==="domain")T=`typeof ${T} === "object" ? ${T} === null ? "null" : "object" : typeof ${T} === "function" ? "object" : typeof ${T}`;let W=this.discriminant.cases,U=Object.keys(W),{optimistic:X}=$;if($.optimistic=!1,$.block(`switch(${T})`,()=>{for(let J in W){let H=W[J],z=J==="default"?J:`case ${J}`;$.line(`${z}: return ${H===!0?X?$.data:H:X?`${$.invoke(H)} ? ${H.contextFreeMorph?`${o$(H.contextFreeMorph)}(${$.data})`:$.data} : "${U6}"`:$.invoke(H)}`)}return $}),$.traversalKind==="Allows"){$.return(X?`"${U6}"`:!1);return}let Y=iT(this.discriminant.kind==="domain"?U.map((J)=>{let H=J.slice(1,-1);return H==="function"?u4.object:u4[H]}):U),_=this.discriminant.path.map((J)=>typeof J==="symbol"?o$(J):JSON.stringify(J)),w=JSON.stringify(Y),G=this.discriminant.kind==="domain"?`${lq}[${T}]`:`${rq}(${T})`;$.line(`ctx.errorFromNodeContext({
140
+ Right: ${T}`;var sx=D$({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:($)=>_U($)??R1($)},dateAllowsInvalid:{}},normalize:($)=>{let T=typeof $==="string"?{proto:BW[$]}:typeof $==="function"?a$($)?$:{proto:$}:typeof $.proto==="string"?{...$,proto:BW[$.proto]}:$;if(typeof T.proto!=="function")B(pU.writeInvalidSchemaMessage(T.proto));if(a2(T,"dateAllowsInvalid")&&T.proto!==Date)B(pU.writeBadInvalidDateMessage(T.proto));return T},applyConfig:($,T)=>{if($.dateAllowsInvalid===void 0&&$.proto===Date&&T.dateAllowsInvalid)return{...$,dateAllowsInvalid:!0};return $},defaults:{description:($)=>$.builtinName?eJ[$.builtinName]:`an instance of ${$.proto.name}`,actual:($)=>$ instanceof Date&&$.toString()==="Invalid Date"?"an invalid Date":RU($)},intersections:{proto:($,T)=>$.proto===Date&&T.proto===Date?$.dateAllowsInvalid?T:$:bQ($.proto,T.proto)?$:bQ(T.proto,$.proto)?T:r.init("proto",$,T),domain:($,T)=>T.domain==="object"?$:r.init("domain",y.intrinsic.object.internal,T)}});class U_ extends bW{builtinName=_U(this.proto);serializedConstructor=this.json.proto;requiresInvalidDateCheck=this.proto===Date&&!this.dateAllowsInvalid;traverseAllows=this.requiresInvalidDateCheck?($)=>$ instanceof Date&&$.toString()!=="Invalid Date":($)=>$ instanceof this.proto;compiledCondition=`data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck?' && data.toString() !== "Invalid Date"':""}`;compiledNegation=`!(${this.compiledCondition})`;innerToJsonSchema($){switch(this.builtinName){case"Array":return{type:"array"};case"Date":return $.fallback.date?.({code:"date",base:{}})??$.fallback.proto({code:"proto",base:{},proto:this.proto});default:return $.fallback.proto({code:"proto",base:{},proto:this.proto})}}expression=this.dateAllowsInvalid?"Date | InvalidDate":this.proto.name;get nestableExpression(){return this.dateAllowsInvalid?`(${this.expression})`:this.expression}domain="object";get defaultShortDescription(){return this.description}}var pU={implementation:sx,Node:U_,writeBadInvalidDateMessage:($)=>`dateAllowsInvalid may only be specified with constructor Date (was ${$.name})`,writeInvalidSchemaMessage:($)=>`instanceOf operand must be a function (was ${f4($)})`};var ex=D$({kind:"union",hasAssociatedError:!0,collapsibleKey:"branches",keys:{ordered:{},branches:{child:!0,parse:($,T)=>{let W=[];for(let w of $){let X=W$(w,"root")?w.branches:T.$.parseSchema(w).branches;for(let U of X)if(U.hasKind("morph")){let Y=W.findIndex((G)=>G.hasKind("morph")&&G.hasEqualMorphs(U));if(Y===-1)W.push(U);else{let G=W[Y];W[Y]=T.$.node("morph",{...G.inner,in:G.in.rawOr(U.in)})}}else W.push(U)}if(!T.def.ordered)W.sort((w,X)=>w.hash<X.hash?-1:1);return W}}},normalize:($)=>o$($)?{branches:$}:$,reduce:($,T)=>{let W=Hf($);if(W.length===1)return W[0];if(W.length===$.branches.length)return;return T.node("union",{...$,branches:W},{prereduced:!0})},defaults:{description:($)=>$.distribute((T)=>T.description,HX),expected:($)=>{let T=oJ($.errors,"propString"),W=Object.entries(T).map(([w,X])=>{let U=[];for(let H of X)z0(U,H.expected);let Y=HX(U),G=X.every((H)=>H.actual===X[0].actual)?X[0].actual:M$(X[0].data);return`${w&&`${w} `}must be ${Y}${G&&` (was ${G})`}`});return HX(W)},problem:($)=>$.expected,message:($)=>$.problem},intersections:{union:($,T,W)=>{if($.isNever!==T.isNever)return r.init("presence",$,T);let w;if($.ordered){if(T.ordered)B(Of($.expression,T.expression));if(w=VZ(T.branches,$.branches,W),w instanceof r)w.invert()}else w=VZ($.branches,T.branches,W);if(w instanceof r)return w;return W.$.parseSchema($.ordered||T.ordered?{branches:w,ordered:!0}:{branches:w})},...F0("union",($,T,W)=>{let w=VZ($.branches,[T],W);if(w instanceof r)return w;if(w.length===1)return w[0];return W.$.parseSchema($.ordered?{branches:w,ordered:!0}:{branches:w})})}});class z_ extends k1{isBoolean=this.branches.length===2&&this.branches[0].hasUnit(!1)&&this.branches[1].hasUnit(!0);get branchGroups(){let $=[],T=-1;for(let W of this.branches){if(W.hasKind("unit")&&W.domain==="boolean"){if(T===-1)T=$.length,$.push(W);else $[T]=y.intrinsic.boolean;continue}$.push(W)}return $}unitBranches=this.branches.filter(($)=>$.in.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?Yf(this.discriminant):null;expression=this.distribute(($)=>$.nestableExpression,zf);createBranchedOptimisticRootApply(){return($,T)=>{let W=this.traverseOptimistic($);if(W!==Q1)return W;let w=new g1($,this.$.resolvedConfig);return this.traverseApply($,w),w.finalize(T)}}get shallowMorphs(){return this.branches.reduce(($,T)=>z0($,T.shallowMorphs),[])}get defaultShortDescription(){return this.distribute(($)=>$.defaultShortDescription,HX)}innerToJsonSchema($){if(this.branchGroups.length===1&&this.branchGroups[0].equals(y.intrinsic.boolean))return{type:"boolean"};let T=this.branchGroups.map((W)=>W.toJsonSchemaRecurse($));if(T.every((W)=>Object.keys(W).length===1&&a2(W,"const")))return{enum:T.map((W)=>W.const)};return{anyOf:T}}traverseAllows=($,T)=>this.branches.some((W)=>W.traverseAllows($,T));traverseApply=($,T)=>{let W=[];for(let w=0;w<this.branches.length;w++){if(T.pushBranch(),this.branches[w].traverseApply($,T),!T.hasError()){if(this.branches[w].includesTransform)return T.queuedMorphs.push(...T.popBranch().queuedMorphs);return T.popBranch()}W.push(T.popBranch().error)}T.errorFromNodeContext({code:"union",errors:W,meta:this.meta})};traverseOptimistic=($)=>{for(let T=0;T<this.branches.length;T++){let W=this.branches[T];if(W.traverseAllows($)){if(W.contextFreeMorph)return W.contextFreeMorph($);return $}}return Q1};compile($){if(!this.discriminant||this.unitBranches.length===this.branches.length&&this.branches.length===2)return this.compileIndiscriminable($);let T=this.discriminant.optionallyChainedPropString;if(this.discriminant.kind==="domain")T=`typeof ${T} === "object" ? ${T} === null ? "null" : "object" : typeof ${T} === "function" ? "object" : typeof ${T}`;let W=this.discriminant.cases,w=Object.keys(W),{optimistic:X}=$;if($.optimistic=!1,$.block(`switch(${T})`,()=>{for(let z in W){let F=W[z],O=z==="default"?z:`case ${z}`;$.line(`${O}: return ${F===!0?X?$.data:F:X?`${$.invoke(F)} ? ${F.contextFreeMorph?`${Z4(F.contextFreeMorph)}(${$.data})`:$.data} : "${Q1}"`:$.invoke(F)}`)}return $}),$.traversalKind==="Allows"){$.return(X?`"${Q1}"`:!1);return}let U=HX(this.discriminant.kind==="domain"?w.map((z)=>{let F=z.slice(1,-1);return F==="function"?d6.object:d6[F]}):w),Y=this.discriminant.path.map((z)=>typeof z==="symbol"?Z4(z):JSON.stringify(z)),G=JSON.stringify(U),H=this.discriminant.kind==="domain"?`${wf}[${T}]`:`${Uf}(${T})`;$.line(`ctx.errorFromNodeContext({
139
141
  code: "predicate",
140
- expected: ${w},
141
- actual: ${G},
142
- relativePath: [${_}],
142
+ expected: ${G},
143
+ actual: ${H},
144
+ relativePath: [${Y}],
143
145
  meta: ${this.compiledMeta}
144
- })`)}compileIndiscriminable($){if($.traversalKind==="Apply"){$.const("errors","[]");for(let T of this.branches)$.line("ctx.pushBranch()").line($.invoke(T)).if("!ctx.hasError()",()=>$.return(T.includesTransform?"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)":"ctx.popBranch()")).line("errors.push(ctx.popBranch().error)");$.line(`ctx.errorFromNodeContext({ code: "union", errors, meta: ${this.compiledMeta} })`)}else{let{optimistic:T}=$;$.optimistic=!1;for(let W of this.branches)$.if(`${$.invoke(W)}`,()=>$.return(T?W.contextFreeMorph?`${o$(W.contextFreeMorph)}(${$.data})`:$.data:!0));$.return(T?`"${U6}"`:!1)}}get nestableExpression(){return this.isBoolean?"boolean":`(${this.expression})`}discriminate(){if(this.branches.length<2||this.isCyclic)return null;if(this.unitBranches.length===this.branches.length){let X=X$(this.unitBranches,(Y,_)=>[`${_.in.serializedValue}`,_.hasKind("morph")?_:!0]);return{kind:"unit",path:[],optionallyChainedPropString:"data",cases:X}}let $=[];for(let X=0;X<this.branches.length-1;X++){let Y=this.branches[X];for(let _=X+1;_<this.branches.length;_++){let w=this.branches[_],G=d4(Y.in,w.in,Y.$);if(!(G instanceof g))continue;for(let J of G){if(!J.kind||J.optional)continue;let H,z;if(J.kind==="domain"){let{l:Q,r:V}=J;H=`"${typeof Q==="string"?Q:Q.domain}"`,z=`"${typeof V==="string"?V:V.domain}"`}else if(J.kind==="unit")H=J.l.serializedValue,z=J.r.serializedValue;else continue;let F=$.find((Q)=>H1(Q.path,J.path)&&Q.kind===J.kind);if(!F)$.push({kind:J.kind,cases:{[H]:{branchIndices:[X],condition:J.l},[z]:{branchIndices:[_],condition:J.r}},path:J.path});else{if(F.cases[H])F.cases[H].branchIndices=g6(F.cases[H].branchIndices,X);else F.cases[H]??={branchIndices:[X],condition:J.l};if(F.cases[z])F.cases[z].branchIndices=g6(F.cases[z].branchIndices,_);else F.cases[z]??={branchIndices:[_],condition:J.r}}}}}let T=this.ordered?oq($,this.branches):$;if(!T.length)return null;let W=uq(T,this),U={};for(let X in W.best.cases){let Y=pq(W,X);if(Y===null){U[X]=!0;continue}if(Y.length===this.branches.length)return null;if(this.ordered)Y.sort((G,J)=>G.originalIndex-J.originalIndex);let _=Y.map((G)=>G.branch),w=_.length===1?_[0]:this.$.node("union",this.ordered?{branches:_,ordered:!0}:_);Object.assign(this.referencesById,w.referencesById),U[X]=w}if(W.defaultEntries.length){let X=W.defaultEntries.map((Y)=>Y.branch);U.default=this.$.node("union",this.ordered?{branches:X,ordered:!0}:X,{prereduced:!0}),Object.assign(this.referencesById,U.default.referencesById)}return Object.assign(W.location,{cases:U})}}var uq=($,T)=>{let W=$.sort((Y,_)=>Object.keys(_.cases).length-Object.keys(Y.cases).length)[0],U={kind:W.kind,path:W.path,optionallyChainedPropString:IK(W.path)},X=T.branches.map((Y,_)=>({originalIndex:_,branch:Y}));return{best:W,location:U,defaultEntries:X,node:T}},pq=($,T)=>{let W=$.best.cases[T],U=dq(W.condition,$.location.path,$.node.$),X=[],Y=[];for(let _=0;_<$.defaultEntries.length;_++){let w=$.defaultEntries[_];if(W.branchIndices.includes(w.originalIndex)){let G=SK($.node.branches[w.originalIndex],$.location);if(G===null)X=null;else X?.push({originalIndex:w.originalIndex,branch:G})}else if(w.branch.hasKind("alias")&&U.hasKind("domain")&&U.domain==="object")X?.push(w);else{if(w.branch.in.overlaps(U)){let G=SK(w.branch,$.location);X?.push({originalIndex:w.originalIndex,branch:G})}Y.push(w)}}return $.defaultEntries=Y,X},oq=($,T)=>{return $.filter((U)=>{let X=Object.values(U.cases).map((Y)=>Y.branchIndices);for(let Y=0;Y<X.length-1;Y++){let _=X[Y];for(let w=Y+1;w<X.length;w++){let G=X[w];for(let J of _)for(let H of G)if(J>H){if(T[J].overlaps(T[H]))return!1}}}return!0})},dq=($,T,W)=>{let U=$==="undefined"?W.node("unit",{unit:void 0}):$==="null"?W.node("unit",{unit:null}):$==="boolean"?W.units([!0,!1]):$;for(let X=T.length-1;X>=0;X--){let Y=T[X];U=W.node("intersection",typeof Y==="number"?{proto:"Array",sequence:[...wV(Y).map((_)=>({})),U]}:{domain:"object",required:[{key:Y,value:U}]})}return U},IK=($)=>$.reduce((T,W)=>T+L7(W,!0),"data"),lq=o$(zV),rq=o$(Y$),n7={implementation:cq,Node:RK},iq=($)=>({kind:$.kind,path:$.path.map((T)=>typeof T==="string"?T:D1(T)),cases:X$($.cases,(T,W)=>[T,W===!0?W:W.hasKind("union")&&W.discriminantJson?W.discriminantJson:W.json])}),nq={delimiter:" | ",finalDelimiter:" | "},tq=($)=>iT($,nq),iT=($,T)=>{let W=T?.delimiter??", ",U=T?.finalDelimiter??" or ";if($.length===0)return"never";if($.length===1)return $[0];if($.length===2&&$[0]==="false"&&$[1]==="true"||$[0]==="true"&&$[1]==="false")return"boolean";let X={},Y=$.filter((w)=>X[w]?!1:X[w]=!0),_=Y.pop();return`${Y.join(W)}${Y.length?U:""}${_}`},i7=($,T,W)=>{let U=T.map(()=>[]);for(let Y=0;Y<$.length;Y++){let _={};for(let w=0;w<T.length;w++){if(U[w]===null)continue;if($[Y].equals(T[w])){U[w]=null,_={};break}let G=j$($[Y],T[w],W);if(G instanceof g)continue;if(G.equals($[Y])){U[w].push($[Y]),_={};break}if(G.equals(T[w]))U[w]=null;else _[w]=G}for(let w in _)U[w][Y]=_[w]}let X=U.flatMap((Y,_)=>Y?.flatMap((w)=>w.branches)??T[_]);return X.length===0?g.init("union",$,T):X},aq=({branches:$,ordered:T})=>{if($.length<2)return $;let W=$.map(()=>!0);for(let U=0;U<$.length;U++)for(let X=U+1;X<$.length&&W[U]&&W[X];X++){if($[U].equals($[X])){W[X]=!1;continue}let Y=d4($[U].in,$[X].in,$[0].$);if(Y instanceof g)continue;if(!T)sq($[U],$[X]);if(Y.equals($[U].in))W[U]=!!T;else if(Y.equals($[X].in))W[X]=!1}return $.filter((U,X)=>W[X])},sq=($,T)=>{if(!$.includesTransform&&!T.includesTransform)return;if(!H1($.shallowMorphs,T.shallowMorphs))S(BK($.expression,T.expression));if(!H1($.flatMorphs,T.flatMorphs,{isEqual:(W,U)=>W.propString===U.propString&&(W.node.hasKind("morph")&&U.node.hasKind("morph")?W.node.hasEqualMorphs(U.node):W.node.hasKind("intersection")&&U.node.hasKind("intersection")?W.node.structure?.structuralMorphRef===U.node.structure?.structuralMorphRef:!1)}))S(BK($.expression,T.expression))},SK=($,T)=>$.transform((W,U)=>{if(W==="domain"||W==="unit")return null;return U},{shouldTransform:(W,U)=>{let X=IK(U.path);if(!T.optionallyChainedPropString.startsWith(X))return!1;if(W.hasKind("domain")&&W.domain==="object")return!0;if((W.hasKind("domain")||T.kind==="unit")&&X===T.optionallyChainedPropString)return!0;return W.children.length!==0&&W.kind!=="index"}}),BK=($,T)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
146
+ })`)}compileIndiscriminable($){if($.traversalKind==="Apply"){$.const("errors","[]");for(let T of this.branches)$.line("ctx.pushBranch()").line($.invoke(T)).if("!ctx.hasError()",()=>$.return(T.includesTransform?"ctx.queuedMorphs.push(...ctx.popBranch().queuedMorphs)":"ctx.popBranch()")).line("errors.push(ctx.popBranch().error)");$.line(`ctx.errorFromNodeContext({ code: "union", errors, meta: ${this.compiledMeta} })`)}else{let{optimistic:T}=$;$.optimistic=!1;for(let W of this.branches)$.if(`${$.invoke(W)}`,()=>$.return(T?W.contextFreeMorph?`${Z4(W.contextFreeMorph)}(${$.data})`:$.data:!0));$.return(T?`"${Q1}"`:!1)}}get nestableExpression(){return this.isBoolean?"boolean":`(${this.expression})`}discriminate(){if(this.branches.length<2||this.isCyclic)return null;if(this.unitBranches.length===this.branches.length){let X=E$(this.unitBranches,(U,Y)=>[`${Y.in.serializedValue}`,Y.hasKind("morph")?Y:!0]);return{kind:"unit",path:[],optionallyChainedPropString:"data",cases:X}}let $=[];for(let X=0;X<this.branches.length-1;X++){let U=this.branches[X];for(let Y=X+1;Y<this.branches.length;Y++){let G=this.branches[Y],H=r6(U.in,G.in,U.$);if(!(H instanceof r))continue;for(let z of H){if(!z.kind||z.optional)continue;let F,O;if(z.kind==="domain"){let{l:Z,r:K}=z;F=`"${typeof Z==="string"?Z:Z.domain}"`,O=`"${typeof K==="string"?K:K.domain}"`}else if(z.kind==="unit")F=z.l.serializedValue,O=z.r.serializedValue;else continue;let Q=$.find((Z)=>u0(Z.path,z.path)&&Z.kind===z.kind);if(!Q)$.push({kind:z.kind,cases:{[F]:{branchIndices:[X],condition:z.l},[O]:{branchIndices:[Y],condition:z.r}},path:z.path});else{if(Q.cases[F])Q.cases[F].branchIndices=z0(Q.cases[F].branchIndices,X);else Q.cases[F]??={branchIndices:[X],condition:z.l};if(Q.cases[O])Q.cases[O].branchIndices=z0(Q.cases[O].branchIndices,Y);else Q.cases[O]??={branchIndices:[Y],condition:z.r}}}}}let T=this.ordered?Wf($,this.branches):$;if(!T.length)return null;let W=$f(T,this),w={};for(let X in W.best.cases){let U=Tf(W,X);if(U===null){w[X]=!0;continue}if(U.length===this.branches.length)return null;if(this.ordered)U.sort((H,z)=>H.originalIndex-z.originalIndex);let Y=U.map((H)=>H.branch),G=Y.length===1?Y[0]:this.$.node("union",this.ordered?{branches:Y,ordered:!0}:Y);Object.assign(this.referencesById,G.referencesById),w[X]=G}if(W.defaultEntries.length){let X=W.defaultEntries.map((U)=>U.branch);w.default=this.$.node("union",this.ordered?{branches:X,ordered:!0}:X,{prereduced:!0}),Object.assign(this.referencesById,w.default.referencesById)}return Object.assign(W.location,{cases:w})}}var $f=($,T)=>{let W=$.sort((U,Y)=>Object.keys(Y.cases).length-Object.keys(U.cases).length)[0],w={kind:W.kind,path:W.path,optionallyChainedPropString:H_(W.path)},X=T.branches.map((U,Y)=>({originalIndex:Y,branch:U}));return{best:W,location:w,defaultEntries:X,node:T}},Tf=($,T)=>{let W=$.best.cases[T],w=Xf(W.condition,$.location.path,$.node.$),X=[],U=[];for(let Y=0;Y<$.defaultEntries.length;Y++){let G=$.defaultEntries[Y];if(W.branchIndices.includes(G.originalIndex)){let H=Y_($.node.branches[G.originalIndex],$.location);if(H===null)X=null;else X?.push({originalIndex:G.originalIndex,branch:H})}else if(G.branch.hasKind("alias")&&w.hasKind("domain")&&w.domain==="object")X?.push(G);else{if(G.branch.in.overlaps(w)){let H=Y_(G.branch,$.location);X?.push({originalIndex:G.originalIndex,branch:H})}U.push(G)}}return $.defaultEntries=U,X},Wf=($,T)=>{return $.filter((w)=>{let X=Object.values(w.cases).map((U)=>U.branchIndices);for(let U=0;U<X.length-1;U++){let Y=X[U];for(let G=U+1;G<X.length;G++){let H=X[G];for(let z of Y)for(let F of H)if(z>F){if(T[z].overlaps(T[F]))return!1}}}return!0})},Xf=($,T,W)=>{let w=$==="undefined"?W.node("unit",{unit:void 0}):$==="null"?W.node("unit",{unit:null}):$==="boolean"?W.units([!0,!1]):$;for(let X=T.length-1;X>=0;X--){let U=T[X];w=W.node("intersection",typeof U==="number"?{proto:"Array",sequence:[...pJ(U).map((Y)=>({})),w]}:{domain:"object",required:[{key:U,value:w}]})}return w},H_=($)=>$.reduce((T,W)=>T+pQ(W,!0),"data"),wf=Z4(lJ),Uf=Z4(M$),KZ={implementation:ex,Node:z_},Yf=($)=>({kind:$.kind,path:$.path.map((T)=>typeof T==="string"?T:o0(T)),cases:E$($.cases,(T,W)=>[T,W===!0?W:W.hasKind("union")&&W.discriminantJson?W.discriminantJson:W.json])}),Gf={delimiter:" | ",finalDelimiter:" | "},zf=($)=>HX($,Gf),HX=($,T)=>{let W=T?.delimiter??", ",w=T?.finalDelimiter??" or ";if($.length===0)return"never";if($.length===1)return $[0];if($.length===2&&$[0]==="false"&&$[1]==="true"||$[0]==="true"&&$[1]==="false")return"boolean";let X={},U=$.filter((G)=>X[G]?!1:X[G]=!0),Y=U.pop();return`${U.join(W)}${U.length?w:""}${Y}`},VZ=($,T,W)=>{let w=T.map(()=>[]);for(let U=0;U<$.length;U++){let Y={};for(let G=0;G<T.length;G++){if(w[G]===null)continue;if($[U].equals(T[G])){w[G]=null,Y={};break}let H=s$($[U],T[G],W);if(H instanceof r)continue;if(H.equals($[U])){w[G].push($[U]),Y={};break}if(H.equals(T[G]))w[G]=null;else Y[G]=H}for(let G in Y)w[G][U]=Y[G]}let X=w.flatMap((U,Y)=>U?.flatMap((G)=>G.branches)??T[Y]);return X.length===0?r.init("union",$,T):X},Hf=({branches:$,ordered:T})=>{if($.length<2)return $;let W=$.map(()=>!0);for(let w=0;w<$.length;w++)for(let X=w+1;X<$.length&&W[w]&&W[X];X++){if($[w].equals($[X])){W[X]=!1;continue}let U=r6($[w].in,$[X].in,$[0].$);if(U instanceof r)continue;if(!T)Ff($[w],$[X]);if(U.equals($[w].in))W[w]=!!T;else if(U.equals($[X].in))W[X]=!1}return $.filter((w,X)=>W[X])},Ff=($,T)=>{if(!$.includesTransform&&!T.includesTransform)return;if(!u0($.shallowMorphs,T.shallowMorphs))B(G_($.expression,T.expression));if(!u0($.flatMorphs,T.flatMorphs,{isEqual:(W,w)=>W.propString===w.propString&&(W.node.hasKind("morph")&&w.node.hasKind("morph")?W.node.hasEqualMorphs(w.node):W.node.hasKind("intersection")&&w.node.hasKind("intersection")?W.node.structure?.structuralMorphRef===w.node.structure?.structuralMorphRef:!1)}))B(G_($.expression,T.expression))},Y_=($,T)=>$.transform((W,w)=>{if(W==="domain"||W==="unit")return null;return w},{shouldTransform:(W,w)=>{let X=H_(w.path);if(!T.optionallyChainedPropString.startsWith(X))return!1;if(W.hasKind("domain")&&W.domain==="object")return!0;if((W.hasKind("domain")||T.kind==="unit")&&X===T.optionallyChainedPropString)return!0;return W.children.length!==0&&W.kind!=="index"}}),G_=($,T)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
145
147
  Left: ${$}
146
- Right: ${T}`,eq=($,T)=>`The intersection of two ordered unions is indeterminate:
148
+ Right: ${T}`,Of=($,T)=>`The intersection of two ordered unions is indeterminate:
147
149
  Left: ${$}
148
- Right: ${T}`;var $P=_$({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:($)=>$ instanceof Date?$.toISOString():H6($)}},normalize:($)=>$,defaults:{description:($)=>Y$($.unit),problem:({expected:$,actual:T})=>`${$===T?`must be reference equal to ${$} (serialized to the same value)`:`must be ${$} (was ${T})`}`},intersections:{unit:($,T)=>g.init("unit",$,T),...c6("unit",($,T)=>{if(T.allows($.unit))return $;let W=T.hasKind("intersection")?T.basis:T;if(W){let U=W.hasKind("domain")?W:v.intrinsic.object;if($.domain!==U.domain){let X=$.domain==="undefined"||$.domain==="null"||$.domain==="boolean"?$.domain:v.intrinsic[$.domain];return g.init("domain",X,U)}}return g.init("assignability",$,T.hasKind("intersection")?T.children.find((U)=>!U.allows($.unit)):T)})}});class vK extends m0{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=kK(this.unit,this.serializedValue);compiledNegation=kK(this.unit,this.serializedValue,"negated");expression=Y$(this.unit);domain=G4(this.unit);get defaultShortDescription(){return this.domain==="object"?u4.object:this.description}innerToJsonSchema($){return this.unit===null?{type:"null"}:v.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:$.fallback.unit({code:"unit",base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?($)=>$ instanceof Date&&$.toISOString()===this.compiledValue:Number.isNaN(this.unit)?($)=>Number.isNaN($):($)=>$===this.unit}var t7={implementation:$P,Node:vK},kK=($,T,W)=>{if($ instanceof Date){let U=`data instanceof Date && data.toISOString() === ${T}`;return W?`!(${U})`:U}if(Number.isNaN($))return`${W?"!":""}Number.isNaN(data)`;return`data ${W?"!":"="}== ${T}`};var TP=_$({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:($,T)=>{let W=T.$.parseSchema($);if(!W.extends(v.intrinsic.key))return S(UP(W.expression));let U=W.branches.filter((X)=>X.hasKind("unit"));if(U.length)return S(WP(U.map((X)=>Y$(X.unit))));return W}},value:{child:!0,parse:($,T)=>T.$.parseSchema($)}},normalize:($)=>$,defaults:{description:($)=>`[${$.signature.expression}]: ${$.value.description}`},intersections:{index:($,T,W)=>{if($.signature.equals(T.signature)){let U=j$($.value,T.value,W),X=U instanceof g?v.intrinsic.never.internal:U;return W.$.node("index",{signature:$.signature,value:X})}if($.signature.extends(T.signature)&&$.value.subsumes(T.value))return T;if(T.signature.extends($.signature)&&T.value.subsumes($.value))return $;return null}}});class qK extends F6{impliedBasis=v.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=O$(this.value.flatRefs.map(($)=>I6([this.signature,...$.path],$.node)),I6([this.signature],this.value));traverseAllows=($,T)=>f0($).every((W)=>{if(this.signature.traverseAllows(W[0],T))return o4(W[0],()=>this.value.traverseAllows(W[1],T),T);return!0});traverseApply=($,T)=>{for(let W of f0($))if(this.signature.traverseAllows(W[0],T))o4(W[0],()=>this.value.traverseApply(W[1],T),T)};_transform($,T){T.path.push(this.signature);let W=super._transform($,T);return T.path.pop(),W}compile(){}}var a7={implementation:TP,Node:qK},WP=($)=>`Index keys ${$.join(", ")} should be specified as named props.`,UP=($)=>`Indexed key definition '${$}' must be a string or symbol`;var XP=_$({kind:"required",hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:($,T)=>T.$.parseSchema($)}},normalize:($)=>$,defaults:{description:($)=>`${$.compiledKey}: ${$.value.description}`,expected:($)=>$.missingValueDescription,actual:()=>"missing"},intersections:{required:BU,optional:BU}});class PK extends RU{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=l1(this.errorContext)}var s7={implementation:XP,Node:PK};var YP=_$({kind:"sequence",hasAssociatedError:!1,collapsibleKey:"variadic",keys:{prefix:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}},optionals:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}},defaultables:{child:($)=>$.map((T)=>T[0]),parse:($,T)=>{if($.length===0)return;return $.map((W)=>{let U=T.$.parseSchema(W[0]);return kU(U,W[1],null),[U,W[1]]})},serialize:($)=>$.map((T)=>[T[0].collapsibleJson,H6(T[1])])},variadic:{child:!0,parse:($,T)=>T.$.parseSchema($,T)},minVariadicLength:{parse:($)=>$===0?void 0:$},postfix:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}}},normalize:($)=>{if(typeof $==="string")return{variadic:$};if("variadic"in $||"prefix"in $||"defaultables"in $||"optionals"in $||"postfix"in $||"minVariadicLength"in $){if($.postfix?.length){if(!$.variadic)return S(GP);if($.optionals?.length||$.defaultables?.length)return S($5)}if($.minVariadicLength&&!$.variadic)return S("minVariadicLength may not be specified without a variadic element");return $}return{variadic:$}},reduce:($,T)=>{let W=$.minVariadicLength??0,U=$.prefix?.slice()??[],X=$.defaultables?.slice()??[],Y=$.optionals?.slice()??[],_=$.postfix?.slice()??[];if($.variadic){while(Y.at(-1)?.equals($.variadic))Y.pop();if(Y.length===0&&X.length===0)while(U.at(-1)?.equals($.variadic))U.pop(),W++;while(_[0]?.equals($.variadic))_.shift(),W++}else if(Y.length===0&&X.length===0)U.push(..._.splice(0));if(W!==$.minVariadicLength||$.prefix&&$.prefix.length!==U.length)return T.node("sequence",{...$,prefix:U,defaultables:X,optionals:Y,postfix:_,minVariadicLength:W},{prereduced:!0})},defaults:{description:($)=>{if($.isVariadicOnly)return`${$.variadic.nestableExpression}[]`;return`[${$.tuple.map((W)=>W.kind==="defaultables"?`${W.node.nestableExpression} = ${Y$(W.default)}`:W.kind==="optionals"?`${W.node.nestableExpression}?`:W.kind==="variadic"?`...${W.node.nestableExpression}[]`:W.node.expression).join(", ")}]`}},intersections:{sequence:($,T,W)=>{let U=CU({l:$.tuple,r:T.tuple,disjoint:new g,result:[],fixedVariants:[],ctx:W}),X=U.disjoint.length===0?[U,...U.fixedVariants]:U.fixedVariants;return X.length===0?U.disjoint:X.length===1?W.$.node("sequence",CK(X[0].result)):W.$.node("union",X.map((Y)=>({proto:Array,sequence:CK(Y.result)})))}}});class jK extends F6{impliedBasis=v.intrinsic.Array.internal;tuple=JP(this.inner);prefixLength=this.prefix?.length??0;defaultablesLength=this.defaultables?.length??0;optionalsLength=this.optionals?.length??0;postfixLength=this.postfix?.length??0;defaultablesAndOptionals=[];prevariadic=this.tuple.filter(($)=>{if($.kind==="defaultables"||$.kind==="optionals")return this.defaultablesAndOptionals.push($.node),!0;return $.kind==="prefix"});variadicOrPostfix=z1(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return I7(this.flatRefs,this.prevariadic.flatMap(($,T)=>O$($.node.flatRefs.map((W)=>I6([`${T}`,...W.path],W.node)),I6([`${T}`],$.node)))),I7(this.flatRefs,this.variadicOrPostfix.flatMap(($)=>O$($.flatRefs.map((T)=>I6([v.intrinsic.nonNegativeIntegerString.internal,...T.path],T.node)),I6([v.intrinsic.nonNegativeIntegerString.internal],$)))),this.flatRefs}isVariadicOnly=this.prevariadic.length+this.postfixLength===0;minVariadicLength=this.inner.minVariadicLength??0;minLength=this.prefixLength+this.minVariadicLength+this.postfixLength;minLengthNode=this.minLength===0?null:this.$.node("minLength",this.minLength);maxLength=this.variadic?null:this.tuple.length;maxLengthNode=this.maxLength===null?null:this.$.node("maxLength",this.maxLength);impliedSiblings=this.minLengthNode?this.maxLengthNode?[this.minLengthNode,this.maxLengthNode]:[this.minLengthNode]:this.maxLengthNode?[this.maxLengthNode]:[];defaultValueMorphs=wP(this);defaultValueMorphsReference=this.defaultValueMorphs.length?o$(this.defaultValueMorphs):void 0;elementAtIndex($,T){if(T<this.prevariadic.length)return this.tuple[T];let W=$.length-this.postfixLength;if(T>=W)return{kind:"postfix",node:this.postfix[T-W]};return{kind:"variadic",node:this.variadic??Z$(`Unexpected attempt to access index ${T} on ${this}`)}}traverseAllows=($,T)=>{for(let W=0;W<$.length;W++)if(!this.elementAtIndex($,W).node.traverseAllows($[W],T))return!1;return!0};traverseApply=($,T)=>{let W=0;for(;W<$.length;W++)o4(W,()=>this.elementAtIndex($,W).node.traverseApply($[W],T),T)};get element(){return this.cacheGetter("element",this.$.node("union",this.children))}compile($){if(this.prefix)for(let[T,W]of this.prefix.entries())$.traverseKey(`${T}`,`data[${T}]`,W);for(let[T,W]of this.defaultablesAndOptionals.entries()){let U=`${T+this.prefixLength}`;$.if(`${U} >= ${$.data}.length`,()=>$.traversalKind==="Allows"?$.return(!0):$.return()),$.traverseKey(U,`data[${U}]`,W)}if(this.variadic){if(this.postfix)$.const("firstPostfixIndex",`${$.data}.length${this.postfix?`- ${this.postfix.length}`:""}`);if($.for(`i < ${this.postfix?"firstPostfixIndex":"data.length"}`,()=>$.traverseKey("i","data[i]",this.variadic),this.prevariadic.length),this.postfix)for(let[T,W]of this.postfix.entries()){let U=`firstPostfixIndex + ${T}`;$.traverseKey(U,`data[${U}]`,W)}}if($.traversalKind==="Allows")$.return(!0)}_transform($,T){T.path.push(v.intrinsic.nonNegativeIntegerString.internal);let W=super._transform($,T);return T.path.pop(),W}expression=this.description;reduceJsonSchema($,T){if(this.prevariadic.length)$.prefixItems=this.prevariadic.map((W)=>{let U=W.node.toJsonSchemaRecurse(T);if(W.kind==="defaultables"){let X=typeof W.default==="function"?W.default():W.default;U.default=v.intrinsic.jsonData.allows(X)?X:T.fallback.defaultValue({code:"defaultValue",base:U,value:X})}return U});if(this.minLength)$.minItems=this.minLength;if(this.variadic){let W=Object.assign($,{items:this.variadic.toJsonSchemaRecurse(T)});if(this.maxLength)W.maxItems=this.maxLength;if(this.postfix){let U=this.postfix.map((X)=>X.toJsonSchemaRecurse(T));$=T.fallback.arrayPostfix({code:"arrayPostfix",base:W,elements:U})}}else $.items=!1,delete $.maxItems;return $}}var _P={},wP=($)=>{if(!$.defaultables)return[];let T=[],W="[",U=$.prefixLength+$.defaultablesLength-1;for(let X=$.prefixLength;X<=U;X++){let[Y,_]=$.defaultables[X-$.prefixLength];T.push(d7(X,Y,_)),W+=`${X}: ${Y.id} = ${H6(_)}, `}return W+="]",_P[W]??=T},e7={implementation:YP,Node:jK},JP=($)=>{let T=[];if($.prefix)for(let W of $.prefix)T.push({kind:"prefix",node:W});if($.defaultables)for(let[W,U]of $.defaultables)T.push({kind:"defaultables",node:W,default:U});if($.optionals)for(let W of $.optionals)T.push({kind:"optionals",node:W});if($.variadic)T.push({kind:"variadic",node:$.variadic});if($.postfix)for(let W of $.postfix)T.push({kind:"postfix",node:W});return T},CK=($)=>$.reduce((T,W)=>{if(W.kind==="variadic")T.variadic=W.node;else if(W.kind==="defaultables")T.defaultables=O$(T.defaultables,[[W.node,W.default]]);else T[W.kind]=O$(T[W.kind],W.node);return T},{}),$5="A postfix required element cannot follow an optional or defaultable element",GP="A postfix element requires a variadic element",CU=($)=>{let[T,...W]=$.l,[U,...X]=$.r;if(!T||!U)return $;let Y=W.at(-1)?.kind==="postfix",_=X.at(-1)?.kind==="postfix",w=T.kind==="prefix"||U.kind==="prefix"?"prefix":T.kind==="postfix"||U.kind==="postfix"?"postfix":T.kind==="variadic"&&U.kind==="variadic"?"variadic":Y||_?"prefix":T.kind==="defaultables"||U.kind==="defaultables"?"defaultables":"optionals";if(T.kind==="prefix"&&U.kind==="variadic"&&_){let z=CU({...$,fixedVariants:[],r:X.map((F)=>({...F,kind:"prefix"}))});if(z.disjoint.length===0)$.fixedVariants.push(z)}else if(U.kind==="prefix"&&T.kind==="variadic"&&Y){let z=CU({...$,fixedVariants:[],l:W.map((F)=>({...F,kind:"prefix"}))});if(z.disjoint.length===0)$.fixedVariants.push(z)}let G=j$(T.node,U.node,$.ctx);if(G instanceof g)if(w==="prefix"||w==="postfix")$.disjoint.push(...G.withPrefixKey(w==="prefix"?$.result.length:`-${W.length+1}`,"required")),$.result=[...$.result,{kind:w,node:v.intrinsic.never.internal}];else if(w==="optionals"||w==="defaultables")return $;else return CU({...$,fixedVariants:[],l:W.map((z)=>({...z,kind:"prefix"})),r:W.map((z)=>({...z,kind:"prefix"}))});else if(w==="defaultables"){if(T.kind==="defaultables"&&U.kind==="defaultables"&&T.default!==U.default)S(o7(T.default,U.default));$.result=[...$.result,{kind:w,node:G,default:T.kind==="defaultables"?T.default:U.kind==="defaultables"?U.default:Z$(`Unexpected defaultable intersection from ${T.kind} and ${U.kind} elements.`)}]}else $.result=[...$.result,{kind:w,node:G}];let J=$.l.length,H=$.r.length;if(T.kind!=="variadic"||J>=H&&(U.kind==="variadic"||H===1))$.l=W;if(U.kind!=="variadic"||H>=J&&(T.kind==="variadic"||J===1))$.r=X;return CU($)};var fK=($)=>(T)=>{if(T.props.length||T.index){let W=T.index?.map((X)=>X[$])??[];for(let X of T.props)W.push(X[$]);if(T.undeclared)W.push(`+ (undeclared): ${T.undeclared}`);let U=`{ ${W.join(", ")} }`;return T.sequence?`${U} & ${T.sequence.description}`:U}return T.sequence?.description??"{}"},zP=fK("description"),HP=fK("expression"),xK=($,T,W)=>{let U=$.required?"required":"optional";if(!T.signature.allows($.key))return null;let X=d4($.value,T.value,W);if(X instanceof g)return U==="optional"?W.node("optional",{key:$.key,value:v.intrinsic.never.internal}):X.withPrefixKey($.key,$.kind);return null},FP=_$({kind:"structure",hasAssociatedError:!1,normalize:($)=>$,applyConfig:($,T)=>{if(!$.undeclared&&T.onUndeclaredKey!=="ignore")return{...$,undeclared:T.onUndeclaredKey};return $},keys:{required:{child:!0,parse:S4("required"),reduceIo:($,T,W)=>{T.required=O$(T.required,W.map((U)=>U[$]));return}},optional:{child:!0,parse:S4("optional"),reduceIo:($,T,W)=>{if($==="in"){T.optional=W.map((U)=>U.in);return}for(let U of W)T[U.outProp.kind]=O$(T[U.outProp.kind],U.outProp.out)}},index:{child:!0,parse:S4("index")},sequence:{child:!0,parse:S4("sequence")},undeclared:{parse:($)=>$==="ignore"?void 0:$,reduceIo:($,T,W)=>{if(W!=="delete")return;if($==="in")delete T.undeclared;else T.undeclared="reject"}}},defaults:{description:zP},intersections:{structure:($,T,W)=>{let U={...$.inner},X={...T.inner},Y=new g;if($.undeclared){let G=$.keyof();for(let J of T.requiredKeys)if(!G.allows(J))Y.add("presence",v.intrinsic.never.internal,T.propsByKey[J].value,{path:[J]});if(X.optional)X.optional=X.optional.filter((J)=>G.allows(J.key));if(X.index)X.index=X.index.flatMap((J)=>{if(J.signature.extends(G))return J;let H=d4(G,J.signature,W.$);if(H instanceof g)return[];let z=R8(H,J.value,W.$);if(z.required)X.required=z1(X.required,z.required);if(z.optional)X.optional=z1(X.optional,z.optional);return z.index??[]})}if(T.undeclared){let G=T.keyof();for(let J of $.requiredKeys)if(!G.allows(J))Y.add("presence",$.propsByKey[J].value,v.intrinsic.never.internal,{path:[J]});if(U.optional)U.optional=U.optional.filter((J)=>G.allows(J.key));if(U.index)U.index=U.index.flatMap((J)=>{if(J.signature.extends(G))return J;let H=d4(G,J.signature,W.$);if(H instanceof g)return[];let z=R8(H,J.value,W.$);if(z.required)U.required=z1(U.required,z.required);if(z.optional)U.optional=z1(U.optional,z.optional);return z.index??[]})}let _={};if($.undeclared||T.undeclared)_.undeclared=$.undeclared==="reject"||T.undeclared==="reject"?"reject":"delete";let w=pT({kind:"structure",baseInner:_,l:oT(U),r:oT(X),roots:[],ctx:W});if(w instanceof g)Y.push(...w);if(Y.length)return Y;return w}},reduce:($,T)=>{if($.index){if(!($.required||$.optional))return;let W=!1,U=$.required??[],X=$.optional??[],Y=[...X];for(let _ of $.index){for(let w of U){let G=xK(w,_,T);if(G instanceof g)return G}for(let[w,G]of X.entries()){let J=xK(G,_,T);if(J instanceof g)return J;if(J===null)continue;Y[w]=J,W=!0}}if(W)return T.node("structure",{...$,optional:Y},{prereduced:!0})}}});class yK extends F6{impliedBasis=v.intrinsic.object.internal;impliedSiblings=this.children.flatMap(($)=>$.impliedSiblings??[]);props=z1(this.required,this.optional);propsByKey=X$(this.props,($,T)=>[T.key,T]);propsByKeyReference=o$(this.propsByKey);expression=HP(this);requiredKeys=this.required?.map(($)=>$.key)??[];optionalKeys=this.optional?.map(($)=>$.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let $=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:T}of this.index)$=$.concat(T.branches);return this._keyof=this.$.node("union",$)}map($){return this.$.node("structure",this.props.flatMap($).reduce((T,W)=>{let U=this.propsByKey[W.key];if(C$(W)){if(W.kind!=="required"&&W.kind!=="optional")return S(`Map result must have kind "required" or "optional" (was ${W.kind})`);return T[W.kind]=O$(T[W.kind],W),T}let X=W.kind??U?.kind??"required",Y=X$(W,(_,w)=>(_ in IU.implementation.keys)?[_,w]:[]);return T[X]=O$(T[X],this.$.node(X,Y)),T},{}))}assertHasKeys($){let T=$.filter((W)=>!vU(W,this.keyof()));if(T.length)return S(bK(this.expression,T))}get($,...T){let W,U=!1,X=ZP($);if((typeof X==="string"||typeof X==="symbol")&&this.propsByKey[X])W=this.propsByKey[X].value,U=this.propsByKey[X].required;if(this.index){for(let _ of this.index)if(vU(X,_.signature))W=W?.and(_.value)??_.value}if(this.sequence&&vU(X,v.intrinsic.nonNegativeIntegerString))if(d(X,"root")){if(this.sequence.variadic)W=W?.and(this.sequence.element)??this.sequence.element}else{let _=Number.parseInt(X);if(_<this.sequence.prevariadic.length){let w=this.sequence.prevariadic[_].node;W=W?.and(w)??w,U||=_<this.sequence.prefixLength}else if(this.sequence.variadic){let w=this.$.node("union",this.sequence.variadicOrPostfix);W=W?.and(w)??w}}if(!W){if(this.sequence?.variadic&&d(X,"root")&&X.extends(v.intrinsic.number))return S(VP(X.expression,this.sequence.expression));return S(bK(this.expression,[X]))}let Y=W.get(...T);return U?Y:Y.or(v.intrinsic.undefined)}pick(...$){return this.assertHasKeys($),this.$.node("structure",this.filterKeys("pick",$))}omit(...$){return this.assertHasKeys($),this.$.node("structure",this.filterKeys("omit",$))}optionalize(){let{required:$,...T}=this.inner;return this.$.node("structure",{...T,optional:this.props.map((W)=>W.hasKind("required")?this.$.node("optional",W.inner):W)})}require(){let{optional:$,...T}=this.inner;return this.$.node("structure",{...T,required:this.props.map((W)=>W.hasKind("optional")?{key:W.key,value:W.value}:W)})}merge($){let T=this.filterKeys("omit",[$.keyof()]);if($.required)T.required=O$(T.required,$.required);if($.optional)T.optional=O$(T.optional,$.optional);if($.index)T.index=O$(T.index,$.index);if($.sequence)T.sequence=$.sequence;if($.undeclared)T.undeclared=$.undeclared;else delete T.undeclared;return this.$.node("structure",T)}filterKeys($,T){let W=Q8(this.inner),U=(X)=>{let Y=T.some((_)=>vU(X,_));return $==="pick"?Y:!Y};if(W.required)W.required=W.required.filter((X)=>U(X.key));if(W.optional)W.optional=W.optional.filter((X)=>U(X.key));if(W.index)W.index=W.index.filter((X)=>U(X.signature));return W}traverseAllows=($,T)=>this._traverse("Allows",$,T);traverseApply=($,T)=>this._traverse("Apply",$,T);_traverse=($,T,W)=>{let U=W?.currentErrorCount??0;for(let X=0;X<this.props.length;X++)if($==="Allows"){if(!this.props[X].traverseAllows(T,W))return!1}else if(this.props[X].traverseApply(T,W),W.failFast&&W.currentErrorCount>U)return!1;if(this.sequence){if($==="Allows"){if(!this.sequence.traverseAllows(T,W))return!1}else if(this.sequence.traverseApply(T,W),W.failFast&&W.currentErrorCount>U)return!1}if(this.index||this.undeclared==="reject"){let X=Object.keys(T);X.push(...Object.getOwnPropertySymbols(T));for(let Y=0;Y<X.length;Y++){let _=X[Y];if(this.index){for(let w of this.index)if(w.signature.traverseAllows(_,W)){if($==="Allows"){if(!o4(_,()=>w.value.traverseAllows(T[_],W),W))return!1}else if(o4(_,()=>w.value.traverseApply(T[_],W),W),W.failFast&&W.currentErrorCount>U)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(_)){if($==="Allows")return!1;if(W.errorFromNodeContext({code:"predicate",expected:"removed",actual:"",relativePath:[_],meta:this.meta}),W.failFast)return!1}}}if(this.structuralMorph&&W&&!W.hasError())W.queueMorphs([this.structuralMorph]);return!0};get defaultable(){return this.cacheGetter("defaultable",this.optional?.filter(($)=>$.hasDefault())??[])}declaresKey=($)=>($ in this.propsByKey)||this.index?.some((T)=>T.signature.allows($))||this.sequence!==void 0&&v.intrinsic.nonNegativeIntegerString.allows($);_compileDeclaresKey($){let T=[];if(this.props.length)T.push(`k in ${this.propsByKeyReference}`);if(this.index)for(let W of this.index)T.push($.invoke(W.signature,{kind:"Allows",arg:"k"}));if(this.sequence)T.push("$ark.intrinsic.nonNegativeIntegerString.allows(k)");return T.join(" || ")||"false"}get structuralMorph(){return this.cacheGetter("structuralMorph",DP(this))}structuralMorphRef=this.structuralMorph&&o$(this.structuralMorph);compile($){if($.traversalKind==="Apply")$.initializeErrorCount();for(let T of this.props)if($.check(T),$.traversalKind==="Apply")$.returnIfFailFast();if(this.sequence){if($.check(this.sequence),$.traversalKind==="Apply")$.returnIfFailFast()}if(this.index||this.undeclared==="reject")$.const("keys","Object.keys(data)"),$.line("keys.push(...Object.getOwnPropertySymbols(data))"),$.for("i < keys.length",()=>this.compileExhaustiveEntry($));if($.traversalKind==="Allows")return $.return(!0);if(this.structuralMorphRef)$.if("ctx && !ctx.hasError()",()=>{return $.line("ctx.queueMorphs(["),QP($,this),$.line("])")})}compileExhaustiveEntry($){if($.const("k","keys[i]"),this.index)for(let T of this.index)$.if(`${$.invoke(T.signature,{arg:"k",kind:"Allows"})}`,()=>$.traverseKey("k","data[k]",T.value));if(this.undeclared==="reject")$.if(`!(${this._compileDeclaresKey($)})`,()=>{if($.traversalKind==="Allows")return $.return(!1);return $.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast",()=>$.return())});return $}reduceJsonSchema($,T){switch($.type){case"object":return this.reduceObjectJsonSchema($,T);case"array":let W=this.sequence?.reduceJsonSchema($,T)??$;if(this.props.length||this.index)return T.fallback.arrayObject({code:"arrayObject",base:W,object:this.reduceObjectJsonSchema({type:"object"},T)});return W;default:return y$.throwInternalOperandError("structure",$)}}reduceObjectJsonSchema($,T){if(this.props.length){$.properties={};for(let W of this.props){let U=W.value.toJsonSchemaRecurse(T);if(typeof W.key==="symbol"){T.fallback.symbolKey({code:"symbolKey",base:$,key:W.key,value:U,optional:W.optional});continue}if(W.hasDefault()){let X=typeof W.default==="function"?W.default():W.default;U.default=v.intrinsic.jsonData.allows(X)?X:T.fallback.defaultValue({code:"defaultValue",base:U,value:X})}$.properties[W.key]=U}if(this.requiredKeys.length&&$.properties)$.required=this.requiredKeys.filter((W)=>typeof W==="string"&&(W in $.properties))}if(this.index)for(let W of this.index){let U=W.value.toJsonSchemaRecurse(T);if(W.signature.equals(v.intrinsic.string)){$.additionalProperties=U;continue}for(let X of W.signature.branches){if(!X.extends(v.intrinsic.string)){$=T.fallback.symbolKey({code:"symbolKey",base:$,key:null,value:U,optional:!1});continue}let Y={type:"string"};if(X.hasKind("morph"))Y=T.fallback.morph({code:"morph",base:X.in.toJsonSchemaRecurse(T),out:X.out.toJsonSchemaRecurse(T)});if(!X.hasKind("intersection"))return Z$(`Unexpected index branch kind ${X.kind}.`);let{pattern:_}=X.inner;if(_){let w=Object.assign(Y,{pattern:_[0].rule});for(let G=1;G<_.length;G++)Y=T.fallback.patternIntersection({code:"patternIntersection",base:w,pattern:_[G].rule});$.patternProperties??={},$.patternProperties[w.pattern]=U}}}if(this.undeclared&&!$.additionalProperties)$.additionalProperties=!1;return $}}var T5={},OP=($)=>{let T="";for(let W=0;W<$.defaultable.length;W++)T+=$.defaultable[W].defaultValueMorphRef;if($.sequence?.defaultValueMorphsReference)T+=$.sequence?.defaultValueMorphsReference;if($.undeclared==="delete"){if(T+="delete !(",$.required)for(let W of $.required)T+=W.compiledKey+" | ";if($.optional)for(let W of $.optional)T+=W.compiledKey+" | ";if($.index)for(let W of $.index)T+=W.signature.id+" | ";if($.sequence)if($.sequence.maxLength===null)T+=n.nonNegativeIntegerString.id;else for(let W=0;W<$.sequence.tuple.length;W++)T+=W+" | ";T+=")"}return T},DP=($)=>{let T=OP($);if(!T)return;if(T5[T])return T5[T];let W=(U,X)=>{for(let Y=0;Y<$.defaultable.length;Y++)if(!($.defaultable[Y].key in U))$.defaultable[Y].defaultValueMorph(U,X);if($.sequence?.defaultables)for(let Y=U.length-$.sequence.prefixLength;Y<$.sequence.defaultables.length;Y++)$.sequence.defaultValueMorphs[Y](U,X);if($.undeclared==="delete"){for(let Y in U)if(!$.declaresKey(Y))delete U[Y]}return U};return T5[T]=W},QP=($,T)=>{let U=`(data${T.defaultable.some((X)=>X.defaultValueMorph.length===2)||T.sequence?.defaultValueMorphs.some((X)=>X.length===2)?", ctx":""})`;return $.block(`${U} => `,(X)=>{for(let Y=0;Y<T.defaultable.length;Y++){let{serializedKey:_,defaultValueMorphRef:w}=T.defaultable[Y];X.if(`!(${_} in data)`,(G)=>G.line(`${w}${U}`))}if(T.sequence?.defaultables)X.for(`i < ${T.sequence.defaultables.length}`,(Y)=>Y.set("data[i]",5),`data.length - ${T.sequence.prefixLength}`);if(T.undeclared==="delete")X.forIn("data",(Y)=>Y.if(`!(${T._compileDeclaresKey(Y)})`,(_)=>_.line("delete data[k]")));return X.return("data")})},W5={implementation:FP,Node:yK},ZP=($)=>{if(d($,"root")&&$.hasKind("unit"))$=$.unit;if(typeof $==="number")$=`${$}`;return $},VP=($,T)=>`${$} is not allowed as an array index on ${T}. Use the 'nonNegativeIntegerString' keyword instead.`,R8=($,T,W)=>{let[U,X]=_V($.branches,(_)=>_.hasKind("unit"));if(!U.length)return{index:W.node("index",{signature:$,value:T})};let Y={};for(let _ of U){let w=W.node("required",{key:_.unit,value:T});Y[w.kind]=O$(Y[w.kind],w)}if(X.length)Y.index=W.node("index",{signature:X,value:T});return Y},KP=($)=>d($,"root")?$.expression:Y$($),bK=($,T)=>`Key${T.length===1?"":"s"} ${T.map(KP).join(", ")} ${T.length===1?"does":"do"} not exist on ${$}`;var lT={...wK,alias:qU.implementation,domain:B8.implementation,unit:t7.implementation,proto:PU.implementation,union:n7.implementation,morph:r7.implementation,intersection:l7.implementation,divisor:C7.implementation,pattern:m7.implementation,predicate:P7.implementation,required:s7.implementation,optional:IU.implementation,index:a7.implementation,sequence:e7.implementation,structure:W5.implementation};v.defaultConfig=QV(Object.assign(X$(lT,($,T)=>[$,T.defaults]),{jitless:MV(),clone:KV,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:y$.defaultConfig}));v.resolvedConfig=AU(v.defaultConfig,v.config);var OK={...JK,alias:qU.Node,domain:B8.Node,unit:t7.Node,proto:PU.Node,union:n7.Node,morph:r7.Node,intersection:l7.Node,divisor:C7.Node,pattern:m7.Node,predicate:P7.Node,required:s7.Node,optional:IU.Node,index:a7.Node,sequence:e7.Node,structure:W5.Node};class nT extends F7{get[P4](){return"module"}}var U5=($,T)=>new nT(X$($,(W,U)=>[W,d(U,"module")?U5(U,T):T.bindReference(U)]));var EP=($)=>I$($)?$:("branches"in $)&&I$($.branches)?$.branches:void 0,AP=($,T)=>S(`Node of kind ${T} is not valid as a ${$} definition`),hK=($)=>`#${$} duplicates public alias ${$}`,X5={};v.ambient??={};var gK,cK="function $",MP=($)=>uK($,pK($)),uK=($,T)=>{let W=T.write(cK,4),U=T.compile()();for(let X of $){if(X.precompilation)continue;if(X.traverseAllows=U[`${X.id}Allows`].bind(U),X.isRoot()&&!X.allowsRequiresContext)X.allows=X.traverseAllows;if(X.traverseApply=U[`${X.id}Apply`].bind(U),U[`${X.id}Optimistic`])X.traverseOptimistic=U[`${X.id}Optimistic`].bind(U);X.precompilation=W}},pK=($)=>new D8().return($.reduce((T,W)=>{let U=new EU({kind:"Allows"}).indent();W.compile(U);let X=U.write(`${W.id}Allows`),Y=new EU({kind:"Apply"}).indent();W.compile(Y);let _=Y.write(`${W.id}Apply`),w=`${T}${X},
149
- ${_},
150
- `;if(!W.hasKind("union"))return w;let G=new EU({kind:"Allows",optimistic:!0}).indent();W.compile(G);let J=G.write(`${W.id}Optimistic`);return`${w}${J},
150
+ Right: ${T}`;var Qf=D$({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:($)=>$ instanceof Date?$.toISOString():R1($)}},normalize:($)=>$,defaults:{description:($)=>M$($.unit),problem:({expected:$,actual:T})=>`${$===T?`must be reference equal to ${$} (serialized to the same value)`:`must be ${$} (was ${T})`}`},intersections:{unit:($,T)=>r.init("unit",$,T),...F0("unit",($,T)=>{if(T.allows($.unit))return $;let W=T.hasKind("intersection")?T.basis:T;if(W){let w=W.hasKind("domain")?W:y.intrinsic.object;if($.domain!==w.domain){let X=$.domain==="undefined"||$.domain==="null"||$.domain==="boolean"?$.domain:y.intrinsic[$.domain];return r.init("domain",X,w)}}return r.init("assignability",$,T.hasKind("intersection")?T.children.find((w)=>!w.allows($.unit)):T)})}});class O_ extends bW{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=F_(this.unit,this.serializedValue);compiledNegation=F_(this.unit,this.serializedValue,"negated");expression=M$(this.unit);domain=f4(this.unit);get defaultShortDescription(){return this.domain==="object"?d6.object:this.description}innerToJsonSchema($){return this.unit===null?{type:"null"}:y.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:$.fallback.unit({code:"unit",base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?($)=>$ instanceof Date&&$.toISOString()===this.compiledValue:Number.isNaN(this.unit)?($)=>Number.isNaN($):($)=>$===this.unit}var AZ={implementation:Qf,Node:O_},F_=($,T,W)=>{if($ instanceof Date){let w=`data instanceof Date && data.toISOString() === ${T}`;return W?`!(${w})`:w}if(Number.isNaN($))return`${W?"!":""}Number.isNaN(data)`;return`data ${W?"!":"="}== ${T}`};var Zf=D$({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:($,T)=>{let W=T.$.parseSchema($);if(!W.extends(y.intrinsic.key))return B(Kf(W.expression));let w=W.branches.filter((X)=>X.hasKind("unit"));if(w.length)return B(Vf(w.map((X)=>M$(X.unit))));return W}},value:{child:!0,parse:($,T)=>T.$.parseSchema($)}},normalize:($)=>$,defaults:{description:($)=>`[${$.signature.expression}]: ${$.value.description}`},intersections:{index:($,T,W)=>{if($.signature.equals(T.signature)){let w=s$($.value,T.value,W),X=w instanceof r?y.intrinsic.never.internal:w;return W.$.node("index",{signature:$.signature,value:X})}if($.signature.extends(T.signature)&&$.value.subsumes(T.value))return T;if(T.signature.extends($.signature)&&T.value.subsumes($.value))return $;return null}}});class Q_ extends _1{impliedBasis=y.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=C$(this.value.flatRefs.map(($)=>m1([this.signature,...$.path],$.node)),m1([this.signature],this.value));traverseAllows=($,T)=>IW($).every((W)=>{if(this.signature.traverseAllows(W[0],T))return l6(W[0],()=>this.value.traverseAllows(W[1],T),T);return!0});traverseApply=($,T)=>{for(let W of IW($))if(this.signature.traverseAllows(W[0],T))l6(W[0],()=>this.value.traverseApply(W[1],T),T)};_transform($,T){T.path.push(this.signature);let W=super._transform($,T);return T.path.pop(),W}compile(){}}var EZ={implementation:Zf,Node:Q_},Vf=($)=>`Index keys ${$.join(", ")} should be specified as named props.`,Kf=($)=>`Indexed key definition '${$}' must be a string or symbol`;var Af=D$({kind:"required",hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:($,T)=>T.$.parseSchema($)}},normalize:($)=>$,defaults:{description:($)=>`${$.compiledKey}: ${$.value.description}`,expected:($)=>$.missingValueDescription,actual:()=>"missing"},intersections:{required:yU,optional:yU}});class Z_ extends hU{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=fT(this.errorContext)}var MZ={implementation:Af,Node:Z_};var Ef=D$({kind:"sequence",hasAssociatedError:!1,collapsibleKey:"variadic",keys:{prefix:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}},optionals:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}},defaultables:{child:($)=>$.map((T)=>T[0]),parse:($,T)=>{if($.length===0)return;return $.map((W)=>{let w=T.$.parseSchema(W[0]);return mU(w,W[1],null),[w,W[1]]})},serialize:($)=>$.map((T)=>[T[0].collapsibleJson,R1(T[1])])},variadic:{child:!0,parse:($,T)=>T.$.parseSchema($,T)},minVariadicLength:{parse:($)=>$===0?void 0:$},postfix:{child:!0,parse:($,T)=>{if($.length===0)return;return $.map((W)=>T.$.parseSchema(W))}}},normalize:($)=>{if(typeof $==="string")return{variadic:$};if("variadic"in $||"prefix"in $||"defaultables"in $||"optionals"in $||"postfix"in $||"minVariadicLength"in $){if($.postfix?.length){if(!$.variadic)return B(Lf);if($.optionals?.length||$.defaultables?.length)return B(NZ)}if($.minVariadicLength&&!$.variadic)return B("minVariadicLength may not be specified without a variadic element");return $}return{variadic:$}},reduce:($,T)=>{let W=$.minVariadicLength??0,w=$.prefix?.slice()??[],X=$.defaultables?.slice()??[],U=$.optionals?.slice()??[],Y=$.postfix?.slice()??[];if($.variadic){while(U.at(-1)?.equals($.variadic))U.pop();if(U.length===0&&X.length===0)while(w.at(-1)?.equals($.variadic))w.pop(),W++;while(Y[0]?.equals($.variadic))Y.shift(),W++}else if(U.length===0&&X.length===0)w.push(...Y.splice(0));if(W!==$.minVariadicLength||$.prefix&&$.prefix.length!==w.length)return T.node("sequence",{...$,prefix:w,defaultables:X,optionals:U,postfix:Y,minVariadicLength:W},{prereduced:!0})},defaults:{description:($)=>{if($.isVariadicOnly)return`${$.variadic.nestableExpression}[]`;return`[${$.tuple.map((W)=>W.kind==="defaultables"?`${W.node.nestableExpression} = ${M$(W.default)}`:W.kind==="optionals"?`${W.node.nestableExpression}?`:W.kind==="variadic"?`...${W.node.nestableExpression}[]`:W.node.expression).join(", ")}]`}},intersections:{sequence:($,T,W)=>{let w=dU({l:$.tuple,r:T.tuple,disjoint:new r,result:[],fixedVariants:[],ctx:W}),X=w.disjoint.length===0?[w,...w.fixedVariants]:w.fixedVariants;return X.length===0?w.disjoint:X.length===1?W.$.node("sequence",V_(X[0].result)):W.$.node("union",X.map((U)=>({proto:Array,sequence:V_(U.result)})))}}});class K_ extends _1{impliedBasis=y.intrinsic.Array.internal;tuple=Nf(this.inner);prefixLength=this.prefix?.length??0;defaultablesLength=this.defaultables?.length??0;optionalsLength=this.optionals?.length??0;postfixLength=this.postfix?.length??0;defaultablesAndOptionals=[];prevariadic=this.tuple.filter(($)=>{if($.kind==="defaultables"||$.kind==="optionals")return this.defaultablesAndOptionals.push($.node),!0;return $.kind==="prefix"});variadicOrPostfix=c0(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return rQ(this.flatRefs,this.prevariadic.flatMap(($,T)=>C$($.node.flatRefs.map((W)=>m1([`${T}`,...W.path],W.node)),m1([`${T}`],$.node)))),rQ(this.flatRefs,this.variadicOrPostfix.flatMap(($)=>C$($.flatRefs.map((T)=>m1([y.intrinsic.nonNegativeIntegerString.internal,...T.path],T.node)),m1([y.intrinsic.nonNegativeIntegerString.internal],$)))),this.flatRefs}isVariadicOnly=this.prevariadic.length+this.postfixLength===0;minVariadicLength=this.inner.minVariadicLength??0;minLength=this.prefixLength+this.minVariadicLength+this.postfixLength;minLengthNode=this.minLength===0?null:this.$.node("minLength",this.minLength);maxLength=this.variadic?null:this.tuple.length;maxLengthNode=this.maxLength===null?null:this.$.node("maxLength",this.maxLength);impliedSiblings=this.minLengthNode?this.maxLengthNode?[this.minLengthNode,this.maxLengthNode]:[this.minLengthNode]:this.maxLengthNode?[this.maxLengthNode]:[];defaultValueMorphs=Df(this);defaultValueMorphsReference=this.defaultValueMorphs.length?Z4(this.defaultValueMorphs):void 0;elementAtIndex($,T){if(T<this.prevariadic.length)return this.tuple[T];let W=$.length-this.postfixLength;if(T>=W)return{kind:"postfix",node:this.postfix[T-W]};return{kind:"variadic",node:this.variadic??I$(`Unexpected attempt to access index ${T} on ${this}`)}}traverseAllows=($,T)=>{for(let W=0;W<$.length;W++)if(!this.elementAtIndex($,W).node.traverseAllows($[W],T))return!1;return!0};traverseApply=($,T)=>{let W=0;for(;W<$.length;W++)l6(W,()=>this.elementAtIndex($,W).node.traverseApply($[W],T),T)};get element(){return this.cacheGetter("element",this.$.node("union",this.children))}compile($){if(this.prefix)for(let[T,W]of this.prefix.entries())$.traverseKey(`${T}`,`data[${T}]`,W);for(let[T,W]of this.defaultablesAndOptionals.entries()){let w=`${T+this.prefixLength}`;$.if(`${w} >= ${$.data}.length`,()=>$.traversalKind==="Allows"?$.return(!0):$.return()),$.traverseKey(w,`data[${w}]`,W)}if(this.variadic){if(this.postfix)$.const("firstPostfixIndex",`${$.data}.length${this.postfix?`- ${this.postfix.length}`:""}`);if($.for(`i < ${this.postfix?"firstPostfixIndex":"data.length"}`,()=>$.traverseKey("i","data[i]",this.variadic),this.prevariadic.length),this.postfix)for(let[T,W]of this.postfix.entries()){let w=`firstPostfixIndex + ${T}`;$.traverseKey(w,`data[${w}]`,W)}}if($.traversalKind==="Allows")$.return(!0)}_transform($,T){T.path.push(y.intrinsic.nonNegativeIntegerString.internal);let W=super._transform($,T);return T.path.pop(),W}expression=this.description;reduceJsonSchema($,T){if(this.prevariadic.length)$.prefixItems=this.prevariadic.map((W)=>{let w=W.node.toJsonSchemaRecurse(T);if(W.kind==="defaultables"){let X=typeof W.default==="function"?W.default():W.default;w.default=y.intrinsic.jsonData.allows(X)?X:T.fallback.defaultValue({code:"defaultValue",base:w,value:X})}return w});if(this.minLength)$.minItems=this.minLength;if(this.variadic){let W=Object.assign($,{items:this.variadic.toJsonSchemaRecurse(T)});if(this.maxLength)W.maxItems=this.maxLength;if(this.postfix){let w=this.postfix.map((X)=>X.toJsonSchemaRecurse(T));$=T.fallback.arrayPostfix({code:"arrayPostfix",base:W,elements:w})}}else $.items=!1,delete $.maxItems;return $}}var Mf={},Df=($)=>{if(!$.defaultables)return[];let T=[],W="[",w=$.prefixLength+$.defaultablesLength-1;for(let X=$.prefixLength;X<=w;X++){let[U,Y]=$.defaultables[X-$.prefixLength];T.push(OZ(X,U,Y)),W+=`${X}: ${U.id} = ${R1(Y)}, `}return W+="]",Mf[W]??=T},DZ={implementation:Ef,Node:K_},Nf=($)=>{let T=[];if($.prefix)for(let W of $.prefix)T.push({kind:"prefix",node:W});if($.defaultables)for(let[W,w]of $.defaultables)T.push({kind:"defaultables",node:W,default:w});if($.optionals)for(let W of $.optionals)T.push({kind:"optionals",node:W});if($.variadic)T.push({kind:"variadic",node:$.variadic});if($.postfix)for(let W of $.postfix)T.push({kind:"postfix",node:W});return T},V_=($)=>$.reduce((T,W)=>{if(W.kind==="variadic")T.variadic=W.node;else if(W.kind==="defaultables")T.defaultables=C$(T.defaultables,[[W.node,W.default]]);else T[W.kind]=C$(T[W.kind],W.node);return T},{}),NZ="A postfix required element cannot follow an optional or defaultable element",Lf="A postfix element requires a variadic element",dU=($)=>{let[T,...W]=$.l,[w,...X]=$.r;if(!T||!w)return $;let U=W.at(-1)?.kind==="postfix",Y=X.at(-1)?.kind==="postfix",G=T.kind==="prefix"||w.kind==="prefix"?"prefix":T.kind==="postfix"||w.kind==="postfix"?"postfix":T.kind==="variadic"&&w.kind==="variadic"?"variadic":U||Y?"prefix":T.kind==="defaultables"||w.kind==="defaultables"?"defaultables":"optionals";if(T.kind==="prefix"&&w.kind==="variadic"&&Y){let O=dU({...$,fixedVariants:[],r:X.map((Q)=>({...Q,kind:"prefix"}))});if(O.disjoint.length===0)$.fixedVariants.push(O)}else if(w.kind==="prefix"&&T.kind==="variadic"&&U){let O=dU({...$,fixedVariants:[],l:W.map((Q)=>({...Q,kind:"prefix"}))});if(O.disjoint.length===0)$.fixedVariants.push(O)}let H=s$(T.node,w.node,$.ctx);if(H instanceof r)if(G==="prefix"||G==="postfix")$.disjoint.push(...H.withPrefixKey(G==="prefix"?$.result.length:`-${W.length+1}`,"required")),$.result=[...$.result,{kind:G,node:y.intrinsic.never.internal}];else if(G==="optionals"||G==="defaultables")return $;else return dU({...$,fixedVariants:[],l:W.map((O)=>({...O,kind:"prefix"})),r:W.map((O)=>({...O,kind:"prefix"}))});else if(G==="defaultables"){if(T.kind==="defaultables"&&w.kind==="defaultables"&&T.default!==w.default)B(FZ(T.default,w.default));$.result=[...$.result,{kind:G,node:H,default:T.kind==="defaultables"?T.default:w.kind==="defaultables"?w.default:I$(`Unexpected defaultable intersection from ${T.kind} and ${w.kind} elements.`)}]}else $.result=[...$.result,{kind:G,node:H}];let z=$.l.length,F=$.r.length;if(T.kind!=="variadic"||z>=F&&(w.kind==="variadic"||F===1))$.l=W;if(w.kind!=="variadic"||F>=z&&(T.kind==="variadic"||z===1))$.r=X;return dU($)};var M_=($)=>(T)=>{if(T.props.length||T.index){let W=T.index?.map((X)=>X[$])??[];for(let X of T.props)W.push(X[$]);if(T.undeclared)W.push(`+ (undeclared): ${T.undeclared}`);let w=`{ ${W.join(", ")} }`;return T.sequence?`${w} & ${T.sequence.description}`:w}return T.sequence?.description??"{}"},Jf=M_("description"),Rf=M_("expression"),A_=($,T,W)=>{let w=$.required?"required":"optional";if(!T.signature.allows($.key))return null;let X=r6($.value,T.value,W);if(X instanceof r)return w==="optional"?W.node("optional",{key:$.key,value:y.intrinsic.never.internal}):X.withPrefixKey($.key,$.kind);return null},_f=D$({kind:"structure",hasAssociatedError:!1,normalize:($)=>$,applyConfig:($,T)=>{if(!$.undeclared&&T.onUndeclaredKey!=="ignore")return{...$,undeclared:T.onUndeclaredKey};return $},keys:{required:{child:!0,parse:U6("required"),reduceIo:($,T,W)=>{T.required=C$(T.required,W.map((w)=>w[$]));return}},optional:{child:!0,parse:U6("optional"),reduceIo:($,T,W)=>{if($==="in"){T.optional=W.map((w)=>w.in);return}for(let w of W)T[w.outProp.kind]=C$(T[w.outProp.kind],w.outProp.out)}},index:{child:!0,parse:U6("index")},sequence:{child:!0,parse:U6("sequence")},undeclared:{parse:($)=>$==="ignore"?void 0:$,reduceIo:($,T,W)=>{if(W!=="delete")return;if($==="in")delete T.undeclared;else T.undeclared="reject"}}},defaults:{description:Jf},intersections:{structure:($,T,W)=>{let w={...$.inner},X={...T.inner},U=new r;if($.undeclared){let H=$.keyof();for(let z of T.requiredKeys)if(!H.allows(z))U.add("presence",y.intrinsic.never.internal,T.propsByKey[z].value,{path:[z]});if(X.optional)X.optional=X.optional.filter((z)=>H.allows(z.key));if(X.index)X.index=X.index.flatMap((z)=>{if(z.signature.extends(H))return z;let F=r6(H,z.signature,W.$);if(F instanceof r)return[];let O=Fz(F,z.value,W.$);if(O.required)X.required=c0(X.required,O.required);if(O.optional)X.optional=c0(X.optional,O.optional);return O.index??[]})}if(T.undeclared){let H=T.keyof();for(let z of $.requiredKeys)if(!H.allows(z))U.add("presence",$.propsByKey[z].value,y.intrinsic.never.internal,{path:[z]});if(w.optional)w.optional=w.optional.filter((z)=>H.allows(z.key));if(w.index)w.index=w.index.flatMap((z)=>{if(z.signature.extends(H))return z;let F=r6(H,z.signature,W.$);if(F instanceof r)return[];let O=Fz(F,z.value,W.$);if(O.required)w.required=c0(w.required,O.required);if(O.optional)w.optional=c0(w.optional,O.optional);return O.index??[]})}let Y={};if($.undeclared||T.undeclared)Y.undeclared=$.undeclared==="reject"||T.undeclared==="reject"?"reject":"delete";let G=wX({kind:"structure",baseInner:Y,l:UX(w),r:UX(X),roots:[],ctx:W});if(G instanceof r)U.push(...G);if(U.length)return U;return G}},reduce:($,T)=>{if($.index){if(!($.required||$.optional))return;let W=!1,w=$.required??[],X=$.optional??[],U=[...X];for(let Y of $.index){for(let G of w){let H=A_(G,Y,T);if(H instanceof r)return H}for(let[G,H]of X.entries()){let z=A_(H,Y,T);if(z instanceof r)return z;if(z===null)continue;U[G]=z,W=!0}}if(W)return T.node("structure",{...$,optional:U},{prereduced:!0})}}});class D_ extends _1{impliedBasis=y.intrinsic.object.internal;impliedSiblings=this.children.flatMap(($)=>$.impliedSiblings??[]);props=c0(this.required,this.optional);propsByKey=E$(this.props,($,T)=>[T.key,T]);propsByKeyReference=Z4(this.propsByKey);expression=Rf(this);requiredKeys=this.required?.map(($)=>$.key)??[];optionalKeys=this.optional?.map(($)=>$.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let $=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:T}of this.index)$=$.concat(T.branches);return this._keyof=this.$.node("union",$)}map($){return this.$.node("structure",this.props.flatMap($).reduce((T,W)=>{let w=this.propsByKey[W.key];if(a$(W)){if(W.kind!=="required"&&W.kind!=="optional")return B(`Map result must have kind "required" or "optional" (was ${W.kind})`);return T[W.kind]=C$(T[W.kind],W),T}let X=W.kind??w?.kind??"required",U=E$(W,(Y,G)=>(Y in gU.implementation.keys)?[Y,G]:[]);return T[X]=C$(T[X],this.$.node(X,U)),T},{}))}assertHasKeys($){let T=$.filter((W)=>!cU(W,this.keyof()));if(T.length)return B(E_(this.expression,T))}get($,...T){let W,w=!1,X=Pf($);if((typeof X==="string"||typeof X==="symbol")&&this.propsByKey[X])W=this.propsByKey[X].value,w=this.propsByKey[X].required;if(this.index){for(let Y of this.index)if(cU(X,Y.signature))W=W?.and(Y.value)??Y.value}if(this.sequence&&cU(X,y.intrinsic.nonNegativeIntegerString))if(W$(X,"root")){if(this.sequence.variadic)W=W?.and(this.sequence.element)??this.sequence.element}else{let Y=Number.parseInt(X);if(Y<this.sequence.prevariadic.length){let G=this.sequence.prevariadic[Y].node;W=W?.and(G)??G,w||=Y<this.sequence.prefixLength}else if(this.sequence.variadic){let G=this.$.node("union",this.sequence.variadicOrPostfix);W=W?.and(G)??G}}if(!W){if(this.sequence?.variadic&&W$(X,"root")&&X.extends(y.intrinsic.number))return B(Cf(X.expression,this.sequence.expression));return B(E_(this.expression,[X]))}let U=W.get(...T);return w?U:U.or(y.intrinsic.undefined)}pick(...$){return this.assertHasKeys($),this.$.node("structure",this.filterKeys("pick",$))}omit(...$){return this.assertHasKeys($),this.$.node("structure",this.filterKeys("omit",$))}optionalize(){let{required:$,...T}=this.inner;return this.$.node("structure",{...T,optional:this.props.map((W)=>W.hasKind("required")?this.$.node("optional",W.inner):W)})}require(){let{optional:$,...T}=this.inner;return this.$.node("structure",{...T,required:this.props.map((W)=>W.hasKind("optional")?{key:W.key,value:W.value}:W)})}merge($){let T=this.filterKeys("omit",[$.keyof()]);if($.required)T.required=C$(T.required,$.required);if($.optional)T.optional=C$(T.optional,$.optional);if($.index)T.index=C$(T.index,$.index);if($.sequence)T.sequence=$.sequence;if($.undeclared)T.undeclared=$.undeclared;else delete T.undeclared;return this.$.node("structure",T)}filterKeys($,T){let W=e9(this.inner),w=(X)=>{let U=T.some((Y)=>cU(X,Y));return $==="pick"?U:!U};if(W.required)W.required=W.required.filter((X)=>w(X.key));if(W.optional)W.optional=W.optional.filter((X)=>w(X.key));if(W.index)W.index=W.index.filter((X)=>w(X.signature));return W}traverseAllows=($,T)=>this._traverse("Allows",$,T);traverseApply=($,T)=>this._traverse("Apply",$,T);_traverse=($,T,W)=>{let w=W?.currentErrorCount??0;for(let X=0;X<this.props.length;X++)if($==="Allows"){if(!this.props[X].traverseAllows(T,W))return!1}else if(this.props[X].traverseApply(T,W),W.failFast&&W.currentErrorCount>w)return!1;if(this.sequence){if($==="Allows"){if(!this.sequence.traverseAllows(T,W))return!1}else if(this.sequence.traverseApply(T,W),W.failFast&&W.currentErrorCount>w)return!1}if(this.index||this.undeclared==="reject"){let X=Object.keys(T);X.push(...Object.getOwnPropertySymbols(T));for(let U=0;U<X.length;U++){let Y=X[U];if(this.index){for(let G of this.index)if(G.signature.traverseAllows(Y,W)){if($==="Allows"){if(!l6(Y,()=>G.value.traverseAllows(T[Y],W),W))return!1}else if(l6(Y,()=>G.value.traverseApply(T[Y],W),W),W.failFast&&W.currentErrorCount>w)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(Y)){if($==="Allows")return!1;if(W.errorFromNodeContext({code:"predicate",expected:"removed",actual:"",relativePath:[Y],meta:this.meta}),W.failFast)return!1}}}if(this.structuralMorph&&W&&!W.hasError())W.queueMorphs([this.structuralMorph]);return!0};get defaultable(){return this.cacheGetter("defaultable",this.optional?.filter(($)=>$.hasDefault())??[])}declaresKey=($)=>($ in this.propsByKey)||this.index?.some((T)=>T.signature.allows($))||this.sequence!==void 0&&y.intrinsic.nonNegativeIntegerString.allows($);_compileDeclaresKey($){let T=[];if(this.props.length)T.push(`k in ${this.propsByKeyReference}`);if(this.index)for(let W of this.index)T.push($.invoke(W.signature,{kind:"Allows",arg:"k"}));if(this.sequence)T.push("$ark.intrinsic.nonNegativeIntegerString.allows(k)");return T.join(" || ")||"false"}get structuralMorph(){return this.cacheGetter("structuralMorph",vf(this))}structuralMorphRef=this.structuralMorph&&Z4(this.structuralMorph);compile($){if($.traversalKind==="Apply")$.initializeErrorCount();for(let T of this.props)if($.check(T),$.traversalKind==="Apply")$.returnIfFailFast();if(this.sequence){if($.check(this.sequence),$.traversalKind==="Apply")$.returnIfFailFast()}if(this.index||this.undeclared==="reject")$.const("keys","Object.keys(data)"),$.line("keys.push(...Object.getOwnPropertySymbols(data))"),$.for("i < keys.length",()=>this.compileExhaustiveEntry($));if($.traversalKind==="Allows")return $.return(!0);if(this.structuralMorphRef)$.if("ctx && !ctx.hasError()",()=>{return $.line("ctx.queueMorphs(["),qf($,this),$.line("])")})}compileExhaustiveEntry($){if($.const("k","keys[i]"),this.index)for(let T of this.index)$.if(`${$.invoke(T.signature,{arg:"k",kind:"Allows"})}`,()=>$.traverseKey("k","data[k]",T.value));if(this.undeclared==="reject")$.if(`!(${this._compileDeclaresKey($)})`,()=>{if($.traversalKind==="Allows")return $.return(!1);return $.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast",()=>$.return())});return $}reduceJsonSchema($,T){switch($.type){case"object":return this.reduceObjectJsonSchema($,T);case"array":let W=this.sequence?.reduceJsonSchema($,T)??$;if(this.props.length||this.index)return T.fallback.arrayObject({code:"arrayObject",base:W,object:this.reduceObjectJsonSchema({type:"object"},T)});return W;default:return w4.throwInternalOperandError("structure",$)}}reduceObjectJsonSchema($,T){if(this.props.length){$.properties={};for(let W of this.props){let w=W.value.toJsonSchemaRecurse(T);if(typeof W.key==="symbol"){T.fallback.symbolKey({code:"symbolKey",base:$,key:W.key,value:w,optional:W.optional});continue}if(W.hasDefault()){let X=typeof W.default==="function"?W.default():W.default;w.default=y.intrinsic.jsonData.allows(X)?X:T.fallback.defaultValue({code:"defaultValue",base:w,value:X})}$.properties[W.key]=w}if(this.requiredKeys.length&&$.properties)$.required=this.requiredKeys.filter((W)=>typeof W==="string"&&(W in $.properties))}if(this.index)for(let W of this.index){let w=W.value.toJsonSchemaRecurse(T);if(W.signature.equals(y.intrinsic.string)){$.additionalProperties=w;continue}for(let X of W.signature.branches){if(!X.extends(y.intrinsic.string)){$=T.fallback.symbolKey({code:"symbolKey",base:$,key:null,value:w,optional:!1});continue}let U={type:"string"};if(X.hasKind("morph"))U=T.fallback.morph({code:"morph",base:X.in.toJsonSchemaRecurse(T),out:X.out.toJsonSchemaRecurse(T)});if(!X.hasKind("intersection"))return I$(`Unexpected index branch kind ${X.kind}.`);let{pattern:Y}=X.inner;if(Y){let G=Object.assign(U,{pattern:Y[0].rule});for(let H=1;H<Y.length;H++)U=T.fallback.patternIntersection({code:"patternIntersection",base:G,pattern:Y[H].rule});$.patternProperties??={},$.patternProperties[G.pattern]=w}}}if(this.undeclared&&!$.additionalProperties)$.additionalProperties=!1;return $}}var LZ={},kf=($)=>{let T="";for(let W=0;W<$.defaultable.length;W++)T+=$.defaultable[W].defaultValueMorphRef;if($.sequence?.defaultValueMorphsReference)T+=$.sequence?.defaultValueMorphsReference;if($.undeclared==="delete"){if(T+="delete !(",$.required)for(let W of $.required)T+=W.compiledKey+" | ";if($.optional)for(let W of $.optional)T+=W.compiledKey+" | ";if($.index)for(let W of $.index)T+=W.signature.id+" | ";if($.sequence)if($.sequence.maxLength===null)T+=G$.nonNegativeIntegerString.id;else for(let W=0;W<$.sequence.tuple.length;W++)T+=W+" | ";T+=")"}return T},vf=($)=>{let T=kf($);if(!T)return;if(LZ[T])return LZ[T];let W=(w,X)=>{for(let U=0;U<$.defaultable.length;U++)if(!($.defaultable[U].key in w))$.defaultable[U].defaultValueMorph(w,X);if($.sequence?.defaultables)for(let U=w.length-$.sequence.prefixLength;U<$.sequence.defaultables.length;U++)$.sequence.defaultValueMorphs[U](w,X);if($.undeclared==="delete"){for(let U in w)if(!$.declaresKey(U))delete w[U]}return w};return LZ[T]=W},qf=($,T)=>{let w=`(data${T.defaultable.some((X)=>X.defaultValueMorph.length===2)||T.sequence?.defaultValueMorphs.some((X)=>X.length===2)?", ctx":""})`;return $.block(`${w} => `,(X)=>{for(let U=0;U<T.defaultable.length;U++){let{serializedKey:Y,defaultValueMorphRef:G}=T.defaultable[U];X.if(`!(${Y} in data)`,(H)=>H.line(`${G}${w}`))}if(T.sequence?.defaultables)X.for(`i < ${T.sequence.defaultables.length}`,(U)=>U.set("data[i]",5),`data.length - ${T.sequence.prefixLength}`);if(T.undeclared==="delete")X.forIn("data",(U)=>U.if(`!(${T._compileDeclaresKey(U)})`,(Y)=>Y.line("delete data[k]")));return X.return("data")})},JZ={implementation:_f,Node:D_},Pf=($)=>{if(W$($,"root")&&$.hasKind("unit"))$=$.unit;if(typeof $==="number")$=`${$}`;return $},Cf=($,T)=>`${$} is not allowed as an array index on ${T}. Use the 'nonNegativeIntegerString' keyword instead.`,Fz=($,T,W)=>{let[w,X]=uJ($.branches,(Y)=>Y.hasKind("unit"));if(!w.length)return{index:W.node("index",{signature:$,value:T})};let U={};for(let Y of w){let G=W.node("required",{key:Y.unit,value:T});U[G.kind]=C$(U[G.kind],G)}if(X.length)U.index=W.node("index",{signature:X,value:T});return U},Sf=($)=>W$($,"root")?$.expression:M$($),E_=($,T)=>`Key${T.length===1?"":"s"} ${T.map(Sf).join(", ")} ${T.length===1?"does":"do"} not exist on ${$}`;var GX={...pR,alias:uU.implementation,domain:Hz.implementation,unit:AZ.implementation,proto:pU.implementation,union:KZ.implementation,morph:ZZ.implementation,intersection:QZ.implementation,divisor:sQ.implementation,pattern:YZ.implementation,predicate:aQ.implementation,required:MZ.implementation,optional:gU.implementation,index:EZ.implementation,sequence:DZ.implementation,structure:JZ.implementation};y.defaultConfig=aJ(Object.assign(E$(GX,($,T)=>[$,T.defaults]),{jitless:XR(),clone:$R,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:w4.defaultConfig}));y.resolvedConfig=IU(y.defaultConfig,y.config);var iR={...dR,alias:uU.Node,domain:Hz.Node,unit:AZ.Node,proto:pU.Node,union:KZ.Node,morph:ZZ.Node,intersection:QZ.Node,divisor:sQ.Node,pattern:YZ.Node,predicate:aQ.Node,required:MZ.Node,optional:gU.Node,index:EZ.Node,sequence:DZ.Node,structure:JZ.Node};class FX extends IQ{get[C6](){return"module"}}var RZ=($,T)=>new FX(E$($,(W,w)=>[W,W$(w,"module")?RZ(w,T):T.bindReference(w)]));var jf=($)=>o$($)?$:("branches"in $)&&o$($.branches)?$.branches:void 0,If=($,T)=>B(`Node of kind ${T} is not valid as a ${$} definition`),N_=($)=>`#${$} duplicates public alias ${$}`,_Z={};y.ambient??={};var L_,R_="function $",Bf=($)=>__($,k_($)),__=($,T)=>{let W=T.write(R_,4),w=T.compile()();for(let X of $){if(X.precompilation)continue;if(X.traverseAllows=w[`${X.id}Allows`].bind(w),X.isRoot()&&!X.allowsRequiresContext)X.allows=X.traverseAllows;if(X.traverseApply=w[`${X.id}Apply`].bind(w),w[`${X.id}Optimistic`])X.traverseOptimistic=w[`${X.id}Optimistic`].bind(w);X.precompilation=W}},k_=($)=>new s9().return($.reduce((T,W)=>{let w=new jU({kind:"Allows"}).indent();W.compile(w);let X=w.write(`${W.id}Allows`),U=new jU({kind:"Apply"}).indent();W.compile(U);let Y=U.write(`${W.id}Apply`),G=`${T}${X},
151
+ ${Y},
152
+ `;if(!W.hasKind("union"))return G;let H=new jU({kind:"Allows",optimistic:!0}).indent();W.compile(H);let z=H.write(`${W.id}Optimistic`);return`${G}${z},
151
153
  `},`{
152
- `)+"}");class I8{config;resolvedConfig;name;get[P4](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor($,T){if(this.config=AU(v.config,T),this.resolvedConfig=AU(v.resolvedConfig,T),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(X5).length}`,this.name in X5)S(`A Scope already named ${this.name} already exists`);X5[this.name]=this;let W=Object.entries($).map((U)=>this.preparseOwnAliasEntry(...U));for(let[U,X]of W){let Y=U;if(U[0]==="#"){if(Y=U.slice(1),Y in this.aliases)S(hK(Y));this.aliases[Y]=X}else{if(Y in this.aliases)S(hK(U));this.aliases[Y]=X,this.exportedNames.push(Y)}if(!d(X,"module")&&!d(X,"generic")&&!p1(X)){let _=this.preparseOwnDefinitionFormat(X,{alias:Y});this.resolutions[Y]=d(_,"root")?this.bindReference(_):this.createParseContext(_).id}}gK??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[gK.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=v.intrinsic?X$(v.intrinsic,(U,X)=>U.startsWith("json")?[]:[U,this.bindReference(X)]):{}}cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema($){return $}generic=(...$)=>{let T=this;return(W,U)=>new i1($,U?new E8(W):W,T,T,U??null)};units=($,T)=>{let W=[];for(let X of $)if(!W.includes(X))W.push(X);let U=W.map((X)=>this.node("unit",{unit:X},T));return this.node("union",U,{...T,prereduced:!0})};lazyResolutions=[];lazilyResolve($,T){let W=this.node("alias",{reference:T??"synthetic",resolve:$},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(W);return W}schema=($,T)=>this.finalize(this.parseSchema($,T));parseSchema=($,T)=>this.node(SU($),$,T);preparseNode($,T,W){let U=typeof $==="string"?$:SU(T,$);if(C$(T)&&T.kind===U)return T;if(U==="alias"&&!W?.prereduced){let{reference:_}=qU.implementation.normalize(T,this);if(_.startsWith("$")){let w=this.resolveRoot(_.slice(1));T=w,U=w.kind}}else if(U==="union"&&c4(T,"object")){let _=EP(T);if(_?.length===1)T=_[0],U=SU(T)}if(C$(T)&&T.kind===U)return T;let Y=lT[U].normalize?.(T,this)??T;if(C$(Y))return Y.kind===U?Y:AP(U,Y.kind);return{...W,$:this,kind:U,def:Y,prefix:W.alias??U}}bindReference($){let T;if(C$($))T=$.$===this?$:new $.constructor($.attachments,this);else T=$.$===this?$:new i1($.params,$.bodyDef,$.$,this,$.hkt);if(!this.resolved)Object.assign(this.referencesById,T.referencesById);return T}resolveRoot($){return this.maybeResolveRoot($)??S(w5($))}maybeResolveRoot($){let T=this.maybeResolve($);if(d(T,"generic"))return;return T}maybeResolveSubalias($){return Y5(this.aliases,$)??Y5(this.ambient,$)}get ambient(){return v.ambient}maybeResolve($){let T=this.resolutions[$];if(T){if(typeof T!=="string")return this.bindReference(T);let U=C4[T];if(d(U,"root"))return this.resolutions[$]=U;if(d(U,"context")){if(U.phase==="resolving")return this.node("alias",{reference:`$${$}`},{prereduced:!0});if(U.phase==="resolved")return Z$(`Unexpected resolved context for was uncached by its scope: ${Y$(U)}`);U.phase="resolving";let X=this.bindReference(this.parseOwnDefinitionFormat(U.def,U));return U.phase="resolved",C4[X.id]=X,C4[U.id]=X,this.resolutions[$]=X}return Z$(`Unexpected nodesById entry for ${T}: ${Y$(U)}`)}let W=this.aliases[$]??this.ambient?.[$];if(!W)return this.maybeResolveSubalias($);if(W=this.normalizeRootScopeValue(W),d(W,"generic"))return this.resolutions[$]=this.bindReference(W);if(d(W,"module")){if(!W.root)S(lK($));return this.resolutions[$]=this.bindReference(W.root)}return this.resolutions[$]=this.parse(W,{alias:$})}createParseContext($){let T=$.id??c7($.prefix);return C4[T]=Object.assign($,{[P4]:"context",$:this,id:T,phase:"unresolved"})}traversal($){return new R6($,this.resolvedConfig)}import(...$){return new nT(X$(this.export(...$),(T,W)=>[`#${T}`,W]))}precompilation;_exportedResolutions;_exports;export(...$){if(!this._exports){this._exports={};for(let W of this.exportedNames){let U=this.aliases[W];this._exports[W]=d(U,"module")?U5(U,this):mK(this.maybeResolve(W))}for(let W of this.lazyResolutions)W.resolution;if(this._exportedResolutions=dK(this,this._exports),this._json=oK(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let W=pK(this.references);this.precompilation=W.write(cK,4),uK(this.references,W)}this.resolved=!0}let T=$.length?$:this.exportedNames;return new nT(X$(T,(W,U)=>[U,this._exports[U]]))}resolve($){return this.export()[$]}node=($,T,W={})=>{let U=this.preparseNode($,T,W);if(C$(U))return this.bindReference(U);let X=this.createParseContext(U),Y=u7(X),_=this.bindReference(Y);return C4[X.id]=_};parse=($,T={})=>this.finalize(this.parseDefinition($,T));parseDefinition($,T={}){if(d($,"root"))return this.bindReference($);let W=this.preparseOwnDefinitionFormat($,T);if(d(W,"root"))return this.bindReference(W);let U=this.createParseContext(W);C4[U.id]=U;let X=this.bindReference(this.parseOwnDefinitionFormat($,U));if(X.isCyclic)X=FK(X,U.id);return C4[U.id]=X,X}finalize($){if(mK($),!$.precompilation&&!this.resolvedConfig.jitless)MP($.references);return $}}class _5 extends I8{parseOwnDefinitionFormat($,T){return u7(T)}preparseOwnDefinitionFormat($,T){return this.preparseNode(SU($),$,T)}preparseOwnAliasEntry($,T){return[$,T]}normalizeRootScopeValue($){return $}}var mK=($)=>{let T=$.references.filter((W)=>W.hasKind("alias"));for(let W of T){Object.assign(W.referencesById,W.resolution.referencesById);for(let U of $.references)if(W.id in U.referencesById)Object.assign(U.referencesById,W.referencesById)}return $},oK=($)=>X$($,(T,W)=>[T,d(W,"root")||d(W,"generic")?W.json:d(W,"module")?oK(W):Z$(`Unexpected resolution ${Y$(W)}`)]),Y5=($,T)=>{let W=T.indexOf(".");if(W===-1)return;let U=T.slice(0,W),X=$[U];if(X===void 0)return;if(!d(X,"module"))return S(NP(U));let Y=T.slice(W+1),_=X[Y];if(_===void 0)return Y5(X,Y);if(d(_,"root")||d(_,"generic"))return _;if(d(_,"module"))return _.root??S(lK(T));Z$(`Unexpected resolution for alias '${T}': ${Y$(_)}`)},k8=($,T)=>new _5($,T),jU=new _5({});var dK=($,T)=>{let W={};for(let U in T){let X=T[U];if(d(X,"module")){let Y=dK($,X),_=X$(Y,(w,G)=>[`${U}.${w}`,G]);Object.assign(W,_)}else if(d(X,"root")||d(X,"generic"))W[U]=X;else Z$(`Unexpected scope resolution ${Y$(X)}`)}return W},w5=($)=>`'${$}' is unresolvable`,NP=($)=>`'${$}' must reference a module to be accessed using dot syntax`,lK=($)=>`Reference to submodule '${$}' must specify an alias`;jU.export();var{schema:E$,node:tT,defineSchema:VT$,generic:D6}=jU;var J5="^(?:0|[1-9]\\d*)$",LP=new RegExp(J5),AT$=o$(LP);var rK=k8({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();v.intrinsic={...rK};var iK=k8({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:J5}},{prereducedAliases:!0}).export();Object.assign(v.intrinsic,iK);var SP=k8({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),n={...rK,...iK,...SP,emptyStructure:tT("structure",{},{prereduced:!0})};v.intrinsic={...n};var tK=($)=>typeof $==="string"&&$[0]==="d"&&($[1]==="'"||$[1]==='"')&&$.at(-1)===$[1],nK=($)=>$.toString()!=="Invalid Date",aK=($)=>$.slice(2,-1),G5=($)=>`'${$}' could not be parsed by the Date constructor`,sK=($,T)=>BP($,T),BP=($,T)=>{let W=new Date($);if(nK(W))return W;let U=qV($);if(U!==void 0){let X=new Date(U);if(nK(X))return X}return T?S(T===!0?G5($):T):void 0};var z5=($,T)=>{let W=$.scanner.shiftUntil(RP[$E[T]]);if($.scanner.lookahead==="")return $.error(kP(W,T));if($.scanner.shift(),T==="/"){try{new RegExp(W)}catch(U){S(String(U))}$.root=$.ctx.$.node("intersection",{domain:"string",pattern:W},{prereduced:!0})}else if(z4(T,H5))$.root=$.ctx.$.node("unit",{unit:W});else{let U=sK(W,G5(W));$.root=$.ctx.$.node("unit",{meta:W,unit:U})}},H5={"'":1,'"':1},eK={"/":1,"'":1,'"':1},$E={"d'":"'",'d"':'"',"'":"'",'"':'"',"/":"/"},RP={"'":($)=>$.lookahead==="'",'"':($)=>$.lookahead==='"',"/":($)=>$.lookahead==="/"},IP={'"':"double-quote","'":"single-quote","/":"forward slash"},kP=($,T)=>`${T}${$} requires a closing ${IP[$E[T]]}`;var TE=($)=>`Private type references should not include '#'. Use '${$}' instead.`,v8="Optional definitions like 'string?' are only valid as properties in an object or tuple",q8="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var WE={">":!0,">=":!0},UE={"<":!0,"<=":!0};var aT={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},XE=($)=>`Unmatched )${$===""?"":` before ${$}`}`,P8=($)=>`Missing ${$}`,YE=($,T)=>`Left bounds are only valid when paired with right bounds (try ...${T}${$})`,C8=($)=>`Left-bounded expressions must specify their limits using < or <= (was ${$})`,_E=($,T,W,U)=>`An expression may have at most one left bound (parsed ${$}${aT[T]}, ${W}${aT[U]})`;var wE=($,T,W)=>JE($,T,W,[]),JE=($,T,W,U)=>{let X=W.parseUntilFinalizer();if(U.push(X.root),X.finalizer===">"){if(U.length!==T.params.length)return W.error(F5($,T.names,U.map((Y)=>Y.expression)));return U}if(X.finalizer===",")return JE($,T,W,U);return X.error(P8(">"))},F5=($,T,W)=>`${$}<${T.join(", ")}> requires exactly ${T.length} args (got ${W.length}${W.length===0?"":`: ${W.join(", ")}`})`;var O5=($)=>{let T=$.scanner.shiftUntilNextTerminator();if(T==="keyof")$.addPrefix("keyof");else $.root=qP($,T)},vP=($,T,W)=>{if(W.scanner.shiftUntilNonWhitespace(),W.scanner.shift()!=="<")return W.error(F5($,T.names,[]));let X=wE($,T,W);return T(...X)},qP=($,T)=>PP($,T)??CP($,T)??$.error(T===""?$.scanner.lookahead==="#"?TE($.shiftedByOne().scanner.shiftUntilNextTerminator()):D5($):w5(T)),PP=($,T)=>{if($.ctx.args?.[T]){let U=$.ctx.args[T];if(typeof U!=="string")return U;return $.ctx.$.node("alias",{reference:U},{prereduced:!0})}let W=$.ctx.$.maybeResolve(T);if(d(W,"root"))return W;if(W===void 0)return;if(d(W,"generic"))return vP(T,W,$);return S(`Unexpected resolution ${Y$(W)}`)},CP=($,T)=>{let W=PV(T);if(W!==void 0)return $.ctx.$.node("unit",{unit:W});let U=jV(T);if(U!==void 0)return $.ctx.$.node("unit",{unit:U})},D5=($)=>{let T=$.previousOperator();return T?Q5(T,$.scanner.unscanned):jP($.scanner.unscanned)},Q5=($,T="")=>`Token '${$}' requires a right operand${T?` before '${T}'`:""}`,jP=($)=>`Expected an expression${$?` before '${$}'`:""}`;var Z5=($)=>$.scanner.lookahead===""?$.error(D5($)):$.scanner.lookahead==="("?$.shiftedByOne().reduceGroupOpen():$.scanner.lookaheadIsIn(eK)?z5($,$.scanner.shift()):$.scanner.lookaheadIsIn(o1)?Z5($.shiftedByOne()):$.scanner.lookahead==="d"?$.scanner.nextLookahead in H5?z5($,`${$.scanner.shift()}${$.scanner.shift()}`):O5($):O5($);class Z1 extends M7{shiftUntilNextTerminator(){return this.shiftUntilNonWhitespace(),this.shiftUntil(()=>(this.lookahead in Z1.terminatingChars))}static terminatingChars={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...o1};static finalizingLookaheads={">":1,",":1,"":1,"=":1,"?":1};static lookaheadIsFinalizing=($,T)=>$===">"?T[0]==="="?T[1]==="=":T.trimStart()===""||z4(T.trimStart()[0],Z1.terminatingChars):$==="="?T[0]!=="=":$===","||$==="?"}var zE=($,T)=>{let W=xP($,T);if($.root.hasKind("unit")){if(typeof $.root.unit==="number"){$.reduceLeftBound($.root.unit,W),$.unsetRoot();return}if($.root.unit instanceof Date){let U=`d'${$.root.description??$.root.unit.toISOString()}'`;$.unsetRoot(),$.reduceLeftBound(U,W);return}}return fP($,W)},HE={"<":1,">":1,"=":1},xP=($,T)=>$.scanner.lookaheadIs("=")?`${T}${$.scanner.shift()}`:T;var GE=($,T,W,U)=>{if(W.extends(v.intrinsic.number)){if(typeof T!=="number")return S(V5($,T,U));return $==="=="?["min","max"]:$[0]===">"?["min"]:["max"]}if(W.extends(v.intrinsic.lengthBoundable)){if(typeof T!=="number")return S(V5($,T,U));return $==="=="?["exactLength"]:$[0]===">"?["minLength"]:["maxLength"]}if(W.extends(v.intrinsic.Date))return $==="=="?["after","before"]:$[0]===">"?["after"]:["before"];return S(eV(W.expression))},bP=($)=>({rule:tK($.limit)?aK($.limit):$.limit,exclusive:$.comparator.length===1}),fP=($,T)=>{let W=$.unsetRoot(),U=$.scanner.location;$.parseOperand();let X=$.unsetRoot(),Y=$.scanner.sliceChars(U,$.scanner.location);if($.root=W,!X.hasKind("unit")||typeof X.unit!=="number"&&!(X.unit instanceof Date))return $.error(V5(T,Y,"right"));let _=X.unit,w=T.length===1,G=GE(T,typeof _==="number"?_:Y,W,"right");for(let H of G)$.constrainRoot(H,T==="=="?{rule:_}:{rule:_,exclusive:w});if(!$.branches.leftBound)return;if(!z4(T,UE))return $.error(C8(T));let J=GE($.branches.leftBound.comparator,$.branches.leftBound.limit,W,"left");$.constrainRoot(J[0],bP($.branches.leftBound)),$.branches.leftBound=null},V5=($,T,W)=>`Comparator ${W==="left"?aT[$]:$} must be ${W==="left"?"preceded":"followed"} by a corresponding literal (was ${T})`;var FE=($)=>{$.scanner.shiftUntilNonWhitespace();let T=$.scanner.shiftUntilNextTerminator();$.root=$.root.brand(T)};var DE=($)=>{let T=$.scanner.shiftUntilNextTerminator(),W=CV(T,{errorOnFail:OE(T)});if(W===0)$.error(OE(0));$.root=$.root.constrain("divisor",W)},OE=($)=>`% operator must be followed by a non-zero integer literal (was ${$})`;var K5=($)=>{let T=$.scanner.shift();return T===""?$.finalize(""):T==="["?$.scanner.shift()==="]"?$.setRoot($.root.array()):$.error(yP):T==="|"?$.scanner.lookahead===">"?$.shiftedByOne().pushRootToBranch("|>"):$.pushRootToBranch(T):T==="&"?$.pushRootToBranch(T):T===")"?$.finalizeGroup():Z1.lookaheadIsFinalizing(T,$.scanner.unscanned)?$.finalize(T):z4(T,HE)?zE($,T):T==="%"?DE($):T==="#"?FE($):(T in o1)?K5($):$.error(j8(T))},j8=($,T="")=>`'${$}' is not allowed here${T&&` (should be ${T})`}`,yP="Missing expected ']'";var QE=($)=>{let T=$.unsetRoot();$.parseOperand();let W=$.unsetRoot();if(!W.hasKind("unit"))return $.error(hP(W.expression));let U=W.unit instanceof Date?()=>new Date(W.unit):W.unit;return[T,"=",U]},hP=($)=>`Default value '${$}' must a literal value`;var E5=($,T)=>{let W=T.$.maybeResolveRoot($);if(W)return W;if($.endsWith("[]")){let Y=T.$.maybeResolveRoot($.slice(0,-2));if(Y)return Y.array()}let U=new sT(new Z1($),T),X=gP(U);if(U.finalizer===">")S(j8(">"));return X},gP=($)=>{$.parseOperand();let T=xU($).root;if(!T)return Z$(`Root was unexpectedly unset after parsing string '${$.scanner.scanned}'`);if($.finalizer==="=")T=QE($);else if($.finalizer==="?")T=[T,"?"];if($.scanner.shiftUntilNonWhitespace(),$.scanner.lookahead)S(j8($.scanner.lookahead));return T},xU=($)=>{while($.finalizer===void 0)mP($);return $},mP=($)=>$.hasRoot()?$.parseOperator():$.parseOperand();class sT{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor($,T){this.scanner=$,this.ctx=T}error($){return S($)}hasRoot(){return this.root!==void 0}setRoot($){this.root=$}unsetRoot(){let $=this.root;return this.root=void 0,$}constrainRoot(...$){this.root=this.root.constrain($[0],$[1])}finalize($){if(this.groups.length)return this.error(P8(")"));this.finalizeBranches(),this.finalizer=$}reduceLeftBound($,T){let W=aT[T];if(!z4(W,WE))return this.error(C8(T));if(this.branches.leftBound)return this.error(_E(this.branches.leftBound.limit,this.branches.leftBound.comparator,$,W));this.branches.leftBound={comparator:W,limit:$}}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 $=this.groups.pop();if(!$)return this.error(XE(this.scanner.unscanned));this.branches=$}addPrefix($){this.branches.prefixes.push($)}applyPrefixes(){while(this.branches.prefixes.length){let $=this.branches.prefixes.pop();this.root=$==="keyof"?this.root.keyof():Z$(`Unexpected prefix '${$}'`)}}pushRootToBranch($){this.assertRangeUnset(),this.applyPrefixes();let T=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(T)??T,$==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,$==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return xU(new sT(this.scanner,this.ctx))}parseOperator(){return K5(this)}parseOperand(){return Z5(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(YE(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 cP="An empty string is not a valid generic parameter name",x8=($,T,W)=>{$.shiftUntilNonWhitespace();let U=$.shiftUntilNextTerminator();if(U===""){if($.lookahead===""&&T.length)return T;return S(cP)}return $.shiftUntilNonWhitespace(),uP($,U,T,W)},ZE="extends ",uP=($,T,W,U)=>{if($.shiftUntilNonWhitespace(),$.unscanned.startsWith(ZE))$.jumpForward(ZE.length);else{if($.lookahead===",")$.shift();return W.push(T),x8($,W,U)}let X=xU(new sT($,U));return W.push([T,X.root]),x8($,W,U)};class A5 extends B6{$;constructor($){super((...T)=>new bU($)(...T),{bind:$});this.$=$}in($){return new bU(this.$,$===void 0?void 0:this.$.parse($))}at($,T){return new bU(this.$).at($,T)}case($,T){return new bU(this.$).case($,T)}}class bU extends B6{$;in;key;branches=[];constructor($,T){super((W)=>this.caseEntries(Object.entries(W).map(([U,X])=>U==="default"?[U,X]:[this.$.parse(U),X])));this.$=$,this.in=T}at($,T){if(this.key)S(oP);if(this.branches.length)S(pP);return this.key=$,T?this.match(T):this}case($,T){return this.caseEntry(this.$.parse($),T)}caseEntry($,T){let U=(this.key?this.$.parse({[this.key]:$}):$).pipe(T);return this.branches.push(U),this}match($){return this($)}strings($){return this.caseEntries(Object.entries($).map(([T,W])=>T==="default"?[T,W]:[this.$.node("unit",{unit:T}),W]))}caseEntries($){for(let T=0;T<$.length;T++){let[W,U]=$[T];if(W==="default"){if(T!==$.length-1)S("default may only be specified as the last key of a switch definition");return this.default(U)}if(typeof U!=="function")return S(`Value for case "${W}" must be a function (was ${G4(U)})`);this.caseEntry(W,U)}return this}default($){if(typeof $==="function")this.case(n.unknown,$);let T={branches:this.branches,ordered:!0};if($==="never"||$==="assert")T.meta={onFail:VE};let W=this.$.node("union",T);if(!this.in)return this.$.finalize(W);let U=this.in.pipe(W);if($==="never"||$==="assert")U=U.configureReferences({onFail:VE},"self");return this.$.finalize(U)}}var VE=($)=>$.throw(),pP="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",oP="At most one key matcher may be specified per expression";var b8=($,T)=>{if(I$($)){if($[1]==="=")return[T.$.parseOwnDefinitionFormat($[0],T),"=",$[2]];if($[1]==="?")return[T.$.parseOwnDefinitionFormat($[0],T),"?"]}return f8($,T)},KE="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",EE="Only required keys may specify default values, e.g. { value: 'number = 0' }";var AE=($,T)=>{let W,U={},X=f0($);for(let[_,w]of X){let G=rP(_);if(G.kind==="spread"){if(!m6(U))return S(lP);let Q=T.$.parseOwnDefinitionFormat(w,T);if(Q.equals(n.object))continue;if(!Q.hasKind("intersection")||!Q.basis?.equals(n.object))return S(iP(Q.expression));W=Q.structure;continue}if(G.kind==="undeclared"){if(w!=="reject"&&w!=="delete"&&w!=="ignore")S(dP(w));U.undeclared=w;continue}let J=b8(w,T),H=G;if(G.kind==="required"){if(!I$(J))M5(U,"required",{key:G.normalized,value:J},T);else M5(U,"optional",J[1]==="="?{key:G.normalized,value:J[0],default:J[2]}:{key:G.normalized,value:J[0]},T);continue}if(I$(J)){if(J[1]==="?")S(KE);if(J[1]==="=")S(EE)}if(G.kind==="optional"){M5(U,"optional",{key:G.normalized,value:J},T);continue}let z=T.$.parseOwnDefinitionFormat(H.normalized,T),F=R8(z,J,T.$);if(F.index)U.index=O$(U.index,F.index);if(F.required)U.required=O$(U.required,F.required)}let Y=T.$.node("structure",U);return T.$.parseSchema({domain:"object",structure:W?.merge(Y)??Y})},M5=($,T,W,U)=>{$[T]=O$($[T],U.$.node(T,W))},dP=($)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${Y$($)})`,lP="Spread operator may only be used as the first key in an object",rP=($)=>typeof $==="symbol"?{kind:"required",normalized:$}:$.at(-1)==="?"?$.at(-2)===OU?{kind:"required",normalized:`${$.slice(0,-2)}?`}:{kind:"optional",normalized:$.slice(0,-1)}:$[0]==="["&&$.at(-1)==="]"?{kind:"index",normalized:$.slice(1,-1)}:$[0]===OU&&$[1]==="["&&$.at(-1)==="]"?{kind:"required",normalized:$.slice(1)}:$==="..."?{kind:"spread"}:$==="+"?{kind:"undeclared"}:{kind:"required",normalized:$==="\\..."?"...":$==="\\+"?"+":$},iP=($)=>`Spread operand must resolve to an object literal type (was ${$})`;var NE=($,T)=>XC($)?RE[$[0]]($,T):WC($)?BE[$[1]]($,T):null,nP=($,T)=>T.$.parseOwnDefinitionFormat($[1],T).keyof(),N5=($,T)=>{if($[2]===void 0)return S(Q5($[1],""));let W=T.$.parseOwnDefinitionFormat($[0],T),U=T.$.parseOwnDefinitionFormat($[2],T);if($[1]==="|")return T.$.node("union",{branches:[W,U]});let X=$[1]==="&"?d4(W,U,T.$):LU(W,U,T.$);if(X instanceof g)return X.throw();return X},tP=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).array(),aP=($,T)=>{if(typeof $[2]!=="function")return S(LE("=>",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).pipe($[2])},LE=($,T)=>`${$===":"?"Narrow":"Morph"} expression requires a function following '${$}' (was ${typeof T})`,sP=($,T)=>{if(typeof $[2]!=="function")return S(LE(":",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).constrain("predicate",$[2])},eP=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).configureReferences($[2],"shallow"),SE=($)=>$,$C=SE({"[]":tP,"?":()=>S(v8)}),TC=SE({"|":N5,"&":N5,":":sP,"=>":aP,"|>":N5,"@":eP,"=":()=>S(q8)}),BE={...$C,...TC},WC=($)=>BE[$[1]]!==void 0,UC=($)=>$,RE=UC({keyof:nP,instanceof:($,T)=>{if(typeof $[1]!=="function")return S(ME(HU($[1])));let W=$.slice(1).map((U)=>typeof U==="function"?T.$.node("proto",{proto:U}):S(ME(HU(U))));return W.length===1?W[0]:T.$.node("union",{branches:W})},"===":($,T)=>T.$.units($.slice(1))}),XC=($)=>RE[$[0]]!==void 0,ME=($)=>`Expected a constructor following 'instanceof' operator (was ${$})`;var vE=($,T)=>{let W=[{}],U=0;while(U<$.length){let X=!1;if($[U]==="..."&&U<$.length-1)X=!0,U++;let Y=b8($[U],T),[_,w,G]=!I$(Y)?[Y]:Y;if(U++,X){if(!_.extends(v.intrinsic.Array))return S(wC(_.expression));W=W.flatMap((J)=>_.distribute((H)=>_C(Q8(J),H)))}else W=W.map((J)=>{if(w==="?")return qE(J,_);if(w==="=")return YC(J,_,G);return L5(J,_)})}return T.$.parseSchema(W.map((X)=>m6(X)?{proto:Array,exactLength:0}:{proto:Array,sequence:X}))},L5=($,T)=>{if($.defaultables||$.optionals)return S($.variadic?$5:JC);if($.variadic)$.postfix=O$($.postfix,T);else $.prefix=O$($.prefix,T);return $},qE=($,T)=>{if($.variadic)return S(PE);return $.optionals=O$($.optionals,T),$},YC=($,T,W)=>{if($.variadic)return S(PE);if($.optionals)return S(GC);return $.defaultables=O$($.defaultables,[[T,W]]),$},IE=($,T)=>{if($.postfix)S(kE);if($.variadic){if(!$.variadic.equals(T))S(kE)}else $.variadic=T.internal;return $},_C=($,T)=>{let W=T.select({method:"find",kind:"sequence"});if(!W)return IE($,v.intrinsic.unknown);if(W.prefix)for(let U of W.prefix)L5($,U);if(W.optionals)for(let U of W.optionals)qE($,U);if(W.variadic)IE($,W.variadic);if(W.postfix)for(let U of W.postfix)L5($,U);return $},wC=($)=>`Spread element must be an array (was ${$})`,kE="A tuple may have at most one variadic element",JC="A required element may not follow an optional element",PE="An optional element may not follow a variadic element";var GC="A defaultable element may not follow an optional element without a default";var zC={},f8=($,T)=>{if(typeof $==="string"){if(T.args&&Object.keys(T.args).some((U)=>$.includes(U)))return E5($,T);let W=zC[T.$.name]??={};return W[$]??=E5($,T)}return c4($,"object")?HC($,T):S(S5(G4($)))},HC=($,T)=>{let W=zU($);switch(W){case void 0:if(d($,"root"))return $;return AE($,T);case"Array":return FC($,T);case"RegExp":return T.$.node("intersection",{domain:"string",pattern:$},{prereduced:!0});case"Function":{let U=p1($)?$():$;if(d(U,"root"))return U;return S(S5("Function"))}default:return S(S5(W??Y$($)))}},FC=($,T)=>NE($,T)??vE($,T),S5=($)=>`Type definitions must be strings or objects (was ${$})`;class B5 extends B6{constructor($){let T=Object.assign({errors:p4,hkt:L4,$,raw:$.parse,module:$.constructor.module,scope:$.constructor.scope,define:$.define,match:$.match,generic:$.generic,schema:$.schema,keywords:$.ambient,unit:$.unit,enumerated:$.enumerated,instanceOf:$.instanceOf,valueOf:$.valueOf,or:$.or,and:$.and,merge:$.merge,pipe:$.pipe},$.ambientAttachments);super((...W)=>{if(W.length===1)return $.parse(W[0]);if(W.length===2&&typeof W[0]==="string"&&W[0][0]==="<"&&W[0].at(-1)===">"){let U=W[0].slice(1,-1),X=$.parseGenericParams(U,{});return new i1(X,W[1],$,$,null)}return $.parse(W)},{bind:$,attach:T})}}var eT=v;class y8 extends I8{get ambientAttachments(){if(!eT.typeAttachments)return;return this.cacheGetter("ambientAttachments",X$(eT.typeAttachments,($,T)=>[$,this.bindReference(T)]))}preparseOwnAliasEntry($,T){let W=$.indexOf("<");if(W===-1){if(d(T,"module")||d(T,"generic"))return[$,T];let Y=this.name==="ark"?$:$==="root"?this.name:`${this.name}.${$}`,_=this.resolvedConfig.keywords?.[Y];if(_)T=[T,"@",_];return[$,T]}if($.at(-1)!==">")S("'>' must be the last character of a generic declaration in a scope");let U=$.slice(0,W),X=$.slice(W+1,-1);return[U,()=>{let Y=this.parseGenericParams(X,{alias:U});return tV(Y,T,this)}]}parseGenericParams($,T){return x8(new Z1($),[],this.createParseContext({...T,def:$,prefix:"generic"}))}normalizeRootScopeValue($){if(p1($)&&!d($,"generic"))return $();return $}preparseOwnDefinitionFormat($,T){return{...T,def:$,prefix:T.alias??"type"}}parseOwnDefinitionFormat($,T){if(!(T.alias&&(T.alias in this.aliases))&&!T.args)T.args={this:T.id};let U=f8($,T);if(I$(U)){if(U[1]==="=")return S(q8);if(U[1]==="?")return S(v8)}return U}unit=($)=>this.units([$]);valueOf=($)=>this.units(ZV($));enumerated=(...$)=>this.units($);instanceOf=($)=>this.node("proto",{proto:$},{prereduced:!0});or=(...$)=>this.schema($.map((T)=>this.parse(T)));and=(...$)=>$.reduce((T,W)=>T.and(this.parse(W)),this.intrinsic.unknown);merge=(...$)=>$.reduce((T,W)=>T.merge(this.parse(W)),this.intrinsic.object);pipe=(...$)=>this.intrinsic.unknown.pipe(...$);match=new A5(this);declare=()=>({type:this.type});define($){return $}type=new B5(this);static scope=($,T={})=>new y8($,T);static module=($,T={})=>this.scope($,T).export()}var R5=Object.assign(y8.scope,{define:($)=>$}),z$=y8;class CE extends L4{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var OC=D6(["base",n.object],["props",n.object])(($)=>$.base.merge($.props),CE),jE=z$.module({Key:n.key,Merge:OC});class xE extends L4{}var DC=D6("element")(($)=>{let T=$.element.exclude(n.Array),W=T.array();return T.rawOr(W).pipe(u1).distribute((U)=>U.assertHasKind("morph").declareOut(W),E$)},xE),bE=z$.module({root:n.Array,readonly:"root",index:n.nonNegativeIntegerString,liftFrom:DC},{name:"Array"});var I5=E$(["string",h0.FileConstructor]),QC=I5.rawOr(I5.array()),fE=E$({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:QC}}),yE=z$.module({root:["instanceof",FormData],value:I5,parsed:fE,parse:E$({in:FormData,morphs:($)=>{let T={};for(let[W,U]of $)if(W in T){let X=T[W];if(typeof X==="string"||X instanceof h0.FileConstructor)T[W]=[X,U];else X.push(U)}else T[W]=U;return T},declaredOut:fE})},{name:"FormData"});var hE=z$.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 ZC={Boolean:1,Number:1,String:1},gE=z$.module({...X$({...O7,...Q7},($,T)=>($ in ZC)?[]:[$,["instanceof",T]]),Array:bE,TypedArray:hE,FormData:yE});var VC=E$({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"}),KC=E$({domain:"number",divisor:1}),h8=z$.module({root:n.number,integer:KC,epoch:VC,safe:E$({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 h$=($,T,W)=>{let U={domain:"string",pattern:{rule:$.source,flags:$.flags,meta:T}};if(W)U.meta={format:W};return tT("intersection",U)},mE=h$(DU,"a well-formed integer string"),sE=z$.module({root:mE,parse:E$({in:mE,morphs:($,T)=>{let W=Number.parseInt($);return Number.isSafeInteger(W)?W:T.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:n.integer})},{name:"string.integer"}),EC=h$(/^[\dA-Fa-f]+$/,"hex characters only"),AC=z$.module({root:h$(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:h$(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),cE=h$(/^[A-Z].*$/,"capitalized"),MC=z$.module({root:E$({in:"string",morphs:($)=>$.charAt(0).toUpperCase()+$.slice(1),declaredOut:cE}),preformatted:cE},{name:"string.capitalize"}),NC=($)=>{let T=$.replaceAll(/[ -]+/g,""),W=0,U,X,Y=!1;for(let _=T.length-1;_>=0;_--){if(U=T.substring(_,_+1),X=Number.parseInt(U,10),Y)X*=2,W+=X>=10?X%10+1:X;else W+=X;Y=!Y}return!!(W%10===0?T:!1)},LC=/^(?: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}))$/,SC=E$({domain:"string",pattern:{meta:"a credit card number",rule:LC.source},predicate:{meta:"a credit card number",predicate:NC}});var BC=/^([+-]?\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 RC=($)=>!Number.isNaN(new Date($).valueOf()),uE=E$({domain:"string",predicate:{meta:"a parsable date",predicate:RC}}).assertHasKind("intersection"),pE=sE.root.internal.narrow(($,T)=>{let W=Number.parseInt($),U=h8.epoch(W);if(U instanceof p4)return T.errors.merge(U),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),IC=z$.module({root:pE,parse:E$({in:pE,morphs:($)=>new Date($),declaredOut:n.Date})},{name:"string.date.epoch"}),oE=h$(BC,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),kC=z$.module({root:oE,parse:E$({in:oE,morphs:($)=>new Date($),declaredOut:n.Date})},{name:"string.date.iso"}),vC=z$.module({root:uE,parse:E$({declaredIn:uE,in:"string",morphs:($,T)=>{let W=new Date($);if(Number.isNaN(W.valueOf()))return T.error("a parsable date");return W},declaredOut:n.Date}),iso:kC,epoch:IC},{name:"string.date"}),qC=h$(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),dE="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",n1=`(${dE}[.]){3}${dE}`,PC=new RegExp(`^${n1}$`),e$="(?:[0-9a-fA-F]{1,4})",CC=new RegExp(`^((?:${e$}:){7}(?:${e$}|:)|(?:${e$}:){6}(?:${n1}|:${e$}|:)|(?:${e$}:){5}(?::${n1}|(:${e$}){1,2}|:)|(?:${e$}:){4}(?:(:${e$}){0,1}:${n1}|(:${e$}){1,3}|:)|(?:${e$}:){3}(?:(:${e$}){0,2}:${n1}|(:${e$}){1,4}|:)|(?:${e$}:){2}(?:(:${e$}){0,3}:${n1}|(:${e$}){1,5}|:)|(?:${e$}:){1}(?:(:${e$}){0,4}:${n1}|(:${e$}){1,6}|:)|(?::((?::${e$}){0,5}:${n1}|(?::${e$}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),jC=z$.module({root:["v4 | v6","@","an IP address"],v4:h$(PC,"an IPv4 address","ipv4"),v6:h$(CC,"an IPv6 address","ipv6")},{name:"string.ip"}),$W="a JSON string",eE=($)=>{if(!($ instanceof SyntaxError))throw $;return`must be ${$W} (${$})`},xC=E$({meta:$W,domain:"string",predicate:{meta:$W,predicate:($,T)=>{try{return JSON.parse($),!0}catch(W){return T.reject({code:"predicate",expected:$W,problem:eE(W)})}}}}),bC=($,T)=>{if($.length===0)return T.error({code:"predicate",expected:$W,actual:"empty"});try{return JSON.parse($)}catch(W){return T.error({code:"predicate",expected:$W,problem:eE(W)})}},fC=z$.module({root:xC,parse:E$({meta:"safe JSON string parser",in:"string",morphs:bC,declaredOut:n.jsonObject})},{name:"string.json"}),lE=h$(/^[a-z]*$/,"only lowercase letters"),yC=z$.module({root:E$({in:"string",morphs:($)=>$.toLowerCase(),declaredOut:lE}),preformatted:lE},{name:"string.lower"}),$A=["NFC","NFD","NFKC","NFKD"],fU=X$($A,($,T)=>[T,E$({domain:"string",predicate:(W)=>W.normalize(T)===W,meta:`${T}-normalized unicode`})]),g8=X$($A,($,T)=>[T,E$({in:"string",morphs:(W)=>W.normalize(T),declaredOut:fU[T]})]),hC=z$.module({root:g8.NFC,preformatted:fU.NFC},{name:"string.normalize.NFC"}),gC=z$.module({root:g8.NFD,preformatted:fU.NFD},{name:"string.normalize.NFD"}),mC=z$.module({root:g8.NFKC,preformatted:fU.NFKC},{name:"string.normalize.NFKC"}),cC=z$.module({root:g8.NFKD,preformatted:fU.NFKD},{name:"string.normalize.NFKD"}),uC=z$.module({root:"NFC",NFC:hC,NFD:gC,NFKC:mC,NFKD:cC},{name:"string.normalize"}),rE=h$(F8,"a well-formed numeric string"),pC=z$.module({root:rE,parse:E$({in:rE,morphs:($)=>Number.parseFloat($),declaredOut:n.number})},{name:"string.numeric"}),iE="a regex pattern",oC=E$({domain:"string",predicate:{meta:iE,predicate:($,T)=>{try{return new RegExp($),!0}catch(W){return T.reject({code:"predicate",expected:iE,problem:String(W)})}}},meta:{format:"regex"}}),dC=/^(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-]+)*))?$/,lC=h$(dC,"a semantic version (see https://semver.org/)"),nE=h$(/^\S.*\S$|^\S?$/,"trimmed"),rC=z$.module({root:E$({in:"string",morphs:($)=>$.trim(),declaredOut:nE}),preformatted:nE},{name:"string.trim"}),tE=h$(/^[A-Z]*$/,"only uppercase letters"),iC=z$.module({root:E$({in:"string",morphs:($)=>$.toUpperCase(),declaredOut:tE}),preformatted:tE},{name:"string.upper"}),nC=($)=>{if(URL.canParse)return URL.canParse($);try{return new URL($),!0}catch{return!1}},aE=E$({domain:"string",predicate:{meta:"a URL string",predicate:nC},meta:{format:"uri"}}),tC=z$.module({root:aE,parse:E$({declaredIn:aE,in:"string",morphs:($,T)=>{try{return new URL($)}catch{return T.error("a URL string")}},declaredOut:E$(URL)})},{name:"string.url"}),aC=z$.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:h$(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:h$(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:h$(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:h$(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:h$(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:h$(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:h$(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:h$(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),TA=z$.module({root:n.string,alpha:h$(/^[A-Za-z]*$/,"only letters"),alphanumeric:h$(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:EC,base64:AC,capitalize:MC,creditCard:SC,date:vC,digits:h$(/^\d*$/,"only digits 0-9"),email:qC,integer:sE,ip:jC,json:fC,lower:yC,normalize:uC,numeric:pC,regex:oC,semver:lC,trim:rC,upper:iC,url:tC,uuid:aC},{name:"string"});var WA=z$.module({bigint:n.bigint,boolean:n.boolean,false:n.false,never:n.never,null:n.null,number:n.number,object:n.object,string:n.string,symbol:n.symbol,true:n.true,unknown:n.unknown,undefined:n.undefined}),UA=z$.module({root:n.unknown,any:n.unknown},{name:"unknown"}),sC=z$.module({root:n.jsonObject,stringify:tT("morph",{in:n.jsonObject,morphs:($)=>JSON.stringify($),declaredOut:n.string})},{name:"object.json"}),XA=z$.module({root:n.object,json:sC},{name:"object"});class YA extends L4{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var eC=D6(["K",n.key],"V")(($)=>({domain:"object",index:{signature:$.K,value:$.V}}),YA);class _A extends L4{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var $j=D6(["T",n.object],["K",n.key])(($)=>$.T.pick($.K),_A);class wA extends L4{description='omit a set of properties from an object like `Omit(User, "age")`'}var Tj=D6(["T",n.object],["K",n.key])(($)=>$.T.omit($.K),wA);class JA extends L4{description="make all named properties of an object optional like `Partial(User)`"}var Wj=D6(["T",n.object])(($)=>$.T.partial(),JA);class GA extends L4{description="make all named properties of an object required like `Required(User)`"}var Uj=D6(["T",n.object])(($)=>$.T.required(),GA);class zA extends L4{description='exclude branches of a union like `Exclude("boolean", "true")`'}var Xj=D6("T","U")(($)=>$.T.exclude($.U),zA);class HA extends L4{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var Yj=D6("T","U")(($)=>$.T.extract($.U),HA),FA=z$.module({Exclude:Xj,Extract:Yj,Omit:Tj,Partial:Wj,Pick:$j,Record:eC,Required:Uj});var t1=R5({...WA,...FA,...gE,...jE,string:TA,number:h8,object:XA,unknown:UA},{prereducedAliases:!0,name:"ark"}),H4=t1.export();Object.assign(eT.ambient,H4);eT.typeAttachments={string:H4.string.root,number:H4.number.root,bigint:H4.bigint,boolean:H4.boolean,symbol:H4.symbol,undefined:H4.undefined,null:H4.null,object:H4.object.root,unknown:H4.unknown.root,false:H4.false,true:H4.true,never:H4.never,arrayIndex:H4.Array.index,Key:H4.Key,Record:H4.Record,Array:H4.Array.root,Date:H4.Date};var k6=Object.assign(t1.type,eT.typeAttachments),_j=t1.match,wj=t1.generic,uU$=t1.schema,Jj=t1.define,Gj=t1.declare;var zj="__vite_start_time"in globalThis,Hj=typeof window!=="undefined",_X$="vitest"in globalThis,V1=k6("string"),OA=k6('"true" | "false" | undefined'),K1=z7({isServer:!zj&&!Hj,server:{CI:k6("string | undefined").pipe(Boolean),POSTGRES_USER:V1,POSTGRES_PASSWORD:V1,POSTGRES_DATABASE:V1,POSTGRES_HOST:V1,POSTGRES_PORT:V1.pipe(($)=>Number.parseInt($,10)),BACKEND_PORT:V1.pipe(($)=>Number.parseInt($,10)),RUN_WORKERS_FROM_SOURCE:OA.pipe(($)=>$==="true"),FRONTEND_PORT:V1.pipe(($)=>Number.parseInt($,10)),FRONTEND_ORIGINS:V1.pipe.try(($)=>JSON.parse($),k6("string[]")),API_KEY_OPENAI:k6("string | undefined"),API_KEY_RESEND:k6("string | undefined")},clientPrefix:"VITE_",client:{VITE_BACKEND_ORIGIN:V1,VITE_DEV_FRONTEND_HOST:k6("string | undefined"),VITE_DEV_HTTPS:OA.pipe(($)=>$==="true")},runtimeEnv:import.meta.env,emptyStringAsUndefined:!0});var v5={};N1(v5,{users:()=>c0,untrackedUserColumnNames:()=>Fj,twoFactorMethod:()=>KA,trackedUserColumnName:()=>Oj,trackableUserColumnNames:()=>ZA,signInHistory:()=>Qj,role:()=>QA,players:()=>k5,passwordResetAttempts:()=>Zj,games:()=>m8,banishedIps:()=>c8,accountActions:()=>Dj,accountAction:()=>VA});function DA($){return Z`lower(${$})`}var QA=m2("role",["admin","user"]),c0=g1("users",{id:G6().primaryKey().defaultRandom(),username:v4({length:16}).notNull(),emailOffered:v4({length:254}).notNull(),emailVerified:v4({length:254}),password:v4({length:254}),createdAt:N6({withTimezone:!0}).notNull().defaultNow(),createdIp:v4({length:45}).notNull(),isActive:l2().notNull().default(!1),verifiedAt:N6({withTimezone:!0}),userRole:QA().default("user")},($)=>[tz("usernameUniqueIndex").on(DA($.username)),tz("emailVerifiedUniqueIndex").on(DA($.emailVerified))]),Fj=["id","createdAt","createdIp","isActive","verifiedAt"],ZA=["username","emailOffered","emailVerified","password","userRole"],Oj=m2("trackedUserColumnName",ZA),VA=m2("accountAction",["cooldown","confirmEmail","signIn","resetPassword"]),Dj=g1("accountActions",{userId:G6().references(()=>c0.id).primaryKey(),action:VA().notNull(),code:v4({length:254}).notNull(),wrongCodeCount:r2().notNull().default(0),expiresAt:N6({withTimezone:!0}).notNull()}),m8=g1("games",{id:G6().primaryKey().defaultRandom()}),k5=g1("players",{userId:G6().notNull().references(()=>c0.id,{onDelete:"cascade"}),gameId:G6().notNull().references(()=>m8.id,{onDelete:"cascade"}),score:r2().notNull()},($)=>[XZ({name:"players_userId_gameId_pk",columns:[$.userId,$.gameId]})]),Qj=g1("signInHistory",{id:G6().primaryKey().defaultRandom(),userId:G6().references(()=>c0.id,{onDelete:"cascade"}),signInTime:N6({withTimezone:!0}).notNull().defaultNow(),ipAddress:v4({length:45}).notNull(),userAgent:v4({length:1024}),successful:l2().notNull().default(!1)}),KA=m2("twoFactorMethod",["email","phone"]),Zj=g1("passwordResetAttempts",{id:G6().primaryKey().defaultRandom(),userId:G6().notNull().references(()=>c0.id,{onDelete:"cascade"}),requestedIp:v4({length:45}).notNull(),requestedAt:N6({withTimezone:!0}).notNull().defaultNow(),succeededIp:v4({length:45}),succeededAt:N6({withTimezone:!0}),verificationMethod:KA().notNull()}),c8=g1("banishedIps",{ip:v4({length:45}).primaryKey(),reason:v4({length:2048}).notNull(),banishedAt:N6({withTimezone:!0}).notNull().defaultNow(),banishedUntil:N6({withTimezone:!0})});var __dirname="/home/runner/work/wayforge/wayforge/apps/tempest.games/src/database";class q5{options;sql;drizzle;observers=new Map;async setupTriggersAndNotifications(){await this.sql.file(Vj.resolve(__dirname,"notify_update.sql"));let $=[O4(c0),O4(m8),O4(k5)];await this.sql`SELECT create_notify_triggers(${this.sql.array($)})`,await this.sql.listen("table_update",(T)=>{let W=T.split(","),U=W[0],X=W[1],Y=`${U}("${X}")`;if(this.observers.has(Y))this.observers.get(Y).next(Y)})}constructor($=!1,T={host:K1.POSTGRES_HOST,port:K1.POSTGRES_PORT,user:K1.POSTGRES_USER,password:K1.POSTGRES_PASSWORD,database:K1.POSTGRES_DATABASE}){this.options=T,this.sql=jT(T),this.drizzle=z8(this.sql,{schema:v5,logger:$})}observe($,T){if(!this.observers.has($))this.observers.set($,new K$);this.observers.get($).subscribe("SINGLETON",T)}}import{resolve as Aj}from"path";import{existsSync as P5,mkdirSync as EA,readFileSync as Kj,readdirSync as AA,rmSync as MA,statSync as NA,writeFileSync as Ej}from"fs";import{resolve as C5}from"path";var LA=class{rootDir;get initialized(){return P5(this.rootDir)}initialize(){if(!this.initialized)EA(this.rootDir,{recursive:!0})}constructor($){if(this.rootDir=$.path,$.eagerInit)this.initialize()}getItem($){let T=C5(this.rootDir,$);if(P5(T))return Kj(T,"utf-8");return null}setItem($,T){this.initialize();let W=C5(this.rootDir,$);Ej(W,T)}removeItem($){let T=C5(this.rootDir,$);if(P5(T))this.initialize(),MA(T)}key($){return AA(this.rootDir).sort((U,X)=>{let Y=NA(U);return NA(X).ctimeMs-Y.ctimeMs})[$]??null}clear(){MA(this.rootDir,{recursive:!0}),EA(this.rootDir,{recursive:!0})}get length(){return AA(this.rootDir).length}};var j5=new LA({path:Aj(process.cwd(),"storage")});import*as u8 from"fs";import*as SA from"readline";function Mj($){let W=$.replace(":","T").replace(" ","").replace(/(\d{2})\/(\w{3})\/(\d{4})T(.+)/,(U,X,Y,_,w)=>{let J={Jan:"01",Feb:"02",Mar:"03",Apr:"04",May:"05",Jun:"06",Jul:"07",Aug:"08",Sep:"09",Oct:"10",Nov:"11",Dec:"12"}[Y];return`${_}-${J}-${X}T${w}`});return new Date(W)}async function BA($,T="/var/log/nginx/access.log",W=new Date){let U=new Map;if(!u8.existsSync(T))return $.error(`Log file not found: ${T}`),U;let X=u8.createReadStream(T),Y=SA.createInterface({input:X,crlfDelay:Number.POSITIVE_INFINITY}),_=new Date(W.getTime()-3600000);return Y.on("line",(w)=>{let G=/^(?<ip>\S+) \S+ \S+ \[(?<dateTime>.*?)\]/,J=w.match(G);if(J?.groups){let H=J.groups.ip,z=J.groups.dateTime,F=Mj(z);if(!Number.isNaN(F.getTime())){if(F>=_&&F<=W){let Q=U.get(H);if(!Q)Q=[],U.set(H,Q);Q.push(w)}}else $.error(`Failed to parse date: ${z}`)}}),new Promise((w,G)=>{Y.on("error",(J)=>{G(J)}),Y.on("close",()=>{w(U)})})}function RA($){return $.toJsonSchema()}var Nj=["Network security adjudicator, your job is to determine if an IP address should be banned.","The IP address in question created the following logs on our server today:","```nginx.log\n"].join(`
153
- `);function IA($){return Nj+$.join(`
154
+ `)+"}");class Oz{config;resolvedConfig;name;get[C6](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor($,T){if(this.config=IU(y.config,T),this.resolvedConfig=IU(y.resolvedConfig,T),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(_Z).length}`,this.name in _Z)B(`A Scope already named ${this.name} already exists`);_Z[this.name]=this;let W=Object.entries($).map((w)=>this.preparseOwnAliasEntry(...w));for(let[w,X]of W){let U=w;if(w[0]==="#"){if(U=w.slice(1),U in this.aliases)B(N_(U));this.aliases[U]=X}else{if(U in this.aliases)B(N_(w));this.aliases[U]=X,this.exportedNames.push(U)}if(!W$(X,"module")&&!W$(X,"generic")&&!IT(X)){let Y=this.preparseOwnDefinitionFormat(X,{alias:U});this.resolutions[U]=W$(Y,"root")?this.bindReference(Y):this.createParseContext(Y).id}}L_??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[L_.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=y.intrinsic?E$(y.intrinsic,(w,X)=>w.startsWith("json")?[]:[w,this.bindReference(X)]):{}}cacheGetter($,T){return Object.defineProperty(this,$,{value:T}),T}get internal(){return this}_json;get json(){if(!this._json)this.export();return this._json}defineSchema($){return $}generic=(...$)=>{let T=this;return(W,w)=>new yT($,w?new Xz(W):W,T,T,w??null)};units=($,T)=>{let W=[];for(let X of $)if(!W.includes(X))W.push(X);let w=W.map((X)=>this.node("unit",{unit:X},T));return this.node("union",w,{...T,prereduced:!0})};lazyResolutions=[];lazilyResolve($,T){let W=this.node("alias",{reference:T??"synthetic",resolve:$},{prereduced:!0});if(!this.resolved)this.lazyResolutions.push(W);return W}schema=($,T)=>this.finalize(this.parseSchema($,T));parseSchema=($,T)=>this.node(bU($),$,T);preparseNode($,T,W){let w=typeof $==="string"?$:bU(T,$);if(a$(T)&&T.kind===w)return T;if(w==="alias"&&!W?.prereduced){let{reference:Y}=uU.implementation.normalize(T,this);if(Y.startsWith("$")){let G=this.resolveRoot(Y.slice(1));T=G,w=G.kind}}else if(w==="union"&&p6(T,"object")){let Y=jf(T);if(Y?.length===1)T=Y[0],w=bU(T)}if(a$(T)&&T.kind===w)return T;let U=GX[w].normalize?.(T,this)??T;if(a$(U))return U.kind===w?U:If(w,U.kind);return{...W,$:this,kind:w,def:U,prefix:W.alias??w}}bindReference($){let T;if(a$($))T=$.$===this?$:new $.constructor($.attachments,this);else T=$.$===this?$:new yT($.params,$.bodyDef,$.$,this,$.hkt);if(!this.resolved)Object.assign(this.referencesById,T.referencesById);return T}resolveRoot($){return this.maybeResolveRoot($)??B(qZ($))}maybeResolveRoot($){let T=this.maybeResolve($);if(W$(T,"generic"))return;return T}maybeResolveSubalias($){return kZ(this.aliases,$)??kZ(this.ambient,$)}get ambient(){return y.ambient}maybeResolve($){let T=this.resolutions[$];if(T){if(typeof T!=="string")return this.bindReference(T);let w=S6[T];if(W$(w,"root"))return this.resolutions[$]=w;if(W$(w,"context")){if(w.phase==="resolving")return this.node("alias",{reference:`$${$}`},{prereduced:!0});if(w.phase==="resolved")return I$(`Unexpected resolved context for was uncached by its scope: ${M$(w)}`);w.phase="resolving";let X=this.bindReference(this.parseOwnDefinitionFormat(w.def,w));return w.phase="resolved",S6[X.id]=X,S6[w.id]=X,this.resolutions[$]=X}return I$(`Unexpected nodesById entry for ${T}: ${M$(w)}`)}let W=this.aliases[$]??this.ambient?.[$];if(!W)return this.maybeResolveSubalias($);if(W=this.normalizeRootScopeValue(W),W$(W,"generic"))return this.resolutions[$]=this.bindReference(W);if(W$(W,"module")){if(!W.root)B(P_($));return this.resolutions[$]=this.bindReference(W.root)}return this.resolutions[$]=this.parse(W,{alias:$})}createParseContext($){let T=$.id??GZ($.prefix);return S6[T]=Object.assign($,{[C6]:"context",$:this,id:T,phase:"unresolved"})}traversal($){return new g1($,this.resolvedConfig)}import(...$){return new FX(E$(this.export(...$),(T,W)=>[`#${T}`,W]))}precompilation;_exportedResolutions;_exports;export(...$){if(!this._exports){this._exports={};for(let W of this.exportedNames){let w=this.aliases[W];this._exports[W]=W$(w,"module")?RZ(w,this):J_(this.maybeResolve(W))}for(let W of this.lazyResolutions)W.resolution;if(this._exportedResolutions=q_(this,this._exports),this._json=v_(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let W=k_(this.references);this.precompilation=W.write(R_,4),__(this.references,W)}this.resolved=!0}let T=$.length?$:this.exportedNames;return new FX(E$(T,(W,w)=>[w,this._exports[w]]))}resolve($){return this.export()[$]}node=($,T,W={})=>{let w=this.preparseNode($,T,W);if(a$(w))return this.bindReference(w);let X=this.createParseContext(w),U=zZ(X),Y=this.bindReference(U);return S6[X.id]=Y};parse=($,T={})=>this.finalize(this.parseDefinition($,T));parseDefinition($,T={}){if(W$($,"root"))return this.bindReference($);let W=this.preparseOwnDefinitionFormat($,T);if(W$(W,"root"))return this.bindReference(W);let w=this.createParseContext(W);S6[w.id]=w;let X=this.bindReference(this.parseOwnDefinitionFormat($,w));if(X.isCyclic)X=nR(X,w.id);return S6[w.id]=X,X}finalize($){if(J_($),!$.precompilation&&!this.resolvedConfig.jitless)Bf($.references);return $}}class vZ extends Oz{parseOwnDefinitionFormat($,T){return zZ(T)}preparseOwnDefinitionFormat($,T){return this.preparseNode(bU($),$,T)}preparseOwnAliasEntry($,T){return[$,T]}normalizeRootScopeValue($){return $}}var J_=($)=>{let T=$.references.filter((W)=>W.hasKind("alias"));for(let W of T){Object.assign(W.referencesById,W.resolution.referencesById);for(let w of $.references)if(W.id in w.referencesById)Object.assign(w.referencesById,W.referencesById)}return $},v_=($)=>E$($,(T,W)=>[T,W$(W,"root")||W$(W,"generic")?W.json:W$(W,"module")?v_(W):I$(`Unexpected resolution ${M$(W)}`)]),kZ=($,T)=>{let W=T.indexOf(".");if(W===-1)return;let w=T.slice(0,W),X=$[w];if(X===void 0)return;if(!W$(X,"module"))return B(xf(w));let U=T.slice(W+1),Y=X[U];if(Y===void 0)return kZ(X,U);if(W$(Y,"root")||W$(Y,"generic"))return Y;if(W$(Y,"module"))return Y.root??B(P_(T));I$(`Unexpected resolution for alias '${T}': ${M$(Y)}`)},Qz=($,T)=>new vZ($,T),oU=new vZ({});var q_=($,T)=>{let W={};for(let w in T){let X=T[w];if(W$(X,"module")){let U=q_($,X),Y=E$(U,(G,H)=>[`${w}.${G}`,H]);Object.assign(W,Y)}else if(W$(X,"root")||W$(X,"generic"))W[w]=X;else I$(`Unexpected scope resolution ${M$(X)}`)}return W},qZ=($)=>`'${$}' is unresolvable`,xf=($)=>`'${$}' must reference a module to be accessed using dot syntax`,P_=($)=>`Reference to submodule '${$}' must specify an alias`;oU.export();var{schema:h$,node:OX,defineSchema:_U$,generic:v1}=oU;var PZ="^(?:0|[1-9]\\d*)$",ff=new RegExp(PZ),qU$=Z4(ff);var C_=Qz({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();y.intrinsic={...C_};var S_=Qz({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:PZ}},{prereducedAliases:!0}).export();Object.assign(y.intrinsic,S_);var bf=Qz({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),G$={...C_,...S_,...bf,emptyStructure:OX("structure",{},{prereduced:!0})};y.intrinsic={...G$};var I_=($)=>typeof $==="string"&&$[0]==="d"&&($[1]==="'"||$[1]==='"')&&$.at(-1)===$[1],j_=($)=>$.toString()!=="Invalid Date",B_=($)=>$.slice(2,-1),CZ=($)=>`'${$}' could not be parsed by the Date constructor`,x_=($,T)=>yf($,T),yf=($,T)=>{let W=new Date($);if(j_(W))return W;let w=QR($);if(w!==void 0){let X=new Date(w);if(j_(X))return X}return T?B(T===!0?CZ($):T):void 0};var SZ=($,T)=>{let W=$.scanner.shiftUntil(hf[b_[T]]);if($.scanner.lookahead==="")return $.error(mf(W,T));if($.scanner.shift(),T==="/"){try{new RegExp(W)}catch(w){B(String(w))}$.root=$.ctx.$.node("intersection",{domain:"string",pattern:W},{prereduced:!0})}else if(b4(T,jZ))$.root=$.ctx.$.node("unit",{unit:W});else{let w=x_(W,CZ(W));$.root=$.ctx.$.node("unit",{meta:W,unit:w})}},jZ={"'":1,'"':1},f_={"/":1,"'":1,'"':1},b_={"d'":"'",'d"':'"',"'":"'",'"':'"',"/":"/"},hf={"'":($)=>$.lookahead==="'",'"':($)=>$.lookahead==='"',"/":($)=>$.lookahead==="/"},gf={'"':"double-quote","'":"single-quote","/":"forward slash"},mf=($,T)=>`${T}${$} requires a closing ${gf[b_[T]]}`;var y_=($)=>`Private type references should not include '#'. Use '${$}' instead.`,Zz="Optional definitions like 'string?' are only valid as properties in an object or tuple",Vz="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var h_={">":!0,">=":!0},g_={"<":!0,"<=":!0};var QX={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},m_=($)=>`Unmatched )${$===""?"":` before ${$}`}`,Kz=($)=>`Missing ${$}`,c_=($,T)=>`Left bounds are only valid when paired with right bounds (try ...${T}${$})`,Az=($)=>`Left-bounded expressions must specify their limits using < or <= (was ${$})`,u_=($,T,W,w)=>`An expression may have at most one left bound (parsed ${$}${QX[T]}, ${W}${QX[w]})`;var p_=($,T,W)=>d_($,T,W,[]),d_=($,T,W,w)=>{let X=W.parseUntilFinalizer();if(w.push(X.root),X.finalizer===">"){if(w.length!==T.params.length)return W.error(IZ($,T.names,w.map((U)=>U.expression)));return w}if(X.finalizer===",")return d_($,T,W,w);return X.error(Kz(">"))},IZ=($,T,W)=>`${$}<${T.join(", ")}> requires exactly ${T.length} args (got ${W.length}${W.length===0?"":`: ${W.join(", ")}`})`;var BZ=($)=>{let T=$.scanner.shiftUntilNextTerminator();if(T==="keyof")$.addPrefix("keyof");else $.root=uf($,T)},cf=($,T,W)=>{if(W.scanner.shiftUntilNonWhitespace(),W.scanner.shift()!=="<")return W.error(IZ($,T.names,[]));let X=p_($,T,W);return T(...X)},uf=($,T)=>pf($,T)??df($,T)??$.error(T===""?$.scanner.lookahead==="#"?y_($.shiftedByOne().scanner.shiftUntilNextTerminator()):xZ($):qZ(T)),pf=($,T)=>{if($.ctx.args?.[T]){let w=$.ctx.args[T];if(typeof w!=="string")return w;return $.ctx.$.node("alias",{reference:w},{prereduced:!0})}let W=$.ctx.$.maybeResolve(T);if(W$(W,"root"))return W;if(W===void 0)return;if(W$(W,"generic"))return cf(T,W,$);return B(`Unexpected resolution ${M$(W)}`)},df=($,T)=>{let W=ZR(T);if(W!==void 0)return $.ctx.$.node("unit",{unit:W});let w=KR(T);if(w!==void 0)return $.ctx.$.node("unit",{unit:w})},xZ=($)=>{let T=$.previousOperator();return T?fZ(T,$.scanner.unscanned):of($.scanner.unscanned)},fZ=($,T="")=>`Token '${$}' requires a right operand${T?` before '${T}'`:""}`,of=($)=>`Expected an expression${$?` before '${$}'`:""}`;var bZ=($)=>$.scanner.lookahead===""?$.error(xZ($)):$.scanner.lookahead==="("?$.shiftedByOne().reduceGroupOpen():$.scanner.lookaheadIsIn(f_)?SZ($,$.scanner.shift()):$.scanner.lookaheadIsIn(BT)?bZ($.shiftedByOne()):$.scanner.lookahead==="d"?$.scanner.nextLookahead in jZ?SZ($,`${$.scanner.shift()}${$.scanner.shift()}`):BZ($):BZ($);class r0 extends cQ{shiftUntilNextTerminator(){return this.shiftUntilNonWhitespace(),this.shiftUntil(()=>(this.lookahead in r0.terminatingChars))}static terminatingChars={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...BT};static finalizingLookaheads={">":1,",":1,"":1,"=":1,"?":1};static lookaheadIsFinalizing=($,T)=>$===">"?T[0]==="="?T[1]==="=":T.trimStart()===""||b4(T.trimStart()[0],r0.terminatingChars):$==="="?T[0]!=="=":$===","||$==="?"}var l_=($,T)=>{let W=lf($,T);if($.root.hasKind("unit")){if(typeof $.root.unit==="number"){$.reduceLeftBound($.root.unit,W),$.unsetRoot();return}if($.root.unit instanceof Date){let w=`d'${$.root.description??$.root.unit.toISOString()}'`;$.unsetRoot(),$.reduceLeftBound(w,W);return}}return nf($,W)},r_={"<":1,">":1,"=":1},lf=($,T)=>$.scanner.lookaheadIs("=")?`${T}${$.scanner.shift()}`:T;var o_=($,T,W,w)=>{if(W.extends(y.intrinsic.number)){if(typeof T!=="number")return B(yZ($,T,w));return $==="=="?["min","max"]:$[0]===">"?["min"]:["max"]}if(W.extends(y.intrinsic.lengthBoundable)){if(typeof T!=="number")return B(yZ($,T,w));return $==="=="?["exactLength"]:$[0]===">"?["minLength"]:["maxLength"]}if(W.extends(y.intrinsic.Date))return $==="=="?["after","before"]:$[0]===">"?["after"]:["before"];return B(fR(W.expression))},rf=($)=>({rule:I_($.limit)?B_($.limit):$.limit,exclusive:$.comparator.length===1}),nf=($,T)=>{let W=$.unsetRoot(),w=$.scanner.location;$.parseOperand();let X=$.unsetRoot(),U=$.scanner.sliceChars(w,$.scanner.location);if($.root=W,!X.hasKind("unit")||typeof X.unit!=="number"&&!(X.unit instanceof Date))return $.error(yZ(T,U,"right"));let Y=X.unit,G=T.length===1,H=o_(T,typeof Y==="number"?Y:U,W,"right");for(let F of H)$.constrainRoot(F,T==="=="?{rule:Y}:{rule:Y,exclusive:G});if(!$.branches.leftBound)return;if(!b4(T,g_))return $.error(Az(T));let z=o_($.branches.leftBound.comparator,$.branches.leftBound.limit,W,"left");$.constrainRoot(z[0],rf($.branches.leftBound)),$.branches.leftBound=null},yZ=($,T,W)=>`Comparator ${W==="left"?QX[$]:$} must be ${W==="left"?"preceded":"followed"} by a corresponding literal (was ${T})`;var n_=($)=>{$.scanner.shiftUntilNonWhitespace();let T=$.scanner.shiftUntilNextTerminator();$.root=$.root.brand(T)};var t_=($)=>{let T=$.scanner.shiftUntilNextTerminator(),W=VR(T,{errorOnFail:i_(T)});if(W===0)$.error(i_(0));$.root=$.root.constrain("divisor",W)},i_=($)=>`% operator must be followed by a non-zero integer literal (was ${$})`;var hZ=($)=>{let T=$.scanner.shift();return T===""?$.finalize(""):T==="["?$.scanner.shift()==="]"?$.setRoot($.root.array()):$.error(tf):T==="|"?$.scanner.lookahead===">"?$.shiftedByOne().pushRootToBranch("|>"):$.pushRootToBranch(T):T==="&"?$.pushRootToBranch(T):T===")"?$.finalizeGroup():r0.lookaheadIsFinalizing(T,$.scanner.unscanned)?$.finalize(T):b4(T,r_)?l_($,T):T==="%"?t_($):T==="#"?n_($):(T in BT)?hZ($):$.error(Ez(T))},Ez=($,T="")=>`'${$}' is not allowed here${T&&` (should be ${T})`}`,tf="Missing expected ']'";var a_=($)=>{let T=$.unsetRoot();$.parseOperand();let W=$.unsetRoot();if(!W.hasKind("unit"))return $.error(af(W.expression));let w=W.unit instanceof Date?()=>new Date(W.unit):W.unit;return[T,"=",w]},af=($)=>`Default value '${$}' must a literal value`;var gZ=($,T)=>{let W=T.$.maybeResolveRoot($);if(W)return W;if($.endsWith("[]")){let U=T.$.maybeResolveRoot($.slice(0,-2));if(U)return U.array()}let w=new ZX(new r0($),T),X=sf(w);if(w.finalizer===">")B(Ez(">"));return X},sf=($)=>{$.parseOperand();let T=lU($).root;if(!T)return I$(`Root was unexpectedly unset after parsing string '${$.scanner.scanned}'`);if($.finalizer==="=")T=a_($);else if($.finalizer==="?")T=[T,"?"];if($.scanner.shiftUntilNonWhitespace(),$.scanner.lookahead)B(Ez($.scanner.lookahead));return T},lU=($)=>{while($.finalizer===void 0)ef($);return $},ef=($)=>$.hasRoot()?$.parseOperator():$.parseOperand();class ZX{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor($,T){this.scanner=$,this.ctx=T}error($){return B($)}hasRoot(){return this.root!==void 0}setRoot($){this.root=$}unsetRoot(){let $=this.root;return this.root=void 0,$}constrainRoot(...$){this.root=this.root.constrain($[0],$[1])}finalize($){if(this.groups.length)return this.error(Kz(")"));this.finalizeBranches(),this.finalizer=$}reduceLeftBound($,T){let W=QX[T];if(!b4(W,h_))return this.error(Az(T));if(this.branches.leftBound)return this.error(u_(this.branches.leftBound.limit,this.branches.leftBound.comparator,$,W));this.branches.leftBound={comparator:W,limit:$}}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 $=this.groups.pop();if(!$)return this.error(m_(this.scanner.unscanned));this.branches=$}addPrefix($){this.branches.prefixes.push($)}applyPrefixes(){while(this.branches.prefixes.length){let $=this.branches.prefixes.pop();this.root=$==="keyof"?this.root.keyof():I$(`Unexpected prefix '${$}'`)}}pushRootToBranch($){this.assertRangeUnset(),this.applyPrefixes();let T=this.root;if(this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(T)??T,$==="&")return;if(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,$==="|")return;this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null}parseUntilFinalizer(){return lU(new ZX(this.scanner,this.ctx))}parseOperator(){return hZ(this)}parseOperand(){return bZ(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(c_(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 $b="An empty string is not a valid generic parameter name",Mz=($,T,W)=>{$.shiftUntilNonWhitespace();let w=$.shiftUntilNextTerminator();if(w===""){if($.lookahead===""&&T.length)return T;return B($b)}return $.shiftUntilNonWhitespace(),Tb($,w,T,W)},s_="extends ",Tb=($,T,W,w)=>{if($.shiftUntilNonWhitespace(),$.unscanned.startsWith(s_))$.jumpForward(s_.length);else{if($.lookahead===",")$.shift();return W.push(T),Mz($,W,w)}let X=lU(new ZX($,w));return W.push([T,X.root]),Mz($,W,w)};class mZ extends h1{$;constructor($){super((...T)=>new rU($)(...T),{bind:$});this.$=$}in($){return new rU(this.$,$===void 0?void 0:this.$.parse($))}at($,T){return new rU(this.$).at($,T)}case($,T){return new rU(this.$).case($,T)}}class rU extends h1{$;in;key;branches=[];constructor($,T){super((W)=>this.caseEntries(Object.entries(W).map(([w,X])=>w==="default"?[w,X]:[this.$.parse(w),X])));this.$=$,this.in=T}at($,T){if(this.key)B(Xb);if(this.branches.length)B(Wb);return this.key=$,T?this.match(T):this}case($,T){return this.caseEntry(this.$.parse($),T)}caseEntry($,T){let w=(this.key?this.$.parse({[this.key]:$}):$).pipe(T);return this.branches.push(w),this}match($){return this($)}strings($){return this.caseEntries(Object.entries($).map(([T,W])=>T==="default"?[T,W]:[this.$.node("unit",{unit:T}),W]))}caseEntries($){for(let T=0;T<$.length;T++){let[W,w]=$[T];if(W==="default"){if(T!==$.length-1)B("default may only be specified as the last key of a switch definition");return this.default(w)}if(typeof w!=="function")return B(`Value for case "${W}" must be a function (was ${f4(w)})`);this.caseEntry(W,w)}return this}default($){if(typeof $==="function")this.case(G$.unknown,$);let T={branches:this.branches,ordered:!0};if($==="never"||$==="assert")T.meta={onFail:e_};let W=this.$.node("union",T);if(!this.in)return this.$.finalize(W);let w=this.in.pipe(W);if($==="never"||$==="assert")w=w.configureReferences({onFail:e_},"self");return this.$.finalize(w)}}var e_=($)=>$.throw(),Wb="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",Xb="At most one key matcher may be specified per expression";var Dz=($,T)=>{if(o$($)){if($[1]==="=")return[T.$.parseOwnDefinitionFormat($[0],T),"=",$[2]];if($[1]==="?")return[T.$.parseOwnDefinitionFormat($[0],T),"?"]}return Nz($,T)},$k="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",Tk="Only required keys may specify default values, e.g. { value: 'number = 0' }";var Wk=($,T)=>{let W,w={},X=IW($);for(let[Y,G]of X){let H=Yb(Y);if(H.kind==="spread"){if(!H0(w))return B(Ub);let Z=T.$.parseOwnDefinitionFormat(G,T);if(Z.equals(G$.object))continue;if(!Z.hasKind("intersection")||!Z.basis?.equals(G$.object))return B(Gb(Z.expression));W=Z.structure;continue}if(H.kind==="undeclared"){if(G!=="reject"&&G!=="delete"&&G!=="ignore")B(wb(G));w.undeclared=G;continue}let z=Dz(G,T),F=H;if(H.kind==="required"){if(!o$(z))cZ(w,"required",{key:H.normalized,value:z},T);else cZ(w,"optional",z[1]==="="?{key:H.normalized,value:z[0],default:z[2]}:{key:H.normalized,value:z[0]},T);continue}if(o$(z)){if(z[1]==="?")B($k);if(z[1]==="=")B(Tk)}if(H.kind==="optional"){cZ(w,"optional",{key:H.normalized,value:z},T);continue}let O=T.$.parseOwnDefinitionFormat(F.normalized,T),Q=Fz(O,z,T.$);if(Q.index)w.index=C$(w.index,Q.index);if(Q.required)w.required=C$(w.required,Q.required)}let U=T.$.node("structure",w);return T.$.parseSchema({domain:"object",structure:W?.merge(U)??U})},cZ=($,T,W,w)=>{$[T]=C$($[T],w.$.node(T,W))},wb=($)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${M$($)})`,Ub="Spread operator may only be used as the first key in an object",Yb=($)=>typeof $==="symbol"?{kind:"required",normalized:$}:$.at(-1)==="?"?$.at(-2)===kU?{kind:"required",normalized:`${$.slice(0,-2)}?`}:{kind:"optional",normalized:$.slice(0,-1)}:$[0]==="["&&$.at(-1)==="]"?{kind:"index",normalized:$.slice(1,-1)}:$[0]===kU&&$[1]==="["&&$.at(-1)==="]"?{kind:"required",normalized:$.slice(1)}:$==="..."?{kind:"spread"}:$==="+"?{kind:"undeclared"}:{kind:"required",normalized:$==="\\..."?"...":$==="\\+"?"+":$},Gb=($)=>`Spread operand must resolve to an object literal type (was ${$})`;var wk=($,T)=>Eb($)?zk[$[0]]($,T):Kb($)?Gk[$[1]]($,T):null,zb=($,T)=>T.$.parseOwnDefinitionFormat($[1],T).keyof(),uZ=($,T)=>{if($[2]===void 0)return B(fZ($[1],""));let W=T.$.parseOwnDefinitionFormat($[0],T),w=T.$.parseOwnDefinitionFormat($[2],T);if($[1]==="|")return T.$.node("union",{branches:[W,w]});let X=$[1]==="&"?r6(W,w,T.$):fU(W,w,T.$);if(X instanceof r)return X.throw();return X},Hb=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).array(),Fb=($,T)=>{if(typeof $[2]!=="function")return B(Uk("=>",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).pipe($[2])},Uk=($,T)=>`${$===":"?"Narrow":"Morph"} expression requires a function following '${$}' (was ${typeof T})`,Ob=($,T)=>{if(typeof $[2]!=="function")return B(Uk(":",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).constrain("predicate",$[2])},Qb=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).configureReferences($[2],"shallow"),Yk=($)=>$,Zb=Yk({"[]":Hb,"?":()=>B(Zz)}),Vb=Yk({"|":uZ,"&":uZ,":":Ob,"=>":Fb,"|>":uZ,"@":Qb,"=":()=>B(Vz)}),Gk={...Zb,...Vb},Kb=($)=>Gk[$[1]]!==void 0,Ab=($)=>$,zk=Ab({keyof:zb,instanceof:($,T)=>{if(typeof $[1]!=="function")return B(Xk(RU($[1])));let W=$.slice(1).map((w)=>typeof w==="function"?T.$.node("proto",{proto:w}):B(Xk(RU(w))));return W.length===1?W[0]:T.$.node("union",{branches:W})},"===":($,T)=>T.$.units($.slice(1))}),Eb=($)=>zk[$[0]]!==void 0,Xk=($)=>`Expected a constructor following 'instanceof' operator (was ${$})`;var Ok=($,T)=>{let W=[{}],w=0;while(w<$.length){let X=!1;if($[w]==="..."&&w<$.length-1)X=!0,w++;let U=Dz($[w],T),[Y,G,H]=!o$(U)?[U]:U;if(w++,X){if(!Y.extends(y.intrinsic.Array))return B(Nb(Y.expression));W=W.flatMap((z)=>Y.distribute((F)=>Db(e9(z),F)))}else W=W.map((z)=>{if(G==="?")return Qk(z,Y);if(G==="=")return Mb(z,Y,H);return pZ(z,Y)})}return T.$.parseSchema(W.map((X)=>H0(X)?{proto:Array,exactLength:0}:{proto:Array,sequence:X}))},pZ=($,T)=>{if($.defaultables||$.optionals)return B($.variadic?NZ:Lb);if($.variadic)$.postfix=C$($.postfix,T);else $.prefix=C$($.prefix,T);return $},Qk=($,T)=>{if($.variadic)return B(Zk);return $.optionals=C$($.optionals,T),$},Mb=($,T,W)=>{if($.variadic)return B(Zk);if($.optionals)return B(Jb);return $.defaultables=C$($.defaultables,[[T,W]]),$},Hk=($,T)=>{if($.postfix)B(Fk);if($.variadic){if(!$.variadic.equals(T))B(Fk)}else $.variadic=T.internal;return $},Db=($,T)=>{let W=T.select({method:"find",kind:"sequence"});if(!W)return Hk($,y.intrinsic.unknown);if(W.prefix)for(let w of W.prefix)pZ($,w);if(W.optionals)for(let w of W.optionals)Qk($,w);if(W.variadic)Hk($,W.variadic);if(W.postfix)for(let w of W.postfix)pZ($,w);return $},Nb=($)=>`Spread element must be an array (was ${$})`,Fk="A tuple may have at most one variadic element",Lb="A required element may not follow an optional element",Zk="An optional element may not follow a variadic element";var Jb="A defaultable element may not follow an optional element without a default";var Rb={},Nz=($,T)=>{if(typeof $==="string"){if(T.args&&Object.keys(T.args).some((w)=>$.includes(w)))return gZ($,T);let W=Rb[T.$.name]??={};return W[$]??=gZ($,T)}return p6($,"object")?_b($,T):B(dZ(f4($)))},_b=($,T)=>{let W=JU($);switch(W){case void 0:if(W$($,"root"))return $;return Wk($,T);case"Array":return kb($,T);case"RegExp":return T.$.node("intersection",{domain:"string",pattern:$},{prereduced:!0});case"Function":{let w=IT($)?$():$;if(W$(w,"root"))return w;return B(dZ("Function"))}default:return B(dZ(W??M$($)))}},kb=($,T)=>wk($,T)??Ok($,T),dZ=($)=>`Type definitions must be strings or objects (was ${$})`;class oZ extends h1{constructor($){let T=Object.assign({errors:o6,hkt:w6,$,raw:$.parse,module:$.constructor.module,scope:$.constructor.scope,define:$.define,match:$.match,generic:$.generic,schema:$.schema,keywords:$.ambient,unit:$.unit,enumerated:$.enumerated,instanceOf:$.instanceOf,valueOf:$.valueOf,or:$.or,and:$.and,merge:$.merge,pipe:$.pipe},$.ambientAttachments);super((...W)=>{if(W.length===1)return $.parse(W[0]);if(W.length===2&&typeof W[0]==="string"&&W[0][0]==="<"&&W[0].at(-1)===">"){let w=W[0].slice(1,-1),X=$.parseGenericParams(w,{});return new yT(X,W[1],$,$,null)}return $.parse(W)},{bind:$,attach:T})}}var VX=y;class Lz extends Oz{get ambientAttachments(){if(!VX.typeAttachments)return;return this.cacheGetter("ambientAttachments",E$(VX.typeAttachments,($,T)=>[$,this.bindReference(T)]))}preparseOwnAliasEntry($,T){let W=$.indexOf("<");if(W===-1){if(W$(T,"module")||W$(T,"generic"))return[$,T];let U=this.name==="ark"?$:$==="root"?this.name:`${this.name}.${$}`,Y=this.resolvedConfig.keywords?.[U];if(Y)T=[T,"@",Y];return[$,T]}if($.at(-1)!==">")B("'>' must be the last character of a generic declaration in a scope");let w=$.slice(0,W),X=$.slice(W+1,-1);return[w,()=>{let U=this.parseGenericParams(X,{alias:w});return IR(U,T,this)}]}parseGenericParams($,T){return Mz(new r0($),[],this.createParseContext({...T,def:$,prefix:"generic"}))}normalizeRootScopeValue($){if(IT($)&&!W$($,"generic"))return $();return $}preparseOwnDefinitionFormat($,T){return{...T,def:$,prefix:T.alias??"type"}}parseOwnDefinitionFormat($,T){if(!(T.alias&&(T.alias in this.aliases))&&!T.args)T.args={this:T.id};let w=Nz($,T);if(o$(w)){if(w[1]==="=")return B(Vz);if(w[1]==="?")return B(Zz)}return w}unit=($)=>this.units([$]);valueOf=($)=>this.units(sJ($));enumerated=(...$)=>this.units($);instanceOf=($)=>this.node("proto",{proto:$},{prereduced:!0});or=(...$)=>this.schema($.map((T)=>this.parse(T)));and=(...$)=>$.reduce((T,W)=>T.and(this.parse(W)),this.intrinsic.unknown);merge=(...$)=>$.reduce((T,W)=>T.merge(this.parse(W)),this.intrinsic.object);pipe=(...$)=>this.intrinsic.unknown.pipe(...$);match=new mZ(this);declare=()=>({type:this.type});define($){return $}type=new oZ(this);static scope=($,T={})=>new Lz($,T);static module=($,T={})=>this.scope($,T).export()}var lZ=Object.assign(Lz.scope,{define:($)=>$}),P$=Lz;class Vk extends w6{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var vb=v1(["base",G$.object],["props",G$.object])(($)=>$.base.merge($.props),Vk),Kk=P$.module({Key:G$.key,Merge:vb});class Ak extends w6{}var qb=v1("element")(($)=>{let T=$.element.exclude(G$.Array),W=T.array();return T.rawOr(W).pipe(jT).distribute((w)=>w.assertHasKind("morph").declareOut(W),h$)},Ak),Ek=P$.module({root:G$.Array,readonly:"root",index:G$.nonNegativeIntegerString,liftFrom:qb},{name:"Array"});var rZ=h$(["string",xW.FileConstructor]),Pb=rZ.rawOr(rZ.array()),Mk=h$({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:Pb}}),Dk=P$.module({root:["instanceof",FormData],value:rZ,parsed:Mk,parse:h$({in:FormData,morphs:($)=>{let T={};for(let[W,w]of $)if(W in T){let X=T[W];if(typeof X==="string"||X instanceof xW.FileConstructor)T[W]=[X,w];else X.push(w)}else T[W]=w;return T},declaredOut:Mk})},{name:"FormData"});var Nk=P$.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 Cb={Boolean:1,Number:1,String:1},Lk=P$.module({...E$({...BQ,...fQ},($,T)=>($ in Cb)?[]:[$,["instanceof",T]]),Array:Ek,TypedArray:Nk,FormData:Dk});var Sb=h$({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"}),jb=h$({domain:"number",divisor:1}),Jz=P$.module({root:G$.number,integer:jb,epoch:Sb,safe:h$({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 U4=($,T,W)=>{let w={domain:"string",pattern:{rule:$.source,flags:$.flags,meta:T}};if(W)w.meta={format:W};return OX("intersection",w)},Jk=U4(vU,"a well-formed integer string"),xk=P$.module({root:Jk,parse:h$({in:Jk,morphs:($,T)=>{let W=Number.parseInt($);return Number.isSafeInteger(W)?W:T.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")},declaredOut:G$.integer})},{name:"string.integer"}),Ib=U4(/^[\dA-Fa-f]+$/,"hex characters only"),Bb=P$.module({root:U4(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,"base64-encoded"),url:U4(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,"base64url-encoded")},{name:"string.base64"}),Rk=U4(/^[A-Z].*$/,"capitalized"),xb=P$.module({root:h$({in:"string",morphs:($)=>$.charAt(0).toUpperCase()+$.slice(1),declaredOut:Rk}),preformatted:Rk},{name:"string.capitalize"}),fb=($)=>{let T=$.replaceAll(/[ -]+/g,""),W=0,w,X,U=!1;for(let Y=T.length-1;Y>=0;Y--){if(w=T.substring(Y,Y+1),X=Number.parseInt(w,10),U)X*=2,W+=X>=10?X%10+1:X;else W+=X;U=!U}return!!(W%10===0?T:!1)},bb=/^(?: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}))$/,yb=h$({domain:"string",pattern:{meta:"a credit card number",rule:bb.source},predicate:{meta:"a credit card number",predicate:fb}});var hb=/^([+-]?\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 gb=($)=>!Number.isNaN(new Date($).valueOf()),_k=h$({domain:"string",predicate:{meta:"a parsable date",predicate:gb}}).assertHasKind("intersection"),kk=xk.root.internal.narrow(($,T)=>{let W=Number.parseInt($),w=Jz.epoch(W);if(w instanceof o6)return T.errors.merge(w),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),mb=P$.module({root:kk,parse:h$({in:kk,morphs:($)=>new Date($),declaredOut:G$.Date})},{name:"string.date.epoch"}),vk=U4(hb,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),cb=P$.module({root:vk,parse:h$({in:vk,morphs:($)=>new Date($),declaredOut:G$.Date})},{name:"string.date.iso"}),ub=P$.module({root:_k,parse:h$({declaredIn:_k,in:"string",morphs:($,T)=>{let W=new Date($);if(Number.isNaN(W.valueOf()))return T.error("a parsable date");return W},declaredOut:G$.Date}),iso:cb,epoch:mb},{name:"string.date"}),pb=U4(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),qk="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",hT=`(${qk}[.]){3}${qk}`,db=new RegExp(`^${hT}$`),R4="(?:[0-9a-fA-F]{1,4})",ob=new RegExp(`^((?:${R4}:){7}(?:${R4}|:)|(?:${R4}:){6}(?:${hT}|:${R4}|:)|(?:${R4}:){5}(?::${hT}|(:${R4}){1,2}|:)|(?:${R4}:){4}(?:(:${R4}){0,1}:${hT}|(:${R4}){1,3}|:)|(?:${R4}:){3}(?:(:${R4}){0,2}:${hT}|(:${R4}){1,4}|:)|(?:${R4}:){2}(?:(:${R4}){0,3}:${hT}|(:${R4}){1,5}|:)|(?:${R4}:){1}(?:(:${R4}){0,4}:${hT}|(:${R4}){1,6}|:)|(?::((?::${R4}){0,5}:${hT}|(?::${R4}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),lb=P$.module({root:["v4 | v6","@","an IP address"],v4:U4(db,"an IPv4 address","ipv4"),v6:U4(ob,"an IPv6 address","ipv6")},{name:"string.ip"}),KX="a JSON string",fk=($)=>{if(!($ instanceof SyntaxError))throw $;return`must be ${KX} (${$})`},rb=h$({meta:KX,domain:"string",predicate:{meta:KX,predicate:($,T)=>{try{return JSON.parse($),!0}catch(W){return T.reject({code:"predicate",expected:KX,problem:fk(W)})}}}}),nb=($,T)=>{if($.length===0)return T.error({code:"predicate",expected:KX,actual:"empty"});try{return JSON.parse($)}catch(W){return T.error({code:"predicate",expected:KX,problem:fk(W)})}},ib=P$.module({root:rb,parse:h$({meta:"safe JSON string parser",in:"string",morphs:nb,declaredOut:G$.jsonObject})},{name:"string.json"}),Pk=U4(/^[a-z]*$/,"only lowercase letters"),tb=P$.module({root:h$({in:"string",morphs:($)=>$.toLowerCase(),declaredOut:Pk}),preformatted:Pk},{name:"string.lower"}),bk=["NFC","NFD","NFKC","NFKD"],nU=E$(bk,($,T)=>[T,h$({domain:"string",predicate:(W)=>W.normalize(T)===W,meta:`${T}-normalized unicode`})]),Rz=E$(bk,($,T)=>[T,h$({in:"string",morphs:(W)=>W.normalize(T),declaredOut:nU[T]})]),ab=P$.module({root:Rz.NFC,preformatted:nU.NFC},{name:"string.normalize.NFC"}),sb=P$.module({root:Rz.NFD,preformatted:nU.NFD},{name:"string.normalize.NFD"}),eb=P$.module({root:Rz.NFKC,preformatted:nU.NFKC},{name:"string.normalize.NFKC"}),$y=P$.module({root:Rz.NFKD,preformatted:nU.NFKD},{name:"string.normalize.NFKD"}),Ty=P$.module({root:"NFC",NFC:ab,NFD:sb,NFKC:eb,NFKD:$y},{name:"string.normalize"}),Ck=U4(t9,"a well-formed numeric string"),Wy=P$.module({root:Ck,parse:h$({in:Ck,morphs:($)=>Number.parseFloat($),declaredOut:G$.number})},{name:"string.numeric"}),Sk="a regex pattern",Xy=h$({domain:"string",predicate:{meta:Sk,predicate:($,T)=>{try{return new RegExp($),!0}catch(W){return T.reject({code:"predicate",expected:Sk,problem:String(W)})}}},meta:{format:"regex"}}),wy=/^(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-]+)*))?$/,Uy=U4(wy,"a semantic version (see https://semver.org/)"),jk=U4(/^\S.*\S$|^\S?$/,"trimmed"),Yy=P$.module({root:h$({in:"string",morphs:($)=>$.trim(),declaredOut:jk}),preformatted:jk},{name:"string.trim"}),Ik=U4(/^[A-Z]*$/,"only uppercase letters"),Gy=P$.module({root:h$({in:"string",morphs:($)=>$.toUpperCase(),declaredOut:Ik}),preformatted:Ik},{name:"string.upper"}),zy=($)=>{if(URL.canParse)return URL.canParse($);try{return new URL($),!0}catch{return!1}},Bk=h$({domain:"string",predicate:{meta:"a URL string",predicate:zy},meta:{format:"uri"}}),Hy=P$.module({root:Bk,parse:h$({declaredIn:Bk,in:"string",morphs:($,T)=>{try{return new URL($)}catch{return T.error("a URL string")}},declaredOut:h$(URL)})},{name:"string.url"}),Fy=P$.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:U4(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv1"),v2:U4(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv2"),v3:U4(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv3"),v4:U4(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv4"),v5:U4(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv5"),v6:U4(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv6"),v7:U4(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv7"),v8:U4(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,"a UUIDv8")},{name:"string.uuid"}),yk=P$.module({root:G$.string,alpha:U4(/^[A-Za-z]*$/,"only letters"),alphanumeric:U4(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:Ib,base64:Bb,capitalize:xb,creditCard:yb,date:ub,digits:U4(/^\d*$/,"only digits 0-9"),email:pb,integer:xk,ip:lb,json:ib,lower:tb,normalize:Ty,numeric:Wy,regex:Xy,semver:Uy,trim:Yy,upper:Gy,url:Hy,uuid:Fy},{name:"string"});var hk=P$.module({bigint:G$.bigint,boolean:G$.boolean,false:G$.false,never:G$.never,null:G$.null,number:G$.number,object:G$.object,string:G$.string,symbol:G$.symbol,true:G$.true,unknown:G$.unknown,undefined:G$.undefined}),gk=P$.module({root:G$.unknown,any:G$.unknown},{name:"unknown"}),Oy=P$.module({root:G$.jsonObject,stringify:OX("morph",{in:G$.jsonObject,morphs:($)=>JSON.stringify($),declaredOut:G$.string})},{name:"object.json"}),mk=P$.module({root:G$.object,json:Oy},{name:"object"});class ck extends w6{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var Qy=v1(["K",G$.key],"V")(($)=>({domain:"object",index:{signature:$.K,value:$.V}}),ck);class uk extends w6{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var Zy=v1(["T",G$.object],["K",G$.key])(($)=>$.T.pick($.K),uk);class pk extends w6{description='omit a set of properties from an object like `Omit(User, "age")`'}var Vy=v1(["T",G$.object],["K",G$.key])(($)=>$.T.omit($.K),pk);class dk extends w6{description="make all named properties of an object optional like `Partial(User)`"}var Ky=v1(["T",G$.object])(($)=>$.T.partial(),dk);class ok extends w6{description="make all named properties of an object required like `Required(User)`"}var Ay=v1(["T",G$.object])(($)=>$.T.required(),ok);class lk extends w6{description='exclude branches of a union like `Exclude("boolean", "true")`'}var Ey=v1("T","U")(($)=>$.T.exclude($.U),lk);class rk extends w6{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var My=v1("T","U")(($)=>$.T.extract($.U),rk),nk=P$.module({Exclude:Ey,Extract:My,Omit:Vy,Partial:Ky,Pick:Zy,Record:Qy,Required:Ay});var gT=lZ({...hk,...nk,...Lk,...Kk,string:yk,number:Jz,object:mk,unknown:gk},{prereducedAliases:!0,name:"ark"}),y4=gT.export();Object.assign(VX.ambient,y4);VX.typeAttachments={string:y4.string.root,number:y4.number.root,bigint:y4.bigint,boolean:y4.boolean,symbol:y4.symbol,undefined:y4.undefined,null:y4.null,object:y4.object.root,unknown:y4.unknown.root,false:y4.false,true:y4.true,never:y4.never,arrayIndex:y4.Array.index,Key:y4.Key,Record:y4.Record,Array:y4.Array.root,Date:y4.Date};var c1=Object.assign(gT.type,VX.typeAttachments),Dy=gT.match,Ny=gT.generic,i9$=gT.schema,Ly=gT.define,Jy=gT.declare;var Ry="__vite_start_time"in globalThis,_y=typeof window!=="undefined",Zz$="vitest"in globalThis,n0=c1("string"),ik=c1('"true" | "false" | undefined'),i0=SQ({isServer:!Ry&&!_y,server:{CI:c1("string | undefined").pipe(Boolean),POSTGRES_USER:n0,POSTGRES_PASSWORD:n0,POSTGRES_DATABASE:n0,POSTGRES_HOST:n0,POSTGRES_PORT:n0.pipe(($)=>Number.parseInt($,10)),BACKEND_PORT:n0.pipe(($)=>Number.parseInt($,10)),RUN_WORKERS_FROM_SOURCE:ik.pipe(($)=>$==="true"),FRONTEND_PORT:n0.pipe(($)=>Number.parseInt($,10)),FRONTEND_ORIGINS:n0.pipe.try(($)=>JSON.parse($),c1("string[]")),API_KEY_OPENAI:c1("string | undefined"),API_KEY_RESEND:c1("string | undefined")},clientPrefix:"VITE_",client:{VITE_BACKEND_ORIGIN:n0,VITE_DEV_FRONTEND_HOST:c1("string | undefined"),VITE_DEV_HTTPS:ik.pipe(($)=>$==="true")},runtimeEnv:import.meta.env,emptyStringAsUndefined:!0});var iZ={};e0(iZ,{users:()=>yW,untrackedUserColumnNames:()=>ky,twoFactorMethod:()=>$v,trackedUserColumnName:()=>vy,trackableUserColumnNames:()=>sk,signInHistory:()=>Py,role:()=>ak,players:()=>nZ,passwordResetAttempts:()=>Cy,games:()=>kz,banishedIps:()=>vz,accountActions:()=>qy,accountAction:()=>ek});function mT(){return W6({length:24}).$type()}function tk($){return J`lower(${$})`}var _z=J`TO_CHAR(NOW() AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')`,ak=sw("role",["admin","user"]),yW=PT("users",{id:L1().primaryKey().defaultRandom(),username:W6({length:16}).notNull(),emailOffered:W6({length:254}).notNull(),emailVerified:W6({length:254}),password:W6({length:254}),createdAtIso:mT().notNull().default(_z),createdIp:W6({length:45}).notNull(),isActive:wU().notNull().default(!1),verifiedAtIso:mT(),userRole:ak().default("user")},($)=>[AQ("usernameUniqueIndex").on(tk($.username)),AQ("emailVerifiedUniqueIndex").on(tk($.emailVerified))]),ky=["id","createdAtIso","createdIp","isActive","verifiedAtIso"],sk=["username","emailOffered","emailVerified","password","userRole"],vy=sw("trackedUserColumnName",sk),ek=sw("accountAction",["cooldown","confirmEmail","signIn","resetPassword"]),qy=PT("accountActions",{userId:L1().references(()=>yW.id).primaryKey(),action:ek().notNull(),code:W6({length:254}).notNull(),wrongCodeCount:UU().notNull().default(0),expiresAtIso:mT().notNull()}),kz=PT("games",{id:L1().primaryKey().defaultRandom()}),nZ=PT("players",{userId:L1().notNull().references(()=>yW.id,{onDelete:"cascade"}),gameId:L1().notNull().references(()=>kz.id,{onDelete:"cascade"}),score:UU().notNull()},($)=>[mL({name:"players_userId_gameId_pk",columns:[$.userId,$.gameId]})]),Py=PT("signInHistory",{id:L1().primaryKey().defaultRandom(),userId:L1().references(()=>yW.id,{onDelete:"cascade"}),signInTimeIso:mT().notNull().default(_z),ipAddress:W6({length:45}).notNull(),userAgent:W6({length:1024}),successful:wU().notNull().default(!1)}),$v=sw("twoFactorMethod",["email","phone"]),Cy=PT("passwordResetAttempts",{id:L1().primaryKey().defaultRandom(),userId:L1().notNull().references(()=>yW.id,{onDelete:"cascade"}),requestedIp:W6({length:45}).notNull(),requestedAtIso:mT().notNull().default(_z),succeededIp:W6({length:45}),succeededAtIso:mT(),verificationMethod:$v().notNull()}),vz=PT("banishedIps",{ip:W6({length:45}).primaryKey(),reason:W6({length:2048}).notNull(),banishedAtIso:mT().notNull().default(_z),banishedUntilIso:mT()});var __dirname="/home/runner/work/wayforge/wayforge/apps/tempest.games/src/database";class tZ{options;sql;drizzle;observers=new Map;async setupTriggersAndNotifications(){await this.sql.file(Sy.resolve(__dirname,"notify_update.sql"));let $=[u4(yW),u4(kz),u4(nZ)];await this.sql`SELECT create_notify_triggers(${this.sql.array($)})`,await this.sql.listen("table_update",(T)=>{let W=T.split(","),w=W[0],X=W[1],U=`${w}("${X}")`;if(this.observers.has(U))this.observers.get(U).next(U)})}constructor($=!1,T={host:i0.POSTGRES_HOST,port:i0.POSTGRES_PORT,user:i0.POSTGRES_USER,password:i0.POSTGRES_PASSWORD,database:i0.POSTGRES_DATABASE}){this.options=T,this.sql=n2(T),this.drizzle=n9(this.sql,{schema:iZ,logger:$})}observe($,T){if(!this.observers.has($))this.observers.set($,new b$);this.observers.get($).subscribe("SINGLETON",T)}}import{resolve as By}from"path";import{existsSync as aZ,mkdirSync as Tv,readFileSync as jy,readdirSync as Wv,rmSync as Xv,statSync as wv,writeFileSync as Iy}from"fs";import{resolve as sZ}from"path";var Uv=class{rootDir;get initialized(){return aZ(this.rootDir)}initialize(){if(!this.initialized)Tv(this.rootDir,{recursive:!0})}constructor($){if(this.rootDir=$.path,$.eagerInit)this.initialize()}getItem($){let T=sZ(this.rootDir,$);if(aZ(T))return jy(T,"utf-8");return null}setItem($,T){this.initialize();let W=sZ(this.rootDir,$);Iy(W,T)}removeItem($){let T=sZ(this.rootDir,$);if(aZ(T))this.initialize(),Xv(T)}key($){return Wv(this.rootDir).sort((w,X)=>{let U=wv(w);return wv(X).ctimeMs-U.ctimeMs})[$]??null}clear(){Xv(this.rootDir,{recursive:!0}),Tv(this.rootDir,{recursive:!0})}get length(){return Wv(this.rootDir).length}};var eZ=new Uv({path:By(process.cwd(),"storage")});function Yv($){return $.toString({smallestUnit:"millisecond"})}function Bz$($){return Q9.Instant.from($)}import*as qz from"fs";import*as Gv from"readline";function xy($){let W=$.replace(":","T").replace(" ","").replace(/(\d{2})\/(\w{3})\/(\d{4})T(.+)/,(w,X,U,Y,G)=>{let z={Jan:"01",Feb:"02",Mar:"03",Apr:"04",May:"05",Jun:"06",Jul:"07",Aug:"08",Sep:"09",Oct:"10",Nov:"11",Dec:"12"}[U];return`${Y}-${z}-${X}T${G}`});return new Date(W)}async function zv($,T="/var/log/nginx/access.log",W=new Date){let w=new Map;if(!qz.existsSync(T))return $.error(`Log file not found: ${T}`),w;let X=qz.createReadStream(T),U=Gv.createInterface({input:X,crlfDelay:Number.POSITIVE_INFINITY}),Y=new Date(W.getTime()-3600000);return U.on("line",(G)=>{let H=/^(?<ip>\S+) \S+ \S+ \[(?<dateTime>.*?)\]/,z=G.match(H);if(z?.groups){let F=z.groups.ip,O=z.groups.dateTime,Q=xy(O);if(!Number.isNaN(Q.getTime())){if(Q>=Y&&Q<=W){let Z=w.get(F);if(!Z)Z=[],w.set(F,Z);Z.push(G)}}else $.error(`Failed to parse date: ${O}`)}}),new Promise((G,H)=>{U.on("error",(z)=>{H(z)}),U.on("close",()=>{G(w)})})}function Hv($){return $.toJsonSchema()}var fy=["Network security adjudicator, your job is to determine if an IP address should be banned.","The IP address in question created the following logs on our server today:","```nginx.log\n"].join(`
155
+ `);function Fv($){return fy+$.join(`
154
156
 
155
- `)}var kA={schema:k6([{shouldBanIp:"false"},"|",{shouldBanIp:"true",veryConciseReason:"string"}]),toJsonSchema:RA,fallback:{shouldBanIp:!1}};var Sj=[".env","php"];async function vA({generator:$,logFilePath:T,logger:W,now:U=new Date}){let X=$.usdBudget,Y=new q5({logQuery(L,q){W.info("\uD83D\uDCDD query",L,q)}}),_=await BA(W,T,U),w=[],G=$.from(kA),J=0,H=0;for(let[L,q]of _){W.info(`\uD83D\uDD0D ruling on ${L}. logs:`),W.info(q.map((x)=>` ${x}`).join(`
156
- `));let y=!1;for(let x of Sj)if(q.some((u)=>u.includes(x))){w.push({ip:L,reason:`Always ban ${x}`}),W.info(` \uD83E\uDDD1\u200D\u2696\uFE0F banning ${L}--always ban ${x}
157
- `),y=!0;break}if(y)continue;if($.usdBudget>$.usdMinimum){let x=IA(q),u=await G(x);if(u.shouldBanIp)w.push({ip:L,reason:u.veryConciseReason}),W.info(` \uD83E\uDDD1\u200D\u2696\uFE0F banning ${L}--${u.veryConciseReason}
158
- `);else H++,W.info(` \uD83D\uDD4A\uFE0F not banning ${L}
159
- `);J++}else{W.warn("\uD83D\uDCB0 insufficient funds to process all logs"),W.warn(`\uD83D\uDCB0 got through ${J}/${_.size} ips
160
- `);break}}let z=w.length;if(w.length>0)await Y.drizzle.insert(c8).values(w).onConflictDoNothing();let F=[],Q=j5.getItem("lastTribunalProcessedDate"),V=new Date(Q??"1970-01-01");try{F.push(...await Y.drizzle.query.banishedIps.findMany({columns:{ip:!0},where:rY(c8.banishedAt,V)}))}catch(L){W.error(L)}try{if(process.env.EXPERIMENTAL_BAN_IPS)await Promise.all(F.map((L)=>new Promise((q,y)=>Lj(`iptables -D INPUT -s ${L.ip} -j DROP`).on("exit",(x)=>{if(x===0)W.info(`\uD83E\uDDD1\u200D\u2696\uFE0F banned ${L.ip}`),q();else y(new Error(`iptables exited with code ${x}`))}))));else W.info("\uD83E\uDDD1\u200D\u2696\uFE0F skipping iptables update")}catch(L){if(L instanceof Error)W.error(L.message);else{let q=gO(L);W.error("iptables exited with error",q)}}j5.setItem("lastTribunalProcessedDate",U.toISOString()),W.info(`\u2728 banned ${z} ips, didn't ban ${H} ips`);let K=X-$.usdBudget,I=K.toLocaleString("en",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:6}),k=X.toLocaleString("en",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:6}),N=Math.round(K/X*100);W.info(`\uD83D\uDCB8 spent ${I}, ${N}% of ${k} budget`)}var E1=new __;Object.assign(console,E1.logger,{log:E1.logger.info});process.on("SIGINT",()=>{E1.logger.info("\u2757 received SIGINT; exiting gracefully"),p8()});process.on("SIGTERM",()=>{E1.logger.info("\u2757 received SIGTERM; exiting gracefully"),p8()});process.on("exit",()=>{E1.logger.info("\u2757 received exit; exiting gracefully"),p8()});E1.logger.info("\uD83D\uDEEB tribunal worker ready");var Bj=new hO({usdBudget:0.01,usdMinimum:0,model:"gpt-4o-mini",apiKey:K1.API_KEY_OPENAI,cachingMode:"off",logger:E1.logger});if(K1.API_KEY_OPENAI===void 0&&!("VITEST"in import.meta.env))throw new Error("OPENAI_API_KEY is not set and vitest is not running.");await vA({generator:Bj,logFilePath:"/var/log/nginx/access.log",logger:E1.logger});p8();function p8(){E1.logger.info("\uD83D\uDEEC tribunal server exiting"),process.exit(0)}
157
+ `)}var Ov={schema:c1([{shouldBanIp:"false"},"|",{shouldBanIp:"true",veryConciseReason:"string"}]),toJsonSchema:Hv,fallback:{shouldBanIp:!1}};var yy=[".env","php"];async function Qv({generator:$,logFilePath:T,logger:W,now:w=new Date}){let X=$.usdBudget,U=new tZ({logQuery(_,S){W.info("\uD83D\uDCDD query",_,S)}}),Y=await zv(W,T,w),G=[],H=$.from(Ov),z=0,F=0;for(let[_,S]of Y){W.info(`\uD83D\uDD0D ruling on ${_}. logs:`),W.info(S.map((b)=>` ${b}`).join(`
158
+ `));let x=!1;for(let b of yy)if(S.some((g)=>g.includes(b))){G.push({ip:_,reason:`Always ban ${b}`}),W.info(` \uD83E\uDDD1\u200D\u2696\uFE0F banning ${_}--always ban ${b}
159
+ `),x=!0;break}if(x)continue;if($.usdBudget>$.usdMinimum){let b=Fv(S),g=await H(b);if(g.shouldBanIp)G.push({ip:_,reason:g.veryConciseReason}),W.info(` \uD83E\uDDD1\u200D\u2696\uFE0F banning ${_}--${g.veryConciseReason}
160
+ `);else F++,W.info(` \uD83D\uDD4A\uFE0F not banning ${_}
161
+ `);z++}else{W.warn("\uD83D\uDCB0 insufficient funds to process all logs"),W.warn(`\uD83D\uDCB0 got through ${z}/${Y.size} ips
162
+ `);break}}let O=G.length;if(G.length>0)await U.drizzle.insert(vz).values(G).onConflictDoNothing();let Q=[],Z=eZ.getItem("lastTribunalProcessedDate"),K=Yv(Q9.Instant.from(Z??"1970-01-01"));try{Q.push(...await U.drizzle.query.banishedIps.findMany({columns:{ip:!0},where:j9(vz.banishedAtIso,K)}))}catch(_){W.error(_)}try{if(process.env.EXPERIMENTAL_BAN_IPS)await Promise.all(Q.map((_)=>new Promise((S,x)=>by(`iptables -D INPUT -s ${_.ip} -j DROP`).on("exit",(b)=>{if(b===0)W.info(`\uD83E\uDDD1\u200D\u2696\uFE0F banned ${_.ip}`),S();else x(new Error(`iptables exited with code ${b}`))}))));else W.info("\uD83E\uDDD1\u200D\u2696\uFE0F skipping iptables update")}catch(_){if(_ instanceof Error)W.error(_.message);else{let S=ND(_);W.error("iptables exited with error",S)}}eZ.setItem("lastTribunalProcessedDate",w.toISOString()),W.info(`\u2728 banned ${O} ips, didn't ban ${F} ips`);let E=X-$.usdBudget,M=E.toLocaleString("en",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:6}),L=X.toLocaleString("en",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:6}),R=Math.round(E/X*100);W.info(`\uD83D\uDCB8 spent ${M}, ${R}% of ${L} budget`)}var t0=new oz;Object.assign(console,t0.logger,{log:t0.logger.info});process.on("SIGINT",()=>{t0.logger.info("\u2757 received SIGINT; exiting gracefully"),Pz()});process.on("SIGTERM",()=>{t0.logger.info("\u2757 received SIGTERM; exiting gracefully"),Pz()});process.on("exit",()=>{t0.logger.info("\u2757 received exit; exiting gracefully"),Pz()});t0.logger.info("\uD83D\uDEEB tribunal worker ready");var hy=new DE({usdBudget:0.01,usdMinimum:0,model:"gpt-4o-mini",apiKey:i0.API_KEY_OPENAI,cachingMode:"off",logger:t0.logger});if(i0.API_KEY_OPENAI===void 0&&!("VITEST"in import.meta.env))throw new Error("OPENAI_API_KEY is not set and vitest is not running.");await Qv({generator:hy,logFilePath:"/var/log/nginx/access.log",logger:t0.logger});Pz();function Pz(){t0.logger.info("\uD83D\uDEEC tribunal server exiting"),process.exit(0)}