@automagik/genie 4.260508.2 → 4.260508.3

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/genie.js CHANGED
@@ -148,7 +148,7 @@ Expecting one of '${allowedValues.join("', '")}'`);let helpEvent=`${position}Hel
148
148
  COUNT(*) FILTER (WHERE entity_type = 'otel_tool')::int AS tool_calls,
149
149
  COUNT(*) FILTER (WHERE entity_type = 'otel_api')::int AS api_requests
150
150
  FROM audit_events
151
- WHERE created_at >= $1::timestamptz`,[sinceTs]))[0]??{};return{agents_spawned:r.agents_spawned??0,tasks_moved:r.tasks_moved??0,total_cost:r.total_cost??0,error_count:r.error_count??0,total_events:r.total_events??0,tool_calls:r.tool_calls??0,api_requests:r.api_requests??0}}function generateTraceId(){return crypto.randomUUID()}var DEFAULT_TIMELINE_LIMIT=200,MAX_TIMELINE_LIMIT=2000,DEFAULT_TIMELINE_SINCE_MS=86400000;var init_audit=__esm(()=>{init_db()});import{readFile,unlink,writeFile}from"fs/promises";function lockPath(filePath){return`${filePath}.lock`}function isPidAlive(pid){try{return process.kill(pid,0),!0}catch{return!1}}async function acquireLock(path){let lock=lockPath(path),deadline=Date.now()+LOCK_TIMEOUT_MS;while(Date.now()<deadline)try{await writeFile(lock,String(process.pid),{flag:"wx"});return}catch{try{let content=await readFile(lock,"utf-8"),holderPid=Number.parseInt(content.trim(),10);if(!Number.isNaN(holderPid)&&!isPidAlive(holderPid)){try{await unlink(lock)}catch{}continue}}catch{continue}let jitter=Math.floor(Math.random()*LOCK_POLL_MS);await new Promise((r)=>setTimeout(r,LOCK_POLL_MS+jitter))}console.warn(`[lockfile] Force-acquiring stale lock: ${lock}`),await writeFile(lock,String(process.pid))}async function releaseLock(path){try{await unlink(lockPath(path))}catch{}}var LOCK_TIMEOUT_MS=5000,LOCK_POLL_MS=50;var init_lockfile=()=>{};var util,objectUtil,ZodParsedType,getParsedType=(data)=>{switch(typeof data){case"undefined":return ZodParsedType.undefined;case"string":return ZodParsedType.string;case"number":return Number.isNaN(data)?ZodParsedType.nan:ZodParsedType.number;case"boolean":return ZodParsedType.boolean;case"function":return ZodParsedType.function;case"bigint":return ZodParsedType.bigint;case"symbol":return ZodParsedType.symbol;case"object":if(Array.isArray(data))return ZodParsedType.array;if(data===null)return ZodParsedType.null;if(data.then&&typeof data.then==="function"&&data.catch&&typeof data.catch==="function")return ZodParsedType.promise;if(typeof Map<"u"&&data instanceof Map)return ZodParsedType.map;if(typeof Set<"u"&&data instanceof Set)return ZodParsedType.set;if(typeof Date<"u"&&data instanceof Date)return ZodParsedType.date;return ZodParsedType.object;default:return ZodParsedType.unknown}};var init_util=__esm(()=>{(function(util2){util2.assertEqual=(_)=>{};function assertIs(_arg){}util2.assertIs=assertIs;function assertNever(_x){throw Error()}util2.assertNever=assertNever,util2.arrayToEnum=(items)=>{let obj={};for(let item of items)obj[item]=item;return obj},util2.getValidEnumValues=(obj)=>{let validKeys=util2.objectKeys(obj).filter((k)=>typeof obj[obj[k]]!=="number"),filtered={};for(let k of validKeys)filtered[k]=obj[k];return util2.objectValues(filtered)},util2.objectValues=(obj)=>{return util2.objectKeys(obj).map(function(e){return obj[e]})},util2.objectKeys=typeof Object.keys==="function"?(obj)=>Object.keys(obj):(object)=>{let keys=[];for(let key in object)if(Object.prototype.hasOwnProperty.call(object,key))keys.push(key);return keys},util2.find=(arr,checker)=>{for(let item of arr)if(checker(item))return item;return},util2.isInteger=typeof Number.isInteger==="function"?(val)=>Number.isInteger(val):(val)=>typeof val==="number"&&Number.isFinite(val)&&Math.floor(val)===val;function joinValues(array,separator=" | "){return array.map((val)=>typeof val==="string"?`'${val}'`:val).join(separator)}util2.joinValues=joinValues,util2.jsonStringifyReplacer=(_,value)=>{if(typeof value==="bigint")return value.toString();return value}})(util||(util={}));(function(objectUtil2){objectUtil2.mergeShapes=(first,second)=>{return{...first,...second}}})(objectUtil||(objectUtil={}));ZodParsedType=util.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var ZodIssueCode,quotelessJson=(obj)=>{return JSON.stringify(obj,null,2).replace(/"([^"]+)":/g,"$1:")},ZodError;var init_ZodError=__esm(()=>{init_util();ZodIssueCode=util.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"]);ZodError=class ZodError extends Error{get errors(){return this.issues}constructor(issues){super();this.issues=[],this.addIssue=(sub)=>{this.issues=[...this.issues,sub]},this.addIssues=(subs=[])=>{this.issues=[...this.issues,...subs]};let actualProto=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,actualProto);else this.__proto__=actualProto;this.name="ZodError",this.issues=issues}format(_mapper){let mapper=_mapper||function(issue){return issue.message},fieldErrors={_errors:[]},processError=(error)=>{for(let issue of error.issues)if(issue.code==="invalid_union")issue.unionErrors.map(processError);else if(issue.code==="invalid_return_type")processError(issue.returnTypeError);else if(issue.code==="invalid_arguments")processError(issue.argumentsError);else if(issue.path.length===0)fieldErrors._errors.push(mapper(issue));else{let curr=fieldErrors,i=0;while(i<issue.path.length){let el=issue.path[i];if(i!==issue.path.length-1)curr[el]=curr[el]||{_errors:[]};else curr[el]=curr[el]||{_errors:[]},curr[el]._errors.push(mapper(issue));curr=curr[el],i++}}};return processError(this),fieldErrors}static assert(value){if(!(value instanceof ZodError))throw Error(`Not a ZodError: ${value}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(mapper=(issue)=>issue.message){let fieldErrors={},formErrors=[];for(let sub of this.issues)if(sub.path.length>0){let firstEl=sub.path[0];fieldErrors[firstEl]=fieldErrors[firstEl]||[],fieldErrors[firstEl].push(mapper(sub))}else formErrors.push(mapper(sub));return{formErrors,fieldErrors}}get formErrors(){return this.flatten()}};ZodError.create=(issues)=>{return new ZodError(issues)}});var errorMap=(issue,_ctx)=>{let message;switch(issue.code){case ZodIssueCode.invalid_type:if(issue.received===ZodParsedType.undefined)message="Required";else message=`Expected ${issue.expected}, received ${issue.received}`;break;case ZodIssueCode.invalid_literal:message=`Invalid literal value, expected ${JSON.stringify(issue.expected,util.jsonStringifyReplacer)}`;break;case ZodIssueCode.unrecognized_keys:message=`Unrecognized key(s) in object: ${util.joinValues(issue.keys,", ")}`;break;case ZodIssueCode.invalid_union:message="Invalid input";break;case ZodIssueCode.invalid_union_discriminator:message=`Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;break;case ZodIssueCode.invalid_enum_value:message=`Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;break;case ZodIssueCode.invalid_arguments:message="Invalid function arguments";break;case ZodIssueCode.invalid_return_type:message="Invalid function return type";break;case ZodIssueCode.invalid_date:message="Invalid date";break;case ZodIssueCode.invalid_string:if(typeof issue.validation==="object")if("includes"in issue.validation){if(message=`Invalid input: must include "${issue.validation.includes}"`,typeof issue.validation.position==="number")message=`${message} at one or more positions greater than or equal to ${issue.validation.position}`}else if("startsWith"in issue.validation)message=`Invalid input: must start with "${issue.validation.startsWith}"`;else if("endsWith"in issue.validation)message=`Invalid input: must end with "${issue.validation.endsWith}"`;else util.assertNever(issue.validation);else if(issue.validation!=="regex")message=`Invalid ${issue.validation}`;else message="Invalid";break;case ZodIssueCode.too_small:if(issue.type==="array")message=`Array must contain ${issue.exact?"exactly":issue.inclusive?"at least":"more than"} ${issue.minimum} element(s)`;else if(issue.type==="string")message=`String must contain ${issue.exact?"exactly":issue.inclusive?"at least":"over"} ${issue.minimum} character(s)`;else if(issue.type==="number")message=`Number must be ${issue.exact?"exactly equal to ":issue.inclusive?"greater than or equal to ":"greater than "}${issue.minimum}`;else if(issue.type==="bigint")message=`Number must be ${issue.exact?"exactly equal to ":issue.inclusive?"greater than or equal to ":"greater than "}${issue.minimum}`;else if(issue.type==="date")message=`Date must be ${issue.exact?"exactly equal to ":issue.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(issue.minimum))}`;else message="Invalid input";break;case ZodIssueCode.too_big:if(issue.type==="array")message=`Array must contain ${issue.exact?"exactly":issue.inclusive?"at most":"less than"} ${issue.maximum} element(s)`;else if(issue.type==="string")message=`String must contain ${issue.exact?"exactly":issue.inclusive?"at most":"under"} ${issue.maximum} character(s)`;else if(issue.type==="number")message=`Number must be ${issue.exact?"exactly":issue.inclusive?"less than or equal to":"less than"} ${issue.maximum}`;else if(issue.type==="bigint")message=`BigInt must be ${issue.exact?"exactly":issue.inclusive?"less than or equal to":"less than"} ${issue.maximum}`;else if(issue.type==="date")message=`Date must be ${issue.exact?"exactly":issue.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(issue.maximum))}`;else message="Invalid input";break;case ZodIssueCode.custom:message="Invalid input";break;case ZodIssueCode.invalid_intersection_types:message="Intersection results could not be merged";break;case ZodIssueCode.not_multiple_of:message=`Number must be a multiple of ${issue.multipleOf}`;break;case ZodIssueCode.not_finite:message="Number must be finite";break;default:message=_ctx.defaultError,util.assertNever(issue)}return{message}},en_default;var init_en=__esm(()=>{init_ZodError();init_util();en_default=errorMap});function setErrorMap(map){overrideErrorMap=map}function getErrorMap(){return overrideErrorMap}var overrideErrorMap;var init_errors=__esm(()=>{init_en();overrideErrorMap=en_default});function addIssueToContext(ctx,issueData){let overrideMap=getErrorMap(),issue=makeIssue({issueData,data:ctx.data,path:ctx.path,errorMaps:[ctx.common.contextualErrorMap,ctx.schemaErrorMap,overrideMap,overrideMap===en_default?void 0:en_default].filter((x)=>!!x)});ctx.common.issues.push(issue)}class ParseStatus{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(status,results){let arrayValue=[];for(let s of results){if(s.status==="aborted")return INVALID;if(s.status==="dirty")status.dirty();arrayValue.push(s.value)}return{status:status.value,value:arrayValue}}static async mergeObjectAsync(status,pairs){let syncPairs=[];for(let pair of pairs){let key=await pair.key,value=await pair.value;syncPairs.push({key,value})}return ParseStatus.mergeObjectSync(status,syncPairs)}static mergeObjectSync(status,pairs){let finalObject={};for(let pair of pairs){let{key,value}=pair;if(key.status==="aborted")return INVALID;if(value.status==="aborted")return INVALID;if(key.status==="dirty")status.dirty();if(value.status==="dirty")status.dirty();if(key.value!=="__proto__"&&(typeof value.value<"u"||pair.alwaysSet))finalObject[key.value]=value.value}return{status:status.value,value:finalObject}}}var makeIssue=(params)=>{let{data,path,errorMaps,issueData}=params,fullPath=[...path,...issueData.path||[]],fullIssue={...issueData,path:fullPath};if(issueData.message!==void 0)return{...issueData,path:fullPath,message:issueData.message};let errorMessage="",maps=errorMaps.filter((m)=>!!m).slice().reverse();for(let map of maps)errorMessage=map(fullIssue,{data,defaultError:errorMessage}).message;return{...issueData,path:fullPath,message:errorMessage}},EMPTY_PATH,INVALID,DIRTY=(value)=>({status:"dirty",value}),OK=(value)=>({status:"valid",value}),isAborted=(x)=>x.status==="aborted",isDirty=(x)=>x.status==="dirty",isValid=(x)=>x.status==="valid",isAsync=(x)=>typeof Promise<"u"&&x instanceof Promise;var init_parseUtil=__esm(()=>{init_errors();init_en();EMPTY_PATH=[];INVALID=Object.freeze({status:"aborted"})});var init_typeAliases=()=>{};var errorUtil;var init_errorUtil=__esm(()=>{(function(errorUtil2){errorUtil2.errToObj=(message)=>typeof message==="string"?{message}:message||{},errorUtil2.toString=(message)=>typeof message==="string"?message:message?.message})(errorUtil||(errorUtil={}))});class ParseInputLazyPath{constructor(parent,value,path,key){this._cachedPath=[],this.parent=parent,this.data=value,this._path=path,this._key=key}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function processCreateParams(params){if(!params)return{};let{errorMap:errorMap2,invalid_type_error,required_error,description}=params;if(errorMap2&&(invalid_type_error||required_error))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(errorMap2)return{errorMap:errorMap2,description};return{errorMap:(iss,ctx)=>{let{message}=params;if(iss.code==="invalid_enum_value")return{message:message??ctx.defaultError};if(typeof ctx.data>"u")return{message:message??required_error??ctx.defaultError};if(iss.code!=="invalid_type")return{message:ctx.defaultError};return{message:message??invalid_type_error??ctx.defaultError}},description}}class ZodType{get description(){return this._def.description}_getType(input){return getParsedType(input.data)}_getOrReturnCtx(input,ctx){return ctx||{common:input.parent.common,data:input.data,parsedType:getParsedType(input.data),schemaErrorMap:this._def.errorMap,path:input.path,parent:input.parent}}_processInputParams(input){return{status:new ParseStatus,ctx:{common:input.parent.common,data:input.data,parsedType:getParsedType(input.data),schemaErrorMap:this._def.errorMap,path:input.path,parent:input.parent}}}_parseSync(input){let result2=this._parse(input);if(isAsync(result2))throw Error("Synchronous parse encountered promise.");return result2}_parseAsync(input){let result2=this._parse(input);return Promise.resolve(result2)}parse(data,params){let result2=this.safeParse(data,params);if(result2.success)return result2.data;throw result2.error}safeParse(data,params){let ctx={common:{issues:[],async:params?.async??!1,contextualErrorMap:params?.errorMap},path:params?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data,parsedType:getParsedType(data)},result2=this._parseSync({data,path:ctx.path,parent:ctx});return handleResult(ctx,result2)}"~validate"(data){let ctx={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data,parsedType:getParsedType(data)};if(!this["~standard"].async)try{let result2=this._parseSync({data,path:[],parent:ctx});return isValid(result2)?{value:result2.value}:{issues:ctx.common.issues}}catch(err){if(err?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;ctx.common={issues:[],async:!0}}return this._parseAsync({data,path:[],parent:ctx}).then((result2)=>isValid(result2)?{value:result2.value}:{issues:ctx.common.issues})}async parseAsync(data,params){let result2=await this.safeParseAsync(data,params);if(result2.success)return result2.data;throw result2.error}async safeParseAsync(data,params){let ctx={common:{issues:[],contextualErrorMap:params?.errorMap,async:!0},path:params?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data,parsedType:getParsedType(data)},maybeAsyncResult=this._parse({data,path:ctx.path,parent:ctx}),result2=await(isAsync(maybeAsyncResult)?maybeAsyncResult:Promise.resolve(maybeAsyncResult));return handleResult(ctx,result2)}refine(check,message){let getIssueProperties=(val)=>{if(typeof message==="string"||typeof message>"u")return{message};else if(typeof message==="function")return message(val);else return message};return this._refinement((val,ctx)=>{let result2=check(val),setError=()=>ctx.addIssue({code:ZodIssueCode.custom,...getIssueProperties(val)});if(typeof Promise<"u"&&result2 instanceof Promise)return result2.then((data)=>{if(!data)return setError(),!1;else return!0});if(!result2)return setError(),!1;else return!0})}refinement(check,refinementData){return this._refinement((val,ctx)=>{if(!check(val))return ctx.addIssue(typeof refinementData==="function"?refinementData(val,ctx):refinementData),!1;else return!0})}_refinement(refinement){return new ZodEffects({schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"refinement",refinement}})}superRefine(refinement){return this._refinement(refinement)}constructor(def){this.spa=this.safeParseAsync,this._def=def,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:(data)=>this["~validate"](data)}}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this)}promise(){return ZodPromise.create(this,this._def)}or(option){return ZodUnion.create([this,option],this._def)}and(incoming){return ZodIntersection.create(this,incoming,this._def)}transform(transform){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"transform",transform}})}default(def){let defaultValueFunc=typeof def==="function"?def:()=>def;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:defaultValueFunc,typeName:ZodFirstPartyTypeKind.ZodDefault})}brand(){return new ZodBranded({typeName:ZodFirstPartyTypeKind.ZodBranded,type:this,...processCreateParams(this._def)})}catch(def){let catchValueFunc=typeof def==="function"?def:()=>def;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:catchValueFunc,typeName:ZodFirstPartyTypeKind.ZodCatch})}describe(description){return new this.constructor({...this._def,description})}pipe(target){return ZodPipeline.create(this,target)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function timeRegexSource(args){let secondsRegexSource="[0-5]\\d";if(args.precision)secondsRegexSource=`${secondsRegexSource}\\.\\d{${args.precision}}`;else if(args.precision==null)secondsRegexSource=`${secondsRegexSource}(\\.\\d+)?`;let secondsQuantifier=args.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`}function timeRegex(args){return new RegExp(`^${timeRegexSource(args)}$`)}function datetimeRegex(args){let regex=`${dateRegexSource}T${timeRegexSource(args)}`,opts=[];if(opts.push(args.local?"Z?":"Z"),args.offset)opts.push("([+-]\\d{2}:?\\d{2})");return regex=`${regex}(${opts.join("|")})`,new RegExp(`^${regex}$`)}function isValidIP(ip,version){if((version==="v4"||!version)&&ipv4Regex.test(ip))return!0;if((version==="v6"||!version)&&ipv6Regex.test(ip))return!0;return!1}function isValidJWT(jwt,alg){if(!jwtRegex.test(jwt))return!1;try{let[header]=jwt.split(".");if(!header)return!1;let base64=header.replace(/-/g,"+").replace(/_/g,"/").padEnd(header.length+(4-header.length%4)%4,"="),decoded=JSON.parse(atob(base64));if(typeof decoded!=="object"||decoded===null)return!1;if("typ"in decoded&&decoded?.typ!=="JWT")return!1;if(!decoded.alg)return!1;if(alg&&decoded.alg!==alg)return!1;return!0}catch{return!1}}function isValidCidr(ip,version){if((version==="v4"||!version)&&ipv4CidrRegex.test(ip))return!0;if((version==="v6"||!version)&&ipv6CidrRegex.test(ip))return!0;return!1}function floatSafeRemainder(val,step){let valDecCount=(val.toString().split(".")[1]||"").length,stepDecCount=(step.toString().split(".")[1]||"").length,decCount=valDecCount>stepDecCount?valDecCount:stepDecCount,valInt=Number.parseInt(val.toFixed(decCount).replace(".","")),stepInt=Number.parseInt(step.toFixed(decCount).replace(".",""));return valInt%stepInt/10**decCount}function deepPartialify(schema){if(schema instanceof ZodObject){let newShape={};for(let key in schema.shape){let fieldSchema=schema.shape[key];newShape[key]=ZodOptional.create(deepPartialify(fieldSchema))}return new ZodObject({...schema._def,shape:()=>newShape})}else if(schema instanceof ZodArray)return new ZodArray({...schema._def,type:deepPartialify(schema.element)});else if(schema instanceof ZodOptional)return ZodOptional.create(deepPartialify(schema.unwrap()));else if(schema instanceof ZodNullable)return ZodNullable.create(deepPartialify(schema.unwrap()));else if(schema instanceof ZodTuple)return ZodTuple.create(schema.items.map((item)=>deepPartialify(item)));else return schema}function mergeValues(a,b){let aType=getParsedType(a),bType=getParsedType(b);if(a===b)return{valid:!0,data:a};else if(aType===ZodParsedType.object&&bType===ZodParsedType.object){let bKeys=util.objectKeys(b),sharedKeys=util.objectKeys(a).filter((key)=>bKeys.indexOf(key)!==-1),newObj={...a,...b};for(let key of sharedKeys){let sharedValue=mergeValues(a[key],b[key]);if(!sharedValue.valid)return{valid:!1};newObj[key]=sharedValue.data}return{valid:!0,data:newObj}}else if(aType===ZodParsedType.array&&bType===ZodParsedType.array){if(a.length!==b.length)return{valid:!1};let newArray=[];for(let index=0;index<a.length;index++){let itemA=a[index],itemB=b[index],sharedValue=mergeValues(itemA,itemB);if(!sharedValue.valid)return{valid:!1};newArray.push(sharedValue.data)}return{valid:!0,data:newArray}}else if(aType===ZodParsedType.date&&bType===ZodParsedType.date&&+a===+b)return{valid:!0,data:a};else return{valid:!1}}function createZodEnum(values,params){return new ZodEnum({values,typeName:ZodFirstPartyTypeKind.ZodEnum,...processCreateParams(params)})}function cleanParams(params,data){let p=typeof params==="function"?params(data):typeof params==="string"?{message:params}:params;return typeof p==="string"?{message:p}:p}function custom(check,_params={},fatal){if(check)return ZodAny.create().superRefine((data,ctx)=>{let r=check(data);if(r instanceof Promise)return r.then((r2)=>{if(!r2){let params=cleanParams(_params,data),_fatal=params.fatal??fatal??!0;ctx.addIssue({code:"custom",...params,fatal:_fatal})}});if(!r){let params=cleanParams(_params,data),_fatal=params.fatal??fatal??!0;ctx.addIssue({code:"custom",...params,fatal:_fatal})}return});return ZodAny.create()}var handleResult=(ctx,result2)=>{if(isValid(result2))return{success:!0,data:result2.value};else{if(!ctx.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let error=new ZodError(ctx.common.issues);return this._error=error,this._error}}}},cuidRegex,cuid2Regex,ulidRegex,uuidRegex,nanoidRegex,jwtRegex,durationRegex,emailRegex,_emojiRegex="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",emojiRegex,ipv4Regex,ipv4CidrRegex,ipv6Regex,ipv6CidrRegex,base64Regex,base64urlRegex,dateRegexSource="((\\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])))",dateRegex,ZodString,ZodNumber,ZodBigInt,ZodBoolean,ZodDate,ZodSymbol,ZodUndefined,ZodNull,ZodAny,ZodUnknown,ZodNever,ZodVoid,ZodArray,ZodObject,ZodUnion,getDiscriminator=(type)=>{if(type instanceof ZodLazy)return getDiscriminator(type.schema);else if(type instanceof ZodEffects)return getDiscriminator(type.innerType());else if(type instanceof ZodLiteral)return[type.value];else if(type instanceof ZodEnum)return type.options;else if(type instanceof ZodNativeEnum)return util.objectValues(type.enum);else if(type instanceof ZodDefault)return getDiscriminator(type._def.innerType);else if(type instanceof ZodUndefined)return[void 0];else if(type instanceof ZodNull)return[null];else if(type instanceof ZodOptional)return[void 0,...getDiscriminator(type.unwrap())];else if(type instanceof ZodNullable)return[null,...getDiscriminator(type.unwrap())];else if(type instanceof ZodBranded)return getDiscriminator(type.unwrap());else if(type instanceof ZodReadonly)return getDiscriminator(type.unwrap());else if(type instanceof ZodCatch)return getDiscriminator(type._def.innerType);else return[]},ZodDiscriminatedUnion,ZodIntersection,ZodTuple,ZodRecord,ZodMap,ZodSet,ZodFunction,ZodLazy,ZodLiteral,ZodEnum,ZodNativeEnum,ZodPromise,ZodEffects,ZodOptional,ZodNullable,ZodDefault,ZodCatch,ZodNaN,BRAND,ZodBranded,ZodPipeline,ZodReadonly,late,ZodFirstPartyTypeKind,instanceOfType=(cls,params={message:`Input not instance of ${cls.name}`})=>custom((data)=>data instanceof cls,params),stringType,numberType,nanType,bigIntType,booleanType,dateType,symbolType,undefinedType,nullType,anyType,unknownType,neverType,voidType,arrayType,objectType,strictObjectType,unionType,discriminatedUnionType,intersectionType,tupleType,recordType,mapType,setType,functionType,lazyType,literalType,enumType,nativeEnumType,promiseType,effectsType,optionalType,nullableType,preprocessType,pipelineType,ostring=()=>stringType().optional(),onumber=()=>numberType().optional(),oboolean=()=>booleanType().optional(),coerce,NEVER;var init_types=__esm(()=>{init_ZodError();init_errors();init_errorUtil();init_parseUtil();init_util();cuidRegex=/^c[^\s-]{8,}$/i,cuid2Regex=/^[0-9a-z]+$/,ulidRegex=/^[0-9A-HJKMNP-TV-Z]{26}$/i,uuidRegex=/^[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,nanoidRegex=/^[a-z0-9_-]{21}$/i,jwtRegex=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,durationRegex=/^[-+]?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)?)??$/,emailRegex=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ipv4Regex=/^(?:(?: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])$/,ipv4CidrRegex=/^(?:(?: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])$/,ipv6Regex=/^(([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]))$/,ipv6CidrRegex=/^(([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])$/,base64Regex=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64urlRegex=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dateRegex=new RegExp(`^${dateRegexSource}$`);ZodString=class ZodString extends ZodType{_parse(input){if(this._def.coerce)input.data=String(input.data);if(this._getType(input)!==ZodParsedType.string){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.string,received:ctx2.parsedType}),INVALID}let status=new ParseStatus,ctx=void 0;for(let check of this._def.checks)if(check.kind==="min"){if(input.data.length<check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:check.value,type:"string",inclusive:!0,exact:!1,message:check.message}),status.dirty()}else if(check.kind==="max"){if(input.data.length>check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:check.value,type:"string",inclusive:!0,exact:!1,message:check.message}),status.dirty()}else if(check.kind==="length"){let tooBig=input.data.length>check.value,tooSmall=input.data.length<check.value;if(tooBig||tooSmall){if(ctx=this._getOrReturnCtx(input,ctx),tooBig)addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:check.value,type:"string",inclusive:!0,exact:!0,message:check.message});else if(tooSmall)addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:check.value,type:"string",inclusive:!0,exact:!0,message:check.message});status.dirty()}}else if(check.kind==="email"){if(!emailRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"email",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="emoji"){if(!emojiRegex)emojiRegex=new RegExp(_emojiRegex,"u");if(!emojiRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"emoji",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="uuid"){if(!uuidRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"uuid",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="nanoid"){if(!nanoidRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"nanoid",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="cuid"){if(!cuidRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"cuid",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="cuid2"){if(!cuid2Regex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"cuid2",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="ulid"){if(!ulidRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"ulid",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="url")try{new URL(input.data)}catch{ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"url",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="regex"){if(check.regex.lastIndex=0,!check.regex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"regex",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="trim")input.data=input.data.trim();else if(check.kind==="includes"){if(!input.data.includes(check.value,check.position))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:{includes:check.value,position:check.position},message:check.message}),status.dirty()}else if(check.kind==="toLowerCase")input.data=input.data.toLowerCase();else if(check.kind==="toUpperCase")input.data=input.data.toUpperCase();else if(check.kind==="startsWith"){if(!input.data.startsWith(check.value))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:{startsWith:check.value},message:check.message}),status.dirty()}else if(check.kind==="endsWith"){if(!input.data.endsWith(check.value))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:{endsWith:check.value},message:check.message}),status.dirty()}else if(check.kind==="datetime"){if(!datetimeRegex(check).test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:"datetime",message:check.message}),status.dirty()}else if(check.kind==="date"){if(!dateRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:"date",message:check.message}),status.dirty()}else if(check.kind==="time"){if(!timeRegex(check).test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:"time",message:check.message}),status.dirty()}else if(check.kind==="duration"){if(!durationRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"duration",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="ip"){if(!isValidIP(input.data,check.version))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"ip",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="jwt"){if(!isValidJWT(input.data,check.alg))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"jwt",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="cidr"){if(!isValidCidr(input.data,check.version))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"cidr",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="base64"){if(!base64Regex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"base64",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="base64url"){if(!base64urlRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"base64url",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else util.assertNever(check);return{status:status.value,value:input.data}}_regex(regex,validation,message){return this.refinement((data)=>regex.test(data),{validation,code:ZodIssueCode.invalid_string,...errorUtil.errToObj(message)})}_addCheck(check){return new ZodString({...this._def,checks:[...this._def.checks,check]})}email(message){return this._addCheck({kind:"email",...errorUtil.errToObj(message)})}url(message){return this._addCheck({kind:"url",...errorUtil.errToObj(message)})}emoji(message){return this._addCheck({kind:"emoji",...errorUtil.errToObj(message)})}uuid(message){return this._addCheck({kind:"uuid",...errorUtil.errToObj(message)})}nanoid(message){return this._addCheck({kind:"nanoid",...errorUtil.errToObj(message)})}cuid(message){return this._addCheck({kind:"cuid",...errorUtil.errToObj(message)})}cuid2(message){return this._addCheck({kind:"cuid2",...errorUtil.errToObj(message)})}ulid(message){return this._addCheck({kind:"ulid",...errorUtil.errToObj(message)})}base64(message){return this._addCheck({kind:"base64",...errorUtil.errToObj(message)})}base64url(message){return this._addCheck({kind:"base64url",...errorUtil.errToObj(message)})}jwt(options){return this._addCheck({kind:"jwt",...errorUtil.errToObj(options)})}ip(options){return this._addCheck({kind:"ip",...errorUtil.errToObj(options)})}cidr(options){return this._addCheck({kind:"cidr",...errorUtil.errToObj(options)})}datetime(options){if(typeof options==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:options});return this._addCheck({kind:"datetime",precision:typeof options?.precision>"u"?null:options?.precision,offset:options?.offset??!1,local:options?.local??!1,...errorUtil.errToObj(options?.message)})}date(message){return this._addCheck({kind:"date",message})}time(options){if(typeof options==="string")return this._addCheck({kind:"time",precision:null,message:options});return this._addCheck({kind:"time",precision:typeof options?.precision>"u"?null:options?.precision,...errorUtil.errToObj(options?.message)})}duration(message){return this._addCheck({kind:"duration",...errorUtil.errToObj(message)})}regex(regex,message){return this._addCheck({kind:"regex",regex,...errorUtil.errToObj(message)})}includes(value,options){return this._addCheck({kind:"includes",value,position:options?.position,...errorUtil.errToObj(options?.message)})}startsWith(value,message){return this._addCheck({kind:"startsWith",value,...errorUtil.errToObj(message)})}endsWith(value,message){return this._addCheck({kind:"endsWith",value,...errorUtil.errToObj(message)})}min(minLength,message){return this._addCheck({kind:"min",value:minLength,...errorUtil.errToObj(message)})}max(maxLength,message){return this._addCheck({kind:"max",value:maxLength,...errorUtil.errToObj(message)})}length(len,message){return this._addCheck({kind:"length",value:len,...errorUtil.errToObj(message)})}nonempty(message){return this.min(1,errorUtil.errToObj(message))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((ch)=>ch.kind==="datetime")}get isDate(){return!!this._def.checks.find((ch)=>ch.kind==="date")}get isTime(){return!!this._def.checks.find((ch)=>ch.kind==="time")}get isDuration(){return!!this._def.checks.find((ch)=>ch.kind==="duration")}get isEmail(){return!!this._def.checks.find((ch)=>ch.kind==="email")}get isURL(){return!!this._def.checks.find((ch)=>ch.kind==="url")}get isEmoji(){return!!this._def.checks.find((ch)=>ch.kind==="emoji")}get isUUID(){return!!this._def.checks.find((ch)=>ch.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((ch)=>ch.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((ch)=>ch.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((ch)=>ch.kind==="cuid2")}get isULID(){return!!this._def.checks.find((ch)=>ch.kind==="ulid")}get isIP(){return!!this._def.checks.find((ch)=>ch.kind==="ip")}get isCIDR(){return!!this._def.checks.find((ch)=>ch.kind==="cidr")}get isBase64(){return!!this._def.checks.find((ch)=>ch.kind==="base64")}get isBase64url(){return!!this._def.checks.find((ch)=>ch.kind==="base64url")}get minLength(){let min=null;for(let ch of this._def.checks)if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}return min}get maxLength(){let max=null;for(let ch of this._def.checks)if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return max}};ZodString.create=(params)=>{return new ZodString({checks:[],typeName:ZodFirstPartyTypeKind.ZodString,coerce:params?.coerce??!1,...processCreateParams(params)})};ZodNumber=class ZodNumber extends ZodType{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(input){if(this._def.coerce)input.data=Number(input.data);if(this._getType(input)!==ZodParsedType.number){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.number,received:ctx2.parsedType}),INVALID}let ctx=void 0,status=new ParseStatus;for(let check of this._def.checks)if(check.kind==="int"){if(!util.isInteger(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:"integer",received:"float",message:check.message}),status.dirty()}else if(check.kind==="min"){if(check.inclusive?input.data<check.value:input.data<=check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:check.value,type:"number",inclusive:check.inclusive,exact:!1,message:check.message}),status.dirty()}else if(check.kind==="max"){if(check.inclusive?input.data>check.value:input.data>=check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:check.value,type:"number",inclusive:check.inclusive,exact:!1,message:check.message}),status.dirty()}else if(check.kind==="multipleOf"){if(floatSafeRemainder(input.data,check.value)!==0)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.not_multiple_of,multipleOf:check.value,message:check.message}),status.dirty()}else if(check.kind==="finite"){if(!Number.isFinite(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.not_finite,message:check.message}),status.dirty()}else util.assertNever(check);return{status:status.value,value:input.data}}gte(value,message){return this.setLimit("min",value,!0,errorUtil.toString(message))}gt(value,message){return this.setLimit("min",value,!1,errorUtil.toString(message))}lte(value,message){return this.setLimit("max",value,!0,errorUtil.toString(message))}lt(value,message){return this.setLimit("max",value,!1,errorUtil.toString(message))}setLimit(kind,value,inclusive,message){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind,value,inclusive,message:errorUtil.toString(message)}]})}_addCheck(check){return new ZodNumber({...this._def,checks:[...this._def.checks,check]})}int(message){return this._addCheck({kind:"int",message:errorUtil.toString(message)})}positive(message){return this._addCheck({kind:"min",value:0,inclusive:!1,message:errorUtil.toString(message)})}negative(message){return this._addCheck({kind:"max",value:0,inclusive:!1,message:errorUtil.toString(message)})}nonpositive(message){return this._addCheck({kind:"max",value:0,inclusive:!0,message:errorUtil.toString(message)})}nonnegative(message){return this._addCheck({kind:"min",value:0,inclusive:!0,message:errorUtil.toString(message)})}multipleOf(value,message){return this._addCheck({kind:"multipleOf",value,message:errorUtil.toString(message)})}finite(message){return this._addCheck({kind:"finite",message:errorUtil.toString(message)})}safe(message){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:errorUtil.toString(message)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:errorUtil.toString(message)})}get minValue(){let min=null;for(let ch of this._def.checks)if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}return min}get maxValue(){let max=null;for(let ch of this._def.checks)if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return max}get isInt(){return!!this._def.checks.find((ch)=>ch.kind==="int"||ch.kind==="multipleOf"&&util.isInteger(ch.value))}get isFinite(){let max=null,min=null;for(let ch of this._def.checks)if(ch.kind==="finite"||ch.kind==="int"||ch.kind==="multipleOf")return!0;else if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}else if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return Number.isFinite(min)&&Number.isFinite(max)}};ZodNumber.create=(params)=>{return new ZodNumber({checks:[],typeName:ZodFirstPartyTypeKind.ZodNumber,coerce:params?.coerce||!1,...processCreateParams(params)})};ZodBigInt=class ZodBigInt extends ZodType{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(input){if(this._def.coerce)try{input.data=BigInt(input.data)}catch{return this._getInvalidInput(input)}if(this._getType(input)!==ZodParsedType.bigint)return this._getInvalidInput(input);let ctx=void 0,status=new ParseStatus;for(let check of this._def.checks)if(check.kind==="min"){if(check.inclusive?input.data<check.value:input.data<=check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_small,type:"bigint",minimum:check.value,inclusive:check.inclusive,message:check.message}),status.dirty()}else if(check.kind==="max"){if(check.inclusive?input.data>check.value:input.data>=check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_big,type:"bigint",maximum:check.value,inclusive:check.inclusive,message:check.message}),status.dirty()}else if(check.kind==="multipleOf"){if(input.data%check.value!==BigInt(0))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.not_multiple_of,multipleOf:check.value,message:check.message}),status.dirty()}else util.assertNever(check);return{status:status.value,value:input.data}}_getInvalidInput(input){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.bigint,received:ctx.parsedType}),INVALID}gte(value,message){return this.setLimit("min",value,!0,errorUtil.toString(message))}gt(value,message){return this.setLimit("min",value,!1,errorUtil.toString(message))}lte(value,message){return this.setLimit("max",value,!0,errorUtil.toString(message))}lt(value,message){return this.setLimit("max",value,!1,errorUtil.toString(message))}setLimit(kind,value,inclusive,message){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind,value,inclusive,message:errorUtil.toString(message)}]})}_addCheck(check){return new ZodBigInt({...this._def,checks:[...this._def.checks,check]})}positive(message){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:errorUtil.toString(message)})}negative(message){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:errorUtil.toString(message)})}nonpositive(message){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:errorUtil.toString(message)})}nonnegative(message){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:errorUtil.toString(message)})}multipleOf(value,message){return this._addCheck({kind:"multipleOf",value,message:errorUtil.toString(message)})}get minValue(){let min=null;for(let ch of this._def.checks)if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}return min}get maxValue(){let max=null;for(let ch of this._def.checks)if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return max}};ZodBigInt.create=(params)=>{return new ZodBigInt({checks:[],typeName:ZodFirstPartyTypeKind.ZodBigInt,coerce:params?.coerce??!1,...processCreateParams(params)})};ZodBoolean=class ZodBoolean extends ZodType{_parse(input){if(this._def.coerce)input.data=Boolean(input.data);if(this._getType(input)!==ZodParsedType.boolean){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.boolean,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodBoolean.create=(params)=>{return new ZodBoolean({typeName:ZodFirstPartyTypeKind.ZodBoolean,coerce:params?.coerce||!1,...processCreateParams(params)})};ZodDate=class ZodDate extends ZodType{_parse(input){if(this._def.coerce)input.data=new Date(input.data);if(this._getType(input)!==ZodParsedType.date){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.date,received:ctx2.parsedType}),INVALID}if(Number.isNaN(input.data.getTime())){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_date}),INVALID}let status=new ParseStatus,ctx=void 0;for(let check of this._def.checks)if(check.kind==="min"){if(input.data.getTime()<check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_small,message:check.message,inclusive:!0,exact:!1,minimum:check.value,type:"date"}),status.dirty()}else if(check.kind==="max"){if(input.data.getTime()>check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_big,message:check.message,inclusive:!0,exact:!1,maximum:check.value,type:"date"}),status.dirty()}else util.assertNever(check);return{status:status.value,value:new Date(input.data.getTime())}}_addCheck(check){return new ZodDate({...this._def,checks:[...this._def.checks,check]})}min(minDate,message){return this._addCheck({kind:"min",value:minDate.getTime(),message:errorUtil.toString(message)})}max(maxDate,message){return this._addCheck({kind:"max",value:maxDate.getTime(),message:errorUtil.toString(message)})}get minDate(){let min=null;for(let ch of this._def.checks)if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}return min!=null?new Date(min):null}get maxDate(){let max=null;for(let ch of this._def.checks)if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return max!=null?new Date(max):null}};ZodDate.create=(params)=>{return new ZodDate({checks:[],coerce:params?.coerce||!1,typeName:ZodFirstPartyTypeKind.ZodDate,...processCreateParams(params)})};ZodSymbol=class ZodSymbol extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.symbol){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.symbol,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodSymbol.create=(params)=>{return new ZodSymbol({typeName:ZodFirstPartyTypeKind.ZodSymbol,...processCreateParams(params)})};ZodUndefined=class ZodUndefined extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.undefined){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.undefined,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodUndefined.create=(params)=>{return new ZodUndefined({typeName:ZodFirstPartyTypeKind.ZodUndefined,...processCreateParams(params)})};ZodNull=class ZodNull extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.null){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.null,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodNull.create=(params)=>{return new ZodNull({typeName:ZodFirstPartyTypeKind.ZodNull,...processCreateParams(params)})};ZodAny=class ZodAny extends ZodType{constructor(){super(...arguments);this._any=!0}_parse(input){return OK(input.data)}};ZodAny.create=(params)=>{return new ZodAny({typeName:ZodFirstPartyTypeKind.ZodAny,...processCreateParams(params)})};ZodUnknown=class ZodUnknown extends ZodType{constructor(){super(...arguments);this._unknown=!0}_parse(input){return OK(input.data)}};ZodUnknown.create=(params)=>{return new ZodUnknown({typeName:ZodFirstPartyTypeKind.ZodUnknown,...processCreateParams(params)})};ZodNever=class ZodNever extends ZodType{_parse(input){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.never,received:ctx.parsedType}),INVALID}};ZodNever.create=(params)=>{return new ZodNever({typeName:ZodFirstPartyTypeKind.ZodNever,...processCreateParams(params)})};ZodVoid=class ZodVoid extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.undefined){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.void,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodVoid.create=(params)=>{return new ZodVoid({typeName:ZodFirstPartyTypeKind.ZodVoid,...processCreateParams(params)})};ZodArray=class ZodArray extends ZodType{_parse(input){let{ctx,status}=this._processInputParams(input),def=this._def;if(ctx.parsedType!==ZodParsedType.array)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:ctx.parsedType}),INVALID;if(def.exactLength!==null){let tooBig=ctx.data.length>def.exactLength.value,tooSmall=ctx.data.length<def.exactLength.value;if(tooBig||tooSmall)addIssueToContext(ctx,{code:tooBig?ZodIssueCode.too_big:ZodIssueCode.too_small,minimum:tooSmall?def.exactLength.value:void 0,maximum:tooBig?def.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:def.exactLength.message}),status.dirty()}if(def.minLength!==null){if(ctx.data.length<def.minLength.value)addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:def.minLength.value,type:"array",inclusive:!0,exact:!1,message:def.minLength.message}),status.dirty()}if(def.maxLength!==null){if(ctx.data.length>def.maxLength.value)addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:def.maxLength.value,type:"array",inclusive:!0,exact:!1,message:def.maxLength.message}),status.dirty()}if(ctx.common.async)return Promise.all([...ctx.data].map((item,i)=>{return def.type._parseAsync(new ParseInputLazyPath(ctx,item,ctx.path,i))})).then((result3)=>{return ParseStatus.mergeArray(status,result3)});let result2=[...ctx.data].map((item,i)=>{return def.type._parseSync(new ParseInputLazyPath(ctx,item,ctx.path,i))});return ParseStatus.mergeArray(status,result2)}get element(){return this._def.type}min(minLength,message){return new ZodArray({...this._def,minLength:{value:minLength,message:errorUtil.toString(message)}})}max(maxLength,message){return new ZodArray({...this._def,maxLength:{value:maxLength,message:errorUtil.toString(message)}})}length(len,message){return new ZodArray({...this._def,exactLength:{value:len,message:errorUtil.toString(message)}})}nonempty(message){return this.min(1,message)}};ZodArray.create=(schema,params)=>{return new ZodArray({type:schema,minLength:null,maxLength:null,exactLength:null,typeName:ZodFirstPartyTypeKind.ZodArray,...processCreateParams(params)})};ZodObject=class ZodObject extends ZodType{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let shape=this._def.shape(),keys=util.objectKeys(shape);return this._cached={shape,keys},this._cached}_parse(input){if(this._getType(input)!==ZodParsedType.object){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:ctx2.parsedType}),INVALID}let{status,ctx}=this._processInputParams(input),{shape,keys:shapeKeys}=this._getCached(),extraKeys=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip")){for(let key in ctx.data)if(!shapeKeys.includes(key))extraKeys.push(key)}let pairs=[];for(let key of shapeKeys){let keyValidator=shape[key],value=ctx.data[key];pairs.push({key:{status:"valid",value:key},value:keyValidator._parse(new ParseInputLazyPath(ctx,value,ctx.path,key)),alwaysSet:key in ctx.data})}if(this._def.catchall instanceof ZodNever){let unknownKeys=this._def.unknownKeys;if(unknownKeys==="passthrough")for(let key of extraKeys)pairs.push({key:{status:"valid",value:key},value:{status:"valid",value:ctx.data[key]}});else if(unknownKeys==="strict"){if(extraKeys.length>0)addIssueToContext(ctx,{code:ZodIssueCode.unrecognized_keys,keys:extraKeys}),status.dirty()}else if(unknownKeys==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let catchall=this._def.catchall;for(let key of extraKeys){let value=ctx.data[key];pairs.push({key:{status:"valid",value:key},value:catchall._parse(new ParseInputLazyPath(ctx,value,ctx.path,key)),alwaysSet:key in ctx.data})}}if(ctx.common.async)return Promise.resolve().then(async()=>{let syncPairs=[];for(let pair of pairs){let key=await pair.key,value=await pair.value;syncPairs.push({key,value,alwaysSet:pair.alwaysSet})}return syncPairs}).then((syncPairs)=>{return ParseStatus.mergeObjectSync(status,syncPairs)});else return ParseStatus.mergeObjectSync(status,pairs)}get shape(){return this._def.shape()}strict(message){return errorUtil.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...message!==void 0?{errorMap:(issue,ctx)=>{let defaultError=this._def.errorMap?.(issue,ctx).message??ctx.defaultError;if(issue.code==="unrecognized_keys")return{message:errorUtil.errToObj(message).message??defaultError};return{message:defaultError}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(augmentation){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...augmentation})})}merge(merging){return new ZodObject({unknownKeys:merging._def.unknownKeys,catchall:merging._def.catchall,shape:()=>({...this._def.shape(),...merging._def.shape()}),typeName:ZodFirstPartyTypeKind.ZodObject})}setKey(key,schema){return this.augment({[key]:schema})}catchall(index){return new ZodObject({...this._def,catchall:index})}pick(mask){let shape={};for(let key of util.objectKeys(mask))if(mask[key]&&this.shape[key])shape[key]=this.shape[key];return new ZodObject({...this._def,shape:()=>shape})}omit(mask){let shape={};for(let key of util.objectKeys(this.shape))if(!mask[key])shape[key]=this.shape[key];return new ZodObject({...this._def,shape:()=>shape})}deepPartial(){return deepPartialify(this)}partial(mask){let newShape={};for(let key of util.objectKeys(this.shape)){let fieldSchema=this.shape[key];if(mask&&!mask[key])newShape[key]=fieldSchema;else newShape[key]=fieldSchema.optional()}return new ZodObject({...this._def,shape:()=>newShape})}required(mask){let newShape={};for(let key of util.objectKeys(this.shape))if(mask&&!mask[key])newShape[key]=this.shape[key];else{let newField=this.shape[key];while(newField instanceof ZodOptional)newField=newField._def.innerType;newShape[key]=newField}return new ZodObject({...this._def,shape:()=>newShape})}keyof(){return createZodEnum(util.objectKeys(this.shape))}};ZodObject.create=(shape,params)=>{return new ZodObject({shape:()=>shape,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(params)})};ZodObject.strictCreate=(shape,params)=>{return new ZodObject({shape:()=>shape,unknownKeys:"strict",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(params)})};ZodObject.lazycreate=(shape,params)=>{return new ZodObject({shape,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(params)})};ZodUnion=class ZodUnion extends ZodType{_parse(input){let{ctx}=this._processInputParams(input),options=this._def.options;function handleResults(results){for(let result2 of results)if(result2.result.status==="valid")return result2.result;for(let result2 of results)if(result2.result.status==="dirty")return ctx.common.issues.push(...result2.ctx.common.issues),result2.result;let unionErrors=results.map((result2)=>new ZodError(result2.ctx.common.issues));return addIssueToContext(ctx,{code:ZodIssueCode.invalid_union,unionErrors}),INVALID}if(ctx.common.async)return Promise.all(options.map(async(option)=>{let childCtx={...ctx,common:{...ctx.common,issues:[]},parent:null};return{result:await option._parseAsync({data:ctx.data,path:ctx.path,parent:childCtx}),ctx:childCtx}})).then(handleResults);else{let dirty=void 0,issues=[];for(let option of options){let childCtx={...ctx,common:{...ctx.common,issues:[]},parent:null},result2=option._parseSync({data:ctx.data,path:ctx.path,parent:childCtx});if(result2.status==="valid")return result2;else if(result2.status==="dirty"&&!dirty)dirty={result:result2,ctx:childCtx};if(childCtx.common.issues.length)issues.push(childCtx.common.issues)}if(dirty)return ctx.common.issues.push(...dirty.ctx.common.issues),dirty.result;let unionErrors=issues.map((issues2)=>new ZodError(issues2));return addIssueToContext(ctx,{code:ZodIssueCode.invalid_union,unionErrors}),INVALID}}get options(){return this._def.options}};ZodUnion.create=(types,params)=>{return new ZodUnion({options:types,typeName:ZodFirstPartyTypeKind.ZodUnion,...processCreateParams(params)})};ZodDiscriminatedUnion=class ZodDiscriminatedUnion extends ZodType{_parse(input){let{ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.object)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:ctx.parsedType}),INVALID;let discriminator=this.discriminator,discriminatorValue=ctx.data[discriminator],option=this.optionsMap.get(discriminatorValue);if(!option)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[discriminator]}),INVALID;if(ctx.common.async)return option._parseAsync({data:ctx.data,path:ctx.path,parent:ctx});else return option._parseSync({data:ctx.data,path:ctx.path,parent:ctx})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(discriminator,options,params){let optionsMap=new Map;for(let type of options){let discriminatorValues=getDiscriminator(type.shape[discriminator]);if(!discriminatorValues.length)throw Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);for(let value of discriminatorValues){if(optionsMap.has(value))throw Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);optionsMap.set(value,type)}}return new ZodDiscriminatedUnion({typeName:ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator,options,optionsMap,...processCreateParams(params)})}};ZodIntersection=class ZodIntersection extends ZodType{_parse(input){let{status,ctx}=this._processInputParams(input),handleParsed=(parsedLeft,parsedRight)=>{if(isAborted(parsedLeft)||isAborted(parsedRight))return INVALID;let merged=mergeValues(parsedLeft.value,parsedRight.value);if(!merged.valid)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_intersection_types}),INVALID;if(isDirty(parsedLeft)||isDirty(parsedRight))status.dirty();return{status:status.value,value:merged.data}};if(ctx.common.async)return Promise.all([this._def.left._parseAsync({data:ctx.data,path:ctx.path,parent:ctx}),this._def.right._parseAsync({data:ctx.data,path:ctx.path,parent:ctx})]).then(([left,right])=>handleParsed(left,right));else return handleParsed(this._def.left._parseSync({data:ctx.data,path:ctx.path,parent:ctx}),this._def.right._parseSync({data:ctx.data,path:ctx.path,parent:ctx}))}};ZodIntersection.create=(left,right,params)=>{return new ZodIntersection({left,right,typeName:ZodFirstPartyTypeKind.ZodIntersection,...processCreateParams(params)})};ZodTuple=class ZodTuple extends ZodType{_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.array)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:ctx.parsedType}),INVALID;if(ctx.data.length<this._def.items.length)return addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),INVALID;if(!this._def.rest&&ctx.data.length>this._def.items.length)addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),status.dirty();let items=[...ctx.data].map((item,itemIndex)=>{let schema=this._def.items[itemIndex]||this._def.rest;if(!schema)return null;return schema._parse(new ParseInputLazyPath(ctx,item,ctx.path,itemIndex))}).filter((x)=>!!x);if(ctx.common.async)return Promise.all(items).then((results)=>{return ParseStatus.mergeArray(status,results)});else return ParseStatus.mergeArray(status,items)}get items(){return this._def.items}rest(rest){return new ZodTuple({...this._def,rest})}};ZodTuple.create=(schemas,params)=>{if(!Array.isArray(schemas))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:schemas,typeName:ZodFirstPartyTypeKind.ZodTuple,rest:null,...processCreateParams(params)})};ZodRecord=class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.object)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:ctx.parsedType}),INVALID;let pairs=[],keyType=this._def.keyType,valueType=this._def.valueType;for(let key in ctx.data)pairs.push({key:keyType._parse(new ParseInputLazyPath(ctx,key,ctx.path,key)),value:valueType._parse(new ParseInputLazyPath(ctx,ctx.data[key],ctx.path,key)),alwaysSet:key in ctx.data});if(ctx.common.async)return ParseStatus.mergeObjectAsync(status,pairs);else return ParseStatus.mergeObjectSync(status,pairs)}get element(){return this._def.valueType}static create(first,second,third){if(second instanceof ZodType)return new ZodRecord({keyType:first,valueType:second,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(third)});return new ZodRecord({keyType:ZodString.create(),valueType:first,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(second)})}};ZodMap=class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.map)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.map,received:ctx.parsedType}),INVALID;let keyType=this._def.keyType,valueType=this._def.valueType,pairs=[...ctx.data.entries()].map(([key,value],index)=>{return{key:keyType._parse(new ParseInputLazyPath(ctx,key,ctx.path,[index,"key"])),value:valueType._parse(new ParseInputLazyPath(ctx,value,ctx.path,[index,"value"]))}});if(ctx.common.async){let finalMap=new Map;return Promise.resolve().then(async()=>{for(let pair of pairs){let key=await pair.key,value=await pair.value;if(key.status==="aborted"||value.status==="aborted")return INVALID;if(key.status==="dirty"||value.status==="dirty")status.dirty();finalMap.set(key.value,value.value)}return{status:status.value,value:finalMap}})}else{let finalMap=new Map;for(let pair of pairs){let{key,value}=pair;if(key.status==="aborted"||value.status==="aborted")return INVALID;if(key.status==="dirty"||value.status==="dirty")status.dirty();finalMap.set(key.value,value.value)}return{status:status.value,value:finalMap}}}};ZodMap.create=(keyType,valueType,params)=>{return new ZodMap({valueType,keyType,typeName:ZodFirstPartyTypeKind.ZodMap,...processCreateParams(params)})};ZodSet=class ZodSet extends ZodType{_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.set)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.set,received:ctx.parsedType}),INVALID;let def=this._def;if(def.minSize!==null){if(ctx.data.size<def.minSize.value)addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:def.minSize.value,type:"set",inclusive:!0,exact:!1,message:def.minSize.message}),status.dirty()}if(def.maxSize!==null){if(ctx.data.size>def.maxSize.value)addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:def.maxSize.value,type:"set",inclusive:!0,exact:!1,message:def.maxSize.message}),status.dirty()}let valueType=this._def.valueType;function finalizeSet(elements2){let parsedSet=new Set;for(let element of elements2){if(element.status==="aborted")return INVALID;if(element.status==="dirty")status.dirty();parsedSet.add(element.value)}return{status:status.value,value:parsedSet}}let elements=[...ctx.data.values()].map((item,i)=>valueType._parse(new ParseInputLazyPath(ctx,item,ctx.path,i)));if(ctx.common.async)return Promise.all(elements).then((elements2)=>finalizeSet(elements2));else return finalizeSet(elements)}min(minSize,message){return new ZodSet({...this._def,minSize:{value:minSize,message:errorUtil.toString(message)}})}max(maxSize,message){return new ZodSet({...this._def,maxSize:{value:maxSize,message:errorUtil.toString(message)}})}size(size,message){return this.min(size,message).max(size,message)}nonempty(message){return this.min(1,message)}};ZodSet.create=(valueType,params)=>{return new ZodSet({valueType,minSize:null,maxSize:null,typeName:ZodFirstPartyTypeKind.ZodSet,...processCreateParams(params)})};ZodFunction=class ZodFunction extends ZodType{constructor(){super(...arguments);this.validate=this.implement}_parse(input){let{ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.function)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.function,received:ctx.parsedType}),INVALID;function makeArgsIssue(args,error){return makeIssue({data:args,path:ctx.path,errorMaps:[ctx.common.contextualErrorMap,ctx.schemaErrorMap,getErrorMap(),en_default].filter((x)=>!!x),issueData:{code:ZodIssueCode.invalid_arguments,argumentsError:error}})}function makeReturnsIssue(returns,error){return makeIssue({data:returns,path:ctx.path,errorMaps:[ctx.common.contextualErrorMap,ctx.schemaErrorMap,getErrorMap(),en_default].filter((x)=>!!x),issueData:{code:ZodIssueCode.invalid_return_type,returnTypeError:error}})}let params={errorMap:ctx.common.contextualErrorMap},fn=ctx.data;if(this._def.returns instanceof ZodPromise){let me=this;return OK(async function(...args){let error=new ZodError([]),parsedArgs=await me._def.args.parseAsync(args,params).catch((e)=>{throw error.addIssue(makeArgsIssue(args,e)),error}),result2=await Reflect.apply(fn,this,parsedArgs);return await me._def.returns._def.type.parseAsync(result2,params).catch((e)=>{throw error.addIssue(makeReturnsIssue(result2,e)),error})})}else{let me=this;return OK(function(...args){let parsedArgs=me._def.args.safeParse(args,params);if(!parsedArgs.success)throw new ZodError([makeArgsIssue(args,parsedArgs.error)]);let result2=Reflect.apply(fn,this,parsedArgs.data),parsedReturns=me._def.returns.safeParse(result2,params);if(!parsedReturns.success)throw new ZodError([makeReturnsIssue(result2,parsedReturns.error)]);return parsedReturns.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...items){return new ZodFunction({...this._def,args:ZodTuple.create(items).rest(ZodUnknown.create())})}returns(returnType){return new ZodFunction({...this._def,returns:returnType})}implement(func){return this.parse(func)}strictImplement(func){return this.parse(func)}static create(args,returns,params){return new ZodFunction({args:args?args:ZodTuple.create([]).rest(ZodUnknown.create()),returns:returns||ZodUnknown.create(),typeName:ZodFirstPartyTypeKind.ZodFunction,...processCreateParams(params)})}};ZodLazy=class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(input){let{ctx}=this._processInputParams(input);return this._def.getter()._parse({data:ctx.data,path:ctx.path,parent:ctx})}};ZodLazy.create=(getter,params)=>{return new ZodLazy({getter,typeName:ZodFirstPartyTypeKind.ZodLazy,...processCreateParams(params)})};ZodLiteral=class ZodLiteral extends ZodType{_parse(input){if(input.data!==this._def.value){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{received:ctx.data,code:ZodIssueCode.invalid_literal,expected:this._def.value}),INVALID}return{status:"valid",value:input.data}}get value(){return this._def.value}};ZodLiteral.create=(value,params)=>{return new ZodLiteral({value,typeName:ZodFirstPartyTypeKind.ZodLiteral,...processCreateParams(params)})};ZodEnum=class ZodEnum extends ZodType{_parse(input){if(typeof input.data!=="string"){let ctx=this._getOrReturnCtx(input),expectedValues=this._def.values;return addIssueToContext(ctx,{expected:util.joinValues(expectedValues),received:ctx.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(input.data)){let ctx=this._getOrReturnCtx(input),expectedValues=this._def.values;return addIssueToContext(ctx,{received:ctx.data,code:ZodIssueCode.invalid_enum_value,options:expectedValues}),INVALID}return OK(input.data)}get options(){return this._def.values}get enum(){let enumValues={};for(let val of this._def.values)enumValues[val]=val;return enumValues}get Values(){let enumValues={};for(let val of this._def.values)enumValues[val]=val;return enumValues}get Enum(){let enumValues={};for(let val of this._def.values)enumValues[val]=val;return enumValues}extract(values,newDef=this._def){return ZodEnum.create(values,{...this._def,...newDef})}exclude(values,newDef=this._def){return ZodEnum.create(this.options.filter((opt)=>!values.includes(opt)),{...this._def,...newDef})}};ZodEnum.create=createZodEnum;ZodNativeEnum=class ZodNativeEnum extends ZodType{_parse(input){let nativeEnumValues=util.getValidEnumValues(this._def.values),ctx=this._getOrReturnCtx(input);if(ctx.parsedType!==ZodParsedType.string&&ctx.parsedType!==ZodParsedType.number){let expectedValues=util.objectValues(nativeEnumValues);return addIssueToContext(ctx,{expected:util.joinValues(expectedValues),received:ctx.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(!this._cache)this._cache=new Set(util.getValidEnumValues(this._def.values));if(!this._cache.has(input.data)){let expectedValues=util.objectValues(nativeEnumValues);return addIssueToContext(ctx,{received:ctx.data,code:ZodIssueCode.invalid_enum_value,options:expectedValues}),INVALID}return OK(input.data)}get enum(){return this._def.values}};ZodNativeEnum.create=(values,params)=>{return new ZodNativeEnum({values,typeName:ZodFirstPartyTypeKind.ZodNativeEnum,...processCreateParams(params)})};ZodPromise=class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(input){let{ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.promise&&ctx.common.async===!1)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.promise,received:ctx.parsedType}),INVALID;let promisified=ctx.parsedType===ZodParsedType.promise?ctx.data:Promise.resolve(ctx.data);return OK(promisified.then((data)=>{return this._def.type.parseAsync(data,{path:ctx.path,errorMap:ctx.common.contextualErrorMap})}))}};ZodPromise.create=(schema,params)=>{return new ZodPromise({type:schema,typeName:ZodFirstPartyTypeKind.ZodPromise,...processCreateParams(params)})};ZodEffects=class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ZodFirstPartyTypeKind.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(input){let{status,ctx}=this._processInputParams(input),effect=this._def.effect||null,checkCtx={addIssue:(arg)=>{if(addIssueToContext(ctx,arg),arg.fatal)status.abort();else status.dirty()},get path(){return ctx.path}};if(checkCtx.addIssue=checkCtx.addIssue.bind(checkCtx),effect.type==="preprocess"){let processed=effect.transform(ctx.data,checkCtx);if(ctx.common.async)return Promise.resolve(processed).then(async(processed2)=>{if(status.value==="aborted")return INVALID;let result2=await this._def.schema._parseAsync({data:processed2,path:ctx.path,parent:ctx});if(result2.status==="aborted")return INVALID;if(result2.status==="dirty")return DIRTY(result2.value);if(status.value==="dirty")return DIRTY(result2.value);return result2});else{if(status.value==="aborted")return INVALID;let result2=this._def.schema._parseSync({data:processed,path:ctx.path,parent:ctx});if(result2.status==="aborted")return INVALID;if(result2.status==="dirty")return DIRTY(result2.value);if(status.value==="dirty")return DIRTY(result2.value);return result2}}if(effect.type==="refinement"){let executeRefinement=(acc)=>{let result2=effect.refinement(acc,checkCtx);if(ctx.common.async)return Promise.resolve(result2);if(result2 instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return acc};if(ctx.common.async===!1){let inner=this._def.schema._parseSync({data:ctx.data,path:ctx.path,parent:ctx});if(inner.status==="aborted")return INVALID;if(inner.status==="dirty")status.dirty();return executeRefinement(inner.value),{status:status.value,value:inner.value}}else return this._def.schema._parseAsync({data:ctx.data,path:ctx.path,parent:ctx}).then((inner)=>{if(inner.status==="aborted")return INVALID;if(inner.status==="dirty")status.dirty();return executeRefinement(inner.value).then(()=>{return{status:status.value,value:inner.value}})})}if(effect.type==="transform")if(ctx.common.async===!1){let base=this._def.schema._parseSync({data:ctx.data,path:ctx.path,parent:ctx});if(!isValid(base))return INVALID;let result2=effect.transform(base.value,checkCtx);if(result2 instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:status.value,value:result2}}else return this._def.schema._parseAsync({data:ctx.data,path:ctx.path,parent:ctx}).then((base)=>{if(!isValid(base))return INVALID;return Promise.resolve(effect.transform(base.value,checkCtx)).then((result2)=>({status:status.value,value:result2}))});util.assertNever(effect)}};ZodEffects.create=(schema,effect,params)=>{return new ZodEffects({schema,typeName:ZodFirstPartyTypeKind.ZodEffects,effect,...processCreateParams(params)})};ZodEffects.createWithPreprocess=(preprocess,schema,params)=>{return new ZodEffects({schema,effect:{type:"preprocess",transform:preprocess},typeName:ZodFirstPartyTypeKind.ZodEffects,...processCreateParams(params)})};ZodOptional=class ZodOptional extends ZodType{_parse(input){if(this._getType(input)===ZodParsedType.undefined)return OK(void 0);return this._def.innerType._parse(input)}unwrap(){return this._def.innerType}};ZodOptional.create=(type,params)=>{return new ZodOptional({innerType:type,typeName:ZodFirstPartyTypeKind.ZodOptional,...processCreateParams(params)})};ZodNullable=class ZodNullable extends ZodType{_parse(input){if(this._getType(input)===ZodParsedType.null)return OK(null);return this._def.innerType._parse(input)}unwrap(){return this._def.innerType}};ZodNullable.create=(type,params)=>{return new ZodNullable({innerType:type,typeName:ZodFirstPartyTypeKind.ZodNullable,...processCreateParams(params)})};ZodDefault=class ZodDefault extends ZodType{_parse(input){let{ctx}=this._processInputParams(input),data=ctx.data;if(ctx.parsedType===ZodParsedType.undefined)data=this._def.defaultValue();return this._def.innerType._parse({data,path:ctx.path,parent:ctx})}removeDefault(){return this._def.innerType}};ZodDefault.create=(type,params)=>{return new ZodDefault({innerType:type,typeName:ZodFirstPartyTypeKind.ZodDefault,defaultValue:typeof params.default==="function"?params.default:()=>params.default,...processCreateParams(params)})};ZodCatch=class ZodCatch extends ZodType{_parse(input){let{ctx}=this._processInputParams(input),newCtx={...ctx,common:{...ctx.common,issues:[]}},result2=this._def.innerType._parse({data:newCtx.data,path:newCtx.path,parent:{...newCtx}});if(isAsync(result2))return result2.then((result3)=>{return{status:"valid",value:result3.status==="valid"?result3.value:this._def.catchValue({get error(){return new ZodError(newCtx.common.issues)},input:newCtx.data})}});else return{status:"valid",value:result2.status==="valid"?result2.value:this._def.catchValue({get error(){return new ZodError(newCtx.common.issues)},input:newCtx.data})}}removeCatch(){return this._def.innerType}};ZodCatch.create=(type,params)=>{return new ZodCatch({innerType:type,typeName:ZodFirstPartyTypeKind.ZodCatch,catchValue:typeof params.catch==="function"?params.catch:()=>params.catch,...processCreateParams(params)})};ZodNaN=class ZodNaN extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.nan){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.nan,received:ctx.parsedType}),INVALID}return{status:"valid",value:input.data}}};ZodNaN.create=(params)=>{return new ZodNaN({typeName:ZodFirstPartyTypeKind.ZodNaN,...processCreateParams(params)})};BRAND=Symbol("zod_brand");ZodBranded=class ZodBranded extends ZodType{_parse(input){let{ctx}=this._processInputParams(input),data=ctx.data;return this._def.type._parse({data,path:ctx.path,parent:ctx})}unwrap(){return this._def.type}};ZodPipeline=class ZodPipeline extends ZodType{_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.common.async)return(async()=>{let inResult=await this._def.in._parseAsync({data:ctx.data,path:ctx.path,parent:ctx});if(inResult.status==="aborted")return INVALID;if(inResult.status==="dirty")return status.dirty(),DIRTY(inResult.value);else return this._def.out._parseAsync({data:inResult.value,path:ctx.path,parent:ctx})})();else{let inResult=this._def.in._parseSync({data:ctx.data,path:ctx.path,parent:ctx});if(inResult.status==="aborted")return INVALID;if(inResult.status==="dirty")return status.dirty(),{status:"dirty",value:inResult.value};else return this._def.out._parseSync({data:inResult.value,path:ctx.path,parent:ctx})}}static create(a,b){return new ZodPipeline({in:a,out:b,typeName:ZodFirstPartyTypeKind.ZodPipeline})}};ZodReadonly=class ZodReadonly extends ZodType{_parse(input){let result2=this._def.innerType._parse(input),freeze=(data)=>{if(isValid(data))data.value=Object.freeze(data.value);return data};return isAsync(result2)?result2.then((data)=>freeze(data)):freeze(result2)}unwrap(){return this._def.innerType}};ZodReadonly.create=(type,params)=>{return new ZodReadonly({innerType:type,typeName:ZodFirstPartyTypeKind.ZodReadonly,...processCreateParams(params)})};late={object:ZodObject.lazycreate};(function(ZodFirstPartyTypeKind2){ZodFirstPartyTypeKind2.ZodString="ZodString",ZodFirstPartyTypeKind2.ZodNumber="ZodNumber",ZodFirstPartyTypeKind2.ZodNaN="ZodNaN",ZodFirstPartyTypeKind2.ZodBigInt="ZodBigInt",ZodFirstPartyTypeKind2.ZodBoolean="ZodBoolean",ZodFirstPartyTypeKind2.ZodDate="ZodDate",ZodFirstPartyTypeKind2.ZodSymbol="ZodSymbol",ZodFirstPartyTypeKind2.ZodUndefined="ZodUndefined",ZodFirstPartyTypeKind2.ZodNull="ZodNull",ZodFirstPartyTypeKind2.ZodAny="ZodAny",ZodFirstPartyTypeKind2.ZodUnknown="ZodUnknown",ZodFirstPartyTypeKind2.ZodNever="ZodNever",ZodFirstPartyTypeKind2.ZodVoid="ZodVoid",ZodFirstPartyTypeKind2.ZodArray="ZodArray",ZodFirstPartyTypeKind2.ZodObject="ZodObject",ZodFirstPartyTypeKind2.ZodUnion="ZodUnion",ZodFirstPartyTypeKind2.ZodDiscriminatedUnion="ZodDiscriminatedUnion",ZodFirstPartyTypeKind2.ZodIntersection="ZodIntersection",ZodFirstPartyTypeKind2.ZodTuple="ZodTuple",ZodFirstPartyTypeKind2.ZodRecord="ZodRecord",ZodFirstPartyTypeKind2.ZodMap="ZodMap",ZodFirstPartyTypeKind2.ZodSet="ZodSet",ZodFirstPartyTypeKind2.ZodFunction="ZodFunction",ZodFirstPartyTypeKind2.ZodLazy="ZodLazy",ZodFirstPartyTypeKind2.ZodLiteral="ZodLiteral",ZodFirstPartyTypeKind2.ZodEnum="ZodEnum",ZodFirstPartyTypeKind2.ZodEffects="ZodEffects",ZodFirstPartyTypeKind2.ZodNativeEnum="ZodNativeEnum",ZodFirstPartyTypeKind2.ZodOptional="ZodOptional",ZodFirstPartyTypeKind2.ZodNullable="ZodNullable",ZodFirstPartyTypeKind2.ZodDefault="ZodDefault",ZodFirstPartyTypeKind2.ZodCatch="ZodCatch",ZodFirstPartyTypeKind2.ZodPromise="ZodPromise",ZodFirstPartyTypeKind2.ZodBranded="ZodBranded",ZodFirstPartyTypeKind2.ZodPipeline="ZodPipeline",ZodFirstPartyTypeKind2.ZodReadonly="ZodReadonly"})(ZodFirstPartyTypeKind||(ZodFirstPartyTypeKind={}));stringType=ZodString.create,numberType=ZodNumber.create,nanType=ZodNaN.create,bigIntType=ZodBigInt.create,booleanType=ZodBoolean.create,dateType=ZodDate.create,symbolType=ZodSymbol.create,undefinedType=ZodUndefined.create,nullType=ZodNull.create,anyType=ZodAny.create,unknownType=ZodUnknown.create,neverType=ZodNever.create,voidType=ZodVoid.create,arrayType=ZodArray.create,objectType=ZodObject.create,strictObjectType=ZodObject.strictCreate,unionType=ZodUnion.create,discriminatedUnionType=ZodDiscriminatedUnion.create,intersectionType=ZodIntersection.create,tupleType=ZodTuple.create,recordType=ZodRecord.create,mapType=ZodMap.create,setType=ZodSet.create,functionType=ZodFunction.create,lazyType=ZodLazy.create,literalType=ZodLiteral.create,enumType=ZodEnum.create,nativeEnumType=ZodNativeEnum.create,promiseType=ZodPromise.create,effectsType=ZodEffects.create,optionalType=ZodOptional.create,nullableType=ZodNullable.create,preprocessType=ZodEffects.createWithPreprocess,pipelineType=ZodPipeline.create,coerce={string:(arg)=>ZodString.create({...arg,coerce:!0}),number:(arg)=>ZodNumber.create({...arg,coerce:!0}),boolean:(arg)=>ZodBoolean.create({...arg,coerce:!0}),bigint:(arg)=>ZodBigInt.create({...arg,coerce:!0}),date:(arg)=>ZodDate.create({...arg,coerce:!0})},NEVER=INVALID});var exports_external={};__export(exports_external,{void:()=>voidType,util:()=>util,unknown:()=>unknownType,union:()=>unionType,undefined:()=>undefinedType,tuple:()=>tupleType,transformer:()=>effectsType,symbol:()=>symbolType,string:()=>stringType,strictObject:()=>strictObjectType,setErrorMap:()=>setErrorMap,set:()=>setType,record:()=>recordType,quotelessJson:()=>quotelessJson,promise:()=>promiseType,preprocess:()=>preprocessType,pipeline:()=>pipelineType,ostring:()=>ostring,optional:()=>optionalType,onumber:()=>onumber,oboolean:()=>oboolean,objectUtil:()=>objectUtil,object:()=>objectType,number:()=>numberType,nullable:()=>nullableType,null:()=>nullType,never:()=>neverType,nativeEnum:()=>nativeEnumType,nan:()=>nanType,map:()=>mapType,makeIssue:()=>makeIssue,literal:()=>literalType,lazy:()=>lazyType,late:()=>late,isValid:()=>isValid,isDirty:()=>isDirty,isAsync:()=>isAsync,isAborted:()=>isAborted,intersection:()=>intersectionType,instanceof:()=>instanceOfType,getParsedType:()=>getParsedType,getErrorMap:()=>getErrorMap,function:()=>functionType,enum:()=>enumType,effect:()=>effectsType,discriminatedUnion:()=>discriminatedUnionType,defaultErrorMap:()=>en_default,datetimeRegex:()=>datetimeRegex,date:()=>dateType,custom:()=>custom,coerce:()=>coerce,boolean:()=>booleanType,bigint:()=>bigIntType,array:()=>arrayType,any:()=>anyType,addIssueToContext:()=>addIssueToContext,ZodVoid:()=>ZodVoid,ZodUnknown:()=>ZodUnknown,ZodUnion:()=>ZodUnion,ZodUndefined:()=>ZodUndefined,ZodType:()=>ZodType,ZodTuple:()=>ZodTuple,ZodTransformer:()=>ZodEffects,ZodSymbol:()=>ZodSymbol,ZodString:()=>ZodString,ZodSet:()=>ZodSet,ZodSchema:()=>ZodType,ZodRecord:()=>ZodRecord,ZodReadonly:()=>ZodReadonly,ZodPromise:()=>ZodPromise,ZodPipeline:()=>ZodPipeline,ZodParsedType:()=>ZodParsedType,ZodOptional:()=>ZodOptional,ZodObject:()=>ZodObject,ZodNumber:()=>ZodNumber,ZodNullable:()=>ZodNullable,ZodNull:()=>ZodNull,ZodNever:()=>ZodNever,ZodNativeEnum:()=>ZodNativeEnum,ZodNaN:()=>ZodNaN,ZodMap:()=>ZodMap,ZodLiteral:()=>ZodLiteral,ZodLazy:()=>ZodLazy,ZodIssueCode:()=>ZodIssueCode,ZodIntersection:()=>ZodIntersection,ZodFunction:()=>ZodFunction,ZodFirstPartyTypeKind:()=>ZodFirstPartyTypeKind,ZodError:()=>ZodError,ZodEnum:()=>ZodEnum,ZodEffects:()=>ZodEffects,ZodDiscriminatedUnion:()=>ZodDiscriminatedUnion,ZodDefault:()=>ZodDefault,ZodDate:()=>ZodDate,ZodCatch:()=>ZodCatch,ZodBranded:()=>ZodBranded,ZodBoolean:()=>ZodBoolean,ZodBigInt:()=>ZodBigInt,ZodArray:()=>ZodArray,ZodAny:()=>ZodAny,Schema:()=>ZodType,ParseStatus:()=>ParseStatus,OK:()=>OK,NEVER:()=>NEVER,INVALID:()=>INVALID,EMPTY_PATH:()=>EMPTY_PATH,DIRTY:()=>DIRTY,BRAND:()=>BRAND});var init_external=__esm(()=>{init_errors();init_parseUtil();init_typeAliases();init_util();init_types();init_ZodError()});var init_zod=__esm(()=>{init_external();init_external()});var exports_types={};__export(exports_types,{isBlockingEvent:()=>isBlockingEvent,DISPATCHED_EVENT_MATCHERS:()=>DISPATCHED_EVENT_MATCHERS,DISPATCHED_EVENTS:()=>DISPATCHED_EVENTS,CODEX_DISPATCHED_EVENT_MATCHERS:()=>CODEX_DISPATCHED_EVENT_MATCHERS});function isBlockingEvent(event){return BLOCKING_EVENTS.has(event)}var DISPATCHED_EVENT_MATCHERS,CODEX_DISPATCHED_EVENT_MATCHERS,DISPATCHED_EVENTS,BLOCKING_EVENTS;var init_types2=__esm(()=>{DISPATCHED_EVENT_MATCHERS={PreToolUse:"*",PostToolUse:"SendMessage"},CODEX_DISPATCHED_EVENT_MATCHERS={PreToolUse:"*",PostToolUse:"SendMessage",UserPromptSubmit:"*",Stop:"*"},DISPATCHED_EVENTS=Object.keys(DISPATCHED_EVENT_MATCHERS),BLOCKING_EVENTS=new Set(["PreToolUse","UserPromptSubmit","TeammateIdle","TaskCompleted","PermissionRequest"])});var exports_inject={};__export(exports_inject,{isTeamHooked:()=>isTeamHooked,injectTeamHooks:()=>injectTeamHooks,buildDispatchCommand:()=>buildDispatchCommand});import{existsSync as existsSync2}from"fs";import{mkdir,readFile as readFile2,writeFile as writeFile2}from"fs/promises";import{homedir as homedir2}from"os";import{join as join3}from"path";import{fileURLToPath}from"url";function escapeShellArg(arg){return`'${arg.replace(/'/g,"'\\''")}'`}function compiledBinaryCandidates(){let candidates=[];if(process.env.GENIE_HOOK_BIN)candidates.push(process.env.GENIE_HOOK_BIN);let home=process.env.GENIE_HOME??join3(homedir2(),".genie");candidates.push(join3(home,"bin","genie-hook"));try{let repoBin=fileURLToPath(new URL("../../dist/genie-hook",import.meta.url));candidates.push(repoBin)}catch{}return candidates}function buildDispatchCommand(){for(let candidate of compiledBinaryCandidates())if(existsSync2(candidate))return escapeShellArg(candidate);let entrypoint=fileURLToPath(new URL("../genie.ts",import.meta.url));if(!existsSync2(entrypoint))return"genie hook dispatch";let bun=process.execPath||"bun";return`${escapeShellArg(bun)} run ${escapeShellArg(entrypoint)} hook dispatch`}function isGenieDispatchCommand(command){return typeof command==="string"&&/(?:^|\s)hook\s+dispatch(?:\s|$)/.test(command)}function claudeConfigDir(){return process.env.CLAUDE_CONFIG_DIR??join3(homedir2(),".claude")}function teamSettingsPath(teamName){let sanitized=teamName.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase();return join3(claudeConfigDir(),"teams",sanitized,"settings.json")}function buildHooksConfig(){let hooks={},dispatchCommand=buildDispatchCommand();for(let[event,matcher]of Object.entries(DISPATCHED_EVENT_MATCHERS))hooks[event]=[{matcher,hooks:[{type:"command",command:dispatchCommand,timeout:DISPATCH_TIMEOUT}]}];return hooks}async function readSettings(settingsPath){if(!existsSync2(settingsPath))return{};try{return JSON.parse(await readFile2(settingsPath,"utf-8"))}catch{return{}}}function allEventsAlreadyInjected(existingHooks,hooksConfig){return DISPATCHED_EVENTS.every((event)=>{let existing=existingHooks[event],desiredCommand=hooksConfig[event][0].hooks[0].command,desiredMatcher=hooksConfig[event][0].matcher;return existing?.some((m)=>m.matcher===desiredMatcher&&m.hooks?.some((h)=>h.command===desiredCommand))})}function hasNoObsoleteGenieEntries(existingHooks){return Object.keys(existingHooks).every((event)=>{if(DISPATCHED_EVENTS.includes(event))return!0;return!existingHooks[event]?.some((m)=>m.hooks?.some((h)=>isGenieDispatchCommand(h.command)))})}function pruneObsoleteGenieEntries(mergedHooks){for(let event of Object.keys(mergedHooks)){if(DISPATCHED_EVENTS.includes(event))continue;let cleaned=(mergedHooks[event]??[]).map((matcher)=>({...matcher,hooks:matcher.hooks?.filter((hook)=>!isGenieDispatchCommand(hook.command))})).filter((matcher)=>(matcher.hooks?.length??0)>0);if(cleaned.length===0)delete mergedHooks[event];else mergedHooks[event]=cleaned}}function refreshMatcherEntries(entries,genieEntry){return entries.map((matcher)=>{let hasGenieHook=matcher.hooks?.some((h)=>isGenieDispatchCommand(h.command));return{...matcher,matcher:hasGenieHook?genieEntry.matcher:matcher.matcher,hooks:matcher.hooks?.map((hook)=>isGenieDispatchCommand(hook.command)?{...hook,command:genieEntry.hooks[0].command,timeout:DISPATCH_TIMEOUT}:hook)}})}function upsertGenieEntry(mergedHooks,event,genieEntry){let existingEntries=refreshMatcherEntries(mergedHooks[event]??[],genieEntry),alreadyPresent=existingEntries.some((m)=>m.hooks?.some((h)=>isGenieDispatchCommand(h.command)));mergedHooks[event]=alreadyPresent?existingEntries:[...existingEntries,genieEntry]}async function injectIntoFile(settingsPath){let settings=await readSettings(settingsPath),hooksConfig=buildHooksConfig(),existingHooks=settings.hooks;if(existingHooks&&allEventsAlreadyInjected(existingHooks,hooksConfig)&&hasNoObsoleteGenieEntries(existingHooks))return!1;let mergedHooks=existingHooks?{...existingHooks}:{};pruneObsoleteGenieEntries(mergedHooks);for(let event of DISPATCHED_EVENTS)upsertGenieEntry(mergedHooks,event,hooksConfig[event][0]);settings.hooks=mergedHooks;let dir=join3(settingsPath,"..");return await mkdir(dir,{recursive:!0}),await writeFile2(settingsPath,JSON.stringify(settings,null,2)),!0}async function injectTeamHooks(teamName){let path=teamSettingsPath(teamName);return injectIntoFile(path)}async function isTeamHooked(teamName){let path=teamSettingsPath(teamName);if(!existsSync2(path))return!1;try{let content=await readFile2(path,"utf-8"),hooks=JSON.parse(content).hooks;if(!hooks)return!1;return DISPATCHED_EVENTS.every((event)=>{return hooks[event]?.some((m)=>m.hooks?.some((h)=>isGenieDispatchCommand(h.command)))})}catch{return!1}}var DISPATCH_TIMEOUT=15;var init_inject=__esm(()=>{init_types2()});function normalizeValue(v){if(v===void 0||v===null)return;if(v==="")return;if(v==="inherit")return;return v}function resolveField(agent,field,ctx){return resolveFieldWithSource(agent,field,ctx).value}function resolveFieldWithSource(agent,field,ctx){let agentVal=normalizeValue(agent[field]);if(agentVal!==void 0)return{value:agentVal,source:"explicit"};if(ctx.parent){let parentVal=normalizeValue(ctx.parent.fields[field]);if(parentVal!==void 0)return{value:parentVal,source:`parent:${ctx.parent.name}`}}if(ctx.workspaceDefaults){let wsVal=normalizeValue(ctx.workspaceDefaults[field]);if(wsVal!==void 0)return{value:wsVal,source:"workspace"}}return{value:BUILTIN_DEFAULTS[field],source:"built-in"}}function computeEffectiveDefaults(workspaceDefaults){if(!workspaceDefaults)return{...BUILTIN_DEFAULTS};let result2={...BUILTIN_DEFAULTS};for(let key of Object.keys(BUILTIN_DEFAULTS)){let wsVal=normalizeValue(workspaceDefaults[key]);if(wsVal!==void 0)result2[key]=wsVal}return result2}var BUILTIN_DEFAULTS,RESOLVED_FIELDS;var init_defaults=__esm(()=>{BUILTIN_DEFAULTS={model:"opus",promptMode:"append",color:"blue",effort:"high",thinking:"enabled",permissionMode:"auto"},RESOLVED_FIELDS=["model"]});var exports_js_yaml={};__export(exports_js_yaml,{types:()=>types2,safeLoadAll:()=>safeLoadAll,safeLoad:()=>safeLoad,safeDump:()=>safeDump,loadAll:()=>loadAll,load:()=>load,dump:()=>dump,default:()=>jsYaml,YAMLException:()=>YAMLException,Type:()=>Type,Schema:()=>Schema,JSON_SCHEMA:()=>JSON_SCHEMA,FAILSAFE_SCHEMA:()=>FAILSAFE_SCHEMA,DEFAULT_SCHEMA:()=>DEFAULT_SCHEMA,CORE_SCHEMA:()=>CORE_SCHEMA});function isNothing(subject){return typeof subject>"u"||subject===null}function isObject(subject){return typeof subject==="object"&&subject!==null}function toArray(sequence){if(Array.isArray(sequence))return sequence;else if(isNothing(sequence))return[];return[sequence]}function extend(target,source){var index,length,key,sourceKeys;if(source){sourceKeys=Object.keys(source);for(index=0,length=sourceKeys.length;index<length;index+=1)key=sourceKeys[index],target[key]=source[key]}return target}function repeat(string,count){var result2="",cycle;for(cycle=0;cycle<count;cycle+=1)result2+=string;return result2}function isNegativeZero(number){return number===0&&Number.NEGATIVE_INFINITY===1/number}function formatError(exception,compact){var where="",message=exception.reason||"(unknown reason)";if(!exception.mark)return message;if(exception.mark.name)where+='in "'+exception.mark.name+'" ';if(where+="("+(exception.mark.line+1)+":"+(exception.mark.column+1)+")",!compact&&exception.mark.snippet)where+=`
151
+ WHERE created_at >= $1::timestamptz`,[sinceTs]))[0]??{};return{agents_spawned:r.agents_spawned??0,tasks_moved:r.tasks_moved??0,total_cost:r.total_cost??0,error_count:r.error_count??0,total_events:r.total_events??0,tool_calls:r.tool_calls??0,api_requests:r.api_requests??0}}function generateTraceId(){return crypto.randomUUID()}var DEFAULT_TIMELINE_LIMIT=200,MAX_TIMELINE_LIMIT=2000,DEFAULT_TIMELINE_SINCE_MS=86400000;var init_audit=__esm(()=>{init_db()});import{readFile,unlink,writeFile}from"fs/promises";function lockPath(filePath){return`${filePath}.lock`}function isPidAlive(pid){try{return process.kill(pid,0),!0}catch{return!1}}async function acquireLock(path){let lock=lockPath(path),deadline=Date.now()+LOCK_TIMEOUT_MS;while(Date.now()<deadline)try{await writeFile(lock,String(process.pid),{flag:"wx"});return}catch{try{let content=await readFile(lock,"utf-8"),holderPid=Number.parseInt(content.trim(),10);if(!Number.isNaN(holderPid)&&!isPidAlive(holderPid)){try{await unlink(lock)}catch{}continue}}catch{continue}let jitter=Math.floor(Math.random()*LOCK_POLL_MS);await new Promise((r)=>setTimeout(r,LOCK_POLL_MS+jitter))}console.warn(`[lockfile] Force-acquiring stale lock: ${lock}`),await writeFile(lock,String(process.pid))}async function releaseLock(path){try{await unlink(lockPath(path))}catch{}}var LOCK_TIMEOUT_MS=5000,LOCK_POLL_MS=50;var init_lockfile=()=>{};var util,objectUtil,ZodParsedType,getParsedType=(data)=>{switch(typeof data){case"undefined":return ZodParsedType.undefined;case"string":return ZodParsedType.string;case"number":return Number.isNaN(data)?ZodParsedType.nan:ZodParsedType.number;case"boolean":return ZodParsedType.boolean;case"function":return ZodParsedType.function;case"bigint":return ZodParsedType.bigint;case"symbol":return ZodParsedType.symbol;case"object":if(Array.isArray(data))return ZodParsedType.array;if(data===null)return ZodParsedType.null;if(data.then&&typeof data.then==="function"&&data.catch&&typeof data.catch==="function")return ZodParsedType.promise;if(typeof Map<"u"&&data instanceof Map)return ZodParsedType.map;if(typeof Set<"u"&&data instanceof Set)return ZodParsedType.set;if(typeof Date<"u"&&data instanceof Date)return ZodParsedType.date;return ZodParsedType.object;default:return ZodParsedType.unknown}};var init_util=__esm(()=>{(function(util2){util2.assertEqual=(_)=>{};function assertIs(_arg){}util2.assertIs=assertIs;function assertNever(_x){throw Error()}util2.assertNever=assertNever,util2.arrayToEnum=(items)=>{let obj={};for(let item of items)obj[item]=item;return obj},util2.getValidEnumValues=(obj)=>{let validKeys=util2.objectKeys(obj).filter((k)=>typeof obj[obj[k]]!=="number"),filtered={};for(let k of validKeys)filtered[k]=obj[k];return util2.objectValues(filtered)},util2.objectValues=(obj)=>{return util2.objectKeys(obj).map(function(e){return obj[e]})},util2.objectKeys=typeof Object.keys==="function"?(obj)=>Object.keys(obj):(object)=>{let keys=[];for(let key in object)if(Object.prototype.hasOwnProperty.call(object,key))keys.push(key);return keys},util2.find=(arr,checker)=>{for(let item of arr)if(checker(item))return item;return},util2.isInteger=typeof Number.isInteger==="function"?(val)=>Number.isInteger(val):(val)=>typeof val==="number"&&Number.isFinite(val)&&Math.floor(val)===val;function joinValues(array,separator=" | "){return array.map((val)=>typeof val==="string"?`'${val}'`:val).join(separator)}util2.joinValues=joinValues,util2.jsonStringifyReplacer=(_,value)=>{if(typeof value==="bigint")return value.toString();return value}})(util||(util={}));(function(objectUtil2){objectUtil2.mergeShapes=(first,second)=>{return{...first,...second}}})(objectUtil||(objectUtil={}));ZodParsedType=util.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var ZodIssueCode,quotelessJson=(obj)=>{return JSON.stringify(obj,null,2).replace(/"([^"]+)":/g,"$1:")},ZodError;var init_ZodError=__esm(()=>{init_util();ZodIssueCode=util.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"]);ZodError=class ZodError extends Error{get errors(){return this.issues}constructor(issues){super();this.issues=[],this.addIssue=(sub)=>{this.issues=[...this.issues,sub]},this.addIssues=(subs=[])=>{this.issues=[...this.issues,...subs]};let actualProto=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,actualProto);else this.__proto__=actualProto;this.name="ZodError",this.issues=issues}format(_mapper){let mapper=_mapper||function(issue){return issue.message},fieldErrors={_errors:[]},processError=(error)=>{for(let issue of error.issues)if(issue.code==="invalid_union")issue.unionErrors.map(processError);else if(issue.code==="invalid_return_type")processError(issue.returnTypeError);else if(issue.code==="invalid_arguments")processError(issue.argumentsError);else if(issue.path.length===0)fieldErrors._errors.push(mapper(issue));else{let curr=fieldErrors,i=0;while(i<issue.path.length){let el=issue.path[i];if(i!==issue.path.length-1)curr[el]=curr[el]||{_errors:[]};else curr[el]=curr[el]||{_errors:[]},curr[el]._errors.push(mapper(issue));curr=curr[el],i++}}};return processError(this),fieldErrors}static assert(value){if(!(value instanceof ZodError))throw Error(`Not a ZodError: ${value}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(mapper=(issue)=>issue.message){let fieldErrors={},formErrors=[];for(let sub of this.issues)if(sub.path.length>0){let firstEl=sub.path[0];fieldErrors[firstEl]=fieldErrors[firstEl]||[],fieldErrors[firstEl].push(mapper(sub))}else formErrors.push(mapper(sub));return{formErrors,fieldErrors}}get formErrors(){return this.flatten()}};ZodError.create=(issues)=>{return new ZodError(issues)}});var errorMap=(issue,_ctx)=>{let message;switch(issue.code){case ZodIssueCode.invalid_type:if(issue.received===ZodParsedType.undefined)message="Required";else message=`Expected ${issue.expected}, received ${issue.received}`;break;case ZodIssueCode.invalid_literal:message=`Invalid literal value, expected ${JSON.stringify(issue.expected,util.jsonStringifyReplacer)}`;break;case ZodIssueCode.unrecognized_keys:message=`Unrecognized key(s) in object: ${util.joinValues(issue.keys,", ")}`;break;case ZodIssueCode.invalid_union:message="Invalid input";break;case ZodIssueCode.invalid_union_discriminator:message=`Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;break;case ZodIssueCode.invalid_enum_value:message=`Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;break;case ZodIssueCode.invalid_arguments:message="Invalid function arguments";break;case ZodIssueCode.invalid_return_type:message="Invalid function return type";break;case ZodIssueCode.invalid_date:message="Invalid date";break;case ZodIssueCode.invalid_string:if(typeof issue.validation==="object")if("includes"in issue.validation){if(message=`Invalid input: must include "${issue.validation.includes}"`,typeof issue.validation.position==="number")message=`${message} at one or more positions greater than or equal to ${issue.validation.position}`}else if("startsWith"in issue.validation)message=`Invalid input: must start with "${issue.validation.startsWith}"`;else if("endsWith"in issue.validation)message=`Invalid input: must end with "${issue.validation.endsWith}"`;else util.assertNever(issue.validation);else if(issue.validation!=="regex")message=`Invalid ${issue.validation}`;else message="Invalid";break;case ZodIssueCode.too_small:if(issue.type==="array")message=`Array must contain ${issue.exact?"exactly":issue.inclusive?"at least":"more than"} ${issue.minimum} element(s)`;else if(issue.type==="string")message=`String must contain ${issue.exact?"exactly":issue.inclusive?"at least":"over"} ${issue.minimum} character(s)`;else if(issue.type==="number")message=`Number must be ${issue.exact?"exactly equal to ":issue.inclusive?"greater than or equal to ":"greater than "}${issue.minimum}`;else if(issue.type==="bigint")message=`Number must be ${issue.exact?"exactly equal to ":issue.inclusive?"greater than or equal to ":"greater than "}${issue.minimum}`;else if(issue.type==="date")message=`Date must be ${issue.exact?"exactly equal to ":issue.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(issue.minimum))}`;else message="Invalid input";break;case ZodIssueCode.too_big:if(issue.type==="array")message=`Array must contain ${issue.exact?"exactly":issue.inclusive?"at most":"less than"} ${issue.maximum} element(s)`;else if(issue.type==="string")message=`String must contain ${issue.exact?"exactly":issue.inclusive?"at most":"under"} ${issue.maximum} character(s)`;else if(issue.type==="number")message=`Number must be ${issue.exact?"exactly":issue.inclusive?"less than or equal to":"less than"} ${issue.maximum}`;else if(issue.type==="bigint")message=`BigInt must be ${issue.exact?"exactly":issue.inclusive?"less than or equal to":"less than"} ${issue.maximum}`;else if(issue.type==="date")message=`Date must be ${issue.exact?"exactly":issue.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(issue.maximum))}`;else message="Invalid input";break;case ZodIssueCode.custom:message="Invalid input";break;case ZodIssueCode.invalid_intersection_types:message="Intersection results could not be merged";break;case ZodIssueCode.not_multiple_of:message=`Number must be a multiple of ${issue.multipleOf}`;break;case ZodIssueCode.not_finite:message="Number must be finite";break;default:message=_ctx.defaultError,util.assertNever(issue)}return{message}},en_default;var init_en=__esm(()=>{init_ZodError();init_util();en_default=errorMap});function setErrorMap(map){overrideErrorMap=map}function getErrorMap(){return overrideErrorMap}var overrideErrorMap;var init_errors=__esm(()=>{init_en();overrideErrorMap=en_default});function addIssueToContext(ctx,issueData){let overrideMap=getErrorMap(),issue=makeIssue({issueData,data:ctx.data,path:ctx.path,errorMaps:[ctx.common.contextualErrorMap,ctx.schemaErrorMap,overrideMap,overrideMap===en_default?void 0:en_default].filter((x)=>!!x)});ctx.common.issues.push(issue)}class ParseStatus{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(status,results){let arrayValue=[];for(let s of results){if(s.status==="aborted")return INVALID;if(s.status==="dirty")status.dirty();arrayValue.push(s.value)}return{status:status.value,value:arrayValue}}static async mergeObjectAsync(status,pairs){let syncPairs=[];for(let pair of pairs){let key=await pair.key,value=await pair.value;syncPairs.push({key,value})}return ParseStatus.mergeObjectSync(status,syncPairs)}static mergeObjectSync(status,pairs){let finalObject={};for(let pair of pairs){let{key,value}=pair;if(key.status==="aborted")return INVALID;if(value.status==="aborted")return INVALID;if(key.status==="dirty")status.dirty();if(value.status==="dirty")status.dirty();if(key.value!=="__proto__"&&(typeof value.value<"u"||pair.alwaysSet))finalObject[key.value]=value.value}return{status:status.value,value:finalObject}}}var makeIssue=(params)=>{let{data,path,errorMaps,issueData}=params,fullPath=[...path,...issueData.path||[]],fullIssue={...issueData,path:fullPath};if(issueData.message!==void 0)return{...issueData,path:fullPath,message:issueData.message};let errorMessage="",maps=errorMaps.filter((m)=>!!m).slice().reverse();for(let map of maps)errorMessage=map(fullIssue,{data,defaultError:errorMessage}).message;return{...issueData,path:fullPath,message:errorMessage}},EMPTY_PATH,INVALID,DIRTY=(value)=>({status:"dirty",value}),OK=(value)=>({status:"valid",value}),isAborted=(x)=>x.status==="aborted",isDirty=(x)=>x.status==="dirty",isValid=(x)=>x.status==="valid",isAsync=(x)=>typeof Promise<"u"&&x instanceof Promise;var init_parseUtil=__esm(()=>{init_errors();init_en();EMPTY_PATH=[];INVALID=Object.freeze({status:"aborted"})});var init_typeAliases=()=>{};var errorUtil;var init_errorUtil=__esm(()=>{(function(errorUtil2){errorUtil2.errToObj=(message)=>typeof message==="string"?{message}:message||{},errorUtil2.toString=(message)=>typeof message==="string"?message:message?.message})(errorUtil||(errorUtil={}))});class ParseInputLazyPath{constructor(parent,value,path,key){this._cachedPath=[],this.parent=parent,this.data=value,this._path=path,this._key=key}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function processCreateParams(params){if(!params)return{};let{errorMap:errorMap2,invalid_type_error,required_error,description}=params;if(errorMap2&&(invalid_type_error||required_error))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(errorMap2)return{errorMap:errorMap2,description};return{errorMap:(iss,ctx)=>{let{message}=params;if(iss.code==="invalid_enum_value")return{message:message??ctx.defaultError};if(typeof ctx.data>"u")return{message:message??required_error??ctx.defaultError};if(iss.code!=="invalid_type")return{message:ctx.defaultError};return{message:message??invalid_type_error??ctx.defaultError}},description}}class ZodType{get description(){return this._def.description}_getType(input){return getParsedType(input.data)}_getOrReturnCtx(input,ctx){return ctx||{common:input.parent.common,data:input.data,parsedType:getParsedType(input.data),schemaErrorMap:this._def.errorMap,path:input.path,parent:input.parent}}_processInputParams(input){return{status:new ParseStatus,ctx:{common:input.parent.common,data:input.data,parsedType:getParsedType(input.data),schemaErrorMap:this._def.errorMap,path:input.path,parent:input.parent}}}_parseSync(input){let result2=this._parse(input);if(isAsync(result2))throw Error("Synchronous parse encountered promise.");return result2}_parseAsync(input){let result2=this._parse(input);return Promise.resolve(result2)}parse(data,params){let result2=this.safeParse(data,params);if(result2.success)return result2.data;throw result2.error}safeParse(data,params){let ctx={common:{issues:[],async:params?.async??!1,contextualErrorMap:params?.errorMap},path:params?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data,parsedType:getParsedType(data)},result2=this._parseSync({data,path:ctx.path,parent:ctx});return handleResult(ctx,result2)}"~validate"(data){let ctx={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data,parsedType:getParsedType(data)};if(!this["~standard"].async)try{let result2=this._parseSync({data,path:[],parent:ctx});return isValid(result2)?{value:result2.value}:{issues:ctx.common.issues}}catch(err){if(err?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;ctx.common={issues:[],async:!0}}return this._parseAsync({data,path:[],parent:ctx}).then((result2)=>isValid(result2)?{value:result2.value}:{issues:ctx.common.issues})}async parseAsync(data,params){let result2=await this.safeParseAsync(data,params);if(result2.success)return result2.data;throw result2.error}async safeParseAsync(data,params){let ctx={common:{issues:[],contextualErrorMap:params?.errorMap,async:!0},path:params?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data,parsedType:getParsedType(data)},maybeAsyncResult=this._parse({data,path:ctx.path,parent:ctx}),result2=await(isAsync(maybeAsyncResult)?maybeAsyncResult:Promise.resolve(maybeAsyncResult));return handleResult(ctx,result2)}refine(check,message){let getIssueProperties=(val)=>{if(typeof message==="string"||typeof message>"u")return{message};else if(typeof message==="function")return message(val);else return message};return this._refinement((val,ctx)=>{let result2=check(val),setError=()=>ctx.addIssue({code:ZodIssueCode.custom,...getIssueProperties(val)});if(typeof Promise<"u"&&result2 instanceof Promise)return result2.then((data)=>{if(!data)return setError(),!1;else return!0});if(!result2)return setError(),!1;else return!0})}refinement(check,refinementData){return this._refinement((val,ctx)=>{if(!check(val))return ctx.addIssue(typeof refinementData==="function"?refinementData(val,ctx):refinementData),!1;else return!0})}_refinement(refinement){return new ZodEffects({schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"refinement",refinement}})}superRefine(refinement){return this._refinement(refinement)}constructor(def){this.spa=this.safeParseAsync,this._def=def,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:(data)=>this["~validate"](data)}}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this)}promise(){return ZodPromise.create(this,this._def)}or(option){return ZodUnion.create([this,option],this._def)}and(incoming){return ZodIntersection.create(this,incoming,this._def)}transform(transform){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:ZodFirstPartyTypeKind.ZodEffects,effect:{type:"transform",transform}})}default(def){let defaultValueFunc=typeof def==="function"?def:()=>def;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:defaultValueFunc,typeName:ZodFirstPartyTypeKind.ZodDefault})}brand(){return new ZodBranded({typeName:ZodFirstPartyTypeKind.ZodBranded,type:this,...processCreateParams(this._def)})}catch(def){let catchValueFunc=typeof def==="function"?def:()=>def;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:catchValueFunc,typeName:ZodFirstPartyTypeKind.ZodCatch})}describe(description){return new this.constructor({...this._def,description})}pipe(target){return ZodPipeline.create(this,target)}readonly(){return ZodReadonly.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function timeRegexSource(args){let secondsRegexSource="[0-5]\\d";if(args.precision)secondsRegexSource=`${secondsRegexSource}\\.\\d{${args.precision}}`;else if(args.precision==null)secondsRegexSource=`${secondsRegexSource}(\\.\\d+)?`;let secondsQuantifier=args.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`}function timeRegex(args){return new RegExp(`^${timeRegexSource(args)}$`)}function datetimeRegex(args){let regex=`${dateRegexSource}T${timeRegexSource(args)}`,opts=[];if(opts.push(args.local?"Z?":"Z"),args.offset)opts.push("([+-]\\d{2}:?\\d{2})");return regex=`${regex}(${opts.join("|")})`,new RegExp(`^${regex}$`)}function isValidIP(ip,version){if((version==="v4"||!version)&&ipv4Regex.test(ip))return!0;if((version==="v6"||!version)&&ipv6Regex.test(ip))return!0;return!1}function isValidJWT(jwt,alg){if(!jwtRegex.test(jwt))return!1;try{let[header]=jwt.split(".");if(!header)return!1;let base64=header.replace(/-/g,"+").replace(/_/g,"/").padEnd(header.length+(4-header.length%4)%4,"="),decoded=JSON.parse(atob(base64));if(typeof decoded!=="object"||decoded===null)return!1;if("typ"in decoded&&decoded?.typ!=="JWT")return!1;if(!decoded.alg)return!1;if(alg&&decoded.alg!==alg)return!1;return!0}catch{return!1}}function isValidCidr(ip,version){if((version==="v4"||!version)&&ipv4CidrRegex.test(ip))return!0;if((version==="v6"||!version)&&ipv6CidrRegex.test(ip))return!0;return!1}function floatSafeRemainder(val,step){let valDecCount=(val.toString().split(".")[1]||"").length,stepDecCount=(step.toString().split(".")[1]||"").length,decCount=valDecCount>stepDecCount?valDecCount:stepDecCount,valInt=Number.parseInt(val.toFixed(decCount).replace(".","")),stepInt=Number.parseInt(step.toFixed(decCount).replace(".",""));return valInt%stepInt/10**decCount}function deepPartialify(schema){if(schema instanceof ZodObject){let newShape={};for(let key in schema.shape){let fieldSchema=schema.shape[key];newShape[key]=ZodOptional.create(deepPartialify(fieldSchema))}return new ZodObject({...schema._def,shape:()=>newShape})}else if(schema instanceof ZodArray)return new ZodArray({...schema._def,type:deepPartialify(schema.element)});else if(schema instanceof ZodOptional)return ZodOptional.create(deepPartialify(schema.unwrap()));else if(schema instanceof ZodNullable)return ZodNullable.create(deepPartialify(schema.unwrap()));else if(schema instanceof ZodTuple)return ZodTuple.create(schema.items.map((item)=>deepPartialify(item)));else return schema}function mergeValues(a,b){let aType=getParsedType(a),bType=getParsedType(b);if(a===b)return{valid:!0,data:a};else if(aType===ZodParsedType.object&&bType===ZodParsedType.object){let bKeys=util.objectKeys(b),sharedKeys=util.objectKeys(a).filter((key)=>bKeys.indexOf(key)!==-1),newObj={...a,...b};for(let key of sharedKeys){let sharedValue=mergeValues(a[key],b[key]);if(!sharedValue.valid)return{valid:!1};newObj[key]=sharedValue.data}return{valid:!0,data:newObj}}else if(aType===ZodParsedType.array&&bType===ZodParsedType.array){if(a.length!==b.length)return{valid:!1};let newArray=[];for(let index=0;index<a.length;index++){let itemA=a[index],itemB=b[index],sharedValue=mergeValues(itemA,itemB);if(!sharedValue.valid)return{valid:!1};newArray.push(sharedValue.data)}return{valid:!0,data:newArray}}else if(aType===ZodParsedType.date&&bType===ZodParsedType.date&&+a===+b)return{valid:!0,data:a};else return{valid:!1}}function createZodEnum(values,params){return new ZodEnum({values,typeName:ZodFirstPartyTypeKind.ZodEnum,...processCreateParams(params)})}function cleanParams(params,data){let p=typeof params==="function"?params(data):typeof params==="string"?{message:params}:params;return typeof p==="string"?{message:p}:p}function custom(check,_params={},fatal){if(check)return ZodAny.create().superRefine((data,ctx)=>{let r=check(data);if(r instanceof Promise)return r.then((r2)=>{if(!r2){let params=cleanParams(_params,data),_fatal=params.fatal??fatal??!0;ctx.addIssue({code:"custom",...params,fatal:_fatal})}});if(!r){let params=cleanParams(_params,data),_fatal=params.fatal??fatal??!0;ctx.addIssue({code:"custom",...params,fatal:_fatal})}return});return ZodAny.create()}var handleResult=(ctx,result2)=>{if(isValid(result2))return{success:!0,data:result2.value};else{if(!ctx.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let error=new ZodError(ctx.common.issues);return this._error=error,this._error}}}},cuidRegex,cuid2Regex,ulidRegex,uuidRegex,nanoidRegex,jwtRegex,durationRegex,emailRegex,_emojiRegex="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",emojiRegex,ipv4Regex,ipv4CidrRegex,ipv6Regex,ipv6CidrRegex,base64Regex,base64urlRegex,dateRegexSource="((\\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])))",dateRegex,ZodString,ZodNumber,ZodBigInt,ZodBoolean,ZodDate,ZodSymbol,ZodUndefined,ZodNull,ZodAny,ZodUnknown,ZodNever,ZodVoid,ZodArray,ZodObject,ZodUnion,getDiscriminator=(type)=>{if(type instanceof ZodLazy)return getDiscriminator(type.schema);else if(type instanceof ZodEffects)return getDiscriminator(type.innerType());else if(type instanceof ZodLiteral)return[type.value];else if(type instanceof ZodEnum)return type.options;else if(type instanceof ZodNativeEnum)return util.objectValues(type.enum);else if(type instanceof ZodDefault)return getDiscriminator(type._def.innerType);else if(type instanceof ZodUndefined)return[void 0];else if(type instanceof ZodNull)return[null];else if(type instanceof ZodOptional)return[void 0,...getDiscriminator(type.unwrap())];else if(type instanceof ZodNullable)return[null,...getDiscriminator(type.unwrap())];else if(type instanceof ZodBranded)return getDiscriminator(type.unwrap());else if(type instanceof ZodReadonly)return getDiscriminator(type.unwrap());else if(type instanceof ZodCatch)return getDiscriminator(type._def.innerType);else return[]},ZodDiscriminatedUnion,ZodIntersection,ZodTuple,ZodRecord,ZodMap,ZodSet,ZodFunction,ZodLazy,ZodLiteral,ZodEnum,ZodNativeEnum,ZodPromise,ZodEffects,ZodOptional,ZodNullable,ZodDefault,ZodCatch,ZodNaN,BRAND,ZodBranded,ZodPipeline,ZodReadonly,late,ZodFirstPartyTypeKind,instanceOfType=(cls,params={message:`Input not instance of ${cls.name}`})=>custom((data)=>data instanceof cls,params),stringType,numberType,nanType,bigIntType,booleanType,dateType,symbolType,undefinedType,nullType,anyType,unknownType,neverType,voidType,arrayType,objectType,strictObjectType,unionType,discriminatedUnionType,intersectionType,tupleType,recordType,mapType,setType,functionType,lazyType,literalType,enumType,nativeEnumType,promiseType,effectsType,optionalType,nullableType,preprocessType,pipelineType,ostring=()=>stringType().optional(),onumber=()=>numberType().optional(),oboolean=()=>booleanType().optional(),coerce,NEVER;var init_types=__esm(()=>{init_ZodError();init_errors();init_errorUtil();init_parseUtil();init_util();cuidRegex=/^c[^\s-]{8,}$/i,cuid2Regex=/^[0-9a-z]+$/,ulidRegex=/^[0-9A-HJKMNP-TV-Z]{26}$/i,uuidRegex=/^[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,nanoidRegex=/^[a-z0-9_-]{21}$/i,jwtRegex=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,durationRegex=/^[-+]?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)?)??$/,emailRegex=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ipv4Regex=/^(?:(?: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])$/,ipv4CidrRegex=/^(?:(?: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])$/,ipv6Regex=/^(([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]))$/,ipv6CidrRegex=/^(([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])$/,base64Regex=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64urlRegex=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dateRegex=new RegExp(`^${dateRegexSource}$`);ZodString=class ZodString extends ZodType{_parse(input){if(this._def.coerce)input.data=String(input.data);if(this._getType(input)!==ZodParsedType.string){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.string,received:ctx2.parsedType}),INVALID}let status=new ParseStatus,ctx=void 0;for(let check of this._def.checks)if(check.kind==="min"){if(input.data.length<check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:check.value,type:"string",inclusive:!0,exact:!1,message:check.message}),status.dirty()}else if(check.kind==="max"){if(input.data.length>check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:check.value,type:"string",inclusive:!0,exact:!1,message:check.message}),status.dirty()}else if(check.kind==="length"){let tooBig=input.data.length>check.value,tooSmall=input.data.length<check.value;if(tooBig||tooSmall){if(ctx=this._getOrReturnCtx(input,ctx),tooBig)addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:check.value,type:"string",inclusive:!0,exact:!0,message:check.message});else if(tooSmall)addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:check.value,type:"string",inclusive:!0,exact:!0,message:check.message});status.dirty()}}else if(check.kind==="email"){if(!emailRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"email",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="emoji"){if(!emojiRegex)emojiRegex=new RegExp(_emojiRegex,"u");if(!emojiRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"emoji",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="uuid"){if(!uuidRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"uuid",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="nanoid"){if(!nanoidRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"nanoid",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="cuid"){if(!cuidRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"cuid",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="cuid2"){if(!cuid2Regex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"cuid2",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="ulid"){if(!ulidRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"ulid",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="url")try{new URL(input.data)}catch{ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"url",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="regex"){if(check.regex.lastIndex=0,!check.regex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"regex",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="trim")input.data=input.data.trim();else if(check.kind==="includes"){if(!input.data.includes(check.value,check.position))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:{includes:check.value,position:check.position},message:check.message}),status.dirty()}else if(check.kind==="toLowerCase")input.data=input.data.toLowerCase();else if(check.kind==="toUpperCase")input.data=input.data.toUpperCase();else if(check.kind==="startsWith"){if(!input.data.startsWith(check.value))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:{startsWith:check.value},message:check.message}),status.dirty()}else if(check.kind==="endsWith"){if(!input.data.endsWith(check.value))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:{endsWith:check.value},message:check.message}),status.dirty()}else if(check.kind==="datetime"){if(!datetimeRegex(check).test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:"datetime",message:check.message}),status.dirty()}else if(check.kind==="date"){if(!dateRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:"date",message:check.message}),status.dirty()}else if(check.kind==="time"){if(!timeRegex(check).test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_string,validation:"time",message:check.message}),status.dirty()}else if(check.kind==="duration"){if(!durationRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"duration",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="ip"){if(!isValidIP(input.data,check.version))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"ip",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="jwt"){if(!isValidJWT(input.data,check.alg))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"jwt",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="cidr"){if(!isValidCidr(input.data,check.version))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"cidr",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="base64"){if(!base64Regex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"base64",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else if(check.kind==="base64url"){if(!base64urlRegex.test(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{validation:"base64url",code:ZodIssueCode.invalid_string,message:check.message}),status.dirty()}else util.assertNever(check);return{status:status.value,value:input.data}}_regex(regex,validation,message){return this.refinement((data)=>regex.test(data),{validation,code:ZodIssueCode.invalid_string,...errorUtil.errToObj(message)})}_addCheck(check){return new ZodString({...this._def,checks:[...this._def.checks,check]})}email(message){return this._addCheck({kind:"email",...errorUtil.errToObj(message)})}url(message){return this._addCheck({kind:"url",...errorUtil.errToObj(message)})}emoji(message){return this._addCheck({kind:"emoji",...errorUtil.errToObj(message)})}uuid(message){return this._addCheck({kind:"uuid",...errorUtil.errToObj(message)})}nanoid(message){return this._addCheck({kind:"nanoid",...errorUtil.errToObj(message)})}cuid(message){return this._addCheck({kind:"cuid",...errorUtil.errToObj(message)})}cuid2(message){return this._addCheck({kind:"cuid2",...errorUtil.errToObj(message)})}ulid(message){return this._addCheck({kind:"ulid",...errorUtil.errToObj(message)})}base64(message){return this._addCheck({kind:"base64",...errorUtil.errToObj(message)})}base64url(message){return this._addCheck({kind:"base64url",...errorUtil.errToObj(message)})}jwt(options){return this._addCheck({kind:"jwt",...errorUtil.errToObj(options)})}ip(options){return this._addCheck({kind:"ip",...errorUtil.errToObj(options)})}cidr(options){return this._addCheck({kind:"cidr",...errorUtil.errToObj(options)})}datetime(options){if(typeof options==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:options});return this._addCheck({kind:"datetime",precision:typeof options?.precision>"u"?null:options?.precision,offset:options?.offset??!1,local:options?.local??!1,...errorUtil.errToObj(options?.message)})}date(message){return this._addCheck({kind:"date",message})}time(options){if(typeof options==="string")return this._addCheck({kind:"time",precision:null,message:options});return this._addCheck({kind:"time",precision:typeof options?.precision>"u"?null:options?.precision,...errorUtil.errToObj(options?.message)})}duration(message){return this._addCheck({kind:"duration",...errorUtil.errToObj(message)})}regex(regex,message){return this._addCheck({kind:"regex",regex,...errorUtil.errToObj(message)})}includes(value,options){return this._addCheck({kind:"includes",value,position:options?.position,...errorUtil.errToObj(options?.message)})}startsWith(value,message){return this._addCheck({kind:"startsWith",value,...errorUtil.errToObj(message)})}endsWith(value,message){return this._addCheck({kind:"endsWith",value,...errorUtil.errToObj(message)})}min(minLength,message){return this._addCheck({kind:"min",value:minLength,...errorUtil.errToObj(message)})}max(maxLength,message){return this._addCheck({kind:"max",value:maxLength,...errorUtil.errToObj(message)})}length(len,message){return this._addCheck({kind:"length",value:len,...errorUtil.errToObj(message)})}nonempty(message){return this.min(1,errorUtil.errToObj(message))}trim(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((ch)=>ch.kind==="datetime")}get isDate(){return!!this._def.checks.find((ch)=>ch.kind==="date")}get isTime(){return!!this._def.checks.find((ch)=>ch.kind==="time")}get isDuration(){return!!this._def.checks.find((ch)=>ch.kind==="duration")}get isEmail(){return!!this._def.checks.find((ch)=>ch.kind==="email")}get isURL(){return!!this._def.checks.find((ch)=>ch.kind==="url")}get isEmoji(){return!!this._def.checks.find((ch)=>ch.kind==="emoji")}get isUUID(){return!!this._def.checks.find((ch)=>ch.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((ch)=>ch.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((ch)=>ch.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((ch)=>ch.kind==="cuid2")}get isULID(){return!!this._def.checks.find((ch)=>ch.kind==="ulid")}get isIP(){return!!this._def.checks.find((ch)=>ch.kind==="ip")}get isCIDR(){return!!this._def.checks.find((ch)=>ch.kind==="cidr")}get isBase64(){return!!this._def.checks.find((ch)=>ch.kind==="base64")}get isBase64url(){return!!this._def.checks.find((ch)=>ch.kind==="base64url")}get minLength(){let min=null;for(let ch of this._def.checks)if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}return min}get maxLength(){let max=null;for(let ch of this._def.checks)if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return max}};ZodString.create=(params)=>{return new ZodString({checks:[],typeName:ZodFirstPartyTypeKind.ZodString,coerce:params?.coerce??!1,...processCreateParams(params)})};ZodNumber=class ZodNumber extends ZodType{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(input){if(this._def.coerce)input.data=Number(input.data);if(this._getType(input)!==ZodParsedType.number){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.number,received:ctx2.parsedType}),INVALID}let ctx=void 0,status=new ParseStatus;for(let check of this._def.checks)if(check.kind==="int"){if(!util.isInteger(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:"integer",received:"float",message:check.message}),status.dirty()}else if(check.kind==="min"){if(check.inclusive?input.data<check.value:input.data<=check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:check.value,type:"number",inclusive:check.inclusive,exact:!1,message:check.message}),status.dirty()}else if(check.kind==="max"){if(check.inclusive?input.data>check.value:input.data>=check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:check.value,type:"number",inclusive:check.inclusive,exact:!1,message:check.message}),status.dirty()}else if(check.kind==="multipleOf"){if(floatSafeRemainder(input.data,check.value)!==0)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.not_multiple_of,multipleOf:check.value,message:check.message}),status.dirty()}else if(check.kind==="finite"){if(!Number.isFinite(input.data))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.not_finite,message:check.message}),status.dirty()}else util.assertNever(check);return{status:status.value,value:input.data}}gte(value,message){return this.setLimit("min",value,!0,errorUtil.toString(message))}gt(value,message){return this.setLimit("min",value,!1,errorUtil.toString(message))}lte(value,message){return this.setLimit("max",value,!0,errorUtil.toString(message))}lt(value,message){return this.setLimit("max",value,!1,errorUtil.toString(message))}setLimit(kind,value,inclusive,message){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind,value,inclusive,message:errorUtil.toString(message)}]})}_addCheck(check){return new ZodNumber({...this._def,checks:[...this._def.checks,check]})}int(message){return this._addCheck({kind:"int",message:errorUtil.toString(message)})}positive(message){return this._addCheck({kind:"min",value:0,inclusive:!1,message:errorUtil.toString(message)})}negative(message){return this._addCheck({kind:"max",value:0,inclusive:!1,message:errorUtil.toString(message)})}nonpositive(message){return this._addCheck({kind:"max",value:0,inclusive:!0,message:errorUtil.toString(message)})}nonnegative(message){return this._addCheck({kind:"min",value:0,inclusive:!0,message:errorUtil.toString(message)})}multipleOf(value,message){return this._addCheck({kind:"multipleOf",value,message:errorUtil.toString(message)})}finite(message){return this._addCheck({kind:"finite",message:errorUtil.toString(message)})}safe(message){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:errorUtil.toString(message)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:errorUtil.toString(message)})}get minValue(){let min=null;for(let ch of this._def.checks)if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}return min}get maxValue(){let max=null;for(let ch of this._def.checks)if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return max}get isInt(){return!!this._def.checks.find((ch)=>ch.kind==="int"||ch.kind==="multipleOf"&&util.isInteger(ch.value))}get isFinite(){let max=null,min=null;for(let ch of this._def.checks)if(ch.kind==="finite"||ch.kind==="int"||ch.kind==="multipleOf")return!0;else if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}else if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return Number.isFinite(min)&&Number.isFinite(max)}};ZodNumber.create=(params)=>{return new ZodNumber({checks:[],typeName:ZodFirstPartyTypeKind.ZodNumber,coerce:params?.coerce||!1,...processCreateParams(params)})};ZodBigInt=class ZodBigInt extends ZodType{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(input){if(this._def.coerce)try{input.data=BigInt(input.data)}catch{return this._getInvalidInput(input)}if(this._getType(input)!==ZodParsedType.bigint)return this._getInvalidInput(input);let ctx=void 0,status=new ParseStatus;for(let check of this._def.checks)if(check.kind==="min"){if(check.inclusive?input.data<check.value:input.data<=check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_small,type:"bigint",minimum:check.value,inclusive:check.inclusive,message:check.message}),status.dirty()}else if(check.kind==="max"){if(check.inclusive?input.data>check.value:input.data>=check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_big,type:"bigint",maximum:check.value,inclusive:check.inclusive,message:check.message}),status.dirty()}else if(check.kind==="multipleOf"){if(input.data%check.value!==BigInt(0))ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.not_multiple_of,multipleOf:check.value,message:check.message}),status.dirty()}else util.assertNever(check);return{status:status.value,value:input.data}}_getInvalidInput(input){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.bigint,received:ctx.parsedType}),INVALID}gte(value,message){return this.setLimit("min",value,!0,errorUtil.toString(message))}gt(value,message){return this.setLimit("min",value,!1,errorUtil.toString(message))}lte(value,message){return this.setLimit("max",value,!0,errorUtil.toString(message))}lt(value,message){return this.setLimit("max",value,!1,errorUtil.toString(message))}setLimit(kind,value,inclusive,message){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind,value,inclusive,message:errorUtil.toString(message)}]})}_addCheck(check){return new ZodBigInt({...this._def,checks:[...this._def.checks,check]})}positive(message){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:errorUtil.toString(message)})}negative(message){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:errorUtil.toString(message)})}nonpositive(message){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:errorUtil.toString(message)})}nonnegative(message){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:errorUtil.toString(message)})}multipleOf(value,message){return this._addCheck({kind:"multipleOf",value,message:errorUtil.toString(message)})}get minValue(){let min=null;for(let ch of this._def.checks)if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}return min}get maxValue(){let max=null;for(let ch of this._def.checks)if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return max}};ZodBigInt.create=(params)=>{return new ZodBigInt({checks:[],typeName:ZodFirstPartyTypeKind.ZodBigInt,coerce:params?.coerce??!1,...processCreateParams(params)})};ZodBoolean=class ZodBoolean extends ZodType{_parse(input){if(this._def.coerce)input.data=Boolean(input.data);if(this._getType(input)!==ZodParsedType.boolean){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.boolean,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodBoolean.create=(params)=>{return new ZodBoolean({typeName:ZodFirstPartyTypeKind.ZodBoolean,coerce:params?.coerce||!1,...processCreateParams(params)})};ZodDate=class ZodDate extends ZodType{_parse(input){if(this._def.coerce)input.data=new Date(input.data);if(this._getType(input)!==ZodParsedType.date){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.date,received:ctx2.parsedType}),INVALID}if(Number.isNaN(input.data.getTime())){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_date}),INVALID}let status=new ParseStatus,ctx=void 0;for(let check of this._def.checks)if(check.kind==="min"){if(input.data.getTime()<check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_small,message:check.message,inclusive:!0,exact:!1,minimum:check.value,type:"date"}),status.dirty()}else if(check.kind==="max"){if(input.data.getTime()>check.value)ctx=this._getOrReturnCtx(input,ctx),addIssueToContext(ctx,{code:ZodIssueCode.too_big,message:check.message,inclusive:!0,exact:!1,maximum:check.value,type:"date"}),status.dirty()}else util.assertNever(check);return{status:status.value,value:new Date(input.data.getTime())}}_addCheck(check){return new ZodDate({...this._def,checks:[...this._def.checks,check]})}min(minDate,message){return this._addCheck({kind:"min",value:minDate.getTime(),message:errorUtil.toString(message)})}max(maxDate,message){return this._addCheck({kind:"max",value:maxDate.getTime(),message:errorUtil.toString(message)})}get minDate(){let min=null;for(let ch of this._def.checks)if(ch.kind==="min"){if(min===null||ch.value>min)min=ch.value}return min!=null?new Date(min):null}get maxDate(){let max=null;for(let ch of this._def.checks)if(ch.kind==="max"){if(max===null||ch.value<max)max=ch.value}return max!=null?new Date(max):null}};ZodDate.create=(params)=>{return new ZodDate({checks:[],coerce:params?.coerce||!1,typeName:ZodFirstPartyTypeKind.ZodDate,...processCreateParams(params)})};ZodSymbol=class ZodSymbol extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.symbol){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.symbol,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodSymbol.create=(params)=>{return new ZodSymbol({typeName:ZodFirstPartyTypeKind.ZodSymbol,...processCreateParams(params)})};ZodUndefined=class ZodUndefined extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.undefined){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.undefined,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodUndefined.create=(params)=>{return new ZodUndefined({typeName:ZodFirstPartyTypeKind.ZodUndefined,...processCreateParams(params)})};ZodNull=class ZodNull extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.null){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.null,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodNull.create=(params)=>{return new ZodNull({typeName:ZodFirstPartyTypeKind.ZodNull,...processCreateParams(params)})};ZodAny=class ZodAny extends ZodType{constructor(){super(...arguments);this._any=!0}_parse(input){return OK(input.data)}};ZodAny.create=(params)=>{return new ZodAny({typeName:ZodFirstPartyTypeKind.ZodAny,...processCreateParams(params)})};ZodUnknown=class ZodUnknown extends ZodType{constructor(){super(...arguments);this._unknown=!0}_parse(input){return OK(input.data)}};ZodUnknown.create=(params)=>{return new ZodUnknown({typeName:ZodFirstPartyTypeKind.ZodUnknown,...processCreateParams(params)})};ZodNever=class ZodNever extends ZodType{_parse(input){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.never,received:ctx.parsedType}),INVALID}};ZodNever.create=(params)=>{return new ZodNever({typeName:ZodFirstPartyTypeKind.ZodNever,...processCreateParams(params)})};ZodVoid=class ZodVoid extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.undefined){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.void,received:ctx.parsedType}),INVALID}return OK(input.data)}};ZodVoid.create=(params)=>{return new ZodVoid({typeName:ZodFirstPartyTypeKind.ZodVoid,...processCreateParams(params)})};ZodArray=class ZodArray extends ZodType{_parse(input){let{ctx,status}=this._processInputParams(input),def=this._def;if(ctx.parsedType!==ZodParsedType.array)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:ctx.parsedType}),INVALID;if(def.exactLength!==null){let tooBig=ctx.data.length>def.exactLength.value,tooSmall=ctx.data.length<def.exactLength.value;if(tooBig||tooSmall)addIssueToContext(ctx,{code:tooBig?ZodIssueCode.too_big:ZodIssueCode.too_small,minimum:tooSmall?def.exactLength.value:void 0,maximum:tooBig?def.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:def.exactLength.message}),status.dirty()}if(def.minLength!==null){if(ctx.data.length<def.minLength.value)addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:def.minLength.value,type:"array",inclusive:!0,exact:!1,message:def.minLength.message}),status.dirty()}if(def.maxLength!==null){if(ctx.data.length>def.maxLength.value)addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:def.maxLength.value,type:"array",inclusive:!0,exact:!1,message:def.maxLength.message}),status.dirty()}if(ctx.common.async)return Promise.all([...ctx.data].map((item,i)=>{return def.type._parseAsync(new ParseInputLazyPath(ctx,item,ctx.path,i))})).then((result3)=>{return ParseStatus.mergeArray(status,result3)});let result2=[...ctx.data].map((item,i)=>{return def.type._parseSync(new ParseInputLazyPath(ctx,item,ctx.path,i))});return ParseStatus.mergeArray(status,result2)}get element(){return this._def.type}min(minLength,message){return new ZodArray({...this._def,minLength:{value:minLength,message:errorUtil.toString(message)}})}max(maxLength,message){return new ZodArray({...this._def,maxLength:{value:maxLength,message:errorUtil.toString(message)}})}length(len,message){return new ZodArray({...this._def,exactLength:{value:len,message:errorUtil.toString(message)}})}nonempty(message){return this.min(1,message)}};ZodArray.create=(schema,params)=>{return new ZodArray({type:schema,minLength:null,maxLength:null,exactLength:null,typeName:ZodFirstPartyTypeKind.ZodArray,...processCreateParams(params)})};ZodObject=class ZodObject extends ZodType{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let shape=this._def.shape(),keys=util.objectKeys(shape);return this._cached={shape,keys},this._cached}_parse(input){if(this._getType(input)!==ZodParsedType.object){let ctx2=this._getOrReturnCtx(input);return addIssueToContext(ctx2,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:ctx2.parsedType}),INVALID}let{status,ctx}=this._processInputParams(input),{shape,keys:shapeKeys}=this._getCached(),extraKeys=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip")){for(let key in ctx.data)if(!shapeKeys.includes(key))extraKeys.push(key)}let pairs=[];for(let key of shapeKeys){let keyValidator=shape[key],value=ctx.data[key];pairs.push({key:{status:"valid",value:key},value:keyValidator._parse(new ParseInputLazyPath(ctx,value,ctx.path,key)),alwaysSet:key in ctx.data})}if(this._def.catchall instanceof ZodNever){let unknownKeys=this._def.unknownKeys;if(unknownKeys==="passthrough")for(let key of extraKeys)pairs.push({key:{status:"valid",value:key},value:{status:"valid",value:ctx.data[key]}});else if(unknownKeys==="strict"){if(extraKeys.length>0)addIssueToContext(ctx,{code:ZodIssueCode.unrecognized_keys,keys:extraKeys}),status.dirty()}else if(unknownKeys==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let catchall=this._def.catchall;for(let key of extraKeys){let value=ctx.data[key];pairs.push({key:{status:"valid",value:key},value:catchall._parse(new ParseInputLazyPath(ctx,value,ctx.path,key)),alwaysSet:key in ctx.data})}}if(ctx.common.async)return Promise.resolve().then(async()=>{let syncPairs=[];for(let pair of pairs){let key=await pair.key,value=await pair.value;syncPairs.push({key,value,alwaysSet:pair.alwaysSet})}return syncPairs}).then((syncPairs)=>{return ParseStatus.mergeObjectSync(status,syncPairs)});else return ParseStatus.mergeObjectSync(status,pairs)}get shape(){return this._def.shape()}strict(message){return errorUtil.errToObj,new ZodObject({...this._def,unknownKeys:"strict",...message!==void 0?{errorMap:(issue,ctx)=>{let defaultError=this._def.errorMap?.(issue,ctx).message??ctx.defaultError;if(issue.code==="unrecognized_keys")return{message:errorUtil.errToObj(message).message??defaultError};return{message:defaultError}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(augmentation){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...augmentation})})}merge(merging){return new ZodObject({unknownKeys:merging._def.unknownKeys,catchall:merging._def.catchall,shape:()=>({...this._def.shape(),...merging._def.shape()}),typeName:ZodFirstPartyTypeKind.ZodObject})}setKey(key,schema){return this.augment({[key]:schema})}catchall(index){return new ZodObject({...this._def,catchall:index})}pick(mask){let shape={};for(let key of util.objectKeys(mask))if(mask[key]&&this.shape[key])shape[key]=this.shape[key];return new ZodObject({...this._def,shape:()=>shape})}omit(mask){let shape={};for(let key of util.objectKeys(this.shape))if(!mask[key])shape[key]=this.shape[key];return new ZodObject({...this._def,shape:()=>shape})}deepPartial(){return deepPartialify(this)}partial(mask){let newShape={};for(let key of util.objectKeys(this.shape)){let fieldSchema=this.shape[key];if(mask&&!mask[key])newShape[key]=fieldSchema;else newShape[key]=fieldSchema.optional()}return new ZodObject({...this._def,shape:()=>newShape})}required(mask){let newShape={};for(let key of util.objectKeys(this.shape))if(mask&&!mask[key])newShape[key]=this.shape[key];else{let newField=this.shape[key];while(newField instanceof ZodOptional)newField=newField._def.innerType;newShape[key]=newField}return new ZodObject({...this._def,shape:()=>newShape})}keyof(){return createZodEnum(util.objectKeys(this.shape))}};ZodObject.create=(shape,params)=>{return new ZodObject({shape:()=>shape,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(params)})};ZodObject.strictCreate=(shape,params)=>{return new ZodObject({shape:()=>shape,unknownKeys:"strict",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(params)})};ZodObject.lazycreate=(shape,params)=>{return new ZodObject({shape,unknownKeys:"strip",catchall:ZodNever.create(),typeName:ZodFirstPartyTypeKind.ZodObject,...processCreateParams(params)})};ZodUnion=class ZodUnion extends ZodType{_parse(input){let{ctx}=this._processInputParams(input),options=this._def.options;function handleResults(results){for(let result2 of results)if(result2.result.status==="valid")return result2.result;for(let result2 of results)if(result2.result.status==="dirty")return ctx.common.issues.push(...result2.ctx.common.issues),result2.result;let unionErrors=results.map((result2)=>new ZodError(result2.ctx.common.issues));return addIssueToContext(ctx,{code:ZodIssueCode.invalid_union,unionErrors}),INVALID}if(ctx.common.async)return Promise.all(options.map(async(option)=>{let childCtx={...ctx,common:{...ctx.common,issues:[]},parent:null};return{result:await option._parseAsync({data:ctx.data,path:ctx.path,parent:childCtx}),ctx:childCtx}})).then(handleResults);else{let dirty=void 0,issues=[];for(let option of options){let childCtx={...ctx,common:{...ctx.common,issues:[]},parent:null},result2=option._parseSync({data:ctx.data,path:ctx.path,parent:childCtx});if(result2.status==="valid")return result2;else if(result2.status==="dirty"&&!dirty)dirty={result:result2,ctx:childCtx};if(childCtx.common.issues.length)issues.push(childCtx.common.issues)}if(dirty)return ctx.common.issues.push(...dirty.ctx.common.issues),dirty.result;let unionErrors=issues.map((issues2)=>new ZodError(issues2));return addIssueToContext(ctx,{code:ZodIssueCode.invalid_union,unionErrors}),INVALID}}get options(){return this._def.options}};ZodUnion.create=(types,params)=>{return new ZodUnion({options:types,typeName:ZodFirstPartyTypeKind.ZodUnion,...processCreateParams(params)})};ZodDiscriminatedUnion=class ZodDiscriminatedUnion extends ZodType{_parse(input){let{ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.object)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:ctx.parsedType}),INVALID;let discriminator=this.discriminator,discriminatorValue=ctx.data[discriminator],option=this.optionsMap.get(discriminatorValue);if(!option)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[discriminator]}),INVALID;if(ctx.common.async)return option._parseAsync({data:ctx.data,path:ctx.path,parent:ctx});else return option._parseSync({data:ctx.data,path:ctx.path,parent:ctx})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(discriminator,options,params){let optionsMap=new Map;for(let type of options){let discriminatorValues=getDiscriminator(type.shape[discriminator]);if(!discriminatorValues.length)throw Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);for(let value of discriminatorValues){if(optionsMap.has(value))throw Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);optionsMap.set(value,type)}}return new ZodDiscriminatedUnion({typeName:ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator,options,optionsMap,...processCreateParams(params)})}};ZodIntersection=class ZodIntersection extends ZodType{_parse(input){let{status,ctx}=this._processInputParams(input),handleParsed=(parsedLeft,parsedRight)=>{if(isAborted(parsedLeft)||isAborted(parsedRight))return INVALID;let merged=mergeValues(parsedLeft.value,parsedRight.value);if(!merged.valid)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_intersection_types}),INVALID;if(isDirty(parsedLeft)||isDirty(parsedRight))status.dirty();return{status:status.value,value:merged.data}};if(ctx.common.async)return Promise.all([this._def.left._parseAsync({data:ctx.data,path:ctx.path,parent:ctx}),this._def.right._parseAsync({data:ctx.data,path:ctx.path,parent:ctx})]).then(([left,right])=>handleParsed(left,right));else return handleParsed(this._def.left._parseSync({data:ctx.data,path:ctx.path,parent:ctx}),this._def.right._parseSync({data:ctx.data,path:ctx.path,parent:ctx}))}};ZodIntersection.create=(left,right,params)=>{return new ZodIntersection({left,right,typeName:ZodFirstPartyTypeKind.ZodIntersection,...processCreateParams(params)})};ZodTuple=class ZodTuple extends ZodType{_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.array)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.array,received:ctx.parsedType}),INVALID;if(ctx.data.length<this._def.items.length)return addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),INVALID;if(!this._def.rest&&ctx.data.length>this._def.items.length)addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),status.dirty();let items=[...ctx.data].map((item,itemIndex)=>{let schema=this._def.items[itemIndex]||this._def.rest;if(!schema)return null;return schema._parse(new ParseInputLazyPath(ctx,item,ctx.path,itemIndex))}).filter((x)=>!!x);if(ctx.common.async)return Promise.all(items).then((results)=>{return ParseStatus.mergeArray(status,results)});else return ParseStatus.mergeArray(status,items)}get items(){return this._def.items}rest(rest){return new ZodTuple({...this._def,rest})}};ZodTuple.create=(schemas,params)=>{if(!Array.isArray(schemas))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new ZodTuple({items:schemas,typeName:ZodFirstPartyTypeKind.ZodTuple,rest:null,...processCreateParams(params)})};ZodRecord=class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.object)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.object,received:ctx.parsedType}),INVALID;let pairs=[],keyType=this._def.keyType,valueType=this._def.valueType;for(let key in ctx.data)pairs.push({key:keyType._parse(new ParseInputLazyPath(ctx,key,ctx.path,key)),value:valueType._parse(new ParseInputLazyPath(ctx,ctx.data[key],ctx.path,key)),alwaysSet:key in ctx.data});if(ctx.common.async)return ParseStatus.mergeObjectAsync(status,pairs);else return ParseStatus.mergeObjectSync(status,pairs)}get element(){return this._def.valueType}static create(first,second,third){if(second instanceof ZodType)return new ZodRecord({keyType:first,valueType:second,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(third)});return new ZodRecord({keyType:ZodString.create(),valueType:first,typeName:ZodFirstPartyTypeKind.ZodRecord,...processCreateParams(second)})}};ZodMap=class ZodMap extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.map)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.map,received:ctx.parsedType}),INVALID;let keyType=this._def.keyType,valueType=this._def.valueType,pairs=[...ctx.data.entries()].map(([key,value],index)=>{return{key:keyType._parse(new ParseInputLazyPath(ctx,key,ctx.path,[index,"key"])),value:valueType._parse(new ParseInputLazyPath(ctx,value,ctx.path,[index,"value"]))}});if(ctx.common.async){let finalMap=new Map;return Promise.resolve().then(async()=>{for(let pair of pairs){let key=await pair.key,value=await pair.value;if(key.status==="aborted"||value.status==="aborted")return INVALID;if(key.status==="dirty"||value.status==="dirty")status.dirty();finalMap.set(key.value,value.value)}return{status:status.value,value:finalMap}})}else{let finalMap=new Map;for(let pair of pairs){let{key,value}=pair;if(key.status==="aborted"||value.status==="aborted")return INVALID;if(key.status==="dirty"||value.status==="dirty")status.dirty();finalMap.set(key.value,value.value)}return{status:status.value,value:finalMap}}}};ZodMap.create=(keyType,valueType,params)=>{return new ZodMap({valueType,keyType,typeName:ZodFirstPartyTypeKind.ZodMap,...processCreateParams(params)})};ZodSet=class ZodSet extends ZodType{_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.set)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.set,received:ctx.parsedType}),INVALID;let def=this._def;if(def.minSize!==null){if(ctx.data.size<def.minSize.value)addIssueToContext(ctx,{code:ZodIssueCode.too_small,minimum:def.minSize.value,type:"set",inclusive:!0,exact:!1,message:def.minSize.message}),status.dirty()}if(def.maxSize!==null){if(ctx.data.size>def.maxSize.value)addIssueToContext(ctx,{code:ZodIssueCode.too_big,maximum:def.maxSize.value,type:"set",inclusive:!0,exact:!1,message:def.maxSize.message}),status.dirty()}let valueType=this._def.valueType;function finalizeSet(elements2){let parsedSet=new Set;for(let element of elements2){if(element.status==="aborted")return INVALID;if(element.status==="dirty")status.dirty();parsedSet.add(element.value)}return{status:status.value,value:parsedSet}}let elements=[...ctx.data.values()].map((item,i)=>valueType._parse(new ParseInputLazyPath(ctx,item,ctx.path,i)));if(ctx.common.async)return Promise.all(elements).then((elements2)=>finalizeSet(elements2));else return finalizeSet(elements)}min(minSize,message){return new ZodSet({...this._def,minSize:{value:minSize,message:errorUtil.toString(message)}})}max(maxSize,message){return new ZodSet({...this._def,maxSize:{value:maxSize,message:errorUtil.toString(message)}})}size(size,message){return this.min(size,message).max(size,message)}nonempty(message){return this.min(1,message)}};ZodSet.create=(valueType,params)=>{return new ZodSet({valueType,minSize:null,maxSize:null,typeName:ZodFirstPartyTypeKind.ZodSet,...processCreateParams(params)})};ZodFunction=class ZodFunction extends ZodType{constructor(){super(...arguments);this.validate=this.implement}_parse(input){let{ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.function)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.function,received:ctx.parsedType}),INVALID;function makeArgsIssue(args,error){return makeIssue({data:args,path:ctx.path,errorMaps:[ctx.common.contextualErrorMap,ctx.schemaErrorMap,getErrorMap(),en_default].filter((x)=>!!x),issueData:{code:ZodIssueCode.invalid_arguments,argumentsError:error}})}function makeReturnsIssue(returns,error){return makeIssue({data:returns,path:ctx.path,errorMaps:[ctx.common.contextualErrorMap,ctx.schemaErrorMap,getErrorMap(),en_default].filter((x)=>!!x),issueData:{code:ZodIssueCode.invalid_return_type,returnTypeError:error}})}let params={errorMap:ctx.common.contextualErrorMap},fn=ctx.data;if(this._def.returns instanceof ZodPromise){let me=this;return OK(async function(...args){let error=new ZodError([]),parsedArgs=await me._def.args.parseAsync(args,params).catch((e)=>{throw error.addIssue(makeArgsIssue(args,e)),error}),result2=await Reflect.apply(fn,this,parsedArgs);return await me._def.returns._def.type.parseAsync(result2,params).catch((e)=>{throw error.addIssue(makeReturnsIssue(result2,e)),error})})}else{let me=this;return OK(function(...args){let parsedArgs=me._def.args.safeParse(args,params);if(!parsedArgs.success)throw new ZodError([makeArgsIssue(args,parsedArgs.error)]);let result2=Reflect.apply(fn,this,parsedArgs.data),parsedReturns=me._def.returns.safeParse(result2,params);if(!parsedReturns.success)throw new ZodError([makeReturnsIssue(result2,parsedReturns.error)]);return parsedReturns.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...items){return new ZodFunction({...this._def,args:ZodTuple.create(items).rest(ZodUnknown.create())})}returns(returnType){return new ZodFunction({...this._def,returns:returnType})}implement(func){return this.parse(func)}strictImplement(func){return this.parse(func)}static create(args,returns,params){return new ZodFunction({args:args?args:ZodTuple.create([]).rest(ZodUnknown.create()),returns:returns||ZodUnknown.create(),typeName:ZodFirstPartyTypeKind.ZodFunction,...processCreateParams(params)})}};ZodLazy=class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(input){let{ctx}=this._processInputParams(input);return this._def.getter()._parse({data:ctx.data,path:ctx.path,parent:ctx})}};ZodLazy.create=(getter,params)=>{return new ZodLazy({getter,typeName:ZodFirstPartyTypeKind.ZodLazy,...processCreateParams(params)})};ZodLiteral=class ZodLiteral extends ZodType{_parse(input){if(input.data!==this._def.value){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{received:ctx.data,code:ZodIssueCode.invalid_literal,expected:this._def.value}),INVALID}return{status:"valid",value:input.data}}get value(){return this._def.value}};ZodLiteral.create=(value,params)=>{return new ZodLiteral({value,typeName:ZodFirstPartyTypeKind.ZodLiteral,...processCreateParams(params)})};ZodEnum=class ZodEnum extends ZodType{_parse(input){if(typeof input.data!=="string"){let ctx=this._getOrReturnCtx(input),expectedValues=this._def.values;return addIssueToContext(ctx,{expected:util.joinValues(expectedValues),received:ctx.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(input.data)){let ctx=this._getOrReturnCtx(input),expectedValues=this._def.values;return addIssueToContext(ctx,{received:ctx.data,code:ZodIssueCode.invalid_enum_value,options:expectedValues}),INVALID}return OK(input.data)}get options(){return this._def.values}get enum(){let enumValues={};for(let val of this._def.values)enumValues[val]=val;return enumValues}get Values(){let enumValues={};for(let val of this._def.values)enumValues[val]=val;return enumValues}get Enum(){let enumValues={};for(let val of this._def.values)enumValues[val]=val;return enumValues}extract(values,newDef=this._def){return ZodEnum.create(values,{...this._def,...newDef})}exclude(values,newDef=this._def){return ZodEnum.create(this.options.filter((opt)=>!values.includes(opt)),{...this._def,...newDef})}};ZodEnum.create=createZodEnum;ZodNativeEnum=class ZodNativeEnum extends ZodType{_parse(input){let nativeEnumValues=util.getValidEnumValues(this._def.values),ctx=this._getOrReturnCtx(input);if(ctx.parsedType!==ZodParsedType.string&&ctx.parsedType!==ZodParsedType.number){let expectedValues=util.objectValues(nativeEnumValues);return addIssueToContext(ctx,{expected:util.joinValues(expectedValues),received:ctx.parsedType,code:ZodIssueCode.invalid_type}),INVALID}if(!this._cache)this._cache=new Set(util.getValidEnumValues(this._def.values));if(!this._cache.has(input.data)){let expectedValues=util.objectValues(nativeEnumValues);return addIssueToContext(ctx,{received:ctx.data,code:ZodIssueCode.invalid_enum_value,options:expectedValues}),INVALID}return OK(input.data)}get enum(){return this._def.values}};ZodNativeEnum.create=(values,params)=>{return new ZodNativeEnum({values,typeName:ZodFirstPartyTypeKind.ZodNativeEnum,...processCreateParams(params)})};ZodPromise=class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(input){let{ctx}=this._processInputParams(input);if(ctx.parsedType!==ZodParsedType.promise&&ctx.common.async===!1)return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.promise,received:ctx.parsedType}),INVALID;let promisified=ctx.parsedType===ZodParsedType.promise?ctx.data:Promise.resolve(ctx.data);return OK(promisified.then((data)=>{return this._def.type.parseAsync(data,{path:ctx.path,errorMap:ctx.common.contextualErrorMap})}))}};ZodPromise.create=(schema,params)=>{return new ZodPromise({type:schema,typeName:ZodFirstPartyTypeKind.ZodPromise,...processCreateParams(params)})};ZodEffects=class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ZodFirstPartyTypeKind.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(input){let{status,ctx}=this._processInputParams(input),effect=this._def.effect||null,checkCtx={addIssue:(arg)=>{if(addIssueToContext(ctx,arg),arg.fatal)status.abort();else status.dirty()},get path(){return ctx.path}};if(checkCtx.addIssue=checkCtx.addIssue.bind(checkCtx),effect.type==="preprocess"){let processed=effect.transform(ctx.data,checkCtx);if(ctx.common.async)return Promise.resolve(processed).then(async(processed2)=>{if(status.value==="aborted")return INVALID;let result2=await this._def.schema._parseAsync({data:processed2,path:ctx.path,parent:ctx});if(result2.status==="aborted")return INVALID;if(result2.status==="dirty")return DIRTY(result2.value);if(status.value==="dirty")return DIRTY(result2.value);return result2});else{if(status.value==="aborted")return INVALID;let result2=this._def.schema._parseSync({data:processed,path:ctx.path,parent:ctx});if(result2.status==="aborted")return INVALID;if(result2.status==="dirty")return DIRTY(result2.value);if(status.value==="dirty")return DIRTY(result2.value);return result2}}if(effect.type==="refinement"){let executeRefinement=(acc)=>{let result2=effect.refinement(acc,checkCtx);if(ctx.common.async)return Promise.resolve(result2);if(result2 instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return acc};if(ctx.common.async===!1){let inner=this._def.schema._parseSync({data:ctx.data,path:ctx.path,parent:ctx});if(inner.status==="aborted")return INVALID;if(inner.status==="dirty")status.dirty();return executeRefinement(inner.value),{status:status.value,value:inner.value}}else return this._def.schema._parseAsync({data:ctx.data,path:ctx.path,parent:ctx}).then((inner)=>{if(inner.status==="aborted")return INVALID;if(inner.status==="dirty")status.dirty();return executeRefinement(inner.value).then(()=>{return{status:status.value,value:inner.value}})})}if(effect.type==="transform")if(ctx.common.async===!1){let base=this._def.schema._parseSync({data:ctx.data,path:ctx.path,parent:ctx});if(!isValid(base))return INVALID;let result2=effect.transform(base.value,checkCtx);if(result2 instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:status.value,value:result2}}else return this._def.schema._parseAsync({data:ctx.data,path:ctx.path,parent:ctx}).then((base)=>{if(!isValid(base))return INVALID;return Promise.resolve(effect.transform(base.value,checkCtx)).then((result2)=>({status:status.value,value:result2}))});util.assertNever(effect)}};ZodEffects.create=(schema,effect,params)=>{return new ZodEffects({schema,typeName:ZodFirstPartyTypeKind.ZodEffects,effect,...processCreateParams(params)})};ZodEffects.createWithPreprocess=(preprocess,schema,params)=>{return new ZodEffects({schema,effect:{type:"preprocess",transform:preprocess},typeName:ZodFirstPartyTypeKind.ZodEffects,...processCreateParams(params)})};ZodOptional=class ZodOptional extends ZodType{_parse(input){if(this._getType(input)===ZodParsedType.undefined)return OK(void 0);return this._def.innerType._parse(input)}unwrap(){return this._def.innerType}};ZodOptional.create=(type,params)=>{return new ZodOptional({innerType:type,typeName:ZodFirstPartyTypeKind.ZodOptional,...processCreateParams(params)})};ZodNullable=class ZodNullable extends ZodType{_parse(input){if(this._getType(input)===ZodParsedType.null)return OK(null);return this._def.innerType._parse(input)}unwrap(){return this._def.innerType}};ZodNullable.create=(type,params)=>{return new ZodNullable({innerType:type,typeName:ZodFirstPartyTypeKind.ZodNullable,...processCreateParams(params)})};ZodDefault=class ZodDefault extends ZodType{_parse(input){let{ctx}=this._processInputParams(input),data=ctx.data;if(ctx.parsedType===ZodParsedType.undefined)data=this._def.defaultValue();return this._def.innerType._parse({data,path:ctx.path,parent:ctx})}removeDefault(){return this._def.innerType}};ZodDefault.create=(type,params)=>{return new ZodDefault({innerType:type,typeName:ZodFirstPartyTypeKind.ZodDefault,defaultValue:typeof params.default==="function"?params.default:()=>params.default,...processCreateParams(params)})};ZodCatch=class ZodCatch extends ZodType{_parse(input){let{ctx}=this._processInputParams(input),newCtx={...ctx,common:{...ctx.common,issues:[]}},result2=this._def.innerType._parse({data:newCtx.data,path:newCtx.path,parent:{...newCtx}});if(isAsync(result2))return result2.then((result3)=>{return{status:"valid",value:result3.status==="valid"?result3.value:this._def.catchValue({get error(){return new ZodError(newCtx.common.issues)},input:newCtx.data})}});else return{status:"valid",value:result2.status==="valid"?result2.value:this._def.catchValue({get error(){return new ZodError(newCtx.common.issues)},input:newCtx.data})}}removeCatch(){return this._def.innerType}};ZodCatch.create=(type,params)=>{return new ZodCatch({innerType:type,typeName:ZodFirstPartyTypeKind.ZodCatch,catchValue:typeof params.catch==="function"?params.catch:()=>params.catch,...processCreateParams(params)})};ZodNaN=class ZodNaN extends ZodType{_parse(input){if(this._getType(input)!==ZodParsedType.nan){let ctx=this._getOrReturnCtx(input);return addIssueToContext(ctx,{code:ZodIssueCode.invalid_type,expected:ZodParsedType.nan,received:ctx.parsedType}),INVALID}return{status:"valid",value:input.data}}};ZodNaN.create=(params)=>{return new ZodNaN({typeName:ZodFirstPartyTypeKind.ZodNaN,...processCreateParams(params)})};BRAND=Symbol("zod_brand");ZodBranded=class ZodBranded extends ZodType{_parse(input){let{ctx}=this._processInputParams(input),data=ctx.data;return this._def.type._parse({data,path:ctx.path,parent:ctx})}unwrap(){return this._def.type}};ZodPipeline=class ZodPipeline extends ZodType{_parse(input){let{status,ctx}=this._processInputParams(input);if(ctx.common.async)return(async()=>{let inResult=await this._def.in._parseAsync({data:ctx.data,path:ctx.path,parent:ctx});if(inResult.status==="aborted")return INVALID;if(inResult.status==="dirty")return status.dirty(),DIRTY(inResult.value);else return this._def.out._parseAsync({data:inResult.value,path:ctx.path,parent:ctx})})();else{let inResult=this._def.in._parseSync({data:ctx.data,path:ctx.path,parent:ctx});if(inResult.status==="aborted")return INVALID;if(inResult.status==="dirty")return status.dirty(),{status:"dirty",value:inResult.value};else return this._def.out._parseSync({data:inResult.value,path:ctx.path,parent:ctx})}}static create(a,b){return new ZodPipeline({in:a,out:b,typeName:ZodFirstPartyTypeKind.ZodPipeline})}};ZodReadonly=class ZodReadonly extends ZodType{_parse(input){let result2=this._def.innerType._parse(input),freeze=(data)=>{if(isValid(data))data.value=Object.freeze(data.value);return data};return isAsync(result2)?result2.then((data)=>freeze(data)):freeze(result2)}unwrap(){return this._def.innerType}};ZodReadonly.create=(type,params)=>{return new ZodReadonly({innerType:type,typeName:ZodFirstPartyTypeKind.ZodReadonly,...processCreateParams(params)})};late={object:ZodObject.lazycreate};(function(ZodFirstPartyTypeKind2){ZodFirstPartyTypeKind2.ZodString="ZodString",ZodFirstPartyTypeKind2.ZodNumber="ZodNumber",ZodFirstPartyTypeKind2.ZodNaN="ZodNaN",ZodFirstPartyTypeKind2.ZodBigInt="ZodBigInt",ZodFirstPartyTypeKind2.ZodBoolean="ZodBoolean",ZodFirstPartyTypeKind2.ZodDate="ZodDate",ZodFirstPartyTypeKind2.ZodSymbol="ZodSymbol",ZodFirstPartyTypeKind2.ZodUndefined="ZodUndefined",ZodFirstPartyTypeKind2.ZodNull="ZodNull",ZodFirstPartyTypeKind2.ZodAny="ZodAny",ZodFirstPartyTypeKind2.ZodUnknown="ZodUnknown",ZodFirstPartyTypeKind2.ZodNever="ZodNever",ZodFirstPartyTypeKind2.ZodVoid="ZodVoid",ZodFirstPartyTypeKind2.ZodArray="ZodArray",ZodFirstPartyTypeKind2.ZodObject="ZodObject",ZodFirstPartyTypeKind2.ZodUnion="ZodUnion",ZodFirstPartyTypeKind2.ZodDiscriminatedUnion="ZodDiscriminatedUnion",ZodFirstPartyTypeKind2.ZodIntersection="ZodIntersection",ZodFirstPartyTypeKind2.ZodTuple="ZodTuple",ZodFirstPartyTypeKind2.ZodRecord="ZodRecord",ZodFirstPartyTypeKind2.ZodMap="ZodMap",ZodFirstPartyTypeKind2.ZodSet="ZodSet",ZodFirstPartyTypeKind2.ZodFunction="ZodFunction",ZodFirstPartyTypeKind2.ZodLazy="ZodLazy",ZodFirstPartyTypeKind2.ZodLiteral="ZodLiteral",ZodFirstPartyTypeKind2.ZodEnum="ZodEnum",ZodFirstPartyTypeKind2.ZodEffects="ZodEffects",ZodFirstPartyTypeKind2.ZodNativeEnum="ZodNativeEnum",ZodFirstPartyTypeKind2.ZodOptional="ZodOptional",ZodFirstPartyTypeKind2.ZodNullable="ZodNullable",ZodFirstPartyTypeKind2.ZodDefault="ZodDefault",ZodFirstPartyTypeKind2.ZodCatch="ZodCatch",ZodFirstPartyTypeKind2.ZodPromise="ZodPromise",ZodFirstPartyTypeKind2.ZodBranded="ZodBranded",ZodFirstPartyTypeKind2.ZodPipeline="ZodPipeline",ZodFirstPartyTypeKind2.ZodReadonly="ZodReadonly"})(ZodFirstPartyTypeKind||(ZodFirstPartyTypeKind={}));stringType=ZodString.create,numberType=ZodNumber.create,nanType=ZodNaN.create,bigIntType=ZodBigInt.create,booleanType=ZodBoolean.create,dateType=ZodDate.create,symbolType=ZodSymbol.create,undefinedType=ZodUndefined.create,nullType=ZodNull.create,anyType=ZodAny.create,unknownType=ZodUnknown.create,neverType=ZodNever.create,voidType=ZodVoid.create,arrayType=ZodArray.create,objectType=ZodObject.create,strictObjectType=ZodObject.strictCreate,unionType=ZodUnion.create,discriminatedUnionType=ZodDiscriminatedUnion.create,intersectionType=ZodIntersection.create,tupleType=ZodTuple.create,recordType=ZodRecord.create,mapType=ZodMap.create,setType=ZodSet.create,functionType=ZodFunction.create,lazyType=ZodLazy.create,literalType=ZodLiteral.create,enumType=ZodEnum.create,nativeEnumType=ZodNativeEnum.create,promiseType=ZodPromise.create,effectsType=ZodEffects.create,optionalType=ZodOptional.create,nullableType=ZodNullable.create,preprocessType=ZodEffects.createWithPreprocess,pipelineType=ZodPipeline.create,coerce={string:(arg)=>ZodString.create({...arg,coerce:!0}),number:(arg)=>ZodNumber.create({...arg,coerce:!0}),boolean:(arg)=>ZodBoolean.create({...arg,coerce:!0}),bigint:(arg)=>ZodBigInt.create({...arg,coerce:!0}),date:(arg)=>ZodDate.create({...arg,coerce:!0})},NEVER=INVALID});var exports_external={};__export(exports_external,{void:()=>voidType,util:()=>util,unknown:()=>unknownType,union:()=>unionType,undefined:()=>undefinedType,tuple:()=>tupleType,transformer:()=>effectsType,symbol:()=>symbolType,string:()=>stringType,strictObject:()=>strictObjectType,setErrorMap:()=>setErrorMap,set:()=>setType,record:()=>recordType,quotelessJson:()=>quotelessJson,promise:()=>promiseType,preprocess:()=>preprocessType,pipeline:()=>pipelineType,ostring:()=>ostring,optional:()=>optionalType,onumber:()=>onumber,oboolean:()=>oboolean,objectUtil:()=>objectUtil,object:()=>objectType,number:()=>numberType,nullable:()=>nullableType,null:()=>nullType,never:()=>neverType,nativeEnum:()=>nativeEnumType,nan:()=>nanType,map:()=>mapType,makeIssue:()=>makeIssue,literal:()=>literalType,lazy:()=>lazyType,late:()=>late,isValid:()=>isValid,isDirty:()=>isDirty,isAsync:()=>isAsync,isAborted:()=>isAborted,intersection:()=>intersectionType,instanceof:()=>instanceOfType,getParsedType:()=>getParsedType,getErrorMap:()=>getErrorMap,function:()=>functionType,enum:()=>enumType,effect:()=>effectsType,discriminatedUnion:()=>discriminatedUnionType,defaultErrorMap:()=>en_default,datetimeRegex:()=>datetimeRegex,date:()=>dateType,custom:()=>custom,coerce:()=>coerce,boolean:()=>booleanType,bigint:()=>bigIntType,array:()=>arrayType,any:()=>anyType,addIssueToContext:()=>addIssueToContext,ZodVoid:()=>ZodVoid,ZodUnknown:()=>ZodUnknown,ZodUnion:()=>ZodUnion,ZodUndefined:()=>ZodUndefined,ZodType:()=>ZodType,ZodTuple:()=>ZodTuple,ZodTransformer:()=>ZodEffects,ZodSymbol:()=>ZodSymbol,ZodString:()=>ZodString,ZodSet:()=>ZodSet,ZodSchema:()=>ZodType,ZodRecord:()=>ZodRecord,ZodReadonly:()=>ZodReadonly,ZodPromise:()=>ZodPromise,ZodPipeline:()=>ZodPipeline,ZodParsedType:()=>ZodParsedType,ZodOptional:()=>ZodOptional,ZodObject:()=>ZodObject,ZodNumber:()=>ZodNumber,ZodNullable:()=>ZodNullable,ZodNull:()=>ZodNull,ZodNever:()=>ZodNever,ZodNativeEnum:()=>ZodNativeEnum,ZodNaN:()=>ZodNaN,ZodMap:()=>ZodMap,ZodLiteral:()=>ZodLiteral,ZodLazy:()=>ZodLazy,ZodIssueCode:()=>ZodIssueCode,ZodIntersection:()=>ZodIntersection,ZodFunction:()=>ZodFunction,ZodFirstPartyTypeKind:()=>ZodFirstPartyTypeKind,ZodError:()=>ZodError,ZodEnum:()=>ZodEnum,ZodEffects:()=>ZodEffects,ZodDiscriminatedUnion:()=>ZodDiscriminatedUnion,ZodDefault:()=>ZodDefault,ZodDate:()=>ZodDate,ZodCatch:()=>ZodCatch,ZodBranded:()=>ZodBranded,ZodBoolean:()=>ZodBoolean,ZodBigInt:()=>ZodBigInt,ZodArray:()=>ZodArray,ZodAny:()=>ZodAny,Schema:()=>ZodType,ParseStatus:()=>ParseStatus,OK:()=>OK,NEVER:()=>NEVER,INVALID:()=>INVALID,EMPTY_PATH:()=>EMPTY_PATH,DIRTY:()=>DIRTY,BRAND:()=>BRAND});var init_external=__esm(()=>{init_errors();init_parseUtil();init_typeAliases();init_util();init_types();init_ZodError()});var init_zod=__esm(()=>{init_external();init_external()});var exports_types={};__export(exports_types,{isBlockingEvent:()=>isBlockingEvent,DISPATCHED_EVENT_MATCHERS:()=>DISPATCHED_EVENT_MATCHERS,DISPATCHED_EVENTS:()=>DISPATCHED_EVENTS,CODEX_DISPATCHED_EVENT_MATCHERS:()=>CODEX_DISPATCHED_EVENT_MATCHERS});function isBlockingEvent(event){return BLOCKING_EVENTS.has(event)}var DISPATCHED_EVENT_MATCHERS,CODEX_DISPATCHED_EVENT_MATCHERS,DISPATCHED_EVENTS,BLOCKING_EVENTS;var init_types2=__esm(()=>{DISPATCHED_EVENT_MATCHERS={PreToolUse:"*",PostToolUse:"SendMessage"},CODEX_DISPATCHED_EVENT_MATCHERS={PreToolUse:"*",PostToolUse:"SendMessage",UserPromptSubmit:"*",Stop:"*"},DISPATCHED_EVENTS=Object.keys(DISPATCHED_EVENT_MATCHERS),BLOCKING_EVENTS=new Set(["PreToolUse","UserPromptSubmit","TeammateIdle","TaskCompleted","PermissionRequest"])});var exports_inject={};__export(exports_inject,{isTeamHooked:()=>isTeamHooked,injectTeamHooks:()=>injectTeamHooks,buildDispatchCommand:()=>buildDispatchCommand});import{existsSync as existsSync2}from"fs";import{mkdir,readFile as readFile2,writeFile as writeFile2}from"fs/promises";import{homedir as homedir2}from"os";import{join as join3}from"path";import{fileURLToPath}from"url";function escapeShellArg(arg){return`'${arg.replace(/'/g,"'\\''")}'`}function compiledBinaryCandidates(){let candidates=[];if(process.env.GENIE_HOOK_BIN)candidates.push(process.env.GENIE_HOOK_BIN);let home=process.env.GENIE_HOME??join3(homedir2(),".genie");candidates.push(join3(home,"bin","genie-hook"));try{let repoBin=fileURLToPath(new URL("../../dist/genie-hook",import.meta.url));candidates.push(repoBin)}catch{}return candidates}function buildDispatchCommand(){for(let candidate of compiledBinaryCandidates())if(existsSync2(candidate))return escapeShellArg(candidate);let entrypoint=fileURLToPath(new URL("../genie.ts",import.meta.url));if(!existsSync2(entrypoint))return"genie hook dispatch";let bun=process.execPath||"bun";return`${escapeShellArg(bun)} run ${escapeShellArg(entrypoint)} hook dispatch`}function isGenieDispatchCommand(command){if(typeof command!=="string")return!1;if(/(?:^|\s)hook\s+dispatch(?:\s|$)/.test(command))return!0;if(/(?:^|[/\\'"])genie-hook(?:['"]|\s|$)/.test(command))return!0;return!1}function claudeConfigDir(){return process.env.CLAUDE_CONFIG_DIR??join3(homedir2(),".claude")}function teamSettingsPath(teamName){let sanitized=teamName.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase();return join3(claudeConfigDir(),"teams",sanitized,"settings.json")}function buildHooksConfig(){let hooks={},dispatchCommand=buildDispatchCommand();for(let[event,matcher]of Object.entries(DISPATCHED_EVENT_MATCHERS))hooks[event]=[{matcher,hooks:[{type:"command",command:dispatchCommand,timeout:DISPATCH_TIMEOUT}]}];return hooks}async function readSettings(settingsPath){if(!existsSync2(settingsPath))return{};try{return JSON.parse(await readFile2(settingsPath,"utf-8"))}catch{return{}}}function allEventsAlreadyInjected(existingHooks,hooksConfig){return DISPATCHED_EVENTS.every((event)=>{let existing=existingHooks[event],desiredCommand=hooksConfig[event][0].hooks[0].command,desiredMatcher=hooksConfig[event][0].matcher;return existing?.some((m)=>m.matcher===desiredMatcher&&m.hooks?.some((h)=>h.command===desiredCommand))})}function hasNoObsoleteGenieEntries(existingHooks){return Object.keys(existingHooks).every((event)=>{if(DISPATCHED_EVENTS.includes(event))return!0;return!existingHooks[event]?.some((m)=>m.hooks?.some((h)=>isGenieDispatchCommand(h.command)))})}function pruneObsoleteGenieEntries(mergedHooks){for(let event of Object.keys(mergedHooks)){if(DISPATCHED_EVENTS.includes(event))continue;let cleaned=(mergedHooks[event]??[]).map((matcher)=>({...matcher,hooks:matcher.hooks?.filter((hook)=>!isGenieDispatchCommand(hook.command))})).filter((matcher)=>(matcher.hooks?.length??0)>0);if(cleaned.length===0)delete mergedHooks[event];else mergedHooks[event]=cleaned}}function refreshMatcherEntries(entries,genieEntry){return entries.map((matcher)=>{let hasGenieHook=matcher.hooks?.some((h)=>isGenieDispatchCommand(h.command));return{...matcher,matcher:hasGenieHook?genieEntry.matcher:matcher.matcher,hooks:matcher.hooks?.map((hook)=>isGenieDispatchCommand(hook.command)?{...hook,command:genieEntry.hooks[0].command,timeout:DISPATCH_TIMEOUT}:hook)}})}function upsertGenieEntry(mergedHooks,event,genieEntry){let existingEntries=refreshMatcherEntries(mergedHooks[event]??[],genieEntry),alreadyPresent=existingEntries.some((m)=>m.hooks?.some((h)=>isGenieDispatchCommand(h.command)));mergedHooks[event]=alreadyPresent?existingEntries:[...existingEntries,genieEntry]}async function injectIntoFile(settingsPath){let settings=await readSettings(settingsPath),hooksConfig=buildHooksConfig(),existingHooks=settings.hooks,hooksAlreadyClean=!!existingHooks&&allEventsAlreadyInjected(existingHooks,hooksConfig)&&hasNoObsoleteGenieEntries(existingHooks),permissionsChanged=ensureBaselineAllowedTools(settings);if(hooksAlreadyClean&&!permissionsChanged)return!1;if(!hooksAlreadyClean){let mergedHooks=existingHooks?{...existingHooks}:{};pruneObsoleteGenieEntries(mergedHooks);for(let event of DISPATCHED_EVENTS)upsertGenieEntry(mergedHooks,event,hooksConfig[event][0]);settings.hooks=mergedHooks}let dir=join3(settingsPath,"..");return await mkdir(dir,{recursive:!0}),await writeFile2(settingsPath,JSON.stringify(settings,null,2)),!0}async function injectTeamHooks(teamName){let path=teamSettingsPath(teamName);return injectIntoFile(path)}async function isTeamHooked(teamName){let path=teamSettingsPath(teamName);if(!existsSync2(path))return!1;try{let content=await readFile2(path,"utf-8"),hooks=JSON.parse(content).hooks;if(!hooks)return!1;return DISPATCHED_EVENTS.every((event)=>{return hooks[event]?.some((m)=>m.hooks?.some((h)=>isGenieDispatchCommand(h.command)))})}catch{return!1}}var DISPATCH_TIMEOUT=15;var init_inject=__esm(()=>{init_claude_settings();init_types2()});function normalizeValue(v){if(v===void 0||v===null)return;if(v==="")return;if(v==="inherit")return;return v}function resolveField(agent,field,ctx){return resolveFieldWithSource(agent,field,ctx).value}function resolveFieldWithSource(agent,field,ctx){let agentVal=normalizeValue(agent[field]);if(agentVal!==void 0)return{value:agentVal,source:"explicit"};if(ctx.parent){let parentVal=normalizeValue(ctx.parent.fields[field]);if(parentVal!==void 0)return{value:parentVal,source:`parent:${ctx.parent.name}`}}if(ctx.workspaceDefaults){let wsVal=normalizeValue(ctx.workspaceDefaults[field]);if(wsVal!==void 0)return{value:wsVal,source:"workspace"}}return{value:BUILTIN_DEFAULTS[field],source:"built-in"}}function computeEffectiveDefaults(workspaceDefaults){if(!workspaceDefaults)return{...BUILTIN_DEFAULTS};let result2={...BUILTIN_DEFAULTS};for(let key of Object.keys(BUILTIN_DEFAULTS)){let wsVal=normalizeValue(workspaceDefaults[key]);if(wsVal!==void 0)result2[key]=wsVal}return result2}var BUILTIN_DEFAULTS,RESOLVED_FIELDS;var init_defaults=__esm(()=>{BUILTIN_DEFAULTS={model:"opus",promptMode:"append",color:"blue",effort:"high",thinking:"enabled",permissionMode:"auto"},RESOLVED_FIELDS=["model"]});var exports_js_yaml={};__export(exports_js_yaml,{types:()=>types2,safeLoadAll:()=>safeLoadAll,safeLoad:()=>safeLoad,safeDump:()=>safeDump,loadAll:()=>loadAll,load:()=>load,dump:()=>dump,default:()=>jsYaml,YAMLException:()=>YAMLException,Type:()=>Type,Schema:()=>Schema,JSON_SCHEMA:()=>JSON_SCHEMA,FAILSAFE_SCHEMA:()=>FAILSAFE_SCHEMA,DEFAULT_SCHEMA:()=>DEFAULT_SCHEMA,CORE_SCHEMA:()=>CORE_SCHEMA});function isNothing(subject){return typeof subject>"u"||subject===null}function isObject(subject){return typeof subject==="object"&&subject!==null}function toArray(sequence){if(Array.isArray(sequence))return sequence;else if(isNothing(sequence))return[];return[sequence]}function extend(target,source){var index,length,key,sourceKeys;if(source){sourceKeys=Object.keys(source);for(index=0,length=sourceKeys.length;index<length;index+=1)key=sourceKeys[index],target[key]=source[key]}return target}function repeat(string,count){var result2="",cycle;for(cycle=0;cycle<count;cycle+=1)result2+=string;return result2}function isNegativeZero(number){return number===0&&Number.NEGATIVE_INFINITY===1/number}function formatError(exception,compact){var where="",message=exception.reason||"(unknown reason)";if(!exception.mark)return message;if(exception.mark.name)where+='in "'+exception.mark.name+'" ';if(where+="("+(exception.mark.line+1)+":"+(exception.mark.column+1)+")",!compact&&exception.mark.snippet)where+=`
152
152
 
153
153
  `+exception.mark.snippet;return message+" "+where}function YAMLException$1(reason,mark){if(Error.call(this),this.name="YAMLException",this.reason=reason,this.mark=mark,this.message=formatError(this,!1),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else this.stack=Error().stack||""}function getLine(buffer,lineStart,lineEnd,position,maxLineLength){var head="",tail="",maxHalfLength=Math.floor(maxLineLength/2)-1;if(position-lineStart>maxHalfLength)head=" ... ",lineStart=position-maxHalfLength+head.length;if(lineEnd-position>maxHalfLength)tail=" ...",lineEnd=position+maxHalfLength-tail.length;return{str:head+buffer.slice(lineStart,lineEnd).replace(/\t/g,"\u2192")+tail,pos:position-lineStart+head.length}}function padStart(string,max){return common.repeat(" ",max-string.length)+string}function makeSnippet(mark,options){if(options=Object.create(options||null),!mark.buffer)return null;if(!options.maxLength)options.maxLength=79;if(typeof options.indent!=="number")options.indent=1;if(typeof options.linesBefore!=="number")options.linesBefore=3;if(typeof options.linesAfter!=="number")options.linesAfter=2;var re=/\r?\n|\r|\0/g,lineStarts=[0],lineEnds=[],match,foundLineNo=-1;while(match=re.exec(mark.buffer))if(lineEnds.push(match.index),lineStarts.push(match.index+match[0].length),mark.position<=match.index&&foundLineNo<0)foundLineNo=lineStarts.length-2;if(foundLineNo<0)foundLineNo=lineStarts.length-1;var result2="",i,line,lineNoLength=Math.min(mark.line+options.linesAfter,lineEnds.length).toString().length,maxLineLength=options.maxLength-(options.indent+lineNoLength+3);for(i=1;i<=options.linesBefore;i++){if(foundLineNo-i<0)break;line=getLine(mark.buffer,lineStarts[foundLineNo-i],lineEnds[foundLineNo-i],mark.position-(lineStarts[foundLineNo]-lineStarts[foundLineNo-i]),maxLineLength),result2=common.repeat(" ",options.indent)+padStart((mark.line-i+1).toString(),lineNoLength)+" | "+line.str+`
154
154
  `+result2}line=getLine(mark.buffer,lineStarts[foundLineNo],lineEnds[foundLineNo],mark.position,maxLineLength),result2+=common.repeat(" ",options.indent)+padStart((mark.line+1).toString(),lineNoLength)+" | "+line.str+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/genie",
3
- "version": "4.260508.2",
3
+ "version": "4.260508.3",
4
4
  "description": "Collaborative terminal toolkit for human + AI workflows. NOTE: the npm distribution is being soft-deprecated — the canonical install is `curl -fsSL https://get.automagik.dev/genie | bash` (cosign + SLSA verified). See https://automagik.dev/genie/security/distribution-sovereignty",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genie",
3
- "version": "4.260508.2",
3
+ "version": "4.260508.3",
4
4
  "description": "Human-AI partnership for Claude Code. Share a terminal, orchestrate workers, evolve together. Brainstorm ideas, turn them into wishes, execute with /work, validate with /review, and ship as one team.",
5
5
  "author": {
6
6
  "name": "Namastex Labs"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genie-plugin",
3
- "version": "4.260508.2",
3
+ "version": "4.260508.3",
4
4
  "private": true,
5
5
  "description": "Runtime dependencies for genie bundled CLIs",
6
6
  "type": "module",