@spectrl/cli 0.6.1 → 0.6.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.
- package/README.md +446 -281
- package/dist/cli.js +216 -194
- package/package.json +25 -15
- package/LICENSE +0 -21
package/dist/cli.js
CHANGED
|
@@ -1,234 +1,256 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var ci=Object.create;var Jt=Object.defineProperty;var li=Object.getOwnPropertyDescriptor;var ui=Object.getOwnPropertyNames;var di=Object.getPrototypeOf,fi=Object.prototype.hasOwnProperty;var R=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),pi=(r,e)=>{for(var t in e)Jt(r,t,{get:e[t],enumerable:!0})},hi=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ui(e))!fi.call(r,n)&&n!==t&&Jt(r,n,{get:()=>e[n],enumerable:!(s=li(e,n))||s.enumerable});return r};var mi=(r,e,t)=>(t=r!=null?ci(di(r)):{},hi(e||!r||!r.__esModule?Jt(t,"default",{value:r,enumerable:!0}):t,r));var ot=R((_d,Gr)=>{"use strict";var Da="2.0.0",qa=Number.MAX_SAFE_INTEGER||9007199254740991,Ma=16,Va=250,Ua=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Gr.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:Ma,MAX_SAFE_BUILD_LENGTH:Va,MAX_SAFE_INTEGER:qa,RELEASE_TYPES:Ua,SEMVER_SPEC_VERSION:Da,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var ct=R((Rd,Zr)=>{"use strict";var za=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...r)=>console.error("SEMVER",...r):()=>{};Zr.exports=za});var Je=R((ce,Wr)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:rr,MAX_SAFE_BUILD_LENGTH:Ga,MAX_LENGTH:Za}=ot(),Wa=ct();ce=Wr.exports={};var Xa=ce.re=[],Ha=ce.safeRe=[],m=ce.src=[],Ba=ce.safeSrc=[],g=ce.t={},Ja=0,sr="[a-zA-Z0-9-]",Ya=[["\\s",1],["\\d",Za],[sr,Ga]],Ka=r=>{for(let[e,t]of Ya)r=r.split(`${e}*`).join(`${e}{0,${t}}`).split(`${e}+`).join(`${e}{1,${t}}`);return r},k=(r,e,t)=>{let s=Ka(e),n=Ja++;Wa(r,n,e),g[r]=n,m[n]=e,Ba[n]=s,Xa[n]=new RegExp(e,t?"g":void 0),Ha[n]=new RegExp(s,t?"g":void 0)};k("NUMERICIDENTIFIER","0|[1-9]\\d*");k("NUMERICIDENTIFIERLOOSE","\\d+");k("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${sr}*`);k("MAINVERSION",`(${m[g.NUMERICIDENTIFIER]})\\.(${m[g.NUMERICIDENTIFIER]})\\.(${m[g.NUMERICIDENTIFIER]})`);k("MAINVERSIONLOOSE",`(${m[g.NUMERICIDENTIFIERLOOSE]})\\.(${m[g.NUMERICIDENTIFIERLOOSE]})\\.(${m[g.NUMERICIDENTIFIERLOOSE]})`);k("PRERELEASEIDENTIFIER",`(?:${m[g.NONNUMERICIDENTIFIER]}|${m[g.NUMERICIDENTIFIER]})`);k("PRERELEASEIDENTIFIERLOOSE",`(?:${m[g.NONNUMERICIDENTIFIER]}|${m[g.NUMERICIDENTIFIERLOOSE]})`);k("PRERELEASE",`(?:-(${m[g.PRERELEASEIDENTIFIER]}(?:\\.${m[g.PRERELEASEIDENTIFIER]})*))`);k("PRERELEASELOOSE",`(?:-?(${m[g.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${m[g.PRERELEASEIDENTIFIERLOOSE]})*))`);k("BUILDIDENTIFIER",`${sr}+`);k("BUILD",`(?:\\+(${m[g.BUILDIDENTIFIER]}(?:\\.${m[g.BUILDIDENTIFIER]})*))`);k("FULLPLAIN",`v?${m[g.MAINVERSION]}${m[g.PRERELEASE]}?${m[g.BUILD]}?`);k("FULL",`^${m[g.FULLPLAIN]}$`);k("LOOSEPLAIN",`[v=\\s]*${m[g.MAINVERSIONLOOSE]}${m[g.PRERELEASELOOSE]}?${m[g.BUILD]}?`);k("LOOSE",`^${m[g.LOOSEPLAIN]}$`);k("GTLT","((?:<|>)?=?)");k("XRANGEIDENTIFIERLOOSE",`${m[g.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);k("XRANGEIDENTIFIER",`${m[g.NUMERICIDENTIFIER]}|x|X|\\*`);k("XRANGEPLAIN",`[v=\\s]*(${m[g.XRANGEIDENTIFIER]})(?:\\.(${m[g.XRANGEIDENTIFIER]})(?:\\.(${m[g.XRANGEIDENTIFIER]})(?:${m[g.PRERELEASE]})?${m[g.BUILD]}?)?)?`);k("XRANGEPLAINLOOSE",`[v=\\s]*(${m[g.XRANGEIDENTIFIERLOOSE]})(?:\\.(${m[g.XRANGEIDENTIFIERLOOSE]})(?:\\.(${m[g.XRANGEIDENTIFIERLOOSE]})(?:${m[g.PRERELEASELOOSE]})?${m[g.BUILD]}?)?)?`);k("XRANGE",`^${m[g.GTLT]}\\s*${m[g.XRANGEPLAIN]}$`);k("XRANGELOOSE",`^${m[g.GTLT]}\\s*${m[g.XRANGEPLAINLOOSE]}$`);k("COERCEPLAIN",`(^|[^\\d])(\\d{1,${rr}})(?:\\.(\\d{1,${rr}}))?(?:\\.(\\d{1,${rr}}))?`);k("COERCE",`${m[g.COERCEPLAIN]}(?:$|[^\\d])`);k("COERCEFULL",m[g.COERCEPLAIN]+`(?:${m[g.PRERELEASE]})?(?:${m[g.BUILD]})?(?:$|[^\\d])`);k("COERCERTL",m[g.COERCE],!0);k("COERCERTLFULL",m[g.COERCEFULL],!0);k("LONETILDE","(?:~>?)");k("TILDETRIM",`(\\s*)${m[g.LONETILDE]}\\s+`,!0);ce.tildeTrimReplace="$1~";k("TILDE",`^${m[g.LONETILDE]}${m[g.XRANGEPLAIN]}$`);k("TILDELOOSE",`^${m[g.LONETILDE]}${m[g.XRANGEPLAINLOOSE]}$`);k("LONECARET","(?:\\^)");k("CARETTRIM",`(\\s*)${m[g.LONECARET]}\\s+`,!0);ce.caretTrimReplace="$1^";k("CARET",`^${m[g.LONECARET]}${m[g.XRANGEPLAIN]}$`);k("CARETLOOSE",`^${m[g.LONECARET]}${m[g.XRANGEPLAINLOOSE]}$`);k("COMPARATORLOOSE",`^${m[g.GTLT]}\\s*(${m[g.LOOSEPLAIN]})$|^$`);k("COMPARATOR",`^${m[g.GTLT]}\\s*(${m[g.FULLPLAIN]})$|^$`);k("COMPARATORTRIM",`(\\s*)${m[g.GTLT]}\\s*(${m[g.LOOSEPLAIN]}|${m[g.XRANGEPLAIN]})`,!0);ce.comparatorTrimReplace="$1$2$3";k("HYPHENRANGE",`^\\s*(${m[g.XRANGEPLAIN]})\\s+-\\s+(${m[g.XRANGEPLAIN]})\\s*$`);k("HYPHENRANGELOOSE",`^\\s*(${m[g.XRANGEPLAINLOOSE]})\\s+-\\s+(${m[g.XRANGEPLAINLOOSE]})\\s*$`);k("STAR","(<|>)?=?\\s*\\*");k("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");k("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var Tt=R((kd,Xr)=>{"use strict";var Qa=Object.freeze({loose:!0}),eo=Object.freeze({}),to=r=>r?typeof r!="object"?Qa:r:eo;Xr.exports=to});var nr=R((Id,Jr)=>{"use strict";var Hr=/^[0-9]+$/,Br=(r,e)=>{if(typeof r=="number"&&typeof e=="number")return r===e?0:r<e?-1:1;let t=Hr.test(r),s=Hr.test(e);return t&&s&&(r=+r,e=+e),r===e?0:t&&!s?-1:s&&!t?1:r<e?-1:1},ro=(r,e)=>Br(e,r);Jr.exports={compareIdentifiers:Br,rcompareIdentifiers:ro}});var U=R((Sd,Kr)=>{"use strict";var At=ct(),{MAX_LENGTH:Yr,MAX_SAFE_INTEGER:Ct}=ot(),{safeRe:Pt,t:Lt}=Je(),so=Tt(),{compareIdentifiers:ir}=nr(),ar=class r{constructor(e,t){if(t=so(t),e instanceof r){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>Yr)throw new TypeError(`version is longer than ${Yr} characters`);At("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;let s=e.trim().match(t.loose?Pt[Lt.LOOSE]:Pt[Lt.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>Ct||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Ct||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Ct||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let i=+n;if(i>=0&&i<Ct)return i}return n}):this.prerelease=[],this.build=s[5]?s[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(At("SemVer.compare",this.version,this.options,e),!(e instanceof r)){if(typeof e=="string"&&e===this.version)return 0;e=new r(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof r||(e=new r(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof r||(e=new r(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{let s=this.prerelease[t],n=e.prerelease[t];if(At("prerelease compare",t,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return ir(s,n)}while(++t)}compareBuild(e){e instanceof r||(e=new r(e,this.options));let t=0;do{let s=this.build[t],n=e.build[t];if(At("build compare",t,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return ir(s,n)}while(++t)}inc(e,t,s){if(e.startsWith("pre")){if(!t&&s===!1)throw new Error("invalid increment argument: identifier is empty");if(t){let n=`-${t}`.match(this.options.loose?Pt[Lt.PRERELEASELOOSE]:Pt[Lt.PRERELEASE]);if(!n||n[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,s);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,s);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,s),this.inc("pre",t,s);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t,s),this.inc("pre",t,s);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let n=Number(s)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let i=this.prerelease.length;for(;--i>=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);if(i===-1){if(t===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(t){let i=[t,n];s===!1&&(i=[t]),ir(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=i):this.prerelease=i}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};Kr.exports=ar});var Ve=R(($d,es)=>{"use strict";var Qr=U(),no=(r,e,t=!1)=>{if(r instanceof Qr)return r;try{return new Qr(r,e)}catch(s){if(!t)return null;throw s}};es.exports=no});var rs=R((bd,ts)=>{"use strict";var io=Ve(),ao=(r,e)=>{let t=io(r,e);return t?t.version:null};ts.exports=ao});var ns=R((Od,ss)=>{"use strict";var oo=Ve(),co=(r,e)=>{let t=oo(r.trim().replace(/^[=v]+/,""),e);return t?t.version:null};ss.exports=co});var os=R((Nd,as)=>{"use strict";var is=U(),lo=(r,e,t,s,n)=>{typeof t=="string"&&(n=s,s=t,t=void 0);try{return new is(r instanceof is?r.version:r,t).inc(e,s,n).version}catch{return null}};as.exports=lo});var us=R((Td,ls)=>{"use strict";var cs=Ve(),uo=(r,e)=>{let t=cs(r,null,!0),s=cs(e,null,!0),n=t.compare(s);if(n===0)return null;let i=n>0,a=i?t:s,o=i?s:t,c=!!a.prerelease.length;if(!!o.prerelease.length&&!c){if(!o.patch&&!o.minor)return"major";if(o.compareMain(a)===0)return o.minor&&!o.patch?"minor":"patch"}let u=c?"pre":"";return t.major!==s.major?u+"major":t.minor!==s.minor?u+"minor":t.patch!==s.patch?u+"patch":"prerelease"};ls.exports=uo});var fs=R((Ad,ds)=>{"use strict";var fo=U(),po=(r,e)=>new fo(r,e).major;ds.exports=po});var hs=R((Cd,ps)=>{"use strict";var ho=U(),mo=(r,e)=>new ho(r,e).minor;ps.exports=mo});var gs=R((Pd,ms)=>{"use strict";var go=U(),yo=(r,e)=>new go(r,e).patch;ms.exports=yo});var xs=R((Ld,ys)=>{"use strict";var xo=Ve(),vo=(r,e)=>{let t=xo(r,e);return t&&t.prerelease.length?t.prerelease:null};ys.exports=vo});var Q=R((jd,ws)=>{"use strict";var vs=U(),wo=(r,e,t)=>new vs(r,t).compare(new vs(e,t));ws.exports=wo});var _s=R((Fd,Es)=>{"use strict";var Eo=Q(),_o=(r,e,t)=>Eo(e,r,t);Es.exports=_o});var ks=R((Dd,Rs)=>{"use strict";var Ro=Q(),ko=(r,e)=>Ro(r,e,!0);Rs.exports=ko});var jt=R((qd,Ss)=>{"use strict";var Is=U(),Io=(r,e,t)=>{let s=new Is(r,t),n=new Is(e,t);return s.compare(n)||s.compareBuild(n)};Ss.exports=Io});var bs=R((Md,$s)=>{"use strict";var So=jt(),$o=(r,e)=>r.sort((t,s)=>So(t,s,e));$s.exports=$o});var Ns=R((Vd,Os)=>{"use strict";var bo=jt(),Oo=(r,e)=>r.sort((t,s)=>bo(s,t,e));Os.exports=Oo});var lt=R((Ud,Ts)=>{"use strict";var No=Q(),To=(r,e,t)=>No(r,e,t)>0;Ts.exports=To});var Ft=R((zd,As)=>{"use strict";var Ao=Q(),Co=(r,e,t)=>Ao(r,e,t)<0;As.exports=Co});var or=R((Gd,Cs)=>{"use strict";var Po=Q(),Lo=(r,e,t)=>Po(r,e,t)===0;Cs.exports=Lo});var cr=R((Zd,Ps)=>{"use strict";var jo=Q(),Fo=(r,e,t)=>jo(r,e,t)!==0;Ps.exports=Fo});var Dt=R((Wd,Ls)=>{"use strict";var Do=Q(),qo=(r,e,t)=>Do(r,e,t)>=0;Ls.exports=qo});var qt=R((Xd,js)=>{"use strict";var Mo=Q(),Vo=(r,e,t)=>Mo(r,e,t)<=0;js.exports=Vo});var lr=R((Hd,Fs)=>{"use strict";var Uo=or(),zo=cr(),Go=lt(),Zo=Dt(),Wo=Ft(),Xo=qt(),Ho=(r,e,t,s)=>{switch(e){case"===":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r===t;case"!==":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r!==t;case"":case"=":case"==":return Uo(r,t,s);case"!=":return zo(r,t,s);case">":return Go(r,t,s);case">=":return Zo(r,t,s);case"<":return Wo(r,t,s);case"<=":return Xo(r,t,s);default:throw new TypeError(`Invalid operator: ${e}`)}};Fs.exports=Ho});var qs=R((Bd,Ds)=>{"use strict";var Bo=U(),Jo=Ve(),{safeRe:Mt,t:Vt}=Je(),Yo=(r,e)=>{if(r instanceof Bo)return r;if(typeof r=="number"&&(r=String(r)),typeof r!="string")return null;e=e||{};let t=null;if(!e.rtl)t=r.match(e.includePrerelease?Mt[Vt.COERCEFULL]:Mt[Vt.COERCE]);else{let c=e.includePrerelease?Mt[Vt.COERCERTLFULL]:Mt[Vt.COERCERTL],l;for(;(l=c.exec(r))&&(!t||t.index+t[0].length!==r.length);)(!t||l.index+l[0].length!==t.index+t[0].length)&&(t=l),c.lastIndex=l.index+l[1].length+l[2].length;c.lastIndex=-1}if(t===null)return null;let s=t[2],n=t[3]||"0",i=t[4]||"0",a=e.includePrerelease&&t[5]?`-${t[5]}`:"",o=e.includePrerelease&&t[6]?`+${t[6]}`:"";return Jo(`${s}.${n}.${i}${a}${o}`,e)};Ds.exports=Yo});var Vs=R((Jd,Ms)=>{"use strict";var ur=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(e,t)}return this}};Ms.exports=ur});var ee=R((Yd,Zs)=>{"use strict";var Ko=/\s+/g,dr=class r{constructor(e,t){if(t=ec(t),e instanceof r)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new r(e.raw,t);if(e instanceof fr)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(Ko," "),this.set=this.raw.split("||").map(s=>this.parseRange(s.trim())).filter(s=>s.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let s=this.set[0];if(this.set=this.set.filter(n=>!zs(n[0])),this.set.length===0)this.set=[s];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&oc(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");let t=this.set[e];for(let s=0;s<t.length;s++)s>0&&(this.formatted+=" "),this.formatted+=t[s].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let s=((this.options.includePrerelease&&ic)|(this.options.loose&&ac))+":"+e,n=Us.get(s);if(n)return n;let i=this.options.loose,a=i?G[z.HYPHENRANGELOOSE]:G[z.HYPHENRANGE];e=e.replace(a,yc(this.options.includePrerelease)),L("hyphen replace",e),e=e.replace(G[z.COMPARATORTRIM],rc),L("comparator trim",e),e=e.replace(G[z.TILDETRIM],sc),L("tilde trim",e),e=e.replace(G[z.CARETTRIM],nc),L("caret trim",e);let o=e.split(" ").map(y=>cc(y,this.options)).join(" ").split(/\s+/).map(y=>gc(y,this.options));i&&(o=o.filter(y=>(L("loose invalid filter",y,this.options),!!y.match(G[z.COMPARATORLOOSE])))),L("range list",o);let c=new Map,l=o.map(y=>new fr(y,this.options));for(let y of l){if(zs(y))return[y];c.set(y.value,y)}c.size>1&&c.has("")&&c.delete("");let u=[...c.values()];return Us.set(s,u),u}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Range is required");return this.set.some(s=>Gs(s,t)&&e.set.some(n=>Gs(n,t)&&s.every(i=>n.every(a=>i.intersects(a,t)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new tc(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(xc(this.set[t],e,this.options))return!0;return!1}};Zs.exports=dr;var Qo=Vs(),Us=new Qo,ec=Tt(),fr=ut(),L=ct(),tc=U(),{safeRe:G,t:z,comparatorTrimReplace:rc,tildeTrimReplace:sc,caretTrimReplace:nc}=Je(),{FLAG_INCLUDE_PRERELEASE:ic,FLAG_LOOSE:ac}=ot(),zs=r=>r.value==="<0.0.0-0",oc=r=>r.value==="",Gs=(r,e)=>{let t=!0,s=r.slice(),n=s.pop();for(;t&&s.length;)t=s.every(i=>n.intersects(i,e)),n=s.pop();return t},cc=(r,e)=>(r=r.replace(G[z.BUILD],""),L("comp",r,e),r=dc(r,e),L("caret",r),r=lc(r,e),L("tildes",r),r=pc(r,e),L("xrange",r),r=mc(r,e),L("stars",r),r),Z=r=>!r||r.toLowerCase()==="x"||r==="*",lc=(r,e)=>r.trim().split(/\s+/).map(t=>uc(t,e)).join(" "),uc=(r,e)=>{let t=e.loose?G[z.TILDELOOSE]:G[z.TILDE];return r.replace(t,(s,n,i,a,o)=>{L("tilde",r,s,n,i,a,o);let c;return Z(n)?c="":Z(i)?c=`>=${n}.0.0 <${+n+1}.0.0-0`:Z(a)?c=`>=${n}.${i}.0 <${n}.${+i+1}.0-0`:o?(L("replaceTilde pr",o),c=`>=${n}.${i}.${a}-${o} <${n}.${+i+1}.0-0`):c=`>=${n}.${i}.${a} <${n}.${+i+1}.0-0`,L("tilde return",c),c})},dc=(r,e)=>r.trim().split(/\s+/).map(t=>fc(t,e)).join(" "),fc=(r,e)=>{L("caret",r,e);let t=e.loose?G[z.CARETLOOSE]:G[z.CARET],s=e.includePrerelease?"-0":"";return r.replace(t,(n,i,a,o,c)=>{L("caret",r,n,i,a,o,c);let l;return Z(i)?l="":Z(a)?l=`>=${i}.0.0${s} <${+i+1}.0.0-0`:Z(o)?i==="0"?l=`>=${i}.${a}.0${s} <${i}.${+a+1}.0-0`:l=`>=${i}.${a}.0${s} <${+i+1}.0.0-0`:c?(L("replaceCaret pr",c),i==="0"?a==="0"?l=`>=${i}.${a}.${o}-${c} <${i}.${a}.${+o+1}-0`:l=`>=${i}.${a}.${o}-${c} <${i}.${+a+1}.0-0`:l=`>=${i}.${a}.${o}-${c} <${+i+1}.0.0-0`):(L("no pr"),i==="0"?a==="0"?l=`>=${i}.${a}.${o}${s} <${i}.${a}.${+o+1}-0`:l=`>=${i}.${a}.${o}${s} <${i}.${+a+1}.0-0`:l=`>=${i}.${a}.${o} <${+i+1}.0.0-0`),L("caret return",l),l})},pc=(r,e)=>(L("replaceXRanges",r,e),r.split(/\s+/).map(t=>hc(t,e)).join(" ")),hc=(r,e)=>{r=r.trim();let t=e.loose?G[z.XRANGELOOSE]:G[z.XRANGE];return r.replace(t,(s,n,i,a,o,c)=>{L("xRange",r,s,n,i,a,o,c);let l=Z(i),u=l||Z(a),y=u||Z(o),$=y;return n==="="&&$&&(n=""),c=e.includePrerelease?"-0":"",l?n===">"||n==="<"?s="<0.0.0-0":s="*":n&&$?(u&&(a=0),o=0,n===">"?(n=">=",u?(i=+i+1,a=0,o=0):(a=+a+1,o=0)):n==="<="&&(n="<",u?i=+i+1:a=+a+1),n==="<"&&(c="-0"),s=`${n+i}.${a}.${o}${c}`):u?s=`>=${i}.0.0${c} <${+i+1}.0.0-0`:y&&(s=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),L("xRange return",s),s})},mc=(r,e)=>(L("replaceStars",r,e),r.trim().replace(G[z.STAR],"")),gc=(r,e)=>(L("replaceGTE0",r,e),r.trim().replace(G[e.includePrerelease?z.GTE0PRE:z.GTE0],"")),yc=r=>(e,t,s,n,i,a,o,c,l,u,y,$)=>(Z(s)?t="":Z(n)?t=`>=${s}.0.0${r?"-0":""}`:Z(i)?t=`>=${s}.${n}.0${r?"-0":""}`:a?t=`>=${t}`:t=`>=${t}${r?"-0":""}`,Z(l)?c="":Z(u)?c=`<${+l+1}.0.0-0`:Z(y)?c=`<${l}.${+u+1}.0-0`:$?c=`<=${l}.${u}.${y}-${$}`:r?c=`<${l}.${u}.${+y+1}-0`:c=`<=${c}`,`${t} ${c}`.trim()),xc=(r,e,t)=>{for(let s=0;s<r.length;s++)if(!r[s].test(e))return!1;if(e.prerelease.length&&!t.includePrerelease){for(let s=0;s<r.length;s++)if(L(r[s].semver),r[s].semver!==fr.ANY&&r[s].semver.prerelease.length>0){let n=r[s].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}});var ut=R((Kd,Ys)=>{"use strict";var dt=Symbol("SemVer ANY"),mr=class r{static get ANY(){return dt}constructor(e,t){if(t=Ws(t),e instanceof r){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),hr("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===dt?this.value="":this.value=this.operator+this.semver.version,hr("comp",this)}parse(e){let t=this.options.loose?Xs[Hs.COMPARATORLOOSE]:Xs[Hs.COMPARATOR],s=e.match(t);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=s[1]!==void 0?s[1]:"",this.operator==="="&&(this.operator=""),s[2]?this.semver=new Bs(s[2],this.options.loose):this.semver=dt}toString(){return this.value}test(e){if(hr("Comparator.test",e,this.options.loose),this.semver===dt||e===dt)return!0;if(typeof e=="string")try{e=new Bs(e,this.options)}catch{return!1}return pr(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof r))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new Js(e.value,t).test(this.value):e.operator===""?e.value===""?!0:new Js(this.value,t).test(e.semver):(t=Ws(t),t.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||pr(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||pr(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};Ys.exports=mr;var Ws=Tt(),{safeRe:Xs,t:Hs}=Je(),pr=lr(),hr=ct(),Bs=U(),Js=ee()});var ft=R((Qd,Ks)=>{"use strict";var vc=ee(),wc=(r,e,t)=>{try{e=new vc(e,t)}catch{return!1}return e.test(r)};Ks.exports=wc});var en=R((ef,Qs)=>{"use strict";var Ec=ee(),_c=(r,e)=>new Ec(r,e).set.map(t=>t.map(s=>s.value).join(" ").trim().split(" "));Qs.exports=_c});var rn=R((tf,tn)=>{"use strict";var Rc=U(),kc=ee(),Ic=(r,e,t)=>{let s=null,n=null,i=null;try{i=new kc(e,t)}catch{return null}return r.forEach(a=>{i.test(a)&&(!s||n.compare(a)===-1)&&(s=a,n=new Rc(s,t))}),s};tn.exports=Ic});var nn=R((rf,sn)=>{"use strict";var Sc=U(),$c=ee(),bc=(r,e,t)=>{let s=null,n=null,i=null;try{i=new $c(e,t)}catch{return null}return r.forEach(a=>{i.test(a)&&(!s||n.compare(a)===1)&&(s=a,n=new Sc(s,t))}),s};sn.exports=bc});var cn=R((sf,on)=>{"use strict";var gr=U(),Oc=ee(),an=lt(),Nc=(r,e)=>{r=new Oc(r,e);let t=new gr("0.0.0");if(r.test(t)||(t=new gr("0.0.0-0"),r.test(t)))return t;t=null;for(let s=0;s<r.set.length;++s){let n=r.set[s],i=null;n.forEach(a=>{let o=new gr(a.semver.version);switch(a.operator){case">":o.prerelease.length===0?o.patch++:o.prerelease.push(0),o.raw=o.format();case"":case">=":(!i||an(o,i))&&(i=o);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${a.operator}`)}}),i&&(!t||an(t,i))&&(t=i)}return t&&r.test(t)?t:null};on.exports=Nc});var un=R((nf,ln)=>{"use strict";var Tc=ee(),Ac=(r,e)=>{try{return new Tc(r,e).range||"*"}catch{return null}};ln.exports=Ac});var Ut=R((af,hn)=>{"use strict";var Cc=U(),pn=ut(),{ANY:Pc}=pn,Lc=ee(),jc=ft(),dn=lt(),fn=Ft(),Fc=qt(),Dc=Dt(),qc=(r,e,t,s)=>{r=new Cc(r,s),e=new Lc(e,s);let n,i,a,o,c;switch(t){case">":n=dn,i=Fc,a=fn,o=">",c=">=";break;case"<":n=fn,i=Dc,a=dn,o="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(jc(r,e,s))return!1;for(let l=0;l<e.set.length;++l){let u=e.set[l],y=null,$=null;if(u.forEach(f=>{f.semver===Pc&&(f=new pn(">=0.0.0")),y=y||f,$=$||f,n(f.semver,y.semver,s)?y=f:a(f.semver,$.semver,s)&&($=f)}),y.operator===o||y.operator===c||(!$.operator||$.operator===o)&&i(r,$.semver))return!1;if($.operator===c&&a(r,$.semver))return!1}return!0};hn.exports=qc});var gn=R((of,mn)=>{"use strict";var Mc=Ut(),Vc=(r,e,t)=>Mc(r,e,">",t);mn.exports=Vc});var xn=R((cf,yn)=>{"use strict";var Uc=Ut(),zc=(r,e,t)=>Uc(r,e,"<",t);yn.exports=zc});var En=R((lf,wn)=>{"use strict";var vn=ee(),Gc=(r,e,t)=>(r=new vn(r,t),e=new vn(e,t),r.intersects(e,t));wn.exports=Gc});var Rn=R((uf,_n)=>{"use strict";var Zc=ft(),Wc=Q();_n.exports=(r,e,t)=>{let s=[],n=null,i=null,a=r.sort((u,y)=>Wc(u,y,t));for(let u of a)Zc(u,e,t)?(i=u,n||(n=u)):(i&&s.push([n,i]),i=null,n=null);n&&s.push([n,null]);let o=[];for(let[u,y]of s)u===y?o.push(u):!y&&u===a[0]?o.push("*"):y?u===a[0]?o.push(`<=${y}`):o.push(`${u} - ${y}`):o.push(`>=${u}`);let c=o.join(" || "),l=typeof e.raw=="string"?e.raw:String(e);return c.length<l.length?c:e}});var On=R((df,bn)=>{"use strict";var kn=ee(),xr=ut(),{ANY:yr}=xr,pt=ft(),vr=Q(),Xc=(r,e,t={})=>{if(r===e)return!0;r=new kn(r,t),e=new kn(e,t);let s=!1;e:for(let n of r.set){for(let i of e.set){let a=Bc(n,i,t);if(s=s||a!==null,a)continue e}if(s)return!1}return!0},Hc=[new xr(">=0.0.0-0")],In=[new xr(">=0.0.0")],Bc=(r,e,t)=>{if(r===e)return!0;if(r.length===1&&r[0].semver===yr){if(e.length===1&&e[0].semver===yr)return!0;t.includePrerelease?r=Hc:r=In}if(e.length===1&&e[0].semver===yr){if(t.includePrerelease)return!0;e=In}let s=new Set,n,i;for(let f of r)f.operator===">"||f.operator===">="?n=Sn(n,f,t):f.operator==="<"||f.operator==="<="?i=$n(i,f,t):s.add(f.semver);if(s.size>1)return null;let a;if(n&&i){if(a=vr(n.semver,i.semver,t),a>0)return null;if(a===0&&(n.operator!==">="||i.operator!=="<="))return null}for(let f of s){if(n&&!pt(f,String(n),t)||i&&!pt(f,String(i),t))return null;for(let A of e)if(!pt(f,String(A),t))return!1;return!0}let o,c,l,u,y=i&&!t.includePrerelease&&i.semver.prerelease.length?i.semver:!1,$=n&&!t.includePrerelease&&n.semver.prerelease.length?n.semver:!1;y&&y.prerelease.length===1&&i.operator==="<"&&y.prerelease[0]===0&&(y=!1);for(let f of e){if(u=u||f.operator===">"||f.operator===">=",l=l||f.operator==="<"||f.operator==="<=",n){if($&&f.semver.prerelease&&f.semver.prerelease.length&&f.semver.major===$.major&&f.semver.minor===$.minor&&f.semver.patch===$.patch&&($=!1),f.operator===">"||f.operator===">="){if(o=Sn(n,f,t),o===f&&o!==n)return!1}else if(n.operator===">="&&!pt(n.semver,String(f),t))return!1}if(i){if(y&&f.semver.prerelease&&f.semver.prerelease.length&&f.semver.major===y.major&&f.semver.minor===y.minor&&f.semver.patch===y.patch&&(y=!1),f.operator==="<"||f.operator==="<="){if(c=$n(i,f,t),c===f&&c!==i)return!1}else if(i.operator==="<="&&!pt(i.semver,String(f),t))return!1}if(!f.operator&&(i||n)&&a!==0)return!1}return!(n&&l&&!i&&a!==0||i&&u&&!n&&a!==0||$||y)},Sn=(r,e,t)=>{if(!r)return e;let s=vr(r.semver,e.semver,t);return s>0?r:s<0||e.operator===">"&&r.operator===">="?e:r},$n=(r,e,t)=>{if(!r)return e;let s=vr(r.semver,e.semver,t);return s<0?r:s>0||e.operator==="<"&&r.operator==="<="?e:r};bn.exports=Xc});var Cn=R((ff,An)=>{"use strict";var wr=Je(),Nn=ot(),Jc=U(),Tn=nr(),Yc=Ve(),Kc=rs(),Qc=ns(),el=os(),tl=us(),rl=fs(),sl=hs(),nl=gs(),il=xs(),al=Q(),ol=_s(),cl=ks(),ll=jt(),ul=bs(),dl=Ns(),fl=lt(),pl=Ft(),hl=or(),ml=cr(),gl=Dt(),yl=qt(),xl=lr(),vl=qs(),wl=ut(),El=ee(),_l=ft(),Rl=en(),kl=rn(),Il=nn(),Sl=cn(),$l=un(),bl=Ut(),Ol=gn(),Nl=xn(),Tl=En(),Al=Rn(),Cl=On();An.exports={parse:Yc,valid:Kc,clean:Qc,inc:el,diff:tl,major:rl,minor:sl,patch:nl,prerelease:il,compare:al,rcompare:ol,compareLoose:cl,compareBuild:ll,sort:ul,rsort:dl,gt:fl,lt:pl,eq:hl,neq:ml,gte:gl,lte:yl,cmp:xl,coerce:vl,Comparator:wl,Range:El,satisfies:_l,toComparators:Rl,maxSatisfying:kl,minSatisfying:Il,minVersion:Sl,validRange:$l,outside:bl,gtr:Ol,ltr:Nl,intersects:Tl,simplifyRange:Al,subset:Cl,SemVer:Jc,re:wr.re,src:wr.src,tokens:wr.t,SEMVER_SPEC_VERSION:Nn.SEMVER_SPEC_VERSION,RELEASE_TYPES:Nn.RELEASE_TYPES,compareIdentifiers:Tn.compareIdentifiers,rcompareIdentifiers:Tn.rcompareIdentifiers}});import{command as Wt,subcommands as nu,run as iu,positional as oi,option as ii,string as Zt,optional as br,flag as ai}from"cmd-ts";import{writeFile as Ul,mkdir as zl,rm as Gl}from"node:fs/promises";import Zl from"ora";import{access as Pl,constants as Ll,readFile as Er}from"node:fs/promises";import{join as Ye}from"node:path";import{homedir as jl}from"node:os";import{select as Fl}from"@inquirer/prompts";import tt from"chalk";var w={SUCCESS:0,VALIDATION_ERROR:1,IO_ERROR:2,DEPENDENCY_ERROR:3,USER_CANCELLED:130},v=class r extends Error{constructor(t,s){super(t);this.exitCode=s;this.name="CLIError",Error.captureStackTrace(this,r)}};function Yt(r,e){let t=tt.red("Error:"),s=e?` ${tt.yellow(e)} failed:`:"";return`${t}${s} ${r.message}`}function rt(r){return`${tt.yellow("Warning:")} ${r}`}function re(r){return tt.dim(r)}function N(r){return tt.cyan(r)}function Or(r){return r instanceof v?r.exitCode:w.VALIDATION_ERROR}import{promises as ve}from"node:fs";import we from"node:path";import at from"fs-extra";var T={};pi(T,{BRAND:()=>Vi,DIRTY:()=>Re,EMPTY_PATH:()=>vi,INVALID:()=>E,NEVER:()=>Ia,OK:()=>V,ParseStatus:()=>D,Schema:()=>S,ZodAny:()=>ye,ZodArray:()=>pe,ZodBigInt:()=>Ie,ZodBoolean:()=>Se,ZodBranded:()=>nt,ZodCatch:()=>Fe,ZodDate:()=>$e,ZodDefault:()=>je,ZodDiscriminatedUnion:()=>_t,ZodEffects:()=>K,ZodEnum:()=>Pe,ZodError:()=>W,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>kt,ZodIntersection:()=>Te,ZodIssueCode:()=>d,ZodLazy:()=>Ae,ZodLiteral:()=>Ce,ZodMap:()=>Xe,ZodNaN:()=>Be,ZodNativeEnum:()=>Le,ZodNever:()=>se,ZodNull:()=>Oe,ZodNullable:()=>oe,ZodNumber:()=>ke,ZodObject:()=>X,ZodOptional:()=>J,ZodParsedType:()=>h,ZodPipeline:()=>it,ZodPromise:()=>xe,ZodReadonly:()=>De,ZodRecord:()=>Rt,ZodSchema:()=>S,ZodSet:()=>He,ZodString:()=>ge,ZodSymbol:()=>Ze,ZodTransformer:()=>K,ZodTuple:()=>ae,ZodType:()=>S,ZodUndefined:()=>be,ZodUnion:()=>Ne,ZodUnknown:()=>fe,ZodVoid:()=>We,addIssueToContext:()=>p,any:()=>Ji,array:()=>ea,bigint:()=>Zi,boolean:()=>Mr,coerce:()=>ka,custom:()=>Fr,date:()=>Wi,datetimeRegex:()=>Lr,defaultErrorMap:()=>ue,discriminatedUnion:()=>na,effect:()=>ga,enum:()=>pa,function:()=>ua,getErrorMap:()=>Ue,getParsedType:()=>ie,instanceof:()=>zi,intersection:()=>ia,isAborted:()=>wt,isAsync:()=>ze,isDirty:()=>Et,isValid:()=>me,late:()=>Ui,lazy:()=>da,literal:()=>fa,makeIssue:()=>st,map:()=>ca,nan:()=>Gi,nativeEnum:()=>ha,never:()=>Ki,null:()=>Bi,nullable:()=>xa,number:()=>qr,object:()=>ta,objectUtil:()=>Kt,oboolean:()=>Ra,onumber:()=>_a,optional:()=>ya,ostring:()=>Ea,pipeline:()=>wa,preprocess:()=>va,promise:()=>ma,quotelessJson:()=>gi,record:()=>oa,set:()=>la,setErrorMap:()=>xi,strictObject:()=>ra,string:()=>Dr,symbol:()=>Xi,transformer:()=>ga,tuple:()=>aa,undefined:()=>Hi,union:()=>sa,unknown:()=>Yi,util:()=>b,void:()=>Qi});var b;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let i={};for(let a of n)i[a]=a;return i},r.getValidEnumValues=n=>{let i=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),a={};for(let o of i)a[o]=n[o];return r.objectValues(a)},r.objectValues=n=>r.objectKeys(n).map(function(i){return n[i]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let i=[];for(let a in n)Object.prototype.hasOwnProperty.call(n,a)&&i.push(a);return i},r.find=(n,i)=>{for(let a of n)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,i=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=s,r.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(b||(b={}));var Kt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Kt||(Kt={}));var h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ie=r=>{switch(typeof r){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(r)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(r)?h.array:r===null?h.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?h.promise:typeof Map<"u"&&r instanceof Map?h.map:typeof Set<"u"&&r instanceof Set?h.set:typeof Date<"u"&&r instanceof Date?h.date:h.object;default:return h.unknown}};var d=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),gi=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),W=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(i){return i.message},s={_errors:[]},n=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)s._errors.push(t(a));else{let o=s,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let n of this.issues)if(n.path.length>0){let i=n.path[0];t[i]=t[i]||[],t[i].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};W.create=r=>new W(r);var yi=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===h.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${b.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${b.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${b.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:b.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,b.assertNever(r)}return{message:t}},ue=yi;var Nr=ue;function xi(r){Nr=r}function Ue(){return Nr}var st=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,i=[...t,...n.path||[]],a={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let o="",c=s.filter(l=>!!l).slice().reverse();for(let l of c)o=l(a,{data:e,defaultError:o}).message;return{...n,path:i,message:o}},vi=[];function p(r,e){let t=Ue(),s=st({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ue?void 0:ue].filter(n=>!!n)});r.common.issues.push(s)}var D=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return E;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let i=await n.key,a=await n.value;s.push({key:i,value:a})}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:i,value:a}=n;if(i.status==="aborted"||a.status==="aborted")return E;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||n.alwaysSet)&&(s[i.value]=a.value)}return{status:e.value,value:s}}},E=Object.freeze({status:"aborted"}),Re=r=>({status:"dirty",value:r}),V=r=>({status:"valid",value:r}),wt=r=>r.status==="aborted",Et=r=>r.status==="dirty",me=r=>r.status==="valid",ze=r=>typeof Promise<"u"&&r instanceof Promise;var x;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(x||(x={}));var Y=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Tr=(r,e)=>{if(me(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new W(r.common.issues);return this._error=t,this._error}}};function I(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,o)=>{let{message:c}=r;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:n}}var S=class{get description(){return this._def.description}_getType(e){return ie(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ze(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ie(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Tr(s,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ie(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return me(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>me(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ie(e)},n=this._parse({data:e,path:s.path,parent:s}),i=await(ze(n)?n:Promise.resolve(n));return Tr(s,i)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,i)=>{let a=e(n),o=()=>i.addIssue({code:d.custom,...s(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new K({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return J.create(this,this._def)}nullable(){return oe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pe.create(this)}promise(){return xe.create(this,this._def)}or(e){return Ne.create([this,e],this._def)}and(e){return Te.create(this,e,this._def)}transform(e){return new K({...I(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new je({...I(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new nt({typeName:_.ZodBranded,type:this,...I(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Fe({...I(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return it.create(this,e)}readonly(){return De.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},wi=/^c[^\s-]{8,}$/i,Ei=/^[0-9a-z]+$/,_i=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ri=/^[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,ki=/^[a-z0-9_-]{21}$/i,Ii=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Si=/^[-+]?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)?)??$/,$i=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Qt,Oi=/^(?:(?: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])$/,Ni=/^(?:(?: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])$/,Ti=/^(([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]))$/,Ai=/^(([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])$/,Ci=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Pi=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Cr="((\\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])))",Li=new RegExp(`^${Cr}$`);function Pr(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function ji(r){return new RegExp(`^${Pr(r)}$`)}function Lr(r){let e=`${Cr}T${Pr(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Fi(r,e){return!!((e==="v4"||!e)&&Oi.test(r)||(e==="v6"||!e)&&Ti.test(r))}function Di(r,e){if(!Ii.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function qi(r,e){return!!((e==="v4"||!e)&&Ni.test(r)||(e==="v6"||!e)&&Ai.test(r))}var ge=class r extends S{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let i=this._getOrReturnCtx(e);return p(i,{code:d.invalid_type,expected:h.string,received:i.parsedType}),E}let s=new D,n;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(n=this._getOrReturnCtx(e,n),a?p(n,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&p(n,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")$i.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"email",code:d.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")Qt||(Qt=new RegExp(bi,"u")),Qt.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"emoji",code:d.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")Ri.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"uuid",code:d.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")ki.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"nanoid",code:d.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")wi.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cuid",code:d.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")Ei.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cuid2",code:d.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")_i.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"ulid",code:d.invalid_string,message:i.message}),s.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),p(n,{validation:"url",code:d.invalid_string,message:i.message}),s.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"regex",code:d.invalid_string,message:i.message}),s.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),s.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?Lr(i).test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?Li.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?ji(i).test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?Si.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"duration",code:d.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?Fi(e.data,i.version)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"ip",code:d.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?Di(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"jwt",code:d.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?qi(e.data,i.version)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"cidr",code:d.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?Ci.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"base64",code:d.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?Pi.test(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{validation:"base64url",code:d.invalid_string,message:i.message}),s.dirty()):b.assertNever(i);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:d.invalid_string,...x.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...x.errToObj(e)})}url(e){return this._addCheck({kind:"url",...x.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...x.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...x.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...x.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...x.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...x.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...x.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...x.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...x.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...x.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...x.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...x.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...x.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,...x.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...x.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...x.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...x.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...x.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...x.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...x.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...x.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...x.errToObj(t)})}nonempty(e){return this.min(1,x.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};ge.create=r=>new ge({checks:[],typeName:_.ZodString,coerce:r?.coerce??!1,...I(r)});function Mi(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,i=Number.parseInt(r.toFixed(n).replace(".","")),a=Number.parseInt(e.toFixed(n).replace(".",""));return i%a/10**n}var ke=class r extends S{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)!==h.number){let i=this._getOrReturnCtx(e);return p(i,{code:d.invalid_type,expected:h.number,received:i.parsedType}),E}let s,n=new D;for(let i of this._def.checks)i.kind==="int"?b.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?Mi(e.data,i.value)!==0&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.not_finite,message:i.message}),n.dirty()):b.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:x.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:x.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:x.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ke.create=r=>new ke({checks:[],typeName:_.ZodNumber,coerce:r?.coerce||!1,...I(r)});var Ie=class r extends S{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)!==h.bigint)return this._getInvalidInput(e);let s,n=new D;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):b.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return p(t,{code:d.invalid_type,expected:h.bigint,received:t.parsedType}),E}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:x.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Ie.create=r=>new Ie({checks:[],typeName:_.ZodBigInt,coerce:r?.coerce??!1,...I(r)});var Se=class extends S{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){let s=this._getOrReturnCtx(e);return p(s,{code:d.invalid_type,expected:h.boolean,received:s.parsedType}),E}return V(e.data)}};Se.create=r=>new Se({typeName:_.ZodBoolean,coerce:r?.coerce||!1,...I(r)});var $e=class r extends S{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){let i=this._getOrReturnCtx(e);return p(i,{code:d.invalid_type,expected:h.date,received:i.parsedType}),E}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return p(i,{code:d.invalid_date}),E}let s=new D,n;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),s.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):b.assertNever(i);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:x.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:x.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};$e.create=r=>new $e({checks:[],coerce:r?.coerce||!1,typeName:_.ZodDate,...I(r)});var Ze=class extends S{_parse(e){if(this._getType(e)!==h.symbol){let s=this._getOrReturnCtx(e);return p(s,{code:d.invalid_type,expected:h.symbol,received:s.parsedType}),E}return V(e.data)}};Ze.create=r=>new Ze({typeName:_.ZodSymbol,...I(r)});var be=class extends S{_parse(e){if(this._getType(e)!==h.undefined){let s=this._getOrReturnCtx(e);return p(s,{code:d.invalid_type,expected:h.undefined,received:s.parsedType}),E}return V(e.data)}};be.create=r=>new be({typeName:_.ZodUndefined,...I(r)});var Oe=class extends S{_parse(e){if(this._getType(e)!==h.null){let s=this._getOrReturnCtx(e);return p(s,{code:d.invalid_type,expected:h.null,received:s.parsedType}),E}return V(e.data)}};Oe.create=r=>new Oe({typeName:_.ZodNull,...I(r)});var ye=class extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return V(e.data)}};ye.create=r=>new ye({typeName:_.ZodAny,...I(r)});var fe=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return V(e.data)}};fe.create=r=>new fe({typeName:_.ZodUnknown,...I(r)});var se=class extends S{_parse(e){let t=this._getOrReturnCtx(e);return p(t,{code:d.invalid_type,expected:h.never,received:t.parsedType}),E}};se.create=r=>new se({typeName:_.ZodNever,...I(r)});var We=class extends S{_parse(e){if(this._getType(e)!==h.undefined){let s=this._getOrReturnCtx(e);return p(s,{code:d.invalid_type,expected:h.void,received:s.parsedType}),E}return V(e.data)}};We.create=r=>new We({typeName:_.ZodVoid,...I(r)});var pe=class r extends S{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==h.array)return p(t,{code:d.invalid_type,expected:h.array,received:t.parsedType}),E;if(n.exactLength!==null){let a=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(a||o)&&(p(t,{code:a?d.too_big:d.too_small,minimum:o?n.exactLength.value:void 0,maximum:a?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(p(t,{code:d.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(p(t,{code:d.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>n.type._parseAsync(new Y(t,a,t.path,o)))).then(a=>D.mergeArray(s,a));let i=[...t.data].map((a,o)=>n.type._parseSync(new Y(t,a,t.path,o)));return D.mergeArray(s,i)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:x.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:x.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:x.toString(t)}})}nonempty(e){return this.min(1,e)}};pe.create=(r,e)=>new pe({type:r,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...I(e)});function Ge(r){if(r instanceof X){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=J.create(Ge(s))}return new X({...r._def,shape:()=>e})}else return r instanceof pe?new pe({...r._def,type:Ge(r.element)}):r instanceof J?J.create(Ge(r.unwrap())):r instanceof oe?oe.create(Ge(r.unwrap())):r instanceof ae?ae.create(r.items.map(e=>Ge(e))):r}var X=class r extends S{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=b.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==h.object){let l=this._getOrReturnCtx(e);return p(l,{code:d.invalid_type,expected:h.object,received:l.parsedType}),E}let{status:s,ctx:n}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof se&&this._def.unknownKeys==="strip"))for(let l in n.data)a.includes(l)||o.push(l);let c=[];for(let l of a){let u=i[l],y=n.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Y(n,y,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof se){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(l==="strict")o.length>0&&(p(n,{code:d.unrecognized_keys,keys:o}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of o){let y=n.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Y(n,y,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let y=await u.key,$=await u.value;l.push({key:y,value:$,alwaysSet:u.alwaysSet})}return l}).then(l=>D.mergeObjectSync(s,l)):D.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return x.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let n=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:x.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let s of b.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let s of b.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}deepPartial(){return Ge(this)}partial(e){let t={};for(let s of b.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let s of b.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let i=this.shape[s];for(;i instanceof J;)i=i._def.innerType;t[s]=i}return new r({...this._def,shape:()=>t})}keyof(){return jr(b.objectKeys(this.shape))}};X.create=(r,e)=>new X({shape:()=>r,unknownKeys:"strip",catchall:se.create(),typeName:_.ZodObject,...I(e)});X.strictCreate=(r,e)=>new X({shape:()=>r,unknownKeys:"strict",catchall:se.create(),typeName:_.ZodObject,...I(e)});X.lazycreate=(r,e)=>new X({shape:r,unknownKeys:"strip",catchall:se.create(),typeName:_.ZodObject,...I(e)});var Ne=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(o=>new W(o.ctx.common.issues));return p(t,{code:d.invalid_union,unionErrors:a}),E}if(t.common.async)return Promise.all(s.map(async i=>{let a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(n);{let i,a=[];for(let c of s){let l={...t,common:{...t.common,issues:[]},parent:null},u=c._parseSync({data:t.data,path:t.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(c=>new W(c));return p(t,{code:d.invalid_union,unionErrors:o}),E}}get options(){return this._def.options}};Ne.create=(r,e)=>new Ne({options:r,typeName:_.ZodUnion,...I(e)});var de=r=>r instanceof Ae?de(r.schema):r instanceof K?de(r.innerType()):r instanceof Ce?[r.value]:r instanceof Pe?r.options:r instanceof Le?b.objectValues(r.enum):r instanceof je?de(r._def.innerType):r instanceof be?[void 0]:r instanceof Oe?[null]:r instanceof J?[void 0,...de(r.unwrap())]:r instanceof oe?[null,...de(r.unwrap())]:r instanceof nt||r instanceof De?de(r.unwrap()):r instanceof Fe?de(r._def.innerType):[],_t=class r extends S{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return p(t,{code:d.invalid_type,expected:h.object,received:t.parsedType}),E;let s=this.discriminator,n=t.data[s],i=this.optionsMap.get(n);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),E)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let i of t){let a=de(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,i)}}return new r({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...I(s)})}};function er(r,e){let t=ie(r),s=ie(e);if(r===e)return{valid:!0,data:r};if(t===h.object&&s===h.object){let n=b.objectKeys(e),i=b.objectKeys(r).filter(o=>n.indexOf(o)!==-1),a={...r,...e};for(let o of i){let c=er(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===h.array&&s===h.array){if(r.length!==e.length)return{valid:!1};let n=[];for(let i=0;i<r.length;i++){let a=r[i],o=e[i],c=er(a,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===h.date&&s===h.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var Te=class extends S{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(i,a)=>{if(wt(i)||wt(a))return E;let o=er(i.value,a.value);return o.valid?((Et(i)||Et(a))&&t.dirty(),{status:t.value,value:o.data}):(p(s,{code:d.invalid_intersection_types}),E)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([i,a])=>n(i,a)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};Te.create=(r,e,t)=>new Te({left:r,right:e,typeName:_.ZodIntersection,...I(t)});var ae=class r extends S{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return p(s,{code:d.invalid_type,expected:h.array,received:s.parsedType}),E;if(s.data.length<this._def.items.length)return p(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&s.data.length>this._def.items.length&&(p(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let i=[...s.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new Y(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(i).then(a=>D.mergeArray(t,a)):D.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};ae.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ae({items:r,typeName:_.ZodTuple,rest:null,...I(e)})};var Rt=class r extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.object)return p(s,{code:d.invalid_type,expected:h.object,received:s.parsedType}),E;let n=[],i=this._def.keyType,a=this._def.valueType;for(let o in s.data)n.push({key:i._parse(new Y(s,o,s.path,o)),value:a._parse(new Y(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?D.mergeObjectAsync(t,n):D.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof S?new r({keyType:e,valueType:t,typeName:_.ZodRecord,...I(s)}):new r({keyType:ge.create(),valueType:e,typeName:_.ZodRecord,...I(t)})}},Xe=class extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return p(s,{code:d.invalid_type,expected:h.map,received:s.parsedType}),E;let n=this._def.keyType,i=this._def.valueType,a=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new Y(s,o,s.path,[l,"key"])),value:i._parse(new Y(s,c,s.path,[l,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return E;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),o.set(l.value,u.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let c of a){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return E;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),o.set(l.value,u.value)}return{status:t.value,value:o}}}};Xe.create=(r,e,t)=>new Xe({valueType:e,keyType:r,typeName:_.ZodMap,...I(t)});var He=class r extends S{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return p(s,{code:d.invalid_type,expected:h.set,received:s.parsedType}),E;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(p(s,{code:d.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(p(s,{code:d.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let i=this._def.valueType;function a(c){let l=new Set;for(let u of c){if(u.status==="aborted")return E;u.status==="dirty"&&t.dirty(),l.add(u.value)}return{status:t.value,value:l}}let o=[...s.data.values()].map((c,l)=>i._parse(new Y(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:x.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:x.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};He.create=(r,e)=>new He({valueType:r,minSize:null,maxSize:null,typeName:_.ZodSet,...I(e)});var kt=class r extends S{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return p(t,{code:d.invalid_type,expected:h.function,received:t.parsedType}),E;function s(o,c){return st({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ue(),ue].filter(l=>!!l),issueData:{code:d.invalid_arguments,argumentsError:c}})}function n(o,c){return st({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ue(),ue].filter(l=>!!l),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof xe){let o=this;return V(async function(...c){let l=new W([]),u=await o._def.args.parseAsync(c,i).catch(f=>{throw l.addIssue(s(c,f)),l}),y=await Reflect.apply(a,this,u);return await o._def.returns._def.type.parseAsync(y,i).catch(f=>{throw l.addIssue(n(y,f)),l})})}else{let o=this;return V(function(...c){let l=o._def.args.safeParse(c,i);if(!l.success)throw new W([s(c,l.error)]);let u=Reflect.apply(a,this,l.data),y=o._def.returns.safeParse(u,i);if(!y.success)throw new W([n(u,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:ae.create(e).rest(fe.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||ae.create([]).rest(fe.create()),returns:t||fe.create(),typeName:_.ZodFunction,...I(s)})}},Ae=class extends S{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ae.create=(r,e)=>new Ae({getter:r,typeName:_.ZodLazy,...I(e)});var Ce=class extends S{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ce.create=(r,e)=>new Ce({value:r,typeName:_.ZodLiteral,...I(e)});function jr(r,e){return new Pe({values:r,typeName:_.ZodEnum,...I(e)})}var Pe=class r extends S{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return p(t,{expected:b.joinValues(s),received:t.parsedType,code:d.invalid_type}),E}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return p(t,{received:t.data,code:d.invalid_enum_value,options:s}),E}return V(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};Pe.create=jr;var Le=class extends S{_parse(e){let t=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){let n=b.objectValues(t);return p(s,{expected:b.joinValues(n),received:s.parsedType,code:d.invalid_type}),E}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=b.objectValues(t);return p(s,{received:s.data,code:d.invalid_enum_value,options:n}),E}return V(e.data)}get enum(){return this._def.values}};Le.create=(r,e)=>new Le({values:r,typeName:_.ZodNativeEnum,...I(e)});var xe=class extends S{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return p(t,{code:d.invalid_type,expected:h.promise,received:t.parsedType}),E;let s=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return V(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};xe.create=(r,e)=>new xe({type:r,typeName:_.ZodPromise,...I(e)});var K=class extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:a=>{p(s,a),a.fatal?t.abort():t.dirty()},get path(){return s.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){let a=n.transform(s.data,i);if(s.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return E;let c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?E:c.status==="dirty"?Re(c.value):t.value==="dirty"?Re(c.value):c});{if(t.value==="aborted")return E;let o=this._def.schema._parseSync({data:a,path:s.path,parent:s});return o.status==="aborted"?E:o.status==="dirty"?Re(o.value):t.value==="dirty"?Re(o.value):o}}if(n.type==="refinement"){let a=o=>{let c=n.refinement(o,i);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?E:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?E:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!me(a))return E;let o=n.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>me(a)?Promise.resolve(n.transform(a.value,i)).then(o=>({status:t.value,value:o})):E);b.assertNever(n)}};K.create=(r,e,t)=>new K({schema:r,typeName:_.ZodEffects,effect:e,...I(t)});K.createWithPreprocess=(r,e,t)=>new K({schema:e,effect:{type:"preprocess",transform:r},typeName:_.ZodEffects,...I(t)});var J=class extends S{_parse(e){return this._getType(e)===h.undefined?V(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};J.create=(r,e)=>new J({innerType:r,typeName:_.ZodOptional,...I(e)});var oe=class extends S{_parse(e){return this._getType(e)===h.null?V(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};oe.create=(r,e)=>new oe({innerType:r,typeName:_.ZodNullable,...I(e)});var je=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};je.create=(r,e)=>new je({innerType:r,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...I(e)});var Fe=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ze(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new W(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new W(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Fe.create=(r,e)=>new Fe({innerType:r,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...I(e)});var Be=class extends S{_parse(e){if(this._getType(e)!==h.nan){let s=this._getOrReturnCtx(e);return p(s,{code:d.invalid_type,expected:h.nan,received:s.parsedType}),E}return{status:"valid",value:e.data}}};Be.create=r=>new Be({typeName:_.ZodNaN,...I(r)});var Vi=Symbol("zod_brand"),nt=class extends S{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},it=class r extends S{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?E:i.status==="dirty"?(t.dirty(),Re(i.value)):this._def.out._parseAsync({data:i.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?E:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:_.ZodPipeline})}},De=class extends S{_parse(e){let t=this._def.innerType._parse(e),s=n=>(me(n)&&(n.value=Object.freeze(n.value)),n);return ze(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};De.create=(r,e)=>new De({innerType:r,typeName:_.ZodReadonly,...I(e)});function Ar(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Fr(r,e={},t){return r?ye.create().superRefine((s,n)=>{let i=r(s);if(i instanceof Promise)return i.then(a=>{if(!a){let o=Ar(e,s),c=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:c})}});if(!i){let a=Ar(e,s),o=a.fatal??t??!0;n.addIssue({code:"custom",...a,fatal:o})}}):ye.create()}var Ui={object:X.lazycreate},_;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(_||(_={}));var zi=(r,e={message:`Input not instance of ${r.name}`})=>Fr(t=>t instanceof r,e),Dr=ge.create,qr=ke.create,Gi=Be.create,Zi=Ie.create,Mr=Se.create,Wi=$e.create,Xi=Ze.create,Hi=be.create,Bi=Oe.create,Ji=ye.create,Yi=fe.create,Ki=se.create,Qi=We.create,ea=pe.create,ta=X.create,ra=X.strictCreate,sa=Ne.create,na=_t.create,ia=Te.create,aa=ae.create,oa=Rt.create,ca=Xe.create,la=He.create,ua=kt.create,da=Ae.create,fa=Ce.create,pa=Pe.create,ha=Le.create,ma=xe.create,ga=K.create,ya=J.create,xa=oe.create,va=K.createWithPreprocess,wa=it.create,Ea=()=>Dr().optional(),_a=()=>qr().optional(),Ra=()=>Mr().optional(),ka={string:(r=>ge.create({...r,coerce:!0})),number:(r=>ke.create({...r,coerce:!0})),boolean:(r=>Se.create({...r,coerce:!0})),bigint:(r=>Ie.create({...r,coerce:!0})),date:(r=>$e.create({...r,coerce:!0}))};var Ia=E;import{promises as Na}from"node:fs";import{join as Ta,isAbsolute as Aa,normalize as Ca}from"node:path";var It=T.object({name:T.string().regex(/^[a-z0-9-]+$/,"Name must be lowercase alphanumeric with hyphens"),version:T.string().regex(/^\d+\.\d+\.\d+$/,"Version must be semver compliant (x.y.z)"),deps:T.record(T.string().regex(/^[a-z0-9-]+$/,"Dependency name must be lowercase alphanumeric with hyphens"),T.string().regex(/^\d+\.\d+\.\d+$/,"Dependency version must be exact semver")).default({}),files:T.array(T.string()).min(1,"Files array cannot be empty"),hash:T.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>").optional()});var Sa=T.string().regex(/^[a-z0-9-]+@\d+\.\d+\.\d+$/,"Key must be name@version"),$a=T.string().refine(r=>r.length===0?!1:(r.startsWith("file:")||r.startsWith("/")||/^[a-zA-Z]:\\/.test(r)||r.startsWith("./")||r.startsWith("../"),!0),"Source must be a non-empty file URL or local path"),ba=T.object({source:$a,hash:T.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>")}),Vr=T.record(Sa,ba);var Oa=T.object({name:T.string().regex(/^[a-z0-9-]+$/,"Name must be lowercase alphanumeric with hyphens"),version:T.string().regex(/^\d+\.\d+\.\d+$/,"Version must be semver compliant (x.y.z)"),hash:T.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>"),source:T.string().url("Source must be a valid URL"),deps:T.array(T.string().regex(/^[a-z0-9-]+@\d+\.\d+\.\d+$/,"Dependency must be in format name@version"))}),ed=T.object({createdAt:T.string().datetime("createdAt must be ISO-8601 format"),entries:T.array(Oa)});function St(r){try{return It.parse(r)}catch(e){if(e instanceof T.ZodError){let t=e.errors.map(s=>`${s.path.length>0?`${s.path.join(".")}: `:""}${s.message}`);throw new Error(`Manifest validation failed:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`;await ve.writeFile(i,a,"utf-8")}};import{promises as zr}from"node:fs";import bt from"node:path";var B=class extends Error{exitCode;constructor(e,t){super(e),this.exitCode=t,this.name="ResolverError"}},Ot=class{async loadIndex(e){try{let t=await zr.readFile(e,"utf-8"),s=JSON.parse(t);return Vr.parse(s)}catch(t){throw this.isFileNotFoundError(t)?new B(`Index file not found: ${e}`,1):t}}isFileNotFoundError(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}async readManifestFromSource(e,t){let s;if(e.startsWith("file://")?s=e.slice(7):e.startsWith("file:")?s=e.slice(5):s=e,!bt.isAbsolute(s)){let n=t||process.cwd();s=bt.resolve(n,s)}try{let n=bt.join(s,"spectrl.json"),i=await zr.readFile(n,"utf-8"),a=JSON.parse(i);return It.parse(a)}catch(n){throw this.isFileNotFoundError(n)?new B(`Missing source for ${e}`,1):new B(`Failed to read manifest from source: ${e}`,1)}}async resolveClosureFromIndex(e){let t=await this.loadIndex(e),s=Object.keys(t).sort(),n=/^([a-z0-9-]+)@(\d+\.\d+\.\d+)$/,i=new Map;for(let f of s){let A=f.match(n);if(!A)throw new B(`Invalid index key: ${f}`,1);let[,C,O]=A;i.set(f,{name:C,version:O})}let a=new Map,o=bt.dirname(e);for(let f of s){let A=i.get(f);if(!A)throw new B(`Internal error: missing parsed key ${f}`,1);let{name:C,version:O}=A,P=t[f];if(!P||!P.source)throw new B(`Missing source for ${f}`,1);let F=await this.readManifestFromSource(P.source,o);if(F.name!==C||F.version!==O)throw new B(`Manifest mismatch for ${f}: found ${F.name}@${F.version}`,1);a.set(f,{manifest:F,source:P.source})}let c=new Map;for(let[f,{manifest:A}]of a){let C=Object.entries(A.deps).map(([O,P])=>`${O}@${P}`).sort();for(let O of C)if(!t[O])throw new B(`Missing dependency: ${O}. Add it to .spectrl/spectrl-index.json`,3);c.set(f,C)}let l=(f,A,C)=>{A.add(f),C.add(f);let O=c.get(f)||[];for(let P of O)if(A.has(P)){if(C.has(P))throw new B(`Cyclic dependency detected: ${f} \u2192 ${P}`,3)}else if(l(P,A,C))return!0;return C.delete(f),!1},u=new Set;for(let f of s)u.has(f)||l(f,u,new Set);let y=[];for(let[f,{manifest:A,source:C}]of a){let O=Object.entries(A.deps).map(([P,F])=>`${P}@${F}`).sort();y.push({name:A.name,version:A.version,source:C,deps:O})}let $=y.map(f=>({node:f,key:`${f.name}@${f.version}`}));return $.sort((f,A)=>f.key.localeCompare(A.key)),$.map(f=>f.node)}};import{createHash as La}from"node:crypto";function Nt(r){let{manifest:e,fileContents:t}=r,s=La("sha256"),n=Fa(e);s.update(n,"utf8");let i=Object.keys(t).sort();for(let a of i){let o=t[a];s.update(a,"utf8");let c=ja(o);s.update(c,"utf8")}return`sha256:${s.digest("hex")}`}function ja(r){return r.replace(/\r\n/g,`
|
|
2
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
3
|
+
const require = __createRequire(import.meta.url);
|
|
4
|
+
if (process.stdout.isTTY && !process.env.NO_COLOR) process.env.FORCE_COLOR = process.env.FORCE_COLOR || '3';
|
|
5
|
+
var Au=Object.create;var ps=Object.defineProperty;var $u=Object.getOwnPropertyDescriptor;var Iu=Object.getOwnPropertyNames;var Ou=Object.getPrototypeOf,ku=Object.prototype.hasOwnProperty;var kn=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var R=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Tu=(t,e)=>{for(var r in e)ps(t,r,{get:e[r],enumerable:!0})},Pu=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Iu(e))!ku.call(t,n)&&n!==r&&ps(t,n,{get:()=>e[n],enumerable:!(s=$u(e,n))||s.enumerable});return t};var _t=(t,e,r)=>(r=t!=null?Au(Ou(t)):{},Pu(e||!t||!t.__esModule?ps(r,"default",{value:t,enumerable:!0}):r,t));var ur=R((Hy,Yn)=>{"use strict";var cd="2.0.0",ud=Number.MAX_SAFE_INTEGER||9007199254740991,ld=16,dd=250,fd=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Yn.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:ld,MAX_SAFE_BUILD_LENGTH:dd,MAX_SAFE_INTEGER:ud,RELEASE_TYPES:fd,SEMVER_SPEC_VERSION:cd,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var lr=R((Jy,Xn)=>{"use strict";var pd=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};Xn.exports=pd});var jt=R((Te,Kn)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:xs,MAX_SAFE_BUILD_LENGTH:hd,MAX_LENGTH:md}=ur(),gd=lr();Te=Kn.exports={};var Dd=Te.re=[],yd=Te.safeRe=[],b=Te.src=[],wd=Te.safeSrc=[],F=Te.t={},Ed=0,vs="[a-zA-Z0-9-]",xd=[["\\s",1],["\\d",md],[vs,hd]],vd=t=>{for(let[e,r]of xd)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t},k=(t,e,r)=>{let s=vd(e),n=Ed++;gd(t,n,e),F[t]=n,b[n]=e,wd[n]=s,Dd[n]=new RegExp(e,r?"g":void 0),yd[n]=new RegExp(s,r?"g":void 0)};k("NUMERICIDENTIFIER","0|[1-9]\\d*");k("NUMERICIDENTIFIERLOOSE","\\d+");k("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${vs}*`);k("MAINVERSION",`(${b[F.NUMERICIDENTIFIER]})\\.(${b[F.NUMERICIDENTIFIER]})\\.(${b[F.NUMERICIDENTIFIER]})`);k("MAINVERSIONLOOSE",`(${b[F.NUMERICIDENTIFIERLOOSE]})\\.(${b[F.NUMERICIDENTIFIERLOOSE]})\\.(${b[F.NUMERICIDENTIFIERLOOSE]})`);k("PRERELEASEIDENTIFIER",`(?:${b[F.NONNUMERICIDENTIFIER]}|${b[F.NUMERICIDENTIFIER]})`);k("PRERELEASEIDENTIFIERLOOSE",`(?:${b[F.NONNUMERICIDENTIFIER]}|${b[F.NUMERICIDENTIFIERLOOSE]})`);k("PRERELEASE",`(?:-(${b[F.PRERELEASEIDENTIFIER]}(?:\\.${b[F.PRERELEASEIDENTIFIER]})*))`);k("PRERELEASELOOSE",`(?:-?(${b[F.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${b[F.PRERELEASEIDENTIFIERLOOSE]})*))`);k("BUILDIDENTIFIER",`${vs}+`);k("BUILD",`(?:\\+(${b[F.BUILDIDENTIFIER]}(?:\\.${b[F.BUILDIDENTIFIER]})*))`);k("FULLPLAIN",`v?${b[F.MAINVERSION]}${b[F.PRERELEASE]}?${b[F.BUILD]}?`);k("FULL",`^${b[F.FULLPLAIN]}$`);k("LOOSEPLAIN",`[v=\\s]*${b[F.MAINVERSIONLOOSE]}${b[F.PRERELEASELOOSE]}?${b[F.BUILD]}?`);k("LOOSE",`^${b[F.LOOSEPLAIN]}$`);k("GTLT","((?:<|>)?=?)");k("XRANGEIDENTIFIERLOOSE",`${b[F.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);k("XRANGEIDENTIFIER",`${b[F.NUMERICIDENTIFIER]}|x|X|\\*`);k("XRANGEPLAIN",`[v=\\s]*(${b[F.XRANGEIDENTIFIER]})(?:\\.(${b[F.XRANGEIDENTIFIER]})(?:\\.(${b[F.XRANGEIDENTIFIER]})(?:${b[F.PRERELEASE]})?${b[F.BUILD]}?)?)?`);k("XRANGEPLAINLOOSE",`[v=\\s]*(${b[F.XRANGEIDENTIFIERLOOSE]})(?:\\.(${b[F.XRANGEIDENTIFIERLOOSE]})(?:\\.(${b[F.XRANGEIDENTIFIERLOOSE]})(?:${b[F.PRERELEASELOOSE]})?${b[F.BUILD]}?)?)?`);k("XRANGE",`^${b[F.GTLT]}\\s*${b[F.XRANGEPLAIN]}$`);k("XRANGELOOSE",`^${b[F.GTLT]}\\s*${b[F.XRANGEPLAINLOOSE]}$`);k("COERCEPLAIN",`(^|[^\\d])(\\d{1,${xs}})(?:\\.(\\d{1,${xs}}))?(?:\\.(\\d{1,${xs}}))?`);k("COERCE",`${b[F.COERCEPLAIN]}(?:$|[^\\d])`);k("COERCEFULL",b[F.COERCEPLAIN]+`(?:${b[F.PRERELEASE]})?(?:${b[F.BUILD]})?(?:$|[^\\d])`);k("COERCERTL",b[F.COERCE],!0);k("COERCERTLFULL",b[F.COERCEFULL],!0);k("LONETILDE","(?:~>?)");k("TILDETRIM",`(\\s*)${b[F.LONETILDE]}\\s+`,!0);Te.tildeTrimReplace="$1~";k("TILDE",`^${b[F.LONETILDE]}${b[F.XRANGEPLAIN]}$`);k("TILDELOOSE",`^${b[F.LONETILDE]}${b[F.XRANGEPLAINLOOSE]}$`);k("LONECARET","(?:\\^)");k("CARETTRIM",`(\\s*)${b[F.LONECARET]}\\s+`,!0);Te.caretTrimReplace="$1^";k("CARET",`^${b[F.LONECARET]}${b[F.XRANGEPLAIN]}$`);k("CARETLOOSE",`^${b[F.LONECARET]}${b[F.XRANGEPLAINLOOSE]}$`);k("COMPARATORLOOSE",`^${b[F.GTLT]}\\s*(${b[F.LOOSEPLAIN]})$|^$`);k("COMPARATOR",`^${b[F.GTLT]}\\s*(${b[F.FULLPLAIN]})$|^$`);k("COMPARATORTRIM",`(\\s*)${b[F.GTLT]}\\s*(${b[F.LOOSEPLAIN]}|${b[F.XRANGEPLAIN]})`,!0);Te.comparatorTrimReplace="$1$2$3";k("HYPHENRANGE",`^\\s*(${b[F.XRANGEPLAIN]})\\s+-\\s+(${b[F.XRANGEPLAIN]})\\s*$`);k("HYPHENRANGELOOSE",`^\\s*(${b[F.XRANGEPLAINLOOSE]})\\s+-\\s+(${b[F.XRANGEPLAINLOOSE]})\\s*$`);k("STAR","(<|>)?=?\\s*\\*");k("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");k("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var Lr=R((Zy,Qn)=>{"use strict";var Cd=Object.freeze({loose:!0}),bd=Object.freeze({}),Fd=t=>t?typeof t!="object"?Cd:t:bd;Qn.exports=Fd});var Cs=R((Yy,ri)=>{"use strict";var ei=/^[0-9]+$/,ti=(t,e)=>{if(typeof t=="number"&&typeof e=="number")return t===e?0:t<e?-1:1;let r=ei.test(t),s=ei.test(e);return r&&s&&(t=+t,e=+e),t===e?0:r&&!s?-1:s&&!r?1:t<e?-1:1},Rd=(t,e)=>ti(e,t);ri.exports={compareIdentifiers:ti,rcompareIdentifiers:Rd}});var te=R((Xy,ni)=>{"use strict";var Mr=lr(),{MAX_LENGTH:si,MAX_SAFE_INTEGER:jr}=ur(),{safeRe:Br,t:Wr}=jt(),Sd=Lr(),{compareIdentifiers:bs}=Cs(),Fs=class t{constructor(e,r){if(r=Sd(r),e instanceof t){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>si)throw new TypeError(`version is longer than ${si} characters`);Mr("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let s=e.trim().match(r.loose?Br[Wr.LOOSE]:Br[Wr.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>jr||this.major<0)throw new TypeError("Invalid major version");if(this.minor>jr||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>jr||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(n=>{if(/^[0-9]+$/.test(n)){let i=+n;if(i>=0&&i<jr)return i}return n}):this.prerelease=[],this.build=s[5]?s[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(Mr("SemVer.compare",this.version,this.options,e),!(e instanceof t)){if(typeof e=="string"&&e===this.version)return 0;e=new t(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof t||(e=new t(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof t||(e=new t(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let r=0;do{let s=this.prerelease[r],n=e.prerelease[r];if(Mr("prerelease compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return bs(s,n)}while(++r)}compareBuild(e){e instanceof t||(e=new t(e,this.options));let r=0;do{let s=this.build[r],n=e.build[r];if(Mr("build compare",r,s,n),s===void 0&&n===void 0)return 0;if(n===void 0)return 1;if(s===void 0)return-1;if(s===n)continue;return bs(s,n)}while(++r)}inc(e,r,s){if(e.startsWith("pre")){if(!r&&s===!1)throw new Error("invalid increment argument: identifier is empty");if(r){let n=`-${r}`.match(this.options.loose?Br[Wr.PRERELEASELOOSE]:Br[Wr.PRERELEASE]);if(!n||n[1]!==r)throw new Error(`invalid identifier: ${r}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",r,s);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",r,s);break;case"prepatch":this.prerelease.length=0,this.inc("patch",r,s),this.inc("pre",r,s);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",r,s),this.inc("pre",r,s);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let n=Number(s)?1:0;if(this.prerelease.length===0)this.prerelease=[n];else{let i=this.prerelease.length;for(;--i>=0;)typeof this.prerelease[i]=="number"&&(this.prerelease[i]++,i=-2);if(i===-1){if(r===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(n)}}if(r){let i=[r,n];s===!1&&(i=[r]),bs(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=i):this.prerelease=i}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};ni.exports=Fs});var vt=R((Ky,oi)=>{"use strict";var ii=te(),_d=(t,e,r=!1)=>{if(t instanceof ii)return t;try{return new ii(t,e)}catch(s){if(!r)return null;throw s}};oi.exports=_d});var ci=R((Qy,ai)=>{"use strict";var Ad=vt(),$d=(t,e)=>{let r=Ad(t,e);return r?r.version:null};ai.exports=$d});var li=R((ew,ui)=>{"use strict";var Id=vt(),Od=(t,e)=>{let r=Id(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null};ui.exports=Od});var pi=R((tw,fi)=>{"use strict";var di=te(),kd=(t,e,r,s,n)=>{typeof r=="string"&&(n=s,s=r,r=void 0);try{return new di(t instanceof di?t.version:t,r).inc(e,s,n).version}catch{return null}};fi.exports=kd});var gi=R((rw,mi)=>{"use strict";var hi=vt(),Td=(t,e)=>{let r=hi(t,null,!0),s=hi(e,null,!0),n=r.compare(s);if(n===0)return null;let i=n>0,o=i?r:s,a=i?s:r,c=!!o.prerelease.length;if(!!a.prerelease.length&&!c){if(!a.patch&&!a.minor)return"major";if(a.compareMain(o)===0)return a.minor&&!a.patch?"minor":"patch"}let d=c?"pre":"";return r.major!==s.major?d+"major":r.minor!==s.minor?d+"minor":r.patch!==s.patch?d+"patch":"prerelease"};mi.exports=Td});var yi=R((sw,Di)=>{"use strict";var Pd=te(),Nd=(t,e)=>new Pd(t,e).major;Di.exports=Nd});var Ei=R((nw,wi)=>{"use strict";var Ld=te(),Md=(t,e)=>new Ld(t,e).minor;wi.exports=Md});var vi=R((iw,xi)=>{"use strict";var jd=te(),Bd=(t,e)=>new jd(t,e).patch;xi.exports=Bd});var bi=R((ow,Ci)=>{"use strict";var Wd=vt(),qd=(t,e)=>{let r=Wd(t,e);return r&&r.prerelease.length?r.prerelease:null};Ci.exports=qd});var Ee=R((aw,Ri)=>{"use strict";var Fi=te(),Ud=(t,e,r)=>new Fi(t,r).compare(new Fi(e,r));Ri.exports=Ud});var _i=R((cw,Si)=>{"use strict";var zd=Ee(),Vd=(t,e,r)=>zd(e,t,r);Si.exports=Vd});var $i=R((uw,Ai)=>{"use strict";var Gd=Ee(),Hd=(t,e)=>Gd(t,e,!0);Ai.exports=Hd});var qr=R((lw,Oi)=>{"use strict";var Ii=te(),Jd=(t,e,r)=>{let s=new Ii(t,r),n=new Ii(e,r);return s.compare(n)||s.compareBuild(n)};Oi.exports=Jd});var Ti=R((dw,ki)=>{"use strict";var Zd=qr(),Yd=(t,e)=>t.sort((r,s)=>Zd(r,s,e));ki.exports=Yd});var Ni=R((fw,Pi)=>{"use strict";var Xd=qr(),Kd=(t,e)=>t.sort((r,s)=>Xd(s,r,e));Pi.exports=Kd});var dr=R((pw,Li)=>{"use strict";var Qd=Ee(),ef=(t,e,r)=>Qd(t,e,r)>0;Li.exports=ef});var Ur=R((hw,Mi)=>{"use strict";var tf=Ee(),rf=(t,e,r)=>tf(t,e,r)<0;Mi.exports=rf});var Rs=R((mw,ji)=>{"use strict";var sf=Ee(),nf=(t,e,r)=>sf(t,e,r)===0;ji.exports=nf});var Ss=R((gw,Bi)=>{"use strict";var of=Ee(),af=(t,e,r)=>of(t,e,r)!==0;Bi.exports=af});var zr=R((Dw,Wi)=>{"use strict";var cf=Ee(),uf=(t,e,r)=>cf(t,e,r)>=0;Wi.exports=uf});var Vr=R((yw,qi)=>{"use strict";var lf=Ee(),df=(t,e,r)=>lf(t,e,r)<=0;qi.exports=df});var _s=R((ww,Ui)=>{"use strict";var ff=Rs(),pf=Ss(),hf=dr(),mf=zr(),gf=Ur(),Df=Vr(),yf=(t,e,r,s)=>{switch(e){case"===":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t===r;case"!==":return typeof t=="object"&&(t=t.version),typeof r=="object"&&(r=r.version),t!==r;case"":case"=":case"==":return ff(t,r,s);case"!=":return pf(t,r,s);case">":return hf(t,r,s);case">=":return mf(t,r,s);case"<":return gf(t,r,s);case"<=":return Df(t,r,s);default:throw new TypeError(`Invalid operator: ${e}`)}};Ui.exports=yf});var Vi=R((Ew,zi)=>{"use strict";var wf=te(),Ef=vt(),{safeRe:Gr,t:Hr}=jt(),xf=(t,e)=>{if(t instanceof wf)return t;if(typeof t=="number"&&(t=String(t)),typeof t!="string")return null;e=e||{};let r=null;if(!e.rtl)r=t.match(e.includePrerelease?Gr[Hr.COERCEFULL]:Gr[Hr.COERCE]);else{let c=e.includePrerelease?Gr[Hr.COERCERTLFULL]:Gr[Hr.COERCERTL],u;for(;(u=c.exec(t))&&(!r||r.index+r[0].length!==t.length);)(!r||u.index+u[0].length!==r.index+r[0].length)&&(r=u),c.lastIndex=u.index+u[1].length+u[2].length;c.lastIndex=-1}if(r===null)return null;let s=r[2],n=r[3]||"0",i=r[4]||"0",o=e.includePrerelease&&r[5]?`-${r[5]}`:"",a=e.includePrerelease&&r[6]?`+${r[6]}`:"";return Ef(`${s}.${n}.${i}${o}${a}`,e)};zi.exports=xf});var Hi=R((xw,Gi)=>{"use strict";var As=class{constructor(){this.max=1e3,this.map=new Map}get(e){let r=this.map.get(e);if(r!==void 0)return this.map.delete(e),this.map.set(e,r),r}delete(e){return this.map.delete(e)}set(e,r){if(!this.delete(e)&&r!==void 0){if(this.map.size>=this.max){let n=this.map.keys().next().value;this.delete(n)}this.map.set(e,r)}return this}};Gi.exports=As});var xe=R((vw,Xi)=>{"use strict";var vf=/\s+/g,$s=class t{constructor(e,r){if(r=bf(r),e instanceof t)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new t(e.raw,r);if(e instanceof Is)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=e.trim().replace(vf," "),this.set=this.raw.split("||").map(s=>this.parseRange(s.trim())).filter(s=>s.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let s=this.set[0];if(this.set=this.set.filter(n=>!Zi(n[0])),this.set.length===0)this.set=[s];else if(this.set.length>1){for(let n of this.set)if(n.length===1&&If(n[0])){this.set=[n];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");let r=this.set[e];for(let s=0;s<r.length;s++)s>0&&(this.formatted+=" "),this.formatted+=r[s].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let s=((this.options.includePrerelease&&Af)|(this.options.loose&&$f))+":"+e,n=Ji.get(s);if(n)return n;let i=this.options.loose,o=i?ne[re.HYPHENRANGELOOSE]:ne[re.HYPHENRANGE];e=e.replace(o,Wf(this.options.includePrerelease)),W("hyphen replace",e),e=e.replace(ne[re.COMPARATORTRIM],Rf),W("comparator trim",e),e=e.replace(ne[re.TILDETRIM],Sf),W("tilde trim",e),e=e.replace(ne[re.CARETTRIM],_f),W("caret trim",e);let a=e.split(" ").map(h=>Of(h,this.options)).join(" ").split(/\s+/).map(h=>Bf(h,this.options));i&&(a=a.filter(h=>(W("loose invalid filter",h,this.options),!!h.match(ne[re.COMPARATORLOOSE])))),W("range list",a);let c=new Map,u=a.map(h=>new Is(h,this.options));for(let h of u){if(Zi(h))return[h];c.set(h.value,h)}c.size>1&&c.has("")&&c.delete("");let d=[...c.values()];return Ji.set(s,d),d}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(s=>Yi(s,r)&&e.set.some(n=>Yi(n,r)&&s.every(i=>n.every(o=>i.intersects(o,r)))))}test(e){if(!e)return!1;if(typeof e=="string")try{e=new Ff(e,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(qf(this.set[r],e,this.options))return!0;return!1}};Xi.exports=$s;var Cf=Hi(),Ji=new Cf,bf=Lr(),Is=fr(),W=lr(),Ff=te(),{safeRe:ne,t:re,comparatorTrimReplace:Rf,tildeTrimReplace:Sf,caretTrimReplace:_f}=jt(),{FLAG_INCLUDE_PRERELEASE:Af,FLAG_LOOSE:$f}=ur(),Zi=t=>t.value==="<0.0.0-0",If=t=>t.value==="",Yi=(t,e)=>{let r=!0,s=t.slice(),n=s.pop();for(;r&&s.length;)r=s.every(i=>n.intersects(i,e)),n=s.pop();return r},Of=(t,e)=>(t=t.replace(ne[re.BUILD],""),W("comp",t,e),t=Pf(t,e),W("caret",t),t=kf(t,e),W("tildes",t),t=Lf(t,e),W("xrange",t),t=jf(t,e),W("stars",t),t),ie=t=>!t||t.toLowerCase()==="x"||t==="*",kf=(t,e)=>t.trim().split(/\s+/).map(r=>Tf(r,e)).join(" "),Tf=(t,e)=>{let r=e.loose?ne[re.TILDELOOSE]:ne[re.TILDE];return t.replace(r,(s,n,i,o,a)=>{W("tilde",t,s,n,i,o,a);let c;return ie(n)?c="":ie(i)?c=`>=${n}.0.0 <${+n+1}.0.0-0`:ie(o)?c=`>=${n}.${i}.0 <${n}.${+i+1}.0-0`:a?(W("replaceTilde pr",a),c=`>=${n}.${i}.${o}-${a} <${n}.${+i+1}.0-0`):c=`>=${n}.${i}.${o} <${n}.${+i+1}.0-0`,W("tilde return",c),c})},Pf=(t,e)=>t.trim().split(/\s+/).map(r=>Nf(r,e)).join(" "),Nf=(t,e)=>{W("caret",t,e);let r=e.loose?ne[re.CARETLOOSE]:ne[re.CARET],s=e.includePrerelease?"-0":"";return t.replace(r,(n,i,o,a,c)=>{W("caret",t,n,i,o,a,c);let u;return ie(i)?u="":ie(o)?u=`>=${i}.0.0${s} <${+i+1}.0.0-0`:ie(a)?i==="0"?u=`>=${i}.${o}.0${s} <${i}.${+o+1}.0-0`:u=`>=${i}.${o}.0${s} <${+i+1}.0.0-0`:c?(W("replaceCaret pr",c),i==="0"?o==="0"?u=`>=${i}.${o}.${a}-${c} <${i}.${o}.${+a+1}-0`:u=`>=${i}.${o}.${a}-${c} <${i}.${+o+1}.0-0`:u=`>=${i}.${o}.${a}-${c} <${+i+1}.0.0-0`):(W("no pr"),i==="0"?o==="0"?u=`>=${i}.${o}.${a}${s} <${i}.${o}.${+a+1}-0`:u=`>=${i}.${o}.${a}${s} <${i}.${+o+1}.0-0`:u=`>=${i}.${o}.${a} <${+i+1}.0.0-0`),W("caret return",u),u})},Lf=(t,e)=>(W("replaceXRanges",t,e),t.split(/\s+/).map(r=>Mf(r,e)).join(" ")),Mf=(t,e)=>{t=t.trim();let r=e.loose?ne[re.XRANGELOOSE]:ne[re.XRANGE];return t.replace(r,(s,n,i,o,a,c)=>{W("xRange",t,s,n,i,o,a,c);let u=ie(i),d=u||ie(o),h=d||ie(a),p=h;return n==="="&&p&&(n=""),c=e.includePrerelease?"-0":"",u?n===">"||n==="<"?s="<0.0.0-0":s="*":n&&p?(d&&(o=0),a=0,n===">"?(n=">=",d?(i=+i+1,o=0,a=0):(o=+o+1,a=0)):n==="<="&&(n="<",d?i=+i+1:o=+o+1),n==="<"&&(c="-0"),s=`${n+i}.${o}.${a}${c}`):d?s=`>=${i}.0.0${c} <${+i+1}.0.0-0`:h&&(s=`>=${i}.${o}.0${c} <${i}.${+o+1}.0-0`),W("xRange return",s),s})},jf=(t,e)=>(W("replaceStars",t,e),t.trim().replace(ne[re.STAR],"")),Bf=(t,e)=>(W("replaceGTE0",t,e),t.trim().replace(ne[e.includePrerelease?re.GTE0PRE:re.GTE0],"")),Wf=t=>(e,r,s,n,i,o,a,c,u,d,h,p)=>(ie(s)?r="":ie(n)?r=`>=${s}.0.0${t?"-0":""}`:ie(i)?r=`>=${s}.${n}.0${t?"-0":""}`:o?r=`>=${r}`:r=`>=${r}${t?"-0":""}`,ie(u)?c="":ie(d)?c=`<${+u+1}.0.0-0`:ie(h)?c=`<${u}.${+d+1}.0-0`:p?c=`<=${u}.${d}.${h}-${p}`:t?c=`<${u}.${d}.${+h+1}-0`:c=`<=${c}`,`${r} ${c}`.trim()),qf=(t,e,r)=>{for(let s=0;s<t.length;s++)if(!t[s].test(e))return!1;if(e.prerelease.length&&!r.includePrerelease){for(let s=0;s<t.length;s++)if(W(t[s].semver),t[s].semver!==Is.ANY&&t[s].semver.prerelease.length>0){let n=t[s].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0}});var fr=R((Cw,so)=>{"use strict";var pr=Symbol("SemVer ANY"),Ts=class t{static get ANY(){return pr}constructor(e,r){if(r=Ki(r),e instanceof t){if(e.loose===!!r.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),ks("comparator",e,r),this.options=r,this.loose=!!r.loose,this.parse(e),this.semver===pr?this.value="":this.value=this.operator+this.semver.version,ks("comp",this)}parse(e){let r=this.options.loose?Qi[eo.COMPARATORLOOSE]:Qi[eo.COMPARATOR],s=e.match(r);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=s[1]!==void 0?s[1]:"",this.operator==="="&&(this.operator=""),s[2]?this.semver=new to(s[2],this.options.loose):this.semver=pr}toString(){return this.value}test(e){if(ks("Comparator.test",e,this.options.loose),this.semver===pr||e===pr)return!0;if(typeof e=="string")try{e=new to(e,this.options)}catch{return!1}return Os(e,this.operator,this.semver,this.options)}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new ro(e.value,r).test(this.value):e.operator===""?e.value===""?!0:new ro(this.value,r).test(e.semver):(r=Ki(r),r.includePrerelease&&(this.value==="<0.0.0-0"||e.value==="<0.0.0-0")||!r.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&e.operator.startsWith(">")||this.operator.startsWith("<")&&e.operator.startsWith("<")||this.semver.version===e.semver.version&&this.operator.includes("=")&&e.operator.includes("=")||Os(this.semver,"<",e.semver,r)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||Os(this.semver,">",e.semver,r)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};so.exports=Ts;var Ki=Lr(),{safeRe:Qi,t:eo}=jt(),Os=_s(),ks=lr(),to=te(),ro=xe()});var hr=R((bw,no)=>{"use strict";var Uf=xe(),zf=(t,e,r)=>{try{e=new Uf(e,r)}catch{return!1}return e.test(t)};no.exports=zf});var oo=R((Fw,io)=>{"use strict";var Vf=xe(),Gf=(t,e)=>new Vf(t,e).set.map(r=>r.map(s=>s.value).join(" ").trim().split(" "));io.exports=Gf});var co=R((Rw,ao)=>{"use strict";var Hf=te(),Jf=xe(),Zf=(t,e,r)=>{let s=null,n=null,i=null;try{i=new Jf(e,r)}catch{return null}return t.forEach(o=>{i.test(o)&&(!s||n.compare(o)===-1)&&(s=o,n=new Hf(s,r))}),s};ao.exports=Zf});var lo=R((Sw,uo)=>{"use strict";var Yf=te(),Xf=xe(),Kf=(t,e,r)=>{let s=null,n=null,i=null;try{i=new Xf(e,r)}catch{return null}return t.forEach(o=>{i.test(o)&&(!s||n.compare(o)===1)&&(s=o,n=new Yf(s,r))}),s};uo.exports=Kf});var ho=R((_w,po)=>{"use strict";var Ps=te(),Qf=xe(),fo=dr(),ep=(t,e)=>{t=new Qf(t,e);let r=new Ps("0.0.0");if(t.test(r)||(r=new Ps("0.0.0-0"),t.test(r)))return r;r=null;for(let s=0;s<t.set.length;++s){let n=t.set[s],i=null;n.forEach(o=>{let a=new Ps(o.semver.version);switch(o.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!i||fo(a,i))&&(i=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${o.operator}`)}}),i&&(!r||fo(r,i))&&(r=i)}return r&&t.test(r)?r:null};po.exports=ep});var go=R((Aw,mo)=>{"use strict";var tp=xe(),rp=(t,e)=>{try{return new tp(t,e).range||"*"}catch{return null}};mo.exports=rp});var Jr=R(($w,Eo)=>{"use strict";var sp=te(),wo=fr(),{ANY:np}=wo,ip=xe(),op=hr(),Do=dr(),yo=Ur(),ap=Vr(),cp=zr(),up=(t,e,r,s)=>{t=new sp(t,s),e=new ip(e,s);let n,i,o,a,c;switch(r){case">":n=Do,i=ap,o=yo,a=">",c=">=";break;case"<":n=yo,i=cp,o=Do,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(op(t,e,s))return!1;for(let u=0;u<e.set.length;++u){let d=e.set[u],h=null,p=null;if(d.forEach(l=>{l.semver===np&&(l=new wo(">=0.0.0")),h=h||l,p=p||l,n(l.semver,h.semver,s)?h=l:o(l.semver,p.semver,s)&&(p=l)}),h.operator===a||h.operator===c||(!p.operator||p.operator===a)&&i(t,p.semver))return!1;if(p.operator===c&&o(t,p.semver))return!1}return!0};Eo.exports=up});var vo=R((Iw,xo)=>{"use strict";var lp=Jr(),dp=(t,e,r)=>lp(t,e,">",r);xo.exports=dp});var bo=R((Ow,Co)=>{"use strict";var fp=Jr(),pp=(t,e,r)=>fp(t,e,"<",r);Co.exports=pp});var So=R((kw,Ro)=>{"use strict";var Fo=xe(),hp=(t,e,r)=>(t=new Fo(t,r),e=new Fo(e,r),t.intersects(e,r));Ro.exports=hp});var Ao=R((Tw,_o)=>{"use strict";var mp=hr(),gp=Ee();_o.exports=(t,e,r)=>{let s=[],n=null,i=null,o=t.sort((d,h)=>gp(d,h,r));for(let d of o)mp(d,e,r)?(i=d,n||(n=d)):(i&&s.push([n,i]),i=null,n=null);n&&s.push([n,null]);let a=[];for(let[d,h]of s)d===h?a.push(d):!h&&d===o[0]?a.push("*"):h?d===o[0]?a.push(`<=${h}`):a.push(`${d} - ${h}`):a.push(`>=${d}`);let c=a.join(" || "),u=typeof e.raw=="string"?e.raw:String(e);return c.length<u.length?c:e}});var Po=R((Pw,To)=>{"use strict";var $o=xe(),Ls=fr(),{ANY:Ns}=Ls,mr=hr(),Ms=Ee(),Dp=(t,e,r={})=>{if(t===e)return!0;t=new $o(t,r),e=new $o(e,r);let s=!1;e:for(let n of t.set){for(let i of e.set){let o=wp(n,i,r);if(s=s||o!==null,o)continue e}if(s)return!1}return!0},yp=[new Ls(">=0.0.0-0")],Io=[new Ls(">=0.0.0")],wp=(t,e,r)=>{if(t===e)return!0;if(t.length===1&&t[0].semver===Ns){if(e.length===1&&e[0].semver===Ns)return!0;r.includePrerelease?t=yp:t=Io}if(e.length===1&&e[0].semver===Ns){if(r.includePrerelease)return!0;e=Io}let s=new Set,n,i;for(let l of t)l.operator===">"||l.operator===">="?n=Oo(n,l,r):l.operator==="<"||l.operator==="<="?i=ko(i,l,r):s.add(l.semver);if(s.size>1)return null;let o;if(n&&i){if(o=Ms(n.semver,i.semver,r),o>0)return null;if(o===0&&(n.operator!==">="||i.operator!=="<="))return null}for(let l of s){if(n&&!mr(l,String(n),r)||i&&!mr(l,String(i),r))return null;for(let g of e)if(!mr(l,String(g),r))return!1;return!0}let a,c,u,d,h=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1,p=n&&!r.includePrerelease&&n.semver.prerelease.length?n.semver:!1;h&&h.prerelease.length===1&&i.operator==="<"&&h.prerelease[0]===0&&(h=!1);for(let l of e){if(d=d||l.operator===">"||l.operator===">=",u=u||l.operator==="<"||l.operator==="<=",n){if(p&&l.semver.prerelease&&l.semver.prerelease.length&&l.semver.major===p.major&&l.semver.minor===p.minor&&l.semver.patch===p.patch&&(p=!1),l.operator===">"||l.operator===">="){if(a=Oo(n,l,r),a===l&&a!==n)return!1}else if(n.operator===">="&&!mr(n.semver,String(l),r))return!1}if(i){if(h&&l.semver.prerelease&&l.semver.prerelease.length&&l.semver.major===h.major&&l.semver.minor===h.minor&&l.semver.patch===h.patch&&(h=!1),l.operator==="<"||l.operator==="<="){if(c=ko(i,l,r),c===l&&c!==i)return!1}else if(i.operator==="<="&&!mr(i.semver,String(l),r))return!1}if(!l.operator&&(i||n)&&o!==0)return!1}return!(n&&u&&!i&&o!==0||i&&d&&!n&&o!==0||p||h)},Oo=(t,e,r)=>{if(!t)return e;let s=Ms(t.semver,e.semver,r);return s>0?t:s<0||e.operator===">"&&t.operator===">="?e:t},ko=(t,e,r)=>{if(!t)return e;let s=Ms(t.semver,e.semver,r);return s<0?t:s>0||e.operator==="<"&&t.operator==="<="?e:t};To.exports=Dp});var Bs=R((Nw,Mo)=>{"use strict";var js=jt(),No=ur(),Ep=te(),Lo=Cs(),xp=vt(),vp=ci(),Cp=li(),bp=pi(),Fp=gi(),Rp=yi(),Sp=Ei(),_p=vi(),Ap=bi(),$p=Ee(),Ip=_i(),Op=$i(),kp=qr(),Tp=Ti(),Pp=Ni(),Np=dr(),Lp=Ur(),Mp=Rs(),jp=Ss(),Bp=zr(),Wp=Vr(),qp=_s(),Up=Vi(),zp=fr(),Vp=xe(),Gp=hr(),Hp=oo(),Jp=co(),Zp=lo(),Yp=ho(),Xp=go(),Kp=Jr(),Qp=vo(),eh=bo(),th=So(),rh=Ao(),sh=Po();Mo.exports={parse:xp,valid:vp,clean:Cp,inc:bp,diff:Fp,major:Rp,minor:Sp,patch:_p,prerelease:Ap,compare:$p,rcompare:Ip,compareLoose:Op,compareBuild:kp,sort:Tp,rsort:Pp,gt:Np,lt:Lp,eq:Mp,neq:jp,gte:Bp,lte:Wp,cmp:qp,coerce:Up,Comparator:zp,Range:Vp,satisfies:Gp,toComparators:Hp,maxSatisfying:Jp,minSatisfying:Zp,minVersion:Yp,validRange:Xp,outside:Kp,gtr:Qp,ltr:eh,intersects:th,simplifyRange:rh,subset:sh,SemVer:Ep,re:js.re,src:js.src,tokens:js.t,SEMVER_SPEC_VERSION:No.SEMVER_SPEC_VERSION,RELEASE_TYPES:No.RELEASE_TYPES,compareIdentifiers:Lo.compareIdentifiers,rcompareIdentifiers:Lo.rcompareIdentifiers}});var as=R((iv,tc)=>{var mn=[],ec=0,se=(t,e)=>{ec>=e&&mn.push(t)};se.WARN=1;se.INFO=2;se.DEBUG=3;se.reset=()=>{mn=[]};se.setDebugLevel=t=>{ec=t};se.warn=t=>se(t,se.WARN);se.info=t=>se(t,se.INFO);se.debug=t=>se(t,se.DEBUG);se.debugMessages=()=>mn;tc.exports=se});var sc=R((ov,rc)=>{"use strict";rc.exports=({onlyFirst:t=!1}={})=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")}});var ic=R((av,nc)=>{"use strict";var Zm=sc();nc.exports=t=>typeof t=="string"?t.replace(Zm(),""):t});var ac=R((cv,gn)=>{"use strict";var oc=t=>Number.isNaN(t)?!1:t>=4352&&(t<=4447||t===9001||t===9002||11904<=t&&t<=12871&&t!==12351||12880<=t&&t<=19903||19968<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65131||65281<=t&&t<=65376||65504<=t&&t<=65510||110592<=t&&t<=110593||127488<=t&&t<=127569||131072<=t&&t<=262141);gn.exports=oc;gn.exports.default=oc});var uc=R((uv,cc)=>{"use strict";cc.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var dc=R((lv,Dn)=>{"use strict";var Ym=ic(),Xm=ac(),Km=uc(),lc=t=>{if(typeof t!="string"||t.length===0||(t=Ym(t),t.length===0))return 0;t=t.replace(Km()," ");let e=0;for(let r=0;r<t.length;r++){let s=t.codePointAt(r);s<=31||s>=127&&s<=159||s>=768&&s<=879||(s>65535&&r++,e+=Xm(s)?2:1)}return e};Dn.exports=lc;Dn.exports.default=lc});var yn=R((dv,mc)=>{var fc=dc();function cs(t){return t?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function Pe(t){let e=cs();return(""+t).replace(e,"").split(`
|
|
6
|
+
`).reduce(function(n,i){return fc(i)>n?fc(i):n},0)}function wr(t,e){return Array(e+1).join(t)}function Qm(t,e,r,s){let n=Pe(t);if(e+1>=n){let i=e-n;switch(s){case"right":{t=wr(r,i)+t;break}case"center":{let o=Math.ceil(i/2),a=i-o;t=wr(r,a)+t+wr(r,o);break}default:{t=t+wr(r,i);break}}}return t}var Yt={};function Er(t,e,r){e="\x1B["+e+"m",r="\x1B["+r+"m",Yt[e]={set:t,to:!0},Yt[r]={set:t,to:!1},Yt[t]={on:e,off:r}}Er("bold",1,22);Er("italics",3,23);Er("underline",4,24);Er("inverse",7,27);Er("strikethrough",9,29);function pc(t,e){let r=e[1]?parseInt(e[1].split(";")[0]):0;if(r>=30&&r<=39||r>=90&&r<=97){t.lastForegroundAdded=e[0];return}if(r>=40&&r<=49||r>=100&&r<=107){t.lastBackgroundAdded=e[0];return}if(r===0){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&delete t[n];return}let s=Yt[e[0]];s&&(t[s.set]=s.to)}function eg(t){let e=cs(!0),r=e.exec(t),s={};for(;r!==null;)pc(s,r),r=e.exec(t);return s}function hc(t,e){let r=t.lastBackgroundAdded,s=t.lastForegroundAdded;return delete t.lastBackgroundAdded,delete t.lastForegroundAdded,Object.keys(t).forEach(function(n){t[n]&&(e+=Yt[n].off)}),r&&r!="\x1B[49m"&&(e+="\x1B[49m"),s&&s!="\x1B[39m"&&(e+="\x1B[39m"),e}function tg(t,e){let r=t.lastBackgroundAdded,s=t.lastForegroundAdded;return delete t.lastBackgroundAdded,delete t.lastForegroundAdded,Object.keys(t).forEach(function(n){t[n]&&(e=Yt[n].on+e)}),r&&r!="\x1B[49m"&&(e=r+e),s&&s!="\x1B[39m"&&(e=s+e),e}function rg(t,e){if(t.length===Pe(t))return t.substr(0,e);for(;Pe(t)>e;)t=t.slice(0,-1);return t}function sg(t,e){let r=cs(!0),s=t.split(cs()),n=0,i=0,o="",a,c={};for(;i<e;){a=r.exec(t);let u=s[n];if(n++,i+Pe(u)>e&&(u=rg(u,e-i)),o+=u,i+=Pe(u),i<e){if(!a)break;o+=a[0],pc(c,a)}}return hc(c,o)}function ng(t,e,r){if(r=r||"\u2026",Pe(t)<=e)return t;e-=Pe(r);let n=sg(t,e);n+=r;let i="\x1B]8;;\x07";return t.includes(i)&&!n.includes(i)&&(n+=i),n}function ig(){return{chars:{top:"\u2500","top-mid":"\u252C","top-left":"\u250C","top-right":"\u2510",bottom:"\u2500","bottom-mid":"\u2534","bottom-left":"\u2514","bottom-right":"\u2518",left:"\u2502","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u253C",right:"\u2502","right-mid":"\u2524",middle:"\u2502"},truncate:"\u2026",colWidths:[],rowHeights:[],colAligns:[],rowAligns:[],style:{"padding-left":1,"padding-right":1,head:["red"],border:["grey"],compact:!1},head:[]}}function og(t,e){t=t||{},e=e||ig();let r=Object.assign({},e,t);return r.chars=Object.assign({},e.chars,t.chars),r.style=Object.assign({},e.style,t.style),r}function ag(t,e){let r=[],s=e.split(/(\s+)/g),n=[],i=0,o;for(let a=0;a<s.length;a+=2){let c=s[a],u=i+Pe(c);i>0&&o&&(u+=o.length),u>t?(i!==0&&r.push(n.join("")),n=[c],i=Pe(c)):(n.push(o||"",c),i=u),o=s[a+1]}return i&&r.push(n.join("")),r}function cg(t,e){let r=[],s="";function n(o,a){for(s.length&&a&&(s+=a),s+=o;s.length>t;)r.push(s.slice(0,t)),s=s.slice(t)}let i=e.split(/(\s+)/g);for(let o=0;o<i.length;o+=2)n(i[o],o&&i[o-1]);return s.length&&r.push(s),r}function ug(t,e,r=!0){let s=[];e=e.split(`
|
|
7
|
+
`);let n=r?ag:cg;for(let i=0;i<e.length;i++)s.push.apply(s,n(t,e[i]));return s}function lg(t){let e={},r=[];for(let s=0;s<t.length;s++){let n=tg(e,t[s]);e=eg(n);let i=Object.assign({},e);r.push(hc(i,n))}return r}function dg(t,e){return["\x1B]","8",";",";",t||e,"\x07",e,"\x1B]","8",";",";","\x07"].join("")}mc.exports={strlen:Pe,repeat:wr,pad:Qm,truncate:ng,mergeOptions:og,wordWrap:ug,colorizeLines:lg,hyperlink:dg}});var wc=R((fv,yc)=>{var Dc={};yc.exports=Dc;var gc={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(gc).forEach(function(t){var e=gc[t],r=Dc[t]=[];r.open="\x1B["+e[0]+"m",r.close="\x1B["+e[1]+"m"})});var xc=R((pv,Ec)=>{"use strict";Ec.exports=function(t,e){e=e||process.argv;var r=e.indexOf("--"),s=/^-{1,2}/.test(t)?"":"--",n=e.indexOf(s+t);return n!==-1&&(r===-1?!0:n<r)}});var Cc=R((hv,vc)=>{"use strict";var fg=kn("os"),Ae=xc(),oe=process.env,Xt=void 0;Ae("no-color")||Ae("no-colors")||Ae("color=false")?Xt=!1:(Ae("color")||Ae("colors")||Ae("color=true")||Ae("color=always"))&&(Xt=!0);"FORCE_COLOR"in oe&&(Xt=oe.FORCE_COLOR.length===0||parseInt(oe.FORCE_COLOR,10)!==0);function pg(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function hg(t){if(Xt===!1)return 0;if(Ae("color=16m")||Ae("color=full")||Ae("color=truecolor"))return 3;if(Ae("color=256"))return 2;if(t&&!t.isTTY&&Xt!==!0)return 0;var e=Xt?1:0;if(process.platform==="win32"){var r=fg.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in oe)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(n){return n in oe})||oe.CI_NAME==="codeship"?1:e;if("TEAMCITY_VERSION"in oe)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(oe.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in oe){var s=parseInt((oe.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(oe.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(oe.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(oe.TERM)||"COLORTERM"in oe?1:(oe.TERM==="dumb",e)}function wn(t){var e=hg(t);return pg(e)}vc.exports={supportsColor:wn,stdout:wn(process.stdout),stderr:wn(process.stderr)}});var Fc=R((mv,bc)=>{bc.exports=function(e,r){var s="";e=e||"Run the trap, drop the bass",e=e.split("");var n={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return e.forEach(function(i){i=i.toLowerCase();var o=n[i]||[" "],a=Math.floor(Math.random()*o.length);typeof n[i]<"u"?s+=n[i][a]:s+=i}),s}});var Sc=R((gv,Rc)=>{Rc.exports=function(e,r){e=e||" he is here ";var s={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},n=[].concat(s.up,s.down,s.mid);function i(c){var u=Math.floor(Math.random()*c);return u}function o(c){var u=!1;return n.filter(function(d){u=d===c}),u}function a(c,u){var d="",h,p;u=u||{},u.up=typeof u.up<"u"?u.up:!0,u.mid=typeof u.mid<"u"?u.mid:!0,u.down=typeof u.down<"u"?u.down:!0,u.size=typeof u.size<"u"?u.size:"maxi",c=c.split("");for(p in c)if(!o(p)){switch(d=d+c[p],h={up:0,down:0,mid:0},u.size){case"mini":h.up=i(8),h.mid=i(2),h.down=i(8);break;case"maxi":h.up=i(16)+3,h.mid=i(4)+1,h.down=i(64)+3;break;default:h.up=i(8)+1,h.mid=i(6)/2,h.down=i(8)+1;break}var l=["up","mid","down"];for(var g in l)for(var w=l[g],x=0;x<=h[w];x++)u[w]&&(d=d+s[w][i(s[w].length)])}return d}return a(e,r)}});var Ac=R((Dv,_c)=>{_c.exports=function(t){return function(e,r,s){if(e===" ")return e;switch(r%3){case 0:return t.red(e);case 1:return t.white(e);case 2:return t.blue(e)}}}});var Ic=R((yv,$c)=>{$c.exports=function(t){return function(e,r,s){return r%2===0?e:t.inverse(e)}}});var kc=R((wv,Oc)=>{Oc.exports=function(t){var e=["red","yellow","green","blue","magenta"];return function(r,s,n){return r===" "?r:t[e[s++%e.length]](r)}}});var Pc=R((Ev,Tc)=>{Tc.exports=function(t){var e=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(r,s,n){return r===" "?r:t[e[Math.round(Math.random()*(e.length-2))]](r)}}});var Wc=R((vv,Bc)=>{var j={};Bc.exports=j;j.themes={};var mg=kn("util"),St=j.styles=wc(),Lc=Object.defineProperties,gg=new RegExp(/[\r\n]+/g);j.supportsColor=Cc().supportsColor;typeof j.enabled>"u"&&(j.enabled=j.supportsColor()!==!1);j.enable=function(){j.enabled=!0};j.disable=function(){j.enabled=!1};j.stripColors=j.strip=function(t){return(""+t).replace(/\x1B\[\d+m/g,"")};var xv=j.stylize=function(e,r){if(!j.enabled)return e+"";var s=St[r];return!s&&r in j?j[r](e):s.open+e+s.close},Dg=/[|\\{}()[\]^$+*?.]/g,yg=function(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(Dg,"\\$&")};function Mc(t){var e=function r(){return Eg.apply(r,arguments)};return e._styles=t,e.__proto__=wg,e}var jc=(function(){var t={};return St.grey=St.gray,Object.keys(St).forEach(function(e){St[e].closeRe=new RegExp(yg(St[e].close),"g"),t[e]={get:function(){return Mc(this._styles.concat(e))}}}),t})(),wg=Lc(function(){},jc);function Eg(){var t=Array.prototype.slice.call(arguments),e=t.map(function(o){return o!=null&&o.constructor===String?o:mg.inspect(o)}).join(" ");if(!j.enabled||!e)return e;for(var r=e.indexOf(`
|
|
8
|
+
`)!=-1,s=this._styles,n=s.length;n--;){var i=St[s[n]];e=i.open+e.replace(i.closeRe,i.open)+i.close,r&&(e=e.replace(gg,function(o){return i.close+o+i.open}))}return e}j.setTheme=function(t){if(typeof t=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var e in t)(function(r){j[r]=function(s){if(typeof t[r]=="object"){var n=s;for(var i in t[r])n=j[t[r][i]](n);return n}return j[t[r]](s)}})(e)};function xg(){var t={};return Object.keys(jc).forEach(function(e){t[e]={get:function(){return Mc([e])}}}),t}var vg=function(e,r){var s=r.split("");return s=s.map(e),s.join("")};j.trap=Fc();j.zalgo=Sc();j.maps={};j.maps.america=Ac()(j);j.maps.zebra=Ic()(j);j.maps.rainbow=kc()(j);j.maps.random=Pc()(j);for(Nc in j.maps)(function(t){j[t]=function(e){return vg(j.maps[t],e)}})(Nc);var Nc;Lc(j,xg())});var Uc=R((Cv,qc)=>{var Cg=Wc();qc.exports=Cg});var Hc=R((bv,us)=>{var{info:bg,debug:Gc}=as(),me=yn(),xn=class t{constructor(e){this.setOptions(e),this.x=null,this.y=null}setOptions(e){["boolean","number","bigint","string"].indexOf(typeof e)!==-1&&(e={content:""+e}),e=e||{},this.options=e;let r=e.content;if(["boolean","number","bigint","string"].indexOf(typeof r)!==-1)this.content=String(r);else if(!r)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof r);this.colSpan=e.colSpan||1,this.rowSpan=e.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(e,r){this.cells=r;let s=this.options.chars||{},n=e.chars,i=this.chars={};Rg.forEach(function(c){En(s,n,c,i)}),this.truncate=this.options.truncate||e.truncate;let o=this.options.style=this.options.style||{},a=e.style;En(o,a,"padding-left",this),En(o,a,"padding-right",this),this.head=o.head||a.head,this.border=o.border||a.border,this.fixedWidth=e.colWidths[this.x],this.lines=this.computeLines(e),this.desiredWidth=me.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(e){let r=e.wordWrap||e.textWrap,{wordWrap:s=r}=this.options;if(this.fixedWidth&&s){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let o=1;for(;o<this.colSpan;)this.fixedWidth+=e.colWidths[this.x+o],o++}let{wrapOnWordBoundary:n=!0}=e,{wrapOnWordBoundary:i=n}=this.options;return this.wrapLines(me.wordWrap(this.fixedWidth,this.content,i))}return this.wrapLines(this.content.split(`
|
|
9
|
+
`))}wrapLines(e){let r=me.colorizeLines(e);return this.href?r.map(s=>me.hyperlink(this.href,s)):r}init(e){let r=this.x,s=this.y;this.widths=e.colWidths.slice(r,r+this.colSpan),this.heights=e.rowHeights.slice(s,s+this.rowSpan),this.width=this.widths.reduce(Vc,-1),this.height=this.heights.reduce(Vc,-1),this.hAlign=this.options.hAlign||e.colAligns[r],this.vAlign=this.options.vAlign||e.rowAligns[s],this.drawRight=r+this.colSpan==e.colWidths.length}draw(e,r){if(e=="top")return this.drawTop(this.drawRight);if(e=="bottom")return this.drawBottom(this.drawRight);let s=me.truncate(this.content,10,this.truncate);e||bg(`${this.y}-${this.x}: ${this.rowSpan-e}x${this.colSpan} Cell ${s}`);let n=Math.max(this.height-this.lines.length,0),i;switch(this.vAlign){case"center":i=Math.ceil(n/2);break;case"bottom":i=n;break;default:i=0}if(e<i||e>=i+this.lines.length)return this.drawEmpty(this.drawRight,r);let o=this.lines.length>this.height&&e+1>=this.height;return this.drawLine(e-i,this.drawRight,o,r)}drawTop(e){let r=[];return this.cells?this.widths.forEach(function(s,n){r.push(this._topLeftChar(n)),r.push(me.repeat(this.chars[this.y==0?"top":"mid"],s))},this):(r.push(this._topLeftChar(0)),r.push(me.repeat(this.chars[this.y==0?"top":"mid"],this.width))),e&&r.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",r.join(""))}_topLeftChar(e){let r=this.x+e,s;if(this.y==0)s=r==0?"topLeft":e==0?"topMid":"top";else if(r==0)s="leftMid";else if(s=e==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][r]instanceof t.ColSpanCell&&(s=e==0?"topMid":"mid"),e==0)){let i=1;for(;this.cells[this.y][r-i]instanceof t.ColSpanCell;)i++;this.cells[this.y][r-i]instanceof t.RowSpanCell&&(s="leftMid")}return this.chars[s]}wrapWithStyleColors(e,r){if(this[e]&&this[e].length)try{let s=Uc();for(let n=this[e].length-1;n>=0;n--)s=s[this[e][n]];return s(r)}catch{return r}else return r}drawLine(e,r,s,n){let i=this.chars[this.x==0?"left":"middle"];if(this.x&&n&&this.cells){let p=this.cells[this.y+n][this.x-1];for(;p instanceof xr;)p=this.cells[p.y][p.x-1];p instanceof vr||(i=this.chars.rightMid)}let o=me.repeat(" ",this.paddingLeft),a=r?this.chars.right:"",c=me.repeat(" ",this.paddingRight),u=this.lines[e],d=this.width-(this.paddingLeft+this.paddingRight);s&&(u+=this.truncate||"\u2026");let h=me.truncate(u,d,this.truncate);return h=me.pad(h,d," ",this.hAlign),h=o+h+c,this.stylizeLine(i,h,a)}stylizeLine(e,r,s){return e=this.wrapWithStyleColors("border",e),s=this.wrapWithStyleColors("border",s),this.y===0&&(r=this.wrapWithStyleColors("head",r)),e+r+s}drawBottom(e){let r=this.chars[this.x==0?"bottomLeft":"bottomMid"],s=me.repeat(this.chars.bottom,this.width),n=e?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",r+s+n)}drawEmpty(e,r){let s=this.chars[this.x==0?"left":"middle"];if(this.x&&r&&this.cells){let o=this.cells[this.y+r][this.x-1];for(;o instanceof xr;)o=this.cells[o.y][o.x-1];o instanceof vr||(s=this.chars.rightMid)}let n=e?this.chars.right:"",i=me.repeat(" ",this.width);return this.stylizeLine(s,i,n)}},xr=class{constructor(){}draw(e){return typeof e=="number"&&Gc(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},vr=class{constructor(e){this.originalCell=e}init(e){let r=this.y,s=this.originalCell.y;this.cellOffset=r-s,this.offset=Fg(e.rowHeights,s,this.cellOffset)}draw(e){return e=="top"?this.originalCell.draw(this.offset,this.cellOffset):e=="bottom"?this.originalCell.draw("bottom"):(Gc(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+e))}mergeTableOptions(){}};function zc(...t){return t.filter(e=>e!=null).shift()}function En(t,e,r,s){let n=r.split("-");n.length>1?(n[1]=n[1].charAt(0).toUpperCase()+n[1].substr(1),n=n.join(""),s[n]=zc(t[n],t[r],e[n],e[r])):s[r]=zc(t[r],e[r])}function Fg(t,e,r){let s=t[e];for(let n=1;n<r;n++)s+=1+t[e+n];return s}function Vc(t,e){return t+e+1}var Rg=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];us.exports=xn;us.exports.ColSpanCell=xr;us.exports.RowSpanCell=vr});var Yc=R((Fv,Zc)=>{var{warn:Sg,debug:_g}=as(),vn=Hc(),{ColSpanCell:Ag,RowSpanCell:$g}=vn;(function(){function t(l,g){return l[g]>0?t(l,g+1):g}function e(l){let g={};l.forEach(function(w,x){let A=0;w.forEach(function($){$.y=x,$.x=x?t(g,A):A;let L=$.rowSpan||1,q=$.colSpan||1;if(L>1)for(let U=0;U<q;U++)g[$.x+U]=L;A=$.x+q}),Object.keys(g).forEach($=>{g[$]--,g[$]<1&&delete g[$]})})}function r(l){let g=0;return l.forEach(function(w){w.forEach(function(x){g=Math.max(g,x.x+(x.colSpan||1))})}),g}function s(l){return l.length}function n(l,g){let w=l.y,x=l.y-1+(l.rowSpan||1),A=g.y,$=g.y-1+(g.rowSpan||1),L=!(w>$||A>x),q=l.x,U=l.x-1+(l.colSpan||1),Le=g.x,N=g.x-1+(g.colSpan||1),G=!(q>N||Le>U);return L&&G}function i(l,g,w){let x=Math.min(l.length-1,w),A={x:g,y:w};for(let $=0;$<=x;$++){let L=l[$];for(let q=0;q<L.length;q++)if(n(A,L[q]))return!0}return!1}function o(l,g,w,x){for(let A=w;A<x;A++)if(i(l,A,g))return!1;return!0}function a(l){l.forEach(function(g,w){g.forEach(function(x){for(let A=1;A<x.rowSpan;A++){let $=new $g(x);$.x=x.x,$.y=x.y+A,$.colSpan=x.colSpan,u($,l[w+A])}})})}function c(l){for(let g=l.length-1;g>=0;g--){let w=l[g];for(let x=0;x<w.length;x++){let A=w[x];for(let $=1;$<A.colSpan;$++){let L=new Ag;L.x=A.x+$,L.y=A.y,w.splice(x+1,0,L)}}}}function u(l,g){let w=0;for(;w<g.length&&g[w].x<l.x;)w++;g.splice(w,0,l)}function d(l){let g=s(l),w=r(l);_g(`Max rows: ${g}; Max cols: ${w}`);for(let x=0;x<g;x++)for(let A=0;A<w;A++)if(!i(l,A,x)){let $={x:A,y:x,colSpan:1,rowSpan:1};for(A++;A<w&&!i(l,A,x);)$.colSpan++,A++;let L=x+1;for(;L<g&&o(l,L,$.x,$.x+$.colSpan);)$.rowSpan++,L++;let q=new vn($);q.x=$.x,q.y=$.y,Sg(`Missing cell at ${q.y}-${q.x}.`),u(q,l[x])}}function h(l){return l.map(function(g){if(!Array.isArray(g)){let w=Object.keys(g)[0];g=g[w],Array.isArray(g)?(g=g.slice(),g.unshift(w)):g=[w,g]}return g.map(function(w){return new vn(w)})})}function p(l){let g=h(l);return e(g),d(g),a(g),c(g),g}Zc.exports={makeTableLayout:p,layoutTable:e,addRowSpanCells:a,maxWidth:r,fillInTable:d,computeWidths:Jc("colSpan","desiredWidth","x",1),computeHeights:Jc("rowSpan","desiredHeight","y",1)}})();function Jc(t,e,r,s){return function(n,i){let o=[],a=[],c={};i.forEach(function(u){u.forEach(function(d){(d[t]||1)>1?a.push(d):o[d[r]]=Math.max(o[d[r]]||0,d[e]||0,s)})}),n.forEach(function(u,d){typeof u=="number"&&(o[d]=u)});for(let u=a.length-1;u>=0;u--){let d=a[u],h=d[t],p=d[r],l=o[p],g=typeof n[p]=="number"?0:1;if(typeof l=="number")for(let w=1;w<h;w++)l+=1+o[p+w],typeof n[p+w]!="number"&&g++;else l=e==="desiredWidth"?d.desiredWidth-1:1,(!c[p]||c[p]<l)&&(c[p]=l);if(d[e]>l){let w=0;for(;g>0&&d[e]>l;){if(typeof n[p+w]!="number"){let x=Math.round((d[e]-l)/g);l+=x,o[p+w]+=x,g--}w++}}}Object.assign(n,o,c);for(let u=0;u<n.length;u++)n[u]=Math.max(s,n[u]||0)}}});var Kc=R((Rv,Xc)=>{var Ve=as(),Ig=yn(),Cn=Yc(),ls=class extends Array{constructor(e){super();let r=Ig.mergeOptions(e);if(Object.defineProperty(this,"options",{value:r,enumerable:r.debug}),r.debug){switch(typeof r.debug){case"boolean":Ve.setDebugLevel(Ve.WARN);break;case"number":Ve.setDebugLevel(r.debug);break;case"string":Ve.setDebugLevel(parseInt(r.debug,10));break;default:Ve.setDebugLevel(Ve.WARN),Ve.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof r.debug}`)}Object.defineProperty(this,"messages",{get(){return Ve.debugMessages()}})}}toString(){let e=this,r=this.options.head&&this.options.head.length;r?(e=[this.options.head],this.length&&e.push.apply(e,this)):this.options.style.head=[];let s=Cn.makeTableLayout(e);s.forEach(function(i){i.forEach(function(o){o.mergeTableOptions(this.options,s)},this)},this),Cn.computeWidths(this.options.colWidths,s),Cn.computeHeights(this.options.rowHeights,s),s.forEach(function(i){i.forEach(function(o){o.init(this.options)},this)},this);let n=[];for(let i=0;i<s.length;i++){let o=s[i],a=this.options.rowHeights[i];(i===0||!this.options.style.compact||i==1&&r)&&bn(o,"top",n);for(let c=0;c<a;c++)bn(o,c,n);i+1==s.length&&bn(o,"bottom",n)}return n.join(`
|
|
10
|
+
`)}get width(){return this.toString().split(`
|
|
11
|
+
`)[0].length}};ls.reset=()=>Ve.reset();function bn(t,e,r){let s=[];t.forEach(function(i){s.push(i.draw(e))});let n=s.join("");n.length&&r.push(n)}Xc.exports=ls});var Cr=R((Sv,Qc)=>{Qc.exports=Kc()});import{command as Fe,subcommands as pD,run as hD,positional as sr,option as In,string as Ge,optional as Fr,flag as On}from"cmd-ts";import{writeFile as ta,mkdir as ra,rm as sa}from"node:fs/promises";import na from"ora";import{access as ch,constants as uh,readFile as zo}from"node:fs/promises";import{join as Bt}from"node:path";import{homedir as lh}from"node:os";import{select as dh}from"@inquirer/prompts";import At from"chalk";var D={SUCCESS:0,VALIDATION_ERROR:1,IO_ERROR:2,DEPENDENCY_ERROR:3,AUTHENTICATION_ERROR:4,USER_CANCELLED:130},m=class t extends Error{constructor(r,s){super(r);this.exitCode=s;this.name="CLIError",Error.captureStackTrace(this,t)}};function hs(t,e){let r=At.red("Error:"),s=e?` ${At.yellow(e)} failed:`:"";return`${r}${s} ${t.message}`}function $t(t){return`${At.yellow("Warning:")} ${t}`}function K(t){return At.dim(t)}function S(t){return At.cyan(t)}function H(t){return At.cyan.bold(t)}function Tn(t){return t instanceof m?t.exitCode:D.VALIDATION_ERROR}import{promises as Xe}from"node:fs";import Ke from"node:path";import ar from"fs-extra";var f={};Tu(f,{BRAND:()=>al,DIRTY:()=>nt,EMPTY_PATH:()=>ju,INVALID:()=>I,NEVER:()=>Vl,OK:()=>ee,ParseStatus:()=>Q,Schema:()=>P,ZodAny:()=>Ze,ZodArray:()=>qe,ZodBigInt:()=>ot,ZodBoolean:()=>at,ZodBranded:()=>ir,ZodCatch:()=>yt,ZodDate:()=>ct,ZodDefault:()=>Dt,ZodDiscriminatedUnion:()=>_r,ZodEffects:()=>we,ZodEnum:()=>mt,ZodError:()=>ce,ZodFirstPartyTypeKind:()=>O,ZodFunction:()=>$r,ZodIntersection:()=>ft,ZodIssueCode:()=>y,ZodLazy:()=>pt,ZodLiteral:()=>ht,ZodMap:()=>Nt,ZodNaN:()=>Mt,ZodNativeEnum:()=>gt,ZodNever:()=>Se,ZodNull:()=>lt,ZodNullable:()=>ke,ZodNumber:()=>it,ZodObject:()=>ue,ZodOptional:()=>De,ZodParsedType:()=>C,ZodPipeline:()=>or,ZodPromise:()=>Ye,ZodReadonly:()=>wt,ZodRecord:()=>Ar,ZodSchema:()=>P,ZodSet:()=>Lt,ZodString:()=>Je,ZodSymbol:()=>Tt,ZodTransformer:()=>we,ZodTuple:()=>Oe,ZodType:()=>P,ZodUndefined:()=>ut,ZodUnion:()=>dt,ZodUnknown:()=>We,ZodVoid:()=>Pt,addIssueToContext:()=>E,any:()=>gl,array:()=>El,bigint:()=>dl,boolean:()=>Vn,coerce:()=>zl,custom:()=>qn,date:()=>fl,datetimeRegex:()=>Bn,defaultErrorMap:()=>je,discriminatedUnion:()=>bl,effect:()=>Nl,enum:()=>kl,function:()=>$l,getErrorMap:()=>It,getParsedType:()=>Ie,instanceof:()=>ul,intersection:()=>Fl,isAborted:()=>Rr,isAsync:()=>Ot,isDirty:()=>Sr,isValid:()=>He,late:()=>cl,lazy:()=>Il,literal:()=>Ol,makeIssue:()=>nr,map:()=>_l,nan:()=>ll,nativeEnum:()=>Tl,never:()=>yl,null:()=>ml,nullable:()=>Ml,number:()=>zn,object:()=>xl,objectUtil:()=>ms,oboolean:()=>Ul,onumber:()=>ql,optional:()=>Ll,ostring:()=>Wl,pipeline:()=>Bl,preprocess:()=>jl,promise:()=>Pl,quotelessJson:()=>Nu,record:()=>Sl,set:()=>Al,setErrorMap:()=>Mu,strictObject:()=>vl,string:()=>Un,symbol:()=>pl,transformer:()=>Nl,tuple:()=>Rl,undefined:()=>hl,union:()=>Cl,unknown:()=>Dl,util:()=>M,void:()=>wl});var M;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{let i={};for(let o of n)i[o]=o;return i},t.getValidEnumValues=n=>{let i=t.objectKeys(n).filter(a=>typeof n[n[a]]!="number"),o={};for(let a of i)o[a]=n[a];return t.objectValues(o)},t.objectValues=n=>t.objectKeys(n).map(function(i){return n[i]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let i=[];for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&i.push(o);return i},t.find=(n,i)=>{for(let o of n)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,i=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=s,t.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(M||(M={}));var ms;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(ms||(ms={}));var C=M.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ie=t=>{switch(typeof t){case"undefined":return C.undefined;case"string":return C.string;case"number":return Number.isNaN(t)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":return Array.isArray(t)?C.array:t===null?C.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?C.promise:typeof Map<"u"&&t instanceof Map?C.map:typeof Set<"u"&&t instanceof Set?C.set:typeof Date<"u"&&t instanceof Date?C.date:C.object;default:return C.unknown}};var y=M.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"]),Nu=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ce=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},s={_errors:[]},n=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)s._errors.push(r(o));else{let a=s,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return n(this),s}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,M.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},s=[];for(let n of this.issues)if(n.path.length>0){let i=n.path[0];r[i]=r[i]||[],r[i].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:r}}get formErrors(){return this.flatten()}};ce.create=t=>new ce(t);var Lu=(t,e)=>{let r;switch(t.code){case y.invalid_type:t.received===C.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case y.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,M.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:r=`Unrecognized key(s) in object: ${M.joinValues(t.keys,", ")}`;break;case y.invalid_union:r="Invalid input";break;case y.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${M.joinValues(t.options)}`;break;case y.invalid_enum_value:r=`Invalid enum value. Expected ${M.joinValues(t.options)}, received '${t.received}'`;break;case y.invalid_arguments:r="Invalid function arguments";break;case y.invalid_return_type:r="Invalid function return type";break;case y.invalid_date:r="Invalid date";break;case y.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:M.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case y.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case y.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case y.custom:r="Invalid input";break;case y.invalid_intersection_types:r="Intersection results could not be merged";break;case y.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case y.not_finite:r="Number must be finite";break;default:r=e.defaultError,M.assertNever(t)}return{message:r}},je=Lu;var Pn=je;function Mu(t){Pn=t}function It(){return Pn}var nr=t=>{let{data:e,path:r,errorMaps:s,issueData:n}=t,i=[...r,...n.path||[]],o={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let a="",c=s.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:e,defaultError:a}).message;return{...n,path:i,message:a}},ju=[];function E(t,e){let r=It(),s=nr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===je?void 0:je].filter(n=>!!n)});t.common.issues.push(s)}var Q=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let s=[];for(let n of r){if(n.status==="aborted")return I;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,r){let s=[];for(let n of r){let i=await n.key,o=await n.value;s.push({key:i,value:o})}return t.mergeObjectSync(e,s)}static mergeObjectSync(e,r){let s={};for(let n of r){let{key:i,value:o}=n;if(i.status==="aborted"||o.status==="aborted")return I;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(s[i.value]=o.value)}return{status:e.value,value:s}}},I=Object.freeze({status:"aborted"}),nt=t=>({status:"dirty",value:t}),ee=t=>({status:"valid",value:t}),Rr=t=>t.status==="aborted",Sr=t=>t.status==="dirty",He=t=>t.status==="valid",Ot=t=>typeof Promise<"u"&&t instanceof Promise;var _;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(_||(_={}));var ye=class{constructor(e,r,s,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Nn=(t,e)=>{if(He(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new ce(t.common.issues);return this._error=r,this._error}}};function T(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:s,description:n}=t;if(e&&(r||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??s??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:n}}var P=class{get description(){return this._def.description}_getType(e){return Ie(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Q,ctx:{common:e.parent.common,data:e.data,parsedType:Ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Ot(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let s=this.safeParse(e,r);if(s.success)return s.data;throw s.error}safeParse(e,r){let s={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ie(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Nn(s,n)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ie(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:r});return He(s)?{value:s.value}:{issues:r.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(s=>He(s)?{value:s.value}:{issues:r.common.issues})}async parseAsync(e,r){let s=await this.safeParseAsync(e,r);if(s.success)return s.data;throw s.error}async safeParseAsync(e,r){let s={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ie(e)},n=this._parse({data:e,path:s.path,parent:s}),i=await(Ot(n)?n:Promise.resolve(n));return Nn(s,i)}refine(e,r){let s=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,i)=>{let o=e(n),a=()=>i.addIssue({code:y.custom,...s(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,r){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof r=="function"?r(s,n):r),!1))}_refinement(e){return new we({schema:this,typeName:O.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return De.create(this,this._def)}nullable(){return ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qe.create(this)}promise(){return Ye.create(this,this._def)}or(e){return dt.create([this,e],this._def)}and(e){return ft.create(this,e,this._def)}transform(e){return new we({...T(this._def),schema:this,typeName:O.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Dt({...T(this._def),innerType:this,defaultValue:r,typeName:O.ZodDefault})}brand(){return new ir({typeName:O.ZodBranded,type:this,...T(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new yt({...T(this._def),innerType:this,catchValue:r,typeName:O.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return or.create(this,e)}readonly(){return wt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Bu=/^c[^\s-]{8,}$/i,Wu=/^[0-9a-z]+$/,qu=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Uu=/^[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,zu=/^[a-z0-9_-]{21}$/i,Vu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Gu=/^[-+]?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)?)??$/,Hu=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ju="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",gs,Zu=/^(?:(?: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])$/,Yu=/^(?:(?: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])$/,Xu=/^(([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]))$/,Ku=/^(([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])$/,Qu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,el=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mn="((\\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])))",tl=new RegExp(`^${Mn}$`);function jn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function rl(t){return new RegExp(`^${jn(t)}$`)}function Bn(t){let e=`${Mn}T${jn(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function sl(t,e){return!!((e==="v4"||!e)&&Zu.test(t)||(e==="v6"||!e)&&Xu.test(t))}function nl(t,e){if(!Vu.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function il(t,e){return!!((e==="v4"||!e)&&Yu.test(t)||(e==="v6"||!e)&&Ku.test(t))}var Je=class t extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==C.string){let i=this._getOrReturnCtx(e);return E(i,{code:y.invalid_type,expected:C.string,received:i.parsedType}),I}let s=new Q,n;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:y.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:y.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(n=this._getOrReturnCtx(e,n),o?E(n,{code:y.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&E(n,{code:y.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")Hu.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"email",code:y.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")gs||(gs=new RegExp(Ju,"u")),gs.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"emoji",code:y.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")Uu.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"uuid",code:y.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")zu.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"nanoid",code:y.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")Bu.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cuid",code:y.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")Wu.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cuid2",code:y.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")qu.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"ulid",code:y.invalid_string,message:i.message}),s.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),E(n,{validation:"url",code:y.invalid_string,message:i.message}),s.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"regex",code:y.invalid_string,message:i.message}),s.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),E(n,{code:y.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),s.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),E(n,{code:y.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),E(n,{code:y.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?Bn(i).test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:y.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?tl.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:y.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?rl(i).test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:y.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?Gu.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"duration",code:y.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?sl(e.data,i.version)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"ip",code:y.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?nl(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"jwt",code:y.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?il(e.data,i.version)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cidr",code:y.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?Qu.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"base64",code:y.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?el.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"base64url",code:y.invalid_string,message:i.message}),s.dirty()):M.assertNever(i);return{status:s.value,value:e.data}}_regex(e,r,s){return this.refinement(n=>e.test(n),{validation:r,code:y.invalid_string,..._.errToObj(s)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",..._.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",..._.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",..._.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,..._.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,..._.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",..._.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,..._.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,..._.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,..._.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,..._.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,..._.errToObj(r)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Je.create=t=>new Je({checks:[],typeName:O.ZodString,coerce:t?.coerce??!1,...T(t)});function ol(t,e){let r=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=r>s?r:s,i=Number.parseInt(t.toFixed(n).replace(".","")),o=Number.parseInt(e.toFixed(n).replace(".",""));return i%o/10**n}var it=class t extends P{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)!==C.number){let i=this._getOrReturnCtx(e);return E(i,{code:y.invalid_type,expected:C.number,received:i.parsedType}),I}let s,n=new Q;for(let i of this._def.checks)i.kind==="int"?M.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{code:y.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),E(s,{code:y.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),E(s,{code:y.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?ol(e.data,i.value)!==0&&(s=this._getOrReturnCtx(e,s),E(s,{code:y.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{code:y.not_finite,message:i.message}),n.dirty()):M.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,_.toString(r))}gt(e,r){return this.setLimit("min",e,!1,_.toString(r))}lte(e,r){return this.setLimit("max",e,!0,_.toString(r))}lt(e,r){return this.setLimit("max",e,!1,_.toString(r))}setLimit(e,r,s,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:s,message:_.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&M.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(r===null||s.value>r)&&(r=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(r)&&Number.isFinite(e)}};it.create=t=>new it({checks:[],typeName:O.ZodNumber,coerce:t?.coerce||!1,...T(t)});var ot=class t extends P{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)!==C.bigint)return this._getInvalidInput(e);let s,n=new Q;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(s=this._getOrReturnCtx(e,s),E(s,{code:y.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(s=this._getOrReturnCtx(e,s),E(s,{code:y.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),E(s,{code:y.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):M.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return E(r,{code:y.invalid_type,expected:C.bigint,received:r.parsedType}),I}gte(e,r){return this.setLimit("min",e,!0,_.toString(r))}gt(e,r){return this.setLimit("min",e,!1,_.toString(r))}lte(e,r){return this.setLimit("max",e,!0,_.toString(r))}lt(e,r){return this.setLimit("max",e,!1,_.toString(r))}setLimit(e,r,s,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:s,message:_.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ot.create=t=>new ot({checks:[],typeName:O.ZodBigInt,coerce:t?.coerce??!1,...T(t)});var at=class extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==C.boolean){let s=this._getOrReturnCtx(e);return E(s,{code:y.invalid_type,expected:C.boolean,received:s.parsedType}),I}return ee(e.data)}};at.create=t=>new at({typeName:O.ZodBoolean,coerce:t?.coerce||!1,...T(t)});var ct=class t extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==C.date){let i=this._getOrReturnCtx(e);return E(i,{code:y.invalid_type,expected:C.date,received:i.parsedType}),I}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return E(i,{code:y.invalid_date}),I}let s=new Q,n;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:y.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),s.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:y.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):M.assertNever(i);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ct.create=t=>new ct({checks:[],coerce:t?.coerce||!1,typeName:O.ZodDate,...T(t)});var Tt=class extends P{_parse(e){if(this._getType(e)!==C.symbol){let s=this._getOrReturnCtx(e);return E(s,{code:y.invalid_type,expected:C.symbol,received:s.parsedType}),I}return ee(e.data)}};Tt.create=t=>new Tt({typeName:O.ZodSymbol,...T(t)});var ut=class extends P{_parse(e){if(this._getType(e)!==C.undefined){let s=this._getOrReturnCtx(e);return E(s,{code:y.invalid_type,expected:C.undefined,received:s.parsedType}),I}return ee(e.data)}};ut.create=t=>new ut({typeName:O.ZodUndefined,...T(t)});var lt=class extends P{_parse(e){if(this._getType(e)!==C.null){let s=this._getOrReturnCtx(e);return E(s,{code:y.invalid_type,expected:C.null,received:s.parsedType}),I}return ee(e.data)}};lt.create=t=>new lt({typeName:O.ZodNull,...T(t)});var Ze=class extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return ee(e.data)}};Ze.create=t=>new Ze({typeName:O.ZodAny,...T(t)});var We=class extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ee(e.data)}};We.create=t=>new We({typeName:O.ZodUnknown,...T(t)});var Se=class extends P{_parse(e){let r=this._getOrReturnCtx(e);return E(r,{code:y.invalid_type,expected:C.never,received:r.parsedType}),I}};Se.create=t=>new Se({typeName:O.ZodNever,...T(t)});var Pt=class extends P{_parse(e){if(this._getType(e)!==C.undefined){let s=this._getOrReturnCtx(e);return E(s,{code:y.invalid_type,expected:C.void,received:s.parsedType}),I}return ee(e.data)}};Pt.create=t=>new Pt({typeName:O.ZodVoid,...T(t)});var qe=class t extends P{_parse(e){let{ctx:r,status:s}=this._processInputParams(e),n=this._def;if(r.parsedType!==C.array)return E(r,{code:y.invalid_type,expected:C.array,received:r.parsedType}),I;if(n.exactLength!==null){let o=r.data.length>n.exactLength.value,a=r.data.length<n.exactLength.value;(o||a)&&(E(r,{code:o?y.too_big:y.too_small,minimum:a?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(E(r,{code:y.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(E(r,{code:y.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>n.type._parseAsync(new ye(r,o,r.path,a)))).then(o=>Q.mergeArray(s,o));let i=[...r.data].map((o,a)=>n.type._parseSync(new ye(r,o,r.path,a)));return Q.mergeArray(s,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:_.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:_.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:_.toString(r)}})}nonempty(e){return this.min(1,e)}};qe.create=(t,e)=>new qe({type:t,minLength:null,maxLength:null,exactLength:null,typeName:O.ZodArray,...T(e)});function kt(t){if(t instanceof ue){let e={};for(let r in t.shape){let s=t.shape[r];e[r]=De.create(kt(s))}return new ue({...t._def,shape:()=>e})}else return t instanceof qe?new qe({...t._def,type:kt(t.element)}):t instanceof De?De.create(kt(t.unwrap())):t instanceof ke?ke.create(kt(t.unwrap())):t instanceof Oe?Oe.create(t.items.map(e=>kt(e))):t}var ue=class t extends P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=M.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==C.object){let u=this._getOrReturnCtx(e);return E(u,{code:y.invalid_type,expected:C.object,received:u.parsedType}),I}let{status:s,ctx:n}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Se&&this._def.unknownKeys==="strip"))for(let u in n.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let d=i[u],h=n.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new ye(n,h,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Se){let u=this._def.unknownKeys;if(u==="passthrough")for(let d of a)c.push({key:{status:"valid",value:d},value:{status:"valid",value:n.data[d]}});else if(u==="strict")a.length>0&&(E(n,{code:y.unrecognized_keys,keys:a}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let d of a){let h=n.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new ye(n,h,n.path,d)),alwaysSet:d in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let u=[];for(let d of c){let h=await d.key,p=await d.value;u.push({key:h,value:p,alwaysSet:d.alwaysSet})}return u}).then(u=>Q.mergeObjectSync(s,u)):Q.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,s)=>{let n=this._def.errorMap?.(r,s).message??s.defaultError;return r.code==="unrecognized_keys"?{message:_.errToObj(e).message??n}:{message:n}}}:{}})}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:O.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let s of M.objectKeys(e))e[s]&&this.shape[s]&&(r[s]=this.shape[s]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let s of M.objectKeys(this.shape))e[s]||(r[s]=this.shape[s]);return new t({...this._def,shape:()=>r})}deepPartial(){return kt(this)}partial(e){let r={};for(let s of M.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?r[s]=n:r[s]=n.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let s of M.objectKeys(this.shape))if(e&&!e[s])r[s]=this.shape[s];else{let i=this.shape[s];for(;i instanceof De;)i=i._def.innerType;r[s]=i}return new t({...this._def,shape:()=>r})}keyof(){return Wn(M.objectKeys(this.shape))}};ue.create=(t,e)=>new ue({shape:()=>t,unknownKeys:"strip",catchall:Se.create(),typeName:O.ZodObject,...T(e)});ue.strictCreate=(t,e)=>new ue({shape:()=>t,unknownKeys:"strict",catchall:Se.create(),typeName:O.ZodObject,...T(e)});ue.lazycreate=(t,e)=>new ue({shape:t,unknownKeys:"strip",catchall:Se.create(),typeName:O.ZodObject,...T(e)});var dt=class extends P{_parse(e){let{ctx:r}=this._processInputParams(e),s=this._def.options;function n(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new ce(a.ctx.common.issues));return E(r,{code:y.invalid_union,unionErrors:o}),I}if(r.common.async)return Promise.all(s.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(n);{let i,o=[];for(let c of s){let u={...r,common:{...r.common,issues:[]},parent:null},d=c._parseSync({data:r.data,path:r.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new ce(c));return E(r,{code:y.invalid_union,unionErrors:a}),I}}get options(){return this._def.options}};dt.create=(t,e)=>new dt({options:t,typeName:O.ZodUnion,...T(e)});var Be=t=>t instanceof pt?Be(t.schema):t instanceof we?Be(t.innerType()):t instanceof ht?[t.value]:t instanceof mt?t.options:t instanceof gt?M.objectValues(t.enum):t instanceof Dt?Be(t._def.innerType):t instanceof ut?[void 0]:t instanceof lt?[null]:t instanceof De?[void 0,...Be(t.unwrap())]:t instanceof ke?[null,...Be(t.unwrap())]:t instanceof ir||t instanceof wt?Be(t.unwrap()):t instanceof yt?Be(t._def.innerType):[],_r=class t extends P{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==C.object)return E(r,{code:y.invalid_type,expected:C.object,received:r.parsedType}),I;let s=this.discriminator,n=r.data[s],i=this.optionsMap.get(n);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(E(r,{code:y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),I)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,s){let n=new Map;for(let i of r){let o=Be(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(n.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);n.set(a,i)}}return new t({typeName:O.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...T(s)})}};function Ds(t,e){let r=Ie(t),s=Ie(e);if(t===e)return{valid:!0,data:t};if(r===C.object&&s===C.object){let n=M.objectKeys(e),i=M.objectKeys(t).filter(a=>n.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Ds(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(r===C.array&&s===C.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Ds(o,a);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===C.date&&s===C.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var ft=class extends P{_parse(e){let{status:r,ctx:s}=this._processInputParams(e),n=(i,o)=>{if(Rr(i)||Rr(o))return I;let a=Ds(i.value,o.value);return a.valid?((Sr(i)||Sr(o))&&r.dirty(),{status:r.value,value:a.data}):(E(s,{code:y.invalid_intersection_types}),I)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([i,o])=>n(i,o)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};ft.create=(t,e,r)=>new ft({left:t,right:e,typeName:O.ZodIntersection,...T(r)});var Oe=class t extends P{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==C.array)return E(s,{code:y.invalid_type,expected:C.array,received:s.parsedType}),I;if(s.data.length<this._def.items.length)return E(s,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),I;!this._def.rest&&s.data.length>this._def.items.length&&(E(s,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...s.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new ye(s,o,s.path,a)):null}).filter(o=>!!o);return s.common.async?Promise.all(i).then(o=>Q.mergeArray(r,o)):Q.mergeArray(r,i)}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:O.ZodTuple,rest:null,...T(e)})};var Ar=class t extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==C.object)return E(s,{code:y.invalid_type,expected:C.object,received:s.parsedType}),I;let n=[],i=this._def.keyType,o=this._def.valueType;for(let a in s.data)n.push({key:i._parse(new ye(s,a,s.path,a)),value:o._parse(new ye(s,s.data[a],s.path,a)),alwaysSet:a in s.data});return s.common.async?Q.mergeObjectAsync(r,n):Q.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,s){return r instanceof P?new t({keyType:e,valueType:r,typeName:O.ZodRecord,...T(s)}):new t({keyType:Je.create(),valueType:e,typeName:O.ZodRecord,...T(r)})}},Nt=class extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==C.map)return E(s,{code:y.invalid_type,expected:C.map,received:s.parsedType}),I;let n=this._def.keyType,i=this._def.valueType,o=[...s.data.entries()].map(([a,c],u)=>({key:n._parse(new ye(s,a,s.path,[u,"key"])),value:i._parse(new ye(s,c,s.path,[u,"value"]))}));if(s.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return I;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),a.set(u.value,d.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return I;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),a.set(u.value,d.value)}return{status:r.value,value:a}}}};Nt.create=(t,e,r)=>new Nt({valueType:e,keyType:t,typeName:O.ZodMap,...T(r)});var Lt=class t extends P{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==C.set)return E(s,{code:y.invalid_type,expected:C.set,received:s.parsedType}),I;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(E(s,{code:y.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(E(s,{code:y.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let d of c){if(d.status==="aborted")return I;d.status==="dirty"&&r.dirty(),u.add(d.value)}return{status:r.value,value:u}}let a=[...s.data.values()].map((c,u)=>i._parse(new ye(s,c,s.path,u)));return s.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:_.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:_.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Lt.create=(t,e)=>new Lt({valueType:t,minSize:null,maxSize:null,typeName:O.ZodSet,...T(e)});var $r=class t extends P{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==C.function)return E(r,{code:y.invalid_type,expected:C.function,received:r.parsedType}),I;function s(a,c){return nr({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,It(),je].filter(u=>!!u),issueData:{code:y.invalid_arguments,argumentsError:c}})}function n(a,c){return nr({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,It(),je].filter(u=>!!u),issueData:{code:y.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Ye){let a=this;return ee(async function(...c){let u=new ce([]),d=await a._def.args.parseAsync(c,i).catch(l=>{throw u.addIssue(s(c,l)),u}),h=await Reflect.apply(o,this,d);return await a._def.returns._def.type.parseAsync(h,i).catch(l=>{throw u.addIssue(n(h,l)),u})})}else{let a=this;return ee(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new ce([s(c,u.error)]);let d=Reflect.apply(o,this,u.data),h=a._def.returns.safeParse(d,i);if(!h.success)throw new ce([n(d,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Oe.create(e).rest(We.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,s){return new t({args:e||Oe.create([]).rest(We.create()),returns:r||We.create(),typeName:O.ZodFunction,...T(s)})}},pt=class extends P{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};pt.create=(t,e)=>new pt({getter:t,typeName:O.ZodLazy,...T(e)});var ht=class extends P{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return E(r,{received:r.data,code:y.invalid_literal,expected:this._def.value}),I}return{status:"valid",value:e.data}}get value(){return this._def.value}};ht.create=(t,e)=>new ht({value:t,typeName:O.ZodLiteral,...T(e)});function Wn(t,e){return new mt({values:t,typeName:O.ZodEnum,...T(e)})}var mt=class t extends P{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),s=this._def.values;return E(r,{expected:M.joinValues(s),received:r.parsedType,code:y.invalid_type}),I}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),s=this._def.values;return E(r,{received:r.data,code:y.invalid_enum_value,options:s}),I}return ee(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(s=>!e.includes(s)),{...this._def,...r})}};mt.create=Wn;var gt=class extends P{_parse(e){let r=M.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==C.string&&s.parsedType!==C.number){let n=M.objectValues(r);return E(s,{expected:M.joinValues(n),received:s.parsedType,code:y.invalid_type}),I}if(this._cache||(this._cache=new Set(M.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=M.objectValues(r);return E(s,{received:s.data,code:y.invalid_enum_value,options:n}),I}return ee(e.data)}get enum(){return this._def.values}};gt.create=(t,e)=>new gt({values:t,typeName:O.ZodNativeEnum,...T(e)});var Ye=class extends P{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==C.promise&&r.common.async===!1)return E(r,{code:y.invalid_type,expected:C.promise,received:r.parsedType}),I;let s=r.parsedType===C.promise?r.data:Promise.resolve(r.data);return ee(s.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Ye.create=(t,e)=>new Ye({type:t,typeName:O.ZodPromise,...T(e)});var we=class extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===O.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:s}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:o=>{E(s,o),o.fatal?r.abort():r.dirty()},get path(){return s.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){let o=n.transform(s.data,i);if(s.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return I;let c=await this._def.schema._parseAsync({data:a,path:s.path,parent:s});return c.status==="aborted"?I:c.status==="dirty"?nt(c.value):r.value==="dirty"?nt(c.value):c});{if(r.value==="aborted")return I;let a=this._def.schema._parseSync({data:o,path:s.path,parent:s});return a.status==="aborted"?I:a.status==="dirty"?nt(a.value):r.value==="dirty"?nt(a.value):a}}if(n.type==="refinement"){let o=a=>{let c=n.refinement(a,i);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(s.common.async===!1){let a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?I:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(a=>a.status==="aborted"?I:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(n.type==="transform")if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!He(o))return I;let a=n.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>He(o)?Promise.resolve(n.transform(o.value,i)).then(a=>({status:r.value,value:a})):I);M.assertNever(n)}};we.create=(t,e,r)=>new we({schema:t,typeName:O.ZodEffects,effect:e,...T(r)});we.createWithPreprocess=(t,e,r)=>new we({schema:e,effect:{type:"preprocess",transform:t},typeName:O.ZodEffects,...T(r)});var De=class extends P{_parse(e){return this._getType(e)===C.undefined?ee(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};De.create=(t,e)=>new De({innerType:t,typeName:O.ZodOptional,...T(e)});var ke=class extends P{_parse(e){return this._getType(e)===C.null?ee(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ke.create=(t,e)=>new ke({innerType:t,typeName:O.ZodNullable,...T(e)});var Dt=class extends P{_parse(e){let{ctx:r}=this._processInputParams(e),s=r.data;return r.parsedType===C.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Dt.create=(t,e)=>new Dt({innerType:t,typeName:O.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...T(e)});var yt=class extends P{_parse(e){let{ctx:r}=this._processInputParams(e),s={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Ot(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ce(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ce(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};yt.create=(t,e)=>new yt({innerType:t,typeName:O.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...T(e)});var Mt=class extends P{_parse(e){if(this._getType(e)!==C.nan){let s=this._getOrReturnCtx(e);return E(s,{code:y.invalid_type,expected:C.nan,received:s.parsedType}),I}return{status:"valid",value:e.data}}};Mt.create=t=>new Mt({typeName:O.ZodNaN,...T(t)});var al=Symbol("zod_brand"),ir=class extends P{_parse(e){let{ctx:r}=this._processInputParams(e),s=r.data;return this._def.type._parse({data:s,path:r.path,parent:r})}unwrap(){return this._def.type}},or=class t extends P{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?I:i.status==="dirty"?(r.dirty(),nt(i.value)):this._def.out._parseAsync({data:i.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?I:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,r){return new t({in:e,out:r,typeName:O.ZodPipeline})}},wt=class extends P{_parse(e){let r=this._def.innerType._parse(e),s=n=>(He(n)&&(n.value=Object.freeze(n.value)),n);return Ot(r)?r.then(n=>s(n)):s(r)}unwrap(){return this._def.innerType}};wt.create=(t,e)=>new wt({innerType:t,typeName:O.ZodReadonly,...T(e)});function Ln(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function qn(t,e={},r){return t?Ze.create().superRefine((s,n)=>{let i=t(s);if(i instanceof Promise)return i.then(o=>{if(!o){let a=Ln(e,s),c=a.fatal??r??!0;n.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=Ln(e,s),a=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:a})}}):Ze.create()}var cl={object:ue.lazycreate},O;(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"})(O||(O={}));var ul=(t,e={message:`Input not instance of ${t.name}`})=>qn(r=>r instanceof t,e),Un=Je.create,zn=it.create,ll=Mt.create,dl=ot.create,Vn=at.create,fl=ct.create,pl=Tt.create,hl=ut.create,ml=lt.create,gl=Ze.create,Dl=We.create,yl=Se.create,wl=Pt.create,El=qe.create,xl=ue.create,vl=ue.strictCreate,Cl=dt.create,bl=_r.create,Fl=ft.create,Rl=Oe.create,Sl=Ar.create,_l=Nt.create,Al=Lt.create,$l=$r.create,Il=pt.create,Ol=ht.create,kl=mt.create,Tl=gt.create,Pl=Ye.create,Nl=we.create,Ll=De.create,Ml=ke.create,jl=we.createWithPreprocess,Bl=or.create,Wl=()=>Un().optional(),ql=()=>zn().optional(),Ul=()=>Vn().optional(),zl={string:(t=>Je.create({...t,coerce:!0})),number:(t=>it.create({...t,coerce:!0})),boolean:(t=>at.create({...t,coerce:!0})),bigint:(t=>ot.create({...t,coerce:!0})),date:(t=>ct.create({...t,coerce:!0}))};var Vl=I;import{promises as Yl}from"node:fs";import{join as Xl,isAbsolute as Kl,normalize as Ql}from"node:path";var Ir=f.object({name:f.string().regex(/^[a-z0-9-]+$/,"Name must be lowercase alphanumeric with hyphens"),version:f.string().regex(/^\d+\.\d+\.\d+$/,"Version must be semver compliant (x.y.z)"),type:f.enum(["spec","power"]).default("spec"),description:f.string().optional(),deps:f.record(f.string().regex(/^[a-z0-9-]+$/,"Dependency name must be lowercase alphanumeric with hyphens"),f.string().regex(/^\d+\.\d+\.\d+$/,"Dependency version must be exact semver")).default({}),files:f.array(f.string()).min(1,"Files array cannot be empty"),hash:f.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>").optional(),agent:f.object({purpose:f.string(),tags:f.array(f.string()).optional()}).optional()});var Gl=f.string().regex(/^[a-z0-9-]+@\d+\.\d+\.\d+$/,"Key must be name@version"),Hl=f.string().refine(t=>t.length===0?!1:(t.startsWith("file:")||t.startsWith("/")||/^[a-zA-Z]:\\/.test(t)||t.startsWith("./")||t.startsWith("../"),!0),"Source must be a non-empty file URL or local path"),Jl=f.object({source:Hl,hash:f.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>")}),Gn=f.record(Gl,Jl);var Zl=f.object({name:f.string().regex(/^[a-z0-9-]+$/,"Name must be lowercase alphanumeric with hyphens"),version:f.string().regex(/^\d+\.\d+\.\d+$/,"Version must be semver compliant (x.y.z)"),hash:f.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>"),source:f.string().url("Source must be a valid URL"),deps:f.array(f.string().regex(/^[a-z0-9-]+@\d+\.\d+\.\d+$/,"Dependency must be in format name@version"))}),Dy=f.object({createdAt:f.string().datetime("createdAt must be ISO-8601 format"),entries:f.array(Zl)});function Or(t){try{return Ir.parse(t)}catch(e){if(e instanceof f.ZodError){let r=e.errors.map(s=>`${s.path.length>0?`${s.path.join(".")}: `:""}${s.message}`);throw new Error(`Manifest validation failed:
|
|
12
|
+
${r.join(`
|
|
13
|
+
`)}`)}throw e}}function kr(t){let e=new Set;for(let r of t){if(r.includes(".."))throw new Error(`Path traversal not allowed: ${r}`);if(Kl(r)||/^[A-Za-z]:\\/.test(r))throw new Error(`Absolute paths not allowed: ${r}`);let s=Ql(r).replace(/\\/g,"/");if(e.has(s))throw new Error(`Duplicate file path: ${r}`);e.add(s)}}async function Hn(t,e){let r=[];for(let s of t){let n=Xl(e,s);try{await Yl.access(n)}catch{r.push(s)}}if(r.length>0)throw new Error(`Files not found: ${r.join(", ")}`)}function ed(t){if(t.includes(".."))throw new Error(`Path traversal not allowed: ${t}`);return t.replace(/\\/g,"/")}function Et(t,e){let r=Ke.resolve(t).replace(/\\/g,"/"),s=Ke.resolve(e).replace(/\\/g,"/");if(!r.startsWith(s))throw new Error(`Path escapes registry boundaries: ${t}`)}var Qe=class{paths;rootPath;constructor(e="~/.spectrl/registry"){this.rootPath=ed(e),this.paths={root:this.rootPath,spec:(r,s)=>`${this.rootPath}/${r}/${s}`.replace(/\\/g,"/"),files:(r,s)=>`${this.rootPath}/${r}/${s}/files`.replace(/\\/g,"/"),manifest:(r,s)=>`${this.rootPath}/${r}/${s}/spectrl.json`.replace(/\\/g,"/")}}async exists(e,r){let s=this.paths.spec(e,r);Et(s,this.rootPath);try{return(await Xe.stat(s)).isDirectory()}catch(n){if(n.code==="ENOENT")return!1;throw n}}async getManifest(e,r){let s=this.paths.manifest(e,r);Et(s,this.rootPath);try{let n=await Xe.readFile(s,"utf-8"),i=JSON.parse(n);return Or(i)}catch(n){throw n.code==="ENOENT"?new Error(`Manifest not found: ${e}@${r}`):n}}async list(){let e=[];try{await Xe.access(this.rootPath)}catch{return e}let r=await Xe.readdir(this.rootPath,{withFileTypes:!0});for(let s of r){if(!s.isDirectory())continue;let n=s.name,i=Ke.join(this.rootPath,n);try{let o=await Xe.readdir(i,{withFileTypes:!0});for(let a of o)a.isDirectory()&&e.push({name:n,version:a.name})}catch{}}return e}async listVersions(e){let r=Ke.join(this.rootPath,e);try{return(await Xe.readdir(r,{withFileTypes:!0})).filter(i=>i.isDirectory()).map(i=>i.name).filter(i=>/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(i))}catch(s){if(s.code==="ENOENT")return[];throw s}}async remove(e,r){if(!await this.exists(e,r))throw new Error(`Spec ${e}@${r} not found in registry`);let s=this.paths.spec(e,r);Et(s,this.rootPath),await ar.remove(s);let n=Ke.join(this.rootPath,e);(await Xe.readdir(n)).length===0&&await ar.remove(n)}async publish(e,r){if(kr(e.files),await this.exists(e.name,e.version))throw new Error(`Spec ${e.name}@${e.version} already exists in registry. Bump version to publish changes.`);let s=this.paths.spec(e.name,e.version),n=this.paths.files(e.name,e.version);Et(s,this.rootPath),Et(n,this.rootPath),await ar.ensureDir(n);for(let a of e.files){let c=Ke.join(r,a),u=Ke.join(n,a);Et(u,this.rootPath),await ar.ensureDir(Ke.dirname(u)),await ar.copy(c,u,{overwrite:!0,errorOnExist:!1,preserveTimestamps:!1})}let i=this.paths.manifest(e.name,e.version);Et(i,this.rootPath);let o=`${JSON.stringify(e,null,2)}
|
|
14
|
+
`;await Xe.writeFile(i,o,"utf-8")}};import{promises as ws}from"node:fs";import cr from"node:path";var Tr=Symbol("singleComment"),Jn=Symbol("multiComment");function td(){return""}function rd(t,e,r){return t.slice(e,r).replace(/[^ \t\r\n]/g," ")}function sd(t,e){let r=e-1,s=0;for(;t[r]==="\\";)r-=1,s+=1;return!!(s%2)}var nd={trailingCommas:!1,whitespace:!0};function ys(t,e=nd){if(typeof t!="string")throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof t}\``);let{trailingCommas:r=!1,whitespace:s=!0}=e,n=s?rd:td,i=!1,o=!1,a=0,c="",u="",d=-1;for(let p=0;p<t.length;p++){let l=t[p],g=t[p+1];if(l&&(!o&&l==='"'&&(sd(t,p)||(i=!i)),!i))if(!o&&l+g==="//")c+=t.slice(a,p),a=p,o=Tr,p++;else if(o===Tr&&l+g===`\r
|
|
15
|
+
`){p++,o=!1,c+=n(t,a,p),a=p;continue}else if(o===Tr&&l===`
|
|
16
|
+
`)o=!1,c+=n(t,a,p),a=p;else if(!o&&l+g==="/*"){c+=t.slice(a,p),a=p,o=Jn,p++;continue}else if(o===Jn&&l+g==="*/"){p++,o=!1,c+=n(t,a,p+1),a=p+1;continue}else r&&!o&&(d!==-1?l==="}"||l==="]"?(c+=t.slice(a,p),u+=n(c,0,1)+c.slice(1),c="",a=p,d=-1):l!==" "&&l!==" "&&l!=="\r"&&l!==`
|
|
17
|
+
`&&(c+=t.slice(a,p),a=p,d=-1):l===","&&(u+=c+t.slice(a,p),c="",a=p,d=p))}let h=o===Tr?n(t,a):t.slice(a);return u+c+h}function Zn(t,e){try{return JSON.parse(t)}catch{return JSON.parse(ys(t,{...e,trailingCommas:!0}))}}function xt(t){try{return Zn(t)}catch(e){throw new Error(`JSONC parse error: ${e instanceof Error?e.message:String(e)}`)}}var pe=class extends Error{exitCode;constructor(e,r){super(e),this.exitCode=r,this.name="ResolverError"}},Pr=class{async loadIndex(e){try{let r=await ws.readFile(e,"utf-8"),s=JSON.parse(r);return Gn.parse(s)}catch(r){throw this.isFileNotFoundError(r)?new pe(`Index file not found: ${e}`,1):r}}isFileNotFoundError(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}async readManifestFromSource(e,r){let s;if(e.startsWith("file://")?s=e.slice(7):e.startsWith("file:")?s=e.slice(5):s=e,!cr.isAbsolute(s)){let n=r||process.cwd();s=cr.resolve(n,s)}try{let n;try{n=await ws.readFile(cr.join(s,"spectrl.jsonc"),"utf-8")}catch{n=await ws.readFile(cr.join(s,"spectrl.json"),"utf-8")}let i=xt(n);return Ir.parse(i)}catch(n){throw this.isFileNotFoundError(n)?new pe(`Missing source for ${e}`,1):new pe(`Failed to read manifest from source: ${e}`,1)}}async resolveClosureFromIndex(e){let r=await this.loadIndex(e),s=Object.keys(r).sort(),n=/^([a-z0-9-]+)@(\d+\.\d+\.\d+)$/,i=new Map;for(let l of s){let g=l.match(n);if(!g)throw new pe(`Invalid index key: ${l}`,1);let[,w,x]=g;i.set(l,{name:w,version:x})}let o=new Map,a=cr.dirname(e);for(let l of s){let g=i.get(l);if(!g)throw new pe(`Internal error: missing parsed key ${l}`,1);let{name:w,version:x}=g,A=r[l];if(!A||!A.source)throw new pe(`Missing source for ${l}`,1);let $=await this.readManifestFromSource(A.source,a);if($.name!==w||$.version!==x)throw new pe(`Manifest mismatch for ${l}: found ${$.name}@${$.version}`,1);o.set(l,{manifest:$,source:A.source})}let c=new Map;for(let[l,{manifest:g}]of o){let w=Object.entries(g.deps).map(([x,A])=>`${x}@${A}`).sort();for(let x of w)if(!r[x])throw new pe(`Missing dependency: ${x}. Add it to .spectrl/spectrl-index.json`,3);c.set(l,w)}let u=(l,g,w)=>{g.add(l),w.add(l);let x=c.get(l)||[];for(let A of x)if(g.has(A)){if(w.has(A))throw new pe(`Cyclic dependency detected: ${l} \u2192 ${A}`,3)}else if(u(A,g,w))return!0;return w.delete(l),!1},d=new Set;for(let l of s)d.has(l)||u(l,d,new Set);let h=[];for(let[l,{manifest:g,source:w}]of o){let x=Object.entries(g.deps).map(([A,$])=>`${A}@${$}`).sort();h.push({name:g.name,version:g.version,source:w,deps:x})}let p=h.map(l=>({node:l,key:`${l.name}@${l.version}`}));return p.sort((l,g)=>l.key.localeCompare(g.key)),p.map(l=>l.node)}};import{createHash as id}from"node:crypto";function Nr(t){let{manifest:e,fileContents:r}=t,s=id("sha256"),n=ad(e);s.update(n,"utf8");let i=Object.keys(r).sort();for(let o of i){let a=r[o];s.update(o,"utf8");let c=od(a);s.update(c,"utf8")}return`sha256:${s.digest("hex")}`}function od(t){return t.replace(/\r\n/g,`
|
|
6
18
|
`).replace(/\r/g,`
|
|
7
|
-
`)}function
|
|
19
|
+
`)}function ad(t){let{hash:e,...r}=t;return Es(r)}function Es(t){return t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(Es).join(",")}]`:`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${Es(t[r])}`).join(",")}}`}var jo=_t(Bs(),1);function Bo(t,e){return jo.default.compare(t,e)}import{promises as Wo}from"node:fs";import{join as nh}from"node:path";var ih="spectrl.jsonc",oh="spectrl.json",ah=[ih,oh];async function qo(t){for(let e of ah){let r=nh(t,e);try{return await Wo.access(r),r}catch{}}throw new Error(`No manifest found in ${t} (looked for spectrl.jsonc, spectrl.json)`)}async function Uo(t){let e=await qo(t),r=await Wo.readFile(e,"utf-8");return xt(r)}async function Ue(t){try{return await ch(t,uh.F_OK),!0}catch{return!1}}async function Vo(t,e){if(await Ue(t))throw new m(`File already exists: ${t}`,D.VALIDATION_ERROR)}function le(t){return Bt(t,".spectrl","spectrl-index.json")}function Ws(t){return Bt(t,".spectrl")}function Wt(){return Bt(lh(),".spectrl","registry")}function qt(t,e,r){return`${t}/${e}@${r}`}function Zr(t,e,r){return`${t}-${e}@${r}`}function Yr(t,e,r,s){return Bt(t,".spectrl","specs",Zr(e,r,s))}function Go(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"}function gr(t){return t instanceof Error}async function Ho(t){let e;try{e=await Uo(t)}catch(r){if(r instanceof m)throw r;let s=gr(r)?r.message:"Unknown error";throw s.includes("No manifest found")?new m(s,D.IO_ERROR):s.startsWith("JSONC parse error")?new m(`Invalid JSON in manifest: ${s}`,D.VALIDATION_ERROR):new m(`Failed to read manifest: ${s}`,D.IO_ERROR)}try{return Or(e)}catch(r){let s=gr(r)?r.message:"Unknown validation error";throw new m(s,D.VALIDATION_ERROR)}}function Jo(t){try{kr(t)}catch(e){let r=gr(e)?e.message:"Invalid file paths";throw new m(r,D.VALIDATION_ERROR)}}async function Zo(t,e){try{await Hn(t,e)}catch(r){let s=gr(r)?r.message:"Files not found";throw new m(s,D.IO_ERROR)}}async function qs(t,e=!0,r){try{let s=r?.yesLabel||"Yes",n=r?.noLabel||"No";return await dh({message:t,choices:[{name:s,value:!0},{name:n,value:!1}],default:e})}catch{return}}var v={log(t){console.log(t)},error(t){console.error(t)}},fh=`
|
|
8
20
|
# Spectrl local registry
|
|
9
21
|
# Track index and lock files, but ignore downloaded specs (like node_modules)
|
|
10
22
|
.spectrl/specs/
|
|
11
|
-
`;async function
|
|
23
|
+
`;async function ph(t){let e=Bt(t,".gitignore");try{return(await zo(e,"utf-8")).includes(".spectrl/")}catch(r){return Go(r)&&r.code==="ENOENT",!1}}async function Us(t){let e=Bt(t,".gitignore");if(await ph(t))return!1;try{let r="";try{r=await zo(e,"utf-8")}catch(i){if(!Go(i)||i.code!=="ENOENT")throw i}let s=r;r.length>0&&!r.endsWith(`
|
|
12
24
|
`)&&(s+=`
|
|
13
|
-
`),s+=
|
|
25
|
+
`),s+=fh;let{writeFile:n}=await import("node:fs/promises");return await n(e,s,"utf-8"),!0}catch(r){let s=gr(r)?r.message:"Failed to update .gitignore";throw new m(`Failed to configure .gitignore: ${s}`,D.IO_ERROR)}}import{readFile as Qo,writeFile as ea}from"node:fs/promises";import{join as zs}from"node:path";var Xr="<!-- Added by Spectrl -->",Yo=`# AI Assistant Instructions for Spectrl
|
|
14
26
|
|
|
15
27
|
## What is Spectrl?
|
|
16
28
|
|
|
17
|
-
Spectrl is a knowledge registry
|
|
29
|
+
Spectrl is a knowledge registry storing two types of authoritative content:
|
|
18
30
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
1. **Specs are the primary source of truth** - Always check \`.spectrl/specs/\` first
|
|
22
|
-
2. **Never assume** - When ambiguous, ask questions rather than guessing
|
|
23
|
-
3. **Human decides** - When in doubt or low confidence, ask for clarification
|
|
24
|
-
4. **Be thorough but efficient** - Read what's needed, not everything blindly
|
|
25
|
-
|
|
26
|
-
## Primary Source of Truth
|
|
27
|
-
|
|
28
|
-
ALWAYS consult specs in \`.spectrl/specs/\` before answering questions about:
|
|
29
|
-
|
|
30
|
-
- API design and conventions
|
|
31
|
-
- Security requirements and policies
|
|
32
|
-
- Architecture patterns and decisions
|
|
33
|
-
- Testing standards and best practices
|
|
34
|
-
- Code style and formatting rules
|
|
35
|
-
- Project-specific workflows and processes
|
|
36
|
-
|
|
37
|
-
## Installed Specs
|
|
38
|
-
|
|
39
|
-
Check \`.spectrl/specs/\` directory for all installed specifications.
|
|
40
|
-
Each subdirectory is named \`{name}@{version}\` and contains the spec files. You can also read \`.spectrl/spectrl-index.json\` to see the complete list with source locations and integrity hashes.
|
|
41
|
-
|
|
42
|
-
## How to Use Specs
|
|
43
|
-
|
|
44
|
-
### 1. Before Answering
|
|
45
|
-
|
|
46
|
-
- Check if a relevant spec exists in \`.spectrl/specs/\`
|
|
47
|
-
- **If unsure whether a spec is relevant**: Ask the user rather than guessing
|
|
48
|
-
- Example: "I see we have specs for api-design and security. Should I check both for authentication guidance, or is one more applicable here?"
|
|
49
|
-
|
|
50
|
-
### 2. Reading Multi-File Specs
|
|
51
|
-
|
|
52
|
-
- Check for entry point files first: \`README.md\`, \`INDEX.md\`, or \`SPEC.md\`
|
|
53
|
-
- Use entry point to guide which files to read for your specific question
|
|
54
|
-
- If no entry point exists or question is broad, read all spec files
|
|
55
|
-
- For specs with 20+ files and narrow questions: Scan filenames and initial sections to identify relevant parts
|
|
56
|
-
- **If uncertain about coverage**: "I've checked [files X, Y, Z] in [spec:name@version]. Should I read the complete spec or is this sufficient?"
|
|
57
|
-
- Once you've read a spec in a conversation, you don't need to re-read it unless told it's changed
|
|
58
|
-
|
|
59
|
-
### 3. If Relevant Spec Exists
|
|
60
|
-
|
|
61
|
-
- Read the spec files (following the multi-file guidance above)
|
|
62
|
-
- Apply the specific patterns and requirements from the spec
|
|
63
|
-
- Cite the spec when referencing requirements: \`[spec:name@version]\`
|
|
64
|
-
- Prefer spec guidance over general best practices when they conflict
|
|
65
|
-
|
|
66
|
-
### 4. Following Spec Dependencies
|
|
67
|
-
|
|
68
|
-
- If a spec references another spec (e.g., "see api-design@1.0 for auth patterns"), follow the reference
|
|
69
|
-
- Continue following dependency chains up to 5 levels deep
|
|
70
|
-
- **If chain exceeds 5 levels or loops back**: "I've followed specs [A\u2192B\u2192C\u2192D\u2192E], but the chain continues or loops. Should I keep following or is this enough context?"
|
|
71
|
-
- **If referenced spec doesn't exist**: "The [spec:security@2.0] references [spec:api-design@1.0], but I only found [spec:api-design@2.0]. Should I use the available version or wait for clarification?"
|
|
72
|
-
|
|
73
|
-
### 5. If No Relevant Spec Exists OR Spec Doesn't Cover the Topic
|
|
74
|
-
|
|
75
|
-
- Use your general knowledge and best practices
|
|
76
|
-
- Mention that no spec was found: "Note: No spec found for [topic], using general best practices"
|
|
77
|
-
- Suggest creating a spec if this seems like a recurring pattern
|
|
78
|
-
|
|
79
|
-
### 6. If Specs Conflict with User Request
|
|
31
|
+
- **Specs** \u2014 Static context documents (PRDs, TDDs, ADRs, architecture decisions). Read before answering questions or generating code.
|
|
32
|
+
- **Powers** \u2014 Behavioral instructions (workflows, patterns, checklists). Follow when performing tasks.
|
|
80
33
|
|
|
81
|
-
|
|
82
|
-
- **Ask for clarification**: "Would you like me to proceed with your suggested approach or follow the spec?"
|
|
83
|
-
- Never assume the user wants to override the spec - always ask
|
|
84
|
-
- If user chooses to deviate, document it clearly in code comments
|
|
34
|
+
Both are versioned, installable, and agent-readable.
|
|
85
35
|
|
|
86
|
-
|
|
36
|
+
## Core Principles
|
|
87
37
|
|
|
88
|
-
**
|
|
38
|
+
1. **Catalog first** \u2014 Always start with \`.spectrl/catalog.md\`
|
|
39
|
+
2. **Lazy-load** \u2014 Only read content relevant to the current task
|
|
40
|
+
3. **Never assume** \u2014 When ambiguous, ask
|
|
41
|
+
4. **Human decides** \u2014 You assist; the user has final say
|
|
42
|
+
5. **Be thorough but efficient** \u2014 Read what's needed, not everything
|
|
89
43
|
|
|
90
|
-
|
|
91
|
-
- Request directly matches a documented pattern in the spec
|
|
92
|
-
- Spec terminology matches user's question exactly
|
|
93
|
-
- The application is straightforward with no judgment calls needed
|
|
44
|
+
## Discovering Installed Content
|
|
94
45
|
|
|
95
|
-
|
|
46
|
+
Read \`.spectrl/catalog.md\` first \u2014 it lists all installed specs and powers with names, versions, types, descriptions, and "when to use" guidance:
|
|
96
47
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
|
|
48
|
+
\`\`\`
|
|
49
|
+
| Name | Version | Type | Description | When to Use |
|
|
50
|
+
| ----------- | ------- | ----- | ---------------------- | -------------------------------- |
|
|
51
|
+
| api-design | 1.0.0 | spec | API design conventions | Consult when designing REST APIs |
|
|
52
|
+
| code-review | 2.0.0 | power | Code review checklist | Follow during code reviews |
|
|
53
|
+
\`\`\`
|
|
103
54
|
|
|
104
|
-
|
|
55
|
+
Load relevant items from \`.spectrl/specs/{name}@{version}/\`. If \`catalog.md\` is missing, fall back to \`.spectrl/spectrl-index.json\`.
|
|
105
56
|
|
|
106
|
-
|
|
107
|
-
- Applying spec could have significant side effects
|
|
108
|
-
- User's context differs from spec's assumptions
|
|
109
|
-
- You need to make assumptions to bridge gaps in the spec
|
|
57
|
+
## Using Specs and Powers
|
|
110
58
|
|
|
111
|
-
|
|
59
|
+
**Before acting:** Read the catalog \u2192 identify relevant items \u2192 load them \u2192 apply specs as context, follow powers as instructions.
|
|
112
60
|
|
|
113
|
-
|
|
114
|
-
- Example: If user clarifies that "auth" means "OAuth2" in their context, apply that understanding to future questions in the same conversation
|
|
115
|
-
- Don't ask the same question twice in one conversation
|
|
61
|
+
**Specs (context):** Read before answering questions about APIs, security, architecture, testing, code style, or project workflows. Cite as \`[spec:name@version]\`. Prefer spec guidance over general best practices.
|
|
116
62
|
|
|
117
|
-
|
|
63
|
+
**Powers (instructions):** Follow step-by-step when performing code reviews, refactoring, deployments, testing, etc. Cite as \`[power:name@version]\`.
|
|
118
64
|
|
|
119
|
-
|
|
65
|
+
**Reading files:** Check for \`README.md\`, \`INDEX.md\`, or \`index.md\` as entry points first. For items with 20+ files and a narrow question, scan filenames before reading everything. Don't re-read items already loaded in the conversation.
|
|
120
66
|
|
|
121
|
-
|
|
122
|
-
- Example: "Both [spec:api-design@1.0] and [spec:security@2.0] cover authentication. Which should I prioritize if they differ?"
|
|
67
|
+
**Dependencies:** Follow spec/power references up to 5 levels deep. If the chain exceeds 5 levels or loops: state what you've followed and ask whether to continue.
|
|
123
68
|
|
|
124
|
-
|
|
69
|
+
**No relevant content found:** Use general best practices, note that no installed content applied, and suggest creating a spec or power if it's a recurring need.
|
|
125
70
|
|
|
126
|
-
|
|
127
|
-
- If version not specified, use the latest version in \`.spectrl/specs/\`
|
|
128
|
-
- **If uncertain about version choice**: Ask
|
|
129
|
-
- Example: "I see api-design@1.0 and api-design@2.0. The code references @1.0 but @2.0 is newer. Which should I use?"
|
|
71
|
+
## When to Infer vs. Ask
|
|
130
72
|
|
|
131
|
-
|
|
73
|
+
**Infer when:** Content explicitly covers the topic with clear examples and no judgment calls are needed.
|
|
132
74
|
|
|
133
|
-
|
|
134
|
-
- **Ask before filling gaps**: "The [spec:security@1.0] covers authentication but not rate limiting. Should I use general best practices for rate limiting, or is there another spec I should check?"
|
|
135
|
-
- When proceeding with mixed sources, cite both clearly
|
|
75
|
+
**Ask when:** Language is ambiguous ("should", "consider", "typically"), multiple valid interpretations exist, stakes are high (security, data integrity, public APIs), or you're extrapolating rather than applying explicit rules.
|
|
136
76
|
|
|
137
|
-
|
|
77
|
+
**Always ask when:** Content is silent on the specific point, applying it could have significant side effects, or you need assumptions to bridge gaps.
|
|
138
78
|
|
|
139
|
-
|
|
140
|
-
- Note if it seems outdated: "Note: [spec:frontend@1.0] references React 16 patterns. The current version is React 18. Should I follow the spec as written or suggest updating it?"
|
|
79
|
+
Once a clarification is made, remember it \u2014 don't ask the same question twice.
|
|
141
80
|
|
|
142
|
-
|
|
81
|
+
## Conflict Resolution
|
|
143
82
|
|
|
144
|
-
|
|
145
|
-
|
|
83
|
+
| Situation | Action |
|
|
84
|
+
|---|---|
|
|
85
|
+
| Multiple items cover same topic | Ask which takes precedence |
|
|
86
|
+
| Version unspecified | Use catalog version; ask if uncertain |
|
|
87
|
+
| Partial coverage | Apply what exists; ask before filling gaps with general knowledge |
|
|
88
|
+
| Outdated content | Follow as written; flag the concern |
|
|
89
|
+
| Self-contradictory content | Cite both sections and ask; never choose silently |
|
|
90
|
+
| User request conflicts with content | State the requirement, ask whether to follow installed content or user's approach |
|
|
146
91
|
|
|
147
92
|
## Error Handling
|
|
148
93
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
-
|
|
152
|
-
- Continue with best practices
|
|
153
|
-
- Suggest fixing spec access if this seems unexpected
|
|
154
|
-
|
|
155
|
-
### If Spec Files are Malformed or Unreadable
|
|
156
|
-
|
|
157
|
-
- Report the specific issue: "Found [spec:X@Y] but unable to read [file]. Should I proceed with available information or wait for spec access?"
|
|
158
|
-
- Don't assume content - ask for help
|
|
159
|
-
|
|
160
|
-
### If Specs Contain Errors
|
|
161
|
-
|
|
162
|
-
- If you encounter clear errors in a spec (broken links, typos, outdated examples), flag them: "Note: Found a potential issue in [spec:X@Y] at [location]. Should I follow as written or would you like to correct this?"
|
|
163
|
-
- Never silently "correct" a spec - follow it as written and flag the concern
|
|
164
|
-
|
|
165
|
-
## Spec Locations
|
|
166
|
-
|
|
167
|
-
All specs are symlinked in \`.spectrl/specs/{name}@{version}/\`
|
|
168
|
-
These are the authoritative source of truth for this project. Read them before providing guidance on topics they cover.
|
|
169
|
-
|
|
170
|
-
## Example Workflows
|
|
171
|
-
|
|
172
|
-
### When Asked About Design, Standards, or Conventions
|
|
173
|
-
|
|
174
|
-
1. Check \`.spectrl/specs/\` to identify relevant specs
|
|
175
|
-
2. **If multiple specs might apply**: Ask which is most relevant
|
|
176
|
-
3. Read the applicable spec files (following multi-file guidance)
|
|
177
|
-
4. Follow any dependencies in the spec (up to 5 levels)
|
|
178
|
-
5. Apply those specific patterns and conventions
|
|
179
|
-
6. Cite using format: \`[spec:{name}@{version}]\`
|
|
180
|
-
|
|
181
|
-
### When Reviewing Code
|
|
182
|
-
|
|
183
|
-
1. Identify which specs apply to the code being reviewed
|
|
184
|
-
2. Check for violations of requirements in those specs
|
|
185
|
-
3. Point out specific requirements from specs with citations
|
|
186
|
-
4. Suggest fixes that align with spec guidance
|
|
187
|
-
5. **If interpretation is unclear**: Ask before flagging as violation
|
|
188
|
-
6. **For legacy code violations**: "This code doesn't match [spec:X@Y]. Should I suggest bringing it into compliance, or is the spec newer than this code?"
|
|
189
|
-
|
|
190
|
-
### When Generating Code
|
|
191
|
-
|
|
192
|
-
1. Check \`.spectrl/specs/\` for relevant standards before writing
|
|
193
|
-
2. **If unsure which specs apply**: List candidates and ask
|
|
194
|
-
3. Follow patterns and conventions from applicable specs
|
|
195
|
-
4. Use examples from specs when available
|
|
196
|
-
5. Cite the spec you followed
|
|
197
|
-
6. **If spec conflicts with modern best practices**: Ask which to prioritize
|
|
198
|
-
|
|
199
|
-
### For New Projects
|
|
200
|
-
|
|
201
|
-
- If \`.spectrl/specs/\` is empty for a new project, note this and ask: "No specs found. Would you like me to proceed with general best practices, or should we create initial specs first?"
|
|
202
|
-
|
|
203
|
-
### In Time-Critical Situations
|
|
204
|
-
|
|
205
|
-
- State: "I can check specs for the proper approach, or provide a quick solution if time is critical. Which would you prefer?"
|
|
206
|
-
- If user requests speed, proceed with best practices and note what specs weren't consulted
|
|
94
|
+
- **\`catalog.md\` missing** \u2014 Fall back to \`spectrl-index.json\`; inform the user to run \`spectrl install\`
|
|
95
|
+
- **Unreadable files** \u2014 Report the issue and ask whether to proceed with available info
|
|
96
|
+
- **Errors in content** \u2014 Flag them; follow as written unless instructed otherwise; never silently "correct"
|
|
207
97
|
|
|
208
98
|
## Key Reminders
|
|
209
99
|
|
|
210
|
-
- **
|
|
211
|
-
- **Never
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
- **Cite sources** - Always attribute to specs or note when using general knowledge
|
|
215
|
-
- **Be efficient** - Read what's needed, not everything. Use entry points and intelligent scanning
|
|
216
|
-
- **Follow the chain** - Pursue spec dependencies to get complete context
|
|
217
|
-
- **Remember context** - Don't ask the same question twice in a conversation
|
|
218
|
-
- **Flag but follow** - If specs seem wrong or outdated, flag the concern but follow them anyway unless instructed otherwise
|
|
219
|
-
`;function zn(){return`${zt}
|
|
220
|
-
${Un}`}function Gn(){return`
|
|
100
|
+
- **Catalog first** \xB7 **Lazy-load** \xB7 **Specs = context** \xB7 **Powers = instructions**
|
|
101
|
+
- **Never guess** \xB7 **Human decides** \xB7 **Cite sources** \xB7 **Remember context** \xB7 **Flag but follow**
|
|
102
|
+
`;function Xo(){return`${Xr}
|
|
103
|
+
${Yo}`}function Ko(){return`
|
|
221
104
|
|
|
222
105
|
---
|
|
223
106
|
|
|
224
|
-
${
|
|
225
|
-
${
|
|
226
|
-
`;await
|
|
227
|
-
|
|
228
|
-
Note: "spectrl new" and "spectrl publish" work without initialization.`,w.VALIDATION_ERROR);let a=Ql(r);if(!a)throw new v(`Invalid spec reference format: ${r}. Use format: name or name@version`,w.VALIDATION_ERROR);let{name:o,version:c}=a,l=new Me(n??mt());c||(t.text=`Resolving ${N(o)}...`,c=await eu(o,l),t.text=`Resolved ${N(o)} to version ${N(c)}`);let u=`${o}@${c}`;if(t.text=`Looking up ${N(u)} in registry`,!await l.exists(o,c))throw new v(`Spec ${N(u)} not found in registry`,w.DEPENDENCY_ERROR);t.text=`Reading manifest for ${N(u)}`;let $=await l.getManifest(o,c);if(!$.hash)throw new v(`Manifest for ${u} is missing hash`,w.VALIDATION_ERROR);let f=l.paths.files(o,c),A=q(s,".spectrl","specs",u);t.text=`Checking ${N(u)}`;let C=await Kn(A,f);if(C.exists&&C.isSymlink&&C.isCorrect){t.succeed(`${N(u)} already installed at ${N(`.spectrl/specs/${u}`)}`),t.text="Updating project index";let M=q(s,".spectrl","spectrl-index.json"),xt={};try{let te=await le.readFile(M,"utf-8");xt=JSON.parse(te)}catch(te){if(te.code!=="ENOENT")throw te}let Ht=l.paths.spec(o,c);xt[u]={source:Ht,hash:$.hash};let vt=JSON.stringify(xt,null,2);await le.writeFile(M,`${vt}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
107
|
+
${Xr}
|
|
108
|
+
${Yo}`}async function Vs(t){let e=zs(t,"AGENTS.md");if(!await Ue(e))return{exists:!1};try{return{exists:!0,hasMarker:(await Qo(e,"utf-8")).includes(Xr)}}catch{return{exists:!1}}}async function Gs(t){let e=zs(t,"AGENTS.md"),r=Xo();try{await ea(e,r,"utf-8")}catch(s){let n=s instanceof Error?s.message:"Unknown error";throw new m(`Failed to create AGENTS.md: ${n}`,D.IO_ERROR)}}async function Hs(t){let e=zs(t,"AGENTS.md");try{let r=await Qo(e,"utf-8");r=r.trimEnd();let s=r+Ko();await ea(e,s,"utf-8")}catch(r){let s=r instanceof Error?r.message:"Unknown error";throw new m(`Failed to append to AGENTS.md: ${s}`,D.IO_ERROR)}}async function Kr(t,e={}){let r=le(t);if(await Ue(r))return{wasInitialized:!1};let s=Ws(t),n=e.spinner??na({spinner:"line"}),i=!e.spinner;i?n.start("Initializing project"):n.text="Initializing spectrl in this project";try{await ra(s,{recursive:!0});let a=`${JSON.stringify({},null,2)}
|
|
109
|
+
`;await ta(r,a,"utf-8");let c=e.skipAgents??!process.stdin.isTTY;await oa(t,{skipAgents:c},n),n.text="Configuring .gitignore",await Us(t);let u="Initialized spectrl in this project";return i?n.succeed(u):v.log(K(`\u2713 ${u}`)),{wasInitialized:!0}}catch(o){if(o instanceof m&&o.exitCode===D.USER_CANCELLED)try{await sa(s,{recursive:!0,force:!0})}catch{}throw i&&n.stop(),o}}async function ia(t,e={}){v.log($t(`Note: "spectrl init" is deprecated. "spectrl install" now auto-initializes when needed.
|
|
110
|
+
This command will be removed in a future version.`));let r=na({text:"Initializing project",spinner:"line"}).start(),s=Ws(t),n=!1;try{if(e.skipAgents&&e.forceAgents)throw r.stop(),new m("Cannot use both --skip-agents and --force-agents",D.VALIDATION_ERROR);let i=le(t);await Vo(i),await ra(s,{recursive:!0}),n=!0;let a=`${JSON.stringify({},null,2)}
|
|
111
|
+
`;await ta(i,a,"utf-8"),await oa(t,e,r),r.text="Configuring .gitignore";let u=await Us(t)?" and configured .gitignore":" (.gitignore already configured)";r.succeed(`Initialized project index at ${S(".spectrl/spectrl-index.json")}${u}`)}catch(i){if(r.stop(),n&&i instanceof m&&i.exitCode===D.USER_CANCELLED)try{await sa(s,{recursive:!0,force:!0})}catch{}throw i}}async function oa(t,e,r){if(e.skipAgents)return;if(e.forceAgents){let i=await Vs(t);if(i.exists)if(i.hasMarker)r.text="Initializing project",v.log(K("\u2713 AGENTS.md already contains Spectrl instructions"));else{r.text="Updating AGENTS.md";try{await Hs(t),r.text="Initializing project",v.log(K("\u2713 Added Spectrl instructions to AGENTS.md"))}catch{r.text="Initializing project",v.log($t("Failed to update AGENTS.md (non-critical)"))}}else{r.text="Creating AGENTS.md";try{await Gs(t),r.text="Initializing project",v.log(K("\u2713 Created AGENTS.md"))}catch{r.text="Initializing project",v.log($t("Failed to create AGENTS.md (non-critical)"))}}return}let s=await Vs(t);if(!s.exists){r.stop();let i=await qs("Create AGENTS.md to configure AI assistants?",!0,{yesLabel:"Yes (recommended)",noLabel:"No"});if(i===void 0)throw new m("Initialization cancelled by user",D.USER_CANCELLED);if(r.start("Initializing project"),i){r.text="Creating AGENTS.md";try{await Gs(t),r.text="Initializing project",v.log(K("\u2713 Created AGENTS.md"))}catch{r.text="Initializing project",v.log($t("Failed to create AGENTS.md (non-critical)"))}}else v.log(K("\u2139 Skipped AGENTS.md creation")),v.log(K("AI assistants won't automatically consult specs. You can create AGENTS.md manually later."));return}if(s.hasMarker){r.text="Initializing project",v.log(K("\u2713 AGENTS.md already contains Spectrl instructions"));return}r.stop();let n=await qs("AGENTS.md found. Append Spectrl instructions to the bottom?",!0,{yesLabel:"Yes (recommended)",noLabel:"No"});if(n===void 0)throw new m("Initialization cancelled by user",D.USER_CANCELLED);if(r.start("Initializing project"),n){r.text="Updating AGENTS.md";try{await Hs(t),r.text="Initializing project",v.log(K("\u2713 Added Spectrl instructions to AGENTS.md"))}catch{r.text="Initializing project",v.log($t("Failed to update AGENTS.md (non-critical)"))}}else v.log(K("\u2139 Skipped AGENTS.md update")),v.log(K("You can add Spectrl instructions manually if needed"))}import{readFile as ha}from"node:fs/promises";import{join as ma}from"node:path";import Nh from"ora";import{select as Lh}from"@inquirer/prompts";import Js from"keytar";import aa from"node-machine-id";import{createCipheriv as hh,createDecipheriv as mh,randomBytes as ca,pbkdf2Sync as ua}from"node:crypto";import{existsSync as Zs,mkdirSync as gh,readFileSync as Dh,writeFileSync as yh,unlinkSync as wh,chmodSync as Eh}from"node:fs";import{homedir as xh}from"node:os";import{join as la}from"node:path";var Ys="spectrl",Xs="github-token",Ks=la(xh(),".spectrl"),Ut=la(Ks,".auth"),vh=f.object({salt:f.string().length(64),iv:f.string().length(32),encrypted:f.string().min(1)}),ve=class{async store(e){try{await Js.setPassword(Ys,Xs,e)}catch{this.storeEncrypted(e)}}async get(){try{return await Js.getPassword(Ys,Xs)}catch{return this.getEncrypted()}}async delete(){try{await Js.deletePassword(Ys,Xs)}catch{}this.deleteEncrypted()}storeEncrypted(e){try{Zs(Ks)||gh(Ks,{recursive:!0});let r=ca(32),s=ca(16),n=aa.machineIdSync(),i=ua(n,r,1e5,32,"sha256"),o=hh("aes-256-cbc",i,s),a=o.update(e,"utf8","hex");a+=o.final("hex");let c=JSON.stringify({salt:r.toString("hex"),iv:s.toString("hex"),encrypted:a});yh(Ut,c,{encoding:"utf8"}),Eh(Ut,384)}catch(r){throw new Error(`Failed to store token: ${r instanceof Error?r.message:"Unknown error"}`)}}getEncrypted(){try{if(!Zs(Ut))return null;let e=Dh(Ut,"utf8"),r=JSON.parse(e),s=vh.safeParse(r);if(!s.success)return null;let{salt:n,iv:i,encrypted:o}=s.data,a=aa.machineIdSync(),c=ua(a,Buffer.from(n,"hex"),1e5,32,"sha256"),u=mh("aes-256-cbc",c,Buffer.from(i,"hex")),d=u.update(o,"hex","utf8");return d+=u.final("utf8"),d}catch{return null}}deleteEncrypted(){try{Zs(Ut)&&wh(Ut)}catch{}}};import{config as Ch}from"dotenv";import{fileURLToPath as bh}from"node:url";import{dirname as Fh,join as Rh}from"node:path";var Sh=bh(import.meta.url),_h=Fh(Sh);process.env.NODE_ENV!=="test"&&!process.env.VITEST&&Ch({path:Rh(_h,"../../.env"),override:!1,quiet:!0});function Ct(){let t=process.env.API_URL;if(t)return t;let e="https://bpleokxqv5.execute-api.eu-north-1.amazonaws.com/prod";if(e)return e;throw new Error("Registry API URL is not configured. Please contact support or reinstall the CLI.")}var _E=f.object({device_code:f.string(),user_code:f.string(),verification_uri:f.string(),expires_in:f.number(),interval:f.number()}),AE=f.object({token:f.string(),username:f.string()}),$E=f.object({status:f.string()}),IE=f.object({error:f.string(),message:f.string().optional()}),Ah=f.object({manifest:f.record(f.string(),f.unknown()),files:f.record(f.string(),f.string())}),$h=f.object({message:f.string(),url:f.string(),specId:f.string(),version:f.string()}),Ih=f.object({specId:f.string(),description:f.string().optional(),tags:f.array(f.string()).optional(),version:f.string(),publishedAt:f.string()}),Oh=f.object({results:f.array(Ih),count:f.number()}),kh=f.object({version:f.string(),description:f.string().optional(),tags:f.array(f.string()).optional(),publishedAt:f.string(),s3Path:f.string(),hash:f.string(),downloads:f.number().optional()}),Th=f.object({specId:f.string(),username:f.string(),specName:f.string(),versions:f.array(kh)}),Ph=f.object({message:f.string()}),V=class extends Error{constructor(r,s,n){super(r);this.statusCode=s;this.response=n;this.name="ApiError"}};async function Qr(t,e={}){let{maxAttempts:r=3,initialDelayMs:s=1e3,maxDelayMs:n=1e4,backoffMultiplier:i=2}=e,o,a=s;for(let c=1;c<=r;c++)try{return await t()}catch(u){if(o=u instanceof Error?u:new Error(String(u)),u instanceof V&&u.statusCode&&u.statusCode<500)throw u;if(c===r)throw o;await new Promise(d=>setTimeout(d,a)),a=Math.min(a*i,n)}throw o||new Error("Retry failed")}async function da(t,e,r){return Qr(async()=>{let s={manifest:e,files:r},n=Ah.safeParse(s);if(!n.success)throw new V(`Invalid request data: ${n.error.message}`,void 0,s);let i=await fetch(`${Ct()}/publish`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n.data)});if(!i.ok){let c=await i.text();throw new V(`Failed to publish spec: ${c}`,i.status,c)}let o=await i.json(),a=$h.safeParse(o);if(!a.success)throw new V("Invalid API response format after publishing.",i.status,o);return a.data})}async function fa(t){return Qr(async()=>{let e=await fetch(`${Ct()}/search?q=${encodeURIComponent(t)}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok){let n=await e.text();throw new V(`Failed to search specs: ${n}`,e.status,n)}let r=await e.json(),s=Oh.safeParse(r);if(!s.success)throw new V("Invalid API response format. Expected search results but received unexpected data.",e.status,r);return s.data})}async function bt(t,e){return Qr(async()=>{let r=await fetch(`${Ct()}/specs/${t}/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){let i=await r.text();throw new V(`Failed to get spec: ${i}`,r.status,i)}let s=await r.json(),n=Th.safeParse(s);if(!n.success)throw new V("Invalid API response format when fetching spec metadata.",r.status,s);return n.data})}async function pa(t,e,r,s){return Qr(async()=>{let n=await fetch(`${Ct()}/specs/${e}/${r}/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});if(!n.ok){let a=await n.text();throw new V(`Failed to unpublish spec: ${a}`,n.status,a)}let i=await n.json(),o=Ph.safeParse(i);if(!o.success)throw new V("Invalid API response format after unpublishing.",n.status,i);return o.data})}function Mh(t,e){if(!t.description||t.description.trim()==="")throw e.stop(),new m('Manifest must include a non-empty "description" field for publishing',D.VALIDATION_ERROR);if(!t.files.includes("index.md"))throw e.stop(),new m('Manifest "files" array must include "index.md" for publishing',D.VALIDATION_ERROR);t.agent?(t.agent.purpose||e.warn('Missing "agent.purpose" \u2014 add a purpose for better discoverability'),(!t.agent.tags||t.agent.tags.length===0)&&e.warn('Missing "agent.tags" \u2014 add tags for better discoverability')):e.warn('Missing "agent" field \u2014 add agent metadata for better discoverability')}async function jh(t,e){let r=Object.entries(t.deps);if(r.length===0)return;let s=new Qe(e??Wt());for(let[n,i]of r){let o;try{o=await s.getManifest(n,i)}catch{continue}let a=o.type??"spec";if(a!==t.type)throw new m(`Dependency "${n}@${i}" is a ${a} but "${t.name}" is a ${t.type} \u2014 cross-type dependencies are not allowed`,D.VALIDATION_ERROR)}}async function ga(t,e){let r=Nh({text:"Publishing spec",spinner:"line"}).start();try{r.text="Validating manifest";let s=await Ho(t);Jo(s.files),await Zo(s.files,t),Mh(s,r),await jh(s,e),r.stop();let n=await Lh({message:"Where do you want to publish?",choices:[{name:"Local registry (~/.spectrl/registry/)",value:"local",description:"Publish to your local registry (private)"},{name:"Public registry (registry.spectrl.dev)",value:"public",description:"Publish to the public registry (requires authentication)"}],default:"local"});r.start(),n==="local"?await Bh(t,s,e,r):await Wh(t,s,r)}catch(s){throw r.stop(),s instanceof m?s:s instanceof Error?new m(s.message,D.IO_ERROR):new m("Unknown error during publish",D.IO_ERROR)}}async function Bh(t,e,r,s){s.text="Reading tracked files";let n={};for(let c of e.files){let u=ma(t,c);try{n[c]=await ha(u,"utf-8")}catch{throw new m(`Failed to read file: ${c}`,D.IO_ERROR)}}s.text="Computing hash";let i=Nr({manifest:e,fileContents:n}),o={...e,hash:i};s.text="Writing to registry",await new Qe(r??Wt()).publish(o,t),s.succeed(`Published ${S(e.name)}@${S(e.version)} to local registry with hash ${S(i.substring(0,12))}`)}async function Wh(t,e,r){r.text="Checking authentication";let n=await new ve().get();if(!n)throw r.stop(),new m(`You need to login first. Run: ${H("spectrl login")}`,D.AUTHENTICATION_ERROR);let i={...e};i.agent||(r.text="Auto-populating agent field",i={...e,agent:{purpose:i.description||"",tags:[]}}),r.text="Reading tracked files";let o={};for(let a of e.files){let c=ma(t,a);try{let u=await ha(c,"utf-8");o[a]=u}catch{throw new m(`Failed to read file: ${a}`,D.IO_ERROR)}}r.text="Publishing to public registry";try{let a={...i},c=await da(n,a,o);r.succeed(`Published ${S(c.specId)}@${S(c.version)} to public registry`),console.log(`
|
|
112
|
+
\u{1F517} ${c.url}
|
|
113
|
+
`)}catch(a){throw a instanceof Error?new m(`Failed to publish to public registry: ${a.message}`,D.IO_ERROR):a}}import{promises as z}from"node:fs";import{dirname as zt,join as B,resolve as wa}from"node:path";import J from"fs-extra";import ts from"ora";import{select as Zh}from"@inquirer/prompts";var et=f.object({name:f.string().regex(/^[a-z0-9-]+$/,"Name must be lowercase alphanumeric with hyphens"),version:f.string().regex(/^\d+\.\d+\.\d+$/,"Version must be semver compliant (x.y.z)"),type:f.enum(["spec","power"]).default("spec"),description:f.string().optional(),deps:f.record(f.string().regex(/^[a-z0-9-]+$/,"Dependency name must be lowercase alphanumeric with hyphens"),f.string().regex(/^\d+\.\d+\.\d+$/,"Dependency version must be exact semver")).default({}),files:f.array(f.string()).min(1,"Files array cannot be empty"),hash:f.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>").optional(),agent:f.object({purpose:f.string(),tags:f.array(f.string()).optional()}).optional()});var qh=f.string().regex(/^[a-z0-9-]+@\d+\.\d+\.\d+$/,"Key must be name@version"),Uh=f.string().refine(t=>t.length===0?!1:(t.startsWith("file:")||t.startsWith("/")||/^[a-zA-Z]:\\/.test(t)||t.startsWith("./")||t.startsWith("../"),!0),"Source must be a non-empty file URL or local path"),zh=f.object({source:Uh,hash:f.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>")}),GE=f.record(qh,zh);var Vh=f.object({name:f.string().regex(/^[a-z0-9-]+$/,"Name must be lowercase alphanumeric with hyphens"),version:f.string().regex(/^\d+\.\d+\.\d+$/,"Version must be semver compliant (x.y.z)"),hash:f.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>"),source:f.string().url("Source must be a valid URL"),deps:f.array(f.string().regex(/^[a-z0-9-]+@\d+\.\d+\.\d+$/,"Dependency must be in format name@version"))}),ZE=f.object({createdAt:f.string().datetime("createdAt must be ISO-8601 format"),entries:f.array(Vh)});var Ft={username:/^[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$/,name:/^[a-z0-9](?:[a-z0-9-]{0,98}[a-z0-9])?$/,version:/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/};function _e(t){if(!t||typeof t!="string")throw new Error("Spec reference must be a non-empty string");let e=t.trim();if(e.length===0)throw new Error("Spec reference must be a non-empty string");return e.includes("/")?Hh(e):Gh(e)}function Gh(t){let e=t.indexOf("@");if(e===-1){let n=t;if(!Ft.name.test(n))throw new Error(`Invalid spec name: ${n}. Must be lowercase alphanumeric with hyphens, 1-100 characters`);return{name:n,isPublic:!1}}let r=t.slice(0,e),s=t.slice(e+1);if(!Ft.name.test(r))throw new Error(`Invalid spec name: ${r}. Must be lowercase alphanumeric with hyphens, 1-100 characters`);if(!Ft.version.test(s))throw new Error(`Invalid version: ${s}. Must be valid semver (e.g., 1.0.0) with no leading zeros`);return{name:r,version:s,isPublic:!1}}function Hh(t){let e=t.indexOf("/");if(e===-1||e===0||e===t.length-1)throw new Error(`Invalid public spec reference: ${t}. Must be in format username/spec or username/spec@version`);let r=t.slice(0,e),s=t.slice(e+1);if(!Ft.username.test(r))throw new Error(`Invalid username: ${r}. Must be lowercase alphanumeric with hyphens, 1-39 characters`);let n=s.indexOf("@");if(n===-1){let a=s;if(!Ft.name.test(a))throw new Error(`Invalid spec name: ${a}. Must be lowercase alphanumeric with hyphens, 1-100 characters`);return{username:r,name:a,isPublic:!0}}let i=s.slice(0,n),o=s.slice(n+1);if(!Ft.name.test(i))throw new Error(`Invalid spec name: ${i}. Must be lowercase alphanumeric with hyphens, 1-100 characters`);if(!Ft.version.test(o))throw new Error(`Invalid version: ${o}. Must be valid semver (e.g., 1.0.0) with no leading zeros`);return{username:r,name:i,version:o,isPublic:!0}}import{promises as es}from"node:fs";import{join as tt}from"node:path";import Jh from"fs-extra";function Da(t){let e=["<!-- Auto-generated by Spectrl. Do not edit manually. -->","","# Spectrl Catalog",""].join(`
|
|
114
|
+
`);if(t.length===0)return`${e}| Name | Version | Type | Description | When to Use |
|
|
115
|
+
| ---- | ------- | ---- | ----------- | ----------- |
|
|
116
|
+
`;let r={name:Math.max(4,...t.map(a=>a.name.length)),version:Math.max(7,...t.map(a=>a.version.length)),type:Math.max(4,...t.map(a=>a.type.length)),description:Math.max(11,...t.map(a=>a.description.length)),purpose:Math.max(11,...t.map(a=>a.purpose.length))},s=(a,c)=>a.padEnd(c),n=`| ${s("Name",r.name)} | ${s("Version",r.version)} | ${s("Type",r.type)} | ${s("Description",r.description)} | ${s("When to Use",r.purpose)} |`,i=`| ${"-".repeat(r.name)} | ${"-".repeat(r.version)} | ${"-".repeat(r.type)} | ${"-".repeat(r.description)} | ${"-".repeat(r.purpose)} |`,o=t.map(a=>`| ${s(a.name,r.name)} | ${s(a.version,r.version)} | ${s(a.type,r.type)} | ${s(a.description,r.description)} | ${s(a.purpose,r.purpose)} |`);return[e,n,i,...o,""].join(`
|
|
117
|
+
`)}async function ya(t){let e=tt(t,".spectrl"),r=tt(e,"spectrl-index.json"),s;try{let a=await es.readFile(r,"utf-8");s=JSON.parse(a)}catch(a){if(a.code==="ENOENT"){let c=tt(e,"catalog.md");await Jh.ensureDir(e),await es.writeFile(c,Da([]),"utf-8");return}throw new m(`Failed to read project index: ${a.message}`,D.IO_ERROR)}if(typeof s!="object"||s===null||Array.isArray(s))throw new m("Invalid project index format",D.VALIDATION_ERROR);let n=Object.keys(s),i=[];for(let a of n){let c=tt(e,"specs"),u=[tt(c,a),tt(c,a.replace("/","-"))],d=s[a];if(d&&typeof d=="object"&&"source"in d&&typeof d.source=="string"){let L=d.source;!L.startsWith("http://")&&!L.startsWith("https://")&&u.push(L)}let h=null;for(let L of u){let q=tt(L,"spectrl.json");try{let U=await es.readFile(q,"utf-8");h=JSON.parse(U);break}catch{}}if(h===null){console.warn(`[spectrl] Warning: could not read manifest for ${a}, skipping in catalog`);continue}let p=et.safeParse(h);if(!p.success){console.warn(`[spectrl] Warning: invalid manifest for ${a}: ${p.error.issues[0].message}, skipping in catalog`);continue}let l=p.data,g=a.lastIndexOf("@"),w=g!==-1?a.slice(0,g):a,x=g!==-1?a.slice(g+1):l.version,A=l.description??"",$=l.agent?.purpose??A;i.push({name:w,version:x,type:l.type,description:A,purpose:$})}let o=tt(e,"catalog.md");try{await es.writeFile(o,Da(i),"utf-8")}catch(a){throw new m(`Failed to generate catalog: ${a.message}`,D.IO_ERROR)}}async function Dr(t){try{await ya(t)}catch(e){console.warn(`[spectrl] Warning: catalog generation failed: ${e instanceof Error?e.message:String(e)}`)}}function Ea(){return process.env.REGISTRY_URL||"https://d12j78i0x57g1k.cloudfront.net"}async function va(t,e,r,s,n){try{let i=le(n),o=await z.readFile(i,"utf-8"),a=JSON.parse(o);if(r){let c=`${t}@${e}`;if(a[c])return{hasCollision:!0,existingType:"local",existingPath:B(n,".spectrl","specs",c),existingKey:c}}else for(let c of Object.keys(a))if(c.includes("/")){let u=c.split("/");if(u.length===2&&u[1]===`${t}@${e}`){let d=u[0];return{hasCollision:!0,existingType:"public",existingPath:B(n,".spectrl","specs",`${d}-${t}@${e}`),existingKey:c}}}return{hasCollision:!1,existingType:null,existingPath:null,existingKey:null}}catch{return{hasCollision:!1,existingType:null,existingPath:null,existingKey:null}}}async function Yh(t,e,r,s){return await Zh({message:`Warning: A ${t} spec '${r}' already exists.
|
|
118
|
+
Installing ${e} spec '${s}' may cause confusion in dependency resolution.
|
|
119
|
+
|
|
120
|
+
What would you like to do?`,choices:[{name:`Replace ${t} spec with ${e} spec`,value:"replace",description:`Remove '${r}' and install '${s}'`},{name:"Cancel installation",value:"cancel",description:"Keep existing spec and abort"}],default:"cancel"})}async function Ca(t,e,r,s){if(!t.hasCollision||!t.existingType||!t.existingKey||!t.existingPath)return;if(!process.stdin.isTTY)throw new m(["Spec name collision detected",` ${t.existingType==="local"?"Local":"Public"} spec '${t.existingKey}' already exists`,` Attempted to install ${r} spec '${e}'`,"","This collision will cause ambiguity in dependency resolution.","","To resolve:",` 1. Remove the ${t.existingType} spec: spectrl uninstall ${t.existingKey}`,` 2. Or remove the ${r} spec from your index`," 3. Then retry the installation"].join(`
|
|
121
|
+
`),D.VALIDATION_ERROR);if(await Yh(t.existingType,r,t.existingKey,e)==="cancel")throw new m("Installation cancelled by user",D.USER_CANCELLED);let i=ts({text:`Removing existing ${t.existingType} spec '${t.existingKey}'`,spinner:"line"}).start();try{await Vt(t.existingPath);let o=le(s),a=await z.readFile(o,"utf-8"),c=JSON.parse(a);if(t.existingKey in c){let u={...c};delete u[t.existingKey],await z.writeFile(o,`${JSON.stringify(u,null,2)}
|
|
122
|
+
`,"utf-8")}i.succeed(`Removed ${t.existingType} spec '${t.existingKey}'`)}catch(o){throw i.fail("Failed to remove existing spec"),new m(`Failed to remove existing spec: ${o instanceof Error?o.message:String(o)}`,D.IO_ERROR)}}function Xh(){return process.platform==="win32"?"junction":"dir"}async function ba(t,e){try{if(!(await J.lstat(t)).isSymbolicLink())return{exists:!0,isSymlink:!1,isCorrect:!1};let n=await J.readlink(t),i=wa(zt(t),n),o=wa(e);return{exists:!0,isSymlink:!0,isCorrect:i===o}}catch(r){if(r.code==="ENOENT")return{exists:!1,isSymlink:!1,isCorrect:!1};throw r}}async function Vt(t){try{(await J.lstat(t)).isSymbolicLink()?await J.unlink(t):await J.remove(t)}catch(e){let r=e;if(r.code!=="ENOENT")throw new m(`Failed to remove existing path ${t}: ${r.message}`,D.IO_ERROR)}}function Kh(){return process.env.SPECTRL_USE_COPY==="1"}async function xa(t,e,r){try{await J.ensureDir(e);let s=B(zt(t),"spectrl.json"),n=B(e,"spectrl.json");await J.copy(s,n);let i=new Set;for(let o of r.files){let a=B(e,o);i.add(zt(a))}for(let o of i)await J.ensureDir(o);for(let o of r.files){let a=B(t,o),c=B(e,o);await J.copy(a,c)}}catch(s){let n=s;throw new m(`Failed to copy files from registry: ${n.message}`,D.IO_ERROR)}}async function Fa(t,e,r,s){if(Kh())return s.info("Using file copy mode (SPECTRL_USE_COPY=1)"),await xa(t,e,r),"copy";if(!await J.pathExists(t))throw new m(`Registry path not found: ${t}
|
|
123
|
+
|
|
124
|
+
Has this spec been published? Run: ${H("spectrl publish")}`,D.DEPENDENCY_ERROR);try{await J.ensureDir(zt(e))}catch(i){let o=i;throw new m(`Failed to create parent directory for symlink: ${o.message}`,D.IO_ERROR)}try{let i=Xh();return await J.symlink(t,e,i),"symlink"}catch(i){let o=i;if(o.code==="EPERM"){s.warn("Permission denied creating symlink. Windows: Enable Developer Mode or run as Administrator. Falling back to file copy...");try{await Vt(e)}catch{}return await xa(t,e,r),"copy"}throw new m(`Failed to create symlink: ${o.message}`,D.IO_ERROR)}}function Ra(t,e){let r;return t.startsWith("file://")?r=t.slice(7):t.startsWith("file:")?r=t.slice(5):r=t,r.startsWith("/")||(r=B(e,r)),r}async function Qh(t,e){if(t.startsWith("https://")||t.startsWith("http://"))try{let s=await fetch(t);if(!s.ok)throw new Error(`HTTP ${s.status}`);let n=await s.json(),i=et.safeParse(n);if(!i.success)throw new Error(`Invalid manifest format: ${i.error.issues[0].message}`);let o=i.data,a=new URL(t),c=`${a.protocol}//${a.host}`,u=a.pathname.split("/");u.pop();let d=u.join("/"),h={};for(let p of o.files){let l=`${c}${d}/files/${p}`,g=await fetch(l);if(!g.ok)throw new Error(`Failed to download ${p}: HTTP ${g.status}`);h[p]=await g.text()}return{manifest:o,fileContents:h}}catch(s){throw s instanceof Error?new m(`Failed to read files from ${t}: ${s.message}`,D.IO_ERROR):s}let r=Ra(t,e);try{let s=B(r,"spectrl.jsonc"),n=B(r,"spectrl.json"),i;try{i=await z.readFile(s,"utf-8")}catch{i=await z.readFile(n,"utf-8")}let o=xt(i),a=et.safeParse(o);if(!a.success)throw new Error(`Invalid manifest in ${r}: ${a.error.issues[0].message}`);let c=a.data,u=B(r,"files"),d=!1;try{d=(await z.stat(u)).isDirectory()}catch{d=!1}let h={};for(let p of c.files){let l=d?B(r,"files",p):B(r,p);h[p]=await z.readFile(l,"utf-8")}return{manifest:c,fileContents:h}}catch(s){throw s instanceof Error?new m(`Failed to read files from ${t}: ${s.message}`,D.IO_ERROR):s}}async function em(t,e){let r=await e.listVersions(t);if(r.length===0)throw new m(`Spec ${S(t)} not found in registry`,D.DEPENDENCY_ERROR);return r.sort((n,i)=>Bo(i,n))[0]}async function Qs(t,e){let{username:r,name:s,version:n}=t,{cwd:i}=e,o=ts({text:`Resolving ${S(`${r}/${s}`)}`,spinner:"line"}).start();try{await Kr(i,{skipAgents:!process.stdin.isTTY,spinner:o}),o.text=`Fetching ${S(`${r}/${s}`)} from public registry`;let a;try{a=await bt(r,s)}catch(N){throw N instanceof V&&N.statusCode===404?new m(`Spec ${S(`${r}/${s}`)} not found in public registry`,D.DEPENDENCY_ERROR):N}let c=n||a.versions[0]?.version;if(!c)throw new m(`No versions available for ${S(`${r}/${s}`)}`,D.DEPENDENCY_ERROR);let u=a.versions.find(N=>N.version===c);if(!u)throw new m(`Version ${S(c)} not found for ${S(`${r}/${s}`)}`,D.DEPENDENCY_ERROR);let d=qt(r,s,c);o.text=`Found ${S(d)}`,o.stop();let h=await va(s,c,!0,r,i);await Ca(h,d,"public",i),o.start(`Installing ${S(d)}`);let p=Yr(i,r,s,c),l=B(p,"spectrl.json");try{let N=await z.readFile(l,"utf-8"),G=JSON.parse(N),Y=et.safeParse(G);if(!Y.success)throw new Error("Invalid manifest");if(Y.data.hash===u.hash){o.succeed(`${S(d)} already installed at ${S(`.spectrl/specs/${Zr(r,s,c)}`)}`);let fe=le(i),X={};try{let Re=await z.readFile(fe,"utf-8");X=JSON.parse(Re)}catch(Re){if(Re.code!=="ENOENT")throw Re}let ae=`${Ea()}/${u.s3Path}/spectrl.json`;X[d]={source:ae,hash:u.hash};let ge=JSON.stringify(X,null,2);await z.writeFile(fe,`${ge}
|
|
125
|
+
`,"utf-8"),await Dr(i);return}}catch(N){if(N.code!=="ENOENT")throw N}o.text=`Downloading ${S(d)} manifest`;let g=Ea(),w=`${g}/${u.s3Path}/spectrl.json`,x;try{x=await fetch(w)}catch(N){throw new m(`Failed to download manifest: ${N instanceof Error?N.message:String(N)}`,D.IO_ERROR)}if(!x.ok)throw new m(`Failed to download manifest: HTTP ${x.status}`,D.IO_ERROR);let A=await x.json(),$=et.safeParse(A);if(!$.success)throw new m(`Downloaded manifest is invalid: ${$.error.issues[0].message}`,D.VALIDATION_ERROR);let L=$.data,q={...L,hash:u.hash};await J.ensureDir(p),await z.writeFile(l,JSON.stringify(q,null,2),"utf-8"),o.text=`Downloading ${S(d)} files (${L.files.length} files)`;for(let N of L.files){let G=`${g}/${u.s3Path}/files/${N}`,Y;try{Y=await fetch(G)}catch(X){throw new m(`Failed to download file ${N}: ${X instanceof Error?X.message:String(X)}`,D.IO_ERROR)}if(!Y.ok)throw new m(`Failed to download file ${N}: HTTP ${Y.status}`,D.IO_ERROR);let Me=await Y.text(),fe=B(p,N);await J.ensureDir(zt(fe)),await z.writeFile(fe,Me,"utf-8")}o.text="Updating project index";let U=le(i),Le={};try{let N=await z.readFile(U,"utf-8");Le=JSON.parse(N)}catch(N){if(N.code!=="ENOENT")throw new m(`Failed to read project index: ${N.message}`,D.IO_ERROR)}Le[d]={source:w,hash:u.hash};try{let N=JSON.stringify(Le,null,2);await z.writeFile(U,`${N}
|
|
126
|
+
`,"utf-8")}catch(N){o.warn("Failed to update index, rolling back installation...");try{await J.remove(p)}catch{}throw new m(`Failed to update project index: ${N.message}`,D.IO_ERROR)}o.succeed(`Installed ${S(d)} from public registry at ${S(`.spectrl/specs/${Zr(r,s,c)}`)}`),await Dr(i)}catch(a){throw o.stop(),a instanceof m?a:a instanceof V?new m(`API error: ${a.message}`,a.statusCode&&a.statusCode>=500?D.IO_ERROR:D.DEPENDENCY_ERROR):a instanceof Error?new m(a.message,D.IO_ERROR):new m("Unknown error during install",D.IO_ERROR)}}async function Sa(t,e){try{let{cwd:r,registry:s}=e;await Kr(r,{skipAgents:!process.stdin.isTTY});let n;try{n=_e(t)}catch(o){throw new m(`Invalid spec reference format: ${t}. ${o instanceof Error?o.message:String(o)}`,D.VALIDATION_ERROR)}if(n.isPublic&&n.username)return await Qs({username:n.username,name:n.name,version:n.version},{cwd:r});let i=ts({text:`Installing ${S(t)}`,spinner:"line"}).start();try{let{name:o,version:a}=n,c=new Qe(s??Wt());a||(i.text=`Resolving ${S(o)}...`,a=await em(o,c),i.text=`Resolved ${S(o)} to version ${S(a)}`);let u=`${o}@${a}`;i.stop();let d=await va(o,a,!1,void 0,r);if(await Ca(d,u,"local",r),i.start(`Installing ${S(u)}`),i.text=`Looking up ${S(u)} in registry`,!await c.exists(o,a))throw new m(`Spec ${S(u)} not found in registry`,D.DEPENDENCY_ERROR);i.text=`Reading manifest for ${S(u)}`;let p=await c.getManifest(o,a);if(!p.hash)throw new m(`Manifest for ${u} is missing hash`,D.VALIDATION_ERROR);let l=c.paths.files(o,a),g=B(r,".spectrl","specs",u);i.text=`Checking ${S(u)}`;let w=await ba(g,l);if(w.exists&&w.isSymlink&&w.isCorrect){i.succeed(`${S(u)} already installed at ${S(`.spectrl/specs/${u}`)}`),i.text="Updating project index";let G=B(r,".spectrl","spectrl-index.json"),Y={};try{let X=await z.readFile(G,"utf-8");Y=JSON.parse(X)}catch(X){if(X.code!=="ENOENT")throw X}let Me=c.paths.spec(o,a);Y[u]={source:Me,hash:p.hash};let fe=JSON.stringify(Y,null,2);await z.writeFile(G,`${fe}
|
|
127
|
+
`,"utf-8"),await Dr(r);return}let x=!1;w.exists&&(w.isSymlink?i.text=`Updating symlink for ${S(u)}`:(i.text=`Upgrading ${S(u)} from copied files to symlink`,x=!0),await Vt(g)),i.text=`Installing ${S(u)}`;let A=await Fa(l,g,p,i);if(!await J.pathExists(g))throw new m(`Installation verification failed: ${g} does not exist after installation`,D.IO_ERROR);i.text="Updating project index";let L=B(r,".spectrl","spectrl-index.json"),q={};try{let G=await z.readFile(L,"utf-8");q=JSON.parse(G)}catch(G){if(G.code!=="ENOENT")throw new m(`Failed to read project index: ${G.message}`,D.IO_ERROR)}let U=c.paths.spec(o,a);q[u]={source:U,hash:p.hash};try{let G=JSON.stringify(q,null,2);await z.writeFile(L,`${G}
|
|
128
|
+
`,"utf-8")}catch(G){i.warn("Failed to update index, rolling back installation...");try{await Vt(g)}catch{}throw new m(`Failed to update project index: ${G.message}`,D.IO_ERROR)}let Le=A==="symlink"?"symlink":"copied files",N=x?"Upgraded":"Installed";i.succeed(`${N} ${S(u)} using ${Le} at ${S(`.spectrl/specs/${u}`)}`),await Dr(r)}catch(o){throw i.stop(),o instanceof m?o:o instanceof Error?new m(o.message,D.IO_ERROR):new m("Unknown error during install",D.IO_ERROR)}}catch(r){throw r instanceof m?r:r instanceof Error?new m(r.message,D.IO_ERROR):new m("Unknown error during install",D.IO_ERROR)}}async function _a(t){let e=ts({text:"Installing specs",spinner:"line"}).start();try{let{cwd:r,registry:s}=t;await Kr(r,{skipAgents:!process.stdin.isTTY,spinner:e}),e.text="Resolving dependencies";let n=le(r),i=B(r,".spectrl","spectrl-index.json"),a=await new Pr().resolveClosureFromIndex(i);if(a.length===0){e.info("No specs to install");return}let c={total:a.length,symlinked:0,copied:0,upgraded:0,skipped:0};e.text=`Resolving ${c.total} spec(s)`;let u=new Qe(s??Wt()),d=[],h=B(r,".spectrl"),p={};try{let x=await z.readFile(n,"utf-8");p=JSON.parse(x)}catch(x){if(x.code!=="ENOENT")throw x}for(let x of a){let{name:A,version:$,source:L,deps:q}=x,U=`${A}@${$}`;e.text=`Processing ${S(U)}`;let Le=L.startsWith("https://")||L.startsWith("http://"),{manifest:N,fileContents:G}=await Qh(L,h),Y=Nr({manifest:N,fileContents:G});if(Le){let Me=U.split("/"),fe=Me.length>1?B(r,".spectrl","specs",`${Me[0]}-${Me[1]}`):B(r,".spectrl","specs",U),X=B(fe,"spectrl.json"),$e=!1;try{let ae=await z.readFile(X,"utf-8"),ge=JSON.parse(ae),Re=et.safeParse(ge);Re.success&&Re.data.hash===Y&&($e=!0,c.skipped++)}catch{}if(!$e){await J.ensureDir(fe),await z.writeFile(X,JSON.stringify(N,null,2),"utf-8");for(let ae of N.files){let ge=B(fe,ae);await J.ensureDir(zt(ge)),await z.writeFile(ge,G[ae],"utf-8")}c.copied++}p[U]={source:L,hash:Y}}else{if(await u.exists(A,$)){if((await u.getManifest(A,$)).hash!==Y)throw new m(`Integrity breach: hash mismatch for ${U}`,D.IO_ERROR)}else{let ge={...N,hash:Y},Re=Ra(L,h);await u.publish(ge,Re)}let fe=u.paths.spec(A,$),X=u.paths.files(A,$),$e=B(r,".spectrl","specs",U);e.text=`Checking ${S(U)}`;let ae=await ba($e,X);if(ae.exists&&ae.isSymlink&&ae.isCorrect)c.skipped++;else{let ge=!1;ae.exists&&!ae.isSymlink?(e.text=`Upgrading ${S(U)} from copied files to symlink`,await Vt($e),ge=!0):ae.exists&&!ae.isCorrect?(e.text=`Updating symlink for ${S(U)}`,await Vt($e)):e.text=`Creating symlink for ${S(U)}`;let Re=await Fa(X,$e,N,e);if(!await J.pathExists($e))throw new m(`Installation verification failed: ${$e} does not exist after installation`,D.IO_ERROR);ge?c.upgraded++:Re==="symlink"?c.symlinked++:c.copied++}p[U]={source:fe,hash:Y}}d.push({name:A,version:$,hash:Y,source:L,deps:q})}e.text="Updating project index";try{let x=JSON.stringify(p,null,2);await z.writeFile(n,`${x}
|
|
129
|
+
`,"utf-8")}catch(x){throw new m(`Failed to update project index: ${x.message}`,D.IO_ERROR)}e.text="Writing lock file",d.sort((x,A)=>{let $=`${x.name}@${x.version}`,L=`${A.name}@${A.version}`;return $.localeCompare(L)});let l={createdAt:new Date().toISOString(),entries:d},g=B(r,".spectrl","lock.json");try{await z.writeFile(g,`${JSON.stringify(l,null,2)}
|
|
130
|
+
`,"utf-8")}catch(x){throw new m(`Failed to write lock file: ${x.message}`,D.IO_ERROR)}let w=[];c.symlinked>0&&w.push(`${c.symlinked} symlinked`),c.copied>0&&w.push(`${c.copied} copied`),c.upgraded>0&&w.push(`${c.upgraded} upgraded`),c.skipped>0&&w.push(`${c.skipped} skipped`),e.succeed(`Processed ${c.total} spec(s) (${w.join(", ")}), lock file written`),await Dr(r)}catch(r){if(e.stop(),r instanceof pe){let s=r.exitCode===3?D.DEPENDENCY_ERROR:D.VALIDATION_ERROR;throw new m(r.message,s)}throw r instanceof m?r:r instanceof Error?new m(r.message,D.IO_ERROR):new m("Unknown error during install",D.IO_ERROR)}}import{writeFile as Aa,mkdir as tm}from"node:fs/promises";import{join as en}from"node:path";import rm from"ora";function sm(t,e){return`{
|
|
131
|
+
"name": "${t}",
|
|
132
|
+
"version": "${e}",
|
|
133
|
+
"type": "spec",
|
|
134
|
+
// Required for publishing. Describe what this spec covers.
|
|
135
|
+
// "description": "",
|
|
136
|
+
"files": ["index.md"],
|
|
137
|
+
"deps": {}
|
|
138
|
+
// Recommended: help agents discover and use this spec.
|
|
139
|
+
// "agent": {
|
|
140
|
+
// "purpose": "Explain when agents should consult this spec",
|
|
141
|
+
// "tags": ["relevant", "keywords"]
|
|
142
|
+
// }
|
|
143
|
+
}
|
|
144
|
+
`}function nm(t,e){return`{
|
|
145
|
+
"name": "${t}",
|
|
146
|
+
"version": "${e}",
|
|
147
|
+
"type": "power",
|
|
148
|
+
// Required for publishing. Describe what this power does.
|
|
149
|
+
// "description": "",
|
|
150
|
+
"files": ["index.md"],
|
|
151
|
+
"deps": {}
|
|
152
|
+
// Recommended: help agents discover and use this power.
|
|
153
|
+
// "agent": {
|
|
154
|
+
// "purpose": "Explain when agents should follow these instructions",
|
|
155
|
+
// "tags": ["relevant", "keywords"]
|
|
156
|
+
// }
|
|
157
|
+
}
|
|
158
|
+
`}var im=`# [Spec Name]
|
|
159
|
+
|
|
160
|
+
<!-- What is this spec about? Write 1-2 sentences an agent can use to decide whether to load it. -->
|
|
161
|
+
|
|
162
|
+
## Overview
|
|
163
|
+
|
|
164
|
+
Describe the context this spec provides. Good specs are:
|
|
165
|
+
|
|
166
|
+
- **Focused** \u2014 cover one topic or decision area, not everything
|
|
167
|
+
- **Stable** \u2014 capture decisions already made, not open questions
|
|
168
|
+
- **Actionable** \u2014 give an agent enough context to act correctly without guessing
|
|
169
|
+
- **Scoped** \u2014 link to related specs rather than duplicating content
|
|
170
|
+
|
|
171
|
+
## Content
|
|
172
|
+
|
|
173
|
+
Add your spec content here.
|
|
174
|
+
|
|
175
|
+
## Quality Checklist
|
|
176
|
+
|
|
177
|
+
Before publishing, verify:
|
|
178
|
+
|
|
179
|
+
- [ ] The overview clearly states what this spec covers
|
|
180
|
+
- [ ] An agent reading only this file would have enough context to act
|
|
181
|
+
- [ ] Decisions are stated as facts, not as options to consider
|
|
182
|
+
- [ ] Ambiguous terms are defined or linked
|
|
183
|
+
- [ ] The \`description\` field in spectrl.jsonc is filled in
|
|
184
|
+
- [ ] The \`agent.purpose\` field explains *when* to consult this spec
|
|
185
|
+
`,om=`# [Power Name]
|
|
186
|
+
|
|
187
|
+
<!-- What does this power do? Write 1-2 sentences an agent can use to decide whether to follow it. -->
|
|
188
|
+
|
|
189
|
+
## When to Use
|
|
190
|
+
|
|
191
|
+
Describe the situations where an agent should follow these instructions. Good powers are:
|
|
192
|
+
|
|
193
|
+
- **Triggered** \u2014 clearly state the condition that activates them (e.g. "when reviewing a PR", "when writing a migration")
|
|
194
|
+
- **Prescriptive** \u2014 tell the agent exactly what to do, not just what to consider
|
|
195
|
+
- **Bounded** \u2014 cover one workflow or pattern, not a grab-bag of rules
|
|
196
|
+
- **Verifiable** \u2014 each step should have a clear done state
|
|
197
|
+
|
|
198
|
+
## Instructions
|
|
199
|
+
|
|
200
|
+
1. Step one
|
|
201
|
+
2. Step two
|
|
202
|
+
3. Step three
|
|
203
|
+
|
|
204
|
+
## Quality Checklist
|
|
205
|
+
|
|
206
|
+
Before publishing, verify:
|
|
207
|
+
|
|
208
|
+
- [ ] The "When to Use" section makes the trigger condition unambiguous
|
|
209
|
+
- [ ] Every instruction is an action, not a suggestion
|
|
210
|
+
- [ ] The steps are in the order an agent should follow them
|
|
211
|
+
- [ ] Edge cases or exceptions are called out explicitly
|
|
212
|
+
- [ ] The \`description\` field in spectrl.jsonc is filled in
|
|
213
|
+
- [ ] The \`agent.purpose\` field explains *when* to activate this power
|
|
214
|
+
`;async function $a(t,e,r="spec",s="0.1.0",n){let i=rm({text:`Creating new ${r}`,spinner:"line"}).start();try{if(!/^[a-z0-9-]+$/.test(t))throw new m("Name must be lowercase alphanumeric with hyphens",D.VALIDATION_ERROR);let o=en(e,t);if(await Ue(o))throw new m(`Directory already exists: ${t}`,D.VALIDATION_ERROR);i.text=`Creating directory ${t}`,await tm(o,{recursive:!0});let a=r==="power"?nm(t,s):sm(t,s),c=en(o,"spectrl.jsonc");await Aa(c,a,"utf-8");let u=r==="power"?om:im,d=en(o,"index.md");await Aa(d,u,"utf-8"),i.succeed(`Created new ${r} ${S(t)} at ${S(`${t}/spectrl.jsonc`)}`)}catch(o){throw i.stop(),o}}import rt from"chalk";import Ha from"node:process";import Ja from"node:path";import{fileURLToPath as Mm}from"node:url";import jm from"node:child_process";import Bm,{constants as Wm}from"node:fs/promises";import{promisify as Dm}from"node:util";import ym from"node:child_process";import on,{constants as Na}from"node:fs/promises";import ka from"node:process";import dm from"node:os";import fm from"node:fs";import um from"node:fs";import Ia from"node:fs";var tn;function am(){try{return Ia.statSync("/.dockerenv"),!0}catch{return!1}}function cm(){try{return Ia.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function rn(){return tn===void 0&&(tn=am()||cm()),tn}var sn,lm=()=>{try{return um.statSync("/run/.containerenv"),!0}catch{return!1}};function Gt(){return sn===void 0&&(sn=lm()||rn()),sn}var Oa=()=>{if(ka.platform!=="linux")return!1;if(dm.release().toLowerCase().includes("microsoft"))return!Gt();try{return fm.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!Gt():!1}catch{return!1}},ze=ka.env.__IS_WSL_TEST__?Oa:Oa();import Ta from"node:process";import{Buffer as pm}from"node:buffer";import{promisify as hm}from"node:util";import mm from"node:child_process";var gm=hm(mm.execFile),nn=()=>`${Ta.env.SYSTEMROOT||Ta.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var he=async(t,e={})=>{let{powerShellPath:r,...s}=e,n=he.encodeCommand(t);return gm(r??nn(),[...he.argumentsPrefix,n],{encoding:"utf8",...s})};he.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];he.encodeCommand=t=>pm.from(t,"utf16le").toString("base64");he.escapeArgument=t=>`'${String(t).replaceAll("'","''")}'`;var wm=Dm(ym.execFile),Em=(()=>{let t="/mnt/",e;return async function(){if(e)return e;let r="/etc/wsl.conf",s=!1;try{await on.access(r,Na.F_OK),s=!0}catch{}if(!s)return t;let n=await on.readFile(r,{encoding:"utf8"}),i=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(n);return i?(e=i.groups.mountPoint.trim(),e=e.endsWith("/")?e:`${e}/`,e):t}})(),xm=async()=>`${await Em()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,rs=ze?xm:nn,Pa,La=async()=>(Pa??=(async()=>{try{let t=await rs();return await on.access(t,Na.X_OK),!0}catch{return!1}})(),Pa),Ma=async()=>{let t=await rs(),e=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:r}=await he(e,{powerShellPath:t});return r.trim()},ja=async t=>{if(/^[a-z]+:\/\//i.test(t))return t;try{let{stdout:e}=await wm("wslpath",["-aw",t],{encoding:"utf8"});return e.trim()}catch{return t}};function Rt(t,e,r){let s=n=>Object.defineProperty(t,e,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){let n=r();return s(n),n},set(n){s(n)}}),t}import{promisify as km}from"node:util";import dn from"node:process";import{execFile as Tm}from"node:child_process";import{promisify as vm}from"node:util";import Cm from"node:process";import{execFile as bm}from"node:child_process";var Fm=vm(bm);async function an(){if(Cm.platform!=="darwin")throw new Error("macOS only");let{stdout:t}=await Fm("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),r=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(t)?.groups.id??"com.apple.Safari";return r==="com.apple.safari"?"com.apple.Safari":r}import Rm from"node:process";import{promisify as Sm}from"node:util";import{execFile as _m,execFileSync as i0}from"node:child_process";var Am=Sm(_m);async function Ba(t,{humanReadableOutput:e=!0,signal:r}={}){if(Rm.platform!=="darwin")throw new Error("macOS only");let s=e?[]:["-ss"],n={};r&&(n.signal=r);let{stdout:i}=await Am("osascript",["-e",t,s],n);return i.trim()}async function cn(t){return Ba(`tell application "Finder" to set app_path to application file id "${t}" as string
|
|
215
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as $m}from"node:util";import{execFile as Im}from"node:child_process";var Om=$m(Im),Wa={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},un=new Map(Object.entries(Wa)),ss=class extends Error{};async function ln(t=Om){let{stdout:e}=await t("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),r=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(e);if(!r)throw new ss(`Cannot find Windows browser in stdout: ${JSON.stringify(e)}`);let{id:s}=r.groups,n=Wa[s];if(!n)throw new ss(`Unknown browser ID: ${s}`);return n}var Pm=km(Tm),Nm=t=>t.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase());async function fn(){if(dn.platform==="darwin"){let t=await an();return{name:await cn(t),id:t}}if(dn.platform==="linux"){let{stdout:t}=await Pm("xdg-mime",["query","default","x-scheme-handler/http"]),e=t.trim();return{name:Nm(e.replace(/.desktop$/,"").replace("-"," ")),id:e}}if(dn.platform==="win32")return ln();throw new Error("Only macOS, Linux, and Windows are supported")}import pn from"node:process";var Lm=!!(pn.env.SSH_CONNECTION||pn.env.SSH_CLIENT||pn.env.SSH_TTY),qa=Lm;var ns=Symbol("fallbackAttempt"),hn=import.meta.url?Ja.dirname(Mm(import.meta.url)):"",Ua=Ja.join(hn,"xdg-open"),{platform:Ht,arch:za}=Ha,Va=async(t,e)=>{if(t.length===0)return;let r=[];for(let s of t)try{return await e(s)}catch(n){r.push(n)}throw new AggregateError(r,"Failed to open in all supported apps")},is=async t=>{t={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...t};let e=t[ns]===!0;if(delete t[ns],Array.isArray(t.app))return Va(t.app,u=>is({...t,app:u,[ns]:!0}));let{name:r,arguments:s=[]}=t.app??{};if(s=[...s],Array.isArray(r))return Va(r,u=>is({...t,app:{name:u,arguments:s},[ns]:!0}));if(r==="browser"||r==="browserPrivate"){let u={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},d={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},h;if(ze){let p=await Ma();h=un.get(p)??{}}else h=await fn();if(h.id in u){let p=u[h.id.toLowerCase()];if(r==="browserPrivate"){if(p==="safari")throw new Error("Safari doesn't support opening in private mode via command line");s.push(d[p])}return is({...t,app:{name:Jt[p],arguments:s}})}throw new Error(`${h.name} is not supported as a default browser`)}let n,i=[],o={},a=!1;if(ze&&!Gt()&&!qa&&!r&&(a=await La()),Ht==="darwin")n="open",t.wait&&i.push("--wait-apps"),t.background&&i.push("--background"),t.newInstance&&i.push("--new"),r&&i.push("-a",r);else if(Ht==="win32"||a){n=await rs(),i.push(...he.argumentsPrefix),ze||(o.windowsVerbatimArguments=!0),ze&&t.target&&(t.target=await ja(t.target));let u=["$ProgressPreference = 'SilentlyContinue';","Start"];t.wait&&u.push("-Wait"),r?(u.push(he.escapeArgument(r)),t.target&&s.push(t.target)):t.target&&u.push(he.escapeArgument(t.target)),s.length>0&&(s=s.map(d=>he.escapeArgument(d)),u.push("-ArgumentList",s.join(","))),t.target=he.encodeCommand(u.join(" ")),t.wait||(o.stdio="ignore")}else{if(r)n=r;else{let u=!hn||hn==="/",d=!1;try{await Bm.access(Ua,Wm.X_OK),d=!0}catch{}n=Ha.versions.electron??(Ht==="android"||u||!d)?"xdg-open":Ua}s.length>0&&i.push(...s),t.wait||(o.stdio="ignore",o.detached=!0)}Ht==="darwin"&&s.length>0&&i.push("--args",...s),t.target&&i.push(t.target);let c=jm.spawn(n,i,o);return t.wait?new Promise((u,d)=>{c.once("error",d),c.once("close",h=>{if(!t.allowNonzeroExitCode&&h!==0){d(new Error(`Exited with code ${h}`));return}u(c)})}):e?new Promise((u,d)=>{c.once("error",d),c.once("spawn",()=>{c.once("close",h=>{if(c.off("error",d),h!==0){d(new Error(`Exited with code ${h}`));return}c.unref(),u(c)})})}):(c.unref(),new Promise((u,d)=>{c.once("error",d),c.once("spawn",()=>{c.off("error",d),u(c)})}))},qm=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a `target`");return is({...e,target:t})};function Ga(t){if(typeof t=="string"||Array.isArray(t))return t;let{[za]:e}=t;if(!e)throw new Error(`${za} is not supported`);return e}function yr({[Ht]:t},{wsl:e}={}){if(e&&ze)return Ga(e);if(!t)throw new Error(`${Ht} is not supported`);return Ga(t)}var Jt={browser:"browser",browserPrivate:"browserPrivate"};Rt(Jt,"chrome",()=>yr({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));Rt(Jt,"brave",()=>yr({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));Rt(Jt,"firefox",()=>yr({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Rt(Jt,"edge",()=>yr({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Rt(Jt,"safari",()=>yr({darwin:"Safari"}));var Za=qm;var Um=f.object({device_code:f.string(),user_code:f.string(),verification_uri:f.string(),expires_in:f.number(),interval:f.number()}),zm=f.object({token:f.string(),username:f.string()}),Vm=f.object({error:f.string().optional(),message:f.string().optional(),status:f.string().optional()});async function Ya(){let t=new ve;v.log(K(K(`Initiating GitHub authentication...
|
|
216
|
+
`)));try{let e=await fetch(`${Ct()}/auth/device/init`,{method:"POST"});if(!e.ok)throw v.error("Failed to initiate authentication"),new Error("Device flow initialization failed");let r=await e.json(),s=Um.safeParse(r);if(!s.success)throw v.error("Invalid response from authentication server"),console.error(rt.dim("Validation error:"),s.error.message),new Error("Device flow initialization failed");let{device_code:n,user_code:i,verification_uri:o,expires_in:a,interval:c}=s.data;console.log(rt.bold(`Please visit: ${rt.cyan(o)}`)),console.log(rt.bold(`
|
|
217
|
+
Enter code: ${rt.green(i)}
|
|
218
|
+
`)),v.log(K(`Opening browser...
|
|
219
|
+
`)),await Za(o);let d=Date.now()+a*1e3;for(v.log(K("Waiting for authorization..."));Date.now()<d;){await new Promise(p=>setTimeout(p,c*1e3));let h=await fetch(`${Ct()}/auth/device/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:n})});if(h.status===200){let p=await h.json(),l=zm.safeParse(p);if(!l.success)throw v.error("Invalid response from server"),console.error(rt.dim("Validation error:"),l.error.message),new Error("Missing token or username in response");let{token:g,username:w}=l.data;await t.store(g),v.log(K(rt.green(`
|
|
220
|
+
\u2713 Logged in as ${rt.bold(w)}`)));return}if(h.status!==202&&h.status===400){let p=await h.json(),l=Vm.safeParse(p),g=l.success&&(l.data.message||l.data.error)||"Unknown error";throw v.error(`Authentication failed: ${g}`),new Error("Authentication failed")}}throw v.error("Authentication timed out"),new Error("Authentication timed out")}catch(e){throw e instanceof Error?e:new Error("Authentication failed")}}import Gm from"chalk";async function Xa(){await new ve().delete(),v.log(Gm.green("\u2713 Logged out"))}import Zt from"chalk";var Hm=f.object({login:f.string()});async function Ka(){let e=await new ve().get();if(!e){console.log(Zt.dim("Not logged in")),console.log(`Run: ${H("spectrl login")}`);return}try{let r=await fetch("https://api.github.com/user",{headers:{Authorization:`Bearer ${e}`}});if(!r.ok){console.log(Zt.yellow("Token invalid")),console.log(`Run: ${H("spectrl login")}`);return}let s=await r.json(),n=Hm.safeParse(s);if(!n.success){console.log(Zt.red("\u2717 Invalid response from GitHub API")),console.log(`Run: ${H("spectrl login")}`);return}let i=n.data;console.log(Zt.green(`Logged in as ${Zt.bold(i.login)}`))}catch{console.log(Zt.red("\u2717 Failed to verify token")),console.log(`Run: ${H("spectrl login")}`)}}import os from"chalk";import{select as Jm}from"@inquirer/prompts";async function Qa(t){try{let e;try{e=_e(t)}catch(u){throw new m(`Invalid spec reference: ${u instanceof Error?u.message:String(u)}`,D.VALIDATION_ERROR)}if(!e.isPublic||!e.username)throw new m("Unpublish only works with public specs. Use format: username/spec@version",D.VALIDATION_ERROR);if(!e.version)throw new m(["Version is required for unpublish","",`Usage: spectrl unpublish ${S(`${e.username}/${e.name}@<version>`)}`,"","Example: spectrl unpublish alice/api-spec@1.0.0"].join(`
|
|
221
|
+
`),D.VALIDATION_ERROR);let{username:r,name:s,version:n}=e,i=qt(r,s,n),a=await new ve().get();if(!a)throw new m(`You need to login first to unpublish specs
|
|
222
|
+
|
|
223
|
+
Run: ${H("spectrl login")}`,D.AUTHENTICATION_ERROR);if(v.log(""),v.log(os.yellow(`\u26A0\uFE0F This will permanently delete ${S(i)} from the public registry.`)),v.log(""),!await Jm({message:"Are you sure you want to continue?",choices:[{name:"No, cancel",value:!1,description:"Keep the spec and abort"},{name:`Yes, delete ${i}`,value:!0,description:"Permanently remove this version from the registry"}],default:!1})){v.log(os.dim("Cancelled"));return}v.log(""),v.log(os.dim(`Unpublishing ${S(i)}...`));try{let u=await pa(a,r,s,n);v.log(""),v.log(os.green(`\u2713 ${u.message}`)),v.log("")}catch(u){throw u instanceof V?u.statusCode===401||u.statusCode===403?new m(["Authentication failed","","Your token may have expired or you may not have permission to unpublish this spec.","","Try logging in again: spectrl login"].join(`
|
|
224
|
+
`),D.AUTHENTICATION_ERROR):u.statusCode===404?new m(`Spec version ${S(i)} not found in the registry`,D.DEPENDENCY_ERROR):new m(`Failed to unpublish: ${u.message}`,D.IO_ERROR):u}}catch(e){throw e instanceof m?e:new m(`Unpublish failed: ${e instanceof Error?e.message:String(e)}`,D.IO_ERROR)}}var eu=_t(Cr(),1),ds=_t(Bs(),1);import Z from"chalk";import{promises as tu}from"node:fs";import Og from"fs-extra";async function Fn(t){try{let e=le(t),r=await tu.readFile(e,"utf-8");return JSON.parse(r)}catch(e){throw e.code==="ENOENT"?new m(`Project not initialized
|
|
225
|
+
|
|
226
|
+
Run: ${H("spectrl init")}`,D.VALIDATION_ERROR):new m(`Failed to read project index: ${e instanceof Error?e.message:String(e)}`,D.IO_ERROR)}}async function kg(t){let e=await Fn(t),r=[],s=Object.entries(e).filter(([n,i])=>i.source.startsWith("https://")||i.source.startsWith("http://"));if(s.length===0)return[];for(let[n]of s)try{let i=_e(n);if(!i.isPublic||!i.username||!i.version)continue;let{username:o,name:a,version:c}=i,u=await bt(o,a);if(u.versions.length===0)continue;let d=u.versions[0].version;ds.default.valid(c)&&ds.default.valid(d)&&ds.default.gt(d,c)&&r.push({specKey:n,username:o,name:a,currentVersion:c,latestVersion:d})}catch{}return r}async function Rn(t,e,r,s){let n=await Fn(s),i=Object.keys(n).filter(o=>{let a=_e(o);return a.isPublic&&a.username===t&&a.name===e});if(await Qs({username:t,name:e,version:r},{cwd:s}),i.length>0){let o=le(s),a=await Fn(s);for(let c of i){if(c===qt(t,e,r))continue;delete a[c];let u=_e(c);if(u.version){let d=Yr(s,t,e,u.version);try{await Og.remove(d)}catch{}}}await tu.writeFile(o,`${JSON.stringify(a,null,2)}
|
|
227
|
+
`,"utf-8")}}async function ru(t,e={}){let r=e.cwd||process.cwd();try{if(t)return await Tg(t,r);v.log(Z.dim(`Checking for updates...
|
|
228
|
+
`));let s=await kg(r);if(s.length===0){v.log(Z.green(`\u2713 All specs are up to date
|
|
229
|
+
`));return}v.log(Z.bold(`Updates available:
|
|
230
|
+
`));let n=new eu.default({head:[Z.cyan("Spec"),Z.cyan("Installed"),Z.cyan("Latest")],colWidths:[30,15,15],style:{head:[],border:["dim"]}});for(let{username:i,name:o,currentVersion:a,latestVersion:c}of s)n.push([Z.bold(`${i}/${o}`),Z.yellow(a),Z.green(c)]);if(v.log(n.toString()),v.log(""),v.log(Z.dim("Run 'spectrl update <spec>' to update a specific spec")),v.log(Z.dim(`Run 'spectrl update --all' to update all specs
|
|
231
|
+
`)),e.all){v.log(Z.bold(`Updating all specs...
|
|
232
|
+
`));for(let{username:i,name:o,latestVersion:a}of s)v.log(Z.dim(`Updating ${S(`${i}/${o}`)}...`)),await Rn(i,o,a,r);v.log(""),v.log(Z.green(`\u2713 Updated ${s.length} spec${s.length===1?"":"s"}
|
|
233
|
+
`))}}catch(s){throw s instanceof m?s:new m(`Update failed: ${s instanceof Error?s.message:String(s)}`,D.IO_ERROR)}}async function Tg(t,e){try{let r=_e(t);if(!r.isPublic||!r.username)throw new m("Update only works with public specs. Use format: username/spec or username/spec@version",D.VALIDATION_ERROR);let{username:s,name:n,version:i}=r;if(i){v.log(Z.dim(`Updating to ${S(`${s}/${n}@${i}`)}...
|
|
234
|
+
`)),await Rn(s,n,i,e),v.log(""),v.log(Z.green(`\u2713 Updated to ${S(`${s}/${n}@${i}`)}
|
|
235
|
+
`));return}v.log(Z.dim(`Fetching latest version of ${S(`${s}/${n}`)}...
|
|
236
|
+
`));try{let o=await bt(s,n);if(o.versions.length===0)throw new m(`No versions available for ${S(`${s}/${n}`)}`,D.DEPENDENCY_ERROR);let a=o.versions[0].version;v.log(Z.dim(`Updating to ${S(`${s}/${n}@${a}`)}...
|
|
237
|
+
`)),await Rn(s,n,a,e),v.log(""),v.log(Z.green(`\u2713 Updated to ${S(`${s}/${n}@${a}`)}
|
|
238
|
+
`))}catch(o){throw o instanceof V&&o.statusCode===404?new m(`Spec ${S(`${s}/${n}`)} not found in public registry`,D.DEPENDENCY_ERROR):o}}catch(r){throw r instanceof m?r:new m(`Update failed: ${r instanceof Error?r.message:String(r)}`,D.IO_ERROR)}}var su=_t(Cr(),1);import Ce from"chalk";async function nu(t){if(!t||t.trim().length===0)throw new m("Search query cannot be empty",D.VALIDATION_ERROR);try{let e=await fa(t.trim());if(e.results.length===0){console.log(Ce.yellow(`
|
|
239
|
+
No specs found`)),console.log(Ce.dim("Try a different search term or browse all specs")),console.log(`Example: ${H("spectrl search api")}
|
|
240
|
+
`);return}let r=e.results.length;console.log(Ce.bold(`
|
|
241
|
+
Found ${r} spec${r===1?"":"s"} matching "${t}":
|
|
242
|
+
`));let s=new su.default({head:[Ce.cyan("Spec"),Ce.cyan("Description"),Ce.cyan("Tags"),Ce.cyan("Version")],colWidths:[35,40,18,10],wordWrap:!0,style:{head:[],border:["dim"]}});for(let n of e.results){let i=n.specId||Ce.dim("unknown"),o=n.description||Ce.dim("No description"),a=n.tags&&n.tags.length>0?n.tags.join(", "):Ce.dim("none"),c=n.version||Ce.dim("unknown");s.push([Ce.bold(i),o,a,c])}console.log(s.toString()),console.log(`
|
|
243
|
+
Install with: ${H("spectrl install <spec>")}`),console.log(`Example: ${H("spectrl install alice/api-spec")}
|
|
244
|
+
`)}catch(e){throw e instanceof m?e:e instanceof Error?new m(`Search failed: ${e.message}`,D.IO_ERROR):new m("Unknown error during search",D.IO_ERROR)}}var bu=_t(Cr(),1);import st from"chalk";var Pg=Math.pow(10,8)*24*60*60*1e3,qv=-Pg;var br=43200,Sn=1440;var Ng=3600;var iu=Ng*24,Uv=iu*7,Lg=iu*365.2425,Mg=Lg/12,zv=Mg*3,_n=Symbol.for("constructDateFrom");function Kt(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&_n in t?t[_n](e):t instanceof Date?new t.constructor(e):new Date(e)}function de(t,e){return Kt(e||t,t)}var jg={};function ou(){return jg}function An(t){let e=de(t),r=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return r.setUTCFullYear(e.getFullYear()),+t-+r}function Qt(t,...e){let r=Kt.bind(null,t||e.find(s=>typeof s=="object"));return e.map(r)}function er(t,e){let r=+de(t)-+de(e);return r<0?-1:r>0?1:r}function au(t){return Kt(t,Date.now())}function cu(t,e,r){let[s,n]=Qt(r?.in,t,e),i=s.getFullYear()-n.getFullYear(),o=s.getMonth()-n.getMonth();return i*12+o}function uu(t){return e=>{let s=(t?Math[t]:Math.trunc)(e);return s===0?0:s}}function lu(t,e){return+de(t)-+de(e)}function du(t,e){let r=de(t,e?.in);return r.setHours(23,59,59,999),r}function fu(t,e){let r=de(t,e?.in),s=r.getMonth();return r.setFullYear(r.getFullYear(),s+1,0),r.setHours(23,59,59,999),r}function pu(t,e){let r=de(t,e?.in);return+du(r,e)==+fu(r,e)}function hu(t,e,r){let[s,n,i]=Qt(r?.in,t,t,e),o=er(n,i),a=Math.abs(cu(n,i));if(a<1)return 0;n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-o*a);let c=er(n,i)===-o;pu(s)&&a===1&&er(s,i)===1&&(c=!1);let u=o*(a-+c);return u===0?0:u}function mu(t,e,r){let s=lu(t,e)/1e3;return uu(r?.roundingMethod)(s)}var Bg={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},gu=(t,e,r)=>{let s,n=Bg[t];return typeof n=="string"?s=n:e===1?s=n.one:s=n.other.replace("{{count}}",e.toString()),r?.addSuffix?r.comparison&&r.comparison>0?"in "+s:s+" ago":s};function fs(t){return(e={})=>{let r=e.width?String(e.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}var Wg={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},qg={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Ug={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Du={date:fs({formats:Wg,defaultWidth:"full"}),time:fs({formats:qg,defaultWidth:"full"}),dateTime:fs({formats:Ug,defaultWidth:"full"})};var zg={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},yu=(t,e,r,s)=>zg[t];function tr(t){return(e,r)=>{let s=r?.context?String(r.context):"standalone",n;if(s==="formatting"&&t.formattingValues){let o=t.defaultFormattingWidth||t.defaultWidth,a=r?.width?String(r.width):o;n=t.formattingValues[a]||t.formattingValues[o]}else{let o=t.defaultWidth,a=r?.width?String(r.width):t.defaultWidth;n=t.values[a]||t.values[o]}let i=t.argumentCallback?t.argumentCallback(e):e;return n[i]}}var Vg={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Gg={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Hg={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Jg={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Zg={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Yg={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Xg=(t,e)=>{let r=Number(t),s=r%100;if(s>20||s<10)switch(s%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},wu={ordinalNumber:Xg,era:tr({values:Vg,defaultWidth:"wide"}),quarter:tr({values:Gg,defaultWidth:"wide",argumentCallback:t=>t-1}),month:tr({values:Hg,defaultWidth:"wide"}),day:tr({values:Jg,defaultWidth:"wide"}),dayPeriod:tr({values:Zg,defaultWidth:"wide",formattingValues:Yg,defaultFormattingWidth:"wide"})};function rr(t){return(e,r={})=>{let s=r.width,n=s&&t.matchPatterns[s]||t.matchPatterns[t.defaultMatchWidth],i=e.match(n);if(!i)return null;let o=i[0],a=s&&t.parsePatterns[s]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(a)?Qg(a,h=>h.test(o)):Kg(a,h=>h.test(o)),u;u=t.valueCallback?t.valueCallback(c):c,u=r.valueCallback?r.valueCallback(u):u;let d=e.slice(o.length);return{value:u,rest:d}}}function Kg(t,e){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&e(t[r]))return r}function Qg(t,e){for(let r=0;r<t.length;r++)if(e(t[r]))return r}function Eu(t){return(e,r={})=>{let s=e.match(t.matchPattern);if(!s)return null;let n=s[0],i=e.match(t.parsePattern);if(!i)return null;let o=t.valueCallback?t.valueCallback(i[0]):i[0];o=r.valueCallback?r.valueCallback(o):o;let a=e.slice(n.length);return{value:o,rest:a}}}var eD=/^(\d+)(th|st|nd|rd)?/i,tD=/\d+/i,rD={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},sD={any:[/^b/i,/^(a|c)/i]},nD={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},iD={any:[/1/i,/2/i,/3/i,/4/i]},oD={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},aD={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},cD={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},uD={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},lD={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},dD={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},xu={ordinalNumber:Eu({matchPattern:eD,parsePattern:tD,valueCallback:t=>parseInt(t,10)}),era:rr({matchPatterns:rD,defaultMatchWidth:"wide",parsePatterns:sD,defaultParseWidth:"any"}),quarter:rr({matchPatterns:nD,defaultMatchWidth:"wide",parsePatterns:iD,defaultParseWidth:"any",valueCallback:t=>t+1}),month:rr({matchPatterns:oD,defaultMatchWidth:"wide",parsePatterns:aD,defaultParseWidth:"any"}),day:rr({matchPatterns:cD,defaultMatchWidth:"wide",parsePatterns:uD,defaultParseWidth:"any"}),dayPeriod:rr({matchPatterns:lD,defaultMatchWidth:"any",parsePatterns:dD,defaultParseWidth:"any"})};var $n={code:"en-US",formatDistance:gu,formatLong:Du,formatRelative:yu,localize:wu,match:xu,options:{weekStartsOn:0,firstWeekContainsDate:1}};function vu(t,e,r){let s=ou(),n=r?.locale??s.locale??$n,i=2520,o=er(t,e);if(isNaN(o))throw new RangeError("Invalid time value");let a=Object.assign({},r,{addSuffix:r?.addSuffix,comparison:o}),[c,u]=Qt(r?.in,...o>0?[e,t]:[t,e]),d=mu(u,c),h=(An(u)-An(c))/1e3,p=Math.round((d-h)/60),l;if(p<2)return r?.includeSeconds?d<5?n.formatDistance("lessThanXSeconds",5,a):d<10?n.formatDistance("lessThanXSeconds",10,a):d<20?n.formatDistance("lessThanXSeconds",20,a):d<40?n.formatDistance("halfAMinute",0,a):d<60?n.formatDistance("lessThanXMinutes",1,a):n.formatDistance("xMinutes",1,a):p===0?n.formatDistance("lessThanXMinutes",1,a):n.formatDistance("xMinutes",p,a);if(p<45)return n.formatDistance("xMinutes",p,a);if(p<90)return n.formatDistance("aboutXHours",1,a);if(p<Sn){let g=Math.round(p/60);return n.formatDistance("aboutXHours",g,a)}else{if(p<i)return n.formatDistance("xDays",1,a);if(p<br){let g=Math.round(p/Sn);return n.formatDistance("xDays",g,a)}else if(p<br*2)return l=Math.round(p/br),n.formatDistance("aboutXMonths",l,a)}if(l=hu(u,c),l<12){let g=Math.round(p/br);return n.formatDistance("xMonths",g,a)}else{let g=l%12,w=Math.trunc(l/12);return g<3?n.formatDistance("aboutXYears",w,a):g<9?n.formatDistance("overXYears",w,a):n.formatDistance("almostXYears",w+1,a)}}function Cu(t,e){return vu(t,au(t),e)}async function Fu(t){let e;try{e=_e(t)}catch(r){throw r instanceof Error?new m(`Invalid spec reference: ${r.message}`,D.VALIDATION_ERROR):new m("Invalid spec reference format",D.VALIDATION_ERROR)}if(!e.isPublic||!e.username)throw new m("Info command requires a public spec reference (username/spec)",D.VALIDATION_ERROR);try{let r=await bt(e.username,e.name);if(console.log(st.bold.cyan(`
|
|
245
|
+
${r.specId}`)),r.versions.length>0&&r.versions[0].description&&console.log(r.versions[0].description),r.versions.length>0&&r.versions[0].tags&&r.versions[0].tags.length>0&&console.log(st.dim(`
|
|
246
|
+
Tags: ${r.versions[0].tags.join(", ")}`)),r.versions.length===0)console.log(st.yellow(`
|
|
247
|
+
No versions available`));else{console.log(st.bold(`
|
|
248
|
+
Versions:`));let s=new bu.default({head:[st.cyan("Version"),st.cyan("Published"),st.cyan("Downloads")],colWidths:[12,30,15],style:{head:[],border:["dim"]}});for(let n of r.versions){let i=new Date(n.publishedAt),o=Cu(i,{addSuffix:!0}),a=`${i.toISOString().split("T")[0]} (${o})`,c=n.downloads?.toString()||"0";s.push([st.bold(n.version),a,c])}console.log(s.toString())}console.log(`
|
|
249
|
+
Install latest: ${H(`spectrl install ${r.specId}`)}`),console.log(`Install specific: ${H(`spectrl install ${r.specId}@<version>`)}
|
|
250
|
+
`)}catch(r){throw r instanceof m?r:r instanceof V?r.statusCode===404?new m(`Spec not found: ${e.username}/${e.name}`,D.IO_ERROR):new m(`Failed to get spec info: ${r.message}`,D.IO_ERROR):r instanceof Error?new m(`Failed to get spec info: ${r.message}`,D.IO_ERROR):new m("Unknown error while fetching spec info",D.IO_ERROR)}}var Ru=_t(Cr(),1);import be from"chalk";import{promises as fD}from"node:fs";async function Su(t={}){let e=t.cwd||process.cwd();try{let r=le(e);if(!await Ue(r))throw new m('Project not initialized. Run "spectrl init" to set up dependency management.',D.VALIDATION_ERROR);let s=await fD.readFile(r,"utf-8"),n=JSON.parse(s),i=Object.entries(n);if(i.length===0){console.log(be.yellow(`
|
|
251
|
+
No specs installed`)),console.log(be.dim("Install a spec with: spectrl install <spec>")),console.log(be.dim(`Example: spectrl install alice/api-spec
|
|
252
|
+
`));return}console.log(be.bold(`
|
|
253
|
+
Installed specs:
|
|
254
|
+
`));let o=new Ru.default({head:[be.cyan("Spec"),be.cyan("Version"),be.cyan("Source")],colWidths:[35,12,12],style:{head:[],border:["dim"]}});for(let[c,u]of i){let h=u.source.startsWith("https://")||u.source.startsWith("http://")?be.blue("public"):be.green("local"),p=c.lastIndexOf("@"),l,g;p!==-1?(l=c.substring(0,p),g=c.substring(p+1)):(l=c,g=be.dim("unknown")),o.push([be.bold(l),g,h])}console.log(o.toString());let a=i.length;console.log(be.dim(`
|
|
255
|
+
${a} spec${a===1?"":"s"} installed
|
|
256
|
+
`))}catch(r){throw r instanceof m?r:r instanceof SyntaxError?new m('Project index is corrupted. Try running "spectrl init" to reinitialize.',D.VALIDATION_ERROR):r instanceof Error?new m(`Failed to read project index: ${r.message}`,D.IO_ERROR):new m("Unknown error while listing specs",D.IO_ERROR)}}import Ne from"chalk";import{readFileSync as mD}from"node:fs";import{fileURLToPath as gD}from"node:url";import{dirname as DD,join as yD}from"node:path";var wD=DD(gD(import.meta.url)),ED=JSON.parse(mD(yD(wD,"../package.json"),"utf-8")),_u=ED.version,xD=Fe({name:"init",description:"Initialize a new project with a local spec index",args:{skipAgents:On({long:"skip-agents",description:"Skip AGENTS.md creation/update entirely",defaultValue:()=>!1}),forceAgents:On({long:"force-agents",description:"Force overwrite AGENTS.md with fresh template",defaultValue:()=>!1})},handler:async t=>{await ia(process.cwd(),{skipAgents:t.skipAgents,forceAgents:t.forceAgents})}}),vD=Fe({name:"publish",description:"Publish a spec to the local registry",args:{},handler:async()=>{await ga(process.cwd())}}),CD=Fe({name:"install",description:"Install specs using symlinks to the registry. Creates links from .spectrl/specs/{name}@{version}/ to the registry. On Windows, uses junction points (no admin required). Falls back to file copying if symlinks fail.",args:{specRef:sr({type:Fr(Ge),displayName:"spec",description:"Optional spec reference (name@version) to install from registry"})},handler:async t=>{t.specRef?await Sa(t.specRef,{cwd:process.cwd()}):await _a({cwd:process.cwd()})}}),bD=Fe({name:"new",description:"Create a new spec or power (defaults to spec)",args:{name:sr({type:Ge,displayName:"name",description:"Name (lowercase alphanumeric with hyphens)"}),type:In({type:Fr(Ge),long:"type",description:"Content type: spec or power (default: spec)",defaultValue:()=>"spec"}),version:In({type:Fr(Ge),long:"version",description:"Initial version (default: 0.1.0)",defaultValue:()=>"0.1.0"}),description:In({type:Fr(Ge),long:"description",description:"Description"})},handler:async t=>{let e=t.type==="power"?"power":"spec";await $a(t.name,process.cwd(),e,t.version,t.description)}}),FD=Fe({name:"login",description:"Authenticate with GitHub to access the public registry",args:{},handler:async()=>{await Ya()}}),RD=Fe({name:"logout",description:"Remove stored GitHub authentication token",args:{},handler:async()=>{await Xa()}}),SD=Fe({name:"whoami",description:"Show current authenticated GitHub user",args:{},handler:async()=>{await Ka()}}),_D=Fe({name:"unpublish",description:"Remove a spec version from the public registry (requires authentication)",args:{specRef:sr({type:Ge,displayName:"spec",description:"Spec reference in format username/spec@version"})},handler:async t=>{await Qa(t.specRef)}}),AD=Fe({name:"update",description:"Check for and install updates for public specs",args:{specRef:sr({type:Fr(Ge),displayName:"spec",description:"Optional spec reference to update (username/spec or username/spec@version)"}),all:On({long:"all",description:"Update all specs with available updates",defaultValue:()=>!1})},handler:async t=>{await ru(t.specRef,{all:t.all,cwd:process.cwd()})}}),$D=Fe({name:"search",description:"Search for specs in the public registry",args:{query:sr({type:Ge,displayName:"query",description:"Search query (keywords, tags, or spec names)"})},handler:async t=>{await nu(t.query)}}),ID=Fe({name:"info",description:"Show detailed information about a spec from the public registry",args:{specRef:sr({type:Ge,displayName:"spec",description:"Spec reference in format username/spec"})},handler:async t=>{await Fu(t.specRef)}}),OD=Fe({name:"list",description:"Show all installed specs (local and public)",args:{},handler:async()=>{await Su({cwd:process.cwd()})}}),kD=pD({name:"spectrl",description:"Local-first spec registry",version:_u,cmds:{init:xD,new:bD,publish:vD,install:CD,login:FD,logout:RD,whoami:SD,unpublish:_D,update:AD,search:$D,info:ID,list:OD}});function TD(){let t=[["init","Initialize a new project with a local spec index"],["new","Create a new spec with a manifest template"],["publish","Publish a spec to the local registry"],["install","Install specs from the registry into .spectrl/specs/"],["login","Authenticate with GitHub to access the public registry"],["logout","Remove stored GitHub authentication token"],["whoami","Show current authenticated GitHub user"],["unpublish","Remove a spec version from the public registry"],["update","Check for and install updates for public specs"],["search","Search for specs in the public registry"],["info","Show detailed information about a spec"],["list","Show all installed specs (local and public)"]],e=Math.max(...t.map(([r])=>r.length))+2;v.log(""),v.log(` ${Ne.bold("spectrl")} ${Ne.dim(`v${_u}`)} ${Ne.dim("\xB7")} Local-first spec registry`),v.log(""),v.log(` ${Ne.dim("Usage:")} spectrl ${Ne.cyan("<command>")} ${Ne.dim("[options]")}`),v.log(""),v.log(` ${Ne.dim("Commands:")}`),v.log("");for(let[r,s]of t)v.log(` ${Ne.cyan(r.padEnd(e))}${Ne.dim(s)}`);v.log(""),v.log(` Run ${Ne.cyan("spectrl <command> --help")} for command-specific options.`),v.log("")}async function PD(){let t=process.argv.slice(2);(t.length===0||t[0]==="--help"||t[0]==="-h")&&(TD(),process.exit(t.length===0?1:0));try{await hD(kD,t)}catch(e){e instanceof m&&(v.error(hs(e)),process.exit(e.exitCode)),e instanceof Error&&(v.error(hs(e)),process.exit(Tn(e))),v.error("Unknown error occurred"),process.exit(1)}}PD();process.stdout.isTTY&&!process.env.NO_COLOR&&(process.env.FORCE_COLOR=process.env.FORCE_COLOR??"3");
|