@tokmizer/plugin 0.5.5 → 0.5.7
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 +1 -1
- package/codex-plugin/plugin.json +1 -1
- package/dist/bin/tkr-daemon.js +9 -9
- package/dist/bin/tkr-exec.js +11 -11
- package/dist/bin/tkr.js +16 -16
- package/dist/hooks-host/reducer-stop.js +1 -1
- package/dist/index.js +5 -5
- package/package.json +1 -1
package/codex-plugin/plugin.json
CHANGED
package/dist/bin/tkr-daemon.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
|
|
3
|
-
var nn=Object.defineProperty;var w=(t,e)=>()=>(t&&(e=t(t=0)),e);var Be=(t,e)=>{for(var r in e)nn(t,r,{get:e[r],enumerable:!0})};var b,pt,f,M,Ne=w(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let i={};for(let a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(let o of i)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(b||(b={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(pt||(pt={}));f=b.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,sn,I,Ve=w(()=>{Ne();u=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),sn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),I=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};I.create=t=>new I(t)});var an,F,mt=w(()=>{Ve();Ne();an=(t,e)=>{let r;switch(t.code){case u.invalid_type:t.received===f.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:r="Invalid function arguments";break;case u.invalid_return_type:r="Invalid function return type";break;case u.invalid_date:r="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case u.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case u.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case u.custom:r="Invalid input";break;case u.invalid_intersection_types:r="Intersection results could not be merged";break;case u.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:r="Number must be finite";break;default:r=e.defaultError,b.assertNever(t)}return{message:r}},F=an});function on(t){qt=t}function ge(){return qt}var qt,Ue=w(()=>{mt();qt=F});function d(t,e){let r=ge(),n=Pe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===F?void 0:F].filter(s=>!!s)});t.common.issues.push(n)}var Pe,cn,E,g,X,A,Ke,He,K,ye,ht=w(()=>{Ue();mt();Pe=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},cn=[];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 i=await s.key,a=await s.value;n.push({key:i,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return g;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),X=t=>({status:"dirty",value:t}),A=t=>({status:"valid",value:t}),Ke=t=>t.status==="aborted",He=t=>t.status==="dirty",K=t=>t.status==="valid",ye=t=>typeof Promise<"u"&&t instanceof Promise});var Gt=w(()=>{});var m,Yt=w(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}))});function v(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}function er(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 Sn(t){return new RegExp(`^${er(t)}$`)}function tr(t){let e=`${Qt}T${er(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 An(t,e){return!!((e==="v4"||!e)&&_n.test(t)||(e==="v6"||!e)&&xn.test(t))}function Tn(t,e){if(!mn.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 Rn(t,e){return!!((e==="v4"||!e)&&vn.test(t)||(e==="v6"||!e)&&bn.test(t))}function In(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}function _e(t){if(t instanceof C){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=D.create(_e(n))}return new C({...t._def,shape:()=>e})}else return t instanceof U?new U({...t._def,type:_e(t.element)}):t instanceof D?D.create(_e(t.unwrap())):t instanceof $?$.create(_e(t.unwrap())):t instanceof j?j.create(t.items.map(e=>_e(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=b.objectKeys(e),i=b.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(let o of i){let c=yt(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(r===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],o=e[i],c=yt(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function rr(t,e){return new ue({values:t,typeName:y.ZodEnum,...v(e)})}function Xt(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function nr(t,e={},r){return t?W.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(a=>{if(!a){let o=Xt(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!i){let a=Xt(e,n),o=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:o})}}):W.create()}var O,Jt,x,un,ln,dn,fn,pn,mn,hn,gn,yn,gt,_n,vn,xn,bn,kn,wn,Qt,En,H,Q,ee,te,re,ve,ne,se,W,V,P,xe,U,C,ie,B,We,ae,j,qe,be,ke,Ge,oe,ce,ue,le,q,N,D,$,de,fe,we,Cn,Me,je,pe,Dn,y,On,sr,ir,Nn,Pn,ar,Mn,jn,$n,Ln,Zn,zn,Fn,Bn,Vn,Un,Kn,Hn,Wn,qn,Gn,Yn,Jn,Xn,Qn,es,ts,rs,ns,ss,is,as,os,cs,us,ls,ds,fs,ps,ms,or=w(()=>{Ve();Ue();Yt();ht();Ne();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}},Jt=(t,e)=>{if(K(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new I(t.common.issues);return this._error=r,this._error}}};x=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(ye(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 Jt(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 K(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=>K(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}),i=await(ye(s)?s:Promise.resolve(s));return Jt(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let a=e(s),o=()=>i.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new N({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 D.create(this,this._def)}nullable(){return $.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return U.create(this)}promise(){return q.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return ae.create(this,e,this._def)}transform(e){return new N({...v(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new de({...v(this._def),innerType:this,defaultValue:r,typeName:y.ZodDefault})}brand(){return new Me({typeName:y.ZodBranded,type:this,...v(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new fe({...v(this._def),innerType:this,catchValue:r,typeName:y.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return je.create(this,e)}readonly(){return pe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},un=/^c[^\s-]{8,}$/i,ln=/^[0-9a-z]+$/,dn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,fn=/^[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,pn=/^[a-z0-9_-]{21}$/i,mn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,hn=/^[-+]?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)?)??$/,gn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",_n=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,xn=/^(([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]))$/,bn=/^(([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])$/,kn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,wn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qt="((\\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])))",En=new RegExp(`^${Qt}$`);H=class t extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.string,received:i.parsedType}),g}let n=new E,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?d(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&d(s,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")gn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"email",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")gt||(gt=new RegExp(yn,"u")),gt.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"emoji",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")fn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"uuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")pn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"nanoid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")un.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")ln.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid2",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")dn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ulid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),d(s,{validation:"url",code:u.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"regex",code:u.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?tr(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?En.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Sn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?hn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"duration",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?An(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ip",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Tn(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"jwt",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Rn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cidr",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?kn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?wn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64url",code:u.invalid_string,message:i.message}),n.dirty()):b.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:u.invalid_string,...m.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.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,...m.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,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...m.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...m.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...m.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...m.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...m.errToObj(r)})}nonempty(e){return this.min(1,m.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}};H.create=t=>new H({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,...v(t)});Q=class t extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.number,received:i.parsedType}),g}let n,s=new E;for(let i of this._def.checks)i.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?In(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_finite,message:i.message}),s.dirty()):b.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Q.create=t=>new Q({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,...v(t)});ee=class t extends x{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 i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):b.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:m.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:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:m.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}};ee.create=t=>new ee({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,...v(t)});te=class extends x{_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 A(e.data)}};te.create=t=>new te({typeName:y.ZodBoolean,coerce:t?.coerce||!1,...v(t)});re=class t extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.date,received:i.parsedType}),g}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_date}),g}let n=new E,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):b.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:m.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}};re.create=t=>new re({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,...v(t)});ve=class extends x{_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 A(e.data)}};ve.create=t=>new ve({typeName:y.ZodSymbol,...v(t)});ne=class extends x{_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 A(e.data)}};ne.create=t=>new ne({typeName:y.ZodUndefined,...v(t)});se=class extends x{_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 A(e.data)}};se.create=t=>new se({typeName:y.ZodNull,...v(t)});W=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return A(e.data)}};W.create=t=>new W({typeName:y.ZodAny,...v(t)});V=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return A(e.data)}};V.create=t=>new V({typeName:y.ZodUnknown,...v(t)});P=class extends x{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.never,received:r.parsedType}),g}};P.create=t=>new P({typeName:y.ZodNever,...v(t)});xe=class extends x{_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 A(e.data)}};xe.create=t=>new xe({typeName:y.ZodVoid,...v(t)});U=class t extends x{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==f.array)return d(r,{code:u.invalid_type,expected:f.array,received:r.parsedType}),g;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(a||o)&&(d(r,{code:a?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(d(r,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(d(r,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>s.type._parseAsync(new O(r,a,r.path,o)))).then(a=>E.mergeArray(n,a));let i=[...r.data].map((a,o)=>s.type._parseSync(new O(r,a,r.path,o)));return E.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:m.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:m.toString(r)}})}nonempty(e){return this.min(1,e)}};U.create=(t,e)=>new U({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...v(e)});C=class t extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=b.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return d(l,{code:u.invalid_type,expected:f.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof P&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||o.push(l);let c=[];for(let l of a){let h=i[l],k=s.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new O(s,k,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof P){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 k=s.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new O(s,k,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let h of c){let k=await h.key,T=await h.value;l.push({key:k,value:T,alwaysSet:h.alwaysSet})}return l}).then(l=>E.mergeObjectSync(n,l)):E.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.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:m.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of b.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of b.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return _e(this)}partial(e){let r={};for(let n of b.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of b.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof D;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return rr(b.objectKeys(this.shape))}};C.create=(t,e)=>new C({shape:()=>t,unknownKeys:"strip",catchall:P.create(),typeName:y.ZodObject,...v(e)});C.strictCreate=(t,e)=>new C({shape:()=>t,unknownKeys:"strict",catchall:P.create(),typeName:y.ZodObject,...v(e)});C.lazycreate=(t,e)=>new C({shape:t,unknownKeys:"strip",catchall:P.create(),typeName:y.ZodObject,...v(e)});ie=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(o=>new I(o.ctx.common.issues));return d(r,{code:u.invalid_union,unionErrors:a}),g}if(r.common.async)return Promise.all(n.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},h=c._parseSync({data:r.data,path:r.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(c=>new I(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,...v(e)});B=t=>t instanceof oe?B(t.schema):t instanceof N?B(t.innerType()):t instanceof ce?[t.value]:t instanceof ue?t.options:t instanceof le?b.objectValues(t.enum):t instanceof de?B(t._def.innerType):t instanceof ne?[void 0]:t instanceof se?[null]:t instanceof D?[void 0,...B(t.unwrap())]:t instanceof $?[null,...B(t.unwrap())]:t instanceof Me||t instanceof pe?B(t.unwrap()):t instanceof fe?B(t._def.innerType):[],We=class t extends x{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return d(r,{code:u.invalid_type,expected:f.object,received:r.parsedType}),g;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(d(r,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let a=B(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...v(n)})}};ae=class extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Ke(i)||Ke(a))return g;let o=yt(i.value,a.value);return o.valid?((He(i)||He(a))&&r.dirty(),{status:r.value,value:o.data}):(d(n,{code:u.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ae.create=(t,e,r)=>new ae({left:t,right:e,typeName:y.ZodIntersection,...v(r)});j=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return d(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return d(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new O(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>E.mergeArray(r,a)):E.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};j.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new j({items:t,typeName:y.ZodTuple,rest:null,...v(e)})};qe=class t extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return d(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],i=this._def.keyType,a=this._def.valueType;for(let o in n.data)s.push({key:i._parse(new O(n,o,n.path,o)),value:a._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 x?new t({keyType:e,valueType:r,typeName:y.ZodRecord,...v(n)}):new t({keyType:H.create(),valueType:e,typeName:y.ZodRecord,...v(r)})}},be=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return d(n,{code:u.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new O(n,o,n.path,[l,"key"])),value:i._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 a){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 a){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}}}};be.create=(t,e,r)=>new be({valueType:e,keyType:t,typeName:y.ZodMap,...v(r)});ke=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return d(n,{code:u.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(d(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(d(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function a(c){let l=new Set;for(let 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)=>i._parse(new O(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:m.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};ke.create=(t,e)=>new ke({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,...v(e)});Ge=class t extends x{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 Pe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ge(),F].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(o,c){return Pe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ge(),F].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof q){let o=this;return A(async function(...c){let l=new I([]),h=await o._def.args.parseAsync(c,i).catch(_=>{throw l.addIssue(n(c,_)),l}),k=await Reflect.apply(a,this,h);return await o._def.returns._def.type.parseAsync(k,i).catch(_=>{throw l.addIssue(s(k,_)),l})})}else{let o=this;return A(function(...c){let l=o._def.args.safeParse(c,i);if(!l.success)throw new I([n(c,l.error)]);let h=Reflect.apply(a,this,l.data),k=o._def.returns.safeParse(h,i);if(!k.success)throw new I([s(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:j.create(e).rest(V.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(V.create()),returns:r||V.create(),typeName:y.ZodFunction,...v(n)})}},oe=class extends x{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})}};oe.create=(t,e)=>new oe({getter:t,typeName:y.ZodLazy,...v(e)});ce=class extends x{_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}};ce.create=(t,e)=>new ce({value:t,typeName:y.ZodLiteral,...v(e)});ue=class t extends x{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:b.joinValues(n),received:r.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{received:r.data,code:u.invalid_enum_value,options:n}),g}return A(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})}};ue.create=rr;le=class extends x{_parse(e){let r=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=b.objectValues(r);return d(n,{expected:b.joinValues(s),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=b.objectValues(r);return d(n,{received:n.data,code:u.invalid_enum_value,options:s}),g}return A(e.data)}get enum(){return this._def.values}};le.create=(t,e)=>new le({values:t,typeName:y.ZodNativeEnum,...v(e)});q=class extends x{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 A(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};q.create=(t,e)=>new q({type:t,typeName:y.ZodPromise,...v(e)});N=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{d(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?X(c.value):r.value==="dirty"?X(c.value):c});{if(r.value==="aborted")return g;let o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?X(o.value):r.value==="dirty"?X(o.value):o}}if(s.type==="refinement"){let a=o=>{let c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!K(a))return g;let o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>K(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:r.value,value:o})):g);b.assertNever(s)}};N.create=(t,e,r)=>new N({schema:t,typeName:y.ZodEffects,effect:e,...v(r)});N.createWithPreprocess=(t,e,r)=>new N({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,...v(r)});D=class extends x{_parse(e){return this._getType(e)===f.undefined?A(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};D.create=(t,e)=>new D({innerType:t,typeName:y.ZodOptional,...v(e)});$=class extends x{_parse(e){return this._getType(e)===f.null?A(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:y.ZodNullable,...v(e)});de=class extends x{_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}};de.create=(t,e)=>new de({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});fe=class extends x{_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 ye(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new I(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new I(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};fe.create=(t,e)=>new fe({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});we=class extends x{_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}}};we.create=t=>new we({typeName:y.ZodNaN,...v(t)});Cn=Symbol("zod_brand"),Me=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},je=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?g:i.status==="dirty"?(r.dirty(),X(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:y.ZodPipeline})}},pe=class extends x{_parse(e){let r=this._def.innerType._parse(e),n=s=>(K(s)&&(s.value=Object.freeze(s.value)),s);return ye(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};pe.create=(t,e)=>new pe({innerType:t,typeName:y.ZodReadonly,...v(e)});Dn={object:C.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={}));On=(t,e={message:`Input not instance of ${t.name}`})=>nr(r=>r instanceof t,e),sr=H.create,ir=Q.create,Nn=we.create,Pn=ee.create,ar=te.create,Mn=re.create,jn=ve.create,$n=ne.create,Ln=se.create,Zn=W.create,zn=V.create,Fn=P.create,Bn=xe.create,Vn=U.create,Un=C.create,Kn=C.strictCreate,Hn=ie.create,Wn=We.create,qn=ae.create,Gn=j.create,Yn=qe.create,Jn=be.create,Xn=ke.create,Qn=Ge.create,es=oe.create,ts=ce.create,rs=ue.create,ns=le.create,ss=q.create,is=N.create,as=D.create,os=$.create,cs=N.createWithPreprocess,us=je.create,ls=()=>sr().optional(),ds=()=>ir().optional(),fs=()=>ar().optional(),ps={string:(t=>H.create({...t,coerce:!0})),number:(t=>Q.create({...t,coerce:!0})),boolean:(t=>te.create({...t,coerce:!0})),bigint:(t=>ee.create({...t,coerce:!0})),date:(t=>re.create({...t,coerce:!0}))},ms=g});var p={};Be(p,{BRAND:()=>Cn,DIRTY:()=>X,EMPTY_PATH:()=>cn,INVALID:()=>g,NEVER:()=>ms,OK:()=>A,ParseStatus:()=>E,Schema:()=>x,ZodAny:()=>W,ZodArray:()=>U,ZodBigInt:()=>ee,ZodBoolean:()=>te,ZodBranded:()=>Me,ZodCatch:()=>fe,ZodDate:()=>re,ZodDefault:()=>de,ZodDiscriminatedUnion:()=>We,ZodEffects:()=>N,ZodEnum:()=>ue,ZodError:()=>I,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>Ge,ZodIntersection:()=>ae,ZodIssueCode:()=>u,ZodLazy:()=>oe,ZodLiteral:()=>ce,ZodMap:()=>be,ZodNaN:()=>we,ZodNativeEnum:()=>le,ZodNever:()=>P,ZodNull:()=>se,ZodNullable:()=>$,ZodNumber:()=>Q,ZodObject:()=>C,ZodOptional:()=>D,ZodParsedType:()=>f,ZodPipeline:()=>je,ZodPromise:()=>q,ZodReadonly:()=>pe,ZodRecord:()=>qe,ZodSchema:()=>x,ZodSet:()=>ke,ZodString:()=>H,ZodSymbol:()=>ve,ZodTransformer:()=>N,ZodTuple:()=>j,ZodType:()=>x,ZodUndefined:()=>ne,ZodUnion:()=>ie,ZodUnknown:()=>V,ZodVoid:()=>xe,addIssueToContext:()=>d,any:()=>Zn,array:()=>Vn,bigint:()=>Pn,boolean:()=>ar,coerce:()=>ps,custom:()=>nr,date:()=>Mn,datetimeRegex:()=>tr,defaultErrorMap:()=>F,discriminatedUnion:()=>Wn,effect:()=>is,enum:()=>rs,function:()=>Qn,getErrorMap:()=>ge,getParsedType:()=>M,instanceof:()=>On,intersection:()=>qn,isAborted:()=>Ke,isAsync:()=>ye,isDirty:()=>He,isValid:()=>K,late:()=>Dn,lazy:()=>es,literal:()=>ts,makeIssue:()=>Pe,map:()=>Jn,nan:()=>Nn,nativeEnum:()=>ns,never:()=>Fn,null:()=>Ln,nullable:()=>os,number:()=>ir,object:()=>Un,objectUtil:()=>pt,oboolean:()=>fs,onumber:()=>ds,optional:()=>as,ostring:()=>ls,pipeline:()=>us,preprocess:()=>cs,promise:()=>ss,quotelessJson:()=>sn,record:()=>Yn,set:()=>Xn,setErrorMap:()=>on,strictObject:()=>Kn,string:()=>sr,symbol:()=>jn,transformer:()=>is,tuple:()=>Gn,undefined:()=>$n,union:()=>Hn,unknown:()=>zn,util:()=>b,void:()=>Bn});var _t=w(()=>{Ue();ht();Gt();Ne();or();Ve()});var $e=w(()=>{_t();_t()});var Ye,vt=w(()=>{"use strict";$e();Ye=p.object({slug:p.string().min(1).max(64),description:p.string().max(255).optional(),match_command:p.string().min(1),priority:p.number().int().default(50),strip_ansi:p.boolean().default(!1),strip_lines_matching:p.array(p.string()).default([]),truncate_lines_at:p.number().int().positive().max(1e4).optional(),max_lines:p.number().int().positive().max(1e5).optional(),transform:p.string().max(64).optional(),on_empty:p.string().max(255).optional()})});function Se(t){return JSON.stringify(t)+Ee}function*Je(t){let e=0;for(;;){let r=t.indexOf(Ee,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function Xe(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var hs,gs,ys,_s,cr,Pa,Ma,ur,Ee,lr,xt=w(()=>{"use strict";$e();vt();hs=p.object({id:p.string().min(1).max(64),op:p.literal("filter"),cmd:p.string().min(1).max(2048),plan:p.enum(["trial","smart","pro"]),installId:p.string().min(1).max(64).optional()}),gs=p.object({id:p.string().min(1).max(64),op:p.literal("ping")}),ys=p.object({id:p.string().min(1).max(64),op:p.literal("shutdown"),installId:p.string().min(1).max(64)}),_s=p.object({id:p.string().min(1).max(64),op:p.literal("reload"),installId:p.string().min(1).max(64).optional()}),cr=p.discriminatedUnion("op",[hs,gs,ys,_s]),Pa=p.object({id:p.string(),ok:p.literal(!0),data:p.unknown()}),Ma=p.object({id:p.string(),ok:p.literal(!1),err:p.string(),retryAfterMs:p.number().int().nonnegative().optional()}),ur=p.object({filter:Ye.nullable(),cacheHit:p.boolean().optional()}),Ee=`
|
|
4
|
-
`,
|
|
3
|
+
var an=Object.defineProperty;var w=(t,e)=>()=>(t&&(e=t(t=0)),e);var Be=(t,e)=>{for(var r in e)an(t,r,{get:e[r],enumerable:!0})};var b,pt,f,j,Ne=w(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let i={};for(let a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(let o of i)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(b||(b={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(pt||(pt={}));f=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),j=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,on,I,Ve=w(()=>{Ne();u=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),on=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),I=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};I.create=t=>new I(t)});var cn,F,mt=w(()=>{Ve();Ne();cn=(t,e)=>{let r;switch(t.code){case u.invalid_type:t.received===f.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:r="Invalid function arguments";break;case u.invalid_return_type:r="Invalid function return type";break;case u.invalid_date:r="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case u.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case u.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case u.custom:r="Invalid input";break;case u.invalid_intersection_types:r="Intersection results could not be merged";break;case u.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:r="Number must be finite";break;default:r=e.defaultError,b.assertNever(t)}return{message:r}},F=cn});function un(t){Gt=t}function ye(){return Gt}var Gt,Ue=w(()=>{mt();Gt=F});function d(t,e){let r=ye(),n=Pe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===F?void 0:F].filter(s=>!!s)});t.common.issues.push(n)}var Pe,ln,E,g,X,A,Ke,He,K,_e,ht=w(()=>{Ue();mt();Pe=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},ln=[];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 i=await s.key,a=await s.value;n.push({key:i,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return g;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),X=t=>({status:"dirty",value:t}),A=t=>({status:"valid",value:t}),Ke=t=>t.status==="aborted",He=t=>t.status==="dirty",K=t=>t.status==="valid",_e=t=>typeof Promise<"u"&&t instanceof Promise});var Yt=w(()=>{});var m,Jt=w(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}))});function v(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}function tr(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 Tn(t){return new RegExp(`^${tr(t)}$`)}function rr(t){let e=`${er}T${tr(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 Rn(t,e){return!!((e==="v4"||!e)&&xn.test(t)||(e==="v6"||!e)&&kn.test(t))}function In(t,e){if(!gn.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 Cn(t,e){return!!((e==="v4"||!e)&&bn.test(t)||(e==="v6"||!e)&&wn.test(t))}function Dn(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}function ve(t){if(t instanceof C){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=D.create(ve(n))}return new C({...t._def,shape:()=>e})}else return t instanceof U?new U({...t._def,type:ve(t.element)}):t instanceof D?D.create(ve(t.unwrap())):t instanceof L?L.create(ve(t.unwrap())):t instanceof $?$.create(t.items.map(e=>ve(e))):t}function yt(t,e){let r=j(t),n=j(e);if(t===e)return{valid:!0,data:t};if(r===f.object&&n===f.object){let s=b.objectKeys(e),i=b.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(let o of i){let c=yt(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(r===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],o=e[i],c=yt(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function nr(t,e){return new ue({values:t,typeName:y.ZodEnum,...v(e)})}function Qt(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function sr(t,e={},r){return t?W.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(a=>{if(!a){let o=Qt(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!i){let a=Qt(e,n),o=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:o})}}):W.create()}var O,Xt,x,dn,fn,pn,mn,hn,gn,yn,_n,vn,gt,xn,bn,kn,wn,En,Sn,er,An,H,Q,ee,te,re,xe,ne,se,W,V,M,be,U,C,ie,B,We,ae,$,qe,ke,we,Ge,oe,ce,ue,le,q,N,D,L,de,fe,Ee,On,Me,je,pe,Nn,y,Pn,ir,ar,Mn,jn,or,$n,Ln,Zn,zn,Fn,Bn,Vn,Un,Kn,Hn,Wn,qn,Gn,Yn,Jn,Xn,Qn,es,ts,rs,ns,ss,is,as,os,cs,us,ls,ds,fs,ps,ms,hs,gs,cr=w(()=>{Ve();Ue();Jt();ht();Ne();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}},Xt=(t,e)=>{if(K(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new I(t.common.issues);return this._error=r,this._error}}};x=class{get description(){return this._def.description}_getType(e){return j(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:j(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:j(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:j(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Xt(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:j(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return K(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=>K(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:j(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(_e(s)?s:Promise.resolve(s));return Xt(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let a=e(s),o=()=>i.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new N({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 D.create(this,this._def)}nullable(){return L.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return U.create(this)}promise(){return q.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return ae.create(this,e,this._def)}transform(e){return new N({...v(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new de({...v(this._def),innerType:this,defaultValue:r,typeName:y.ZodDefault})}brand(){return new Me({typeName:y.ZodBranded,type:this,...v(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new fe({...v(this._def),innerType:this,catchValue:r,typeName:y.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return je.create(this,e)}readonly(){return pe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},dn=/^c[^\s-]{8,}$/i,fn=/^[0-9a-z]+$/,pn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,mn=/^[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,hn=/^[a-z0-9_-]{21}$/i,gn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,yn=/^[-+]?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)?)??$/,_n=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,vn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",xn=/^(?:(?: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])$/,bn=/^(?:(?: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])$/,kn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,wn=/^(([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])$/,En=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Sn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,er="((\\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])))",An=new RegExp(`^${er}$`);H=class t extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.string,received:i.parsedType}),g}let n=new E,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?d(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&d(s,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")_n.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"email",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")gt||(gt=new RegExp(vn,"u")),gt.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"emoji",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")mn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"uuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")hn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"nanoid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")dn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")fn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid2",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")pn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ulid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),d(s,{validation:"url",code:u.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"regex",code:u.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?rr(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?An.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Tn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?yn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"duration",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Rn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ip",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?In(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"jwt",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Cn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cidr",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?En.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Sn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64url",code:u.invalid_string,message:i.message}),n.dirty()):b.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:u.invalid_string,...m.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.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,...m.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,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...m.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...m.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...m.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...m.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...m.errToObj(r)})}nonempty(e){return this.min(1,m.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}};H.create=t=>new H({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,...v(t)});Q=class t extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.number,received:i.parsedType}),g}let n,s=new E;for(let i of this._def.checks)i.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Dn(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_finite,message:i.message}),s.dirty()):b.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Q.create=t=>new Q({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,...v(t)});ee=class t extends x{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 i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):b.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:m.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:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:m.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}};ee.create=t=>new ee({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,...v(t)});te=class extends x{_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 A(e.data)}};te.create=t=>new te({typeName:y.ZodBoolean,coerce:t?.coerce||!1,...v(t)});re=class t extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.date,received:i.parsedType}),g}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_date}),g}let n=new E,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):b.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:m.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}};re.create=t=>new re({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,...v(t)});xe=class extends x{_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 A(e.data)}};xe.create=t=>new xe({typeName:y.ZodSymbol,...v(t)});ne=class extends x{_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 A(e.data)}};ne.create=t=>new ne({typeName:y.ZodUndefined,...v(t)});se=class extends x{_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 A(e.data)}};se.create=t=>new se({typeName:y.ZodNull,...v(t)});W=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return A(e.data)}};W.create=t=>new W({typeName:y.ZodAny,...v(t)});V=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return A(e.data)}};V.create=t=>new V({typeName:y.ZodUnknown,...v(t)});M=class extends x{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.never,received:r.parsedType}),g}};M.create=t=>new M({typeName:y.ZodNever,...v(t)});be=class extends x{_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 A(e.data)}};be.create=t=>new be({typeName:y.ZodVoid,...v(t)});U=class t extends x{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==f.array)return d(r,{code:u.invalid_type,expected:f.array,received:r.parsedType}),g;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(a||o)&&(d(r,{code:a?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(d(r,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(d(r,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>s.type._parseAsync(new O(r,a,r.path,o)))).then(a=>E.mergeArray(n,a));let i=[...r.data].map((a,o)=>s.type._parseSync(new O(r,a,r.path,o)));return E.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:m.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:m.toString(r)}})}nonempty(e){return this.min(1,e)}};U.create=(t,e)=>new U({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...v(e)});C=class t extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=b.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return d(l,{code:u.invalid_type,expected:f.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||o.push(l);let c=[];for(let l of a){let h=i[l],k=s.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new O(s,k,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof M){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 k=s.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new O(s,k,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let h of c){let k=await h.key,T=await h.value;l.push({key:k,value:T,alwaysSet:h.alwaysSet})}return l}).then(l=>E.mergeObjectSync(n,l)):E.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.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:m.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of b.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of b.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return ve(this)}partial(e){let r={};for(let n of b.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of b.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof D;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return nr(b.objectKeys(this.shape))}};C.create=(t,e)=>new C({shape:()=>t,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...v(e)});C.strictCreate=(t,e)=>new C({shape:()=>t,unknownKeys:"strict",catchall:M.create(),typeName:y.ZodObject,...v(e)});C.lazycreate=(t,e)=>new C({shape:t,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...v(e)});ie=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(o=>new I(o.ctx.common.issues));return d(r,{code:u.invalid_union,unionErrors:a}),g}if(r.common.async)return Promise.all(n.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},h=c._parseSync({data:r.data,path:r.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(c=>new I(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,...v(e)});B=t=>t instanceof oe?B(t.schema):t instanceof N?B(t.innerType()):t instanceof ce?[t.value]:t instanceof ue?t.options:t instanceof le?b.objectValues(t.enum):t instanceof de?B(t._def.innerType):t instanceof ne?[void 0]:t instanceof se?[null]:t instanceof D?[void 0,...B(t.unwrap())]:t instanceof L?[null,...B(t.unwrap())]:t instanceof Me||t instanceof pe?B(t.unwrap()):t instanceof fe?B(t._def.innerType):[],We=class t extends x{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return d(r,{code:u.invalid_type,expected:f.object,received:r.parsedType}),g;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(d(r,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let a=B(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...v(n)})}};ae=class extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Ke(i)||Ke(a))return g;let o=yt(i.value,a.value);return o.valid?((He(i)||He(a))&&r.dirty(),{status:r.value,value:o.data}):(d(n,{code:u.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ae.create=(t,e,r)=>new ae({left:t,right:e,typeName:y.ZodIntersection,...v(r)});$=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return d(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return d(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new O(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>E.mergeArray(r,a)):E.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};$.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $({items:t,typeName:y.ZodTuple,rest:null,...v(e)})};qe=class t extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return d(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],i=this._def.keyType,a=this._def.valueType;for(let o in n.data)s.push({key:i._parse(new O(n,o,n.path,o)),value:a._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 x?new t({keyType:e,valueType:r,typeName:y.ZodRecord,...v(n)}):new t({keyType:H.create(),valueType:e,typeName:y.ZodRecord,...v(r)})}},ke=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return d(n,{code:u.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new O(n,o,n.path,[l,"key"])),value:i._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 a){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 a){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,...v(r)});we=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return d(n,{code:u.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(d(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(d(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function a(c){let l=new Set;for(let 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)=>i._parse(new O(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:m.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,...v(e)});Ge=class t extends x{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 Pe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ye(),F].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(o,c){return Pe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ye(),F].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof q){let o=this;return A(async function(...c){let l=new I([]),h=await o._def.args.parseAsync(c,i).catch(_=>{throw l.addIssue(n(c,_)),l}),k=await Reflect.apply(a,this,h);return await o._def.returns._def.type.parseAsync(k,i).catch(_=>{throw l.addIssue(s(k,_)),l})})}else{let o=this;return A(function(...c){let l=o._def.args.safeParse(c,i);if(!l.success)throw new I([n(c,l.error)]);let h=Reflect.apply(a,this,l.data),k=o._def.returns.safeParse(h,i);if(!k.success)throw new I([s(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:$.create(e).rest(V.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||$.create([]).rest(V.create()),returns:r||V.create(),typeName:y.ZodFunction,...v(n)})}},oe=class extends x{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})}};oe.create=(t,e)=>new oe({getter:t,typeName:y.ZodLazy,...v(e)});ce=class extends x{_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}};ce.create=(t,e)=>new ce({value:t,typeName:y.ZodLiteral,...v(e)});ue=class t extends x{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:b.joinValues(n),received:r.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{received:r.data,code:u.invalid_enum_value,options:n}),g}return A(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})}};ue.create=nr;le=class extends x{_parse(e){let r=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=b.objectValues(r);return d(n,{expected:b.joinValues(s),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=b.objectValues(r);return d(n,{received:n.data,code:u.invalid_enum_value,options:s}),g}return A(e.data)}get enum(){return this._def.values}};le.create=(t,e)=>new le({values:t,typeName:y.ZodNativeEnum,...v(e)});q=class extends x{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 A(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};q.create=(t,e)=>new q({type:t,typeName:y.ZodPromise,...v(e)});N=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{d(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?X(c.value):r.value==="dirty"?X(c.value):c});{if(r.value==="aborted")return g;let o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?X(o.value):r.value==="dirty"?X(o.value):o}}if(s.type==="refinement"){let a=o=>{let c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!K(a))return g;let o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>K(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:r.value,value:o})):g);b.assertNever(s)}};N.create=(t,e,r)=>new N({schema:t,typeName:y.ZodEffects,effect:e,...v(r)});N.createWithPreprocess=(t,e,r)=>new N({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,...v(r)});D=class extends x{_parse(e){return this._getType(e)===f.undefined?A(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};D.create=(t,e)=>new D({innerType:t,typeName:y.ZodOptional,...v(e)});L=class extends x{_parse(e){return this._getType(e)===f.null?A(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};L.create=(t,e)=>new L({innerType:t,typeName:y.ZodNullable,...v(e)});de=class extends x{_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}};de.create=(t,e)=>new de({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});fe=class extends x{_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(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new I(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new I(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};fe.create=(t,e)=>new fe({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});Ee=class extends x{_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,...v(t)});On=Symbol("zod_brand"),Me=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},je=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?g:i.status==="dirty"?(r.dirty(),X(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:y.ZodPipeline})}},pe=class extends x{_parse(e){let r=this._def.innerType._parse(e),n=s=>(K(s)&&(s.value=Object.freeze(s.value)),s);return _e(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};pe.create=(t,e)=>new pe({innerType:t,typeName:y.ZodReadonly,...v(e)});Nn={object:C.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={}));Pn=(t,e={message:`Input not instance of ${t.name}`})=>sr(r=>r instanceof t,e),ir=H.create,ar=Q.create,Mn=Ee.create,jn=ee.create,or=te.create,$n=re.create,Ln=xe.create,Zn=ne.create,zn=se.create,Fn=W.create,Bn=V.create,Vn=M.create,Un=be.create,Kn=U.create,Hn=C.create,Wn=C.strictCreate,qn=ie.create,Gn=We.create,Yn=ae.create,Jn=$.create,Xn=qe.create,Qn=ke.create,es=we.create,ts=Ge.create,rs=oe.create,ns=ce.create,ss=ue.create,is=le.create,as=q.create,os=N.create,cs=D.create,us=L.create,ls=N.createWithPreprocess,ds=je.create,fs=()=>ir().optional(),ps=()=>ar().optional(),ms=()=>or().optional(),hs={string:(t=>H.create({...t,coerce:!0})),number:(t=>Q.create({...t,coerce:!0})),boolean:(t=>te.create({...t,coerce:!0})),bigint:(t=>ee.create({...t,coerce:!0})),date:(t=>re.create({...t,coerce:!0}))},gs=g});var p={};Be(p,{BRAND:()=>On,DIRTY:()=>X,EMPTY_PATH:()=>ln,INVALID:()=>g,NEVER:()=>gs,OK:()=>A,ParseStatus:()=>E,Schema:()=>x,ZodAny:()=>W,ZodArray:()=>U,ZodBigInt:()=>ee,ZodBoolean:()=>te,ZodBranded:()=>Me,ZodCatch:()=>fe,ZodDate:()=>re,ZodDefault:()=>de,ZodDiscriminatedUnion:()=>We,ZodEffects:()=>N,ZodEnum:()=>ue,ZodError:()=>I,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>Ge,ZodIntersection:()=>ae,ZodIssueCode:()=>u,ZodLazy:()=>oe,ZodLiteral:()=>ce,ZodMap:()=>ke,ZodNaN:()=>Ee,ZodNativeEnum:()=>le,ZodNever:()=>M,ZodNull:()=>se,ZodNullable:()=>L,ZodNumber:()=>Q,ZodObject:()=>C,ZodOptional:()=>D,ZodParsedType:()=>f,ZodPipeline:()=>je,ZodPromise:()=>q,ZodReadonly:()=>pe,ZodRecord:()=>qe,ZodSchema:()=>x,ZodSet:()=>we,ZodString:()=>H,ZodSymbol:()=>xe,ZodTransformer:()=>N,ZodTuple:()=>$,ZodType:()=>x,ZodUndefined:()=>ne,ZodUnion:()=>ie,ZodUnknown:()=>V,ZodVoid:()=>be,addIssueToContext:()=>d,any:()=>Fn,array:()=>Kn,bigint:()=>jn,boolean:()=>or,coerce:()=>hs,custom:()=>sr,date:()=>$n,datetimeRegex:()=>rr,defaultErrorMap:()=>F,discriminatedUnion:()=>Gn,effect:()=>os,enum:()=>ss,function:()=>ts,getErrorMap:()=>ye,getParsedType:()=>j,instanceof:()=>Pn,intersection:()=>Yn,isAborted:()=>Ke,isAsync:()=>_e,isDirty:()=>He,isValid:()=>K,late:()=>Nn,lazy:()=>rs,literal:()=>ns,makeIssue:()=>Pe,map:()=>Qn,nan:()=>Mn,nativeEnum:()=>is,never:()=>Vn,null:()=>zn,nullable:()=>us,number:()=>ar,object:()=>Hn,objectUtil:()=>pt,oboolean:()=>ms,onumber:()=>ps,optional:()=>cs,ostring:()=>fs,pipeline:()=>ds,preprocess:()=>ls,promise:()=>as,quotelessJson:()=>on,record:()=>Xn,set:()=>es,setErrorMap:()=>un,strictObject:()=>Wn,string:()=>ir,symbol:()=>Ln,transformer:()=>os,tuple:()=>Jn,undefined:()=>Zn,union:()=>qn,unknown:()=>Bn,util:()=>b,void:()=>Un});var _t=w(()=>{Ue();ht();Yt();Ne();cr();Ve()});var $e=w(()=>{_t();_t()});var Ye,vt=w(()=>{"use strict";$e();Ye=p.object({slug:p.string().min(1).max(64),description:p.string().max(255).optional(),match_command:p.string().min(1),priority:p.number().int().default(50),strip_ansi:p.boolean().default(!1),strip_lines_matching:p.array(p.string()).default([]),truncate_lines_at:p.number().int().positive().max(1e4).optional(),max_lines:p.number().int().positive().max(1e5).optional(),transform:p.string().max(64).optional(),on_empty:p.string().max(255).optional()})});function Ae(t){return JSON.stringify(t)+Se}function*Je(t){let e=0;for(;;){let r=t.indexOf(Se,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function Xe(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var ys,_s,vs,xs,ur,La,Za,lr,Se,dr,xt=w(()=>{"use strict";$e();vt();ys=p.object({id:p.string().min(1).max(64),op:p.literal("filter"),cmd:p.string().min(1).max(2048),plan:p.enum(["trial","smart","pro"]),installId:p.string().min(1).max(64).optional()}),_s=p.object({id:p.string().min(1).max(64),op:p.literal("ping")}),vs=p.object({id:p.string().min(1).max(64),op:p.literal("shutdown"),installId:p.string().min(1).max(64)}),xs=p.object({id:p.string().min(1).max(64),op:p.literal("reload"),installId:p.string().min(1).max(64).optional()}),ur=p.discriminatedUnion("op",[ys,_s,vs,xs]),La=p.object({id:p.string(),ok:p.literal(!0),data:p.unknown()}),Za=p.object({id:p.string(),ok:p.literal(!1),err:p.string(),retryAfterMs:p.number().int().nonnegative().optional()}),lr=p.object({filter:Ye.nullable(),cacheHit:p.boolean().optional()}),Se=`
|
|
4
|
+
`,dr=64*1024});import fr from"node:os";import{join as me}from"node:path";function S(){return process.env.TOKMIZER_HOME||me(fr.homedir(),".tokmizer")}function bt(){return me(S(),"install-id")}function pr(){return me(S(),"bundle-refresh.json")}function Qe(){return me(S(),"skills")}function et(t){return me(Qe(),`${t}.md`)}function tt(){return process.env.TOKMIZER_CLAUDE_COMMANDS_DIR||me(fr.homedir(),".claude","commands")}function rt(t){return me(tt(),`${t}.md`)}var G=w(()=>{"use strict"});import{join as kt}from"node:path";import{existsSync as mr,statSync as bs,unlinkSync as ks,mkdirSync as ws,chmodSync as Es}from"node:fs";function Te(){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&&mr(e))return{path:kt(e,`tokmizer-${t}.sock`),isPipe:!1};let r=kt(S(),"run");try{ws(r,{recursive:!0,mode:448}),Es(r,448)}catch{}return{path:kt(r,"daemon.sock"),isPipe:!1}}async function nt(){let{path:t,isPipe:e}=Te();if(e||!mr(t))return;try{if(!bs(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let i=r.createConnection(t),a=o=>{i.removeAllListeners();try{i.destroy()}catch{}s(o)};i.once("connect",()=>a(!0)),i.once("error",o=>{let c=o.code;a(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>a(!0),250)}))try{ks(t)}catch{}}function yr(){let t=process.ppid;if(!t||t===1)return!1;try{return process.kill(t,0),!0}catch{return!1}}var hr,gr,wt=w(()=>{"use strict";G();hr=3e4,gr=5*6e4});import{join as Et}from"node:path";import{mkdir as Ts,readFile as Rs,writeFile as Is,unlink as Cs,rename as Ds}from"node:fs/promises";function st(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function At(t){return t?.dir??S()}async function P(t){let e=At(t);try{let r=await Rs(Et(e,St),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??st(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}async function br(t,e){let r=At(e);await Ts(r,{recursive:!0});let n=Et(r,St),s=`${n}.tmp`;await Is(s,JSON.stringify(t,null,2),{mode:384}),await Ds(s,n)}async function kr(t){let e=At(t);try{await Cs(Et(e,St))}catch{return}}var St,Xa,he=w(()=>{"use strict";G();St="state.json",Xa={lastSettingsRevision:0,timeZone:st(),bonusActive:!1}});import{createRequire as Os}from"node:module";function Ps(){for(let t of["../package.json","../../package.json"])try{let e=Ns(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Ns,Tt,Rt=w(()=>{"use strict";Ns=Os(import.meta.url);Tt=Ps()});var wr,Er=w(()=>{"use strict";wr=`-----BEGIN PUBLIC KEY-----
|
|
5
5
|
MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
|
|
6
6
|
-----END PUBLIC KEY-----
|
|
7
|
-
`});import{createHmac as
|
|
8
|
-
`)}function
|
|
9
|
-
`,{mode:384})}catch{return}}function
|
|
10
|
-
`))if(i.trim())try{s.push(JSON.parse(i))}catch{continue}return s.length===0?(it(e),[]):s}catch{return[]}}function
|
|
7
|
+
`});import{createHmac as Ms,createPublicKey as js,verify as $s}from"node:crypto";function Le(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??wr).replace(/\\n/g,`
|
|
8
|
+
`)}function Zs(t,e,r,n){try{let s=js({key:n,format:"pem"});return $s(null,Buffer.from(`${e}.${t}`,"utf8"),s,Buffer.from(r,"base64url"))}catch{return!1}}async function Ie(t){let e=await t.text(),r=Le(),n=t.headers?.get?.("x-tokmizer-resp-ts")??null;if(n!==null){let a=Number(n);if(!Number.isFinite(a)||Date.now()-a>Ls)throw new Y("http","stale server response (resp-ts outside freshness window)")}if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new Y("http","no signing public key configured; refusing to trust server response");let s=t.headers?.get?.("x-tokmizer-resp-sig")??null,i=Number(n);if(!s||n===null||!Number.isFinite(i))throw new Y("http","missing server response signature");if(!Zs(e,i,s,r))throw new Y("http","invalid server response signature");return JSON.parse(e)}function zs(t,e,r){return Ms("sha256",r).update(`${e}.${t}`).digest("hex")}async function Z(t,e,r,n){let s=Date.now(),i=r===void 0?"":JSON.stringify(r),a=n.signingSecret?zs(i,s,n.signingSecret):"0".repeat(64),o={"content-type":"application/json","x-tokmizer-fingerprint":n.fingerprint,"x-tokmizer-install-id":n.installId,"x-tokmizer-sig":a,"x-tokmizer-ts":String(s),"x-tokmizer-plugin-version":Tt};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=i);try{return await fetch(`${n.baseUrl}${e}`,h)}catch(k){let T=k.name;throw T==="TimeoutError"||T==="AbortError"?new Y("timeout",`${t} ${e} timed out after ${c}ms`):new Y("network",`${t} ${e} failed: ${k.message}`)}}var Ls,Y,Ce=w(()=>{"use strict";Rt();Er();Ls=300*1e3;Y=class extends Error{constructor(r,n,s){super(n);this.kind=r;this.status=s;this.name="TransportError"}kind;status}});import De from"node:os";import{createHash as ti,randomUUID as ri}from"node:crypto";import{readFile as ni,writeFile as si,mkdir as ii}from"node:fs/promises";async function Ct(){try{let r=(await ni(bt(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await ii(S(),{recursive:!0});let t=ri();return await si(bt(),t,{mode:384}),t}function It(t){return ti("sha256").update(t).digest("hex")}function ai(){let t=De.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 J(){let t=await Ct(),e=De.hostname(),r=De.platform(),n=De.release(),s=De.cpus(),i=s[0]?.model??"unknown",a=s.length,o=It(ai()),c=It(De.userInfo().username),l=[e,r,n,i,String(a),o,c,t].join("|");return{fingerprint:It(l),installId:t,hostname:e,os:r,osVersion:n,cpuModel:i,cpuCores:a,macHash:o,usernameHash:c}}var Oe=w(()=>{"use strict";G()});var Hr={};Be(Hr,{connectDaemon:()=>ji});import{createConnection as Si}from"node:net";import{spawn as Ai}from"node:child_process";import{existsSync as Kr,openSync as zr,closeSync as Ti,unlinkSync as Fr,writeFileSync as Br}from"node:fs";import{dirname as Ri,join as Ii}from"node:path";import{fileURLToPath as Ci}from"node:url";async function Ni(t,e){return new Promise((r,n)=>{let s=Si(t),i=o=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(a),o){try{s.destroy()}catch{}n(o)}else r(s)},a=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",o=>i(o))})}function Pi(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Ci(new URL("../bin/tkr-daemon.js",import.meta.url))}async function Ur(t,e=3e3){let r=Math.ceil(e/75);for(let n=0;n<r;n++){if(Kr(t))return!0;await new Promise(s=>setTimeout(s,75))}return!1}async function Mi(t){let e=Pi();if(!Kr(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=Te(),n=Ii(Ri(r),"daemon.spawn.lock"),s=null;try{s=zr(n,"wx"),Br(s,String(process.pid))}catch(i){if(i.code==="EEXIST"){if(await Ur(r,5e3))return;try{Fr(n)}catch{}s=zr(n,"wx"),Br(s,String(process.pid))}else throw i}try{if(Ai(process.execPath,[e],{detached:!0,stdio:["ignore","ignore","ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),!await Ur(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(s!==null){try{Ti(s)}catch{}try{Fr(n)}catch{}}}}async function ji(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Te(),r=await Ct(),n=null,s=0;for(;s<=Vr;)try{n=await Ni(e,Di);break}catch{if(s+=1,s>Vr)throw new Error(`tkr-daemon unreachable at ${e}`);await nt(),await Mi(r)}if(!n)throw new Error("tkr-daemon: socket setup failed");let i=new Map,a="";n.setEncoding("utf8"),n.on("data",c=>{a+=c;let l=-1;for(let k=0;k<a.length;k++)a[k]===Se&&(l=k);if(l<0)return;let h=[];for(let k of Je(a.slice(0,l+1)))h.push(k);a=a.slice(l+1);for(let k of h)if(k)try{let T=JSON.parse(k),_=i.get(T.id);if(!_)continue;clearTimeout(_.timer),i.delete(T.id),_.resolve(T)}catch{}}),n.on("close",()=>{for(let c of i.values())clearTimeout(c.timer),c.reject(new Error("daemon socket closed"));i.clear()}),n.on("error",()=>{});function o(c){return new Promise((l,h)=>{let k=setTimeout(()=>{i.delete(c.id),h(new Error(`daemon request timeout (${c.op})`))},Oi);i.set(c.id,{resolve:l,reject:h,timer:k}),n.write(Ae(c))})}return{filter:async(c,l)=>{let h=await o({id:Xe(),op:"filter",cmd:c.slice(0,2048),plan:l,installId:r});if(!h.ok)return null;let k=lr.safeParse(h.data);return k.success?k.data.filter:null},ping:async()=>{let c=await o({id:Xe(),op:"ping"});if(!c.ok)throw new Error(c.err);return c.data},reload:async()=>{let c=await o({id:Xe(),op:"reload",installId:r});if(!c.ok)throw new Error(c.err);return c.data},close:()=>{try{n.end()}catch{}}}}var Di,Oi,Vr,Wr=w(()=>{"use strict";xt();wt();Oe();Di=500,Oi=3e3,Vr=1});function Ze(t){let e=t;for(let[r,n]of $i)e=e.replace(r,n);return e}var $i,Mt=w(()=>{"use strict";$i=[[/(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 Zt}from"node:path";import{appendFileSync as Lt,existsSync as ze,mkdirSync as Li,readFileSync as jt,renameSync as qr,statSync as Zi,unlinkSync as it}from"node:fs";function zt(){return Zt(S(),"spool")}function Jr(t){return Zt(zt(),`${t}.jsonl`)}function Xr(t){return Zt(zt(),`${t}.pending.jsonl`)}function at(t,e){try{Li(zt(),{recursive:!0,mode:448});let r=Jr(t);if(ze(r)&&Zi(r).size>=zi)return;Lt(r,JSON.stringify(e)+`
|
|
9
|
+
`,{mode:384})}catch{return}}function Fi(t){try{let e=Xr(t),r=Jr(t),n=`${r}.merging`;if(ze(n)&&(Lt(e,jt(n,"utf8"),{mode:384}),it(n)),ze(e))ze(r)&&(qr(r,n),Lt(e,jt(n,"utf8"),{mode:384}),it(n));else{if(!ze(r))return[];qr(r,e)}let s=[];for(let i of jt(e,"utf8").split(`
|
|
10
|
+
`))if(i.trim())try{s.push(JSON.parse(i))}catch{continue}return s.length===0?(it(e),[]):s}catch{return[]}}function Yr(t){try{it(Xr(t))}catch{return}}async function ot(t,e,r={}){if($t.has(t))return"fail";$t.add(t);try{let n=Fi(t);if(n.length===0)return"empty";let s=await P();if(!s)return"fail";if(r.requirePro&&s.plan!=="pro")return Yr(t),"ok";let i=r.baseUrl??process.env.TOKMIZER_BASE_URL??"https://tokmizer.com",a=await J();for(let o=0;o<n.length;o+=Gr){let c=await Z("POST",e,{events:n.slice(o,o+Gr)},{baseUrl:i,bearer:s.jwt,signingSecret:s.signingSecret,fingerprint:a.fingerprint,installId:a.installId});if(!c.ok)return c.status===401||c.status===403?"auth":"fail"}return Yr(t),"ok"}catch{return"fail"}finally{$t.delete(t)}}var zi,Gr,$t,Ft=w(()=>{"use strict";G();he();Oe();Ce();zi=512*1024,Gr=500,$t=new Set});var en={};Be(en,{commandName:()=>ct,flushTelemetry:()=>Bt,recordTelemetry:()=>Gi});function Qr(t){let e=t.toLowerCase();return e.startsWith("git")||Ki.has(e)}function ct(t){let e=t.trim().split(/\s+/).filter(o=>o.length>0),r=0;for(;r<e.length&&Ui.test(e[r]??"");)r+=1;let n=e[r];if(!n||!Bi.test(n)||n.length>Wi||Qr(n)||Hi.test(n)||Ze(n)!==n)return"";let s=e[r+1];return s&&Qr(s)?"":(s&&qi.has(n.toLowerCase())&&Vi.test(s)?`${n} ${s}`:n).slice(0,64)}async function Gi(t){if(!t.telemetryOptIn)return;let e=ct(t.cmd),r=e&&Ze(e)===e?e:"other";at("telemetry",{cmd:r,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),optimized:t.optimized})}async function Bt(t){return ot("telemetry","/api/v1/telemetry",{baseUrl:t})}var Bi,Vi,Ui,Ki,Hi,Wi,qi,ut=w(()=>{"use strict";Mt();Ft();Bi=/^[a-z0-9][a-z0-9._-]*$/i,Vi=/^[a-z][a-z-]+$/,Ui=/^[A-Za-z_][A-Za-z0-9_]*=/,Ki=new Set(["gh","glab","gup","hub","gist"]),Hi=/^(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,Wi=24,qi=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 tn={};Be(tn,{flush:()=>Vt,recordEvent:()=>Yi});async function Yi(t){if(t.plan!=="pro")return;let e=ct(t.cmd);!e||Ze(e)!==e||at("learn",{cmd:e,filterId:t.filterId,rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}async function Vt(t){return ot("learn","/api/v1/learn",{baseUrl:t,requirePro:!0})}var Ut=w(()=>{"use strict";ut();Mt();Ft()});xt();wt();import{createServer as Qs}from"node:net";import{chmodSync as ei}from"node:fs";$e();vt();import{createPublicKey as Hs,verify as Ws}from"node:crypto";var Re=new Map,Ss=256,_r=new WeakMap;function As(t){if(!t)return"*";let e=_r.get(t);return e===void 0&&(e=[...t].join(","),_r.set(t,e)),e}function vr(t,e,r){let n=`${t}::${As(r)}`,s=Re.get(n);if(s!==void 0)return s;let i=null;for(let a of e)r&&!r.has(a.slug)||a.matchRegex.test(t)&&(!i||a.priority>i.priority)&&(i=a);if(Re.size>=Ss){let a=Re.keys().next().value;a&&Re.delete(a)}return Re.set(n,i),i}function xr(){Re.clear()}he();Ce();import{createCipheriv as co,createDecipheriv as Fs,hkdfSync as Bs,randomBytes as uo}from"node:crypto";var Vs=Buffer.from("tokmizer-bundle-enc-v1"),Us=Buffer.from("rules-bundle");function Ks(t){return Buffer.from(Bs("sha256",Buffer.from(t,"utf8"),Vs,Us,32))}function Sr(t,e){let r=Ks(e),n=Buffer.from(t,"base64url"),s=n.subarray(0,12),i=n.subarray(12,28),a=n.subarray(28),o=Fs("aes-256-gcm",r,s);return o.setAuthTag(i),Buffer.concat([o.update(a),o.final()]).toString("utf8")}var qs=p.object({bundleVersion:p.number().int().nonnegative(),signedAt:p.number().int(),filters:p.array(Ye)}),Gs=p.object({payload:p.string().min(1),signature:p.string().min(1),enc:p.literal("v1")}),Ys=10080*60*1e3;function Js(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Ys}function Ar(t,e=Date.now()){return e-t.fetchedAt>Js()}function Xs(t,e){let r=Le();if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new Error("tkr-daemon: no valid signing public key configured (set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM at build time).");let n=Hs({key:r,format:"pem"});if(!Ws(null,Buffer.from(t.payload,"utf8"),n,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(Sr(t.payload,e))}async function Tr(t){let e=await P();if(!e||!e.jwt)throw new Error("tkr-daemon: not activated (no JWT)");if(!e.signingSecret)throw new Error("tkr-daemon: not activated (no signing secret)");let r=await Z("GET","/api/v1/rules/bundle",void 0,{baseUrl:t,bearer:e.jwt,signingSecret:e.signingSecret,fingerprint:e.fingerprint??"0".repeat(64),installId:e.installId,timeoutMs:1e4});if(!r.ok)throw new Error(`tkr-daemon: bundle fetch failed ${r.status}`);let n=Gs.parse(await r.json()),s=Xs(n,e.signingSecret),i=qs.parse(s),a=new Map;for(let o of i.filters)a.set(o.slug,{...o,matchRegex:new RegExp(o.match_command)});return xr(),{bundleVersion:i.bundleVersion,signedAt:i.signedAt,ruleCount:a.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:o=>vr(o,a.values(),new Set(a.keys()))}}async function Rr(t,e={}){await nt();let{path:r,isPipe:n}=e.socketPath?{path:e.socketPath,isPipe:process.platform==="win32"}:Te(),s=t,i=null,a=Date.now(),o=e.idleTimeoutMs??gr,c=process.env.TOKMIZER_DAEMON_INSTALL_ID??"",l=async _=>{if(a=Date.now(),_.op==="ping")return{id:_.id,ok:!0,data:{pid:process.pid,uptimeMs:s?Date.now()-s.startedAt:0,ruleCount:s?.ruleCount??0,bundleVersion:s?.bundleVersion??0}};if(_.op==="shutdown")return!c||_.installId!==c?{id:_.id,ok:!1,err:"forbidden"}:(setTimeout(()=>e.onShutdown?.(),10),{id:_.id,ok:!0,data:{stopping:!0}});if(_.op==="reload"){if(!c||_.installId!==c)return{id:_.id,ok:!1,err:"forbidden"};if(!e.onWarming)return{id:_.id,ok:!1,err:"no_warming_handler"};try{return s=await e.onWarming(),{id:_.id,ok:!0,data:{ruleCount:s.ruleCount,bundleVersion:s.bundleVersion}}}catch(R){return{id:_.id,ok:!1,err:R.message,retryAfterMs:1e3}}}if(_.op==="filter"){if(c&&_.installId!==c)return{id:_.id,ok:!1,err:"forbidden"};if(s&&Ar(s))if(e.onWarming)s=null;else return{id:_.id,ok:!0,data:{filter:null,cacheHit:!0}};if(!s)if(e.onWarming){i||(i=e.onWarming());try{s=await i}catch(dt){return i=null,{id:_.id,ok:!1,err:dt.message,retryAfterMs:1e3}}i=null}else return{id:_.id,ok:!1,err:"warming",retryAfterMs:250};let R=s.selectFor(_.cmd,_.plan);return{id:_.id,ok:!0,data:{filter:R??null,cacheHit:!0}}}return{id:_.id,ok:!1,err:"unknown_op"}},h=Qs(_=>{let R="";_.setEncoding("utf8"),_.on("data",dt=>{if(R+=dt,R.length>dr){_.destroy();return}let Fe=-1;for(let z=0;z<R.length;z++)R[z]===Se&&(Fe=z);if(Fe<0)return;let Ht=[];for(let z of Je(R.slice(0,Fe+1)))Ht.push(z);R=R.slice(Fe+1);for(let z of Ht){if(!z)continue;let Wt="?";try{let ge=JSON.parse(z);typeof ge.id=="string"&&ge.id.length<=64&&(Wt=ge.id);let qt=ur.parse(ge);l(qt).then(ft=>{_.write(Ae(ft))}).catch(ft=>{_.write(Ae({id:qt.id,ok:!1,err:`internal:${ft.message?.slice(0,80)??"error"}`}))})}catch(ge){_.write(Ae({id:Wt,ok:!1,err:`bad_request:${ge.message.slice(0,80)}`}))}}}),_.on("error",()=>{try{_.destroy()}catch{}})}),k=setInterval(()=>{!yr()&&Date.now()-a>o&&e.onShutdown?.(),Date.now()-a>o*2&&e.onShutdown?.()},hr);return k.unref(),await new Promise((_,R)=>{h.once("error",R),h.listen(r,()=>{if(h.off("error",R),!n)try{ei(r,384)}catch{}_()})}),{server:h,close:async()=>{clearInterval(k),await new Promise(_=>h.close(()=>_()))}}}function Ir(t){let e=0,r=0,n=null;return async function(){let i=Date.now();if(r>i&&n)throw new Error(`bundle fetch cooling down for ${r-i}ms (last: ${n.message})`);try{let a=await t();return e=0,r=0,n=null,a}catch(a){if(e+=1,n=a,e>=3){let o=Math.min(6e4,500*2**(e-3));r=Date.now()+o}throw a}}}Oe();he();Ce();G();Ce();he();Oe();import{createPublicKey as oi,verify as ci}from"node:crypto";function ui(t,e){let r=Le();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=oi({key:r,format:"pem"});try{let s=Buffer.from(e,"base64url");return ci(null,Buffer.from(t,"utf8"),n,s)}catch{return!1}}var li=/^[a-z0-9][a-z0-9-]*$/;async function Cr(t){let e=await P();if(!e)throw new Error("Plugin not activated.");let r=await J(),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 Ie(n),i=[];for(let a of s.bundles){if(!li.test(a.slug))throw new Error(`invalid bundle slug ${a.slug}`);let o=[...a.fragments].sort((c,l)=>c.position-l.position);for(let c of o)if(!ui(c.body,c.hash))throw new Error(`fragment signature mismatch on ${a.slug}[${c.position}]`);i.push({slug:a.slug,version:a.version,body:o.map(c=>c.body).join(`
|
|
11
11
|
|
|
12
|
-
`)})}return i}G();import{mkdir as Dt,readFile as
|
|
12
|
+
`)})}return i}G();import{mkdir as Dt,readFile as di,writeFile as Ot,stat as fi,readdir as Dr,rm as Or}from"node:fs/promises";var pi="managed-by: tokmizer",mi=3600*1e3,hi=10080*60*1e3;function gi(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:hi}async function Nr(t){try{let e=await fi(et(t)),r=Date.now()-e.mtimeMs;return r<mi&&r<=gi()}catch{return!1}}async function Pr(t,e){await Dt(Qe(),{recursive:!0}),await Ot(et(t),e,{mode:384})}async function Mr(t){let e=new Set(t),r;try{r=await Dr(Qe())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{await Or(et(s))}catch{}}}async function jr(t,e){await Dt(tt(),{recursive:!0}),await Ot(rt(t),e,{mode:384})}async function Nt(t){let e=new Set(t),r;try{r=await Dr(tt())}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 di(rt(s),"utf8")).includes(pi))continue;await Or(rt(s))}catch{}}}async function Pt(t){try{await Dt(S(),{recursive:!0}),await Ot(pr(),JSON.stringify({at:Date.now(),error:t}),{mode:384})}catch{}}he();Oe();Ce();import{readFile as Ko,writeFile as vi,mkdir as xi,chmod as bi}from"node:fs/promises";import{join as ki}from"node:path";$e();var yi=p.enum(["normal","compact","minimal"]),_i=p.enum(["off","light","balanced","max"]),$r=p.object({enabled:p.boolean().default(!0),telemetryOptIn:p.boolean().default(!0),outputVerbosity:yi.default("compact"),reducer:_i.default("off"),filters:p.object({enableAll:p.boolean().default(!0),disabled:p.array(p.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})});G();var wi="settings-cache.json",Go=$r.parse({});async function Lr(t){await xi(S(),{recursive:!0});let e=ki(S(),wi);await vi(e,JSON.stringify(t,null,2),{mode:384});try{await bi(e,384)}catch{}}async function Ei(t,e){let r=await P();if(!r)throw new Error("Not activated. Run: tkr link");let n=process.env.TOKMIZER_BASE_URL??"https://tokmizer.com",s=await J(),i=await Z(t,"/api/v1/settings",e,{baseUrl:n,bearer:r.jwt,signingSecret:r.signingSecret,fingerprint:s.fingerprint,installId:s.installId,timeoutMs:8e3});if(!i.ok)throw new Error(`Settings ${t} failed: ${i.status}`);let a=await Ie(i);return await Lr(a.settings),a}async function Zr(){return Ei("GET")}Rt();var rn="-command";async function Ji(t,e){if(!(!e&&await Nr("power")))try{let r=await Cr(t),n=[],s=[];for(let i of r)if(i.slug.endsWith(rn)){let a=i.slug.slice(0,-rn.length);await jr(a,i.body),s.push(a)}else await Pr(i.slug,i.body),n.push(i.slug);await Mr(n),await Nt(s),await Pt(null)}catch(r){await Pt(r instanceof Error?r.message:String(r))}}function Xi(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)}}function nn(t,e=0){let r=t.split(".")[1];if(!r)return!0;try{let n=Number(JSON.parse(Buffer.from(r,"base64url").toString("utf8")).exp);return!Number.isFinite(n)||n*1e3<=Date.now()+e}catch{return!0}}async function lt(t){let e=await P();if(!e)return null;let r=await J(),n=e.timeZone??st(),s={ts:Date.now(),localDate:Xi(n),timeZone:n},i;try{i=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(i.status===401)return null;if(i.status===423||i.status===426||i.status===451){await kr();try{await Nt([])}catch{}return null}if(!i.ok)return e;let a;try{a=await Ie(i)}catch{return e}let o=a.settingsRevision??0,c=e.lastSettingsRevision??0,l=o>c,h=a.plan!==e.plan,k={...e,jwt:a.jwt,plan:a.plan,status:a.status,trialEndsAt:a.trialEndsAt,subEndsAt:a.subEndsAt,jwtVersion:a.jwtVersion,lastSettingsRevision:o,lastHeartbeatOkAt:Date.now(),timeZone:n,bonusActive:a.bonusActive??!1,...a.bonusResetAt!==void 0?{bonusResetAt:a.bonusResetAt}:{},...a.latestPluginVersion?{latestPluginVersion:a.latestPluginVersion}:{},...Array.isArray(a.allowedFilters)?{allowedFilters:a.allowedFilters}:{}};if(await br(k),l)try{await Zr()}catch{}if(l||h)try{let{connectDaemon:T}=await Promise.resolve().then(()=>(Wr(),Hr)),_=await T();try{await _.reload()}finally{_.close()}}catch{}await Ji(t,l||h);try{let{flushTelemetry:T}=await Promise.resolve().then(()=>(ut(),en)),{flush:_}=await Promise.resolve().then(()=>(Ut(),tn));await T(t),await _(t)}catch{}return k}var Mc=5*6e4;he();Ut();ut();var Qi=10*6e4,ea=6e4;function sn(t){let e=0,r=async()=>{let n=Date.now();n-e<Qi||(e=n,await lt(t))};return async()=>{let n=await P();if(!n)return;if(nn(n.jwt,ea)){await r();return}(await Promise.all([Vt(t),Bt(t)])).includes("auth")&&await r()}}var Kt=process.env.TOKMIZER_BASE_URL??"https://tokmizer.com",ta=360*60*1e3,ra=6e4;function na(){let t=sn(Kt),e=()=>{t().catch(()=>{})};setTimeout(e,5e3).unref?.(),setInterval(e,ra).unref?.()}function sa(){let t=()=>{lt(Kt).catch(()=>{})};setTimeout(t,6e4+Math.floor(Math.random()*6e4)).unref?.(),setInterval(t,ta).unref?.()}function ia(){if(process.env.TOKMIZER_ALLOW_INSPECT==="1")return;let e=(process.execArgv??[]).find(r=>r.startsWith("--inspect")||r==="--inspect-brk"||r.startsWith("--inspect-port"));e&&(process.stderr.write("tkr-daemon: refusing to start with "+e+` (set TOKMIZER_ALLOW_INSPECT=1 to override for development).
|
|
13
13
|
`),process.exit(2)),process.env.NODE_OPTIONS&&/--inspect/.test(process.env.NODE_OPTIONS)&&(process.stderr.write(`tkr-daemon: refusing to start with --inspect in NODE_OPTIONS.
|
|
14
|
-
`),process.exit(2))}async function
|
|
15
|
-
`)}let r=null;r=await
|
|
14
|
+
`),process.exit(2))}async function aa(){ia(),process.title="tkr-daemon";let t=Ir(()=>Tr(Kt)),e=null;try{e=await t()}catch(n){process.stderr.write(`tkr-daemon: initial fetch failed: ${n.message}
|
|
15
|
+
`)}let r=null;r=await Rr(e,{onWarming:t,onShutdown:()=>{r?.close().finally(()=>process.exit(0))}}),process.on("SIGINT",()=>r.close().finally(()=>process.exit(0))),process.on("SIGTERM",()=>r.close().finally(()=>process.exit(0))),sa(),na()}aa().catch(t=>{process.stderr.write(`tkr-daemon: ${t.message}
|
|
16
16
|
`),process.exit(1)});
|