@tokmizer/plugin 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +10 -0
- package/README.md +81 -0
- package/codex-plugin/plugin.json +21 -0
- package/commands/tkr-compression.md +26 -0
- package/commands/tkr-gain.md +16 -0
- package/commands/tkr-link.md +20 -0
- package/commands/tkr-reducer.md +27 -0
- package/commands/tkr-status.md +15 -0
- package/commands/tkr-telemetry.md +19 -0
- package/commands/tkr-unlink.md +13 -0
- package/commands/tkr-update.md +22 -0
- package/commands/tkr.md +42 -0
- package/dist/bin/tkr-codex-hook.js +13 -0
- package/dist/bin/tkr-daemon.js +16 -0
- package/dist/bin/tkr-exec.js +21 -0
- package/dist/bin/tkr-shim.js +13 -0
- package/dist/bin/tkr.js +139 -0
- package/dist/hooks-host/post-tool-use.js +10 -0
- package/dist/hooks-host/pre-tool-use.js +6 -0
- package/dist/hooks-host/reducer-prompt-submit.js +3 -0
- package/dist/hooks-host/reducer-session-start.js +3 -0
- package/dist/hooks-host/reducer-stop.js +5 -0
- package/dist/index.js +11 -0
- package/dist/prod-public-key.js +5 -0
- package/hooks/hooks.json +69 -0
- package/hooks/on-session-start.mjs +102 -0
- package/package.json +59 -0
- package/scripts/README-INSTALL.md +37 -0
- package/scripts/install-mac-linux.sh +69 -0
- package/scripts/install-windows.ps1 +69 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
|
|
3
|
+
var Ye=Object.defineProperty;var qe=(r,e)=>{for(var t in e)Ye(r,t,{get:e[t],enumerable:!0})};import{openSync as Pr,fstatSync as zr,readSync as Mr,closeSync as Lr}from"node:fs";import{readFile as dr,writeFile as Ss,mkdir as Rs}from"node:fs/promises";import{join as lr}from"node:path";var R={};qe(R,{BRAND:()=>kt,DIRTY:()=>F,EMPTY_PATH:()=>et,INVALID:()=>m,NEVER:()=>ir,OK:()=>b,ParseStatus:()=>x,Schema:()=>y,ZodAny:()=>M,ZodArray:()=>$,ZodBigInt:()=>B,ZodBoolean:()=>K,ZodBranded:()=>pe,ZodCatch:()=>re,ZodDate:()=>H,ZodDefault:()=>te,ZodDiscriminatedUnion:()=>ye,ZodEffects:()=>S,ZodEnum:()=>Q,ZodError:()=>k,ZodFirstPartyTypeKind:()=>h,ZodFunction:()=>ve,ZodIntersection:()=>q,ZodIssueCode:()=>c,ZodLazy:()=>J,ZodLiteral:()=>X,ZodMap:()=>ue,ZodNaN:()=>le,ZodNativeEnum:()=>ee,ZodNever:()=>C,ZodNull:()=>G,ZodNullable:()=>I,ZodNumber:()=>U,ZodObject:()=>E,ZodOptional:()=>A,ZodParsedType:()=>d,ZodPipeline:()=>me,ZodPromise:()=>L,ZodReadonly:()=>se,ZodRecord:()=>_e,ZodSchema:()=>y,ZodSet:()=>de,ZodString:()=>z,ZodSymbol:()=>oe,ZodTransformer:()=>S,ZodTuple:()=>D,ZodType:()=>y,ZodUndefined:()=>W,ZodUnion:()=>Y,ZodUnknown:()=>Z,ZodVoid:()=>ce,addIssueToContext:()=>u,any:()=>Dt,array:()=>Zt,bigint:()=>Tt,boolean:()=>Me,coerce:()=>ar,custom:()=>$e,date:()=>St,datetimeRegex:()=>je,defaultErrorMap:()=>N,discriminatedUnion:()=>Mt,effect:()=>Jt,enum:()=>Gt,function:()=>Kt,getErrorMap:()=>ne,getParsedType:()=>O,instanceof:()=>wt,intersection:()=>Lt,isAborted:()=>he,isAsync:()=>ae,isDirty:()=>ge,isValid:()=>P,late:()=>Et,lazy:()=>Ht,literal:()=>Wt,makeIssue:()=>fe,map:()=>Ut,nan:()=>At,nativeEnum:()=>Yt,never:()=>Nt,null:()=>Ot,nullable:()=>Qt,number:()=>ze,object:()=>$t,objectUtil:()=>be,oboolean:()=>nr,onumber:()=>sr,optional:()=>Xt,ostring:()=>rr,pipeline:()=>tr,preprocess:()=>er,promise:()=>qt,quotelessJson:()=>Je,record:()=>Ft,set:()=>Bt,setErrorMap:()=>Qe,strictObject:()=>Pt,string:()=>Pe,symbol:()=>Rt,transformer:()=>Jt,tuple:()=>Vt,undefined:()=>Ct,union:()=>zt,unknown:()=>It,util:()=>_,void:()=>jt});var _;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let a={};for(let o of n)a[o]=o;return a},r.getValidEnumValues=n=>{let a=r.objectKeys(n).filter(i=>typeof n[n[i]]!="number"),o={};for(let i of a)o[i]=n[i];return r.objectValues(o)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&a.push(o);return a},r.find=(n,a)=>{for(let o of n)if(a(o))return o},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(_||(_={}));var be;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(be||(be={}));var d=_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),O=r=>{switch(typeof r){case"undefined":return d.undefined;case"string":return d.string;case"number":return Number.isNaN(r)?d.nan:d.number;case"boolean":return d.boolean;case"function":return d.function;case"bigint":return d.bigint;case"symbol":return d.symbol;case"object":return Array.isArray(r)?d.array:r===null?d.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?d.promise:typeof Map<"u"&&r instanceof Map?d.map:typeof Set<"u"&&r instanceof Set?d.set:typeof Date<"u"&&r instanceof Date?d.date:d.object;default:return d.unknown}};var c=_.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"]),Je=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),k=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)s._errors.push(t(o));else{let i=s,l=0;for(;l<o.path.length;){let f=o.path[l];l===o.path.length-1?(i[f]=i[f]||{_errors:[]},i[f]._errors.push(t(o))):i[f]=i[f]||{_errors:[]},i=i[f],l++}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,_.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let n of this.issues)if(n.path.length>0){let a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};k.create=r=>new k(r);var Xe=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===d.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,_.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${_.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${_.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:_.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,_.assertNever(r)}return{message:t}},N=Xe;var Ce=N;function Qe(r){Ce=r}function ne(){return Ce}var fe=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],o={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let i="",l=s.filter(f=>!!f).slice().reverse();for(let f of l)i=f(o,{data:e,defaultError:i}).message;return{...n,path:a,message:i}},et=[];function u(r,e){let t=ne(),s=fe({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===N?void 0:N].filter(n=>!!n)});r.common.issues.push(s)}var x=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return m;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let a=await n.key,o=await n.value;s.push({key:a,value:o})}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:a,value:o}=n;if(a.status==="aborted"||o.status==="aborted")return m;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(s[a.value]=o.value)}return{status:e.value,value:s}}},m=Object.freeze({status:"aborted"}),F=r=>({status:"dirty",value:r}),b=r=>({status:"valid",value:r}),he=r=>r.status==="aborted",ge=r=>r.status==="dirty",P=r=>r.status==="valid",ae=r=>typeof Promise<"u"&&r instanceof Promise;var p;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));var T=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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}},Oe=(r,e)=>{if(P(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new k(r.common.issues);return this._error=t,this._error}}};function g(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(o,i)=>{let{message:l}=r;return o.code==="invalid_enum_value"?{message:l??i.defaultError}:typeof i.data>"u"?{message:l??s??i.defaultError}:o.code!=="invalid_type"?{message:i.defaultError}:{message:l??t??i.defaultError}},description:n}}var y=class{get description(){return this._def.description}_getType(e){return O(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:O(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new x,ctx:{common:e.parent.common,data:e.data,parsedType:O(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ae(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:O(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Oe(s,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:O(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return P(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>P(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:O(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ae(n)?n:Promise.resolve(n));return Oe(s,a)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let o=e(n),i=()=>a.addIssue({code:c.custom,...s(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(i(),!1)):o?!0:(i(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new S({schema:this,typeName:h.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:t=>this["~validate"](t)}}optional(){return A.create(this,this._def)}nullable(){return I.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $.create(this)}promise(){return L.create(this,this._def)}or(e){return Y.create([this,e],this._def)}and(e){return q.create(this,e,this._def)}transform(e){return new S({...g(this._def),schema:this,typeName:h.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new te({...g(this._def),innerType:this,defaultValue:t,typeName:h.ZodDefault})}brand(){return new pe({typeName:h.ZodBranded,type:this,...g(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new re({...g(this._def),innerType:this,catchValue:t,typeName:h.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return me.create(this,e)}readonly(){return se.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},tt=/^c[^\s-]{8,}$/i,rt=/^[0-9a-z]+$/,st=/^[0-9A-HJKMNP-TV-Z]{26}$/i,nt=/^[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,at=/^[a-z0-9_-]{21}$/i,it=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ot=/^[-+]?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)?)??$/,ct=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ut="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ke,dt=/^(?:(?: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])$/,lt=/^(?:(?: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])$/,ft=/^(([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]))$/,pt=/^(([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])$/,mt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ht=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ie="((\\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])))",gt=new RegExp(`^${Ie}$`);function Ne(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function yt(r){return new RegExp(`^${Ne(r)}$`)}function je(r){let e=`${Ie}T${Ne(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function _t(r,e){return!!((e==="v4"||!e)&&dt.test(r)||(e==="v6"||!e)&&ft.test(r))}function vt(r,e){if(!it.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function xt(r,e){return!!((e==="v4"||!e)&<.test(r)||(e==="v6"||!e)&&pt.test(r))}var z=class r extends y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==d.string){let a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:d.string,received:a.parsedType}),m}let s=new x,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){let o=e.data.length>a.value,i=e.data.length<a.value;(o||i)&&(n=this._getOrReturnCtx(e,n),o?u(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&u(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")ct.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"email",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")ke||(ke=new RegExp(ut,"u")),ke.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"emoji",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")nt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"uuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")at.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"nanoid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")tt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")rt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")st.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"ulid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),u(n,{validation:"url",code:c.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"regex",code:c.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?je(a).test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?gt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?yt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?ot.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"duration",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?_t(e.data,a.version)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"ip",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?vt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"jwt",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?xt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cidr",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?mt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"base64",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?ht.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"base64url",code:c.invalid_string,message:a.message}),s.dirty()):_.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...p.errToObj(s)})}_addCheck(e){return new r({...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,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...p.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};z.create=r=>new z({checks:[],typeName:h.ZodString,coerce:r?.coerce??!1,...g(r)});function bt(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(r.toFixed(n).replace(".","")),o=Number.parseInt(e.toFixed(n).replace(".",""));return a%o/10**n}var U=class r extends y{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)!==d.number){let a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:d.number,received:a.parsedType}),m}let s,n=new x;for(let a of this._def.checks)a.kind==="int"?_.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?bt(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:c.not_finite,message:a.message}),n.dirty()):_.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...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,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};U.create=r=>new U({checks:[],typeName:h.ZodNumber,coerce:r?.coerce||!1,...g(r)});var B=class r extends y{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)!==d.bigint)return this._getInvalidInput(e);let s,n=new x;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):_.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return u(t,{code:c.invalid_type,expected:d.bigint,received:t.parsedType}),m}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...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,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};B.create=r=>new B({checks:[],typeName:h.ZodBigInt,coerce:r?.coerce??!1,...g(r)});var K=class extends y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==d.boolean){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:d.boolean,received:s.parsedType}),m}return b(e.data)}};K.create=r=>new K({typeName:h.ZodBoolean,coerce:r?.coerce||!1,...g(r)});var H=class r extends y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==d.date){let a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:d.date,received:a.parsedType}),m}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_date}),m}let s=new x,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):_.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};H.create=r=>new H({checks:[],coerce:r?.coerce||!1,typeName:h.ZodDate,...g(r)});var oe=class extends y{_parse(e){if(this._getType(e)!==d.symbol){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:d.symbol,received:s.parsedType}),m}return b(e.data)}};oe.create=r=>new oe({typeName:h.ZodSymbol,...g(r)});var W=class extends y{_parse(e){if(this._getType(e)!==d.undefined){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:d.undefined,received:s.parsedType}),m}return b(e.data)}};W.create=r=>new W({typeName:h.ZodUndefined,...g(r)});var G=class extends y{_parse(e){if(this._getType(e)!==d.null){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:d.null,received:s.parsedType}),m}return b(e.data)}};G.create=r=>new G({typeName:h.ZodNull,...g(r)});var M=class extends y{constructor(){super(...arguments),this._any=!0}_parse(e){return b(e.data)}};M.create=r=>new M({typeName:h.ZodAny,...g(r)});var Z=class extends y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return b(e.data)}};Z.create=r=>new Z({typeName:h.ZodUnknown,...g(r)});var C=class extends y{_parse(e){let t=this._getOrReturnCtx(e);return u(t,{code:c.invalid_type,expected:d.never,received:t.parsedType}),m}};C.create=r=>new C({typeName:h.ZodNever,...g(r)});var ce=class extends y{_parse(e){if(this._getType(e)!==d.undefined){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:d.void,received:s.parsedType}),m}return b(e.data)}};ce.create=r=>new ce({typeName:h.ZodVoid,...g(r)});var $=class r extends y{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==d.array)return u(t,{code:c.invalid_type,expected:d.array,received:t.parsedType}),m;if(n.exactLength!==null){let o=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;(o||i)&&(u(t,{code:o?c.too_big:c.too_small,minimum:i?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(u(t,{code:c.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(u(t,{code:c.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((o,i)=>n.type._parseAsync(new T(t,o,t.path,i)))).then(o=>x.mergeArray(s,o));let a=[...t.data].map((o,i)=>n.type._parseSync(new T(t,o,t.path,i)));return x.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}};$.create=(r,e)=>new $({type:r,minLength:null,maxLength:null,exactLength:null,typeName:h.ZodArray,...g(e)});function ie(r){if(r instanceof E){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=A.create(ie(s))}return new E({...r._def,shape:()=>e})}else return r instanceof $?new $({...r._def,type:ie(r.element)}):r instanceof A?A.create(ie(r.unwrap())):r instanceof I?I.create(ie(r.unwrap())):r instanceof D?D.create(r.items.map(e=>ie(e))):r}var E=class r extends y{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(),t=_.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==d.object){let f=this._getOrReturnCtx(e);return u(f,{code:c.invalid_type,expected:d.object,received:f.parsedType}),m}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),i=[];if(!(this._def.catchall instanceof C&&this._def.unknownKeys==="strip"))for(let f in n.data)o.includes(f)||i.push(f);let l=[];for(let f of o){let v=a[f],w=n.data[f];l.push({key:{status:"valid",value:f},value:v._parse(new T(n,w,n.path,f)),alwaysSet:f in n.data})}if(this._def.catchall instanceof C){let f=this._def.unknownKeys;if(f==="passthrough")for(let v of i)l.push({key:{status:"valid",value:v},value:{status:"valid",value:n.data[v]}});else if(f==="strict")i.length>0&&(u(n,{code:c.unrecognized_keys,keys:i}),s.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let f=this._def.catchall;for(let v of i){let w=n.data[v];l.push({key:{status:"valid",value:v},value:f._parse(new T(n,w,n.path,v)),alwaysSet:v in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let f=[];for(let v of l){let w=await v.key,Re=await v.value;f.push({key:w,value:Re,alwaysSet:v.alwaysSet})}return f}).then(f=>x.mergeObjectSync(s,f)):x.mergeObjectSync(s,l)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let n=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:p.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:h.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let s of _.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let s of _.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}deepPartial(){return ie(this)}partial(e){let t={};for(let s of _.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let s of _.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof A;)a=a._def.innerType;t[s]=a}return new r({...this._def,shape:()=>t})}keyof(){return Ze(_.objectKeys(this.shape))}};E.create=(r,e)=>new E({shape:()=>r,unknownKeys:"strip",catchall:C.create(),typeName:h.ZodObject,...g(e)});E.strictCreate=(r,e)=>new E({shape:()=>r,unknownKeys:"strict",catchall:C.create(),typeName:h.ZodObject,...g(e)});E.lazycreate=(r,e)=>new E({shape:r,unknownKeys:"strip",catchall:C.create(),typeName:h.ZodObject,...g(e)});var Y=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let i of a)if(i.result.status==="valid")return i.result;for(let i of a)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(i=>new k(i.ctx.common.issues));return u(t,{code:c.invalid_union,unionErrors:o}),m}if(t.common.async)return Promise.all(s.map(async a=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(n);{let a,o=[];for(let l of s){let f={...t,common:{...t.common,issues:[]},parent:null},v=l._parseSync({data:t.data,path:t.path,parent:f});if(v.status==="valid")return v;v.status==="dirty"&&!a&&(a={result:v,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let i=o.map(l=>new k(l));return u(t,{code:c.invalid_union,unionErrors:i}),m}}get options(){return this._def.options}};Y.create=(r,e)=>new Y({options:r,typeName:h.ZodUnion,...g(e)});var j=r=>r instanceof J?j(r.schema):r instanceof S?j(r.innerType()):r instanceof X?[r.value]:r instanceof Q?r.options:r instanceof ee?_.objectValues(r.enum):r instanceof te?j(r._def.innerType):r instanceof W?[void 0]:r instanceof G?[null]:r instanceof A?[void 0,...j(r.unwrap())]:r instanceof I?[null,...j(r.unwrap())]:r instanceof pe||r instanceof se?j(r.unwrap()):r instanceof re?j(r._def.innerType):[],ye=class r extends y{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==d.object)return u(t,{code:c.invalid_type,expected:d.object,received:t.parsedType}),m;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(u(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let a of t){let o=j(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of o){if(n.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,a)}}return new r({typeName:h.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...g(s)})}};function Ee(r,e){let t=O(r),s=O(e);if(r===e)return{valid:!0,data:r};if(t===d.object&&s===d.object){let n=_.objectKeys(e),a=_.objectKeys(r).filter(i=>n.indexOf(i)!==-1),o={...r,...e};for(let i of a){let l=Ee(r[i],e[i]);if(!l.valid)return{valid:!1};o[i]=l.data}return{valid:!0,data:o}}else if(t===d.array&&s===d.array){if(r.length!==e.length)return{valid:!1};let n=[];for(let a=0;a<r.length;a++){let o=r[a],i=e[a],l=Ee(o,i);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return t===d.date&&s===d.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var q=class extends y{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,o)=>{if(he(a)||he(o))return m;let i=Ee(a.value,o.value);return i.valid?((ge(a)||ge(o))&&t.dirty(),{status:t.value,value:i.data}):(u(s,{code:c.invalid_intersection_types}),m)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,o])=>n(a,o)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};q.create=(r,e,t)=>new q({left:r,right:e,typeName:h.ZodIntersection,...g(t)});var D=class r extends y{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==d.array)return u(s,{code:c.invalid_type,expected:d.array,received:s.parsedType}),m;if(s.data.length<this._def.items.length)return u(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&s.data.length>this._def.items.length&&(u(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((o,i)=>{let l=this._def.items[i]||this._def.rest;return l?l._parse(new T(s,o,s.path,i)):null}).filter(o=>!!o);return s.common.async?Promise.all(a).then(o=>x.mergeArray(t,o)):x.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};D.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new D({items:r,typeName:h.ZodTuple,rest:null,...g(e)})};var _e=class r extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==d.object)return u(s,{code:c.invalid_type,expected:d.object,received:s.parsedType}),m;let n=[],a=this._def.keyType,o=this._def.valueType;for(let i in s.data)n.push({key:a._parse(new T(s,i,s.path,i)),value:o._parse(new T(s,s.data[i],s.path,i)),alwaysSet:i in s.data});return s.common.async?x.mergeObjectAsync(t,n):x.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof y?new r({keyType:e,valueType:t,typeName:h.ZodRecord,...g(s)}):new r({keyType:z.create(),valueType:e,typeName:h.ZodRecord,...g(t)})}},ue=class extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==d.map)return u(s,{code:c.invalid_type,expected:d.map,received:s.parsedType}),m;let n=this._def.keyType,a=this._def.valueType,o=[...s.data.entries()].map(([i,l],f)=>({key:n._parse(new T(s,i,s.path,[f,"key"])),value:a._parse(new T(s,l,s.path,[f,"value"]))}));if(s.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let l of o){let f=await l.key,v=await l.value;if(f.status==="aborted"||v.status==="aborted")return m;(f.status==="dirty"||v.status==="dirty")&&t.dirty(),i.set(f.value,v.value)}return{status:t.value,value:i}})}else{let i=new Map;for(let l of o){let f=l.key,v=l.value;if(f.status==="aborted"||v.status==="aborted")return m;(f.status==="dirty"||v.status==="dirty")&&t.dirty(),i.set(f.value,v.value)}return{status:t.value,value:i}}}};ue.create=(r,e,t)=>new ue({valueType:e,keyType:r,typeName:h.ZodMap,...g(t)});var de=class r extends y{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==d.set)return u(s,{code:c.invalid_type,expected:d.set,received:s.parsedType}),m;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(u(s,{code:c.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(u(s,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function o(l){let f=new Set;for(let v of l){if(v.status==="aborted")return m;v.status==="dirty"&&t.dirty(),f.add(v.value)}return{status:t.value,value:f}}let i=[...s.data.values()].map((l,f)=>a._parse(new T(s,l,s.path,f)));return s.common.async?Promise.all(i).then(l=>o(l)):o(i)}min(e,t){return new r({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};de.create=(r,e)=>new de({valueType:r,minSize:null,maxSize:null,typeName:h.ZodSet,...g(e)});var ve=class r extends y{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==d.function)return u(t,{code:c.invalid_type,expected:d.function,received:t.parsedType}),m;function s(i,l){return fe({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),N].filter(f=>!!f),issueData:{code:c.invalid_arguments,argumentsError:l}})}function n(i,l){return fe({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),N].filter(f=>!!f),issueData:{code:c.invalid_return_type,returnTypeError:l}})}let a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof L){let i=this;return b(async function(...l){let f=new k([]),v=await i._def.args.parseAsync(l,a).catch(xe=>{throw f.addIssue(s(l,xe)),f}),w=await Reflect.apply(o,this,v);return await i._def.returns._def.type.parseAsync(w,a).catch(xe=>{throw f.addIssue(n(w,xe)),f})})}else{let i=this;return b(function(...l){let f=i._def.args.safeParse(l,a);if(!f.success)throw new k([s(l,f.error)]);let v=Reflect.apply(o,this,f.data),w=i._def.returns.safeParse(v,a);if(!w.success)throw new k([n(v,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:D.create(e).rest(Z.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||D.create([]).rest(Z.create()),returns:t||Z.create(),typeName:h.ZodFunction,...g(s)})}},J=class extends y{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};J.create=(r,e)=>new J({getter:r,typeName:h.ZodLazy,...g(e)});var X=class extends y{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}};X.create=(r,e)=>new X({value:r,typeName:h.ZodLiteral,...g(e)});function Ze(r,e){return new Q({values:r,typeName:h.ZodEnum,...g(e)})}var Q=class r extends y{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{expected:_.joinValues(s),received:t.parsedType,code:c.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{received:t.data,code:c.invalid_enum_value,options:s}),m}return b(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};Q.create=Ze;var ee=class extends y{_parse(e){let t=_.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==d.string&&s.parsedType!==d.number){let n=_.objectValues(t);return u(s,{expected:_.joinValues(n),received:s.parsedType,code:c.invalid_type}),m}if(this._cache||(this._cache=new Set(_.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=_.objectValues(t);return u(s,{received:s.data,code:c.invalid_enum_value,options:n}),m}return b(e.data)}get enum(){return this._def.values}};ee.create=(r,e)=>new ee({values:r,typeName:h.ZodNativeEnum,...g(e)});var L=class extends y{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==d.promise&&t.common.async===!1)return u(t,{code:c.invalid_type,expected:d.promise,received:t.parsedType}),m;let s=t.parsedType===d.promise?t.data:Promise.resolve(t.data);return b(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};L.create=(r,e)=>new L({type:r,typeName:h.ZodPromise,...g(e)});var S=class extends y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===h.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:o=>{u(s,o),o.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let o=n.transform(s.data,a);if(s.common.async)return Promise.resolve(o).then(async i=>{if(t.value==="aborted")return m;let l=await this._def.schema._parseAsync({data:i,path:s.path,parent:s});return l.status==="aborted"?m:l.status==="dirty"?F(l.value):t.value==="dirty"?F(l.value):l});{if(t.value==="aborted")return m;let i=this._def.schema._parseSync({data:o,path:s.path,parent:s});return i.status==="aborted"?m:i.status==="dirty"?F(i.value):t.value==="dirty"?F(i.value):i}}if(n.type==="refinement"){let o=i=>{let l=n.refinement(i,a);if(s.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?m:(i.status==="dirty"&&t.dirty(),o(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>i.status==="aborted"?m:(i.status==="dirty"&&t.dirty(),o(i.value).then(()=>({status:t.value,value:i.value}))))}if(n.type==="transform")if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!P(o))return m;let i=n.transform(o.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>P(o)?Promise.resolve(n.transform(o.value,a)).then(i=>({status:t.value,value:i})):m);_.assertNever(n)}};S.create=(r,e,t)=>new S({schema:r,typeName:h.ZodEffects,effect:e,...g(t)});S.createWithPreprocess=(r,e,t)=>new S({schema:e,effect:{type:"preprocess",transform:r},typeName:h.ZodEffects,...g(t)});var A=class extends y{_parse(e){return this._getType(e)===d.undefined?b(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};A.create=(r,e)=>new A({innerType:r,typeName:h.ZodOptional,...g(e)});var I=class extends y{_parse(e){return this._getType(e)===d.null?b(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};I.create=(r,e)=>new I({innerType:r,typeName:h.ZodNullable,...g(e)});var te=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===d.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};te.create=(r,e)=>new te({innerType:r,typeName:h.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});var re=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ae(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new k(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new k(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};re.create=(r,e)=>new re({innerType:r,typeName:h.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});var le=class extends y{_parse(e){if(this._getType(e)!==d.nan){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:d.nan,received:s.parsedType}),m}return{status:"valid",value:e.data}}};le.create=r=>new le({typeName:h.ZodNaN,...g(r)});var kt=Symbol("zod_brand"),pe=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},me=class r extends y{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?m:a.status==="dirty"?(t.dirty(),F(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?m:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:h.ZodPipeline})}},se=class extends y{_parse(e){let t=this._def.innerType._parse(e),s=n=>(P(n)&&(n.value=Object.freeze(n.value)),n);return ae(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};se.create=(r,e)=>new se({innerType:r,typeName:h.ZodReadonly,...g(e)});function De(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function $e(r,e={},t){return r?M.create().superRefine((s,n)=>{let a=r(s);if(a instanceof Promise)return a.then(o=>{if(!o){let i=De(e,s),l=i.fatal??t??!0;n.addIssue({code:"custom",...i,fatal:l})}});if(!a){let o=De(e,s),i=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:i})}}):M.create()}var Et={object:E.lazycreate},h;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(h||(h={}));var wt=(r,e={message:`Input not instance of ${r.name}`})=>$e(t=>t instanceof r,e),Pe=z.create,ze=U.create,At=le.create,Tt=B.create,Me=K.create,St=H.create,Rt=oe.create,Ct=W.create,Ot=G.create,Dt=M.create,It=Z.create,Nt=C.create,jt=ce.create,Zt=$.create,$t=E.create,Pt=E.strictCreate,zt=Y.create,Mt=ye.create,Lt=q.create,Vt=D.create,Ft=_e.create,Ut=ue.create,Bt=de.create,Kt=ve.create,Ht=J.create,Wt=X.create,Gt=Q.create,Yt=ee.create,qt=L.create,Jt=S.create,Xt=A.create,Qt=I.create,er=S.createWithPreprocess,tr=me.create,rr=()=>Pe().optional(),sr=()=>ze().optional(),nr=()=>Me().optional(),ar={string:(r=>z.create({...r,coerce:!0})),number:(r=>U.create({...r,coerce:!0})),boolean:(r=>K.create({...r,coerce:!0})),bigint:(r=>B.create({...r,coerce:!0})),date:(r=>H.create({...r,coerce:!0}))};var ir=m;var or=R.enum(["normal","compact","minimal"]),cr=R.enum(["off","light","balanced","max"]),we=R.object({enabled:R.boolean().default(!0),telemetryOptIn:R.boolean().default(!0),outputVerbosity:or.default("compact"),reducer:cr.default("off"),filters:R.object({enableAll:R.boolean().default(!0),disabled:R.array(R.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})});import ur from"node:os";import{join as Ae}from"node:path";function V(){return process.env.TOKMIZER_HOME??Ae(ur.homedir(),".tokmizer")}function Le(){return Ae(V(),"skills")}function Te(r){return Ae(Le(),`${r}.md`)}var fr="settings-cache.json",Ve=we.parse({});async function Fe(){try{let r=await dr(lr(V(),fr),"utf8"),e=JSON.parse(r);return we.parse({...Ve,...e})}catch{return Ve}}import{mkdir as Ps,readFile as pr,writeFile as zs,stat as mr,readdir as Ms,rm as Ls}from"node:fs/promises";var Fs=3600*1e3,hr=10080*60*1e3;function gr(){let r=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(r)&&r>0?r:hr}async function Ue(r){try{let e=await mr(Te(r));return Date.now()-e.mtimeMs>gr()?null:await pr(Te(r),"utf8")}catch{return null}}var yr=[[/(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]"]];function Se(r){let e=r;for(let[t,s]of yr)e=e.replace(t,s);return e}import{join as Be}from"node:path";import{appendFileSync as Er,existsSync as wr,mkdirSync as Ar,readFileSync as ln,renameSync as fn,statSync as Tr,unlinkSync as pn}from"node:fs";var Hs={lastSettingsRevision:0,timeZone:_r(),bonusActive:!1};function _r(){try{let r=Intl.DateTimeFormat().resolvedOptions().timeZone;return r&&r.length>0?r:"Etc/UTC"}catch{return"Etc/UTC"}}import{createRequire as vr}from"node:module";var xr=vr(import.meta.url);function br(){for(let r of["../package.json","../../package.json"])try{let e=xr(r).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var kr=br();var sn=300*1e3;var Sr=512*1024;function Ke(){return Be(V(),"spool")}function Rr(r){return Be(Ke(),`${r}.jsonl`)}function He(r,e){try{Ar(Ke(),{recursive:!0,mode:448});let t=Rr(r);if(wr(t)&&Tr(t).size>=Sr)return;Er(t,JSON.stringify(e)+`
|
|
4
|
+
`,{mode:384})}catch{return}}var Cr=/^[a-z0-9][a-z0-9._-]*$/i,Or=/^[a-z][a-z-]+$/,Dr=/^[A-Za-z_][A-Za-z0-9_]*=/,Ir=new Set(["gh","glab","gup","hub","gist"]),Nr=/^(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,jr=24,Zr=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"]);function We(r){let e=r.toLowerCase();return e.startsWith("git")||Ir.has(e)}function $r(r){let e=r.trim().split(/\s+/).filter(i=>i.length>0),t=0;for(;t<e.length&&Dr.test(e[t]??"");)t+=1;let s=e[t];if(!s||!Cr.test(s)||s.length>jr||We(s)||Nr.test(s)||Se(s)!==s)return"";let n=e[t+1];return n&&We(n)?"":(n&&Zr.has(s.toLowerCase())&&Or.test(n)?`${s} ${n}`:s).slice(0,64)}async function Ge(r){if(!r.telemetryOptIn)return;let e=$r(r.cmd),t=e&&Se(e)===e?e:"other";He("telemetry",{cmd:t,tokensSaved:Math.max(0,Math.round(r.tokensSaved)),optimized:r.optimized})}var Vr={light:.25,balanced:.45,max:.7},Fr=256*1024,Ur=2e3,Br=5;function Kr(r){let e=Pr(r,"r");try{let t=zr(e).size,s=Math.max(0,t-Fr),n=Buffer.alloc(t-s);return Mr(e,n,0,n.length,s),n.toString("utf8")}finally{Lr(e)}}function Hr(r){let e=r.split(`
|
|
5
|
+
`);for(let t=e.length-1;t>=0;t--){let s=e[t];if(!(!s||!s.includes('"assistant"')))try{let n=JSON.parse(s);if(n.type!=="assistant")continue;let a=n.message?.content;if(!Array.isArray(a))continue;let o=0;for(let i of a)i?.type==="text"&&typeof i.text=="string"&&(o+=i.text.length);return o}catch{continue}}return 0}async function Wr(){let r=[];for await(let l of process.stdin)r.push(l);let t=JSON.parse(Buffer.concat(r).toString("utf8")).transcript_path;if(typeof t!="string"||!t)return;let s=await Fe(),n=Vr[s.reducer];if(!n||!await Ue(`reducer-${s.reducer}`))return;let a=Hr(Kr(t));if(a<=0)return;let o=Math.ceil(a/4),i=Math.min(Ur,Math.round(o*n/(1-n)));i<Br||await Ge({cmd:"reducer",tokensSaved:i,optimized:!0,telemetryOptIn:s.telemetryOptIn})}Wr().catch(()=>{});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
|
|
2
|
+
var Dr=Object.defineProperty;var k=(t,e)=>()=>(t&&(e=t(t=0)),e);var Pe=(t,e)=>{for(var r in e)Dr(t,r,{get:e[r],enumerable:!0})};import Rt from"node:os";import{join as Y}from"node:path";function w(){return process.env.TOKMIZER_HOME??Y(Rt.homedir(),".tokmizer")}function tt(){return Y(w(),"install-id")}function Ct(){return Y(w(),"bundle-refresh.json")}function Me(){return Y(w(),"skills")}function je(t){return Y(Me(),`${t}.md`)}function $e(){return process.env.TOKMIZER_CLAUDE_COMMANDS_DIR??Y(Rt.homedir(),".claude","commands")}function Ze(t){return Y($e(),`${t}.md`)}var B=k(()=>{"use strict"});import he from"node:os";import{createHash as Nr,randomUUID as Pr}from"node:crypto";import{readFile as Mr,writeFile as jr,mkdir as $r}from"node:fs/promises";async function nt(){try{let r=(await Mr(tt(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await $r(w(),{recursive:!0});let t=Pr();return await jr(tt(),t,{mode:384}),t}function rt(t){return Nr("sha256").update(t).digest("hex")}function Zr(){let t=he.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 P(){let t=await nt(),e=he.hostname(),r=he.platform(),n=he.release(),s=he.cpus(),a=s[0]?.model??"unknown",i=s.length,o=rt(Zr()),c=rt(he.userInfo().username),l=[e,r,n,a,String(i),o,c,t].join("|");return{fingerprint:rt(l),installId:t,hostname:e,os:r,osVersion:n,cpuModel:a,cpuCores:i,macHash:o,usernameHash:c}}var J=k(()=>{"use strict";B()});import{join as st}from"node:path";import{mkdir as zr,readFile as Lr,writeFile as Fr,unlink as Vr,rename as Br}from"node:fs/promises";function Se(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function it(t){return t?.dir??w()}async function U(t){let e=it(t);try{let r=await Lr(st(e,at),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??Se(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}async function ot(t,e){let r=it(e);await zr(r,{recursive:!0});let n=st(r,at),s=`${n}.tmp`;await Fr(s,JSON.stringify(t,null,2),{mode:384}),await Br(s,n)}async function It(t){let e=it(t);try{await Vr(st(e,at))}catch{return}}var at,Sa,Ae=k(()=>{"use strict";B();at="state.json",Sa={lastSettingsRevision:0,timeZone:Se(),bonusActive:!1}});import{createRequire as Ur}from"node:module";function Hr(){for(let t of["../package.json","../../package.json"])try{let e=Kr(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Kr,ge,ze=k(()=>{"use strict";Kr=Ur(import.meta.url);ge=Hr()});var Ot,Dt=k(()=>{"use strict";Ot=`-----BEGIN PUBLIC KEY-----
|
|
3
|
+
MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
|
|
4
|
+
-----END PUBLIC KEY-----
|
|
5
|
+
`});import{createHmac as qr,createPublicKey as Gr,verify as Wr}from"node:crypto";function ct(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??Ot).replace(/\\n/g,`
|
|
6
|
+
`)}function Jr(t,e,r,n){try{let s=Gr({key:n,format:"pem"});return Wr(null,Buffer.from(`${e}.${t}`,"utf8"),s,Buffer.from(r,"base64url"))}catch{return!1}}async function X(t){let e=await t.text(),r=ct(),n=t.headers?.get?.("x-tokmizer-resp-ts")??null;if(n!==null){let i=Number(n);if(!Number.isFinite(i)||Date.now()-i>Yr)throw new K("http","stale server response (resp-ts outside freshness window)")}if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new K("http","no signing public key configured; refusing to trust server response");let s=t.headers?.get?.("x-tokmizer-resp-sig")??null,a=Number(n);if(!s||n===null||!Number.isFinite(a))throw new K("http","missing server response signature");if(!Jr(e,a,s,r))throw new K("http","invalid server response signature");return JSON.parse(e)}function Xr(t,e,r){return qr("sha256",r).update(`${e}.${t}`).digest("hex")}async function Z(t,e,r,n){let s=Date.now(),a=r===void 0?"":JSON.stringify(r),i=n.signingSecret?Xr(a,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":i,"x-tokmizer-ts":String(s),"x-tokmizer-plugin-version":ge};n.bearer&&(o.authorization=`Bearer ${n.bearer}`);let c=n.timeoutMs??5e3,l=t!=="GET"&&t!=="DELETE",h={method:t,headers:o,signal:AbortSignal.timeout(c)};l&&(h.body=a);try{return await fetch(`${n.baseUrl}${e}`,h)}catch(b){let R=b.name;throw R==="TimeoutError"||R==="AbortError"?new K("timeout",`${t} ${e} timed out after ${c}ms`):new K("network",`${t} ${e} failed: ${b.message}`)}}var Yr,K,Te=k(()=>{"use strict";ze();Dt();Yr=300*1e3;K=class extends Error{constructor(r,n,s){super(n);this.kind=r;this.status=s;this.name="TransportError"}kind;status}});var x,pt,f,M,Re=k(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},t.find=(s,a)=>{for(let i of s)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(pt||(pt={}));f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=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,ln,A,Le=k(()=>{Re();u=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"]),ln=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),A=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(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let o=n,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(i))):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,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 a=s.path[0];r[a]=r[a]||[],r[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};A.create=t=>new A(t)});var dn,z,mt=k(()=>{Le();Re();dn=(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,x.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${x.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}"`:x.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,x.assertNever(t)}return{message:r}},z=dn});function fn(t){Ft=t}function ye(){return Ft}var Ft,Fe=k(()=>{mt();Ft=z});function d(t,e){let r=ye(),n=Ce({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===z?void 0:z].filter(s=>!!s)});t.common.issues.push(n)}var Ce,pn,E,g,Q,S,Ve,Be,H,_e,ht=k(()=>{Fe();mt();Ce=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},pn=[];E=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 a=await s.key,i=await s.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return g;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),Q=t=>({status:"dirty",value:t}),S=t=>({status:"valid",value:t}),Ve=t=>t.status==="aborted",Be=t=>t.status==="dirty",H=t=>t.status==="valid",_e=t=>typeof Promise<"u"&&t instanceof Promise});var Vt=k(()=>{});var p,Bt=k(()=>{(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:(i,o)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:i.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 In(t){return new RegExp(`^${qt(t)}$`)}function Gt(t){let e=`${Ht}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 On(t,e){return!!((e==="v4"||!e)&&wn.test(t)||(e==="v6"||!e)&&Sn.test(t))}function Dn(t,e){if(!vn.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 Nn(t,e){return!!((e==="v4"||!e)&&En.test(t)||(e==="v6"||!e)&&An.test(t))}function Pn(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}function ve(t){if(t instanceof T){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=I.create(ve(n))}return new T({...t._def,shape:()=>e})}else return t instanceof V?new V({...t._def,type:ve(t.element)}):t instanceof I?I.create(ve(t.unwrap())):t instanceof $?$.create(ve(t.unwrap())):t instanceof j?j.create(t.items.map(e=>ve(e))):t}function yt(t,e){let r=M(t),n=M(e);if(t===e)return{valid:!0,data:t};if(r===f.object&&n===f.object){let s=x.objectKeys(e),a=x.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(let o of a){let c=yt(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(r===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<t.length;a++){let i=t[a],o=e[a],c=yt(i,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 Wt(t,e){return new le({values:t,typeName:y.ZodEnum,..._(e)})}function Kt(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Yt(t,e={},r){return t?G.create().superRefine((n,s)=>{let a=t(n);if(a instanceof Promise)return a.then(i=>{if(!i){let o=Kt(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=Kt(e,n),o=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:o})}}):G.create()}var O,Ut,v,mn,hn,gn,yn,_n,vn,xn,bn,kn,gt,wn,En,Sn,An,Tn,Rn,Ht,Cn,q,ee,te,re,ne,xe,se,ae,G,F,N,be,V,T,ie,L,Ue,oe,j,Ke,ke,we,He,ce,ue,le,de,W,D,I,$,fe,pe,Ee,Mn,Ie,Oe,me,jn,y,$n,Jt,Xt,Zn,zn,Qt,Ln,Fn,Vn,Bn,Un,Kn,Hn,qn,Gn,Wn,Yn,Jn,Xn,Qn,es,ts,rs,ns,ss,as,is,os,cs,us,ls,ds,fs,ps,ms,hs,gs,ys,_s,vs,er=k(()=>{Le();Fe();Bt();ht();Re();O=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}},Ut=(t,e)=>{if(H(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 A(t.common.issues);return this._error=r,this._error}}};v=class{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new E,ctx:{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(_e(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:M(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Ut(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return H(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=>H(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:M(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(_e(s)?s:Promise.resolve(s));return Ut(n,a)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{let i=e(s),o=()=>a.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!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 D({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 I.create(this,this._def)}nullable(){return $.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return V.create(this)}promise(){return W.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return oe.create(this,e,this._def)}transform(e){return new D({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new fe({..._(this._def),innerType:this,defaultValue:r,typeName:y.ZodDefault})}brand(){return new Ie({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new pe({..._(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 Oe.create(this,e)}readonly(){return me.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},mn=/^c[^\s-]{8,}$/i,hn=/^[0-9a-z]+$/,gn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,yn=/^[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,_n=/^[a-z0-9_-]{21}$/i,vn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xn=/^[-+]?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)?)??$/,bn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,kn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",wn=/^(?:(?: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])$/,En=/^(?:(?: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])$/,Sn=/^(([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]))$/,An=/^(([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])$/,Tn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Rn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ht="((\\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])))",Cn=new RegExp(`^${Ht}$`);q=class t extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_type,expected:f.string,received:a.parsedType}),g}let n=new E,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?d(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&d(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")bn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"email",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")gt||(gt=new RegExp(kn,"u")),gt.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"emoji",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")yn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"uuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")_n.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"nanoid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")mn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")hn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid2",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")gn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ulid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),d(s,{validation:"url",code:u.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"regex",code:u.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Gt(a).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?In(a).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?xn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"duration",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?On(e.data,a.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ip",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Dn(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"jwt",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Nn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cidr",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Tn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Rn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64url",code:u.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);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)});ee=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 a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),g}let n,s=new E;for(let a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Pn(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_finite,message:a.message}),s.dirty()):x.assertNever(a);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)}};ee.create=t=>new ee({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,..._(t)});te=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 E;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);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}};te.create=t=>new te({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,..._(t)});re=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 S(e.data)}};re.create=t=>new re({typeName:y.ZodBoolean,coerce:t?.coerce||!1,..._(t)});ne=class t extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_type,expected:f.date,received:a.parsedType}),g}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_date}),g}let n=new E,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);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}};ne.create=t=>new ne({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,..._(t)});xe=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 S(e.data)}};xe.create=t=>new xe({typeName:y.ZodSymbol,..._(t)});se=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 S(e.data)}};se.create=t=>new se({typeName:y.ZodUndefined,..._(t)});ae=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 S(e.data)}};ae.create=t=>new ae({typeName:y.ZodNull,..._(t)});G=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return S(e.data)}};G.create=t=>new G({typeName:y.ZodAny,..._(t)});F=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return S(e.data)}};F.create=t=>new F({typeName:y.ZodUnknown,..._(t)});N=class extends v{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.never,received:r.parsedType}),g}};N.create=t=>new N({typeName:y.ZodNever,..._(t)});be=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 S(e.data)}};be.create=t=>new be({typeName:y.ZodVoid,..._(t)});V=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 i=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(i||o)&&(d(r,{code:i?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?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((i,o)=>s.type._parseAsync(new O(r,i,r.path,o)))).then(i=>E.mergeArray(n,i));let a=[...r.data].map((i,o)=>s.type._parseSync(new O(r,i,r.path,o)));return E.mergeArray(n,a)}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)}};V.create=(t,e)=>new V({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});T=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 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:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof N&&this._def.unknownKeys==="strip"))for(let l in s.data)i.includes(l)||o.push(l);let c=[];for(let l of i){let h=a[l],b=s.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new O(s,b,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof N){let l=this._def.unknownKeys;if(l==="passthrough")for(let h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});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 h of o){let b=s.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new O(s,b,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let h of c){let b=await h.key,R=await h.value;l.push({key:b,value:R,alwaysSet:h.alwaysSet})}return l}).then(l=>E.mergeObjectSync(n,l)):E.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 ve(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 a=this.shape[n];for(;a instanceof I;)a=a._def.innerType;r[n]=a}return new t({...this._def,shape:()=>r})}keyof(){return Wt(x.objectKeys(this.shape))}};T.create=(t,e)=>new T({shape:()=>t,unknownKeys:"strip",catchall:N.create(),typeName:y.ZodObject,..._(e)});T.strictCreate=(t,e)=>new T({shape:()=>t,unknownKeys:"strict",catchall:N.create(),typeName:y.ZodObject,..._(e)});T.lazycreate=(t,e)=>new T({shape:t,unknownKeys:"strip",catchall:N.create(),typeName:y.ZodObject,..._(e)});ie=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new A(o.ctx.common.issues));return d(r,{code:u.invalid_union,unionErrors:i}),g}if(r.common.async)return Promise.all(n.map(async a=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},h=c._parseSync({data:r.data,path:r.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new A(c));return d(r,{code:u.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};ie.create=(t,e)=>new ie({options:t,typeName:y.ZodUnion,..._(e)});L=t=>t instanceof ce?L(t.schema):t instanceof D?L(t.innerType()):t instanceof ue?[t.value]:t instanceof le?t.options:t instanceof de?x.objectValues(t.enum):t instanceof fe?L(t._def.innerType):t instanceof se?[void 0]:t instanceof ae?[null]:t instanceof I?[void 0,...L(t.unwrap())]:t instanceof $?[null,...L(t.unwrap())]:t instanceof Ie||t instanceof me?L(t.unwrap()):t instanceof pe?L(t._def.innerType):[],Ue=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],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._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 a of r){let i=L(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,..._(n)})}};oe=class extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Ve(a)||Ve(i))return g;let o=yt(a.value,i.value);return o.valid?((Be(a)||Be(i))&&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(([a,i])=>s(a,i)):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}))}};oe.create=(t,e,r)=>new oe({left:t,right:e,typeName:y.ZodIntersection,..._(r)});j=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 a=[...n.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new O(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>E.mergeArray(r,i)):E.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};j.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new j({items:t,typeName:y.ZodTuple,rest:null,..._(e)})};Ke=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=[],a=this._def.keyType,i=this._def.valueType;for(let o in n.data)s.push({key:a._parse(new O(n,o,n.path,o)),value:i._parse(new O(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?E.mergeObjectAsync(r,s):E.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)})}},ke=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,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new O(n,o,n.path,[l,"key"])),value:a._parse(new O(n,c,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return g;(l.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(l.value,h.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of i){let l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return g;(l.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(l.value,h.value)}return{status:r.value,value:o}}}};ke.create=(t,e,r)=>new ke({valueType:e,keyType:t,typeName:y.ZodMap,..._(r)});we=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 a=this._def.valueType;function i(c){let l=new Set;for(let h of c){if(h.status==="aborted")return g;h.status==="dirty"&&r.dirty(),l.add(h.value)}return{status:r.value,value:l}}let o=[...n.data.values()].map((c,l)=>a._parse(new O(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(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)}};we.create=(t,e)=>new we({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});He=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 Ce({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ye(),z].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(o,c){return Ce({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ye(),z].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof W){let o=this;return S(async function(...c){let l=new A([]),h=await o._def.args.parseAsync(c,a).catch(C=>{throw l.addIssue(n(c,C)),l}),b=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(b,a).catch(C=>{throw l.addIssue(s(b,C)),l})})}else{let o=this;return S(function(...c){let l=o._def.args.safeParse(c,a);if(!l.success)throw new A([n(c,l.error)]);let h=Reflect.apply(i,this,l.data),b=o._def.returns.safeParse(h,a);if(!b.success)throw new A([s(h,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:j.create(e).rest(F.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||j.create([]).rest(F.create()),returns:r||F.create(),typeName:y.ZodFunction,..._(n)})}},ce=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})}};ce.create=(t,e)=>new ce({getter:t,typeName:y.ZodLazy,..._(e)});ue=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}};ue.create=(t,e)=>new ue({value:t,typeName:y.ZodLiteral,..._(e)});le=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: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 S(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})}};le.create=Wt;de=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:u.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:u.invalid_enum_value,options:s}),g}return S(e.data)}get enum(){return this._def.values}};de.create=(t,e)=>new de({values:t,typeName:y.ZodNativeEnum,..._(e)});W=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 S(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};W.create=(t,e)=>new W({type:t,typeName:y.ZodPromise,..._(e)});D=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,a={addIssue:i=>{d(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).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"?Q(c.value):r.value==="dirty"?Q(c.value):c});{if(r.value==="aborted")return g;let o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?Q(o.value):r.value==="dirty"?Q(o.value):o}}if(s.type==="refinement"){let i=o=>{let c=s.refinement(o,a);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(),i(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(),i(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!H(i))return g;let o=s.transform(i.value,a);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(i=>H(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):g);x.assertNever(s)}};D.create=(t,e,r)=>new D({schema:t,typeName:y.ZodEffects,effect:e,..._(r)});D.createWithPreprocess=(t,e,r)=>new D({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,..._(r)});I=class extends v{_parse(e){return this._getType(e)===f.undefined?S(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};I.create=(t,e)=>new I({innerType:t,typeName:y.ZodOptional,..._(e)});$=class extends v{_parse(e){return this._getType(e)===f.null?S(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:y.ZodNullable,..._(e)});fe=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}};fe.create=(t,e)=>new fe({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});pe=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 _e(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new A(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new A(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};pe.create=(t,e)=>new pe({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});Ee=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}}};Ee.create=t=>new Ee({typeName:y.ZodNaN,..._(t)});Mn=Symbol("zod_brand"),Ie=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}},Oe=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?g:a.status==="dirty"?(r.dirty(),Q(a.value)):this._def.out._parseAsync({data:a.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})}},me=class extends v{_parse(e){let r=this._def.innerType._parse(e),n=s=>(H(s)&&(s.value=Object.freeze(s.value)),s);return _e(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};me.create=(t,e)=>new me({innerType:t,typeName:y.ZodReadonly,..._(e)});jn={object:T.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={}));$n=(t,e={message:`Input not instance of ${t.name}`})=>Yt(r=>r instanceof t,e),Jt=q.create,Xt=ee.create,Zn=Ee.create,zn=te.create,Qt=re.create,Ln=ne.create,Fn=xe.create,Vn=se.create,Bn=ae.create,Un=G.create,Kn=F.create,Hn=N.create,qn=be.create,Gn=V.create,Wn=T.create,Yn=T.strictCreate,Jn=ie.create,Xn=Ue.create,Qn=oe.create,es=j.create,ts=Ke.create,rs=ke.create,ns=we.create,ss=He.create,as=ce.create,is=ue.create,os=le.create,cs=de.create,us=W.create,ls=D.create,ds=I.create,fs=$.create,ps=D.createWithPreprocess,ms=Oe.create,hs=()=>Jt().optional(),gs=()=>Xt().optional(),ys=()=>Qt().optional(),_s={string:(t=>q.create({...t,coerce:!0})),number:(t=>ee.create({...t,coerce:!0})),boolean:(t=>re.create({...t,coerce:!0})),bigint:(t=>te.create({...t,coerce:!0})),date:(t=>ne.create({...t,coerce:!0}))},vs=g});var m={};Pe(m,{BRAND:()=>Mn,DIRTY:()=>Q,EMPTY_PATH:()=>pn,INVALID:()=>g,NEVER:()=>vs,OK:()=>S,ParseStatus:()=>E,Schema:()=>v,ZodAny:()=>G,ZodArray:()=>V,ZodBigInt:()=>te,ZodBoolean:()=>re,ZodBranded:()=>Ie,ZodCatch:()=>pe,ZodDate:()=>ne,ZodDefault:()=>fe,ZodDiscriminatedUnion:()=>Ue,ZodEffects:()=>D,ZodEnum:()=>le,ZodError:()=>A,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>He,ZodIntersection:()=>oe,ZodIssueCode:()=>u,ZodLazy:()=>ce,ZodLiteral:()=>ue,ZodMap:()=>ke,ZodNaN:()=>Ee,ZodNativeEnum:()=>de,ZodNever:()=>N,ZodNull:()=>ae,ZodNullable:()=>$,ZodNumber:()=>ee,ZodObject:()=>T,ZodOptional:()=>I,ZodParsedType:()=>f,ZodPipeline:()=>Oe,ZodPromise:()=>W,ZodReadonly:()=>me,ZodRecord:()=>Ke,ZodSchema:()=>v,ZodSet:()=>we,ZodString:()=>q,ZodSymbol:()=>xe,ZodTransformer:()=>D,ZodTuple:()=>j,ZodType:()=>v,ZodUndefined:()=>se,ZodUnion:()=>ie,ZodUnknown:()=>F,ZodVoid:()=>be,addIssueToContext:()=>d,any:()=>Un,array:()=>Gn,bigint:()=>zn,boolean:()=>Qt,coerce:()=>_s,custom:()=>Yt,date:()=>Ln,datetimeRegex:()=>Gt,defaultErrorMap:()=>z,discriminatedUnion:()=>Xn,effect:()=>ls,enum:()=>os,function:()=>ss,getErrorMap:()=>ye,getParsedType:()=>M,instanceof:()=>$n,intersection:()=>Qn,isAborted:()=>Ve,isAsync:()=>_e,isDirty:()=>Be,isValid:()=>H,late:()=>jn,lazy:()=>as,literal:()=>is,makeIssue:()=>Ce,map:()=>rs,nan:()=>Zn,nativeEnum:()=>cs,never:()=>Hn,null:()=>Bn,nullable:()=>fs,number:()=>Xt,object:()=>Wn,objectUtil:()=>pt,oboolean:()=>ys,onumber:()=>gs,optional:()=>ds,ostring:()=>hs,pipeline:()=>ms,preprocess:()=>ps,promise:()=>us,quotelessJson:()=>ln,record:()=>ts,set:()=>ns,setErrorMap:()=>fn,strictObject:()=>Yn,string:()=>Jt,symbol:()=>Fn,transformer:()=>ls,tuple:()=>es,undefined:()=>Vn,union:()=>Jn,unknown:()=>Kn,util:()=>x,void:()=>qn});var _t=k(()=>{Fe();ht();Vt();Re();er();Le()});var qe=k(()=>{_t();_t()});var sr,ar=k(()=>{"use strict";qe();sr=m.object({slug:m.string().min(1).max(64),description:m.string().max(255).optional(),match_command:m.string().min(1),priority:m.number().int().default(50),strip_ansi:m.boolean().default(!1),strip_lines_matching:m.array(m.string()).default([]),truncate_lines_at:m.number().int().positive().max(1e4).optional(),max_lines:m.number().int().positive().max(1e5).optional(),transform:m.string().max(64).optional(),on_empty:m.string().max(255).optional()})});function or(t){return JSON.stringify(t)+Ge}function*cr(t){let e=0;for(;;){let r=t.indexOf(Ge,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function We(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Ts,Rs,Cs,Is,Ni,Pi,Mi,ir,Ge,ji,ur=k(()=>{"use strict";qe();ar();Ts=m.object({id:m.string().min(1).max(64),op:m.literal("filter"),cmd:m.string().min(1).max(2048),plan:m.enum(["trial","smart","pro"]),installId:m.string().min(1).max(64).optional()}),Rs=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),Cs=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),Is=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),Ni=m.discriminatedUnion("op",[Ts,Rs,Cs,Is]),Pi=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),Mi=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),ir=m.object({filter:sr.nullable(),cacheHit:m.boolean().optional()}),Ge=`
|
|
7
|
+
`,ji=64*1024});import{join as vt}from"node:path";import{existsSync as lr,statSync as Os,unlinkSync as Ds,mkdirSync as Ns,chmodSync as Ps}from"node:fs";function Ye(){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&&lr(e))return{path:vt(e,`tokmizer-${t}.sock`),isPipe:!1};let r=vt(w(),"run");try{Ns(r,{recursive:!0,mode:448}),Ps(r,448)}catch{}return{path:vt(r,"daemon.sock"),isPipe:!1}}async function dr(){let{path:t,isPipe:e}=Ye();if(e||!lr(t))return;try{if(!Os(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let a=r.createConnection(t),i=o=>{a.removeAllListeners();try{a.destroy()}catch{}s(o)};a.once("connect",()=>i(!0)),a.once("error",o=>{let c=o.code;i(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>i(!0),250)}))try{Ds(t)}catch{}}var Fi,fr=k(()=>{"use strict";B();Fi=5*6e4});var vr={};Pe(vr,{connectDaemon:()=>Hs});import{createConnection as Ms}from"node:net";import{spawn as js}from"node:child_process";import{existsSync as _r,openSync as pr,closeSync as $s,unlinkSync as mr,writeFileSync as hr}from"node:fs";import{dirname as Zs,join as zs}from"node:path";import{fileURLToPath as Ls}from"node:url";async function Bs(t,e){return new Promise((r,n)=>{let s=Ms(t),a=o=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(i),o){try{s.destroy()}catch{}n(o)}else r(s)},i=setTimeout(()=>a(new Error("connect timeout")),e);s.once("connect",()=>a(null)),s.once("error",o=>a(o))})}function Us(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Ls(new URL("../bin/tkr-daemon.js",import.meta.url))}async function yr(t,e=3e3){let r=Math.ceil(e/75);for(let n=0;n<r;n++){if(_r(t))return!0;await new Promise(s=>setTimeout(s,75))}return!1}async function Ks(t){let e=Us();if(!_r(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=Ye(),n=zs(Zs(r),"daemon.spawn.lock"),s=null;try{s=pr(n,"wx"),hr(s,String(process.pid))}catch(a){if(a.code==="EEXIST"){if(await yr(r,5e3))return;try{mr(n)}catch{}s=pr(n,"wx"),hr(s,String(process.pid))}else throw a}try{if(js(process.execPath,[e],{detached:!0,stdio:["ignore","ignore","ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),!await yr(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(s!==null){try{$s(s)}catch{}try{mr(n)}catch{}}}}async function Hs(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Ye(),r=await nt(),n=null,s=0;for(;s<=gr;)try{n=await Bs(e,Fs);break}catch{if(s+=1,s>gr)throw new Error(`tkr-daemon unreachable at ${e}`);await dr(),await Ks(r)}if(!n)throw new Error("tkr-daemon: socket setup failed");let a=new Map,i="";n.setEncoding("utf8"),n.on("data",c=>{i+=c;let l=-1;for(let b=0;b<i.length;b++)i[b]===Ge&&(l=b);if(l<0)return;let h=[];for(let b of cr(i.slice(0,l+1)))h.push(b);i=i.slice(l+1);for(let b of h)if(b)try{let R=JSON.parse(b),C=a.get(R.id);if(!C)continue;clearTimeout(C.timer),a.delete(R.id),C.resolve(R)}catch{}}),n.on("close",()=>{for(let c of a.values())clearTimeout(c.timer),c.reject(new Error("daemon socket closed"));a.clear()}),n.on("error",()=>{});function o(c){return new Promise((l,h)=>{let b=setTimeout(()=>{a.delete(c.id),h(new Error(`daemon request timeout (${c.op})`))},Vs);a.set(c.id,{resolve:l,reject:h,timer:b}),n.write(or(c))})}return{filter:async(c,l)=>{let h=await o({id:We(),op:"filter",cmd:c.slice(0,2048),plan:l,installId:r});if(!h.ok)return null;let b=ir.safeParse(h.data);return b.success?b.data.filter:null},ping:async()=>{let c=await o({id:We(),op:"ping"});if(!c.ok)throw new Error(c.err);return c.data},reload:async()=>{let c=await o({id:We(),op:"reload",installId:r});if(!c.ok)throw new Error(c.err);return c.data},close:()=>{try{n.end()}catch{}}}}var Fs,Vs,gr,xr=k(()=>{"use strict";ur();fr();J();Fs=500,Vs=3e3,gr=1});function De(t){let e=t;for(let[r,n]of qs)e=e.replace(r,n);return e}var qs,xt=k(()=>{"use strict";qs=[[/(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 Et}from"node:path";import{appendFileSync as wt,existsSync as Ne,mkdirSync as Gs,readFileSync as bt,renameSync as br,statSync as Ws,unlinkSync as Je}from"node:fs";function St(){return Et(w(),"spool")}function Er(t){return Et(St(),`${t}.jsonl`)}function Sr(t){return Et(St(),`${t}.pending.jsonl`)}function Xe(t,e){try{Gs(St(),{recursive:!0,mode:448});let r=Er(t);if(Ne(r)&&Ws(r).size>=Ys)return;wt(r,JSON.stringify(e)+`
|
|
8
|
+
`,{mode:384})}catch{return}}function Js(t){try{let e=Sr(t),r=Er(t),n=`${r}.merging`;if(Ne(n)&&(wt(e,bt(n,"utf8"),{mode:384}),Je(n)),Ne(e))Ne(r)&&(br(r,n),wt(e,bt(n,"utf8"),{mode:384}),Je(n));else{if(!Ne(r))return[];br(r,e)}let s=[];for(let a of bt(e,"utf8").split(`
|
|
9
|
+
`))if(a.trim())try{s.push(JSON.parse(a))}catch{continue}return s.length===0?(Je(e),[]):s}catch{return[]}}function wr(t){try{Je(Sr(t))}catch{return}}async function Qe(t,e,r={}){if(!kt.has(t)){kt.add(t);try{let n=Js(t);if(n.length===0)return;let s=await U();if(!s)return;if(r.requirePro&&s.plan!=="pro"){wr(t);return}let a=r.baseUrl??process.env.TOKMIZER_BASE_URL??"https://tokmizer.com",i=await P();for(let o=0;o<n.length;o+=kr)await Z("POST",e,{events:n.slice(o,o+kr)},{baseUrl:a,bearer:s.jwt,signingSecret:s.signingSecret,fingerprint:i.fingerprint,installId:i.installId});wr(t)}catch{return}finally{kt.delete(t)}}}var Ys,kr,kt,At=k(()=>{"use strict";B();Ae();J();Te();Ys=512*1024,kr=500,kt=new Set});var Tr={};Pe(Tr,{commandName:()=>et,flushTelemetry:()=>ia,recordTelemetry:()=>aa});function Ar(t){let e=t.toLowerCase();return e.startsWith("git")||ta.has(e)}function et(t){let e=t.trim().split(/\s+/).filter(o=>o.length>0),r=0;for(;r<e.length&&ea.test(e[r]??"");)r+=1;let n=e[r];if(!n||!Xs.test(n)||n.length>na||Ar(n)||ra.test(n)||De(n)!==n)return"";let s=e[r+1];return s&&Ar(s)?"":(s&&sa.has(n.toLowerCase())&&Qs.test(s)?`${n} ${s}`:n).slice(0,64)}async function aa(t){if(!t.telemetryOptIn)return;let e=et(t.cmd),r=e&&De(e)===e?e:"other";Xe("telemetry",{cmd:r,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),optimized:t.optimized})}async function ia(t){await Qe("telemetry","/api/v1/telemetry",{baseUrl:t})}var Xs,Qs,ea,ta,ra,na,sa,Tt=k(()=>{"use strict";xt();At();Xs=/^[a-z0-9][a-z0-9._-]*$/i,Qs=/^[a-z][a-z-]+$/,ea=/^[A-Za-z_][A-Za-z0-9_]*=/,ta=new Set(["gh","glab","gup","hub","gist"]),ra=/^(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,na=24,sa=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"])});var Rr={};Pe(Rr,{flush:()=>ca,recordEvent:()=>oa});async function oa(t){if(t.plan!=="pro")return;let e=et(t.cmd);!e||De(e)!==e||Xe("learn",{cmd:e,filterId:t.filterId,rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}async function ca(t){await Qe("learn","/api/v1/learn",{baseUrl:t,requirePro:!0})}var Cr=k(()=>{"use strict";Tt();xt();At()});J();Ae();Te();B();Te();Ae();J();import{createPublicKey as Qr,verify as en}from"node:crypto";function tn(t,e){let r=ct();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=Qr({key:r,format:"pem"});try{let s=Buffer.from(e,"base64url");return en(null,Buffer.from(t,"utf8"),n,s)}catch{return!1}}var rn=/^[a-z0-9][a-z0-9-]*$/;async function Nt(t){let e=await U();if(!e)throw new Error("Plugin not activated.");let r=await P(),n=await Z("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 X(n),a=[];for(let i of s.bundles){if(!rn.test(i.slug))throw new Error(`invalid bundle slug ${i.slug}`);let o=[...i.fragments].sort((c,l)=>c.position-l.position);for(let c of o)if(!tn(c.body,c.hash))throw new Error(`fragment signature mismatch on ${i.slug}[${c.position}]`);a.push({slug:i.slug,version:i.version,body:o.map(c=>c.body).join(`
|
|
10
|
+
|
|
11
|
+
`)})}return a}B();import{mkdir as ut,readFile as nn,writeFile as lt,stat as sn,readdir as Pt,rm as Mt}from"node:fs/promises";var an="managed-by: tokmizer",on=3600*1e3,cn=10080*60*1e3;function un(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:cn}async function jt(t){try{let e=await sn(je(t)),r=Date.now()-e.mtimeMs;return r<on&&r<=un()}catch{return!1}}async function $t(t,e){await ut(Me(),{recursive:!0}),await lt(je(t),e,{mode:384})}async function Zt(t){let e=new Set(t),r;try{r=await Pt(Me())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{await Mt(je(s))}catch{}}}async function zt(t,e){await ut($e(),{recursive:!0}),await lt(Ze(t),e,{mode:384})}async function dt(t){let e=new Set(t),r;try{r=await Pt($e())}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 nn(Ze(s),"utf8")).includes(an))continue;await Mt(Ze(s))}catch{}}}async function ft(t){try{await ut(w(),{recursive:!0}),await lt(Ct(),JSON.stringify({at:Date.now(),error:t}),{mode:384})}catch{}}var Lt={welcome:"Link your paid Tokmizer account.",needToken:"Tokmizer already works for free on this device. Linking is only to attach a paid plan.",getToken:"Subscribe at tokmizer.com/#pricing, then grab your key from your dashboard.",askToken:"Paste your dashboard key, then press Enter:",activating:"Linking...",activated:t=>`Linked. You are on the ${t} plan.`,failed:t=>`Activation failed: ${t}`,trialEnded:"Your trial has ended. Renew at tokmizer.com/dashboard/billing",suspended:t=>`Your token is suspended. ${t}`,revoked:"Your token has been revoked. Contact support at tokmizer.com/contact",rotated:"Token rotated. Paste your new token from tokmizer.com/dashboard/token",offline:"Network required. Tokmizer needs an internet connection.",deviceCap:"Device limit reached. Manage devices at tokmizer.com/dashboard/devices"};Ae();J();Te();import{readFile as _i,writeFile as ks,mkdir as ws}from"node:fs/promises";import{join as Es}from"node:path";qe();var xs=m.enum(["normal","compact","minimal"]),bs=m.enum(["off","light","balanced","max"]),tr=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:xs.default("compact"),reducer:bs.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})});B();var Ss="settings-cache.json",ki=tr.parse({});async function rr(t){await ws(w(),{recursive:!0}),await ks(Es(w(),Ss),JSON.stringify(t,null,2),{mode:384})}async function As(t,e){let r=await U();if(!r)throw new Error("Not activated. Run: tkr link");let n=process.env.TOKMIZER_BASE_URL??"https://tokmizer.com",s=await P(),a=await Z(t,"/api/v1/settings",e,{baseUrl:n,bearer:r.jwt,signingSecret:r.signingSecret,fingerprint:s.fingerprint,installId:s.installId,timeoutMs:8e3});if(!a.ok)throw new Error(`Settings ${t} failed: ${a.status}`);let i=await X(a);return await rr(i.settings),i}async function nr(){return As("GET")}ze();var Ir="-command";async function Or(t,e){if(!(!e&&await jt("power")))try{let r=await Nt(t),n=[],s=[];for(let a of r)if(a.slug.endsWith(Ir)){let i=a.slug.slice(0,-Ir.length);await zt(i,a.body),s.push(i)}else await $t(a.slug,a.body),n.push(a.slug);await Zt(n),await dt(s),await ft(null)}catch(r){await ft(r instanceof Error?r.message:String(r))}}async function ua(t,e){let r;for(let n=0;n<e.attempts;n++)try{return await t()}catch(s){if(r=s,n===e.attempts-1)break;let a=500*Math.pow(3,n)+Math.floor(Math.random()*300);await new Promise(i=>setTimeout(i,a))}throw r}async function la(t){let e=await P(),r=Se(),n={token:t.token,...t.email?{email:t.email}:{},pluginVersion:ge,timeZone:r,...e},s=await ua(()=>Z("POST","/api/v1/license/activate",n,{baseUrl:t.baseUrl,bearer:t.token,fingerprint:e.fingerprint,installId:e.installId,timeoutMs:1e4}),{attempts:3});if(!s.ok)throw s.status>=500?new Error("Tokmizer servers are temporarily unreachable. Try again in a minute."):new Error(Lt.failed(`${s.status} ${await s.text()}`));let a=await X(s),i={token:t.token,jwt:a.jwt,signingSecret:a.signingSecret,plan:a.plan,status:a.status,trialEndsAt:a.trialEndsAt,subEndsAt:a.subEndsAt,jwtVersion:a.jwtVersion,installId:e.installId,fingerprint:e.fingerprint,pluginVersion:ge,...t.email||a.boundEmail?{email:t.email??a.boundEmail??""}:{},timeZone:r,bonusActive:!1,lastHeartbeatOkAt:Date.now()};return await ot(i),await Or(t.baseUrl,!0),i}function da(t){try{return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date)}catch{return new Date().toISOString().slice(0,10)}}async function fa(t){let e=await U();if(!e)return null;let r=await P(),n=e.timeZone??Se(),s={ts:Date.now(),localDate:da(n),timeZone:n},a;try{a=await Z("POST","/api/v1/license/heartbeat",s,{baseUrl:t,bearer:e.jwt,signingSecret:e.signingSecret,fingerprint:r.fingerprint,installId:r.installId,timeoutMs:5e3})}catch{return e}if(a.status===401)return null;if(a.status===423||a.status===426||a.status===451){await It();try{await dt([])}catch{}return null}if(!a.ok)return e;let i;try{i=await X(a)}catch{return e}let o=i.settingsRevision??0,c=e.lastSettingsRevision??0,l=o>c,h=i.plan!==e.plan,b={...e,jwt:i.jwt,plan:i.plan,status:i.status,trialEndsAt:i.trialEndsAt,subEndsAt:i.subEndsAt,jwtVersion:i.jwtVersion,lastSettingsRevision:o,lastHeartbeatOkAt:Date.now(),timeZone:n,bonusActive:i.bonusActive??!1,...i.bonusResetAt!==void 0?{bonusResetAt:i.bonusResetAt}:{},...i.latestPluginVersion?{latestPluginVersion:i.latestPluginVersion}:{},...Array.isArray(i.allowedFilters)?{allowedFilters:i.allowedFilters}:{}};if(await ot(b),l)try{await nr()}catch{}if(l||h)try{let{connectDaemon:R}=await Promise.resolve().then(()=>(xr(),vr)),C=await R();try{await C.reload()}finally{C.close()}}catch{}await Or(t,l||h);try{let{flushTelemetry:R}=await Promise.resolve().then(()=>(Tt(),Tr)),{flush:C}=await Promise.resolve().then(()=>(Cr(),Rr));await R(t),await C(t)}catch{}return b}var ko=5*6e4;J();ze();export{ge as PLUGIN_VERSION,la as activate,P as buildFingerprint,fa as heartbeat};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
|
|
2
|
+
var E=`-----BEGIN PUBLIC KEY-----
|
|
3
|
+
MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
|
|
4
|
+
-----END PUBLIC KEY-----
|
|
5
|
+
`;export{E as TOKMIZER_PROD_PUBLIC_KEY_PEM};
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/on-session-start.mjs\"",
|
|
10
|
+
"timeout": 5
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "command",
|
|
14
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/hooks-host/reducer-session-start.js\"",
|
|
15
|
+
"timeout": 5
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"UserPromptSubmit": [
|
|
21
|
+
{
|
|
22
|
+
"matcher": "",
|
|
23
|
+
"hooks": [
|
|
24
|
+
{
|
|
25
|
+
"type": "command",
|
|
26
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/hooks-host/reducer-prompt-submit.js\"",
|
|
27
|
+
"timeout": 5
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"Stop": [
|
|
33
|
+
{
|
|
34
|
+
"matcher": "",
|
|
35
|
+
"hooks": [
|
|
36
|
+
{
|
|
37
|
+
"type": "command",
|
|
38
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/hooks-host/reducer-stop.js\"",
|
|
39
|
+
"timeout": 5
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"PreToolUse": [
|
|
45
|
+
{
|
|
46
|
+
"matcher": "Bash",
|
|
47
|
+
"hooks": [
|
|
48
|
+
{
|
|
49
|
+
"type": "command",
|
|
50
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/hooks-host/pre-tool-use.js\"",
|
|
51
|
+
"timeout": 5
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"PostToolUse": [
|
|
57
|
+
{
|
|
58
|
+
"matcher": "Read|Grep|Glob|Bash",
|
|
59
|
+
"hooks": [
|
|
60
|
+
{
|
|
61
|
+
"type": "command",
|
|
62
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/hooks-host/post-tool-use.js\"",
|
|
63
|
+
"timeout": 5
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { join, dirname } from "node:path";
|
|
4
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
|
|
7
|
+
const home = process.env.TOKMIZER_HOME || join(homedir(), ".tokmizer");
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const onboardFile = join(home, "onboarded");
|
|
11
|
+
if (!existsSync(onboardFile)) {
|
|
12
|
+
console.log(
|
|
13
|
+
"Tokmizer is on with the recommended settings. Free tier, no account needed.\n" +
|
|
14
|
+
"Pick your own experience anytime: run 'tkr settings configure' in a terminal.\n" +
|
|
15
|
+
"Paid plan? Link it with 'tkr link'."
|
|
16
|
+
);
|
|
17
|
+
mkdirSync(home, { recursive: true });
|
|
18
|
+
writeFileSync(onboardFile, String(Date.now()));
|
|
19
|
+
}
|
|
20
|
+
} catch {}
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const onboardFile = join(home, "onboarded");
|
|
24
|
+
const shimNudge = join(home, "shim-nudge");
|
|
25
|
+
const shimsDir = join(home, "shims");
|
|
26
|
+
if (existsSync(onboardFile) && !existsSync(shimNudge) && !existsSync(shimsDir)) {
|
|
27
|
+
const onboardedAt = Number(readFileSync(onboardFile, "utf8")) || 0;
|
|
28
|
+
if (onboardedAt > 0 && Date.now() - onboardedAt >= 24 * 60 * 60 * 1000) {
|
|
29
|
+
console.log(
|
|
30
|
+
"Tokmizer covers this agent. Your other terminals and sub-agents are not covered yet. " +
|
|
31
|
+
"One command fixes that: tkr shim install"
|
|
32
|
+
);
|
|
33
|
+
writeFileSync(shimNudge, String(Date.now()));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} catch {}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const onboardFile = join(home, "onboarded");
|
|
40
|
+
const nudgeFile = join(home, "value-nudge");
|
|
41
|
+
if (existsSync(onboardFile) && !existsSync(nudgeFile)) {
|
|
42
|
+
const onboardedAt = Number(readFileSync(onboardFile, "utf8")) || 0;
|
|
43
|
+
if (onboardedAt > 0 && Date.now() - onboardedAt >= 60 * 60 * 1000 && existsSync(join(home, "stats.jsonl"))) {
|
|
44
|
+
let rawB = 0;
|
|
45
|
+
let filtB = 0;
|
|
46
|
+
for (const line of readFileSync(join(home, "stats.jsonl"), "utf8").split("\n")) {
|
|
47
|
+
if (!line.trim()) continue;
|
|
48
|
+
try {
|
|
49
|
+
const rec = JSON.parse(line);
|
|
50
|
+
if (typeof rec.r === "number" && typeof rec.f === "number") {
|
|
51
|
+
rawB += rec.r;
|
|
52
|
+
filtB += rec.f;
|
|
53
|
+
}
|
|
54
|
+
} catch {}
|
|
55
|
+
}
|
|
56
|
+
const saved = Math.max(0, Math.ceil(rawB / 4) - Math.ceil(filtB / 4));
|
|
57
|
+
if (saved >= 1000) {
|
|
58
|
+
const label = saved >= 1e6 ? (saved / 1e6).toFixed(1) + "M" : saved >= 1e3 ? (saved / 1e3).toFixed(1) + "K" : String(saved);
|
|
59
|
+
console.log(`Tokmizer has already saved you ~${label} tokens since install. Details: /tkr-gain`);
|
|
60
|
+
writeFileSync(nudgeFile, String(Date.now()));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} catch {}
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
68
|
+
const manifest = JSON.parse(readFileSync(join(here, "..", ".claude-plugin", "plugin.json"), "utf8"));
|
|
69
|
+
const state = JSON.parse(readFileSync(join(home, "state.json"), "utf8"));
|
|
70
|
+
const latest = state.latestPluginVersion;
|
|
71
|
+
if (latest && manifest.version && latest !== manifest.version) {
|
|
72
|
+
const nudgeFile = join(home, `update-nudge-${latest}`);
|
|
73
|
+
if (!existsSync(nudgeFile)) {
|
|
74
|
+
console.log(`Tokmizer ${latest} is available. Update with: /tkr-update`);
|
|
75
|
+
writeFileSync(nudgeFile, String(Date.now()));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} catch {}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const stateFile = join(home, "state.json");
|
|
82
|
+
const throttleFile = join(home, "last-auto-heartbeat");
|
|
83
|
+
const THROTTLE_MS = 6 * 60 * 60 * 1000;
|
|
84
|
+
|
|
85
|
+
let last = 0;
|
|
86
|
+
try {
|
|
87
|
+
last = Number(readFileSync(throttleFile, "utf8")) || 0;
|
|
88
|
+
} catch {}
|
|
89
|
+
|
|
90
|
+
if (existsSync(stateFile) && Date.now() - last >= THROTTLE_MS) {
|
|
91
|
+
try {
|
|
92
|
+
writeFileSync(throttleFile, String(Date.now()));
|
|
93
|
+
} catch {}
|
|
94
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
95
|
+
const tkr = join(here, "..", "dist", "bin", "tkr.js");
|
|
96
|
+
const child = spawn(process.execPath, [tkr, "heartbeat"], {
|
|
97
|
+
detached: true,
|
|
98
|
+
stdio: "ignore"
|
|
99
|
+
});
|
|
100
|
+
child.unref();
|
|
101
|
+
}
|
|
102
|
+
} catch {}
|