@tokmizer/plugin 0.9.51 → 0.9.52

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,52 +1,56 @@
1
1
  import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
2
- var oi=Object.defineProperty;var _=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var wt=(t,e)=>{for(var n in e)oi(t,n,{get:e[n],enumerable:!0})};import ai from"node:os";import{join as rt}from"node:path";function A(){return process.env.TOKMIZER_HOME||rt(ai.homedir(),".tokmizer")}function Ze(){return rt(A(),"install-id")}function St(){return rt(A(),"content-cache")}function kn(t){return rt(St(),t)}var N=_(()=>{"use strict"});import{join as ui}from"node:path";import{mkdir as Du,readFile as di,writeFile as $u,unlink as Nu,rename as Pu}from"node:fs/promises";function pi(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function mi(t){return t?.dir??A()}async function Ue(t){let e=mi(t);try{let n=await di(ui(e,fi),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??pi(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}var fi,st=_(()=>{"use strict";N();fi="state.json"});import{readFileSync as Bi}from"node:fs";import{join as ji}from"node:path";function ee(){try{return Bi(ji(A(),"yolo-mode"),"utf8")==="on"}catch{return!1}}var At=_(()=>{"use strict";N()});var T,Rt,y,H,Ve=_(()=>{(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})(T||(T={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Rt||(Rt={}));y=T.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),H=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,zi,P,it=_(()=>{Ve();p=T.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"]),zi=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),P=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,T.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()}};P.create=t=>new P(t)});var Zi,Y,Ct=_(()=>{it();Ve();Zi=(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,T.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${T.joinValues(t.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${T.joinValues(t.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${T.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}"`:T.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,T.assertNever(t)}return{message:n}},Y=Zi});function Ui(t){Mn=t}function Re(){return Mn}var Mn,ot=_(()=>{Ct();Mn=Y});function h(t,e){let n=Re(),r=He({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Y?void 0:Y].filter(s=>!!s)});t.common.issues.push(r)}var He,Vi,D,x,ue,$,at,ct,te,Ce,It=_(()=>{ot();Ct();He=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}},Vi=[];D=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 x;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 x;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}}},x=Object.freeze({status:"aborted"}),ue=t=>({status:"dirty",value:t}),$=t=>({status:"valid",value:t}),at=t=>t.status==="aborted",ct=t=>t.status==="dirty",te=t=>t.status==="valid",Ce=t=>typeof Promise<"u"&&t instanceof Promise});var Ln=_(()=>{});var b,Fn=_(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}))});function w(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}function Zn(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 ao(t){return new RegExp(`^${Zn(t)}$`)}function Un(t){let e=`${zn}T${Zn(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 co(t,e){return!!((e==="v4"||!e)&&eo.test(t)||(e==="v6"||!e)&&no.test(t))}function lo(t,e){if(!Ji.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 uo(t,e){return!!((e==="v4"||!e)&&to.test(t)||(e==="v6"||!e)&&ro.test(t))}function fo(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function Ie(t){if(t instanceof M){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=F.create(Ie(r))}return new M({...t._def,shape:()=>e})}else return t instanceof X?new X({...t._def,type:Ie(t.element)}):t instanceof F?F.create(Ie(t.unwrap())):t instanceof G?G.create(Ie(t.unwrap())):t instanceof K?K.create(t.items.map(e=>Ie(e))):t}function Dt(t,e){let n=H(t),r=H(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=T.objectKeys(e),i=T.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Dt(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Dt(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function Vn(t,e){return new xe({values:t,typeName:k.ZodEnum,...w(e)})}function jn(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Hn(t,e={},n){return t?re.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=jn(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=jn(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):re.create()}var B,Bn,S,Hi,Ki,Gi,Wi,Yi,Ji,qi,Xi,Qi,Ot,eo,to,no,ro,so,io,zn,oo,ne,de,fe,pe,me,Oe,he,ge,re,q,Z,De,X,M,ye,J,lt,_e,K,ut,$e,Ne,dt,be,ve,xe,ke,se,j,F,G,Ee,we,Pe,po,Ke,Ge,Se,mo,k,ho,Kn,Gn,go,yo,Wn,_o,bo,vo,xo,ko,Eo,wo,So,To,Ao,Ro,Co,Io,Oo,Do,$o,No,Po,Mo,Lo,Fo,Bo,jo,zo,Zo,Uo,Vo,Ho,Ko,Go,Wo,Yo,Jo,qo,Yn=_(()=>{it();ot();Fn();It();Ve();B=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}},Bn=(t,e)=>{if(te(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 P(t.common.issues);return this._error=n,this._error}}};S=class{get description(){return this._def.description}_getType(e){return H(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:H(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:H(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Ce(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:H(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Bn(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:H(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return te(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=>te(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:H(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ce(s)?s:Promise.resolve(s));return Bn(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(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 j({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return F.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X.create(this)}promise(){return se.create(this,this._def)}or(e){return ye.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new j({...w(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ee({...w(this._def),innerType:this,defaultValue:n,typeName:k.ZodDefault})}brand(){return new Ke({typeName:k.ZodBranded,type:this,...w(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new we({...w(this._def),innerType:this,catchValue:n,typeName:k.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ge.create(this,e)}readonly(){return Se.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Hi=/^c[^\s-]{8,}$/i,Ki=/^[0-9a-z]+$/,Gi=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Wi=/^[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,Yi=/^[a-z0-9_-]{21}$/i,Ji=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,qi=/^[-+]?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)?)??$/,Xi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Qi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",eo=/^(?:(?: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])$/,to=/^(?:(?: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])$/,no=/^(([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]))$/,ro=/^(([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])$/,so=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,io=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zn="((\\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])))",oo=new RegExp(`^${zn}$`);ne=class t extends S{_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}),x}let r=new D,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")Xi.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")Ot||(Ot=new RegExp(Qi,"u")),Ot.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")Wi.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")Yi.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")Hi.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")Ki.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")Gi.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"?Un(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"?oo.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?ao(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"?qi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?co(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"?lo(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"?uo(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"?so.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?io.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:p.invalid_string,message:i.message}),r.dirty()):T.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}};ne.create=t=>new ne({checks:[],typeName:k.ZodString,coerce:t?.coerce??!1,...w(t)});de=class t extends S{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}),x}let r,s=new D;for(let i of this._def.checks)i.kind==="int"?T.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"?fo(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()):T.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"&&T.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)}};de.create=t=>new de({checks:[],typeName:k.ZodNumber,coerce:t?.coerce||!1,...w(t)});fe=class t extends S{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 D;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()):T.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}),x}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}};fe.create=t=>new fe({checks:[],typeName:k.ZodBigInt,coerce:t?.coerce??!1,...w(t)});pe=class extends S{_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}),x}return $(e.data)}};pe.create=t=>new pe({typeName:k.ZodBoolean,coerce:t?.coerce||!1,...w(t)});me=class t extends S{_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}),x}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_date}),x}let r=new D,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()):T.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}};me.create=t=>new me({checks:[],coerce:t?.coerce||!1,typeName:k.ZodDate,...w(t)});Oe=class extends S{_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}),x}return $(e.data)}};Oe.create=t=>new Oe({typeName:k.ZodSymbol,...w(t)});he=class extends S{_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}),x}return $(e.data)}};he.create=t=>new he({typeName:k.ZodUndefined,...w(t)});ge=class extends S{_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}),x}return $(e.data)}};ge.create=t=>new ge({typeName:k.ZodNull,...w(t)});re=class extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}};re.create=t=>new re({typeName:k.ZodAny,...w(t)});q=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}};q.create=t=>new q({typeName:k.ZodUnknown,...w(t)});Z=class extends S{_parse(e){let n=this._getOrReturnCtx(e);return h(n,{code:p.invalid_type,expected:y.never,received:n.parsedType}),x}};Z.create=t=>new Z({typeName:k.ZodNever,...w(t)});De=class extends S{_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}),x}return $(e.data)}};De.create=t=>new De({typeName:k.ZodVoid,...w(t)});X=class t extends S{_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}),x;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 B(n,o,n.path,a)))).then(o=>D.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new B(n,o,n.path,a)));return D.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)}};X.create=(t,e)=>new X({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...w(e)});M=class t extends S{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=T.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let l=this._getOrReturnCtx(e);return h(l,{code:p.invalid_type,expected:y.object,received:l.parsedType}),x}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Z&&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],f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new B(s,f,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Z){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:p.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 f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new B(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let f=await u.key,d=await u.value;l.push({key:f,value:d,alwaysSet:u.alwaysSet})}return l}).then(l=>D.mergeObjectSync(r,l)):D.mergeObjectSync(r,c)}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:k.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of T.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 T.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Ie(this)}partial(e){let n={};for(let r of T.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 T.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof F;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Vn(T.objectKeys(this.shape))}};M.create=(t,e)=>new M({shape:()=>t,unknownKeys:"strip",catchall:Z.create(),typeName:k.ZodObject,...w(e)});M.strictCreate=(t,e)=>new M({shape:()=>t,unknownKeys:"strict",catchall:Z.create(),typeName:k.ZodObject,...w(e)});M.lazycreate=(t,e)=>new M({shape:t,unknownKeys:"strip",catchall:Z.create(),typeName:k.ZodObject,...w(e)});ye=class extends S{_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 P(a.ctx.common.issues));return h(n,{code:p.invalid_union,unionErrors:o}),x}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 P(c));return h(n,{code:p.invalid_union,unionErrors:a}),x}}get options(){return this._def.options}};ye.create=(t,e)=>new ye({options:t,typeName:k.ZodUnion,...w(e)});J=t=>t instanceof be?J(t.schema):t instanceof j?J(t.innerType()):t instanceof ve?[t.value]:t instanceof xe?t.options:t instanceof ke?T.objectValues(t.enum):t instanceof Ee?J(t._def.innerType):t instanceof he?[void 0]:t instanceof ge?[null]:t instanceof F?[void 0,...J(t.unwrap())]:t instanceof G?[null,...J(t.unwrap())]:t instanceof Ke||t instanceof Se?J(t.unwrap()):t instanceof we?J(t._def.innerType):[],lt=class t extends S{_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}),x;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]}),x)}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=J(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...w(r)})}};_e=class extends S{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(at(i)||at(o))return x;let a=Dt(i.value,o.value);return a.valid?((ct(i)||ct(o))&&n.dirty(),{status:n.value,value:a.data}):(h(r,{code:p.invalid_intersection_types}),x)};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}))}};_e.create=(t,e,n)=>new _e({left:t,right:e,typeName:k.ZodIntersection,...w(n)});K=class t extends S{_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}),x;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"}),x;!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 c=this._def.items[a]||this._def.rest;return c?c._parse(new B(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>D.mergeArray(n,o)):D.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};K.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new K({items:t,typeName:k.ZodTuple,rest:null,...w(e)})};ut=class t extends S{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}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new B(r,a,r.path,a)),value:o._parse(new B(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?D.mergeObjectAsync(n,s):D.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof S?new t({keyType:e,valueType:n,typeName:k.ZodRecord,...w(r)}):new t({keyType:ne.create(),valueType:e,typeName:k.ZodRecord,...w(n)})}},$e=class extends S{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}),x;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new B(r,a,r.path,[l,"key"])),value:i._parse(new B(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 x;(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 x;(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:k.ZodMap,...w(n)});Ne=class t extends S{_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}),x;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(c){let l=new Set;for(let u of c){if(u.status==="aborted")return x;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 B(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: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)}};Ne.create=(t,e)=>new Ne({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...w(e)});dt=class t extends S{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}),x;function r(a,c){return He({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Re(),Y].filter(l=>!!l),issueData:{code:p.invalid_arguments,argumentsError:c}})}function s(a,c){return He({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Re(),Y].filter(l=>!!l),issueData:{code:p.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof se){let a=this;return $(async function(...c){let l=new P([]),u=await a._def.args.parseAsync(c,i).catch(g=>{throw l.addIssue(r(c,g)),l}),f=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(f,i).catch(g=>{throw l.addIssue(s(f,g)),l})})}else{let a=this;return $(function(...c){let l=a._def.args.safeParse(c,i);if(!l.success)throw new P([r(c,l.error)]);let u=Reflect.apply(o,this,l.data),f=a._def.returns.safeParse(u,i);if(!f.success)throw new P([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:K.create(e).rest(q.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||K.create([]).rest(q.create()),returns:n||q.create(),typeName:k.ZodFunction,...w(r)})}},be=class extends S{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})}};be.create=(t,e)=>new be({getter:t,typeName:k.ZodLazy,...w(e)});ve=class extends S{_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}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}};ve.create=(t,e)=>new ve({value:t,typeName:k.ZodLiteral,...w(e)});xe=class t extends S{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{expected:T.joinValues(r),received:n.parsedType,code:p.invalid_type}),x}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}),x}return $(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})}};xe.create=Vn;ke=class extends S{_parse(e){let n=T.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=T.objectValues(n);return h(r,{expected:T.joinValues(s),received:r.parsedType,code:p.invalid_type}),x}if(this._cache||(this._cache=new Set(T.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=T.objectValues(n);return h(r,{received:r.data,code:p.invalid_enum_value,options:s}),x}return $(e.data)}get enum(){return this._def.values}};ke.create=(t,e)=>new ke({values:t,typeName:k.ZodNativeEnum,...w(e)});se=class extends S{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}),x;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return $(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};se.create=(t,e)=>new se({type:t,typeName:k.ZodPromise,...w(e)});j=class extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{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 x;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"?ue(c.value):n.value==="dirty"?ue(c.value):c});{if(n.value==="aborted")return x;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?x:a.status==="dirty"?ue(a.value):n.value==="dirty"?ue(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"?x:(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"?x:(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(!te(o))return x;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=>te(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):x);T.assertNever(s)}};j.create=(t,e,n)=>new j({schema:t,typeName:k.ZodEffects,effect:e,...w(n)});j.createWithPreprocess=(t,e,n)=>new j({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...w(n)});F=class extends S{_parse(e){return this._getType(e)===y.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:k.ZodOptional,...w(e)});G=class extends S{_parse(e){return this._getType(e)===y.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};G.create=(t,e)=>new G({innerType:t,typeName:k.ZodNullable,...w(e)});Ee=class extends S{_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}};Ee.create=(t,e)=>new Ee({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...w(e)});we=class extends S{_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 Ce(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new P(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new P(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};we.create=(t,e)=>new we({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...w(e)});Pe=class extends S{_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}),x}return{status:"valid",value:e.data}}};Pe.create=t=>new Pe({typeName:k.ZodNaN,...w(t)});po=Symbol("zod_brand"),Ke=class extends S{_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}},Ge=class t extends S{_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"?x:i.status==="dirty"?(n.dirty(),ue(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"?x:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:k.ZodPipeline})}},Se=class extends S{_parse(e){let n=this._def.innerType._parse(e),r=s=>(te(s)&&(s.value=Object.freeze(s.value)),s);return Ce(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};Se.create=(t,e)=>new Se({innerType:t,typeName:k.ZodReadonly,...w(e)});mo={object:M.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(k||(k={}));ho=(t,e={message:`Input not instance of ${t.name}`})=>Hn(n=>n instanceof t,e),Kn=ne.create,Gn=de.create,go=Pe.create,yo=fe.create,Wn=pe.create,_o=me.create,bo=Oe.create,vo=he.create,xo=ge.create,ko=re.create,Eo=q.create,wo=Z.create,So=De.create,To=X.create,Ao=M.create,Ro=M.strictCreate,Co=ye.create,Io=lt.create,Oo=_e.create,Do=K.create,$o=ut.create,No=$e.create,Po=Ne.create,Mo=dt.create,Lo=be.create,Fo=ve.create,Bo=xe.create,jo=ke.create,zo=se.create,Zo=j.create,Uo=F.create,Vo=G.create,Ho=j.createWithPreprocess,Ko=Ge.create,Go=()=>Kn().optional(),Wo=()=>Gn().optional(),Yo=()=>Wn().optional(),Jo={string:(t=>ne.create({...t,coerce:!0})),number:(t=>de.create({...t,coerce:!0})),boolean:(t=>pe.create({...t,coerce:!0})),bigint:(t=>fe.create({...t,coerce:!0})),date:(t=>me.create({...t,coerce:!0}))},qo=x});var m={};wt(m,{BRAND:()=>po,DIRTY:()=>ue,EMPTY_PATH:()=>Vi,INVALID:()=>x,NEVER:()=>qo,OK:()=>$,ParseStatus:()=>D,Schema:()=>S,ZodAny:()=>re,ZodArray:()=>X,ZodBigInt:()=>fe,ZodBoolean:()=>pe,ZodBranded:()=>Ke,ZodCatch:()=>we,ZodDate:()=>me,ZodDefault:()=>Ee,ZodDiscriminatedUnion:()=>lt,ZodEffects:()=>j,ZodEnum:()=>xe,ZodError:()=>P,ZodFirstPartyTypeKind:()=>k,ZodFunction:()=>dt,ZodIntersection:()=>_e,ZodIssueCode:()=>p,ZodLazy:()=>be,ZodLiteral:()=>ve,ZodMap:()=>$e,ZodNaN:()=>Pe,ZodNativeEnum:()=>ke,ZodNever:()=>Z,ZodNull:()=>ge,ZodNullable:()=>G,ZodNumber:()=>de,ZodObject:()=>M,ZodOptional:()=>F,ZodParsedType:()=>y,ZodPipeline:()=>Ge,ZodPromise:()=>se,ZodReadonly:()=>Se,ZodRecord:()=>ut,ZodSchema:()=>S,ZodSet:()=>Ne,ZodString:()=>ne,ZodSymbol:()=>Oe,ZodTransformer:()=>j,ZodTuple:()=>K,ZodType:()=>S,ZodUndefined:()=>he,ZodUnion:()=>ye,ZodUnknown:()=>q,ZodVoid:()=>De,addIssueToContext:()=>h,any:()=>ko,array:()=>To,bigint:()=>yo,boolean:()=>Wn,coerce:()=>Jo,custom:()=>Hn,date:()=>_o,datetimeRegex:()=>Un,defaultErrorMap:()=>Y,discriminatedUnion:()=>Io,effect:()=>Zo,enum:()=>Bo,function:()=>Mo,getErrorMap:()=>Re,getParsedType:()=>H,instanceof:()=>ho,intersection:()=>Oo,isAborted:()=>at,isAsync:()=>Ce,isDirty:()=>ct,isValid:()=>te,late:()=>mo,lazy:()=>Lo,literal:()=>Fo,makeIssue:()=>He,map:()=>No,nan:()=>go,nativeEnum:()=>jo,never:()=>wo,null:()=>xo,nullable:()=>Vo,number:()=>Gn,object:()=>Ao,objectUtil:()=>Rt,oboolean:()=>Yo,onumber:()=>Wo,optional:()=>Uo,ostring:()=>Go,pipeline:()=>Ko,preprocess:()=>Ho,promise:()=>zo,quotelessJson:()=>zi,record:()=>$o,set:()=>Po,setErrorMap:()=>Ui,strictObject:()=>Ro,string:()=>Kn,symbol:()=>bo,transformer:()=>Zo,tuple:()=>Do,undefined:()=>vo,union:()=>Co,unknown:()=>Eo,util:()=>T,void:()=>So});var $t=_(()=>{ot();It();Ln();Ve();Yn();it()});var Me=_(()=>{$t();$t()});var Le,ft=_(()=>{"use strict";Me();Le=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()})});import{readdir as Xo,readFile as Qo}from"node:fs/promises";import{join as Xn,dirname as ea}from"node:path";import{fileURLToPath as ta}from"node:url";function ra(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function Qn(){if(ie)return ie;if(!ra())return!qn&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
3
- `),qn=!0),ie=new Map,ie;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await Xo(Jn)).filter(r=>r.endsWith(".toml"))}catch{return ie=t,ie}for(let r of n){let s=await Qo(Xn(Jn,r),"utf8"),o=e(s).filters;if(o)for(let[a,c]of Object.entries(o)){let l=Le.parse({slug:a,...c});t.set(a,{...l,matchRegex:new RegExp(l.match_command)})}}return ie=t,ie}var na,Jn,ie,qn,er=_(()=>{"use strict";ft();na=ea(ta(import.meta.url)),Jn=process.env.TOKMIZER_FILTERS_DIR||Xn(na,"..","..","filters"),ie=null,qn=!1});var or={};wt(or,{FREE_FALLBACK:()=>ir,OutputVerbosity:()=>rr,ReducerLevel:()=>sr,Settings:()=>Fe,resolveAllowedFilters:()=>We,slugKey:()=>W});import{createHash as sa}from"node:crypto";function W(t){let e=tr.get(t);return e||(e=sa("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),tr.set(t,e)),e}function We(t,e=!1){return e||!t||t.length===0?(nr??=new Set(ir.map(W)),new Set(nr)):new Set(t.map(n=>ia.test(n)?n:W(n)))}var rr,sr,Fe,ir,ia,tr,nr,Te=_(()=>{"use strict";Me();rr=m.enum(["normal","compact","minimal"]),sr=m.enum(["off","light","balanced","max"]),Fe=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:rr.default("compact"),reducer:sr.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),ir=["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"],ia=/^[0-9a-f]{16}$/,tr=new Map;nr=null});function aa(t){if(!t)return"*";let e=ar.get(t);return e===void 0&&(e=[...t].join(","),ar.set(t,e)),e}function pt(t,e,n){let r=`${t}::${aa(n)}`,s=Be.get(r);if(s!==void 0)return s;let i=null;for(let o of e)n&&!n.has(W(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Be.size>=oa){let o=Be.keys().next().value;o&&Be.delete(o)}return Be.set(r,i),i}function cr(){Be.clear()}var Be,oa,ar,Nt=_(()=>{"use strict";Te();Be=new Map,oa=256,ar=new WeakMap});function Ae(t){return t.replace(ca,"").replace(la,"")}var ca,la,mt=_(()=>{"use strict";ca=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,la=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g});function lr(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}var ur=_(()=>{"use strict"});function dr(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`})}var fr=_(()=>{"use strict"});function ht(t){return`\u2026 (${t} more lines omitted)`}function pr(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),ht(s.length),...t.slice(t.length-r)],dropped:s}}var mr=_(()=>{"use strict"});function hr(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)ua.test(a)&&!oe.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var ua,oe,Pt=_(()=>{"use strict";ua=/^\s*(?:[✓✔√]|ok )/,oe=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/});function gr(t){return t.map(e=>e.replace(da,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var da,yr=_(()=>{"use strict";da=/(?:\/[\w.@+-]+){3,}/g});function ga(t){let e=ma.exec(t);return!e||ha.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}function _a(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 ba(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==="&"))&&_a(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}function Mt(t){let e=new Array(t.length).fill(!1);for(let n=0;n<t.length;n+=1){let r=va.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 gt(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if(fa.test(r)&&pa.test(r)||ga(r)||ya.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=ba(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 f=0;f<l-1;f++)e.push("");e.push(t[o-1]),n=o;continue}}e.push(r),n+=1}return e}function br(t){let e=t.slice(0,4096);return!(!xa.test(e)||e.split(`
4
- `).length<6)}var fa,pa,ma,ha,ya,_r,va,xa,yt=_(()=>{"use strict";fa=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,pa=/\{\s*$/,ma=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,ha=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);ya=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;_r=/^\s*… \d+ lines? folded …$/,va=/^\s*… (\d+) lines? folded …$/;xa=/\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 vr(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(Ea.test(s.replace(ka,""))&&!wa.test(s)&&!Sa.test(s)){n+=1;continue}r(),e.push(s)}return r(),e}function xr(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 kr(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 ka,Ea,wa,Sa,Er=_(()=>{"use strict";Pt();ka=/^\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*/,Ea=/^\s*(?:\[(?:DEBUG|TRACE|INFO|VERBOSE)\]|(?:DEBUG|TRACE|INFO|VERBOSE)(?!\s*:))(?=\s|:|$)(?!\s*[+\-*\/%&|^?]*=)/,wa=new RegExp(oe.source,"i"),Sa=/\bWARN(?:ING)?\b/i});function L(t,e){wr.set(t,e)}function Sr(t){return wr.get(t)}var wr,Q=_(()=>{"use strict";wr=new Map});function Ra(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 Ca(t){if(!Ta.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 Ia(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 Oa(t){let e=[],n=[],r=!1;for(let d of t){if(/^total\s+\d+/.test(d))continue;if(Aa.test(d.trim()))return t;let g=Ca(d);g&&(r=!0,(g.isDir?e:n).push(g))}if(!r)return t;let s=(d,g)=>d.name.localeCompare(g.name);e.sort(s),n.sort((d,g)=>g.size-d.size||s(d,g));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 g=d.isDir?`${d.name}/`:d.name,v=d.isDir?"":Ra(d.size);a.push(v?`${g.padEnd(o)} ${v}`:g)}if(a.length>Lt){let d=a.length-Lt;a=[...a.slice(0,Lt),`\u2026 ${d} more lines omitted`]}let c=n.length===1?"file":"files",l=e.length===1?"dir":"dirs",u=Ia(n),f=`${n.length} ${c}, ${e.length} ${l}`+(u?` (${u})`:"");return a.push(f),a}var Ta,Aa,Lt,Tr=_(()=>{"use strict";Q();Ta=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,Aa=/^[./~][^\s]*:$/,Lt=1e3;L("smart-ls",Oa)});var Ar=_(()=>{"use strict";yt();Q();L("smart-read",t=>gt(t))});function Da(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 f=u.trim();if(f.startsWith("find:")){s.push(f);continue}let d=f.replace(/^\.\//,"").replace(/\/+$/,""),g=d.lastIndexOf("/"),v=g>=0?d.slice(0,g):"",E=g>=0?d.slice(g+1):d;if(!E)continue;let R=r.get(v)??[];R.push(/\s/.test(E)?`"${E}"`:E),r.set(v,R),i+=1}if(i===0)return t;let o=new Set([""]);for(let u of r.keys()){if(u==="")continue;let f=u.split("/");for(let d=1;d<=f.length;d+=1)o.add(f.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 f=u===""?0:u.split("/").length,d=u===""?".":u.slice(u.lastIndexOf("/")+1),g=r.get(u)??[],v=g.length?` ${g.join(" ")}`:"";l.push(`${" ".repeat(f)}${d}/${v}`)}if(l.length+s.length>Rr){let u=Math.max(0,Rr-s.length),f=l.length-u;return[...l.slice(0,u),`\u2026 ${f} more lines omitted`,...s]}return[...l,...s]}var Rr,Cr=_(()=>{"use strict";Q();Rr=1e3;L("smart-find",Da)});function Dr(t){let e=t.trim();return e.length>Ir?`${e.slice(0,Ir)}\u2026`:e}function Fa(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>Na&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function Ba(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 d=Pa.exec(f),g=Ma.exec(f);if(d&&g)return t;let v=d||g?null:La.exec(f),E=(d??g??v)?.[1];if(!E)return t;let R=d?{line:d[2],content:d[3],context:!1}:g?{line:g[2],content:g[3],context:!0}:{line:"",content:v[2],context:!1},O=n.get(E)??[];O.push(R),n.set(E,O),R.context||(i+=1,r.set(E,(r.get(E)??0)+1)),o+=1,s=E}if(n.size===o)return t;let a=[...n.keys()].sort((f,d)=>{let g=Or.test(f)?1:0,v=Or.test(d)?1:0;return g-v||(f<d?-1:f>d?1:0)}),c=[];for(let f of a){c.push(`${f} (${r.get(f)??0}):`);for(let d of n.get(f))"separator"in d?c.push(" --"):d.line?c.push(` ${d.line}${d.context?"-":":"} ${Dr(d.content)}`):c.push(` ${Dr(d.content)}`)}let l=a.length>1&&c.length>$a?Fa(a.map(f=>`${f} (${r.get(f)??0})`)):[],u=[`${i}m ${a.length}f:`,...l,"",...c];if(u.length>Ft){let f=u.length-Ft;return[...u.slice(0,Ft),`\u2026 ${f} more lines omitted`]}return u}var Ft,Ir,$a,Na,Pa,Ma,La,Or,$r=_(()=>{"use strict";Q();Ft=1e3,Ir=200,$a=60,Na=190,Pa=/^([^\s:]+):(\d+):(.*)$/,Ma=/^([^:]+?)-(\d+)-(.*)$/,La=/^([^\s:]+):(.*)$/,Or=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;L("smart-grep",Ba)});function Ua(t){if(!t.some(l=>Nr.test(l)))return t;let e=[],n=0,r=0,s=0,i="",o=!1,a=!1,c=()=>{r>0&&e.push(`${i} \u2026 ${r} ${r===1?"line":"lines"} folded \u2026`),r=0};for(let l of t){let u=l.slice(0,s),f=ja.test(u),d=f?l.slice(s):l,g=za.test(d),v=o&&g?null:Nr.exec(l);if(v){c(),n=0,s=v[1]?.length??0,o=!0,a=!1,e.push(l);continue}if(/^diff --(?:git|cc|combined) /.test(d)&&(a=!0),g&&!a&&!(s>0&&d.trim().length===0)){n+=1,n<=Za?e.push(l):(r+=1,i=f?u:"");continue}c(),e.push(l)}return c(),e}var Nr,ja,za,Za,Pr=_(()=>{"use strict";Q();Nr=/^(?:([|\\/ ._-]*\*[|\\/* ._-]* ))?commit [0-9a-f]{7,40}\b/,ja=/^[|\\/* ._-]*$/,za=/^ {4}/,Za=2;L("smart-log",Ua)});var Va,Ha,Ka,Mr=_(()=>{"use strict";Q();Va=/^[\s=]+$/,Ha=/^\s*=+\s+(.*?)\s+=+\s*$/,Ka=512;L("strip-banners",t=>{let e=[];for(let n of t){if(Va.test(n))continue;let r=n.length<=Ka?Ha.exec(n):null;e.push(r?r[1]:n)}return e})});function Ga(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}var Lr=_(()=>{"use strict";Q();L("squeeze-output",Ga)});function Wa(t){return t==="compact"?.6:t==="minimal"?.3:1}function Ja(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,c)=>c>2||!/^ RUN v\d+\.\d+\.\d+(?:[\w.+-]*) .+$/.test(a)),e,n,i]:t}function qa(t){let e=Fr.get(t);if(e)return e;let n=t.strip_lines_matching.map(s=>new RegExp(s)),r={def:t,stripRegexes:n};return Fr.set(t,r),r}function Br(t,e,n={}){return Bt(t,e,n).text}function Bt(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=qa(e),i=t;e.strip_ansi&&(i=Ae(i));let o=i.endsWith(`
2
+ var ci=Object.defineProperty;var _=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var At=(t,e)=>{for(var n in e)ci(t,n,{get:e[n],enumerable:!0})};import li from"node:os";import{join as ot}from"node:path";function R(){return process.env.TOKMIZER_HOME||ot(li.homedir(),".tokmizer")}function He(){return ot(R(),"install-id")}function Ct(){return ot(R(),"content-cache")}function kn(t){return ot(Ct(),t)}var N=_(()=>{"use strict"});import{join as fi}from"node:path";import{mkdir as Mu,readFile as pi,writeFile as Lu,unlink as Fu,rename as Bu}from"node:fs/promises";function hi(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function gi(t){return t?.dir??R()}async function Ke(t){let e=gi(t);try{let n=await pi(fi(e,mi),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??hi(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}var mi,at=_(()=>{"use strict";N();mi="state.json"});import{readFileSync as zi}from"node:fs";import{join as Zi}from"node:path";function ee(){try{return zi(Zi(R(),"yolo-mode"),"utf8")==="on"}catch{return!1}}var Ot=_(()=>{"use strict";N()});var T,Dt,y,H,Ge=_(()=>{(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})(T||(T={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Dt||(Dt={}));y=T.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),H=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,Ui,P,ct=_(()=>{Ge();p=T.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"]),Ui=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),P=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,T.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()}};P.create=t=>new P(t)});var Vi,Y,$t=_(()=>{ct();Ge();Vi=(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,T.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${T.joinValues(t.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${T.joinValues(t.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${T.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}"`:T.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,T.assertNever(t)}return{message:n}},Y=Vi});function Hi(t){Ln=t}function Ce(){return Ln}var Ln,lt=_(()=>{$t();Ln=Y});function h(t,e){let n=Ce(),r=We({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Y?void 0:Y].filter(s=>!!s)});t.common.issues.push(r)}var We,Ki,D,x,ce,$,ut,dt,te,Ie,Nt=_(()=>{lt();$t();We=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}},Ki=[];D=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 x;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 x;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}}},x=Object.freeze({status:"aborted"}),ce=t=>({status:"dirty",value:t}),$=t=>({status:"valid",value:t}),ut=t=>t.status==="aborted",dt=t=>t.status==="dirty",te=t=>t.status==="valid",Ie=t=>typeof Promise<"u"&&t instanceof Promise});var Fn=_(()=>{});var b,Bn=_(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}))});function k(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}function Un(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 lo(t){return new RegExp(`^${Un(t)}$`)}function Vn(t){let e=`${Zn}T${Un(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 uo(t,e){return!!((e==="v4"||!e)&&no.test(t)||(e==="v6"||!e)&&so.test(t))}function fo(t,e){if(!Xi.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 po(t,e){return!!((e==="v4"||!e)&&ro.test(t)||(e==="v6"||!e)&&io.test(t))}function mo(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function Oe(t){if(t instanceof M){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=F.create(Oe(r))}return new M({...t._def,shape:()=>e})}else return t instanceof X?new X({...t._def,type:Oe(t.element)}):t instanceof F?F.create(Oe(t.unwrap())):t instanceof G?G.create(Oe(t.unwrap())):t instanceof K?K.create(t.items.map(e=>Oe(e))):t}function Mt(t,e){let n=H(t),r=H(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=T.objectKeys(e),i=T.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Mt(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Mt(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function Hn(t,e){return new be({values:t,typeName:E.ZodEnum,...k(e)})}function zn(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Kn(t,e={},n){return t?re.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=zn(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=zn(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):re.create()}var B,jn,S,Gi,Wi,Yi,Ji,qi,Xi,Qi,eo,to,Pt,no,ro,so,io,oo,ao,Zn,co,ne,le,ue,de,fe,De,pe,me,re,q,Z,$e,X,M,he,J,ft,ge,K,pt,Ne,Pe,mt,ye,_e,be,ve,se,j,F,G,xe,Ee,Me,ho,Ye,Je,ke,go,E,yo,Gn,Wn,_o,bo,Yn,vo,xo,Eo,ko,wo,So,To,Ro,Ao,Co,Io,Oo,Do,$o,No,Po,Mo,Lo,Fo,Bo,jo,zo,Zo,Uo,Vo,Ho,Ko,Go,Wo,Yo,Jo,qo,Xo,Qo,Jn=_(()=>{ct();lt();Bn();Nt();Ge();B=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}},jn=(t,e)=>{if(te(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 P(t.common.issues);return this._error=n,this._error}}};S=class{get description(){return this._def.description}_getType(e){return H(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:H(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:H(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Ie(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:H(e)},s=this._parseSync({data:e,path:r.path,parent:r});return jn(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:H(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return te(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=>te(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:H(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ie(s)?s:Promise.resolve(s));return jn(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(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 j({schema:this,typeName:E.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 F.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X.create(this)}promise(){return se.create(this,this._def)}or(e){return he.create([this,e],this._def)}and(e){return ge.create(this,e,this._def)}transform(e){return new j({...k(this._def),schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new xe({...k(this._def),innerType:this,defaultValue:n,typeName:E.ZodDefault})}brand(){return new Ye({typeName:E.ZodBranded,type:this,...k(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Ee({...k(this._def),innerType:this,catchValue:n,typeName:E.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Je.create(this,e)}readonly(){return ke.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Gi=/^c[^\s-]{8,}$/i,Wi=/^[0-9a-z]+$/,Yi=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ji=/^[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,qi=/^[a-z0-9_-]{21}$/i,Xi=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Qi=/^[-+]?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)?)??$/,eo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,to="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",no=/^(?:(?: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])$/,ro=/^(?:(?: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])$/,so=/^(([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]))$/,io=/^(([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])$/,oo=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ao=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Zn="((\\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])))",co=new RegExp(`^${Zn}$`);ne=class t extends S{_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}),x}let r=new D,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")eo.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")Pt||(Pt=new RegExp(to,"u")),Pt.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")Ji.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")qi.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")Gi.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")Wi.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")Yi.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"?Vn(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"?co.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?lo(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"?Qi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?uo(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"?fo(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"?po(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"?oo.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?ao.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:p.invalid_string,message:i.message}),r.dirty()):T.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}};ne.create=t=>new ne({checks:[],typeName:E.ZodString,coerce:t?.coerce??!1,...k(t)});le=class t extends S{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}),x}let r,s=new D;for(let i of this._def.checks)i.kind==="int"?T.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"?mo(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()):T.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"&&T.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)}};le.create=t=>new le({checks:[],typeName:E.ZodNumber,coerce:t?.coerce||!1,...k(t)});ue=class t extends S{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 D;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()):T.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}),x}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}};ue.create=t=>new ue({checks:[],typeName:E.ZodBigInt,coerce:t?.coerce??!1,...k(t)});de=class extends S{_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}),x}return $(e.data)}};de.create=t=>new de({typeName:E.ZodBoolean,coerce:t?.coerce||!1,...k(t)});fe=class t extends S{_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}),x}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_date}),x}let r=new D,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()):T.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}};fe.create=t=>new fe({checks:[],coerce:t?.coerce||!1,typeName:E.ZodDate,...k(t)});De=class extends S{_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}),x}return $(e.data)}};De.create=t=>new De({typeName:E.ZodSymbol,...k(t)});pe=class extends S{_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}),x}return $(e.data)}};pe.create=t=>new pe({typeName:E.ZodUndefined,...k(t)});me=class extends S{_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}),x}return $(e.data)}};me.create=t=>new me({typeName:E.ZodNull,...k(t)});re=class extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}};re.create=t=>new re({typeName:E.ZodAny,...k(t)});q=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}};q.create=t=>new q({typeName:E.ZodUnknown,...k(t)});Z=class extends S{_parse(e){let n=this._getOrReturnCtx(e);return h(n,{code:p.invalid_type,expected:y.never,received:n.parsedType}),x}};Z.create=t=>new Z({typeName:E.ZodNever,...k(t)});$e=class extends S{_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}),x}return $(e.data)}};$e.create=t=>new $e({typeName:E.ZodVoid,...k(t)});X=class t extends S{_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}),x;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 B(n,o,n.path,a)))).then(o=>D.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new B(n,o,n.path,a)));return D.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)}};X.create=(t,e)=>new X({type:t,minLength:null,maxLength:null,exactLength:null,typeName:E.ZodArray,...k(e)});M=class t extends S{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=T.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let l=this._getOrReturnCtx(e);return h(l,{code:p.invalid_type,expected:y.object,received:l.parsedType}),x}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Z&&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],f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new B(s,f,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Z){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:p.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 f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new B(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let f=await u.key,d=await u.value;l.push({key:f,value:d,alwaysSet:u.alwaysSet})}return l}).then(l=>D.mergeObjectSync(r,l)):D.mergeObjectSync(r,c)}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:E.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 T.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 T.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Oe(this)}partial(e){let n={};for(let r of T.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 T.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof F;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Hn(T.objectKeys(this.shape))}};M.create=(t,e)=>new M({shape:()=>t,unknownKeys:"strip",catchall:Z.create(),typeName:E.ZodObject,...k(e)});M.strictCreate=(t,e)=>new M({shape:()=>t,unknownKeys:"strict",catchall:Z.create(),typeName:E.ZodObject,...k(e)});M.lazycreate=(t,e)=>new M({shape:t,unknownKeys:"strip",catchall:Z.create(),typeName:E.ZodObject,...k(e)});he=class extends S{_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 P(a.ctx.common.issues));return h(n,{code:p.invalid_union,unionErrors:o}),x}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 P(c));return h(n,{code:p.invalid_union,unionErrors:a}),x}}get options(){return this._def.options}};he.create=(t,e)=>new he({options:t,typeName:E.ZodUnion,...k(e)});J=t=>t instanceof ye?J(t.schema):t instanceof j?J(t.innerType()):t instanceof _e?[t.value]:t instanceof be?t.options:t instanceof ve?T.objectValues(t.enum):t instanceof xe?J(t._def.innerType):t instanceof pe?[void 0]:t instanceof me?[null]:t instanceof F?[void 0,...J(t.unwrap())]:t instanceof G?[null,...J(t.unwrap())]:t instanceof Ye||t instanceof ke?J(t.unwrap()):t instanceof Ee?J(t._def.innerType):[],ft=class t extends S{_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}),x;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]}),x)}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=J(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:E.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...k(r)})}};ge=class extends S{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(ut(i)||ut(o))return x;let a=Mt(i.value,o.value);return a.valid?((dt(i)||dt(o))&&n.dirty(),{status:n.value,value:a.data}):(h(r,{code:p.invalid_intersection_types}),x)};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}))}};ge.create=(t,e,n)=>new ge({left:t,right:e,typeName:E.ZodIntersection,...k(n)});K=class t extends S{_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}),x;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"}),x;!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 c=this._def.items[a]||this._def.rest;return c?c._parse(new B(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>D.mergeArray(n,o)):D.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};K.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new K({items:t,typeName:E.ZodTuple,rest:null,...k(e)})};pt=class t extends S{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}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new B(r,a,r.path,a)),value:o._parse(new B(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?D.mergeObjectAsync(n,s):D.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof S?new t({keyType:e,valueType:n,typeName:E.ZodRecord,...k(r)}):new t({keyType:ne.create(),valueType:e,typeName:E.ZodRecord,...k(n)})}},Ne=class extends S{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}),x;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new B(r,a,r.path,[l,"key"])),value:i._parse(new B(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 x;(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 x;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}}}};Ne.create=(t,e,n)=>new Ne({valueType:e,keyType:t,typeName:E.ZodMap,...k(n)});Pe=class t extends S{_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}),x;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(c){let l=new Set;for(let u of c){if(u.status==="aborted")return x;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 B(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: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)}};Pe.create=(t,e)=>new Pe({valueType:t,minSize:null,maxSize:null,typeName:E.ZodSet,...k(e)});mt=class t extends S{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}),x;function r(a,c){return We({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ce(),Y].filter(l=>!!l),issueData:{code:p.invalid_arguments,argumentsError:c}})}function s(a,c){return We({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ce(),Y].filter(l=>!!l),issueData:{code:p.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof se){let a=this;return $(async function(...c){let l=new P([]),u=await a._def.args.parseAsync(c,i).catch(g=>{throw l.addIssue(r(c,g)),l}),f=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(f,i).catch(g=>{throw l.addIssue(s(f,g)),l})})}else{let a=this;return $(function(...c){let l=a._def.args.safeParse(c,i);if(!l.success)throw new P([r(c,l.error)]);let u=Reflect.apply(o,this,l.data),f=a._def.returns.safeParse(u,i);if(!f.success)throw new P([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:K.create(e).rest(q.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||K.create([]).rest(q.create()),returns:n||q.create(),typeName:E.ZodFunction,...k(r)})}},ye=class extends S{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})}};ye.create=(t,e)=>new ye({getter:t,typeName:E.ZodLazy,...k(e)});_e=class extends S{_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}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}};_e.create=(t,e)=>new _e({value:t,typeName:E.ZodLiteral,...k(e)});be=class t extends S{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{expected:T.joinValues(r),received:n.parsedType,code:p.invalid_type}),x}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}),x}return $(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})}};be.create=Hn;ve=class extends S{_parse(e){let n=T.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=T.objectValues(n);return h(r,{expected:T.joinValues(s),received:r.parsedType,code:p.invalid_type}),x}if(this._cache||(this._cache=new Set(T.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=T.objectValues(n);return h(r,{received:r.data,code:p.invalid_enum_value,options:s}),x}return $(e.data)}get enum(){return this._def.values}};ve.create=(t,e)=>new ve({values:t,typeName:E.ZodNativeEnum,...k(e)});se=class extends S{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}),x;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return $(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};se.create=(t,e)=>new se({type:t,typeName:E.ZodPromise,...k(e)});j=class extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.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 x;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"?ce(c.value):n.value==="dirty"?ce(c.value):c});{if(n.value==="aborted")return x;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?x:a.status==="dirty"?ce(a.value):n.value==="dirty"?ce(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"?x:(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"?x:(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(!te(o))return x;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=>te(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):x);T.assertNever(s)}};j.create=(t,e,n)=>new j({schema:t,typeName:E.ZodEffects,effect:e,...k(n)});j.createWithPreprocess=(t,e,n)=>new j({schema:e,effect:{type:"preprocess",transform:t},typeName:E.ZodEffects,...k(n)});F=class extends S{_parse(e){return this._getType(e)===y.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:E.ZodOptional,...k(e)});G=class extends S{_parse(e){return this._getType(e)===y.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};G.create=(t,e)=>new G({innerType:t,typeName:E.ZodNullable,...k(e)});xe=class extends S{_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}};xe.create=(t,e)=>new xe({innerType:t,typeName:E.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});Ee=class extends S{_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 Ie(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new P(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new P(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Ee.create=(t,e)=>new Ee({innerType:t,typeName:E.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});Me=class extends S{_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}),x}return{status:"valid",value:e.data}}};Me.create=t=>new Me({typeName:E.ZodNaN,...k(t)});ho=Symbol("zod_brand"),Ye=class extends S{_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}},Je=class t extends S{_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"?x:i.status==="dirty"?(n.dirty(),ce(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"?x: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:E.ZodPipeline})}},ke=class extends S{_parse(e){let n=this._def.innerType._parse(e),r=s=>(te(s)&&(s.value=Object.freeze(s.value)),s);return Ie(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};ke.create=(t,e)=>new ke({innerType:t,typeName:E.ZodReadonly,...k(e)});go={object:M.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(E||(E={}));yo=(t,e={message:`Input not instance of ${t.name}`})=>Kn(n=>n instanceof t,e),Gn=ne.create,Wn=le.create,_o=Me.create,bo=ue.create,Yn=de.create,vo=fe.create,xo=De.create,Eo=pe.create,ko=me.create,wo=re.create,So=q.create,To=Z.create,Ro=$e.create,Ao=X.create,Co=M.create,Io=M.strictCreate,Oo=he.create,Do=ft.create,$o=ge.create,No=K.create,Po=pt.create,Mo=Ne.create,Lo=Pe.create,Fo=mt.create,Bo=ye.create,jo=_e.create,zo=be.create,Zo=ve.create,Uo=se.create,Vo=j.create,Ho=F.create,Ko=G.create,Go=j.createWithPreprocess,Wo=Je.create,Yo=()=>Gn().optional(),Jo=()=>Wn().optional(),qo=()=>Yn().optional(),Xo={string:(t=>ne.create({...t,coerce:!0})),number:(t=>le.create({...t,coerce:!0})),boolean:(t=>de.create({...t,coerce:!0})),bigint:(t=>ue.create({...t,coerce:!0})),date:(t=>fe.create({...t,coerce:!0}))},Qo=x});var m={};At(m,{BRAND:()=>ho,DIRTY:()=>ce,EMPTY_PATH:()=>Ki,INVALID:()=>x,NEVER:()=>Qo,OK:()=>$,ParseStatus:()=>D,Schema:()=>S,ZodAny:()=>re,ZodArray:()=>X,ZodBigInt:()=>ue,ZodBoolean:()=>de,ZodBranded:()=>Ye,ZodCatch:()=>Ee,ZodDate:()=>fe,ZodDefault:()=>xe,ZodDiscriminatedUnion:()=>ft,ZodEffects:()=>j,ZodEnum:()=>be,ZodError:()=>P,ZodFirstPartyTypeKind:()=>E,ZodFunction:()=>mt,ZodIntersection:()=>ge,ZodIssueCode:()=>p,ZodLazy:()=>ye,ZodLiteral:()=>_e,ZodMap:()=>Ne,ZodNaN:()=>Me,ZodNativeEnum:()=>ve,ZodNever:()=>Z,ZodNull:()=>me,ZodNullable:()=>G,ZodNumber:()=>le,ZodObject:()=>M,ZodOptional:()=>F,ZodParsedType:()=>y,ZodPipeline:()=>Je,ZodPromise:()=>se,ZodReadonly:()=>ke,ZodRecord:()=>pt,ZodSchema:()=>S,ZodSet:()=>Pe,ZodString:()=>ne,ZodSymbol:()=>De,ZodTransformer:()=>j,ZodTuple:()=>K,ZodType:()=>S,ZodUndefined:()=>pe,ZodUnion:()=>he,ZodUnknown:()=>q,ZodVoid:()=>$e,addIssueToContext:()=>h,any:()=>wo,array:()=>Ao,bigint:()=>bo,boolean:()=>Yn,coerce:()=>Xo,custom:()=>Kn,date:()=>vo,datetimeRegex:()=>Vn,defaultErrorMap:()=>Y,discriminatedUnion:()=>Do,effect:()=>Vo,enum:()=>zo,function:()=>Fo,getErrorMap:()=>Ce,getParsedType:()=>H,instanceof:()=>yo,intersection:()=>$o,isAborted:()=>ut,isAsync:()=>Ie,isDirty:()=>dt,isValid:()=>te,late:()=>go,lazy:()=>Bo,literal:()=>jo,makeIssue:()=>We,map:()=>Mo,nan:()=>_o,nativeEnum:()=>Zo,never:()=>To,null:()=>ko,nullable:()=>Ko,number:()=>Wn,object:()=>Co,objectUtil:()=>Dt,oboolean:()=>qo,onumber:()=>Jo,optional:()=>Ho,ostring:()=>Yo,pipeline:()=>Wo,preprocess:()=>Go,promise:()=>Uo,quotelessJson:()=>Ui,record:()=>Po,set:()=>Lo,setErrorMap:()=>Hi,strictObject:()=>Io,string:()=>Gn,symbol:()=>xo,transformer:()=>Vo,tuple:()=>No,undefined:()=>Eo,union:()=>Oo,unknown:()=>So,util:()=>T,void:()=>Ro});var Lt=_(()=>{lt();Nt();Fn();Ge();Jn();ct()});var Le=_(()=>{Lt();Lt()});var Fe,ht=_(()=>{"use strict";Le();Fe=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()})});import{readdir as ea,readFile as ta}from"node:fs/promises";import{join as Qn,dirname as na}from"node:path";import{fileURLToPath as ra}from"node:url";function ia(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function er(){if(ie)return ie;if(!ia())return!Xn&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
3
+ `),Xn=!0),ie=new Map,ie;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await ea(qn)).filter(r=>r.endsWith(".toml"))}catch{return ie=t,ie}for(let r of n){let s=await ta(Qn(qn,r),"utf8"),o=e(s).filters;if(o)for(let[a,c]of Object.entries(o)){let l=Fe.parse({slug:a,...c});t.set(a,{...l,matchRegex:new RegExp(l.match_command)})}}return ie=t,ie}var sa,qn,ie,Xn,tr=_(()=>{"use strict";ht();sa=na(ra(import.meta.url)),qn=process.env.TOKMIZER_FILTERS_DIR||Qn(sa,"..","..","filters"),ie=null,Xn=!1});var ar={};At(ar,{FREE_FALLBACK:()=>or,OutputVerbosity:()=>sr,ReducerLevel:()=>ir,Settings:()=>Be,resolveAllowedFilters:()=>qe,slugKey:()=>W});import{createHash as oa}from"node:crypto";function W(t){let e=nr.get(t);return e||(e=oa("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),nr.set(t,e)),e}function qe(t,e=!1){return e||!t||t.length===0?(rr??=new Set(or.map(W)),new Set(rr)):new Set(t.map(n=>aa.test(n)?n:W(n)))}var sr,ir,Be,or,aa,nr,rr,we=_(()=>{"use strict";Le();sr=m.enum(["normal","compact","minimal"]),ir=m.enum(["off","light","balanced","max"]),Be=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:sr.default("compact"),reducer:ir.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),or=["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"],aa=/^[0-9a-f]{16}$/,nr=new Map;rr=null});function la(t){if(!t)return"*";let e=cr.get(t);return e===void 0&&(e=[...t].join(","),cr.set(t,e)),e}function gt(t,e,n){let r=`${t}::${la(n)}`,s=je.get(r);if(s!==void 0)return s;let i=null;for(let o of e)n&&!n.has(W(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(je.size>=ca){let o=je.keys().next().value;o&&je.delete(o)}return je.set(r,i),i}function lr(){je.clear()}var je,ca,cr,Ft=_(()=>{"use strict";we();je=new Map,ca=256,cr=new WeakMap});function Se(t){return t.replace(ua,"").replace(da,"")}var ua,da,yt=_(()=>{"use strict";ua=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,da=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g});function ur(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}var dr=_(()=>{"use strict"});function fr(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`})}var pr=_(()=>{"use strict"});function _t(t){return`\u2026 (${t} more lines omitted)`}function mr(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),_t(s.length),...t.slice(t.length-r)],dropped:s}}var hr=_(()=>{"use strict"});function gr(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)fa.test(a)&&!oe.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var fa,oe,Bt=_(()=>{"use strict";fa=/^\s*(?:[✓✔√]|ok )/,oe=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/});function yr(t){return t.map(e=>e.replace(pa,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var pa,_r=_(()=>{"use strict";pa=/(?:\/[\w.@+-]+){3,}/g});function _a(t){let e=ga.exec(t);return!e||ya.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}function va(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 xa(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==="&"))&&va(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}function jt(t){let e=new Array(t.length).fill(!1);for(let n=0;n<t.length;n+=1){let r=Ea.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 bt(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if(ma.test(r)&&ha.test(r)||_a(r)||ba.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=xa(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 f=0;f<l-1;f++)e.push("");e.push(t[o-1]),n=o;continue}}e.push(r),n+=1}return e}function vt(t){let e=t.slice(0,4096);return!(!ka.test(e)||e.split(`
4
+ `).length<6)}var ma,ha,ga,ya,ba,br,Ea,ka,Xe=_(()=>{"use strict";ma=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,ha=/\{\s*$/,ga=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,ya=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);ba=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;br=/^\s*… \d+ lines? folded …$/,Ea=/^\s*… (\d+) lines? folded …$/;ka=/\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 vr(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(Sa.test(s.replace(wa,""))&&!Ta.test(s)&&!Ra.test(s)){n+=1;continue}r(),e.push(s)}return r(),e}function xr(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 Er(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 wa,Sa,Ta,Ra,kr=_(()=>{"use strict";Bt();wa=/^\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*/,Sa=/^\s*(?:\[(?:DEBUG|TRACE|INFO|VERBOSE)\]|(?:DEBUG|TRACE|INFO|VERBOSE)(?!\s*:))(?=\s|:|$)(?!\s*[+\-*\/%&|^?]*=)/,Ta=new RegExp(oe.source,"i"),Ra=/\bWARN(?:ING)?\b/i});function L(t,e){wr.set(t,e)}function Sr(t){return wr.get(t)}var wr,Q=_(()=>{"use strict";wr=new Map});function Ia(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 Oa(t){if(!Aa.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 Da(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 $a(t){let e=[],n=[],r=!1;for(let d of t){if(/^total\s+\d+/.test(d))continue;if(Ca.test(d.trim()))return t;let g=Oa(d);g&&(r=!0,(g.isDir?e:n).push(g))}if(!r)return t;let s=(d,g)=>d.name.localeCompare(g.name);e.sort(s),n.sort((d,g)=>g.size-d.size||s(d,g));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 g=d.isDir?`${d.name}/`:d.name,v=d.isDir?"":Ia(d.size);a.push(v?`${g.padEnd(o)} ${v}`:g)}if(a.length>zt){let d=a.length-zt;a=[...a.slice(0,zt),`\u2026 ${d} more lines omitted`]}let c=n.length===1?"file":"files",l=e.length===1?"dir":"dirs",u=Da(n),f=`${n.length} ${c}, ${e.length} ${l}`+(u?` (${u})`:"");return a.push(f),a}var Aa,Ca,zt,Tr=_(()=>{"use strict";Q();Aa=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,Ca=/^[./~][^\s]*:$/,zt=1e3;L("smart-ls",$a)});var Rr=_(()=>{"use strict";Xe();Q();L("smart-read",t=>bt(t))});function Na(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 f=u.trim();if(f.startsWith("find:")){s.push(f);continue}let d=f.replace(/^\.\//,"").replace(/\/+$/,""),g=d.lastIndexOf("/"),v=g>=0?d.slice(0,g):"",w=g>=0?d.slice(g+1):d;if(!w)continue;let A=r.get(v)??[];A.push(/\s/.test(w)?`"${w}"`:w),r.set(v,A),i+=1}if(i===0)return t;let o=new Set([""]);for(let u of r.keys()){if(u==="")continue;let f=u.split("/");for(let d=1;d<=f.length;d+=1)o.add(f.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 f=u===""?0:u.split("/").length,d=u===""?".":u.slice(u.lastIndexOf("/")+1),g=r.get(u)??[],v=g.length?` ${g.join(" ")}`:"";l.push(`${" ".repeat(f)}${d}/${v}`)}if(l.length+s.length>Ar){let u=Math.max(0,Ar-s.length),f=l.length-u;return[...l.slice(0,u),`\u2026 ${f} more lines omitted`,...s]}return[...l,...s]}var Ar,Cr=_(()=>{"use strict";Q();Ar=1e3;L("smart-find",Na)});function Dr(t){let e=t.trim();return e.length>Ir?`${e.slice(0,Ir)}\u2026`:e}function ja(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>Ma&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function za(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 d=La.exec(f),g=Fa.exec(f);if(d&&g)return t;let v=d||g?null:Ba.exec(f),w=(d??g??v)?.[1];if(!w)return t;let A=d?{line:d[2],content:d[3],context:!1}:g?{line:g[2],content:g[3],context:!0}:{line:"",content:v[2],context:!1},O=n.get(w)??[];O.push(A),n.set(w,O),A.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((f,d)=>{let g=Or.test(f)?1:0,v=Or.test(d)?1:0;return g-v||(f<d?-1:f>d?1:0)}),c=[];for(let f of a){c.push(`${f} (${r.get(f)??0}):`);for(let d of n.get(f))"separator"in d?c.push(" --"):d.line?c.push(` ${d.line}${d.context?"-":":"} ${Dr(d.content)}`):c.push(` ${Dr(d.content)}`)}let l=a.length>1&&c.length>Pa?ja(a.map(f=>`${f} (${r.get(f)??0})`)):[],u=[`${i}m ${a.length}f:`,...l,"",...c];if(u.length>Zt){let f=u.length-Zt;return[...u.slice(0,Zt),`\u2026 ${f} more lines omitted`]}return u}var Zt,Ir,Pa,Ma,La,Fa,Ba,Or,$r=_(()=>{"use strict";Q();Zt=1e3,Ir=200,Pa=60,Ma=190,La=/^([^\s:]+):(\d+):(.*)$/,Fa=/^([^:]+?)-(\d+)-(.*)$/,Ba=/^([^\s:]+):(.*)$/,Or=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;L("smart-grep",za)});function Ha(t){if(!t.some(l=>Nr.test(l)))return t;let e=[],n=0,r=0,s=0,i="",o=!1,a=!1,c=()=>{r>0&&e.push(`${i} \u2026 ${r} ${r===1?"line":"lines"} folded \u2026`),r=0};for(let l of t){let u=l.slice(0,s),f=Za.test(u),d=f?l.slice(s):l,g=Ua.test(d),v=o&&g?null:Nr.exec(l);if(v){c(),n=0,s=v[1]?.length??0,o=!0,a=!1,e.push(l);continue}if(/^diff --(?:git|cc|combined) /.test(d)&&(a=!0),g&&!a&&!(s>0&&d.trim().length===0)){n+=1,n<=Va?e.push(l):(r+=1,i=f?u:"");continue}c(),e.push(l)}return c(),e}var Nr,Za,Ua,Va,Pr=_(()=>{"use strict";Q();Nr=/^(?:([|\\/ ._-]*\*[|\\/* ._-]* ))?commit [0-9a-f]{7,40}\b/,Za=/^[|\\/* ._-]*$/,Ua=/^ {4}/,Va=2;L("smart-log",Ha)});var Ka,Ga,Wa,Mr=_(()=>{"use strict";Q();Ka=/^[\s=]+$/,Ga=/^\s*=+\s+(.*?)\s+=+\s*$/,Wa=512;L("strip-banners",t=>{let e=[];for(let n of t){if(Ka.test(n))continue;let r=n.length<=Wa?Ga.exec(n):null;e.push(r?r[1]:n)}return e})});function Ya(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}var Lr=_(()=>{"use strict";Q();L("squeeze-output",Ya)});function Ja(t){return t==="compact"?.6:t==="minimal"?.3:1}function Xa(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,c)=>c>2||!/^ RUN v\d+\.\d+\.\d+(?:[\w.+-]*) .+$/.test(a)),e,n,i]:t}function Qa(t){let e=Fr.get(t);if(e)return e;let n=t.strip_lines_matching.map(s=>new RegExp(s)),r={def:t,stripRegexes:n};return Fr.set(t,r),r}function Br(t,e,n={}){return Ut(t,e,n).text}function Ut(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=Qa(e),i=t;e.strip_ansi&&(i=Se(i));let o=i.endsWith(`
5
5
  `),a=(o?i.slice(0,-1):i).split(`
6
- `);if(s.stripRegexes.length&&(a=e.keep_failures?a.filter(f=>oe.test(f)||!s.stripRegexes.some(d=>d.test(f))):lr(a,s.stripRegexes)),r!=="normal"&&!e.preserve_exact&&(a=xr(a),a=kr(a)),r==="minimal"&&!e.preserve_exact&&(a=vr(a),(e.slug==="vitest"||e.slug==="npm-test")&&(a=Ja(a))),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&r!=="normal"&&br(i))&&(a=gt(a)),e.transform){let f=Sr(e.transform);f&&(a=f(a))}let c=e.slug==="read-tool";if(!c){let f=Mt(a);f.some(Boolean)&&(a=a.filter((d,g)=>!f[g]))}e.mask_abs_paths&&(a=gr(a)),e.fold_passing&&(a=hr(a,e.fold_passing_threshold??5)),e.truncate_lines_at&&(a=dr(a,e.truncate_lines_at));let l=null;if(e.max_lines){let f=e.scale_with_level?Wa(n.verbosity):1,d=Math.min(e.max_lines,Math.max(Ya,Math.round(e.max_lines*f))),g=c?Mt(a):null,v=g?g.filter(E=>!E).length:a.length;if(v>d){let E=d;if(g){let O=0;for(E=0;E<a.length&&O<d;)g[E]||(O+=1),E+=1}let R=v-d;if(e.keep_failures){let O=a.slice(E),U=O.filter(I=>!oe.test(I)),ae=O.reduce((I,ce,V)=>I+(!oe.test(ce)&&!g?.[E+V]?1:0),0);l=U.length>0?U.join(`
7
- `):null,a=[...a.slice(0,E),...ae>0?[ht(ae)]:[],...O.filter(I=>oe.test(I))]}else if(c)l=a.slice(E).join(`
8
- `),a=[...a.slice(0,E),ht(R)];else{let{kept:O,dropped:U}=pr(a,d);l=U.length>0?U.join(`
6
+ `);if(s.stripRegexes.length&&(a=e.keep_failures?a.filter(f=>oe.test(f)||!s.stripRegexes.some(d=>d.test(f))):ur(a,s.stripRegexes)),r!=="normal"&&!e.preserve_exact&&(a=xr(a),a=Er(a)),r==="minimal"&&!e.preserve_exact&&(a=vr(a),(e.slug==="vitest"||e.slug==="npm-test")&&(a=Xa(a))),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&r!=="normal"&&vt(i))&&(a=bt(a)),e.transform){let f=Sr(e.transform);f&&(a=f(a))}let c=e.slug==="read-tool";if(!c){let f=jt(a);f.some(Boolean)&&(a=a.filter((d,g)=>!f[g]))}e.mask_abs_paths&&(a=yr(a)),e.fold_passing&&(a=gr(a,e.fold_passing_threshold??5)),e.truncate_lines_at&&(a=fr(a,e.truncate_lines_at));let l=null;if(e.max_lines){let f=e.scale_with_level?Ja(n.verbosity):1,d=Math.min(e.max_lines,Math.max(qa,Math.round(e.max_lines*f))),g=c?jt(a):null,v=g?g.filter(w=>!w).length:a.length;if(v>d){let w=d;if(g){let O=0;for(w=0;w<a.length&&O<d;)g[w]||(O+=1),w+=1}let A=v-d;if(e.keep_failures){let O=a.slice(w),U=O.filter(V=>!oe.test(V)),Te=O.reduce((V,Re,C)=>V+(!oe.test(Re)&&!g?.[w+C]?1:0),0);l=U.length>0?U.join(`
7
+ `):null,a=[...a.slice(0,w),...Te>0?[_t(Te)]:[],...O.filter(V=>oe.test(V))]}else if(c)l=a.slice(w).join(`
8
+ `),a=[...a.slice(0,w),_t(A)];else{let{kept:O,dropped:U}=mr(a,d);l=U.length>0?U.join(`
9
9
  `):null,a=O}}}let u=a.join(`
10
10
  `);return o&&u.length>0&&(u+=`
11
- `),u.trim().length===0&&e.on_empty&&(u=e.on_empty),{text:u,droppedTail:l}}var Ya,Fr,jr=_(()=>{"use strict";mt();ur();fr();mr();Pt();yr();yt();Er();Q();Tr();Ar();Cr();$r();Pr();Mr();Lr();Ya=20;Fr=new WeakMap});function zr(t){if(!t)return!1;for(let e of Ae(t).split(`
12
- `))if(!/^\s*[✓✔√]\s/.test(e)&&Xa.some(n=>n.test(e)))return!0;return!1}var Xa,Zr=_(()=>{"use strict";mt();Xa=[/\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 Ye(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(ec.test(a)){r++;continue}if(Qa.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}function Ur(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 nc(t){let e=Ur(t,!1);for(let n=e.length-1;n>=0;n--){let r=e[n].trim();if(r)return r}return t.trim()}function zt(t){let e=Ur(t,!0).map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;for(let n of e.slice(0,-1)){let r=Ye(n).split(/\s+/)[0]??"";if(!tc.has(r))return null}return nc(e[e.length-1])}function Vr(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 Hr(t){let e=jt.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=zt(n),s=r?Ye(r):null;return s&&s!==t?[s,t]:[t]}var Qa,ec,jt,tc,Kr=_(()=>{"use strict";Qa=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),ec=/^[A-Za-z_][A-Za-z0-9_]*=/,jt=/^([a-z]+)-tool(?::\s|$)/;tc=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"])});function Zt(t){let e=Buffer.from(t,"utf8");if(e.length<=256)return t;let n=256-Buffer.byteLength(Gr,"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")+Gr+e.subarray(s).toString("utf8")}var Gr,Wr=_(()=>{"use strict";Gr=`
11
+ `),u.trim().length===0&&e.on_empty&&(u=e.on_empty),{text:u,droppedTail:l}}var qa,Fr,jr=_(()=>{"use strict";yt();dr();pr();hr();Bt();_r();Xe();kr();Q();Tr();Rr();Cr();$r();Pr();Mr();Lr();qa=20;Fr=new WeakMap});function zr(t){if(!t)return!1;for(let e of Se(t).split(`
12
+ `))if(!/^\s*[✓✔√]\s/.test(e)&&ec.some(n=>n.test(e)))return!0;return!1}var ec,Zr=_(()=>{"use strict";yt();ec=[/\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 ze(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(nc.test(a)){r++;continue}if(tc.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}function Ur(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 sc(t){let e=Ur(t,!1);for(let n=e.length-1;n>=0;n--){let r=e[n].trim();if(r)return r}return t.trim()}function Ht(t){let e=Ur(t,!0).map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;for(let n of e.slice(0,-1)){let r=ze(n).split(/\s+/)[0]??"";if(!rc.has(r))return null}return sc(e[e.length-1])}function Vr(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 Hr(t){let e=Vt.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=Ht(n),s=r?ze(r):null;return s&&s!==t?[s,t]:[t]}var tc,nc,Vt,rc,Kr=_(()=>{"use strict";tc=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),nc=/^[A-Za-z_][A-Za-z0-9_]*=/,Vt=/^([a-z]+)-tool(?::\s|$)/;rc=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"])});function Kt(t){let e=Buffer.from(t,"utf8");if(e.length<=256)return t;let n=256-Buffer.byteLength(Gr,"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")+Gr+e.subarray(s).toString("utf8")}var Gr,Wr=_(()=>{"use strict";Gr=`
13
13
  [YOLO: omitted]
14
- `});function oc(t,e){if(!e)return t.split(`
14
+ `});function cc(t,e){if(!e)return t.split(`
15
15
  `).map(i=>i.replace(/^[ \t]+|[ \t]+(?=\r?$)/g,"")).join(`
16
16
  `);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!==`
17
17
  `&&(n+=i);return n+(t.endsWith(`
18
18
  `)?`
19
- `:"")}function ac(t,e){if(/@\d|\r/.test(t))return t;let n=t.endsWith(`
19
+ `:"")}function lc(t,e){if(/@\d|\r/.test(t))return t;let n=t.endsWith(`
20
20
  `)?`
21
21
  `:"",r=(n?t.slice(0,-1):t).split(`
22
- `),s=r.findIndex(d=>rc.test(d));if(s>=0&&r.slice(0,s).some(d=>d!==""&&!/^Showing \d+ of \d+ (?:open|closed|all) pull requests in \S+$/.test(d)))return t;let i=s>=0?[...r[s].matchAll(/\S+/g)].map(d=>d.index):[],o=[];for(let d=s+1;d<r.length;d+=1){let g=r[d];if(sc.test(g))continue;if(/…|\.\.\./.test(g))return t;let v;if(s>=0){if(/[^\x20-\x7e]/.test(g))return t;let E=i.map((R,O)=>g.slice(R,i[O+1]));if(E.slice(0,-1).some(R=>R[0]===" "||!R.endsWith(" "))||(v=E.map(R=>R.replace(/ +$/,"")),!/^#\d+$/.test(v[0])||!/^\S+$/.test(v[2])||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(v[3])||!/^\d+(?:s|m|h|d|w|mo|y)$/.test(v[4])))return t}else if(v=g.split(" "),v.length!==5||!/^\d+$/.test(v[0])||!v[1]||!v[2]||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(v[3])||!ic.test(v[4])||!Number.isFinite(Date.parse(v[4])))return t;if(v.some(E=>/[\u0000-\u001f\u007f]/.test(E)))return t;o.push({index:d,cells:v})}if(o.length===0)return t;s>=0&&(r[s]="ID TITLE BRANCH STATE CREATED");for(let d of o)r[d.index]=d.cells.join(" ");let a=r.join(`
23
- `)+n;if(!e)return a;let c=new Map;for(let{cells:d}of o)c.set(d[1],(c.get(d[1])??0)+1);let l=new Map,u=[];for(let[d,g]of c){if(d.length<40||g<3||d.trim().split(/\s+/).length<8)continue;let v=`@${l.size+1}`,E=JSON.stringify(d).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),R=`TITLE ${v} = ${E}`;g*(Buffer.byteLength(d)-Buffer.byteLength(v))<=Buffer.byteLength(R)+1||(l.set(d,v),u.push(R))}if(u.length===0)return a;for(let{index:d,cells:g}of o)r[d]=g.map((v,E)=>E===1?l.get(v)??v:v).join(" ");let f=[...r,"",...u].join(`
24
- `)+n;return Buffer.byteLength(f)<Buffer.byteLength(a)?f:a}function Ut(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=oc(t,e==="minimal")}else n==="gh"&&(r=ac(t,e==="minimal"));return Buffer.byteLength(r)<Buffer.byteLength(t)?r:t}var rc,sc,ic,Yr=_(()=>{"use strict";rc=/^ID {2,}TITLE {2,}BRANCH {2,}STATE {2,}CREATED *$/,sc=/^… \([1-9]\d* more lines omitted\)$/,ic=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/});function Vt(t){Jr=t}async function cc(t,e){let n=await Qn();return pt(t,n.values(),e)}async function qr(t,e,n,r={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,yolo:o=!1,...a}=r,c=Ye(Vr(t.startsWith("bash-tool: ")?t.slice(11):t)),l=i!=null&&i!==0&&!(i===1&&lc.test(c)),u=Jr??cc,f=null;for(let I of Hr(t))if(f=await u(I,n),f)break;!f&&s>=uc&&!jt.test(t)&&(f=await u(`bash-tool: ${t}`,n));let d=zt(t.startsWith("bash-tool: ")?t.slice(11):t),g=f?.slug==="git-log"&&d!=null&&/^git\s+log(?:\s|$)/.test(Ye(d)),v=i==null&&(g?/^(?:fatal|error):/im.test(Ae(e)):zr(e));if(!f||(l||v)&&f.preserve_exact&&!o)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:l||v,...o?{droppedTail:null}:{}};let E=I=>{if(!o)return I;let ce=I.filteredBytes>s||s>0&&I.output.length===0?e:I.output,V=!I.debugBypass&&!f?.preserve_exact?Ut(ce,"minimal",I.filterId??""):ce,ze=Zt(V)===V?V:Zt(ce);return{...I,output:ze,filteredBytes:Buffer.byteLength(ze,"utf8"),droppedTail:null}};if(l||v){let I=o?Br(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?Ae(e):e;return E({output:I,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(I,"utf8"),debugBypass:!0})}let{text:R,droppedTail:O}=Bt(e,f,o?{...a,verbosity:"minimal"}:a),U=!o&&!f.preserve_exact?Ut(R,a.verbosity,f.slug):R,ae=Buffer.byteLength(U,"utf8");return e.trim().length>0&&ae>=s?E({output:e,filterId:f.slug,rawBytes:s,filteredBytes:s,debugBypass:!1,droppedTail:null}):E({output:U,filterId:f.slug,rawBytes:s,filteredBytes:ae,debugBypass:!1,droppedTail:O})}var Jr,lc,uc,Ht=_(()=>{"use strict";er();Nt();jr();Zr();Kr();Wr();mt();Yr();Jr=null;lc=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,uc=2048});import{chmod as dc,mkdir as fc,readFile as Hf,writeFile as pc,stat as Kf,readdir as Gf,rm as Xr,rename as mc}from"node:fs/promises";import{createHash as Qr}from"node:crypto";function yc(t,e){let n=Number(process.env[t]);return Number.isFinite(n)&&n>0?n:e}async function es(t,e){if(ee()||!gc.test(t)||Buffer.byteLength(e,"utf8")>yc("TOKMIZER_CCR_ENTRY_MAX_BYTES",hc))return!1;let n=kn(t),r=`${n}.tmp-${process.pid}-${process.hrtime.bigint()}`;try{return await fc(St(),{recursive:!0}),ee()?!1:(await pc(r,e,{mode:384}),await dc(r,384),ee()?(await Xr(r,{force:!0}),!1):(await mc(r,n),!0))}catch{try{await Xr(r)}catch{}return!1}}async function ts(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||ee()||!t)return e;let r=Qr("sha256").update(t).digest("hex").slice(0,16),s=`
25
- [tkr restore ${r}]`;return Buffer.byteLength(t,"utf8")<=Buffer.byteLength(s,"utf8")||!await es(r,t)?e:`${e}${s}`}async function ns(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||ee()||!t)return e;let r=Qr("sha256").update(t).digest("hex").slice(0,16);return await es(r,t)?`${e}
26
- [tkr restore ${r}]`:e}var qf,Xf,hc,gc,rs=_(()=>{"use strict";N();At();qf=10080*60*1e3,Xf=100*1024*1024,hc=2*1024*1024,gc=/^[0-9a-f]{8,64}$/i});function _c(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function ss(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>_c())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function is(t,e=Date.now()){return t.plan}var os=_(()=>{"use strict"});function Je(t){let e=t;for(let[n,r]of bc)e=e.replace(n,r);return e}var bc,Kt=_(()=>{"use strict";bc=[[/(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]"]]});import{createHash as rp,randomUUID as vc}from"node:crypto";import{readFile as as,writeFile as cs,mkdir as xc}from"node:fs/promises";async function Gt(){try{let n=(await as(Ze(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await xc(A(),{recursive:!0});let t=vc();try{return await cs(Ze(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await as(Ze(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await cs(Ze(),t,{mode:384}),t}}var Wt=_(()=>{"use strict";N()});import{createRequire as kc}from"node:module";function wc(){for(let t of["../package.json","../../package.json"])try{let e=Ec(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Ec,Yt,Jt=_(()=>{"use strict";Ec=kc(import.meta.url);Yt=wc()});var ls,us=_(()=>{"use strict";ls=`-----BEGIN PUBLIC KEY-----
22
+ `),s=r.findIndex(d=>ic.test(d));if(s>=0&&r.slice(0,s).some(d=>d!==""&&!/^Showing \d+ of \d+ (?:open|closed|all) pull requests in \S+$/.test(d)))return t;let i=s>=0?[...r[s].matchAll(/\S+/g)].map(d=>d.index):[],o=[];for(let d=s+1;d<r.length;d+=1){let g=r[d];if(oc.test(g))continue;if(/…|\.\.\./.test(g))return t;let v;if(s>=0){if(/[^\x20-\x7e]/.test(g))return t;let w=i.map((A,O)=>g.slice(A,i[O+1]));if(w.slice(0,-1).some(A=>A[0]===" "||!A.endsWith(" "))||(v=w.map(A=>A.replace(/ +$/,"")),!/^#\d+$/.test(v[0])||!/^\S+$/.test(v[2])||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(v[3])||!/^\d+(?:s|m|h|d|w|mo|y)$/.test(v[4])))return t}else if(v=g.split(" "),v.length!==5||!/^\d+$/.test(v[0])||!v[1]||!v[2]||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(v[3])||!ac.test(v[4])||!Number.isFinite(Date.parse(v[4])))return t;if(v.some(w=>/[\u0000-\u001f\u007f]/.test(w)))return t;o.push({index:d,cells:v})}if(o.length===0)return t;s>=0&&(r[s]="ID TITLE BRANCH STATE CREATED");for(let d of o)r[d.index]=d.cells.join(" ");let a=r.join(`
23
+ `)+n;if(!e)return a;let c=new Map;for(let{cells:d}of o)c.set(d[1],(c.get(d[1])??0)+1);let l=new Map,u=[];for(let[d,g]of c){if(d.length<40||g<3||d.trim().split(/\s+/).length<8)continue;let v=`@${l.size+1}`,w=JSON.stringify(d).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),A=`TITLE ${v} = ${w}`;g*(Buffer.byteLength(d)-Buffer.byteLength(v))<=Buffer.byteLength(A)+1||(l.set(d,v),u.push(A))}if(u.length===0)return a;for(let{index:d,cells:g}of o)r[d]=g.map((v,w)=>w===1?l.get(v)??v:v).join(" ");let f=[...r,"",...u].join(`
24
+ `)+n;return Buffer.byteLength(f)<Buffer.byteLength(a)?f:a}function Gt(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=cc(t,e==="minimal")}else n==="gh"&&(r=lc(t,e==="minimal"));return Buffer.byteLength(r)<Buffer.byteLength(t)?r:t}var ic,oc,ac,Yr=_(()=>{"use strict";ic=/^ID {2,}TITLE {2,}BRANCH {2,}STATE {2,}CREATED *$/,oc=/^… \([1-9]\d* more lines omitted\)$/,ac=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/});function Jr(t){if(Buffer.byteLength(t)<2048||vt(t)||dc.test(t))return t;let e=t.split(`
25
+ `),n=[];for(let r=0;r<e.length;){let s=e[r],i=r+1;if(uc.test(s))for(;i<e.length&&e[i]===s;)i+=1;let o=i-r,a=`[tkr: previous log line repeated ${o-1} additional times]`;if(o>=3&&Buffer.byteLength(a)+1<(o-1)*(Buffer.byteLength(s)+1))n.push(s,a);else for(let c=r;c<i;c+=1)n.push(s);r=i}return n.join(`
26
+ `)}var uc,dc,qr=_(()=>{"use strict";Xe();uc=/^(?:\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?\s+)?(?:\[(?:DEBUG|TRACE|INFO|WARN|WARNING|ERROR|FATAL)\]|DEBUG|TRACE|INFO|WARN|WARNING|ERROR|FATAL)(?::|\s|$)/,dc=/^\[tkr: previous log line repeated \d+ additional times\]$/m});function Wt(t){Xr=t}async function fc(t,e){let n=await er();return gt(t,n.values(),e)}async function Qr(t,e,n,r={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,yolo:o=!1,...a}=r,c=ze(Vr(t.startsWith("bash-tool: ")?t.slice(11):t)),l=i!=null&&i!==0&&!(i===1&&pc.test(c)),u=Xr??fc,f=null;for(let C of Hr(t))if(f=await u(C,n),f)break;!f&&s>=mc&&!Vt.test(t)&&(f=await u(`bash-tool: ${t}`,n));let d=Ht(t.startsWith("bash-tool: ")?t.slice(11):t),g=f?.slug==="git-log"&&d!=null&&/^git\s+log(?:\s|$)/.test(ze(d)),v=i==null&&(g?/^(?:fatal|error):/im.test(Se(e)):zr(e)),w=f?.transform==="smart-read"&&s<=16384&&(e.endsWith(`
27
+ `)?e.slice(0,-1):e).split(`
28
+ `).length<=200,A=s<=16384&&d!=null&&/^(?:head|tail)(?:\s|$)|^sed\s+(?:(?:-[Eru]+|--(?:regexp-extended|unbuffered|sandbox))\s+)*(?:-[Enruse]*n[Enruse]*(?:\s|$)|--(?:quiet|silent)(?:\s|$))/.test(ze(d));if(!o&&(A||w&&a.smartCode!==!0))return{output:e,filterId:f?.slug??null,rawBytes:s,filteredBytes:s,debugBypass:l||v,droppedTail:null};if(!f||(l||v)&&f.preserve_exact&&!o)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:l||v,...o?{droppedTail:null}:{}};let O=C=>{if(!o)return C;let Ue=C.filteredBytes>s||s>0&&C.output.length===0?e:C.output,Ae=!C.debugBypass&&!f?.preserve_exact?Gt(Ue,"minimal",C.filterId??""):Ue,Ve=Kt(Ae)===Ae?Ae:Kt(Ue);return{...C,output:Ve,filteredBytes:Buffer.byteLength(Ve,"utf8"),droppedTail:null}};if(l||v){let C=o?Br(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?Se(e):e;return!o&&a.verbosity==="minimal"&&f.transform!=="smart-read"&&(C=Jr(C)),O({output:C,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(C,"utf8"),debugBypass:!0})}let{text:U,droppedTail:Te}=Ut(e,f,o?{...a,verbosity:"minimal"}:a),V=!o&&!f.preserve_exact?Gt(U,a.verbosity,f.slug):U,Re=Buffer.byteLength(V,"utf8");return e.trim().length>0&&Re>=s?O({output:e,filterId:f.slug,rawBytes:s,filteredBytes:s,debugBypass:!1,droppedTail:null}):O({output:V,filterId:f.slug,rawBytes:s,filteredBytes:Re,debugBypass:!1,droppedTail:Te})}var Xr,pc,mc,Yt=_(()=>{"use strict";tr();Ft();jr();Zr();Kr();Wr();yt();Yr();qr();Xr=null;pc=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,mc=2048});import{chmod as hc,mkdir as gc,readFile as Xf,writeFile as yc,stat as Qf,readdir as ep,rm as es,rename as _c}from"node:fs/promises";import{createHash as ts}from"node:crypto";function xc(t,e){let n=Number(process.env[t]);return Number.isFinite(n)&&n>0?n:e}async function ns(t,e){if(ee()||!vc.test(t)||Buffer.byteLength(e,"utf8")>xc("TOKMIZER_CCR_ENTRY_MAX_BYTES",bc))return!1;let n=kn(t),r=`${n}.tmp-${process.pid}-${process.hrtime.bigint()}`;try{return await gc(Ct(),{recursive:!0}),ee()?!1:(await yc(r,e,{mode:384}),await hc(r,384),ee()?(await es(r,{force:!0}),!1):(await _c(r,n),!0))}catch{try{await es(r)}catch{}return!1}}async function rs(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||ee()||!t)return e;let r=ts("sha256").update(t).digest("hex").slice(0,16),s=`
29
+ [tkr restore ${r}]`;return Buffer.byteLength(t,"utf8")<=Buffer.byteLength(s,"utf8")||!await ns(r,t)?e:`${e}${s}`}async function ss(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||ee()||!t)return e;let r=ts("sha256").update(t).digest("hex").slice(0,16);return await ns(r,t)?`${e}
30
+ [tkr restore ${r}]`:e}var sp,ip,bc,vc,is=_(()=>{"use strict";N();Ot();sp=10080*60*1e3,ip=100*1024*1024,bc=2*1024*1024,vc=/^[0-9a-f]{8,64}$/i});function Ec(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function os(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>Ec())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function as(t,e=Date.now()){return t.plan}var cs=_(()=>{"use strict"});function Qe(t){let e=t;for(let[n,r]of kc)e=e.replace(n,r);return e}var kc,Jt=_(()=>{"use strict";kc=[[/(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]"]]});import{createHash as up,randomUUID as wc}from"node:crypto";import{readFile as ls,writeFile as us,mkdir as Sc}from"node:fs/promises";async function qt(){try{let n=(await ls(He(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await Sc(R(),{recursive:!0});let t=wc();try{return await us(He(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await ls(He(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await us(He(),t,{mode:384}),t}}var Xt=_(()=>{"use strict";N()});import{createRequire as Tc}from"node:module";function Ac(){for(let t of["../package.json","../../package.json"])try{let e=Rc(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Rc,Qt,en=_(()=>{"use strict";Rc=Tc(import.meta.url);Qt=Ac()});var ds,fs=_(()=>{"use strict";ds=`-----BEGIN PUBLIC KEY-----
27
31
  MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
28
32
  -----END PUBLIC KEY-----
29
- `});function ds(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??ls).replace(/\\n/g,`
30
- `)}var fp,qt=_(()=>{"use strict";Jt();us();fp=300*1e3});import{readFile as Sc,writeFile as hp,mkdir as gp,chmod as yp,rm as _p,rename as bp,readdir as vp}from"node:fs/promises";import{join as Tc}from"node:path";async function qe(){try{let t=await Sc(Tc(A(),Ac),"utf8"),e=JSON.parse(t);return Fe.parse({...fs,...e})}catch{return fs}}var Ac,fs,wp,_t=_(()=>{"use strict";Te();N();Ac="settings-cache.json",fs=Fe.parse({}),wp=Fe.partial().extend({filters:Fe.shape.filters.removeDefault().partial().optional()})});import{join as ps}from"node:path";import{appendFileSync as Cc,chmodSync as Ic,existsSync as Oc,mkdirSync as Dc,readFileSync as Cp,renameSync as Ip,rmdirSync as Op,statSync as $c,unlinkSync as Dp,utimesSync as $p,writeFileSync as Np}from"node:fs";function ms(){return ps(A(),"spool")}function Pc(t){return ps(ms(),`${t}.jsonl`)}function bt(t,e){try{Dc(ms(),{recursive:!0,mode:448});let n=Pc(t);if(Oc(n)&&$c(n).size>=Nc)return;Cc(n,JSON.stringify(e)+`
31
- `,{mode:384}),Ic(n,384)}catch{return}}var Nc,Xt=_(()=>{"use strict";N();st();Wt();qt();_t();Nc=512*1024});function hs(t){let e=t.toLowerCase();return e.startsWith("git")||jc.has(e)}function Qt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&Bc.test(e[n]??"");)n+=1;let r=e[n];if(!r||!Lc.test(r)||r.length>Zc||hs(r)||zc.test(r)||Je(r)!==r)return"";let s=e[n+1];return s&&hs(s)?"":(s&&Uc.has(r.toLowerCase())&&Fc.test(s)?`${r} ${s}`:r).slice(0,64)}async function gs(t){if(!t.telemetryOptIn)return;let e=Qt(t.cmd),n=e&&Je(e)===e?e:"other",r=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";bt("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}:{}})}var Lc,Fc,Bc,jc,zc,Zc,Uc,en=_(()=>{"use strict";Kt();Xt();Lc=/^[a-z0-9][a-z0-9._-]*$/i,Fc=/^[a-z][a-z-]+$/,Bc=/^[A-Za-z_][A-Za-z0-9_]*=/,jc=new Set(["gh","glab","gup","hub","gist"]),zc=/^(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,Zc=24,Uc=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"])});async function ys(t){if(t.plan!=="pro"||!(await qe()).telemetryOptIn)return;let e=Qt(t.cmd);!e||Je(e)!==e||bt("learn",{cmd:e,filterId:t.filterId==null?null:W(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}var _s=_(()=>{"use strict";en();Kt();Xt();Te();_t()});import{readFileSync as Vc,renameSync as Hc,statSync as Kc,writeFileSync as Gc}from"node:fs";function bs(t,e,n){try{if(Kc(t).size<=e)return;let r=Vc(t,"utf8").split(`
32
- `).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}`;Gc(o,s.length?`${s.join(`
33
+ `});function ps(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??ds).replace(/\\n/g,`
34
+ `)}var bp,tn=_(()=>{"use strict";en();fs();bp=300*1e3});import{readFile as Cc,writeFile as Ep,mkdir as kp,chmod as wp,rm as Sp,rename as Tp,readdir as Rp}from"node:fs/promises";import{join as Ic}from"node:path";async function et(){try{let t=await Cc(Ic(R(),Oc),"utf8"),e=JSON.parse(t);return Be.parse({...ms,...e})}catch{return ms}}var Oc,ms,Op,xt=_(()=>{"use strict";we();N();Oc="settings-cache.json",ms=Be.parse({}),Op=Be.partial().extend({filters:Be.shape.filters.removeDefault().partial().optional()})});import{join as hs}from"node:path";import{appendFileSync as $c,chmodSync as Nc,existsSync as Pc,mkdirSync as Mc,readFileSync as Mp,renameSync as Lp,rmdirSync as Fp,statSync as Lc,unlinkSync as Bp,utimesSync as jp,writeFileSync as zp}from"node:fs";function gs(){return hs(R(),"spool")}function Bc(t){return hs(gs(),`${t}.jsonl`)}function Et(t,e){try{Mc(gs(),{recursive:!0,mode:448});let n=Bc(t);if(Pc(n)&&Lc(n).size>=Fc)return;$c(n,JSON.stringify(e)+`
35
+ `,{mode:384}),Nc(n,384)}catch{return}}var Fc,nn=_(()=>{"use strict";N();at();Xt();tn();xt();Fc=512*1024});function ys(t){let e=t.toLowerCase();return e.startsWith("git")||Vc.has(e)}function rn(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&Uc.test(e[n]??"");)n+=1;let r=e[n];if(!r||!zc.test(r)||r.length>Kc||ys(r)||Hc.test(r)||Qe(r)!==r)return"";let s=e[n+1];return s&&ys(s)?"":(s&&Gc.has(r.toLowerCase())&&Zc.test(s)?`${r} ${s}`:r).slice(0,64)}async function _s(t){if(!t.telemetryOptIn)return;let e=rn(t.cmd),n=e&&Qe(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}:{}})}var zc,Zc,Uc,Vc,Hc,Kc,Gc,sn=_(()=>{"use strict";Jt();nn();zc=/^[a-z0-9][a-z0-9._-]*$/i,Zc=/^[a-z][a-z-]+$/,Uc=/^[A-Za-z_][A-Za-z0-9_]*=/,Vc=new Set(["gh","glab","gup","hub","gist"]),Hc=/^(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,Kc=24,Gc=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"])});async function bs(t){if(t.plan!=="pro"||!(await et()).telemetryOptIn)return;let e=rn(t.cmd);!e||Qe(e)!==e||Et("learn",{cmd:e,filterId:t.filterId==null?null:W(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}var vs=_(()=>{"use strict";sn();Jt();nn();we();xt()});import{readFileSync as Wc,renameSync as Yc,statSync as Jc,writeFileSync as qc}from"node:fs";function xs(t,e,n){try{if(Jc(t).size<=e)return;let r=Wc(t,"utf8").split(`
36
+ `).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}`;qc(o,s.length?`${s.join(`
33
37
  `)}
34
- `:"",{mode:384}),Hc(o,t)}catch{}}var vs=_(()=>{"use strict"});var xs=_(()=>{"use strict"});import{appendFileSync as Wc,chmodSync as Yc,mkdirSync as Jc}from"node:fs";import{join as qc}from"node:path";function Es(t){return t.length===0||t[0]==="cd"||t.every(e=>ws.test(e))}function rl(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(`|;&<>
35
- `.includes(o)){if(i(),Es(e)){e=[];continue}return e}n+=o,r=!0}return i(),Es(e)?[]:e}function Ss(t){let e=rl(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(ws.test(a)){n+=1;continue}if(Qc.has(a)){for(n+=1;n<e.length;){let c=e[n];if(c.startsWith("-")){n+=el.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("-")&&tl.test(i)&&nl.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function sl(){return qc(A(),Xc)}function Ts(t,e,n=sl(),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)}`:"",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}}
36
- `;try{Jc(A(),{recursive:!0,mode:448}),Wc(n,u,{mode:384}),Yc(n,384),bs(n,ks,ks/2)}catch{return}}function As(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 Xc,ks,Qc,el,tl,nl,ws,Rs=_(()=>{"use strict";vs();N();xs();Xc="stats.jsonl",ks=2*1024*1024,Qc=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),el=new Set(["-u","-g","-n","-s","-k"]),tl=/^[a-z0-9][a-z0-9._-]*$/i,nl=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"]),ws=/^[A-Za-z_][A-Za-z0-9_]*=/});function tn(t){return JSON.stringify(t)+vt}function*Is(t){let e=0;for(;;){let n=t.indexOf(vt,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function Xe(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var il,ol,al,cl,cm,lm,um,Cs,vt,dm,Os=_(()=>{"use strict";Me();ft();il=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()}),ol=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),al=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),cl=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),cm=m.discriminatedUnion("op",[il,ol,al,cl]),lm=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),um=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),Cs=m.object({filter:Le.nullable(),cacheHit:m.boolean().optional()}),vt=`
37
- `,dm=64*1024});import ll from"node:os";import{join as Qe}from"node:path";import{existsSync as ul,statSync as dl,lstatSync as Ds,unlinkSync as fl,mkdirSync as pl,chmodSync as ml}from"node:fs";import{createHash as hl}from"node:crypto";function gl(t){let e=hl("sha256").update(A()).digest("hex").slice(0,8),n=Qe(ll.tmpdir(),`tkr-${t}-${e}`),r=Qe(n,"d.sock");if(Buffer.byteLength(r)>nn)throw new Error("Temporary directory path is too long for IPC");return $s(n,t),r}function yl(t,e){try{let n=Ds(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function $s(t,e){pl(t,{recursive:!0,mode:448});let n=Ds(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");ml(t,448)}function et(){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&&yl(e,t)){let s=Qe(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=nn)return{path:s,isPipe:!1}}let n=Qe(A(),"run"),r=Qe(n,"daemon.sock");return Buffer.byteLength(r)>nn?{path:gl(t),isPipe:!1}:($s(n,t),{path:r,isPipe:!1})}async function rn(){let{path:t,isPipe:e}=et();if(e||!ul(t))return;try{if(!dl(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{fl(t)}catch{}}var nn,_m,Ns=_(()=>{"use strict";N();nn=100;_m=5*6e4});import{createConnection as _l}from"node:net";import{spawn as bl}from"node:child_process";import{existsSync as Ls,openSync as sn,closeSync as Ps,unlinkSync as an,writeFileSync as cn,mkdirSync as ln,readFileSync as vl,appendFileSync as xl,rmSync as kl,statSync as El}from"node:fs";import{dirname as wl,join as un}from"node:path";import{fileURLToPath as Sl}from"node:url";function dn(){return un(A(),"daemon.spawn.fail")}function fn(){return un(A(),"daemon.log")}function Cl(){try{let t=Number(vl(dn(),"utf8"));return Number.isFinite(t)&&Date.now()-t<Al}catch{return!1}}function Il(t){try{ln(A(),{recursive:!0});let e=fn();try{El(e).size>Rl&&an(e)}catch{}xl(e,`${new Date().toISOString()} ${t}
38
- `)}catch{}}function Ol(t){try{ln(A(),{recursive:!0}),cn(dn(),String(Date.now()))}catch{}Il(`spawn failed: ${t.message}`)}function Dl(){try{kl(dn(),{force:!0})}catch{}}async function xt(t,e){return new Promise((n,r)=>{let s=_l(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 $l(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Sl(new URL("../bin/tkr-daemon.js",import.meta.url))}async function on(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 xt(t,75)).destroy(),!0}catch{}else if(Ls(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function Nl(t){let e=$l();if(!Ls(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=et(),r=process.platform==="win32"?A():wl(n);try{ln(r,{recursive:!0})}catch{}let s=un(r,"daemon.spawn.lock"),i=null;try{i=sn(s,"wx"),cn(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await on(n,5e3))return;try{an(s)}catch{}try{i=sn(s,"wx"),cn(i,String(process.pid))}catch(c){if(c.code==="EEXIST"){await on(n,5e3);return}throw c}}else throw o}try{let o=null;try{o=sn(fn(),"a")}catch{}if(bl(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{Ps(o)}catch{}if(!await on(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{Ps(i)}catch{}try{an(s)}catch{}}}}async function Pl(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:et(),n=await Gt();try{let r=await xt(e,Fs);r.write(tn({id:Xe(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function Ml(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await xt(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function pn(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:et(),n=await Gt(),r=null,s=0,i=!1;for(;s<=Ms;)try{r=await xt(e,Fs),Dl();break}catch{if(s+=1,s>Ms)throw new Error(`tkr-daemon unreachable at ${e}`);if(Cl())throw new Error(`tkr-daemon spawn on cooldown (see ${fn()})`);await rn();try{await Nl(n),i=!0}catch(u){throw Ol(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 f=-1;for(let g=0;g<a.length;g++)a[g]===vt&&(f=g);if(f<0)return;let d=[];for(let g of Is(a.slice(0,f+1)))d.push(g);a=a.slice(f+1);for(let g of d)if(g)try{let v=JSON.parse(g),E=o.get(v.id);if(!E)continue;clearTimeout(E.timer),o.delete(v.id),E.resolve(v)}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((f,d)=>{let g=setTimeout(()=>{o.delete(u.id),d(new Error(`daemon request timeout (${u.op})`))},Tl);o.set(u.id,{resolve:f,reject:d,timer:g}),r.write(tn(u))})}let l={filter:async(u,f,d)=>{let g=await c({id:Xe(),op:"filter",cmd:u.slice(0,2048),plan:f,...d&&d.length>0?{allowed:d.slice(0,512)}:{},installId:n});if(!g.ok)return null;let v=Cs.safeParse(g.data);return v.success?v.data.filter:null},ping:async()=>{let u=await c({id:Xe(),op:"ping"});if(!u.ok)throw new Error(u.err);return u.data},reload:async()=>{let u=await c({id:Xe(),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!==Yt}catch{}if(u){try{await Pl(t.socketPath?{socketPath:t.socketPath}:{})}catch{}l.close();let f=await Ml(e,2e3);if(await rn(),!f)throw new Error("stale daemon still running after shutdown request");return pn({...t,skipVersionCheck:!0})}}return l}var Fs,Tl,Ms,Al,Rl,Bs=_(()=>{"use strict";Os();Ns();N();Wt();Jt();Fs=500,Tl=3e3,Ms=1,Al=6e4,Rl=256*1024});import{createCipheriv as $m,createDecipheriv as Ll,hkdfSync as Fl,randomBytes as Nm}from"node:crypto";function zl(t){return Buffer.from(Fl("sha256",Buffer.from(t,"utf8"),Bl,jl,32))}function js(t,e){let n=zl(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=Ll("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}var Bl,jl,zs=_(()=>{"use strict";Bl=Buffer.from("tokmizer-bundle-enc-v1"),jl=Buffer.from("rules-bundle")});import{chmodSync as Lm,readFileSync as Zl,writeFileSync as Fm,mkdirSync as Bm,renameSync as jm}from"node:fs";import{join as Ul}from"node:path";function Hl(){return Ul(A(),"bundle-cache.json")}function Zs(){try{let t=Zl(Hl(),"utf8"),e=Vl.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var Vl,Us=_(()=>{"use strict";Me();N();Vl=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()})});import{createPublicKey as Kl,verify as Gl}from"node:crypto";function Jl(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Yl}function ql(t,e){let n=ds();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=Kl({key:n,format:"pem"});if(!Gl(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(js(t.payload,e))}function Xl(t,e){let n=ql(t,e),r=Wl.parse(n);if(Date.now()-r.signedAt>Jl())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 cr(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>pt(i,s.values(),a&&a.length>0?new Set(a):null)}}async function Vs(){try{let t=Zs();if(!t)return null;let e=await Ue();return e?.signingSecret?Xl(t,e.signingSecret):null}catch{return null}}var Wl,eh,Yl,Hs=_(()=>{"use strict";Me();ft();Nt();st();qt();zs();Us();Wl=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array(Le)}),eh=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),Yl=10080*60*1e3});async function Ql(){if(je)return je;if(tt)return tt;let t=pn().then(e=>{if(tt===t)return je=e,e;try{e.close()}catch{}return null}).catch(()=>null);return tt=t,t}async function eu(){return hn||(hn=!0,mn=await Vs()),mn}async function Ks(t,e,n){let r=await eu();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(W(s.slug))?null:s}function tu(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Gs(t){Vt(async(e,n)=>{let r=t==="free"?"trial":t,s=n??We(void 0),i=await Ql();if(!i)return Ks(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(W(o.slug))?null:tu(o)}catch{return Ks(e,r,s)}})}function Ws(){if(Vt(null),je)try{je.close()}catch{}je=null,tt=null,mn=null,hn=!1}var je,tt,mn,hn,Ys=_(()=>{"use strict";Bs();Ht();Te();Hs();je=null,tt=null;mn=null,hn=!1});var Js={};wt(Js,{FOLD_MARKER_RE:()=>_r,captureForRestore:()=>ts,captureOriginalForRestore:()=>ns,closeDaemonResolver:()=>Ws,countedSaving:()=>As,gatingPlan:()=>is,graceExceeded:()=>ss,installDaemonResolver:()=>Gs,loadSettingsCache:()=>qe,processOutput:()=>qr,recordEvent:()=>ys,recordStat:()=>Ts,recordTelemetry:()=>gs,resolveAllowedFilters:()=>We,statCmdLabel:()=>Ss});var qs=_(()=>{"use strict";Ht();rs();yt();Te();os();_s();en();Rs();Ys();_t()});N();import{existsSync as nu,writeFileSync as ru,appendFileSync as su,statSync as iu}from"node:fs";import{join as ei}from"node:path";async function En(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}import{realpathSync as wn}from"node:fs";import{fileURLToPath as ci,pathToFileURL as li}from"node:url";function Sn(t,e){if(!t)return!1;if(e===li(t).href)return!0;try{return wn(t)===wn(ci(e))}catch{return!1}}st();var Tn=[{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"]}],Fu=[...Tn.map(t=>t.host),"shell"],hi=new Set(["claude-code","codex"]);function An(t){return null}function Rn(t=process.env){let e=process.platform,n=e==="darwin"||e==="linux"||e==="win32"?e:"other",r=process.arch;for(let s of Tn)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:n,arch:r,shimRecommended:!hi.has(s.host)};return{host:"shell",source:"fallback",os:n,arch:r,shimRecommended:!0}}N();import{appendFileSync as gi,mkdirSync as yi,readFileSync as _i,writeFileSync as bi,renameSync as vi,statSync as xi,readdirSync as zu,rmSync as Zu,chmodSync as ki}from"node:fs";import{join as Cn}from"node:path";var Ei=96*1024,wi=500,Hu=168*3600*1e3,Si=120;function In(){return Cn(A(),"sessions")}function Ti(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return Cn(In(),`${e}.jsonl`)}function On(t,e){try{let n=Ti(t);yi(In(),{recursive:!0,mode:448});let r=JSON.stringify({t:e.t??Math.floor(Date.now()/1e3),tool:e.tool,target:e.target.slice(0,Si),...e.fail?{fail:1}:{}});if(gi(n,`${r}
39
- `,{mode:384}),ki(n,384),xi(n).size>Ei){let s=_i(n,"utf8").split(`
40
- `).filter(a=>a.trim()!==""),i=s.slice(s.length-wi),o=`${n}.tmp-${process.pid}`;bi(o,`${i.join(`
38
+ `:"",{mode:384}),Yc(o,t)}catch{}}var Es=_(()=>{"use strict"});var ks=_(()=>{"use strict"});import{appendFileSync as Xc,chmodSync as Qc,mkdirSync as el}from"node:fs";import{join as tl}from"node:path";function Ss(t){return t.length===0||t[0]==="cd"||t.every(e=>Ts.test(e))}function al(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(`|;&<>
39
+ `.includes(o)){if(i(),Ss(e)){e=[];continue}return e}n+=o,r=!0}return i(),Ss(e)?[]:e}function Rs(t){let e=al(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(Ts.test(a)){n+=1;continue}if(rl.has(a)){for(n+=1;n<e.length;){let c=e[n];if(c.startsWith("-")){n+=sl.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("-")&&il.test(i)&&ol.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function cl(){return tl(R(),nl)}function As(t,e,n=cl(),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)}`:"",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}}
40
+ `;try{el(R(),{recursive:!0,mode:448}),Xc(n,u,{mode:384}),Qc(n,384),xs(n,ws,ws/2)}catch{return}}function Cs(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 nl,ws,rl,sl,il,ol,Ts,Is=_(()=>{"use strict";Es();N();ks();nl="stats.jsonl",ws=2*1024*1024,rl=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),sl=new Set(["-u","-g","-n","-s","-k"]),il=/^[a-z0-9][a-z0-9._-]*$/i,ol=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"]),Ts=/^[A-Za-z_][A-Za-z0-9_]*=/});function on(t){return JSON.stringify(t)+kt}function*Ds(t){let e=0;for(;;){let n=t.indexOf(kt,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function tt(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var ll,ul,dl,fl,hm,gm,ym,Os,kt,_m,$s=_(()=>{"use strict";Le();ht();ll=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()}),ul=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),dl=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),fl=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),hm=m.discriminatedUnion("op",[ll,ul,dl,fl]),gm=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),ym=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),Os=m.object({filter:Fe.nullable(),cacheHit:m.boolean().optional()}),kt=`
41
+ `,_m=64*1024});import pl from"node:os";import{join as nt}from"node:path";import{existsSync as ml,statSync as hl,lstatSync as Ns,unlinkSync as gl,mkdirSync as yl,chmodSync as _l}from"node:fs";import{createHash as bl}from"node:crypto";function vl(t){let e=bl("sha256").update(R()).digest("hex").slice(0,8),n=nt(pl.tmpdir(),`tkr-${t}-${e}`),r=nt(n,"d.sock");if(Buffer.byteLength(r)>an)throw new Error("Temporary directory path is too long for IPC");return Ps(n,t),r}function xl(t,e){try{let n=Ns(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function Ps(t,e){yl(t,{recursive:!0,mode:448});let n=Ns(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");_l(t,448)}function rt(){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&&xl(e,t)){let s=nt(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=an)return{path:s,isPipe:!1}}let n=nt(R(),"run"),r=nt(n,"daemon.sock");return Buffer.byteLength(r)>an?{path:vl(t),isPipe:!1}:(Ps(n,t),{path:r,isPipe:!1})}async function cn(){let{path:t,isPipe:e}=rt();if(e||!ml(t))return;try{if(!hl(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{gl(t)}catch{}}var an,Sm,Ms=_(()=>{"use strict";N();an=100;Sm=5*6e4});import{createConnection as El}from"node:net";import{spawn as kl}from"node:child_process";import{existsSync as Bs,openSync as ln,closeSync as Ls,unlinkSync as dn,writeFileSync as fn,mkdirSync as pn,readFileSync as wl,appendFileSync as Sl,rmSync as Tl,statSync as Rl}from"node:fs";import{dirname as Al,join as mn}from"node:path";import{fileURLToPath as Cl}from"node:url";function hn(){return mn(R(),"daemon.spawn.fail")}function gn(){return mn(R(),"daemon.log")}function $l(){try{let t=Number(wl(hn(),"utf8"));return Number.isFinite(t)&&Date.now()-t<Ol}catch{return!1}}function Nl(t){try{pn(R(),{recursive:!0});let e=gn();try{Rl(e).size>Dl&&dn(e)}catch{}Sl(e,`${new Date().toISOString()} ${t}
42
+ `)}catch{}}function Pl(t){try{pn(R(),{recursive:!0}),fn(hn(),String(Date.now()))}catch{}Nl(`spawn failed: ${t.message}`)}function Ml(){try{Tl(hn(),{force:!0})}catch{}}async function wt(t,e){return new Promise((n,r)=>{let s=El(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 Ll(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Cl(new URL("../bin/tkr-daemon.js",import.meta.url))}async function un(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 wt(t,75)).destroy(),!0}catch{}else if(Bs(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function Fl(t){let e=Ll();if(!Bs(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=rt(),r=process.platform==="win32"?R():Al(n);try{pn(r,{recursive:!0})}catch{}let s=mn(r,"daemon.spawn.lock"),i=null;try{i=ln(s,"wx"),fn(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await un(n,5e3))return;try{dn(s)}catch{}try{i=ln(s,"wx"),fn(i,String(process.pid))}catch(c){if(c.code==="EEXIST"){await un(n,5e3);return}throw c}}else throw o}try{let o=null;try{o=ln(gn(),"a")}catch{}if(kl(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{Ls(o)}catch{}if(!await un(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{Ls(i)}catch{}try{dn(s)}catch{}}}}async function Bl(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:rt(),n=await qt();try{let r=await wt(e,js);r.write(on({id:tt(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function jl(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await wt(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function yn(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:rt(),n=await qt(),r=null,s=0,i=!1;for(;s<=Fs;)try{r=await wt(e,js),Ml();break}catch{if(s+=1,s>Fs)throw new Error(`tkr-daemon unreachable at ${e}`);if($l())throw new Error(`tkr-daemon spawn on cooldown (see ${gn()})`);await cn();try{await Fl(n),i=!0}catch(u){throw Pl(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 f=-1;for(let g=0;g<a.length;g++)a[g]===kt&&(f=g);if(f<0)return;let d=[];for(let g of Ds(a.slice(0,f+1)))d.push(g);a=a.slice(f+1);for(let g of d)if(g)try{let v=JSON.parse(g),w=o.get(v.id);if(!w)continue;clearTimeout(w.timer),o.delete(v.id),w.resolve(v)}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((f,d)=>{let g=setTimeout(()=>{o.delete(u.id),d(new Error(`daemon request timeout (${u.op})`))},Il);o.set(u.id,{resolve:f,reject:d,timer:g}),r.write(on(u))})}let l={filter:async(u,f,d)=>{let g=await c({id:tt(),op:"filter",cmd:u.slice(0,2048),plan:f,...d&&d.length>0?{allowed:d.slice(0,512)}:{},installId:n});if(!g.ok)return null;let v=Os.safeParse(g.data);return v.success?v.data.filter:null},ping:async()=>{let u=await c({id:tt(),op:"ping"});if(!u.ok)throw new Error(u.err);return u.data},reload:async()=>{let u=await c({id:tt(),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!==Qt}catch{}if(u){try{await Bl(t.socketPath?{socketPath:t.socketPath}:{})}catch{}l.close();let f=await jl(e,2e3);if(await cn(),!f)throw new Error("stale daemon still running after shutdown request");return yn({...t,skipVersionCheck:!0})}}return l}var js,Il,Fs,Ol,Dl,zs=_(()=>{"use strict";$s();Ms();N();Xt();en();js=500,Il=3e3,Fs=1,Ol=6e4,Dl=256*1024});import{createCipheriv as jm,createDecipheriv as zl,hkdfSync as Zl,randomBytes as zm}from"node:crypto";function Hl(t){return Buffer.from(Zl("sha256",Buffer.from(t,"utf8"),Ul,Vl,32))}function Zs(t,e){let n=Hl(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=zl("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}var Ul,Vl,Us=_(()=>{"use strict";Ul=Buffer.from("tokmizer-bundle-enc-v1"),Vl=Buffer.from("rules-bundle")});import{chmodSync as Vm,readFileSync as Kl,writeFileSync as Hm,mkdirSync as Km,renameSync as Gm}from"node:fs";import{join as Gl}from"node:path";function Yl(){return Gl(R(),"bundle-cache.json")}function Vs(){try{let t=Kl(Yl(),"utf8"),e=Wl.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var Wl,Hs=_(()=>{"use strict";Le();N();Wl=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()})});import{createPublicKey as Jl,verify as ql}from"node:crypto";function eu(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Ql}function tu(t,e){let n=ps();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=Jl({key:n,format:"pem"});if(!ql(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(Zs(t.payload,e))}function nu(t,e){let n=tu(t,e),r=Xl.parse(n);if(Date.now()-r.signedAt>eu())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 lr(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>gt(i,s.values(),a&&a.length>0?new Set(a):null)}}async function Ks(){try{let t=Vs();if(!t)return null;let e=await Ke();return e?.signingSecret?nu(t,e.signingSecret):null}catch{return null}}var Xl,ah,Ql,Gs=_(()=>{"use strict";Le();ht();Ft();at();tn();Us();Hs();Xl=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array(Fe)}),ah=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),Ql=10080*60*1e3});async function ru(){if(Ze)return Ze;if(st)return st;let t=yn().then(e=>{if(st===t)return Ze=e,e;try{e.close()}catch{}return null}).catch(()=>null);return st=t,t}async function su(){return bn||(bn=!0,_n=await Ks()),_n}async function Ws(t,e,n){let r=await su();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(W(s.slug))?null:s}function iu(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Ys(t){Wt(async(e,n)=>{let r=t==="free"?"trial":t,s=n??qe(void 0),i=await ru();if(!i)return Ws(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(W(o.slug))?null:iu(o)}catch{return Ws(e,r,s)}})}function Js(){if(Wt(null),Ze)try{Ze.close()}catch{}Ze=null,st=null,_n=null,bn=!1}var Ze,st,_n,bn,qs=_(()=>{"use strict";zs();Yt();we();Gs();Ze=null,st=null;_n=null,bn=!1});var Xs={};At(Xs,{FOLD_MARKER_RE:()=>br,captureForRestore:()=>rs,captureOriginalForRestore:()=>ss,closeDaemonResolver:()=>Js,countedSaving:()=>Cs,gatingPlan:()=>as,graceExceeded:()=>os,installDaemonResolver:()=>Ys,loadSettingsCache:()=>et,processOutput:()=>Qr,recordEvent:()=>bs,recordStat:()=>As,recordTelemetry:()=>_s,resolveAllowedFilters:()=>qe,statCmdLabel:()=>Rs});var Qs=_(()=>{"use strict";Yt();is();Xe();we();cs();vs();sn();Is();qs();xt()});N();import{existsSync as ou,writeFileSync as au,appendFileSync as cu,statSync as lu}from"node:fs";import{join as ni}from"node:path";async function wn(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}import{realpathSync as Sn}from"node:fs";import{fileURLToPath as ui,pathToFileURL as di}from"node:url";function Tn(t,e){if(!t)return!1;if(e===di(t).href)return!0;try{return Sn(t)===Sn(ui(e))}catch{return!1}}at();var Rn=[{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"]}],Zu=[...Rn.map(t=>t.host),"shell"],yi=new Set(["claude-code","codex"]);function An(t){return null}function Cn(t=process.env){let e=process.platform,n=e==="darwin"||e==="linux"||e==="win32"?e:"other",r=process.arch;for(let s of Rn)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:n,arch:r,shimRecommended:!yi.has(s.host)};return{host:"shell",source:"fallback",os:n,arch:r,shimRecommended:!0}}N();import{appendFileSync as _i,mkdirSync as bi,readFileSync as vi,writeFileSync as xi,renameSync as Ei,statSync as ki,readdirSync as Hu,rmSync as Ku,chmodSync as wi}from"node:fs";import{join as In}from"node:path";var Si=96*1024,Ti=500,Yu=168*3600*1e3,Ri=120;function On(){return In(R(),"sessions")}function Ai(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return In(On(),`${e}.jsonl`)}function Dn(t,e){try{let n=Ai(t);bi(On(),{recursive:!0,mode:448});let r=JSON.stringify({t:e.t??Math.floor(Date.now()/1e3),tool:e.tool,target:e.target.slice(0,Ri),...e.fail?{fail:1}:{}});if(_i(n,`${r}
43
+ `,{mode:384}),wi(n,384),ki(n).size>Si){let s=vi(n,"utf8").split(`
44
+ `).filter(a=>a.trim()!==""),i=s.slice(s.length-Ti),o=`${n}.tmp-${process.pid}`;xi(o,`${i.join(`
41
45
  `)}
42
- `,{mode:384}),vi(o,n)}}catch{}}N();import{readFileSync as Ai}from"node:fs";import{join as Ri}from"node:path";function Dn(){try{return JSON.parse(Ai(Ri(A(),"settings-cache.json"),"utf8")).enabled!==!1}catch{return!0}}N();import{createHash as Ci}from"node:crypto";import{appendFileSync as Ii,chmodSync as Oi,mkdirSync as Di,readFileSync as $i,rmSync as Ni,statSync as Pi}from"node:fs";import{join as $n}from"node:path";var Mi=256*1024,Li=80;function Fi(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return $n(A(),"sessions",`${e}.seen`)}function Tt(t){return t.replace(/[\t\r\n]+/g," ").trim().slice(0,Li)}function Nn(t,e,n,r){try{let s=Fi(t),i=Tt(e),o=Ci("sha256").update(n).digest("hex").slice(0,32),a="";try{a=$i(s,"utf8")}catch{}for(let c of a.split(`
43
- `)){let[l,u,f]=c.split(" ");if(l===i&&u===o)return{cmd:f??""}}Di($n(A(),"sessions"),{recursive:!0,mode:448}),Ii(s,`${i} ${o} ${Tt(r)}
44
- `,{mode:384}),Oi(s,384),Pi(s).size>Mi&&Ni(s,{force:!0})}catch{}return null}function Pn(t,e){return`[same output as \`${Tt(t)}\` earlier in this session, unchanged, ~${Math.round(e/4)} tokens]`}At();var ou=new Set(["Read","Grep","Glob","Bash"]),au=10*1024*1024,cu=1024,lu=/^… \(?\d+ more lines omitted\)?$/,uu=/^\[tkr restore [0-9a-f]{8,64}\]$/;function du(t){return lu.test(t)||uu.test(t)||t==="[YOLO: omitted]"}function ti(t,e){if(!t||typeof t=="string")return e;if(t.file?.content!=null)return{...t,file:{...t.file,content:e}};if(t.content!=null)return{...t,content:e};if(t.output!=null)return{...t,output:e};if(t.stdout!=null||t.stderr!=null)return{...t,stdout:e,stderr:""};if(Array.isArray(t.filenames)){let n=new Set(t.filenames),r=e.split(`
45
- `).filter(s=>n.has(s)||du(s));return{...t,filenames:r}}return e}function fu(t,e,n){return JSON.stringify({...n?{systemMessage:n}:{},hookSpecificOutput:{hookEventName:"PostToolUse",updatedToolOutput:ti(t.tool_response,e)}})}var pu=100,gn=null;function mu(){let t=gn;return gn=null,t}function Xs(t){let e=Math.round(t/4);return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function hu(t,e){try{if(Math.round((t-e)/4)<pu)return;let n=ei(A(),"first-save");if(nu(n))return;ru(n,String(Date.now())),gn=`Tokmizer just optimized its first command output here: ~${Xs(t)} tokens down to ~${Xs(e)}. Watch it add up: /tkr-gain`}catch{}}function Qs(t){return t?typeof t=="string"?t:t.file?.content!=null?t.file.content:t.content!=null?t.content:t.output!=null?t.output:t.stdout!=null||t.stderr!=null?[t.stdout??"",t.stderr??""].filter(Boolean).join(`
46
+ `,{mode:384}),Ei(o,n)}}catch{}}N();import{readFileSync as Ci}from"node:fs";import{join as Ii}from"node:path";function $n(){try{return JSON.parse(Ci(Ii(R(),"settings-cache.json"),"utf8")).enabled!==!1}catch{return!0}}N();import{createHash as Oi}from"node:crypto";import{appendFileSync as Di,chmodSync as $i,mkdirSync as Ni,readFileSync as Pi,rmSync as Mi,statSync as Li}from"node:fs";import{join as Nn}from"node:path";var Fi=256*1024,Bi=80;function ji(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return Nn(R(),"sessions",`${e}.seen`)}function It(t){return t.replace(/[\t\r\n]+/g," ").trim().slice(0,Bi)}function Pn(t,e,n,r){try{let s=ji(t),i=It(e),o=Oi("sha256").update(n).digest("hex").slice(0,32),a="";try{a=Pi(s,"utf8")}catch{}for(let c of a.split(`
47
+ `)){let[l,u,f]=c.split(" ");if(l===i&&u===o)return{cmd:f??""}}Ni(Nn(R(),"sessions"),{recursive:!0,mode:448}),Di(s,`${i} ${o} ${It(r)}
48
+ `,{mode:384}),$i(s,384),Li(s).size>Fi&&Mi(s,{force:!0})}catch{}return null}function Mn(t,e){return`[same output as \`${It(t)}\` earlier in this session, unchanged, ~${Math.round(e/4)} tokens]`}Ot();var uu=new Set(["Read","Grep","Glob","Bash"]),du=10*1024*1024,fu=1024,pu=/^… \(?\d+ more lines omitted\)?$/,mu=/^\[tkr restore [0-9a-f]{8,64}\]$/;function hu(t){return pu.test(t)||mu.test(t)||t==="[YOLO: omitted]"}function ri(t,e){if(!t||typeof t=="string")return e;if(t.file?.content!=null)return{...t,file:{...t.file,content:e}};if(t.content!=null)return{...t,content:e};if(t.output!=null)return{...t,output:e};if(t.stdout!=null||t.stderr!=null)return{...t,stdout:e,stderr:""};if(Array.isArray(t.filenames)){let n=new Set(t.filenames),r=e.split(`
49
+ `).filter(s=>n.has(s)||hu(s));return{...t,filenames:r}}return e}function gu(t,e,n){return JSON.stringify({...n?{systemMessage:n}:{},hookSpecificOutput:{hookEventName:"PostToolUse",updatedToolOutput:ri(t.tool_response,e)}})}var yu=100,vn=null;function _u(){let t=vn;return vn=null,t}function ei(t){let e=Math.round(t/4);return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function bu(t,e){try{if(Math.round((t-e)/4)<yu)return;let n=ni(R(),"first-save");if(ou(n))return;au(n,String(Date.now())),vn=`Tokmizer just optimized its first command output here: ~${ei(t)} tokens down to ~${ei(e)}. Watch it add up: /tkr-gain`}catch{}}function ti(t){return t?typeof t=="string"?t:t.file?.content!=null?t.file.content:t.content!=null?t.content:t.output!=null?t.output:t.stdout!=null||t.stderr!=null?[t.stdout??"",t.stderr??""].filter(Boolean).join(`
46
50
  `):Array.isArray(t.filenames)?t.filenames.join(`
47
- `):null:""}var gu=64*1024;function yu(t,e){try{if(!e||typeof e!="object")return;let n=ei(A(),"drift.jsonl");try{if(iu(n).size>gu)return}catch{}let r=Object.keys(e).slice(0,12);su(n,`${JSON.stringify({t:Math.floor(Date.now()/1e3),tool:t,keys:r})}
48
- `)}catch{}}function _u(t){let e=t.tool_name??"tool",n=t.tool_input??{};return n.command?n.command.split(`
49
- `)[0].trim().slice(0,200):n.file_path?`${e.toLowerCase()} ${n.file_path}`:n.pattern?`${e.toLowerCase()} ${n.pattern}`:n.path?`${e.toLowerCase()} ${n.path}`:e.toLowerCase()}async function bu(t){let e=ee();if(!t.tool_name||!ou.has(t.tool_name))return null;let n=t.tool_name==="Bash"?t.tool_input?.command??"":"",r=n.includes("tkr-exec");if(/\btkr(?:\.js)?\s+restore\b/.test(n))return null;let s=await Ue();if(!s||!s.token||!Dn())return null;if(t.session_id&&!r){let C=t.tool_input??{},nt=C.command??C.file_path??C.pattern??C.path??"";nt&&On(t.session_id,{tool:t.tool_name,target:nt.split(`
50
- `)[0].trim()})}if(t.tool_name==="Read"&&(t.tool_input?.offset!=null||t.tool_input?.limit!=null))return null;let i=Qs(t.tool_response);if(i==null)return yu(t.tool_name,t.tool_response),null;if(!i)return null;let o=Buffer.byteLength(i,"utf8");if(o>au||t.tool_name==="Bash"&&o<cu||r)return null;let{loadSettingsCache:a,processOutput:c,captureForRestore:l,captureOriginalForRestore:u,FOLD_MARKER_RE:f,resolveAllowedFilters:d,gatingPlan:g,graceExceeded:v,recordEvent:E,recordTelemetry:R,recordStat:O,countedSaving:U,statCmdLabel:ae,installDaemonResolver:I,closeDaemonResolver:ce}=await Promise.resolve().then(()=>(qs(),Js)),V=await a();if(!V.enabled)return null;let{slugKey:yn}=await Promise.resolve().then(()=>(Te(),or)),ze=g(s);I(ze);let _n=d(s.allowedFilters,v(s)),bn=new Set(V.filters.disabled.map(yn)),ni=bn.size>0?new Set([..._n].filter(C=>!bn.has(C))):_n,ri=_u(t),kt=`${t.tool_name.toLowerCase()}-tool`,si=`${kt}: ${ri}`;try{let C=await c(si,i,ni,{verbosity:V.outputVerbosity,yolo:e,exitCode:t.tool_name==="Bash"?void 0:0});if(C.filterId!=null&&t.tool_name==="Bash"&&t.session_id){let vn=Nn(t.session_id,t.agent_id??"main",i,n.split(`
51
- `)[0]??"");if(vn){let xn=Pn(vn.cmd,o);return e?xn:await u(i,xn)}}await E({cmd:kt,filterId:C.filterId,rawBytes:C.rawBytes,filteredBytes:C.filteredBytes,plan:ze});let nt=new RegExp(f.source,"m"),z;C.filteredBytes>=C.rawBytes?z=null:e?z=C.output:nt.test(C.output)?z=await u(i,C.output):z=await l(C.droppedTail??null,C.output),e&&z!=null&&(z=Qs(ti(t.tool_response,z)));let ii=z==null?C.rawBytes:Buffer.byteLength(z,"utf8"),Et=Rn().host,le=U(C.rawBytes,ii,An(Et));return z!=null&&hu(le.raw,le.filtered),O(le.raw,le.filtered,void 0,!1,Et,t.tool_name==="Bash"?"sh":void 0,t.tool_name==="Bash"?ae(t.tool_input?.command??""):t.tool_name),await R({cmd:kt,tokensSaved:Math.round((le.raw-le.filtered)/4),rawTokens:Math.round(le.raw/4),optimized:C.filterId!=null,telemetryOptIn:V.telemetryOptIn,host:Et}),z}finally{ce()}}async function vu(){let t=await En();t||process.exit(0);let e;try{e=JSON.parse(t)}catch{process.exit(0)}let n=await bu(e);n||process.exit(0),process.stdout.write(fu(e,n,mu()??void 0))}var xu=process.argv[1]??"";Sn(xu,import.meta.url)&&vu().catch(t=>{process.stderr.write(`tkr post-tool-use: ${t.message}
52
- `),process.exit(0)});export{fu as buildHookEnvelope,bu as processToolOutput,mu as takeFirstSaveNotice};
51
+ `):null:""}var vu=64*1024;function xu(t,e){try{if(!e||typeof e!="object")return;let n=ni(R(),"drift.jsonl");try{if(lu(n).size>vu)return}catch{}let r=Object.keys(e).slice(0,12);cu(n,`${JSON.stringify({t:Math.floor(Date.now()/1e3),tool:t,keys:r})}
52
+ `)}catch{}}function Eu(t){let e=t.tool_name??"tool",n=t.tool_input??{};return n.command?n.command.split(`
53
+ `)[0].trim().slice(0,200):n.file_path?`${e.toLowerCase()} ${n.file_path}`:n.pattern?`${e.toLowerCase()} ${n.pattern}`:n.path?`${e.toLowerCase()} ${n.path}`:e.toLowerCase()}async function ku(t){let e=ee();if(!t.tool_name||!uu.has(t.tool_name))return null;let n=t.tool_name==="Bash"?t.tool_input?.command??"":"",r=n.includes("tkr-exec");if(/\btkr(?:\.js)?\s+restore\b/.test(n))return null;let s=await Ke();if(!s||!s.token||!$n())return null;if(t.session_id&&!r){let I=t.tool_input??{},it=I.command??I.file_path??I.pattern??I.path??"";it&&Dn(t.session_id,{tool:t.tool_name,target:it.split(`
54
+ `)[0].trim()})}if(t.tool_name==="Read"&&(t.tool_input?.offset!=null||t.tool_input?.limit!=null))return null;let i=ti(t.tool_response);if(i==null)return xu(t.tool_name,t.tool_response),null;if(!i)return null;let o=Buffer.byteLength(i,"utf8");if(o>du||t.tool_name==="Bash"&&o<fu||r)return null;let{loadSettingsCache:a,processOutput:c,captureForRestore:l,captureOriginalForRestore:u,FOLD_MARKER_RE:f,resolveAllowedFilters:d,gatingPlan:g,graceExceeded:v,recordEvent:w,recordTelemetry:A,recordStat:O,countedSaving:U,statCmdLabel:Te,installDaemonResolver:V,closeDaemonResolver:Re}=await Promise.resolve().then(()=>(Qs(),Xs)),C=await a();if(!C.enabled)return null;let{slugKey:Ue}=await Promise.resolve().then(()=>(we(),ar)),Ae=g(s);V(Ae);let St=d(s.allowedFilters,v(s)),Ve=new Set(C.filters.disabled.map(Ue)),si=Ve.size>0?new Set([...St].filter(I=>!Ve.has(I))):St,ii=Eu(t),Tt=`${t.tool_name.toLowerCase()}-tool`,oi=`${Tt}: ${ii}`;try{let I=await c(oi,i,si,{verbosity:C.outputVerbosity,yolo:e,exitCode:t.tool_name==="Bash"?void 0:0});if(I.filterId!=null&&t.tool_name==="Bash"&&t.session_id){let xn=Pn(t.session_id,t.agent_id??"main",i,n.split(`
55
+ `)[0]??"");if(xn){let En=Mn(xn.cmd,o);return e?En:await u(i,En)}}await w({cmd:Tt,filterId:I.filterId,rawBytes:I.rawBytes,filteredBytes:I.filteredBytes,plan:Ae});let it=new RegExp(f.source,"m"),z;I.filteredBytes>=I.rawBytes?z=null:e?z=I.output:it.test(I.output)?z=await u(i,I.output):z=await l(I.droppedTail??null,I.output),e&&z!=null&&(z=ti(ri(t.tool_response,z)));let ai=z==null?I.rawBytes:Buffer.byteLength(z,"utf8"),Rt=Cn().host,ae=U(I.rawBytes,ai,An(Rt));return z!=null&&bu(ae.raw,ae.filtered),O(ae.raw,ae.filtered,void 0,!1,Rt,t.tool_name==="Bash"?"sh":void 0,t.tool_name==="Bash"?Te(t.tool_input?.command??""):t.tool_name),await A({cmd:Tt,tokensSaved:Math.round((ae.raw-ae.filtered)/4),rawTokens:Math.round(ae.raw/4),optimized:I.filterId!=null,telemetryOptIn:C.telemetryOptIn,host:Rt}),z}finally{Re()}}async function wu(){let t=await wn();t||process.exit(0);let e;try{e=JSON.parse(t)}catch{process.exit(0)}let n=await ku(e);n||process.exit(0),process.stdout.write(gu(e,n,_u()??void 0))}var Su=process.argv[1]??"";Tn(Su,import.meta.url)&&wu().catch(t=>{process.stderr.write(`tkr post-tool-use: ${t.message}
56
+ `),process.exit(0)});export{gu as buildHookEnvelope,ku as processToolOutput,_u as takeFirstSaveNotice};