@visulima/vis 3.0.3 → 3.0.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.
- package/CHANGELOG.md +12 -0
- package/LICENSE.md +1 -130
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/catalog.js +1 -1
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +173 -173
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +3 -3
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +5 -5
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler21.js +2 -2
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler33.js +2 -2
- package/dist/packem_chunks/handler34.js +1 -1
- package/dist/packem_chunks/handler45.js +1 -1
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler48.js +3 -3
- package/dist/packem_chunks/handler5.js +1 -1
- package/dist/packem_chunks/handler50.js +6 -6
- package/dist/packem_chunks/handler51.js +1 -1
- package/dist/packem_chunks/handler54.js +1 -1
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler57.js +1 -1
- package/dist/packem_chunks/handler58.js +2 -2
- package/dist/packem_chunks/handler59.js +2 -2
- package/dist/packem_chunks/handler6.js +7 -7
- package/dist/packem_chunks/handler62.js +2 -2
- package/dist/packem_chunks/handler64.js +3 -3
- package/dist/packem_chunks/handler66.js +2 -2
- package/dist/packem_chunks/handler68.js +1 -1
- package/dist/packem_chunks/handler69.js +2 -2
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler70.js +1 -1
- package/dist/packem_chunks/handler72.js +2 -2
- package/dist/packem_chunks/handler74.js +1 -1
- package/dist/packem_chunks/handler76.js +1 -1
- package/dist/packem_chunks/handler77.js +4 -4
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +7 -7
- package/dist/packem_chunks/index5.js +1 -1
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/{affected-selection-BMoQWuHl.js → affected-selection-DZLa0Hfn.js} +1 -1
- package/dist/packem_shared/{ai-fix-CKN1JGRh.js → ai-fix-CyUx_ZAB.js} +1 -1
- package/dist/packem_shared/{bin-CN4heKmb.js → bin-BWrnjd6M.js} +1 -1
- package/dist/packem_shared/{failure-log-D92tM0ie.js → failure-log-DE_MJCzB.js} +1 -1
- package/dist/packem_shared/{formatBytes-BHAzNIrn-DFIppnY0.js → formatBytes-BHAzNIrn-Bkk_uRS-.js} +1 -1
- package/dist/packem_shared/{index-DXPSWMbG.js → index-CIIKPX4H.js} +1 -1
- package/dist/packem_shared/index-QChhI1AU.js +1 -0
- package/dist/packem_shared/{lifecycle-CfTZQHOG.js → lifecycle-DW8KRF5d.js} +1 -1
- package/dist/packem_shared/{package-version-CJxZ_B7G.js → package-version-cRcuUsLC.js} +1 -1
- package/dist/packem_shared/{packument-C55kVxcQ.js → packument-CHdDsn0O.js} +1 -1
- package/dist/packem_shared/{pm-runner-de-jCq8q.js → pm-runner-d93_73O6.js} +1 -1
- package/dist/packem_shared/{project-name-filter-DsrVo0MY.js → project-name-filter-D4q4JaLN.js} +1 -1
- package/dist/packem_shared/{provenance-CvfQEJPQ.js → provenance-w-NIPtim.js} +1 -1
- package/dist/packem_shared/{registry-keys-DmBrAlhg.js → registry-keys-_IKDLSbu.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-DYaHAVDg.js → resolve-explicit-ZZEPWdpP.js} +1 -1
- package/dist/packem_shared/{s1ngularity-C8sva2SO.js → s1ngularity-R-zLjQjp.js} +1 -1
- package/dist/packem_shared/{signatures-oZ_2IneN.js → signatures-ijwqxAtF.js} +1 -1
- package/dist/packem_shared/{vis-update-app-zqSa2clT.js → vis-update-app-DNeU8RBQ.js} +1 -1
- package/dist/packem_shared/vis-user-error-DZSnp0Uj.js +30 -0
- package/index.js +26 -26
- package/package.json +11 -11
- package/dist/packem_shared/index-DjTWo3sH.js +0 -1
- package/dist/packem_shared/vis-user-error-Dkc97rGY.js +0 -30
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as w}from"node:module";import{D as N,m as x}from"./provenance-
|
|
1
|
+
import{createRequire as w}from"node:module";import{D as N,m as x}from"./provenance-w-NIPtim.js";import{g as P}from"./packument-CHdDsn0O.js";import{c as b}from"../packem_chunks/cli-main.js";import{f as E}from"./registry-keys-_IKDLSbu.js";let _;const $=s=>(_??=w(import.meta.url))(s),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=s=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[e,r]=u.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return u.getBuiltinModule(s)}return $(s)},{createPublicKey:M,createVerify:R}=v("node:crypto"),B=s=>{const e=["-----BEGIN PUBLIC KEY-----"],r=s.replaceAll(/\s+/g,"");for(let n=0;n<r.length;n+=64)e.push(r.slice(n,n+64));return e.push("-----END PUBLIC KEY-----"),e.join(`
|
|
2
2
|
`)},j=({keyBase64:s,message:e,signatureBase64:r})=>{try{const n=M({format:"pem",key:B(s)}),c=R("SHA256");return c.update(e),c.end(),c.verify(n,Buffer.from(r,"base64"))}catch{return!1}},A=(s,e)=>{if(s.expires===void 0||s.expires==="")return!1;const r=Date.parse(s.expires);return Number.isNaN(r)?!1:r<=e},C=(s,e,r)=>`${s}@${e}:${r}`,S=(s,e)=>e!==void 0&&s.includes(e)?e:s.at(-1),Y=async(s,e={})=>{if(b("signatures"))return[];const r=new Set(e.allowlist),n=e.treatExpiredAs??"warning",c=e.concurrency??N,p=await E({keysUrl:e.keysUrl,signal:e.signal,ttlMs:e.keysTtlMs});if(p===void 0)return s.filter(({name:t})=>!r.has(t)).map(({name:t,version:i})=>({code:"fetch-failed",message:"Could not fetch registry signing keys.",packageName:t,severity:"warning",version:i}));const k=new Map;for(const t of p.keys)k.set(t.keyid,t);const m=Date.now();return(await x(s,c,async({name:t,version:i})=>{if(r.has(t))return[];const o=await P(t,{workspaceRoot:e.workspaceRoot});if(o===void 0)return[];const y=o.versions[i]??o.versions[S(Object.keys(o.versions),o["dist-tags"]?.latest)??""];if(y===void 0)return[];const f=y.dist?.signatures,l=y.dist?.integrity;if(f===void 0||f.length===0)return[{code:"missing-signature",message:`Package ${t}@${i} has no dist.signatures from the registry.`,packageName:t,severity:"warning",version:i}];if(typeof l!="string"||l==="")return[{code:"missing-signature",message:`Package ${t}@${i} has signatures but no dist.integrity to verify against.`,packageName:t,severity:"warning",version:i}];const h=C(t,i,l),g=[];for(const a of f){const d=k.get(a.keyid);if(d===void 0){g.push({code:"unknown-keyid",keyid:a.keyid,message:`Package ${t}@${i} was signed with an unrecognized keyid (${a.keyid}).`,packageName:t,severity:"error",version:i});continue}if(A(d,m)){g.push({code:"expired-key",keyid:a.keyid,message:`Package ${t}@${i} was signed with an expired key (${a.keyid}, expired ${d.expires??"unknown"}).`,packageName:t,severity:n,version:i});continue}j({keyBase64:d.key,message:h,signatureBase64:a.sig})||g.push({code:"invalid-signature",keyid:a.keyid,message:`Package ${t}@${i} signature did not verify against ${a.keyid}.`,packageName:t,severity:"error",version:i})}return g})).flat()};export{Y as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as e,X as t,m as r,u as p}from"../packem_chunks/catalog.js";import{T as ae,U as je,V as pe,W as fe,v as me,X as z,Y as ce}from"../packem_chunks/cli-main.js";import{l as we}from"./spinner-BM_0Bj6x.js";import{s as xe}from"./formatBytes-BHAzNIrn-DFIppnY0.js";import{n as Ce,a as be}from"./tabs-UDYQ3tqt.js";import{u as Te}from"./use-measured-height-BPQg2q_p.js";const _e=({current:a,total:l})=>{const{columns:i}=ae(),s=i||80,d=l>0?Math.min(1,a/l):0,h=`${String(Math.round(d*100)).padStart(3)}%`,f=`${String(a)}/${String(l)}`,w=Math.max(10,s-2-h.length-1),g=Math.round(w*d),j=w-g;return e.jsxs(t,{flexDirection:"column",paddingX:1,children:[e.jsxs(t,{children:[e.jsx(we,{type:"dots"}),e.jsx(r,{children:" Checking catalog dependencies "}),e.jsx(r,{dimColor:!0,children:f})]}),e.jsxs(t,{children:[e.jsx(r,{color:"cyan",children:"━".repeat(g)}),e.jsx(r,{dimColor:!0,children:"─".repeat(j)}),e.jsxs(r,{dimColor:!0,children:[" ",h]})]})]})},Z=["default","name","updateType","severity"],ne=a=>{const l=a.vulnerabilities?.map(i=>i.severity)??[];return l.includes("CRITICAL")?4:l.includes("HIGH")?3:l.includes("MODERATE")?2:l.includes("LOW")?1:0},de={digest:0,major:3,minor:2,patch:1,pin:0,unknown:0},he=(a,l)=>{if(l==="default")return a;const i=[...a];return l==="name"?i.sort((s,d)=>s.packageName.localeCompare(d.packageName)):l==="updateType"?i.sort((s,d)=>(de[d.updateType]??0)-(de[s.updateType]??0)||s.packageName.localeCompare(d.packageName)):i.sort((s,d)=>ne(d)-ne(s)||s.packageName.localeCompare(d.packageName)),i},J=a=>`${a.ecosystem}|${a.file}:${String(a.line)}|${a.name}`,I=a=>`${a.catalogName} ${a.packageName}`,W=a=>{const l=new Map;for(const i of a){const s=l.get(i.catalogName);s?s.push(i):l.set(i.catalogName,[i])}return l},$=(a,l,i)=>{let s=a;if(l!=="all"&&(s=l==="security"?s.filter(d=>d.vulnerabilities&&d.vulnerabilities.length>0||d.socketReport&&d.socketReport.alerts.length>0):s.filter(d=>d.updateType===l)),i){const d=i.toLowerCase();s=s.filter(h=>h.packageName.toLowerCase().includes(d))}return s};class Ke{#e;#t=new Set;#l;#s;#i=null;constructor(l,i=null,s=[]){this.#l=l,this.#s=s,i&&(this.#i=new Map(i.recommendations.map(d=>[d.package,d]))),this.#e={aiResult:i,allChecked:!0,applyProgress:null,checkedEcosystemKeys:new Set(s.map(d=>J(d))),checkedEntries:new Set(l.map(d=>I(d))),ecosystemEntries:s,entries:l,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",groupedByCatalog:W(l),phase:"browsing",selectedIndex:0,sortMode:"default"}}getSnapshot=()=>this.#e;subscribe=l=>(this.#t.add(l),()=>{this.#t.delete(l)});getFilteredEntries(){return he($(this.#l,this.#e.filterType,this.#e.filterText),this.#e.sortMode)}setSortMode(l){if(l===this.#e.sortMode)return;const s=this.getFilteredEntries()[this.#e.selectedIndex]?.packageName,d=he($(this.#l,this.#e.filterType,this.#e.filterText),l),h=s?Math.max(0,d.findIndex(f=>f.packageName===s)):0;this.#r({...this.#e,selectedIndex:h,sortMode:l})}cycleSortMode(){const l=Z.indexOf(this.#e.sortMode),i=Z[(l+1)%Z.length]??"default";this.setSortMode(i)}getRecommendation(l){return this.#i?.get(l)}getCheckedEntries(){return this.#l.filter(l=>this.#e.checkedEntries.has(I(l)))}getCheckedEcosystemEntries(){return this.#s.filter(l=>this.#e.checkedEcosystemKeys.has(J(l)))}toggleEcosystemCheck(l){const i=new Set(this.#e.checkedEcosystemKeys);i.has(l)?i.delete(l):i.add(l),this.#r({...this.#e,checkedEcosystemKeys:i})}checkAllEcosystem(){this.#r({...this.#e,checkedEcosystemKeys:new Set(this.#s.map(l=>J(l)))})}uncheckAllEcosystem(){this.#r({...this.#e,checkedEcosystemKeys:new Set})}setSelectedIndex(l){const i=this.getFilteredEntries(),s=Math.max(0,Math.min(l,i.length-1));s!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:s})}setFocusedPanel(l){l!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:l})}setFilterType(l){if(l!==this.#e.filterType){const i=$(this.#l,l,this.#e.filterText);this.#r({...this.#e,entries:i,filterType:l,groupedByCatalog:W(i),selectedIndex:0})}}setFilter(l){const i=$(this.#l,this.#e.filterType,l);this.#r({...this.#e,entries:i,filterText:l,groupedByCatalog:W(i),selectedIndex:0})}setFilterActive(l){if(l!==this.#e.filterActive)if(l)this.#r({...this.#e,filterActive:!0});else{const i=$(this.#l,this.#e.filterType,"");this.#r({...this.#e,entries:i,filterActive:!1,filterText:"",groupedByCatalog:W(i),selectedIndex:0})}}toggleCheck(l){const i=I(l),s=new Set(this.#e.checkedEntries);s.has(i)?s.delete(i):s.add(i),this.#r({...this.#e,allChecked:s.size===this.#l.length,checkedEntries:s})}checkAll(){this.#r({...this.#e,allChecked:!0,checkedEntries:new Set(this.#l.map(l=>I(l)))})}uncheckAll(){this.#r({...this.#e,allChecked:!1,checkedEntries:new Set})}toggleAll(){this.#e.allChecked?this.uncheckAll():this.checkAll()}startApply(){const l=this.getCheckedEntries();this.#r({...this.#e,applyProgress:{current:0,total:l.length},phase:"applying"})}updateApplyProgress(l){this.#e.applyProgress&&this.#r({...this.#e,applyProgress:{...this.#e.applyProgress,current:l}})}markDone(){this.#r({...this.#e,phase:"done"})}setError(l){this.#r({...this.#e,error:l,phase:"error"})}#r(l){this.#e=l;for(const i of this.#t)try{i()}catch{}}}const Se={major:"red",minor:"yellow",patch:"green"},ke={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},ye={critical:"red",high:"red",low:"gray",medium:"yellow"},Re={critical:"red",high:"red",low:"green",medium:"yellow"},Ee={defer:"gray",review:"yellow",skip:"red",update:"green"},Ae=({changelogUrl:a,entry:l,focused:i,recommendation:s,scrollRef:d})=>{const h=i?"white":"gray";if(!l)return e.jsx(t,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:e.jsx(r,{dimColor:!0,children:"No package selected"})});const f=Se[l.updateType]??"white",w=l.vulnerabilities&&l.vulnerabilities.length>0,g=l.socketReport?.score.overall??0,j=l.socketReport?xe(g):"gray";return e.jsxs(t,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsx(t,{flexShrink:0,paddingTop:1,paddingX:2,children:e.jsx(r,{bold:!0,color:"white",children:l.displayName??l.packageName})}),e.jsxs(je,{flexGrow:1,flexShrink:1,paddingX:2,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[e.jsx(r,{}),e.jsxs(t,{children:[e.jsx(t,{width:12,children:e.jsx(r,{dimColor:!0,children:"Current:"})}),e.jsx(r,{children:l.currentRange})]}),e.jsxs(t,{children:[e.jsx(t,{width:12,children:e.jsx(r,{dimColor:!0,children:"Target:"})}),e.jsx(r,{children:l.newRange}),e.jsxs(r,{bold:!0,color:f,children:[" ","(",l.updateType,")"]})]}),e.jsxs(t,{children:[e.jsx(t,{width:12,children:e.jsx(r,{dimColor:!0,children:"Version:"})}),e.jsx(r,{children:l.targetVersion})]}),e.jsxs(t,{children:[e.jsx(t,{width:12,children:e.jsx(r,{dimColor:!0,children:l.kind==="ecosystem"?"Source:":"Catalog:"})}),e.jsx(r,{color:l.kind==="ecosystem"?"cyan":void 0,children:l.catalogName})]}),l.acceptedRisk&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{color:"gray",children:"── "}),e.jsx(r,{bold:!0,color:"gray",children:"ACKNOWLEDGED RISK"}),e.jsxs(t,{flexDirection:"column",paddingLeft:2,children:[e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Reason: "}),e.jsx(r,{children:l.acceptedRisk.reason})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Accepted: "}),e.jsx(r,{children:l.acceptedRisk.acceptedAt.slice(0,10)})]})]})]}),w&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"red",children:"SECURITY"}),e.jsx(r,{}),l.vulnerabilities.map(c=>e.jsxs(t,{flexDirection:"column",marginBottom:1,children:[e.jsxs(t,{gap:1,children:[e.jsxs(r,{bold:!0,color:ke[c.severity]??"gray",children:["⚠"," ",c.severity]}),e.jsx(r,{bold:!0,children:c.id})]}),e.jsx(t,{paddingLeft:2,children:e.jsx(r,{children:c.summary})}),e.jsxs(t,{gap:2,paddingLeft:2,children:[c.cvssScore!==void 0&&e.jsxs(r,{dimColor:!0,children:["CVSS:",String(c.cvssScore)]}),c.fixedVersions.length>0&&e.jsxs(r,{dimColor:!0,children:["Fixed in:",c.fixedVersions.join(", ")]})]})]},c.id))]}),l.socketReport&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"cyan",children:"SOCKET.DEV"}),e.jsx(r,{}),e.jsxs(t,{gap:2,children:[e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Overall: "}),e.jsxs(r,{bold:!0,color:j,children:[String(Math.round(g*100)),"%"]})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Supply Chain: "}),e.jsxs(r,{children:[String(Math.round(l.socketReport.score.supplyChain*100)),"%"]})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Quality: "}),e.jsxs(r,{children:[String(Math.round(l.socketReport.score.quality*100)),"%"]})]})]}),e.jsxs(t,{gap:2,children:[e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Maintenance: "}),e.jsxs(r,{children:[String(Math.round(l.socketReport.score.maintenance*100)),"%"]})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Vulnerability: "}),e.jsxs(r,{children:[String(Math.round(l.socketReport.score.vulnerability*100)),"%"]})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"License: "}),e.jsxs(r,{children:[l.socketReport.license||"unknown"," ","(",String(Math.round(l.socketReport.score.license*100)),"%)"]})]})]}),l.socketReport.alerts.length>0&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsxs(r,{bold:!0,color:"yellow",children:["⚠"," ",String(l.socketReport.alerts.length)," ","alert",l.socketReport.alerts.length===1?"":"s",":"]}),l.socketReport.alerts.map(c=>e.jsxs(t,{gap:1,paddingLeft:2,children:[e.jsxs(r,{bold:!0,color:ye[c.severity]??"gray",children:["[",c.severity.toUpperCase(),"]"]}),e.jsx(r,{children:c.type}),e.jsxs(r,{dimColor:!0,children:["(",c.category,")"]})]},c.key))]})]}),s&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"AI ANALYSIS"}),e.jsx(r,{}),e.jsxs(t,{gap:2,children:[e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Action: "}),e.jsx(r,{bold:!0,color:Ee[s.action]??"white",children:s.action})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Risk: "}),e.jsx(r,{bold:!0,color:Re[s.riskLevel]??"white",children:s.riskLevel})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Effort: "}),e.jsx(r,{bold:!0,children:s.effort})]})]}),s.reason&&e.jsx(t,{marginTop:1,paddingLeft:2,children:e.jsx(r,{children:s.reason})}),s.breakingChanges.length>0&&e.jsxs(t,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.jsx(r,{bold:!0,color:"yellow",children:"Breaking changes:"}),s.breakingChanges.map((c,v)=>e.jsxs(r,{children:[" ","•"," ",c]},String(v)))]})]}),a&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"CHANGELOG"}),e.jsx(t,{marginTop:1,paddingLeft:2,children:e.jsx(r,{color:"cyan",underline:!0,children:a})})]}),e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"LINKS"}),e.jsx(t,{flexDirection:"column",marginTop:1,paddingLeft:2,children:l.kind==="ecosystem"?e.jsx(r,{color:"cyan",underline:!0,children:l.detailUrl??l.displayName??l.packageName}):e.jsxs(r,{color:"cyan",underline:!0,children:["https://npmx.dev/",l.packageName]})})]}),!s&&l.kind!=="ecosystem"&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"GUIDANCE"}),e.jsxs(t,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[l.updateType==="major"&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{color:"red",children:["⚠"," ","Major update — likely contains breaking changes."]}),e.jsx(r,{dimColor:!0,children:" Review the changelog before updating."}),e.jsx(r,{dimColor:!0,children:" Use --changelog to fetch release URLs."})]}),l.updateType==="minor"&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{color:"yellow",children:["ℹ"," ","Minor update — new features, backward compatible."]}),e.jsx(r,{dimColor:!0,children:" Generally safe to update."})]}),l.updateType==="patch"&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{color:"green",children:["✓"," ","Patch update — bug fixes only."]}),e.jsx(r,{dimColor:!0,children:" Safe to update."})]}),!s&&e.jsx(r,{dimColor:!0,children:" Use --ai to get AI-powered analysis."})]})]})]})]})},Ie={major:"red",minor:"yellow",patch:"green"},ve=[{id:"all",label:"All"},{id:"major",label:"Major"},{id:"minor",label:"Minor"},{id:"patch",label:"Patch"},{id:"security",label:"Security"}],Me=({checked:a,entry:l,isSelected:i})=>{const s=Ie[l.updateType]??"white",d=l.vulnerabilities&&l.vulnerabilities.length>0,h=l.socketReport&&l.socketReport.alerts.length>0,f=!!l.acceptedRisk,w=a?"☑":"☐",g=l.socketReport?`${String(Math.round(l.socketReport.score.overall*100))}%`:"",j=l.socketReport?xe(l.socketReport.score.overall):"gray";return e.jsxs(t,{flexShrink:0,height:1,children:[e.jsx(r,{children:i?">":" "}),e.jsxs(r,{color:a?"white":"gray",children:[" ",w," "]}),d||h?e.jsx(r,{color:f?"gray":"red",children:f?"✓ ":"⚠ "}):e.jsx(r,{children:" "}),e.jsx(t,{flexGrow:1,children:e.jsxs(r,{bold:i,inverse:i,wrap:"truncate",children:[l.displayName??l.packageName,f?" [ack]":""]})}),g&&e.jsxs(r,{color:j,children:[" ",g]}),e.jsxs(r,{dimColor:!0,children:[" ",l.currentRange]}),e.jsxs(r,{dimColor:!0,children:[" ","→"," "]}),e.jsxs(r,{children:[l.newRange," "]}),e.jsx(r,{bold:!0,color:s,children:l.updateType})]})},Ne=({count:a,ecosystem:l=!1,name:i})=>e.jsxs(t,{flexShrink:0,height:1,marginTop:1,children:[e.jsxs(r,{color:l?"cyan":void 0,dimColor:!l,children:[l?"◈":"▼"," "]}),e.jsx(r,{bold:!0,color:l?"cyan":"white",children:i.toUpperCase()}),e.jsxs(r,{dimColor:!0,children:[" ","(",a,")"]}),l&&e.jsxs(r,{color:"cyan",dimColor:!0,children:[" ","ci/cd refs"]})]}),De=({checkedEntries:a,entries:l,filterActive:i,filteredOutCount:s,filterText:d,filterType:h,focused:f,groupedByCatalog:w,isDryRun:g,onViewportHeightChange:j,scrollOffset:c,selectedIndex:v,totalCatalogEntries:M,totalChecked:R,totalEntries:U,viewportHeight:P})=>{const B=f?"white":"gray",{measuredHeight:m,ref:E}=Te(P,j);let V=0,y=0,N=0,A=0;for(const u of l)u.updateType==="major"?V++:u.updateType==="minor"?y++:N++,(u.vulnerabilities&&u.vulnerabilities.length>0||u.socketReport&&u.socketReport.alerts.length>0)&&A++;const b=[];V>0&&b.push(`${V} major`),y>0&&b.push(`${y} minor`),N>0&&b.push(`${N} patch`),A>0&&b.push(`${A} vulnerable`);const D=b.length>0?` (${b.join(", ")})`:"",C=l.filter(u=>u.kind==="ecosystem").length,T=l.length-C;let F=0;for(const u of l)a.has(I(u))&&F++;const O=[];let H=0;for(const[u,S]of w){O.push(e.jsx(Ne,{count:S.length,ecosystem:S[0]?.kind==="ecosystem",name:u},`hdr-${u}`));for(const k of S){const X=H;O.push(e.jsx(Me,{checked:a.has(I(k)),entry:k,isSelected:X===v},I(k))),H++}}let L=0;for(const[,u]of w)L+=2+u.length;const _=L>m&&m>0;return e.jsxs(t,{borderColor:B,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(t,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(r,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(r,{wrap:"truncate",children:[C>0?T:U,R>0?`/${R}`:""," ",C>0?"pkgs":"outdated",D,M>R?` · ${M-R} dupes`:""]}),C>0&&e.jsxs(r,{color:"cyan",children:[" ","◈",C," ","ci/cd"]}),!g&&F>0&&e.jsxs(r,{dimColor:!0,children:[" ","—",F," ","selected"]})]}),e.jsx(t,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(Ce,{isFocused:f,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:()=>{},showIndex:!1,value:h,children:ve.map(({id:u,label:S})=>e.jsx(be,{name:u,children:S},u))})}),i&&e.jsxs(t,{flexShrink:0,paddingX:1,children:[e.jsx(r,{bold:!0,color:"white",children:"/ "}),e.jsx(r,{children:d}),e.jsx(r,{inverse:!0,children:" "})]}),s>0&&e.jsx(t,{flexShrink:0,paddingX:1,children:e.jsxs(r,{color:"yellow",children:["⚠"," ",s," ","package",s===1?"":"s"," ","filtered out by target constraint — press"," ",e.jsx(r,{bold:!0,color:"white",children:"f"})," ","to view"]})}),e.jsxs(t,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:E,children:[e.jsx(t,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(t,{flexDirection:"column",marginTop:-c,children:O})}),_&&e.jsx(t,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(pe,{contentHeight:L,placement:"inset",scrollOffset:c,style:"block",viewportHeight:m})})]},`list-${h}-${d}`)]})},Le=100,Pe=40,Be=10,Ve=[],G=["all","major","minor","patch","security"],Ye=({autoExitSeconds:a=0,changelogUrls:l,checkedCount:i=0,filteredOutEntries:s=Ve,isDryRun:d,store:h,totalCatalogEntries:f=0})=>{const{exit:w}=fe(),{columns:g,rows:j}=ae(),c=p.useSyncExternalStore(h.subscribe,h.getSnapshot),[v,M]=p.useState(!1),[R,U]=p.useState(!1),P=p.useRef(null),B=p.useRef(null),m=p.useRef(null),E=p.useRef(null),[V,y]=p.useState(0),[N,A]=p.useState(!1),[b,D]=p.useState(!1),C=p.useMemo(()=>h.getFilteredEntries(),[c.entries,c.filterType,c.filterText,c.sortMode]),T=C[c.selectedIndex]??null,F=T?h.getRecommendation(T.packageName):void 0,O=T&&l?l.get(T.packageName):void 0,H=p.useCallback(o=>{let n=0,x=0;for(const[,Q]of c.groupedByCatalog){n+=2;for(let oe=0;oe<Q.length;oe++){if(x===o)return n;n+=1,x++}}return n},[c.groupedByCatalog]),L=Math.max(1,j-8-(c.filterActive?1:0)),[_,u]=p.useState(L),S=_>0?_:L,k=p.useCallback(o=>{const n=H(o);y(x=>n>x+S-2?Math.max(0,n-S+2):n<x+1?Math.max(0,n-1):x)},[H,S]);if(p.useEffect(()=>{m.current?.scrollToTop()},[T?.packageName]),me((o,n)=>{if(o==="c"&&n.ctrl){w();return}if(!b){if(R){n.escape||o==="f"||o==="q"?U(!1):n.downArrow||o==="j"?B.current?.scrollBy(1):(n.upArrow||o==="k")&&B.current?.scrollBy(-1);return}if(N){o==="u"||n.return?(A(!1),h.startApply(),w(h.getCheckedEntries())):n.escape||o==="q"?A(!1):n.downArrow||o==="j"?E.current?.scrollBy(1):n.upArrow||o==="k"?E.current?.scrollBy(-1):n.pageDown?E.current?.scrollBy(5):n.pageUp&&E.current?.scrollBy(-5);return}if(v){n.escape||o==="?"?M(!1):o==="q"?(M(!1),D(!0)):n.downArrow||o==="j"?P.current?.scrollBy(1):(n.upArrow||o==="k")&&P.current?.scrollBy(-1);return}if(o==="?"){M(!0);return}if(o==="q"){D(!0);return}if(n.tab){h.setFocusedPanel(c.focusedPanel==="list"?"detail":"list");return}if(c.focusedPanel==="list"&&(n.leftArrow||n.rightArrow)){const x=G.indexOf(c.filterType),Q=n.rightArrow?(x+1)%G.length:(x-1+G.length)%G.length;y(0),m.current?.scrollToTop(),h.setFilterType(G[Q]);return}if(o==="f"&&s.length>0){U(x=>!x);return}if(c.filterActive){if(n.escape){h.setFilterActive(!1);return}if(n.return){h.setFilterActive(!1);return}if(n.backspace){y(0),h.setFilter(c.filterText.slice(0,-1));return}if(o&&!n.ctrl&&!n.meta){y(0),h.setFilter(c.filterText+o);return}return}if(c.focusedPanel==="list"){if(n.downArrow||o==="j"){const x=Math.min(c.selectedIndex+1,C.length-1);h.setSelectedIndex(x),k(x);return}if(n.upArrow||o==="k"){const x=Math.max(c.selectedIndex-1,0);h.setSelectedIndex(x),k(x);return}if(n.pageDown){const x=Math.min(c.selectedIndex+10,C.length-1);h.setSelectedIndex(x),k(x);return}if(n.pageUp){const x=Math.max(c.selectedIndex-10,0);h.setSelectedIndex(x),k(x);return}if(n.home){h.setSelectedIndex(0),y(0);return}if(n.end){const x=C.length-1;h.setSelectedIndex(x),k(x);return}if(o===" "||n.return){T&&h.toggleCheck(T);return}if(o==="a"){h.toggleAll();return}if(o==="s"){h.cycleSortMode(),k(h.getSnapshot().selectedIndex);return}if(o==="/"){h.setFilterActive(!0);return}if(o==="u"&&!d&&c.checkedEntries.size>0){A(!0);return}if(n.rightArrow){h.setFocusedPanel("detail");return}return}if(c.focusedPanel==="detail"){if(n.escape||n.leftArrow){h.setFocusedPanel("list");return}if(n.downArrow||o==="j"){m.current?.scrollBy(1);return}if(n.upArrow||o==="k"){m.current?.scrollBy(-1);return}if(n.pageDown){m.current?.scrollBy(10);return}if(n.pageUp){m.current?.scrollBy(-10);return}if(n.home){m.current?.scrollToTop();return}n.end&&m.current?.scrollToBottom()}}},{isActive:!0}),g<Pe||j<Be)return e.jsx(t,{alignItems:"center",height:j,justifyContent:"center",width:g,children:e.jsxs(r,{color:"yellow",children:["Terminal too small (",g,"x",j,")"]})});const X=g>=Le,K=[e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),e.jsx(r,{dimColor:!0,children:"NAV"})]},"nav"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:"CHECK"})]},"sp"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"a"}),e.jsx(r,{dimColor:!0,children:"ALL"})]},"a")];!d&&c.checkedEntries.size>0&&K.push(e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"green",children:"u"}),e.jsx(r,{dimColor:!0,children:"APPLY"})]},"u")),s.length>0&&K.push(e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"yellow",children:"f"}),e.jsxs(r,{dimColor:!0,children:["FILTERED (",s.length,")"]})]},"fo")),K.push(e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:"FILTER"})]},"lr"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:"SEARCH"})]},"f"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:"PANEL"})]},"t"));const ee=e.jsx(t,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:e.jsx(t,{flexWrap:"wrap",gap:2,paddingX:1,children:K})}),re=e.jsxs(z,{footer:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(r,{bold:!0,color:"white",children:"?"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:P,title:"KEYBOARD SHORTCUTS",visible:v,width:52,children:[e.jsxs(t,{flexDirection:"column",marginBottom:1,children:[e.jsxs(t,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(t,{children:[e.jsx(t,{width:24,children:e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","↑","/k"]}),e.jsx(r,{dimColor:!0,children:" Move up"})]})}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","↓","/j"]}),e.jsx(r,{dimColor:!0,children:" Move down"})]})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","Tab"]}),e.jsx(r,{dimColor:!0,children:" Switch panel"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","→","/","←"]}),e.jsx(r,{dimColor:!0,children:" Focus detail/list"})]})]}),e.jsxs(t,{flexDirection:"column",marginBottom:1,children:[e.jsxs(t,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"SELECTION"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","Space"]}),e.jsx(r,{dimColor:!0,children:" Toggle check on package"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","a"]}),e.jsx(r,{dimColor:!0,children:" Toggle check all"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","s"]}),e.jsx(r,{dimColor:!0,children:" Cycle sort (default / name / type / severity)"})]})]}),e.jsxs(t,{flexDirection:"column",marginBottom:1,children:[e.jsxs(t,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"FILTERS"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","←→"]}),e.jsx(r,{dimColor:!0,children:" Switch filter tab"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","/"]}),e.jsx(r,{dimColor:!0,children:" Text filter"})]}),s.length>0&&e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","f"]}),e.jsx(r,{dimColor:!0,children:" View filtered-out packages"})]})]}),e.jsxs(t,{flexDirection:"column",children:[e.jsxs(t,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),!d&&e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","u"]}),e.jsx(r,{dimColor:!0,children:" Apply selected updates"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","q"]}),e.jsx(r,{dimColor:!0,children:" Quit"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","?"]}),e.jsx(r,{dimColor:!0,children:" Toggle help"})]})]})]}),Y=h.getCheckedEntries(),q=Y.filter(o=>o.updateType==="major").length,ue=e.jsxs(t,{alignItems:"center",flexDirection:"column",children:[q>0&&e.jsx(t,{marginBottom:1,marginTop:1,children:e.jsxs(r,{color:"yellow",children:["⚠"," ",q," ","major update",q===1?"":"s"," ","— review breaking changes"]})}),e.jsxs(r,{dimColor:!0,children:["Press"," ",e.jsx(r,{bold:!0,color:"white",children:"u"})," ","or"," ",e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","to confirm,"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","to cancel"]})]}),le=e.jsx(z,{footer:ue,scrollRef:E,title:`Apply ${Y.length} update${Y.length===1?"":"s"}?`,visible:N,width:70,children:Y.map(o=>e.jsxs(t,{gap:1,children:[e.jsxs(r,{children:[" ",o.displayName??o.packageName]}),e.jsxs(r,{dimColor:!0,children:[o.currentRange," ","→"," ",o.newRange]}),e.jsx(r,{bold:!0,color:o.updateType==="major"?"red":o.updateType==="minor"?"yellow":"green",children:o.updateType})]},o.packageName))}),te=s.length>0?e.jsx(z,{footer:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(r,{bold:!0,color:"white",children:"f"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:B,title:`${s.length} PACKAGE${s.length===1?"":"S"} FILTERED BY TARGET`,visible:R,width:70,children:e.jsxs(t,{flexDirection:"column",children:[e.jsx(t,{marginBottom:1,children:e.jsxs(r,{dimColor:!0,children:["These packages have newer versions available but are excluded by the current target constraint. Use"," ",e.jsx(r,{bold:!0,color:"white",children:"--target latest"})," ","to include them."]})}),s.map(o=>e.jsxs(t,{gap:1,children:[e.jsxs(r,{children:[" ",o.packageName]}),e.jsxs(r,{dimColor:!0,children:[o.currentRange," ","→"," ",o.newRange]}),e.jsx(r,{bold:!0,color:o.updateType==="major"?"red":o.updateType==="minor"?"yellow":"green",children:o.updateType})]},o.packageName))]})}):null,se=e.jsx(De,{checkedEntries:c.checkedEntries,entries:C,filterActive:c.filterActive,filteredOutCount:s.length,filterText:c.filterText,filterType:c.filterType,focused:c.focusedPanel==="list",groupedByCatalog:c.groupedByCatalog,isDryRun:d,onViewportHeightChange:u,scrollOffset:V,selectedIndex:c.selectedIndex,totalCatalogEntries:f,totalChecked:i,totalEntries:C.length,viewportHeight:S}),ie=e.jsx(Ae,{changelogUrl:O,entry:T,focused:c.focusedPanel==="detail",recommendation:F,scrollRef:m});if(X){const o=Math.floor(g*.35);return e.jsxs(t,{flexDirection:"column",height:j,width:g,children:[e.jsxs(t,{flexDirection:"row",flexGrow:1,children:[e.jsx(t,{flexGrow:1,children:se}),e.jsx(t,{width:o,children:ie})]}),ee,le,te,e.jsx(ce,{autoExitSeconds:a||3,onCancel:()=>{D(!1)},visible:b}),re]})}const ge=Math.floor(j*.55);return e.jsxs(t,{flexDirection:"column",height:j,width:g,children:[e.jsx(t,{height:ge,children:se}),e.jsx(t,{flexGrow:1,children:ie}),ee,le,te,e.jsx(ce,{autoExitSeconds:a||3,onCancel:()=>{D(!1)},visible:b}),re]})};export{_e as C,Ke as U,Ye as V,J as e};
|
|
1
|
+
import{y as e,X as t,m as r,u as p}from"../packem_chunks/catalog.js";import{T as ae,U as je,V as pe,W as fe,v as me,X as z,Y as ce}from"../packem_chunks/cli-main.js";import{l as we}from"./spinner-BM_0Bj6x.js";import{s as xe}from"./formatBytes-BHAzNIrn-Bkk_uRS-.js";import{n as Ce,a as be}from"./tabs-UDYQ3tqt.js";import{u as Te}from"./use-measured-height-BPQg2q_p.js";const _e=({current:a,total:l})=>{const{columns:i}=ae(),s=i||80,d=l>0?Math.min(1,a/l):0,h=`${String(Math.round(d*100)).padStart(3)}%`,f=`${String(a)}/${String(l)}`,w=Math.max(10,s-2-h.length-1),g=Math.round(w*d),j=w-g;return e.jsxs(t,{flexDirection:"column",paddingX:1,children:[e.jsxs(t,{children:[e.jsx(we,{type:"dots"}),e.jsx(r,{children:" Checking catalog dependencies "}),e.jsx(r,{dimColor:!0,children:f})]}),e.jsxs(t,{children:[e.jsx(r,{color:"cyan",children:"━".repeat(g)}),e.jsx(r,{dimColor:!0,children:"─".repeat(j)}),e.jsxs(r,{dimColor:!0,children:[" ",h]})]})]})},Z=["default","name","updateType","severity"],ne=a=>{const l=a.vulnerabilities?.map(i=>i.severity)??[];return l.includes("CRITICAL")?4:l.includes("HIGH")?3:l.includes("MODERATE")?2:l.includes("LOW")?1:0},de={digest:0,major:3,minor:2,patch:1,pin:0,unknown:0},he=(a,l)=>{if(l==="default")return a;const i=[...a];return l==="name"?i.sort((s,d)=>s.packageName.localeCompare(d.packageName)):l==="updateType"?i.sort((s,d)=>(de[d.updateType]??0)-(de[s.updateType]??0)||s.packageName.localeCompare(d.packageName)):i.sort((s,d)=>ne(d)-ne(s)||s.packageName.localeCompare(d.packageName)),i},J=a=>`${a.ecosystem}|${a.file}:${String(a.line)}|${a.name}`,I=a=>`${a.catalogName} ${a.packageName}`,W=a=>{const l=new Map;for(const i of a){const s=l.get(i.catalogName);s?s.push(i):l.set(i.catalogName,[i])}return l},$=(a,l,i)=>{let s=a;if(l!=="all"&&(s=l==="security"?s.filter(d=>d.vulnerabilities&&d.vulnerabilities.length>0||d.socketReport&&d.socketReport.alerts.length>0):s.filter(d=>d.updateType===l)),i){const d=i.toLowerCase();s=s.filter(h=>h.packageName.toLowerCase().includes(d))}return s};class Ke{#e;#t=new Set;#l;#s;#i=null;constructor(l,i=null,s=[]){this.#l=l,this.#s=s,i&&(this.#i=new Map(i.recommendations.map(d=>[d.package,d]))),this.#e={aiResult:i,allChecked:!0,applyProgress:null,checkedEcosystemKeys:new Set(s.map(d=>J(d))),checkedEntries:new Set(l.map(d=>I(d))),ecosystemEntries:s,entries:l,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",groupedByCatalog:W(l),phase:"browsing",selectedIndex:0,sortMode:"default"}}getSnapshot=()=>this.#e;subscribe=l=>(this.#t.add(l),()=>{this.#t.delete(l)});getFilteredEntries(){return he($(this.#l,this.#e.filterType,this.#e.filterText),this.#e.sortMode)}setSortMode(l){if(l===this.#e.sortMode)return;const s=this.getFilteredEntries()[this.#e.selectedIndex]?.packageName,d=he($(this.#l,this.#e.filterType,this.#e.filterText),l),h=s?Math.max(0,d.findIndex(f=>f.packageName===s)):0;this.#r({...this.#e,selectedIndex:h,sortMode:l})}cycleSortMode(){const l=Z.indexOf(this.#e.sortMode),i=Z[(l+1)%Z.length]??"default";this.setSortMode(i)}getRecommendation(l){return this.#i?.get(l)}getCheckedEntries(){return this.#l.filter(l=>this.#e.checkedEntries.has(I(l)))}getCheckedEcosystemEntries(){return this.#s.filter(l=>this.#e.checkedEcosystemKeys.has(J(l)))}toggleEcosystemCheck(l){const i=new Set(this.#e.checkedEcosystemKeys);i.has(l)?i.delete(l):i.add(l),this.#r({...this.#e,checkedEcosystemKeys:i})}checkAllEcosystem(){this.#r({...this.#e,checkedEcosystemKeys:new Set(this.#s.map(l=>J(l)))})}uncheckAllEcosystem(){this.#r({...this.#e,checkedEcosystemKeys:new Set})}setSelectedIndex(l){const i=this.getFilteredEntries(),s=Math.max(0,Math.min(l,i.length-1));s!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:s})}setFocusedPanel(l){l!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:l})}setFilterType(l){if(l!==this.#e.filterType){const i=$(this.#l,l,this.#e.filterText);this.#r({...this.#e,entries:i,filterType:l,groupedByCatalog:W(i),selectedIndex:0})}}setFilter(l){const i=$(this.#l,this.#e.filterType,l);this.#r({...this.#e,entries:i,filterText:l,groupedByCatalog:W(i),selectedIndex:0})}setFilterActive(l){if(l!==this.#e.filterActive)if(l)this.#r({...this.#e,filterActive:!0});else{const i=$(this.#l,this.#e.filterType,"");this.#r({...this.#e,entries:i,filterActive:!1,filterText:"",groupedByCatalog:W(i),selectedIndex:0})}}toggleCheck(l){const i=I(l),s=new Set(this.#e.checkedEntries);s.has(i)?s.delete(i):s.add(i),this.#r({...this.#e,allChecked:s.size===this.#l.length,checkedEntries:s})}checkAll(){this.#r({...this.#e,allChecked:!0,checkedEntries:new Set(this.#l.map(l=>I(l)))})}uncheckAll(){this.#r({...this.#e,allChecked:!1,checkedEntries:new Set})}toggleAll(){this.#e.allChecked?this.uncheckAll():this.checkAll()}startApply(){const l=this.getCheckedEntries();this.#r({...this.#e,applyProgress:{current:0,total:l.length},phase:"applying"})}updateApplyProgress(l){this.#e.applyProgress&&this.#r({...this.#e,applyProgress:{...this.#e.applyProgress,current:l}})}markDone(){this.#r({...this.#e,phase:"done"})}setError(l){this.#r({...this.#e,error:l,phase:"error"})}#r(l){this.#e=l;for(const i of this.#t)try{i()}catch{}}}const Se={major:"red",minor:"yellow",patch:"green"},ke={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},ye={critical:"red",high:"red",low:"gray",medium:"yellow"},Re={critical:"red",high:"red",low:"green",medium:"yellow"},Ee={defer:"gray",review:"yellow",skip:"red",update:"green"},Ae=({changelogUrl:a,entry:l,focused:i,recommendation:s,scrollRef:d})=>{const h=i?"white":"gray";if(!l)return e.jsx(t,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:e.jsx(r,{dimColor:!0,children:"No package selected"})});const f=Se[l.updateType]??"white",w=l.vulnerabilities&&l.vulnerabilities.length>0,g=l.socketReport?.score.overall??0,j=l.socketReport?xe(g):"gray";return e.jsxs(t,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsx(t,{flexShrink:0,paddingTop:1,paddingX:2,children:e.jsx(r,{bold:!0,color:"white",children:l.displayName??l.packageName})}),e.jsxs(je,{flexGrow:1,flexShrink:1,paddingX:2,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[e.jsx(r,{}),e.jsxs(t,{children:[e.jsx(t,{width:12,children:e.jsx(r,{dimColor:!0,children:"Current:"})}),e.jsx(r,{children:l.currentRange})]}),e.jsxs(t,{children:[e.jsx(t,{width:12,children:e.jsx(r,{dimColor:!0,children:"Target:"})}),e.jsx(r,{children:l.newRange}),e.jsxs(r,{bold:!0,color:f,children:[" ","(",l.updateType,")"]})]}),e.jsxs(t,{children:[e.jsx(t,{width:12,children:e.jsx(r,{dimColor:!0,children:"Version:"})}),e.jsx(r,{children:l.targetVersion})]}),e.jsxs(t,{children:[e.jsx(t,{width:12,children:e.jsx(r,{dimColor:!0,children:l.kind==="ecosystem"?"Source:":"Catalog:"})}),e.jsx(r,{color:l.kind==="ecosystem"?"cyan":void 0,children:l.catalogName})]}),l.acceptedRisk&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{color:"gray",children:"── "}),e.jsx(r,{bold:!0,color:"gray",children:"ACKNOWLEDGED RISK"}),e.jsxs(t,{flexDirection:"column",paddingLeft:2,children:[e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Reason: "}),e.jsx(r,{children:l.acceptedRisk.reason})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Accepted: "}),e.jsx(r,{children:l.acceptedRisk.acceptedAt.slice(0,10)})]})]})]}),w&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"red",children:"SECURITY"}),e.jsx(r,{}),l.vulnerabilities.map(c=>e.jsxs(t,{flexDirection:"column",marginBottom:1,children:[e.jsxs(t,{gap:1,children:[e.jsxs(r,{bold:!0,color:ke[c.severity]??"gray",children:["⚠"," ",c.severity]}),e.jsx(r,{bold:!0,children:c.id})]}),e.jsx(t,{paddingLeft:2,children:e.jsx(r,{children:c.summary})}),e.jsxs(t,{gap:2,paddingLeft:2,children:[c.cvssScore!==void 0&&e.jsxs(r,{dimColor:!0,children:["CVSS:",String(c.cvssScore)]}),c.fixedVersions.length>0&&e.jsxs(r,{dimColor:!0,children:["Fixed in:",c.fixedVersions.join(", ")]})]})]},c.id))]}),l.socketReport&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"cyan",children:"SOCKET.DEV"}),e.jsx(r,{}),e.jsxs(t,{gap:2,children:[e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Overall: "}),e.jsxs(r,{bold:!0,color:j,children:[String(Math.round(g*100)),"%"]})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Supply Chain: "}),e.jsxs(r,{children:[String(Math.round(l.socketReport.score.supplyChain*100)),"%"]})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Quality: "}),e.jsxs(r,{children:[String(Math.round(l.socketReport.score.quality*100)),"%"]})]})]}),e.jsxs(t,{gap:2,children:[e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Maintenance: "}),e.jsxs(r,{children:[String(Math.round(l.socketReport.score.maintenance*100)),"%"]})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Vulnerability: "}),e.jsxs(r,{children:[String(Math.round(l.socketReport.score.vulnerability*100)),"%"]})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"License: "}),e.jsxs(r,{children:[l.socketReport.license||"unknown"," ","(",String(Math.round(l.socketReport.score.license*100)),"%)"]})]})]}),l.socketReport.alerts.length>0&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsxs(r,{bold:!0,color:"yellow",children:["⚠"," ",String(l.socketReport.alerts.length)," ","alert",l.socketReport.alerts.length===1?"":"s",":"]}),l.socketReport.alerts.map(c=>e.jsxs(t,{gap:1,paddingLeft:2,children:[e.jsxs(r,{bold:!0,color:ye[c.severity]??"gray",children:["[",c.severity.toUpperCase(),"]"]}),e.jsx(r,{children:c.type}),e.jsxs(r,{dimColor:!0,children:["(",c.category,")"]})]},c.key))]})]}),s&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"AI ANALYSIS"}),e.jsx(r,{}),e.jsxs(t,{gap:2,children:[e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Action: "}),e.jsx(r,{bold:!0,color:Ee[s.action]??"white",children:s.action})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Risk: "}),e.jsx(r,{bold:!0,color:Re[s.riskLevel]??"white",children:s.riskLevel})]}),e.jsxs(t,{children:[e.jsx(r,{dimColor:!0,children:"Effort: "}),e.jsx(r,{bold:!0,children:s.effort})]})]}),s.reason&&e.jsx(t,{marginTop:1,paddingLeft:2,children:e.jsx(r,{children:s.reason})}),s.breakingChanges.length>0&&e.jsxs(t,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.jsx(r,{bold:!0,color:"yellow",children:"Breaking changes:"}),s.breakingChanges.map((c,v)=>e.jsxs(r,{children:[" ","•"," ",c]},String(v)))]})]}),a&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"CHANGELOG"}),e.jsx(t,{marginTop:1,paddingLeft:2,children:e.jsx(r,{color:"cyan",underline:!0,children:a})})]}),e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"LINKS"}),e.jsx(t,{flexDirection:"column",marginTop:1,paddingLeft:2,children:l.kind==="ecosystem"?e.jsx(r,{color:"cyan",underline:!0,children:l.detailUrl??l.displayName??l.packageName}):e.jsxs(r,{color:"cyan",underline:!0,children:["https://npmx.dev/",l.packageName]})})]}),!s&&l.kind!=="ecosystem"&&e.jsxs(t,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"GUIDANCE"}),e.jsxs(t,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[l.updateType==="major"&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{color:"red",children:["⚠"," ","Major update — likely contains breaking changes."]}),e.jsx(r,{dimColor:!0,children:" Review the changelog before updating."}),e.jsx(r,{dimColor:!0,children:" Use --changelog to fetch release URLs."})]}),l.updateType==="minor"&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{color:"yellow",children:["ℹ"," ","Minor update — new features, backward compatible."]}),e.jsx(r,{dimColor:!0,children:" Generally safe to update."})]}),l.updateType==="patch"&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{color:"green",children:["✓"," ","Patch update — bug fixes only."]}),e.jsx(r,{dimColor:!0,children:" Safe to update."})]}),!s&&e.jsx(r,{dimColor:!0,children:" Use --ai to get AI-powered analysis."})]})]})]})]})},Ie={major:"red",minor:"yellow",patch:"green"},ve=[{id:"all",label:"All"},{id:"major",label:"Major"},{id:"minor",label:"Minor"},{id:"patch",label:"Patch"},{id:"security",label:"Security"}],Me=({checked:a,entry:l,isSelected:i})=>{const s=Ie[l.updateType]??"white",d=l.vulnerabilities&&l.vulnerabilities.length>0,h=l.socketReport&&l.socketReport.alerts.length>0,f=!!l.acceptedRisk,w=a?"☑":"☐",g=l.socketReport?`${String(Math.round(l.socketReport.score.overall*100))}%`:"",j=l.socketReport?xe(l.socketReport.score.overall):"gray";return e.jsxs(t,{flexShrink:0,height:1,children:[e.jsx(r,{children:i?">":" "}),e.jsxs(r,{color:a?"white":"gray",children:[" ",w," "]}),d||h?e.jsx(r,{color:f?"gray":"red",children:f?"✓ ":"⚠ "}):e.jsx(r,{children:" "}),e.jsx(t,{flexGrow:1,children:e.jsxs(r,{bold:i,inverse:i,wrap:"truncate",children:[l.displayName??l.packageName,f?" [ack]":""]})}),g&&e.jsxs(r,{color:j,children:[" ",g]}),e.jsxs(r,{dimColor:!0,children:[" ",l.currentRange]}),e.jsxs(r,{dimColor:!0,children:[" ","→"," "]}),e.jsxs(r,{children:[l.newRange," "]}),e.jsx(r,{bold:!0,color:s,children:l.updateType})]})},Ne=({count:a,ecosystem:l=!1,name:i})=>e.jsxs(t,{flexShrink:0,height:1,marginTop:1,children:[e.jsxs(r,{color:l?"cyan":void 0,dimColor:!l,children:[l?"◈":"▼"," "]}),e.jsx(r,{bold:!0,color:l?"cyan":"white",children:i.toUpperCase()}),e.jsxs(r,{dimColor:!0,children:[" ","(",a,")"]}),l&&e.jsxs(r,{color:"cyan",dimColor:!0,children:[" ","ci/cd refs"]})]}),De=({checkedEntries:a,entries:l,filterActive:i,filteredOutCount:s,filterText:d,filterType:h,focused:f,groupedByCatalog:w,isDryRun:g,onViewportHeightChange:j,scrollOffset:c,selectedIndex:v,totalCatalogEntries:M,totalChecked:R,totalEntries:U,viewportHeight:P})=>{const B=f?"white":"gray",{measuredHeight:m,ref:E}=Te(P,j);let V=0,y=0,N=0,A=0;for(const u of l)u.updateType==="major"?V++:u.updateType==="minor"?y++:N++,(u.vulnerabilities&&u.vulnerabilities.length>0||u.socketReport&&u.socketReport.alerts.length>0)&&A++;const b=[];V>0&&b.push(`${V} major`),y>0&&b.push(`${y} minor`),N>0&&b.push(`${N} patch`),A>0&&b.push(`${A} vulnerable`);const D=b.length>0?` (${b.join(", ")})`:"",C=l.filter(u=>u.kind==="ecosystem").length,T=l.length-C;let F=0;for(const u of l)a.has(I(u))&&F++;const O=[];let H=0;for(const[u,S]of w){O.push(e.jsx(Ne,{count:S.length,ecosystem:S[0]?.kind==="ecosystem",name:u},`hdr-${u}`));for(const k of S){const X=H;O.push(e.jsx(Me,{checked:a.has(I(k)),entry:k,isSelected:X===v},I(k))),H++}}let L=0;for(const[,u]of w)L+=2+u.length;const _=L>m&&m>0;return e.jsxs(t,{borderColor:B,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(t,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(r,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(r,{wrap:"truncate",children:[C>0?T:U,R>0?`/${R}`:""," ",C>0?"pkgs":"outdated",D,M>R?` · ${M-R} dupes`:""]}),C>0&&e.jsxs(r,{color:"cyan",children:[" ","◈",C," ","ci/cd"]}),!g&&F>0&&e.jsxs(r,{dimColor:!0,children:[" ","—",F," ","selected"]})]}),e.jsx(t,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(Ce,{isFocused:f,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:()=>{},showIndex:!1,value:h,children:ve.map(({id:u,label:S})=>e.jsx(be,{name:u,children:S},u))})}),i&&e.jsxs(t,{flexShrink:0,paddingX:1,children:[e.jsx(r,{bold:!0,color:"white",children:"/ "}),e.jsx(r,{children:d}),e.jsx(r,{inverse:!0,children:" "})]}),s>0&&e.jsx(t,{flexShrink:0,paddingX:1,children:e.jsxs(r,{color:"yellow",children:["⚠"," ",s," ","package",s===1?"":"s"," ","filtered out by target constraint — press"," ",e.jsx(r,{bold:!0,color:"white",children:"f"})," ","to view"]})}),e.jsxs(t,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:E,children:[e.jsx(t,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(t,{flexDirection:"column",marginTop:-c,children:O})}),_&&e.jsx(t,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(pe,{contentHeight:L,placement:"inset",scrollOffset:c,style:"block",viewportHeight:m})})]},`list-${h}-${d}`)]})},Le=100,Pe=40,Be=10,Ve=[],G=["all","major","minor","patch","security"],Ye=({autoExitSeconds:a=0,changelogUrls:l,checkedCount:i=0,filteredOutEntries:s=Ve,isDryRun:d,store:h,totalCatalogEntries:f=0})=>{const{exit:w}=fe(),{columns:g,rows:j}=ae(),c=p.useSyncExternalStore(h.subscribe,h.getSnapshot),[v,M]=p.useState(!1),[R,U]=p.useState(!1),P=p.useRef(null),B=p.useRef(null),m=p.useRef(null),E=p.useRef(null),[V,y]=p.useState(0),[N,A]=p.useState(!1),[b,D]=p.useState(!1),C=p.useMemo(()=>h.getFilteredEntries(),[c.entries,c.filterType,c.filterText,c.sortMode]),T=C[c.selectedIndex]??null,F=T?h.getRecommendation(T.packageName):void 0,O=T&&l?l.get(T.packageName):void 0,H=p.useCallback(o=>{let n=0,x=0;for(const[,Q]of c.groupedByCatalog){n+=2;for(let oe=0;oe<Q.length;oe++){if(x===o)return n;n+=1,x++}}return n},[c.groupedByCatalog]),L=Math.max(1,j-8-(c.filterActive?1:0)),[_,u]=p.useState(L),S=_>0?_:L,k=p.useCallback(o=>{const n=H(o);y(x=>n>x+S-2?Math.max(0,n-S+2):n<x+1?Math.max(0,n-1):x)},[H,S]);if(p.useEffect(()=>{m.current?.scrollToTop()},[T?.packageName]),me((o,n)=>{if(o==="c"&&n.ctrl){w();return}if(!b){if(R){n.escape||o==="f"||o==="q"?U(!1):n.downArrow||o==="j"?B.current?.scrollBy(1):(n.upArrow||o==="k")&&B.current?.scrollBy(-1);return}if(N){o==="u"||n.return?(A(!1),h.startApply(),w(h.getCheckedEntries())):n.escape||o==="q"?A(!1):n.downArrow||o==="j"?E.current?.scrollBy(1):n.upArrow||o==="k"?E.current?.scrollBy(-1):n.pageDown?E.current?.scrollBy(5):n.pageUp&&E.current?.scrollBy(-5);return}if(v){n.escape||o==="?"?M(!1):o==="q"?(M(!1),D(!0)):n.downArrow||o==="j"?P.current?.scrollBy(1):(n.upArrow||o==="k")&&P.current?.scrollBy(-1);return}if(o==="?"){M(!0);return}if(o==="q"){D(!0);return}if(n.tab){h.setFocusedPanel(c.focusedPanel==="list"?"detail":"list");return}if(c.focusedPanel==="list"&&(n.leftArrow||n.rightArrow)){const x=G.indexOf(c.filterType),Q=n.rightArrow?(x+1)%G.length:(x-1+G.length)%G.length;y(0),m.current?.scrollToTop(),h.setFilterType(G[Q]);return}if(o==="f"&&s.length>0){U(x=>!x);return}if(c.filterActive){if(n.escape){h.setFilterActive(!1);return}if(n.return){h.setFilterActive(!1);return}if(n.backspace){y(0),h.setFilter(c.filterText.slice(0,-1));return}if(o&&!n.ctrl&&!n.meta){y(0),h.setFilter(c.filterText+o);return}return}if(c.focusedPanel==="list"){if(n.downArrow||o==="j"){const x=Math.min(c.selectedIndex+1,C.length-1);h.setSelectedIndex(x),k(x);return}if(n.upArrow||o==="k"){const x=Math.max(c.selectedIndex-1,0);h.setSelectedIndex(x),k(x);return}if(n.pageDown){const x=Math.min(c.selectedIndex+10,C.length-1);h.setSelectedIndex(x),k(x);return}if(n.pageUp){const x=Math.max(c.selectedIndex-10,0);h.setSelectedIndex(x),k(x);return}if(n.home){h.setSelectedIndex(0),y(0);return}if(n.end){const x=C.length-1;h.setSelectedIndex(x),k(x);return}if(o===" "||n.return){T&&h.toggleCheck(T);return}if(o==="a"){h.toggleAll();return}if(o==="s"){h.cycleSortMode(),k(h.getSnapshot().selectedIndex);return}if(o==="/"){h.setFilterActive(!0);return}if(o==="u"&&!d&&c.checkedEntries.size>0){A(!0);return}if(n.rightArrow){h.setFocusedPanel("detail");return}return}if(c.focusedPanel==="detail"){if(n.escape||n.leftArrow){h.setFocusedPanel("list");return}if(n.downArrow||o==="j"){m.current?.scrollBy(1);return}if(n.upArrow||o==="k"){m.current?.scrollBy(-1);return}if(n.pageDown){m.current?.scrollBy(10);return}if(n.pageUp){m.current?.scrollBy(-10);return}if(n.home){m.current?.scrollToTop();return}n.end&&m.current?.scrollToBottom()}}},{isActive:!0}),g<Pe||j<Be)return e.jsx(t,{alignItems:"center",height:j,justifyContent:"center",width:g,children:e.jsxs(r,{color:"yellow",children:["Terminal too small (",g,"x",j,")"]})});const X=g>=Le,K=[e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),e.jsx(r,{dimColor:!0,children:"NAV"})]},"nav"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:"CHECK"})]},"sp"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"a"}),e.jsx(r,{dimColor:!0,children:"ALL"})]},"a")];!d&&c.checkedEntries.size>0&&K.push(e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"green",children:"u"}),e.jsx(r,{dimColor:!0,children:"APPLY"})]},"u")),s.length>0&&K.push(e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"yellow",children:"f"}),e.jsxs(r,{dimColor:!0,children:["FILTERED (",s.length,")"]})]},"fo")),K.push(e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:"FILTER"})]},"lr"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:"SEARCH"})]},"f"),e.jsxs(t,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:"PANEL"})]},"t"));const ee=e.jsx(t,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:e.jsx(t,{flexWrap:"wrap",gap:2,paddingX:1,children:K})}),re=e.jsxs(z,{footer:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(r,{bold:!0,color:"white",children:"?"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:P,title:"KEYBOARD SHORTCUTS",visible:v,width:52,children:[e.jsxs(t,{flexDirection:"column",marginBottom:1,children:[e.jsxs(t,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(t,{children:[e.jsx(t,{width:24,children:e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","↑","/k"]}),e.jsx(r,{dimColor:!0,children:" Move up"})]})}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","↓","/j"]}),e.jsx(r,{dimColor:!0,children:" Move down"})]})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","Tab"]}),e.jsx(r,{dimColor:!0,children:" Switch panel"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","→","/","←"]}),e.jsx(r,{dimColor:!0,children:" Focus detail/list"})]})]}),e.jsxs(t,{flexDirection:"column",marginBottom:1,children:[e.jsxs(t,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"SELECTION"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","Space"]}),e.jsx(r,{dimColor:!0,children:" Toggle check on package"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","a"]}),e.jsx(r,{dimColor:!0,children:" Toggle check all"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","s"]}),e.jsx(r,{dimColor:!0,children:" Cycle sort (default / name / type / severity)"})]})]}),e.jsxs(t,{flexDirection:"column",marginBottom:1,children:[e.jsxs(t,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"FILTERS"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","←→"]}),e.jsx(r,{dimColor:!0,children:" Switch filter tab"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","/"]}),e.jsx(r,{dimColor:!0,children:" Text filter"})]}),s.length>0&&e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","f"]}),e.jsx(r,{dimColor:!0,children:" View filtered-out packages"})]})]}),e.jsxs(t,{flexDirection:"column",children:[e.jsxs(t,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),!d&&e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","u"]}),e.jsx(r,{dimColor:!0,children:" Apply selected updates"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","q"]}),e.jsx(r,{dimColor:!0,children:" Quit"})]}),e.jsxs(r,{children:[e.jsxs(r,{bold:!0,color:"white",children:[" ","?"]}),e.jsx(r,{dimColor:!0,children:" Toggle help"})]})]})]}),Y=h.getCheckedEntries(),q=Y.filter(o=>o.updateType==="major").length,ue=e.jsxs(t,{alignItems:"center",flexDirection:"column",children:[q>0&&e.jsx(t,{marginBottom:1,marginTop:1,children:e.jsxs(r,{color:"yellow",children:["⚠"," ",q," ","major update",q===1?"":"s"," ","— review breaking changes"]})}),e.jsxs(r,{dimColor:!0,children:["Press"," ",e.jsx(r,{bold:!0,color:"white",children:"u"})," ","or"," ",e.jsx(r,{bold:!0,color:"white",children:"Enter"})," ","to confirm,"," ",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","to cancel"]})]}),le=e.jsx(z,{footer:ue,scrollRef:E,title:`Apply ${Y.length} update${Y.length===1?"":"s"}?`,visible:N,width:70,children:Y.map(o=>e.jsxs(t,{gap:1,children:[e.jsxs(r,{children:[" ",o.displayName??o.packageName]}),e.jsxs(r,{dimColor:!0,children:[o.currentRange," ","→"," ",o.newRange]}),e.jsx(r,{bold:!0,color:o.updateType==="major"?"red":o.updateType==="minor"?"yellow":"green",children:o.updateType})]},o.packageName))}),te=s.length>0?e.jsx(z,{footer:e.jsxs(r,{dimColor:!0,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(r,{bold:!0,color:"white",children:"f"}),"/",e.jsx(r,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:B,title:`${s.length} PACKAGE${s.length===1?"":"S"} FILTERED BY TARGET`,visible:R,width:70,children:e.jsxs(t,{flexDirection:"column",children:[e.jsx(t,{marginBottom:1,children:e.jsxs(r,{dimColor:!0,children:["These packages have newer versions available but are excluded by the current target constraint. Use"," ",e.jsx(r,{bold:!0,color:"white",children:"--target latest"})," ","to include them."]})}),s.map(o=>e.jsxs(t,{gap:1,children:[e.jsxs(r,{children:[" ",o.packageName]}),e.jsxs(r,{dimColor:!0,children:[o.currentRange," ","→"," ",o.newRange]}),e.jsx(r,{bold:!0,color:o.updateType==="major"?"red":o.updateType==="minor"?"yellow":"green",children:o.updateType})]},o.packageName))]})}):null,se=e.jsx(De,{checkedEntries:c.checkedEntries,entries:C,filterActive:c.filterActive,filteredOutCount:s.length,filterText:c.filterText,filterType:c.filterType,focused:c.focusedPanel==="list",groupedByCatalog:c.groupedByCatalog,isDryRun:d,onViewportHeightChange:u,scrollOffset:V,selectedIndex:c.selectedIndex,totalCatalogEntries:f,totalChecked:i,totalEntries:C.length,viewportHeight:S}),ie=e.jsx(Ae,{changelogUrl:O,entry:T,focused:c.focusedPanel==="detail",recommendation:F,scrollRef:m});if(X){const o=Math.floor(g*.35);return e.jsxs(t,{flexDirection:"column",height:j,width:g,children:[e.jsxs(t,{flexDirection:"row",flexGrow:1,children:[e.jsx(t,{flexGrow:1,children:se}),e.jsx(t,{width:o,children:ie})]}),ee,le,te,e.jsx(ce,{autoExitSeconds:a||3,onCancel:()=>{D(!1)},visible:b}),re]})}const ge=Math.floor(j*.55);return e.jsxs(t,{flexDirection:"column",height:j,width:g,children:[e.jsx(t,{height:ge,children:se}),e.jsx(t,{flexGrow:1,children:ie}),ee,le,te,e.jsx(ce,{autoExitSeconds:a||3,onCancel:()=>{D(!1)},visible:b}),re]})};export{_e as C,Ke as U,Ye as V,J as e};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{createRequire as Pt}from"node:module";import{b as de,u as Tt,c as W,h as Rt,i as Ce,d as Bt,a as zt,l as Wt,e as Se}from"./package-version-cRcuUsLC.js";let jt;const Ut=t=>(jt??=Pt(import.meta.url))(t),oe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Vt=t=>{if(typeof oe<"u"&&oe.versions&&oe.versions.node){const[e,n]=oe.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return oe.getBuiltinModule(t)}return Ut(t)},{createRequire:Dt}=Vt("node:module"),Ft=16,ge=32,qt=64,T=128,ue="positionals";let ne=class extends Error{loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:o,message:i,name:s,stack:l,title:r}){super(i,{cause:e}),this.title=r,this.name=s,this.stack=l??this.stack,this.loc=o,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}},N=class extends ne{code;context;constructor(e,n,o){super({message:e,name:"CerebroError"}),this.code=n,this.context=o}},Gt=class extends N{argument;choices;value;constructor(e,n,o){super(`Invalid value "${n}" for argument "${e}". Allowed values: ${o.join(", ")}`,"INVALID_CHOICE",{argument:e,choices:o,value:n}),this.name="InvalidArgumentChoiceError",this.argument=e,this.value=n,this.choices=o,this.hint=`Pass one of: ${o.join(", ")}`}},Ht=class extends N{commandName;missingArguments;constructor(e,n){super(`Command "${e}" is missing required arguments: ${n.join(", ")}`,"MISSING_ARGUMENT",{commandName:e,missingArguments:n}),this.name="MissingArgumentError",this.commandName=e,this.missingArguments=n,this.hint=`Provide the following positional arguments: ${n.join(", ")}`}},Jt=class extends N{commandName;surplusArguments;constructor(e,n,o){super(`Command "${e}" accepts ${String(o)} positional argument${o===1?"":"s"}, but got ${String(n.length)} extra: ${n.join(", ")}`,"SURPLUS_ARGUMENT",{commandName:e,surplusArguments:[...n]}),this.name="SurplusArgumentError",this.commandName=e,this.surplusArguments=n,this.hint=`Remove the extra argument${n.length===1?"":"s"}, or declare a trailing "multiple: true" argument to collect them.`}};const it=String.raw,Le=it`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Kt=()=>new RegExp(it`\p{RI}{2}|(?)${Le}(?:\u200D${Le})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const gi=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,wi=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,F=Kt(),Zt=/[-_./\s]+/g,he=/(\u001B\[[0-9;]*[a-z])/i,Me=new RegExp("\\p{Script=Arabic}","u"),Yt=new RegExp("\\p{Script=Bengali}","u"),X=new RegExp("\\p{Script=Cyrillic}","u"),Qt=new RegExp("\\p{Script=Devanagari}","u"),Xt=new RegExp("\\p{Script=Ethiopic}","u"),we=new RegExp("\\p{Script=Greek}","u"),Pe=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),en=new RegExp("\\p{Script=Gujarati}","u"),tn=new RegExp("\\p{Script=Gurmukhi}","u"),je=new RegExp("\\p{Script=Hangul}","u"),Ue=new RegExp("\\p{Script=Hebrew}","u"),nn=new RegExp("\\p{Script=Hiragana}","u"),Ve=new RegExp("\\p{Script=Han}","u"),on=new RegExp("\\p{Script=Kannada}","u"),sn=new RegExp("\\p{Script=Katakana}","u"),rn=new RegExp("\\p{Script=Khmer}","u"),an=new RegExp("\\p{Script=Lao}","u"),L=new RegExp("\\p{Script=Latin}","u"),cn=new RegExp("\\p{Script=Malayalam}","u"),ln=new RegExp("\\p{Script=Myanmar}","u"),un=new RegExp("\\p{Script=Oriya}","u"),hn=new RegExp("\\p{Script=Sinhala}","u"),pn=new RegExp("\\p{Script=Tamil}","u"),dn=new RegExp("\\p{Script=Telugu}","u"),fn=new RegExp("\\p{Script=Thai}","u"),mn=new RegExp("\\p{Script=Tibetan}","u"),De=/[\u02BB\u02BC\u0027]/u,gn=t=>t.replace(F,""),R=new Uint32Array(65536),wn=(t,e)=>{const n=t.length,o=e.length,i=1<<n-1;let s=-1,l=0,r=n,u=n;for(;u--;)R[t.charCodeAt(u)]|=1<<u;for(u=0;u<o;u++){let a=R[e.charCodeAt(u)];const c=a|l;a|=(a&s)+s^s,l|=~(a|s),s&=a,l&i&&r++,s&i&&r--,l=l<<1|1,s=s<<1|~(c|l),l&=c}for(u=n;u--;)R[t.charCodeAt(u)]=0;return r},vn=(t,e)=>{const n=e.length,o=t.length,i=[],s=[],l=Math.ceil(n/32),r=Math.ceil(o/32);for(let p=0;p<l;p++)s[p]=-1,i[p]=0;let u=0;for(;u<r-1;u++){let p=0,w=-1;const $=u*32,m=Math.min(32,o)+$;for(let y=$;y<m;y++)R[t.charCodeAt(y)]|=1<<y;for(let y=0;y<n;y++){const A=R[e.charCodeAt(y)],k=s[y/32|0]>>>y&1,C=i[y/32|0]>>>y&1,U=A|p,_=((A|C)&w)+w^w|A|C;let g=p|~(_|w),v=w&_;g>>>31^k&&(s[y/32|0]^=1<<y),v>>>31^C&&(i[y/32|0]^=1<<y),g=g<<1|k,v=v<<1|C,w=v|~(U|g),p=g&U}for(let y=$;y<m;y++)R[t.charCodeAt(y)]=0}let a=0,c=-1;const d=u*32,h=Math.min(32,o-d)+d;for(let p=d;p<h;p++)R[t.charCodeAt(p)]|=1<<p;let f=o;for(let p=0;p<n;p++){const w=R[e.charCodeAt(p)],$=s[p/32|0]>>>p&1,m=i[p/32|0]>>>p&1,y=w|a,A=((w|m)&c)+c^c|w|m;let k=a|~(A|c),C=c&A;f+=k>>>o-1&1,f-=C>>>o-1&1,k>>>31^$&&(s[p/32|0]^=1<<p),C>>>31^m&&(i[p/32|0]^=1<<p),k=k<<1|$,C=C<<1|m,c=C|~(y|k),a=k&y}for(let p=d;p<h;p++)R[t.charCodeAt(p)]=0;return f},yn=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?wn(t,e):vn(t,e)};let $n;const xn=t=>($n??=Dt(import.meta.url))(t),se=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,An=t=>{if(typeof se<"u"&&se.versions&&se.versions.node){const[e,n]=se.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return se.getBuiltinModule(t)}return xn(t)},{writeFile:bn,stat:Nn,rm:Cn,readFile:Te,readdir:kn,mkdir:En,access:On}=An("node:fs/promises"),ae=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];let G=class extends N{commandName;constructor(e,n=[]){const o=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(o,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}};class rt extends N{option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}}class _n extends N{unknownOptions;constructor(e,n){const o=e.join(", "),i=`Found unknown ${e.length===1?"option":"options"}: ${o}`;super(i,"UNKNOWN_OPTION",{suggestions:n,unknownOptions:e}),this.name="UnknownOptionError",this.unknownOptions=e,n&&n.length>0&&(this.hint=`Did you mean: ${n.join(", ")}?`)}}class In extends N{pluginName;constructor(e,n,o){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:o,pluginName:e}),this.name="PluginError",this.pluginName=e,o&&(this.cause=o)}}class Sn{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);de().CEREBRO_OUTPUT_LEVEL===String(T)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const o of n)if(typeof o.init=="function"){this.logger.debug(`initializing plugin: ${o.name}`);try{await o.init(e)}catch(i){const s=new In(o.name,`Failed to initialize: ${i instanceof Error?i.message:String(i)}`,i instanceof Error?i:void 0);throw this.logger.error(s.message),s}}this.initialized=!0}async executeLifecycle(e,n,o){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const i=this.getDependencyOrder();for(const s of i){const l=s[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${s.name}`);try{await(e==="afterCommand"?l(n,o):l(n))}catch(r){throw this.logger.error(`Error in ${e} hook for plugin "${s.name}":`,r),r}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const o=this.getDependencyOrder();for(const i of o)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(e,n)}catch(s){this.logger.error(`Error in error handler for plugin "${i.name}":`,s)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,o=new Set,i=s=>{if(n.has(s))return;if(o.has(s))throw new Error(`Circular dependency detected involving plugin "${s}"`);const l=this.plugins.get(s);if(!l)throw new Error(`Plugin "${s}" not found`);if(o.add(s),l.dependencies)for(const r of l.dependencies)i(r);o.delete(s),n.add(s),e.push(l)};for(const s of this.plugins.keys())i(s);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}}const ie=t=>t.type?.name==="Boolean",Ln=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},Re=t=>(ie(t)||(t.typeLabel=t.typeLabel??Ln(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),Mn=new RegExp(/^-([^\d-])$/),Pn=new RegExp(/^--(\S+)/),jn=new RegExp(/^-([^\d-]{2,})$/),Un=t=>Mn.test(t)||Pn.test(t)||jn.test(t),Vn=(t,e)=>{const n=e[0]&&Un(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${String(n)}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}};let Dn=class at extends ne{optionName;value;constructor(e,n,o){super({hint:`Pass a valid ${o} value for '${e}'.`,message:`Invalid ${o} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,at.prototype)}},Tn=class ct extends ne{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,ct.prototype)}},Be=class lt extends ne{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,lt.prototype)}},Rn=class ut extends ne{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,ut.prototype)}},M=class ht extends ne{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,ht.prototype)}};const K=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",ke=t=>t===Number||typeof t=="function"&&t.name==="Number",ze=t=>t===String||typeof t=="function"&&t.name==="String",We=(t,e,n)=>{const o=Number(t);if(e&&Number.isNaN(o)&&String(t).trim().toLowerCase()!=="nan")throw new Dn(n??"",String(t),"Number");return o},Bn=(t,e,n={})=>{const{optionName:o,strictTypes:i}=n;return Array.isArray(t)?K(e)?t.map(Boolean):ke(e)?t.map(s=>We(s,i,o)):ze(e)?t.map(String):t.map(s=>e(String(s))):t===null?null:K(e)?!!t:ke(e)?We(t,i,o):ze(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},O=(t,e,n,...o)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...o)},zn=/-([a-z])/g,Wn=/^\d+$/,Fn=t=>t.codePointAt(0)===95,Fe=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],qe=t=>t==="__proto__"||t==="constructor"||t==="prototype",ve=(t,e,n,o=!1)=>{t[e]===void 0?t[e]=o?[n]:n:o&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},Ge=(t,e,n,o,i)=>{let s=e.get(t)??n.get(t);if(!s&&o){const l=t.toLowerCase();s=o.get(l)??i?.get(l)}return s},qn=(t,e,n,o)=>{const i=n.debug??!1;O(i,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),O(i,"Starting argument resolution","resolver"),O(i,"Tokens:","resolver",t),O(i,"Definitions:","resolver",e),O(i,"Processing tokens...","resolver");const s=new Map,l=new Map,r=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,a=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const g of e)if(s.set(g.name,g),g.alias&&l.set(g.alias,g),n.caseInsensitive&&r&&(r.set(g.name.toLowerCase(),g),g.alias&&u&&u.set(g.alias.toLowerCase(),g)),n.camelCase&&a&&c){const v=g.name.replaceAll(zn,(x,I)=>I.toUpperCase());a.set(g.name,v),c.set(v,g.name)}const d=Object.create(null),h=Object.create(null),f=[],p=[],w=new Set;let $=!1;const m=e.find(g=>g.defaultOption),y=e.some(g=>g.group),A=e.find(g=>ke(g.type));for(let g=0;g<t.length;g++){const v=t[g];if(v.kind==="option-terminator"){d._unknown=o.slice(v.index),$=!0;break}if(v.kind==="option"&&v.name){let x=Ge(v.name,s,l,r,u);!x&&v.value===void 0&&A&&Wn.test(v.name)&&(x=A,v.value=v.name,v.name=A.name);let I=!1;if(!x&&n.negation&&v.value===void 0&&v.name.startsWith("no-")){const E=v.name.slice(3),j=Ge(E,s,l,r,u);j?.type&&K(j.type)&&(x=j,I=!0)}const b=x?x.name:v.name,S=x?.multiple,P=x?.lazyMultiple;if(Object.hasOwn(h,b)&&h[b]!==void 0&&!S&&!P&&!n.partial)throw new Tn(b);if(!x&&n.partial){const E=v.rawName??`--${v.name}${v.value!==void 0&&v.inlineValue?`=${v.value}`:""}`;f.push({index:v.index,value:E});continue}if(!x&&n.stopAtFirstUnknown){d._unknown=o.slice(v.index);break}if(!x&&!n.partial)throw new Be(v.name);if(v.value===void 0){const E=t[g+1],j=E?.kind==="option"&&!("name"in E)&&E.value!==void 0,V=E&&x&&!(x.type&&K(x.type))&&(E.kind==="positional"||j),Mt=x&&x.defaultOption&&!x.multiple&&!x.lazyMultiple;if(V&&(!x?.defaultOption||Mt))if(S){let D=g+1;const me=[];for(;D<t.length&&(t[D].kind==="positional"||t[D].kind==="option"&&!("name"in t[D])&&t[D].value!==void 0);)me.push(t[D].value),w.add(t[D].index),D++;h[b]=h[b]===void 0?me:Fe(h[b],me),g=D-1}else P?(ve(h,b,E.value,!0),w.add(E.index),g++):(h[b]=E.value,w.add(E.index),g++);else x?.type&&K(x.type)?ve(h,b,!I,S):(S||P)&&h[b]!==void 0?ve(h,b,null,!0):h[b]=S?[]:null}else{let{value:E}=v;if(x?.type&&K(x.type))switch(E){case"":{if(n.partial){const V=`${v.rawName??`--${v.name}`}${v.value?`=${v.value}`:""}`;p.push({index:v.index,value:V}),E=!0}else throw new Be(v.name);break}case"false":{E=!1;break}case"true":{E=!0;break}default:E=!0}const j=[E];if(S){let V=g+1;for(;V<t.length&&t[V].kind==="positional";)j.push(t[V].value),w.add(t[V].index),V++;g=V-1}h[b]===void 0?h[b]=S||P?j:E:S||P?h[b]=Fe(h[b],j):h[b]=E}}else if(v.kind==="positional"&&n.stopAtFirstUnknown&&!w.has(v.index)&&!m){O(i,`Found unconsumed positional token at index ${String(v.index)}, stopping processing`,"resolver"),d._unknown=o.slice(v.index);break}}for(const[g,v]of Object.entries(h)){const x=s.get(g);x&&(x.multiple||x.lazyMultiple)&&!Array.isArray(v)&&(h[g]=[v])}const k=g=>g.kind==="option"&&!s.has(g.name??"")&&!l.has(g.name??"")&&(!n.caseInsensitive||!r?.has(g.name?.toLowerCase()??"")&&!u?.has(g.name?.toLowerCase()??""));let C=-1,U=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!$&&(C=t.findIndex(g=>k(g)),C!==-1&&(U=t[C].index)),m){const g=[],v=[];for(const x of t)x.kind==="positional"&&!w.has(x.index)&&x.index<U&&(g.push(x.value),v.push(x));if(g.length>0){const x=h[m.name],I=m.multiple??m.lazyMultiple;x===void 0?I?(v.forEach(b=>w.add(b.index)),h[m.name]=g):(w.add(v[0].index),h[m.name]=g[0]):I&&(v.forEach(b=>w.add(b.index)),h[m.name]=Array.isArray(x)?[...g,...x]:[...g,x])}}if(!n.partial){for(const g of t)if(g.kind==="positional"&&!w.has(g.index))throw new Rn(o[g.index])}if(n.partial&&!n.stopAtFirstUnknown){const g=[...f];for(const v of p)g.push({index:v.index,value:v.value});for(const v of t)v.kind==="positional"&&!w.has(v.index)&&g.push({index:v.index,value:o[v.index]});g.length>0&&(g.sort((v,x)=>v.index-x.index),d._unknown=g.map(v=>v.value))}if(n.stopAtFirstUnknown&&!$){const g=t.findIndex(x=>x.kind==="positional"&&!w.has(x.index));let v=-1;if(C!==-1&&g!==-1?v=Math.min(C,g):C!==-1?v=C:g!==-1&&(v=g),v>=0){const x=t[v].index;d._unknown=o.slice(x)}}for(const[g,v]of Object.entries(h)){const x=n.camelCase?a?.get(g)??g:g,I=s.get(g);I?.type?d[x]=Bn(v,I.type,{optionName:I.name,strictTypes:n.strictTypes}):d[x]=v===void 0?null:v}for(const g of e){const v=n.camelCase?a?.get(g.name)??g.name:g.name;!(v in d)&&g.defaultValue!==void 0&&(g.multiple??g.lazyMultiple?d[v]=Array.isArray(g.defaultValue)?[...g.defaultValue]:[g.defaultValue]:d[v]=g.defaultValue)}if(y){const g={},v={},x={};for(const b of e)if(b.group){const S=Array.isArray(b.group)?b.group:[b.group];for(const P of S)qe(P)||(g[P]??={})}for(const b of Object.keys(d))if(!Fn(b)){v[b]=d[b];let S=b;n.camelCase&&(S=c?.get(b)??b);const P=s.get(S);if(P?.group){const E=Array.isArray(P.group)?P.group:[P.group];for(const j of E)qe(j)||g[j]&&(g[j][b]=d[b])}else x[b]=d[b]}const I={_all:v};for(const[b,S]of Object.entries(g))I[b]=S;Object.keys(x).length>0&&(I._none=x),d._unknown&&(I._unknown=d._unknown),Object.keys(d).forEach(b=>delete d[b]),Object.assign(d,I)}const _=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));return O(i,"Final parsed result:","resolver",_),_},pt="-",te=pt.codePointAt(0),Z="=",Gn=Z.codePointAt(0),Hn="--",Jn=pt,Kn="--",dt=t=>t.length>2&&t.startsWith(Kn),Zn=t=>dt(t)&&!t.includes(Z,3),Yn=t=>dt(t)&&t.includes(Z,3),Qn=t=>{if(t.length!==2||t.codePointAt(0)!==te||t.codePointAt(1)===te)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},Xn=t=>{if(t.length<=2||t.codePointAt(0)!==te||t.codePointAt(1)===te)return!1;const e=t.codePointAt(1);return!(e!==void 0&&e>=48&&e<=57)},eo=t=>{const e=[];let n=0,o=[],i=0,s=-1,l=0;for(;i<o.length||n<t.length;){let r;if(i<o.length?(r=o[i],i++):(r=t[n],n++),l>0?l--:s++,r===Hn){e.push({index:s,kind:"option-terminator"});const u=[...o.slice(i),...t.slice(n)],a=u.map((c,d)=>({index:s+d+1,kind:"positional",value:c}));e.push(...a),s+=u.length;break}if(Qn(r)){const u=r.charAt(1);e.push({index:s,kind:"option",name:u,rawName:r});continue}if(Xn(r)&&!r.includes(Z)){const u=[];let a="",c=!1;for(let d=1;d<r.length;d++){const h=r.charAt(d);c?a+=h:h.codePointAt(0)===Gn?c=!0:u.push(`${Jn}${h}`)}if(c)if(u.length>0){const d=u.pop();u.push(`${d}=${a}`)}else u.push(a);o=i<o.length?[...u,...o.slice(i)]:u,i=0,l=u.length;continue}if(Zn(r)){const u=r.slice(2);e.push({index:s,kind:"option",name:u,rawName:r});continue}if(Yn(r)){const u=r.indexOf(Z),a=r.slice(2,u),c=r.slice(u+1);e.push({index:s,inlineValue:!0,kind:"option",name:a,rawName:r,value:c});continue}if(r.length>2&&r.codePointAt(0)===te&&r.codePointAt(1)!==te&&r.includes(Z)){const u=r.indexOf(Z),a=r.charAt(1),c=r.slice(u+1);e.push({index:s,inlineValue:!0,kind:"option",name:a,rawName:r,value:c});continue}e.push({index:s,kind:"positional",value:r})}return e},to=/\d/,no=t=>typeof t=="function",oo=(t,e,n)=>{const o=n?.debug??!1;O(o,"Validating definitions:","validation",t,"caseInsensitive:",e);const i=new Set,s=new Set,l=new Set,r=new Set;let u=0;for(const a of t){if(O(o,"Checking definition:","validation",a),!a.name)throw O(o,"Validation failed: name is required","validation"),new M("Invalid option definition: name is required");if(typeof a.name!="string")throw new M("Invalid option definition: name must be a string");if(a.name.trim()==="")throw new M("Invalid option definition: name cannot be empty");const c=e?a.name.toLowerCase():"";if(i.has(a.name)||e&&l.has(c))throw new M(`Invalid option definition: duplicate name '${a.name}'`);if(s.has(a.name)||e&&r.has(c))throw new M(`Invalid option definition: name '${a.name}' conflicts with an existing alias`);if(i.add(a.name),e&&l.add(c),a.alias!==void 0){if(typeof a.alias!="string")throw new M("Invalid option definition: alias must be a string");if(a.alias.length!==1)throw new M("Invalid option definition: alias must be a single character");if(to.test(a.alias))throw new M("Invalid option definition: alias cannot be numeric");if(a.alias==="-")throw new M('Invalid option definition: alias cannot be "-"');const d=e?a.alias.toLowerCase():"";if(s.has(a.alias)||e&&r.has(d))throw new M(`Invalid option definition: duplicate alias '${a.alias}'`);if(i.has(a.alias)||e&&l.has(d))throw new M(`Invalid option definition: alias '${a.alias}' conflicts with an existing option name`);s.add(a.alias),e&&r.add(d)}if(a.defaultOption&&(u++,a.type!==void 0&&K(a.type)))throw new M("Invalid option definition: defaultOption cannot be Boolean type");if(a.type!==void 0&&!(a.type===Boolean||a.type===Number||a.type===String||typeof a.type=="function"&&no(a.type)))throw new M("Invalid option definition: invalid type")}if(u>1)throw O(o,"Validation failed: multiple defaultOptions not allowed","validation"),new M("Invalid option definition: multiple defaultOptions not allowed");O(o,"Validation completed successfully","validation")};function so(t,e={}){const n=e.debug??!1;O(n,"Starting command-line-args parsing","index"),O(n,"Options:","index",e);const o={...e};o.stopAtFirstUnknown&&(o.partial=!0);const i=Array.isArray(t)?t:[t];O(n,"Normalized definitions:","index",i),oo(i,o.caseInsensitive,n?o:void 0);let{argv:s}=o;s??=process.argv.slice(2),O(n,"Using argv:","index",s);let l=s;o.caseInsensitive&&(l=s.map(a=>{if(a.startsWith("--")){const c=a.indexOf("="),d=(c===-1?a.slice(2):a.slice(2,c)).toLowerCase();return c===-1?`--${d}`:`--${d}${a.slice(c)}`}if(a.startsWith("-")&&!a.startsWith("--")&&a.length>1){const c=a.indexOf("="),d=c===-1?a.slice(1):a.slice(1,c);if(!d)return a;const h=d.toLowerCase();return c===-1?`-${h}`:`-${h}${a.slice(c)}`}return a}));const r=eo(l.map(String));O(n,"Tokenized arguments:","index",r);const u=qn(r,i,o,s);return O(n,"Command-line-args parsing completed","index"),u}class io{result;argv;options;argument;args;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let ye=class extends N{commandName;constructor(e,n,o){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",o!==void 0&&(this.cause=o)}};const ro=/^-{1,2}(\w+)(=(.+))?$/,ft=(t,e,n,o)=>{const i=ro.exec(t);if(i===null)return{};const s=i[1];if(!s)return{};const l=n&&o?n.get(s)??o.get(s):e.find(r=>r.name===s||r.alias===s);return l!==void 0?{argName:l.name,argValue:i[3],option:l}:{}},He=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},ao=new Set(["0","1","false","true"]),co=(t,e,n,o)=>{if(e.length===0||t.length===0)return{};const i=(s,l)=>{const{argName:r,argValue:u,option:a}=ft(l,e,n,o),{lastOption:c}=s;return a&&ie(a)&&u&&r?s.partial[r]=He(u,a):s.lastName&&c&&ie(c)&&ao.has(l)&&(s.partial[s.lastName]=He(l,c)),{lastName:r,lastOption:a,partial:s.partial}};return t.reduce(i,{partial:{}}).partial},lo=new Set(["0","1","false","true"]),uo=(t,e,n,o)=>{if(e.length===0||t.length===0)return t;const i=(s,l)=>{const{argValue:r,option:u}=ft(l,e,n,o),{lastOption:a}=s;if(a&&ie(a)&&lo.has(l)){const{args:c}=s;return{args:c.slice(0,-1)}}return u&&ie(u)&&r?{args:s.args}:{args:[...s.args,l],lastOption:u}};return t.reduce(i,{args:[]}).args},ho=t=>{const e=new Map;for(const n of t){const o=e.get(n.name);o?e.set(n.name,{...o,...n}):e.set(n.name,n)}return[...e.values()]},po=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},fo=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return po(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},mo=/_./g,go=/^[A-Z]/,wo=t=>t.toLowerCase().replaceAll(mo,e=>e[1]?.toUpperCase()??e).replace(go,e=>e.toLowerCase()),vo=(t,e=de())=>{if(!t||t.length===0)return{};const n={};for(const o of t){const i=e[o.name],s=fo(o,i),l=s===void 0?o.defaultValue:s,r=wo(o.name);n[r]=l}return n},yo=/-([a-z])/g,mt=t=>t.replaceAll(yo,(e,n)=>n.toUpperCase()),Je=(t,e)=>t.type===void 0?e:t.type(e),$o=(t,e)=>{const{choices:n}=t;if(!n||n.length===0)return[];const o=[];for(const i of e)n.includes(i)||o.push({choices:n,name:t.name,value:i});return o},xo=(t,e)=>e&&t.defaultValue!==void 0&&!Array.isArray(t.defaultValue)?[t.defaultValue]:t.defaultValue,Ao=(t,e)=>{const n={},o=[],i=[],s=t.length-1;let l=0;for(const[r,u]of t.entries()){const a=mt(u.name),c=r===s&&u.multiple===!0,d=c?e.slice(r):e.slice(r,r+1);if(d.length===0){u.required===!0&&o.push(u.name),n[a]=xo(u,c);continue}i.push(...$o(u,d)),l=r+d.length,n[a]=c?d.map(h=>Je(u,h)):Je(u,d[0])}return{invalid:i,missing:o,resolved:n,surplus:e.slice(l)}},bo=t=>{const e=new Map,n=new Map;for(const o of t)if(e.set(o.name,o),o.alias){const i=Array.isArray(o.alias)?o.alias:[o.alias];for(const s of i)n.set(s,o)}return{optionMapByAlias:n,optionMapByName:e}},gt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new ye(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(o){throw new ye(t.name,o instanceof Error?o.message:String(o),o)}const n=e.default;if(typeof n!="function")throw new ye(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},No=(t,e,n,o,i)=>{const s=new io(t.name,t),{_all:l,_unknown:r,positionals:u}=e,a=Object.keys(n).length>0?{...l,...n}:l;ue in a&&delete a[ue],s.argument=u?.[ue]??[],s.args={},s.rawUnknown=[...r??[]];const c=Object.keys(o).length>0;return s.options=c?{...a,...o}:a,s.env=vo(t.env,i),s},Co=(t,e,n)=>{const o=t.options??[],i=o.length>0;let s=ho(i?[...o,...n]:n);if(s.length>0){for(const c of s)if(c.multiple&&c.lazyMultiple)throw new Error(`Argument "${c.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}const l=t.arguments!==void 0&&t.arguments.length>0;(t.argument||l)&&(s=[{defaultOption:!0,description:t.argument?.description,group:"positionals",multiple:!0,name:ue,type:t.argument?.type??String,typeLabel:t.argument?.typeLabel},...s]);let r,u;if(i){const{optionMapByAlias:c,optionMapByName:d}=bo(o);r=uo(e,o,d,c),u=co(e,o,d,c)}else r=e,u={};const a=so(s,{argv:r,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:s,booleanValues:u,parsedArgs:a}},$e=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await gt(t))(e),ko=(t,e)=>{if(!t.arguments||t.arguments.length===0)return;const n=e.rawUnknown.indexOf("--"),o=n===-1?[]:e.rawUnknown.slice(n+1),i=o.length===0?e.argument:e.argument.slice(0,Math.max(0,e.argument.length-o.length)),s=Ao(t.arguments,i);if(e.args=s.resolved,s.missing.length>0)throw new Ht(t.name,s.missing);const[l]=s.invalid;if(l)throw new Gt(l.name,l.value,l.choices);if(s.surplus.length>0)throw new Jt(t.name,s.surplus,t.arguments.length)};let Eo=class{capacity;cache;constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;const e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}has(t){return this.cache.has(t)}set(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const n=this.cache.keys().next().value;n!==void 0&&this.cache.delete(n)}this.cache.set(t,e)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}};const Oo=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),_o=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),Io=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(_o,"")},xe=new Eo(1e3),So=/[.*+?^${}()|[\]\\]/g,Lo=t=>{const e=t.join("");if(xe.has(e)){const i=xe.get(e);return i.lastIndex=0,i}const n=t.map(i=>i.replaceAll(So,String.raw`\$&`)).join("|"),o=new RegExp(n,"g");return xe.set(e,o),o},Mo=t=>{const e=[];let n=0,o;for(F.lastIndex=0;(o=F.exec(t))!==null;)o.index>n&&e.push(t.slice(n,o.index)),e.push(o[0]),n=F.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},Po=/[ČŠŽĐ]/i,wt=new Uint8Array(128),vt=new Uint8Array(128),yt=new Uint8Array(128);for(let t=0;t<128;t++)wt[t]=t>=65&&t<=90?1:0,vt[t]=t>=97&&t<=122?1:0,yt[t]=t>=48&&t<=57?1:0;const Ae=t=>wt[t],Ke=t=>vt[t],be=t=>yt[t],B=(t,e,n,o,i)=>{if(t.length===0)return[];let s=!1;const l=Object.values(e);for(const f of l)if(f(t[0])){s=!0;break}if(!s&&!n)return[t];const r=[...t],u=[];let a=r[0],c="other";const d=Object.entries(e);for(const f of d){const[p,w]=f;if(w(r[0])){c=p;break}}let h=n&&o?r[0]===r[0].toLocaleUpperCase(o):!1;for(let f=1;f<r.length;f++){const p=r[f];let w="other";for(const y of d){const[A,k]=y;if(k(p)){w=A;break}}const $=n&&o?p===p.toLocaleUpperCase(o):!1;let m=!1;i?m=i(c,w,h,$,p,f,r):(c!==w&&c!=="other"&&w!=="other"&&(m=!0),n&&w!=="other"&&!h&&$&&(m=!0)),m?(u.push(a),a=p):a+=p,c=w,n&&(h=$)}return a&&a.length>0&&u.push(a),u.length>0?u:[t]},jo=(t,e,n,o)=>{if(n.size===0)return e;for(const i of n)if(t.startsWith(i,e))return o.push(i),e+i.length;return e},$t=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const o=[],i=t.length;for(let s=1;s<i;s++){const l=jo(t,n,e,o);if(l!==n){n=l,s=n-1;continue}const r=t.codePointAt(s-1),u=t.codePointAt(s),a=r&&r<128&&Ae(r),c=u&&u<128&&Ae(u),d=r&&r<128&&Ke(r),h=r&&r<128&&be(r),f=u&&u<128&&be(u);if(d&&c){o.push(t.slice(n,s)),n=s;continue}if(h&&!f||!h&&f){o.push(t.slice(n,s)),n=s;continue}if(f&&!h){let p=!1,w=!1;if(s+1<i){const $=t.codePointAt(s+1);p=$&&$<128&&Ae($),w=$&&$<128&&be($)}if(!w&&p){o.push(t.slice(n,s),t.slice(s,s+1)),n=s+1;continue}}if(s+1<i){const p=t.codePointAt(s+1),w=p&&p<128&&Ke(p);if(a&&c&&w){const $=t.slice(n,s+1);e.has($)||(o.push(t.slice(n,s)),n=s)}}}return n<i&&o.push(t.slice(n)),o.filter(s=>s!=="")},xt=(t,e,n)=>{if(t.length===0)return[];const o=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!o&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const a=[...t],c=a.length,d=[];let h=a[0],f=a[0]===a[0].toLocaleUpperCase(e),p=f,w=f?0:-1;for(let $=1;$<c;$++){const m=a[$],y=m===m.toLocaleUpperCase(e);if(y===f)h+=m;else if(y)h&&h.length>0&&(d.push(h),h=m),p=!0,w=$;else{if(p&&$-w>1){const A=a[$-1],k=h.slice(0,-1);k&&k.length>0&&d.push(k),h=A+m}else h+=m;p=!1,w=-1}f=y}return h&&h.length>0&&d.push(h),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!X.test(t)&&!L.test(t))return[t];const a=[...t],c=a.length,d=[];let h=a[0];const f=a[0];let p;X.test(f)?p=1:L.test(f)?p=2:p=0;let w=f===f.toLocaleUpperCase(e);for(let m=1;m<c;m++){const y=a[m];let A;X.test(y)?A=1:L.test(y)?A=2:A=0;const k=y===y.toLocaleUpperCase(e);p!==A&&(p===1||p===2)&&(A===1||A===2)||A===p&&!w&&k?(d.push(h),h=y):h+=y,p=A,w=k}h&&h.length>0&&d.push(h);const $=[];for(let m=0;m<d.length;m++)m<d.length-1&&d[m].length===1&&L.test(d[m])&&X.test(d[m+1][0])?($.push(d[m]+d[m+1]),m+=1):$.push(d[m]);return $}if(e.startsWith("el")){if(!we.test(t)&&!L.test(t))return[t];const a=[];Pe.lastIndex=0;let c;for(;(c=Pe.exec(t))!==null;)a.push(c[0]);a.length===0&&a.push(t);const d=[];if(a.length===1){const h=a[0];if(!h||!we.test(h[0])||h.length===1)return[h??t]}for(const h of a){if(!h)continue;if(!we.test(h[0])||h.length===1){d.push(h);continue}const f=h.length;let p=h[0],w=h[0]===h[0].toLocaleUpperCase(e);for(let $=1;$<f;$++){const m=h[$],y=m===m.toLocaleUpperCase(e);!w&&y?(d.push(p),p=m):p+=m,w=y}p&&d.push(p)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const a=e.startsWith("ja"),c=a?{hiragana:h=>nn.test(h),kanji:h=>Ve.test(h),katakana:h=>sn.test(h),latin:h=>L.test(h)}:{hangul:h=>je.test(h),latin:h=>L.test(h)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(a){const h=B(t,c,!1,e,(p,w)=>p==="hiragana"&&w==="katakana"||p==="katakana"&&w==="hiragana"||p==="hiragana"&&w==="latin"||p==="katakana"&&w==="latin"||p==="kanji"&&w==="latin"||p==="latin"&&(w==="hiragana"||w==="katakana"||w==="kanji")),f=[];for(const p of h){const w=p;w.length===1&&d.has(w)&&f.length>0?f[f.length-1]=f.at(-1)+w:f.push(w)}return f.length>0?f:[t]}return B(t,c,!1,e,(h,f)=>h==="hangul"&&f==="latin"||h==="latin"&&f==="hangul")}if(e.startsWith("sl")){const a=[...t],c=a.length,d=[];let h=a[0],f=a[0]===a[0].toLocaleUpperCase(e);for(let p=1;p<c;p++){const w=a[p],$=w===w.toLocaleUpperCase(e),m=Po.test(w),y=p<c-1&&a[p+1]===a[p+1].toLocaleUpperCase(e);!f&&$||m&&y?(d.push(h),h=w,m&&y&&(d.push(h),h="")):h+=w,f=$}return h&&h.length>0&&d.push(h),d}if(e.startsWith("zh"))return B(t,{han:a=>Ve.test(a),latin:a=>L.test(a)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const a=c=>Ue.test(c)||Me.test(c);return B(t,{latin:c=>L.test(c),rtl:c=>a(c)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const a=c=>Qt.test(c)||Yt.test(c)||en.test(c)||tn.test(c)||on.test(c)||pn.test(c)||dn.test(c)||cn.test(c)||hn.test(c)||fn.test(c)||an.test(c)||mn.test(c)||ln.test(c)||Xt.test(c)||rn.test(c)||un.test(c);return B(t,{indic:c=>a(c),latin:c=>L.test(c)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return B(t,{cyrillic:a=>X.test(a),latin:a=>L.test(a)},!0,e);if(["ar","fa","he"].includes(e))return B(t,{latin:a=>L.test(a),rtl:a=>Ue.test(a)||Me.test(a)},!1,e);if(e.startsWith("ko"))return B(t,{hangul:a=>je.test(a),latin:a=>L.test(a)},!1,e);if(e.startsWith("uz")){if(!X.test(t)&&!L.test(t))return[t];const a=[...t],c=a.length,d=[];let h=a[0],f=a[0]===a[0].toLocaleUpperCase(e);for(let p=1;p<c;p++){const w=a[p],$=w===w.toLocaleUpperCase(e);if(De.test(w)||De.test(a[p-1])){h+=w;continue}!f&&$?(d.push(h),h=w):h+=w,f=$}return h&&h.length>0&&d.push(h),d}const i=[...t],s=i.length,l=[];let r=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(const a of n)if(t.startsWith(a)){l.push(a),r=i[a.length],u=r===r.toLocaleUpperCase(e);break}for(let a=1;a<s;a++){const c=i[a],d=c===c.toLocaleUpperCase(e);let h=0;for(const f of n)if(t.startsWith(f,a)){l.push(r,f),h=f.length,r="";const p=f.at(-1);p&&(u=p===p.toLocaleUpperCase(e));break}if(h>0){a+=h-1;continue}!u&&d?(l.push(r),r=c):r+=c,u=d}return r&&l.push(r),l},Uo=(t,e,n)=>{const o=[],i=he.test(t)?t.split(he).filter(Boolean):[t];for(const s of i){const l=s;if(he.test(l))o.push(l);else{F.lastIndex=0;const r=F.test(l)?Mo(l).filter(Boolean):[l];for(const u of r)if(F.lastIndex=0,F.test(u))o.push(u);else if(e){const a=e.toLowerCase().split("-")[0];o.push(...xt(u,a,n))}else o.push(...$t(u,n))}}return o},Vo=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:o=!1,knownAcronyms:i=[],locale:s,normalize:l=!1,separators:r,stripAnsi:u=!1,stripEmoji:a=!1}=e,c=new Set([...i].toSorted((m,y)=>y.length-m.length));let d=t;u&&(d=Io(d)),a&&(d=gn(d));let h;Array.isArray(r)?h=Lo(r):r instanceof RegExp?h=r:h=Zt;const f=[];let p=d;const w=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;p.length>0;){const m=w.exec(p);if(!m){p===".."?f.push(".."):p==="."?f.push("."):p.length>0&&f.push(p);break}const y=m.index,A=m[0],k=A.length,C=p.slice(0,y),U=p.slice(y+k);if(A.startsWith("../"))f.push(".."),p=p.slice(y+3);else if(A.startsWith("./"))f.push("."),p=p.slice(y+2);else if(y===0&&A==="..")f.push(".."),p=p.slice(2);else if(y===0&&A===".")f.push("."),p=p.slice(1);else{C.length>0&&f.push(C);let _=0;for(;(_=A.indexOf("../",_))!==-1;)f.push(".."),_+=3;for(_=0;(_=A.indexOf("./",_))!==-1;)(_===0||A[_-1]!==".")&&f.push("."),_+=2;let g=U;for(;g.startsWith("../");)f.push(".."),g=g.slice(3);for(;g.startsWith("./");)f.push("."),g=g.slice(2);if(g===".."){f.push("..");break}else if(g==="."){f.push(".");break}else p=g}w.lastIndex=0}if(f.length===0){const m=d.split(h).filter(Boolean);f.push(...m)}let $=[];for(const m of f)n||o?$.push(...Uo(m,s,c)):s?$.push(...xt(m,s,c)):$.push(...$t(m,c));return l&&($=$.map(m=>c.has(m)?m:s&&m===m.toLocaleUpperCase(s)?m[0]+m.slice(1).toLocaleLowerCase(s):m.toUpperCase()===m&&!c.has(m)?m.slice(0,1)+m.slice(1).toLowerCase():m)),$},Do=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),To=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const o=[];let i="",s="";for(let l=0;l<n;l++){const r=t[l];if(he.test(r)){i?(o.push(i+s+r),i="",s=""):(o.length>0&&o.push(e),i=r);continue}i?(s&&(s+=e),s+=r):(o.length>0&&o.push(e),o.push(r))}return o.join("")},ee=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return To(Vo(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(o=>{const i=o,s=i.toLowerCase();return n?(n=!1,Oo(s)):Do(s)}),"")};class Ro extends N{commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}}class Bo extends N{choices;option;value;constructor(e,n,o){super(`Invalid value "${n}" for option "${e}". Allowed values: ${o.join(", ")}`,"INVALID_CHOICE",{choices:o,option:e,value:n}),this.name="InvalidChoiceError",this.option=e,this.value=n,this.choices=o,this.hint=`Use one of: ${o.map(i=>`--${e} ${i}`).join(", ")}`}}const Ze=(t,e,n=!1)=>{const o=[],i=e._all??e;for(const s of t){if(!n&&!s.required)continue;const l=s.__camelCaseName__??s.name;if(i[l]===void 0){if(s.type?.name==="Boolean"){e[l]=!1;continue}o.push(s)}}return o},zo=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:yn(t,e)<=t.length/3,z=(t,e)=>{const n=t.toLowerCase();return e.filter(o=>zo(o.toLowerCase(),n))},Wo=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(o=>{const i=o.startsWith("--");let s=`Found unknown ${i?"option":"argument"} "${o}"`;if(i){const l=z(o.replace("--",""),(e.options??[]).map(r=>r.name));if(l.length>0){const[r,...u]=l.map(a=>`--${a}`);s+=u.length>0?`, did you mean ${r??""} or ${u.join(", ")}?`:`, did you mean ${r??""}?`}}n.push(s)}),n.length>0)throw new Error(n.join(`
|
|
2
|
+
`))},J=(t,e)=>new N(`Command "${t}" ${e}`,"INVALID_COMMAND",{commandName:t}),Fo=(t,e)=>{const n=new Set;for(const[o,i]of t.entries()){if(typeof i!="object"||i===null)throw J(e,`has a positional argument at index ${String(o)} that is not an object`);const{name:s}=i;if(typeof s!="string"||s.length===0)throw J(e,`has a positional argument at index ${String(o)} without a name`);const l=mt(s);if(n.has(l))throw J(e,`declares duplicate positional argument "${s}"`);n.add(l);const r=o===0?void 0:t[o-1];if(i.required===!0&&r!==void 0&&r.required!==!0)throw J(e,`declares required positional "${s}" after an optional one, which can never be satisfied`);if(i.multiple===!0&&o!==t.length-1)throw J(e,`declares a variadic positional "${s}" that is not the last one`)}},qo=(t,e,n)=>{const o=n.__requiredOptions__,i=o?Ze(o,e,!0):Ze(t,e,!1);if(i.length>0)throw new Ro(n.name,i.map(s=>s.name));e._unknown&&e._unknown.length>0&&!n.argument&&!n.arguments?.length&&Wo(e,n)},Go=(t,e,n)=>{const o=n.__conflictingOptions__??t.filter(i=>i.conflicts!==void 0);if(o.length>0){const i=o.find(s=>{const l=s.__camelCaseName__??ee(s.name);return Array.isArray(s.conflicts)?s.conflicts.some(r=>e[ee(r)]!==void 0)&&e[l]!==void 0:e[ee(s.conflicts)]!==void 0&&e[l]!==void 0});if(i)throw new rt(i.name,typeof i.conflicts=="string"?i.conflicts:i.conflicts?.[0]??"unknown")}},Ho=(t,e)=>{const n=e.options;if(n)for(const o of n){if(!o.choices||o.choices.length===0)continue;const i=o.__camelCaseName__??ee(o.name),s=t[i];if(s==null)continue;const l=Array.isArray(s)?s:[s];for(const r of l){const u=String(r);if(!o.choices.includes(u))throw new Bo(o.name,u,o.choices)}}},Jo=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const i of t.options){if(i.name){const s=e.get(i.name)??[];s.push(i),e.set(i.name,s)}if(typeof i.alias=="string"&&i.alias.length>0){const s=n.get(i.alias)??[];s.push(i),n.set(i.alias,s)}else if(Array.isArray(i.alias)){for(const s of i.alias)if(s.length>0){const l=n.get(s)??[];l.push(i),n.set(s,l)}}}const o=[];for(const[i,s]of e)s.length>1&&o.push(`Duplicate option name "${i}" in command "${t.name}": ${JSON.stringify(s)}`);for(const[i,s]of n)s.length>1&&o.push(`Duplicate option alias "-${i}" used by options ${s.map(l=>`"${l.name}"`).join(", ")} in command "${t.name}"`);if(o.length>0)throw new Error(o.join(`
|
|
3
|
+
`))},Ko=t=>{const{arguments:e}=t;if(e!==void 0){if(!Array.isArray(e))throw J(t.name,'must declare "arguments" as an array — slot order is significant, so a record cannot express it');if(t.argument!==void 0)throw J(t.name,'cannot define both "argument" and "arguments" — choose one');Fo(e,t.name)}},Zo=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let o;for(let i=1;i<=e.length;i+=1){const s=e[i-1];if(s===void 0||s.startsWith("-"))break;n.push(s);const l=n.join(" ");t.has(l)&&(o={commandPath:[...n],depth:i})}return o?{argv:e.slice(o.depth),commandPath:o.commandPath}:{argv:e,commandPath:void 0}},H=t=>t.join(" "),Ye=(t,e)=>e&&e.length>0?[...e,t]:[t],Qe=t=>t===void 0||Array.isArray(t)?t:Object.entries(t).map(([e,n])=>({...n,name:e})),Yo=t=>{const e=Qe(t.options),n=Qe(t.env);return e===t.options&&n===t.env?t:Object.assign(Object.create(Object.getPrototypeOf(t)),t,{env:n,options:e})},Qo=/^no-/,Xo=t=>{t.options?.forEach(e=>{e.__camelCaseName__=ee(e.name)})},es=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const o of t.options)e.add(o.name);const n=[];for(const o of t.options)if(o.name.startsWith("no-")){const i=o.name.replace(Qo,"");if(!e.has(i)){if(o.type!==Boolean)throw new Error(`Cannot add negated option "${o.name}" to command "${t.name}" because it is not a boolean.`);const s={...o,defaultValue:o.defaultValue===void 0?!0:!o.defaultValue,name:i};n.push(s),e.add(i)}}n.length>0&&t.options.push(...n)},ts=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,o=new Map;for(const s of e.options)if(s.name.startsWith("no-")){const l=ee(s.name);o.set(l,s)}const i=Object.keys(n).filter(s=>o.has(s));if(i.length!==0)for(const s of i){const l=s.charAt(2);if(!l)continue;const r=l.toLowerCase()+s.slice(3),u=o.get(s);u&&(u.__negated__=!0),n[r]=!n[s],Reflect.deleteProperty(n,s)}},ns=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const i of e.options)i.__camelCaseName__&&i.__negated__===void 0&&i.implies!==void 0&&n.set(i.__camelCaseName__,i);if(n.size===0)return;const{options:o}=t;for(const i of Object.keys(o)){const s=n.get(i);if(s?.implies){const{implies:l}=s;for(const[r,u]of Object.entries(l))o[r]===void 0&&(o[r]=u)}}},os=()=>!!process.versions.electron,ss=()=>os()&&!process.defaultApp,is=()=>ss()?0:1,rs=t=>t.slice(is()+1),as=" ",cs=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,o)=>n===e[o]),ls=t=>{if(typeof t=="string")return t.split(as);const e=Ce();return cs(t,e)?rs(t):t},us=t=>{const e=s=>{t.error(`Uncaught exception: ${s.message||s}`),s.stack&&t.error(s.stack),W(1)},n=(s,l)=>{if(s instanceof Error)t.error(`Promise rejection: ${s.message||s}`),s.stack&&t.error(s.stack);else{let r;if(typeof s=="string")r=s;else try{r=JSON.stringify(s)}catch{r=String(s)}t.error(`Promise rejection: ${r}`)}W(1)},o=Se("uncaughtException",e),i=Se("unhandledRejection",n);return()=>{o(),i()}},Xe=100,hs=/^[a-z][\w-]*$/i,Ee=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new N(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},et=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new N(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},ce=(t,e)=>{if(typeof t!="object"||t===null)throw new N(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},le=t=>{const e=Ee(t,"Command name");if(e.length>Xe)throw new N(`Command name is too long (maximum ${String(Xe)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new N(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!hs.test(e))throw new N(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},ps=1e6,ds=1e5,fs=new Set([`
|
|
4
|
+
`,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),ms=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArgumentLength??ps;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Argument is too long (maximum ${String(o)} characters)`);if(n.checkDangerousChars){for(const i of t)if(fs.has(i))throw new Error(`Argument contains dangerous character: ${i}`)}return n.trim?t.trim():t},tt=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArguments??ds;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Too many arguments (maximum ${String(o)})`);return t.map(i=>ms(i,n))},gs=/^-([^\d-])$/,ws=/^--(\S+)/,vs=/^-([^\d-]{2,})$/,Ne=t=>gs.test(t)||ws.test(t)||vs.test(t),ys={access:(t,e)=>On(t,e),mkdir:(t,e)=>En(t,e),readdir:t=>kn(t),readFile:(async(t,e)=>e===void 0?Te(t):Te(t,e)),rm:(t,e)=>Cn(t,e),stat:t=>Nn(t),writeFile:(t,e,n)=>bn(t,e,n)},$s=(t,e,n)=>{const o=e.indexOf("--"),i=o===-1?new Set:new Set(e.slice(o+1)),s=n.filter(u=>u.startsWith("--")&&u!=="--"&&!i.has(u));if(s.length===0)return;const l=(t.options??[]).map(u=>u.name),r=s.flatMap(u=>z(u.slice(2),l).map(a=>`--${a}`));throw new _n(s,r)};class Oe{#t;#e;#u;#p;#d;#f;#N;#C;#k;#$;#E;#x;#O;#A=ge;#h;#n;#o;#s;#i;#r;#_=!1;#I;#S=!1;#m;#g;#w;#c=[];#V(){return this.#m===void 0&&(this.#m=[...this.#o.keys()]),this.#m}#L(){return this.#g===void 0&&(this.#g=[...this.#n.keys()]),this.#g}#a(){return this.#w===void 0&&(this.#w=[...this.#V(),...this.#L()]),this.#w}#M(){return this.#c.length===0?ae:[...ae,...this.#c]}#P(){this.#m=void 0,this.#g=void 0,this.#w=void 0}#b(){if(this.#u===void 0){const e=ls(this.#e.argv);this.#u=tt(e,{maxArguments:this.#x}),this.#D()}return this.#u}#v(){return this.#$??de()}#y(e){this.#A=e,this.#v().CEREBRO_OUTPUT_LEVEL=String(e)}#l(){return this.#A}#D(){if(!this.#u)return;let e=!1;for(const n of this.#u){if(n==="--quiet"||n==="-q"){this.#y(Ft),e=!0;break}if(n==="--verbose"||n==="-v"){this.#y(qt),e=!0;break}if(n==="--debug"){this.#y(T),e=!0;break}}e||this.#y(Object.hasOwn(this.#v(),"DEBUG")?T:ge)}#T(){this.#S||(this.#I=us(this.#t),this.#S=!0)}#R(){return{arch:Rt(),argv:this.#b(),cwd:this.#p,env:this.#$??de(),exit:this.#k??(e=>W(e??0)),platform:Tt(),stdin:this.#E}}#j(e,n,o,i){this.#l()===T&&this.#t.debug(`command '${i}' found, parsing command args: ${n.join(", ")}`);const{arguments_:s,booleanValues:l,parsedArgs:r}=Co(e,n,this.#M()),u=Object.keys(l).length>0;let a=r;u&&(a={...r,_all:{...r._all,...l}}),qo(s,a,e);const c=No(e,r,l,o,this.#v());c.runtime=this,c.argv=this.#b(),c.fs=this.#C??ys,c.process=this.#R(),c.console=this.#t,ko(e,c);const d=e.options&&e.options.length>0;if(d&&e.options){const h=e.options.filter(f=>f.name.startsWith("no-"));for(const f of h){const p=f.name.slice(3),w=`--${f.name}`,$=`--${p}`,m=n.includes(w),y=n.includes($);if(m&&y)throw new rt(p,f.name)}}return d&&(ts(c,e),ns(c,e)),Go(s,c.options,e),Ho(c.options,e),this.#O&&$s(e,n,c.rawUnknown),this.#l()===T&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(c.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(c.argument,null,2))),{arguments_:s,booleanValues:l,commandArgs:a,parsedArgs:r,toolbox:c}}async#U(e,n,o){const i=this.getPluginManager();try{!this.#_&&i.hasPlugins()&&(await i.init({cli:this,cwd:this.#p,logger:this.#t}),this.#_=!0),await i.executeLifecycle("execute",n),await i.executeLifecycle("beforeCommand",n);let s;const l=o.global;if(l?.help){const r=this.#n.get("help");if(!r)throw new N("Help command not found","COMMAND_NOT_FOUND");s=await $e(r,n,o)}else if(l?.version??l?.V){const r=this.#n.get("version");if(!r)throw new N("Version command not found","COMMAND_NOT_FOUND");s=await $e(r,n,o)}else s=await $e(e,n,o);return await i.executeLifecycle("afterCommand",n,s),s}catch(s){throw await i.executeErrorHandlers(s,n),s}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new N("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#d=e.trim();const o=n.argv??Ce(),i=n.cwd??Bt();if(this.#e={...n,argv:o,cwd:i},this.#e.argv&&!Array.isArray(this.#e.argv))throw new N("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new N("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new N("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new N("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const d=["debug","error","info","log","warn"],h=[],f=this.#e.logger;for(const p of d)typeof f[p]!="function"&&h.push(p);if(h.length>0)throw new N(`Logger object is missing required methods: ${h.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:h});this.#t=this.#e.logger}else this.#t={...console,debug:(...d)=>{this.#l()===T&&console.debug(...d)}};this.#f=this.#e.packageVersion,this.#N=this.#e.packageName,this.#p=this.#e.cwd,this.#i="help",this.#r={};const s=n.fs;if(s!==void 0&&(typeof s!="object"||s===null))throw new N("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new N("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const r=n.env;if(r!==void 0&&(typeof r!="object"||r===null))throw new N("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new N("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#C=n.fs,this.#k=n.exit,this.#$=n.env,this.#E=n.stdin??"",this.#x=n.maxArguments,this.#O=n.strictOptions??!1;const a=this.#v().CEREBRO_OUTPUT_LEVEL,c=a===void 0?Number.NaN:Number(a);this.#A=Number.isNaN(c)?ge:c,this.#n=new Map,this.#o=new Map,this.#s=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#d}${this.#f?` v${this.#f}`:""}`),this.#r}setDefaultCommand(e){return this.#i=e,this}get defaultCommand(){return this.#i}addCommand(e){ce(e,"Command"),le(e.name),e.options!==void 0&&ce(e.options,"Command options"),e.env!==void 0&&ce(e.env,"Command env"),Ko(e);const n=Yo(e),o=typeof n.execute=="function",i=typeof n.loader=="function";if(o&&i)throw new N(`Command "${n.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:n.name});if(!o&&!i)throw new N(`Command "${n.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:n.name});n.alias&&(typeof n.alias=="string"?le(n.alias):et(n.alias,"Command alias").forEach(c=>le(c))),n.argument&&ce(n.argument,"Command argument"),n.commandPath&&(et(n.commandPath,"Command commandPath"),n.commandPath.forEach(c=>{le(c)}));const s=Ye(n.name,n.commandPath),l=H(s);if(this.#o.has(l))throw new N(`Command with path "${l}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name,commandPath:n.commandPath});const r=Array.isArray(n.commandPath)&&n.commandPath.length>0,u=this.#n.get(n.name),a=u!==void 0&&(u.commandPath===void 0||u.commandPath.length===0);if(!r&&a)throw new N(`Command with name "${n.name}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name});if(n.options)for(const c of n.options)Re(c);if(Jo(n),es(n),Xo(n),n.options&&(n.__conflictingOptions__=n.options.filter(c=>c.conflicts!==void 0),n.__requiredOptions__=n.options.filter(c=>c.required===!0)),r&&u!==void 0)this.#n.set(l,n);else{if(!r&&u!==void 0&&!a){const c=Ye(u.name,u.commandPath);this.#n.set(H(c),u)}this.#n.set(n.name,n)}if(this.#o.set(l,s),this.#s.set(l,n),this.#P(),n.alias!==void 0){const c=typeof n.alias=="string"?[n.alias]:n.alias;for(const d of c){if(this.#l()===T&&this.#t.debug("adding alias",d),this.#n.has(d))throw new N(`Command alias "${d}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:d,commandName:n.name});this.#n.set(d,n)}}return this}addGlobalOption(e){const n=e,o=new Set(ae.map(s=>s.name)),i=new Set(ae.map(s=>s.alias).filter(Boolean));if(o.has(n.name))throw new N(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&i.has(n.alias))throw new N(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#c.map(s=>s.name)).has(n.name))throw new N(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",Re(n),this.#c.push(n),this}getGlobalOptions(){return this.#M()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#h?this.#h:(this.#h=new Sn(this.#t),this.#h.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#h)}getCliName(){return this.#d}getPackageVersion(){return this.#f}getPackageName(){return this.#N}getCommands(){return this.#n}getCwd(){return this.#p}dispose(){this.#I?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:o=!0,...i}=e;if(!this.#n.has("help")){const{default:m}=await import("../packem_chunks/help-command.js");this.addCommand(new m(this.#n))}const s=this.#L(),l=this.#o;this.#T();const r=this.#b();let u,a=[...r];this.#l()===T&&(this.#t.debug(`process.execPath: ${zt()}`),this.#t.debug(`process.execArgv: ${Wt().join(" ")}`),this.#t.debug(`process.argv: ${Ce().join(" ")}`));const c=Zo(l,[...r]);if(c.commandPath)u=c.commandPath,a=c.argv;else{if(r.length>1&&r[0]&&r[1]&&!Ne(r[0])&&!Ne(r[1])){const y=[];let A=0;for(;A<r.length;){const C=r[A];if(!C||Ne(C))break;y.push(C),A+=1}const k=H(y);if(y[0]&&!s.includes(y[0])){const C=this.#a(),U=z(k,C);throw new G(k,U)}}let m;try{m=Vn([null,...s],[...r])}catch(y){if(y instanceof Error&&y.name==="INVALID_COMMAND"&&"command"in y){const A=y.command,k=this.#a(),C=z(A,k);throw new G(A,C)}throw y}m.command&&(u=[m.command],a=m.argv)}if(!u)if(this.#i)u=[this.#i];else{const m=this.#a();throw new G("",m)}const d=H(u),h=this.#o.get(d);let f;if(h){if(f=this.#s.get(d),!f||H(h)!==d){const m=this.#a(),y=z(d,m);throw new G(d,y)}}else{const m=u.at(-1);if(f=m?this.#n.get(m):void 0,!f){const y=this.#a(),A=z(d,y);throw new G(d,A)}}if(typeof f.execute!="function"&&typeof f.loader!="function")return this.#t.error(`Command "${f.name}" has no function to execute.`),o?W(1):void 0;const p=a;let w,$;try{({commandArgs:w,toolbox:$}=this.#j(f,p,i,d))}catch(m){if(this.#t.error(m),o)return W(1);throw m}try{return await this.#U(f,$,w),o?W(0):void 0}catch(m){if(o)return this.#t.error(m),W(1);throw m}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:o=[],...i}=n;Ee(e,"Command name");const s=e.split(" ").filter(Boolean),l=H(s),r=this.#o.get(l)?this.#s.get(l):this.#n.get(e);if(!r){const d=this.#a(),h=z(l||e,d);throw new G(e,h)}if(typeof r.execute!="function"&&typeof r.loader!="function")throw new N(`Command "${r.name}" has no function to execute`,"INVALID_COMMAND",{commandName:r.name});const u=[...tt(o,{maxArguments:this.#x})];this.#l()===T&&this.#t.debug(`running command '${e}' programmatically with args: ${u.join(", ")}`);const{commandArgs:a,toolbox:c}=this.#j(r,u,i,l||e);return this.#U(r,c,a)}clone(e){const n={...this.#e,...e},o=new Oe(this.#d,n);for(const[i,s]of this.#n)o.#n.set(i,s);for(const[i,s]of this.#o)o.#o.set(i,[...s]);for(const[i,s]of this.#s)o.#s.set(i,s);for(const i of this.#c)o.#c.push(i);return o.#i=this.#i,o.#r={...this.#r},o.#P(),o}async getAction(e){Ee(e,"Command name");const n=e.split(" ").filter(Boolean),o=H(n),i=this.#o.get(o)?this.#s.get(o):this.#n.get(e);if(!i){const s=this.#a(),l=z(o||e,s);throw new G(e,l)}if(typeof i.execute=="function")return i.execute;if(typeof i.loader=="function")return gt(i);throw new N(`Command "${i.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:i.name})}}const xs=t=>t,$i=(t,e)=>new Oe(t,e),As=globalThis.process??Object.create(null),nt={versions:{}},re=new Proxy(As,{get(t,e){if(e in t)return t[e];if(e in nt)return nt[e]}}),bs=t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
5
|
+
`),Ns=(t,e,n,o)=>{const i={column:0,line:-1,...t.start},s={...i,...t.end},l=i.line,r=i.column,u=s.line,a=s.column;let c=Math.max(l-(n+1),0),d=Math.min(e.length,u+o);l===-1&&(c=0),u===-1&&(d=e.length);const h=u-l,f={};if(h)for(let p=0;p<=h;p++){const w=p+l;if(!r)f[w]=!0;else if(p===0){const $=e[w-1]?.length;f[w]=[r,($??0)-r+1]}else if(p===h)f[w]=[0,a];else{const $=e[w-p]?.length;f[w]=[0,$]}}else r===a?f[l]=r?[r,0]:!0:f[l]=[r,(a??0)-(r??0)];return{end:d,markerLines:f,start:c}},Cs=re.platform==="win32"&&!re.env?.WT_SESSION?">":"❯",ks=(t,e,n)=>{const o={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...n,color:{gutter:p=>p,marker:p=>p,message:p=>p,...n?.color}},i=typeof e.start.column=="number";let s=(t.includes("\r")?bs(t):t).split(`
|
|
6
|
+
`);typeof o.tabWidth=="number"&&t.includes(" ")&&(s=s.map(p=>p.replaceAll(" "," ".repeat(o.tabWidth))));const{end:l,markerLines:r,start:u}=Ns(e,s,o.linesAbove,o.linesBelow),a=String(l).length,{gutter:c,marker:d,message:h}=o.color;let f=s.slice(u,l).map((p,w)=>{const $=u+1+w,m=r[$],y=String($).padStart(a),A=!r[$+1],k=` ${y}${o.showGutter?" |":""}`;if(m){let C="";if(Array.isArray(m)){const U=p.replaceAll(/[^\t]/g," ").slice(0,Math.max(m[0]-1,0)),_=m[1]||1;C=[`
|
|
7
|
+
`,o.prefix+c(k.replaceAll(/\d/g," "))," ",U,d("^").repeat(_)].join(""),A&&o.message&&(C+=` ${h(o.message)}`)}return[o.prefix+d(Cs),c(k),p.length>0?` ${p}`:"",C].join("")}return`${o.prefix} ${c(k)}${p.length>0?` ${p}`:""}`}).join(`
|
|
8
|
+
`);return o.message&&!i&&(f=`${o.prefix+" ".repeat(a+1)+o.message}
|
|
9
|
+
${f}`),f},fe=t=>{let e;return()=>{if(e===void 0){if(typeof re.getBuiltinModule!="function")throw new TypeError(`[@visulima/error] Cannot load ${t}: this runtime implements no process.getBuiltinModule(). Requires Node ^22.14.0 || >=24.10.0, or another runtime providing process.getBuiltinModule().`);e=re.getBuiltinModule(t)}return e}},Es=()=>re.env?.DEBUG==="true",Y=(t,...e)=>{if(Es()){const n=e.map(o=>typeof o=="function"?o():o);console.debug(`error:parse-stacktrace: ${t}`,...n)}},Q="<unknown>",Os=/^(?:node:internal\/|node:|internal\/)/,_s=t=>t!==void 0&&Os.test(t),Is=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ss=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,Ls=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,Ms=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,Ps=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,js=/in\s(.*)\s\(at\s(.+)\)\sat/,Us=/^(?:.*@)?(.*):(\d+):(\d+)$/,Vs=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ds=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ts=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,ot=/\(error: ([^)]*)\)/,Rs=/at\s/,Bs=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,zs=/Error: |AggregateError:/,At=/^Anonymous function$/,Ws=/^\s*in\s.*/,Fs=/^.*?\s*at\s.*/,qs=/^.*?\s*@.*|\[native code\]/,bt=(t,e)=>{const n=t.includes("safari-extension"),o=t.includes("safari-web-extension");return n||o?[t.includes("@")?t.split("@")[0]:Q,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]},Nt=(t,e)=>{const n=Ls.exec(e);n&&(t.file=n[1],t.line=+n[2],t.column=+n[3])},Gs=t=>{const e=js.exec(t);if(e){Y(`parse nested node error stack line: "${t}"`,()=>`found: ${JSON.stringify(e)}`);const o=e[2].split(":");return{column:o[2]?+o[2]:void 0,file:o[0],line:o[1]?+o[1]:void 0,methodName:e[1]??Q,raw:t,type:void 0}}const n=Ps.exec(t);if(n){Y(`parse node error stack line: "${t}"`,()=>`found: ${JSON.stringify(n)}`);const o={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(Rs,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]??Q,raw:t,type:t.startsWith("internal")?"internal":void 0};return Nt(o,`${n[2]}:${n[3]}:${n[4]}`),o}},Hs=t=>{const e=Is.exec(t);if(e){Y(`parse chrome error stack line: "${t}"`,()=>`found: ${JSON.stringify(e)}`);const n=e[2]?.startsWith("native"),o=e[2]?.startsWith("eval")||e[1]?.startsWith("eval");let i,s;if(o){const a=Ss.exec(t);if(a){const c=Bs.exec(a[1]);c?(e[2]=c[4]??c[1],e[3]=c[5]??c[2],e[4]=c[3]):a[2]&&(e[2]=a[1]),a[2]&&(i={column:a[4]?+a[4]:void 0,file:a[2],line:a[3]?+a[3]:void 0,methodName:"eval",raw:t,type:"eval"})}else{const c=Ms.exec(t);c&&(s={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0},i={column:c[6]?+c[6]:void 0,file:c[1],line:c[5]?+c[5]:void 0,methodName:"eval",raw:c[0],type:"eval"})}}const[l,r]=bt(e[1]?e[1].replace(At,"<anonymous>"):Q,e[2]),u={column:e[4]?+e[4]:void 0,evalOrigin:i,file:r,line:e[3]?+e[3]:void 0,methodName:l,raw:t,type:o?"eval":n?"native":_s(r)?"internal":void 0};return s?(u.column=s.column,u.file=s.file,u.line=s.line):Nt(u,`${r}:${e[3]}:${e[4]}`),u}},Js=(t,e)=>{const n=Vs.exec(t);if(n){Y(`parse gecko error stack line: "${t}"`,()=>`found: ${JSON.stringify(n)}`);const o=n[3]?.includes(" > eval"),i=o&&n[3]&&Ds.exec(n[3]);let s;o&&i&&(n[3]=i[1],s={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:t,type:"eval"},n[4]=i[2]);const[l,r]=bt(n[1]?n[1].replace(At,"<anonymous>"):Q,n[3]);let u;(e?.type==="safari"||!o&&e?.type==="firefox")&&e.column?u=e.column:!o&&n[5]&&(u=+n[5]);let a;return(e?.type==="safari"||!o&&e?.type==="firefox")&&e.line?a=e.line:n[4]&&(a=+n[4]),{column:u,evalOrigin:s,file:r,line:a,methodName:l,raw:t,type:o?"eval":r.includes("[native code]")?"native":void 0}}},Ks=(t,e)=>{const n=Ts.exec(t);if(!(n&&n[2].includes(" > eval"))&&n)return Y(`parse firefox error stack line: "${t}"`,()=>`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:e?.column??void 0,file:n[2],line:n[3]?+n[3]:e?.line??void 0,methodName:n[1]||Q,raw:t,type:void 0}},Zs=t=>{const e=Us.exec(t);if(e)return Y(`parse react android native error stack line: "${t}"`,()=>`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:Q,raw:t,type:void 0}},Ct=(t,{filter:e,frameLimit:n=50}={})=>{const o=t;let i=(typeof o.stacktrace=="string"?o.stacktrace:t.stack??"").split(`
|
|
10
|
+
`).map(s=>(ot.test(s)?s.replace(ot,"$1"):s).trim()).filter(s=>!zs.test(s)&&s!=="eval code");return e&&(i=i.filter(s=>e(s))),i=i.slice(0,n),i.reduce((s,l,r)=>{if(!l||l.length>1024)return s;let u;if(Ws.test(l))u=Gs(l);else if(Fs.test(l))u=Hs(l);else if(qs.test(l)){let a;if(r===0){const c=t,d=c.columnNumber,h=c.lineNumber,f=c.line,p=c.column;d||h?a={column:d,line:h,type:"firefox"}:(f||p)&&(a={column:p,line:f,type:"safari"})}u=Ks(l,a)??Js(l,a)}else u=Zs(l);return u?s.push(u):Y(`parse error stack line: "${l}"`,"not parser found"),s},[])},st=fe("node:fs"),pe=fe("node:path"),Ys=fe("node:process"),Qs=fe("node:url"),q=(t,e,n)=>n===0?t:e===" "?t+" ".repeat(n):t+" ".repeat(e*n),kt=t=>t.replaceAll("\\","/"),Xs=t=>{if(!t.startsWith("file:"))return t;try{return Qs().fileURLToPath(t)}catch{return t}},ei=(t,e)=>{const n=t.replace("async file:","file:");return kt(pe().relative(e,Xs(n)))},ti=(t,e,n)=>{if(e)return n.title(t.message);const o=t.message?`: ${t.message}`:"";return n.title(t.name+o)},Et=(t,{color:e,hideErrorTitle:n,indentation:o,prefix:i},s)=>`${q(i,o,s)}${ti(t,n,e)}
|
|
11
|
+
`,Ot=(t,{color:e,indentation:n,prefix:o},i)=>{if(t.hint===void 0)return;const s=q(o,n,i);let l="";if(Array.isArray(t.hint))for(const r of t.hint)l+=`${s+r}
|
|
12
|
+
`;else l+=s+t.hint;return e.hint(l)},_e=(t,e)=>{if(!e||t.file===void 0||t.line===void 0)return{trace:t};try{const n=e({column:t.column,file:t.file,line:t.line});return n?{source:n.source,trace:{...t,column:n.column??t.column,file:n.file??t.file,line:n.line??t.line}}:{trace:t}}catch{return{trace:t}}},Ie=(t,e,n=0)=>{const{color:o,cwd:i,displayShortPath:s,indentation:l,prefix:r}=e,{trace:u}=t;let a;u.file===void 0?a="<unknown>":a=s?ei(u.file,i):kt(u.file);const{fileLine:c,method:d}=o;return`${q(r,l,n)}at ${u.methodName?`${d(u.methodName)} `:""}${c(a)}:${c(u.line?.toString()??"")}`},ni=(t,e)=>{if(e.allowAllFilePaths)return!0;const n=pe().resolve(e.cwd),o=pe().resolve(n,t);return o===n||o.startsWith(n+pe().sep)},oi=t=>{try{return st().existsSync(t)?st().readFileSync(t,"utf8"):void 0}catch{return}},_t=(t,e,n)=>{const{color:o,indentation:i,linesAbove:s,linesBelow:l,prefix:r,showGutter:u,showLineNumbers:a,tabWidth:c}=e,{source:d,trace:h}=t;if(h.file===void 0)return;let f;if(d===void 0){const p=h.file.replace("file://","");if(!ni(p,e))return;const w=oi(p);if(w===void 0)return;f=w}else f=d;return ks(f,{start:{column:h.column,line:h.line}},{color:o,linesAbove:s,linesBelow:l,prefix:q(r,i,n),showGutter:u,showLineNumbers:a,tabWidth:c})},It=(t,e,n)=>{if(t.errors.length===0)return;let o=`${q(e.prefix,e.indentation,n)}Errors:
|
|
13
|
+
|
|
14
|
+
`,i=!0;for(const s of t.errors)i?i=!1:o+=`
|
|
15
|
+
|
|
16
|
+
`,o+=Lt(s,{...e,framesMaxLimit:1,hideErrorCodeView:e.hideErrorErrorsCodeView},n+1);return`
|
|
17
|
+
${o}`},si=t=>{if(typeof t=="object"&&t!==null)try{return JSON.stringify(t)}catch{return Object.prototype.toString.call(t)}return String(t)},St=(t,e,n,o=new Set)=>{o.add(t);let i=`${q(e.prefix,e.indentation,n)}Caused by:
|
|
18
|
+
|
|
19
|
+
`;const{cause:s}=t;if(!(s instanceof Error)){const u=si(s);return i+=`${q(e.prefix,e.indentation,n)}${e.color.title(u)}
|
|
20
|
+
`,`
|
|
21
|
+
${i}`}i+=Et(s,e,n);const l=Ct(s).shift(),r=Ot(s,e,n);if(r&&(i+=`${r}
|
|
22
|
+
`),l){const u=_e(l,e.sourceMap);if(i+=Ie(u,e,n),!e.hideErrorCauseCodeView){const a=_t(u,e,n);a!==void 0&&(i+=`
|
|
23
|
+
${a}`)}}if(s instanceof AggregateError){const u=It(s,e,n);u!==void 0&&(i+=`
|
|
24
|
+
${u}`)}return s.cause&&(i+=o.has(s)?`
|
|
25
|
+
${q(e.prefix,e.indentation,n+1)}Caused by: [Circular]`:`
|
|
26
|
+
${St(s,e,n+1,o)}`),`
|
|
27
|
+
${i}`},ii=(t,e)=>(t.length>0?`
|
|
28
|
+
`:"")+t.map(n=>Ie(_e(n,e.sourceMap),e)).join(`
|
|
29
|
+
`),Lt=(t,e,n)=>{const o={allowAllFilePaths:!1,cwd:Ys().cwd(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...e,color:{fileLine:r=>r,gutter:r=>r,hint:r=>r,marker:r=>r,message:r=>r,method:r=>r,title:r=>r,...e.color}},i=Ct(t,{filter:e.filterStacktrace,frameLimit:o.framesMaxLimit}),s=i.shift(),l=s?_e(s,o.sourceMap):void 0;return[e.hideMessage?void 0:Et(t,o,n),Ot(t,o,n),l?Ie(l,o,n):void 0,l&&!o.hideErrorCodeView?_t(l,o,n):void 0,t instanceof AggregateError?It(t,o,n):void 0,t.cause===void 0||t.cause===null?void 0:St(t,o,n),i.length>0?ii(i,o):void 0].filter(Boolean).join(`
|
|
30
|
+
`)},ri=(t,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return Lt(t,e,0)},xi=(t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:o,runtime:i}=n,{concise:s,detailed:l=!1,exitOnError:r=!0,formatter:u,logErrors:a=!0,renderOptions:c={}}=t;if(a)if(u)o.error(u(e));else if(!l&&s?.(e))o.error(e.message);else if(l){const d=i.getCwd(),h=ri(e,{cwd:d,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...c});o.error(h)}else o.error(e);r&&W(1)},version:"1.0.0"}),Ai=async t=>{try{await t.run({shouldExitProcess:!1})}catch{process.exitCode=process.exitCode||1}finally{process.exit(process.exitCode??0)}},ai={info:{description:"Always show the first-run info panel (size, security score, permissions, changelog), even for an approved package",type:Boolean},"no-info":{defaultValue:!1,description:"Disable the first-run info panel entirely (also via VIS_DLX_NO_INFO)",type:Boolean},offline:{defaultValue:!1,description:"Resolve from local store only — fail rather than fetch from the registry. Pair with `vis install` for hardened npx-style workflows.",type:Boolean},package:{alias:"p",description:"Additional packages to install (repeatable)",multiple:!0,type:String},"shell-mode":{alias:"c",defaultValue:!1,description:"Execute within shell environment",type:Boolean},silent:{alias:"s",defaultValue:!1,description:"Suppress output except command results",type:Boolean},yes:{alias:"y",defaultValue:!1,description:"Skip the first-run info panel and confirmation prompt (also via VIS_DLX_YES — note this auto-approves every package)",type:Boolean}},bi=xs({argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"],["vis install && vis dlx --offline typescript tsc --version","Hardened: pre-install + offline (no registry fetch on dlx)"],["vis dlx --info create-vite","Always show the first-run panel (size, score, permissions, changelog)"],["vis dlx --yes create-vite my-app","Skip the first-run panel and confirmation"]],group:"Run & Execute",loader:()=>import("../packem_chunks/handler66.js"),name:"dlx",options:ai});class ci extends Error{isVisUserError=!0;constructor(e,n){super(e,n),this.name="VisUserError"}}const Ni=t=>t instanceof ci||t instanceof Error&&t.isVisUserError===!0;export{ci as V,$i as a,xs as b,wi as c,bi as d,F as e,Ni as i,N as n,Ai as r,gi as u,xi as w};
|