tempest.games 0.2.9 → 0.2.11

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,73 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var GM=Object.create;var{getPrototypeOf:JM,defineProperty:gU,getOwnPropertyNames:wM}=Object;var zM=Object.prototype.hasOwnProperty;var _M=($,T,W)=>{W=$!=null?GM(JM($)):{};let X=T||!$||!$.__esModule?gU(W,"default",{value:$,enumerable:!0}):W;for(let Y of wM($))if(!zM.call(X,Y))gU(X,Y,{get:()=>$[Y],enumerable:!0});return X};var HM=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports);var K1=($,T)=>{for(var W in T)gU($,W,{get:T[W],enumerable:!0,configurable:!0,set:(X)=>T[W]=()=>X})};var nv=($,T)=>()=>($&&(T=$($=0)),T);var v5=import.meta.require;var zF=HM((jh,wF)=>{var pW=v5("os"),oW=v5("path");function JF($){let T=process.env.XDG_CACHE_HOME||oW.join(pW.homedir(),".cache");return oW.join(T,$)}function XR($){return oW.join(pW.homedir(),"Library","Caches",$)}function YR($){let T=process.env.LOCALAPPDATA||oW.join(pW.homedir(),"AppData","Local");return oW.join(T,$,"Cache")}var UR=function(){switch(pW.platform()){case"darwin":return XR;case"win32":return YR;case"aix":case"android":case"freebsd":case"linux":case"netbsd":case"openbsd":case"sunos":return JF;default:return console.error(`(node:${process.pid}) [cachedir] Warning: the platform "${pW.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`),JF}}();wF.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 UR(T)}});class sT extends Promise{fate;resolve;reject;done=!1;constructor($){let T,W;super((X,Y)=>{T=X,W=Y});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 ev=($,T,W=x5.STORE)=>{return j5(W,{key:`${$.key}:JSON`,get:({get:X})=>T.toJson(X($)),set:({set:X},Y)=>{X($,T.fromJson(Y))}})};function Wj($,T,W){return mU($,{key:`${T.key}:JSON`,get:(Y)=>({get:U})=>{let G=U(T,Y);return W.toJson(G)},set:(Y)=>({set:U},G)=>{U(T,Y,W.fromJson(G))}},["mutable","json"])}var eT=($)=>JSON.parse($),R4=($)=>JSON.stringify($),Yj=[Array.prototype,Boolean.prototype,Number.prototype,Object.prototype,String.prototype];function s($){while($.child!==null)$=$.child;return $}class CX{_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 CX([...this._buffer]);return $._index=this._index,$}}var FM={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 b5($,T){let W=R4(T),X=`${$.key}(${W})`,Y=FM[$.type],U={key:X,type:Y};return Object.assign(U,{family:{key:$.key,subKey:W}}),Object.assign(U,{counterfeit:!0}),U}function $W($){let T={key:$.key,type:$.type};if("family"in $)T.family=$.family;return T}var cU=($)=>(T,W,X,Y,...U)=>{console[$](`${T} ${W} "${X}" ${Y}`,...U)},QM={error:cU("error"),info:cU("info"),warn:cU("warn")};class uU{logLevel;filter;logger;constructor($,T,W=QM){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($),X=this.relations.get(T);if(W)W.add(T);else W=new Set([T]),this.relations.set($,W);if(X)X.add($);else X=new Set([$]),this.relations.set(T,X)}deleteRelation($,T){let W=this.relations.get($);if(W){if(W.delete(T),W.size===0)this.relations.delete($);let X=this.relations.get(T);if(X){if(X.delete($),X.size===0)this.relations.delete(T)}}}replaceRelationsUnsafely($,T){this.relations.set($,new Set(T));for(let W of T){let X=new Set().add($);this.relations.set(W,X)}}replaceRelationsSafely($,T){let W=this.relations.get($),X=this.isAType?.($)?$:void 0,Y=X===void 0?$:void 0;if(W)for(let U of W){X??=U,Y??=U;let G=this.relations.get(U);if(G){if(G.size===1)this.relations.delete(U);else G.delete($);this.contents.delete(this.makeContentKey(X,Y))}}this.relations.set($,new Set(T));for(let U of T){let G=this.relations.get(U);if(G)G.add($);else G=new Set().add($),this.relations.set(U,G)}}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,X])=>[W,new Set(X)])),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=(X,Y)=>W.has(X,Y),this.addRelation=(X,Y)=>{W.addRelation(X,Y)},this.deleteRelation=(X,Y)=>{W.deleteRelation(X,Y)},this.replaceRelationsSafely=(X,Y)=>{W.replaceRelationsSafely(X,Y)},this.replaceRelationsUnsafely=(X,Y)=>{W.replaceRelationsUnsafely(X,Y)},this.getRelatedKeys=(X)=>W.getRelatedKeys(X),W.getContent)this.getContentInternal=(X)=>{return W.getContent(X)},this.setContent=(X,Y)=>{W.setContent(X,Y)},this.deleteContent=(X)=>{W.deleteContent(X)};for(let[X,Y]of $.relations??[]){let U=this.isAType?.(X)?X:void 0,G=U===void 0?X:void 0;for(let J of Y)U??=J,G??=J,this.addRelation(U,G)}for(let[X,Y]of $.contents??[])this.setContent(X,Y)}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,X;switch($.length){case 1:{let Y=$[0];T=Y[this.a],W=Y[this.b],X=void 0;break}case 2:{let Y=$[0];if(typeof Y==="string")[T,W]=$;else T=Y[this.a],W=Y[this.b],X=$[1];break}default:{T=$[0],W=$[1],X=$[2];break}}switch(this.cardinality){case"1:1":{let Y=this.getRelatedKey(T);if(Y&&Y!==W)this.delete(T,Y)}case"1:n":{let Y=this.getRelatedKey(W);if(Y&&Y!==T)this.delete(Y,W)}break;case"n:n":}if(X){let Y=this.makeContentKey(T,W);this.setContent(Y,X)}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 X=this.getRelatedKeys(T);if(X)for(let Y of X)this.delete(Y,T)}if(typeof W==="string"&&T===void 0){let X=this.getRelatedKeys(W);if(X)for(let Y of X)this.delete(W,Y)}if(typeof W==="string"&&typeof T==="string"){this.deleteRelation(W,T);let X=this.makeContentKey(W,T);this.deleteContent(X)}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((X)=>`"${X}"`).join(", ")}). Only one related key was expected.`);let W;for(let X of T){W=X;break}return W}}replaceRelations($,T,W){let X=!Array.isArray(T),Y=X?Object.keys(T):T;if(W?.reckless)this.replaceRelationsUnsafely($,Y);else this.replaceRelationsSafely($,Y);if(X)for(let U of Y){let G=this.makeContentKey($,U),J=T[U];this.setContent(G,J)}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 X=this.getRelatedKeys(T);if(X)return[...X].map((Y)=>{return[Y,this.getContent(T,Y)]})}if(T===void 0&&W!==void 0){let X=this.getRelatedKeys(W);if(X)return[...X].map((Y)=>{return[Y,this.getContent(Y,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 pU extends K${state;constructor($){super();this.state=$}next($){this.state=$,super.next($)}}function E1($){return"epoch"in $.transactionMeta}function d4($){return"phase"in $.transactionMeta}function f5($){return $[0].toUpperCase()+$.slice(1)}function vX($){return $.type.split("_").map(f5).join(" ")}class TW extends Error{constructor($,T){super(`${vX($)} ${R4($.key)} not found in store "${T.config.name}".`)}}var m0=($)=>(T)=>$ instanceof Function?$(T):$;var A1=($,T)=>{if($.valueMap.has(T.key))return $.logger.info("\uD83D\uDCD6",T.type,T.key,"reading cached value"),y5(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,X;if(W instanceof Function)X=W();else X=W;return $.logger.info("\uD83D\uDC81","atom",T.key,"could not find cached value; using default",X),X}}};var h5=($,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}"${!d4($)?"":` ${$.transactionMeta.phase} "${$.transactionMeta.update.key}"`}`)},g5=($)=>{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)},m5=($,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)},M1=($,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 c5=($,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 oU=($,T)=>{let W=s($),X=W.selectorAtoms.getRelatedKeys(T.key);if(W.logger.info("\uD83E\uDDF9",T.type,T.key,X?`evicting ${X.size} states downstream:`:"no downstream states",X??"to evict"),X){if(W.operation.open)W.logger.info("\uD83E\uDDF9",T.type,T.key,`[ ${[...W.operation.done].join(", ")} ] already done`);for(let Y of X){if(m5(W,Y))continue;u5(Y,W),M1(W,Y)}}};var p5=($,T,W)=>{let X=A1($,T),Y=X;if(T.type==="mutable_atom"&&d4($)){let{parent:G}=$;Y=WW($,T,G)}if(Y=m0(W)(Y),$.logger.info("\uD83D\uDCDD","atom",T.key,"set to",Y),Y=I4($,T.key,Y,T.subject),d5($,T.key))l5($,T.key);M1($,T.key),oU($,T);let U={oldValue:X,newValue:Y};if(!d4($)){c5($,T,U);return}if($.on.transactionApplying.state===null){let{key:G}=T;if(o5(U.newValue))return;let J={type:"atom_update",key:G,...U};if(T.family)J.family=T.family;$.transactionMeta.update.updates.push(J),$.logger.info("\uD83D\uDCC1","atom",G,"stowed (",U.oldValue,"->",U.newValue,")")}else if(T.key.startsWith("*")){let G=T.key.slice(1),J=$.atoms.get(G),z=$.valueMap.get(G);if(J.type==="mutable_atom"&&d4($)){let{parent:H}=$;z=WW($,J,H)}if(z.do(U.newValue)===null)oU($,J)}};var jX=($,T,W)=>{switch(T.type){case"atom":case"mutable_atom":p5($,T,W);break;case"writable_pure_selector":case"writable_held_selector":T.set(W);break}};var xX=($,T)=>s($).atoms.has(T),ZM=($,T)=>s($).writableSelectors.has(T),DM=($,T)=>s($).readonlySelectors.has(T),r5=($,T)=>xX($,T)||ZM($,T)||DM($,T);var bX=($,T)=>{return s($).selectorGraph.getRelationEntries({downstreamSelectorKey:T}).filter(([X,{source:Y}])=>Y!==T).map(([X,{source:Y}])=>Y).filter((X)=>r5($,X))};var dU=($,T,W)=>{let X=[],Y=bX($,T);while(Y.length>0){let U=Y.shift();if(W.has(U))continue;if(W.add(U),!xX($,U))Y.push(...bX($,U));else if(!X.includes(U))X.push(U)}return X},i5=($,T)=>{let W=$.key,X=bX(T,W),Y=new Set;return X.flatMap((U)=>xX(T,U)?U:dU(T,U,Y))};var n5=($,T,W,X,Y)=>{let U=s($),{type:G,key:J}=X;if(G==="atom"||G==="mutable_atom")U.selectorAtoms.set({selectorKey:W,atomKey:J}),$.logger.info("\uD83D\uDD0D",T,W,`discovers root atom "${J}"`);else{let z=dU($,J,Y);$.logger.info("\uD83D\uDD0D",T,W,`discovers root atoms: [ ${z.map((w)=>`"${w}"`).join(", ")} ]`);for(let w of z)U.selectorAtoms=U.selectorAtoms.set({selectorKey:W,atomKey:w})}Y.add(J)};var N1=($,T,W,X)=>({get:(...Y)=>{let U=s($),G;if(Y.length===2){let[H,_]=Y;G=l4($,H,_)}else[G]=Y;let J=j4($,G),z=A1($,J),w=G.key;return $.logger.info("\uD83D\uDD0C",T,W,`registers dependency ( "${w}" =`,z,")"),U.selectorGraph.set({upstreamSelectorKey:w,downstreamSelectorKey:W},{source:G.key}),n5($,T,W,G,X),z},set:(...Y)=>{let U,G;if(Y.length===2)U=Y[0],G=Y[1];else{let w=Y[0],H=Y[1];G=Y[2],U=l4($,w,H)}let J=s($),z=j4(J,U);jX(J,z,G)},find:(...Y)=>l4($,...Y),json:(Y)=>c0($,Y)});var lU=($,T,W)=>{let X=s($),Y=new K$,U=new Set,{key:G,const:J}=T,z="readonly_held_selector",{get:w,find:H,json:_}=N1(X,"readonly_held_selector",G,U),D={...T,type:"readonly_held_selector",subject:Y,install:(E)=>lU(E,T,W),get:()=>{return T.get({get:w,find:H,json:_},J),I4(s($),G,J,Y),U.clear(),J},...W&&{family:W}};X.readonlySelectors.set(G,D),$.logger.info("\u2728","readonly_held_selector",G,"=",J);let V={key:G,type:"readonly_held_selector"};if(W)V.family=W;return V};var rU=($,T,W)=>{let X=s($),Y=new K$,U=new Set,G=T.key,J="readonly_pure_selector",{get:z,find:w,json:H}=N1(X,"readonly_pure_selector",G,U),_=()=>{let E=T.get({get:z,find:w,json:H});return I4(s($),G,E,Y),U.clear(),E},F={...T,type:"readonly_pure_selector",subject:Y,install:(E)=>rU(E,T,W),get:_,...W&&{family:W}};X.readonlySelectors.set(G,F);let D=_();$.logger.info("\u2728","readonly_pure_selector",G,"=",D);let V={key:G,type:"readonly_pure_selector"};if(W)V.family=W;return V};var iU=($,T,W)=>{let X=s($),Y=new K$,U=new Set,{key:G,const:J}=T,z="writable_held_selector",w=N1(X,"writable_held_selector",G,U),{find:H,get:_,json:F}=w,D={find:H,get:_,json:F},V=(N=T.get,k=s($))=>{return N(D,J),I4(k,G,J,Y),U.clear(),J},R={...T,type:"writable_held_selector",subject:Y,install:(N)=>iU(N,T,W),get:V,set:(N)=>{let k=s($),y=V(T.get,k),x=m0(N)(y);if($.logger.info("\uD83D\uDCDD","writable_held_selector",G,"set (",y,"->",x,")"),I4(k,G,x,Y),M1(k,G),E1(k))Y.next({newValue:x,oldValue:y});T.set(w,x)},...W&&{family:W}};X.writableSelectors.set(G,R);let P=V();$.logger.info("\u2728","writable_held_selector",G,"=",P);let M={key:G,type:"writable_held_selector"};if(W)M.family=W;return M};var XW=($,T,W)=>{let X=s($),Y=new K$,U=new Set,G=T.key,J="writable_pure_selector",z=N1(X,"writable_pure_selector",G,U),{find:w,get:H,json:_}=z,F={find:w,get:H,json:_},D=(M=T.get,N=s($))=>{let k=M(F);return I4(N,G,k,Y),U.clear(),k},E={...T,type:"writable_pure_selector",subject:Y,install:(M)=>XW(M,T,W),get:D,set:(M)=>{let N=s($),k=D(T.get,N),y=m0(M)(k);if($.logger.info("\uD83D\uDCDD","writable_pure_selector",G,"set (",k,"->",y,")"),I4(N,T.key,y,Y),M1(N,T.key),E1(N))Y.next({newValue:y,oldValue:k});T.set(z,y)},...W&&{family:W}};X.writableSelectors.set(G,E);let R=D();$.logger.info("\u2728",E.type,E.key,"=",R);let P={key:G,type:"writable_pure_selector"};if(W)P.family=W;return P};function j5($,T){let W="set"in T,X="const"in T;if(X&&W){let U=iU($,T,void 0);return $.on.selectorCreation.next(U),U}if(X){let U=lU($,T,void 0);return $.on.selectorCreation.next(U),U}if(W){let U=XW($,T,void 0);return $.on.selectorCreation.next(U),U}let Y=rU($,T,void 0);return $.on.selectorCreation.next(Y),Y}function mU($,T,W){let X=T.key,Y="writable_pure_selector_family",U={key:X,type:"writable_pure_selector_family"},G=$.families.get(X);if(G)$.logger.error("\u2757","writable_pure_selector_family",X,`Overwriting an existing ${vX(G)} "${G.key}" in store "${$.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);let J=new K$,w=Object.assign((H)=>{let _=R4(H),F={key:X,subKey:_},D=`${X}(${_})`,V=s($),E=XW(V,{key:D,get:T.get(H),set:T.set(H)},F);return J.next({type:"state_creation",token:E}),E},U,{internalRoles:W,subject:J,install:(H)=>mU(H,T),default:(H)=>{return T.get(H)({get:(...F)=>YW($,...F),find:(...F)=>l4($,...F),json:(F)=>c0($,F)})}});return $.families.set(X,w),U}function t5($,T,W){let X=$.families.get(T.key);if(X===void 0)throw new TW(T,$);let Y=X(W),U=s($);if(Y.family){if(E1(U))switch(Y.type){case"atom":case"mutable_atom":$.on.atomCreation.next(Y);break;case"writable_pure_selector":case"readonly_pure_selector":case"writable_held_selector":case"readonly_held_selector":$.on.selectorCreation.next(Y);break}else if(d4(U)&&U.on.transactionApplying.state===null)U.transactionMeta.update.updates.push({type:"state_creation",token:Y})}return Y}function a5($,T,W){let X=R4(W),Y=`${T.key}(${X})`,U=s($),G;switch(T.type){case"atom_family":case"mutable_atom_family":G=U.atoms.get(Y);break;case"writable_held_selector_family":case"writable_pure_selector_family":G=U.writableSelectors.get(Y);break;case"readonly_held_selector_family":case"readonly_pure_selector_family":G=U.readonlySelectors.get(Y);break}if(G)return $W(G);return G}function l4($,T,W){let X=a5($,T,W);if(X)return X;let Y=R4(W),U=$.molecules.get(Y);if(!U&&$.config.lifespan==="immortal"){let G=b5(T,W);return $.logger.error("\u274C",G.type,G.key,`was not found in store "${$.config.name}"; returned a counterfeit token.`),G}if(X=t5($,T,W),U)s($).moleculeData.set(Y,T.key);return X}function s5($,T){if(T.family){let W=$.families.get(T.family.key);if(W)return W}}function L1($,...T){let W,X,Y,U;if(T.length===2){if(W=T[0],U=T[1],X=s5($,W)??null,X)Y=W.family?eT(W.family.subKey):null,W=l4($,X,Y)}else X=T[0],Y=T[1],U=T[2],W=l4($,X,Y);if("counterfeit"in W&&"family"in W){let z=W.family.subKey,w=$.disposalTraces.buffer.find((H)=>H?.key===z);$.logger.error("\u274C",W.type,W.key,`could not be set because it was not found in the store "${$.config.name}".`,w?`This state was previously disposed:
4
- ${w.trace}`:"No previous disposal trace was found.");return}let G=h5($,W);if(G){let z=$.on.operationClose.subscribe(`waiting to set "${W.key}" at T-${G}`,()=>{z(),$.logger.info("\uD83D\uDFE2",W.type,W.key,`resuming deferred setState from T-${G}`),L1($,W,U)});return}let J=j4($,W);jX($,J,U),g5($)}function YW($,...T){let W,X,Y;if(T.length===1)W=T[0];else X=T[0],Y=T[1],W=l4($,X,Y);if("counterfeit"in W&&"family"in W){X=$.families.get(W.family.key);let U=W.family.subKey,G=$.disposalTraces.buffer.find((J)=>J?.key===U);switch($.logger.error("\u274C",W.type,W.key,`could not be retrieved because it was not found in the store "${$.config.name}".`,G?`This state was previously disposed:
5
- ${G.trace}`:"No previous disposal trace was found."),X.type){case"atom_family":case"mutable_atom_family":return $.defaults.get(X.key);case"readonly_pure_selector_family":case"writable_pure_selector_family":case"readonly_held_selector_family":case"writable_held_selector_family":{if($.defaults.has(X.key))return $.defaults.get(W.family.key);let J=j4($,X).default(U);return $.defaults.set(X.key,J),J}}}return A1($,j4($,W))}class e5{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 CX(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 pU(null),operationClose:new K$,moleculeCreation:new K$,moleculeDisposal:new K$};operation={open:!1};config={name:"IMPLICIT_STORE",lifespan:"ephemeral"};loggers=[new uU("warn",($,T,W)=>!T3(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},E1(T))this.transactionMeta={epoch:new Map(T?.transactionMeta.epoch),actionContinuities:new P6(T?.transactionMeta.actionContinuities.toJSON())};for(let[,X]of T.families){if(X.internalRoles?.includes("mutable")||X.internalRoles?.includes("join"))continue;X.install(this)}let W=new Set;for(let[,X]of T.atoms){if(W.has(X.key))continue;if(X.install(this),X.type==="mutable_atom"){let Y=c0(T,X),U=$3(X);W.add(Y.key),W.add(U.key)}}for(let[,X]of T.readonlySelectors)X.install(this);for(let[,X]of T.writableSelectors){if(W.has(X.key))continue;X.install(this)}for(let[,X]of T.transactions)X.install(this);for(let[,X]of T.timelines)X.install(this)}}}var x5={get STORE(){return globalThis.ATOM_IO_IMPLICIT_STORE??=new e5({name:"IMPLICIT_STORE",lifespan:"ephemeral"}),globalThis.ATOM_IO_IMPLICIT_STORE}};function j4($,T){let W,X=$;while(X!==null){switch(T.type){case"atom":case"mutable_atom":W=X.atoms.get(T.key);break;case"writable_pure_selector":case"writable_held_selector":W=X.writableSelectors.get(T.key);break;case"readonly_pure_selector":case"readonly_held_selector":W=X.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=X.families.get(T.key);break;case"timeline":W=X.timelines.get(T.key);break;case"transaction":W=X.transactions.get(T.key);break}if(W)return W;X=X.child}throw new TW(T,$)}var W3=($,T)=>{let W=s($);if(W.operation.open)return W.operation.prev.get(T.key);return W.valueMap.get(T.key)};var nU=($,T)=>{let W=s($);return i5(T,$).map((Y)=>{let U=W.atoms.get(Y);if(U===void 0)throw new Error(`Atom "${Y}", a dependency of selector "${T.key}", not found in store "${$.config.name}".`);return U.subject.subscribe(`${T.type}:${T.key}`,(G)=>{$.logger.info("\uD83D\uDCE2",T.type,T.key,"root",Y,"went",G.oldValue,"->",G.newValue);let J=W3(W,T),z=A1(W,T);$.logger.info("\u2728",T.type,T.key,"went",J,"->",z),T.subject.next({newValue:z,oldValue:J})})})};function UW($,T,W,X){function Y(_){if($.operation.open){let F=$.on.operationClose.subscribe(`state subscription ${W}`,()=>{F(),X(_)})}else X(_)}let U=j4($,T);$.logger.info("\uD83D\uDC40",U.type,U.key,`Adding subscription "${W}"`);let G=U.type==="writable_pure_selector"||U.type==="readonly_pure_selector",J=null,z=Y;if(G)J=nU($,U),z=(_)=>{if(J)J.length=0,J.push(...nU($,U));Y(_)};let w=U.subject.subscribe(W,z);return()=>{if($.logger.info("\uD83D\uDE48",U.type,U.key,`Removing subscription "${W}"`),w(),J)for(let _ of J)_()}}var X3=($,T,W,X)=>{let Y=j4($,T);$.logger.info("\uD83D\uDC40","timeline",T.key,`Adding subscription "${W}"`);let U=Y.subject.subscribe(W,X);return()=>{$.logger.info("\uD83D\uDE48","timeline",T.key,`Removing subscription "${W}" from timeline`),U()}};class tU{initializeState($,T){let W=`*${$.key}`;T.atoms.delete(W),T.valueMap.delete(W);let X=$.family?{key:`*${$.family.key}`,subKey:$.family.subKey}:void 0,Y=aU(T,{key:W,default:null},X);if(T.parent?.valueMap.has(W)){let U=T.parent.valueMap.get(W);T.valueMap.set(W,U)}return Y}unsubscribeFromInnerValue;unsubscribeFromState;observeCore($,T,W){let X=`tracker:${W.config.name}:${d4(W)?W.transactionMeta.update.key:"main"}:${$.key}`,Y=YW(W,$);this.unsubscribeFromInnerValue=Y.subscribe(X,(U)=>{L1(W,T,U)}),this.unsubscribeFromState=UW(W,$,X,(U)=>{if(U.newValue!==U.oldValue)this.unsubscribeFromInnerValue(),this.unsubscribeFromInnerValue=U.newValue.subscribe(X,(G)=>{L1(W,T,G)})})}updateCore($,T,W){let X=`tracker:${W.config.name}:${d4(W)?W.transactionMeta.update.key:"main"}:${$.key}`;UW(W,T,X,({newValue:Y,oldValue:U})=>{let G=W.timelineTopics.getRelatedKey(T.key);if(G){if(W.timelines.get(G)?.timeTraveling){let w=X3(W,{key:G,type:"timeline"},X,(H)=>{w(),L1(W,$,(_)=>{if(H==="redo"&&Y)_.do(Y);else if(H==="undo"&&U)_.undo(U);return _})});return}}let J=W.on.operationClose.subscribe(X,()=>{J();let z=YW(W,$),w=Y===null?-1:z.getUpdateNumber(Y),H=w-z.cacheUpdateNumber;if(Y&&H===1)L1(W,$,(_)=>(_.do(Y),_));else W.logger.info("\u274C","mutable_atom",$.key,`could not be updated. Expected update number ${z.cacheUpdateNumber+1}, but got ${w}`)})})}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 c0=($,T)=>{if(T.family){let X=s($),U={key:`${T.family.key}:JSON`,type:"writable_pure_selector_family"},G=j4(X,U),J=JSON.parse(T.family.subKey);return l4($,G,J)}return{type:"writable_pure_selector",key:`${T.key}:JSON`}};var $3=($)=>{let W={type:"atom",key:`*${$.key}`};if($.family)W.family={key:`*${$.family.key}`,subKey:$.family.subKey};return W};function o5($){return typeof $==="object"&&$!==null&&"do"in $&&"undo"in $&&"subscribe"in $}function WW($,T,W){let X=W.valueMap.get(T.key),Y=$.valueMap.get(T.key);if(X!==Y)return Y;if(X===void 0)return T.default();W.logger.info("\uD83D\uDCC3","atom",T.key,"copying");let U=T.toJson(X),G=T.fromJson(U);return $.valueMap.set(T.key,G),new tU(T,W),G}function I4($,T,W,X){let Y=$.valueMap.get(T);if(Y instanceof sT)Y.use(W);if(W instanceof Promise){let U=new sT(W);return $.valueMap.set(T,U),U.then((G)=>{I4($,T,G,X),X.next({newValue:G,oldValue:U})}).catch((G)=>{$.logger.error("\uD83D\uDCA5","state",T,"rejected:",G)}),U}return $.valueMap.set(T,W),W}var y5=($,T)=>{let W=T.valueMap.get($.key);if($.type==="mutable_atom"&&d4(T)){let{parent:X}=T;W=WW(T,$,X)}return W},u5=($,T)=>{let W=T.valueMap.get($);if(W instanceof sT){let X=W,Y=T.writableSelectors.get($)??T.readonlySelectors.get($);if(Y)X.use(Y.get());return}if(T.operation.open)T.operation.prev.set($,W);T.valueMap.delete($),T.logger.info("\uD83D\uDDD1","state",$,"evicted")};var d5=($,T)=>{return s($).atomsThatAreDefault.has(T)},Y3=($,T)=>{let W=s($);W.atomsThatAreDefault=new Set(W.atomsThatAreDefault).add(T)},l5=($,T)=>{let W=s($);W.atomsThatAreDefault=new Set(s($).atomsThatAreDefault),W.atomsThatAreDefault.delete(T)};function aU($,T,W){let{key:Y,default:U}=T;$.logger.info("\uD83D\uDD28","atom",Y,`creating in store "${$.config.name}"`);let G=s($),J=G.atoms.get(Y);if(J&&J.type==="atom")return $.logger.error("\u274C","atom",Y,"Tried to create atom, but it already exists in the store."),$W(J);let z=new K$,w={...T,type:"atom",install:(F)=>{return F.logger.info("\uD83D\uDEE0\uFE0F","atom",Y,`installing in store "${F.config.name}"`),aU(F,T,W)},subject:z};if(W)w.family=W;let H=U;if(U instanceof Function)H=U();G.atoms.set(Y,w),Y3($,Y),I4(G,Y,H,z);let _=$W(w);if(T.effects){let F=0,D=[];for(let V of T.effects){let E=V({setSelf:(R)=>{L1($,_,R)},onSet:(R)=>UW($,_,`effect[${F}]`,R)});if(E)D.push(E);++F}w.cleanup=()=>{for(let V of D)V()}}return _}class u0 extends Set{mode="record";subject=new K$;cacheLimit=0;cache=[];cacheIdx=-1;cacheUpdateNumber=-1;constructor($,T=0){super($);if($ instanceof u0)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 u0($.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 u0(this);let T=this.child._subscribe("transaction",(W)=>{this.transactionUpdates?.push(W)});try{if($(this.child)){for(let X of this.transactionUpdates)this.doStep(X);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),X=$.substring(T+1);switch(W){case"add":this.add(JSON.parse(X));break;case"clear":this.clear();break;case"del":this.delete(JSON.parse(X));break;case"tx":for(let Y of X.split(";"))this.doStep(Y)}}getUpdateNumber($){let T=$.indexOf("=");return Number($.substring(0,T))}do($){let T=$.indexOf("="),W=Number($.substring(0,T)),X=W-this.cacheUpdateNumber;if(X>0){if(X===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(X)<this.cacheLimit){let U=this.cacheIdx+X;if(this.cache[U]===$)return null;this.mode="playback";let J=!1;while(!J){this.cacheIdx%=this.cacheLimit;let w=this.cache[this.cacheIdx];if(this.cacheIdx--,!w)return"OUT_OF_RANGE";this.undo(w),J=this.cacheIdx===U-1}let z=$.substring(T+1);return this.doStep(z),this.mode="record",this.cacheUpdateNumber=W,null}return"OUT_OF_RANGE"}undoStep($){let T=$.indexOf(":"),W=$.substring(0,T),X=$.substring(T+1);switch(W){case"add":this.delete(JSON.parse(X));break;case"del":this.add(JSON.parse(X));break;case"clear":{let Y=JSON.parse(X);for(let U of Y)this.add(U);break}case"tx":{let Y=X.split(";");for(let U=Y.length-1;U>=0;U--)this.undoStep(Y[U])}}}undo($){let T=$.indexOf("=");if(Number($.substring(0,T))===this.cacheUpdateNumber){this.mode="playback";let X=$.substring(T+1);return this.undoStep(X),this.mode="record",this.cacheUpdateNumber--,null}return this.cacheUpdateNumber}}function T3($){return $.startsWith("\uD83D\uDD0D ")}class fX{listeners;globalListeners;handleEvent($,...T){for(let X of this.globalListeners)X($,...T);let W=this.listeners.get($);if(W)for(let X of W)X(...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 U3 extends fX{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 sU extends fX{incompleteData="";unprocessedEvents=[];relays;relayServices;process;id="#####";log(...$){this.process.stderr.write(R4($.map((T)=>T instanceof u0?`{ ${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 X=eT(this.incompleteData);this.logger.info("\uD83C\uDFB0","received",X),this.handleEvent(...X);while(this.unprocessedEvents.length>0){let Y=this.unprocessedEvents.shift();if(Y){if(this.unprocessedEvents.length===0)this.incompleteData=Y;let U=eT(Y);this.handleEvent(...U)}}this.incompleteData=""}catch(X){if(X instanceof Error)this.logger.error("\u2757",X.message,X.cause,X.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 U3(`user:${$}`);this.relays.set($,T),this.logger.info("\uD83D\uDD17","attaching services:",`[${[...this.relayServices.keys()].join(", ")}]`);for(let W of this.relayServices){let X=W(T);if(X)T.disposalFunctions.push(X)}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 y8={};K1(y8,{xid:()=>zB,void:()=>qB,uuidv7:()=>WB,uuidv6:()=>TB,uuidv4:()=>$B,uuid:()=>eS,url:()=>XB,uppercase:()=>qW,unknown:()=>q8,union:()=>b8,undefined:()=>IB,ulid:()=>wB,uint64:()=>BB,uint32:()=>NB,tuple:()=>fB,trim:()=>bW,treeifyError:()=>_G,transform:()=>_z,toUpperCase:()=>yW,toLowerCase:()=>fW,toJSONSchema:()=>qw,templateLiteral:()=>dB,symbol:()=>RB,superRefine:()=>YF,success:()=>pB,stringbool:()=>nB,string:()=>gw,strictObject:()=>jB,startsWith:()=>CW,size:()=>RW,setErrorMap:()=>TR,set:()=>gB,safeParseAsync:()=>yw,safeParse:()=>fw,registry:()=>W8,regexes:()=>a1,regex:()=>IW,refine:()=>XF,record:()=>vH,readonly:()=>aH,property:()=>Lw,promise:()=>lB,prettifyError:()=>HG,preprocess:()=>aB,prefault:()=>oH,positive:()=>Ew,pipe:()=>v8,partialRecord:()=>yB,parseAsync:()=>bw,parse:()=>xw,overwrite:()=>d6,optional:()=>P8,object:()=>vB,number:()=>KH,nullish:()=>uB,nullable:()=>C8,null:()=>LH,normalize:()=>xW,nonpositive:()=>Mw,nonoptional:()=>dH,nonnegative:()=>Nw,never:()=>j8,negative:()=>Aw,nativeEnum:()=>mB,nanoid:()=>UB,nan:()=>oB,multipleOf:()=>e1,minSize:()=>$0,minLength:()=>B1,mime:()=>jW,maxSize:()=>d0,maxLength:()=>l0,map:()=>hB,lte:()=>Y6,lt:()=>p6,lowercase:()=>kW,looseObject:()=>xB,locales:()=>LW,literal:()=>yH,length:()=>r0,lazy:()=>$F,ksuid:()=>_B,keyof:()=>CB,jwt:()=>KB,json:()=>tB,iso:()=>B8,ipv6:()=>FB,ipv4:()=>HB,intersection:()=>PH,int64:()=>SB,int32:()=>MB,int:()=>mw,instanceof:()=>iB,includes:()=>PW,guid:()=>sS,gte:()=>b4,gt:()=>o6,globalRegistry:()=>v6,getErrorMap:()=>WR,function:()=>kw,formatError:()=>OW,float64:()=>AB,float32:()=>EB,flattenError:()=>DW,file:()=>cB,enum:()=>bH,endsWith:()=>vW,emoji:()=>YB,email:()=>aS,e164:()=>VB,discriminatedUnion:()=>bB,date:()=>PB,custom:()=>rB,cuid2:()=>JB,cuid:()=>GB,core:()=>l6,config:()=>n$,coerce:()=>hw,clone:()=>r4,cidrv6:()=>ZB,cidrv4:()=>QB,check:()=>WF,catch:()=>iH,boolean:()=>EH,bigint:()=>LB,base64url:()=>OB,base64:()=>DB,array:()=>Jz,any:()=>kB,_default:()=>uH,_ZodString:()=>cw,ZodXID:()=>nw,ZodVoid:()=>RH,ZodUnknown:()=>Gz,ZodUnion:()=>wz,ZodUndefined:()=>MH,ZodUUID:()=>r6,ZodURL:()=>pw,ZodULID:()=>iw,ZodType:()=>w$,ZodTuple:()=>CH,ZodTransform:()=>gH,ZodTemplateLiteral:()=>sH,ZodSymbol:()=>AH,ZodSuccess:()=>lH,ZodStringFormat:()=>f$,ZodString:()=>R8,ZodSet:()=>xH,ZodRecord:()=>zz,ZodRealError:()=>n0,ZodReadonly:()=>tH,ZodPromise:()=>TF,ZodPrefault:()=>pH,ZodPipe:()=>Qz,ZodOptional:()=>Hz,ZodObject:()=>x8,ZodNumberFormat:()=>t0,ZodNumber:()=>gW,ZodNullable:()=>mH,ZodNull:()=>NH,ZodNonOptional:()=>Fz,ZodNever:()=>BH,ZodNanoID:()=>dw,ZodNaN:()=>nH,ZodMap:()=>jH,ZodLiteral:()=>fH,ZodLazy:()=>eH,ZodKSUID:()=>tw,ZodJWT:()=>Yz,ZodIssueCode:()=>sB,ZodIntersection:()=>qH,ZodIPv6:()=>sw,ZodIPv4:()=>aw,ZodGUID:()=>k8,ZodFile:()=>hH,ZodError:()=>oS,ZodEnum:()=>uW,ZodEmoji:()=>ow,ZodEmail:()=>uw,ZodE164:()=>Xz,ZodDiscriminatedUnion:()=>kH,ZodDefault:()=>cH,ZodDate:()=>I8,ZodCustom:()=>f8,ZodCatch:()=>rH,ZodCUID2:()=>rw,ZodCUID:()=>lw,ZodCIDRv6:()=>$z,ZodCIDRv4:()=>ew,ZodBoolean:()=>mW,ZodBigIntFormat:()=>Uz,ZodBigInt:()=>cW,ZodBase64URL:()=>Wz,ZodBase64:()=>Tz,ZodArray:()=>IH,ZodAny:()=>SH,NEVER:()=>$R,$output:()=>u9,$input:()=>p9,$brand:()=>eU});var l6={};K1(l6,{version:()=>YJ,util:()=>g,treeifyError:()=>_G,toJSONSchema:()=>qw,toDotPath:()=>w3,safeParseAsync:()=>QG,safeParse:()=>FG,registry:()=>W8,regexes:()=>a1,prettifyError:()=>HG,parseAsync:()=>uX,parse:()=>mX,locales:()=>LW,isValidJWT:()=>R3,isValidBase64URL:()=>B3,isValidBase64:()=>BJ,globalRegistry:()=>v6,globalConfig:()=>GW,function:()=>kw,formatError:()=>OW,flattenError:()=>DW,config:()=>n$,clone:()=>r4,_xid:()=>Z8,_void:()=>Dw,_uuidv7:()=>J8,_uuidv6:()=>G8,_uuidv4:()=>U8,_uuid:()=>Y8,_url:()=>w8,_uppercase:()=>qW,_unknown:()=>Qw,_union:()=>AS,_undefined:()=>_w,_ulid:()=>Q8,_uint64:()=>ww,_uint32:()=>Ww,_tuple:()=>Bw,_trim:()=>bW,_transform:()=>qS,_toUpperCase:()=>yW,_toLowerCase:()=>fW,_templateLiteral:()=>hS,_symbol:()=>zw,_success:()=>xS,_stringbool:()=>Iw,_string:()=>o9,_startsWith:()=>CW,_size:()=>RW,_set:()=>BS,_safeParseAsync:()=>oX,_safeParse:()=>pX,_regex:()=>IW,_refine:()=>cS,_record:()=>LS,_readonly:()=>yS,_property:()=>Lw,_promise:()=>mS,_positive:()=>Ew,_pipe:()=>fS,_parseAsync:()=>cX,_parse:()=>gX,_overwrite:()=>d6,_optional:()=>PS,_number:()=>t9,_nullable:()=>CS,_null:()=>Hw,_normalize:()=>xW,_nonpositive:()=>Mw,_nonoptional:()=>jS,_nonnegative:()=>Nw,_never:()=>Zw,_negative:()=>Aw,_nativeEnum:()=>IS,_nanoid:()=>_8,_nan:()=>Kw,_multipleOf:()=>e1,_minSize:()=>$0,_minLength:()=>B1,_min:()=>b4,_mime:()=>jW,_maxSize:()=>d0,_maxLength:()=>l0,_max:()=>Y6,_map:()=>SS,_lte:()=>Y6,_lt:()=>p6,_lowercase:()=>kW,_literal:()=>kS,_length:()=>r0,_lazy:()=>gS,_ksuid:()=>D8,_jwt:()=>L8,_isoTime:()=>i9,_isoDuration:()=>n9,_isoDateTime:()=>l9,_isoDate:()=>r9,_ipv6:()=>V8,_ipv4:()=>O8,_intersection:()=>NS,_int64:()=>Jw,_int32:()=>Tw,_int:()=>s9,_includes:()=>PW,_guid:()=>BW,_gte:()=>b4,_gt:()=>o6,_float64:()=>$w,_float32:()=>e9,_file:()=>Rw,_enum:()=>RS,_endsWith:()=>vW,_emoji:()=>z8,_email:()=>X8,_e164:()=>N8,_discriminatedUnion:()=>MS,_default:()=>vS,_date:()=>Ow,_custom:()=>hW,_cuid2:()=>F8,_cuid:()=>H8,_coercedString:()=>d9,_coercedNumber:()=>a9,_coercedDate:()=>Vw,_coercedBoolean:()=>Yw,_coercedBigint:()=>Gw,_cidrv6:()=>E8,_cidrv4:()=>K8,_catch:()=>bS,_boolean:()=>Xw,_bigint:()=>Uw,_base64url:()=>M8,_base64:()=>A8,_array:()=>Sw,_any:()=>Fw,JSONSchemaGenerator:()=>S8,JSONSchema:()=>HH,Doc:()=>tX,$output:()=>u9,$input:()=>p9,$constructor:()=>K,$brand:()=>eU,$ZodXID:()=>DJ,$ZodVoid:()=>yJ,$ZodUnknown:()=>AW,$ZodUnion:()=>T8,$ZodUndefined:()=>jJ,$ZodUUID:()=>JJ,$ZodURL:()=>zJ,$ZodULID:()=>ZJ,$ZodType:()=>T$,$ZodTuple:()=>s1,$ZodTransform:()=>nJ,$ZodTemplateLiteral:()=>U9,$ZodSymbol:()=>vJ,$ZodSuccess:()=>T9,$ZodStringFormat:()=>q$,$ZodString:()=>KW,$ZodSet:()=>dJ,$ZodRegistry:()=>SW,$ZodRecord:()=>pJ,$ZodRealError:()=>p0,$ZodReadonly:()=>Y9,$ZodPromise:()=>G9,$ZodPrefault:()=>eJ,$ZodPipe:()=>MW,$ZodOptional:()=>tJ,$ZodObject:()=>mJ,$ZodNumberFormat:()=>PJ,$ZodNumber:()=>eX,$ZodNullable:()=>aJ,$ZodNull:()=>xJ,$ZodNonOptional:()=>$9,$ZodNever:()=>fJ,$ZodNanoID:()=>HJ,$ZodNaN:()=>X9,$ZodMap:()=>oJ,$ZodLiteral:()=>rJ,$ZodLazy:()=>J9,$ZodKSUID:()=>OJ,$ZodJWT:()=>qJ,$ZodIntersection:()=>uJ,$ZodISOTime:()=>EJ,$ZodISODuration:()=>AJ,$ZodISODateTime:()=>VJ,$ZodISODate:()=>KJ,$ZodIPv6:()=>NJ,$ZodIPv4:()=>MJ,$ZodGUID:()=>GJ,$ZodFunction:()=>i0,$ZodFile:()=>iJ,$ZodError:()=>ZW,$ZodEnum:()=>lJ,$ZodEmoji:()=>_J,$ZodEmail:()=>wJ,$ZodE164:()=>kJ,$ZodDiscriminatedUnion:()=>cJ,$ZodDefault:()=>sJ,$ZodDate:()=>hJ,$ZodCustom:()=>w9,$ZodCheckUpperCase:()=>aG,$ZodCheckStringFormat:()=>o0,$ZodCheckStartsWith:()=>eG,$ZodCheckSizeEquals:()=>dG,$ZodCheckRegex:()=>nG,$ZodCheckProperty:()=>TJ,$ZodCheckOverwrite:()=>XJ,$ZodCheckNumberFormat:()=>cG,$ZodCheckMultipleOf:()=>mG,$ZodCheckMinSize:()=>oG,$ZodCheckMinLength:()=>rG,$ZodCheckMimeType:()=>WJ,$ZodCheckMaxSize:()=>pG,$ZodCheckMaxLength:()=>lG,$ZodCheckLowerCase:()=>tG,$ZodCheckLessThan:()=>iX,$ZodCheckLengthEquals:()=>iG,$ZodCheckIncludes:()=>sG,$ZodCheckGreaterThan:()=>nX,$ZodCheckEndsWith:()=>$J,$ZodCheckBigIntFormat:()=>uG,$ZodCheck:()=>u$,$ZodCatch:()=>W9,$ZodCUID2:()=>QJ,$ZodCUID:()=>FJ,$ZodCIDRv6:()=>SJ,$ZodCIDRv4:()=>LJ,$ZodBoolean:()=>EW,$ZodBigIntFormat:()=>CJ,$ZodBigInt:()=>$8,$ZodBase64URL:()=>IJ,$ZodBase64:()=>RJ,$ZodAsyncError:()=>u6,$ZodArray:()=>gJ,$ZodAny:()=>bJ});function K($,T,W){let X=W?.Parent??Object;class Y extends X{constructor(U){var G;super();let J=this;Y.init(J,U),(G=J._zod).deferred??(G.deferred=[]);for(let z of J._zod.deferred)z()}static init(U,G){var J;Object.defineProperty(U,"_zod",{value:U._zod??{},enumerable:!1}),(J=U._zod).traits??(J.traits=new Set),U._zod.traits.add($),T(U,G);for(let z in Y.prototype)Object.defineProperty(U,z,{value:Y.prototype[z].bind(U)});U._zod.constr=Y,U._zod.def=G}static[Symbol.hasInstance](U){if(W?.Parent&&U instanceof W.Parent)return!0;return U?._zod?.traits?.has($)}}return Object.defineProperty(Y,"name",{value:$}),Y}var eU=Symbol("zod_brand");class u6 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}var GW={};function n$($){if($)Object.assign(GW,$);return GW}var g={};K1(g,{unwrapMessage:()=>JW,stringifyPrimitive:()=>u,required:()=>vM,randomString:()=>yX,propertyKeyTypes:()=>HW,promiseAllObject:()=>LM,primitiveTypes:()=>UG,prefixIssues:()=>x4,pick:()=>IM,partial:()=>CM,optionalKeys:()=>GG,omit:()=>kM,numKeys:()=>SM,nullish:()=>S1,normalizeParams:()=>j,merge:()=>PM,jsonStringifyReplacer:()=>TG,joinValues:()=>q,issue:()=>zG,isPlainObject:()=>_W,isObject:()=>hX,getValidEnumValues:()=>MM,getSizableOrigin:()=>FW,getParsedType:()=>BM,getLengthableOrigin:()=>QW,getElementAtPath:()=>NM,floatSafeRemainder:()=>WG,finalizeIssue:()=>i4,extend:()=>qM,escapeRegex:()=>C6,esc:()=>i1,defineLazy:()=>M$,createTransparentProxy:()=>RM,clone:()=>r4,cleanRegex:()=>zW,cleanEnum:()=>jM,cached:()=>wW,assignProp:()=>XG,assertNotEqual:()=>VM,assertNever:()=>EM,assertIs:()=>KM,assertEqual:()=>OM,assert:()=>AM,allowsEval:()=>YG,aborted:()=>n1,NUMBER_FORMAT_RANGES:()=>JG,Class:()=>G3,BIGINT_FORMAT_RANGES:()=>wG});function OM($){return $}function VM($){return $}function KM($){}function EM($){throw new Error}function AM($){}function MM($){let T=Object.keys($).filter((X)=>typeof $[$[X]]!=="number"),W={};for(let X of T)W[X]=$[X];return Object.values(W)}function q($,T="|"){return $.map((W)=>u(W)).join(T)}function TG($,T){if(typeof T==="bigint")return T.toString();return T}function wW($){return{get value(){{let W=$();return Object.defineProperty(this,"value",{value:W}),W}throw new Error("cached value already set")}}}function S1($){return $===null||$===void 0}function zW($){let T=$.startsWith("^")?1:0,W=$.endsWith("$")?$.length-1:$.length;return $.slice(T,W)}function WG($,T){let W=($.toString().split(".")[1]||"").length,X=(T.toString().split(".")[1]||"").length,Y=W>X?W:X,U=Number.parseInt($.toFixed(Y).replace(".","")),G=Number.parseInt(T.toFixed(Y).replace(".",""));return U%G/10**Y}function M$($,T,W){Object.defineProperty($,T,{get(){{let Y=W();return $[T]=Y,Y}throw new Error("cached value already set")},set(Y){Object.defineProperty($,T,{value:Y})},configurable:!0})}function XG($,T,W){Object.defineProperty($,T,{value:W,writable:!0,enumerable:!0,configurable:!0})}function NM($,T){if(!T)return $;return T.reduce((W,X)=>W?.[X],$)}function LM($){let T=Object.keys($),W=T.map((X)=>$[X]);return Promise.all(W).then((X)=>{let Y={};for(let U=0;U<T.length;U++)Y[T[U]]=X[U];return Y})}function yX($=10){let W="";for(let X=0;X<$;X++)W+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return W}function i1($){return JSON.stringify($)}function hX($){return typeof $==="object"&&$!==null}var YG=wW(()=>{try{return new Function(""),!0}catch($){return!1}});function _W($){return typeof $==="object"&&$!==null&&Object.getPrototypeOf($)===Object.prototype}function SM($){let T=0;for(let W in $)if(Object.prototype.hasOwnProperty.call($,W))T++;return T}var BM=($)=>{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}`)}},HW=new Set(["string","number","symbol"]),UG=new Set(["string","number","bigint","boolean","symbol","undefined"]);function C6($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r4($,T,W){let X=new $._zod.constr(T??$._zod.def);if(!T||W?.parent)X._zod.parent=$;return X}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 RM($){let T;return new Proxy({},{get(W,X,Y){return T??(T=$()),Reflect.get(T,X,Y)},set(W,X,Y,U){return T??(T=$()),Reflect.set(T,X,Y,U)},has(W,X){return T??(T=$()),Reflect.has(T,X)},deleteProperty(W,X){return T??(T=$()),Reflect.deleteProperty(T,X)},ownKeys(W){return T??(T=$()),Reflect.ownKeys(T)},getOwnPropertyDescriptor(W,X){return T??(T=$()),Reflect.getOwnPropertyDescriptor(T,X)},defineProperty(W,X,Y){return T??(T=$()),Reflect.defineProperty(T,X,Y)}})}function u($){if(typeof $==="bigint")return $.toString()+"n";if(typeof $==="string")return`"${$}"`;return`${$}`}function GG($){return Object.keys($).filter((T)=>{return $[T]._zod.optin==="optional"})}var JG={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]},wG={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function IM($,T){let W={},X=$._zod.def;for(let Y in T){if(!(Y in X.shape))throw new Error(`Unrecognized key: "${Y}"`);if(!T[Y])continue;W[Y]=X.shape[Y]}return r4($,{...$._zod.def,shape:W,checks:[]})}function kM($,T){let W={...$._zod.def.shape},X=$._zod.def;for(let Y in T){if(!(Y in X.shape))throw new Error(`Unrecognized key: "${Y}"`);if(!T[Y])continue;delete W[Y]}return r4($,{...$._zod.def,shape:W,checks:[]})}function qM($,T){let W={...$._zod.def,get shape(){let X={...$._zod.def.shape,...T};return XG(this,"shape",X),X},checks:[]};return r4($,W)}function PM($,T){return r4($,{...$._zod.def,get shape(){let W={...$._zod.def.shape,...T._zod.def.shape};return XG(this,"shape",W),W},catchall:T._zod.def.catchall,checks:[]})}function CM($,T,W){let X=T._zod.def.shape,Y={...X};if(W)for(let U in W){if(!(U in X))throw new Error(`Unrecognized key: "${U}"`);if(!W[U])continue;Y[U]=$?new $({type:"optional",innerType:X[U]}):X[U]}else for(let U in X)Y[U]=$?new $({type:"optional",innerType:X[U]}):X[U];return r4(T,{...T._zod.def,shape:Y,checks:[]})}function vM($,T,W){let X=T._zod.def.shape,Y={...X};if(W)for(let U in W){if(!(U in Y))throw new Error(`Unrecognized key: "${U}"`);if(!W[U])continue;Y[U]=new $({type:"nonoptional",innerType:X[U]})}else for(let U in X)Y[U]=new $({type:"nonoptional",innerType:X[U]});return r4(T,{...T._zod.def,shape:Y,checks:[]})}function n1($,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 X;return(X=W).path??(X.path=[]),W.path.unshift($),W})}function JW($){return typeof $==="string"?$:$?.message}function i4($,T,W){let X={...$,path:$.path??[]};if(!$.message){let Y=JW($.inst?._zod.def?.error?.($))??JW(T?.error?.($))??JW(W.customError?.($))??JW(W.localeError?.($))??"Invalid input";X.message=Y}if(delete X.inst,delete X.continue,!T?.reportInput)delete X.input;return X}function FW($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function QW($){if(Array.isArray($))return"array";if(typeof $==="string")return"string";return"unknown"}function zG(...$){let[T,W,X]=$;if(typeof T==="string")return{message:T,code:"custom",input:W,inst:X};return{...T}}function jM($){return Object.entries($).filter(([T,W])=>{return Number.isNaN(Number.parseInt(T,10))}).map((T)=>T[1])}class G3{constructor(...$){}}var J3=($,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,TG,2)},enumerable:!0})},ZW=K("$ZodError",J3),p0=K("$ZodError",J3,{Parent:Error});function DW($,T=(W)=>W.message){let W={},X=[];for(let Y of $.issues)if(Y.path.length>0)W[Y.path[0]]=W[Y.path[0]]||[],W[Y.path[0]].push(T(Y));else X.push(T(Y));return{formErrors:X,fieldErrors:W}}function OW($,T){let W=T||function(U){return U.message},X={_errors:[]},Y=(U)=>{for(let G of U.issues)if(G.code==="invalid_union")G.errors.map((J)=>Y({issues:J}));else if(G.code==="invalid_key")Y({issues:G.issues});else if(G.code==="invalid_element")Y({issues:G.issues});else if(G.path.length===0)X._errors.push(W(G));else{let J=X,z=0;while(z<G.path.length){let w=G.path[z];if(z!==G.path.length-1)J[w]=J[w]||{_errors:[]};else J[w]=J[w]||{_errors:[]},J[w]._errors.push(W(G));J=J[w],z++}}};return Y($),X}function _G($,T){let W=T||function(U){return U.message},X={errors:[]},Y=(U,G=[])=>{var J,z;for(let w of U.issues)if(w.code==="invalid_union")w.errors.map((H)=>Y({issues:H},w.path));else if(w.code==="invalid_key")Y({issues:w.issues},w.path);else if(w.code==="invalid_element")Y({issues:w.issues},w.path);else{let H=[...G,...w.path];if(H.length===0){X.errors.push(W(w));continue}let _=X,F=0;while(F<H.length){let D=H[F],V=F===H.length-1;if(typeof D==="string")_.properties??(_.properties={}),(J=_.properties)[D]??(J[D]={errors:[]}),_=_.properties[D];else _.items??(_.items=[]),(z=_.items)[D]??(z[D]={errors:[]}),_=_.items[D];if(V)_.errors.push(W(w));F++}}};return Y($),X}function w3($){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 HG($){let T=[],W=[...$.issues].sort((X,Y)=>X.path.length-Y.path.length);for(let X of W)if(T.push(`\u2716 ${X.message}`),X.path?.length)T.push(` \u2192 at ${w3(X.path)}`);return T.join(`
6
- `)}var gX=($)=>(T,W,X,Y)=>{let U=X?Object.assign(X,{async:!1}):{async:!1},G=T._zod.run({value:W,issues:[]},U);if(G instanceof Promise)throw new u6;if(G.issues.length){let J=new(Y?.Err??$)(G.issues.map((z)=>i4(z,U,n$())));throw Error.captureStackTrace(J,Y?.callee),J}return G.value},mX=gX(p0),cX=($)=>async(T,W,X,Y)=>{let U=X?Object.assign(X,{async:!0}):{async:!0},G=T._zod.run({value:W,issues:[]},U);if(G instanceof Promise)G=await G;if(G.issues.length){let J=new(Y?.Err??$)(G.issues.map((z)=>i4(z,U,n$())));throw Error.captureStackTrace(J,Y?.callee),J}return G.value},uX=cX(p0),pX=($)=>(T,W,X)=>{let Y=X?{...X,async:!1}:{async:!1},U=T._zod.run({value:W,issues:[]},Y);if(U instanceof Promise)throw new u6;return U.issues.length?{success:!1,error:new($??ZW)(U.issues.map((G)=>i4(G,Y,n$())))}:{success:!0,data:U.value}},FG=pX(p0),oX=($)=>async(T,W,X)=>{let Y=X?Object.assign(X,{async:!0}):{async:!0},U=T._zod.run({value:W,issues:[]},Y);if(U instanceof Promise)U=await U;return U.issues.length?{success:!1,error:new $(U.issues.map((G)=>i4(G,Y,n$())))}:{success:!0,data:U.value}},QG=oX(p0);var a1={};K1(a1,{xid:()=>VG,uuid7:()=>hM,uuid6:()=>yM,uuid4:()=>fM,uuid:()=>t1,uppercase:()=>gG,unicodeEmail:()=>cM,undefined:()=>yG,ulid:()=>OG,time:()=>qG,string:()=>CG,rfc5322Email:()=>mM,number:()=>xG,null:()=>fG,nanoid:()=>EG,lowercase:()=>hG,ksuid:()=>KG,ipv6:()=>lX,ipv4:()=>dX,ip:()=>oM,integer:()=>jG,html5Email:()=>gM,hostname:()=>VW,guid:()=>MG,extendedDuration:()=>bM,emoji:()=>LG,email:()=>NG,e164:()=>IG,duration:()=>AG,datetime:()=>PG,date:()=>kG,cuid2:()=>DG,cuid:()=>ZG,cidrv6:()=>BG,cidrv4:()=>SG,browserEmail:()=>uM,boolean:()=>bG,bigint:()=>vG,base64url:()=>rX,base64:()=>RG,_emoji:()=>pM});var ZG=/^[cC][^\s-]{8,}$/,DG=/^[0-9a-z]+$/,OG=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,VG=/^[0-9a-vA-V]{20}$/,KG=/^[A-Za-z0-9]{27}$/,EG=/^[a-zA-Z0-9_-]{21}$/,AG=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,bM=/^[-+]?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)?)??$/,MG=/^([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})$/,t1=($)=>{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})$`)},fM=t1(4),yM=t1(6),hM=t1(7),NG=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,gM=/^[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])?)*$/,mM=/^(([^<>()\[\]\\.,;:\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,}))$/,cM=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,uM=/^[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])?)*$/,pM="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function LG(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var dX=/^(?:(?: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])$/,lX=/^(([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})$/,SG=/^((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])$/,BG=/^(([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])$/,oM=new RegExp(`(${dX.source})|(${lX.source})`),RG=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rX=/^[A-Za-z0-9_-]*$/,VW=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,IG=/^\+(?:[0-9]){6,14}[0-9]$/,z3="((\\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])))",kG=new RegExp(`^${z3}$`);function _3($){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 qG($){return new RegExp(`^${_3($)}$`)}function PG($){let T=`${z3}T${_3($)}`,W=[];if(W.push($.local?"Z?":"Z"),$.offset)W.push("([+-]\\d{2}:?\\d{2})");return T=`${T}(${W.join("|")})`,new RegExp(`^${T}$`)}var CG=($)=>{let T=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${T}$`)},vG=/^\d+n?$/,jG=/^\d+$/,xG=/^-?\d+(?:\.\d+)?/i,bG=/true|false/i,fG=/null/i;var yG=/undefined/i;var hG=/^[^A-Z]*$/,gG=/^[^a-z]*$/;var u$=K("$ZodCheck",($,T)=>{var W;$._zod??($._zod={}),$._zod.def=T,(W=$._zod).onattach??(W.onattach=[])}),F3={number:"number",bigint:"bigint",object:"date"},iX=K("$ZodCheckLessThan",($,T)=>{u$.init($,T);let W=F3[typeof T.value];$._zod.onattach.push((X)=>{let Y=X._zod.bag,U=(T.inclusive?Y.maximum:Y.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(T.value<U)if(T.inclusive)Y.maximum=T.value;else Y.exclusiveMaximum=T.value}),$._zod.check=(X)=>{if(T.inclusive?X.value<=T.value:X.value<T.value)return;X.issues.push({origin:W,code:"too_big",maximum:T.value,input:X.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),nX=K("$ZodCheckGreaterThan",($,T)=>{u$.init($,T);let W=F3[typeof T.value];$._zod.onattach.push((X)=>{let Y=X._zod.bag,U=(T.inclusive?Y.minimum:Y.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(T.value>U)if(T.inclusive)Y.minimum=T.value;else Y.exclusiveMinimum=T.value}),$._zod.check=(X)=>{if(T.inclusive?X.value>=T.value:X.value>T.value)return;X.issues.push({origin:W,code:"too_small",minimum:T.value,input:X.value,inclusive:T.inclusive,inst:$,continue:!T.abort})}}),mG=K("$ZodCheckMultipleOf",($,T)=>{u$.init($,T),$._zod.onattach.push((W)=>{var X;(X=W._zod.bag).multipleOf??(X.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):WG(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})}}),cG=K("$ZodCheckNumberFormat",($,T)=>{u$.init($,T),T.format=T.format||"float64";let W=T.format?.includes("int"),X=W?"int":"number",[Y,U]=JG[T.format];$._zod.onattach.push((G)=>{let J=G._zod.bag;if(J.format=T.format,J.minimum=Y,J.maximum=U,W)J.pattern=jG}),$._zod.check=(G)=>{let J=G.value;if(W){if(!Number.isInteger(J)){G.issues.push({expected:X,format:T.format,code:"invalid_type",input:J,inst:$});return}if(!Number.isSafeInteger(J)){if(J>0)G.issues.push({input:J,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the the safe integer range.",inst:$,origin:X,continue:!T.abort});else G.issues.push({input:J,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:X,continue:!T.abort});return}}if(J<Y)G.issues.push({origin:"number",input:J,code:"too_small",minimum:Y,inclusive:!0,inst:$,continue:!T.abort});if(J>U)G.issues.push({origin:"number",input:J,code:"too_big",maximum:U,inst:$})}}),uG=K("$ZodCheckBigIntFormat",($,T)=>{u$.init($,T);let[W,X]=wG[T.format];$._zod.onattach.push((Y)=>{let U=Y._zod.bag;U.format=T.format,U.minimum=W,U.maximum=X}),$._zod.check=(Y)=>{let U=Y.value;if(U<W)Y.issues.push({origin:"bigint",input:U,code:"too_small",minimum:W,inclusive:!0,inst:$,continue:!T.abort});if(U>X)Y.issues.push({origin:"bigint",input:U,code:"too_big",maximum:X,inst:$})}}),pG=K("$ZodCheckMaxSize",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!S1(X)&&X.size!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<X)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let X=W.value;if(X.size<=T.maximum)return;W.issues.push({origin:FW(X),code:"too_big",maximum:T.maximum,input:X,inst:$,continue:!T.abort})}}),oG=K("$ZodCheckMinSize",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!S1(X)&&X.size!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>X)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let X=W.value;if(X.size>=T.minimum)return;W.issues.push({origin:FW(X),code:"too_small",minimum:T.minimum,input:X,inst:$,continue:!T.abort})}}),dG=K("$ZodCheckSizeEquals",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!S1(X)&&X.size!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag;X.minimum=T.size,X.maximum=T.size,X.size=T.size}),$._zod.check=(W)=>{let X=W.value,Y=X.size;if(Y===T.size)return;let U=Y>T.size;W.issues.push({origin:FW(X),...U?{code:"too_big",maximum:T.size}:{code:"too_small",minimum:T.size},input:W.value,inst:$,continue:!T.abort})}}),lG=K("$ZodCheckMaxLength",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!S1(X)&&X.length!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(T.maximum<X)W._zod.bag.maximum=T.maximum}),$._zod.check=(W)=>{let X=W.value;if(X.length<=T.maximum)return;let U=QW(X);W.issues.push({origin:U,code:"too_big",maximum:T.maximum,input:X,inst:$,continue:!T.abort})}}),rG=K("$ZodCheckMinLength",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!S1(X)&&X.length!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(T.minimum>X)W._zod.bag.minimum=T.minimum}),$._zod.check=(W)=>{let X=W.value;if(X.length>=T.minimum)return;let U=QW(X);W.issues.push({origin:U,code:"too_small",minimum:T.minimum,input:X,inst:$,continue:!T.abort})}}),iG=K("$ZodCheckLengthEquals",($,T)=>{u$.init($,T),$._zod.when=(W)=>{let X=W.value;return!S1(X)&&X.length!==void 0},$._zod.onattach.push((W)=>{let X=W._zod.bag;X.minimum=T.length,X.maximum=T.length,X.length=T.length}),$._zod.check=(W)=>{let X=W.value,Y=X.length;if(Y===T.length)return;let U=QW(X),G=Y>T.length;W.issues.push({origin:U,...G?{code:"too_big",maximum:T.length}:{code:"too_small",minimum:T.length},input:W.value,inst:$,continue:!T.abort})}}),o0=K("$ZodCheckStringFormat",($,T)=>{var W;u$.init($,T),$._zod.onattach.push((X)=>{if(X._zod.bag.format=T.format,T.pattern)X._zod.bag.pattern=T.pattern}),(W=$._zod).check??(W.check=(X)=>{if(!T.pattern)throw new Error("Not implemented.");if(T.pattern.lastIndex=0,T.pattern.test(X.value))return;X.issues.push({origin:"string",code:"invalid_format",format:T.format,input:X.value,...T.pattern?{pattern:T.pattern.toString()}:{},inst:$,continue:!T.abort})})}),nG=K("$ZodCheckRegex",($,T)=>{o0.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})}}),tG=K("$ZodCheckLowerCase",($,T)=>{T.pattern??(T.pattern=hG),o0.init($,T)}),aG=K("$ZodCheckUpperCase",($,T)=>{T.pattern??(T.pattern=gG),o0.init($,T)}),sG=K("$ZodCheckIncludes",($,T)=>{u$.init($,T);let W=new RegExp(C6(T.includes));T.pattern=W,$._zod.onattach.push((X)=>{X._zod.bag.pattern=W}),$._zod.check=(X)=>{if(X.value.includes(T.includes,T.position))return;X.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:T.includes,input:X.value,inst:$,continue:!T.abort})}}),eG=K("$ZodCheckStartsWith",($,T)=>{u$.init($,T);let W=new RegExp(`^${C6(T.prefix)}.*`);T.pattern??(T.pattern=W),$._zod.onattach.push((X)=>{X._zod.bag.pattern=W}),$._zod.check=(X)=>{if(X.value.startsWith(T.prefix))return;X.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:T.prefix,input:X.value,inst:$,continue:!T.abort})}}),$J=K("$ZodCheckEndsWith",($,T)=>{u$.init($,T);let W=new RegExp(`.*${C6(T.suffix)}$`);T.pattern??(T.pattern=W),$._zod.onattach.push((X)=>{X._zod.bag.pattern=new RegExp(`.*${C6(T.suffix)}$`)}),$._zod.check=(X)=>{if(X.value.endsWith(T.suffix))return;X.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:T.suffix,input:X.value,inst:$,continue:!T.abort})}});function H3($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues))}var TJ=K("$ZodCheckProperty",($,T)=>{u$.init($,T),$._zod.check=(W)=>{let X=T.schema._zod.run({value:W.value[T.property],issues:[]},{});if(X instanceof Promise)return X.then((Y)=>H3(Y,W,T.property));H3(X,W,T.property);return}}),WJ=K("$ZodCheckMimeType",($,T)=>{u$.init($,T);let W=new Set(T.mime);$._zod.onattach.push((X)=>{X._zod.bag.mime=T.mime}),$._zod.check=(X)=>{if(W.has(X.value.type))return;X.issues.push({code:"invalid_value",values:T.mime,input:X.value.type,path:["type"],inst:$})}}),XJ=K("$ZodCheckOverwrite",($,T)=>{u$.init($,T),$._zod.check=(W)=>{W.value=T.tx(W.value)}});class tX{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),X=Math.min(...W.map((U)=>U.length-U.trimStart().length)),Y=W.map((U)=>U.slice(X)).map((U)=>" ".repeat(this.indent*2)+U);for(let U of Y)this.content.push(U)}compile(){let $=Function,T=this?.args,X=[...(this?.content??[""]).map((Y)=>` ${Y}`)];return new $(...T,X.join(`
8
- `))}}var YJ={major:4,minor:0,patch:0};var T$=K("$ZodType",($,T)=>{var W;$??($={}),$._zod.id=T.type+"_"+yX(10),$._zod.def=T,$._zod.bag=$._zod.bag||{},$._zod.version=YJ;let X=[...$._zod.def.checks??[]];if($._zod.traits.has("$ZodCheck"))X.unshift($);for(let Y of X)for(let U of Y._zod.onattach)U($);if(X.length===0)(W=$._zod).deferred??(W.deferred=[]),$._zod.deferred?.push(()=>{$._zod.run=$._zod.parse});else{let Y=(U,G,J)=>{let z=n1(U),w;for(let H of G){if(H._zod.when){if(!H._zod.when(U))continue}else if(z)continue;let _=U.issues.length,F=H._zod.check(U);if(F instanceof Promise&&J?.async===!1)throw new u6;if(w||F instanceof Promise)w=(w??Promise.resolve()).then(async()=>{if(await F,U.issues.length===_)return;if(!z)z=n1(U,_)});else{if(U.issues.length===_)continue;if(!z)z=n1(U,_)}}if(w)return w.then(()=>{return U});return U};$._zod.run=(U,G)=>{let J=$._zod.parse(U,G);if(J instanceof Promise){if(G.async===!1)throw new u6;return J.then((z)=>Y(z,X,G))}return Y(J,X,G)}}$["~standard"]={validate:(Y)=>{try{let U=FG($,Y);return U.success?{value:U.data}:{issues:U.error?.issues}}catch(U){return QG($,Y).then((G)=>G.success?{value:G.data}:{issues:G.error?.issues})}},vendor:"zod",version:1}}),KW=K("$ZodString",($,T)=>{T$.init($,T),$._zod.pattern=$?._zod.bag?.pattern??CG($._zod.bag),$._zod.parse=(W,X)=>{if(T.coerce)try{W.value=String(W.value)}catch(Y){}if(typeof W.value==="string")return W;return W.issues.push({expected:"string",code:"invalid_type",input:W.value,inst:$}),W}}),q$=K("$ZodStringFormat",($,T)=>{o0.init($,T),KW.init($,T)}),GJ=K("$ZodGUID",($,T)=>{T.pattern??(T.pattern=MG),q$.init($,T)}),JJ=K("$ZodUUID",($,T)=>{if(T.version){let X={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[T.version];if(X===void 0)throw new Error(`Invalid UUID version: "${T.version}"`);T.pattern??(T.pattern=t1(X))}else T.pattern??(T.pattern=t1());q$.init($,T)}),wJ=K("$ZodEmail",($,T)=>{T.pattern??(T.pattern=NG),q$.init($,T)}),zJ=K("$ZodURL",($,T)=>{q$.init($,T),$._zod.check=(W)=>{try{let X=new URL(W.value);if(VW.lastIndex=0,!VW.test(X.hostname))W.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:VW.source,input:W.value,inst:$});if(T.hostname){if(T.hostname.lastIndex=0,!T.hostname.test(X.hostname))W.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:T.hostname.source,input:W.value,inst:$})}if(T.protocol){if(T.protocol.lastIndex=0,!T.protocol.test(X.protocol.endsWith(":")?X.protocol.slice(0,-1):X.protocol))W.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:T.protocol.source,input:W.value,inst:$})}return}catch(X){W.issues.push({code:"invalid_format",format:"url",input:W.value,inst:$})}}}),_J=K("$ZodEmoji",($,T)=>{T.pattern??(T.pattern=LG()),q$.init($,T)}),HJ=K("$ZodNanoID",($,T)=>{T.pattern??(T.pattern=EG),q$.init($,T)}),FJ=K("$ZodCUID",($,T)=>{T.pattern??(T.pattern=ZG),q$.init($,T)}),QJ=K("$ZodCUID2",($,T)=>{T.pattern??(T.pattern=DG),q$.init($,T)}),ZJ=K("$ZodULID",($,T)=>{T.pattern??(T.pattern=OG),q$.init($,T)}),DJ=K("$ZodXID",($,T)=>{T.pattern??(T.pattern=VG),q$.init($,T)}),OJ=K("$ZodKSUID",($,T)=>{T.pattern??(T.pattern=KG),q$.init($,T)}),VJ=K("$ZodISODateTime",($,T)=>{T.pattern??(T.pattern=PG(T)),q$.init($,T)}),KJ=K("$ZodISODate",($,T)=>{T.pattern??(T.pattern=kG),q$.init($,T)}),EJ=K("$ZodISOTime",($,T)=>{T.pattern??(T.pattern=qG(T)),q$.init($,T)}),AJ=K("$ZodISODuration",($,T)=>{T.pattern??(T.pattern=AG),q$.init($,T)}),MJ=K("$ZodIPv4",($,T)=>{T.pattern??(T.pattern=dX),q$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.format="ipv4"})}),NJ=K("$ZodIPv6",($,T)=>{T.pattern??(T.pattern=lX),q$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.format="ipv6"}),$._zod.check=(W)=>{try{new URL(`http://[${W.value}]`)}catch{W.issues.push({code:"invalid_format",format:"ipv6",input:W.value,inst:$})}}}),LJ=K("$ZodCIDRv4",($,T)=>{T.pattern??(T.pattern=SG),q$.init($,T)}),SJ=K("$ZodCIDRv6",($,T)=>{T.pattern??(T.pattern=BG),q$.init($,T),$._zod.check=(W)=>{let[X,Y]=W.value.split("/");try{if(!Y)throw new Error;let U=Number(Y);if(`${U}`!==Y)throw new Error;if(U<0||U>128)throw new Error;new URL(`http://[${X}]`)}catch{W.issues.push({code:"invalid_format",format:"cidrv6",input:W.value,inst:$})}}});function BJ($){if($==="")return!0;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}var RJ=K("$ZodBase64",($,T)=>{T.pattern??(T.pattern=RG),q$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.contentEncoding="base64"}),$._zod.check=(W)=>{if(BJ(W.value))return;W.issues.push({code:"invalid_format",format:"base64",input:W.value,inst:$})}});function B3($){if(!rX.test($))return!1;let T=$.replace(/[-_]/g,(X)=>X==="-"?"+":"/"),W=T.padEnd(Math.ceil(T.length/4)*4,"=");return BJ(W)}var IJ=K("$ZodBase64URL",($,T)=>{T.pattern??(T.pattern=rX),q$.init($,T),$._zod.onattach.push((W)=>{W._zod.bag.contentEncoding="base64url"}),$._zod.check=(W)=>{if(B3(W.value))return;W.issues.push({code:"invalid_format",format:"base64url",input:W.value,inst:$})}}),kJ=K("$ZodE164",($,T)=>{T.pattern??(T.pattern=IG),q$.init($,T)});function R3($,T=null){try{let W=$.split(".");if(W.length!==3)return!1;let[X]=W,Y=JSON.parse(atob(X));if("typ"in Y&&Y?.typ!=="JWT")return!1;if(!Y.alg)return!1;if(T&&(!("alg"in Y)||Y.alg!==T))return!1;return!0}catch{return!1}}var qJ=K("$ZodJWT",($,T)=>{q$.init($,T),$._zod.check=(W)=>{if(R3(W.value,T.alg))return;W.issues.push({code:"invalid_format",format:"jwt",input:W.value,inst:$})}}),eX=K("$ZodNumber",($,T)=>{T$.init($,T),$._zod.pattern=$._zod.bag.pattern??xG,$._zod.parse=(W,X)=>{if(T.coerce)try{W.value=Number(W.value)}catch(G){}let Y=W.value;if(typeof Y==="number"&&!Number.isNaN(Y)&&Number.isFinite(Y))return W;let U=typeof Y==="number"?Number.isNaN(Y)?"NaN":!Number.isFinite(Y)?"Infinity":void 0:void 0;return W.issues.push({expected:"number",code:"invalid_type",input:Y,inst:$,...U?{received:U}:{}}),W}}),PJ=K("$ZodNumber",($,T)=>{cG.init($,T),eX.init($,T)}),EW=K("$ZodBoolean",($,T)=>{T$.init($,T),$._zod.pattern=bG,$._zod.parse=(W,X)=>{if(T.coerce)try{W.value=Boolean(W.value)}catch(U){}let Y=W.value;if(typeof Y==="boolean")return W;return W.issues.push({expected:"boolean",code:"invalid_type",input:Y,inst:$}),W}}),$8=K("$ZodBigInt",($,T)=>{T$.init($,T),$._zod.pattern=vG,$._zod.parse=(W,X)=>{if(T.coerce)try{W.value=BigInt(W.value)}catch(U){}let{value:Y}=W;if(typeof Y==="bigint")return W;return W.issues.push({expected:"bigint",code:"invalid_type",input:Y,inst:$}),W}}),CJ=K("$ZodBigInt",($,T)=>{uG.init($,T),$8.init($,T)}),vJ=K("$ZodSymbol",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let{value:Y}=W;if(typeof Y==="symbol")return W;return W.issues.push({expected:"symbol",code:"invalid_type",input:Y,inst:$}),W}}),jJ=K("$ZodUndefined",($,T)=>{T$.init($,T),$._zod.pattern=yG,$._zod.values=new Set([void 0]),$._zod.parse=(W,X)=>{let{value:Y}=W;if(typeof Y==="undefined")return W;return W.issues.push({expected:"undefined",code:"invalid_type",input:Y,inst:$}),W}}),xJ=K("$ZodNull",($,T)=>{T$.init($,T),$._zod.pattern=fG,$._zod.values=new Set([null]),$._zod.parse=(W,X)=>{let{value:Y}=W;if(Y===null)return W;return W.issues.push({expected:"null",code:"invalid_type",input:Y,inst:$}),W}}),bJ=K("$ZodAny",($,T)=>{T$.init($,T),$._zod.parse=(W)=>W}),AW=K("$ZodUnknown",($,T)=>{T$.init($,T),$._zod.parse=(W)=>W}),fJ=K("$ZodNever",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{return W.issues.push({expected:"never",code:"invalid_type",input:W.value,inst:$}),W}}),yJ=K("$ZodVoid",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let{value:Y}=W;if(typeof Y==="undefined")return W;return W.issues.push({expected:"void",code:"invalid_type",input:Y,inst:$}),W}}),hJ=K("$ZodDate",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{if(T.coerce)try{W.value=new Date(W.value)}catch(J){}let Y=W.value,U=Y instanceof Date;if(U&&!Number.isNaN(Y.getTime()))return W;return W.issues.push({expected:"date",code:"invalid_type",input:Y,...U?{received:"Invalid Date"}:{},inst:$}),W}});function Z3($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues));T.value[W]=$.value}var gJ=K("$ZodArray",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let Y=W.value;if(!Array.isArray(Y))return W.issues.push({expected:"array",code:"invalid_type",input:Y,inst:$}),W;W.value=Array(Y.length);let U=[];for(let G=0;G<Y.length;G++){let J=Y[G],z=T.element._zod.run({value:J,issues:[]},X);if(z instanceof Promise)U.push(z.then((w)=>Z3(w,W,G)));else Z3(z,W,G)}if(U.length)return Promise.all(U).then(()=>W);return W}});function aX($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues));T.value[W]=$.value}function D3($,T,W,X){if($.issues.length)if(X[W]===void 0)if(W in X)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 X)T.value[W]=void 0}else T.value[W]=$.value}var mJ=K("$ZodObject",($,T)=>{T$.init($,T);let W=wW(()=>{let _=Object.keys(T.shape),F=GG(T.shape);return{shape:T.shape,keys:_,keySet:new Set(_),numKeys:_.length,optionalKeys:new Set(F)}});M$($._zod,"disc",()=>{let _=T.shape,F=new Map,D=!1;for(let V in _){let E=_[V]._zod;if(E.values||E.disc){D=!0;let R={values:new Set(E.values??[]),maps:E.disc?[E.disc]:[]};F.set(V,R)}}if(!D)return;return F});let X=(_)=>{let F=new tX(["shape","payload","ctx"]),{keys:D,optionalKeys:V}=W.value,E=(M)=>{let N=i1(M);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};F.write("const input = payload.value;");let R=Object.create(null);for(let M of D)R[M]=yX(15);F.write("const newResult = {}");for(let M of D)if(V.has(M)){let N=R[M];F.write(`const ${N} = ${E(M)};`);let k=i1(M);F.write(`
9
- if (${N}.issues.length) {
10
- if (input[${k}] === undefined) {
11
- if (${k} in input) {
12
- newResult[${k}] = undefined;
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;
13
13
  }
14
14
  } else {
15
15
  payload.issues = payload.issues.concat(
16
- ${N}.issues.map((iss) => ({
16
+ ${L}.issues.map((iss) => ({
17
17
  ...iss,
18
- path: iss.path ? [${k}, ...iss.path] : [${k}],
18
+ path: iss.path ? [${q}, ...iss.path] : [${q}],
19
19
  }))
20
20
  );
21
21
  }
22
- } else if (${N}.value === undefined) {
23
- if (${k} in input) newResult[${k}] = undefined;
22
+ } else if (${L}.value === undefined) {
23
+ if (${q} in input) newResult[${q}] = undefined;
24
24
  } else {
25
- newResult[${k}] = ${N}.value;
25
+ newResult[${q}] = ${L}.value;
26
26
  }
27
- `)}else{let N=R[M];F.write(`const ${N} = ${E(M)};`),F.write(`
28
- if (${N}.issues.length) payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
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 => ({
29
29
  ...iss,
30
- path: iss.path ? [${i1(M)}, ...iss.path] : [${i1(M)}]
31
- })));`),F.write(`newResult[${i1(M)}] = ${N}.value`)}F.write("payload.value = newResult;"),F.write("return payload;");let P=F.compile();return(M,N)=>P(_,M,N)},Y,U=hX,G=!GW.jitless,z=G&&YG.value,{catchall:w}=T,H;$._zod.parse=(_,F)=>{H??(H=W.value);let D=_.value;if(!U(D))return _.issues.push({expected:"object",code:"invalid_type",input:D,inst:$}),_;let V=[];if(G&&z&&F?.async===!1&&F.jitless!==!0){if(!Y)Y=X(T.shape);_=Y(_,F)}else{_.value={};let N=H.shape;for(let k of H.keys){let y=N[k],x=y._zod.run({value:D[k],issues:[]},F),m=y._zod.optin==="optional";if(x instanceof Promise)V.push(x.then((J$)=>m?D3(J$,_,k,D):aX(J$,_,k)));else if(m)D3(x,_,k,D);else aX(x,_,k)}}if(!w)return V.length?Promise.all(V).then(()=>_):_;let E=[],R=H.keySet,P=w._zod,M=P.def.type;for(let N of Object.keys(D)){if(R.has(N))continue;if(M==="never"){E.push(N);continue}let k=P.run({value:D[N],issues:[]},F);if(k instanceof Promise)V.push(k.then((y)=>aX(y,_,N)));else aX(k,_,N)}if(E.length)_.issues.push({code:"unrecognized_keys",keys:E,input:D,inst:$});if(!V.length)return _;return Promise.all(V).then(()=>{return _})}});function O3($,T,W,X){for(let Y of $)if(Y.issues.length===0)return T.value=Y.value,T;return T.issues.push({code:"invalid_union",input:T.value,inst:W,errors:$.map((Y)=>Y.issues.map((U)=>i4(U,X,n$())))}),T}var T8=K("$ZodUnion",($,T)=>{T$.init($,T),M$($._zod,"values",()=>{if(T.options.every((W)=>W._zod.values))return new Set(T.options.flatMap((W)=>Array.from(W._zod.values)));return}),M$($._zod,"pattern",()=>{if(T.options.every((W)=>W._zod.pattern)){let W=T.options.map((X)=>X._zod.pattern);return new RegExp(`^(${W.map((X)=>zW(X.source)).join("|")})$`)}return}),$._zod.parse=(W,X)=>{let Y=!1,U=[];for(let G of T.options){let J=G._zod.run({value:W.value,issues:[]},X);if(J instanceof Promise)U.push(J),Y=!0;else{if(J.issues.length===0)return J;U.push(J)}}if(!Y)return O3(U,W,$,X);return Promise.all(U).then((G)=>{return O3(G,W,$,X)})}});function I3($,T,W){let X=!0,Y=$?.[T];if(W.values.size&&!W.values.has(Y))X=!1;if(W.maps.length>0){for(let U of W.maps)if(!dM(Y,U))X=!1}return X}function dM($,T){let W=!0;for(let[X,Y]of T)if(!I3($,X,Y))W=!1;return W}var cJ=K("$ZodDiscriminatedUnion",($,T)=>{T8.init($,T);let W=$._zod.parse;M$($._zod,"disc",()=>{let Y=new Map;for(let U of T.options){let G=U._zod.disc;if(!G)throw new Error(`Invalid discriminated union option at index "${T.options.indexOf(U)}"`);for(let[J,z]of G){if(!Y.has(J))Y.set(J,{values:new Set,maps:[]});let w=Y.get(J);for(let H of z.values)w.values.add(H);for(let H of z.maps)w.maps.push(H)}}return Y});let X=wW(()=>{let Y=new Map;for(let U of T.options){let G=U._zod.disc?.get(T.discriminator);if(!G)throw new Error("Invalid discriminated union option");Y.set(U,G)}return Y});$._zod.parse=(Y,U)=>{let G=Y.value;if(!hX(G))return Y.issues.push({code:"invalid_type",expected:"object",input:G,inst:$}),Y;let J=[],z=X.value;for(let w of T.options){let H=z.get(w);if(I3(G,T.discriminator,H))J.push(w)}if(J.length===1)return J[0]._zod.run(Y,U);if(T.unionFallback)return W(Y,U);return Y.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:G,path:[T.discriminator],inst:$}),Y}}),uJ=K("$ZodIntersection",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let{value:Y}=W,U=T.left._zod.run({value:Y,issues:[]},X),G=T.right._zod.run({value:Y,issues:[]},X);if(U instanceof Promise||G instanceof Promise)return Promise.all([U,G]).then(([z,w])=>{return V3(W,z,w)});return V3(W,U,G)}});function UJ($,T){if($===T)return{valid:!0,data:$};if($ instanceof Date&&T instanceof Date&&+$===+T)return{valid:!0,data:$};if(_W($)&&_W(T)){let W=Object.keys(T),X=Object.keys($).filter((U)=>W.indexOf(U)!==-1),Y={...$,...T};for(let U of X){let G=UJ($[U],T[U]);if(!G.valid)return{valid:!1,mergeErrorPath:[U,...G.mergeErrorPath]};Y[U]=G.data}return{valid:!0,data:Y}}if(Array.isArray($)&&Array.isArray(T)){if($.length!==T.length)return{valid:!1,mergeErrorPath:[]};let W=[];for(let X=0;X<$.length;X++){let Y=$[X],U=T[X],G=UJ(Y,U);if(!G.valid)return{valid:!1,mergeErrorPath:[X,...G.mergeErrorPath]};W.push(G.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(n1($))return $;let X=UJ(T.value,W.value);if(!X.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(X.mergeErrorPath)}`);return $.value=X.data,$}var s1=K("$ZodTuple",($,T)=>{T$.init($,T);let W=T.items,X=W.length-[...W].reverse().findIndex((Y)=>Y._zod.optin!=="optional");$._zod.parse=(Y,U)=>{let G=Y.value;if(!Array.isArray(G))return Y.issues.push({input:G,inst:$,expected:"tuple",code:"invalid_type"}),Y;Y.value=[];let J=[];if(!T.rest){let w=G.length>W.length,H=G.length<X-1;if(w||H)return Y.issues.push({input:G,inst:$,origin:"array",...w?{code:"too_big",maximum:W.length}:{code:"too_small",minimum:W.length}}),Y}let z=-1;for(let w of W){if(z++,z>=G.length){if(z>=X)continue}let H=w._zod.run({value:G[z],issues:[]},U);if(H instanceof Promise)J.push(H.then((_)=>sX(_,Y,z)));else sX(H,Y,z)}if(T.rest){let w=G.slice(W.length);for(let H of w){z++;let _=T.rest._zod.run({value:H,issues:[]},U);if(_ instanceof Promise)J.push(_.then((F)=>sX(F,Y,z)));else sX(_,Y,z)}}if(J.length)return Promise.all(J).then(()=>Y);return Y}});function sX($,T,W){if($.issues.length)T.issues.push(...x4(W,$.issues));T.value[W]=$.value}var pJ=K("$ZodRecord",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let Y=W.value;if(!_W(Y))return W.issues.push({expected:"record",code:"invalid_type",input:Y,inst:$}),W;let U=[];if(T.keyType._zod.values){let G=T.keyType._zod.values;W.value={};for(let z of G)if(typeof z==="string"||typeof z==="number"||typeof z==="symbol"){let w=T.valueType._zod.run({value:Y[z],issues:[]},X);if(w instanceof Promise)U.push(w.then((H)=>{if(H.issues.length)W.issues.push(...x4(z,H.issues));W.value[z]=H.value}));else{if(w.issues.length)W.issues.push(...x4(z,w.issues));W.value[z]=w.value}}let J;for(let z in Y)if(!G.has(z))J=J??[],J.push(z);if(J&&J.length>0)W.issues.push({code:"unrecognized_keys",input:Y,inst:$,keys:J})}else{W.value={};for(let G of Reflect.ownKeys(Y)){if(G==="__proto__")continue;let J=T.keyType._zod.run({value:G,issues:[]},X);if(J instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(J.issues.length){W.issues.push({origin:"record",code:"invalid_key",issues:J.issues.map((w)=>i4(w,X,n$())),input:G,path:[G],inst:$}),W.value[J.value]=J.value;continue}let z=T.valueType._zod.run({value:Y[G],issues:[]},X);if(z instanceof Promise)U.push(z.then((w)=>{if(w.issues.length)W.issues.push(...x4(G,w.issues));W.value[J.value]=w.value}));else{if(z.issues.length)W.issues.push(...x4(G,z.issues));W.value[J.value]=z.value}}}if(U.length)return Promise.all(U).then(()=>W);return W}}),oJ=K("$ZodMap",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let Y=W.value;if(!(Y instanceof Map))return W.issues.push({expected:"map",code:"invalid_type",input:Y,inst:$}),W;let U=[];W.value=new Map;for(let[G,J]of Y){let z=T.keyType._zod.run({value:G,issues:[]},X),w=T.valueType._zod.run({value:J,issues:[]},X);if(z instanceof Promise||w instanceof Promise)U.push(Promise.all([z,w]).then(([H,_])=>{K3(H,_,W,G,Y,$,X)}));else K3(z,w,W,G,Y,$,X)}if(U.length)return Promise.all(U).then(()=>W);return W}});function K3($,T,W,X,Y,U,G){if($.issues.length)if(HW.has(typeof X))W.issues.push(...x4(X,$.issues));else W.issues.push({origin:"map",code:"invalid_key",input:Y,inst:U,issues:$.issues.map((J)=>i4(J,G,n$()))});if(T.issues.length)if(HW.has(typeof X))W.issues.push(...x4(X,T.issues));else W.issues.push({origin:"map",code:"invalid_element",input:Y,inst:U,key:X,issues:T.issues.map((J)=>i4(J,G,n$()))});W.value.set($.value,T.value)}var dJ=K("$ZodSet",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let Y=W.value;if(!(Y instanceof Set))return W.issues.push({input:Y,inst:$,expected:"set",code:"invalid_type"}),W;let U=[];W.value=new Set;for(let G of Y){let J=T.valueType._zod.run({value:G,issues:[]},X);if(J instanceof Promise)U.push(J.then((z)=>E3(z,W)));else E3(J,W)}if(U.length)return Promise.all(U).then(()=>W);return W}});function E3($,T){if($.issues.length)T.issues.push(...$.issues);T.value.add($.value)}var lJ=K("$ZodEnum",($,T)=>{T$.init($,T);let W=Object.values(T.entries).filter((Y)=>typeof Y==="number"),X=Object.entries(T.entries).filter(([Y,U])=>W.indexOf(+Y)===-1).map(([Y,U])=>U);$._zod.values=new Set(X),$._zod.pattern=new RegExp(`^(${X.filter((Y)=>HW.has(typeof Y)).map((Y)=>typeof Y==="string"?C6(Y):Y.toString()).join("|")})$`),$._zod.parse=(Y,U)=>{let G=Y.value;if($._zod.values.has(G))return Y;return Y.issues.push({code:"invalid_value",values:X,input:G,inst:$}),Y}}),rJ=K("$ZodLiteral",($,T)=>{T$.init($,T),$._zod.values=new Set(T.values),$._zod.pattern=new RegExp(`^(${T.values.map((W)=>typeof W==="string"?C6(W):W?W.toString():String(W)).join("|")})$`),$._zod.parse=(W,X)=>{let Y=W.value;if($._zod.values.has(Y))return W;return W.issues.push({code:"invalid_value",values:T.values,input:Y,inst:$}),W}}),iJ=K("$ZodFile",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let Y=W.value;if(Y instanceof File)return W;return W.issues.push({expected:"file",code:"invalid_type",input:Y,inst:$}),W}}),nJ=K("$ZodTransform",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let Y=T.transform(W.value,W);if(X.async)return(Y instanceof Promise?Y:Promise.resolve(Y)).then((G)=>{return W.value=G,W});if(Y instanceof Promise)throw new u6;return W.value=Y,W}}),tJ=K("$ZodOptional",($,T)=>{T$.init($,T),$._zod.optin="optional",$._zod.optout="optional",M$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,void 0]):void 0}),M$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${zW(W.source)})?$`):void 0}),$._zod.parse=(W,X)=>{if(W.value===void 0)return W;return T.innerType._zod.run(W,X)}}),aJ=K("$ZodNullable",($,T)=>{T$.init($,T),M$($._zod,"optin",()=>T.innerType._zod.optin),M$($._zod,"optout",()=>T.innerType._zod.optout),M$($._zod,"pattern",()=>{let W=T.innerType._zod.pattern;return W?new RegExp(`^(${zW(W.source)}|null)$`):void 0}),M$($._zod,"values",()=>{return T.innerType._zod.values?new Set([...T.innerType._zod.values,null]):void 0}),$._zod.parse=(W,X)=>{if(W.value===null)return W;return T.innerType._zod.run(W,X)}}),sJ=K("$ZodDefault",($,T)=>{T$.init($,T),$._zod.optin="optional",M$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,X)=>{if(W.value===void 0)return W.value=T.defaultValue,W;let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>A3(U,T));return A3(Y,T)}});function A3($,T){if($.value===void 0)$.value=T.defaultValue;return $}var eJ=K("$ZodPrefault",($,T)=>{T$.init($,T),$._zod.optin="optional",M$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,X)=>{if(W.value===void 0)W.value=T.defaultValue;return T.innerType._zod.run(W,X)}}),$9=K("$ZodNonOptional",($,T)=>{T$.init($,T),M$($._zod,"values",()=>{let W=T.innerType._zod.values;return W?new Set([...W].filter((X)=>X!==void 0)):void 0}),$._zod.parse=(W,X)=>{let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>M3(U,$));return M3(Y,$)}});function M3($,T){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:T});return $}var T9=K("$ZodSuccess",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>{return W.value=U.issues.length===0,W});return W.value=Y.issues.length===0,W}}),W9=K("$ZodCatch",($,T)=>{T$.init($,T),M$($._zod,"optin",()=>T.innerType._zod.optin),M$($._zod,"optout",()=>T.innerType._zod.optout),M$($._zod,"values",()=>T.innerType._zod.values),$._zod.parse=(W,X)=>{let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>{if(W.value=U.value,U.issues.length)W.value=T.catchValue({...W,error:{issues:U.issues.map((G)=>i4(G,X,n$()))},input:W.value}),W.issues=[];return W});if(W.value=Y.value,Y.issues.length)W.value=T.catchValue({...W,error:{issues:Y.issues.map((U)=>i4(U,X,n$()))},input:W.value}),W.issues=[];return W}}),X9=K("$ZodNaN",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{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}}),MW=K("$ZodPipe",($,T)=>{T$.init($,T),M$($._zod,"values",()=>T.in._zod.values),M$($._zod,"optin",()=>T.in._zod.optin),M$($._zod,"optout",()=>T.out._zod.optout),$._zod.parse=(W,X)=>{let Y=T.in._zod.run(W,X);if(Y instanceof Promise)return Y.then((U)=>N3(U,T,X));return N3(Y,T,X)}});function N3($,T,W){if(n1($))return $;return T.out._zod.run({value:$.value,issues:$.issues},W)}var Y9=K("$ZodReadonly",($,T)=>{T$.init($,T),M$($._zod,"disc",()=>T.innerType._zod.disc),M$($._zod,"optin",()=>T.innerType._zod.optin),M$($._zod,"optout",()=>T.innerType._zod.optout),$._zod.parse=(W,X)=>{let Y=T.innerType._zod.run(W,X);if(Y instanceof Promise)return Y.then(L3);return L3(Y)}});function L3($){return $.value=Object.freeze($.value),$}var U9=K("$ZodTemplateLiteral",($,T)=>{T$.init($,T);let W=[];for(let X of T.parts)if(X instanceof T$){if(!X._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...X._zod.traits].shift()}`);let Y=X._zod.pattern instanceof RegExp?X._zod.pattern.source:X._zod.pattern;if(!Y)throw new Error(`Invalid template literal part: ${X._zod.traits}`);let U=Y.startsWith("^")?1:0,G=Y.endsWith("$")?Y.length-1:Y.length;W.push(Y.slice(U,G))}else if(X===null||UG.has(typeof X))W.push(C6(`${X}`));else throw new Error(`Invalid template literal part: ${X}`);$._zod.pattern=new RegExp(`^${W.join("")}$`),$._zod.parse=(X,Y)=>{if(typeof X.value!=="string")return X.issues.push({input:X.value,inst:$,expected:"template_literal",code:"invalid_type"}),X;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(X.value))return X.issues.push({input:X.value,inst:$,code:"invalid_format",format:"template_literal",pattern:$._zod.pattern.source}),X;return X}}),G9=K("$ZodPromise",($,T)=>{T$.init($,T),$._zod.parse=(W,X)=>{return Promise.resolve(W.value).then((Y)=>T.innerType._zod.run({value:Y,issues:[]},X))}}),J9=K("$ZodLazy",($,T)=>{T$.init($,T),M$($._zod,"innerType",()=>T.getter()),M$($._zod,"pattern",()=>$._zod.innerType._zod.pattern),M$($._zod,"disc",()=>$._zod.innerType._zod.disc),M$($._zod,"optin",()=>$._zod.innerType._zod.optin),M$($._zod,"optout",()=>$._zod.innerType._zod.optout),$._zod.parse=(W,X)=>{return $._zod.innerType._zod.run(W,X)}}),w9=K("$ZodCustom",($,T)=>{u$.init($,T),T$.init($,T),$._zod.parse=(W,X)=>{return W},$._zod.check=(W)=>{let X=W.value,Y=T.fn(X);if(Y instanceof Promise)return Y.then((U)=>S3(U,W,X,$));S3(Y,W,X,$);return}});function S3($,T,W,X){if(!$){let Y={code:"custom",input:W,inst:X,path:[...X._zod.def.path??[]],continue:!X._zod.def.abort};if(X._zod.def.params)Y.params=X._zod.def.params;T.issues.push(zG(Y))}}var LW={};K1(LW,{zhTW:()=>c9,zhCN:()=>m9,vi:()=>g9,ur:()=>h9,ua:()=>y9,tr:()=>f9,th:()=>b9,ta:()=>x9,sl:()=>j9,ru:()=>v9,pt:()=>C9,pl:()=>P9,ota:()=>q9,no:()=>k9,ms:()=>I9,mk:()=>R9,ko:()=>B9,ja:()=>S9,it:()=>L9,id:()=>N9,hu:()=>M9,he:()=>A9,frCA:()=>E9,fr:()=>K9,fi:()=>V9,fa:()=>O9,es:()=>D9,en:()=>NW,de:()=>Z9,cs:()=>Q9,ca:()=>F9,be:()=>H9,az:()=>_9,ar:()=>z9});var lM={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 q3($){return lM[$]??null}var rM=($)=>{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},iM={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"},nM=($)=>{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 ${rM($.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 ${u($.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: ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=q3($.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=q3($.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`${iM[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":""}: ${q($.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 z9(){return{localeError:nM}}var tM={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 P3($){return tM[$]??null}var aM=($)=>{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},sM={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"},eM=($)=>{switch($.code){case"invalid_type":return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${$.expected}, daxil olan ${aM($.input)}`;case"invalid_value":if($.values.length===1)return`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${u($.values[0])}`;return`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=P3($.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=P3($.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 ${sM[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":""}: ${q($.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 _9(){return{localeError:eM}}function C3($,T,W,X){let Y=Math.abs($),U=Y%10,G=Y%100;if(G>=11&&G<=19)return X;if(U===1)return T;if(U>=2&&U<=4)return W;return X}var $N={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 v3($){return $N[$]??null}var TN=($)=>{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},WN={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"},XN=($)=>{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 ${TN($.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 ${u($.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 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=v3($.origin);if(W){let X=Number($.maximum),Y=C3(X,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()} ${Y}`}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=v3($.origin);if(W){let X=Number($.minimum),Y=C3(X,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()} ${Y}`}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 ${WN[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"}: ${q($.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 H9(){return{localeError:XN}}var YN={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function j3($){return YN[$]??null}var UN=($)=>{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},GN={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"},JN=($)=>{switch($.code){case"invalid_type":return`Tipus inv\xE0lid: s'esperava ${$.expected}, s'ha rebut ${UN($.input)}`;case"invalid_value":if($.values.length===1)return`Valor inv\xE0lid: s'esperava ${u($.values[0])}`;return`Opci\xF3 inv\xE0lida: s'esperava una de ${q($.values," o ")}`;case"too_big":{let T=$.inclusive?"com a m\xE0xim":"menys de",W=j3($.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=j3($.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 ${GN[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":""}: ${q($.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 F9(){return{localeError:JN}}var wN={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 x3($){return wN[$]??null}var zN=($)=>{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},_N={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"},HN=($)=>{switch($.code){case"invalid_type":return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${$.expected}, obdr\u017Eeno ${zN($.input)}`;case"invalid_value":if($.values.length===1)return`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${u($.values[0])}`;return`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=x3($.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=x3($.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 ${_N[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: ${q($.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 Q9(){return{localeError:HN}}var FN={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 b3($){return FN[$]??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},ZN={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"},DN=($)=>{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 ${u($.values[0])}`;return`Ung\xFCltige Option: erwartet eine von ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=b3($.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=b3($.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: ${ZN[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"}: ${q($.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 Z9(){return{localeError:DN}}var ON={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 f3($){return ON[$]??null}var VN=($)=>{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},KN={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"},EN=($)=>{switch($.code){case"invalid_type":return`Invalid input: expected ${$.expected}, received ${VN($.input)}`;case"invalid_value":if($.values.length===1)return`Invalid input: expected ${u($.values[0])}`;return`Invalid option: expected one of ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=f3($.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=f3($.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 ${KN[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":""}: ${q($.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 NW(){return{localeError:EN}}var AN={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function y3($){return AN[$]??null}var MN=($)=>{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},NN={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"},LN=($)=>{switch($.code){case"invalid_type":return`Entrada inv\xE1lida: se esperaba ${$.expected}, recibido ${MN($.input)}`;case"invalid_value":if($.values.length===1)return`Entrada inv\xE1lida: se esperaba ${u($.values[0])}`;return`Opci\xF3n inv\xE1lida: se esperaba una de ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=y3($.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=y3($.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 ${NN[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":""}: ${q($.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 D9(){return{localeError:LN}}var SN={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 h3($){return SN[$]??null}var BN=($)=>{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},RN={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"},IN=($)=>{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 ${BN($.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 ${u($.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 ${q($.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let T=$.inclusive?"<=":"<",W=h3($.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=h3($.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`${RN[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: ${q($.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 O9(){return{localeError:IN}}var kN={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 g3($){return kN[$]??null}var qN=($)=>{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},PN={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"},CN=($)=>{switch($.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${$.expected}, oli ${qN($.input)}`;case"invalid_value":if($.values.length===1)return`Virheellinen sy\xF6te: t\xE4ytyy olla ${u($.values[0])}`;return`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=g3($.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=g3($.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 ${PN[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"}: ${q($.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 V9(){return{localeError:CN}}var vN={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function m3($){return vN[$]??null}var jN=($)=>{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},xN={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"},bN=($)=>{switch($.code){case"invalid_type":return`Entr\xE9e invalide : ${$.expected} attendu, ${jN($.input)} re\xE7u`;case"invalid_value":if($.values.length===1)return`Entr\xE9e invalide : ${u($.values[0])} attendu`;return`Option invalide : une valeur parmi ${q($.values,"|")} attendue`;case"too_big":{let T=$.inclusive?"<=":"<",W=m3($.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=m3($.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`${xN[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":""} : ${q($.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 K9(){return{localeError:bN}}var fN={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function c3($){return fN[$]??null}var yN=($)=>{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:"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"},gN=($)=>{switch($.code){case"invalid_type":return`Entr\xE9e invalide : attendu ${$.expected}, re\xE7u ${yN($.input)}`;case"invalid_value":if($.values.length===1)return`Entr\xE9e invalide : attendu ${u($.values[0])}`;return`Option invalide : attendu l'une des valeurs suivantes ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"\u2264":"<",W=c3($.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=c3($.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`${hN[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":""} : ${q($.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 E9(){return{localeError:gN}}var mN={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 u3($){return mN[$]??null}var cN=($)=>{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},uN={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"},pN=($)=>{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 ${cN($.input)}`;case"invalid_value":if($.values.length===1)return`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA ${u($.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 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=u3($.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=u3($.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`${uN[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"}: ${q($.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 A9(){return{localeError:pN}}var oN={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function p3($){return oN[$]??null}var dN=($)=>{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},lN={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"},rN=($)=>{switch($.code){case"invalid_type":return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${$.expected}, a kapott \xE9rt\xE9k ${dN($.input)}`;case"invalid_value":if($.values.length===1)return`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${u($.values[0])}`;return`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=p3($.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=p3($.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 ${lN[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":""}: ${q($.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 M9(){return{localeError:rN}}var iN={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function o3($){return iN[$]??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},tN={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"},aN=($)=>{switch($.code){case"invalid_type":return`Input tidak valid: diharapkan ${$.expected}, diterima ${nN($.input)}`;case"invalid_value":if($.values.length===1)return`Input tidak valid: diharapkan ${u($.values[0])}`;return`Pilihan tidak valid: diharapkan salah satu dari ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=o3($.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=o3($.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`${tN[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":""}: ${q($.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 N9(){return{localeError:aN}}var sN={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function d3($){return sN[$]??null}var eN=($)=>{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},$L={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"},TL=($)=>{switch($.code){case"invalid_type":return`Input non valido: atteso ${$.expected}, ricevuto ${eN($.input)}`;case"invalid_value":if($.values.length===1)return`Input non valido: atteso ${u($.values[0])}`;return`Opzione non valida: atteso uno tra ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=d3($.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=d3($.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 ${$L[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"}: ${q($.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 L9(){return{localeError:TL}}var WL={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 l3($){return WL[$]??null}var XL=($)=>{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},YL={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"},UL=($)=>{switch($.code){case"invalid_type":return`\u7121\u52B9\u306A\u5165\u529B: ${$.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${XL($.input)}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`;case"invalid_value":if($.values.length===1)return`\u7121\u52B9\u306A\u5165\u529B: ${u($.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`;return`\u7121\u52B9\u306A\u9078\u629E: ${q($.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let T=$.inclusive?"<=":"<",W=l3($.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=l3($.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${YL[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":""}: ${q($.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 S9(){return{localeError:UL}}var GL={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 r3($){return GL[$]??null}var JL=($)=>{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},wL={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"},zL=($)=>{switch($.code){case"invalid_type":return`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${$.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${JL($.input)}\uC785\uB2C8\uB2E4`;case"invalid_value":if($.values.length===1)return`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${u($.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`;return`\uC798\uBABB\uB41C \uC635\uC158: ${q($.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",X=r3($.origin),Y=X?.unit??"\uC694\uC18C";if(X)return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${$.maximum.toString()}${Y} ${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",X=r3($.origin),Y=X?.unit??"\uC694\uC18C";if(X)return`${$.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${$.minimum.toString()}${Y} ${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 ${wL[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: ${q($.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 B9(){return{localeError:zL}}var _L={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 i3($){return _L[$]??null}var HL=($)=>{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},FL={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"},QL=($)=>{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 ${HL($.input)}`;case"invalid_value":if($.values.length===1)return`Invalid input: expected ${u($.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 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=i3($.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=i3($.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 ${FL[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"}: ${q($.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 R9(){return{localeError:QL}}var ZL={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function n3($){return ZL[$]??null}var DL=($)=>{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},OL={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"},VL=($)=>{switch($.code){case"invalid_type":return`Input tidak sah: dijangka ${$.expected}, diterima ${DL($.input)}`;case"invalid_value":if($.values.length===1)return`Input tidak sah: dijangka ${u($.values[0])}`;return`Pilihan tidak sah: dijangka salah satu daripada ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=n3($.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=n3($.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`${OL[T.format]??$.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${$.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${q($.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 I9(){return{localeError:VL}}var KL={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 t3($){return KL[$]??null}var EL=($)=>{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},AL={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"},ML=($)=>{switch($.code){case"invalid_type":return`Ugyldig input: forventet ${$.expected}, fikk ${EL($.input)}`;case"invalid_value":if($.values.length===1)return`Ugyldig verdi: forventet ${u($.values[0])}`;return`Ugyldig valg: forventet en av ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=t3($.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=t3($.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 ${AL[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"}: ${q($.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 k9(){return{localeError:ML}}var NL={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 a3($){return NL[$]??null}var LL=($)=>{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},SL={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"},BL=($)=>{switch($.code){case"invalid_type":return`F\xE2sit giren: umulan ${$.expected}, al\u0131nan ${LL($.input)}`;case"invalid_value":if($.values.length===1)return`F\xE2sit giren: umulan ${u($.values[0])}`;return`F\xE2sit tercih: m\xFBteberler ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=a3($.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=a3($.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 ${SL[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":""}: ${q($.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 q9(){return{localeError:BL}}var RL={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 s3($){return RL[$]??null}var IL=($)=>{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},kL={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"},qL=($)=>{switch($.code){case"invalid_type":return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${$.expected}, otrzymano ${IL($.input)}`;case"invalid_value":if($.values.length===1)return`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${u($.values[0])}`;return`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=s3($.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=s3($.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) ${kL[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":""}: ${q($.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 P9(){return{localeError:qL}}var PL={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function e3($){return PL[$]??null}var CL=($)=>{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},vL={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"},jL=($)=>{switch($.code){case"invalid_type":return`Tipo inv\xE1lido: esperado ${$.expected}, recebido ${CL($.input)}`;case"invalid_value":if($.values.length===1)return`Entrada inv\xE1lida: esperado ${u($.values[0])}`;return`Op\xE7\xE3o inv\xE1lida: esperada uma das ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=e3($.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=e3($.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`${vL[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":""}: ${q($.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 C9(){return{localeError:jL}}function $H($,T,W,X){let Y=Math.abs($),U=Y%10,G=Y%100;if(G>=11&&G<=19)return X;if(U===1)return T;if(U>=2&&U<=4)return W;return X}var xL={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 TH($){return xL[$]??null}var bL=($)=>{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},fL={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"},yL=($)=>{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 ${bL($.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 ${u($.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 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=TH($.origin);if(W){let X=Number($.maximum),Y=$H(X,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()} ${Y}`}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=TH($.origin);if(W){let X=Number($.minimum),Y=$H(X,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()} ${Y}`}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 ${fL[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":""}: ${q($.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 v9(){return{localeError:yL}}var hL={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function WH($){return hL[$]??null}var gL=($)=>{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},mL={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"},cL=($)=>{switch($.code){case"invalid_type":return`Neveljaven vnos: pri\u010Dakovano ${$.expected}, prejeto ${gL($.input)}`;case"invalid_value":if($.values.length===1)return`Neveljaven vnos: pri\u010Dakovano ${u($.values[0])}`;return`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=WH($.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=WH($.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 ${mL[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"}: ${q($.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 j9(){return{localeError:cL}}var uL={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 XH($){return uL[$]??null}var pL=($)=>{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},oL={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"},dL=($)=>{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 ${pL($.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 ${u($.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 ${q($.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let T=$.inclusive?"<=":"<",W=XH($.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=XH($.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 ${oL[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":""}: ${q($.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 x9(){return{localeError:dL}}var lL={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 YH($){return lL[$]??null}var rL=($)=>{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},iL={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"},nL=($)=>{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 ${rL($.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 ${u($.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 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",W=YH($.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=YH($.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: ${iL[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: ${q($.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 b9(){return{localeError:nL}}var tL={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 UH($){return tL[$]??null}var aL=($)=>{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},sL={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"},eL=($)=>{switch($.code){case"invalid_type":return`Ge\xE7ersiz de\u011Fer: beklenen ${$.expected}, al\u0131nan ${aL($.input)}`;case"invalid_value":if($.values.length===1)return`Ge\xE7ersiz de\u011Fer: beklenen ${u($.values[0])}`;return`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=UH($.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=UH($.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 ${sL[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":""}: ${q($.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 f9(){return{localeError:eL}}var $S={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 GH($){return $S[$]??null}var TS=($)=>{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},WS={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"},XS=($)=>{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 ${TS($.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 ${u($.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 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=GH($.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=GH($.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 ${WS[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":""}: ${q($.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 y9(){return{localeError:XS}}var YS={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 JH($){return YS[$]??null}var US=($)=>{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},GS={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"},JS=($)=>{switch($.code){case"invalid_type":return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${$.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${US($.input)} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`;case"invalid_value":if($.values.length===1)return`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${u($.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;return`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${q($.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let T=$.inclusive?"<=":"<",W=JH($.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=JH($.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 ${GS[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":""}: ${q($.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 h9(){return{localeError:JS}}var wS={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 wH($){return wS[$]??null}var zS=($)=>{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},_S={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"},HS=($)=>{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 ${zS($.input)}`;case"invalid_value":if($.values.length===1)return`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${u($.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 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=wH($.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=wH($.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`${_S[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: ${q($.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 g9(){return{localeError:HS}}var FS={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 zH($){return FS[$]??null}var QS=($)=>{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},ZS={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"},DS=($)=>{switch($.code){case"invalid_type":return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${$.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${QS($.input)}`;case"invalid_value":if($.values.length===1)return`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${u($.values[0])}`;return`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=zH($.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=zH($.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${ZS[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): ${q($.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 m9(){return{localeError:DS}}var OS={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 _H($){return OS[$]??null}var VS=($)=>{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},KS={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"},ES=($)=>{switch($.code){case"invalid_type":return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${$.expected}\uFF0C\u4F46\u6536\u5230 ${VS($.input)}`;case"invalid_value":if($.values.length===1)return`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${u($.values[0])}`;return`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${q($.values,"|")}`;case"too_big":{let T=$.inclusive?"<=":"<",W=_H($.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=_H($.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 ${KS[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${q($.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 c9(){return{localeError:ES}}var u9=Symbol("ZodOutput"),p9=Symbol("ZodInput");class SW{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 W8(){return new SW}var v6=W8();function o9($,T){return new $({type:"string",...j(T)})}function d9($,T){return new $({type:"string",coerce:!0,...j(T)})}function X8($,T){return new $({type:"string",format:"email",check:"string_format",abort:!1,...j(T)})}function BW($,T){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...j(T)})}function Y8($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...j(T)})}function U8($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...j(T)})}function G8($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...j(T)})}function J8($,T){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...j(T)})}function w8($,T){return new $({type:"string",format:"url",check:"string_format",abort:!1,...j(T)})}function z8($,T){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...j(T)})}function _8($,T){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...j(T)})}function H8($,T){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...j(T)})}function F8($,T){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...j(T)})}function Q8($,T){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...j(T)})}function Z8($,T){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...j(T)})}function D8($,T){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...j(T)})}function O8($,T){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...j(T)})}function V8($,T){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...j(T)})}function K8($,T){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...j(T)})}function E8($,T){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...j(T)})}function A8($,T){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...j(T)})}function M8($,T){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...j(T)})}function N8($,T){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...j(T)})}function L8($,T){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...j(T)})}function l9($,T){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...j(T)})}function r9($,T){return new $({type:"string",format:"date",check:"string_format",...j(T)})}function i9($,T){return new $({type:"string",format:"time",check:"string_format",precision:null,...j(T)})}function n9($,T){return new $({type:"string",format:"duration",check:"string_format",...j(T)})}function t9($,T){return new $({type:"number",checks:[],...j(T)})}function a9($,T){return new $({type:"number",coerce:!0,checks:[],...j(T)})}function s9($,T){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...j(T)})}function e9($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...j(T)})}function $w($,T){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...j(T)})}function Tw($,T){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...j(T)})}function Ww($,T){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...j(T)})}function Xw($,T){return new $({type:"boolean",...j(T)})}function Yw($,T){return new $({type:"boolean",coerce:!0,...j(T)})}function Uw($,T){return new $({type:"bigint",...j(T)})}function Gw($,T){return new $({type:"bigint",coerce:!0,...j(T)})}function Jw($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...j(T)})}function ww($,T){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...j(T)})}function zw($,T){return new $({type:"symbol",...j(T)})}function _w($,T){return new $({type:"undefined",...j(T)})}function Hw($,T){return new $({type:"null",...j(T)})}function Fw($){return new $({type:"any"})}function Qw($){return new $({type:"unknown"})}function Zw($,T){return new $({type:"never",...j(T)})}function Dw($,T){return new $({type:"void",...j(T)})}function Ow($,T){return new $({type:"date",...j(T)})}function Vw($,T){return new $({type:"date",coerce:!0,...j(T)})}function Kw($,T){return new $({type:"nan",...j(T)})}function p6($,T){return new iX({check:"less_than",...j(T),value:$,inclusive:!1})}function Y6($,T){return new iX({check:"less_than",...j(T),value:$,inclusive:!0})}function o6($,T){return new nX({check:"greater_than",...j(T),value:$,inclusive:!1})}function b4($,T){return new nX({check:"greater_than",...j(T),value:$,inclusive:!0})}function Ew($){return o6(0,$)}function Aw($){return p6(0,$)}function Mw($){return Y6(0,$)}function Nw($){return b4(0,$)}function e1($,T){return new mG({check:"multiple_of",...j(T),value:$})}function d0($,T){return new pG({check:"max_size",...j(T),maximum:$})}function $0($,T){return new oG({check:"min_size",...j(T),minimum:$})}function RW($,T){return new dG({check:"size_equals",...j(T),size:$})}function l0($,T){return new lG({check:"max_length",...j(T),maximum:$})}function B1($,T){return new rG({check:"min_length",...j(T),minimum:$})}function r0($,T){return new iG({check:"length_equals",...j(T),length:$})}function IW($,T){return new nG({check:"string_format",format:"regex",...j(T),pattern:$})}function kW($){return new tG({check:"string_format",format:"lowercase",...j($)})}function qW($){return new aG({check:"string_format",format:"uppercase",...j($)})}function PW($,T){return new sG({check:"string_format",format:"includes",...j(T),includes:$})}function CW($,T){return new eG({check:"string_format",format:"starts_with",...j(T),prefix:$})}function vW($,T){return new $J({check:"string_format",format:"ends_with",...j(T),suffix:$})}function Lw($,T,W){return new TJ({check:"property",property:$,schema:T,...j(W)})}function jW($,T){return new WJ({check:"mime_type",mime:$,...j(T)})}function d6($){return new XJ({check:"overwrite",tx:$})}function xW($){return d6((T)=>T.normalize($))}function bW(){return d6(($)=>$.trim())}function fW(){return d6(($)=>$.toLowerCase())}function yW(){return d6(($)=>$.toUpperCase())}function Sw($,T,W){return new $({type:"array",element:T,...j(W)})}function AS($,T,W){return new $({type:"union",options:T,...j(W)})}function MS($,T,W,X){return new $({type:"union",options:W,discriminator:T,...j(X)})}function NS($,T,W){return new $({type:"intersection",left:T,right:W})}function Bw($,T,W,X){let Y=W instanceof T$;return new $({type:"tuple",items:T,rest:Y?W:null,...j(Y?X:W)})}function LS($,T,W,X){return new $({type:"record",keyType:T,valueType:W,...j(X)})}function SS($,T,W,X){return new $({type:"map",keyType:T,valueType:W,...j(X)})}function BS($,T,W){return new $({type:"set",valueType:T,...j(W)})}function RS($,T,W){let X=Array.isArray(T)?Object.fromEntries(T.map((Y)=>[Y,Y])):T;return new $({type:"enum",entries:X,...j(W)})}function IS($,T,W){return new $({type:"enum",entries:T,...j(W)})}function kS($,T,W){return new $({type:"literal",values:Array.isArray(T)?T:[T],...j(W)})}function Rw($,T){return new $({type:"file",...j(T)})}function qS($,T){return new $({type:"transform",transform:T})}function PS($,T){return new $({type:"optional",innerType:T})}function CS($,T){return new $({type:"nullable",innerType:T})}function vS($,T,W){return new $({type:"default",innerType:T,get defaultValue(){return typeof W==="function"?W():W}})}function jS($,T,W){return new $({type:"nonoptional",innerType:T,...j(W)})}function xS($,T){return new $({type:"success",innerType:T})}function bS($,T,W){return new $({type:"catch",innerType:T,catchValue:typeof W==="function"?W:()=>W})}function fS($,T,W){return new $({type:"pipe",in:T,out:W})}function yS($,T){return new $({type:"readonly",innerType:T})}function hS($,T,W){return new $({type:"template_literal",parts:T,...j(W)})}function gS($,T){return new $({type:"lazy",getter:T})}function mS($,T){return new $({type:"promise",innerType:T})}function hW($,T,W){return new $({type:"custom",check:"custom",fn:T,...j(W)})}function cS($,T,W={}){return hW($,T,W)}function Iw($,T){let W=j(T),X=new Set(W?.truthy??["true","1","yes","on","y","enabled"]),Y=new Set(W?.falsy??["false","0","no","off","n","disabled"]),U=$.Pipe??MW,G=$.Boolean??EW,z=new($.Unknown??AW)({type:"unknown",checks:[{_zod:{check:(w)=>{if(typeof w.value==="string"){let H=w.value;if(W?.case!=="sensitive")H=H.toLowerCase();if(X.has(H))w.value=!0;else if(Y.has(H))w.value=!1;else w.issues.push({code:"invalid_value",expected:"stringbool",values:[...X,...Y],input:w.value,inst:z})}else w.issues.push({code:"invalid_type",expected:"string",input:w.value})},def:{check:"custom"},onattach:[]}}]});return new U({type:"pipe",in:z,out:new G({type:"boolean"})})}class i0{constructor($){this._def=$}implement($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=(...W)=>{let X=this._def.input?mX(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(X))throw new Error("Invalid arguments schema: not an array or tuple schema.");let Y=$(...X);return this._def.output?mX(this._def.output,Y,void 0,{callee:T}):Y};return T}implementAsync($){if(typeof $!=="function")throw new Error("implement() must be called with a function");let T=async(...W)=>{let X=this._def.input?await uX(this._def.input,W,void 0,{callee:T}):W;if(!Array.isArray(X))throw new Error("Invalid arguments schema: not an array or tuple schema.");let Y=await $(...X);return this._def.output?uX(this._def.output,Y,void 0,{callee:T}):Y};return T}input(...$){if(Array.isArray($[0]))return new i0({type:"function",input:new s1({type:"tuple",items:$[0],rest:$[1]}),output:this._def.output});return new i0({type:"function",input:$[0],output:this._def.output})}output($){return new i0({type:"function",input:this._def.input,output:$})}}function kw($){return new i0({type:"function",input:Array.isArray($?.input)?Bw(s1,$?.input):$?.input??null,output:$?.output??null})}var uS={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string"};class S8{constructor($){this.counter=0,this.metadataRegistry=$?.metadata??v6,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 X=$._zod.def,Y=this.seen.get($);if(Y){if(Y.count++,T.schemaPath.includes($))Y.cycle=T.path;return Y.count++,Y.schema}let U={schema:{},count:1,cycle:void 0};if(this.seen.set($,U),$._zod.toJSONSchema)U.schema=$._zod.toJSONSchema();let G={...T,schemaPath:[...T.schemaPath,$],path:T.path},J=$._zod.parent;if(J)U.ref=J,this.process(J,G),this.seen.get(J).isParent=!0;else{let H=U.schema;switch(X.type){case"string":{let _=H;_.type="string";let{minimum:F,maximum:D,format:V,pattern:E,contentEncoding:R}=$._zod.bag;if(typeof F==="number")_.minLength=F;if(typeof D==="number")_.maxLength=D;if(V)_.format=uS[V]??V;if(E)_.pattern=E.source;if(R)_.contentEncoding=R;break}case"number":{let _=H,{minimum:F,maximum:D,format:V,multipleOf:E,exclusiveMaximum:R,exclusiveMinimum:P}=$._zod.bag;if(typeof V==="string"&&V.includes("int"))_.type="integer";else _.type="number";if(typeof P==="number")_.exclusiveMinimum=P;if(typeof F==="number"){if(_.minimum=F,typeof P==="number")if(P>=F)delete _.minimum;else delete _.exclusiveMinimum}if(typeof R==="number")_.exclusiveMaximum=R;if(typeof D==="number"){if(_.maximum=D,typeof R==="number")if(R<=D)delete _.maximum;else delete _.exclusiveMaximum}if(typeof E==="number")_.multipleOf=E;break}case"boolean":{let _=H;_.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 _=H;_.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 _=H,{minimum:F,maximum:D}=$._zod.bag;if(typeof F==="number")_.minItems=F;if(typeof D==="number")_.maxItems=D;_.type="array",_.items=this.process(X.element,{...G,path:[...G.path,"items"]});break}case"object":{let _=H;_.type="object",_.properties={};let F=X.shape;for(let E in F)_.properties[E]=this.process(F[E],{...G,path:[...G.path,"properties",E]});let D=new Set(Object.keys(F)),V=new Set([...D].filter((E)=>{let R=X.shape[E]._zod;if(this.io==="input")return R.optin===void 0;else return R.optout===void 0}));if(_.required=Array.from(V),X.catchall?._zod.def.type==="never")_.additionalProperties=!1;else if(X.catchall)_.additionalProperties=this.process(X.catchall,{...G,path:[...G.path,"additionalProperties"]});break}case"union":{let _=H;_.anyOf=X.options.map((F,D)=>this.process(F,{...G,path:[...G.path,"anyOf",D]}));break}case"intersection":{let _=H;_.allOf=[this.process(X.left,{...G,path:[...G.path,"allOf",0]}),this.process(X.right,{...G,path:[...G.path,"allOf",1]})];break}case"tuple":{let _=H;_.type="array";let F=X.items.map((E,R)=>this.process(E,{...G,path:[...G.path,"prefixItems",R]}));if(this.target==="draft-2020-12")_.prefixItems=F;else _.items=F;if(X.rest){let E=this.process(X.rest,{...G,path:[...G.path,"items"]});if(this.target==="draft-2020-12")_.items=E;else _.additionalItems=E}if(X.rest)_.items=this.process(X.rest,{...G,path:[...G.path,"items"]});let{minimum:D,maximum:V}=$._zod.bag;if(typeof D==="number")_.minItems=D;if(typeof V==="number")_.maxItems=V;break}case"record":{let _=H;_.type="object",_.propertyNames=this.process(X.keyType,{...G,path:[...G.path,"propertyNames"]}),_.additionalProperties=this.process(X.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 _=H;_.enum=Object.values(X.entries);break}case"literal":{let _=H,F=[];for(let D of X.values)if(D===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof D==="bigint")if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");else F.push(Number(D));else F.push(D);if(F.length===0);else if(F.length===1){let D=F[0];_.const=D}else _.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 _=this.process(X.innerType,G);H.anyOf=[_,{type:"null"}];break}case"nonoptional":{this.process(X.innerType,G),U.ref=X.innerType;break}case"success":{let _=H;_.type="boolean";break}case"default":{this.process(X.innerType,G),U.ref=X.innerType,H.default=X.defaultValue;break}case"prefault":{if(this.process(X.innerType,G),U.ref=X.innerType,this.io==="input")H._prefault=X.defaultValue;break}case"catch":{this.process(X.innerType,G),U.ref=X.innerType;let _;try{_=X.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}H.default=_;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let _=H,F=$._zod.pattern;if(!F)throw new Error("Pattern not found in template literal");_.type="string",_.pattern=F.source;break}case"pipe":{let _=this.io==="input"?X.in:X.out;this.process(_,G),U.ref=_;break}case"readonly":{this.process(X.innerType,G),U.ref=X.innerType,H.readOnly=!0;break}case"promise":{this.process(X.innerType,G),U.ref=X.innerType;break}case"optional":{this.process(X.innerType,G),U.ref=X.innerType;break}case"lazy":{let _=$._zod.innerType;this.process(_,G),U.ref=_;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(U.schema,z);if(this.io==="input"&&X.type==="pipe"){if(delete U.schema.examples,delete U.schema.default,U.schema._prefault)U.schema.default=U.schema._prefault}if(this.io==="input"&&U.schema._prefault)(W=U.schema).default??(W.default=U.schema._prefault);return delete U.schema._prefault,this.seen.get($).schema}emit($,T){let W={cycles:T?.cycles??"ref",reused:T?.reused??"inline",external:T?.external??void 0},X=this.seen.get($);if(!X)throw new Error("Unprocessed schema. This is a bug in Zod.");let Y=(w)=>{let H=this.target==="draft-2020-12"?"$defs":"definitions";if(W.external){let V=W.external.registry.get(w[0])?.id;if(V)return{ref:W.external.uri(V)};let E=w[1].defId??w[1].schema.id??`schema${this.counter++}`;return w[1].defId=E,{defId:E,ref:`${W.external.uri("__shared")}#/${H}/${E}`}}if(w[1]===X)return{ref:"#"};let F=`${"#"}/${H}/`,D=w[1].schema.id??`__schema${this.counter++}`;return{defId:D,ref:F+D}},U=(w)=>{if(w[1].schema.$ref)return;let H=w[1],{ref:_,defId:F}=Y(w);if(H.def={...H.schema},F)H.defId=F;let D=H.schema;for(let V in D)delete D[V],D.$ref=_};for(let w of this.seen.entries()){let H=w[1];if($===w[0]){U(w);continue}if(W.external){let F=W.external.registry.get(w[0])?.id;if($!==w[0]&&F){U(w);continue}}if(this.metadataRegistry.get(w[0])?.id){U(w);continue}if(H.cycle){if(W.cycles==="throw")throw new Error(`Cycle detected: #/${H.cycle?.join("/")}/<root>
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>
32
32
 
33
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);else if(W.cycles==="ref")U(w);continue}if(H.count>1){if(W.reused==="ref"){U(w);continue}}}let G=(w,H)=>{let _=this.seen.get(w),F=_.def??_.schema,D={...F};if(_.ref===null)return;let V=_.ref;if(_.ref=null,V){G(V,H);let E=this.seen.get(V).schema;if(E.$ref&&H.target==="draft-7")F.allOf=F.allOf??[],F.allOf.push(E);else Object.assign(F,E),Object.assign(F,D)}if(!_.isParent)this.override({zodSchema:w,jsonSchema:F})};for(let w of[...this.seen.entries()].reverse())G(w[0],{target:this.target});let J={...X.def},z=W.external?.defs??{};for(let w of this.seen.entries()){let H=w[1];if(H.def&&H.defId)z[H.defId]=H.def}if(!W.external&&Object.keys(z).length>0)if(this.target==="draft-2020-12")J.$defs=z;else J.definitions=z;if(this.target==="draft-2020-12")J.$schema="https://json-schema.org/draft-2020-12/schema";else if(this.target==="draft-7")J.$schema="https://json-schema.org/draft-07/schema";else console.warn(`Invalid target: ${this.target}`);try{return JSON.parse(JSON.stringify(J))}catch(w){throw new Error("Error converting schema to JSON.")}}}function qw($,T){if($ instanceof SW){let X=new S8(T),Y={};for(let J of $._idmap.entries()){let[z,w]=J;X.process(w)}let U={},G={registry:$,uri:T?.uri||((J)=>J),defs:Y};for(let J of $._idmap.entries()){let[z,w]=J;U[z]=X.emit(w,{...T,external:G})}if(Object.keys(Y).length>0){let J=X.target==="draft-2020-12"?"$defs":"definitions";U.__shared={[J]:Y}}return{schemas:U}}let W=new S8(T);return W.process($),W.emit($,T)}var HH={};var B8={};K1(B8,{time:()=>vw,duration:()=>jw,datetime:()=>Pw,date:()=>Cw,ZodISOTime:()=>ZH,ZodISODuration:()=>DH,ZodISODateTime:()=>FH,ZodISODate:()=>QH});var FH=K("ZodISODateTime",($,T)=>{VJ.init($,T),f$.init($,T)});function Pw($){return l9(FH,$)}var QH=K("ZodISODate",($,T)=>{KJ.init($,T),f$.init($,T)});function Cw($){return r9(QH,$)}var ZH=K("ZodISOTime",($,T)=>{EJ.init($,T),f$.init($,T)});function vw($){return i9(ZH,$)}var DH=K("ZodISODuration",($,T)=>{AJ.init($,T),f$.init($,T)});function jw($){return n9(DH,$)}var VH=($,T)=>{ZW.init($,T),$.name="ZodError",Object.defineProperties($,{format:{value:(W)=>OW($,W)},flatten:{value:(W)=>DW($,W)},addIssue:{value:(W)=>$.issues.push(W)},addIssues:{value:(W)=>$.issues.push(...W)},isEmpty:{get(){return $.issues.length===0}}})},oS=K("ZodError",VH),n0=K("ZodError",VH,{Parent:Error});var xw=gX(n0),bw=cX(n0),fw=pX(n0),yw=oX(n0);var hw={};K1(hw,{string:()=>lS,number:()=>rS,date:()=>tS,boolean:()=>iS,bigint:()=>nS});function lS($){return d9(R8,$)}function rS($){return a9(gW,$)}function iS($){return Yw(mW,$)}function nS($){return Gw(cW,$)}function tS($){return Vw(I8,$)}var w$=K("ZodType",($,T)=>{return T$.init($,T),$.def=T,$._def=T,$.check=(...W)=>{return $.clone({...T,checks:[...T.checks??[],...W.map((X)=>typeof X==="function"?{_zod:{check:X,def:{check:"custom"},onattach:[]}}:X)]})},$.clone=(W,X)=>r4($,W,X),$.brand=()=>$,$.register=(W,X)=>{return W.add($,X),$},$.parse=(W,X)=>xw($,W,X,{callee:$.parse}),$.safeParse=(W,X)=>fw($,W,X),$.parseAsync=async(W,X)=>bw($,W,X,{callee:$.parseAsync}),$.safeParseAsync=async(W,X)=>yw($,W,X),$.spa=$.safeParseAsync,$.refine=(W,X)=>$.check(XF(W,X)),$.superRefine=(W)=>$.check(YF(W)),$.overwrite=(W)=>$.check(d6(W)),$.optional=()=>P8($),$.nullable=()=>C8($),$.nullish=()=>P8(C8($)),$.nonoptional=(W)=>dH($,W),$.array=()=>Jz($),$.or=(W)=>b8([$,W]),$.and=(W)=>PH($,W),$.transform=(W)=>v8($,_z(W)),$.default=(W)=>uH($,W),$.prefault=(W)=>oH($,W),$.catch=(W)=>iH($,W),$.pipe=(W)=>v8($,W),$.readonly=()=>aH($),$.describe=(W)=>{let X=$.clone();return v6.add(X,{description:W}),X},Object.defineProperty($,"description",{get(){return v6.get($)?.description},configurable:!0}),$.meta=(...W)=>{if(W.length===0)return v6.get($);let X=$.clone();return v6.add(X,W[0]),X},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$}),cw=K("_ZodString",($,T)=>{KW.init($,T),w$.init($,T);let W=$._zod.bag;$.format=W.format??null,$.minLength=W.minimum??null,$.maxLength=W.maximum??null,$.regex=(...X)=>$.check(IW(...X)),$.includes=(...X)=>$.check(PW(...X)),$.startsWith=(X)=>$.check(CW(X)),$.endsWith=(X)=>$.check(vW(X)),$.min=(...X)=>$.check(B1(...X)),$.max=(...X)=>$.check(l0(...X)),$.length=(...X)=>$.check(r0(...X)),$.nonempty=(...X)=>$.check(B1(1,...X)),$.lowercase=(X)=>$.check(kW(X)),$.uppercase=(X)=>$.check(qW(X)),$.trim=()=>$.check(bW()),$.normalize=(...X)=>$.check(xW(...X)),$.toLowerCase=()=>$.check(fW()),$.toUpperCase=()=>$.check(yW())}),R8=K("ZodString",($,T)=>{KW.init($,T),cw.init($,T),$.email=(W)=>$.check(X8(uw,W)),$.url=(W)=>$.check(w8(pw,W)),$.jwt=(W)=>$.check(L8(Yz,W)),$.emoji=(W)=>$.check(z8(ow,W)),$.guid=(W)=>$.check(BW(k8,W)),$.uuid=(W)=>$.check(Y8(r6,W)),$.uuidv4=(W)=>$.check(U8(r6,W)),$.uuidv6=(W)=>$.check(G8(r6,W)),$.uuidv7=(W)=>$.check(J8(r6,W)),$.nanoid=(W)=>$.check(_8(dw,W)),$.guid=(W)=>$.check(BW(k8,W)),$.cuid=(W)=>$.check(H8(lw,W)),$.cuid2=(W)=>$.check(F8(rw,W)),$.ulid=(W)=>$.check(Q8(iw,W)),$.base64=(W)=>$.check(A8(Tz,W)),$.base64url=(W)=>$.check(M8(Wz,W)),$.xid=(W)=>$.check(Z8(nw,W)),$.ksuid=(W)=>$.check(D8(tw,W)),$.ipv4=(W)=>$.check(O8(aw,W)),$.ipv6=(W)=>$.check(V8(sw,W)),$.cidrv4=(W)=>$.check(K8(ew,W)),$.cidrv6=(W)=>$.check(E8($z,W)),$.e164=(W)=>$.check(N8(Xz,W)),$.datetime=(W)=>$.check(Pw(W)),$.date=(W)=>$.check(Cw(W)),$.time=(W)=>$.check(vw(W)),$.duration=(W)=>$.check(jw(W))});function gw($){return o9(R8,$)}var f$=K("ZodStringFormat",($,T)=>{q$.init($,T),cw.init($,T)}),uw=K("ZodEmail",($,T)=>{wJ.init($,T),f$.init($,T)});function aS($){return X8(uw,$)}var k8=K("ZodGUID",($,T)=>{GJ.init($,T),f$.init($,T)});function sS($){return BW(k8,$)}var r6=K("ZodUUID",($,T)=>{JJ.init($,T),f$.init($,T)});function eS($){return Y8(r6,$)}function $B($){return U8(r6,$)}function TB($){return G8(r6,$)}function WB($){return J8(r6,$)}var pw=K("ZodURL",($,T)=>{zJ.init($,T),f$.init($,T)});function XB($){return w8(pw,$)}var ow=K("ZodEmoji",($,T)=>{_J.init($,T),f$.init($,T)});function YB($){return z8(ow,$)}var dw=K("ZodNanoID",($,T)=>{HJ.init($,T),f$.init($,T)});function UB($){return _8(dw,$)}var lw=K("ZodCUID",($,T)=>{FJ.init($,T),f$.init($,T)});function GB($){return H8(lw,$)}var rw=K("ZodCUID2",($,T)=>{QJ.init($,T),f$.init($,T)});function JB($){return F8(rw,$)}var iw=K("ZodULID",($,T)=>{ZJ.init($,T),f$.init($,T)});function wB($){return Q8(iw,$)}var nw=K("ZodXID",($,T)=>{DJ.init($,T),f$.init($,T)});function zB($){return Z8(nw,$)}var tw=K("ZodKSUID",($,T)=>{OJ.init($,T),f$.init($,T)});function _B($){return D8(tw,$)}var aw=K("ZodIPv4",($,T)=>{MJ.init($,T),f$.init($,T)});function HB($){return O8(aw,$)}var sw=K("ZodIPv6",($,T)=>{NJ.init($,T),f$.init($,T)});function FB($){return V8(sw,$)}var ew=K("ZodCIDRv4",($,T)=>{LJ.init($,T),f$.init($,T)});function QB($){return K8(ew,$)}var $z=K("ZodCIDRv6",($,T)=>{SJ.init($,T),f$.init($,T)});function ZB($){return E8($z,$)}var Tz=K("ZodBase64",($,T)=>{RJ.init($,T),f$.init($,T)});function DB($){return A8(Tz,$)}var Wz=K("ZodBase64URL",($,T)=>{IJ.init($,T),f$.init($,T)});function OB($){return M8(Wz,$)}var Xz=K("ZodE164",($,T)=>{kJ.init($,T),f$.init($,T)});function VB($){return N8(Xz,$)}var Yz=K("ZodJWT",($,T)=>{qJ.init($,T),f$.init($,T)});function KB($){return L8(Yz,$)}var gW=K("ZodNumber",($,T)=>{eX.init($,T),w$.init($,T),$.gt=(X,Y)=>$.check(o6(X,Y)),$.gte=(X,Y)=>$.check(b4(X,Y)),$.min=(X,Y)=>$.check(b4(X,Y)),$.lt=(X,Y)=>$.check(p6(X,Y)),$.lte=(X,Y)=>$.check(Y6(X,Y)),$.max=(X,Y)=>$.check(Y6(X,Y)),$.int=(X)=>$.check(mw(X)),$.safe=(X)=>$.check(mw(X)),$.positive=(X)=>$.check(o6(0,X)),$.nonnegative=(X)=>$.check(b4(0,X)),$.negative=(X)=>$.check(p6(0,X)),$.nonpositive=(X)=>$.check(Y6(0,X)),$.multipleOf=(X,Y)=>$.check(e1(X,Y)),$.step=(X,Y)=>$.check(e1(X,Y)),$.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 KH($){return t9(gW,$)}var t0=K("ZodNumberFormat",($,T)=>{PJ.init($,T),gW.init($,T)});function mw($){return s9(t0,$)}function EB($){return e9(t0,$)}function AB($){return $w(t0,$)}function MB($){return Tw(t0,$)}function NB($){return Ww(t0,$)}var mW=K("ZodBoolean",($,T)=>{EW.init($,T),w$.init($,T)});function EH($){return Xw(mW,$)}var cW=K("ZodBigInt",($,T)=>{$8.init($,T),w$.init($,T),$.gte=(X,Y)=>$.check(b4(X,Y)),$.min=(X,Y)=>$.check(b4(X,Y)),$.gt=(X,Y)=>$.check(o6(X,Y)),$.gte=(X,Y)=>$.check(b4(X,Y)),$.min=(X,Y)=>$.check(b4(X,Y)),$.lt=(X,Y)=>$.check(p6(X,Y)),$.lte=(X,Y)=>$.check(Y6(X,Y)),$.max=(X,Y)=>$.check(Y6(X,Y)),$.positive=(X)=>$.check(o6(BigInt(0),X)),$.negative=(X)=>$.check(p6(BigInt(0),X)),$.nonpositive=(X)=>$.check(Y6(BigInt(0),X)),$.nonnegative=(X)=>$.check(b4(BigInt(0),X)),$.multipleOf=(X,Y)=>$.check(e1(X,Y));let W=$._zod.bag;$.minValue=W.minimum??null,$.maxValue=W.maximum??null,$.format=W.format??null});function LB($){return Uw(cW,$)}var Uz=K("ZodBigIntFormat",($,T)=>{CJ.init($,T),cW.init($,T)});function SB($){return Jw(Uz,$)}function BB($){return ww(Uz,$)}var AH=K("ZodSymbol",($,T)=>{vJ.init($,T),w$.init($,T)});function RB($){return zw(AH,$)}var MH=K("ZodUndefined",($,T)=>{jJ.init($,T),w$.init($,T)});function IB($){return _w(MH,$)}var NH=K("ZodNull",($,T)=>{xJ.init($,T),w$.init($,T)});function LH($){return Hw(NH,$)}var SH=K("ZodAny",($,T)=>{bJ.init($,T),w$.init($,T)});function kB(){return Fw(SH)}var Gz=K("ZodUnknown",($,T)=>{AW.init($,T),w$.init($,T)});function q8(){return Qw(Gz)}var BH=K("ZodNever",($,T)=>{fJ.init($,T),w$.init($,T)});function j8($){return Zw(BH,$)}var RH=K("ZodVoid",($,T)=>{yJ.init($,T),w$.init($,T)});function qB($){return Dw(RH,$)}var I8=K("ZodDate",($,T)=>{hJ.init($,T),w$.init($,T),$.min=(X,Y)=>$.check(b4(X,Y)),$.max=(X,Y)=>$.check(Y6(X,Y));let W=$._zod.bag;$.minDate=W.minimum?new Date(W.minimum):null,$.maxDate=W.maximum?new Date(W.maximum):null});function PB($){return Ow(I8,$)}var IH=K("ZodArray",($,T)=>{gJ.init($,T),w$.init($,T),$.element=T.element,$.min=(W,X)=>$.check(B1(W,X)),$.nonempty=(W)=>$.check(B1(1,W)),$.max=(W,X)=>$.check(l0(W,X)),$.length=(W,X)=>$.check(r0(W,X))});function Jz($,T){return Sw(IH,$,T)}function CB($){let T=$._zod.def.shape;return yH(Object.keys(T))}var x8=K("ZodObject",($,T)=>{mJ.init($,T),w$.init($,T),g.defineLazy($,"shape",()=>{return Object.fromEntries(Object.entries($._zod.def.shape))}),$.keyof=()=>bH(Object.keys($._zod.def.shape)),$.catchall=(W)=>$.clone({...$._zod.def,catchall:W}),$.passthrough=()=>$.clone({...$._zod.def,catchall:q8()}),$.loose=()=>$.clone({...$._zod.def,catchall:q8()}),$.strict=()=>$.clone({...$._zod.def,catchall:j8()}),$.strip=()=>$.clone({...$._zod.def,catchall:void 0}),$.extend=(W)=>{return g.extend($,W)},$.merge=(W)=>g.merge($,W),$.pick=(W)=>g.pick($,W),$.omit=(W)=>g.omit($,W),$.partial=(...W)=>g.partial(Hz,$,W[0]),$.required=(...W)=>g.required(Fz,$,W[0])});function vB($,T){let W={type:"object",get shape(){return g.assignProp(this,"shape",{...$}),this.shape},...g.normalizeParams(T)};return new x8(W)}function jB($,T){return new x8({type:"object",get shape(){return g.assignProp(this,"shape",{...$}),this.shape},catchall:j8(),...g.normalizeParams(T)})}function xB($,T){return new x8({type:"object",get shape(){return g.assignProp(this,"shape",{...$}),this.shape},catchall:q8(),...g.normalizeParams(T)})}var wz=K("ZodUnion",($,T)=>{T8.init($,T),w$.init($,T),$.options=T.options});function b8($,T){return new wz({type:"union",options:$,...g.normalizeParams(T)})}var kH=K("ZodDiscriminatedUnion",($,T)=>{wz.init($,T),cJ.init($,T)});function bB($,T,W){return new kH({type:"union",options:T,discriminator:$,...g.normalizeParams(W)})}var qH=K("ZodIntersection",($,T)=>{uJ.init($,T),w$.init($,T)});function PH($,T){return new qH({type:"intersection",left:$,right:T})}var CH=K("ZodTuple",($,T)=>{s1.init($,T),w$.init($,T),$.rest=(W)=>$.clone({...$._zod.def,rest:W})});function fB($,T,W){let X=T instanceof T$,Y=X?W:T;return new CH({type:"tuple",items:$,rest:X?T:null,...g.normalizeParams(Y)})}var zz=K("ZodRecord",($,T)=>{pJ.init($,T),w$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function vH($,T,W){return new zz({type:"record",keyType:$,valueType:T,...g.normalizeParams(W)})}function yB($,T,W){return new zz({type:"record",keyType:b8([$,j8()]),valueType:T,...g.normalizeParams(W)})}var jH=K("ZodMap",($,T)=>{oJ.init($,T),w$.init($,T),$.keyType=T.keyType,$.valueType=T.valueType});function hB($,T,W){return new jH({type:"map",keyType:$,valueType:T,...g.normalizeParams(W)})}var xH=K("ZodSet",($,T)=>{dJ.init($,T),w$.init($,T),$.min=(...W)=>$.check($0(...W)),$.nonempty=(W)=>$.check($0(1,W)),$.max=(...W)=>$.check(d0(...W)),$.size=(...W)=>$.check(RW(...W))});function gB($,T){return new xH({type:"set",valueType:$,...g.normalizeParams(T)})}var uW=K("ZodEnum",($,T)=>{lJ.init($,T),w$.init($,T),$.enum=T.entries,$.options=Object.values(T.entries);let W=new Set(Object.keys(T.entries));$.extract=(X,Y)=>{let U={};for(let G of X)if(W.has(G))U[G]=T.entries[G];else throw new Error(`Key ${G} not found in enum`);return new uW({...T,checks:[],...g.normalizeParams(Y),entries:U})},$.exclude=(X,Y)=>{let U={...T.entries};for(let G of X)if(W.has(G))delete U[G];else throw new Error(`Key ${G} not found in enum`);return new uW({...T,checks:[],...g.normalizeParams(Y),entries:U})}});function bH($,T){let W=Array.isArray($)?Object.fromEntries($.map((X)=>[X,X])):$;return new uW({type:"enum",entries:W,...g.normalizeParams(T)})}function mB($,T){return new uW({type:"enum",entries:$,...g.normalizeParams(T)})}var fH=K("ZodLiteral",($,T)=>{rJ.init($,T),w$.init($,T),$.values=new Set(T.values)});function yH($,T){return new fH({type:"literal",values:Array.isArray($)?$:[$],...g.normalizeParams(T)})}var hH=K("ZodFile",($,T)=>{iJ.init($,T),w$.init($,T),$.min=(W,X)=>$.check($0(W,X)),$.max=(W,X)=>$.check(d0(W,X)),$.mime=(W,X)=>$.check(jW(W,X))});function cB($){return Rw(hH,$)}var gH=K("ZodTransform",($,T)=>{nJ.init($,T),w$.init($,T),$._zod.parse=(W,X)=>{W.addIssue=(U)=>{if(typeof U==="string")W.issues.push(g.issue(U,W.value,T));else{let G=U;if(G.fatal)G.continue=!1;G.code??(G.code="custom"),G.input??(G.input=W.value),G.inst??(G.inst=$),G.continue??(G.continue=!0),W.issues.push(g.issue(G))}};let Y=T.transform(W.value,W);if(Y instanceof Promise)return Y.then((U)=>{return W.value=U,W});return W.value=Y,W}});function _z($){return new gH({type:"transform",transform:$})}var Hz=K("ZodOptional",($,T)=>{tJ.init($,T),w$.init($,T),$.unwrap=()=>$._zod.def.innerType});function P8($){return new Hz({type:"optional",innerType:$})}var mH=K("ZodNullable",($,T)=>{aJ.init($,T),w$.init($,T),$.unwrap=()=>$._zod.def.innerType});function C8($){return new mH({type:"nullable",innerType:$})}function uB($){return P8(C8($))}var cH=K("ZodDefault",($,T)=>{sJ.init($,T),w$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function uH($,T){return new cH({type:"default",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var pH=K("ZodPrefault",($,T)=>{eJ.init($,T),w$.init($,T),$.unwrap=()=>$._zod.def.innerType});function oH($,T){return new pH({type:"prefault",innerType:$,get defaultValue(){return typeof T==="function"?T():T}})}var Fz=K("ZodNonOptional",($,T)=>{$9.init($,T),w$.init($,T),$.unwrap=()=>$._zod.def.innerType});function dH($,T){return new Fz({type:"nonoptional",innerType:$,...g.normalizeParams(T)})}var lH=K("ZodSuccess",($,T)=>{T9.init($,T),w$.init($,T),$.unwrap=()=>$._zod.def.innerType});function pB($){return new lH({type:"success",innerType:$})}var rH=K("ZodCatch",($,T)=>{W9.init($,T),w$.init($,T),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function iH($,T){return new rH({type:"catch",innerType:$,catchValue:typeof T==="function"?T:()=>T})}var nH=K("ZodNaN",($,T)=>{X9.init($,T),w$.init($,T)});function oB($){return Kw(nH,$)}var Qz=K("ZodPipe",($,T)=>{MW.init($,T),w$.init($,T),$.in=T.in,$.out=T.out});function v8($,T){return new Qz({type:"pipe",in:$,out:T})}var tH=K("ZodReadonly",($,T)=>{Y9.init($,T),w$.init($,T)});function aH($){return new tH({type:"readonly",innerType:$})}var sH=K("ZodTemplateLiteral",($,T)=>{U9.init($,T),w$.init($,T)});function dB($,T){return new sH({type:"template_literal",parts:$,...g.normalizeParams(T)})}var eH=K("ZodLazy",($,T)=>{J9.init($,T),w$.init($,T),$.unwrap=()=>$._zod.def.getter()});function $F($){return new eH({type:"lazy",getter:$})}var TF=K("ZodPromise",($,T)=>{G9.init($,T),w$.init($,T),$.unwrap=()=>$._zod.def.innerType});function lB($){return new TF({type:"promise",innerType:$})}var f8=K("ZodCustom",($,T)=>{w9.init($,T),w$.init($,T)});function WF($,T){let W=new u$({check:"custom",...g.normalizeParams(T)});return W._zod.check=$,W}function rB($,T){return hW(f8,$??(()=>!0),T)}function XF($,T={}){return hW(f8,$,T)}function YF($,T){let W=WF((X)=>{return X.addIssue=(Y)=>{if(typeof Y==="string")X.issues.push(g.issue(Y,X.value,W._zod.def));else{let U=Y;if(U.fatal)U.continue=!1;U.code??(U.code="custom"),U.input??(U.input=X.value),U.inst??(U.inst=W),U.continue??(U.continue=!W._zod.def.abort),X.issues.push(g.issue(U))}},$(X.value,X)},T);return W}function iB($,T={error:`Input not instance of ${$.name}`}){let W=new f8({type:"custom",check:"custom",fn:(X)=>X instanceof $,abort:!0,...g.normalizeParams(T)});return W._zod.bag.Class=$,W}var nB=Iw.bind(null,{Pipe:Qz,Boolean:mW,Unknown:Gz});function tB($){let T=$F(()=>{return b8([gw($),KH(),EH(),LH(),Jz(T),vH(gw(),T)])});return T}function aB($,T){return v8(_z($),T)}var sB={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"},eB=Object.freeze({status:"aborted"}),$R=eB;function TR($){n$({customError:$})}function WR(){return n$().customError}n$(NW());function UF($,T){return function W({schema:X,fallback:Y,toJsonSchema:U=y8.toJSONSchema}){let G=U(X);return async function J(z,w=3){let H,_=[];while(_.length<w){H=await $(z,G,Y,_);let F=await X["~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")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.
34
34
  `,`Here's what was returned last time:
35
35
  `,JSON.stringify(H,null,"\t"),`
36
36
  `,`Here are the issues returned from our validation:
37
- `,JSON.stringify(F.issues,null,"\t")),_.push({response:H,error:F})}return T?.error(`safegen was unable to generate well-formed data after ${w} failed attempts.`),Y}}}function GF($){return["Please generate a response in JSON that conforms to the following JSON Schema:",JSON.stringify($,null,2)].join(`
38
- `)}var DF=_M(zF(),1);import*as f4 from"fs";import*as a0 from"path";import{resolve as wR}from"path";import{createHash as zR}from"crypto";import{copyFile as _R}from"fs/promises";import{existsSync as Zz,mkdirSync as _F,readFileSync as GR,readdirSync as HF,rmSync as FF,statSync as QF,writeFileSync as JR}from"fs";import{resolve as Dz}from"path";var ZF=class{rootDir;get initialized(){return Zz(this.rootDir)}initialize(){if(!this.initialized)_F(this.rootDir,{recursive:!0})}constructor($){if(this.rootDir=$.path,$.eagerInit)this.initialize()}getItem($){let T=Dz(this.rootDir,$);if(Zz(T))return GR(T,"utf-8");return null}setItem($,T){this.initialize();let W=Dz(this.rootDir,$);JR(W,T)}removeItem($){let T=Dz(this.rootDir,$);if(Zz(T))this.initialize(),FF(T)}key($){return HF(this.rootDir).sort((X,Y)=>{let U=QF(X);return QF(Y).ctimeMs-U.ctimeMs})[$]??null}clear(){FF(this.rootDir,{recursive:!0}),_F(this.rootDir,{recursive:!0})}get length(){return HF(this.rootDir).length}};var OF=/[^a-zA-Z0-9\-._]/g;function lW($,T=64){if(T%2===1)T+=1;let W=$.replace(OF,"-");if(W.length<=T)return W;let X=zR("sha256").update($).digest("base64").slice(0,8).replace("/","_"),Y=W;if(Y.length>T){let U=Y.slice(0,T/2),G=Y.slice(-T/2);Y=U+"_"+G}return Y+"+"+X}var HR=DF.default("varmint"),dW=lW(process.cwd(),150),Oz=wR(HR,dW),W4="_-$-_-$-_",VF=`file${W4}`,KF=`list${W4}`,EF=`root${W4}`,FR=`unmatched${W4}`,P$={storage:new ZF({path:Oz,eagerInit:!1}),startGlobalTracking(){if(console.log(`\uD83D\uDC3F\uFE0F Starting global tracking of varmint files using project identifier "${dW}"`),P$.storage.initialized)console.error(`\uD83D\uDCA5 The global cache for the project "${dW}" was found already initialized. Clearing it and starting fresh.`),P$.storage.clear();P$.storage.initialize()},async prepareUploads($){console.log(`\uD83D\uDC3F\uFE0F Moving unmatched inputs to /tmp/varmint-uploads using project identifier "${dW}"`);let T=[];for(let W of f4.readdirSync(P$.storage.rootDir))if(h8(`unmatched${W4}`,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(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:",`
39
39
  - ${T.join(`
40
40
  `)}
41
41
  `,`in root folder:
42
- `,Oz),process.env[$])f4.mkdirSync("/tmp/varmint-uploads",{recursive:!0}),await Promise.all(T.map(async(W)=>{let X=a0.join(Oz,W),Y=a0.join("/tmp/varmint-uploads",W);await _R(X,Y)}));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 "${dW}" and starting cleanup of untouched files.`),!P$.storage.initialized){console.error("\uD83D\uDCA5 called flushGlobal, but the global cache wasn't initialized with startGlobalTracking");return}let $=f4.readdirSync(P$.storage.rootDir),T=new Map,W=[],X=[],Y=[];for(let G of $)if(h8(`root${W4}`,G))W.push(G);else if(h8(`list${W4}`,G))X.push(G);else if(h8(`file${W4}`,G))Y.push(G);if(P$.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 G=new Map;for(let J of W){let z=J.replace(EF,"");G.set(z,new Map);let w=P$.storage.getItem(J);if(w)T.set(z,w);else console.error(`\uD83D\uDCA5 Could not find folder ${w} referenced in the global cache`)}for(let J of X){let z=J.replace(KF,""),[w,H]=z.split(W4),_=G.get(w);if(_)_.set(H,new Set);else console.error(`\uD83D\uDCA5 Could not find root ${w} for list ${H}`)}for(let J of Y){let z=J.replace(VF,""),[w,H,_]=z.split(W4),F=G.get(w);if(F){let D=F.get(H);if(D)D.add(_);else console.error(`\uD83D\uDCA5 Could not find list ${H} for file ${z}`)}else console.error(`\uD83D\uDCA5 Could not find root ${w} for file ${z}`)}console.log("\uD83D\uDC3F\uFE0F ",G);for(let[J,z]of G.entries()){let w=T.get(J);if(!w){console.error(`\uD83D\uDCA5 Could not find root ${J}`);continue}if(!f4.existsSync(w)){console.warn(`\uD83D\uDCA5 Root folder ${w}, identified as being used during tracking, no longer exists during cleanup.`);continue}let _=f4.readdirSync(w);for(let F of _)if(F!==".ferret"&&!z.has(F)){let D=a0.join(w,F);console.log(`\uD83E\uDDF9 globalFlush: removing directory ${D}`),f4.rmSync(D,{recursive:!0})}for(let[F,D]of z.entries()){let V=a0.join(w,F);if(!f4.existsSync(V)){console.warn(`\uD83D\uDCA5 List folder ${V}, identified as being used during tracking, no longer exists.`);continue}let R=f4.readdirSync(V);for(let P of R){let M=P.replace(".input.json","").replace(".output.json","").replace(".stream.txt","");if(!D.has(M)){let N=a0.join(V,P);console.log(`\uD83E\uDDF9 globalFlush: removing file ${N}`),f4.rmSync(N)}}}}}f4.rmSync(P$.storage.rootDir,{recursive:!0})}};function h8($,T){return T.startsWith($)}import*as l$ from"fs";import*as K6 from"path";import{inspect as AF}from"util";var MF=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=lW(this.baseDir),P$.storage.initialized&&!P$.storage.getItem(`root${W4}${this.rootName}`))P$.storage.setItem(`root${W4}${this.rootName}`,this.baseDir)}read($,T,W){let X=K6.join(this.baseDir,$),Y=`${T}.input.json`,U=K6.join(X,Y);if(!l$.existsSync(U)){if(!l$.existsSync(X)){if(P$.storage.initialized&&this.mode==="read")P$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: input file for key "${$}" with "${T}" was not found. Directory "${X}" does not exist.`)}let _=l$.readdirSync(X).map((V)=>[V,l$.readFileSync(K6.join(X,V),"utf-8")]).filter(([V])=>V.endsWith(".input.json")),F=[];for(let[V,E]of _){let R=` ${V}`,P=` ${AF(JSON.parse(E),{depth:Number.POSITIVE_INFINITY,colors:!0}).split(`
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(`
43
43
  `).join(`
44
- `)}`;F.push(R,P)}let D=` ${Y}
45
- ${AF(W,{depth:Number.POSITIVE_INFINITY,colors:!0}).split(`
44
+ `)}`;F.push(I,k)}let Q=` ${X}
45
+ ${bF(W,{depth:Number.POSITIVE_INFINITY,colors:!0}).split(`
46
46
  `).join(`
47
- `)}`;if(P$.storage.initialized&&this.mode==="read")P$.storage.setItem(`unmatched${W4}${Y}`,JSON.stringify(W,null,"\t")),P$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: input file for key "${$}" with subKey "${T}" (${U}) was not found. Directory "${X}" 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(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.
48
48
 
49
49
  CACHED INPUT FILES:
50
50
  ${F.join(`
51
51
  `)}
52
52
 
53
53
  YOUR INPUT DATA:
54
- ${D}
55
- `)}let G=l$.readFileSync(U,"utf-8"),J=JSON.stringify(W,null,"\t");if(J!==G){if(P$.storage.initialized&&this.mode==="read")P$.storage.setItem("DID_CACHE_MISS","true");throw new Error(`Squirrel: the content of the cached input file ${U} does not match the input provided.
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.
56
56
 
57
57
  Provided:
58
- ${J}
58
+ ${w}
59
59
 
60
60
  Cached:
61
- ${G}`)}let z=K6.join(this.baseDir,`${$}/${T}.output.json`);return JSON.parse(l$.readFileSync(z,"utf-8"))}async write($,T,W,X){let Y=K6.join(this.baseDir,$),U=K6.join(Y,`${T}.input.json`),G=K6.join(Y,`${T}.output.json`),J=JSON.stringify(W,null,"\t");if(!l$.existsSync(this.baseDir))l$.mkdirSync(this.baseDir,{recursive:!0});if(!l$.existsSync(Y))l$.mkdirSync(Y);if(l$.writeFileSync(U,J),l$.existsSync(G))l$.unlinkSync(G);let z=await X(...W),w=JSON.stringify(z,null,"\t");return l$.writeFileSync(G,w),z}add($,T){let W=`${this.rootName}${W4}${lW($)}`;return{flush:()=>{this.flush($)},for:(X)=>{if(this.mode!=="off"){if(this.filesTouched.set($,new Set),P$.storage.initialized&&!P$.storage.getItem(`list${W4}${W}`))P$.storage.setItem(`list${W4}${W}`,"true")}return{get:async(...Y)=>{let U=X;if(this.mode!=="off"){let G=this.filenameCache.get(X);if(!G)G=lW(X),this.filenameCache.set(X,G);U=G,this.filesTouched.get($)?.add(U);let J=`${W}${W4}${U}`,z=`file${W4}${J}`;if(P$.storage.initialized&&!P$.storage.getItem(z))P$.storage.setItem(z,"true")}switch(this.mode){case"off":return T(...Y);case"read":return this.read($,U,Y);case"write":return this.write($,U,Y,T);case"read-write":try{return this.read($,U,Y)}catch(G){if(G instanceof Error)return this.write($,U,Y,T);throw G}}}}}}}flush(...$){console.log(this.filesTouched);for(let[T,W]of this.filesTouched.entries())if($.length===0||$.includes(T)){let X=K6.join(this.baseDir,T),Y=l$.readdirSync(X);for(let U of Y){let G=U.replace(".input.json","").replace(".output.json","");if(!W.has(G))console.info(`\uD83E\uDDF9 Flushing ${G}`),l$.unlinkSync(K6.join(X,U))}}}};var g8="RFC3986",m8={RFC1738:($)=>String($).replace(/%20/g,"+"),RFC3986:($)=>String($)},NF="RFC1738";var QR=Array.isArray,j6=(()=>{let $=[];for(let T=0;T<256;++T)$.push("%"+((T<16?"0":"")+T.toString(16)).toUpperCase());return $})();var Vz=1024,LF=($,T,W,X,Y)=>{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(J){return"%26%23"+parseInt(J.slice(2),16)+"%3B"});let G="";for(let J=0;J<U.length;J+=Vz){let z=U.length>=Vz?U.slice(J,J+Vz):U,w=[];for(let H=0;H<z.length;++H){let _=z.charCodeAt(H);if(_===45||_===46||_===95||_===126||_>=48&&_<=57||_>=65&&_<=90||_>=97&&_<=122||Y===NF&&(_===40||_===41)){w[w.length]=z.charAt(H);continue}if(_<128){w[w.length]=j6[_];continue}if(_<2048){w[w.length]=j6[192|_>>6]+j6[128|_&63];continue}if(_<55296||_>=57344){w[w.length]=j6[224|_>>12]+j6[128|_>>6&63]+j6[128|_&63];continue}H+=1,_=65536+((_&1023)<<10|z.charCodeAt(H)&1023),w[w.length]=j6[240|_>>18]+j6[128|_>>12&63]+j6[128|_>>6&63]+j6[128|_&63]}G+=w.join("")}return G};function SF($){if(!$||typeof $!=="object")return!1;return!!($.constructor&&$.constructor.isBuffer&&$.constructor.isBuffer($))}function Kz($,T){if(QR($)){let W=[];for(let X=0;X<$.length;X+=1)W.push(T($[X]));return W}return T($)}var ZR=Object.prototype.hasOwnProperty,BF={brackets($){return String($)+"[]"},comma:"comma",indices($,T){return String($)+"["+T+"]"},repeat($){return String($)}},x6=Array.isArray,DR=Array.prototype.push,RF=function($,T){DR.apply($,x6(T)?T:[T])},OR=Date.prototype.toISOString,X4={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:LF,encodeValuesOnly:!1,format:g8,formatter:m8[g8],indices:!1,serializeDate($){return OR.call($)},skipNulls:!1,strictNullHandling:!1};function VR($){return typeof $==="string"||typeof $==="number"||typeof $==="boolean"||typeof $==="symbol"||typeof $==="bigint"}var Ez={};function IF($,T,W,X,Y,U,G,J,z,w,H,_,F,D,V,E,R,P){let M=$,N=P,k=0,y=!1;while((N=N.get(Ez))!==void 0&&!y){let B=N.get($);if(k+=1,typeof B!=="undefined")if(B===k)throw new RangeError("Cyclic object value");else y=!0;if(typeof N.get(Ez)==="undefined")k=0}if(typeof w==="function")M=w(T,M);else if(M instanceof Date)M=F?.(M);else if(W==="comma"&&x6(M))M=Kz(M,function(B){if(B instanceof Date)return F?.(B);return B});if(M===null){if(U)return z&&!E?z(T,X4.encoder,R,"key",D):T;M=""}if(VR(M)||SF(M)){if(z){let B=E?T:z(T,X4.encoder,R,"key",D);return[V?.(B)+"="+V?.(z(M,X4.encoder,R,"value",D))]}return[V?.(T)+"="+V?.(String(M))]}let x=[];if(typeof M==="undefined")return x;let m;if(W==="comma"&&x6(M)){if(E&&z)M=Kz(M,z);m=[{value:M.length>0?M.join(",")||null:void 0}]}else if(x6(w))m=w;else{let B=Object.keys(M);m=H?B.sort(H):B}let J$=J?String(T).replace(/\./g,"%2E"):String(T),m$=X&&x6(M)&&M.length===1?J$+"[]":J$;if(Y&&x6(M)&&M.length===0)return m$+"[]";for(let B=0;B<m.length;++B){let Q$=m[B],$$=typeof Q$==="object"&&typeof Q$.value!=="undefined"?Q$.value:M[Q$];if(G&&$$===null)continue;let H$=_&&J?Q$.replace(/\./g,"%2E"):Q$,e$=x6(M)?typeof W==="function"?W(m$,H$):m$:m$+(_?"."+H$:"["+H$+"]");P.set($,k);let O4=new WeakMap;O4.set(Ez,P),RF(x,IF($$,e$,W,X,Y,U,G,J,W==="comma"&&E&&x6(M)?null:z,w,H,_,F,D,V,E,R,O4))}return x}function KR($=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=g8;if(typeof $.format!=="undefined"){if(!ZR.call(m8,$.format))throw new TypeError("Unknown format option provided.");W=$.format}let X=m8[W],Y=X4.filter;if(typeof $.filter==="function"||x6($.filter))Y=$.filter;let U;if($.arrayFormat&&$.arrayFormat in BF)U=$.arrayFormat;else if("indices"in $)U=$.indices?"indices":"repeat";else U=X4.arrayFormat;if("commaRoundTrip"in $&&typeof $.commaRoundTrip!=="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let G=typeof $.allowDots==="undefined"?!!$.encodeDotInKeys===!0?!0:X4.allowDots:!!$.allowDots;return{addQueryPrefix:typeof $.addQueryPrefix==="boolean"?$.addQueryPrefix:X4.addQueryPrefix,allowDots:G,allowEmptyArrays:typeof $.allowEmptyArrays==="boolean"?!!$.allowEmptyArrays:X4.allowEmptyArrays,arrayFormat:U,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:Y,format:W,formatter:X,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 Az($,T={}){let W=$,X=KR(T),Y,U;if(typeof X.filter==="function")U=X.filter,W=U("",W);else if(x6(X.filter))U=X.filter,Y=U;let G=[];if(typeof W!=="object"||W===null)return"";let J=BF[X.arrayFormat],z=J==="comma"&&X.commaRoundTrip;if(!Y)Y=Object.keys(W);if(X.sort)Y.sort(X.sort);let w=new WeakMap;for(let F=0;F<Y.length;++F){let D=Y[F];if(X.skipNulls&&W[D]===null)continue;RF(G,IF(W[D],D,J,z,X.allowEmptyArrays,X.strictNullHandling,X.skipNulls,X.encodeDotInKeys,X.encode?X.encoder:null,X.filter,X.sort,X.allowDots,X.serializeDate,X.format,X.formatter,X.encodeValuesOnly,X.charset,w))}let H=G.join(X.delimiter),_=X.addQueryPrefix===!0?"?":"";if(X.charsetSentinel)if(X.charset==="iso-8859-1")_+="utf8=%26%2310003%3B&";else _+="utf8=%E2%9C%93&";return H.length>0?_+H:""}var T0="4.100.0";var kF=!1,W0=void 0,Mz=void 0,AR=void 0,MR=void 0,NR=void 0,Nz=void 0,LR=void 0,c8=void 0,Lz=void 0,Sz=void 0,Bz=void 0,u8=void 0,Rz=void 0;function qF($,T={auto:!1}){if(kF)throw new Error(`you must \`import 'openai/shims/${$.kind}'\` before importing anything else from openai`);if(W0)throw new Error(`can't \`import 'openai/shims/${$.kind}'\` after \`import 'openai/shims/${W0}'\``);kF=T.auto,W0=$.kind,Mz=$.fetch,AR=$.Request,MR=$.Response,NR=$.Headers,Nz=$.FormData,LR=$.Blob,c8=$.File,Lz=$.ReadableStream,Sz=$.getMultipartRequestOptions,Bz=$.getDefaultAgent,u8=$.fileFromPath,Rz=$.isFsReadStream}class Iz{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function PF({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,X,Y,U;try{W=fetch,X=Request,Y=Response,U=Headers}catch(G){throw new Error(`this environment is missing the following Web Fetch API type: ${G.message}. ${T}`)}return{kind:"web",fetch:W,Request:X,Response:Y,Headers:U,FormData:typeof FormData!=="undefined"?FormData:class G{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${T}`)}},Blob:typeof Blob!=="undefined"?Blob:class G{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${T}`)}},File:typeof File!=="undefined"?File:class G{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${T}`)}},ReadableStream:typeof ReadableStream!=="undefined"?ReadableStream:class G{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${T}`)}},getMultipartRequestOptions:async(G,J)=>({...J,body:new Iz(G)}),getDefaultAgent:(G)=>{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:(G)=>!1}}import{ReadStream as BR}from"fs";function CF(){let $=PF();function T(W){return W instanceof BR}return{...$,isFsReadStream:T}}var kz=()=>{if(!W0)qF(CF(),{auto:!0})};kz();class l extends Error{}class t$ extends l{constructor($,T,W,X){super(`${t$.makeMessage($,T,W)}`);this.status=$,this.headers=X,this.request_id=X?.["x-request-id"],this.error=T;let Y=T;this.code=Y?.code,this.param=Y?.param,this.type=Y?.type}static makeMessage($,T,W){let X=T?.message?typeof T.message==="string"?T.message:JSON.stringify(T.message):T?JSON.stringify(T):W;if($&&X)return`${$} ${X}`;if($)return`${$} status code (no body)`;if(X)return X;return"(no status code or body)"}static generate($,T,W,X){if(!$||!X)return new X0({message:W,cause:a8(T)});let Y=T?.error;if($===400)return new p8($,Y,W,X);if($===401)return new o8($,Y,W,X);if($===403)return new d8($,Y,W,X);if($===404)return new l8($,Y,W,X);if($===409)return new r8($,Y,W,X);if($===422)return new i8($,Y,W,X);if($===429)return new n8($,Y,W,X);if($>=500)return new t8($,Y,W,X);return new t$($,Y,W,X)}}class Y4 extends t${constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class X0 extends t${constructor({message:$,cause:T}){super(void 0,void 0,$||"Connection error.",void 0);if(T)this.cause=T}}class Y0 extends X0{constructor({message:$}={}){super({message:$??"Request timed out."})}}class p8 extends t${}class o8 extends t${}class d8 extends t${}class l8 extends t${}class r8 extends t${}class i8 extends t${}class n8 extends t${}class t8 extends t${}class rW extends l{constructor(){super("Could not parse response content as the length limit was reached")}}class iW extends l{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var s8=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},U0=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},n4;class s0{constructor(){n4.set(this,void 0),this.buffer=new Uint8Array,s8(this,n4,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 X=[],Y;while((Y=IR(this.buffer,U0(this,n4,"f")))!=null){if(Y.carriage&&U0(this,n4,"f")==null){s8(this,n4,Y.index,"f");continue}if(U0(this,n4,"f")!=null&&(Y.index!==U0(this,n4,"f")+1||Y.carriage)){X.push(this.decodeText(this.buffer.slice(0,U0(this,n4,"f")-1))),this.buffer=this.buffer.slice(U0(this,n4,"f")),s8(this,n4,null,"f");continue}let U=U0(this,n4,"f")!==null?Y.preceding-1:Y.preceding,G=this.decodeText(this.buffer.slice(0,U));X.push(G),this.buffer=this.buffer.slice(Y.index),s8(this,n4,null,"f")}return X}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
- `)}}n4=new WeakMap;s0.NEWLINE_CHARS=new Set([`
63
- `,"\r"]);s0.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function IR($,T){for(let Y=T??0;Y<$.length;Y++){if($[Y]===10)return{preceding:Y,index:Y+1,carriage:!1};if($[Y]===13)return{preceding:Y,index:Y+1,carriage:!0}}return null}function vF($){for(let X=0;X<$.length-1;X++){if($[X]===10&&$[X+1]===10)return X+2;if($[X]===13&&$[X+1]===13)return X+2;if($[X]===13&&$[X+1]===10&&X+3<$.length&&$[X+2]===13&&$[X+3]===10)return X+4}return-1}function qz($){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 t4{constructor($,T){this.iterator=$,this.controller=T}static fromSSEResponse($,T){let W=!1;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 U of kR($,T)){if(Y)continue;if(U.data.startsWith("[DONE]")){Y=!0;continue}if(U.event===null||U.event.startsWith("response.")||U.event.startsWith("transcript.")){let G;try{G=JSON.parse(U.data)}catch(J){throw console.error("Could not parse message into JSON:",U.data),console.error("From chunk:",U.raw),J}if(G&&G.error)throw new t$(void 0,G.error,void 0,Pz($.headers));yield G}else{let G;try{G=JSON.parse(U.data)}catch(J){throw console.error("Could not parse message into JSON:",U.data),console.error("From chunk:",U.raw),J}if(U.event=="error")throw new t$(void 0,G.error,G.message,void 0);yield{event:U.event,data:G}}}Y=!0}catch(U){if(U instanceof Error&&U.name==="AbortError")return;throw U}finally{if(!Y)T.abort()}}return new t4(X,T)}static fromReadableStream($,T){let W=!1;async function*X(){let U=new s0,G=qz($);for await(let J of G)for(let z of U.decode(J))yield z;for(let J of U.flush())yield J}async function*Y(){if(W)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");W=!0;let U=!1;try{for await(let G of X()){if(U)continue;if(G)yield JSON.parse(G)}U=!0}catch(G){if(G instanceof Error&&G.name==="AbortError")return;throw G}finally{if(!U)T.abort()}}return new t4(Y,T)}[Symbol.asyncIterator](){return this.iterator()}tee(){let $=[],T=[],W=this.iterator(),X=(Y)=>{return{next:()=>{if(Y.length===0){let U=W.next();$.push(U),T.push(U)}return Y.shift()}}};return[new t4(()=>X($),this.controller),new t4(()=>X(T),this.controller)]}toReadableStream(){let $=this,T,W=new TextEncoder;return new Lz({async start(){T=$[Symbol.asyncIterator]()},async pull(X){try{let{value:Y,done:U}=await T.next();if(U)return X.close();let G=W.encode(JSON.stringify(Y)+`
64
- `);X.enqueue(G)}catch(Y){X.error(Y)}},async cancel(){await T.return?.()}})}}async function*kR($,T){if(!$.body)throw T.abort(),new l("Attempted to iterate over a response with no body");let W=new jF,X=new s0,Y=qz($.body);for await(let U of qR(Y))for(let G of X.decode(U)){let J=W.decode(G);if(J)yield J}for(let U of X.flush()){let G=W.decode(U);if(G)yield G}}async function*qR($){let T=new Uint8Array;for await(let W of $){if(W==null)continue;let X=W instanceof ArrayBuffer?new Uint8Array(W):typeof W==="string"?new TextEncoder().encode(W):W,Y=new Uint8Array(T.length+X.length);Y.set(T),Y.set(X,T.length),T=Y;let U;while((U=vF(T))!==-1)yield T.slice(0,U),T=T.slice(U)}if(T.length>0)yield T}class jF{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 Y={event:this.event,data:this.data.join(`
65
- `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],Y}if(this.chunks.push($),$.startsWith(":"))return null;let[T,W,X]=PR($,":");if(X.startsWith(" "))X=X.substring(1);if(T==="event")this.event=X;else if(T==="data")this.data.push(X);return null}}function PR($,T){let W=$.indexOf(T);if(W!==-1)return[$.substring(0,W),T,$.substring(W+T.length)];return[$,"",""]}var xF=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",bF=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&nW($),nW=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function",CR=($)=>{return bF($)||xF($)||Rz($)};async function jz($,T,W){if($=await $,bF($))return $;if(xF($)){let Y=await $.blob();T||(T=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let U=nW(Y)?[await Y.arrayBuffer()]:[Y];return new c8(U,T,W)}let X=await vR($);if(T||(T=xR($)??"unknown_file"),!W?.type){let Y=X[0]?.type;if(typeof Y==="string")W={...W,type:Y}}return new c8(X,T,W)}async function vR($){let T=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)T.push($);else if(nW($))T.push(await $.arrayBuffer());else if(bR($))for await(let W of $)T.push(W);else throw new Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${jR($)}`);return T}function jR($){return`[${Object.getOwnPropertyNames($).map((W)=>`"${W}"`).join(", ")}]`}function xR($){return Cz($.name)||Cz($.filename)||Cz($.path)?.split(/[\\/]/).pop()}var Cz=($)=>{if(typeof $==="string")return $;if(typeof Buffer!=="undefined"&&$ instanceof Buffer)return String($);return},bR=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",xz=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var U6=async($)=>{let T=await fF($.body);return Sz(T,$)},fF=async($)=>{let T=new Nz;return await Promise.all(Object.entries($||{}).map(([W,X])=>vz(T,W,X))),T};var vz=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(CR(W)){let X=await jz(W);$.append(T,X)}else if(Array.isArray(W))await Promise.all(W.map((X)=>vz($,T+"[]",X)));else if(typeof W==="object")await Promise.all(Object.entries(W).map(([X,Y])=>vz($,`${T}[${X}]`,Y)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${W} instead`)};var yR=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},hR=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},e8;kz();async function uF($){let{response:T}=$;if($.options.stream){if(i6("response",T.status,T.url,T.headers,T.body),$.options.__streamClass)return $.options.__streamClass.fromSSEResponse(T,$.controller);return t4.fromSSEResponse(T,$.controller)}if(T.status===204)return null;if($.options.__binaryResponse)return T;let X=T.headers.get("content-type")?.split(";")[0]?.trim();if(X?.includes("application/json")||X?.endsWith("+json")){let G=await T.json();return i6("response",T.status,T.url,T.headers,G),pF(G,T)}let U=await T.text();return i6("response",T.status,T.url,T.headers,U),U}function pF($,T){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:T.headers.get("x-request-id"),enumerable:!1})}class TY extends Promise{constructor($,T=uF){super((W)=>{W(null)});this.responsePromise=$,this.parseResponse=T}_thenUnwrap($){return new TY(this.responsePromise,async(T)=>pF($(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 fz{constructor({baseURL:$,maxRetries:T=2,timeout:W=600000,httpAgent:X,fetch:Y}){this.baseURL=$,this.maxRetries=bz("maxRetries",T),this.timeout=bz("timeout",W),this.httpAgent=X,this.fetch=Y??Mz}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...uR(),...this.authHeaders($)}}validateHeaders($,T){}defaultIdempotencyKey(){return`stainless-node-retry-${lR()}`}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(X)=>{let Y=X&&nW(X?.body)?new DataView(await X.body.arrayBuffer()):X?.body instanceof DataView?X.body:X?.body instanceof ArrayBuffer?new DataView(X.body):X&&ArrayBuffer.isView(X?.body)?new DataView(X.body.buffer):X?.body;return{method:$,path:T,...X,body:Y}}))}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:X,path:Y,query:U,headers:G={}}=W,J=ArrayBuffer.isView(W.body)||W.__binaryRequest&&typeof W.body==="string"?W.body:xz(W.body)?W.body.body:W.body?JSON.stringify(W.body,null,2):null,z=this.calculateContentLength(J),w=this.buildURL(Y,U);if("timeout"in W)bz("timeout",W.timeout);W.timeout=W.timeout??this.timeout;let H=W.httpAgent??this.httpAgent??Bz(w),_=W.timeout+1000;if(typeof H?.options?.timeout==="number"&&_>(H.options.timeout??0))H.options.timeout=_;if(this.idempotencyHeader&&X!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=$.idempotencyKey}let F=this.buildHeaders({options:W,headers:G,contentLength:z,retryCount:T});return{req:{method:X,...J&&{body:J},headers:F,...H&&{agent:H},signal:W.signal??null},url:w,timeout:W.timeout}}buildHeaders({options:$,headers:T,contentLength:W,retryCount:X}){let Y={};if(W)Y["content-length"]=W;let U=this.defaultHeaders($);if(mF(Y,U),mF(Y,T),xz($.body)&&W0!=="node")delete Y["content-type"];if($Y(U,"x-stainless-retry-count")===void 0&&$Y(T,"x-stainless-retry-count")===void 0)Y["x-stainless-retry-count"]=String(X);if($Y(U,"x-stainless-timeout")===void 0&&$Y(T,"x-stainless-timeout")===void 0&&$.timeout)Y["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(Y,T),Y}async prepareOptions($){}async prepareRequest($,{url:T,options:W}){}parseHeaders($){return!$?{}:(Symbol.iterator in $)?Object.fromEntries(Array.from($).map((T)=>[...T])):{...$}}makeStatusError($,T,W,X){return t$.generate($,T,W,X)}request($,T=null){return new TY(this.makeRequest($,T))}async makeRequest($,T){let W=await $,X=W.maxRetries??this.maxRetries;if(T==null)T=X;await this.prepareOptions(W);let{req:Y,url:U,timeout:G}=this.buildRequest(W,{retryCount:X-T});if(await this.prepareRequest(Y,{url:U,options:W}),i6("request",U,W,Y.headers),W.signal?.aborted)throw new Y4;let J=new AbortController,z=await this.fetchWithTimeout(U,Y,G,J).catch(a8);if(z instanceof Error){if(W.signal?.aborted)throw new Y4;if(T)return this.retryRequest(W,T);if(z.name==="AbortError")throw new Y0;throw new X0({cause:z})}let w=Pz(z.headers);if(!z.ok){if(T&&this.shouldRetry(z)){let E=`retrying, ${T} attempts remaining`;return i6(`response (error; ${E})`,z.status,U,w),this.retryRequest(W,T,w)}let H=await z.text().catch((E)=>a8(E).message),_=pR(H),F=_?void 0:H;throw i6(`response (error; ${T?"(error; no more retries left)":"(error; not retryable)"})`,z.status,U,w,F),this.makeStatusError(z.status,_,F,w)}return{response:z,options:W,controller:J}}requestAPIList($,T){let W=this.makeRequest(T,null);return new oF(this,W,$)}buildURL($,T){let W=dR($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),X=this.defaultQuery();if(!dF(X))T={...X,...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,X){let{signal:Y,...U}=T||{};if(Y)Y.addEventListener("abort",()=>X.abort());let G=setTimeout(()=>X.abort(),W),J={signal:X.signal,...U};if(J.method)J.method=J.method.toUpperCase();return this.fetch.call(void 0,$,J).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){let X,Y=W?.["retry-after-ms"];if(Y){let G=parseFloat(Y);if(!Number.isNaN(G))X=G}let U=W?.["retry-after"];if(U&&!X){let G=parseFloat(U);if(!Number.isNaN(G))X=G*1000;else X=Date.parse(U)-Date.now()}if(!(X&&0<=X&&X<60000)){let G=$.maxRetries??this.maxRetries;X=this.calculateDefaultRetryTimeoutMillis(T,G)}return await n6(X),this.makeRequest($,T-1)}calculateDefaultRetryTimeoutMillis($,T){let Y=T-$,U=Math.min(0.5*Math.pow(2,Y),8),G=1-Math.random()*0.25;return U*G*1000}getUserAgent(){return`${this.constructor.name}/JS ${T0}`}}class WY{constructor($,T,W,X){e8.set(this,void 0),yR(this,e8,$,"f"),this.options=X,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[X,Y]of W)$.url.searchParams.set(X,Y);T.query=void 0,T.path=$.url.toString()}return await hR(this,e8,"f").requestAPIList(this.constructor,T)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(e8=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let T of $.getPaginatedItems())yield T}}class oF extends TY{constructor($,T,W){super(T,async(X)=>new W($,X.response,await uF(X),X.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let T of $)yield T}}var Pz=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(T,W){let X=W.toString();return T[X.toLowerCase()]||T[X]}})},gR={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},G$=($)=>{return typeof $==="object"&&$!==null&&!dF($)&&Object.keys($).every((T)=>lF(gR,T))},mR=()=>{if(typeof Deno!=="undefined"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":T0,"X-Stainless-OS":hF(Deno.build.os),"X-Stainless-Arch":yF(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":T0,"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":T0,"X-Stainless-OS":hF(process.platform),"X-Stainless-Arch":yF(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let $=cR();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":T0,"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":T0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function cR(){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 X=W.exec(navigator.userAgent);if(X){let Y=X[1]||0,U=X[2]||0,G=X[3]||0;return{browser:T,version:`${Y}.${U}.${G}`}}}return null}var yF=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},hF=($)=>{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"},gF,uR=()=>{return gF??(gF=mR())},pR=($)=>{try{return JSON.parse($)}catch(T){return}},oR=/^[a-z][a-z0-9+.-]*:/i,dR=($)=>{return oR.test($)},n6=($)=>new Promise((T)=>setTimeout(T,$)),bz=($,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},a8=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null)try{return new Error(JSON.stringify($))}catch{}return new Error($)};var tW=($)=>{if(typeof process!=="undefined")return process.env?.[$]?.trim()??void 0;if(typeof Deno!=="undefined")return Deno.env?.get?.($)?.trim();return};function dF($){if(!$)return!0;for(let T in $)return!1;return!0}function lF($,T){return Object.prototype.hasOwnProperty.call($,T)}function mF($,T){for(let W in T){if(!lF(T,W))continue;let X=W.toLowerCase();if(!X)continue;let Y=T[W];if(Y===null)delete $[X];else if(Y!==void 0)$[X]=Y}}var cF=new Set(["authorization","api-key"]);function i6($,...T){if(typeof process!=="undefined"&&process?.env?.DEBUG==="true"){let W=T.map((X)=>{if(!X)return X;if(X.headers){let U={...X,headers:{...X.headers}};for(let G in X.headers)if(cF.has(G.toLowerCase()))U.headers[G]="REDACTED";return U}let Y=null;for(let U in X)if(cF.has(U.toLowerCase()))Y??(Y={...X}),Y[U]="REDACTED";return Y??X});console.log(`OpenAI:DEBUG:${$}`,...W)}}var lR=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let T=Math.random()*16|0;return($==="x"?T:T&3|8).toString(16)})},rF=()=>{return typeof window!=="undefined"&&typeof window.document!=="undefined"&&typeof navigator!=="undefined"},rR=($)=>{return typeof $?.get==="function"};var $Y=($,T)=>{let W=T.toLowerCase();if(rR($)){let X=T[0]?.toUpperCase()+T.substring(1).replace(/([^\w])(\w)/g,(Y,U,G)=>U+G.toUpperCase());for(let Y of[T,W,T.toUpperCase(),X]){let U=$.get(Y);if(U)return U}}for(let[X,Y]of Object.entries($))if(X.toLowerCase()===W){if(Array.isArray(Y)){if(Y.length<=1)return Y[0];return console.warn(`Received ${Y.length} entries for the ${T} header, using the first entry.`),Y[0]}return Y}return};var iF=($)=>{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,X=new Uint8Array(W);for(let Y=0;Y<W;Y++)X[Y]=T.charCodeAt(Y);return Array.from(new Float32Array(X.buffer))}};function aW($){return $!=null&&typeof $==="object"&&!Array.isArray($)}class t6 extends WY{constructor($,T,W,X){super($,T,W,X);this.data=W.data||[],this.object=W.object}getPaginatedItems(){return this.data??[]}nextPageParams(){return null}nextPageInfo(){return null}}class O$ extends WY{constructor($,T,W,X){super($,T,W,X);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 C{constructor($){this._client=$}}class sW extends C{list($,T={},W){if(G$(T))return this.list($,{},T);return this._client.getAPIList(`/chat/completions/${$}/messages`,yz,{query:T,...W})}}class G0 extends C{constructor(){super(...arguments);this.messages=new sW(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(G$($))return this.list({},$);return this._client.getAPIList("/chat/completions",J0,{query:$,...T})}del($,T){return this._client.delete(`/chat/completions/${$}`,T)}}class J0 extends O${}class yz extends O${}G0.ChatCompletionsPage=J0;G0.Messages=sW;class I1 extends C{constructor(){super(...arguments);this.completions=new G0(this._client)}}I1.Completions=G0;I1.ChatCompletionsPage=J0;class eW extends C{create($,T){return this._client.post("/audio/speech",{body:$,...T,headers:{Accept:"application/octet-stream",...T?.headers},__binaryResponse:!0})}}class $2 extends C{create($,T){return this._client.post("/audio/transcriptions",U6({body:$,...T,stream:$.stream??!1,__metadata:{model:$.model}}))}}class T2 extends C{create($,T){return this._client.post("/audio/translations",U6({body:$,...T,__metadata:{model:$.model}}))}}class a6 extends C{constructor(){super(...arguments);this.transcriptions=new $2(this._client),this.translations=new T2(this._client),this.speech=new eW(this._client)}}a6.Transcriptions=$2;a6.Translations=T2;a6.Speech=eW;class w0 extends C{create($,T){return this._client.post("/batches",{body:$,...T})}retrieve($,T){return this._client.get(`/batches/${$}`,T)}list($={},T){if(G$($))return this.list({},$);return this._client.getAPIList("/batches",e0,{query:$,...T})}cancel($,T){return this._client.post(`/batches/${$}/cancel`,T)}}class e0 extends O${}w0.BatchesPage=e0;var E6=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},p$=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},hz,XY,YY,W2,X2,UY,Y2,s6,U2,GY,JY,$T,nF;class z0{constructor(){hz.add(this),this.controller=new AbortController,XY.set(this,void 0),YY.set(this,()=>{}),W2.set(this,()=>{}),X2.set(this,void 0),UY.set(this,()=>{}),Y2.set(this,()=>{}),s6.set(this,{}),U2.set(this,!1),GY.set(this,!1),JY.set(this,!1),$T.set(this,!1),E6(this,XY,new Promise(($,T)=>{E6(this,YY,$,"f"),E6(this,W2,T,"f")}),"f"),E6(this,X2,new Promise(($,T)=>{E6(this,UY,$,"f"),E6(this,Y2,T,"f")}),"f"),p$(this,XY,"f").catch(()=>{}),p$(this,X2,"f").catch(()=>{})}_run($){setTimeout(()=>{$().then(()=>{this._emitFinal(),this._emit("end")},p$(this,hz,"m",nF).bind(this))},0)}_connected(){if(this.ended)return;p$(this,YY,"f").call(this),this._emit("connect")}get ended(){return p$(this,U2,"f")}get errored(){return p$(this,GY,"f")}get aborted(){return p$(this,JY,"f")}abort(){this.controller.abort()}on($,T){return(p$(this,s6,"f")[$]||(p$(this,s6,"f")[$]=[])).push({listener:T}),this}off($,T){let W=p$(this,s6,"f")[$];if(!W)return this;let X=W.findIndex((Y)=>Y.listener===T);if(X>=0)W.splice(X,1);return this}once($,T){return(p$(this,s6,"f")[$]||(p$(this,s6,"f")[$]=[])).push({listener:T,once:!0}),this}emitted($){return new Promise((T,W)=>{if(E6(this,$T,!0,"f"),$!=="error")this.once("error",W);this.once($,T)})}async done(){E6(this,$T,!0,"f"),await p$(this,X2,"f")}_emit($,...T){if(p$(this,U2,"f"))return;if($==="end")E6(this,U2,!0,"f"),p$(this,UY,"f").call(this);let W=p$(this,s6,"f")[$];if(W)p$(this,s6,"f")[$]=W.filter((X)=>!X.once),W.forEach(({listener:X})=>X(...T));if($==="abort"){let X=T[0];if(!p$(this,$T,"f")&&!W?.length)Promise.reject(X);p$(this,W2,"f").call(this,X),p$(this,Y2,"f").call(this,X),this._emit("end");return}if($==="error"){let X=T[0];if(!p$(this,$T,"f")&&!W?.length)Promise.reject(X);p$(this,W2,"f").call(this,X),p$(this,Y2,"f").call(this,X),this._emit("end")}}_emitFinal(){}}XY=new WeakMap,YY=new WeakMap,W2=new WeakMap,X2=new WeakMap,UY=new WeakMap,Y2=new WeakMap,s6=new WeakMap,U2=new WeakMap,GY=new WeakMap,JY=new WeakMap,$T=new WeakMap,hz=new WeakSet,nF=function $(T){if(E6(this,GY,!0,"f"),T instanceof Error&&T.name==="AbortError")T=new Y4;if(T instanceof Y4)return E6(this,JY,!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,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},a4=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},Z4,gz,b6,wY,A6,H0,TT,_0,HY,s4,zY,_Y,w2,G2,J2,tF,aF,sF,eF,$Q,TQ,WQ;class e4 extends z0{constructor(){super(...arguments);Z4.add(this),gz.set(this,[]),b6.set(this,{}),wY.set(this,{}),A6.set(this,void 0),H0.set(this,void 0),TT.set(this,void 0),_0.set(this,void 0),HY.set(this,void 0),s4.set(this,void 0),zY.set(this,void 0),_Y.set(this,void 0),w2.set(this,void 0)}[(gz=new WeakMap,b6=new WeakMap,wY=new WeakMap,A6=new WeakMap,H0=new WeakMap,TT=new WeakMap,_0=new WeakMap,HY=new WeakMap,s4=new WeakMap,zY=new WeakMap,_Y=new WeakMap,w2=new WeakMap,Z4=new WeakSet,Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(X)=>{let Y=T.shift();if(Y)Y.resolve(X);else $.push(X)}),this.on("end",()=>{W=!0;for(let X of T)X.resolve(void 0);T.length=0}),this.on("abort",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),this.on("error",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((Y,U)=>T.push({resolve:Y,reject:U})).then((Y)=>Y?{value:Y,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 e4;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 X=t4.fromReadableStream($,this.controller);for await(let Y of X)r(this,Z4,"m",G2).call(this,Y);if(X.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,Z4,"m",J2).call(this))}toReadableStream(){return new t4(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream($,T,W,X,Y){let U=new e4;return U._run(()=>U._runToolAssistantStream($,T,W,X,{...Y,headers:{...Y?.headers,"X-Stainless-Helper-Method":"stream"}})),U}async _createToolAssistantStream($,T,W,X,Y){let U=Y?.signal;if(U){if(U.aborted)this.controller.abort();U.addEventListener("abort",()=>this.controller.abort())}let G={...X,stream:!0},J=await $.submitToolOutputs(T,W,G,{...Y,signal:this.controller.signal});this._connected();for await(let z of J)r(this,Z4,"m",G2).call(this,z);if(J.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,Z4,"m",J2).call(this))}static createThreadAssistantStream($,T,W){let X=new e4;return X._run(()=>X._threadAssistantStream($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),X}static createAssistantStream($,T,W,X){let Y=new e4;return Y._run(()=>Y._runAssistantStream($,T,W,{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),Y}currentEvent(){return r(this,zY,"f")}currentRun(){return r(this,_Y,"f")}currentMessageSnapshot(){return r(this,A6,"f")}currentRunStepSnapshot(){return r(this,w2,"f")}async finalRunSteps(){return await this.done(),Object.values(r(this,b6,"f"))}async finalMessages(){return await this.done(),Object.values(r(this,wY,"f"))}async finalRun(){if(await this.done(),!r(this,H0,"f"))throw Error("Final run was not received.");return r(this,H0,"f")}async _createThreadAssistantStream($,T,W){let X=W?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}let Y={...T,stream:!0},U=await $.createAndRun(Y,{...W,signal:this.controller.signal});this._connected();for await(let G of U)r(this,Z4,"m",G2).call(this,G);if(U.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,Z4,"m",J2).call(this))}async _createAssistantStream($,T,W,X){let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}let U={...W,stream:!0},G=await $.create(T,U,{...X,signal:this.controller.signal});this._connected();for await(let J of G)r(this,Z4,"m",G2).call(this,J);if(G.controller.signal?.aborted)throw new Y4;return this._addRun(r(this,Z4,"m",J2).call(this))}static accumulateDelta($,T){for(let[W,X]of Object.entries(T)){if(!$.hasOwnProperty(W)){$[W]=X;continue}let Y=$[W];if(Y===null||Y===void 0){$[W]=X;continue}if(W==="index"||W==="type"){$[W]=X;continue}if(typeof Y==="string"&&typeof X==="string")Y+=X;else if(typeof Y==="number"&&typeof X==="number")Y+=X;else if(aW(Y)&&aW(X))Y=this.accumulateDelta(Y,X);else if(Array.isArray(Y)&&Array.isArray(X)){if(Y.every((U)=>typeof U==="string"||typeof U==="number")){Y.push(...X);continue}for(let U of X){if(!aW(U))throw new Error(`Expected array delta entry to be an object but got: ${U}`);let G=U.index;if(G==null)throw console.error(U),new Error("Expected array delta entry to have an `index` property");if(typeof G!=="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${G}`);let J=Y[G];if(J==null)Y.push(U);else Y[G]=this.accumulateDelta(J,U)}continue}else throw Error(`Unhandled record type: ${W}, deltaValue: ${X}, accValue: ${Y}`);$[W]=Y}return $}_addRun($){return $}async _threadAssistantStream($,T,W){return await this._createThreadAssistantStream(T,$,W)}async _runAssistantStream($,T,W,X){return await this._createAssistantStream(T,$,W,X)}async _runToolAssistantStream($,T,W,X,Y){return await this._createToolAssistantStream(W,$,T,X,Y)}}G2=function $(T){if(this.ended)return;switch(a4(this,zY,T,"f"),r(this,Z4,"m",sF).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",WQ).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",aF).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",tF).call(this,T);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier");default:eR(T)}},J2=function $(){if(this.ended)throw new l("stream has ended, this shouldn't happen");if(!r(this,H0,"f"))throw Error("Final run has not been received");return r(this,H0,"f")},tF=function $(T){let[W,X]=r(this,Z4,"m",$Q).call(this,T,r(this,A6,"f"));a4(this,A6,W,"f"),r(this,wY,"f")[W.id]=W;for(let Y of X){let U=W.content[Y.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 Y of T.data.delta.content){if(Y.type=="text"&&Y.text){let U=Y.text,G=W.content[Y.index];if(G&&G.type=="text")this._emit("textDelta",U,G.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(Y.index!=r(this,TT,"f")){if(r(this,_0,"f"))switch(r(this,_0,"f").type){case"text":this._emit("textDone",r(this,_0,"f").text,r(this,A6,"f"));break;case"image_file":this._emit("imageFileDone",r(this,_0,"f").image_file,r(this,A6,"f"));break}a4(this,TT,Y.index,"f")}a4(this,_0,W.content[Y.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(r(this,TT,"f")!==void 0){let Y=T.data.content[r(this,TT,"f")];if(Y)switch(Y.type){case"image_file":this._emit("imageFileDone",Y.image_file,r(this,A6,"f"));break;case"text":this._emit("textDone",Y.text,r(this,A6,"f"));break}}if(r(this,A6,"f"))this._emit("messageDone",T.data);a4(this,A6,void 0,"f")}},aF=function $(T){let W=r(this,Z4,"m",eF).call(this,T);switch(a4(this,w2,W,"f"),T.event){case"thread.run.step.created":this._emit("runStepCreated",T.data);break;case"thread.run.step.delta":let X=T.data.delta;if(X.step_details&&X.step_details.type=="tool_calls"&&X.step_details.tool_calls&&W.step_details.type=="tool_calls")for(let U of X.step_details.tool_calls)if(U.index==r(this,HY,"f"))this._emit("toolCallDelta",U,W.step_details.tool_calls[U.index]);else{if(r(this,s4,"f"))this._emit("toolCallDone",r(this,s4,"f"));if(a4(this,HY,U.index,"f"),a4(this,s4,W.step_details.tool_calls[U.index],"f"),r(this,s4,"f"))this._emit("toolCallCreated",r(this,s4,"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(a4(this,w2,void 0,"f"),T.data.step_details.type=="tool_calls"){if(r(this,s4,"f"))this._emit("toolCallDone",r(this,s4,"f")),a4(this,s4,void 0,"f")}this._emit("runStepDone",T.data,W);break;case"thread.run.step.in_progress":break}},sF=function $(T){r(this,gz,"f").push(T),this._emit("event",T)},eF=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 X=T.data;if(X.delta){let Y=e4.accumulateDelta(W,X.delta);r(this,b6,"f")[T.data.id]=Y}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")},$Q=function $(T,W){let X=[];switch(T.event){case"thread.message.created":return[T.data,X];case"thread.message.delta":if(!W)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let Y=T.data;if(Y.delta.content)for(let U of Y.delta.content)if(U.index in W.content){let G=W.content[U.index];W.content[U.index]=r(this,Z4,"m",TQ).call(this,U,G)}else W.content[U.index]=U,X.push(U);return[W,X];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(W)return[W,X];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},TQ=function $(T,W){return e4.accumulateDelta(W,T)},WQ=function $(T){switch(a4(this,_Y,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(a4(this,H0,T.data,"f"),r(this,s4,"f"))this._emit("toolCallDone",r(this,s4,"f")),a4(this,s4,void 0,"f");break;case"thread.run.cancelling":break}};function eR($){}class WT extends C{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(G$($))return this.list({},$);return this._client.getAPIList("/assistants",z2,{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 z2 extends O${}WT.AssistantsPage=z2;function mz($){return typeof $.parse==="function"}var k1=($)=>{return $?.role==="assistant"},cz=($)=>{return $?.role==="function"},uz=($)=>{return $?.role==="tool"};function _2($){return $?.$brand==="auto-parseable-response-format"}function F0($){return $?.$brand==="auto-parseable-tool"}function XQ($,T){if(!T||!pz(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 H2($,T)}function H2($,T){let W=$.choices.map((X)=>{if(X.finish_reason==="length")throw new rW;if(X.finish_reason==="content_filter")throw new iW;return{...X,message:{...X.message,...X.message.tool_calls?{tool_calls:X.message.tool_calls?.map((Y)=>WI(T,Y))??void 0}:void 0,parsed:X.message.content&&!X.message.refusal?TI(T,X.message.content):null}}});return{...$,choices:W}}function TI($,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 WI($,T){let W=$.tools?.find((X)=>X.function?.name===T.function.name);return{...T,function:{...T.function,parsed_arguments:F0(W)?W.$parseRaw(T.function.arguments):W?.function.strict?JSON.parse(T.function.arguments):null}}}function YQ($,T){if(!$)return!1;let W=$.tools?.find((X)=>X.function?.name===T.function.name);return F0(W)||W?.function.strict||!1}function pz($){if(_2($.response_format))return!0;return $.tools?.some((T)=>F0(T)||T.type==="function"&&T.function.strict===!0)??!1}function UQ($){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 y4=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},M4,oz,FY,dz,lz,rz,JQ,iz,GQ=10;class F2 extends z0{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",$),(cz($)||uz($))&&$.content)this._emit("functionCallResult",$.content);else if(k1($)&&$.function_call)this._emit("functionCall",$.function_call);else if(k1($)&&$.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(),y4(this,M4,"m",oz).call(this)}async finalMessage(){return await this.done(),y4(this,M4,"m",FY).call(this)}async finalFunctionCall(){return await this.done(),y4(this,M4,"m",dz).call(this)}async finalFunctionCallResult(){return await this.done(),y4(this,M4,"m",lz).call(this)}async totalUsage(){return await this.done(),y4(this,M4,"m",rz).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let $=this._chatCompletions[this._chatCompletions.length-1];if($)this._emit("finalChatCompletion",$);let T=y4(this,M4,"m",FY).call(this);if(T)this._emit("finalMessage",T);let W=y4(this,M4,"m",oz).call(this);if(W)this._emit("finalContent",W);let X=y4(this,M4,"m",dz).call(this);if(X)this._emit("finalFunctionCall",X);let Y=y4(this,M4,"m",lz).call(this);if(Y!=null)this._emit("finalFunctionCallResult",Y);if(this._chatCompletions.some((U)=>U.usage))this._emit("totalUsage",y4(this,M4,"m",rz).call(this))}async _createChatCompletion($,T,W){let X=W?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}y4(this,M4,"m",JQ).call(this,T);let Y=await $.chat.completions.create({...T,stream:!1},{...W,signal:this.controller.signal});return this._connected(),this._addChatCompletion(H2(Y,T))}async _runChatCompletion($,T,W){for(let X of T.messages)this._addMessage(X,!1);return await this._createChatCompletion($,T,W)}async _runFunctions($,T,W){let{function_call:Y="auto",stream:U,...G}=T,J=typeof Y!=="string"&&Y?.name,{maxChatCompletions:z=GQ}=W||{},w={};for(let _ of T.functions)w[_.name||_.function.name]=_;let H=T.functions.map((_)=>({name:_.name||_.function.name,parameters:_.parameters,description:_.description}));for(let _ of T.messages)this._addMessage(_,!1);for(let _=0;_<z;++_){let D=(await this._createChatCompletion($,{...G,function_call:Y,functions:H,messages:[...this.messages]},W)).choices[0]?.message;if(!D)throw new l("missing message in ChatCompletion response");if(!D.function_call)return;let{name:V,arguments:E}=D.function_call,R=w[V];if(!R){let k=`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:k});continue}else if(J&&J!==V){let k=`Invalid function_call: ${JSON.stringify(V)}. ${JSON.stringify(J)} requested. Please try again`;this._addMessage({role:"function",name:V,content:k});continue}let P;try{P=mz(R)?await R.parse(E):E}catch(k){this._addMessage({role:"function",name:V,content:k instanceof Error?k.message:String(k)});continue}let M=await R.function(P,this),N=y4(this,M4,"m",iz).call(this,M);if(this._addMessage({role:"function",name:V,content:N}),J)return}}async _runTools($,T,W){let{tool_choice:Y="auto",stream:U,...G}=T,J=typeof Y!=="string"&&Y?.function?.name,{maxChatCompletions:z=GQ}=W||{},w=T.tools.map((F)=>{if(F0(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 w)if(F.type==="function")H[F.function.name||F.function.function.name]=F.function;let _="tools"in T?w.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<z;++F){let V=(await this._createChatCompletion($,{...G,tool_choice:Y,tools:_,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 E of V.tool_calls){if(E.type!=="function")continue;let R=E.id,{name:P,arguments:M}=E.function,N=H[P];if(!N){let m=`Invalid tool_call: ${JSON.stringify(P)}. Available options are: ${Object.keys(H).map((J$)=>JSON.stringify(J$)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:R,content:m});continue}else if(J&&J!==P){let m=`Invalid tool_call: ${JSON.stringify(P)}. ${JSON.stringify(J)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:R,content:m});continue}let k;try{k=mz(N)?await N.parse(M):M}catch(m){let J$=m instanceof Error?m.message:String(m);this._addMessage({role:"tool",tool_call_id:R,content:J$});continue}let y=await N.function(k,this),x=y4(this,M4,"m",iz).call(this,y);if(this._addMessage({role:"tool",tool_call_id:R,content:x}),J)return}}return}}M4=new WeakSet,oz=function $(){return y4(this,M4,"m",FY).call(this).content??null},FY=function $(){let T=this.messages.length;while(T-- >0){let W=this.messages[T];if(k1(W)){let{function_call:X,...Y}=W,U={...Y,content:W.content??null,refusal:W.refusal??null};if(X)U.function_call=X;return U}}throw new l("stream ended without producing a ChatCompletionMessage with role=assistant")},dz=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(k1(W)&&W?.function_call)return W.function_call;if(k1(W)&&W?.tool_calls?.length)return W.tool_calls.at(-1)?.function}return},lz=function $(){for(let T=this.messages.length-1;T>=0;T--){let W=this.messages[T];if(cz(W)&&W.content!=null)return W.content;if(uz(W)&&W.content!=null&&typeof W.content==="string"&&this.messages.some((X)=>X.role==="assistant"&&X.tool_calls?.some((Y)=>Y.type==="function"&&Y.id===W.tool_call_id)))return W.content}return},rz=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},JQ=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.")},iz=function $(T){return typeof T==="string"?T:T===void 0?"undefined":JSON.stringify(T)};class XT extends F2{static runFunctions($,T,W){let X=new XT,Y={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return X._run(()=>X._runFunctions($,T,Y)),X}static runTools($,T,W){let X=new XT,Y={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return X._run(()=>X._runTools($,T,Y)),X}_addMessage($,T=!0){if(super._addMessage($,T),k1($)&&$.content)this._emit("content",$.content)}}var H4={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 wQ extends Error{}class zQ extends Error{}function XI($,T=H4.ALL){if(typeof $!=="string")throw new TypeError(`expecting str, got ${typeof $}`);if(!$.trim())throw new Error(`${$} is empty`);return YI($.trim(),T)}var YI=($,T)=>{let W=$.length,X=0,Y=(F)=>{throw new wQ(`${F} at position ${X}`)},U=(F)=>{throw new zQ(`${F} at position ${X}`)},G=()=>{if(_(),X>=W)Y("Unexpected end of input");if($[X]==='"')return J();if($[X]==="{")return z();if($[X]==="[")return w();if($.substring(X,X+4)==="null"||H4.NULL&T&&W-X<4&&"null".startsWith($.substring(X)))return X+=4,null;if($.substring(X,X+4)==="true"||H4.BOOL&T&&W-X<4&&"true".startsWith($.substring(X)))return X+=4,!0;if($.substring(X,X+5)==="false"||H4.BOOL&T&&W-X<5&&"false".startsWith($.substring(X)))return X+=5,!1;if($.substring(X,X+8)==="Infinity"||H4.INFINITY&T&&W-X<8&&"Infinity".startsWith($.substring(X)))return X+=8,1/0;if($.substring(X,X+9)==="-Infinity"||H4.MINUS_INFINITY&T&&1<W-X&&W-X<9&&"-Infinity".startsWith($.substring(X)))return X+=9,-1/0;if($.substring(X,X+3)==="NaN"||H4.NAN&T&&W-X<3&&"NaN".startsWith($.substring(X)))return X+=3,NaN;return H()},J=()=>{let F=X,D=!1;X++;while(X<W&&($[X]!=='"'||D&&$[X-1]==="\\"))D=$[X]==="\\"?!D:!1,X++;if($.charAt(X)=='"')try{return JSON.parse($.substring(F,++X-Number(D)))}catch(V){U(String(V))}else if(H4.STR&T)try{return JSON.parse($.substring(F,X-Number(D))+'"')}catch(V){return JSON.parse($.substring(F,$.lastIndexOf("\\"))+'"')}Y("Unterminated string literal")},z=()=>{X++,_();let F={};try{while($[X]!=="}"){if(_(),X>=W&&H4.OBJ&T)return F;let D=J();_(),X++;try{let V=G();Object.defineProperty(F,D,{value:V,writable:!0,enumerable:!0,configurable:!0})}catch(V){if(H4.OBJ&T)return F;else throw V}if(_(),$[X]===",")X++}}catch(D){if(H4.OBJ&T)return F;else Y("Expected '}' at end of object")}return X++,F},w=()=>{X++;let F=[];try{while($[X]!=="]")if(F.push(G()),_(),$[X]===",")X++}catch(D){if(H4.ARR&T)return F;Y("Expected ']' at end of array")}return X++,F},H=()=>{if(X===0){if($==="-"&&H4.NUM&T)Y("Not sure what '-' is");try{return JSON.parse($)}catch(D){if(H4.NUM&T)try{if($[$.length-1]===".")return JSON.parse($.substring(0,$.lastIndexOf(".")));return JSON.parse($.substring(0,$.lastIndexOf("e")))}catch(V){}U(String(D))}}let F=X;if($[X]==="-")X++;while($[X]&&!",]}".includes($[X]))X++;if(X==W&&!(H4.NUM&T))Y("Unterminated number literal");try{return JSON.parse($.substring(F,X))}catch(D){if($.substring(F,X)==="-"&&H4.NUM&T)Y("Not sure what '-' is");try{return JSON.parse($.substring(F,$.lastIndexOf("e")))}catch(V){U(String(V))}}},_=()=>{while(X<W&&`
66
- \r `.includes($[X]))X++};return G()},nz=($)=>XI($,H4.ALL^H4.NUM);var YT=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},N$=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},U4,e6,UT,q1,tz,QY,az,sz,ez,ZY,$7,_Q;class Q0 extends F2{constructor($){super();U4.add(this),e6.set(this,void 0),UT.set(this,void 0),q1.set(this,void 0),YT(this,e6,$,"f"),YT(this,UT,[],"f")}get currentChatCompletionSnapshot(){return N$(this,q1,"f")}static fromReadableStream($){let T=new Q0(null);return T._run(()=>T._fromReadableStream($)),T}static createChatCompletion($,T,W){let X=new Q0(T);return X._run(()=>X._runChatCompletion($,{...T,stream:!0},{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),X}async _createChatCompletion($,T,W){super._createChatCompletion;let X=W?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}N$(this,U4,"m",tz).call(this);let Y=await $.chat.completions.create({...T,stream:!0},{...W,signal:this.controller.signal});this._connected();for await(let U of Y)N$(this,U4,"m",az).call(this,U);if(Y.controller.signal?.aborted)throw new Y4;return this._addChatCompletion(N$(this,U4,"m",ZY).call(this))}async _fromReadableStream($,T){let W=T?.signal;if(W){if(W.aborted)this.controller.abort();W.addEventListener("abort",()=>this.controller.abort())}N$(this,U4,"m",tz).call(this),this._connected();let X=t4.fromReadableStream($,this.controller),Y;for await(let U of X){if(Y&&Y!==U.id)this._addChatCompletion(N$(this,U4,"m",ZY).call(this));N$(this,U4,"m",az).call(this,U),Y=U.id}if(X.controller.signal?.aborted)throw new Y4;return this._addChatCompletion(N$(this,U4,"m",ZY).call(this))}[(e6=new WeakMap,UT=new WeakMap,q1=new WeakMap,U4=new WeakSet,tz=function $(){if(this.ended)return;YT(this,q1,void 0,"f")},QY=function $(T){let W=N$(this,UT,"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},N$(this,UT,"f")[T.index]=W,W},az=function $(T){if(this.ended)return;let W=N$(this,U4,"m",_Q).call(this,T);this._emit("chunk",T,W);for(let X of T.choices){let Y=W.choices[X.index];if(X.delta.content!=null&&Y.message?.role==="assistant"&&Y.message?.content)this._emit("content",X.delta.content,Y.message.content),this._emit("content.delta",{delta:X.delta.content,snapshot:Y.message.content,parsed:Y.message.parsed});if(X.delta.refusal!=null&&Y.message?.role==="assistant"&&Y.message?.refusal)this._emit("refusal.delta",{delta:X.delta.refusal,snapshot:Y.message.refusal});if(X.logprobs?.content!=null&&Y.message?.role==="assistant")this._emit("logprobs.content.delta",{content:X.logprobs?.content,snapshot:Y.logprobs?.content??[]});if(X.logprobs?.refusal!=null&&Y.message?.role==="assistant")this._emit("logprobs.refusal.delta",{refusal:X.logprobs?.refusal,snapshot:Y.logprobs?.refusal??[]});let U=N$(this,U4,"m",QY).call(this,Y);if(Y.finish_reason){if(N$(this,U4,"m",ez).call(this,Y),U.current_tool_call_index!=null)N$(this,U4,"m",sz).call(this,Y,U.current_tool_call_index)}for(let G of X.delta.tool_calls??[]){if(U.current_tool_call_index!==G.index){if(N$(this,U4,"m",ez).call(this,Y),U.current_tool_call_index!=null)N$(this,U4,"m",sz).call(this,Y,U.current_tool_call_index)}U.current_tool_call_index=G.index}for(let G of X.delta.tool_calls??[]){let J=Y.message.tool_calls?.[G.index];if(!J?.type)continue;if(J?.type==="function")this._emit("tool_calls.function.arguments.delta",{name:J.function?.name,index:G.index,arguments:J.function.arguments,parsed_arguments:J.function.parsed_arguments,arguments_delta:G.function?.arguments??""});else FQ(J?.type)}}},sz=function $(T,W){if(N$(this,U4,"m",QY).call(this,T).done_tool_calls.has(W))return;let Y=T.message.tool_calls?.[W];if(!Y)throw new Error("no tool call snapshot");if(!Y.type)throw new Error("tool call snapshot missing `type`");if(Y.type==="function"){let U=N$(this,e6,"f")?.tools?.find((G)=>G.type==="function"&&G.function.name===Y.function.name);this._emit("tool_calls.function.arguments.done",{name:Y.function.name,index:W,arguments:Y.function.arguments,parsed_arguments:F0(U)?U.$parseRaw(Y.function.arguments):U?.function.strict?JSON.parse(Y.function.arguments):null})}else FQ(Y.type)},ez=function $(T){let W=N$(this,U4,"m",QY).call(this,T);if(T.message.content&&!W.content_done){W.content_done=!0;let X=N$(this,U4,"m",$7).call(this);this._emit("content.done",{content:T.message.content,parsed:X?X.$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})},ZY=function $(){if(this.ended)throw new l("stream has ended, this shouldn't happen");let T=N$(this,q1,"f");if(!T)throw new l("request ended without sending any chunks");return YT(this,q1,void 0,"f"),YT(this,UT,[],"f"),UI(T,N$(this,e6,"f"))},$7=function $(){let T=N$(this,e6,"f")?.response_format;if(_2(T))return T;return null},_Q=function $(T){var W,X,Y,U;let G=N$(this,q1,"f"),{choices:J,...z}=T;if(!G)G=YT(this,q1,{...z,choices:[]},"f");else Object.assign(G,z);for(let{delta:w,finish_reason:H,index:_,logprobs:F=null,...D}of T.choices){let V=G.choices[_];if(!V)V=G.choices[_]={finish_reason:H,index:_,message:{},logprobs:F,...D};if(F)if(!V.logprobs)V.logprobs=Object.assign({},F);else{let{content:y,refusal:x,...m}=F;if(HQ(m),Object.assign(V.logprobs,m),y)(W=V.logprobs).content??(W.content=[]),V.logprobs.content.push(...y);if(x)(X=V.logprobs).refusal??(X.refusal=[]),V.logprobs.refusal.push(...x)}if(H){if(V.finish_reason=H,N$(this,e6,"f")&&pz(N$(this,e6,"f"))){if(H==="length")throw new rW;if(H==="content_filter")throw new iW}}if(Object.assign(V,D),!w)continue;let{content:E,refusal:R,function_call:P,role:M,tool_calls:N,...k}=w;if(HQ(k),Object.assign(V.message,k),R)V.message.refusal=(V.message.refusal||"")+R;if(M)V.message.role=M;if(P)if(!V.message.function_call)V.message.function_call=P;else{if(P.name)V.message.function_call.name=P.name;if(P.arguments)(Y=V.message.function_call).arguments??(Y.arguments=""),V.message.function_call.arguments+=P.arguments}if(E){if(V.message.content=(V.message.content||"")+E,!V.message.refusal&&N$(this,U4,"m",$7).call(this))V.message.parsed=nz(V.message.content)}if(N){if(!V.message.tool_calls)V.message.tool_calls=[];for(let{index:y,id:x,type:m,function:J$,...m$}of N){let B=(U=V.message.tool_calls)[y]??(U[y]={});if(Object.assign(B,m$),x)B.id=x;if(m)B.type=m;if(J$)B.function??(B.function={name:J$.name??"",arguments:""});if(J$?.name)B.function.name=J$.name;if(J$?.arguments){if(B.function.arguments+=J$.arguments,YQ(N$(this,e6,"f"),B))B.function.parsed_arguments=nz(B.function.arguments)}}}}return G},Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("chunk",(X)=>{let Y=T.shift();if(Y)Y.resolve(X);else $.push(X)}),this.on("end",()=>{W=!0;for(let X of T)X.resolve(void 0);T.length=0}),this.on("abort",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),this.on("error",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((Y,U)=>T.push({resolve:Y,reject:U})).then((Y)=>Y?{value:Y,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 t4(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function UI($,T){let{id:W,choices:X,created:Y,model:U,system_fingerprint:G,...J}=$,z={...J,id:W,choices:X.map(({message:w,finish_reason:H,index:_,logprobs:F,...D})=>{if(!H)throw new l(`missing finish_reason for choice ${_}`);let{content:V=null,function_call:E,tool_calls:R,...P}=w,M=w.role;if(!M)throw new l(`missing role for choice ${_}`);if(E){let{arguments:N,name:k}=E;if(N==null)throw new l(`missing function_call.arguments for choice ${_}`);if(!k)throw new l(`missing function_call.name for choice ${_}`);return{...D,message:{content:V,function_call:{arguments:N,name:k},role:M,refusal:w.refusal??null},finish_reason:H,index:_,logprobs:F}}if(R)return{...D,index:_,finish_reason:H,logprobs:F,message:{...P,role:M,content:V,refusal:w.refusal??null,tool_calls:R.map((N,k)=>{let{function:y,type:x,id:m,...J$}=N,{arguments:m$,name:B,...Q$}=y||{};if(m==null)throw new l(`missing choices[${_}].tool_calls[${k}].id
67
- ${DY($)}`);if(x==null)throw new l(`missing choices[${_}].tool_calls[${k}].type
68
- ${DY($)}`);if(B==null)throw new l(`missing choices[${_}].tool_calls[${k}].function.name
69
- ${DY($)}`);if(m$==null)throw new l(`missing choices[${_}].tool_calls[${k}].function.arguments
70
- ${DY($)}`);return{...J$,id:m,type:x,function:{...Q$,name:B,arguments:m$}}})}};return{...D,message:{...P,content:V,role:M,refusal:w.refusal??null},finish_reason:H,index:_,logprobs:F}}),created:Y,model:U,object:"chat.completion",...G?{system_fingerprint:G}:{}};return XQ(z,T)}function DY($){return JSON.stringify($)}function HQ($){return}function FQ($){}class Z0 extends Q0{static fromReadableStream($){let T=new Z0(null);return T._run(()=>T._fromReadableStream($)),T}static runFunctions($,T,W){let X=new Z0(null),Y={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return X._run(()=>X._runFunctions($,T,Y)),X}static runTools($,T,W){let X=new Z0(T),Y={...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"runTools"}};return X._run(()=>X._runTools($,T,Y)),X}}class OY extends C{parse($,T){return UQ($.tools),this._client.chat.completions.create($,{...T,headers:{...T?.headers,"X-Stainless-Helper-Method":"beta.chat.completions.parse"}})._thenUnwrap((W)=>H2(W,$))}runFunctions($,T){if($.stream)return Z0.runFunctions(this._client,$,T);return XT.runFunctions(this._client,$,T)}runTools($,T){if($.stream)return Z0.runTools(this._client,$,T);return XT.runTools(this._client,$,T)}stream($,T){return Q0.createChatCompletion(this._client,$,T)}}class Q2 extends C{constructor(){super(...arguments);this.completions=new OY(this._client)}}(function($){$.Completions=OY})(Q2||(Q2={}));class Z2 extends C{create($,T){return this._client.post("/realtime/sessions",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class D2 extends C{create($,T){return this._client.post("/realtime/transcription_sessions",{body:$,...T,headers:{"OpenAI-Beta":"assistants=v2",...T?.headers}})}}class D0 extends C{constructor(){super(...arguments);this.sessions=new Z2(this._client),this.transcriptionSessions=new D2(this._client)}}D0.Sessions=Z2;D0.TranscriptionSessions=D2;class GT extends C{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,X){return this._client.post(`/threads/${$}/messages/${T}`,{body:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}list($,T={},W){if(G$(T))return this.list($,{},T);return this._client.getAPIList(`/threads/${$}/messages`,O2,{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 O2 extends O${}GT.MessagesPage=O2;class JT extends C{retrieve($,T,W,X={},Y){if(G$(X))return this.retrieve($,T,W,{},X);return this._client.get(`/threads/${$}/runs/${T}/steps/${W}`,{query:X,...Y,headers:{"OpenAI-Beta":"assistants=v2",...Y?.headers}})}list($,T,W={},X){if(G$(W))return this.list($,T,{},W);return this._client.getAPIList(`/threads/${$}/runs/${T}/steps`,V2,{query:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}}class V2 extends O${}JT.RunStepsPage=V2;class P1 extends C{constructor(){super(...arguments);this.steps=new JT(this._client)}create($,T,W){let{include:X,...Y}=T;return this._client.post(`/threads/${$}/runs`,{query:{include:X},body:Y,...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,X){return this._client.post(`/threads/${$}/runs/${T}`,{body:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}list($,T={},W){if(G$(T))return this.list($,{},T);return this._client.getAPIList(`/threads/${$}/runs`,K2,{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 X=await this.create($,T,W);return await this.poll($,X.id,W)}createAndStream($,T,W){return e4.createAssistantStream($,this._client.beta.threads.runs,T,W)}async poll($,T,W){let X={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)X["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let{data:Y,response:U}=await this.retrieve($,T,{...W,headers:{...W?.headers,...X}}).withResponse();switch(Y.status){case"queued":case"in_progress":case"cancelling":let G=5000;if(W?.pollIntervalMs)G=W.pollIntervalMs;else{let J=U.headers.get("openai-poll-after-ms");if(J){let z=parseInt(J);if(!isNaN(z))G=z}}await n6(G);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return Y}}}stream($,T,W){return e4.createAssistantStream($,this._client.beta.threads.runs,T,W)}submitToolOutputs($,T,W,X){return this._client.post(`/threads/${$}/runs/${T}/submit_tool_outputs`,{body:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers},stream:W.stream??!1})}async submitToolOutputsAndPoll($,T,W,X){let Y=await this.submitToolOutputs($,T,W,X);return await this.poll($,Y.id,X)}submitToolOutputsStream($,T,W,X){return e4.createToolAssistantStream($,T,this._client.beta.threads.runs,W,X)}}class K2 extends O${}P1.RunsPage=K2;P1.Steps=JT;P1.RunStepsPage=V2;class $1 extends C{constructor(){super(...arguments);this.runs=new P1(this._client),this.messages=new GT(this._client)}create($={},T){if(G$($))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 e4.createThreadAssistantStream($,this._client.beta.threads,T)}}$1.Runs=P1;$1.RunsPage=K2;$1.Messages=GT;$1.MessagesPage=O2;class f6 extends C{constructor(){super(...arguments);this.realtime=new D0(this._client),this.chat=new Q2(this._client),this.assistants=new WT(this._client),this.threads=new $1(this._client)}}f6.Realtime=D0;f6.Assistants=WT;f6.AssistantsPage=z2;f6.Threads=$1;class wT extends C{create($,T){return this._client.post("/completions",{body:$,...T,stream:$.stream??!1})}}class zT extends C{create($,T){let W=!!$.encoding_format,X=W?$.encoding_format:"base64";if(W)i6("Request","User defined encoding_format:",$.encoding_format);let Y=this._client.post("/embeddings",{body:{...$,encoding_format:X},...T});if(W)return Y;return i6("response","Decoding base64 embeddings to float32 array"),Y._thenUnwrap((U)=>{if(U&&U.data)U.data.forEach((G)=>{let J=G.embedding;G.embedding=iF(J)});return U})}}class _T extends C{retrieve($,T,W,X){return this._client.get(`/evals/${$}/runs/${T}/output_items/${W}`,X)}list($,T,W={},X){if(G$(W))return this.list($,T,{},W);return this._client.getAPIList(`/evals/${$}/runs/${T}/output_items`,E2,{query:W,...X})}}class E2 extends O${}_T.OutputItemListResponsesPage=E2;class C1 extends C{constructor(){super(...arguments);this.outputItems=new _T(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(G$(T))return this.list($,{},T);return this._client.getAPIList(`/evals/${$}/runs`,A2,{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 A2 extends O${}C1.RunListResponsesPage=A2;C1.OutputItems=_T;C1.OutputItemListResponsesPage=E2;class T1 extends C{constructor(){super(...arguments);this.runs=new C1(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(G$($))return this.list({},$);return this._client.getAPIList("/evals",HT,{query:$,...T})}del($,T){return this._client.delete(`/evals/${$}`,T)}}class HT extends O${}T1.EvalListResponsesPage=HT;T1.Runs=C1;T1.RunListResponsesPage=A2;class O0 extends C{create($,T){return this._client.post("/files",U6({body:$,...T}))}retrieve($,T){return this._client.get(`/files/${$}`,T)}list($={},T){if(G$($))return this.list({},$);return this._client.getAPIList("/files",FT,{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 X=new Set(["processed","error","deleted"]),Y=Date.now(),U=await this.retrieve($);while(!U.status||!X.has(U.status))if(await n6(T),U=await this.retrieve($),Date.now()-Y>W)throw new Y0({message:`Giving up on waiting for file ${$} to finish processing after ${W} milliseconds.`});return U}}class FT extends O${}O0.FileObjectsPage=FT;class M2 extends C{}class N2 extends C{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 QT extends C{constructor(){super(...arguments);this.graders=new N2(this._client)}}QT.Graders=N2;class ZT extends C{create($,T,W){return this._client.getAPIList(`/fine_tuning/checkpoints/${$}/permissions`,L2,{body:T,method:"post",...W})}retrieve($,T={},W){if(G$(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 L2 extends t6{}ZT.PermissionCreateResponsesPage=L2;class V0 extends C{constructor(){super(...arguments);this.permissions=new ZT(this._client)}}V0.Permissions=ZT;V0.PermissionCreateResponsesPage=L2;class DT extends C{list($,T={},W){if(G$(T))return this.list($,{},T);return this._client.getAPIList(`/fine_tuning/jobs/${$}/checkpoints`,S2,{query:T,...W})}}class S2 extends O${}DT.FineTuningJobCheckpointsPage=S2;class W1 extends C{constructor(){super(...arguments);this.checkpoints=new DT(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(G$($))return this.list({},$);return this._client.getAPIList("/fine_tuning/jobs",B2,{query:$,...T})}cancel($,T){return this._client.post(`/fine_tuning/jobs/${$}/cancel`,T)}listEvents($,T={},W){if(G$(T))return this.listEvents($,{},T);return this._client.getAPIList(`/fine_tuning/jobs/${$}/events`,R2,{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 B2 extends O${}class R2 extends O${}W1.FineTuningJobsPage=B2;W1.FineTuningJobEventsPage=R2;W1.Checkpoints=DT;W1.FineTuningJobCheckpointsPage=S2;class G6 extends C{constructor(){super(...arguments);this.methods=new M2(this._client),this.jobs=new W1(this._client),this.checkpoints=new V0(this._client),this.alpha=new QT(this._client)}}G6.Methods=M2;G6.Jobs=W1;G6.FineTuningJobsPage=B2;G6.FineTuningJobEventsPage=R2;G6.Checkpoints=V0;G6.Alpha=QT;class I2 extends C{}class K0 extends C{constructor(){super(...arguments);this.graderModels=new I2(this._client)}}K0.GraderModels=I2;class OT extends C{createVariation($,T){return this._client.post("/images/variations",U6({body:$,...T}))}edit($,T){return this._client.post("/images/edits",U6({body:$,...T}))}generate($,T){return this._client.post("/images/generations",{body:$,...T})}}class E0 extends C{retrieve($,T){return this._client.get(`/models/${$}`,T)}list($){return this._client.getAPIList("/models",VT,$)}del($,T){return this._client.delete(`/models/${$}`,T)}}class VT extends t6{}E0.ModelsPage=VT;class KT extends C{create($,T){return this._client.post("/moderations",{body:$,...T})}}function QQ($,T){if(!T||!RI(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((X)=>({...X,parsed:null}))};else return W})};return T7($,T)}function T7($,T){let W=$.output.map((Y)=>{if(Y.type==="function_call")return{...Y,parsed_arguments:qI(T,Y)};if(Y.type==="message"){let U=Y.content.map((G)=>{if(G.type==="output_text")return{...G,parsed:BI(T,G.text)};return G});return{...Y,content:U}}return Y}),X=Object.assign({},$,{output:W});if(!Object.getOwnPropertyDescriptor($,"output_text"))W7(X);return Object.defineProperty(X,"output_parsed",{enumerable:!0,get(){for(let Y of X.output){if(Y.type!=="message")continue;for(let U of Y.content)if(U.type==="output_text"&&U.parsed!==null)return U.parsed}return null}}),X}function BI($,T){if($.text?.format?.type!=="json_schema")return null;if("$parseRaw"in $.text?.format)return($.text?.format).$parseRaw(T);return JSON.parse(T)}function RI($){if(_2($.text?.format))return!0;return!1}function II($){return $?.$brand==="auto-parseable-tool"}function kI($,T){return $.find((W)=>W.type==="function"&&W.name===T)}function qI($,T){let W=kI($.tools??[],T.name);return{...T,...T,parsed_arguments:II(W)?W.$parseRaw(T.arguments):W?.strict?JSON.parse(T.arguments):null}}function W7($){let T=[];for(let W of $.output){if(W.type!=="message")continue;for(let X of W.content)if(X.type==="output_text")T.push(X.text)}$.output_text=T.join("")}class k2 extends C{list($,T={},W){if(G$(T))return this.list($,{},T);return this._client.getAPIList(`/responses/${$}/input_items`,X7,{query:T,...W})}}var ET=function($,T,W,X,Y){if(X==="m")throw new TypeError("Private method is not writable");if(X==="a"&&!Y)throw new TypeError("Private accessor was defined without a setter");if(typeof T==="function"?$!==T||!Y:!T.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?Y.call($,W):Y?Y.value=W:T.set($,W),W},v1=function($,T,W,X){if(W==="a"&&!X)throw new TypeError("Private accessor was defined without a getter");if(typeof T==="function"?$!==T||!X:!T.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?X:W==="a"?X.call($):X?X.value:T.get($)},AT,VY,j1,KY,ZQ,DQ,OQ,VQ;class EY extends z0{constructor($){super();AT.add(this),VY.set(this,void 0),j1.set(this,void 0),KY.set(this,void 0),ET(this,VY,$,"f")}static createResponse($,T,W){let X=new EY(T);return X._run(()=>X._createResponse($,T,{...W,headers:{...W?.headers,"X-Stainless-Helper-Method":"stream"}})),X}async _createResponse($,T,W){let X=W?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}v1(this,AT,"m",ZQ).call(this);let Y=await $.responses.create({...T,stream:!0},{...W,signal:this.controller.signal});this._connected();for await(let U of Y)v1(this,AT,"m",DQ).call(this,U);if(Y.controller.signal?.aborted)throw new Y4;return v1(this,AT,"m",OQ).call(this)}[(VY=new WeakMap,j1=new WeakMap,KY=new WeakMap,AT=new WeakSet,ZQ=function $(){if(this.ended)return;ET(this,j1,void 0,"f")},DQ=function $(T){if(this.ended)return;let W=v1(this,AT,"m",VQ).call(this,T);switch(this._emit("event",T),T.type){case"response.output_text.delta":{let X=W.output[T.output_index];if(!X)throw new l(`missing output at index ${T.output_index}`);if(X.type==="message"){let Y=X.content[T.content_index];if(!Y)throw new l(`missing content at index ${T.content_index}`);if(Y.type!=="output_text")throw new l(`expected content to be 'output_text', got ${Y.type}`);this._emit("response.output_text.delta",{...T,snapshot:Y.text})}break}case"response.function_call_arguments.delta":{let X=W.output[T.output_index];if(!X)throw new l(`missing output at index ${T.output_index}`);if(X.type==="function_call")this._emit("response.function_call_arguments.delta",{...T,snapshot:X.arguments});break}default:this._emit(T.type,T);break}},OQ=function $(){if(this.ended)throw new l("stream has ended, this shouldn't happen");let T=v1(this,j1,"f");if(!T)throw new l("request ended without sending any events");ET(this,j1,void 0,"f");let W=CI(T,v1(this,VY,"f"));return ET(this,KY,W,"f"),W},VQ=function $(T){let W=v1(this,j1,"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=ET(this,j1,T.response,"f"),W}switch(T.type){case"response.output_item.added":{W.output.push(T.item);break}case"response.content_part.added":{let X=W.output[T.output_index];if(!X)throw new l(`missing output at index ${T.output_index}`);if(X.type==="message")X.content.push(T.part);break}case"response.output_text.delta":{let X=W.output[T.output_index];if(!X)throw new l(`missing output at index ${T.output_index}`);if(X.type==="message"){let Y=X.content[T.content_index];if(!Y)throw new l(`missing content at index ${T.content_index}`);if(Y.type!=="output_text")throw new l(`expected content to be 'output_text', got ${Y.type}`);Y.text+=T.delta}break}case"response.function_call_arguments.delta":{let X=W.output[T.output_index];if(!X)throw new l(`missing output at index ${T.output_index}`);if(X.type==="function_call")X.arguments+=T.delta;break}case"response.completed":{ET(this,j1,T.response,"f");break}}return W},Symbol.asyncIterator)](){let $=[],T=[],W=!1;return this.on("event",(X)=>{let Y=T.shift();if(Y)Y.resolve(X);else $.push(X)}),this.on("end",()=>{W=!0;for(let X of T)X.resolve(void 0);T.length=0}),this.on("abort",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),this.on("error",(X)=>{W=!0;for(let Y of T)Y.reject(X);T.length=0}),{next:async()=>{if(!$.length){if(W)return{value:void 0,done:!0};return new Promise((Y,U)=>T.push({resolve:Y,reject:U})).then((Y)=>Y?{value:Y,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 $=v1(this,KY,"f");if(!$)throw new l("stream ended without producing a ChatCompletion");return $}}function CI($,T){return QQ($,T)}class A0 extends C{constructor(){super(...arguments);this.inputItems=new k2(this._client)}create($,T){return this._client.post("/responses",{body:$,...T,stream:$.stream??!1})._thenUnwrap((W)=>{if("object"in W&&W.object==="response")W7(W);return W})}retrieve($,T={},W){if(G$(T))return this.retrieve($,{},T);return this._client.get(`/responses/${$}`,{query:T,...W})}del($,T){return this._client.delete(`/responses/${$}`,{...T,headers:{Accept:"*/*",...T?.headers}})}parse($,T){return this._client.responses.create($,T)._thenUnwrap((W)=>T7(W,$))}stream($,T){return EY.createResponse(this._client,$,T)}}class X7 extends O${}A0.InputItems=k2;class q2 extends C{create($,T,W){return this._client.post(`/uploads/${$}/parts`,U6({body:T,...W}))}}class M0 extends C{constructor(){super(...arguments);this.parts=new q2(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})}}M0.Parts=q2;var KQ=async($)=>{let T=await Promise.allSettled($),W=T.filter((Y)=>Y.status==="rejected");if(W.length){for(let Y of W)console.error(Y.reason);throw new Error(`${W.length} promise(s) failed - see the above errors`)}let X=[];for(let Y of T)if(Y.status==="fulfilled")X.push(Y.value);return X};class N0 extends C{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,X){return this._client.post(`/vector_stores/${$}/files/${T}`,{body:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}list($,T={},W){if(G$(T))return this.list($,{},T);return this._client.getAPIList(`/vector_stores/${$}/files`,L0,{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 X=await this.create($,T,W);return await this.poll($,X.id,W)}async poll($,T,W){let X={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)X["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let Y=await this.retrieve($,T,{...W,headers:X}).withResponse(),U=Y.data;switch(U.status){case"in_progress":let G=5000;if(W?.pollIntervalMs)G=W.pollIntervalMs;else{let J=Y.response.headers.get("openai-poll-after-ms");if(J){let z=parseInt(J);if(!isNaN(z))G=z}}await n6(G);break;case"failed":case"completed":return U}}}async upload($,T,W){let X=await this._client.files.create({file:T,purpose:"assistants"},W);return this.create($,{file_id:X.id},W)}async uploadAndPoll($,T,W){let X=await this.upload($,T,W);return await this.poll($,X.id,W)}content($,T,W){return this._client.getAPIList(`/vector_stores/${$}/files/${T}/content`,P2,{...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class L0 extends O${}class P2 extends t6{}N0.VectorStoreFilesPage=L0;N0.FileContentResponsesPage=P2;class C2 extends C{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 X=await this.create($,T);return await this.poll($,X.id,W)}listFiles($,T,W={},X){if(G$(W))return this.listFiles($,T,{},W);return this._client.getAPIList(`/vector_stores/${$}/file_batches/${T}/files`,L0,{query:W,...X,headers:{"OpenAI-Beta":"assistants=v2",...X?.headers}})}async poll($,T,W){let X={...W?.headers,"X-Stainless-Poll-Helper":"true"};if(W?.pollIntervalMs)X["X-Stainless-Custom-Poll-Interval"]=W.pollIntervalMs.toString();while(!0){let{data:Y,response:U}=await this.retrieve($,T,{...W,headers:X}).withResponse();switch(Y.status){case"in_progress":let G=5000;if(W?.pollIntervalMs)G=W.pollIntervalMs;else{let J=U.headers.get("openai-poll-after-ms");if(J){let z=parseInt(J);if(!isNaN(z))G=z}}await n6(G);break;case"failed":case"cancelled":case"completed":return Y}}}async uploadAndPoll($,{files:T,fileIds:W=[]},X){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 Y=X?.maxConcurrency??5,U=Math.min(Y,T.length),G=this._client,J=T.values(),z=[...W];async function w(_){for(let F of _){let D=await G.files.create({file:F,purpose:"assistants"},X);z.push(D.id)}}let H=Array(U).fill(J).map(w);return await KQ(H),await this.createAndPoll($,{file_ids:z})}}class J6 extends C{constructor(){super(...arguments);this.files=new N0(this._client),this.fileBatches=new C2(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(G$($))return this.list({},$);return this._client.getAPIList("/vector_stores",MT,{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`,NT,{body:T,method:"post",...W,headers:{"OpenAI-Beta":"assistants=v2",...W?.headers}})}}class MT extends O${}class NT extends t6{}J6.VectorStoresPage=MT;J6.VectorStoreSearchResponsesPage=NT;J6.Files=N0;J6.VectorStoreFilesPage=L0;J6.FileContentResponsesPage=P2;J6.FileBatches=C2;var EQ;class U$ extends fz{constructor({baseURL:$=tW("OPENAI_BASE_URL"),apiKey:T=tW("OPENAI_API_KEY"),organization:W=tW("OPENAI_ORG_ID")??null,project:X=tW("OPENAI_PROJECT_ID")??null,...Y}={}){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 U={apiKey:T,organization:W,project:X,...Y,baseURL:$||"https://api.openai.com/v1"};if(!U.dangerouslyAllowBrowser&&rF())throw new l(`It looks like you're running in a browser-like environment.
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.
71
71
 
72
72
  This is disabled by default, as it risks exposing your secret API credentials to attackers.
73
73
  If you understand the risks and have appropriate mitigations in place,
@@ -76,21 +76,21 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
76
76
  new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
77
77
 
78
78
  https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
79
- `);super({baseURL:U.baseURL,timeout:U.timeout??600000,httpAgent:U.httpAgent,maxRetries:U.maxRetries,fetch:U.fetch});this.completions=new wT(this),this.chat=new I1(this),this.embeddings=new zT(this),this.files=new O0(this),this.images=new OT(this),this.audio=new a6(this),this.moderations=new KT(this),this.models=new E0(this),this.fineTuning=new G6(this),this.graders=new K0(this),this.vectorStores=new J6(this),this.beta=new f6(this),this.batches=new w0(this),this.uploads=new M0(this),this.responses=new A0(this),this.evals=new T1(this),this._options=U,this.apiKey=T,this.organization=W,this.project=X}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 Az($,{arrayFormat:"brackets"})}}EQ=U$;U$.OpenAI=EQ;U$.DEFAULT_TIMEOUT=600000;U$.OpenAIError=l;U$.APIError=t$;U$.APIConnectionError=X0;U$.APIConnectionTimeoutError=Y0;U$.APIUserAbortError=Y4;U$.NotFoundError=l8;U$.ConflictError=r8;U$.RateLimitError=n8;U$.BadRequestError=p8;U$.AuthenticationError=o8;U$.InternalServerError=t8;U$.PermissionDeniedError=d8;U$.UnprocessableEntityError=i8;U$.toFile=jz;U$.fileFromPath=u8;U$.Completions=wT;U$.Chat=I1;U$.ChatCompletionsPage=J0;U$.Embeddings=zT;U$.Files=O0;U$.FileObjectsPage=FT;U$.Images=OT;U$.Audio=a6;U$.Moderations=KT;U$.Models=E0;U$.ModelsPage=VT;U$.FineTuning=G6;U$.Graders=K0;U$.VectorStores=J6;U$.VectorStoresPage=MT;U$.VectorStoreSearchResponsesPage=NT;U$.Beta=f6;U$.Batches=w0;U$.BatchesPage=e0;U$.Uploads=M0;U$.Responses=A0;U$.Evals=T1;U$.EvalListResponsesPage=HT;var AQ=U$;function fI($,...T){let[W,X,Y,U]=T,G=[{role:"user",content:GF(X)},{role:"user",content:W}],J=U.at(-1);if(J)G.push({role:"user",content:["Oops! That didn't work. Here's what was returned last time:",JSON.stringify(J.response,null,2),"Here's the error message:",JSON.stringify(J.error.issues,null,2)].join(`
80
- `)});return{model:$,messages:G}}var a=1e6,MQ={"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 yI($){let W=Object.keys(MQ).filter((X)=>$.startsWith(X)).sort((X,Y)=>Y.length-X.length)[0];if(!W)return;return MQ[W]}function hI($){return async function T(W,X){if(!$)throw new Error("This is a bug in safegen. OpenAI client not available to the json generator.");let Y=await $.chat.completions.create({...W,stream:!1,response_format:{type:"json_object"}},X),U=Y.choices[0].message?.content,{usage:G}=Y;if(U&&G){let J=G.prompt_tokens,z=G.prompt_tokens_details?.cached_tokens??0,w=J-z,H=G.completion_tokens,_=yI(W.model),F=0;if(_)F=J*_.promptPricePerToken+w*(_.promptPricePerTokenCached??0)+H*_.completionPricePerToken;else console.warn(`No pricing facts found for model ${W.model}. Giving a price of 0.`);return{data:JSON.parse(U),usage:G,usdPrice:F}}if(!U&&!G)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 NQ=new Map,LQ=class{usdBudget;usdMinimum;getUnknownJsonFromOpenAi;getUnknownJsonFromOpenAiSquirreled;squirrel;client;lastUsage;constructor({model:$,usdBudget:T,usdMinimum:W,apiKey:X,cachingMode:Y,cacheKey:U="openai-safegen",logger:G}){this.usdBudget=T,this.usdMinimum=W,this.squirrel=new MF(Y);let J=NQ.get(X);if(Y!=="read"){if(!J)J=new AQ({apiKey:X,dangerouslyAllowBrowser:!1}),NQ.set(X,J);this.client=J}this.getUnknownJsonFromOpenAi=hI(this.client),this.getUnknownJsonFromOpenAiSquirreled=this.squirrel.add(U,this.getUnknownJsonFromOpenAi),this.from=UF(async(...z)=>{if(this.usdBudget<this.usdMinimum)return G?.warn("SafeGen budget exhausted"),z[2];let w=fI($,...z),H=z[0],_=z[3],{data:F,usage:D,usdPrice:V}=await this.getUnknownJsonFromOpenAiSquirreled.for(`${H.replace(/[^a-zA-Z0-9-_. ]/g,"_")}-${_.length}`).get(w);return this.lastUsage=D,this.usdBudget-=V,F},G)}from};import{exec as lv}from"child_process";class AY{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(X){try{if($ instanceof W)return{type:T,data:$}}catch(Y){}}return null}}var gI=new AY({number:($)=>typeof $==="number",string:($)=>typeof $==="string",boolean:($)=>typeof $==="boolean",null:($)=>$===null});function mI($){if(!$)return!1;return Object.getPrototypeOf($)===Object.prototype}var cI=new AY({object:mI,array:($)=>Array.isArray($)}),uI=new AY({...gI.supported,...cI.supported}),SQ=($)=>{if($===void 0)return"undefined";let T=uI.refine($);if(T)return T.type;return Object.getPrototypeOf($).constructor.name};var Z=Symbol.for("drizzle:entityKind"),fp=Symbol.for("drizzle:hasOwnEntityKind");function S($,T){if(!$||typeof $!=="object")return!1;if($ instanceof T)return!0;if(!Object.prototype.hasOwnProperty.call(T,Z))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(Z in W&&W[Z]===T[Z])return!0;W=Object.getPrototypeOf(W)}return!1}class S${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[Z]="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 Y7{static[Z]="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 U7{static[Z]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor($,T){if(this.reference=()=>{let{name:W,columns:X,foreignColumns:Y}=$();return{name:W,columns:X,foreignTable:Y[0].table,foreignColumns:Y}},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 BQ($,this)}}class BQ{constructor($,T){this.table=$,this.reference=T.reference,this.onUpdate=T._onUpdate,this.onDelete=T._onDelete}static[Z]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:T,foreignColumns:W}=this.reference(),X=T.map((G)=>G.name),Y=W.map((G)=>G.name),U=[this.table[M6],...X,W[0].table[M6],...Y];return $??`${U.join("_")}_fk`}}function MY($,...T){return $(...T)}function RQ($,T){return`${$[M6]}_${T.join("_")}_unique`}function IQ($,T,W){for(let X=T;X<$.length;X++){let Y=$[X];if(Y==="\\"){X++;continue}if(Y==='"')return[$.slice(T,X).replace(/\\/g,""),X+1];if(W)continue;if(Y===","||Y==="}")return[$.slice(T,X).replace(/\\/g,""),X]}return[$.slice(T).replace(/\\/g,""),$.length]}function kQ($,T=0){let W=[],X=T,Y=!1;while(X<$.length){let U=$[X];if(U===","){if(Y||X===T)W.push("");Y=!0,X++;continue}if(Y=!1,U==="\\"){X+=2;continue}if(U==='"'){let[z,w]=IQ($,X+1,!0);W.push(z),X=w;continue}if(U==="}")return[W,X+1];if(U==="{"){let[z,w]=kQ($,X+1);W.push(z),X=w;continue}let[G,J]=IQ($,X,!1);W.push(G),X=J}return[W,X]}function qQ($){let[T]=kQ($,1);return T}function G7($){return`{${$.map((T)=>{if(Array.isArray(T))return G7(T);if(typeof T==="string")return`"${T.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${T}`}).join(",")}}`}class o extends Y7{foreignKeyConfigs=[];static[Z]="PgColumnBuilder";array($){return new CQ(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:X})=>{return MY((Y,U)=>{let G=new U7(()=>{let J=Y();return{columns:[$],foreignColumns:[J]}});if(U.onUpdate)G.onUpdate(U.onUpdate);if(U.onDelete)G.onDelete(U.onDelete);return G.build(T)},W,X)})}buildExtraConfigColumn($){return new PQ($,this.config)}}class b extends S${constructor($,T){if(!T.uniqueName)T.uniqueName=RQ($,[T.name]);super($,T);this.table=$}static[Z]="PgColumn"}class PQ extends b{static[Z]="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 v2{static[Z]="IndexedColumn";constructor($,T,W,X){this.name=$,this.keyAsName=T,this.type=W,this.indexConfig=X}name;keyAsName;type;indexConfig}class CQ extends o{static[Z]="PgArrayBuilder";constructor($,T,W){super($,"array","PgArray");this.config.baseBuilder=T,this.config.size=W}build($){let T=this.config.baseBuilder.build($);return new J7($,this.config,T)}}class J7 extends b{constructor($,T,W,X){super($,T);this.baseColumn=W,this.range=X,this.size=T.size}size;static[Z]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue($){if(typeof $==="string")$=qQ($);return $.map((T)=>this.baseColumn.mapFromDriverValue(T))}mapToDriverValue($,T=!1){let W=$.map((X)=>X===null?null:S(this.baseColumn,J7)?this.baseColumn.mapToDriverValue(X,!0):this.baseColumn.mapToDriverValue(X));if(T)return W;return G7(W)}}class vQ extends o{static[Z]="PgEnumObjectColumnBuilder";constructor($,T){super($,"string","PgEnumObjectColumn");this.config.enum=T}build($){return new jQ($,this.config)}}class jQ extends b{static[Z]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}var NY=Symbol.for("drizzle:isPgEnum");function xQ($){return!!$&&typeof $==="function"&&NY in $&&$[NY]===!0}class bQ extends o{static[Z]="PgEnumColumnBuilder";constructor($,T){super($,"string","PgEnumColumn");this.config.enum=T}build($){return new fQ($,this.config)}}class fQ extends b{static[Z]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,T){super($,T);this.enum=T.enum}getSQLType(){return this.enum.enumName}}function j2($,T){return Array.isArray(T)?pI($,[...T],void 0):oI($,T,void 0)}function pI($,T,W){let X=Object.assign((Y)=>new bQ(Y??"",X),{enumName:$,enumValues:T,schema:W,[NY]:!0});return X}function oI($,T,W){let X=Object.assign((Y)=>new vQ(Y??"",X),{enumName:$,enumValues:Object.values(T),schema:W,[NY]:!0});return X}class G4{static[Z]="Subquery";constructor($,T,W,X=!1){this._={brand:"Subquery",sql:$,selectedFields:T,alias:W,isWith:X}}}class x2 extends G4{static[Z]="WithSubquery"}var yQ="0.43.1";var w7,z7,B$={startActiveSpan($,T){if(!w7)return T();if(!z7)z7=w7.trace.getTracer("drizzle-orm",yQ);return MY((W,X)=>X.startActiveSpan($,(Y)=>{try{return T(Y)}catch(U){throw Y.setStatus({code:W.SpanStatusCode.ERROR,message:U instanceof Error?U.message:"Unknown error"}),U}finally{Y.end()}}),w7,z7)}};var C$=Symbol.for("drizzle:ViewBaseConfig");var LY=Symbol.for("drizzle:Schema"),SY=Symbol.for("drizzle:Columns"),hQ=Symbol.for("drizzle:ExtraConfigColumns"),_7=Symbol.for("drizzle:OriginalName"),H7=Symbol.for("drizzle:BaseName"),b2=Symbol.for("drizzle:IsAlias"),gQ=Symbol.for("drizzle:ExtraConfigBuilder"),dI=Symbol.for("drizzle:IsDrizzleTable");class c{static[Z]="Table";static Symbol={Name:M6,Schema:LY,OriginalName:_7,Columns:SY,ExtraConfigColumns:hQ,BaseName:H7,IsAlias:b2,ExtraConfigBuilder:gQ};[M6];[_7];[LY];[SY];[hQ];[H7];[b2]=!1;[dI]=!0;[gQ]=void 0;constructor($,T,W){this[M6]=this[_7]=$,this[LY]=T,this[H7]=W}}function F4($){return $[M6]}function S0($){return`${$[LY]??"public"}.${$[M6]}`}function F7($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function lI($){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 J4{static[Z]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new p([this])}}class p{constructor($){this.queryChunks=$}static[Z]="SQL";decoder=cQ;shouldInlineParams=!1;append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return B$.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:X,escapeName:Y,escapeParam:U,prepareTyping:G,inlineParams:J,paramStartIndex:z}=W;return lI($.map((w)=>{if(S(w,J4))return{sql:w.value.join(""),params:[]};if(S(w,BY))return{sql:Y(w.value),params:[]};if(w===void 0)return{sql:"",params:[]};if(Array.isArray(w)){let H=[new J4("(")];for(let[_,F]of w.entries())if(H.push(F),_<w.length-1)H.push(new J4(", "));return H.push(new J4(")")),this.buildQueryFromSourceParams(H,W)}if(S(w,p))return this.buildQueryFromSourceParams(w.queryChunks,{...W,inlineParams:J||w.shouldInlineParams});if(S(w,c)){let H=w[c.Symbol.Schema],_=w[c.Symbol.Name];return{sql:H===void 0||w[b2]?Y(_):Y(H)+"."+Y(_),params:[]}}if(S(w,S$)){let H=X.getColumnCasing(w);if(T.invokeSource==="indexes")return{sql:Y(H),params:[]};let _=w.table[c.Symbol.Schema];return{sql:w.table[b2]||_===void 0?Y(w.table[c.Symbol.Name])+"."+Y(H):Y(_)+"."+Y(w.table[c.Symbol.Name])+"."+Y(H),params:[]}}if(S(w,h4)){let H=w[C$].schema,_=w[C$].name;return{sql:H===void 0||w[C$].isAlias?Y(_):Y(H)+"."+Y(_),params:[]}}if(S(w,$6)){if(S(w.value,x1))return{sql:U(z.value++,w),params:[w],typings:["none"]};let H=w.value===null?null:w.encoder.mapToDriverValue(w.value);if(S(H,p))return this.buildQueryFromSourceParams([H],W);if(J)return{sql:this.mapInlineParam(H,W),params:[]};let _=["none"];if(G)_=[G(w.encoder)];return{sql:U(z.value++,H),params:[H],typings:_}}if(S(w,x1))return{sql:U(z.value++,w),params:[w],typings:["none"]};if(S(w,p.Aliased)&&w.fieldAlias!==void 0)return{sql:Y(w.fieldAlias),params:[]};if(S(w,G4)){if(w._.isWith)return{sql:Y(w._.alias),params:[]};return this.buildQueryFromSourceParams([new J4("("),w._.sql,new J4(") "),new BY(w._.alias)],W)}if(xQ(w)){if(w.schema)return{sql:Y(w.schema)+"."+Y(w.enumName),params:[]};return{sql:Y(w.enumName),params:[]}}if(F7(w)){if(w.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([w.getSQL()],W);return this.buildQueryFromSourceParams([new J4("("),w.getSQL(),new J4(")")],W)}if(J)return{sql:this.mapInlineParam(w,W),params:[]};return{sql:U(z.value++,w),params:[w],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 BY{constructor($){this.value=$}static[Z]="Name";brand;getSQL(){return new p([this])}}function mQ($){return typeof $==="object"&&$!==null&&"mapToDriverValue"in $&&typeof $.mapToDriverValue==="function"}var cQ={mapFromDriverValue:($)=>$},uQ={mapToDriverValue:($)=>$},So={...cQ,...uQ};class $6{constructor($,T=uQ){this.value=$,this.encoder=T}static[Z]="Param";brand;getSQL(){return new p([this])}}function O($,...T){let W=[];if(T.length>0||$.length>0&&$[0]!=="")W.push(new J4($[0]));for(let[X,Y]of T.entries())W.push(Y,new J4($[X+1]));return new p(W)}(($)=>{function T(){return new p([])}$.empty=T;function W(z){return new p(z)}$.fromList=W;function X(z){return new p([new J4(z)])}$.raw=X;function Y(z,w){let H=[];for(let[_,F]of z.entries()){if(_>0&&w!==void 0)H.push(w);H.push(F)}return new p(H)}$.join=Y;function U(z){return new BY(z)}$.identifier=U;function G(z){return new x1(z)}$.placeholder=G;function J(z,w){return new $6(z,w)}$.param=J})(O||(O={}));(($)=>{class T{constructor(W,X){this.sql=W,this.fieldAlias=X}static[Z]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new T(this.sql,this.fieldAlias)}}$.Aliased=T})(p||(p={}));class x1{constructor($){this.name=$}static[Z]="Placeholder";getSQL(){return new p([this])}}function Q7($,T){return $.map((W)=>{if(S(W,x1)){if(!(W.name in T))throw new Error(`No value for placeholder "${W.name}" was provided`);return T[W.name]}if(S(W,$6)&&S(W.value,x1)){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 rI=Symbol.for("drizzle:IsDrizzleView");class h4{static[Z]="View";[C$];[rI]=!0;constructor({name:$,schema:T,selectedFields:W,query:X}){this[C$]={name:$,originalName:$,schema:T,selectedFields:W,query:X,isExisting:!X,isAlias:!1}}getSQL(){return new p([this])}}S$.prototype.getSQL=function(){return new p([this])};c.prototype.getSQL=function(){return new p([this])};G4.prototype.getSQL=function(){return new p([this])};class LT{constructor($){this.table=$}static[Z]="ColumnAliasProxyHandler";get($,T){if(T==="table")return this.table;return $[T]}}class f2{constructor($,T){this.alias=$,this.replaceOriginalName=T}static[Z]="TableAliasProxyHandler";get($,T){if(T===c.Symbol.IsAlias)return!0;if(T===c.Symbol.Name)return this.alias;if(this.replaceOriginalName&&T===c.Symbol.OriginalName)return this.alias;if(T===C$)return{...$[C$],name:this.alias,isAlias:!0};if(T===c.Symbol.Columns){let X=$[c.Symbol.Columns];if(!X)return X;let Y={};return Object.keys(X).map((U)=>{Y[U]=new Proxy(X[U],new LT(new Proxy($,this)))}),Y}let W=$[T];if(S(W,S$))return new Proxy(W,new LT(new Proxy($,this)));return W}}function RY($,T){return new Proxy($,new f2(T,!1))}function y6($,T){return new Proxy($,new LT(new Proxy($.table,new f2(T,!1))))}function Z7($,T){return new p.Aliased(y2($.sql,T),$.fieldAlias)}function y2($,T){return O.join($.queryChunks.map((W)=>{if(S(W,S$))return y6(W,T);if(S(W,p))return y2(W,T);if(S(W,p.Aliased))return Z7(W,T);return W}))}class IY extends Error{static[Z]="DrizzleError";constructor({message:$,cause:T}){super($);this.name="DrizzleError",this.cause=T}}class D7 extends IY{static[Z]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class pQ{static[Z]="ConsoleLogWriter";write($){console.log($)}}class O7{static[Z]="DefaultLogger";writer;constructor($){this.writer=$?.writer??new pQ}logQuery($,T){let W=T.map((Y)=>{try{return JSON.stringify(Y)}catch{return String(Y)}}),X=W.length?` -- params: [${W.join(", ")}]`:"";this.writer.write(`Query: ${$}${X}`)}}class V7{static[Z]="NoopLogger";logQuery(){}}class k4{static[Z]="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 oQ($,T,W){let X={},Y=$.reduce((U,{path:G,field:J},z)=>{let w;if(S(J,S$))w=J;else if(S(J,p))w=J.decoder;else w=J.sql.decoder;let H=U;for(let[_,F]of G.entries())if(_<G.length-1){if(!(F in H))H[F]={};H=H[F]}else{let D=T[z],V=H[F]=D===null?null:w.mapFromDriverValue(D);if(W&&S(J,S$)&&G.length===2){let E=G[0];if(!(E in X))X[E]=V===null?F4(J.table):!1;else if(typeof X[E]==="string"&&X[E]!==F4(J.table))X[E]=!1}}return U},{});if(W&&Object.keys(X).length>0){for(let[U,G]of Object.entries(X))if(typeof G==="string"&&!W[G])Y[U]=null}return Y}function w6($,T){return Object.entries($).reduce((W,[X,Y])=>{if(typeof X!=="string")return W;let U=T?[...T,X]:[X];if(S(Y,S$)||S(Y,p)||S(Y,p.Aliased))W.push({path:U,field:Y});else if(S(Y,c))W.push(...w6(Y[c.Symbol.Columns],U));else W.push(...w6(Y,U));return W},[])}function h2($,T){let W=Object.keys($),X=Object.keys(T);if(W.length!==X.length)return!1;for(let[Y,U]of W.entries())if(U!==X[Y])return!1;return!0}function kY($,T){let W=Object.entries(T).filter(([,X])=>X!==void 0).map(([X,Y])=>{if(S(Y,p)||S(Y,S$))return[X,Y];else return[X,new $6(Y,$[c.Symbol.Columns][X])]});if(W.length===0)throw new Error("No values to set");return Object.fromEntries(W)}function dQ($,T){for(let W of T)for(let X of Object.getOwnPropertyNames(W.prototype)){if(X==="constructor")continue;Object.defineProperty($.prototype,X,Object.getOwnPropertyDescriptor(W.prototype,X)||Object.create(null))}}function lQ($){return $[c.Symbol.Columns]}function X1($){return S($,G4)?$._.alias:S($,h4)?$[C$].name:S($,p)?void 0:$[c.Symbol.IsAlias]?$[c.Symbol.Name]:$[c.Symbol.BaseName]}function Z$($,T){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:T}}function rQ($){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 b1 extends o{static[Z]="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 iQ extends b1{static[Z]="PgBigInt53Builder";constructor($){super($,"number","PgBigInt53")}build($){return new nQ($,this.config)}}class nQ extends b{static[Z]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class tQ extends b1{static[Z]="PgBigInt64Builder";constructor($){super($,"bigint","PgBigInt64")}build($){return new aQ($,this.config)}}class aQ extends b{static[Z]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue($){return BigInt($)}}function sQ($,T){let{name:W,config:X}=Z$($,T);if(X.mode==="number")return new iQ(W);return new tQ(W)}class eQ extends o{static[Z]="PgBigSerial53Builder";constructor($){super($,"number","PgBigSerial53");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new $Z($,this.config)}}class $Z extends b{static[Z]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}}class TZ extends o{static[Z]="PgBigSerial64Builder";constructor($){super($,"bigint","PgBigSerial64");this.config.hasDefault=!0}build($){return new WZ($,this.config)}}class WZ extends b{static[Z]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue($){return BigInt($)}}function XZ($,T){let{name:W,config:X}=Z$($,T);if(X.mode==="number")return new eQ(W);return new TZ(W)}class YZ extends o{static[Z]="PgBooleanBuilder";constructor($){super($,"boolean","PgBoolean")}build($){return new UZ($,this.config)}}class UZ extends b{static[Z]="PgBoolean";getSQLType(){return"boolean"}}function g2($){return new YZ($??"")}class GZ extends o{static[Z]="PgCharBuilder";constructor($,T){super($,"string","PgChar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new JZ($,this.config)}}class JZ extends b{static[Z]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function wZ($,T={}){let{name:W,config:X}=Z$($,T);return new GZ(W,X)}class zZ extends o{static[Z]="PgCidrBuilder";constructor($){super($,"string","PgCidr")}build($){return new _Z($,this.config)}}class _Z extends b{static[Z]="PgCidr";getSQLType(){return"cidr"}}function HZ($){return new zZ($??"")}class FZ extends o{static[Z]="PgCustomColumnBuilder";constructor($,T,W){super($,"custom","PgCustomColumn");this.config.fieldConfig=T,this.config.customTypeParams=W}build($){return new QZ($,this.config)}}class QZ extends b{static[Z]="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 ZZ($){return(T,W)=>{let{name:X,config:Y}=Z$(T,W);return new FZ(X,Y,$)}}class Y1 extends o{static[Z]="PgDateColumnBaseBuilder";defaultNow(){return this.default(O`now()`)}}class DZ extends Y1{static[Z]="PgDateBuilder";constructor($){super($,"date","PgDate")}build($){return new qY($,this.config)}}class qY extends b{static[Z]="PgDate";getSQLType(){return"date"}mapFromDriverValue($){return new Date($)}mapToDriverValue($){return $.toISOString()}}class OZ extends Y1{static[Z]="PgDateStringBuilder";constructor($){super($,"string","PgDateString")}build($){return new PY($,this.config)}}class PY extends b{static[Z]="PgDateString";getSQLType(){return"date"}}function VZ($,T){let{name:W,config:X}=Z$($,T);if(X?.mode==="date")return new DZ(W);return new OZ(W)}class KZ extends o{static[Z]="PgDoublePrecisionBuilder";constructor($){super($,"number","PgDoublePrecision")}build($){return new EZ($,this.config)}}class EZ extends b{static[Z]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue($){if(typeof $==="string")return Number.parseFloat($);return $}}function AZ($){return new KZ($??"")}class MZ extends o{static[Z]="PgInetBuilder";constructor($){super($,"string","PgInet")}build($){return new NZ($,this.config)}}class NZ extends b{static[Z]="PgInet";getSQLType(){return"inet"}}function LZ($){return new MZ($??"")}class SZ extends b1{static[Z]="PgIntegerBuilder";constructor($){super($,"number","PgInteger")}build($){return new BZ($,this.config)}}class BZ extends b{static[Z]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue($){if(typeof $==="string")return Number.parseInt($);return $}}function m2($){return new SZ($??"")}class RZ extends o{static[Z]="PgIntervalBuilder";constructor($,T){super($,"string","PgInterval");this.config.intervalConfig=T}build($){return new IZ($,this.config)}}class IZ extends b{static[Z]="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 kZ($,T={}){let{name:W,config:X}=Z$($,T);return new RZ(W,X)}class qZ extends o{static[Z]="PgJsonBuilder";constructor($){super($,"json","PgJson")}build($){return new CY($,this.config)}}class CY extends b{static[Z]="PgJson";constructor($,T){super($,T)}getSQLType(){return"json"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function PZ($){return new qZ($??"")}class CZ extends o{static[Z]="PgJsonbBuilder";constructor($){super($,"json","PgJsonb")}build($){return new vY($,this.config)}}class vY extends b{static[Z]="PgJsonb";constructor($,T){super($,T)}getSQLType(){return"jsonb"}mapToDriverValue($){return JSON.stringify($)}mapFromDriverValue($){if(typeof $==="string")try{return JSON.parse($)}catch{return $}return $}}function vZ($){return new CZ($??"")}class jZ extends o{static[Z]="PgLineBuilder";constructor($){super($,"array","PgLine")}build($){return new xZ($,this.config)}}class xZ extends b{static[Z]="PgLine";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,X]=$.slice(1,-1).split(",");return[Number.parseFloat(T),Number.parseFloat(W),Number.parseFloat(X)]}mapToDriverValue($){return`{${$[0]},${$[1]},${$[2]}}`}}class bZ extends o{static[Z]="PgLineABCBuilder";constructor($){super($,"json","PgLineABC")}build($){return new fZ($,this.config)}}class fZ extends b{static[Z]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue($){let[T,W,X]=$.slice(1,-1).split(",");return{a:Number.parseFloat(T),b:Number.parseFloat(W),c:Number.parseFloat(X)}}mapToDriverValue($){return`{${$.a},${$.b},${$.c}}`}}function yZ($,T){let{name:W,config:X}=Z$($,T);if(!X?.mode||X.mode==="tuple")return new jZ(W);return new bZ(W)}class hZ extends o{static[Z]="PgMacaddrBuilder";constructor($){super($,"string","PgMacaddr")}build($){return new gZ($,this.config)}}class gZ extends b{static[Z]="PgMacaddr";getSQLType(){return"macaddr"}}function mZ($){return new hZ($??"")}class cZ extends o{static[Z]="PgMacaddr8Builder";constructor($){super($,"string","PgMacaddr8")}build($){return new uZ($,this.config)}}class uZ extends b{static[Z]="PgMacaddr8";getSQLType(){return"macaddr8"}}function pZ($){return new cZ($??"")}class oZ extends o{static[Z]="PgNumericBuilder";constructor($,T,W){super($,"string","PgNumeric");this.config.precision=T,this.config.scale=W}build($){return new jY($,this.config)}}class jY extends b{static[Z]="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 dZ extends o{static[Z]="PgNumericNumberBuilder";constructor($,T,W){super($,"number","PgNumericNumber");this.config.precision=T,this.config.scale=W}build($){return new lZ($,this.config)}}class lZ extends b{static[Z]="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 rZ extends o{static[Z]="PgNumericBigIntBuilder";constructor($,T,W){super($,"bigint","PgNumericBigInt");this.config.precision=T,this.config.scale=W}build($){return new iZ($,this.config)}}class iZ extends b{static[Z]="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 nZ($,T){let{name:W,config:X}=Z$($,T),Y=X?.mode;return Y==="number"?new dZ(W,X?.precision,X?.scale):Y==="bigint"?new rZ(W,X?.precision,X?.scale):new oZ(W,X?.precision,X?.scale)}class tZ extends o{static[Z]="PgPointTupleBuilder";constructor($){super($,"array","PgPointTuple")}build($){return new aZ($,this.config)}}class aZ extends b{static[Z]="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 sZ extends o{static[Z]="PgPointObjectBuilder";constructor($){super($,"json","PgPointObject")}build($){return new eZ($,this.config)}}class eZ extends b{static[Z]="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 $D($,T){let{name:W,config:X}=Z$($,T);if(!X?.mode||X.mode==="tuple")return new tZ(W);return new sZ(W)}function iI($){let T=[];for(let W=0;W<$.length;W+=2)T.push(Number.parseInt($.slice(W,W+2),16));return new Uint8Array(T)}function TD($,T){let W=new ArrayBuffer(8),X=new DataView(W);for(let Y=0;Y<8;Y++)X.setUint8(Y,$[T+Y]);return X.getFloat64(0,!0)}function K7($){let T=iI($),W=0,X=T[W];W+=1;let Y=new DataView(T.buffer),U=Y.getUint32(W,X===1);W+=4;let G;if(U&536870912)G=Y.getUint32(W,X===1),W+=4;if((U&65535)===1){let J=TD(T,W);W+=8;let z=TD(T,W);return W+=8,[J,z]}throw new Error("Unsupported geometry type")}class WD extends o{static[Z]="PgGeometryBuilder";constructor($){super($,"array","PgGeometry")}build($){return new XD($,this.config)}}class XD extends b{static[Z]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue($){return K7($)}mapToDriverValue($){return`point(${$[0]} ${$[1]})`}}class YD extends o{static[Z]="PgGeometryObjectBuilder";constructor($){super($,"json","PgGeometryObject")}build($){return new UD($,this.config)}}class UD extends b{static[Z]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue($){let T=K7($);return{x:T[0],y:T[1]}}mapToDriverValue($){return`point(${$.x} ${$.y})`}}function GD($,T){let{name:W,config:X}=Z$($,T);if(!X?.mode||X.mode==="tuple")return new WD(W);return new YD(W)}class JD extends o{static[Z]="PgRealBuilder";constructor($,T){super($,"number","PgReal");this.config.length=T}build($){return new wD($,this.config)}}class wD extends b{static[Z]="PgReal";constructor($,T){super($,T)}getSQLType(){return"real"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number.parseFloat($);return $}}function zD($){return new JD($??"")}class _D extends o{static[Z]="PgSerialBuilder";constructor($){super($,"number","PgSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new HD($,this.config)}}class HD extends b{static[Z]="PgSerial";getSQLType(){return"serial"}}function FD($){return new _D($??"")}class QD extends b1{static[Z]="PgSmallIntBuilder";constructor($){super($,"number","PgSmallInt")}build($){return new ZD($,this.config)}}class ZD extends b{static[Z]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=($)=>{if(typeof $==="string")return Number($);return $}}function DD($){return new QD($??"")}class OD extends o{static[Z]="PgSmallSerialBuilder";constructor($){super($,"number","PgSmallSerial");this.config.hasDefault=!0,this.config.notNull=!0}build($){return new VD($,this.config)}}class VD extends b{static[Z]="PgSmallSerial";getSQLType(){return"smallserial"}}function KD($){return new OD($??"")}class ED extends o{static[Z]="PgTextBuilder";constructor($,T){super($,"string","PgText");this.config.enumValues=T.enum}build($){return new AD($,this.config)}}class AD extends b{static[Z]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function MD($,T={}){let{name:W,config:X}=Z$($,T);return new ED(W,X)}class ND extends Y1{constructor($,T,W){super($,"string","PgTime");this.withTimezone=T,this.precision=W,this.config.withTimezone=T,this.config.precision=W}static[Z]="PgTimeBuilder";build($){return new xY($,this.config)}}class xY extends b{static[Z]="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 LD($,T={}){let{name:W,config:X}=Z$($,T);return new ND(W,X.withTimezone??!1,X.precision)}class SD extends Y1{static[Z]="PgTimestampBuilder";constructor($,T,W){super($,"date","PgTimestamp");this.config.withTimezone=T,this.config.precision=W}build($){return new bY($,this.config)}}class bY extends b{static[Z]="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 BD extends Y1{static[Z]="PgTimestampStringBuilder";constructor($,T,W){super($,"string","PgTimestampString");this.config.withTimezone=T,this.config.precision=W}build($){return new fY($,this.config)}}class fY extends b{static[Z]="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:X}=Z$($,T);if(X?.mode==="string")return new BD(W,X.withTimezone??!1,X.precision);return new SD(W,X?.withTimezone??!1,X?.precision)}class RD extends o{static[Z]="PgUUIDBuilder";constructor($){super($,"string","PgUUID")}defaultRandom(){return this.default(O`gen_random_uuid()`)}build($){return new yY($,this.config)}}class yY extends b{static[Z]="PgUUID";getSQLType(){return"uuid"}}function z6($){return new RD($??"")}class ID extends o{static[Z]="PgVarcharBuilder";constructor($,T){super($,"string","PgVarchar");this.config.length=T.length,this.config.enumValues=T.enum}build($){return new kD($,this.config)}}class kD extends b{static[Z]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function q4($,T={}){let{name:W,config:X}=Z$($,T);return new ID(W,X)}class qD extends o{static[Z]="PgBinaryVectorBuilder";constructor($,T){super($,"string","PgBinaryVector");this.config.dimensions=T.dimensions}build($){return new PD($,this.config)}}class PD extends b{static[Z]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function CD($,T){let{name:W,config:X}=Z$($,T);return new qD(W,X)}class vD extends o{static[Z]="PgHalfVectorBuilder";constructor($,T){super($,"array","PgHalfVector");this.config.dimensions=T.dimensions}build($){return new jD($,this.config)}}class jD extends b{static[Z]="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 xD($,T){let{name:W,config:X}=Z$($,T);return new vD(W,X)}class bD extends o{static[Z]="PgSparseVectorBuilder";constructor($,T){super($,"string","PgSparseVector");this.config.dimensions=T.dimensions}build($){return new fD($,this.config)}}class fD extends b{static[Z]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}function yD($,T){let{name:W,config:X}=Z$($,T);return new bD(W,X)}class hD extends o{static[Z]="PgVectorBuilder";constructor($,T){super($,"array","PgVector");this.config.dimensions=T.dimensions}build($){return new gD($,this.config)}}class gD extends b{static[Z]="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 mD($,T){let{name:W,config:X}=Z$($,T);return new hD(W,X)}function cD(){return{bigint:sQ,bigserial:XZ,boolean:g2,char:wZ,cidr:HZ,customType:ZZ,date:VZ,doublePrecision:AZ,inet:LZ,integer:m2,interval:kZ,json:PZ,jsonb:vZ,line:yZ,macaddr:mZ,macaddr8:pZ,numeric:nZ,point:$D,geometry:GD,real:zD,serial:FD,smallint:DD,smallserial:KD,text:MD,time:LD,timestamp:N6,uuid:z6,varchar:q4,bit:CD,halfvec:xD,sparsevec:yD,vector:mD}}var E7=Symbol.for("drizzle:PgInlineForeignKeys"),uD=Symbol.for("drizzle:EnableRLS");class D4 extends c{static[Z]="PgTable";static Symbol=Object.assign({},c.Symbol,{InlineForeignKeys:E7,EnableRLS:uD});[E7]=[];[uD]=!1;[c.Symbol.ExtraConfigBuilder]=void 0;[c.Symbol.ExtraConfigColumns]={}}function nI($,T,W,X,Y=$){let U=new D4($,X,Y),G=typeof T==="function"?T(cD()):T,J=Object.fromEntries(Object.entries(G).map(([H,_])=>{let F=_;F.setName(H);let D=F.build(U);return U[E7].push(...F.buildForeignKeys(D,U)),[H,D]})),z=Object.fromEntries(Object.entries(G).map(([H,_])=>{let F=_;F.setName(H);let D=F.buildExtraConfigColumn(U);return[H,D]})),w=Object.assign(U,J);if(w[c.Symbol.Columns]=J,w[c.Symbol.ExtraConfigColumns]=z,W)w[D4.Symbol.ExtraConfigBuilder]=W;return Object.assign(w,{enableRLS:()=>{return w[D4.Symbol.EnableRLS]=!0,w}})}var f1=($,T,W)=>{return nI($,T,W,void 0)};function pD(...$){if($[0].columns)return new c2($[0].columns,$[0].name);return new c2($)}class c2{static[Z]="PgPrimaryKeyBuilder";columns;name;constructor($,T){this.columns=$,this.name=T}build($){return new oD($,this.columns,this.name)}}class oD{constructor($,T,W){this.table=$,this.columns=T,this.name=W}static[Z]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[D4.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}function g4($,T){if(mQ(T)&&!F7($)&&!S($,$6)&&!S($,x1)&&!S($,S$)&&!S($,c)&&!S($,h4))return new $6($,T);return $}var hY=($,T)=>{return O`${$} = ${g4(T,$)}`},dD=($,T)=>{return O`${$} <> ${g4(T,$)}`};function u2(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new p(T);return new p([new J4("("),O.join(T,new J4(" and ")),new J4(")")])}function lD(...$){let T=$.filter((W)=>W!==void 0);if(T.length===0)return;if(T.length===1)return new p(T);return new p([new J4("("),O.join(T,new J4(" or ")),new J4(")")])}function rD($){return O`not ${$}`}var gY=($,T)=>{return O`${$} > ${g4(T,$)}`},iD=($,T)=>{return O`${$} >= ${g4(T,$)}`},nD=($,T)=>{return O`${$} < ${g4(T,$)}`},tD=($,T)=>{return O`${$} <= ${g4(T,$)}`};function aD($,T){if(Array.isArray(T)){if(T.length===0)return O`false`;return O`${$} in ${T.map((W)=>g4(W,$))}`}return O`${$} in ${g4(T,$)}`}function sD($,T){if(Array.isArray(T)){if(T.length===0)return O`true`;return O`${$} not in ${T.map((W)=>g4(W,$))}`}return O`${$} not in ${g4(T,$)}`}function eD($){return O`${$} is null`}function $O($){return O`${$} is not null`}function TO($){return O`exists ${$}`}function WO($){return O`not exists ${$}`}function XO($,T,W){return O`${$} between ${g4(T,$)} and ${g4(W,$)}`}function YO($,T,W){return O`${$} not between ${g4(T,$)} and ${g4(W,$)}`}function UO($,T){return O`${$} like ${T}`}function GO($,T){return O`${$} not like ${T}`}function JO($,T){return O`${$} ilike ${T}`}function wO($,T){return O`${$} not ilike ${T}`}function zO($){return O`${$} asc`}function _O($){return O`${$} desc`}class A7{constructor($,T,W){this.sourceTable=$,this.referencedTable=T,this.relationName=W,this.referencedTableName=T[c.Symbol.Name]}static[Z]="Relation";referencedTableName;fieldName}class HO{constructor($,T){this.table=$,this.config=T}static[Z]="Relations"}class y1 extends A7{constructor($,T,W,X){super($,T,W?.relationName);this.config=W,this.isNullable=X}static[Z]="One";withFieldName($){let T=new y1(this.sourceTable,this.referencedTable,this.config,this.isNullable);return T.fieldName=$,T}}class p2 extends A7{constructor($,T,W){super($,T,W?.relationName);this.config=W}static[Z]="Many";withFieldName($){let T=new p2(this.sourceTable,this.referencedTable,this.config);return T.fieldName=$,T}}function FO(){return{and:u2,between:XO,eq:hY,exists:TO,gt:gY,gte:iD,ilike:JO,inArray:aD,isNull:eD,isNotNull:$O,like:UO,lt:nD,lte:tD,ne:dD,not:rD,notBetween:YO,notExists:WO,notLike:GO,notIlike:wO,notInArray:sD,or:lD,sql:O}}function QO(){return{sql:O,asc:zO,desc:_O}}function ZO($,T){if(Object.keys($).length===1&&"default"in $&&!S($.default,c))$=$.default;let W={},X={},Y={};for(let[U,G]of Object.entries($))if(S(G,c)){let J=S0(G),z=X[J];W[J]=U,Y[U]={tsName:U,dbName:G[c.Symbol.Name],schema:G[c.Symbol.Schema],columns:G[c.Symbol.Columns],relations:z?.relations??{},primaryKey:z?.primaryKey??[]};for(let H of Object.values(G[c.Symbol.Columns]))if(H.primary)Y[U].primaryKey.push(H);let w=G[c.Symbol.ExtraConfigBuilder]?.(G[c.Symbol.ExtraConfigColumns]);if(w){for(let H of Object.values(w))if(S(H,c2))Y[U].primaryKey.push(...H.columns)}}else if(S(G,HO)){let J=S0(G.table),z=W[J],w=G.config(T(G.table)),H;for(let[_,F]of Object.entries(w))if(z){let D=Y[z];if(D.relations[_]=F,H)D.primaryKey.push(...H)}else{if(!(J in X))X[J]={relations:{},primaryKey:H};X[J].relations[_]=F}}return{tables:Y,tableNamesMap:W}}function tI($){return function T(W,X){return new y1($,W,X,X?.fields.reduce((Y,U)=>Y&&U.notNull,!0)??!1)}}function aI($){return function T(W,X){return new p2($,W,X)}}function DO($,T,W){if(S(W,y1)&&W.config)return{fields:W.config.fields,references:W.config.references};let X=T[S0(W.referencedTable)];if(!X)throw new Error(`Table "${W.referencedTable[c.Symbol.Name]}" not found in schema`);let Y=$[X];if(!Y)throw new Error(`Table "${X}" not found in schema`);let U=W.sourceTable,G=T[S0(U)];if(!G)throw new Error(`Table "${U[c.Symbol.Name]}" not found in schema`);let J=[];for(let z of Object.values(Y.relations))if(W.relationName&&W!==z&&z.relationName===W.relationName||!W.relationName&&z.referencedTable===W.sourceTable)J.push(z);if(J.length>1)throw W.relationName?new Error(`There are multiple relations with name "${W.relationName}" in table "${X}"`):new Error(`There are multiple relations between "${X}" and "${W.sourceTable[c.Symbol.Name]}". Please specify relation name`);if(J[0]&&S(J[0],y1)&&J[0].config)return{fields:J[0].config.references,references:J[0].config.fields};throw new Error(`There is not enough information to infer relation "${G}.${W.fieldName}"`)}function OO($){return{one:tI($),many:aI($)}}function mY($,T,W,X,Y=(U)=>U){let U={};for(let[G,J]of X.entries())if(J.isJson){let z=T.relations[J.tsKey],w=W[G],H=typeof w==="string"?JSON.parse(w):w;U[J.tsKey]=S(z,y1)?H&&mY($,$[J.relationTableTsKey],H,J.selection,Y):H.map((_)=>mY($,$[J.relationTableTsKey],_,J.selection,Y))}else{let z=Y(W[G]),w=J.field,H;if(S(w,S$))H=w;else if(S(w,p))H=w.decoder;else H=w.sql.decoder;U[J.tsKey]=z===null?null:H.mapFromDriverValue(z)}return U}import mv from"path";import Mk from"os";import Nk from"fs";var cY=new Map,M7=new Map,N7=Symbol("OriginError"),ST={};class _6 extends Promise{constructor($,T,W,X,Y={}){let U,G;super((J,z)=>{U=J,G=z});this.tagged=Array.isArray($.raw),this.strings=$,this.args=T,this.handler=W,this.canceller=X,this.options=Y,this.state=null,this.statement=null,this.resolve=(J)=>(this.active=!1,U(J)),this.reject=(J)=>(this.active=!1,G(J)),this.active=!1,this.cancelled=null,this.executed=!1,this.signature="",this[N7]=this.handler.debug?new Error:this.tagged&&sI(this.strings)}get origin(){return(this.handler.debug?this[N7].stack:this.tagged&&M7.has(this.strings)?M7.get(this.strings):M7.set(this.strings,this[N7].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 X=new Promise((Y,U)=>{this.cursorFn=(G)=>{return Y({value:G,done:!1}),new Promise((J)=>W=J)},this.resolve=()=>(this.active=!1,Y({done:!0})),this.reject=(G)=>(this.active=!1,U(G))});return this.execute(),X},return(){return W&&W(ST),{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 sI($){if(cY.has($))return cY.get($);let T=Error.stackTraceLimit;return Error.stackTraceLimit=4,cY.set($,new Error),Error.stackTraceLimit=T,cY.get($)}class BT extends Error{constructor($){super($.message);this.name=this.constructor.name,Object.assign(this,$)}}var a$={connection:VO,postgres:KO,generic:EO,notSupported:AO};function VO($,T,W){let{host:X,port:Y}=W||T,U=Object.assign(new Error("write "+$+" "+(T.path||X+":"+Y)),{code:$,errno:$,address:T.path||X},T.path?{}:{port:Y});return Error.captureStackTrace(U,VO),U}function KO($){let T=new BT($);return Error.captureStackTrace(T,KO),T}function EO($,T){let W=Object.assign(new Error($+": "+T),{code:$});return Error.captureStackTrace(W,EO),W}function AO($){let T=Object.assign(new Error($+" (B) is not supported"),{code:"MESSAGE_NOT_SUPPORTED",name:$});return Error.captureStackTrace(T,AO),T}var eI={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 oY{then(){L7()}catch(){L7()}finally(){L7()}}class r2 extends oY{constructor($){super();this.value=rY($)}}class h6 extends oY{constructor($,T,W){super();this.value=$,this.type=T,this.array=W}}class dY extends oY{constructor($,T){super();this.first=$,this.rest=T}build($,T,W,X){let Y=$k.map(([U,G])=>({fn:G,i:$.search(U)})).sort((U,G)=>U.i-G.i).pop();return Y.i===-1?k7(this.first,X):Y.fn(this.first,this.rest,T,W,X)}}function lY($,T,W,X){let Y=$ instanceof h6?$.value:$;if(Y===void 0){if($ instanceof h6?$.value=X.transform.undefined:Y=$=X.transform.undefined,Y===void 0)throw a$.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return"$"+W.push($ instanceof h6?(T.push($.value),$.array?$.array[$.type||pY($.value)]||$.type||SO($.value):$.type):(T.push($),pY($)))}var NO=RO(eI);function R7($,T,W,X,Y,U){for(let G=1;G<$.strings.length;G++)T+=I7(T,W,X,Y,U)+$.strings[G],W=$.args[G];return T}function I7($,T,W,X,Y){return T instanceof dY?T.build($,W,X,Y):T instanceof _6?B7(T,W,X,Y):T instanceof r2?T.value:T&&T[0]instanceof _6?T.reduce((U,G)=>U+" "+B7(G,W,X,Y),""):lY(T,W,X,Y)}function B7($,T,W,X){return $.fragment=!0,R7($,$.strings[0],$.args[0],T,W,X)}function LO($,T,W,X,Y){return $.map((U)=>"("+X.map((G)=>I7("values",U[G],T,W,Y)).join(",")+")").join(",")}function MO($,T,W,X,Y){let U=Array.isArray($[0]),G=T.length?T.flat():Object.keys(U?$[0]:$);return LO(U?$:[$],W,X,G,Y)}function uY($,T,W,X,Y){if(typeof $==="string"&&($=[$].concat(T)),Array.isArray($))return k7($,Y);let U;return(T.length?T.flat():Object.keys($)).map((J)=>{return U=$[J],(U instanceof _6?B7(U,W,X,Y):U instanceof r2?U.value:lY(U,W,X,Y))+" as "+rY(Y.transform.column.to?Y.transform.column.to(J):J)}).join(",")}var $k=Object.entries({values:MO,in:(...$)=>{let T=MO(...$);return T==="()"?"(null)":T},select:uY,as:uY,returning:uY,"\\(":uY,update($,T,W,X,Y){return(T.length?T.flat():Object.keys($)).map((U)=>rY(Y.transform.column.to?Y.transform.column.to(U):U)+"="+I7("values",$[U],W,X,Y))},insert($,T,W,X,Y){let U=T.length?T.flat():Object.keys(Array.isArray($)?$[0]:$);return"("+k7(U,Y)+")values"+LO(Array.isArray($)?$:[$],W,X,U,Y)}}).map(([$,T])=>[new RegExp("((?:^|[\\s(])"+$+"(?:$|[\\s(]))(?![\\s\\S]*\\1)","i"),T]);function L7(){throw a$.generic("NOT_TAGGED_CALL","Query not called as a tagged template literal")}var{serializers:Tk,parsers:Wk}=NO;function SO($){if(Array.isArray($))return SO($[0]);return typeof $==="string"?1009:0}var BO=function($){let T=RO($||{});return{serializers:Object.assign({},Tk,T.serializers),parsers:Object.assign({},Wk,T.parsers)}};function RO($){return Object.keys($).reduce((T,W)=>{if($[W].from&&[].concat($[W].from).forEach((X)=>T.parsers[X]=$[W].parse),$[W].serialize)T.serializers[$[W].to]=$[W].serialize,$[W].from&&[].concat($[W].from).forEach((X)=>T.serializers[X]=$[W].serialize);return T},{parsers:{},serializers:{}})}function k7($,{transform:{column:T}}){return $.map((W)=>rY(T.to?T.to(W):W)).join(",")}var rY=function $(T){return'"'+T.replace(/"/g,'""').replace(/\./g,'"."')+'"'},pY=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,Yk=/"/g;function Uk($){return $.replace(Xk,"\\\\").replace(Yk,"\\\"")}var IO=function $(T,W,X,Y){if(Array.isArray(T)===!1)return T;if(!T.length)return"{}";let U=T[0],G=Y===1020?";":",";if(Array.isArray(U)&&!U.type)return"{"+T.map((J)=>$(J,W,X,Y)).join(G)+"}";return"{"+T.map((J)=>{if(J===void 0){if(J=X.transform.undefined,J===void 0)throw a$.generic("UNDEFINED_VALUE","Undefined values are not allowed")}return J===null?"null":'"'+Uk(W?W(J.type?J.value:J):""+J)+'"'}).join(G)+"}"},S7={i:0,char:null,str:"",quoted:!1,last:0},kO=function $(T,W,X){return S7.i=S7.last=0,qO(S7,T,W,X)};function qO($,T,W,X){let Y=[],U=X===1020?";":",";for(;$.i<T.length;$.i++){if($.char=T[$.i],$.quoted)if($.char==="\\")$.str+=T[++$.i];else if($.char==='"')Y.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,Y.push(qO($,T,W,X));else if($.char==="}"){$.quoted=!1,$.last<$.i&&Y.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;break}else if($.char===U&&$.p!=="}"&&$.p!=='"')Y.push(W?W(T.slice($.last,$.i)):T.slice($.last,$.i)),$.last=$.i+1;$.p=$.char}return $.last<$.i&&Y.push(W?W(T.slice($.last,$.i+1)):T.slice($.last,$.i+1)),Y}var B0=($)=>{let T=$[0];for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},R0=($)=>{let T=$[0].toUpperCase();for(let W=1;W<$.length;W++)T+=$[W]==="_"?$[++W].toUpperCase():$[W];return T},I0=($)=>$.replace(/_/g,"-"),o2=($)=>$.replace(/([A-Z])/g,"_$1").toLowerCase(),d2=($)=>($.slice(0,1)+$.slice(1).replace(/([A-Z])/g,"_$1")).toLowerCase(),l2=($)=>$.replace(/-/g,"_");function q7($){return function T(W,X){return typeof W==="object"&&W!==null&&(X.type===114||X.type===3802)?Array.isArray(W)?W.map((Y)=>T(Y,X)):Object.entries(W).reduce((Y,[U,G])=>Object.assign(Y,{[$(U)]:T(G,X)}),{}):W}}B0.column={from:B0};B0.value={from:q7(B0)};o2.column={to:o2};var P7={...B0};P7.column.to=o2;R0.column={from:R0};R0.value={from:q7(R0)};d2.column={to:d2};var C7={...R0};C7.column.to=d2;I0.column={from:I0};I0.value={from:q7(I0)};l2.column={to:l2};var v7={...I0};v7.column.to=l2;import PO from"net";import zk from"tls";import i2 from"crypto";import j7 from"stream";import{performance as CO}from"perf_hooks";class k0 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 T6=Gk;function Gk($=[]){let T=$.slice(),W=0;return{get length(){return T.length-W},remove:(X)=>{let Y=T.indexOf(X);return Y===-1?null:(T.splice(Y,1),X)},push:(X)=>(T.push(X),X),shift:()=>{let X=T[W++];if(W===T.length)W=0,T=[];else T[W-1]=void 0;return X}}}var N4=Buffer.allocUnsafe(256),Jk="BCcDdEFfHPpQSX".split("").reduce(($,T)=>{let W=T.charCodeAt(0);return $[T]=()=>{return N4[0]=W,L$.i=5,L$},$},{}),L$=Object.assign(wk,Jk,{N:String.fromCharCode(0),i:0,inc($){return L$.i+=$,L$},str($){let T=Buffer.byteLength($);return iY(T),L$.i+=N4.write($,L$.i,T,"utf8"),L$},i16($){return iY(2),N4.writeUInt16BE($,L$.i),L$.i+=2,L$},i32($,T){if(T||T===0)return N4.writeUInt32BE($,T),L$;return iY(4),N4.writeUInt32BE($,L$.i),L$.i+=4,L$},z($){return iY($),N4.fill(0,L$.i,L$.i+$),L$.i+=$,L$},raw($){return N4=Buffer.concat([N4.subarray(0,L$.i),$]),L$.i=N4.length,L$},end($=1){N4.writeUInt32BE(L$.i-$,$);let T=N4.subarray(0,L$.i);return L$.i=0,N4=Buffer.allocUnsafe(256),T}}),i=L$;function iY($){if(N4.length-L$.i<$){let T=N4,W=T.length;N4=Buffer.allocUnsafe(W+(W>>1)+$),T.copy(N4)}}function wk(){return L$.i=0,L$}var f7=xO,_k=1,h1=i().S().end(),vO=i().H().end(),Hk=i().i32(8).i32(80877103).end(8),Fk=Buffer.concat([i().E().str(i.N).i32(0).end(),h1]),Qk=i().D().str("S").str(i.N).end(),RT=()=>{},Zk=new Set(["FetchPreparedStatement","RevalidateCachedQuery","transformAssignedExpr"]),Dk={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 xO($,T={},{onopen:W=RT,onend:X=RT,onclose:Y=RT}={}){let{ssl:U,max:G,user:J,host:z,port:w,database:H,parsers:_,transform:F,onnotice:D,onnotify:V,onparameter:E,max_pipeline:R,keep_alive:P,backoff:M,target_session_attrs:N}=$,k=T6(),y=_k++,x={pid:null,secret:null},m=b7(yU,$.idle_timeout),J$=b7(yU,$.max_lifetime),m$=b7(EA,$.connect_timeout),B=null,Q$,$$=new k0,H$=Buffer.alloc(0),e$=$.fetch_types,O4={},D6={},y0=Math.random().toString(36).slice(2),v=1,e=0,A$=0,g$=0,$4=0,_$=0,I$=0,i$=0,c$=null,x$=null,V4=!1,k$=null,O6=null,K4=null,O1=null,T4=null,b$=null,V6=null,k6=null,h=null,nT=null,E4={queue:T.closed,idleTimer:m,connect(Q){K4=Q||!0,I5()},terminate:aT,execute:tT,cancel:DA,end:yU,count:0,id:y};return T.closed&&T.closed.push(E4),E4;async function ZA(){let Q;try{Q=$.socket?await Promise.resolve($.socket($)):new PO.Socket}catch(A){g0(A);return}return Q.on("error",g0),Q.on("close",k5),Q.on("drain",B5),Q}async function DA({pid:Q,secret:A},t,V$){try{Q$=i().i32(16).i32(80877102).i32(Q).i32(A).end(16),await R5(),B.once("error",V$),B.once("close",t)}catch(d$){V$(d$)}}function tT(Q){if(V4)return PX(Q,a$.connection("CONNECTION_DESTROYED",$));if(Q.cancelled)return;try{return Q.state=x,h?k.push(Q):(h=Q,h.active=!0),KA(Q),Q4(OA(Q))&&!Q.describeFirst&&!Q.cursorFn&&k.length<R&&(!Q.options.onexecute||Q.options.onexecute(E4))}catch(A){return k.length===0&&Q4(h1),q6(A),!0}}function OA(Q){if(Q.parameters.length>=65534)throw a$.generic("MAX_PARAMETERS_EXCEEDED","Max number of parameters (65534) exceeded");return Q.options.simple?i().Q().str(Q.statement.string+i.N).end():Q.describeFirst?Buffer.concat([N5(Q),vO]):Q.prepare?Q.prepared?qX(Q):Buffer.concat([N5(Q),qX(Q)]):VA(Q)}function N5(Q){return Buffer.concat([P5(Q.statement.string,Q.parameters,Q.statement.types,Q.statement.name),XM("S",Q.statement.name)])}function qX(Q){return Buffer.concat([WM(Q.parameters,Q.statement.types,Q.statement.name,Q.cursorName),Q.cursorFn?C5("",Q.cursorRows):Fk])}function VA(Q){return Buffer.concat([P5(Q.statement.string,Q.parameters,Q.statement.types),Qk,qX(Q)])}function KA(Q){let A=[],t=[],V$=R7(Q,Q.strings[0],Q.args[0],A,t,$);!Q.tagged&&Q.args.forEach((d$)=>lY(d$,A,t,$)),Q.prepare=$.prepare&&("prepare"in Q.options?Q.options.prepare:!0),Q.string=V$,Q.signature=Q.prepare&&t+V$,Q.onlyDescribe&&delete D6[Q.signature],Q.parameters=Q.parameters||A,Q.prepared=Q.prepare&&Q.signature in D6,Q.describeFirst=Q.onlyDescribe||A.length&&!Q.prepared,Q.statement=Q.prepared?D6[Q.signature]:{string:V$,types:t,name:Q.prepare?y0+v++:""},typeof $.debug==="function"&&$.debug(y,V$,A,t)}function Q4(Q,A){if(b$=b$?Buffer.concat([b$,Q]):Buffer.from(Q),A||b$.length>=1024)return L5(A);return x$===null&&(x$=setImmediate(L5)),!0}function L5(Q){let A=B.write(b$,Q);return x$!==null&&clearImmediate(x$),b$=x$=null,A}function EA(){q6(a$.connection("CONNECT_TIMEOUT",$,B)),B.destroy()}async function S5(){if(Q4(Hk),!await new Promise((A)=>B.once("data",(t)=>A(t[0]===83)))&&U==="prefer")return h0();B.removeAllListeners(),B=zk.connect({socket:B,servername:PO.isIP(B.host)?void 0:B.host,...U==="require"||U==="allow"||U==="prefer"?{rejectUnauthorized:!1}:U==="verify-full"?{}:typeof U==="object"?U:{}}),B.on("secureConnect",h0),B.on("error",g0),B.on("close",k5),B.on("drain",B5)}function B5(){!h&&W(E4)}function fU(Q){if(k$){if(k$.push(Q),A$-=Q.length,A$>=0)return}H$=k$?Buffer.concat(k$,_$-A$):H$.length===0?Q:Buffer.concat([H$,Q],H$.length+Q.length);while(H$.length>4){if(_$=H$.readUInt32BE(1),_$>=H$.length){A$=_$-H$.length,k$=[H$];break}try{AA(H$.subarray(0,_$+1))}catch(A){h&&(h.cursorFn||h.describeFirst)&&Q4(h1),q6(A)}H$=H$.subarray(_$+1),A$=0,k$=null}}async function R5(){if(V4=!1,O4={},B||(B=await ZA()),!B)return;if(m$.start(),$.socket)return U?S5():h0();if(B.on("connect",U?S5:h0),$.path)return B.connect($.path);B.ssl=U,B.connect(w[g$],z[g$]),B.host=z[g$],B.port=w[g$],g$=(g$+1)%w.length}function I5(){setTimeout(R5,e?e+I$-CO.now():0)}function h0(){try{D6={},e$=$.fetch_types,y0=Math.random().toString(36).slice(2),v=1,J$.start(),B.on("data",fU),P&&B.setKeepAlive&&B.setKeepAlive(!0,1000*P);let Q=UM();Q4(Q)}catch(Q){g0(Q)}}function g0(Q){if(E4.queue===T.connecting&&$.host[$4+1])return;q6(Q);while(k.length)PX(k.shift(),Q)}function q6(Q){T4&&(T4.destroy(Q),T4=null),h&&PX(h,Q),K4&&(PX(K4,Q),K4=null)}function PX(Q,A){"query"in A||"parameters"in A||Object.defineProperties(A,{stack:{value:A.stack+Q.origin.replace(/.*\n/,`
81
- `),enumerable:$.debug},query:{value:Q.string,enumerable:$.debug},parameters:{value:Q.parameters,enumerable:$.debug},args:{value:Q.args,enumerable:$.debug},types:{value:Q.statement&&Q.statement.types,enumerable:$.debug}}),Q.reject(A)}function yU(){return O1||(!E4.reserved&&X(E4),!E4.reserved&&!K4&&!h&&k.length===0?(aT(),new Promise((Q)=>B&&B.readyState!=="closed"?B.once("close",Q):Q())):O1=new Promise((Q)=>V6=Q))}function aT(){if(V4=!0,T4||h||K4||k.length)g0(a$.connection("CONNECTION_DESTROYED",$));if(clearImmediate(x$),B)B.removeListener("data",fU),B.removeListener("connect",h0),B.readyState==="open"&&B.end(i().X().end());V6&&(V6(),O1=V6=null)}async function k5(Q){if(H$=Buffer.alloc(0),A$=0,k$=null,clearImmediate(x$),B.removeListener("data",fU),B.removeListener("connect",h0),m.cancel(),J$.cancel(),m$.cancel(),B.removeAllListeners(),B=null,K4)return I5();!Q&&(h||k.length)&&g0(a$.connection("CONNECTION_CLOSED",$,B)),e=CO.now(),Q&&$.shared.retries++,I$=(typeof M==="function"?M($.shared.retries):M)*1000,Y(E4,a$.connection("CONNECTION_CLOSED",$,B))}function AA(Q,A=Q[0]){(A===68?MA:A===100?iA:A===65?uA:A===83?NA:A===90?LA:A===67?SA:A===50?q5:A===49?BA:A===116?RA:A===84?IA:A===82?kA:A===110?xA:A===75?bA:A===69?mA:A===115?pA:A===51?oA:A===71?dA:A===78?tA:A===72?lA:A===99?nA:A===73?aA:A===86?sA:A===118?eA:A===87?rA:$M)(Q)}function MA(Q){let A=7,t,V$,d$,A4=h.isRaw?new Array(h.statement.columns.length):{};for(let B4=0;B4<h.statement.columns.length;B4++)V$=h.statement.columns[B4],t=Q.readInt32BE(A),A+=4,d$=t===-1?null:h.isRaw===!0?Q.subarray(A,A+=t):V$.parser===void 0?Q.toString("utf8",A,A+=t):V$.parser.array===!0?V$.parser(Q.toString("utf8",A+1,A+=t)):V$.parser(Q.toString("utf8",A,A+=t)),h.isRaw?A4[B4]=h.isRaw===!0?d$:F.value.from?F.value.from(d$,V$):d$:A4[V$.name]=F.value.from?F.value.from(d$,V$):d$;h.forEachFn?h.forEachFn(F.row.from?F.row.from(A4):A4,$$):$$[i$++]=F.row.from?F.row.from(A4):A4}function NA(Q){let[A,t]=Q.toString("utf8",5,Q.length-1).split(i.N);if(O4[A]=t,$.parameters[A]!==t)$.parameters[A]=t,E&&E(A,t)}function LA(Q){if(h&&h.options.simple&&h.resolve(O6||$$),h=O6=null,$$=new k0,m$.cancel(),K4){if(N){if(!O4.in_hot_standby||!O4.default_transaction_read_only)return gA();else if(hA(N,O4))return aT()}if(e$)return K4===!0&&(K4=null),fA();K4!==!0&&tT(K4),$.shared.retries=$4=0,K4=null;return}while(k.length&&(h=k.shift())&&(h.active=!0,h.cancelled))xO($).cancel(h.state,h.cancelled.resolve,h.cancelled.reject);if(h)return;E4.reserved?!E4.reserved.release&&Q[5]===73?O1?aT():(E4.reserved=null,W(E4)):E4.reserved():O1?aT():W(E4)}function SA(Q){i$=0;for(let A=Q.length-1;A>0;A--){if(Q[A]===32&&Q[A+1]<58&&$$.count===null)$$.count=+Q.toString("utf8",A+1,Q.length-1);if(Q[A-1]>=65){$$.command=Q.toString("utf8",5,A),$$.state=x;break}}if(nT&&(nT(),nT=null),$$.command==="BEGIN"&&G!==1&&!E4.reserved)return q6(a$.generic("UNSAFE_TRANSACTION","Only use sql.begin, sql.reserved or max: 1"));if(h.options.simple)return q5();if(h.cursorFn)$$.count&&h.cursorFn($$),Q4(h1);h.resolve($$)}function BA(){h.parsing=!1}function q5(){!$$.statement&&($$.statement=h.statement),$$.columns=h.statement.columns}function RA(Q){let A=Q.readUInt16BE(5);for(let t=0;t<A;++t)!h.statement.types[t]&&(h.statement.types[t]=Q.readUInt32BE(7+t*4));h.prepare&&(D6[h.signature]=h.statement),h.describeFirst&&!h.onlyDescribe&&(Q4(qX(h)),h.describeFirst=!1)}function IA(Q){if($$.command)O6=O6||[$$],O6.push($$=new k0),$$.count=null,h.statement.columns=null;let A=Q.readUInt16BE(5),t=7,V$;h.statement.columns=Array(A);for(let d$=0;d$<A;++d$){V$=t;while(Q[t++]!==0);let A4=Q.readUInt32BE(t),B4=Q.readUInt16BE(t+4),V1=Q.readUInt32BE(t+6);h.statement.columns[d$]={name:F.column.from?F.column.from(Q.toString("utf8",V$,t-1)):Q.toString("utf8",V$,t-1),parser:_[V1],table:A4,number:B4,type:V1},t+=18}if($$.statement=h.statement,h.onlyDescribe)return h.resolve(h.statement),Q4(h1)}async function kA(Q,A=Q.readUInt32BE(5)){(A===3?qA:A===5?PA:A===10?CA:A===11?vA:A===12?jA:A!==0?TM:RT)(Q,A)}async function qA(){let Q=await hU();Q4(i().p().str(Q).z(1).end())}async function PA(Q){let A="md5"+await jO(Buffer.concat([Buffer.from(await jO(await hU()+J)),Q.subarray(9)]));Q4(i().p().str(A).z(1).end())}async function CA(){k6=(await i2.randomBytes(18)).toString("base64"),i().p().str("SCRAM-SHA-256"+i.N);let Q=i.i;Q4(i.inc(4).str("n,,n=*,r="+k6).i32(i.i-Q-4,Q).end())}async function vA(Q){let A=Q.toString("utf8",9).split(",").reduce((B4,V1)=>(B4[V1[0]]=V1.slice(2),B4),{}),t=await i2.pbkdf2Sync(await hU(),Buffer.from(A.s,"base64"),parseInt(A.i),32,"sha256"),V$=await nY(t,"Client Key"),d$="n=*,r="+k6+",r="+A.r+",s="+A.s+",i="+A.i+",c=biws,r="+A.r;c$=(await nY(await nY(t,"Server Key"),d$)).toString("base64");let A4="c=biws,r="+A.r+",p="+Vk(V$,Buffer.from(await nY(await Ok(V$),d$))).toString("base64");Q4(i().p().str(A4).end())}function jA(Q){if(Q.toString("utf8",9).split(i.N,1)[0].slice(2)===c$)return;q6(a$.generic("SASL_SIGNATURE_MISMATCH","The server did not return the correct signature")),B.destroy()}function hU(){return Promise.resolve(typeof $.pass==="function"?$.pass():$.pass)}function xA(){if($$.statement=h.statement,$$.statement.columns=[],h.onlyDescribe)return h.resolve(h.statement),Q4(h1)}function bA(Q){x.pid=Q.readUInt32BE(5),x.secret=Q.readUInt32BE(9)}async function fA(){e$=!1,(await new _6([`
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([`
82
82
  select b.oid, b.typarray
83
83
  from pg_catalog.pg_type a
84
84
  left join pg_catalog.pg_type b on b.oid = a.typelem
85
85
  where a.typcategory = 'A'
86
86
  group by b.oid, b.typarray
87
87
  order by b.oid
88
- `],[],tT)).forEach(({oid:A,typarray:t})=>yA(A,t))}function yA(Q,A){if(!!$.parsers[A]&&!!$.serializers[A])return;let t=$.parsers[Q];$.shared.typeArrayMap[Q]=A,$.parsers[A]=(V$)=>kO(V$,t,A),$.parsers[A].array=!0,$.serializers[A]=(V$)=>IO(V$,$.serializers[Q],$,A)}function hA(Q,A){return Q==="read-write"&&A.default_transaction_read_only==="on"||Q==="read-only"&&A.default_transaction_read_only==="off"||Q==="primary"&&A.in_hot_standby==="on"||Q==="standby"&&A.in_hot_standby==="off"||Q==="prefer-standby"&&A.in_hot_standby==="off"&&$.host[$4]}function gA(){let Q=new _6([`
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([`
89
89
  show transaction_read_only;
90
90
  select pg_catalog.pg_is_in_recovery()
91
- `],[],tT,null,{simple:!0});Q.resolve=([[A],[t]])=>{O4.default_transaction_read_only=A.transaction_read_only,O4.in_hot_standby=t.pg_is_in_recovery?"on":"off"},Q.execute()}function mA(Q){h&&(h.cursorFn||h.describeFirst)&&Q4(h1);let A=a$.postgres(x7(Q));h&&h.retried?q6(h.retried):h&&h.prepared&&Zk.has(A.routine)?cA(h,A):q6(A)}function cA(Q,A){delete D6[Q.signature],Q.retried=A,tT(Q)}function uA(Q){if(!V)return;let A=9;while(Q[A++]!==0);V(Q.toString("utf8",9,A-1),Q.toString("utf8",A,Q.length-1))}async function pA(){try{let Q=await Promise.resolve(h.cursorFn($$));i$=0,Q===ST?Q4(YM(h.portal)):($$=new k0,Q4(C5("",h.cursorRows)))}catch(Q){Q4(h1),h.reject(Q)}}function oA(){$$.count&&h.cursorFn($$),h.resolve($$)}function dA(){T4=new j7.Writable({autoDestroy:!0,write(Q,A,t){B.write(i().d().raw(Q).end(),t)},destroy(Q,A){A(Q),B.write(i().f().str(Q+i.N).end()),T4=null},final(Q){B.write(i().c().end()),nT=Q}}),h.resolve(T4)}function lA(){T4=new j7.Readable({read(){B.resume()}}),h.resolve(T4)}function rA(){T4=new j7.Duplex({autoDestroy:!0,read(){B.resume()},write(Q,A,t){B.write(i().d().raw(Q).end(),t)},destroy(Q,A){A(Q),B.write(i().f().str(Q+i.N).end()),T4=null},final(Q){B.write(i().c().end()),nT=Q}}),h.resolve(T4)}function iA(Q){T4&&(T4.push(Q.subarray(5))||B.pause())}function nA(){T4&&T4.push(null),T4=null}function tA(Q){D?D(x7(Q)):console.log(x7(Q))}function aA(){}function sA(){q6(a$.notSupported("FunctionCallResponse"))}function eA(){q6(a$.notSupported("NegotiateProtocolVersion"))}function $M(Q){console.error("Postgres.js : Unknown Message:",Q[0])}function TM(Q,A){console.error("Postgres.js : Unknown Auth:",A)}function WM(Q,A,t="",V$=""){let d$,A4;return i().B().str(V$+i.N).str(t+i.N).i16(0).i16(Q.length),Q.forEach((B4,V1)=>{if(B4===null)return i.i32(4294967295);A4=A[V1],Q[V1]=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 P5(Q,A,t,V$=""){return i().P().str(V$+i.N).str(Q+i.N).i16(A.length),A.forEach((d$,A4)=>i.i32(t[A4]||0)),i.end()}function XM(Q,A=""){return i().D().str(Q).str(A+i.N).end()}function C5(Q="",A=0){return Buffer.concat([i().E().str(Q+i.N).i32(A).end(),vO])}function YM(Q=""){return Buffer.concat([i().C().str("P").str(Q+i.N).end(),i().S().end()])}function UM(){return Q$||i().inc(4).i16(3).z(2).str(Object.entries(Object.assign({user:J,database:H,client_encoding:"UTF8"},$.connection)).filter(([,Q])=>Q).map(([Q,A])=>Q+i.N+A).join(i.N)).z(2).end(0)}}function x7($){let T={},W=5;for(let X=5;X<$.length-1;X++)if($[X]===0)T[Dk[$[W]]]=$.toString("utf8",W+1,X),W=X+1;return T}function jO($){return i2.createHash("md5").update($).digest("hex")}function nY($,T){return i2.createHmac("sha256",$).update(T).digest()}function Ok($){return i2.createHash("sha256").update($).digest()}function Vk($,T){let W=Math.max($.length,T.length),X=Buffer.allocUnsafe(W);for(let Y=0;Y<W;Y++)X[Y]=$[Y]^T[Y];return X}function b7($,T){if(T=typeof T==="function"?T():T,!T)return{cancel:RT,start:RT};let W;return{cancel(){W&&(clearTimeout(W),W=null)},start(){W&&clearTimeout(W),W=setTimeout(X,T*1000,arguments)}};function X(Y){$.apply(null,Y),W=null}}var bO=()=>{};function y7($,T){let W=new Map,X="postgresjs_"+Math.random().toString(36).slice(2),Y={},U,G,J=!1,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(J)return;G=null,Y.pid=Y.secret=void 0,F(await D(z,X,T.publications)),W.forEach((E)=>E.forEach(({onsubscribe:R})=>R()))},no_subscribe:!0}),w=z.end,H=z.close;return z.end=async()=>{return J=!0,G&&await new Promise((E)=>(G.once("close",E),G.end())),w()},z.close=async()=>{return G&&await new Promise((E)=>(G.once("close",E),G.end())),H()},_;async function _(E,R,P=bO,M=bO){if(E=Ak(E),!U)U=D(z,X,T.publications);let N={fn:R,onsubscribe:P},k=W.has(E)?W.get(E).add(N):W.set(E,new Set([N])).get(E),y=()=>{k.delete(N),k.size===0&&W.delete(E)};return U.then((x)=>{return F(x),P(),G&&G.on("error",M),{unsubscribe:y,state:Y,sql:z}})}function F(E){G=E.stream,Y.pid=E.state.pid,Y.secret=E.state.secret}async function D(E,R,P){if(!P)throw new Error("Missing publication names");let M=await E.unsafe(`CREATE_REPLICATION_SLOT ${R} TEMPORARY LOGICAL pgoutput NOEXPORT_SNAPSHOT`),[N]=M,k=await E.unsafe(`START_REPLICATION SLOT ${R} LOGICAL ${N.consistent_point} (proto_version '1', publication_names '${P}')`).writable(),y={lsn:Buffer.concat(N.consistent_point.split("/").map((B)=>Buffer.from(("00000000"+B).slice(-8),"hex")))};return k.on("data",m),k.on("error",x),k.on("close",E.close),{stream:k,state:M.state};function x(B){console.error("Unexpected error during logical streaming - reconnecting",B)}function m(B){if(B[0]===119)Ek(B.subarray(25),y,E.options.parsers,J$,T.transform);else if(B[0]===107&&B[17])y.lsn=B.subarray(1,9),m$()}function J$(B,Q$){let $$=Q$.relation.schema+"."+Q$.relation.table;V("*",B,Q$),V("*:"+$$,B,Q$),Q$.relation.keys.length&&V("*:"+$$+"="+Q$.relation.keys.map((H$)=>B[H$.name]),B,Q$),V(Q$.command,B,Q$),V(Q$.command+":"+$$,B,Q$),Q$.relation.keys.length&&V(Q$.command+":"+$$+"="+Q$.relation.keys.map((H$)=>B[H$.name]),B,Q$)}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),k.write(B)}}function V(E,R,P){W.has(E)&&W.get(E).forEach(({fn:M})=>M(R,P,E))}}function Kk($){return new Date(Date.UTC(2000,0,1)+Number($/BigInt(1000)))}function Ek($,T,W,X,Y){let U=(G,[J,z])=>(G[J.charCodeAt(0)]=z,G);Object.entries({R:(G)=>{let J=1,z=T[G.readUInt32BE(J)]={schema:G.toString("utf8",J+=4,J=G.indexOf(0,J))||"pg_catalog",table:G.toString("utf8",J+1,J=G.indexOf(0,J+1)),columns:Array(G.readUInt16BE(J+=2)),keys:[]};J+=2;let w=0,H;while(J<G.length)H=z.columns[w++]={key:G[J++],name:Y.column.from?Y.column.from(G.toString("utf8",J,J=G.indexOf(0,J))):G.toString("utf8",J,J=G.indexOf(0,J)),type:G.readUInt32BE(J+=1),parser:W[G.readUInt32BE(J)],atttypmod:G.readUInt32BE(J+=4)},H.key&&z.keys.push(H),J+=4},Y:()=>{},O:()=>{},B:(G)=>{T.date=Kk(G.readBigInt64BE(9)),T.lsn=G.subarray(1,9)},I:(G)=>{let J=1,z=T[G.readUInt32BE(J)],{row:w}=tY(G,z.columns,J+=7,Y);X(w,{command:"insert",relation:z})},D:(G)=>{let J=1,z=T[G.readUInt32BE(J)];J+=4;let w=G[J]===75;X(w||G[J]===79?tY(G,z.columns,J+=3,Y).row:null,{command:"delete",relation:z,key:w})},U:(G)=>{let J=1,z=T[G.readUInt32BE(J)];J+=4;let w=G[J]===75,H=w||G[J]===79?tY(G,z.columns,J+=3,Y):null;H&&(J=H.i);let{row:_}=tY(G,z.columns,J+3,Y);X(_,{command:"update",relation:z,key:w,old:H&&H.row})},T:()=>{},C:()=>{}}).reduce(U,{})[$[0]]($)}function tY($,T,W,X){let Y,U,G,J=X.raw?new Array(T.length):{};for(let z=0;z<T.length;z++)Y=$[W++],U=T[z],G=Y===110?null:Y===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))),X.raw?J[z]=X.raw===!0?G:X.value.from?X.value.from(G,U):G:J[U.name]=X.value.from?X.value.from(G,U):G;return{i:W,row:X.row.from?X.row.from(J):J}}function Ak($){let T=$.match(/^(\*|insert|update|delete)?:?([^.]+?\.?[^=]+)?=?(.+)?/i)||[];if(!T)throw new Error("Malformed subscribe pattern: "+$);let[,W,X,Y]=T;return(W||"*")+(X?":"+(X.indexOf(".")===-1?"public."+X:X):"")+(Y?"="+Y:"")}import fO from"stream";function h7($,T,W=393216){return new Promise(async(X,Y)=>{await $.begin(async(U)=>{let G;!T&&([{oid:T}]=await U`select lo_creat(-1) as oid`);let[{fd:J}]=await U`select lo_open(${T}, ${W}) as fd`,z={writable:H,readable:w,close:()=>U`select lo_close(${J})`.then(G),tell:()=>U`select lo_tell64(${J})`,read:(_)=>U`select loread(${J}, ${_}) as data`,write:(_)=>U`select lowrite(${J}, ${_})`,truncate:(_)=>U`select lo_truncate64(${J}, ${_})`,seek:(_,F=0)=>U`select lo_lseek64(${J}, ${_}, ${F})`,size:()=>U`
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`
92
92
  select
93
- lo_lseek64(${J}, location, 0) as position,
93
+ lo_lseek64(${w}, location, 0) as position,
94
94
  seek.size
95
95
  from (
96
96
  select
@@ -98,62 +98,63 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
98
98
  tell.location
99
99
  from (select lo_tell64($1) as location) tell
100
100
  ) seek
101
- `};return X(z),new Promise(async(_)=>G=_);async function w({highWaterMark:_=16384,start:F=0,end:D=1/0}={}){let V=D-F;return F&&await z.seek(F),new fO.Readable({highWaterMark:_,async read(E){let R=E>V?E-V:E;V-=E;let[{data:P}]=await z.read(R);if(this.push(P),P.length<E)this.push(null)}})}async function H({highWaterMark:_=16384,start:F=0}={}){return F&&await z.seek(F),new fO.Writable({highWaterMark:_,write(D,V,E){z.write(D).then(()=>E(),E)}})}}).catch(Y)})}Object.assign(aY,{PostgresError:BT,toPascal:R0,pascal:C7,toCamel:B0,camel:P7,toKebab:I0,kebab:v7,fromPascal:d2,fromCamel:o2,fromKebab:l2,BigInt:{to:20,from:[20],parse:($)=>BigInt($),serialize:($)=>$.toString()}});var IT=aY;function aY($,T){let W=Lk($,T),X=W.no_subscribe||y7(aY,{...W}),Y=!1,U=T6(),G=T6(),J=T6(),z=T6(),w=T6(),H=T6(),_=T6(),F=T6(),D={connecting:G,reserved:J,closed:z,ended:w,open:H,busy:_,full:F},V=[...Array(W.max)].map(()=>f7(W,D,{onopen:D6,onend:O4,onclose:y0})),E=R(J$);return Object.assign(E,{get parameters(){return W.parameters},largeObject:h7.bind(null,E),subscribe:X,CLOSE:ST,END:ST,PostgresError:BT,options:W,reserve:N,listen:P,begin:k,close:$$,end:Q$}),E;function R(v){return v.debug=W.debug,Object.entries(W.types).reduce((_$,[I$,i$])=>{return _$[I$]=(c$)=>new h6(c$,i$.to),_$},e),Object.assign(A$,{types:e,typed:e,unsafe:g$,notify:M,array:m,json:x,file:$4}),A$;function e(_$,I$){return new h6(_$,I$)}function A$(_$,...I$){return _$&&Array.isArray(_$.raw)?new _6(_$,I$,v,B):typeof _$==="string"&&!I$.length?new r2(W.transform.column.to?W.transform.column.to(_$):_$):new dY(_$,I$)}function g$(_$,I$=[],i$={}){return arguments.length===2&&!Array.isArray(I$)&&(i$=I$,I$=[]),new _6([_$],I$,v,B,{prepare:!1,...i$,simple:"simple"in i$?i$.simple:I$.length===0})}function $4(_$,I$=[],i$={}){return arguments.length===2&&!Array.isArray(I$)&&(i$=I$,I$=[]),new _6([],I$,(x$)=>{Nk.readFile(_$,"utf8",(V4,k$)=>{if(V4)return x$.reject(V4);x$.strings=[k$],v(x$)})},B,{...i$,simple:"simple"in i$?i$.simple:I$.length===0})}}async function P(v,e,A$){let g$={fn:e,onlisten:A$},$4=P.sql||(P.sql=aY({...W,max:1,idle_timeout:null,max_lifetime:null,fetch_types:!1,onclose(){Object.entries(P.channels).forEach(([x$,{listeners:V4}])=>{delete P.channels[x$],Promise.all(V4.map((k$)=>P(x$,k$.fn,k$.onlisten).catch(()=>{})))})},onnotify(x$,V4){x$ in P.channels&&P.channels[x$].listeners.forEach((k$)=>k$.fn(V4))}})),_$=P.channels||(P.channels={});if(v in _$){_$[v].listeners.push(g$);let x$=await _$[v].result;return g$.onlisten&&g$.onlisten(),{state:x$.state,unlisten:c$}}_$[v]={result:$4`listen ${$4.unsafe('"'+v.replace(/"/g,'""')+'"')}`,listeners:[g$]};let i$=await _$[v].result;return g$.onlisten&&g$.onlisten(),{state:i$.state,unlisten:c$};async function c$(){if(v in _$===!1)return;if(_$[v].listeners=_$[v].listeners.filter((x$)=>x$!==g$),_$[v].listeners.length)return;return delete _$[v],$4`unlisten ${$4.unsafe('"'+v.replace(/"/g,'""')+'"')}`}}async function M(v,e){return await E`select pg_notify(${v}, ${""+e})`}async function N(){let v=T6(),e=H.length?H.shift():await new Promise(($4)=>{U.push({reserve:$4}),z.length&&e$(z.shift())});y(e,J),e.reserved=()=>v.length?e.execute(v.shift()):y(e,J),e.reserved.release=!0;let A$=R(g$);return A$.release=()=>{e.reserved=null,D6(e)},A$;function g$($4){e.queue===F?v.push($4):e.execute($4)||y(e,F)}}async function k(v,e){!e&&(e=v,v="");let A$=T6(),g$=0,$4,_$=null;try{return await E.unsafe("begin "+v.replace(/[^a-z ]/ig,""),[],{onexecute:i$}).execute(),await Promise.race([I$($4,e),new Promise((c$,x$)=>$4.onclose=x$)])}catch(c$){throw c$}async function I$(c$,x$,V4){let k$=R(T4);k$.savepoint=O1,k$.prepare=(b$)=>_$=b$.replace(/[^a-z0-9$-_. ]/gi);let O6,K4;V4&&await k$`savepoint ${k$(V4)}`;try{if(K4=await new Promise((b$,V6)=>{let k6=x$(k$);Promise.resolve(Array.isArray(k6)?Promise.all(k6):k6).then(b$,V6)}),O6)throw O6}catch(b$){throw await(V4?k$`rollback to ${k$(V4)}`:k$`rollback`),b$ instanceof BT&&b$.code==="25P02"&&O6||b$}if(!V4)_$?await k$`prepare transaction '${k$.unsafe(_$)}'`:await k$`commit`;return K4;function O1(b$,V6){if(b$&&Array.isArray(b$.raw))return O1((k6)=>k6.apply(k6,arguments));return arguments.length===1&&(V6=b$,b$=null),I$(c$,V6,"s"+g$+++(b$?"_"+b$:""))}function T4(b$){b$.catch((V6)=>O6||(O6=V6)),c$.queue===F?A$.push(b$):c$.execute(b$)||y(c$,F)}}function i$(c$){$4=c$,y(c$,J),c$.reserved=()=>A$.length?c$.execute(A$.shift()):y(c$,J)}}function y(v,e){return v.queue.remove(v),e.push(v),v.queue=e,e===H?v.idleTimer.start():v.idleTimer.cancel(),v}function x(v){return new h6(v,3802)}function m(v,e){if(!Array.isArray(v))return m(Array.from(arguments));return new h6(v,e||(v.length?pY(v)||25:0),W.shared.typeArrayMap)}function J$(v){if(Y)return v.reject(a$.connection("CONNECTION_ENDED",W,W));if(H.length)return m$(H.shift(),v);if(z.length)return e$(z.shift(),v);_.length?m$(_.shift(),v):U.push(v)}function m$(v,e){return v.execute(e)?y(v,_):y(v,F)}function B(v){return new Promise((e,A$)=>{v.state?v.active?f7(W).cancel(v.state,e,A$):v.cancelled={resolve:e,reject:A$}:(U.remove(v),v.cancelled=!0,v.reject(a$.generic("57014","canceling statement due to user request")),e())})}async function Q$({timeout:v=null}={}){if(Y)return Y;await 1;let e;return Y=Promise.race([new Promise((A$)=>v!==null&&(e=setTimeout(H$,v*1000,A$))),Promise.all(V.map((A$)=>A$.end()).concat(P.sql?P.sql.end({timeout:0}):[],X.sql?X.sql.end({timeout:0}):[]))]).then(()=>clearTimeout(e))}async function $$(){await Promise.all(V.map((v)=>v.end()))}async function H$(v){await Promise.all(V.map((e)=>e.terminate()));while(U.length)U.shift().reject(a$.connection("CONNECTION_DESTROYED",W));v()}function e$(v,e){return y(v,G),v.connect(e),v}function O4(v){y(v,w)}function D6(v){if(U.length===0)return y(v,H);let e=Math.ceil(U.length/(G.length+1)),A$=!0;while(A$&&U.length&&e-- >0){let g$=U.shift();if(g$.reserve)return g$.reserve(v);A$=v.execute(g$)}A$?y(v,_):y(v,F)}function y0(v,e){y(v,z),v.reserved=null,v.onclose&&(v.onclose(e),v.onclose=null),W.onclose&&W.onclose(v.id),U.length&&e$(v,U.shift())}}function Lk($,T){if($&&$.shared)return $;let W=process.env,X=(!$||typeof $==="string"?T:$)||{},{url:Y,multihost:U}=kk($),G=[...Y.searchParams].reduce((F,[D,V])=>(F[D]=V,F),{}),J=X.hostname||X.host||U||Y.hostname||W.PGHOST||"localhost",z=X.port||Y.port||W.PGPORT||5432,w=X.user||X.username||Y.username||W.PGUSERNAME||W.PGUSER||qk();X.no_prepare&&(X.prepare=!1),G.sslmode&&(G.ssl=G.sslmode,delete G.sslmode),"timeout"in X&&(console.log("The timeout option is deprecated, use idle_timeout instead"),X.idle_timeout=X.timeout),G.sslrootcert==="system"&&(G.ssl="verify-full");let H=["idle_timeout","connect_timeout","max_lifetime","max_pipeline","backoff","keep_alive"],_={max:10,ssl:!1,idle_timeout:null,connect_timeout:30,max_lifetime:Rk,max_pipeline:100,backoff:Bk,keep_alive:60,prepare:!0,debug:!1,fetch_types:!0,publications:"alltables",target_session_attrs:null};return{host:Array.isArray(J)?J:J.split(",").map((F)=>F.split(":")[0]),port:Array.isArray(z)?z:J.split(",").map((F)=>parseInt(F.split(":")[1]||z)),path:X.path||J.indexOf("/")>-1&&J+"/.s.PGSQL."+z,database:X.database||X.db||(Y.pathname||"").slice(1)||W.PGDATABASE||w,user:w,pass:X.pass||X.password||Y.password||W.PGPASSWORD||"",...Object.entries(_).reduce((F,[D,V])=>{let E=D in X?X[D]:(D in G)?G[D]==="disable"||G[D]==="false"?!1:G[D]:W["PG"+D.toUpperCase()]||V;return F[D]=typeof E==="string"&&H.includes(D)?+E:E,F},{}),connection:{application_name:"postgres.js",...X.connection,...Object.entries(G).reduce((F,[D,V])=>((D in _)||(F[D]=V),F),{})},types:X.types||{},target_session_attrs:Sk(X,Y,W),onnotice:X.onnotice,onnotify:X.onnotify,onclose:X.onclose,onparameter:X.onparameter,socket:X.socket,transform:Ik(X.transform||{undefined:void 0}),parameters:{},shared:{retries:0,typeArrayMap:{}},...BO(X.types)}}function Sk($,T,W){let X=$.target_session_attrs||T.searchParams.get("target_session_attrs")||W.PGTARGETSESSIONATTRS;if(!X||["read-write","read-only","primary","standby","prefer-standby"].includes(X))return X;throw new Error("target_session_attrs "+X+" is not supported")}function Bk($){return(0.5+Math.random()/2)*Math.min(3**$/100,20)}function Rk(){return 60*(30+Math.random()*30)}function Ik($){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 kk($){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 qk(){try{return Mk.userInfo().username}catch($){return process.env.USERNAME||process.env.USER||process.env.LOGNAME}}class r${static[Z]="SelectionProxyHandler";config;constructor($){this.config={...$}}get($,T){if(T==="_")return{...$._,selectedFields:new Proxy($._.selectedFields,this)};if(T===C$)return{...$[C$],selectedFields:new Proxy($[C$].selectedFields,this)};if(typeof T==="symbol")return $[T];let X=(S($,G4)?$._.selectedFields:S($,h4)?$[C$].selectedFields:$)[T];if(S(X,p.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!X.isSelectionField)return X.sql;let Y=X.clone();return Y.isSelectionField=!0,Y}if(S(X,p)){if(this.config.sqlBehavior==="sql")return X;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(S(X,S$)){if(this.config.alias)return new Proxy(X,new LT(new Proxy(X.table,new f2(this.config.alias,this.config.replaceOriginalName??!1))));return X}if(typeof X!=="object"||X===null)return X;return new Proxy(X,new r$(this.config))}}class sY extends k4{constructor($,T,W,X){super();this.session=T,this.dialect=W,this.config={table:$,withList:X}}static[Z]="PgDelete";config;where($){return this.config.where=$,this}returning($=this.config.table[c.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=w6($),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return B$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return B$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new r$({alias:F4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}function Pk($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map((W)=>W.toLowerCase()).join("_")}function Ck($){return($.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((W,X,Y)=>{let U=Y===0?X.toLowerCase():`${X[0].toUpperCase()}${X.slice(1)}`;return W+U},"")}function vk($){return $}class g7{static[Z]="CasingCache";cache={};cachedTables={};convert;constructor($){this.convert=$==="snake_case"?Pk:$==="camelCase"?Ck:vk}getColumnCasing($){if(!$.keyAsName)return $.name;let T=$.table[c.Symbol.Schema]??"public",W=$.table[c.Symbol.OriginalName],X=`${T}.${W}.${$.name}`;if(!this.cache[X])this.cacheTable($.table);return this.cache[X]}cacheTable($){let T=$[c.Symbol.Schema]??"public",W=$[c.Symbol.OriginalName],X=`${T}.${W}`;if(!this.cachedTables[X]){for(let Y of Object.values($[c.Symbol.Columns])){let U=`${X}.${Y.name}`;this.cache[U]=this.convert(Y.name)}this.cachedTables[X]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class n2 extends h4{static[Z]="PgViewBase"}class q0{static[Z]="PgDialect";casing;constructor($){this.casing=new g7($?.casing)}async migrate($,T,W){let X=typeof W==="string"?"__drizzle_migrations":W.migrationsTable??"__drizzle_migrations",Y=typeof W==="string"?"drizzle":W.migrationsSchema??"drizzle",U=O`
102
- CREATE TABLE IF NOT EXISTS ${O.identifier(Y)}.${O.identifier(X)} (
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
103
  id SERIAL PRIMARY KEY,
104
104
  hash text NOT NULL,
105
105
  created_at bigint
106
106
  )
107
- `;await T.execute(O`CREATE SCHEMA IF NOT EXISTS ${O.identifier(Y)}`),await T.execute(U);let J=(await T.all(O`select id, hash, created_at from ${O.identifier(Y)}.${O.identifier(X)} order by created_at desc limit 1`))[0];await T.transaction(async(z)=>{for await(let w of $)if(!J||Number(J.created_at)<w.folderMillis){for(let H of w.sql)await z.execute(O.raw(H));await z.execute(O`insert into ${O.identifier(Y)}.${O.identifier(X)} ("hash", "created_at") values(${w.hash}, ${w.folderMillis})`)}})}escapeName($){return`"${$}"`}escapeParam($){return`$${$+1}`}escapeString($){return`'${$.replace(/'/g,"''")}'`}buildWithCTE($){if(!$?.length)return;let T=[O`with `];for(let[W,X]of $.entries())if(T.push(O`${O.identifier(X._.alias)} as (${X._.sql})`),W<$.length-1)T.push(O`, `);return T.push(O` `),O.join(T)}buildDeleteQuery({table:$,where:T,returning:W,withList:X}){let Y=this.buildWithCTE(X),U=W?O` returning ${this.buildSelection(W,{isSingleTable:!0})}`:void 0,G=T?O` where ${T}`:void 0;return O`${Y}delete from ${$}${G}${U}`}buildUpdateSet($,T){let W=$[c.Symbol.Columns],X=Object.keys(W).filter((U)=>T[U]!==void 0||W[U]?.onUpdateFn!==void 0),Y=X.length;return O.join(X.flatMap((U,G)=>{let J=W[U],z=T[U]??O.param(J.onUpdateFn(),J),w=O`${O.identifier(this.casing.getColumnCasing(J))} = ${z}`;if(G<Y-1)return[w,O.raw(", ")];return[w]}))}buildUpdateQuery({table:$,set:T,where:W,returning:X,withList:Y,from:U,joins:G}){let J=this.buildWithCTE(Y),z=$[D4.Symbol.Name],w=$[D4.Symbol.Schema],H=$[D4.Symbol.OriginalName],_=z===H?void 0:z,F=O`${w?O`${O.identifier(w)}.`:void 0}${O.identifier(H)}${_&&O` ${O.identifier(_)}`}`,D=this.buildUpdateSet($,T),V=U&&O.join([O.raw(" from "),this.buildFromTable(U)]),E=this.buildJoins(G),R=X?O` returning ${this.buildSelection(X,{isSingleTable:!U})}`:void 0,P=W?O` where ${W}`:void 0;return O`${J}update ${F} set ${D}${V}${E}${P}${R}`}buildSelection($,{isSingleTable:T=!1}={}){let W=$.length,X=$.flatMap(({field:Y},U)=>{let G=[];if(S(Y,p.Aliased)&&Y.isSelectionField)G.push(O.identifier(Y.fieldAlias));else if(S(Y,p.Aliased)||S(Y,p)){let J=S(Y,p.Aliased)?Y.sql:Y;if(T)G.push(new p(J.queryChunks.map((z)=>{if(S(z,b))return O.identifier(this.casing.getColumnCasing(z));return z})));else G.push(J);if(S(Y,p.Aliased))G.push(O` as ${O.identifier(Y.fieldAlias)}`)}else if(S(Y,S$))if(T)G.push(O.identifier(this.casing.getColumnCasing(Y)));else G.push(Y);if(U<W-1)G.push(O`, `);return G});return O.join(X)}buildJoins($){if(!$||$.length===0)return;let T=[];for(let[W,X]of $.entries()){if(W===0)T.push(O` `);let Y=X.table,U=X.lateral?O` lateral`:void 0,G=X.on?O` on ${X.on}`:void 0;if(S(Y,D4)){let J=Y[D4.Symbol.Name],z=Y[D4.Symbol.Schema],w=Y[D4.Symbol.OriginalName],H=J===w?void 0:X.alias;T.push(O`${O.raw(X.joinType)} join${U} ${z?O`${O.identifier(z)}.`:void 0}${O.identifier(w)}${H&&O` ${O.identifier(H)}`}${G}`)}else if(S(Y,h4)){let J=Y[C$].name,z=Y[C$].schema,w=Y[C$].originalName,H=J===w?void 0:X.alias;T.push(O`${O.raw(X.joinType)} join${U} ${z?O`${O.identifier(z)}.`:void 0}${O.identifier(w)}${H&&O` ${O.identifier(H)}`}${G}`)}else T.push(O`${O.raw(X.joinType)} join${U} ${Y}${G}`);if(W<$.length-1)T.push(O` `)}return O.join(T)}buildFromTable($){if(S($,c)&&$[c.Symbol.IsAlias]){let T=O`${O.identifier($[c.Symbol.OriginalName])}`;if($[c.Symbol.Schema])T=O`${O.identifier($[c.Symbol.Schema])}.${T}`;return O`${T} ${O.identifier($[c.Symbol.Name])}`}return $}buildSelectQuery({withList:$,fields:T,fieldsFlat:W,where:X,having:Y,table:U,joins:G,orderBy:J,groupBy:z,limit:w,offset:H,lockingClause:_,distinct:F,setOperators:D}){let V=W??w6(T);for(let H$ of V)if(S(H$.field,S$)&&F4(H$.field.table)!==(S(U,G4)?U._.alias:S(U,n2)?U[C$].name:S(U,p)?void 0:F4(U))&&!((e$)=>G?.some(({alias:O4})=>O4===(e$[c.Symbol.IsAlias]?F4(e$):e$[c.Symbol.BaseName])))(H$.field.table)){let e$=F4(H$.field.table);throw new Error(`Your "${H$.path.join("->")}" field references a column "${e$}"."${H$.field.name}", but the table "${e$}" is not part of the query! Did you forget to join it?`)}let E=!G||G.length===0,R=this.buildWithCTE($),P;if(F)P=F===!0?O` distinct`:O` distinct on (${O.join(F.on,O`, `)})`;let M=this.buildSelection(V,{isSingleTable:E}),N=this.buildFromTable(U),k=this.buildJoins(G),y=X?O` where ${X}`:void 0,x=Y?O` having ${Y}`:void 0,m;if(J&&J.length>0)m=O` order by ${O.join(J,O`, `)}`;let J$;if(z&&z.length>0)J$=O` group by ${O.join(z,O`, `)}`;let m$=typeof w==="object"||typeof w==="number"&&w>=0?O` limit ${w}`:void 0,B=H?O` offset ${H}`:void 0,Q$=O.empty();if(_){let H$=O` for ${O.raw(_.strength)}`;if(_.config.of)H$.append(O` of ${O.join(Array.isArray(_.config.of)?_.config.of:[_.config.of],O`, `)}`);if(_.config.noWait)H$.append(O` nowait`);else if(_.config.skipLocked)H$.append(O` skip locked`);Q$.append(H$)}let $$=O`${R}select${P} ${M} from ${N}${k}${y}${J$}${x}${m}${m$}${B}${Q$}`;if(D.length>0)return this.buildSetOperations($$,D);return $$}buildSetOperations($,T){let[W,...X]=T;if(!W)throw new Error("Cannot pass undefined values to any set operator");if(X.length===0)return this.buildSetOperationQuery({leftSelect:$,setOperator:W});return this.buildSetOperations(this.buildSetOperationQuery({leftSelect:$,setOperator:W}),X)}buildSetOperationQuery({leftSelect:$,setOperator:{type:T,isAll:W,rightSelect:X,limit:Y,orderBy:U,offset:G}}){let J=O`(${$.getSQL()}) `,z=O`(${X.getSQL()})`,w;if(U&&U.length>0){let D=[];for(let V of U)if(S(V,b))D.push(O.identifier(V.name));else if(S(V,p)){for(let E=0;E<V.queryChunks.length;E++){let R=V.queryChunks[E];if(S(R,b))V.queryChunks[E]=O.identifier(R.name)}D.push(O`${V}`)}else D.push(O`${V}`);w=O` order by ${O.join(D,O`, `)} `}let H=typeof Y==="object"||typeof Y==="number"&&Y>=0?O` limit ${Y}`:void 0,_=O.raw(`${T} ${W?"all ":""}`),F=G?O` offset ${G}`:void 0;return O`${J}${_}${z}${w}${H}${F}`}buildInsertQuery({table:$,values:T,onConflict:W,returning:X,withList:Y,select:U,overridingSystemValue_:G}){let J=[],z=$[c.Symbol.Columns],w=Object.entries(z).filter(([R,P])=>!P.shouldDisableInsert()),H=w.map(([,R])=>O.identifier(this.casing.getColumnCasing(R)));if(U){let R=T;if(S(R,p))J.push(R);else J.push(R.getSQL())}else{let R=T;J.push(O.raw("values "));for(let[P,M]of R.entries()){let N=[];for(let[k,y]of w){let x=M[k];if(x===void 0||S(x,$6)&&x.value===void 0)if(y.defaultFn!==void 0){let m=y.defaultFn(),J$=S(m,p)?m:O.param(m,y);N.push(J$)}else if(!y.default&&y.onUpdateFn!==void 0){let m=y.onUpdateFn(),J$=S(m,p)?m:O.param(m,y);N.push(J$)}else N.push(O`default`);else N.push(x)}if(J.push(N),P<R.length-1)J.push(O`, `)}}let _=this.buildWithCTE(Y),F=O.join(J),D=X?O` returning ${this.buildSelection(X,{isSingleTable:!0})}`:void 0,V=W?O` on conflict ${W}`:void 0,E=G===!0?O`overriding system value `:void 0;return O`${_}insert into ${$} ${H} ${E}${F}${V}${D}`}buildRefreshMaterializedViewQuery({view:$,concurrently:T,withNoData:W}){let X=T?O` concurrently`:void 0,Y=W?O` with no data`:void 0;return O`refresh materialized view${X} ${$}${Y}`}prepareTyping($){if(S($,vY)||S($,CY))return"json";else if(S($,jY))return"decimal";else if(S($,xY))return"time";else if(S($,bY)||S($,fY))return"timestamp";else if(S($,qY)||S($,PY))return"date";else if(S($,yY))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:X,tableConfig:Y,queryConfig:U,tableAlias:G,nestedQueryRelation:J,joinOn:z}){let w=[],H,_,F=[],D,V=[];if(U===!0)w=Object.entries(Y.columns).map(([P,M])=>({dbKey:M.name,tsKey:P,field:y6(M,G),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{let R=Object.fromEntries(Object.entries(Y.columns).map(([x,m])=>[x,y6(m,G)]));if(U.where){let x=typeof U.where==="function"?U.where(R,FO()):U.where;D=x&&y2(x,G)}let P=[],M=[];if(U.columns){let x=!1;for(let[m,J$]of Object.entries(U.columns)){if(J$===void 0)continue;if(m in Y.columns){if(!x&&J$===!0)x=!0;M.push(m)}}if(M.length>0)M=x?M.filter((m)=>U.columns?.[m]===!0):Object.keys(Y.columns).filter((m)=>!M.includes(m))}else M=Object.keys(Y.columns);for(let x of M){let m=Y.columns[x];P.push({tsKey:x,value:m})}let N=[];if(U.with)N=Object.entries(U.with).filter((x)=>!!x[1]).map(([x,m])=>({tsKey:x,queryConfig:m,relation:Y.relations[x]}));let k;if(U.extras){k=typeof U.extras==="function"?U.extras(R,{sql:O}):U.extras;for(let[x,m]of Object.entries(k))P.push({tsKey:x,value:Z7(m,G)})}for(let{tsKey:x,value:m}of P)w.push({dbKey:S(m,p.Aliased)?m.fieldAlias:Y.columns[x].name,tsKey:x,field:S(m,S$)?y6(m,G):m,relationTableTsKey:void 0,isJson:!1,selection:[]});let y=typeof U.orderBy==="function"?U.orderBy(R,QO()):U.orderBy??[];if(!Array.isArray(y))y=[y];F=y.map((x)=>{if(S(x,S$))return y6(x,G);return y2(x,G)}),H=U.limit,_=U.offset;for(let{tsKey:x,queryConfig:m,relation:J$}of N){let m$=DO(T,W,J$),B=S0(J$.referencedTable),Q$=W[B],$$=`${G}_${x}`,H$=u2(...m$.fields.map((D6,y0)=>hY(y6(m$.references[y0],$$),y6(D6,G)))),e$=this.buildRelationalQueryWithoutPK({fullSchema:$,schema:T,tableNamesMap:W,table:$[Q$],tableConfig:T[Q$],queryConfig:S(J$,y1)?m===!0?{limit:1}:{...m,limit:1}:m,tableAlias:$$,joinOn:H$,nestedQueryRelation:J$}),O4=O`${O.identifier($$)}.${O.identifier("data")}`.as(x);V.push({on:O`true`,table:new G4(e$.sql,{},$$),alias:$$,joinType:"left",lateral:!0}),w.push({dbKey:x,tsKey:x,field:O4,relationTableTsKey:Q$,isJson:!0,selection:e$.selection})}}if(w.length===0)throw new IY({message:`No fields selected for table "${Y.tsName}" ("${G}")`});let E;if(D=u2(z,D),J){let R=O`json_build_array(${O.join(w.map(({field:N,tsKey:k,isJson:y})=>y?O`${O.identifier(`${G}_${k}`)}.${O.identifier("data")}`:S(N,p.Aliased)?N.sql:N),O`, `)})`;if(S(J,p2))R=O`coalesce(json_agg(${R}${F.length>0?O` order by ${O.join(F,O`, `)}`:void 0}), '[]'::json)`;let P=[{dbKey:"data",tsKey:"data",field:R.as("data"),isJson:!0,relationTableTsKey:Y.tsName,selection:w}];if(H!==void 0||_!==void 0||F.length>0)E=this.buildSelectQuery({table:RY(X,G),fields:{},fieldsFlat:[{path:[],field:O.raw("*")}],where:D,limit:H,offset:_,orderBy:F,setOperators:[]}),D=void 0,H=void 0,_=void 0,F=[];else E=RY(X,G);E=this.buildSelectQuery({table:S(E,D4)?E:new G4(E,{},G),fields:{},fieldsFlat:P.map(({field:N})=>({path:[],field:S(N,S$)?y6(N,G):N})),joins:V,where:D,limit:H,offset:_,orderBy:F,setOperators:[]})}else E=this.buildSelectQuery({table:RY(X,G),fields:{},fieldsFlat:w.map(({field:R})=>({path:[],field:S(R,S$)?y6(R,G):R})),joins:V,where:D,limit:H,offset:_,orderBy:F,setOperators:[]});return{tableTsKey:Y.tsName,sql:E,selection:w}}}class m7{static[Z]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}class P4{static[Z]="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=$,X;if(this.fields)X=this.fields;else if(S(W,G4))X=Object.fromEntries(Object.keys(W._.selectedFields).map((Y)=>[Y,W[Y]]));else if(S(W,n2))X=W[C$].selectedFields;else if(S(W,p))X={};else X=lQ(W);return new c7({table:W,fields:X,isPartialSelect:T,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}class yO extends m7{static[Z]="PgSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;constructor({table:$,fields:T,isPartialSelect:W,session:X,dialect:Y,withList:U,distinct:G}){super();this.config={withList:U,table:$,fields:{...T},distinct:G,setOperators:[]},this.isPartialSelect=W,this.session=X,this.dialect=Y,this._={selectedFields:T},this.tableName=X1($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}createJoin($,T){return(W,X)=>{let Y=this.tableName,U=X1(W);if(typeof U==="string"&&this.config.joins?.some((G)=>G.alias===U))throw new Error(`Alias "${U}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof Y==="string")this.config.fields={[Y]:this.config.fields};if(typeof U==="string"&&!S(W,p)){let G=S(W,G4)?W._.selectedFields:S(W,h4)?W[C$].selectedFields:W[c.Symbol.Columns];this.config.fields[U]=G}}if(typeof X==="function")X=X(new Proxy(this.config.fields,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:X,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(([G])=>[G,!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(([G])=>[G,!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 X=typeof W==="function"?W(jk()):W;if(!h2(this.getSelectedFields(),X.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:X}),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($){return new Proxy(new G4(this.getSQL(),this.config.fields,$),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}}class c7 extends yO{static[Z]="PgSelect";_prepare($){let{session:T,config:W,dialect:X,joinsNotNullableMap:Y,authToken:U}=this;if(!T)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return B$.startActiveSpan("drizzle.prepareQuery",()=>{let G=w6(W.fields),J=T.prepareQuery(X.sqlToQuery(this.getSQL()),G,$,!0);return J.joinsNotNullableMap=Y,J.setToken(U)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return B$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}dQ(c7,[k4]);function kT($,T){return(W,X,...Y)=>{let U=[X,...Y].map((G)=>({type:$,isAll:T,rightSelect:G}));for(let G of U)if(!h2(W.getSelectedFields(),G.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 jk=()=>({union:xk,unionAll:bk,intersect:fk,intersectAll:yk,except:hk,exceptAll:gk}),xk=kT("union",!1),bk=kT("union",!0),fk=kT("intersect",!1),yk=kT("intersect",!0),hk=kT("except",!1),gk=kT("except",!0);class t2{static[Z]="PgQueryBuilder";dialect;dialectConfig;constructor($){this.dialect=S($,q0)?$:void 0,this.dialectConfig=S($,q0)?void 0:$}$with=($,T)=>{let W=this;return{as:(Y)=>{if(typeof Y==="function")Y=Y(W);return new Proxy(new x2(Y.getSQL(),T??("getSelectedFields"in Y?Y.getSelectedFields()??{}:{}),$,!0),new r$({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};with(...$){let T=this;function W(U){return new P4({fields:U??void 0,session:void 0,dialect:T.getDialect(),withList:$})}function X(U){return new P4({fields:U??void 0,session:void 0,dialect:T.getDialect(),distinct:!0})}function Y(U,G){return new P4({fields:G??void 0,session:void 0,dialect:T.getDialect(),distinct:{on:U}})}return{select:W,selectDistinct:X,selectDistinctOn:Y}}select($){return new P4({fields:$??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct($){return new P4({fields:$??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn($,T){return new P4({fields:T??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:$}})}getDialect(){if(!this.dialect)this.dialect=new q0(this.dialectConfig);return this.dialect}}class eY{constructor($,T,W,X,Y){this.table=$,this.session=T,this.dialect=W,this.withList=X,this.overridingSystemValue_=Y}static[Z]="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 X={},Y=this.table[c.Symbol.Columns];for(let U of Object.keys(W)){let G=W[U];X[U]=S(G,p)?G:new $6(G,Y[U])}return X});return new u7(this.table,T,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select($){let T=typeof $==="function"?$(new t2):$;if(!S(T,p)&&!h2(this.table[SY],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 u7(this.table,T,this.session,this.dialect,this.withList,!0)}}class u7 extends k4{constructor($,T,W,X,Y,U,G){super();this.session=W,this.dialect=X,this.config={table:$,values:T,withList:Y,select:U,overridingSystemValue_:G}}static[Z]="PgInsert";config;returning($=this.config.table[c.Symbol.Columns]){return this.config.returningFields=$,this.config.returning=w6($),this}onConflictDoNothing($={}){if($.target===void 0)this.config.onConflict=O`do nothing`;else{let T="";T=Array.isArray($.target)?$.target.map((X)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(X))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target));let W=$.where?O` where ${$.where}`:void 0;this.config.onConflict=O`(${O.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?O` where ${$.where}`:void 0,W=$.targetWhere?O` where ${$.targetWhere}`:void 0,X=$.setWhere?O` where ${$.setWhere}`:void 0,Y=this.dialect.buildUpdateSet(this.config.table,kY(this.config.table,$.set)),U="";return U=Array.isArray($.target)?$.target.map((G)=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(G))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing($.target)),this.config.onConflict=O`(${O.raw(U)})${W} do update set ${Y}${T}${X}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:$,...T}=this.dialect.sqlToQuery(this.getSQL());return T}_prepare($){return B$.startActiveSpan("drizzle.prepareQuery",()=>{return this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,$,!0)})}prepare($){return this._prepare($)}authToken;setToken($){return this.authToken=$,this}execute=($)=>{return B$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})};getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new r$({alias:F4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class p7 extends k4{constructor($,T,W){super();this.session=T,this.dialect=W,this.config={view:$}}static[Z]="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 B$.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 B$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute($,this.authToken)})}}class $U{constructor($,T,W,X){this.table=$,this.session=T,this.dialect=W,this.withList=X}static[Z]="PgUpdateBuilder";authToken;setToken($){return this.authToken=$,this}set($){return new hO(this.table,kY(this.table,$),this.session,this.dialect,this.withList).setToken(this.authToken)}}class hO extends k4{constructor($,T,W,X,Y){super();this.session=W,this.dialect=X,this.config={set:T,table:$,withList:Y,joins:[]},this.tableName=X1($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{}}static[Z]="PgUpdate";config;tableName;joinsNotNullableMap;from($){let T=$,W=X1(T);if(typeof W==="string")this.joinsNotNullableMap[W]=!0;return this.config.from=T,this}getTableLikeFields($){if(S($,D4))return $[c.Symbol.Columns];else if(S($,G4))return $._.selectedFields;return $[C$].selectedFields}createJoin($){return(T,W)=>{let X=X1(T);if(typeof X==="string"&&this.config.joins.some((Y)=>Y.alias===X))throw new Error(`Alias "${X}" is already used in this query`);if(typeof W==="function"){let Y=this.config.from&&!S(this.config.from,p)?this.getTableLikeFields(this.config.from):void 0;W=W(new Proxy(this.config.table[c.Symbol.Columns],new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),Y&&new Proxy(Y,new r$({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:W,table:T,joinType:$,alias:X}),typeof X==="string")switch($){case"left":{this.joinsNotNullableMap[X]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([Y])=>[Y,!1])),this.joinsNotNullableMap[X]=!0;break}case"inner":{this.joinsNotNullableMap[X]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([Y])=>[Y,!1])),this.joinsNotNullableMap[X]=!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[c.Symbol.Columns]),this.config.from){let T=X1(this.config.from);if(typeof T==="string"&&this.config.from&&!S(this.config.from,p)){let W=this.getTableLikeFields(this.config.from);$[T]=W}for(let W of this.config.joins){let X=X1(W.table);if(typeof X==="string"&&!S(W.table,p)){let Y=this.getTableLikeFields(W.table);$[X]=Y}}}}return this.config.returningFields=$,this.config.returning=w6($),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);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:F4(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}class a2 extends p{constructor($){super(a2.buildEmbeddedCount($.source,$.filters).queryChunks);this.params=$,this.mapWith(Number),this.session=$.session,this.sql=a2.buildCount($.source,$.filters)}sql;token;static[Z]="PgCountBuilder";[Symbol.toStringTag]="PgCountBuilder";session;static buildEmbeddedCount($,T){return O`(select count(*) from ${$}${O.raw(" where ").if(T)}${T})`}static buildCount($,T){return O`select count(*) as count from ${$}${O.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 d7{constructor($,T,W,X,Y,U,G){this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=X,this.tableConfig=Y,this.dialect=U,this.session=G}static[Z]="PgRelationalQueryBuilder";findMany($){return new o7(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?$:{},"many")}findFirst($){return new o7(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,$?{...$,limit:1}:{limit:1},"first")}}class o7 extends k4{constructor($,T,W,X,Y,U,G,J,z){super();this.fullSchema=$,this.schema=T,this.tableNamesMap=W,this.table=X,this.tableConfig=Y,this.dialect=U,this.session=G,this.config=J,this.mode=z}static[Z]="PgRelationalQuery";_prepare($){return B$.startActiveSpan("drizzle.prepareQuery",()=>{let{query:T,builtQuery:W}=this._toSQL();return this.session.prepareQuery(W,void 0,$,!0,(X,Y)=>{let U=X.map((G)=>mY(this.schema,this.tableConfig,G,T.selection,Y));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 B$.startActiveSpan("drizzle.operation",()=>{return this._prepare().execute(void 0,this.authToken)})}}class l7 extends k4{constructor($,T,W,X){super();this.execute=$,this.sql=T,this.query=W,this.mapBatchResult=X}static[Z]="PgRaw";getSQL(){return this.sql}getQuery(){return this.query}mapResult($,T){return T?this.mapBatchResult($):$}_prepare(){return this}isResponseInArrayMode(){return!1}}class s2{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[X,Y]of Object.entries(this._.schema))this.query[X]=new d7(W.fullSchema,this._.schema,this._.tableNamesMap,W.fullSchema[X],Y,$,T)}static[Z]="PgDatabase";query;$with=($,T)=>{let W=this;return{as:(Y)=>{if(typeof Y==="function")Y=Y(new t2(W.dialect));return new Proxy(new x2(Y.getSQL(),T??("getSelectedFields"in Y?Y.getSelectedFields()??{}:{}),$,!0),new r$({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}}};$count($,T){return new a2({source:$,filters:T,session:this.session})}with(...$){let T=this;function W(z){return new P4({fields:z??void 0,session:T.session,dialect:T.dialect,withList:$})}function X(z){return new P4({fields:z??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:!0})}function Y(z,w){return new P4({fields:w??void 0,session:T.session,dialect:T.dialect,withList:$,distinct:{on:z}})}function U(z){return new $U(z,T.session,T.dialect,$)}function G(z){return new eY(z,T.session,T.dialect,$)}function J(z){return new sY(z,T.session,T.dialect,$)}return{select:W,selectDistinct:X,selectDistinctOn:Y,update:U,insert:G,delete:J}}select($){return new P4({fields:$??void 0,session:this.session,dialect:this.dialect})}selectDistinct($){return new P4({fields:$??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn($,T){return new P4({fields:T??void 0,session:this.session,dialect:this.dialect,distinct:{on:$}})}update($){return new $U($,this.session,this.dialect)}insert($){return new eY($,this.session,this.dialect)}delete($){return new sY($,this.session,this.dialect)}refreshMaterializedView($){return new p7($,this.session,this.dialect)}authToken;execute($){let T=typeof $==="string"?O.raw($):$.getSQL(),W=this.dialect.sqlToQuery(T),X=this.session.prepareQuery(W,void 0,void 0,!1);return new l7(()=>X.execute(void 0,this.authToken),T,W,(Y)=>X.mapResult(Y,!0))}transaction($,T){return this.session.transaction($,T)}}class gO{constructor($,T){this.unique=$,this.name=T}static[Z]="PgIndexBuilderOn";on(...$){return new TU($.map((T)=>{if(S(T,p))return T;T=T;let W=new v2(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 TU($.map((T)=>{if(S(T,p))return T;T=T;let W=new v2(T.name,!!T.keyAsName,T.columnType,T.indexConfig);return T.indexConfig=T.defaultConfig,W}),this.unique,!0,this.name)}using($,...T){return new TU(T.map((W)=>{if(S(W,p))return W;W=W;let X=new v2(W.name,!!W.keyAsName,W.columnType,W.indexConfig);return W.indexConfig=JSON.parse(JSON.stringify(W.defaultConfig)),X}),this.unique,!0,this.name,$)}}class TU{static[Z]="PgIndexBuilder";config;constructor($,T,W,X,Y="btree"){this.config={name:X,columns:$,unique:T,only:W,method:Y}}concurrently(){return this.config.concurrently=!0,this}with($){return this.config.with=$,this}where($){return this.config.where=$,this}build($){return new mO(this.config,$)}}class mO{static[Z]="PgIndex";config;constructor($,T){this.config={...$,table:T}}}function r7($){return new gO(!0,$)}class i7{constructor($){this.query=$}authToken;getQuery(){return this.query}mapResult($,T){return $}setToken($){return this.authToken=$,this}static[Z]="PgPreparedQuery";joinsNotNullableMap}class n7{constructor($){this.dialect=$}static[Z]="PgSession";execute($,T){return B$.startActiveSpan("drizzle.operation",()=>{return B$.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 t7 extends s2{constructor($,T,W,X=0){super($,T,W);this.schema=W,this.nestedIndex=X}static[Z]="PgTransaction";rollback(){throw new D7}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 O.raw(T.join(" "))}setTransaction($){return this.session.execute(O`set transaction ${this.getTransactionConfigSQL($)}`)}}class cO extends i7{constructor($,T,W,X,Y,U,G){super({sql:T,params:W});this.client=$,this.queryString=T,this.params=W,this.logger=X,this.fields=Y,this._isResponseInArrayMode=U,this.customResultMapper=G}static[Z]="PostgresJsPreparedQuery";async execute($={}){return B$.startActiveSpan("drizzle.execute",async(T)=>{let W=Q7(this.params,$);T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W);let{fields:X,queryString:Y,client:U,joinsNotNullableMap:G,customResultMapper:J}=this;if(!X&&!J)return B$.startActiveSpan("drizzle.driver.execute",()=>{return U.unsafe(Y,W)});let z=await B$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":Y,"drizzle.query.params":JSON.stringify(W)}),U.unsafe(Y,W).values()});return B$.startActiveSpan("drizzle.mapResponse",()=>{return J?J(z):z.map((w)=>oQ(X,w,G))})})}all($={}){return B$.startActiveSpan("drizzle.execute",async(T)=>{let W=Q7(this.params,$);return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.logger.logQuery(this.queryString,W),B$.startActiveSpan("drizzle.driver.execute",()=>{return T?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(W)}),this.client.unsafe(this.queryString,W)})})}isResponseInArrayMode(){return this._isResponseInArrayMode}}class e2 extends n7{constructor($,T,W,X={}){super(T);this.client=$,this.schema=W,this.options=X,this.logger=X.logger??new V7}static[Z]="PostgresJsSession";logger;prepareQuery($,T,W,X,Y){return new cO(this.client,$.sql,$.params,this.logger,T,X,Y)}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 X=new e2(W,this.dialect,this.schema,this.options),Y=new a7(this.dialect,X,this.schema);if(T)await Y.setTransaction(T);return $(Y)})}}class a7 extends t7{constructor($,T,W,X=0){super($,T,W,X);this.session=T}static[Z]="PostgresJsTransaction";transaction($){return this.session.client.savepoint((T)=>{let W=new e2(T,this.dialect,this.schema,this.session.options),X=new a7(this.dialect,W,this.schema);return $(X)})}}class uO extends s2{static[Z]="PostgresJsDatabase"}function qT($,T={}){let W=(z)=>z;for(let z of["1184","1082","1083","1114","1182","1185","1115","1231"])$.options.parsers[z]=W,$.options.serializers[z]=W;$.options.serializers["114"]=W,$.options.serializers["3802"]=W;let X=new q0({casing:T.casing}),Y;if(T.logger===!0)Y=new O7;else if(T.logger!==!1)Y=T.logger;let U;if(T.schema){let z=ZO(T.schema,OO);U={fullSchema:T.schema,schema:z.tables,tableNamesMap:z.tableNamesMap}}let G=new e2($,X,U,{logger:Y}),J=new uO(X,G,U);return J.$client=$,J}function WU(...$){if(typeof $[0]==="string"){let T=IT($[0]);return qT(T,$[1])}if(rQ($[0])){let{connection:T,client:W,...X}=$[0];if(W)return qT(W,X);if(typeof T==="object"&&T.url!==void 0){let{url:U,...G}=T,J=IT(U,G);return qT(J,X)}let Y=IT(T);return qT(Y,X)}return qT($[0],$[1])}(($)=>{function T(W){return qT({options:{parsers:{},serializers:{}}},W)}$.mock=T})(WU||(WU={}));function pO($,T){if($ instanceof Promise)throw new Error(T)}function mk($,T){let W={},X=[];for(let Y in $){let U=$[Y]["~standard"].validate(T[Y]);if(pO(U,`Validation must be synchronous, but ${Y} returned a Promise.`),U.issues){X.push(...U.issues.map((G)=>({...G,path:[Y,...G.path??[]]})));continue}W[Y]=U.value}if(X.length)return{issues:X};return{value:W}}function s7($){let T=$.runtimeEnvStrict??$.runtimeEnv??process.env;if($.emptyStringAsUndefined??!1){for(let[M,N]of Object.entries(T))if(N==="")delete T[M]}if(!!$.skipValidation)return T;let Y=typeof $.client==="object"?$.client:{},U=typeof $.server==="object"?$.server:{},G=typeof $.shared==="object"?$.shared:{},J=$.isServer??(typeof window==="undefined"||("Deno"in window)),z=J?{...U,...G,...Y}:{...Y,...G},w=$.createFinalSchema?.(z,J)["~standard"].validate(T)??mk(z,T);pO(w,"Validation must be synchronous");let H=$.onValidationError??((M)=>{throw console.error("\u274C Invalid environment variables:",M),new Error("Invalid environment variables")}),_=$.onInvalidAccess??(()=>{throw new Error("\u274C Attempted to access a server-side environment variable on the client")});if(w.issues)return H(w.issues);let F=(M)=>{if(!$.clientPrefix)return!0;return!M.startsWith($.clientPrefix)&&!(M in G)},D=(M)=>{return J||!F(M)},V=(M)=>{return M==="__esModule"||M==="$$typeof"},E=($.extends??[]).reduce((M,N)=>{return Object.assign(M,N)},{}),R=Object.assign(E,w.value);return new Proxy(R,{get(M,N){if(typeof N!=="string")return;if(V(N))return;if(!D(N))return _(N);return Reflect.get(M,N)}})}var g1=($)=>Array.isArray($)?$:[$],oO=($,T)=>{let W=[[],[]];for(let X of $)if(T(X))W[0].push(X);else W[1].push(X);return W},XU=Array,U1=($,T)=>$.includes(T),dO=($,T=0)=>[...new Array($)].map((W,X)=>X+T),F$=($,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 $},G1=($,T)=>{if(T===void 0||T===null)return $??[];if($===void 0||$===null)return g1(T);return $.concat(T)},lO=(...$)=>$.reduce(G1,[]),g6=($,T,W)=>{if($===void 0)return Array.isArray(T)?T:[T];let X=W?.isEqual??((Y,U)=>Y===U);for(let Y of g1(T))if(!$.some((U)=>X(U,Y)))$.push(Y);return $},rO=($,T)=>$.reduce((W,X)=>{let Y=X[T];return W[Y]=F$(W[Y],X),W},{}),J1=($,T,W)=>$.length===T.length&&$.every(W?.isEqual?(X,Y)=>W.isEqual(X,T[Y]):(X,Y)=>X===T[Y]);var m4=($,T)=>w4($)===T,w4=($)=>{let T=typeof $;return T==="object"?$===null?"null":"object":T==="function"?"object":T},c4={boolean:"boolean",null:"null",undefined:"undefined",bigint:"a bigint",number:"a number",object:"an object",string:"a string",symbol:"a symbol"},iO={...c4,function:"a function"};class nO extends Error{}var D$=($)=>P0($,nO),P0=($,T=Error)=>{throw new T($)};class $X extends Error{name="ParseError"}var L=($)=>P0($,$X),L6=($)=>` ${$}`;var W$=($,T)=>{let W={},X=Array.isArray($),Y=!1;for(let[U,G]of Object.entries($).entries()){let J=X?T(U,G[1]):T(...G,U);Y||=typeof J[0]==="number";let z=Array.isArray(J[0])||J.length===0?J:[J];for(let[w,H]of z)if(typeof w==="object")W[w.group]=F$(W[w.group],H);else W[w]=H}return Y?Object.values(W):W};var e7=Object.entries;var z4=($,T)=>($ in T),PT=($,T)=>(T in $);class $_{constructor($){Object.assign(this,$)}}var tO=class{};class TX extends tO{}var ck=($,T)=>{let W={},X={},Y;for(Y in $)if(Y in T)W[Y]=$[Y];else X[Y]=$[Y];return[W,X]};var aO=($,T)=>ck($,T)[1],m6=($)=>Object.keys($).length===0,C0=($)=>[...Object.entries($),...Object.getOwnPropertySymbols($).map((T)=>[T,$[T]])],sO=($,T)=>Object.defineProperties($,Object.getOwnPropertyDescriptors(T)),eO=($)=>{let T=Object.keys($).sort(),W={};for(let X=0;X<T.length;X++)W[T[X]]=$[T[X]];return W};var W6=L6("represents an uninitialized value"),$V=($)=>Object.values($).filter((T)=>{if(typeof T==="number")return!0;return typeof $[T]!=="number"});var T_={Array,Boolean,Date,Error,Function,Map,Number,Promise,RegExp,Set,String,WeakMap,WeakSet},W_=globalThis.File??Blob,X_={ArrayBuffer,Blob,File:W_,FormData,Headers,Request,Response,URL},uk={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array},v0={...T_,...X_,...uk,String,Number,Boolean},WX=($)=>{let T=Object.getPrototypeOf($);while(T?.constructor&&(!z4(T.constructor.name,v0)||!($ instanceof v0[T.constructor.name])))T=Object.getPrototypeOf(T);let W=T?.constructor?.name;if(W===void 0||W==="Object")return;return W},XX=($)=>typeof $==="object"&&$!==null?WX($)??"object":w4($);var R$=Array.isArray,pk={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"},ok={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"},dk={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"},TV={...pk,...ok,...dk},YX=($)=>{let T=Object($).name??null;return T&&z4(T,v0)&&v0[T]===$?T:null};var Y_=($,T)=>{let W=$.prototype;while(W!==null){if(W===T.prototype)return!0;W=Object.getPrototypeOf(W)}return!1};var WV=($)=>XV($,new Map),XV=($,T)=>{if(typeof $!=="object"||$===null)return $;if(T?.has($))return T.get($);let W=YX($.constructor);if(W==="Date")return new Date($.getTime());if(W&&W!=="Array")return $;let X=Array.isArray($)?$.slice():Object.create(Object.getPrototypeOf($)),Y=Object.getOwnPropertyDescriptors($);if(T){T.set($,X);for(let U in Y){let G=Y[U];if("get"in G||"set"in G)continue;G.value=XV(G.value,T)}}return Object.defineProperties(X,Y),X};var lk=($)=>{let T=W6;return()=>T===W6?T=$():T},m1=($)=>typeof $==="function"&&$.length===0;var YV=class extends Function{constructor(...$){let T=$.slice(0,-1),W=$.at(-1);try{super(...T,W)}catch(X){return D$(`Encountered an unexpected error while compiling your definition:
108
- Message: ${X}
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
110
  Source: (${$.slice(0,-1)}) => {
110
111
  ${$.at(-1)}
111
- }`)}}};class S6{constructor($,...[T]){return Object.assign(Object.setPrototypeOf($.bind(T?.bind??this),this.constructor.prototype),T?.attach)}}var UV=lk(()=>{try{return new Function("return false")()}catch{return!0}});var fa=L6("brand");var GV=L6("arkInferred");var ga=L6("args");class L4{constructor(){}}var rk=()=>{try{return((new Error().stack?.split(`
112
- `)[2]?.trim()||"").match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1]||"unknown").replace(/^file:\/\//,"")}catch{return"unknown"}},ik=globalThis.process?.env??{},JV={fileName:rk,env:ik};var wV=($)=>$[0].toUpperCase()+$.slice(1);var U_=($)=>new RegExp(nk($),typeof $==="string"?"":$.flags);var nk=($)=>{return`^(?:${typeof $==="string"?$:$.source})$`};var w1={negativeLookahead:($)=>`(?!${$})`,nonCapturingGroup:($)=>`(?:${$})`},UX="\\",c1={" ":1,"\n":1,"\t":1};var tk=/^-0\.?0*$/.source,_V=/[1-9]\d*/.source,ak=/\.\d+/.source,sk=/\.\d*[1-9]/.source,HV=($)=>U_(w1.negativeLookahead(tk)+w1.nonCapturingGroup("-?"+w1.nonCapturingGroup(w1.nonCapturingGroup("0|"+_V)+w1.nonCapturingGroup($.decimalPattern)+"?")+($.allowDecimalOnly?"|"+$.decimalPattern:"")+"?")),zV=HV({decimalPattern:sk,allowDecimalOnly:!1}),ek=zV.test.bind(zV),YU=HV({decimalPattern:ak,allowDecimalOnly:!0}),la=YU.test.bind(YU),$q=/^-?\d*\.?\d*$/,Tq=($)=>$.length!==0&&$q.test($),GX=U_(w1.negativeLookahead("^-0$")+"-?"+w1.nonCapturingGroup(w1.nonCapturingGroup("0|"+_V))),Wq=GX.test.bind(GX),G_=/^-?\d+$/,Xq=G_.test.bind(G_),FV={number:"a number",bigint:"a bigint",integer:"an integer"},QV=($,T)=>`'${$}' was parsed as ${FV[T]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,Yq=($,T)=>T==="number"?ek($):Wq($),Uq=($,T)=>T==="number"?Number($):Number.parseInt($),Gq=($,T)=>T==="number"?Tq($):Xq($),ZV=($,T)=>J_($,"number",T),DV=($,T)=>J_($,"number",{...T,strict:!0}),OV=($,T)=>J_($,"integer",T),J_=($,T,W)=>{let X=Uq($,T);if(!Number.isNaN(X)){if(Gq($,T)){if(W?.strict)return Yq($,T)?X:L(QV($,T));return X}}return W?.errorOnFail?L(W?.errorOnFail===!0?`Failed to parse ${FV[T]} from '${$}'`:W?.errorOnFail):void 0},VV=($)=>{if($[$.length-1]!=="n")return;let T=$.slice(0,-1),W;try{W=BigInt(T)}catch{return}if(GX.test(T))return W;if(G_.test(T))return L(QV($,"bigint"))};var Jq="0.46.0",wq={version:Jq,filename:JV.fileName(),FileConstructor:W_},j0=wq,KV=new Map,w_=Object.create(null),JX=($)=>{let T=KV.get($);if(T)return T;let W=zq($);if(w_[W])W=`${W}${w_[W]++}`;else w_[W]=1;return j0[W]=$,KV.set($,W),W},u1=($)=>/^[$A-Z_a-z][\w$]*$/.test($),zq=($)=>{switch(typeof $){case"object":{if($===null)break;let T=WX($)??"object";return T[0].toLowerCase()+T.slice(1)}case"function":return u1($.name)?$.name:"fn";case"symbol":return $.description&&u1($.description)?$.description:"symbol"}return D$(`Unexpected attempt to register serializable value of type ${w4($)}`)};var wX=($)=>typeof $==="string"?JSON.stringify($):typeof $==="bigint"?`${$}n`:`${$}`;var EV=($,T={})=>zX($,{onUndefined:"$ark.undefined",onBigInt:(W)=>`$ark.bigint-${W}`,...T},[]);var X$=($,T)=>{switch(w4($)){case"object":let W=$,X=W.constructor.name;return X==="Object"||X==="Array"?T?.quoteKeys===!1?UU(W,T?.indent??0,""):JSON.stringify(zX(W,CT,[]),null,T?.indent):UU(W,T?.indent??0,"");case"symbol":return CT.onSymbol($);default:return wX($)}},UU=($,T,W)=>{if(typeof $==="function")return CT.onFunction($);if(typeof $!=="object"||$===null)return wX($);let X=W+" ".repeat(T);if(Array.isArray($)){if($.length===0)return"[]";let U=$.map((G)=>UU(G,T,X)).join(`,
113
- `+X);return T?`[
114
- ${X}${U}
115
- ${W}]`:`[${U}]`}let Y=$.constructor.name;if(Y==="Object"){let U=C0($).map(([G,J])=>{let z=typeof G==="symbol"?CT.onSymbol(G):u1(G)?G:JSON.stringify(G),w=UU(J,T,X);return`${X}${z}: ${w}`});if(U.length===0)return"{}";return T?`{
116
- ${U.join(`,
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(`,
117
118
  `)}
118
- ${W}}`:`{${U.join(", ")}}`}if($ instanceof Date)return x0($);if("expression"in $&&typeof $.expression==="string")return $.expression;return Y},CT={onCycle:()=>"(cycle)",onSymbol:($)=>`Symbol(${JX($)})`,onFunction:($)=>`Function(${JX($)})`},zX=($,T,W)=>{switch(w4($)){case"object":{let X=$;if("toJSON"in X&&typeof X.toJSON==="function")return X.toJSON();if(typeof X==="function")return CT.onFunction(X);if(W.includes(X))return"(cycle)";let Y=[...W,X];if(Array.isArray(X))return X.map((G)=>zX(G,T,Y));if(X instanceof Date)return X.toDateString();let U={};for(let G in X)U[G]=zX(X[G],T,Y);for(let G of Object.getOwnPropertySymbols(X))U[T.onSymbol?.(G)??G.toString()]=zX(X[G],T,Y);return U}case"symbol":return CT.onSymbol($);case"bigint":return T.onBigInt?.($)??`${$}n`;case"undefined":return T.onUndefined??"undefined";case"string":return $.replaceAll("\\","\\\\");default:return $}},x0=($)=>{let T=$.getFullYear(),W=$.getMonth(),X=$.getDate(),Y=$.getHours(),U=$.getMinutes(),G=$.getSeconds(),J=$.getMilliseconds();if(W===0&&X===1&&Y===0&&U===0&&G===0&&J===0)return`${T}`;let z=`${_q[W]} ${X}, ${T}`;if(Y===0&&U===0&&G===0&&J===0)return z;let w=$.toLocaleTimeString(),H=w.endsWith(" AM")||w.endsWith(" PM")?w.slice(-3):"";if(H)w=w.slice(0,-H.length);if(J)w+=`.${Fq(J,3)}`;else if(Hq.test(w))w=w.slice(0,-3);return`${w+H}, ${z}`},_q=["January","February","March","April","May","June","July","August","September","October","November","December"],Hq=/:\d\d:00$/,Fq=($,T)=>String($).padStart(T,"0");var AV=($,T,...[W])=>{let X=W?.stringifySymbol??X$,Y=$;switch(typeof T){case"string":Y=u1(T)?$===""?T:`${$}.${T}`:`${$}[${JSON.stringify(T)}]`;break;case"number":Y=`${$}[${T}]`;break;case"symbol":Y=`${$}[${X(T)}]`;break;default:if(W?.stringifyNonKey)Y=`${$}[${W.stringifyNonKey(T)}]`;else L(`${X$(T)} must be a PropertyKey or stringifyNonKey must be passed to options`)}return Y},z1=($,...T)=>$.reduce((W,X)=>AV(W,X,...T),"");class _X extends XU{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"?X$(this[$]):this[$]);return this.cache.json}stringify(){if(this.cache.stringify)return this.cache.stringify;return this.cache.stringify=z1(this)}stringifyAncestors(){if(this.cache.stringifyAncestors)return this.cache.stringifyAncestors;let $="",T=[$];for(let W of this)$=AV($,W),T.push($);return this.cache.stringifyAncestors=T}}class z_{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]===UX)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 c1))}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 Vs=L6("implementedTraits");var __="$ark",Qq=2;while(__ in globalThis)__=`$ark${Qq++}`;var MV=__;globalThis[MV]=j0;var I=j0,Zq=($)=>`${MV}.${$}`,o$=($)=>Zq(JX($));class GU extends TX{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 H_($,T)}index($,T=!1){return NV(`${$}`,T)}line($){return this.body+=`${" ".repeat(this.indentation)}${$}
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)}${$}
119
120
  `,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(`
120
121
  `).map((W)=>" ".repeat(T)+`${W}`).join(`
121
- `):this.body} }`}compile(){return new YV(...this.argNames,this.body)}}var _1=($)=>m4($,"object")||typeof $==="symbol"?o$($):wX($),H_=($,T=!1)=>{if(typeof $==="string"&&u1($))return`${T?"?":""}.${$}`;return NV(Dq($),T)},Dq=($)=>typeof $==="symbol"?o$($):JSON.stringify($),NV=($,T=!1)=>`${T?"?.":""}[${$}]`;class HX extends GU{traversalKind;optimistic;constructor($){super("data","ctx");this.traversalKind=$.kind,this.optimistic=$.optimistic===!0}invoke($,T){let W=T?.arg??this.data,X=typeof $==="string"?!0:this.requiresContextFor($),Y=typeof $==="string"?$:$.id;if(X)return`${this.referenceToId(Y,T)}(${W}, ${this.ctx})`;return`${this.referenceToId(Y,T)}(${W})`}referenceToId($,T){let W=T?.kind??this.traversalKind,X=`this.${$}${W}`;return T?.bind?`${X}.bind(${T?.bind})`:X}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 X=this.requiresContextFor(W);if(X)this.line(`${this.ctx}.path.push(${$})`);if(this.check(W,{arg:T}),X)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 JU=($)=>W$($,(T,W)=>[T,R$(W)?[...W]:W]),C4=L6("arkKind"),d=($,T)=>$?.[C4]===T,v$=($)=>d($,"root")||d($,"constraint");var LV=["unit","proto","domain"],vT=["required","optional","index","sequence"],F_=["pattern","divisor","exactLength","max","min","maxLength","minLength","before","after"],wU=[...F_,...vT,"structure","predicate"],jT=["alias","union","morph","unit","intersection","proto","domain"],Oq=[...jT,...wU],zU=W$(wU,($,T)=>[T,1]),SV=W$([...vT,"undeclared"],($,T)=>[T,1]),BV=W$(Oq,($,T)=>[T,$]),xT=($)=>typeof $==="string"&&($ in BV);var bT=($)=>BV[$],_U=($)=>jT.slice(bT($)+1),$e=[..._U("union"),"alias"],Te=[..._U("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 _1($)},p1=($)=>{let T="{ ";for(let[W,X]of Object.entries($))T+=`${W}: ${_1(X)}, `;return T+" }"},Y$=($)=>{let T=$;if(T.hasAssociatedError)T.defaults.expected??=(W)=>("description"in W)?W.description:T.defaults.description(W),T.defaults.actual??=(W)=>X$(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 X=`${W.propString} ${W.problem}`;if(X[0]==="[")return`value at ${X}`;return X};return T};class RV extends Error{name="ToJsonSchemaError";code;context;constructor($,T){super(X$(T,{quoteKeys:!1,indent:4}));this.code=$,this.context=T}hasCode($){return this.code===$}}var Vq={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:RV,throw:(...$)=>{throw new y$.Error(...$)},throwInternalOperandError:($,T)=>D$(`Unexpected JSON Schema input for ${$}: ${X$(T)}`),defaultConfig:Vq};I.config??={};var FX=($,T)=>{if(!T)return $;let W={...$},X;for(X in T){let Y={...$.keywords};if(X==="keywords"){for(let U in T[X]){let G=T.keywords[U];if(G===void 0)continue;Y[U]=typeof G==="string"?{description:G}:G}W.keywords=Y}else if(X==="toJsonSchema")W[X]=Q_($.toJsonSchema,T.toJsonSchema);else if(xT(X))W[X]={...$[X],...T[X]};else W[X]=T[X]}return W},Q_=($,T)=>{if(!$)return T??{};if(!T)return $;let W={...$},X;for(X in T)if(X==="fallback")W.fallback=Kq($.fallback,T.fallback);else W[X]=T[X];return W},Kq=($,T)=>{$=IV($),T=IV(T);let W={},X;for(X in y$.defaultConfig.fallback)W[X]=T[X]??T.default??$[X]??$.default??y$.defaultConfig.fallback[X];return W},IV=($)=>typeof $==="function"?{default:$}:$??{};class o1 extends TX{[C4]="error";path;data;nodeConfig;input;ctx;constructor({prefixPath:$,relativePath:T,...W},X){super();this.input=W,this.ctx=X,sO(this,W);let Y=X.data;if(W.code==="union")W.errors=W.errors.flatMap((G)=>{let J=G.hasCode("union")?G.errors:[G];if(!$&&!T)return J;return J.map((z)=>z.transform((w)=>({...w,path:lO($,w.path,T)})))});this.nodeConfig=X.config[this.code];let U=[...W.path??X.path];if(T)U.push(...T);if($)U.unshift(...$);this.path=new _X(...U),this.data="data"in W?W.data:Y}transform($){return new o1($({data:this.data,path:this.path,...this.input}),this.ctx)}hasCode($){return this.code===$}get propString(){return z1(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 u4 extends XU{[C4]="errors";ctx;constructor($){super();this.ctx=$}byPath=Object.create(null);get flatByPath(){return W$(this.byPath,($,T)=>[$,T.flat])}get flatProblemsByPath(){return W$(this.byPath,($,T)=>[$,T.flat.map((W)=>W.problem)])}byAncestorPath=Object.create(null);count=0;mutable=this;throw(){throw this.toTraversalError()}toTraversalError(){return new Z_(this)}add($){if(this.includes($))return;this._add($)}transform($){let T=new u4(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 o1({...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(`
122
- `)}_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 o1({code:"intersection",errors:T.hasCode("intersection")?[...T.errors,$]:[T,$]},this.ctx),X=this.indexOf(T);this.mutable[X===-1?this.length:X]=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]=F$(this.byAncestorPath[T],$)}}class Z_ extends Error{name="TraversalError";constructor($){if($.length===1)super($.summary);else super(`
123
- `+$.map((T)=>` \u2022 ${Eq(T)}`).join(`
124
- `));Object.defineProperty(this,"arkErrors",{value:$,enumerable:!1})}}var Eq=($)=>$.toString().split(`
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(`
125
126
  `).join(`
126
- `);class B6{path=[];errors=new u4(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 z1(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 _X(...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 o1($,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),X;if(W!==void 0){X=this.root;for(let Y=0;Y<$.length-1;Y++)X=X[$[Y]]}this.path=[...$];for(let Y of T){let U=v$(Y),G=Y(X===void 0?this.root:X[W],this);if(G instanceof o1){this.errors.add(G);break}if(G instanceof u4){if(!U)this.errors.merge(G);break}if(X===void 0)this.root=G;else X[W]=G;this.applyQueuedMorphs()}}}var p4=($,T,W)=>{if(!W)return T();W.path.push($);let X=T();return W.path.pop(),X};class ZX extends S6{attachments;$;onFail;includesTransform;includesContextualPredicate;isCyclic;allowsRequiresContext;rootApplyStrategy;contextFreeMorph;rootApply;referencesById;shallowReferences;flatRefs;flatMorphs;allows;get shallowMorphs(){return[]}constructor($,T){super((X,Y,U=this.onFail)=>{if(Y)return this.traverseApply(X,Y),Y.hasError()?Y.errors:Y.data;return this.rootApply(X,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((X,Y)=>Lq(X,Y.shallowReferences),[this]);let W=this.isStructural();this.flatRefs=[],this.flatMorphs=[];for(let X=0;X<this.children.length;X++){if(this.includesTransform||=this.children[X].includesTransform,this.includesContextualPredicate||=this.children[X].includesContextualPredicate,this.isCyclic||=this.children[X].isCyclic,!W){let Y=this.children[X].flatRefs;for(let U=0;U<Y.length;U++){let G=Y[U];if(!this.flatRefs.some((J)=>qV(J,G))){this.flatRefs.push(G);for(let J of G.node.branches)if(J.hasKind("morph")||J.hasKind("intersection")&&J.structure?.structuralMorph!==void 0)this.flatMorphs.push({path:G.path,propString:G.propString,node:J})}}}Object.assign(this.referencesById,this.children[X].referencesById)}this.flatRefs.sort((X,Y)=>X.path.length>Y.path.length?1:X.path.length<Y.path.length?-1:X.propString>Y.propString?1:X.propString<Y.propString?-1:X.node.expression<Y.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((X)=>X.length===1||X.name==="$arkStructuralMorph")?this.hasKind("union")?this.branches.some((X)=>X.shallowMorphs.length>1)?"contextual":"branchedOptimistic":this.shallowMorphs.length>1?"contextual":"optimistic":"contextual":"contextual",this.rootApply=this.createRootApply(),this.allows=this.allowsRequiresContext?(X)=>this.traverseAllows(X,new B6(X,this.$.resolvedConfig)):(X)=>this.traverseAllows(X)}createRootApply(){switch(this.rootApplyStrategy){case"allows":return(T,W)=>{if(this.allows(T))return T;let X=new B6(T,this.$.resolvedConfig);return this.traverseApply(T,X),X.finalize(W)};case"contextual":return(T,W)=>{let X=new B6(T,this.$.resolvedConfig);return this.traverseApply(T,X),X.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 X=new B6(T,this.$.resolvedConfig);return this.traverseApply(T,X),X.finalize(W)};case"branchedOptimistic":return this.createBranchedOptimisticRootApply();default:return this.rootApplyStrategy,D$(`Unexpected rootApplyStrategy ${this.rootApplyStrategy}`)}}compiledMeta=Nq(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=bT(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,X]of this.innerEntries){let Y=this.impl.keys[W];if(Y.reduceIo)Y.reduceIo($,T,X);else if(Y.child){let U=X;T[W]=R$(U)?U.map((G)=>G[$]):U[$]}else T[W]=X}return this.$.node(this.kind,T)}toJSON(){return this.json}toString(){return`Type<${this.expression}>`}equals($){let T=v$($)?$:this.$.parseDefinition($);return this.innerHash===T.innerHash}ifEquals($){return this.equals($)?this:void 0}hasKind($){return this.kind===$}assertHasKind($){if(this.kind!==$)P0(`${this.kind} node was not of asserted kind ${$}`);return this}hasKindIn(...$){return $.includes(this.kind)}assertHasKindIn(...$){if(!U1($,this.kind))P0(`${this.kind} node was not one of asserted kinds ${$}`);return this}isBasis(){return U1(LV,this.kind)}isConstraint(){return U1(wU,this.kind)}isStructural(){return U1(vT,this.kind)}isRefinement(){return U1(F_,this.kind)}isRoot(){return U1(jT,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=QX.normalize($);return this._select(T)}_select($){let T=QX.applyBoundary[$.boundary??"references"](this);if($.kind)T=T.filter((W)=>W.kind===$.kind);if($.where)T=T.filter($.where);return QX.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 X;if(T.seen[this.id]=()=>X,this.hasKind("structure")&&this.undeclared!==T.undeclaredKeyHandling)T={...T,undeclaredKeyHandling:this.undeclared};let Y=W$(this.inner,(w,H)=>{if(!this.impl.keys[w].child)return[w,H];let _=H;if(!R$(_)){let D=_._transform($,T);return D?[w,D]:[]}if(_.length===0)return[w,H];let F=_.flatMap((D)=>{return D._transform($,T)??[]});return F.length?[w,F]:[]});delete T.seen[this.id];let U=Object.assign(Y,{meta:this.meta}),G=T.selected&&!T.selected.includes(this)?U:$(this.kind,U,T);if(G===null)return null;if(v$(G))return X=G;let J=Object.keys(G);if((J.length===0||J.length===1&&J[0]==="meta")&&!m6(this.inner))return null;if((this.kind==="required"||this.kind==="optional"||this.kind==="index")&&!("value"in G))return T.undeclaredKeyHandling?{...G,value:I.intrinsic.unknown}:null;if(this.kind==="morph")G.in??=I.intrinsic.unknown;return X=W.node(this.kind,G,T.parseOptions)}configureReferences($,T="references"){let W=QX.normalize(T),X=typeof $==="string"?(J,z)=>({...z,meta:{...z.meta,description:$}}):typeof $==="function"?(J,z)=>({...z,meta:$(z.meta)}):(J,z)=>({...z,meta:{...z.meta,...$}});if(W.boundary==="self")return this.$.node(this.kind,X(this.kind,{...this.inner,meta:this.meta}));let Y=this._select(W),U=Y&&g1(Y),G=W.boundary==="child"?(J,z)=>z.root.children.includes(J):W.boundary==="shallow"?(J)=>J.kind!=="structure":()=>!0;return this.$.finalize(this.transform(X,{shouldTransform:G,selected:U}))}}var QX={applyBoundary:{self:($)=>[$],child:($)=>[...$.children],shallow:($)=>[...$.shallowReferences],references:($)=>[...$.references]},applyMethod:{filter:($)=>$,assertFilter:($,T,W)=>{if($.length===0)P0(kV(T,W));return $},find:($)=>$[0],assertFind:($,T,W)=>{if($.length===0)P0(kV(T,W));return $[0]}},normalize:($)=>typeof $==="function"?{boundary:"references",method:"filter",where:$}:typeof $==="string"?z4($,QX.applyBoundary)?{method:"filter",boundary:$}:{boundary:"references",method:"filter",kind:$}:{boundary:"references",method:"filter",...$}},kV=($,T)=>`${$} had no references matching ${X$(T)}.`,Aq=($)=>z1($,{stringifyNonKey:(T)=>T.expression}),Mq=/"(\$ark\.[^"]+)"/g,Nq=($)=>JSON.stringify($).replaceAll(Mq,"$1"),R6=($,T)=>({path:$,node:T,propString:Aq($)}),qV=($,T)=>$.propString===T.propString&&$.node.equals(T.node),D_=($,T)=>g6($,T,{isEqual:qV}),Lq=($,T)=>g6($,T,{isEqual:(W,X)=>W.equals(X)});class f extends Array{static init($,T,W,X){return new f({kind:$,l:T,r:W,path:X?.path??[],optional:X?.optional??!1})}add($,T,W,X){return this.push({kind:$,l:T,r:W,path:X?.path??[],optional:X?.optional??!1}),this}get summary(){return this.describeReasons()}describeReasons(){if(this.length===1){let{path:$,l:T,r:W}=this[0],X=z1($);return V_(`Intersection${X&&` at ${X}`} of ${PV(T,W)}`)}return`The following intersections result in unsatisfiable types:
127
- \u2022 ${this.map(({path:$,l:T,r:W})=>`${$}: ${PV(T,W)}`).join(`
128
- \u2022 `)}`}throw(){return L(this.describeReasons())}invert(){let $=this.map((T)=>({...T,l:T.r,r:T.l}));if(!($ instanceof f))return new f(...$);return $}withPrefixKey($,T){return this.map((W)=>({...W,path:[$,...W.path],optional:W.optional||T==="optional"}))}toNeverIfDisjoint(){return I.intrinsic.never}}var PV=($,T)=>`${O_($)} and ${O_(T)}`,O_=($)=>v$($)?$.expression:R$($)?$.map(O_).join(" | ")||"never":String($),V_=($)=>`${$} results in an unsatisfiable type`;var fT={},o4=($,T,W)=>j$($,T,{$:W,invert:!1,pipe:!1}),DX=($,T,W)=>j$($,T,{$:W,invert:!1,pipe:!0}),j$=($,T,W)=>{let X=W.pipe?"|>":"&",Y=`${$.hash}${X}${T.hash}`;if(fT[Y]!==void 0)return fT[Y];if(!W.pipe){let J=`${T.hash}${X}${$.hash}`;if(fT[J]!==void 0){let z=fT[J],w=z instanceof f?z.invert():z;return fT[Y]=w,w}}let U=!W.pipe||!$.includesTransform&&!T.includesTransform;if(U&&$.equals(T))return $;let G=U?K_($,T,W):$.hasKindIn(...jT)?Sq($,T,W):K_($,T,W);if(v$(G)){if($.equals(G))G=$;else if(T.equals(G))G=T}return fT[Y]=G,G},K_=($,T,W)=>{let X=$.precedence<T.precedence?$.kind:T.kind,Y=$.impl.intersections[T.kind]??T.impl.intersections[$.kind];if(Y===void 0)return null;else if(X===$.kind)return Y($,T,W);else{let U=Y(T,$,{...W,invert:!W.invert});if(U instanceof f)U=U.invert();return U}},Sq=($,T,W)=>$.includesTransform||T.includesTransform?W.invert?CV(T,$,W):CV($,T,W):K_($,T,W),CV=($,T,W)=>$.distribute((X)=>Bq(X,T,W),(X)=>{let Y=X.filter(v$);if(Y.length===0)return f.init("union",$.branches,T.branches);if(Y.length<$.branches.length||!$.branches.every((J,z)=>J.in.equals(Y[z].in)))return W.$.parseSchema(Y);let U;if(Y.length===1){let J=Y[0];if(!U)return J;return W.$.node("morph",{...J.inner,in:J.in.configure(U,"self")})}let G={branches:Y};if(U)G.meta=U;return W.$.parseSchema(G)}),Bq=($,T,W)=>{if($.hasKind("morph")){let Y=[...$.morphs];if($.lastMorphIfNode){let U=j$($.lastMorphIfNode,T,W);if(U instanceof f)return U;Y[Y.length-1]=U}else Y.push(T);return W.$.node("morph",{morphs:Y,in:$.inner.in})}if(T.hasKind("morph")){let Y=j$($,T.in,W);if(Y instanceof f)return Y;return W.$.node("morph",{morphs:[T],in:Y})}return W.$.node("morph",{morphs:[T],in:$})};class F6 extends ZX{constructor($,T){super($,T);Object.defineProperty(this,C4,{value:"constraint",enumerable:!1})}impliedSiblings;intersect($){return o4(this,$,this.$)}}class H1 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 p1(this.errorContext)}}var S4=($)=>(T,W)=>{if(R$(T)){if(T.length===0)return;let Y=T.map((U)=>W.$.node($,U));if($==="predicate")return Y;return Y.sort((U,G)=>U.hash<G.hash?-1:1)}let X=W.$.node($,T);return X.hasOpenIntersection()?[X]:X},yT=($)=>{let T=$.r.shift();if(!T){let X=$.l.length===0&&$.kind==="structure"?I.intrinsic.unknown.internal:$.ctx.$.node($.kind,Object.assign($.baseInner,Rq($.l)),{prereduced:!0});for(let Y of $.roots){if(X instanceof f)return X;X=j$(Y,X,$.ctx)}return X}let W=!1;for(let X=0;X<$.l.length;X++){let Y=j$($.l[X],T,$.ctx);if(Y===null)continue;if(Y instanceof f)return Y;if(!W){if(Y.isRoot())return $.roots.push(Y),$.l.splice(X),yT($);$.l[X]=Y,W=!0}else if(!$.l.includes(Y))return D$(`Unexpectedly encountered multiple distinct intersection results for refinement ${Y}`)}if(!W)$.l.push(T);if($.kind==="intersection"){if(T.impliedSiblings)for(let X of T.impliedSiblings)g6($.r,X)}return yT($)},hT=($)=>{return Object.entries($).flatMap(([W,X])=>(W in zU)?X:[]).sort((W,X)=>W.precedence<X.precedence?-1:W.precedence>X.precedence?1:W.kind==="predicate"&&X.kind==="predicate"?0:W.hash<X.hash?-1:1)},Rq=($)=>{let T={};for(let W of $)if(W.hasOpenIntersection())T[W.kind]=F$(T[W.kind],W);else{if(T[W.kind])return D$(`Unexpected intersection of closed refinements of kind ${W.kind}`);T[W.kind]=W}return T},vV=(...$)=>L(jV(...$)),jV=($,T,W)=>{let X=W.hasKind("morph")?"a morph":W.isUnknown()?"unknown":W.exclude(T).defaultShortDescription;return`${wV($)} operand must be ${T.description} (was ${X})`};var xV=($,T,W)=>new d1($,T,W,W,null);class HU extends S6{}class d1 extends S6{[C4]="generic";paramDefs;bodyDef;$;arg$;baseInstantiation;hkt;description;constructor($,T,W,X,Y){super((...U)=>{let G=W$(this.names,(J,z)=>{let w=this.arg$.parse(U[J]);if(!w.extends(this.constraints[J]))L(Iq(z,this.constraints[J].expression,w.expression));return[z,w]});if(this.defIsLazy()){let J=this.bodyDef(G);return this.$.parse(J)}return this.$.parse(T,{args:G})});this.paramDefs=$,this.bodyDef=T,this.$=W,this.arg$=X,this.hkt=Y,this.description=Y?new Y().description??`a generic type for ${Y.constructor.name}`:"a generic type",this.baseInstantiation=this(...this.constraints)}defIsLazy(){return this.bodyDef instanceof HU}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:EV(this.bodyDef)})}get params(){return this.cacheGetter("params",this.paramDefs.map(($)=>typeof $==="string"?[$,I.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 Iq=($,T,W)=>`${$} must be assignable to ${T} (was ${W})`;var kq=Y$({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 bV 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=p1(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 E_={implementation:kq,Node:bV};var qq=Y$({kind:"divisor",collapsibleKey:"rule",keys:{rule:{parse:($)=>Number.isInteger($)?$:L(Pq($))}},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/Cq($.rule,T.rule))})},obviatesBasisDescription:!0});class fV extends H1{traverseAllows=($)=>$%this.rule===0;compiledCondition=`data % ${this.rule} === 0`;compiledNegation=`data % ${this.rule} !== 0`;impliedBasis=I.intrinsic.number.internal;expression=`% ${this.rule}`;reduceJsonSchema($){if($.type="integer",this.rule===1)return $;return $.multipleOf=this.rule,$}}var A_={implementation:qq,Node:fV};var Pq=($)=>`divisor must be an integer (was ${$})`,Cq=($,T)=>{let W,X=$,Y=T;while(Y!==0)W=Y,Y=X%Y,X=W;return X};class X6 extends H1{boundOperandKind=bq[this.kind];compiledActual=this.boundOperandKind==="value"?"data":this.boundOperandKind==="length"?"data.length":"data.valueOf()";comparator=fq(this.kind,this.exclusive);numericLimit=this.rule.valueOf();expression=`${this.comparator} ${this.rule}`;compiledCondition=`${this.compiledActual} ${this.comparator} ${this.numericLimit}`;compiledNegation=`${this.compiledActual} ${vq[this.comparator]} ${this.numericLimit}`;stringLimit=this.boundOperandKind==="date"?yq(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 vq={"<":">=","<=":">",">":"<=",">=":"<"},jq={min:"max",minLength:"maxLength",after:"before"},FU={parse:($)=>$||void 0},QU=($)=>(T)=>{if(typeof T==="number")return{rule:T};let{exclusive:W,...X}=T;return W?{...X,rule:$==="minLength"?X.rule+1:X.rule-1}:X},ZU=($)=>(T)=>{if(typeof T==="number"||typeof T==="string"||T instanceof Date)return{rule:T};let{exclusive:W,...X}=T;if(!W)return X;let Y=typeof X.rule==="number"?X.rule:typeof X.rule==="string"?new Date(X.rule).valueOf():X.rule.valueOf();return W?{...X,rule:$==="after"?Y+1:Y-1}:X},DU=($)=>typeof $==="string"||typeof $==="number"?new Date($):$,xq=($,T)=>`${$} bound must be a positive integer (was ${T})`,gT=($)=>(T)=>{if(!Number.isInteger(T)||T<0)L(xq($,T));return T},bq={min:"value",max:"value",minLength:"length",maxLength:"length",after:"date",before:"date"},fq=($,T)=>`${z4($,jq)?">":"<"}${T?"":"="}`,yq=($)=>typeof $==="string"?$:new Date($).toLocaleString(),yV=($)=>`Bounded expression ${$} must be exactly one of number, string, Array, or Date`;var hq=Y$({kind:"after",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:DU,serialize:($)=>$.toISOString()}},normalize:ZU("after"),defaults:{description:($)=>`${$.collapsibleLimitString} or later`,actual:x0},intersections:{after:($,T)=>$.isStricterThan(T)?$:T}});class hV extends X6{impliedBasis=I.intrinsic.Date.internal;collapsibleLimitString=x0(this.rule);traverseAllows=($)=>$>=this.rule;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,after:this.rule})}}var M_={implementation:hq,Node:hV};var gq=Y$({kind:"before",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:DU,serialize:($)=>$.toISOString()}},normalize:ZU("before"),defaults:{description:($)=>`${$.collapsibleLimitString} or earlier`,actual:x0},intersections:{before:($,T)=>$.isStricterThan(T)?$:T,after:($,T,W)=>$.overlapsRange(T)?$.overlapIsUnit(T)?W.$.node("unit",{unit:$.rule}):null:f.init("range",$,T)}});class gV extends X6{collapsibleLimitString=x0(this.rule);traverseAllows=($)=>$<=this.rule;impliedBasis=I.intrinsic.Date.internal;reduceJsonSchema($,T){return T.fallback.date({code:"date",base:$,before:this.rule})}}var N_={implementation:gq,Node:gV};var mq=Y$({kind:"exactLength",collapsibleKey:"rule",keys:{rule:{parse:gT("exactLength")}},normalize:($)=>typeof $==="number"?{rule:$}:$,hasAssociatedError:!0,defaults:{description:($)=>`exactly length ${$.rule}`,actual:($)=>`${$.length}`},intersections:{exactLength:($,T,W)=>f.init("unit",W.$.node("unit",{unit:$.rule}),W.$.node("unit",{unit:T.rule}),{path:["length"]}),minLength:($,T)=>$.rule>=T.rule?$:f.init("range",$,T),maxLength:($,T)=>$.rule<=T.rule?$:f.init("range",$,T)}});class mV extends H1{traverseAllows=($)=>$.length===this.rule;compiledCondition=`data.length === ${this.rule}`;compiledNegation=`data.length !== ${this.rule}`;impliedBasis=I.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 L_={implementation:mq,Node:mV};var cq=Y$({kind:"max",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:FU},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:f.init("range",$,T)},obviatesBasisDescription:!0});class cV extends X6{impliedBasis=I.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$<this.rule:($)=>$<=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMaximum=this.rule;else $.maximum=this.rule;return $}}var S_={implementation:cq,Node:cV};var uq=Y$({kind:"maxLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:gT("maxLength")}},reduce:($,T)=>$.rule===0?T.node("exactLength",$):void 0,normalize:QU("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:f.init("range",$,T)}});class uV extends X6{impliedBasis=I.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 B_={implementation:uq,Node:uV};var pq=Y$({kind:"min",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{},exclusive:FU},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 pV extends X6{impliedBasis=I.intrinsic.number.internal;traverseAllows=this.exclusive?($)=>$>this.rule:($)=>$>=this.rule;reduceJsonSchema($){if(this.exclusive)$.exclusiveMinimum=this.rule;else $.minimum=this.rule;return $}}var R_={implementation:pq,Node:pV};var oq=Y$({kind:"minLength",collapsibleKey:"rule",hasAssociatedError:!0,keys:{rule:{parse:gT("minLength")}},reduce:($)=>$.rule===0?I.intrinsic.unknown:void 0,normalize:QU("minLength"),defaults:{description:($)=>$.rule===1?"non-empty":`at least length ${$.rule}`,actual:($)=>$.length===0?"":`${$.length}`},intersections:{minLength:($,T)=>$.isStricterThan(T)?$:T}});class oV extends X6{impliedBasis=I.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 I_={implementation:oq,Node:oV};var dV={min:R_.implementation,max:S_.implementation,minLength:I_.implementation,maxLength:B_.implementation,exactLength:L_.implementation,after:M_.implementation,before:N_.implementation},lV={min:R_.Node,max:S_.Node,minLength:I_.Node,maxLength:B_.Node,exactLength:L_.Node,after:M_.Node,before:N_.Node};var dq=Y$({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 rV extends H1{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=I.intrinsic.string.internal;reduceJsonSchema($,T){if($.pattern)return T.fallback.patternIntersection({code:"patternIntersection",base:$,pattern:this.rule});return $.pattern=this.rule,$}}var k_={implementation:dq,Node:rV};var OX=($,T)=>{let W=lq($);if(T&&!T.includes(W))return L(`Root of kind ${W} should be one of ${T}`);return W},lq=($)=>{if(d($,"root"))return $.kind;if(typeof $==="string")return $[0]==="$"?"alias":($ in c4)?"domain":"proto";if(typeof $==="function")return"proto";if(typeof $!=="object"||$===null)return L(iV($));if("morphs"in $)return"morph";if("branches"in $||R$($))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 zU)))return"intersection";if("proto"in $)return"proto";if("domain"in $)return"domain";return L(iV($))},iV=($)=>`${X$($)} is not a valid type schema`,nV={},rq=($)=>R$($)?$.map((T)=>T.collapsibleJson):$.collapsibleJson,v4={};I.nodesByRegisteredId=v4;var q_=($)=>{return nV[$]??=0,`${$}${++nV[$]}`},P_=($)=>{let T=mT[$.kind],W=T.applyConfig?.($.def,$.$.resolvedConfig)??$.def,X={},{meta:Y,...U}=W,G=Y===void 0?{}:typeof Y==="string"?{description:Y}:Y,J=e7(U).sort(([w],[H])=>xT(w)?xT(H)?bT(w)-bT(H):1:xT(H)?-1:w<H?-1:1).filter(([w,H])=>{if(w.startsWith("meta.")){let _=w.slice(5);return G[_]=H,!1}return!0});for(let w of J){let H=w[0],_=T.keys[H];if(!_)return L(`Key ${H} is not valid on ${$.kind} schema`);let F=_.parse?_.parse(w[1],$):w[1];if(F!==W6&&(F!==void 0||_.preserveUndefined))X[H]=F}if(T.reduce&&!$.prereduced){let w=T.reduce(X,$.$);if(w){if(w instanceof f)return w.throw();return iq(w,G)}}return C_({id:$.id,kind:$.kind,inner:X,meta:G,$:$.$})},C_=({id:$,kind:T,inner:W,meta:X,$:Y,ignoreCache:U})=>{let G=mT[T],J=e7(W),z=[],w={};for(let[P,M]of J){let N=G.keys[P],k=N.serialize??(N.child?rq:H6);if(w[P]=k(M),N.child===!0){let y=M;if(R$(y))z.push(...y);else z.push(y)}else if(typeof N.child==="function")z.push(...N.child(M))}if(G.finalizeInnerJson)w=G.finalizeInnerJson(w);let H={...w},_={};if(!m6(X))_=W$(X,(P,M)=>[P,P==="examples"?M:H6(M)]),H.meta=OU(_,"description",!0);w=OU(w,G.collapsibleKey,!1);let F=JSON.stringify({kind:T,...w});H=OU(H,G.collapsibleKey,!1);let D=OU(H,G.collapsibleKey,!0),V=JSON.stringify({kind:T,...H});if(Y.nodesByHash[V]&&!U)return Y.nodesByHash[V];let E={id:$,kind:T,impl:G,inner:W,innerEntries:J,innerJson:w,innerHash:F,meta:X,metaJson:_,json:H,hash:V,collapsibleJson:D,children:z};if(T!=="intersection"){for(let P in W)if(P!=="in"&&P!=="out")E[P]=W[P]}let R=new aV[T](E,Y);return Y.nodesByHash[V]=R},tV=($,T)=>{if($.id===T)return $;if(v$(v4[T]))D$(`Unexpected attempt to overwrite node id ${T}`);return C_({id:T,kind:$.kind,inner:$.inner,meta:$.meta,$:$.$,ignoreCache:!0})},iq=($,T,W)=>{if(W&&v$(v4[W]))D$(`Unexpected attempt to overwrite node id ${W}`);return C_({id:W??q_(T.alias??$.kind),kind:$.kind,inner:$.inner,meta:T,$:$.$})},OU=($,T,W)=>{let X=Object.keys($);if(X.length===1&&X[0]===T){let Y=$[T];if(W)return Y;if(m4(Y,"object")&&(Object.keys(Y).length===1||Array.isArray(Y)))return Y}return $};var VX=($,T,W)=>{if($.key!==T.key)return null;let X=$.key,Y=j$($.value,T.value,W),U=$.required||T.required?"required":"optional";if(Y instanceof f)if(U==="optional")Y=I.intrinsic.never.internal;else return Y.withPrefixKey($.key,$.required&&T.required?"required":"optional");if(U==="required")return W.$.node("required",{key:X,value:Y});let G=$.hasDefault()?T.hasDefault()?$.default===T.default?$.default:L(v_($.default,T.default)):$.default:T.hasDefault()?T.default:W6;return W.$.node("optional",{key:X,value:Y,default:G})};class KX extends F6{required=this.kind==="required";optional=this.kind==="optional";impliedBasis=I.intrinsic.object.internal;serializedKey=_1(this.key);compiledKey=typeof this.key==="string"?this.key:this.serializedKey;flatRefs=F$(this.value.flatRefs.map(($)=>R6([this.key,...$.path],$.node)),R6([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 p4(this.key,()=>this.value.traverseAllows($[this.key],T),T);return this.optional};traverseApply=($,T)=>{if(this.key in $)p4(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 v_=($,T)=>`Invalid intersection of default values ${X$($)} & ${X$(T)}`;var nq=Y$({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:VX}});class sV extends KX{constructor(...$){super(...$);if("default"in this.inner)AX(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} = ${X$(this.inner.default)}`:`${this.compiledKey}?: ${this.value.expression}`;defaultValueMorph=aq(this);defaultValueMorphRef=this.defaultValueMorph&&o$(this.defaultValueMorph)}var EX={implementation:nq,Node:sV},tq={},aq=($)=>{if(!$.hasDefault())return;let T=`{${$.compiledKey}: ${$.value.id} = ${H6($.default)}}`;return tq[T]??=j_($.key,$.value,$.default)},j_=($,T,W)=>{if(typeof W==="function")return T.includesTransform?(Y,U)=>{return p4($,()=>T(Y[$]=W(),U),U),Y}:(Y)=>{return Y[$]=W(),Y};let X=T.includesTransform?T.assert(W):W;return m4(X,"object")?(Y,U)=>{return p4($,()=>T(Y[$]=W,U),U),Y}:(Y)=>{return Y[$]=X,Y}},AX=($,T,W)=>{let X=m1(T);if(m4(T,"object")&&!X)L(sq(W));let Y=$.in(X?T():T);if(Y instanceof u4){if(W===null)L(`Default ${Y.summary}`);let U=Y.transform((G)=>G.transform((J)=>({...J,prefixPath:[W]})));L(`Default for ${U.summary}`)}return T},sq=($)=>{return`Non-primitive default ${$===null?"":typeof $==="number"?`for value at [${$}] `:`for ${_1($)} `}must be specified as a function like () => ({my: 'object'})`};class Q6 extends ZX{constructor($,T){super($,T);Object.defineProperty(this,C4,{value:"root",enumerable:!1})}get internal(){return this}get "~standard"(){return{vendor:"arktype",version:1,validate:($)=>{let T=this($);if(T instanceof u4)return T;return{value:T}}}}as(){return this}brand($){if($==="")return L(eq);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=Q_(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=W$(this.references,(X,Y)=>Y.isRoot()&&!Y.alwaysExpandJsonSchema?[Y.id,Y.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 f)return W;return this.$.finalize(W)}rawIntersect($){return o4(this,$,this.$)}toNeverIfDisjoint(){return this}and($){let T=this.intersect($);return T instanceof f?T.throw():T}rawAnd($){let T=this.rawIntersect($);return T instanceof f?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(),I.intrinsic.unknown.internal);if($.branches.length===0)L(V_(`keyof ${this.expression}`));return this._keyof=this.$.finalize($)}get props(){if(this.branches.length!==1)return L($P(this.expression));return[...this.applyStructuralOperation("props",[])[0]]}merge($){let T=this.$.parseDefinition($);return this.$.schema(T.distribute((W)=>this.applyStructuralOperation("merge",[eV(W)??L($K("merge",W.expression))])))}applyStructuralOperation($,T){return this.distribute((W)=>{if(W.equals(I.intrinsic.object)&&$!=="merge")return W;let X=eV(W);if(!X)L($K($,W.expression));if($==="keyof")return X.keyof();if($==="get")return X.get(...T);if($==="props")return X.props;let Y=$==="required"?"require":$==="partial"?"optionalize":$;return this.$.node("intersection",{...W.inner,structure:X[Y](...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 f)}extends($){let T=this.intersect($);return!(T instanceof f)&&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 AX(this,$,null),[this,"=",$]}from($){return this.assert($)}_pipe(...$){let T=$.reduce((W,X)=>W.rawPipeOnce(X),this);return this.$.finalize(T)}tryPipe(...$){let T=$.reduce((W,X)=>W.rawPipeOnce(d(X,"root")?X:(Y,U)=>{try{return X(Y,U)}catch(G){return U.error({code:"predicate",predicate:X,actual:`aborted due to error:
129
- ${G}
130
- `})}}),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=DX(this,$,this.$);if(T instanceof f)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 X=this.$.node(T,W);if(X.isRoot())return X.isUnknown()?this:D$(`Unexpected constraint node ${X}`);let Y=$==="root"?this:this[$];if(Y.hasKind("morph")||X.impliedBasis&&!Y.extends(X.impliedBasis))return vV(T,X.impliedBasis,this);let U=this.$.node("intersection",{[X.kind]:X}),G=$==="out"?DX(this,U,this.$):o4(this,U,this.$);if(G instanceof f)G.throw();return this.$.finalize(G)}onUndeclaredKey($){let T=typeof $==="string"?$:$.rule,W=typeof $==="string"?!1:$.deep;return this.$.finalize(this.transform((X,Y)=>X==="structure"?T==="ignore"?aO(Y,{undeclared:1}):{...Y,undeclared:T}:Y,W?void 0:{shouldTransform:(X)=>!U1(vT,X.kind)}))}hasEqualMorphs($){if(!this.includesTransform&&!$.includesTransform)return!0;if(!J1(this.shallowMorphs,$.shallowMorphs))return!1;if(!J1(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",cT($))}lessThan($){return this.constrain("max",cT($))}atLeastLength($){return this.constrain("minLength",$)}atMostLength($){return this.constrain("maxLength",$)}moreThanLength($){return this.constrain("minLength",cT($))}lessThanLength($){return this.constrain("maxLength",cT($))}exactlyLength($){return this.constrain("exactLength",$)}atOrAfter($){return this.constrain("after",$)}atOrBefore($){return this.constrain("before",$)}laterThan($){return this.constrain("after",cT($))}earlierThan($){return this.constrain("before",cT($))}}var eq="Expected a non-empty brand name after #",cT=($)=>typeof $==="object"&&!($ instanceof Date)?{...$,exclusive:!0}:{rule:$,exclusive:!0},MX=($,T)=>d(T,"root")?d($,"root")?$.extends(T):T.allows($):d($,"root")?$.hasUnit(T):T===$,eV=($)=>{if($.hasKind("morph"))return null;if($.hasKind("intersection"))return $.inner.structure??($.basis?.domain==="object"?$.$.bindReference(I.intrinsic.emptyStructure):null);if($.isBasis()&&$.domain==="object")return $.$.bindReference(I.intrinsic.emptyStructure);return null},$P=($)=>`Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
131
- ${$}`,$K=($,T)=>`${$} operand must be an object (was ${T})`;var c6=($,T)=>W$(_U($),(W,X)=>[X,T]);var TP=($)=>typeof $==="string"?{reference:$}:$,TK=($)=>$ instanceof f?I.intrinsic.never.internal:$,WP=Y$({kind:"alias",hasAssociatedError:!1,collapsibleKey:"reference",keys:{reference:{serialize:($)=>$.startsWith("$")?$:`$ark.${$}`},resolve:{}},normalize:TP,defaults:{description:($)=>$.reference},intersections:{alias:($,T,W)=>W.$.lazilyResolve(()=>TK(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(I.intrinsic.object))return f.init("assignability",I.intrinsic.object,T);return W.$.lazilyResolve(()=>TK(j$($.resolution,T,W)),`${$.reference}${W.pipe?"=>":"&"}${T.id}`)})}});class WK extends Q6{expression=this.reference;structure=void 0;get resolution(){let $=this._resolve();return v4[this.id]=$}_resolve(){if(this.resolve)return this.resolve();if(this.reference[0]==="$")return this.$.resolveRoot(this.reference.slice(1));let $=this.reference,T=v4[$],W=[];while(d(T,"context")){if(W.includes(T.id))return L(XP(T.id,W));W.push(T.id),T=v4[T.id]}if(!d(T,"root"))return D$(`Unexpected resolution for reference ${this.reference}
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}
132
133
  Seen: [${W.join("->")}]
133
- Resolution: ${X$(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 D$(`Unexpected resolution for reference ${this.reference}: ${X$(T)}`)}get defaultShortDescription(){return c4.object}innerToJsonSchema($){return this.resolution.toJsonSchemaRecurse($)}traverseAllows=($,T)=>{let W=T.seen[this.reference];if(W?.includes($))return!0;return T.seen[this.reference]=F$(W,$),this.resolution.traverseAllows($,T)};traverseApply=($,T)=>{let W=T.seen[this.reference];if(W?.includes($))return;T.seen[this.reference]=F$(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 XP=($,T)=>`Alias '${$}' has a shallow resolution cycle: ${[...T,$].join("->")}`,NX={implementation:WP,Node:WK};class b0 extends Q6{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 p1(this.errorContext)}compile($){if($.traversalKind==="Allows")$.return(this.compiledCondition);else $.if(this.compiledNegation,()=>$.line(`${$.ctx}.errorFromNodeContext(${this.compiledErrorContext})`))}}var YP=Y$({kind:"domain",hasAssociatedError:!0,collapsibleKey:"domain",keys:{domain:{},numberAllowsNaN:{}},normalize:($)=>typeof $==="string"?{domain:$}:PT($,"numberAllowsNaN")&&$.domain!=="number"?L(VU.writeBadAllowNanMessage($.domain)):$,applyConfig:($,T)=>$.numberAllowsNaN===void 0&&$.domain==="number"&&T.numberAllowsNaN?{...$,numberAllowsNaN:!0}:$,defaults:{description:($)=>c4[$.domain],actual:($)=>Number.isNaN($)?"NaN":c4[w4($)]},intersections:{domain:($,T)=>$.domain==="number"&&T.domain==="number"?$.numberAllowsNaN?T:$:f.init("domain",$,T)}});class XK extends b0{requiresNaNCheck=this.domain==="number"&&!this.numberAllowsNaN;traverseAllows=this.requiresNaNCheck?($)=>typeof $==="number"&&!Number.isNaN($):($)=>w4($)===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 c4[this.domain]}innerToJsonSchema($){if(this.domain==="bigint"||this.domain==="symbol")return $.fallback.domain({code:"domain",base:{},domain:this.domain});return{type:this.domain}}}var VU={implementation:YP,Node:XK,writeBadAllowNanMessage:($)=>`numberAllowsNaN may only be specified with domain "number" (was ${$})`};var UP=Y$({kind:"intersection",hasAssociatedError:!0,normalize:($)=>{if(v$($))return $;let{structure:T,...W}=$,X=!!T,Y=T??{},U=W$(W,(G,J)=>{if(z4(G,SV)){if(X)L(`Flattened structure key ${G} cannot be specified alongside a root 'structure' key.`);return Y[G]=J,[]}return[G,J]});if(d(Y,"constraint")||!m6(Y))U.structure=Y;return U},finalizeInnerJson:({structure:$,...T})=>m4($,"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:X,...Y}=T,U=Y.variadic&&Object.keys(Y).length===1?Y.variadic:Y;return{...W,sequence:U}}},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)=>YK({},$,{$: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((X,Y)=>X.kind==="min"&&Y.kind==="max"?-1:0).map((X)=>X.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(`
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(`
134
135
  \u25E6 `)}`,problem:($)=>`(${$.actual}) must be...
135
- ${$.expected}`},intersections:{intersection:($,T,W)=>YK($.inner,T.inner,W),...c6("intersection",($,T,W)=>{if($.children.length===0)return T;let{domain:X,proto:Y,...U}=$.inner,G=Y??X,J=G?j$(G,T,W):T;return J instanceof f?J:$?.basis?.equals(J)?$:$.$.node("intersection",{...U,[J.kind]:J},{prereduced:!0})})}});class UK extends Q6{basis=this.inner.domain??this.inner.proto??null;refinements=this.children.filter(($)=>$.isRefinement());structure=this.inner.structure;expression=GP(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 X=0;X<this.refinements.length-1;X++)if(this.refinements[X].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 X=0;X<this.inner.predicate.length-1;X++)if(this.inner.predicate[X].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 x_={implementation:UP,Node:UK},GP=($)=>{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},YK=($,T,W)=>{let X={},Y=$.proto??$.domain,U=T.proto??T.domain,G=Y?U?j$(Y,U,W):Y:U;if(G instanceof f)return G;if(G)X[G.kind]=G;return yT({kind:"intersection",baseInner:X,l:hT($),r:hT(T),roots:[],ctx:W})};var JP=Y$({kind:"morph",hasAssociatedError:!1,keys:{in:{child:!0,parse:($,T)=>T.$.parseSchema($)},morphs:{parse:g1,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 L(wP($.expression,T.expression));let X=j$($.in,T.in,W);if(X instanceof f)return X;let Y={morphs:$.morphs};if($.declaredIn||T.declaredIn){let U=j$($.in,T.in,W);if(U instanceof f)return U.throw();else Y.declaredIn=U}if($.declaredOut||T.declaredOut){let U=j$($.out,T.out,W);if(U instanceof f)return U.throw();else Y.declaredOut=U}return X.distribute((U)=>W.$.node("morph",{...Y,in:U}),W.$.parseSchema)},...c6("morph",($,T,W)=>{let X=$.inner.in?j$($.inner.in,T,W):T;return X instanceof f?X:X.equals($.inner.in)?$:W.$.node("morph",{...$.inner,in:X})})}});class GK extends Q6{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??I.intrinsic.unknown.internal}get out(){return this.declaredOut??this.introspectableOut??I.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 J1(this.morphs,$.morphs,{isEqual:(T,W)=>T===W||d(T,"root")&&d(W,"root")&&T.equals(W)})}}var b_={implementation:JP,Node:GK},wP=($,T)=>`The intersection of distinct morphs at a single path is indeterminate:
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:
136
137
  Left: ${$}
137
- Right: ${T}`;var zP=Y$({kind:"proto",hasAssociatedError:!0,collapsibleKey:"proto",keys:{proto:{serialize:($)=>YX($)??H6($)},dateAllowsInvalid:{}},normalize:($)=>{let T=typeof $==="string"?{proto:v0[$]}:typeof $==="function"?v$($)?$:{proto:$}:typeof $.proto==="string"?{...$,proto:v0[$.proto]}:$;if(typeof T.proto!=="function")L(LX.writeInvalidSchemaMessage(T.proto));if(PT(T,"dateAllowsInvalid")&&T.proto!==Date)L(LX.writeBadInvalidDateMessage(T.proto));return T},applyConfig:($,T)=>{if($.dateAllowsInvalid===void 0&&$.proto===Date&&T.dateAllowsInvalid)return{...$,dateAllowsInvalid:!0};return $},defaults:{description:($)=>$.builtinName?TV[$.builtinName]:`an instance of ${$.proto.name}`,actual:($)=>$ instanceof Date&&$.toString()==="Invalid Date"?"an invalid Date":XX($)},intersections:{proto:($,T)=>$.proto===Date&&T.proto===Date?$.dateAllowsInvalid?T:$:Y_($.proto,T.proto)?$:Y_(T.proto,$.proto)?T:f.init("proto",$,T),domain:($,T)=>T.domain==="object"?$:f.init("domain",I.intrinsic.object.internal,T)}});class JK extends b0{builtinName=YX(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 LX={implementation:zP,Node:JK,writeBadInvalidDateMessage:($)=>`dateAllowsInvalid may only be specified with constructor Date (was ${$.name})`,writeInvalidSchemaMessage:($)=>`instanceOf operand must be a function (was ${w4($)})`};var _P=Y$({kind:"union",hasAssociatedError:!0,collapsibleKey:"branches",keys:{ordered:{},branches:{child:!0,parse:($,T)=>{let W=[];for(let X of $){let Y=d(X,"root")?X.branches:T.$.parseSchema(X).branches;for(let U of Y)if(U.hasKind("morph")){let G=W.findIndex((J)=>J.hasKind("morph")&&J.hasEqualMorphs(U));if(G===-1)W.push(U);else{let J=W[G];W[G]=T.$.node("morph",{...J.inner,in:J.in.rawOr(U.in)})}}else W.push(U)}if(!T.def.ordered)W.sort((X,Y)=>X.hash<Y.hash?-1:1);return W}}},normalize:($)=>R$($)?{branches:$}:$,reduce:($,T)=>{let W=AP($);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,uT),expected:($)=>{let T=rO($.errors,"propString"),W=Object.entries(T).map(([X,Y])=>{let U=[];for(let z of Y)g6(U,z.expected);let G=uT(U),J=Y.every((z)=>z.actual===Y[0].actual)?Y[0].actual:X$(Y[0].data);return`${X&&`${X} `}must be ${G}${J&&` (was ${J})`}`});return uT(W)},problem:($)=>$.expected,message:($)=>$.problem},intersections:{union:($,T,W)=>{if($.isNever!==T.isNever)return f.init("presence",$,T);let X;if($.ordered){if(T.ordered)L(NP($.expression,T.expression));if(X=f_(T.branches,$.branches,W),X instanceof f)X.invert()}else X=f_($.branches,T.branches,W);if(X instanceof f)return X;return W.$.parseSchema($.ordered||T.ordered?{branches:X,ordered:!0}:{branches:X})},...c6("union",($,T,W)=>{let X=f_($.branches,[T],W);if(X instanceof f)return X;if(X.length===1)return X[0];return W.$.parseSchema($.ordered?{branches:X,ordered:!0}:{branches:X})})}});class _K extends Q6{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]=I.intrinsic.boolean;continue}$.push(W)}return $}unitBranches=this.branches.filter(($)=>$.in.hasKind("unit"));discriminant=this.discriminate();discriminantJson=this.discriminant?VP(this.discriminant):null;expression=this.distribute(($)=>$.nestableExpression,EP);createBranchedOptimisticRootApply(){return($,T)=>{let W=this.traverseOptimistic($);if(W!==W6)return W;let X=new B6($,this.$.resolvedConfig);return this.traverseApply($,X),X.finalize(T)}}get shallowMorphs(){return this.branches.reduce(($,T)=>g6($,T.shallowMorphs),[])}get defaultShortDescription(){return this.distribute(($)=>$.defaultShortDescription,uT)}innerToJsonSchema($){if(this.branchGroups.length===1&&this.branchGroups[0].equals(I.intrinsic.boolean))return{type:"boolean"};let T=this.branchGroups.map((W)=>W.toJsonSchemaRecurse($));if(T.every((W)=>Object.keys(W).length===1&&PT(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 X=0;X<this.branches.length;X++){if(T.pushBranch(),this.branches[X].traverseApply($,T),!T.hasError()){if(this.branches[X].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 W6};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,X=Object.keys(W),{optimistic:Y}=$;if($.optimistic=!1,$.block(`switch(${T})`,()=>{for(let w in W){let H=W[w],_=w==="default"?w:`case ${w}`;$.line(`${_}: return ${H===!0?Y?$.data:H:Y?`${$.invoke(H)} ? ${H.contextFreeMorph?`${o$(H.contextFreeMorph)}(${$.data})`:$.data} : "${W6}"`:$.invoke(H)}`)}return $}),$.traversalKind==="Allows"){$.return(Y?`"${W6}"`:!1);return}let U=uT(this.discriminant.kind==="domain"?X.map((w)=>{let H=w.slice(1,-1);return H==="function"?c4.object:c4[H]}):X),G=this.discriminant.path.map((w)=>typeof w==="symbol"?o$(w):JSON.stringify(w)),J=JSON.stringify(U),z=this.discriminant.kind==="domain"?`${DP}[${T}]`:`${OP}(${T})`;$.line(`ctx.errorFromNodeContext({
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({
138
139
  code: "predicate",
139
- expected: ${J},
140
- actual: ${z},
141
- relativePath: [${G}],
140
+ expected: ${w},
141
+ actual: ${G},
142
+ relativePath: [${_}],
142
143
  meta: ${this.compiledMeta}
143
- })`)}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?`"${W6}"`:!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 Y=W$(this.unitBranches,(U,G)=>[`${G.in.serializedValue}`,G.hasKind("morph")?G:!0]);return{kind:"unit",path:[],optionallyChainedPropString:"data",cases:Y}}let $=[];for(let Y=0;Y<this.branches.length-1;Y++){let U=this.branches[Y];for(let G=Y+1;G<this.branches.length;G++){let J=this.branches[G],z=o4(U.in,J.in,U.$);if(!(z instanceof f))continue;for(let w of z){if(!w.kind||w.optional)continue;let H,_;if(w.kind==="domain"){let{l:D,r:V}=w;H=`"${typeof D==="string"?D:D.domain}"`,_=`"${typeof V==="string"?V:V.domain}"`}else if(w.kind==="unit")H=w.l.serializedValue,_=w.r.serializedValue;else continue;let F=$.find((D)=>J1(D.path,w.path)&&D.kind===w.kind);if(!F)$.push({kind:w.kind,cases:{[H]:{branchIndices:[Y],condition:w.l},[_]:{branchIndices:[G],condition:w.r}},path:w.path});else{if(F.cases[H])F.cases[H].branchIndices=g6(F.cases[H].branchIndices,Y);else F.cases[H]??={branchIndices:[Y],condition:w.l};if(F.cases[_])F.cases[_].branchIndices=g6(F.cases[_].branchIndices,G);else F.cases[_]??={branchIndices:[G],condition:w.r}}}}}let T=this.ordered?QP($,this.branches):$;if(!T.length)return null;let W=HP(T,this),X={};for(let Y in W.best.cases){let U=FP(W,Y);if(U===null){X[Y]=!0;continue}if(U.length===this.branches.length)return null;if(this.ordered)U.sort((z,w)=>z.originalIndex-w.originalIndex);let G=U.map((z)=>z.branch),J=G.length===1?G[0]:this.$.node("union",this.ordered?{branches:G,ordered:!0}:G);Object.assign(this.referencesById,J.referencesById),X[Y]=J}if(W.defaultEntries.length){let Y=W.defaultEntries.map((U)=>U.branch);X.default=this.$.node("union",this.ordered?{branches:Y,ordered:!0}:Y,{prereduced:!0}),Object.assign(this.referencesById,X.default.referencesById)}return Object.assign(W.location,{cases:X})}}var HP=($,T)=>{let W=$.sort((U,G)=>Object.keys(G.cases).length-Object.keys(U.cases).length)[0],X={kind:W.kind,path:W.path,optionallyChainedPropString:HK(W.path)},Y=T.branches.map((U,G)=>({originalIndex:G,branch:U}));return{best:W,location:X,defaultEntries:Y,node:T}},FP=($,T)=>{let W=$.best.cases[T],X=ZP(W.condition,$.location.path,$.node.$),Y=[],U=[];for(let G=0;G<$.defaultEntries.length;G++){let J=$.defaultEntries[G];if(W.branchIndices.includes(J.originalIndex)){let z=wK($.node.branches[J.originalIndex],$.location);if(z===null)Y=null;else Y?.push({originalIndex:J.originalIndex,branch:z})}else if(J.branch.hasKind("alias")&&X.hasKind("domain")&&X.domain==="object")Y?.push(J);else{if(J.branch.in.overlaps(X)){let z=wK(J.branch,$.location);Y?.push({originalIndex:J.originalIndex,branch:z})}U.push(J)}}return $.defaultEntries=U,Y},QP=($,T)=>{return $.filter((X)=>{let Y=Object.values(X.cases).map((U)=>U.branchIndices);for(let U=0;U<Y.length-1;U++){let G=Y[U];for(let J=U+1;J<Y.length;J++){let z=Y[J];for(let w of G)for(let H of z)if(w>H){if(T[w].overlaps(T[H]))return!1}}}return!0})},ZP=($,T,W)=>{let X=$==="undefined"?W.node("unit",{unit:void 0}):$==="null"?W.node("unit",{unit:null}):$==="boolean"?W.units([!0,!1]):$;for(let Y=T.length-1;Y>=0;Y--){let U=T[Y];X=W.node("intersection",typeof U==="number"?{proto:"Array",sequence:[...dO(U).map((G)=>({})),X]}:{domain:"object",required:[{key:U,value:X}]})}return X},HK=($)=>$.reduce((T,W)=>T+H_(W,!0),"data"),DP=o$(iO),OP=o$(X$),y_={implementation:_P,Node:_K},VP=($)=>({kind:$.kind,path:$.path.map((T)=>typeof T==="string"?T:_1(T)),cases:W$($.cases,(T,W)=>[T,W===!0?W:W.hasKind("union")&&W.discriminantJson?W.discriminantJson:W.json])}),KP={delimiter:" | ",finalDelimiter:" | "},EP=($)=>uT($,KP),uT=($,T)=>{let W=T?.delimiter??", ",X=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 Y={},U=$.filter((J)=>Y[J]?!1:Y[J]=!0),G=U.pop();return`${U.join(W)}${U.length?X:""}${G}`},f_=($,T,W)=>{let X=T.map(()=>[]);for(let U=0;U<$.length;U++){let G={};for(let J=0;J<T.length;J++){if(X[J]===null)continue;if($[U].equals(T[J])){X[J]=null,G={};break}let z=j$($[U],T[J],W);if(z instanceof f)continue;if(z.equals($[U])){X[J].push($[U]),G={};break}if(z.equals(T[J]))X[J]=null;else G[J]=z}for(let J in G)X[J][U]=G[J]}let Y=X.flatMap((U,G)=>U?.flatMap((J)=>J.branches)??T[G]);return Y.length===0?f.init("union",$,T):Y},AP=({branches:$,ordered:T})=>{if($.length<2)return $;let W=$.map(()=>!0);for(let X=0;X<$.length;X++)for(let Y=X+1;Y<$.length&&W[X]&&W[Y];Y++){if($[X].equals($[Y])){W[Y]=!1;continue}let U=o4($[X].in,$[Y].in,$[0].$);if(U instanceof f)continue;if(!T)MP($[X],$[Y]);if(U.equals($[X].in))W[X]=!!T;else if(U.equals($[Y].in))W[Y]=!1}return $.filter((X,Y)=>W[Y])},MP=($,T)=>{if(!$.includesTransform&&!T.includesTransform)return;if(!J1($.shallowMorphs,T.shallowMorphs))L(zK($.expression,T.expression));if(!J1($.flatMorphs,T.flatMorphs,{isEqual:(W,X)=>W.propString===X.propString&&(W.node.hasKind("morph")&&X.node.hasKind("morph")?W.node.hasEqualMorphs(X.node):W.node.hasKind("intersection")&&X.node.hasKind("intersection")?W.node.structure?.structuralMorphRef===X.node.structure?.structuralMorphRef:!1)}))L(zK($.expression,T.expression))},wK=($,T)=>$.transform((W,X)=>{if(W==="domain"||W==="unit")return null;return X},{shouldTransform:(W,X)=>{let Y=HK(X.path);if(!T.optionallyChainedPropString.startsWith(Y))return!1;if(W.hasKind("domain")&&W.domain==="object")return!0;if((W.hasKind("domain")||T.kind==="unit")&&Y===T.optionallyChainedPropString)return!0;return W.children.length!==0&&W.kind!=="index"}}),zK=($,T)=>`An unordered union of a type including a morph and a type with overlapping input is indeterminate:
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:
144
145
  Left: ${$}
145
- Right: ${T}`,NP=($,T)=>`The intersection of two ordered unions is indeterminate:
146
+ Right: ${T}`,eq=($,T)=>`The intersection of two ordered unions is indeterminate:
146
147
  Left: ${$}
147
- Right: ${T}`;var LP=Y$({kind:"unit",hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:($)=>$ instanceof Date?$.toISOString():H6($)}},normalize:($)=>$,defaults:{description:($)=>X$($.unit),problem:({expected:$,actual:T})=>`${$===T?`must be reference equal to ${$} (serialized to the same value)`:`must be ${$} (was ${T})`}`},intersections:{unit:($,T)=>f.init("unit",$,T),...c6("unit",($,T)=>{if(T.allows($.unit))return $;let W=T.hasKind("intersection")?T.basis:T;if(W){let X=W.hasKind("domain")?W:I.intrinsic.object;if($.domain!==X.domain){let Y=$.domain==="undefined"||$.domain==="null"||$.domain==="boolean"?$.domain:I.intrinsic[$.domain];return f.init("domain",Y,X)}}return f.init("assignability",$,T.hasKind("intersection")?T.children.find((X)=>!X.allows($.unit)):T)})}});class QK extends b0{compiledValue=this.json.unit;serializedValue=typeof this.unit==="string"||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=FK(this.unit,this.serializedValue);compiledNegation=FK(this.unit,this.serializedValue,"negated");expression=X$(this.unit);domain=w4(this.unit);get defaultShortDescription(){return this.domain==="object"?c4.object:this.description}innerToJsonSchema($){return this.unit===null?{type:"null"}:I.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 h_={implementation:LP,Node:QK},FK=($,T,W)=>{if($ instanceof Date){let X=`data instanceof Date && data.toISOString() === ${T}`;return W?`!(${X})`:X}if(Number.isNaN($))return`${W?"!":""}Number.isNaN(data)`;return`data ${W?"!":"="}== ${T}`};var SP=Y$({kind:"index",hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:($,T)=>{let W=T.$.parseSchema($);if(!W.extends(I.intrinsic.key))return L(RP(W.expression));let X=W.branches.filter((Y)=>Y.hasKind("unit"));if(X.length)return L(BP(X.map((Y)=>X$(Y.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 X=j$($.value,T.value,W),Y=X instanceof f?I.intrinsic.never.internal:X;return W.$.node("index",{signature:$.signature,value:Y})}if($.signature.extends(T.signature)&&$.value.subsumes(T.value))return T;if(T.signature.extends($.signature)&&T.value.subsumes($.value))return $;return null}}});class ZK extends F6{impliedBasis=I.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=F$(this.value.flatRefs.map(($)=>R6([this.signature,...$.path],$.node)),R6([this.signature],this.value));traverseAllows=($,T)=>C0($).every((W)=>{if(this.signature.traverseAllows(W[0],T))return p4(W[0],()=>this.value.traverseAllows(W[1],T),T);return!0});traverseApply=($,T)=>{for(let W of C0($))if(this.signature.traverseAllows(W[0],T))p4(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 g_={implementation:SP,Node:ZK},BP=($)=>`Index keys ${$.join(", ")} should be specified as named props.`,RP=($)=>`Indexed key definition '${$}' must be a string or symbol`;var IP=Y$({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:VX,optional:VX}});class DK extends KX{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:"required",missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=p1(this.errorContext)}var m_={implementation:IP,Node:DK};var kP=Y$({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 X=T.$.parseSchema(W[0]);return AX(X,W[1],null),[X,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 L(vP);if($.optionals?.length||$.defaultables?.length)return L(u_)}if($.minVariadicLength&&!$.variadic)return L("minVariadicLength may not be specified without a variadic element");return $}return{variadic:$}},reduce:($,T)=>{let W=$.minVariadicLength??0,X=$.prefix?.slice()??[],Y=$.defaultables?.slice()??[],U=$.optionals?.slice()??[],G=$.postfix?.slice()??[];if($.variadic){while(U.at(-1)?.equals($.variadic))U.pop();if(U.length===0&&Y.length===0)while(X.at(-1)?.equals($.variadic))X.pop(),W++;while(G[0]?.equals($.variadic))G.shift(),W++}else if(U.length===0&&Y.length===0)X.push(...G.splice(0));if(W!==$.minVariadicLength||$.prefix&&$.prefix.length!==X.length)return T.node("sequence",{...$,prefix:X,defaultables:Y,optionals:U,postfix:G,minVariadicLength:W},{prereduced:!0})},defaults:{description:($)=>{if($.isVariadicOnly)return`${$.variadic.nestableExpression}[]`;return`[${$.tuple.map((W)=>W.kind==="defaultables"?`${W.node.nestableExpression} = ${X$(W.default)}`:W.kind==="optionals"?`${W.node.nestableExpression}?`:W.kind==="variadic"?`...${W.node.nestableExpression}[]`:W.node.expression).join(", ")}]`}},intersections:{sequence:($,T,W)=>{let X=SX({l:$.tuple,r:T.tuple,disjoint:new f,result:[],fixedVariants:[],ctx:W}),Y=X.disjoint.length===0?[X,...X.fixedVariants]:X.fixedVariants;return Y.length===0?X.disjoint:Y.length===1?W.$.node("sequence",OK(Y[0].result)):W.$.node("union",Y.map((U)=>({proto:Array,sequence:OK(U.result)})))}}});class VK extends F6{impliedBasis=I.intrinsic.Array.internal;tuple=CP(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=G1(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return D_(this.flatRefs,this.prevariadic.flatMap(($,T)=>F$($.node.flatRefs.map((W)=>R6([`${T}`,...W.path],W.node)),R6([`${T}`],$.node)))),D_(this.flatRefs,this.variadicOrPostfix.flatMap(($)=>F$($.flatRefs.map((T)=>R6([I.intrinsic.nonNegativeIntegerString.internal,...T.path],T.node)),R6([I.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=PP(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??D$(`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++)p4(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 X=`${T+this.prefixLength}`;$.if(`${X} >= ${$.data}.length`,()=>$.traversalKind==="Allows"?$.return(!0):$.return()),$.traverseKey(X,`data[${X}]`,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 X=`firstPostfixIndex + ${T}`;$.traverseKey(X,`data[${X}]`,W)}}if($.traversalKind==="Allows")$.return(!0)}_transform($,T){T.path.push(I.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 X=W.node.toJsonSchemaRecurse(T);if(W.kind==="defaultables"){let Y=typeof W.default==="function"?W.default():W.default;X.default=I.intrinsic.jsonData.allows(Y)?Y:T.fallback.defaultValue({code:"defaultValue",base:X,value:Y})}return X});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 X=this.postfix.map((Y)=>Y.toJsonSchemaRecurse(T));$=T.fallback.arrayPostfix({code:"arrayPostfix",base:W,elements:X})}}else $.items=!1,delete $.maxItems;return $}}var qP={},PP=($)=>{if(!$.defaultables)return[];let T=[],W="[",X=$.prefixLength+$.defaultablesLength-1;for(let Y=$.prefixLength;Y<=X;Y++){let[U,G]=$.defaultables[Y-$.prefixLength];T.push(j_(Y,U,G)),W+=`${Y}: ${U.id} = ${H6(G)}, `}return W+="]",qP[W]??=T},c_={implementation:kP,Node:VK},CP=($)=>{let T=[];if($.prefix)for(let W of $.prefix)T.push({kind:"prefix",node:W});if($.defaultables)for(let[W,X]of $.defaultables)T.push({kind:"defaultables",node:W,default:X});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},OK=($)=>$.reduce((T,W)=>{if(W.kind==="variadic")T.variadic=W.node;else if(W.kind==="defaultables")T.defaultables=F$(T.defaultables,[[W.node,W.default]]);else T[W.kind]=F$(T[W.kind],W.node);return T},{}),u_="A postfix required element cannot follow an optional or defaultable element",vP="A postfix element requires a variadic element",SX=($)=>{let[T,...W]=$.l,[X,...Y]=$.r;if(!T||!X)return $;let U=W.at(-1)?.kind==="postfix",G=Y.at(-1)?.kind==="postfix",J=T.kind==="prefix"||X.kind==="prefix"?"prefix":T.kind==="postfix"||X.kind==="postfix"?"postfix":T.kind==="variadic"&&X.kind==="variadic"?"variadic":U||G?"prefix":T.kind==="defaultables"||X.kind==="defaultables"?"defaultables":"optionals";if(T.kind==="prefix"&&X.kind==="variadic"&&G){let _=SX({...$,fixedVariants:[],r:Y.map((F)=>({...F,kind:"prefix"}))});if(_.disjoint.length===0)$.fixedVariants.push(_)}else if(X.kind==="prefix"&&T.kind==="variadic"&&U){let _=SX({...$,fixedVariants:[],l:W.map((F)=>({...F,kind:"prefix"}))});if(_.disjoint.length===0)$.fixedVariants.push(_)}let z=j$(T.node,X.node,$.ctx);if(z instanceof f)if(J==="prefix"||J==="postfix")$.disjoint.push(...z.withPrefixKey(J==="prefix"?$.result.length:`-${W.length+1}`,"required")),$.result=[...$.result,{kind:J,node:I.intrinsic.never.internal}];else if(J==="optionals"||J==="defaultables")return $;else return SX({...$,fixedVariants:[],l:W.map((_)=>({..._,kind:"prefix"})),r:W.map((_)=>({..._,kind:"prefix"}))});else if(J==="defaultables"){if(T.kind==="defaultables"&&X.kind==="defaultables"&&T.default!==X.default)L(v_(T.default,X.default));$.result=[...$.result,{kind:J,node:z,default:T.kind==="defaultables"?T.default:X.kind==="defaultables"?X.default:D$(`Unexpected defaultable intersection from ${T.kind} and ${X.kind} elements.`)}]}else $.result=[...$.result,{kind:J,node:z}];let w=$.l.length,H=$.r.length;if(T.kind!=="variadic"||w>=H&&(X.kind==="variadic"||H===1))$.l=W;if(X.kind!=="variadic"||H>=w&&(T.kind==="variadic"||w===1))$.r=Y;return SX($)};var AK=($)=>(T)=>{if(T.props.length||T.index){let W=T.index?.map((Y)=>Y[$])??[];for(let Y of T.props)W.push(Y[$]);if(T.undeclared)W.push(`+ (undeclared): ${T.undeclared}`);let X=`{ ${W.join(", ")} }`;return T.sequence?`${X} & ${T.sequence.description}`:X}return T.sequence?.description??"{}"},jP=AK("description"),xP=AK("expression"),KK=($,T,W)=>{let X=$.required?"required":"optional";if(!T.signature.allows($.key))return null;let Y=o4($.value,T.value,W);if(Y instanceof f)return X==="optional"?W.node("optional",{key:$.key,value:I.intrinsic.never.internal}):Y.withPrefixKey($.key,$.kind);return null},bP=Y$({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=F$(T.required,W.map((X)=>X[$]));return}},optional:{child:!0,parse:S4("optional"),reduceIo:($,T,W)=>{if($==="in"){T.optional=W.map((X)=>X.in);return}for(let X of W)T[X.outProp.kind]=F$(T[X.outProp.kind],X.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:jP},intersections:{structure:($,T,W)=>{let X={...$.inner},Y={...T.inner},U=new f;if($.undeclared){let z=$.keyof();for(let w of T.requiredKeys)if(!z.allows(w))U.add("presence",I.intrinsic.never.internal,T.propsByKey[w].value,{path:[w]});if(Y.optional)Y.optional=Y.optional.filter((w)=>z.allows(w.key));if(Y.index)Y.index=Y.index.flatMap((w)=>{if(w.signature.extends(z))return w;let H=o4(z,w.signature,W.$);if(H instanceof f)return[];let _=KU(H,w.value,W.$);if(_.required)Y.required=G1(Y.required,_.required);if(_.optional)Y.optional=G1(Y.optional,_.optional);return _.index??[]})}if(T.undeclared){let z=T.keyof();for(let w of $.requiredKeys)if(!z.allows(w))U.add("presence",$.propsByKey[w].value,I.intrinsic.never.internal,{path:[w]});if(X.optional)X.optional=X.optional.filter((w)=>z.allows(w.key));if(X.index)X.index=X.index.flatMap((w)=>{if(w.signature.extends(z))return w;let H=o4(z,w.signature,W.$);if(H instanceof f)return[];let _=KU(H,w.value,W.$);if(_.required)X.required=G1(X.required,_.required);if(_.optional)X.optional=G1(X.optional,_.optional);return _.index??[]})}let G={};if($.undeclared||T.undeclared)G.undeclared=$.undeclared==="reject"||T.undeclared==="reject"?"reject":"delete";let J=yT({kind:"structure",baseInner:G,l:hT(X),r:hT(Y),roots:[],ctx:W});if(J instanceof f)U.push(...J);if(U.length)return U;return J}},reduce:($,T)=>{if($.index){if(!($.required||$.optional))return;let W=!1,X=$.required??[],Y=$.optional??[],U=[...Y];for(let G of $.index){for(let J of X){let z=KK(J,G,T);if(z instanceof f)return z}for(let[J,z]of Y.entries()){let w=KK(z,G,T);if(w instanceof f)return w;if(w===null)continue;U[J]=w,W=!0}}if(W)return T.node("structure",{...$,optional:U},{prereduced:!0})}}});class MK extends F6{impliedBasis=I.intrinsic.object.internal;impliedSiblings=this.children.flatMap(($)=>$.impliedSiblings??[]);props=G1(this.required,this.optional);propsByKey=W$(this.props,($,T)=>[T.key,T]);propsByKeyReference=o$(this.propsByKey);expression=xP(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 X=this.propsByKey[W.key];if(v$(W)){if(W.kind!=="required"&&W.kind!=="optional")return L(`Map result must have kind "required" or "optional" (was ${W.kind})`);return T[W.kind]=F$(T[W.kind],W),T}let Y=W.kind??X?.kind??"required",U=W$(W,(G,J)=>(G in EX.implementation.keys)?[G,J]:[]);return T[Y]=F$(T[Y],this.$.node(Y,U)),T},{}))}assertHasKeys($){let T=$.filter((W)=>!MX(W,this.keyof()));if(T.length)return L(EK(this.expression,T))}get($,...T){let W,X=!1,Y=gP($);if((typeof Y==="string"||typeof Y==="symbol")&&this.propsByKey[Y])W=this.propsByKey[Y].value,X=this.propsByKey[Y].required;if(this.index){for(let G of this.index)if(MX(Y,G.signature))W=W?.and(G.value)??G.value}if(this.sequence&&MX(Y,I.intrinsic.nonNegativeIntegerString))if(d(Y,"root")){if(this.sequence.variadic)W=W?.and(this.sequence.element)??this.sequence.element}else{let G=Number.parseInt(Y);if(G<this.sequence.prevariadic.length){let J=this.sequence.prevariadic[G].node;W=W?.and(J)??J,X||=G<this.sequence.prefixLength}else if(this.sequence.variadic){let J=this.$.node("union",this.sequence.variadicOrPostfix);W=W?.and(J)??J}}if(!W){if(this.sequence?.variadic&&d(Y,"root")&&Y.extends(I.intrinsic.number))return L(mP(Y.expression,this.sequence.expression));return L(EK(this.expression,[Y]))}let U=W.get(...T);return X?U:U.or(I.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=F$(T.required,$.required);if($.optional)T.optional=F$(T.optional,$.optional);if($.index)T.index=F$(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=JU(this.inner),X=(Y)=>{let U=T.some((G)=>MX(Y,G));return $==="pick"?U:!U};if(W.required)W.required=W.required.filter((Y)=>X(Y.key));if(W.optional)W.optional=W.optional.filter((Y)=>X(Y.key));if(W.index)W.index=W.index.filter((Y)=>X(Y.signature));return W}traverseAllows=($,T)=>this._traverse("Allows",$,T);traverseApply=($,T)=>this._traverse("Apply",$,T);_traverse=($,T,W)=>{let X=W?.currentErrorCount??0;for(let Y=0;Y<this.props.length;Y++)if($==="Allows"){if(!this.props[Y].traverseAllows(T,W))return!1}else if(this.props[Y].traverseApply(T,W),W.failFast&&W.currentErrorCount>X)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>X)return!1}if(this.index||this.undeclared==="reject"){let Y=Object.keys(T);Y.push(...Object.getOwnPropertySymbols(T));for(let U=0;U<Y.length;U++){let G=Y[U];if(this.index){for(let J of this.index)if(J.signature.traverseAllows(G,W)){if($==="Allows"){if(!p4(G,()=>J.value.traverseAllows(T[G],W),W))return!1}else if(p4(G,()=>J.value.traverseApply(T[G],W),W),W.failFast&&W.currentErrorCount>X)return!1}}if(this.undeclared==="reject"&&!this.declaresKey(G)){if($==="Allows")return!1;if(W.errorFromNodeContext({code:"predicate",expected:"removed",actual:"",relativePath:[G],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&&I.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",yP(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(["),hP($,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 X=W.value.toJsonSchemaRecurse(T);if(typeof W.key==="symbol"){T.fallback.symbolKey({code:"symbolKey",base:$,key:W.key,value:X,optional:W.optional});continue}if(W.hasDefault()){let Y=typeof W.default==="function"?W.default():W.default;X.default=I.intrinsic.jsonData.allows(Y)?Y:T.fallback.defaultValue({code:"defaultValue",base:X,value:Y})}$.properties[W.key]=X}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 X=W.value.toJsonSchemaRecurse(T);if(W.signature.equals(I.intrinsic.string)){$.additionalProperties=X;continue}for(let Y of W.signature.branches){if(!Y.extends(I.intrinsic.string)){$=T.fallback.symbolKey({code:"symbolKey",base:$,key:null,value:X,optional:!1});continue}let U={type:"string"};if(Y.hasKind("morph"))U=T.fallback.morph({code:"morph",base:Y.in.toJsonSchemaRecurse(T),out:Y.out.toJsonSchemaRecurse(T)});if(!Y.hasKind("intersection"))return D$(`Unexpected index branch kind ${Y.kind}.`);let{pattern:G}=Y.inner;if(G){let J=Object.assign(U,{pattern:G[0].rule});for(let z=1;z<G.length;z++)U=T.fallback.patternIntersection({code:"patternIntersection",base:J,pattern:G[z].rule});$.patternProperties??={},$.patternProperties[J.pattern]=X}}}if(this.undeclared&&!$.additionalProperties)$.additionalProperties=!1;return $}}var p_={},fP=($)=>{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},yP=($)=>{let T=fP($);if(!T)return;if(p_[T])return p_[T];let W=(X,Y)=>{for(let U=0;U<$.defaultable.length;U++)if(!($.defaultable[U].key in X))$.defaultable[U].defaultValueMorph(X,Y);if($.sequence?.defaultables)for(let U=X.length-$.sequence.prefixLength;U<$.sequence.defaultables.length;U++)$.sequence.defaultValueMorphs[U](X,Y);if($.undeclared==="delete"){for(let U in X)if(!$.declaresKey(U))delete X[U]}return X};return p_[T]=W},hP=($,T)=>{let X=`(data${T.defaultable.some((Y)=>Y.defaultValueMorph.length===2)||T.sequence?.defaultValueMorphs.some((Y)=>Y.length===2)?", ctx":""})`;return $.block(`${X} => `,(Y)=>{for(let U=0;U<T.defaultable.length;U++){let{serializedKey:G,defaultValueMorphRef:J}=T.defaultable[U];Y.if(`!(${G} in data)`,(z)=>z.line(`${J}${X}`))}if(T.sequence?.defaultables)Y.for(`i < ${T.sequence.defaultables.length}`,(U)=>U.set("data[i]",5),`data.length - ${T.sequence.prefixLength}`);if(T.undeclared==="delete")Y.forIn("data",(U)=>U.if(`!(${T._compileDeclaresKey(U)})`,(G)=>G.line("delete data[k]")));return Y.return("data")})},o_={implementation:bP,Node:MK},gP=($)=>{if(d($,"root")&&$.hasKind("unit"))$=$.unit;if(typeof $==="number")$=`${$}`;return $},mP=($,T)=>`${$} is not allowed as an array index on ${T}. Use the 'nonNegativeIntegerString' keyword instead.`,KU=($,T,W)=>{let[X,Y]=oO($.branches,(G)=>G.hasKind("unit"));if(!X.length)return{index:W.node("index",{signature:$,value:T})};let U={};for(let G of X){let J=W.node("required",{key:G.unit,value:T});U[J.kind]=F$(U[J.kind],J)}if(Y.length)U.index=W.node("index",{signature:Y,value:T});return U},cP=($)=>d($,"root")?$.expression:X$($),EK=($,T)=>`Key${T.length===1?"":"s"} ${T.map(cP).join(", ")} ${T.length===1?"does":"do"} not exist on ${$}`;var mT={...dV,alias:NX.implementation,domain:VU.implementation,unit:h_.implementation,proto:LX.implementation,union:y_.implementation,morph:b_.implementation,intersection:x_.implementation,divisor:A_.implementation,pattern:k_.implementation,predicate:E_.implementation,required:m_.implementation,optional:EX.implementation,index:g_.implementation,sequence:c_.implementation,structure:o_.implementation};I.defaultConfig=eO(Object.assign(W$(mT,($,T)=>[$,T.defaults]),{jitless:UV(),clone:WV,onUndeclaredKey:"ignore",exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:y$.defaultConfig}));I.resolvedConfig=FX(I.defaultConfig,I.config);var aV={...lV,alias:NX.Node,domain:VU.Node,unit:h_.Node,proto:LX.Node,union:y_.Node,morph:b_.Node,intersection:x_.Node,divisor:A_.Node,pattern:k_.Node,predicate:E_.Node,required:m_.Node,optional:EX.Node,index:g_.Node,sequence:c_.Node,structure:o_.Node};class pT extends $_{get[C4](){return"module"}}var d_=($,T)=>new pT(W$($,(W,X)=>[W,d(X,"module")?d_(X,T):T.bindReference(X)]));var uP=($)=>R$($)?$:("branches"in $)&&R$($.branches)?$.branches:void 0,pP=($,T)=>L(`Node of kind ${T} is not valid as a ${$} definition`),NK=($)=>`#${$} duplicates public alias ${$}`,l_={};I.ambient??={};var LK,BK="function $",oP=($)=>RK($,IK($)),RK=($,T)=>{let W=T.write(BK,4),X=T.compile()();for(let Y of $){if(Y.precompilation)continue;if(Y.traverseAllows=X[`${Y.id}Allows`].bind(X),Y.isRoot()&&!Y.allowsRequiresContext)Y.allows=Y.traverseAllows;if(Y.traverseApply=X[`${Y.id}Apply`].bind(X),X[`${Y.id}Optimistic`])Y.traverseOptimistic=X[`${Y.id}Optimistic`].bind(X);Y.precompilation=W}},IK=($)=>new GU().return($.reduce((T,W)=>{let X=new HX({kind:"Allows"}).indent();W.compile(X);let Y=X.write(`${W.id}Allows`),U=new HX({kind:"Apply"}).indent();W.compile(U);let G=U.write(`${W.id}Apply`),J=`${T}${Y},
148
- ${G},
149
- `;if(!W.hasKind("union"))return J;let z=new HX({kind:"Allows",optimistic:!0}).indent();W.compile(z);let w=z.write(`${W.id}Optimistic`);return`${J}${w},
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
151
  `},`{
151
- `)+"}");class EU{config;resolvedConfig;name;get[C4](){return"scope"}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor($,T){if(this.config=FX(I.config,T),this.resolvedConfig=FX(I.resolvedConfig,T),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(l_).length}`,this.name in l_)L(`A Scope already named ${this.name} already exists`);l_[this.name]=this;let W=Object.entries($).map((X)=>this.preparseOwnAliasEntry(...X));for(let[X,Y]of W){let U=X;if(X[0]==="#"){if(U=X.slice(1),U in this.aliases)L(NK(U));this.aliases[U]=Y}else{if(U in this.aliases)L(NK(X));this.aliases[U]=Y,this.exportedNames.push(U)}if(!d(Y,"module")&&!d(Y,"generic")&&!m1(Y)){let G=this.preparseOwnDefinitionFormat(Y,{alias:U});this.resolutions[U]=d(G,"root")?this.bindReference(G):this.createParseContext(G).id}}LK??=this.node("union",{branches:["string","number","object","bigint","symbol",{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[LK.hash]=this.node("intersection",{},{prereduced:!0}),this.intrinsic=I.intrinsic?W$(I.intrinsic,(X,Y)=>X.startsWith("json")?[]:[X,this.bindReference(Y)]):{}}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,X)=>new d1($,X?new HU(W):W,T,T,X??null)};units=($,T)=>{let W=[];for(let Y of $)if(!W.includes(Y))W.push(Y);let X=W.map((Y)=>this.node("unit",{unit:Y},T));return this.node("union",X,{...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(OX($),$,T);preparseNode($,T,W){let X=typeof $==="string"?$:OX(T,$);if(v$(T)&&T.kind===X)return T;if(X==="alias"&&!W?.prereduced){let{reference:G}=NX.implementation.normalize(T,this);if(G.startsWith("$")){let J=this.resolveRoot(G.slice(1));T=J,X=J.kind}}else if(X==="union"&&m4(T,"object")){let G=uP(T);if(G?.length===1)T=G[0],X=OX(T)}if(v$(T)&&T.kind===X)return T;let U=mT[X].normalize?.(T,this)??T;if(v$(U))return U.kind===X?U:pP(X,U.kind);return{...W,$:this,kind:X,def:U,prefix:W.alias??X}}bindReference($){let T;if(v$($))T=$.$===this?$:new $.constructor($.attachments,this);else T=$.$===this?$:new d1($.params,$.bodyDef,$.$,this,$.hkt);if(!this.resolved)Object.assign(this.referencesById,T.referencesById);return T}resolveRoot($){return this.maybeResolveRoot($)??L(n_($))}maybeResolveRoot($){let T=this.maybeResolve($);if(d(T,"generic"))return;return T}maybeResolveSubalias($){return r_(this.aliases,$)??r_(this.ambient,$)}get ambient(){return I.ambient}maybeResolve($){let T=this.resolutions[$];if(T){if(typeof T!=="string")return this.bindReference(T);let X=v4[T];if(d(X,"root"))return this.resolutions[$]=X;if(d(X,"context")){if(X.phase==="resolving")return this.node("alias",{reference:`$${$}`},{prereduced:!0});if(X.phase==="resolved")return D$(`Unexpected resolved context for was uncached by its scope: ${X$(X)}`);X.phase="resolving";let Y=this.bindReference(this.parseOwnDefinitionFormat(X.def,X));return X.phase="resolved",v4[Y.id]=Y,v4[X.id]=Y,this.resolutions[$]=Y}return D$(`Unexpected nodesById entry for ${T}: ${X$(X)}`)}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)L(PK($));return this.resolutions[$]=this.bindReference(W.root)}return this.resolutions[$]=this.parse(W,{alias:$})}createParseContext($){let T=$.id??q_($.prefix);return v4[T]=Object.assign($,{[C4]:"context",$:this,id:T,phase:"unresolved"})}traversal($){return new B6($,this.resolvedConfig)}import(...$){return new pT(W$(this.export(...$),(T,W)=>[`#${T}`,W]))}precompilation;_exportedResolutions;_exports;export(...$){if(!this._exports){this._exports={};for(let W of this.exportedNames){let X=this.aliases[W];this._exports[W]=d(X,"module")?d_(X,this):SK(this.maybeResolve(W))}for(let W of this.lazyResolutions)W.resolution;if(this._exportedResolutions=qK(this,this._exports),this._json=kK(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let W=IK(this.references);this.precompilation=W.write(BK,4),RK(this.references,W)}this.resolved=!0}let T=$.length?$:this.exportedNames;return new pT(W$(T,(W,X)=>[X,this._exports[X]]))}resolve($){return this.export()[$]}node=($,T,W={})=>{let X=this.preparseNode($,T,W);if(v$(X))return this.bindReference(X);let Y=this.createParseContext(X),U=P_(Y),G=this.bindReference(U);return v4[Y.id]=G};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 X=this.createParseContext(W);v4[X.id]=X;let Y=this.bindReference(this.parseOwnDefinitionFormat($,X));if(Y.isCyclic)Y=tV(Y,X.id);return v4[X.id]=Y,Y}finalize($){if(SK($),!$.precompilation&&!this.resolvedConfig.jitless)oP($.references);return $}}class i_ extends EU{parseOwnDefinitionFormat($,T){return P_(T)}preparseOwnDefinitionFormat($,T){return this.preparseNode(OX($),$,T)}preparseOwnAliasEntry($,T){return[$,T]}normalizeRootScopeValue($){return $}}var SK=($)=>{let T=$.references.filter((W)=>W.hasKind("alias"));for(let W of T){Object.assign(W.referencesById,W.resolution.referencesById);for(let X of $.references)if(W.id in X.referencesById)Object.assign(X.referencesById,W.referencesById)}return $},kK=($)=>W$($,(T,W)=>[T,d(W,"root")||d(W,"generic")?W.json:d(W,"module")?kK(W):D$(`Unexpected resolution ${X$(W)}`)]),r_=($,T)=>{let W=T.indexOf(".");if(W===-1)return;let X=T.slice(0,W),Y=$[X];if(Y===void 0)return;if(!d(Y,"module"))return L(dP(X));let U=T.slice(W+1),G=Y[U];if(G===void 0)return r_(Y,U);if(d(G,"root")||d(G,"generic"))return G;if(d(G,"module"))return G.root??L(PK(T));D$(`Unexpected resolution for alias '${T}': ${X$(G)}`)},AU=($,T)=>new i_($,T),BX=new i_({});var qK=($,T)=>{let W={};for(let X in T){let Y=T[X];if(d(Y,"module")){let U=qK($,Y),G=W$(U,(J,z)=>[`${X}.${J}`,z]);Object.assign(W,G)}else if(d(Y,"root")||d(Y,"generic"))W[X]=Y;else D$(`Unexpected scope resolution ${X$(Y)}`)}return W},n_=($)=>`'${$}' is unresolvable`,dP=($)=>`'${$}' must reference a module to be accessed using dot syntax`,PK=($)=>`Reference to submodule '${$}' must specify an alias`;BX.export();var{schema:E$,node:oT,defineSchema:G0$,generic:Z6}=BX;var t_="^(?:0|[1-9]\\d*)$",lP=new RegExp(t_),z0$=o$(lP);var CK=AU({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();I.intrinsic={...CK};var vK=AU({integer:{domain:"number",divisor:1},lengthBoundable:["string",Array],key:["string","symbol"],nonNegativeIntegerString:{domain:"string",pattern:t_}},{prereducedAliases:!0}).export();Object.assign(I.intrinsic,vK);var rP=AU({jsonPrimitive:["string","number",{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:"object",index:{signature:"string",value:"$jsonData"}},jsonData:["$jsonPrimitive","$jsonObject"]},{prereducedAliases:!0}).export(),n={...CK,...vK,...rP,emptyStructure:oT("structure",{},{prereduced:!0})};I.intrinsic={...n};var xK=($)=>typeof $==="string"&&$[0]==="d"&&($[1]==="'"||$[1]==='"')&&$.at(-1)===$[1],jK=($)=>$.toString()!=="Invalid Date",bK=($)=>$.slice(2,-1),a_=($)=>`'${$}' could not be parsed by the Date constructor`,fK=($,T)=>iP($,T),iP=($,T)=>{let W=new Date($);if(jK(W))return W;let X=ZV($);if(X!==void 0){let Y=new Date(X);if(jK(Y))return Y}return T?L(T===!0?a_($):T):void 0};var s_=($,T)=>{let W=$.scanner.shiftUntil(nP[hK[T]]);if($.scanner.lookahead==="")return $.error(aP(W,T));if($.scanner.shift(),T==="/"){try{new RegExp(W)}catch(X){L(String(X))}$.root=$.ctx.$.node("intersection",{domain:"string",pattern:W},{prereduced:!0})}else if(z4(T,e_))$.root=$.ctx.$.node("unit",{unit:W});else{let X=fK(W,a_(W));$.root=$.ctx.$.node("unit",{meta:W,unit:X})}},e_={"'":1,'"':1},yK={"/":1,"'":1,'"':1},hK={"d'":"'",'d"':'"',"'":"'",'"':'"',"/":"/"},nP={"'":($)=>$.lookahead==="'",'"':($)=>$.lookahead==='"',"/":($)=>$.lookahead==="/"},tP={'"':"double-quote","'":"single-quote","/":"forward slash"},aP=($,T)=>`${T}${$} requires a closing ${tP[hK[T]]}`;var gK=($)=>`Private type references should not include '#'. Use '${$}' instead.`,MU="Optional definitions like 'string?' are only valid as properties in an object or tuple",NU="Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";var mK={">":!0,">=":!0},cK={"<":!0,"<=":!0};var dT={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},uK=($)=>`Unmatched )${$===""?"":` before ${$}`}`,LU=($)=>`Missing ${$}`,pK=($,T)=>`Left bounds are only valid when paired with right bounds (try ...${T}${$})`,SU=($)=>`Left-bounded expressions must specify their limits using < or <= (was ${$})`,oK=($,T,W,X)=>`An expression may have at most one left bound (parsed ${$}${dT[T]}, ${W}${dT[X]})`;var dK=($,T,W)=>lK($,T,W,[]),lK=($,T,W,X)=>{let Y=W.parseUntilFinalizer();if(X.push(Y.root),Y.finalizer===">"){if(X.length!==T.params.length)return W.error($5($,T.names,X.map((U)=>U.expression)));return X}if(Y.finalizer===",")return lK($,T,W,X);return Y.error(LU(">"))},$5=($,T,W)=>`${$}<${T.join(", ")}> requires exactly ${T.length} args (got ${W.length}${W.length===0?"":`: ${W.join(", ")}`})`;var T5=($)=>{let T=$.scanner.shiftUntilNextTerminator();if(T==="keyof")$.addPrefix("keyof");else $.root=eP($,T)},sP=($,T,W)=>{if(W.scanner.shiftUntilNonWhitespace(),W.scanner.shift()!=="<")return W.error($5($,T.names,[]));let Y=dK($,T,W);return T(...Y)},eP=($,T)=>$C($,T)??TC($,T)??$.error(T===""?$.scanner.lookahead==="#"?gK($.shiftedByOne().scanner.shiftUntilNextTerminator()):W5($):n_(T)),$C=($,T)=>{if($.ctx.args?.[T]){let X=$.ctx.args[T];if(typeof X!=="string")return X;return $.ctx.$.node("alias",{reference:X},{prereduced:!0})}let W=$.ctx.$.maybeResolve(T);if(d(W,"root"))return W;if(W===void 0)return;if(d(W,"generic"))return sP(T,W,$);return L(`Unexpected resolution ${X$(W)}`)},TC=($,T)=>{let W=DV(T);if(W!==void 0)return $.ctx.$.node("unit",{unit:W});let X=VV(T);if(X!==void 0)return $.ctx.$.node("unit",{unit:X})},W5=($)=>{let T=$.previousOperator();return T?X5(T,$.scanner.unscanned):WC($.scanner.unscanned)},X5=($,T="")=>`Token '${$}' requires a right operand${T?` before '${T}'`:""}`,WC=($)=>`Expected an expression${$?` before '${$}'`:""}`;var Y5=($)=>$.scanner.lookahead===""?$.error(W5($)):$.scanner.lookahead==="("?$.shiftedByOne().reduceGroupOpen():$.scanner.lookaheadIsIn(yK)?s_($,$.scanner.shift()):$.scanner.lookaheadIsIn(c1)?Y5($.shiftedByOne()):$.scanner.lookahead==="d"?$.scanner.nextLookahead in e_?s_($,`${$.scanner.shift()}${$.scanner.shift()}`):T5($):T5($);class F1 extends z_{shiftUntilNextTerminator(){return this.shiftUntilNonWhitespace(),this.shiftUntil(()=>(this.lookahead in F1.terminatingChars))}static terminatingChars={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...c1};static finalizingLookaheads={">":1,",":1,"":1,"=":1,"?":1};static lookaheadIsFinalizing=($,T)=>$===">"?T[0]==="="?T[1]==="=":T.trimStart()===""||z4(T.trimStart()[0],F1.terminatingChars):$==="="?T[0]!=="=":$===","||$==="?"}var iK=($,T)=>{let W=XC($,T);if($.root.hasKind("unit")){if(typeof $.root.unit==="number"){$.reduceLeftBound($.root.unit,W),$.unsetRoot();return}if($.root.unit instanceof Date){let X=`d'${$.root.description??$.root.unit.toISOString()}'`;$.unsetRoot(),$.reduceLeftBound(X,W);return}}return UC($,W)},nK={"<":1,">":1,"=":1},XC=($,T)=>$.scanner.lookaheadIs("=")?`${T}${$.scanner.shift()}`:T;var rK=($,T,W,X)=>{if(W.extends(I.intrinsic.number)){if(typeof T!=="number")return L(U5($,T,X));return $==="=="?["min","max"]:$[0]===">"?["min"]:["max"]}if(W.extends(I.intrinsic.lengthBoundable)){if(typeof T!=="number")return L(U5($,T,X));return $==="=="?["exactLength"]:$[0]===">"?["minLength"]:["maxLength"]}if(W.extends(I.intrinsic.Date))return $==="=="?["after","before"]:$[0]===">"?["after"]:["before"];return L(yV(W.expression))},YC=($)=>({rule:xK($.limit)?bK($.limit):$.limit,exclusive:$.comparator.length===1}),UC=($,T)=>{let W=$.unsetRoot(),X=$.scanner.location;$.parseOperand();let Y=$.unsetRoot(),U=$.scanner.sliceChars(X,$.scanner.location);if($.root=W,!Y.hasKind("unit")||typeof Y.unit!=="number"&&!(Y.unit instanceof Date))return $.error(U5(T,U,"right"));let G=Y.unit,J=T.length===1,z=rK(T,typeof G==="number"?G:U,W,"right");for(let H of z)$.constrainRoot(H,T==="=="?{rule:G}:{rule:G,exclusive:J});if(!$.branches.leftBound)return;if(!z4(T,cK))return $.error(SU(T));let w=rK($.branches.leftBound.comparator,$.branches.leftBound.limit,W,"left");$.constrainRoot(w[0],YC($.branches.leftBound)),$.branches.leftBound=null},U5=($,T,W)=>`Comparator ${W==="left"?dT[$]:$} must be ${W==="left"?"preceded":"followed"} by a corresponding literal (was ${T})`;var tK=($)=>{$.scanner.shiftUntilNonWhitespace();let T=$.scanner.shiftUntilNextTerminator();$.root=$.root.brand(T)};var sK=($)=>{let T=$.scanner.shiftUntilNextTerminator(),W=OV(T,{errorOnFail:aK(T)});if(W===0)$.error(aK(0));$.root=$.root.constrain("divisor",W)},aK=($)=>`% operator must be followed by a non-zero integer literal (was ${$})`;var G5=($)=>{let T=$.scanner.shift();return T===""?$.finalize(""):T==="["?$.scanner.shift()==="]"?$.setRoot($.root.array()):$.error(GC):T==="|"?$.scanner.lookahead===">"?$.shiftedByOne().pushRootToBranch("|>"):$.pushRootToBranch(T):T==="&"?$.pushRootToBranch(T):T===")"?$.finalizeGroup():F1.lookaheadIsFinalizing(T,$.scanner.unscanned)?$.finalize(T):z4(T,nK)?iK($,T):T==="%"?sK($):T==="#"?tK($):(T in c1)?G5($):$.error(BU(T))},BU=($,T="")=>`'${$}' is not allowed here${T&&` (should be ${T})`}`,GC="Missing expected ']'";var eK=($)=>{let T=$.unsetRoot();$.parseOperand();let W=$.unsetRoot();if(!W.hasKind("unit"))return $.error(JC(W.expression));let X=W.unit instanceof Date?()=>new Date(W.unit):W.unit;return[T,"=",X]},JC=($)=>`Default value '${$}' must a literal value`;var J5=($,T)=>{let W=T.$.maybeResolveRoot($);if(W)return W;if($.endsWith("[]")){let U=T.$.maybeResolveRoot($.slice(0,-2));if(U)return U.array()}let X=new lT(new F1($),T),Y=wC(X);if(X.finalizer===">")L(BU(">"));return Y},wC=($)=>{$.parseOperand();let T=RX($).root;if(!T)return D$(`Root was unexpectedly unset after parsing string '${$.scanner.scanned}'`);if($.finalizer==="=")T=eK($);else if($.finalizer==="?")T=[T,"?"];if($.scanner.shiftUntilNonWhitespace(),$.scanner.lookahead)L(BU($.scanner.lookahead));return T},RX=($)=>{while($.finalizer===void 0)zC($);return $},zC=($)=>$.hasRoot()?$.parseOperator():$.parseOperand();class lT{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor($,T){this.scanner=$,this.ctx=T}error($){return L($)}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(LU(")"));this.finalizeBranches(),this.finalizer=$}reduceLeftBound($,T){let W=dT[T];if(!z4(W,mK))return this.error(SU(T));if(this.branches.leftBound)return this.error(oK(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(uK(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():D$(`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 RX(new lT(this.scanner,this.ctx))}parseOperator(){return G5(this)}parseOperand(){return Y5(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(pK(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 _C="An empty string is not a valid generic parameter name",RU=($,T,W)=>{$.shiftUntilNonWhitespace();let X=$.shiftUntilNextTerminator();if(X===""){if($.lookahead===""&&T.length)return T;return L(_C)}return $.shiftUntilNonWhitespace(),HC($,X,T,W)},$E="extends ",HC=($,T,W,X)=>{if($.shiftUntilNonWhitespace(),$.unscanned.startsWith($E))$.jumpForward($E.length);else{if($.lookahead===",")$.shift();return W.push(T),RU($,W,X)}let Y=RX(new lT($,X));return W.push([T,Y.root]),RU($,W,X)};class w5 extends S6{$;constructor($){super((...T)=>new IX($)(...T),{bind:$});this.$=$}in($){return new IX(this.$,$===void 0?void 0:this.$.parse($))}at($,T){return new IX(this.$).at($,T)}case($,T){return new IX(this.$).case($,T)}}class IX extends S6{$;in;key;branches=[];constructor($,T){super((W)=>this.caseEntries(Object.entries(W).map(([X,Y])=>X==="default"?[X,Y]:[this.$.parse(X),Y])));this.$=$,this.in=T}at($,T){if(this.key)L(QC);if(this.branches.length)L(FC);return this.key=$,T?this.match(T):this}case($,T){return this.caseEntry(this.$.parse($),T)}caseEntry($,T){let X=(this.key?this.$.parse({[this.key]:$}):$).pipe(T);return this.branches.push(X),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,X]=$[T];if(W==="default"){if(T!==$.length-1)L("default may only be specified as the last key of a switch definition");return this.default(X)}if(typeof X!=="function")return L(`Value for case "${W}" must be a function (was ${w4(X)})`);this.caseEntry(W,X)}return this}default($){if(typeof $==="function")this.case(n.unknown,$);let T={branches:this.branches,ordered:!0};if($==="never"||$==="assert")T.meta={onFail:TE};let W=this.$.node("union",T);if(!this.in)return this.$.finalize(W);let X=this.in.pipe(W);if($==="never"||$==="assert")X=X.configureReferences({onFail:TE},"self");return this.$.finalize(X)}}var TE=($)=>$.throw(),FC="A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')",QC="At most one key matcher may be specified per expression";var IU=($,T)=>{if(R$($)){if($[1]==="=")return[T.$.parseOwnDefinitionFormat($[0],T),"=",$[2]];if($[1]==="?")return[T.$.parseOwnDefinitionFormat($[0],T),"?"]}return kU($,T)},WE="Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }",XE="Only required keys may specify default values, e.g. { value: 'number = 0' }";var YE=($,T)=>{let W,X={},Y=C0($);for(let[G,J]of Y){let z=OC(G);if(z.kind==="spread"){if(!m6(X))return L(DC);let D=T.$.parseOwnDefinitionFormat(J,T);if(D.equals(n.object))continue;if(!D.hasKind("intersection")||!D.basis?.equals(n.object))return L(VC(D.expression));W=D.structure;continue}if(z.kind==="undeclared"){if(J!=="reject"&&J!=="delete"&&J!=="ignore")L(ZC(J));X.undeclared=J;continue}let w=IU(J,T),H=z;if(z.kind==="required"){if(!R$(w))z5(X,"required",{key:z.normalized,value:w},T);else z5(X,"optional",w[1]==="="?{key:z.normalized,value:w[0],default:w[2]}:{key:z.normalized,value:w[0]},T);continue}if(R$(w)){if(w[1]==="?")L(WE);if(w[1]==="=")L(XE)}if(z.kind==="optional"){z5(X,"optional",{key:z.normalized,value:w},T);continue}let _=T.$.parseOwnDefinitionFormat(H.normalized,T),F=KU(_,w,T.$);if(F.index)X.index=F$(X.index,F.index);if(F.required)X.required=F$(X.required,F.required)}let U=T.$.node("structure",X);return T.$.parseSchema({domain:"object",structure:W?.merge(U)??U})},z5=($,T,W,X)=>{$[T]=F$($[T],X.$.node(T,W))},ZC=($)=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${X$($)})`,DC="Spread operator may only be used as the first key in an object",OC=($)=>typeof $==="symbol"?{kind:"required",normalized:$}:$.at(-1)==="?"?$.at(-2)===UX?{kind:"required",normalized:`${$.slice(0,-2)}?`}:{kind:"optional",normalized:$.slice(0,-1)}:$[0]==="["&&$.at(-1)==="]"?{kind:"index",normalized:$.slice(1,-1)}:$[0]===UX&&$[1]==="["&&$.at(-1)==="]"?{kind:"required",normalized:$.slice(1)}:$==="..."?{kind:"spread"}:$==="+"?{kind:"undeclared"}:{kind:"required",normalized:$==="\\..."?"...":$==="\\+"?"+":$},VC=($)=>`Spread operand must resolve to an object literal type (was ${$})`;var GE=($,T)=>IC($)?_E[$[0]]($,T):BC($)?zE[$[1]]($,T):null,KC=($,T)=>T.$.parseOwnDefinitionFormat($[1],T).keyof(),_5=($,T)=>{if($[2]===void 0)return L(X5($[1],""));let W=T.$.parseOwnDefinitionFormat($[0],T),X=T.$.parseOwnDefinitionFormat($[2],T);if($[1]==="|")return T.$.node("union",{branches:[W,X]});let Y=$[1]==="&"?o4(W,X,T.$):DX(W,X,T.$);if(Y instanceof f)return Y.throw();return Y},EC=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).array(),AC=($,T)=>{if(typeof $[2]!=="function")return L(JE("=>",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).pipe($[2])},JE=($,T)=>`${$===":"?"Narrow":"Morph"} expression requires a function following '${$}' (was ${typeof T})`,MC=($,T)=>{if(typeof $[2]!=="function")return L(JE(":",$[2]));return T.$.parseOwnDefinitionFormat($[0],T).constrain("predicate",$[2])},NC=($,T)=>T.$.parseOwnDefinitionFormat($[0],T).configureReferences($[2],"shallow"),wE=($)=>$,LC=wE({"[]":EC,"?":()=>L(MU)}),SC=wE({"|":_5,"&":_5,":":MC,"=>":AC,"|>":_5,"@":NC,"=":()=>L(NU)}),zE={...LC,...SC},BC=($)=>zE[$[1]]!==void 0,RC=($)=>$,_E=RC({keyof:KC,instanceof:($,T)=>{if(typeof $[1]!=="function")return L(UE(XX($[1])));let W=$.slice(1).map((X)=>typeof X==="function"?T.$.node("proto",{proto:X}):L(UE(XX(X))));return W.length===1?W[0]:T.$.node("union",{branches:W})},"===":($,T)=>T.$.units($.slice(1))}),IC=($)=>_E[$[0]]!==void 0,UE=($)=>`Expected a constructor following 'instanceof' operator (was ${$})`;var QE=($,T)=>{let W=[{}],X=0;while(X<$.length){let Y=!1;if($[X]==="..."&&X<$.length-1)Y=!0,X++;let U=IU($[X],T),[G,J,z]=!R$(U)?[U]:U;if(X++,Y){if(!G.extends(I.intrinsic.Array))return L(PC(G.expression));W=W.flatMap((w)=>G.distribute((H)=>qC(JU(w),H)))}else W=W.map((w)=>{if(J==="?")return ZE(w,G);if(J==="=")return kC(w,G,z);return H5(w,G)})}return T.$.parseSchema(W.map((Y)=>m6(Y)?{proto:Array,exactLength:0}:{proto:Array,sequence:Y}))},H5=($,T)=>{if($.defaultables||$.optionals)return L($.variadic?u_:CC);if($.variadic)$.postfix=F$($.postfix,T);else $.prefix=F$($.prefix,T);return $},ZE=($,T)=>{if($.variadic)return L(DE);return $.optionals=F$($.optionals,T),$},kC=($,T,W)=>{if($.variadic)return L(DE);if($.optionals)return L(vC);return $.defaultables=F$($.defaultables,[[T,W]]),$},HE=($,T)=>{if($.postfix)L(FE);if($.variadic){if(!$.variadic.equals(T))L(FE)}else $.variadic=T.internal;return $},qC=($,T)=>{let W=T.select({method:"find",kind:"sequence"});if(!W)return HE($,I.intrinsic.unknown);if(W.prefix)for(let X of W.prefix)H5($,X);if(W.optionals)for(let X of W.optionals)ZE($,X);if(W.variadic)HE($,W.variadic);if(W.postfix)for(let X of W.postfix)H5($,X);return $},PC=($)=>`Spread element must be an array (was ${$})`,FE="A tuple may have at most one variadic element",CC="A required element may not follow an optional element",DE="An optional element may not follow a variadic element";var vC="A defaultable element may not follow an optional element without a default";var jC={},kU=($,T)=>{if(typeof $==="string"){if(T.args&&Object.keys(T.args).some((X)=>$.includes(X)))return J5($,T);let W=jC[T.$.name]??={};return W[$]??=J5($,T)}return m4($,"object")?xC($,T):L(F5(w4($)))},xC=($,T)=>{let W=WX($);switch(W){case void 0:if(d($,"root"))return $;return YE($,T);case"Array":return bC($,T);case"RegExp":return T.$.node("intersection",{domain:"string",pattern:$},{prereduced:!0});case"Function":{let X=m1($)?$():$;if(d(X,"root"))return X;return L(F5("Function"))}default:return L(F5(W??X$($)))}},bC=($,T)=>GE($,T)??QE($,T),F5=($)=>`Type definitions must be strings or objects (was ${$})`;class Q5 extends S6{constructor($){let T=Object.assign({errors:u4,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 X=W[0].slice(1,-1),Y=$.parseGenericParams(X,{});return new d1(Y,W[1],$,$,null)}return $.parse(W)},{bind:$,attach:T})}}var rT=I;class qU extends EU{get ambientAttachments(){if(!rT.typeAttachments)return;return this.cacheGetter("ambientAttachments",W$(rT.typeAttachments,($,T)=>[$,this.bindReference(T)]))}preparseOwnAliasEntry($,T){let W=$.indexOf("<");if(W===-1){if(d(T,"module")||d(T,"generic"))return[$,T];let U=this.name==="ark"?$:$==="root"?this.name:`${this.name}.${$}`,G=this.resolvedConfig.keywords?.[U];if(G)T=[T,"@",G];return[$,T]}if($.at(-1)!==">")L("'>' must be the last character of a generic declaration in a scope");let X=$.slice(0,W),Y=$.slice(W+1,-1);return[X,()=>{let U=this.parseGenericParams(Y,{alias:X});return xV(U,T,this)}]}parseGenericParams($,T){return RU(new F1($),[],this.createParseContext({...T,def:$,prefix:"generic"}))}normalizeRootScopeValue($){if(m1($)&&!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 X=kU($,T);if(R$(X)){if(X[1]==="=")return L(NU);if(X[1]==="?")return L(MU)}return X}unit=($)=>this.units([$]);valueOf=($)=>this.units($V($));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 w5(this);declare=()=>({type:this.type});define($){return $}type=new Q5(this);static scope=($,T={})=>new qU($,T);static module=($,T={})=>this.scope($,T).export()}var Z5=Object.assign(qU.scope,{define:($)=>$}),z$=qU;class OE extends L4{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'}var fC=Z6(["base",n.object],["props",n.object])(($)=>$.base.merge($.props),OE),VE=z$.module({Key:n.key,Merge:fC});class KE extends L4{}var yC=Z6("element")(($)=>{let T=$.element.exclude(n.Array),W=T.array();return T.rawOr(W).pipe(g1).distribute((X)=>X.assertHasKind("morph").declareOut(W),E$)},KE),EE=z$.module({root:n.Array,readonly:"root",index:n.nonNegativeIntegerString,liftFrom:yC},{name:"Array"});var D5=E$(["string",j0.FileConstructor]),hC=D5.rawOr(D5.array()),AE=E$({meta:"an object representing parsed form data",domain:"object",index:{signature:"string",value:hC}}),ME=z$.module({root:["instanceof",FormData],value:D5,parsed:AE,parse:E$({in:FormData,morphs:($)=>{let T={};for(let[W,X]of $)if(W in T){let Y=T[W];if(typeof Y==="string"||Y instanceof j0.FileConstructor)T[W]=[Y,X];else Y.push(X)}else T[W]=X;return T},declaredOut:AE})},{name:"FormData"});var NE=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 gC={Boolean:1,Number:1,String:1},LE=z$.module({...W$({...T_,...X_},($,T)=>($ in gC)?[]:[$,["instanceof",T]]),Array:EE,TypedArray:NE,FormData:ME});var mC=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"}),cC=E$({domain:"number",divisor:1}),PU=z$.module({root:n.number,integer:cC,epoch:mC,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 X={domain:"string",pattern:{rule:$.source,flags:$.flags,meta:T}};if(W)X.meta={format:W};return oT("intersection",X)},SE=h$(GX,"a well-formed integer string"),fE=z$.module({root:SE,parse:E$({in:SE,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"}),uC=h$(/^[\dA-Fa-f]+$/,"hex characters only"),pC=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"}),BE=h$(/^[A-Z].*$/,"capitalized"),oC=z$.module({root:E$({in:"string",morphs:($)=>$.charAt(0).toUpperCase()+$.slice(1),declaredOut:BE}),preformatted:BE},{name:"string.capitalize"}),dC=($)=>{let T=$.replaceAll(/[ -]+/g,""),W=0,X,Y,U=!1;for(let G=T.length-1;G>=0;G--){if(X=T.substring(G,G+1),Y=Number.parseInt(X,10),U)Y*=2,W+=Y>=10?Y%10+1:Y;else W+=Y;U=!U}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}))$/,rC=E$({domain:"string",pattern:{meta:"a credit card number",rule:lC.source},predicate:{meta:"a credit card number",predicate:dC}});var iC=/^([+-]?\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 nC=($)=>!Number.isNaN(new Date($).valueOf()),RE=E$({domain:"string",predicate:{meta:"a parsable date",predicate:nC}}).assertHasKind("intersection"),IE=fE.root.internal.narrow(($,T)=>{let W=Number.parseInt($),X=PU.epoch(W);if(X instanceof u4)return T.errors.merge(X),!1;return!0}).configure({description:"an integer string representing a safe Unix timestamp"},"self").assertHasKind("intersection"),tC=z$.module({root:IE,parse:E$({in:IE,morphs:($)=>new Date($),declaredOut:n.Date})},{name:"string.date.epoch"}),kE=h$(iC,"an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection"),aC=z$.module({root:kE,parse:E$({in:kE,morphs:($)=>new Date($),declaredOut:n.Date})},{name:"string.date.iso"}),sC=z$.module({root:RE,parse:E$({declaredIn:RE,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:aC,epoch:tC},{name:"string.date"}),eC=h$(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,"an email address","email"),qE="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",l1=`(${qE}[.]){3}${qE}`,$v=new RegExp(`^${l1}$`),s$="(?:[0-9a-fA-F]{1,4})",Tv=new RegExp(`^((?:${s$}:){7}(?:${s$}|:)|(?:${s$}:){6}(?:${l1}|:${s$}|:)|(?:${s$}:){5}(?::${l1}|(:${s$}){1,2}|:)|(?:${s$}:){4}(?:(:${s$}){0,1}:${l1}|(:${s$}){1,3}|:)|(?:${s$}:){3}(?:(:${s$}){0,2}:${l1}|(:${s$}){1,4}|:)|(?:${s$}:){2}(?:(:${s$}){0,3}:${l1}|(:${s$}){1,5}|:)|(?:${s$}:){1}(?:(:${s$}){0,4}:${l1}|(:${s$}){1,6}|:)|(?::((?::${s$}){0,5}:${l1}|(?::${s$}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?$`),Wv=z$.module({root:["v4 | v6","@","an IP address"],v4:h$($v,"an IPv4 address","ipv4"),v6:h$(Tv,"an IPv6 address","ipv6")},{name:"string.ip"}),iT="a JSON string",yE=($)=>{if(!($ instanceof SyntaxError))throw $;return`must be ${iT} (${$})`},Xv=E$({meta:iT,domain:"string",predicate:{meta:iT,predicate:($,T)=>{try{return JSON.parse($),!0}catch(W){return T.reject({code:"predicate",expected:iT,problem:yE(W)})}}}}),Yv=($,T)=>{if($.length===0)return T.error({code:"predicate",expected:iT,actual:"empty"});try{return JSON.parse($)}catch(W){return T.error({code:"predicate",expected:iT,problem:yE(W)})}},Uv=z$.module({root:Xv,parse:E$({meta:"safe JSON string parser",in:"string",morphs:Yv,declaredOut:n.jsonObject})},{name:"string.json"}),PE=h$(/^[a-z]*$/,"only lowercase letters"),Gv=z$.module({root:E$({in:"string",morphs:($)=>$.toLowerCase(),declaredOut:PE}),preformatted:PE},{name:"string.lower"}),hE=["NFC","NFD","NFKC","NFKD"],kX=W$(hE,($,T)=>[T,E$({domain:"string",predicate:(W)=>W.normalize(T)===W,meta:`${T}-normalized unicode`})]),CU=W$(hE,($,T)=>[T,E$({in:"string",morphs:(W)=>W.normalize(T),declaredOut:kX[T]})]),Jv=z$.module({root:CU.NFC,preformatted:kX.NFC},{name:"string.normalize.NFC"}),wv=z$.module({root:CU.NFD,preformatted:kX.NFD},{name:"string.normalize.NFD"}),zv=z$.module({root:CU.NFKC,preformatted:kX.NFKC},{name:"string.normalize.NFKC"}),_v=z$.module({root:CU.NFKD,preformatted:kX.NFKD},{name:"string.normalize.NFKD"}),Hv=z$.module({root:"NFC",NFC:Jv,NFD:wv,NFKC:zv,NFKD:_v},{name:"string.normalize"}),CE=h$(YU,"a well-formed numeric string"),Fv=z$.module({root:CE,parse:E$({in:CE,morphs:($)=>Number.parseFloat($),declaredOut:n.number})},{name:"string.numeric"}),vE="a regex pattern",Qv=E$({domain:"string",predicate:{meta:vE,predicate:($,T)=>{try{return new RegExp($),!0}catch(W){return T.reject({code:"predicate",expected:vE,problem:String(W)})}}},meta:{format:"regex"}}),Zv=/^(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-]+)*))?$/,Dv=h$(Zv,"a semantic version (see https://semver.org/)"),jE=h$(/^\S.*\S$|^\S?$/,"trimmed"),Ov=z$.module({root:E$({in:"string",morphs:($)=>$.trim(),declaredOut:jE}),preformatted:jE},{name:"string.trim"}),xE=h$(/^[A-Z]*$/,"only uppercase letters"),Vv=z$.module({root:E$({in:"string",morphs:($)=>$.toUpperCase(),declaredOut:xE}),preformatted:xE},{name:"string.upper"}),Kv=($)=>{if(URL.canParse)return URL.canParse($);try{return new URL($),!0}catch{return!1}},bE=E$({domain:"string",predicate:{meta:"a URL string",predicate:Kv},meta:{format:"uri"}}),Ev=z$.module({root:bE,parse:E$({declaredIn:bE,in:"string",morphs:($,T)=>{try{return new URL($)}catch{return T.error("a URL string")}},declaredOut:E$(URL)})},{name:"string.url"}),Av=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"}),gE=z$.module({root:n.string,alpha:h$(/^[A-Za-z]*$/,"only letters"),alphanumeric:h$(/^[\dA-Za-z]*$/,"only letters and digits 0-9"),hex:uC,base64:pC,capitalize:oC,creditCard:rC,date:sC,digits:h$(/^\d*$/,"only digits 0-9"),email:eC,integer:fE,ip:Wv,json:Uv,lower:Gv,normalize:Hv,numeric:Fv,regex:Qv,semver:Dv,trim:Ov,upper:Vv,url:Ev,uuid:Av},{name:"string"});var mE=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}),cE=z$.module({root:n.unknown,any:n.unknown},{name:"unknown"}),Mv=z$.module({root:n.jsonObject,stringify:oT("morph",{in:n.jsonObject,morphs:($)=>JSON.stringify($),declaredOut:n.string})},{name:"object.json"}),uE=z$.module({root:n.object,json:Mv},{name:"object"});class pE extends L4{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'}var Nv=Z6(["K",n.key],"V")(($)=>({domain:"object",index:{signature:$.K,value:$.V}}),pE);class oE extends L4{description='pick a set of properties from an object like `Pick(User, "name | age")`'}var Lv=Z6(["T",n.object],["K",n.key])(($)=>$.T.pick($.K),oE);class dE extends L4{description='omit a set of properties from an object like `Omit(User, "age")`'}var Sv=Z6(["T",n.object],["K",n.key])(($)=>$.T.omit($.K),dE);class lE extends L4{description="make all named properties of an object optional like `Partial(User)`"}var Bv=Z6(["T",n.object])(($)=>$.T.partial(),lE);class rE extends L4{description="make all named properties of an object required like `Required(User)`"}var Rv=Z6(["T",n.object])(($)=>$.T.required(),rE);class iE extends L4{description='exclude branches of a union like `Exclude("boolean", "true")`'}var Iv=Z6("T","U")(($)=>$.T.exclude($.U),iE);class nE extends L4{description='extract branches of a union like `Extract("0 | false | 1", "number")`'}var kv=Z6("T","U")(($)=>$.T.extract($.U),nE),tE=z$.module({Exclude:Iv,Extract:kv,Omit:Sv,Partial:Bv,Pick:Lv,Record:Nv,Required:Rv});var r1=Z5({...mE,...tE,...LE,...VE,string:gE,number:PU,object:uE,unknown:cE},{prereducedAliases:!0,name:"ark"}),_4=r1.export();Object.assign(rT.ambient,_4);rT.typeAttachments={string:_4.string.root,number:_4.number.root,bigint:_4.bigint,boolean:_4.boolean,symbol:_4.symbol,undefined:_4.undefined,null:_4.null,object:_4.object.root,unknown:_4.unknown.root,false:_4.false,true:_4.true,never:_4.never,arrayIndex:_4.Array.index,Key:_4.Key,Record:_4.Record,Array:_4.Array.root,Date:_4.Date};var I6=Object.assign(r1.type,rT.typeAttachments),qv=r1.match,Pv=r1.generic,C2$=r1.schema,Cv=r1.define,vv=r1.declare;var jv="__vite_start_time"in globalThis,xv=typeof window!=="undefined",n2$="vitest"in globalThis,Q1=I6("string"),aE=I6('"true" | "false" | undefined'),Z1=s7({isServer:!jv&&!xv,server:{CI:I6("string | undefined").pipe(Boolean),POSTGRES_USER:Q1,POSTGRES_PASSWORD:Q1,POSTGRES_DATABASE:Q1,POSTGRES_HOST:Q1,POSTGRES_PORT:Q1.pipe(($)=>Number.parseInt($,10)),BACKEND_PORT:Q1.pipe(($)=>Number.parseInt($,10)),RUN_WORKERS_FROM_SOURCE:aE.pipe(($)=>$==="true"),FRONTEND_PORT:Q1.pipe(($)=>Number.parseInt($,10)),FRONTEND_ORIGINS:Q1.pipe.try(($)=>JSON.parse($),I6("string[]")),API_KEY_OPENAI:I6("string | undefined"),API_KEY_RESEND:I6("string | undefined")},clientPrefix:"VITE_",client:{VITE_BACKEND_ORIGIN:Q1,VITE_DEV_FRONTEND_HOST:I6("string | undefined"),VITE_DEV_HTTPS:aE.pipe(($)=>$==="true")},runtimeEnv:import.meta.env,emptyStringAsUndefined:!0});var V5={};K1(V5,{users:()=>f0,untrackedUserColumnNames:()=>bv,twoFactorMethod:()=>WA,trackedUserColumnName:()=>fv,trackableUserColumnNames:()=>$A,signInHistory:()=>hv,role:()=>eE,players:()=>O5,passwordResetAttempts:()=>gv,games:()=>vU,banishedIps:()=>jU,accountActions:()=>yv,accountAction:()=>TA});function sE($){return O`lower(${$})`}var eE=j2("role",["admin","user"]),f0=f1("users",{id:z6().primaryKey().defaultRandom(),username:q4({length:16}).notNull(),emailOffered:q4({length:254}).notNull(),emailVerified:q4({length:254}),password:q4({length:254}),createdAt:N6({withTimezone:!0}).notNull().defaultNow(),createdIp:q4({length:45}).notNull(),isActive:g2().notNull().default(!1),verifiedAt:N6({withTimezone:!0}),userRole:eE().default("user")},($)=>[r7("usernameUniqueIndex").on(sE($.username)),r7("emailVerifiedUniqueIndex").on(sE($.emailVerified))]),bv=["id","createdAt","createdIp","isActive","verifiedAt"],$A=["username","emailOffered","emailVerified","password","userRole"],fv=j2("trackedUserColumnName",$A),TA=j2("accountAction",["cooldown","confirmEmail","signIn","resetPassword"]),yv=f1("accountActions",{userId:z6().references(()=>f0.id).primaryKey(),action:TA().notNull(),code:q4({length:254}).notNull(),wrongCodeCount:m2().notNull().default(0),expiresAt:N6({withTimezone:!0}).notNull()}),vU=f1("games",{id:z6().primaryKey().defaultRandom()}),O5=f1("players",{userId:z6().notNull().references(()=>f0.id,{onDelete:"cascade"}),gameId:z6().notNull().references(()=>vU.id,{onDelete:"cascade"}),score:m2().notNull()},($)=>[pD({name:"players_userId_gameId_pk",columns:[$.userId,$.gameId]})]),hv=f1("signInHistory",{id:z6().primaryKey().defaultRandom(),userId:z6().references(()=>f0.id,{onDelete:"cascade"}),signInTime:N6({withTimezone:!0}).notNull().defaultNow(),ipAddress:q4({length:45}).notNull(),userAgent:q4({length:1024}),successful:g2().notNull().default(!1)}),WA=j2("twoFactorMethod",["email","phone"]),gv=f1("passwordResetAttempts",{id:z6().primaryKey().defaultRandom(),userId:z6().notNull().references(()=>f0.id,{onDelete:"cascade"}),requestedIp:q4({length:45}).notNull(),requestedAt:N6({withTimezone:!0}).notNull().defaultNow(),succeededIp:q4({length:45}),succeededAt:N6({withTimezone:!0}),verificationMethod:WA().notNull()}),jU=f1("banishedIps",{ip:q4({length:45}).primaryKey(),reason:q4({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 K5{options;sql;drizzle;observers=new Map;async setupTriggersAndNotifications(){await this.sql.file(mv.resolve(__dirname,"notify_update.sql"));let $=[F4(f0),F4(vU),F4(O5)];await this.sql`SELECT create_notify_triggers(${this.sql.array($)})`,await this.sql.listen("table_update",(T)=>{let W=T.split(","),X=W[0],Y=W[1],U=`${X}("${Y}")`;if(this.observers.has(U))this.observers.get(U).next(U)})}constructor($=!1,T={host:Z1.POSTGRES_HOST,port:Z1.POSTGRES_PORT,user:Z1.POSTGRES_USER,password:Z1.POSTGRES_PASSWORD,database:Z1.POSTGRES_DATABASE}){this.options=T,this.sql=IT(T),this.drizzle=WU(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 pv}from"path";import{existsSync as E5,mkdirSync as XA,readFileSync as cv,readdirSync as YA,rmSync as UA,statSync as GA,writeFileSync as uv}from"fs";import{resolve as A5}from"path";var JA=class{rootDir;get initialized(){return E5(this.rootDir)}initialize(){if(!this.initialized)XA(this.rootDir,{recursive:!0})}constructor($){if(this.rootDir=$.path,$.eagerInit)this.initialize()}getItem($){let T=A5(this.rootDir,$);if(E5(T))return cv(T,"utf-8");return null}setItem($,T){this.initialize();let W=A5(this.rootDir,$);uv(W,T)}removeItem($){let T=A5(this.rootDir,$);if(E5(T))this.initialize(),UA(T)}key($){return YA(this.rootDir).sort((X,Y)=>{let U=GA(X);return GA(Y).ctimeMs-U.ctimeMs})[$]??null}clear(){UA(this.rootDir,{recursive:!0}),XA(this.rootDir,{recursive:!0})}get length(){return YA(this.rootDir).length}};var M5=new JA({path:pv(process.cwd(),"storage")});import*as xU from"fs";import*as wA from"readline";function ov($){let W=$.replace(":","T").replace(" ","").replace(/(\d{2})\/(\w{3})\/(\d{4})T(.+)/,(X,Y,U,G,J)=>{let w={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`${G}-${w}-${Y}T${J}`});return new Date(W)}async function zA($,T="/var/log/nginx/access.log",W=new Date){let X=new Map;if(!xU.existsSync(T))return $.error(`Log file not found: ${T}`),X;let Y=xU.createReadStream(T),U=wA.createInterface({input:Y,crlfDelay:Number.POSITIVE_INFINITY}),G=new Date(W.getTime()-3600000);return U.on("line",(J)=>{let z=/^(?<ip>\S+) \S+ \S+ \[(?<dateTime>.*?)\]/,w=J.match(z);if(w?.groups){let H=w.groups.ip,_=w.groups.dateTime,F=ov(_);if(!Number.isNaN(F.getTime())){if(F>=G&&F<=W){let D=X.get(H);if(!D)D=[],X.set(H,D);D.push(J)}}else $.error(`Failed to parse date: ${_}`)}}),new Promise((J,z)=>{U.on("error",(w)=>{z(w)}),U.on("close",()=>{J(X)})})}function _A($){return $.toJsonSchema()}var dv=["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(`
152
- `);function HA($){return dv+$.join(`
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(`
153
154
 
154
- `)}var FA={schema:I6([{shouldBanIp:"false"},"|",{shouldBanIp:"true",veryConciseReason:"string"}]),toJsonSchema:_A,fallback:{shouldBanIp:!1}};var rv=[".env","php"];async function QA({generator:$,logFilePath:T,logger:W,now:X=new Date}){let Y=$.usdBudget,U=new K5({logQuery(N,k){W.info("\uD83D\uDCDD query",N,k)}}),G=await zA(W,T,X),J=[],z=$.from(FA),w=0,H=0;for(let[N,k]of G){W.info(`\uD83D\uDD0D ruling on ${N}. logs:`),W.info(k.map((x)=>` ${x}`).join(`
155
- `));let y=!1;for(let x of rv)if(k.some((m)=>m.includes(x))){J.push({ip:N,reason:`Always ban ${x}`}),W.info(` \uD83E\uDDD1\u200D\u2696\uFE0F banning ${N}--always ban ${x}
156
- `),y=!0;break}if(y)continue;if($.usdBudget>$.usdMinimum){let x=HA(k),m=await z(x);if(m.shouldBanIp)J.push({ip:N,reason:m.veryConciseReason}),W.info(` \uD83E\uDDD1\u200D\u2696\uFE0F banning ${N}--${m.veryConciseReason}
157
- `);else H++,W.info(` \uD83D\uDD4A\uFE0F not banning ${N}
158
- `);w++}else{W.warn("\uD83D\uDCB0 insufficient funds to process all logs"),W.warn(`\uD83D\uDCB0 got through ${w}/${G.size} ips
159
- `);break}}let _=J.length;if(J.length>0)await U.drizzle.insert(jU).values(J).onConflictDoNothing();let F=[],D=M5.getItem("lastTribunalProcessedDate"),V=new Date(D??"1970-01-01");try{F.push(...await U.drizzle.query.banishedIps.findMany({columns:{ip:!0},where:gY(jU.banishedAt,V)}))}catch(N){W.error(N)}try{if(process.env.EXPERIMENTAL_BAN_IPS)await Promise.all(F.map((N)=>new Promise((k,y)=>lv(`iptables -D INPUT -s ${N.ip} -j DROP`).on("exit",(x)=>{if(x===0)W.info(`\uD83E\uDDD1\u200D\u2696\uFE0F banned ${N.ip}`),k();else y(new Error(`iptables exited with code ${x}`))}))));else W.info("\uD83E\uDDD1\u200D\u2696\uFE0F skipping iptables update")}catch(N){if(N instanceof Error)W.error(N.message);else{let k=SQ(N);W.error("iptables exited with error",k)}}M5.setItem("lastTribunalProcessedDate",X.toISOString()),W.info(`\u2728 banned ${_} ips, didn't ban ${H} ips`);let E=Y-$.usdBudget,R=E.toLocaleString("en",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:6}),P=Y.toLocaleString("en",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:6}),M=Math.round(E/Y*100);W.info(`\uD83D\uDCB8 spent ${R}, ${M}% of ${P} budget`)}var D1=new sU;Object.assign(console,D1.logger,{log:D1.logger.info});process.on("SIGINT",()=>{D1.logger.info("\u2757 received SIGINT; exiting gracefully"),bU()});process.on("SIGTERM",()=>{D1.logger.info("\u2757 received SIGTERM; exiting gracefully"),bU()});process.on("exit",()=>{D1.logger.info("\u2757 received exit; exiting gracefully"),bU()});D1.logger.info("\uD83D\uDEEB tribunal worker ready");var iv=new LQ({usdBudget:0.01,usdMinimum:0,model:"gpt-4o-mini",apiKey:Z1.API_KEY_OPENAI,cachingMode:"off",logger:D1.logger});if(Z1.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 QA({generator:iv,logFilePath:"/var/log/nginx/access.log",logger:D1.logger});bU();function bU(){D1.logger.info("\uD83D\uDEEC tribunal server exiting"),process.exit(0)}
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)}