@nockdev/hsa 1.4.12 → 1.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hsa-cli.bundle.js +2 -2
- package/dist/hsa-http.bundle.js +2 -2
- package/dist/hsa-lib.bundle.js +19 -19
- package/dist/integrity.json +7 -7
- package/package.json +1 -1
package/dist/hsa-http.bundle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire as __cr}from"module";const require=__cr(import.meta.url);
|
|
3
|
-
var nL=Object.create;var hV=Object.defineProperty;var hL=Object.getOwnPropertyDescriptor;var tL=Object.getOwnPropertyNames;var sL=Object.getPrototypeOf,RL=Object.prototype.hasOwnProperty;var D=(l=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(l,{get:(I,G)=>(typeof require<"u"?require:I)[G]}):l)(function(l){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+l+'" is not supported')});var u=(l,I)=>()=>(l&&(I=l(l=0)),I);var F=(l,I)=>()=>(I||l((I={exports:{}}).exports,I),I.exports),TI=(l,I)=>{for(var G in I)hV(l,G,{get:I[G],enumerable:!0})},FL=(l,I,G,c)=>{if(I&&typeof I=="object"||typeof I=="function")for(let b of tL(I))!RL.call(l,b)&&b!==G&&hV(l,b,{get:()=>I[b],enumerable:!(c=hL(I,b))||c.enumerable});return l};var Kc=(l,I,G)=>(G=l!=null?nL(sL(l)):{},FL(I||!l||!l.__esModule?hV(G,"default",{value:l,enumerable:!0}):G,l));function tu(l){hu=l}function J(l){function I(c){return nu[c]>=nu[hu]}function G(c,b,Z){let W=`[${new Date().toISOString()}] [${c.toUpperCase()}] [${l}]`;return Z&&Object.keys(Z).length>0?`${W} ${b} ${JSON.stringify(Z)}`:`${W} ${b}`}return{debug(c,b){I("debug")&&console.error(G("debug",c,b))},info(c,b){I("info")&&console.error(G("info",c,b))},warn(c,b){I("warn")&&console.error(G("warn",c,b))},error(c,b,Z){if(I("error")){let d={...Z,...b instanceof Error?{error:b.message,stack:b.stack}:{error:String(b)}};console.error(G("error",c,d))}},child(c){return J(`${l}:${c}`)}}}var nu,hu,T=u(()=>{"use strict";nu={debug:0,info:1,warn:2,error:3},hu="info"});var $l,EN,la,Ga,su,Ru,Fu,uu,Xu,Qu,Hu,vu,wu,iu,tV,sV,ou,yu,Eu,Sc,JN,rl,Ju,bl=u(()=>{"use strict";$l={DEFAULT:8e3,MAX:128e3,MIN:100,PROFILES:{MVP:2e3,PRODUCTION:8e3,ENTERPRISE:16e3},TOOLS:{REPO_MAP:2e3,REPO_MAP_MAX:16e3,HANDOFF:1500,HANDOFF_MAX:5e3,HANDOFF_MIN:500}},EN=$l.DEFAULT,la=$l.MAX,Ga=$l.MIN,su=256,Ru=300*1e3,Fu=50*1024*1024,uu=1.5,Xu=.75,Qu=.1,Hu=50,vu=10*1024*1024,wu="merkle.json",iu={system:.05,skills:.05,context:.65,stack:.05,changes:.1,prefetch:.05,reserve:.05},tV=.3,sV=20,ou=25,yu=2e5,Eu=3600,Sc=13100,JN="domyh-hsa",rl="1.4.12",Ju=".agent/hsa"});var hI,RV,_,MG,ca=u(()=>{(function(l){l.assertEqual=b=>{};function I(b){}l.assertIs=I;function G(b){throw new Error}l.assertNever=G,l.arrayToEnum=b=>{let Z={};for(let d of b)Z[d]=d;return Z},l.getValidEnumValues=b=>{let Z=l.objectKeys(b).filter(W=>typeof b[b[W]]!="number"),d={};for(let W of Z)d[W]=b[W];return l.objectValues(d)},l.objectValues=b=>l.objectKeys(b).map(function(Z){return b[Z]}),l.objectKeys=typeof Object.keys=="function"?b=>Object.keys(b):b=>{let Z=[];for(let d in b)Object.prototype.hasOwnProperty.call(b,d)&&Z.push(d);return Z},l.find=(b,Z)=>{for(let d of b)if(Z(d))return d},l.isInteger=typeof Number.isInteger=="function"?b=>Number.isInteger(b):b=>typeof b=="number"&&Number.isFinite(b)&&Math.floor(b)===b;function c(b,Z=" | "){return b.map(d=>typeof d=="string"?`'${d}'`:d).join(Z)}l.joinValues=c,l.jsonStringifyReplacer=(b,Z)=>typeof Z=="bigint"?Z.toString():Z})(hI||(hI={}));(function(l){l.mergeShapes=(I,G)=>({...I,...G})})(RV||(RV={}));_=hI.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),MG=l=>{switch(typeof l){case"undefined":return _.undefined;case"string":return _.string;case"number":return Number.isNaN(l)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(l)?_.array:l===null?_.null:l.then&&typeof l.then=="function"&&l.catch&&typeof l.catch=="function"?_.promise:typeof Map<"u"&&l instanceof Map?_.map:typeof Set<"u"&&l instanceof Set?_.set:typeof Date<"u"&&l instanceof Date?_.date:_.object;default:return _.unknown}}});var M,uL,Cl,rN=u(()=>{ca();M=hI.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"]),uL=l=>JSON.stringify(l,null,2).replace(/"([^"]+)":/g,"$1:"),Cl=class l extends Error{get errors(){return this.issues}constructor(I){super(),this.issues=[],this.addIssue=c=>{this.issues=[...this.issues,c]},this.addIssues=(c=[])=>{this.issues=[...this.issues,...c]};let G=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,G):this.__proto__=G,this.name="ZodError",this.issues=I}format(I){let G=I||function(Z){return Z.message},c={_errors:[]},b=Z=>{for(let d of Z.issues)if(d.code==="invalid_union")d.unionErrors.map(b);else if(d.code==="invalid_return_type")b(d.returnTypeError);else if(d.code==="invalid_arguments")b(d.argumentsError);else if(d.path.length===0)c._errors.push(G(d));else{let W=c,a=0;for(;a<d.path.length;){let m=d.path[a];a===d.path.length-1?(W[m]=W[m]||{_errors:[]},W[m]._errors.push(G(d))):W[m]=W[m]||{_errors:[]},W=W[m],a++}}};return b(this),c}static assert(I){if(!(I instanceof l))throw new Error(`Not a ZodError: ${I}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,hI.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(I=G=>G.message){let G={},c=[];for(let b of this.issues)if(b.path.length>0){let Z=b.path[0];G[Z]=G[Z]||[],G[Z].push(I(b))}else c.push(I(b));return{formErrors:c,fieldErrors:G}}get formErrors(){return this.flatten()}};Cl.create=l=>new Cl(l)});var XL,nc,FV=u(()=>{rN();ca();XL=(l,I)=>{let G;switch(l.code){case M.invalid_type:l.received===_.undefined?G="Required":G=`Expected ${l.expected}, received ${l.received}`;break;case M.invalid_literal:G=`Invalid literal value, expected ${JSON.stringify(l.expected,hI.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:G=`Unrecognized key(s) in object: ${hI.joinValues(l.keys,", ")}`;break;case M.invalid_union:G="Invalid input";break;case M.invalid_union_discriminator:G=`Invalid discriminator value. Expected ${hI.joinValues(l.options)}`;break;case M.invalid_enum_value:G=`Invalid enum value. Expected ${hI.joinValues(l.options)}, received '${l.received}'`;break;case M.invalid_arguments:G="Invalid function arguments";break;case M.invalid_return_type:G="Invalid function return type";break;case M.invalid_date:G="Invalid date";break;case M.invalid_string:typeof l.validation=="object"?"includes"in l.validation?(G=`Invalid input: must include "${l.validation.includes}"`,typeof l.validation.position=="number"&&(G=`${G} at one or more positions greater than or equal to ${l.validation.position}`)):"startsWith"in l.validation?G=`Invalid input: must start with "${l.validation.startsWith}"`:"endsWith"in l.validation?G=`Invalid input: must end with "${l.validation.endsWith}"`:hI.assertNever(l.validation):l.validation!=="regex"?G=`Invalid ${l.validation}`:G="Invalid";break;case M.too_small:l.type==="array"?G=`Array must contain ${l.exact?"exactly":l.inclusive?"at least":"more than"} ${l.minimum} element(s)`:l.type==="string"?G=`String must contain ${l.exact?"exactly":l.inclusive?"at least":"over"} ${l.minimum} character(s)`:l.type==="number"?G=`Number must be ${l.exact?"exactly equal to ":l.inclusive?"greater than or equal to ":"greater than "}${l.minimum}`:l.type==="bigint"?G=`Number must be ${l.exact?"exactly equal to ":l.inclusive?"greater than or equal to ":"greater than "}${l.minimum}`:l.type==="date"?G=`Date must be ${l.exact?"exactly equal to ":l.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(l.minimum))}`:G="Invalid input";break;case M.too_big:l.type==="array"?G=`Array must contain ${l.exact?"exactly":l.inclusive?"at most":"less than"} ${l.maximum} element(s)`:l.type==="string"?G=`String must contain ${l.exact?"exactly":l.inclusive?"at most":"under"} ${l.maximum} character(s)`:l.type==="number"?G=`Number must be ${l.exact?"exactly":l.inclusive?"less than or equal to":"less than"} ${l.maximum}`:l.type==="bigint"?G=`BigInt must be ${l.exact?"exactly":l.inclusive?"less than or equal to":"less than"} ${l.maximum}`:l.type==="date"?G=`Date must be ${l.exact?"exactly":l.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(l.maximum))}`:G="Invalid input";break;case M.custom:G="Invalid input";break;case M.invalid_intersection_types:G="Intersection results could not be merged";break;case M.not_multiple_of:G=`Number must be a multiple of ${l.multipleOf}`;break;case M.not_finite:G="Number must be finite";break;default:G=I.defaultError,hI.assertNever(l)}return{message:G}},nc=XL});function QL(l){ru=l}function Gd(){return ru}var ru,CN=u(()=>{FV();ru=nc});function q(l,I){let G=Gd(),c=ba({issueData:I,data:l.data,path:l.path,errorMaps:[l.common.contextualErrorMap,l.schemaErrorMap,G,G===nc?void 0:nc].filter(b=>!!b)});l.common.issues.push(c)}var ba,HL,Ql,aI,Kb,gl,gN,AN,fc,cd,uV=u(()=>{CN();FV();ba=l=>{let{data:I,path:G,errorMaps:c,issueData:b}=l,Z=[...G,...b.path||[]],d={...b,path:Z};if(b.message!==void 0)return{...b,path:Z,message:b.message};let W="",a=c.filter(m=>!!m).slice().reverse();for(let m of a)W=m(d,{data:I,defaultError:W}).message;return{...b,path:Z,message:W}},HL=[];Ql=class l{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(I,G){let c=[];for(let b of G){if(b.status==="aborted")return aI;b.status==="dirty"&&I.dirty(),c.push(b.value)}return{status:I.value,value:c}}static async mergeObjectAsync(I,G){let c=[];for(let b of G){let Z=await b.key,d=await b.value;c.push({key:Z,value:d})}return l.mergeObjectSync(I,c)}static mergeObjectSync(I,G){let c={};for(let b of G){let{key:Z,value:d}=b;if(Z.status==="aborted"||d.status==="aborted")return aI;Z.status==="dirty"&&I.dirty(),d.status==="dirty"&&I.dirty(),Z.value!=="__proto__"&&(typeof d.value<"u"||b.alwaysSet)&&(c[Z.value]=d.value)}return{status:I.value,value:c}}},aI=Object.freeze({status:"aborted"}),Kb=l=>({status:"dirty",value:l}),gl=l=>({status:"valid",value:l}),gN=l=>l.status==="aborted",AN=l=>l.status==="dirty",fc=l=>l.status==="valid",cd=l=>typeof Promise<"u"&&l instanceof Promise});var Cu=u(()=>{});var lI,gu=u(()=>{(function(l){l.errToObj=I=>typeof I=="string"?{message:I}:I||{},l.toString=I=>typeof I=="string"?I:I?.message})(lI||(lI={}))});function YI(l){if(!l)return{};let{errorMap:I,invalid_type_error:G,required_error:c,description:b}=l;if(I&&(G||c))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return I?{errorMap:I,description:b}:{errorMap:(d,W)=>{let{message:a}=l;return d.code==="invalid_enum_value"?{message:a??W.defaultError}:typeof W.data>"u"?{message:a??c??W.defaultError}:d.code!=="invalid_type"?{message:W.defaultError}:{message:a??G??W.defaultError}},description:b}}function zu(l){let I="[0-5]\\d";l.precision?I=`${I}\\.\\d{${l.precision}}`:l.precision==null&&(I=`${I}(\\.\\d+)?`);let G=l.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${I})${G}`}function BL(l){return new RegExp(`^${zu(l)}$`)}function xu(l){let I=`${ku}T${zu(l)}`,G=[];return G.push(l.local?"Z?":"Z"),l.offset&&G.push("([+-]\\d{2}:?\\d{2})"),I=`${I}(${G.join("|")})`,new RegExp(`^${I}$`)}function OL(l,I){return!!((I==="v4"||!I)&&gL.test(l)||(I==="v6"||!I)&&LL.test(l))}function ML(l,I){if(!EL.test(l))return!1;try{let[G]=l.split(".");if(!G)return!1;let c=G.replace(/-/g,"+").replace(/_/g,"/").padEnd(G.length+(4-G.length%4)%4,"="),b=JSON.parse(atob(c));return!(typeof b!="object"||b===null||"typ"in b&&b?.typ!=="JWT"||!b.alg||I&&b.alg!==I)}catch{return!1}}function jL(l,I){return!!((I==="v4"||!I)&&AL.test(l)||(I==="v6"||!I)&&kL.test(l))}function KL(l,I){let G=(l.toString().split(".")[1]||"").length,c=(I.toString().split(".")[1]||"").length,b=G>c?G:c,Z=Number.parseInt(l.toFixed(b).replace(".","")),d=Number.parseInt(I.toFixed(b).replace(".",""));return Z%d/10**b}function bd(l){if(l instanceof Ml){let I={};for(let G in l.shape){let c=l.shape[G];I[G]=aG.create(bd(c))}return new Ml({...l._def,shape:()=>I})}else return l instanceof sc?new sc({...l._def,type:bd(l.element)}):l instanceof aG?aG.create(bd(l.unwrap())):l instanceof KG?KG.create(bd(l.unwrap())):l instanceof jG?jG.create(l.items.map(I=>bd(I))):l}function QV(l,I){let G=MG(l),c=MG(I);if(l===I)return{valid:!0,data:l};if(G===_.object&&c===_.object){let b=hI.objectKeys(I),Z=hI.objectKeys(l).filter(W=>b.indexOf(W)!==-1),d={...l,...I};for(let W of Z){let a=QV(l[W],I[W]);if(!a.valid)return{valid:!1};d[W]=a.data}return{valid:!0,data:d}}else if(G===_.array&&c===_.array){if(l.length!==I.length)return{valid:!1};let b=[];for(let Z=0;Z<l.length;Z++){let d=l[Z],W=I[Z],a=QV(d,W);if(!a.valid)return{valid:!1};b.push(a.data)}return{valid:!0,data:b}}else return G===_.date&&c===_.date&&+l==+I?{valid:!0,data:l}:{valid:!1}}function Uu(l,I){return new GZ({values:l,typeName:NI.ZodEnum,...YI(I)})}function Lu(l,I){let G=typeof l=="function"?l(I):typeof l=="string"?{message:l}:l;return typeof G=="string"?{message:G}:G}function Bu(l,I={},G){return l?Tc.create().superRefine((c,b)=>{let Z=l(c);if(Z instanceof Promise)return Z.then(d=>{if(!d){let W=Lu(I,c),a=W.fatal??G??!0;b.addIssue({code:"custom",...W,fatal:a})}});if(!Z){let d=Lu(I,c),W=d.fatal??G??!0;b.addIssue({code:"custom",...d,fatal:W})}}):Tc.create()}var mG,Au,pI,vL,wL,iL,oL,yL,EL,JL,rL,CL,XV,gL,AL,LL,kL,zL,xL,ku,UL,Dc,Sb,fb,Db,Tb,Zd,qb,Pb,Tc,tc,oG,dd,sc,Ml,_b,hc,LN,$b,jG,kN,Wd,ad,zN,IZ,lZ,GZ,cZ,qc,NG,aG,KG,bZ,ZZ,md,SL,Za,da,dZ,fL,NI,DL,Ou,Mu,TL,qL,ju,PL,_L,$L,Ik,lk,Gk,ck,bk,Zk,dk,Wk,ak,mk,Nk,ek,Yk,pk,Vk,nk,hk,tk,sk,Rk,Fk,uk,Xk,Qk,Hk,vk,wk,ik,ok,yk,Ek,Ku=u(()=>{rN();CN();gu();uV();ca();mG=class{constructor(I,G,c,b){this._cachedPath=[],this.parent=I,this.data=G,this._path=c,this._key=b}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}},Au=(l,I)=>{if(fc(I))return{success:!0,data:I.value};if(!l.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let G=new Cl(l.common.issues);return this._error=G,this._error}}};pI=class{get description(){return this._def.description}_getType(I){return MG(I.data)}_getOrReturnCtx(I,G){return G||{common:I.parent.common,data:I.data,parsedType:MG(I.data),schemaErrorMap:this._def.errorMap,path:I.path,parent:I.parent}}_processInputParams(I){return{status:new Ql,ctx:{common:I.parent.common,data:I.data,parsedType:MG(I.data),schemaErrorMap:this._def.errorMap,path:I.path,parent:I.parent}}}_parseSync(I){let G=this._parse(I);if(cd(G))throw new Error("Synchronous parse encountered promise.");return G}_parseAsync(I){let G=this._parse(I);return Promise.resolve(G)}parse(I,G){let c=this.safeParse(I,G);if(c.success)return c.data;throw c.error}safeParse(I,G){let c={common:{issues:[],async:G?.async??!1,contextualErrorMap:G?.errorMap},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:I,parsedType:MG(I)},b=this._parseSync({data:I,path:c.path,parent:c});return Au(c,b)}"~validate"(I){let G={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:I,parsedType:MG(I)};if(!this["~standard"].async)try{let c=this._parseSync({data:I,path:[],parent:G});return fc(c)?{value:c.value}:{issues:G.common.issues}}catch(c){c?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),G.common={issues:[],async:!0}}return this._parseAsync({data:I,path:[],parent:G}).then(c=>fc(c)?{value:c.value}:{issues:G.common.issues})}async parseAsync(I,G){let c=await this.safeParseAsync(I,G);if(c.success)return c.data;throw c.error}async safeParseAsync(I,G){let c={common:{issues:[],contextualErrorMap:G?.errorMap,async:!0},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:I,parsedType:MG(I)},b=this._parse({data:I,path:c.path,parent:c}),Z=await(cd(b)?b:Promise.resolve(b));return Au(c,Z)}refine(I,G){let c=b=>typeof G=="string"||typeof G>"u"?{message:G}:typeof G=="function"?G(b):G;return this._refinement((b,Z)=>{let d=I(b),W=()=>Z.addIssue({code:M.custom,...c(b)});return typeof Promise<"u"&&d instanceof Promise?d.then(a=>a?!0:(W(),!1)):d?!0:(W(),!1)})}refinement(I,G){return this._refinement((c,b)=>I(c)?!0:(b.addIssue(typeof G=="function"?G(c,b):G),!1))}_refinement(I){return new NG({schema:this,typeName:NI.ZodEffects,effect:{type:"refinement",refinement:I}})}superRefine(I){return this._refinement(I)}constructor(I){this.spa=this.safeParseAsync,this._def=I,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:G=>this["~validate"](G)}}optional(){return aG.create(this,this._def)}nullable(){return KG.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return sc.create(this)}promise(){return qc.create(this,this._def)}or(I){return _b.create([this,I],this._def)}and(I){return $b.create(this,I,this._def)}transform(I){return new NG({...YI(this._def),schema:this,typeName:NI.ZodEffects,effect:{type:"transform",transform:I}})}default(I){let G=typeof I=="function"?I:()=>I;return new bZ({...YI(this._def),innerType:this,defaultValue:G,typeName:NI.ZodDefault})}brand(){return new Za({typeName:NI.ZodBranded,type:this,...YI(this._def)})}catch(I){let G=typeof I=="function"?I:()=>I;return new ZZ({...YI(this._def),innerType:this,catchValue:G,typeName:NI.ZodCatch})}describe(I){let G=this.constructor;return new G({...this._def,description:I})}pipe(I){return da.create(this,I)}readonly(){return dZ.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},vL=/^c[^\s-]{8,}$/i,wL=/^[0-9a-z]+$/,iL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oL=/^[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,yL=/^[a-z0-9_-]{21}$/i,EL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,JL=/^[-+]?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)?)??$/,rL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,CL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",gL=/^(?:(?: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])$/,AL=/^(?:(?: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])$/,LL=/^(([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]))$/,kL=/^(([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])$/,zL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ku="((\\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])))",UL=new RegExp(`^${ku}$`);Dc=class l extends pI{_parse(I){if(this._def.coerce&&(I.data=String(I.data)),this._getType(I)!==_.string){let Z=this._getOrReturnCtx(I);return q(Z,{code:M.invalid_type,expected:_.string,received:Z.parsedType}),aI}let c=new Ql,b;for(let Z of this._def.checks)if(Z.kind==="min")I.data.length<Z.value&&(b=this._getOrReturnCtx(I,b),q(b,{code:M.too_small,minimum:Z.value,type:"string",inclusive:!0,exact:!1,message:Z.message}),c.dirty());else if(Z.kind==="max")I.data.length>Z.value&&(b=this._getOrReturnCtx(I,b),q(b,{code:M.too_big,maximum:Z.value,type:"string",inclusive:!0,exact:!1,message:Z.message}),c.dirty());else if(Z.kind==="length"){let d=I.data.length>Z.value,W=I.data.length<Z.value;(d||W)&&(b=this._getOrReturnCtx(I,b),d?q(b,{code:M.too_big,maximum:Z.value,type:"string",inclusive:!0,exact:!0,message:Z.message}):W&&q(b,{code:M.too_small,minimum:Z.value,type:"string",inclusive:!0,exact:!0,message:Z.message}),c.dirty())}else if(Z.kind==="email")rL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"email",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="emoji")XV||(XV=new RegExp(CL,"u")),XV.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"emoji",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="uuid")oL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"uuid",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="nanoid")yL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"nanoid",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="cuid")vL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"cuid",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="cuid2")wL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"cuid2",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="ulid")iL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"ulid",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="url")try{new URL(I.data)}catch{b=this._getOrReturnCtx(I,b),q(b,{validation:"url",code:M.invalid_string,message:Z.message}),c.dirty()}else Z.kind==="regex"?(Z.regex.lastIndex=0,Z.regex.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"regex",code:M.invalid_string,message:Z.message}),c.dirty())):Z.kind==="trim"?I.data=I.data.trim():Z.kind==="includes"?I.data.includes(Z.value,Z.position)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:{includes:Z.value,position:Z.position},message:Z.message}),c.dirty()):Z.kind==="toLowerCase"?I.data=I.data.toLowerCase():Z.kind==="toUpperCase"?I.data=I.data.toUpperCase():Z.kind==="startsWith"?I.data.startsWith(Z.value)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:{startsWith:Z.value},message:Z.message}),c.dirty()):Z.kind==="endsWith"?I.data.endsWith(Z.value)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:{endsWith:Z.value},message:Z.message}),c.dirty()):Z.kind==="datetime"?xu(Z).test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:"datetime",message:Z.message}),c.dirty()):Z.kind==="date"?UL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:"date",message:Z.message}),c.dirty()):Z.kind==="time"?BL(Z).test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:"time",message:Z.message}),c.dirty()):Z.kind==="duration"?JL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"duration",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="ip"?OL(I.data,Z.version)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"ip",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="jwt"?ML(I.data,Z.alg)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"jwt",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="cidr"?jL(I.data,Z.version)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"cidr",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="base64"?zL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"base64",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="base64url"?xL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"base64url",code:M.invalid_string,message:Z.message}),c.dirty()):hI.assertNever(Z);return{status:c.value,value:I.data}}_regex(I,G,c){return this.refinement(b=>I.test(b),{validation:G,code:M.invalid_string,...lI.errToObj(c)})}_addCheck(I){return new l({...this._def,checks:[...this._def.checks,I]})}email(I){return this._addCheck({kind:"email",...lI.errToObj(I)})}url(I){return this._addCheck({kind:"url",...lI.errToObj(I)})}emoji(I){return this._addCheck({kind:"emoji",...lI.errToObj(I)})}uuid(I){return this._addCheck({kind:"uuid",...lI.errToObj(I)})}nanoid(I){return this._addCheck({kind:"nanoid",...lI.errToObj(I)})}cuid(I){return this._addCheck({kind:"cuid",...lI.errToObj(I)})}cuid2(I){return this._addCheck({kind:"cuid2",...lI.errToObj(I)})}ulid(I){return this._addCheck({kind:"ulid",...lI.errToObj(I)})}base64(I){return this._addCheck({kind:"base64",...lI.errToObj(I)})}base64url(I){return this._addCheck({kind:"base64url",...lI.errToObj(I)})}jwt(I){return this._addCheck({kind:"jwt",...lI.errToObj(I)})}ip(I){return this._addCheck({kind:"ip",...lI.errToObj(I)})}cidr(I){return this._addCheck({kind:"cidr",...lI.errToObj(I)})}datetime(I){return typeof I=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:I}):this._addCheck({kind:"datetime",precision:typeof I?.precision>"u"?null:I?.precision,offset:I?.offset??!1,local:I?.local??!1,...lI.errToObj(I?.message)})}date(I){return this._addCheck({kind:"date",message:I})}time(I){return typeof I=="string"?this._addCheck({kind:"time",precision:null,message:I}):this._addCheck({kind:"time",precision:typeof I?.precision>"u"?null:I?.precision,...lI.errToObj(I?.message)})}duration(I){return this._addCheck({kind:"duration",...lI.errToObj(I)})}regex(I,G){return this._addCheck({kind:"regex",regex:I,...lI.errToObj(G)})}includes(I,G){return this._addCheck({kind:"includes",value:I,position:G?.position,...lI.errToObj(G?.message)})}startsWith(I,G){return this._addCheck({kind:"startsWith",value:I,...lI.errToObj(G)})}endsWith(I,G){return this._addCheck({kind:"endsWith",value:I,...lI.errToObj(G)})}min(I,G){return this._addCheck({kind:"min",value:I,...lI.errToObj(G)})}max(I,G){return this._addCheck({kind:"max",value:I,...lI.errToObj(G)})}length(I,G){return this._addCheck({kind:"length",value:I,...lI.errToObj(G)})}nonempty(I){return this.min(1,lI.errToObj(I))}trim(){return new l({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new l({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new l({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(I=>I.kind==="datetime")}get isDate(){return!!this._def.checks.find(I=>I.kind==="date")}get isTime(){return!!this._def.checks.find(I=>I.kind==="time")}get isDuration(){return!!this._def.checks.find(I=>I.kind==="duration")}get isEmail(){return!!this._def.checks.find(I=>I.kind==="email")}get isURL(){return!!this._def.checks.find(I=>I.kind==="url")}get isEmoji(){return!!this._def.checks.find(I=>I.kind==="emoji")}get isUUID(){return!!this._def.checks.find(I=>I.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(I=>I.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(I=>I.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(I=>I.kind==="cuid2")}get isULID(){return!!this._def.checks.find(I=>I.kind==="ulid")}get isIP(){return!!this._def.checks.find(I=>I.kind==="ip")}get isCIDR(){return!!this._def.checks.find(I=>I.kind==="cidr")}get isBase64(){return!!this._def.checks.find(I=>I.kind==="base64")}get isBase64url(){return!!this._def.checks.find(I=>I.kind==="base64url")}get minLength(){let I=null;for(let G of this._def.checks)G.kind==="min"&&(I===null||G.value>I)&&(I=G.value);return I}get maxLength(){let I=null;for(let G of this._def.checks)G.kind==="max"&&(I===null||G.value<I)&&(I=G.value);return I}};Dc.create=l=>new Dc({checks:[],typeName:NI.ZodString,coerce:l?.coerce??!1,...YI(l)});Sb=class l extends pI{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(I){if(this._def.coerce&&(I.data=Number(I.data)),this._getType(I)!==_.number){let Z=this._getOrReturnCtx(I);return q(Z,{code:M.invalid_type,expected:_.number,received:Z.parsedType}),aI}let c,b=new Ql;for(let Z of this._def.checks)Z.kind==="int"?hI.isInteger(I.data)||(c=this._getOrReturnCtx(I,c),q(c,{code:M.invalid_type,expected:"integer",received:"float",message:Z.message}),b.dirty()):Z.kind==="min"?(Z.inclusive?I.data<Z.value:I.data<=Z.value)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.too_small,minimum:Z.value,type:"number",inclusive:Z.inclusive,exact:!1,message:Z.message}),b.dirty()):Z.kind==="max"?(Z.inclusive?I.data>Z.value:I.data>=Z.value)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.too_big,maximum:Z.value,type:"number",inclusive:Z.inclusive,exact:!1,message:Z.message}),b.dirty()):Z.kind==="multipleOf"?KL(I.data,Z.value)!==0&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.not_multiple_of,multipleOf:Z.value,message:Z.message}),b.dirty()):Z.kind==="finite"?Number.isFinite(I.data)||(c=this._getOrReturnCtx(I,c),q(c,{code:M.not_finite,message:Z.message}),b.dirty()):hI.assertNever(Z);return{status:b.value,value:I.data}}gte(I,G){return this.setLimit("min",I,!0,lI.toString(G))}gt(I,G){return this.setLimit("min",I,!1,lI.toString(G))}lte(I,G){return this.setLimit("max",I,!0,lI.toString(G))}lt(I,G){return this.setLimit("max",I,!1,lI.toString(G))}setLimit(I,G,c,b){return new l({...this._def,checks:[...this._def.checks,{kind:I,value:G,inclusive:c,message:lI.toString(b)}]})}_addCheck(I){return new l({...this._def,checks:[...this._def.checks,I]})}int(I){return this._addCheck({kind:"int",message:lI.toString(I)})}positive(I){return this._addCheck({kind:"min",value:0,inclusive:!1,message:lI.toString(I)})}negative(I){return this._addCheck({kind:"max",value:0,inclusive:!1,message:lI.toString(I)})}nonpositive(I){return this._addCheck({kind:"max",value:0,inclusive:!0,message:lI.toString(I)})}nonnegative(I){return this._addCheck({kind:"min",value:0,inclusive:!0,message:lI.toString(I)})}multipleOf(I,G){return this._addCheck({kind:"multipleOf",value:I,message:lI.toString(G)})}finite(I){return this._addCheck({kind:"finite",message:lI.toString(I)})}safe(I){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:lI.toString(I)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:lI.toString(I)})}get minValue(){let I=null;for(let G of this._def.checks)G.kind==="min"&&(I===null||G.value>I)&&(I=G.value);return I}get maxValue(){let I=null;for(let G of this._def.checks)G.kind==="max"&&(I===null||G.value<I)&&(I=G.value);return I}get isInt(){return!!this._def.checks.find(I=>I.kind==="int"||I.kind==="multipleOf"&&hI.isInteger(I.value))}get isFinite(){let I=null,G=null;for(let c of this._def.checks){if(c.kind==="finite"||c.kind==="int"||c.kind==="multipleOf")return!0;c.kind==="min"?(G===null||c.value>G)&&(G=c.value):c.kind==="max"&&(I===null||c.value<I)&&(I=c.value)}return Number.isFinite(G)&&Number.isFinite(I)}};Sb.create=l=>new Sb({checks:[],typeName:NI.ZodNumber,coerce:l?.coerce||!1,...YI(l)});fb=class l extends pI{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(I){if(this._def.coerce)try{I.data=BigInt(I.data)}catch{return this._getInvalidInput(I)}if(this._getType(I)!==_.bigint)return this._getInvalidInput(I);let c,b=new Ql;for(let Z of this._def.checks)Z.kind==="min"?(Z.inclusive?I.data<Z.value:I.data<=Z.value)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.too_small,type:"bigint",minimum:Z.value,inclusive:Z.inclusive,message:Z.message}),b.dirty()):Z.kind==="max"?(Z.inclusive?I.data>Z.value:I.data>=Z.value)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.too_big,type:"bigint",maximum:Z.value,inclusive:Z.inclusive,message:Z.message}),b.dirty()):Z.kind==="multipleOf"?I.data%Z.value!==BigInt(0)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.not_multiple_of,multipleOf:Z.value,message:Z.message}),b.dirty()):hI.assertNever(Z);return{status:b.value,value:I.data}}_getInvalidInput(I){let G=this._getOrReturnCtx(I);return q(G,{code:M.invalid_type,expected:_.bigint,received:G.parsedType}),aI}gte(I,G){return this.setLimit("min",I,!0,lI.toString(G))}gt(I,G){return this.setLimit("min",I,!1,lI.toString(G))}lte(I,G){return this.setLimit("max",I,!0,lI.toString(G))}lt(I,G){return this.setLimit("max",I,!1,lI.toString(G))}setLimit(I,G,c,b){return new l({...this._def,checks:[...this._def.checks,{kind:I,value:G,inclusive:c,message:lI.toString(b)}]})}_addCheck(I){return new l({...this._def,checks:[...this._def.checks,I]})}positive(I){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:lI.toString(I)})}negative(I){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:lI.toString(I)})}nonpositive(I){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:lI.toString(I)})}nonnegative(I){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:lI.toString(I)})}multipleOf(I,G){return this._addCheck({kind:"multipleOf",value:I,message:lI.toString(G)})}get minValue(){let I=null;for(let G of this._def.checks)G.kind==="min"&&(I===null||G.value>I)&&(I=G.value);return I}get maxValue(){let I=null;for(let G of this._def.checks)G.kind==="max"&&(I===null||G.value<I)&&(I=G.value);return I}};fb.create=l=>new fb({checks:[],typeName:NI.ZodBigInt,coerce:l?.coerce??!1,...YI(l)});Db=class extends pI{_parse(I){if(this._def.coerce&&(I.data=!!I.data),this._getType(I)!==_.boolean){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.boolean,received:c.parsedType}),aI}return gl(I.data)}};Db.create=l=>new Db({typeName:NI.ZodBoolean,coerce:l?.coerce||!1,...YI(l)});Tb=class l extends pI{_parse(I){if(this._def.coerce&&(I.data=new Date(I.data)),this._getType(I)!==_.date){let Z=this._getOrReturnCtx(I);return q(Z,{code:M.invalid_type,expected:_.date,received:Z.parsedType}),aI}if(Number.isNaN(I.data.getTime())){let Z=this._getOrReturnCtx(I);return q(Z,{code:M.invalid_date}),aI}let c=new Ql,b;for(let Z of this._def.checks)Z.kind==="min"?I.data.getTime()<Z.value&&(b=this._getOrReturnCtx(I,b),q(b,{code:M.too_small,message:Z.message,inclusive:!0,exact:!1,minimum:Z.value,type:"date"}),c.dirty()):Z.kind==="max"?I.data.getTime()>Z.value&&(b=this._getOrReturnCtx(I,b),q(b,{code:M.too_big,message:Z.message,inclusive:!0,exact:!1,maximum:Z.value,type:"date"}),c.dirty()):hI.assertNever(Z);return{status:c.value,value:new Date(I.data.getTime())}}_addCheck(I){return new l({...this._def,checks:[...this._def.checks,I]})}min(I,G){return this._addCheck({kind:"min",value:I.getTime(),message:lI.toString(G)})}max(I,G){return this._addCheck({kind:"max",value:I.getTime(),message:lI.toString(G)})}get minDate(){let I=null;for(let G of this._def.checks)G.kind==="min"&&(I===null||G.value>I)&&(I=G.value);return I!=null?new Date(I):null}get maxDate(){let I=null;for(let G of this._def.checks)G.kind==="max"&&(I===null||G.value<I)&&(I=G.value);return I!=null?new Date(I):null}};Tb.create=l=>new Tb({checks:[],coerce:l?.coerce||!1,typeName:NI.ZodDate,...YI(l)});Zd=class extends pI{_parse(I){if(this._getType(I)!==_.symbol){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.symbol,received:c.parsedType}),aI}return gl(I.data)}};Zd.create=l=>new Zd({typeName:NI.ZodSymbol,...YI(l)});qb=class extends pI{_parse(I){if(this._getType(I)!==_.undefined){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.undefined,received:c.parsedType}),aI}return gl(I.data)}};qb.create=l=>new qb({typeName:NI.ZodUndefined,...YI(l)});Pb=class extends pI{_parse(I){if(this._getType(I)!==_.null){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.null,received:c.parsedType}),aI}return gl(I.data)}};Pb.create=l=>new Pb({typeName:NI.ZodNull,...YI(l)});Tc=class extends pI{constructor(){super(...arguments),this._any=!0}_parse(I){return gl(I.data)}};Tc.create=l=>new Tc({typeName:NI.ZodAny,...YI(l)});tc=class extends pI{constructor(){super(...arguments),this._unknown=!0}_parse(I){return gl(I.data)}};tc.create=l=>new tc({typeName:NI.ZodUnknown,...YI(l)});oG=class extends pI{_parse(I){let G=this._getOrReturnCtx(I);return q(G,{code:M.invalid_type,expected:_.never,received:G.parsedType}),aI}};oG.create=l=>new oG({typeName:NI.ZodNever,...YI(l)});dd=class extends pI{_parse(I){if(this._getType(I)!==_.undefined){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.void,received:c.parsedType}),aI}return gl(I.data)}};dd.create=l=>new dd({typeName:NI.ZodVoid,...YI(l)});sc=class l extends pI{_parse(I){let{ctx:G,status:c}=this._processInputParams(I),b=this._def;if(G.parsedType!==_.array)return q(G,{code:M.invalid_type,expected:_.array,received:G.parsedType}),aI;if(b.exactLength!==null){let d=G.data.length>b.exactLength.value,W=G.data.length<b.exactLength.value;(d||W)&&(q(G,{code:d?M.too_big:M.too_small,minimum:W?b.exactLength.value:void 0,maximum:d?b.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:b.exactLength.message}),c.dirty())}if(b.minLength!==null&&G.data.length<b.minLength.value&&(q(G,{code:M.too_small,minimum:b.minLength.value,type:"array",inclusive:!0,exact:!1,message:b.minLength.message}),c.dirty()),b.maxLength!==null&&G.data.length>b.maxLength.value&&(q(G,{code:M.too_big,maximum:b.maxLength.value,type:"array",inclusive:!0,exact:!1,message:b.maxLength.message}),c.dirty()),G.common.async)return Promise.all([...G.data].map((d,W)=>b.type._parseAsync(new mG(G,d,G.path,W)))).then(d=>Ql.mergeArray(c,d));let Z=[...G.data].map((d,W)=>b.type._parseSync(new mG(G,d,G.path,W)));return Ql.mergeArray(c,Z)}get element(){return this._def.type}min(I,G){return new l({...this._def,minLength:{value:I,message:lI.toString(G)}})}max(I,G){return new l({...this._def,maxLength:{value:I,message:lI.toString(G)}})}length(I,G){return new l({...this._def,exactLength:{value:I,message:lI.toString(G)}})}nonempty(I){return this.min(1,I)}};sc.create=(l,I)=>new sc({type:l,minLength:null,maxLength:null,exactLength:null,typeName:NI.ZodArray,...YI(I)});Ml=class l extends pI{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let I=this._def.shape(),G=hI.objectKeys(I);return this._cached={shape:I,keys:G},this._cached}_parse(I){if(this._getType(I)!==_.object){let m=this._getOrReturnCtx(I);return q(m,{code:M.invalid_type,expected:_.object,received:m.parsedType}),aI}let{status:c,ctx:b}=this._processInputParams(I),{shape:Z,keys:d}=this._getCached(),W=[];if(!(this._def.catchall instanceof oG&&this._def.unknownKeys==="strip"))for(let m in b.data)d.includes(m)||W.push(m);let a=[];for(let m of d){let N=Z[m],e=b.data[m];a.push({key:{status:"valid",value:m},value:N._parse(new mG(b,e,b.path,m)),alwaysSet:m in b.data})}if(this._def.catchall instanceof oG){let m=this._def.unknownKeys;if(m==="passthrough")for(let N of W)a.push({key:{status:"valid",value:N},value:{status:"valid",value:b.data[N]}});else if(m==="strict")W.length>0&&(q(b,{code:M.unrecognized_keys,keys:W}),c.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let m=this._def.catchall;for(let N of W){let e=b.data[N];a.push({key:{status:"valid",value:N},value:m._parse(new mG(b,e,b.path,N)),alwaysSet:N in b.data})}}return b.common.async?Promise.resolve().then(async()=>{let m=[];for(let N of a){let e=await N.key,Y=await N.value;m.push({key:e,value:Y,alwaysSet:N.alwaysSet})}return m}).then(m=>Ql.mergeObjectSync(c,m)):Ql.mergeObjectSync(c,a)}get shape(){return this._def.shape()}strict(I){return lI.errToObj,new l({...this._def,unknownKeys:"strict",...I!==void 0?{errorMap:(G,c)=>{let b=this._def.errorMap?.(G,c).message??c.defaultError;return G.code==="unrecognized_keys"?{message:lI.errToObj(I).message??b}:{message:b}}}:{}})}strip(){return new l({...this._def,unknownKeys:"strip"})}passthrough(){return new l({...this._def,unknownKeys:"passthrough"})}extend(I){return new l({...this._def,shape:()=>({...this._def.shape(),...I})})}merge(I){return new l({unknownKeys:I._def.unknownKeys,catchall:I._def.catchall,shape:()=>({...this._def.shape(),...I._def.shape()}),typeName:NI.ZodObject})}setKey(I,G){return this.augment({[I]:G})}catchall(I){return new l({...this._def,catchall:I})}pick(I){let G={};for(let c of hI.objectKeys(I))I[c]&&this.shape[c]&&(G[c]=this.shape[c]);return new l({...this._def,shape:()=>G})}omit(I){let G={};for(let c of hI.objectKeys(this.shape))I[c]||(G[c]=this.shape[c]);return new l({...this._def,shape:()=>G})}deepPartial(){return bd(this)}partial(I){let G={};for(let c of hI.objectKeys(this.shape)){let b=this.shape[c];I&&!I[c]?G[c]=b:G[c]=b.optional()}return new l({...this._def,shape:()=>G})}required(I){let G={};for(let c of hI.objectKeys(this.shape))if(I&&!I[c])G[c]=this.shape[c];else{let Z=this.shape[c];for(;Z instanceof aG;)Z=Z._def.innerType;G[c]=Z}return new l({...this._def,shape:()=>G})}keyof(){return Uu(hI.objectKeys(this.shape))}};Ml.create=(l,I)=>new Ml({shape:()=>l,unknownKeys:"strip",catchall:oG.create(),typeName:NI.ZodObject,...YI(I)});Ml.strictCreate=(l,I)=>new Ml({shape:()=>l,unknownKeys:"strict",catchall:oG.create(),typeName:NI.ZodObject,...YI(I)});Ml.lazycreate=(l,I)=>new Ml({shape:l,unknownKeys:"strip",catchall:oG.create(),typeName:NI.ZodObject,...YI(I)});_b=class extends pI{_parse(I){let{ctx:G}=this._processInputParams(I),c=this._def.options;function b(Z){for(let W of Z)if(W.result.status==="valid")return W.result;for(let W of Z)if(W.result.status==="dirty")return G.common.issues.push(...W.ctx.common.issues),W.result;let d=Z.map(W=>new Cl(W.ctx.common.issues));return q(G,{code:M.invalid_union,unionErrors:d}),aI}if(G.common.async)return Promise.all(c.map(async Z=>{let d={...G,common:{...G.common,issues:[]},parent:null};return{result:await Z._parseAsync({data:G.data,path:G.path,parent:d}),ctx:d}})).then(b);{let Z,d=[];for(let a of c){let m={...G,common:{...G.common,issues:[]},parent:null},N=a._parseSync({data:G.data,path:G.path,parent:m});if(N.status==="valid")return N;N.status==="dirty"&&!Z&&(Z={result:N,ctx:m}),m.common.issues.length&&d.push(m.common.issues)}if(Z)return G.common.issues.push(...Z.ctx.common.issues),Z.result;let W=d.map(a=>new Cl(a));return q(G,{code:M.invalid_union,unionErrors:W}),aI}}get options(){return this._def.options}};_b.create=(l,I)=>new _b({options:l,typeName:NI.ZodUnion,...YI(I)});hc=l=>l instanceof IZ?hc(l.schema):l instanceof NG?hc(l.innerType()):l instanceof lZ?[l.value]:l instanceof GZ?l.options:l instanceof cZ?hI.objectValues(l.enum):l instanceof bZ?hc(l._def.innerType):l instanceof qb?[void 0]:l instanceof Pb?[null]:l instanceof aG?[void 0,...hc(l.unwrap())]:l instanceof KG?[null,...hc(l.unwrap())]:l instanceof Za||l instanceof dZ?hc(l.unwrap()):l instanceof ZZ?hc(l._def.innerType):[],LN=class l extends pI{_parse(I){let{ctx:G}=this._processInputParams(I);if(G.parsedType!==_.object)return q(G,{code:M.invalid_type,expected:_.object,received:G.parsedType}),aI;let c=this.discriminator,b=G.data[c],Z=this.optionsMap.get(b);return Z?G.common.async?Z._parseAsync({data:G.data,path:G.path,parent:G}):Z._parseSync({data:G.data,path:G.path,parent:G}):(q(G,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[c]}),aI)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(I,G,c){let b=new Map;for(let Z of G){let d=hc(Z.shape[I]);if(!d.length)throw new Error(`A discriminator value for key \`${I}\` could not be extracted from all schema options`);for(let W of d){if(b.has(W))throw new Error(`Discriminator property ${String(I)} has duplicate value ${String(W)}`);b.set(W,Z)}}return new l({typeName:NI.ZodDiscriminatedUnion,discriminator:I,options:G,optionsMap:b,...YI(c)})}};$b=class extends pI{_parse(I){let{status:G,ctx:c}=this._processInputParams(I),b=(Z,d)=>{if(gN(Z)||gN(d))return aI;let W=QV(Z.value,d.value);return W.valid?((AN(Z)||AN(d))&&G.dirty(),{status:G.value,value:W.data}):(q(c,{code:M.invalid_intersection_types}),aI)};return c.common.async?Promise.all([this._def.left._parseAsync({data:c.data,path:c.path,parent:c}),this._def.right._parseAsync({data:c.data,path:c.path,parent:c})]).then(([Z,d])=>b(Z,d)):b(this._def.left._parseSync({data:c.data,path:c.path,parent:c}),this._def.right._parseSync({data:c.data,path:c.path,parent:c}))}};$b.create=(l,I,G)=>new $b({left:l,right:I,typeName:NI.ZodIntersection,...YI(G)});jG=class l extends pI{_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.parsedType!==_.array)return q(c,{code:M.invalid_type,expected:_.array,received:c.parsedType}),aI;if(c.data.length<this._def.items.length)return q(c,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),aI;!this._def.rest&&c.data.length>this._def.items.length&&(q(c,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),G.dirty());let Z=[...c.data].map((d,W)=>{let a=this._def.items[W]||this._def.rest;return a?a._parse(new mG(c,d,c.path,W)):null}).filter(d=>!!d);return c.common.async?Promise.all(Z).then(d=>Ql.mergeArray(G,d)):Ql.mergeArray(G,Z)}get items(){return this._def.items}rest(I){return new l({...this._def,rest:I})}};jG.create=(l,I)=>{if(!Array.isArray(l))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jG({items:l,typeName:NI.ZodTuple,rest:null,...YI(I)})};kN=class l extends pI{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.parsedType!==_.object)return q(c,{code:M.invalid_type,expected:_.object,received:c.parsedType}),aI;let b=[],Z=this._def.keyType,d=this._def.valueType;for(let W in c.data)b.push({key:Z._parse(new mG(c,W,c.path,W)),value:d._parse(new mG(c,c.data[W],c.path,W)),alwaysSet:W in c.data});return c.common.async?Ql.mergeObjectAsync(G,b):Ql.mergeObjectSync(G,b)}get element(){return this._def.valueType}static create(I,G,c){return G instanceof pI?new l({keyType:I,valueType:G,typeName:NI.ZodRecord,...YI(c)}):new l({keyType:Dc.create(),valueType:I,typeName:NI.ZodRecord,...YI(G)})}},Wd=class extends pI{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.parsedType!==_.map)return q(c,{code:M.invalid_type,expected:_.map,received:c.parsedType}),aI;let b=this._def.keyType,Z=this._def.valueType,d=[...c.data.entries()].map(([W,a],m)=>({key:b._parse(new mG(c,W,c.path,[m,"key"])),value:Z._parse(new mG(c,a,c.path,[m,"value"]))}));if(c.common.async){let W=new Map;return Promise.resolve().then(async()=>{for(let a of d){let m=await a.key,N=await a.value;if(m.status==="aborted"||N.status==="aborted")return aI;(m.status==="dirty"||N.status==="dirty")&&G.dirty(),W.set(m.value,N.value)}return{status:G.value,value:W}})}else{let W=new Map;for(let a of d){let m=a.key,N=a.value;if(m.status==="aborted"||N.status==="aborted")return aI;(m.status==="dirty"||N.status==="dirty")&&G.dirty(),W.set(m.value,N.value)}return{status:G.value,value:W}}}};Wd.create=(l,I,G)=>new Wd({valueType:I,keyType:l,typeName:NI.ZodMap,...YI(G)});ad=class l extends pI{_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.parsedType!==_.set)return q(c,{code:M.invalid_type,expected:_.set,received:c.parsedType}),aI;let b=this._def;b.minSize!==null&&c.data.size<b.minSize.value&&(q(c,{code:M.too_small,minimum:b.minSize.value,type:"set",inclusive:!0,exact:!1,message:b.minSize.message}),G.dirty()),b.maxSize!==null&&c.data.size>b.maxSize.value&&(q(c,{code:M.too_big,maximum:b.maxSize.value,type:"set",inclusive:!0,exact:!1,message:b.maxSize.message}),G.dirty());let Z=this._def.valueType;function d(a){let m=new Set;for(let N of a){if(N.status==="aborted")return aI;N.status==="dirty"&&G.dirty(),m.add(N.value)}return{status:G.value,value:m}}let W=[...c.data.values()].map((a,m)=>Z._parse(new mG(c,a,c.path,m)));return c.common.async?Promise.all(W).then(a=>d(a)):d(W)}min(I,G){return new l({...this._def,minSize:{value:I,message:lI.toString(G)}})}max(I,G){return new l({...this._def,maxSize:{value:I,message:lI.toString(G)}})}size(I,G){return this.min(I,G).max(I,G)}nonempty(I){return this.min(1,I)}};ad.create=(l,I)=>new ad({valueType:l,minSize:null,maxSize:null,typeName:NI.ZodSet,...YI(I)});zN=class l extends pI{constructor(){super(...arguments),this.validate=this.implement}_parse(I){let{ctx:G}=this._processInputParams(I);if(G.parsedType!==_.function)return q(G,{code:M.invalid_type,expected:_.function,received:G.parsedType}),aI;function c(W,a){return ba({data:W,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,Gd(),nc].filter(m=>!!m),issueData:{code:M.invalid_arguments,argumentsError:a}})}function b(W,a){return ba({data:W,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,Gd(),nc].filter(m=>!!m),issueData:{code:M.invalid_return_type,returnTypeError:a}})}let Z={errorMap:G.common.contextualErrorMap},d=G.data;if(this._def.returns instanceof qc){let W=this;return gl(async function(...a){let m=new Cl([]),N=await W._def.args.parseAsync(a,Z).catch(p=>{throw m.addIssue(c(a,p)),m}),e=await Reflect.apply(d,this,N);return await W._def.returns._def.type.parseAsync(e,Z).catch(p=>{throw m.addIssue(b(e,p)),m})})}else{let W=this;return gl(function(...a){let m=W._def.args.safeParse(a,Z);if(!m.success)throw new Cl([c(a,m.error)]);let N=Reflect.apply(d,this,m.data),e=W._def.returns.safeParse(N,Z);if(!e.success)throw new Cl([b(N,e.error)]);return e.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...I){return new l({...this._def,args:jG.create(I).rest(tc.create())})}returns(I){return new l({...this._def,returns:I})}implement(I){return this.parse(I)}strictImplement(I){return this.parse(I)}static create(I,G,c){return new l({args:I||jG.create([]).rest(tc.create()),returns:G||tc.create(),typeName:NI.ZodFunction,...YI(c)})}},IZ=class extends pI{get schema(){return this._def.getter()}_parse(I){let{ctx:G}=this._processInputParams(I);return this._def.getter()._parse({data:G.data,path:G.path,parent:G})}};IZ.create=(l,I)=>new IZ({getter:l,typeName:NI.ZodLazy,...YI(I)});lZ=class extends pI{_parse(I){if(I.data!==this._def.value){let G=this._getOrReturnCtx(I);return q(G,{received:G.data,code:M.invalid_literal,expected:this._def.value}),aI}return{status:"valid",value:I.data}}get value(){return this._def.value}};lZ.create=(l,I)=>new lZ({value:l,typeName:NI.ZodLiteral,...YI(I)});GZ=class l extends pI{_parse(I){if(typeof I.data!="string"){let G=this._getOrReturnCtx(I),c=this._def.values;return q(G,{expected:hI.joinValues(c),received:G.parsedType,code:M.invalid_type}),aI}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(I.data)){let G=this._getOrReturnCtx(I),c=this._def.values;return q(G,{received:G.data,code:M.invalid_enum_value,options:c}),aI}return gl(I.data)}get options(){return this._def.values}get enum(){let I={};for(let G of this._def.values)I[G]=G;return I}get Values(){let I={};for(let G of this._def.values)I[G]=G;return I}get Enum(){let I={};for(let G of this._def.values)I[G]=G;return I}extract(I,G=this._def){return l.create(I,{...this._def,...G})}exclude(I,G=this._def){return l.create(this.options.filter(c=>!I.includes(c)),{...this._def,...G})}};GZ.create=Uu;cZ=class extends pI{_parse(I){let G=hI.getValidEnumValues(this._def.values),c=this._getOrReturnCtx(I);if(c.parsedType!==_.string&&c.parsedType!==_.number){let b=hI.objectValues(G);return q(c,{expected:hI.joinValues(b),received:c.parsedType,code:M.invalid_type}),aI}if(this._cache||(this._cache=new Set(hI.getValidEnumValues(this._def.values))),!this._cache.has(I.data)){let b=hI.objectValues(G);return q(c,{received:c.data,code:M.invalid_enum_value,options:b}),aI}return gl(I.data)}get enum(){return this._def.values}};cZ.create=(l,I)=>new cZ({values:l,typeName:NI.ZodNativeEnum,...YI(I)});qc=class extends pI{unwrap(){return this._def.type}_parse(I){let{ctx:G}=this._processInputParams(I);if(G.parsedType!==_.promise&&G.common.async===!1)return q(G,{code:M.invalid_type,expected:_.promise,received:G.parsedType}),aI;let c=G.parsedType===_.promise?G.data:Promise.resolve(G.data);return gl(c.then(b=>this._def.type.parseAsync(b,{path:G.path,errorMap:G.common.contextualErrorMap})))}};qc.create=(l,I)=>new qc({type:l,typeName:NI.ZodPromise,...YI(I)});NG=class extends pI{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===NI.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(I){let{status:G,ctx:c}=this._processInputParams(I),b=this._def.effect||null,Z={addIssue:d=>{q(c,d),d.fatal?G.abort():G.dirty()},get path(){return c.path}};if(Z.addIssue=Z.addIssue.bind(Z),b.type==="preprocess"){let d=b.transform(c.data,Z);if(c.common.async)return Promise.resolve(d).then(async W=>{if(G.value==="aborted")return aI;let a=await this._def.schema._parseAsync({data:W,path:c.path,parent:c});return a.status==="aborted"?aI:a.status==="dirty"?Kb(a.value):G.value==="dirty"?Kb(a.value):a});{if(G.value==="aborted")return aI;let W=this._def.schema._parseSync({data:d,path:c.path,parent:c});return W.status==="aborted"?aI:W.status==="dirty"?Kb(W.value):G.value==="dirty"?Kb(W.value):W}}if(b.type==="refinement"){let d=W=>{let a=b.refinement(W,Z);if(c.common.async)return Promise.resolve(a);if(a instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return W};if(c.common.async===!1){let W=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});return W.status==="aborted"?aI:(W.status==="dirty"&&G.dirty(),d(W.value),{status:G.value,value:W.value})}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then(W=>W.status==="aborted"?aI:(W.status==="dirty"&&G.dirty(),d(W.value).then(()=>({status:G.value,value:W.value}))))}if(b.type==="transform")if(c.common.async===!1){let d=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});if(!fc(d))return aI;let W=b.transform(d.value,Z);if(W instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:G.value,value:W}}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then(d=>fc(d)?Promise.resolve(b.transform(d.value,Z)).then(W=>({status:G.value,value:W})):aI);hI.assertNever(b)}};NG.create=(l,I,G)=>new NG({schema:l,typeName:NI.ZodEffects,effect:I,...YI(G)});NG.createWithPreprocess=(l,I,G)=>new NG({schema:I,effect:{type:"preprocess",transform:l},typeName:NI.ZodEffects,...YI(G)});aG=class extends pI{_parse(I){return this._getType(I)===_.undefined?gl(void 0):this._def.innerType._parse(I)}unwrap(){return this._def.innerType}};aG.create=(l,I)=>new aG({innerType:l,typeName:NI.ZodOptional,...YI(I)});KG=class extends pI{_parse(I){return this._getType(I)===_.null?gl(null):this._def.innerType._parse(I)}unwrap(){return this._def.innerType}};KG.create=(l,I)=>new KG({innerType:l,typeName:NI.ZodNullable,...YI(I)});bZ=class extends pI{_parse(I){let{ctx:G}=this._processInputParams(I),c=G.data;return G.parsedType===_.undefined&&(c=this._def.defaultValue()),this._def.innerType._parse({data:c,path:G.path,parent:G})}removeDefault(){return this._def.innerType}};bZ.create=(l,I)=>new bZ({innerType:l,typeName:NI.ZodDefault,defaultValue:typeof I.default=="function"?I.default:()=>I.default,...YI(I)});ZZ=class extends pI{_parse(I){let{ctx:G}=this._processInputParams(I),c={...G,common:{...G.common,issues:[]}},b=this._def.innerType._parse({data:c.data,path:c.path,parent:{...c}});return cd(b)?b.then(Z=>({status:"valid",value:Z.status==="valid"?Z.value:this._def.catchValue({get error(){return new Cl(c.common.issues)},input:c.data})})):{status:"valid",value:b.status==="valid"?b.value:this._def.catchValue({get error(){return new Cl(c.common.issues)},input:c.data})}}removeCatch(){return this._def.innerType}};ZZ.create=(l,I)=>new ZZ({innerType:l,typeName:NI.ZodCatch,catchValue:typeof I.catch=="function"?I.catch:()=>I.catch,...YI(I)});md=class extends pI{_parse(I){if(this._getType(I)!==_.nan){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.nan,received:c.parsedType}),aI}return{status:"valid",value:I.data}}};md.create=l=>new md({typeName:NI.ZodNaN,...YI(l)});SL=Symbol("zod_brand"),Za=class extends pI{_parse(I){let{ctx:G}=this._processInputParams(I),c=G.data;return this._def.type._parse({data:c,path:G.path,parent:G})}unwrap(){return this._def.type}},da=class l extends pI{_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.common.async)return(async()=>{let Z=await this._def.in._parseAsync({data:c.data,path:c.path,parent:c});return Z.status==="aborted"?aI:Z.status==="dirty"?(G.dirty(),Kb(Z.value)):this._def.out._parseAsync({data:Z.value,path:c.path,parent:c})})();{let b=this._def.in._parseSync({data:c.data,path:c.path,parent:c});return b.status==="aborted"?aI:b.status==="dirty"?(G.dirty(),{status:"dirty",value:b.value}):this._def.out._parseSync({data:b.value,path:c.path,parent:c})}}static create(I,G){return new l({in:I,out:G,typeName:NI.ZodPipeline})}},dZ=class extends pI{_parse(I){let G=this._def.innerType._parse(I),c=b=>(fc(b)&&(b.value=Object.freeze(b.value)),b);return cd(G)?G.then(b=>c(b)):c(G)}unwrap(){return this._def.innerType}};dZ.create=(l,I)=>new dZ({innerType:l,typeName:NI.ZodReadonly,...YI(I)});fL={object:Ml.lazycreate};(function(l){l.ZodString="ZodString",l.ZodNumber="ZodNumber",l.ZodNaN="ZodNaN",l.ZodBigInt="ZodBigInt",l.ZodBoolean="ZodBoolean",l.ZodDate="ZodDate",l.ZodSymbol="ZodSymbol",l.ZodUndefined="ZodUndefined",l.ZodNull="ZodNull",l.ZodAny="ZodAny",l.ZodUnknown="ZodUnknown",l.ZodNever="ZodNever",l.ZodVoid="ZodVoid",l.ZodArray="ZodArray",l.ZodObject="ZodObject",l.ZodUnion="ZodUnion",l.ZodDiscriminatedUnion="ZodDiscriminatedUnion",l.ZodIntersection="ZodIntersection",l.ZodTuple="ZodTuple",l.ZodRecord="ZodRecord",l.ZodMap="ZodMap",l.ZodSet="ZodSet",l.ZodFunction="ZodFunction",l.ZodLazy="ZodLazy",l.ZodLiteral="ZodLiteral",l.ZodEnum="ZodEnum",l.ZodEffects="ZodEffects",l.ZodNativeEnum="ZodNativeEnum",l.ZodOptional="ZodOptional",l.ZodNullable="ZodNullable",l.ZodDefault="ZodDefault",l.ZodCatch="ZodCatch",l.ZodPromise="ZodPromise",l.ZodBranded="ZodBranded",l.ZodPipeline="ZodPipeline",l.ZodReadonly="ZodReadonly"})(NI||(NI={}));DL=(l,I={message:`Input not instance of ${l.name}`})=>Bu(G=>G instanceof l,I),Ou=Dc.create,Mu=Sb.create,TL=md.create,qL=fb.create,ju=Db.create,PL=Tb.create,_L=Zd.create,$L=qb.create,Ik=Pb.create,lk=Tc.create,Gk=tc.create,ck=oG.create,bk=dd.create,Zk=sc.create,dk=Ml.create,Wk=Ml.strictCreate,ak=_b.create,mk=LN.create,Nk=$b.create,ek=jG.create,Yk=kN.create,pk=Wd.create,Vk=ad.create,nk=zN.create,hk=IZ.create,tk=lZ.create,sk=GZ.create,Rk=cZ.create,Fk=qc.create,uk=NG.create,Xk=aG.create,Qk=KG.create,Hk=NG.createWithPreprocess,vk=da.create,wk=()=>Ou().optional(),ik=()=>Mu().optional(),ok=()=>ju().optional(),yk={string:(l=>Dc.create({...l,coerce:!0})),number:(l=>Sb.create({...l,coerce:!0})),boolean:(l=>Db.create({...l,coerce:!0})),bigint:(l=>fb.create({...l,coerce:!0})),date:(l=>Tb.create({...l,coerce:!0}))},Ek=aI});var r={};TI(r,{BRAND:()=>SL,DIRTY:()=>Kb,EMPTY_PATH:()=>HL,INVALID:()=>aI,NEVER:()=>Ek,OK:()=>gl,ParseStatus:()=>Ql,Schema:()=>pI,ZodAny:()=>Tc,ZodArray:()=>sc,ZodBigInt:()=>fb,ZodBoolean:()=>Db,ZodBranded:()=>Za,ZodCatch:()=>ZZ,ZodDate:()=>Tb,ZodDefault:()=>bZ,ZodDiscriminatedUnion:()=>LN,ZodEffects:()=>NG,ZodEnum:()=>GZ,ZodError:()=>Cl,ZodFirstPartyTypeKind:()=>NI,ZodFunction:()=>zN,ZodIntersection:()=>$b,ZodIssueCode:()=>M,ZodLazy:()=>IZ,ZodLiteral:()=>lZ,ZodMap:()=>Wd,ZodNaN:()=>md,ZodNativeEnum:()=>cZ,ZodNever:()=>oG,ZodNull:()=>Pb,ZodNullable:()=>KG,ZodNumber:()=>Sb,ZodObject:()=>Ml,ZodOptional:()=>aG,ZodParsedType:()=>_,ZodPipeline:()=>da,ZodPromise:()=>qc,ZodReadonly:()=>dZ,ZodRecord:()=>kN,ZodSchema:()=>pI,ZodSet:()=>ad,ZodString:()=>Dc,ZodSymbol:()=>Zd,ZodTransformer:()=>NG,ZodTuple:()=>jG,ZodType:()=>pI,ZodUndefined:()=>qb,ZodUnion:()=>_b,ZodUnknown:()=>tc,ZodVoid:()=>dd,addIssueToContext:()=>q,any:()=>lk,array:()=>Zk,bigint:()=>qL,boolean:()=>ju,coerce:()=>yk,custom:()=>Bu,date:()=>PL,datetimeRegex:()=>xu,defaultErrorMap:()=>nc,discriminatedUnion:()=>mk,effect:()=>uk,enum:()=>sk,function:()=>nk,getErrorMap:()=>Gd,getParsedType:()=>MG,instanceof:()=>DL,intersection:()=>Nk,isAborted:()=>gN,isAsync:()=>cd,isDirty:()=>AN,isValid:()=>fc,late:()=>fL,lazy:()=>hk,literal:()=>tk,makeIssue:()=>ba,map:()=>pk,nan:()=>TL,nativeEnum:()=>Rk,never:()=>ck,null:()=>Ik,nullable:()=>Qk,number:()=>Mu,object:()=>dk,objectUtil:()=>RV,oboolean:()=>ok,onumber:()=>ik,optional:()=>Xk,ostring:()=>wk,pipeline:()=>vk,preprocess:()=>Hk,promise:()=>Fk,quotelessJson:()=>uL,record:()=>Yk,set:()=>Vk,setErrorMap:()=>QL,strictObject:()=>Wk,string:()=>Ou,symbol:()=>_L,transformer:()=>uk,tuple:()=>ek,undefined:()=>$L,union:()=>ak,unknown:()=>Gk,util:()=>hI,void:()=>bk});var HV=u(()=>{CN();uV();Cu();ca();Ku();rN()});var Nd=u(()=>{HV();HV()});function Jk(l=!1){try{let I=Su.parse(process.env);return vV.info("Environment variables validated successfully"),I}catch(I){if(I instanceof r.ZodError){let G=I.errors.map(c=>`${c.path.join(".")}: ${c.message}`).join(`
|
|
3
|
+
var nL=Object.create;var hV=Object.defineProperty;var hL=Object.getOwnPropertyDescriptor;var tL=Object.getOwnPropertyNames;var sL=Object.getPrototypeOf,RL=Object.prototype.hasOwnProperty;var D=(l=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(l,{get:(I,G)=>(typeof require<"u"?require:I)[G]}):l)(function(l){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+l+'" is not supported')});var u=(l,I)=>()=>(l&&(I=l(l=0)),I);var F=(l,I)=>()=>(I||l((I={exports:{}}).exports,I),I.exports),TI=(l,I)=>{for(var G in I)hV(l,G,{get:I[G],enumerable:!0})},FL=(l,I,G,c)=>{if(I&&typeof I=="object"||typeof I=="function")for(let b of tL(I))!RL.call(l,b)&&b!==G&&hV(l,b,{get:()=>I[b],enumerable:!(c=hL(I,b))||c.enumerable});return l};var Kc=(l,I,G)=>(G=l!=null?nL(sL(l)):{},FL(I||!l||!l.__esModule?hV(G,"default",{value:l,enumerable:!0}):G,l));function tu(l){hu=l}function J(l){function I(c){return nu[c]>=nu[hu]}function G(c,b,Z){let W=`[${new Date().toISOString()}] [${c.toUpperCase()}] [${l}]`;return Z&&Object.keys(Z).length>0?`${W} ${b} ${JSON.stringify(Z)}`:`${W} ${b}`}return{debug(c,b){I("debug")&&console.error(G("debug",c,b))},info(c,b){I("info")&&console.error(G("info",c,b))},warn(c,b){I("warn")&&console.error(G("warn",c,b))},error(c,b,Z){if(I("error")){let d={...Z,...b instanceof Error?{error:b.message,stack:b.stack}:{error:String(b)}};console.error(G("error",c,d))}},child(c){return J(`${l}:${c}`)}}}var nu,hu,T=u(()=>{"use strict";nu={debug:0,info:1,warn:2,error:3},hu="info"});var $l,EN,la,Ga,su,Ru,Fu,uu,Xu,Qu,Hu,vu,wu,iu,tV,sV,ou,yu,Eu,Sc,JN,rl,Ju,bl=u(()=>{"use strict";$l={DEFAULT:8e3,MAX:128e3,MIN:100,PROFILES:{MVP:2e3,PRODUCTION:8e3,ENTERPRISE:16e3},TOOLS:{REPO_MAP:2e3,REPO_MAP_MAX:16e3,HANDOFF:1500,HANDOFF_MAX:5e3,HANDOFF_MIN:500}},EN=$l.DEFAULT,la=$l.MAX,Ga=$l.MIN,su=256,Ru=300*1e3,Fu=50*1024*1024,uu=1.5,Xu=.75,Qu=.1,Hu=50,vu=10*1024*1024,wu="merkle.json",iu={system:.05,skills:.05,context:.65,stack:.05,changes:.1,prefetch:.05,reserve:.05},tV=.3,sV=20,ou=25,yu=2e5,Eu=3600,Sc=13100,JN="domyh-hsa",rl="1.4.13",Ju=".agent/hsa"});var hI,RV,_,MG,ca=u(()=>{(function(l){l.assertEqual=b=>{};function I(b){}l.assertIs=I;function G(b){throw new Error}l.assertNever=G,l.arrayToEnum=b=>{let Z={};for(let d of b)Z[d]=d;return Z},l.getValidEnumValues=b=>{let Z=l.objectKeys(b).filter(W=>typeof b[b[W]]!="number"),d={};for(let W of Z)d[W]=b[W];return l.objectValues(d)},l.objectValues=b=>l.objectKeys(b).map(function(Z){return b[Z]}),l.objectKeys=typeof Object.keys=="function"?b=>Object.keys(b):b=>{let Z=[];for(let d in b)Object.prototype.hasOwnProperty.call(b,d)&&Z.push(d);return Z},l.find=(b,Z)=>{for(let d of b)if(Z(d))return d},l.isInteger=typeof Number.isInteger=="function"?b=>Number.isInteger(b):b=>typeof b=="number"&&Number.isFinite(b)&&Math.floor(b)===b;function c(b,Z=" | "){return b.map(d=>typeof d=="string"?`'${d}'`:d).join(Z)}l.joinValues=c,l.jsonStringifyReplacer=(b,Z)=>typeof Z=="bigint"?Z.toString():Z})(hI||(hI={}));(function(l){l.mergeShapes=(I,G)=>({...I,...G})})(RV||(RV={}));_=hI.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),MG=l=>{switch(typeof l){case"undefined":return _.undefined;case"string":return _.string;case"number":return Number.isNaN(l)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(l)?_.array:l===null?_.null:l.then&&typeof l.then=="function"&&l.catch&&typeof l.catch=="function"?_.promise:typeof Map<"u"&&l instanceof Map?_.map:typeof Set<"u"&&l instanceof Set?_.set:typeof Date<"u"&&l instanceof Date?_.date:_.object;default:return _.unknown}}});var M,uL,Cl,rN=u(()=>{ca();M=hI.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"]),uL=l=>JSON.stringify(l,null,2).replace(/"([^"]+)":/g,"$1:"),Cl=class l extends Error{get errors(){return this.issues}constructor(I){super(),this.issues=[],this.addIssue=c=>{this.issues=[...this.issues,c]},this.addIssues=(c=[])=>{this.issues=[...this.issues,...c]};let G=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,G):this.__proto__=G,this.name="ZodError",this.issues=I}format(I){let G=I||function(Z){return Z.message},c={_errors:[]},b=Z=>{for(let d of Z.issues)if(d.code==="invalid_union")d.unionErrors.map(b);else if(d.code==="invalid_return_type")b(d.returnTypeError);else if(d.code==="invalid_arguments")b(d.argumentsError);else if(d.path.length===0)c._errors.push(G(d));else{let W=c,a=0;for(;a<d.path.length;){let m=d.path[a];a===d.path.length-1?(W[m]=W[m]||{_errors:[]},W[m]._errors.push(G(d))):W[m]=W[m]||{_errors:[]},W=W[m],a++}}};return b(this),c}static assert(I){if(!(I instanceof l))throw new Error(`Not a ZodError: ${I}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,hI.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(I=G=>G.message){let G={},c=[];for(let b of this.issues)if(b.path.length>0){let Z=b.path[0];G[Z]=G[Z]||[],G[Z].push(I(b))}else c.push(I(b));return{formErrors:c,fieldErrors:G}}get formErrors(){return this.flatten()}};Cl.create=l=>new Cl(l)});var XL,nc,FV=u(()=>{rN();ca();XL=(l,I)=>{let G;switch(l.code){case M.invalid_type:l.received===_.undefined?G="Required":G=`Expected ${l.expected}, received ${l.received}`;break;case M.invalid_literal:G=`Invalid literal value, expected ${JSON.stringify(l.expected,hI.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:G=`Unrecognized key(s) in object: ${hI.joinValues(l.keys,", ")}`;break;case M.invalid_union:G="Invalid input";break;case M.invalid_union_discriminator:G=`Invalid discriminator value. Expected ${hI.joinValues(l.options)}`;break;case M.invalid_enum_value:G=`Invalid enum value. Expected ${hI.joinValues(l.options)}, received '${l.received}'`;break;case M.invalid_arguments:G="Invalid function arguments";break;case M.invalid_return_type:G="Invalid function return type";break;case M.invalid_date:G="Invalid date";break;case M.invalid_string:typeof l.validation=="object"?"includes"in l.validation?(G=`Invalid input: must include "${l.validation.includes}"`,typeof l.validation.position=="number"&&(G=`${G} at one or more positions greater than or equal to ${l.validation.position}`)):"startsWith"in l.validation?G=`Invalid input: must start with "${l.validation.startsWith}"`:"endsWith"in l.validation?G=`Invalid input: must end with "${l.validation.endsWith}"`:hI.assertNever(l.validation):l.validation!=="regex"?G=`Invalid ${l.validation}`:G="Invalid";break;case M.too_small:l.type==="array"?G=`Array must contain ${l.exact?"exactly":l.inclusive?"at least":"more than"} ${l.minimum} element(s)`:l.type==="string"?G=`String must contain ${l.exact?"exactly":l.inclusive?"at least":"over"} ${l.minimum} character(s)`:l.type==="number"?G=`Number must be ${l.exact?"exactly equal to ":l.inclusive?"greater than or equal to ":"greater than "}${l.minimum}`:l.type==="bigint"?G=`Number must be ${l.exact?"exactly equal to ":l.inclusive?"greater than or equal to ":"greater than "}${l.minimum}`:l.type==="date"?G=`Date must be ${l.exact?"exactly equal to ":l.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(l.minimum))}`:G="Invalid input";break;case M.too_big:l.type==="array"?G=`Array must contain ${l.exact?"exactly":l.inclusive?"at most":"less than"} ${l.maximum} element(s)`:l.type==="string"?G=`String must contain ${l.exact?"exactly":l.inclusive?"at most":"under"} ${l.maximum} character(s)`:l.type==="number"?G=`Number must be ${l.exact?"exactly":l.inclusive?"less than or equal to":"less than"} ${l.maximum}`:l.type==="bigint"?G=`BigInt must be ${l.exact?"exactly":l.inclusive?"less than or equal to":"less than"} ${l.maximum}`:l.type==="date"?G=`Date must be ${l.exact?"exactly":l.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(l.maximum))}`:G="Invalid input";break;case M.custom:G="Invalid input";break;case M.invalid_intersection_types:G="Intersection results could not be merged";break;case M.not_multiple_of:G=`Number must be a multiple of ${l.multipleOf}`;break;case M.not_finite:G="Number must be finite";break;default:G=I.defaultError,hI.assertNever(l)}return{message:G}},nc=XL});function QL(l){ru=l}function Gd(){return ru}var ru,CN=u(()=>{FV();ru=nc});function q(l,I){let G=Gd(),c=ba({issueData:I,data:l.data,path:l.path,errorMaps:[l.common.contextualErrorMap,l.schemaErrorMap,G,G===nc?void 0:nc].filter(b=>!!b)});l.common.issues.push(c)}var ba,HL,Ql,aI,Kb,gl,gN,AN,fc,cd,uV=u(()=>{CN();FV();ba=l=>{let{data:I,path:G,errorMaps:c,issueData:b}=l,Z=[...G,...b.path||[]],d={...b,path:Z};if(b.message!==void 0)return{...b,path:Z,message:b.message};let W="",a=c.filter(m=>!!m).slice().reverse();for(let m of a)W=m(d,{data:I,defaultError:W}).message;return{...b,path:Z,message:W}},HL=[];Ql=class l{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(I,G){let c=[];for(let b of G){if(b.status==="aborted")return aI;b.status==="dirty"&&I.dirty(),c.push(b.value)}return{status:I.value,value:c}}static async mergeObjectAsync(I,G){let c=[];for(let b of G){let Z=await b.key,d=await b.value;c.push({key:Z,value:d})}return l.mergeObjectSync(I,c)}static mergeObjectSync(I,G){let c={};for(let b of G){let{key:Z,value:d}=b;if(Z.status==="aborted"||d.status==="aborted")return aI;Z.status==="dirty"&&I.dirty(),d.status==="dirty"&&I.dirty(),Z.value!=="__proto__"&&(typeof d.value<"u"||b.alwaysSet)&&(c[Z.value]=d.value)}return{status:I.value,value:c}}},aI=Object.freeze({status:"aborted"}),Kb=l=>({status:"dirty",value:l}),gl=l=>({status:"valid",value:l}),gN=l=>l.status==="aborted",AN=l=>l.status==="dirty",fc=l=>l.status==="valid",cd=l=>typeof Promise<"u"&&l instanceof Promise});var Cu=u(()=>{});var lI,gu=u(()=>{(function(l){l.errToObj=I=>typeof I=="string"?{message:I}:I||{},l.toString=I=>typeof I=="string"?I:I?.message})(lI||(lI={}))});function YI(l){if(!l)return{};let{errorMap:I,invalid_type_error:G,required_error:c,description:b}=l;if(I&&(G||c))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return I?{errorMap:I,description:b}:{errorMap:(d,W)=>{let{message:a}=l;return d.code==="invalid_enum_value"?{message:a??W.defaultError}:typeof W.data>"u"?{message:a??c??W.defaultError}:d.code!=="invalid_type"?{message:W.defaultError}:{message:a??G??W.defaultError}},description:b}}function zu(l){let I="[0-5]\\d";l.precision?I=`${I}\\.\\d{${l.precision}}`:l.precision==null&&(I=`${I}(\\.\\d+)?`);let G=l.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${I})${G}`}function BL(l){return new RegExp(`^${zu(l)}$`)}function xu(l){let I=`${ku}T${zu(l)}`,G=[];return G.push(l.local?"Z?":"Z"),l.offset&&G.push("([+-]\\d{2}:?\\d{2})"),I=`${I}(${G.join("|")})`,new RegExp(`^${I}$`)}function OL(l,I){return!!((I==="v4"||!I)&&gL.test(l)||(I==="v6"||!I)&&LL.test(l))}function ML(l,I){if(!EL.test(l))return!1;try{let[G]=l.split(".");if(!G)return!1;let c=G.replace(/-/g,"+").replace(/_/g,"/").padEnd(G.length+(4-G.length%4)%4,"="),b=JSON.parse(atob(c));return!(typeof b!="object"||b===null||"typ"in b&&b?.typ!=="JWT"||!b.alg||I&&b.alg!==I)}catch{return!1}}function jL(l,I){return!!((I==="v4"||!I)&&AL.test(l)||(I==="v6"||!I)&&kL.test(l))}function KL(l,I){let G=(l.toString().split(".")[1]||"").length,c=(I.toString().split(".")[1]||"").length,b=G>c?G:c,Z=Number.parseInt(l.toFixed(b).replace(".","")),d=Number.parseInt(I.toFixed(b).replace(".",""));return Z%d/10**b}function bd(l){if(l instanceof Ml){let I={};for(let G in l.shape){let c=l.shape[G];I[G]=aG.create(bd(c))}return new Ml({...l._def,shape:()=>I})}else return l instanceof sc?new sc({...l._def,type:bd(l.element)}):l instanceof aG?aG.create(bd(l.unwrap())):l instanceof KG?KG.create(bd(l.unwrap())):l instanceof jG?jG.create(l.items.map(I=>bd(I))):l}function QV(l,I){let G=MG(l),c=MG(I);if(l===I)return{valid:!0,data:l};if(G===_.object&&c===_.object){let b=hI.objectKeys(I),Z=hI.objectKeys(l).filter(W=>b.indexOf(W)!==-1),d={...l,...I};for(let W of Z){let a=QV(l[W],I[W]);if(!a.valid)return{valid:!1};d[W]=a.data}return{valid:!0,data:d}}else if(G===_.array&&c===_.array){if(l.length!==I.length)return{valid:!1};let b=[];for(let Z=0;Z<l.length;Z++){let d=l[Z],W=I[Z],a=QV(d,W);if(!a.valid)return{valid:!1};b.push(a.data)}return{valid:!0,data:b}}else return G===_.date&&c===_.date&&+l==+I?{valid:!0,data:l}:{valid:!1}}function Uu(l,I){return new GZ({values:l,typeName:NI.ZodEnum,...YI(I)})}function Lu(l,I){let G=typeof l=="function"?l(I):typeof l=="string"?{message:l}:l;return typeof G=="string"?{message:G}:G}function Bu(l,I={},G){return l?Tc.create().superRefine((c,b)=>{let Z=l(c);if(Z instanceof Promise)return Z.then(d=>{if(!d){let W=Lu(I,c),a=W.fatal??G??!0;b.addIssue({code:"custom",...W,fatal:a})}});if(!Z){let d=Lu(I,c),W=d.fatal??G??!0;b.addIssue({code:"custom",...d,fatal:W})}}):Tc.create()}var mG,Au,pI,vL,wL,iL,oL,yL,EL,JL,rL,CL,XV,gL,AL,LL,kL,zL,xL,ku,UL,Dc,Sb,fb,Db,Tb,Zd,qb,Pb,Tc,tc,oG,dd,sc,Ml,_b,hc,LN,$b,jG,kN,Wd,ad,zN,IZ,lZ,GZ,cZ,qc,NG,aG,KG,bZ,ZZ,md,SL,Za,da,dZ,fL,NI,DL,Ou,Mu,TL,qL,ju,PL,_L,$L,Ik,lk,Gk,ck,bk,Zk,dk,Wk,ak,mk,Nk,ek,Yk,pk,Vk,nk,hk,tk,sk,Rk,Fk,uk,Xk,Qk,Hk,vk,wk,ik,ok,yk,Ek,Ku=u(()=>{rN();CN();gu();uV();ca();mG=class{constructor(I,G,c,b){this._cachedPath=[],this.parent=I,this.data=G,this._path=c,this._key=b}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}},Au=(l,I)=>{if(fc(I))return{success:!0,data:I.value};if(!l.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let G=new Cl(l.common.issues);return this._error=G,this._error}}};pI=class{get description(){return this._def.description}_getType(I){return MG(I.data)}_getOrReturnCtx(I,G){return G||{common:I.parent.common,data:I.data,parsedType:MG(I.data),schemaErrorMap:this._def.errorMap,path:I.path,parent:I.parent}}_processInputParams(I){return{status:new Ql,ctx:{common:I.parent.common,data:I.data,parsedType:MG(I.data),schemaErrorMap:this._def.errorMap,path:I.path,parent:I.parent}}}_parseSync(I){let G=this._parse(I);if(cd(G))throw new Error("Synchronous parse encountered promise.");return G}_parseAsync(I){let G=this._parse(I);return Promise.resolve(G)}parse(I,G){let c=this.safeParse(I,G);if(c.success)return c.data;throw c.error}safeParse(I,G){let c={common:{issues:[],async:G?.async??!1,contextualErrorMap:G?.errorMap},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:I,parsedType:MG(I)},b=this._parseSync({data:I,path:c.path,parent:c});return Au(c,b)}"~validate"(I){let G={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:I,parsedType:MG(I)};if(!this["~standard"].async)try{let c=this._parseSync({data:I,path:[],parent:G});return fc(c)?{value:c.value}:{issues:G.common.issues}}catch(c){c?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),G.common={issues:[],async:!0}}return this._parseAsync({data:I,path:[],parent:G}).then(c=>fc(c)?{value:c.value}:{issues:G.common.issues})}async parseAsync(I,G){let c=await this.safeParseAsync(I,G);if(c.success)return c.data;throw c.error}async safeParseAsync(I,G){let c={common:{issues:[],contextualErrorMap:G?.errorMap,async:!0},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:I,parsedType:MG(I)},b=this._parse({data:I,path:c.path,parent:c}),Z=await(cd(b)?b:Promise.resolve(b));return Au(c,Z)}refine(I,G){let c=b=>typeof G=="string"||typeof G>"u"?{message:G}:typeof G=="function"?G(b):G;return this._refinement((b,Z)=>{let d=I(b),W=()=>Z.addIssue({code:M.custom,...c(b)});return typeof Promise<"u"&&d instanceof Promise?d.then(a=>a?!0:(W(),!1)):d?!0:(W(),!1)})}refinement(I,G){return this._refinement((c,b)=>I(c)?!0:(b.addIssue(typeof G=="function"?G(c,b):G),!1))}_refinement(I){return new NG({schema:this,typeName:NI.ZodEffects,effect:{type:"refinement",refinement:I}})}superRefine(I){return this._refinement(I)}constructor(I){this.spa=this.safeParseAsync,this._def=I,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:G=>this["~validate"](G)}}optional(){return aG.create(this,this._def)}nullable(){return KG.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return sc.create(this)}promise(){return qc.create(this,this._def)}or(I){return _b.create([this,I],this._def)}and(I){return $b.create(this,I,this._def)}transform(I){return new NG({...YI(this._def),schema:this,typeName:NI.ZodEffects,effect:{type:"transform",transform:I}})}default(I){let G=typeof I=="function"?I:()=>I;return new bZ({...YI(this._def),innerType:this,defaultValue:G,typeName:NI.ZodDefault})}brand(){return new Za({typeName:NI.ZodBranded,type:this,...YI(this._def)})}catch(I){let G=typeof I=="function"?I:()=>I;return new ZZ({...YI(this._def),innerType:this,catchValue:G,typeName:NI.ZodCatch})}describe(I){let G=this.constructor;return new G({...this._def,description:I})}pipe(I){return da.create(this,I)}readonly(){return dZ.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},vL=/^c[^\s-]{8,}$/i,wL=/^[0-9a-z]+$/,iL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oL=/^[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,yL=/^[a-z0-9_-]{21}$/i,EL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,JL=/^[-+]?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)?)??$/,rL=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,CL="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",gL=/^(?:(?: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])$/,AL=/^(?:(?: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])$/,LL=/^(([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]))$/,kL=/^(([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])$/,zL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ku="((\\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])))",UL=new RegExp(`^${ku}$`);Dc=class l extends pI{_parse(I){if(this._def.coerce&&(I.data=String(I.data)),this._getType(I)!==_.string){let Z=this._getOrReturnCtx(I);return q(Z,{code:M.invalid_type,expected:_.string,received:Z.parsedType}),aI}let c=new Ql,b;for(let Z of this._def.checks)if(Z.kind==="min")I.data.length<Z.value&&(b=this._getOrReturnCtx(I,b),q(b,{code:M.too_small,minimum:Z.value,type:"string",inclusive:!0,exact:!1,message:Z.message}),c.dirty());else if(Z.kind==="max")I.data.length>Z.value&&(b=this._getOrReturnCtx(I,b),q(b,{code:M.too_big,maximum:Z.value,type:"string",inclusive:!0,exact:!1,message:Z.message}),c.dirty());else if(Z.kind==="length"){let d=I.data.length>Z.value,W=I.data.length<Z.value;(d||W)&&(b=this._getOrReturnCtx(I,b),d?q(b,{code:M.too_big,maximum:Z.value,type:"string",inclusive:!0,exact:!0,message:Z.message}):W&&q(b,{code:M.too_small,minimum:Z.value,type:"string",inclusive:!0,exact:!0,message:Z.message}),c.dirty())}else if(Z.kind==="email")rL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"email",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="emoji")XV||(XV=new RegExp(CL,"u")),XV.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"emoji",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="uuid")oL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"uuid",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="nanoid")yL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"nanoid",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="cuid")vL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"cuid",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="cuid2")wL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"cuid2",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="ulid")iL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"ulid",code:M.invalid_string,message:Z.message}),c.dirty());else if(Z.kind==="url")try{new URL(I.data)}catch{b=this._getOrReturnCtx(I,b),q(b,{validation:"url",code:M.invalid_string,message:Z.message}),c.dirty()}else Z.kind==="regex"?(Z.regex.lastIndex=0,Z.regex.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"regex",code:M.invalid_string,message:Z.message}),c.dirty())):Z.kind==="trim"?I.data=I.data.trim():Z.kind==="includes"?I.data.includes(Z.value,Z.position)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:{includes:Z.value,position:Z.position},message:Z.message}),c.dirty()):Z.kind==="toLowerCase"?I.data=I.data.toLowerCase():Z.kind==="toUpperCase"?I.data=I.data.toUpperCase():Z.kind==="startsWith"?I.data.startsWith(Z.value)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:{startsWith:Z.value},message:Z.message}),c.dirty()):Z.kind==="endsWith"?I.data.endsWith(Z.value)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:{endsWith:Z.value},message:Z.message}),c.dirty()):Z.kind==="datetime"?xu(Z).test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:"datetime",message:Z.message}),c.dirty()):Z.kind==="date"?UL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:"date",message:Z.message}),c.dirty()):Z.kind==="time"?BL(Z).test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{code:M.invalid_string,validation:"time",message:Z.message}),c.dirty()):Z.kind==="duration"?JL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"duration",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="ip"?OL(I.data,Z.version)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"ip",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="jwt"?ML(I.data,Z.alg)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"jwt",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="cidr"?jL(I.data,Z.version)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"cidr",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="base64"?zL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"base64",code:M.invalid_string,message:Z.message}),c.dirty()):Z.kind==="base64url"?xL.test(I.data)||(b=this._getOrReturnCtx(I,b),q(b,{validation:"base64url",code:M.invalid_string,message:Z.message}),c.dirty()):hI.assertNever(Z);return{status:c.value,value:I.data}}_regex(I,G,c){return this.refinement(b=>I.test(b),{validation:G,code:M.invalid_string,...lI.errToObj(c)})}_addCheck(I){return new l({...this._def,checks:[...this._def.checks,I]})}email(I){return this._addCheck({kind:"email",...lI.errToObj(I)})}url(I){return this._addCheck({kind:"url",...lI.errToObj(I)})}emoji(I){return this._addCheck({kind:"emoji",...lI.errToObj(I)})}uuid(I){return this._addCheck({kind:"uuid",...lI.errToObj(I)})}nanoid(I){return this._addCheck({kind:"nanoid",...lI.errToObj(I)})}cuid(I){return this._addCheck({kind:"cuid",...lI.errToObj(I)})}cuid2(I){return this._addCheck({kind:"cuid2",...lI.errToObj(I)})}ulid(I){return this._addCheck({kind:"ulid",...lI.errToObj(I)})}base64(I){return this._addCheck({kind:"base64",...lI.errToObj(I)})}base64url(I){return this._addCheck({kind:"base64url",...lI.errToObj(I)})}jwt(I){return this._addCheck({kind:"jwt",...lI.errToObj(I)})}ip(I){return this._addCheck({kind:"ip",...lI.errToObj(I)})}cidr(I){return this._addCheck({kind:"cidr",...lI.errToObj(I)})}datetime(I){return typeof I=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:I}):this._addCheck({kind:"datetime",precision:typeof I?.precision>"u"?null:I?.precision,offset:I?.offset??!1,local:I?.local??!1,...lI.errToObj(I?.message)})}date(I){return this._addCheck({kind:"date",message:I})}time(I){return typeof I=="string"?this._addCheck({kind:"time",precision:null,message:I}):this._addCheck({kind:"time",precision:typeof I?.precision>"u"?null:I?.precision,...lI.errToObj(I?.message)})}duration(I){return this._addCheck({kind:"duration",...lI.errToObj(I)})}regex(I,G){return this._addCheck({kind:"regex",regex:I,...lI.errToObj(G)})}includes(I,G){return this._addCheck({kind:"includes",value:I,position:G?.position,...lI.errToObj(G?.message)})}startsWith(I,G){return this._addCheck({kind:"startsWith",value:I,...lI.errToObj(G)})}endsWith(I,G){return this._addCheck({kind:"endsWith",value:I,...lI.errToObj(G)})}min(I,G){return this._addCheck({kind:"min",value:I,...lI.errToObj(G)})}max(I,G){return this._addCheck({kind:"max",value:I,...lI.errToObj(G)})}length(I,G){return this._addCheck({kind:"length",value:I,...lI.errToObj(G)})}nonempty(I){return this.min(1,lI.errToObj(I))}trim(){return new l({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new l({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new l({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(I=>I.kind==="datetime")}get isDate(){return!!this._def.checks.find(I=>I.kind==="date")}get isTime(){return!!this._def.checks.find(I=>I.kind==="time")}get isDuration(){return!!this._def.checks.find(I=>I.kind==="duration")}get isEmail(){return!!this._def.checks.find(I=>I.kind==="email")}get isURL(){return!!this._def.checks.find(I=>I.kind==="url")}get isEmoji(){return!!this._def.checks.find(I=>I.kind==="emoji")}get isUUID(){return!!this._def.checks.find(I=>I.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(I=>I.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(I=>I.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(I=>I.kind==="cuid2")}get isULID(){return!!this._def.checks.find(I=>I.kind==="ulid")}get isIP(){return!!this._def.checks.find(I=>I.kind==="ip")}get isCIDR(){return!!this._def.checks.find(I=>I.kind==="cidr")}get isBase64(){return!!this._def.checks.find(I=>I.kind==="base64")}get isBase64url(){return!!this._def.checks.find(I=>I.kind==="base64url")}get minLength(){let I=null;for(let G of this._def.checks)G.kind==="min"&&(I===null||G.value>I)&&(I=G.value);return I}get maxLength(){let I=null;for(let G of this._def.checks)G.kind==="max"&&(I===null||G.value<I)&&(I=G.value);return I}};Dc.create=l=>new Dc({checks:[],typeName:NI.ZodString,coerce:l?.coerce??!1,...YI(l)});Sb=class l extends pI{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(I){if(this._def.coerce&&(I.data=Number(I.data)),this._getType(I)!==_.number){let Z=this._getOrReturnCtx(I);return q(Z,{code:M.invalid_type,expected:_.number,received:Z.parsedType}),aI}let c,b=new Ql;for(let Z of this._def.checks)Z.kind==="int"?hI.isInteger(I.data)||(c=this._getOrReturnCtx(I,c),q(c,{code:M.invalid_type,expected:"integer",received:"float",message:Z.message}),b.dirty()):Z.kind==="min"?(Z.inclusive?I.data<Z.value:I.data<=Z.value)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.too_small,minimum:Z.value,type:"number",inclusive:Z.inclusive,exact:!1,message:Z.message}),b.dirty()):Z.kind==="max"?(Z.inclusive?I.data>Z.value:I.data>=Z.value)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.too_big,maximum:Z.value,type:"number",inclusive:Z.inclusive,exact:!1,message:Z.message}),b.dirty()):Z.kind==="multipleOf"?KL(I.data,Z.value)!==0&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.not_multiple_of,multipleOf:Z.value,message:Z.message}),b.dirty()):Z.kind==="finite"?Number.isFinite(I.data)||(c=this._getOrReturnCtx(I,c),q(c,{code:M.not_finite,message:Z.message}),b.dirty()):hI.assertNever(Z);return{status:b.value,value:I.data}}gte(I,G){return this.setLimit("min",I,!0,lI.toString(G))}gt(I,G){return this.setLimit("min",I,!1,lI.toString(G))}lte(I,G){return this.setLimit("max",I,!0,lI.toString(G))}lt(I,G){return this.setLimit("max",I,!1,lI.toString(G))}setLimit(I,G,c,b){return new l({...this._def,checks:[...this._def.checks,{kind:I,value:G,inclusive:c,message:lI.toString(b)}]})}_addCheck(I){return new l({...this._def,checks:[...this._def.checks,I]})}int(I){return this._addCheck({kind:"int",message:lI.toString(I)})}positive(I){return this._addCheck({kind:"min",value:0,inclusive:!1,message:lI.toString(I)})}negative(I){return this._addCheck({kind:"max",value:0,inclusive:!1,message:lI.toString(I)})}nonpositive(I){return this._addCheck({kind:"max",value:0,inclusive:!0,message:lI.toString(I)})}nonnegative(I){return this._addCheck({kind:"min",value:0,inclusive:!0,message:lI.toString(I)})}multipleOf(I,G){return this._addCheck({kind:"multipleOf",value:I,message:lI.toString(G)})}finite(I){return this._addCheck({kind:"finite",message:lI.toString(I)})}safe(I){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:lI.toString(I)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:lI.toString(I)})}get minValue(){let I=null;for(let G of this._def.checks)G.kind==="min"&&(I===null||G.value>I)&&(I=G.value);return I}get maxValue(){let I=null;for(let G of this._def.checks)G.kind==="max"&&(I===null||G.value<I)&&(I=G.value);return I}get isInt(){return!!this._def.checks.find(I=>I.kind==="int"||I.kind==="multipleOf"&&hI.isInteger(I.value))}get isFinite(){let I=null,G=null;for(let c of this._def.checks){if(c.kind==="finite"||c.kind==="int"||c.kind==="multipleOf")return!0;c.kind==="min"?(G===null||c.value>G)&&(G=c.value):c.kind==="max"&&(I===null||c.value<I)&&(I=c.value)}return Number.isFinite(G)&&Number.isFinite(I)}};Sb.create=l=>new Sb({checks:[],typeName:NI.ZodNumber,coerce:l?.coerce||!1,...YI(l)});fb=class l extends pI{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(I){if(this._def.coerce)try{I.data=BigInt(I.data)}catch{return this._getInvalidInput(I)}if(this._getType(I)!==_.bigint)return this._getInvalidInput(I);let c,b=new Ql;for(let Z of this._def.checks)Z.kind==="min"?(Z.inclusive?I.data<Z.value:I.data<=Z.value)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.too_small,type:"bigint",minimum:Z.value,inclusive:Z.inclusive,message:Z.message}),b.dirty()):Z.kind==="max"?(Z.inclusive?I.data>Z.value:I.data>=Z.value)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.too_big,type:"bigint",maximum:Z.value,inclusive:Z.inclusive,message:Z.message}),b.dirty()):Z.kind==="multipleOf"?I.data%Z.value!==BigInt(0)&&(c=this._getOrReturnCtx(I,c),q(c,{code:M.not_multiple_of,multipleOf:Z.value,message:Z.message}),b.dirty()):hI.assertNever(Z);return{status:b.value,value:I.data}}_getInvalidInput(I){let G=this._getOrReturnCtx(I);return q(G,{code:M.invalid_type,expected:_.bigint,received:G.parsedType}),aI}gte(I,G){return this.setLimit("min",I,!0,lI.toString(G))}gt(I,G){return this.setLimit("min",I,!1,lI.toString(G))}lte(I,G){return this.setLimit("max",I,!0,lI.toString(G))}lt(I,G){return this.setLimit("max",I,!1,lI.toString(G))}setLimit(I,G,c,b){return new l({...this._def,checks:[...this._def.checks,{kind:I,value:G,inclusive:c,message:lI.toString(b)}]})}_addCheck(I){return new l({...this._def,checks:[...this._def.checks,I]})}positive(I){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:lI.toString(I)})}negative(I){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:lI.toString(I)})}nonpositive(I){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:lI.toString(I)})}nonnegative(I){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:lI.toString(I)})}multipleOf(I,G){return this._addCheck({kind:"multipleOf",value:I,message:lI.toString(G)})}get minValue(){let I=null;for(let G of this._def.checks)G.kind==="min"&&(I===null||G.value>I)&&(I=G.value);return I}get maxValue(){let I=null;for(let G of this._def.checks)G.kind==="max"&&(I===null||G.value<I)&&(I=G.value);return I}};fb.create=l=>new fb({checks:[],typeName:NI.ZodBigInt,coerce:l?.coerce??!1,...YI(l)});Db=class extends pI{_parse(I){if(this._def.coerce&&(I.data=!!I.data),this._getType(I)!==_.boolean){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.boolean,received:c.parsedType}),aI}return gl(I.data)}};Db.create=l=>new Db({typeName:NI.ZodBoolean,coerce:l?.coerce||!1,...YI(l)});Tb=class l extends pI{_parse(I){if(this._def.coerce&&(I.data=new Date(I.data)),this._getType(I)!==_.date){let Z=this._getOrReturnCtx(I);return q(Z,{code:M.invalid_type,expected:_.date,received:Z.parsedType}),aI}if(Number.isNaN(I.data.getTime())){let Z=this._getOrReturnCtx(I);return q(Z,{code:M.invalid_date}),aI}let c=new Ql,b;for(let Z of this._def.checks)Z.kind==="min"?I.data.getTime()<Z.value&&(b=this._getOrReturnCtx(I,b),q(b,{code:M.too_small,message:Z.message,inclusive:!0,exact:!1,minimum:Z.value,type:"date"}),c.dirty()):Z.kind==="max"?I.data.getTime()>Z.value&&(b=this._getOrReturnCtx(I,b),q(b,{code:M.too_big,message:Z.message,inclusive:!0,exact:!1,maximum:Z.value,type:"date"}),c.dirty()):hI.assertNever(Z);return{status:c.value,value:new Date(I.data.getTime())}}_addCheck(I){return new l({...this._def,checks:[...this._def.checks,I]})}min(I,G){return this._addCheck({kind:"min",value:I.getTime(),message:lI.toString(G)})}max(I,G){return this._addCheck({kind:"max",value:I.getTime(),message:lI.toString(G)})}get minDate(){let I=null;for(let G of this._def.checks)G.kind==="min"&&(I===null||G.value>I)&&(I=G.value);return I!=null?new Date(I):null}get maxDate(){let I=null;for(let G of this._def.checks)G.kind==="max"&&(I===null||G.value<I)&&(I=G.value);return I!=null?new Date(I):null}};Tb.create=l=>new Tb({checks:[],coerce:l?.coerce||!1,typeName:NI.ZodDate,...YI(l)});Zd=class extends pI{_parse(I){if(this._getType(I)!==_.symbol){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.symbol,received:c.parsedType}),aI}return gl(I.data)}};Zd.create=l=>new Zd({typeName:NI.ZodSymbol,...YI(l)});qb=class extends pI{_parse(I){if(this._getType(I)!==_.undefined){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.undefined,received:c.parsedType}),aI}return gl(I.data)}};qb.create=l=>new qb({typeName:NI.ZodUndefined,...YI(l)});Pb=class extends pI{_parse(I){if(this._getType(I)!==_.null){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.null,received:c.parsedType}),aI}return gl(I.data)}};Pb.create=l=>new Pb({typeName:NI.ZodNull,...YI(l)});Tc=class extends pI{constructor(){super(...arguments),this._any=!0}_parse(I){return gl(I.data)}};Tc.create=l=>new Tc({typeName:NI.ZodAny,...YI(l)});tc=class extends pI{constructor(){super(...arguments),this._unknown=!0}_parse(I){return gl(I.data)}};tc.create=l=>new tc({typeName:NI.ZodUnknown,...YI(l)});oG=class extends pI{_parse(I){let G=this._getOrReturnCtx(I);return q(G,{code:M.invalid_type,expected:_.never,received:G.parsedType}),aI}};oG.create=l=>new oG({typeName:NI.ZodNever,...YI(l)});dd=class extends pI{_parse(I){if(this._getType(I)!==_.undefined){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.void,received:c.parsedType}),aI}return gl(I.data)}};dd.create=l=>new dd({typeName:NI.ZodVoid,...YI(l)});sc=class l extends pI{_parse(I){let{ctx:G,status:c}=this._processInputParams(I),b=this._def;if(G.parsedType!==_.array)return q(G,{code:M.invalid_type,expected:_.array,received:G.parsedType}),aI;if(b.exactLength!==null){let d=G.data.length>b.exactLength.value,W=G.data.length<b.exactLength.value;(d||W)&&(q(G,{code:d?M.too_big:M.too_small,minimum:W?b.exactLength.value:void 0,maximum:d?b.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:b.exactLength.message}),c.dirty())}if(b.minLength!==null&&G.data.length<b.minLength.value&&(q(G,{code:M.too_small,minimum:b.minLength.value,type:"array",inclusive:!0,exact:!1,message:b.minLength.message}),c.dirty()),b.maxLength!==null&&G.data.length>b.maxLength.value&&(q(G,{code:M.too_big,maximum:b.maxLength.value,type:"array",inclusive:!0,exact:!1,message:b.maxLength.message}),c.dirty()),G.common.async)return Promise.all([...G.data].map((d,W)=>b.type._parseAsync(new mG(G,d,G.path,W)))).then(d=>Ql.mergeArray(c,d));let Z=[...G.data].map((d,W)=>b.type._parseSync(new mG(G,d,G.path,W)));return Ql.mergeArray(c,Z)}get element(){return this._def.type}min(I,G){return new l({...this._def,minLength:{value:I,message:lI.toString(G)}})}max(I,G){return new l({...this._def,maxLength:{value:I,message:lI.toString(G)}})}length(I,G){return new l({...this._def,exactLength:{value:I,message:lI.toString(G)}})}nonempty(I){return this.min(1,I)}};sc.create=(l,I)=>new sc({type:l,minLength:null,maxLength:null,exactLength:null,typeName:NI.ZodArray,...YI(I)});Ml=class l extends pI{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let I=this._def.shape(),G=hI.objectKeys(I);return this._cached={shape:I,keys:G},this._cached}_parse(I){if(this._getType(I)!==_.object){let m=this._getOrReturnCtx(I);return q(m,{code:M.invalid_type,expected:_.object,received:m.parsedType}),aI}let{status:c,ctx:b}=this._processInputParams(I),{shape:Z,keys:d}=this._getCached(),W=[];if(!(this._def.catchall instanceof oG&&this._def.unknownKeys==="strip"))for(let m in b.data)d.includes(m)||W.push(m);let a=[];for(let m of d){let N=Z[m],e=b.data[m];a.push({key:{status:"valid",value:m},value:N._parse(new mG(b,e,b.path,m)),alwaysSet:m in b.data})}if(this._def.catchall instanceof oG){let m=this._def.unknownKeys;if(m==="passthrough")for(let N of W)a.push({key:{status:"valid",value:N},value:{status:"valid",value:b.data[N]}});else if(m==="strict")W.length>0&&(q(b,{code:M.unrecognized_keys,keys:W}),c.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let m=this._def.catchall;for(let N of W){let e=b.data[N];a.push({key:{status:"valid",value:N},value:m._parse(new mG(b,e,b.path,N)),alwaysSet:N in b.data})}}return b.common.async?Promise.resolve().then(async()=>{let m=[];for(let N of a){let e=await N.key,Y=await N.value;m.push({key:e,value:Y,alwaysSet:N.alwaysSet})}return m}).then(m=>Ql.mergeObjectSync(c,m)):Ql.mergeObjectSync(c,a)}get shape(){return this._def.shape()}strict(I){return lI.errToObj,new l({...this._def,unknownKeys:"strict",...I!==void 0?{errorMap:(G,c)=>{let b=this._def.errorMap?.(G,c).message??c.defaultError;return G.code==="unrecognized_keys"?{message:lI.errToObj(I).message??b}:{message:b}}}:{}})}strip(){return new l({...this._def,unknownKeys:"strip"})}passthrough(){return new l({...this._def,unknownKeys:"passthrough"})}extend(I){return new l({...this._def,shape:()=>({...this._def.shape(),...I})})}merge(I){return new l({unknownKeys:I._def.unknownKeys,catchall:I._def.catchall,shape:()=>({...this._def.shape(),...I._def.shape()}),typeName:NI.ZodObject})}setKey(I,G){return this.augment({[I]:G})}catchall(I){return new l({...this._def,catchall:I})}pick(I){let G={};for(let c of hI.objectKeys(I))I[c]&&this.shape[c]&&(G[c]=this.shape[c]);return new l({...this._def,shape:()=>G})}omit(I){let G={};for(let c of hI.objectKeys(this.shape))I[c]||(G[c]=this.shape[c]);return new l({...this._def,shape:()=>G})}deepPartial(){return bd(this)}partial(I){let G={};for(let c of hI.objectKeys(this.shape)){let b=this.shape[c];I&&!I[c]?G[c]=b:G[c]=b.optional()}return new l({...this._def,shape:()=>G})}required(I){let G={};for(let c of hI.objectKeys(this.shape))if(I&&!I[c])G[c]=this.shape[c];else{let Z=this.shape[c];for(;Z instanceof aG;)Z=Z._def.innerType;G[c]=Z}return new l({...this._def,shape:()=>G})}keyof(){return Uu(hI.objectKeys(this.shape))}};Ml.create=(l,I)=>new Ml({shape:()=>l,unknownKeys:"strip",catchall:oG.create(),typeName:NI.ZodObject,...YI(I)});Ml.strictCreate=(l,I)=>new Ml({shape:()=>l,unknownKeys:"strict",catchall:oG.create(),typeName:NI.ZodObject,...YI(I)});Ml.lazycreate=(l,I)=>new Ml({shape:l,unknownKeys:"strip",catchall:oG.create(),typeName:NI.ZodObject,...YI(I)});_b=class extends pI{_parse(I){let{ctx:G}=this._processInputParams(I),c=this._def.options;function b(Z){for(let W of Z)if(W.result.status==="valid")return W.result;for(let W of Z)if(W.result.status==="dirty")return G.common.issues.push(...W.ctx.common.issues),W.result;let d=Z.map(W=>new Cl(W.ctx.common.issues));return q(G,{code:M.invalid_union,unionErrors:d}),aI}if(G.common.async)return Promise.all(c.map(async Z=>{let d={...G,common:{...G.common,issues:[]},parent:null};return{result:await Z._parseAsync({data:G.data,path:G.path,parent:d}),ctx:d}})).then(b);{let Z,d=[];for(let a of c){let m={...G,common:{...G.common,issues:[]},parent:null},N=a._parseSync({data:G.data,path:G.path,parent:m});if(N.status==="valid")return N;N.status==="dirty"&&!Z&&(Z={result:N,ctx:m}),m.common.issues.length&&d.push(m.common.issues)}if(Z)return G.common.issues.push(...Z.ctx.common.issues),Z.result;let W=d.map(a=>new Cl(a));return q(G,{code:M.invalid_union,unionErrors:W}),aI}}get options(){return this._def.options}};_b.create=(l,I)=>new _b({options:l,typeName:NI.ZodUnion,...YI(I)});hc=l=>l instanceof IZ?hc(l.schema):l instanceof NG?hc(l.innerType()):l instanceof lZ?[l.value]:l instanceof GZ?l.options:l instanceof cZ?hI.objectValues(l.enum):l instanceof bZ?hc(l._def.innerType):l instanceof qb?[void 0]:l instanceof Pb?[null]:l instanceof aG?[void 0,...hc(l.unwrap())]:l instanceof KG?[null,...hc(l.unwrap())]:l instanceof Za||l instanceof dZ?hc(l.unwrap()):l instanceof ZZ?hc(l._def.innerType):[],LN=class l extends pI{_parse(I){let{ctx:G}=this._processInputParams(I);if(G.parsedType!==_.object)return q(G,{code:M.invalid_type,expected:_.object,received:G.parsedType}),aI;let c=this.discriminator,b=G.data[c],Z=this.optionsMap.get(b);return Z?G.common.async?Z._parseAsync({data:G.data,path:G.path,parent:G}):Z._parseSync({data:G.data,path:G.path,parent:G}):(q(G,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[c]}),aI)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(I,G,c){let b=new Map;for(let Z of G){let d=hc(Z.shape[I]);if(!d.length)throw new Error(`A discriminator value for key \`${I}\` could not be extracted from all schema options`);for(let W of d){if(b.has(W))throw new Error(`Discriminator property ${String(I)} has duplicate value ${String(W)}`);b.set(W,Z)}}return new l({typeName:NI.ZodDiscriminatedUnion,discriminator:I,options:G,optionsMap:b,...YI(c)})}};$b=class extends pI{_parse(I){let{status:G,ctx:c}=this._processInputParams(I),b=(Z,d)=>{if(gN(Z)||gN(d))return aI;let W=QV(Z.value,d.value);return W.valid?((AN(Z)||AN(d))&&G.dirty(),{status:G.value,value:W.data}):(q(c,{code:M.invalid_intersection_types}),aI)};return c.common.async?Promise.all([this._def.left._parseAsync({data:c.data,path:c.path,parent:c}),this._def.right._parseAsync({data:c.data,path:c.path,parent:c})]).then(([Z,d])=>b(Z,d)):b(this._def.left._parseSync({data:c.data,path:c.path,parent:c}),this._def.right._parseSync({data:c.data,path:c.path,parent:c}))}};$b.create=(l,I,G)=>new $b({left:l,right:I,typeName:NI.ZodIntersection,...YI(G)});jG=class l extends pI{_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.parsedType!==_.array)return q(c,{code:M.invalid_type,expected:_.array,received:c.parsedType}),aI;if(c.data.length<this._def.items.length)return q(c,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),aI;!this._def.rest&&c.data.length>this._def.items.length&&(q(c,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),G.dirty());let Z=[...c.data].map((d,W)=>{let a=this._def.items[W]||this._def.rest;return a?a._parse(new mG(c,d,c.path,W)):null}).filter(d=>!!d);return c.common.async?Promise.all(Z).then(d=>Ql.mergeArray(G,d)):Ql.mergeArray(G,Z)}get items(){return this._def.items}rest(I){return new l({...this._def,rest:I})}};jG.create=(l,I)=>{if(!Array.isArray(l))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jG({items:l,typeName:NI.ZodTuple,rest:null,...YI(I)})};kN=class l extends pI{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.parsedType!==_.object)return q(c,{code:M.invalid_type,expected:_.object,received:c.parsedType}),aI;let b=[],Z=this._def.keyType,d=this._def.valueType;for(let W in c.data)b.push({key:Z._parse(new mG(c,W,c.path,W)),value:d._parse(new mG(c,c.data[W],c.path,W)),alwaysSet:W in c.data});return c.common.async?Ql.mergeObjectAsync(G,b):Ql.mergeObjectSync(G,b)}get element(){return this._def.valueType}static create(I,G,c){return G instanceof pI?new l({keyType:I,valueType:G,typeName:NI.ZodRecord,...YI(c)}):new l({keyType:Dc.create(),valueType:I,typeName:NI.ZodRecord,...YI(G)})}},Wd=class extends pI{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.parsedType!==_.map)return q(c,{code:M.invalid_type,expected:_.map,received:c.parsedType}),aI;let b=this._def.keyType,Z=this._def.valueType,d=[...c.data.entries()].map(([W,a],m)=>({key:b._parse(new mG(c,W,c.path,[m,"key"])),value:Z._parse(new mG(c,a,c.path,[m,"value"]))}));if(c.common.async){let W=new Map;return Promise.resolve().then(async()=>{for(let a of d){let m=await a.key,N=await a.value;if(m.status==="aborted"||N.status==="aborted")return aI;(m.status==="dirty"||N.status==="dirty")&&G.dirty(),W.set(m.value,N.value)}return{status:G.value,value:W}})}else{let W=new Map;for(let a of d){let m=a.key,N=a.value;if(m.status==="aborted"||N.status==="aborted")return aI;(m.status==="dirty"||N.status==="dirty")&&G.dirty(),W.set(m.value,N.value)}return{status:G.value,value:W}}}};Wd.create=(l,I,G)=>new Wd({valueType:I,keyType:l,typeName:NI.ZodMap,...YI(G)});ad=class l extends pI{_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.parsedType!==_.set)return q(c,{code:M.invalid_type,expected:_.set,received:c.parsedType}),aI;let b=this._def;b.minSize!==null&&c.data.size<b.minSize.value&&(q(c,{code:M.too_small,minimum:b.minSize.value,type:"set",inclusive:!0,exact:!1,message:b.minSize.message}),G.dirty()),b.maxSize!==null&&c.data.size>b.maxSize.value&&(q(c,{code:M.too_big,maximum:b.maxSize.value,type:"set",inclusive:!0,exact:!1,message:b.maxSize.message}),G.dirty());let Z=this._def.valueType;function d(a){let m=new Set;for(let N of a){if(N.status==="aborted")return aI;N.status==="dirty"&&G.dirty(),m.add(N.value)}return{status:G.value,value:m}}let W=[...c.data.values()].map((a,m)=>Z._parse(new mG(c,a,c.path,m)));return c.common.async?Promise.all(W).then(a=>d(a)):d(W)}min(I,G){return new l({...this._def,minSize:{value:I,message:lI.toString(G)}})}max(I,G){return new l({...this._def,maxSize:{value:I,message:lI.toString(G)}})}size(I,G){return this.min(I,G).max(I,G)}nonempty(I){return this.min(1,I)}};ad.create=(l,I)=>new ad({valueType:l,minSize:null,maxSize:null,typeName:NI.ZodSet,...YI(I)});zN=class l extends pI{constructor(){super(...arguments),this.validate=this.implement}_parse(I){let{ctx:G}=this._processInputParams(I);if(G.parsedType!==_.function)return q(G,{code:M.invalid_type,expected:_.function,received:G.parsedType}),aI;function c(W,a){return ba({data:W,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,Gd(),nc].filter(m=>!!m),issueData:{code:M.invalid_arguments,argumentsError:a}})}function b(W,a){return ba({data:W,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,Gd(),nc].filter(m=>!!m),issueData:{code:M.invalid_return_type,returnTypeError:a}})}let Z={errorMap:G.common.contextualErrorMap},d=G.data;if(this._def.returns instanceof qc){let W=this;return gl(async function(...a){let m=new Cl([]),N=await W._def.args.parseAsync(a,Z).catch(p=>{throw m.addIssue(c(a,p)),m}),e=await Reflect.apply(d,this,N);return await W._def.returns._def.type.parseAsync(e,Z).catch(p=>{throw m.addIssue(b(e,p)),m})})}else{let W=this;return gl(function(...a){let m=W._def.args.safeParse(a,Z);if(!m.success)throw new Cl([c(a,m.error)]);let N=Reflect.apply(d,this,m.data),e=W._def.returns.safeParse(N,Z);if(!e.success)throw new Cl([b(N,e.error)]);return e.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...I){return new l({...this._def,args:jG.create(I).rest(tc.create())})}returns(I){return new l({...this._def,returns:I})}implement(I){return this.parse(I)}strictImplement(I){return this.parse(I)}static create(I,G,c){return new l({args:I||jG.create([]).rest(tc.create()),returns:G||tc.create(),typeName:NI.ZodFunction,...YI(c)})}},IZ=class extends pI{get schema(){return this._def.getter()}_parse(I){let{ctx:G}=this._processInputParams(I);return this._def.getter()._parse({data:G.data,path:G.path,parent:G})}};IZ.create=(l,I)=>new IZ({getter:l,typeName:NI.ZodLazy,...YI(I)});lZ=class extends pI{_parse(I){if(I.data!==this._def.value){let G=this._getOrReturnCtx(I);return q(G,{received:G.data,code:M.invalid_literal,expected:this._def.value}),aI}return{status:"valid",value:I.data}}get value(){return this._def.value}};lZ.create=(l,I)=>new lZ({value:l,typeName:NI.ZodLiteral,...YI(I)});GZ=class l extends pI{_parse(I){if(typeof I.data!="string"){let G=this._getOrReturnCtx(I),c=this._def.values;return q(G,{expected:hI.joinValues(c),received:G.parsedType,code:M.invalid_type}),aI}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(I.data)){let G=this._getOrReturnCtx(I),c=this._def.values;return q(G,{received:G.data,code:M.invalid_enum_value,options:c}),aI}return gl(I.data)}get options(){return this._def.values}get enum(){let I={};for(let G of this._def.values)I[G]=G;return I}get Values(){let I={};for(let G of this._def.values)I[G]=G;return I}get Enum(){let I={};for(let G of this._def.values)I[G]=G;return I}extract(I,G=this._def){return l.create(I,{...this._def,...G})}exclude(I,G=this._def){return l.create(this.options.filter(c=>!I.includes(c)),{...this._def,...G})}};GZ.create=Uu;cZ=class extends pI{_parse(I){let G=hI.getValidEnumValues(this._def.values),c=this._getOrReturnCtx(I);if(c.parsedType!==_.string&&c.parsedType!==_.number){let b=hI.objectValues(G);return q(c,{expected:hI.joinValues(b),received:c.parsedType,code:M.invalid_type}),aI}if(this._cache||(this._cache=new Set(hI.getValidEnumValues(this._def.values))),!this._cache.has(I.data)){let b=hI.objectValues(G);return q(c,{received:c.data,code:M.invalid_enum_value,options:b}),aI}return gl(I.data)}get enum(){return this._def.values}};cZ.create=(l,I)=>new cZ({values:l,typeName:NI.ZodNativeEnum,...YI(I)});qc=class extends pI{unwrap(){return this._def.type}_parse(I){let{ctx:G}=this._processInputParams(I);if(G.parsedType!==_.promise&&G.common.async===!1)return q(G,{code:M.invalid_type,expected:_.promise,received:G.parsedType}),aI;let c=G.parsedType===_.promise?G.data:Promise.resolve(G.data);return gl(c.then(b=>this._def.type.parseAsync(b,{path:G.path,errorMap:G.common.contextualErrorMap})))}};qc.create=(l,I)=>new qc({type:l,typeName:NI.ZodPromise,...YI(I)});NG=class extends pI{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===NI.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(I){let{status:G,ctx:c}=this._processInputParams(I),b=this._def.effect||null,Z={addIssue:d=>{q(c,d),d.fatal?G.abort():G.dirty()},get path(){return c.path}};if(Z.addIssue=Z.addIssue.bind(Z),b.type==="preprocess"){let d=b.transform(c.data,Z);if(c.common.async)return Promise.resolve(d).then(async W=>{if(G.value==="aborted")return aI;let a=await this._def.schema._parseAsync({data:W,path:c.path,parent:c});return a.status==="aborted"?aI:a.status==="dirty"?Kb(a.value):G.value==="dirty"?Kb(a.value):a});{if(G.value==="aborted")return aI;let W=this._def.schema._parseSync({data:d,path:c.path,parent:c});return W.status==="aborted"?aI:W.status==="dirty"?Kb(W.value):G.value==="dirty"?Kb(W.value):W}}if(b.type==="refinement"){let d=W=>{let a=b.refinement(W,Z);if(c.common.async)return Promise.resolve(a);if(a instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return W};if(c.common.async===!1){let W=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});return W.status==="aborted"?aI:(W.status==="dirty"&&G.dirty(),d(W.value),{status:G.value,value:W.value})}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then(W=>W.status==="aborted"?aI:(W.status==="dirty"&&G.dirty(),d(W.value).then(()=>({status:G.value,value:W.value}))))}if(b.type==="transform")if(c.common.async===!1){let d=this._def.schema._parseSync({data:c.data,path:c.path,parent:c});if(!fc(d))return aI;let W=b.transform(d.value,Z);if(W instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:G.value,value:W}}else return this._def.schema._parseAsync({data:c.data,path:c.path,parent:c}).then(d=>fc(d)?Promise.resolve(b.transform(d.value,Z)).then(W=>({status:G.value,value:W})):aI);hI.assertNever(b)}};NG.create=(l,I,G)=>new NG({schema:l,typeName:NI.ZodEffects,effect:I,...YI(G)});NG.createWithPreprocess=(l,I,G)=>new NG({schema:I,effect:{type:"preprocess",transform:l},typeName:NI.ZodEffects,...YI(G)});aG=class extends pI{_parse(I){return this._getType(I)===_.undefined?gl(void 0):this._def.innerType._parse(I)}unwrap(){return this._def.innerType}};aG.create=(l,I)=>new aG({innerType:l,typeName:NI.ZodOptional,...YI(I)});KG=class extends pI{_parse(I){return this._getType(I)===_.null?gl(null):this._def.innerType._parse(I)}unwrap(){return this._def.innerType}};KG.create=(l,I)=>new KG({innerType:l,typeName:NI.ZodNullable,...YI(I)});bZ=class extends pI{_parse(I){let{ctx:G}=this._processInputParams(I),c=G.data;return G.parsedType===_.undefined&&(c=this._def.defaultValue()),this._def.innerType._parse({data:c,path:G.path,parent:G})}removeDefault(){return this._def.innerType}};bZ.create=(l,I)=>new bZ({innerType:l,typeName:NI.ZodDefault,defaultValue:typeof I.default=="function"?I.default:()=>I.default,...YI(I)});ZZ=class extends pI{_parse(I){let{ctx:G}=this._processInputParams(I),c={...G,common:{...G.common,issues:[]}},b=this._def.innerType._parse({data:c.data,path:c.path,parent:{...c}});return cd(b)?b.then(Z=>({status:"valid",value:Z.status==="valid"?Z.value:this._def.catchValue({get error(){return new Cl(c.common.issues)},input:c.data})})):{status:"valid",value:b.status==="valid"?b.value:this._def.catchValue({get error(){return new Cl(c.common.issues)},input:c.data})}}removeCatch(){return this._def.innerType}};ZZ.create=(l,I)=>new ZZ({innerType:l,typeName:NI.ZodCatch,catchValue:typeof I.catch=="function"?I.catch:()=>I.catch,...YI(I)});md=class extends pI{_parse(I){if(this._getType(I)!==_.nan){let c=this._getOrReturnCtx(I);return q(c,{code:M.invalid_type,expected:_.nan,received:c.parsedType}),aI}return{status:"valid",value:I.data}}};md.create=l=>new md({typeName:NI.ZodNaN,...YI(l)});SL=Symbol("zod_brand"),Za=class extends pI{_parse(I){let{ctx:G}=this._processInputParams(I),c=G.data;return this._def.type._parse({data:c,path:G.path,parent:G})}unwrap(){return this._def.type}},da=class l extends pI{_parse(I){let{status:G,ctx:c}=this._processInputParams(I);if(c.common.async)return(async()=>{let Z=await this._def.in._parseAsync({data:c.data,path:c.path,parent:c});return Z.status==="aborted"?aI:Z.status==="dirty"?(G.dirty(),Kb(Z.value)):this._def.out._parseAsync({data:Z.value,path:c.path,parent:c})})();{let b=this._def.in._parseSync({data:c.data,path:c.path,parent:c});return b.status==="aborted"?aI:b.status==="dirty"?(G.dirty(),{status:"dirty",value:b.value}):this._def.out._parseSync({data:b.value,path:c.path,parent:c})}}static create(I,G){return new l({in:I,out:G,typeName:NI.ZodPipeline})}},dZ=class extends pI{_parse(I){let G=this._def.innerType._parse(I),c=b=>(fc(b)&&(b.value=Object.freeze(b.value)),b);return cd(G)?G.then(b=>c(b)):c(G)}unwrap(){return this._def.innerType}};dZ.create=(l,I)=>new dZ({innerType:l,typeName:NI.ZodReadonly,...YI(I)});fL={object:Ml.lazycreate};(function(l){l.ZodString="ZodString",l.ZodNumber="ZodNumber",l.ZodNaN="ZodNaN",l.ZodBigInt="ZodBigInt",l.ZodBoolean="ZodBoolean",l.ZodDate="ZodDate",l.ZodSymbol="ZodSymbol",l.ZodUndefined="ZodUndefined",l.ZodNull="ZodNull",l.ZodAny="ZodAny",l.ZodUnknown="ZodUnknown",l.ZodNever="ZodNever",l.ZodVoid="ZodVoid",l.ZodArray="ZodArray",l.ZodObject="ZodObject",l.ZodUnion="ZodUnion",l.ZodDiscriminatedUnion="ZodDiscriminatedUnion",l.ZodIntersection="ZodIntersection",l.ZodTuple="ZodTuple",l.ZodRecord="ZodRecord",l.ZodMap="ZodMap",l.ZodSet="ZodSet",l.ZodFunction="ZodFunction",l.ZodLazy="ZodLazy",l.ZodLiteral="ZodLiteral",l.ZodEnum="ZodEnum",l.ZodEffects="ZodEffects",l.ZodNativeEnum="ZodNativeEnum",l.ZodOptional="ZodOptional",l.ZodNullable="ZodNullable",l.ZodDefault="ZodDefault",l.ZodCatch="ZodCatch",l.ZodPromise="ZodPromise",l.ZodBranded="ZodBranded",l.ZodPipeline="ZodPipeline",l.ZodReadonly="ZodReadonly"})(NI||(NI={}));DL=(l,I={message:`Input not instance of ${l.name}`})=>Bu(G=>G instanceof l,I),Ou=Dc.create,Mu=Sb.create,TL=md.create,qL=fb.create,ju=Db.create,PL=Tb.create,_L=Zd.create,$L=qb.create,Ik=Pb.create,lk=Tc.create,Gk=tc.create,ck=oG.create,bk=dd.create,Zk=sc.create,dk=Ml.create,Wk=Ml.strictCreate,ak=_b.create,mk=LN.create,Nk=$b.create,ek=jG.create,Yk=kN.create,pk=Wd.create,Vk=ad.create,nk=zN.create,hk=IZ.create,tk=lZ.create,sk=GZ.create,Rk=cZ.create,Fk=qc.create,uk=NG.create,Xk=aG.create,Qk=KG.create,Hk=NG.createWithPreprocess,vk=da.create,wk=()=>Ou().optional(),ik=()=>Mu().optional(),ok=()=>ju().optional(),yk={string:(l=>Dc.create({...l,coerce:!0})),number:(l=>Sb.create({...l,coerce:!0})),boolean:(l=>Db.create({...l,coerce:!0})),bigint:(l=>fb.create({...l,coerce:!0})),date:(l=>Tb.create({...l,coerce:!0}))},Ek=aI});var r={};TI(r,{BRAND:()=>SL,DIRTY:()=>Kb,EMPTY_PATH:()=>HL,INVALID:()=>aI,NEVER:()=>Ek,OK:()=>gl,ParseStatus:()=>Ql,Schema:()=>pI,ZodAny:()=>Tc,ZodArray:()=>sc,ZodBigInt:()=>fb,ZodBoolean:()=>Db,ZodBranded:()=>Za,ZodCatch:()=>ZZ,ZodDate:()=>Tb,ZodDefault:()=>bZ,ZodDiscriminatedUnion:()=>LN,ZodEffects:()=>NG,ZodEnum:()=>GZ,ZodError:()=>Cl,ZodFirstPartyTypeKind:()=>NI,ZodFunction:()=>zN,ZodIntersection:()=>$b,ZodIssueCode:()=>M,ZodLazy:()=>IZ,ZodLiteral:()=>lZ,ZodMap:()=>Wd,ZodNaN:()=>md,ZodNativeEnum:()=>cZ,ZodNever:()=>oG,ZodNull:()=>Pb,ZodNullable:()=>KG,ZodNumber:()=>Sb,ZodObject:()=>Ml,ZodOptional:()=>aG,ZodParsedType:()=>_,ZodPipeline:()=>da,ZodPromise:()=>qc,ZodReadonly:()=>dZ,ZodRecord:()=>kN,ZodSchema:()=>pI,ZodSet:()=>ad,ZodString:()=>Dc,ZodSymbol:()=>Zd,ZodTransformer:()=>NG,ZodTuple:()=>jG,ZodType:()=>pI,ZodUndefined:()=>qb,ZodUnion:()=>_b,ZodUnknown:()=>tc,ZodVoid:()=>dd,addIssueToContext:()=>q,any:()=>lk,array:()=>Zk,bigint:()=>qL,boolean:()=>ju,coerce:()=>yk,custom:()=>Bu,date:()=>PL,datetimeRegex:()=>xu,defaultErrorMap:()=>nc,discriminatedUnion:()=>mk,effect:()=>uk,enum:()=>sk,function:()=>nk,getErrorMap:()=>Gd,getParsedType:()=>MG,instanceof:()=>DL,intersection:()=>Nk,isAborted:()=>gN,isAsync:()=>cd,isDirty:()=>AN,isValid:()=>fc,late:()=>fL,lazy:()=>hk,literal:()=>tk,makeIssue:()=>ba,map:()=>pk,nan:()=>TL,nativeEnum:()=>Rk,never:()=>ck,null:()=>Ik,nullable:()=>Qk,number:()=>Mu,object:()=>dk,objectUtil:()=>RV,oboolean:()=>ok,onumber:()=>ik,optional:()=>Xk,ostring:()=>wk,pipeline:()=>vk,preprocess:()=>Hk,promise:()=>Fk,quotelessJson:()=>uL,record:()=>Yk,set:()=>Vk,setErrorMap:()=>QL,strictObject:()=>Wk,string:()=>Ou,symbol:()=>_L,transformer:()=>uk,tuple:()=>ek,undefined:()=>$L,union:()=>ak,unknown:()=>Gk,util:()=>hI,void:()=>bk});var HV=u(()=>{CN();uV();Cu();ca();Ku();rN()});var Nd=u(()=>{HV();HV()});function Jk(l=!1){try{let I=Su.parse(process.env);return vV.info("Environment variables validated successfully"),I}catch(I){if(I instanceof r.ZodError){let G=I.errors.map(c=>`${c.path.join(".")}: ${c.message}`).join(`
|
|
4
4
|
`);if(l)throw vV.error("Environment validation failed (strict mode)",{errors:G}),new Error(`Environment validation failed:
|
|
5
5
|
${G}`);return vV.warn("Environment validation failed, using defaults",{errors:G}),Su.parse({})}throw I}}function rI(l=!1){return wV===null&&(wV=Jk(l)),wV}var vV,Su,wV,IG=u(()=>{"use strict";Nd();T();vV=J("config:env"),Su=r.object({AUTH_REQUIRED:r.enum(["true","false"]).transform(l=>l==="true").default("false"),AUTH_SECRET:r.string().min(32,"AUTH_SECRET must be at least 32 characters").optional(),AUTH_ISSUER:r.string().min(1).optional().default("nock-hsa"),AUTH_AUDIENCE:r.string().min(1).optional().default("hsa-mcp"),AUTH_JWKS_URL:r.string().url("AUTH_JWKS_URL must be a valid URL").optional(),API_KEYS:r.string().optional().transform(l=>l?l.split(",").map(I=>I.trim()).filter(Boolean):[]).default(""),API_KEY_SCOPES:r.string().default("read").transform(l=>l.split(",").map(I=>I.trim()).filter(Boolean)).pipe(r.array(r.enum(["read","write","admin"])).min(1,"At least one scope required")),HSA_DAEMON_PORT:r.coerce.number().int("Port must be an integer").min(1,"Port must be >= 1").max(65535,"Port must be <= 65535").optional(),PORT:r.coerce.number().int("Port must be an integer").min(1,"Port must be >= 1").max(65535,"Port must be <= 65535").optional(),HSA_DAEMON_MODE:r.enum(["true","false"]).transform(l=>l==="true").default("false"),HSA_NO_PROXY:r.enum(["true","false"]).transform(l=>l==="true").default("false"),HSA_DASHBOARD:r.enum(["true","false"]).transform(l=>l==="true").default("false"),HSA_DASHBOARD_PORT:r.coerce.number().int("Port must be an integer").min(1,"Port must be >= 1").max(65535,"Port must be <= 65535").optional(),ALLOWED_ORIGINS:r.string().optional().transform(l=>l?l.split(",").map(I=>I.trim()).filter(Boolean):[]),HSA_MAX_TOKENS:r.coerce.number().int("Token budget must be an integer").min(100,"Token budget must be >= 100").max(128e3,"Token budget must be <= 128000").optional(),HSA_ENCODING:r.enum(["cl100k_base","p50k_base","r50k_base"]).default("cl100k_base"),HSA_MAX_ENGINES:r.coerce.number().int("Max engines must be an integer").min(1,"Max engines must be >= 1").max(5,"Max engines must be <= 5").optional(),HSA_ENGINE_IDLE_MS:r.coerce.number().int("Idle timeout must be an integer").min(1e3,"Idle timeout must be >= 1000ms").optional(),HSA_IDLE_TIMEOUT_MS:r.coerce.number().int("Idle timeout must be an integer").min(1e3,"Idle timeout must be >= 1000ms").optional(),HSA_STRICT_INTEGRITY:r.enum(["true","false"]).transform(l=>l==="true").default("false"),HSA_PROJECT_PATH:r.string().min(1).optional(),HSA_RUN_DIR:r.string().min(1).optional(),HSA_AUTH_TOKEN:r.string().min(16,"HSA_AUTH_TOKEN must be >= 16 chars").optional(),HSA_SHUTDOWN_NONCE:r.string().optional(),HSA_IDE_NAME:r.string().optional(),HSA_IDE_VERSION:r.string().optional(),HSA_WINDOW_ID:r.string().optional()});wV=null});import fu from"node:path";import{mkdir as rk}from"node:fs/promises";import{existsSync as Ck}from"node:fs";async function Du(l,I="pure-ts"){let G=fu.join(l,Ju);try{await rk(G,{recursive:!0}),iV.info("Ensured HSA index directory",{indexDir:G})}catch(d){iV.warn("Could not create index directory",{indexDir:G,error:String(d)})}let c=rI(),b=c.HSA_MAX_TOKENS??EN,Z={projectPath:l,indexDir:G,maxTokens:b,engineTier:I,encoding:c.HSA_ENCODING};return iV.info("Configuration built",{projectPath:Z.projectPath,indexDir:Z.indexDir,maxTokens:Z.maxTokens,engineTier:Z.engineTier}),Z}function Tu(l){let I=[],G=[];return l.projectPath||I.push("projectPath is required"),fu.isAbsolute(l.projectPath)||I.push("projectPath must be an absolute path"),l.maxTokens<Ga&&G.push(`maxTokens (${l.maxTokens}) is very low, minimum is ${Ga}`),l.maxTokens>la&&G.push(`maxTokens (${l.maxTokens}) exceeds recommended maximum of ${la}`),Ck(l.projectPath)||G.push(`projectPath does not exist: ${l.projectPath}`),{valid:I.length===0,errors:I,warnings:G}}var iV,qu=u(()=>{"use strict";bl();IG();T();iV=J("config")});import Nl from"node:path";import Pu from"node:os";import{existsSync as WZ,statSync as gk,readFileSync as Ak,readdirSync as Lk}from"node:fs";function kk(){let l=process.env.HSA_RUN_DIR||Nl.join(process.env.HOME||process.env.USERPROFILE||Pu.homedir(),".hsa");return Nl.join(l,"workspace")}function _u(){let I=rI().HSA_PROJECT_PATH;if(I&&!I.includes("${")){let d=Nl.resolve(I);if(Pc(d))lG.warn("HSA_PROJECT_PATH points to dangerous dir, ignoring",{path:d});else return lG.info("Using HSA_PROJECT_PATH env var",{path:d}),ed(d)}else I?.includes("${")&&lG.warn("HSA_PROJECT_PATH contains unresolved variable, falling through",{raw:I});let G=process.argv.indexOf("--project-path");if(G!==-1&&process.argv[G+1]){let d=Nl.resolve(process.argv[G+1]);if(Pc(d))lG.warn("--project-path points to dangerous dir, ignoring",{path:d});else return lG.info("Using --project-path CLI argument",{path:d}),ed(d)}let c=zk();if(c)return lG.info("Using cached project root from .domyh/",{path:c}),ed(c);let b=process.cwd(),Z=xk(b);if(Z!==b&&!Pc(Z))return lG.info("Found workspace root via upward traversal",{path:Z,cwd:b}),ed(Z);if(Pc(b)){let d=kk();return lG.warn("cwd is a dangerous root \u2014 falling back to safe workspace",{cwd:b,fallback:d,reason:"Scanning home/system/IDE dirs causes JavaScript heap OOM"}),ed(d)}return lG.info("Using cwd as project path",{path:b}),ed(b)}function zk(){try{let l=[process.cwd()],I=process.cwd(),G=Nl.parse(I).root,c=0;for(;I!==G&&c<10&&!Pc(I);){if(WZ(Nl.join(I,".domyh"))){I!==process.cwd()&&l.unshift(I);break}I=Nl.dirname(I),c++}for(let b of l){let Z=Nl.join(b,".domyh","mcp-context.json");if(!WZ(Z))continue;let d=Ak(Z,"utf-8"),W=JSON.parse(d);if(W?.version!==1||!W?.project?.root)continue;let a=Nl.resolve(W.project.root);if(WZ(a)){if(Pc(a)){lG.warn("Cached project root is dangerous \u2014 ignoring",{cached:a,cacheFile:Z});continue}return a}}return null}catch{return null}}function xk(l){let I=[".git","rush.json","nx.json","turbo.json","lerna.json","pnpm-workspace.yaml",".domyh","deno.json","Cargo.toml"],G=l,c=Nl.parse(G).root,b=0,Z=10;for(;G!==c&&b<Z&&!Pc(G);){for(let d of I)if(WZ(Nl.join(G,d)))return G;try{if(Lk(G).some(W=>W.endsWith(".sln")||W.endsWith(".slnx")||W.endsWith(".code-workspace")))return G}catch(d){if(d.code!=="EACCES")break}G=Nl.dirname(G),b++}return l}function ed(l){if(!WZ(l))return lG.warn("Project path does not exist, using anyway",{path:l}),l;try{if(!gk(l).isDirectory())return lG.warn("Project path is not a directory, using parent",{path:l}),Nl.dirname(l)}catch{}return Uk(l)||lG.warn("No project markers found in resolved root \u2014 may be wrong directory",{path:l,hint:"Expected .git, package.json, Cargo.toml, go.mod, etc."}),l}function Pc(l){let I=Nl.resolve(l),G=I.toLowerCase().replace(/\\/g,"/");if(I===Nl.parse(I).root)return!0;let c=Pu.homedir();return!!(I===Nl.resolve(c)||["windows/system32","windows/syswow64","program files","program files (x86)","programdata","appdata/local","appdata/roaming","appdata/locallow","anthropicclaude","claude-desktop","programs/antigravity","programs/cursor","programs/windsurf","programs/microsoft vs code","programs/zed",".vscode-server/","/applications/","/library/","/system/","/usr/","/var/","/etc/","/tmp/"].some(d=>G.includes(d))||["resources.pak","icudtl.dat","chrome_100_percent.pak","vk_swiftshader_icd.json"].some(d=>WZ(Nl.join(l,d))))}function Uk(l){let I=[".git","package.json","Cargo.toml","go.mod","pyproject.toml","setup.py","requirements.txt","pom.xml","build.gradle","build.gradle.kts","CMakeLists.txt","Makefile",".agent","composer.json","Gemfile","mix.exs","stack.yaml","deno.json","bun.lockb"];try{return I.some(G=>WZ(Nl.join(l,G)))}catch{return!1}}var lG,oV,yV=u(()=>{"use strict";T();IG();lG=J("config:resolver");oV=Pc});var IX=F((zdI,$u)=>{var _c=D("constants"),Bk=process.cwd,xN=null,Ok=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return xN||(xN=Bk.call(process)),xN};try{process.cwd()}catch{}typeof process.chdir=="function"&&(EV=process.chdir,process.chdir=function(l){xN=null,EV.call(process,l)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,EV));var EV;$u.exports=Mk;function Mk(l){_c.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&I(l),l.lutimes||G(l),l.chown=Z(l.chown),l.fchown=Z(l.fchown),l.lchown=Z(l.lchown),l.chmod=c(l.chmod),l.fchmod=c(l.fchmod),l.lchmod=c(l.lchmod),l.chownSync=d(l.chownSync),l.fchownSync=d(l.fchownSync),l.lchownSync=d(l.lchownSync),l.chmodSync=b(l.chmodSync),l.fchmodSync=b(l.fchmodSync),l.lchmodSync=b(l.lchmodSync),l.stat=W(l.stat),l.fstat=W(l.fstat),l.lstat=W(l.lstat),l.statSync=a(l.statSync),l.fstatSync=a(l.fstatSync),l.lstatSync=a(l.lstatSync),l.chmod&&!l.lchmod&&(l.lchmod=function(N,e,Y){Y&&process.nextTick(Y)},l.lchmodSync=function(){}),l.chown&&!l.lchown&&(l.lchown=function(N,e,Y,p){p&&process.nextTick(p)},l.lchownSync=function(){}),Ok==="win32"&&(l.rename=typeof l.rename!="function"?l.rename:(function(N){function e(Y,p,V){var n=Date.now(),h=0;N(Y,p,function t(s){if(s&&(s.code==="EACCES"||s.code==="EPERM"||s.code==="EBUSY")&&Date.now()-n<6e4){setTimeout(function(){l.stat(p,function(R,H){R&&R.code==="ENOENT"?N(Y,p,t):V(s)})},h),h<100&&(h+=10);return}V&&V(s)})}return Object.setPrototypeOf&&Object.setPrototypeOf(e,N),e})(l.rename)),l.read=typeof l.read!="function"?l.read:(function(N){function e(Y,p,V,n,h,t){var s;if(t&&typeof t=="function"){var R=0;s=function(H,w,E){if(H&&H.code==="EAGAIN"&&R<10)return R++,N.call(l,Y,p,V,n,h,s);t.apply(this,arguments)}}return N.call(l,Y,p,V,n,h,s)}return Object.setPrototypeOf&&Object.setPrototypeOf(e,N),e})(l.read),l.readSync=typeof l.readSync!="function"?l.readSync:(function(N){return function(e,Y,p,V,n){for(var h=0;;)try{return N.call(l,e,Y,p,V,n)}catch(t){if(t.code==="EAGAIN"&&h<10){h++;continue}throw t}}})(l.readSync);function I(N){N.lchmod=function(e,Y,p){N.open(e,_c.O_WRONLY|_c.O_SYMLINK,Y,function(V,n){if(V){p&&p(V);return}N.fchmod(n,Y,function(h){N.close(n,function(t){p&&p(h||t)})})})},N.lchmodSync=function(e,Y){var p=N.openSync(e,_c.O_WRONLY|_c.O_SYMLINK,Y),V=!0,n;try{n=N.fchmodSync(p,Y),V=!1}finally{if(V)try{N.closeSync(p)}catch{}else N.closeSync(p)}return n}}function G(N){_c.hasOwnProperty("O_SYMLINK")&&N.futimes?(N.lutimes=function(e,Y,p,V){N.open(e,_c.O_SYMLINK,function(n,h){if(n){V&&V(n);return}N.futimes(h,Y,p,function(t){N.close(h,function(s){V&&V(t||s)})})})},N.lutimesSync=function(e,Y,p){var V=N.openSync(e,_c.O_SYMLINK),n,h=!0;try{n=N.futimesSync(V,Y,p),h=!1}finally{if(h)try{N.closeSync(V)}catch{}else N.closeSync(V)}return n}):N.futimes&&(N.lutimes=function(e,Y,p,V){V&&process.nextTick(V)},N.lutimesSync=function(){})}function c(N){return N&&function(e,Y,p){return N.call(l,e,Y,function(V){m(V)&&(V=null),p&&p.apply(this,arguments)})}}function b(N){return N&&function(e,Y){try{return N.call(l,e,Y)}catch(p){if(!m(p))throw p}}}function Z(N){return N&&function(e,Y,p,V){return N.call(l,e,Y,p,function(n){m(n)&&(n=null),V&&V.apply(this,arguments)})}}function d(N){return N&&function(e,Y,p){try{return N.call(l,e,Y,p)}catch(V){if(!m(V))throw V}}}function W(N){return N&&function(e,Y,p){typeof Y=="function"&&(p=Y,Y=null);function V(n,h){h&&(h.uid<0&&(h.uid+=4294967296),h.gid<0&&(h.gid+=4294967296)),p&&p.apply(this,arguments)}return Y?N.call(l,e,Y,V):N.call(l,e,V)}}function a(N){return N&&function(e,Y){var p=Y?N.call(l,e,Y):N.call(l,e);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}function m(N){if(!N||N.code==="ENOSYS")return!0;var e=!process.getuid||process.getuid()!==0;return!!(e&&(N.code==="EINVAL"||N.code==="EPERM"))}}});var cX=F((xdI,GX)=>{var lX=D("stream").Stream;GX.exports=jk;function jk(l){return{ReadStream:I,WriteStream:G};function I(c,b){if(!(this instanceof I))return new I(c,b);lX.call(this);var Z=this;this.path=c,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,b=b||{};for(var d=Object.keys(b),W=0,a=d.length;W<a;W++){var m=d[W];this[m]=b[m]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){Z._read()});return}l.open(this.path,this.flags,this.mode,function(N,e){if(N){Z.emit("error",N),Z.readable=!1;return}Z.fd=e,Z.emit("open",e),Z._read()})}function G(c,b){if(!(this instanceof G))return new G(c,b);lX.call(this),this.path=c,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,b=b||{};for(var Z=Object.keys(b),d=0,W=Z.length;d<W;d++){var a=Z[d];this[a]=b[a]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=l.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var ZX=F((UdI,bX)=>{"use strict";bX.exports=Sk;var Kk=Object.getPrototypeOf||function(l){return l.__proto__};function Sk(l){if(l===null||typeof l!="object")return l;if(l instanceof Object)var I={__proto__:Kk(l)};else var I=Object.create(null);return Object.getOwnPropertyNames(l).forEach(function(G){Object.defineProperty(I,G,Object.getOwnPropertyDescriptor(l,G))}),I}});var gV=F((BdI,CV)=>{var OI=D("fs"),fk=IX(),Dk=cX(),Tk=ZX(),UN=D("util"),Hl,ON;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Hl=Symbol.for("graceful-fs.queue"),ON=Symbol.for("graceful-fs.previous")):(Hl="___graceful-fs.queue",ON="___graceful-fs.previous");function qk(){}function aX(l,I){Object.defineProperty(l,Hl,{get:function(){return I}})}var aZ=qk;UN.debuglog?aZ=UN.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(aZ=function(){var l=UN.format.apply(UN,arguments);l="GFS4: "+l.split(/\n/).join(`
|
|
6
6
|
GFS4: `),console.error(l)});OI[Hl]||(dX=global[Hl]||[],aX(OI,dX),OI.close=(function(l){function I(G,c){return l.call(OI,G,function(b){b||WX(),typeof c=="function"&&c.apply(this,arguments)})}return Object.defineProperty(I,ON,{value:l}),I})(OI.close),OI.closeSync=(function(l){function I(G){l.apply(OI,arguments),WX()}return Object.defineProperty(I,ON,{value:l}),I})(OI.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){aZ(OI[Hl]),D("assert").equal(OI[Hl].length,0)}));var dX;global[Hl]||aX(global,OI[Hl]);CV.exports=JV(Tk(OI));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!OI.__patched&&(CV.exports=JV(OI),OI.__patched=!0);function JV(l){fk(l),l.gracefulify=JV,l.createReadStream=w,l.createWriteStream=E;var I=l.readFile;l.readFile=G;function G(v,X,A){return typeof X=="function"&&(A=X,X=null),L(v,X,A);function L(j,o,k,O){return I(j,o,function(S){S&&(S.code==="EMFILE"||S.code==="ENFILE")?Yd([L,[j,o,k],S,O||Date.now(),Date.now()]):typeof k=="function"&&k.apply(this,arguments)})}}var c=l.writeFile;l.writeFile=b;function b(v,X,A,L){return typeof A=="function"&&(L=A,A=null),j(v,X,A,L);function j(o,k,O,S,B){return c(o,k,O,function($){$&&($.code==="EMFILE"||$.code==="ENFILE")?Yd([j,[o,k,O,S],$,B||Date.now(),Date.now()]):typeof S=="function"&&S.apply(this,arguments)})}}var Z=l.appendFile;Z&&(l.appendFile=d);function d(v,X,A,L){return typeof A=="function"&&(L=A,A=null),j(v,X,A,L);function j(o,k,O,S,B){return Z(o,k,O,function($){$&&($.code==="EMFILE"||$.code==="ENFILE")?Yd([j,[o,k,O,S],$,B||Date.now(),Date.now()]):typeof S=="function"&&S.apply(this,arguments)})}}var W=l.copyFile;W&&(l.copyFile=a);function a(v,X,A,L){return typeof A=="function"&&(L=A,A=0),j(v,X,A,L);function j(o,k,O,S,B){return W(o,k,O,function($){$&&($.code==="EMFILE"||$.code==="ENFILE")?Yd([j,[o,k,O,S],$,B||Date.now(),Date.now()]):typeof S=="function"&&S.apply(this,arguments)})}}var m=l.readdir;l.readdir=e;var N=/^v[0-5]\./;function e(v,X,A){typeof X=="function"&&(A=X,X=null);var L=N.test(process.version)?function(k,O,S,B){return m(k,j(k,O,S,B))}:function(k,O,S,B){return m(k,O,j(k,O,S,B))};return L(v,X,A);function j(o,k,O,S){return function(B,$){B&&(B.code==="EMFILE"||B.code==="ENFILE")?Yd([L,[o,k,O],B,S||Date.now(),Date.now()]):($&&$.sort&&$.sort(),typeof O=="function"&&O.call(this,B,$))}}}if(process.version.substr(0,4)==="v0.8"){var Y=Dk(l);t=Y.ReadStream,R=Y.WriteStream}var p=l.ReadStream;p&&(t.prototype=Object.create(p.prototype),t.prototype.open=s);var V=l.WriteStream;V&&(R.prototype=Object.create(V.prototype),R.prototype.open=H),Object.defineProperty(l,"ReadStream",{get:function(){return t},set:function(v){t=v},enumerable:!0,configurable:!0}),Object.defineProperty(l,"WriteStream",{get:function(){return R},set:function(v){R=v},enumerable:!0,configurable:!0});var n=t;Object.defineProperty(l,"FileReadStream",{get:function(){return n},set:function(v){n=v},enumerable:!0,configurable:!0});var h=R;Object.defineProperty(l,"FileWriteStream",{get:function(){return h},set:function(v){h=v},enumerable:!0,configurable:!0});function t(v,X){return this instanceof t?(p.apply(this,arguments),this):t.apply(Object.create(t.prototype),arguments)}function s(){var v=this;y(v.path,v.flags,v.mode,function(X,A){X?(v.autoClose&&v.destroy(),v.emit("error",X)):(v.fd=A,v.emit("open",A),v.read())})}function R(v,X){return this instanceof R?(V.apply(this,arguments),this):R.apply(Object.create(R.prototype),arguments)}function H(){var v=this;y(v.path,v.flags,v.mode,function(X,A){X?(v.destroy(),v.emit("error",X)):(v.fd=A,v.emit("open",A))})}function w(v,X){return new l.ReadStream(v,X)}function E(v,X){return new l.WriteStream(v,X)}var g=l.open;l.open=y;function y(v,X,A,L){return typeof A=="function"&&(L=A,A=null),j(v,X,A,L);function j(o,k,O,S,B){return g(o,k,O,function($,z){$&&($.code==="EMFILE"||$.code==="ENFILE")?Yd([j,[o,k,O,S],$,B||Date.now(),Date.now()]):typeof S=="function"&&S.apply(this,arguments)})}}return l}function Yd(l){aZ("ENQUEUE",l[0].name,l[1]),OI[Hl].push(l),rV()}var BN;function WX(){for(var l=Date.now(),I=0;I<OI[Hl].length;++I)OI[Hl][I].length>2&&(OI[Hl][I][3]=l,OI[Hl][I][4]=l);rV()}function rV(){if(clearTimeout(BN),BN=void 0,OI[Hl].length!==0){var l=OI[Hl].shift(),I=l[0],G=l[1],c=l[2],b=l[3],Z=l[4];if(b===void 0)aZ("RETRY",I.name,G),I.apply(null,G);else if(Date.now()-b>=6e4){aZ("TIMEOUT",I.name,G);var d=G.pop();typeof d=="function"&&d.call(null,c)}else{var W=Date.now()-Z,a=Math.max(Z-b,1),m=Math.min(a*1.2,100);W>=m?(aZ("RETRY",I.name,G),I.apply(null,G.concat([b]))):OI[Hl].push(l)}BN===void 0&&(BN=setTimeout(rV,0))}}});var NX=F((OdI,mX)=>{function eG(l,I){typeof I=="boolean"&&(I={forever:I}),this._originalTimeouts=JSON.parse(JSON.stringify(l)),this._timeouts=l,this._options=I||{},this._maxRetryTime=I&&I.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}mX.exports=eG;eG.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};eG.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};eG.prototype.retry=function(l){if(this._timeout&&clearTimeout(this._timeout),!l)return!1;var I=new Date().getTime();if(l&&I-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(l);var G=this._timeouts.shift();if(G===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),G=this._timeouts.shift();else return!1;var c=this,b=setTimeout(function(){c._attempts++,c._operationTimeoutCb&&(c._timeout=setTimeout(function(){c._operationTimeoutCb(c._attempts)},c._operationTimeout),c._options.unref&&c._timeout.unref()),c._fn(c._attempts)},G);return this._options.unref&&b.unref(),!0};eG.prototype.attempt=function(l,I){this._fn=l,I&&(I.timeout&&(this._operationTimeout=I.timeout),I.cb&&(this._operationTimeoutCb=I.cb));var G=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){G._operationTimeoutCb()},G._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};eG.prototype.try=function(l){console.log("Using RetryOperation.try() is deprecated"),this.attempt(l)};eG.prototype.start=function(l){console.log("Using RetryOperation.start() is deprecated"),this.attempt(l)};eG.prototype.start=eG.prototype.try;eG.prototype.errors=function(){return this._errors};eG.prototype.attempts=function(){return this._attempts};eG.prototype.mainError=function(){if(this._errors.length===0)return null;for(var l={},I=null,G=0,c=0;c<this._errors.length;c++){var b=this._errors[c],Z=b.message,d=(l[Z]||0)+1;l[Z]=d,d>=G&&(I=b,G=d)}return I}});var eX=F(mZ=>{var Pk=NX();mZ.operation=function(l){var I=mZ.timeouts(l);return new Pk(I,{forever:l&&l.forever,unref:l&&l.unref,maxRetryTime:l&&l.maxRetryTime})};mZ.timeouts=function(l){if(l instanceof Array)return[].concat(l);var I={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var G in l)I[G]=l[G];if(I.minTimeout>I.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var c=[],b=0;b<I.retries;b++)c.push(this.createTimeout(b,I));return l&&l.forever&&!c.length&&c.push(this.createTimeout(b,I)),c.sort(function(Z,d){return Z-d}),c};mZ.createTimeout=function(l,I){var G=I.randomize?Math.random()+1:1,c=Math.round(G*I.minTimeout*Math.pow(I.factor,l));return c=Math.min(c,I.maxTimeout),c};mZ.wrap=function(l,I,G){if(I instanceof Array&&(G=I,I=null),!G){G=[];for(var c in l)typeof l[c]=="function"&&G.push(c)}for(var b=0;b<G.length;b++){var Z=G[b],d=l[Z];l[Z]=function(a){var m=mZ.operation(I),N=Array.prototype.slice.call(arguments,1),e=N.pop();N.push(function(Y){m.retry(Y)||(Y&&(arguments[0]=m.mainError()),e.apply(this,arguments))}),m.attempt(function(){a.apply(l,N)})}.bind(l,d),l[Z].options=I}}});var pX=F((jdI,YX)=>{YX.exports=eX()});var VX=F((KdI,MN)=>{MN.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&MN.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&MN.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var RX=F((SdI,nd)=>{var xI=global.process,NZ=function(l){return l&&typeof l=="object"&&typeof l.removeListener=="function"&&typeof l.emit=="function"&&typeof l.reallyExit=="function"&&typeof l.listeners=="function"&&typeof l.kill=="function"&&typeof l.pid=="number"&&typeof l.on=="function"};NZ(xI)?(nX=D("assert"),pd=VX(),hX=/^win/i.test(xI.platform),Wa=D("events"),typeof Wa!="function"&&(Wa=Wa.EventEmitter),xI.__signal_exit_emitter__?el=xI.__signal_exit_emitter__:(el=xI.__signal_exit_emitter__=new Wa,el.count=0,el.emitted={}),el.infinite||(el.setMaxListeners(1/0),el.infinite=!0),nd.exports=function(l,I){if(!NZ(global.process))return function(){};nX.equal(typeof l,"function","a callback must be provided for exit handler"),Vd===!1&&AV();var G="exit";I&&I.alwaysLast&&(G="afterexit");var c=function(){el.removeListener(G,l),el.listeners("exit").length===0&&el.listeners("afterexit").length===0&&jN()};return el.on(G,l),c},jN=function(){!Vd||!NZ(global.process)||(Vd=!1,pd.forEach(function(I){try{xI.removeListener(I,KN[I])}catch{}}),xI.emit=SN,xI.reallyExit=LV,el.count-=1)},nd.exports.unload=jN,eZ=function(I,G,c){el.emitted[I]||(el.emitted[I]=!0,el.emit(I,G,c))},KN={},pd.forEach(function(l){KN[l]=function(){if(NZ(global.process)){var G=xI.listeners(l);G.length===el.count&&(jN(),eZ("exit",null,l),eZ("afterexit",null,l),hX&&l==="SIGHUP"&&(l="SIGINT"),xI.kill(xI.pid,l))}}}),nd.exports.signals=function(){return pd},Vd=!1,AV=function(){Vd||!NZ(global.process)||(Vd=!0,el.count+=1,pd=pd.filter(function(I){try{return xI.on(I,KN[I]),!0}catch{return!1}}),xI.emit=sX,xI.reallyExit=tX)},nd.exports.load=AV,LV=xI.reallyExit,tX=function(I){NZ(global.process)&&(xI.exitCode=I||0,eZ("exit",xI.exitCode,null),eZ("afterexit",xI.exitCode,null),LV.call(xI,xI.exitCode))},SN=xI.emit,sX=function(I,G){if(I==="exit"&&NZ(global.process)){G!==void 0&&(xI.exitCode=G);var c=SN.apply(this,arguments);return eZ("exit",xI.exitCode,null),eZ("afterexit",xI.exitCode,null),c}else return SN.apply(this,arguments)}):nd.exports=function(){return function(){}};var nX,pd,hX,Wa,el,jN,eZ,KN,Vd,AV,LV,tX,SN,sX});var uX=F((fdI,kV)=>{"use strict";var FX=Symbol();function _k(l,I,G){let c=I[FX];if(c)return I.stat(l,(Z,d)=>{if(Z)return G(Z);G(null,d.mtime,c)});let b=new Date(Math.ceil(Date.now()/1e3)*1e3+5);I.utimes(l,b,b,Z=>{if(Z)return G(Z);I.stat(l,(d,W)=>{if(d)return G(d);let a=W.mtime.getTime()%1e3===0?"s":"ms";Object.defineProperty(I,FX,{value:a}),G(null,W.mtime,a)})})}function $k(l){let I=Date.now();return l==="s"&&(I=Math.ceil(I/1e3)*1e3),new Date(I)}kV.exports.probe=_k;kV.exports.getMtime=$k});var wX=F((DdI,ma)=>{"use strict";var Iz=D("path"),UV=gV(),lz=pX(),Gz=RX(),XX=uX(),Rc={};function aa(l,I){return I.lockfilePath||`${l}.lock`}function BV(l,I,G){if(!I.realpath)return G(null,Iz.resolve(l));I.fs.realpath(l,G)}function xV(l,I,G){let c=aa(l,I);I.fs.mkdir(c,b=>{if(!b)return XX.probe(c,I.fs,(Z,d,W)=>{if(Z)return I.fs.rmdir(c,()=>{}),G(Z);G(null,d,W)});if(b.code!=="EEXIST")return G(b);if(I.stale<=0)return G(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:l}));I.fs.stat(c,(Z,d)=>{if(Z)return Z.code==="ENOENT"?xV(l,{...I,stale:0},G):G(Z);if(!QX(d,I))return G(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:l}));HX(l,I,W=>{if(W)return G(W);xV(l,{...I,stale:0},G)})})})}function QX(l,I){return l.mtime.getTime()<Date.now()-I.stale}function HX(l,I,G){I.fs.rmdir(aa(l,I),c=>{if(c&&c.code!=="ENOENT")return G(c);G()})}function fN(l,I){let G=Rc[l];G.updateTimeout||(G.updateDelay=G.updateDelay||I.update,G.updateTimeout=setTimeout(()=>{G.updateTimeout=null,I.fs.stat(G.lockfilePath,(c,b)=>{let Z=G.lastUpdate+I.stale<Date.now();if(c)return c.code==="ENOENT"||Z?zV(l,G,Object.assign(c,{code:"ECOMPROMISED"})):(G.updateDelay=1e3,fN(l,I));if(!(G.mtime.getTime()===b.mtime.getTime()))return zV(l,G,Object.assign(new Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let W=XX.getMtime(G.mtimePrecision);I.fs.utimes(G.lockfilePath,W,W,a=>{let m=G.lastUpdate+I.stale<Date.now();if(!G.released){if(a)return a.code==="ENOENT"||m?zV(l,G,Object.assign(a,{code:"ECOMPROMISED"})):(G.updateDelay=1e3,fN(l,I));G.mtime=W,G.lastUpdate=Date.now(),G.updateDelay=null,fN(l,I)}})})},G.updateDelay),G.updateTimeout.unref&&G.updateTimeout.unref())}function zV(l,I,G){I.released=!0,I.updateTimeout&&clearTimeout(I.updateTimeout),Rc[l]===I&&delete Rc[l],I.options.onCompromised(G)}function cz(l,I,G){I={stale:1e4,update:null,realpath:!0,retries:0,fs:UV,onCompromised:c=>{throw c},...I},I.retries=I.retries||0,I.retries=typeof I.retries=="number"?{retries:I.retries}:I.retries,I.stale=Math.max(I.stale||0,2e3),I.update=I.update==null?I.stale/2:I.update||0,I.update=Math.max(Math.min(I.update,I.stale/2),1e3),BV(l,I,(c,b)=>{if(c)return G(c);let Z=lz.operation(I.retries);Z.attempt(()=>{xV(b,I,(d,W,a)=>{if(Z.retry(d))return;if(d)return G(Z.mainError());let m=Rc[b]={lockfilePath:aa(b,I),mtime:W,mtimePrecision:a,options:I,lastUpdate:Date.now()};fN(b,I),G(null,N=>{if(m.released)return N&&N(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));vX(b,{...I,realpath:!1},N)})})})})}function vX(l,I,G){I={fs:UV,realpath:!0,...I},BV(l,I,(c,b)=>{if(c)return G(c);let Z=Rc[b];if(!Z)return G(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));Z.updateTimeout&&clearTimeout(Z.updateTimeout),Z.released=!0,delete Rc[b],HX(b,I,G)})}function bz(l,I,G){I={stale:1e4,realpath:!0,fs:UV,...I},I.stale=Math.max(I.stale||0,2e3),BV(l,I,(c,b)=>{if(c)return G(c);I.fs.stat(aa(b,I),(Z,d)=>Z?Z.code==="ENOENT"?G(null,!1):G(Z):G(null,!QX(d,I)))})}function Zz(){return Rc}Gz(()=>{for(let l in Rc){let I=Rc[l].options;try{I.fs.rmdirSync(aa(l,I))}catch{}}});ma.exports.lock=cz;ma.exports.unlock=vX;ma.exports.check=bz;ma.exports.getLocks=Zz});var oX=F((TdI,iX)=>{"use strict";var dz=gV();function Wz(l){let I=["mkdir","realpath","stat","rmdir","utimes"],G={...l};return I.forEach(c=>{G[c]=(...b)=>{let Z=b.pop(),d;try{d=l[`${c}Sync`](...b)}catch(W){return Z(W)}Z(null,d)}}),G}function az(l){return(...I)=>new Promise((G,c)=>{I.push((b,Z)=>{b?c(b):G(Z)}),l(...I)})}function mz(l){return(...I)=>{let G,c;if(I.push((b,Z)=>{G=b,c=Z}),l(...I),G)throw G;return c}}function Nz(l){if(l={...l},l.fs=Wz(l.fs||dz),typeof l.retries=="number"&&l.retries>0||l.retries&&typeof l.retries.retries=="number"&&l.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return l}iX.exports={toPromise:az,toSync:mz,toSyncOptions:Nz}});var EX=F((qdI,$c)=>{"use strict";var hd=wX(),{toPromise:DN,toSync:TN,toSyncOptions:OV}=oX();async function yX(l,I){let G=await DN(hd.lock)(l,I);return DN(G)}function ez(l,I){let G=TN(hd.lock)(l,OV(I));return TN(G)}function Yz(l,I){return DN(hd.unlock)(l,I)}function pz(l,I){return TN(hd.unlock)(l,OV(I))}function Vz(l,I){return DN(hd.check)(l,I)}function nz(l,I){return TN(hd.check)(l,OV(I))}$c.exports=yX;$c.exports.lock=yX;$c.exports.unlock=Yz;$c.exports.lockSync=ez;$c.exports.unlockSync=pz;$c.exports.check=Vz;$c.exports.checkSync=nz});import{readFile as hz,writeFile as tz,rename as sz,unlink as Rz,mkdir as Fz,stat as JX}from"node:fs/promises";import{existsSync as rX}from"node:fs";import td from"node:path";async function CX(l){let I=gX(l);try{if(!rX(I))return Fc.info("No .domyh cache found \u2014 will detect fresh"),null;let G=await hz(I,"utf-8"),c=JSON.parse(G);return c.version!==MV?(Fc.info("Cache version mismatch",{cached:c.version,current:MV}),null):Date.now()>c._meta.expiresAt?(Fc.info("Cache TTL expired \u2014 re-detecting"),null):await vz(l,c._validation.watchedFiles)?(Fc.info("Using cached project context",{project:c.project.name,type:c.project.type,stack:c.stack.primary,age:`${Math.round((Date.now()-new Date(c._meta.createdAt).getTime())/1e3)}s`}),c):(Fc.info("Stack indicator files changed \u2014 re-detecting"),null)}catch(G){return Fc.warn("Failed to load cache \u2014 will detect fresh",{error:G instanceof Error?G.message:String(G)}),null}}async function qN(l,I){let G=gX(l),c=`${G}.${process.pid}.tmp`;try{await Hz(l);let b;try{b=await(await Promise.resolve().then(()=>Kc(EX(),1))).lock(td.dirname(G),Xz)}catch(Z){Fc.warn("Could not acquire lock \u2014 writing without lock",{error:Z instanceof Error?Z.message:String(Z)})}try{let Z=JSON.stringify(I,null,2);await tz(c,Z,"utf-8"),await sz(c,G),Fc.info("Saved project context cache",{path:G})}finally{if(b)try{await b()}catch{}}}catch(b){Fc.warn("Failed to save cache \u2014 continuing without cache",{error:b instanceof Error?b.message:String(b)});try{await Rz(c)}catch{}}}async function PN(l,I,G="single",c="unknown"){let b=await wz(l);return{version:MV,project:{name:td.basename(l),root:l.replace(/\\/g,"/"),type:G},stack:I,_validation:{watchedFiles:b},_meta:{createdAt:new Date().toISOString(),expiresAt:Date.now()+uz,lastIDE:c}}}function gX(l){return td.join(l,".domyh","mcp-context.json")}async function Hz(l){let I=td.join(l,".domyh");rX(I)||await Fz(I,{recursive:!0})}async function vz(l,I){for(let[G,c]of Object.entries(I)){let b=td.join(l,G);try{let Z=await JX(b);if(Math.abs(Z.mtimeMs-c.mtimeMs)>1e3||Z.size!==c.size)return!1}catch{return!1}}return!0}async function wz(l){let I={};for(let G of Qz){let c=td.join(l,G);try{let b=await JX(c);b.isFile()&&(I[G]={mtimeMs:b.mtimeMs,size:b.size})}catch{}}return I}var Fc,MV,uz,Xz,Qz,_N=u(()=>{"use strict";T();Fc=J("config:project-context"),MV=1,uz=1440*60*1e3,Xz={retries:{retries:3,minTimeout:100,maxTimeout:1e3},stale:5e3},Qz=["package.json","go.mod","Cargo.toml","pyproject.toml","setup.py","requirements.txt","pom.xml","build.gradle","build.gradle.kts","CMakeLists.txt","Makefile","nuxt.config.ts","nuxt.config.js","next.config.js","next.config.ts","vite.config.ts","angular.json","pubspec.yaml","composer.json","Gemfile","deno.json","bun.lockb","nx.json","turbo.json","lerna.json","pnpm-workspace.yaml","Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml"]});var AX={};TI(AX,{NativeEngine:()=>jV});var jV,LX=u(()=>{"use strict";jV=class{tier="native";native;constructor(I){this.native=I}sha256(I){return this.native.sha256(typeof I=="string"?Buffer.from(I):I)}async fileHash(I){return this.native.fileHash(I)}async batchFileHash(I){let G=await this.native.batchFileHash([...I]);return new Map(G)}countTokens(I,G){return this.native.countTokens(I)}truncateToTokens(I,G,c){return this.native.truncateToTokens(I,G)}merkleRoot(I){let G=[...I.entries()];return this.native.merkleRoot(G)}merkleDiff(I,G){return this.native.merkleDiff([...I.entries()],[...G.entries()])}}});import{createHash as iz}from"node:crypto";import{readFile as oz}from"node:fs/promises";function yz(l){let I=iz("sha256");return I.update(l),I.digest("hex")}async function Ez(l){let I=await oz(l);return yz(I)}async function kX(l,I=32){let G=new Map;for(let c=0;c<l.length;c+=I){let b=l.slice(c,c+I),Z=await Promise.all(b.map(async d=>{try{return[d,await Ez(d)]}catch{return[d,""]}}));for(let[d,W]of Z)W&&G.set(d,W)}return G}var zX=u(()=>{"use strict"});var xX={};TI(xX,{PureTSEngine:()=>Na});import{createHash as Jz}from"node:crypto";import{readFile as rz}from"node:fs/promises";var Na,KV=u(()=>{"use strict";zX();Na=class{tier="pure-ts";sha256(I){let G=Jz("sha256");return G.update(I),G.digest("hex")}async fileHash(I){let G=await rz(I);return this.sha256(G)}async batchFileHash(I){return kX(I)}countTokens(I,G){if(I.length===0)return 0;let c=0,b=!1;for(let Z=0;Z<I.length;Z++){let d=I.charCodeAt(Z);d>=65&&d<=90||d>=97&&d<=122||d>=48&&d<=57||d===95?b||(c++,b=!0):(b=!1,d!==32&&d!==10&&d!==13&&d!==9&&c++)}return c}truncateToTokens(I,G,c){if(I.length===0||G<=0)return"";if(this.countTokens(I)<=G)return I;let Z=0,d=!1,W=0;for(let a=0;a<I.length;a++){let m=I.charCodeAt(a);if(m>=65&&m<=90||m>=97&&m<=122||m>=48&&m<=57||m===95){if(!d&&(Z++,d=!0,Z>G))return I.slice(0,W)}else if(d=!1,m!==32&&m!==10&&m!==13&&m!==9&&(Z++,Z>G))return I.slice(0,W);W=a+1}return I.slice(0,W)}merkleRoot(I){if(I.size===0)return this.sha256("");let c=[...I.entries()].sort(([b],[Z])=>b.localeCompare(Z)).map(([b,Z])=>this.sha256(`${b}:${Z}`));for(;c.length>1;){let b=[];for(let Z=0;Z<c.length;Z+=2)Z+1<c.length?b.push(this.sha256(c[Z]+c[Z+1])):b.push(c[Z]);c=b}return c[0]}merkleDiff(I,G){let c=[],b=[],Z=[];for(let[d,W]of G){let a=I.get(d);a===void 0?c.push(d):a!==W&&b.push(d)}for(let d of I.keys())G.has(d)||Z.push(d);return{added:c,modified:b,deleted:Z}}}});var UX={};TI(UX,{WasmEngine:()=>SV});var Cz,SV,BX=u(()=>{"use strict";KV();T();Cz=J("engine:wasm"),SV=class{tier="wasm";fallback=new Na;wasm;fallbackWarned=new Set;constructor(I){this.wasm=I}sha256(I){return typeof this.wasm.sha256=="function"?this.wasm.sha256(I):this.fallback.sha256(I)}async fileHash(I){return this.warnFallback("fileHash"),this.fallback.fileHash(I)}async batchFileHash(I){return this.warnFallback("batchFileHash"),this.fallback.batchFileHash(I)}countTokens(I,G){return typeof this.wasm.countTokens=="function"?this.wasm.countTokens(I,G):this.fallback.countTokens(I,G)}truncateToTokens(I,G,c){return this.warnFallback("truncateToTokens"),this.fallback.truncateToTokens(I,G,c)}merkleRoot(I){return this.warnFallback("merkleRoot"),this.fallback.merkleRoot(I)}merkleDiff(I,G){return this.warnFallback("merkleDiff"),this.fallback.merkleDiff(I,G)}warnFallback(I){this.fallbackWarned.has(I)||(this.fallbackWarned.add(I),Cz.debug(`WASM: ${I}() not available, using PureTS fallback`))}}});import{createRequire as gz}from"node:module";import{fileURLToPath as Az}from"node:url";import*as yG from"node:fs";import*as sd from"node:path";import*as OX from"node:os";import*as MX from"node:crypto";function jX(l){return Lz.every(I=>typeof l[I]=="function")}async function KX(){return SG||(SG=await zz(),SG)||(SG=await xz(),SG)||(SG=await Uz()),SG}async function kz(l){if(process.platform!=="win32"||!yG.existsSync(l))return l;try{let I=sd.join(OX.tmpdir(),"hsa-native");yG.mkdirSync(I,{recursive:!0});let G=await new Promise((b,Z)=>{let d=MX.createHash("md5"),W=yG.createReadStream(l);W.on("data",a=>d.update(a)),W.on("end",()=>b(d.digest("hex").slice(0,8))),W.on("error",Z)}),c=sd.join(I,`hsa-engine-${G}.node`);return yG.existsSync(c)||(yG.copyFileSync(l,c),YZ.debug(`Copied native addon to temp: ${c}`)),fV=c,c}catch(I){return YZ.debug(`Failed to copy native addon to temp, using source directly: ${I}`),l}}async function zz(){try{let l=gz(import.meta.url),I=sd.dirname(Az(import.meta.url)),G=sd.join(I,"hsa-engine.node"),c=await kz(G),b=l(c);if(b&&jX(b)){let{NativeEngine:Z}=await Promise.resolve().then(()=>(LX(),AX)),d=new Z(b);return YZ.info(`\u26A1 Native engine loaded (${process.platform}-${process.arch})`),d}}catch{YZ.debug("Native engine not available, trying WASM")}return null}async function xz(){try{let l=await import("@domyh/hsa-wasm"),I=l.default||l;if(I&&jX(I)){let{WasmEngine:G}=await Promise.resolve().then(()=>(BX(),UX)),c=new G(I);return YZ.info("\u{1F504} WASM engine loaded"),c}}catch{YZ.debug("WASM engine not available, falling back to pure TS")}return null}async function Uz(){let{PureTSEngine:l}=await Promise.resolve().then(()=>(KV(),xX)),I=new l;return YZ.info("\u{1F4CB} Pure TS engine loaded (fallback)"),I}var YZ,SG,fV,Lz,SX=u(()=>{"use strict";T();YZ=J("engine:loader"),SG=null,fV=null,Lz=["sha256","fileHash","batchFileHash","countTokens","truncateToTokens","merkleRoot","merkleDiff"];process.on("exit",()=>{if(fV)try{yG.unlinkSync(fV)}catch{}})});var fX={};TI(fX,{SimpleTokenizer:()=>$N});var $N,DV=u(()=>{"use strict";$N=class{name="simple-heuristic";countTokens(I){if(I.length===0)return 0;let G=0,c=!1;for(let Z=0;Z<I.length;Z++){let d=I.charCodeAt(Z);d>=65&&d<=90||d>=97&&d<=122||d>=48&&d<=57||d===95?c||(G++,c=!0):(c=!1,d!==32&&d!==10&&d!==13&&d!==9&&G++)}let b=this.detectContentScale(I);return Math.ceil(G*b)}detectContentScale(I){let G=I.slice(0,500),c=0;for(let d of G)"{}();=<>[]|&!".includes(d)&&c++;let b=G.split(/\s+/).length,Z=c/Math.max(G.length,1);return Z>.05?1.15:b>30&&Z<.02?.85:1}truncateToFit(I,G){if(I.length===0||G<=0)return"";if(this.countTokens(I)<=G)return I;let b=this.detectContentScale(I),Z=Math.floor(G/b),d=0,W=!1,a=0;for(let m=0;m<I.length;m++){let N=I.charCodeAt(m);if(N>=65&&N<=90||N>=97&&N<=122||N>=48&&N<=57||N===95){if(!W&&(d++,W=!0,d>Z))return I.slice(0,a)}else if(W=!1,N!==32&&N!==10&&N!==13&&N!==9&&(d++,d>Z))return I.slice(0,a);a=m+1}return I.slice(0,a)}encode(I){return Array.from(I).map(G=>G.charCodeAt(0))}decode(I){return I.map(G=>String.fromCharCode(G)).join("")}}});var qX=F(Ie=>{"use strict";Ie.byteLength=Oz;Ie.toByteArray=jz;Ie.fromByteArray=fz;var fG=[],YG=[],Bz=typeof Uint8Array<"u"?Uint8Array:Array,TV="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(pZ=0,DX=TV.length;pZ<DX;++pZ)fG[pZ]=TV[pZ],YG[TV.charCodeAt(pZ)]=pZ;var pZ,DX;YG[45]=62;YG[95]=63;function TX(l){var I=l.length;if(I%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var G=l.indexOf("=");G===-1&&(G=I);var c=G===I?0:4-G%4;return[G,c]}function Oz(l){var I=TX(l),G=I[0],c=I[1];return(G+c)*3/4-c}function Mz(l,I,G){return(I+G)*3/4-G}function jz(l){var I,G=TX(l),c=G[0],b=G[1],Z=new Bz(Mz(l,c,b)),d=0,W=b>0?c-4:c,a;for(a=0;a<W;a+=4)I=YG[l.charCodeAt(a)]<<18|YG[l.charCodeAt(a+1)]<<12|YG[l.charCodeAt(a+2)]<<6|YG[l.charCodeAt(a+3)],Z[d++]=I>>16&255,Z[d++]=I>>8&255,Z[d++]=I&255;return b===2&&(I=YG[l.charCodeAt(a)]<<2|YG[l.charCodeAt(a+1)]>>4,Z[d++]=I&255),b===1&&(I=YG[l.charCodeAt(a)]<<10|YG[l.charCodeAt(a+1)]<<4|YG[l.charCodeAt(a+2)]>>2,Z[d++]=I>>8&255,Z[d++]=I&255),Z}function Kz(l){return fG[l>>18&63]+fG[l>>12&63]+fG[l>>6&63]+fG[l&63]}function Sz(l,I,G){for(var c,b=[],Z=I;Z<G;Z+=3)c=(l[Z]<<16&16711680)+(l[Z+1]<<8&65280)+(l[Z+2]&255),b.push(Kz(c));return b.join("")}function fz(l){for(var I,G=l.length,c=G%3,b=[],Z=16383,d=0,W=G-c;d<W;d+=Z)b.push(Sz(l,d,d+Z>W?W:d+Z));return c===1?(I=l[G-1],b.push(fG[I>>2]+fG[I<<4&63]+"==")):c===2&&(I=(l[G-2]<<8)+l[G-1],b.push(fG[I>>10]+fG[I>>4&63]+fG[I<<2&63]+"=")),b.join("")}});function Pz(l,I){let G=Array.from({length:l.length},(c,b)=>({start:b,end:b+1}));for(;G.length>1;){let c=null;for(let b=0;b<G.length-1;b++){let Z=l.slice(G[b].start,G[b+1].end),d=I.get(Z.join(","));d!=null&&(c==null||d<c[0])&&(c=[d,b])}if(c!=null){let b=c[1];G[b]={start:G[b].start,end:G[b+1].end},G.splice(b+1,1)}else break}return G}function _z(l,I){return l.length===1?[I.get(l.join(","))]:Pz(l,I).map(G=>I.get(l.slice(G.start,G.end).join(","))).filter(G=>G!=null)}function $z(l){return l.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}function le(l){switch(l){case"gpt2":return"gpt2";case"code-cushman-001":case"code-cushman-002":case"code-davinci-001":case"code-davinci-002":case"cushman-codex":case"davinci-codex":case"davinci-002":case"text-davinci-002":case"text-davinci-003":return"p50k_base";case"code-davinci-edit-001":case"text-davinci-edit-001":return"p50k_edit";case"ada":case"babbage":case"babbage-002":case"code-search-ada-code-001":case"code-search-babbage-code-001":case"curie":case"davinci":case"text-ada-001":case"text-babbage-001":case"text-curie-001":case"text-davinci-001":case"text-search-ada-doc-001":case"text-search-babbage-doc-001":case"text-search-curie-doc-001":case"text-search-davinci-doc-001":case"text-similarity-ada-001":case"text-similarity-babbage-001":case"text-similarity-curie-001":case"text-similarity-davinci-001":return"r50k_base";case"gpt-3.5-turbo-instruct-0914":case"gpt-3.5-turbo-instruct":case"gpt-3.5-turbo-16k-0613":case"gpt-3.5-turbo-16k":case"gpt-3.5-turbo-0613":case"gpt-3.5-turbo-0301":case"gpt-3.5-turbo":case"gpt-4-32k-0613":case"gpt-4-32k-0314":case"gpt-4-32k":case"gpt-4-0613":case"gpt-4-0314":case"gpt-4":case"gpt-3.5-turbo-1106":case"gpt-35-turbo":case"gpt-4-1106-preview":case"gpt-4-vision-preview":case"gpt-3.5-turbo-0125":case"gpt-4-turbo":case"gpt-4-turbo-2024-04-09":case"gpt-4-turbo-preview":case"gpt-4-0125-preview":case"text-embedding-ada-002":case"text-embedding-3-small":case"text-embedding-3-large":return"cl100k_base";case"gpt-4o":case"gpt-4o-2024-05-13":case"gpt-4o-2024-08-06":case"gpt-4o-2024-11-20":case"gpt-4o-mini-2024-07-18":case"gpt-4o-mini":case"gpt-4o-search-preview":case"gpt-4o-search-preview-2025-03-11":case"gpt-4o-mini-search-preview":case"gpt-4o-mini-search-preview-2025-03-11":case"gpt-4o-audio-preview":case"gpt-4o-audio-preview-2024-12-17":case"gpt-4o-audio-preview-2024-10-01":case"gpt-4o-mini-audio-preview":case"gpt-4o-mini-audio-preview-2024-12-17":case"o1":case"o1-2024-12-17":case"o1-mini":case"o1-mini-2024-09-12":case"o1-preview":case"o1-preview-2024-09-12":case"o1-pro":case"o1-pro-2025-03-19":case"o3":case"o3-2025-04-16":case"o3-mini":case"o3-mini-2025-01-31":case"o4-mini":case"o4-mini-2025-04-16":case"chatgpt-4o-latest":case"gpt-4o-realtime":case"gpt-4o-realtime-preview-2024-10-01":case"gpt-4o-realtime-preview-2024-12-17":case"gpt-4o-mini-realtime-preview":case"gpt-4o-mini-realtime-preview-2024-12-17":case"gpt-4.1":case"gpt-4.1-2025-04-14":case"gpt-4.1-mini":case"gpt-4.1-mini-2025-04-14":case"gpt-4.1-nano":case"gpt-4.1-nano-2025-04-14":case"gpt-4.5-preview":case"gpt-4.5-preview-2025-02-27":case"gpt-5":case"gpt-5-2025-08-07":case"gpt-5-nano":case"gpt-5-nano-2025-08-07":case"gpt-5-mini":case"gpt-5-mini-2025-08-07":case"gpt-5-chat-latest":return"o200k_base";default:throw new Error("Unknown model")}}var PX,Dz,Tz,qz,qV,DG,PV=u(()=>{PX=Kc(qX(),1),Dz=Object.defineProperty,Tz=(l,I,G)=>I in l?Dz(l,I,{enumerable:!0,configurable:!0,writable:!0,value:G}):l[I]=G,qz=(l,I,G)=>(Tz(l,typeof I!="symbol"?I+"":I,G),G);qV=class{specialTokens;inverseSpecialTokens;patStr;textEncoder=new TextEncoder;textDecoder=new TextDecoder("utf-8");rankMap=new Map;textMap=new Map;constructor(l,I){this.patStr=l.pat_str;let G=l.bpe_ranks.split(`
|
|
@@ -308,7 +308,7 @@ ${W}`}var os,nJ=u(()=>{"use strict";nZ();Im();pJ();T();bb();Ve();os=J("tool:get-
|
|
|
308
308
|
`),d.push(`**Indexed skills**: ${I.skillRegistry.indexedCount}`),d.push(`**Total skills discovered**: ${I.skillRegistry.totalSkills}`),d.push(""),d.push("### \u{1F4A1} Try these alternatives:"),d.push('- `hsa_search_skills` with `skill` filter (e.g. `skill: "tailwind"`, `skill: "vue"`)'),d.push("- Browse `.agent/skills/` \u2014 7 categories, 85+ skills:"),d.push(" - `core/` (security, api-design, error-handling, logging, observability, authentication)"),d.push(" - `languages/` (python, typescript, go, rust, java, kotlin, ...)"),d.push(" - `frameworks/` (react, vue, nuxt, nextjs, angular, svelte, flutter)"),d.push(" - `devops/` (docker, kubernetes, aws, ci-cd, terraform)"),d.push(" - `cross-cutting/` (tailwind, testing, database, electron, playwright)"),d.push(" - `tooling/` (mcp, api-protocols, browser-agent)"),d.push(" - `ai-ml/` (ai-agents, prompt-engineering, rag-patterns, vector-search)"),d.push("- \u26D4 Direct read: `.agent/skills/{category}/{name}/SKILL.md` \u2014 MUST read before implementing"),d.join(`
|
|
309
309
|
`);let W=I.skillRegistry.getAllMeta();for(let e=0;e<c.length;e++){let Y=c[e],p=W.get(Y.skill),n=`.agent/skills/${p?.category??"unknown"}/${Y.skill}/SKILL.md`;d.push(`### ${e+1}. ${Y.pattern.title}`),d.push(`- **Skill**: ${Y.skill} | **Domain**: ${Y.domain}`),d.push(`- **Score**: ${Y.score.toFixed(3)} | **Tokens**: ${Y.pattern.tokenCost}`),p?d.push(`- **\u{1F4D6} SKILL.md**: \`${n}\``):d.push(`- **\u26A0\uFE0F SKILL.md**: \`${n}\` (not verified \u2014 skill from indexed cache)`);let h=Y.pattern.data,t=Object.keys(h).filter(s=>!s.startsWith("_"));if(t.length>0&&t.length<=8){d.push("```yaml");for(let s of t.slice(0,6)){let R=h[s];typeof R=="string"&&R.length<=200?d.push(`${s}: ${R}`):typeof R=="number"||typeof R=="boolean"?d.push(`${s}: ${String(R)}`):Array.isArray(R)&&R.length<=5&&d.push(`${s}: [${R.map(H=>typeof H=="string"?H:JSON.stringify(H)).join(", ")}]`)}d.push("```")}d.push("")}d.push("---"),d.push(`**Search duration**: ${b}ms`),d.push(`**Indexed skills**: ${I.skillRegistry.indexedCount}/${I.skillRegistry.totalSkills}`),d.push(`**Total indexed patterns**: ${I.skillRegistry.totalPatterns}`),d.push(`**Token usage**: ${Z}`),[...new Set(c.map(e=>e.skill))].length>0&&(d.push(""),d.push("> \u26D4 **MUST**: Read `.agent/skills/{category}/{skill}/SKILL.md` before implementing. Apply patterns from skill to your code."));let m=d.join(`
|
|
310
310
|
`),N=8e3;return m.length>N?m.slice(0,N)+"\n\n---\n*Output truncated. Use `skill` or `domain` filters to narrow results.*":m}var T8,tJ=u(()=>{"use strict";T();T8=J("tool:search-skills")});function ys(l){return!l||l.length===0?sJ:sJ.filter(I=>l.includes(I.category))}var sJ,RJ,FJ=u(()=>{"use strict";sJ=[{name:"node",category:"runtime",displayName:"Node.js",commands:{win32:"node -v",darwin:"node -v",linux:"node -v"},versionRegex:/v?(\d+\.\d+\.\d+)/},{name:"python",category:"runtime",displayName:"Python",commands:{win32:"python --version",darwin:"python3 --version",linux:"python3 --version"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"go",category:"runtime",displayName:"Go",commands:{win32:"go version",darwin:"go version",linux:"go version"},versionRegex:/go(\d+\.\d+(?:\.\d+)?)/},{name:"rust",category:"runtime",displayName:"Rust",commands:{win32:"rustc --version",darwin:"rustc --version",linux:"rustc --version"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"dotnet",category:"runtime",displayName:".NET SDK",commands:{win32:"dotnet --version",darwin:"dotnet --version",linux:"dotnet --version"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"java",category:"runtime",displayName:"Java",commands:{win32:"java -version 2>&1",darwin:"java -version 2>&1",linux:"java -version 2>&1"},versionRegex:/(?:version\s+)?"?(\d+[\.\d]*)/},{name:"ruby",category:"runtime",displayName:"Ruby",commands:{win32:"ruby --version",darwin:"ruby --version",linux:"ruby --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0},{name:"php",category:"runtime",displayName:"PHP",commands:{win32:"php --version",darwin:"php --version",linux:"php --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0},{name:"bun",category:"runtime",displayName:"Bun",commands:{win32:"bun -v",darwin:"bun -v",linux:"bun -v"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"deno",category:"runtime",displayName:"Deno",commands:{win32:"deno --version",darwin:"deno --version",linux:"deno --version"},versionRegex:/deno\s+(\d+\.\d+\.\d+)/},{name:"npm",category:"package_manager",displayName:"npm",commands:{win32:"npm -v",darwin:"npm -v",linux:"npm -v"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"pnpm",category:"package_manager",displayName:"pnpm",commands:{win32:"pnpm -v",darwin:"pnpm -v",linux:"pnpm -v"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"yarn",category:"package_manager",displayName:"Yarn",commands:{win32:"yarn -v",darwin:"yarn -v",linux:"yarn -v"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"pip",category:"package_manager",displayName:"pip",commands:{win32:"pip --version",darwin:"pip3 --version",linux:"pip3 --version"},versionRegex:/pip\s+(\d+\.\d+(?:\.\d+)?)/},{name:"uv",category:"package_manager",displayName:"uv",commands:{win32:"uv --version",darwin:"uv --version",linux:"uv --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0},{name:"cargo",category:"package_manager",displayName:"Cargo",commands:{win32:"cargo --version",darwin:"cargo --version",linux:"cargo --version"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"composer",category:"package_manager",displayName:"Composer",commands:{win32:"composer --version",darwin:"composer --version",linux:"composer --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0},{name:"psql",category:"database",displayName:"PostgreSQL",commands:{win32:"psql --version",darwin:"psql --version",linux:"psql --version"},versionRegex:/(\d+\.\d+(?:\.\d+)?)/,optional:!0},{name:"mysql",category:"database",displayName:"MySQL",commands:{win32:"mysql --version",darwin:"mysql --version",linux:"mysql --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0},{name:"redis",category:"database",displayName:"Redis",commands:{win32:"redis-cli --version",darwin:"redis-cli --version",linux:"redis-cli --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0},{name:"mongosh",category:"database",displayName:"MongoDB Shell",commands:{win32:"mongosh --version",darwin:"mongosh --version",linux:"mongosh --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0},{name:"sqlite3",category:"database",displayName:"SQLite",commands:{win32:"sqlite3 --version",darwin:"sqlite3 --version",linux:"sqlite3 --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0},{name:"docker",category:"devops",displayName:"Docker",commands:{win32:"docker -v",darwin:"docker -v",linux:"docker -v"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"kubectl",category:"devops",displayName:"kubectl",commands:{win32:"kubectl version --client --short 2>&1",darwin:"kubectl version --client --short 2>&1",linux:"kubectl version --client --short 2>&1"},versionRegex:/v?(\d+\.\d+\.\d+)/,optional:!0},{name:"terraform",category:"devops",displayName:"Terraform",commands:{win32:"terraform --version",darwin:"terraform --version",linux:"terraform --version"},versionRegex:/v?(\d+\.\d+\.\d+)/,optional:!0},{name:"git",category:"devops",displayName:"Git",commands:{win32:"git --version",darwin:"git --version",linux:"git --version"},versionRegex:/(\d+\.\d+\.\d+)/},{name:"gh",category:"devops",displayName:"GitHub CLI",commands:{win32:"gh --version",darwin:"gh --version",linux:"gh --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0},{name:"make",category:"devops",displayName:"Make",commands:{win32:"make --version",darwin:"make --version",linux:"make --version"},versionRegex:/(\d+\.\d+(?:\.\d+)?)/,optional:!0},{name:"cmake",category:"devops",displayName:"CMake",commands:{win32:"cmake --version",darwin:"cmake --version",linux:"cmake --version"},versionRegex:/(\d+\.\d+\.\d+)/,optional:!0}];RJ={runtime:"\u{1F527} Runtimes",package_manager:"\u{1F4E6} Package Managers",ide:"\u{1F4BB} IDEs / Editors",database:"\u{1F5C4}\uFE0F Databases",devops:"\u{1F680} DevOps / Tooling"}});import{exec as q8}from"node:child_process";import{promisify as P8}from"node:util";import{readFileSync as fp,existsSync as jm,readdirSync as _8,statSync as $8}from"node:fs";import Dp from"node:os";import ql from"node:path";async function cq(l,I){let G=l.commands[I]??null;if(!G)return null;try{let{stdout:c,stderr:b}=await Iq(G,{timeout:lq,windowsHide:!0,env:{...process.env,NODE_NO_WARNINGS:"1"},maxBuffer:262144}),d=(c||b||"").trim().match(l.versionRegex);return d?.[1]?{name:l.name,displayName:l.displayName,version:d[1],category:l.category}:null}catch{return null}}async function QJ(l,I){let G=l.verbose??!1,c=Js.get(I.projectRoot);if(c&&Date.now()-c.timestamp<Gq){let V=c.result;if(Es.debug("Returning cached environment detection",{project:I.projectRoot}),l.categories&&l.categories.length>0){let n=uJ(V,l.categories);return Sp(n,G)}return Sp({...V,cached:!0},G)}c&&Js.delete(I.projectRoot);let b=Date.now(),Z=Dp.platform(),d=ys();Es.info(`Scanning ${d.length} tools on ${Z}...`);let W=5,a=[];for(let V=0;V<d.length;V+=W){let n=d.slice(V,V+W),h=await Promise.allSettled(n.map(t=>cq(t,Z)));a.push(...h)}let m=[],N=[];a.forEach((V,n)=>{V.status==="fulfilled"&&V.value?m.push(V.value):N.push(d[n].displayName)});let e=Date.now()-b,Y=bq(),p={installed:m,notFound:N,scanDurationMs:e,platform:Z,cached:!1,ideShell:Y};if(Js.set(I.projectRoot,{result:p,timestamp:Date.now()}),Es.info(`Detection complete: ${m.length} installed, ${N.length} not found (${e}ms)`),l.categories&&l.categories.length>0){let V=uJ(p,l.categories);return Sp(V,G)}return Sp(p,G)}function uJ(l,I){let G=ys(I),c=new Set(G.map(b=>b.displayName));return{...l,installed:l.installed.filter(b=>I.includes(b.category)),notFound:l.notFound.filter(b=>c.has(b)),cached:!0}}function Sp(l,I){let G=[];if(G.push("# \u{1F5A5}\uFE0F System Environment Detection"),G.push(""),l.ideShell){let d={bash:"Use `&&` for chaining, `/` paths, `$VAR` env vars",cmd:"Use `&` for chaining, `\\\\` paths, `%VAR%` env vars. Wrap with `cmd /c`",powershell:"Use `;` for chaining (PS5) or `&&` (PS7+), `$env:VAR` env vars",zsh:"Use `&&` for chaining, `/` paths, `$VAR` env vars",fish:"Use `; and` for chaining, `/` paths, `$VAR` env vars"}[l.ideShell]??"";G.push(`> **Shell**: \`${l.ideShell}\`${d?` \u2014 ${d}`:""}`),G.push("")}G.push(`**Platform**: ${l.platform} | **Found**: ${l.installed.length} tools | **Scan**: ${l.scanDurationMs}ms${l.cached?" (cached)":""}`),G.push("");let c=new Map;for(let Z of l.installed){let d=c.get(Z.category)??[];d.push(Z),c.set(Z.category,d)}let b=["runtime","package_manager","ide","database","devops"];for(let Z of b){let d=c.get(Z);if(!d||d.length===0)continue;let W=RJ[Z]??Z;G.push(`## ${W}`),G.push(""),G.push("| Tool | Version |"),G.push("|------|---------|");for(let a of d)G.push(`| ${a.displayName} | ${a.version} |`);G.push("")}return I&&l.notFound.length>0&&(G.push("---"),G.push(""),G.push(`**Not found** (${l.notFound.length}): ${l.notFound.join(", ")}`),G.push("")),G.join(`
|
|
311
|
-
`)}function bq(){try{let l=XZ(),I=Dp.homedir(),G=Dp.platform(),c={vscode:ql.join(I,G==="win32"?"AppData/Roaming/Code/User/settings.json":".config/Code/User/settings.json"),cursor:ql.join(I,".cursor","User","settings.json"),windsurf:ql.join(I,".codeium","windsurf","User","settings.json"),antigravity:ql.join(I,".gemini","antigravity","settings.json"),trae:ql.join(I,".trae","User","settings.json"),kiro:ql.join(I,".kiro","User","settings.json")},b=c[l.name];if(b&&jm(b)){let W=JSON.parse(fp(b,"utf-8"))[`terminal.integrated.defaultProfile.${G==="win32"?"windows":G==="darwin"?"osx":"linux"}`];if(W&&typeof W=="string")return XJ(W)}if(l.name==="jetbrains"){let Z=Zq(I,G);if(Z)return Z}if(l.name==="zed"){let Z=ql.join(I,".config","zed","settings.json");if(jm(Z)){let W=JSON.parse(fp(Z,"utf-8"))?.terminal?.shell?.program;if(W&&typeof W=="string")return HJ(W)}}if(["cline","roo","amazon-q","tabnine"].includes(l.name)){let Z=c.vscode;if(Z&&jm(Z)){let a=JSON.parse(fp(Z,"utf-8"))[`terminal.integrated.defaultProfile.${G==="win32"?"windows":G==="darwin"?"osx":"linux"}`];if(a&&typeof a=="string")return XJ(a)}}}catch{}if(Dp.platform()==="win32"){let l=(process.env.COMSPEC||"").toLowerCase();return l.includes("powershell")||l.includes("pwsh")?"powershell":"cmd"}return process.env.SHELL?.split("/").pop()||"bash"}function XJ(l){let I=l.toLowerCase();return I.includes("bash")||I.includes("git bash")?"bash":I.includes("pwsh")||I.includes("powershell")?"powershell":I.includes("cmd")||I.includes("command prompt")?"cmd":I.includes("zsh")?"zsh":I.includes("fish")?"fish":I}function HJ(l){let I=ql.basename(l).toLowerCase().replace(/\.exe$/i,"");return I.includes("bash")?"bash":I.includes("pwsh")||I.includes("powershell")?"powershell":I.includes("cmd")?"cmd":I.includes("zsh")?"zsh":I.includes("fish")?"fish":I}function Zq(l,I){try{let G=I==="win32"?process.env.APPDATA||ql.join(l,"AppData","Roaming"):I==="darwin"?ql.join(l,"Library","Application Support"):ql.join(l,".config"),c=ql.join(G,"JetBrains");if(!jm(c))return null;let b=_8(c).filter(Z=>{try{return $8(ql.join(c,Z)).isDirectory()}catch{return!1}}).sort().reverse();for(let Z of b){let d=ql.join(c,Z,"options","terminal.xml");if(jm(d)){let a=fp(d,"utf-8").match(/name="myShellPath"\s+value="([^"]+)"/);if(a?.[1])return HJ(a[1])}}}catch{}return null}var Es,Iq,lq,Gq,Js,vJ=u(()=>{"use strict";FJ();T();Ud();Es=J("tool:detect-environment"),Iq=P8(q8),lq=3e3,Gq=600*1e3,Js=new Map});var wW,rs=u(()=>{"use strict";wW={code:{include:["read_file","write_file","view_file","view_file_outline","view_code_item","replace_file_content","multi_replace_file_content","write_to_file","grep_search","find_by_name","list_dir","run_command","command_status","send_command_input"],exclude:["browser_*","mcp_playwright_*","deploy_*","generate_image","search_web","read_url_content"],rationale:"Full file manipulation + search + terminal. No browser or web tools."},test:{include:["read_file","write_file","view_file","view_file_outline","view_code_item","replace_file_content","write_to_file","grep_search","find_by_name","list_dir","run_command","command_status"],exclude:["browser_*","mcp_playwright_*","deploy_*","generate_image","search_web","read_url_content"],rationale:"File read/write + search + test runner. No browser or web tools."},review:{include:["read_file","view_file","view_file_outline","view_code_item","grep_search","find_by_name","list_dir"],exclude:["write_file","write_to_file","replace_file_content","multi_replace_file_content","run_command","send_command_input","browser_*","mcp_playwright_*","deploy_*","generate_image"],rationale:"Read-only file access + search. No write, terminal, or browser tools."},debug:{include:["read_file","view_file","view_file_outline","view_code_item","replace_file_content","multi_replace_file_content","grep_search","find_by_name","list_dir","run_command","command_status","send_command_input"],exclude:["browser_*","mcp_playwright_*","deploy_*","generate_image","search_web"],rationale:"File read + limited edit + full terminal for debugging. No browser or deploy."},browser:{include:["mcp_playwright_browser_navigate","mcp_playwright_browser_snapshot","mcp_playwright_browser_click","mcp_playwright_browser_type","mcp_playwright_browser_take_screenshot","mcp_playwright_browser_wait_for","mcp_playwright_browser_evaluate","mcp_playwright_browser_press_key","mcp_playwright_browser_hover","mcp_playwright_browser_select_option","read_file","view_file"],exclude:["write_file","write_to_file","replace_file_content","multi_replace_file_content","run_command","deploy_*"],rationale:"Full Playwright browser control + limited file read. No file write or terminal."},research:{include:["read_url_content","search_web","view_content_chunk","read_file","view_file","view_file_outline","grep_search","find_by_name","list_dir"],exclude:["write_file","write_to_file","replace_file_content","multi_replace_file_content","run_command","send_command_input","browser_*","mcp_playwright_*","deploy_*"],rationale:"Web + file read for research. No write, terminal, or browser tools."}}});function dq(l,I){let G=[],c=I?.skills?.map(b=>b.name.toLowerCase())??[];switch(c.includes("typescript")&&(G.push("Use TypeScript strict mode"),G.push("Add proper type annotations")),c.includes("react")&&G.push("Follow React functional component patterns with hooks"),(c.includes("vue")||c.includes("nuxt"))&&G.push("Follow Vue 3 Composition API patterns"),l){case"code":G.push("Follow existing code conventions in the project"),I?.buildSystem?.testCommand&&G.push(`Run tests after changes: \`${I.buildSystem.testCommand}\``);break;case"test":G.push("Follow AAA pattern (Arrange, Act, Assert)"),G.push("Write descriptive test names"),(c.includes("vitest")||c.includes("jest"))&&G.push("Use describe/it blocks with clear grouping");break;case"review":G.push("Check for security vulnerabilities"),G.push("Evaluate error handling completeness"),G.push("Verify type safety and edge cases");break;case"debug":G.push("Reproduce the issue first, then fix"),G.push("Add regression test for the bug");break;case"browser":G.push("Take screenshots for verification"),G.push("Use accessibility snapshots for element interaction");break;case"research":G.push("Cite sources with URLs"),G.push("Verify information from multiple sources");break}return I?.buildSystem?.buildCommand&&G.push(`Build: \`${I.buildSystem.buildCommand}\``),G}async function wJ(l,I){Km.info("hsa_prepare_handoff called",{taskType:l.task_type,hasFocusFiles:!!l.focus_files?.length,maxTokens:l.max_tokens}),FI.increment("handoff.calls");let G=l.max_tokens,b=(I.cachedDetection?.skills?.map(V=>V.name)??[]).join(", ")||"unknown",Z=[];if(l.focus_files?.length)for(let V of l.focus_files)Z.push({path:V,role:"primary"});if(l.task_description&&I.contextManager)try{let V=await I.contextManager.getContext({query:l.task_description,maxTokens:Math.min(G,2e3),strategy:"code-aware",includeFiles:l.focus_files});for(let n of V.sources){let h=n.file.replace(/\\/g,"/");!Z.some(t=>t.path===h)&&Z.length<10&&Z.push({path:h,role:"related"})}}catch(V){Km.debug("Context retrieval for handoff failed",{error:String(V)})}if(I.codeGraph&&l.focus_files?.length)try{for(let V of l.focus_files.slice(0,3)){let n=I.codeGraph.findDependencies(V);for(let h of n.slice(0,3))!Z.some(t=>t.path===h)&&Z.length<15&&Z.push({path:h,role:"dependency"})}}catch(V){Km.debug("CodeGraph dependency lookup failed",{error:String(V)})}let d=[];try{let V=I.merkle.currentHashesView;if(V.size>0)for(let h of l.focus_files??[]){let t=h.replace(/\\/g,"/");V.has(t)&&d.push(`${t} (tracked, hash: ${V.get(t).slice(0,8)}...)`)}}catch(V){Km.debug("Merkle state export failed",{error:String(V)})}let W=dq(l.task_type,I.cachedDetection),a=wW[l.task_type]?.include??wW.code.include,m=I.projectRoot.split(/[/\\]/).pop()??"project",N=[];if(N.push(`<!-- HSA Handoff v1.1.0 | type:${l.task_type} | stack:${b} | files:${Z.length} -->`),N.push(""),N.push(`## Project: ${m}`),N.push(`- **Stack**: ${b}`),N.push(`- **Root**: \`${I.projectRoot}\``),I.cachedDetection?.buildSystem){let V=I.cachedDetection.buildSystem,n=[];V.buildCommand&&n.push(`**Build**: \`${V.buildCommand}\``),V.testCommand&&n.push(`**Test**: \`${V.testCommand}\``),V.devCommand&&n.push(`**Dev**: \`${V.devCommand}\``),n.length>0&&N.push(`- ${n.join(" | ")}`)}if(I.cachedDetection?.monorepo&&N.push("- \u{1F4E6} **Monorepo** detected"),N.push(""),Z.length>0){N.push("## Relevant Files"),N.push(""),N.push("| File | Role |"),N.push("|------|------|");for(let V of Z.slice(0,10))N.push(`| \`${V.path}\` | ${V.role} |`);if(Z.length>10&&N.push(`| ... | +${Z.length-10} more |`),N.push(""),I.codeGraph){let V=Z.filter(n=>n.role==="primary").slice(0,5);for(let n of V){let t=I.codeGraph.getFileSymbols(n.path).filter(s=>s.exported).slice(0,8);t.length>0&&N.push(`**\`${n.path}\`**: ${t.map(s=>`${s.kind} \`${s.name}\``).join(", ")}`)}V.length>0&&N.push("")}}if(d.length>0){N.push("## Tracked Files");for(let V of d.slice(0,5))N.push(`- ${V}`);N.push("")}if(l.task_description&&(N.push("## Task"),N.push(l.task_description),N.push("")),W.length>0){N.push("## Constraints");for(let V of W)N.push(`- ${V}`);N.push("")}if(I.session){let V=I.session.getRecentQueries(3),n=I.session.getRecentEdits(5);(V.length>0||n.length>0)&&(N.push("## Session Context"),V.length>0&&N.push("**Recent queries**: "+V.map(h=>`\`${h.slice(0,60)}\``).join(" \u2192 ")),n.length>0&&N.push("**Recently edited**: "+n.map(h=>`\`${h}\``).join(", ")),N.push(""))}N.push("## Suggested Tools"),N.push(a.map(V=>`\`${V}\``).join(", ")),N.push("");let e=N.join(`
|
|
311
|
+
`)}function bq(){try{let l=XZ(),I=Dp.homedir(),G=Dp.platform(),c={vscode:ql.join(I,G==="win32"?"AppData/Roaming/Code/User/settings.json":".config/Code/User/settings.json"),cursor:ql.join(I,G==="win32"?"AppData/Roaming/Cursor/User/settings.json":".config/Cursor/User/settings.json"),windsurf:ql.join(I,G==="win32"?"AppData/Roaming/Windsurf/User/settings.json":".config/Windsurf/User/settings.json"),antigravity:ql.join(I,G==="win32"?"AppData/Roaming/Antigravity/User/settings.json":".config/Antigravity/User/settings.json"),trae:ql.join(I,G==="win32"?"AppData/Roaming/Trae/User/settings.json":".config/Trae/User/settings.json"),kiro:ql.join(I,".kiro","settings","settings.json")},b=c[l.name];if(b&&jm(b)){let W=JSON.parse(fp(b,"utf-8"))[`terminal.integrated.defaultProfile.${G==="win32"?"windows":G==="darwin"?"osx":"linux"}`];if(W&&typeof W=="string")return XJ(W)}if(l.name==="jetbrains"){let Z=Zq(I,G);if(Z)return Z}if(l.name==="zed"){let Z=ql.join(I,".config","zed","settings.json");if(jm(Z)){let W=JSON.parse(fp(Z,"utf-8"))?.terminal?.shell?.program;if(W&&typeof W=="string")return HJ(W)}}if(["cline","roo","amazon-q","tabnine"].includes(l.name)){let Z=c.vscode;if(Z&&jm(Z)){let a=JSON.parse(fp(Z,"utf-8"))[`terminal.integrated.defaultProfile.${G==="win32"?"windows":G==="darwin"?"osx":"linux"}`];if(a&&typeof a=="string")return XJ(a)}}}catch{}if(Dp.platform()==="win32"){let l=(process.env.SHELL||"").toLowerCase();if(l.includes("bash")||l.includes("zsh"))return l.split("/").pop()||"bash";if(process.env.MSYSTEM)return"bash";let I=(process.env.TERM_PROGRAM||"").toLowerCase();if(I.includes("bash")||I.includes("mintty"))return"bash";let G=(process.env.COMSPEC||"").toLowerCase();return G.includes("powershell")||G.includes("pwsh")?"powershell":"cmd"}return process.env.SHELL?.split("/").pop()||"bash"}function XJ(l){let I=l.toLowerCase();return I.includes("bash")||I.includes("git bash")?"bash":I.includes("pwsh")||I.includes("powershell")?"powershell":I.includes("cmd")||I.includes("command prompt")?"cmd":I.includes("zsh")?"zsh":I.includes("fish")?"fish":I}function HJ(l){let I=ql.basename(l).toLowerCase().replace(/\.exe$/i,"");return I.includes("bash")?"bash":I.includes("pwsh")||I.includes("powershell")?"powershell":I.includes("cmd")?"cmd":I.includes("zsh")?"zsh":I.includes("fish")?"fish":I}function Zq(l,I){try{let G=I==="win32"?process.env.APPDATA||ql.join(l,"AppData","Roaming"):I==="darwin"?ql.join(l,"Library","Application Support"):ql.join(l,".config"),c=ql.join(G,"JetBrains");if(!jm(c))return null;let b=_8(c).filter(Z=>{try{return $8(ql.join(c,Z)).isDirectory()}catch{return!1}}).sort().reverse();for(let Z of b){let d=ql.join(c,Z,"options","terminal.xml");if(jm(d)){let a=fp(d,"utf-8").match(/name="myShellPath"\s+value="([^"]+)"/);if(a?.[1])return HJ(a[1])}}}catch{}return null}var Es,Iq,lq,Gq,Js,vJ=u(()=>{"use strict";FJ();T();Ud();Es=J("tool:detect-environment"),Iq=P8(q8),lq=3e3,Gq=600*1e3,Js=new Map});var wW,rs=u(()=>{"use strict";wW={code:{include:["read_file","write_file","view_file","view_file_outline","view_code_item","replace_file_content","multi_replace_file_content","write_to_file","grep_search","find_by_name","list_dir","run_command","command_status","send_command_input"],exclude:["browser_*","mcp_playwright_*","deploy_*","generate_image","search_web","read_url_content"],rationale:"Full file manipulation + search + terminal. No browser or web tools."},test:{include:["read_file","write_file","view_file","view_file_outline","view_code_item","replace_file_content","write_to_file","grep_search","find_by_name","list_dir","run_command","command_status"],exclude:["browser_*","mcp_playwright_*","deploy_*","generate_image","search_web","read_url_content"],rationale:"File read/write + search + test runner. No browser or web tools."},review:{include:["read_file","view_file","view_file_outline","view_code_item","grep_search","find_by_name","list_dir"],exclude:["write_file","write_to_file","replace_file_content","multi_replace_file_content","run_command","send_command_input","browser_*","mcp_playwright_*","deploy_*","generate_image"],rationale:"Read-only file access + search. No write, terminal, or browser tools."},debug:{include:["read_file","view_file","view_file_outline","view_code_item","replace_file_content","multi_replace_file_content","grep_search","find_by_name","list_dir","run_command","command_status","send_command_input"],exclude:["browser_*","mcp_playwright_*","deploy_*","generate_image","search_web"],rationale:"File read + limited edit + full terminal for debugging. No browser or deploy."},browser:{include:["mcp_playwright_browser_navigate","mcp_playwright_browser_snapshot","mcp_playwright_browser_click","mcp_playwright_browser_type","mcp_playwright_browser_take_screenshot","mcp_playwright_browser_wait_for","mcp_playwright_browser_evaluate","mcp_playwright_browser_press_key","mcp_playwright_browser_hover","mcp_playwright_browser_select_option","read_file","view_file"],exclude:["write_file","write_to_file","replace_file_content","multi_replace_file_content","run_command","deploy_*"],rationale:"Full Playwright browser control + limited file read. No file write or terminal."},research:{include:["read_url_content","search_web","view_content_chunk","read_file","view_file","view_file_outline","grep_search","find_by_name","list_dir"],exclude:["write_file","write_to_file","replace_file_content","multi_replace_file_content","run_command","send_command_input","browser_*","mcp_playwright_*","deploy_*"],rationale:"Web + file read for research. No write, terminal, or browser tools."}}});function dq(l,I){let G=[],c=I?.skills?.map(b=>b.name.toLowerCase())??[];switch(c.includes("typescript")&&(G.push("Use TypeScript strict mode"),G.push("Add proper type annotations")),c.includes("react")&&G.push("Follow React functional component patterns with hooks"),(c.includes("vue")||c.includes("nuxt"))&&G.push("Follow Vue 3 Composition API patterns"),l){case"code":G.push("Follow existing code conventions in the project"),I?.buildSystem?.testCommand&&G.push(`Run tests after changes: \`${I.buildSystem.testCommand}\``);break;case"test":G.push("Follow AAA pattern (Arrange, Act, Assert)"),G.push("Write descriptive test names"),(c.includes("vitest")||c.includes("jest"))&&G.push("Use describe/it blocks with clear grouping");break;case"review":G.push("Check for security vulnerabilities"),G.push("Evaluate error handling completeness"),G.push("Verify type safety and edge cases");break;case"debug":G.push("Reproduce the issue first, then fix"),G.push("Add regression test for the bug");break;case"browser":G.push("Take screenshots for verification"),G.push("Use accessibility snapshots for element interaction");break;case"research":G.push("Cite sources with URLs"),G.push("Verify information from multiple sources");break}return I?.buildSystem?.buildCommand&&G.push(`Build: \`${I.buildSystem.buildCommand}\``),G}async function wJ(l,I){Km.info("hsa_prepare_handoff called",{taskType:l.task_type,hasFocusFiles:!!l.focus_files?.length,maxTokens:l.max_tokens}),FI.increment("handoff.calls");let G=l.max_tokens,b=(I.cachedDetection?.skills?.map(V=>V.name)??[]).join(", ")||"unknown",Z=[];if(l.focus_files?.length)for(let V of l.focus_files)Z.push({path:V,role:"primary"});if(l.task_description&&I.contextManager)try{let V=await I.contextManager.getContext({query:l.task_description,maxTokens:Math.min(G,2e3),strategy:"code-aware",includeFiles:l.focus_files});for(let n of V.sources){let h=n.file.replace(/\\/g,"/");!Z.some(t=>t.path===h)&&Z.length<10&&Z.push({path:h,role:"related"})}}catch(V){Km.debug("Context retrieval for handoff failed",{error:String(V)})}if(I.codeGraph&&l.focus_files?.length)try{for(let V of l.focus_files.slice(0,3)){let n=I.codeGraph.findDependencies(V);for(let h of n.slice(0,3))!Z.some(t=>t.path===h)&&Z.length<15&&Z.push({path:h,role:"dependency"})}}catch(V){Km.debug("CodeGraph dependency lookup failed",{error:String(V)})}let d=[];try{let V=I.merkle.currentHashesView;if(V.size>0)for(let h of l.focus_files??[]){let t=h.replace(/\\/g,"/");V.has(t)&&d.push(`${t} (tracked, hash: ${V.get(t).slice(0,8)}...)`)}}catch(V){Km.debug("Merkle state export failed",{error:String(V)})}let W=dq(l.task_type,I.cachedDetection),a=wW[l.task_type]?.include??wW.code.include,m=I.projectRoot.split(/[/\\]/).pop()??"project",N=[];if(N.push(`<!-- HSA Handoff v1.1.0 | type:${l.task_type} | stack:${b} | files:${Z.length} -->`),N.push(""),N.push(`## Project: ${m}`),N.push(`- **Stack**: ${b}`),N.push(`- **Root**: \`${I.projectRoot}\``),I.cachedDetection?.buildSystem){let V=I.cachedDetection.buildSystem,n=[];V.buildCommand&&n.push(`**Build**: \`${V.buildCommand}\``),V.testCommand&&n.push(`**Test**: \`${V.testCommand}\``),V.devCommand&&n.push(`**Dev**: \`${V.devCommand}\``),n.length>0&&N.push(`- ${n.join(" | ")}`)}if(I.cachedDetection?.monorepo&&N.push("- \u{1F4E6} **Monorepo** detected"),N.push(""),Z.length>0){N.push("## Relevant Files"),N.push(""),N.push("| File | Role |"),N.push("|------|------|");for(let V of Z.slice(0,10))N.push(`| \`${V.path}\` | ${V.role} |`);if(Z.length>10&&N.push(`| ... | +${Z.length-10} more |`),N.push(""),I.codeGraph){let V=Z.filter(n=>n.role==="primary").slice(0,5);for(let n of V){let t=I.codeGraph.getFileSymbols(n.path).filter(s=>s.exported).slice(0,8);t.length>0&&N.push(`**\`${n.path}\`**: ${t.map(s=>`${s.kind} \`${s.name}\``).join(", ")}`)}V.length>0&&N.push("")}}if(d.length>0){N.push("## Tracked Files");for(let V of d.slice(0,5))N.push(`- ${V}`);N.push("")}if(l.task_description&&(N.push("## Task"),N.push(l.task_description),N.push("")),W.length>0){N.push("## Constraints");for(let V of W)N.push(`- ${V}`);N.push("")}if(I.session){let V=I.session.getRecentQueries(3),n=I.session.getRecentEdits(5);(V.length>0||n.length>0)&&(N.push("## Session Context"),V.length>0&&N.push("**Recent queries**: "+V.map(h=>`\`${h.slice(0,60)}\``).join(" \u2192 ")),n.length>0&&N.push("**Recently edited**: "+n.map(h=>`\`${h}\``).join(", ")),N.push(""))}N.push("## Suggested Tools"),N.push(a.map(V=>`\`${V}\``).join(", ")),N.push("");let e=N.join(`
|
|
312
312
|
`),Y=I.tokenizer.countTokens(e),p=`${e}
|
|
313
313
|
<!-- tokens: ${Y} -->`;return FI.increment("handoff.tokens",I.tokenizer.countTokens(p)),Km.info("Handoff packet generated",{taskType:l.task_type,files:Z.length,constraints:W.length,tokens:I.tokenizer.countTokens(p)}),p}var Km,iJ=u(()=>{"use strict";rs();T();bb();Km=J("tool:prepare-handoff")});function oJ(l){Wq.info("hsa_filter_tools called",{taskType:l.task_type});let I=wW[l.task_type];if(!I)return`Unknown task type: ${l.task_type}. Supported: ${Object.keys(wW).join(", ")}`;let G=[];G.push(`## Tool Filter: ${l.task_type}`),G.push(""),G.push(`**Rationale**: ${I.rationale}`),G.push(""),G.push("### \u2705 Include (expose to sub-agent)"),G.push("");for(let c of I.include)G.push(`- \`${c}\``);G.push(""),G.push("### \u274C Exclude (hide from sub-agent)"),G.push("");for(let c of I.exclude)G.push(`- \`${c}\``);return G.push(""),G.push("### \u{1F4CA} Impact"),G.push(`- **Included tools**: ${I.include.length}`),G.push(`- **Estimated token savings**: ~${aq(I.include.length)}`),G.push(""),G.join(`
|
|
314
314
|
`)}function aq(l){return`~${l*300} tokens (${l} tools \xD7 ~300 tok each). Exclude the rest to save context.`}var Wq,yJ=u(()=>{"use strict";rs();T();Wq=J("tool:filter-tools")});async function EJ(l,I){Cs.info("hsa_trace_flow called",{entry:l.entry_point,depth:l.depth});let{codeGraph:G}=I;if(G.fileCount===0)return Cs.warn("Trace flow unavailable \u2014 CodeGraph has 0 indexed files"),Zl({level:"warning",tool:"hsa_trace_flow",message:"CodeGraph has 0 indexed files. Background indexing may not have completed yet.",suggestion:"Run `hsa_check_changes` first, then retry."});let c=Math.min(l.depth??3,5),b=l.direction??"downstream",Z=G.getTagIndex(),d=[...Z.findDefinitions(l.entry_point)];if(d.length===0){let Y=G.getAllFiles();for(let p of Y)G.getFileSymbols(p).some(n=>n.name===l.entry_point)&&d.push(p)}if(d.length===0)return Zl({level:"error",tool:"hsa_trace_flow",message:`Symbol "${l.entry_point}" not found in the codebase.`,suggestion:"Use exact symbol name (case sensitive). Ensure the file has been indexed via `hsa_check_changes`."});let W=[],a=0,m=new Set;for(let Y of d.slice(0,3)){let p=new Set,n=G.getFileSymbols(Y).find(w=>w.name===l.entry_point),s=Z.getFileDefinitions(Y).find(w=>w.name===l.entry_point)?.signature?.split(`
|