@tokmizer/plugin 0.5.8 → 0.5.10

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,21 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
3
- var gn=Object.defineProperty;var w=(t,e)=>()=>(t&&(e=t(t=0)),e);var yn=(t,e)=>{for(var r in e)gn(t,r,{get:e[r],enumerable:!0})};var b,ht,f,z,$e=w(()=>{(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 a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(let o of i)a[o]=s[o];return t.objectValues(a)},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 a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},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(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(b||(b={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(ht||(ht={}));f=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}}});var u,_n,D,We=w(()=>{$e();u=b.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"]),_n=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),D=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=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 a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(a))):o[l]=o[l]||{_errors:[]},o=o[l],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,b.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()}};D.create=t=>new D(t)});var vn,V,gt=w(()=>{We();$e();vn=(t,e)=>{let r;switch(t.code){case u.invalid_type:t.received===f.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:r="Invalid function arguments";break;case u.invalid_return_type:r="Invalid function return type";break;case u.invalid_date:r="Invalid date";break;case u.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}"`:b.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case u.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 u.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 u.custom:r="Invalid input";break;case u.invalid_intersection_types:r="Intersection results could not be merged";break;case u.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:r="Number must be finite";break;default:r=e.defaultError,b.assertNever(t)}return{message:r}},V=vn});function xn(t){jt=t}function ve(){return jt}var jt,qe=w(()=>{gt();jt=V});function d(t,e){let r=ve(),n=Fe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===V?void 0:V].filter(s=>!!s)});t.common.issues.push(n)}var Fe,bn,R,g,re,I,Ye,Je,W,xe,yt=w(()=>{qe();gt();Fe=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},bn=[];R=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 g;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,a=await s.value;n.push({key:i,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return g;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),re=t=>({status:"dirty",value:t}),I=t=>({status:"valid",value:t}),Ye=t=>t.status==="aborted",Je=t=>t.status==="dirty",W=t=>t.status==="valid",xe=t=>typeof Promise<"u"&&t instanceof Promise});var zt=w(()=>{});var p,Zt=w(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}))});function _(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:(a,o)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}function Gt(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 Ln(t){return new RegExp(`^${Gt(t)}$`)}function Kt(t){let e=`${Ut}T${Gt(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 jn(t,e){return!!((e==="v4"||!e)&&Dn.test(t)||(e==="v6"||!e)&&Nn.test(t))}function zn(t,e){if(!An.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 Zn(t,e){return!!((e==="v4"||!e)&&On.test(t)||(e==="v6"||!e)&&Pn.test(t))}function Bn(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(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}function be(t){if(t instanceof O){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=$.create(be(n))}return new O({...t._def,shape:()=>e})}else return t instanceof K?new K({...t._def,type:be(t.element)}):t instanceof $?$.create(be(t.unwrap())):t instanceof B?B.create(be(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>be(e))):t}function vt(t,e){let r=z(t),n=z(e);if(t===e)return{valid:!0,data:t};if(r===f.object&&n===f.object){let s=b.objectKeys(e),i=b.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(let o of i){let c=vt(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(r===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],o=e[i],c=vt(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function Ht(t,e){return new pe({values:t,typeName:y.ZodEnum,..._(e)})}function Vt(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Wt(t,e={},r){return t?Y.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(a=>{if(!a){let o=Vt(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!i){let a=Vt(e,n),o=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:o})}}):Y.create()}var F,Bt,v,kn,wn,En,Sn,Tn,An,Rn,In,Cn,_t,Dn,On,Nn,Pn,Mn,$n,Ut,Fn,q,ne,se,ie,ae,ke,oe,ce,Y,G,j,we,K,O,ue,U,Xe,le,Z,Qe,Ee,Se,et,de,fe,pe,me,J,L,$,B,he,ge,Te,Vn,Le,je,ye,Un,y,Gn,qt,Yt,Kn,Hn,Jt,Wn,qn,Yn,Jn,Xn,Qn,es,ts,rs,ns,ss,is,as,os,cs,us,ls,ds,fs,ps,ms,hs,gs,ys,_s,vs,xs,bs,ks,ws,Es,Ss,Ts,As,Xt=w(()=>{We();qe();Zt();yt();$e();F=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}},Bt=(t,e)=>{if(W(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 D(t.common.issues);return this._error=r,this._error}}};v=class{get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(xe(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:z(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Bt(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return W(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=>W(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:z(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(xe(s)?s:Promise.resolve(s));return Bt(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 a=e(s),o=()=>i.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!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 L({schema:this,typeName:y.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 $.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return K.create(this)}promise(){return J.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new L({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new he({..._(this._def),innerType:this,defaultValue:r,typeName:y.ZodDefault})}brand(){return new Le({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ge({..._(this._def),innerType:this,catchValue:r,typeName:y.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return je.create(this,e)}readonly(){return ye.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},kn=/^c[^\s-]{8,}$/i,wn=/^[0-9a-z]+$/,En=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Sn=/^[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,Tn=/^[a-z0-9_-]{21}$/i,An=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rn=/^[-+]?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)?)??$/,In=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Cn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Dn=/^(?:(?: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])$/,On=/^(?:(?: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])$/,Nn=/^(([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]))$/,Pn=/^(([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])$/,Mn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$n=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ut="((\\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])))",Fn=new RegExp(`^${Ut}$`);q=class t extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.string,received:i.parsedType}),g}let n=new R,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.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),d(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?d(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&d(s,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")In.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"email",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")_t||(_t=new RegExp(Cn,"u")),_t.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"emoji",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Sn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"uuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Tn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"nanoid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")kn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")wn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid2",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")En.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ulid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),d(s,{validation:"url",code:u.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),d(s,{validation:"regex",code:u.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),d(s,{code:u.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),d(s,{code:u.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Kt(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Fn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Ln(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Rn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"duration",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?jn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ip",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?zn(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"jwt",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Zn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cidr",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?$n.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64url",code:u.invalid_string,message:i.message}),n.dirty()):b.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:u.invalid_string,...p.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.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,...p.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,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...p.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...p.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...p.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...p.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...p.errToObj(r)})}nonempty(e){return this.min(1,p.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}};q.create=t=>new q({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,..._(t)});ne=class t extends v{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)!==f.number){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.number,received:i.parsedType}),g}let n,s=new R;for(let i of this._def.checks)i.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.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),d(n,{code:u.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),d(n,{code:u.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Bn(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_finite,message:i.message}),s.dirty()):b.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,p.toString(r))}gt(e,r){return this.setLimit("min",e,!1,p.toString(r))}lte(e,r){return this.setLimit("max",e,!0,p.toString(r))}lt(e,r){return this.setLimit("max",e,!1,p.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.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"&&b.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)}};ne.create=t=>new ne({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,..._(t)});se=class t extends v{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)!==f.bigint)return this._getInvalidInput(e);let n,s=new R;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),d(n,{code:u.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),d(n,{code:u.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),d(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):b.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,p.toString(r))}gt(e,r){return this.setLimit("min",e,!1,p.toString(r))}lte(e,r){return this.setLimit("max",e,!0,p.toString(r))}lt(e,r){return this.setLimit("max",e,!1,p.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:p.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:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:p.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}};se.create=t=>new se({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,..._(t)});ie=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.boolean,received:n.parsedType}),g}return I(e.data)}};ie.create=t=>new ie({typeName:y.ZodBoolean,coerce:t?.coerce||!1,..._(t)});ae=class t extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.date,received:i.parsedType}),g}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_date}),g}let n=new R,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.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),d(s,{code:u.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):b.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:p.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:p.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}};ae.create=t=>new ae({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,..._(t)});ke=class extends v{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.symbol,received:n.parsedType}),g}return I(e.data)}};ke.create=t=>new ke({typeName:y.ZodSymbol,..._(t)});oe=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.undefined,received:n.parsedType}),g}return I(e.data)}};oe.create=t=>new oe({typeName:y.ZodUndefined,..._(t)});ce=class extends v{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.null,received:n.parsedType}),g}return I(e.data)}};ce.create=t=>new ce({typeName:y.ZodNull,..._(t)});Y=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return I(e.data)}};Y.create=t=>new Y({typeName:y.ZodAny,..._(t)});G=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return I(e.data)}};G.create=t=>new G({typeName:y.ZodUnknown,..._(t)});j=class extends v{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.never,received:r.parsedType}),g}};j.create=t=>new j({typeName:y.ZodNever,..._(t)});we=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.void,received:n.parsedType}),g}return I(e.data)}};we.create=t=>new we({typeName:y.ZodVoid,..._(t)});K=class t extends v{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==f.array)return d(r,{code:u.invalid_type,expected:f.array,received:r.parsedType}),g;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(a||o)&&(d(r,{code:a?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?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&&(d(r,{code:u.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&&(d(r,{code:u.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((a,o)=>s.type._parseAsync(new F(r,a,r.path,o)))).then(a=>R.mergeArray(n,a));let i=[...r.data].map((a,o)=>s.type._parseSync(new F(r,a,r.path,o)));return R.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:p.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:p.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:p.toString(r)}})}nonempty(e){return this.min(1,e)}};K.create=(t,e)=>new K({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});O=class t extends v{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=b.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return d(l,{code:u.invalid_type,expected:f.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof j&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||o.push(l);let c=[];for(let l of a){let m=i[l],x=s.data[l];c.push({key:{status:"valid",value:l},value:m._parse(new F(s,x,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof j){let l=this._def.unknownKeys;if(l==="passthrough")for(let m of o)c.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(l==="strict")o.length>0&&(d(s,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let m of o){let x=s.data[m];c.push({key:{status:"valid",value:m},value:l._parse(new F(s,x,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let m of c){let x=await m.key,T=await m.value;l.push({key:x,value:T,alwaysSet:m.alwaysSet})}return l}).then(l=>R.mergeObjectSync(n,l)):R.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return p.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:p.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:y.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 b.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 b.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return be(this)}partial(e){let r={};for(let n of b.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 b.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof $;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return Ht(b.objectKeys(this.shape))}};O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:j.create(),typeName:y.ZodObject,..._(e)});O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:j.create(),typeName:y.ZodObject,..._(e)});O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:j.create(),typeName:y.ZodObject,..._(e)});ue=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(o=>new D(o.ctx.common.issues));return d(r,{code:u.invalid_union,unionErrors:a}),g}if(r.common.async)return Promise.all(n.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},m=c._parseSync({data:r.data,path:r.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(c=>new D(c));return d(r,{code:u.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};ue.create=(t,e)=>new ue({options:t,typeName:y.ZodUnion,..._(e)});U=t=>t instanceof de?U(t.schema):t instanceof L?U(t.innerType()):t instanceof fe?[t.value]:t instanceof pe?t.options:t instanceof me?b.objectValues(t.enum):t instanceof he?U(t._def.innerType):t instanceof oe?[void 0]:t instanceof ce?[null]:t instanceof $?[void 0,...U(t.unwrap())]:t instanceof B?[null,...U(t.unwrap())]:t instanceof Le||t instanceof ye?U(t.unwrap()):t instanceof ge?U(t._def.innerType):[],Xe=class t extends v{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return d(r,{code:u.invalid_type,expected:f.object,received:r.parsedType}),g;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}):(d(r,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}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 a=U(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,..._(n)})}};le=class extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Ye(i)||Ye(a))return g;let o=vt(i.value,a.value);return o.valid?((Je(i)||Je(a))&&r.dirty(),{status:r.value,value:o.data}):(d(n,{code:u.invalid_intersection_types}),g)};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,a])=>s(i,a)):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}))}};le.create=(t,e,r)=>new le({left:t,right:e,typeName:y.ZodIntersection,..._(r)});Z=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return d(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return d(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new F(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>R.mergeArray(r,a)):R.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Z({items:t,typeName:y.ZodTuple,rest:null,..._(e)})};Qe=class t extends v{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!==f.object)return d(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],i=this._def.keyType,a=this._def.valueType;for(let o in n.data)s.push({key:i._parse(new F(n,o,n.path,o)),value:a._parse(new F(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?R.mergeObjectAsync(r,s):R.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof v?new t({keyType:e,valueType:r,typeName:y.ZodRecord,..._(n)}):new t({keyType:q.create(),valueType:e,typeName:y.ZodRecord,..._(r)})}},Ee=class extends v{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!==f.map)return d(n,{code:u.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new F(n,o,n.path,[l,"key"])),value:i._parse(new F(n,c,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,m=await c.value;if(l.status==="aborted"||m.status==="aborted")return g;(l.status==="dirty"||m.status==="dirty")&&r.dirty(),o.set(l.value,m.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of a){let l=c.key,m=c.value;if(l.status==="aborted"||m.status==="aborted")return g;(l.status==="dirty"||m.status==="dirty")&&r.dirty(),o.set(l.value,m.value)}return{status:r.value,value:o}}}};Ee.create=(t,e,r)=>new Ee({valueType:e,keyType:t,typeName:y.ZodMap,..._(r)});Se=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return d(n,{code:u.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(d(n,{code:u.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&&(d(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function a(c){let l=new Set;for(let m of c){if(m.status==="aborted")return g;m.status==="dirty"&&r.dirty(),l.add(m.value)}return{status:r.value,value:l}}let o=[...n.data.values()].map((c,l)=>i._parse(new F(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:p.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:p.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Se.create=(t,e)=>new Se({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});et=class t extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.function)return d(r,{code:u.invalid_type,expected:f.function,received:r.parsedType}),g;function n(o,c){return Fe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ve(),V].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(o,c){return Fe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ve(),V].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof J){let o=this;return I(async function(...c){let l=new D([]),m=await o._def.args.parseAsync(c,i).catch(N=>{throw l.addIssue(n(c,N)),l}),x=await Reflect.apply(a,this,m);return await o._def.returns._def.type.parseAsync(x,i).catch(N=>{throw l.addIssue(s(x,N)),l})})}else{let o=this;return I(function(...c){let l=o._def.args.safeParse(c,i);if(!l.success)throw new D([n(c,l.error)]);let m=Reflect.apply(a,this,l.data),x=o._def.returns.safeParse(m,i);if(!x.success)throw new D([s(m,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(G.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||Z.create([]).rest(G.create()),returns:r||G.create(),typeName:y.ZodFunction,..._(n)})}},de=class extends v{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})}};de.create=(t,e)=>new de({getter:t,typeName:y.ZodLazy,..._(e)});fe=class extends v{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return d(r,{received:r.data,code:u.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};fe.create=(t,e)=>new fe({value:t,typeName:y.ZodLiteral,..._(e)});pe=class t extends v{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:b.joinValues(n),received:r.parsedType,code:u.invalid_type}),g}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 d(r,{received:r.data,code:u.invalid_enum_value,options:n}),g}return I(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})}};pe.create=Ht;me=class extends v{_parse(e){let r=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=b.objectValues(r);return d(n,{expected:b.joinValues(s),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=b.objectValues(r);return d(n,{received:n.data,code:u.invalid_enum_value,options:s}),g}return I(e.data)}get enum(){return this._def.values}};me.create=(t,e)=>new me({values:t,typeName:y.ZodNativeEnum,..._(e)});J=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.promise&&r.common.async===!1)return d(r,{code:u.invalid_type,expected:f.promise,received:r.parsedType}),g;let n=r.parsedType===f.promise?r.data:Promise.resolve(r.data);return I(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};J.create=(t,e)=>new J({type:t,typeName:y.ZodPromise,..._(e)});L=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.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:a=>{d(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?re(c.value):r.value==="dirty"?re(c.value):c});{if(r.value==="aborted")return g;let o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?re(o.value):r.value==="dirty"?re(o.value):o}}if(s.type==="refinement"){let a=o=>{let c=s.refinement(o,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 o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!W(a))return g;let o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>W(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:r.value,value:o})):g);b.assertNever(s)}};L.create=(t,e,r)=>new L({schema:t,typeName:y.ZodEffects,effect:e,..._(r)});L.createWithPreprocess=(t,e,r)=>new L({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,..._(r)});$=class extends v{_parse(e){return this._getType(e)===f.undefined?I(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:y.ZodOptional,..._(e)});B=class extends v{_parse(e){return this._getType(e)===f.null?I(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(t,e)=>new B({innerType:t,typeName:y.ZodNullable,..._(e)});he=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};he.create=(t,e)=>new he({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});ge=class extends v{_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 xe(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new D(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new D(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});Te=class extends v{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};Te.create=t=>new Te({typeName:y.ZodNaN,..._(t)});Vn=Symbol("zod_brand"),Le=class extends v{_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}},je=class t extends v{_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"?g:i.status==="dirty"?(r.dirty(),re(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"?g: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:y.ZodPipeline})}},ye=class extends v{_parse(e){let r=this._def.innerType._parse(e),n=s=>(W(s)&&(s.value=Object.freeze(s.value)),s);return xe(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};ye.create=(t,e)=>new ye({innerType:t,typeName:y.ZodReadonly,..._(e)});Un={object:O.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(y||(y={}));Gn=(t,e={message:`Input not instance of ${t.name}`})=>Wt(r=>r instanceof t,e),qt=q.create,Yt=ne.create,Kn=Te.create,Hn=se.create,Jt=ie.create,Wn=ae.create,qn=ke.create,Yn=oe.create,Jn=ce.create,Xn=Y.create,Qn=G.create,es=j.create,ts=we.create,rs=K.create,ns=O.create,ss=O.strictCreate,is=ue.create,as=Xe.create,os=le.create,cs=Z.create,us=Qe.create,ls=Ee.create,ds=Se.create,fs=et.create,ps=de.create,ms=fe.create,hs=pe.create,gs=me.create,ys=J.create,_s=L.create,vs=$.create,xs=B.create,bs=L.createWithPreprocess,ks=je.create,ws=()=>qt().optional(),Es=()=>Yt().optional(),Ss=()=>Jt().optional(),Ts={string:(t=>q.create({...t,coerce:!0})),number:(t=>ne.create({...t,coerce:!0})),boolean:(t=>ie.create({...t,coerce:!0})),bigint:(t=>se.create({...t,coerce:!0})),date:(t=>ae.create({...t,coerce:!0}))},As=g});var h={};yn(h,{BRAND:()=>Vn,DIRTY:()=>re,EMPTY_PATH:()=>bn,INVALID:()=>g,NEVER:()=>As,OK:()=>I,ParseStatus:()=>R,Schema:()=>v,ZodAny:()=>Y,ZodArray:()=>K,ZodBigInt:()=>se,ZodBoolean:()=>ie,ZodBranded:()=>Le,ZodCatch:()=>ge,ZodDate:()=>ae,ZodDefault:()=>he,ZodDiscriminatedUnion:()=>Xe,ZodEffects:()=>L,ZodEnum:()=>pe,ZodError:()=>D,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>et,ZodIntersection:()=>le,ZodIssueCode:()=>u,ZodLazy:()=>de,ZodLiteral:()=>fe,ZodMap:()=>Ee,ZodNaN:()=>Te,ZodNativeEnum:()=>me,ZodNever:()=>j,ZodNull:()=>ce,ZodNullable:()=>B,ZodNumber:()=>ne,ZodObject:()=>O,ZodOptional:()=>$,ZodParsedType:()=>f,ZodPipeline:()=>je,ZodPromise:()=>J,ZodReadonly:()=>ye,ZodRecord:()=>Qe,ZodSchema:()=>v,ZodSet:()=>Se,ZodString:()=>q,ZodSymbol:()=>ke,ZodTransformer:()=>L,ZodTuple:()=>Z,ZodType:()=>v,ZodUndefined:()=>oe,ZodUnion:()=>ue,ZodUnknown:()=>G,ZodVoid:()=>we,addIssueToContext:()=>d,any:()=>Xn,array:()=>rs,bigint:()=>Hn,boolean:()=>Jt,coerce:()=>Ts,custom:()=>Wt,date:()=>Wn,datetimeRegex:()=>Kt,defaultErrorMap:()=>V,discriminatedUnion:()=>as,effect:()=>_s,enum:()=>hs,function:()=>fs,getErrorMap:()=>ve,getParsedType:()=>z,instanceof:()=>Gn,intersection:()=>os,isAborted:()=>Ye,isAsync:()=>xe,isDirty:()=>Je,isValid:()=>W,late:()=>Un,lazy:()=>ps,literal:()=>ms,makeIssue:()=>Fe,map:()=>ls,nan:()=>Kn,nativeEnum:()=>gs,never:()=>es,null:()=>Jn,nullable:()=>xs,number:()=>Yt,object:()=>ns,objectUtil:()=>ht,oboolean:()=>Ss,onumber:()=>Es,optional:()=>vs,ostring:()=>ws,pipeline:()=>ks,preprocess:()=>bs,promise:()=>ys,quotelessJson:()=>_n,record:()=>us,set:()=>ds,setErrorMap:()=>xn,strictObject:()=>ss,string:()=>qt,symbol:()=>qn,transformer:()=>_s,tuple:()=>cs,undefined:()=>Yn,union:()=>is,unknown:()=>Qn,util:()=>b,void:()=>ts});var xt=w(()=>{qe();yt();zt();$e();Xt();We()});var tt=w(()=>{xt();xt()});var rt,bt=w(()=>{"use strict";tt();rt=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([]),truncate_lines_at:h.number().int().positive().max(1e4).optional(),max_lines:h.number().int().positive().max(1e5).optional(),transform:h.string().max(64).optional(),on_empty:h.string().max(255).optional()})});import xr from"node:os";import{join as ee}from"node:path";function E(){return process.env.TOKMIZER_HOME||ee(xr.homedir(),".tokmizer")}function Et(){return ee(E(),"install-id")}function br(){return ee(E(),"enroll-cooldown")}function kr(){return ee(E(),"bundle-refresh.json")}function it(){return ee(E(),"skills")}function at(t){return ee(it(),`${t}.md`)}function ot(){return process.env.TOKMIZER_CLAUDE_COMMANDS_DIR||ee(xr.homedir(),".claude","commands")}function ct(t){return ee(ot(),`${t}.md`)}var H=w(()=>{"use strict"});import Ae from"node:os";import{createHash as ni,randomUUID as si}from"node:crypto";import{readFile as ii,writeFile as ai,mkdir as oi}from"node:fs/promises";async function Tt(){try{let r=(await ii(Et(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await oi(E(),{recursive:!0});let t=si();return await ai(Et(),t,{mode:384}),t}function St(t){return ni("sha256").update(t).digest("hex")}function ci(){let t=Ae.networkInterfaces();for(let e of Object.keys(t))for(let r of t[e]??[])if(!r.internal&&r.mac&&r.mac!=="00:00:00:00:00:00")return r.mac;return"no-mac"}async function Re(){let t=await Tt(),e=Ae.hostname(),r=Ae.platform(),n=Ae.release(),s=Ae.cpus(),i=s[0]?.model??"unknown",a=s.length,o=St(ci()),c=St(Ae.userInfo().username),l=[e,r,n,i,String(a),o,c,t].join("|");return{fingerprint:St(l),installId:t,hostname:e,os:r,osVersion:n,cpuModel:i,cpuCores:a,macHash:o,usernameHash:c}}var Ie=w(()=>{"use strict";H()});import{join as wr}from"node:path";import{mkdir as ui,readFile as li,writeFile as di,unlink as uc,rename as fi}from"node:fs/promises";function ut(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function Sr(t){return t?.dir??E()}async function Ce(t){let e=Sr(t);try{let r=await li(wr(e,Er),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??ut(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}async function Tr(t,e){let r=Sr(e);await ui(r,{recursive:!0});let n=wr(r,Er),s=`${n}.tmp`;await di(s,JSON.stringify(t,null,2),{mode:384}),await fi(s,n)}var Er,dc,Ze=w(()=>{"use strict";H();Er="state.json",dc={lastSettingsRevision:0,timeZone:ut(),bonusActive:!1}});import{createRequire as pi}from"node:module";function hi(){for(let t of["../package.json","../../package.json"])try{let e=mi(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var mi,Be,At=w(()=>{"use strict";mi=pi(import.meta.url);Be=hi()});var Ar,Rr=w(()=>{"use strict";Ar=`-----BEGIN PUBLIC KEY-----
3
+ var Rn=Object.defineProperty;var w=(t,e)=>()=>(t&&(e=t(t=0)),e);var In=(t,e)=>{for(var r in e)Rn(t,r,{get:e[r],enumerable:!0})};var x,_t,f,Z,Fe=w(()=>{(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 a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(let o of i)a[o]=s[o];return t.objectValues(a)},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 a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},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(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(x||(x={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(_t||(_t={}));f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Z=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}}});var l,Cn,O,Je=w(()=>{Fe();l=x.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"]),Cn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),O=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 a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,c=0;for(;c<a.path.length;){let u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(a))):o[u]=o[u]||{_errors:[]},o=o[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,x.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()}};O.create=t=>new O(t)});var On,H,vt=w(()=>{Je();Fe();On=(t,e)=>{let r;switch(t.code){case l.invalid_type:t.received===f.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case l.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:r=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case l.invalid_union:r="Invalid input";break;case l.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case l.invalid_enum_value:r=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case l.invalid_arguments:r="Invalid function arguments";break;case l.invalid_return_type:r="Invalid function return type";break;case l.invalid_date:r="Invalid date";break;case l.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}"`:x.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case l.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 l.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 l.custom:r="Invalid input";break;case l.invalid_intersection_types:r="Intersection results could not be merged";break;case l.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case l.not_finite:r="Number must be finite";break;default:r=e.defaultError,x.assertNever(t)}return{message:r}},H=On});function Dn(t){Ut=t}function xe(){return Ut}var Ut,Xe=w(()=>{vt();Ut=H});function d(t,e){let r=xe(),n=je({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===H?void 0:H].filter(s=>!!s)});t.common.issues.push(n)}var je,Pn,R,g,ne,I,Qe,et,q,we,bt=w(()=>{Xe();vt();je=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},Pn=[];R=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 g;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,a=await s.value;n.push({key:i,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return g;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),ne=t=>({status:"dirty",value:t}),I=t=>({status:"valid",value:t}),Qe=t=>t.status==="aborted",et=t=>t.status==="dirty",q=t=>t.status==="valid",we=t=>typeof Promise<"u"&&t instanceof Promise});var Vt=w(()=>{});var p,Ht=w(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}))});function _(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:(a,o)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}function qt(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 Yn(t){return new RegExp(`^${qt(t)}$`)}function Yt(t){let e=`${Wt}T${qt(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 Jn(t,e){return!!((e==="v4"||!e)&&Un.test(t)||(e==="v6"||!e)&&Hn.test(t))}function Xn(t,e){if(!jn.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 Qn(t,e){return!!((e==="v4"||!e)&&Vn.test(t)||(e==="v6"||!e)&&Kn.test(t))}function es(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(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}function ke(t){if(t instanceof D){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=$.create(ke(n))}return new D({...t._def,shape:()=>e})}else return t instanceof W?new W({...t._def,type:ke(t.element)}):t instanceof $?$.create(ke(t.unwrap())):t instanceof U?U.create(ke(t.unwrap())):t instanceof B?B.create(t.items.map(e=>ke(e))):t}function wt(t,e){let r=Z(t),n=Z(e);if(t===e)return{valid:!0,data:t};if(r===f.object&&n===f.object){let s=x.objectKeys(e),i=x.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(let o of i){let c=wt(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(r===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],o=e[i],c=wt(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function Jt(t,e){return new me({values:t,typeName:y.ZodEnum,..._(e)})}function Gt(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Xt(t,e={},r){return t?J.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(a=>{if(!a){let o=Gt(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!i){let a=Gt(e,n),o=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:o})}}):J.create()}var M,Kt,v,Nn,$n,Mn,Ln,Fn,jn,zn,Zn,Bn,xt,Un,Vn,Hn,Kn,Gn,Wn,Wt,qn,Y,se,ie,ae,oe,Ee,ce,le,J,G,F,Se,W,D,ue,K,tt,de,B,rt,Te,Ae,nt,fe,pe,me,he,X,L,$,U,ge,ye,Re,ts,ze,Ze,_e,rs,y,ns,Qt,er,ss,is,tr,as,os,cs,ls,us,ds,fs,ps,ms,hs,gs,ys,_s,vs,bs,xs,ws,ks,Es,Ss,Ts,As,Rs,Is,Cs,Os,Ds,Ps,Ns,$s,Ms,Ls,Fs,js,rr=w(()=>{Je();Xe();Ht();bt();Fe();M=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}},Kt=(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 O(t.common.issues);return this._error=r,this._error}}};v=class{get description(){return this._def.description}_getType(e){return Z(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:Z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(we(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:Z(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Kt(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Z(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:Z(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(we(s)?s:Promise.resolve(s));return Kt(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 a=e(s),o=()=>i.addIssue({code:l.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!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 L({schema:this,typeName:y.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 $.create(this,this._def)}nullable(){return U.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this)}promise(){return X.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new L({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ge({..._(this._def),innerType:this,defaultValue:r,typeName:y.ZodDefault})}brand(){return new ze({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ye({..._(this._def),innerType:this,catchValue:r,typeName:y.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ze.create(this,e)}readonly(){return _e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Nn=/^c[^\s-]{8,}$/i,$n=/^[0-9a-z]+$/,Mn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ln=/^[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,Fn=/^[a-z0-9_-]{21}$/i,jn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zn=/^[-+]?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)?)??$/,Zn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Un=/^(?:(?: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])$/,Vn=/^(?:(?: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])$/,Hn=/^(([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]))$/,Kn=/^(([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])$/,Gn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Wt="((\\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])))",qn=new RegExp(`^${Wt}$`);Y=class t extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let i=this._getOrReturnCtx(e);return d(i,{code:l.invalid_type,expected:f.string,received:i.parsedType}),g}let n=new R,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:l.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),d(s,{code:l.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?d(s,{code:l.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&d(s,{code:l.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"email",code:l.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")xt||(xt=new RegExp(Bn,"u")),xt.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"emoji",code:l.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"uuid",code:l.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Fn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"nanoid",code:l.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid",code:l.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")$n.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid2",code:l.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ulid",code:l.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),d(s,{validation:"url",code:l.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),d(s,{validation:"regex",code:l.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),d(s,{code:l.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),d(s,{code:l.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:l.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Yt(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:l.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?qn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:l.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Yn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:l.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?zn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"duration",code:l.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Jn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ip",code:l.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Xn(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"jwt",code:l.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Qn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cidr",code:l.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Gn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64",code:l.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Wn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64url",code:l.invalid_string,message:i.message}),n.dirty()):x.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:l.invalid_string,...p.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.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,...p.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,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...p.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...p.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...p.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...p.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...p.errToObj(r)})}nonempty(e){return this.min(1,p.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}};Y.create=t=>new Y({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,..._(t)});se=class t extends v{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)!==f.number){let i=this._getOrReturnCtx(e);return d(i,{code:l.invalid_type,expected:f.number,received:i.parsedType}),g}let n,s=new R;for(let i of this._def.checks)i.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:l.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),d(n,{code:l.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),d(n,{code:l.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?es(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:l.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:l.not_finite,message:i.message}),s.dirty()):x.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,p.toString(r))}gt(e,r){return this.setLimit("min",e,!1,p.toString(r))}lte(e,r){return this.setLimit("max",e,!0,p.toString(r))}lt(e,r){return this.setLimit("max",e,!1,p.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.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"&&x.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)}};se.create=t=>new se({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,..._(t)});ie=class t extends v{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)!==f.bigint)return this._getInvalidInput(e);let n,s=new R;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),d(n,{code:l.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),d(n,{code:l.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),d(n,{code:l.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):x.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:l.invalid_type,expected:f.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,p.toString(r))}gt(e,r){return this.setLimit("min",e,!1,p.toString(r))}lte(e,r){return this.setLimit("max",e,!0,p.toString(r))}lt(e,r){return this.setLimit("max",e,!1,p.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:p.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:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:p.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}};ie.create=t=>new ie({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,..._(t)});ae=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return d(n,{code:l.invalid_type,expected:f.boolean,received:n.parsedType}),g}return I(e.data)}};ae.create=t=>new ae({typeName:y.ZodBoolean,coerce:t?.coerce||!1,..._(t)});oe=class t extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let i=this._getOrReturnCtx(e);return d(i,{code:l.invalid_type,expected:f.date,received:i.parsedType}),g}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return d(i,{code:l.invalid_date}),g}let n=new R,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:l.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),d(s,{code:l.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):x.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:p.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:p.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}};oe.create=t=>new oe({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,..._(t)});Ee=class extends v{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return d(n,{code:l.invalid_type,expected:f.symbol,received:n.parsedType}),g}return I(e.data)}};Ee.create=t=>new Ee({typeName:y.ZodSymbol,..._(t)});ce=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:l.invalid_type,expected:f.undefined,received:n.parsedType}),g}return I(e.data)}};ce.create=t=>new ce({typeName:y.ZodUndefined,..._(t)});le=class extends v{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return d(n,{code:l.invalid_type,expected:f.null,received:n.parsedType}),g}return I(e.data)}};le.create=t=>new le({typeName:y.ZodNull,..._(t)});J=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return I(e.data)}};J.create=t=>new J({typeName:y.ZodAny,..._(t)});G=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return I(e.data)}};G.create=t=>new G({typeName:y.ZodUnknown,..._(t)});F=class extends v{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:l.invalid_type,expected:f.never,received:r.parsedType}),g}};F.create=t=>new F({typeName:y.ZodNever,..._(t)});Se=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:l.invalid_type,expected:f.void,received:n.parsedType}),g}return I(e.data)}};Se.create=t=>new Se({typeName:y.ZodVoid,..._(t)});W=class t extends v{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==f.array)return d(r,{code:l.invalid_type,expected:f.array,received:r.parsedType}),g;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(a||o)&&(d(r,{code:a?l.too_big:l.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?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&&(d(r,{code:l.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&&(d(r,{code:l.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((a,o)=>s.type._parseAsync(new M(r,a,r.path,o)))).then(a=>R.mergeArray(n,a));let i=[...r.data].map((a,o)=>s.type._parseSync(new M(r,a,r.path,o)));return R.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:p.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:p.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:p.toString(r)}})}nonempty(e){return this.min(1,e)}};W.create=(t,e)=>new W({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});D=class t extends v{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=x.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==f.object){let u=this._getOrReturnCtx(e);return d(u,{code:l.invalid_type,expected:f.object,received:u.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(let u in s.data)a.includes(u)||o.push(u);let c=[];for(let u of a){let m=i[u],b=s.data[u];c.push({key:{status:"valid",value:u},value:m._parse(new M(s,b,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof F){let u=this._def.unknownKeys;if(u==="passthrough")for(let m of o)c.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(u==="strict")o.length>0&&(d(s,{code:l.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let m of o){let b=s.data[m];c.push({key:{status:"valid",value:m},value:u._parse(new M(s,b,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let m of c){let b=await m.key,T=await m.value;u.push({key:b,value:T,alwaysSet:m.alwaysSet})}return u}).then(u=>R.mergeObjectSync(n,u)):R.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return p.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:p.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:y.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 x.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 x.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return ke(this)}partial(e){let r={};for(let n of x.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 x.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof $;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return Jt(x.objectKeys(this.shape))}};D.create=(t,e)=>new D({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,..._(e)});D.strictCreate=(t,e)=>new D({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:y.ZodObject,..._(e)});D.lazycreate=(t,e)=>new D({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,..._(e)});ue=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(o=>new O(o.ctx.common.issues));return d(r,{code:l.invalid_union,unionErrors:a}),g}if(r.common.async)return Promise.all(n.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},m=c._parseSync({data:r.data,path:r.path,parent:u});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(c=>new O(c));return d(r,{code:l.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};ue.create=(t,e)=>new ue({options:t,typeName:y.ZodUnion,..._(e)});K=t=>t instanceof fe?K(t.schema):t instanceof L?K(t.innerType()):t instanceof pe?[t.value]:t instanceof me?t.options:t instanceof he?x.objectValues(t.enum):t instanceof ge?K(t._def.innerType):t instanceof ce?[void 0]:t instanceof le?[null]:t instanceof $?[void 0,...K(t.unwrap())]:t instanceof U?[null,...K(t.unwrap())]:t instanceof ze||t instanceof _e?K(t.unwrap()):t instanceof ye?K(t._def.innerType):[],tt=class t extends v{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return d(r,{code:l.invalid_type,expected:f.object,received:r.parsedType}),g;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}):(d(r,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}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 a=K(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,..._(n)})}};de=class extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Qe(i)||Qe(a))return g;let o=wt(i.value,a.value);return o.valid?((et(i)||et(a))&&r.dirty(),{status:r.value,value:o.data}):(d(n,{code:l.invalid_intersection_types}),g)};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,a])=>s(i,a)):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}))}};de.create=(t,e,r)=>new de({left:t,right:e,typeName:y.ZodIntersection,..._(r)});B=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return d(n,{code:l.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return d(n,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new M(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>R.mergeArray(r,a)):R.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};B.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new B({items:t,typeName:y.ZodTuple,rest:null,..._(e)})};rt=class t extends v{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!==f.object)return d(n,{code:l.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],i=this._def.keyType,a=this._def.valueType;for(let o in n.data)s.push({key:i._parse(new M(n,o,n.path,o)),value:a._parse(new M(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?R.mergeObjectAsync(r,s):R.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof v?new t({keyType:e,valueType:r,typeName:y.ZodRecord,..._(n)}):new t({keyType:Y.create(),valueType:e,typeName:y.ZodRecord,..._(r)})}},Te=class extends v{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!==f.map)return d(n,{code:l.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new M(n,o,n.path,[u,"key"])),value:i._parse(new M(n,c,n.path,[u,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of a){let u=await c.key,m=await c.value;if(u.status==="aborted"||m.status==="aborted")return g;(u.status==="dirty"||m.status==="dirty")&&r.dirty(),o.set(u.value,m.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of a){let u=c.key,m=c.value;if(u.status==="aborted"||m.status==="aborted")return g;(u.status==="dirty"||m.status==="dirty")&&r.dirty(),o.set(u.value,m.value)}return{status:r.value,value:o}}}};Te.create=(t,e,r)=>new Te({valueType:e,keyType:t,typeName:y.ZodMap,..._(r)});Ae=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return d(n,{code:l.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(d(n,{code:l.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&&(d(n,{code:l.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function a(c){let u=new Set;for(let m of c){if(m.status==="aborted")return g;m.status==="dirty"&&r.dirty(),u.add(m.value)}return{status:r.value,value:u}}let o=[...n.data.values()].map((c,u)=>i._parse(new M(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:p.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:p.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Ae.create=(t,e)=>new Ae({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});nt=class t extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.function)return d(r,{code:l.invalid_type,expected:f.function,received:r.parsedType}),g;function n(o,c){return je({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xe(),H].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:c}})}function s(o,c){return je({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xe(),H].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof X){let o=this;return I(async function(...c){let u=new O([]),m=await o._def.args.parseAsync(c,i).catch(P=>{throw u.addIssue(n(c,P)),u}),b=await Reflect.apply(a,this,m);return await o._def.returns._def.type.parseAsync(b,i).catch(P=>{throw u.addIssue(s(b,P)),u})})}else{let o=this;return I(function(...c){let u=o._def.args.safeParse(c,i);if(!u.success)throw new O([n(c,u.error)]);let m=Reflect.apply(a,this,u.data),b=o._def.returns.safeParse(m,i);if(!b.success)throw new O([s(m,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:B.create(e).rest(G.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||B.create([]).rest(G.create()),returns:r||G.create(),typeName:y.ZodFunction,..._(n)})}},fe=class extends v{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})}};fe.create=(t,e)=>new fe({getter:t,typeName:y.ZodLazy,..._(e)});pe=class extends v{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return d(r,{received:r.data,code:l.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};pe.create=(t,e)=>new pe({value:t,typeName:y.ZodLiteral,..._(e)});me=class t extends v{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:x.joinValues(n),received:r.parsedType,code:l.invalid_type}),g}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 d(r,{received:r.data,code:l.invalid_enum_value,options:n}),g}return I(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})}};me.create=Jt;he=class extends v{_parse(e){let r=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=x.objectValues(r);return d(n,{expected:x.joinValues(s),received:n.parsedType,code:l.invalid_type}),g}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=x.objectValues(r);return d(n,{received:n.data,code:l.invalid_enum_value,options:s}),g}return I(e.data)}get enum(){return this._def.values}};he.create=(t,e)=>new he({values:t,typeName:y.ZodNativeEnum,..._(e)});X=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.promise&&r.common.async===!1)return d(r,{code:l.invalid_type,expected:f.promise,received:r.parsedType}),g;let n=r.parsedType===f.promise?r.data:Promise.resolve(r.data);return I(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};X.create=(t,e)=>new X({type:t,typeName:y.ZodPromise,..._(e)});L=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.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:a=>{d(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?ne(c.value):r.value==="dirty"?ne(c.value):c});{if(r.value==="aborted")return g;let o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?ne(o.value):r.value==="dirty"?ne(o.value):o}}if(s.type==="refinement"){let a=o=>{let c=s.refinement(o,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 o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!q(a))return g;let o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>q(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:r.value,value:o})):g);x.assertNever(s)}};L.create=(t,e,r)=>new L({schema:t,typeName:y.ZodEffects,effect:e,..._(r)});L.createWithPreprocess=(t,e,r)=>new L({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,..._(r)});$=class extends v{_parse(e){return this._getType(e)===f.undefined?I(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:y.ZodOptional,..._(e)});U=class extends v{_parse(e){return this._getType(e)===f.null?I(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};U.create=(t,e)=>new U({innerType:t,typeName:y.ZodNullable,..._(e)});ge=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});ye=class extends v{_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 we(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new O(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new O(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ye.create=(t,e)=>new ye({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});Re=class extends v{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return d(n,{code:l.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};Re.create=t=>new Re({typeName:y.ZodNaN,..._(t)});ts=Symbol("zod_brand"),ze=class extends v{_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}},Ze=class t extends v{_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"?g:i.status==="dirty"?(r.dirty(),ne(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"?g: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:y.ZodPipeline})}},_e=class extends v{_parse(e){let r=this._def.innerType._parse(e),n=s=>(q(s)&&(s.value=Object.freeze(s.value)),s);return we(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};_e.create=(t,e)=>new _e({innerType:t,typeName:y.ZodReadonly,..._(e)});rs={object:D.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(y||(y={}));ns=(t,e={message:`Input not instance of ${t.name}`})=>Xt(r=>r instanceof t,e),Qt=Y.create,er=se.create,ss=Re.create,is=ie.create,tr=ae.create,as=oe.create,os=Ee.create,cs=ce.create,ls=le.create,us=J.create,ds=G.create,fs=F.create,ps=Se.create,ms=W.create,hs=D.create,gs=D.strictCreate,ys=ue.create,_s=tt.create,vs=de.create,bs=B.create,xs=rt.create,ws=Te.create,ks=Ae.create,Es=nt.create,Ss=fe.create,Ts=pe.create,As=me.create,Rs=he.create,Is=X.create,Cs=L.create,Os=$.create,Ds=U.create,Ps=L.createWithPreprocess,Ns=Ze.create,$s=()=>Qt().optional(),Ms=()=>er().optional(),Ls=()=>tr().optional(),Fs={string:(t=>Y.create({...t,coerce:!0})),number:(t=>se.create({...t,coerce:!0})),boolean:(t=>ae.create({...t,coerce:!0})),bigint:(t=>ie.create({...t,coerce:!0})),date:(t=>oe.create({...t,coerce:!0}))},js=g});var h={};In(h,{BRAND:()=>ts,DIRTY:()=>ne,EMPTY_PATH:()=>Pn,INVALID:()=>g,NEVER:()=>js,OK:()=>I,ParseStatus:()=>R,Schema:()=>v,ZodAny:()=>J,ZodArray:()=>W,ZodBigInt:()=>ie,ZodBoolean:()=>ae,ZodBranded:()=>ze,ZodCatch:()=>ye,ZodDate:()=>oe,ZodDefault:()=>ge,ZodDiscriminatedUnion:()=>tt,ZodEffects:()=>L,ZodEnum:()=>me,ZodError:()=>O,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>nt,ZodIntersection:()=>de,ZodIssueCode:()=>l,ZodLazy:()=>fe,ZodLiteral:()=>pe,ZodMap:()=>Te,ZodNaN:()=>Re,ZodNativeEnum:()=>he,ZodNever:()=>F,ZodNull:()=>le,ZodNullable:()=>U,ZodNumber:()=>se,ZodObject:()=>D,ZodOptional:()=>$,ZodParsedType:()=>f,ZodPipeline:()=>Ze,ZodPromise:()=>X,ZodReadonly:()=>_e,ZodRecord:()=>rt,ZodSchema:()=>v,ZodSet:()=>Ae,ZodString:()=>Y,ZodSymbol:()=>Ee,ZodTransformer:()=>L,ZodTuple:()=>B,ZodType:()=>v,ZodUndefined:()=>ce,ZodUnion:()=>ue,ZodUnknown:()=>G,ZodVoid:()=>Se,addIssueToContext:()=>d,any:()=>us,array:()=>ms,bigint:()=>is,boolean:()=>tr,coerce:()=>Fs,custom:()=>Xt,date:()=>as,datetimeRegex:()=>Yt,defaultErrorMap:()=>H,discriminatedUnion:()=>_s,effect:()=>Cs,enum:()=>As,function:()=>Es,getErrorMap:()=>xe,getParsedType:()=>Z,instanceof:()=>ns,intersection:()=>vs,isAborted:()=>Qe,isAsync:()=>we,isDirty:()=>et,isValid:()=>q,late:()=>rs,lazy:()=>Ss,literal:()=>Ts,makeIssue:()=>je,map:()=>ws,nan:()=>ss,nativeEnum:()=>Rs,never:()=>fs,null:()=>ls,nullable:()=>Ds,number:()=>er,object:()=>hs,objectUtil:()=>_t,oboolean:()=>Ls,onumber:()=>Ms,optional:()=>Os,ostring:()=>$s,pipeline:()=>Ns,preprocess:()=>Ps,promise:()=>Is,quotelessJson:()=>Cn,record:()=>xs,set:()=>ks,setErrorMap:()=>Dn,strictObject:()=>gs,string:()=>Qt,symbol:()=>os,transformer:()=>Cs,tuple:()=>bs,undefined:()=>cs,union:()=>ys,unknown:()=>ds,util:()=>x,void:()=>ps});var kt=w(()=>{Xe();bt();Vt();Fe();rr();Je()});var st=w(()=>{kt();kt()});var it,Et=w(()=>{"use strict";st();it=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([]),truncate_lines_at:h.number().int().positive().max(1e4).optional(),max_lines:h.number().int().positive().max(1e5).optional(),transform:h.string().max(64).optional(),on_empty:h.string().max(255).optional()})});import{createHash as Ks}from"node:crypto";function j(t){let e=or.get(t);return e||(e=Ks("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),or.set(t,e)),e}function at(t,e=!1){return e||!t||t.length===0?(cr??=new Set(qs.map(j)),new Set(cr)):new Set(t.map(r=>Ys.test(r)?r:j(r)))}var Gs,Ws,St,qs,Ys,or,cr,ve=w(()=>{"use strict";st();Gs=h.enum(["normal","compact","minimal"]),Ws=h.enum(["off","light","balanced","max"]),St=h.object({enabled:h.boolean().default(!0),telemetryOptIn:h.boolean().default(!0),outputVerbosity:Gs.default("compact"),reducer:Ws.default("off"),filters:h.object({enableAll:h.boolean().default(!0),disabled:h.array(h.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),qs=["git","grep","find","ls","ps","cat","head","tail","df","du","tree","wc","read-tool","grep-tool","glob-tool","npm","docker","kubectl","curl","cargo","go-test","gh","aws","dotnet","prisma","tsc","next","jest","vitest","pytest","pip","rspec"],Ys=/^[0-9a-f]{16}$/,or=new Map;cr=null});import Tr from"node:os";import{join as te}from"node:path";function E(){return process.env.TOKMIZER_HOME||te(Tr.homedir(),".tokmizer")}function At(){return te(E(),"install-id")}function Ar(){return te(E(),"enroll-cooldown")}function Rr(){return te(E(),"bundle-refresh.json")}function ct(){return te(E(),"skills")}function lt(t){return te(ct(),`${t}.md`)}function ut(){return process.env.TOKMIZER_CLAUDE_COMMANDS_DIR||te(Tr.homedir(),".claude","commands")}function dt(t){return te(ut(),`${t}.md`)}var V=w(()=>{"use strict"});import Ie from"node:os";import{createHash as bi,randomUUID as xi}from"node:crypto";import{readFile as wi,writeFile as ki,mkdir as Ei}from"node:fs/promises";async function It(){try{let r=(await wi(At(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await Ei(E(),{recursive:!0});let t=xi();return await ki(At(),t,{mode:384}),t}function Rt(t){return bi("sha256").update(t).digest("hex")}function Si(){let t=Ie.networkInterfaces();for(let e of Object.keys(t))for(let r of t[e]??[])if(!r.internal&&r.mac&&r.mac!=="00:00:00:00:00:00")return r.mac;return"no-mac"}async function Ce(){let t=await It(),e=Ie.hostname(),r=Ie.platform(),n=Ie.release(),s=Ie.cpus(),i=s[0]?.model??"unknown",a=s.length,o=Rt(Si()),c=Rt(Ie.userInfo().username),u=[e,r,n,i,String(a),o,c,t].join("|");return{fingerprint:Rt(u),installId:t,hostname:e,os:r,osVersion:n,cpuModel:i,cpuCores:a,macHash:o,usernameHash:c}}var Oe=w(()=>{"use strict";V()});import{join as Ir}from"node:path";import{mkdir as Ti,readFile as Ai,writeFile as Ri,unlink as Dc,rename as Ii}from"node:fs/promises";function ft(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function Or(t){return t?.dir??E()}async function De(t){let e=Or(t);try{let r=await Ai(Ir(e,Cr),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??ft(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}async function Dr(t,e){let r=Or(e);await Ti(r,{recursive:!0});let n=Ir(r,Cr),s=`${n}.tmp`;await Ri(s,JSON.stringify(t,null,2),{mode:384}),await Ii(s,n)}var Cr,Nc,Ue=w(()=>{"use strict";V();Cr="state.json",Nc={lastSettingsRevision:0,timeZone:ft(),bonusActive:!1}});import{createRequire as Ci}from"node:module";function Di(){for(let t of["../package.json","../../package.json"])try{let e=Oi(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Oi,Ve,Ct=w(()=>{"use strict";Oi=Ci(import.meta.url);Ve=Di()});var Pr,Nr=w(()=>{"use strict";Pr=`-----BEGIN PUBLIC KEY-----
4
4
  MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
5
5
  -----END PUBLIC KEY-----
6
- `});import{createHmac as gi,createPublicKey as yi,verify as _i}from"node:crypto";function Rt(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??Ar).replace(/\\n/g,`
7
- `)}function xi(t,e,r,n){try{let s=yi({key:n,format:"pem"});return _i(null,Buffer.from(`${e}.${t}`,"utf8"),s,Buffer.from(r,"base64url"))}catch{return!1}}async function Ve(t){let e=await t.text(),r=Rt(),n=t.headers?.get?.("x-tokmizer-resp-ts")??null;if(n!==null){let a=Number(n);if(!Number.isFinite(a)||Date.now()-a>vi)throw new te("http","stale server response (resp-ts outside freshness window)")}if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new te("http","no signing public key configured; refusing to trust server response");let s=t.headers?.get?.("x-tokmizer-resp-sig")??null,i=Number(n);if(!s||n===null||!Number.isFinite(i))throw new te("http","missing server response signature");if(!xi(e,i,s,r))throw new te("http","invalid server response signature");return JSON.parse(e)}function bi(t,e,r){return gi("sha256",r).update(`${e}.${t}`).digest("hex")}async function De(t,e,r,n){let s=Date.now(),i=r===void 0?"":JSON.stringify(r),a=n.signingSecret?bi(i,s,n.signingSecret):"0".repeat(64),o={"content-type":"application/json","x-tokmizer-fingerprint":n.fingerprint,"x-tokmizer-install-id":n.installId,"x-tokmizer-sig":a,"x-tokmizer-ts":String(s),"x-tokmizer-plugin-version":Be};n.bearer&&(o.authorization=`Bearer ${n.bearer}`);let c=n.timeoutMs??5e3,l=t!=="GET"&&t!=="DELETE",m={method:t,headers:o,signal:AbortSignal.timeout(c)};l&&(m.body=i);try{return await fetch(`${n.baseUrl}${e}`,m)}catch(x){let T=x.name;throw T==="TimeoutError"||T==="AbortError"?new te("timeout",`${t} ${e} timed out after ${c}ms`):new te("network",`${t} ${e} failed: ${x.message}`)}}var vi,te,Ue=w(()=>{"use strict";At();Rr();vi=300*1e3;te=class extends Error{constructor(r,n,s){super(n);this.kind=r;this.status=s;this.name="TransportError"}kind;status}});function Ge(t){let e=t;for(let[r,n]of Vi)e=e.replace(r,n);return e}var Vi,Nt=w(()=>{"use strict";Vi=[[/(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]+-)*(?: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+.-]*:\/\/[^:/\s@]*:)[^\s]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]]});import{join as Br}from"node:path";import{appendFileSync as Ui,existsSync as Gi,mkdirSync as Ki,readFileSync as ou,renameSync as cu,statSync as Hi,unlinkSync as uu}from"node:fs";function Vr(){return Br(E(),"spool")}function qi(t){return Br(Vr(),`${t}.jsonl`)}function lt(t,e){try{Ki(Vr(),{recursive:!0,mode:448});let r=qi(t);if(Gi(r)&&Hi(r).size>=Wi)return;Ui(r,JSON.stringify(e)+`
8
- `,{mode:384})}catch{return}}var Wi,Pt=w(()=>{"use strict";H();Ze();Ie();Ue();Wi=512*1024});function Ur(t){let e=t.toLowerCase();return e.startsWith("git")||ea.has(e)}function Mt(t){let e=t.trim().split(/\s+/).filter(o=>o.length>0),r=0;for(;r<e.length&&Qi.test(e[r]??"");)r+=1;let n=e[r];if(!n||!Ji.test(n)||n.length>ra||Ur(n)||ta.test(n)||Ge(n)!==n)return"";let s=e[r+1];return s&&Ur(s)?"":(s&&na.has(n.toLowerCase())&&Xi.test(s)?`${n} ${s}`:n).slice(0,64)}async function Gr(t){if(!t.telemetryOptIn)return;let e=Mt(t.cmd),r=e&&Ge(e)===e?e:"other";lt("telemetry",{cmd:r,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),optimized:t.optimized})}var Ji,Xi,Qi,ea,ta,ra,na,$t=w(()=>{"use strict";Nt();Pt();Ji=/^[a-z0-9][a-z0-9._-]*$/i,Xi=/^[a-z][a-z-]+$/,Qi=/^[A-Za-z_][A-Za-z0-9_]*=/,ea=new Set(["gh","glab","gup","hub","gist"]),ta=/^(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,ra=24,na=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"])});async function Kr(t){if(t.plan!=="pro")return;let e=Mt(t.cmd);!e||Ge(e)!==e||lt("learn",{cmd:e,filterId:t.filterId,rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}var Hr=w(()=>{"use strict";$t();Nt();Pt()});function Yr(t){return JSON.stringify(t)+dt}function*Jr(t){let e=0;for(;;){let r=t.indexOf(dt,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function ft(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var la,da,fa,pa,Ru,Iu,Cu,qr,dt,Du,Xr=w(()=>{"use strict";tt();bt();la=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"]),installId:h.string().min(1).max(64).optional()}),da=h.object({id:h.string().min(1).max(64),op:h.literal("ping")}),fa=h.object({id:h.string().min(1).max(64),op:h.literal("shutdown"),installId:h.string().min(1).max(64)}),pa=h.object({id:h.string().min(1).max(64),op:h.literal("reload"),installId:h.string().min(1).max(64).optional()}),Ru=h.discriminatedUnion("op",[la,da,fa,pa]),Iu=h.object({id:h.string(),ok:h.literal(!0),data:h.unknown()}),Cu=h.object({id:h.string(),ok:h.literal(!1),err:h.string(),retryAfterMs:h.number().int().nonnegative().optional()}),qr=h.object({filter:rt.nullable(),cacheHit:h.boolean().optional()}),dt=`
9
- `,Du=64*1024});import{join as Ft}from"node:path";import{existsSync as Qr,statSync as ma,unlinkSync as ha,mkdirSync as ga,chmodSync as ya}from"node:fs";function pt(){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&&Qr(e))return{path:Ft(e,`tokmizer-${t}.sock`),isPipe:!1};let r=Ft(E(),"run");try{ga(r,{recursive:!0,mode:448}),ya(r,448)}catch{}return{path:Ft(r,"daemon.sock"),isPipe:!1}}async function en(){let{path:t,isPipe:e}=pt();if(e||!Qr(t))return;try{if(!ma(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let i=r.createConnection(t),a=o=>{i.removeAllListeners();try{i.destroy()}catch{}s(o)};i.once("connect",()=>a(!0)),i.once("error",o=>{let c=o.code;a(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>a(!0),250)}))try{ha(t)}catch{}}var $u,tn=w(()=>{"use strict";H();$u=5*6e4});import{createConnection as _a}from"node:net";import{spawn as va}from"node:child_process";import{existsSync as cn,openSync as rn,closeSync as xa,unlinkSync as nn,writeFileSync as sn}from"node:fs";import{dirname as ba,join as ka}from"node:path";import{fileURLToPath as wa}from"node:url";async function Ta(t,e){return new Promise((r,n)=>{let s=_a(t),i=o=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(a),o){try{s.destroy()}catch{}n(o)}else r(s)},a=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",o=>i(o))})}function Aa(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:wa(new URL("../bin/tkr-daemon.js",import.meta.url))}async function on(t,e=3e3){let r=Math.ceil(e/75);for(let n=0;n<r;n++){if(cn(t))return!0;await new Promise(s=>setTimeout(s,75))}return!1}async function Ra(t){let e=Aa();if(!cn(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=pt(),n=ka(ba(r),"daemon.spawn.lock"),s=null;try{s=rn(n,"wx"),sn(s,String(process.pid))}catch(i){if(i.code==="EEXIST"){if(await on(r,5e3))return;try{nn(n)}catch{}s=rn(n,"wx"),sn(s,String(process.pid))}else throw i}try{if(va(process.execPath,[e],{detached:!0,stdio:["ignore","ignore","ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),!await on(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(s!==null){try{xa(s)}catch{}try{nn(n)}catch{}}}}async function un(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:pt(),r=await Tt(),n=null,s=0;for(;s<=an;)try{n=await Ta(e,Ea);break}catch{if(s+=1,s>an)throw new Error(`tkr-daemon unreachable at ${e}`);await en(),await Ra(r)}if(!n)throw new Error("tkr-daemon: socket setup failed");let i=new Map,a="";n.setEncoding("utf8"),n.on("data",c=>{a+=c;let l=-1;for(let x=0;x<a.length;x++)a[x]===dt&&(l=x);if(l<0)return;let m=[];for(let x of Jr(a.slice(0,l+1)))m.push(x);a=a.slice(l+1);for(let x of m)if(x)try{let T=JSON.parse(x),N=i.get(T.id);if(!N)continue;clearTimeout(N.timer),i.delete(T.id),N.resolve(T)}catch{}}),n.on("close",()=>{for(let c of i.values())clearTimeout(c.timer),c.reject(new Error("daemon socket closed"));i.clear()}),n.on("error",()=>{});function o(c){return new Promise((l,m)=>{let x=setTimeout(()=>{i.delete(c.id),m(new Error(`daemon request timeout (${c.op})`))},Sa);i.set(c.id,{resolve:l,reject:m,timer:x}),n.write(Yr(c))})}return{filter:async(c,l)=>{let m=await o({id:ft(),op:"filter",cmd:c.slice(0,2048),plan:l,installId:r});if(!m.ok)return null;let x=qr.safeParse(m.data);return x.success?x.data.filter:null},ping:async()=>{let c=await o({id:ft(),op:"ping"});if(!c.ok)throw new Error(c.err);return c.data},reload:async()=>{let c=await o({id:ft(),op:"reload",installId:r});if(!c.ok)throw new Error(c.err);return c.data},close:()=>{try{n.end()}catch{}}}}var Ea,Sa,an,ln=w(()=>{"use strict";Xr();tn();Ie();Ea=500,Sa=3e3,an=1});import{spawn as Pa}from"node:child_process";import{spawn as Da}from"node:child_process";bt();import{readdir as Rs,readFile as Is}from"node:fs/promises";import{join as tr,dirname as Cs}from"node:path";import{fileURLToPath as Ds}from"node:url";var Os=Cs(Ds(import.meta.url)),Qt=tr(Os,"..","..","filters"),X=null,er=!1;function Ns(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function rr(){if(X)return X;if(!Ns())return!er&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
10
- `),er=!0),X=new Map,X;let t=new Map,e,r;try{e=(await import("smol-toml")).parse,r=(await Rs(Qt)).filter(n=>n.endsWith(".toml"))}catch{return X=t,X}for(let n of r){let s=await Is(tr(Qt,n),"utf8"),a=e(s).filters;if(a)for(let[o,c]of Object.entries(a)){let l=rt.parse({slug:o,...c});t.set(o,{...l,matchRegex:new RegExp(l.match_command)})}}return X=t,X}var ze=new Map,Ps=256,nr=new WeakMap;function Ms(t){if(!t)return"*";let e=nr.get(t);return e===void 0&&(e=[...t].join(","),nr.set(t,e)),e}function sr(t,e,r){let n=`${t}::${Ms(r)}`,s=ze.get(n);if(s!==void 0)return s;let i=null;for(let a of e)r&&!r.has(a.slug)||a.matchRegex.test(t)&&(!i||a.priority>i.priority)&&(i=a);if(ze.size>=Ps){let a=ze.keys().next().value;a&&ze.delete(a)}return ze.set(n,i),i}var $s=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,Fs=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function ir(t){return t.replace($s,"").replace(Fs,"")}function ar(t,e){return e.length===0?t:t.filter(r=>!e.some(n=>n.test(r)))}function or(t,e){return t.map(r=>r.length<=e?r:`${r.slice(0,e)}\u2026`)}function cr(t,e){if(t.length<=e)return t;let r=t.length-e;return[...t.slice(0,e),`\u2026 (${r} more lines omitted)`]}var Ls=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|class|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,js=/\{\s*$/;function nt(t){let e=[],r=0;for(;r<t.length;){let n=t[r];if(Ls.test(n)&&js.test(n)){let s=0,i=r,a=!1;for(;i<t.length&&i-r<200;){for(let o of t[i])o==="{"||o==="("||o==="["?s+=1:(o==="}"||o===")"||o==="]")&&(s-=1);if(i+=1,s<=0){a=!0;break}}if(a){e.push(`${n.replace(/\{\s*$/,"")}{ \u2026 }`),r=i;continue}}e.push(n),r+=1}return e}var zs=/\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 ur(t){let e=t.slice(0,4096);return!(!zs.test(e)||e.split(`
11
- `).length<6)}var Zs=/\b(?:DEBUG|TRACE|INFO|VERBOSE)\b/;function lr(t){return t.filter(e=>!Zs.test(e))}function dr(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 fr(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 pr=new Map;function Q(t,e){pr.set(t,e)}function mr(t){return pr.get(t)}var Bs=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/;function Vs(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 Us(t){if(!Bs.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}}var Gs=16;function Ks(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 a=s.name.slice(i);e.set(a,(e.get(a)??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 Hs(t){let e=[],r=[],n=!1;for(let S of t){if(/^total\s+\d+/.test(S))continue;let C=Us(S);C&&(n=!0,(C.isDir?e:r).push(C))}if(!n)return t;let s=(S,C)=>S.name.localeCompare(C.name);e.sort(s),r.sort((S,C)=>C.size-S.size||s(S,C));let a=e.slice(0,3),o=r.slice(0,Math.max(0,Gs-a.length)),c=[...a,...o],l=e.length-a.length+(r.length-o.length),m=Math.min(40,Math.max(0,...c.map(S=>S.isDir?S.name.length+1:S.name.length))),x=[];for(let S of c){let C=S.isDir?`${S.name}/`:S.name,Me=S.isDir?"":Vs(S.size);x.push(Me?`${C.padEnd(m)} ${Me}`:C)}l>0&&x.push(`\u2026 ${l} more`);let T=r.length===1?"file":"files",N=e.length===1?"dir":"dirs",Pe=Ks(r),He=`${r.length} ${T}, ${e.length} ${N}`+(Pe?` (${Pe})`:"");return x.push(He),x}Q("smart-ls",Hs);Q("smart-read",t=>nt(t));var Ws=/^[\s=]+$/,qs=/^\s*=+\s+(.*?)\s+=+\s*$/;Q("strip-banners",t=>{let e=[];for(let r of t){if(Ws.test(r))continue;let n=qs.exec(r);e.push(n?n[1]:r)}return e});function Ys(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 a=0;a<i;a++)e.push(s);n+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}Q("squeeze-output",Ys);var hr=new WeakMap;function Js(t){let e=hr.get(t);if(e)return e;let r=t.strip_lines_matching.map(s=>new RegExp(s)),n={def:t,stripRegexes:r};return hr.set(t,n),n}function gr(t,e,r={}){let n=Js(e),s=t;e.strip_ansi&&(s=ir(s));let i=s.split(`
12
- `);n.stripRegexes.length&&(i=ar(i,n.stripRegexes));let a=r.verbosity??"normal";if(a!=="normal"&&(i=dr(i),i=fr(i)),a==="minimal"&&(i=lr(i)),(r.smartCode||r.smartCode===void 0&&a!=="normal"&&ur(s))&&(i=nt(i)),e.transform){let c=mr(e.transform);c&&(i=c(i))}e.truncate_lines_at&&(i=or(i,e.truncate_lines_at)),e.max_lines&&(i=cr(i,e.max_lines));let o=i.join(`
13
- `);return o.trim().length===0&&e.on_empty&&(o=e.on_empty),o}var Xs=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/thread '.*' panicked/];function yr(t){if(!t)return!1;let e=t.length<=262144*2?[t]:[t.slice(0,262144),t.slice(-262144)];for(let r of Xs)for(let n of e)if(r.test(n))return!0;return!1}var _r=null;function kt(t){_r=t}async function Qs(t,e){let r=await rr();return sr(t,r.values(),e)}async function vr(t,e,r,n={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,...a}=n;if(i!=null&&i!==0||yr(e))return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:!0};let c=await(_r??Qs)(t,r);if(!c)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:!1};let l=gr(e,c,a);return{output:l,filterId:c.slug,rawBytes:s,filteredBytes:Buffer.byteLength(l,"utf8"),debugBypass:!1}}tt();var ei=h.enum(["normal","compact","minimal"]),ti=h.enum(["off","light","balanced","max"]),wt=h.object({enabled:h.boolean().default(!0),telemetryOptIn:h.boolean().default(!0),outputVerbosity:ei.default("compact"),reducer:ti.default("off"),filters:h.object({enableAll:h.boolean().default(!0),disabled:h.array(h.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),ri=["git","grep","find","ls","ps","cat","head","tail","df","du","tree","wc","read-tool","grep-tool","glob-tool","npm","docker","kubectl","curl","cargo","go-test","gh","aws","dotnet","prisma","tsc","next","jest","vitest","pytest","pip","rspec"];function st(t,e=!1){return e||!t||t.length===0?new Set(ri):new Set(t)}Ie();Ze();Ue();H();import{readFile as Mi,writeFile as $i,mkdir as Fi}from"node:fs/promises";Ue();Ze();Ie();import{createPublicKey as ki,verify as wi}from"node:crypto";function Ei(t,e){let r=Rt();if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new Error("Tokmizer plugin: no valid signing public key. Set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM or rebuild plugin against a prod key.");let n=ki({key:r,format:"pem"});try{let s=Buffer.from(e,"base64url");return wi(null,Buffer.from(t,"utf8"),n,s)}catch{return!1}}var Si=/^[a-z0-9][a-z0-9-]*$/;async function Ir(t){let e=await Ce();if(!e)throw new Error("Plugin not activated.");let r=await Re(),n=await De("GET","/api/v1/skills/bundle",void 0,{baseUrl:t,bearer:e.jwt,signingSecret:e.signingSecret,fingerprint:r.fingerprint,installId:r.installId,timeoutMs:8e3});if(!n.ok)throw new Error(`bundle fetch failed ${n.status}`);let s=await Ve(n),i=[];for(let a of s.bundles){if(!Si.test(a.slug))throw new Error(`invalid bundle slug ${a.slug}`);let o=[...a.fragments].sort((c,l)=>c.position-l.position);for(let c of o)if(!Ei(c.body,c.hash))throw new Error(`fragment signature mismatch on ${a.slug}[${c.position}]`);i.push({slug:a.slug,version:a.version,body:o.map(c=>c.body).join(`
6
+ `});import{createHmac as Pi,createPublicKey as Ni,verify as $i}from"node:crypto";function Ot(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??Pr).replace(/\\n/g,`
7
+ `)}function Li(t,e,r,n){try{let s=Ni({key:n,format:"pem"});return $i(null,Buffer.from(`${e}.${t}`,"utf8"),s,Buffer.from(r,"base64url"))}catch{return!1}}async function He(t){let e=await t.text(),r=Ot(),n=t.headers?.get?.("x-tokmizer-resp-ts")??null;if(n!==null){let a=Number(n);if(!Number.isFinite(a)||Date.now()-a>Mi)throw new re("http","stale server response (resp-ts outside freshness window)")}if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new re("http","no signing public key configured; refusing to trust server response");let s=t.headers?.get?.("x-tokmizer-resp-sig")??null,i=Number(n);if(!s||n===null||!Number.isFinite(i))throw new re("http","missing server response signature");if(!Li(e,i,s,r))throw new re("http","invalid server response signature");return JSON.parse(e)}function Fi(t,e,r){return Pi("sha256",r).update(`${e}.${t}`).digest("hex")}async function Pe(t,e,r,n){let s=Date.now(),i=r===void 0?"":JSON.stringify(r),a=n.signingSecret?Fi(i,s,n.signingSecret):"0".repeat(64),o={"content-type":"application/json","x-tokmizer-fingerprint":n.fingerprint,"x-tokmizer-install-id":n.installId,"x-tokmizer-sig":a,"x-tokmizer-ts":String(s),"x-tokmizer-plugin-version":Ve};n.bearer&&(o.authorization=`Bearer ${n.bearer}`);let c=n.timeoutMs??5e3,u=t!=="GET"&&t!=="DELETE",m={method:t,headers:o,signal:AbortSignal.timeout(c)};u&&(m.body=i);try{return await fetch(`${n.baseUrl}${e}`,m)}catch(b){let T=b.name;throw T==="TimeoutError"||T==="AbortError"?new re("timeout",`${t} ${e} timed out after ${c}ms`):new re("network",`${t} ${e} failed: ${b.message}`)}}var Mi,re,Ke=w(()=>{"use strict";Ct();Nr();Mi=300*1e3;re=class extends Error{constructor(r,n,s){super(n);this.kind=r;this.status=s;this.name="TransportError"}kind;status}});function Ge(t){let e=t;for(let[r,n]of aa)e=e.replace(r,n);return e}var aa,Mt=w(()=>{"use strict";aa=[[/(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]+-)*(?: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+.-]*:\/\/[^:/\s@]*:)[^\s]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]]});import{join as Wr}from"node:path";import{appendFileSync as oa,existsSync as ca,mkdirSync as la,readFileSync as Ol,renameSync as Dl,statSync as ua,unlinkSync as Pl,writeFileSync as Nl}from"node:fs";function qr(){return Wr(E(),"spool")}function fa(t){return Wr(qr(),`${t}.jsonl`)}function pt(t,e){try{la(qr(),{recursive:!0,mode:448});let r=fa(t);if(ca(r)&&ua(r).size>=da)return;oa(r,JSON.stringify(e)+`
8
+ `,{mode:384})}catch{return}}var da,Lt=w(()=>{"use strict";V();Ue();Oe();Ke();da=512*1024});function Yr(t){let e=t.toLowerCase();return e.startsWith("git")||ya.has(e)}function Ft(t){let e=t.trim().split(/\s+/).filter(o=>o.length>0),r=0;for(;r<e.length&&ga.test(e[r]??"");)r+=1;let n=e[r];if(!n||!ma.test(n)||n.length>va||Yr(n)||_a.test(n)||Ge(n)!==n)return"";let s=e[r+1];return s&&Yr(s)?"":(s&&ba.has(n.toLowerCase())&&ha.test(s)?`${n} ${s}`:n).slice(0,64)}async function Jr(t){if(!t.telemetryOptIn)return;let e=Ft(t.cmd),r=e&&Ge(e)===e?e:"other";pt("telemetry",{cmd:r,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),optimized:t.optimized})}var ma,ha,ga,ya,_a,va,ba,jt=w(()=>{"use strict";Mt();Lt();ma=/^[a-z0-9][a-z0-9._-]*$/i,ha=/^[a-z][a-z-]+$/,ga=/^[A-Za-z_][A-Za-z0-9_]*=/,ya=new Set(["gh","glab","gup","hub","gist"]),_a=/^(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,va=24,ba=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"])});async function Xr(t){if(t.plan!=="pro")return;let e=Ft(t.cmd);!e||Ge(e)!==e||pt("learn",{cmd:e,filterId:t.filterId==null?null:j(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}var Qr=w(()=>{"use strict";jt();Mt();Lt();ve()});function ln(t){return JSON.stringify(t)+mt}function*un(t){let e=0;for(;;){let r=t.indexOf(mt,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function ht(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Oa,Da,Pa,Na,su,iu,au,cn,mt,ou,dn=w(()=>{"use strict";st();Et();Oa=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"]),installId:h.string().min(1).max(64).optional()}),Da=h.object({id:h.string().min(1).max(64),op:h.literal("ping")}),Pa=h.object({id:h.string().min(1).max(64),op:h.literal("shutdown"),installId:h.string().min(1).max(64)}),Na=h.object({id:h.string().min(1).max(64),op:h.literal("reload"),installId:h.string().min(1).max(64).optional()}),su=h.discriminatedUnion("op",[Oa,Da,Pa,Na]),iu=h.object({id:h.string(),ok:h.literal(!0),data:h.unknown()}),au=h.object({id:h.string(),ok:h.literal(!1),err:h.string(),retryAfterMs:h.number().int().nonnegative().optional()}),cn=h.object({filter:it.nullable(),cacheHit:h.boolean().optional()}),mt=`
9
+ `,ou=64*1024});import{join as zt}from"node:path";import{existsSync as fn,statSync as $a,unlinkSync as Ma,mkdirSync as La,chmodSync as Fa}from"node:fs";function gt(){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&&fn(e))return{path:zt(e,`tokmizer-${t}.sock`),isPipe:!1};let r=zt(E(),"run");try{La(r,{recursive:!0,mode:448}),Fa(r,448)}catch{}return{path:zt(r,"daemon.sock"),isPipe:!1}}async function pn(){let{path:t,isPipe:e}=gt();if(e||!fn(t))return;try{if(!$a(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let i=r.createConnection(t),a=o=>{i.removeAllListeners();try{i.destroy()}catch{}s(o)};i.once("connect",()=>a(!0)),i.once("error",o=>{let c=o.code;a(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>a(!0),250)}))try{Ma(t)}catch{}}var fu,mn=w(()=>{"use strict";V();fu=5*6e4});import{createConnection as ja}from"node:net";import{spawn as za}from"node:child_process";import{existsSync as bn,openSync as hn,closeSync as Za,unlinkSync as gn,writeFileSync as yn}from"node:fs";import{dirname as Ba,join as Ua}from"node:path";import{fileURLToPath as Va}from"node:url";async function Ga(t,e){return new Promise((r,n)=>{let s=ja(t),i=o=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(a),o){try{s.destroy()}catch{}n(o)}else r(s)},a=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",o=>i(o))})}function Wa(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Va(new URL("../bin/tkr-daemon.js",import.meta.url))}async function vn(t,e=3e3){let r=Math.ceil(e/75);for(let n=0;n<r;n++){if(bn(t))return!0;await new Promise(s=>setTimeout(s,75))}return!1}async function qa(t){let e=Wa();if(!bn(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=gt(),n=Ua(Ba(r),"daemon.spawn.lock"),s=null;try{s=hn(n,"wx"),yn(s,String(process.pid))}catch(i){if(i.code==="EEXIST"){if(await vn(r,5e3))return;try{gn(n)}catch{}s=hn(n,"wx"),yn(s,String(process.pid))}else throw i}try{if(za(process.execPath,[e],{detached:!0,stdio:["ignore","ignore","ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),!await vn(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(s!==null){try{Za(s)}catch{}try{gn(n)}catch{}}}}async function xn(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:gt(),r=await It(),n=null,s=0;for(;s<=_n;)try{n=await Ga(e,Ha);break}catch{if(s+=1,s>_n)throw new Error(`tkr-daemon unreachable at ${e}`);await pn(),await qa(r)}if(!n)throw new Error("tkr-daemon: socket setup failed");let i=new Map,a="";n.setEncoding("utf8"),n.on("data",c=>{a+=c;let u=-1;for(let b=0;b<a.length;b++)a[b]===mt&&(u=b);if(u<0)return;let m=[];for(let b of un(a.slice(0,u+1)))m.push(b);a=a.slice(u+1);for(let b of m)if(b)try{let T=JSON.parse(b),P=i.get(T.id);if(!P)continue;clearTimeout(P.timer),i.delete(T.id),P.resolve(T)}catch{}}),n.on("close",()=>{for(let c of i.values())clearTimeout(c.timer),c.reject(new Error("daemon socket closed"));i.clear()}),n.on("error",()=>{});function o(c){return new Promise((u,m)=>{let b=setTimeout(()=>{i.delete(c.id),m(new Error(`daemon request timeout (${c.op})`))},Ka);i.set(c.id,{resolve:u,reject:m,timer:b}),n.write(ln(c))})}return{filter:async(c,u)=>{let m=await o({id:ht(),op:"filter",cmd:c.slice(0,2048),plan:u,installId:r});if(!m.ok)return null;let b=cn.safeParse(m.data);return b.success?b.data.filter:null},ping:async()=>{let c=await o({id:ht(),op:"ping"});if(!c.ok)throw new Error(c.err);return c.data},reload:async()=>{let c=await o({id:ht(),op:"reload",installId:r});if(!c.ok)throw new Error(c.err);return c.data},close:()=>{try{n.end()}catch{}}}}var Ha,Ka,_n,wn=w(()=>{"use strict";dn();mn();Oe();Ha=500,Ka=3e3,_n=1});import{spawn as to}from"node:child_process";import{spawn as Xa}from"node:child_process";Et();import{readdir as zs,readFile as Zs}from"node:fs/promises";import{join as ir,dirname as Bs}from"node:path";import{fileURLToPath as Us}from"node:url";var Vs=Bs(Us(import.meta.url)),nr=ir(Vs,"..","..","filters"),Q=null,sr=!1;function Hs(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function ar(){if(Q)return Q;if(!Hs())return!sr&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
10
+ `),sr=!0),Q=new Map,Q;let t=new Map,e,r;try{e=(await import("smol-toml")).parse,r=(await zs(nr)).filter(n=>n.endsWith(".toml"))}catch{return Q=t,Q}for(let n of r){let s=await Zs(ir(nr,n),"utf8"),a=e(s).filters;if(a)for(let[o,c]of Object.entries(a)){let u=it.parse({slug:o,...c});t.set(o,{...u,matchRegex:new RegExp(u.match_command)})}}return Q=t,Q}ve();var Be=new Map,Js=256,lr=new WeakMap;function Xs(t){if(!t)return"*";let e=lr.get(t);return e===void 0&&(e=[...t].join(","),lr.set(t,e)),e}function ur(t,e,r){let n=`${t}::${Xs(r)}`,s=Be.get(n);if(s!==void 0)return s;let i=null;for(let a of e)r&&!r.has(j(a.slug))||a.matchRegex.test(t)&&(!i||a.priority>i.priority)&&(i=a);if(Be.size>=Js){let a=Be.keys().next().value;a&&Be.delete(a)}return Be.set(n,i),i}var Qs=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,ei=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function dr(t){return t.replace(Qs,"").replace(ei,"")}function fr(t,e){return e.length===0?t:t.filter(r=>!e.some(n=>n.test(r)))}function pr(t,e){return t.map(r=>r.length<=e?r:`${r.slice(0,e)}\u2026`)}function mr(t,e){if(t.length<=e)return t;let r=t.length-e;return[...t.slice(0,e),`\u2026 (${r} more lines omitted)`]}var ti=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,ri=/\{\s*$/;var ni=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,si=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function ii(t){let e=ni.exec(t);return!e||si.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}function ot(t){let e=[],r=0;for(;r<t.length;){let n=t[r];if(ti.test(n)&&ri.test(n)||ii(n)){let s=0,i=r,a=!1;for(;i<t.length&&i-r<200;){for(let o of t[i])o==="{"||o==="("||o==="["?s+=1:(o==="}"||o===")"||o==="]")&&(s-=1);if(i+=1,s<=0){a=!0;break}}if(a){e.push(`${n.replace(/\{\s*$/,"")}{ \u2026 }`),r=i;continue}}e.push(n),r+=1}return e}var ai=/\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 hr(t){let e=t.slice(0,4096);return!(!ai.test(e)||e.split(`
11
+ `).length<6)}var oi=/\b(?:DEBUG|TRACE|INFO|VERBOSE)\b/;function gr(t){return t.filter(e=>!oi.test(e))}function yr(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 _r(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 vr=new Map;function ee(t,e){vr.set(t,e)}function br(t){return vr.get(t)}var ci=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/;function li(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 ui(t){if(!ci.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}}var di=16;function fi(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 a=s.name.slice(i);e.set(a,(e.get(a)??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 pi(t){let e=[],r=[],n=!1;for(let S of t){if(/^total\s+\d+/.test(S))continue;let C=ui(S);C&&(n=!0,(C.isDir?e:r).push(C))}if(!n)return t;let s=(S,C)=>S.name.localeCompare(C.name);e.sort(s),r.sort((S,C)=>C.size-S.size||s(S,C));let a=e.slice(0,3),o=r.slice(0,Math.max(0,di-a.length)),c=[...a,...o],u=e.length-a.length+(r.length-o.length),m=Math.min(40,Math.max(0,...c.map(S=>S.isDir?S.name.length+1:S.name.length))),b=[];for(let S of c){let C=S.isDir?`${S.name}/`:S.name,Le=S.isDir?"":li(S.size);b.push(Le?`${C.padEnd(m)} ${Le}`:C)}u>0&&b.push(`\u2026 ${u} more`);let T=r.length===1?"file":"files",P=e.length===1?"dir":"dirs",Me=fi(r),qe=`${r.length} ${T}, ${e.length} ${P}`+(Me?` (${Me})`:"");return b.push(qe),b}ee("smart-ls",pi);ee("smart-read",t=>ot(t));var mi=/^[\s=]+$/,hi=/^\s*=+\s+(.*?)\s+=+\s*$/;ee("strip-banners",t=>{let e=[];for(let r of t){if(mi.test(r))continue;let n=hi.exec(r);e.push(n?n[1]:r)}return e});function gi(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 a=0;a<i;a++)e.push(s);n+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}ee("squeeze-output",gi);var xr=new WeakMap;function yi(t){let e=xr.get(t);if(e)return e;let r=t.strip_lines_matching.map(s=>new RegExp(s)),n={def:t,stripRegexes:r};return xr.set(t,n),n}function wr(t,e,r={}){let n=yi(e),s=t;e.strip_ansi&&(s=dr(s));let i=s.split(`
12
+ `);n.stripRegexes.length&&(i=fr(i,n.stripRegexes));let a=r.verbosity??"normal";if(a!=="normal"&&(i=yr(i),i=_r(i)),a==="minimal"&&(i=gr(i)),(r.smartCode||r.smartCode===void 0&&a!=="normal"&&hr(s))&&(i=ot(i)),e.transform){let c=br(e.transform);c&&(i=c(i))}e.truncate_lines_at&&(i=pr(i,e.truncate_lines_at)),e.max_lines&&(i=mr(i,e.max_lines));let o=i.join(`
13
+ `);return o.trim().length===0&&e.on_empty&&(o=e.on_empty),o}var _i=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/thread '.*' panicked/];function kr(t){if(!t)return!1;let e=t.length<=262144*2?[t]:[t.slice(0,262144),t.slice(-262144)];for(let r of _i)for(let n of e)if(r.test(n))return!0;return!1}var Er=null;function Tt(t){Er=t}async function vi(t,e){let r=await ar();return ur(t,r.values(),e)}async function Sr(t,e,r,n={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,...a}=n;if(i!=null?i!==0:kr(e))return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:!0};let u=await(Er??vi)(t,r);if(!u)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:!1};let m=wr(e,u,a);return{output:m,filterId:u.slug,rawBytes:s,filteredBytes:Buffer.byteLength(m,"utf8"),debugBypass:!1}}ve();ve();Oe();Ue();Ke();V();import{readFile as Xi,writeFile as Qi,mkdir as ea}from"node:fs/promises";Ke();Ue();Oe();import{createPublicKey as ji,verify as zi}from"node:crypto";function Zi(t,e){let r=Ot();if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new Error("Tokmizer plugin: no valid signing public key. Set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM or rebuild plugin against a prod key.");let n=ji({key:r,format:"pem"});try{let s=Buffer.from(e,"base64url");return zi(null,Buffer.from(t,"utf8"),n,s)}catch{return!1}}var Bi=/^[a-z0-9][a-z0-9-]*$/;async function $r(t){let e=await De();if(!e)throw new Error("Plugin not activated.");let r=await Ce(),n=await Pe("GET","/api/v1/skills/bundle",void 0,{baseUrl:t,bearer:e.jwt,signingSecret:e.signingSecret,fingerprint:r.fingerprint,installId:r.installId,timeoutMs:8e3});if(!n.ok)throw new Error(`bundle fetch failed ${n.status}`);let s=await He(n),i=[];for(let a of s.bundles){if(!Bi.test(a.slug))throw new Error(`invalid bundle slug ${a.slug}`);let o=[...a.fragments].sort((c,u)=>c.position-u.position);for(let c of o)if(!Zi(c.body,c.hash))throw new Error(`fragment signature mismatch on ${a.slug}[${c.position}]`);i.push({slug:a.slug,version:a.version,body:o.map(c=>c.body).join(`
14
14
 
15
- `)})}return i}H();import{mkdir as It,readFile as Ti,writeFile as Ct,stat as Ai,readdir as Cr,rm as Dr}from"node:fs/promises";var Ri="managed-by: tokmizer",Ii=3600*1e3,Ci=10080*60*1e3;function Di(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Ci}async function Or(t){try{let e=await Ai(at(t)),r=Date.now()-e.mtimeMs;return r<Ii&&r<=Di()}catch{return!1}}async function Nr(t,e){await It(it(),{recursive:!0}),await Ct(at(t),e,{mode:384})}async function Pr(t){let e=new Set(t),r;try{r=await Cr(it())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{await Dr(at(s))}catch{}}}async function Mr(t,e){await It(ot(),{recursive:!0}),await Ct(ct(t),e,{mode:384})}async function $r(t){let e=new Set(t),r;try{r=await Cr(ot())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{if(!(await Ti(ct(s),"utf8")).includes(Ri))continue;await Dr(ct(s))}catch{}}}async function Dt(t){try{await It(E(),{recursive:!0}),await Ct(kr(),JSON.stringify({at:Date.now(),error:t}),{mode:384})}catch{}}Ze();Ie();Ue();import{readFile as Oi,writeFile as Cc,mkdir as Dc,chmod as Oc}from"node:fs/promises";import{join as Ni}from"node:path";H();var Pi="settings-cache.json",Fr=wt.parse({});async function Lr(){try{let t=await Oi(Ni(E(),Pi),"utf8"),e=JSON.parse(t);return wt.parse({...Fr,...e})}catch{return Fr}}At();var jr="-command";async function Li(t,e){if(!(!e&&await Or("power")))try{let r=await Ir(t),n=[],s=[];for(let i of r)if(i.slug.endsWith(jr)){let a=i.slug.slice(0,-jr.length);await Mr(a,i.body),s.push(a)}else await Nr(i.slug,i.body),n.push(i.slug);await Pr(n),await $r(s),await Dt(null)}catch(r){await Dt(r instanceof Error?r.message:String(r))}}var ji=5*6e4;function zi(){return process.env.TOKMIZER_BASE_URL??"https://tokmizer.com"}async function Zi(t){let e=await Re(),r=ut(),n={pluginVersion:Be,timeZone:r,...e},s=await De("POST","/api/v1/license/enroll",n,{baseUrl:t,fingerprint:e.fingerprint,installId:e.installId,timeoutMs:4e3});if(!s.ok)throw new Error(`enroll failed ${s.status}`);let i=await Ve(s),a={token:i.token,jwt:i.jwt,signingSecret:i.signingSecret,plan:i.plan,status:i.status,trialEndsAt:i.trialEndsAt,subEndsAt:i.subEndsAt,jwtVersion:i.jwtVersion,installId:e.installId,fingerprint:e.fingerprint,pluginVersion:Be,email:"",timeZone:r,bonusActive:!1,lastHeartbeatOkAt:Date.now()};return await Tr(a),await Li(t,!0),a}async function zr(t){let e=await Ce();if(e)return e;let r=br();try{let n=await Mi(r,"utf8"),s=Number(n);if(Number.isFinite(s)&&Date.now()-s<ji)return null}catch{}try{return await Zi(t??zi())}catch{return await Fi(E(),{recursive:!0}),await $i(r,String(Date.now()),{mode:384}),null}}function Bi(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function Ot(t,e=Date.now()){let r=t.lastHeartbeatOkAt;if(typeof r=="number"&&e-r>Bi())return!0;if(t.subEndsAt){let n=Date.parse(t.subEndsAt);if(Number.isFinite(n)&&e>n)return!0}return!1}function Zr(t,e=Date.now()){return Ot(t,e)?"free":t.plan}Hr();$t();H();import{appendFileSync as sa,chmodSync as ia,mkdirSync as aa}from"node:fs";import{join as oa}from"node:path";var ca="stats.jsonl";function ua(){return oa(E(),ca)}function Wr(t,e,r=ua()){if(t<=0||e<0||e>t)return;let n=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}}
16
- `;try{aa(E(),{recursive:!0,mode:448}),sa(r,n,{mode:384}),ia(r,384)}catch{return}}ln();var Oe=null,Ke=null;async function Ia(){return Oe||Ke||(Ke=un().then(t=>(Oe=t,t)).catch(()=>null),Ke)}function Ca(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function dn(t){kt(async(e,r)=>{let n=await Ia();if(!n)return null;try{let s=t==="free"?"trial":t,i=await n.filter(e,s);return!i||!(r??st(void 0)).has(i.slug)?null:Ca(i)}catch{return null}})}function fn(){if(kt(null),Oe){try{Oe.close()}catch{}Oe=null,Ke=null}}var Ne=10*1024*1024,Oa=Number(process.env.TOKMIZER_EXEC_TIMEOUT_MS??"600000"),Na={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15};function Lt(t){return Na[t]??15}async function pn(t){let[e,...r]=t;if(!e)throw new Error("tkr-exec: missing command");let n=Da(e,r,{stdio:["inherit","pipe","pipe"]}),s=!1;n.on("spawn",()=>{s=!0});let i=k=>{try{n.kill(k)}catch{}};process.on("SIGINT",()=>i("SIGINT")),process.on("SIGTERM",()=>i("SIGTERM"));let a=[],o=[],c=0,l=0,m=!1,x=!1;n.stdout.on("data",k=>{if(c>=Ne){m=!0;return}let A=Ne-c,P=k.length>A?k.subarray(0,A):k;a.push(P),c+=P.length,k.length>A&&(m=!0)}),n.stderr.on("data",k=>{if(l>=Ne){x=!0;return}let A=Ne-l,P=k.length>A?k.subarray(0,A):k;o.push(P),l+=P.length,k.length>A&&(x=!0)});let T,N=await new Promise((k,A)=>{n.on("error",P=>{T&&clearTimeout(T),s?k(1):A(P)}),n.on("close",(P,_e)=>{T&&clearTimeout(T),k(P??(_e?128+Lt(_e):0))}),T=setTimeout(()=>{n.kill("SIGTERM"),setTimeout(()=>n.kill("SIGKILL"),2e3)},Oa),T.unref?.()}),Pe=Buffer.concat(a).toString("utf8"),He=Buffer.concat(o).toString("utf8"),S=m?`
17
- \u2026 (output truncated at ${Ne/(1024*1024)}MB)`:"",C=x?He+`
18
- \u2026 (stderr truncated at ${Ne/(1024*1024)}MB)`:He,Me=()=>{let k=Pe+S,A=Buffer.byteLength(k,"utf8");return{stdout:k,stderr:C,code:N,filterId:null,rawBytes:A,filteredBytes:A,truncated:m}};try{let k=await zr(),A=await Lr();if(!A.enabled)return Me();let P=k?Zr(k):null,_e=k?st(k.allowedFilters,Ot(k)):null,mn=_e&&A.filters.disabled.length>0?new Set([..._e].filter(hn=>!A.filters.disabled.includes(hn))):_e,mt=t.join(" ");k&&dn(P);let M=await vr(mt,Pe,mn,{verbosity:A.outputVerbosity,exitCode:N});return Wr(M.rawBytes,M.filteredBytes),await Kr({cmd:mt,filterId:M.filterId,rawBytes:M.rawBytes,filteredBytes:M.filteredBytes,plan:P}),await Gr({cmd:mt,tokensSaved:Math.round((M.rawBytes-M.filteredBytes)/4),optimized:M.filterId!=null,telemetryOptIn:A.telemetryOptIn}),{stdout:M.output+S,stderr:C,code:N,filterId:M.filterId,rawBytes:M.rawBytes,filteredBytes:M.filteredBytes,truncated:m}}catch{return Me()}finally{fn()}}async function Ma(t){let[e,...r]=t;e||process.exit(2);let n=Pa(e,r,{stdio:"inherit"}),s=await new Promise(i=>{n.on("error",()=>i(127)),n.on("close",(a,o)=>i(a??(o?128+Lt(o):0)))});process.exit(s)}async function $a(){let t=process.argv.slice(2);t.length===0&&(process.stderr.write(`tkr-exec: missing command
19
- `),process.exit(2));let e;try{e=await pn(t)}catch(r){return process.stderr.write(`tkr-exec: ${r.message??r}
20
- `),Ma(t)}e.stdout&&process.stdout.write(e.stdout),e.stderr&&process.stderr.write(e.stderr),process.exitCode=e.code}$a().catch(t=>{process.stderr.write(`${t.message??t}
15
+ `)})}return i}V();import{mkdir as Dt,readFile as Ui,writeFile as Pt,stat as Vi,readdir as Mr,rm as Lr}from"node:fs/promises";var Hi="managed-by: tokmizer",Ki=3600*1e3,Gi=10080*60*1e3;function Wi(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Gi}async function Fr(t){try{let e=await Vi(lt(t)),r=Date.now()-e.mtimeMs;return r<Ki&&r<=Wi()}catch{return!1}}async function jr(t,e){await Dt(ct(),{recursive:!0}),await Pt(lt(t),e,{mode:384})}async function zr(t){let e=new Set(t),r;try{r=await Mr(ct())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{await Lr(lt(s))}catch{}}}async function Zr(t,e){await Dt(ut(),{recursive:!0}),await Pt(dt(t),e,{mode:384})}async function Br(t){let e=new Set(t),r;try{r=await Mr(ut())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{if(!(await Ui(dt(s),"utf8")).includes(Hi))continue;await Lr(dt(s))}catch{}}}async function Nt(t){try{await Dt(E(),{recursive:!0}),await Pt(Rr(),JSON.stringify({at:Date.now(),error:t}),{mode:384})}catch{}}Ue();Oe();Ke();ve();V();import{readFile as qi,writeFile as Qc,mkdir as el,chmod as tl}from"node:fs/promises";import{join as Yi}from"node:path";var Ji="settings-cache.json",Ur=St.parse({});async function Vr(){try{let t=await qi(Yi(E(),Ji),"utf8"),e=JSON.parse(t);return St.parse({...Ur,...e})}catch{return Ur}}Ct();var Hr="-command";async function ta(t,e){if(!(!e&&await Fr("power")))try{let r=await $r(t),n=[],s=[];for(let i of r)if(i.slug.endsWith(Hr)){let a=i.slug.slice(0,-Hr.length);await Zr(a,i.body),s.push(a)}else await jr(i.slug,i.body),n.push(i.slug);await zr(n),await Br(s),await Nt(null)}catch(r){await Nt(r instanceof Error?r.message:String(r))}}var ra=5*6e4;function na(){return process.env.TOKMIZER_BASE_URL??"https://tokmizer.com"}async function sa(t){let e=await Ce(),r=ft(),n={pluginVersion:Ve,timeZone:r,...e},s=await Pe("POST","/api/v1/license/enroll",n,{baseUrl:t,fingerprint:e.fingerprint,installId:e.installId,timeoutMs:4e3});if(!s.ok)throw new Error(`enroll failed ${s.status}`);let i=await He(s),a={token:i.token,jwt:i.jwt,signingSecret:i.signingSecret,plan:i.plan,status:i.status,trialEndsAt:i.trialEndsAt,subEndsAt:i.subEndsAt,jwtVersion:i.jwtVersion,installId:e.installId,fingerprint:e.fingerprint,pluginVersion:Ve,email:"",timeZone:r,bonusActive:!1,lastHeartbeatOkAt:Date.now()};return await Dr(a),await ta(t,!0),a}async function Kr(t){let e=await De();if(e)return e;let r=Ar();try{let n=await Xi(r,"utf8"),s=Number(n);if(Number.isFinite(s)&&Date.now()-s<ra)return null}catch{}try{return await sa(t??na())}catch{return await ea(E(),{recursive:!0}),await Qi(r,String(Date.now()),{mode:384}),null}}function ia(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function $t(t,e=Date.now()){let r=t.lastHeartbeatOkAt;if(typeof r=="number"&&e-r>ia())return!0;if(t.subEndsAt){let n=Date.parse(t.subEndsAt);if(Number.isFinite(n)&&e>n)return!0}return!1}function Gr(t,e=Date.now()){return $t(t,e)?"free":t.plan}Qr();jt();V();import{appendFileSync as xa,chmodSync as wa,mkdirSync as ka}from"node:fs";import{join as Ea}from"node:path";var Sa="stats.jsonl";function Ta(){return Ea(E(),Sa)}function en(t,e,r=Ta()){if(t<=0||e<0||e>t)return;let n=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}}
16
+ `;try{ka(E(),{recursive:!0,mode:448}),xa(r,n,{mode:384}),wa(r,384)}catch{return}}function tn(t,e,r){let n=r!=null?Math.min(t,r):t,s=Math.min(e,n);return{raw:n,filtered:s}}var Aa=[{host:"claude-code",vars:["CLAUDE_CODE","CLAUDE_CODE_VERSION","ANTHROPIC_CLAUDE_CODE"]},{host:"codex",vars:["CODEX_VERSION","CODEX_CLI","OPENAI_CODEX"]},{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"]}],rn=new Set(["claude-code","codex"]),Ra=3e4;function nn(t){return rn.has(t)?Ra:null}function sn(t=process.env){let e=process.platform,r=e==="darwin"||e==="linux"||e==="win32"?e:"other",n=process.arch;for(let s of Aa)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:r,arch:n,shimRecommended:!rn.has(s.host)};return{host:"shell",source:"fallback",os:r,arch:n,shimRecommended:!0}}import{delimiter as an,join as Ia}from"node:path";V();function Ca(){return Ia(E(),"shims")}function on(){let t=Ca(),e={...process.env},r=process.platform==="win32"?"Path":"PATH",s=(e[r]??e.PATH??"").split(an).filter(i=>i&&i!==t);return e[r]=s.join(an),r==="Path"&&(e.PATH=e[r]),e}wn();ve();var Ne=null,We=null;async function Ya(){return Ne||We||(We=xn().then(t=>(Ne=t,t)).catch(()=>null),We)}function Ja(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function kn(t){Tt(async(e,r)=>{let n=await Ya();if(!n)return null;try{let s=t==="free"?"trial":t,i=await n.filter(e,s);return!i||!(r??at(void 0)).has(j(i.slug))?null:Ja(i)}catch{return null}})}function En(){if(Tt(null),Ne){try{Ne.close()}catch{}Ne=null,We=null}}var $e=10*1024*1024,Qa=Number(process.env.TOKMIZER_EXEC_TIMEOUT_MS??"600000"),eo={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15};function Zt(t){return eo[t]??15}async function Sn(t){let[e,...r]=t;if(!e)throw new Error("tkr-exec: missing command");let n=Xa(e,r,{stdio:["inherit","pipe","pipe"],env:on()}),s=!1;n.on("spawn",()=>{s=!0});let i=k=>{try{n.kill(k)}catch{}};process.on("SIGINT",()=>i("SIGINT")),process.on("SIGTERM",()=>i("SIGTERM"));let a=[],o=[],c=0,u=0,m=!1,b=!1;n.stdout.on("data",k=>{if(c>=$e){m=!0;return}let A=$e-c,N=k.length>A?k.subarray(0,A):k;a.push(N),c+=N.length,k.length>A&&(m=!0)}),n.stderr.on("data",k=>{if(u>=$e){b=!0;return}let A=$e-u,N=k.length>A?k.subarray(0,A):k;o.push(N),u+=N.length,k.length>A&&(b=!0)});let T,P=await new Promise((k,A)=>{n.on("error",N=>{T&&clearTimeout(T),s?k(1):A(N)}),n.on("close",(N,be)=>{T&&clearTimeout(T),k(N??(be?128+Zt(be):0))}),T=setTimeout(()=>{n.kill("SIGTERM"),setTimeout(()=>n.kill("SIGKILL"),2e3)},Qa),T.unref?.()}),Me=Buffer.concat(a).toString("utf8"),qe=Buffer.concat(o).toString("utf8"),S=m?`
17
+ \u2026 (output truncated at ${$e/(1024*1024)}MB)`:"",C=b?qe+`
18
+ \u2026 (stderr truncated at ${$e/(1024*1024)}MB)`:qe,Le=()=>{let k=Me+S,A=Buffer.byteLength(k,"utf8");return{stdout:k,stderr:C,code:P,filterId:null,rawBytes:A,filteredBytes:A,truncated:m}};try{let k=await Kr(),A=await Vr();if(!A.enabled)return Le();let N=k?Gr(k):null,be=k?at(k.allowedFilters,$t(k)):null,Bt=new Set(A.filters.disabled.map(j)),Tn=be&&Bt.size>0?new Set([...be].filter(An=>!Bt.has(An))):be,yt=t.join(" ");k&&kn(N);let z=await Sr(yt,Me,Tn,{verbosity:A.outputVerbosity,exitCode:P}),Ye=tn(z.rawBytes,z.filteredBytes,nn(sn().host));return en(Ye.raw,Ye.filtered),await Xr({cmd:yt,filterId:z.filterId,rawBytes:z.rawBytes,filteredBytes:z.filteredBytes,plan:N}),await Jr({cmd:yt,tokensSaved:Math.round((Ye.raw-Ye.filtered)/4),optimized:z.filterId!=null,telemetryOptIn:A.telemetryOptIn}),{stdout:z.output+S,stderr:C,code:P,filterId:z.filterId,rawBytes:z.rawBytes,filteredBytes:z.filteredBytes,truncated:m}}catch{return Le()}finally{En()}}async function ro(t){let[e,...r]=t;e||process.exit(2);let n=to(e,r,{stdio:"inherit"}),s=await new Promise(i=>{n.on("error",()=>i(127)),n.on("close",(a,o)=>i(a??(o?128+Zt(o):0)))});process.exit(s)}async function no(){let t=process.argv.slice(2);t.length===0&&(process.stderr.write(`tkr-exec: missing command
19
+ `),process.exit(2));let e;try{e=await Sn(t)}catch(r){return process.stderr.write(`tkr-exec: ${r.message??r}
20
+ `),ro(t)}e.stdout&&process.stdout.write(e.stdout),e.stderr&&process.stderr.write(e.stderr),process.exitCode=e.code}no().catch(t=>{process.stderr.write(`${t.message??t}
21
21
  `),process.exit(1)});