@tokmizer/plugin 0.9.50 → 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,32 +1,47 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
3
- var Js=Object.create;var Et=Object.defineProperty;var Xs=Object.getOwnPropertyDescriptor;var Qs=Object.getOwnPropertyNames;var ei=Object.getPrototypeOf,ti=Object.prototype.hasOwnProperty;var X=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var M=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},ri=(t,e)=>{for(var r in e)Et(t,r,{get:e[r],enumerable:!0})},ni=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Qs(e))!ti.call(t,s)&&s!==r&&Et(t,s,{get:()=>e[s],enumerable:!(n=Xs(e,s))||n.enumerable});return t};var si=(t,e,r)=>(r=t!=null?Js(ei(t)):{},ni(e||!t||!t.__esModule?Et(r,"default",{value:t,enumerable:!0}):r,t));var vr=M((cu,_r)=>{_r.exports=yr;yr.sync=oi;var hr=X("fs");function ii(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var s=r[n].toLowerCase();if(s&&t.substr(-s.length).toLowerCase()===s)return!0}return!1}function gr(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:ii(e,r)}function yr(t,e,r){hr.stat(t,function(n,s){r(n,n?!1:gr(s,t,e))})}function oi(t,e){return gr(hr.statSync(t),t,e)}});var kr=M((lu,wr)=>{wr.exports=br;br.sync=ai;var xr=X("fs");function br(t,e,r){xr.stat(t,function(n,s){r(n,n?!1:Er(s,e))})}function ai(t,e){return Er(xr.statSync(t),e)}function Er(t,e){return t.isFile()&&ci(t,e)}function ci(t,e){var r=t.mode,n=t.uid,s=t.gid,i=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),l=a|c,d=r&u||r&c&&s===o||r&a&&n===i||r&l&&i===0;return d}});var Tr=M((du,Sr)=>{var uu=X("fs"),rt;process.platform==="win32"||global.TESTING_WINDOWS?rt=vr():rt=kr();Sr.exports=wt;wt.sync=li;function wt(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,s){wt(t,e||{},function(i,o){i?s(i):n(o)})})}rt(t,e||{},function(n,s){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,s=!1),r(n,s)})}function li(t,e){try{return rt.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Pr=M((fu,Or)=>{var Ae=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ar=X("path"),ui=Ae?";":":",Rr=Tr(),Cr=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Ir=(t,e)=>{let r=e.colon||ui,n=t.match(/\//)||Ae&&t.match(/\\/)?[""]:[...Ae?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],s=Ae?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",i=Ae?s.split(r):[""];return Ae&&t.indexOf(".")!==-1&&i[0]!==""&&i.unshift(""),{pathEnv:n,pathExt:i,pathExtExe:s}},$r=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:n,pathExt:s,pathExtExe:i}=Ir(t,e),o=[],a=u=>new Promise((l,d)=>{if(u===n.length)return e.all&&o.length?l(o):d(Cr(t));let p=n[u],y=/^".*"$/.test(p)?p.slice(1,-1):p,S=Ar.join(y,t),w=!y&&/^\.[\\\/]/.test(t)?t.slice(0,2)+S:S;l(c(w,u,0))}),c=(u,l,d)=>new Promise((p,y)=>{if(d===s.length)return p(a(l+1));let S=s[d];Rr(u+S,{pathExt:i},(w,A)=>{if(!w&&A)if(e.all)o.push(u+S);else return p(u+S);return p(c(u,l,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},di=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:n,pathExtExe:s}=Ir(t,e),i=[];for(let o=0;o<r.length;o++){let a=r[o],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=Ar.join(c,t),l=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;for(let d=0;d<n.length;d++){let p=l+n[d];try{if(Rr.sync(p,{pathExt:s}))if(e.all)i.push(p);else return p}catch{}}}if(e.all&&i.length)return i;if(e.nothrow)return null;throw Cr(t)};Or.exports=$r;$r.sync=di});var Nr=M((pu,kt)=>{"use strict";var Dr=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};kt.exports=Dr;kt.exports.default=Dr});var Br=M((mu,Fr)=>{"use strict";var Mr=X("path"),fi=Pr(),pi=Nr();function Lr(t,e){let r=t.options.env||process.env,n=process.cwd(),s=t.options.cwd!=null,i=s&&process.chdir!==void 0&&!process.chdir.disabled;if(i)try{process.chdir(t.options.cwd)}catch{}let o;try{o=fi.sync(t.command,{path:r[pi({env:r})],pathExt:e?Mr.delimiter:void 0})}catch{}finally{i&&process.chdir(n)}return o&&(o=Mr.resolve(s?t.options.cwd:"",o)),o}function mi(t){return Lr(t)||Lr(t,!0)}Fr.exports=mi});var jr=M((hu,Tt)=>{"use strict";var St=/([()\][%!^"`<>&|;, *?])/g;function hi(t){return t=t.replace(St,"^$1"),t}function gi(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(St,"^$1"),e&&(t=t.replace(St,"^$1")),t}Tt.exports.command=hi;Tt.exports.argument=gi});var Zr=M((gu,zr)=>{"use strict";zr.exports=/^#!(.*)/});var Hr=M((yu,Ur)=>{"use strict";var yi=Zr();Ur.exports=(t="")=>{let e=t.match(yi);if(!e)return null;let[r,n]=e[0].replace(/#! ?/,"").split(" "),s=r.split("/").pop();return s==="env"?n:n?`${s} ${n}`:s}});var Kr=M((_u,Vr)=>{"use strict";var At=X("fs"),_i=Hr();function vi(t){let r=Buffer.alloc(150),n;try{n=At.openSync(t,"r"),At.readSync(n,r,0,150,0),At.closeSync(n)}catch{}return _i(r.toString())}Vr.exports=vi});var Yr=M((vu,qr)=>{"use strict";var xi=X("path"),Wr=Br(),Gr=jr(),bi=Kr(),Ei=process.platform==="win32",wi=/\.(?:com|exe)$/i,ki=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Si(t){t.file=Wr(t);let e=t.file&&bi(t.file);return e?(t.args.unshift(t.file),t.command=e,Wr(t)):t.file}function Ti(t){if(!Ei)return t;let e=Si(t),r=!wi.test(e);if(t.options.forceShell||r){let n=ki.test(e);t.command=xi.normalize(t.command),t.command=Gr.command(t.command),t.args=t.args.map(i=>Gr.argument(i,n));let s=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${s}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function Ai(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let n={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?n:Ti(n)}qr.exports=Ai});var Qr=M((xu,Xr)=>{"use strict";var Rt=process.platform==="win32";function Ct(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function Ri(t,e){if(!Rt)return;let r=t.emit;t.emit=function(n,s){if(n==="exit"){let i=Jr(s,e);if(i)return r.call(t,"error",i)}return r.apply(t,arguments)}}function Jr(t,e){return Rt&&t===1&&!e.file?Ct(e.original,"spawn"):null}function Ci(t,e){return Rt&&t===1&&!e.file?Ct(e.original,"spawnSync"):null}Xr.exports={hookChildProcess:Ri,verifyENOENT:Jr,verifyENOENTSync:Ci,notFoundError:Ct}});var rn=M((bu,Re)=>{"use strict";var en=X("child_process"),It=Yr(),$t=Qr();function tn(t,e,r){let n=It(t,e,r),s=en.spawn(n.command,n.args,n.options);return $t.hookChildProcess(s,n),s}function Ii(t,e,r){let n=It(t,e,r),s=en.spawnSync(n.command,n.args,n.options);return s.error=s.error||$t.verifyENOENTSync(s.status,n),s}Re.exports=tn;Re.exports.spawn=tn;Re.exports.sync=Ii;Re.exports._parse=It;Re.exports._enoent=$t});var Vs=si(rn(),1);import{readdir as Zo,readFile as Uo}from"node:fs/promises";import{join as yn,dirname as Ho}from"node:path";import{fileURLToPath as Vo}from"node:url";var m={};ri(m,{BRAND:()=>ro,DIRTY:()=>oe,EMPTY_PATH:()=>Di,INVALID:()=>v,NEVER:()=>zo,OK:()=>O,ParseStatus:()=>I,Schema:()=>E,ZodAny:()=>te,ZodArray:()=>Y,ZodBigInt:()=>ce,ZodBoolean:()=>le,ZodBranded:()=>Ze,ZodCatch:()=>xe,ZodDate:()=>ue,ZodDefault:()=>ve,ZodDiscriminatedUnion:()=>it,ZodEffects:()=>j,ZodEnum:()=>ye,ZodError:()=>P,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>at,ZodIntersection:()=>me,ZodIssueCode:()=>f,ZodLazy:()=>he,ZodLiteral:()=>ge,ZodMap:()=>De,ZodNaN:()=>Me,ZodNativeEnum:()=>_e,ZodNever:()=>z,ZodNull:()=>fe,ZodNullable:()=>K,ZodNumber:()=>ae,ZodObject:()=>D,ZodOptional:()=>F,ZodParsedType:()=>g,ZodPipeline:()=>Ue,ZodPromise:()=>re,ZodReadonly:()=>be,ZodRecord:()=>ot,ZodSchema:()=>E,ZodSet:()=>Ne,ZodString:()=>ee,ZodSymbol:()=>Oe,ZodTransformer:()=>j,ZodTuple:()=>V,ZodType:()=>E,ZodUndefined:()=>de,ZodUnion:()=>pe,ZodUnknown:()=>q,ZodVoid:()=>Pe,addIssueToContext:()=>h,any:()=>fo,array:()=>go,bigint:()=>oo,boolean:()=>mn,coerce:()=>jo,custom:()=>dn,date:()=>ao,datetimeRegex:()=>ln,defaultErrorMap:()=>W,discriminatedUnion:()=>xo,effect:()=>Oo,enum:()=>Co,function:()=>To,getErrorMap:()=>Ce,getParsedType:()=>H,instanceof:()=>so,intersection:()=>bo,isAborted:()=>nt,isAsync:()=>Ie,isDirty:()=>st,isValid:()=>Q,late:()=>no,lazy:()=>Ao,literal:()=>Ro,makeIssue:()=>ze,map:()=>ko,nan:()=>io,nativeEnum:()=>Io,never:()=>mo,null:()=>uo,nullable:()=>Do,number:()=>pn,object:()=>yo,objectUtil:()=>Ot,oboolean:()=>Bo,onumber:()=>Fo,optional:()=>Po,ostring:()=>Lo,pipeline:()=>Mo,preprocess:()=>No,promise:()=>$o,quotelessJson:()=>$i,record:()=>wo,set:()=>So,setErrorMap:()=>Pi,strictObject:()=>_o,string:()=>fn,symbol:()=>co,transformer:()=>Oo,tuple:()=>Eo,undefined:()=>lo,union:()=>vo,unknown:()=>po,util:()=>k,void:()=>ho});var k;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,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 n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(k||(k={}));var Ot;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ot||(Ot={}));var g=k.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 g.undefined;case"string":return g.string;case"number":return Number.isNaN(t)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}};var f=k.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"]),$i=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=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_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)n._errors.push(r(o));else{let a=n,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),n}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,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};P.create=t=>new P(t);var Oi=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===g.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,k.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:k.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case f.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case f.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,k.assertNever(t)}return{message:r}},W=Oi;var nn=W;function Pi(t){nn=t}function Ce(){return nn}var ze=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},Di=[];function h(t,e){let r=Ce(),n=ze({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===W?void 0:W].filter(s=>!!s)});t.common.issues.push(n)}var I=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let i=await s.key,o=await s.value;n.push({key:i,value:o})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}},v=Object.freeze({status:"aborted"}),oe=t=>({status:"dirty",value:t}),O=t=>({status:"valid",value:t}),nt=t=>t.status==="aborted",st=t=>t.status==="dirty",Q=t=>t.status==="valid",Ie=t=>typeof Promise<"u"&&t instanceof Promise;var _;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(_||(_={}));var B=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,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}},sn=(t,e)=>{if(Q(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 r=new P(t.common.issues);return this._error=r,this._error}}};function b(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))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??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}var E=class{get description(){return this._def.description}_getType(e){return H(e.data)}_getOrReturnCtx(e,r){return r||{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 I,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 r=this._parse(e);if(Ie(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:H(e)},s=this._parseSync({data:e,path:n.path,parent:n});return sn(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:H(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Q(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>Q(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:H(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Ie(s)?s:Promise.resolve(s));return sn(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:f.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new j({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return F.create(this,this._def)}nullable(){return K.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this)}promise(){return re.create(this,this._def)}or(e){return pe.create([this,e],this._def)}and(e){return me.create(this,e,this._def)}transform(e){return new j({...b(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ve({...b(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new Ze({typeName:x.ZodBranded,type:this,...b(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new xe({...b(this._def),innerType:this,catchValue:r,typeName:x.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ue.create(this,e)}readonly(){return be.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ni=/^c[^\s-]{8,}$/i,Mi=/^[0-9a-z]+$/,Li=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Fi=/^[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,Bi=/^[a-z0-9_-]{21}$/i,ji=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zi=/^[-+]?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)?)??$/,Zi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ui="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Pt,Hi=/^(?:(?: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])$/,Vi=/^(?:(?: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])$/,Ki=/^(([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]))$/,Wi=/^(([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])$/,Gi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qi=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,an="((\\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])))",Yi=new RegExp(`^${an}$`);function cn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Ji(t){return new RegExp(`^${cn(t)}$`)}function ln(t){let e=`${an}T${cn(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Xi(t,e){return!!((e==="v4"||!e)&&Hi.test(t)||(e==="v6"||!e)&&Ki.test(t))}function Qi(t,e){if(!ji.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function eo(t,e){return!!((e==="v4"||!e)&&Vi.test(t)||(e==="v6"||!e)&&Wi.test(t))}var ee=class t extends E{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:g.string,received:i.parsedType}),v}let n=new I,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?h(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&h(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Zi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"email",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Pt||(Pt=new RegExp(Ui,"u")),Pt.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"emoji",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Fi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"uuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Bi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"nanoid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Ni.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Mi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid2",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Li.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ulid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),h(s,{validation:"url",code:f.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"regex",code:f.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?ln(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Yi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Ji(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?zi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Xi(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ip",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Qi(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"jwt",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?eo(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cidr",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Gi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?qi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:f.invalid_string,message:i.message}),n.dirty()):k.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:f.invalid_string,..._.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",..._.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",..._.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",..._.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,..._.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,..._.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",..._.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,..._.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,..._.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,..._.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,..._.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,..._.errToObj(r)})}nonempty(e){return this.min(1,_.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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ee.create=t=>new ee({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...b(t)});function to(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var ae=class t extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:g.number,received:i.parsedType}),v}let n,s=new I;for(let i of this._def.checks)i.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:f.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?to(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:f.not_finite,message:i.message}),s.dirty()):k.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,_.toString(r))}gt(e,r){return this.setLimit("min",e,!1,_.toString(r))}lte(e,r){return this.setLimit("max",e,!0,_.toString(r))}lt(e,r){return this.setLimit("max",e,!1,_.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:_.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};ae.create=t=>new ae({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...b(t)});var ce=class t extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==g.bigint)return this._getInvalidInput(e);let n,s=new I;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):k.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.bigint,received:r.parsedType}),v}gte(e,r){return this.setLimit("min",e,!0,_.toString(r))}gt(e,r){return this.setLimit("min",e,!1,_.toString(r))}lte(e,r){return this.setLimit("max",e,!0,_.toString(r))}lt(e,r){return this.setLimit("max",e,!1,_.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:_.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:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ce.create=t=>new ce({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...b(t)});var le=class extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.boolean,received:n.parsedType}),v}return O(e.data)}};le.create=t=>new le({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...b(t)});var ue=class t extends E{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:g.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_date}),v}let n=new I,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):k.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ue.create=t=>new ue({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...b(t)});var Oe=class extends E{_parse(e){if(this._getType(e)!==g.symbol){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.symbol,received:n.parsedType}),v}return O(e.data)}};Oe.create=t=>new Oe({typeName:x.ZodSymbol,...b(t)});var de=class extends E{_parse(e){if(this._getType(e)!==g.undefined){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.undefined,received:n.parsedType}),v}return O(e.data)}};de.create=t=>new de({typeName:x.ZodUndefined,...b(t)});var fe=class extends E{_parse(e){if(this._getType(e)!==g.null){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.null,received:n.parsedType}),v}return O(e.data)}};fe.create=t=>new fe({typeName:x.ZodNull,...b(t)});var te=class extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}};te.create=t=>new te({typeName:x.ZodAny,...b(t)});var q=class extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}};q.create=t=>new q({typeName:x.ZodUnknown,...b(t)});var z=class extends E{_parse(e){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.never,received:r.parsedType}),v}};z.create=t=>new z({typeName:x.ZodNever,...b(t)});var Pe=class extends E{_parse(e){if(this._getType(e)!==g.undefined){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.void,received:n.parsedType}),v}return O(e.data)}};Pe.create=t=>new Pe({typeName:x.ZodVoid,...b(t)});var Y=class t extends E{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==g.array)return h(r,{code:f.invalid_type,expected:g.array,received:r.parsedType}),v;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(o||a)&&(h(r,{code:o?f.too_big:f.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(h(r,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(h(r,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>s.type._parseAsync(new B(r,o,r.path,a)))).then(o=>I.mergeArray(n,o));let i=[...r.data].map((o,a)=>s.type._parseSync(new B(r,o,r.path,a)));return I.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:_.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:_.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:_.toString(r)}})}nonempty(e){return this.min(1,e)}};Y.create=(t,e)=>new Y({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...b(e)});function $e(t){if(t instanceof D){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=F.create($e(n))}return new D({...t._def,shape:()=>e})}else return t instanceof Y?new Y({...t._def,type:$e(t.element)}):t instanceof F?F.create($e(t.unwrap())):t instanceof K?K.create($e(t.unwrap())):t instanceof V?V.create(t.items.map(e=>$e(e))):t}var D=class t extends E{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(),r=k.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==g.object){let u=this._getOrReturnCtx(e);return h(u,{code:f.invalid_type,expected:g.object,received:u.parsedType}),v}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof z&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new B(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof z){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(h(s,{code:f.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new B(s,d,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,p=await l.value;u.push({key:d,value:p,alwaysSet:l.alwaysSet})}return u}).then(u=>I.mergeObjectSync(n,u)):I.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:_.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of k.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of k.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return $e(this)}partial(e){let r={};for(let n of k.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of k.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof F;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return un(k.objectKeys(this.shape))}};D.create=(t,e)=>new D({shape:()=>t,unknownKeys:"strip",catchall:z.create(),typeName:x.ZodObject,...b(e)});D.strictCreate=(t,e)=>new D({shape:()=>t,unknownKeys:"strict",catchall:z.create(),typeName:x.ZodObject,...b(e)});D.lazycreate=(t,e)=>new D({shape:t,unknownKeys:"strip",catchall:z.create(),typeName:x.ZodObject,...b(e)});var pe=class extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n=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 r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new P(a.ctx.common.issues));return h(r,{code:f.invalid_union,unionErrors:o}),v}if(r.common.async)return Promise.all(n.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new P(c));return h(r,{code:f.invalid_union,unionErrors:a}),v}}get options(){return this._def.options}};pe.create=(t,e)=>new pe({options:t,typeName:x.ZodUnion,...b(e)});var G=t=>t instanceof he?G(t.schema):t instanceof j?G(t.innerType()):t instanceof ge?[t.value]:t instanceof ye?t.options:t instanceof _e?k.objectValues(t.enum):t instanceof ve?G(t._def.innerType):t instanceof de?[void 0]:t instanceof fe?[null]:t instanceof F?[void 0,...G(t.unwrap())]:t instanceof K?[null,...G(t.unwrap())]:t instanceof Ze||t instanceof be?G(t.unwrap()):t instanceof xe?G(t._def.innerType):[],it=class t extends E{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return h(r,{code:f.invalid_type,expected:g.object,received:r.parsedType}),v;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(h(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let o=G(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...b(n)})}};function Dt(t,e){let r=H(t),n=H(e);if(t===e)return{valid:!0,data:t};if(r===g.object&&n===g.object){let s=k.objectKeys(e),i=k.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(r===g.array&&n===g.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Dt(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===g.date&&n===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var me=class extends E{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,o)=>{if(nt(i)||nt(o))return v;let a=Dt(i.value,o.value);return a.valid?((st(i)||st(o))&&r.dirty(),{status:r.value,value:a.data}):(h(n,{code:f.invalid_intersection_types}),v)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};me.create=(t,e,r)=>new me({left:t,right:e,typeName:x.ZodIntersection,...b(r)});var V=class t extends E{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.array)return h(n,{code:f.invalid_type,expected:g.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return h(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(h(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new B(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>I.mergeArray(r,o)):I.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};V.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new V({items:t,typeName:x.ZodTuple,rest:null,...b(e)})};var ot=class t extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return h(n,{code:f.invalid_type,expected:g.object,received:n.parsedType}),v;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:i._parse(new B(n,a,n.path,a)),value:o._parse(new B(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?I.mergeObjectAsync(r,s):I.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof E?new t({keyType:e,valueType:r,typeName:x.ZodRecord,...b(n)}):new t({keyType:ee.create(),valueType:e,typeName:x.ZodRecord,...b(r)})}},De=class extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.map)return h(n,{code:f.invalid_type,expected:g.map,received:n.parsedType}),v;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,c],u)=>({key:s._parse(new B(n,a,n.path,[u,"key"])),value:i._parse(new B(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return v;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return v;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};De.create=(t,e,r)=>new De({valueType:e,keyType:t,typeName:x.ZodMap,...b(r)});var Ne=class t extends E{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.set)return h(n,{code:f.invalid_type,expected:g.set,received:n.parsedType}),v;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(h(n,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(h(n,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return v;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>i._parse(new B(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:_.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:_.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Ne.create=(t,e)=>new Ne({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...b(e)});var at=class t extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.function)return h(r,{code:f.invalid_type,expected:g.function,received:r.parsedType}),v;function n(a,c){return ze({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ce(),W].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:c}})}function s(a,c){return ze({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ce(),W].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof re){let a=this;return O(async function(...c){let u=new P([]),l=await a._def.args.parseAsync(c,i).catch(y=>{throw u.addIssue(n(c,y)),u}),d=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(d,i).catch(y=>{throw u.addIssue(s(d,y)),u})})}else{let a=this;return O(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new P([n(c,u.error)]);let l=Reflect.apply(o,this,u.data),d=a._def.returns.safeParse(l,i);if(!d.success)throw new P([s(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:V.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,r,n){return new t({args:e||V.create([]).rest(q.create()),returns:r||q.create(),typeName:x.ZodFunction,...b(n)})}},he=class extends E{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};he.create=(t,e)=>new he({getter:t,typeName:x.ZodLazy,...b(e)});var ge=class extends E{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return h(r,{received:r.data,code:f.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};ge.create=(t,e)=>new ge({value:t,typeName:x.ZodLiteral,...b(e)});function un(t,e){return new ye({values:t,typeName:x.ZodEnum,...b(e)})}var ye=class t extends E{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return h(r,{expected:k.joinValues(n),received:r.parsedType,code:f.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return h(r,{received:r.data,code:f.invalid_enum_value,options:n}),v}return O(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};ye.create=un;var _e=class extends E{_parse(e){let r=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==g.string&&n.parsedType!==g.number){let s=k.objectValues(r);return h(n,{expected:k.joinValues(s),received:n.parsedType,code:f.invalid_type}),v}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=k.objectValues(r);return h(n,{received:n.data,code:f.invalid_enum_value,options:s}),v}return O(e.data)}get enum(){return this._def.values}};_e.create=(t,e)=>new _e({values:t,typeName:x.ZodNativeEnum,...b(e)});var re=class extends E{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.promise&&r.common.async===!1)return h(r,{code:f.invalid_type,expected:g.promise,received:r.parsedType}),v;let n=r.parsedType===g.promise?r.data:Promise.resolve(r.data);return O(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};re.create=(t,e)=>new re({type:t,typeName:x.ZodPromise,...b(e)});var j=class extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{h(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return v;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?v:c.status==="dirty"?oe(c.value):r.value==="dirty"?oe(c.value):c});{if(r.value==="aborted")return v;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?v:a.status==="dirty"?oe(a.value):r.value==="dirty"?oe(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(n.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(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?v:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?v:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Q(o))return v;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Q(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:r.value,value:a})):v);k.assertNever(s)}};j.create=(t,e,r)=>new j({schema:t,typeName:x.ZodEffects,effect:e,...b(r)});j.createWithPreprocess=(t,e,r)=>new j({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...b(r)});var F=class extends E{_parse(e){return this._getType(e)===g.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:x.ZodOptional,...b(e)});var K=class extends E{_parse(e){return this._getType(e)===g.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};K.create=(t,e)=>new K({innerType:t,typeName:x.ZodNullable,...b(e)});var ve=class extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===g.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ve.create=(t,e)=>new ve({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var xe=class extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ie(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new P(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new P(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};xe.create=(t,e)=>new xe({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var Me=class extends E{_parse(e){if(this._getType(e)!==g.nan){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}};Me.create=t=>new Me({typeName:x.ZodNaN,...b(t)});var ro=Symbol("zod_brand"),Ze=class extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Ue=class t extends E{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?v:i.status==="dirty"?(r.dirty(),oe(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:x.ZodPipeline})}},be=class extends E{_parse(e){let r=this._def.innerType._parse(e),n=s=>(Q(s)&&(s.value=Object.freeze(s.value)),s);return Ie(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};be.create=(t,e)=>new be({innerType:t,typeName:x.ZodReadonly,...b(e)});function on(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function dn(t,e={},r){return t?te.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(o=>{if(!o){let a=on(e,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=on(e,n),a=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:a})}}):te.create()}var no={object:D.lazycreate},x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));var so=(t,e={message:`Input not instance of ${t.name}`})=>dn(r=>r instanceof t,e),fn=ee.create,pn=ae.create,io=Me.create,oo=ce.create,mn=le.create,ao=ue.create,co=Oe.create,lo=de.create,uo=fe.create,fo=te.create,po=q.create,mo=z.create,ho=Pe.create,go=Y.create,yo=D.create,_o=D.strictCreate,vo=pe.create,xo=it.create,bo=me.create,Eo=V.create,wo=ot.create,ko=De.create,So=Ne.create,To=at.create,Ao=he.create,Ro=ge.create,Co=ye.create,Io=_e.create,$o=re.create,Oo=j.create,Po=F.create,Do=K.create,No=j.createWithPreprocess,Mo=Ue.create,Lo=()=>fn().optional(),Fo=()=>pn().optional(),Bo=()=>mn().optional(),jo={string:(t=>ee.create({...t,coerce:!0})),number:(t=>ae.create({...t,coerce:!0})),boolean:(t=>le.create({...t,coerce:!0})),bigint:(t=>ce.create({...t,coerce:!0})),date:(t=>ue.create({...t,coerce:!0}))};var zo=v;var 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()});var Ko=Ho(Vo(import.meta.url)),hn=process.env.TOKMIZER_FILTERS_DIR||yn(Ko,"..","..","filters"),ne=null,gn=!1;function Wo(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function _n(){if(ne)return ne;if(!Wo())return!gn&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
4
- `),gn=!0),ne=new Map,ne;let t=new Map,e,r;try{e=(await import("smol-toml")).parse,r=(await Zo(hn)).filter(n=>n.endsWith(".toml"))}catch{return ne=t,ne}for(let n of r){let s=await Uo(yn(hn,n),"utf8"),o=e(s).filters;if(o)for(let[a,c]of Object.entries(o)){let u=Le.parse({slug:a,...c});t.set(a,{...u,matchRegex:new RegExp(u.match_command)})}}return ne=t,ne}import{createHash as Go}from"node:crypto";var qo=m.enum(["normal","compact","minimal"]),Yo=m.enum(["off","light","balanced","max"]),Nt=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:qo.default("compact"),reducer:Yo.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),Jo=["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"],Xo=/^[0-9a-f]{16}$/,vn=new Map;function Z(t){let e=vn.get(t);return e||(e=Go("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),vn.set(t,e)),e}var xn=null;function ct(t,e=!1){return e||!t||t.length===0?(xn??=new Set(Jo.map(Z)),new Set(xn)):new Set(t.map(r=>Xo.test(r)?r:Z(r)))}var Fe=new Map,Qo=256,bn=new WeakMap;function ea(t){if(!t)return"*";let e=bn.get(t);return e===void 0&&(e=[...t].join(","),bn.set(t,e)),e}function lt(t,e,r){let n=`${t}::${ea(r)}`,s=Fe.get(n);if(s!==void 0)return s;let i=null;for(let o of e)r&&!r.has(Z(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Fe.size>=Qo){let o=Fe.keys().next().value;o&&Fe.delete(o)}return Fe.set(n,i),i}function En(){Fe.clear()}var ta=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,ra=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function wn(t){return t.replace(ta,"").replace(ra,"")}function kn(t,e){return e.length===0?t:t.filter(r=>!e.some(n=>n.test(r)))}function Sn(t,e){return t.map(r=>r.length<=e?r:`${r.slice(0,e)}\u2026`)}function ut(t){return`\u2026 (${t} more lines omitted)`}function Tn(t,e){if(t.length<=e)return{kept:t,dropped:[]};let r=Math.ceil(e*.7),n=e-r,s=t.slice(r,t.length-n);return{kept:[...t.slice(0,r),ut(s.length),...t.slice(t.length-n)],dropped:s}}var na=/^\s*(?:[✓✔√]|ok )/,He=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/;function An(t,e){let r=e>0?e:5,n=[],s=0,i=a=>{s>=r?n.push(`\u2026 ${s} passing checks folded \u2026`):n.push(...a)},o=[];for(let a of t)na.test(a)&&!He.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,n.push(a));return i(o),n}var sa=/(?:\/[\w.@+-]+){3,}/g;function Rn(t){return t.map(e=>e.replace(sa,r=>{let n=r.split("/").filter(Boolean);return n.length<=2?r:`\u2026/${n.slice(-2).join("/")}`}))}var ia=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,oa=/\{\s*$/;var aa=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,ca=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function la(t){let e=aa.exec(t);return!e||ca.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var ua=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function da(t,e,r){let n=e;for(;n<t.length;){if(t[n]==="\\"){n+=2;continue}if(t[n]===r)return!0;n+=1}return!1}function fa(t,e){let r=0,n=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(n){if(i==="\\"){s+=2;continue}i===n&&(n=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==="&"))&&da(t,s+1,i)&&(n=i),s+=1;continue}i==="{"||i==="("||i==="["?r+=1:(i==="}"||i===")"||i==="]")&&(r-=1),s+=1}return r}var Cn=/^\s*… \d+ lines? folded …$/,pa=/^\s*… (\d+) lines? folded …$/;function Mt(t){let e=new Array(t.length).fill(!1);for(let r=0;r<t.length;r+=1){let n=pa.exec(t[r]);if(!n)continue;let s=Number(n[1])-1,i=r+1;for(;s>0&&i<t.length&&t[i]==="";)e[i]=!0,s-=1,i+=1;r=i-1}return e}function dt(t){let e=[],r=0;for(;r<t.length;){let n=t[r];if(ia.test(n)&&oa.test(n)||la(n)||ua.test(n)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=r,a=!1;for(;o<t.length&&o-r<200;)if(i+=fa(t[o],s),o+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){a=!0;break}let c=o-r;if(a&&c>=3){let u=c-2,l=/^\s*/.exec(t[r+1]??"")?.[0]??" ";e.push(n),e.push(`${l}\u2026 ${u} ${u===1?"line":"lines"} folded \u2026`);for(let d=0;d<u-1;d++)e.push("");e.push(t[o-1]),r=o;continue}}e.push(n),r+=1}return e}var ma=/\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 In(t){let e=t.slice(0,4096);return!(!ma.test(e)||e.split(`
5
- `).length<6)}var ha=/\b(?:DEBUG|TRACE|INFO|VERBOSE)\b/;function $n(t){let e=[],r=0,n=()=>{r>0&&e.push(`\u2026 ${r} verbose log line${r===1?"":"s"} dropped \u2026`),r=0};for(let s of t){if(ha.test(s)){r+=1;continue}n(),e.push(s)}return n(),e}function On(t){if(t.length===0)return t;let e=[],r=1,n=t[0];for(let s=1;s<t.length;s++){if(t[s]===n){r+=1;continue}e.push(r>1?`${n} \xD7${r}`:n),n=t[s],r=1}return e.push(r>1?`${n} \xD7${r}`:n),e}function Pn(t){let e=[],r=0;for(let n of t){if(n.trim()===""){r+=1;continue}r>0&&e.push(""),r=0,e.push(n)}return e}var Dn=new Map;function N(t,e){Dn.set(t,e)}function Nn(t){return Dn.get(t)}var ga=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,ya=/^[./~][^\s]*:$/,Lt=1e3;function _a(t){if(t<1024)return String(t);let e=["K","M","G","T"],r=t/1024,n=0;for(;r>=1024&&n<e.length-1;)r/=1024,n+=1;return`${r.toFixed(1)}${e[n]}`}function va(t){if(!ga.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let r=Number(e[4]);if(!Number.isFinite(r))return null;let n=e.slice(8).join(" ").trim();if(n===""||n==="."||n==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:n,size:r,isDir:s}}function xa(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 r=null,n=0;for(let[s,i]of e)i>n&&(n=i,r=s);return r&&n>=Math.ceil(t.length/2)?`${n} ${r}`:null}function ba(t){let e=[],r=[],n=!1;for(let p of t){if(/^total\s+\d+/.test(p))continue;if(ya.test(p.trim()))return t;let y=va(p);y&&(n=!0,(y.isDir?e:r).push(y))}if(!n)return t;let s=(p,y)=>p.name.localeCompare(y.name);e.sort(s),r.sort((p,y)=>y.size-p.size||s(p,y));let i=[...e,...r],o=Math.min(40,Math.max(0,...i.map(p=>p.isDir?p.name.length+1:p.name.length))),a=[];for(let p of i){let y=p.isDir?`${p.name}/`:p.name,S=p.isDir?"":_a(p.size);a.push(S?`${y.padEnd(o)} ${S}`:y)}if(a.length>Lt){let p=a.length-Lt;a=[...a.slice(0,Lt),`\u2026 ${p} more lines omitted`]}let c=r.length===1?"file":"files",u=e.length===1?"dir":"dirs",l=xa(r),d=`${r.length} ${c}, ${e.length} ${u}`+(l?` (${l})`:"");return a.push(d),a}N("smart-ls",ba);N("smart-read",t=>dt(t));var Mn=1e3;function Ea(t){let e=t.filter(l=>l.trim()!=="");if(e.length===0||e.filter(l=>!/\s/.test(l.trim())).length<e.length*.6)return t;let n=new Map,s=[],i=0;for(let l of e){let d=l.trim();if(d.startsWith("find:")){s.push(d);continue}let p=d.replace(/^\.\//,"").replace(/\/+$/,""),y=p.lastIndexOf("/"),S=y>=0?p.slice(0,y):"",w=y>=0?p.slice(y+1):p;if(!w)continue;let A=n.get(S)??[];A.push(/\s/.test(w)?`"${w}"`:w),n.set(S,A),i+=1}if(i===0)return t;let o=new Set([""]);for(let l of n.keys()){if(l==="")continue;let d=l.split("/");for(let p=1;p<=d.length;p+=1)o.add(d.slice(0,p).join("/"))}let a=[...o].sort(),c=a.filter(l=>l!=="").length,u=[`${i}F ${c}D:`,""];for(let l of a){let d=l===""?0:l.split("/").length,p=l===""?".":l.slice(l.lastIndexOf("/")+1),y=n.get(l)??[],S=y.length?` ${y.join(" ")}`:"";u.push(`${" ".repeat(d)}${p}/${S}`)}if(u.length+s.length>Mn){let l=Math.max(0,Mn-s.length),d=u.length-l;return[...u.slice(0,l),`\u2026 ${d} more lines omitted`,...s]}return[...u,...s]}N("smart-find",Ea);var Ft=1e3,Ln=200,wa=60,ka=190,Sa=/^([^\s:]+):(\d+):(.*)$/,Ta=/^([^:]+?)-(\d+)-(.*)$/,Aa=/^([^\s:]+):(.*)$/,Fn=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;function Bn(t){let e=t.trim();return e.length>Ln?`${e.slice(0,Ln)}\u2026`:e}function Ra(t){let e=[],r="";for(let n of t){let s=r?`${r}, ${n}`:n;s.length>ka&&r?(e.push(`${r},`),r=n):r=s}return r&&e.push(r),e}function Ca(t){let e=t.filter(d=>d.trim()!=="");if(e.length===0)return t;let r=new Map,n=new Map,s=null,i=0,o=0;for(let d of e){if(d==="--"){s&&r.get(s).push({separator:!0});continue}let p=Sa.exec(d),y=p?null:Ta.exec(d),S=p||y?null:Aa.exec(d),w=(p??y??S)?.[1];if(!w)return t;let A=p?{line:p[2],content:p[3],context:!1}:y?{line:y[2],content:y[3],context:!0}:{line:"",content:S[2],context:!1},C=r.get(w)??[];C.push(A),r.set(w,C),A.context||(i+=1,n.set(w,(n.get(w)??0)+1)),o+=1,s=w}if(r.size===o)return t;let a=[...r.keys()].sort((d,p)=>{let y=Fn.test(d)?1:0,S=Fn.test(p)?1:0;return y-S||(d<p?-1:d>p?1:0)}),c=[];for(let d of a){c.push(`${d} (${n.get(d)??0}):`);for(let p of r.get(d))"separator"in p?c.push(" --"):p.line?c.push(` ${p.line}${p.context?"-":":"} ${Bn(p.content)}`):c.push(` ${Bn(p.content)}`)}let u=a.length>1&&c.length>wa?Ra(a.map(d=>`${d} (${n.get(d)??0})`)):[],l=[`${i}m ${a.length}f:`,...u,"",...c];if(l.length>Ft){let d=l.length-Ft;return[...l.slice(0,Ft),`\u2026 ${d} more lines omitted`]}return l}N("smart-grep",Ca);var jn=/^commit [0-9a-f]{7,40}\b/,Ia=/^ {4}/,$a=2;function Oa(t){if(!t.some(i=>jn.test(i)))return t;let e=[],r=0,n=0,s=()=>{n>0&&e.push(` \u2026 ${n} ${n===1?"line":"lines"} folded \u2026`),n=0};for(let i of t){if(jn.test(i)){s(),r=0,e.push(i);continue}if(Ia.test(i)){r+=1,r<=$a?e.push(i):n+=1;continue}s(),e.push(i)}return s(),e}N("smart-log",Oa);var Pa=/^[\s=]+$/,Da=/^\s*=+\s+(.*?)\s+=+\s*$/,Na=512;N("strip-banners",t=>{let e=[];for(let r of t){if(Pa.test(r))continue;let n=r.length<=Na?Da.exec(r):null;e.push(n?n[1]:r)}return e});function Ma(t){let e=[],r=0,n=0;for(;n<t.length;){let s=t[n].replace(/\s+$/,"");if(s===""){r+=1,n+=1,r<=1&&e.push("");continue}r=0;let i=1;for(;n+i<t.length&&t[n+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);n+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}N("squeeze-output",Ma);function La(t){return t==="compact"?.6:t==="minimal"?.3:1}var Fa=20,zn=new WeakMap;function Ba(t){let e=zn.get(t);if(e)return e;let r=t.strip_lines_matching.map(s=>new RegExp(s)),n={def:t,stripRegexes:r};return zn.set(t,n),n}function Zn(t,e,r={}){return Bt(t,e,r).text}function Bt(t,e,r={}){let n=Ba(e),s=t;e.strip_ansi&&(s=wn(s));let i=s.endsWith(`
6
- `),o=(i?s.slice(0,-1):s).split(`
7
- `);n.stripRegexes.length&&(o=e.keep_failures?o.filter(d=>He.test(d)||!n.stripRegexes.some(p=>p.test(d))):kn(o,n.stripRegexes));let a=r.verbosity??"normal";if(a!=="normal"&&!e.preserve_exact&&(o=On(o),o=Pn(o)),a==="minimal"&&!e.preserve_exact&&(o=$n(o)),!e.preserve_exact&&(r.smartCode||r.smartCode===void 0&&a!=="normal"&&In(s))&&(o=dt(o)),e.transform){let d=Nn(e.transform);d&&(o=d(o))}let c=e.slug==="read-tool";if(!c){let d=Mt(o);d.some(Boolean)&&(o=o.filter((p,y)=>!d[y]))}e.mask_abs_paths&&(o=Rn(o)),e.fold_passing&&(o=An(o,e.fold_passing_threshold??5)),e.truncate_lines_at&&(o=Sn(o,e.truncate_lines_at));let u=null;if(e.max_lines){let d=e.scale_with_level?La(r.verbosity):1,p=Math.min(e.max_lines,Math.max(Fa,Math.round(e.max_lines*d))),y=c?Mt(o):null,S=y?y.filter(w=>!w).length:o.length;if(S>p){let w=p;if(y){let C=0;for(w=0;w<o.length&&C<p;)y[w]||(C+=1),w+=1}let A=S-p;if(e.keep_failures){let C=o.slice(w),L=C.filter(U=>!He.test(U));u=L.length>0?L.join(`
8
- `):null,o=[...o.slice(0,w),ut(A),...C.filter(U=>He.test(U))]}else if(c)u=o.slice(w).join(`
9
- `),o=[...o.slice(0,w),ut(A)];else{let{kept:C,dropped:L}=Tn(o,p);u=L.length>0?L.join(`
10
- `):null,o=C}}}let l=o.join(`
11
- `);return i&&l.length>0&&(l+=`
12
- `),l.trim().length===0&&e.on_empty&&(l=e.on_empty),{text:l,droppedTail:u}}var ja=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/thread '.*' panicked/];function Un(t){if(!t)return!1;let e=t.split(`
13
- `),r=e.length<=60?t:[...e.slice(0,30),...e.slice(-30)].join(`
14
- `),n=r.length<=32768*2?[r]:[r.slice(0,32768),r.slice(-32768)];for(let s of ja)for(let i of n)if(s.test(i))return!0;return!1}var za=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Za=/^[A-Za-z_][A-Za-z0-9_]*=/,jt=/^([a-z]+)-tool(?::\s|$)/;function ft(t){let e=t.trim(),r=e.split(/\s+/),n=0;for(;n<r.length;){let a=r[n];if(Za.test(a)){n++;continue}if(za.has(a)){for(n++,a==="timeout"&&n<r.length&&/^\d+(?:\.\d+)?[smhd]?$/.test(r[n])&&n++;(a==="stdbuf"||a==="nice")&&n<r.length&&r[n].startsWith("-");)n++;continue}break}if(n>=r.length)return e;let s=r[n],i=s.includes("/")?s.slice(s.lastIndexOf("/")+1):s,o=r.slice(n+1);return o.length?`${i} ${o.join(" ")}`:i}var Ua=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"]);function Hn(t,e){let r=!1,n=!1,s=0,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="\\"&&!r){o++;continue}a==="'"&&!n?r=!r:a==='"'&&!r?n=!n:!r&&!n&&(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 Ha(t){let e=Hn(t,!1);for(let r=e.length-1;r>=0;r--){let n=e[r].trim();if(n)return n}return t.trim()}function Va(t){let e=Hn(t,!0).map(r=>r.trim()).filter(Boolean);if(e.length===0)return null;for(let r of e.slice(0,-1)){let n=ft(r).split(/\s+/)[0]??"";if(!Ua.has(n))return null}return Ha(e[e.length-1])}function Vn(t){let e=!1,r=!1,n=0,s=[];for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&!e){i++;continue}o==="'"&&!r?e=!e:o==='"'&&!e?r=!r:!e&&!r&&(o==="|"||o===";"?(s.push(t.slice(n,i)),o==="|"&&t[i+1]==="|"&&i++,n=i+1):o==="&"&&t[i+1]==="&"&&(s.push(t.slice(n,i)),i++,n=i+1))}s.push(t.slice(n));for(let i=s.length-1;i>=0;i--){let o=s[i].trim();if(o)return o}return t.trim()}function Kn(t){let e=jt.exec(t),r=t;if(e){if(e[1]!=="bash")return[t];let i=t.indexOf(": ");if(i<0)return[t];r=t.slice(i+2)}let n=Va(r),s=n?ft(n):null;return s&&s!==t?[s,t]:[t]}var Wn=null;function zt(t){Wn=t}async function Ka(t,e){let r=await _n();return lt(t,r.values(),e)}var Wa=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,Ga=2048;async function Gn(t,e,r,n={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,...o}=n,a=ft(Vn(t.startsWith("bash-tool: ")?t.slice(11):t)),c=i!=null&&i!==0&&!(i===1&&Wa.test(a)),u=i==null&&Un(e),l=Wn??Ka,d=null;for(let w of Kn(t))if(d=await l(w,r),d)break;if(!d&&s>=Ga&&!jt.test(t)&&(d=await l(`bash-tool: ${t}`,r)),!d||c&&d.preserve_exact)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:c||u};if(c){let w={...d,keep_failures:!0,transform:void 0,max_lines:void 0,truncate_lines_at:void 0},A=Zn(e,w,{verbosity:"normal",smartCode:!1});return{output:A,filterId:d.slug,rawBytes:s,filteredBytes:Buffer.byteLength(A,"utf8"),debugBypass:!0}}let p=u&&!d.preserve_exact?{...d,keep_failures:!0}:d,{text:y,droppedTail:S}=Bt(e,p,o);return{output:y,filterId:d.slug,rawBytes:s,filteredBytes:Buffer.byteLength(y,"utf8"),debugBypass:!1,droppedTail:S}}import{join as Ya}from"node:path";import{mkdir as sf,readFile as Ja,writeFile as of,unlink as af,rename as cf}from"node:fs/promises";import qa from"node:os";import{join as pt}from"node:path";function T(){return process.env.TOKMIZER_HOME||pt(qa.homedir(),".tokmizer")}function Ve(){return pt(T(),"install-id")}function Zt(){return pt(T(),"content-cache")}function qn(t){return pt(Zt(),t)}var Xa="state.json";function Qa(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function ec(t){return t?.dir??T()}async function Ke(t){let e=ec(t);try{let r=await Ja(Ya(e,Xa),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??Qa(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}function tc(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function Yn(t,e=Date.now()){let r=t.lastHeartbeatOkAt;if(typeof r=="number"&&e-r>tc())return!0;if(t.subEndsAt){let n=Date.parse(t.subEndsAt);if(Number.isFinite(n)&&e>n)return!0}return!1}function Jn(t,e=Date.now()){return t.plan}import{readFile as rc,writeFile as pf,mkdir as mf,chmod as hf,rm as gf,rename as yf}from"node:fs/promises";import{join as nc}from"node:path";var sc="settings-cache.json",Xn=Nt.parse({});async function We(){try{let t=await rc(nc(T(),sc),"utf8"),e=JSON.parse(t);return Nt.parse({...Xn,...e})}catch{return Xn}}var ic=[[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];function Ge(t){let e=t;for(let[r,n]of ic)e=e.replace(r,n);return e}import{join as ns}from"node:path";import{appendFileSync as fc,chmodSync as pc,existsSync as mc,mkdirSync as hc,readFileSync as Ff,renameSync as Bf,rmdirSync as jf,statSync as gc,unlinkSync as zf,utimesSync as Zf,writeFileSync as Uf}from"node:fs";import{createHash as kf,randomUUID as oc}from"node:crypto";import{readFile as Qn,writeFile as es,mkdir as ac}from"node:fs/promises";async function Ut(){try{let r=(await Qn(Ve(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await ac(T(),{recursive:!0});let t=oc();try{return await es(Ve(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await Qn(Ve(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await es(Ve(),t,{mode:384}),t}}import{createRequire as cc}from"node:module";var lc=cc(import.meta.url);function uc(){for(let t of["../package.json","../../package.json"])try{let e=lc(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Ht=uc();var ts=`-----BEGIN PUBLIC KEY-----
3
+ var li=Object.create;var $t=Object.defineProperty;var di=Object.getOwnPropertyDescriptor;var fi=Object.getOwnPropertyNames;var pi=Object.getPrototypeOf,mi=Object.prototype.hasOwnProperty;var ne=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var B=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},hi=(t,e)=>{for(var r in e)$t(t,r,{get:e[r],enumerable:!0})},gi=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of fi(e))!mi.call(t,s)&&s!==r&&$t(t,s,{get:()=>e[s],enumerable:!(n=di(e,s))||n.enumerable});return t};var yi=(t,e,r)=>(r=t!=null?li(pi(t)):{},gi(e||!t||!t.__esModule?$t(r,"default",{value:t,enumerable:!0}):r,t));var Or=B((Nl,$r)=>{$r.exports=Ir;Ir.sync=vi;var Rr=ne("fs");function _i(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var s=r[n].toLowerCase();if(s&&t.substr(-s.length).toLowerCase()===s)return!0}return!1}function Cr(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:_i(e,r)}function Ir(t,e,r){Rr.stat(t,function(n,s){r(n,n?!1:Cr(s,t,e))})}function vi(t,e){return Cr(Rr.statSync(t),t,e)}});var Lr=B((Pl,Mr)=>{Mr.exports=Pr;Pr.sync=bi;var Nr=ne("fs");function Pr(t,e,r){Nr.stat(t,function(n,s){r(n,n?!1:Dr(s,e))})}function bi(t,e){return Dr(Nr.statSync(t),e)}function Dr(t,e){return t.isFile()&&xi(t,e)}function xi(t,e){var r=t.mode,n=t.uid,s=t.gid,i=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),u=parseInt("010",8),c=parseInt("001",8),l=a|u,f=r&c||r&u&&s===o||r&a&&n===i||r&l&&i===0;return f}});var Br=B((Ml,Fr)=>{var Dl=ne("fs"),ft;process.platform==="win32"||global.TESTING_WINDOWS?ft=Or():ft=Lr();Fr.exports=Ot;Ot.sync=Ei;function Ot(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,s){Ot(t,e||{},function(i,o){i?s(i):n(o)})})}ft(t,e||{},function(n,s){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,s=!1),r(n,s)})}function Ei(t,e){try{return ft.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Kr=B((Ll,Vr)=>{var Oe=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",jr=ne("path"),wi=Oe?";":":",zr=Br(),Zr=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Ur=(t,e)=>{let r=e.colon||wi,n=t.match(/\//)||Oe&&t.match(/\\/)?[""]:[...Oe?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],s=Oe?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",i=Oe?s.split(r):[""];return Oe&&t.indexOf(".")!==-1&&i[0]!==""&&i.unshift(""),{pathEnv:n,pathExt:i,pathExtExe:s}},Hr=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:n,pathExt:s,pathExtExe:i}=Ur(t,e),o=[],a=c=>new Promise((l,f)=>{if(c===n.length)return e.all&&o.length?l(o):f(Zr(t));let d=n[c],m=/^".*"$/.test(d)?d.slice(1,-1):d,_=jr.join(m,t),E=!m&&/^\.[\\\/]/.test(t)?t.slice(0,2)+_:_;l(u(E,c,0))}),u=(c,l,f)=>new Promise((d,m)=>{if(f===s.length)return d(a(l+1));let _=s[f];zr(c+_,{pathExt:i},(E,A)=>{if(!E&&A)if(e.all)o.push(c+_);else return d(c+_);return d(u(c,l,f+1))})});return r?a(0).then(c=>r(null,c),r):a(0)},ki=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:n,pathExtExe:s}=Ur(t,e),i=[];for(let o=0;o<r.length;o++){let a=r[o],u=/^".*"$/.test(a)?a.slice(1,-1):a,c=jr.join(u,t),l=!u&&/^\.[\\\/]/.test(t)?t.slice(0,2)+c:c;for(let f=0;f<n.length;f++){let d=l+n[f];try{if(zr.sync(d,{pathExt:s}))if(e.all)i.push(d);else return d}catch{}}}if(e.all&&i.length)return i;if(e.nothrow)return null;throw Zr(t)};Vr.exports=Hr;Hr.sync=ki});var Wr=B((Fl,Nt)=>{"use strict";var Gr=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Nt.exports=Gr;Nt.exports.default=Gr});var Xr=B((Bl,Jr)=>{"use strict";var qr=ne("path"),Si=Kr(),Ti=Wr();function Yr(t,e){let r=t.options.env||process.env,n=process.cwd(),s=t.options.cwd!=null,i=s&&process.chdir!==void 0&&!process.chdir.disabled;if(i)try{process.chdir(t.options.cwd)}catch{}let o;try{o=Si.sync(t.command,{path:r[Ti({env:r})],pathExt:e?qr.delimiter:void 0})}catch{}finally{i&&process.chdir(n)}return o&&(o=qr.resolve(s?t.options.cwd:"",o)),o}function Ai(t){return Yr(t)||Yr(t,!0)}Jr.exports=Ai});var Qr=B((jl,Dt)=>{"use strict";var Pt=/([()\][%!^"`<>&|;, *?])/g;function Ri(t){return t=t.replace(Pt,"^$1"),t}function Ci(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Pt,"^$1"),e&&(t=t.replace(Pt,"^$1")),t}Dt.exports.command=Ri;Dt.exports.argument=Ci});var tn=B((zl,en)=>{"use strict";en.exports=/^#!(.*)/});var nn=B((Zl,rn)=>{"use strict";var Ii=tn();rn.exports=(t="")=>{let e=t.match(Ii);if(!e)return null;let[r,n]=e[0].replace(/#! ?/,"").split(" "),s=r.split("/").pop();return s==="env"?n:n?`${s} ${n}`:s}});var on=B((Ul,sn)=>{"use strict";var Mt=ne("fs"),$i=nn();function Oi(t){let r=Buffer.alloc(150),n;try{n=Mt.openSync(t,"r"),Mt.readSync(n,r,0,150,0),Mt.closeSync(n)}catch{}return $i(r.toString())}sn.exports=Oi});var ln=B((Hl,un)=>{"use strict";var Ni=ne("path"),an=Xr(),cn=Qr(),Pi=on(),Di=process.platform==="win32",Mi=/\.(?:com|exe)$/i,Li=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Fi(t){t.file=an(t);let e=t.file&&Pi(t.file);return e?(t.args.unshift(t.file),t.command=e,an(t)):t.file}function Bi(t){if(!Di)return t;let e=Fi(t),r=!Mi.test(e);if(t.options.forceShell||r){let n=Li.test(e);t.command=Ni.normalize(t.command),t.command=cn.command(t.command),t.args=t.args.map(i=>cn.argument(i,n));let s=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${s}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function ji(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let n={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?n:Bi(n)}un.exports=ji});var pn=B((Vl,fn)=>{"use strict";var Lt=process.platform==="win32";function Ft(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function zi(t,e){if(!Lt)return;let r=t.emit;t.emit=function(n,s){if(n==="exit"){let i=dn(s,e);if(i)return r.call(t,"error",i)}return r.apply(t,arguments)}}function dn(t,e){return Lt&&t===1&&!e.file?Ft(e.original,"spawn"):null}function Zi(t,e){return Lt&&t===1&&!e.file?Ft(e.original,"spawnSync"):null}fn.exports={hookChildProcess:zi,verifyENOENT:dn,verifyENOENTSync:Zi,notFoundError:Ft}});var gn=B((Kl,Ne)=>{"use strict";var mn=ne("child_process"),Bt=ln(),jt=pn();function hn(t,e,r){let n=Bt(t,e,r),s=mn.spawn(n.command,n.args,n.options);return jt.hookChildProcess(s,n),s}function Ui(t,e,r){let n=Bt(t,e,r),s=mn.spawnSync(n.command,n.args,n.options);return s.error=s.error||jt.verifyENOENTSync(s.status,n),s}Ne.exports=hn;Ne.exports.spawn=hn;Ne.exports.sync=Ui;Ne.exports._parse=Bt;Ne.exports._enoent=jt});var si=yi(gn(),1);import{readdir as ta,readFile as ra}from"node:fs/promises";import{join as In,dirname as na}from"node:path";import{fileURLToPath as sa}from"node:url";var h={};hi(h,{BRAND:()=>go,DIRTY:()=>me,EMPTY_PATH:()=>Gi,INVALID:()=>b,NEVER:()=>ea,OK:()=>O,ParseStatus:()=>$,Schema:()=>k,ZodAny:()=>oe,ZodArray:()=>te,ZodBigInt:()=>ge,ZodBoolean:()=>ye,ZodBranded:()=>Je,ZodCatch:()=>Re,ZodDate:()=>_e,ZodDefault:()=>Ae,ZodDiscriminatedUnion:()=>ht,ZodEffects:()=>Z,ZodEnum:()=>Se,ZodError:()=>M,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>yt,ZodIntersection:()=>Ee,ZodIssueCode:()=>p,ZodLazy:()=>we,ZodLiteral:()=>ke,ZodMap:()=>Be,ZodNaN:()=>ze,ZodNativeEnum:()=>Te,ZodNever:()=>K,ZodNull:()=>be,ZodNullable:()=>Y,ZodNumber:()=>he,ZodObject:()=>L,ZodOptional:()=>j,ZodParsedType:()=>y,ZodPipeline:()=>Xe,ZodPromise:()=>ae,ZodReadonly:()=>Ce,ZodRecord:()=>gt,ZodSchema:()=>k,ZodSet:()=>je,ZodString:()=>ie,ZodSymbol:()=>Le,ZodTransformer:()=>Z,ZodTuple:()=>q,ZodType:()=>k,ZodUndefined:()=>ve,ZodUnion:()=>xe,ZodUnknown:()=>ee,ZodVoid:()=>Fe,addIssueToContext:()=>g,any:()=>So,array:()=>Co,bigint:()=>bo,boolean:()=>An,coerce:()=>Qo,custom:()=>kn,date:()=>xo,datetimeRegex:()=>En,defaultErrorMap:()=>X,discriminatedUnion:()=>No,effect:()=>Vo,enum:()=>Zo,function:()=>Bo,getErrorMap:()=>Pe,getParsedType:()=>W,instanceof:()=>_o,intersection:()=>Po,isAborted:()=>pt,isAsync:()=>De,isDirty:()=>mt,isValid:()=>se,late:()=>yo,lazy:()=>jo,literal:()=>zo,makeIssue:()=>Ye,map:()=>Lo,nan:()=>vo,nativeEnum:()=>Uo,never:()=>Ao,null:()=>ko,nullable:()=>Go,number:()=>Tn,object:()=>Io,objectUtil:()=>zt,oboolean:()=>Xo,onumber:()=>Jo,optional:()=>Ko,ostring:()=>Yo,pipeline:()=>qo,preprocess:()=>Wo,promise:()=>Ho,quotelessJson:()=>Hi,record:()=>Mo,set:()=>Fo,setErrorMap:()=>Ki,strictObject:()=>$o,string:()=>Sn,symbol:()=>Eo,transformer:()=>Vo,tuple:()=>Do,undefined:()=>wo,union:()=>Oo,unknown:()=>To,util:()=>S,void:()=>Ro});var S;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,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 n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(S||(S={}));var zt;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(zt||(zt={}));var y=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),W=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}};var p=S.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Hi=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),M=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_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)n._errors.push(r(o));else{let a=n,u=0;for(;u<o.path.length;){let c=o.path[u];u===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(o))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};M.create=t=>new M(t);var Vi=(t,e)=>{let r;switch(t.code){case p.invalid_type:t.received===y.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case p.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:r=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case p.invalid_union:r="Invalid input";break;case p.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case p.invalid_enum_value:r=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case p.invalid_arguments:r="Invalid function arguments";break;case p.invalid_return_type:r="Invalid function return type";break;case p.invalid_date:r="Invalid date";break;case p.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:S.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case p.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case p.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case p.custom:r="Invalid input";break;case p.invalid_intersection_types:r="Intersection results could not be merged";break;case p.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case p.not_finite:r="Number must be finite";break;default:r=e.defaultError,S.assertNever(t)}return{message:r}},X=Vi;var yn=X;function Ki(t){yn=t}function Pe(){return yn}var Ye=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)a=c(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},Gi=[];function g(t,e){let r=Pe(),n=Ye({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===X?void 0:X].filter(s=>!!s)});t.common.issues.push(n)}var $=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return b;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let i=await s.key,o=await s.value;n.push({key:i,value:o})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return b;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}},b=Object.freeze({status:"aborted"}),me=t=>({status:"dirty",value:t}),O=t=>({status:"valid",value:t}),pt=t=>t.status==="aborted",mt=t=>t.status==="dirty",se=t=>t.status==="valid",De=t=>typeof Promise<"u"&&t instanceof Promise;var v;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(v||(v={}));var z=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,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}},_n=(t,e)=>{if(se(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 r=new M(t.common.issues);return this._error=r,this._error}}};function w(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))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:u}=t;return o.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:u??r??a.defaultError}},description:s}}var k=class{get description(){return this._def.description}_getType(e){return W(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:W(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:W(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(De(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:W(e)},s=this._parseSync({data:e,path:n.path,parent:n});return _n(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:W(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return se(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>se(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:W(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(De(s)?s:Promise.resolve(s));return _n(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:p.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Z({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return j.create(this,this._def)}nullable(){return Y.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return te.create(this)}promise(){return ae.create(this,this._def)}or(e){return xe.create([this,e],this._def)}and(e){return Ee.create(this,e,this._def)}transform(e){return new Z({...w(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ae({...w(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new Je({typeName:x.ZodBranded,type:this,...w(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Re({...w(this._def),innerType:this,catchValue:r,typeName:x.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Xe.create(this,e)}readonly(){return Ce.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Wi=/^c[^\s-]{8,}$/i,qi=/^[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,Xi=/^[a-z0-9_-]{21}$/i,Qi=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,eo=/^[-+]?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)?)??$/,to=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ro="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Zt,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])$/,so=/^(?:(?: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])$/,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]))$/,oo=/^(([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])$/,ao=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,co=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bn="((\\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])))",uo=new RegExp(`^${bn}$`);function xn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function lo(t){return new RegExp(`^${xn(t)}$`)}function En(t){let e=`${bn}T${xn(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function fo(t,e){return!!((e==="v4"||!e)&&no.test(t)||(e==="v6"||!e)&&io.test(t))}function po(t,e){if(!Qi.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function mo(t,e){return!!((e==="v4"||!e)&&so.test(t)||(e==="v6"||!e)&&oo.test(t))}var ie=class t extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let i=this._getOrReturnCtx(e);return g(i,{code:p.invalid_type,expected:y.string,received:i.parsedType}),b}let n=new $,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?g(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&g(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")to.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"email",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Zt||(Zt=new RegExp(ro,"u")),Zt.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"emoji",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Ji.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"uuid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Xi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"nanoid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Wi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")qi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid2",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Yi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ulid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),g(s,{validation:"url",code:p.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"regex",code:p.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?En(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?uo.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?lo(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?eo.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"duration",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?fo(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ip",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?po(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"jwt",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?mo(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cidr",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?ao.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?co.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64url",code:p.invalid_string,message:i.message}),n.dirty()):S.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:p.invalid_string,...v.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...v.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...v.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...v.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...v.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...v.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...v.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...v.errToObj(r)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ie.create=t=>new ie({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...w(t)});function ho(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var he=class t extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){let i=this._getOrReturnCtx(e);return g(i,{code:p.invalid_type,expected:y.number,received:i.parsedType}),b}let n,s=new $;for(let i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{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)&&(n=this._getOrReturnCtx(e,n),g(n,{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)&&(n=this._getOrReturnCtx(e,n),g(n,{code:p.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?ho(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),g(n,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{code:p.not_finite,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,v.toString(r))}gt(e,r){return this.setLimit("min",e,!1,v.toString(r))}lte(e,r){return this.setLimit("max",e,!0,v.toString(r))}lt(e,r){return this.setLimit("max",e,!1,v.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:v.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};he.create=t=>new he({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...w(t)});var ge=class t extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let n,s=new $;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),g(n,{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)&&(n=this._getOrReturnCtx(e,n),g(n,{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)&&(n=this._getOrReturnCtx(e,n),g(n,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return g(r,{code:p.invalid_type,expected:y.bigint,received:r.parsedType}),b}gte(e,r){return this.setLimit("min",e,!0,v.toString(r))}gt(e,r){return this.setLimit("min",e,!1,v.toString(r))}lte(e,r){return this.setLimit("max",e,!0,v.toString(r))}lt(e,r){return this.setLimit("max",e,!1,v.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:v.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ge.create=t=>new ge({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...w(t)});var ye=class extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.boolean,received:n.parsedType}),b}return O(e.data)}};ye.create=t=>new ye({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...w(t)});var _e=class t extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let i=this._getOrReturnCtx(e);return g(i,{code:p.invalid_type,expected:y.date,received:i.parsedType}),b}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return g(i,{code:p.invalid_date}),b}let n=new $,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:p.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:p.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):S.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};_e.create=t=>new _e({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...w(t)});var Le=class extends k{_parse(e){if(this._getType(e)!==y.symbol){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.symbol,received:n.parsedType}),b}return O(e.data)}};Le.create=t=>new Le({typeName:x.ZodSymbol,...w(t)});var ve=class extends k{_parse(e){if(this._getType(e)!==y.undefined){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.undefined,received:n.parsedType}),b}return O(e.data)}};ve.create=t=>new ve({typeName:x.ZodUndefined,...w(t)});var be=class extends k{_parse(e){if(this._getType(e)!==y.null){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.null,received:n.parsedType}),b}return O(e.data)}};be.create=t=>new be({typeName:x.ZodNull,...w(t)});var oe=class extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}};oe.create=t=>new oe({typeName:x.ZodAny,...w(t)});var ee=class extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}};ee.create=t=>new ee({typeName:x.ZodUnknown,...w(t)});var K=class extends k{_parse(e){let r=this._getOrReturnCtx(e);return g(r,{code:p.invalid_type,expected:y.never,received:r.parsedType}),b}};K.create=t=>new K({typeName:x.ZodNever,...w(t)});var Fe=class extends k{_parse(e){if(this._getType(e)!==y.undefined){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.void,received:n.parsedType}),b}return O(e.data)}};Fe.create=t=>new Fe({typeName:x.ZodVoid,...w(t)});var te=class t extends k{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==y.array)return g(r,{code:p.invalid_type,expected:y.array,received:r.parsedType}),b;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(o||a)&&(g(r,{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}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(g(r,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(g(r,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>s.type._parseAsync(new z(r,o,r.path,a)))).then(o=>$.mergeArray(n,o));let i=[...r.data].map((o,a)=>s.type._parseSync(new z(r,o,r.path,a)));return $.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:v.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:v.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:v.toString(r)}})}nonempty(e){return this.min(1,e)}};te.create=(t,e)=>new te({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...w(e)});function Me(t){if(t instanceof L){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=j.create(Me(n))}return new L({...t._def,shape:()=>e})}else return t instanceof te?new te({...t._def,type:Me(t.element)}):t instanceof j?j.create(Me(t.unwrap())):t instanceof Y?Y.create(Me(t.unwrap())):t instanceof q?q.create(t.items.map(e=>Me(e))):t}var L=class t extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=S.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==y.object){let c=this._getOrReturnCtx(e);return g(c,{code:p.invalid_type,expected:y.object,received:c.parsedType}),b}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof K&&this._def.unknownKeys==="strip"))for(let c in s.data)o.includes(c)||a.push(c);let u=[];for(let c of o){let l=i[c],f=s.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new z(s,f,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof K){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of a)u.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")a.length>0&&(g(s,{code:p.unrecognized_keys,keys:a}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of a){let f=s.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new z(s,f,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of u){let f=await l.key,d=await l.value;c.push({key:f,value:d,alwaysSet:l.alwaysSet})}return c}).then(c=>$.mergeObjectSync(n,c)):$.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:v.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of S.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of S.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Me(this)}partial(e){let r={};for(let n of S.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of S.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof j;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return wn(S.objectKeys(this.shape))}};L.create=(t,e)=>new L({shape:()=>t,unknownKeys:"strip",catchall:K.create(),typeName:x.ZodObject,...w(e)});L.strictCreate=(t,e)=>new L({shape:()=>t,unknownKeys:"strict",catchall:K.create(),typeName:x.ZodObject,...w(e)});L.lazycreate=(t,e)=>new L({shape:t,unknownKeys:"strip",catchall:K.create(),typeName:x.ZodObject,...w(e)});var xe=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=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 r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new M(a.ctx.common.issues));return g(r,{code:p.invalid_union,unionErrors:o}),b}if(r.common.async)return Promise.all(n.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let u of n){let c={...r,common:{...r.common,issues:[]},parent:null},l=u._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(u=>new M(u));return g(r,{code:p.invalid_union,unionErrors:a}),b}}get options(){return this._def.options}};xe.create=(t,e)=>new xe({options:t,typeName:x.ZodUnion,...w(e)});var Q=t=>t instanceof we?Q(t.schema):t instanceof Z?Q(t.innerType()):t instanceof ke?[t.value]:t instanceof Se?t.options:t instanceof Te?S.objectValues(t.enum):t instanceof Ae?Q(t._def.innerType):t instanceof ve?[void 0]:t instanceof be?[null]:t instanceof j?[void 0,...Q(t.unwrap())]:t instanceof Y?[null,...Q(t.unwrap())]:t instanceof Je||t instanceof Ce?Q(t.unwrap()):t instanceof Re?Q(t._def.innerType):[],ht=class t extends k{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return g(r,{code:p.invalid_type,expected:y.object,received:r.parsedType}),b;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(g(r,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),b)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let o=Q(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...w(n)})}};function Ut(t,e){let r=W(t),n=W(e);if(t===e)return{valid:!0,data:t};if(r===y.object&&n===y.object){let s=S.objectKeys(e),i=S.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let u=Ut(t[a],e[a]);if(!u.valid)return{valid:!1};o[a]=u.data}return{valid:!0,data:o}}else if(r===y.array&&n===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],u=Ut(o,a);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return r===y.date&&n===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Ee=class extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,o)=>{if(pt(i)||pt(o))return b;let a=Ut(i.value,o.value);return a.valid?((mt(i)||mt(o))&&r.dirty(),{status:r.value,value:a.data}):(g(n,{code:p.invalid_intersection_types}),b)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ee.create=(t,e,r)=>new Ee({left:t,right:e,typeName:x.ZodIntersection,...w(r)});var q=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.array)return g(n,{code:p.invalid_type,expected:y.array,received:n.parsedType}),b;if(n.data.length<this._def.items.length)return g(n,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;!this._def.rest&&n.data.length>this._def.items.length&&(g(n,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new z(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>$.mergeArray(r,o)):$.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};q.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new q({items:t,typeName:x.ZodTuple,rest:null,...w(e)})};var gt=class t extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return g(n,{code:p.invalid_type,expected:y.object,received:n.parsedType}),b;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:i._parse(new z(n,a,n.path,a)),value:o._parse(new z(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?$.mergeObjectAsync(r,s):$.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof k?new t({keyType:e,valueType:r,typeName:x.ZodRecord,...w(n)}):new t({keyType:ie.create(),valueType:e,typeName:x.ZodRecord,...w(r)})}},Be=class extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.map)return g(n,{code:p.invalid_type,expected:y.map,received:n.parsedType}),b;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,u],c)=>({key:s._parse(new z(n,a,n.path,[c,"key"])),value:i._parse(new z(n,u,n.path,[c,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of o){let c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return b;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let u of o){let c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return b;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}}}};Be.create=(t,e,r)=>new Be({valueType:e,keyType:t,typeName:x.ZodMap,...w(r)});var je=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.set)return g(n,{code:p.invalid_type,expected:y.set,received:n.parsedType}),b;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(g(n,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(g(n,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(u){let c=new Set;for(let l of u){if(l.status==="aborted")return b;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let a=[...n.data.values()].map((u,c)=>i._parse(new z(n,u,n.path,c)));return n.common.async?Promise.all(a).then(u=>o(u)):o(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:v.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:v.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};je.create=(t,e)=>new je({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...w(e)});var yt=class t extends k{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==y.function)return g(r,{code:p.invalid_type,expected:y.function,received:r.parsedType}),b;function n(a,u){return Ye({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Pe(),X].filter(c=>!!c),issueData:{code:p.invalid_arguments,argumentsError:u}})}function s(a,u){return Ye({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Pe(),X].filter(c=>!!c),issueData:{code:p.invalid_return_type,returnTypeError:u}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof ae){let a=this;return O(async function(...u){let c=new M([]),l=await a._def.args.parseAsync(u,i).catch(m=>{throw c.addIssue(n(u,m)),c}),f=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(f,i).catch(m=>{throw c.addIssue(s(f,m)),c})})}else{let a=this;return O(function(...u){let c=a._def.args.safeParse(u,i);if(!c.success)throw new M([n(u,c.error)]);let l=Reflect.apply(o,this,c.data),f=a._def.returns.safeParse(l,i);if(!f.success)throw new M([s(l,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:q.create(e).rest(ee.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,r,n){return new t({args:e||q.create([]).rest(ee.create()),returns:r||ee.create(),typeName:x.ZodFunction,...w(n)})}},we=class extends k{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};we.create=(t,e)=>new we({getter:t,typeName:x.ZodLazy,...w(e)});var ke=class extends k{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return g(r,{received:r.data,code:p.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:e.data}}get value(){return this._def.value}};ke.create=(t,e)=>new ke({value:t,typeName:x.ZodLiteral,...w(e)});function wn(t,e){return new Se({values:t,typeName:x.ZodEnum,...w(e)})}var Se=class t extends k{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return g(r,{expected:S.joinValues(n),received:r.parsedType,code:p.invalid_type}),b}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return g(r,{received:r.data,code:p.invalid_enum_value,options:n}),b}return O(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Se.create=wn;var Te=class extends k{_parse(e){let r=S.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==y.string&&n.parsedType!==y.number){let s=S.objectValues(r);return g(n,{expected:S.joinValues(s),received:n.parsedType,code:p.invalid_type}),b}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=S.objectValues(r);return g(n,{received:n.data,code:p.invalid_enum_value,options:s}),b}return O(e.data)}get enum(){return this._def.values}};Te.create=(t,e)=>new Te({values:t,typeName:x.ZodNativeEnum,...w(e)});var ae=class extends k{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==y.promise&&r.common.async===!1)return g(r,{code:p.invalid_type,expected:y.promise,received:r.parsedType}),b;let n=r.parsedType===y.promise?r.data:Promise.resolve(r.data);return O(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ae.create=(t,e)=>new ae({type:t,typeName:x.ZodPromise,...w(e)});var Z=class extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{g(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return b;let u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?b:u.status==="dirty"?me(u.value):r.value==="dirty"?me(u.value):u});{if(r.value==="aborted")return b;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?b:a.status==="dirty"?me(a.value):r.value==="dirty"?me(a.value):a}}if(s.type==="refinement"){let o=a=>{let u=s.refinement(a,i);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?b:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?b:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!se(o))return b;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:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>se(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:r.value,value:a})):b);S.assertNever(s)}};Z.create=(t,e,r)=>new Z({schema:t,typeName:x.ZodEffects,effect:e,...w(r)});Z.createWithPreprocess=(t,e,r)=>new Z({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...w(r)});var j=class extends k{_parse(e){return this._getType(e)===y.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};j.create=(t,e)=>new j({innerType:t,typeName:x.ZodOptional,...w(e)});var Y=class extends k{_parse(e){return this._getType(e)===y.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Y.create=(t,e)=>new Y({innerType:t,typeName:x.ZodNullable,...w(e)});var Ae=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ae.create=(t,e)=>new Ae({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...w(e)});var Re=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return De(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Re.create=(t,e)=>new Re({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...w(e)});var ze=class extends k{_parse(e){if(this._getType(e)!==y.nan){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.nan,received:n.parsedType}),b}return{status:"valid",value:e.data}}};ze.create=t=>new ze({typeName:x.ZodNaN,...w(t)});var go=Symbol("zod_brand"),Je=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Xe=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?b:i.status==="dirty"?(r.dirty(),me(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?b:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:x.ZodPipeline})}},Ce=class extends k{_parse(e){let r=this._def.innerType._parse(e),n=s=>(se(s)&&(s.value=Object.freeze(s.value)),s);return De(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};Ce.create=(t,e)=>new Ce({innerType:t,typeName:x.ZodReadonly,...w(e)});function vn(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function kn(t,e={},r){return t?oe.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(o=>{if(!o){let a=vn(e,n),u=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:u})}});if(!i){let o=vn(e,n),a=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:a})}}):oe.create()}var yo={object:L.lazycreate},x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));var _o=(t,e={message:`Input not instance of ${t.name}`})=>kn(r=>r instanceof t,e),Sn=ie.create,Tn=he.create,vo=ze.create,bo=ge.create,An=ye.create,xo=_e.create,Eo=Le.create,wo=ve.create,ko=be.create,So=oe.create,To=ee.create,Ao=K.create,Ro=Fe.create,Co=te.create,Io=L.create,$o=L.strictCreate,Oo=xe.create,No=ht.create,Po=Ee.create,Do=q.create,Mo=gt.create,Lo=Be.create,Fo=je.create,Bo=yt.create,jo=we.create,zo=ke.create,Zo=Se.create,Uo=Te.create,Ho=ae.create,Vo=Z.create,Ko=j.create,Go=Y.create,Wo=Z.createWithPreprocess,qo=Xe.create,Yo=()=>Sn().optional(),Jo=()=>Tn().optional(),Xo=()=>An().optional(),Qo={string:(t=>ie.create({...t,coerce:!0})),number:(t=>he.create({...t,coerce:!0})),boolean:(t=>ye.create({...t,coerce:!0})),bigint:(t=>ge.create({...t,coerce:!0})),date:(t=>_e.create({...t,coerce:!0}))};var ea=b;var Ze=h.object({slug:h.string().min(1).max(64),description:h.string().max(255).optional(),match_command:h.string().min(1),priority:h.number().int().default(50),strip_ansi:h.boolean().default(!1),strip_lines_matching:h.array(h.string()).default([]),keep_failures:h.boolean().default(!1),fold_passing:h.boolean().default(!1),fold_passing_threshold:h.number().int().positive().max(1e3).optional(),mask_abs_paths:h.boolean().default(!1),preserve_exact:h.boolean().default(!1),truncate_lines_at:h.number().int().positive().max(1e4).optional(),max_lines:h.number().int().positive().max(1e5).optional(),scale_with_level:h.boolean().default(!0),transform:h.string().max(64).optional(),on_empty:h.string().max(255).optional()});var ia=na(sa(import.meta.url)),Rn=process.env.TOKMIZER_FILTERS_DIR||In(ia,"..","..","filters"),ce=null,Cn=!1;function oa(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function $n(){if(ce)return ce;if(!oa())return!Cn&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
4
+ `),Cn=!0),ce=new Map,ce;let t=new Map,e,r;try{e=(await import("smol-toml")).parse,r=(await ta(Rn)).filter(n=>n.endsWith(".toml"))}catch{return ce=t,ce}for(let n of r){let s=await ra(In(Rn,n),"utf8"),o=e(s).filters;if(o)for(let[a,u]of Object.entries(o)){let c=Ze.parse({slug:a,...u});t.set(a,{...c,matchRegex:new RegExp(c.match_command)})}}return ce=t,ce}import{createHash as aa}from"node:crypto";var ca=h.enum(["normal","compact","minimal"]),ua=h.enum(["off","light","balanced","max"]),Qe=h.object({enabled:h.boolean().default(!0),telemetryOptIn:h.boolean().default(!0),outputVerbosity:ca.default("compact"),reducer:ua.default("off"),filters:h.object({enableAll:h.boolean().default(!0),disabled:h.array(h.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),la=["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"],da=/^[0-9a-f]{16}$/,On=new Map;function G(t){let e=On.get(t);return e||(e=aa("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),On.set(t,e)),e}var Nn=null;function _t(t,e=!1){return e||!t||t.length===0?(Nn??=new Set(la.map(G)),new Set(Nn)):new Set(t.map(r=>da.test(r)?r:G(r)))}var Ue=new Map,fa=256,Pn=new WeakMap;function pa(t){if(!t)return"*";let e=Pn.get(t);return e===void 0&&(e=[...t].join(","),Pn.set(t,e)),e}function vt(t,e,r){let n=`${t}::${pa(r)}`,s=Ue.get(n);if(s!==void 0)return s;let i=null;for(let o of e)r&&!r.has(G(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Ue.size>=fa){let o=Ue.keys().next().value;o&&Ue.delete(o)}return Ue.set(n,i),i}function Dn(){Ue.clear()}var ma=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,ha=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function Ie(t){return t.replace(ma,"").replace(ha,"")}function Mn(t,e){return e.length===0?t:t.filter(r=>!e.some(n=>n.test(r)))}function Ln(t,e){return t.map(r=>{if(r.length<=e)return r;let n=r.charCodeAt(e-1),s=r.charCodeAt(e),i=n>=55296&&n<=56319&&s>=56320&&s<=57343?e-1:e;return`${r.slice(0,i)}\u2026`})}function bt(t){return`\u2026 (${t} more lines omitted)`}function Fn(t,e){if(t.length<=e)return{kept:t,dropped:[]};let r=Math.ceil(e*.7),n=e-r,s=t.slice(r,t.length-n);return{kept:[...t.slice(0,r),bt(s.length),...t.slice(t.length-n)],dropped:s}}var ga=/^\s*(?:[✓✔√]|ok )/,ue=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/;function Bn(t,e){let r=e>0?e:5,n=[],s=0,i=a=>{s>=r?n.push(`\u2026 ${s} passing checks folded \u2026`):n.push(...a)},o=[];for(let a of t)ga.test(a)&&!ue.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,n.push(a));return i(o),n}var ya=/(?:\/[\w.@+-]+){3,}/g;function jn(t){return t.map(e=>e.replace(ya,r=>{let n=r.split("/").filter(Boolean);return n.length<=2?r:`\u2026/${n.slice(-2).join("/")}`}))}var _a=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,va=/\{\s*$/;var ba=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,xa=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function Ea(t){let e=ba.exec(t);return!e||xa.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var wa=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function ka(t,e,r){let n=e;for(;n<t.length;){if(t[n]==="\\"){n+=2;continue}if(t[n]===r)return!0;n+=1}return!1}function Sa(t,e){let r=0,n=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(n){if(i==="\\"){s+=2;continue}i===n&&(n=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==="&"))&&ka(t,s+1,i)&&(n=i),s+=1;continue}i==="{"||i==="("||i==="["?r+=1:(i==="}"||i===")"||i==="]")&&(r-=1),s+=1}return r}var zn=/^\s*… \d+ lines? folded …$/,Ta=/^\s*… (\d+) lines? folded …$/;function Ht(t){let e=new Array(t.length).fill(!1);for(let r=0;r<t.length;r+=1){let n=Ta.exec(t[r]);if(!n)continue;let s=Number(n[1])-1,i=r+1;for(;s>0&&i<t.length&&t[i]==="";)e[i]=!0,s-=1,i+=1;r=i-1}return e}function xt(t){let e=[],r=0;for(;r<t.length;){let n=t[r];if(_a.test(n)&&va.test(n)||Ea(n)||wa.test(n)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=r,a=!1;for(;o<t.length&&o-r<200;)if(i+=Sa(t[o],s),o+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){a=!0;break}let u=o-r;if(a&&u>=3){let c=u-2,l=/^\s*/.exec(t[r+1]??"")?.[0]??" ";e.push(n),e.push(`${l}\u2026 ${c} ${c===1?"line":"lines"} folded \u2026`);for(let f=0;f<c-1;f++)e.push("");e.push(t[o-1]),r=o;continue}}e.push(n),r+=1}return e}var Aa=/\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 Et(t){let e=t.slice(0,4096);return!(!Aa.test(e)||e.split(`
5
+ `).length<6)}var Ra=/^\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*/,Ca=/^\s*(?:\[(?:DEBUG|TRACE|INFO|VERBOSE)\]|(?:DEBUG|TRACE|INFO|VERBOSE)(?!\s*:))(?=\s|:|$)(?!\s*[+\-*\/%&|^?]*=)/,Ia=new RegExp(ue.source,"i"),$a=/\bWARN(?:ING)?\b/i;function Zn(t){let e=[],r=0,n=()=>{r>0&&e.push(`\u2026 ${r} verbose log line${r===1?"":"s"} dropped \u2026`),r=0};for(let s of t){if(Ca.test(s.replace(Ra,""))&&!Ia.test(s)&&!$a.test(s)){r+=1;continue}n(),e.push(s)}return n(),e}function Un(t){if(t.length===0)return t;let e=[],r=1,n=t[0];for(let s=1;s<t.length;s++){if(t[s]===n){r+=1;continue}e.push(r>1?`${n} \xD7${r}`:n),n=t[s],r=1}return e.push(r>1?`${n} \xD7${r}`:n),e}function Hn(t){let e=[],r=0;for(let n of t){if(n.trim()===""){r+=1;continue}r>0&&e.push(""),r=0,e.push(n)}return e}var Vn=new Map;function F(t,e){Vn.set(t,e)}function Kn(t){return Vn.get(t)}var Oa=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,Na=/^[./~][^\s]*:$/,Vt=1e3;function Pa(t){if(t<1024)return String(t);let e=["K","M","G","T"],r=t/1024,n=0;for(;r>=1024&&n<e.length-1;)r/=1024,n+=1;return`${r.toFixed(1)}${e[n]}`}function Da(t){if(!Oa.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let r=Number(e[4]);if(!Number.isFinite(r))return null;let n=e.slice(8).join(" ").trim();if(n===""||n==="."||n==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:n,size:r,isDir:s}}function Ma(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 r=null,n=0;for(let[s,i]of e)i>n&&(n=i,r=s);return r&&n>=Math.ceil(t.length/2)?`${n} ${r}`:null}function La(t){let e=[],r=[],n=!1;for(let d of t){if(/^total\s+\d+/.test(d))continue;if(Na.test(d.trim()))return t;let m=Da(d);m&&(n=!0,(m.isDir?e:r).push(m))}if(!n)return t;let s=(d,m)=>d.name.localeCompare(m.name);e.sort(s),r.sort((d,m)=>m.size-d.size||s(d,m));let i=[...e,...r],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 m=d.isDir?`${d.name}/`:d.name,_=d.isDir?"":Pa(d.size);a.push(_?`${m.padEnd(o)} ${_}`:m)}if(a.length>Vt){let d=a.length-Vt;a=[...a.slice(0,Vt),`\u2026 ${d} more lines omitted`]}let u=r.length===1?"file":"files",c=e.length===1?"dir":"dirs",l=Ma(r),f=`${r.length} ${u}, ${e.length} ${c}`+(l?` (${l})`:"");return a.push(f),a}F("smart-ls",La);F("smart-read",t=>xt(t));var Gn=1e3;function Fa(t){let e=t.filter(l=>l.trim()!=="");if(e.length===0||e.filter(l=>!/\s/.test(l.trim())).length<e.length*.6)return t;let n=new Map,s=[],i=0;for(let l of e){let f=l.trim();if(f.startsWith("find:")){s.push(f);continue}let d=f.replace(/^\.\//,"").replace(/\/+$/,""),m=d.lastIndexOf("/"),_=m>=0?d.slice(0,m):"",E=m>=0?d.slice(m+1):d;if(!E)continue;let A=n.get(_)??[];A.push(/\s/.test(E)?`"${E}"`:E),n.set(_,A),i+=1}if(i===0)return t;let o=new Set([""]);for(let l of n.keys()){if(l==="")continue;let f=l.split("/");for(let d=1;d<=f.length;d+=1)o.add(f.slice(0,d).join("/"))}let a=[...o].sort(),u=a.filter(l=>l!=="").length,c=[`${i}F ${u}D:`,""];for(let l of a){let f=l===""?0:l.split("/").length,d=l===""?".":l.slice(l.lastIndexOf("/")+1),m=n.get(l)??[],_=m.length?` ${m.join(" ")}`:"";c.push(`${" ".repeat(f)}${d}/${_}`)}if(c.length+s.length>Gn){let l=Math.max(0,Gn-s.length),f=c.length-l;return[...c.slice(0,l),`\u2026 ${f} more lines omitted`,...s]}return[...c,...s]}F("smart-find",Fa);var Kt=1e3,Wn=200,Ba=60,ja=190,za=/^([^\s:]+):(\d+):(.*)$/,Za=/^([^:]+?)-(\d+)-(.*)$/,Ua=/^([^\s:]+):(.*)$/,qn=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;function Yn(t){let e=t.trim();return e.length>Wn?`${e.slice(0,Wn)}\u2026`:e}function Ha(t){let e=[],r="";for(let n of t){let s=r?`${r}, ${n}`:n;s.length>ja&&r?(e.push(`${r},`),r=n):r=s}return r&&e.push(r),e}function Va(t){let e=t.filter(f=>f.trim()!=="");if(e.length===0)return t;let r=new Map,n=new Map,s=null,i=0,o=0;for(let f of e){if(f==="--"){s&&r.get(s).push({separator:!0});continue}if(/^[A-Za-z]:[\\/]/.test(f))return t;let d=za.exec(f),m=Za.exec(f);if(d&&m)return t;let _=d||m?null:Ua.exec(f),E=(d??m??_)?.[1];if(!E)return t;let A=d?{line:d[2],content:d[3],context:!1}:m?{line:m[2],content:m[3],context:!0}:{line:"",content:_[2],context:!1},R=r.get(E)??[];R.push(A),r.set(E,R),A.context||(i+=1,n.set(E,(n.get(E)??0)+1)),o+=1,s=E}if(r.size===o)return t;let a=[...r.keys()].sort((f,d)=>{let m=qn.test(f)?1:0,_=qn.test(d)?1:0;return m-_||(f<d?-1:f>d?1:0)}),u=[];for(let f of a){u.push(`${f} (${n.get(f)??0}):`);for(let d of r.get(f))"separator"in d?u.push(" --"):d.line?u.push(` ${d.line}${d.context?"-":":"} ${Yn(d.content)}`):u.push(` ${Yn(d.content)}`)}let c=a.length>1&&u.length>Ba?Ha(a.map(f=>`${f} (${n.get(f)??0})`)):[],l=[`${i}m ${a.length}f:`,...c,"",...u];if(l.length>Kt){let f=l.length-Kt;return[...l.slice(0,Kt),`\u2026 ${f} more lines omitted`]}return l}F("smart-grep",Va);var Jn=/^(?:([|\\/ ._-]*\*[|\\/* ._-]* ))?commit [0-9a-f]{7,40}\b/,Ka=/^[|\\/* ._-]*$/,Ga=/^ {4}/,Wa=2;function qa(t){if(!t.some(c=>Jn.test(c)))return t;let e=[],r=0,n=0,s=0,i="",o=!1,a=!1,u=()=>{n>0&&e.push(`${i} \u2026 ${n} ${n===1?"line":"lines"} folded \u2026`),n=0};for(let c of t){let l=c.slice(0,s),f=Ka.test(l),d=f?c.slice(s):c,m=Ga.test(d),_=o&&m?null:Jn.exec(c);if(_){u(),r=0,s=_[1]?.length??0,o=!0,a=!1,e.push(c);continue}if(/^diff --(?:git|cc|combined) /.test(d)&&(a=!0),m&&!a&&!(s>0&&d.trim().length===0)){r+=1,r<=Wa?e.push(c):(n+=1,i=f?l:"");continue}u(),e.push(c)}return u(),e}F("smart-log",qa);var Ya=/^[\s=]+$/,Ja=/^\s*=+\s+(.*?)\s+=+\s*$/,Xa=512;F("strip-banners",t=>{let e=[];for(let r of t){if(Ya.test(r))continue;let n=r.length<=Xa?Ja.exec(r):null;e.push(n?n[1]:r)}return e});function Qa(t){let e=[],r=0,n=0;for(;n<t.length;){let s=t[n].replace(/\s+$/,"");if(s===""){r+=1,n+=1,r<=1&&e.push("");continue}r=0;let i=1;for(;n+i<t.length&&t[n+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);n+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}F("squeeze-output",Qa);function ec(t){return t==="compact"?.6:t==="minimal"?.3:1}var tc=20;function rc(t){let[e,r,n,s]=t.slice(-4);if(!e||!r||!n||!s||!/^\s*Test Files\s+([1-9]\d*) passed \(\1\)$/.test(e)||!/^\s*Tests\s+([1-9]\d*) passed \(\1\)$/.test(r)||!/^\s*Start at\s+\d{2}:\d{2}:\d{2}$/.test(n))return t;let i=/^(\s*Duration\s+\d+(?:\.\d+)?(?:ms|s)) \(transform [^\n]+\)$/.exec(s)?.[1];return i?[...t.slice(0,-4).filter((a,u)=>u>2||!/^ RUN v\d+\.\d+\.\d+(?:[\w.+-]*) .+$/.test(a)),e,r,i]:t}var Xn=new WeakMap;function nc(t){let e=Xn.get(t);if(e)return e;let r=t.strip_lines_matching.map(s=>new RegExp(s)),n={def:t,stripRegexes:r};return Xn.set(t,n),n}function Qn(t,e,r={}){return Gt(t,e,r).text}function Gt(t,e,r={}){let n=r.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&&!r.smartCode&&n==="normal")return{text:t,droppedTail:null};let s=nc(e),i=t;e.strip_ansi&&(i=Ie(i));let o=i.endsWith(`
6
+ `),a=(o?i.slice(0,-1):i).split(`
7
+ `);if(s.stripRegexes.length&&(a=e.keep_failures?a.filter(f=>ue.test(f)||!s.stripRegexes.some(d=>d.test(f))):Mn(a,s.stripRegexes)),n!=="normal"&&!e.preserve_exact&&(a=Un(a),a=Hn(a)),n==="minimal"&&!e.preserve_exact&&(a=Zn(a),(e.slug==="vitest"||e.slug==="npm-test")&&(a=rc(a))),!e.preserve_exact&&(r.smartCode||r.smartCode===void 0&&n!=="normal"&&Et(i))&&(a=xt(a)),e.transform){let f=Kn(e.transform);f&&(a=f(a))}let u=e.slug==="read-tool";if(!u){let f=Ht(a);f.some(Boolean)&&(a=a.filter((d,m)=>!f[m]))}e.mask_abs_paths&&(a=jn(a)),e.fold_passing&&(a=Bn(a,e.fold_passing_threshold??5)),e.truncate_lines_at&&(a=Ln(a,e.truncate_lines_at));let c=null;if(e.max_lines){let f=e.scale_with_level?ec(r.verbosity):1,d=Math.min(e.max_lines,Math.max(tc,Math.round(e.max_lines*f))),m=u?Ht(a):null,_=m?m.filter(E=>!E).length:a.length;if(_>d){let E=d;if(m){let R=0;for(E=0;E<a.length&&R<d;)m[E]||(R+=1),E+=1}let A=_-d;if(e.keep_failures){let R=a.slice(E),N=R.filter(P=>!ue.test(P)),U=R.reduce((P,H,C)=>P+(!ue.test(H)&&!m?.[E+C]?1:0),0);c=N.length>0?N.join(`
8
+ `):null,a=[...a.slice(0,E),...U>0?[bt(U)]:[],...R.filter(P=>ue.test(P))]}else if(u)c=a.slice(E).join(`
9
+ `),a=[...a.slice(0,E),bt(A)];else{let{kept:R,dropped:N}=Fn(a,d);c=N.length>0?N.join(`
10
+ `):null,a=R}}}let l=a.join(`
11
+ `);return o&&l.length>0&&(l+=`
12
+ `),l.trim().length===0&&e.on_empty&&(l=e.on_empty),{text:l,droppedTail:c}}var sc=[/\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 es(t){if(!t)return!1;for(let e of Ie(t).split(`
13
+ `))if(!/^\s*[✓✔√]\s/.test(e)&&sc.some(r=>r.test(e)))return!0;return!1}var ic=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),oc=/^[A-Za-z_][A-Za-z0-9_]*=/,Wt=/^([a-z]+)-tool(?::\s|$)/;function He(t){let e=t.trim(),r=e.split(/\s+/),n=0;for(;n<r.length;){let a=r[n];if(oc.test(a)){n++;continue}if(ic.has(a)){for(n++,a==="timeout"&&n<r.length&&/^\d+(?:\.\d+)?[smhd]?$/.test(r[n])&&n++;(a==="stdbuf"||a==="nice")&&n<r.length&&r[n].startsWith("-");)n++;continue}break}if(n>=r.length)return e;let s=r[n],i=s.includes("/")?s.slice(s.lastIndexOf("/")+1):s,o=r.slice(n+1);return o.length?`${i} ${o.join(" ")}`:i}var ac=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"]);function ts(t,e){let r=!1,n=!1,s=0,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="\\"&&!r){o++;continue}a==="'"&&!n?r=!r:a==='"'&&!r?n=!n:!r&&!n&&(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 cc(t){let e=ts(t,!1);for(let r=e.length-1;r>=0;r--){let n=e[r].trim();if(n)return n}return t.trim()}function qt(t){let e=ts(t,!0).map(r=>r.trim()).filter(Boolean);if(e.length===0)return null;for(let r of e.slice(0,-1)){let n=He(r).split(/\s+/)[0]??"";if(!ac.has(n))return null}return cc(e[e.length-1])}function rs(t){let e=!1,r=!1,n=0,s=[];for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&!e){i++;continue}o==="'"&&!r?e=!e:o==='"'&&!e?r=!r:!e&&!r&&(o==="|"||o===";"?(s.push(t.slice(n,i)),o==="|"&&t[i+1]==="|"&&i++,n=i+1):o==="&"&&t[i+1]==="&"&&(s.push(t.slice(n,i)),i++,n=i+1))}s.push(t.slice(n));for(let i=s.length-1;i>=0;i--){let o=s[i].trim();if(o)return o}return t.trim()}function ns(t){let e=Wt.exec(t),r=t;if(e){if(e[1]!=="bash")return[t];let i=t.indexOf(": ");if(i<0)return[t];r=t.slice(i+2)}let n=qt(r),s=n?He(n):null;return s&&s!==t?[s,t]:[t]}var ss=`
14
+ [YOLO: omitted]
15
+ `;function Yt(t){let e=Buffer.from(t,"utf8");if(e.length<=256)return t;let r=256-Buffer.byteLength(ss,"utf8"),n=Math.floor(r/2);for(;(e[n]&192)===128;)n-=1;let s=e.length-(r-n);for(;(e[s]&192)===128;)s+=1;return e.subarray(0,n).toString("utf8")+ss+e.subarray(s).toString("utf8")}var uc=/^ID {2,}TITLE {2,}BRANCH {2,}STATE {2,}CREATED *$/,lc=/^… \([1-9]\d* more lines omitted\)$/,dc=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;function fc(t,e){if(!e)return t.split(`
16
+ `).map(i=>i.replace(/^[ \t]+|[ \t]+(?=\r?$)/g,"")).join(`
17
+ `);let r="",n=!1,s=!1;for(let i of t)n?(r+=i,s?s=!1:i==="\\"?s=!0:i==='"'&&(n=!1)):i==='"'?(n=!0,r+=i):i!==" "&&i!==" "&&i!=="\r"&&i!==`
18
+ `&&(r+=i);return r+(t.endsWith(`
19
+ `)?`
20
+ `:"")}function pc(t,e){if(/@\d|\r/.test(t))return t;let r=t.endsWith(`
21
+ `)?`
22
+ `:"",n=(r?t.slice(0,-1):t).split(`
23
+ `),s=n.findIndex(d=>uc.test(d));if(s>=0&&n.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?[...n[s].matchAll(/\S+/g)].map(d=>d.index):[],o=[];for(let d=s+1;d<n.length;d+=1){let m=n[d];if(lc.test(m))continue;if(/…|\.\.\./.test(m))return t;let _;if(s>=0){if(/[^\x20-\x7e]/.test(m))return t;let E=i.map((A,R)=>m.slice(A,i[R+1]));if(E.slice(0,-1).some(A=>A[0]===" "||!A.endsWith(" "))||(_=E.map(A=>A.replace(/ +$/,"")),!/^#\d+$/.test(_[0])||!/^\S+$/.test(_[2])||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!/^\d+(?:s|m|h|d|w|mo|y)$/.test(_[4])))return t}else if(_=m.split(" "),_.length!==5||!/^\d+$/.test(_[0])||!_[1]||!_[2]||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!dc.test(_[4])||!Number.isFinite(Date.parse(_[4])))return t;if(_.some(E=>/[\u0000-\u001f\u007f]/.test(E)))return t;o.push({index:d,cells:_})}if(o.length===0)return t;s>=0&&(n[s]="ID TITLE BRANCH STATE CREATED");for(let d of o)n[d.index]=d.cells.join(" ");let a=n.join(`
24
+ `)+r;if(!e)return a;let u=new Map;for(let{cells:d}of o)u.set(d[1],(u.get(d[1])??0)+1);let c=new Map,l=[];for(let[d,m]of u){if(d.length<40||m<3||d.trim().split(/\s+/).length<8)continue;let _=`@${c.size+1}`,E=JSON.stringify(d).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),A=`TITLE ${_} = ${E}`;m*(Buffer.byteLength(d)-Buffer.byteLength(_))<=Buffer.byteLength(A)+1||(c.set(d,_),l.push(A))}if(l.length===0)return a;for(let{index:d,cells:m}of o)n[d]=m.map((_,E)=>E===1?c.get(_)??_:_).join(" ");let f=[...n,"",...l].join(`
25
+ `)+r;return Buffer.byteLength(f)<Buffer.byteLength(a)?f:a}function Jt(t,e,r){if(e!=="compact"&&e!=="minimal")return t;let n=t;if(/^[ \t\r\n]*[\[{]/.test(t)){try{JSON.parse(t)}catch{return t}n=fc(t,e==="minimal")}else r==="gh"&&(n=pc(t,e==="minimal"));return Buffer.byteLength(n)<Buffer.byteLength(t)?n:t}var mc=/^(?:\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|$)/,hc=/^\[tkr: previous log line repeated \d+ additional times\]$/m;function is(t){if(Buffer.byteLength(t)<2048||Et(t)||hc.test(t))return t;let e=t.split(`
26
+ `),r=[];for(let n=0;n<e.length;){let s=e[n],i=n+1;if(mc.test(s))for(;i<e.length&&e[i]===s;)i+=1;let o=i-n,a=`[tkr: previous log line repeated ${o-1} additional times]`;if(o>=3&&Buffer.byteLength(a)+1<(o-1)*(Buffer.byteLength(s)+1))r.push(s,a);else for(let u=n;u<i;u+=1)r.push(s);n=i}return r.join(`
27
+ `)}var os=null;function Xt(t){os=t}async function gc(t,e){let r=await $n();return vt(t,r.values(),e)}var yc=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,_c=2048;async function Qt(t,e,r,n={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,yolo:o=!1,...a}=n,u=He(rs(t.startsWith("bash-tool: ")?t.slice(11):t)),c=i!=null&&i!==0&&!(i===1&&yc.test(u)),l=os??gc,f=null;for(let C of ns(t))if(f=await l(C,r),f)break;!f&&s>=_c&&!Wt.test(t)&&(f=await l(`bash-tool: ${t}`,r));let d=qt(t.startsWith("bash-tool: ")?t.slice(11):t),m=f?.slug==="git-log"&&d!=null&&/^git\s+log(?:\s|$)/.test(He(d)),_=i==null&&(m?/^(?:fatal|error):/im.test(Ie(e)):es(e)),E=f?.transform==="smart-read"&&s<=16384&&(e.endsWith(`
28
+ `)?e.slice(0,-1):e).split(`
29
+ `).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(He(d));if(!o&&(A||E&&a.smartCode!==!0))return{output:e,filterId:f?.slug??null,rawBytes:s,filteredBytes:s,debugBypass:c||_,droppedTail:null};if(!f||(c||_)&&f.preserve_exact&&!o)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:c||_,...o?{droppedTail:null}:{}};let R=C=>{if(!o)return C;let J=C.filteredBytes>s||s>0&&C.output.length===0?e:C.output,V=!C.debugBypass&&!f?.preserve_exact?Jt(J,"minimal",C.filterId??""):J,Ke=Yt(V)===V?V:Yt(J);return{...C,output:Ke,filteredBytes:Buffer.byteLength(Ke,"utf8"),droppedTail:null}};if(c||_){let C=o?Qn(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?Ie(e):e;return!o&&a.verbosity==="minimal"&&f.transform!=="smart-read"&&(C=is(C)),R({output:C,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(C,"utf8"),debugBypass:!0})}let{text:N,droppedTail:U}=Gt(e,f,o?{...a,verbosity:"minimal"}:a),P=!o&&!f.preserve_exact?Jt(N,a.verbosity,f.slug):N,H=Buffer.byteLength(P,"utf8");return e.trim().length>0&&H>=s?R({output:e,filterId:f.slug,rawBytes:s,filteredBytes:s,debugBypass:!1,droppedTail:null}):R({output:P,filterId:f.slug,rawBytes:s,filteredBytes:H,debugBypass:!1,droppedTail:U})}import{join as bc}from"node:path";import{mkdir as jf,readFile as xc,writeFile as zf,unlink as Zf,rename as Uf}from"node:fs/promises";import vc from"node:os";import{join as wt}from"node:path";function T(){return process.env.TOKMIZER_HOME||wt(vc.homedir(),".tokmizer")}function et(){return wt(T(),"install-id")}function er(){return wt(T(),"content-cache")}function as(t){return wt(er(),t)}var Ec="state.json";function wc(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function kc(t){return t?.dir??T()}async function tt(t){let e=kc(t);try{let r=await xc(bc(e,Ec),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??wc(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}function Sc(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function cs(t,e=Date.now()){let r=t.lastHeartbeatOkAt;if(typeof r=="number"&&e-r>Sc())return!0;if(t.subEndsAt){let n=Date.parse(t.subEndsAt);if(Number.isFinite(n)&&e>n)return!0}return!1}function us(t,e=Date.now()){return t.plan}import{readFile as Tc,writeFile as Wf,mkdir as qf,chmod as Yf,rm as Jf,rename as Xf,readdir as Qf}from"node:fs/promises";import{join as Ac}from"node:path";var Rc="settings-cache.json",ls=Qe.parse({}),np=Qe.partial().extend({filters:Qe.shape.filters.removeDefault().partial().optional()});async function rt(){try{let t=await Tc(Ac(T(),Rc),"utf8"),e=JSON.parse(t);return Qe.parse({...ls,...e})}catch{return ls}}var Cc=[[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];function nt(t){let e=t;for(let[r,n]of Cc)e=e.replace(r,n);return e}import{join as hs}from"node:path";import{appendFileSync as Mc,chmodSync as Lc,existsSync as Fc,mkdirSync as Bc,readFileSync as xp,renameSync as Ep,rmdirSync as wp,statSync as jc,unlinkSync as kp,utimesSync as Sp,writeFileSync as Tp}from"node:fs";import{createHash as ap,randomUUID as Ic}from"node:crypto";import{readFile as ds,writeFile as fs,mkdir as $c}from"node:fs/promises";async function tr(){try{let r=(await ds(et(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await $c(T(),{recursive:!0});let t=Ic();try{return await fs(et(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await ds(et(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await fs(et(),t,{mode:384}),t}}import{createRequire as Oc}from"node:module";var Nc=Oc(import.meta.url);function Pc(){for(let t of["../package.json","../../package.json"])try{let e=Nc(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var rr=Pc();var ps=`-----BEGIN PUBLIC KEY-----
15
30
  MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
16
31
  -----END PUBLIC KEY-----
17
- `;var Pf=300*1e3;function rs(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??ts).replace(/\\n/g,`
18
- `)}var yc=512*1024;function ss(){return ns(T(),"spool")}function _c(t){return ns(ss(),`${t}.jsonl`)}function mt(t,e){try{hc(ss(),{recursive:!0,mode:448});let r=_c(t);if(mc(r)&&gc(r).size>=yc)return;fc(r,JSON.stringify(e)+`
19
- `,{mode:384}),pc(r,384)}catch{return}}var xc=/^[a-z0-9][a-z0-9._-]*$/i,bc=/^[a-z][a-z-]+$/,Ec=/^[A-Za-z_][A-Za-z0-9_]*=/,wc=new Set(["gh","glab","gup","hub","gist"]),kc=/^(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,Sc=24,Tc=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"]);function is(t){let e=t.toLowerCase();return e.startsWith("git")||wc.has(e)}function Vt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),r=0;for(;r<e.length&&Ec.test(e[r]??"");)r+=1;let n=e[r];if(!n||!xc.test(n)||n.length>Sc||is(n)||kc.test(n)||Ge(n)!==n)return"";let s=e[r+1];return s&&is(s)?"":(s&&Tc.has(n.toLowerCase())&&bc.test(s)?`${n} ${s}`:n).slice(0,64)}async function os(t){if(!t.telemetryOptIn)return;let e=Vt(t.cmd),r=e&&Ge(e)===e?e:"other",n=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";mt("telemetry",{cmd:r,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,...n?{sessionId:n}:{},...t.host?{host:t.host}:{}})}async function as(t){if(t.plan!=="pro"||!(await We()).telemetryOptIn)return;let e=Vt(t.cmd);!e||Ge(e)!==e||mt("learn",{cmd:e,filterId:t.filterId==null?null:Z(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}import{appendFileSync as $c,chmodSync as Oc,mkdirSync as Pc}from"node:fs";import{readFileSync as Ac,renameSync as Rc,statSync as Cc,writeFileSync as Ic}from"node:fs";function cs(t,e,r){try{if(Cc(t).size<=e)return;let n=Ac(t,"utf8").split(`
20
- `).filter(a=>a.trim()!==""),s=[],i=0;for(let a=n.length-1;a>=0;a-=1){let c=n[a],u=Buffer.byteLength(c)+1;if(i+u>r)break;s.push(c),i+=u}s.reverse();let o=`${t}.tmp-${process.pid}`;Ic(o,s.length?`${s.join(`
32
+ `;var gp=300*1e3;function ms(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??ps).replace(/\\n/g,`
33
+ `)}var zc=512*1024;function gs(){return hs(T(),"spool")}function Zc(t){return hs(gs(),`${t}.jsonl`)}function kt(t,e){try{Bc(gs(),{recursive:!0,mode:448});let r=Zc(t);if(Fc(r)&&jc(r).size>=zc)return;Mc(r,JSON.stringify(e)+`
34
+ `,{mode:384}),Lc(r,384)}catch{return}}var Hc=/^[a-z0-9][a-z0-9._-]*$/i,Vc=/^[a-z][a-z-]+$/,Kc=/^[A-Za-z_][A-Za-z0-9_]*=/,Gc=new Set(["gh","glab","gup","hub","gist"]),Wc=/^(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,qc=24,Yc=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"]);function ys(t){let e=t.toLowerCase();return e.startsWith("git")||Gc.has(e)}function nr(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),r=0;for(;r<e.length&&Kc.test(e[r]??"");)r+=1;let n=e[r];if(!n||!Hc.test(n)||n.length>qc||ys(n)||Wc.test(n)||nt(n)!==n)return"";let s=e[r+1];return s&&ys(s)?"":(s&&Yc.has(n.toLowerCase())&&Vc.test(s)?`${n} ${s}`:n).slice(0,64)}async function _s(t){if(!t.telemetryOptIn)return;let e=nr(t.cmd),r=e&&nt(e)===e?e:"other",n=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";kt("telemetry",{cmd:r,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,...n?{sessionId:n}:{},...t.host?{host:t.host}:{}})}async function vs(t){if(t.plan!=="pro"||!(await rt()).telemetryOptIn)return;let e=nr(t.cmd);!e||nt(e)!==e||kt("learn",{cmd:e,filterId:t.filterId==null?null:G(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}import{appendFileSync as tu,chmodSync as ru,mkdirSync as nu}from"node:fs";import{readFileSync as Jc,renameSync as Xc,statSync as Qc,writeFileSync as eu}from"node:fs";function bs(t,e,r){try{if(Qc(t).size<=e)return;let n=Jc(t,"utf8").split(`
35
+ `).filter(a=>a.trim()!==""),s=[],i=0;for(let a=n.length-1;a>=0;a-=1){let u=n[a],c=Buffer.byteLength(u)+1;if(i+c>r)break;s.push(u),i+=c}s.reverse();let o=`${t}.tmp-${process.pid}`;eu(o,s.length?`${s.join(`
21
36
  `)}
22
- `:"",{mode:384}),Rc(o,t)}catch{}}import{join as Dc}from"node:path";var Nc="stats.jsonl";var ls=2*1024*1024;var Mc=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Lc=new Set(["-u","-g","-n","-s","-k"]),Fc=/^[a-z0-9][a-z0-9._-]*$/i,Bc=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"]),ds=/^[A-Za-z_][A-Za-z0-9_]*=/;function us(t){return t.length===0||t[0]==="cd"||t.every(e=>ds.test(e))}function jc(t){let e=[],r="",n=!1,s=null,i=()=>{n&&e.push(r),r="",n=!1};for(let o of t){if(s){o===s?s=null:r+=o;continue}if(o==="'"||o==='"'){s=o,n=!0;continue}if(o===" "||o===" "){i();continue}if(`|;&<>
23
- `.includes(o)){if(i(),us(e)){e=[];continue}return e}r+=o,n=!0}return i(),us(e)?[]:e}function fs(t){let e=jc(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),r=0;for(;r<e.length;){let a=e[r];if(ds.test(a)){r+=1;continue}if(Mc.has(a)){for(r+=1;r<e.length;){let c=e[r];if(c.startsWith("-")){r+=Lc.has(c)?2:1;continue}if(/^\d+(?:\.\d+)?[smhd]?$/.test(c)){r+=1;continue}break}continue}break}if(r>=e.length)return"";let n=e[r],s=n.includes("/")?n.slice(n.lastIndexOf("/")+1):n,i=e[r+1];return(i&&!i.startsWith("-")&&Fc.test(i)&&Bc.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function zc(){return Dc(T(),Nc)}function ps(t,e,r=zc(),n=!1,s,i,o){if(t<=0||e<0||e>t)return;let a=s?`,"h":${JSON.stringify(s)}`:"",c=i?`,"k":${JSON.stringify(i)}`:"",u=o?`,"c":${JSON.stringify(o.slice(0,24))}`:"",l=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}${n?',"m":1':""}${a}${c}${u}}
24
- `;try{Pc(T(),{recursive:!0,mode:448}),$c(r,l,{mode:384}),Oc(r,384),cs(r,ls,ls/2)}catch{return}}function ms(t,e,r){let n=r!=null?Math.min(t,r):t,s=Math.min(e,n);return{raw:n,filtered:s}}import{mkdir as vp,writeFile as Zc,readFile as xs,unlink as Uc,chmod as Hc,rename as Vc}from"node:fs/promises";import{existsSync as Kc}from"node:fs";import{delimiter as _s,join as qt,dirname as Ep}from"node:path";import{fileURLToPath as Wc}from"node:url";import bs from"node:os";var Kt=[{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"]}],gp=[...Kt.map(t=>t.host),"shell"],Wt=new Set(["claude-code","codex"]);function Gt(t){return Kt.filter(e=>Wt.has(e.host)===t).flatMap(e=>e.vars)}function hs(t){return Wt.has(t)}function gs(t){return null}function ys(t=process.env){let e=process.platform,r=e==="darwin"||e==="linux"||e==="win32"?e:"other",n=process.arch;for(let s of Kt)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:r,arch:n,shimRecommended:!Wt.has(s.host)};return{host:"shell",source:"fallback",os:r,arch:n,shimRecommended:!0}}var Gc=["git","npm","yarn","pnpm","docker","kubectl","terraform","tofu","cargo","go","mvn","gradle","rg","grep","find","ls","cat","tail","head","ps","lsof","ssh","scp","rsync","curl","wget","jq","yq","make"];function gt(){return qt(T(),"shims")}function Es(){let t=gt(),e={...process.env},r=process.platform==="win32"?"Path":"PATH",s=(e[r]??e.PATH??"").split(_s).filter(i=>i&&i!==t);return e[r]=s.join(_s),r==="Path"&&(e.PATH=e[r]),e}function ht(t){return`'${t.replace(/'/g,"'\\''")}'`}function vs(t){return`"${t.map(e=>`\${${e}:-}`).join("")}"`}function ws(t,e){return["#!/bin/sh",`if [ -n ${vs(Gt(!0))} ] || { [ -z ${vs(Gt(!1))} ] && [ ! -t 1 ]; }; then`," set -f",` _tk_d=${ht(gt())}`,` _tk_c=${ht(e)}`," _tk_o=$IFS; IFS=:; _tk_p=; _tk_x="," for _tk_e in $PATH; do",' [ -n "$_tk_e" ] || continue',' [ "$_tk_e" -ef "$_tk_d" ] && continue'," _tk_p=${_tk_p:+$_tk_p:}$_tk_e",' [ -z "$_tk_x" ] && [ -f "$_tk_e/$_tk_c" ] && [ -x "$_tk_e/$_tk_c" ] && _tk_x=$_tk_e/$_tk_c'," done"," IFS=$_tk_o; PATH=$_tk_p; export PATH; set +f",' [ -n "$_tk_x" ] || { echo "$_tk_c: command not found" >&2; exit 127; }',' exec "$_tk_x" "$@"',"fi",`exec node ${ht(t)} --as ${ht(e)} "$@"`,""].join(`
25
- `)}async function ks(t,e){if(bs.platform()==="win32")return 0;try{if(await xs(qt(gt(),e),"utf8")===ws(t,e))return 0}catch{return 0}return qc(t)}async function qc(t){if(bs.platform()==="win32")return 0;let e=gt();if(!Kc(e))return 0;let r=0;for(let n of Gc){let s=qt(e,n),i=ws(t,n),o;try{o=await xs(s,"utf8")}catch{continue}if(o===i)continue;let a=`${s}.${process.pid}.tmp`;try{await Zc(a,i,{mode:493}),await Hc(a,493),await Vc(a,s),r+=1}catch{try{await Uc(a)}catch{}}}return r}function Ss(){return process.env.TOKMIZER_SHIM_JS?process.env.TOKMIZER_SHIM_JS:Wc(new URL("../bin/tkr-shim.js",import.meta.url))}import{createConnection as ll}from"node:net";import{spawn as ul}from"node:child_process";import{existsSync as Os,openSync as Qt,closeSync as Is,unlinkSync as tr,writeFileSync as rr,mkdirSync as nr,readFileSync as dl,appendFileSync as fl,rmSync as pl,statSync as ml}from"node:fs";import{dirname as hl,join as sr}from"node:path";import{fileURLToPath as gl}from"node:url";var Yc=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()}),Jc=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),Xc=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),Qc=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),Ip=m.discriminatedUnion("op",[Yc,Jc,Xc,Qc]),$p=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),Op=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),Ts=m.object({filter:Le.nullable(),cacheHit:m.boolean().optional()}),yt=`
26
- `,Pp=64*1024;function Yt(t){return JSON.stringify(t)+yt}function*As(t){let e=0;for(;;){let r=t.indexOf(yt,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function qe(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import el from"node:os";import{join as Ye}from"node:path";import{existsSync as tl,statSync as rl,lstatSync as Rs,unlinkSync as nl,mkdirSync as sl,chmodSync as il}from"node:fs";import{createHash as ol}from"node:crypto";var Jt=100;function al(t){let e=ol("sha256").update(T()).digest("hex").slice(0,8),r=Ye(el.tmpdir(),`tkr-${t}-${e}`),n=Ye(r,"d.sock");if(Buffer.byteLength(n)>Jt)throw new Error("Temporary directory path is too long for IPC");return Cs(r,t),n}function cl(t,e){try{let r=Rs(t);return r.isDirectory()&&r.uid===e&&(r.mode&63)===0}catch{return!1}}function Cs(t,e){sl(t,{recursive:!0,mode:448});let r=Rs(t);if(!r.isDirectory()||r.uid!==e)throw new Error("Unsafe IPC directory");il(t,448)}function Je(){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&&cl(e,t)){let s=Ye(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=Jt)return{path:s,isPipe:!1}}let r=Ye(T(),"run"),n=Ye(r,"daemon.sock");return Buffer.byteLength(n)>Jt?{path:al(t),isPipe:!1}:(Cs(r,t),{path:n,isPipe:!1})}async function Xt(){let{path:t,isPipe:e}=Je();if(e||!tl(t))return;try{if(!rl(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let i=r.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{nl(t)}catch{}}var jp=5*6e4;var Ps=500,yl=3e3,$s=1,_l=6e4,vl=256*1024;function ir(){return sr(T(),"daemon.spawn.fail")}function or(){return sr(T(),"daemon.log")}function xl(){try{let t=Number(dl(ir(),"utf8"));return Number.isFinite(t)&&Date.now()-t<_l}catch{return!1}}function bl(t){try{nr(T(),{recursive:!0});let e=or();try{ml(e).size>vl&&tr(e)}catch{}fl(e,`${new Date().toISOString()} ${t}
27
- `)}catch{}}function El(t){try{nr(T(),{recursive:!0}),rr(ir(),String(Date.now()))}catch{}bl(`spawn failed: ${t.message}`)}function wl(){try{pl(ir(),{force:!0})}catch{}}async function _t(t,e){return new Promise((r,n)=>{let s=ll(t),i=a=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(o),a){try{s.destroy()}catch{}n(a)}else r(s)},o=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",a=>i(a))})}function kl(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:gl(new URL("../bin/tkr-daemon.js",import.meta.url))}async function er(t,e=3e3){let r=Math.ceil(e/75),n=process.platform==="win32";for(let s=0;s<r;s++){if(n)try{return(await _t(t,75)).destroy(),!0}catch{}else if(Os(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function Sl(t){let e=kl();if(!Os(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=Je(),n=process.platform==="win32"?T():hl(r);try{nr(n,{recursive:!0})}catch{}let s=sr(n,"daemon.spawn.lock"),i=null;try{i=Qt(s,"wx"),rr(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await er(r,5e3))return;try{tr(s)}catch{}try{i=Qt(s,"wx"),rr(i,String(process.pid))}catch(c){if(c.code==="EEXIST"){await er(r,5e3);return}throw c}}else throw o}try{let o=null;try{o=Qt(or(),"a")}catch{}if(ul(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{Is(o)}catch{}if(!await er(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{Is(i)}catch{}try{tr(s)}catch{}}}}async function Tl(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Je(),r=await Ut();try{let n=await _t(e,Ps);n.write(Yt({id:qe(),op:"shutdown",installId:r})),await new Promise(s=>setTimeout(s,150));try{n.destroy()}catch{}return!0}catch{return!1}}async function Al(t,e){let r=Date.now()+e;for(;Date.now()<r;){try{(await _t(t,250)).destroy()}catch{return!0}await new Promise(n=>setTimeout(n,100))}return!1}async function ar(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Je(),r=await Ut(),n=null,s=0,i=!1;for(;s<=$s;)try{n=await _t(e,Ps),wl();break}catch{if(s+=1,s>$s)throw new Error(`tkr-daemon unreachable at ${e}`);if(xl())throw new Error(`tkr-daemon spawn on cooldown (see ${or()})`);await Xt();try{await Sl(r),i=!0}catch(l){throw El(l),l}}if(!n)throw new Error("tkr-daemon: socket setup failed");let o=new Map,a="";n.setEncoding("utf8"),n.on("data",l=>{a+=l;let d=-1;for(let y=0;y<a.length;y++)a[y]===yt&&(d=y);if(d<0)return;let p=[];for(let y of As(a.slice(0,d+1)))p.push(y);a=a.slice(d+1);for(let y of p)if(y)try{let S=JSON.parse(y),w=o.get(S.id);if(!w)continue;clearTimeout(w.timer),o.delete(S.id),w.resolve(S)}catch{}}),n.on("close",()=>{for(let l of o.values())clearTimeout(l.timer),l.reject(new Error("daemon socket closed"));o.clear()}),n.on("error",()=>{});function c(l){return new Promise((d,p)=>{let y=setTimeout(()=>{o.delete(l.id),p(new Error(`daemon request timeout (${l.op})`))},yl);o.set(l.id,{resolve:d,reject:p,timer:y}),n.write(Yt(l))})}let u={filter:async(l,d,p)=>{let y=await c({id:qe(),op:"filter",cmd:l.slice(0,2048),plan:d,...p&&p.length>0?{allowed:p.slice(0,512)}:{},installId:r});if(!y.ok)return null;let S=Ts.safeParse(y.data);return S.success?S.data.filter:null},ping:async()=>{let l=await c({id:qe(),op:"ping"});if(!l.ok)throw new Error(l.err);return l.data},reload:async()=>{let l=await c({id:qe(),op:"reload",installId:r});if(!l.ok)throw new Error(l.err);return l.data},close:()=>{try{n.end()}catch{}}};if(!t.skipVersionCheck&&!i){let l=!1;try{l=(await u.ping()).version!==Ht}catch{}if(l){try{await Tl(t.socketPath?{socketPath:t.socketPath}:{})}catch{}u.close();let d=await Al(e,2e3);if(await Xt(),!d)throw new Error("stale daemon still running after shutdown request");return ar({...t,skipVersionCheck:!0})}}return u}import{createPublicKey as Ll,verify as Fl}from"node:crypto";import{createCipheriv as tm,createDecipheriv as Rl,hkdfSync as Cl,randomBytes as rm}from"node:crypto";var Il=Buffer.from("tokmizer-bundle-enc-v1"),$l=Buffer.from("rules-bundle");function Ol(t){return Buffer.from(Cl("sha256",Buffer.from(t,"utf8"),Il,$l,32))}function Ds(t,e){let r=Ol(e),n=Buffer.from(t,"base64url"),s=n.subarray(0,12),i=n.subarray(12,28),o=n.subarray(28),a=Rl("aes-256-gcm",r,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}import{chmodSync as im,readFileSync as Pl,writeFileSync as om,mkdirSync as am,renameSync as cm}from"node:fs";import{join as Dl}from"node:path";var Nl=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()});function Ml(){return Dl(T(),"bundle-cache.json")}function Ns(){try{let t=Pl(Ml(),"utf8"),e=Nl.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var Bl=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array(Le)}),Em=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),jl=10080*60*1e3;function zl(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:jl}function Zl(t,e){let r=rs();if(!r||!r.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 n=Ll({key:r,format:"pem"});if(!Fl(null,Buffer.from(t.payload,"utf8"),n,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(Ds(t.payload,e))}function Ul(t,e){let r=Zl(t,e),n=Bl.parse(r);if(Date.now()-n.signedAt>zl())throw new Error("tkr-daemon: rules bundle is stale");let s=new Map;for(let i of n.filters)s.set(i.slug,{...i,matchRegex:new RegExp(i.match_command)});return En(),{bundleVersion:n.bundleVersion,signedAt:n.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>lt(i,s.values(),a&&a.length>0?new Set(a):null)}}async function Ms(){try{let t=Ns();if(!t)return null;let e=await Ke();return e?.signingSecret?Ul(t,e.signingSecret):null}catch{return null}}var Be=null,Xe=null;async function Hl(){if(Be)return Be;if(Xe)return Xe;let t=ar().then(e=>{if(Xe===t)return Be=e,e;try{e.close()}catch{}return null}).catch(()=>null);return Xe=t,t}var cr=null,lr=!1;async function Vl(){return lr||(lr=!0,cr=await Ms()),cr}async function Ls(t,e,r){let n=await Vl();if(!n)return null;let s=n.selectFor(t,e,[...r]);return!s||!r.has(Z(s.slug))?null:s}function Kl(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Fs(t){zt(async(e,r)=>{let n=t==="free"?"trial":t,s=r??ct(void 0),i=await Hl();if(!i)return Ls(e,n,s);try{let o=await i.filter(e,n,[...s]);return!o||!s.has(Z(o.slug))?null:Kl(o)}catch{return Ls(e,n,s)}})}function Bs(){if(zt(null),Be)try{Be.close()}catch{}Be=null,Xe=null,cr=null,lr=!1}import{chmod as Wl,mkdir as Gl,readFile as Im,writeFile as ql,stat as $m,readdir as Om,rm as Yl,rename as Jl}from"node:fs/promises";import{createHash as js}from"node:crypto";var Nm=10080*60*1e3,Mm=100*1024*1024,Xl=2*1024*1024,Ql=/^[0-9a-f]{8,64}$/i;function eu(t,e){let r=Number(process.env[t]);return Number.isFinite(r)&&r>0?r:e}async function zs(t,e){if(!Ql.test(t)||Buffer.byteLength(e,"utf8")>eu("TOKMIZER_CCR_ENTRY_MAX_BYTES",Xl))return!1;let r=qn(t),n=`${r}.tmp-${process.pid}-${process.hrtime.bigint()}`;try{return await Gl(Zt(),{recursive:!0}),await ql(n,e,{mode:384}),await Wl(n,384),await Jl(n,r),!0}catch{try{await Yl(n)}catch{}return!1}}async function Zs(t,e){let r=process.env.TOKMIZER_CCR_DISABLED;if(r==="1"||r==="true"||!t)return e;let n=js("sha256").update(t).digest("hex").slice(0,16),s=`
28
- [tkr restore ${n}]`;return Buffer.byteLength(t,"utf8")<=Buffer.byteLength(s,"utf8")||!await zs(n,t)?e:`${e}${s}`}async function Us(t,e){let r=process.env.TOKMIZER_CCR_DISABLED;if(r==="1"||r==="true"||!t)return e;let n=js("sha256").update(t).digest("hex").slice(0,16);return await zs(n,t)?`${e}
29
- [tkr restore ${n}]`:e}var Hs=16*1024*1024,tu=6e5,ru=1500,nu=new Set(["npm","pnpm","yarn","bun"]),su=new Set(["dev","start","serve","preview","watch"]);function Ks(t,e){let r=process.env[t];if(r==null||r==="")return e;let n=Number(r);return Number.isFinite(n)?n:e}function iu(){return Ks("TOKMIZER_SHIM_STREAM_AFTER_MS",process.stdout.isTTY?ru:0)}function ou(t,e){let r=t.split(/[\\/]/).pop()??t;return nu.has(r)?e.some(n=>!n.startsWith("-")&&su.has(n)):!1}function Ws(t){return t[0]==="--as"&&typeof t[1]=="string"?{cmdName:t[1],args:t.slice(2)}:t.length>0?{cmdName:t[0],args:t.slice(1)}:{cmdName:"",args:[]}}async function Gs(t){let{cmdName:e,args:r}=t;if(!e)return process.stderr.write(`tkr-shim: missing command name
30
- `),{exitCode:2,filteredOut:"",filteredErr:"",filterId:null,rawBytes:0,filteredBytes:0};let n=[e,...r].join(" "),s=await We(),i=await Ke(),o=i?Jn(i):null,a=i?ct(i.allowedFilters,Yn(i)):new Set,c=new Set(s.filters.disabled.map(Z)),u=c.size>0?new Set([...a].filter(A=>!c.has(A))):a,l=ys().host,d=!process.stdout.isTTY&&l==="shell",p=!s.enabled||!i||hs(l),y=ou(e,r);i&&!p&&!d&&!y&&Fs(o);let S,w;try{return await new Promise(A=>{let C=(0,Vs.default)(e,r,{stdio:y?"inherit":["inherit","pipe","pipe"],shell:!1,windowsHide:!0,env:Es()}),L=[],U=[],Ee=0,we=0,je=!1,se=y,dr=Ks("TOKMIZER_SHIM_TIMEOUT_MS",tu),fr=iu(),J,ie,pr=()=>{J&&clearTimeout(J),ie&&clearTimeout(ie),J=void 0,ie=void 0},Ys=()=>{if(!se){se=!0,J&&clearTimeout(J),J=void 0;for(let R of L)process.stdout.write(R);for(let R of U)process.stderr.write(R);L.length=0,U.length=0}},vt=()=>{se||fr<=0||(ie&&clearTimeout(ie),ie=setTimeout(Ys,fr),ie.unref?.())};!se&&dr>0&&(J=setTimeout(()=>C.kill("SIGTERM"),dr),J.unref?.()),vt();let mr=R=>{try{C.kill(R)}catch{}};S=()=>mr("SIGINT"),w=()=>mr("SIGTERM"),process.on("SIGINT",S),process.on("SIGTERM",w),C.stdout?.on("data",R=>{if(Ee+=R.length,se){process.stdout.write(R);return}if(Ee>Hs){if(!je){for(let ke of L)process.stdout.write(ke);L.length=0,je=!0}process.stdout.write(R);return}L.push(R),vt()}),C.stderr?.on("data",R=>{if(we+=R.length,se){process.stderr.write(R);return}if(we>Hs){if(!je){for(let ke of U)process.stderr.write(ke);U.length=0,je=!0}process.stderr.write(R);return}U.push(R),vt()}),C.on("error",R=>{pr(),process.stderr.write(`tkr-shim: ${R.message}
31
- `),A({exitCode:127,filteredOut:"",filteredErr:"",filterId:null,rawBytes:0,filteredBytes:0})}),C.on("close",async(R,ke)=>{pr();let Qe=typeof R=="number"?R:ke==="SIGTERM"?143:ke==="SIGINT"?130:1,Se=Buffer.concat(L),Te=Buffer.concat(U);if(je||se||p||d){Se.length&&process.stdout.write(Se),Te.length&&process.stderr.write(Te),A({exitCode:Qe,filteredOut:Se.toString("utf8"),filteredErr:Te.toString("utf8"),filterId:null,rawBytes:Ee+we,filteredBytes:Ee+we});return}let xt=Se.toString("utf8"),et=Te.toString("utf8");try{let $=await Gn(n,xt,u,{verbosity:s.outputVerbosity,exitCode:Qe}),tt=ms($.rawBytes,$.filteredBytes,gs(l));ps(tt.raw,tt.filtered,void 0,!1,l,"sh",fs(n));try{await as({cmd:n,filterId:$.filterId,rawBytes:$.rawBytes,filteredBytes:$.filteredBytes,plan:o}),await os({cmd:n,tokensSaved:Math.round((tt.raw-tt.filtered)/4),optimized:$.filterId!=null,telemetryOptIn:s.telemetryOptIn,sessionId:process.env.CLAUDE_CODE_SESSION_ID,host:l})}catch{}if($.filteredBytes<$.rawBytes){let bt=$.output;try{bt=new RegExp(Cn.source,"m").test($.output)?await Us(xt,$.output):await Zs($.droppedTail??null,$.output)}catch{}process.stdout.write(bt),et&&process.stderr.write(et),A({exitCode:Qe,filteredOut:bt,filteredErr:et,filterId:$.filterId,rawBytes:$.rawBytes,filteredBytes:$.filteredBytes});return}}catch{}Se.length&&process.stdout.write(Se),Te.length&&process.stderr.write(Te),A({exitCode:Qe,filteredOut:xt,filteredErr:et,filterId:null,rawBytes:Ee+we,filteredBytes:Ee+we})})})}finally{S&&process.off("SIGINT",S),w&&process.off("SIGTERM",w),Bs()}}function qs(t=process.stdout,e=r=>process.exit(r)){t.on("error",r=>{if(r.code==="EPIPE"){e(141);return}throw r})}qs();var ur=Ws(process.argv.slice(2));ur.cmdName&&ks(Ss(),ur.cmdName).catch(()=>{});Gs(ur).then(t=>{process.exitCode=t.exitCode}).catch(t=>{process.stderr.write(`tkr-shim: ${t.message}
37
+ `:"",{mode:384}),Xc(o,t)}catch{}}import{join as su}from"node:path";var iu="stats.jsonl";var xs=2*1024*1024;var ou=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),au=new Set(["-u","-g","-n","-s","-k"]),cu=/^[a-z0-9][a-z0-9._-]*$/i,uu=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 Es(t){return t.length===0||t[0]==="cd"||t.every(e=>ws.test(e))}function lu(t){let e=[],r="",n=!1,s=null,i=()=>{n&&e.push(r),r="",n=!1};for(let o of t){if(s){o===s?s=null:r+=o;continue}if(o==="'"||o==='"'){s=o,n=!0;continue}if(o===" "||o===" "){i();continue}if(`|;&<>
38
+ `.includes(o)){if(i(),Es(e)){e=[];continue}return e}r+=o,n=!0}return i(),Es(e)?[]:e}function ks(t){let e=lu(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),r=0;for(;r<e.length;){let a=e[r];if(ws.test(a)){r+=1;continue}if(ou.has(a)){for(r+=1;r<e.length;){let u=e[r];if(u.startsWith("-")){r+=au.has(u)?2:1;continue}if(/^\d+(?:\.\d+)?[smhd]?$/.test(u)){r+=1;continue}break}continue}break}if(r>=e.length)return"";let n=e[r],s=n.includes("/")?n.slice(n.lastIndexOf("/")+1):n,i=e[r+1];return(i&&!i.startsWith("-")&&cu.test(i)&&uu.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function du(){return su(T(),iu)}function Ss(t,e,r=du(),n=!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)}`:"",u=i?`,"k":${JSON.stringify(i)}`:"",c=o?`,"c":${JSON.stringify(o.slice(0,24))}`:"",l=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}${n?',"m":1':""}${a}${u}${c}}
39
+ `;try{nu(T(),{recursive:!0,mode:448}),tu(r,l,{mode:384}),ru(r,384),bs(r,xs,xs/2)}catch{return}}function Ts(t,e,r){let n=r!=null?Math.min(t,r):t,s=r!=null?Math.min(e,r):e;return{raw:n,filtered:s}}import{mkdir as tm,writeFile as fu,readFile as Os,unlink as pu,chmod as mu,rename as hu}from"node:fs/promises";import{existsSync as gu}from"node:fs";import{delimiter as Is,join as ar,dirname as sm}from"node:path";import{fileURLToPath as yu}from"node:url";import Ns from"node:os";var sr=[{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"]}],Xp=[...sr.map(t=>t.host),"shell"],ir=new Set(["claude-code","codex"]);function or(t){return sr.filter(e=>ir.has(e.host)===t).flatMap(e=>e.vars)}function As(t){return ir.has(t)}function Rs(t){return null}function Cs(t=process.env){let e=process.platform,r=e==="darwin"||e==="linux"||e==="win32"?e:"other",n=process.arch;for(let s of sr)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:r,arch:n,shimRecommended:!ir.has(s.host)};return{host:"shell",source:"fallback",os:r,arch:n,shimRecommended:!0}}var _u=["git","npm","yarn","pnpm","docker","kubectl","terraform","tofu","cargo","go","mvn","gradle","rg","grep","find","ls","cat","tail","head","ps","lsof","ssh","scp","rsync","curl","wget","jq","yq","make"];function Tt(){return ar(T(),"shims")}function Ps(){let t=Tt(),e={...process.env},r=process.platform==="win32"?"Path":"PATH",s=(e[r]??e.PATH??"").split(Is).filter(i=>i&&i!==t);return e[r]=s.join(Is),r==="Path"&&(e.PATH=e[r]),e}function St(t){return`'${t.replace(/'/g,"'\\''")}'`}function $s(t){return`"${t.map(e=>`\${${e}:-}`).join("")}"`}function Ds(t,e){return["#!/bin/sh",`if [ -n ${$s(or(!0))} ] || { [ -z ${$s(or(!1))} ] && [ ! -t 1 ]; }; then`," set -f",` _tk_d=${St(Tt())}`,` _tk_c=${St(e)}`," _tk_o=$IFS; IFS=:; _tk_p=; _tk_x="," for _tk_e in $PATH; do",' [ -n "$_tk_e" ] || continue',' [ "$_tk_e" -ef "$_tk_d" ] && continue'," _tk_p=${_tk_p:+$_tk_p:}$_tk_e",' [ -z "$_tk_x" ] && [ -f "$_tk_e/$_tk_c" ] && [ -x "$_tk_e/$_tk_c" ] && _tk_x=$_tk_e/$_tk_c'," done"," IFS=$_tk_o; PATH=$_tk_p; export PATH; set +f",' [ -n "$_tk_x" ] || { echo "$_tk_c: command not found" >&2; exit 127; }',' exec "$_tk_x" "$@"',"fi",`exec node ${St(t)} --as ${St(e)} "$@"`,""].join(`
40
+ `)}async function Ms(t,e){if(Ns.platform()==="win32")return 0;try{if(await Os(ar(Tt(),e),"utf8")===Ds(t,e))return 0}catch{return 0}return vu(t)}async function vu(t){if(Ns.platform()==="win32")return 0;let e=Tt();if(!gu(e))return 0;let r=0;for(let n of _u){let s=ar(e,n),i=Ds(t,n),o;try{o=await Os(s,"utf8")}catch{continue}if(o===i)continue;let a=`${s}.${process.pid}.tmp`;try{await fu(a,i,{mode:493}),await mu(a,493),await hu(a,s),r+=1}catch{try{await pu(a)}catch{}}}return r}function Ls(){return process.env.TOKMIZER_SHIM_JS?process.env.TOKMIZER_SHIM_JS:yu(new URL("../bin/tkr-shim.js",import.meta.url))}import{createConnection as Nu}from"node:net";import{spawn as Pu}from"node:child_process";import{existsSync as Hs,openSync as dr,closeSync as Zs,unlinkSync as pr,writeFileSync as mr,mkdirSync as hr,readFileSync as Du,appendFileSync as Mu,rmSync as Lu,statSync as Fu}from"node:fs";import{dirname as Bu,join as gr}from"node:path";import{fileURLToPath as ju}from"node:url";var bu=h.object({id:h.string().min(1).max(64),op:h.literal("filter"),cmd:h.string().min(1).max(2048),plan:h.enum(["trial","smart","pro"]),allowed:h.array(h.string().min(1).max(64)).max(512).optional(),installId:h.string().min(1).max(64).optional()}),xu=h.object({id:h.string().min(1).max(64),op:h.literal("ping")}),Eu=h.object({id:h.string().min(1).max(64),op:h.literal("shutdown"),installId:h.string().min(1).max(64)}),wu=h.object({id:h.string().min(1).max(64),op:h.literal("reload"),installId:h.string().min(1).max(64).optional()}),fm=h.discriminatedUnion("op",[bu,xu,Eu,wu]),pm=h.object({id:h.string(),ok:h.literal(!0),data:h.unknown()}),mm=h.object({id:h.string(),ok:h.literal(!1),err:h.string(),retryAfterMs:h.number().int().nonnegative().optional()}),Fs=h.object({filter:Ze.nullable(),cacheHit:h.boolean().optional()}),At=`
41
+ `,hm=64*1024;function cr(t){return JSON.stringify(t)+At}function*Bs(t){let e=0;for(;;){let r=t.indexOf(At,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function st(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import ku from"node:os";import{join as it}from"node:path";import{existsSync as Su,statSync as Tu,lstatSync as js,unlinkSync as Au,mkdirSync as Ru,chmodSync as Cu}from"node:fs";import{createHash as Iu}from"node:crypto";var ur=100;function $u(t){let e=Iu("sha256").update(T()).digest("hex").slice(0,8),r=it(ku.tmpdir(),`tkr-${t}-${e}`),n=it(r,"d.sock");if(Buffer.byteLength(n)>ur)throw new Error("Temporary directory path is too long for IPC");return zs(r,t),n}function Ou(t,e){try{let r=js(t);return r.isDirectory()&&r.uid===e&&(r.mode&63)===0}catch{return!1}}function zs(t,e){Ru(t,{recursive:!0,mode:448});let r=js(t);if(!r.isDirectory()||r.uid!==e)throw new Error("Unsafe IPC directory");Cu(t,448)}function ot(){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&&Ou(e,t)){let s=it(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=ur)return{path:s,isPipe:!1}}let r=it(T(),"run"),n=it(r,"daemon.sock");return Buffer.byteLength(n)>ur?{path:$u(t),isPipe:!1}:(zs(r,t),{path:n,isPipe:!1})}async function lr(){let{path:t,isPipe:e}=ot();if(e||!Su(t))return;try{if(!Tu(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let i=r.createConnection(t),o=a=>{i.removeAllListeners();try{i.destroy()}catch{}s(a)};i.once("connect",()=>o(!0)),i.once("error",a=>{let u=a.code;o(u!=="ECONNREFUSED"&&u!=="ENOENT")}),setTimeout(()=>o(!0),250)}))try{Au(t)}catch{}}var Em=5*6e4;var Vs=500,zu=3e3,Us=1,Zu=6e4,Uu=256*1024;function yr(){return gr(T(),"daemon.spawn.fail")}function _r(){return gr(T(),"daemon.log")}function Hu(){try{let t=Number(Du(yr(),"utf8"));return Number.isFinite(t)&&Date.now()-t<Zu}catch{return!1}}function Vu(t){try{hr(T(),{recursive:!0});let e=_r();try{Fu(e).size>Uu&&pr(e)}catch{}Mu(e,`${new Date().toISOString()} ${t}
42
+ `)}catch{}}function Ku(t){try{hr(T(),{recursive:!0}),mr(yr(),String(Date.now()))}catch{}Vu(`spawn failed: ${t.message}`)}function Gu(){try{Lu(yr(),{force:!0})}catch{}}async function Rt(t,e){return new Promise((r,n)=>{let s=Nu(t),i=a=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(o),a){try{s.destroy()}catch{}n(a)}else r(s)},o=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",a=>i(a))})}function Wu(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:ju(new URL("../bin/tkr-daemon.js",import.meta.url))}async function fr(t,e=3e3){let r=Math.ceil(e/75),n=process.platform==="win32";for(let s=0;s<r;s++){if(n)try{return(await Rt(t,75)).destroy(),!0}catch{}else if(Hs(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function qu(t){let e=Wu();if(!Hs(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=ot(),n=process.platform==="win32"?T():Bu(r);try{hr(n,{recursive:!0})}catch{}let s=gr(n,"daemon.spawn.lock"),i=null;try{i=dr(s,"wx"),mr(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await fr(r,5e3))return;try{pr(s)}catch{}try{i=dr(s,"wx"),mr(i,String(process.pid))}catch(u){if(u.code==="EEXIST"){await fr(r,5e3);return}throw u}}else throw o}try{let o=null;try{o=dr(_r(),"a")}catch{}if(Pu(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{Zs(o)}catch{}if(!await fr(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{Zs(i)}catch{}try{pr(s)}catch{}}}}async function Yu(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:ot(),r=await tr();try{let n=await Rt(e,Vs);n.write(cr({id:st(),op:"shutdown",installId:r})),await new Promise(s=>setTimeout(s,150));try{n.destroy()}catch{}return!0}catch{return!1}}async function Ju(t,e){let r=Date.now()+e;for(;Date.now()<r;){try{(await Rt(t,250)).destroy()}catch{return!0}await new Promise(n=>setTimeout(n,100))}return!1}async function vr(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:ot(),r=await tr(),n=null,s=0,i=!1;for(;s<=Us;)try{n=await Rt(e,Vs),Gu();break}catch{if(s+=1,s>Us)throw new Error(`tkr-daemon unreachable at ${e}`);if(Hu())throw new Error(`tkr-daemon spawn on cooldown (see ${_r()})`);await lr();try{await qu(r),i=!0}catch(l){throw Ku(l),l}}if(!n)throw new Error("tkr-daemon: socket setup failed");let o=new Map,a="";n.setEncoding("utf8"),n.on("data",l=>{a+=l;let f=-1;for(let m=0;m<a.length;m++)a[m]===At&&(f=m);if(f<0)return;let d=[];for(let m of Bs(a.slice(0,f+1)))d.push(m);a=a.slice(f+1);for(let m of d)if(m)try{let _=JSON.parse(m),E=o.get(_.id);if(!E)continue;clearTimeout(E.timer),o.delete(_.id),E.resolve(_)}catch{}}),n.on("close",()=>{for(let l of o.values())clearTimeout(l.timer),l.reject(new Error("daemon socket closed"));o.clear()}),n.on("error",()=>{});function u(l){return new Promise((f,d)=>{let m=setTimeout(()=>{o.delete(l.id),d(new Error(`daemon request timeout (${l.op})`))},zu);o.set(l.id,{resolve:f,reject:d,timer:m}),n.write(cr(l))})}let c={filter:async(l,f,d)=>{let m=await u({id:st(),op:"filter",cmd:l.slice(0,2048),plan:f,...d&&d.length>0?{allowed:d.slice(0,512)}:{},installId:r});if(!m.ok)return null;let _=Fs.safeParse(m.data);return _.success?_.data.filter:null},ping:async()=>{let l=await u({id:st(),op:"ping"});if(!l.ok)throw new Error(l.err);return l.data},reload:async()=>{let l=await u({id:st(),op:"reload",installId:r});if(!l.ok)throw new Error(l.err);return l.data},close:()=>{try{n.end()}catch{}}};if(!t.skipVersionCheck&&!i){let l=!1;try{l=(await c.ping()).version!==rr}catch{}if(l){try{await Yu(t.socketPath?{socketPath:t.socketPath}:{})}catch{}c.close();let f=await Ju(e,2e3);if(await lr(),!f)throw new Error("stale daemon still running after shutdown request");return vr({...t,skipVersionCheck:!0})}}return c}import{createPublicKey as al,verify as cl}from"node:crypto";import{createCipheriv as Lm,createDecipheriv as Xu,hkdfSync as Qu,randomBytes as Fm}from"node:crypto";var el=Buffer.from("tokmizer-bundle-enc-v1"),tl=Buffer.from("rules-bundle");function rl(t){return Buffer.from(Qu("sha256",Buffer.from(t,"utf8"),el,tl,32))}function Ks(t,e){let r=rl(e),n=Buffer.from(t,"base64url"),s=n.subarray(0,12),i=n.subarray(12,28),o=n.subarray(28),a=Xu("aes-256-gcm",r,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}import{chmodSync as zm,readFileSync as nl,writeFileSync as Zm,mkdirSync as Um,renameSync as Hm}from"node:fs";import{join as sl}from"node:path";var il=h.object({payload:h.string().min(1),signature:h.string().min(1),enc:h.literal("v1"),fetchedAt:h.number().int().nonnegative()});function ol(){return sl(T(),"bundle-cache.json")}function Gs(){try{let t=nl(ol(),"utf8"),e=il.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var ul=h.object({bundleVersion:h.number().int().nonnegative(),signedAt:h.number().int(),filters:h.array(Ze)}),sh=h.object({payload:h.string().min(1),signature:h.string().min(1),enc:h.literal("v1")}),ll=10080*60*1e3;function dl(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:ll}function fl(t,e){let r=ms();if(!r||!r.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 n=al({key:r,format:"pem"});if(!cl(null,Buffer.from(t.payload,"utf8"),n,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(Ks(t.payload,e))}function pl(t,e){let r=fl(t,e),n=ul.parse(r);if(Date.now()-n.signedAt>dl())throw new Error("tkr-daemon: rules bundle is stale");let s=new Map;for(let i of n.filters)s.set(i.slug,{...i,matchRegex:new RegExp(i.match_command)});return Dn(),{bundleVersion:n.bundleVersion,signedAt:n.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>vt(i,s.values(),a&&a.length>0?new Set(a):null)}}async function Ws(){try{let t=Gs();if(!t)return null;let e=await tt();return e?.signingSecret?pl(t,e.signingSecret):null}catch{return null}}var Ve=null,at=null;async function ml(){if(Ve)return Ve;if(at)return at;let t=vr().then(e=>{if(at===t)return Ve=e,e;try{e.close()}catch{}return null}).catch(()=>null);return at=t,t}var br=null,xr=!1;async function hl(){return xr||(xr=!0,br=await Ws()),br}async function qs(t,e,r){let n=await hl();if(!n)return null;let s=n.selectFor(t,e,[...r]);return!s||!r.has(G(s.slug))?null:s}function gl(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Ys(t){Xt(async(e,r)=>{let n=t==="free"?"trial":t,s=r??_t(void 0),i=await ml();if(!i)return qs(e,n,s);try{let o=await i.filter(e,n,[...s]);return!o||!s.has(G(o.slug))?null:gl(o)}catch{return qs(e,n,s)}})}function Js(){if(Xt(null),Ve)try{Ve.close()}catch{}Ve=null,at=null,br=null,xr=!1}import{chmod as vl,mkdir as bl,readFile as gh,writeFile as xl,stat as yh,readdir as _h,rm as Xs,rename as El}from"node:fs/promises";import{createHash as Qs}from"node:crypto";import{readFileSync as yl}from"node:fs";import{join as _l}from"node:path";function le(){try{return yl(_l(T(),"yolo-mode"),"utf8")==="on"}catch{return!1}}var Eh=10080*60*1e3,wh=100*1024*1024,wl=2*1024*1024,kl=/^[0-9a-f]{8,64}$/i;function Sl(t,e){let r=Number(process.env[t]);return Number.isFinite(r)&&r>0?r:e}async function ei(t,e){if(le()||!kl.test(t)||Buffer.byteLength(e,"utf8")>Sl("TOKMIZER_CCR_ENTRY_MAX_BYTES",wl))return!1;let r=as(t),n=`${r}.tmp-${process.pid}-${process.hrtime.bigint()}`;try{return await bl(er(),{recursive:!0}),le()?!1:(await xl(n,e,{mode:384}),await vl(n,384),le()?(await Xs(n,{force:!0}),!1):(await El(n,r),!0))}catch{try{await Xs(n)}catch{}return!1}}async function ti(t,e){let r=process.env.TOKMIZER_CCR_DISABLED;if(r==="1"||r==="true"||le()||!t)return e;let n=Qs("sha256").update(t).digest("hex").slice(0,16),s=`
43
+ [tkr restore ${n}]`;return Buffer.byteLength(t,"utf8")<=Buffer.byteLength(s,"utf8")||!await ei(n,t)?e:`${e}${s}`}async function ri(t,e){let r=process.env.TOKMIZER_CCR_DISABLED;if(r==="1"||r==="true"||le()||!t)return e;let n=Qs("sha256").update(t).digest("hex").slice(0,16);return await ei(n,t)?`${e}
44
+ [tkr restore ${n}]`:e}var ni=16*1024*1024,Tl=6e5,Al=1500,Rl=new Set(["npm","pnpm","yarn","bun"]),Cl=new Set(["dev","start","serve","preview","watch"]);function ii(t,e){let r=process.env[t];if(r==null||r==="")return e;let n=Number(r);return Number.isFinite(n)?n:e}function Il(){return ii("TOKMIZER_SHIM_STREAM_AFTER_MS",process.stdout.isTTY?Al:0)}function $l(t,e){let r=t.split(/[\\/]/).pop()??t;return Rl.has(r)?e.some(n=>!n.startsWith("-")&&Cl.has(n)):!1}function oi(t){return t[0]==="--as"&&typeof t[1]=="string"?{cmdName:t[1],args:t.slice(2)}:t.length>0?{cmdName:t[0],args:t.slice(1)}:{cmdName:"",args:[]}}async function ai(t){let{cmdName:e,args:r}=t;if(!e)return process.stderr.write(`tkr-shim: missing command name
45
+ `),{exitCode:2,filteredOut:"",filteredErr:"",filterId:null,rawBytes:0,filteredBytes:0};let n=[e,...r].join(" "),s=le(),i=await rt(),o=await tt(),a=o?us(o):null,u=o?_t(o.allowedFilters,cs(o)):new Set,c=new Set(i.filters.disabled.map(G)),l=c.size>0?new Set([...u].filter(R=>!c.has(R))):u,f=Cs().host,d=!process.stdout.isTTY&&f==="shell",m=!i.enabled||!o||As(f),_=$l(e,r);o&&!m&&!d&&!_&&Ys(a);let E,A;try{return await new Promise(R=>{let N=(0,si.default)(e,r,{stdio:_?"inherit":["inherit","pipe","pipe"],shell:!1,windowsHide:!0,env:Ps()}),U=[],P=[],H=0,C=0,J=!1,V=_,Ct=ii("TOKMIZER_SHIM_TIMEOUT_MS",Tl),Ke=Il(),re,de,wr=()=>{re&&clearTimeout(re),de&&clearTimeout(de),re=void 0,de=void 0},ui=()=>{if(!V){V=!0,re&&clearTimeout(re),re=void 0;for(let I of U)process.stdout.write(I);for(let I of P)process.stderr.write(I);U.length=0,P.length=0}},It=()=>{V||Ke<=0||(de&&clearTimeout(de),de=setTimeout(ui,Ke),de.unref?.())};!V&&Ct>0&&(re=setTimeout(()=>N.kill("SIGTERM"),Ct),re.unref?.()),It();let kr=I=>{try{N.kill(I)}catch{}};E=()=>kr("SIGINT"),A=()=>kr("SIGTERM"),process.on("SIGINT",E),process.on("SIGTERM",A),N.stdout?.on("data",I=>{if(H+=I.length,V){process.stdout.write(I);return}if(H>ni){if(!J){for(let $e of U)process.stdout.write($e);U.length=0,J=!0}process.stdout.write(I);return}U.push(I),It()}),N.stderr?.on("data",I=>{if(C+=I.length,V){process.stderr.write(I);return}if(C>ni){if(!J){for(let $e of P)process.stderr.write($e);P.length=0,J=!0}process.stderr.write(I);return}P.push(I),It()}),N.on("error",I=>{wr(),process.stderr.write(`tkr-shim: ${I.message}
46
+ `),R({exitCode:127,filteredOut:"",filteredErr:"",filterId:null,rawBytes:0,filteredBytes:0})}),N.on("close",async(I,$e)=>{wr();let Ge=typeof I=="number"?I:$e==="SIGTERM"?143:$e==="SIGINT"?130:1,fe=Buffer.concat(U),pe=Buffer.concat(P);if(J||V||m||d){fe.length&&process.stdout.write(fe),pe.length&&process.stderr.write(pe),R({exitCode:Ge,filteredOut:fe.toString("utf8"),filteredErr:pe.toString("utf8"),filterId:null,rawBytes:H+C,filteredBytes:H+C});return}let ct=fe.toString("utf8"),ut=pe.toString("utf8");try{let D=await Qt(n,ct,l,{verbosity:i.outputVerbosity,yolo:s,exitCode:Ge}),lt=s&&ut?await Qt(n,ut,l,{verbosity:i.outputVerbosity,yolo:s,exitCode:Ge}):null,Sr=D.filteredBytes<D.rawBytes,Tr=Sr||lt!=null&&lt.filteredBytes<lt.rawBytes,dt=lt?.output??ut,We=ct;if(Sr&&(We=D.output,!s))try{We=new RegExp(zn.source,"m").test(D.output)?await ri(ct,D.output):await ti(D.droppedTail??null,D.output)}catch{}let Ar=fe.length+pe.length,qe=Ts(Ar,Tr?Buffer.byteLength(We,"utf8")+Buffer.byteLength(dt,"utf8"):Ar,Rs(f));Ss(qe.raw,qe.filtered,void 0,!1,f,"sh",ks(n));try{await vs({cmd:n,filterId:D.filterId,rawBytes:D.rawBytes,filteredBytes:D.filteredBytes,plan:a}),await _s({cmd:n,tokensSaved:Math.max(0,Math.round((qe.raw-qe.filtered)/4)),rawTokens:Math.round(qe.raw/4),optimized:D.filterId!=null,telemetryOptIn:i.telemetryOptIn,sessionId:process.env.CLAUDE_CODE_SESSION_ID,host:f})}catch{}if(Tr){process.stdout.write(We),dt&&process.stderr.write(dt),R({exitCode:Ge,filteredOut:We,filteredErr:dt,filterId:D.filterId,rawBytes:D.rawBytes,filteredBytes:D.filteredBytes});return}}catch{}fe.length&&process.stdout.write(fe),pe.length&&process.stderr.write(pe),R({exitCode:Ge,filteredOut:ct,filteredErr:ut,filterId:null,rawBytes:H+C,filteredBytes:H+C})})})}finally{E&&process.off("SIGINT",E),A&&process.off("SIGTERM",A),Js()}}function ci(t=process.stdout,e=r=>process.exit(r)){t.on("error",r=>{if(r.code==="EPIPE"){e(141);return}throw r})}ci();var Er=oi(process.argv.slice(2));Er.cmdName&&Ms(Ls(),Er.cmdName).catch(()=>{});ai(Er).then(t=>{process.exitCode=t.exitCode}).catch(t=>{process.stderr.write(`tkr-shim: ${t.message}
32
47
  `),process.exitCode=1});