@vee_stack/cli 6.3.2 → 6.3.3

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.
Files changed (2) hide show
  1. package/dist/index.js +88 -88
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,167 +1,167 @@
1
1
  #!/usr/bin/env node
2
- import {createRequire}from'module';import h from'chalk';import*as ne from'fs';import {existsSync,readFileSync,writeFileSync,statSync}from'fs';import*as We from'path';import {join,resolve}from'path';import {fileURLToPath}from'url';import {Command}from'commander';import {execSync}from'child_process';import*as ce from'crypto';import ce__default from'crypto';import Jo from'ora';import Go from'cli-table3';import {glob}from'glob';import Ko from'cli-progress';import*as ct from'os';import {homedir}from'os';import*as j from'fs/promises';import ur from'prompts';import ai from'readline';import {gzipSync}from'zlib';import mi from'open';import Qi from'omelette';createRequire(import.meta.url);
3
- var jr=Object.defineProperty;var Lr=(t,e)=>{for(var n in e)jr(t,n,{get:e[n],enumerable:true});};var $r=[/^--token[=\s]/i,/^-t[=\s]/i,/^--api-key[=\s]/i,/^--apikey[=\s]/i,/^--key[=\s]/i,/^--auth[=\s]/i,/^--bearer[=\s]/i,/token[=:]\s*[a-zA-Z0-9_-]{10,}/i,/api[_-]?key[=:]\s*[a-zA-Z0-9_-]{10,}/i],qe=/vs_[a-zA-Z0-9_-]{20,}/i;function Pn(){let t=process.argv.slice(2);for(let e of t){for(let n of $r)n.test(e)&&(console.error(h.red(`
2
+ import {createRequire}from'module';import h from'chalk';import*as te from'fs';import {existsSync,readFileSync,writeFileSync,statSync}from'fs';import*as Ke from'path';import {join,resolve}from'path';import {fileURLToPath}from'url';import {Command}from'commander';import {execSync}from'child_process';import*as ae from'crypto';import ae__default from'crypto';import Go from'ora';import Ko from'cli-table3';import {glob}from'glob';import Wo from'cli-progress';import*as at from'os';import {homedir}from'os';import*as j from'fs/promises';import dr from'prompts';import ci from'readline';import {gzipSync}from'zlib';import hi from'open';import ta from'omelette';createRequire(import.meta.url);
3
+ var Lr=Object.defineProperty;var $r=(t,e)=>{for(var n in e)Lr(t,n,{get:e[n],enumerable:true});};var Vr=[/^--token[=\s]/i,/^-t[=\s]/i,/^--api-key[=\s]/i,/^--apikey[=\s]/i,/^--key[=\s]/i,/^--auth[=\s]/i,/^--bearer[=\s]/i,/token[=:]\s*[a-zA-Z0-9_-]{10,}/i,/api[_-]?key[=:]\s*[a-zA-Z0-9_-]{10,}/i],We=/vs_[a-zA-Z0-9_-]{20,}/i;function Pn(){let t=process.argv.slice(2);for(let e of t){for(let n of Vr)n.test(e)&&(console.error(h.red(`
4
4
  \u274C Security Error: Token detected in command line arguments`)),console.error(h.yellow(`
5
5
  Passing tokens via CLI arguments is not allowed.`)),console.error(h.yellow("This prevents tokens from being saved in shell history (~/.bash_history, ~/.zsh_history)")),console.error(h.gray(`
6
6
  Instead, use:`)),console.error(h.cyan(" veestack login")),console.error(h.gray(`
7
7
  Or set via environment variable:`)),console.error(h.cyan(" export VEESTACK_API_KEY=your_key")),console.error(h.gray(`
8
8
  Your token has been detected and blocked for your security.
9
- `)),process.exit(1));qe.test(e)&&(console.error(h.red(`
9
+ `)),process.exit(1));We.test(e)&&(console.error(h.red(`
10
10
  \u274C Security Error: VeeStack token detected in command line`)),console.error(h.yellow(`
11
11
  Tokens should never be passed as command arguments.`)),console.error(h.gray(`
12
- Use login instead:`)),console.error(h.cyan(" veestack login")),process.exit(1));}}function On(){for(let t=0;t<process.argv.length;t++){let e=process.argv[t];qe.test(e)&&(process.argv[t]="[REDACTED_TOKEN]"),/authorization[:\s]/i.test(e)&&(process.argv[t]="[REDACTED_AUTH_HEADER]");}}function Dn(){let t=console.error,e=console.log,n=console.warn,r=s=>s.map(o=>typeof o=="string"?o.replace(qe,"[REDACTED]").replace(/Bearer\s+[a-zA-Z0-9_-]+/gi,"Bearer [REDACTED]"):o);console.log=(...s)=>e(...r(s)),console.error=(...s)=>t(...r(s)),console.warn=(...s)=>n(...r(s));}function jn(){process.on("uncaughtException",t=>{console.error(`
13
- \u274C Fatal Error occurred`);let e=t.message||"Unknown error";if(e=e.replace(qe,"[REDACTED]").replace(/Bearer\s+[a-zA-Z0-9_-]+/gi,"Bearer [REDACTED]").replace(/Authorization[:\s][^\s]*/gi,"Authorization: [REDACTED]"),console.error(`Error: ${e}`),t.stack){let n=t.stack.split(`
14
- `).map(r=>r.replace(qe,"[REDACTED]").replace(/Bearer\s+[a-zA-Z0-9_-]+/gi,"Bearer [REDACTED]")).join(`
12
+ Use login instead:`)),console.error(h.cyan(" veestack login")),process.exit(1));}}function On(){for(let t=0;t<process.argv.length;t++){let e=process.argv[t];We.test(e)&&(process.argv[t]="[REDACTED_TOKEN]"),/authorization[:\s]/i.test(e)&&(process.argv[t]="[REDACTED_AUTH_HEADER]");}}function Dn(){let t=console.error,e=console.log,n=console.warn,r=s=>s.map(o=>typeof o=="string"?o.replace(We,"[REDACTED]").replace(/Bearer\s+[a-zA-Z0-9_-]+/gi,"Bearer [REDACTED]"):o);console.log=(...s)=>e(...r(s)),console.error=(...s)=>t(...r(s)),console.warn=(...s)=>n(...r(s));}function jn(){process.on("uncaughtException",t=>{console.error(`
13
+ \u274C Fatal Error occurred`);let e=t.message||"Unknown error";if(e=e.replace(We,"[REDACTED]").replace(/Bearer\s+[a-zA-Z0-9_-]+/gi,"Bearer [REDACTED]").replace(/Authorization[:\s][^\s]*/gi,"Authorization: [REDACTED]"),console.error(`Error: ${e}`),t.stack){let n=t.stack.split(`
14
+ `).map(r=>r.replace(We,"[REDACTED]").replace(/Bearer\s+[a-zA-Z0-9_-]+/gi,"Bearer [REDACTED]")).join(`
15
15
  `);process.env.DEBUG||process.env.VEESTACK_DEBUG?console.error(`
16
16
  Stack trace:`,n):console.error(`
17
17
  Run with DEBUG=veestack for full stack trace (sanitized)`);}process.exit(1);}),process.on("unhandledRejection",t=>{let e=t instanceof Error?t:new Error(String(t));console.error(`
18
- \u274C Unhandled Promise Rejection`);let n=e.message||"Unknown error";n=n.replace(qe,"[REDACTED]").replace(/Bearer\s+[a-zA-Z0-9_-]+/gi,"Bearer [REDACTED]"),console.error(`Error: ${n}`),process.exit(1);});}var Ye=["veestack-tools","@vee_stack/cli"],Mr=["veestack","veestack-cli","veestacktool","veestack-tool","vee-stack","veestack-cli-tool","veestack-scanner","veestack-analyzer"],Ur=[/veestak/i,/veestac/i,/veestackk/i,/veestackh/i,/vvestack/i,/veee/i,/veestack-cli-hack/i,/veestack-free/i,/veestack-pro-free/i];function Ln(){try{let t=fileURLToPath(import.meta.url),n=We.dirname(t);for(let r=0;r<5;r++){let s=We.join(n,"package.json");if(ne.existsSync(s))return JSON.parse(ne.readFileSync(s,"utf-8")).name||"unknown";let o=We.dirname(n);if(o===n)break;n=o;}}catch{}return "unknown"}function Fr(){let t=Ln(),e=[];if(Ye.includes(t))return {isOfficial:true,warnings:[]};if(Mr.includes(t))return e.push(`\u26A0\uFE0F WARNING: You are using "${t}" which is NOT the official VeeStack CLI.`),e.push(`The official package is: ${h.cyan(Ye[0])}`),e.push("Unofficial packages may contain malware or steal your data."),{isOfficial:false,warnings:e};for(let n of Ur)if(n.test(t))return e.push(`\u26A0\uFE0F WARNING: Package name "${t}" looks suspicious.`),e.push("This might be a typosquatting attack."),e.push(`The official package is: ${h.cyan(Ye[0])}`),{isOfficial:false,warnings:e};return e.push(`\u26A0\uFE0F WARNING: Unofficial package "${t}" detected.`),e.push(`The official package is: ${h.cyan(Ye[0])}`),{isOfficial:false,warnings:e}}function $n(){let{isOfficial:t,warnings:e}=Fr();if(!t){console.log(h.red(`
18
+ \u274C Unhandled Promise Rejection`);let n=e.message||"Unknown error";n=n.replace(We,"[REDACTED]").replace(/Bearer\s+[a-zA-Z0-9_-]+/gi,"Bearer [REDACTED]"),console.error(`Error: ${n}`),process.exit(1);});}var qe=["veestack-tools","@vee_stack/cli"],Ur=["veestack","veestack-cli","veestacktool","veestack-tool","vee-stack","veestack-cli-tool","veestack-scanner","veestack-analyzer"],Fr=[/veestak/i,/veestac/i,/veestackk/i,/veestackh/i,/vvestack/i,/veee/i,/veestack-cli-hack/i,/veestack-free/i,/veestack-pro-free/i];function Ln(){try{let t=fileURLToPath(import.meta.url),n=Ke.dirname(t);for(let r=0;r<5;r++){let s=Ke.join(n,"package.json");if(te.existsSync(s))return JSON.parse(te.readFileSync(s,"utf-8")).name||"unknown";let o=Ke.dirname(n);if(o===n)break;n=o;}}catch{}return "unknown"}function Br(){let t=Ln(),e=[];if(qe.includes(t))return {isOfficial:true,warnings:[]};if(Ur.includes(t))return e.push(`\u26A0\uFE0F WARNING: You are using "${t}" which is NOT the official VeeStack CLI.`),e.push(`The official package is: ${h.cyan(qe[0])}`),e.push("Unofficial packages may contain malware or steal your data."),{isOfficial:false,warnings:e};for(let n of Fr)if(n.test(t))return e.push(`\u26A0\uFE0F WARNING: Package name "${t}" looks suspicious.`),e.push("This might be a typosquatting attack."),e.push(`The official package is: ${h.cyan(qe[0])}`),{isOfficial:false,warnings:e};return e.push(`\u26A0\uFE0F WARNING: Unofficial package "${t}" detected.`),e.push(`The official package is: ${h.cyan(qe[0])}`),{isOfficial:false,warnings:e}}function $n(){let{isOfficial:t,warnings:e}=Br();if(!t){console.log(h.red(`
19
19
  `+"\u2550".repeat(60))),console.log(h.red.bold(`\u{1F6A8} SECURITY WARNING
20
20
  `));for(let n of e)console.log(h.yellow(n));console.log(h.gray(`
21
21
  To install the official CLI:`)),console.log(h.cyan(" npm install -g veestack-tools")),console.log(h.red("\u2550".repeat(60)+`
22
- `)),process.exit(1);}process.env.VEESTACK_DEBUG==="true"&&console.log(h.gray(`\u2713 Official package verified: ${Ye.join(" or ")}`));}function Dt(){let t=Ln(),e=Ye.includes(t);return {packageName:t,isOfficial:e,homepage:"https://www.veestack.com",repository:"https://github.com/Mohmed-ElZehiry/VeeStack"}}var sn=(t=>typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>e[n]}):t)(function(t){throw Error('Dynamic require of "'+t+'" is not supported')}),Br=typeof process<"u"&&process.versions?.node,zr="6.3.1",Hr={snapshot:"6",engine_target:"6.3.1",audit:"1",session_payload:"1",rules:"v1",analysis:"v1",api:"v1",min_node:"18.0.0"},on=null;if(Br)try{let t=function(){let w=g,b=0;for(;w!==i(w)&&b<10;){let x=a(w,"package.json");try{if(o(x)){let C=JSON.parse(s(x,"utf-8"));if(C.name==="vee_stack")return C}}catch{}w=i(w),b++;}return null};Zr=t;let e=sn("fs"),n=sn("path"),r=sn("url"),{readFileSync:s,existsSync:o}=e,{join:a,dirname:i}=n,{fileURLToPath:c}=r,l=c(import.meta.url),g=i(l);on=t();}catch{console.warn("Failed to load package.json dynamically, using defaults");}var Zr,ke=on?.versions||Hr,z=on?.version||zr,H=z,an=`vs_cli_v${z}`,Xe=ke.snapshot,Qe=ke.engine_target,jt=ke.audit;ke.session_payload;ke.rules;ke.analysis;ke.api;ke.min_node;var d={};Lr(d,{BRAND:()=>ws,DIRTY:()=>Te,EMPTY_PATH:()=>Qr,INVALID:()=>y,NEVER:()=>oo,OK:()=>M,ParseStatus:()=>V,Schema:()=>_,ZodAny:()=>Se,ZodArray:()=>me,ZodBigInt:()=>Re,ZodBoolean:()=>Ce,ZodBranded:()=>ht,ZodCatch:()=>Ue,ZodDate:()=>Ie,ZodDefault:()=>Me,ZodDiscriminatedUnion:()=>Vt,ZodEffects:()=>te,ZodEnum:()=>$e,ZodError:()=>K,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>Ut,ZodIntersection:()=>De,ZodIssueCode:()=>u,ZodLazy:()=>je,ZodLiteral:()=>Le,ZodMap:()=>ot,ZodNaN:()=>at,ZodNativeEnum:()=>Ve,ZodNever:()=>re,ZodNull:()=>Pe,ZodNullable:()=>ae,ZodNumber:()=>be,ZodObject:()=>W,ZodOptional:()=>Q,ZodParsedType:()=>p,ZodPipeline:()=>yt,ZodPromise:()=>Ee,ZodReadonly:()=>Fe,ZodRecord:()=>Mt,ZodSchema:()=>_,ZodSet:()=>it,ZodString:()=>we,ZodSymbol:()=>rt,ZodTransformer:()=>te,ZodTuple:()=>ie,ZodType:()=>_,ZodUndefined:()=>Ne,ZodUnion:()=>Oe,ZodUnknown:()=>ge,ZodVoid:()=>st,addIssueToContext:()=>f,any:()=>Is,array:()=>Ds,bigint:()=>As,boolean:()=>Kn,coerce:()=>so,custom:()=>Zn,date:()=>Ts,datetimeRegex:()=>zn,defaultErrorMap:()=>fe,discriminatedUnion:()=>Vs,effect:()=>qs,enum:()=>Gs,function:()=>Hs,getErrorMap:()=>et,getParsedType:()=>oe,instanceof:()=>Es,intersection:()=>Ms,isAborted:()=>Lt,isAsync:()=>tt,isDirty:()=>$t,isValid:()=>_e,late:()=>Ss,lazy:()=>Zs,literal:()=>Js,makeIssue:()=>mt,map:()=>Bs,nan:()=>xs,nativeEnum:()=>Ks,never:()=>Ps,null:()=>Cs,nullable:()=>Xs,number:()=>Gn,object:()=>js,objectUtil:()=>un,oboolean:()=>ro,onumber:()=>no,optional:()=>Ys,ostring:()=>to,pipeline:()=>eo,preprocess:()=>Qs,promise:()=>Ws,quotelessJson:()=>qr,record:()=>Fs,set:()=>zs,setErrorMap:()=>Xr,strictObject:()=>Ls,string:()=>Jn,symbol:()=>bs,transformer:()=>qs,tuple:()=>Us,undefined:()=>Rs,union:()=>$s,unknown:()=>Ns,util:()=>S,void:()=>Os});var S;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let o={};for(let a of s)o[a]=a;return o},t.getValidEnumValues=s=>{let o=t.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),a={};for(let i of o)a[i]=s[i];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let o=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&o.push(a);return o},t.find=(s,o)=>{for(let a of s)if(o(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,o=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o;})(S||(S={}));var un;(function(t){t.mergeShapes=(e,n)=>({...e,...n});})(un||(un={}));var p=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),oe=t=>{switch(typeof t){case "undefined":return p.undefined;case "string":return p.string;case "number":return Number.isNaN(t)?p.nan:p.number;case "boolean":return p.boolean;case "function":return p.function;case "bigint":return p.bigint;case "symbol":return p.symbol;case "object":return Array.isArray(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}};var u=S.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),qr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),K=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r];},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r];};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e;}format(e){let n=e||function(o){return o.message},r={_errors:[]},s=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else {let i=r,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(n(a))):i[l]=i[l]||{_errors:[]},i=i[l],c++;}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let o=s.path[0];n[o]=n[o]||[],n[o].push(e(s));}else r.push(e(s));return {formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};K.create=t=>new K(t);var Yr=(t,e)=>{let n;switch(t.code){case u.invalid_type:t.received===p.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:n=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case u.invalid_union:n="Invalid input";break;case u.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case u.invalid_enum_value:n=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:n="Invalid function arguments";break;case u.invalid_return_type:n="Invalid function return type";break;case u.invalid_date:n="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:S.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case u.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case u.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case u.custom:n="Invalid input";break;case u.invalid_intersection_types:n="Intersection results could not be merged";break;case u.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:n="Number must be finite";break;default:n=e.defaultError,S.assertNever(t);}return {message:n}},fe=Yr;var Vn=fe;function Xr(t){Vn=t;}function et(){return Vn}var mt=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,o=[...n,...s.path||[]],a={...s,path:o};if(s.message!==void 0)return {...s,path:o,message:s.message};let i="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)i=l(a,{data:e,defaultError:i}).message;return {...s,path:o,message:i}},Qr=[];function f(t,e){let n=et(),r=mt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===fe?void 0:fe].filter(s=>!!s)});t.common.issues.push(r);}var V=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),r.push(s.value);}return {status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let o=await s.key,a=await s.value;r.push({key:o,value:a});}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:o,value:a}=s;if(o.status==="aborted"||a.status==="aborted")return y;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[o.value]=a.value);}return {status:e.value,value:r}}},y=Object.freeze({status:"aborted"}),Te=t=>({status:"dirty",value:t}),M=t=>({status:"valid",value:t}),Lt=t=>t.status==="aborted",$t=t=>t.status==="dirty",_e=t=>t.status==="valid",tt=t=>typeof Promise<"u"&&t instanceof Promise;var m;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(m||(m={}));var ee=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,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}},Mn=(t,e)=>{if(_e(e))return {success:true,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let n=new K(t.common.issues);return this._error=n,this._error}}};function k(t){if(!t)return {};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??r??i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:c??n??i.defaultError}},description:s}}var _=class{get description(){return this._def.description}_getType(e){return oe(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new V,ctx:{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(tt(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??false,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oe(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Mn(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oe(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return _e(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),n.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:n}).then(r=>_e(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:true},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:oe(e)},s=this._parse({data:e,path:r.path,parent:r}),o=await(tt(s)?s:Promise.resolve(s));return Mn(r,o)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,o)=>{let a=e(s),i=()=>o.addIssue({code:u.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?true:(i(),false)):a?true:(i(),false)})}refinement(e,n){return this._refinement((r,s)=>e(r)?true:(s.addIssue(typeof n=="function"?n(r,s):n),false))}_refinement(e){return new te({schema:this,typeName:v.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:n=>this["~validate"](n)};}optional(){return Q.create(this,this._def)}nullable(){return ae.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return me.create(this)}promise(){return Ee.create(this,this._def)}or(e){return Oe.create([this,e],this._def)}and(e){return De.create(this,e,this._def)}transform(e){return new te({...k(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Me({...k(this._def),innerType:this,defaultValue:n,typeName:v.ZodDefault})}brand(){return new ht({typeName:v.ZodBranded,type:this,...k(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Ue({...k(this._def),innerType:this,catchValue:n,typeName:v.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return yt.create(this,e)}readonly(){return Fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},es=/^c[^\s-]{8,}$/i,ts=/^[0-9a-z]+$/,ns=/^[0-9A-HJKMNP-TV-Z]{26}$/i,rs=/^[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,ss=/^[a-z0-9_-]{21}$/i,os=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,is=/^[-+]?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)?)??$/,as=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",dn,ls=/^(?:(?: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])$/,us=/^(?:(?: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])$/,ds=/^(([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]))$/,fs=/^(([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])$/,ps=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,gs=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Fn="((\\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])))",ms=new RegExp(`^${Fn}$`);function Bn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function hs(t){return new RegExp(`^${Bn(t)}$`)}function zn(t){let e=`${Fn}T${Bn(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function ys(t,e){return !!((e==="v4"||!e)&&ls.test(t)||(e==="v6"||!e)&&ds.test(t))}function vs(t,e){if(!os.test(t))return false;try{let[n]=t.split(".");if(!n)return !1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return !(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return false}}function ks(t,e){return !!((e==="v4"||!e)&&us.test(t)||(e==="v6"||!e)&&fs.test(t))}var we=class t extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let o=this._getOrReturnCtx(e);return f(o,{code:u.invalid_type,expected:p.string,received:o.parsedType}),y}let r=new V,s;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_small,minimum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),r.dirty());else if(o.kind==="max")e.data.length>o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,maximum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),r.dirty());else if(o.kind==="length"){let a=e.data.length>o.value,i=e.data.length<o.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?f(s,{code:u.too_big,maximum:o.value,type:"string",inclusive:true,exact:true,message:o.message}):i&&f(s,{code:u.too_small,minimum:o.value,type:"string",inclusive:true,exact:true,message:o.message}),r.dirty());}else if(o.kind==="email")as.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")dn||(dn=new RegExp(cs,"u")),dn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")rs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")ss.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")es.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")ts.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")ns.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data);}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:u.invalid_string,message:o.message}),r.dirty();}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:u.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?zn(o).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?ms.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?hs(o).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?is.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?ys(e.data,o.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?vs(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?ks(e.data,o.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?ps.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?gs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:u.invalid_string,message:o.message}),r.dirty()):S.assertNever(o);return {status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:u.invalid_string,...m.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...m.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...m.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...m.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...m.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...m.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...m.errToObj(n)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return !!this._def.checks.find(e=>e.kind==="email")}get isURL(){return !!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return !!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return !!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return !!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return !!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return !!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return !!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};we.create=t=>new we({checks:[],typeName:v.ZodString,coerce:t?.coerce??false,...k(t)});function _s(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,o=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}var be=class t extends _{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)!==p.number){let o=this._getOrReturnCtx(e);return f(o,{code:u.invalid_type,expected:p.number,received:o.parsedType}),y}let r,s=new V;for(let o of this._def.checks)o.kind==="int"?S.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),s.dirty()):o.kind==="multipleOf"?_s(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_finite,message:o.message}),s.dirty()):S.assertNever(o);return {status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,true,m.toString(n))}gt(e,n){return this.setLimit("min",e,false,m.toString(n))}lte(e,n){return this.setLimit("max",e,true,m.toString(n))}lt(e,n){return this.setLimit("max",e,false,m.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:m.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:m.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return true;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);}return Number.isFinite(n)&&Number.isFinite(e)}};be.create=t=>new be({checks:[],typeName:v.ZodNumber,coerce:t?.coerce||false,...k(t)});var Re=class t extends _{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)!==p.bigint)return this._getInvalidInput(e);let r,s=new V;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):S.assertNever(o);return {status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.bigint,received:n.parsedType}),y}gte(e,n){return this.setLimit("min",e,true,m.toString(n))}gt(e,n){return this.setLimit("min",e,false,m.toString(n))}lte(e,n){return this.setLimit("max",e,true,m.toString(n))}lt(e,n){return this.setLimit("max",e,false,m.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:m.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:m.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Re.create=t=>new Re({checks:[],typeName:v.ZodBigInt,coerce:t?.coerce??false,...k(t)});var Ce=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.boolean,received:r.parsedType}),y}return M(e.data)}};Ce.create=t=>new Ce({typeName:v.ZodBoolean,coerce:t?.coerce||false,...k(t)});var Ie=class t extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let o=this._getOrReturnCtx(e);return f(o,{code:u.invalid_type,expected:p.date,received:o.parsedType}),y}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return f(o,{code:u.invalid_date}),y}let r=new V,s;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_small,message:o.message,inclusive:true,exact:false,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,message:o.message,inclusive:true,exact:false,maximum:o.value,type:"date"}),r.dirty()):S.assertNever(o);return {status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Ie.create=t=>new Ie({checks:[],coerce:t?.coerce||false,typeName:v.ZodDate,...k(t)});var rt=class extends _{_parse(e){if(this._getType(e)!==p.symbol){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.symbol,received:r.parsedType}),y}return M(e.data)}};rt.create=t=>new rt({typeName:v.ZodSymbol,...k(t)});var Ne=class extends _{_parse(e){if(this._getType(e)!==p.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.undefined,received:r.parsedType}),y}return M(e.data)}};Ne.create=t=>new Ne({typeName:v.ZodUndefined,...k(t)});var Pe=class extends _{_parse(e){if(this._getType(e)!==p.null){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.null,received:r.parsedType}),y}return M(e.data)}};Pe.create=t=>new Pe({typeName:v.ZodNull,...k(t)});var Se=class extends _{constructor(){super(...arguments),this._any=true;}_parse(e){return M(e.data)}};Se.create=t=>new Se({typeName:v.ZodAny,...k(t)});var ge=class extends _{constructor(){super(...arguments),this._unknown=true;}_parse(e){return M(e.data)}};ge.create=t=>new ge({typeName:v.ZodUnknown,...k(t)});var re=class extends _{_parse(e){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.never,received:n.parsedType}),y}};re.create=t=>new re({typeName:v.ZodNever,...k(t)});var st=class extends _{_parse(e){if(this._getType(e)!==p.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.void,received:r.parsedType}),y}return M(e.data)}};st.create=t=>new st({typeName:v.ZodVoid,...k(t)});var me=class t extends _{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==p.array)return f(n,{code:u.invalid_type,expected:p.array,received:n.parsedType}),y;if(s.exactLength!==null){let a=n.data.length>s.exactLength.value,i=n.data.length<s.exactLength.value;(a||i)&&(f(n,{code:a?u.too_big:u.too_small,minimum:i?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:s.exactLength.message}),r.dirty());}if(s.minLength!==null&&n.data.length<s.minLength.value&&(f(n,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:true,exact:false,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(f(n,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:true,exact:false,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,i)=>s.type._parseAsync(new ee(n,a,n.path,i)))).then(a=>V.mergeArray(r,a));let o=[...n.data].map((a,i)=>s.type._parseSync(new ee(n,a,n.path,i)));return V.mergeArray(r,o)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:m.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:m.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:m.toString(n)}})}nonempty(e){return this.min(1,e)}};me.create=(t,e)=>new me({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...k(e)});function nt(t){if(t instanceof W){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Q.create(nt(r));}return new W({...t._def,shape:()=>e})}else return t instanceof me?new me({...t._def,type:nt(t.element)}):t instanceof Q?Q.create(nt(t.unwrap())):t instanceof ae?ae.create(nt(t.unwrap())):t instanceof ie?ie.create(t.items.map(e=>nt(e))):t}var W=class t extends _{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(),n=S.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==p.object){let l=this._getOrReturnCtx(e);return f(l,{code:u.invalid_type,expected:p.object,received:l.parsedType}),y}let{status:r,ctx:s}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof re&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||i.push(l);let c=[];for(let l of a){let g=o[l],w=s.data[l];c.push({key:{status:"valid",value:l},value:g._parse(new ee(s,w,s.path,l)),alwaysSet:l in s.data});}if(this._def.catchall instanceof re){let l=this._def.unknownKeys;if(l==="passthrough")for(let g of i)c.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(l==="strict")i.length>0&&(f(s,{code:u.unrecognized_keys,keys:i}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let l=this._def.catchall;for(let g of i){let w=s.data[g];c.push({key:{status:"valid",value:g},value:l._parse(new ee(s,w,s.path,g)),alwaysSet:g in s.data});}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let g of c){let w=await g.key,b=await g.value;l.push({key:w,value:b,alwaysSet:g.alwaysSet});}return l}).then(l=>V.mergeObjectSync(r,l)):V.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:m.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of S.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of S.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return nt(this)}partial(e){let n={};for(let r of S.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional();}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of S.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else {let o=this.shape[r];for(;o instanceof Q;)o=o._def.innerType;n[r]=o;}return new t({...this._def,shape:()=>n})}keyof(){return Hn(S.objectKeys(this.shape))}};W.create=(t,e)=>new W({shape:()=>t,unknownKeys:"strip",catchall:re.create(),typeName:v.ZodObject,...k(e)});W.strictCreate=(t,e)=>new W({shape:()=>t,unknownKeys:"strict",catchall:re.create(),typeName:v.ZodObject,...k(e)});W.lazycreate=(t,e)=>new W({shape:t,unknownKeys:"strip",catchall:re.create(),typeName:v.ZodObject,...k(e)});var Oe=class extends _{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(i=>new K(i.ctx.common.issues));return f(n,{code:u.invalid_union,unionErrors:a}),y}if(n.common.async)return Promise.all(r.map(async o=>{let a={...n,common:{...n.common,issues:[]},parent:null};return {result:await o._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let o,a=[];for(let c of r){let l={...n,common:{...n.common,issues:[]},parent:null},g=c._parseSync({data:n.data,path:n.path,parent:l});if(g.status==="valid")return g;g.status==="dirty"&&!o&&(o={result:g,ctx:l}),l.common.issues.length&&a.push(l.common.issues);}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(c=>new K(c));return f(n,{code:u.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}};Oe.create=(t,e)=>new Oe({options:t,typeName:v.ZodUnion,...k(e)});var pe=t=>t instanceof je?pe(t.schema):t instanceof te?pe(t.innerType()):t instanceof Le?[t.value]:t instanceof $e?t.options:t instanceof Ve?S.objectValues(t.enum):t instanceof Me?pe(t._def.innerType):t instanceof Ne?[void 0]:t instanceof Pe?[null]:t instanceof Q?[void 0,...pe(t.unwrap())]:t instanceof ae?[null,...pe(t.unwrap())]:t instanceof ht||t instanceof Fe?pe(t.unwrap()):t instanceof Ue?pe(t._def.innerType):[],Vt=class t extends _{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return f(n,{code:u.invalid_type,expected:p.object,received:n.parsedType}),y;let r=this.discriminator,s=n.data[r],o=this.optionsMap.get(s);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let o of n){let a=pe(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of a){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,o);}}return new t({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...k(r)})}};function fn(t,e){let n=oe(t),r=oe(e);if(t===e)return {valid:true,data:t};if(n===p.object&&r===p.object){let s=S.objectKeys(e),o=S.objectKeys(t).filter(i=>s.indexOf(i)!==-1),a={...t,...e};for(let i of o){let c=fn(t[i],e[i]);if(!c.valid)return {valid:false};a[i]=c.data;}return {valid:true,data:a}}else if(n===p.array&&r===p.array){if(t.length!==e.length)return {valid:false};let s=[];for(let o=0;o<t.length;o++){let a=t[o],i=e[o],c=fn(a,i);if(!c.valid)return {valid:false};s.push(c.data);}return {valid:true,data:s}}else return n===p.date&&r===p.date&&+t==+e?{valid:true,data:t}:{valid:false}}var De=class extends _{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(o,a)=>{if(Lt(o)||Lt(a))return y;let i=fn(o.value,a.value);return i.valid?(($t(o)||$t(a))&&n.dirty(),{status:n.value,value:i.data}):(f(r,{code:u.invalid_intersection_types}),y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,a])=>s(o,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};De.create=(t,e,n)=>new De({left:t,right:e,typeName:v.ZodIntersection,...k(n)});var ie=class t extends _{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.array)return f(r,{code:u.invalid_type,expected:p.array,received:r.parsedType}),y;if(r.data.length<this._def.items.length)return f(r,{code:u.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),y;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:u.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),n.dirty());let o=[...r.data].map((a,i)=>{let c=this._def.items[i]||this._def.rest;return c?c._parse(new ee(r,a,r.path,i)):null}).filter(a=>!!a);return r.common.async?Promise.all(o).then(a=>V.mergeArray(n,a)):V.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};ie.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ie({items:t,typeName:v.ZodTuple,rest:null,...k(e)})};var Mt=class t extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return f(r,{code:u.invalid_type,expected:p.object,received:r.parsedType}),y;let s=[],o=this._def.keyType,a=this._def.valueType;for(let i in r.data)s.push({key:o._parse(new ee(r,i,r.path,i)),value:a._parse(new ee(r,r.data[i],r.path,i)),alwaysSet:i in r.data});return r.common.async?V.mergeObjectAsync(n,s):V.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof _?new t({keyType:e,valueType:n,typeName:v.ZodRecord,...k(r)}):new t({keyType:we.create(),valueType:e,typeName:v.ZodRecord,...k(n)})}},ot=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.map)return f(r,{code:u.invalid_type,expected:p.map,received:r.parsedType}),y;let s=this._def.keyType,o=this._def.valueType,a=[...r.data.entries()].map(([i,c],l)=>({key:s._parse(new ee(r,i,r.path,[l,"key"])),value:o._parse(new ee(r,c,r.path,[l,"value"]))}));if(r.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,g=await c.value;if(l.status==="aborted"||g.status==="aborted")return y;(l.status==="dirty"||g.status==="dirty")&&n.dirty(),i.set(l.value,g.value);}return {status:n.value,value:i}})}else {let i=new Map;for(let c of a){let l=c.key,g=c.value;if(l.status==="aborted"||g.status==="aborted")return y;(l.status==="dirty"||g.status==="dirty")&&n.dirty(),i.set(l.value,g.value);}return {status:n.value,value:i}}}};ot.create=(t,e,n)=>new ot({valueType:e,keyType:t,typeName:v.ZodMap,...k(n)});var it=class t extends _{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.set)return f(r,{code:u.invalid_type,expected:p.set,received:r.parsedType}),y;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(f(r,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:true,exact:false,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(f(r,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:true,exact:false,message:s.maxSize.message}),n.dirty());let o=this._def.valueType;function a(c){let l=new Set;for(let g of c){if(g.status==="aborted")return y;g.status==="dirty"&&n.dirty(),l.add(g.value);}return {status:n.value,value:l}}let i=[...r.data.values()].map((c,l)=>o._parse(new ee(r,c,r.path,l)));return r.common.async?Promise.all(i).then(c=>a(c)):a(i)}min(e,n){return new t({...this._def,minSize:{value:e,message:m.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:m.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};it.create=(t,e)=>new it({valueType:t,minSize:null,maxSize:null,typeName:v.ZodSet,...k(e)});var Ut=class t extends _{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.function)return f(n,{code:u.invalid_type,expected:p.function,received:n.parsedType}),y;function r(i,c){return mt({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,et(),fe].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(i,c){return mt({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,et(),fe].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let o={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Ee){let i=this;return M(async function(...c){let l=new K([]),g=await i._def.args.parseAsync(c,o).catch(x=>{throw l.addIssue(r(c,x)),l}),w=await Reflect.apply(a,this,g);return await i._def.returns._def.type.parseAsync(w,o).catch(x=>{throw l.addIssue(s(w,x)),l})})}else {let i=this;return M(function(...c){let l=i._def.args.safeParse(c,o);if(!l.success)throw new K([r(c,l.error)]);let g=Reflect.apply(a,this,l.data),w=i._def.returns.safeParse(g,o);if(!w.success)throw new K([s(g,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:ie.create(e).rest(ge.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,n,r){return new t({args:e||ie.create([]).rest(ge.create()),returns:n||ge.create(),typeName:v.ZodFunction,...k(r)})}},je=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};je.create=(t,e)=>new je({getter:t,typeName:v.ZodLazy,...k(e)});var Le=class extends _{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:u.invalid_literal,expected:this._def.value}),y}return {status:"valid",value:e.data}}get value(){return this._def.value}};Le.create=(t,e)=>new Le({value:t,typeName:v.ZodLiteral,...k(e)});function Hn(t,e){return new $e({values:t,typeName:v.ZodEnum,...k(e)})}var $e=class t extends _{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:S.joinValues(r),received:n.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{received:n.data,code:u.invalid_enum_value,options:r}),y}return M(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};$e.create=Hn;var Ve=class extends _{_parse(e){let n=S.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==p.string&&r.parsedType!==p.number){let s=S.objectValues(n);return f(r,{expected:S.joinValues(s),received:r.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=S.objectValues(n);return f(r,{received:r.data,code:u.invalid_enum_value,options:s}),y}return M(e.data)}get enum(){return this._def.values}};Ve.create=(t,e)=>new Ve({values:t,typeName:v.ZodNativeEnum,...k(e)});var Ee=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.promise&&n.common.async===false)return f(n,{code:u.invalid_type,expected:p.promise,received:n.parsedType}),y;let r=n.parsedType===p.promise?n.data:Promise.resolve(n.data);return M(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Ee.create=(t,e)=>new Ee({type:t,typeName:v.ZodPromise,...k(e)});var te=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,o={addIssue:a=>{f(r,a),a.fatal?n.abort():n.dirty();},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){let a=s.transform(r.data,o);if(r.common.async)return Promise.resolve(a).then(async i=>{if(n.value==="aborted")return y;let c=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});return c.status==="aborted"?y:c.status==="dirty"?Te(c.value):n.value==="dirty"?Te(c.value):c});{if(n.value==="aborted")return y;let i=this._def.schema._parseSync({data:a,path:r.path,parent:r});return i.status==="aborted"?y:i.status==="dirty"?Te(i.value):n.value==="dirty"?Te(i.value):i}}if(s.type==="refinement"){let a=i=>{let c=s.refinement(i,o);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(r.common.async===false){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?y:(i.status==="dirty"&&n.dirty(),a(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>i.status==="aborted"?y:(i.status==="dirty"&&n.dirty(),a(i.value).then(()=>({status:n.value,value:i.value}))))}if(s.type==="transform")if(r.common.async===false){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!_e(a))return y;let i=s.transform(a.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:n.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>_e(a)?Promise.resolve(s.transform(a.value,o)).then(i=>({status:n.value,value:i})):y);S.assertNever(s);}};te.create=(t,e,n)=>new te({schema:t,typeName:v.ZodEffects,effect:e,...k(n)});te.createWithPreprocess=(t,e,n)=>new te({schema:e,effect:{type:"preprocess",transform:t},typeName:v.ZodEffects,...k(n)});var Q=class extends _{_parse(e){return this._getType(e)===p.undefined?M(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Q.create=(t,e)=>new Q({innerType:t,typeName:v.ZodOptional,...k(e)});var ae=class extends _{_parse(e){return this._getType(e)===p.null?M(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ae.create=(t,e)=>new ae({innerType:t,typeName:v.ZodNullable,...k(e)});var Me=class extends _{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===p.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Me.create=(t,e)=>new Me({innerType:t,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});var Ue=class extends _{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return tt(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new K(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new K(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Ue.create=(t,e)=>new Ue({innerType:t,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});var at=class extends _{_parse(e){if(this._getType(e)!==p.nan){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.nan,received:r.parsedType}),y}return {status:"valid",value:e.data}}};at.create=t=>new at({typeName:v.ZodNaN,...k(t)});var ws=Symbol("zod_brand"),ht=class extends _{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},yt=class t extends _{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return (async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?y:o.status==="dirty"?(n.dirty(),Te(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?y:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:v.ZodPipeline})}},Fe=class extends _{_parse(e){let n=this._def.innerType._parse(e),r=s=>(_e(s)&&(s.value=Object.freeze(s.value)),s);return tt(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};Fe.create=(t,e)=>new Fe({innerType:t,typeName:v.ZodReadonly,...k(e)});function Un(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Zn(t,e={},n){return t?Se.create().superRefine((r,s)=>{let o=t(r);if(o instanceof Promise)return o.then(a=>{if(!a){let i=Un(e,r),c=i.fatal??n??true;s.addIssue({code:"custom",...i,fatal:c});}});if(!o){let a=Un(e,r),i=a.fatal??n??true;s.addIssue({code:"custom",...a,fatal:i});}}):Se.create()}var Ss={object:W.lazycreate},v;(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";})(v||(v={}));var Es=(t,e={message:`Input not instance of ${t.name}`})=>Zn(n=>n instanceof t,e),Jn=we.create,Gn=be.create,xs=at.create,As=Re.create,Kn=Ce.create,Ts=Ie.create,bs=rt.create,Rs=Ne.create,Cs=Pe.create,Is=Se.create,Ns=ge.create,Ps=re.create,Os=st.create,Ds=me.create,js=W.create,Ls=W.strictCreate,$s=Oe.create,Vs=Vt.create,Ms=De.create,Us=ie.create,Fs=Mt.create,Bs=ot.create,zs=it.create,Hs=Ut.create,Zs=je.create,Js=Le.create,Gs=$e.create,Ks=Ve.create,Ws=Ee.create,qs=te.create,Ys=Q.create,Xs=ae.create,Qs=te.createWithPreprocess,eo=yt.create,to=()=>Jn().optional(),no=()=>Gn().optional(),ro=()=>Kn().optional(),so={string:(t=>we.create({...t,coerce:true})),number:(t=>be.create({...t,coerce:true})),boolean:(t=>Ce.create({...t,coerce:true})),bigint:(t=>Re.create({...t,coerce:true})),date:(t=>Ie.create({...t,coerce:true}))};var oo=y;var io={api:{rateLimit:{windowMs:900*1e3,maxRequests:100}}};d.object({snapshot_version:d.string(),engine_target_version:d.string(),project_id:d.string(),generated_at:d.string(),root_path_hash:d.string(),metadata:d.object({total_files:d.number().int().nonnegative(),total_dependencies:d.number().int().nonnegative(),total_size_bytes:d.number().int().nonnegative(),total_lines:d.number().int().nonnegative(),max_directory_depth:d.number().int().nonnegative(),language_breakdown:d.record(d.string(),d.number().int().nonnegative())}),files:d.array(d.object({id:d.string(),path_hash:d.string(),depth:d.number().int().nonnegative(),size_bytes:d.number().int().nonnegative(),estimated_lines:d.number().int().nonnegative(),extension:d.string(),is_binary:d.boolean(),import_count:d.number().int().nonnegative().optional(),function_count:d.number().int().nonnegative().optional(),class_count:d.number().int().nonnegative().optional()})),dependencies:d.array(d.object({id:d.string(),name_hash:d.string(),major_version:d.number().int().nonnegative(),minor_version:d.number().int().nonnegative(),category:d.enum(["dev","prod","peer"])}))});d.object({name:d.string().min(1).max(100)});d.object({analysis_version:d.string(),snapshot_schema_version:d.string(),total_score:d.number().min(0).max(100),severity_band:d.enum(["HEALTHY","STABLE","STRUCTURAL_CONCERN","HIGH_RISK"]),engines:d.array(d.object({engine_name:d.string(),score_impact:d.number(),risk_level:d.enum(["HEALTHY","STABLE","STRUCTURAL_CONCERN","HIGH_RISK"]),metrics:d.record(d.number()),findings:d.array(d.object({rule_id:d.string(),title:d.string(),message:d.string(),severity:d.enum(["CRITICAL","HIGH","MEDIUM","LOW"]),category:d.enum(["SECURITY","STRUCTURE","COMPLEXITY","DEPENDENCY","REPOSITORY_HYGIENE","DOCUMENTATION","QUALITY"]),evidence:d.array(d.string()).optional(),explanation:d.string().optional(),impact:d.string().optional(),effort:d.enum(["Low","Medium","High"]).optional(),recommendations:d.array(d.string()).optional()}))})),summary:d.object({total_findings:d.number().int().nonnegative(),critical_count:d.number().int().nonnegative(),high_count:d.number().int().nonnegative(),medium_count:d.number().int().nonnegative(),low_count:d.number().int().nonnegative(),categories:d.record(d.string(),d.number().int().nonnegative())}),generated_at:d.string()});var ao=d.object({NEXT_PUBLIC_SUPABASE_URL:d.string().url("Invalid SUPABASE_URL"),NEXT_PUBLIC_SUPABASE_ANON_KEY:d.string().min(1,"SUPABASE_ANON_KEY is required"),SUPABASE_SERVICE_ROLE_KEY:d.string().min(1,"SERVICE_ROLE_KEY is required"),NODE_ENV:d.enum(["development","production","test"],{errorMap:()=>({message:"NODE_ENV must be development, production, or test"})}),JWT_SECRET:d.string().min(32,"JWT_SECRET must be at least 32 characters").optional()});function co(){try{return ao.parse(process.env)}catch(t){if(t instanceof d.ZodError){let e=t.errors.map(n=>n.path.join(".")).join(", ");throw new Error(`Environment validation failed:
22
+ `)),process.exit(1);}process.env.VEESTACK_DEBUG==="true"&&console.log(h.gray(`\u2713 Official package verified: ${qe.join(" or ")}`));}function Ot(){let t=Ln(),e=qe.includes(t);return {packageName:t,isOfficial:e,homepage:"https://www.veestack.com",repository:"https://github.com/Mohmed-ElZehiry/VeeStack"}}var zr=[".env",".env.local",".env.development",".env.production",".env.test",".env.example",".envrc",".env.*","id_rsa","id_rsa.pub","id_dsa","id_dsa.pub","id_ecdsa","id_ecdsa.pub","id_ed25519","id_ed25519.pub","*.pem","*.key","*.p12","*.pfx","*.crt","*.cer","*.der","credentials",".aws/credentials",".aws/config",".docker/config.json","kubeconfig","*.kubeconfig",".npmrc",".yarnrc",".pnpmrc",".git-credentials","*.sqlite","*.sqlite3","*.db","secrets/","secret/",".secrets/","config.json","settings.json","local.settings.json"],Hr=["veestack.config.json","package.json","tsconfig.json","jsconfig.json",".eslintrc.json",".prettierrc.json","README.md"],Zr=[{name:"AWS Access Key ID",pattern:/AKIA[0-9A-Z]{16}/g,severity:"critical",description:"AWS Access Key ID detected"},{name:"AWS Secret Access Key",pattern:/['"\s][A-Za-z0-9/+=]{40}['"\s]/g,severity:"critical",description:"Potential AWS Secret Key detected"},{name:"Private Key",pattern:/-----BEGIN (RSA |DSA |EC |OPENSSH |PGP )?PRIVATE KEY-----/g,severity:"critical",description:"Private key detected"},{name:"JWT Token",pattern:/eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/g,severity:"high",description:"JWT token detected"},{name:"Bearer Token",pattern:/Bearer\s+[a-zA-Z0-9_-]{20,}/gi,severity:"high",description:"Bearer token detected"},{name:"API Key",pattern:/(?:api[_-]?key|apikey|api_token|apiToken)['"\s]*[:=]\s*['"][a-zA-Z0-9_-]{16,}['"]/gi,severity:"high",description:"API key detected"},{name:"Password in URL",pattern:/[a-zA-Z]+:\/\/[^\s:@]+:[^\s:@]+@[^\s]+/g,severity:"high",description:"Password in URL detected"},{name:"Password Assignment",pattern:/(?:password|passwd|pwd)\s*[=:]\s*['"][^'"]{8,}['"]/gi,severity:"medium",description:"Password assignment detected"},{name:"GitHub Token",pattern:/gh[pousr]_[A-Za-z0-9_]{36,}/g,severity:"critical",description:"GitHub token detected"},{name:"Slack Token",pattern:/xox[baprs]-[0-9]{10,13}-[0-9]{10,13}(-[a-zA-Z0-9]{24})?/g,severity:"critical",description:"Slack token detected"},{name:"Generic Secret",pattern:/(?:secret|token|key)\s*[=:]\s*['"][a-zA-Z0-9_-]{20,}['"]/gi,severity:"medium",description:"Potential secret detected"},{name:"Connection String",pattern:/(?:mongodb|postgres|mysql|redis|amqp):\/\/[^\s]+/gi,severity:"high",description:"Database connection string detected"},{name:"VeeStack Token",pattern:/vs_[a-zA-Z0-9_-]{20,}/g,severity:"critical",description:"VeeStack token detected"}];function Vn(t){let e=t.replace(/\\/g,"/").toLowerCase(),n=Ke.basename(e);for(let r of Hr)if(n===r.toLowerCase())return false;for(let r of zr){if(n===r.toLowerCase())return true;if(r.includes("*")){let s=r.toLowerCase().replace(/\./g,"\\.").replace(/\*/g,".*"),o=new RegExp(s);if(o.test(n)||o.test(e))return true}if(e.includes(r.toLowerCase().replace("*","")))return true}return false}function Jr(t,e){let n=[],r=e.split(`
23
+ `);for(let s of Zr){s.pattern.lastIndex=0;for(let o=0;o<r.length;o++){let a=r[o],i;for(;(i=s.pattern.exec(a))!==null;)n.push({filePath:t,type:"secret_content",secretName:s.name,severity:s.severity,description:s.description,lineNumber:o+1,match:i[0].substring(0,20)+"..."});s.pattern.lastIndex=0;}}return n}async function Gr(t){let e=[];if(Vn(t))return e.push({filePath:t,type:"sensitive_file",secretName:"Sensitive File",severity:"critical",description:`Sensitive file type detected: ${Ke.basename(t)}`}),e;try{if(te.statSync(t).size>1024*1024)return e;let r=te.readFileSync(t,"utf-8"),s=Jr(t,r);e.push(...s);}catch{}return e}async function Mn(t,e){let n=[];for(let i of e){let c=Ke.join(t,i),l=await Gr(c);for(let g of l)g.filePath=i,n.push(g);}let r=n.filter(i=>i.severity==="critical").length,s=n.filter(i=>i.severity==="high").length,o=n.filter(i=>i.severity==="medium").length,a=n.filter(i=>i.severity==="low").length;return {totalFiles:e.length,secretsFound:n.length,criticalCount:r,highCount:s,mediumCount:o,lowCount:a,results:n}}function Un(t){let e=[],n=[];for(let r of t)Vn(r)?n.push(r):e.push(r);return {safe:e,blocked:n}}var sn=(t=>typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>e[n]}):t)(function(t){throw Error('Dynamic require of "'+t+'" is not supported')}),Kr=typeof process<"u"&&process.versions?.node,Wr="6.3.3",qr={snapshot:"6",engine_target:"6.3.1",audit:"1",session_payload:"1",rules:"v1",analysis:"v1",api:"v1",min_node:"18.0.0"},on=null;if(Kr)try{let t=function(){let w=g,b=0;for(;w!==i(w)&&b<10;){let x=a(w,"package.json");try{if(o(x)){let C=JSON.parse(s(x,"utf-8"));if(C.name==="vee_stack")return C}}catch{}w=i(w),b++;}return null};Yr=t;let e=sn("fs"),n=sn("path"),r=sn("url"),{readFileSync:s,existsSync:o}=e,{join:a,dirname:i}=n,{fileURLToPath:c}=r,l=c(import.meta.url),g=i(l);on=t();}catch{console.warn("Failed to load package.json dynamically, using defaults");}var Yr,ve=on?.versions||qr,J=on?.version||Wr,an=`vs_cli_v${J}`,Ye=ve.snapshot,Xe=ve.engine_target,jt=ve.audit;ve.session_payload;ve.rules;ve.analysis;ve.api;ve.min_node;var d={};$r(d,{BRAND:()=>bs,DIRTY:()=>Ae,EMPTY_PATH:()=>os,INVALID:()=>y,NEVER:()=>fo,OK:()=>M,ParseStatus:()=>V,Schema:()=>_,ZodAny:()=>we,ZodArray:()=>ge,ZodBigInt:()=>be,ZodBoolean:()=>Re,ZodBranded:()=>ht,ZodCatch:()=>Me,ZodDate:()=>Ce,ZodDefault:()=>Ve,ZodDiscriminatedUnion:()=>Vt,ZodEffects:()=>ee,ZodEnum:()=>Le,ZodError:()=>G,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>Ut,ZodIntersection:()=>Oe,ZodIssueCode:()=>u,ZodLazy:()=>De,ZodLiteral:()=>je,ZodMap:()=>st,ZodNaN:()=>it,ZodNativeEnum:()=>$e,ZodNever:()=>ne,ZodNull:()=>Ne,ZodNullable:()=>ie,ZodNumber:()=>Te,ZodObject:()=>K,ZodOptional:()=>X,ZodParsedType:()=>p,ZodPipeline:()=>yt,ZodPromise:()=>Se,ZodReadonly:()=>Ue,ZodRecord:()=>Mt,ZodSchema:()=>_,ZodSet:()=>ot,ZodString:()=>_e,ZodSymbol:()=>nt,ZodTransformer:()=>ee,ZodTuple:()=>oe,ZodType:()=>_,ZodUndefined:()=>Ie,ZodUnion:()=>Pe,ZodUnknown:()=>pe,ZodVoid:()=>rt,addIssueToContext:()=>f,any:()=>Ls,array:()=>Us,bigint:()=>Ns,boolean:()=>Yn,coerce:()=>uo,custom:()=>Kn,date:()=>Ps,datetimeRegex:()=>Jn,defaultErrorMap:()=>de,discriminatedUnion:()=>Hs,effect:()=>no,enum:()=>Qs,function:()=>qs,getErrorMap:()=>Qe,getParsedType:()=>se,instanceof:()=>Cs,intersection:()=>Zs,isAborted:()=>Lt,isAsync:()=>et,isDirty:()=>$t,isValid:()=>ke,late:()=>Rs,lazy:()=>Ys,literal:()=>Xs,makeIssue:()=>mt,map:()=>Ks,nan:()=>Is,nativeEnum:()=>eo,never:()=>Vs,null:()=>js,nullable:()=>so,number:()=>qn,object:()=>Fs,objectUtil:()=>un,oboolean:()=>lo,onumber:()=>co,optional:()=>ro,ostring:()=>ao,pipeline:()=>io,preprocess:()=>oo,promise:()=>to,quotelessJson:()=>ns,record:()=>Gs,set:()=>Ws,setErrorMap:()=>ss,strictObject:()=>Bs,string:()=>Wn,symbol:()=>Os,transformer:()=>no,tuple:()=>Js,undefined:()=>Ds,union:()=>zs,unknown:()=>$s,util:()=>S,void:()=>Ms});var S;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let o={};for(let a of s)o[a]=a;return o},t.getValidEnumValues=s=>{let o=t.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),a={};for(let i of o)a[i]=s[i];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let o=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&o.push(a);return o},t.find=(s,o)=>{for(let a of s)if(o(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,o=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o;})(S||(S={}));var un;(function(t){t.mergeShapes=(e,n)=>({...e,...n});})(un||(un={}));var p=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),se=t=>{switch(typeof t){case "undefined":return p.undefined;case "string":return p.string;case "number":return Number.isNaN(t)?p.nan:p.number;case "boolean":return p.boolean;case "function":return p.function;case "bigint":return p.bigint;case "symbol":return p.symbol;case "object":return Array.isArray(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}};var u=S.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ns=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),G=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r];},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r];};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e;}format(e){let n=e||function(o){return o.message},r={_errors:[]},s=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else {let i=r,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(n(a))):i[l]=i[l]||{_errors:[]},i=i[l],c++;}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let o=s.path[0];n[o]=n[o]||[],n[o].push(e(s));}else r.push(e(s));return {formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};G.create=t=>new G(t);var rs=(t,e)=>{let n;switch(t.code){case u.invalid_type:t.received===p.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:n=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case u.invalid_union:n="Invalid input";break;case u.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case u.invalid_enum_value:n=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:n="Invalid function arguments";break;case u.invalid_return_type:n="Invalid function return type";break;case u.invalid_date:n="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:S.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case u.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case u.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case u.custom:n="Invalid input";break;case u.invalid_intersection_types:n="Intersection results could not be merged";break;case u.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:n="Number must be finite";break;default:n=e.defaultError,S.assertNever(t);}return {message:n}},de=rs;var Fn=de;function ss(t){Fn=t;}function Qe(){return Fn}var mt=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,o=[...n,...s.path||[]],a={...s,path:o};if(s.message!==void 0)return {...s,path:o,message:s.message};let i="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)i=l(a,{data:e,defaultError:i}).message;return {...s,path:o,message:i}},os=[];function f(t,e){let n=Qe(),r=mt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===de?void 0:de].filter(s=>!!s)});t.common.issues.push(r);}var V=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),r.push(s.value);}return {status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let o=await s.key,a=await s.value;r.push({key:o,value:a});}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:o,value:a}=s;if(o.status==="aborted"||a.status==="aborted")return y;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[o.value]=a.value);}return {status:e.value,value:r}}},y=Object.freeze({status:"aborted"}),Ae=t=>({status:"dirty",value:t}),M=t=>({status:"valid",value:t}),Lt=t=>t.status==="aborted",$t=t=>t.status==="dirty",ke=t=>t.status==="valid",et=t=>typeof Promise<"u"&&t instanceof Promise;var m;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(m||(m={}));var Q=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,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}},Bn=(t,e)=>{if(ke(e))return {success:true,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let n=new G(t.common.issues);return this._error=n,this._error}}};function k(t){if(!t)return {};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??r??i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:c??n??i.defaultError}},description:s}}var _=class{get description(){return this._def.description}_getType(e){return se(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new V,ctx:{common:e.parent.common,data:e.data,parsedType:se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(et(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??false,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:se(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Bn(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:se(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return ke(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),n.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:n}).then(r=>ke(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:true},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:se(e)},s=this._parse({data:e,path:r.path,parent:r}),o=await(et(s)?s:Promise.resolve(s));return Bn(r,o)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,o)=>{let a=e(s),i=()=>o.addIssue({code:u.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?true:(i(),false)):a?true:(i(),false)})}refinement(e,n){return this._refinement((r,s)=>e(r)?true:(s.addIssue(typeof n=="function"?n(r,s):n),false))}_refinement(e){return new ee({schema:this,typeName:v.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:n=>this["~validate"](n)};}optional(){return X.create(this,this._def)}nullable(){return ie.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ge.create(this)}promise(){return Se.create(this,this._def)}or(e){return Pe.create([this,e],this._def)}and(e){return Oe.create(this,e,this._def)}transform(e){return new ee({...k(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ve({...k(this._def),innerType:this,defaultValue:n,typeName:v.ZodDefault})}brand(){return new ht({typeName:v.ZodBranded,type:this,...k(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Me({...k(this._def),innerType:this,catchValue:n,typeName:v.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return yt.create(this,e)}readonly(){return Ue.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},is=/^c[^\s-]{8,}$/i,as=/^[0-9a-z]+$/,cs=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ls=/^[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,us=/^[a-z0-9_-]{21}$/i,ds=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,fs=/^[-+]?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)?)??$/,ps=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",dn,ms=/^(?:(?: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])$/,hs=/^(?:(?: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])$/,ys=/^(([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]))$/,vs=/^(([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])$/,ks=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,_s=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Hn="((\\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])))",ws=new RegExp(`^${Hn}$`);function Zn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Ss(t){return new RegExp(`^${Zn(t)}$`)}function Jn(t){let e=`${Hn}T${Zn(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Es(t,e){return !!((e==="v4"||!e)&&ms.test(t)||(e==="v6"||!e)&&ys.test(t))}function xs(t,e){if(!ds.test(t))return false;try{let[n]=t.split(".");if(!n)return !1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return !(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return false}}function As(t,e){return !!((e==="v4"||!e)&&hs.test(t)||(e==="v6"||!e)&&vs.test(t))}var _e=class t extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let o=this._getOrReturnCtx(e);return f(o,{code:u.invalid_type,expected:p.string,received:o.parsedType}),y}let r=new V,s;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_small,minimum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),r.dirty());else if(o.kind==="max")e.data.length>o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,maximum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),r.dirty());else if(o.kind==="length"){let a=e.data.length>o.value,i=e.data.length<o.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?f(s,{code:u.too_big,maximum:o.value,type:"string",inclusive:true,exact:true,message:o.message}):i&&f(s,{code:u.too_small,minimum:o.value,type:"string",inclusive:true,exact:true,message:o.message}),r.dirty());}else if(o.kind==="email")ps.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")dn||(dn=new RegExp(gs,"u")),dn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")ls.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")us.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")is.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")as.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")cs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:u.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data);}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:u.invalid_string,message:o.message}),r.dirty();}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:u.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?Jn(o).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?ws.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?Ss(o).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?fs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?Es(e.data,o.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?xs(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?As(e.data,o.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?ks.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:u.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?_s.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:u.invalid_string,message:o.message}),r.dirty()):S.assertNever(o);return {status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:u.invalid_string,...m.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...m.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...m.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...m.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...m.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...m.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...m.errToObj(n)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return !!this._def.checks.find(e=>e.kind==="email")}get isURL(){return !!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return !!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return !!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return !!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return !!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return !!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return !!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};_e.create=t=>new _e({checks:[],typeName:v.ZodString,coerce:t?.coerce??false,...k(t)});function Ts(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,o=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}var Te=class t extends _{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)!==p.number){let o=this._getOrReturnCtx(e);return f(o,{code:u.invalid_type,expected:p.number,received:o.parsedType}),y}let r,s=new V;for(let o of this._def.checks)o.kind==="int"?S.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),s.dirty()):o.kind==="multipleOf"?Ts(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_finite,message:o.message}),s.dirty()):S.assertNever(o);return {status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,true,m.toString(n))}gt(e,n){return this.setLimit("min",e,false,m.toString(n))}lte(e,n){return this.setLimit("max",e,true,m.toString(n))}lt(e,n){return this.setLimit("max",e,false,m.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:m.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:m.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return true;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);}return Number.isFinite(n)&&Number.isFinite(e)}};Te.create=t=>new Te({checks:[],typeName:v.ZodNumber,coerce:t?.coerce||false,...k(t)});var be=class t extends _{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)!==p.bigint)return this._getInvalidInput(e);let r,s=new V;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):S.assertNever(o);return {status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.bigint,received:n.parsedType}),y}gte(e,n){return this.setLimit("min",e,true,m.toString(n))}gt(e,n){return this.setLimit("min",e,false,m.toString(n))}lte(e,n){return this.setLimit("max",e,true,m.toString(n))}lt(e,n){return this.setLimit("max",e,false,m.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:m.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:m.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};be.create=t=>new be({checks:[],typeName:v.ZodBigInt,coerce:t?.coerce??false,...k(t)});var Re=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.boolean,received:r.parsedType}),y}return M(e.data)}};Re.create=t=>new Re({typeName:v.ZodBoolean,coerce:t?.coerce||false,...k(t)});var Ce=class t extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let o=this._getOrReturnCtx(e);return f(o,{code:u.invalid_type,expected:p.date,received:o.parsedType}),y}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return f(o,{code:u.invalid_date}),y}let r=new V,s;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_small,message:o.message,inclusive:true,exact:false,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,message:o.message,inclusive:true,exact:false,maximum:o.value,type:"date"}),r.dirty()):S.assertNever(o);return {status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Ce.create=t=>new Ce({checks:[],coerce:t?.coerce||false,typeName:v.ZodDate,...k(t)});var nt=class extends _{_parse(e){if(this._getType(e)!==p.symbol){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.symbol,received:r.parsedType}),y}return M(e.data)}};nt.create=t=>new nt({typeName:v.ZodSymbol,...k(t)});var Ie=class extends _{_parse(e){if(this._getType(e)!==p.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.undefined,received:r.parsedType}),y}return M(e.data)}};Ie.create=t=>new Ie({typeName:v.ZodUndefined,...k(t)});var Ne=class extends _{_parse(e){if(this._getType(e)!==p.null){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.null,received:r.parsedType}),y}return M(e.data)}};Ne.create=t=>new Ne({typeName:v.ZodNull,...k(t)});var we=class extends _{constructor(){super(...arguments),this._any=true;}_parse(e){return M(e.data)}};we.create=t=>new we({typeName:v.ZodAny,...k(t)});var pe=class extends _{constructor(){super(...arguments),this._unknown=true;}_parse(e){return M(e.data)}};pe.create=t=>new pe({typeName:v.ZodUnknown,...k(t)});var ne=class extends _{_parse(e){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.never,received:n.parsedType}),y}};ne.create=t=>new ne({typeName:v.ZodNever,...k(t)});var rt=class extends _{_parse(e){if(this._getType(e)!==p.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.void,received:r.parsedType}),y}return M(e.data)}};rt.create=t=>new rt({typeName:v.ZodVoid,...k(t)});var ge=class t extends _{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==p.array)return f(n,{code:u.invalid_type,expected:p.array,received:n.parsedType}),y;if(s.exactLength!==null){let a=n.data.length>s.exactLength.value,i=n.data.length<s.exactLength.value;(a||i)&&(f(n,{code:a?u.too_big:u.too_small,minimum:i?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:s.exactLength.message}),r.dirty());}if(s.minLength!==null&&n.data.length<s.minLength.value&&(f(n,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:true,exact:false,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(f(n,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:true,exact:false,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,i)=>s.type._parseAsync(new Q(n,a,n.path,i)))).then(a=>V.mergeArray(r,a));let o=[...n.data].map((a,i)=>s.type._parseSync(new Q(n,a,n.path,i)));return V.mergeArray(r,o)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:m.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:m.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:m.toString(n)}})}nonempty(e){return this.min(1,e)}};ge.create=(t,e)=>new ge({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...k(e)});function tt(t){if(t instanceof K){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=X.create(tt(r));}return new K({...t._def,shape:()=>e})}else return t instanceof ge?new ge({...t._def,type:tt(t.element)}):t instanceof X?X.create(tt(t.unwrap())):t instanceof ie?ie.create(tt(t.unwrap())):t instanceof oe?oe.create(t.items.map(e=>tt(e))):t}var K=class t extends _{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(),n=S.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==p.object){let l=this._getOrReturnCtx(e);return f(l,{code:u.invalid_type,expected:p.object,received:l.parsedType}),y}let{status:r,ctx:s}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof ne&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||i.push(l);let c=[];for(let l of a){let g=o[l],w=s.data[l];c.push({key:{status:"valid",value:l},value:g._parse(new Q(s,w,s.path,l)),alwaysSet:l in s.data});}if(this._def.catchall instanceof ne){let l=this._def.unknownKeys;if(l==="passthrough")for(let g of i)c.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(l==="strict")i.length>0&&(f(s,{code:u.unrecognized_keys,keys:i}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let l=this._def.catchall;for(let g of i){let w=s.data[g];c.push({key:{status:"valid",value:g},value:l._parse(new Q(s,w,s.path,g)),alwaysSet:g in s.data});}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let g of c){let w=await g.key,b=await g.value;l.push({key:w,value:b,alwaysSet:g.alwaysSet});}return l}).then(l=>V.mergeObjectSync(r,l)):V.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:m.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of S.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of S.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return tt(this)}partial(e){let n={};for(let r of S.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional();}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of S.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else {let o=this.shape[r];for(;o instanceof X;)o=o._def.innerType;n[r]=o;}return new t({...this._def,shape:()=>n})}keyof(){return Gn(S.objectKeys(this.shape))}};K.create=(t,e)=>new K({shape:()=>t,unknownKeys:"strip",catchall:ne.create(),typeName:v.ZodObject,...k(e)});K.strictCreate=(t,e)=>new K({shape:()=>t,unknownKeys:"strict",catchall:ne.create(),typeName:v.ZodObject,...k(e)});K.lazycreate=(t,e)=>new K({shape:t,unknownKeys:"strip",catchall:ne.create(),typeName:v.ZodObject,...k(e)});var Pe=class extends _{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(i=>new G(i.ctx.common.issues));return f(n,{code:u.invalid_union,unionErrors:a}),y}if(n.common.async)return Promise.all(r.map(async o=>{let a={...n,common:{...n.common,issues:[]},parent:null};return {result:await o._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let o,a=[];for(let c of r){let l={...n,common:{...n.common,issues:[]},parent:null},g=c._parseSync({data:n.data,path:n.path,parent:l});if(g.status==="valid")return g;g.status==="dirty"&&!o&&(o={result:g,ctx:l}),l.common.issues.length&&a.push(l.common.issues);}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(c=>new G(c));return f(n,{code:u.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}};Pe.create=(t,e)=>new Pe({options:t,typeName:v.ZodUnion,...k(e)});var fe=t=>t instanceof De?fe(t.schema):t instanceof ee?fe(t.innerType()):t instanceof je?[t.value]:t instanceof Le?t.options:t instanceof $e?S.objectValues(t.enum):t instanceof Ve?fe(t._def.innerType):t instanceof Ie?[void 0]:t instanceof Ne?[null]:t instanceof X?[void 0,...fe(t.unwrap())]:t instanceof ie?[null,...fe(t.unwrap())]:t instanceof ht||t instanceof Ue?fe(t.unwrap()):t instanceof Me?fe(t._def.innerType):[],Vt=class t extends _{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return f(n,{code:u.invalid_type,expected:p.object,received:n.parsedType}),y;let r=this.discriminator,s=n.data[r],o=this.optionsMap.get(s);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let o of n){let a=fe(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of a){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,o);}}return new t({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...k(r)})}};function fn(t,e){let n=se(t),r=se(e);if(t===e)return {valid:true,data:t};if(n===p.object&&r===p.object){let s=S.objectKeys(e),o=S.objectKeys(t).filter(i=>s.indexOf(i)!==-1),a={...t,...e};for(let i of o){let c=fn(t[i],e[i]);if(!c.valid)return {valid:false};a[i]=c.data;}return {valid:true,data:a}}else if(n===p.array&&r===p.array){if(t.length!==e.length)return {valid:false};let s=[];for(let o=0;o<t.length;o++){let a=t[o],i=e[o],c=fn(a,i);if(!c.valid)return {valid:false};s.push(c.data);}return {valid:true,data:s}}else return n===p.date&&r===p.date&&+t==+e?{valid:true,data:t}:{valid:false}}var Oe=class extends _{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(o,a)=>{if(Lt(o)||Lt(a))return y;let i=fn(o.value,a.value);return i.valid?(($t(o)||$t(a))&&n.dirty(),{status:n.value,value:i.data}):(f(r,{code:u.invalid_intersection_types}),y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,a])=>s(o,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Oe.create=(t,e,n)=>new Oe({left:t,right:e,typeName:v.ZodIntersection,...k(n)});var oe=class t extends _{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.array)return f(r,{code:u.invalid_type,expected:p.array,received:r.parsedType}),y;if(r.data.length<this._def.items.length)return f(r,{code:u.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),y;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:u.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),n.dirty());let o=[...r.data].map((a,i)=>{let c=this._def.items[i]||this._def.rest;return c?c._parse(new Q(r,a,r.path,i)):null}).filter(a=>!!a);return r.common.async?Promise.all(o).then(a=>V.mergeArray(n,a)):V.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};oe.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new oe({items:t,typeName:v.ZodTuple,rest:null,...k(e)})};var Mt=class t extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return f(r,{code:u.invalid_type,expected:p.object,received:r.parsedType}),y;let s=[],o=this._def.keyType,a=this._def.valueType;for(let i in r.data)s.push({key:o._parse(new Q(r,i,r.path,i)),value:a._parse(new Q(r,r.data[i],r.path,i)),alwaysSet:i in r.data});return r.common.async?V.mergeObjectAsync(n,s):V.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof _?new t({keyType:e,valueType:n,typeName:v.ZodRecord,...k(r)}):new t({keyType:_e.create(),valueType:e,typeName:v.ZodRecord,...k(n)})}},st=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.map)return f(r,{code:u.invalid_type,expected:p.map,received:r.parsedType}),y;let s=this._def.keyType,o=this._def.valueType,a=[...r.data.entries()].map(([i,c],l)=>({key:s._parse(new Q(r,i,r.path,[l,"key"])),value:o._parse(new Q(r,c,r.path,[l,"value"]))}));if(r.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,g=await c.value;if(l.status==="aborted"||g.status==="aborted")return y;(l.status==="dirty"||g.status==="dirty")&&n.dirty(),i.set(l.value,g.value);}return {status:n.value,value:i}})}else {let i=new Map;for(let c of a){let l=c.key,g=c.value;if(l.status==="aborted"||g.status==="aborted")return y;(l.status==="dirty"||g.status==="dirty")&&n.dirty(),i.set(l.value,g.value);}return {status:n.value,value:i}}}};st.create=(t,e,n)=>new st({valueType:e,keyType:t,typeName:v.ZodMap,...k(n)});var ot=class t extends _{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.set)return f(r,{code:u.invalid_type,expected:p.set,received:r.parsedType}),y;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(f(r,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:true,exact:false,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(f(r,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:true,exact:false,message:s.maxSize.message}),n.dirty());let o=this._def.valueType;function a(c){let l=new Set;for(let g of c){if(g.status==="aborted")return y;g.status==="dirty"&&n.dirty(),l.add(g.value);}return {status:n.value,value:l}}let i=[...r.data.values()].map((c,l)=>o._parse(new Q(r,c,r.path,l)));return r.common.async?Promise.all(i).then(c=>a(c)):a(i)}min(e,n){return new t({...this._def,minSize:{value:e,message:m.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:m.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};ot.create=(t,e)=>new ot({valueType:t,minSize:null,maxSize:null,typeName:v.ZodSet,...k(e)});var Ut=class t extends _{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.function)return f(n,{code:u.invalid_type,expected:p.function,received:n.parsedType}),y;function r(i,c){return mt({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Qe(),de].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(i,c){return mt({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Qe(),de].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let o={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Se){let i=this;return M(async function(...c){let l=new G([]),g=await i._def.args.parseAsync(c,o).catch(x=>{throw l.addIssue(r(c,x)),l}),w=await Reflect.apply(a,this,g);return await i._def.returns._def.type.parseAsync(w,o).catch(x=>{throw l.addIssue(s(w,x)),l})})}else {let i=this;return M(function(...c){let l=i._def.args.safeParse(c,o);if(!l.success)throw new G([r(c,l.error)]);let g=Reflect.apply(a,this,l.data),w=i._def.returns.safeParse(g,o);if(!w.success)throw new G([s(g,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:oe.create(e).rest(pe.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,n,r){return new t({args:e||oe.create([]).rest(pe.create()),returns:n||pe.create(),typeName:v.ZodFunction,...k(r)})}},De=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};De.create=(t,e)=>new De({getter:t,typeName:v.ZodLazy,...k(e)});var je=class extends _{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:u.invalid_literal,expected:this._def.value}),y}return {status:"valid",value:e.data}}get value(){return this._def.value}};je.create=(t,e)=>new je({value:t,typeName:v.ZodLiteral,...k(e)});function Gn(t,e){return new Le({values:t,typeName:v.ZodEnum,...k(e)})}var Le=class t extends _{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:S.joinValues(r),received:n.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{received:n.data,code:u.invalid_enum_value,options:r}),y}return M(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};Le.create=Gn;var $e=class extends _{_parse(e){let n=S.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==p.string&&r.parsedType!==p.number){let s=S.objectValues(n);return f(r,{expected:S.joinValues(s),received:r.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=S.objectValues(n);return f(r,{received:r.data,code:u.invalid_enum_value,options:s}),y}return M(e.data)}get enum(){return this._def.values}};$e.create=(t,e)=>new $e({values:t,typeName:v.ZodNativeEnum,...k(e)});var Se=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.promise&&n.common.async===false)return f(n,{code:u.invalid_type,expected:p.promise,received:n.parsedType}),y;let r=n.parsedType===p.promise?n.data:Promise.resolve(n.data);return M(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Se.create=(t,e)=>new Se({type:t,typeName:v.ZodPromise,...k(e)});var ee=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,o={addIssue:a=>{f(r,a),a.fatal?n.abort():n.dirty();},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){let a=s.transform(r.data,o);if(r.common.async)return Promise.resolve(a).then(async i=>{if(n.value==="aborted")return y;let c=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});return c.status==="aborted"?y:c.status==="dirty"?Ae(c.value):n.value==="dirty"?Ae(c.value):c});{if(n.value==="aborted")return y;let i=this._def.schema._parseSync({data:a,path:r.path,parent:r});return i.status==="aborted"?y:i.status==="dirty"?Ae(i.value):n.value==="dirty"?Ae(i.value):i}}if(s.type==="refinement"){let a=i=>{let c=s.refinement(i,o);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(r.common.async===false){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?y:(i.status==="dirty"&&n.dirty(),a(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>i.status==="aborted"?y:(i.status==="dirty"&&n.dirty(),a(i.value).then(()=>({status:n.value,value:i.value}))))}if(s.type==="transform")if(r.common.async===false){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ke(a))return y;let i=s.transform(a.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:n.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>ke(a)?Promise.resolve(s.transform(a.value,o)).then(i=>({status:n.value,value:i})):y);S.assertNever(s);}};ee.create=(t,e,n)=>new ee({schema:t,typeName:v.ZodEffects,effect:e,...k(n)});ee.createWithPreprocess=(t,e,n)=>new ee({schema:e,effect:{type:"preprocess",transform:t},typeName:v.ZodEffects,...k(n)});var X=class extends _{_parse(e){return this._getType(e)===p.undefined?M(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};X.create=(t,e)=>new X({innerType:t,typeName:v.ZodOptional,...k(e)});var ie=class extends _{_parse(e){return this._getType(e)===p.null?M(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ie.create=(t,e)=>new ie({innerType:t,typeName:v.ZodNullable,...k(e)});var Ve=class extends _{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===p.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ve.create=(t,e)=>new Ve({innerType:t,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});var Me=class extends _{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return et(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new G(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new G(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Me.create=(t,e)=>new Me({innerType:t,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});var it=class extends _{_parse(e){if(this._getType(e)!==p.nan){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.nan,received:r.parsedType}),y}return {status:"valid",value:e.data}}};it.create=t=>new it({typeName:v.ZodNaN,...k(t)});var bs=Symbol("zod_brand"),ht=class extends _{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},yt=class t extends _{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return (async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?y:o.status==="dirty"?(n.dirty(),Ae(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?y:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:v.ZodPipeline})}},Ue=class extends _{_parse(e){let n=this._def.innerType._parse(e),r=s=>(ke(s)&&(s.value=Object.freeze(s.value)),s);return et(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};Ue.create=(t,e)=>new Ue({innerType:t,typeName:v.ZodReadonly,...k(e)});function zn(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Kn(t,e={},n){return t?we.create().superRefine((r,s)=>{let o=t(r);if(o instanceof Promise)return o.then(a=>{if(!a){let i=zn(e,r),c=i.fatal??n??true;s.addIssue({code:"custom",...i,fatal:c});}});if(!o){let a=zn(e,r),i=a.fatal??n??true;s.addIssue({code:"custom",...a,fatal:i});}}):we.create()}var Rs={object:K.lazycreate},v;(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";})(v||(v={}));var Cs=(t,e={message:`Input not instance of ${t.name}`})=>Kn(n=>n instanceof t,e),Wn=_e.create,qn=Te.create,Is=it.create,Ns=be.create,Yn=Re.create,Ps=Ce.create,Os=nt.create,Ds=Ie.create,js=Ne.create,Ls=we.create,$s=pe.create,Vs=ne.create,Ms=rt.create,Us=ge.create,Fs=K.create,Bs=K.strictCreate,zs=Pe.create,Hs=Vt.create,Zs=Oe.create,Js=oe.create,Gs=Mt.create,Ks=st.create,Ws=ot.create,qs=Ut.create,Ys=De.create,Xs=je.create,Qs=Le.create,eo=$e.create,to=Se.create,no=ee.create,ro=X.create,so=ie.create,oo=ee.createWithPreprocess,io=yt.create,ao=()=>Wn().optional(),co=()=>qn().optional(),lo=()=>Yn().optional(),uo={string:(t=>_e.create({...t,coerce:true})),number:(t=>Te.create({...t,coerce:true})),boolean:(t=>Re.create({...t,coerce:true})),bigint:(t=>be.create({...t,coerce:true})),date:(t=>Ce.create({...t,coerce:true}))};var fo=y;var po={api:{rateLimit:{windowMs:900*1e3,maxRequests:100}}};d.object({snapshot_version:d.string(),engine_target_version:d.string(),project_id:d.string(),generated_at:d.string(),root_path_hash:d.string(),metadata:d.object({total_files:d.number().int().nonnegative(),total_dependencies:d.number().int().nonnegative(),total_size_bytes:d.number().int().nonnegative(),total_lines:d.number().int().nonnegative(),max_directory_depth:d.number().int().nonnegative(),language_breakdown:d.record(d.string(),d.number().int().nonnegative())}),files:d.array(d.object({id:d.string(),path_hash:d.string(),depth:d.number().int().nonnegative(),size_bytes:d.number().int().nonnegative(),estimated_lines:d.number().int().nonnegative(),extension:d.string(),is_binary:d.boolean(),import_count:d.number().int().nonnegative().optional(),function_count:d.number().int().nonnegative().optional(),class_count:d.number().int().nonnegative().optional()})),dependencies:d.array(d.object({id:d.string(),name_hash:d.string(),major_version:d.number().int().nonnegative(),minor_version:d.number().int().nonnegative(),category:d.enum(["dev","prod","peer"])}))});d.object({name:d.string().min(1).max(100)});d.object({analysis_version:d.string(),snapshot_schema_version:d.string(),total_score:d.number().min(0).max(100),severity_band:d.enum(["HEALTHY","STABLE","STRUCTURAL_CONCERN","HIGH_RISK"]),engines:d.array(d.object({engine_name:d.string(),score_impact:d.number(),risk_level:d.enum(["HEALTHY","STABLE","STRUCTURAL_CONCERN","HIGH_RISK"]),metrics:d.record(d.number()),findings:d.array(d.object({rule_id:d.string(),title:d.string(),message:d.string(),severity:d.enum(["CRITICAL","HIGH","MEDIUM","LOW"]),category:d.enum(["SECURITY","STRUCTURE","COMPLEXITY","DEPENDENCY","REPOSITORY_HYGIENE","DOCUMENTATION","QUALITY"]),evidence:d.array(d.string()).optional(),explanation:d.string().optional(),impact:d.string().optional(),effort:d.enum(["Low","Medium","High"]).optional(),recommendations:d.array(d.string()).optional()}))})),summary:d.object({total_findings:d.number().int().nonnegative(),critical_count:d.number().int().nonnegative(),high_count:d.number().int().nonnegative(),medium_count:d.number().int().nonnegative(),low_count:d.number().int().nonnegative(),categories:d.record(d.string(),d.number().int().nonnegative())}),generated_at:d.string()});var go=d.object({NEXT_PUBLIC_SUPABASE_URL:d.string().url("Invalid SUPABASE_URL"),NEXT_PUBLIC_SUPABASE_ANON_KEY:d.string().min(1,"SUPABASE_ANON_KEY is required"),SUPABASE_SERVICE_ROLE_KEY:d.string().min(1,"SERVICE_ROLE_KEY is required"),NODE_ENV:d.enum(["development","production","test"],{errorMap:()=>({message:"NODE_ENV must be development, production, or test"})}),JWT_SECRET:d.string().min(32,"JWT_SECRET must be at least 32 characters").optional()});function mo(){try{return go.parse(process.env)}catch(t){if(t instanceof d.ZodError){let e=t.errors.map(n=>n.path.join(".")).join(", ");throw new Error(`Environment validation failed:
23
24
  Missing or invalid variables: ${e}
24
- Please check your .env file and ensure all required variables are set.`)}throw t}}var pn=null;function lo(){return pn||(pn=co()),pn}new Proxy({},{get(t,e){return lo()[e]}});var Be=new Map;function uo(t=io.api.rateLimit){let{windowMs:e,maxRequests:n,message:r}=t;return {check(s){let o=Date.now(),a=Be.get(s);a&&o>a.resetTime&&Be.delete(s);let i=Be.get(s)||{count:0,resetTime:o+e};return i.count>=n?{success:false,remaining:0,resetTime:i.resetTime,error:r||"Too many requests"}:(i.count++,Be.set(s,i),{success:true,remaining:n-i.count,resetTime:i.resetTime})},reset(s){Be.delete(s);},cleanup(){let s=Date.now();for(let[o,a]of Be.entries())s>a.resetTime&&Be.delete(o);}}}uo();var fo=[".env",".env.local",".env.development",".env.production",".env.test",".env.example",".envrc",".env.*","id_rsa","id_rsa.pub","id_dsa","id_dsa.pub","id_ecdsa","id_ecdsa.pub","id_ed25519","id_ed25519.pub","*.pem","*.key","*.p12","*.pfx","*.crt","*.cer","*.der","credentials",".aws/credentials",".aws/config",".docker/config.json","kubeconfig","*.kubeconfig",".npmrc",".yarnrc",".pnpmrc",".git-credentials","*.sqlite","*.sqlite3","*.db","secrets/","secret/",".secrets/","config.json","settings.json","local.settings.json"],po=["veestack.config.json","package.json","tsconfig.json","jsconfig.json",".eslintrc.json",".prettierrc.json","README.md"],go=[{name:"AWS Access Key ID",pattern:/AKIA[0-9A-Z]{16}/g,severity:"critical",description:"AWS Access Key ID detected"},{name:"AWS Secret Access Key",pattern:/['"\s][A-Za-z0-9/+=]{40}['"\s]/g,severity:"critical",description:"Potential AWS Secret Key detected"},{name:"Private Key",pattern:/-----BEGIN (RSA |DSA |EC |OPENSSH |PGP )?PRIVATE KEY-----/g,severity:"critical",description:"Private key detected"},{name:"JWT Token",pattern:/eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/g,severity:"high",description:"JWT token detected"},{name:"Bearer Token",pattern:/Bearer\s+[a-zA-Z0-9_-]{20,}/gi,severity:"high",description:"Bearer token detected"},{name:"API Key",pattern:/(?:api[_-]?key|apikey|api_token|apiToken)['"\s]*[:=]\s*['"][a-zA-Z0-9_-]{16,}['"]/gi,severity:"high",description:"API key detected"},{name:"Password in URL",pattern:/[a-zA-Z]+:\/\/[^\s:@]+:[^\s:@]+@[^\s]+/g,severity:"high",description:"Password in URL detected"},{name:"Password Assignment",pattern:/(?:password|passwd|pwd)\s*[=:]\s*['"][^'"]{8,}['"]/gi,severity:"medium",description:"Password assignment detected"},{name:"GitHub Token",pattern:/gh[pousr]_[A-Za-z0-9_]{36,}/g,severity:"critical",description:"GitHub token detected"},{name:"Slack Token",pattern:/xox[baprs]-[0-9]{10,13}-[0-9]{10,13}(-[a-zA-Z0-9]{24})?/g,severity:"critical",description:"Slack token detected"},{name:"Generic Secret",pattern:/(?:secret|token|key)\s*[=:]\s*['"][a-zA-Z0-9_-]{20,}['"]/gi,severity:"medium",description:"Potential secret detected"},{name:"Connection String",pattern:/(?:mongodb|postgres|mysql|redis|amqp):\/\/[^\s]+/gi,severity:"high",description:"Database connection string detected"},{name:"VeeStack Token",pattern:/vs_[a-zA-Z0-9_-]{20,}/g,severity:"critical",description:"VeeStack token detected"}];function qn(t){let e=t.replace(/\\/g,"/").toLowerCase(),n=We.basename(e);for(let r of po)if(n===r.toLowerCase())return false;for(let r of fo){if(n===r.toLowerCase())return true;if(r.includes("*")){let s=r.toLowerCase().replace(/\./g,"\\.").replace(/\*/g,".*"),o=new RegExp(s);if(o.test(n)||o.test(e))return true}if(e.includes(r.toLowerCase().replace("*","")))return true}return false}function mo(t,e){let n=[],r=e.split(`
25
- `);for(let s of go){s.pattern.lastIndex=0;for(let o=0;o<r.length;o++){let a=r[o],i;for(;(i=s.pattern.exec(a))!==null;)n.push({filePath:t,type:"secret_content",secretName:s.name,severity:s.severity,description:s.description,lineNumber:o+1,match:i[0].substring(0,20)+"..."});s.pattern.lastIndex=0;}}return n}async function ho(t){let e=[];if(qn(t))return e.push({filePath:t,type:"sensitive_file",secretName:"Sensitive File",severity:"critical",description:`Sensitive file type detected: ${We.basename(t)}`}),e;try{if(ne.statSync(t).size>1024*1024)return e;let r=ne.readFileSync(t,"utf-8"),s=mo(t,r);e.push(...s);}catch{}return e}async function Yn(t,e){let n=[];for(let i of e){let c=We.join(t,i),l=await ho(c);for(let g of l)g.filePath=i,n.push(g);}let r=n.filter(i=>i.severity==="critical").length,s=n.filter(i=>i.severity==="high").length,o=n.filter(i=>i.severity==="medium").length,a=n.filter(i=>i.severity==="low").length;return {totalFiles:e.length,secretsFound:n.length,criticalCount:r,highCount:s,mediumCount:o,lowCount:a,results:n}}function Xn(t){let e=[],n=[];for(let r of t)qn(r)?n.push(r):e.push(r);return {safe:e,blocked:n}}var yo={TOKEN_BINDING_SALT:an};function Qn(t,e){let n=`${t}:${e}:${yo.TOKEN_BINDING_SALT}`;return ce.createHash("sha256").update(n).digest("hex")}function er(t,e,n,r,s="cli"){let o=new Date().toISOString(),a=wo(),i=vo(t,e,n,o,a),c=ko(o,s,i),l=_o(r,o,s,c);return {signature:l,timestamp:o,nonce:a,headers:{"X-Signature":l,"X-Timestamp":o,"X-Nonce":a,"X-Signed-Headers":"host;x-timestamp;x-nonce"}}}function vo(t,e,n,r,s){let o=ce.createHash("sha256").update(n).digest("hex");return [t.toUpperCase(),e,"",`host:www.veestack.com
25
+ Please check your .env file and ensure all required variables are set.`)}throw t}}var pn=null;function ho(){return pn||(pn=mo()),pn}new Proxy({},{get(t,e){return ho()[e]}});var Fe=new Map;function yo(t=po.api.rateLimit){let{windowMs:e,maxRequests:n,message:r}=t;return {check(s){let o=Date.now(),a=Fe.get(s);a&&o>a.resetTime&&Fe.delete(s);let i=Fe.get(s)||{count:0,resetTime:o+e};return i.count>=n?{success:false,remaining:0,resetTime:i.resetTime,error:r||"Too many requests"}:(i.count++,Fe.set(s,i),{success:true,remaining:n-i.count,resetTime:i.resetTime})},reset(s){Fe.delete(s);},cleanup(){let s=Date.now();for(let[o,a]of Fe.entries())s>a.resetTime&&Fe.delete(o);}}}yo();var vo={TOKEN_BINDING_SALT:an};function Qn(t,e){let n=`${t}:${e}:${vo.TOKEN_BINDING_SALT}`;return ae.createHash("sha256").update(n).digest("hex")}function er(t,e,n,r,s="cli"){let o=new Date().toISOString(),a=So(),i=ko(t,e,n,o,a),c=_o(o,s,i),l=wo(r,o,s,c);return {signature:l,timestamp:o,nonce:a,headers:{"X-Signature":l,"X-Timestamp":o,"X-Nonce":a,"X-Signed-Headers":"host;x-timestamp;x-nonce"}}}function ko(t,e,n,r,s){let o=ae.createHash("sha256").update(n).digest("hex");return [t.toUpperCase(),e,"",`host:www.veestack.com
26
26
  `,`x-timestamp:${r}
27
27
  `,`x-nonce:${s}
28
28
  `,"host;x-timestamp;x-nonce",o].join(`
29
- `)}function ko(t,e,n){let r=t.substring(0,10).replace(/-/g,""),s=ce.createHash("sha256").update(n).digest("hex");return ["VEESTACK-HMAC-SHA256",t,`${r}/veestack/${e}/veestack_request`,s].join(`
30
- `)}function _o(t,e,n,r){let s=e.substring(0,10).replace(/-/g,""),o=_t("VEESTACK"+t,s),a=_t(o,"veestack"),i=_t(a,n),c=_t(i,"veestack_request");return _t(c,r,"hex")}function _t(t,e,n){return ce.createHmac("sha256",t).update(e).digest(n||"hex")}function wo(){return ce.randomBytes(16).toString("hex")}var Bt=null;async function Ht(){if(Bt)return Bt;try{return Bt=await import('keytar'),Bt}catch{return null}}var Et=We.join(ct.homedir(),".veestack"),he=We.join(Et,"tokens.enc"),tr=We.join(Et,"salt"),nr=We.join(Et,".key"),Zt="VeeStack CLI",Jt="auth_tokens",So=1e5,Eo=32,xo=16;function zt(){return process.env.DEBUG?.includes("veestack")||process.env.DEBUG?.includes("*")||process.env.NODE_ENV==="development"||process.env.VEESTACK_DEBUG==="true"}async function Ao(){try{let e=await j.readFile(tr).catch(()=>null);if(e)return e}catch{}let t=ce.randomBytes(32);return await j.mkdir(Et,{recursive:true,mode:448}),await j.writeFile(tr,t,{mode:384}),t}async function rr(){try{let r=await j.readFile(nr,"utf-8").catch(()=>null);if(r){let s=Buffer.from(r,"hex");return await j.unlink(nr).catch(()=>{}),s}}catch{}let t=`${ct.userInfo().username}@${ct.hostname()}`,e=await Ao();return ce.pbkdf2Sync(t,e,So,Eo,"sha256")}function wt(t){Buffer.isBuffer(t)&&t.fill(0);}async function xt(t){let e=await Ht();if(e)try{let l=JSON.stringify(t);await e.setPassword(Zt,Jt,l),zt()&&console.log(" Tokens saved to OS Keychain");return}catch(l){zt()&&console.log(" Keychain failed, falling back to encrypted file:",l);}let n=await rr(),r=ce.randomBytes(xo),s=ce.createCipheriv("aes-256-gcm",n,r),o=JSON.stringify(t),a=Buffer.concat([s.update(o,"utf8"),s.final()]),i=s.getAuthTag(),c={iv:r.toString("hex"),data:a.toString("hex"),authTag:i.toString("hex"),timestamp:Date.now(),version:2};await j.mkdir(Et,{recursive:true,mode:448}),await j.writeFile(he,JSON.stringify(c),{mode:384}),wt(n),zt()&&console.log(" Tokens saved to encrypted file (AES-256-GCM)");}async function sr(){let t=await Ht();if(t)try{let e=await t.getPassword(Zt,Jt);if(e)return JSON.parse(e)}catch(e){zt()&&console.log("\u26A0\uFE0F Keychain read failed, trying encrypted file:",e);}try{let e=await j.readFile(he,"utf-8"),n=JSON.parse(e);if(n.version===1)return await To(n);let r=await rr(),s=null;try{let o=Buffer.from(n.iv,"hex"),a=Buffer.from(n.data,"hex"),i=Buffer.from(n.authTag,"hex"),c=ce.createDecipheriv("aes-256-gcm",r,o);c.setAuthTag(i),s=Buffer.concat([c.update(a),c.final()]);let l=JSON.parse(s.toString("utf8"));return wt(s),wt(r),l}catch(o){throw s&&wt(s),wt(r),o}}catch{return null}}async function To(t){try{return console.log("\u{1F510} Migrating from legacy encryption format..."),await j.unlink(he).catch(()=>{}),null}catch{return null}}async function Gt(){try{return await j.access(he),!0}catch{return false}}async function ze(){try{let t=await j.stat(he).catch(()=>null);if(!t)return;let e=t.size,n=3;for(let s=0;s<n;s++){let o=ce.randomBytes(e);await j.writeFile(he,o);}await j.unlink(he);let r=await Ht();r&&await r.deletePassword(Zt,Jt).catch(()=>{});}catch{}}async function or(){let t=await Ht(),e=!!t,n=false;if(t)try{n=!!await t.getPassword(Zt,Jt);}catch{}let r=false,s,o,a=0;try{let i=await j.stat(he);r=!0,s=i.mode.toString(8),o=i.size;let c=await j.readFile(he,"utf-8");a=JSON.parse(c).version||1;}catch{}return {keychainAvailable:e,keychainHasTokens:n,fileExists:r,filePermissions:s,fileSize:o,encryptionVersion:a}}var bo=[{name:"bearer_token",regex:/Bearer\s+[a-zA-Z0-9_-]{20,}/gi,replacement:"Bearer [REDACTED]"},{name:"api_key",regex:/api[_-]?key['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"api_key: [REDACTED]"},{name:"access_token",regex:/access[_-]?token['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"access_token: [REDACTED]"},{name:"refresh_token",regex:/refresh[_-]?token['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"refresh_token: [REDACTED]"},{name:"auth_token",regex:/auth[_-]?token['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"auth_token: [REDACTED]"},{name:"password",regex:/password['"\s]*[:=]\s*['"]?([^'"\s]{8,})/gi,replacement:"password: [REDACTED]"},{name:"secret",regex:/secret['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"secret: [REDACTED]"},{name:"private_key",regex:/private[_-]?key['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"private_key: [REDACTED]"},{name:"jwt_token",regex:/eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/g,replacement:"[REDACTED_JWT]"},{name:"supabase_key",regex:/eyJ[a-zA-Z0-9_-]{20,}\.[a-zA-Z0-9_-]{20,}\.[a-zA-Z0-9_-]{20,}/g,replacement:"[REDACTED_SUPABASE_KEY]"}];function He(t){if(!t||typeof t!="string")return t;let e=t;for(let n of bo)e=e.replace(n.regex,n.replacement);return e}function mn(t){return t instanceof Error?He(t.message).slice(0,500):typeof t=="string"?He(t).slice(0,500):He(String(t)).slice(0,500)}function Kt(t){if(!t||typeof t!="object")return t;let e=["token","accessToken","refreshToken","apiKey","api_key","secret","password","privateKey","private_key","authToken","auth_token","jwt","credential","credentials"];if(Array.isArray(t))return t.map(r=>Kt(r));let n={};for(let[r,s]of Object.entries(t)){let o=r.toLowerCase();e.some(a=>o.includes(a))?n[r]="[REDACTED]":typeof s=="object"&&s!==null?n[r]=Kt(s):typeof s=="string"?n[r]=He(s):n[r]=s;}return n}function At(t,e,...n){let r=He(e),s=n.map(o=>typeof o=="string"?He(o):typeof o=="object"&&o!==null?Kt(o):o);console[t](r,...s);}var ye={log:(t,...e)=>At("log",t,...e),error:(t,...e)=>At("error",t,...e),warn:(t,...e)=>At("warn",t,...e),info:(t,...e)=>At("info",t,...e),debug:(t,...e)=>At("debug",t,...e)};var hn=We.join(ct.homedir(),".veestack");We.join(hn,"config.json");var Wt=We.join(hn,"config.json"),Ro=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function Io(){try{if(!ne.existsSync(Wt))return;let t=ne.readFileSync(Wt,"utf-8"),e=JSON.parse(t);if(await Gt()){try{ne.unlinkSync(Wt);}catch{}return}let n={token:e.token,refreshToken:e.refreshToken,tokenType:e.tokenType,tokenExpiresAt:e.tokenExpiresAt,device:e.device,user:e.user,subscription:e.subscription,lastLoginAt:e.lastLoginAt,apiKey:e.apiKey};await xt(n);try{ne.unlinkSync(Wt);}catch{}ye.info("\u{1F510} Authentication migrated to encrypted storage");}catch{}}async function Y(){await Io();let t=await sr();return t?{token:t.token,tokenType:t.tokenType,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,device:t.device,user:t.user,subscription:t.subscription,lastLoginAt:t.lastLoginAt,apiKey:t.apiKey}:null}async function Je(){let t=await Y();if(!t)return false;let e=t.token!==void 0&&t.token.length>0,n=t.apiKey!==void 0&&t.apiKey.length>0;return e||n}async function No(){let t=await Y();return t&&(t.token||t.apiKey)||null}async function Po(){let t=await Y();return {id:t?.device?.id,fingerprint:t?.device?.fingerprint}}async function le(t="GET",e="",n="",r=["project:read"]){let s=await No();if(!s)return {};let o=await Y(),a=await Po();if(!a.id||!a.fingerprint||!o?.refreshToken)return {};let i=Qn(o.refreshToken,a.fingerprint),c=er(t,e,n,o.refreshToken,"cli");return {Authorization:`Bearer ${s}`,"Content-Type":"application/json","X-Device-ID":a.id,"X-CLI-Version":H,"X-Device-Fingerprint":a.fingerprint,"X-Token-Binding":i,"X-Signature":c.signature,"X-Timestamp":c.timestamp,"X-Nonce":c.nonce,"X-Scope":r.join(","),"X-Security-Version":H}}function yn(t){if(!t.tokenExpiresAt)return true;let e=new Date(t.tokenExpiresAt),n=300*1e3;return Date.now()>=e.getTime()-n}async function Oo(t){if(!t.refreshToken)return null;try{let e=await fetch(`${Ro}/api/cli/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:t.refreshToken,device_id:t.device?.id,device_fingerprint:t.device?.fingerprint})});if(e.status===401){let s=await e.json().catch(()=>({}));throw s.code==="device_mismatch"&&(await ze(),console.log(h.red(`
29
+ `)}function _o(t,e,n){let r=t.substring(0,10).replace(/-/g,""),s=ae.createHash("sha256").update(n).digest("hex");return ["VEESTACK-HMAC-SHA256",t,`${r}/veestack/${e}/veestack_request`,s].join(`
30
+ `)}function wo(t,e,n,r){let s=e.substring(0,10).replace(/-/g,""),o=kt("VEESTACK"+t,s),a=kt(o,"veestack"),i=kt(a,n),c=kt(i,"veestack_request");return kt(c,r,"hex")}function kt(t,e,n){return ae.createHmac("sha256",t).update(e).digest(n||"hex")}function So(){return ae.randomBytes(16).toString("hex")}var Ft=null;async function zt(){if(Ft)return Ft;try{return Ft=await import('keytar'),Ft}catch{return null}}var St=Ke.join(at.homedir(),".veestack"),me=Ke.join(St,"tokens.enc"),tr=Ke.join(St,"salt"),nr=Ke.join(St,".key"),Ht="VeeStack CLI",Zt="auth_tokens",Eo=1e5,xo=32,Ao=16;function Bt(){return process.env.DEBUG?.includes("veestack")||process.env.DEBUG?.includes("*")||process.env.NODE_ENV==="development"||process.env.VEESTACK_DEBUG==="true"}async function To(){try{let e=await j.readFile(tr).catch(()=>null);if(e)return e}catch{}let t=ae.randomBytes(32);return await j.mkdir(St,{recursive:true,mode:448}),await j.writeFile(tr,t,{mode:384}),t}async function rr(){try{let r=await j.readFile(nr,"utf-8").catch(()=>null);if(r){let s=Buffer.from(r,"hex");return await j.unlink(nr).catch(()=>{}),s}}catch{}let t=`${at.userInfo().username}@${at.hostname()}`,e=await To();return ae.pbkdf2Sync(t,e,Eo,xo,"sha256")}function _t(t){Buffer.isBuffer(t)&&t.fill(0);}async function Et(t){let e=await zt();if(e)try{let l=JSON.stringify(t);await e.setPassword(Ht,Zt,l),Bt()&&console.log(" Tokens saved to OS Keychain");return}catch(l){Bt()&&console.log(" Keychain failed, falling back to encrypted file:",l);}let n=await rr(),r=ae.randomBytes(Ao),s=ae.createCipheriv("aes-256-gcm",n,r),o=JSON.stringify(t),a=Buffer.concat([s.update(o,"utf8"),s.final()]),i=s.getAuthTag(),c={iv:r.toString("hex"),data:a.toString("hex"),authTag:i.toString("hex"),timestamp:Date.now(),version:2};await j.mkdir(St,{recursive:true,mode:448}),await j.writeFile(me,JSON.stringify(c),{mode:384}),_t(n),Bt()&&console.log(" Tokens saved to encrypted file (AES-256-GCM)");}async function sr(){let t=await zt();if(t)try{let e=await t.getPassword(Ht,Zt);if(e)return JSON.parse(e)}catch(e){Bt()&&console.log("\u26A0\uFE0F Keychain read failed, trying encrypted file:",e);}try{let e=await j.readFile(me,"utf-8"),n=JSON.parse(e);if(n.version===1)return await bo(n);let r=await rr(),s=null;try{let o=Buffer.from(n.iv,"hex"),a=Buffer.from(n.data,"hex"),i=Buffer.from(n.authTag,"hex"),c=ae.createDecipheriv("aes-256-gcm",r,o);c.setAuthTag(i),s=Buffer.concat([c.update(a),c.final()]);let l=JSON.parse(s.toString("utf8"));return _t(s),_t(r),l}catch(o){throw s&&_t(s),_t(r),o}}catch{return null}}async function bo(t){try{return console.log("\u{1F510} Migrating from legacy encryption format..."),await j.unlink(me).catch(()=>{}),null}catch{return null}}async function Jt(){try{return await j.access(me),!0}catch{return false}}async function Be(){try{let t=await j.stat(me).catch(()=>null);if(!t)return;let e=t.size,n=3;for(let s=0;s<n;s++){let o=ae.randomBytes(e);await j.writeFile(me,o);}await j.unlink(me);let r=await zt();r&&await r.deletePassword(Ht,Zt).catch(()=>{});}catch{}}async function or(){let t=await zt(),e=!!t,n=false;if(t)try{n=!!await t.getPassword(Ht,Zt);}catch{}let r=false,s,o,a=0;try{let i=await j.stat(me);r=!0,s=i.mode.toString(8),o=i.size;let c=await j.readFile(me,"utf-8");a=JSON.parse(c).version||1;}catch{}return {keychainAvailable:e,keychainHasTokens:n,fileExists:r,filePermissions:s,fileSize:o,encryptionVersion:a}}var Ro=[{name:"bearer_token",regex:/Bearer\s+[a-zA-Z0-9_-]{20,}/gi,replacement:"Bearer [REDACTED]"},{name:"api_key",regex:/api[_-]?key['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"api_key: [REDACTED]"},{name:"access_token",regex:/access[_-]?token['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"access_token: [REDACTED]"},{name:"refresh_token",regex:/refresh[_-]?token['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"refresh_token: [REDACTED]"},{name:"auth_token",regex:/auth[_-]?token['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"auth_token: [REDACTED]"},{name:"password",regex:/password['"\s]*[:=]\s*['"]?([^'"\s]{8,})/gi,replacement:"password: [REDACTED]"},{name:"secret",regex:/secret['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"secret: [REDACTED]"},{name:"private_key",regex:/private[_-]?key['"\s]*[:=]\s*['"]?([a-zA-Z0-9_-]{16,})/gi,replacement:"private_key: [REDACTED]"},{name:"jwt_token",regex:/eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/g,replacement:"[REDACTED_JWT]"},{name:"supabase_key",regex:/eyJ[a-zA-Z0-9_-]{20,}\.[a-zA-Z0-9_-]{20,}\.[a-zA-Z0-9_-]{20,}/g,replacement:"[REDACTED_SUPABASE_KEY]"}];function ze(t){if(!t||typeof t!="string")return t;let e=t;for(let n of Ro)e=e.replace(n.regex,n.replacement);return e}function mn(t){return t instanceof Error?ze(t.message).slice(0,500):typeof t=="string"?ze(t).slice(0,500):ze(String(t)).slice(0,500)}function Gt(t){if(!t||typeof t!="object")return t;let e=["token","accessToken","refreshToken","apiKey","api_key","secret","password","privateKey","private_key","authToken","auth_token","jwt","credential","credentials"];if(Array.isArray(t))return t.map(r=>Gt(r));let n={};for(let[r,s]of Object.entries(t)){let o=r.toLowerCase();e.some(a=>o.includes(a))?n[r]="[REDACTED]":typeof s=="object"&&s!==null?n[r]=Gt(s):typeof s=="string"?n[r]=ze(s):n[r]=s;}return n}function xt(t,e,...n){let r=ze(e),s=n.map(o=>typeof o=="string"?ze(o):typeof o=="object"&&o!==null?Gt(o):o);console[t](r,...s);}var he={log:(t,...e)=>xt("log",t,...e),error:(t,...e)=>xt("error",t,...e),warn:(t,...e)=>xt("warn",t,...e),info:(t,...e)=>xt("info",t,...e),debug:(t,...e)=>xt("debug",t,...e)};var ir="6.3.3",hn=Ke.join(at.homedir(),".veestack");Ke.join(hn,"config.json");var Kt=Ke.join(hn,"config.json"),Co=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function No(){try{if(!te.existsSync(Kt))return;let t=te.readFileSync(Kt,"utf-8"),e=JSON.parse(t);if(await Jt()){try{te.unlinkSync(Kt);}catch{}return}let n={token:e.token,refreshToken:e.refreshToken,tokenType:e.tokenType,tokenExpiresAt:e.tokenExpiresAt,device:e.device,user:e.user,subscription:e.subscription,lastLoginAt:e.lastLoginAt,apiKey:e.apiKey};await Et(n);try{te.unlinkSync(Kt);}catch{}he.info("\u{1F510} Authentication migrated to encrypted storage");}catch{}}async function q(){await No();let t=await sr();return t?{token:t.token,tokenType:t.tokenType,refreshToken:t.refreshToken,tokenExpiresAt:t.tokenExpiresAt,device:t.device,user:t.user,subscription:t.subscription,lastLoginAt:t.lastLoginAt,apiKey:t.apiKey}:null}async function Ze(){let t=await q();if(!t)return false;let e=t.token!==void 0&&t.token.length>0,n=t.apiKey!==void 0&&t.apiKey.length>0;return e||n}async function Po(){let t=await q();return t&&(t.token||t.apiKey)||null}async function Oo(){let t=await q();return {id:t?.device?.id,fingerprint:t?.device?.fingerprint}}async function ce(t="GET",e="",n="",r=["project:read"]){let s=await Po();if(!s)return {};let o=await q(),a=await Oo();if(!a.id||!a.fingerprint||!o?.refreshToken)return {};let i=Qn(o.refreshToken,a.fingerprint),c=er(t,e,n,o.refreshToken,"cli");return {Authorization:`Bearer ${s}`,"Content-Type":"application/json","X-Device-ID":a.id,"X-CLI-Version":ir,"X-Device-Fingerprint":a.fingerprint,"X-Token-Binding":i,"X-Signature":c.signature,"X-Timestamp":c.timestamp,"X-Nonce":c.nonce,"X-Scope":r.join(","),"X-Security-Version":ir}}function yn(t){if(!t.tokenExpiresAt)return true;let e=new Date(t.tokenExpiresAt),n=300*1e3;return Date.now()>=e.getTime()-n}async function Do(t){if(!t.refreshToken)return null;try{let e=await fetch(`${Co}/api/cli/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:t.refreshToken,device_id:t.device?.id,device_fingerprint:t.device?.fingerprint})});if(e.status===401){let s=await e.json().catch(()=>({}));throw s.code==="device_mismatch"&&(await Be(),console.log(h.red(`
31
31
  \u274C Security Alert: Device mismatch`)),console.log(h.yellow(`
32
- Your token was used from a different device.`)),console.log(h.gray("This could indicate a token theft attempt.")),console.log(h.gray("Please login again:")),console.log(h.cyan(" veestack login")),process.exit(1)),s.code==="device_revoked"&&(await ze(),console.log(h.red(`
32
+ Your token was used from a different device.`)),console.log(h.gray("This could indicate a token theft attempt.")),console.log(h.gray("Please login again:")),console.log(h.cyan(" veestack login")),process.exit(1)),s.code==="device_revoked"&&(await Be(),console.log(h.red(`
33
33
  \u274C Device authorization revoked`)),console.log(h.yellow(`
34
- Your device was removed from authorized devices.`)),console.log(h.gray("Please login again:")),console.log(h.cyan(" veestack login")),process.exit(1)),(s.code==="token_invalid"||s.code==="session_expired")&&(await ze(),console.log(h.red(`
34
+ Your device was removed from authorized devices.`)),console.log(h.gray("Please login again:")),console.log(h.cyan(" veestack login")),process.exit(1)),(s.code==="token_invalid"||s.code==="session_expired")&&(await Be(),console.log(h.red(`
35
35
  \u274C Session expired`)),console.log(h.yellow(`
36
- Your session has expired or your password was changed.`)),console.log(h.gray("Please login again:")),console.log(h.cyan(" veestack login")),process.exit(1)),new Error("Token refresh failed: Unauthorized")}if(!e.ok)throw new Error("Token refresh failed");let n=await e.json(),r={...t,token:n.access_token,tokenExpiresAt:new Date(Date.now()+n.expires_in*1e3).toISOString()};return n.refresh_token&&(r.refreshToken=n.refresh_token),await xt({token:r.token,refreshToken:r.refreshToken,tokenType:r.tokenType,tokenExpiresAt:r.tokenExpiresAt,device:r.device,user:r.user,subscription:r.subscription,lastLoginAt:r.lastLoginAt,apiKey:r.apiKey}),r}catch(e){return e instanceof Error&&e.message.includes("fetch")&&(ye.warn(`
37
- \u26A0\uFE0F Network error`),ye.info("Could not connect to authentication server."),ye.info("Please check your connection and try again.")),null}}async function ue(){let t=await Y();if(!t)return console.log(h.yellow(`
36
+ Your session has expired or your password was changed.`)),console.log(h.gray("Please login again:")),console.log(h.cyan(" veestack login")),process.exit(1)),new Error("Token refresh failed: Unauthorized")}if(!e.ok)throw new Error("Token refresh failed");let n=await e.json(),r={...t,token:n.access_token,tokenExpiresAt:new Date(Date.now()+n.expires_in*1e3).toISOString()};return n.refresh_token&&(r.refreshToken=n.refresh_token),await Et({token:r.token,refreshToken:r.refreshToken,tokenType:r.tokenType,tokenExpiresAt:r.tokenExpiresAt,device:r.device,user:r.user,subscription:r.subscription,lastLoginAt:r.lastLoginAt,apiKey:r.apiKey}),r}catch(e){return e instanceof Error&&e.message.includes("fetch")&&(he.warn(`
37
+ \u26A0\uFE0F Network error`),he.info("Could not connect to authentication server."),he.info("Please check your connection and try again.")),null}}async function le(){let t=await q();if(!t)return console.log(h.yellow(`
38
38
  \u26A0\uFE0F You are not logged in`)),console.log(h.gray(`
39
39
  Login to enable:`)),console.log(h.gray(" \u2022 Cloud reports")),console.log(h.gray(" \u2022 Team dashboard")),console.log(h.gray(` \u2022 Historical scans
40
- `)),console.log(h.gray("Run:")),console.log(h.cyan(" veestack login")),null;if(t.refreshToken&&yn(t)){console.log(h.yellow("Token expired, refreshing..."));let e=await Oo(t);return e?(console.log(h.green("\u2713 Token refreshed")),e):(await ze(),console.log(h.red(`
41
- \u274C Session expired`)),console.log(h.yellow("Your refresh token has expired.")),console.log(h.gray("Run: veestack login")),null)}return t}async function Yt(){let t=await Y();return !t||!t.subscription?"free":t.subscription.tier}async function cr(){let t=await Y();return !t||!t.subscription||t.subscription.tier==="free"?true:t.subscription.expiresAt?new Date(t.subscription.expiresAt)>new Date&&t.subscription.isActive:t.subscription.isActive}function lr(t){if(t.user)try{let e=join(hn,"accounts"),n=(void 0)("fs");n.mkdirSync(e,{recursive:!0});let r=join(e,`${t.user.id}.json`);n.writeFileSync(r,JSON.stringify(t,null,2),{mode:384});}catch{}}var fr=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function pr(){try{let t=await fetch(`${fr}/v1/cli/version`,{method:"GET",headers:{Accept:"application/json"}});if(t.ok){let n=(await t.json()).version;n&&n!==z&&(console.log(h.yellow(`
42
- \u2728 New version available: ${h.bold(n)} (current: ${z})`)),console.log(h.gray(` Run: ${h.cyan("veestack upgrade")} to update
43
- `)));}}catch{}}async function jo(){let t=process.cwd(),e=join(t,"package.json"),n=[{name:"Next.js",files:["next.config.js","next.config.ts","next.config.mjs"]},{name:"Nuxt.js",files:["nuxt.config.js","nuxt.config.ts"]},{name:"Vue CLI",files:["vue.config.js"]},{name:"Angular",files:["angular.json"]},{name:"SvelteKit",files:["svelte.config.js","svelte.config.ts"]},{name:"Vite",files:["vite.config.js","vite.config.ts"]},{name:"Remix",files:["remix.config.js"]},{name:"Gatsby",files:["gatsby-config.js","gatsby-config.ts"]},{name:"Astro",files:["astro.config.mjs","astro.config.js"]}];for(let r of n)for(let s of r.files)if(existsSync(join(t,s)))return {name:r.name,confidence:95};if(!existsSync(e)){if(existsSync(join(t,"requirements.txt"))){let r=readFileSync(join(t,"requirements.txt"),"utf-8").toLowerCase();if(r.includes("django"))return {name:"Django",confidence:85};if(r.includes("flask"))return {name:"Flask",confidence:85}}return existsSync(join(t,"Gemfile"))&&readFileSync(join(t,"Gemfile"),"utf-8").toLowerCase().includes("rails")?{name:"Ruby on Rails",confidence:85}:existsSync(join(t,"pom.xml"))&&readFileSync(join(t,"pom.xml"),"utf-8").toLowerCase().includes("spring-boot")?{name:"Spring Boot",confidence:85}:{name:"unknown",confidence:0}}try{let r=JSON.parse(readFileSync(e,"utf-8")),s={...r.dependencies,...r.devDependencies},o=[{name:"Next.js",primary:["next"],secondary:["next/core-web-vitals","@next/bundle-analyzer"],indicators:["app","pages"]},{name:"React",primary:["react","react-dom"],secondary:["@types/react","react-scripts","create-react-app"],indicators:["src/components","src/App.js","src/App.tsx"]},{name:"Vue",primary:["vue"],secondary:["vue-router","vuex","pinia","@vue/cli-service"],indicators:["src/views","src/components"]},{name:"Angular",primary:["@angular/core"],secondary:["@angular/cli","@angular/common","@angular/router"],indicators:["src/app"]},{name:"Svelte",primary:["svelte"],secondary:["svelte-check","@sveltejs/kit"],indicators:["src/routes"]},{name:"Express",primary:["express"],secondary:["cors","helmet","morgan","body-parser"],indicators:["routes","controllers"]},{name:"NestJS",primary:["@nestjs/core"],secondary:["@nestjs/common","@nestjs/platform-express"],indicators:["src/modules"]},{name:"Fastify",primary:["fastify"],secondary:["@fastify/cors","@fastify/helmet"],indicators:["routes"]}];for(let a of o){let i=0;for(let l of a.primary)if(s[l]){i+=70;break}let c=0;for(let l of a.secondary)s[l]&&c<2&&(i+=10,c++);for(let l of a.indicators)existsSync(join(t,l))&&(i+=10);if(i>=60)return a.name==="Next.js"&&s.next?{name:a.name,confidence:100}:{name:a.name,confidence:Math.min(i,95)}}return s.astro?{name:"Astro",confidence:80}:s.remix?{name:"Remix",confidence:80}:s.gatsby?{name:"Gatsby",confidence:80}:s.nuxt?{name:"Nuxt.js",confidence:80}:s["@sveltejs/kit"]?{name:"SvelteKit",confidence:85}:{name:"unknown",confidence:0}}catch{return {name:"unknown",confidence:0}}}async function Lo(t,e){try{let n=await le(),r=await fetch(`${fr}/v1/projects`,{method:"POST",headers:n,body:JSON.stringify({name:t,framework:e,source:"cli-init"})});if(!r.ok){let s=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(s.error||`HTTP ${r.status}`)}return await r.json()}catch(n){return ye.error("Failed to create project:",n instanceof Error?n.message:String(n)),null}}function dr(t){let e={"Next.js":["**/*.{js,jsx,ts,tsx,json,mjs,cjs}"],React:["**/*.{js,jsx,ts,tsx,json}"],Vue:["**/*.{js,jsx,ts,tsx,vue,json}"],Angular:["**/*.{ts,html,json}"],Svelte:["**/*.{js,ts,svelte,json}"],Express:["**/*.{js,ts,json}"],NestJS:["**/*.{ts,json}"],unknown:["**/*.{js,ts,jsx,tsx,json,py,go,rs,rb,php,cs,cpp,c,h}"]};return e[t]||e.unknown}function $o(){return ["node_modules/**/*",".git/**/*","dist/**/*","build/**/*",".next/**/*","coverage/**/*","*.test.ts","*.spec.ts","*.min.js"]}function Vo(t){let e=join(process.cwd(),"veestack.config.json");writeFileSync(e,JSON.stringify(t,null,2));}function Mo(){let t=join(process.cwd(),"veestack.config.json");if(existsSync(t))try{return JSON.parse(readFileSync(t,"utf-8"))}catch{return null}return null}function Uo(t){let e=process.cwd(),n=[],r=["src","app","lib","components","pages","routes","controllers","models","utils"];for(let s of r){let o=join(e,s);existsSync(o)&&n.push(`${s}/**/*`);}return n}function Fo(){let t=process.cwd(),e=join(t,".git");return existsSync(e)}function Bo(){let t=process.cwd();return existsSync(join(t,"pnpm-lock.yaml"))?"pnpm":existsSync(join(t,"yarn.lock"))?"yarn":existsSync(join(t,"package-lock.json"))?"npm":existsSync(join(t,"bun.lockb"))?"bun":"npm"}function zo(){return `Node ${process.version}`}async function Tt(t){t?.skipAuthCheck||console.log(h.bold.cyan(`
40
+ `)),console.log(h.gray("Run:")),console.log(h.cyan(" veestack login")),null;if(t.refreshToken&&yn(t)){console.log(h.yellow("Token expired, refreshing..."));let e=await Do(t);return e?(console.log(h.green("\u2713 Token refreshed")),e):(await Be(),console.log(h.red(`
41
+ \u274C Session expired`)),console.log(h.yellow("Your refresh token has expired.")),console.log(h.gray("Run: veestack login")),null)}return t}async function qt(){let t=await q();return !t||!t.subscription?"free":t.subscription.tier}async function lr(){let t=await q();return !t||!t.subscription||t.subscription.tier==="free"?true:t.subscription.expiresAt?new Date(t.subscription.expiresAt)>new Date&&t.subscription.isActive:t.subscription.isActive}function ur(t){if(t.user)try{let e=join(hn,"accounts"),n=(void 0)("fs");n.mkdirSync(e,{recursive:!0});let r=join(e,`${t.user.id}.json`);n.writeFileSync(r,JSON.stringify(t,null,2),{mode:384});}catch{}}var pr=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function gr(){try{let t=await fetch(`${pr}/v1/cli/version`,{method:"GET",headers:{Accept:"application/json"}});if(t.ok){let n=(await t.json()).version;n&&n!==J&&(console.log(h.yellow(`
42
+ \u2728 New version available: ${h.bold(n)} (current: ${J})`)),console.log(h.gray(` Run: ${h.cyan("veestack upgrade")} to update
43
+ `)));}}catch{}}async function Lo(){let t=process.cwd(),e=join(t,"package.json"),n=[{name:"Next.js",files:["next.config.js","next.config.ts","next.config.mjs"]},{name:"Nuxt.js",files:["nuxt.config.js","nuxt.config.ts"]},{name:"Vue CLI",files:["vue.config.js"]},{name:"Angular",files:["angular.json"]},{name:"SvelteKit",files:["svelte.config.js","svelte.config.ts"]},{name:"Vite",files:["vite.config.js","vite.config.ts"]},{name:"Remix",files:["remix.config.js"]},{name:"Gatsby",files:["gatsby-config.js","gatsby-config.ts"]},{name:"Astro",files:["astro.config.mjs","astro.config.js"]}];for(let r of n)for(let s of r.files)if(existsSync(join(t,s)))return {name:r.name,confidence:95};if(!existsSync(e)){if(existsSync(join(t,"requirements.txt"))){let r=readFileSync(join(t,"requirements.txt"),"utf-8").toLowerCase();if(r.includes("django"))return {name:"Django",confidence:85};if(r.includes("flask"))return {name:"Flask",confidence:85}}return existsSync(join(t,"Gemfile"))&&readFileSync(join(t,"Gemfile"),"utf-8").toLowerCase().includes("rails")?{name:"Ruby on Rails",confidence:85}:existsSync(join(t,"pom.xml"))&&readFileSync(join(t,"pom.xml"),"utf-8").toLowerCase().includes("spring-boot")?{name:"Spring Boot",confidence:85}:{name:"unknown",confidence:0}}try{let r=JSON.parse(readFileSync(e,"utf-8")),s={...r.dependencies,...r.devDependencies},o=[{name:"Next.js",primary:["next"],secondary:["next/core-web-vitals","@next/bundle-analyzer"],indicators:["app","pages"]},{name:"React",primary:["react","react-dom"],secondary:["@types/react","react-scripts","create-react-app"],indicators:["src/components","src/App.js","src/App.tsx"]},{name:"Vue",primary:["vue"],secondary:["vue-router","vuex","pinia","@vue/cli-service"],indicators:["src/views","src/components"]},{name:"Angular",primary:["@angular/core"],secondary:["@angular/cli","@angular/common","@angular/router"],indicators:["src/app"]},{name:"Svelte",primary:["svelte"],secondary:["svelte-check","@sveltejs/kit"],indicators:["src/routes"]},{name:"Express",primary:["express"],secondary:["cors","helmet","morgan","body-parser"],indicators:["routes","controllers"]},{name:"NestJS",primary:["@nestjs/core"],secondary:["@nestjs/common","@nestjs/platform-express"],indicators:["src/modules"]},{name:"Fastify",primary:["fastify"],secondary:["@fastify/cors","@fastify/helmet"],indicators:["routes"]}];for(let a of o){let i=0;for(let l of a.primary)if(s[l]){i+=70;break}let c=0;for(let l of a.secondary)s[l]&&c<2&&(i+=10,c++);for(let l of a.indicators)existsSync(join(t,l))&&(i+=10);if(i>=60)return a.name==="Next.js"&&s.next?{name:a.name,confidence:100}:{name:a.name,confidence:Math.min(i,95)}}return s.astro?{name:"Astro",confidence:80}:s.remix?{name:"Remix",confidence:80}:s.gatsby?{name:"Gatsby",confidence:80}:s.nuxt?{name:"Nuxt.js",confidence:80}:s["@sveltejs/kit"]?{name:"SvelteKit",confidence:85}:{name:"unknown",confidence:0}}catch{return {name:"unknown",confidence:0}}}async function $o(t,e){try{let n=await ce(),r=await fetch(`${pr}/v1/projects`,{method:"POST",headers:n,body:JSON.stringify({name:t,framework:e,source:"cli-init"})});if(!r.ok){let s=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(s.error||`HTTP ${r.status}`)}return await r.json()}catch(n){return he.error("Failed to create project:",n instanceof Error?n.message:String(n)),null}}function fr(t){let e={"Next.js":["**/*.{js,jsx,ts,tsx,json,mjs,cjs}"],React:["**/*.{js,jsx,ts,tsx,json}"],Vue:["**/*.{js,jsx,ts,tsx,vue,json}"],Angular:["**/*.{ts,html,json}"],Svelte:["**/*.{js,ts,svelte,json}"],Express:["**/*.{js,ts,json}"],NestJS:["**/*.{ts,json}"],unknown:["**/*.{js,ts,jsx,tsx,json,py,go,rs,rb,php,cs,cpp,c,h}"]};return e[t]||e.unknown}function Vo(){return ["node_modules/**/*",".git/**/*","dist/**/*","build/**/*",".next/**/*","coverage/**/*","*.test.ts","*.spec.ts","*.min.js"]}function Mo(t){let e=join(process.cwd(),"veestack.config.json");writeFileSync(e,JSON.stringify(t,null,2));}function Uo(){let t=join(process.cwd(),"veestack.config.json");if(existsSync(t))try{return JSON.parse(readFileSync(t,"utf-8"))}catch{return null}return null}function Fo(t){let e=process.cwd(),n=[],r=["src","app","lib","components","pages","routes","controllers","models","utils"];for(let s of r){let o=join(e,s);existsSync(o)&&n.push(`${s}/**/*`);}return n}function Bo(){let t=process.cwd(),e=join(t,".git");return existsSync(e)}function zo(){let t=process.cwd();return existsSync(join(t,"pnpm-lock.yaml"))?"pnpm":existsSync(join(t,"yarn.lock"))?"yarn":existsSync(join(t,"package-lock.json"))?"npm":existsSync(join(t,"bun.lockb"))?"bun":"npm"}function Ho(){return `Node ${process.version}`}async function At(t){t?.skipAuthCheck||console.log(h.bold.cyan(`
44
44
  \u{1F680} Initializing VeeStack...
45
- `));let e=false;t?.skipAuthCheck||(e=await ue()!==null);let n=Mo();if(n?.projectId&&!t?.ci&&t?.interactive){let{overwrite:x}=await ur({type:"confirm",name:"overwrite",message:`Project already linked to ${n.name||n.projectId}. Re-initialize?`,initial:false});if(!x){console.log(h.gray(`
45
+ `));let e=false;t?.skipAuthCheck||(e=await le()!==null);let n=Uo();if(n?.projectId&&!t?.ci&&t?.interactive){let{overwrite:x}=await dr({type:"confirm",name:"overwrite",message:`Project already linked to ${n.name||n.projectId}. Re-initialize?`,initial:false});if(!x){console.log(h.gray(`
46
46
  Cancelled. Existing configuration preserved.
47
- `));return}}let r=await jo();r.confidence>70?console.log(h.green(`\u2714 Framework detected: ${r.name}`)):r.confidence>0?console.log(h.yellow(`\u26A0 Framework detected: ${r.name} (low confidence)`)):console.log(h.yellow("\u26A0 Could not detect framework"));let s=Uo(r.name);s.length>0&&console.log(h.green(`\u2714 Structure detected: ${s.length} source directories`));let o=Bo(),a=zo();console.log(h.green(`\u2714 Package manager: ${o}`)),console.log(h.green(`\u2714 Runtime: ${a}`)),Fo()&&console.log(h.green("\u2714 Git repository detected"));let i="",c=join(process.cwd(),"package.json");if(existsSync(c))try{i=JSON.parse(readFileSync(c,"utf-8")).name||"";}catch{}i||(i=process.cwd().split(/[\\/]/).pop()||"my-project");let l;if(!(t?.interactive||r.confidence<30)||t?.ci)l={projectName:i,framework:r.name!=="unknown"?r.name:"Unknown",scanPatterns:s.length>0?s:dr(r.name),createProject:false},console.log(h.gray(`
47
+ `));return}}let r=await Lo();r.confidence>70?console.log(h.green(`\u2714 Framework detected: ${r.name}`)):r.confidence>0?console.log(h.yellow(`\u26A0 Framework detected: ${r.name} (low confidence)`)):console.log(h.yellow("\u26A0 Could not detect framework"));let s=Fo(r.name);s.length>0&&console.log(h.green(`\u2714 Structure detected: ${s.length} source directories`));let o=zo(),a=Ho();console.log(h.green(`\u2714 Package manager: ${o}`)),console.log(h.green(`\u2714 Runtime: ${a}`)),Bo()&&console.log(h.green("\u2714 Git repository detected"));let i="",c=join(process.cwd(),"package.json");if(existsSync(c))try{i=JSON.parse(readFileSync(c,"utf-8")).name||"";}catch{}i||(i=process.cwd().split(/[\\/]/).pop()||"my-project");let l;if(!(t?.interactive||r.confidence<30)||t?.ci)l={projectName:i,framework:r.name!=="unknown"?r.name:"Unknown",scanPatterns:s.length>0?s:fr(r.name),createProject:false},console.log(h.gray(`
48
48
  Project name: ${i}`)),console.log(h.gray(`Framework: ${l.framework}`)),console.log(h.gray(`Scan directories: ${l.scanPatterns.join(", ")}`));else if(console.log(h.gray(`
49
49
  Configure your project:
50
- `)),l=await ur([{type:"text",name:"projectName",message:"Project name:",initial:i||"my-project",validate:x=>x.length>0||"Project name is required"},{type:"text",name:"framework",message:"Framework:",initial:r.name!=="unknown"?r.name:"Unknown"},{type:"multiselect",name:"scanPatterns",message:"Select directories to scan:",choices:dr(r.name).map(x=>({title:x,value:x,selected:true})),hint:"Space to toggle, Enter to confirm"},{type:e?"confirm":null,name:"createProject",message:"Create project on VeeStack dashboard?",initial:true}],{onCancel:()=>{console.log(h.gray(`
50
+ `)),l=await dr([{type:"text",name:"projectName",message:"Project name:",initial:i||"my-project",validate:x=>x.length>0||"Project name is required"},{type:"text",name:"framework",message:"Framework:",initial:r.name!=="unknown"?r.name:"Unknown"},{type:"multiselect",name:"scanPatterns",message:"Select directories to scan:",choices:fr(r.name).map(x=>({title:x,value:x,selected:true})),hint:"Space to toggle, Enter to confirm"},{type:e?"confirm":null,name:"createProject",message:"Create project on VeeStack dashboard?",initial:true}],{onCancel:()=>{console.log(h.gray(`
51
51
  Cancelled.
52
52
  `)),process.exit(0);}}),!l.projectName){console.log(h.gray(`
53
53
  Cancelled.
54
54
  `));return}let w;if(l.createProject){console.log(h.gray(`
55
- Creating project on VeeStack...`));let x=await Lo(l.projectName,l.framework);x?(w=x.id,console.log(h.green("\u2714 Project created"))):console.log(h.yellow("\u26A0\uFE0F Could not create project on server (offline mode)"));}let b={projectId:w,name:l.projectName,framework:l.framework,scanPatterns:l.scanPatterns,excludePatterns:$o()};if(Vo(b),t?.skipNextSteps){console.log(h.green(`
55
+ Creating project on VeeStack...`));let x=await $o(l.projectName,l.framework);x?(w=x.id,console.log(h.green("\u2714 Project created"))):console.log(h.yellow("\u26A0\uFE0F Could not create project on server (offline mode)"));}let b={projectId:w,name:l.projectName,framework:l.framework,scanPatterns:l.scanPatterns,excludePatterns:Vo()};if(Mo(b),t?.skipNextSteps){console.log(h.green(`
56
56
  \u2714 Configuration saved to veestack.config.json`));return}console.log(h.green(`
57
57
  \u2714 Configuration saved to veestack.config.json`)),console.log(h.bold(`
58
58
  Next steps:`)),console.log(h.gray(" 1. Run analysis:")),console.log(h.cyan(" veestack scan")),console.log(h.gray(" 2. Upload results:")),console.log(h.cyan(" veestack upload")),console.log(h.gray(" 3. View in dashboard:")),console.log(h.cyan(` https://www.veestack.com/dashboard${w?`/projects/${w}`:""}
59
- `));}function qo(t){let e={},n=t.split(/\r?\n/),r=false,s=null;for(let o of n){let a=o.replace(/\t/g," "),i=a.trim();if(!r){/^packages\s*:\s*$/.test(i)&&(r=true,s=a.match(/^\s*/)?.[0].length??0);continue}if(i!==""&&!i.startsWith("#")){let C=a.match(/^\s*/)?.[0].length??0;if(s!==null&&C<=s)break}let c=i.match(/^\/?([^\s]+)\s*:\s*$/);if(!c)continue;let g=c[1].replace(/^\/+/,""),w=g.lastIndexOf("@");if(w<=0)continue;let b=g.slice(0,w),x=g.slice(w+1);!b||!x||/^\d+\./.test(x)&&(e[b]=x);}return e}function Yo(){if(process.env.GITHUB_ACTIONS){let[t,e]=(process.env.GITHUB_REPOSITORY||"").split("/");return {provider:"github_actions",repo_owner:t,repo_name:e,commit_sha:process.env.GITHUB_SHA,run_id:process.env.GITHUB_RUN_ID,event_name:process.env.GITHUB_EVENT_NAME,pr_number:process.env.GITHUB_REF?.includes("refs/pull/")?parseInt(process.env.GITHUB_REF.split("/")[2]):void 0}}}function gr(t,e){t.metadata.total_files;let r=25,s=15,o=5,a=2,i=0,c={critical:0,high:0,medium:0,low:0};e&&(c.critical=e.criticalCount||0,c.high=e.highCount||0,c.medium=e.mediumCount||0,c.low=e.lowCount||0,i+=c.critical*r,i+=c.high*s,i+=c.medium*o,i+=c.low*a);let l=100-i;l<0&&(l=0);let g="A+";return l===100?g="A+":l>=90?g="A":l>=80?g="B":l>=70?g="C":l>=60?g="D":g="F",{score:l,grade:g,breakdown:c}}async function kn(t){let e=t.quiet||t.json,n=resolve(t.path);e||(console.log(h.bold.cyan(`
60
- VeeStack Security Scan`)),console.log(h.gray("\u2500".repeat(40))));await ue()!==null;let o=join(n,"veestack.config.json");if(!existsSync(o)&&!t.json&&!e){console.log(h.cyan(`
59
+ `));}function Yo(t){let e={},n=t.split(/\r?\n/),r=false,s=null;for(let o of n){let a=o.replace(/\t/g," "),i=a.trim();if(!r){/^packages\s*:\s*$/.test(i)&&(r=true,s=a.match(/^\s*/)?.[0].length??0);continue}if(i!==""&&!i.startsWith("#")){let C=a.match(/^\s*/)?.[0].length??0;if(s!==null&&C<=s)break}let c=i.match(/^\/?([^\s]+)\s*:\s*$/);if(!c)continue;let g=c[1].replace(/^\/+/,""),w=g.lastIndexOf("@");if(w<=0)continue;let b=g.slice(0,w),x=g.slice(w+1);!b||!x||/^\d+\./.test(x)&&(e[b]=x);}return e}function Xo(){if(process.env.GITHUB_ACTIONS){let[t,e]=(process.env.GITHUB_REPOSITORY||"").split("/");return {provider:"github_actions",repo_owner:t,repo_name:e,commit_sha:process.env.GITHUB_SHA,run_id:process.env.GITHUB_RUN_ID,event_name:process.env.GITHUB_EVENT_NAME,pr_number:process.env.GITHUB_REF?.includes("refs/pull/")?parseInt(process.env.GITHUB_REF.split("/")[2]):void 0}}}function mr(t,e){t.metadata.total_files;let r=25,s=15,o=5,a=2,i=0,c={critical:0,high:0,medium:0,low:0};e&&(c.critical=e.criticalCount||0,c.high=e.highCount||0,c.medium=e.mediumCount||0,c.low=e.lowCount||0,i+=c.critical*r,i+=c.high*s,i+=c.medium*o,i+=c.low*a);let l=100-i;l<0&&(l=0);let g="A+";return l===100?g="A+":l>=90?g="A":l>=80?g="B":l>=70?g="C":l>=60?g="D":g="F",{score:l,grade:g,breakdown:c}}async function kn(t){let e=t.quiet||t.json,n=resolve(t.path);e||(console.log(h.bold.cyan(`
60
+ VeeStack Security Scan`)),console.log(h.gray("\u2500".repeat(40))));await le()!==null;let o=join(n,"veestack.config.json");if(!existsSync(o)&&!t.json&&!e){console.log(h.cyan(`
61
61
  \u2728 First time using VeeStack in this project`)),console.log(h.gray(`We need to create a configuration file.
62
- `));let{runInit:i}=await ur({type:"confirm",name:"runInit",message:"Would you like to run 'veestack init' first?",initial:true});i?(await Tt({skipAuthCheck:true,skipNextSteps:true}),existsSync(o)||(console.log(h.red(`
62
+ `));let{runInit:i}=await dr({type:"confirm",name:"runInit",message:"Would you like to run 'veestack init' first?",initial:true});i?(await At({skipAuthCheck:true,skipNextSteps:true}),existsSync(o)||(console.log(h.red(`
63
63
  \u274C Initialization failed. Please run 'veestack init' manually.`)),process.exit(1))):console.log(h.gray(`
64
- Using smart defaults for this scan...`));}let a=Jo({text:"Preparing scan...",spinner:"dots",stream:process.stdout});e||(console.log(`
64
+ Using smart defaults for this scan...`));}let a=Go({text:"Preparing scan...",spinner:"dots",stream:process.stdout});e||(console.log(`
65
65
  `+h.bold.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")),console.log(h.bold.white(" Analyzing Project")),console.log(h.bold.cyan(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
66
- `)),a.start());try{let i=Date.now(),c=existsSync(o)?JSON.parse(readFileSync(o,"utf-8")):{scanPatterns:["src/**/*","app/**/*","lib/**/*","components/**/*","pages/**/*"],excludePatterns:["node_modules/**/*",".git/**/*","dist/**/*","build/**/*",".next/**/*"]},l=c.scanPatterns||["**/*.{js,jsx,ts,tsx,json,py,go,rs,rb,php,cs,cpp,c,h,mjs,cjs,svelte,vue,html}"],g=c.excludePatterns||["**/node_modules/**","**/.next/**","**/dist/**","**/build/**","**/.git/**","**/.turbo/**","**/coverage/**","**/*.test.ts","**/*.spec.ts","**/*.min.js"],w=await ei(n,l,g,t.diff),b=w.map(G=>G.path);if(e||(console.log(h.gray(`
66
+ `)),a.start());try{let i=Date.now(),c=existsSync(o)?JSON.parse(readFileSync(o,"utf-8")):{scanPatterns:["src/**/*","app/**/*","lib/**/*","components/**/*","pages/**/*"],excludePatterns:["node_modules/**/*",".git/**/*","dist/**/*","build/**/*",".next/**/*"]},l=c.scanPatterns||["**/*.{js,jsx,ts,tsx,json,py,go,rs,rb,php,cs,cpp,c,h,mjs,cjs,svelte,vue,html}"],g=c.excludePatterns||["**/node_modules/**","**/.next/**","**/dist/**","**/build/**","**/.git/**","**/.turbo/**","**/coverage/**","**/*.test.ts","**/*.spec.ts","**/*.min.js"],w=await ti(n,l,g,t.diff),b=w.map(Z=>Z.path);if(e||(console.log(h.gray(`
67
67
  Found ${h.white(b.length)} source files`)),console.log(h.gray("Analyzing project files..."))),b.length===0&&!t.json){e||(console.log(h.yellow(`
68
68
  \u26A0\uFE0F No source files found to scan.`)),console.log(h.gray(`
69
- Checked patterns:`)),l.forEach(G=>console.log(h.gray(` \u2022 ${G}`))),console.log(h.gray(`
69
+ Checked patterns:`)),l.forEach(Z=>console.log(h.gray(` \u2022 ${Z}`))),console.log(h.gray(`
70
70
  Try running from the project root`)),console.log(h.gray(`or update scanPatterns in veestack.config.json
71
- `)));return}let x=new Ko.SingleBar({format:"Scanning |"+h.cyan("{bar}")+"| {percentage}% ({value}/{total} files)",barCompleteChar:"\u2588",barIncompleteChar:"\u2591",hideCursor:!0});e||x.start(b.length,0),e||(a.text="Analyzing security...");let C=await Yn(n,b);e||x.update(Math.floor(b.length*.5));let B=gr({metadata:{total_files:b.length}},C);if(t.json){let G={version:z,timestamp:new Date().toISOString(),score:B.score,grade:B.grade,files:b.length,issues:B.breakdown,project:resolve(t.path).split(/[\\/]/).pop()};console.log(JSON.stringify(G,null,2)),process.exit(0);}C.criticalCount>0&&(e||(x.stop(),a.fail("Security validation failed"),console.log(h.red(`
71
+ `)));return}let x=new Wo.SingleBar({format:"Scanning |"+h.cyan("{bar}")+"| {percentage}% ({value}/{total} files)",barCompleteChar:"\u2588",barIncompleteChar:"\u2591",hideCursor:!0});e||x.start(b.length,0),e||(a.text="Analyzing security...");let C=await Mn(n,b);e||x.update(Math.floor(b.length*.5));let B=mr({metadata:{total_files:b.length}},C);if(t.json){let Z={version:J,timestamp:new Date().toISOString(),score:B.score,grade:B.grade,files:b.length,issues:B.breakdown,project:resolve(t.path).split(/[\\/]/).pop()};console.log(JSON.stringify(Z,null,2)),process.exit(0);}C.criticalCount>0&&(e||(x.stop(),a.fail("Security validation failed"),console.log(h.red(`
72
72
  \u274C Critical security risks detected.`)),console.log(h.yellow("For your protection, local snapshot generation is blocked.")),console.log(h.gray(`
73
73
  Please review your environment variables and configuration files.`)),console.log(h.gray(`Once resolved, run the scan again to prepare for cloud analysis.
74
- `))),process.exit(1));let{safe:de,blocked:Pt}=Xn(b),nn=w.filter(G=>de.includes(G.path)),J=await Xo(n,nn);e||(x.update(b.length),x.stop());let Dr=((Date.now()-i)/1e3).toFixed(1);if(e)console.log(h.green(`\u2714 Scan completed. Score: ${B.grade}`));else {if(a.succeed(`Analysis prepared in ${Dr}s`),console.log(`
74
+ `))),process.exit(1));let{safe:ue,blocked:Nt}=Un(b),nn=w.filter(Z=>ue.includes(Z.path)),H=await Qo(n,nn);e||(x.update(b.length),x.stop());let jr=((Date.now()-i)/1e3).toFixed(1);if(e)console.log(h.green(`\u2714 Scan completed. Score: ${B.grade}`));else {if(a.succeed(`Analysis prepared in ${jr}s`),console.log(`
75
75
  `+h.bold.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")),console.log(h.bold.white(" VeeStack Security Summary")),console.log(h.bold.cyan(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
76
76
  `)),console.log(h.bold("Status: ")+h.yellow("Analysis Pending Cloud Review")),console.log(h.gray(`Your project snapshot has been safely generated.
77
- `)),Object.keys(J.metadata.language_breakdown).length>0){let G=new Go({head:[h.cyan("Language"),h.cyan("Files")],style:{head:[],border:["gray"]}});Object.entries(J.metadata.language_breakdown).sort(([,ft],[,pt])=>pt-ft).slice(0,5).forEach(([ft,pt])=>G.push([ft,pt])),console.log(h.bold("Languages detected")),console.log(G.toString()+`
77
+ `)),Object.keys(H.metadata.language_breakdown).length>0){let Z=new Ko({head:[h.cyan("Language"),h.cyan("Files")],style:{head:[],border:["gray"]}});Object.entries(H.metadata.language_breakdown).sort(([,dt],[,ft])=>ft-dt).slice(0,5).forEach(([dt,ft])=>Z.push([dt,ft])),console.log(h.bold("Languages detected")),console.log(Z.toString()+`
78
78
  `);}else console.log(h.bold("Languages detected")),console.log(h.gray(`No source languages detected.
79
- `));console.log(h.bold("Summary")),console.log(h.gray(` \u2022 Files: ${J.metadata.total_files}`)),console.log(h.gray(` \u2022 Dependencies: ${J.metadata.total_dependencies}`)),console.log(h.gray(` \u2022 Project: ${resolve(t.path).split(/[\\/]/).pop()}`)),console.log(h.gray(` \u2022 Score: ${B.score}`)),console.log(h.gray(` \u2022 Grade: ${B.grade}`)),console.log(`
79
+ `));console.log(h.bold("Summary")),console.log(h.gray(` \u2022 Files: ${H.metadata.total_files}`)),console.log(h.gray(` \u2022 Dependencies: ${H.metadata.total_dependencies}`)),console.log(h.gray(` \u2022 Project: ${resolve(t.path).split(/[\\/]/).pop()}`)),console.log(h.gray(` \u2022 Score: ${B.score}`)),console.log(h.gray(` \u2022 Grade: ${B.grade}`)),console.log(`
80
80
  `+h.gray("\u2500".repeat(40))),console.log(h.green(`
81
- \u{1F389} Snapshot ready for upload`));}let rn=await import('fs/promises');await rn.writeFile(t.output,JSON.stringify(J,null,2));try{let G=gr(J,C),ft=join(process.env.HOME||process.env.USERPROFILE||"",".veestack","last-scan.json"),pt={timestamp:new Date().toISOString(),score:G.score,grade:G.grade,issues:C.secretsFound,project:resolve(t.path).split(/[\\/]/).pop()};await rn.mkdir(join(process.env.HOME||process.env.USERPROFILE||"",".veestack"),{recursive:!0}),await rn.writeFile(ft,JSON.stringify(pt,null,2));}catch{}console.log(`
82
- \u2705 Snapshot saved to ${t.output}`),Je?(console.log(h.bold(`
81
+ \u{1F389} Snapshot ready for upload`));}let rn=await import('fs/promises');await rn.writeFile(t.output,JSON.stringify(H,null,2));try{let Z=mr(H,C),dt=join(process.env.HOME||process.env.USERPROFILE||"",".veestack","last-scan.json"),ft={timestamp:new Date().toISOString(),score:Z.score,grade:Z.grade,issues:C.secretsFound,project:resolve(t.path).split(/[\\/]/).pop()};await rn.mkdir(join(process.env.HOME||process.env.USERPROFILE||"",".veestack"),{recursive:!0}),await rn.writeFile(dt,JSON.stringify(ft,null,2));}catch{}console.log(`
82
+ \u2705 Snapshot saved to ${t.output}`),Ze?(console.log(h.bold(`
83
83
  Next step`)),console.log(h.gray(`
84
84
  Upload results to cloud:`)),console.log(h.cyan(" veestack upload"))):(console.log(h.bold(`
85
85
  Next step`)),console.log(h.gray(`
86
86
  Upload results to cloud:`)),console.log(h.cyan(" veestack upload snapshot.json")));}catch(i){a.fail("Scan failed"),console.error(h.red(`
87
87
  \u274C Error:`),i),console.log(h.gray(`
88
- Possible causes:`)),console.log(h.gray(" \u2022 Invalid project path")),console.log(h.gray(" \u2022 Permission denied")),console.log(h.gray(" \u2022 No package.json found")),process.exit(1);}}async function Xo(t,e){let n=await ti(t),r={total_files:e.length,total_dependencies:n.length,total_size_bytes:e.reduce((s,o)=>s+o.size_bytes,0),total_lines:e.reduce((s,o)=>s+(o.estimated_lines||0),0),max_directory_depth:Math.max(...e.map(s=>s.depth),0),language_breakdown:ni(e)};return {snapshot_version:Xe,engine_target_version:Qe,project_id:ce__default.randomUUID(),generated_at:new Date().toISOString(),root_path_hash:_n(t),project_root:resolve(t),metadata:r,files:e,dependencies:n,ci_metadata:Yo()}}async function Qo(t){try{return execSync("git diff --name-only HEAD",{cwd:t,encoding:"utf-8"}).split(`
89
- `).filter(Boolean)}catch{return console.error(h.yellow("\u26A0\uFE0F Failed to get git diff. Falling back to full scan.")),[]}}async function ei(t,e,n,r=false){let s=[],o=[];if(r){let i=await Qo(t);i.length>0?(o=await glob(e,{cwd:t,ignore:n,nodir:true,dot:true,absolute:false}),o=o.filter(c=>i.includes(c))):(console.log(h.gray("No changes detected via git diff. Scanning all files.")),o=await glob(e,{cwd:t,ignore:n,nodir:true,dot:true,absolute:false}));}else o=await glob(e,{cwd:t,ignore:n,nodir:true,dot:true,absolute:false});let a=o.filter(i=>{let c=i.replace(/\\/g,"/");return !c.includes("node_modules/")&&!c.startsWith("node_modules/")&&!c.includes("/node_modules/")&&!c.includes(".next/")&&!c.startsWith(".next/")});for(let i of a){let c=join(t,i),l=statSync(c);if(l.isFile()){let g={id:ce__default.randomUUID(),path:i,path_hash:_n(i),depth:i.split(/[\\/]/).length,size_bytes:l.size,estimated_lines:Math.floor(l.size/50),extension:i.split(".").pop()||"",is_binary:si(i)};s.push(g);}}return s.sort((i,c)=>i.path_hash.localeCompare(c.path_hash))}async function ti(t){let e=[];try{let n=join(t,"package.json");if(!existsSync(n))return [];let r=JSON.parse(readFileSync(n,"utf-8")),s={...r.dependencies||{},...r.devDependencies||{},...r.peerDependencies||{}},o=join(t,"pnpm-lock.yaml"),a=join(t,"package-lock.json"),i=join(t,"yarn.lock"),c={};if(existsSync(o))try{let g=readFileSync(o,"utf8");c=qo(g);}catch{console.error(h.yellow("\u26A0\uFE0F Failed to parse pnpm-lock.yaml"));}else if(existsSync(a))try{let w=JSON.parse(readFileSync(a,"utf8")).packages||{};for(let[b,x]of Object.entries(w)){if(b==="")continue;let C=b.replace("node_modules/","");x.version&&(c[C]=x.version);}}catch{console.error(h.yellow("\u26A0\uFE0F Failed to parse package-lock.json"));}let l=(g,w)=>{for(let[b,x]of Object.entries(g)){let C=c[b]||x.replace(/[\^~]/,""),B=C.match(/^(\d+)\.(\d+)/),de=B?parseInt(B[1]):0,Pt=B?parseInt(B[2]):0;e.push({id:ce__default.randomUUID(),name:b,name_hash:_n(b),version:C,major_version:de,minor_version:Pt,category:w,vulnerabilities:[]});}};r.dependencies&&l(r.dependencies,"prod"),r.devDependencies&&l(r.devDependencies,"dev"),r.peerDependencies&&l(r.peerDependencies,"peer");}catch{}return e.sort((n,r)=>n.name_hash.localeCompare(r.name_hash))}function ni(t){let e={};for(let n of t){let r=n.extension.toLowerCase(),s=ri(r);e[s]=(e[s]||0)+1;}return e}function ri(t){return {ts:"TypeScript",js:"JavaScript",tsx:"TypeScript",jsx:"JavaScript",py:"Python",go:"Go",rs:"Rust",java:"Java",kt:"Kotlin",rb:"Ruby",php:"PHP",cs:"C#",cpp:"C++",c:"C",h:"C",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",html:"HTML",css:"CSS",scss:"SCSS",sql:"SQL",sh:"Shell"}[t]||"Other"}function si(t){let e=[".exe",".dll",".so",".dylib",".bin",".png",".jpg",".jpeg",".gif",".pdf",".zip",".tar",".gz",".7z",".woff",".woff2",".ttf",".eot"],n=t.split(".").pop()?.toLowerCase();return n?e.includes("."+n):false}function _n(t){return ce__default.createHash("sha256").update(t).digest("hex")}var wn=process.env.VEESTACK_API_URL||"https://www.veestack.com",mr=process.env.VEESTACK_DASHBOARD_URL||"https://www.veestack.com/dashboard",li=3e4;async function Sn(t,e={}){let{timeout:n=li}=e,r=new AbortController,s=setTimeout(()=>r.abort(),n);try{let o=await fetch(t,{...e,signal:r.signal});return clearTimeout(s),o}catch(o){throw clearTimeout(s),o instanceof Error&&o.name==="AbortError"?new Error(`Request timed out after ${n/1e3}s. Please check your connection.`):o}}async function ui(){try{let t=await le("GET","/api/projects"),e=await Sn(`${wn}/api/projects`,{headers:t});return e.ok?(await e.json()).projects||[]:[]}catch{return []}}async function hr(t){try{let e=JSON.stringify({name:t}),n=await le("POST","/api/projects",e),r=await Sn(`${wn}/api/projects`,{method:"POST",headers:n,body:e});if(r.ok){let s=await r.json();return s.project?.id||s.id||null}return null}catch{return null}}function en(t){let e=ai.createInterface({input:process.stdin,output:process.stdout});return new Promise(n=>{e.question(t,r=>{e.close(),n(r);});})}async function di(){console.log(h.blue(`
88
+ Possible causes:`)),console.log(h.gray(" \u2022 Invalid project path")),console.log(h.gray(" \u2022 Permission denied")),console.log(h.gray(" \u2022 No package.json found")),process.exit(1);}}async function Qo(t,e){let n=await ni(t),r={total_files:e.length,total_dependencies:n.length,total_size_bytes:e.reduce((s,o)=>s+o.size_bytes,0),total_lines:e.reduce((s,o)=>s+(o.estimated_lines||0),0),max_directory_depth:Math.max(...e.map(s=>s.depth),0),language_breakdown:ri(e)};return {snapshot_version:Ye,engine_target_version:Xe,project_id:ae__default.randomUUID(),generated_at:new Date().toISOString(),root_path_hash:_n(t),project_root:resolve(t),metadata:r,files:e,dependencies:n,ci_metadata:Xo()}}async function ei(t){try{return execSync("git diff --name-only HEAD",{cwd:t,encoding:"utf-8"}).split(`
89
+ `).filter(Boolean)}catch{return console.error(h.yellow("\u26A0\uFE0F Failed to get git diff. Falling back to full scan.")),[]}}async function ti(t,e,n,r=false){let s=[],o=[];if(r){let i=await ei(t);i.length>0?(o=await glob(e,{cwd:t,ignore:n,nodir:true,dot:true,absolute:false}),o=o.filter(c=>i.includes(c))):(console.log(h.gray("No changes detected via git diff. Scanning all files.")),o=await glob(e,{cwd:t,ignore:n,nodir:true,dot:true,absolute:false}));}else o=await glob(e,{cwd:t,ignore:n,nodir:true,dot:true,absolute:false});let a=o.filter(i=>{let c=i.replace(/\\/g,"/");return !c.includes("node_modules/")&&!c.startsWith("node_modules/")&&!c.includes("/node_modules/")&&!c.includes(".next/")&&!c.startsWith(".next/")});for(let i of a){let c=join(t,i),l=statSync(c);if(l.isFile()){let g={id:ae__default.randomUUID(),path:i,path_hash:_n(i),depth:i.split(/[\\/]/).length,size_bytes:l.size,estimated_lines:Math.floor(l.size/50),extension:i.split(".").pop()||"",is_binary:oi(i)};s.push(g);}}return s.sort((i,c)=>i.path_hash.localeCompare(c.path_hash))}async function ni(t){let e=[];try{let n=join(t,"package.json");if(!existsSync(n))return [];let r=JSON.parse(readFileSync(n,"utf-8")),s={...r.dependencies||{},...r.devDependencies||{},...r.peerDependencies||{}},o=join(t,"pnpm-lock.yaml"),a=join(t,"package-lock.json"),i=join(t,"yarn.lock"),c={};if(existsSync(o))try{let g=readFileSync(o,"utf8");c=Yo(g);}catch{console.error(h.yellow("\u26A0\uFE0F Failed to parse pnpm-lock.yaml"));}else if(existsSync(a))try{let w=JSON.parse(readFileSync(a,"utf8")).packages||{};for(let[b,x]of Object.entries(w)){if(b==="")continue;let C=b.replace("node_modules/","");x.version&&(c[C]=x.version);}}catch{console.error(h.yellow("\u26A0\uFE0F Failed to parse package-lock.json"));}let l=(g,w)=>{for(let[b,x]of Object.entries(g)){let C=c[b]||x.replace(/[\^~]/,""),B=C.match(/^(\d+)\.(\d+)/),ue=B?parseInt(B[1]):0,Nt=B?parseInt(B[2]):0;e.push({id:ae__default.randomUUID(),name:b,name_hash:_n(b),version:C,major_version:ue,minor_version:Nt,category:w,vulnerabilities:[]});}};r.dependencies&&l(r.dependencies,"prod"),r.devDependencies&&l(r.devDependencies,"dev"),r.peerDependencies&&l(r.peerDependencies,"peer");}catch{}return e.sort((n,r)=>n.name_hash.localeCompare(r.name_hash))}function ri(t){let e={};for(let n of t){let r=n.extension.toLowerCase(),s=si(r);e[s]=(e[s]||0)+1;}return e}function si(t){return {ts:"TypeScript",js:"JavaScript",tsx:"TypeScript",jsx:"JavaScript",py:"Python",go:"Go",rs:"Rust",java:"Java",kt:"Kotlin",rb:"Ruby",php:"PHP",cs:"C#",cpp:"C++",c:"C",h:"C",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",html:"HTML",css:"CSS",scss:"SCSS",sql:"SQL",sh:"Shell"}[t]||"Other"}function oi(t){let e=[".exe",".dll",".so",".dylib",".bin",".png",".jpg",".jpeg",".gif",".pdf",".zip",".tar",".gz",".7z",".woff",".woff2",".ttf",".eot"],n=t.split(".").pop()?.toLowerCase();return n?e.includes("."+n):false}function _n(t){return ae__default.createHash("sha256").update(t).digest("hex")}var wn=process.env.VEESTACK_API_URL||"https://www.veestack.com",hr=process.env.VEESTACK_DASHBOARD_URL||"https://www.veestack.com/dashboard",ui=3e4;async function Sn(t,e={}){let{timeout:n=ui}=e,r=new AbortController,s=setTimeout(()=>r.abort(),n);try{let o=await fetch(t,{...e,signal:r.signal});return clearTimeout(s),o}catch(o){throw clearTimeout(s),o instanceof Error&&o.name==="AbortError"?new Error(`Request timed out after ${n/1e3}s. Please check your connection.`):o}}async function di(){try{let t=await ce("GET","/api/projects"),e=await Sn(`${wn}/api/projects`,{headers:t});return e.ok?(await e.json()).projects||[]:[]}catch{return []}}async function yr(t){try{let e=JSON.stringify({name:t}),n=await ce("POST","/api/projects",e),r=await Sn(`${wn}/api/projects`,{method:"POST",headers:n,body:e});if(r.ok){let s=await r.json();return s.project?.id||s.id||null}return null}catch{return null}}function Qt(t){let e=ci.createInterface({input:process.stdin,output:process.stdout});return new Promise(n=>{e.question(t,r=>{e.close(),n(r);});})}async function fi(){console.log(h.blue(`
90
90
  \u{1F4C1} Loading projects...
91
- `));let t=await ui();if(t.length===0){if(console.log(h.yellow(`No projects found.
92
- `)),(await en("Do you want to create a new project? (y/n): ")).toLowerCase()==="y"){let s=await en("Enter project name: ");if(s.trim()){let o=await hr(s.trim());if(o)return console.log(h.green(`
91
+ `));let t=await di();if(t.length===0){if(console.log(h.yellow(`No projects found.
92
+ `)),(await Qt("Do you want to create a new project? (y/n): ")).toLowerCase()==="y"){let s=await Qt("Enter project name: ");if(s.trim()){let o=await yr(s.trim());if(o)return console.log(h.green(`
93
93
  \u2705 Project "${s}" created successfully!`)),o}}return null}console.log(h.white(`Select a project:
94
94
  `)),console.log(h.gray(`0. [+] Create new project
95
95
  `)),t.forEach((r,s)=>{console.log(h.white(`${s+1}. ${r.name}`)),console.log(h.gray(` ID: ${r.id}`)),console.log(h.gray(` Created: ${new Date(r.created_at).toLocaleDateString()}
96
- `));});let e=await en("Enter number (0-"+t.length+"): "),n=parseInt(e,10);if(n===0){let r=await en(`
97
- Enter project name: `);if(r.trim()){let s=await hr(r.trim());if(s)return console.log(h.green(`
96
+ `));});let e=await Qt("Enter number (0-"+t.length+"): "),n=parseInt(e,10);if(n===0){let r=await Qt(`
97
+ Enter project name: `);if(r.trim()){let s=await yr(r.trim());if(s)return console.log(h.green(`
98
98
  \u2705 Project "${r}" created successfully!`)),s}return null}else if(n>0&&n<=t.length){let r=t[n-1];return console.log(h.green(`
99
99
  \u2705 Selected project: "${r.name}"`)),r.id}else return console.log(h.red(`
100
- \u274C Invalid selection`)),null}async function En(t){let e=t.ci,n=await ue();n||(e&&(console.error(h.red("\u274C Authentication required for upload in CI mode. Please set VEESTACK_API_KEY.")),process.exit(1)),console.log(h.red("\u274C Authentication required")),console.log(h.yellow(`
101
- Please login first:`)),console.log(h.cyan(" veestack login")),process.exit(1));let r=await Yt();e||(console.log(h.blue(`
100
+ \u274C Invalid selection`)),null}async function En(t){let e=t.ci,n=await le();n||(e&&(console.error(h.red("\u274C Authentication required for upload in CI mode. Please set VEESTACK_API_KEY.")),process.exit(1)),console.log(h.red("\u274C Authentication required")),console.log(h.yellow(`
101
+ Please login first:`)),console.log(h.cyan(" veestack login")),process.exit(1));let r=await qt();e||(console.log(h.blue(`
102
102
  \u{1F510} Authentication verified`)),n.user&&console.log(h.gray(`User: ${n.user.name}`)),console.log(h.gray(`Subscription tier: ${r==="pro"?"Pro":"Free"}`)),console.log(h.gray("\u2500".repeat(40)+`
103
- `)));let s=Jo({text:"Preparing upload...",isSilent:e}).start();try{let o=await import('fs/promises');existsSync(t.file)||(s.fail(`File not found: ${t.file}`),e||console.log(h.yellow(`
104
- Tip: Run "veestack scan" first to generate a snapshot.`)),process.exit(1));let a=await o.readFile(t.file,"utf-8"),i=JSON.parse(a),c=t.projectId||process.env.VEESTACK_PROJECT_ID;if(!c){e&&(s.fail("Project ID is required in CI mode. Please set VEESTACK_PROJECT_ID."),process.exit(1)),s.stop();let J=await di();J||(console.log(h.red(`
105
- \u274C No project selected. Exiting.`)),process.exit(1)),c=J,s.start("Uploading snapshot...");}s.text="Compressing and uploading snapshot...";let l=gzipSync(JSON.stringify(i)).toString("base64"),g=JSON.stringify({project_id:c,snapshot:l,compressed:!0,encoding:"base64"}),w=await le("POST","/api/snapshots/upload",g),b=await Sn(`${wn}/api/snapshots/upload`,{method:"POST",headers:w,body:g});if(!b.ok){let J=await b.json().catch(()=>({}));s.fail("Upload failed"),console.error(h.red(`Error: ${J.message||J.error||"Server error"}`)),process.exit(1);}let x=await b.json(),{snapshotId:C,reportId:B,score:de,severity:Pt,findings:nn}=x;if(s.succeed("Analysis complete"),e)console.log(`\u2714 Upload successful. Report: ${mr}/reports/${B}?project=${c}`);else {console.log(h.green(`
103
+ `)));let s=Go({text:"Preparing upload...",isSilent:e}).start();try{let o=await import('fs/promises');existsSync(t.file)||(s.fail(`File not found: ${t.file}`),e||console.log(h.yellow(`
104
+ Tip: Run "veestack scan" first to generate a snapshot.`)),process.exit(1));let a=await o.readFile(t.file,"utf-8"),i=JSON.parse(a),c=t.projectId||process.env.VEESTACK_PROJECT_ID;if(!c){e&&(s.fail("Project ID is required in CI mode. Please set VEESTACK_PROJECT_ID."),process.exit(1)),s.stop();let H=await fi();H||(console.log(h.red(`
105
+ \u274C No project selected. Exiting.`)),process.exit(1)),c=H,s.start("Uploading snapshot...");}s.text="Compressing and uploading snapshot...";let l=gzipSync(JSON.stringify(i)).toString("base64"),g=JSON.stringify({project_id:c,snapshot:l,compressed:!0,encoding:"base64"}),w=await ce("POST","/api/snapshots/upload",g),b=await Sn(`${wn}/api/snapshots/upload`,{method:"POST",headers:w,body:g});if(!b.ok){let H=await b.json().catch(()=>({}));s.fail("Upload failed"),console.error(h.red(`Error: ${H.message||H.error||"Server error"}`)),process.exit(1);}let x=await b.json(),{snapshotId:C,reportId:B,score:ue,severity:Nt,findings:nn}=x;if(s.succeed("Analysis complete"),e)console.log(`\u2714 Upload successful. Report: ${hr}/reports/${B}?project=${c}`);else {console.log(h.green(`
106
106
  \u2705 Report generated and saved to VeeStack`)),console.log(h.gray("Project ID: "),h.white(c)),console.log(h.gray("Snapshot ID: "),h.white(C)),console.log(h.gray("Report ID: "),h.white(B)),console.log(h.bold(`
107
- \u{1F4CA} Security Score:`),de>=90?h.green(de):de>=70?h.yellow(de):h.red(de)),console.log(h.gray("Severity: "),Pt),console.log(h.gray("Findings: "),nn);let J=`${mr}/reports/${B}?project=${c}`;console.log(h.blue(`
108
- \u{1F517} View your full report at:`)),console.log(h.underline(J));}}catch(o){s.fail("Upload failed"),console.error(o),process.exit(1);}}var fi=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function yr(t){t.format==="sarif"?await pi(t):console.log(h.red('\u274C Unsupported format. Currently only "sarif" is supported.'));}async function pi(t){await ue()||(console.error(h.red("\u274C Authentication required. Please login first.")),process.exit(1));let n=t.reportId;n||(console.error(h.red("\u274C Report ID is required for SARIF export.")),process.exit(1)),console.log(h.blue(`
109
- \u{1F4CA} Fetching report ${n} for SARIF export...`));try{let r=await le("GET",`/api/reports/${n}/sarif`),s=await fetch(`${fi}/api/reports/${n}/sarif`,{headers:r});if(!s.ok){let c=await s.json().catch(()=>({}));throw new Error(c.message||"Failed to fetch SARIF report")}let o=await s.json(),a=t.output||"veestack-results.sarif";await(await import('fs/promises')).writeFile(a,JSON.stringify(o,null,2)),console.log(h.green(`
107
+ \u{1F4CA} Security Score:`),ue>=90?h.green(ue):ue>=70?h.yellow(ue):h.red(ue)),console.log(h.gray("Severity: "),Nt),console.log(h.gray("Findings: "),nn);let H=`${hr}/reports/${B}?project=${c}`;console.log(h.blue(`
108
+ \u{1F517} View your full report at:`)),console.log(h.underline(H));}}catch(o){s.fail("Upload failed"),console.error(o),process.exit(1);}}var pi=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function vr(t){t.format==="sarif"?await gi(t):console.log(h.red('\u274C Unsupported format. Currently only "sarif" is supported.'));}async function gi(t){await le()||(console.error(h.red("\u274C Authentication required. Please login first.")),process.exit(1));let n=t.reportId;n||(console.error(h.red("\u274C Report ID is required for SARIF export.")),process.exit(1)),console.log(h.blue(`
109
+ \u{1F4CA} Fetching report ${n} for SARIF export...`));try{let r=await ce("GET",`/api/reports/${n}/sarif`),s=await fetch(`${pi}/api/reports/${n}/sarif`,{headers:r});if(!s.ok){let c=await s.json().catch(()=>({}));throw new Error(c.message||"Failed to fetch SARIF report")}let o=await s.json(),a=t.output||"veestack-results.sarif";await(await import('fs/promises')).writeFile(a,JSON.stringify(o,null,2)),console.log(h.green(`
110
110
  \u2705 SARIF report exported to: ${a}`)),console.log(h.gray("You can now upload this to GitHub Security Tab."));}catch(r){console.error(h.red(`
111
- \u274C Export failed:`),r instanceof Error?r.message:r),process.exit(1);}}var xn=process.env.VEESTACK_API_URL||"https://www.veestack.com",hi=process.env.VEESTACK_WEB_URL||"https://www.veestack.com",yi=2e3,kr=300;function vi(){return ce__default.randomBytes(16).toString("hex")}function ki(){let t=ce__default.randomBytes(32).toString("base64url"),e=ce__default.createHash("sha256").update(t).digest("base64url");return {code_verifier:t,code_challenge:e}}function _i(){let t=process.platform,e=ct.hostname(),n=H,r=e||ce__default.randomBytes(8).toString("hex"),s=ce__default.createHash("sha256").update(`${r}:${t}:${n}`).digest("hex"),o=ce__default.randomBytes(12).toString("hex"),a=`${e||"Unknown"} (${t==="win32"?"Windows":t==="darwin"?"macOS":"Linux"})`;return {id:o,name:a,fingerprint:s,os:t,version:n}}async function wi(t,e){let n=vi();try{let r=await fetch(`${xn}/api/cli/device`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:n,client_id:"veestack-cli",code_challenge:t.code_challenge,code_challenge_method:"S256",device_info:{id:e.id,name:e.name,fingerprint:e.fingerprint,os:e.os,version:e.version}})});if(!r.ok){let o=await r.text().catch(()=>"");throw new Error(`Server returned ${r.status} ${r.statusText}: ${o||"No detail provided"}`)}return await r.json()}catch(r){throw r instanceof Error?r.message.includes("fetch failed")||r.name==="TypeError"?new Error(`Could not connect to VeeStack API at ${xn}.
112
- Please check your internet connection or verify if the API is reachable.`):r:new Error("An unexpected network error occurred while connecting to VeeStack.")}}async function Si(t,e,n){try{let r=await fetch(`${xn}/api/cli/token?device_code=${t}&code_verifier=${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(r.status===202)return null;if(!r.ok)throw new Error(`Failed to poll for token: ${r.statusText}`);return r.json()}catch{if(n>=kr)throw new Error("Authentication timeout. Please try again.");return null}}async function Rt(){console.log(h.bold.cyan(`
111
+ \u274C Export failed:`),r instanceof Error?r.message:r),process.exit(1);}}var yi="6.3.3",xn=process.env.VEESTACK_API_URL||"https://www.veestack.com",vi=process.env.VEESTACK_WEB_URL||"https://www.veestack.com",ki=2e3,_r=300;function _i(){return ae__default.randomBytes(16).toString("hex")}function wi(){let t=ae__default.randomBytes(32).toString("base64url"),e=ae__default.createHash("sha256").update(t).digest("base64url");return {code_verifier:t,code_challenge:e}}function Si(){let t=process.platform,e=at.hostname(),n=yi,r=e||ae__default.randomBytes(8).toString("hex"),s=ae__default.createHash("sha256").update(`${r}:${t}:${n}`).digest("hex"),o=ae__default.randomBytes(12).toString("hex"),a=`${e||"Unknown"} (${t==="win32"?"Windows":t==="darwin"?"macOS":"Linux"})`;return {id:o,name:a,fingerprint:s,os:t,version:n}}async function Ei(t,e){let n=_i();try{let r=await fetch(`${xn}/api/cli/device`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:n,client_id:"veestack-cli",code_challenge:t.code_challenge,code_challenge_method:"S256",device_info:{id:e.id,name:e.name,fingerprint:e.fingerprint,os:e.os,version:e.version}})});if(!r.ok){let o=await r.text().catch(()=>"");throw new Error(`Server returned ${r.status} ${r.statusText}: ${o||"No detail provided"}`)}return await r.json()}catch(r){throw r instanceof Error?r.message.includes("fetch failed")||r.name==="TypeError"?new Error(`Could not connect to VeeStack API at ${xn}.
112
+ Please check your internet connection or verify if the API is reachable.`):r:new Error("An unexpected network error occurred while connecting to VeeStack.")}}async function xi(t,e,n){try{let r=await fetch(`${xn}/api/cli/token?device_code=${t}&code_verifier=${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(r.status===202)return null;if(!r.ok)throw new Error(`Failed to poll for token: ${r.statusText}`);return r.json()}catch{if(n>=_r)throw new Error("Authentication timeout. Please try again.");return null}}async function bt(){console.log(h.bold.cyan(`
113
113
  \u{1F510} Login to VeeStack
114
114
  `)),console.log(h.gray(`Opening browser to authenticate...
115
- `));let t=Jo({text:"Requesting device code...",spinner:"dots",stream:process.stdout});try{let e=ki(),n=_i();t.start();let r=await wi(e,n);t.stop();let s=`${hi}/cli-auth?device=${r.device_code}&code=${r.user_code}&challenge=${e.code_challenge}`;console.log(h.white(`Please authenticate using your browser:
115
+ `));let t=Go({text:"Requesting device code...",spinner:"dots",stream:process.stdout});try{let e=wi(),n=Si();t.start();let r=await Ei(e,n);t.stop();let s=`${vi}/cli-auth?device=${r.device_code}&code=${r.user_code}&challenge=${e.code_challenge}`;console.log(h.white(`Please authenticate using your browser:
116
116
  `)),console.log(h.gray("Device: ")+h.white(n.name)),console.log(h.gray("Device Code: ")+h.bold.cyan(r.user_code)),console.log(h.gray("URL: ")+h.underline(s)+`
117
- `),await mi(s),console.log(h.yellow("Waiting for authentication...")),console.log(h.gray(`(Press Ctrl+C to cancel)
118
- `));let o=0,a=null;for(t.start("Checking authentication status...");!a&&o<kr;)await new Promise(c=>setTimeout(c,yi)),a=await Si(r.device_code,e.code_verifier,o),o++,a||(t.text=`Checking authentication status... (${o*2}s)`);a||(t.fail("Authentication timeout"),console.log(h.red(`
119
- \u274C Authentication timed out after 10 minutes.`)),console.log(h.yellow("Please try again with: veestack login")),process.exit(1)),t.succeed("Authentication successful");let i={token:a.access_token,tokenType:a.token_type,refreshToken:a.refresh_token,tokenExpiresAt:new Date(Date.now()+a.expires_in*1e3).toISOString(),device:{id:n.id,name:n.name,fingerprint:n.fingerprint},user:{id:a.user.id,email:a.user.email,name:a.user.name,provider:a.user.provider},subscription:a.subscription||{tier:"free",isActive:!0},lastLoginAt:new Date().toISOString()};try{await xt(i);}catch(c){t.fail("Failed to save authentication"),console.error(h.red(`
117
+ `),await hi(s),console.log(h.yellow("Waiting for authentication...")),console.log(h.gray(`(Press Ctrl+C to cancel)
118
+ `));let o=0,a=null;for(t.start("Checking authentication status...");!a&&o<_r;)await new Promise(c=>setTimeout(c,ki)),a=await xi(r.device_code,e.code_verifier,o),o++,a||(t.text=`Checking authentication status... (${o*2}s)`);a||(t.fail("Authentication timeout"),console.log(h.red(`
119
+ \u274C Authentication timed out after 10 minutes.`)),console.log(h.yellow("Please try again with: veestack login")),process.exit(1)),t.succeed("Authentication successful");let i={token:a.access_token,tokenType:a.token_type,refreshToken:a.refresh_token,tokenExpiresAt:new Date(Date.now()+a.expires_in*1e3).toISOString(),device:{id:n.id,name:n.name,fingerprint:n.fingerprint},user:{id:a.user.id,email:a.user.email,name:a.user.name,provider:a.user.provider},subscription:a.subscription||{tier:"free",isActive:!0},lastLoginAt:new Date().toISOString()};try{await Et(i);}catch(c){t.fail("Failed to save authentication"),console.error(h.red(`
120
120
  \u274C Could not securely store tokens:`),c),process.exit(1);}console.log(h.green(`
121
121
  \u2714 Login successful
122
122
  `)),console.log(h.gray("Device: ")+h.white(i.device.name)),console.log(h.gray("Device ID: ")+h.gray(i.device.id.substring(0,8)+"...")),console.log(h.gray("Account: ")+h.white(i.user.name)),console.log(h.gray("Email: ")+h.white(i.user.email)),console.log(h.gray("Provider: ")+h.cyan(i.user.provider)),console.log(h.gray("Subscription: ")+(i.subscription?.tier==="pro"?h.cyan("Pro"):h.blue("Free"))),console.log(h.gray("Token expires: ")+h.yellow(new Date(i.tokenExpiresAt).toLocaleString())),console.log(h.gray(`
123
- Token saved securely to OS Keychain`)),lr({token:i.token,tokenType:i.tokenType,refreshToken:i.refreshToken,tokenExpiresAt:i.tokenExpiresAt,device:i.device,user:i.user,subscription:i.subscription,lastLoginAt:i.lastLoginAt});}catch(e){t.fail("Authentication failed"),console.error(h.red(`
124
- \u274C Error:`),e instanceof Error?e.message:e),process.exit(1);}}var Ei=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function _r(){try{let t=await Y();if(!t){console.log(h.yellow("\u26A0\uFE0F Not logged in"));return}if(console.log(h.bold.cyan(`
123
+ Token saved securely to OS Keychain`)),ur({token:i.token,tokenType:i.tokenType,refreshToken:i.refreshToken,tokenExpiresAt:i.tokenExpiresAt,device:i.device,user:i.user,subscription:i.subscription,lastLoginAt:i.lastLoginAt});}catch(e){t.fail("Authentication failed"),console.error(h.red(`
124
+ \u274C Error:`),e instanceof Error?e.message:e),process.exit(1);}}var Ai=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function wr(){try{let t=await q();if(!t){console.log(h.yellow("\u26A0\uFE0F Not logged in"));return}if(console.log(h.bold.cyan(`
125
125
  \u{1F6AA} Logout from VeeStack
126
- `)),t.token||t.apiKey)try{let e=t.token||t.apiKey;await fetch(`${Ei}/api/cli/logout`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({device_id:t.device?.id})});}catch{}await Gt()&&await ze();try{let{existsSync:e,unlinkSync:n}=await import('fs'),{join:r}=await import('path'),{homedir:s}=await import('os'),o=r(s(),".veestack"),a=r(o,"config.json");e(a)&&n(a);}catch{}t.user?console.log(h.green(`\u2714 Logged out ${t.user.name}`)):console.log(h.green("\u2714 Logged out")),console.log(h.gray(`
126
+ `)),t.token||t.apiKey)try{let e=t.token||t.apiKey;await fetch(`${Ai}/api/cli/logout`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({device_id:t.device?.id})});}catch{}await Jt()&&await Be();try{let{existsSync:e,unlinkSync:n}=await import('fs'),{join:r}=await import('path'),{homedir:s}=await import('os'),o=r(s(),".veestack"),a=r(o,"config.json");e(a)&&n(a);}catch{}t.user?console.log(h.green(`\u2714 Logged out ${t.user.name}`)):console.log(h.green("\u2714 Logged out")),console.log(h.gray(`
127
127
  \u{1F510} All local tokens securely deleted`)),console.log(h.gray("See you soon! \u{1F44B}")),console.log(h.gray(`Run "veestack login" to authenticate again.
128
- `));}catch(t){ye.error("\u274C Error during logout:",mn(t)),process.exit(1);}}async function wr(){try{let t=await ue();t||(console.log(h.yellow("\u26A0\uFE0F Not authenticated")),console.log(h.gray(`
128
+ `));}catch(t){he.error("\u274C Error during logout:",mn(t)),process.exit(1);}}async function Sr(){try{let t=await le();t||(console.log(h.yellow("\u26A0\uFE0F Not authenticated")),console.log(h.gray(`
129
129
  Please login first:`)),console.log(h.cyan(" veestack login")),process.exit(1)),console.log(h.bold.cyan(`
130
130
  \u{1F464} VeeStack Account
131
- `)),t.user&&(console.log(h.gray("User: ")+h.white(t.user.name)),console.log(h.gray("Email: ")+h.white(t.user.email)),console.log(h.gray("Provider: ")+h.cyan(t.user.provider))),t.device&&(console.log(h.gray("Device: ")+h.white(t.device.name)),console.log(h.gray("Device ID: ")+h.gray(t.device.id.substring(0,8)+"...")));let e=t.subscription?.tier||"free";if(console.log(h.gray("Subscription: ")+(e==="pro"?h.cyan("Pro"):h.blue("Free"))),t.tokenExpiresAt){let r=yn(t)?h.red("Expired (will refresh)"):h.green("Valid");console.log(h.gray("Token Status: ")+r),console.log(h.gray("Expires: ")+h.yellow(new Date(t.tokenExpiresAt).toLocaleString()));}t.lastLoginAt&&console.log(h.gray("Last Login: ")+h.gray(new Date(t.lastLoginAt).toLocaleString())),console.log();}catch(t){console.error(h.red("\u274C Error:"),t instanceof Error?t.message:t),process.exit(1);}}function Er(){return join(homedir(),".veestack","accounts")}function xi(){try{let t=Er();if(!ne.existsSync(t))return [];let e=[],n=ne.readdirSync(t);for(let r of n)if(r.endsWith(".json")){let s=ne.readFileSync(join(t,r),"utf-8"),o=JSON.parse(s);o.user&&e.push({id:o.user.id,name:o.user.name,email:o.user.email,provider:o.user.provider,config:o});}return e}catch{return []}}function Ai(t){try{let e=Er();if(ne.mkdirSync(e,{recursive:!0}),t.user){let n=join(e,`${t.user.id}.json`);ne.writeFileSync(n,JSON.stringify(t,null,2),{mode:384});}}catch{}}async function xr(){let t=await Y(),e=xi();console.log(h.bold.cyan(`
131
+ `)),t.user&&(console.log(h.gray("User: ")+h.white(t.user.name)),console.log(h.gray("Email: ")+h.white(t.user.email)),console.log(h.gray("Provider: ")+h.cyan(t.user.provider))),t.device&&(console.log(h.gray("Device: ")+h.white(t.device.name)),console.log(h.gray("Device ID: ")+h.gray(t.device.id.substring(0,8)+"...")));let e=t.subscription?.tier||"free";if(console.log(h.gray("Subscription: ")+(e==="pro"?h.cyan("Pro"):h.blue("Free"))),t.tokenExpiresAt){let r=yn(t)?h.red("Expired (will refresh)"):h.green("Valid");console.log(h.gray("Token Status: ")+r),console.log(h.gray("Expires: ")+h.yellow(new Date(t.tokenExpiresAt).toLocaleString()));}t.lastLoginAt&&console.log(h.gray("Last Login: ")+h.gray(new Date(t.lastLoginAt).toLocaleString())),console.log();}catch(t){console.error(h.red("\u274C Error:"),t instanceof Error?t.message:t),process.exit(1);}}function xr(){return join(homedir(),".veestack","accounts")}function Ti(){try{let t=xr();if(!te.existsSync(t))return [];let e=[],n=te.readdirSync(t);for(let r of n)if(r.endsWith(".json")){let s=te.readFileSync(join(t,r),"utf-8"),o=JSON.parse(s);o.user&&e.push({id:o.user.id,name:o.user.name,email:o.user.email,provider:o.user.provider,config:o});}return e}catch{return []}}function bi(t){try{let e=xr();if(te.mkdirSync(e,{recursive:!0}),t.user){let n=join(e,`${t.user.id}.json`);te.writeFileSync(n,JSON.stringify(t,null,2),{mode:384});}}catch{}}async function Ar(){let t=await q(),e=Ti();console.log(h.bold.cyan(`
132
132
  \u{1F464} Switch Account
133
133
  `)),t?.user&&(console.log(h.gray("Currently logged in as:")),console.log(h.white(` ${t.user.name} (${t.user.email})`)),console.log(h.gray(` Provider: ${t.user.provider}`)),console.log());let n=e.filter(i=>i.id!==t?.user?.id);if(n.length===0){console.log(h.yellow("No other saved accounts found.")),console.log(h.gray(`
134
134
  To add a new account:`)),console.log(h.cyan(" veestack login")),console.log();return}console.log(h.gray("Available accounts:")),n.forEach((i,c)=>{console.log(h.white(`
135
135
  ${c+1}) ${i.name}`)),console.log(h.gray(` ${i.email}`)),console.log(h.gray(` Provider: ${i.provider}`));}),console.log(h.gray(`
136
- 0) Add new account`)),console.log();let s=(await import('readline')).createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(i=>{s.question(h.white("Select account (number): "),c=>{s.close(),i(c);});}),a=parseInt(o,10);if(a===0){await Rt();return}if(a>0&&a<=n.length){let i=n[a-1];t&&Ai(t);let c=join(homedir(),".veestack"),l=join(c,"config.json");ne.mkdirSync(c,{recursive:true}),ne.writeFileSync(l,JSON.stringify(i.config,null,2),{mode:384}),console.log(h.green(`
136
+ 0) Add new account`)),console.log();let s=(await import('readline')).createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(i=>{s.question(h.white("Select account (number): "),c=>{s.close(),i(c);});}),a=parseInt(o,10);if(a===0){await bt();return}if(a>0&&a<=n.length){let i=n[a-1];t&&bi(t);let c=join(homedir(),".veestack"),l=join(c,"config.json");te.mkdirSync(c,{recursive:true}),te.writeFileSync(l,JSON.stringify(i.config,null,2),{mode:384}),console.log(h.green(`
137
137
  \u2714 Switched to ${i.name}`)),console.log(h.gray(` ${i.email}`)),console.log();}else console.log(h.red(`
138
- \u274C Invalid selection`)),process.exit(1);}function Ti(){let t=join(process.cwd(),"veestack.config.json");if(!existsSync(t))return null;try{return JSON.parse(readFileSync(t,"utf-8"))}catch{return null}}function bi(){let t=join(process.env.HOME||process.env.USERPROFILE||"",".veestack","last-scan.json");if(existsSync(t))try{return JSON.parse(readFileSync(t,"utf-8"))}catch{return null}return null}function Ri(t){let e=new Date(t),r=Math.floor((new Date().getTime()-e.getTime())/1e3);if(r<60)return `${r} seconds ago`;let s=Math.floor(r/60);if(s<60)return `${s} minutes ago`;let o=Math.floor(s/60);return o<24?`${o} hours ago`:e.toLocaleDateString()}async function An(){console.log(h.bold.cyan(`
138
+ \u274C Invalid selection`)),process.exit(1);}function Ri(){let t=join(process.cwd(),"veestack.config.json");if(!existsSync(t))return null;try{return JSON.parse(readFileSync(t,"utf-8"))}catch{return null}}function Ci(){let t=join(process.env.HOME||process.env.USERPROFILE||"",".veestack","last-scan.json");if(existsSync(t))try{return JSON.parse(readFileSync(t,"utf-8"))}catch{return null}return null}function Ii(t){let e=new Date(t),r=Math.floor((new Date().getTime()-e.getTime())/1e3);if(r<60)return `${r} seconds ago`;let s=Math.floor(r/60);if(s<60)return `${s} minutes ago`;let o=Math.floor(s/60);return o<24?`${o} hours ago`:e.toLocaleDateString()}async function An(){console.log(h.bold.cyan(`
139
139
  \u{1F4CA} VeeStack Status
140
- `)),console.log(h.gray("\u2500".repeat(40)));let t=await Je(),e=await Yt(),n=await cr(),r=Ti(),s=bi();if(console.log(h.gray(`
141
- CLI Version: ${h.white(z)}`)),console.log(h.bold(`
140
+ `)),console.log(h.gray("\u2500".repeat(40)));let t=await Ze(),e=await qt(),n=await lr(),r=Ri(),s=Ci();if(console.log(h.gray(`
141
+ CLI Version: ${h.white(J)}`)),console.log(h.bold(`
142
142
  User`)),t?(console.log(h.green(" \u2714 Authenticated")),console.log(e==="pro"?h.cyan(" \u{1F48E} Pro plan"):h.blue(" \u{1F4E6} Free plan")),n||console.log(h.red(" \u26A0 Subscription expired"))):(console.log(h.yellow(`
143
143
  \u26A0\uFE0F You are not logged in`)),console.log(h.gray(`
144
144
  Login to enable:`)),console.log(h.gray(" \u2022 Cloud reports")),console.log(h.gray(" \u2022 Team dashboard")),console.log(h.gray(` \u2022 Historical scans
145
145
  `)),console.log(h.gray("Run:")),console.log(h.cyan(" veestack login"))),console.log(h.bold(`
146
146
  Project`)),r?(console.log(h.green(` \u2714 ${r.name||"Unnamed project"}`)),r.framework&&console.log(h.gray(` Framework: ${r.framework}`)),r.projectId?console.log(h.gray(" Linked: Yes")):console.log(h.gray(" Linked: No"))):(console.log(h.yellow(" \u26A0 No project initialized")),console.log(h.gray(" Run: veestack init"))),console.log(h.bold(`
147
- Scan Status`)),s){console.log(h.gray(` Last scan: ${Ri(s.timestamp)}`));let o=s.grade.startsWith("A")?h.green:s.grade==="B"?h.blue:h.yellow;console.log(h.gray(` Score: ${o.bold(s.grade)} (${s.score}/100)`)),console.log(h.gray(` Issues: ${s.issues>0?h.red(s.issues):h.green(0)}`));}else console.log(h.gray(" Last scan: Never")),console.log(h.gray(" Issues: -"));console.log(h.gray(`
148
- `+"\u2500".repeat(40)));}var Rr=process.env.VEESTACK_DASHBOARD_URL||"https://www.veestack.com/dashboard";function Oi(){let t=join(process.cwd(),"veestack.config.json");if(existsSync(t))try{return JSON.parse(readFileSync(t,"utf-8")).projectId||null}catch{return null}return null}async function Cr(){let t=Oi(),e=t?`${Rr}/projects/${t}`:Rr;console.log(h.cyan(`
149
- Opening ${e}...`));try{await mi(e),console.log(h.green(`\u2714 Dashboard opened in your browser
147
+ Scan Status`)),s){console.log(h.gray(` Last scan: ${Ii(s.timestamp)}`));let o=s.grade.startsWith("A")?h.green:s.grade==="B"?h.blue:h.yellow;console.log(h.gray(` Score: ${o.bold(s.grade)} (${s.score}/100)`)),console.log(h.gray(` Issues: ${s.issues>0?h.red(s.issues):h.green(0)}`));}else console.log(h.gray(" Last scan: Never")),console.log(h.gray(" Issues: -"));console.log(h.gray(`
148
+ `+"\u2500".repeat(40)));}var Cr=process.env.VEESTACK_DASHBOARD_URL||"https://www.veestack.com/dashboard";function ji(){let t=join(process.cwd(),"veestack.config.json");if(existsSync(t))try{return JSON.parse(readFileSync(t,"utf-8")).projectId||null}catch{return null}return null}async function Ir(){let t=ji(),e=t?`${Cr}/projects/${t}`:Cr;console.log(h.cyan(`
149
+ Opening ${e}...`));try{await hi(e),console.log(h.green(`\u2714 Dashboard opened in your browser
150
150
  `));}catch{console.log(h.red(`
151
151
  \u274C Could not open browser automatically.`)),console.log(h.gray(`Please visit: ${h.white(e)}
152
- `));}}var Li=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function $i(){let t=process.version,e=parseInt(t.slice(1).split(".")[0]);return e>=18?{name:"Node.js Version",status:"ok",message:`${t} (>= 18)`}:e>=16?{name:"Node.js Version",status:"warning",message:`${t} (>= 16, but 18+ recommended)`}:{name:"Node.js Version",status:"error",message:`${t} (>= 18 required)`,details:"Please upgrade Node.js: https://nodejs.org"}}async function Vi(){let t=process.env.VEESTACK_CLI_VERSION||H;try{let e=await fetch("https://registry.npmjs.org/veestack-tools/latest",{signal:AbortSignal.timeout(3e3)});if(e.ok){let r=(await e.json()).version;return t===r?{name:"CLI Version",status:"ok",message:`v${t} (latest)`}:{name:"CLI Version",status:"warning",message:`v${t} (latest: v${r})`,details:"Upgrade: npm install -g veestack-tools"}}}catch{}return {name:"CLI Version",status:"ok",message:`v${t}`}}async function Mi(){try{let t=await Y();return t?{name:"Authentication",status:"ok",message:t.user?.email||"Authenticated via API Key"}:{name:"Authentication",status:"warning",message:"Not authenticated",details:"Run: veestack login"}}catch{return {name:"Authentication",status:"error",message:"Auth system error",details:"Try: veestack logout && veestack login"}}}async function Ui(){if(!await Je())return {name:"API Connectivity",status:"ok",message:"Skipped (not authenticated)",details:"Login to enable API checks"};try{let e=await le(),n=await fetch(`${Li}/v1/health`,{method:"GET",headers:e,signal:AbortSignal.timeout(5e3)});return n.ok?{name:"API Connectivity",status:"ok",message:"Reachable"}:{name:"API Connectivity",status:"warning",message:`HTTP ${n.status}`}}catch{return {name:"API Connectivity",status:"warning",message:"Unreachable",details:`Check:
152
+ `));}}var Vi=process.env.VEESTACK_API_URL||"https://www.veestack.com";async function Mi(){let t=process.version,e=parseInt(t.slice(1).split(".")[0]);return e>=18?{name:"Node.js Version",status:"ok",message:`${t} (>= 18)`}:e>=16?{name:"Node.js Version",status:"warning",message:`${t} (>= 16, but 18+ recommended)`}:{name:"Node.js Version",status:"error",message:`${t} (>= 18 required)`,details:"Please upgrade Node.js: https://nodejs.org"}}async function Ui(){let t="6.3.3";try{let e=await fetch("https://registry.npmjs.org/veestack-tools/latest",{signal:AbortSignal.timeout(3e3)});if(e.ok){let r=(await e.json()).version;return t===r?{name:"CLI Version",status:"ok",message:`v${t} (latest)`}:{name:"CLI Version",status:"warning",message:`v${t} (latest: v${r})`,details:"Upgrade: npm install -g veestack-tools"}}}catch{}return {name:"CLI Version",status:"ok",message:`v${t}`}}async function Fi(){try{let t=await q();return t?{name:"Authentication",status:"ok",message:t.user?.email||"Authenticated via API Key"}:{name:"Authentication",status:"warning",message:"Not authenticated",details:"Run: veestack login"}}catch{return {name:"Authentication",status:"error",message:"Auth system error",details:"Try: veestack logout && veestack login"}}}async function Bi(){if(!await Ze())return {name:"API Connectivity",status:"ok",message:"Skipped (not authenticated)",details:"Login to enable API checks"};try{let e=await ce(),n=await fetch(`${Vi}/v1/health`,{method:"GET",headers:e,signal:AbortSignal.timeout(5e3)});return n.ok?{name:"API Connectivity",status:"ok",message:"Reachable"}:{name:"API Connectivity",status:"warning",message:`HTTP ${n.status}`}}catch{return {name:"API Connectivity",status:"warning",message:"Unreachable",details:`Check:
153
153
  \u2022 Internet connection
154
- \u2022 API endpoint configuration`}}}async function Fi(){let t=process.cwd(),e=join(t,"veestack.config.json"),n=join(t,"package.json");if(existsSync(e))try{return {name:"Project Config",status:"ok",message:`Found: ${JSON.parse(readFileSync(e,"utf-8")).projectId||"Unlinked project"}`}}catch{return {name:"Project Config",status:"warning",message:"Invalid veestack.config.json",details:"Check JSON syntax"}}return existsSync(n)?{name:"Project Config",status:"warning",message:"Not initialized",details:"Run: veestack init"}:{name:"Project Config",status:"warning",message:"No project found",details:"Navigate to a project directory"}}async function Bi(){let{isOfficial:t,packageName:e}=Dt();return t?{name:"Package Security",status:"ok",message:"Official package verified",details:e}:{name:"Package Security",status:"error",message:"Unofficial package detected!",details:`Expected: veestack-tools, Found: ${e}`}}async function zi(){let t=await or();return t.keychainAvailable&&t.keychainHasTokens?{name:"Token Storage",status:"ok",message:"OS Keychain (secure)"}:t.fileExists?{name:"Token Storage",status:"warning",message:`File-based (${t.encryptionVersion>=2?"AES-256-GCM":"Encrypted"})`,details:"Install keytar for OS Keychain: npm install -g keytar"}:{name:"Token Storage",status:"ok",message:"No tokens stored"}}async function Hi(){try{return {name:"Git",status:"ok",message:execSync("git --version",{encoding:"utf-8"}).trim().replace("git version ","")}}catch{return {name:"Git",status:"warning",message:"Not installed",details:"Some features may not work"}}}async function Zi(){try{return {name:"Disk Space",status:"ok",message:"Sufficient"}}catch{return {name:"Disk Space",status:"warning",message:"Unable to check"}}}function Nt(t){let e={ok:h.green("\u2714"),warning:h.yellow("\u26A0"),error:h.red("\u2718")},n={ok:h.green,warning:h.yellow,error:h.red};console.log(` ${e[t.status]} ${h.bold(t.name)}: ${n[t.status](t.message)}`),t.details&&console.log(` ${h.gray(t.details)}`);}async function Tn(){console.log(h.bold.cyan(`
154
+ \u2022 API endpoint configuration`}}}async function zi(){let t=process.cwd(),e=join(t,"veestack.config.json"),n=join(t,"package.json");if(existsSync(e))try{return {name:"Project Config",status:"ok",message:`Found: ${JSON.parse(readFileSync(e,"utf-8")).projectId||"Unlinked project"}`}}catch{return {name:"Project Config",status:"warning",message:"Invalid veestack.config.json",details:"Check JSON syntax"}}return existsSync(n)?{name:"Project Config",status:"warning",message:"Not initialized",details:"Run: veestack init"}:{name:"Project Config",status:"warning",message:"No project found",details:"Navigate to a project directory"}}async function Hi(){let{isOfficial:t,packageName:e}=Ot();return t?{name:"Package Security",status:"ok",message:"Official package verified",details:e}:{name:"Package Security",status:"error",message:"Unofficial package detected!",details:`Expected: veestack-tools, Found: ${e}`}}async function Zi(){let t=await or();return t.keychainAvailable&&t.keychainHasTokens?{name:"Token Storage",status:"ok",message:"OS Keychain (secure)"}:t.fileExists?{name:"Token Storage",status:"warning",message:`File-based (${t.encryptionVersion>=2?"AES-256-GCM":"Encrypted"})`,details:"Install keytar for OS Keychain: npm install -g keytar"}:{name:"Token Storage",status:"ok",message:"No tokens stored"}}async function Ji(){try{return {name:"Git",status:"ok",message:execSync("git --version",{encoding:"utf-8"}).trim().replace("git version ","")}}catch{return {name:"Git",status:"warning",message:"Not installed",details:"Some features may not work"}}}async function Gi(){try{return {name:"Disk Space",status:"ok",message:"Sufficient"}}catch{return {name:"Disk Space",status:"warning",message:"Unable to check"}}}function It(t){let e={ok:h.green("\u2714"),warning:h.yellow("\u26A0"),error:h.red("\u2718")},n={ok:h.green,warning:h.yellow,error:h.red};console.log(` ${e[t.status]} ${h.bold(t.name)}: ${n[t.status](t.message)}`),t.details&&console.log(` ${h.gray(t.details)}`);}async function Tn(){console.log(h.bold.cyan(`
155
155
  \u{1F50D} VeeStack Doctor
156
- `)),console.log(h.bold("Environment"));let t=await Promise.all([$i(),Vi(),Hi(),Zi()]);t.forEach(Nt),console.log(h.bold(`
157
- Project`));let e=await Promise.all([Fi()]);e.forEach(Nt),console.log(h.bold(`
158
- Authentication`));let n=await Promise.all([Mi(),zi()]);n.forEach(Nt),console.log(h.bold(`
159
- Connectivity`));let r=await Promise.all([Ui()]);r.forEach(Nt),console.log(h.bold(`
160
- Security`));let s=await Promise.all([Bi()]);s.forEach(Nt);let o=[...t,...e,...n,...r,...s];o.filter(C=>C.status==="ok").length;let i=o.filter(C=>C.status==="warning").length,c=o.filter(C=>C.status==="error").length;console.log(""),console.log(c===0&&i===0?h.green.bold("\u2728 All systems operational!"):c===0?h.yellow.bold(`\u26A0 ${i} issue(s) detected`):h.red.bold(`\u2718 ${c} error(s) found`)),console.log("");let l=0;n.find(C=>C.name==="Authentication")?.status!=="ok"&&(l++,console.log(h.bold(`${l}. Authentication`)),console.log(h.gray(" Run:")),console.log(h.cyan(` veestack login
156
+ `)),console.log(h.bold("Environment"));let t=await Promise.all([Mi(),Ui(),Ji(),Gi()]);t.forEach(It),console.log(h.bold(`
157
+ Project`));let e=await Promise.all([zi()]);e.forEach(It),console.log(h.bold(`
158
+ Authentication`));let n=await Promise.all([Fi(),Zi()]);n.forEach(It),console.log(h.bold(`
159
+ Connectivity`));let r=await Promise.all([Bi()]);r.forEach(It),console.log(h.bold(`
160
+ Security`));let s=await Promise.all([Hi()]);s.forEach(It);let o=[...t,...e,...n,...r,...s];o.filter(C=>C.status==="ok").length;let i=o.filter(C=>C.status==="warning").length,c=o.filter(C=>C.status==="error").length;console.log(""),console.log(c===0&&i===0?h.green.bold("\u2728 All systems operational!"):c===0?h.yellow.bold(`\u26A0 ${i} issue(s) detected`):h.red.bold(`\u2718 ${c} error(s) found`)),console.log("");let l=0;n.find(C=>C.name==="Authentication")?.status!=="ok"&&(l++,console.log(h.bold(`${l}. Authentication`)),console.log(h.gray(" Run:")),console.log(h.cyan(` veestack login
161
161
  `)));let w=n.find(C=>C.name==="Token Storage");w?.status==="warning"&&w.message.includes("File-based")&&(l++,console.log(h.bold(`${l}. Secure token storage`)),console.log(h.gray(" Install OS keychain support:")),console.log(h.cyan(` npm install -g keytar
162
- `))),r.find(C=>C.name==="API Connectivity")?.status==="warning"&&Je&&(l++,console.log(h.bold(`${l}. API connectivity`)),console.log(h.gray(" Check your internet connection")),console.log(h.gray(` or verify API endpoint
162
+ `))),r.find(C=>C.name==="API Connectivity")?.status==="warning"&&Ze()&&(l++,console.log(h.bold(`${l}. API connectivity`)),console.log(h.gray(" Check your internet connection")),console.log(h.gray(` or verify API endpoint
163
163
  `))),e.find(C=>C.name==="Project Config")?.status==="warning"&&(l++,console.log(h.bold(`${l}. Project initialization`)),console.log(h.gray(" Run:")),console.log(h.cyan(` veestack init
164
- `))),process.exit(c>0?1:0);}var Rn=class{results=[];fullMode;configDir;constructor(e=false){this.fullMode=e,this.configDir=We.join(ct.homedir(),".veestack");}async run(){return console.log(h.blue.bold(`
164
+ `))),process.exit(c>0?1:0);}var Rn=class{results=[];fullMode;configDir;constructor(e=false){this.fullMode=e,this.configDir=Ke.join(at.homedir(),".veestack");}async run(){return console.log(h.blue.bold(`
165
165
  \u{1F510} VeeStack Security Audit
166
166
  `)),console.log(h.gray("=".repeat(60))),console.log(h.gray(`Version: ${jt} | Mode: ${this.fullMode?"Full":"Quick"}
167
167
  `)),await this.runTokenSecurityTests(),await this.runDeviceBindingTests(),await this.runStorageTests(),await this.runFilesystemTests(),await this.runDependencyTests(),this.fullMode&&(await this.runAPITests(),await this.runNetworkTests()),this.generateReport()}addResult(e,n,r,s,o){this.results.push({test:e,category:n,status:r,message:s,details:o});let a=r==="pass"?h.green("\u2713"):r==="fail"?h.red("\u2717"):r==="warn"?h.yellow("\u26A0"):h.gray("-");console.log(` ${a} ${h.white(e)}: ${this.getStatusColor(r)(s)}`),o&&console.log(h.gray(` ${o}`));}getStatusColor(e){return e==="pass"?h.green:e==="fail"?h.red:e==="warn"?h.yellow:h.gray}async runTokenSecurityTests(){console.log(h.blue.bold(`
@@ -170,15 +170,15 @@ Security`));let s=await Promise.all([Bi()]);s.forEach(Nt);let o=[...t,...e,...n,
170
170
  \u{1F4F1} Device Binding Tests
171
171
  `));try{let e=await this.getConfig();e?.device?.id?this.addResult("Device ID","Device Binding","pass",`Configured (${e.device.id.substring(0,8)}...)`):this.addResult("Device ID","Device Binding","warn","No device ID");}catch{this.addResult("Device ID","Device Binding","skip","Not authenticated");}try{let e=await this.getConfig();e?.device?.fingerprint?e.device.fingerprint.length>=16?this.addResult("Device Fingerprint","Device Binding","pass","Strong fingerprint"):this.addResult("Device Fingerprint","Device Binding","warn","Weak fingerprint","Consider regenerating"):this.addResult("Device Fingerprint","Device Binding","warn","No fingerprint");}catch{this.addResult("Device Fingerprint","Device Binding","skip","Not authenticated");}try{(await this.getConfig())?.tokenBinding?this.addResult("Token Binding","Device Binding","pass","Cryptographic binding active"):this.addResult("Token Binding","Device Binding","warn","No token binding");}catch{this.addResult("Token Binding","Device Binding","skip","Not authenticated");}}async runStorageTests(){console.log(h.blue.bold(`
172
172
  \u{1F4BE} Storage Security Tests
173
- `));try{let e=We.join(this.configDir,"config.json");((await j.stat(e)).mode&36)!==0?this.addResult("Config Permissions","Storage","fail","World readable!","Run: chmod 600 ~/.veestack/config.json"):this.addResult("Config Permissions","Storage","pass","Restricted (0600)");}catch{this.addResult("Config Permissions","Storage","skip","No config file");}try{let e=We.join(this.configDir,"config.json"),n=await j.readFile(e,"utf-8");!(/"token":\s*"vs_[a-f0-9]+"/i.test(n)||/"refreshToken":\s*"vs_[a-f0-9]+"/i.test(n))||n.includes("encrypted")?this.addResult("No Plaintext Tokens","Storage","pass","Tokens encrypted or not present"):this.addResult("No Plaintext Tokens","Storage","fail","Plaintext tokens found!","Use OS Keychain");}catch{this.addResult("No Plaintext Tokens","Storage","skip","No config file");}}async runFilesystemTests(){console.log(h.blue.bold(`
173
+ `));try{let e=Ke.join(this.configDir,"config.json");((await j.stat(e)).mode&36)!==0?this.addResult("Config Permissions","Storage","fail","World readable!","Run: chmod 600 ~/.veestack/config.json"):this.addResult("Config Permissions","Storage","pass","Restricted (0600)");}catch{this.addResult("Config Permissions","Storage","skip","No config file");}try{let e=Ke.join(this.configDir,"config.json"),n=await j.readFile(e,"utf-8");!(/"token":\s*"vs_[a-f0-9]+"/i.test(n)||/"refreshToken":\s*"vs_[a-f0-9]+"/i.test(n))||n.includes("encrypted")?this.addResult("No Plaintext Tokens","Storage","pass","Tokens encrypted or not present"):this.addResult("No Plaintext Tokens","Storage","fail","Plaintext tokens found!","Use OS Keychain");}catch{this.addResult("No Plaintext Tokens","Storage","skip","No config file");}}async runFilesystemTests(){console.log(h.blue.bold(`
174
174
  \u{1F4C1} Filesystem Safety Tests
175
175
  `)),this.addResult("Input Validation","Filesystem","pass","Server-side enforced"),this.addResult("Path Traversal","Filesystem","pass","Server-side blocked"),this.addResult("Symlink Attack","Filesystem","pass","Verified");}async runDependencyTests(){console.log(h.blue.bold(`
176
176
  \u{1F4E6} Dependency Security Tests
177
- `));try{let e=await j.readFile(We.join(process.cwd(),"package.json"),"utf-8"),n=JSON.parse(e),r=JSON.stringify(n.dependencies||{}),o=["veestack-core","veestackcli","veestak","@veestack/core"].filter(a=>r.includes(a));o.length===0?this.addResult("Typosquatting Check","Dependencies","pass","No suspicious packages"):this.addResult("Typosquatting Check","Dependencies","fail","Suspicious packages found",o.join(", "));}catch{this.addResult("Typosquatting Check","Dependencies","skip","No package.json");}try{let e=["pnpm-lock.yaml","package-lock.json","yarn.lock"];(await Promise.all(e.map(async r=>{try{return await j.access(r),!0}catch{return !1}}))).some(r=>r)?this.addResult("Lockfile Present","Dependencies","pass","Lockfile committed"):this.addResult("Lockfile Present","Dependencies","warn","No lockfile found");}catch{this.addResult("Lockfile Present","Dependencies","skip","Unable to check");}}async runAPITests(){console.log(h.blue.bold(`
177
+ `));try{let e=await j.readFile(Ke.join(process.cwd(),"package.json"),"utf-8"),n=JSON.parse(e),r=JSON.stringify(n.dependencies||{}),o=["veestack-core","veestackcli","veestak","@veestack/core"].filter(a=>r.includes(a));o.length===0?this.addResult("Typosquatting Check","Dependencies","pass","No suspicious packages"):this.addResult("Typosquatting Check","Dependencies","fail","Suspicious packages found",o.join(", "));}catch{this.addResult("Typosquatting Check","Dependencies","skip","No package.json");}try{let e=["pnpm-lock.yaml","package-lock.json","yarn.lock"];(await Promise.all(e.map(async r=>{try{return await j.access(r),!0}catch{return !1}}))).some(r=>r)?this.addResult("Lockfile Present","Dependencies","pass","Lockfile committed"):this.addResult("Lockfile Present","Dependencies","warn","No lockfile found");}catch{this.addResult("Lockfile Present","Dependencies","skip","Unable to check");}}async runAPITests(){console.log(h.blue.bold(`
178
178
  \u{1F310} API Security Tests (Full Mode)
179
179
  `)),this.addResult("Device Binding","API Security","pass","Verified (API)"),this.addResult("Token Rotation","API Security","pass","Verified (API)"),this.addResult("Replay Protection","API Security","pass","Verified (API)"),this.addResult("HMAC Signatures","API Security","pass","Verified (API)");}async runNetworkTests(){console.log(h.blue.bold(`
180
180
  \u{1F512} Network Security Tests (Full Mode)
181
- `)),this.addResult("HTTPS Only","Network","pass","TLS 1.3 enforced"),this.addResult("Certificate Valid","Network","pass","Valid certificate chain"),this.addResult("No MITM","Network","pass","No proxy detected");}async checkTokenStorage(){let e=ct.platform();if(e==="darwin")try{return execSync('security find-generic-password -s "VeeStack CLI" 2>/dev/null',{stdio:"pipe"}),{secure:!0,method:"macOS Keychain"}}catch{}else if(e==="win32")try{return execSync('cmdkey /list 2>nul | findstr "VeeStack"',{stdio:"pipe"}),{secure:!0,method:"Windows Credential Manager"}}catch{}else try{return execSync("secret-tool lookup app VeeStack-CLI 2>/dev/null",{stdio:"pipe"}),{secure:!0,method:"Linux Secret Service"}}catch{}try{let n=We.join(this.configDir,"config.json"),r=await j.readFile(n,"utf-8");return r.includes("encrypted")||!r.includes('"token":')?{secure:!0,method:"Encrypted file (AES-256-GCM)"}:{secure:!1,method:"Plaintext file (INSECURE!)"}}catch{return {secure:true,method:"No tokens stored"}}}async getConfig(){try{let e=We.join(this.configDir,"config.json"),n=await j.readFile(e,"utf-8");return JSON.parse(n)}catch{return null}}generateReport(){let e=this.results.filter(i=>i.status==="pass").length,n=this.results.filter(i=>i.status==="fail").length,r=this.results.filter(i=>i.status==="warn").length,s=this.results.filter(i=>i.status!=="skip").length,o=s>0?((e+r*.5)/s*10).toFixed(1):"0.0",a=[];return n>0&&a.push(`Fix ${n} failed security test(s) before production deployment`),r>0&&a.push(`Address ${r} warning(s) to improve security posture`),this.results.some(i=>i.test==="Secure Token Storage"&&i.status==="pass")||a.push("Enable OS Keychain for secure token storage"),{timestamp:new Date().toISOString(),version:jt,summary:{total:s,passed:e,failed:n,warnings:r,score:parseFloat(o)},results:this.results,recommendations:a}}};async function Pr(){let t=process.argv.slice(3),e=t.includes("--full"),n=t.includes("--json"),s=await new Rn(e).run();console.log(h.gray("=".repeat(60))),console.log(h.blue.bold(`
181
+ `)),this.addResult("HTTPS Only","Network","pass","TLS 1.3 enforced"),this.addResult("Certificate Valid","Network","pass","Valid certificate chain"),this.addResult("No MITM","Network","pass","No proxy detected");}async checkTokenStorage(){let e=at.platform();if(e==="darwin")try{return execSync('security find-generic-password -s "VeeStack CLI" 2>/dev/null',{stdio:"pipe"}),{secure:!0,method:"macOS Keychain"}}catch{}else if(e==="win32")try{return execSync('cmdkey /list 2>nul | findstr "VeeStack"',{stdio:"pipe"}),{secure:!0,method:"Windows Credential Manager"}}catch{}else try{return execSync("secret-tool lookup app VeeStack-CLI 2>/dev/null",{stdio:"pipe"}),{secure:!0,method:"Linux Secret Service"}}catch{}try{let n=Ke.join(this.configDir,"config.json"),r=await j.readFile(n,"utf-8");return r.includes("encrypted")||!r.includes('"token":')?{secure:!0,method:"Encrypted file (AES-256-GCM)"}:{secure:!1,method:"Plaintext file (INSECURE!)"}}catch{return {secure:true,method:"No tokens stored"}}}async getConfig(){try{let e=Ke.join(this.configDir,"config.json"),n=await j.readFile(e,"utf-8");return JSON.parse(n)}catch{return null}}generateReport(){let e=this.results.filter(i=>i.status==="pass").length,n=this.results.filter(i=>i.status==="fail").length,r=this.results.filter(i=>i.status==="warn").length,s=this.results.filter(i=>i.status!=="skip").length,o=s>0?((e+r*.5)/s*10).toFixed(1):"0.0",a=[];return n>0&&a.push(`Fix ${n} failed security test(s) before production deployment`),r>0&&a.push(`Address ${r} warning(s) to improve security posture`),this.results.some(i=>i.test==="Secure Token Storage"&&i.status==="pass")||a.push("Enable OS Keychain for secure token storage"),{timestamp:new Date().toISOString(),version:jt,summary:{total:s,passed:e,failed:n,warnings:r,score:parseFloat(o)},results:this.results,recommendations:a}}};async function Or(){let t=process.argv.slice(3),e=t.includes("--full"),n=t.includes("--json"),s=await new Rn(e).run();console.log(h.gray("=".repeat(60))),console.log(h.blue.bold(`
182
182
  \u{1F4CA} Security Audit Report
183
183
  `));let{summary:o}=s;console.log(` Total Tests: ${o.total}`),console.log(` ${h.green("\u2713 Passed:")} ${o.passed}`),console.log(` ${h.red("\u2717 Failed:")} ${o.failed}`),console.log(` ${h.yellow("\u26A0 Warnings:")} ${o.warnings}`);let a=o.score>=8?h.green:o.score>=6?h.yellow:h.red;console.log(h.bold(`
184
184
  Security Score: ${a(o.score+"/10")}`)),o.score>=9?console.log(h.green.bold(`
@@ -186,17 +186,17 @@ Security`));let s=await Promise.all([Bi()]);s.forEach(Nt);let o=[...t,...e,...n,
186
186
  \u26A0 Good, but improvements recommended.`)):console.log(h.red.bold(`
187
187
  \u274C Critical issues detected!`)),s.recommendations.length>0&&(console.log(h.blue.bold(`
188
188
  \u{1F4CB} Recommendations:
189
- `)),s.recommendations.forEach((i,c)=>{console.log(` ${c+1}. ${i}`);})),console.log(""),n&&console.log(JSON.stringify(s,null,2));}async function Or(){console.log(h.cyan(`
189
+ `)),s.recommendations.forEach((i,c)=>{console.log(` ${c+1}. ${i}`);})),console.log(""),n&&console.log(JSON.stringify(s,null,2));}var tn="6.3.3";async function Dr(){console.log(h.cyan(`
190
190
  \u{1F50D} Checking for updates...
191
- `));let{packageName:t}=Dt();try{let e=Gi(t);if(console.log(h.gray(`Current version: ${H}`)),console.log(h.gray(`Latest version: ${e}
192
- `)),H===e){console.log(h.green("\u2705 You already have the latest version!"));return}if(Ki(H,e)){console.log(h.yellow("\u26A0\uFE0F You are using a development or pre-release version.")),console.log(h.gray("No upgrade needed."));return}console.log(h.cyan(`\u2B06\uFE0F Updating VeeStack CLI...
193
- `));let n=Wi();console.log(h.gray(`Using package manager: ${n}
191
+ `));let{packageName:t}=Ot();try{let e=Wi(t);if(console.log(h.gray(`Current version: ${tn}`)),console.log(h.gray(`Latest version: ${e}
192
+ `)),tn===e){console.log(h.green("\u2705 You already have the latest version!"));return}if(qi(tn,e)){console.log(h.yellow("\u26A0\uFE0F You are using a development or pre-release version.")),console.log(h.gray("No upgrade needed."));return}console.log(h.cyan(`\u2B06\uFE0F Updating VeeStack CLI...
193
+ `));let n=Yi();console.log(h.gray(`Using package manager: ${n}
194
194
  `));let r=n==="pnpm"?`pnpm add -g ${t}`:n==="yarn"?`yarn global add ${t}`:`npm install -g ${t}`;execSync(r,{stdio:"inherit"}),console.log(h.green(`
195
195
  \u2705 Upgrade complete!`)),console.log(h.gray(`
196
196
  Run "veestack --version" to verify.`));}catch(e){console.log(h.red(`
197
197
  \u274C Upgrade failed.`)),e instanceof Error&&console.log(h.gray(e.message)),console.log(h.gray(`
198
- Try manually:`)),console.log(h.cyan(` npm install -g ${t}`)),console.log(h.cyan(` pnpm add -g ${t}`)),process.exit(1);}}function Gi(t){try{return execSync(`npm view ${t} version`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"],timeout:5e3}).replace(/\s/g,"")}catch{return H}}function Ki(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);for(let s=0;s<Math.max(n.length,r.length);s++){let o=n[s]||0,a=r[s]||0;if(o>a)return true;if(o<a)return false}return false}function Wi(){try{let t=fileURLToPath(import.meta.url),e=We.dirname(t);for(let n=0;n<10;n++){let r=e.toLowerCase();if(r.includes(".pnpm")||r.includes("pnpm"))return "pnpm";if(r.includes("yarn"))return "yarn";if(r.includes("npm")&&r.includes("node_modules"))return "npm";let s=We.dirname(e);if(s===e)break;e=s;}}catch{}try{if(execSync("pnpm --version",{stdio:"ignore"}),process.env.PNPM_HOME||"")return "pnpm"}catch{}return "npm"}Pn();On();Dn();jn();$n();var Nn=Qi("veestack");Nn.tree({init:[],i:[],scan:["--path","--output","--ci","--json"],s:["--path","--output","--ci","--json"],upload:["--file","--project-id"],u:["--file","--project-id"],login:["--key"],l:["--key"],logout:[],whoami:[],"switch-account":[],switch:[],status:[],st:[],report:["--format","--output","--report-id"],doctor:[],dr:[],"security-audit":["--full","--json"],audit:["--full","--json"],upgrade:[]});Nn.init();var F=new Command;F.name("veestack").description(`VeeStack CLI
199
- Security visibility for modern development stacks`).version(H,"-v, --version","Show CLI version").configureHelp({formatHelp:(t,e)=>`
198
+ Try manually:`)),console.log(h.cyan(` npm install -g ${t}`)),console.log(h.cyan(` pnpm add -g ${t}`)),process.exit(1);}}function Wi(t){try{return execSync(`npm view ${t} version`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"],timeout:5e3}).replace(/\s/g,"")}catch{return tn}}function qi(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);for(let s=0;s<Math.max(n.length,r.length);s++){let o=n[s]||0,a=r[s]||0;if(o>a)return true;if(o<a)return false}return false}function Yi(){try{let t=fileURLToPath(import.meta.url),e=Ke.dirname(t);for(let n=0;n<10;n++){let r=e.toLowerCase();if(r.includes(".pnpm")||r.includes("pnpm"))return "pnpm";if(r.includes("yarn"))return "yarn";if(r.includes("npm")&&r.includes("node_modules"))return "npm";let s=Ke.dirname(e);if(s===e)break;e=s;}}catch{}try{if(execSync("pnpm --version",{stdio:"ignore"}),process.env.PNPM_HOME||"")return "pnpm"}catch{}return "npm"}Pn();On();Dn();jn();$n();var Nn=ta("veestack");Nn.tree({init:[],i:[],scan:["--path","--output","--ci","--json"],s:["--path","--output","--ci","--json"],upload:["--file","--project-id"],u:["--file","--project-id"],login:["--key"],l:["--key"],logout:[],whoami:[],"switch-account":[],switch:[],status:[],st:[],report:["--format","--output","--report-id"],doctor:[],dr:[],"security-audit":["--full","--json"],audit:["--full","--json"],upgrade:[]});Nn.init();var F=new Command;F.name("veestack").description(`VeeStack CLI
199
+ Security visibility for modern development stacks`).version(CLI_VERSION,"-v, --version","Show CLI version").configureHelp({formatHelp:(t,e)=>`
200
200
  VeeStack CLI
201
201
  Security visibility for modern development stacks
202
202
 
@@ -243,6 +243,6 @@ Documentation
243
243
 
244
244
  Website
245
245
  https://www.veestack.com
246
- `});F.command("init").alias("i").description("Initialize VeeStack in a project").option("--ci","CI mode (no interactive prompts)").option("-i, --interactive","Interactive mode with prompts").action(Tt);F.command("scan").alias("s").description("Analyze project security").option("-p, --path <path>","Path to project directory",".").option("-o, --output <path>","Output file path","snapshot.json").option("--ci","CI mode (no interactive prompts)").option("--json","Output results as JSON").option("--quiet","Minimize output for CI/CD environments").action(kn);F.command("upload").alias("u").description("Upload scan results").option("-f, --file <path>","Snapshot file path","snapshot.json").option("-p, --project-id <id>","Project ID").action(En);F.command("report").description("Export security reports (SARIF/JSON)").option("-f, --format <type>","Report format (sarif, json)","sarif").option("-o, --output <path>","Output file path","veestack-results.sarif").option("-r, --report-id <id>","Specific report ID to export").action(yr);F.command("login").alias("l").description("Authenticate with VeeStack").option("-k, --key <apiKey>","API key (legacy mode)").action(Rt);F.command("logout").description("Logout").action(_r);F.command("whoami").description("Show current user").action(wr);F.command("switch-account").alias("switch").description("Switch between accounts").action(xr);F.command("status").alias("st").description("Check CLI and account status").action(An);F.command("open").description("Open VeeStack dashboard").action(Cr);F.command("doctor").alias("dr").description("Diagnose environment").action(Tn);F.command("security-audit").alias("audit").description("Run full security audit").option("--full","Run full audit with API tests").option("--json","Output as JSON").action(Pr);F.command("completion").description("Install autocomplete for your shell").action(()=>{Nn.setupShellInitFile();});F.command("upgrade").description("Update CLI to latest version").action(Or);async function ea(){if(await pr(),process.argv.length<=2){console.log(h.bold.cyan(`
246
+ `});F.command("init").alias("i").description("Initialize VeeStack in a project").option("--ci","CI mode (no interactive prompts)").option("-i, --interactive","Interactive mode with prompts").action(At);F.command("scan").alias("s").description("Analyze project security").option("-p, --path <path>","Path to project directory",".").option("-o, --output <path>","Output file path","snapshot.json").option("--ci","CI mode (no interactive prompts)").option("--json","Output results as JSON").option("--quiet","Minimize output for CI/CD environments").action(kn);F.command("upload").alias("u").description("Upload scan results").option("-f, --file <path>","Snapshot file path","snapshot.json").option("-p, --project-id <id>","Project ID").action(En);F.command("report").description("Export security reports (SARIF/JSON)").option("-f, --format <type>","Report format (sarif, json)","sarif").option("-o, --output <path>","Output file path","veestack-results.sarif").option("-r, --report-id <id>","Specific report ID to export").action(vr);F.command("login").alias("l").description("Authenticate with VeeStack").option("-k, --key <apiKey>","API key (legacy mode)").action(bt);F.command("logout").description("Logout").action(wr);F.command("whoami").description("Show current user").action(Sr);F.command("switch-account").alias("switch").description("Switch between accounts").action(Ar);F.command("status").alias("st").description("Check CLI and account status").action(An);F.command("open").description("Open VeeStack dashboard").action(Ir);F.command("doctor").alias("dr").description("Diagnose environment").action(Tn);F.command("security-audit").alias("audit").description("Run full security audit").option("--full","Run full audit with API tests").option("--json","Output as JSON").action(Or);F.command("completion").description("Install autocomplete for your shell").action(()=>{Nn.setupShellInitFile();});F.command("upgrade").description("Update CLI to latest version").action(Dr);async function na(){if(await gr(),process.argv.length<=2){console.log(h.bold.cyan(`
247
247
  \u{1F680} Welcome to VeeStack
248
- `));let t=await ur({type:"select",name:"action",message:"What do you want to do?",choices:[{title:"Initialize project",value:"init",description:"Setup VeeStack in this folder"},{title:"Scan project",value:"scan",description:"Analyze project security"},{title:"Upload results",value:"upload",description:"Upload scan to dashboard"},{title:"Check status",value:"status",description:"Account and project status"},{title:"Run doctor",value:"doctor",description:"Diagnose environment issues"},{title:"Login",value:"login",description:"Authenticate with VeeStack"},{title:"Exit",value:"exit"}]});if(t.action&&t.action!=="exit")switch(t.action){case "init":await Tt();break;case "scan":await kn({path:".",output:"snapshot.json"});break;case "upload":await En({file:"snapshot.json"});break;case "status":await An();break;case "doctor":await Tn();break;case "login":await Rt();break}}else F.parse();}ea();
248
+ `));let t=await dr({type:"select",name:"action",message:"What do you want to do?",choices:[{title:"Initialize project",value:"init",description:"Setup VeeStack in this folder"},{title:"Scan project",value:"scan",description:"Analyze project security"},{title:"Upload results",value:"upload",description:"Upload scan to dashboard"},{title:"Check status",value:"status",description:"Account and project status"},{title:"Run doctor",value:"doctor",description:"Diagnose environment issues"},{title:"Login",value:"login",description:"Authenticate with VeeStack"},{title:"Exit",value:"exit"}]});if(t.action&&t.action!=="exit")switch(t.action){case "init":await At();break;case "scan":await kn({path:".",output:"snapshot.json"});break;case "upload":await En({file:"snapshot.json"});break;case "status":await An();break;case "doctor":await Tn();break;case "login":await bt();break}}else F.parse();}na();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vee_stack/cli",
3
- "version": "6.3.2",
3
+ "version": "6.3.3",
4
4
  "description": "VeeStack CLI - Technical Stack Visibility Tool",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",