@spectrl/cli 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +208 -248
  2. package/package.json +3 -2
package/dist/cli.js CHANGED
@@ -1,296 +1,256 @@
1
1
  #!/usr/bin/env node
2
- var uc=Object.create;var as=Object.defineProperty;var cc=Object.getOwnPropertyDescriptor;var lc=Object.getOwnPropertyNames;var dc=Object.getPrototypeOf,fc=Object.prototype.hasOwnProperty;var bn=(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 F=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),pc=(t,e)=>{for(var r in e)as(t,r,{get:e[r],enumerable:!0})},hc=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of lc(e))!fc.call(t,n)&&n!==r&&as(t,n,{get:()=>e[n],enumerable:!(s=cc(e,n))||s.enumerable});return t};var Ft=(t,e,r)=>(r=t!=null?uc(dc(t)):{},hc(e||!t||!t.__esModule?as(r,"default",{value:t,enumerable:!0}):r,t));var ir=F((ly,Mn)=>{"use strict";var Ll="2.0.0",jl=Number.MAX_SAFE_INTEGER||9007199254740991,Ml=16,Bl=250,ql=["major","premajor","minor","preminor","patch","prepatch","prerelease"];Mn.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:Ml,MAX_SAFE_BUILD_LENGTH:Bl,MAX_SAFE_INTEGER:jl,RELEASE_TYPES:ql,SEMVER_SPEC_VERSION:Ll,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var or=F((dy,Bn)=>{"use strict";var Wl=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};Bn.exports=Wl});var Pt=F((Pe,qn)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:ps,MAX_SAFE_BUILD_LENGTH:Ul,MAX_LENGTH:zl}=ir(),Vl=or();Pe=qn.exports={};var Gl=Pe.re=[],Hl=Pe.safeRe=[],b=Pe.src=[],Yl=Pe.safeSrc=[],C=Pe.t={},Zl=0,hs="[a-zA-Z0-9-]",Xl=[["\\s",1],["\\d",zl],[hs,Ul]],Jl=t=>{for(let[e,r]of Xl)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t},O=(t,e,r)=>{let s=Jl(e),n=Zl++;Vl(t,n,e),C[t]=n,b[n]=e,Yl[n]=s,Gl[n]=new RegExp(e,r?"g":void 0),Hl[n]=new RegExp(s,r?"g":void 0)};O("NUMERICIDENTIFIER","0|[1-9]\\d*");O("NUMERICIDENTIFIERLOOSE","\\d+");O("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${hs}*`);O("MAINVERSION",`(${b[C.NUMERICIDENTIFIER]})\\.(${b[C.NUMERICIDENTIFIER]})\\.(${b[C.NUMERICIDENTIFIER]})`);O("MAINVERSIONLOOSE",`(${b[C.NUMERICIDENTIFIERLOOSE]})\\.(${b[C.NUMERICIDENTIFIERLOOSE]})\\.(${b[C.NUMERICIDENTIFIERLOOSE]})`);O("PRERELEASEIDENTIFIER",`(?:${b[C.NONNUMERICIDENTIFIER]}|${b[C.NUMERICIDENTIFIER]})`);O("PRERELEASEIDENTIFIERLOOSE",`(?:${b[C.NONNUMERICIDENTIFIER]}|${b[C.NUMERICIDENTIFIERLOOSE]})`);O("PRERELEASE",`(?:-(${b[C.PRERELEASEIDENTIFIER]}(?:\\.${b[C.PRERELEASEIDENTIFIER]})*))`);O("PRERELEASELOOSE",`(?:-?(${b[C.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${b[C.PRERELEASEIDENTIFIERLOOSE]})*))`);O("BUILDIDENTIFIER",`${hs}+`);O("BUILD",`(?:\\+(${b[C.BUILDIDENTIFIER]}(?:\\.${b[C.BUILDIDENTIFIER]})*))`);O("FULLPLAIN",`v?${b[C.MAINVERSION]}${b[C.PRERELEASE]}?${b[C.BUILD]}?`);O("FULL",`^${b[C.FULLPLAIN]}$`);O("LOOSEPLAIN",`[v=\\s]*${b[C.MAINVERSIONLOOSE]}${b[C.PRERELEASELOOSE]}?${b[C.BUILD]}?`);O("LOOSE",`^${b[C.LOOSEPLAIN]}$`);O("GTLT","((?:<|>)?=?)");O("XRANGEIDENTIFIERLOOSE",`${b[C.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);O("XRANGEIDENTIFIER",`${b[C.NUMERICIDENTIFIER]}|x|X|\\*`);O("XRANGEPLAIN",`[v=\\s]*(${b[C.XRANGEIDENTIFIER]})(?:\\.(${b[C.XRANGEIDENTIFIER]})(?:\\.(${b[C.XRANGEIDENTIFIER]})(?:${b[C.PRERELEASE]})?${b[C.BUILD]}?)?)?`);O("XRANGEPLAINLOOSE",`[v=\\s]*(${b[C.XRANGEIDENTIFIERLOOSE]})(?:\\.(${b[C.XRANGEIDENTIFIERLOOSE]})(?:\\.(${b[C.XRANGEIDENTIFIERLOOSE]})(?:${b[C.PRERELEASELOOSE]})?${b[C.BUILD]}?)?)?`);O("XRANGE",`^${b[C.GTLT]}\\s*${b[C.XRANGEPLAIN]}$`);O("XRANGELOOSE",`^${b[C.GTLT]}\\s*${b[C.XRANGEPLAINLOOSE]}$`);O("COERCEPLAIN",`(^|[^\\d])(\\d{1,${ps}})(?:\\.(\\d{1,${ps}}))?(?:\\.(\\d{1,${ps}}))?`);O("COERCE",`${b[C.COERCEPLAIN]}(?:$|[^\\d])`);O("COERCEFULL",b[C.COERCEPLAIN]+`(?:${b[C.PRERELEASE]})?(?:${b[C.BUILD]})?(?:$|[^\\d])`);O("COERCERTL",b[C.COERCE],!0);O("COERCERTLFULL",b[C.COERCEFULL],!0);O("LONETILDE","(?:~>?)");O("TILDETRIM",`(\\s*)${b[C.LONETILDE]}\\s+`,!0);Pe.tildeTrimReplace="$1~";O("TILDE",`^${b[C.LONETILDE]}${b[C.XRANGEPLAIN]}$`);O("TILDELOOSE",`^${b[C.LONETILDE]}${b[C.XRANGEPLAINLOOSE]}$`);O("LONECARET","(?:\\^)");O("CARETTRIM",`(\\s*)${b[C.LONECARET]}\\s+`,!0);Pe.caretTrimReplace="$1^";O("CARET",`^${b[C.LONECARET]}${b[C.XRANGEPLAIN]}$`);O("CARETLOOSE",`^${b[C.LONECARET]}${b[C.XRANGEPLAINLOOSE]}$`);O("COMPARATORLOOSE",`^${b[C.GTLT]}\\s*(${b[C.LOOSEPLAIN]})$|^$`);O("COMPARATOR",`^${b[C.GTLT]}\\s*(${b[C.FULLPLAIN]})$|^$`);O("COMPARATORTRIM",`(\\s*)${b[C.GTLT]}\\s*(${b[C.LOOSEPLAIN]}|${b[C.XRANGEPLAIN]})`,!0);Pe.comparatorTrimReplace="$1$2$3";O("HYPHENRANGE",`^\\s*(${b[C.XRANGEPLAIN]})\\s+-\\s+(${b[C.XRANGEPLAIN]})\\s*$`);O("HYPHENRANGELOOSE",`^\\s*(${b[C.XRANGEPLAINLOOSE]})\\s+-\\s+(${b[C.XRANGEPLAINLOOSE]})\\s*$`);O("STAR","(<|>)?=?\\s*\\*");O("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");O("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var kr=F((fy,Wn)=>{"use strict";var Kl=Object.freeze({loose:!0}),Ql=Object.freeze({}),ed=t=>t?typeof t!="object"?Kl:t:Ql;Wn.exports=ed});var ms=F((py,Vn)=>{"use strict";var Un=/^[0-9]+$/,zn=(t,e)=>{if(typeof t=="number"&&typeof e=="number")return t===e?0:t<e?-1:1;let r=Un.test(t),s=Un.test(e);return r&&s&&(t=+t,e=+e),t===e?0:r&&!s?-1:s&&!r?1:t<e?-1:1},td=(t,e)=>zn(e,t);Vn.exports={compareIdentifiers:zn,rcompareIdentifiers:td}});var te=F((hy,Hn)=>{"use strict";var Or=or(),{MAX_LENGTH:Gn,MAX_SAFE_INTEGER:Tr}=ir(),{safeRe:Pr,t:Nr}=Pt(),rd=kr(),{compareIdentifiers:Ds}=ms(),gs=class t{constructor(e,r){if(r=rd(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>Gn)throw new TypeError(`version is longer than ${Gn} characters`);Or("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;let s=e.trim().match(r.loose?Pr[Nr.LOOSE]:Pr[Nr.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>Tr||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Tr||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Tr||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<Tr)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(Or("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(Or("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 Ds(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(Or("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 Ds(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?Pr[Nr.PRERELEASELOOSE]:Pr[Nr.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]),Ds(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}};Hn.exports=gs});var yt=F((my,Zn)=>{"use strict";var Yn=te(),sd=(t,e,r=!1)=>{if(t instanceof Yn)return t;try{return new Yn(t,e)}catch(s){if(!r)return null;throw s}};Zn.exports=sd});var Jn=F((Dy,Xn)=>{"use strict";var nd=yt(),id=(t,e)=>{let r=nd(t,e);return r?r.version:null};Xn.exports=id});var Qn=F((gy,Kn)=>{"use strict";var od=yt(),ad=(t,e)=>{let r=od(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null};Kn.exports=ad});var ri=F((yy,ti)=>{"use strict";var ei=te(),ud=(t,e,r,s,n)=>{typeof r=="string"&&(n=s,s=r,r=void 0);try{return new ei(t instanceof ei?t.version:t,r).inc(e,s,n).version}catch{return null}};ti.exports=ud});var ii=F((wy,ni)=>{"use strict";var si=yt(),cd=(t,e)=>{let r=si(t,null,!0),s=si(e,null,!0),n=r.compare(s);if(n===0)return null;let i=n>0,o=i?r:s,a=i?s:r,u=!!o.prerelease.length;if(!!a.prerelease.length&&!u){if(!a.patch&&!a.minor)return"major";if(a.compareMain(o)===0)return a.minor&&!a.patch?"minor":"patch"}let l=u?"pre":"";return r.major!==s.major?l+"major":r.minor!==s.minor?l+"minor":r.patch!==s.patch?l+"patch":"prerelease"};ni.exports=cd});var ai=F((Ey,oi)=>{"use strict";var ld=te(),dd=(t,e)=>new ld(t,e).major;oi.exports=dd});var ci=F((xy,ui)=>{"use strict";var fd=te(),pd=(t,e)=>new fd(t,e).minor;ui.exports=pd});var di=F((vy,li)=>{"use strict";var hd=te(),md=(t,e)=>new hd(t,e).patch;li.exports=md});var pi=F((by,fi)=>{"use strict";var Dd=yt(),gd=(t,e)=>{let r=Dd(t,e);return r&&r.prerelease.length?r.prerelease:null};fi.exports=gd});var xe=F((Cy,mi)=>{"use strict";var hi=te(),yd=(t,e,r)=>new hi(t,r).compare(new hi(e,r));mi.exports=yd});var gi=F((Fy,Di)=>{"use strict";var wd=xe(),Ed=(t,e,r)=>wd(e,t,r);Di.exports=Ed});var wi=F((Ry,yi)=>{"use strict";var xd=xe(),vd=(t,e)=>xd(t,e,!0);yi.exports=vd});var Lr=F((Sy,xi)=>{"use strict";var Ei=te(),bd=(t,e,r)=>{let s=new Ei(t,r),n=new Ei(e,r);return s.compare(n)||s.compareBuild(n)};xi.exports=bd});var bi=F((_y,vi)=>{"use strict";var Cd=Lr(),Fd=(t,e)=>t.sort((r,s)=>Cd(r,s,e));vi.exports=Fd});var Fi=F((Ay,Ci)=>{"use strict";var Rd=Lr(),Sd=(t,e)=>t.sort((r,s)=>Rd(s,r,e));Ci.exports=Sd});var ar=F((Iy,Ri)=>{"use strict";var _d=xe(),Ad=(t,e,r)=>_d(t,e,r)>0;Ri.exports=Ad});var jr=F(($y,Si)=>{"use strict";var Id=xe(),$d=(t,e,r)=>Id(t,e,r)<0;Si.exports=$d});var ys=F((ky,_i)=>{"use strict";var kd=xe(),Od=(t,e,r)=>kd(t,e,r)===0;_i.exports=Od});var ws=F((Oy,Ai)=>{"use strict";var Td=xe(),Pd=(t,e,r)=>Td(t,e,r)!==0;Ai.exports=Pd});var Mr=F((Ty,Ii)=>{"use strict";var Nd=xe(),Ld=(t,e,r)=>Nd(t,e,r)>=0;Ii.exports=Ld});var Br=F((Py,$i)=>{"use strict";var jd=xe(),Md=(t,e,r)=>jd(t,e,r)<=0;$i.exports=Md});var Es=F((Ny,ki)=>{"use strict";var Bd=ys(),qd=ws(),Wd=ar(),Ud=Mr(),zd=jr(),Vd=Br(),Gd=(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 Bd(t,r,s);case"!=":return qd(t,r,s);case">":return Wd(t,r,s);case">=":return Ud(t,r,s);case"<":return zd(t,r,s);case"<=":return Vd(t,r,s);default:throw new TypeError(`Invalid operator: ${e}`)}};ki.exports=Gd});var Ti=F((Ly,Oi)=>{"use strict";var Hd=te(),Yd=yt(),{safeRe:qr,t:Wr}=Pt(),Zd=(t,e)=>{if(t instanceof Hd)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?qr[Wr.COERCEFULL]:qr[Wr.COERCE]);else{let u=e.includePrerelease?qr[Wr.COERCERTLFULL]:qr[Wr.COERCERTL],c;for(;(c=u.exec(t))&&(!r||r.index+r[0].length!==t.length);)(!r||c.index+c[0].length!==r.index+r[0].length)&&(r=c),u.lastIndex=c.index+c[1].length+c[2].length;u.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 Yd(`${s}.${n}.${i}${o}${a}`,e)};Oi.exports=Zd});var Ni=F((jy,Pi)=>{"use strict";var xs=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}};Pi.exports=xs});var ve=F((My,Bi)=>{"use strict";var Xd=/\s+/g,vs=class t{constructor(e,r){if(r=Kd(r),e instanceof t)return e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease?e:new t(e.raw,r);if(e instanceof bs)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(Xd," "),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=>!ji(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&&of(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&&sf)|(this.options.loose&&nf))+":"+e,n=Li.get(s);if(n)return n;let i=this.options.loose,o=i?ne[re.HYPHENRANGELOOSE]:ne[re.HYPHENRANGE];e=e.replace(o,Df(this.options.includePrerelease)),q("hyphen replace",e),e=e.replace(ne[re.COMPARATORTRIM],ef),q("comparator trim",e),e=e.replace(ne[re.TILDETRIM],tf),q("tilde trim",e),e=e.replace(ne[re.CARETTRIM],rf),q("caret trim",e);let a=e.split(" ").map(p=>af(p,this.options)).join(" ").split(/\s+/).map(p=>mf(p,this.options));i&&(a=a.filter(p=>(q("loose invalid filter",p,this.options),!!p.match(ne[re.COMPARATORLOOSE])))),q("range list",a);let u=new Map,c=a.map(p=>new bs(p,this.options));for(let p of c){if(ji(p))return[p];u.set(p.value,p)}u.size>1&&u.has("")&&u.delete("");let l=[...u.values()];return Li.set(s,l),l}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(s=>Mi(s,r)&&e.set.some(n=>Mi(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 Qd(e,this.options)}catch{return!1}for(let r=0;r<this.set.length;r++)if(gf(this.set[r],e,this.options))return!0;return!1}};Bi.exports=vs;var Jd=Ni(),Li=new Jd,Kd=kr(),bs=ur(),q=or(),Qd=te(),{safeRe:ne,t:re,comparatorTrimReplace:ef,tildeTrimReplace:tf,caretTrimReplace:rf}=Pt(),{FLAG_INCLUDE_PRERELEASE:sf,FLAG_LOOSE:nf}=ir(),ji=t=>t.value==="<0.0.0-0",of=t=>t.value==="",Mi=(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},af=(t,e)=>(t=t.replace(ne[re.BUILD],""),q("comp",t,e),t=lf(t,e),q("caret",t),t=uf(t,e),q("tildes",t),t=ff(t,e),q("xrange",t),t=hf(t,e),q("stars",t),t),ie=t=>!t||t.toLowerCase()==="x"||t==="*",uf=(t,e)=>t.trim().split(/\s+/).map(r=>cf(r,e)).join(" "),cf=(t,e)=>{let r=e.loose?ne[re.TILDELOOSE]:ne[re.TILDE];return t.replace(r,(s,n,i,o,a)=>{q("tilde",t,s,n,i,o,a);let u;return ie(n)?u="":ie(i)?u=`>=${n}.0.0 <${+n+1}.0.0-0`:ie(o)?u=`>=${n}.${i}.0 <${n}.${+i+1}.0-0`:a?(q("replaceTilde pr",a),u=`>=${n}.${i}.${o}-${a} <${n}.${+i+1}.0-0`):u=`>=${n}.${i}.${o} <${n}.${+i+1}.0-0`,q("tilde return",u),u})},lf=(t,e)=>t.trim().split(/\s+/).map(r=>df(r,e)).join(" "),df=(t,e)=>{q("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,u)=>{q("caret",t,n,i,o,a,u);let c;return ie(i)?c="":ie(o)?c=`>=${i}.0.0${s} <${+i+1}.0.0-0`:ie(a)?i==="0"?c=`>=${i}.${o}.0${s} <${i}.${+o+1}.0-0`:c=`>=${i}.${o}.0${s} <${+i+1}.0.0-0`:u?(q("replaceCaret pr",u),i==="0"?o==="0"?c=`>=${i}.${o}.${a}-${u} <${i}.${o}.${+a+1}-0`:c=`>=${i}.${o}.${a}-${u} <${i}.${+o+1}.0-0`:c=`>=${i}.${o}.${a}-${u} <${+i+1}.0.0-0`):(q("no pr"),i==="0"?o==="0"?c=`>=${i}.${o}.${a}${s} <${i}.${o}.${+a+1}-0`:c=`>=${i}.${o}.${a}${s} <${i}.${+o+1}.0-0`:c=`>=${i}.${o}.${a} <${+i+1}.0.0-0`),q("caret return",c),c})},ff=(t,e)=>(q("replaceXRanges",t,e),t.split(/\s+/).map(r=>pf(r,e)).join(" ")),pf=(t,e)=>{t=t.trim();let r=e.loose?ne[re.XRANGELOOSE]:ne[re.XRANGE];return t.replace(r,(s,n,i,o,a,u)=>{q("xRange",t,s,n,i,o,a,u);let c=ie(i),l=c||ie(o),p=l||ie(a),y=p;return n==="="&&y&&(n=""),u=e.includePrerelease?"-0":"",c?n===">"||n==="<"?s="<0.0.0-0":s="*":n&&y?(l&&(o=0),a=0,n===">"?(n=">=",l?(i=+i+1,o=0,a=0):(o=+o+1,a=0)):n==="<="&&(n="<",l?i=+i+1:o=+o+1),n==="<"&&(u="-0"),s=`${n+i}.${o}.${a}${u}`):l?s=`>=${i}.0.0${u} <${+i+1}.0.0-0`:p&&(s=`>=${i}.${o}.0${u} <${i}.${+o+1}.0-0`),q("xRange return",s),s})},hf=(t,e)=>(q("replaceStars",t,e),t.trim().replace(ne[re.STAR],"")),mf=(t,e)=>(q("replaceGTE0",t,e),t.trim().replace(ne[e.includePrerelease?re.GTE0PRE:re.GTE0],"")),Df=t=>(e,r,s,n,i,o,a,u,c,l,p,y)=>(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(c)?u="":ie(l)?u=`<${+c+1}.0.0-0`:ie(p)?u=`<${c}.${+l+1}.0-0`:y?u=`<=${c}.${l}.${p}-${y}`:t?u=`<${c}.${l}.${+p+1}-0`:u=`<=${u}`,`${r} ${u}`.trim()),gf=(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(q(t[s].semver),t[s].semver!==bs.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 ur=F((By,Gi)=>{"use strict";var cr=Symbol("SemVer ANY"),Rs=class t{static get ANY(){return cr}constructor(e,r){if(r=qi(r),e instanceof t){if(e.loose===!!r.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),Fs("comparator",e,r),this.options=r,this.loose=!!r.loose,this.parse(e),this.semver===cr?this.value="":this.value=this.operator+this.semver.version,Fs("comp",this)}parse(e){let r=this.options.loose?Wi[Ui.COMPARATORLOOSE]:Wi[Ui.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 zi(s[2],this.options.loose):this.semver=cr}toString(){return this.value}test(e){if(Fs("Comparator.test",e,this.options.loose),this.semver===cr||e===cr)return!0;if(typeof e=="string")try{e=new zi(e,this.options)}catch{return!1}return Cs(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 Vi(e.value,r).test(this.value):e.operator===""?e.value===""?!0:new Vi(this.value,r).test(e.semver):(r=qi(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("=")||Cs(this.semver,"<",e.semver,r)&&this.operator.startsWith(">")&&e.operator.startsWith("<")||Cs(this.semver,">",e.semver,r)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}};Gi.exports=Rs;var qi=kr(),{safeRe:Wi,t:Ui}=Pt(),Cs=Es(),Fs=or(),zi=te(),Vi=ve()});var lr=F((qy,Hi)=>{"use strict";var yf=ve(),wf=(t,e,r)=>{try{e=new yf(e,r)}catch{return!1}return e.test(t)};Hi.exports=wf});var Zi=F((Wy,Yi)=>{"use strict";var Ef=ve(),xf=(t,e)=>new Ef(t,e).set.map(r=>r.map(s=>s.value).join(" ").trim().split(" "));Yi.exports=xf});var Ji=F((Uy,Xi)=>{"use strict";var vf=te(),bf=ve(),Cf=(t,e,r)=>{let s=null,n=null,i=null;try{i=new bf(e,r)}catch{return null}return t.forEach(o=>{i.test(o)&&(!s||n.compare(o)===-1)&&(s=o,n=new vf(s,r))}),s};Xi.exports=Cf});var Qi=F((zy,Ki)=>{"use strict";var Ff=te(),Rf=ve(),Sf=(t,e,r)=>{let s=null,n=null,i=null;try{i=new Rf(e,r)}catch{return null}return t.forEach(o=>{i.test(o)&&(!s||n.compare(o)===1)&&(s=o,n=new Ff(s,r))}),s};Ki.exports=Sf});var ro=F((Vy,to)=>{"use strict";var Ss=te(),_f=ve(),eo=ar(),Af=(t,e)=>{t=new _f(t,e);let r=new Ss("0.0.0");if(t.test(r)||(r=new Ss("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 Ss(o.semver.version);switch(o.operator){case">":a.prerelease.length===0?a.patch++:a.prerelease.push(0),a.raw=a.format();case"":case">=":(!i||eo(a,i))&&(i=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${o.operator}`)}}),i&&(!r||eo(r,i))&&(r=i)}return r&&t.test(r)?r:null};to.exports=Af});var no=F((Gy,so)=>{"use strict";var If=ve(),$f=(t,e)=>{try{return new If(t,e).range||"*"}catch{return null}};so.exports=$f});var Ur=F((Hy,uo)=>{"use strict";var kf=te(),ao=ur(),{ANY:Of}=ao,Tf=ve(),Pf=lr(),io=ar(),oo=jr(),Nf=Br(),Lf=Mr(),jf=(t,e,r,s)=>{t=new kf(t,s),e=new Tf(e,s);let n,i,o,a,u;switch(r){case">":n=io,i=Nf,o=oo,a=">",u=">=";break;case"<":n=oo,i=Lf,o=io,a="<",u="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(Pf(t,e,s))return!1;for(let c=0;c<e.set.length;++c){let l=e.set[c],p=null,y=null;if(l.forEach(d=>{d.semver===Of&&(d=new ao(">=0.0.0")),p=p||d,y=y||d,n(d.semver,p.semver,s)?p=d:o(d.semver,y.semver,s)&&(y=d)}),p.operator===a||p.operator===u||(!y.operator||y.operator===a)&&i(t,y.semver))return!1;if(y.operator===u&&o(t,y.semver))return!1}return!0};uo.exports=jf});var lo=F((Yy,co)=>{"use strict";var Mf=Ur(),Bf=(t,e,r)=>Mf(t,e,">",r);co.exports=Bf});var po=F((Zy,fo)=>{"use strict";var qf=Ur(),Wf=(t,e,r)=>qf(t,e,"<",r);fo.exports=Wf});var Do=F((Xy,mo)=>{"use strict";var ho=ve(),Uf=(t,e,r)=>(t=new ho(t,r),e=new ho(e,r),t.intersects(e,r));mo.exports=Uf});var yo=F((Jy,go)=>{"use strict";var zf=lr(),Vf=xe();go.exports=(t,e,r)=>{let s=[],n=null,i=null,o=t.sort((l,p)=>Vf(l,p,r));for(let l of o)zf(l,e,r)?(i=l,n||(n=l)):(i&&s.push([n,i]),i=null,n=null);n&&s.push([n,null]);let a=[];for(let[l,p]of s)l===p?a.push(l):!p&&l===o[0]?a.push("*"):p?l===o[0]?a.push(`<=${p}`):a.push(`${l} - ${p}`):a.push(`>=${l}`);let u=a.join(" || "),c=typeof e.raw=="string"?e.raw:String(e);return u.length<c.length?u:e}});var Co=F((Ky,bo)=>{"use strict";var wo=ve(),As=ur(),{ANY:_s}=As,dr=lr(),Is=xe(),Gf=(t,e,r={})=>{if(t===e)return!0;t=new wo(t,r),e=new wo(e,r);let s=!1;e:for(let n of t.set){for(let i of e.set){let o=Yf(n,i,r);if(s=s||o!==null,o)continue e}if(s)return!1}return!0},Hf=[new As(">=0.0.0-0")],Eo=[new As(">=0.0.0")],Yf=(t,e,r)=>{if(t===e)return!0;if(t.length===1&&t[0].semver===_s){if(e.length===1&&e[0].semver===_s)return!0;r.includePrerelease?t=Hf:t=Eo}if(e.length===1&&e[0].semver===_s){if(r.includePrerelease)return!0;e=Eo}let s=new Set,n,i;for(let d of t)d.operator===">"||d.operator===">="?n=xo(n,d,r):d.operator==="<"||d.operator==="<="?i=vo(i,d,r):s.add(d.semver);if(s.size>1)return null;let o;if(n&&i){if(o=Is(n.semver,i.semver,r),o>0)return null;if(o===0&&(n.operator!==">="||i.operator!=="<="))return null}for(let d of s){if(n&&!dr(d,String(n),r)||i&&!dr(d,String(i),r))return null;for(let m of e)if(!dr(d,String(m),r))return!1;return!0}let a,u,c,l,p=i&&!r.includePrerelease&&i.semver.prerelease.length?i.semver:!1,y=n&&!r.includePrerelease&&n.semver.prerelease.length?n.semver:!1;p&&p.prerelease.length===1&&i.operator==="<"&&p.prerelease[0]===0&&(p=!1);for(let d of e){if(l=l||d.operator===">"||d.operator===">=",c=c||d.operator==="<"||d.operator==="<=",n){if(y&&d.semver.prerelease&&d.semver.prerelease.length&&d.semver.major===y.major&&d.semver.minor===y.minor&&d.semver.patch===y.patch&&(y=!1),d.operator===">"||d.operator===">="){if(a=xo(n,d,r),a===d&&a!==n)return!1}else if(n.operator===">="&&!dr(n.semver,String(d),r))return!1}if(i){if(p&&d.semver.prerelease&&d.semver.prerelease.length&&d.semver.major===p.major&&d.semver.minor===p.minor&&d.semver.patch===p.patch&&(p=!1),d.operator==="<"||d.operator==="<="){if(u=vo(i,d,r),u===d&&u!==i)return!1}else if(i.operator==="<="&&!dr(i.semver,String(d),r))return!1}if(!d.operator&&(i||n)&&o!==0)return!1}return!(n&&c&&!i&&o!==0||i&&l&&!n&&o!==0||y||p)},xo=(t,e,r)=>{if(!t)return e;let s=Is(t.semver,e.semver,r);return s>0?t:s<0||e.operator===">"&&t.operator===">="?e:t},vo=(t,e,r)=>{if(!t)return e;let s=Is(t.semver,e.semver,r);return s<0?t:s>0||e.operator==="<"&&t.operator==="<="?e:t};bo.exports=Gf});var ks=F((Qy,So)=>{"use strict";var $s=Pt(),Fo=ir(),Zf=te(),Ro=ms(),Xf=yt(),Jf=Jn(),Kf=Qn(),Qf=ri(),ep=ii(),tp=ai(),rp=ci(),sp=di(),np=pi(),ip=xe(),op=gi(),ap=wi(),up=Lr(),cp=bi(),lp=Fi(),dp=ar(),fp=jr(),pp=ys(),hp=ws(),mp=Mr(),Dp=Br(),gp=Es(),yp=Ti(),wp=ur(),Ep=ve(),xp=lr(),vp=Zi(),bp=Ji(),Cp=Qi(),Fp=ro(),Rp=no(),Sp=Ur(),_p=lo(),Ap=po(),Ip=Do(),$p=yo(),kp=Co();So.exports={parse:Xf,valid:Jf,clean:Kf,inc:Qf,diff:ep,major:tp,minor:rp,patch:sp,prerelease:np,compare:ip,rcompare:op,compareLoose:ap,compareBuild:up,sort:cp,rsort:lp,gt:dp,lt:fp,eq:pp,neq:hp,gte:mp,lte:Dp,cmp:gp,coerce:yp,Comparator:wp,Range:Ep,satisfies:xp,toComparators:vp,maxSatisfying:bp,minSatisfying:Cp,minVersion:Fp,validRange:Rp,outside:Sp,gtr:_p,ltr:Ap,intersects:Ip,simplifyRange:$p,subset:kp,SemVer:Zf,re:$s.re,src:$s.src,tokens:$s.t,SEMVER_SPEC_VERSION:Fo.SEMVER_SPEC_VERSION,RELEASE_TYPES:Fo.RELEASE_TYPES,compareIdentifiers:Ro.compareIdentifiers,rcompareIdentifiers:Ro.rcompareIdentifiers}});var es=F((a0,Ta)=>{var on=[],Oa=0,se=(t,e)=>{Oa>=e&&on.push(t)};se.WARN=1;se.INFO=2;se.DEBUG=3;se.reset=()=>{on=[]};se.setDebugLevel=t=>{Oa=t};se.warn=t=>se(t,se.WARN);se.info=t=>se(t,se.INFO);se.debug=t=>se(t,se.DEBUG);se.debugMessages=()=>on;Ta.exports=se});var Na=F((u0,Pa)=>{"use strict";Pa.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 ja=F((c0,La)=>{"use strict";var xm=Na();La.exports=t=>typeof t=="string"?t.replace(xm(),""):t});var Ba=F((l0,an)=>{"use strict";var Ma=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);an.exports=Ma;an.exports.default=Ma});var Wa=F((d0,qa)=>{"use strict";qa.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 za=F((f0,un)=>{"use strict";var vm=ja(),bm=Ba(),Cm=Wa(),Ua=t=>{if(typeof t!="string"||t.length===0||(t=vm(t),t.length===0))return 0;t=t.replace(Cm()," ");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+=bm(s)?2:1)}return e};un.exports=Ua;un.exports.default=Ua});var cn=F((p0,Ya)=>{var Va=za();function ts(t){return t?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function Ne(t){let e=ts();return(""+t).replace(e,"").split(`
3
- `).reduce(function(n,i){return Va(i)>n?Va(i):n},0)}function mr(t,e){return Array(e+1).join(t)}function Fm(t,e,r,s){let n=Ne(t);if(e+1>=n){let i=e-n;switch(s){case"right":{t=mr(r,i)+t;break}case"center":{let o=Math.ceil(i/2),a=i-o;t=mr(r,a)+t+mr(r,o);break}default:{t=t+mr(r,i);break}}}return t}var Vt={};function Dr(t,e,r){e="\x1B["+e+"m",r="\x1B["+r+"m",Vt[e]={set:t,to:!0},Vt[r]={set:t,to:!1},Vt[t]={on:e,off:r}}Dr("bold",1,22);Dr("italics",3,23);Dr("underline",4,24);Dr("inverse",7,27);Dr("strikethrough",9,29);function Ga(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=Vt[e[0]];s&&(t[s.set]=s.to)}function Rm(t){let e=ts(!0),r=e.exec(t),s={};for(;r!==null;)Ga(s,r),r=e.exec(t);return s}function Ha(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+=Vt[n].off)}),r&&r!="\x1B[49m"&&(e+="\x1B[49m"),s&&s!="\x1B[39m"&&(e+="\x1B[39m"),e}function Sm(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=Vt[n].on+e)}),r&&r!="\x1B[49m"&&(e=r+e),s&&s!="\x1B[39m"&&(e=s+e),e}function _m(t,e){if(t.length===Ne(t))return t.substr(0,e);for(;Ne(t)>e;)t=t.slice(0,-1);return t}function Am(t,e){let r=ts(!0),s=t.split(ts()),n=0,i=0,o="",a,u={};for(;i<e;){a=r.exec(t);let c=s[n];if(n++,i+Ne(c)>e&&(c=_m(c,e-i)),o+=c,i+=Ne(c),i<e){if(!a)break;o+=a[0],Ga(u,a)}}return Ha(u,o)}function Im(t,e,r){if(r=r||"\u2026",Ne(t)<=e)return t;e-=Ne(r);let n=Am(t,e);n+=r;let i="\x1B]8;;\x07";return t.includes(i)&&!n.includes(i)&&(n+=i),n}function $m(){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 km(t,e){t=t||{},e=e||$m();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 Om(t,e){let r=[],s=e.split(/(\s+)/g),n=[],i=0,o;for(let a=0;a<s.length;a+=2){let u=s[a],c=i+Ne(u);i>0&&o&&(c+=o.length),c>t?(i!==0&&r.push(n.join("")),n=[u],i=Ne(u)):(n.push(o||"",u),i=c),o=s[a+1]}return i&&r.push(n.join("")),r}function Tm(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 Pm(t,e,r=!0){let s=[];e=e.split(`
4
- `);let n=r?Om:Tm;for(let i=0;i<e.length;i++)s.push.apply(s,n(t,e[i]));return s}function Nm(t){let e={},r=[];for(let s=0;s<t.length;s++){let n=Sm(e,t[s]);e=Rm(n);let i=Object.assign({},e);r.push(Ha(i,n))}return r}function Lm(t,e){return["\x1B]","8",";",";",t||e,"\x07",e,"\x1B]","8",";",";","\x07"].join("")}Ya.exports={strlen:Ne,repeat:mr,pad:Fm,truncate:Im,mergeOptions:km,wordWrap:Pm,colorizeLines:Nm,hyperlink:Lm}});var Ka=F((h0,Ja)=>{var Xa={};Ja.exports=Xa;var Za={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(Za).forEach(function(t){var e=Za[t],r=Xa[t]=[];r.open="\x1B["+e[0]+"m",r.close="\x1B["+e[1]+"m"})});var eu=F((m0,Qa)=>{"use strict";Qa.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 ru=F((D0,tu)=>{"use strict";var jm=bn("os"),Ie=eu(),ae=process.env,Gt=void 0;Ie("no-color")||Ie("no-colors")||Ie("color=false")?Gt=!1:(Ie("color")||Ie("colors")||Ie("color=true")||Ie("color=always"))&&(Gt=!0);"FORCE_COLOR"in ae&&(Gt=ae.FORCE_COLOR.length===0||parseInt(ae.FORCE_COLOR,10)!==0);function Mm(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function Bm(t){if(Gt===!1)return 0;if(Ie("color=16m")||Ie("color=full")||Ie("color=truecolor"))return 3;if(Ie("color=256"))return 2;if(t&&!t.isTTY&&Gt!==!0)return 0;var e=Gt?1:0;if(process.platform==="win32"){var r=jm.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 ae)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(n){return n in ae})||ae.CI_NAME==="codeship"?1:e;if("TEAMCITY_VERSION"in ae)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ae.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in ae){var s=parseInt((ae.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(ae.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(ae.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(ae.TERM)||"COLORTERM"in ae?1:(ae.TERM==="dumb",e)}function ln(t){var e=Bm(t);return Mm(e)}tu.exports={supportsColor:ln,stdout:ln(process.stdout),stderr:ln(process.stderr)}});var nu=F((g0,su)=>{su.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 ou=F((y0,iu)=>{iu.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(u){var c=Math.floor(Math.random()*u);return c}function o(u){var c=!1;return n.filter(function(l){c=l===u}),c}function a(u,c){var l="",p,y;c=c||{},c.up=typeof c.up<"u"?c.up:!0,c.mid=typeof c.mid<"u"?c.mid:!0,c.down=typeof c.down<"u"?c.down:!0,c.size=typeof c.size<"u"?c.size:"maxi",u=u.split("");for(y in u)if(!o(y)){switch(l=l+u[y],p={up:0,down:0,mid:0},c.size){case"mini":p.up=i(8),p.mid=i(2),p.down=i(8);break;case"maxi":p.up=i(16)+3,p.mid=i(4)+1,p.down=i(64)+3;break;default:p.up=i(8)+1,p.mid=i(6)/2,p.down=i(8)+1;break}var d=["up","mid","down"];for(var m in d)for(var w=d[m],x=0;x<=p[w];x++)c[w]&&(l=l+s[w][i(s[w].length)])}return l}return a(e,r)}});var uu=F((w0,au)=>{au.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 lu=F((E0,cu)=>{cu.exports=function(t){return function(e,r,s){return r%2===0?e:t.inverse(e)}}});var fu=F((x0,du)=>{du.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 hu=F((v0,pu)=>{pu.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 Eu=F((C0,wu)=>{var L={};wu.exports=L;L.themes={};var qm=bn("util"),Ct=L.styles=Ka(),Du=Object.defineProperties,Wm=new RegExp(/[\r\n]+/g);L.supportsColor=ru().supportsColor;typeof L.enabled>"u"&&(L.enabled=L.supportsColor()!==!1);L.enable=function(){L.enabled=!0};L.disable=function(){L.enabled=!1};L.stripColors=L.strip=function(t){return(""+t).replace(/\x1B\[\d+m/g,"")};var b0=L.stylize=function(e,r){if(!L.enabled)return e+"";var s=Ct[r];return!s&&r in L?L[r](e):s.open+e+s.close},Um=/[|\\{}()[\]^$+*?.]/g,zm=function(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(Um,"\\$&")};function gu(t){var e=function r(){return Gm.apply(r,arguments)};return e._styles=t,e.__proto__=Vm,e}var yu=(function(){var t={};return Ct.grey=Ct.gray,Object.keys(Ct).forEach(function(e){Ct[e].closeRe=new RegExp(zm(Ct[e].close),"g"),t[e]={get:function(){return gu(this._styles.concat(e))}}}),t})(),Vm=Du(function(){},yu);function Gm(){var t=Array.prototype.slice.call(arguments),e=t.map(function(o){return o!=null&&o.constructor===String?o:qm.inspect(o)}).join(" ");if(!L.enabled||!e)return e;for(var r=e.indexOf(`
5
- `)!=-1,s=this._styles,n=s.length;n--;){var i=Ct[s[n]];e=i.open+e.replace(i.closeRe,i.open)+i.close,r&&(e=e.replace(Wm,function(o){return i.close+o+i.open}))}return e}L.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){L[r]=function(s){if(typeof t[r]=="object"){var n=s;for(var i in t[r])n=L[t[r][i]](n);return n}return L[t[r]](s)}})(e)};function Hm(){var t={};return Object.keys(yu).forEach(function(e){t[e]={get:function(){return gu([e])}}}),t}var Ym=function(e,r){var s=r.split("");return s=s.map(e),s.join("")};L.trap=nu();L.zalgo=ou();L.maps={};L.maps.america=uu()(L);L.maps.zebra=lu()(L);L.maps.rainbow=fu()(L);L.maps.random=hu()(L);for(mu in L.maps)(function(t){L[t]=function(e){return Ym(L.maps[t],e)}})(mu);var mu;Du(L,Hm())});var vu=F((F0,xu)=>{var Zm=Eu();xu.exports=Zm});var Ru=F((R0,rs)=>{var{info:Xm,debug:Fu}=es(),De=cn(),fn=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={};Km.forEach(function(u){dn(s,n,u,i)}),this.truncate=this.options.truncate||e.truncate;let o=this.options.style=this.options.style||{},a=e.style;dn(o,a,"padding-left",this),dn(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=De.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(De.wordWrap(this.fixedWidth,this.content,i))}return this.wrapLines(this.content.split(`
6
- `))}wrapLines(e){let r=De.colorizeLines(e);return this.href?r.map(s=>De.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(Cu,-1),this.height=this.heights.reduce(Cu,-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=De.truncate(this.content,10,this.truncate);e||Xm(`${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(De.repeat(this.chars[this.y==0?"top":"mid"],s))},this):(r.push(this._topLeftChar(0)),r.push(De.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=vu();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 y=this.cells[this.y+n][this.x-1];for(;y instanceof gr;)y=this.cells[y.y][y.x-1];y instanceof yr||(i=this.chars.rightMid)}let o=De.repeat(" ",this.paddingLeft),a=r?this.chars.right:"",u=De.repeat(" ",this.paddingRight),c=this.lines[e],l=this.width-(this.paddingLeft+this.paddingRight);s&&(c+=this.truncate||"\u2026");let p=De.truncate(c,l,this.truncate);return p=De.pad(p,l," ",this.hAlign),p=o+p+u,this.stylizeLine(i,p,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=De.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 gr;)o=this.cells[o.y][o.x-1];o instanceof yr||(s=this.chars.rightMid)}let n=e?this.chars.right:"",i=De.repeat(" ",this.width);return this.stylizeLine(s,i,n)}},gr=class{constructor(){}draw(e){return typeof e=="number"&&Fu(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},yr=class{constructor(e){this.originalCell=e}init(e){let r=this.y,s=this.originalCell.y;this.cellOffset=r-s,this.offset=Jm(e.rowHeights,s,this.cellOffset)}draw(e){return e=="top"?this.originalCell.draw(this.offset,this.cellOffset):e=="bottom"?this.originalCell.draw("bottom"):(Fu(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+e))}mergeTableOptions(){}};function bu(...t){return t.filter(e=>e!=null).shift()}function dn(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]=bu(t[n],t[r],e[n],e[r])):s[r]=bu(t[r],e[r])}function Jm(t,e,r){let s=t[e];for(let n=1;n<r;n++)s+=1+t[e+n];return s}function Cu(t,e){return t+e+1}var Km=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];rs.exports=fn;rs.exports.ColSpanCell=gr;rs.exports.RowSpanCell=yr});var Au=F((S0,_u)=>{var{warn:Qm,debug:eD}=es(),pn=Ru(),{ColSpanCell:tD,RowSpanCell:rD}=pn;(function(){function t(d,m){return d[m]>0?t(d,m+1):m}function e(d){let m={};d.forEach(function(w,x){let S=0;w.forEach(function(I){I.y=x,I.x=x?t(m,S):S;let M=I.rowSpan||1,U=I.colSpan||1;if(M>1)for(let z=0;z<U;z++)m[I.x+z]=M;S=I.x+U}),Object.keys(m).forEach(I=>{m[I]--,m[I]<1&&delete m[I]})})}function r(d){let m=0;return d.forEach(function(w){w.forEach(function(x){m=Math.max(m,x.x+(x.colSpan||1))})}),m}function s(d){return d.length}function n(d,m){let w=d.y,x=d.y-1+(d.rowSpan||1),S=m.y,I=m.y-1+(m.rowSpan||1),M=!(w>I||S>x),U=d.x,z=d.x-1+(d.colSpan||1),Ue=m.x,de=m.x-1+(m.colSpan||1),j=!(U>de||Ue>z);return M&&j}function i(d,m,w){let x=Math.min(d.length-1,w),S={x:m,y:w};for(let I=0;I<=x;I++){let M=d[I];for(let U=0;U<M.length;U++)if(n(S,M[U]))return!0}return!1}function o(d,m,w,x){for(let S=w;S<x;S++)if(i(d,S,m))return!1;return!0}function a(d){d.forEach(function(m,w){m.forEach(function(x){for(let S=1;S<x.rowSpan;S++){let I=new rD(x);I.x=x.x,I.y=x.y+S,I.colSpan=x.colSpan,c(I,d[w+S])}})})}function u(d){for(let m=d.length-1;m>=0;m--){let w=d[m];for(let x=0;x<w.length;x++){let S=w[x];for(let I=1;I<S.colSpan;I++){let M=new tD;M.x=S.x+I,M.y=S.y,w.splice(x+1,0,M)}}}}function c(d,m){let w=0;for(;w<m.length&&m[w].x<d.x;)w++;m.splice(w,0,d)}function l(d){let m=s(d),w=r(d);eD(`Max rows: ${m}; Max cols: ${w}`);for(let x=0;x<m;x++)for(let S=0;S<w;S++)if(!i(d,S,x)){let I={x:S,y:x,colSpan:1,rowSpan:1};for(S++;S<w&&!i(d,S,x);)I.colSpan++,S++;let M=x+1;for(;M<m&&o(d,M,I.x,I.x+I.colSpan);)I.rowSpan++,M++;let U=new pn(I);U.x=I.x,U.y=I.y,Qm(`Missing cell at ${U.y}-${U.x}.`),c(U,d[x])}}function p(d){return d.map(function(m){if(!Array.isArray(m)){let w=Object.keys(m)[0];m=m[w],Array.isArray(m)?(m=m.slice(),m.unshift(w)):m=[w,m]}return m.map(function(w){return new pn(w)})})}function y(d){let m=p(d);return e(m),l(m),a(m),u(m),m}_u.exports={makeTableLayout:y,layoutTable:e,addRowSpanCells:a,maxWidth:r,fillInTable:l,computeWidths:Su("colSpan","desiredWidth","x",1),computeHeights:Su("rowSpan","desiredHeight","y",1)}})();function Su(t,e,r,s){return function(n,i){let o=[],a=[],u={};i.forEach(function(c){c.forEach(function(l){(l[t]||1)>1?a.push(l):o[l[r]]=Math.max(o[l[r]]||0,l[e]||0,s)})}),n.forEach(function(c,l){typeof c=="number"&&(o[l]=c)});for(let c=a.length-1;c>=0;c--){let l=a[c],p=l[t],y=l[r],d=o[y],m=typeof n[y]=="number"?0:1;if(typeof d=="number")for(let w=1;w<p;w++)d+=1+o[y+w],typeof n[y+w]!="number"&&m++;else d=e==="desiredWidth"?l.desiredWidth-1:1,(!u[y]||u[y]<d)&&(u[y]=d);if(l[e]>d){let w=0;for(;m>0&&l[e]>d;){if(typeof n[y+w]!="number"){let x=Math.round((l[e]-d)/m);d+=x,o[y+w]+=x,m--}w++}}}Object.assign(n,o,u);for(let c=0;c<n.length;c++)n[c]=Math.max(s,n[c]||0)}}});var $u=F((_0,Iu)=>{var We=es(),sD=cn(),hn=Au(),ss=class extends Array{constructor(e){super();let r=sD.mergeOptions(e);if(Object.defineProperty(this,"options",{value:r,enumerable:r.debug}),r.debug){switch(typeof r.debug){case"boolean":We.setDebugLevel(We.WARN);break;case"number":We.setDebugLevel(r.debug);break;case"string":We.setDebugLevel(parseInt(r.debug,10));break;default:We.setDebugLevel(We.WARN),We.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof r.debug}`)}Object.defineProperty(this,"messages",{get(){return We.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=hn.makeTableLayout(e);s.forEach(function(i){i.forEach(function(o){o.mergeTableOptions(this.options,s)},this)},this),hn.computeWidths(this.options.colWidths,s),hn.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)&&mn(o,"top",n);for(let u=0;u<a;u++)mn(o,u,n);i+1==s.length&&mn(o,"bottom",n)}return n.join(`
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 On=(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 At=(t,e,r)=>(r=t!=null?Au(Ou(t)):{},Pu(e||!t||!t.__esModule?ps(r,"default",{value:t,enumerable:!0}):r,t));var lr=R((Hy,Zn)=>{"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"];Zn.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 dr=R((Jy,Yn)=>{"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):()=>{};Yn.exports=pd});var Bt=R((Te,Xn)=>{"use strict";var{MAX_SAFE_COMPONENT_LENGTH:xs,MAX_SAFE_BUILD_LENGTH:hd,MAX_LENGTH:md}=lr(),gd=dr();Te=Xn.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,Kn)=>{"use strict";var Cd=Object.freeze({loose:!0}),bd=Object.freeze({}),Fd=t=>t?typeof t!="object"?Cd:t:bd;Kn.exports=Fd});var Cs=R((Yy,ti)=>{"use strict";var Qn=/^[0-9]+$/,ei=(t,e)=>{if(typeof t=="number"&&typeof e=="number")return t===e?0:t<e?-1:1;let r=Qn.test(t),s=Qn.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)=>ei(e,t);ti.exports={compareIdentifiers:ei,rcompareIdentifiers:Rd}});var te=R((Xy,si)=>{"use strict";var Mr=dr(),{MAX_LENGTH:ri,MAX_SAFE_INTEGER:jr}=lr(),{safeRe:Br,t:Wr}=Bt(),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>ri)throw new TypeError(`version is longer than ${ri} 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}};si.exports=Fs});var vt=R((Ky,ii)=>{"use strict";var ni=te(),_d=(t,e,r=!1)=>{if(t instanceof ni)return t;try{return new ni(t,e)}catch(s){if(!r)return null;throw s}};ii.exports=_d});var ai=R((Qy,oi)=>{"use strict";var Ad=vt(),$d=(t,e)=>{let r=Ad(t,e);return r?r.version:null};oi.exports=$d});var ui=R((ew,ci)=>{"use strict";var Id=vt(),Od=(t,e)=>{let r=Id(t.trim().replace(/^[=v]+/,""),e);return r?r.version:null};ci.exports=Od});var fi=R((tw,di)=>{"use strict";var li=te(),kd=(t,e,r,s,n)=>{typeof r=="string"&&(n=s,s=r,r=void 0);try{return new li(t instanceof li?t.version:t,r).inc(e,s,n).version}catch{return null}};di.exports=kd});var mi=R((rw,hi)=>{"use strict";var pi=vt(),Td=(t,e)=>{let r=pi(t,null,!0),s=pi(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"};hi.exports=Td});var Di=R((sw,gi)=>{"use strict";var Pd=te(),Nd=(t,e)=>new Pd(t,e).major;gi.exports=Nd});var wi=R((nw,yi)=>{"use strict";var Ld=te(),Md=(t,e)=>new Ld(t,e).minor;yi.exports=Md});var xi=R((iw,Ei)=>{"use strict";var jd=te(),Bd=(t,e)=>new jd(t,e).patch;Ei.exports=Bd});var Ci=R((ow,vi)=>{"use strict";var Wd=vt(),qd=(t,e)=>{let r=Wd(t,e);return r&&r.prerelease.length?r.prerelease:null};vi.exports=qd});var Ee=R((aw,Fi)=>{"use strict";var bi=te(),Ud=(t,e,r)=>new bi(t,r).compare(new bi(e,r));Fi.exports=Ud});var Si=R((cw,Ri)=>{"use strict";var zd=Ee(),Vd=(t,e,r)=>zd(e,t,r);Ri.exports=Vd});var Ai=R((uw,_i)=>{"use strict";var Gd=Ee(),Hd=(t,e)=>Gd(t,e,!0);_i.exports=Hd});var qr=R((lw,Ii)=>{"use strict";var $i=te(),Jd=(t,e,r)=>{let s=new $i(t,r),n=new $i(e,r);return s.compare(n)||s.compareBuild(n)};Ii.exports=Jd});var ki=R((dw,Oi)=>{"use strict";var Zd=qr(),Yd=(t,e)=>t.sort((r,s)=>Zd(r,s,e));Oi.exports=Yd});var Pi=R((fw,Ti)=>{"use strict";var Xd=qr(),Kd=(t,e)=>t.sort((r,s)=>Xd(s,r,e));Ti.exports=Kd});var fr=R((pw,Ni)=>{"use strict";var Qd=Ee(),ef=(t,e,r)=>Qd(t,e,r)>0;Ni.exports=ef});var Ur=R((hw,Li)=>{"use strict";var tf=Ee(),rf=(t,e,r)=>tf(t,e,r)<0;Li.exports=rf});var Rs=R((mw,Mi)=>{"use strict";var sf=Ee(),nf=(t,e,r)=>sf(t,e,r)===0;Mi.exports=nf});var Ss=R((gw,ji)=>{"use strict";var of=Ee(),af=(t,e,r)=>of(t,e,r)!==0;ji.exports=af});var zr=R((Dw,Bi)=>{"use strict";var cf=Ee(),uf=(t,e,r)=>cf(t,e,r)>=0;Bi.exports=uf});var Vr=R((yw,Wi)=>{"use strict";var lf=Ee(),df=(t,e,r)=>lf(t,e,r)<=0;Wi.exports=df});var _s=R((ww,qi)=>{"use strict";var ff=Rs(),pf=Ss(),hf=fr(),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}`)}};qi.exports=yf});var zi=R((Ew,Ui)=>{"use strict";var wf=te(),Ef=vt(),{safeRe:Gr,t:Hr}=Bt(),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)};Ui.exports=xf});var Gi=R((xw,Vi)=>{"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}};Vi.exports=As});var xe=R((vw,Yi)=>{"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=>!Ji(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=Hi.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(Ji(h))return[h];c.set(h.value,h)}c.size>1&&c.has("")&&c.delete("");let d=[...c.values()];return Hi.set(s,d),d}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(s=>Zi(s,r)&&e.set.some(n=>Zi(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}};Yi.exports=$s;var Cf=Gi(),Hi=new Cf,bf=Lr(),Is=pr(),W=dr(),Ff=te(),{safeRe:ne,t:re,comparatorTrimReplace:Rf,tildeTrimReplace:Sf,caretTrimReplace:_f}=Bt(),{FLAG_INCLUDE_PRERELEASE:Af,FLAG_LOOSE:$f}=lr(),Ji=t=>t.value==="<0.0.0-0",If=t=>t.value==="",Zi=(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 pr=R((Cw,ro)=>{"use strict";var hr=Symbol("SemVer ANY"),Ts=class t{static get ANY(){return hr}constructor(e,r){if(r=Xi(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===hr?this.value="":this.value=this.operator+this.semver.version,ks("comp",this)}parse(e){let r=this.options.loose?Ki[Qi.COMPARATORLOOSE]:Ki[Qi.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 eo(s[2],this.options.loose):this.semver=hr}toString(){return this.value}test(e){if(ks("Comparator.test",e,this.options.loose),this.semver===hr||e===hr)return!0;if(typeof e=="string")try{e=new eo(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 to(e.value,r).test(this.value):e.operator===""?e.value===""?!0:new to(this.value,r).test(e.semver):(r=Xi(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(">")))}};ro.exports=Ts;var Xi=Lr(),{safeRe:Ki,t:Qi}=Bt(),Os=_s(),ks=dr(),eo=te(),to=xe()});var mr=R((bw,so)=>{"use strict";var Uf=xe(),zf=(t,e,r)=>{try{e=new Uf(e,r)}catch{return!1}return e.test(t)};so.exports=zf});var io=R((Fw,no)=>{"use strict";var Vf=xe(),Gf=(t,e)=>new Vf(t,e).set.map(r=>r.map(s=>s.value).join(" ").trim().split(" "));no.exports=Gf});var ao=R((Rw,oo)=>{"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};oo.exports=Zf});var uo=R((Sw,co)=>{"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};co.exports=Kf});var po=R((_w,fo)=>{"use strict";var Ps=te(),Qf=xe(),lo=fr(),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||lo(a,i))&&(i=a);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${o.operator}`)}}),i&&(!r||lo(r,i))&&(r=i)}return r&&t.test(r)?r:null};fo.exports=ep});var mo=R((Aw,ho)=>{"use strict";var tp=xe(),rp=(t,e)=>{try{return new tp(t,e).range||"*"}catch{return null}};ho.exports=rp});var Jr=R(($w,wo)=>{"use strict";var sp=te(),yo=pr(),{ANY:np}=yo,ip=xe(),op=mr(),go=fr(),Do=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=go,i=ap,o=Do,a=">",c=">=";break;case"<":n=Do,i=cp,o=go,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 yo(">=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};wo.exports=up});var xo=R((Iw,Eo)=>{"use strict";var lp=Jr(),dp=(t,e,r)=>lp(t,e,">",r);Eo.exports=dp});var Co=R((Ow,vo)=>{"use strict";var fp=Jr(),pp=(t,e,r)=>fp(t,e,"<",r);vo.exports=pp});var Ro=R((kw,Fo)=>{"use strict";var bo=xe(),hp=(t,e,r)=>(t=new bo(t,r),e=new bo(e,r),t.intersects(e,r));Fo.exports=hp});var _o=R((Tw,So)=>{"use strict";var mp=mr(),gp=Ee();So.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 To=R((Pw,ko)=>{"use strict";var Ao=xe(),Ls=pr(),{ANY:Ns}=Ls,gr=mr(),Ms=Ee(),Dp=(t,e,r={})=>{if(t===e)return!0;t=new Ao(t,r),e=new Ao(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")],$o=[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=$o}if(e.length===1&&e[0].semver===Ns){if(r.includePrerelease)return!0;e=$o}let s=new Set,n,i;for(let l of t)l.operator===">"||l.operator===">="?n=Io(n,l,r):l.operator==="<"||l.operator==="<="?i=Oo(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&&!gr(l,String(n),r)||i&&!gr(l,String(i),r))return null;for(let g of e)if(!gr(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=Io(n,l,r),a===l&&a!==n)return!1}else if(n.operator===">="&&!gr(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=Oo(i,l,r),c===l&&c!==i)return!1}else if(i.operator==="<="&&!gr(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)},Io=(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},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.exports=Dp});var Bs=R((Nw,Lo)=>{"use strict";var js=Bt(),Po=lr(),Ep=te(),No=Cs(),xp=vt(),vp=ai(),Cp=ui(),bp=fi(),Fp=mi(),Rp=Di(),Sp=wi(),_p=xi(),Ap=Ci(),$p=Ee(),Ip=Si(),Op=Ai(),kp=qr(),Tp=ki(),Pp=Pi(),Np=fr(),Lp=Ur(),Mp=Rs(),jp=Ss(),Bp=zr(),Wp=Vr(),qp=_s(),Up=zi(),zp=pr(),Vp=xe(),Gp=mr(),Hp=io(),Jp=ao(),Zp=uo(),Yp=po(),Xp=mo(),Kp=Jr(),Qp=xo(),eh=Co(),th=Ro(),rh=_o(),sh=To();Lo.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:Po.SEMVER_SPEC_VERSION,RELEASE_TYPES:Po.RELEASE_TYPES,compareIdentifiers:No.compareIdentifiers,rcompareIdentifiers:No.rcompareIdentifiers}});var as=R((iv,ec)=>{var mn=[],Qa=0,se=(t,e)=>{Qa>=e&&mn.push(t)};se.WARN=1;se.INFO=2;se.DEBUG=3;se.reset=()=>{mn=[]};se.setDebugLevel=t=>{Qa=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;ec.exports=se});var rc=R((ov,tc)=>{"use strict";tc.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 nc=R((av,sc)=>{"use strict";var Zm=rc();sc.exports=t=>typeof t=="string"?t.replace(Zm(),""):t});var oc=R((cv,gn)=>{"use strict";var ic=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=ic;gn.exports.default=ic});var cc=R((uv,ac)=>{"use strict";ac.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 lc=R((lv,Dn)=>{"use strict";var Ym=nc(),Xm=oc(),Km=cc(),uc=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=uc;Dn.exports.default=uc});var yn=R((dv,hc)=>{var dc=lc();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 dc(i)>n?dc(i):n},0)}function Er(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=Er(r,i)+t;break}case"center":{let o=Math.ceil(i/2),a=i-o;t=Er(r,a)+t+Er(r,o);break}default:{t=t+Er(r,i);break}}}return t}var Xt={};function xr(t,e,r){e="\x1B["+e+"m",r="\x1B["+r+"m",Xt[e]={set:t,to:!0},Xt[r]={set:t,to:!1},Xt[t]={on:e,off:r}}xr("bold",1,22);xr("italics",3,23);xr("underline",4,24);xr("inverse",7,27);xr("strikethrough",9,29);function fc(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=Xt[e[0]];s&&(t[s.set]=s.to)}function eg(t){let e=cs(!0),r=e.exec(t),s={};for(;r!==null;)fc(s,r),r=e.exec(t);return s}function pc(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+=Xt[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=Xt[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],fc(c,a)}}return pc(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(pc(i,n))}return r}function dg(t,e){return["\x1B]","8",";",";",t||e,"\x07",e,"\x1B]","8",";",";","\x07"].join("")}hc.exports={strlen:Pe,repeat:Er,pad:Qm,truncate:ng,mergeOptions:og,wordWrap:ug,colorizeLines:lg,hyperlink:dg}});var yc=R((fv,Dc)=>{var gc={};Dc.exports=gc;var mc={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(mc).forEach(function(t){var e=mc[t],r=gc[t]=[];r.open="\x1B["+e[0]+"m",r.close="\x1B["+e[1]+"m"})});var Ec=R((pv,wc)=>{"use strict";wc.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 vc=R((hv,xc)=>{"use strict";var fg=On("os"),Ae=Ec(),oe=process.env,Kt=void 0;Ae("no-color")||Ae("no-colors")||Ae("color=false")?Kt=!1:(Ae("color")||Ae("colors")||Ae("color=true")||Ae("color=always"))&&(Kt=!0);"FORCE_COLOR"in oe&&(Kt=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(Kt===!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&&Kt!==!0)return 0;var e=Kt?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)}xc.exports={supportsColor:wn,stdout:wn(process.stdout),stderr:wn(process.stderr)}});var bc=R((mv,Cc)=>{Cc.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 Rc=R((gv,Fc)=>{Fc.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 _c=R((Dv,Sc)=>{Sc.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 $c=R((yv,Ac)=>{Ac.exports=function(t){return function(e,r,s){return r%2===0?e:t.inverse(e)}}});var Oc=R((wv,Ic)=>{Ic.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 Tc=R((Ev,kc)=>{kc.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 Bc=R((vv,jc)=>{var j={};jc.exports=j;j.themes={};var mg=On("util"),St=j.styles=yc(),Nc=Object.defineProperties,gg=new RegExp(/[\r\n]+/g);j.supportsColor=vc().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 Lc(t){var e=function r(){return Eg.apply(r,arguments)};return e._styles=t,e.__proto__=wg,e}var Mc=(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 Lc(this._styles.concat(e))}}}),t})(),wg=Nc(function(){},Mc);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(Mc).forEach(function(e){t[e]={get:function(){return Lc([e])}}}),t}var vg=function(e,r){var s=r.split("");return s=s.map(e),s.join("")};j.trap=bc();j.zalgo=Rc();j.maps={};j.maps.america=_c()(j);j.maps.zebra=$c()(j);j.maps.rainbow=Oc()(j);j.maps.random=Tc()(j);for(Pc in j.maps)(function(t){j[t]=function(e){return vg(j.maps[t],e)}})(Pc);var Pc;Nc(j,xg())});var qc=R((Cv,Wc)=>{var Cg=Bc();Wc.exports=Cg});var Gc=R((bv,us)=>{var{info:bg,debug:Vc}=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(zc,-1),this.height=this.heights.reduce(zc,-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=qc();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 vr;)p=this.cells[p.y][p.x-1];p instanceof Cr||(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 vr;)o=this.cells[o.y][o.x-1];o instanceof Cr||(s=this.chars.rightMid)}let n=e?this.chars.right:"",i=me.repeat(" ",this.width);return this.stylizeLine(s,i,n)}},vr=class{constructor(){}draw(e){return typeof e=="number"&&Vc(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},Cr=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"):(Vc(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+e))}mergeTableOptions(){}};function Uc(...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]=Uc(t[n],t[r],e[n],e[r])):s[r]=Uc(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 zc(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=vr;us.exports.RowSpanCell=Cr});var Zc=R((Fv,Jc)=>{var{warn:Sg,debug:_g}=as(),vn=Gc(),{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}Jc.exports={makeTableLayout:p,layoutTable:e,addRowSpanCells:a,maxWidth:r,fillInTable:d,computeWidths:Hc("colSpan","desiredWidth","x",1),computeHeights:Hc("rowSpan","desiredHeight","y",1)}})();function Hc(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 Xc=R((Rv,Yc)=>{var Ve=as(),Ig=yn(),Cn=Zc(),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(`
7
10
  `)}get width(){return this.toString().split(`
8
- `)[0].length}};ss.reset=()=>We.reset();function mn(t,e,r){let s=[];t.forEach(function(i){s.push(i.draw(e))});let n=s.join("");n.length&&r.push(n)}Iu.exports=ss});var wr=F((A0,ku)=>{ku.exports=$u()});import{command as Re,subcommands as MD,run as BD,positional as Kt,option as ac,string as Qe,optional as os,flag as vn}from"cmd-ts";import{writeFile as qp,mkdir as Wp,rm as Up}from"node:fs/promises";import zp from"ora";import{access as Op,constants as Tp,readFile as Os}from"node:fs/promises";import{join as wt}from"node:path";import{homedir as Pp}from"node:os";import{select as Np}from"@inquirer/prompts";import Rt from"chalk";var D={SUCCESS:0,VALIDATION_ERROR:1,IO_ERROR:2,DEPENDENCY_ERROR:3,AUTHENTICATION_ERROR:4,USER_CANCELLED:130},h=class t extends Error{constructor(r,s){super(r);this.exitCode=s;this.name="CLIError",Error.captureStackTrace(this,t)}};function us(t,e){let r=Rt.red("Error:"),s=e?` ${Rt.yellow(e)} failed:`:"";return`${r}${s} ${t.message}`}function er(t){return`${Rt.yellow("Warning:")} ${t}`}function J(t){return Rt.dim(t)}function R(t){return Rt.cyan(t)}function B(t){return Rt.cyan.bold(t)}function Cn(t){return t instanceof h?t.exitCode:D.VALIDATION_ERROR}import{promises as Ze}from"node:fs";import Xe from"node:path";import nr from"fs-extra";var f={};pc(f,{BRAND:()=>Bc,DIRTY:()=>et,EMPTY_PATH:()=>yc,INVALID:()=>$,NEVER:()=>Cl,OK:()=>ee,ParseStatus:()=>K,Schema:()=>P,ZodAny:()=>He,ZodArray:()=>Be,ZodBigInt:()=>rt,ZodBoolean:()=>st,ZodBranded:()=>rr,ZodCatch:()=>ht,ZodDate:()=>nt,ZodDefault:()=>pt,ZodDiscriminatedUnion:()=>br,ZodEffects:()=>Ee,ZodEnum:()=>dt,ZodError:()=>ue,ZodFirstPartyTypeKind:()=>k,ZodFunction:()=>Fr,ZodIntersection:()=>ut,ZodIssueCode:()=>g,ZodLazy:()=>ct,ZodLiteral:()=>lt,ZodMap:()=>kt,ZodNaN:()=>Tt,ZodNativeEnum:()=>ft,ZodNever:()=>Se,ZodNull:()=>ot,ZodNullable:()=>Te,ZodNumber:()=>tt,ZodObject:()=>ce,ZodOptional:()=>ye,ZodParsedType:()=>v,ZodPipeline:()=>sr,ZodPromise:()=>Ye,ZodReadonly:()=>mt,ZodRecord:()=>Cr,ZodSchema:()=>P,ZodSet:()=>Ot,ZodString:()=>Ge,ZodSymbol:()=>It,ZodTransformer:()=>Ee,ZodTuple:()=>Oe,ZodType:()=>P,ZodUndefined:()=>it,ZodUnion:()=>at,ZodUnknown:()=>Me,ZodVoid:()=>$t,addIssueToContext:()=>E,any:()=>Zc,array:()=>Qc,bigint:()=>zc,boolean:()=>Pn,coerce:()=>bl,custom:()=>kn,date:()=>Vc,datetimeRegex:()=>In,defaultErrorMap:()=>Le,discriminatedUnion:()=>sl,effect:()=>ml,enum:()=>fl,function:()=>cl,getErrorMap:()=>St,getParsedType:()=>ke,instanceof:()=>Wc,intersection:()=>nl,isAborted:()=>xr,isAsync:()=>_t,isDirty:()=>vr,isValid:()=>Ve,late:()=>qc,lazy:()=>ll,literal:()=>dl,makeIssue:()=>tr,map:()=>al,nan:()=>Uc,nativeEnum:()=>pl,never:()=>Jc,null:()=>Yc,nullable:()=>gl,number:()=>Tn,object:()=>el,objectUtil:()=>cs,oboolean:()=>vl,onumber:()=>xl,optional:()=>Dl,ostring:()=>El,pipeline:()=>wl,preprocess:()=>yl,promise:()=>hl,quotelessJson:()=>mc,record:()=>ol,set:()=>ul,setErrorMap:()=>gc,strictObject:()=>tl,string:()=>On,symbol:()=>Gc,transformer:()=>ml,tuple:()=>il,undefined:()=>Hc,union:()=>rl,unknown:()=>Xc,util:()=>N,void:()=>Kc});var N;(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})(N||(N={}));var cs;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(cs||(cs={}));var v=N.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ke=t=>{switch(typeof t){case"undefined":return v.undefined;case"string":return v.string;case"number":return Number.isNaN(t)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(t)?v.array:t===null?v.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?v.promise:typeof Map<"u"&&t instanceof Map?v.map:typeof Set<"u"&&t instanceof Set?v.set:typeof Date<"u"&&t instanceof Date?v.date:v.object;default:return v.unknown}};var g=N.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"]),mc=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ue=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,u=0;for(;u<o.path.length;){let c=o.path[u];u===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(o))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};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,N.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()}};ue.create=t=>new ue(t);var Dc=(t,e)=>{let r;switch(t.code){case g.invalid_type:t.received===v.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case g.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,N.jsonStringifyReplacer)}`;break;case g.unrecognized_keys:r=`Unrecognized key(s) in object: ${N.joinValues(t.keys,", ")}`;break;case g.invalid_union:r="Invalid input";break;case g.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${N.joinValues(t.options)}`;break;case g.invalid_enum_value:r=`Invalid enum value. Expected ${N.joinValues(t.options)}, received '${t.received}'`;break;case g.invalid_arguments:r="Invalid function arguments";break;case g.invalid_return_type:r="Invalid function return type";break;case g.invalid_date:r="Invalid date";break;case g.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}"`:N.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case g.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 g.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 g.custom:r="Invalid input";break;case g.invalid_intersection_types:r="Intersection results could not be merged";break;case g.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case g.not_finite:r="Number must be finite";break;default:r=e.defaultError,N.assertNever(t)}return{message:r}},Le=Dc;var Fn=Le;function gc(t){Fn=t}function St(){return Fn}var tr=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="",u=s.filter(c=>!!c).slice().reverse();for(let c of u)a=c(o,{data:e,defaultError:a}).message;return{...n,path:i,message:a}},yc=[];function E(t,e){let r=St(),s=tr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Le?void 0:Le].filter(n=>!!n)});t.common.issues.push(s)}var K=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 $;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.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}}},$=Object.freeze({status:"aborted"}),et=t=>({status:"dirty",value:t}),ee=t=>({status:"valid",value:t}),xr=t=>t.status==="aborted",vr=t=>t.status==="dirty",Ve=t=>t.status==="valid",_t=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 we=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}},Rn=(t,e)=>{if(Ve(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 ue(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:u}=t;return o.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??s??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:u??r??a.defaultError}},description:n}}var P=class{get description(){return this._def.description}_getType(e){return ke(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ke(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new K,ctx:{common:e.parent.common,data:e.data,parsedType:ke(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(_t(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:ke(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Rn(s,n)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ke(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:r});return Ve(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=>Ve(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:ke(e)},n=this._parse({data:e,path:s.path,parent:s}),i=await(_t(n)?n:Promise.resolve(n));return Rn(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:g.custom,...s(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!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 Ee({schema:this,typeName:k.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 ye.create(this,this._def)}nullable(){return Te.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Be.create(this)}promise(){return Ye.create(this,this._def)}or(e){return at.create([this,e],this._def)}and(e){return ut.create(this,e,this._def)}transform(e){return new Ee({...T(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new pt({...T(this._def),innerType:this,defaultValue:r,typeName:k.ZodDefault})}brand(){return new rr({typeName:k.ZodBranded,type:this,...T(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ht({...T(this._def),innerType:this,catchValue:r,typeName:k.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return sr.create(this,e)}readonly(){return mt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},wc=/^c[^\s-]{8,}$/i,Ec=/^[0-9a-z]+$/,xc=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vc=/^[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,bc=/^[a-z0-9_-]{21}$/i,Cc=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Fc=/^[-+]?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)?)??$/,Rc=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Sc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ls,_c=/^(?:(?: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])$/,Ac=/^(?:(?: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])$/,Ic=/^(([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]))$/,$c=/^(([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])$/,kc=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Oc=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,_n="((\\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])))",Tc=new RegExp(`^${_n}$`);function An(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 Pc(t){return new RegExp(`^${An(t)}$`)}function In(t){let e=`${_n}T${An(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 Nc(t,e){return!!((e==="v4"||!e)&&_c.test(t)||(e==="v6"||!e)&&Ic.test(t))}function Lc(t,e){if(!Cc.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 jc(t,e){return!!((e==="v4"||!e)&&Ac.test(t)||(e==="v6"||!e)&&$c.test(t))}var Ge=class t extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){let i=this._getOrReturnCtx(e);return E(i,{code:g.invalid_type,expected:v.string,received:i.parsedType}),$}let s=new K,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:g.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:g.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:g.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&E(n,{code:g.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")Rc.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"email",code:g.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")ls||(ls=new RegExp(Sc,"u")),ls.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"emoji",code:g.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")vc.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"uuid",code:g.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")bc.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"nanoid",code:g.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")wc.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cuid",code:g.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")Ec.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cuid2",code:g.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")xc.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"ulid",code:g.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:g.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:g.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:g.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:g.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:g.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?In(i).test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:g.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?Tc.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:g.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?Pc(i).test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:g.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?Fc.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"duration",code:g.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?Nc(e.data,i.version)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"ip",code:g.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?Lc(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"jwt",code:g.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?jc(e.data,i.version)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cidr",code:g.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?kc.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"base64",code:g.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?Oc.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"base64url",code:g.invalid_string,message:i.message}),s.dirty()):N.assertNever(i);return{status:s.value,value:e.data}}_regex(e,r,s){return this.refinement(n=>e.test(n),{validation:r,code:g.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}};Ge.create=t=>new Ge({checks:[],typeName:k.ZodString,coerce:t?.coerce??!1,...T(t)});function Mc(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 tt=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)!==v.number){let i=this._getOrReturnCtx(e);return E(i,{code:g.invalid_type,expected:v.number,received:i.parsedType}),$}let s,n=new K;for(let i of this._def.checks)i.kind==="int"?N.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{code:g.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:g.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:g.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?Mc(e.data,i.value)!==0&&(s=this._getOrReturnCtx(e,s),E(s,{code:g.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:g.not_finite,message:i.message}),n.dirty()):N.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"&&N.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)}};tt.create=t=>new tt({checks:[],typeName:k.ZodNumber,coerce:t?.coerce||!1,...T(t)});var rt=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)!==v.bigint)return this._getInvalidInput(e);let s,n=new K;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:g.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:g.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:g.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):N.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return E(r,{code:g.invalid_type,expected:v.bigint,received:r.parsedType}),$}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}};rt.create=t=>new rt({checks:[],typeName:k.ZodBigInt,coerce:t?.coerce??!1,...T(t)});var st=class extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){let s=this._getOrReturnCtx(e);return E(s,{code:g.invalid_type,expected:v.boolean,received:s.parsedType}),$}return ee(e.data)}};st.create=t=>new st({typeName:k.ZodBoolean,coerce:t?.coerce||!1,...T(t)});var nt=class t extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){let i=this._getOrReturnCtx(e);return E(i,{code:g.invalid_type,expected:v.date,received:i.parsedType}),$}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return E(i,{code:g.invalid_date}),$}let s=new K,n;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:g.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:g.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):N.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}};nt.create=t=>new nt({checks:[],coerce:t?.coerce||!1,typeName:k.ZodDate,...T(t)});var It=class extends P{_parse(e){if(this._getType(e)!==v.symbol){let s=this._getOrReturnCtx(e);return E(s,{code:g.invalid_type,expected:v.symbol,received:s.parsedType}),$}return ee(e.data)}};It.create=t=>new It({typeName:k.ZodSymbol,...T(t)});var it=class extends P{_parse(e){if(this._getType(e)!==v.undefined){let s=this._getOrReturnCtx(e);return E(s,{code:g.invalid_type,expected:v.undefined,received:s.parsedType}),$}return ee(e.data)}};it.create=t=>new it({typeName:k.ZodUndefined,...T(t)});var ot=class extends P{_parse(e){if(this._getType(e)!==v.null){let s=this._getOrReturnCtx(e);return E(s,{code:g.invalid_type,expected:v.null,received:s.parsedType}),$}return ee(e.data)}};ot.create=t=>new ot({typeName:k.ZodNull,...T(t)});var He=class extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return ee(e.data)}};He.create=t=>new He({typeName:k.ZodAny,...T(t)});var Me=class extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ee(e.data)}};Me.create=t=>new Me({typeName:k.ZodUnknown,...T(t)});var Se=class extends P{_parse(e){let r=this._getOrReturnCtx(e);return E(r,{code:g.invalid_type,expected:v.never,received:r.parsedType}),$}};Se.create=t=>new Se({typeName:k.ZodNever,...T(t)});var $t=class extends P{_parse(e){if(this._getType(e)!==v.undefined){let s=this._getOrReturnCtx(e);return E(s,{code:g.invalid_type,expected:v.void,received:s.parsedType}),$}return ee(e.data)}};$t.create=t=>new $t({typeName:k.ZodVoid,...T(t)});var Be=class t extends P{_parse(e){let{ctx:r,status:s}=this._processInputParams(e),n=this._def;if(r.parsedType!==v.array)return E(r,{code:g.invalid_type,expected:v.array,received:r.parsedType}),$;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?g.too_big:g.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:g.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:g.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 we(r,o,r.path,a)))).then(o=>K.mergeArray(s,o));let i=[...r.data].map((o,a)=>n.type._parseSync(new we(r,o,r.path,a)));return K.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)}};Be.create=(t,e)=>new Be({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...T(e)});function At(t){if(t instanceof ce){let e={};for(let r in t.shape){let s=t.shape[r];e[r]=ye.create(At(s))}return new ce({...t._def,shape:()=>e})}else return t instanceof Be?new Be({...t._def,type:At(t.element)}):t instanceof ye?ye.create(At(t.unwrap())):t instanceof Te?Te.create(At(t.unwrap())):t instanceof Oe?Oe.create(t.items.map(e=>At(e))):t}var ce=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=N.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==v.object){let c=this._getOrReturnCtx(e);return E(c,{code:g.invalid_type,expected:v.object,received:c.parsedType}),$}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 c in n.data)o.includes(c)||a.push(c);let u=[];for(let c of o){let l=i[c],p=n.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new we(n,p,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Se){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of a)u.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")a.length>0&&(E(n,{code:g.unrecognized_keys,keys:a}),s.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of a){let p=n.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new we(n,p,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of u){let p=await l.key,y=await l.value;c.push({key:p,value:y,alwaysSet:l.alwaysSet})}return c}).then(c=>K.mergeObjectSync(s,c)):K.mergeObjectSync(s,u)}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:k.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 N.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 N.objectKeys(this.shape))e[s]||(r[s]=this.shape[s]);return new t({...this._def,shape:()=>r})}deepPartial(){return At(this)}partial(e){let r={};for(let s of N.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 N.objectKeys(this.shape))if(e&&!e[s])r[s]=this.shape[s];else{let i=this.shape[s];for(;i instanceof ye;)i=i._def.innerType;r[s]=i}return new t({...this._def,shape:()=>r})}keyof(){return $n(N.objectKeys(this.shape))}};ce.create=(t,e)=>new ce({shape:()=>t,unknownKeys:"strip",catchall:Se.create(),typeName:k.ZodObject,...T(e)});ce.strictCreate=(t,e)=>new ce({shape:()=>t,unknownKeys:"strict",catchall:Se.create(),typeName:k.ZodObject,...T(e)});ce.lazycreate=(t,e)=>new ce({shape:t,unknownKeys:"strip",catchall:Se.create(),typeName:k.ZodObject,...T(e)});var at=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 ue(a.ctx.common.issues));return E(r,{code:g.invalid_union,unionErrors:o}),$}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 u of s){let c={...r,common:{...r.common,issues:[]},parent:null},l=u._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(u=>new ue(u));return E(r,{code:g.invalid_union,unionErrors:a}),$}}get options(){return this._def.options}};at.create=(t,e)=>new at({options:t,typeName:k.ZodUnion,...T(e)});var je=t=>t instanceof ct?je(t.schema):t instanceof Ee?je(t.innerType()):t instanceof lt?[t.value]:t instanceof dt?t.options:t instanceof ft?N.objectValues(t.enum):t instanceof pt?je(t._def.innerType):t instanceof it?[void 0]:t instanceof ot?[null]:t instanceof ye?[void 0,...je(t.unwrap())]:t instanceof Te?[null,...je(t.unwrap())]:t instanceof rr||t instanceof mt?je(t.unwrap()):t instanceof ht?je(t._def.innerType):[],br=class t extends P{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.object)return E(r,{code:g.invalid_type,expected:v.object,received:r.parsedType}),$;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:g.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),$)}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=je(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:k.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...T(s)})}};function ds(t,e){let r=ke(t),s=ke(e);if(t===e)return{valid:!0,data:t};if(r===v.object&&s===v.object){let n=N.objectKeys(e),i=N.objectKeys(t).filter(a=>n.indexOf(a)!==-1),o={...t,...e};for(let a of i){let u=ds(t[a],e[a]);if(!u.valid)return{valid:!1};o[a]=u.data}return{valid:!0,data:o}}else if(r===v.array&&s===v.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],u=ds(o,a);if(!u.valid)return{valid:!1};n.push(u.data)}return{valid:!0,data:n}}else return r===v.date&&s===v.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var ut=class extends P{_parse(e){let{status:r,ctx:s}=this._processInputParams(e),n=(i,o)=>{if(xr(i)||xr(o))return $;let a=ds(i.value,o.value);return a.valid?((vr(i)||vr(o))&&r.dirty(),{status:r.value,value:a.data}):(E(s,{code:g.invalid_intersection_types}),$)};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}))}};ut.create=(t,e,r)=>new ut({left:t,right:e,typeName:k.ZodIntersection,...T(r)});var Oe=class t extends P{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==v.array)return E(s,{code:g.invalid_type,expected:v.array,received:s.parsedType}),$;if(s.data.length<this._def.items.length)return E(s,{code:g.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$;!this._def.rest&&s.data.length>this._def.items.length&&(E(s,{code:g.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...s.data].map((o,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new we(s,o,s.path,a)):null}).filter(o=>!!o);return s.common.async?Promise.all(i).then(o=>K.mergeArray(r,o)):K.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:k.ZodTuple,rest:null,...T(e)})};var Cr=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!==v.object)return E(s,{code:g.invalid_type,expected:v.object,received:s.parsedType}),$;let n=[],i=this._def.keyType,o=this._def.valueType;for(let a in s.data)n.push({key:i._parse(new we(s,a,s.path,a)),value:o._parse(new we(s,s.data[a],s.path,a)),alwaysSet:a in s.data});return s.common.async?K.mergeObjectAsync(r,n):K.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:k.ZodRecord,...T(s)}):new t({keyType:Ge.create(),valueType:e,typeName:k.ZodRecord,...T(r)})}},kt=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!==v.map)return E(s,{code:g.invalid_type,expected:v.map,received:s.parsedType}),$;let n=this._def.keyType,i=this._def.valueType,o=[...s.data.entries()].map(([a,u],c)=>({key:n._parse(new we(s,a,s.path,[c,"key"])),value:i._parse(new we(s,u,s.path,[c,"value"]))}));if(s.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of o){let c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return $;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let u of o){let c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return $;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}}}};kt.create=(t,e,r)=>new kt({valueType:e,keyType:t,typeName:k.ZodMap,...T(r)});var Ot=class t extends P{_parse(e){let{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==v.set)return E(s,{code:g.invalid_type,expected:v.set,received:s.parsedType}),$;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(E(s,{code:g.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:g.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(u){let c=new Set;for(let l of u){if(l.status==="aborted")return $;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let a=[...s.data.values()].map((u,c)=>i._parse(new we(s,u,s.path,c)));return s.common.async?Promise.all(a).then(u=>o(u)):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)}};Ot.create=(t,e)=>new Ot({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...T(e)});var Fr=class t extends P{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.function)return E(r,{code:g.invalid_type,expected:v.function,received:r.parsedType}),$;function s(a,u){return tr({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,St(),Le].filter(c=>!!c),issueData:{code:g.invalid_arguments,argumentsError:u}})}function n(a,u){return tr({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,St(),Le].filter(c=>!!c),issueData:{code:g.invalid_return_type,returnTypeError:u}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Ye){let a=this;return ee(async function(...u){let c=new ue([]),l=await a._def.args.parseAsync(u,i).catch(d=>{throw c.addIssue(s(u,d)),c}),p=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(p,i).catch(d=>{throw c.addIssue(n(p,d)),c})})}else{let a=this;return ee(function(...u){let c=a._def.args.safeParse(u,i);if(!c.success)throw new ue([s(u,c.error)]);let l=Reflect.apply(o,this,c.data),p=a._def.returns.safeParse(l,i);if(!p.success)throw new ue([n(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Oe.create(e).rest(Me.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(Me.create()),returns:r||Me.create(),typeName:k.ZodFunction,...T(s)})}},ct=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})}};ct.create=(t,e)=>new ct({getter:t,typeName:k.ZodLazy,...T(e)});var lt=class extends P{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return E(r,{received:r.data,code:g.invalid_literal,expected:this._def.value}),$}return{status:"valid",value:e.data}}get value(){return this._def.value}};lt.create=(t,e)=>new lt({value:t,typeName:k.ZodLiteral,...T(e)});function $n(t,e){return new dt({values:t,typeName:k.ZodEnum,...T(e)})}var dt=class t extends P{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),s=this._def.values;return E(r,{expected:N.joinValues(s),received:r.parsedType,code:g.invalid_type}),$}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:g.invalid_enum_value,options:s}),$}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})}};dt.create=$n;var ft=class extends P{_parse(e){let r=N.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==v.string&&s.parsedType!==v.number){let n=N.objectValues(r);return E(s,{expected:N.joinValues(n),received:s.parsedType,code:g.invalid_type}),$}if(this._cache||(this._cache=new Set(N.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=N.objectValues(r);return E(s,{received:s.data,code:g.invalid_enum_value,options:n}),$}return ee(e.data)}get enum(){return this._def.values}};ft.create=(t,e)=>new ft({values:t,typeName:k.ZodNativeEnum,...T(e)});var Ye=class extends P{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.promise&&r.common.async===!1)return E(r,{code:g.invalid_type,expected:v.promise,received:r.parsedType}),$;let s=r.parsedType===v.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:k.ZodPromise,...T(e)});var Ee=class extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.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 $;let u=await this._def.schema._parseAsync({data:a,path:s.path,parent:s});return u.status==="aborted"?$:u.status==="dirty"?et(u.value):r.value==="dirty"?et(u.value):u});{if(r.value==="aborted")return $;let a=this._def.schema._parseSync({data:o,path:s.path,parent:s});return a.status==="aborted"?$:a.status==="dirty"?et(a.value):r.value==="dirty"?et(a.value):a}}if(n.type==="refinement"){let o=a=>{let u=n.refinement(a,i);if(s.common.async)return Promise.resolve(u);if(u 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"?$:(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"?$:(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(!Ve(o))return $;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=>Ve(o)?Promise.resolve(n.transform(o.value,i)).then(a=>({status:r.value,value:a})):$);N.assertNever(n)}};Ee.create=(t,e,r)=>new Ee({schema:t,typeName:k.ZodEffects,effect:e,...T(r)});Ee.createWithPreprocess=(t,e,r)=>new Ee({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...T(r)});var ye=class extends P{_parse(e){return this._getType(e)===v.undefined?ee(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ye.create=(t,e)=>new ye({innerType:t,typeName:k.ZodOptional,...T(e)});var Te=class extends P{_parse(e){return this._getType(e)===v.null?ee(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Te.create=(t,e)=>new Te({innerType:t,typeName:k.ZodNullable,...T(e)});var pt=class extends P{_parse(e){let{ctx:r}=this._processInputParams(e),s=r.data;return r.parsedType===v.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};pt.create=(t,e)=>new pt({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...T(e)});var ht=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 _t(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ue(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ue(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};ht.create=(t,e)=>new ht({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...T(e)});var Tt=class extends P{_parse(e){if(this._getType(e)!==v.nan){let s=this._getOrReturnCtx(e);return E(s,{code:g.invalid_type,expected:v.nan,received:s.parsedType}),$}return{status:"valid",value:e.data}}};Tt.create=t=>new Tt({typeName:k.ZodNaN,...T(t)});var Bc=Symbol("zod_brand"),rr=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}},sr=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.status==="dirty"?(r.dirty(),et(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"?$: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:k.ZodPipeline})}},mt=class extends P{_parse(e){let r=this._def.innerType._parse(e),s=n=>(Ve(n)&&(n.value=Object.freeze(n.value)),n);return _t(r)?r.then(n=>s(n)):s(r)}unwrap(){return this._def.innerType}};mt.create=(t,e)=>new mt({innerType:t,typeName:k.ZodReadonly,...T(e)});function Sn(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function kn(t,e={},r){return t?He.create().superRefine((s,n)=>{let i=t(s);if(i instanceof Promise)return i.then(o=>{if(!o){let a=Sn(e,s),u=a.fatal??r??!0;n.addIssue({code:"custom",...a,fatal:u})}});if(!i){let o=Sn(e,s),a=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:a})}}):He.create()}var qc={object:ce.lazycreate},k;(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"})(k||(k={}));var Wc=(t,e={message:`Input not instance of ${t.name}`})=>kn(r=>r instanceof t,e),On=Ge.create,Tn=tt.create,Uc=Tt.create,zc=rt.create,Pn=st.create,Vc=nt.create,Gc=It.create,Hc=it.create,Yc=ot.create,Zc=He.create,Xc=Me.create,Jc=Se.create,Kc=$t.create,Qc=Be.create,el=ce.create,tl=ce.strictCreate,rl=at.create,sl=br.create,nl=ut.create,il=Oe.create,ol=Cr.create,al=kt.create,ul=Ot.create,cl=Fr.create,ll=ct.create,dl=lt.create,fl=dt.create,pl=ft.create,hl=Ye.create,ml=Ee.create,Dl=ye.create,gl=Te.create,yl=Ee.createWithPreprocess,wl=sr.create,El=()=>On().optional(),xl=()=>Tn().optional(),vl=()=>Pn().optional(),bl={string:(t=>Ge.create({...t,coerce:!0})),number:(t=>tt.create({...t,coerce:!0})),boolean:(t=>st.create({...t,coerce:!0})),bigint:(t=>rt.create({...t,coerce:!0})),date:(t=>nt.create({...t,coerce:!0}))};var Cl=$;import{promises as Al}from"node:fs";import{join as Il,isAbsolute as $l,normalize as kl}from"node:path";var Rr=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)"),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 Fl=f.string().regex(/^[a-z0-9-]+@\d+\.\d+\.\d+$/,"Key must be name@version"),Rl=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"),Sl=f.object({source:Rl,hash:f.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>")}),Nn=f.record(Fl,Sl);var _l=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"))}),Wg=f.object({createdAt:f.string().datetime("createdAt must be ISO-8601 format"),entries:f.array(_l)});function Sr(t){try{return Rr.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:
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)}Yc.exports=ls});var br=R((Sv,Kc)=>{Kc.exports=Xc()});import{command as Fe,subcommands as pD,run as hD,positional as _t,option as Su,string as Ge,optional as nr,flag as In}from"cmd-ts";import{writeFile as ea,mkdir as ta,rm as ra}from"node:fs/promises";import sa from"ora";import{access as ch,constants as uh,readFile as Uo}from"node:fs/promises";import{join as Wt}from"node:path";import{homedir as lh}from"node:os";import{select as dh}from"@inquirer/prompts";import $t 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=$t.red("Error:"),s=e?` ${$t.yellow(e)} failed:`:"";return`${r}${s} ${t.message}`}function It(t){return`${$t.yellow("Warning:")} ${t}`}function K(t){return $t.dim(t)}function S(t){return $t.cyan(t)}function H(t){return $t.cyan.bold(t)}function kn(t){return t instanceof m?t.exitCode:D.VALIDATION_ERROR}import{promises as Xe}from"node:fs";import Ke from"node:path";import cr 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:()=>or,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:()=>Lt,ZodNaN:()=>jt,ZodNativeEnum:()=>gt,ZodNever:()=>Se,ZodNull:()=>lt,ZodNullable:()=>ke,ZodNumber:()=>it,ZodObject:()=>ue,ZodOptional:()=>De,ZodParsedType:()=>C,ZodPipeline:()=>ar,ZodPromise:()=>Ye,ZodReadonly:()=>wt,ZodRecord:()=>Ar,ZodSchema:()=>P,ZodSet:()=>Mt,ZodString:()=>Je,ZodSymbol:()=>Pt,ZodTransformer:()=>we,ZodTuple:()=>Oe,ZodType:()=>P,ZodUndefined:()=>ut,ZodUnion:()=>dt,ZodUnknown:()=>We,ZodVoid:()=>Nt,addIssueToContext:()=>E,any:()=>gl,array:()=>El,bigint:()=>dl,boolean:()=>zn,coerce:()=>zl,custom:()=>Wn,date:()=>fl,datetimeRegex:()=>jn,defaultErrorMap:()=>je,discriminatedUnion:()=>bl,effect:()=>Nl,enum:()=>kl,function:()=>$l,getErrorMap:()=>Ot,getParsedType:()=>Ie,instanceof:()=>ul,intersection:()=>Fl,isAborted:()=>Rr,isAsync:()=>kt,isDirty:()=>Sr,isValid:()=>He,late:()=>cl,lazy:()=>Il,literal:()=>Ol,makeIssue:()=>ir,map:()=>_l,nan:()=>ll,nativeEnum:()=>Tl,never:()=>yl,null:()=>ml,nullable:()=>Ml,number:()=>Un,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:()=>qn,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 Tn=je;function Mu(t){Tn=t}function Ot(){return Tn}var ir=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=Ot(),s=ir({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",kt=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}},Pn=(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(kt(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 Pn(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(kt(n)?n:Promise.resolve(n));return Pn(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 or({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 ar.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}(=)?))?$/,Ln="((\\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(`^${Ln}$`);function Mn(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(`^${Mn(t)}$`)}function jn(t){let e=`${Ln}T${Mn(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"?jn(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 Pt=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)}};Pt.create=t=>new Pt({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 Nt=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)}};Nt.create=t=>new Nt({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 Tt(t){if(t instanceof ue){let e={};for(let r in t.shape){let s=t.shape[r];e[r]=De.create(Tt(s))}return new ue({...t._def,shape:()=>e})}else return t instanceof qe?new qe({...t._def,type:Tt(t.element)}):t instanceof De?De.create(Tt(t.unwrap())):t instanceof ke?ke.create(Tt(t.unwrap())):t instanceof Oe?Oe.create(t.items.map(e=>Tt(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 Tt(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 Bn(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 or||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)})}},Lt=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}}}};Lt.create=(t,e,r)=>new Lt({valueType:e,keyType:t,typeName:O.ZodMap,...T(r)});var Mt=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)}};Mt.create=(t,e)=>new Mt({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 ir({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ot(),je].filter(u=>!!u),issueData:{code:y.invalid_arguments,argumentsError:c}})}function n(a,c){return ir({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ot(),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 Bn(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=Bn;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 kt(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 jt=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}}};jt.create=t=>new jt({typeName:O.ZodNaN,...T(t)});var al=Symbol("zod_brand"),or=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}},ar=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 kt(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 Nn(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Wn(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=Nn(e,s),c=a.fatal??r??!0;n.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=Nn(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}`})=>Wn(r=>r instanceof t,e),qn=Je.create,Un=it.create,ll=jt.create,dl=ot.create,zn=at.create,fl=ct.create,pl=Pt.create,hl=ut.create,ml=lt.create,gl=Ze.create,Dl=We.create,yl=Se.create,wl=Nt.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=Lt.create,Al=Mt.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=ar.create,Wl=()=>qn().optional(),ql=()=>Un().optional(),Ul=()=>zn().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>")}),Vn=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:
9
12
  ${r.join(`
10
- `)}`)}throw e}}function _r(t){let e=new Set;for(let r of t){if(r.includes(".."))throw new Error(`Path traversal not allowed: ${r}`);if($l(r)||/^[A-Za-z]:\\/.test(r))throw new Error(`Absolute paths not allowed: ${r}`);let s=kl(r).replace(/\\/g,"/");if(e.has(s))throw new Error(`Duplicate file path: ${r}`);e.add(s)}}async function Ln(t,e){let r=[];for(let s of t){let n=Il(e,s);try{await Al.access(n)}catch{r.push(s)}}if(r.length>0)throw new Error(`Files not found: ${r.join(", ")}`)}function Ol(t){if(t.includes(".."))throw new Error(`Path traversal not allowed: ${t}`);return t.replace(/\\/g,"/")}function Dt(t,e){let r=Xe.resolve(t).replace(/\\/g,"/"),s=Xe.resolve(e).replace(/\\/g,"/");if(!r.startsWith(s))throw new Error(`Path escapes registry boundaries: ${t}`)}var gt=class{paths;rootPath;constructor(e="~/.spectrl/registry"){this.rootPath=Ol(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);Dt(s,this.rootPath);try{return(await Ze.stat(s)).isDirectory()}catch(n){if(n.code==="ENOENT")return!1;throw n}}async getManifest(e,r){let s=this.paths.manifest(e,r);Dt(s,this.rootPath);try{let n=await Ze.readFile(s,"utf-8"),i=JSON.parse(n);return Sr(i)}catch(n){throw n.code==="ENOENT"?new Error(`Manifest not found: ${e}@${r}`):n}}async list(){let e=[];try{await Ze.access(this.rootPath)}catch{return e}let r=await Ze.readdir(this.rootPath,{withFileTypes:!0});for(let s of r){if(!s.isDirectory())continue;let n=s.name,i=Xe.join(this.rootPath,n);try{let o=await Ze.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=Xe.join(this.rootPath,e);try{return(await Ze.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);Dt(s,this.rootPath),await nr.remove(s);let n=Xe.join(this.rootPath,e);(await Ze.readdir(n)).length===0&&await nr.remove(n)}async publish(e,r){if(_r(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);Dt(s,this.rootPath),Dt(n,this.rootPath),await nr.ensureDir(n);for(let a of e.files){let u=Xe.join(r,a),c=Xe.join(n,a);Dt(c,this.rootPath),await nr.ensureDir(Xe.dirname(c)),await nr.copy(u,c,{overwrite:!0,errorOnExist:!1,preserveTimestamps:!1})}let i=this.paths.manifest(e.name,e.version);Dt(i,this.rootPath);let o=`${JSON.stringify(e,null,2)}
11
- `;await Ze.writeFile(i,o,"utf-8")}};import{promises as jn}from"node:fs";import Ar from"node:path";var he=class extends Error{exitCode;constructor(e,r){super(e),this.exitCode=r,this.name="ResolverError"}},Ir=class{async loadIndex(e){try{let r=await jn.readFile(e,"utf-8"),s=JSON.parse(r);return Nn.parse(s)}catch(r){throw this.isFileNotFoundError(r)?new he(`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,!Ar.isAbsolute(s)){let n=r||process.cwd();s=Ar.resolve(n,s)}try{let n=Ar.join(s,"spectrl.json"),i=await jn.readFile(n,"utf-8"),o=JSON.parse(i);return Rr.parse(o)}catch(n){throw this.isFileNotFoundError(n)?new he(`Missing source for ${e}`,1):new he(`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 d of s){let m=d.match(n);if(!m)throw new he(`Invalid index key: ${d}`,1);let[,w,x]=m;i.set(d,{name:w,version:x})}let o=new Map,a=Ar.dirname(e);for(let d of s){let m=i.get(d);if(!m)throw new he(`Internal error: missing parsed key ${d}`,1);let{name:w,version:x}=m,S=r[d];if(!S||!S.source)throw new he(`Missing source for ${d}`,1);let I=await this.readManifestFromSource(S.source,a);if(I.name!==w||I.version!==x)throw new he(`Manifest mismatch for ${d}: found ${I.name}@${I.version}`,1);o.set(d,{manifest:I,source:S.source})}let u=new Map;for(let[d,{manifest:m}]of o){let w=Object.entries(m.deps).map(([x,S])=>`${x}@${S}`).sort();for(let x of w)if(!r[x])throw new he(`Missing dependency: ${x}. Add it to .spectrl/spectrl-index.json`,3);u.set(d,w)}let c=(d,m,w)=>{m.add(d),w.add(d);let x=u.get(d)||[];for(let S of x)if(m.has(S)){if(w.has(S))throw new he(`Cyclic dependency detected: ${d} \u2192 ${S}`,3)}else if(c(S,m,w))return!0;return w.delete(d),!1},l=new Set;for(let d of s)l.has(d)||c(d,l,new Set);let p=[];for(let[d,{manifest:m,source:w}]of o){let x=Object.entries(m.deps).map(([S,I])=>`${S}@${I}`).sort();p.push({name:m.name,version:m.version,source:w,deps:x})}let y=p.map(d=>({node:d,key:`${d.name}@${d.version}`}));return y.sort((d,m)=>d.key.localeCompare(m.key)),y.map(d=>d.node)}};import{createHash as Tl}from"node:crypto";function $r(t){let{manifest:e,fileContents:r}=t,s=Tl("sha256"),n=Nl(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 u=Pl(a);s.update(u,"utf8")}return`sha256:${s.digest("hex")}`}function Pl(t){return t.replace(/\r\n/g,`
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 Gn(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 cr.remove(s);let n=Ke.join(this.rootPath,e);(await Xe.readdir(n)).length===0&&await cr.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 cr.ensureDir(n);for(let a of e.files){let c=Ke.join(r,a),u=Ke.join(n,a);Et(u,this.rootPath),await cr.ensureDir(Ke.dirname(u)),await cr.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 ur from"node:path";var Tr=Symbol("singleComment"),Hn=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=Hn,p++;continue}else if(o===Hn&&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 Jn(t,e){try{return JSON.parse(t)}catch{return JSON.parse(ys(t,{...e,trailingCommas:!0}))}}function xt(t){try{return Jn(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 Vn.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,!ur.isAbsolute(s)){let n=r||process.cwd();s=ur.resolve(n,s)}try{let n;try{n=await ws.readFile(ur.join(s,"spectrl.jsonc"),"utf-8")}catch{n=await ws.readFile(ur.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=ur.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,`
12
18
  `).replace(/\r/g,`
13
- `)}function Nl(t){let{hash:e,...r}=t;return fs(r)}function fs(t){return t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(fs).join(",")}]`:`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${fs(t[r])}`).join(",")}}`}var _o=Ft(ks(),1);function Ao(t,e){return _o.default.compare(t,e)}async function _e(t){try{return await Op(t,Tp.F_OK),!0}catch{return!1}}async function Io(t,e){if(await _e(t))throw new h(`File already exists: ${t}`,D.VALIDATION_ERROR)}function Lp(t){return wt(t,"spectrl.json")}function oe(t){return wt(t,".spectrl","spectrl-index.json")}function $o(t){return wt(t,".spectrl")}function fr(){return wt(Pp(),".spectrl","registry")}function Nt(t,e,r){return`${t}/${e}@${r}`}function zr(t,e,r){return`${t}-${e}@${r}`}function Vr(t,e,r,s){return wt(t,".spectrl","specs",zr(e,r,s))}function Ts(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"}function pr(t){return t instanceof Error}async function jp(t){try{let e=await Os(t,"utf-8");return JSON.parse(e)}catch(e){if(Ts(e)&&e.code==="ENOENT")throw new h(`File not found: ${t}`,D.IO_ERROR);if(e instanceof SyntaxError)throw new h(`Invalid JSON in ${t}: ${e.message}`,D.VALIDATION_ERROR);let r=pr(e)?e.message:"Unknown error";throw new h(`Failed to read ${t}: ${r}`,D.IO_ERROR)}}async function ko(t){let e=Lp(t),r=await jp(e);try{return Sr(r)}catch(s){let n=pr(s)?s.message:"Unknown validation error";throw new h(n,D.VALIDATION_ERROR)}}function Oo(t){try{_r(t)}catch(e){let r=pr(e)?e.message:"Invalid file paths";throw new h(r,D.VALIDATION_ERROR)}}async function To(t,e){try{await Ln(t,e)}catch(r){let s=pr(r)?r.message:"Files not found";throw new h(s,D.IO_ERROR)}}async function Ps(t,e=!0,r){try{let s=r?.yesLabel||"Yes",n=r?.noLabel||"No";return await Np({message:t,choices:[{name:s,value:!0},{name:n,value:!1}],default:e})}catch{return}}var A={log(t){console.log(t)},error(t){console.error(t)}},Mp=`
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 Mo=At(Bs(),1);function jo(t,e){return Mo.default.compare(t,e)}import{promises as Bo}from"node:fs";import{join as nh}from"node:path";var ih="spectrl.jsonc",oh="spectrl.json",ah=[ih,oh];async function Wo(t){for(let e of ah){let r=nh(t,e);try{return await Bo.access(r),r}catch{}}throw new Error(`No manifest found in ${t} (looked for spectrl.jsonc, spectrl.json)`)}async function qo(t){let e=await Wo(t),r=await Bo.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 zo(t,e){if(await Ue(t))throw new m(`File already exists: ${t}`,D.VALIDATION_ERROR)}function le(t){return Wt(t,".spectrl","spectrl-index.json")}function Ws(t){return Wt(t,".spectrl")}function qt(){return Wt(lh(),".spectrl","registry")}function Ut(t,e,r){return`${t}/${e}@${r}`}function Zr(t,e,r){return`${t}-${e}@${r}`}function Yr(t,e,r,s){return Wt(t,".spectrl","specs",Zr(e,r,s))}function Vo(t){return typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"}function Dr(t){return t instanceof Error}async function Go(t){let e;try{e=await qo(t)}catch(r){if(r instanceof m)throw r;let s=Dr(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=Dr(r)?r.message:"Unknown validation error";throw new m(s,D.VALIDATION_ERROR)}}function Ho(t){try{kr(t)}catch(e){let r=Dr(e)?e.message:"Invalid file paths";throw new m(r,D.VALIDATION_ERROR)}}async function Jo(t,e){try{await Gn(t,e)}catch(r){let s=Dr(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=`
14
20
  # Spectrl local registry
15
21
  # Track index and lock files, but ignore downloaded specs (like node_modules)
16
22
  .spectrl/specs/
17
- `;async function Bp(t){let e=wt(t,".gitignore");try{return(await Os(e,"utf-8")).includes(".spectrl/")}catch(r){return Ts(r)&&r.code==="ENOENT",!1}}async function Po(t){let e=wt(t,".gitignore");if(await Bp(t))return!1;try{let r="";try{r=await Os(e,"utf-8")}catch(i){if(!Ts(i)||i.code!=="ENOENT")throw i}let s=r;r.length>0&&!r.endsWith(`
23
+ `;async function ph(t){let e=Wt(t,".gitignore");try{return(await Uo(e,"utf-8")).includes(".spectrl/")}catch(r){return Vo(r)&&r.code==="ENOENT",!1}}async function Us(t){let e=Wt(t,".gitignore");if(await ph(t))return!1;try{let r="";try{r=await Uo(e,"utf-8")}catch(i){if(!Vo(i)||i.code!=="ENOENT")throw i}let s=r;r.length>0&&!r.endsWith(`
18
24
  `)&&(s+=`
19
- `),s+=Mp;let{writeFile:n}=await import("node:fs/promises");return await n(e,s,"utf-8"),!0}catch(r){let s=pr(r)?r.message:"Failed to update .gitignore";throw new h(`Failed to configure .gitignore: ${s}`,D.IO_ERROR)}}import{readFile as Mo,writeFile as Bo}from"node:fs/promises";import{join as Ns}from"node:path";var Gr="<!-- Added by Spectrl -->",No=`# Instructions for AI Assistants
25
+ `),s+=fh;let{writeFile:n}=await import("node:fs/promises");return await n(e,s,"utf-8"),!0}catch(r){let s=Dr(r)?r.message:"Failed to update .gitignore";throw new m(`Failed to configure .gitignore: ${s}`,D.IO_ERROR)}}import{readFile as Ko,writeFile as Qo}from"node:fs/promises";import{join as zs}from"node:path";var Xr="<!-- Added by Spectrl -->",Zo=`# AI Assistant Instructions for Spectrl
20
26
 
21
27
  ## What is Spectrl?
22
28
 
23
- Spectrl is a knowledge registry system that stores authoritative specifications for software projects. It ensures teams follow agreed-upon standards by making specs (PRDs, TDDs, ADRs, API conventions, security policies, etc.) the primary source of truth. Agents should consult these specs before generating code, reviewing changes, or answering technical questions.
29
+ Spectrl is a knowledge registry storing two types of authoritative content:
24
30
 
25
- ## Core Principles
26
-
27
- 1. **Specs are the primary source of truth** - Always check \`.spectrl/specs/\` first
28
- 2. **Never assume** - When ambiguous, ask questions rather than guessing
29
- 3. **Human decides** - When in doubt or low confidence, ask for clarification
30
- 4. **Be thorough but efficient** - Read what's needed, not everything blindly
31
-
32
- ## Primary Source of Truth
33
-
34
- ALWAYS consult specs in \`.spectrl/specs/\` before answering questions about:
35
-
36
- - API design and conventions
37
- - Security requirements and policies
38
- - Architecture patterns and decisions
39
- - Testing standards and best practices
40
- - Code style and formatting rules
41
- - Project-specific workflows and processes
42
-
43
- ## Installed Specs
44
-
45
- Check \`.spectrl/specs/\` directory for all installed specifications.
46
- 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.
47
-
48
- ## How to Use Specs
49
-
50
- ### 1. Before Answering
51
-
52
- - Check if a relevant spec exists in \`.spectrl/specs/\`
53
- - **If unsure whether a spec is relevant**: Ask the user rather than guessing
54
- - Example: "I see we have specs for api-design and security. Should I check both for authentication guidance, or is one more applicable here?"
55
-
56
- ### 2. Reading Multi-File Specs
57
-
58
- - Check for entry point files first: \`README.md\`, \`INDEX.md\`, or \`SPEC.md\`
59
- - Use entry point to guide which files to read for your specific question
60
- - If no entry point exists or question is broad, read all spec files
61
- - For specs with 20+ files and narrow questions: Scan filenames and initial sections to identify relevant parts
62
- - **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?"
63
- - Once you've read a spec in a conversation, you don't need to re-read it unless told it's changed
64
-
65
- ### 3. If Relevant Spec Exists
66
-
67
- - Read the spec files (following the multi-file guidance above)
68
- - Apply the specific patterns and requirements from the spec
69
- - Cite the spec when referencing requirements: \`[spec:name@version]\`
70
- - Prefer spec guidance over general best practices when they conflict
71
-
72
- ### 4. Following Spec Dependencies
73
-
74
- - If a spec references another spec (e.g., "see api-design@1.0 for auth patterns"), follow the reference
75
- - Continue following dependency chains up to 5 levels deep
76
- - **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?"
77
- - **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?"
78
-
79
- ### 5. If No Relevant Spec Exists OR Spec Doesn't Cover the Topic
80
-
81
- - Use your general knowledge and best practices
82
- - Mention that no spec was found: "Note: No spec found for [topic], using general best practices"
83
- - Suggest creating a spec if this seems like a recurring pattern
84
-
85
- ### 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.
86
33
 
87
- - Explicitly state the spec requirement: "Per [spec:security@2.0], authentication must use OAuth2"
88
- - **Ask for clarification**: "Would you like me to proceed with your suggested approach or follow the spec?"
89
- - Never assume the user wants to override the spec - always ask
90
- - If user chooses to deviate, document it clearly in code comments
34
+ Both are versioned, installable, and agent-readable.
91
35
 
92
- ### 7. When to Infer vs. Ask
36
+ ## Core Principles
93
37
 
94
- **Infer without asking when**:
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
95
43
 
96
- - Spec explicitly covers the topic with clear examples
97
- - Request directly matches a documented pattern in the spec
98
- - Spec terminology matches user's question exactly
99
- - The application is straightforward with no judgment calls needed
44
+ ## Discovering Installed Content
100
45
 
101
- **Ask before inferring when**:
46
+ Read \`.spectrl/catalog.md\` first \u2014 it lists all installed specs and powers with names, versions, types, descriptions, and "when to use" guidance:
102
47
 
103
- - Spec uses ambiguous language ("should", "consider", "typically")
104
- - Applying spec requires judgment call about scope or applicability
105
- - User's question uses different terminology than spec
106
- - Multiple valid interpretations exist
107
- - Stakes are high (security, data integrity, public APIs)
108
- - You're extrapolating from examples rather than explicit rules
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
+ \`\`\`
109
54
 
110
- **Always ask when**:
55
+ Load relevant items from \`.spectrl/specs/{name}@{version}/\`. If \`catalog.md\` is missing, fall back to \`.spectrl/spectrl-index.json\`.
111
56
 
112
- - Spec is silent or vague on the specific point
113
- - Applying spec could have significant side effects
114
- - User's context differs from spec's assumptions
115
- - You need to make assumptions to bridge gaps in the spec
57
+ ## Using Specs and Powers
116
58
 
117
- ### 8. Remembering Context
59
+ **Before acting:** Read the catalog \u2192 identify relevant items \u2192 load them \u2192 apply specs as context, follow powers as instructions.
118
60
 
119
- - Once a clarification is made in a conversation, remember it for subsequent questions
120
- - Example: If user clarifies that "auth" means "OAuth2" in their context, apply that understanding to future questions in the same conversation
121
- - 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.
122
62
 
123
- ## Priority and Conflict Resolution
63
+ **Powers (instructions):** Follow step-by-step when performing code reviews, refactoring, deployments, testing, etc. Cite as \`[power:name@version]\`.
124
64
 
125
- ### Multiple Specs Cover the Same Topic
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.
126
66
 
127
- - **Ask which takes precedence** rather than assuming
128
- - 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.
129
68
 
130
- ### Spec Version Handling
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.
131
70
 
132
- - Use the version specified in the user's request
133
- - If version not specified, use the latest version in \`.spectrl/specs/\`
134
- - **If uncertain about version choice**: Ask
135
- - 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
136
72
 
137
- ### Partial Spec Coverage
73
+ **Infer when:** Content explicitly covers the topic with clear examples and no judgment calls are needed.
138
74
 
139
- - Use spec guidance for what it covers
140
- - **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?"
141
- - 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.
142
76
 
143
- ### Outdated Specs
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.
144
78
 
145
- - Follow the spec as written (it's still the source of truth)
146
- - 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.
147
80
 
148
- ### Self-Contradictory Specs
81
+ ## Conflict Resolution
149
82
 
150
- - If a spec contradicts itself internally, cite both sections and ask: "I see conflicting guidance in [spec:X@Y] - Section A says [this] but Section B says [that]. Which should apply here?"
151
- - Never choose one interpretation silently
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 |
152
91
 
153
92
  ## Error Handling
154
93
 
155
- ### If \`.spectrl/specs/\` is Inaccessible or Empty
156
-
157
- - Inform user: "Unable to access specs directory at \`.spectrl/specs/\`. Proceeding with general knowledge."
158
- - Continue with best practices
159
- - Suggest fixing spec access if this seems unexpected
160
-
161
- ### If Spec Files are Malformed or Unreadable
162
-
163
- - Report the specific issue: "Found [spec:X@Y] but unable to read [file]. Should I proceed with available information or wait for spec access?"
164
- - Don't assume content - ask for help
165
-
166
- ### If Specs Contain Errors
167
-
168
- - 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?"
169
- - Never silently "correct" a spec - follow it as written and flag the concern
170
-
171
- ## Spec Locations
172
-
173
- All specs are symlinked in \`.spectrl/specs/{name}@{version}/\`
174
- These are the authoritative source of truth for this project. Read them before providing guidance on topics they cover.
175
-
176
- ## Example Workflows
177
-
178
- ### When Asked About Design, Standards, or Conventions
179
-
180
- 1. Check \`.spectrl/specs/\` to identify relevant specs
181
- 2. **If multiple specs might apply**: Ask which is most relevant
182
- 3. Read the applicable spec files (following multi-file guidance)
183
- 4. Follow any dependencies in the spec (up to 5 levels)
184
- 5. Apply those specific patterns and conventions
185
- 6. Cite using format: \`[spec:{name}@{version}]\`
186
-
187
- ### When Reviewing Code
188
-
189
- 1. Identify which specs apply to the code being reviewed
190
- 2. Check for violations of requirements in those specs
191
- 3. Point out specific requirements from specs with citations
192
- 4. Suggest fixes that align with spec guidance
193
- 5. **If interpretation is unclear**: Ask before flagging as violation
194
- 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?"
195
-
196
- ### When Generating Code
197
-
198
- 1. Check \`.spectrl/specs/\` for relevant standards before writing
199
- 2. **If unsure which specs apply**: List candidates and ask
200
- 3. Follow patterns and conventions from applicable specs
201
- 4. Use examples from specs when available
202
- 5. Cite the spec you followed
203
- 6. **If spec conflicts with modern best practices**: Ask which to prioritize
204
-
205
- ### For New Projects
206
-
207
- - 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?"
208
-
209
- ### In Time-Critical Situations
210
-
211
- - State: "I can check specs for the proper approach, or provide a quick solution if time is critical. Which would you prefer?"
212
- - 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"
213
97
 
214
98
  ## Key Reminders
215
99
 
216
- - **Never guess** - If you're unsure, ask questions
217
- - **Never improvise** - When confidence is low, seek clarification
218
- - **Human decides** - You're the assistant; the user makes final calls
219
- - **Be specific** - When asking questions, explain exactly what's unclear
220
- - **Cite sources** - Always attribute to specs or note when using general knowledge
221
- - **Be efficient** - Read what's needed, not everything. Use entry points and intelligent scanning
222
- - **Follow the chain** - Pursue spec dependencies to get complete context
223
- - **Remember context** - Don't ask the same question twice in a conversation
224
- - **Flag but follow** - If specs seem wrong or outdated, flag the concern but follow them anyway unless instructed otherwise
225
- `;function Lo(){return`${Gr}
226
- ${No}`}function jo(){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 Yo(){return`${Xr}
103
+ ${Zo}`}function Xo(){return`
227
104
 
228
105
  ---
229
106
 
230
- ${Gr}
231
- ${No}`}async function Ls(t){let e=Ns(t,"AGENTS.md");if(!await _e(e))return{exists:!1};try{return{exists:!0,hasMarker:(await Mo(e,"utf-8")).includes(Gr)}}catch{return{exists:!1}}}async function js(t){let e=Ns(t,"AGENTS.md"),r=Lo();try{await Bo(e,r,"utf-8")}catch(s){let n=s instanceof Error?s.message:"Unknown error";throw new h(`Failed to create AGENTS.md: ${n}`,D.IO_ERROR)}}async function Ms(t){let e=Ns(t,"AGENTS.md");try{let r=await Mo(e,"utf-8");r=r.trimEnd();let s=r+jo();await Bo(e,s,"utf-8")}catch(r){let s=r instanceof Error?r.message:"Unknown error";throw new h(`Failed to append to AGENTS.md: ${s}`,D.IO_ERROR)}}async function qo(t,e={}){let r=zp({text:"Initializing project",spinner:"line"}).start(),s=$o(t),n=!1;try{if(e.skipAgents&&e.forceAgents)throw r.stop(),new h("Cannot use both --skip-agents and --force-agents",D.VALIDATION_ERROR);let i=oe(t);await Io(i),await Wp(s,{recursive:!0}),n=!0;let a=`${JSON.stringify({},null,2)}
232
- `;await qp(i,a,"utf-8"),await Vp(t,e,r),r.text="Configuring .gitignore";let c=await Po(t)?" and configured .gitignore":" (.gitignore already configured)";r.succeed(`Initialized project index at ${R(".spectrl/spectrl-index.json")}${c}`)}catch(i){if(r.stop(),n&&i instanceof h&&i.exitCode===D.USER_CANCELLED)try{await Up(s,{recursive:!0,force:!0})}catch{}throw i}}async function Vp(t,e,r){if(e.skipAgents)return;if(e.forceAgents){let i=await Ls(t);if(i.exists)if(i.hasMarker)r.text="Initializing project",A.log(J("\u2713 AGENTS.md already contains Spectrl instructions"));else{r.text="Updating AGENTS.md";try{await Ms(t),r.text="Initializing project",A.log(J("\u2713 Added Spectrl instructions to AGENTS.md"))}catch{r.text="Initializing project",A.log(er("Failed to update AGENTS.md (non-critical)"))}}else{r.text="Creating AGENTS.md";try{await js(t),r.text="Initializing project",A.log(J("\u2713 Created AGENTS.md"))}catch{r.text="Initializing project",A.log(er("Failed to create AGENTS.md (non-critical)"))}}return}let s=await Ls(t);if(!s.exists){r.stop();let i=await Ps("Create AGENTS.md to configure AI assistants?",!0,{yesLabel:"Yes (recommended)",noLabel:"No"});if(i===void 0)throw new h("Initialization cancelled by user",D.USER_CANCELLED);if(r.start("Initializing project"),i){r.text="Creating AGENTS.md";try{await js(t),r.text="Initializing project",A.log(J("\u2713 Created AGENTS.md"))}catch{r.text="Initializing project",A.log(er("Failed to create AGENTS.md (non-critical)"))}}else A.log(J("\u2139 Skipped AGENTS.md creation")),A.log(J("AI assistants won't automatically consult specs. You can create AGENTS.md manually later."));return}if(s.hasMarker){r.text="Initializing project",A.log(J("\u2713 AGENTS.md already contains Spectrl instructions"));return}r.stop();let n=await Ps("AGENTS.md found. Append Spectrl instructions to the bottom?",!0,{yesLabel:"Yes (recommended)",noLabel:"No"});if(n===void 0)throw new h("Initialization cancelled by user",D.USER_CANCELLED);if(r.start("Initializing project"),n){r.text="Updating AGENTS.md";try{await Ms(t),r.text="Initializing project",A.log(J("\u2713 Added Spectrl instructions to AGENTS.md"))}catch{r.text="Initializing project",A.log(er("Failed to update AGENTS.md (non-critical)"))}}else A.log(J("\u2139 Skipped AGENTS.md update")),A.log(J("You can add Spectrl instructions manually if needed"))}import{readFile as Zo}from"node:fs/promises";import{join as Xo}from"node:path";import hh from"ora";import{select as mh}from"@inquirer/prompts";import Bs from"keytar";import Wo from"node-machine-id";import{createCipheriv as Gp,createDecipheriv as Hp,randomBytes as Uo,pbkdf2Sync as zo}from"node:crypto";import{existsSync as qs,mkdirSync as Yp,readFileSync as Zp,writeFileSync as Xp,unlinkSync as Jp,chmodSync as Kp}from"node:fs";import{homedir as Qp}from"node:os";import{join as Vo}from"node:path";var Ws="spectrl",Us="github-token",zs=Vo(Qp(),".spectrl"),Lt=Vo(zs,".auth"),eh=f.object({salt:f.string().length(64),iv:f.string().length(32),encrypted:f.string().min(1)}),be=class{async store(e){try{await Bs.setPassword(Ws,Us,e)}catch{this.storeEncrypted(e)}}async get(){try{return await Bs.getPassword(Ws,Us)}catch{return this.getEncrypted()}}async delete(){try{await Bs.deletePassword(Ws,Us)}catch{}this.deleteEncrypted()}storeEncrypted(e){try{qs(zs)||Yp(zs,{recursive:!0});let r=Uo(32),s=Uo(16),n=Wo.machineIdSync(),i=zo(n,r,1e5,32,"sha256"),o=Gp("aes-256-cbc",i,s),a=o.update(e,"utf8","hex");a+=o.final("hex");let u=JSON.stringify({salt:r.toString("hex"),iv:s.toString("hex"),encrypted:a});Xp(Lt,u,{encoding:"utf8"}),Kp(Lt,384)}catch(r){throw new Error(`Failed to store token: ${r instanceof Error?r.message:"Unknown error"}`)}}getEncrypted(){try{if(!qs(Lt))return null;let e=Zp(Lt,"utf8"),r=JSON.parse(e),s=eh.safeParse(r);if(!s.success)return null;let{salt:n,iv:i,encrypted:o}=s.data,a=Wo.machineIdSync(),u=zo(a,Buffer.from(n,"hex"),1e5,32,"sha256"),c=Hp("aes-256-cbc",u,Buffer.from(i,"hex")),l=c.update(o,"hex","utf8");return l+=c.final("utf8"),l}catch{return null}}deleteEncrypted(){try{qs(Lt)&&Jp(Lt)}catch{}}};import{config as th}from"dotenv";import{fileURLToPath as rh}from"node:url";import{dirname as sh,join as nh}from"node:path";var ih=rh(import.meta.url),oh=sh(ih);process.env.NODE_ENV!=="test"&&!process.env.VITEST&&th({path:nh(oh,"../../.env"),override:!1,quiet:!0});function Et(){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 Mw=f.object({device_code:f.string(),user_code:f.string(),verification_uri:f.string(),expires_in:f.number(),interval:f.number()}),Bw=f.object({token:f.string(),username:f.string()}),qw=f.object({status:f.string()}),Ww=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())}),uh=f.object({message:f.string(),url:f.string(),specId:f.string(),version:f.string()}),ch=f.object({specId:f.string(),description:f.string().optional(),tags:f.array(f.string()).optional(),version:f.string(),publishedAt:f.string()}),lh=f.object({results:f.array(ch),count:f.number()}),dh=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()}),fh=f.object({specId:f.string(),username:f.string(),specName:f.string(),versions:f.array(dh)}),ph=f.object({message:f.string()}),Y=class extends Error{constructor(r,s,n){super(r);this.statusCode=s;this.response=n;this.name="ApiError"}};async function Hr(t,e={}){let{maxAttempts:r=3,initialDelayMs:s=1e3,maxDelayMs:n=1e4,backoffMultiplier:i=2}=e,o,a=s;for(let u=1;u<=r;u++)try{return await t()}catch(c){if(o=c instanceof Error?c:new Error(String(c)),c instanceof Y&&c.statusCode&&c.statusCode<500)throw c;if(u===r)throw o;await new Promise(l=>setTimeout(l,a)),a=Math.min(a*i,n)}throw o||new Error("Retry failed")}async function Go(t,e,r){return Hr(async()=>{let s={manifest:e,files:r},n=ah.safeParse(s);if(!n.success)throw new Y(`Invalid request data: ${n.error.message}`,void 0,s);let i=await fetch(`${Et()}/publish`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(n.data)});if(!i.ok){let u=await i.text();throw new Y(`Failed to publish spec: ${u}`,i.status,u)}let o=await i.json(),a=uh.safeParse(o);if(!a.success)throw new Y("Invalid API response format after publishing.",i.status,o);return a.data})}async function Ho(t){return Hr(async()=>{let e=await fetch(`${Et()}/search?q=${encodeURIComponent(t)}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok){let n=await e.text();throw new Y(`Failed to search specs: ${n}`,e.status,n)}let r=await e.json(),s=lh.safeParse(r);if(!s.success)throw new Y("Invalid API response format. Expected search results but received unexpected data.",e.status,r);return s.data})}async function xt(t,e){return Hr(async()=>{let r=await fetch(`${Et()}/specs/${t}/${e}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok){let i=await r.text();throw new Y(`Failed to get spec: ${i}`,r.status,i)}let s=await r.json(),n=fh.safeParse(s);if(!n.success)throw new Y("Invalid API response format when fetching spec metadata.",r.status,s);return n.data})}async function Yo(t,e,r,s){return Hr(async()=>{let n=await fetch(`${Et()}/specs/${e}/${r}/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});if(!n.ok){let a=await n.text();throw new Y(`Failed to unpublish spec: ${a}`,n.status,a)}let i=await n.json(),o=ph.safeParse(i);if(!o.success)throw new Y("Invalid API response format after unpublishing.",n.status,i);return o.data})}async function Jo(t,e){let r=hh({text:"Publishing spec",spinner:"line"}).start();try{r.text="Validating manifest";let s=await ko(t);Oo(s.files),await To(s.files,t),r.stop();let n=await mh({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 Dh(t,s,e,r):await gh(t,s,r)}catch(s){throw r.stop(),s instanceof h?s:s instanceof Error?new h(s.message,D.IO_ERROR):new h("Unknown error during publish",D.IO_ERROR)}}async function Dh(t,e,r,s){s.text="Reading tracked files";let n={};for(let u of e.files){let c=Xo(t,u);try{n[u]=await Zo(c,"utf-8")}catch{throw new h(`Failed to read file: ${u}`,D.IO_ERROR)}}s.text="Computing hash";let i=$r({manifest:e,fileContents:n}),o={...e,hash:i};s.text="Writing to registry",await new gt(r??fr()).publish(o,t),s.succeed(`Published ${R(e.name)}@${R(e.version)} to local registry with hash ${R(i.substring(0,12))}`)}async function gh(t,e,r){r.text="Checking authentication";let n=await new be().get();if(!n)throw r.stop(),new h(`You need to login first. Run: ${B("spectrl login")}`,D.AUTHENTICATION_ERROR);if(!e.description)throw r.stop(),new h('Manifest must include a "description" field for public registry publishing',D.VALIDATION_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 u=Xo(t,a);try{let c=await Zo(u,"utf-8");o[a]=c}catch{throw new h(`Failed to read file: ${a}`,D.IO_ERROR)}}r.text="Publishing to public registry";try{let a={...i},u=await Go(n,a,o);r.succeed(`Published ${R(u.specId)}@${R(u.version)} to public registry`),console.log(`
233
- \u{1F517} ${u.url}
234
- `)}catch(a){throw a instanceof Error?new h(`Failed to publish to public registry: ${a.message}`,D.IO_ERROR):a}}import{promises as V}from"node:fs";import{dirname as Mt,join as W,resolve as Ko}from"node:path";import Z from"fs-extra";import Yr from"ora";import{select as Ch}from"@inquirer/prompts";var jt=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)"),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 yh=f.string().regex(/^[a-z0-9-]+@\d+\.\d+\.\d+$/,"Key must be name@version"),wh=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"),Eh=f.object({source:wh,hash:f.string().regex(/^sha256:[a-f0-9]{64}$/,"Hash must be in format sha256:<64 hex chars>")}),sE=f.record(yh,Eh);var xh=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"))}),oE=f.object({createdAt:f.string().datetime("createdAt must be ISO-8601 format"),entries:f.array(xh)});var vt={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 Ae(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("/")?bh(e):vh(e)}function vh(t){let e=t.indexOf("@");if(e===-1){let n=t;if(!vt.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(!vt.name.test(r))throw new Error(`Invalid spec name: ${r}. Must be lowercase alphanumeric with hyphens, 1-100 characters`);if(!vt.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 bh(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(!vt.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(!vt.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(!vt.name.test(i))throw new Error(`Invalid spec name: ${i}. Must be lowercase alphanumeric with hyphens, 1-100 characters`);if(!vt.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}}function Qo(){return process.env.REGISTRY_URL||"https://d12j78i0x57g1k.cloudfront.net"}async function ta(t,e,r,s,n){try{let i=oe(n),o=await V.readFile(i,"utf-8"),a=JSON.parse(o);if(r){let u=`${t}@${e}`;if(a[u])return{hasCollision:!0,existingType:"local",existingPath:W(n,".spectrl","specs",u),existingKey:u}}else for(let u of Object.keys(a))if(u.includes("/")){let c=u.split("/");if(c.length===2&&c[1]===`${t}@${e}`){let l=c[0];return{hasCollision:!0,existingType:"public",existingPath:W(n,".spectrl","specs",`${l}-${t}@${e}`),existingKey:u}}}return{hasCollision:!1,existingType:null,existingPath:null,existingKey:null}}catch{return{hasCollision:!1,existingType:null,existingPath:null,existingKey:null}}}async function Fh(t,e,r,s){return await Ch({message:`Warning: A ${t} spec '${r}' already exists.
107
+ ${Xr}
108
+ ${Zo}`}async function Vs(t){let e=zs(t,"AGENTS.md");if(!await Ue(e))return{exists:!1};try{return{exists:!0,hasMarker:(await Ko(e,"utf-8")).includes(Xr)}}catch{return{exists:!1}}}async function Gs(t){let e=zs(t,"AGENTS.md"),r=Yo();try{await Qo(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 Ko(e,"utf-8");r=r.trimEnd();let s=r+Xo();await Qo(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??sa({spinner:"line"}),i=!e.spinner;i?n.start("Initializing project"):n.text="Initializing spectrl in this project";try{await ta(s,{recursive:!0});let a=`${JSON.stringify({},null,2)}
109
+ `;await ea(r,a,"utf-8");let c=e.skipAgents??!process.stdin.isTTY;await ia(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 ra(s,{recursive:!0,force:!0})}catch{}throw i&&n.stop(),o}}async function na(t,e={}){v.log(It(`Note: "spectrl init" is deprecated. "spectrl install" now auto-initializes when needed.
110
+ This command will be removed in a future version.`));let r=sa({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 zo(i),await ta(s,{recursive:!0}),n=!0;let a=`${JSON.stringify({},null,2)}
111
+ `;await ea(i,a,"utf-8"),await ia(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 ra(s,{recursive:!0,force:!0})}catch{}throw i}}async function ia(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(It("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(It("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(It("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(It("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 pa}from"node:fs/promises";import{join as ha}from"node:path";import Nh from"ora";import{select as Lh}from"@inquirer/prompts";import Js from"keytar";import oa from"node-machine-id";import{createCipheriv as hh,createDecipheriv as mh,randomBytes as aa,pbkdf2Sync as ca}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 ua}from"node:path";var Ys="spectrl",Xs="github-token",Ks=ua(xh(),".spectrl"),zt=ua(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=aa(32),s=aa(16),n=oa.machineIdSync(),i=ca(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(zt,c,{encoding:"utf8"}),Eh(zt,384)}catch(r){throw new Error(`Failed to store token: ${r instanceof Error?r.message:"Unknown error"}`)}}getEncrypted(){try{if(!Zs(zt))return null;let e=Dh(zt,"utf8"),r=JSON.parse(e),s=vh.safeParse(r);if(!s.success)return null;let{salt:n,iv:i,encrypted:o}=s.data,a=oa.machineIdSync(),c=ca(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(zt)&&wh(zt)}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 la(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 da(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 fa(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??qt());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 ma(t,e){let r=Nh({text:"Publishing spec",spinner:"line"}).start();try{r.text="Validating manifest";let s=await Go(t);Ho(s.files),await Jo(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 (spectrl.pro)",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=ha(t,c);try{n[c]=await pa(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??qt()).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=ha(t,a);try{let u=await pa(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 la(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 Vt,join as B,resolve as ya}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 ga(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 Da(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,ga([]),"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,ga(i),"utf-8")}catch(a){throw new m(`Failed to generate catalog: ${a.message}`,D.IO_ERROR)}}async function yr(t){try{await Da(t)}catch(e){console.warn(`[spectrl] Warning: catalog generation failed: ${e instanceof Error?e.message:String(e)}`)}}function wa(){return process.env.REGISTRY_URL||"https://d12j78i0x57g1k.cloudfront.net"}async function xa(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.
235
118
  Installing ${e} spec '${s}' may cause confusion in dependency resolution.
236
119
 
237
- 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 ra(t,e,r,s){if(!t.hasCollision||!t.existingType||!t.existingKey||!t.existingPath)return;if(!process.stdin.isTTY)throw new h(["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(`
238
- `),D.VALIDATION_ERROR);if(await Fh(t.existingType,r,t.existingKey,e)==="cancel")throw new h("Installation cancelled by user",D.USER_CANCELLED);let i=Yr({text:`Removing existing ${t.existingType} spec '${t.existingKey}'`,spinner:"line"}).start();try{await Bt(t.existingPath);let o=oe(s),a=await V.readFile(o,"utf-8"),u=JSON.parse(a);if(t.existingKey in u){let c={...u};delete c[t.existingKey],await V.writeFile(o,`${JSON.stringify(c,null,2)}
239
- `,"utf-8")}i.succeed(`Removed ${t.existingType} spec '${t.existingKey}'`)}catch(o){throw i.fail("Failed to remove existing spec"),new h(`Failed to remove existing spec: ${o instanceof Error?o.message:String(o)}`,D.IO_ERROR)}}function Rh(){return process.platform==="win32"?"junction":"dir"}async function sa(t,e){try{if(!(await Z.lstat(t)).isSymbolicLink())return{exists:!0,isSymlink:!1,isCorrect:!1};let n=await Z.readlink(t),i=Ko(Mt(t),n),o=Ko(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 Bt(t){try{(await Z.lstat(t)).isSymbolicLink()?await Z.unlink(t):await Z.remove(t)}catch(e){let r=e;if(r.code!=="ENOENT")throw new h(`Failed to remove existing path ${t}: ${r.message}`,D.IO_ERROR)}}function Sh(){return process.env.SPECTRL_USE_COPY==="1"}async function ea(t,e,r){try{await Z.ensureDir(e);let s=W(Mt(t),"spectrl.json"),n=W(e,"spectrl.json");await Z.copy(s,n);let i=new Set;for(let o of r.files){let a=W(e,o);i.add(Mt(a))}for(let o of i)await Z.ensureDir(o);for(let o of r.files){let a=W(t,o),u=W(e,o);await Z.copy(a,u)}}catch(s){let n=s;throw new h(`Failed to copy files from registry: ${n.message}`,D.IO_ERROR)}}async function na(t,e,r,s){if(Sh())return s.info("Using file copy mode (SPECTRL_USE_COPY=1)"),await ea(t,e,r),"copy";if(!await Z.pathExists(t))throw new h(`Registry path not found: ${t}
240
-
241
- Has this spec been published? Run: ${B("spectrl publish")}`,D.DEPENDENCY_ERROR);try{await Z.ensureDir(Mt(e))}catch(i){let o=i;throw new h(`Failed to create parent directory for symlink: ${o.message}`,D.IO_ERROR)}try{let i=Rh();return await Z.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 Bt(e)}catch{}return await ea(t,e,r),"copy"}throw new h(`Failed to create symlink: ${o.message}`,D.IO_ERROR)}}function ia(t,e){let r;return t.startsWith("file://")?r=t.slice(7):t.startsWith("file:")?r=t.slice(5):r=t,r.startsWith("/")||(r=W(e,r)),r}async function _h(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=jt.safeParse(n);if(!i.success)throw new Error(`Invalid manifest format: ${i.error.issues[0].message}`);let o=i.data,a=new URL(t),u=`${a.protocol}//${a.host}`,c=a.pathname.split("/");c.pop();let l=c.join("/"),p={};for(let y of o.files){let d=`${u}${l}/files/${y}`,m=await fetch(d);if(!m.ok)throw new Error(`Failed to download ${y}: HTTP ${m.status}`);p[y]=await m.text()}return{manifest:o,fileContents:p}}catch(s){throw s instanceof Error?new h(`Failed to read files from ${t}: ${s.message}`,D.IO_ERROR):s}let r=ia(t,e);try{let s=W(r,"spectrl.json"),n=await V.readFile(s,"utf-8"),i=JSON.parse(n),o=jt.safeParse(i);if(!o.success)throw new Error(`Invalid manifest in ${r}: ${o.error.issues[0].message}`);let a=o.data,u=W(r,"files"),c=!1;try{c=(await V.stat(u)).isDirectory()}catch{c=!1}let l={};for(let p of a.files){let y=c?W(r,"files",p):W(r,p);l[p]=await V.readFile(y,"utf-8")}return{manifest:a,fileContents:l}}catch(s){throw s instanceof Error?new h(`Failed to read files from ${t}: ${s.message}`,D.IO_ERROR):s}}async function Ah(t,e){let r=await e.listVersions(t);if(r.length===0)throw new h(`Spec ${R(t)} not found in registry`,D.DEPENDENCY_ERROR);return r.sort((n,i)=>Ao(i,n))[0]}async function Vs(t,e){let{username:r,name:s,version:n}=t,{cwd:i}=e,o=Yr({text:`Resolving ${R(`${r}/${s}`)}`,spinner:"line"}).start();try{let a=oe(i);if(!await _e(a))throw new h(`Project not initialized. Run ${B("spectrl init")} to set up dependency management.
242
-
243
- Note: ${B("spectrl new")} and ${B("spectrl publish")} work without initialization.`,D.VALIDATION_ERROR);o.text=`Fetching ${R(`${r}/${s}`)} from public registry`;let u;try{u=await xt(r,s)}catch(j){throw j instanceof Y&&j.statusCode===404?new h(`Spec ${R(`${r}/${s}`)} not found in public registry`,D.DEPENDENCY_ERROR):j}let c=n||u.versions[0]?.version;if(!c)throw new h(`No versions available for ${R(`${r}/${s}`)}`,D.DEPENDENCY_ERROR);let l=u.versions.find(j=>j.version===c);if(!l)throw new h(`Version ${R(c)} not found for ${R(`${r}/${s}`)}`,D.DEPENDENCY_ERROR);let p=Nt(r,s,c);o.text=`Found ${R(p)}`,o.stop();let y=await ta(s,c,!0,r,i);await ra(y,p,"public",i),o.start(`Installing ${R(p)}`);let d=Vr(i,r,s,c),m=W(d,"spectrl.json");try{let j=await V.readFile(m,"utf-8"),G=JSON.parse(j),Q=jt.safeParse(G);if(!Q.success)throw new Error("Invalid manifest");if(Q.data.hash===l.hash){o.succeed(`${R(p)} already installed at ${R(`.spectrl/specs/${zr(r,s,c)}`)}`);let fe=oe(i),H={};try{let Qt=await V.readFile(fe,"utf-8");H=JSON.parse(Qt)}catch(Qt){if(Qt.code!=="ENOENT")throw Qt}let ge=`${Qo()}/${l.s3Path}/spectrl.json`;H[p]={source:ge,hash:l.hash};let ze=JSON.stringify(H,null,2);await V.writeFile(fe,`${ze}
244
- `,"utf-8");return}}catch(j){if(j.code!=="ENOENT")throw j}o.text=`Downloading ${R(p)} manifest`;let w=Qo(),x=`${w}/${l.s3Path}/spectrl.json`,S;try{S=await fetch(x)}catch(j){throw new h(`Failed to download manifest: ${j instanceof Error?j.message:String(j)}`,D.IO_ERROR)}if(!S.ok)throw new h(`Failed to download manifest: HTTP ${S.status}`,D.IO_ERROR);let I=await S.json(),M=jt.safeParse(I);if(!M.success)throw new h(`Downloaded manifest is invalid: ${M.error.issues[0].message}`,D.VALIDATION_ERROR);let U=M.data,z={...U,hash:l.hash};await Z.ensureDir(d),await V.writeFile(m,JSON.stringify(z,null,2),"utf-8"),o.text=`Downloading ${R(p)} files (${U.files.length} files)`;for(let j of U.files){let G=`${w}/${l.s3Path}/files/${j}`,Q;try{Q=await fetch(G)}catch(H){throw new h(`Failed to download file ${j}: ${H instanceof Error?H.message:String(H)}`,D.IO_ERROR)}if(!Q.ok)throw new h(`Failed to download file ${j}: HTTP ${Q.status}`,D.IO_ERROR);let $e=await Q.text(),fe=W(d,j);await Z.ensureDir(Mt(fe)),await V.writeFile(fe,$e,"utf-8")}o.text="Updating project index";let Ue=oe(i),de={};try{let j=await V.readFile(Ue,"utf-8");de=JSON.parse(j)}catch(j){if(j.code!=="ENOENT")throw new h(`Failed to read project index: ${j.message}`,D.IO_ERROR)}de[p]={source:x,hash:l.hash};try{let j=JSON.stringify(de,null,2);await V.writeFile(Ue,`${j}
245
- `,"utf-8")}catch(j){o.warn("Failed to update index, rolling back installation...");try{await Z.remove(d)}catch{}throw new h(`Failed to update project index: ${j.message}`,D.IO_ERROR)}o.succeed(`Installed ${R(p)} from public registry at ${R(`.spectrl/specs/${zr(r,s,c)}`)}`)}catch(a){throw o.stop(),a instanceof h?a:a instanceof Y?new h(`API error: ${a.message}`,a.statusCode&&a.statusCode>=500?D.IO_ERROR:D.DEPENDENCY_ERROR):a instanceof Error?new h(a.message,D.IO_ERROR):new h("Unknown error during install",D.IO_ERROR)}}async function oa(t,e){try{let{cwd:r,registry:s}=e,n=oe(r);if(!await _e(n))throw new h(`Project not initialized. Run ${B("spectrl init")} to set up dependency management.
246
-
247
- Note: ${B("spectrl new")} and ${B("spectrl publish")} work without initialization.`,D.VALIDATION_ERROR);let i;try{i=Ae(t)}catch(a){throw new h(`Invalid spec reference format: ${t}. ${a instanceof Error?a.message:String(a)}`,D.VALIDATION_ERROR)}if(i.isPublic&&i.username)return await Vs({username:i.username,name:i.name,version:i.version},{cwd:r});let o=Yr({text:`Installing ${R(t)}`,spinner:"line"}).start();try{let{name:a,version:u}=i,c=new gt(s??fr());u||(o.text=`Resolving ${R(a)}...`,u=await Ah(a,c),o.text=`Resolved ${R(a)} to version ${R(u)}`);let l=`${a}@${u}`;o.stop();let p=await ta(a,u,!1,void 0,r);if(await ra(p,l,"local",r),o.start(`Installing ${R(l)}`),o.text=`Looking up ${R(l)} in registry`,!await c.exists(a,u))throw new h(`Spec ${R(l)} not found in registry`,D.DEPENDENCY_ERROR);o.text=`Reading manifest for ${R(l)}`;let d=await c.getManifest(a,u);if(!d.hash)throw new h(`Manifest for ${l} is missing hash`,D.VALIDATION_ERROR);let m=c.paths.files(a,u),w=W(r,".spectrl","specs",l);o.text=`Checking ${R(l)}`;let x=await sa(w,m);if(x.exists&&x.isSymlink&&x.isCorrect){o.succeed(`${R(l)} already installed at ${R(`.spectrl/specs/${l}`)}`),o.text="Updating project index";let G=W(r,".spectrl","spectrl-index.json"),Q={};try{let H=await V.readFile(G,"utf-8");Q=JSON.parse(H)}catch(H){if(H.code!=="ENOENT")throw H}let $e=c.paths.spec(a,u);Q[l]={source:$e,hash:d.hash};let fe=JSON.stringify(Q,null,2);await V.writeFile(G,`${fe}
248
- `,"utf-8");return}let S=!1;x.exists&&(x.isSymlink?o.text=`Updating symlink for ${R(l)}`:(o.text=`Upgrading ${R(l)} from copied files to symlink`,S=!0),await Bt(w)),o.text=`Installing ${R(l)}`;let I=await na(m,w,d,o);if(!await Z.pathExists(w))throw new h(`Installation verification failed: ${w} does not exist after installation`,D.IO_ERROR);o.text="Updating project index";let U=W(r,".spectrl","spectrl-index.json"),z={};try{let G=await V.readFile(U,"utf-8");z=JSON.parse(G)}catch(G){if(G.code!=="ENOENT")throw new h(`Failed to read project index: ${G.message}`,D.IO_ERROR)}let Ue=c.paths.spec(a,u);z[l]={source:Ue,hash:d.hash};try{let G=JSON.stringify(z,null,2);await V.writeFile(U,`${G}
249
- `,"utf-8")}catch(G){o.warn("Failed to update index, rolling back installation...");try{await Bt(w)}catch{}throw new h(`Failed to update project index: ${G.message}`,D.IO_ERROR)}let de=I==="symlink"?"symlink":"copied files",j=S?"Upgraded":"Installed";o.succeed(`${j} ${R(l)} using ${de} at ${R(`.spectrl/specs/${l}`)}`)}catch(a){throw o.stop(),a instanceof h?a:a instanceof Error?new h(a.message,D.IO_ERROR):new h("Unknown error during install",D.IO_ERROR)}}catch(r){throw r instanceof h?r:r instanceof Error?new h(r.message,D.IO_ERROR):new h("Unknown error during install",D.IO_ERROR)}}async function aa(t){let e=Yr({text:"Installing specs",spinner:"line"}).start();try{let{cwd:r,registry:s}=t,n=oe(r);if(!await _e(n))throw new h(`Project not initialized. Run ${B("spectrl init")} to set up dependency management.
250
-
251
- Note: ${B("spectrl new")} and ${B("spectrl publish")} work without initialization.`,D.VALIDATION_ERROR);e.text="Resolving dependencies";let i=W(r,".spectrl","spectrl-index.json"),a=await new Ir().resolveClosureFromIndex(i);if(a.length===0){e.info("No specs to install");return}let u={total:a.length,symlinked:0,copied:0,upgraded:0,skipped:0};e.text=`Resolving ${u.total} spec(s)`;let c=new gt(s??fr()),l=[],p=W(r,".spectrl"),y={};try{let x=await V.readFile(n,"utf-8");y=JSON.parse(x)}catch(x){if(x.code!=="ENOENT")throw x}for(let x of a){let{name:S,version:I,source:M,deps:U}=x,z=`${S}@${I}`;e.text=`Processing ${R(z)}`;let Ue=M.startsWith("https://")||M.startsWith("http://"),{manifest:de,fileContents:j}=await _h(M,p),G=$r({manifest:de,fileContents:j});if(Ue){let Q=z.split("/"),$e=Q.length>1?W(r,".spectrl","specs",`${Q[0]}-${Q[1]}`):W(r,".spectrl","specs",z),fe=W($e,"spectrl.json"),H=!1;try{let pe=await V.readFile(fe,"utf-8"),ge=JSON.parse(pe),ze=jt.safeParse(ge);ze.success&&ze.data.hash===G&&(H=!0,u.skipped++)}catch{}if(!H){await Z.ensureDir($e),await V.writeFile(fe,JSON.stringify(de,null,2),"utf-8");for(let pe of de.files){let ge=W($e,pe);await Z.ensureDir(Mt(ge)),await V.writeFile(ge,j[pe],"utf-8")}u.copied++}y[z]={source:M,hash:G}}else{if(await c.exists(S,I)){if((await c.getManifest(S,I)).hash!==G)throw new h(`Integrity breach: hash mismatch for ${z}`,D.IO_ERROR)}else{let ge={...de,hash:G},ze=ia(M,p);await c.publish(ge,ze)}let $e=c.paths.spec(S,I),fe=c.paths.files(S,I),H=W(r,".spectrl","specs",z);e.text=`Checking ${R(z)}`;let pe=await sa(H,fe);if(pe.exists&&pe.isSymlink&&pe.isCorrect)u.skipped++;else{let ge=!1;pe.exists&&!pe.isSymlink?(e.text=`Upgrading ${R(z)} from copied files to symlink`,await Bt(H),ge=!0):pe.exists&&!pe.isCorrect?(e.text=`Updating symlink for ${R(z)}`,await Bt(H)):e.text=`Creating symlink for ${R(z)}`;let ze=await na(fe,H,de,e);if(!await Z.pathExists(H))throw new h(`Installation verification failed: ${H} does not exist after installation`,D.IO_ERROR);ge?u.upgraded++:ze==="symlink"?u.symlinked++:u.copied++}y[z]={source:$e,hash:G}}l.push({name:S,version:I,hash:G,source:M,deps:U})}e.text="Updating project index";try{let x=JSON.stringify(y,null,2);await V.writeFile(n,`${x}
252
- `,"utf-8")}catch(x){throw new h(`Failed to update project index: ${x.message}`,D.IO_ERROR)}e.text="Writing lock file",l.sort((x,S)=>{let I=`${x.name}@${x.version}`,M=`${S.name}@${S.version}`;return I.localeCompare(M)});let d={createdAt:new Date().toISOString(),entries:l},m=W(r,".spectrl","lock.json");try{await V.writeFile(m,`${JSON.stringify(d,null,2)}
253
- `,"utf-8")}catch(x){throw new h(`Failed to write lock file: ${x.message}`,D.IO_ERROR)}let w=[];u.symlinked>0&&w.push(`${u.symlinked} symlinked`),u.copied>0&&w.push(`${u.copied} copied`),u.upgraded>0&&w.push(`${u.upgraded} upgraded`),u.skipped>0&&w.push(`${u.skipped} skipped`),e.succeed(`Processed ${u.total} spec(s) (${w.join(", ")}), lock file written`)}catch(r){if(e.stop(),r instanceof he){let s=r.exitCode===3?D.DEPENDENCY_ERROR:D.VALIDATION_ERROR;throw new h(r.message,s)}throw r instanceof h?r:r instanceof Error?new h(r.message,D.IO_ERROR):new h("Unknown error during install",D.IO_ERROR)}}import{writeFile as Ih,mkdir as $h}from"node:fs/promises";import{join as ua}from"node:path";import kh from"ora";async function ca(t,e,r="0.1.0",s){let n=kh({text:"Creating new spec",spinner:"line"}).start();try{if(!/^[a-z0-9-]+$/.test(t))throw new h("Spec name must be lowercase alphanumeric with hyphens",D.VALIDATION_ERROR);let i=ua(e,t);if(await _e(i))throw new h(`Directory already exists: ${t}`,D.VALIDATION_ERROR);n.text=`Creating directory ${t}`,await $h(i,{recursive:!0});let o={name:t,version:r,files:[],deps:{},...s&&{description:s}},a=ua(i,"spectrl.json"),u=`${JSON.stringify(o,null,2)}
254
- `;await Ih(a,u,"utf-8"),n.succeed(`Created new spec ${R(t)} with manifest at ${R(`${t}/spectrl.json`)}`)}catch(i){throw n.stop(),i}}import Je from"chalk";import Ra from"node:process";import Sa from"node:path";import{fileURLToPath as lm}from"node:url";import dm from"node:child_process";import fm,{constants as pm}from"node:fs/promises";import{promisify as Uh}from"node:util";import zh from"node:child_process";import Xs,{constants as ma}from"node:fs/promises";import fa from"node:process";import Lh from"node:os";import jh from"node:fs";import Ph from"node:fs";import la from"node:fs";var Gs;function Oh(){try{return la.statSync("/.dockerenv"),!0}catch{return!1}}function Th(){try{return la.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function Hs(){return Gs===void 0&&(Gs=Oh()||Th()),Gs}var Ys,Nh=()=>{try{return Ph.statSync("/run/.containerenv"),!0}catch{return!1}};function qt(){return Ys===void 0&&(Ys=Nh()||Hs()),Ys}var da=()=>{if(fa.platform!=="linux")return!1;if(Lh.release().toLowerCase().includes("microsoft"))return!qt();try{return jh.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!qt():!1}catch{return!1}},qe=fa.env.__IS_WSL_TEST__?da:da();import pa from"node:process";import{Buffer as Mh}from"node:buffer";import{promisify as Bh}from"node:util";import qh from"node:child_process";var Wh=Bh(qh.execFile),Zs=()=>`${pa.env.SYSTEMROOT||pa.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var me=async(t,e={})=>{let{powerShellPath:r,...s}=e,n=me.encodeCommand(t);return Wh(r??Zs(),[...me.argumentsPrefix,n],{encoding:"utf8",...s})};me.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];me.encodeCommand=t=>Mh.from(t,"utf16le").toString("base64");me.escapeArgument=t=>`'${String(t).replaceAll("'","''")}'`;var Vh=Uh(zh.execFile),Gh=(()=>{let t="/mnt/",e;return async function(){if(e)return e;let r="/etc/wsl.conf",s=!1;try{await Xs.access(r,ma.F_OK),s=!0}catch{}if(!s)return t;let n=await Xs.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}})(),Hh=async()=>`${await Gh()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Zr=qe?Hh:Zs,ha,Da=async()=>(ha??=(async()=>{try{let t=await Zr();return await Xs.access(t,ma.X_OK),!0}catch{return!1}})(),ha),ga=async()=>{let t=await Zr(),e=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:r}=await me(e,{powerShellPath:t});return r.trim()},ya=async t=>{if(/^[a-z]+:\/\//i.test(t))return t;try{let{stdout:e}=await Vh("wslpath",["-aw",t],{encoding:"utf8"});return e.trim()}catch{return t}};function bt(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 im}from"node:util";import tn from"node:process";import{execFile as om}from"node:child_process";import{promisify as Yh}from"node:util";import Zh from"node:process";import{execFile as Xh}from"node:child_process";var Jh=Yh(Xh);async function Js(){if(Zh.platform!=="darwin")throw new Error("macOS only");let{stdout:t}=await Jh("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 Kh from"node:process";import{promisify as Qh}from"node:util";import{execFile as em,execFileSync as ax}from"node:child_process";var tm=Qh(em);async function wa(t,{humanReadableOutput:e=!0,signal:r}={}){if(Kh.platform!=="darwin")throw new Error("macOS only");let s=e?[]:["-ss"],n={};r&&(n.signal=r);let{stdout:i}=await tm("osascript",["-e",t,s],n);return i.trim()}async function Ks(t){return wa(`tell application "Finder" to set app_path to application file id "${t}" as string
255
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as rm}from"node:util";import{execFile as sm}from"node:child_process";var nm=rm(sm),Ea={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"}},Qs=new Map(Object.entries(Ea)),Xr=class extends Error{};async function en(t=nm){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 Xr(`Cannot find Windows browser in stdout: ${JSON.stringify(e)}`);let{id:s}=r.groups,n=Ea[s];if(!n)throw new Xr(`Unknown browser ID: ${s}`);return n}var am=im(om),um=t=>t.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase());async function rn(){if(tn.platform==="darwin"){let t=await Js();return{name:await Ks(t),id:t}}if(tn.platform==="linux"){let{stdout:t}=await am("xdg-mime",["query","default","x-scheme-handler/http"]),e=t.trim();return{name:um(e.replace(/.desktop$/,"").replace("-"," ")),id:e}}if(tn.platform==="win32")return en();throw new Error("Only macOS, Linux, and Windows are supported")}import sn from"node:process";var cm=!!(sn.env.SSH_CONNECTION||sn.env.SSH_CLIENT||sn.env.SSH_TTY),xa=cm;var Jr=Symbol("fallbackAttempt"),nn=import.meta.url?Sa.dirname(lm(import.meta.url)):"",va=Sa.join(nn,"xdg-open"),{platform:Wt,arch:ba}=Ra,Ca=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")},Kr=async t=>{t={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...t};let e=t[Jr]===!0;if(delete t[Jr],Array.isArray(t.app))return Ca(t.app,c=>Kr({...t,app:c,[Jr]:!0}));let{name:r,arguments:s=[]}=t.app??{};if(s=[...s],Array.isArray(r))return Ca(r,c=>Kr({...t,app:{name:c,arguments:s},[Jr]:!0}));if(r==="browser"||r==="browserPrivate"){let c={"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"},l={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},p;if(qe){let y=await ga();p=Qs.get(y)??{}}else p=await rn();if(p.id in c){let y=c[p.id.toLowerCase()];if(r==="browserPrivate"){if(y==="safari")throw new Error("Safari doesn't support opening in private mode via command line");s.push(l[y])}return Kr({...t,app:{name:Ut[y],arguments:s}})}throw new Error(`${p.name} is not supported as a default browser`)}let n,i=[],o={},a=!1;if(qe&&!qt()&&!xa&&!r&&(a=await Da()),Wt==="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(Wt==="win32"||a){n=await Zr(),i.push(...me.argumentsPrefix),qe||(o.windowsVerbatimArguments=!0),qe&&t.target&&(t.target=await ya(t.target));let c=["$ProgressPreference = 'SilentlyContinue';","Start"];t.wait&&c.push("-Wait"),r?(c.push(me.escapeArgument(r)),t.target&&s.push(t.target)):t.target&&c.push(me.escapeArgument(t.target)),s.length>0&&(s=s.map(l=>me.escapeArgument(l)),c.push("-ArgumentList",s.join(","))),t.target=me.encodeCommand(c.join(" ")),t.wait||(o.stdio="ignore")}else{if(r)n=r;else{let c=!nn||nn==="/",l=!1;try{await fm.access(va,pm.X_OK),l=!0}catch{}n=Ra.versions.electron??(Wt==="android"||c||!l)?"xdg-open":va}s.length>0&&i.push(...s),t.wait||(o.stdio="ignore",o.detached=!0)}Wt==="darwin"&&s.length>0&&i.push("--args",...s),t.target&&i.push(t.target);let u=dm.spawn(n,i,o);return t.wait?new Promise((c,l)=>{u.once("error",l),u.once("close",p=>{if(!t.allowNonzeroExitCode&&p!==0){l(new Error(`Exited with code ${p}`));return}c(u)})}):e?new Promise((c,l)=>{u.once("error",l),u.once("spawn",()=>{u.once("close",p=>{if(u.off("error",l),p!==0){l(new Error(`Exited with code ${p}`));return}u.unref(),c(u)})})}):(u.unref(),new Promise((c,l)=>{u.once("error",l),u.once("spawn",()=>{u.off("error",l),c(u)})}))},hm=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a `target`");return Kr({...e,target:t})};function Fa(t){if(typeof t=="string"||Array.isArray(t))return t;let{[ba]:e}=t;if(!e)throw new Error(`${ba} is not supported`);return e}function hr({[Wt]:t},{wsl:e}={}){if(e&&qe)return Fa(e);if(!t)throw new Error(`${Wt} is not supported`);return Fa(t)}var Ut={browser:"browser",browserPrivate:"browserPrivate"};bt(Ut,"chrome",()=>hr({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"]}}));bt(Ut,"brave",()=>hr({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"]}}));bt(Ut,"firefox",()=>hr({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));bt(Ut,"edge",()=>hr({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));bt(Ut,"safari",()=>hr({darwin:"Safari"}));var _a=hm;var mm=f.object({device_code:f.string(),user_code:f.string(),verification_uri:f.string(),expires_in:f.number(),interval:f.number()}),Dm=f.object({token:f.string(),username:f.string()}),gm=f.object({error:f.string().optional(),message:f.string().optional(),status:f.string().optional()});async function Aa(){let t=new be;A.log(J(J(`Initiating GitHub authentication...
256
- `)));try{let e=await fetch(`${Et()}/auth/device/init`,{method:"POST"});if(!e.ok)throw A.error("Failed to initiate authentication"),new Error("Device flow initialization failed");let r=await e.json(),s=mm.safeParse(r);if(!s.success)throw A.error("Invalid response from authentication server"),console.error(Je.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:u}=s.data;console.log(Je.bold(`Please visit: ${Je.cyan(o)}`)),console.log(Je.bold(`
257
- Enter code: ${Je.green(i)}
258
- `)),A.log(J(`Opening browser...
259
- `)),await _a(o);let l=Date.now()+a*1e3;for(A.log(J("Waiting for authorization..."));Date.now()<l;){await new Promise(y=>setTimeout(y,u*1e3));let p=await fetch(`${Et()}/auth/device/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:n})});if(p.status===200){let y=await p.json(),d=Dm.safeParse(y);if(!d.success)throw A.error("Invalid response from server"),console.error(Je.dim("Validation error:"),d.error.message),new Error("Missing token or username in response");let{token:m,username:w}=d.data;await t.store(m),A.log(J(Je.green(`
260
- \u2713 Logged in as ${Je.bold(w)}`)));return}if(p.status!==202&&p.status===400){let y=await p.json(),d=gm.safeParse(y),m=d.success&&(d.data.message||d.data.error)||"Unknown error";throw A.error(`Authentication failed: ${m}`),new Error("Authentication failed")}}throw A.error("Authentication timed out"),new Error("Authentication timed out")}catch(e){throw e instanceof Error?e:new Error("Authentication failed")}}import ym from"chalk";async function Ia(){await new be().delete(),A.log(ym.green("\u2713 Logged out"))}import zt from"chalk";var wm=f.object({login:f.string()});async function $a(){let e=await new be().get();if(!e){console.log(zt.dim("Not logged in")),console.log(`Run: ${B("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: ${B("spectrl login")}`);return}let s=await r.json(),n=wm.safeParse(s);if(!n.success){console.log(zt.red("\u2717 Invalid response from GitHub API")),console.log(`Run: ${B("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: ${B("spectrl login")}`)}}import Qr from"chalk";import{select as Em}from"@inquirer/prompts";async function ka(t){try{let e;try{e=Ae(t)}catch(c){throw new h(`Invalid spec reference: ${c instanceof Error?c.message:String(c)}`,D.VALIDATION_ERROR)}if(!e.isPublic||!e.username)throw new h("Unpublish only works with public specs. Use format: username/spec@version",D.VALIDATION_ERROR);if(!e.version)throw new h(["Version is required for unpublish","",`Usage: spectrl unpublish ${R(`${e.username}/${e.name}@<version>`)}`,"","Example: spectrl unpublish alice/api-spec@1.0.0"].join(`
261
- `),D.VALIDATION_ERROR);let{username:r,name:s,version:n}=e,i=Nt(r,s,n),a=await new be().get();if(!a)throw new h(`You need to login first to unpublish specs
262
-
263
- Run: ${B("spectrl login")}`,D.AUTHENTICATION_ERROR);if(A.log(""),A.log(Qr.yellow(`\u26A0\uFE0F This will permanently delete ${R(i)} from the public registry.`)),A.log(""),!await Em({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})){A.log(Qr.dim("Cancelled"));return}A.log(""),A.log(Qr.dim(`Unpublishing ${R(i)}...`));try{let c=await Yo(a,r,s,n);A.log(""),A.log(Qr.green(`\u2713 ${c.message}`)),A.log("")}catch(c){throw c instanceof Y?c.statusCode===401||c.statusCode===403?new h(["Authentication failed","","Your token may have expired or you may not have permission to unpublish this spec.","","Try logging in again: spectrl login"].join(`
264
- `),D.AUTHENTICATION_ERROR):c.statusCode===404?new h(`Spec version ${R(i)} not found in the registry`,D.DEPENDENCY_ERROR):new h(`Failed to unpublish: ${c.message}`,D.IO_ERROR):c}}catch(e){throw e instanceof h?e:new h(`Unpublish failed: ${e instanceof Error?e.message:String(e)}`,D.IO_ERROR)}}var Ou=Ft(wr(),1),ns=Ft(ks(),1);import X from"chalk";import{promises as Tu}from"node:fs";import nD from"fs-extra";async function Dn(t){try{let e=oe(t),r=await Tu.readFile(e,"utf-8");return JSON.parse(r)}catch(e){throw e.code==="ENOENT"?new h(`Project not initialized
265
-
266
- Run: ${B("spectrl init")}`,D.VALIDATION_ERROR):new h(`Failed to read project index: ${e instanceof Error?e.message:String(e)}`,D.IO_ERROR)}}async function iD(t){let e=await Dn(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=Ae(n);if(!i.isPublic||!i.username||!i.version)continue;let{username:o,name:a,version:u}=i,c=await xt(o,a);if(c.versions.length===0)continue;let l=c.versions[0].version;ns.default.valid(u)&&ns.default.valid(l)&&ns.default.gt(l,u)&&r.push({specKey:n,username:o,name:a,currentVersion:u,latestVersion:l})}catch{}return r}async function gn(t,e,r,s){let n=await Dn(s),i=Object.keys(n).filter(o=>{let a=Ae(o);return a.isPublic&&a.username===t&&a.name===e});if(await Vs({username:t,name:e,version:r},{cwd:s}),i.length>0){let o=oe(s),a=await Dn(s);for(let u of i){if(u===Nt(t,e,r))continue;delete a[u];let c=Ae(u);if(c.version){let l=Vr(s,t,e,c.version);try{await nD.remove(l)}catch{}}}await Tu.writeFile(o,`${JSON.stringify(a,null,2)}
267
- `,"utf-8")}}async function Pu(t,e={}){let r=e.cwd||process.cwd();try{if(t)return await oD(t,r);A.log(X.dim(`Checking for updates...
268
- `));let s=await iD(r);if(s.length===0){A.log(X.green(`\u2713 All specs are up to date
269
- `));return}A.log(X.bold(`Updates available:
270
- `));let n=new Ou.default({head:[X.cyan("Spec"),X.cyan("Installed"),X.cyan("Latest")],colWidths:[30,15,15],style:{head:[],border:["dim"]}});for(let{username:i,name:o,currentVersion:a,latestVersion:u}of s)n.push([X.bold(`${i}/${o}`),X.yellow(a),X.green(u)]);if(A.log(n.toString()),A.log(""),A.log(X.dim("Run 'spectrl update <spec>' to update a specific spec")),A.log(X.dim(`Run 'spectrl update --all' to update all specs
271
- `)),e.all){A.log(X.bold(`Updating all specs...
272
- `));for(let{username:i,name:o,latestVersion:a}of s)A.log(X.dim(`Updating ${R(`${i}/${o}`)}...`)),await gn(i,o,a,r);A.log(""),A.log(X.green(`\u2713 Updated ${s.length} spec${s.length===1?"":"s"}
273
- `))}}catch(s){throw s instanceof h?s:new h(`Update failed: ${s instanceof Error?s.message:String(s)}`,D.IO_ERROR)}}async function oD(t,e){try{let r=Ae(t);if(!r.isPublic||!r.username)throw new h("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){A.log(X.dim(`Updating to ${R(`${s}/${n}@${i}`)}...
274
- `)),await gn(s,n,i,e),A.log(""),A.log(X.green(`\u2713 Updated to ${R(`${s}/${n}@${i}`)}
275
- `));return}A.log(X.dim(`Fetching latest version of ${R(`${s}/${n}`)}...
276
- `));try{let o=await xt(s,n);if(o.versions.length===0)throw new h(`No versions available for ${R(`${s}/${n}`)}`,D.DEPENDENCY_ERROR);let a=o.versions[0].version;A.log(X.dim(`Updating to ${R(`${s}/${n}@${a}`)}...
277
- `)),await gn(s,n,a,e),A.log(""),A.log(X.green(`\u2713 Updated to ${R(`${s}/${n}@${a}`)}
278
- `))}catch(o){throw o instanceof Y&&o.statusCode===404?new h(`Spec ${R(`${s}/${n}`)} not found in public registry`,D.DEPENDENCY_ERROR):o}}catch(r){throw r instanceof h?r:new h(`Update failed: ${r instanceof Error?r.message:String(r)}`,D.IO_ERROR)}}var Nu=Ft(wr(),1);import Ce from"chalk";async function Lu(t){if(!t||t.trim().length===0)throw new h("Search query cannot be empty",D.VALIDATION_ERROR);try{let e=await Ho(t.trim());if(e.results.length===0){console.log(Ce.yellow(`
279
- No specs found`)),console.log(Ce.dim("Try a different search term or browse all specs")),console.log(`Example: ${B("spectrl search api")}
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 va(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 Gt(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 Ca(t,e){try{if(!(await J.lstat(t)).isSymbolicLink())return{exists:!0,isSymlink:!1,isCorrect:!1};let n=await J.readlink(t),i=ya(Vt(t),n),o=ya(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 Gt(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 Ea(t,e,r){try{await J.ensureDir(e);let s=B(Vt(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(Vt(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 ba(t,e,r,s){if(Kh())return s.info("Using file copy mode (SPECTRL_USE_COPY=1)"),await Ea(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(Vt(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 Gt(e)}catch{}return await Ea(t,e,r),"copy"}throw new m(`Failed to create symlink: ${o.message}`,D.IO_ERROR)}}function Fa(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=Fa(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)=>jo(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=Ut(r,s,c);o.text=`Found ${S(d)}`,o.stop();let h=await xa(s,c,!0,r,i);await va(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=`${wa()}/${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 yr(i);return}}catch(N){if(N.code!=="ENOENT")throw N}o.text=`Downloading ${S(d)} manifest`;let g=wa(),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(Vt(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 yr(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 Ra(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??qt());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 xa(o,a,!1,void 0,r);if(await va(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 Ca(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 yr(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 Gt(g)),i.text=`Installing ${S(u)}`;let A=await ba(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 Gt(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 yr(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 Sa(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??qt()),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(Vt(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=Fa(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 Ca($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 Gt($e),ge=!0):ae.exists&&!ae.isCorrect?(e.text=`Updating symlink for ${S(U)}`,await Gt($e)):e.text=`Creating symlink for ${S(U)}`;let Re=await ba(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 yr(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 _a,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 Aa(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 _a(c,a,"utf-8");let u=r==="power"?om:im,d=en(o,"index.md");await _a(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 Ga from"node:process";import Ha 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 Pa}from"node:fs/promises";import Oa from"node:process";import dm from"node:os";import fm from"node:fs";import um from"node:fs";import $a from"node:fs";var tn;function am(){try{return $a.statSync("/.dockerenv"),!0}catch{return!1}}function cm(){try{return $a.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 Ht(){return sn===void 0&&(sn=lm()||rn()),sn}var Ia=()=>{if(Oa.platform!=="linux")return!1;if(dm.release().toLowerCase().includes("microsoft"))return!Ht();try{return fm.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!Ht():!1}catch{return!1}},ze=Oa.env.__IS_WSL_TEST__?Ia:Ia();import ka 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=()=>`${ka.env.SYSTEMROOT||ka.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,Pa.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,Ta,Na=async()=>(Ta??=(async()=>{try{let t=await rs();return await on.access(t,Pa.X_OK),!0}catch{return!1}})(),Ta),La=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()},Ma=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 ja(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 ja(`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),Ba={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(Ba)),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=Ba[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),Wa=Lm;var ns=Symbol("fallbackAttempt"),hn=import.meta.url?Ha.dirname(Mm(import.meta.url)):"",qa=Ha.join(hn,"xdg-open"),{platform:Jt,arch:Ua}=Ga,za=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 za(t.app,u=>is({...t,app:u,[ns]:!0}));let{name:r,arguments:s=[]}=t.app??{};if(s=[...s],Array.isArray(r))return za(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 La();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:Zt[p],arguments:s}})}throw new Error(`${h.name} is not supported as a default browser`)}let n,i=[],o={},a=!1;if(ze&&!Ht()&&!Wa&&!r&&(a=await Na()),Jt==="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(Jt==="win32"||a){n=await rs(),i.push(...he.argumentsPrefix),ze||(o.windowsVerbatimArguments=!0),ze&&t.target&&(t.target=await Ma(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(qa,Wm.X_OK),d=!0}catch{}n=Ga.versions.electron??(Jt==="android"||u||!d)?"xdg-open":qa}s.length>0&&i.push(...s),t.wait||(o.stdio="ignore",o.detached=!0)}Jt==="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 Va(t){if(typeof t=="string"||Array.isArray(t))return t;let{[Ua]:e}=t;if(!e)throw new Error(`${Ua} is not supported`);return e}function wr({[Jt]:t},{wsl:e}={}){if(e&&ze)return Va(e);if(!t)throw new Error(`${Jt} is not supported`);return Va(t)}var Zt={browser:"browser",browserPrivate:"browserPrivate"};Rt(Zt,"chrome",()=>wr({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(Zt,"brave",()=>wr({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(Zt,"firefox",()=>wr({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Rt(Zt,"edge",()=>wr({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Rt(Zt,"safari",()=>wr({darwin:"Safari"}));var Ja=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 Za(){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 Ja(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 Ya(){await new ve().delete(),v.log(Gm.green("\u2713 Logged out"))}import Yt from"chalk";var Hm=f.object({login:f.string()});async function Xa(){let e=await new ve().get();if(!e){console.log(Yt.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(Yt.yellow("Token invalid")),console.log(`Run: ${H("spectrl login")}`);return}let s=await r.json(),n=Hm.safeParse(s);if(!n.success){console.log(Yt.red("\u2717 Invalid response from GitHub API")),console.log(`Run: ${H("spectrl login")}`);return}let i=n.data;console.log(Yt.green(`Logged in as ${Yt.bold(i.login)}`))}catch{console.log(Yt.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 Ka(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=Ut(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 fa(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 Qc=At(br(),1),ds=At(Bs(),1);import Z from"chalk";import{promises as eu}from"node:fs";import Og from"fs-extra";async function Fn(t){try{let e=le(t),r=await eu.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===Ut(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 eu.writeFile(o,`${JSON.stringify(a,null,2)}
227
+ `,"utf-8")}}async function tu(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 Qc.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 ru=At(br(),1);import Ce from"chalk";async function su(t){if(!t||t.trim().length===0)throw new m("Search query cannot be empty",D.VALIDATION_ERROR);try{let e=await da(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")}
280
240
  `);return}let r=e.results.length;console.log(Ce.bold(`
281
241
  Found ${r} spec${r===1?"":"s"} matching "${t}":
282
- `));let s=new Nu.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"),u=n.version||Ce.dim("unknown");s.push([Ce.bold(i),o,a,u])}console.log(s.toString()),console.log(`
283
- Install with: ${B("spectrl install <spec>")}`),console.log(`Example: ${B("spectrl install alice/api-spec")}
284
- `)}catch(e){throw e instanceof h?e:e instanceof Error?new h(`Search failed: ${e.message}`,D.IO_ERROR):new h("Unknown error during search",D.IO_ERROR)}}var sc=Ft(wr(),1);import Ke from"chalk";var aD=Math.pow(10,8)*24*60*60*1e3,z0=-aD;var Er=43200,yn=1440;var uD=3600;var ju=uD*24,V0=ju*7,cD=ju*365.2425,lD=cD/12,G0=lD*3,wn=Symbol.for("constructDateFrom");function Ht(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&wn in t?t[wn](e):t instanceof Date?new t.constructor(e):new Date(e)}function le(t,e){return Ht(e||t,t)}var dD={};function Mu(){return dD}function En(t){let e=le(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 Yt(t,...e){let r=Ht.bind(null,t||e.find(s=>typeof s=="object"));return e.map(r)}function Zt(t,e){let r=+le(t)-+le(e);return r<0?-1:r>0?1:r}function Bu(t){return Ht(t,Date.now())}function qu(t,e,r){let[s,n]=Yt(r?.in,t,e),i=s.getFullYear()-n.getFullYear(),o=s.getMonth()-n.getMonth();return i*12+o}function Wu(t){return e=>{let s=(t?Math[t]:Math.trunc)(e);return s===0?0:s}}function Uu(t,e){return+le(t)-+le(e)}function zu(t,e){let r=le(t,e?.in);return r.setHours(23,59,59,999),r}function Vu(t,e){let r=le(t,e?.in),s=r.getMonth();return r.setFullYear(r.getFullYear(),s+1,0),r.setHours(23,59,59,999),r}function Gu(t,e){let r=le(t,e?.in);return+zu(r,e)==+Vu(r,e)}function Hu(t,e,r){let[s,n,i]=Yt(r?.in,t,t,e),o=Zt(n,i),a=Math.abs(qu(n,i));if(a<1)return 0;n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-o*a);let u=Zt(n,i)===-o;Gu(s)&&a===1&&Zt(s,i)===1&&(u=!1);let c=o*(a-+u);return c===0?0:c}function Yu(t,e,r){let s=Uu(t,e)/1e3;return Wu(r?.roundingMethod)(s)}var fD={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"}},Zu=(t,e,r)=>{let s,n=fD[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 is(t){return(e={})=>{let r=e.width?String(e.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}var pD={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},hD={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},mD={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Xu={date:is({formats:pD,defaultWidth:"full"}),time:is({formats:hD,defaultWidth:"full"}),dateTime:is({formats:mD,defaultWidth:"full"})};var DD={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ju=(t,e,r,s)=>DD[t];function Xt(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 gD={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},yD={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},wD={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"]},ED={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"]},xD={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"}},vD={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"}},bD=(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"},Ku={ordinalNumber:bD,era:Xt({values:gD,defaultWidth:"wide"}),quarter:Xt({values:yD,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Xt({values:wD,defaultWidth:"wide"}),day:Xt({values:ED,defaultWidth:"wide"}),dayPeriod:Xt({values:xD,defaultWidth:"wide",formattingValues:vD,defaultFormattingWidth:"wide"})};function Jt(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],u=Array.isArray(a)?FD(a,p=>p.test(o)):CD(a,p=>p.test(o)),c;c=t.valueCallback?t.valueCallback(u):u,c=r.valueCallback?r.valueCallback(c):c;let l=e.slice(o.length);return{value:c,rest:l}}}function CD(t,e){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&e(t[r]))return r}function FD(t,e){for(let r=0;r<t.length;r++)if(e(t[r]))return r}function Qu(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 RD=/^(\d+)(th|st|nd|rd)?/i,SD=/\d+/i,_D={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},AD={any:[/^b/i,/^(a|c)/i]},ID={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},$D={any:[/1/i,/2/i,/3/i,/4/i]},kD={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},OD={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]},TD={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},PD={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]},ND={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},LD={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}},ec={ordinalNumber:Qu({matchPattern:RD,parsePattern:SD,valueCallback:t=>parseInt(t,10)}),era:Jt({matchPatterns:_D,defaultMatchWidth:"wide",parsePatterns:AD,defaultParseWidth:"any"}),quarter:Jt({matchPatterns:ID,defaultMatchWidth:"wide",parsePatterns:$D,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Jt({matchPatterns:kD,defaultMatchWidth:"wide",parsePatterns:OD,defaultParseWidth:"any"}),day:Jt({matchPatterns:TD,defaultMatchWidth:"wide",parsePatterns:PD,defaultParseWidth:"any"}),dayPeriod:Jt({matchPatterns:ND,defaultMatchWidth:"any",parsePatterns:LD,defaultParseWidth:"any"})};var xn={code:"en-US",formatDistance:Zu,formatLong:Xu,formatRelative:Ju,localize:Ku,match:ec,options:{weekStartsOn:0,firstWeekContainsDate:1}};function tc(t,e,r){let s=Mu(),n=r?.locale??s.locale??xn,i=2520,o=Zt(t,e);if(isNaN(o))throw new RangeError("Invalid time value");let a=Object.assign({},r,{addSuffix:r?.addSuffix,comparison:o}),[u,c]=Yt(r?.in,...o>0?[e,t]:[t,e]),l=Yu(c,u),p=(En(c)-En(u))/1e3,y=Math.round((l-p)/60),d;if(y<2)return r?.includeSeconds?l<5?n.formatDistance("lessThanXSeconds",5,a):l<10?n.formatDistance("lessThanXSeconds",10,a):l<20?n.formatDistance("lessThanXSeconds",20,a):l<40?n.formatDistance("halfAMinute",0,a):l<60?n.formatDistance("lessThanXMinutes",1,a):n.formatDistance("xMinutes",1,a):y===0?n.formatDistance("lessThanXMinutes",1,a):n.formatDistance("xMinutes",y,a);if(y<45)return n.formatDistance("xMinutes",y,a);if(y<90)return n.formatDistance("aboutXHours",1,a);if(y<yn){let m=Math.round(y/60);return n.formatDistance("aboutXHours",m,a)}else{if(y<i)return n.formatDistance("xDays",1,a);if(y<Er){let m=Math.round(y/yn);return n.formatDistance("xDays",m,a)}else if(y<Er*2)return d=Math.round(y/Er),n.formatDistance("aboutXMonths",d,a)}if(d=Hu(c,u),d<12){let m=Math.round(y/Er);return n.formatDistance("xMonths",m,a)}else{let m=d%12,w=Math.trunc(d/12);return m<3?n.formatDistance("aboutXYears",w,a):m<9?n.formatDistance("overXYears",w,a):n.formatDistance("almostXYears",w+1,a)}}function rc(t,e){return tc(t,Bu(t),e)}async function nc(t){let e;try{e=Ae(t)}catch(r){throw r instanceof Error?new h(`Invalid spec reference: ${r.message}`,D.VALIDATION_ERROR):new h("Invalid spec reference format",D.VALIDATION_ERROR)}if(!e.isPublic||!e.username)throw new h("Info command requires a public spec reference (username/spec)",D.VALIDATION_ERROR);try{let r=await xt(e.username,e.name);if(console.log(Ke.bold.cyan(`
285
- ${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(Ke.dim(`
286
- Tags: ${r.versions[0].tags.join(", ")}`)),r.versions.length===0)console.log(Ke.yellow(`
287
- No versions available`));else{console.log(Ke.bold(`
288
- Versions:`));let s=new sc.default({head:[Ke.cyan("Version"),Ke.cyan("Published"),Ke.cyan("Downloads")],colWidths:[12,30,15],style:{head:[],border:["dim"]}});for(let n of r.versions){let i=new Date(n.publishedAt),o=rc(i,{addSuffix:!0}),a=`${i.toISOString().split("T")[0]} (${o})`,u=n.downloads?.toString()||"0";s.push([Ke.bold(n.version),a,u])}console.log(s.toString())}console.log(`
289
- Install latest: ${B(`spectrl install ${r.specId}`)}`),console.log(`Install specific: ${B(`spectrl install ${r.specId}@<version>`)}
290
- `)}catch(r){throw r instanceof h?r:r instanceof Y?r.statusCode===404?new h(`Spec not found: ${e.username}/${e.name}`,D.IO_ERROR):new h(`Failed to get spec info: ${r.message}`,D.IO_ERROR):r instanceof Error?new h(`Failed to get spec info: ${r.message}`,D.IO_ERROR):new h("Unknown error while fetching spec info",D.IO_ERROR)}}var ic=Ft(wr(),1);import Fe from"chalk";import{promises as jD}from"node:fs";async function oc(t={}){let e=t.cwd||process.cwd();try{let r=oe(e);if(!await _e(r))throw new h('Project not initialized. Run "spectrl init" to set up dependency management.',D.VALIDATION_ERROR);let s=await jD.readFile(r,"utf-8"),n=JSON.parse(s),i=Object.entries(n);if(i.length===0){console.log(Fe.yellow(`
291
- No specs installed`)),console.log(Fe.dim("Install a spec with: spectrl install <spec>")),console.log(Fe.dim(`Example: spectrl install alice/api-spec
292
- `));return}console.log(Fe.bold(`
242
+ `));let s=new ru.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 Cu=At(br(),1);import st from"chalk";var Pg=Math.pow(10,8)*24*60*60*1e3,qv=-Pg;var Fr=43200,Sn=1440;var Ng=3600;var nu=Ng*24,Uv=nu*7,Lg=nu*365.2425,Mg=Lg/12,zv=Mg*3,_n=Symbol.for("constructDateFrom");function Qt(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 Qt(e||t,t)}var jg={};function iu(){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 er(t,...e){let r=Qt.bind(null,t||e.find(s=>typeof s=="object"));return e.map(r)}function tr(t,e){let r=+de(t)-+de(e);return r<0?-1:r>0?1:r}function ou(t){return Qt(t,Date.now())}function au(t,e,r){let[s,n]=er(r?.in,t,e),i=s.getFullYear()-n.getFullYear(),o=s.getMonth()-n.getMonth();return i*12+o}function cu(t){return e=>{let s=(t?Math[t]:Math.trunc)(e);return s===0?0:s}}function uu(t,e){return+de(t)-+de(e)}function lu(t,e){let r=de(t,e?.in);return r.setHours(23,59,59,999),r}function du(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 fu(t,e){let r=de(t,e?.in);return+lu(r,e)==+du(r,e)}function pu(t,e,r){let[s,n,i]=er(r?.in,t,t,e),o=tr(n,i),a=Math.abs(au(n,i));if(a<1)return 0;n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-o*a);let c=tr(n,i)===-o;fu(s)&&a===1&&tr(s,i)===1&&(c=!1);let u=o*(a-+c);return u===0?0:u}function hu(t,e,r){let s=uu(t,e)/1e3;return cu(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"}},mu=(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}}"},gu={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"},Du=(t,e,r,s)=>zg[t];function rr(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"},yu={ordinalNumber:Xg,era:rr({values:Vg,defaultWidth:"wide"}),quarter:rr({values:Gg,defaultWidth:"wide",argumentCallback:t=>t-1}),month:rr({values:Hg,defaultWidth:"wide"}),day:rr({values:Jg,defaultWidth:"wide"}),dayPeriod:rr({values:Zg,defaultWidth:"wide",formattingValues:Yg,defaultFormattingWidth:"wide"})};function sr(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 wu(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}},Eu={ordinalNumber:wu({matchPattern:eD,parsePattern:tD,valueCallback:t=>parseInt(t,10)}),era:sr({matchPatterns:rD,defaultMatchWidth:"wide",parsePatterns:sD,defaultParseWidth:"any"}),quarter:sr({matchPatterns:nD,defaultMatchWidth:"wide",parsePatterns:iD,defaultParseWidth:"any",valueCallback:t=>t+1}),month:sr({matchPatterns:oD,defaultMatchWidth:"wide",parsePatterns:aD,defaultParseWidth:"any"}),day:sr({matchPatterns:cD,defaultMatchWidth:"wide",parsePatterns:uD,defaultParseWidth:"any"}),dayPeriod:sr({matchPatterns:lD,defaultMatchWidth:"any",parsePatterns:dD,defaultParseWidth:"any"})};var $n={code:"en-US",formatDistance:mu,formatLong:gu,formatRelative:Du,localize:yu,match:Eu,options:{weekStartsOn:0,firstWeekContainsDate:1}};function xu(t,e,r){let s=iu(),n=r?.locale??s.locale??$n,i=2520,o=tr(t,e);if(isNaN(o))throw new RangeError("Invalid time value");let a=Object.assign({},r,{addSuffix:r?.addSuffix,comparison:o}),[c,u]=er(r?.in,...o>0?[e,t]:[t,e]),d=hu(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<Fr){let g=Math.round(p/Sn);return n.formatDistance("xDays",g,a)}else if(p<Fr*2)return l=Math.round(p/Fr),n.formatDistance("aboutXMonths",l,a)}if(l=pu(u,c),l<12){let g=Math.round(p/Fr);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 vu(t,e){return xu(t,ou(t),e)}async function bu(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 Cu.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=vu(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 Fu=At(br(),1);import be from"chalk";import{promises as fD}from"node:fs";async function Ru(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(`
293
253
  Installed specs:
294
- `));let o=new ic.default({head:[Fe.cyan("Spec"),Fe.cyan("Version"),Fe.cyan("Source")],colWidths:[35,12,12],style:{head:[],border:["dim"]}});for(let[u,c]of i){let p=c.source.startsWith("https://")||c.source.startsWith("http://")?Fe.blue("public"):Fe.green("local"),y=u.lastIndexOf("@"),d,m;y!==-1?(d=u.substring(0,y),m=u.substring(y+1)):(d=u,m=Fe.dim("unknown")),o.push([Fe.bold(d),m,p])}console.log(o.toString());let a=i.length;console.log(Fe.dim(`
254
+ `));let o=new Fu.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(`
295
255
  ${a} spec${a===1?"":"s"} installed
296
- `))}catch(r){throw r instanceof h?r:r instanceof SyntaxError?new h('Project index is corrupted. Try running "spectrl init" to reinitialize.',D.VALIDATION_ERROR):r instanceof Error?new h(`Failed to read project index: ${r.message}`,D.IO_ERROR):new h("Unknown error while listing specs",D.IO_ERROR)}}import{readFileSync as qD}from"node:fs";import{fileURLToPath as WD}from"node:url";import{dirname as UD,join as zD}from"node:path";var VD=UD(WD(import.meta.url)),GD=JSON.parse(qD(zD(VD,"../package.json"),"utf-8")),HD=GD.version,YD=Re({name:"init",description:"Initialize a new project with a local spec index",args:{skipAgents:vn({long:"skip-agents",description:"Skip AGENTS.md creation/update entirely",defaultValue:()=>!1}),forceAgents:vn({long:"force-agents",description:"Force overwrite AGENTS.md with fresh template",defaultValue:()=>!1})},handler:async t=>{await qo(process.cwd(),{skipAgents:t.skipAgents,forceAgents:t.forceAgents})}}),ZD=Re({name:"publish",description:"Publish a spec to the local registry",args:{},handler:async()=>{await Jo(process.cwd())}}),XD=Re({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:Kt({type:os(Qe),displayName:"spec",description:"Optional spec reference (name@version) to install from registry"})},handler:async t=>{t.specRef?await oa(t.specRef,{cwd:process.cwd()}):await aa({cwd:process.cwd()})}}),JD=Re({name:"new",description:"Create a new spec with a manifest template",args:{name:Kt({type:Qe,displayName:"name",description:"Name of the spec (lowercase alphanumeric with hyphens)"}),version:ac({type:os(Qe),long:"version",description:"Initial version (default: 0.1.0)",defaultValue:()=>"0.1.0"}),description:ac({type:os(Qe),long:"description",description:"Description of the spec"})},handler:async t=>{await ca(t.name,process.cwd(),t.version,t.description)}}),KD=Re({name:"login",description:"Authenticate with GitHub to access the public registry",args:{},handler:async()=>{await Aa()}}),QD=Re({name:"logout",description:"Remove stored GitHub authentication token",args:{},handler:async()=>{await Ia()}}),eg=Re({name:"whoami",description:"Show current authenticated GitHub user",args:{},handler:async()=>{await $a()}}),tg=Re({name:"unpublish",description:"Remove a spec version from the public registry (requires authentication)",args:{specRef:Kt({type:Qe,displayName:"spec",description:"Spec reference in format username/spec@version"})},handler:async t=>{await ka(t.specRef)}}),rg=Re({name:"update",description:"Check for and install updates for public specs",args:{specRef:Kt({type:os(Qe),displayName:"spec",description:"Optional spec reference to update (username/spec or username/spec@version)"}),all:vn({long:"all",description:"Update all specs with available updates",defaultValue:()=>!1})},handler:async t=>{await Pu(t.specRef,{all:t.all,cwd:process.cwd()})}}),sg=Re({name:"search",description:"Search for specs in the public registry",args:{query:Kt({type:Qe,displayName:"query",description:"Search query (keywords, tags, or spec names)"})},handler:async t=>{await Lu(t.query)}}),ng=Re({name:"info",description:"Show detailed information about a spec from the public registry",args:{specRef:Kt({type:Qe,displayName:"spec",description:"Spec reference in format username/spec"})},handler:async t=>{await nc(t.specRef)}}),ig=Re({name:"list",description:"Show all installed specs (local and public)",args:{},handler:async()=>{await oc({cwd:process.cwd()})}}),og=MD({name:"spectrl",description:"Local-first spec registry",version:HD,cmds:{init:YD,new:JD,publish:ZD,install:XD,login:KD,logout:QD,whoami:eg,unpublish:tg,update:rg,search:sg,info:ng,list:ig}});async function ag(){try{await BD(og,process.argv.slice(2))}catch(t){t instanceof h&&(A.error(us(t)),process.exit(t.exitCode)),t instanceof Error&&(A.error(us(t)),process.exit(Cn(t))),A.error("Unknown error occurred"),process.exit(1)}}ag();
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:In({long:"skip-agents",description:"Skip AGENTS.md creation/update entirely",defaultValue:()=>!1}),forceAgents:In({long:"force-agents",description:"Force overwrite AGENTS.md with fresh template",defaultValue:()=>!1})},handler:async t=>{await na(process.cwd(),{skipAgents:t.skipAgents,forceAgents:t.forceAgents})}}),vD=Fe({name:"publish",description:"Publish a spec to the local registry",args:{},handler:async()=>{await ma(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:_t({type:nr(Ge),displayName:"spec",description:"Optional spec reference (name@version) to install from registry"})},handler:async t=>{t.specRef?await Ra(t.specRef,{cwd:process.cwd()}):await Sa({cwd:process.cwd()})}}),bD=Fe({name:"new",description:"Create a new spec or power (defaults to spec). Usage: spectrl new [spec|power] <name>",args:{first:_t({type:nr(Ge),displayName:"type-or-name",description:"Content type (spec|power) or name if type is omitted"}),second:_t({type:nr(Ge),displayName:"name",description:"Name (if first arg is the type)"}),version:Su({type:nr(Ge),long:"version",description:"Initial version (default: 0.1.0)",defaultValue:()=>"0.1.0"}),description:Su({type:nr(Ge),long:"description",description:"Description"})},handler:async t=>{let e="spec",r;if(t.first==="spec"||t.first==="power")e=t.first,r=t.second;else if(t.first)r=t.first;else{let{select:s}=await import("@inquirer/prompts");e=await s({message:"What do you want to create?",choices:[{value:"spec",name:"Spec",description:"Structured knowledge \u2014 a PRD, TDD, ADR, or any document agents can consume"},{value:"power",name:"Power",description:"Agent instructions \u2014 reusable workflow rules that steer how an agent behaves"}]})}if(!r){let{input:s}=await import("@inquirer/prompts");r=await s({message:`${e==="power"?"Power":"Spec"} name (lowercase, hyphens ok):`,validate:n=>n.trim()?/^[a-z0-9-]+$/.test(n.trim())?!0:"Must be lowercase alphanumeric with hyphens":"Name is required"}),r=r.trim()}await Aa(r,process.cwd(),e,t.version,t.description)}}),FD=Fe({name:"login",description:"Authenticate with GitHub to access the public registry",args:{},handler:async()=>{await Za()}}),RD=Fe({name:"logout",description:"Remove stored GitHub authentication token",args:{},handler:async()=>{await Ya()}}),SD=Fe({name:"whoami",description:"Show current authenticated GitHub user",args:{},handler:async()=>{await Xa()}}),_D=Fe({name:"unpublish",description:"Remove a spec version from the public registry (requires authentication)",args:{specRef:_t({type:Ge,displayName:"spec",description:"Spec reference in format username/spec@version"})},handler:async t=>{await Ka(t.specRef)}}),AD=Fe({name:"update",description:"Check for and install updates for public specs",args:{specRef:_t({type:nr(Ge),displayName:"spec",description:"Optional spec reference to update (username/spec or username/spec@version)"}),all:In({long:"all",description:"Update all specs with available updates",defaultValue:()=>!1})},handler:async t=>{await tu(t.specRef,{all:t.all,cwd:process.cwd()})}}),$D=Fe({name:"search",description:"Search for specs in the public registry",args:{query:_t({type:Ge,displayName:"query",description:"Search query (keywords, tags, or spec names)"})},handler:async t=>{await su(t.query)}}),ID=Fe({name:"info",description:"Show detailed information about a spec from the public registry",args:{specRef:_t({type:Ge,displayName:"spec",description:"Spec reference in format username/spec"})},handler:async t=>{await bu(t.specRef)}}),OD=Fe({name:"list",description:"Show all installed specs (local and public)",args:{},handler:async()=>{await Ru({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(kn(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");