@tokmizer/plugin 0.5.7 → 0.5.8
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-codex-hook.js +5 -5
- package/dist/bin/tkr-daemon.js +9 -9
- package/dist/bin/tkr-exec.js +12 -12
- package/dist/bin/tkr-shim.js +2 -2
- package/dist/bin/tkr.js +65 -62
- package/dist/hooks-host/post-tool-use.js +1 -1
- package/dist/hooks-host/reducer-stop.js +1 -1
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
|
|
2
|
-
var
|
|
2
|
+
var Nr=Object.defineProperty;var k=(t,e)=>()=>(t&&(e=t(t=0)),e);var Me=(t,e)=>{for(var r in e)Nr(t,r,{get:e[r],enumerable:!0})};import Ct from"node:os";import{join as X}from"node:path";function E(){return process.env.TOKMIZER_HOME||X(Ct.homedir(),".tokmizer")}function rt(){return X(E(),"install-id")}function It(){return X(E(),"bundle-refresh.json")}function je(){return X(E(),"skills")}function $e(t){return X(je(),`${t}.md`)}function Ze(){return process.env.TOKMIZER_CLAUDE_COMMANDS_DIR||X(Ct.homedir(),".claude","commands")}function ze(t){return X(Ze(),`${t}.md`)}var U=k(()=>{"use strict"});import ge from"node:os";import{createHash as Pr,randomUUID as Mr}from"node:crypto";import{readFile as jr,writeFile as $r,mkdir as Zr}from"node:fs/promises";async function st(){try{let r=(await jr(rt(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await Zr(E(),{recursive:!0});let t=Mr();return await $r(rt(),t,{mode:384}),t}function nt(t){return Pr("sha256").update(t).digest("hex")}function zr(){let t=ge.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 N(){let t=await st(),e=ge.hostname(),r=ge.platform(),n=ge.release(),s=ge.cpus(),a=s[0]?.model??"unknown",i=s.length,o=nt(zr()),c=nt(ge.userInfo().username),l=[e,r,n,a,String(i),o,c,t].join("|");return{fingerprint:nt(l),installId:t,hostname:e,os:r,osVersion:n,cpuModel:a,cpuCores:i,macHash:o,usernameHash:c}}var Q=k(()=>{"use strict";U()});import{join as at}from"node:path";import{mkdir as Fr,readFile as Lr,writeFile as Vr,unlink as Ur,rename as Br}from"node:fs/promises";function ye(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function ot(t){return t?.dir??E()}async function B(t){let e=ot(t);try{let r=await Lr(at(e,it),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??ye(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}async function Ae(t,e){let r=ot(e);await Fr(r,{recursive:!0});let n=at(r,it),s=`${n}.tmp`;await Vr(s,JSON.stringify(t,null,2),{mode:384}),await Br(s,n)}async function Ot(t){let e=ot(t);try{await Ur(at(e,it))}catch{return}}var it,Ra,Te=k(()=>{"use strict";U();it="state.json",Ra={lastSettingsRevision:0,timeZone:ye(),bonusActive:!1}});import{createRequire as Kr}from"node:module";function qr(){for(let t of["../package.json","../../package.json"])try{let e=Hr(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Hr,K,Fe=k(()=>{"use strict";Hr=Kr(import.meta.url);K=qr()});var Dt,Nt=k(()=>{"use strict";Dt=`-----BEGIN PUBLIC KEY-----
|
|
3
3
|
MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
|
|
4
4
|
-----END PUBLIC KEY-----
|
|
5
|
-
`});import{createHmac as
|
|
6
|
-
`)}function Jr(t,e,r,n){try{let s=Gr({key:n,format:"pem"});return Wr(null,Buffer.from(`${e}.${t}`,"utf8"),s,Buffer.from(r,"base64url"))}catch{return!1}}async function X(t){let e=await t.text(),r=ct(),n=t.headers?.get?.("x-tokmizer-resp-ts")??null;if(n!==null){let i=Number(n);if(!Number.isFinite(i)||Date.now()-i>Yr)throw new K("http","stale server response (resp-ts outside freshness window)")}if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new K("http","no signing public key configured; refusing to trust server response");let s=t.headers?.get?.("x-tokmizer-resp-sig")??null,a=Number(n);if(!s||n===null||!Number.isFinite(a))throw new K("http","missing server response signature");if(!Jr(e,a,s,r))throw new K("http","invalid server response signature");return JSON.parse(e)}function Xr(t,e,r){return qr("sha256",r).update(`${e}.${t}`).digest("hex")}async function Z(t,e,r,n){let s=Date.now(),a=r===void 0?"":JSON.stringify(r),i=n.signingSecret?Xr(a,s,n.signingSecret):"0".repeat(64),o={"content-type":"application/json","x-tokmizer-fingerprint":n.fingerprint,"x-tokmizer-install-id":n.installId,"x-tokmizer-sig":i,"x-tokmizer-ts":String(s),"x-tokmizer-plugin-version":ge};n.bearer&&(o.authorization=`Bearer ${n.bearer}`);let c=n.timeoutMs??5e3,l=t!=="GET"&&t!=="DELETE",h={method:t,headers:o,signal:AbortSignal.timeout(c)};l&&(h.body=a);try{return await fetch(`${n.baseUrl}${e}`,h)}catch(b){let R=b.name;throw R==="TimeoutError"||R==="AbortError"?new K("timeout",`${t} ${e} timed out after ${c}ms`):new K("network",`${t} ${e} failed: ${b.message}`)}}var Yr,K,Te=k(()=>{"use strict";ze();Dt();Yr=300*1e3;K=class extends Error{constructor(r,n,s){super(n);this.kind=r;this.status=s;this.name="TransportError"}kind;status}});var x,pt,f,M,Re=k(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},t.find=(s,a)=>{for(let i of s)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(pt||(pt={}));f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}}});var u,ln,A,Le=k(()=>{Re();u=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ln=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),A=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let o=n,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let a=s.path[0];r[a]=r[a]||[],r[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};A.create=t=>new A(t)});var dn,z,mt=k(()=>{Le();Re();dn=(t,e)=>{let r;switch(t.code){case u.invalid_type:t.received===f.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:r="Invalid function arguments";break;case u.invalid_return_type:r="Invalid function return type";break;case u.invalid_date:r="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:x.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case u.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case u.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case u.custom:r="Invalid input";break;case u.invalid_intersection_types:r="Intersection results could not be merged";break;case u.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:r="Number must be finite";break;default:r=e.defaultError,x.assertNever(t)}return{message:r}},z=dn});function fn(t){Ft=t}function ye(){return Ft}var Ft,Fe=k(()=>{mt();Ft=z});function d(t,e){let r=ye(),n=Ce({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===z?void 0:z].filter(s=>!!s)});t.common.issues.push(n)}var Ce,pn,E,g,Q,S,Ve,Ue,H,_e,ht=k(()=>{Fe();mt();Ce=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},pn=[];E=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let a=await s.key,i=await s.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return g;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),Q=t=>({status:"dirty",value:t}),S=t=>({status:"valid",value:t}),Ve=t=>t.status==="aborted",Ue=t=>t.status==="dirty",H=t=>t.status==="valid",_e=t=>typeof Promise<"u"&&t instanceof Promise});var Vt=k(()=>{});var p,Ut=k(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}))});function _(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}function qt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function In(t){return new RegExp(`^${qt(t)}$`)}function Gt(t){let e=`${Ht}T${qt(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function On(t,e){return!!((e==="v4"||!e)&&wn.test(t)||(e==="v6"||!e)&&Sn.test(t))}function Dn(t,e){if(!vn.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Nn(t,e){return!!((e==="v4"||!e)&&En.test(t)||(e==="v6"||!e)&&An.test(t))}function Pn(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}function ve(t){if(t instanceof T){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=I.create(ve(n))}return new T({...t._def,shape:()=>e})}else return t instanceof V?new V({...t._def,type:ve(t.element)}):t instanceof I?I.create(ve(t.unwrap())):t instanceof $?$.create(ve(t.unwrap())):t instanceof j?j.create(t.items.map(e=>ve(e))):t}function yt(t,e){let r=M(t),n=M(e);if(t===e)return{valid:!0,data:t};if(r===f.object&&n===f.object){let s=x.objectKeys(e),a=x.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(let o of a){let c=yt(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(r===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<t.length;a++){let i=t[a],o=e[a],c=yt(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function Wt(t,e){return new le({values:t,typeName:y.ZodEnum,..._(e)})}function Kt(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Yt(t,e={},r){return t?G.create().superRefine((n,s)=>{let a=t(n);if(a instanceof Promise)return a.then(i=>{if(!i){let o=Kt(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=Kt(e,n),o=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:o})}}):G.create()}var O,Bt,v,mn,hn,gn,yn,_n,vn,xn,bn,kn,gt,wn,En,Sn,An,Tn,Rn,Ht,Cn,q,ee,te,re,ne,xe,se,ae,G,F,N,be,V,T,ie,L,Be,oe,j,Ke,ke,we,He,ce,ue,le,de,W,D,I,$,fe,pe,Ee,Mn,Ie,Oe,me,jn,y,$n,Jt,Xt,Zn,zn,Qt,Ln,Fn,Vn,Un,Bn,Kn,Hn,qn,Gn,Wn,Yn,Jn,Xn,Qn,es,ts,rs,ns,ss,as,is,os,cs,us,ls,ds,fs,ps,ms,hs,gs,ys,_s,vs,er=k(()=>{Le();Fe();Ut();ht();Re();O=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Bt=(t,e)=>{if(H(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new A(t.common.issues);return this._error=r,this._error}}};v=class{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new E,ctx:{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(_e(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Bt(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return H(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>H(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(_e(s)?s:Promise.resolve(s));return Bt(n,a)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{let i=e(s),o=()=>a.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new D({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return I.create(this,this._def)}nullable(){return $.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return V.create(this)}promise(){return W.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return oe.create(this,e,this._def)}transform(e){return new D({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new fe({..._(this._def),innerType:this,defaultValue:r,typeName:y.ZodDefault})}brand(){return new Ie({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new pe({..._(this._def),innerType:this,catchValue:r,typeName:y.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Oe.create(this,e)}readonly(){return me.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},mn=/^c[^\s-]{8,}$/i,hn=/^[0-9a-z]+$/,gn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,yn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,_n=/^[a-z0-9_-]{21}$/i,vn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,bn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,kn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",wn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,En=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Sn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,An=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Tn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Rn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ht="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Cn=new RegExp(`^${Ht}$`);q=class t extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_type,expected:f.string,received:a.parsedType}),g}let n=new E,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?d(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&d(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")bn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"email",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")gt||(gt=new RegExp(kn,"u")),gt.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"emoji",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")yn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"uuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")_n.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"nanoid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")mn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")hn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid2",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")gn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ulid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),d(s,{validation:"url",code:u.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"regex",code:u.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Gt(a).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?In(a).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?xn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"duration",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?On(e.data,a.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ip",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Dn(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"jwt",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Nn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cidr",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Tn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Rn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64url",code:u.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:u.invalid_string,...p.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...p.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...p.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...p.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...p.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...p.errToObj(r)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};q.create=t=>new q({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,..._(t)});ee=class t extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),g}let n,s=new E;for(let a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Pn(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,p.toString(r))}gt(e,r){return this.setLimit("min",e,!1,p.toString(r))}lte(e,r){return this.setLimit("max",e,!0,p.toString(r))}lt(e,r){return this.setLimit("max",e,!1,p.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};ee.create=t=>new ee({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,..._(t)});te=class t extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let n,s=new E;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,p.toString(r))}gt(e,r){return this.setLimit("min",e,!1,p.toString(r))}lte(e,r){return this.setLimit("max",e,!0,p.toString(r))}lt(e,r){return this.setLimit("max",e,!1,p.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};te.create=t=>new te({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,..._(t)});re=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.boolean,received:n.parsedType}),g}return S(e.data)}};re.create=t=>new re({typeName:y.ZodBoolean,coerce:t?.coerce||!1,..._(t)});ne=class t extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_type,expected:f.date,received:a.parsedType}),g}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_date}),g}let n=new E,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ne.create=t=>new ne({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,..._(t)});xe=class extends v{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.symbol,received:n.parsedType}),g}return S(e.data)}};xe.create=t=>new xe({typeName:y.ZodSymbol,..._(t)});se=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.undefined,received:n.parsedType}),g}return S(e.data)}};se.create=t=>new se({typeName:y.ZodUndefined,..._(t)});ae=class extends v{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.null,received:n.parsedType}),g}return S(e.data)}};ae.create=t=>new ae({typeName:y.ZodNull,..._(t)});G=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return S(e.data)}};G.create=t=>new G({typeName:y.ZodAny,..._(t)});F=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return S(e.data)}};F.create=t=>new F({typeName:y.ZodUnknown,..._(t)});N=class extends v{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.never,received:r.parsedType}),g}};N.create=t=>new N({typeName:y.ZodNever,..._(t)});be=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.void,received:n.parsedType}),g}return S(e.data)}};be.create=t=>new be({typeName:y.ZodVoid,..._(t)});V=class t extends v{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==f.array)return d(r,{code:u.invalid_type,expected:f.array,received:r.parsedType}),g;if(s.exactLength!==null){let i=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(i||o)&&(d(r,{code:i?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(d(r,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(d(r,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>s.type._parseAsync(new O(r,i,r.path,o)))).then(i=>E.mergeArray(n,i));let a=[...r.data].map((i,o)=>s.type._parseSync(new O(r,i,r.path,o)));return E.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:p.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:p.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:p.toString(r)}})}nonempty(e){return this.min(1,e)}};V.create=(t,e)=>new V({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});T=class t extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=x.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return d(l,{code:u.invalid_type,expected:f.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof N&&this._def.unknownKeys==="strip"))for(let l in s.data)i.includes(l)||o.push(l);let c=[];for(let l of i){let h=a[l],b=s.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new O(s,b,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof N){let l=this._def.unknownKeys;if(l==="passthrough")for(let h of o)c.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(l==="strict")o.length>0&&(d(s,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let h of o){let b=s.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new O(s,b,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let h of c){let b=await h.key,R=await h.value;l.push({key:b,value:R,alwaysSet:h.alwaysSet})}return l}).then(l=>E.mergeObjectSync(n,l)):E.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:p.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of x.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of x.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return ve(this)}partial(e){let r={};for(let n of x.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of x.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof I;)a=a._def.innerType;r[n]=a}return new t({...this._def,shape:()=>r})}keyof(){return Wt(x.objectKeys(this.shape))}};T.create=(t,e)=>new T({shape:()=>t,unknownKeys:"strip",catchall:N.create(),typeName:y.ZodObject,..._(e)});T.strictCreate=(t,e)=>new T({shape:()=>t,unknownKeys:"strict",catchall:N.create(),typeName:y.ZodObject,..._(e)});T.lazycreate=(t,e)=>new T({shape:t,unknownKeys:"strip",catchall:N.create(),typeName:y.ZodObject,..._(e)});ie=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new A(o.ctx.common.issues));return d(r,{code:u.invalid_union,unionErrors:i}),g}if(r.common.async)return Promise.all(n.map(async a=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},h=c._parseSync({data:r.data,path:r.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new A(c));return d(r,{code:u.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};ie.create=(t,e)=>new ie({options:t,typeName:y.ZodUnion,..._(e)});L=t=>t instanceof ce?L(t.schema):t instanceof D?L(t.innerType()):t instanceof ue?[t.value]:t instanceof le?t.options:t instanceof de?x.objectValues(t.enum):t instanceof fe?L(t._def.innerType):t instanceof se?[void 0]:t instanceof ae?[null]:t instanceof I?[void 0,...L(t.unwrap())]:t instanceof $?[null,...L(t.unwrap())]:t instanceof Ie||t instanceof me?L(t.unwrap()):t instanceof pe?L(t._def.innerType):[],Be=class t extends v{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return d(r,{code:u.invalid_type,expected:f.object,received:r.parsedType}),g;let n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(d(r,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let a of r){let i=L(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,..._(n)})}};oe=class extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Ve(a)||Ve(i))return g;let o=yt(a.value,i.value);return o.valid?((Ue(a)||Ue(i))&&r.dirty(),{status:r.value,value:o.data}):(d(n,{code:u.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};oe.create=(t,e,r)=>new oe({left:t,right:e,typeName:y.ZodIntersection,..._(r)});j=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return d(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return d(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new O(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>E.mergeArray(r,i)):E.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};j.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new j({items:t,typeName:y.ZodTuple,rest:null,..._(e)})};Ke=class t extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return d(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],a=this._def.keyType,i=this._def.valueType;for(let o in n.data)s.push({key:a._parse(new O(n,o,n.path,o)),value:i._parse(new O(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?E.mergeObjectAsync(r,s):E.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof v?new t({keyType:e,valueType:r,typeName:y.ZodRecord,..._(n)}):new t({keyType:q.create(),valueType:e,typeName:y.ZodRecord,..._(r)})}},ke=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return d(n,{code:u.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new O(n,o,n.path,[l,"key"])),value:a._parse(new O(n,c,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return g;(l.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(l.value,h.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of i){let l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return g;(l.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(l.value,h.value)}return{status:r.value,value:o}}}};ke.create=(t,e,r)=>new ke({valueType:e,keyType:t,typeName:y.ZodMap,..._(r)});we=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return d(n,{code:u.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(d(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(d(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let a=this._def.valueType;function i(c){let l=new Set;for(let h of c){if(h.status==="aborted")return g;h.status==="dirty"&&r.dirty(),l.add(h.value)}return{status:r.value,value:l}}let o=[...n.data.values()].map((c,l)=>a._parse(new O(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:p.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:p.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};we.create=(t,e)=>new we({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});He=class t extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.function)return d(r,{code:u.invalid_type,expected:f.function,received:r.parsedType}),g;function n(o,c){return Ce({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ye(),z].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(o,c){return Ce({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ye(),z].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof W){let o=this;return S(async function(...c){let l=new A([]),h=await o._def.args.parseAsync(c,a).catch(C=>{throw l.addIssue(n(c,C)),l}),b=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(b,a).catch(C=>{throw l.addIssue(s(b,C)),l})})}else{let o=this;return S(function(...c){let l=o._def.args.safeParse(c,a);if(!l.success)throw new A([n(c,l.error)]);let h=Reflect.apply(i,this,l.data),b=o._def.returns.safeParse(h,a);if(!b.success)throw new A([s(h,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:j.create(e).rest(F.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||j.create([]).rest(F.create()),returns:r||F.create(),typeName:y.ZodFunction,..._(n)})}},ce=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};ce.create=(t,e)=>new ce({getter:t,typeName:y.ZodLazy,..._(e)});ue=class extends v{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return d(r,{received:r.data,code:u.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};ue.create=(t,e)=>new ue({value:t,typeName:y.ZodLiteral,..._(e)});le=class t extends v{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:x.joinValues(n),received:r.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{received:r.data,code:u.invalid_enum_value,options:n}),g}return S(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};le.create=Wt;de=class extends v{_parse(e){let r=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=x.objectValues(r);return d(n,{expected:x.joinValues(s),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=x.objectValues(r);return d(n,{received:n.data,code:u.invalid_enum_value,options:s}),g}return S(e.data)}get enum(){return this._def.values}};de.create=(t,e)=>new de({values:t,typeName:y.ZodNativeEnum,..._(e)});W=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.promise&&r.common.async===!1)return d(r,{code:u.invalid_type,expected:f.promise,received:r.parsedType}),g;let n=r.parsedType===f.promise?r.data:Promise.resolve(r.data);return S(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};W.create=(t,e)=>new W({type:t,typeName:y.ZodPromise,..._(e)});D=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{d(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(r.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?Q(c.value):r.value==="dirty"?Q(c.value):c});{if(r.value==="aborted")return g;let o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?Q(o.value):r.value==="dirty"?Q(o.value):o}}if(s.type==="refinement"){let i=o=>{let c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),i(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),i(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!H(i))return g;let o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>H(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):g);x.assertNever(s)}};D.create=(t,e,r)=>new D({schema:t,typeName:y.ZodEffects,effect:e,..._(r)});D.createWithPreprocess=(t,e,r)=>new D({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,..._(r)});I=class extends v{_parse(e){return this._getType(e)===f.undefined?S(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};I.create=(t,e)=>new I({innerType:t,typeName:y.ZodOptional,..._(e)});$=class extends v{_parse(e){return this._getType(e)===f.null?S(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:y.ZodNullable,..._(e)});fe=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};fe.create=(t,e)=>new fe({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});pe=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return _e(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new A(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new A(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};pe.create=(t,e)=>new pe({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});Ee=class extends v{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};Ee.create=t=>new Ee({typeName:y.ZodNaN,..._(t)});Mn=Symbol("zod_brand"),Ie=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Oe=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?g:a.status==="dirty"?(r.dirty(),Q(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:y.ZodPipeline})}},me=class extends v{_parse(e){let r=this._def.innerType._parse(e),n=s=>(H(s)&&(s.value=Object.freeze(s.value)),s);return _e(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};me.create=(t,e)=>new me({innerType:t,typeName:y.ZodReadonly,..._(e)});jn={object:T.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(y||(y={}));$n=(t,e={message:`Input not instance of ${t.name}`})=>Yt(r=>r instanceof t,e),Jt=q.create,Xt=ee.create,Zn=Ee.create,zn=te.create,Qt=re.create,Ln=ne.create,Fn=xe.create,Vn=se.create,Un=ae.create,Bn=G.create,Kn=F.create,Hn=N.create,qn=be.create,Gn=V.create,Wn=T.create,Yn=T.strictCreate,Jn=ie.create,Xn=Be.create,Qn=oe.create,es=j.create,ts=Ke.create,rs=ke.create,ns=we.create,ss=He.create,as=ce.create,is=ue.create,os=le.create,cs=de.create,us=W.create,ls=D.create,ds=I.create,fs=$.create,ps=D.createWithPreprocess,ms=Oe.create,hs=()=>Jt().optional(),gs=()=>Xt().optional(),ys=()=>Qt().optional(),_s={string:(t=>q.create({...t,coerce:!0})),number:(t=>ee.create({...t,coerce:!0})),boolean:(t=>re.create({...t,coerce:!0})),bigint:(t=>te.create({...t,coerce:!0})),date:(t=>ne.create({...t,coerce:!0}))},vs=g});var m={};Pe(m,{BRAND:()=>Mn,DIRTY:()=>Q,EMPTY_PATH:()=>pn,INVALID:()=>g,NEVER:()=>vs,OK:()=>S,ParseStatus:()=>E,Schema:()=>v,ZodAny:()=>G,ZodArray:()=>V,ZodBigInt:()=>te,ZodBoolean:()=>re,ZodBranded:()=>Ie,ZodCatch:()=>pe,ZodDate:()=>ne,ZodDefault:()=>fe,ZodDiscriminatedUnion:()=>Be,ZodEffects:()=>D,ZodEnum:()=>le,ZodError:()=>A,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>He,ZodIntersection:()=>oe,ZodIssueCode:()=>u,ZodLazy:()=>ce,ZodLiteral:()=>ue,ZodMap:()=>ke,ZodNaN:()=>Ee,ZodNativeEnum:()=>de,ZodNever:()=>N,ZodNull:()=>ae,ZodNullable:()=>$,ZodNumber:()=>ee,ZodObject:()=>T,ZodOptional:()=>I,ZodParsedType:()=>f,ZodPipeline:()=>Oe,ZodPromise:()=>W,ZodReadonly:()=>me,ZodRecord:()=>Ke,ZodSchema:()=>v,ZodSet:()=>we,ZodString:()=>q,ZodSymbol:()=>xe,ZodTransformer:()=>D,ZodTuple:()=>j,ZodType:()=>v,ZodUndefined:()=>se,ZodUnion:()=>ie,ZodUnknown:()=>F,ZodVoid:()=>be,addIssueToContext:()=>d,any:()=>Bn,array:()=>Gn,bigint:()=>zn,boolean:()=>Qt,coerce:()=>_s,custom:()=>Yt,date:()=>Ln,datetimeRegex:()=>Gt,defaultErrorMap:()=>z,discriminatedUnion:()=>Xn,effect:()=>ls,enum:()=>os,function:()=>ss,getErrorMap:()=>ye,getParsedType:()=>M,instanceof:()=>$n,intersection:()=>Qn,isAborted:()=>Ve,isAsync:()=>_e,isDirty:()=>Ue,isValid:()=>H,late:()=>jn,lazy:()=>as,literal:()=>is,makeIssue:()=>Ce,map:()=>rs,nan:()=>Zn,nativeEnum:()=>cs,never:()=>Hn,null:()=>Un,nullable:()=>fs,number:()=>Xt,object:()=>Wn,objectUtil:()=>pt,oboolean:()=>ys,onumber:()=>gs,optional:()=>ds,ostring:()=>hs,pipeline:()=>ms,preprocess:()=>ps,promise:()=>us,quotelessJson:()=>ln,record:()=>ts,set:()=>ns,setErrorMap:()=>fn,strictObject:()=>Yn,string:()=>Jt,symbol:()=>Fn,transformer:()=>ls,tuple:()=>es,undefined:()=>Vn,union:()=>Jn,unknown:()=>Kn,util:()=>x,void:()=>qn});var _t=k(()=>{Fe();ht();Vt();Re();er();Le()});var qe=k(()=>{_t();_t()});var sr,ar=k(()=>{"use strict";qe();sr=m.object({slug:m.string().min(1).max(64),description:m.string().max(255).optional(),match_command:m.string().min(1),priority:m.number().int().default(50),strip_ansi:m.boolean().default(!1),strip_lines_matching:m.array(m.string()).default([]),truncate_lines_at:m.number().int().positive().max(1e4).optional(),max_lines:m.number().int().positive().max(1e5).optional(),transform:m.string().max(64).optional(),on_empty:m.string().max(255).optional()})});function or(t){return JSON.stringify(t)+Ge}function*cr(t){let e=0;for(;;){let r=t.indexOf(Ge,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function We(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Rs,Cs,Is,Os,Pi,Mi,ji,ir,Ge,$i,ur=k(()=>{"use strict";qe();ar();Rs=m.object({id:m.string().min(1).max(64),op:m.literal("filter"),cmd:m.string().min(1).max(2048),plan:m.enum(["trial","smart","pro"]),installId:m.string().min(1).max(64).optional()}),Cs=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),Is=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),Os=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),Pi=m.discriminatedUnion("op",[Rs,Cs,Is,Os]),Mi=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),ji=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),ir=m.object({filter:sr.nullable(),cacheHit:m.boolean().optional()}),Ge=`
|
|
7
|
-
|
|
8
|
-
`,{mode:384})}catch{return}}function
|
|
9
|
-
`))if(a.trim())try{s.push(JSON.parse(a))}catch{continue}return s.length===0?(
|
|
5
|
+
`});import{createHmac as Gr,createPublicKey as Wr,verify as Yr}from"node:crypto";function ct(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??Dt).replace(/\\n/g,`
|
|
6
|
+
`)}function Xr(t,e,r,n){try{let s=Wr({key:n,format:"pem"});return Yr(null,Buffer.from(`${e}.${t}`,"utf8"),s,Buffer.from(r,"base64url"))}catch{return!1}}async function q(t){let e=await t.text(),r=ct(),n=t.headers?.get?.("x-tokmizer-resp-ts")??null;if(n!==null){let i=Number(n);if(!Number.isFinite(i)||Date.now()-i>Jr)throw new H("http","stale server response (resp-ts outside freshness window)")}if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new H("http","no signing public key configured; refusing to trust server response");let s=t.headers?.get?.("x-tokmizer-resp-sig")??null,a=Number(n);if(!s||n===null||!Number.isFinite(a))throw new H("http","missing server response signature");if(!Xr(e,a,s,r))throw new H("http","invalid server response signature");return JSON.parse(e)}function Qr(t,e,r){return Gr("sha256",r).update(`${e}.${t}`).digest("hex")}async function M(t,e,r,n){let s=Date.now(),a=r===void 0?"":JSON.stringify(r),i=n.signingSecret?Qr(a,s,n.signingSecret):"0".repeat(64),o={"content-type":"application/json","x-tokmizer-fingerprint":n.fingerprint,"x-tokmizer-install-id":n.installId,"x-tokmizer-sig":i,"x-tokmizer-ts":String(s),"x-tokmizer-plugin-version":K};n.bearer&&(o.authorization=`Bearer ${n.bearer}`);let c=n.timeoutMs??5e3,l=t!=="GET"&&t!=="DELETE",h={method:t,headers:o,signal:AbortSignal.timeout(c)};l&&(h.body=a);try{return await fetch(`${n.baseUrl}${e}`,h)}catch(b){let w=b.name;throw w==="TimeoutError"||w==="AbortError"?new H("timeout",`${t} ${e} timed out after ${c}ms`):new H("network",`${t} ${e} failed: ${b.message}`)}}var Jr,H,Re=k(()=>{"use strict";Fe();Nt();Jr=300*1e3;H=class extends Error{constructor(r,n,s){super(n);this.kind=r;this.status=s;this.name="TransportError"}kind;status}});var x,pt,f,j,Ce=k(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},t.find=(s,a)=>{for(let i of s)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(pt||(pt={}));f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),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,dn,R,Le=k(()=>{Ce();u=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),dn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),R=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let o=n,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let a=s.path[0];r[a]=r[a]||[],r[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};R.create=t=>new R(t)});var fn,z,mt=k(()=>{Le();Ce();fn=(t,e)=>{let r;switch(t.code){case u.invalid_type:t.received===f.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:r="Invalid function arguments";break;case u.invalid_return_type:r="Invalid function return type";break;case u.invalid_date:r="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:x.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case u.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case u.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case u.custom:r="Invalid input";break;case u.invalid_intersection_types:r="Intersection results could not be merged";break;case u.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:r="Number must be finite";break;default:r=e.defaultError,x.assertNever(t)}return{message:r}},z=fn});function pn(t){Vt=t}function _e(){return Vt}var Vt,Ve=k(()=>{mt();Vt=z});function d(t,e){let r=_e(),n=Ie({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===z?void 0:z].filter(s=>!!s)});t.common.issues.push(n)}var Ie,mn,S,g,ee,A,Ue,Be,G,ve,ht=k(()=>{Ve();mt();Ie=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},mn=[];S=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let a=await s.key,i=await s.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return g;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),ee=t=>({status:"dirty",value:t}),A=t=>({status:"valid",value:t}),Ue=t=>t.status==="aborted",Be=t=>t.status==="dirty",G=t=>t.status==="valid",ve=t=>typeof Promise<"u"&&t instanceof Promise});var Ut=k(()=>{});var p,Bt=k(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}))});function _(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}function Gt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function On(t){return new RegExp(`^${Gt(t)}$`)}function Wt(t){let e=`${qt}T${Gt(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Dn(t,e){return!!((e==="v4"||!e)&&En.test(t)||(e==="v6"||!e)&&An.test(t))}function Nn(t,e){if(!xn.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 Pn(t,e){return!!((e==="v4"||!e)&&Sn.test(t)||(e==="v6"||!e)&&Tn.test(t))}function Mn(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}function xe(t){if(t instanceof C){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=I.create(xe(n))}return new C({...t._def,shape:()=>e})}else return t instanceof V?new V({...t._def,type:xe(t.element)}):t instanceof I?I.create(xe(t.unwrap())):t instanceof Z?Z.create(xe(t.unwrap())):t instanceof $?$.create(t.items.map(e=>xe(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=x.objectKeys(e),a=x.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(let o of a){let c=yt(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(r===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<t.length;a++){let i=t[a],o=e[a],c=yt(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function Yt(t,e){return new de({values:t,typeName:y.ZodEnum,..._(e)})}function Ht(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Jt(t,e={},r){return t?Y.create().superRefine((n,s)=>{let a=t(n);if(a instanceof Promise)return a.then(i=>{if(!i){let o=Ht(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=Ht(e,n),o=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:o})}}):Y.create()}var O,Kt,v,hn,gn,yn,_n,vn,xn,bn,kn,wn,gt,En,Sn,An,Tn,Rn,Cn,qt,In,W,te,re,ne,se,be,ae,ie,Y,L,P,ke,V,C,oe,F,Ke,ce,$,He,we,Ee,qe,ue,le,de,fe,J,D,I,Z,pe,me,Se,jn,Oe,De,he,$n,y,Zn,Xt,Qt,zn,Fn,er,Ln,Vn,Un,Bn,Kn,Hn,qn,Gn,Wn,Yn,Jn,Xn,Qn,es,ts,rs,ns,ss,as,is,os,cs,us,ls,ds,fs,ps,ms,hs,gs,ys,_s,vs,xs,tr=k(()=>{Le();Ve();Bt();ht();Ce();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}},Kt=(t,e)=>{if(G(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 R(t.common.issues);return this._error=r,this._error}}};v=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 S,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(ve(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 Kt(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 G(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=>G(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}),a=await(ve(s)?s:Promise.resolve(s));return Kt(n,a)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{let i=e(s),o=()=>a.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new D({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return I.create(this,this._def)}nullable(){return Z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return V.create(this)}promise(){return J.create(this,this._def)}or(e){return oe.create([this,e],this._def)}and(e){return ce.create(this,e,this._def)}transform(e){return new D({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new pe({..._(this._def),innerType:this,defaultValue:r,typeName:y.ZodDefault})}brand(){return new Oe({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new me({..._(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 De.create(this,e)}readonly(){return he.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},hn=/^c[^\s-]{8,}$/i,gn=/^[0-9a-z]+$/,yn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_n=/^[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,vn=/^[a-z0-9_-]{21}$/i,xn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,bn=/^[-+]?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)?)??$/,kn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",En=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Sn=/^(?:(?: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])$/,An=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Tn=/^(([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])$/,Rn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Cn=/^([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])))",In=new RegExp(`^${qt}$`);W=class t extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_type,expected:f.string,received:a.parsedType}),g}let n=new S,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?d(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&d(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")kn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"email",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")gt||(gt=new RegExp(wn,"u")),gt.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"emoji",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")_n.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"uuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")vn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"nanoid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")hn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")gn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid2",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")yn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ulid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),d(s,{validation:"url",code:u.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"regex",code:u.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Wt(a).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?In.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?On(a).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?bn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"duration",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Dn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ip",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Nn(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"jwt",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Pn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cidr",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Rn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64url",code:u.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:u.invalid_string,...p.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...p.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...p.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...p.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...p.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...p.errToObj(r)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};W.create=t=>new W({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,..._(t)});te=class t extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),g}let n,s=new S;for(let a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Mn(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,p.toString(r))}gt(e,r){return this.setLimit("min",e,!1,p.toString(r))}lte(e,r){return this.setLimit("max",e,!0,p.toString(r))}lt(e,r){return this.setLimit("max",e,!1,p.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};te.create=t=>new te({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,..._(t)});re=class t extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let n,s=new S;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,p.toString(r))}gt(e,r){return this.setLimit("min",e,!1,p.toString(r))}lte(e,r){return this.setLimit("max",e,!0,p.toString(r))}lt(e,r){return this.setLimit("max",e,!1,p.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};re.create=t=>new re({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,..._(t)});ne=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.boolean,received:n.parsedType}),g}return A(e.data)}};ne.create=t=>new ne({typeName:y.ZodBoolean,coerce:t?.coerce||!1,..._(t)});se=class t extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_type,expected:f.date,received:a.parsedType}),g}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return d(a,{code:u.invalid_date}),g}let n=new S,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};se.create=t=>new se({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,..._(t)});be=class extends v{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.symbol,received:n.parsedType}),g}return A(e.data)}};be.create=t=>new be({typeName:y.ZodSymbol,..._(t)});ae=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.undefined,received:n.parsedType}),g}return A(e.data)}};ae.create=t=>new ae({typeName:y.ZodUndefined,..._(t)});ie=class extends v{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.null,received:n.parsedType}),g}return A(e.data)}};ie.create=t=>new ie({typeName:y.ZodNull,..._(t)});Y=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return A(e.data)}};Y.create=t=>new Y({typeName:y.ZodAny,..._(t)});L=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return A(e.data)}};L.create=t=>new L({typeName:y.ZodUnknown,..._(t)});P=class extends v{_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,..._(t)});ke=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.void,received:n.parsedType}),g}return A(e.data)}};ke.create=t=>new ke({typeName:y.ZodVoid,..._(t)});V=class t extends v{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==f.array)return d(r,{code:u.invalid_type,expected:f.array,received:r.parsedType}),g;if(s.exactLength!==null){let i=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(i||o)&&(d(r,{code:i?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(d(r,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(d(r,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>s.type._parseAsync(new O(r,i,r.path,o)))).then(i=>S.mergeArray(n,i));let a=[...r.data].map((i,o)=>s.type._parseSync(new O(r,i,r.path,o)));return S.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:p.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:p.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:p.toString(r)}})}nonempty(e){return this.min(1,e)}};V.create=(t,e)=>new V({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});C=class t extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=x.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return d(l,{code:u.invalid_type,expected:f.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof P&&this._def.unknownKeys==="strip"))for(let l in s.data)i.includes(l)||o.push(l);let c=[];for(let l of i){let h=a[l],b=s.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new O(s,b,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof 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 b=s.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new O(s,b,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let h of c){let b=await h.key,w=await h.value;l.push({key:b,value:w,alwaysSet:h.alwaysSet})}return l}).then(l=>S.mergeObjectSync(n,l)):S.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:p.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of x.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of x.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return xe(this)}partial(e){let r={};for(let n of x.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of x.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof I;)a=a._def.innerType;r[n]=a}return new t({...this._def,shape:()=>r})}keyof(){return Yt(x.objectKeys(this.shape))}};C.create=(t,e)=>new C({shape:()=>t,unknownKeys:"strip",catchall:P.create(),typeName:y.ZodObject,..._(e)});C.strictCreate=(t,e)=>new C({shape:()=>t,unknownKeys:"strict",catchall:P.create(),typeName:y.ZodObject,..._(e)});C.lazycreate=(t,e)=>new C({shape:t,unknownKeys:"strip",catchall:P.create(),typeName:y.ZodObject,..._(e)});oe=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new R(o.ctx.common.issues));return d(r,{code:u.invalid_union,unionErrors:i}),g}if(r.common.async)return Promise.all(n.map(async a=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},h=c._parseSync({data:r.data,path:r.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new R(c));return d(r,{code:u.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};oe.create=(t,e)=>new oe({options:t,typeName:y.ZodUnion,..._(e)});F=t=>t instanceof ue?F(t.schema):t instanceof D?F(t.innerType()):t instanceof le?[t.value]:t instanceof de?t.options:t instanceof fe?x.objectValues(t.enum):t instanceof pe?F(t._def.innerType):t instanceof ae?[void 0]:t instanceof ie?[null]:t instanceof I?[void 0,...F(t.unwrap())]:t instanceof Z?[null,...F(t.unwrap())]:t instanceof Oe||t instanceof he?F(t.unwrap()):t instanceof me?F(t._def.innerType):[],Ke=class t extends v{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return d(r,{code:u.invalid_type,expected:f.object,received:r.parsedType}),g;let n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(d(r,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let a of r){let i=F(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,..._(n)})}};ce=class extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Ue(a)||Ue(i))return g;let o=yt(a.value,i.value);return o.valid?((Be(a)||Be(i))&&r.dirty(),{status:r.value,value:o.data}):(d(n,{code:u.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ce.create=(t,e,r)=>new ce({left:t,right:e,typeName:y.ZodIntersection,..._(r)});$=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return d(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return d(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new O(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>S.mergeArray(r,i)):S.mergeArray(r,a)}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,..._(e)})};He=class t extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return d(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],a=this._def.keyType,i=this._def.valueType;for(let o in n.data)s.push({key:a._parse(new O(n,o,n.path,o)),value:i._parse(new O(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?S.mergeObjectAsync(r,s):S.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof v?new t({keyType:e,valueType:r,typeName:y.ZodRecord,..._(n)}):new t({keyType:W.create(),valueType:e,typeName:y.ZodRecord,..._(r)})}},we=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return d(n,{code:u.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new O(n,o,n.path,[l,"key"])),value:a._parse(new O(n,c,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return g;(l.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(l.value,h.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of i){let l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return g;(l.status==="dirty"||h.status==="dirty")&&r.dirty(),o.set(l.value,h.value)}return{status:r.value,value:o}}}};we.create=(t,e,r)=>new we({valueType:e,keyType:t,typeName:y.ZodMap,..._(r)});Ee=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return d(n,{code:u.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(d(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(d(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let a=this._def.valueType;function i(c){let l=new Set;for(let h of c){if(h.status==="aborted")return g;h.status==="dirty"&&r.dirty(),l.add(h.value)}return{status:r.value,value:l}}let o=[...n.data.values()].map((c,l)=>a._parse(new O(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:p.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:p.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Ee.create=(t,e)=>new Ee({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});qe=class t extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.function)return d(r,{code:u.invalid_type,expected:f.function,received:r.parsedType}),g;function n(o,c){return Ie({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_e(),z].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(o,c){return Ie({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_e(),z].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof J){let o=this;return A(async function(...c){let l=new R([]),h=await o._def.args.parseAsync(c,a).catch(T=>{throw l.addIssue(n(c,T)),l}),b=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(b,a).catch(T=>{throw l.addIssue(s(b,T)),l})})}else{let o=this;return A(function(...c){let l=o._def.args.safeParse(c,a);if(!l.success)throw new R([n(c,l.error)]);let h=Reflect.apply(i,this,l.data),b=o._def.returns.safeParse(h,a);if(!b.success)throw new R([s(h,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:$.create(e).rest(L.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(L.create()),returns:r||L.create(),typeName:y.ZodFunction,..._(n)})}},ue=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};ue.create=(t,e)=>new ue({getter:t,typeName:y.ZodLazy,..._(e)});le=class extends v{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return d(r,{received:r.data,code:u.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};le.create=(t,e)=>new le({value:t,typeName:y.ZodLiteral,..._(e)});de=class t extends v{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:x.joinValues(n),received:r.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{received:r.data,code:u.invalid_enum_value,options:n}),g}return 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})}};de.create=Yt;fe=class extends v{_parse(e){let r=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=x.objectValues(r);return d(n,{expected:x.joinValues(s),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=x.objectValues(r);return d(n,{received:n.data,code:u.invalid_enum_value,options:s}),g}return A(e.data)}get enum(){return this._def.values}};fe.create=(t,e)=>new fe({values:t,typeName:y.ZodNativeEnum,..._(e)});J=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.promise&&r.common.async===!1)return d(r,{code:u.invalid_type,expected:f.promise,received:r.parsedType}),g;let n=r.parsedType===f.promise?r.data:Promise.resolve(r.data);return A(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};J.create=(t,e)=>new J({type:t,typeName:y.ZodPromise,..._(e)});D=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{d(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(r.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?ee(c.value):r.value==="dirty"?ee(c.value):c});{if(r.value==="aborted")return g;let o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?ee(o.value):r.value==="dirty"?ee(o.value):o}}if(s.type==="refinement"){let i=o=>{let c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),i(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),i(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!G(i))return g;let o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>G(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):g);x.assertNever(s)}};D.create=(t,e,r)=>new D({schema:t,typeName:y.ZodEffects,effect:e,..._(r)});D.createWithPreprocess=(t,e,r)=>new D({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,..._(r)});I=class extends v{_parse(e){return this._getType(e)===f.undefined?A(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};I.create=(t,e)=>new I({innerType:t,typeName:y.ZodOptional,..._(e)});Z=class extends v{_parse(e){return this._getType(e)===f.null?A(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Z.create=(t,e)=>new Z({innerType:t,typeName:y.ZodNullable,..._(e)});pe=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};pe.create=(t,e)=>new pe({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});me=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ve(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new R(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new R(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};me.create=(t,e)=>new me({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});Se=class extends v{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};Se.create=t=>new Se({typeName:y.ZodNaN,..._(t)});jn=Symbol("zod_brand"),Oe=class extends v{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},De=class t extends v{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?g:a.status==="dirty"?(r.dirty(),ee(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:y.ZodPipeline})}},he=class extends v{_parse(e){let r=this._def.innerType._parse(e),n=s=>(G(s)&&(s.value=Object.freeze(s.value)),s);return ve(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};he.create=(t,e)=>new he({innerType:t,typeName:y.ZodReadonly,..._(e)});$n={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={}));Zn=(t,e={message:`Input not instance of ${t.name}`})=>Jt(r=>r instanceof t,e),Xt=W.create,Qt=te.create,zn=Se.create,Fn=re.create,er=ne.create,Ln=se.create,Vn=be.create,Un=ae.create,Bn=ie.create,Kn=Y.create,Hn=L.create,qn=P.create,Gn=ke.create,Wn=V.create,Yn=C.create,Jn=C.strictCreate,Xn=oe.create,Qn=Ke.create,es=ce.create,ts=$.create,rs=He.create,ns=we.create,ss=Ee.create,as=qe.create,is=ue.create,os=le.create,cs=de.create,us=fe.create,ls=J.create,ds=D.create,fs=I.create,ps=Z.create,ms=D.createWithPreprocess,hs=De.create,gs=()=>Xt().optional(),ys=()=>Qt().optional(),_s=()=>er().optional(),vs={string:(t=>W.create({...t,coerce:!0})),number:(t=>te.create({...t,coerce:!0})),boolean:(t=>ne.create({...t,coerce:!0})),bigint:(t=>re.create({...t,coerce:!0})),date:(t=>se.create({...t,coerce:!0}))},xs=g});var m={};Me(m,{BRAND:()=>jn,DIRTY:()=>ee,EMPTY_PATH:()=>mn,INVALID:()=>g,NEVER:()=>xs,OK:()=>A,ParseStatus:()=>S,Schema:()=>v,ZodAny:()=>Y,ZodArray:()=>V,ZodBigInt:()=>re,ZodBoolean:()=>ne,ZodBranded:()=>Oe,ZodCatch:()=>me,ZodDate:()=>se,ZodDefault:()=>pe,ZodDiscriminatedUnion:()=>Ke,ZodEffects:()=>D,ZodEnum:()=>de,ZodError:()=>R,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>qe,ZodIntersection:()=>ce,ZodIssueCode:()=>u,ZodLazy:()=>ue,ZodLiteral:()=>le,ZodMap:()=>we,ZodNaN:()=>Se,ZodNativeEnum:()=>fe,ZodNever:()=>P,ZodNull:()=>ie,ZodNullable:()=>Z,ZodNumber:()=>te,ZodObject:()=>C,ZodOptional:()=>I,ZodParsedType:()=>f,ZodPipeline:()=>De,ZodPromise:()=>J,ZodReadonly:()=>he,ZodRecord:()=>He,ZodSchema:()=>v,ZodSet:()=>Ee,ZodString:()=>W,ZodSymbol:()=>be,ZodTransformer:()=>D,ZodTuple:()=>$,ZodType:()=>v,ZodUndefined:()=>ae,ZodUnion:()=>oe,ZodUnknown:()=>L,ZodVoid:()=>ke,addIssueToContext:()=>d,any:()=>Kn,array:()=>Wn,bigint:()=>Fn,boolean:()=>er,coerce:()=>vs,custom:()=>Jt,date:()=>Ln,datetimeRegex:()=>Wt,defaultErrorMap:()=>z,discriminatedUnion:()=>Qn,effect:()=>ds,enum:()=>cs,function:()=>as,getErrorMap:()=>_e,getParsedType:()=>j,instanceof:()=>Zn,intersection:()=>es,isAborted:()=>Ue,isAsync:()=>ve,isDirty:()=>Be,isValid:()=>G,late:()=>$n,lazy:()=>is,literal:()=>os,makeIssue:()=>Ie,map:()=>ns,nan:()=>zn,nativeEnum:()=>us,never:()=>qn,null:()=>Bn,nullable:()=>ps,number:()=>Qt,object:()=>Yn,objectUtil:()=>pt,oboolean:()=>_s,onumber:()=>ys,optional:()=>fs,ostring:()=>gs,pipeline:()=>hs,preprocess:()=>ms,promise:()=>ls,quotelessJson:()=>dn,record:()=>rs,set:()=>ss,setErrorMap:()=>pn,strictObject:()=>Jn,string:()=>Xt,symbol:()=>Vn,transformer:()=>ds,tuple:()=>ts,undefined:()=>Un,union:()=>Xn,unknown:()=>Hn,util:()=>x,void:()=>Gn});var _t=k(()=>{Ve();ht();Ut();Ce();tr();Le()});var Ge=k(()=>{_t();_t()});var ar,ir=k(()=>{"use strict";Ge();ar=m.object({slug:m.string().min(1).max(64),description:m.string().max(255).optional(),match_command:m.string().min(1),priority:m.number().int().default(50),strip_ansi:m.boolean().default(!1),strip_lines_matching:m.array(m.string()).default([]),truncate_lines_at:m.number().int().positive().max(1e4).optional(),max_lines:m.number().int().positive().max(1e5).optional(),transform:m.string().max(64).optional(),on_empty:m.string().max(255).optional()})});function cr(t){return JSON.stringify(t)+We}function*ur(t){let e=0;for(;;){let r=t.indexOf(We,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function Ye(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Cs,Is,Os,Ds,ji,$i,Zi,or,We,zi,lr=k(()=>{"use strict";Ge();ir();Cs=m.object({id:m.string().min(1).max(64),op:m.literal("filter"),cmd:m.string().min(1).max(2048),plan:m.enum(["trial","smart","pro"]),installId:m.string().min(1).max(64).optional()}),Is=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),Os=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),Ds=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),ji=m.discriminatedUnion("op",[Cs,Is,Os,Ds]),$i=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),Zi=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),or=m.object({filter:ar.nullable(),cacheHit:m.boolean().optional()}),We=`
|
|
7
|
+
`,zi=64*1024});import{join as vt}from"node:path";import{existsSync as dr,statSync as Ns,unlinkSync as Ps,mkdirSync as Ms,chmodSync as js}from"node:fs";function Je(){if(process.platform==="win32")return{path:`\\\\.\\pipe\\tokmizer-${process.env.USERNAME??"tokmizer"}`,isPipe:!0};let t=typeof process.getuid=="function"?process.getuid():0,e=process.env.XDG_RUNTIME_DIR;if(e&&dr(e))return{path:vt(e,`tokmizer-${t}.sock`),isPipe:!1};let r=vt(E(),"run");try{Ms(r,{recursive:!0,mode:448}),js(r,448)}catch{}return{path:vt(r,"daemon.sock"),isPipe:!1}}async function fr(){let{path:t,isPipe:e}=Je();if(e||!dr(t))return;try{if(!Ns(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let a=r.createConnection(t),i=o=>{a.removeAllListeners();try{a.destroy()}catch{}s(o)};a.once("connect",()=>i(!0)),a.once("error",o=>{let c=o.code;i(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>i(!0),250)}))try{Ps(t)}catch{}}var Bi,pr=k(()=>{"use strict";U();Bi=5*6e4});var xr={};Me(xr,{connectDaemon:()=>Gs});import{createConnection as $s}from"node:net";import{spawn as Zs}from"node:child_process";import{existsSync as vr,openSync as mr,closeSync as zs,unlinkSync as hr,writeFileSync as gr}from"node:fs";import{dirname as Fs,join as Ls}from"node:path";import{fileURLToPath as Vs}from"node:url";async function Ks(t,e){return new Promise((r,n)=>{let s=$s(t),a=o=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(i),o){try{s.destroy()}catch{}n(o)}else r(s)},i=setTimeout(()=>a(new Error("connect timeout")),e);s.once("connect",()=>a(null)),s.once("error",o=>a(o))})}function Hs(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Vs(new URL("../bin/tkr-daemon.js",import.meta.url))}async function _r(t,e=3e3){let r=Math.ceil(e/75);for(let n=0;n<r;n++){if(vr(t))return!0;await new Promise(s=>setTimeout(s,75))}return!1}async function qs(t){let e=Hs();if(!vr(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=Je(),n=Ls(Fs(r),"daemon.spawn.lock"),s=null;try{s=mr(n,"wx"),gr(s,String(process.pid))}catch(a){if(a.code==="EEXIST"){if(await _r(r,5e3))return;try{hr(n)}catch{}s=mr(n,"wx"),gr(s,String(process.pid))}else throw a}try{if(Zs(process.execPath,[e],{detached:!0,stdio:["ignore","ignore","ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),!await _r(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(s!==null){try{zs(s)}catch{}try{hr(n)}catch{}}}}async function Gs(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Je(),r=await st(),n=null,s=0;for(;s<=yr;)try{n=await Ks(e,Us);break}catch{if(s+=1,s>yr)throw new Error(`tkr-daemon unreachable at ${e}`);await fr(),await qs(r)}if(!n)throw new Error("tkr-daemon: socket setup failed");let a=new Map,i="";n.setEncoding("utf8"),n.on("data",c=>{i+=c;let l=-1;for(let b=0;b<i.length;b++)i[b]===We&&(l=b);if(l<0)return;let h=[];for(let b of ur(i.slice(0,l+1)))h.push(b);i=i.slice(l+1);for(let b of h)if(b)try{let w=JSON.parse(b),T=a.get(w.id);if(!T)continue;clearTimeout(T.timer),a.delete(w.id),T.resolve(w)}catch{}}),n.on("close",()=>{for(let c of a.values())clearTimeout(c.timer),c.reject(new Error("daemon socket closed"));a.clear()}),n.on("error",()=>{});function o(c){return new Promise((l,h)=>{let b=setTimeout(()=>{a.delete(c.id),h(new Error(`daemon request timeout (${c.op})`))},Bs);a.set(c.id,{resolve:l,reject:h,timer:b}),n.write(cr(c))})}return{filter:async(c,l)=>{let h=await o({id:Ye(),op:"filter",cmd:c.slice(0,2048),plan:l,installId:r});if(!h.ok)return null;let b=or.safeParse(h.data);return b.success?b.data.filter:null},ping:async()=>{let c=await o({id:Ye(),op:"ping"});if(!c.ok)throw new Error(c.err);return c.data},reload:async()=>{let c=await o({id:Ye(),op:"reload",installId:r});if(!c.ok)throw new Error(c.err);return c.data},close:()=>{try{n.end()}catch{}}}}var Us,Bs,yr,br=k(()=>{"use strict";lr();pr();Q();Us=500,Bs=3e3,yr=1});function Ne(t){let e=t;for(let[r,n]of Ws)e=e.replace(r,n);return e}var Ws,xt=k(()=>{"use strict";Ws=[[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-)*(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^:/\s@]*:)[^\s]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]]});import{join as Et}from"node:path";import{appendFileSync as wt,existsSync as Pe,mkdirSync as Ys,readFileSync as bt,renameSync as kr,statSync as Js,unlinkSync as Xe}from"node:fs";function St(){return Et(E(),"spool")}function Sr(t){return Et(St(),`${t}.jsonl`)}function Ar(t){return Et(St(),`${t}.pending.jsonl`)}function Qe(t,e){try{Ys(St(),{recursive:!0,mode:448});let r=Sr(t);if(Pe(r)&&Js(r).size>=Xs)return;wt(r,JSON.stringify(e)+`
|
|
8
|
+
`,{mode:384})}catch{return}}function Qs(t){try{let e=Ar(t),r=Sr(t),n=`${r}.merging`;if(Pe(n)&&(wt(e,bt(n,"utf8"),{mode:384}),Xe(n)),Pe(e))Pe(r)&&(kr(r,n),wt(e,bt(n,"utf8"),{mode:384}),Xe(n));else{if(!Pe(r))return[];kr(r,e)}let s=[];for(let a of bt(e,"utf8").split(`
|
|
9
|
+
`))if(a.trim())try{s.push(JSON.parse(a))}catch{continue}return s.length===0?(Xe(e),[]):s}catch{return[]}}function Er(t){try{Xe(Ar(t))}catch{return}}async function et(t,e,r={}){if(kt.has(t))return"fail";kt.add(t);try{let n=Qs(t);if(n.length===0)return"empty";let s=await B();if(!s)return"fail";if(r.requirePro&&s.plan!=="pro")return Er(t),"ok";let a=r.baseUrl??process.env.TOKMIZER_BASE_URL??"https://tokmizer.com",i=await N();for(let o=0;o<n.length;o+=wr){let c=await M("POST",e,{events:n.slice(o,o+wr)},{baseUrl:a,bearer:s.jwt,signingSecret:s.signingSecret,fingerprint:i.fingerprint,installId:i.installId});if(!c.ok)return c.status===401||c.status===403?"auth":"fail"}return Er(t),"ok"}catch{return"fail"}finally{kt.delete(t)}}var Xs,wr,kt,At=k(()=>{"use strict";U();Te();Q();Re();Xs=512*1024,wr=500,kt=new Set});var Rr={};Me(Rr,{commandName:()=>tt,flushTelemetry:()=>ca,recordTelemetry:()=>oa});function Tr(t){let e=t.toLowerCase();return e.startsWith("git")||na.has(e)}function tt(t){let e=t.trim().split(/\s+/).filter(o=>o.length>0),r=0;for(;r<e.length&&ra.test(e[r]??"");)r+=1;let n=e[r];if(!n||!ea.test(n)||n.length>aa||Tr(n)||sa.test(n)||Ne(n)!==n)return"";let s=e[r+1];return s&&Tr(s)?"":(s&&ia.has(n.toLowerCase())&&ta.test(s)?`${n} ${s}`:n).slice(0,64)}async function oa(t){if(!t.telemetryOptIn)return;let e=tt(t.cmd),r=e&&Ne(e)===e?e:"other";Qe("telemetry",{cmd:r,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),optimized:t.optimized})}async function ca(t){return et("telemetry","/api/v1/telemetry",{baseUrl:t})}var ea,ta,ra,na,sa,aa,ia,Tt=k(()=>{"use strict";xt();At();ea=/^[a-z0-9][a-z0-9._-]*$/i,ta=/^[a-z][a-z-]+$/,ra=/^[A-Za-z_][A-Za-z0-9_]*=/,na=new Set(["gh","glab","gup","hub","gist"]),sa=/^(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,aa=24,ia=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 Cr={};Me(Cr,{flush:()=>la,recordEvent:()=>ua});async function ua(t){if(t.plan!=="pro")return;let e=tt(t.cmd);!e||Ne(e)!==e||Qe("learn",{cmd:e,filterId:t.filterId,rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}async function la(t){return et("learn","/api/v1/learn",{baseUrl:t,requirePro:!0})}var Ir=k(()=>{"use strict";Tt();xt();At()});Q();Te();Re();U();Re();Te();Q();import{createPublicKey as en,verify as tn}from"node:crypto";function rn(t,e){let r=ct();if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new Error("Tokmizer plugin: no valid signing public key. Set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM or rebuild plugin against a prod key.");let n=en({key:r,format:"pem"});try{let s=Buffer.from(e,"base64url");return tn(null,Buffer.from(t,"utf8"),n,s)}catch{return!1}}var nn=/^[a-z0-9][a-z0-9-]*$/;async function Pt(t){let e=await B();if(!e)throw new Error("Plugin not activated.");let r=await N(),n=await M("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 q(n),a=[];for(let i of s.bundles){if(!nn.test(i.slug))throw new Error(`invalid bundle slug ${i.slug}`);let o=[...i.fragments].sort((c,l)=>c.position-l.position);for(let c of o)if(!rn(c.body,c.hash))throw new Error(`fragment signature mismatch on ${i.slug}[${c.position}]`);a.push({slug:i.slug,version:i.version,body:o.map(c=>c.body).join(`
|
|
10
10
|
|
|
11
|
-
`)})}return a}U();import{mkdir as ut,readFile as
|
|
11
|
+
`)})}return a}U();import{mkdir as ut,readFile as sn,writeFile as lt,stat as an,readdir as Mt,rm as jt}from"node:fs/promises";var on="managed-by: tokmizer",cn=3600*1e3,un=10080*60*1e3;function ln(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:un}async function $t(t){try{let e=await an($e(t)),r=Date.now()-e.mtimeMs;return r<cn&&r<=ln()}catch{return!1}}async function Zt(t,e){await ut(je(),{recursive:!0}),await lt($e(t),e,{mode:384})}async function zt(t){let e=new Set(t),r;try{r=await Mt(je())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{await jt($e(s))}catch{}}}async function Ft(t,e){await ut(Ze(),{recursive:!0}),await lt(ze(t),e,{mode:384})}async function dt(t){let e=new Set(t),r;try{r=await Mt(Ze())}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 sn(ze(s),"utf8")).includes(on))continue;await jt(ze(s))}catch{}}}async function ft(t){try{await ut(E(),{recursive:!0}),await lt(It(),JSON.stringify({at:Date.now(),error:t}),{mode:384})}catch{}}var Lt={welcome:"Link your paid Tokmizer account.",needToken:"Tokmizer already works for free on this device. Linking is only to attach a paid plan.",getToken:"Subscribe at tokmizer.com/#pricing, then grab your key from your dashboard.",askToken:"Paste your dashboard key, then press Enter:",activating:"Linking...",activated:t=>`Linked. You are on the ${t} plan.`,failed:t=>`Activation failed: ${t}`,trialEnded:"Your trial has ended. Renew at tokmizer.com/dashboard/billing",suspended:t=>`Your token is suspended. ${t}`,revoked:"Your token has been revoked. Contact support at tokmizer.com/contact",rotated:"Token rotated. Paste your new token from tokmizer.com/dashboard/token",offline:"Network required. Tokmizer needs an internet connection.",deviceCap:"Device limit reached. Manage devices at tokmizer.com/dashboard/devices"};Te();Q();Re();import{readFile as bi,writeFile as ws,mkdir as Es,chmod as Ss}from"node:fs/promises";import{join as As}from"node:path";Ge();var bs=m.enum(["normal","compact","minimal"]),ks=m.enum(["off","light","balanced","max"]),rr=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:bs.default("compact"),reducer:ks.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})});U();var Ts="settings-cache.json",Si=rr.parse({});async function nr(t){await Es(E(),{recursive:!0});let e=As(E(),Ts);await ws(e,JSON.stringify(t,null,2),{mode:384});try{await Ss(e,384)}catch{}}async function Rs(t,e){let r=await B();if(!r)throw new Error("Not activated. Run: tkr link");let n=process.env.TOKMIZER_BASE_URL??"https://tokmizer.com",s=await N(),a=await M(t,"/api/v1/settings",e,{baseUrl:n,bearer:r.jwt,signingSecret:r.signingSecret,fingerprint:s.fingerprint,installId:s.installId,timeoutMs:8e3});if(!a.ok)throw new Error(`Settings ${t} failed: ${a.status}`);let i=await q(a);return await nr(i.settings),i}async function sr(){return Rs("GET")}Fe();var Or="-command",Dr=3;async function Rt(t,e){if(!(!e&&await $t("power")))try{let r=await Pt(t),n=[],s=[];for(let a of r)if(a.slug.endsWith(Or)){let i=a.slug.slice(0,-Or.length);await Ft(i,a.body),s.push(i)}else await Zt(a.slug,a.body),n.push(a.slug);await zt(n),await dt(s),await ft(null)}catch(r){await ft(r instanceof Error?r.message:String(r))}}async function da(t,e){let r;for(let n=0;n<e.attempts;n++)try{return await t()}catch(s){if(r=s,n===e.attempts-1)break;let a=500*Math.pow(3,n)+Math.floor(Math.random()*300);await new Promise(i=>setTimeout(i,a))}throw r}async function fa(t){let e=await N(),r=ye(),n={token:t.token,...t.email?{email:t.email}:{},pluginVersion:K,timeZone:r,...e},s=await da(()=>M("POST","/api/v1/license/activate",n,{baseUrl:t.baseUrl,bearer:t.token,fingerprint:e.fingerprint,installId:e.installId,timeoutMs:1e4}),{attempts:3});if(!s.ok)throw s.status>=500?new Error("Tokmizer servers are temporarily unreachable. Try again in a minute."):new Error(Lt.failed(`${s.status} ${await s.text()}`));let a=await q(s),i={token:t.token,jwt:a.jwt,signingSecret:a.signingSecret,plan:a.plan,status:a.status,trialEndsAt:a.trialEndsAt,subEndsAt:a.subEndsAt,jwtVersion:a.jwtVersion,installId:e.installId,fingerprint:e.fingerprint,pluginVersion:K,...t.email||a.boundEmail?{email:t.email??a.boundEmail??""}:{},timeZone:r,bonusActive:!1,lastHeartbeatOkAt:Date.now()};return await Ae(i),await Rt(t.baseUrl,!0),i}function pa(t){try{return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date)}catch{return new Date().toISOString().slice(0,10)}}async function ma(t){let e=await B();if(!e)return null;let r=await N(),n=e.timeZone??ye(),s={ts:Date.now(),localDate:pa(n),timeZone:n},a;try{a=await M("POST","/api/v1/license/heartbeat",s,{baseUrl:t,bearer:e.jwt,signingSecret:e.signingSecret,fingerprint:r.fingerprint,installId:r.installId,timeoutMs:5e3})}catch{return e}if(a.status===401){let w=(e.heartbeatAuthFails??0)+1,T={...e,heartbeatAuthFails:w};if(w>=Dr&&e.email&&(T.relinkRequired=!0),await Ae(T),w>=Dr&&!e.email)try{return await ha(t)}catch{return null}return null}if(a.status===423||a.status===426||a.status===451){await Ot();try{await dt([])}catch{}return null}if(!a.ok)return e;let i;try{i=await q(a)}catch{return e}let o=i.settingsRevision??0,c=e.lastSettingsRevision??0,l=o>c,h=i.plan!==e.plan,b={...e,jwt:i.jwt,plan:i.plan,status:i.status,trialEndsAt:i.trialEndsAt,subEndsAt:i.subEndsAt,jwtVersion:i.jwtVersion,lastSettingsRevision:o,lastHeartbeatOkAt:Date.now(),heartbeatAuthFails:0,relinkRequired:!1,timeZone:n,bonusActive:i.bonusActive??!1,...i.bonusResetAt!==void 0?{bonusResetAt:i.bonusResetAt}:{},...i.latestPluginVersion?{latestPluginVersion:i.latestPluginVersion}:{},...Array.isArray(i.allowedFilters)?{allowedFilters:i.allowedFilters}:{}};if(await Ae(b),l)try{await sr()}catch{}if(l||h)try{let{connectDaemon:w}=await Promise.resolve().then(()=>(br(),xr)),T=await w();try{await T.reload()}finally{T.close()}}catch{}await Rt(t,l||h);try{let{flushTelemetry:w}=await Promise.resolve().then(()=>(Tt(),Rr)),{flush:T}=await Promise.resolve().then(()=>(Ir(),Cr));await w(t),await T(t)}catch{}return b}var So=5*6e4;async function ha(t){let e=await N(),r=ye(),n={pluginVersion:K,timeZone:r,...e},s=await M("POST","/api/v1/license/enroll",n,{baseUrl:t,fingerprint:e.fingerprint,installId:e.installId,timeoutMs:4e3});if(!s.ok)throw new Error(`enroll failed ${s.status}`);let a=await q(s),i={token:a.token,jwt:a.jwt,signingSecret:a.signingSecret,plan:a.plan,status:a.status,trialEndsAt:a.trialEndsAt,subEndsAt:a.subEndsAt,jwtVersion:a.jwtVersion,installId:e.installId,fingerprint:e.fingerprint,pluginVersion:K,email:"",timeZone:r,bonusActive:!1,lastHeartbeatOkAt:Date.now()};return await Ae(i),await Rt(t,!0),i}Q();Fe();export{K as PLUGIN_VERSION,fa as activate,N as buildFingerprint,ma as heartbeat};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokmizer/plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "Tokmizer reduces token consumption for AI coding tools (Claude Code, Codex, Cursor, Aider, Gemini CLI, Cline, Windsurf, Copilot). Cross-OS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|