@openai/agents-realtime
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. This package contains the logic for building realtime voice agents on the server or in the browser.
3 lines (2 loc) • 1.76 MB
JavaScript
(function(J,ee){typeof exports=="object"&&typeof module<"u"?ee(exports):typeof define=="function"&&define.amd?define(["exports"],ee):(J=typeof globalThis<"u"?globalThis:J||self,ee(J.OpenAIAgentsRealtime={}))})(this,(function(J){"use strict";var df=Object.defineProperty;var vo=J=>{throw TypeError(J)};var pf=(J,ee,ce)=>ee in J?df(J,ee,{enumerable:!0,configurable:!0,writable:!0,value:ce}):J[ee]=ce;var S=(J,ee,ce)=>pf(J,typeof ee!="symbol"?ee+"":ee,ce),js=(J,ee,ce)=>ee.has(J)||vo("Cannot "+ce);var u=(J,ee,ce)=>(js(J,ee,"read from private field"),ce?ce.call(J):ee.get(J)),R=(J,ee,ce)=>ee.has(J)?vo("Cannot add the same private member more than once"):ee instanceof WeakSet?ee.add(J):ee.set(J,ce),k=(J,ee,ce,tr)=>(js(J,ee,"write to private field"),tr?tr.call(J,ce):ee.set(J,ce),ce),U=(J,ee,ce)=>(js(J,ee,"access private method"),ce);var Yt,Et,Te,Qt,ae,$s,Fs,wo,bo,Io,So,Xn,Ls,Us,On,dt,ke,nt,en,tn,En,Rt,Rn,Nn,nn,Pn,Dn,rn,ve,rt,pt,ft,sn,Se,Zs,qs,fn,Ae,Mn,jn,$n,Fn,Nt,ht,mt,Pt,Ln,an,st,ye,Dt,jr,xo,Mt,Un,xe,Zn,qn,se,Bn,gt,Jn,yt,jt,$t,ge,zn,it,Ft,Lt,on,Gn,Ut,Bs,To,H,q,un,B,cn,ln,Vn,oe,dn,pn,ze,Wn,Zt,Hn,Kn,ie,Qn,er,ko,Fr,Ao,Js,Co,zs;const ee={version:"0.3.7"};async function ce(n){try{return[null,await n()]}catch(e){return[e,null]}}function tr(n){const e=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,s])=>e.indexOf(+r)===-1).map(([r,s])=>s)}class Gs{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const r=t[0];if(this._map.set(e,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};return delete r.id,{...r,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function Oo(){return new Gs}const Eo=Oo();class Vs{constructor(e){this.counter=0,this.metadataRegistry=(e==null?void 0:e.metadata)??Eo,this.target=(e==null?void 0:e.target)??"draft-2020-12",this.unrepresentable=(e==null?void 0:e.unrepresentable)??"throw",this.override=(e==null?void 0:e.override)??(()=>{}),this.io=(e==null?void 0:e.io)??"output",this.seen=new Map}process(e,t={path:[],schemaPath:[]}){var d,m,g;var r;const s=e._zod.def,i={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},o=this.seen.get(e);if(o)return o.count++,t.schemaPath.includes(e)&&(o.cycle=t.path),o.schema;const a={schema:{},count:1,cycle:void 0,path:t.path};this.seen.set(e,a);const c=(m=(d=e._zod).toJSONSchema)==null?void 0:m.call(d);if(c)a.schema=c;else{const v={...t,schemaPath:[...t.schemaPath,e],path:t.path},x=e._zod.parent;if(x)a.ref=x,this.process(x,v),this.seen.get(x).isParent=!0;else{const y=a.schema;switch(s.type){case"string":{const h=y;h.type="string";const{minimum:b,maximum:_,format:N,patterns:T,contentEncoding:A}=e._zod.bag;if(typeof b=="number"&&(h.minLength=b),typeof _=="number"&&(h.maxLength=_),N&&(h.format=i[N]??N,h.format===""&&delete h.format),A&&(h.contentEncoding=A),T&&T.size>0){const D=[...T];D.length===1?h.pattern=D[0].source:D.length>1&&(a.schema.allOf=[...D.map(F=>({...this.target==="draft-7"?{type:"string"}:{},pattern:F.source}))])}break}case"number":{const h=y,{minimum:b,maximum:_,format:N,multipleOf:T,exclusiveMaximum:A,exclusiveMinimum:D}=e._zod.bag;typeof N=="string"&&N.includes("int")?h.type="integer":h.type="number",typeof D=="number"&&(h.exclusiveMinimum=D),typeof b=="number"&&(h.minimum=b,typeof D=="number"&&(D>=b?delete h.minimum:delete h.exclusiveMinimum)),typeof A=="number"&&(h.exclusiveMaximum=A),typeof _=="number"&&(h.maximum=_,typeof A=="number"&&(A<=_?delete h.maximum:delete h.exclusiveMaximum)),typeof T=="number"&&(h.multipleOf=T);break}case"boolean":{const h=y;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"null":{y.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{y.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const h=y,{minimum:b,maximum:_}=e._zod.bag;typeof b=="number"&&(h.minItems=b),typeof _=="number"&&(h.maxItems=_),h.type="array",h.items=this.process(s.element,{...v,path:[...v.path,"items"]});break}case"object":{const h=y;h.type="object",h.properties={};const b=s.shape;for(const T in b)h.properties[T]=this.process(b[T],{...v,path:[...v.path,"properties",T]});const _=new Set(Object.keys(b)),N=new Set([..._].filter(T=>{const A=s.shape[T]._zod;return this.io==="input"?A.optin===void 0:A.optout===void 0}));N.size>0&&(h.required=Array.from(N)),((g=s.catchall)==null?void 0:g._zod.def.type)==="never"?h.additionalProperties=!1:s.catchall?s.catchall&&(h.additionalProperties=this.process(s.catchall,{...v,path:[...v.path,"additionalProperties"]})):this.io==="output"&&(h.additionalProperties=!1);break}case"union":{const h=y;h.anyOf=s.options.map((b,_)=>this.process(b,{...v,path:[...v.path,"anyOf",_]}));break}case"intersection":{const h=y,b=this.process(s.left,{...v,path:[...v.path,"allOf",0]}),_=this.process(s.right,{...v,path:[...v.path,"allOf",1]}),N=A=>"allOf"in A&&Object.keys(A).length===1,T=[...N(b)?b.allOf:[b],...N(_)?_.allOf:[_]];h.allOf=T;break}case"tuple":{const h=y;h.type="array";const b=s.items.map((T,A)=>this.process(T,{...v,path:[...v.path,"prefixItems",A]}));if(this.target==="draft-2020-12"?h.prefixItems=b:h.items=b,s.rest){const T=this.process(s.rest,{...v,path:[...v.path,"items"]});this.target==="draft-2020-12"?h.items=T:h.additionalItems=T}s.rest&&(h.items=this.process(s.rest,{...v,path:[...v.path,"items"]}));const{minimum:_,maximum:N}=e._zod.bag;typeof _=="number"&&(h.minItems=_),typeof N=="number"&&(h.maxItems=N);break}case"record":{const h=y;h.type="object",h.propertyNames=this.process(s.keyType,{...v,path:[...v.path,"propertyNames"]}),h.additionalProperties=this.process(s.valueType,{...v,path:[...v.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":{const h=y,b=tr(s.entries);b.every(_=>typeof _=="number")&&(h.type="number"),b.every(_=>typeof _=="string")&&(h.type="string"),h.enum=b;break}case"literal":{const h=y,b=[];for(const _ of s.values)if(_===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof _=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");b.push(Number(_))}else b.push(_);if(b.length!==0)if(b.length===1){const _=b[0];h.type=_===null?"null":typeof _,h.const=_}else b.every(_=>typeof _=="number")&&(h.type="number"),b.every(_=>typeof _=="string")&&(h.type="string"),b.every(_=>typeof _=="boolean")&&(h.type="string"),b.every(_=>_===null)&&(h.type="null"),h.enum=b;break}case"file":{const h=y,b={type:"string",format:"binary",contentEncoding:"binary"},{minimum:_,maximum:N,mime:T}=e._zod.bag;_!==void 0&&(b.minLength=_),N!==void 0&&(b.maxLength=N),T?T.length===1?(b.contentMediaType=T[0],Object.assign(h,b)):h.anyOf=T.map(A=>({...b,contentMediaType:A})):Object.assign(h,b);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const h=this.process(s.innerType,v);y.anyOf=[h,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,v),a.ref=s.innerType;break}case"success":{const h=y;h.type="boolean";break}case"default":{this.process(s.innerType,v),a.ref=s.innerType,y.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,v),a.ref=s.innerType,this.io==="input"&&(y._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,v),a.ref=s.innerType;let h;try{h=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}y.default=h;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const h=y,b=e._zod.pattern;if(!b)throw new Error("Pattern not found in template literal");h.type="string",h.pattern=b.source;break}case"pipe":{const h=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(h,v),a.ref=h;break}case"readonly":{this.process(s.innerType,v),a.ref=s.innerType,y.readOnly=!0;break}case"promise":{this.process(s.innerType,v),a.ref=s.innerType;break}case"optional":{this.process(s.innerType,v),a.ref=s.innerType;break}case"lazy":{const h=e._zod.innerType;this.process(h,v),a.ref=h;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const l=this.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),this.io==="input"&&fe(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,t){var f,d,m,g,v,x;const r={cycles:(t==null?void 0:t.cycles)??"ref",reused:(t==null?void 0:t.reused)??"inline",external:(t==null?void 0:t.external)??void 0},s=this.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=y=>{var T;const h=this.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const A=(T=r.external.registry.get(y[0]))==null?void 0:T.id,D=r.external.uri??(G=>G);if(A)return{ref:D(A)};const F=y[1].defId??y[1].schema.id??`schema${this.counter++}`;return y[1].defId=F,{defId:F,ref:`${D("__shared")}#/${h}/${F}`}}if(y[1]===s)return{ref:"#"};const _=`#/${h}/`,N=y[1].schema.id??`__schema${this.counter++}`;return{defId:N,ref:_+N}},o=y=>{if(y[1].schema.$ref)return;const h=y[1],{ref:b,defId:_}=i(y);h.def={...h.schema},_&&(h.defId=_);const N=h.schema;for(const T in N)delete N[T];N.$ref=b};if(r.cycles==="throw")for(const y of this.seen.entries()){const h=y[1];if(h.cycle)throw new Error(`Cycle detected: #/${(f=h.cycle)==null?void 0:f.join("/")}/<root>
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const y of this.seen.entries()){const h=y[1];if(e===y[0]){o(y);continue}if(r.external){const _=(d=r.external.registry.get(y[0]))==null?void 0:d.id;if(e!==y[0]&&_){o(y);continue}}if((m=this.metadataRegistry.get(y[0]))==null?void 0:m.id){o(y);continue}if(h.cycle){o(y);continue}if(h.count>1&&r.reused==="ref"){o(y);continue}}const a=(y,h)=>{const b=this.seen.get(y),_=b.def??b.schema,N={..._};if(b.ref===null)return;const T=b.ref;if(b.ref=null,T){a(T,h);const A=this.seen.get(T).schema;A.$ref&&h.target==="draft-7"?(_.allOf=_.allOf??[],_.allOf.push(A)):(Object.assign(_,A),Object.assign(_,N))}b.isParent||this.override({zodSchema:y,jsonSchema:_,path:b.path??[]})};for(const y of[...this.seen.entries()].reverse())a(y[0],{target:this.target});const c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),(g=r.external)!=null&&g.uri){const y=(v=r.external.registry.get(e))==null?void 0:v.id;if(!y)throw new Error("Schema is missing an `id` property");c.$id=r.external.uri(y)}Object.assign(c,s.def);const l=((x=r.external)==null?void 0:x.defs)??{};for(const y of this.seen.entries()){const h=y[1];h.def&&h.defId&&(l[h.defId]=h.def)}r.external||Object.keys(l).length>0&&(this.target==="draft-2020-12"?c.$defs=l:c.definitions=l);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}}function Ro(n,e){if(n instanceof Gs){const r=new Vs(e),s={};for(const a of n._idmap.entries()){const[c,l]=a;r.process(l)}const i={},o={registry:n,uri:e==null?void 0:e.uri,defs:s};for(const a of n._idmap.entries()){const[c,l]=a;i[c]=r.emit(l,{...e,external:o})}if(Object.keys(s).length>0){const a=r.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[a]:s}}return{schemas:i}}const t=new Vs(e);return t.process(n),t.emit(n,e)}function fe(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const s=n._zod.def;switch(s.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return fe(s.element,t);case"object":{for(const i in s.shape)if(fe(s.shape[i],t))return!0;return!1}case"union":{for(const i of s.options)if(fe(i,t))return!0;return!1}case"intersection":return fe(s.left,t)||fe(s.right,t);case"tuple":{for(const i of s.items)if(fe(i,t))return!0;return!!(s.rest&&fe(s.rest,t))}case"record":return fe(s.keyType,t)||fe(s.valueType,t);case"map":return fe(s.keyType,t)||fe(s.valueType,t);case"set":return fe(s.valueType,t);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return fe(s.innerType,t);case"lazy":return fe(s.getter(),t);case"default":return fe(s.innerType,t);case"prefault":return fe(s.innerType,t);case"custom":return!1;case"transform":return!0;case"pipe":return fe(s.in,t)||fe(s.out,t);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}function No(n,e){const t={...n};return Object.defineProperties(t,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:e,enumerable:!1}}),t}const Po=Symbol("Let zodToJsonSchema decide on which parser to use"),Ws={name:void 0,$refStrategy:"root",effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",nullableStrategy:"from-target",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Do=n=>typeof n=="string"?{...Ws,basePath:["#"],definitions:{},name:n}:{...Ws,basePath:["#"],definitions:{},...n},Lr=n=>"_def"in n?n._def:n;function Mo(n){if(!n)return!0;for(const e in n)return!1;return!0}const jo=n=>{const e=Do(n),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:t,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(e.definitions).map(([r,s])=>[Lr(s),{def:Lr(s),path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))}};function Hs(n,e,t,r){r!=null&&r.errorMessages&&t&&(n.errorMessage={...n.errorMessage,[e]:t})}function ne(n,e,t,r,s){n[e]=t,Hs(n,e,r,s)}var X;(function(n){n.assertEqual=s=>{};function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},n.getValidEnumValues=s=>{const i=n.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(i){return s[i]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},n.find=(s,i)=>{for(const o of s)if(i(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}n.joinValues=r,n.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(X||(X={}));var Ks;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Ks||(Ks={}));const M=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),at=n=>{switch(typeof n){case"undefined":return M.undefined;case"string":return M.string;case"number":return Number.isNaN(n)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(n)?M.array:n===null?M.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?M.promise:typeof Map<"u"&&n instanceof Map?M.map:typeof Set<"u"&&n instanceof Set?M.set:typeof Date<"u"&&n instanceof Date?M.date:M.object;default:return M.unknown}},C=X.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class je extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let a=r,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof je))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,X.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];t[i]=t[i]||[],t[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}je.create=n=>new je(n);const Ur=(n,e)=>{let t;switch(n.code){case C.invalid_type:n.received===M.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case C.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,X.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:t=`Unrecognized key(s) in object: ${X.joinValues(n.keys,", ")}`;break;case C.invalid_union:t="Invalid input";break;case C.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${X.joinValues(n.options)}`;break;case C.invalid_enum_value:t=`Invalid enum value. Expected ${X.joinValues(n.options)}, received '${n.received}'`;break;case C.invalid_arguments:t="Invalid function arguments";break;case C.invalid_return_type:t="Invalid function return type";break;case C.invalid_date:t="Invalid date";break;case C.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:X.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case C.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case C.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case C.custom:t="Invalid input";break;case C.invalid_intersection_types:t="Intersection results could not be merged";break;case C.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case C.not_finite:t="Number must be finite";break;default:t=e.defaultError,X.assertNever(n)}return{message:t}};let $o=Ur;function Fo(){return $o}const Lo=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,i=[...t,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)a=l(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function P(n,e){const t=Fo(),r=Lo({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Ur?void 0:Ur].filter(s=>!!s)});n.common.issues.push(r)}class we{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return Z;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return we.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return Z;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const Z=Object.freeze({status:"aborted"}),hn=n=>({status:"dirty",value:n}),Ce=n=>({status:"valid",value:n}),Ys=n=>n.status==="aborted",Xs=n=>n.status==="dirty",qt=n=>n.status==="valid",nr=n=>typeof Promise<"u"&&n instanceof Promise;var $;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})($||($={}));class $e{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Qs=(n,e)=>{if(qt(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new je(n.common.issues);return this._error=t,this._error}}};function V(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{const{message:c}=n;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??t??a.defaultError}},description:s}}class K{get description(){return this._def.description}_getType(e){return at(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:at(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new we,ctx:{common:e.parent.common,data:e.data,parsedType:at(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(nr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:at(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Qs(r,s)}"~validate"(e){var r,s;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:at(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return qt(i)?{value:i.value}:{issues:t.common.issues}}catch(i){(s=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>qt(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:at(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(nr(s)?s:Promise.resolve(s));return Qs(r,i)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:C.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new wt({schema:this,typeName:O.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return He.create(this,this._def)}nullable(){return bt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Fe.create(this)}promise(){return cr.create(this,this._def)}or(e){return sr.create([this,e],this._def)}and(e){return ir.create(this,e,this._def)}transform(e){return new wt({...V(this._def),schema:this,typeName:O.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lr({...V(this._def),innerType:this,defaultValue:t,typeName:O.ZodDefault})}brand(){return new ui({typeName:O.ZodBranded,type:this,...V(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new dr({...V(this._def),innerType:this,catchValue:t,typeName:O.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Wr.create(this,e)}readonly(){return pr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Uo=/^c[^\s-]{8,}$/i,Zo=/^[0-9a-z]+$/,qo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Bo=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Jo=/^[a-z0-9_-]{21}$/i,zo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Go=/^[-+]?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)?)??$/,Vo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Wo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Zr;const Ho=/^(?:(?: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])$/,Ko=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Yo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Xo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Qo=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,eu=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ei="((\\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])))",tu=new RegExp(`^${ei}$`);function ti(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);const t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function nu(n){return new RegExp(`^${ti(n)}$`)}function ru(n){let e=`${ei}T${ti(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function su(n,e){return!!((e==="v4"||!e)&&Ho.test(n)||(e==="v6"||!e)&&Yo.test(n))}function iu(n,e){if(!zo.test(n))return!1;try{const[t]=n.split(".");if(!t)return!1;const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function au(n,e){return!!((e==="v4"||!e)&&Ko.test(n)||(e==="v6"||!e)&&Xo.test(n))}class Ve extends K{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==M.string){const i=this._getOrReturnCtx(e);return P(i,{code:C.invalid_type,expected:M.string,received:i.parsedType}),Z}const r=new we;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),P(s,{code:C.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),P(s,{code:C.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?P(s,{code:C.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&P(s,{code:C.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Vo.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"email",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Zr||(Zr=new RegExp(Wo,"u")),Zr.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"emoji",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Bo.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"uuid",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Jo.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"nanoid",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")Uo.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"cuid",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Zo.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"cuid2",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")qo.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"ulid",code:C.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),P(s,{validation:"url",code:C.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"regex",code:C.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),P(s,{code:C.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),P(s,{code:C.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),P(s,{code:C.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?ru(i).test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{code:C.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?tu.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{code:C.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?nu(i).test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{code:C.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Go.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"duration",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?su(e.data,i.version)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"ip",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?iu(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"jwt",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?au(e.data,i.version)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"cidr",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Qo.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"base64",code:C.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?eu.test(e.data)||(s=this._getOrReturnCtx(e,s),P(s,{validation:"base64url",code:C.invalid_string,message:i.message}),r.dirty()):X.assertNever(i);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:C.invalid_string,...$.errToObj(r)})}_addCheck(e){return new Ve({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...$.errToObj(e)})}url(e){return this._addCheck({kind:"url",...$.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...$.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...$.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...$.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...$.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...$.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...$.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...$.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...$.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...$.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...$.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...$.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...$.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...$.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...$.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...$.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...$.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...$.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...$.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...$.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...$.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...$.errToObj(t)})}nonempty(e){return this.min(1,$.errToObj(e))}trim(){return new Ve({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ve({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ve({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ve.create=n=>new Ve({checks:[],typeName:O.ZodString,coerce:(n==null?void 0:n.coerce)??!1,...V(n)});function ou(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,i=Number.parseInt(n.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}class Bt extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==M.number){const i=this._getOrReturnCtx(e);return P(i,{code:C.invalid_type,expected:M.number,received:i.parsedType}),Z}let r;const s=new we;for(const i of this._def.checks)i.kind==="int"?X.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),P(r,{code:C.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?ou(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),P(r,{code:C.not_finite,message:i.message}),s.dirty()):X.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,$.toString(t))}gt(e,t){return this.setLimit("min",e,!1,$.toString(t))}lte(e,t){return this.setLimit("max",e,!0,$.toString(t))}lt(e,t){return this.setLimit("max",e,!1,$.toString(t))}setLimit(e,t,r,s){return new Bt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:$.toString(s)}]})}_addCheck(e){return new Bt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:$.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:$.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:$.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:$.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:$.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:$.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:$.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:$.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:$.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&X.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Bt.create=n=>new Bt({checks:[],typeName:O.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...V(n)});class mn extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==M.bigint)return this._getInvalidInput(e);let r;const s=new we;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):X.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return P(t,{code:C.invalid_type,expected:M.bigint,received:t.parsedType}),Z}gte(e,t){return this.setLimit("min",e,!0,$.toString(t))}gt(e,t){return this.setLimit("min",e,!1,$.toString(t))}lte(e,t){return this.setLimit("max",e,!0,$.toString(t))}lt(e,t){return this.setLimit("max",e,!1,$.toString(t))}setLimit(e,t,r,s){return new mn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:$.toString(s)}]})}_addCheck(e){return new mn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:$.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:$.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:$.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:$.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:$.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}mn.create=n=>new mn({checks:[],typeName:O.ZodBigInt,coerce:(n==null?void 0:n.coerce)??!1,...V(n)});class qr extends K{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==M.boolean){const r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:M.boolean,received:r.parsedType}),Z}return Ce(e.data)}}qr.create=n=>new qr({typeName:O.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...V(n)});class rr extends K{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==M.date){const i=this._getOrReturnCtx(e);return P(i,{code:C.invalid_type,expected:M.date,received:i.parsedType}),Z}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return P(i,{code:C.invalid_date}),Z}const r=new we;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),P(s,{code:C.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),P(s,{code:C.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):X.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new rr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:$.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:$.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}rr.create=n=>new rr({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:O.ZodDate,...V(n)});class ni extends K{_parse(e){if(this._getType(e)!==M.symbol){const r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:M.symbol,received:r.parsedType}),Z}return Ce(e.data)}}ni.create=n=>new ni({typeName:O.ZodSymbol,...V(n)});class Br extends K{_parse(e){if(this._getType(e)!==M.undefined){const r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:M.undefined,received:r.parsedType}),Z}return Ce(e.data)}}Br.create=n=>new Br({typeName:O.ZodUndefined,...V(n)});class Jr extends K{_parse(e){if(this._getType(e)!==M.null){const r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:M.null,received:r.parsedType}),Z}return Ce(e.data)}}Jr.create=n=>new Jr({typeName:O.ZodNull,...V(n)});class gn extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return Ce(e.data)}}gn.create=n=>new gn({typeName:O.ZodAny,...V(n)});class ri extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ce(e.data)}}ri.create=n=>new ri({typeName:O.ZodUnknown,...V(n)});class ot extends K{_parse(e){const t=this._getOrReturnCtx(e);return P(t,{code:C.invalid_type,expected:M.never,received:t.parsedType}),Z}}ot.create=n=>new ot({typeName:O.ZodNever,...V(n)});class si extends K{_parse(e){if(this._getType(e)!==M.undefined){const r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:M.void,received:r.parsedType}),Z}return Ce(e.data)}}si.create=n=>new si({typeName:O.ZodVoid,...V(n)});class Fe extends K{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==M.array)return P(t,{code:C.invalid_type,expected:M.array,received:t.parsedType}),Z;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;(o||a)&&(P(t,{code:o?C.too_big:C.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array"