@tokmizer/plugin 0.9.50 → 0.9.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,43 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
3
- var or=Object.defineProperty;var ar=(t,e)=>{for(var n in e)or(t,n,{get:e[n],enumerable:!0})};import{readdir as _s,readFile as vs}from"node:fs/promises";import{join as jt,dirname as xs}from"node:path";import{fileURLToPath as bs}from"node:url";var m={};ar(m,{BRAND:()=>Nr,DIRTY:()=>J,EMPTY_PATH:()=>dr,INVALID:()=>v,NEVER:()=>ys,OK:()=>R,ParseStatus:()=>A,Schema:()=>k,ZodAny:()=>G,ZodArray:()=>V,ZodBigInt:()=>Q,ZodBoolean:()=>ee,ZodBranded:()=>Te,ZodCatch:()=>de,ZodDate:()=>te,ZodDefault:()=>ue,ZodDiscriminatedUnion:()=>je,ZodEffects:()=>P,ZodEnum:()=>ce,ZodError:()=>C,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>Be,ZodIntersection:()=>ie,ZodIssueCode:()=>f,ZodLazy:()=>oe,ZodLiteral:()=>ae,ZodMap:()=>_e,ZodNaN:()=>xe,ZodNativeEnum:()=>le,ZodNever:()=>M,ZodNull:()=>re,ZodNullable:()=>z,ZodNumber:()=>X,ZodObject:()=>O,ZodOptional:()=>D,ZodParsedType:()=>g,ZodPipeline:()=>Ae,ZodPromise:()=>Y,ZodReadonly:()=>fe,ZodRecord:()=>ze,ZodSchema:()=>k,ZodSet:()=>ve,ZodString:()=>W,ZodSymbol:()=>ge,ZodTransformer:()=>P,ZodTuple:()=>j,ZodType:()=>k,ZodUndefined:()=>ne,ZodUnion:()=>se,ZodUnknown:()=>U,ZodVoid:()=>ye,addIssueToContext:()=>h,any:()=>Zr,array:()=>Kr,bigint:()=>Lr,boolean:()=>Mt,coerce:()=>gs,custom:()=>Nt,date:()=>Fr,datetimeRegex:()=>It,defaultErrorMap:()=>B,discriminatedUnion:()=>qr,effect:()=>cs,enum:()=>is,function:()=>ns,getErrorMap:()=>pe,getParsedType:()=>F,instanceof:()=>$r,intersection:()=>Jr,isAborted:()=>Le,isAsync:()=>me,isDirty:()=>Fe,isValid:()=>K,late:()=>Pr,lazy:()=>rs,literal:()=>ss,makeIssue:()=>Se,map:()=>es,nan:()=>Mr,nativeEnum:()=>os,never:()=>Vr,null:()=>Br,nullable:()=>us,number:()=>$t,object:()=>Wr,objectUtil:()=>Xe,oboolean:()=>hs,onumber:()=>ms,optional:()=>ls,ostring:()=>ps,pipeline:()=>fs,preprocess:()=>ds,promise:()=>as,quotelessJson:()=>cr,record:()=>Qr,set:()=>ts,setErrorMap:()=>ur,strictObject:()=>Gr,string:()=>Pt,symbol:()=>jr,transformer:()=>cs,tuple:()=>Xr,undefined:()=>zr,union:()=>Yr,unknown:()=>Ur,util:()=>E,void:()=>Hr});var E;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(E||(E={}));var Xe;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Xe||(Xe={}));var g=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),F=t=>{switch(typeof t){case"undefined":return g.undefined;case"string":return g.string;case"number":return Number.isNaN(t)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}};var f=E.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"]),cr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),C=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,c=0;for(;c<o.path.length;){let l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(n(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};C.create=t=>new C(t);var lr=(t,e)=>{let n;switch(t.code){case f.invalid_type:t.received===g.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,E.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:n=`Unrecognized key(s) in object: ${E.joinValues(t.keys,", ")}`;break;case f.invalid_union:n="Invalid input";break;case f.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${E.joinValues(t.options)}`;break;case f.invalid_enum_value:n=`Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:n="Invalid function arguments";break;case f.invalid_return_type:n="Invalid function return type";break;case f.invalid_date:n="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:E.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case f.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case f.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case f.custom:n="Invalid input";break;case f.invalid_intersection_types:n="Intersection results could not be merged";break;case f.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:n="Number must be finite";break;default:n=e.defaultError,E.assertNever(t)}return{message:n}},B=lr;var Tt=B;function ur(t){Tt=t}function pe(){return Tt}var Se=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)a=l(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},dr=[];function h(t,e){let n=pe(),r=Se({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===B?void 0:B].filter(s=>!!s)});t.common.issues.push(r)}var A=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},v=Object.freeze({status:"aborted"}),J=t=>({status:"dirty",value:t}),R=t=>({status:"valid",value:t}),Le=t=>t.status==="aborted",Fe=t=>t.status==="dirty",K=t=>t.status==="valid",me=t=>typeof Promise<"u"&&t instanceof Promise;var y;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(y||(y={}));var N=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},At=(t,e)=>{if(K(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new C(t.common.issues);return this._error=n,this._error}}};function b(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}var k=class{get description(){return this._def.description}_getType(e){return F(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:F(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new A,ctx:{common:e.parent.common,data:e.data,parsedType:F(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(me(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:F(e)},s=this._parseSync({data:e,path:r.path,parent:r});return At(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:F(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return K(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>K(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:F(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(me(s)?s:Promise.resolve(s));return At(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:f.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new P({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return D.create(this,this._def)}nullable(){return z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return V.create(this)}promise(){return Y.create(this,this._def)}or(e){return se.create([this,e],this._def)}and(e){return ie.create(this,e,this._def)}transform(e){return new P({...b(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new ue({...b(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new Te({typeName:x.ZodBranded,type:this,...b(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new de({...b(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ae.create(this,e)}readonly(){return fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},fr=/^c[^\s-]{8,}$/i,pr=/^[0-9a-z]+$/,mr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,hr=/^[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,gr=/^[a-z0-9_-]{21}$/i,yr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_r=/^[-+]?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)?)??$/,vr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Qe,br=/^(?:(?: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])$/,kr=/^(?:(?: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])$/,Er=/^(([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]))$/,wr=/^(([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])$/,Sr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Tr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ct="((\\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])))",Ar=new RegExp(`^${Ct}$`);function Ot(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Rr(t){return new RegExp(`^${Ot(t)}$`)}function It(t){let e=`${Ct}T${Ot(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Cr(t,e){return!!((e==="v4"||!e)&&br.test(t)||(e==="v6"||!e)&&Er.test(t))}function Or(t,e){if(!yr.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Ir(t,e){return!!((e==="v4"||!e)&&kr.test(t)||(e==="v6"||!e)&&wr.test(t))}var W=class t extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:g.string,received:i.parsedType}),v}let r=new A,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?h(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&h(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")vr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"email",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Qe||(Qe=new RegExp(xr,"u")),Qe.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"emoji",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")hr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"uuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")gr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"nanoid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")fr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")pr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid2",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")mr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ulid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),h(s,{validation:"url",code:f.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"regex",code:f.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?It(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Ar.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Rr(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?_r.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Cr(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ip",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Or(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"jwt",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Ir(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cidr",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Sr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Tr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:f.invalid_string,message:i.message}),r.dirty()):E.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:f.invalid_string,...y.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...y.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...y.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...y.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...y.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...y.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...y.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...y.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...y.errToObj(n)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};W.create=t=>new W({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...b(t)});function Dr(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var X=class t extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:g.number,received:i.parsedType}),v}let r,s=new A;for(let i of this._def.checks)i.kind==="int"?E.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:f.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Dr(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:f.not_finite,message:i.message}),s.dirty()):E.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,y.toString(n))}gt(e,n){return this.setLimit("min",e,!1,y.toString(n))}lte(e,n){return this.setLimit("max",e,!0,y.toString(n))}lt(e,n){return this.setLimit("max",e,!1,y.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&E.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};X.create=t=>new X({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...b(t)});var Q=class t extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==g.bigint)return this._getInvalidInput(e);let r,s=new A;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):E.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.bigint,received:n.parsedType}),v}gte(e,n){return this.setLimit("min",e,!0,y.toString(n))}gt(e,n){return this.setLimit("min",e,!1,y.toString(n))}lte(e,n){return this.setLimit("max",e,!0,y.toString(n))}lt(e,n){return this.setLimit("max",e,!1,y.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Q.create=t=>new Q({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...b(t)});var ee=class extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.boolean,received:r.parsedType}),v}return R(e.data)}};ee.create=t=>new ee({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...b(t)});var te=class t extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:g.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_date}),v}let r=new A,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):E.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:y.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};te.create=t=>new te({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...b(t)});var ge=class extends k{_parse(e){if(this._getType(e)!==g.symbol){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.symbol,received:r.parsedType}),v}return R(e.data)}};ge.create=t=>new ge({typeName:x.ZodSymbol,...b(t)});var ne=class extends k{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.undefined,received:r.parsedType}),v}return R(e.data)}};ne.create=t=>new ne({typeName:x.ZodUndefined,...b(t)});var re=class extends k{_parse(e){if(this._getType(e)!==g.null){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.null,received:r.parsedType}),v}return R(e.data)}};re.create=t=>new re({typeName:x.ZodNull,...b(t)});var G=class extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return R(e.data)}};G.create=t=>new G({typeName:x.ZodAny,...b(t)});var U=class extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return R(e.data)}};U.create=t=>new U({typeName:x.ZodUnknown,...b(t)});var M=class extends k{_parse(e){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.never,received:n.parsedType}),v}};M.create=t=>new M({typeName:x.ZodNever,...b(t)});var ye=class extends k{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.void,received:r.parsedType}),v}return R(e.data)}};ye.create=t=>new ye({typeName:x.ZodVoid,...b(t)});var V=class t extends k{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==g.array)return h(n,{code:f.invalid_type,expected:g.array,received:n.parsedType}),v;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(h(n,{code:o?f.too_big:f.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(h(n,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(h(n,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new N(n,o,n.path,a)))).then(o=>A.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new N(n,o,n.path,a)));return A.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:y.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:y.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:y.toString(n)}})}nonempty(e){return this.min(1,e)}};V.create=(t,e)=>new V({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...b(e)});function he(t){if(t instanceof O){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=D.create(he(r))}return new O({...t._def,shape:()=>e})}else return t instanceof V?new V({...t._def,type:he(t.element)}):t instanceof D?D.create(he(t.unwrap())):t instanceof z?z.create(he(t.unwrap())):t instanceof j?j.create(t.items.map(e=>he(e))):t}var O=class t extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=E.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==g.object){let l=this._getOrReturnCtx(e);return h(l,{code:f.invalid_type,expected:g.object,received:l.parsedType}),v}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(let l in s.data)o.includes(l)||a.push(l);let c=[];for(let l of o){let u=i[l],p=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new N(s,p,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof M){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")a.length>0&&(h(s,{code:f.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let p=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new N(s,p,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let p=await u.key,d=await u.value;l.push({key:p,value:d,alwaysSet:u.alwaysSet})}return l}).then(l=>A.mergeObjectSync(r,l)):A.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:y.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of E.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of E.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return he(this)}partial(e){let n={};for(let r of E.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of E.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof D;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Dt(E.objectKeys(this.shape))}};O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:M.create(),typeName:x.ZodObject,...b(e)});O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:M.create(),typeName:x.ZodObject,...b(e)});O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:M.create(),typeName:x.ZodObject,...b(e)});var se=class extends k{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new C(a.ctx.common.issues));return h(n,{code:f.invalid_union,unionErrors:o}),v}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of r){let l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new C(c));return h(n,{code:f.invalid_union,unionErrors:a}),v}}get options(){return this._def.options}};se.create=(t,e)=>new se({options:t,typeName:x.ZodUnion,...b(e)});var Z=t=>t instanceof oe?Z(t.schema):t instanceof P?Z(t.innerType()):t instanceof ae?[t.value]:t instanceof ce?t.options:t instanceof le?E.objectValues(t.enum):t instanceof ue?Z(t._def.innerType):t instanceof ne?[void 0]:t instanceof re?[null]:t instanceof D?[void 0,...Z(t.unwrap())]:t instanceof z?[null,...Z(t.unwrap())]:t instanceof Te||t instanceof fe?Z(t.unwrap()):t instanceof de?Z(t._def.innerType):[],je=class t extends k{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return h(n,{code:f.invalid_type,expected:g.object,received:n.parsedType}),v;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(h(n,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=Z(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...b(r)})}};function et(t,e){let n=F(t),r=F(e);if(t===e)return{valid:!0,data:t};if(n===g.object&&r===g.object){let s=E.objectKeys(e),i=E.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=et(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===g.array&&r===g.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=et(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===g.date&&r===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var ie=class extends k{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Le(i)||Le(o))return v;let a=et(i.value,o.value);return a.valid?((Fe(i)||Fe(o))&&n.dirty(),{status:n.value,value:a.data}):(h(r,{code:f.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ie.create=(t,e,n)=>new ie({left:t,right:e,typeName:x.ZodIntersection,...b(n)});var j=class t extends k{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return h(r,{code:f.invalid_type,expected:g.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return h(r,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new N(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>A.mergeArray(n,o)):A.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};j.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new j({items:t,typeName:x.ZodTuple,rest:null,...b(e)})};var ze=class t extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return h(r,{code:f.invalid_type,expected:g.object,received:r.parsedType}),v;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new N(r,a,r.path,a)),value:o._parse(new N(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?A.mergeObjectAsync(n,s):A.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof k?new t({keyType:e,valueType:n,typeName:x.ZodRecord,...b(r)}):new t({keyType:W.create(),valueType:e,typeName:x.ZodRecord,...b(n)})}},_e=class extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.map)return h(r,{code:f.invalid_type,expected:g.map,received:r.parsedType}),v;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new N(r,a,r.path,[l,"key"])),value:i._parse(new N(r,c,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return v;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of o){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return v;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}}}};_e.create=(t,e,n)=>new _e({valueType:e,keyType:t,typeName:x.ZodMap,...b(n)});var ve=class t extends k{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return h(r,{code:f.invalid_type,expected:g.set,received:r.parsedType}),v;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(h(r,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(h(r,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let l=new Set;for(let u of c){if(u.status==="aborted")return v;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}let a=[...r.data.values()].map((c,l)=>i._parse(new N(r,c,r.path,l)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:y.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:y.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};ve.create=(t,e)=>new ve({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...b(e)});var Be=class t extends k{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.function)return h(n,{code:f.invalid_type,expected:g.function,received:n.parsedType}),v;function r(a,c){return Se({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pe(),B].filter(l=>!!l),issueData:{code:f.invalid_arguments,argumentsError:c}})}function s(a,c){return Se({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pe(),B].filter(l=>!!l),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Y){let a=this;return R(async function(...c){let l=new C([]),u=await a._def.args.parseAsync(c,i).catch(_=>{throw l.addIssue(r(c,_)),l}),p=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(p,i).catch(_=>{throw l.addIssue(s(p,_)),l})})}else{let a=this;return R(function(...c){let l=a._def.args.safeParse(c,i);if(!l.success)throw new C([r(c,l.error)]);let u=Reflect.apply(o,this,l.data),p=a._def.returns.safeParse(u,i);if(!p.success)throw new C([s(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:j.create(e).rest(U.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||j.create([]).rest(U.create()),returns:n||U.create(),typeName:x.ZodFunction,...b(r)})}},oe=class extends k{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};oe.create=(t,e)=>new oe({getter:t,typeName:x.ZodLazy,...b(e)});var ae=class extends k{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return h(n,{received:n.data,code:f.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};ae.create=(t,e)=>new ae({value:t,typeName:x.ZodLiteral,...b(e)});function Dt(t,e){return new ce({values:t,typeName:x.ZodEnum,...b(e)})}var ce=class t extends k{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{expected:E.joinValues(r),received:n.parsedType,code:f.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{received:n.data,code:f.invalid_enum_value,options:r}),v}return R(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};ce.create=Dt;var le=class extends k{_parse(e){let n=E.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){let s=E.objectValues(n);return h(r,{expected:E.joinValues(s),received:r.parsedType,code:f.invalid_type}),v}if(this._cache||(this._cache=new Set(E.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=E.objectValues(n);return h(r,{received:r.data,code:f.invalid_enum_value,options:s}),v}return R(e.data)}get enum(){return this._def.values}};le.create=(t,e)=>new le({values:t,typeName:x.ZodNativeEnum,...b(e)});var Y=class extends k{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.promise&&n.common.async===!1)return h(n,{code:f.invalid_type,expected:g.promise,received:n.parsedType}),v;let r=n.parsedType===g.promise?n.data:Promise.resolve(n.data);return R(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Y.create=(t,e)=>new Y({type:t,typeName:x.ZodPromise,...b(e)});var P=class extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{h(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return v;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"?J(c.value):n.value==="dirty"?J(c.value):c});{if(n.value==="aborted")return v;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?J(a.value):n.value==="dirty"?J(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?v:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!K(o))return v;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>K(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):v);E.assertNever(s)}};P.create=(t,e,n)=>new P({schema:t,typeName:x.ZodEffects,effect:e,...b(n)});P.createWithPreprocess=(t,e,n)=>new P({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...b(n)});var D=class extends k{_parse(e){return this._getType(e)===g.undefined?R(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};D.create=(t,e)=>new D({innerType:t,typeName:x.ZodOptional,...b(e)});var z=class extends k{_parse(e){return this._getType(e)===g.null?R(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};z.create=(t,e)=>new z({innerType:t,typeName:x.ZodNullable,...b(e)});var ue=class extends k{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};ue.create=(t,e)=>new ue({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var de=class extends k{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return me(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};de.create=(t,e)=>new de({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var xe=class extends k{_parse(e){if(this._getType(e)!==g.nan){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}};xe.create=t=>new xe({typeName:x.ZodNaN,...b(t)});var Nr=Symbol("zod_brand"),Te=class extends k{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Ae=class t extends k{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(n.dirty(),J(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:x.ZodPipeline})}},fe=class extends k{_parse(e){let n=this._def.innerType._parse(e),r=s=>(K(s)&&(s.value=Object.freeze(s.value)),s);return me(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};fe.create=(t,e)=>new fe({innerType:t,typeName:x.ZodReadonly,...b(e)});function Rt(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Nt(t,e={},n){return t?G.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=Rt(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=Rt(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):G.create()}var Pr={object:O.lazycreate},x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));var $r=(t,e={message:`Input not instance of ${t.name}`})=>Nt(n=>n instanceof t,e),Pt=W.create,$t=X.create,Mr=xe.create,Lr=Q.create,Mt=ee.create,Fr=te.create,jr=ge.create,zr=ne.create,Br=re.create,Zr=G.create,Ur=U.create,Vr=M.create,Hr=ye.create,Kr=V.create,Wr=O.create,Gr=O.strictCreate,Yr=se.create,qr=je.create,Jr=ie.create,Xr=j.create,Qr=ze.create,es=_e.create,ts=ve.create,ns=Be.create,rs=oe.create,ss=ae.create,is=ce.create,os=le.create,as=Y.create,cs=P.create,ls=D.create,us=z.create,ds=P.createWithPreprocess,fs=Ae.create,ps=()=>Pt().optional(),ms=()=>$t().optional(),hs=()=>Mt().optional(),gs={string:(t=>W.create({...t,coerce:!0})),number:(t=>X.create({...t,coerce:!0})),boolean:(t=>ee.create({...t,coerce:!0})),bigint:(t=>Q.create({...t,coerce:!0})),date:(t=>te.create({...t,coerce:!0}))};var ys=v;var be=m.object({slug:m.string().min(1).max(64),description:m.string().max(255).optional(),match_command:m.string().min(1),priority:m.number().int().default(50),strip_ansi:m.boolean().default(!1),strip_lines_matching:m.array(m.string()).default([]),keep_failures:m.boolean().default(!1),fold_passing:m.boolean().default(!1),fold_passing_threshold:m.number().int().positive().max(1e3).optional(),mask_abs_paths:m.boolean().default(!1),preserve_exact:m.boolean().default(!1),truncate_lines_at:m.number().int().positive().max(1e4).optional(),max_lines:m.number().int().positive().max(1e5).optional(),scale_with_level:m.boolean().default(!0),transform:m.string().max(64).optional(),on_empty:m.string().max(255).optional()});var ks=xs(bs(import.meta.url)),Lt=process.env.TOKMIZER_FILTERS_DIR||jt(ks,"..","..","filters"),q=null,Ft=!1;function Es(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function zt(){if(q)return q;if(!Es())return!Ft&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
4
- `),Ft=!0),q=new Map,q;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await _s(Lt)).filter(r=>r.endsWith(".toml"))}catch{return q=t,q}for(let r of n){let s=await vs(jt(Lt,r),"utf8"),o=e(s).filters;if(o)for(let[a,c]of Object.entries(o)){let l=be.parse({slug:a,...c});t.set(a,{...l,matchRegex:new RegExp(l.match_command)})}}return q=t,q}import{createHash as ws}from"node:crypto";var Ss=m.enum(["normal","compact","minimal"]),Ts=m.enum(["off","light","balanced","max"]),tt=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:Ss.default("compact"),reducer:Ts.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),As=["git","git-status","git-log","git-diff","grep","find","diff","ls","ls-long","ps","cat","head","tail","df","du","tree","wc","nl","xargs","seq","echo","printf","sleep","shasum","python","node","read-tool","grep-tool","glob-tool","bash-tool","npm","npm-test","docker","kubectl","curl","cargo","go-test","go-build","gh","gh-api","aws","dotnet","prisma","tsc","next","jest","vitest","pytest","pip","rspec"],Rs=/^[0-9a-f]{16}$/,Bt=new Map;function H(t){let e=Bt.get(t);return e||(e=ws("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),Bt.set(t,e)),e}var Zt=null;function Ze(t,e=!1){return e||!t||t.length===0?(Zt??=new Set(As.map(H)),new Set(Zt)):new Set(t.map(n=>Rs.test(n)?n:H(n)))}var ke=new Map,Cs=256,Ut=new WeakMap;function Os(t){if(!t)return"*";let e=Ut.get(t);return e===void 0&&(e=[...t].join(","),Ut.set(t,e)),e}function Ue(t,e,n){let r=`${t}::${Os(n)}`,s=ke.get(r);if(s!==void 0)return s;let i=null;for(let o of e)n&&!n.has(H(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(ke.size>=Cs){let o=ke.keys().next().value;o&&ke.delete(o)}return ke.set(r,i),i}function Vt(){ke.clear()}var Is=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,Ds=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function Ht(t){return t.replace(Is,"").replace(Ds,"")}function Kt(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}function Wt(t,e){return t.map(n=>n.length<=e?n:`${n.slice(0,e)}\u2026`)}function Ve(t){return`\u2026 (${t} more lines omitted)`}function Gt(t,e){if(t.length<=e)return{kept:t,dropped:[]};let n=Math.ceil(e*.7),r=e-n,s=t.slice(n,t.length-r);return{kept:[...t.slice(0,n),Ve(s.length),...t.slice(t.length-r)],dropped:s}}var Ns=/^\s*(?:[✓✔√]|ok )/,Re=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/;function Yt(t,e){let n=e>0?e:5,r=[],s=0,i=a=>{s>=n?r.push(`\u2026 ${s} passing checks folded \u2026`):r.push(...a)},o=[];for(let a of t)Ns.test(a)&&!Re.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var Ps=/(?:\/[\w.@+-]+){3,}/g;function qt(t){return t.map(e=>e.replace(Ps,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var $s=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,Ms=/\{\s*$/;var Ls=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,Fs=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function js(t){let e=Ls.exec(t);return!e||Fs.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var zs=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function Bs(t,e,n){let r=e;for(;r<t.length;){if(t[r]==="\\"){r+=2;continue}if(t[r]===n)return!0;r+=1}return!1}function Zs(t,e){let n=0,r=null,s=0;for(;s<t.length;){let i=t[s];if(e.inBlockComment){if(i==="*"&&t[s+1]==="/"){e.inBlockComment=!1,s+=2;continue}s+=1;continue}if(e.inTemplate){if(i==="\\"){s+=2;continue}i==="`"&&(e.inTemplate=!1),s+=1;continue}if(r){if(i==="\\"){s+=2;continue}i===r&&(r=null),s+=1;continue}if(i==="/"&&t[s+1]==="/")break;if(i==="/"&&t[s+1]==="*"){e.inBlockComment=!0,s+=2;continue}if(i==="`"){e.inTemplate=!0,s+=1;continue}if(i==="'"||i==='"'){let o=s>0?t[s-1]:"";!(i==="'"&&(o==="<"||o==="&"))&&Bs(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}var Us=/^\s*… (\d+) lines? folded …$/;function nt(t){let e=new Array(t.length).fill(!1);for(let n=0;n<t.length;n+=1){let r=Us.exec(t[n]);if(!r)continue;let s=Number(r[1])-1,i=n+1;for(;s>0&&i<t.length&&t[i]==="";)e[i]=!0,s-=1,i+=1;n=i-1}return e}function He(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if($s.test(r)&&Ms.test(r)||js(r)||zs.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=Zs(t[o],s),o+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){a=!0;break}let c=o-n;if(a&&c>=3){let l=c-2,u=/^\s*/.exec(t[n+1]??"")?.[0]??" ";e.push(r),e.push(`${u}\u2026 ${l} ${l===1?"line":"lines"} folded \u2026`);for(let p=0;p<l-1;p++)e.push("");e.push(t[o-1]),n=o;continue}}e.push(r),n+=1}return e}var Vs=/\b(?:function|class|interface|import\s+|export\s+|def\s+|fn\s+|impl\s+|package\s+|namespace\s+|using\s+|#include|=>\s*\{|=\s*function)/;function Jt(t){let e=t.slice(0,4096);return!(!Vs.test(e)||e.split(`
5
- `).length<6)}var Hs=/\b(?:DEBUG|TRACE|INFO|VERBOSE)\b/;function Xt(t){let e=[],n=0,r=()=>{n>0&&e.push(`\u2026 ${n} verbose log line${n===1?"":"s"} dropped \u2026`),n=0};for(let s of t){if(Hs.test(s)){n+=1;continue}r(),e.push(s)}return r(),e}function Qt(t){if(t.length===0)return t;let e=[],n=1,r=t[0];for(let s=1;s<t.length;s++){if(t[s]===r){n+=1;continue}e.push(n>1?`${r} \xD7${n}`:r),r=t[s],n=1}return e.push(n>1?`${r} \xD7${n}`:r),e}function en(t){let e=[],n=0;for(let r of t){if(r.trim()===""){n+=1;continue}n>0&&e.push(""),n=0,e.push(r)}return e}var tn=new Map;function I(t,e){tn.set(t,e)}function nn(t){return tn.get(t)}var Ks=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,Ws=/^[./~][^\s]*:$/,rt=1e3;function Gs(t){if(t<1024)return String(t);let e=["K","M","G","T"],n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r+=1;return`${n.toFixed(1)}${e[r]}`}function Ys(t){if(!Ks.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let n=Number(e[4]);if(!Number.isFinite(n))return null;let r=e.slice(8).join(" ").trim();if(r===""||r==="."||r==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:r,size:n,isDir:s}}function qs(t){if(t.length<3)return null;let e=new Map;for(let s of t){let i=s.name.lastIndexOf(".");if(i<=0)continue;let o=s.name.slice(i);e.set(o,(e.get(o)??0)+1)}let n=null,r=0;for(let[s,i]of e)i>r&&(r=i,n=s);return n&&r>=Math.ceil(t.length/2)?`${r} ${n}`:null}function Js(t){let e=[],n=[],r=!1;for(let d of t){if(/^total\s+\d+/.test(d))continue;if(Ws.test(d.trim()))return t;let _=Ys(d);_&&(r=!0,(_.isDir?e:n).push(_))}if(!r)return t;let s=(d,_)=>d.name.localeCompare(_.name);e.sort(s),n.sort((d,_)=>_.size-d.size||s(d,_));let i=[...e,...n],o=Math.min(40,Math.max(0,...i.map(d=>d.isDir?d.name.length+1:d.name.length))),a=[];for(let d of i){let _=d.isDir?`${d.name}/`:d.name,S=d.isDir?"":Gs(d.size);a.push(S?`${_.padEnd(o)} ${S}`:_)}if(a.length>rt){let d=a.length-rt;a=[...a.slice(0,rt),`\u2026 ${d} more lines omitted`]}let c=n.length===1?"file":"files",l=e.length===1?"dir":"dirs",u=qs(n),p=`${n.length} ${c}, ${e.length} ${l}`+(u?` (${u})`:"");return a.push(p),a}I("smart-ls",Js);I("smart-read",t=>He(t));var rn=1e3;function Xs(t){let e=t.filter(u=>u.trim()!=="");if(e.length===0||e.filter(u=>!/\s/.test(u.trim())).length<e.length*.6)return t;let r=new Map,s=[],i=0;for(let u of e){let p=u.trim();if(p.startsWith("find:")){s.push(p);continue}let d=p.replace(/^\.\//,"").replace(/\/+$/,""),_=d.lastIndexOf("/"),S=_>=0?d.slice(0,_):"",w=_>=0?d.slice(_+1):d;if(!w)continue;let $=r.get(S)??[];$.push(/\s/.test(w)?`"${w}"`:w),r.set(S,$),i+=1}if(i===0)return t;let o=new Set([""]);for(let u of r.keys()){if(u==="")continue;let p=u.split("/");for(let d=1;d<=p.length;d+=1)o.add(p.slice(0,d).join("/"))}let a=[...o].sort(),c=a.filter(u=>u!=="").length,l=[`${i}F ${c}D:`,""];for(let u of a){let p=u===""?0:u.split("/").length,d=u===""?".":u.slice(u.lastIndexOf("/")+1),_=r.get(u)??[],S=_.length?` ${_.join(" ")}`:"";l.push(`${" ".repeat(p)}${d}/${S}`)}if(l.length+s.length>rn){let u=Math.max(0,rn-s.length),p=l.length-u;return[...l.slice(0,u),`\u2026 ${p} more lines omitted`,...s]}return[...l,...s]}I("smart-find",Xs);var st=1e3,sn=200,Qs=60,ei=190,ti=/^([^\s:]+):(\d+):(.*)$/,ni=/^([^:]+?)-(\d+)-(.*)$/,ri=/^([^\s:]+):(.*)$/,on=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;function an(t){let e=t.trim();return e.length>sn?`${e.slice(0,sn)}\u2026`:e}function si(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>ei&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function ii(t){let e=t.filter(p=>p.trim()!=="");if(e.length===0)return t;let n=new Map,r=new Map,s=null,i=0,o=0;for(let p of e){if(p==="--"){s&&n.get(s).push({separator:!0});continue}let d=ti.exec(p),_=d?null:ni.exec(p),S=d||_?null:ri.exec(p),w=(d??_??S)?.[1];if(!w)return t;let $=d?{line:d[2],content:d[3],context:!1}:_?{line:_[2],content:_[3],context:!0}:{line:"",content:S[2],context:!1},L=n.get(w)??[];L.push($),n.set(w,L),$.context||(i+=1,r.set(w,(r.get(w)??0)+1)),o+=1,s=w}if(n.size===o)return t;let a=[...n.keys()].sort((p,d)=>{let _=on.test(p)?1:0,S=on.test(d)?1:0;return _-S||(p<d?-1:p>d?1:0)}),c=[];for(let p of a){c.push(`${p} (${r.get(p)??0}):`);for(let d of n.get(p))"separator"in d?c.push(" --"):d.line?c.push(` ${d.line}${d.context?"-":":"} ${an(d.content)}`):c.push(` ${an(d.content)}`)}let l=a.length>1&&c.length>Qs?si(a.map(p=>`${p} (${r.get(p)??0})`)):[],u=[`${i}m ${a.length}f:`,...l,"",...c];if(u.length>st){let p=u.length-st;return[...u.slice(0,st),`\u2026 ${p} more lines omitted`]}return u}I("smart-grep",ii);var cn=/^commit [0-9a-f]{7,40}\b/,oi=/^ {4}/,ai=2;function ci(t){if(!t.some(i=>cn.test(i)))return t;let e=[],n=0,r=0,s=()=>{r>0&&e.push(` \u2026 ${r} ${r===1?"line":"lines"} folded \u2026`),r=0};for(let i of t){if(cn.test(i)){s(),n=0,e.push(i);continue}if(oi.test(i)){n+=1,n<=ai?e.push(i):r+=1;continue}s(),e.push(i)}return s(),e}I("smart-log",ci);var li=/^[\s=]+$/,ui=/^\s*=+\s+(.*?)\s+=+\s*$/,di=512;I("strip-banners",t=>{let e=[];for(let n of t){if(li.test(n))continue;let r=n.length<=di?ui.exec(n):null;e.push(r?r[1]:n)}return e});function fi(t){let e=[],n=0,r=0;for(;r<t.length;){let s=t[r].replace(/\s+$/,"");if(s===""){n+=1,r+=1,n<=1&&e.push("");continue}n=0;let i=1;for(;r+i<t.length&&t[r+i].replace(/\s+$/,"")===s;)i+=1;if(i>=3)e.push(s),e.push(` \u2026 (repeated ${i}x)`);else for(let o=0;o<i;o++)e.push(s);r+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}I("squeeze-output",fi);function pi(t){return t==="compact"?.6:t==="minimal"?.3:1}var mi=20,ln=new WeakMap;function hi(t){let e=ln.get(t);if(e)return e;let n=t.strip_lines_matching.map(s=>new RegExp(s)),r={def:t,stripRegexes:n};return ln.set(t,r),r}function un(t,e,n={}){return it(t,e,n).text}function it(t,e,n={}){let r=hi(e),s=t;e.strip_ansi&&(s=Ht(s));let i=s.endsWith(`
6
- `),o=(i?s.slice(0,-1):s).split(`
7
- `);r.stripRegexes.length&&(o=e.keep_failures?o.filter(p=>Re.test(p)||!r.stripRegexes.some(d=>d.test(p))):Kt(o,r.stripRegexes));let a=n.verbosity??"normal";if(a!=="normal"&&!e.preserve_exact&&(o=Qt(o),o=en(o)),a==="minimal"&&!e.preserve_exact&&(o=Xt(o)),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&a!=="normal"&&Jt(s))&&(o=He(o)),e.transform){let p=nn(e.transform);p&&(o=p(o))}let c=e.slug==="read-tool";if(!c){let p=nt(o);p.some(Boolean)&&(o=o.filter((d,_)=>!p[_]))}e.mask_abs_paths&&(o=qt(o)),e.fold_passing&&(o=Yt(o,e.fold_passing_threshold??5)),e.truncate_lines_at&&(o=Wt(o,e.truncate_lines_at));let l=null;if(e.max_lines){let p=e.scale_with_level?pi(n.verbosity):1,d=Math.min(e.max_lines,Math.max(mi,Math.round(e.max_lines*p))),_=c?nt(o):null,S=_?_.filter(w=>!w).length:o.length;if(S>d){let w=d;if(_){let L=0;for(w=0;w<o.length&&L<d;)_[w]||(L+=1),w+=1}let $=S-d;if(e.keep_failures){let L=o.slice(w),we=L.filter(Je=>!Re.test(Je));l=we.length>0?we.join(`
8
- `):null,o=[...o.slice(0,w),Ve($),...L.filter(Je=>Re.test(Je))]}else if(c)l=o.slice(w).join(`
9
- `),o=[...o.slice(0,w),Ve($)];else{let{kept:L,dropped:we}=Gt(o,d);l=we.length>0?we.join(`
10
- `):null,o=L}}}let u=o.join(`
11
- `);return i&&u.length>0&&(u+=`
12
- `),u.trim().length===0&&e.on_empty&&(u=e.on_empty),{text:u,droppedTail:l}}var gi=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/thread '.*' panicked/];function dn(t){if(!t)return!1;let e=t.split(`
13
- `),n=e.length<=60?t:[...e.slice(0,30),...e.slice(-30)].join(`
14
- `),r=n.length<=32768*2?[n]:[n.slice(0,32768),n.slice(-32768)];for(let s of gi)for(let i of r)if(s.test(i))return!0;return!1}var yi=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),_i=/^[A-Za-z_][A-Za-z0-9_]*=/,ot=/^([a-z]+)-tool(?::\s|$)/;function Ke(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(_i.test(a)){r++;continue}if(yi.has(a)){for(r++,a==="timeout"&&r<n.length&&/^\d+(?:\.\d+)?[smhd]?$/.test(n[r])&&r++;(a==="stdbuf"||a==="nice")&&r<n.length&&n[r].startsWith("-");)r++;continue}break}if(r>=n.length)return e;let s=n[r],i=s.includes("/")?s.slice(s.lastIndexOf("/")+1):s,o=n.slice(r+1);return o.length?`${i} ${o.join(" ")}`:i}var vi=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"]);function fn(t,e){let n=!1,r=!1,s=0,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="\\"&&!n){o++;continue}a==="'"&&!r?n=!n:a==='"'&&!n?r=!r:!n&&!r&&(a===";"?(i.push(t.slice(s,o)),s=o+1):a==="|"&&t[o+1]==="|"?(i.push(t.slice(s,o)),o++,s=o+1):a==="|"?e||(i.push(t.slice(s,o)),s=o+1):a==="&"&&t[o+1]==="&"&&(i.push(t.slice(s,o)),o++,s=o+1))}return i.push(t.slice(s)),i}function xi(t){let e=fn(t,!1);for(let n=e.length-1;n>=0;n--){let r=e[n].trim();if(r)return r}return t.trim()}function bi(t){let e=fn(t,!0).map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;for(let n of e.slice(0,-1)){let r=Ke(n).split(/\s+/)[0]??"";if(!vi.has(r))return null}return xi(e[e.length-1])}function pn(t){let e=!1,n=!1,r=0,s=[];for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&!e){i++;continue}o==="'"&&!n?e=!e:o==='"'&&!e?n=!n:!e&&!n&&(o==="|"||o===";"?(s.push(t.slice(r,i)),o==="|"&&t[i+1]==="|"&&i++,r=i+1):o==="&"&&t[i+1]==="&"&&(s.push(t.slice(r,i)),i++,r=i+1))}s.push(t.slice(r));for(let i=s.length-1;i>=0;i--){let o=s[i].trim();if(o)return o}return t.trim()}function mn(t){let e=ot.exec(t),n=t;if(e){if(e[1]!=="bash")return[t];let i=t.indexOf(": ");if(i<0)return[t];n=t.slice(i+2)}let r=bi(n),s=r?Ke(r):null;return s&&s!==t?[s,t]:[t]}var hn=null;function at(t){hn=t}async function ki(t,e){let n=await zt();return Ue(t,n.values(),e)}var Ei=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,wi=2048;async function gn(t,e,n,r={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,...o}=r,a=Ke(pn(t.startsWith("bash-tool: ")?t.slice(11):t)),c=i!=null&&i!==0&&!(i===1&&Ei.test(a)),l=i==null&&dn(e),u=hn??ki,p=null;for(let w of mn(t))if(p=await u(w,n),p)break;if(!p&&s>=wi&&!ot.test(t)&&(p=await u(`bash-tool: ${t}`,n)),!p||c&&p.preserve_exact)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:c||l};if(c){let w={...p,keep_failures:!0,transform:void 0,max_lines:void 0,truncate_lines_at:void 0},$=un(e,w,{verbosity:"normal",smartCode:!1});return{output:$,filterId:p.slug,rawBytes:s,filteredBytes:Buffer.byteLength($,"utf8"),debugBypass:!0}}let d=l&&!p.preserve_exact?{...p,keep_failures:!0}:p,{text:_,droppedTail:S}=it(e,d,o);return{output:_,filterId:p.slug,rawBytes:s,filteredBytes:Buffer.byteLength(_,"utf8"),debugBypass:!1,droppedTail:S}}async function yn(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}import{existsSync as Fi}from"node:fs";import{fileURLToPath as ji}from"node:url";import{dirname as zi,join as Bi}from"node:path";import{appendFileSync as Oi,chmodSync as Ii,mkdirSync as Di,existsSync as Ni,readFileSync as Dl,rmSync as Nl}from"node:fs";import{dirname as Pi,join as $i}from"node:path";import Si from"node:os";import{join as _n}from"node:path";function T(){return process.env.TOKMIZER_HOME||_n(Si.homedir(),".tokmizer")}function Ce(){return _n(T(),"install-id")}import{readFileSync as Ti,renameSync as Ai,statSync as Ri,writeFileSync as Ci}from"node:fs";function We(t,e,n){try{if(Ri(t).size<=e)return;let r=Ti(t,"utf8").split(`
15
- `).filter(a=>a.trim()!==""),s=[],i=0;for(let a=r.length-1;a>=0;a-=1){let c=r[a],l=Buffer.byteLength(c)+1;if(i+l>n)break;s.push(c),i+=l}s.reverse();let o=`${t}.tmp-${process.pid}`;Ci(o,s.length?`${s.join(`
3
+ var hr=Object.defineProperty;var gr=(t,e)=>{for(var n in e)hr(t,n,{get:e[n],enumerable:!0})};import{readdir as As,readFile as Rs}from"node:fs/promises";import{join as Gt,dirname as Cs}from"node:path";import{fileURLToPath as Is}from"node:url";var m={};gr(m,{BRAND:()=>Zr,DIRTY:()=>ee,EMPTY_PATH:()=>vr,INVALID:()=>v,NEVER:()=>Ts,OK:()=>O,ParseStatus:()=>I,Schema:()=>w,ZodAny:()=>q,ZodArray:()=>W,ZodBigInt:()=>ne,ZodBoolean:()=>re,ZodBranded:()=>De,ZodCatch:()=>me,ZodDate:()=>se,ZodDefault:()=>pe,ZodDiscriminatedUnion:()=>Ke,ZodEffects:()=>L,ZodEnum:()=>de,ZodError:()=>D,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>Ge,ZodIntersection:()=>ce,ZodIssueCode:()=>p,ZodLazy:()=>le,ZodLiteral:()=>ue,ZodMap:()=>ke,ZodNaN:()=>we,ZodNativeEnum:()=>fe,ZodNever:()=>F,ZodNull:()=>oe,ZodNullable:()=>U,ZodNumber:()=>te,ZodObject:()=>N,ZodOptional:()=>P,ZodParsedType:()=>y,ZodPipeline:()=>Ne,ZodPromise:()=>J,ZodReadonly:()=>he,ZodRecord:()=>We,ZodSchema:()=>w,ZodSet:()=>Ee,ZodString:()=>Y,ZodSymbol:()=>ve,ZodTransformer:()=>L,ZodTuple:()=>Z,ZodType:()=>w,ZodUndefined:()=>ie,ZodUnion:()=>ae,ZodUnknown:()=>K,ZodVoid:()=>xe,addIssueToContext:()=>h,any:()=>Jr,array:()=>ts,bigint:()=>Kr,boolean:()=>Vt,coerce:()=>Ss,custom:()=>Zt,date:()=>Wr,datetimeRegex:()=>Bt,defaultErrorMap:()=>H,discriminatedUnion:()=>is,effect:()=>ys,enum:()=>ms,function:()=>ds,getErrorMap:()=>ye,getParsedType:()=>z,instanceof:()=>Hr,intersection:()=>os,isAborted:()=>He,isAsync:()=>_e,isDirty:()=>Ve,isValid:()=>G,late:()=>Ur,lazy:()=>fs,literal:()=>ps,makeIssue:()=>Oe,map:()=>ls,nan:()=>Vr,nativeEnum:()=>hs,never:()=>Qr,null:()=>qr,nullable:()=>bs,number:()=>Ht,object:()=>ns,objectUtil:()=>rt,oboolean:()=>ws,onumber:()=>Es,optional:()=>_s,ostring:()=>ks,pipeline:()=>xs,preprocess:()=>vs,promise:()=>gs,quotelessJson:()=>yr,record:()=>cs,set:()=>us,setErrorMap:()=>br,strictObject:()=>rs,string:()=>Ut,symbol:()=>Gr,transformer:()=>ys,tuple:()=>as,undefined:()=>Yr,union:()=>ss,unknown:()=>Xr,util:()=>S,void:()=>es});var S;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(S||(S={}));var rt;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(rt||(rt={}));var y=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}};var p=S.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"]),yr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),D=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){let u=o.path[l];l===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],l++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};D.create=t=>new D(t);var _r=(t,e)=>{let n;switch(t.code){case p.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case p.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case p.invalid_arguments:n="Invalid function arguments";break;case p.invalid_return_type:n="Invalid function return type";break;case p.invalid_date:n="Invalid date";break;case p.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:S.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case p.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case p.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case p.custom:n="Invalid input";break;case p.invalid_intersection_types:n="Intersection results could not be merged";break;case p.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case p.not_finite:n="Number must be finite";break;default:n=e.defaultError,S.assertNever(t)}return{message:n}},H=_r;var Pt=H;function br(t){Pt=t}function ye(){return Pt}var Oe=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",l=r.filter(u=>!!u).slice().reverse();for(let u of l)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},vr=[];function h(t,e){let n=ye(),r=Oe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===H?void 0:H].filter(s=>!!s)});t.common.issues.push(r)}var I=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},v=Object.freeze({status:"aborted"}),ee=t=>({status:"dirty",value:t}),O=t=>({status:"valid",value:t}),He=t=>t.status==="aborted",Ve=t=>t.status==="dirty",G=t=>t.status==="valid",_e=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}));var M=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Mt=(t,e)=>{if(G(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new D(t.common.issues);return this._error=n,this._error}}};function E(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:s}}var w=class{get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new I,ctx:{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(_e(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Mt(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return G(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>G(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(_e(s)?s:Promise.resolve(s));return Mt(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:p.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new L({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return P.create(this,this._def)}nullable(){return U.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this)}promise(){return J.create(this,this._def)}or(e){return ae.create([this,e],this._def)}and(e){return ce.create(this,e,this._def)}transform(e){return new L({...E(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new pe({...E(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new De({typeName:x.ZodBranded,type:this,...E(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new me({...E(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ne.create(this,e)}readonly(){return he.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},xr=/^c[^\s-]{8,}$/i,kr=/^[0-9a-z]+$/,Er=/^[0-9A-HJKMNP-TV-Z]{26}$/i,wr=/^[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,Sr=/^[a-z0-9_-]{21}$/i,Tr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ar=/^[-+]?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)?)??$/,Rr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Cr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",st,Ir=/^(?:(?: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])$/,Or=/^(?:(?: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])$/,Dr=/^(([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]))$/,Nr=/^(([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])$/,$r=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Pr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ft="((\\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])))",Mr=new RegExp(`^${Ft}$`);function jt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Lr(t){return new RegExp(`^${jt(t)}$`)}function Bt(t){let e=`${Ft}T${jt(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Fr(t,e){return!!((e==="v4"||!e)&&Ir.test(t)||(e==="v6"||!e)&&Dr.test(t))}function jr(t,e){if(!Tr.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Br(t,e){return!!((e==="v4"||!e)&&Or.test(t)||(e==="v6"||!e)&&Nr.test(t))}var Y=class t extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_type,expected:y.string,received:i.parsedType}),v}let r=new I,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?h(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&h(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Rr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"email",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")st||(st=new RegExp(Cr,"u")),st.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"emoji",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")wr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"uuid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Sr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"nanoid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")xr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")kr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid2",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Er.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ulid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),h(s,{validation:"url",code:p.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"regex",code:p.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Bt(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Mr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Lr(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ar.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Fr(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ip",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?jr(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"jwt",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Br(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cidr",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?$r.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Pr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:p.invalid_string,message:i.message}),r.dirty()):S.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:p.invalid_string,...b.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...b.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...b.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Y.create=t=>new Y({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...E(t)});function zr(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var te=class t extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_type,expected:y.number,received:i.parsedType}),v}let r,s=new I;for(let i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:p.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?zr(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:p.not_finite,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};te.create=t=>new te({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...E(t)});var ne=class t extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let r,s=new I;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return h(n,{code:p.invalid_type,expected:y.bigint,received:n.parsedType}),v}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ne.create=t=>new ne({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...E(t)});var re=class extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.boolean,received:r.parsedType}),v}return O(e.data)}};re.create=t=>new re({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...E(t)});var se=class t extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_type,expected:y.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_date}),v}let r=new I,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):S.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};se.create=t=>new se({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...E(t)});var ve=class extends w{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.symbol,received:r.parsedType}),v}return O(e.data)}};ve.create=t=>new ve({typeName:x.ZodSymbol,...E(t)});var ie=class extends w{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.undefined,received:r.parsedType}),v}return O(e.data)}};ie.create=t=>new ie({typeName:x.ZodUndefined,...E(t)});var oe=class extends w{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.null,received:r.parsedType}),v}return O(e.data)}};oe.create=t=>new oe({typeName:x.ZodNull,...E(t)});var q=class extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}};q.create=t=>new q({typeName:x.ZodAny,...E(t)});var K=class extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}};K.create=t=>new K({typeName:x.ZodUnknown,...E(t)});var F=class extends w{_parse(e){let n=this._getOrReturnCtx(e);return h(n,{code:p.invalid_type,expected:y.never,received:n.parsedType}),v}};F.create=t=>new F({typeName:x.ZodNever,...E(t)});var xe=class extends w{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.void,received:r.parsedType}),v}return O(e.data)}};xe.create=t=>new xe({typeName:x.ZodVoid,...E(t)});var W=class t extends w{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==y.array)return h(n,{code:p.invalid_type,expected:y.array,received:n.parsedType}),v;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(h(n,{code:o?p.too_big:p.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(h(n,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(h(n,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new M(n,o,n.path,a)))).then(o=>I.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new M(n,o,n.path,a)));return I.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};W.create=(t,e)=>new W({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...E(e)});function be(t){if(t instanceof N){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=P.create(be(r))}return new N({...t._def,shape:()=>e})}else return t instanceof W?new W({...t._def,type:be(t.element)}):t instanceof P?P.create(be(t.unwrap())):t instanceof U?U.create(be(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>be(e))):t}var N=class t extends w{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=S.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let u=this._getOrReturnCtx(e);return h(u,{code:p.invalid_type,expected:y.object,received:u.parsedType}),v}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let l=[];for(let u of o){let d=i[u],f=s.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new M(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof F){let u=this._def.unknownKeys;if(u==="passthrough")for(let d of a)l.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")a.length>0&&(h(s,{code:p.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let d of a){let f=s.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new M(s,f,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let d of l){let f=await d.key,c=await d.value;u.push({key:f,value:c,alwaysSet:d.alwaysSet})}return u}).then(u=>I.mergeObjectSync(r,u)):I.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:b.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of S.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of S.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return be(this)}partial(e){let n={};for(let r of S.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of S.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof P;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return zt(S.objectKeys(this.shape))}};N.create=(t,e)=>new N({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:x.ZodObject,...E(e)});N.strictCreate=(t,e)=>new N({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:x.ZodObject,...E(e)});N.lazycreate=(t,e)=>new N({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:x.ZodObject,...E(e)});var ae=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new D(a.ctx.common.issues));return h(n,{code:p.invalid_union,unionErrors:o}),v}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let l of r){let u={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(l=>new D(l));return h(n,{code:p.invalid_union,unionErrors:a}),v}}get options(){return this._def.options}};ae.create=(t,e)=>new ae({options:t,typeName:x.ZodUnion,...E(e)});var V=t=>t instanceof le?V(t.schema):t instanceof L?V(t.innerType()):t instanceof ue?[t.value]:t instanceof de?t.options:t instanceof fe?S.objectValues(t.enum):t instanceof pe?V(t._def.innerType):t instanceof ie?[void 0]:t instanceof oe?[null]:t instanceof P?[void 0,...V(t.unwrap())]:t instanceof U?[null,...V(t.unwrap())]:t instanceof De||t instanceof he?V(t.unwrap()):t instanceof me?V(t._def.innerType):[],Ke=class t extends w{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return h(n,{code:p.invalid_type,expected:y.object,received:n.parsedType}),v;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(h(n,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=V(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...E(r)})}};function it(t,e){let n=z(t),r=z(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=S.objectKeys(e),i=S.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let l=it(t[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],l=it(o,a);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var ce=class extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(He(i)||He(o))return v;let a=it(i.value,o.value);return a.valid?((Ve(i)||Ve(o))&&n.dirty(),{status:n.value,value:a.data}):(h(r,{code:p.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ce.create=(t,e,n)=>new ce({left:t,right:e,typeName:x.ZodIntersection,...E(n)});var Z=class t extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return h(r,{code:p.invalid_type,expected:y.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return h(r,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new M(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>I.mergeArray(n,o)):I.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Z({items:t,typeName:x.ZodTuple,rest:null,...E(e)})};var We=class t extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return h(r,{code:p.invalid_type,expected:y.object,received:r.parsedType}),v;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new M(r,a,r.path,a)),value:o._parse(new M(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?I.mergeObjectAsync(n,s):I.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof w?new t({keyType:e,valueType:n,typeName:x.ZodRecord,...E(r)}):new t({keyType:Y.create(),valueType:e,typeName:x.ZodRecord,...E(n)})}},ke=class extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return h(r,{code:p.invalid_type,expected:y.map,received:r.parsedType}),v;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,l],u)=>({key:s._parse(new M(r,a,r.path,[u,"key"])),value:i._parse(new M(r,l,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let u=await l.key,d=await l.value;if(u.status==="aborted"||d.status==="aborted")return v;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(u.value,d.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of o){let u=l.key,d=l.value;if(u.status==="aborted"||d.status==="aborted")return v;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(u.value,d.value)}return{status:n.value,value:a}}}};ke.create=(t,e,n)=>new ke({valueType:e,keyType:t,typeName:x.ZodMap,...E(n)});var Ee=class t extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return h(r,{code:p.invalid_type,expected:y.set,received:r.parsedType}),v;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(h(r,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(h(r,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(l){let u=new Set;for(let d of l){if(d.status==="aborted")return v;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((l,u)=>i._parse(new M(r,l,r.path,u)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Ee.create=(t,e)=>new Ee({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...E(e)});var Ge=class t extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return h(n,{code:p.invalid_type,expected:y.function,received:n.parsedType}),v;function r(a,l){return Oe({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:l}})}function s(a,l){return Oe({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof J){let a=this;return O(async function(...l){let u=new D([]),d=await a._def.args.parseAsync(l,i).catch(g=>{throw u.addIssue(r(l,g)),u}),f=await Reflect.apply(o,this,d);return await a._def.returns._def.type.parseAsync(f,i).catch(g=>{throw u.addIssue(s(f,g)),u})})}else{let a=this;return O(function(...l){let u=a._def.args.safeParse(l,i);if(!u.success)throw new D([r(l,u.error)]);let d=Reflect.apply(o,this,u.data),f=a._def.returns.safeParse(d,i);if(!f.success)throw new D([s(d,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(K.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||Z.create([]).rest(K.create()),returns:n||K.create(),typeName:x.ZodFunction,...E(r)})}},le=class extends w{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};le.create=(t,e)=>new le({getter:t,typeName:x.ZodLazy,...E(e)});var ue=class extends w{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return h(n,{received:n.data,code:p.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};ue.create=(t,e)=>new ue({value:t,typeName:x.ZodLiteral,...E(e)});function zt(t,e){return new de({values:t,typeName:x.ZodEnum,...E(e)})}var de=class t extends w{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{expected:S.joinValues(r),received:n.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{received:n.data,code:p.invalid_enum_value,options:r}),v}return O(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};de.create=zt;var fe=class extends w{_parse(e){let n=S.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=S.objectValues(n);return h(r,{expected:S.joinValues(s),received:r.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=S.objectValues(n);return h(r,{received:r.data,code:p.invalid_enum_value,options:s}),v}return O(e.data)}get enum(){return this._def.values}};fe.create=(t,e)=>new fe({values:t,typeName:x.ZodNativeEnum,...E(e)});var J=class extends w{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return h(n,{code:p.invalid_type,expected:y.promise,received:n.parsedType}),v;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return O(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};J.create=(t,e)=>new J({type:t,typeName:x.ZodPromise,...E(e)});var L=class extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{h(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return v;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?v:l.status==="dirty"?ee(l.value):n.value==="dirty"?ee(l.value):l});{if(n.value==="aborted")return v;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?ee(a.value):n.value==="dirty"?ee(a.value):a}}if(s.type==="refinement"){let o=a=>{let l=s.refinement(a,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?v:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!G(o))return v;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>G(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):v);S.assertNever(s)}};L.create=(t,e,n)=>new L({schema:t,typeName:x.ZodEffects,effect:e,...E(n)});L.createWithPreprocess=(t,e,n)=>new L({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...E(n)});var P=class extends w{_parse(e){return this._getType(e)===y.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(t,e)=>new P({innerType:t,typeName:x.ZodOptional,...E(e)});var U=class extends w{_parse(e){return this._getType(e)===y.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};U.create=(t,e)=>new U({innerType:t,typeName:x.ZodNullable,...E(e)});var pe=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};pe.create=(t,e)=>new pe({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...E(e)});var me=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _e(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};me.create=(t,e)=>new me({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...E(e)});var we=class extends w{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}};we.create=t=>new we({typeName:x.ZodNaN,...E(t)});var Zr=Symbol("zod_brand"),De=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Ne=class t extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(n.dirty(),ee(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:x.ZodPipeline})}},he=class extends w{_parse(e){let n=this._def.innerType._parse(e),r=s=>(G(s)&&(s.value=Object.freeze(s.value)),s);return _e(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};he.create=(t,e)=>new he({innerType:t,typeName:x.ZodReadonly,...E(e)});function Lt(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Zt(t,e={},n){return t?q.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=Lt(e,r),l=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:l})}});if(!i){let o=Lt(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):q.create()}var Ur={object:N.lazycreate},x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));var Hr=(t,e={message:`Input not instance of ${t.name}`})=>Zt(n=>n instanceof t,e),Ut=Y.create,Ht=te.create,Vr=we.create,Kr=ne.create,Vt=re.create,Wr=se.create,Gr=ve.create,Yr=ie.create,qr=oe.create,Jr=q.create,Xr=K.create,Qr=F.create,es=xe.create,ts=W.create,ns=N.create,rs=N.strictCreate,ss=ae.create,is=Ke.create,os=ce.create,as=Z.create,cs=We.create,ls=ke.create,us=Ee.create,ds=Ge.create,fs=le.create,ps=ue.create,ms=de.create,hs=fe.create,gs=J.create,ys=L.create,_s=P.create,bs=U.create,vs=L.createWithPreprocess,xs=Ne.create,ks=()=>Ut().optional(),Es=()=>Ht().optional(),ws=()=>Vt().optional(),Ss={string:(t=>Y.create({...t,coerce:!0})),number:(t=>te.create({...t,coerce:!0})),boolean:(t=>re.create({...t,coerce:!0})),bigint:(t=>ne.create({...t,coerce:!0})),date:(t=>se.create({...t,coerce:!0}))};var Ts=v;var Se=m.object({slug:m.string().min(1).max(64),description:m.string().max(255).optional(),match_command:m.string().min(1),priority:m.number().int().default(50),strip_ansi:m.boolean().default(!1),strip_lines_matching:m.array(m.string()).default([]),keep_failures:m.boolean().default(!1),fold_passing:m.boolean().default(!1),fold_passing_threshold:m.number().int().positive().max(1e3).optional(),mask_abs_paths:m.boolean().default(!1),preserve_exact:m.boolean().default(!1),truncate_lines_at:m.number().int().positive().max(1e4).optional(),max_lines:m.number().int().positive().max(1e5).optional(),scale_with_level:m.boolean().default(!0),transform:m.string().max(64).optional(),on_empty:m.string().max(255).optional()});var Os=Cs(Is(import.meta.url)),Kt=process.env.TOKMIZER_FILTERS_DIR||Gt(Os,"..","..","filters"),X=null,Wt=!1;function Ds(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function Yt(){if(X)return X;if(!Ds())return!Wt&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
4
+ `),Wt=!0),X=new Map,X;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await As(Kt)).filter(r=>r.endsWith(".toml"))}catch{return X=t,X}for(let r of n){let s=await Rs(Gt(Kt,r),"utf8"),o=e(s).filters;if(o)for(let[a,l]of Object.entries(o)){let u=Se.parse({slug:a,...l});t.set(a,{...u,matchRegex:new RegExp(u.match_command)})}}return X=t,X}import{createHash as Ns}from"node:crypto";var $s=m.enum(["normal","compact","minimal"]),Ps=m.enum(["off","light","balanced","max"]),$e=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:$s.default("compact"),reducer:Ps.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),Ms=["git","git-status","git-log","git-diff","grep","find","diff","ls","ls-long","ps","cat","head","tail","df","du","tree","wc","nl","xargs","seq","echo","printf","sleep","shasum","python","node","read-tool","grep-tool","glob-tool","bash-tool","npm","npm-test","docker","kubectl","curl","cargo","go-test","go-build","gh","gh-api","aws","dotnet","prisma","tsc","next","jest","vitest","pytest","pip","rspec"],Ls=/^[0-9a-f]{16}$/,qt=new Map;function j(t){let e=qt.get(t);return e||(e=Ns("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),qt.set(t,e)),e}var Jt=null;function Ye(t,e=!1){return e||!t||t.length===0?(Jt??=new Set(Ms.map(j)),new Set(Jt)):new Set(t.map(n=>Ls.test(n)?n:j(n)))}var Te=new Map,Fs=256,Xt=new WeakMap;function js(t){if(!t)return"*";let e=Xt.get(t);return e===void 0&&(e=[...t].join(","),Xt.set(t,e)),e}function qe(t,e,n){let r=`${t}::${js(n)}`,s=Te.get(r);if(s!==void 0)return s;let i=null;for(let o of e)n&&!n.has(j(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Te.size>=Fs){let o=Te.keys().next().value;o&&Te.delete(o)}return Te.set(r,i),i}function Qt(){Te.clear()}var Bs=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,zs=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function ge(t){return t.replace(Bs,"").replace(zs,"")}function en(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}function tn(t,e){return t.map(n=>{if(n.length<=e)return n;let r=n.charCodeAt(e-1),s=n.charCodeAt(e),i=r>=55296&&r<=56319&&s>=56320&&s<=57343?e-1:e;return`${n.slice(0,i)}\u2026`})}function Je(t){return`\u2026 (${t} more lines omitted)`}function nn(t,e){if(t.length<=e)return{kept:t,dropped:[]};let n=Math.ceil(e*.7),r=e-n,s=t.slice(n,t.length-r);return{kept:[...t.slice(0,n),Je(s.length),...t.slice(t.length-r)],dropped:s}}var Zs=/^\s*(?:[✓✔√]|ok )/,Q=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/;function rn(t,e){let n=e>0?e:5,r=[],s=0,i=a=>{s>=n?r.push(`\u2026 ${s} passing checks folded \u2026`):r.push(...a)},o=[];for(let a of t)Zs.test(a)&&!Q.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var Us=/(?:\/[\w.@+-]+){3,}/g;function sn(t){return t.map(e=>e.replace(Us,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var Hs=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,Vs=/\{\s*$/;var Ks=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,Ws=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function Gs(t){let e=Ks.exec(t);return!e||Ws.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var Ys=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function qs(t,e,n){let r=e;for(;r<t.length;){if(t[r]==="\\"){r+=2;continue}if(t[r]===n)return!0;r+=1}return!1}function Js(t,e){let n=0,r=null,s=0;for(;s<t.length;){let i=t[s];if(e.inBlockComment){if(i==="*"&&t[s+1]==="/"){e.inBlockComment=!1,s+=2;continue}s+=1;continue}if(e.inTemplate){if(i==="\\"){s+=2;continue}i==="`"&&(e.inTemplate=!1),s+=1;continue}if(r){if(i==="\\"){s+=2;continue}i===r&&(r=null),s+=1;continue}if(i==="/"&&t[s+1]==="/")break;if(i==="/"&&t[s+1]==="*"){e.inBlockComment=!0,s+=2;continue}if(i==="`"){e.inTemplate=!0,s+=1;continue}if(i==="'"||i==='"'){let o=s>0?t[s-1]:"";!(i==="'"&&(o==="<"||o==="&"))&&qs(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}var Xs=/^\s*… (\d+) lines? folded …$/;function ot(t){let e=new Array(t.length).fill(!1);for(let n=0;n<t.length;n+=1){let r=Xs.exec(t[n]);if(!r)continue;let s=Number(r[1])-1,i=n+1;for(;s>0&&i<t.length&&t[i]==="";)e[i]=!0,s-=1,i+=1;n=i-1}return e}function Xe(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if(Hs.test(r)&&Vs.test(r)||Gs(r)||Ys.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=Js(t[o],s),o+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){a=!0;break}let l=o-n;if(a&&l>=3){let u=l-2,d=/^\s*/.exec(t[n+1]??"")?.[0]??" ";e.push(r),e.push(`${d}\u2026 ${u} ${u===1?"line":"lines"} folded \u2026`);for(let f=0;f<u-1;f++)e.push("");e.push(t[o-1]),n=o;continue}}e.push(r),n+=1}return e}var Qs=/\b(?:function|class|interface|import\s+|export\s+|def\s+|fn\s+|impl\s+|package\s+|namespace\s+|using\s+|#include|=>\s*\{|=\s*function)/;function on(t){let e=t.slice(0,4096);return!(!Qs.test(e)||e.split(`
5
+ `).length<6)}var ei=/^\s*(?:\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?|\d{2}:\d{2}:\d{2}(?:\.\d+)?)\s*/,ti=/^\s*(?:\[(?:DEBUG|TRACE|INFO|VERBOSE)\]|(?:DEBUG|TRACE|INFO|VERBOSE)(?!\s*:))(?=\s|:|$)(?!\s*[+\-*\/%&|^?]*=)/,ni=new RegExp(Q.source,"i"),ri=/\bWARN(?:ING)?\b/i;function an(t){let e=[],n=0,r=()=>{n>0&&e.push(`\u2026 ${n} verbose log line${n===1?"":"s"} dropped \u2026`),n=0};for(let s of t){if(ti.test(s.replace(ei,""))&&!ni.test(s)&&!ri.test(s)){n+=1;continue}r(),e.push(s)}return r(),e}function cn(t){if(t.length===0)return t;let e=[],n=1,r=t[0];for(let s=1;s<t.length;s++){if(t[s]===r){n+=1;continue}e.push(n>1?`${r} \xD7${n}`:r),r=t[s],n=1}return e.push(n>1?`${r} \xD7${n}`:r),e}function ln(t){let e=[],n=0;for(let r of t){if(r.trim()===""){n+=1;continue}n>0&&e.push(""),n=0,e.push(r)}return e}var un=new Map;function $(t,e){un.set(t,e)}function dn(t){return un.get(t)}var si=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,ii=/^[./~][^\s]*:$/,at=1e3;function oi(t){if(t<1024)return String(t);let e=["K","M","G","T"],n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r+=1;return`${n.toFixed(1)}${e[r]}`}function ai(t){if(!si.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let n=Number(e[4]);if(!Number.isFinite(n))return null;let r=e.slice(8).join(" ").trim();if(r===""||r==="."||r==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:r,size:n,isDir:s}}function ci(t){if(t.length<3)return null;let e=new Map;for(let s of t){let i=s.name.lastIndexOf(".");if(i<=0)continue;let o=s.name.slice(i);e.set(o,(e.get(o)??0)+1)}let n=null,r=0;for(let[s,i]of e)i>r&&(r=i,n=s);return n&&r>=Math.ceil(t.length/2)?`${r} ${n}`:null}function li(t){let e=[],n=[],r=!1;for(let c of t){if(/^total\s+\d+/.test(c))continue;if(ii.test(c.trim()))return t;let g=ai(c);g&&(r=!0,(g.isDir?e:n).push(g))}if(!r)return t;let s=(c,g)=>c.name.localeCompare(g.name);e.sort(s),n.sort((c,g)=>g.size-c.size||s(c,g));let i=[...e,...n],o=Math.min(40,Math.max(0,...i.map(c=>c.isDir?c.name.length+1:c.name.length))),a=[];for(let c of i){let g=c.isDir?`${c.name}/`:c.name,_=c.isDir?"":oi(c.size);a.push(_?`${g.padEnd(o)} ${_}`:g)}if(a.length>at){let c=a.length-at;a=[...a.slice(0,at),`\u2026 ${c} more lines omitted`]}let l=n.length===1?"file":"files",u=e.length===1?"dir":"dirs",d=ci(n),f=`${n.length} ${l}, ${e.length} ${u}`+(d?` (${d})`:"");return a.push(f),a}$("smart-ls",li);$("smart-read",t=>Xe(t));var fn=1e3;function ui(t){let e=t.filter(d=>d.trim()!=="");if(e.length===0||e.filter(d=>!/\s/.test(d.trim())).length<e.length*.6)return t;let r=new Map,s=[],i=0;for(let d of e){let f=d.trim();if(f.startsWith("find:")){s.push(f);continue}let c=f.replace(/^\.\//,"").replace(/\/+$/,""),g=c.lastIndexOf("/"),_=g>=0?c.slice(0,g):"",k=g>=0?c.slice(g+1):c;if(!k)continue;let A=r.get(_)??[];A.push(/\s/.test(k)?`"${k}"`:k),r.set(_,A),i+=1}if(i===0)return t;let o=new Set([""]);for(let d of r.keys()){if(d==="")continue;let f=d.split("/");for(let c=1;c<=f.length;c+=1)o.add(f.slice(0,c).join("/"))}let a=[...o].sort(),l=a.filter(d=>d!=="").length,u=[`${i}F ${l}D:`,""];for(let d of a){let f=d===""?0:d.split("/").length,c=d===""?".":d.slice(d.lastIndexOf("/")+1),g=r.get(d)??[],_=g.length?` ${g.join(" ")}`:"";u.push(`${" ".repeat(f)}${c}/${_}`)}if(u.length+s.length>fn){let d=Math.max(0,fn-s.length),f=u.length-d;return[...u.slice(0,d),`\u2026 ${f} more lines omitted`,...s]}return[...u,...s]}$("smart-find",ui);var ct=1e3,pn=200,di=60,fi=190,pi=/^([^\s:]+):(\d+):(.*)$/,mi=/^([^:]+?)-(\d+)-(.*)$/,hi=/^([^\s:]+):(.*)$/,mn=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;function hn(t){let e=t.trim();return e.length>pn?`${e.slice(0,pn)}\u2026`:e}function gi(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>fi&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function yi(t){let e=t.filter(f=>f.trim()!=="");if(e.length===0)return t;let n=new Map,r=new Map,s=null,i=0,o=0;for(let f of e){if(f==="--"){s&&n.get(s).push({separator:!0});continue}if(/^[A-Za-z]:[\\/]/.test(f))return t;let c=pi.exec(f),g=mi.exec(f);if(c&&g)return t;let _=c||g?null:hi.exec(f),k=(c??g??_)?.[1];if(!k)return t;let A=c?{line:c[2],content:c[3],context:!1}:g?{line:g[2],content:g[3],context:!0}:{line:"",content:_[2],context:!1},R=n.get(k)??[];R.push(A),n.set(k,R),A.context||(i+=1,r.set(k,(r.get(k)??0)+1)),o+=1,s=k}if(n.size===o)return t;let a=[...n.keys()].sort((f,c)=>{let g=mn.test(f)?1:0,_=mn.test(c)?1:0;return g-_||(f<c?-1:f>c?1:0)}),l=[];for(let f of a){l.push(`${f} (${r.get(f)??0}):`);for(let c of n.get(f))"separator"in c?l.push(" --"):c.line?l.push(` ${c.line}${c.context?"-":":"} ${hn(c.content)}`):l.push(` ${hn(c.content)}`)}let u=a.length>1&&l.length>di?gi(a.map(f=>`${f} (${r.get(f)??0})`)):[],d=[`${i}m ${a.length}f:`,...u,"",...l];if(d.length>ct){let f=d.length-ct;return[...d.slice(0,ct),`\u2026 ${f} more lines omitted`]}return d}$("smart-grep",yi);var gn=/^(?:([|\\/ ._-]*\*[|\\/* ._-]* ))?commit [0-9a-f]{7,40}\b/,_i=/^[|\\/* ._-]*$/,bi=/^ {4}/,vi=2;function xi(t){if(!t.some(u=>gn.test(u)))return t;let e=[],n=0,r=0,s=0,i="",o=!1,a=!1,l=()=>{r>0&&e.push(`${i} \u2026 ${r} ${r===1?"line":"lines"} folded \u2026`),r=0};for(let u of t){let d=u.slice(0,s),f=_i.test(d),c=f?u.slice(s):u,g=bi.test(c),_=o&&g?null:gn.exec(u);if(_){l(),n=0,s=_[1]?.length??0,o=!0,a=!1,e.push(u);continue}if(/^diff --(?:git|cc|combined) /.test(c)&&(a=!0),g&&!a&&!(s>0&&c.trim().length===0)){n+=1,n<=vi?e.push(u):(r+=1,i=f?d:"");continue}l(),e.push(u)}return l(),e}$("smart-log",xi);var ki=/^[\s=]+$/,Ei=/^\s*=+\s+(.*?)\s+=+\s*$/,wi=512;$("strip-banners",t=>{let e=[];for(let n of t){if(ki.test(n))continue;let r=n.length<=wi?Ei.exec(n):null;e.push(r?r[1]:n)}return e});function Si(t){let e=[],n=0,r=0;for(;r<t.length;){let s=t[r].replace(/\s+$/,"");if(s===""){n+=1,r+=1,n<=1&&e.push("");continue}n=0;let i=1;for(;r+i<t.length&&t[r+i].replace(/\s+$/,"")===s;)i+=1;if(i>=3)e.push(s),e.push(` \u2026 (repeated ${i}x)`);else for(let o=0;o<i;o++)e.push(s);r+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}$("squeeze-output",Si);function Ti(t){return t==="compact"?.6:t==="minimal"?.3:1}var Ai=20;function Ri(t){let[e,n,r,s]=t.slice(-4);if(!e||!n||!r||!s||!/^\s*Test Files\s+([1-9]\d*) passed \(\1\)$/.test(e)||!/^\s*Tests\s+([1-9]\d*) passed \(\1\)$/.test(n)||!/^\s*Start at\s+\d{2}:\d{2}:\d{2}$/.test(r))return t;let i=/^(\s*Duration\s+\d+(?:\.\d+)?(?:ms|s)) \(transform [^\n]+\)$/.exec(s)?.[1];return i?[...t.slice(0,-4).filter((a,l)=>l>2||!/^ RUN v\d+\.\d+\.\d+(?:[\w.+-]*) .+$/.test(a)),e,n,i]:t}var yn=new WeakMap;function Ci(t){let e=yn.get(t);if(e)return e;let n=t.strip_lines_matching.map(s=>new RegExp(s)),r={def:t,stripRegexes:n};return yn.set(t,r),r}function _n(t,e,n={}){return lt(t,e,n).text}function lt(t,e,n={}){let r=n.verbosity??"normal";if(!e.strip_ansi&&e.strip_lines_matching.length===0&&!e.transform&&!e.mask_abs_paths&&!e.fold_passing&&!e.truncate_lines_at&&!e.max_lines&&!e.on_empty&&!n.smartCode&&r==="normal")return{text:t,droppedTail:null};let s=Ci(e),i=t;e.strip_ansi&&(i=ge(i));let o=i.endsWith(`
6
+ `),a=(o?i.slice(0,-1):i).split(`
7
+ `);if(s.stripRegexes.length&&(a=e.keep_failures?a.filter(f=>Q.test(f)||!s.stripRegexes.some(c=>c.test(f))):en(a,s.stripRegexes)),r!=="normal"&&!e.preserve_exact&&(a=cn(a),a=ln(a)),r==="minimal"&&!e.preserve_exact&&(a=an(a),(e.slug==="vitest"||e.slug==="npm-test")&&(a=Ri(a))),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&r!=="normal"&&on(i))&&(a=Xe(a)),e.transform){let f=dn(e.transform);f&&(a=f(a))}let l=e.slug==="read-tool";if(!l){let f=ot(a);f.some(Boolean)&&(a=a.filter((c,g)=>!f[g]))}e.mask_abs_paths&&(a=sn(a)),e.fold_passing&&(a=rn(a,e.fold_passing_threshold??5)),e.truncate_lines_at&&(a=tn(a,e.truncate_lines_at));let u=null;if(e.max_lines){let f=e.scale_with_level?Ti(n.verbosity):1,c=Math.min(e.max_lines,Math.max(Ai,Math.round(e.max_lines*f))),g=l?ot(a):null,_=g?g.filter(k=>!k).length:a.length;if(_>c){let k=c;if(g){let R=0;for(k=0;k<a.length&&R<c;)g[k]||(R+=1),k+=1}let A=_-c;if(e.keep_failures){let R=a.slice(k),B=R.filter(C=>!Q.test(C)),Re=R.reduce((C,Ce,Ie)=>C+(!Q.test(Ce)&&!g?.[k+Ie]?1:0),0);u=B.length>0?B.join(`
8
+ `):null,a=[...a.slice(0,k),...Re>0?[Je(Re)]:[],...R.filter(C=>Q.test(C))]}else if(l)u=a.slice(k).join(`
9
+ `),a=[...a.slice(0,k),Je(A)];else{let{kept:R,dropped:B}=nn(a,c);u=B.length>0?B.join(`
10
+ `):null,a=R}}}let d=a.join(`
11
+ `);return o&&d.length>0&&(d+=`
12
+ `),d.trim().length===0&&e.on_empty&&(d=e.on_empty),{text:d,droppedTail:u}}var Ii=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/AssertionError:/,/^\s*(?:error|fatal):/i,/thread '.*' panicked/,/\b[1-9]\d* (?:failed|errors?)\b/];function bn(t){if(!t)return!1;for(let e of ge(t).split(`
13
+ `))if(!/^\s*[✓✔√]\s/.test(e)&&Ii.some(n=>n.test(e)))return!0;return!1}var Oi=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Di=/^[A-Za-z_][A-Za-z0-9_]*=/,ut=/^([a-z]+)-tool(?::\s|$)/;function Pe(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(Di.test(a)){r++;continue}if(Oi.has(a)){for(r++,a==="timeout"&&r<n.length&&/^\d+(?:\.\d+)?[smhd]?$/.test(n[r])&&r++;(a==="stdbuf"||a==="nice")&&r<n.length&&n[r].startsWith("-");)r++;continue}break}if(r>=n.length)return e;let s=n[r],i=s.includes("/")?s.slice(s.lastIndexOf("/")+1):s,o=n.slice(r+1);return o.length?`${i} ${o.join(" ")}`:i}var Ni=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"]);function vn(t,e){let n=!1,r=!1,s=0,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="\\"&&!n){o++;continue}a==="'"&&!r?n=!n:a==='"'&&!n?r=!r:!n&&!r&&(a===";"?(i.push(t.slice(s,o)),s=o+1):a==="|"&&t[o+1]==="|"?(i.push(t.slice(s,o)),o++,s=o+1):a==="|"?e||(i.push(t.slice(s,o)),s=o+1):a==="&"&&t[o+1]==="&"&&(i.push(t.slice(s,o)),o++,s=o+1))}return i.push(t.slice(s)),i}function $i(t){let e=vn(t,!1);for(let n=e.length-1;n>=0;n--){let r=e[n].trim();if(r)return r}return t.trim()}function dt(t){let e=vn(t,!0).map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;for(let n of e.slice(0,-1)){let r=Pe(n).split(/\s+/)[0]??"";if(!Ni.has(r))return null}return $i(e[e.length-1])}function xn(t){let e=!1,n=!1,r=0,s=[];for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&!e){i++;continue}o==="'"&&!n?e=!e:o==='"'&&!e?n=!n:!e&&!n&&(o==="|"||o===";"?(s.push(t.slice(r,i)),o==="|"&&t[i+1]==="|"&&i++,r=i+1):o==="&"&&t[i+1]==="&"&&(s.push(t.slice(r,i)),i++,r=i+1))}s.push(t.slice(r));for(let i=s.length-1;i>=0;i--){let o=s[i].trim();if(o)return o}return t.trim()}function kn(t){let e=ut.exec(t),n=t;if(e){if(e[1]!=="bash")return[t];let i=t.indexOf(": ");if(i<0)return[t];n=t.slice(i+2)}let r=dt(n),s=r?Pe(r):null;return s&&s!==t?[s,t]:[t]}var En=`
14
+ [YOLO: omitted]
15
+ `;function ft(t){let e=Buffer.from(t,"utf8");if(e.length<=256)return t;let n=256-Buffer.byteLength(En,"utf8"),r=Math.floor(n/2);for(;(e[r]&192)===128;)r-=1;let s=e.length-(n-r);for(;(e[s]&192)===128;)s+=1;return e.subarray(0,r).toString("utf8")+En+e.subarray(s).toString("utf8")}var Pi=/^ID {2,}TITLE {2,}BRANCH {2,}STATE {2,}CREATED *$/,Mi=/^… \([1-9]\d* more lines omitted\)$/,Li=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;function Fi(t,e){if(!e)return t.split(`
16
+ `).map(i=>i.replace(/^[ \t]+|[ \t]+(?=\r?$)/g,"")).join(`
17
+ `);let n="",r=!1,s=!1;for(let i of t)r?(n+=i,s?s=!1:i==="\\"?s=!0:i==='"'&&(r=!1)):i==='"'?(r=!0,n+=i):i!==" "&&i!==" "&&i!=="\r"&&i!==`
18
+ `&&(n+=i);return n+(t.endsWith(`
19
+ `)?`
20
+ `:"")}function ji(t,e){if(/@\d|\r/.test(t))return t;let n=t.endsWith(`
21
+ `)?`
22
+ `:"",r=(n?t.slice(0,-1):t).split(`
23
+ `),s=r.findIndex(c=>Pi.test(c));if(s>=0&&r.slice(0,s).some(c=>c!==""&&!/^Showing \d+ of \d+ (?:open|closed|all) pull requests in \S+$/.test(c)))return t;let i=s>=0?[...r[s].matchAll(/\S+/g)].map(c=>c.index):[],o=[];for(let c=s+1;c<r.length;c+=1){let g=r[c];if(Mi.test(g))continue;if(/…|\.\.\./.test(g))return t;let _;if(s>=0){if(/[^\x20-\x7e]/.test(g))return t;let k=i.map((A,R)=>g.slice(A,i[R+1]));if(k.slice(0,-1).some(A=>A[0]===" "||!A.endsWith(" "))||(_=k.map(A=>A.replace(/ +$/,"")),!/^#\d+$/.test(_[0])||!/^\S+$/.test(_[2])||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!/^\d+(?:s|m|h|d|w|mo|y)$/.test(_[4])))return t}else if(_=g.split(" "),_.length!==5||!/^\d+$/.test(_[0])||!_[1]||!_[2]||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!Li.test(_[4])||!Number.isFinite(Date.parse(_[4])))return t;if(_.some(k=>/[\u0000-\u001f\u007f]/.test(k)))return t;o.push({index:c,cells:_})}if(o.length===0)return t;s>=0&&(r[s]="ID TITLE BRANCH STATE CREATED");for(let c of o)r[c.index]=c.cells.join(" ");let a=r.join(`
24
+ `)+n;if(!e)return a;let l=new Map;for(let{cells:c}of o)l.set(c[1],(l.get(c[1])??0)+1);let u=new Map,d=[];for(let[c,g]of l){if(c.length<40||g<3||c.trim().split(/\s+/).length<8)continue;let _=`@${u.size+1}`,k=JSON.stringify(c).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),A=`TITLE ${_} = ${k}`;g*(Buffer.byteLength(c)-Buffer.byteLength(_))<=Buffer.byteLength(A)+1||(u.set(c,_),d.push(A))}if(d.length===0)return a;for(let{index:c,cells:g}of o)r[c]=g.map((_,k)=>k===1?u.get(_)??_:_).join(" ");let f=[...r,"",...d].join(`
25
+ `)+n;return Buffer.byteLength(f)<Buffer.byteLength(a)?f:a}function pt(t,e,n){if(e!=="compact"&&e!=="minimal")return t;let r=t;if(/^[ \t\r\n]*[\[{]/.test(t)){try{JSON.parse(t)}catch{return t}r=Fi(t,e==="minimal")}else n==="gh"&&(r=ji(t,e==="minimal"));return Buffer.byteLength(r)<Buffer.byteLength(t)?r:t}var wn=null;function mt(t){wn=t}async function Bi(t,e){let n=await Yt();return qe(t,n.values(),e)}var zi=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,Zi=2048;async function ht(t,e,n,r={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,yolo:o=!1,...a}=r,l=Pe(xn(t.startsWith("bash-tool: ")?t.slice(11):t)),u=i!=null&&i!==0&&!(i===1&&zi.test(l)),d=wn??Bi,f=null;for(let C of kn(t))if(f=await d(C,n),f)break;!f&&s>=Zi&&!ut.test(t)&&(f=await d(`bash-tool: ${t}`,n));let c=dt(t.startsWith("bash-tool: ")?t.slice(11):t),g=f?.slug==="git-log"&&c!=null&&/^git\s+log(?:\s|$)/.test(Pe(c)),_=i==null&&(g?/^(?:fatal|error):/im.test(ge(e)):bn(e));if(!f||(u||_)&&f.preserve_exact&&!o)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:u||_,...o?{droppedTail:null}:{}};let k=C=>{if(!o)return C;let Ce=C.filteredBytes>s||s>0&&C.output.length===0?e:C.output,Ie=!C.debugBypass&&!f?.preserve_exact?pt(Ce,"minimal",C.filterId??""):Ce,$t=ft(Ie)===Ie?Ie:ft(Ce);return{...C,output:$t,filteredBytes:Buffer.byteLength($t,"utf8"),droppedTail:null}};if(u||_){let C=o?_n(e,{...f,keep_failures:!0,transform:void 0,max_lines:void 0,truncate_lines_at:void 0,on_empty:void 0},{verbosity:"minimal",smartCode:!1}):f.strip_ansi&&!f.preserve_exact?ge(e):e;return k({output:C,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(C,"utf8"),debugBypass:!0})}let{text:A,droppedTail:R}=lt(e,f,o?{...a,verbosity:"minimal"}:a),B=!o&&!f.preserve_exact?pt(A,a.verbosity,f.slug):A,Re=Buffer.byteLength(B,"utf8");return e.trim().length>0&&Re>=s?k({output:e,filterId:f.slug,rawBytes:s,filteredBytes:s,debugBypass:!1,droppedTail:null}):k({output:B,filterId:f.slug,rawBytes:s,filteredBytes:Re,debugBypass:!1,droppedTail:R})}async function Sn(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}import{existsSync as no}from"node:fs";import{fileURLToPath as ro}from"node:url";import{dirname as so,join as io}from"node:path";import{appendFileSync as Gi,chmodSync as Yi,mkdirSync as qi,existsSync as Ji,readFileSync as ou,rmSync as au}from"node:fs";import{dirname as Xi,join as Qi}from"node:path";import Ui from"node:os";import{join as Tn}from"node:path";function T(){return process.env.TOKMIZER_HOME||Tn(Ui.homedir(),".tokmizer")}function Me(){return Tn(T(),"install-id")}import{readFileSync as Hi,renameSync as Vi,statSync as Ki,writeFileSync as Wi}from"node:fs";function Qe(t,e,n){try{if(Ki(t).size<=e)return;let r=Hi(t,"utf8").split(`
26
+ `).filter(a=>a.trim()!==""),s=[],i=0;for(let a=r.length-1;a>=0;a-=1){let l=r[a],u=Buffer.byteLength(l)+1;if(i+u>n)break;s.push(l),i+=u}s.reverse();let o=`${t}.tmp-${process.pid}`;Wi(o,s.length?`${s.join(`
16
27
  `)}
17
- `:"",{mode:384}),Ai(o,t)}catch{}}var Mi="usage.jsonl";var vn=2*1024*1024;function Li(){return $i(T(),Mi)}function xn(t,e,n=Li()){try{let r=Pi(n);Ni(r)||Di(r,{recursive:!0,mode:448});let s=t.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64)||"unknown";Oi(n,`{"t":${Math.floor(Date.now()/1e3)},"s":"${s}","o":${e?1:0}}
18
- `,{mode:384}),Ii(n,384),We(n,vn,vn/2)}catch{}}var Zi=new Set(["tkr","tkr-exec","token","claude","cd","export","source","echo","mkdir","rm","mv","cp","chmod","ln","true","false",":","test","[","exit","return","nohup","sudo","doas","env"]),Ui=new Set(["for","while","until","if","then","else","elif","fi","do","done","case","esac","select","function","time","coproc","in","!","[[","]]","{","}",".","declare","typeset","local","readonly","unset","set","shift","trap","wait","read","eval","exec","break","continue","pushd","popd","dirs","alias","unalias","hash","ulimit","umask","getopts","let","shopt","builtin","command","compgen","complete","disown","suspend","jobs","fg","bg","kill","history","fc","bind","enable","caller","type"]),bn=new Set(["sh","bash","zsh","dash","ksh","fish","python","python3","python2","node","ruby","perl","php","awk","sed","deno","bun"]),kn=/(?:^|\s)(?:--follow|-[0-9a-zA-Z]*f[a-zA-Z]*)(?:\s|=|$)/,Vi=new Set(["docker","podman","kubectl","nerdctl","docker-compose","stern","flyctl"]);function Hi(t,e){let n=ct(e);return n==="tail"||n==="journalctl"?kn.test(t):n==="stern"?!0:Vi.has(n)?/\blogs?\b/.test(t)&&kn.test(t):!1}var En=/^[A-Za-z_][A-Za-z0-9_]*\+?=/,Ki=/^[A-Za-z_][A-Za-z0-9_-]*\s*\(\s*\)/,Wi=/(?:^|[;&|\n({])\s*[A-Za-z_][A-Za-z0-9_-]*\s*\(\s*\)/;function ct(t){let e=t.lastIndexOf("/");return e===-1?t:t.slice(e+1)}function Gi(t){let e=!1,n=!1,r=!1,s=!1;for(let i=0;i<t.length;i++){let o=t[i];if(s){s=!1;continue}if(o==="\\"&&!e){s=!0;continue}if(!n&&!r&&o==="'"){e=!e;continue}if(!e&&!r&&o==='"'){n=!n;continue}if(!e&&!n&&o==="`"){r=!r;continue}if(!e&&!n&&!r&&o===">")return!0}return!1}function wn(t){let e=[],n="",r=0,s=!1,i=!1,o=!1,a=!1,c=0,l=0,u=()=>{n.length>0&&(e.push({kind:"cmd",text:n}),n="")},p=d=>{u(),e.push({kind:"sep",text:d})};for(;r<t.length;){let d=t[r];if(a){n+=d,a=!1,r+=1;continue}if(d==="\\"&&!s){n+=d,a=!0,r+=1;continue}if(!i&&!o&&d==="'"){s=!s,n+=d,r+=1;continue}if(!s&&!o&&d==='"'){i=!i,n+=d,r+=1;continue}if(!s&&!i&&d==="`"){o=!o,n+=d,r+=1;continue}if(!(s||i||o)){if(d==="$"&&t[r+1]==="{"){n+="${",l+=1,r+=2;continue}if(l>0){d==="{"?l+=1:d==="}"&&(l-=1),n+=d,r+=1;continue}if(d==="$"&&t[r+1]==="("){n+="$(",c+=1,r+=2;continue}if(d==="("){n+="(",c+=1,r+=1;continue}if(c>0){d==="("?c+=1:d===")"&&(c-=1),n+=d,r+=1;continue}if(d===">"&&t[r+1]==="|"){n+=">|",r+=2;continue}if(d==="&"&&t[r+1]==="&"){p("&&"),r+=2;continue}if(d==="&"&&t[r+1]!==">"){let S=n.replace(/\s+$/,""),w=S[S.length-1];if(w!==">"&&w!=="<"&&w!=="&"){p("&"),r+=1;continue}}if(d==="|"&&t[r+1]==="|"){p("||"),r+=2;continue}if(d==="|"&&t[r+1]==="&"){p("|&"),r+=2;continue}if(d===";"&&t[r+1]===";"){let S=t[r+2]==="&";p(S?";;&":";;"),r+=S?3:2;continue}if(d===";"){p(";"),r+=1;continue}if(d===`
19
- `){p(`
20
- `),r+=1;continue}if(d==="|"){p("|"),r+=1;continue}}n+=d,r+=1}return s||i||o||c!==0||l!==0||a?[{kind:"cmd",text:t,unsafe:!0}]:(u(),e)}function Yi(t){return t.trim().split(/\s+/)[0]??""}function qi(){try{let t=zi(ji(import.meta.url)),e=Bi(t,"..","bin","tkr-exec.js");return Fi(e)?`node '${e.replace(/'/g,"'\\''")}'`:null}catch{return null}}function Ji(t,e="tkr-exec"){if(t.includes("<<")||Wi.test(t))return t;let n=wn(t),r=[];for(let s=0;s<n.length;s++){let i=n[s];if(i.kind==="sep"||i.unsafe){r.push(i.text);continue}let o=i.text.trim();if(!o){r.push(i.text);continue}let a=Yi(o),c=n[s+1],l=c?.kind==="sep"&&(c.text==="|"||c.text==="|&"),u=c?.kind==="sep"&&c.text==="&";if(Zi.has(a)||Ui.has(a)||bn.has(a)||bn.has(ct(a))||En.test(a)||a.startsWith("(")||a.startsWith("#")||a.startsWith("<")||a.startsWith(">")||Ki.test(o)||Hi(o,a)||a.endsWith(")")||l||u||Gi(i.text)||i.text.includes("<(")||i.text.includes(">(")||a==="node"&&o.includes("tkr-exec.js")){r.push(i.text);continue}let p=i.text.match(/^\s*/)?.[0]??"",d=i.text.match(/\s*$/)?.[0]??"";r.push(`${p}${e} ${o}${d}`)}return r.join("")}var Xi=new Set(["command","workdir","timeout_ms","yield_time_ms","max_output_tokens","shell","login","tty","description"]),Qi=new Set(["cd","cat","head","tail","ls","tree","find","grep","rg","wc","nl","sort","cut","diff","stat","file","du","df","ps","jq","yq","pwd","which"]),eo=new Set(["log","diff","show","status","blame","ls-files","rev-parse","describe","shortlog"]),to={find:/^-(?:delete|exec|execdir|ok|okdir|fprint|fls)/,sort:/^(?:-[^-]*o|--output|--compress-program)/,rg:/^(?:--pre|-[^-]*z|--search-zip)/,yq:/^(?:-[^-]*[is]|--inplace|--split-exp)/,file:/^(?:-C|--compile)/,tree:/^(?:-o|--output|-R$|-H$)/,git:/^(?:--output|--ext-diff|--textconv|-c$|--exec-path|--git-dir|--work-tree)/};function no(t){if(/\$|`|<\(|>\(|\\\r?\n/.test(t)||/>/.test(t.replace(/2>&1|[12]?>\s*\/dev\/null/g,"")))return!1;for(let e of wn(t)){if(e.kind==="sep")continue;if(e.unsafe)return!1;let n=e.text.trim().split(/\s+/).filter(Boolean).map(i=>i.replace(/['"\\]/g,""));if(n.length===0)continue;if(n.some(i=>En.test(i)))return!1;let r=ct(n[0]);if(r!==n[0])return!1;let s=to[r];if(s&&n.slice(1).some(i=>s.test(i)))return!1;if(!(r==="git"?eo.has(n[1]??""):Qi.has(r)))return!1}return!0}function Sn(t,e,n=qi()){if(t.tool_name!=="Bash")return null;let r=t.tool_input??{};if(r.run_in_background)return null;let s=r.command;if(typeof s!="string"||!s||e==="codex"&&Object.keys(r).some(o=>!Xi.has(o))||e==="codex"&&!no(s)||!n)return null;let i=Ji(s,n);return xn(t.session_id??"unknown",i!==s),i===s?null:JSON.stringify({hookSpecificOutput:e==="codex"?{hookEventName:"PreToolUse",permissionDecision:"allow",updatedInput:{...r,command:i}}:{hookEventName:"PreToolUse",updatedInput:{command:i}}})}import{join as ro}from"node:path";import{mkdir as Hl,readFile as so,writeFile as Kl,unlink as Wl,rename as Gl}from"node:fs/promises";var io="state.json";function oo(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function ao(t){return t?.dir??T()}async function Oe(t){let e=ao(t);try{let n=await so(ro(e,io),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??oo(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}function co(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function Tn(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>co())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function An(t,e=Date.now()){return t.plan}import{readFile as lo,writeFile as Ql,mkdir as eu,chmod as tu,rm as nu,rename as ru}from"node:fs/promises";import{join as uo}from"node:path";var fo="settings-cache.json",Rn=tt.parse({});async function Ie(){try{let t=await lo(uo(T(),fo),"utf8"),e=JSON.parse(t);return tt.parse({...Rn,...e})}catch{return Rn}}var po=[[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];function De(t){let e=t;for(let[n,r]of po)e=e.replace(n,r);return e}import{join as Nn}from"node:path";import{appendFileSync as xo,chmodSync as bo,existsSync as ko,mkdirSync as Eo,readFileSync as wu,renameSync as Su,rmdirSync as Tu,statSync as wo,unlinkSync as Au,utimesSync as Ru,writeFileSync as Cu}from"node:fs";import{createHash as uu,randomUUID as mo}from"node:crypto";import{readFile as Cn,writeFile as On,mkdir as ho}from"node:fs/promises";async function lt(){try{let n=(await Cn(Ce(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await ho(T(),{recursive:!0});let t=mo();try{return await On(Ce(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await Cn(Ce(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await On(Ce(),t,{mode:384}),t}}import{createRequire as go}from"node:module";var yo=go(import.meta.url);function _o(){for(let t of["../package.json","../../package.json"])try{let e=yo(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var ut=_o();var In=`-----BEGIN PUBLIC KEY-----
28
+ `:"",{mode:384}),Vi(o,t)}catch{}}var eo="usage.jsonl";var An=2*1024*1024;function to(){return Qi(T(),eo)}function Rn(t,e,n=to()){try{let r=Xi(n);Ji(r)||qi(r,{recursive:!0,mode:448});let s=t.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64)||"unknown";Gi(n,`{"t":${Math.floor(Date.now()/1e3)},"s":"${s}","o":${e?1:0}}
29
+ `,{mode:384}),Yi(n,384),Qe(n,An,An/2)}catch{}}var oo=new Set(["tkr","tkr-exec","token","claude","cd","export","source","echo","mkdir","rm","mv","cp","chmod","ln","true","false",":","test","[","exit","return","nohup","sudo","doas","env"]),ao=new Set(["for","while","until","if","then","else","elif","fi","do","done","case","esac","select","function","time","coproc","in","!","[[","]]","{","}",".","declare","typeset","local","readonly","unset","set","shift","trap","wait","read","eval","exec","break","continue","pushd","popd","dirs","alias","unalias","hash","ulimit","umask","getopts","let","shopt","builtin","command","compgen","complete","disown","suspend","jobs","fg","bg","kill","history","fc","bind","enable","caller","type"]),Cn=new Set(["sh","bash","zsh","dash","ksh","fish","python","python3","python2","node","ruby","perl","php","awk","sed","deno","bun"]),In=/(?:^|\s)(?:--follow|-[0-9a-zA-Z]*f[a-zA-Z]*)(?:\s|=|$)/,co=new Set(["docker","podman","kubectl","nerdctl","docker-compose","stern","flyctl"]);function lo(t,e){let n=gt(e);return n==="tail"||n==="journalctl"?In.test(t):n==="stern"?!0:co.has(n)?/\blogs?\b/.test(t)&&In.test(t):!1}var On=/^[A-Za-z_][A-Za-z0-9_]*\+?=/,uo=/^[A-Za-z_][A-Za-z0-9_-]*\s*\(\s*\)/,fo=/(?:^|[;&|\n({])\s*[A-Za-z_][A-Za-z0-9_-]*\s*\(\s*\)/;function gt(t){let e=t.lastIndexOf("/");return e===-1?t:t.slice(e+1)}function po(t){let e=!1,n=!1,r=!1,s=!1;for(let i=0;i<t.length;i++){let o=t[i];if(s){s=!1;continue}if(o==="\\"&&!e){s=!0;continue}if(!n&&!r&&o==="'"){e=!e;continue}if(!e&&!r&&o==='"'){n=!n;continue}if(!e&&!n&&o==="`"){r=!r;continue}if(!e&&!n&&!r&&o===">")return!0}return!1}function Dn(t){let e=[],n="",r=0,s=!1,i=!1,o=!1,a=!1,l=0,u=0,d=()=>{n.length>0&&(e.push({kind:"cmd",text:n}),n="")},f=c=>{d(),e.push({kind:"sep",text:c})};for(;r<t.length;){let c=t[r];if(a){n+=c,a=!1,r+=1;continue}if(c==="\\"&&!s){n+=c,a=!0,r+=1;continue}if(!i&&!o&&c==="'"){s=!s,n+=c,r+=1;continue}if(!s&&!o&&c==='"'){i=!i,n+=c,r+=1;continue}if(!s&&!i&&c==="`"){o=!o,n+=c,r+=1;continue}if(!(s||i||o)){if(c==="$"&&t[r+1]==="{"){n+="${",u+=1,r+=2;continue}if(u>0){c==="{"?u+=1:c==="}"&&(u-=1),n+=c,r+=1;continue}if(c==="$"&&t[r+1]==="("){n+="$(",l+=1,r+=2;continue}if(c==="("){n+="(",l+=1,r+=1;continue}if(l>0){c==="("?l+=1:c===")"&&(l-=1),n+=c,r+=1;continue}if(c===">"&&t[r+1]==="|"){n+=">|",r+=2;continue}if(c==="&"&&t[r+1]==="&"){f("&&"),r+=2;continue}if(c==="&"&&t[r+1]!==">"){let _=n.replace(/\s+$/,""),k=_[_.length-1];if(k!==">"&&k!=="<"&&k!=="&"){f("&"),r+=1;continue}}if(c==="|"&&t[r+1]==="|"){f("||"),r+=2;continue}if(c==="|"&&t[r+1]==="&"){f("|&"),r+=2;continue}if(c===";"&&t[r+1]===";"){let _=t[r+2]==="&";f(_?";;&":";;"),r+=_?3:2;continue}if(c===";"){f(";"),r+=1;continue}if(c===`
30
+ `){f(`
31
+ `),r+=1;continue}if(c==="|"){f("|"),r+=1;continue}}n+=c,r+=1}return s||i||o||l!==0||u!==0||a?[{kind:"cmd",text:t,unsafe:!0}]:(d(),e)}function mo(t){return t.trim().split(/\s+/)[0]??""}function ho(){try{let t=so(ro(import.meta.url)),e=io(t,"..","bin","tkr-exec.js");return no(e)?`node '${e.replace(/'/g,"'\\''")}'`:null}catch{return null}}function go(t,e="tkr-exec"){if(t.includes("<<")||fo.test(t))return t;let n=Dn(t),r=[];for(let s=0;s<n.length;s++){let i=n[s];if(i.kind==="sep"||i.unsafe){r.push(i.text);continue}let o=i.text.trim();if(!o){r.push(i.text);continue}let a=mo(o),l=n[s+1],u=l?.kind==="sep"&&(l.text==="|"||l.text==="|&"),d=l?.kind==="sep"&&l.text==="&";if(oo.has(a)||ao.has(a)||Cn.has(a)||Cn.has(gt(a))||On.test(a)||a.startsWith("(")||a.startsWith("#")||a.startsWith("<")||a.startsWith(">")||uo.test(o)||lo(o,a)||a.endsWith(")")||u||d||po(i.text)||i.text.includes("<(")||i.text.includes(">(")||a==="node"&&o.includes("tkr-exec.js")){r.push(i.text);continue}let f=i.text.match(/^\s*/)?.[0]??"",c=i.text.match(/\s*$/)?.[0]??"";r.push(`${f}${e} ${o}${c}`)}return r.join("")}var yo=new Set(["command","workdir","timeout_ms","yield_time_ms","max_output_tokens","shell","login","tty","description"]),_o=new Set(["cd","cat","head","tail","ls","tree","find","grep","rg","wc","nl","sort","cut","diff","stat","file","du","df","ps","jq","yq","pwd","which"]),bo=new Set(["log","diff","show","status","blame","ls-files","rev-parse","describe","shortlog"]),vo={find:/^-(?:delete|exec|execdir|ok|okdir|fprint|fls)/,sort:/^(?:-[^-]*o|--output|--compress-program)/,rg:/^(?:--pre|-[^-]*z|--search-zip)/,yq:/^(?:-[^-]*[is]|--inplace|--split-exp)/,file:/^(?:-C|--compile)/,tree:/^(?:-o|--output|-R$|-H$)/,git:/^(?:--output|--ext-diff|--textconv|-c$|--exec-path|--git-dir|--work-tree)/};function xo(t){if(/\$|`|<\(|>\(|\\\r?\n/.test(t)||/>/.test(t.replace(/2>&1|[12]?>\s*\/dev\/null/g,"")))return!1;for(let e of Dn(t)){if(e.kind==="sep")continue;if(e.unsafe)return!1;let n=e.text.trim().split(/\s+/).filter(Boolean).map(i=>i.replace(/['"\\]/g,""));if(n.length===0)continue;if(n.some(i=>On.test(i)))return!1;let r=gt(n[0]);if(r!==n[0])return!1;let s=vo[r];if(s&&n.slice(1).some(i=>s.test(i)))return!1;if(!(r==="git"?bo.has(n[1]??""):_o.has(r)))return!1}return!0}function Nn(t,e,n=ho()){if(t.tool_name!=="Bash")return null;let r=t.tool_input??{};if(r.run_in_background)return null;let s=r.command;if(typeof s!="string"||!s||e==="codex"&&Object.keys(r).some(o=>!yo.has(o))||e==="codex"&&!xo(s)||!n)return null;let i=go(s,n);return Rn(t.session_id??"unknown",i!==s),i===s?null:JSON.stringify({hookSpecificOutput:e==="codex"?{hookEventName:"PreToolUse",permissionDecision:"allow",updatedInput:{...r,command:i}}:{hookEventName:"PreToolUse",updatedInput:{command:i}}})}import{join as ko}from"node:path";import{mkdir as bu,readFile as Eo,writeFile as vu,unlink as xu,rename as ku}from"node:fs/promises";var wo="state.json";function So(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function To(t){return t?.dir??T()}async function Le(t){let e=To(t);try{let n=await Eo(ko(e,wo),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??So(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}function Ao(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function $n(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>Ao())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function Pn(t,e=Date.now()){return t.plan}import{readFile as Ro,writeFile as Au,mkdir as Ru,chmod as Cu,rm as Iu,rename as Ou,readdir as Du}from"node:fs/promises";import{join as Co}from"node:path";var Io="settings-cache.json",Mn=$e.parse({}),Mu=$e.partial().extend({filters:$e.shape.filters.removeDefault().partial().optional()});async function Fe(){try{let t=await Ro(Co(T(),Io),"utf8"),e=JSON.parse(t);return $e.parse({...Mn,...e})}catch{return Mn}}var Oo=[[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];function je(t){let e=t;for(let[n,r]of Oo)e=e.replace(n,r);return e}import{join as zn}from"node:path";import{appendFileSync as Fo,chmodSync as jo,existsSync as Bo,mkdirSync as zo,readFileSync as ed,renameSync as td,rmdirSync as nd,statSync as Zo,unlinkSync as rd,utimesSync as sd,writeFileSync as id}from"node:fs";import{createHash as Bu,randomUUID as Do}from"node:crypto";import{readFile as Ln,writeFile as Fn,mkdir as No}from"node:fs/promises";async function yt(){try{let n=(await Ln(Me(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await No(T(),{recursive:!0});let t=Do();try{return await Fn(Me(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await Ln(Me(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await Fn(Me(),t,{mode:384}),t}}import{createRequire as $o}from"node:module";var Po=$o(import.meta.url);function Mo(){for(let t of["../package.json","../../package.json"])try{let e=Po(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var _t=Mo();var jn=`-----BEGIN PUBLIC KEY-----
21
32
  MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
22
33
  -----END PUBLIC KEY-----
23
- `;var vu=300*1e3;function Dn(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??In).replace(/\\n/g,`
24
- `)}var So=512*1024;function Pn(){return Nn(T(),"spool")}function To(t){return Nn(Pn(),`${t}.jsonl`)}function Ge(t,e){try{Eo(Pn(),{recursive:!0,mode:448});let n=To(t);if(ko(n)&&wo(n).size>=So)return;xo(n,JSON.stringify(e)+`
25
- `,{mode:384}),bo(n,384)}catch{return}}var Ro=/^[a-z0-9][a-z0-9._-]*$/i,Co=/^[a-z][a-z-]+$/,Oo=/^[A-Za-z_][A-Za-z0-9_]*=/,Io=new Set(["gh","glab","gup","hub","gist"]),Do=/^(gh[a-z]_|github_pat_|gl(?:pat|rt|soat|imt|dt|ft|agent|oas)-|npm_|xox|sk-|sk_|eyj|a(?:kia|sia|gpa|ida|roa|npa)|aiza|hv[sb]\.)/i,No=24,Po=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"]);function $n(t){let e=t.toLowerCase();return e.startsWith("git")||Io.has(e)}function dt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&Oo.test(e[n]??"");)n+=1;let r=e[n];if(!r||!Ro.test(r)||r.length>No||$n(r)||Do.test(r)||De(r)!==r)return"";let s=e[n+1];return s&&$n(s)?"":(s&&Po.has(r.toLowerCase())&&Co.test(s)?`${r} ${s}`:r).slice(0,64)}async function Mn(t){if(!t.telemetryOptIn)return;let e=dt(t.cmd),n=e&&De(e)===e?e:"other",r=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";Ge("telemetry",{cmd:n,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),...t.tokensRestored?{tokensRestored:Math.max(0,Math.round(t.tokensRestored))}:{},...t.rawTokens!=null?{rawTokens:Math.max(0,Math.round(t.rawTokens))}:{},optimized:t.optimized,...r?{sessionId:r}:{},...t.host?{host:t.host}:{}})}async function Ln(t){if(t.plan!=="pro"||!(await Ie()).telemetryOptIn)return;let e=dt(t.cmd);!e||De(e)!==e||Ge("learn",{cmd:e,filterId:t.filterId==null?null:H(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}import{appendFileSync as $o,chmodSync as Mo,mkdirSync as Lo}from"node:fs";import{join as Fo}from"node:path";var jo="stats.jsonl";var Fn=2*1024*1024;var zo=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Bo=new Set(["-u","-g","-n","-s","-k"]),Zo=/^[a-z0-9][a-z0-9._-]*$/i,Uo=new Set(["git","npm","pnpm","yarn","npx","docker","kubectl","helm","cargo","go","brew","gh","pip","pip3","apt","apt-get","systemctl","terraform","aws","gcloud","az","bundle","rake","rails","prisma","poetry","uv","gem","composer"]),zn=/^[A-Za-z_][A-Za-z0-9_]*=/;function jn(t){return t.length===0||t[0]==="cd"||t.every(e=>zn.test(e))}function Vo(t){let e=[],n="",r=!1,s=null,i=()=>{r&&e.push(n),n="",r=!1};for(let o of t){if(s){o===s?s=null:n+=o;continue}if(o==="'"||o==='"'){s=o,r=!0;continue}if(o===" "||o===" "){i();continue}if(`|;&<>
26
- `.includes(o)){if(i(),jn(e)){e=[];continue}return e}n+=o,r=!0}return i(),jn(e)?[]:e}function Bn(t){let e=Vo(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(zn.test(a)){n+=1;continue}if(zo.has(a)){for(n+=1;n<e.length;){let c=e[n];if(c.startsWith("-")){n+=Bo.has(c)?2:1;continue}if(/^\d+(?:\.\d+)?[smhd]?$/.test(c)){n+=1;continue}break}continue}break}if(n>=e.length)return"";let r=e[n],s=r.includes("/")?r.slice(r.lastIndexOf("/")+1):r,i=e[n+1];return(i&&!i.startsWith("-")&&Zo.test(i)&&Uo.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function Ho(){return Fo(T(),jo)}function Zn(t,e,n=Ho(),r=!1,s,i,o){if(t<=0||e<0||e>t)return;let a=s?`,"h":${JSON.stringify(s)}`:"",c=i?`,"k":${JSON.stringify(i)}`:"",l=o?`,"c":${JSON.stringify(o.slice(0,24))}`:"",u=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}${r?',"m":1':""}${a}${c}${l}}
27
- `;try{Lo(T(),{recursive:!0,mode:448}),$o(n,u,{mode:384}),Mo(n,384),We(n,Fn,Fn/2)}catch{return}}function Un(t,e,n){let r=n!=null?Math.min(t,n):t,s=Math.min(e,r);return{raw:r,filtered:s}}var Ko=[{host:"claude-code",vars:["CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE","CLAUDE_CODE_VERSION","ANTHROPIC_CLAUDE_CODE"]},{host:"codex",vars:["CODEX_VERSION","CODEX_CLI","OPENAI_CODEX","CODEX_THREAD_ID","CODEX_SESSION_ID"]},{host:"cursor",vars:["CURSOR_VERSION","CURSOR_TRACE_ID"]},{host:"cline",vars:["CLINE_VERSION","CLINE_API_KEY"]},{host:"aider",vars:["AIDER_VERSION","AIDER_MODEL"]},{host:"gemini-cli",vars:["GEMINI_CLI_VERSION","GEMINI_API_KEY"]},{host:"windsurf",vars:["WINDSURF_VERSION","WINDSURF_USER"]},{host:"copilot",vars:["GITHUB_COPILOT_VERSION","COPILOT_INTEGRATION_ID"]}],ed=[...Ko.map(t=>t.host),"shell"];function Vn(t){return null}import{createConnection as oa}from"node:net";import{spawn as aa}from"node:child_process";import{existsSync as Jn,openSync as ht,closeSync as Yn,unlinkSync as yt,writeFileSync as _t,mkdirSync as vt,readFileSync as ca,appendFileSync as la,rmSync as ua,statSync as da}from"node:fs";import{dirname as fa,join as xt}from"node:path";import{fileURLToPath as pa}from"node:url";var Wo=m.object({id:m.string().min(1).max(64),op:m.literal("filter"),cmd:m.string().min(1).max(2048),plan:m.enum(["trial","smart","pro"]),allowed:m.array(m.string().min(1).max(64)).max(512).optional(),installId:m.string().min(1).max(64).optional()}),Go=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),Yo=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),qo=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),sd=m.discriminatedUnion("op",[Wo,Go,Yo,qo]),id=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),od=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),Hn=m.object({filter:be.nullable(),cacheHit:m.boolean().optional()}),Ye=`
28
- `,ad=64*1024;function ft(t){return JSON.stringify(t)+Ye}function*Kn(t){let e=0;for(;;){let n=t.indexOf(Ye,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function Ne(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import Jo from"node:os";import{join as Pe}from"node:path";import{existsSync as Xo,statSync as Qo,lstatSync as Wn,unlinkSync as ea,mkdirSync as ta,chmodSync as na}from"node:fs";import{createHash as ra}from"node:crypto";var pt=100;function sa(t){let e=ra("sha256").update(T()).digest("hex").slice(0,8),n=Pe(Jo.tmpdir(),`tkr-${t}-${e}`),r=Pe(n,"d.sock");if(Buffer.byteLength(r)>pt)throw new Error("Temporary directory path is too long for IPC");return Gn(n,t),r}function ia(t,e){try{let n=Wn(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function Gn(t,e){ta(t,{recursive:!0,mode:448});let n=Wn(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");na(t,448)}function $e(){if(process.platform==="win32")return{path:`\\\\.\\pipe\\tokmizer-${process.env.USERNAME??"tokmizer"}`,isPipe:!0};let t=typeof process.getuid=="function"?process.getuid():0,e=process.env.XDG_RUNTIME_DIR;if(e&&ia(e,t)){let s=Pe(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=pt)return{path:s,isPipe:!1}}let n=Pe(T(),"run"),r=Pe(n,"daemon.sock");return Buffer.byteLength(r)>pt?{path:sa(t),isPipe:!1}:(Gn(n,t),{path:r,isPipe:!1})}async function mt(){let{path:t,isPipe:e}=$e();if(e||!Xo(t))return;try{if(!Qo(t).isSocket())return}catch{return}let n=await import("node:net");if(!await new Promise(s=>{let i=n.createConnection(t),o=a=>{i.removeAllListeners();try{i.destroy()}catch{}s(a)};i.once("connect",()=>o(!0)),i.once("error",a=>{let c=a.code;o(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>o(!0),250)}))try{ea(t)}catch{}}var md=5*6e4;var Xn=500,ma=3e3,qn=1,ha=6e4,ga=256*1024;function bt(){return xt(T(),"daemon.spawn.fail")}function kt(){return xt(T(),"daemon.log")}function ya(){try{let t=Number(ca(bt(),"utf8"));return Number.isFinite(t)&&Date.now()-t<ha}catch{return!1}}function _a(t){try{vt(T(),{recursive:!0});let e=kt();try{da(e).size>ga&&yt(e)}catch{}la(e,`${new Date().toISOString()} ${t}
29
- `)}catch{}}function va(t){try{vt(T(),{recursive:!0}),_t(bt(),String(Date.now()))}catch{}_a(`spawn failed: ${t.message}`)}function xa(){try{ua(bt(),{force:!0})}catch{}}async function qe(t,e){return new Promise((n,r)=>{let s=oa(t),i=a=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(o),a){try{s.destroy()}catch{}r(a)}else n(s)},o=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",a=>i(a))})}function ba(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:pa(new URL("../bin/tkr-daemon.js",import.meta.url))}async function gt(t,e=3e3){let n=Math.ceil(e/75),r=process.platform==="win32";for(let s=0;s<n;s++){if(r)try{return(await qe(t,75)).destroy(),!0}catch{}else if(Jn(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function ka(t){let e=ba();if(!Jn(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=$e(),r=process.platform==="win32"?T():fa(n);try{vt(r,{recursive:!0})}catch{}let s=xt(r,"daemon.spawn.lock"),i=null;try{i=ht(s,"wx"),_t(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await gt(n,5e3))return;try{yt(s)}catch{}try{i=ht(s,"wx"),_t(i,String(process.pid))}catch(c){if(c.code==="EEXIST"){await gt(n,5e3);return}throw c}}else throw o}try{let o=null;try{o=ht(kt(),"a")}catch{}if(aa(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{Yn(o)}catch{}if(!await gt(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{Yn(i)}catch{}try{yt(s)}catch{}}}}async function Ea(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:$e(),n=await lt();try{let r=await qe(e,Xn);r.write(ft({id:Ne(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function wa(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await qe(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function Et(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:$e(),n=await lt(),r=null,s=0,i=!1;for(;s<=qn;)try{r=await qe(e,Xn),xa();break}catch{if(s+=1,s>qn)throw new Error(`tkr-daemon unreachable at ${e}`);if(ya())throw new Error(`tkr-daemon spawn on cooldown (see ${kt()})`);await mt();try{await ka(n),i=!0}catch(u){throw va(u),u}}if(!r)throw new Error("tkr-daemon: socket setup failed");let o=new Map,a="";r.setEncoding("utf8"),r.on("data",u=>{a+=u;let p=-1;for(let _=0;_<a.length;_++)a[_]===Ye&&(p=_);if(p<0)return;let d=[];for(let _ of Kn(a.slice(0,p+1)))d.push(_);a=a.slice(p+1);for(let _ of d)if(_)try{let S=JSON.parse(_),w=o.get(S.id);if(!w)continue;clearTimeout(w.timer),o.delete(S.id),w.resolve(S)}catch{}}),r.on("close",()=>{for(let u of o.values())clearTimeout(u.timer),u.reject(new Error("daemon socket closed"));o.clear()}),r.on("error",()=>{});function c(u){return new Promise((p,d)=>{let _=setTimeout(()=>{o.delete(u.id),d(new Error(`daemon request timeout (${u.op})`))},ma);o.set(u.id,{resolve:p,reject:d,timer:_}),r.write(ft(u))})}let l={filter:async(u,p,d)=>{let _=await c({id:Ne(),op:"filter",cmd:u.slice(0,2048),plan:p,...d&&d.length>0?{allowed:d.slice(0,512)}:{},installId:n});if(!_.ok)return null;let S=Hn.safeParse(_.data);return S.success?S.data.filter:null},ping:async()=>{let u=await c({id:Ne(),op:"ping"});if(!u.ok)throw new Error(u.err);return u.data},reload:async()=>{let u=await c({id:Ne(),op:"reload",installId:n});if(!u.ok)throw new Error(u.err);return u.data},close:()=>{try{r.end()}catch{}}};if(!t.skipVersionCheck&&!i){let u=!1;try{u=(await l.ping()).version!==ut}catch{}if(u){try{await Ea(t.socketPath?{socketPath:t.socketPath}:{})}catch{}l.close();let p=await wa(e,2e3);if(await mt(),!p)throw new Error("stale daemon still running after shutdown request");return Et({...t,skipVersionCheck:!0})}}return l}import{createPublicKey as Pa,verify as $a}from"node:crypto";import{createCipheriv as Cd,createDecipheriv as Sa,hkdfSync as Ta,randomBytes as Od}from"node:crypto";var Aa=Buffer.from("tokmizer-bundle-enc-v1"),Ra=Buffer.from("rules-bundle");function Ca(t){return Buffer.from(Ta("sha256",Buffer.from(t,"utf8"),Aa,Ra,32))}function Qn(t,e){let n=Ca(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=Sa("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}import{chmodSync as Nd,readFileSync as Oa,writeFileSync as Pd,mkdirSync as $d,renameSync as Md}from"node:fs";import{join as Ia}from"node:path";var Da=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()});function Na(){return Ia(T(),"bundle-cache.json")}function er(){try{let t=Oa(Na(),"utf8"),e=Da.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var Ma=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array(be)}),qd=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),La=10080*60*1e3;function Fa(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:La}function ja(t,e){let n=Dn();if(!n||!n.includes("BEGIN PUBLIC KEY"))throw new Error("tkr-daemon: no valid signing public key configured (set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM at build time).");let r=Pa({key:n,format:"pem"});if(!$a(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(Qn(t.payload,e))}function za(t,e){let n=ja(t,e),r=Ma.parse(n);if(Date.now()-r.signedAt>Fa())throw new Error("tkr-daemon: rules bundle is stale");let s=new Map;for(let i of r.filters)s.set(i.slug,{...i,matchRegex:new RegExp(i.match_command)});return Vt(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>Ue(i,s.values(),a&&a.length>0?new Set(a):null)}}async function tr(){try{let t=er();if(!t)return null;let e=await Oe();return e?.signingSecret?za(t,e.signingSecret):null}catch{return null}}var Ee=null,Me=null;async function Ba(){if(Ee)return Ee;if(Me)return Me;let t=Et().then(e=>{if(Me===t)return Ee=e,e;try{e.close()}catch{}return null}).catch(()=>null);return Me=t,t}var wt=null,St=!1;async function Za(){return St||(St=!0,wt=await tr()),wt}async function nr(t,e,n){let r=await Za();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(H(s.slug))?null:s}function Ua(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function rr(t){at(async(e,n)=>{let r=t==="free"?"trial":t,s=n??Ze(void 0),i=await Ba();if(!i)return nr(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(H(o.slug))?null:Ua(o)}catch{return nr(e,r,s)}})}function sr(){if(at(null),Ee)try{Ee.close()}catch{}Ee=null,Me=null,wt=null,St=!1}var Va=new Set(["shell","bash","exec","run_shell_command","execute_shell_command"]);async function Ha(t){if(t.event!=="after_tool_call")return{action:"continue"};if(!Va.has(t.tool))return{action:"continue"};let e=t.command??(t.args??[]).join(" ");if(!e)return{action:"continue"};let n=t.stdout??"";if(!n)return{action:"continue"};let r=t.stderr??"",s=await Ie();if(!s.enabled)return{action:"continue"};let i=await Oe();if(!i||!i.token)return{action:"continue"};let o=An(i);rr(o);let a=Ze(i.allowedFilters,Tn(i)),c;try{c=await gn(e,n,a,{verbosity:s.outputVerbosity,exitCode:t.exit_code})}finally{sr()}let l=Un(c.rawBytes,c.filteredBytes,Vn("codex"));return Zn(l.raw,l.filtered,void 0,!1,"codex","sh",Bn(e)),await Ln({cmd:e,filterId:c.filterId,rawBytes:c.rawBytes,filteredBytes:c.filteredBytes,plan:o}),await Mn({cmd:e,tokensSaved:Math.round((l.raw-l.filtered)/4),rawTokens:Math.round(l.raw/4),optimized:c.filterId!=null,telemetryOptIn:s.telemetryOptIn,host:"codex"}),c.filteredBytes>=c.rawBytes?{action:"continue"}:{action:"replace_output",replacement:r?`${c.output}
30
- ${r}`:c.output,reason:"tokmizer"}}async function Ka(t){let e=JSON.stringify({action:"continue"});if(!t)return e;let n;try{n=JSON.parse(t)}catch{return e}if(n.hook_event_name==="PreToolUse")return Sn(n,"codex")??"";if(n.hook_event_name)return"";try{return JSON.stringify(await Ha(n))}catch(r){return process.stderr.write(`tkr-codex: ${r.message}
31
- `),e}}async function ir(){let t=await Ka(await yn());t&&process.stdout.write(t)}ir().catch(t=>{process.stderr.write(`tkr-codex-hook: ${t.message}
34
+ `;var Yu=300*1e3;function Bn(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??jn).replace(/\\n/g,`
35
+ `)}var Uo=512*1024;function Zn(){return zn(T(),"spool")}function Ho(t){return zn(Zn(),`${t}.jsonl`)}function et(t,e){try{zo(Zn(),{recursive:!0,mode:448});let n=Ho(t);if(Bo(n)&&Zo(n).size>=Uo)return;Fo(n,JSON.stringify(e)+`
36
+ `,{mode:384}),jo(n,384)}catch{return}}var Ko=/^[a-z0-9][a-z0-9._-]*$/i,Wo=/^[a-z][a-z-]+$/,Go=/^[A-Za-z_][A-Za-z0-9_]*=/,Yo=new Set(["gh","glab","gup","hub","gist"]),qo=/^(gh[a-z]_|github_pat_|gl(?:pat|rt|soat|imt|dt|ft|agent|oas)-|npm_|xox|sk-|sk_|eyj|a(?:kia|sia|gpa|ida|roa|npa)|aiza|hv[sb]\.)/i,Jo=24,Xo=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"]);function Un(t){let e=t.toLowerCase();return e.startsWith("git")||Yo.has(e)}function bt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&Go.test(e[n]??"");)n+=1;let r=e[n];if(!r||!Ko.test(r)||r.length>Jo||Un(r)||qo.test(r)||je(r)!==r)return"";let s=e[n+1];return s&&Un(s)?"":(s&&Xo.has(r.toLowerCase())&&Wo.test(s)?`${r} ${s}`:r).slice(0,64)}async function Hn(t){if(!t.telemetryOptIn)return;let e=bt(t.cmd),n=e&&je(e)===e?e:"other",r=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";et("telemetry",{cmd:n,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),...t.tokensRestored?{tokensRestored:Math.max(0,Math.round(t.tokensRestored))}:{},...t.rawTokens!=null?{rawTokens:Math.max(0,Math.round(t.rawTokens))}:{},optimized:t.optimized,...r?{sessionId:r}:{},...t.host?{host:t.host}:{}})}async function Vn(t){if(t.plan!=="pro"||!(await Fe()).telemetryOptIn)return;let e=bt(t.cmd);!e||je(e)!==e||et("learn",{cmd:e,filterId:t.filterId==null?null:j(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}import{appendFileSync as Qo,chmodSync as ea,mkdirSync as ta}from"node:fs";import{join as na}from"node:path";var ra="stats.jsonl";var Kn=2*1024*1024;var sa=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),ia=new Set(["-u","-g","-n","-s","-k"]),oa=/^[a-z0-9][a-z0-9._-]*$/i,aa=new Set(["git","npm","pnpm","yarn","npx","docker","kubectl","helm","cargo","go","brew","gh","pip","pip3","apt","apt-get","systemctl","terraform","aws","gcloud","az","bundle","rake","rails","prisma","poetry","uv","gem","composer"]),Gn=/^[A-Za-z_][A-Za-z0-9_]*=/;function Wn(t){return t.length===0||t[0]==="cd"||t.every(e=>Gn.test(e))}function ca(t){let e=[],n="",r=!1,s=null,i=()=>{r&&e.push(n),n="",r=!1};for(let o of t){if(s){o===s?s=null:n+=o;continue}if(o==="'"||o==='"'){s=o,r=!0;continue}if(o===" "||o===" "){i();continue}if(`|;&<>
37
+ `.includes(o)){if(i(),Wn(e)){e=[];continue}return e}n+=o,r=!0}return i(),Wn(e)?[]:e}function Yn(t){let e=ca(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(Gn.test(a)){n+=1;continue}if(sa.has(a)){for(n+=1;n<e.length;){let l=e[n];if(l.startsWith("-")){n+=ia.has(l)?2:1;continue}if(/^\d+(?:\.\d+)?[smhd]?$/.test(l)){n+=1;continue}break}continue}break}if(n>=e.length)return"";let r=e[n],s=r.includes("/")?r.slice(r.lastIndexOf("/")+1):r,i=e[n+1];return(i&&!i.startsWith("-")&&oa.test(i)&&aa.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function la(){return na(T(),ra)}function qn(t,e,n=la(),r=!1,s,i,o){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(e)||t<0||e<0||t+e===0)return;let a=s?`,"h":${JSON.stringify(s)}`:"",l=i?`,"k":${JSON.stringify(i)}`:"",u=o?`,"c":${JSON.stringify(o.slice(0,24))}`:"",d=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}${r?',"m":1':""}${a}${l}${u}}
38
+ `;try{ta(T(),{recursive:!0,mode:448}),Qo(n,d,{mode:384}),ea(n,384),Qe(n,Kn,Kn/2)}catch{return}}function Jn(t,e,n){let r=n!=null?Math.min(t,n):t,s=n!=null?Math.min(e,n):e;return{raw:r,filtered:s}}var ua=[{host:"claude-code",vars:["CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE","CLAUDE_CODE_VERSION","ANTHROPIC_CLAUDE_CODE"]},{host:"codex",vars:["CODEX_VERSION","CODEX_CLI","OPENAI_CODEX","CODEX_THREAD_ID","CODEX_SESSION_ID"]},{host:"cursor",vars:["CURSOR_VERSION","CURSOR_TRACE_ID"]},{host:"cline",vars:["CLINE_VERSION","CLINE_API_KEY"]},{host:"aider",vars:["AIDER_VERSION","AIDER_MODEL"]},{host:"gemini-cli",vars:["GEMINI_CLI_VERSION","GEMINI_API_KEY"]},{host:"windsurf",vars:["WINDSURF_VERSION","WINDSURF_USER"]},{host:"copilot",vars:["GITHUB_COPILOT_VERSION","COPILOT_INTEGRATION_ID"]}],Cd=[...ua.map(t=>t.host),"shell"];function Xn(t){return null}import{createConnection as wa}from"node:net";import{spawn as Sa}from"node:child_process";import{existsSync as ir,openSync as Et,closeSync as rr,unlinkSync as St,writeFileSync as Tt,mkdirSync as At,readFileSync as Ta,appendFileSync as Aa,rmSync as Ra,statSync as Ca}from"node:fs";import{dirname as Ia,join as Rt}from"node:path";import{fileURLToPath as Oa}from"node:url";var da=m.object({id:m.string().min(1).max(64),op:m.literal("filter"),cmd:m.string().min(1).max(2048),plan:m.enum(["trial","smart","pro"]),allowed:m.array(m.string().min(1).max(64)).max(512).optional(),installId:m.string().min(1).max(64).optional()}),fa=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),pa=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),ma=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),Nd=m.discriminatedUnion("op",[da,fa,pa,ma]),$d=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),Pd=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),Qn=m.object({filter:Se.nullable(),cacheHit:m.boolean().optional()}),tt=`
39
+ `,Md=64*1024;function vt(t){return JSON.stringify(t)+tt}function*er(t){let e=0;for(;;){let n=t.indexOf(tt,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function Be(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import ha from"node:os";import{join as ze}from"node:path";import{existsSync as ga,statSync as ya,lstatSync as tr,unlinkSync as _a,mkdirSync as ba,chmodSync as va}from"node:fs";import{createHash as xa}from"node:crypto";var xt=100;function ka(t){let e=xa("sha256").update(T()).digest("hex").slice(0,8),n=ze(ha.tmpdir(),`tkr-${t}-${e}`),r=ze(n,"d.sock");if(Buffer.byteLength(r)>xt)throw new Error("Temporary directory path is too long for IPC");return nr(n,t),r}function Ea(t,e){try{let n=tr(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function nr(t,e){ba(t,{recursive:!0,mode:448});let n=tr(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");va(t,448)}function Ze(){if(process.platform==="win32")return{path:`\\\\.\\pipe\\tokmizer-${process.env.USERNAME??"tokmizer"}`,isPipe:!0};let t=typeof process.getuid=="function"?process.getuid():0,e=process.env.XDG_RUNTIME_DIR;if(e&&Ea(e,t)){let s=ze(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=xt)return{path:s,isPipe:!1}}let n=ze(T(),"run"),r=ze(n,"daemon.sock");return Buffer.byteLength(r)>xt?{path:ka(t),isPipe:!1}:(nr(n,t),{path:r,isPipe:!1})}async function kt(){let{path:t,isPipe:e}=Ze();if(e||!ga(t))return;try{if(!ya(t).isSocket())return}catch{return}let n=await import("node:net");if(!await new Promise(s=>{let i=n.createConnection(t),o=a=>{i.removeAllListeners();try{i.destroy()}catch{}s(a)};i.once("connect",()=>o(!0)),i.once("error",a=>{let l=a.code;o(l!=="ECONNREFUSED"&&l!=="ENOENT")}),setTimeout(()=>o(!0),250)}))try{_a(t)}catch{}}var Ud=5*6e4;var or=500,Da=3e3,sr=1,Na=6e4,$a=256*1024;function Ct(){return Rt(T(),"daemon.spawn.fail")}function It(){return Rt(T(),"daemon.log")}function Pa(){try{let t=Number(Ta(Ct(),"utf8"));return Number.isFinite(t)&&Date.now()-t<Na}catch{return!1}}function Ma(t){try{At(T(),{recursive:!0});let e=It();try{Ca(e).size>$a&&St(e)}catch{}Aa(e,`${new Date().toISOString()} ${t}
40
+ `)}catch{}}function La(t){try{At(T(),{recursive:!0}),Tt(Ct(),String(Date.now()))}catch{}Ma(`spawn failed: ${t.message}`)}function Fa(){try{Ra(Ct(),{force:!0})}catch{}}async function nt(t,e){return new Promise((n,r)=>{let s=wa(t),i=a=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(o),a){try{s.destroy()}catch{}r(a)}else n(s)},o=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",a=>i(a))})}function ja(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Oa(new URL("../bin/tkr-daemon.js",import.meta.url))}async function wt(t,e=3e3){let n=Math.ceil(e/75),r=process.platform==="win32";for(let s=0;s<n;s++){if(r)try{return(await nt(t,75)).destroy(),!0}catch{}else if(ir(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function Ba(t){let e=ja();if(!ir(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=Ze(),r=process.platform==="win32"?T():Ia(n);try{At(r,{recursive:!0})}catch{}let s=Rt(r,"daemon.spawn.lock"),i=null;try{i=Et(s,"wx"),Tt(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await wt(n,5e3))return;try{St(s)}catch{}try{i=Et(s,"wx"),Tt(i,String(process.pid))}catch(l){if(l.code==="EEXIST"){await wt(n,5e3);return}throw l}}else throw o}try{let o=null;try{o=Et(It(),"a")}catch{}if(Sa(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{rr(o)}catch{}if(!await wt(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{rr(i)}catch{}try{St(s)}catch{}}}}async function za(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Ze(),n=await yt();try{let r=await nt(e,or);r.write(vt({id:Be(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function Za(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await nt(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function Ot(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Ze(),n=await yt(),r=null,s=0,i=!1;for(;s<=sr;)try{r=await nt(e,or),Fa();break}catch{if(s+=1,s>sr)throw new Error(`tkr-daemon unreachable at ${e}`);if(Pa())throw new Error(`tkr-daemon spawn on cooldown (see ${It()})`);await kt();try{await Ba(n),i=!0}catch(d){throw La(d),d}}if(!r)throw new Error("tkr-daemon: socket setup failed");let o=new Map,a="";r.setEncoding("utf8"),r.on("data",d=>{a+=d;let f=-1;for(let g=0;g<a.length;g++)a[g]===tt&&(f=g);if(f<0)return;let c=[];for(let g of er(a.slice(0,f+1)))c.push(g);a=a.slice(f+1);for(let g of c)if(g)try{let _=JSON.parse(g),k=o.get(_.id);if(!k)continue;clearTimeout(k.timer),o.delete(_.id),k.resolve(_)}catch{}}),r.on("close",()=>{for(let d of o.values())clearTimeout(d.timer),d.reject(new Error("daemon socket closed"));o.clear()}),r.on("error",()=>{});function l(d){return new Promise((f,c)=>{let g=setTimeout(()=>{o.delete(d.id),c(new Error(`daemon request timeout (${d.op})`))},Da);o.set(d.id,{resolve:f,reject:c,timer:g}),r.write(vt(d))})}let u={filter:async(d,f,c)=>{let g=await l({id:Be(),op:"filter",cmd:d.slice(0,2048),plan:f,...c&&c.length>0?{allowed:c.slice(0,512)}:{},installId:n});if(!g.ok)return null;let _=Qn.safeParse(g.data);return _.success?_.data.filter:null},ping:async()=>{let d=await l({id:Be(),op:"ping"});if(!d.ok)throw new Error(d.err);return d.data},reload:async()=>{let d=await l({id:Be(),op:"reload",installId:n});if(!d.ok)throw new Error(d.err);return d.data},close:()=>{try{r.end()}catch{}}};if(!t.skipVersionCheck&&!i){let d=!1;try{d=(await u.ping()).version!==_t}catch{}if(d){try{await za(t.socketPath?{socketPath:t.socketPath}:{})}catch{}u.close();let f=await Za(e,2e3);if(await kt(),!f)throw new Error("stale daemon still running after shutdown request");return Ot({...t,skipVersionCheck:!0})}}return u}import{createPublicKey as Xa,verify as Qa}from"node:crypto";import{createCipheriv as sf,createDecipheriv as Ua,hkdfSync as Ha,randomBytes as of}from"node:crypto";var Va=Buffer.from("tokmizer-bundle-enc-v1"),Ka=Buffer.from("rules-bundle");function Wa(t){return Buffer.from(Ha("sha256",Buffer.from(t,"utf8"),Va,Ka,32))}function ar(t,e){let n=Wa(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=Ua("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}import{chmodSync as lf,readFileSync as Ga,writeFileSync as uf,mkdirSync as df,renameSync as ff}from"node:fs";import{join as Ya}from"node:path";var qa=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()});function Ja(){return Ya(T(),"bundle-cache.json")}function cr(){try{let t=Ga(Ja(),"utf8"),e=qa.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var ec=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array(Se)}),Tf=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),tc=10080*60*1e3;function nc(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:tc}function rc(t,e){let n=Bn();if(!n||!n.includes("BEGIN PUBLIC KEY"))throw new Error("tkr-daemon: no valid signing public key configured (set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM at build time).");let r=Xa({key:n,format:"pem"});if(!Qa(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(ar(t.payload,e))}function sc(t,e){let n=rc(t,e),r=ec.parse(n);if(Date.now()-r.signedAt>nc())throw new Error("tkr-daemon: rules bundle is stale");let s=new Map;for(let i of r.filters)s.set(i.slug,{...i,matchRegex:new RegExp(i.match_command)});return Qt(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>qe(i,s.values(),a&&a.length>0?new Set(a):null)}}async function lr(){try{let t=cr();if(!t)return null;let e=await Le();return e?.signingSecret?sc(t,e.signingSecret):null}catch{return null}}var Ae=null,Ue=null;async function ic(){if(Ae)return Ae;if(Ue)return Ue;let t=Ot().then(e=>{if(Ue===t)return Ae=e,e;try{e.close()}catch{}return null}).catch(()=>null);return Ue=t,t}var Dt=null,Nt=!1;async function oc(){return Nt||(Nt=!0,Dt=await lr()),Dt}async function ur(t,e,n){let r=await oc();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(j(s.slug))?null:s}function ac(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function dr(t){mt(async(e,n)=>{let r=t==="free"?"trial":t,s=n??Ye(void 0),i=await ic();if(!i)return ur(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(j(o.slug))?null:ac(o)}catch{return ur(e,r,s)}})}function fr(){if(mt(null),Ae)try{Ae.close()}catch{}Ae=null,Ue=null,Dt=null,Nt=!1}import{readFileSync as cc}from"node:fs";import{join as lc}from"node:path";function pr(){try{return cc(lc(T(),"yolo-mode"),"utf8")==="on"}catch{return!1}}var uc=new Set(["shell","bash","exec","run_shell_command","execute_shell_command"]);async function dc(t){if(t.event!=="after_tool_call")return{action:"continue"};if(!uc.has(t.tool))return{action:"continue"};let e=t.command??(t.args??[]).join(" ");if(!e)return{action:"continue"};let n=t.stdout??"",r=t.stderr??"",s=pr();if(!n&&(!s||!r))return{action:"continue"};let i=await Fe();if(!i.enabled)return{action:"continue"};let o=await Le();if(!o||!o.token)return{action:"continue"};let a=Pn(o);dr(a);let l=Ye(o.allowedFilters,$n(o)),u=new Set(i.filters.disabled.map(j)),d=u.size>0?new Set([...l].filter(B=>!u.has(B))):l,f,c=null;try{f=await ht(e,n,d,{verbosity:i.outputVerbosity,yolo:s,exitCode:t.exit_code}),s&&r&&(c=await ht(e,r,d,{verbosity:i.outputVerbosity,yolo:s,exitCode:t.exit_code}))}finally{fr()}let g=f.filteredBytes<f.rawBytes||c!=null&&c.filteredBytes<c.rawBytes,_=c?.output??r,k=_?f.output?`${f.output}
41
+ ${_}`:_:f.output,A=Buffer.byteLength(n,"utf8")+Buffer.byteLength(r,"utf8"),R=Jn(A,g?Buffer.byteLength(k,"utf8"):A,Xn("codex"));return qn(R.raw,R.filtered,void 0,!1,"codex","sh",Yn(e)),await Vn({cmd:e,filterId:f.filterId,rawBytes:f.rawBytes,filteredBytes:f.filteredBytes,plan:a}),await Hn({cmd:e,tokensSaved:Math.max(0,Math.round((R.raw-R.filtered)/4)),rawTokens:Math.round(R.raw/4),optimized:f.filterId!=null,telemetryOptIn:i.telemetryOptIn,host:"codex"}),g?{action:"replace_output",replacement:k,reason:"tokmizer"}:{action:"continue"}}async function fc(t){let e=JSON.stringify({action:"continue"});if(!t)return e;let n;try{n=JSON.parse(t)}catch{return e}if(n.hook_event_name==="PreToolUse")return Nn(n,"codex")??"";if(n.hook_event_name)return"";try{return JSON.stringify(await dc(n))}catch(r){return process.stderr.write(`tkr-codex: ${r.message}
42
+ `),e}}async function mr(){let t=await fc(await Sn());t&&process.stdout.write(t)}mr().catch(t=>{process.stderr.write(`tkr-codex-hook: ${t.message}
32
43
  `),process.stdout.write(JSON.stringify({action:"continue"})),process.exit(0)});