palmagent 0.1.0-alpha.39 → 0.1.0-alpha.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build-info.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.0-alpha.39",
2
+ "version": "0.1.0-alpha.40",
3
3
  "agentCliCompatibility": {
4
4
  "claude": {
5
5
  "range": ">=2.1.268 <2.2.0",
@@ -12,6 +12,6 @@
12
12
  "exclusiveMaximum": "0.155.0"
13
13
  }
14
14
  },
15
- "sourceCommit": "22c5add3b5bacbe580d27d46eced6302890b99a9",
15
+ "sourceCommit": "d805b92dfee3b2d8869eed55a00a1e2a9061b872",
16
16
  "dirty": false
17
17
  }
package/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var cc=Object.defineProperty;var O=(t,e)=>()=>(t&&(e=t(t=0)),e);var Or=(t,e)=>{for(var n in e)cc(t,n,{get:e[n],enumerable:!0})};var Qs=O(()=>{});function uc(t){let e=dc.exec(t);return e?{repo:e[1],number:Number(e[2])}:null}function Un(t){let e=uc(t);return e?{url:t,number:e.number,repo:e.repo,status:"open",checks:"unknown"}:null}var dc,ei=O(()=>{dc=/^https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)/});var Dr,ti=O(()=>{Dr={claude:"acceptEdits",codex:"workspace-write"}});var ni=O(()=>{});var _,ri=O(()=>{_={productName:"Palmagent",displayName:"PalmAgent",packageName:"palmagent",cliName:"palmagent",unitBase:"palmagent",stateDirName:"palmagent"}});var rt,Pr=O(()=>{rt={claude:{range:">=2.1.268 <2.2.0",minimum:"2.1.268",exclusiveMaximum:"2.2.0"},codex:{range:">=0.154.0 <0.155.0",minimum:"0.154.0",exclusiveMaximum:"0.155.0"}}});function si(t,e){let n=o=>/^\d+\.\d+\.\d+$/.test(o)?o.split(".").map(Number):void 0,r=n(e);if(!r)return!1;let s=o=>{let a=n(o);for(let c=0;c<3;c++)if(r[c]!==a[c])return r[c]-a[c];return 0},i=rt[t];return s(i.minimum)>=0&&s(i.exclusiveMaximum)<0}var ii=O(()=>{Pr();Pr()});var P,Lr,y,we,Yt=O(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.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)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(P||(P={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Lr||(Lr={}));y=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),we=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}}});var f,pc,ee,$n=O(()=>{Yt();f=P.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"]),pc=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ee=class t 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]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let 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(n(o));else{let a=r,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};ee.create=t=>new ee(t)});var fc,Te,Ur=O(()=>{$n();Yt();fc=(t,e)=>{let n;switch(t.code){case f.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,P.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:n=`Unrecognized key(s) in object: ${P.joinValues(t.keys,", ")}`;break;case f.invalid_union:n="Invalid input";break;case f.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${P.joinValues(t.options)}`;break;case f.invalid_enum_value:n=`Invalid enum value. Expected ${P.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:n="Invalid function arguments";break;case f.invalid_return_type:n="Invalid function return type";break;case f.invalid_date:n="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:P.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case f.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case f.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case f.custom:n="Invalid input";break;case f.invalid_intersection_types:n="Intersection results could not be merged";break;case f.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:n="Number must be finite";break;default:n=e.defaultError,P.assertNever(t)}return{message:n}},Te=fc});function hc(t){oi=t}function It(){return oi}var oi,jn=O(()=>{Ur();oi=Te});function g(t,e){let n=It(),r=Qt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Te?void 0:Te].filter(s=>!!s)});t.common.issues.push(r)}var Qt,mc,J,S,st,K,Mn,Hn,Fe,Ct,$r=O(()=>{jn();Ur();Qt=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},mc=[];J=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return S;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return S;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}}},S=Object.freeze({status:"aborted"}),st=t=>({status:"dirty",value:t}),K=t=>({status:"valid",value:t}),Mn=t=>t.status==="aborted",Hn=t=>t.status==="dirty",Fe=t=>t.status==="valid",Ct=t=>typeof Promise<"u"&&t instanceof Promise});var ai=O(()=>{});var v,ci=O(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(v||(v={}))});function C(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||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)=>{let{message:c}=t;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??n??a.defaultError}},description:s}}function pi(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Oc(t){return new RegExp(`^${pi(t)}$`)}function fi(t){let e=`${li}T${pi(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Dc(t,e){return!!((e==="v4"||!e)&&kc.test(t)||(e==="v6"||!e)&&Rc.test(t))}function Pc(t,e){if(!wc.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Lc(t,e){return!!((e==="v4"||!e)&&Tc.test(t)||(e==="v6"||!e)&&Ac.test(t))}function Uc(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function Nt(t){if(t instanceof te){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=ae.create(Nt(r))}return new te({...t._def,shape:()=>e})}else return t instanceof Ie?new Ie({...t._def,type:Nt(t.element)}):t instanceof ae?ae.create(Nt(t.unwrap())):t instanceof xe?xe.create(Nt(t.unwrap())):t instanceof _e?_e.create(t.items.map(e=>Nt(e))):t}function Mr(t,e){let n=we(t),r=we(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=P.objectKeys(e),i=P.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Mr(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Mr(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function hi(t,e){return new mt({values:t,typeName:k.ZodEnum,...C(e)})}function ui(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function mi(t,e={},n){return t?We.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=ui(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=ui(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):We.create()}var ce,di,N,gc,yc,bc,vc,Ec,wc,_c,xc,Sc,jr,kc,Tc,Rc,Ac,Ic,Cc,li,Nc,Be,it,ot,at,ct,Ot,dt,ut,We,Ae,he,Dt,Ie,te,lt,Re,qn,pt,_e,Fn,Pt,Lt,Bn,ft,ht,mt,gt,Ve,de,ae,xe,yt,bt,Ut,$c,en,tn,vt,jc,k,Mc,gi,yi,Hc,qc,bi,Fc,Bc,Wc,Vc,zc,Gc,Jc,Xc,Kc,Zc,Yc,Qc,ed,td,nd,rd,sd,id,od,ad,cd,dd,ud,ld,pd,fd,hd,md,gd,yd,bd,vd,Ed,wd,vi=O(()=>{$n();jn();ci();$r();Yt();ce=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,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}},di=(t,e)=>{if(Fe(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new ee(t.common.issues);return this._error=n,this._error}}};N=class{get description(){return this._def.description}_getType(e){return we(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:we(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new J,ctx:{common:e.parent.common,data:e.data,parsedType:we(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Ct(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:we(e)},s=this._parseSync({data:e,path:r.path,parent:r});return di(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:we(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Fe(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Fe(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:we(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ct(s)?s:Promise.resolve(s));return di(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:f.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new de({schema:this,typeName:k.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:n=>this["~validate"](n)}}optional(){return ae.create(this,this._def)}nullable(){return xe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ie.create(this)}promise(){return Ve.create(this,this._def)}or(e){return lt.create([this,e],this._def)}and(e){return pt.create(this,e,this._def)}transform(e){return new de({...C(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new yt({...C(this._def),innerType:this,defaultValue:n,typeName:k.ZodDefault})}brand(){return new en({typeName:k.ZodBranded,type:this,...C(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new bt({...C(this._def),innerType:this,catchValue:n,typeName:k.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return tn.create(this,e)}readonly(){return vt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},gc=/^c[^\s-]{8,}$/i,yc=/^[0-9a-z]+$/,bc=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vc=/^[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,Ec=/^[a-z0-9_-]{21}$/i,wc=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_c=/^[-+]?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)?)??$/,xc=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Sc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",kc=/^(?:(?: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])$/,Tc=/^(?:(?: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])$/,Rc=/^(([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]))$/,Ac=/^(([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])$/,Ic=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Cc=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,li="((\\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])))",Nc=new RegExp(`^${li}$`);Be=class t extends N{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let i=this._getOrReturnCtx(e);return g(i,{code:f.invalid_type,expected:y.string,received:i.parsedType}),S}let r=new J,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:f.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),g(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?g(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&g(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")xc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"email",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")jr||(jr=new RegExp(Sc,"u")),jr.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"emoji",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")vc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"uuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Ec.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"nanoid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")gc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")yc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid2",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")bc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ulid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),g(s,{validation:"url",code:f.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),g(s,{validation:"regex",code:f.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),g(s,{code:f.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),g(s,{code:f.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:f.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?fi(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:f.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Nc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:f.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Oc(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:f.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?_c.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"duration",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Dc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ip",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Pc(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"jwt",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Lc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cidr",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Ic.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Cc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64url",code:f.invalid_string,message:i.message}),r.dirty()):P.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:f.invalid_string,...v.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.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?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...v.errToObj(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?.precision>"u"?null:e?.precision,...v.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...v.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...v.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...v.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...v.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...v.errToObj(n)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Be.create=t=>new Be({checks:[],typeName:k.ZodString,coerce:t?.coerce??!1,...C(t)});it=class t extends N{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)!==y.number){let i=this._getOrReturnCtx(e);return g(i,{code:f.invalid_type,expected:y.number,received:i.parsedType}),S}let r,s=new J;for(let i of this._def.checks)i.kind==="int"?P.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:f.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),g(r,{code:f.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),g(r,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Uc(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_finite,message:i.message}),s.dirty()):P.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,v.toString(n))}gt(e,n){return this.setLimit("min",e,!1,v.toString(n))}lte(e,n){return this.setLimit("max",e,!0,v.toString(n))}lt(e,n){return this.setLimit("max",e,!1,v.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&P.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};it.create=t=>new it({checks:[],typeName:k.ZodNumber,coerce:t?.coerce||!1,...C(t)});ot=class t extends N{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)!==y.bigint)return this._getInvalidInput(e);let r,s=new J;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.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),g(r,{code:f.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),g(r,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):P.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return g(n,{code:f.invalid_type,expected:y.bigint,received:n.parsedType}),S}gte(e,n){return this.setLimit("min",e,!0,v.toString(n))}gt(e,n){return this.setLimit("min",e,!1,v.toString(n))}lte(e,n){return this.setLimit("max",e,!0,v.toString(n))}lt(e,n){return this.setLimit("max",e,!1,v.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ot.create=t=>new ot({checks:[],typeName:k.ZodBigInt,coerce:t?.coerce??!1,...C(t)});at=class extends N{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.boolean,received:r.parsedType}),S}return K(e.data)}};at.create=t=>new at({typeName:k.ZodBoolean,coerce:t?.coerce||!1,...C(t)});ct=class t extends N{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let i=this._getOrReturnCtx(e);return g(i,{code:f.invalid_type,expected:y.date,received:i.parsedType}),S}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return g(i,{code:f.invalid_date}),S}let r=new J,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:f.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),g(s,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):P.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};ct.create=t=>new ct({checks:[],coerce:t?.coerce||!1,typeName:k.ZodDate,...C(t)});Ot=class extends N{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.symbol,received:r.parsedType}),S}return K(e.data)}};Ot.create=t=>new Ot({typeName:k.ZodSymbol,...C(t)});dt=class extends N{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.undefined,received:r.parsedType}),S}return K(e.data)}};dt.create=t=>new dt({typeName:k.ZodUndefined,...C(t)});ut=class extends N{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.null,received:r.parsedType}),S}return K(e.data)}};ut.create=t=>new ut({typeName:k.ZodNull,...C(t)});We=class extends N{constructor(){super(...arguments),this._any=!0}_parse(e){return K(e.data)}};We.create=t=>new We({typeName:k.ZodAny,...C(t)});Ae=class extends N{constructor(){super(...arguments),this._unknown=!0}_parse(e){return K(e.data)}};Ae.create=t=>new Ae({typeName:k.ZodUnknown,...C(t)});he=class extends N{_parse(e){let n=this._getOrReturnCtx(e);return g(n,{code:f.invalid_type,expected:y.never,received:n.parsedType}),S}};he.create=t=>new he({typeName:k.ZodNever,...C(t)});Dt=class extends N{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.void,received:r.parsedType}),S}return K(e.data)}};Dt.create=t=>new Dt({typeName:k.ZodVoid,...C(t)});Ie=class t extends N{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==y.array)return g(n,{code:f.invalid_type,expected:y.array,received:n.parsedType}),S;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(g(n,{code:o?f.too_big:f.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(g(n,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(g(n,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new ce(n,o,n.path,a)))).then(o=>J.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new ce(n,o,n.path,a)));return J.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:v.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:v.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:v.toString(n)}})}nonempty(e){return this.min(1,e)}};Ie.create=(t,e)=>new Ie({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...C(e)});te=class t extends N{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=P.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let u=this._getOrReturnCtx(e);return g(u,{code:f.invalid_type,expected:y.object,received:u.parsedType}),S}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof he&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],p=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ce(s,p,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof he){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(g(s,{code:f.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let p=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ce(s,p,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let p=await l.key,m=await l.value;u.push({key:p,value:m,alwaysSet:l.alwaysSet})}return u}).then(u=>J.mergeObjectSync(r,u)):J.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:v.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of P.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of P.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Nt(this)}partial(e){let n={};for(let r of P.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of P.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ae;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return hi(P.objectKeys(this.shape))}};te.create=(t,e)=>new te({shape:()=>t,unknownKeys:"strip",catchall:he.create(),typeName:k.ZodObject,...C(e)});te.strictCreate=(t,e)=>new te({shape:()=>t,unknownKeys:"strict",catchall:he.create(),typeName:k.ZodObject,...C(e)});te.lazycreate=(t,e)=>new te({shape:t,unknownKeys:"strip",catchall:he.create(),typeName:k.ZodObject,...C(e)});lt=class extends N{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new ee(a.ctx.common.issues));return g(n,{code:f.invalid_union,unionErrors:o}),S}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of r){let u={...n,common:{...n.common,issues:[]},parent:null},l=c._parseSync({data:n.data,path:n.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new ee(c));return g(n,{code:f.invalid_union,unionErrors:a}),S}}get options(){return this._def.options}};lt.create=(t,e)=>new lt({options:t,typeName:k.ZodUnion,...C(e)});Re=t=>t instanceof ft?Re(t.schema):t instanceof de?Re(t.innerType()):t instanceof ht?[t.value]:t instanceof mt?t.options:t instanceof gt?P.objectValues(t.enum):t instanceof yt?Re(t._def.innerType):t instanceof dt?[void 0]:t instanceof ut?[null]:t instanceof ae?[void 0,...Re(t.unwrap())]:t instanceof xe?[null,...Re(t.unwrap())]:t instanceof en||t instanceof vt?Re(t.unwrap()):t instanceof bt?Re(t._def.innerType):[],qn=class t extends N{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return g(n,{code:f.invalid_type,expected:y.object,received:n.parsedType}),S;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(g(n,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=Re(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...C(r)})}};pt=class extends N{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Mn(i)||Mn(o))return S;let a=Mr(i.value,o.value);return a.valid?((Hn(i)||Hn(o))&&n.dirty(),{status:n.value,value:a.data}):(g(r,{code:f.invalid_intersection_types}),S)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};pt.create=(t,e,n)=>new pt({left:t,right:e,typeName:k.ZodIntersection,...C(n)});_e=class t extends N{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return g(r,{code:f.invalid_type,expected:y.array,received:r.parsedType}),S;if(r.data.length<this._def.items.length)return g(r,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new ce(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>J.mergeArray(n,o)):J.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};_e.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new _e({items:t,typeName:k.ZodTuple,rest:null,...C(e)})};Fn=class t extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return g(r,{code:f.invalid_type,expected:y.object,received:r.parsedType}),S;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new ce(r,a,r.path,a)),value:o._parse(new ce(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?J.mergeObjectAsync(n,s):J.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof N?new t({keyType:e,valueType:n,typeName:k.ZodRecord,...C(r)}):new t({keyType:Be.create(),valueType:e,typeName:k.ZodRecord,...C(n)})}},Pt=class extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return g(r,{code:f.invalid_type,expected:y.map,received:r.parsedType}),S;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],u)=>({key:s._parse(new ce(r,a,r.path,[u,"key"])),value:i._parse(new ce(r,c,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return S;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return S;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}}}};Pt.create=(t,e,n)=>new Pt({valueType:e,keyType:t,typeName:k.ZodMap,...C(n)});Lt=class t extends N{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return g(r,{code:f.invalid_type,expected:y.set,received:r.parsedType}),S;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(g(r,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(g(r,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return S;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((c,u)=>i._parse(new ce(r,c,r.path,u)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:v.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:v.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Lt.create=(t,e)=>new Lt({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...C(e)});Bn=class t extends N{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return g(n,{code:f.invalid_type,expected:y.function,received:n.parsedType}),S;function r(a,c){return Qt({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,It(),Te].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:c}})}function s(a,c){return Qt({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,It(),Te].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Ve){let a=this;return K(async function(...c){let u=new ee([]),l=await a._def.args.parseAsync(c,i).catch(w=>{throw u.addIssue(r(c,w)),u}),p=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(p,i).catch(w=>{throw u.addIssue(s(p,w)),u})})}else{let a=this;return K(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new ee([r(c,u.error)]);let l=Reflect.apply(o,this,u.data),p=a._def.returns.safeParse(l,i);if(!p.success)throw new ee([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:_e.create(e).rest(Ae.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||_e.create([]).rest(Ae.create()),returns:n||Ae.create(),typeName:k.ZodFunction,...C(r)})}},ft=class extends N{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};ft.create=(t,e)=>new ft({getter:t,typeName:k.ZodLazy,...C(e)});ht=class extends N{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return g(n,{received:n.data,code:f.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}};ht.create=(t,e)=>new ht({value:t,typeName:k.ZodLiteral,...C(e)});mt=class t extends N{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{expected:P.joinValues(r),received:n.parsedType,code:f.invalid_type}),S}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{received:n.data,code:f.invalid_enum_value,options:r}),S}return K(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};mt.create=hi;gt=class extends N{_parse(e){let n=P.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=P.objectValues(n);return g(r,{expected:P.joinValues(s),received:r.parsedType,code:f.invalid_type}),S}if(this._cache||(this._cache=new Set(P.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=P.objectValues(n);return g(r,{received:r.data,code:f.invalid_enum_value,options:s}),S}return K(e.data)}get enum(){return this._def.values}};gt.create=(t,e)=>new gt({values:t,typeName:k.ZodNativeEnum,...C(e)});Ve=class extends N{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return g(n,{code:f.invalid_type,expected:y.promise,received:n.parsedType}),S;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return K(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Ve.create=(t,e)=>new Ve({type:t,typeName:k.ZodPromise,...C(e)});de=class extends N{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{g(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return S;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?S:c.status==="dirty"?st(c.value):n.value==="dirty"?st(c.value):c});{if(n.value==="aborted")return S;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?S:a.status==="dirty"?st(a.value):n.value==="dirty"?st(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?S:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?S:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Fe(o))return S;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Fe(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):S);P.assertNever(s)}};de.create=(t,e,n)=>new de({schema:t,typeName:k.ZodEffects,effect:e,...C(n)});de.createWithPreprocess=(t,e,n)=>new de({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...C(n)});ae=class extends N{_parse(e){return this._getType(e)===y.undefined?K(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ae.create=(t,e)=>new ae({innerType:t,typeName:k.ZodOptional,...C(e)});xe=class extends N{_parse(e){return this._getType(e)===y.null?K(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xe.create=(t,e)=>new xe({innerType:t,typeName:k.ZodNullable,...C(e)});yt=class extends N{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};yt.create=(t,e)=>new yt({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...C(e)});bt=class extends N{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ct(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ee(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ee(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};bt.create=(t,e)=>new bt({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...C(e)});Ut=class extends N{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.nan,received:r.parsedType}),S}return{status:"valid",value:e.data}}};Ut.create=t=>new Ut({typeName:k.ZodNaN,...C(t)});$c=Symbol("zod_brand"),en=class extends N{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},tn=class t extends N{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?S:i.status==="dirty"?(n.dirty(),st(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?S:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:k.ZodPipeline})}},vt=class extends N{_parse(e){let n=this._def.innerType._parse(e),r=s=>(Fe(s)&&(s.value=Object.freeze(s.value)),s);return Ct(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};vt.create=(t,e)=>new vt({innerType:t,typeName:k.ZodReadonly,...C(e)});jc={object:te.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(k||(k={}));Mc=(t,e={message:`Input not instance of ${t.name}`})=>mi(n=>n instanceof t,e),gi=Be.create,yi=it.create,Hc=Ut.create,qc=ot.create,bi=at.create,Fc=ct.create,Bc=Ot.create,Wc=dt.create,Vc=ut.create,zc=We.create,Gc=Ae.create,Jc=he.create,Xc=Dt.create,Kc=Ie.create,Zc=te.create,Yc=te.strictCreate,Qc=lt.create,ed=qn.create,td=pt.create,nd=_e.create,rd=Fn.create,sd=Pt.create,id=Lt.create,od=Bn.create,ad=ft.create,cd=ht.create,dd=mt.create,ud=gt.create,ld=Ve.create,pd=de.create,fd=ae.create,hd=xe.create,md=de.createWithPreprocess,gd=tn.create,yd=()=>gi().optional(),bd=()=>yi().optional(),vd=()=>bi().optional(),Ed={string:t=>Be.create({...t,coerce:!0}),number:t=>it.create({...t,coerce:!0}),boolean:t=>at.create({...t,coerce:!0}),bigint:t=>ot.create({...t,coerce:!0}),date:t=>ct.create({...t,coerce:!0})},wd=S});var d={};Or(d,{BRAND:()=>$c,DIRTY:()=>st,EMPTY_PATH:()=>mc,INVALID:()=>S,NEVER:()=>wd,OK:()=>K,ParseStatus:()=>J,Schema:()=>N,ZodAny:()=>We,ZodArray:()=>Ie,ZodBigInt:()=>ot,ZodBoolean:()=>at,ZodBranded:()=>en,ZodCatch:()=>bt,ZodDate:()=>ct,ZodDefault:()=>yt,ZodDiscriminatedUnion:()=>qn,ZodEffects:()=>de,ZodEnum:()=>mt,ZodError:()=>ee,ZodFirstPartyTypeKind:()=>k,ZodFunction:()=>Bn,ZodIntersection:()=>pt,ZodIssueCode:()=>f,ZodLazy:()=>ft,ZodLiteral:()=>ht,ZodMap:()=>Pt,ZodNaN:()=>Ut,ZodNativeEnum:()=>gt,ZodNever:()=>he,ZodNull:()=>ut,ZodNullable:()=>xe,ZodNumber:()=>it,ZodObject:()=>te,ZodOptional:()=>ae,ZodParsedType:()=>y,ZodPipeline:()=>tn,ZodPromise:()=>Ve,ZodReadonly:()=>vt,ZodRecord:()=>Fn,ZodSchema:()=>N,ZodSet:()=>Lt,ZodString:()=>Be,ZodSymbol:()=>Ot,ZodTransformer:()=>de,ZodTuple:()=>_e,ZodType:()=>N,ZodUndefined:()=>dt,ZodUnion:()=>lt,ZodUnknown:()=>Ae,ZodVoid:()=>Dt,addIssueToContext:()=>g,any:()=>zc,array:()=>Kc,bigint:()=>qc,boolean:()=>bi,coerce:()=>Ed,custom:()=>mi,date:()=>Fc,datetimeRegex:()=>fi,defaultErrorMap:()=>Te,discriminatedUnion:()=>ed,effect:()=>pd,enum:()=>dd,function:()=>od,getErrorMap:()=>It,getParsedType:()=>we,instanceof:()=>Mc,intersection:()=>td,isAborted:()=>Mn,isAsync:()=>Ct,isDirty:()=>Hn,isValid:()=>Fe,late:()=>jc,lazy:()=>ad,literal:()=>cd,makeIssue:()=>Qt,map:()=>sd,nan:()=>Hc,nativeEnum:()=>ud,never:()=>Jc,null:()=>Vc,nullable:()=>hd,number:()=>yi,object:()=>Zc,objectUtil:()=>Lr,oboolean:()=>vd,onumber:()=>bd,optional:()=>fd,ostring:()=>yd,pipeline:()=>gd,preprocess:()=>md,promise:()=>ld,quotelessJson:()=>pc,record:()=>rd,set:()=>id,setErrorMap:()=>hc,strictObject:()=>Yc,string:()=>gi,symbol:()=>Bc,transformer:()=>pd,tuple:()=>nd,undefined:()=>Wc,union:()=>Qc,unknown:()=>Gc,util:()=>P,void:()=>Xc});var Hr=O(()=>{jn();$r();ai();Yt();vi();$n()});var me=O(()=>{Hr();Hr()});var ze,qr,Wn,ih,Fr,Br,_d,oh,Et=O(()=>{"use strict";me();ze=d.enum(["stable","preview"]),qr=d.object({schemaVersion:d.literal(1),status:d.enum(["applying","succeeded","failed","deferred"]),previousVersion:d.string(),targetVersion:d.string(),reason:d.string(),checkedAt:d.string()}),Wn=d.union([d.object({channel:ze}).strict(),d.object({autoUpdate:d.boolean()}).strict()]),ih=d.union([d.object({action:d.enum(["visit","check"])}).strict(),d.object({action:d.literal("install"),version:d.string().min(1).max(100)}).strict()]),Fr=d.object({channel:ze,currentVersion:d.string(),targetVersion:d.string().nullable(),checkedAt:d.string().datetime(),eligible:d.boolean(),error:d.boolean()}),Br=d.object({id:d.string().uuid(),channel:ze,currentVersion:d.string(),targetVersion:d.string(),automatic:d.boolean()}),_d=d.object({availability:d.enum(["available","not-installed","source-install","installation-mismatch","permission-required","authentication-required","unavailable"]),settings:d.object({channel:ze,autoUpdate:d.boolean(),independentExecutions:d.boolean().optional(),discovery:Fr.nullable(),pending:Br.nullable(),lastUpdate:qr.nullable()}).nullable()}),oh=d.union([d.object({ok:d.literal(!0),state:_d}),d.object({ok:d.literal(!1),error:d.enum(["busy","unavailable","save-failed","stale-update","update-failed"])})])});var xd,$t,Wr,Ei=O(()=>{me();xd=d.string().trim().min(1).max(4096).refine(t=>!/[\x00-\x1f\x7f]/.test(t),"Path contains control characters"),$t=d.array(xd).max(64),Wr=d.discriminatedUnion("action",[d.object({action:d.literal("set"),paths:$t}).strict(),d.object({action:d.literal("add"),paths:$t.min(1)}).strict(),d.object({action:d.literal("remove"),paths:$t.min(1)}).strict(),d.object({action:d.literal("reset")}).strict()])});var Vr,$,W,nn,Ge,zr,lh,ph,fh,hh,mh,gh,Sd,wi,_i,yh,bh,kd,vh,Eh,Td,Rd,wh,Ad,_h,xh,Sh,kh,Th,Id,Rh,Ah,Ih,xi,Ch,Nh,rn=O(()=>{me();Et();Ei();Vr=d.enum(["claude","codex"]),$=d.string(),W=$.min(1),nn={permission:$.optional(),model:$.optional(),effort:$.optional()},Ge=d.object({mediaType:$,data:$}),zr=d.array(Ge).optional(),lh=d.object({path:W,name:$.optional(),defaultBaseRef:$.optional()}),ph=d.object({repoId:W,agent:Vr,prompt:$,...nn,title:$.optional(),images:zr,isolate:d.boolean().optional()}),fh=d.object({prompt:$,images:zr,...nn}),hh=d.object({title:$.trim().min(1,"Enter a session name.").max(200,"Use 200 characters or fewer.").regex(/^[^\r\n]*$/,"Use a single line for the session name.")}),mh=d.object({text:$,images:zr,...nn}),gh=d.object({decision:d.enum(["approve","deny"]),scope:$.optional()}),Sd=d.object({questionId:W.optional(),question:$,selected:d.array($),notes:$.optional()}),wi=d.object({requestId:W,answers:d.array(Sd),response:$.optional()}),_i={preset:d.enum(["hourly","daily","weekly","weekdays","manual","custom"]).optional(),schedule:$.optional(),hour:d.number().int().min(0).max(23).optional(),dayOfWeek:d.number().int().min(0).max(6).optional()},yh=d.object({repoId:W,agent:Vr,prompt:W,..._i,...nn,title:$.optional()}),bh=d.object({prompt:W.optional(),..._i,...nn,title:$.optional(),enabled:d.boolean().optional()}),kd=d.object({endpoint:W,expirationTime:d.number().nullable().optional(),keys:d.record($).optional()}),vh=d.object({subscription:kd}),Eh=d.object({endpoint:W}),Td=d.object({agent:Vr,sessionId:W,cwd:W,home:W,waitPid:d.number().int().positive()}),Rd=d.enum(["queued","running","awaiting_approval","awaiting_input","idle","archived","failed","cancelled"]),wh=d.object({status:Rd.optional()}),Ad=d.coerce.number().int().min(1).max(Number.MAX_SAFE_INTEGER),_h=d.object({before:Ad}),xh=d.object({path:$.min(1).max(4096).regex(/^[^\u0000-\u001f\u007f]*$/)}),Sh=d.object({task:$.optional(),lastEventId:$.optional(),tail:d.literal("1").optional(),snapshots:d.literal("1").optional()}),kh=d.object({path:$.optional()}),Th=d.object({refresh:d.enum(["0","1"]).optional()}),Id=d.object({id:W}),Rh=Id.extend({messageId:W}),Ah=d.object({}),Ih=d.object({token:$.optional()}),xi={id:W,rawId:W,type:d.literal("public-key"),authenticatorAttachment:d.enum(["platform","cross-platform"]).optional(),clientExtensionResults:d.object({}).passthrough()},Ch=d.object({...xi,response:d.object({clientDataJSON:W,authenticatorData:W,signature:W,userHandle:$.optional()})}),Nh=d.object({response:d.object({...xi,response:d.object({clientDataJSON:W,attestationObject:W,transports:d.array(d.enum(["ble","cable","hybrid","internal","nfc","smart-card","usb"])).optional(),publicKeyAlgorithm:d.number().optional(),publicKey:$.optional(),authenticatorData:$.optional()})}),label:$.optional()})});var Cd,$h,jh,Si=O(()=>{me();rn();Cd=d.object({model:d.string().optional(),effort:d.string().optional(),permission:d.string().optional()}),$h=d.object({clientMessageId:d.string().uuid(),mode:d.enum(["send","queue"]),text:d.string().trim().min(1).max(1e5),images:d.array(Ge).optional(),expectedRunId:d.string().nullable(),settings:Cd.optional()}),jh=d.discriminatedUnion("action",[d.object({action:d.literal("edit"),version:d.number().int(),token:d.string().uuid()}),d.object({action:d.literal("renew"),token:d.string().uuid()}),d.object({action:d.literal("save"),token:d.string().uuid(),version:d.number().int(),text:d.string().trim().min(1).max(1e5),images:d.array(Ge).optional()}),d.object({action:d.literal("release"),token:d.string().uuid()}),d.object({action:d.literal("delete"),version:d.number().int()}),d.object({action:d.literal("send"),version:d.number().int(),expectedRunId:d.string().nullable()})])});var ne=O(()=>{"use strict";Qs();ei();ti();ni();ri();ii();Si()});var ss=O(()=>{});import{homedir as Ji}from"node:os";import{join as Eu}from"node:path";function wt(t){return t==="~"?Ji():t.startsWith("~/")?Eu(Ji(),t.slice(2)):t}var Qn=O(()=>{});import{homedir as wu}from"node:os";import{existsSync as Xi}from"node:fs";import{dirname as Qi,join as Ht,resolve as _t}from"node:path";import{fileURLToPath as _u}from"node:url";function Tu(t){let e={};for(let[n,r]of Object.entries(t))r!==void 0&&r!==""&&(e[n]=r);return e}var xu,Su,ku,U,eo,is,os,Ki,Zi,Yi,qt,ln=O(()=>{me();ne();Qn();xu=Qi(_u(import.meta.url)),Su=t=>t==="localhost"||t==="::1"||/^127(?:\.\d{1,3}){3}$/.test(t),ku=d.object({PORT:d.coerce.number().int().positive().default(4e3),HOST:d.string().min(1).refine(Su,"HOST must be loopback; terminate public HTTPS at the reverse proxy").default("localhost"),DISPATCH_CONCURRENCY:d.coerce.number().int().min(1).default(8),SSE_KEEPALIVE_MS:d.coerce.number().int().positive().default(15e3),AUTH_SESSION_TTL_MS:d.coerce.number().int().positive().default(30*24*60*60*1e3),AUTH_COOKIE_NAME:d.string().min(1).default("palmagent_session"),AUTH_RP_ID:d.string().min(1).regex(/^[A-Za-z0-9.-]+$/,"AUTH_RP_ID must be a hostname without a scheme, path, or port").optional(),AUTH_RP_NAME:d.string().min(1).optional(),AUTH_ORIGIN:d.string().url().startsWith("https://","AUTH_ORIGIN must use https://").optional(),AUTH_ENABLED:d.string().optional(),AUTH_DISABLED:d.string().optional(),PUSH_SUBJECT:d.string().regex(/^(mailto:|https:\/\/)/,"PUSH_SUBJECT must be a mailto: or https:// URL").optional(),DISPATCHER_DATA_DIR:d.string().min(1).optional(),XDG_STATE_HOME:d.string().min(1).optional(),DISPATCHER_DB:d.string().min(1).optional(),VAPID_KEY_PATH:d.string().min(1).optional(),STATIC_DIR:d.string().min(1).optional(),REPO_ROOTS:d.string().optional(),GITHUB_TOKEN:d.string().min(1).optional(),RUNNER_SOCKET:d.string().min(1).optional(),EXECUTION_RELEASE:d.string().min(1).optional(),EXECUTION_NODE:d.string().min(1).optional(),CLAUDE_MODEL:d.string().min(1).optional(),CODEX_MODEL:d.string().min(1).optional(),CLAUDE_EFFORT:d.string().min(1).optional(),CODEX_EFFORT:d.string().min(1).optional(),CLAUDE_CONFIG_DIR:d.string().min(1).optional(),NODE_ENV:d.string().optional()}).passthrough();U=ku.parse(Tu(process.env)),eo=U.AUTH_DISABLED==="1"?!1:U.AUTH_ENABLED==="1"?!0:U.NODE_ENV==="production",is=U.AUTH_RP_ID??(eo?"":"localhost"),os=U.DISPATCHER_DATA_DIR?_t(U.DISPATCHER_DATA_DIR):U.XDG_STATE_HOME?Ht(_t(U.XDG_STATE_HOME),_.stateDirName):Ht(wu(),".local","state",_.stateDirName),Ki=Ht(os,"palmagent.db"),Zi=Ht(os,"dispatcher.db"),Yi=U.DISPATCHER_DB?_t(U.DISPATCHER_DB):Xi(Ki)||!Xi(Zi)?Ki:Zi,qt={port:U.PORT,host:U.HOST,concurrency:U.DISPATCH_CONCURRENCY,dataDir:os,dbPath:Yi,keepAliveMs:U.SSE_KEEPALIVE_MS,claudeModel:U.CLAUDE_MODEL,codexModel:U.CODEX_MODEL,claudeEffort:U.CLAUDE_EFFORT,codexEffort:U.CODEX_EFFORT,claudeConfigDir:U.CLAUDE_CONFIG_DIR?_t(wt(U.CLAUDE_CONFIG_DIR)):void 0,vapidKeyPath:U.VAPID_KEY_PATH?_t(U.VAPID_KEY_PATH):Ht(Qi(Yi),"vapid.json"),pushSubject:U.PUSH_SUBJECT,staticDir:U.STATIC_DIR?_t(U.STATIC_DIR):Ht(xu,"..","..","web","dist"),repoRoots:(U.REPO_ROOTS??"").split(":").filter(Boolean).map(t=>_t(wt(t))),runnerSocket:U.RUNNER_SOCKET,executionRelease:U.EXECUTION_RELEASE,executionNode:U.EXECUTION_NODE,githubToken:U.GITHUB_TOKEN,authEnabled:eo,rpId:is,rpName:U.AUTH_RP_NAME??_.displayName,authOrigin:U.AUTH_ORIGIN??(is?`https://${is}`:""),sessionTtlMs:U.AUTH_SESSION_TTL_MS,cookieName:U.AUTH_COOKIE_NAME,nodeEnv:U.NODE_ENV}});var as=O(()=>{});import{createHash as Au}from"node:crypto";import{readFileSync as to,readdirSync as Oy,realpathSync as Dy,statSync as Py}from"node:fs";function cs(t){if(!Number.isSafeInteger(t)||t<=1)throw new Error("A valid local CLI process id is required");try{let e=to(`/proc/${t}/stat`,"utf8"),n=e.slice(e.lastIndexOf(")")+2).split(" ");return n[0]==="Z"?void 0:`${to("/proc/sys/kernel/random/boot_id","utf8").trim()}:${n[19]}`}catch(e){if(e.code==="ENOENT")return;throw new Error("Cannot verify the local CLI process; ownership is retained")}}var Iu,Cu,ds=O(()=>{ln();as();Iu=t=>Au("sha256").update(t).digest("hex");Cu=Iu(Buffer.alloc(0))});var no=O(()=>{});function Du({permission:t,model:e,effort:n,resumeId:r}){let s=["-p","--input-format","stream-json","--output-format","stream-json","--verbose","--include-partial-messages","--permission-mode",Ou(t),"--permission-prompt-tool","stdio"];return e&&s.push("--model",e),n&&s.push("--effort",n),r&&s.push("--resume",r),s}function Pu(t,e=[]){let n=e.map(r=>({type:"image",source:{type:"base64",media_type:r.mediaType,data:r.data}}));return n.push({type:"text",text:t}),{type:"user",message:{role:"user",content:n}}}var Nu,ro,Ou,er,so=O(()=>{ne();ln();Nu=1500,ro={plan:"plan",acceptEdits:"acceptEdits",dontAsk:"dontAsk",bypassPermissions:"bypassPermissions",readonly:"plan","auto-edit":"acceptEdits",full:"bypassPermissions"},Ou=t=>ro[t??""]??ro[Dr.claude];er=class{agent="claude";start(e,n,r){let{taskId:s,cwd:i,prompt:o,images:a,resumeId:c,permission:u,model:l,effort:p,reattach:m,resumeFromSeq:w,pendingInput:L}=e,x=Du({permission:u,model:l,effort:p,resumeId:c});e.interactive&&x.push("--replay-user-messages");let b=c,q=e.providerHome??qt.claudeConfigDir,be=q?{CLAUDE_CONFIG_DIR:q}:void 0,Z=m?r.attach(s,0):r.start({turnId:s,command:"claude",argv:x,cwd:i,env:be});if(!Z)return n({taskId:s,kind:"status",sessionId:b,payload:{subtype:"reattach_failed"}}),{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel:()=>{},done:Promise.resolve()};let E,V=H=>{E&&(clearTimeout(E.timer),E.resolve(H),E=void 0,A=!1)},T,A=!1,I,z,pe=!1,ve=0,Zt=new Map;m&&L&&Zt.set(L.requestId,{questions:L.questions});let nt=H=>Z.writeStdin(JSON.stringify(H)+`
2
+ var cc=Object.defineProperty;var O=(t,e)=>()=>(t&&(e=t(t=0)),e);var Or=(t,e)=>{for(var n in e)cc(t,n,{get:e[n],enumerable:!0})};var Qs=O(()=>{});function uc(t){let e=dc.exec(t);return e?{repo:e[1],number:Number(e[2])}:null}function Un(t){let e=uc(t);return e?{url:t,number:e.number,repo:e.repo,status:"open",checks:"unknown"}:null}var dc,ei=O(()=>{dc=/^https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)/});var Dr,ti=O(()=>{Dr={claude:"acceptEdits",codex:"workspace-write"}});var ni=O(()=>{});var _,ri=O(()=>{_={productName:"Palmagent",displayName:"PalmAgent",packageName:"palmagent",cliName:"palmagent",unitBase:"palmagent",stateDirName:"palmagent"}});var rt,Pr=O(()=>{rt={claude:{range:">=2.1.268 <2.2.0",minimum:"2.1.268",exclusiveMaximum:"2.2.0"},codex:{range:">=0.154.0 <0.155.0",minimum:"0.154.0",exclusiveMaximum:"0.155.0"}}});function si(t,e){let n=o=>/^\d+\.\d+\.\d+$/.test(o)?o.split(".").map(Number):void 0,r=n(e);if(!r)return!1;let s=o=>{let a=n(o);for(let c=0;c<3;c++)if(r[c]!==a[c])return r[c]-a[c];return 0},i=rt[t];return s(i.minimum)>=0&&s(i.exclusiveMaximum)<0}var ii=O(()=>{Pr();Pr()});var P,Lr,y,we,Yt=O(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.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)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(P||(P={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Lr||(Lr={}));y=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),we=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}}});var f,pc,ee,$n=O(()=>{Yt();f=P.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"]),pc=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ee=class t 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]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let 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(n(o));else{let a=r,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};ee.create=t=>new ee(t)});var fc,Te,Ur=O(()=>{$n();Yt();fc=(t,e)=>{let n;switch(t.code){case f.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,P.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:n=`Unrecognized key(s) in object: ${P.joinValues(t.keys,", ")}`;break;case f.invalid_union:n="Invalid input";break;case f.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${P.joinValues(t.options)}`;break;case f.invalid_enum_value:n=`Invalid enum value. Expected ${P.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:n="Invalid function arguments";break;case f.invalid_return_type:n="Invalid function return type";break;case f.invalid_date:n="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:P.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case f.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case f.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case f.custom:n="Invalid input";break;case f.invalid_intersection_types:n="Intersection results could not be merged";break;case f.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:n="Number must be finite";break;default:n=e.defaultError,P.assertNever(t)}return{message:n}},Te=fc});function hc(t){oi=t}function It(){return oi}var oi,jn=O(()=>{Ur();oi=Te});function g(t,e){let n=It(),r=Qt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Te?void 0:Te].filter(s=>!!s)});t.common.issues.push(r)}var Qt,mc,J,S,st,K,Mn,Hn,Fe,Ct,$r=O(()=>{jn();Ur();Qt=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},mc=[];J=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return S;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return S;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}}},S=Object.freeze({status:"aborted"}),st=t=>({status:"dirty",value:t}),K=t=>({status:"valid",value:t}),Mn=t=>t.status==="aborted",Hn=t=>t.status==="dirty",Fe=t=>t.status==="valid",Ct=t=>typeof Promise<"u"&&t instanceof Promise});var ai=O(()=>{});var v,ci=O(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(v||(v={}))});function C(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||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)=>{let{message:c}=t;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??n??a.defaultError}},description:s}}function pi(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Oc(t){return new RegExp(`^${pi(t)}$`)}function fi(t){let e=`${li}T${pi(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Dc(t,e){return!!((e==="v4"||!e)&&kc.test(t)||(e==="v6"||!e)&&Rc.test(t))}function Pc(t,e){if(!wc.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Lc(t,e){return!!((e==="v4"||!e)&&Tc.test(t)||(e==="v6"||!e)&&Ac.test(t))}function Uc(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function Nt(t){if(t instanceof te){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=ae.create(Nt(r))}return new te({...t._def,shape:()=>e})}else return t instanceof Ie?new Ie({...t._def,type:Nt(t.element)}):t instanceof ae?ae.create(Nt(t.unwrap())):t instanceof xe?xe.create(Nt(t.unwrap())):t instanceof _e?_e.create(t.items.map(e=>Nt(e))):t}function Mr(t,e){let n=we(t),r=we(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=P.objectKeys(e),i=P.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Mr(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Mr(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function hi(t,e){return new mt({values:t,typeName:k.ZodEnum,...C(e)})}function ui(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function mi(t,e={},n){return t?We.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=ui(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=ui(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):We.create()}var ce,di,N,gc,yc,bc,vc,Ec,wc,_c,xc,Sc,jr,kc,Tc,Rc,Ac,Ic,Cc,li,Nc,Be,it,ot,at,ct,Ot,dt,ut,We,Ae,he,Dt,Ie,te,lt,Re,qn,pt,_e,Fn,Pt,Lt,Bn,ft,ht,mt,gt,Ve,de,ae,xe,yt,bt,Ut,$c,en,tn,vt,jc,k,Mc,gi,yi,Hc,qc,bi,Fc,Bc,Wc,Vc,zc,Gc,Jc,Xc,Kc,Zc,Yc,Qc,ed,td,nd,rd,sd,id,od,ad,cd,dd,ud,ld,pd,fd,hd,md,gd,yd,bd,vd,Ed,wd,vi=O(()=>{$n();jn();ci();$r();Yt();ce=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,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}},di=(t,e)=>{if(Fe(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new ee(t.common.issues);return this._error=n,this._error}}};N=class{get description(){return this._def.description}_getType(e){return we(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:we(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new J,ctx:{common:e.parent.common,data:e.data,parsedType:we(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Ct(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:we(e)},s=this._parseSync({data:e,path:r.path,parent:r});return di(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:we(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Fe(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Fe(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:we(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ct(s)?s:Promise.resolve(s));return di(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:f.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new de({schema:this,typeName:k.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:n=>this["~validate"](n)}}optional(){return ae.create(this,this._def)}nullable(){return xe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ie.create(this)}promise(){return Ve.create(this,this._def)}or(e){return lt.create([this,e],this._def)}and(e){return pt.create(this,e,this._def)}transform(e){return new de({...C(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new yt({...C(this._def),innerType:this,defaultValue:n,typeName:k.ZodDefault})}brand(){return new en({typeName:k.ZodBranded,type:this,...C(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new bt({...C(this._def),innerType:this,catchValue:n,typeName:k.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return tn.create(this,e)}readonly(){return vt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},gc=/^c[^\s-]{8,}$/i,yc=/^[0-9a-z]+$/,bc=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vc=/^[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,Ec=/^[a-z0-9_-]{21}$/i,wc=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_c=/^[-+]?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)?)??$/,xc=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Sc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",kc=/^(?:(?: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])$/,Tc=/^(?:(?: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])$/,Rc=/^(([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]))$/,Ac=/^(([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])$/,Ic=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Cc=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,li="((\\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])))",Nc=new RegExp(`^${li}$`);Be=class t extends N{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let i=this._getOrReturnCtx(e);return g(i,{code:f.invalid_type,expected:y.string,received:i.parsedType}),S}let r=new J,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:f.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),g(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?g(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&g(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")xc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"email",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")jr||(jr=new RegExp(Sc,"u")),jr.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"emoji",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")vc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"uuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Ec.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"nanoid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")gc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")yc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid2",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")bc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ulid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),g(s,{validation:"url",code:f.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),g(s,{validation:"regex",code:f.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),g(s,{code:f.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),g(s,{code:f.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:f.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?fi(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:f.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Nc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:f.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Oc(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:f.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?_c.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"duration",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Dc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ip",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Pc(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"jwt",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Lc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cidr",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Ic.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Cc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64url",code:f.invalid_string,message:i.message}),r.dirty()):P.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:f.invalid_string,...v.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.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?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...v.errToObj(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?.precision>"u"?null:e?.precision,...v.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...v.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...v.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...v.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...v.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...v.errToObj(n)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Be.create=t=>new Be({checks:[],typeName:k.ZodString,coerce:t?.coerce??!1,...C(t)});it=class t extends N{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)!==y.number){let i=this._getOrReturnCtx(e);return g(i,{code:f.invalid_type,expected:y.number,received:i.parsedType}),S}let r,s=new J;for(let i of this._def.checks)i.kind==="int"?P.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:f.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),g(r,{code:f.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),g(r,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Uc(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_finite,message:i.message}),s.dirty()):P.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,v.toString(n))}gt(e,n){return this.setLimit("min",e,!1,v.toString(n))}lte(e,n){return this.setLimit("max",e,!0,v.toString(n))}lt(e,n){return this.setLimit("max",e,!1,v.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&P.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};it.create=t=>new it({checks:[],typeName:k.ZodNumber,coerce:t?.coerce||!1,...C(t)});ot=class t extends N{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)!==y.bigint)return this._getInvalidInput(e);let r,s=new J;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.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),g(r,{code:f.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),g(r,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):P.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return g(n,{code:f.invalid_type,expected:y.bigint,received:n.parsedType}),S}gte(e,n){return this.setLimit("min",e,!0,v.toString(n))}gt(e,n){return this.setLimit("min",e,!1,v.toString(n))}lte(e,n){return this.setLimit("max",e,!0,v.toString(n))}lt(e,n){return this.setLimit("max",e,!1,v.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ot.create=t=>new ot({checks:[],typeName:k.ZodBigInt,coerce:t?.coerce??!1,...C(t)});at=class extends N{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.boolean,received:r.parsedType}),S}return K(e.data)}};at.create=t=>new at({typeName:k.ZodBoolean,coerce:t?.coerce||!1,...C(t)});ct=class t extends N{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let i=this._getOrReturnCtx(e);return g(i,{code:f.invalid_type,expected:y.date,received:i.parsedType}),S}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return g(i,{code:f.invalid_date}),S}let r=new J,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:f.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),g(s,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):P.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};ct.create=t=>new ct({checks:[],coerce:t?.coerce||!1,typeName:k.ZodDate,...C(t)});Ot=class extends N{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.symbol,received:r.parsedType}),S}return K(e.data)}};Ot.create=t=>new Ot({typeName:k.ZodSymbol,...C(t)});dt=class extends N{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.undefined,received:r.parsedType}),S}return K(e.data)}};dt.create=t=>new dt({typeName:k.ZodUndefined,...C(t)});ut=class extends N{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.null,received:r.parsedType}),S}return K(e.data)}};ut.create=t=>new ut({typeName:k.ZodNull,...C(t)});We=class extends N{constructor(){super(...arguments),this._any=!0}_parse(e){return K(e.data)}};We.create=t=>new We({typeName:k.ZodAny,...C(t)});Ae=class extends N{constructor(){super(...arguments),this._unknown=!0}_parse(e){return K(e.data)}};Ae.create=t=>new Ae({typeName:k.ZodUnknown,...C(t)});he=class extends N{_parse(e){let n=this._getOrReturnCtx(e);return g(n,{code:f.invalid_type,expected:y.never,received:n.parsedType}),S}};he.create=t=>new he({typeName:k.ZodNever,...C(t)});Dt=class extends N{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.void,received:r.parsedType}),S}return K(e.data)}};Dt.create=t=>new Dt({typeName:k.ZodVoid,...C(t)});Ie=class t extends N{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==y.array)return g(n,{code:f.invalid_type,expected:y.array,received:n.parsedType}),S;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(g(n,{code:o?f.too_big:f.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(g(n,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(g(n,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new ce(n,o,n.path,a)))).then(o=>J.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new ce(n,o,n.path,a)));return J.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:v.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:v.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:v.toString(n)}})}nonempty(e){return this.min(1,e)}};Ie.create=(t,e)=>new Ie({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...C(e)});te=class t extends N{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=P.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let u=this._getOrReturnCtx(e);return g(u,{code:f.invalid_type,expected:y.object,received:u.parsedType}),S}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof he&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],p=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ce(s,p,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof he){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(g(s,{code:f.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let p=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ce(s,p,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let p=await l.key,m=await l.value;u.push({key:p,value:m,alwaysSet:l.alwaysSet})}return u}).then(u=>J.mergeObjectSync(r,u)):J.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:v.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of P.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of P.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Nt(this)}partial(e){let n={};for(let r of P.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of P.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ae;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return hi(P.objectKeys(this.shape))}};te.create=(t,e)=>new te({shape:()=>t,unknownKeys:"strip",catchall:he.create(),typeName:k.ZodObject,...C(e)});te.strictCreate=(t,e)=>new te({shape:()=>t,unknownKeys:"strict",catchall:he.create(),typeName:k.ZodObject,...C(e)});te.lazycreate=(t,e)=>new te({shape:t,unknownKeys:"strip",catchall:he.create(),typeName:k.ZodObject,...C(e)});lt=class extends N{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new ee(a.ctx.common.issues));return g(n,{code:f.invalid_union,unionErrors:o}),S}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of r){let u={...n,common:{...n.common,issues:[]},parent:null},l=c._parseSync({data:n.data,path:n.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new ee(c));return g(n,{code:f.invalid_union,unionErrors:a}),S}}get options(){return this._def.options}};lt.create=(t,e)=>new lt({options:t,typeName:k.ZodUnion,...C(e)});Re=t=>t instanceof ft?Re(t.schema):t instanceof de?Re(t.innerType()):t instanceof ht?[t.value]:t instanceof mt?t.options:t instanceof gt?P.objectValues(t.enum):t instanceof yt?Re(t._def.innerType):t instanceof dt?[void 0]:t instanceof ut?[null]:t instanceof ae?[void 0,...Re(t.unwrap())]:t instanceof xe?[null,...Re(t.unwrap())]:t instanceof en||t instanceof vt?Re(t.unwrap()):t instanceof bt?Re(t._def.innerType):[],qn=class t extends N{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return g(n,{code:f.invalid_type,expected:y.object,received:n.parsedType}),S;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(g(n,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=Re(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...C(r)})}};pt=class extends N{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Mn(i)||Mn(o))return S;let a=Mr(i.value,o.value);return a.valid?((Hn(i)||Hn(o))&&n.dirty(),{status:n.value,value:a.data}):(g(r,{code:f.invalid_intersection_types}),S)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};pt.create=(t,e,n)=>new pt({left:t,right:e,typeName:k.ZodIntersection,...C(n)});_e=class t extends N{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return g(r,{code:f.invalid_type,expected:y.array,received:r.parsedType}),S;if(r.data.length<this._def.items.length)return g(r,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new ce(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>J.mergeArray(n,o)):J.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};_e.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new _e({items:t,typeName:k.ZodTuple,rest:null,...C(e)})};Fn=class t extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return g(r,{code:f.invalid_type,expected:y.object,received:r.parsedType}),S;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new ce(r,a,r.path,a)),value:o._parse(new ce(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?J.mergeObjectAsync(n,s):J.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof N?new t({keyType:e,valueType:n,typeName:k.ZodRecord,...C(r)}):new t({keyType:Be.create(),valueType:e,typeName:k.ZodRecord,...C(n)})}},Pt=class extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return g(r,{code:f.invalid_type,expected:y.map,received:r.parsedType}),S;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],u)=>({key:s._parse(new ce(r,a,r.path,[u,"key"])),value:i._parse(new ce(r,c,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return S;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return S;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}}}};Pt.create=(t,e,n)=>new Pt({valueType:e,keyType:t,typeName:k.ZodMap,...C(n)});Lt=class t extends N{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return g(r,{code:f.invalid_type,expected:y.set,received:r.parsedType}),S;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(g(r,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(g(r,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return S;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((c,u)=>i._parse(new ce(r,c,r.path,u)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:v.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:v.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Lt.create=(t,e)=>new Lt({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...C(e)});Bn=class t extends N{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return g(n,{code:f.invalid_type,expected:y.function,received:n.parsedType}),S;function r(a,c){return Qt({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,It(),Te].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:c}})}function s(a,c){return Qt({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,It(),Te].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Ve){let a=this;return K(async function(...c){let u=new ee([]),l=await a._def.args.parseAsync(c,i).catch(w=>{throw u.addIssue(r(c,w)),u}),p=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(p,i).catch(w=>{throw u.addIssue(s(p,w)),u})})}else{let a=this;return K(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new ee([r(c,u.error)]);let l=Reflect.apply(o,this,u.data),p=a._def.returns.safeParse(l,i);if(!p.success)throw new ee([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:_e.create(e).rest(Ae.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||_e.create([]).rest(Ae.create()),returns:n||Ae.create(),typeName:k.ZodFunction,...C(r)})}},ft=class extends N{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};ft.create=(t,e)=>new ft({getter:t,typeName:k.ZodLazy,...C(e)});ht=class extends N{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return g(n,{received:n.data,code:f.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}};ht.create=(t,e)=>new ht({value:t,typeName:k.ZodLiteral,...C(e)});mt=class t extends N{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{expected:P.joinValues(r),received:n.parsedType,code:f.invalid_type}),S}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{received:n.data,code:f.invalid_enum_value,options:r}),S}return K(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};mt.create=hi;gt=class extends N{_parse(e){let n=P.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=P.objectValues(n);return g(r,{expected:P.joinValues(s),received:r.parsedType,code:f.invalid_type}),S}if(this._cache||(this._cache=new Set(P.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=P.objectValues(n);return g(r,{received:r.data,code:f.invalid_enum_value,options:s}),S}return K(e.data)}get enum(){return this._def.values}};gt.create=(t,e)=>new gt({values:t,typeName:k.ZodNativeEnum,...C(e)});Ve=class extends N{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return g(n,{code:f.invalid_type,expected:y.promise,received:n.parsedType}),S;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return K(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Ve.create=(t,e)=>new Ve({type:t,typeName:k.ZodPromise,...C(e)});de=class extends N{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{g(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return S;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?S:c.status==="dirty"?st(c.value):n.value==="dirty"?st(c.value):c});{if(n.value==="aborted")return S;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?S:a.status==="dirty"?st(a.value):n.value==="dirty"?st(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?S:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?S:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Fe(o))return S;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Fe(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):S);P.assertNever(s)}};de.create=(t,e,n)=>new de({schema:t,typeName:k.ZodEffects,effect:e,...C(n)});de.createWithPreprocess=(t,e,n)=>new de({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...C(n)});ae=class extends N{_parse(e){return this._getType(e)===y.undefined?K(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ae.create=(t,e)=>new ae({innerType:t,typeName:k.ZodOptional,...C(e)});xe=class extends N{_parse(e){return this._getType(e)===y.null?K(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xe.create=(t,e)=>new xe({innerType:t,typeName:k.ZodNullable,...C(e)});yt=class extends N{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};yt.create=(t,e)=>new yt({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...C(e)});bt=class extends N{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ct(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ee(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ee(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};bt.create=(t,e)=>new bt({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...C(e)});Ut=class extends N{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.nan,received:r.parsedType}),S}return{status:"valid",value:e.data}}};Ut.create=t=>new Ut({typeName:k.ZodNaN,...C(t)});$c=Symbol("zod_brand"),en=class extends N{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},tn=class t extends N{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?S:i.status==="dirty"?(n.dirty(),st(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?S:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:k.ZodPipeline})}},vt=class extends N{_parse(e){let n=this._def.innerType._parse(e),r=s=>(Fe(s)&&(s.value=Object.freeze(s.value)),s);return Ct(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};vt.create=(t,e)=>new vt({innerType:t,typeName:k.ZodReadonly,...C(e)});jc={object:te.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(k||(k={}));Mc=(t,e={message:`Input not instance of ${t.name}`})=>mi(n=>n instanceof t,e),gi=Be.create,yi=it.create,Hc=Ut.create,qc=ot.create,bi=at.create,Fc=ct.create,Bc=Ot.create,Wc=dt.create,Vc=ut.create,zc=We.create,Gc=Ae.create,Jc=he.create,Xc=Dt.create,Kc=Ie.create,Zc=te.create,Yc=te.strictCreate,Qc=lt.create,ed=qn.create,td=pt.create,nd=_e.create,rd=Fn.create,sd=Pt.create,id=Lt.create,od=Bn.create,ad=ft.create,cd=ht.create,dd=mt.create,ud=gt.create,ld=Ve.create,pd=de.create,fd=ae.create,hd=xe.create,md=de.createWithPreprocess,gd=tn.create,yd=()=>gi().optional(),bd=()=>yi().optional(),vd=()=>bi().optional(),Ed={string:t=>Be.create({...t,coerce:!0}),number:t=>it.create({...t,coerce:!0}),boolean:t=>at.create({...t,coerce:!0}),bigint:t=>ot.create({...t,coerce:!0}),date:t=>ct.create({...t,coerce:!0})},wd=S});var d={};Or(d,{BRAND:()=>$c,DIRTY:()=>st,EMPTY_PATH:()=>mc,INVALID:()=>S,NEVER:()=>wd,OK:()=>K,ParseStatus:()=>J,Schema:()=>N,ZodAny:()=>We,ZodArray:()=>Ie,ZodBigInt:()=>ot,ZodBoolean:()=>at,ZodBranded:()=>en,ZodCatch:()=>bt,ZodDate:()=>ct,ZodDefault:()=>yt,ZodDiscriminatedUnion:()=>qn,ZodEffects:()=>de,ZodEnum:()=>mt,ZodError:()=>ee,ZodFirstPartyTypeKind:()=>k,ZodFunction:()=>Bn,ZodIntersection:()=>pt,ZodIssueCode:()=>f,ZodLazy:()=>ft,ZodLiteral:()=>ht,ZodMap:()=>Pt,ZodNaN:()=>Ut,ZodNativeEnum:()=>gt,ZodNever:()=>he,ZodNull:()=>ut,ZodNullable:()=>xe,ZodNumber:()=>it,ZodObject:()=>te,ZodOptional:()=>ae,ZodParsedType:()=>y,ZodPipeline:()=>tn,ZodPromise:()=>Ve,ZodReadonly:()=>vt,ZodRecord:()=>Fn,ZodSchema:()=>N,ZodSet:()=>Lt,ZodString:()=>Be,ZodSymbol:()=>Ot,ZodTransformer:()=>de,ZodTuple:()=>_e,ZodType:()=>N,ZodUndefined:()=>dt,ZodUnion:()=>lt,ZodUnknown:()=>Ae,ZodVoid:()=>Dt,addIssueToContext:()=>g,any:()=>zc,array:()=>Kc,bigint:()=>qc,boolean:()=>bi,coerce:()=>Ed,custom:()=>mi,date:()=>Fc,datetimeRegex:()=>fi,defaultErrorMap:()=>Te,discriminatedUnion:()=>ed,effect:()=>pd,enum:()=>dd,function:()=>od,getErrorMap:()=>It,getParsedType:()=>we,instanceof:()=>Mc,intersection:()=>td,isAborted:()=>Mn,isAsync:()=>Ct,isDirty:()=>Hn,isValid:()=>Fe,late:()=>jc,lazy:()=>ad,literal:()=>cd,makeIssue:()=>Qt,map:()=>sd,nan:()=>Hc,nativeEnum:()=>ud,never:()=>Jc,null:()=>Vc,nullable:()=>hd,number:()=>yi,object:()=>Zc,objectUtil:()=>Lr,oboolean:()=>vd,onumber:()=>bd,optional:()=>fd,ostring:()=>yd,pipeline:()=>gd,preprocess:()=>md,promise:()=>ld,quotelessJson:()=>pc,record:()=>rd,set:()=>id,setErrorMap:()=>hc,strictObject:()=>Yc,string:()=>gi,symbol:()=>Bc,transformer:()=>pd,tuple:()=>nd,undefined:()=>Wc,union:()=>Qc,unknown:()=>Gc,util:()=>P,void:()=>Xc});var Hr=O(()=>{jn();$r();ai();Yt();vi();$n()});var me=O(()=>{Hr();Hr()});var ze,qr,Wn,ih,Fr,Br,_d,oh,Et=O(()=>{"use strict";me();ze=d.enum(["stable","preview"]),qr=d.object({schemaVersion:d.literal(1),status:d.enum(["applying","succeeded","failed","deferred"]),previousVersion:d.string(),targetVersion:d.string(),reason:d.string(),checkedAt:d.string()}),Wn=d.union([d.object({channel:ze}).strict(),d.object({autoUpdate:d.boolean()}).strict()]),ih=d.union([d.object({action:d.enum(["visit","check"])}).strict(),d.object({action:d.literal("install"),version:d.string().min(1).max(100)}).strict()]),Fr=d.object({channel:ze,currentVersion:d.string(),targetVersion:d.string().nullable(),checkedAt:d.string().datetime(),eligible:d.boolean(),error:d.boolean()}),Br=d.object({id:d.string().uuid(),channel:ze,currentVersion:d.string(),targetVersion:d.string(),automatic:d.boolean()}),_d=d.object({availability:d.enum(["available","not-installed","source-install","installation-mismatch","permission-required","authentication-required","unavailable"]),settings:d.object({channel:ze,autoUpdate:d.boolean(),independentExecutions:d.boolean().optional(),discovery:Fr.nullable(),pending:Br.nullable(),lastUpdate:qr.nullable()}).nullable()}),oh=d.union([d.object({ok:d.literal(!0),state:_d}),d.object({ok:d.literal(!1),error:d.enum(["busy","unavailable","save-failed","stale-update","update-failed"])})])});var xd,$t,Wr,Ei=O(()=>{me();xd=d.string().trim().min(1).max(4096).refine(t=>!/[\x00-\x1f\x7f]/.test(t),"Path contains control characters"),$t=d.array(xd).max(64),Wr=d.discriminatedUnion("action",[d.object({action:d.literal("set"),paths:$t}).strict(),d.object({action:d.literal("add"),paths:$t.min(1)}).strict(),d.object({action:d.literal("remove"),paths:$t.min(1)}).strict(),d.object({action:d.literal("reset")}).strict()])});var Vr,$,W,nn,Ge,zr,lh,ph,fh,hh,mh,gh,Sd,wi,_i,yh,bh,kd,vh,Eh,Td,Rd,wh,Ad,_h,xh,Sh,kh,Th,Id,Rh,Ah,Ih,xi,Ch,Nh,rn=O(()=>{"use strict";me();Et();Ei();Vr=d.enum(["claude","codex"]),$=d.string(),W=$.min(1),nn={permission:$.optional(),model:$.optional(),effort:$.optional()},Ge=d.object({mediaType:$,data:$}),zr=d.array(Ge).optional(),lh=d.object({path:W,name:$.optional(),defaultBaseRef:$.optional()}),ph=d.object({repoId:W,agent:Vr,prompt:$,...nn,title:$.optional(),images:zr,isolate:d.boolean().optional()}),fh=d.object({prompt:$,images:zr,...nn}),hh=d.object({title:$.trim().min(1,"Enter a session name.").max(200,"Use 200 characters or fewer.").regex(/^[^\r\n]*$/,"Use a single line for the session name.")}),mh=d.object({text:$,images:zr,...nn}),gh=d.object({decision:d.enum(["approve","deny"]),scope:$.optional()}),Sd=d.object({questionId:W.optional(),question:$,selected:d.array($),notes:$.optional()}),wi=d.object({requestId:W,answers:d.array(Sd),response:$.optional()}),_i={preset:d.enum(["hourly","daily","weekly","weekdays","manual","custom"]).optional(),schedule:$.optional(),hour:d.number().int().min(0).max(23).optional(),dayOfWeek:d.number().int().min(0).max(6).optional()},yh=d.object({repoId:W,agent:Vr,prompt:W,..._i,...nn,title:$.optional()}),bh=d.object({prompt:W.optional(),..._i,...nn,title:$.optional(),enabled:d.boolean().optional()}),kd=d.object({endpoint:W,expirationTime:d.number().nullable().optional(),keys:d.record($).optional()}),vh=d.object({subscription:kd}),Eh=d.object({endpoint:W}),Td=d.object({agent:Vr,sessionId:W,cwd:W,home:W,waitPid:d.number().int().positive()}),Rd=d.enum(["queued","running","awaiting_approval","awaiting_input","idle","archived","failed","cancelled"]),wh=d.object({status:Rd.optional()}),Ad=d.coerce.number().int().min(1).max(Number.MAX_SAFE_INTEGER),_h=d.object({before:Ad}),xh=d.object({path:$.min(1).max(4096).regex(/^[^\u0000-\u001f\u007f]*$/)}),Sh=d.object({task:$.optional(),lastEventId:$.optional(),tail:d.literal("1").optional(),snapshots:d.literal("1").optional()}),kh=d.object({path:$.optional()}),Th=d.object({refresh:d.enum(["0","1"]).optional()}),Id=d.object({id:W}),Rh=Id.extend({messageId:W}),Ah=d.object({}),Ih=d.object({token:$.optional()}),xi={id:W,rawId:W,type:d.literal("public-key"),authenticatorAttachment:d.enum(["platform","cross-platform"]).optional(),clientExtensionResults:d.object({}).passthrough()},Ch=d.object({...xi,response:d.object({clientDataJSON:W,authenticatorData:W,signature:W,userHandle:$.optional()})}),Nh=d.object({response:d.object({...xi,response:d.object({clientDataJSON:W,attestationObject:W,transports:d.array(d.enum(["ble","cable","hybrid","internal","nfc","smart-card","usb"])).optional(),publicKeyAlgorithm:d.number().optional(),publicKey:$.optional(),authenticatorData:$.optional()})}),label:$.optional()})});var Cd,$h,jh,Si=O(()=>{me();rn();Cd=d.object({model:d.string().optional(),effort:d.string().optional(),permission:d.string().optional()}),$h=d.object({clientMessageId:d.string().uuid(),mode:d.enum(["send","queue"]),text:d.string().trim().min(1).max(1e5),images:d.array(Ge).optional(),expectedRunId:d.string().nullable(),settings:Cd.optional()}),jh=d.discriminatedUnion("action",[d.object({action:d.literal("edit"),version:d.number().int(),token:d.string().uuid()}),d.object({action:d.literal("renew"),token:d.string().uuid()}),d.object({action:d.literal("save"),token:d.string().uuid(),version:d.number().int(),text:d.string().trim().min(1).max(1e5),images:d.array(Ge).optional()}),d.object({action:d.literal("release"),token:d.string().uuid()}),d.object({action:d.literal("delete"),version:d.number().int()}),d.object({action:d.literal("send"),version:d.number().int(),expectedRunId:d.string().nullable()})])});var ne=O(()=>{"use strict";Qs();ei();ti();ni();ri();ii();Si()});var ss=O(()=>{});import{homedir as Ji}from"node:os";import{join as Eu}from"node:path";function wt(t){return t==="~"?Ji():t.startsWith("~/")?Eu(Ji(),t.slice(2)):t}var Qn=O(()=>{});import{homedir as wu}from"node:os";import{existsSync as Xi}from"node:fs";import{dirname as Qi,join as Ht,resolve as _t}from"node:path";import{fileURLToPath as _u}from"node:url";function Tu(t){let e={};for(let[n,r]of Object.entries(t))r!==void 0&&r!==""&&(e[n]=r);return e}var xu,Su,ku,U,eo,is,os,Ki,Zi,Yi,qt,ln=O(()=>{me();ne();Qn();xu=Qi(_u(import.meta.url)),Su=t=>t==="localhost"||t==="::1"||/^127(?:\.\d{1,3}){3}$/.test(t),ku=d.object({PORT:d.coerce.number().int().positive().default(4e3),HOST:d.string().min(1).refine(Su,"HOST must be loopback; terminate public HTTPS at the reverse proxy").default("localhost"),DISPATCH_CONCURRENCY:d.coerce.number().int().min(1).default(8),SSE_KEEPALIVE_MS:d.coerce.number().int().positive().default(15e3),AUTH_SESSION_TTL_MS:d.coerce.number().int().positive().default(30*24*60*60*1e3),AUTH_COOKIE_NAME:d.string().min(1).default("palmagent_session"),AUTH_RP_ID:d.string().min(1).regex(/^[A-Za-z0-9.-]+$/,"AUTH_RP_ID must be a hostname without a scheme, path, or port").optional(),AUTH_RP_NAME:d.string().min(1).optional(),AUTH_ORIGIN:d.string().url().startsWith("https://","AUTH_ORIGIN must use https://").optional(),AUTH_ENABLED:d.string().optional(),AUTH_DISABLED:d.string().optional(),PUSH_SUBJECT:d.string().regex(/^(mailto:|https:\/\/)/,"PUSH_SUBJECT must be a mailto: or https:// URL").optional(),DISPATCHER_DATA_DIR:d.string().min(1).optional(),XDG_STATE_HOME:d.string().min(1).optional(),DISPATCHER_DB:d.string().min(1).optional(),VAPID_KEY_PATH:d.string().min(1).optional(),STATIC_DIR:d.string().min(1).optional(),REPO_ROOTS:d.string().optional(),GITHUB_TOKEN:d.string().min(1).optional(),RUNNER_SOCKET:d.string().min(1).optional(),EXECUTION_RELEASE:d.string().min(1).optional(),EXECUTION_NODE:d.string().min(1).optional(),CLAUDE_MODEL:d.string().min(1).optional(),CODEX_MODEL:d.string().min(1).optional(),CLAUDE_EFFORT:d.string().min(1).optional(),CODEX_EFFORT:d.string().min(1).optional(),CLAUDE_CONFIG_DIR:d.string().min(1).optional(),NODE_ENV:d.string().optional()}).passthrough();U=ku.parse(Tu(process.env)),eo=U.AUTH_DISABLED==="1"?!1:U.AUTH_ENABLED==="1"?!0:U.NODE_ENV==="production",is=U.AUTH_RP_ID??(eo?"":"localhost"),os=U.DISPATCHER_DATA_DIR?_t(U.DISPATCHER_DATA_DIR):U.XDG_STATE_HOME?Ht(_t(U.XDG_STATE_HOME),_.stateDirName):Ht(wu(),".local","state",_.stateDirName),Ki=Ht(os,"palmagent.db"),Zi=Ht(os,"dispatcher.db"),Yi=U.DISPATCHER_DB?_t(U.DISPATCHER_DB):Xi(Ki)||!Xi(Zi)?Ki:Zi,qt={port:U.PORT,host:U.HOST,concurrency:U.DISPATCH_CONCURRENCY,dataDir:os,dbPath:Yi,keepAliveMs:U.SSE_KEEPALIVE_MS,claudeModel:U.CLAUDE_MODEL,codexModel:U.CODEX_MODEL,claudeEffort:U.CLAUDE_EFFORT,codexEffort:U.CODEX_EFFORT,claudeConfigDir:U.CLAUDE_CONFIG_DIR?_t(wt(U.CLAUDE_CONFIG_DIR)):void 0,vapidKeyPath:U.VAPID_KEY_PATH?_t(U.VAPID_KEY_PATH):Ht(Qi(Yi),"vapid.json"),pushSubject:U.PUSH_SUBJECT,staticDir:U.STATIC_DIR?_t(U.STATIC_DIR):Ht(xu,"..","..","web","dist"),repoRoots:(U.REPO_ROOTS??"").split(":").filter(Boolean).map(t=>_t(wt(t))),runnerSocket:U.RUNNER_SOCKET,executionRelease:U.EXECUTION_RELEASE,executionNode:U.EXECUTION_NODE,githubToken:U.GITHUB_TOKEN,authEnabled:eo,rpId:is,rpName:U.AUTH_RP_NAME??_.displayName,authOrigin:U.AUTH_ORIGIN??(is?`https://${is}`:""),sessionTtlMs:U.AUTH_SESSION_TTL_MS,cookieName:U.AUTH_COOKIE_NAME,nodeEnv:U.NODE_ENV}});var as=O(()=>{});import{createHash as Au}from"node:crypto";import{readFileSync as to,readdirSync as Oy,realpathSync as Dy,statSync as Py}from"node:fs";function cs(t){if(!Number.isSafeInteger(t)||t<=1)throw new Error("A valid local CLI process id is required");try{let e=to(`/proc/${t}/stat`,"utf8"),n=e.slice(e.lastIndexOf(")")+2).split(" ");return n[0]==="Z"?void 0:`${to("/proc/sys/kernel/random/boot_id","utf8").trim()}:${n[19]}`}catch(e){if(e.code==="ENOENT")return;throw new Error("Cannot verify the local CLI process; ownership is retained")}}var Iu,Cu,ds=O(()=>{ln();as();Iu=t=>Au("sha256").update(t).digest("hex");Cu=Iu(Buffer.alloc(0))});var no=O(()=>{});function Du({permission:t,model:e,effort:n,resumeId:r}){let s=["-p","--input-format","stream-json","--output-format","stream-json","--verbose","--include-partial-messages","--permission-mode",Ou(t),"--permission-prompt-tool","stdio"];return e&&s.push("--model",e),n&&s.push("--effort",n),r&&s.push("--resume",r),s}function Pu(t,e=[]){let n=e.map(r=>({type:"image",source:{type:"base64",media_type:r.mediaType,data:r.data}}));return n.push({type:"text",text:t}),{type:"user",message:{role:"user",content:n}}}var Nu,ro,Ou,er,so=O(()=>{ne();ln();Nu=1500,ro={plan:"plan",acceptEdits:"acceptEdits",dontAsk:"dontAsk",bypassPermissions:"bypassPermissions",readonly:"plan","auto-edit":"acceptEdits",full:"bypassPermissions"},Ou=t=>ro[t??""]??ro[Dr.claude];er=class{agent="claude";start(e,n,r){let{taskId:s,cwd:i,prompt:o,images:a,resumeId:c,permission:u,model:l,effort:p,reattach:m,resumeFromSeq:w,pendingInput:L}=e,x=Du({permission:u,model:l,effort:p,resumeId:c});e.interactive&&x.push("--replay-user-messages");let b=c,q=e.providerHome??qt.claudeConfigDir,be=q?{CLAUDE_CONFIG_DIR:q}:void 0,Z=m?r.attach(s,0):r.start({turnId:s,command:"claude",argv:x,cwd:i,env:be});if(!Z)return n({taskId:s,kind:"status",sessionId:b,payload:{subtype:"reattach_failed"}}),{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel:()=>{},done:Promise.resolve()};let E,V=H=>{E&&(clearTimeout(E.timer),E.resolve(H),E=void 0,A=!1)},T,A=!1,I,z,pe=!1,ve=0,Zt=new Map;m&&L&&Zt.set(L.requestId,{questions:L.questions});let nt=H=>Z.writeStdin(JSON.stringify(H)+`
3
3
  `),Cr=(H,ie,D)=>{nt({...Pu(H,ie),...D?{uuid:D}:{}})},Nr=(H=!1)=>{z&&clearTimeout(z),pe=H,z=setTimeout(()=>{!A&&Z.stdinWritable()&&Z.closeStdin()},Nu)},Ln=()=>{z&&clearTimeout(z),z=void 0,pe=!1};Z.onLine((H,ie)=>{let D;try{D=JSON.parse(ie)}catch{return}D.session_id&&(b=D.session_id);let X=j=>n(j,H),Ee=m&&H<=(w??0);switch(pe&&["stream_event","assistant","user","control_request"].includes(D.type)&&Ln(),D.type){case"system":X({taskId:s,kind:"status",sessionId:b,payload:{subtype:D.subtype,model:D.model,cwd:D.cwd,tools:D.tools?.length}});break;case"rate_limit_event":X({taskId:s,kind:"status",sessionId:b,payload:{subtype:"rate_limit",info:D}});break;case"stream_event":{let j=D.event;if(j?.type==="message_start"&&(T=j.message?.id),j?.type==="message_delta"&&T){let qe=j.delta?.stop_reason,ke=qe==="tool_use"?"progress":qe==="end_turn"?"final":void 0;ke&&X({taskId:s,kind:"status",sessionId:b,payload:{subtype:"assistant_message",messageId:T,phase:ke}})}j?.type==="message_stop"&&(T=void 0),j?.type==="content_block_delta"&&j.delta?.type==="text_delta"&&X({taskId:s,kind:"assistant_text",sessionId:b,payload:{text:j.delta.text,...T?{messageId:T}:{}}});break}case"assistant":{for(let j of D.message?.content??[])j.type==="tool_use"&&X({taskId:s,kind:"tool_call",sessionId:b,payload:{id:j.id,name:j.name,input:j.input}});break}case"user":{typeof D.uuid=="string"&&(D.uuid===e.messageId||D.uuid===E?.id||e.interactive&&D.message?.role==="user"&&D.message?.content?.some(j=>j.type==="text"))&&(X({taskId:s,kind:"status",sessionId:b,payload:{subtype:"message_delivered",messageId:D.uuid}}),E?.id===D.uuid&&V("delivered"));for(let j of D.message?.content??[])j.type==="tool_result"&&X({taskId:s,kind:"tool_result",sessionId:b,payload:{tool_use_id:j.tool_use_id,content:j.content,is_error:j.is_error}});break}case"result":X({taskId:s,kind:"result",sessionId:b,payload:{subtype:D.subtype,is_error:D.is_error,result:D.result,num_turns:D.num_turns,duration_ms:D.duration_ms,total_cost_usd:D.total_cost_usd}}),E&&!E.sent&&(E.sent=!0,Cr(E.text,E.images,E.id)),A||Nr(!!Ee);break;case"control_response":X({taskId:s,kind:"status",sessionId:b,payload:{subtype:"control_response",response:D.response}});break;case"control_request":{if(Ee)break;let j=D.request_id,qe=D.request??{};if(qe.subtype!=="can_use_tool")break;if(qe.tool_name==="AskUserQuestion"&&Array.isArray(qe.input?.questions)){let ke=qe.input.questions;Zt.set(j,{questions:ke}),X({taskId:s,kind:"question",sessionId:b,payload:{requestId:j,questions:ke}})}else nt({type:"control_response",response:{subtype:"success",request_id:j,response:{behavior:"deny",message:"Auto-denied (non-interactive dispatch)."}}});break}default:break}}),Z.onStderr(H=>{n({taskId:s,kind:"status",sessionId:b,payload:{subtype:"stderr",text:H}})});let ac=new Promise(H=>{Z.onExit(ie=>{Ln(),V("unknown"),n({taskId:s,kind:"status",sessionId:b,payload:{subtype:"process_exit",code:ie}}),H()})});return m||Cr(o,a,e.messageId),{send:(H,ie,D)=>!Z.stdinWritable()||E||z||!e.interactive?Promise.resolve("rejected"):(A=!0,Ln(),new Promise(X=>{let Ee=setTimeout(()=>{V("unknown"),Nr()},15e3);Ee.unref(),E={id:D,text:H,images:ie,sent:!1,resolve:X,timer:Ee},nt({type:"control_request",request_id:`send_${D}`,request:{subtype:"interrupt"}})})),steer:(H,ie)=>Z.stdinWritable()?(A=!0,Ln(),nt({type:"control_request",request_id:`int_${++ve}`,request:{subtype:"interrupt"}}),I=setTimeout(()=>{Cr(H,ie),A=!1},250),!0):!1,interrupt:()=>Z.stdinWritable()?(I&&clearTimeout(I),V(E?.sent?"unknown":"rejected"),A=!1,nt({type:"control_request",request_id:`int_${++ve}`,request:{subtype:"interrupt"}}),Nr(),!0):!1,approve:()=>!1,answer:H=>{let ie=Zt.get(H.requestId);if(!ie||!Z.stdinWritable())return!1;let D=new Map(ie.questions.map(fe=>[fe.question,fe])),X={},Ee={};for(let fe of H.answers??[])fe.selected?.length&&(X[fe.question]=D.get(fe.question)?.multiSelect?fe.selected:fe.selected[0]),fe.notes?.trim()&&(Ee[fe.question]={notes:fe.notes.trim()});let j=H.response?.trim();if(!(Object.keys(X).length>0||Object.keys(Ee).length>0||!!j))return nt({type:"control_response",response:{subtype:"success",request_id:H.requestId,response:{behavior:"deny",message:"User declined to answer."}}})?(Zt.delete(H.requestId),!0):!1;let ke={questions:ie.questions,answers:X};return Object.keys(Ee).length&&(ke.annotations=Ee),j&&(ke.response=j),nt({type:"control_response",response:{subtype:"success",request_id:H.requestId,response:{behavior:"allow",updatedInput:ke}}})?(Zt.delete(H.requestId),!0):!1},cancel:()=>Z.kill("SIGINT"),done:ac}}}});function oo(t,e,n){let{taskId:r,reattach:s}=t,i=t.resumeId,o,a=!1,c,u=new Map,l=new Map;s&&t.pendingInput&&l.set(t.pendingInput.requestId,t.pendingInput);let p=t.permission,m=p==="read-only"||p==="readonly"?"read-only":p==="danger-full-access"||p==="full"?"danger-full-access":"workspace-write",w=s?n.attach(r,0):n.start({turnId:r,command:"codex",cwd:t.cwd,argv:["app-server","--listen","stdio://","-c",'approval_policy="never"',"-c",`sandbox_mode=${JSON.stringify(m)}`,...p==="workspace-write-net"?["-c","sandbox_workspace_write.network_access=true"]:[]],...t.providerHome?{env:{CODEX_HOME:t.providerHome}}:{}});if(!w)return e({taskId:r,kind:"status",sessionId:i,payload:{subtype:"reattach_failed"}}),{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel(){},done:Promise.resolve()};let L=E=>w.writeStdin(JSON.stringify(E)+`
4
4
  `),x=(E,V,T)=>L({jsonrpc:"2.0",id:E,method:V,params:T}),b=(E,V,T)=>e({taskId:r,sessionId:i,kind:E,payload:V},T),q=(E,V)=>{b("status",{subtype:"message_delivered",messageId:E},V);let T=u.get(E);T&&(clearTimeout(T.timer),u.delete(E),T.resolve("delivered"))},be=setTimeout(()=>{!o&&!a&&(b("error",{message:"Codex did not start a turn; the request will not be replayed automatically."}),w.kill("SIGINT"))},3e4);be.unref(),w.onLine((E,V)=>{let T;try{T=JSON.parse(V)}catch{return}let A=T.params??{};if(typeof T.id=="string"&&("result"in T||"error"in T)){if(T.id.startsWith("message:")){let I=T.id.slice(8),z=u.get(I);T.error?z&&(clearTimeout(z.timer),u.delete(I),z.resolve("rejected")):q(I,E)}else T.error?(b("error",{message:T.error.message??"Codex request failed"},E),a=!0,w.closeStdin()):T.id==="initialize"&&!s?(L({jsonrpc:"2.0",method:"initialized",params:{}}),x("session",t.resumeId?"thread/resume":"thread/start",{...t.resumeId?{threadId:t.resumeId}:{},cwd:t.cwd,approvalPolicy:"never",sandbox:m,...t.model?{model:t.model}:{},...t.effort?{config:{model_reasoning_effort:t.effort}}:{}})):T.id==="session"?(i=T.result.thread.id,b("status",{subtype:"thread_started"},E),s||x("start","turn/start",{threadId:i,input:io(t.prompt,t.images),...t.messageId?{clientUserMessageId:t.messageId}:{},...t.effort?{effort:t.effort}:{}})):T.id==="start"&&(o=T.result.turn.id,clearTimeout(be),t.messageId&&q(t.messageId,E));return}if(!(A.threadId&&i&&A.threadId!==i))switch(T.method){case"thread/started":i=A.thread.id,b("status",{subtype:"thread_started"},E);break;case"turn/started":o=A.turn.id,clearTimeout(be),b("status",{subtype:"turn_started",turnId:o},E);break;case"item/agentMessage/delta":b("assistant_text",{text:A.delta,messageId:A.itemId},E);break;case"item/started":A.item?.type==="commandExecution"&&b("tool_call",{id:A.item.id,name:"bash",command:A.item.command},E);break;case"item/completed":{let I=A.item;I?.type==="userMessage"&&I.clientId?q(I.clientId,E):I?.type==="agentMessage"?b("status",{subtype:"assistant_message",messageId:I.id,phase:I.phase==="commentary"?"progress":I.phase==="final_answer"?"final":void 0},E):I?.type==="commandExecution"?b("tool_result",{tool_use_id:I.id,output:I.aggregatedOutput,exit_code:I.exitCode},E):I?.type==="fileChange"?b("tool_call",{id:I.id,name:"file_change",changes:I.changes},E):(I?.type==="mcpToolCall"||I?.type==="webSearch")&&b("tool_result",{tool_use_id:I.id,content:I.result??I.action,name:I.tool??I.type},E);break}case"turn/completed":a=!0,o=void 0,l.clear(),clearTimeout(be),A.turn.status==="failed"&&b("error",{message:A.turn.error?.message??"Codex turn failed."},E),b("result",{is_error:A.turn.status!=="completed",subtype:A.turn.status,error:A.turn.error,usage:c},E),w.closeStdin();break;case"thread/tokenUsage/updated":A.tokenUsage?.last&&(c={input_tokens:A.tokenUsage.last.inputTokens,cached_input_tokens:A.tokenUsage.last.cachedInputTokens,output_tokens:A.tokenUsage.last.outputTokens}),b("status",{subtype:"usage",usage:A.tokenUsage},E);break;case"error":b("error",{message:A.error?.message??A.message},E);break;case"item/commandExecution/requestApproval":case"item/fileChange/requestApproval":L({jsonrpc:"2.0",id:T.id,result:{decision:"decline"}});break;case"item/tool/requestUserInput":{if(typeof T.id!="string"&&typeof T.id!="number")break;let I=JSON.stringify(T.id);if(s&&E<=(t.resumeFromSeq??0)||!Array.isArray(A.questions))break;let z={requestId:I,questions:A.questions.map(pe=>({id:pe.id,question:pe.question,header:pe.header,options:pe.options??[]}))};l.set(I,z),b("question",z,E);break}case"serverRequest/resolved":{let I=JSON.stringify(A.requestId);l.delete(I),b("status",{subtype:"input_resolved",requestId:I},E);break}}}),w.onStderr(E=>b("status",{subtype:"stderr",text:E}));let Z=new Promise(E=>w.onExit(V=>{clearTimeout(be);for(let T of u.values())clearTimeout(T.timer),T.resolve("unknown");u.clear(),l.clear(),a||b("error",{message:"Codex exited before a terminal turn result."}),b("status",{subtype:"process_exit",code:V}),E()}));return s||x("initialize","initialize",{clientInfo:{name:"palmagent",version:"1.0.0"},capabilities:{}}),{send:(E,V,T)=>!o||a||!w.stdinWritable()?Promise.resolve("rejected"):new Promise(A=>{let I=setTimeout(()=>{u.delete(T),A("unknown")},15e3);I.unref(),u.set(T,{resolve:A,timer:I}),x(`message:${T}`,"turn/steer",{threadId:i,expectedTurnId:o,clientUserMessageId:T,input:io(E,V)})||(clearTimeout(I),u.delete(T),A("unknown"))}),steer:()=>!1,interrupt:()=>!!o&&!a&&x(`stop:${o}`,"turn/interrupt",{threadId:i,turnId:o}),approve:()=>!1,answer:E=>{let V=l.get(E.requestId);if(!V||a||!w.stdinWritable())return!1;let T={};for(let A of V.questions){if(!A.id)return!1;let I=E.answers.filter(ve=>ve.questionId?ve.questionId===A.id:ve.question===A.question),z=I[0];if(I.length>1||z&&!z.questionId&&V.questions.filter(ve=>ve.question===A.question).length>1)return!1;let pe=[...z?.selected??[],...[z?.notes?.trim(),E.response?.trim()].filter(ve=>!!ve)];pe.length&&(T[A.id]={answers:pe})}return L({jsonrpc:"2.0",id:JSON.parse(E.requestId),result:{answers:T}})?(l.delete(E.requestId),!0):!1},cancel:()=>w.kill("SIGINT"),done:Z}}var io,ao=O(()=>{io=(t,e)=>[{type:"text",text:t,text_elements:[]},...(e??[]).map(n=>({type:"image",url:`data:${n.mediaType};base64,${n.data}`}))]});import{mkdtempSync as Lu,rmSync as Uu,writeFileSync as $u}from"node:fs";import{tmpdir as ju}from"node:os";import{join as co}from"node:path";function Hu(t){if(!t?.length)return{argv:[],cleanup:()=>{}};let e=Lu(co(ju(),"palmagent-img-")),n=[];return t.forEach((r,s)=>{let i=co(e,`img-${s}${Mu[r.mediaType]??".png"}`);$u(i,Buffer.from(r.data,"base64")),n.push("-i",i)}),{argv:n,cleanup:()=>Uu(e,{recursive:!0,force:!0})}}function qu(t){return uo[t??""]??uo["workspace-write"]}function Fu({prompt:t,resumeId:e,permission:n,model:r,effort:s},i=[]){let o=[...r?["-c",`model=${r}`]:[],...s?["-c",`model_reasoning_effort=${s}`]:[]],a=qu(n),c=e?["-c",`sandbox_mode=${a.mode}`]:["--sandbox",a.mode],u=a.network?["-c","sandbox_workspace_write.network_access=true"]:[],l=["--json","--skip-git-repo-check","-c","approval_policy=never",...c,...u,...o,...i];return e?["exec","resume",e,t,...l]:["exec",t,...l]}var Mu,uo,tr,lo=O(()=>{ao();Mu={"image/png":".png","image/jpeg":".jpg","image/webp":".webp","image/gif":".gif"};uo={"read-only":{mode:"read-only"},"workspace-write":{mode:"workspace-write"},"workspace-write-net":{mode:"workspace-write",network:!0},"danger-full-access":{mode:"danger-full-access"},readonly:{mode:"read-only"},"auto-edit":{mode:"workspace-write"},full:{mode:"danger-full-access"}};tr=class{agent="codex";start(e,n,r){if(e.interactive)return oo(e,n,r);let{taskId:s,cwd:i,prompt:o,images:a,resumeId:c,permission:u,model:l,effort:p,reattach:m}=e,w=c;if(m){let q=r.attach(s,0);return q?this.wire(s,q,n,()=>{},()=>w,be=>{w=be}):(n({taskId:s,kind:"status",sessionId:w,payload:{subtype:"reattach_failed"}}),{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel:()=>{},done:Promise.resolve()})}let L=Hu(a),x=Fu({prompt:o,resumeId:c,permission:u,model:l,effort:p},L.argv),b=r.start({turnId:s,command:"codex",argv:x,cwd:i,...e.providerHome?{env:{CODEX_HOME:e.providerHome}}:{}});return b.closeStdin(),this.wire(s,b,n,L.cleanup,()=>w,q=>{w=q})}wire(e,n,r,s,i,o){let a=(u,l)=>{let p=i();switch(u?.type){case"agent_message":l({taskId:e,kind:"assistant_text",sessionId:p,payload:{text:u.text,messageId:u.id,...u.phase==="commentary"?{phase:"progress"}:u.phase==="final_answer"?{phase:"final"}:{}}});break;case"reasoning":l({taskId:e,kind:"status",sessionId:p,payload:{subtype:"reasoning",text:u.text}});break;case"command_execution":l({taskId:e,kind:"tool_call",sessionId:p,payload:{id:u.id,name:"bash",command:u.command,status:u.status}}),(u.aggregated_output!=null||u.exit_code!=null)&&l({taskId:e,kind:"tool_result",sessionId:p,payload:{tool_use_id:u.id,output:u.aggregated_output,exit_code:u.exit_code,status:u.status}});break;case"file_change":l({taskId:e,kind:"tool_call",sessionId:p,payload:{id:u.id,name:"file_change",changes:u.changes,status:u.status}});break;case"mcp_tool_call":case"web_search":l({taskId:e,kind:"tool_call",sessionId:p,payload:{id:u.id,name:u.type,status:u.status,item:u}});break;case"error":l({taskId:e,kind:"error",sessionId:p,payload:{message:u.message}});break;default:l({taskId:e,kind:"status",sessionId:p,payload:{subtype:u?.type??"item",item:u}})}};n.onLine((u,l)=>{let p;try{p=JSON.parse(l)}catch{return}let m=L=>r(L,u),w=i();switch(p.type){case"thread.started":o(p.thread_id),m({taskId:e,kind:"status",sessionId:p.thread_id,payload:{subtype:"thread_started",thread_id:p.thread_id}});break;case"turn.started":m({taskId:e,kind:"status",sessionId:w,payload:{subtype:"turn_started"}});break;case"item.started":p.item?.type==="command_execution"&&a(p.item,m);break;case"item.updated":break;case"item.completed":a(p.item,m);break;case"turn.completed":m({taskId:e,kind:"result",sessionId:w,payload:{usage:p.usage}});break;case"turn.failed":m({taskId:e,kind:"error",sessionId:w,payload:{error:p.error}});break;case"error":m({taskId:e,kind:"error",sessionId:w,payload:{message:p.message}});break;default:break}}),n.onStderr(u=>{r({taskId:e,kind:"status",sessionId:i(),payload:{subtype:"stderr",text:u}})});let c=new Promise(u=>{n.onExit(l=>{s(),r({taskId:e,kind:"status",sessionId:i(),payload:{subtype:"process_exit",code:l}}),u()})});return{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel:()=>n.kill("SIGINT"),done:c}}}});var Ky,po=O(()=>{so();lo();Ky={claude:new er,codex:new tr}});var fo=O(()=>{});var G,vb,pn=O(()=>{ss();ne();ds();as();no();ln();po();Qn();fo();G=class extends Error{constructor(n,r){super(r);this.status=n}},vb=4.5*1024*1024});import{chmodSync as bo,mkdirSync as vo,openSync as ho,closeSync as mo,fsyncSync as go,writeFileSync as Bu,renameSync as Wu,unlinkSync as Vu}from"node:fs";import{dirname as yo}from"node:path";import{randomUUID as zu}from"node:crypto";function ue(t){vo(t,{recursive:!0,mode:448}),bo(t,448)}function ge(t){vo(t,{recursive:!0,mode:448})}function Ke(t){bo(t,384)}function Ze(t,e){ge(yo(t));let n=`${t}.${zu()}.tmp`,r=ho(n,"wx",384);try{Bu(r,e),go(r)}finally{mo(r)}try{Wu(n,t);let s=ho(yo(t),"r");try{go(s)}finally{mo(s)}}finally{try{Vu(n)}catch(s){if(s.code!=="ENOENT")throw s}}}var oe=O(()=>{});function Bp(t){let e=[],n=[],r="",s=!1,i="",o=!1,a=[],c=!1,u=()=>{s&&(o?(a.push({end:r,tabs:c}),o=!1):n.push(r),r="",s=!1)},l=()=>{u(),n.length&&e.push(n),n=[]};for(let p=0;p<t.length;p++){let m=t[p];if(i){if(m===i){i="";continue}if(i==='"'&&(m==="$"||m==="`"))return null;if(i==='"'&&m==="\\"&&/[\\"$`\n]/.test(t[p+1]??"")){let w=t[++p];w!==`
5
5
  `&&(r+=w)}else r+=m;continue}if(m==="'"||m==='"'){i=m,s=!0;continue}if(m==="\\"){if(++p>=t.length)return null;t[p]!==`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "palmagent",
3
- "version": "0.1.0-alpha.39",
3
+ "version": "0.1.0-alpha.40",
4
4
  "palmagent": {
5
5
  "agentCliCompatibility": {
6
6
  "claude": {