@visulima/vis 2.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE.md +95 -65
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/packem_chunks/CONFIG_FILES.js +2 -2
  6. package/dist/packem_chunks/bloom-status.js +1 -1
  7. package/dist/packem_chunks/bloom-sync.js +1 -1
  8. package/dist/packem_chunks/catalog.js +47 -47
  9. package/dist/packem_chunks/cli-exec.js +1 -1
  10. package/dist/packem_chunks/cli-main.js +141 -141
  11. package/dist/packem_chunks/dispatch.js +1 -1
  12. package/dist/packem_chunks/fix.js +1 -1
  13. package/dist/packem_chunks/handler.js +1 -1
  14. package/dist/packem_chunks/handler10.js +1 -1
  15. package/dist/packem_chunks/handler11.js +1 -1
  16. package/dist/packem_chunks/handler12.js +1 -1
  17. package/dist/packem_chunks/handler13.js +1 -1
  18. package/dist/packem_chunks/handler14.js +1 -1
  19. package/dist/packem_chunks/handler15.js +1 -1
  20. package/dist/packem_chunks/handler16.js +1 -1
  21. package/dist/packem_chunks/handler17.js +1 -1
  22. package/dist/packem_chunks/handler18.js +1 -1
  23. package/dist/packem_chunks/handler19.js +1 -1
  24. package/dist/packem_chunks/handler2.js +1 -1
  25. package/dist/packem_chunks/handler20.js +1 -1
  26. package/dist/packem_chunks/handler21.js +1 -1
  27. package/dist/packem_chunks/handler22.js +1 -1
  28. package/dist/packem_chunks/handler23.js +1 -1
  29. package/dist/packem_chunks/handler24.js +1 -1
  30. package/dist/packem_chunks/handler26.js +1 -1
  31. package/dist/packem_chunks/handler27.js +1 -1
  32. package/dist/packem_chunks/handler28.js +1 -1
  33. package/dist/packem_chunks/handler29.js +1 -1
  34. package/dist/packem_chunks/handler3.js +1 -1
  35. package/dist/packem_chunks/handler30.js +1 -1
  36. package/dist/packem_chunks/handler4.js +1 -1
  37. package/dist/packem_chunks/handler5.js +1 -1
  38. package/dist/packem_chunks/handler50.js +1 -1
  39. package/dist/packem_chunks/handler51.js +1 -1
  40. package/dist/packem_chunks/handler53.js +1 -1
  41. package/dist/packem_chunks/handler54.js +1 -1
  42. package/dist/packem_chunks/handler55.js +1 -1
  43. package/dist/packem_chunks/handler58.js +1 -1
  44. package/dist/packem_chunks/handler59.js +1 -1
  45. package/dist/packem_chunks/handler6.js +1 -1
  46. package/dist/packem_chunks/handler60.js +1 -1
  47. package/dist/packem_chunks/handler61.js +1 -1
  48. package/dist/packem_chunks/handler62.js +1 -1
  49. package/dist/packem_chunks/handler63.js +1 -1
  50. package/dist/packem_chunks/handler64.js +1 -1
  51. package/dist/packem_chunks/handler66.js +1 -1
  52. package/dist/packem_chunks/handler67.js +13 -13
  53. package/dist/packem_chunks/handler68.js +1 -1
  54. package/dist/packem_chunks/handler69.js +1 -1
  55. package/dist/packem_chunks/handler7.js +1 -1
  56. package/dist/packem_chunks/handler70.js +5 -5
  57. package/dist/packem_chunks/handler71.js +1 -1
  58. package/dist/packem_chunks/handler72.js +1 -1
  59. package/dist/packem_chunks/handler73.js +1 -1
  60. package/dist/packem_chunks/handler74.js +15 -15
  61. package/dist/packem_chunks/handler75.js +1 -1
  62. package/dist/packem_chunks/handler76.js +1 -1
  63. package/dist/packem_chunks/handler77.js +1 -1
  64. package/dist/packem_chunks/handler78.js +1 -1
  65. package/dist/packem_chunks/handler8.js +1 -1
  66. package/dist/packem_chunks/handler9.js +1 -1
  67. package/dist/packem_chunks/heal-accept.js +1 -1
  68. package/dist/packem_chunks/heal.js +1 -1
  69. package/dist/packem_chunks/help-command.js +1 -1
  70. package/dist/packem_chunks/index2.js +6 -4
  71. package/dist/packem_chunks/index3.js +1 -1
  72. package/dist/packem_chunks/index4.js +49 -49
  73. package/dist/packem_chunks/keys-refresh.js +1 -1
  74. package/dist/packem_chunks/lean.js +1 -1
  75. package/dist/packem_chunks/list.js +1 -1
  76. package/dist/packem_chunks/loader.js +1 -1
  77. package/dist/packem_chunks/orchestrator.js +2 -2
  78. package/dist/packem_chunks/prune.js +1 -1
  79. package/dist/packem_chunks/registry.js +10 -10
  80. package/dist/packem_chunks/status.js +1 -1
  81. package/dist/packem_chunks/sync.js +1 -1
  82. package/dist/packem_chunks/sync2.js +1 -1
  83. package/dist/packem_chunks/tripwire.js +1 -1
  84. package/dist/packem_chunks/ts-loader.js +1 -1
  85. package/dist/packem_chunks/verify-lockfile.js +1 -1
  86. package/dist/packem_shared/{advisories-CCBGdU8U.js → advisories-DsXRmIA5.js} +1 -1
  87. package/dist/packem_shared/{affected-selection-Dj-ymxhw.js → affected-selection-BE6VFCDV.js} +1 -1
  88. package/dist/packem_shared/{affected-shas-PwkVbPch.js → affected-shas-BKEu4RZc.js} +1 -1
  89. package/dist/packem_shared/{ai-analysis-bGCAc1jR.js → ai-analysis-DikAj6rX.js} +1 -1
  90. package/dist/packem_shared/{ai-fix-DV5-dHBY.js → ai-fix-bfWo0cZX.js} +1 -1
  91. package/dist/packem_shared/{augment-24KX2nkI.js → augment-BkJxi_GW.js} +1 -1
  92. package/dist/packem_shared/{bin-CtzhnYMp.js → bin-B-TytgzW.js} +1 -1
  93. package/dist/packem_shared/{build-scripts-w4SNeR7D.js → build-scripts-DWypBQ--.js} +1 -1
  94. package/dist/packem_shared/{command-runtime-BLFPUYAT.js → command-runtime-DQ7ZpLYL.js} +1 -1
  95. package/dist/packem_shared/{cyclonedx-C4KaVTn1.js → cyclonedx-DLBi65MV.js} +1 -1
  96. package/dist/packem_shared/dependency-scan-ZLOuLkGN.js +1 -0
  97. package/dist/packem_shared/{docker-DaVs-9wK.js → docker-B4zAZCZG.js} +15 -15
  98. package/dist/packem_shared/{en-D3CfXlO7.js → en-BDYMmM2_.js} +1 -1
  99. package/dist/packem_shared/{failure-log-CTneNcio.js → failure-log-DyhWPqno.js} +1 -1
  100. package/dist/packem_shared/glob-BUjyjdE8-Dp_QcayW.js +1 -0
  101. package/dist/packem_shared/index-BLtnel38.js +35 -0
  102. package/dist/packem_shared/index-CuKDxOCI.js +1 -0
  103. package/dist/packem_shared/index-tNFGWxc0.js +39 -0
  104. package/dist/packem_shared/{lifecycle-B8A2T3gx.js → lifecycle-KY9umOg6.js} +1 -1
  105. package/dist/packem_shared/{lockfile-Bccery3L.js → lockfile-YAuZf1gh.js} +1 -1
  106. package/dist/packem_shared/{manifests-BDkwiVbh.js → manifests-BwTn_1ad.js} +1 -1
  107. package/dist/packem_shared/{min-release-age-OaYpLwux.js → min-release-age-6avfn81h.js} +1 -1
  108. package/dist/packem_shared/{missing-package-json-BqS-OnKd.js → missing-package-json-Cl0vdz6K.js} +1 -1
  109. package/dist/packem_shared/{native-config-sync-Ds1FtcrM.js → native-config-sync-CHMCJx7H.js} +7 -7
  110. package/dist/packem_shared/{osv-bloom-pKp7urSB.js → osv-bloom-DdqDnLCt.js} +2 -2
  111. package/dist/packem_shared/package-version-BNRJ3o9C.js +4 -0
  112. package/dist/packem_shared/{packument-HBVbyf7x.js → packument-B9-WqReu.js} +1 -1
  113. package/dist/packem_shared/{pm-runner-C6eTANt1.js → pm-runner-DRybtzOV.js} +1 -1
  114. package/dist/packem_shared/{project-name-filter-CJ3XX2TI.js → project-name-filter-Dw0fC6IO.js} +1 -1
  115. package/dist/packem_shared/{provenance-D4Cza8cp.js → provenance-CLxuqCfL.js} +1 -1
  116. package/dist/packem_shared/{readJsonSync-DweZd5ZA-0eZh9sGm.js → readJsonSync-DweZd5ZA-CtrDlqpb.js} +1 -1
  117. package/dist/packem_shared/{registry-keys-C0ez2VND.js → registry-keys-cTN24144.js} +1 -1
  118. package/dist/packem_shared/{resolve-explicit-BbT764KS.js → resolve-explicit-Uw6WQl9R.js} +1 -1
  119. package/dist/packem_shared/{resolve-runtime-D_vZovbB.js → resolve-runtime-DztanwkZ.js} +1 -1
  120. package/dist/packem_shared/{run-file-DyPFFN9U.js → run-file-CaE5_xBY.js} +1 -1
  121. package/dist/packem_shared/{runtime-check-D4um-yQq.js → runtime-check-C32yE57I.js} +1 -1
  122. package/dist/packem_shared/{s1ngularity-St6dhKiq.js → s1ngularity-BIYhg82u.js} +1 -1
  123. package/dist/packem_shared/{scan-progress-q-N2JtIp.js → scan-progress-DWfY4zkp.js} +1 -1
  124. package/dist/packem_shared/{selectors-Ce_6UAoY.js → selectors-D2j4M9Ul.js} +1 -1
  125. package/dist/packem_shared/{signatures-Dyeyg1q9.js → signatures-C8iQ5fUq.js} +1 -1
  126. package/dist/packem_shared/target-merge-DLxJTcxn.js +11 -0
  127. package/dist/packem_shared/{target-options-7XcbqGDe.js → target-options-3t4-2F-F.js} +1 -1
  128. package/dist/packem_shared/{toolchain-C_pNMBM6.js → toolchain-BPzbahcQ.js} +1 -1
  129. package/dist/packem_shared/{typosquats-xzcAGPiM.js → typosquats-BWrmhh36.js} +1 -1
  130. package/dist/packem_shared/{use-measured-height-CBjN0fle.js → use-measured-height-BwAwGHjw.js} +1 -1
  131. package/dist/packem_shared/verify-CzUPT6Uk.js +1 -0
  132. package/dist/packem_shared/{vis-update-app-DMAC2pPf.js → vis-update-app-D6Wq8ZHM.js} +1 -1
  133. package/dist/packem_shared/{vis-user-error-xmha3L4n.js → vis-user-error-CfM4_ORo.js} +1 -1
  134. package/dist/packem_shared/{watch-BXOOX7lx.js → watch-D_oAxW_Z.js} +1 -1
  135. package/dist/packem_shared/{watch-loop-Q7UpkVbr.js → watch-loop-BrjblOz5.js} +1 -1
  136. package/dist/runtime/preload.js +1 -1
  137. package/index.d.ts +204 -204
  138. package/index.js +26 -26
  139. package/package.json +13 -13
  140. package/dist/packem_shared/dependency-scan-D_ona0Qm.js +0 -1
  141. package/dist/packem_shared/glob-BUjyjdE8-C4M8e02u.js +0 -1
  142. package/dist/packem_shared/index-CTMU29dI.js +0 -1
  143. package/dist/packem_shared/index-uBVnF4ji.js +0 -35
  144. package/dist/packem_shared/package-version-C47v64aB.js +0 -4
  145. package/dist/packem_shared/public-api-WqUCiyIe.js +0 -131
  146. package/dist/packem_shared/target-merge-Cfy7c__2.js +0 -11
  147. package/dist/packem_shared/verify-Dve9PQj3.js +0 -1
@@ -1 +1 @@
1
- import{l as e,m as l,i as r,r as g}from"../packem_chunks/catalog.js";import{I as ae,J as je,K as ge,M as ne}from"../packem_chunks/cli-main.js";import{Spinner as me}from"@visulima/tui-kit/spinner";import{Dialog as J}from"@visulima/tui-kit/dialog";import{ScrollView as fe}from"@visulima/tui-kit/scroll-view";import{B as ue}from"./en-D3CfXlO7.js";import{ScrollBar as ye}from"@visulima/tui-kit/scroll-bar";import{Tab as we}from"@visulima/tui-kit/tab";import{Tabs as Ce}from"@visulima/tui-kit/tabs";import{u as ke}from"./use-measured-height-CBjN0fle.js";const We=({current:a,total:t})=>{const{columns:i}=ae(),s=i||80,d=t>0?Math.min(1,a/t):0,h=`${String(Math.round(d*100)).padStart(3)}%`,f=`${String(a)}/${String(t)}`,y=Math.max(10,s-2-h.length-1),p=Math.round(y*d),j=y-p;return e.jsxs(l,{flexDirection:"column",paddingX:1,children:[e.jsxs(l,{children:[e.jsx(me,{type:"dots"}),e.jsx(r,{children:" Checking catalog dependencies "}),e.jsx(r,{dimColor:!0,children:f})]}),e.jsxs(l,{children:[e.jsx(r,{color:"cyan",children:"━".repeat(p)}),e.jsx(r,{dimColor:!0,children:"─".repeat(j)}),e.jsxs(r,{dimColor:!0,children:[" ",h]})]})]})},_=["default","name","updateType","severity"],ce=a=>{const t=a.vulnerabilities?.map(i=>i.severity)??[];return t.includes("CRITICAL")?4:t.includes("HIGH")?3:t.includes("MODERATE")?2:t.includes("LOW")?1:0},de={digest:0,major:3,minor:2,patch:1,pin:0,unknown:0},he=(a,t)=>{if(t==="default")return a;const i=[...a];return t==="name"?i.sort((s,d)=>s.packageName.localeCompare(d.packageName)):t==="updateType"?i.sort((s,d)=>(de[d.updateType]??0)-(de[s.updateType]??0)||s.packageName.localeCompare(d.packageName)):i.sort((s,d)=>ce(d)-ce(s)||s.packageName.localeCompare(d.packageName)),i},Z=a=>`${a.ecosystem}|${a.file}:${String(a.line)}|${a.name}`,A=a=>`${a.catalogName} ${a.packageName}`,Y=a=>{const t=new Map;for(const i of a){const s=t.get(i.catalogName);s?s.push(i):t.set(i.catalogName,[i])}return t},G=(a,t,i)=>{let s=a;if(t!=="all"&&(s=t==="security"?s.filter(d=>d.vulnerabilities&&d.vulnerabilities.length>0||d.socketReport&&d.socketReport.alerts.length>0):s.filter(d=>d.updateType===t)),i){const d=i.toLowerCase();s=s.filter(h=>h.packageName.toLowerCase().includes(d))}return s};class ze{#e;#l=new Set;#t;#s;#i=null;constructor(t,i=null,s=[]){this.#t=t,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=>Z(d))),checkedEntries:new Set(t.map(d=>A(d))),ecosystemEntries:s,entries:t,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",groupedByCatalog:Y(t),phase:"browsing",selectedIndex:0,sortMode:"default"}}getSnapshot=()=>this.#e;subscribe=t=>(this.#l.add(t),()=>{this.#l.delete(t)});getFilteredEntries(){return he(G(this.#t,this.#e.filterType,this.#e.filterText),this.#e.sortMode)}setSortMode(t){if(t===this.#e.sortMode)return;const i=this.getFilteredEntries()[this.#e.selectedIndex]?.packageName,s=he(G(this.#t,this.#e.filterType,this.#e.filterText),t),d=i?Math.max(0,s.findIndex(h=>h.packageName===i)):0;this.#r({...this.#e,selectedIndex:d,sortMode:t})}cycleSortMode(){const t=_.indexOf(this.#e.sortMode),i=_[(t+1)%_.length]??"default";this.setSortMode(i)}getRecommendation(t){return this.#i?.get(t)}getCheckedEntries(){return this.#t.filter(t=>this.#e.checkedEntries.has(A(t)))}getCheckedEcosystemEntries(){return this.#s.filter(t=>this.#e.checkedEcosystemKeys.has(Z(t)))}toggleEcosystemCheck(t){const i=new Set(this.#e.checkedEcosystemKeys);i.has(t)?i.delete(t):i.add(t),this.#r({...this.#e,checkedEcosystemKeys:i})}checkAllEcosystem(){this.#r({...this.#e,checkedEcosystemKeys:new Set(this.#s.map(t=>Z(t)))})}uncheckAllEcosystem(){this.#r({...this.#e,checkedEcosystemKeys:new Set})}setSelectedIndex(t){const i=this.getFilteredEntries(),s=Math.max(0,Math.min(t,i.length-1));s!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:s})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:t})}setFilterType(t){if(t!==this.#e.filterType){const i=G(this.#t,t,this.#e.filterText);this.#r({...this.#e,entries:i,filterType:t,groupedByCatalog:Y(i),selectedIndex:0})}}setFilter(t){const i=G(this.#t,this.#e.filterType,t);this.#r({...this.#e,entries:i,filterText:t,groupedByCatalog:Y(i),selectedIndex:0})}setFilterActive(t){if(t!==this.#e.filterActive)if(t)this.#r({...this.#e,filterActive:!0});else{const i=G(this.#t,this.#e.filterType,"");this.#r({...this.#e,entries:i,filterActive:!1,filterText:"",groupedByCatalog:Y(i),selectedIndex:0})}}toggleCheck(t){const i=A(t),s=new Set(this.#e.checkedEntries);s.has(i)?s.delete(i):s.add(i),this.#r({...this.#e,allChecked:s.size===this.#t.length,checkedEntries:s})}checkAll(){this.#r({...this.#e,allChecked:!0,checkedEntries:new Set(this.#t.map(t=>A(t)))})}uncheckAll(){this.#r({...this.#e,allChecked:!1,checkedEntries:new Set})}toggleAll(){this.#e.allChecked?this.uncheckAll():this.checkAll()}startApply(){const t=this.getCheckedEntries();this.#r({...this.#e,applyProgress:{current:0,total:t.length},phase:"applying"})}updateApplyProgress(t){this.#e.applyProgress&&this.#r({...this.#e,applyProgress:{...this.#e.applyProgress,current:t}})}markDone(){this.#r({...this.#e,phase:"done"})}setError(t){this.#r({...this.#e,error:t,phase:"error"})}#r(t){this.#e=t;for(const i of this.#l)try{i()}catch{}}}const be={major:"red",minor:"yellow",patch:"green"},Te={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},Se={critical:"red",high:"red",low:"gray",medium:"yellow"},Ee={critical:"red",high:"red",low:"green",medium:"yellow"},ve={defer:"gray",review:"yellow",skip:"red",update:"green"},Re=({changelogUrl:a,entry:t,focused:i,recommendation:s,scrollRef:d})=>{const h=i?"white":"gray";if(!t)return e.jsx(l,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:e.jsx(r,{dimColor:!0,children:"No package selected"})});const f=be[t.updateType]??"white",y=t.vulnerabilities&&t.vulnerabilities.length>0,p=t.socketReport?.score.overall??0,j=t.socketReport?ue(p):"gray";return e.jsxs(l,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsx(l,{flexShrink:0,paddingTop:1,paddingX:2,children:e.jsx(r,{bold:!0,color:"white",children:t.displayName??t.packageName})}),e.jsxs(fe,{flexGrow:1,flexShrink:1,paddingX:2,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[e.jsx(r,{}),e.jsxs(l,{children:[e.jsx(l,{width:12,children:e.jsx(r,{dimColor:!0,children:"Current:"})}),e.jsx(r,{children:t.currentRange})]}),e.jsxs(l,{children:[e.jsx(l,{width:12,children:e.jsx(r,{dimColor:!0,children:"Target:"})}),e.jsx(r,{children:t.newRange}),e.jsxs(r,{bold:!0,color:f,children:[" ","(",t.updateType,")"]})]}),e.jsxs(l,{children:[e.jsx(l,{width:12,children:e.jsx(r,{dimColor:!0,children:"Version:"})}),e.jsx(r,{children:t.targetVersion})]}),e.jsxs(l,{children:[e.jsx(l,{width:12,children:e.jsx(r,{dimColor:!0,children:t.kind==="ecosystem"?"Source:":"Catalog:"})}),e.jsx(r,{color:t.kind==="ecosystem"?"cyan":void 0,children:t.catalogName})]}),t.acceptedRisk&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{color:"gray",children:"── "}),e.jsx(r,{bold:!0,color:"gray",children:"ACKNOWLEDGED RISK"}),e.jsxs(l,{flexDirection:"column",paddingLeft:2,children:[e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Reason: "}),e.jsx(r,{children:t.acceptedRisk.reason})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Accepted: "}),e.jsx(r,{children:t.acceptedRisk.acceptedAt.slice(0,10)})]})]})]}),y&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"red",children:"SECURITY"}),e.jsx(r,{}),t.vulnerabilities.map(n=>e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{gap:1,children:[e.jsxs(r,{bold:!0,color:Te[n.severity]??"gray",children:["⚠"," ",n.severity]}),e.jsx(r,{bold:!0,children:n.id})]}),e.jsx(l,{paddingLeft:2,children:e.jsx(r,{children:n.summary})}),e.jsxs(l,{gap:2,paddingLeft:2,children:[n.cvssScore!==void 0&&e.jsxs(r,{dimColor:!0,children:["CVSS:",String(n.cvssScore)]}),n.fixedVersions.length>0&&e.jsxs(r,{dimColor:!0,children:["Fixed in:",n.fixedVersions.join(", ")]})]})]},n.id))]}),t.socketReport&&e.jsxs(l,{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(l,{gap:2,children:[e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Overall: "}),e.jsxs(r,{bold:!0,color:j,children:[String(Math.round(p*100)),"%"]})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Supply Chain: "}),e.jsxs(r,{children:[String(Math.round(t.socketReport.score.supplyChain*100)),"%"]})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Quality: "}),e.jsxs(r,{children:[String(Math.round(t.socketReport.score.quality*100)),"%"]})]})]}),e.jsxs(l,{gap:2,children:[e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Maintenance: "}),e.jsxs(r,{children:[String(Math.round(t.socketReport.score.maintenance*100)),"%"]})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Vulnerability: "}),e.jsxs(r,{children:[String(Math.round(t.socketReport.score.vulnerability*100)),"%"]})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"License: "}),e.jsxs(r,{children:[t.socketReport.license||"unknown"," ","(",String(Math.round(t.socketReport.score.license*100)),"%)"]})]})]}),t.socketReport.alerts.length>0&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(r,{bold:!0,color:"yellow",children:["⚠"," ",String(t.socketReport.alerts.length)," ","alert",t.socketReport.alerts.length===1?"":"s",":"]}),t.socketReport.alerts.map(n=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsxs(r,{bold:!0,color:Se[n.severity]??"gray",children:["[",n.severity.toUpperCase(),"]"]}),e.jsx(r,{children:n.type}),e.jsxs(r,{dimColor:!0,children:["(",n.category,")"]})]},n.key))]})]}),s&&e.jsxs(l,{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(l,{gap:2,children:[e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Action: "}),e.jsx(r,{bold:!0,color:ve[s.action]??"white",children:s.action})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Risk: "}),e.jsx(r,{bold:!0,color:Ee[s.riskLevel]??"white",children:s.riskLevel})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Effort: "}),e.jsx(r,{bold:!0,children:s.effort})]})]}),s.reason&&e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(r,{children:s.reason})}),s.breakingChanges.length>0&&e.jsxs(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.jsx(r,{bold:!0,color:"yellow",children:"Breaking changes:"}),s.breakingChanges.map((n,I)=>e.jsxs(r,{children:[" ","•"," ",n]},String(I)))]})]}),a&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"CHANGELOG"}),e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(r,{color:"cyan",underline:!0,children:a})})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"LINKS"}),e.jsx(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:t.kind==="ecosystem"?e.jsx(r,{color:"cyan",underline:!0,children:t.detailUrl??t.displayName??t.packageName}):e.jsxs(r,{color:"cyan",underline:!0,children:["https://npmx.dev/",t.packageName]})})]}),!s&&t.kind!=="ecosystem"&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"GUIDANCE"}),e.jsxs(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.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."})]}),t.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."})]}),t.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."})]})]})]})]})},Ae={major:"red",minor:"yellow",patch:"green"},Ie=[{id:"all",label:"All"},{id:"major",label:"Major"},{id:"minor",label:"Minor"},{id:"patch",label:"Patch"},{id:"security",label:"Security"}],De=({checked:a,entry:t,isSelected:i})=>{const s=Ae[t.updateType]??"white",d=t.vulnerabilities&&t.vulnerabilities.length>0,h=t.socketReport&&t.socketReport.alerts.length>0,f=!!t.acceptedRisk,y=a?"☑":"☐",p=t.socketReport?`${String(Math.round(t.socketReport.score.overall*100))}%`:"",j=t.socketReport?ue(t.socketReport.score.overall):"gray";return e.jsxs(l,{flexShrink:0,height:1,children:[e.jsx(r,{children:i?">":" "}),e.jsxs(r,{color:a?"white":"gray",children:[" ",y," "]}),d||h?e.jsx(r,{color:f?"gray":"red",children:f?"✓ ":"⚠ "}):e.jsx(r,{children:" "}),e.jsx(l,{flexGrow:1,children:e.jsxs(r,{bold:i,inverse:i,wrap:"truncate",children:[t.displayName??t.packageName,f?" [ack]":""]})}),p&&e.jsxs(r,{color:j,children:[" ",p]}),e.jsxs(r,{dimColor:!0,children:[" ",t.currentRange]}),e.jsxs(r,{dimColor:!0,children:[" ","→"," "]}),e.jsxs(r,{children:[t.newRange," "]}),e.jsx(r,{bold:!0,color:s,children:t.updateType})]})},Me=({count:a,ecosystem:t=!1,name:i})=>e.jsxs(l,{flexShrink:0,height:1,marginTop:1,children:[e.jsxs(r,{color:t?"cyan":void 0,dimColor:!t,children:[t?"◈":"▼"," "]}),e.jsx(r,{bold:!0,color:t?"cyan":"white",children:i.toUpperCase()}),e.jsxs(r,{dimColor:!0,children:[" ","(",a,")"]}),t&&e.jsxs(r,{color:"cyan",dimColor:!0,children:[" ","ci/cd refs"]})]}),Ne=({checkedEntries:a,entries:t,filterActive:i,filteredOutCount:s,filterText:d,filterType:h,focused:f,groupedByCatalog:y,isDryRun:p,onViewportHeightChange:j,scrollOffset:n,selectedIndex:I,totalCatalogEntries:D,totalChecked:E,totalEntries:H,viewportHeight:L})=>{const P=f?"white":"gray",{measuredHeight:m,ref:v}=ke(L,j);let F=0,S=0,M=0,R=0;for(const x of t)x.updateType==="major"?F++:x.updateType==="minor"?S++:M++,(x.vulnerabilities&&x.vulnerabilities.length>0||x.socketReport&&x.socketReport.alerts.length>0)&&R++;const C=[];F>0&&C.push(`${F} major`),S>0&&C.push(`${S} minor`),M>0&&C.push(`${M} patch`),R>0&&C.push(`${R} vulnerable`);const N=C.length>0?` (${C.join(", ")})`:"",w=t.filter(x=>x.kind==="ecosystem").length,k=t.length-w;let O=0;for(const x of t)a.has(A(x))&&O++;const U=[];let $=0;for(const[x,b]of y){U.push(e.jsx(Me,{count:b.length,ecosystem:b[0]?.kind==="ecosystem",name:x},`hdr-${x}`));for(const T of b){const W=$;U.push(e.jsx(De,{checked:a.has(A(T)),entry:T,isSelected:W===I},A(T))),$++}}let B=0;for(const[,x]of y)B+=2+x.length;const V=B>m&&m>0;return e.jsxs(l,{borderColor:P,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(l,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(r,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(r,{wrap:"truncate",children:[w>0?k:H,E>0?`/${E}`:""," ",w>0?"pkgs":"outdated",N,D>E?` · ${D-E} dupes`:""]}),w>0&&e.jsxs(r,{color:"cyan",children:[" ","◈",w," ","ci/cd"]}),!p&&O>0&&e.jsxs(r,{dimColor:!0,children:[" ","—",O," ","selected"]})]}),e.jsx(l,{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:Ie.map(({id:x,label:b})=>e.jsx(we,{name:x,children:b},x))})}),i&&e.jsxs(l,{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(l,{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(l,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:v,children:[e.jsx(l,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(l,{flexDirection:"column",marginTop:-n,children:U})}),V&&e.jsx(l,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(ye,{contentHeight:B,placement:"inset",scrollOffset:n,style:"block",viewportHeight:m})})]},`list-${h}-${d}`)]})},Be=100,Le=40,Pe=10,Fe=[],K=["all","major","minor","patch","security"],Qe=({autoExitSeconds:a=0,changelogUrls:t,checkedCount:i=0,filteredOutEntries:s=Fe,isDryRun:d,store:h,totalCatalogEntries:f=0})=>{const{exit:y}=je(),{columns:p,rows:j}=ae(),n=g.useSyncExternalStore(h.subscribe,h.getSnapshot),[I,D]=g.useState(!1),[E,H]=g.useState(!1),L=g.useRef(null),P=g.useRef(null),m=g.useRef(null),v=g.useRef(null),[F,S]=g.useState(0),[M,R]=g.useState(!1),[C,N]=g.useState(!1),w=g.useMemo(()=>h.getFilteredEntries(),[n.entries,n.filterType,n.filterText,n.sortMode]),k=w[n.selectedIndex]??null,O=k?h.getRecommendation(k.packageName):void 0,U=k&&t?t.get(k.packageName):void 0,$=g.useCallback(o=>{let c=0,u=0;for(const[,Q]of n.groupedByCatalog){c+=2;for(let oe=0;oe<Q.length;oe++){if(u===o)return c;c+=1,u++}}return c},[n.groupedByCatalog]),B=Math.max(1,j-8-(n.filterActive?1:0)),[V,x]=g.useState(B),b=V>0?V:B,T=g.useCallback(o=>{const c=$(o);S(u=>c>u+b-2?Math.max(0,c-b+2):c<u+1?Math.max(0,c-1):u)},[$,b]);if(g.useEffect(()=>{m.current?.scrollToTop()},[k?.packageName]),ge((o,c)=>{if(o==="c"&&c.ctrl){y();return}if(!C){if(E){c.escape||o==="f"||o==="q"?H(!1):c.downArrow||o==="j"?P.current?.scrollBy(1):(c.upArrow||o==="k")&&P.current?.scrollBy(-1);return}if(M){o==="u"||c.return?(R(!1),h.startApply(),y(h.getCheckedEntries())):c.escape||o==="q"?R(!1):c.downArrow||o==="j"?v.current?.scrollBy(1):c.upArrow||o==="k"?v.current?.scrollBy(-1):c.pageDown?v.current?.scrollBy(5):c.pageUp&&v.current?.scrollBy(-5);return}if(I){c.escape||o==="?"?D(!1):o==="q"?(D(!1),N(!0)):c.downArrow||o==="j"?L.current?.scrollBy(1):(c.upArrow||o==="k")&&L.current?.scrollBy(-1);return}if(o==="?"){D(!0);return}if(o==="q"){N(!0);return}if(c.tab){h.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}if(n.focusedPanel==="list"&&(c.leftArrow||c.rightArrow)){const u=K.indexOf(n.filterType),Q=c.rightArrow?(u+1)%K.length:(u-1+K.length)%K.length;S(0),m.current?.scrollToTop(),h.setFilterType(K[Q]);return}if(o==="f"&&s.length>0){H(u=>!u);return}if(n.filterActive){if(c.escape){h.setFilterActive(!1);return}if(c.return){h.setFilterActive(!1);return}if(c.backspace){S(0),h.setFilter(n.filterText.slice(0,-1));return}if(o&&!c.ctrl&&!c.meta){S(0),h.setFilter(n.filterText+o);return}return}if(n.focusedPanel==="list"){if(c.downArrow||o==="j"){const u=Math.min(n.selectedIndex+1,w.length-1);h.setSelectedIndex(u),T(u);return}if(c.upArrow||o==="k"){const u=Math.max(n.selectedIndex-1,0);h.setSelectedIndex(u),T(u);return}if(c.pageDown){const u=Math.min(n.selectedIndex+10,w.length-1);h.setSelectedIndex(u),T(u);return}if(c.pageUp){const u=Math.max(n.selectedIndex-10,0);h.setSelectedIndex(u),T(u);return}if(c.home){h.setSelectedIndex(0),S(0);return}if(c.end){const u=w.length-1;h.setSelectedIndex(u),T(u);return}if(o===" "||c.return){k&&h.toggleCheck(k);return}if(o==="a"){h.toggleAll();return}if(o==="s"){h.cycleSortMode(),T(h.getSnapshot().selectedIndex);return}if(o==="/"){h.setFilterActive(!0);return}if(o==="u"&&!d&&n.checkedEntries.size>0){R(!0);return}if(c.rightArrow){h.setFocusedPanel("detail");return}return}if(n.focusedPanel==="detail"){if(c.escape||c.leftArrow){h.setFocusedPanel("list");return}if(c.downArrow||o==="j"){m.current?.scrollBy(1);return}if(c.upArrow||o==="k"){m.current?.scrollBy(-1);return}if(c.pageDown){m.current?.scrollBy(10);return}if(c.pageUp){m.current?.scrollBy(-10);return}if(c.home){m.current?.scrollToTop();return}c.end&&m.current?.scrollToBottom()}}},{isActive:!0}),p<Le||j<Pe)return e.jsx(l,{alignItems:"center",height:j,justifyContent:"center",width:p,children:e.jsxs(r,{color:"yellow",children:["Terminal too small (",p,"x",j,")"]})});const W=p>=Be,q=[e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),e.jsx(r,{dimColor:!0,children:"NAV"})]},"nav"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:"CHECK"})]},"sp"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"a"}),e.jsx(r,{dimColor:!0,children:"ALL"})]},"a")];!d&&n.checkedEntries.size>0&&q.push(e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"green",children:"u"}),e.jsx(r,{dimColor:!0,children:"APPLY"})]},"u")),s.length>0&&q.push(e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"yellow",children:"f"}),e.jsxs(r,{dimColor:!0,children:["FILTERED (",s.length,")"]})]},"fo")),q.push(e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:"FILTER"})]},"lr"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:"SEARCH"})]},"f"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:"PANEL"})]},"t"));const ee=e.jsx(l,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:e.jsx(l,{flexWrap:"wrap",gap:2,paddingX:1,children:q})}),re=e.jsxs(J,{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:L,title:"KEYBOARD SHORTCUTS",visible:I,width:52,children:[e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(l,{children:[e.jsx(l,{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(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{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(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{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(l,{flexDirection:"column",children:[e.jsxs(l,{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"})]})]})]}),X=h.getCheckedEntries(),z=X.filter(o=>o.updateType==="major").length,xe=e.jsxs(l,{alignItems:"center",flexDirection:"column",children:[z>0&&e.jsx(l,{marginBottom:1,marginTop:1,children:e.jsxs(r,{color:"yellow",children:["⚠"," ",z," ","major update",z===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"]})]}),te=e.jsx(J,{footer:xe,scrollRef:v,title:`Apply ${X.length} update${X.length===1?"":"s"}?`,visible:M,width:70,children:X.map(o=>e.jsxs(l,{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))}),le=s.length>0?e.jsx(J,{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:P,title:`${s.length} PACKAGE${s.length===1?"":"S"} FILTERED BY TARGET`,visible:E,width:70,children:e.jsxs(l,{flexDirection:"column",children:[e.jsx(l,{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(l,{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(Ne,{checkedEntries:n.checkedEntries,entries:w,filterActive:n.filterActive,filteredOutCount:s.length,filterText:n.filterText,filterType:n.filterType,focused:n.focusedPanel==="list",groupedByCatalog:n.groupedByCatalog,isDryRun:d,onViewportHeightChange:x,scrollOffset:F,selectedIndex:n.selectedIndex,totalCatalogEntries:f,totalChecked:i,totalEntries:w.length,viewportHeight:b}),ie=e.jsx(Re,{changelogUrl:U,entry:k,focused:n.focusedPanel==="detail",recommendation:O,scrollRef:m});if(W){const o=Math.floor(p*.35);return e.jsxs(l,{flexDirection:"column",height:j,width:p,children:[e.jsxs(l,{flexDirection:"row",flexGrow:1,children:[e.jsx(l,{flexGrow:1,children:se}),e.jsx(l,{width:o,children:ie})]}),ee,te,le,e.jsx(ne,{autoExitSeconds:a||3,onCancel:()=>{N(!1)},visible:C}),re]})}const pe=Math.floor(j*.55);return e.jsxs(l,{flexDirection:"column",height:j,width:p,children:[e.jsx(l,{height:pe,children:se}),e.jsx(l,{flexGrow:1,children:ie}),ee,te,le,e.jsx(ne,{autoExitSeconds:a||3,onCancel:()=>{N(!1)},visible:C}),re]})};export{ze as U,Qe as b,Z as e,We as u};
1
+ import{l as e,m as l,i as r,r as g}from"../packem_chunks/catalog.js";import{I as ae,J as je,K as ge,M as ne}from"../packem_chunks/cli-main.js";import{Spinner as me}from"@visulima/tui-kit/spinner";import{Dialog as J}from"@visulima/tui-kit/dialog";import{ScrollView as fe}from"@visulima/tui-kit/scroll-view";import{B as ue}from"./en-BDYMmM2_.js";import{ScrollBar as ye}from"@visulima/tui-kit/scroll-bar";import{Tab as we}from"@visulima/tui-kit/tab";import{Tabs as Ce}from"@visulima/tui-kit/tabs";import{u as ke}from"./use-measured-height-BwAwGHjw.js";const We=({current:a,total:t})=>{const{columns:i}=ae(),s=i||80,d=t>0?Math.min(1,a/t):0,h=`${String(Math.round(d*100)).padStart(3)}%`,f=`${String(a)}/${String(t)}`,y=Math.max(10,s-2-h.length-1),p=Math.round(y*d),j=y-p;return e.jsxs(l,{flexDirection:"column",paddingX:1,children:[e.jsxs(l,{children:[e.jsx(me,{type:"dots"}),e.jsx(r,{children:" Checking catalog dependencies "}),e.jsx(r,{dimColor:!0,children:f})]}),e.jsxs(l,{children:[e.jsx(r,{color:"cyan",children:"━".repeat(p)}),e.jsx(r,{dimColor:!0,children:"─".repeat(j)}),e.jsxs(r,{dimColor:!0,children:[" ",h]})]})]})},_=["default","name","updateType","severity"],ce=a=>{const t=a.vulnerabilities?.map(i=>i.severity)??[];return t.includes("CRITICAL")?4:t.includes("HIGH")?3:t.includes("MODERATE")?2:t.includes("LOW")?1:0},de={digest:0,major:3,minor:2,patch:1,pin:0,unknown:0},he=(a,t)=>{if(t==="default")return a;const i=[...a];return t==="name"?i.sort((s,d)=>s.packageName.localeCompare(d.packageName)):t==="updateType"?i.sort((s,d)=>(de[d.updateType]??0)-(de[s.updateType]??0)||s.packageName.localeCompare(d.packageName)):i.sort((s,d)=>ce(d)-ce(s)||s.packageName.localeCompare(d.packageName)),i},Z=a=>`${a.ecosystem}|${a.file}:${String(a.line)}|${a.name}`,A=a=>`${a.catalogName} ${a.packageName}`,Y=a=>{const t=new Map;for(const i of a){const s=t.get(i.catalogName);s?s.push(i):t.set(i.catalogName,[i])}return t},G=(a,t,i)=>{let s=a;if(t!=="all"&&(s=t==="security"?s.filter(d=>d.vulnerabilities&&d.vulnerabilities.length>0||d.socketReport&&d.socketReport.alerts.length>0):s.filter(d=>d.updateType===t)),i){const d=i.toLowerCase();s=s.filter(h=>h.packageName.toLowerCase().includes(d))}return s};class ze{#e;#l=new Set;#t;#s;#i=null;constructor(t,i=null,s=[]){this.#t=t,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=>Z(d))),checkedEntries:new Set(t.map(d=>A(d))),ecosystemEntries:s,entries:t,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",groupedByCatalog:Y(t),phase:"browsing",selectedIndex:0,sortMode:"default"}}getSnapshot=()=>this.#e;subscribe=t=>(this.#l.add(t),()=>{this.#l.delete(t)});getFilteredEntries(){return he(G(this.#t,this.#e.filterType,this.#e.filterText),this.#e.sortMode)}setSortMode(t){if(t===this.#e.sortMode)return;const i=this.getFilteredEntries()[this.#e.selectedIndex]?.packageName,s=he(G(this.#t,this.#e.filterType,this.#e.filterText),t),d=i?Math.max(0,s.findIndex(h=>h.packageName===i)):0;this.#r({...this.#e,selectedIndex:d,sortMode:t})}cycleSortMode(){const t=_.indexOf(this.#e.sortMode),i=_[(t+1)%_.length]??"default";this.setSortMode(i)}getRecommendation(t){return this.#i?.get(t)}getCheckedEntries(){return this.#t.filter(t=>this.#e.checkedEntries.has(A(t)))}getCheckedEcosystemEntries(){return this.#s.filter(t=>this.#e.checkedEcosystemKeys.has(Z(t)))}toggleEcosystemCheck(t){const i=new Set(this.#e.checkedEcosystemKeys);i.has(t)?i.delete(t):i.add(t),this.#r({...this.#e,checkedEcosystemKeys:i})}checkAllEcosystem(){this.#r({...this.#e,checkedEcosystemKeys:new Set(this.#s.map(t=>Z(t)))})}uncheckAllEcosystem(){this.#r({...this.#e,checkedEcosystemKeys:new Set})}setSelectedIndex(t){const i=this.getFilteredEntries(),s=Math.max(0,Math.min(t,i.length-1));s!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:s})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:t})}setFilterType(t){if(t!==this.#e.filterType){const i=G(this.#t,t,this.#e.filterText);this.#r({...this.#e,entries:i,filterType:t,groupedByCatalog:Y(i),selectedIndex:0})}}setFilter(t){const i=G(this.#t,this.#e.filterType,t);this.#r({...this.#e,entries:i,filterText:t,groupedByCatalog:Y(i),selectedIndex:0})}setFilterActive(t){if(t!==this.#e.filterActive)if(t)this.#r({...this.#e,filterActive:!0});else{const i=G(this.#t,this.#e.filterType,"");this.#r({...this.#e,entries:i,filterActive:!1,filterText:"",groupedByCatalog:Y(i),selectedIndex:0})}}toggleCheck(t){const i=A(t),s=new Set(this.#e.checkedEntries);s.has(i)?s.delete(i):s.add(i),this.#r({...this.#e,allChecked:s.size===this.#t.length,checkedEntries:s})}checkAll(){this.#r({...this.#e,allChecked:!0,checkedEntries:new Set(this.#t.map(t=>A(t)))})}uncheckAll(){this.#r({...this.#e,allChecked:!1,checkedEntries:new Set})}toggleAll(){this.#e.allChecked?this.uncheckAll():this.checkAll()}startApply(){const t=this.getCheckedEntries();this.#r({...this.#e,applyProgress:{current:0,total:t.length},phase:"applying"})}updateApplyProgress(t){this.#e.applyProgress&&this.#r({...this.#e,applyProgress:{...this.#e.applyProgress,current:t}})}markDone(){this.#r({...this.#e,phase:"done"})}setError(t){this.#r({...this.#e,error:t,phase:"error"})}#r(t){this.#e=t;for(const i of this.#l)try{i()}catch{}}}const be={major:"red",minor:"yellow",patch:"green"},Te={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},Se={critical:"red",high:"red",low:"gray",medium:"yellow"},Ee={critical:"red",high:"red",low:"green",medium:"yellow"},ve={defer:"gray",review:"yellow",skip:"red",update:"green"},Re=({changelogUrl:a,entry:t,focused:i,recommendation:s,scrollRef:d})=>{const h=i?"white":"gray";if(!t)return e.jsx(l,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:e.jsx(r,{dimColor:!0,children:"No package selected"})});const f=be[t.updateType]??"white",y=t.vulnerabilities&&t.vulnerabilities.length>0,p=t.socketReport?.score.overall??0,j=t.socketReport?ue(p):"gray";return e.jsxs(l,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsx(l,{flexShrink:0,paddingTop:1,paddingX:2,children:e.jsx(r,{bold:!0,color:"white",children:t.displayName??t.packageName})}),e.jsxs(fe,{flexGrow:1,flexShrink:1,paddingX:2,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[e.jsx(r,{}),e.jsxs(l,{children:[e.jsx(l,{width:12,children:e.jsx(r,{dimColor:!0,children:"Current:"})}),e.jsx(r,{children:t.currentRange})]}),e.jsxs(l,{children:[e.jsx(l,{width:12,children:e.jsx(r,{dimColor:!0,children:"Target:"})}),e.jsx(r,{children:t.newRange}),e.jsxs(r,{bold:!0,color:f,children:[" ","(",t.updateType,")"]})]}),e.jsxs(l,{children:[e.jsx(l,{width:12,children:e.jsx(r,{dimColor:!0,children:"Version:"})}),e.jsx(r,{children:t.targetVersion})]}),e.jsxs(l,{children:[e.jsx(l,{width:12,children:e.jsx(r,{dimColor:!0,children:t.kind==="ecosystem"?"Source:":"Catalog:"})}),e.jsx(r,{color:t.kind==="ecosystem"?"cyan":void 0,children:t.catalogName})]}),t.acceptedRisk&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{color:"gray",children:"── "}),e.jsx(r,{bold:!0,color:"gray",children:"ACKNOWLEDGED RISK"}),e.jsxs(l,{flexDirection:"column",paddingLeft:2,children:[e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Reason: "}),e.jsx(r,{children:t.acceptedRisk.reason})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Accepted: "}),e.jsx(r,{children:t.acceptedRisk.acceptedAt.slice(0,10)})]})]})]}),y&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"red",children:"SECURITY"}),e.jsx(r,{}),t.vulnerabilities.map(n=>e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{gap:1,children:[e.jsxs(r,{bold:!0,color:Te[n.severity]??"gray",children:["⚠"," ",n.severity]}),e.jsx(r,{bold:!0,children:n.id})]}),e.jsx(l,{paddingLeft:2,children:e.jsx(r,{children:n.summary})}),e.jsxs(l,{gap:2,paddingLeft:2,children:[n.cvssScore!==void 0&&e.jsxs(r,{dimColor:!0,children:["CVSS:",String(n.cvssScore)]}),n.fixedVersions.length>0&&e.jsxs(r,{dimColor:!0,children:["Fixed in:",n.fixedVersions.join(", ")]})]})]},n.id))]}),t.socketReport&&e.jsxs(l,{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(l,{gap:2,children:[e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Overall: "}),e.jsxs(r,{bold:!0,color:j,children:[String(Math.round(p*100)),"%"]})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Supply Chain: "}),e.jsxs(r,{children:[String(Math.round(t.socketReport.score.supplyChain*100)),"%"]})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Quality: "}),e.jsxs(r,{children:[String(Math.round(t.socketReport.score.quality*100)),"%"]})]})]}),e.jsxs(l,{gap:2,children:[e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Maintenance: "}),e.jsxs(r,{children:[String(Math.round(t.socketReport.score.maintenance*100)),"%"]})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Vulnerability: "}),e.jsxs(r,{children:[String(Math.round(t.socketReport.score.vulnerability*100)),"%"]})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"License: "}),e.jsxs(r,{children:[t.socketReport.license||"unknown"," ","(",String(Math.round(t.socketReport.score.license*100)),"%)"]})]})]}),t.socketReport.alerts.length>0&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(r,{bold:!0,color:"yellow",children:["⚠"," ",String(t.socketReport.alerts.length)," ","alert",t.socketReport.alerts.length===1?"":"s",":"]}),t.socketReport.alerts.map(n=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsxs(r,{bold:!0,color:Se[n.severity]??"gray",children:["[",n.severity.toUpperCase(),"]"]}),e.jsx(r,{children:n.type}),e.jsxs(r,{dimColor:!0,children:["(",n.category,")"]})]},n.key))]})]}),s&&e.jsxs(l,{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(l,{gap:2,children:[e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Action: "}),e.jsx(r,{bold:!0,color:ve[s.action]??"white",children:s.action})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Risk: "}),e.jsx(r,{bold:!0,color:Ee[s.riskLevel]??"white",children:s.riskLevel})]}),e.jsxs(l,{children:[e.jsx(r,{dimColor:!0,children:"Effort: "}),e.jsx(r,{bold:!0,children:s.effort})]})]}),s.reason&&e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(r,{children:s.reason})}),s.breakingChanges.length>0&&e.jsxs(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.jsx(r,{bold:!0,color:"yellow",children:"Breaking changes:"}),s.breakingChanges.map((n,I)=>e.jsxs(r,{children:[" ","•"," ",n]},String(I)))]})]}),a&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"CHANGELOG"}),e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(r,{color:"cyan",underline:!0,children:a})})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"LINKS"}),e.jsx(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:t.kind==="ecosystem"?e.jsx(r,{color:"cyan",underline:!0,children:t.detailUrl??t.displayName??t.packageName}):e.jsxs(r,{color:"cyan",underline:!0,children:["https://npmx.dev/",t.packageName]})})]}),!s&&t.kind!=="ecosystem"&&e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"GUIDANCE"}),e.jsxs(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.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."})]}),t.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."})]}),t.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."})]})]})]})]})},Ae={major:"red",minor:"yellow",patch:"green"},Ie=[{id:"all",label:"All"},{id:"major",label:"Major"},{id:"minor",label:"Minor"},{id:"patch",label:"Patch"},{id:"security",label:"Security"}],De=({checked:a,entry:t,isSelected:i})=>{const s=Ae[t.updateType]??"white",d=t.vulnerabilities&&t.vulnerabilities.length>0,h=t.socketReport&&t.socketReport.alerts.length>0,f=!!t.acceptedRisk,y=a?"☑":"☐",p=t.socketReport?`${String(Math.round(t.socketReport.score.overall*100))}%`:"",j=t.socketReport?ue(t.socketReport.score.overall):"gray";return e.jsxs(l,{flexShrink:0,height:1,children:[e.jsx(r,{children:i?">":" "}),e.jsxs(r,{color:a?"white":"gray",children:[" ",y," "]}),d||h?e.jsx(r,{color:f?"gray":"red",children:f?"✓ ":"⚠ "}):e.jsx(r,{children:" "}),e.jsx(l,{flexGrow:1,children:e.jsxs(r,{bold:i,inverse:i,wrap:"truncate",children:[t.displayName??t.packageName,f?" [ack]":""]})}),p&&e.jsxs(r,{color:j,children:[" ",p]}),e.jsxs(r,{dimColor:!0,children:[" ",t.currentRange]}),e.jsxs(r,{dimColor:!0,children:[" ","→"," "]}),e.jsxs(r,{children:[t.newRange," "]}),e.jsx(r,{bold:!0,color:s,children:t.updateType})]})},Me=({count:a,ecosystem:t=!1,name:i})=>e.jsxs(l,{flexShrink:0,height:1,marginTop:1,children:[e.jsxs(r,{color:t?"cyan":void 0,dimColor:!t,children:[t?"◈":"▼"," "]}),e.jsx(r,{bold:!0,color:t?"cyan":"white",children:i.toUpperCase()}),e.jsxs(r,{dimColor:!0,children:[" ","(",a,")"]}),t&&e.jsxs(r,{color:"cyan",dimColor:!0,children:[" ","ci/cd refs"]})]}),Ne=({checkedEntries:a,entries:t,filterActive:i,filteredOutCount:s,filterText:d,filterType:h,focused:f,groupedByCatalog:y,isDryRun:p,onViewportHeightChange:j,scrollOffset:n,selectedIndex:I,totalCatalogEntries:D,totalChecked:E,totalEntries:H,viewportHeight:L})=>{const P=f?"white":"gray",{measuredHeight:m,ref:v}=ke(L,j);let F=0,S=0,M=0,R=0;for(const x of t)x.updateType==="major"?F++:x.updateType==="minor"?S++:M++,(x.vulnerabilities&&x.vulnerabilities.length>0||x.socketReport&&x.socketReport.alerts.length>0)&&R++;const C=[];F>0&&C.push(`${F} major`),S>0&&C.push(`${S} minor`),M>0&&C.push(`${M} patch`),R>0&&C.push(`${R} vulnerable`);const N=C.length>0?` (${C.join(", ")})`:"",w=t.filter(x=>x.kind==="ecosystem").length,k=t.length-w;let O=0;for(const x of t)a.has(A(x))&&O++;const U=[];let $=0;for(const[x,b]of y){U.push(e.jsx(Me,{count:b.length,ecosystem:b[0]?.kind==="ecosystem",name:x},`hdr-${x}`));for(const T of b){const W=$;U.push(e.jsx(De,{checked:a.has(A(T)),entry:T,isSelected:W===I},A(T))),$++}}let B=0;for(const[,x]of y)B+=2+x.length;const V=B>m&&m>0;return e.jsxs(l,{borderColor:P,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(l,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(r,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(r,{wrap:"truncate",children:[w>0?k:H,E>0?`/${E}`:""," ",w>0?"pkgs":"outdated",N,D>E?` · ${D-E} dupes`:""]}),w>0&&e.jsxs(r,{color:"cyan",children:[" ","◈",w," ","ci/cd"]}),!p&&O>0&&e.jsxs(r,{dimColor:!0,children:[" ","—",O," ","selected"]})]}),e.jsx(l,{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:Ie.map(({id:x,label:b})=>e.jsx(we,{name:x,children:b},x))})}),i&&e.jsxs(l,{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(l,{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(l,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:v,children:[e.jsx(l,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(l,{flexDirection:"column",marginTop:-n,children:U})}),V&&e.jsx(l,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(ye,{contentHeight:B,placement:"inset",scrollOffset:n,style:"block",viewportHeight:m})})]},`list-${h}-${d}`)]})},Be=100,Le=40,Pe=10,Fe=[],K=["all","major","minor","patch","security"],Qe=({autoExitSeconds:a=0,changelogUrls:t,checkedCount:i=0,filteredOutEntries:s=Fe,isDryRun:d,store:h,totalCatalogEntries:f=0})=>{const{exit:y}=je(),{columns:p,rows:j}=ae(),n=g.useSyncExternalStore(h.subscribe,h.getSnapshot),[I,D]=g.useState(!1),[E,H]=g.useState(!1),L=g.useRef(null),P=g.useRef(null),m=g.useRef(null),v=g.useRef(null),[F,S]=g.useState(0),[M,R]=g.useState(!1),[C,N]=g.useState(!1),w=g.useMemo(()=>h.getFilteredEntries(),[n.entries,n.filterType,n.filterText,n.sortMode]),k=w[n.selectedIndex]??null,O=k?h.getRecommendation(k.packageName):void 0,U=k&&t?t.get(k.packageName):void 0,$=g.useCallback(o=>{let c=0,u=0;for(const[,Q]of n.groupedByCatalog){c+=2;for(let oe=0;oe<Q.length;oe++){if(u===o)return c;c+=1,u++}}return c},[n.groupedByCatalog]),B=Math.max(1,j-8-(n.filterActive?1:0)),[V,x]=g.useState(B),b=V>0?V:B,T=g.useCallback(o=>{const c=$(o);S(u=>c>u+b-2?Math.max(0,c-b+2):c<u+1?Math.max(0,c-1):u)},[$,b]);if(g.useEffect(()=>{m.current?.scrollToTop()},[k?.packageName]),ge((o,c)=>{if(o==="c"&&c.ctrl){y();return}if(!C){if(E){c.escape||o==="f"||o==="q"?H(!1):c.downArrow||o==="j"?P.current?.scrollBy(1):(c.upArrow||o==="k")&&P.current?.scrollBy(-1);return}if(M){o==="u"||c.return?(R(!1),h.startApply(),y(h.getCheckedEntries())):c.escape||o==="q"?R(!1):c.downArrow||o==="j"?v.current?.scrollBy(1):c.upArrow||o==="k"?v.current?.scrollBy(-1):c.pageDown?v.current?.scrollBy(5):c.pageUp&&v.current?.scrollBy(-5);return}if(I){c.escape||o==="?"?D(!1):o==="q"?(D(!1),N(!0)):c.downArrow||o==="j"?L.current?.scrollBy(1):(c.upArrow||o==="k")&&L.current?.scrollBy(-1);return}if(o==="?"){D(!0);return}if(o==="q"){N(!0);return}if(c.tab){h.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}if(n.focusedPanel==="list"&&(c.leftArrow||c.rightArrow)){const u=K.indexOf(n.filterType),Q=c.rightArrow?(u+1)%K.length:(u-1+K.length)%K.length;S(0),m.current?.scrollToTop(),h.setFilterType(K[Q]);return}if(o==="f"&&s.length>0){H(u=>!u);return}if(n.filterActive){if(c.escape){h.setFilterActive(!1);return}if(c.return){h.setFilterActive(!1);return}if(c.backspace){S(0),h.setFilter(n.filterText.slice(0,-1));return}if(o&&!c.ctrl&&!c.meta){S(0),h.setFilter(n.filterText+o);return}return}if(n.focusedPanel==="list"){if(c.downArrow||o==="j"){const u=Math.min(n.selectedIndex+1,w.length-1);h.setSelectedIndex(u),T(u);return}if(c.upArrow||o==="k"){const u=Math.max(n.selectedIndex-1,0);h.setSelectedIndex(u),T(u);return}if(c.pageDown){const u=Math.min(n.selectedIndex+10,w.length-1);h.setSelectedIndex(u),T(u);return}if(c.pageUp){const u=Math.max(n.selectedIndex-10,0);h.setSelectedIndex(u),T(u);return}if(c.home){h.setSelectedIndex(0),S(0);return}if(c.end){const u=w.length-1;h.setSelectedIndex(u),T(u);return}if(o===" "||c.return){k&&h.toggleCheck(k);return}if(o==="a"){h.toggleAll();return}if(o==="s"){h.cycleSortMode(),T(h.getSnapshot().selectedIndex);return}if(o==="/"){h.setFilterActive(!0);return}if(o==="u"&&!d&&n.checkedEntries.size>0){R(!0);return}if(c.rightArrow){h.setFocusedPanel("detail");return}return}if(n.focusedPanel==="detail"){if(c.escape||c.leftArrow){h.setFocusedPanel("list");return}if(c.downArrow||o==="j"){m.current?.scrollBy(1);return}if(c.upArrow||o==="k"){m.current?.scrollBy(-1);return}if(c.pageDown){m.current?.scrollBy(10);return}if(c.pageUp){m.current?.scrollBy(-10);return}if(c.home){m.current?.scrollToTop();return}c.end&&m.current?.scrollToBottom()}}},{isActive:!0}),p<Le||j<Pe)return e.jsx(l,{alignItems:"center",height:j,justifyContent:"center",width:p,children:e.jsxs(r,{color:"yellow",children:["Terminal too small (",p,"x",j,")"]})});const W=p>=Be,q=[e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"q"}),e.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"?"}),e.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"↑↓"}),e.jsx(r,{dimColor:!0,children:"NAV"})]},"nav"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Space"}),e.jsx(r,{dimColor:!0,children:"CHECK"})]},"sp"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"a"}),e.jsx(r,{dimColor:!0,children:"ALL"})]},"a")];!d&&n.checkedEntries.size>0&&q.push(e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"green",children:"u"}),e.jsx(r,{dimColor:!0,children:"APPLY"})]},"u")),s.length>0&&q.push(e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"yellow",children:"f"}),e.jsxs(r,{dimColor:!0,children:["FILTERED (",s.length,")"]})]},"fo")),q.push(e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"←→"}),e.jsx(r,{dimColor:!0,children:"FILTER"})]},"lr"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"/"}),e.jsx(r,{dimColor:!0,children:"SEARCH"})]},"f"),e.jsxs(l,{gap:1,children:[e.jsx(r,{bold:!0,color:"white",children:"Tab"}),e.jsx(r,{dimColor:!0,children:"PANEL"})]},"t"));const ee=e.jsx(l,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:e.jsx(l,{flexWrap:"wrap",gap:2,paddingX:1,children:q})}),re=e.jsxs(J,{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:L,title:"KEYBOARD SHORTCUTS",visible:I,width:52,children:[e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(r,{dimColor:!0,children:"── "}),e.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(l,{children:[e.jsx(l,{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(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{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(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{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(l,{flexDirection:"column",children:[e.jsxs(l,{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"})]})]})]}),X=h.getCheckedEntries(),z=X.filter(o=>o.updateType==="major").length,xe=e.jsxs(l,{alignItems:"center",flexDirection:"column",children:[z>0&&e.jsx(l,{marginBottom:1,marginTop:1,children:e.jsxs(r,{color:"yellow",children:["⚠"," ",z," ","major update",z===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"]})]}),te=e.jsx(J,{footer:xe,scrollRef:v,title:`Apply ${X.length} update${X.length===1?"":"s"}?`,visible:M,width:70,children:X.map(o=>e.jsxs(l,{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))}),le=s.length>0?e.jsx(J,{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:P,title:`${s.length} PACKAGE${s.length===1?"":"S"} FILTERED BY TARGET`,visible:E,width:70,children:e.jsxs(l,{flexDirection:"column",children:[e.jsx(l,{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(l,{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(Ne,{checkedEntries:n.checkedEntries,entries:w,filterActive:n.filterActive,filteredOutCount:s.length,filterText:n.filterText,filterType:n.filterType,focused:n.focusedPanel==="list",groupedByCatalog:n.groupedByCatalog,isDryRun:d,onViewportHeightChange:x,scrollOffset:F,selectedIndex:n.selectedIndex,totalCatalogEntries:f,totalChecked:i,totalEntries:w.length,viewportHeight:b}),ie=e.jsx(Re,{changelogUrl:U,entry:k,focused:n.focusedPanel==="detail",recommendation:O,scrollRef:m});if(W){const o=Math.floor(p*.35);return e.jsxs(l,{flexDirection:"column",height:j,width:p,children:[e.jsxs(l,{flexDirection:"row",flexGrow:1,children:[e.jsx(l,{flexGrow:1,children:se}),e.jsx(l,{width:o,children:ie})]}),ee,te,le,e.jsx(ne,{autoExitSeconds:a||3,onCancel:()=>{N(!1)},visible:C}),re]})}const pe=Math.floor(j*.55);return e.jsxs(l,{flexDirection:"column",height:j,width:p,children:[e.jsx(l,{height:pe,children:se}),e.jsx(l,{flexGrow:1,children:ie}),ee,te,le,e.jsx(ne,{autoExitSeconds:a||3,onCancel:()=>{N(!1)},visible:C}),re]})};export{ze as U,Qe as b,Z as e,We as u};
@@ -1,4 +1,4 @@
1
- import{createRequire as Ot}from"node:module";import{a as he,g as Mt,u as W,b as Ut,t as Ae,l as Vt,h as jt,c as Dt,v as Oe}from"./package-version-C47v64aB.js";let It;const Lt=t=>(It??=Ot(import.meta.url))(t),ne=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,St=t=>{if(typeof ne<"u"&&ne.versions&&ne.versions.node){const[e,n]=ne.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ne.getBuiltinModule(t)}return Lt(t)},{createRequire:Pt}=St("node:module"),Tt=16,fe=32,Rt=64,T=128,le="positionals";class te extends Error{loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:i,message:s,name:o,stack:c,title:a}){super(s,{cause:e}),this.title=a,this.name=o,this.stack=c??this.stack,this.loc=i,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}}class A extends te{code;context;constructor(e,n,i){super({message:e,name:"CerebroError"}),this.code=n,this.context=i}}const tt=String.raw,Ie=tt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Bt=()=>new RegExp(tt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${Ie}(?:\u200D${Ie})*`,"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 Go=/^[ \t]*(?:\r\n|\r|\n)/,Ho=/(?:\r\n|\r|\n)[ \t]*$/,Jo=/^(?:[\r\n]|$)/,Ko=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,Zo=/^[ \t]*[\r\n][ \t\r\n]*$/,Xo=/\r\n|\n|\r/g,Yo=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Qo=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,F=Bt(),zt=/[-_./\s]+/g,ce=/(\u001B\[[0-9;]*[a-z])/i,Le=new RegExp("\\p{Script=Arabic}","u"),Wt=new RegExp("\\p{Script=Bengali}","u"),Y=new RegExp("\\p{Script=Cyrillic}","u"),Ft=new RegExp("\\p{Script=Devanagari}","u"),qt=new RegExp("\\p{Script=Ethiopic}","u"),me=new RegExp("\\p{Script=Greek}","u"),Se=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),Gt=new RegExp("\\p{Script=Gujarati}","u"),Ht=new RegExp("\\p{Script=Gurmukhi}","u"),Pe=new RegExp("\\p{Script=Hangul}","u"),Me=new RegExp("\\p{Script=Hebrew}","u"),Jt=new RegExp("\\p{Script=Hiragana}","u"),Ue=new RegExp("\\p{Script=Han}","u"),Kt=new RegExp("\\p{Script=Kannada}","u"),Zt=new RegExp("\\p{Script=Katakana}","u"),Xt=new RegExp("\\p{Script=Khmer}","u"),Yt=new RegExp("\\p{Script=Lao}","u"),S=new RegExp("\\p{Script=Latin}","u"),Qt=new RegExp("\\p{Script=Malayalam}","u"),en=new RegExp("\\p{Script=Myanmar}","u"),tn=new RegExp("\\p{Script=Oriya}","u"),nn=new RegExp("\\p{Script=Sinhala}","u"),on=new RegExp("\\p{Script=Tamil}","u"),sn=new RegExp("\\p{Script=Telugu}","u"),rn=new RegExp("\\p{Script=Thai}","u"),an=new RegExp("\\p{Script=Tibetan}","u"),Ve=/[\u02BB\u02BC\u0027]/u,ln=t=>t.replace(F,"");let cn=class{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const i=this.cache.keys().next().value;i!==void 0&&this.cache.delete(i)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};const un=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"),hn=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(un,"")},ge=new cn(1e3),pn=/[.*+?^${}()|[\]\\]/g,dn=t=>{const e=t.join("");if(ge.has(e)){const s=ge.get(e);return s.lastIndex=0,s}const n=t.map(s=>s.replaceAll(pn,String.raw`\$&`)).join("|"),i=new RegExp(n,"g");return ge.set(e,i),i},fn=t=>{const e=[];let n=0,i;for(F.lastIndex=0;(i=F.exec(t))!==null;)i.index>n&&e.push(t.slice(n,i.index)),e.push(i[0]),n=F.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},mn=/[ČŠŽĐ]/i,nt=new Uint8Array(128),it=new Uint8Array(128),ot=new Uint8Array(128);for(let t=0;t<128;t++)nt[t]=t>=65&&t<=90?1:0,it[t]=t>=97&&t<=122?1:0,ot[t]=t>=48&&t<=57?1:0;const we=t=>nt[t],je=t=>it[t],ye=t=>ot[t],B=(t,e,n,i,s)=>{if(t.length===0)return[];let o=!1;const c=Object.values(e);for(const f of c)if(f(t[0])){o=!0;break}if(!o&&!n)return[t];const a=[...t],u=[];let r=a[0],l="other";const d=Object.entries(e);for(const f of d){const[p,w]=f;if(w(a[0])){l=p;break}}let h=n&&i?a[0]===a[0].toLocaleUpperCase(i):!1;for(let f=1;f<a.length;f++){const p=a[f];let w="other";for(const v of d){const[b,C]=v;if(C(p)){w=b;break}}const $=n&&i?p===p.toLocaleUpperCase(i):!1;let m=!1;s?m=s(l,w,h,$,p,f,a):(l!==w&&l!=="other"&&w!=="other"&&(m=!0),n&&w!=="other"&&!h&&$&&(m=!0)),m?(u.push(r),r=p):r+=p,l=w,n&&(h=$)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},gn=(t,e,n,i)=>{if(n.size===0)return e;for(const s of n)if(t.startsWith(s,e))return i.push(s),e+s.length;return e},st=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const i=[],s=t.length;for(let o=1;o<s;o++){const c=gn(t,n,e,i);if(c!==n){n=c,o=n-1;continue}const a=t.codePointAt(o-1),u=t.codePointAt(o),r=a&&a<128&&we(a),l=u&&u<128&&we(u),d=a&&a<128&&je(a),h=a&&a<128&&ye(a),f=u&&u<128&&ye(u);if(d&&l){i.push(t.slice(n,o)),n=o;continue}if(h&&!f||!h&&f){i.push(t.slice(n,o)),n=o;continue}if(f&&!h){let p=!1,w=!1;if(o+1<s){const $=t.codePointAt(o+1);p=$&&$<128&&we($),w=$&&$<128&&ye($)}if(!w&&p){i.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<s){const p=t.codePointAt(o+1),w=p&&p<128&&je(p);if(r&&l&&w){const $=t.slice(n,o+1);e.has($)||(i.push(t.slice(n,o)),n=o)}}}return n<s&&i.push(t.slice(n)),i.filter(o=>o!=="")},rt=(t,e,n)=>{if(t.length===0)return[];const i=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!i&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e),p=f,w=f?0:-1;for(let $=1;$<l;$++){const m=r[$],v=m===m.toLocaleUpperCase(e);if(v===f)h+=m;else if(v)h&&h.length>0&&(d.push(h),h=m),p=!0,w=$;else{if(p&&$-w>1){const b=r[$-1],C=h.slice(0,-1);C&&C.length>0&&d.push(C),h=b+m}else h+=m;p=!1,w=-1}f=v}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(!Y.test(t)&&!S.test(t))return[t];const r=[...t],l=r.length,d=[];let h=r[0];const f=r[0];let p;Y.test(f)?p=1:S.test(f)?p=2:p=0;let w=f===f.toLocaleUpperCase(e);for(let m=1;m<l;m++){const v=r[m];let b;Y.test(v)?b=1:S.test(v)?b=2:b=0;const C=v===v.toLocaleUpperCase(e);p!==b&&(p===1||p===2)&&(b===1||b===2)||b===p&&!w&&C?(d.push(h),h=v):h+=v,p=b,w=C}h&&h.length>0&&d.push(h);const $=[];for(let m=0;m<d.length;m++)m<d.length-1&&d[m].length===1&&S.test(d[m])&&Y.test(d[m+1][0])?($.push(d[m]+d[m+1]),m+=1):$.push(d[m]);return $}if(e.startsWith("el")){if(!me.test(t)&&!S.test(t))return[t];const r=[];Se.lastIndex=0;let l;for(;(l=Se.exec(t))!==null;)r.push(l[0]);r.length===0&&r.push(t);const d=[];if(r.length===1){const h=r[0];if(!h||!me.test(h[0])||h.length===1)return[h??t]}for(const h of r){if(!h)continue;if(!me.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[$],v=m===m.toLocaleUpperCase(e);!w&&v?(d.push(p),p=m):p+=m,w=v}p&&d.push(p)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),l=r?{hiragana:h=>Jt.test(h),kanji:h=>Ue.test(h),katakana:h=>Zt.test(h),latin:h=>S.test(h)}:{hangul:h=>Pe.test(h),latin:h=>S.test(h)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=B(t,l,!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,l,!1,e,(h,f)=>h==="hangul"&&f==="latin"||h==="latin"&&f==="hangul")}if(e.startsWith("sl")){const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<l;p++){const w=r[p],$=w===w.toLocaleUpperCase(e),m=mn.test(w),v=p<l-1&&r[p+1]===r[p+1].toLocaleUpperCase(e);!f&&$||m&&v?(d.push(h),h=w,m&&v&&(d.push(h),h="")):h+=w,f=$}return h&&h.length>0&&d.push(h),d}if(e.startsWith("zh"))return B(t,{han:r=>Ue.test(r),latin:r=>S.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=l=>Me.test(l)||Le.test(l);return B(t,{latin:l=>S.test(l),rtl:l=>r(l)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=l=>Ft.test(l)||Wt.test(l)||Gt.test(l)||Ht.test(l)||Kt.test(l)||on.test(l)||sn.test(l)||Qt.test(l)||nn.test(l)||rn.test(l)||Yt.test(l)||an.test(l)||en.test(l)||qt.test(l)||Xt.test(l)||tn.test(l);return B(t,{indic:l=>r(l),latin:l=>S.test(l)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return B(t,{cyrillic:r=>Y.test(r),latin:r=>S.test(r)},!0,e);if(["ar","fa","he"].includes(e))return B(t,{latin:r=>S.test(r),rtl:r=>Me.test(r)||Le.test(r)},!1,e);if(e.startsWith("ko"))return B(t,{hangul:r=>Pe.test(r),latin:r=>S.test(r)},!1,e);if(e.startsWith("uz")){if(!Y.test(t)&&!S.test(t))return[t];const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<l;p++){const w=r[p],$=w===w.toLocaleUpperCase(e);if(Ve.test(w)||Ve.test(r[p-1])){h+=w;continue}!f&&$?(d.push(h),h=w):h+=w,f=$}return h&&h.length>0&&d.push(h),d}const s=[...t],o=s.length,c=[];let a=s[0],u=s[0]===s[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){c.push(r),a=s[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<o;r++){const l=s[r],d=l===l.toLocaleUpperCase(e);let h=0;for(const f of n)if(t.startsWith(f,r)){c.push(a,f),h=f.length,a="";const p=f.at(-1);p&&(u=p===p.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&d?(c.push(a),a=l):a+=l,u=d}return a&&c.push(a),c},wn=(t,e,n)=>{const i=[],s=ce.test(t)?t.split(ce).filter(Boolean):[t];for(const o of s){const c=o;if(ce.test(c))i.push(c);else{F.lastIndex=0;const a=F.test(c)?fn(c).filter(Boolean):[c];for(const u of a)if(F.lastIndex=0,F.test(u))i.push(u);else if(e){const r=e.toLowerCase().split("-")[0];i.push(...rt(u,r,n))}else i.push(...st(u,n))}}return i},yn=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:i=!1,knownAcronyms:s=[],locale:o,normalize:c=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,l=new Set([...s].toSorted((m,v)=>v.length-m.length));let d=t;u&&(d=hn(d)),r&&(d=ln(d));let h;Array.isArray(a)?h=dn(a):a instanceof RegExp?h=a: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 v=m.index,b=m[0],C=b.length,k=p.slice(0,v),V=p.slice(v+C);if(b.startsWith("../"))f.push(".."),p=p.slice(v+3);else if(b.startsWith("./"))f.push("."),p=p.slice(v+2);else if(v===0&&b==="..")f.push(".."),p=p.slice(2);else if(v===0&&b===".")f.push("."),p=p.slice(1);else{k.length>0&&f.push(k);let O=0;for(;(O=b.indexOf("../",O))!==-1;)f.push(".."),O+=3;for(O=0;(O=b.indexOf("./",O))!==-1;)(O===0||b[O-1]!==".")&&f.push("."),O+=2;let g=V;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||i?$.push(...wn(m,o,l)):o?$.push(...rt(m,o,l)):$.push(...st(m,l));return c&&($=$.map(m=>l.has(m)?m:o&&m===m.toLocaleUpperCase(o)?m[0]+m.slice(1).toLocaleLowerCase(o):m.toUpperCase()===m&&!l.has(m)?m.slice(0,1)+m.slice(1).toLowerCase():m)),$},R=new Uint32Array(65536),vn=(t,e)=>{const n=t.length,i=e.length,s=1<<n-1;let o=-1,c=0,a=n,u=n;for(;u--;)R[t.charCodeAt(u)]|=1<<u;for(u=0;u<i;u++){let r=R[e.charCodeAt(u)];const l=r|c;r|=(r&o)+o^o,c|=~(r|o),o&=r,c&s&&a++,o&s&&a--,c=c<<1|1,o=o<<1|~(l|c),c&=l}for(u=n;u--;)R[t.charCodeAt(u)]=0;return a},$n=(t,e)=>{const n=e.length,i=t.length,s=[],o=[],c=Math.ceil(n/32),a=Math.ceil(i/32);for(let p=0;p<c;p++)o[p]=-1,s[p]=0;let u=0;for(;u<a-1;u++){let p=0,w=-1;const $=u*32,m=Math.min(32,i)+$;for(let v=$;v<m;v++)R[t.charCodeAt(v)]|=1<<v;for(let v=0;v<n;v++){const b=R[e.charCodeAt(v)],C=o[v/32|0]>>>v&1,k=s[v/32|0]>>>v&1,V=b|p,O=((b|k)&w)+w^w|b|k;let g=p|~(O|w),y=w&O;g>>>31^C&&(o[v/32|0]^=1<<v),y>>>31^k&&(s[v/32|0]^=1<<v),g=g<<1|C,y=y<<1|k,w=y|~(V|g),p=g&V}for(let v=$;v<m;v++)R[t.charCodeAt(v)]=0}let r=0,l=-1;const d=u*32,h=Math.min(32,i-d)+d;for(let p=d;p<h;p++)R[t.charCodeAt(p)]|=1<<p;let f=i;for(let p=0;p<n;p++){const w=R[e.charCodeAt(p)],$=o[p/32|0]>>>p&1,m=s[p/32|0]>>>p&1,v=w|r,b=((w|m)&l)+l^l|w|m;let C=r|~(b|l),k=l&b;f+=C>>>i-1&1,f-=k>>>i-1&1,C>>>31^$&&(o[p/32|0]^=1<<p),k>>>31^m&&(s[p/32|0]^=1<<p),C=C<<1|$,k=k<<1|m,l=k|~(v|C),r=C&v}for(let p=d;p<h;p++)R[t.charCodeAt(p)]=0;return f},xn=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?vn(t,e):$n(t,e)};let bn;const Nn=t=>(bn??=Pt(import.meta.url))(t),ie=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,An=t=>{if(typeof ie<"u"&&ie.versions&&ie.versions.node){const[e,n]=ie.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ie.getBuiltinModule(t)}return Nn(t)},{writeFile:kn,stat:Cn,rm:En,readFile:De,readdir:_n,mkdir:On,access:In}=An("node:fs/promises"),re=[{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 A{commandName;constructor(e,n=[]){const i=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(i,"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(", ")}`)}},at=class extends A{option1;option2;constructor(t,e){super(`Options "${t}" and "${e}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:t,option2:e}),this.name="ConflictingOptionsError",this.option1=t,this.option2=e,this.hint=`Remove either --${t} or --${e}`}},Ln=class extends A{unknownOptions;constructor(t,e){const n=t.join(", "),i=`Found unknown ${t.length===1?"option":"options"}: ${n}`;super(i,"UNKNOWN_OPTION",{suggestions:e,unknownOptions:t}),this.name="UnknownOptionError",this.unknownOptions=t,e&&e.length>0&&(this.hint=`Did you mean: ${e.join(", ")}?`)}},Sn=class extends A{pluginName;constructor(t,e,n){super(`Plugin "${t}" error: ${e}`,"PLUGIN_ERROR",{originalError:n,pluginName:t}),this.name="PluginError",this.pluginName=t,n&&(this.cause=n)}},Pn=class{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(t){this.logger=t}hasPlugins(){return this.plugins.size>0}register(t){if(this.initialized)throw new Error(`Cannot register plugin "${t.name}" after initialization`);if(this.plugins.has(t.name))throw new Error(`Plugin "${t.name}" is already registered`);he().CEREBRO_OUTPUT_LEVEL===String(T)&&this.logger.debug(`registering plugin: ${t.name}`),this.plugins.set(t.name,t),this.cachedDependencyOrder=void 0}async init(t){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 e=this.getDependencyOrder();this.logger.debug(`initializing ${String(e.length)} plugin(s)...`);for(const n of e)if(typeof n.init=="function"){this.logger.debug(`initializing plugin: ${n.name}`);try{await n.init(t)}catch(i){const s=new Sn(n.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(t,e,n){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 o=s[t];if(typeof o=="function"){this.logger.debug(`executing ${t} hook for plugin: ${s.name}`);try{await(t==="afterCommand"?o(e,n):o(e))}catch(c){throw this.logger.error(`Error in ${t} hook for plugin "${s.name}":`,c),c}}}}async executeErrorHandlers(t,e){if(!this.initialized||this.plugins.size===0)return;const n=this.getDependencyOrder();for(const i of n)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(t,e)}catch(s){this.logger.error(`Error in error handler for plugin "${i.name}":`,s)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const t=[],e=new Set,n=new Set,i=s=>{if(e.has(s))return;if(n.has(s))throw new Error(`Circular dependency detected involving plugin "${s}"`);const o=this.plugins.get(s);if(!o)throw new Error(`Plugin "${s}" not found`);if(n.add(s),o.dependencies)for(const c of o.dependencies)i(c);n.delete(s),e.add(s),t.push(o)};for(const s of this.plugins.keys())i(s);return this.cachedDependencyOrder=t,t}validateDependencies(){for(const t of this.plugins.values())if(t.dependencies){for(const e of t.dependencies)if(!this.plugins.has(e))throw new Error(`Plugin "${t.name}" depends on "${e}" which is not registered`)}}};const oe=t=>t.type?.name==="Boolean",Mn=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},Te=t=>(oe(t)||(t.typeLabel=t.typeLabel??Mn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),Un=new RegExp(/^-([^\d-])$/),Vn=new RegExp(/^--(\S+)/),jn=new RegExp(/^-([^\d-]{2,})$/),Dn=t=>Un.test(t)||Vn.test(t)||jn.test(t),Tn=(t,e)=>{const n=e[0]&&Dn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const i=new Error(`Command not recognised: ${String(n)}`);throw i.command=n,i.name="INVALID_COMMAND",i}return{argv:e,command:n}};let Rn=class lt extends te{optionName;value;constructor(e,n,i){super({hint:`Pass a valid ${i} value for '${e}'.`,message:`Invalid ${i} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,lt.prototype)}},Bn=class ct extends te{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)}},Re=class ut extends te{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,ut.prototype)}},zn=class ht extends te{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,ht.prototype)}},P=class pt extends te{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,pt.prototype)}};const J=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",ke=t=>t===Number||typeof t=="function"&&t.name==="Number",Be=t=>t===String||typeof t=="function"&&t.name==="String",ze=(t,e,n)=>{const i=Number(t);if(e&&Number.isNaN(i)&&String(t).trim().toLowerCase()!=="nan")throw new Rn(n??"",String(t),"Number");return i},Wn=(t,e,n={})=>{const{optionName:i,strictTypes:s}=n;return Array.isArray(t)?J(e)?t.map(Boolean):ke(e)?t.map(o=>ze(o,s,i)):Be(e)?t.map(String):t.map(o=>e(String(o))):t===null?null:J(e)?!!t:ke(e)?ze(t,s,i):Be(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},_=(t,e,n,...i)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...i)},Fn=/-([a-z])/g,qn=/^\d+$/,Gn=t=>t.codePointAt(0)===95,We=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Fe=t=>t==="__proto__"||t==="constructor"||t==="prototype",ve=(t,e,n,i=!1)=>{t[e]===void 0?t[e]=i?[n]:n:i&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},qe=(t,e,n,i,s)=>{let o=e.get(t)??n.get(t);if(!o&&i){const c=t.toLowerCase();o=i.get(c)??s?.get(c)}return o},Hn=(t,e,n,i)=>{const s=n.debug??!1;_(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),_(s,"Starting argument resolution","resolver"),_(s,"Tokens:","resolver",t),_(s,"Definitions:","resolver",e),_(s,"Processing tokens...","resolver");const o=new Map,c=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,l=n.camelCase?new Map:void 0;for(const g of e)if(o.set(g.name,g),g.alias&&c.set(g.alias,g),n.caseInsensitive&&a&&(a.set(g.name.toLowerCase(),g),g.alias&&u&&u.set(g.alias.toLowerCase(),g)),n.camelCase&&r&&l){const y=g.name.replaceAll(Fn,(x,I)=>I.toUpperCase());r.set(g.name,y),l.set(y,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),v=e.some(g=>g.group),b=e.find(g=>ke(g.type));for(let g=0;g<t.length;g++){const y=t[g];if(y.kind==="option-terminator"){d._unknown=i.slice(y.index),$=!0;break}if(y.kind==="option"&&y.name){let x=qe(y.name,o,c,a,u);!x&&y.value===void 0&&b&&qn.test(y.name)&&(x=b,y.value=y.name,y.name=b.name);let I=!1;if(!x&&n.negation&&y.value===void 0&&y.name.startsWith("no-")){const E=y.name.slice(3),U=qe(E,o,c,a,u);U?.type&&J(U.type)&&(x=U,I=!0)}const N=x?x.name:y.name,L=x?.multiple,M=x?.lazyMultiple;if(Object.hasOwn(h,N)&&h[N]!==void 0&&!L&&!M&&!n.partial)throw new Bn(N);if(!x&&n.partial){const E=y.rawName??`--${y.name}${y.value!==void 0&&y.inlineValue?`=${y.value}`:""}`;f.push({index:y.index,value:E});continue}if(!x&&n.stopAtFirstUnknown){d._unknown=i.slice(y.index);break}if(!x&&!n.partial)throw new Re(y.name);if(y.value===void 0){const E=t[g+1],U=E?.kind==="option"&&!("name"in E)&&E.value!==void 0,j=E&&x&&!(x.type&&J(x.type))&&(E.kind==="positional"||U),_t=x&&x.defaultOption&&!x.multiple&&!x.lazyMultiple;if(j&&(!x?.defaultOption||_t))if(L){let D=g+1;const de=[];for(;D<t.length&&(t[D].kind==="positional"||t[D].kind==="option"&&!("name"in t[D])&&t[D].value!==void 0);)de.push(t[D].value),w.add(t[D].index),D++;h[N]=h[N]===void 0?de:We(h[N],de),g=D-1}else M?(ve(h,N,E.value,!0),w.add(E.index),g++):(h[N]=E.value,w.add(E.index),g++);else x?.type&&J(x.type)?ve(h,N,!I,L):(L||M)&&h[N]!==void 0?ve(h,N,null,!0):h[N]=L?[]:null}else{let{value:E}=y;if(x?.type&&J(x.type))switch(E){case"":{if(n.partial){const j=`${y.rawName??`--${y.name}`}${y.value?`=${y.value}`:""}`;p.push({index:y.index,value:j}),E=!0}else throw new Re(y.name);break}case"false":{E=!1;break}case"true":{E=!0;break}default:E=!0}const U=[E];if(L){let j=g+1;for(;j<t.length&&t[j].kind==="positional";)U.push(t[j].value),w.add(t[j].index),j++;g=j-1}h[N]===void 0?h[N]=L||M?U:E:L||M?h[N]=We(h[N],U):h[N]=E}}else if(y.kind==="positional"&&n.stopAtFirstUnknown&&!w.has(y.index)&&!m){_(s,`Found unconsumed positional token at index ${String(y.index)}, stopping processing`,"resolver"),d._unknown=i.slice(y.index);break}}for(const[g,y]of Object.entries(h)){const x=o.get(g);x&&(x.multiple||x.lazyMultiple)&&!Array.isArray(y)&&(h[g]=[y])}const C=g=>g.kind==="option"&&!o.has(g.name??"")&&!c.has(g.name??"")&&(!n.caseInsensitive||!a?.has(g.name?.toLowerCase()??"")&&!u?.has(g.name?.toLowerCase()??""));let k=-1,V=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!$&&(k=t.findIndex(g=>C(g)),k!==-1&&(V=t[k].index)),m){const g=[],y=[];for(const x of t)x.kind==="positional"&&!w.has(x.index)&&x.index<V&&(g.push(x.value),y.push(x));if(g.length>0){const x=h[m.name],I=m.multiple??m.lazyMultiple;x===void 0?I?(y.forEach(N=>w.add(N.index)),h[m.name]=g):(w.add(y[0].index),h[m.name]=g[0]):I&&(y.forEach(N=>w.add(N.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 zn(i[g.index])}if(n.partial&&!n.stopAtFirstUnknown){const g=[...f];for(const y of p)g.push({index:y.index,value:y.value});for(const y of t)y.kind==="positional"&&!w.has(y.index)&&g.push({index:y.index,value:i[y.index]});g.length>0&&(g.sort((y,x)=>y.index-x.index),d._unknown=g.map(y=>y.value))}if(n.stopAtFirstUnknown&&!$){const g=t.findIndex(x=>x.kind==="positional"&&!w.has(x.index));let y=-1;if(k!==-1&&g!==-1?y=Math.min(k,g):k!==-1?y=k:g!==-1&&(y=g),y>=0){const x=t[y].index;d._unknown=i.slice(x)}}for(const[g,y]of Object.entries(h)){const x=n.camelCase?r?.get(g)??g:g,I=o.get(g);I?.type?d[x]=Wn(y,I.type,{optionName:I.name,strictTypes:n.strictTypes}):d[x]=y===void 0?null:y}for(const g of e){const y=n.camelCase?r?.get(g.name)??g.name:g.name;!(y in d)&&g.defaultValue!==void 0&&(g.multiple??g.lazyMultiple?d[y]=Array.isArray(g.defaultValue)?[...g.defaultValue]:[g.defaultValue]:d[y]=g.defaultValue)}if(v){const g={},y={},x={};for(const N of e)if(N.group){const L=Array.isArray(N.group)?N.group:[N.group];for(const M of L)Fe(M)||(g[M]??={})}for(const N of Object.keys(d))if(!Gn(N)){y[N]=d[N];let L=N;n.camelCase&&(L=l?.get(N)??N);const M=o.get(L);if(M?.group){const E=Array.isArray(M.group)?M.group:[M.group];for(const U of E)Fe(U)||g[U]&&(g[U][N]=d[N])}else x[N]=d[N]}const I={_all:y};for(const[N,L]of Object.entries(g))I[N]=L;Object.keys(x).length>0&&(I._none=x),d._unknown&&(I._unknown=d._unknown),Object.keys(d).forEach(N=>delete d[N]),Object.assign(d,I)}const O=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));return _(s,"Final parsed result:","resolver",O),O},ee="-".codePointAt(0),K="=",Jn=K.codePointAt(0),Kn="--",Zn="-",Xn="--",dt=t=>t.length>2&&t.startsWith(Xn),Yn=t=>dt(t)&&!t.includes(K,3),Qn=t=>dt(t)&&t.includes(K,3),ei=t=>{if(t.length!==2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},ti=t=>{if(t.length<=2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee)return!1;const e=t.codePointAt(1);return!(e!==void 0&&e>=48&&e<=57)},ni=t=>{const e=[];let n=0,i=[],s=0,o=-1,c=0;for(;s<i.length||n<t.length;){let a;if(s<i.length?(a=i[s],s++):(a=t[n],n++),c>0?c--:o++,a===Kn){e.push({index:o,kind:"option-terminator"});const u=[...i.slice(s),...t.slice(n)],r=u.map((l,d)=>({index:o+d+1,kind:"positional",value:l}));e.push(...r),o+=u.length;break}if(ei(a)){const u=a.charAt(1);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(ti(a)&&!a.includes(K)){const u=[];let r="",l=!1;for(let d=1;d<a.length;d++){const h=a.charAt(d);l?r+=h:h.codePointAt(0)===Jn?l=!0:u.push(`${Zn}${h}`)}if(l)if(u.length>0){const d=u.pop();u.push(`${d}=${r}`)}else u.push(r);i=s<i.length?[...u,...i.slice(s)]:u,s=0,c=u.length;continue}if(Yn(a)){const u=a.slice(2);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(Qn(a)){const u=a.indexOf(K),r=a.slice(2,u),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}if(a.length>2&&a.codePointAt(0)===ee&&a.codePointAt(1)!==ee&&a.includes(K)){const u=a.indexOf(K),r=a.charAt(1),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}e.push({index:o,kind:"positional",value:a})}return e},ii=/\d/,oi=t=>typeof t=="function",si=(t,e,n)=>{const i=n?.debug??!1;_(i,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,o=new Set,c=new Set,a=new Set;let u=0;for(const r of t){if(_(i,"Checking definition:","validation",r),!r.name)throw _(i,"Validation failed: name is required","validation"),new P("Invalid option definition: name is required");if(typeof r.name!="string")throw new P("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new P("Invalid option definition: name cannot be empty");const l=e?r.name.toLowerCase():"";if(s.has(r.name)||e&&c.has(l))throw new P(`Invalid option definition: duplicate name '${r.name}'`);if(o.has(r.name)||e&&a.has(l))throw new P(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(s.add(r.name),e&&c.add(l),r.alias!==void 0){if(typeof r.alias!="string")throw new P("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new P("Invalid option definition: alias must be a single character");if(ii.test(r.alias))throw new P("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new P('Invalid option definition: alias cannot be "-"');const d=e?r.alias.toLowerCase():"";if(o.has(r.alias)||e&&a.has(d))throw new P(`Invalid option definition: duplicate alias '${r.alias}'`);if(s.has(r.alias)||e&&c.has(d))throw new P(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);o.add(r.alias),e&&a.add(d)}if(r.defaultOption&&(u++,r.type!==void 0&&J(r.type)))throw new P("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&oi(r.type)))throw new P("Invalid option definition: invalid type")}if(u>1)throw _(i,"Validation failed: multiple defaultOptions not allowed","validation"),new P("Invalid option definition: multiple defaultOptions not allowed");_(i,"Validation completed successfully","validation")};function ri(t,e={}){const n=e.debug??!1;_(n,"Starting command-line-args parsing","index"),_(n,"Options:","index",e);const i={...e};i.stopAtFirstUnknown&&(i.partial=!0);const s=Array.isArray(t)?t:[t];_(n,"Normalized definitions:","index",s),si(s,i.caseInsensitive,n?i:void 0);let{argv:o}=i;o??=process.argv.slice(2),_(n,"Using argv:","index",o);let c=o;i.caseInsensitive&&(c=o.map(r=>{if(r.startsWith("--")){const l=r.indexOf("="),d=(l===-1?r.slice(2):r.slice(2,l)).toLowerCase();return l===-1?`--${d}`:`--${d}${r.slice(l)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const l=r.indexOf("="),d=l===-1?r.slice(1):r.slice(1,l);if(!d)return r;const h=d.toLowerCase();return l===-1?`-${h}`:`-${h}${r.slice(l)}`}return r}));const a=ni(c.map(String));_(n,"Tokenized arguments:","index",a);const u=Hn(a,s,i,o);return _(n,"Command-line-args parsing completed","index"),u}class ai{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let $e=class extends A{commandName;constructor(e,n,i){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.",i!==void 0&&(this.cause=i)}};const li=/^-{1,2}(\w+)(=(.+))?$/,ft=(t,e,n,i)=>{const s=li.exec(t);if(s===null)return{};const o=s[1];if(!o)return{};const c=n&&i?n.get(o)??i.get(o):e.find(a=>a.name===o||a.alias===o);return c!==void 0?{argName:c.name,argValue:s[3],option:c}:{}},Ge=(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)},ci=new Set(["0","1","false","true"]),ui=(t,e,n,i)=>{if(e.length===0||t.length===0)return{};const s=(o,c)=>{const{argName:a,argValue:u,option:r}=ft(c,e,n,i),{lastOption:l}=o;return r&&oe(r)&&u&&a?o.partial[a]=Ge(u,r):o.lastName&&l&&oe(l)&&ci.has(c)&&(o.partial[o.lastName]=Ge(c,l)),{lastName:a,lastOption:r,partial:o.partial}};return t.reduce(s,{partial:{}}).partial},hi=new Set(["0","1","false","true"]),pi=(t,e,n,i)=>{if(e.length===0||t.length===0)return t;const s=(o,c)=>{const{argValue:a,option:u}=ft(c,e,n,i),{lastOption:r}=o;if(r&&oe(r)&&hi.has(c)){const{args:l}=o;return{args:l.slice(0,-1)}}return u&&oe(u)&&a?{args:o.args}:{args:[...o.args,c],lastOption:u}};return t.reduce(s,{args:[]}).args},di=t=>{const e=new Map;for(const n of t){const i=e.get(n.name);i?e.set(n.name,{...i,...n}):e.set(n.name,n)}return[...e.values()]},fi=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},mi=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return fi(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)}},gi=/_./g,wi=/^[A-Z]/,yi=t=>t.toLowerCase().replaceAll(gi,e=>e[1]?.toUpperCase()??e).replace(wi,e=>e.toLowerCase()),vi=(t,e=he())=>{if(!t||t.length===0)return{};const n={};for(const i of t){const s=e[i.name],o=mi(i,s),c=o===void 0?i.defaultValue:o,a=yi(i.name);n[a]=c}return n},$i=t=>{const e=new Map,n=new Map;for(const i of t)if(e.set(i.name,i),i.alias){const s=Array.isArray(i.alias)?i.alias:[i.alias];for(const o of s)n.set(o,i)}return{optionMapByAlias:n,optionMapByName:e}},mt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new $e(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(i){throw new $e(t.name,i instanceof Error?i.message:String(i),i)}const n=e.default;if(typeof n!="function")throw new $e(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},xi=(t,e,n,i,s)=>{const o=new ai(t.name,t),{_all:c,_unknown:a,positionals:u}=e,r=Object.keys(n).length>0?{...c,...n}:c;le in r&&delete r[le],o.argument=u?.[le]??[],o.rawUnknown=[...a??[]];const l=Object.keys(i).length>0;return o.options=l?{...r,...i}:r,o.env=vi(t.env,s),o},bi=(t,e,n)=>{const i=t.options??[],s=i.length>0;let o=di(s?[...i,...n]:n);if(o.length>0){for(const r of o)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(o=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:le,type:t.argument.type,typeLabel:t.argument.typeLabel},...o]);let c,a;if(s){const{optionMapByAlias:r,optionMapByName:l}=$i(i);c=pi(e,i,l,r),a=ui(e,i,l,r)}else c=e,a={};const u=ri(o,{argv:c,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:a,parsedArgs:u}},xe=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await mt(t))(e),Ni=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Ai=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),ki=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const i=[];let s="",o="";for(let c=0;c<n;c++){const a=t[c];if(ce.test(a)){s?(i.push(s+o+a),s="",o=""):(i.length>0&&i.push(e),s=a);continue}s?(o&&(o+=e),o+=a):(i.length>0&&i.push(e),i.push(a))}return i.join("")},Q=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return ki(yn(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(i=>{const s=i,o=s.toLowerCase();return n?(n=!1,Ni(o)):Ai(o)}),"")};let Ci=class extends A{commandName;missingOptions;constructor(t,e){super(`Command "${t}" is missing required options: ${e.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:t,missingOptions:e}),this.name="CommandValidationError",this.commandName=t,this.missingOptions=e,this.hint=`Provide the following required options: ${e.join(", ")}`}},Ei=class extends A{choices;option;value;constructor(t,e,n){super(`Invalid value "${e}" for option "${t}". Allowed values: ${n.join(", ")}`,"INVALID_CHOICE",{choices:n,option:t,value:e}),this.name="InvalidChoiceError",this.option=t,this.value=e,this.choices=n,this.hint=`Use one of: ${n.map(i=>`--${t} ${i}`).join(", ")}`}};const He=(t,e,n=!1)=>{const i=[],s=e._all??e;for(const o of t){if(!n&&!o.required)continue;const c=o.__camelCaseName__??o.name;if(s[c]===void 0){if(o.type?.name==="Boolean"){e[c]=!1;continue}i.push(o)}}return i},_i=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:xn(t,e)<=t.length/3,z=(t,e)=>{const n=t.toLowerCase();return e.filter(i=>_i(i.toLowerCase(),n))},Oi=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(i=>{const s=i.startsWith("--");let o=`Found unknown ${s?"option":"argument"} "${i}"`;if(s){const c=z(i.replace("--",""),(e.options??[]).map(a=>a.name));if(c.length>0){const[a,...u]=c.map(r=>`--${r}`);o+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(o)}),n.length>0)throw new Error(n.join(`
1
+ import{createRequire as Ot}from"node:module";import{a as he,g as Mt,u as W,b as Ut,t as Ae,l as Vt,h as jt,c as Dt,v as Oe}from"./package-version-BNRJ3o9C.js";let It;const Lt=t=>(It??=Ot(import.meta.url))(t),ne=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,St=t=>{if(typeof ne<"u"&&ne.versions&&ne.versions.node){const[e,n]=ne.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ne.getBuiltinModule(t)}return Lt(t)},{createRequire:Pt}=St("node:module"),Tt=16,fe=32,Rt=64,T=128,le="positionals";class te extends Error{loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:i,message:s,name:o,stack:c,title:a}){super(s,{cause:e}),this.title=a,this.name=o,this.stack=c??this.stack,this.loc=i,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}}class A extends te{code;context;constructor(e,n,i){super({message:e,name:"CerebroError"}),this.code=n,this.context=i}}const tt=String.raw,Ie=tt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Bt=()=>new RegExp(tt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${Ie}(?:\u200D${Ie})*`,"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 Go=/^[ \t]*(?:\r\n|\r|\n)/,Ho=/(?:\r\n|\r|\n)[ \t]*$/,Jo=/^(?:[\r\n]|$)/,Ko=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,Zo=/^[ \t]*[\r\n][ \t\r\n]*$/,Xo=/\r\n|\n|\r/g,Yo=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Qo=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,F=Bt(),zt=/[-_./\s]+/g,ce=/(\u001B\[[0-9;]*[a-z])/i,Le=new RegExp("\\p{Script=Arabic}","u"),Wt=new RegExp("\\p{Script=Bengali}","u"),Y=new RegExp("\\p{Script=Cyrillic}","u"),Ft=new RegExp("\\p{Script=Devanagari}","u"),qt=new RegExp("\\p{Script=Ethiopic}","u"),me=new RegExp("\\p{Script=Greek}","u"),Se=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),Gt=new RegExp("\\p{Script=Gujarati}","u"),Ht=new RegExp("\\p{Script=Gurmukhi}","u"),Pe=new RegExp("\\p{Script=Hangul}","u"),Me=new RegExp("\\p{Script=Hebrew}","u"),Jt=new RegExp("\\p{Script=Hiragana}","u"),Ue=new RegExp("\\p{Script=Han}","u"),Kt=new RegExp("\\p{Script=Kannada}","u"),Zt=new RegExp("\\p{Script=Katakana}","u"),Xt=new RegExp("\\p{Script=Khmer}","u"),Yt=new RegExp("\\p{Script=Lao}","u"),S=new RegExp("\\p{Script=Latin}","u"),Qt=new RegExp("\\p{Script=Malayalam}","u"),en=new RegExp("\\p{Script=Myanmar}","u"),tn=new RegExp("\\p{Script=Oriya}","u"),nn=new RegExp("\\p{Script=Sinhala}","u"),on=new RegExp("\\p{Script=Tamil}","u"),sn=new RegExp("\\p{Script=Telugu}","u"),rn=new RegExp("\\p{Script=Thai}","u"),an=new RegExp("\\p{Script=Tibetan}","u"),Ve=/[\u02BB\u02BC\u0027]/u,ln=t=>t.replace(F,"");let cn=class{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const i=this.cache.keys().next().value;i!==void 0&&this.cache.delete(i)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};const un=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"),hn=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(un,"")},ge=new cn(1e3),pn=/[.*+?^${}()|[\]\\]/g,dn=t=>{const e=t.join("");if(ge.has(e)){const s=ge.get(e);return s.lastIndex=0,s}const n=t.map(s=>s.replaceAll(pn,String.raw`\$&`)).join("|"),i=new RegExp(n,"g");return ge.set(e,i),i},fn=t=>{const e=[];let n=0,i;for(F.lastIndex=0;(i=F.exec(t))!==null;)i.index>n&&e.push(t.slice(n,i.index)),e.push(i[0]),n=F.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},mn=/[ČŠŽĐ]/i,nt=new Uint8Array(128),it=new Uint8Array(128),ot=new Uint8Array(128);for(let t=0;t<128;t++)nt[t]=t>=65&&t<=90?1:0,it[t]=t>=97&&t<=122?1:0,ot[t]=t>=48&&t<=57?1:0;const we=t=>nt[t],je=t=>it[t],ye=t=>ot[t],B=(t,e,n,i,s)=>{if(t.length===0)return[];let o=!1;const c=Object.values(e);for(const f of c)if(f(t[0])){o=!0;break}if(!o&&!n)return[t];const a=[...t],u=[];let r=a[0],l="other";const d=Object.entries(e);for(const f of d){const[p,w]=f;if(w(a[0])){l=p;break}}let h=n&&i?a[0]===a[0].toLocaleUpperCase(i):!1;for(let f=1;f<a.length;f++){const p=a[f];let w="other";for(const v of d){const[b,C]=v;if(C(p)){w=b;break}}const $=n&&i?p===p.toLocaleUpperCase(i):!1;let m=!1;s?m=s(l,w,h,$,p,f,a):(l!==w&&l!=="other"&&w!=="other"&&(m=!0),n&&w!=="other"&&!h&&$&&(m=!0)),m?(u.push(r),r=p):r+=p,l=w,n&&(h=$)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},gn=(t,e,n,i)=>{if(n.size===0)return e;for(const s of n)if(t.startsWith(s,e))return i.push(s),e+s.length;return e},st=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const i=[],s=t.length;for(let o=1;o<s;o++){const c=gn(t,n,e,i);if(c!==n){n=c,o=n-1;continue}const a=t.codePointAt(o-1),u=t.codePointAt(o),r=a&&a<128&&we(a),l=u&&u<128&&we(u),d=a&&a<128&&je(a),h=a&&a<128&&ye(a),f=u&&u<128&&ye(u);if(d&&l){i.push(t.slice(n,o)),n=o;continue}if(h&&!f||!h&&f){i.push(t.slice(n,o)),n=o;continue}if(f&&!h){let p=!1,w=!1;if(o+1<s){const $=t.codePointAt(o+1);p=$&&$<128&&we($),w=$&&$<128&&ye($)}if(!w&&p){i.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<s){const p=t.codePointAt(o+1),w=p&&p<128&&je(p);if(r&&l&&w){const $=t.slice(n,o+1);e.has($)||(i.push(t.slice(n,o)),n=o)}}}return n<s&&i.push(t.slice(n)),i.filter(o=>o!=="")},rt=(t,e,n)=>{if(t.length===0)return[];const i=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!i&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e),p=f,w=f?0:-1;for(let $=1;$<l;$++){const m=r[$],v=m===m.toLocaleUpperCase(e);if(v===f)h+=m;else if(v)h&&h.length>0&&(d.push(h),h=m),p=!0,w=$;else{if(p&&$-w>1){const b=r[$-1],C=h.slice(0,-1);C&&C.length>0&&d.push(C),h=b+m}else h+=m;p=!1,w=-1}f=v}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(!Y.test(t)&&!S.test(t))return[t];const r=[...t],l=r.length,d=[];let h=r[0];const f=r[0];let p;Y.test(f)?p=1:S.test(f)?p=2:p=0;let w=f===f.toLocaleUpperCase(e);for(let m=1;m<l;m++){const v=r[m];let b;Y.test(v)?b=1:S.test(v)?b=2:b=0;const C=v===v.toLocaleUpperCase(e);p!==b&&(p===1||p===2)&&(b===1||b===2)||b===p&&!w&&C?(d.push(h),h=v):h+=v,p=b,w=C}h&&h.length>0&&d.push(h);const $=[];for(let m=0;m<d.length;m++)m<d.length-1&&d[m].length===1&&S.test(d[m])&&Y.test(d[m+1][0])?($.push(d[m]+d[m+1]),m+=1):$.push(d[m]);return $}if(e.startsWith("el")){if(!me.test(t)&&!S.test(t))return[t];const r=[];Se.lastIndex=0;let l;for(;(l=Se.exec(t))!==null;)r.push(l[0]);r.length===0&&r.push(t);const d=[];if(r.length===1){const h=r[0];if(!h||!me.test(h[0])||h.length===1)return[h??t]}for(const h of r){if(!h)continue;if(!me.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[$],v=m===m.toLocaleUpperCase(e);!w&&v?(d.push(p),p=m):p+=m,w=v}p&&d.push(p)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),l=r?{hiragana:h=>Jt.test(h),kanji:h=>Ue.test(h),katakana:h=>Zt.test(h),latin:h=>S.test(h)}:{hangul:h=>Pe.test(h),latin:h=>S.test(h)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=B(t,l,!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,l,!1,e,(h,f)=>h==="hangul"&&f==="latin"||h==="latin"&&f==="hangul")}if(e.startsWith("sl")){const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<l;p++){const w=r[p],$=w===w.toLocaleUpperCase(e),m=mn.test(w),v=p<l-1&&r[p+1]===r[p+1].toLocaleUpperCase(e);!f&&$||m&&v?(d.push(h),h=w,m&&v&&(d.push(h),h="")):h+=w,f=$}return h&&h.length>0&&d.push(h),d}if(e.startsWith("zh"))return B(t,{han:r=>Ue.test(r),latin:r=>S.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=l=>Me.test(l)||Le.test(l);return B(t,{latin:l=>S.test(l),rtl:l=>r(l)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=l=>Ft.test(l)||Wt.test(l)||Gt.test(l)||Ht.test(l)||Kt.test(l)||on.test(l)||sn.test(l)||Qt.test(l)||nn.test(l)||rn.test(l)||Yt.test(l)||an.test(l)||en.test(l)||qt.test(l)||Xt.test(l)||tn.test(l);return B(t,{indic:l=>r(l),latin:l=>S.test(l)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return B(t,{cyrillic:r=>Y.test(r),latin:r=>S.test(r)},!0,e);if(["ar","fa","he"].includes(e))return B(t,{latin:r=>S.test(r),rtl:r=>Me.test(r)||Le.test(r)},!1,e);if(e.startsWith("ko"))return B(t,{hangul:r=>Pe.test(r),latin:r=>S.test(r)},!1,e);if(e.startsWith("uz")){if(!Y.test(t)&&!S.test(t))return[t];const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<l;p++){const w=r[p],$=w===w.toLocaleUpperCase(e);if(Ve.test(w)||Ve.test(r[p-1])){h+=w;continue}!f&&$?(d.push(h),h=w):h+=w,f=$}return h&&h.length>0&&d.push(h),d}const s=[...t],o=s.length,c=[];let a=s[0],u=s[0]===s[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){c.push(r),a=s[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<o;r++){const l=s[r],d=l===l.toLocaleUpperCase(e);let h=0;for(const f of n)if(t.startsWith(f,r)){c.push(a,f),h=f.length,a="";const p=f.at(-1);p&&(u=p===p.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&d?(c.push(a),a=l):a+=l,u=d}return a&&c.push(a),c},wn=(t,e,n)=>{const i=[],s=ce.test(t)?t.split(ce).filter(Boolean):[t];for(const o of s){const c=o;if(ce.test(c))i.push(c);else{F.lastIndex=0;const a=F.test(c)?fn(c).filter(Boolean):[c];for(const u of a)if(F.lastIndex=0,F.test(u))i.push(u);else if(e){const r=e.toLowerCase().split("-")[0];i.push(...rt(u,r,n))}else i.push(...st(u,n))}}return i},yn=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:i=!1,knownAcronyms:s=[],locale:o,normalize:c=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,l=new Set([...s].toSorted((m,v)=>v.length-m.length));let d=t;u&&(d=hn(d)),r&&(d=ln(d));let h;Array.isArray(a)?h=dn(a):a instanceof RegExp?h=a: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 v=m.index,b=m[0],C=b.length,k=p.slice(0,v),V=p.slice(v+C);if(b.startsWith("../"))f.push(".."),p=p.slice(v+3);else if(b.startsWith("./"))f.push("."),p=p.slice(v+2);else if(v===0&&b==="..")f.push(".."),p=p.slice(2);else if(v===0&&b===".")f.push("."),p=p.slice(1);else{k.length>0&&f.push(k);let O=0;for(;(O=b.indexOf("../",O))!==-1;)f.push(".."),O+=3;for(O=0;(O=b.indexOf("./",O))!==-1;)(O===0||b[O-1]!==".")&&f.push("."),O+=2;let g=V;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||i?$.push(...wn(m,o,l)):o?$.push(...rt(m,o,l)):$.push(...st(m,l));return c&&($=$.map(m=>l.has(m)?m:o&&m===m.toLocaleUpperCase(o)?m[0]+m.slice(1).toLocaleLowerCase(o):m.toUpperCase()===m&&!l.has(m)?m.slice(0,1)+m.slice(1).toLowerCase():m)),$},R=new Uint32Array(65536),vn=(t,e)=>{const n=t.length,i=e.length,s=1<<n-1;let o=-1,c=0,a=n,u=n;for(;u--;)R[t.charCodeAt(u)]|=1<<u;for(u=0;u<i;u++){let r=R[e.charCodeAt(u)];const l=r|c;r|=(r&o)+o^o,c|=~(r|o),o&=r,c&s&&a++,o&s&&a--,c=c<<1|1,o=o<<1|~(l|c),c&=l}for(u=n;u--;)R[t.charCodeAt(u)]=0;return a},$n=(t,e)=>{const n=e.length,i=t.length,s=[],o=[],c=Math.ceil(n/32),a=Math.ceil(i/32);for(let p=0;p<c;p++)o[p]=-1,s[p]=0;let u=0;for(;u<a-1;u++){let p=0,w=-1;const $=u*32,m=Math.min(32,i)+$;for(let v=$;v<m;v++)R[t.charCodeAt(v)]|=1<<v;for(let v=0;v<n;v++){const b=R[e.charCodeAt(v)],C=o[v/32|0]>>>v&1,k=s[v/32|0]>>>v&1,V=b|p,O=((b|k)&w)+w^w|b|k;let g=p|~(O|w),y=w&O;g>>>31^C&&(o[v/32|0]^=1<<v),y>>>31^k&&(s[v/32|0]^=1<<v),g=g<<1|C,y=y<<1|k,w=y|~(V|g),p=g&V}for(let v=$;v<m;v++)R[t.charCodeAt(v)]=0}let r=0,l=-1;const d=u*32,h=Math.min(32,i-d)+d;for(let p=d;p<h;p++)R[t.charCodeAt(p)]|=1<<p;let f=i;for(let p=0;p<n;p++){const w=R[e.charCodeAt(p)],$=o[p/32|0]>>>p&1,m=s[p/32|0]>>>p&1,v=w|r,b=((w|m)&l)+l^l|w|m;let C=r|~(b|l),k=l&b;f+=C>>>i-1&1,f-=k>>>i-1&1,C>>>31^$&&(o[p/32|0]^=1<<p),k>>>31^m&&(s[p/32|0]^=1<<p),C=C<<1|$,k=k<<1|m,l=k|~(v|C),r=C&v}for(let p=d;p<h;p++)R[t.charCodeAt(p)]=0;return f},xn=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?vn(t,e):$n(t,e)};let bn;const Nn=t=>(bn??=Pt(import.meta.url))(t),ie=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,An=t=>{if(typeof ie<"u"&&ie.versions&&ie.versions.node){const[e,n]=ie.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ie.getBuiltinModule(t)}return Nn(t)},{writeFile:kn,stat:Cn,rm:En,readFile:De,readdir:_n,mkdir:On,access:In}=An("node:fs/promises"),re=[{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 A{commandName;constructor(e,n=[]){const i=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(i,"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(", ")}`)}},at=class extends A{option1;option2;constructor(t,e){super(`Options "${t}" and "${e}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:t,option2:e}),this.name="ConflictingOptionsError",this.option1=t,this.option2=e,this.hint=`Remove either --${t} or --${e}`}},Ln=class extends A{unknownOptions;constructor(t,e){const n=t.join(", "),i=`Found unknown ${t.length===1?"option":"options"}: ${n}`;super(i,"UNKNOWN_OPTION",{suggestions:e,unknownOptions:t}),this.name="UnknownOptionError",this.unknownOptions=t,e&&e.length>0&&(this.hint=`Did you mean: ${e.join(", ")}?`)}},Sn=class extends A{pluginName;constructor(t,e,n){super(`Plugin "${t}" error: ${e}`,"PLUGIN_ERROR",{originalError:n,pluginName:t}),this.name="PluginError",this.pluginName=t,n&&(this.cause=n)}},Pn=class{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(t){this.logger=t}hasPlugins(){return this.plugins.size>0}register(t){if(this.initialized)throw new Error(`Cannot register plugin "${t.name}" after initialization`);if(this.plugins.has(t.name))throw new Error(`Plugin "${t.name}" is already registered`);he().CEREBRO_OUTPUT_LEVEL===String(T)&&this.logger.debug(`registering plugin: ${t.name}`),this.plugins.set(t.name,t),this.cachedDependencyOrder=void 0}async init(t){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 e=this.getDependencyOrder();this.logger.debug(`initializing ${String(e.length)} plugin(s)...`);for(const n of e)if(typeof n.init=="function"){this.logger.debug(`initializing plugin: ${n.name}`);try{await n.init(t)}catch(i){const s=new Sn(n.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(t,e,n){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 o=s[t];if(typeof o=="function"){this.logger.debug(`executing ${t} hook for plugin: ${s.name}`);try{await(t==="afterCommand"?o(e,n):o(e))}catch(c){throw this.logger.error(`Error in ${t} hook for plugin "${s.name}":`,c),c}}}}async executeErrorHandlers(t,e){if(!this.initialized||this.plugins.size===0)return;const n=this.getDependencyOrder();for(const i of n)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(t,e)}catch(s){this.logger.error(`Error in error handler for plugin "${i.name}":`,s)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const t=[],e=new Set,n=new Set,i=s=>{if(e.has(s))return;if(n.has(s))throw new Error(`Circular dependency detected involving plugin "${s}"`);const o=this.plugins.get(s);if(!o)throw new Error(`Plugin "${s}" not found`);if(n.add(s),o.dependencies)for(const c of o.dependencies)i(c);n.delete(s),e.add(s),t.push(o)};for(const s of this.plugins.keys())i(s);return this.cachedDependencyOrder=t,t}validateDependencies(){for(const t of this.plugins.values())if(t.dependencies){for(const e of t.dependencies)if(!this.plugins.has(e))throw new Error(`Plugin "${t.name}" depends on "${e}" which is not registered`)}}};const oe=t=>t.type?.name==="Boolean",Mn=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},Te=t=>(oe(t)||(t.typeLabel=t.typeLabel??Mn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),Un=new RegExp(/^-([^\d-])$/),Vn=new RegExp(/^--(\S+)/),jn=new RegExp(/^-([^\d-]{2,})$/),Dn=t=>Un.test(t)||Vn.test(t)||jn.test(t),Tn=(t,e)=>{const n=e[0]&&Dn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const i=new Error(`Command not recognised: ${String(n)}`);throw i.command=n,i.name="INVALID_COMMAND",i}return{argv:e,command:n}};let Rn=class lt extends te{optionName;value;constructor(e,n,i){super({hint:`Pass a valid ${i} value for '${e}'.`,message:`Invalid ${i} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,lt.prototype)}},Bn=class ct extends te{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)}},Re=class ut extends te{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,ut.prototype)}},zn=class ht extends te{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,ht.prototype)}},P=class pt extends te{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,pt.prototype)}};const J=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",ke=t=>t===Number||typeof t=="function"&&t.name==="Number",Be=t=>t===String||typeof t=="function"&&t.name==="String",ze=(t,e,n)=>{const i=Number(t);if(e&&Number.isNaN(i)&&String(t).trim().toLowerCase()!=="nan")throw new Rn(n??"",String(t),"Number");return i},Wn=(t,e,n={})=>{const{optionName:i,strictTypes:s}=n;return Array.isArray(t)?J(e)?t.map(Boolean):ke(e)?t.map(o=>ze(o,s,i)):Be(e)?t.map(String):t.map(o=>e(String(o))):t===null?null:J(e)?!!t:ke(e)?ze(t,s,i):Be(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},_=(t,e,n,...i)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...i)},Fn=/-([a-z])/g,qn=/^\d+$/,Gn=t=>t.codePointAt(0)===95,We=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Fe=t=>t==="__proto__"||t==="constructor"||t==="prototype",ve=(t,e,n,i=!1)=>{t[e]===void 0?t[e]=i?[n]:n:i&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},qe=(t,e,n,i,s)=>{let o=e.get(t)??n.get(t);if(!o&&i){const c=t.toLowerCase();o=i.get(c)??s?.get(c)}return o},Hn=(t,e,n,i)=>{const s=n.debug??!1;_(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),_(s,"Starting argument resolution","resolver"),_(s,"Tokens:","resolver",t),_(s,"Definitions:","resolver",e),_(s,"Processing tokens...","resolver");const o=new Map,c=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,l=n.camelCase?new Map:void 0;for(const g of e)if(o.set(g.name,g),g.alias&&c.set(g.alias,g),n.caseInsensitive&&a&&(a.set(g.name.toLowerCase(),g),g.alias&&u&&u.set(g.alias.toLowerCase(),g)),n.camelCase&&r&&l){const y=g.name.replaceAll(Fn,(x,I)=>I.toUpperCase());r.set(g.name,y),l.set(y,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),v=e.some(g=>g.group),b=e.find(g=>ke(g.type));for(let g=0;g<t.length;g++){const y=t[g];if(y.kind==="option-terminator"){d._unknown=i.slice(y.index),$=!0;break}if(y.kind==="option"&&y.name){let x=qe(y.name,o,c,a,u);!x&&y.value===void 0&&b&&qn.test(y.name)&&(x=b,y.value=y.name,y.name=b.name);let I=!1;if(!x&&n.negation&&y.value===void 0&&y.name.startsWith("no-")){const E=y.name.slice(3),U=qe(E,o,c,a,u);U?.type&&J(U.type)&&(x=U,I=!0)}const N=x?x.name:y.name,L=x?.multiple,M=x?.lazyMultiple;if(Object.hasOwn(h,N)&&h[N]!==void 0&&!L&&!M&&!n.partial)throw new Bn(N);if(!x&&n.partial){const E=y.rawName??`--${y.name}${y.value!==void 0&&y.inlineValue?`=${y.value}`:""}`;f.push({index:y.index,value:E});continue}if(!x&&n.stopAtFirstUnknown){d._unknown=i.slice(y.index);break}if(!x&&!n.partial)throw new Re(y.name);if(y.value===void 0){const E=t[g+1],U=E?.kind==="option"&&!("name"in E)&&E.value!==void 0,j=E&&x&&!(x.type&&J(x.type))&&(E.kind==="positional"||U),_t=x&&x.defaultOption&&!x.multiple&&!x.lazyMultiple;if(j&&(!x?.defaultOption||_t))if(L){let D=g+1;const de=[];for(;D<t.length&&(t[D].kind==="positional"||t[D].kind==="option"&&!("name"in t[D])&&t[D].value!==void 0);)de.push(t[D].value),w.add(t[D].index),D++;h[N]=h[N]===void 0?de:We(h[N],de),g=D-1}else M?(ve(h,N,E.value,!0),w.add(E.index),g++):(h[N]=E.value,w.add(E.index),g++);else x?.type&&J(x.type)?ve(h,N,!I,L):(L||M)&&h[N]!==void 0?ve(h,N,null,!0):h[N]=L?[]:null}else{let{value:E}=y;if(x?.type&&J(x.type))switch(E){case"":{if(n.partial){const j=`${y.rawName??`--${y.name}`}${y.value?`=${y.value}`:""}`;p.push({index:y.index,value:j}),E=!0}else throw new Re(y.name);break}case"false":{E=!1;break}case"true":{E=!0;break}default:E=!0}const U=[E];if(L){let j=g+1;for(;j<t.length&&t[j].kind==="positional";)U.push(t[j].value),w.add(t[j].index),j++;g=j-1}h[N]===void 0?h[N]=L||M?U:E:L||M?h[N]=We(h[N],U):h[N]=E}}else if(y.kind==="positional"&&n.stopAtFirstUnknown&&!w.has(y.index)&&!m){_(s,`Found unconsumed positional token at index ${String(y.index)}, stopping processing`,"resolver"),d._unknown=i.slice(y.index);break}}for(const[g,y]of Object.entries(h)){const x=o.get(g);x&&(x.multiple||x.lazyMultiple)&&!Array.isArray(y)&&(h[g]=[y])}const C=g=>g.kind==="option"&&!o.has(g.name??"")&&!c.has(g.name??"")&&(!n.caseInsensitive||!a?.has(g.name?.toLowerCase()??"")&&!u?.has(g.name?.toLowerCase()??""));let k=-1,V=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!$&&(k=t.findIndex(g=>C(g)),k!==-1&&(V=t[k].index)),m){const g=[],y=[];for(const x of t)x.kind==="positional"&&!w.has(x.index)&&x.index<V&&(g.push(x.value),y.push(x));if(g.length>0){const x=h[m.name],I=m.multiple??m.lazyMultiple;x===void 0?I?(y.forEach(N=>w.add(N.index)),h[m.name]=g):(w.add(y[0].index),h[m.name]=g[0]):I&&(y.forEach(N=>w.add(N.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 zn(i[g.index])}if(n.partial&&!n.stopAtFirstUnknown){const g=[...f];for(const y of p)g.push({index:y.index,value:y.value});for(const y of t)y.kind==="positional"&&!w.has(y.index)&&g.push({index:y.index,value:i[y.index]});g.length>0&&(g.sort((y,x)=>y.index-x.index),d._unknown=g.map(y=>y.value))}if(n.stopAtFirstUnknown&&!$){const g=t.findIndex(x=>x.kind==="positional"&&!w.has(x.index));let y=-1;if(k!==-1&&g!==-1?y=Math.min(k,g):k!==-1?y=k:g!==-1&&(y=g),y>=0){const x=t[y].index;d._unknown=i.slice(x)}}for(const[g,y]of Object.entries(h)){const x=n.camelCase?r?.get(g)??g:g,I=o.get(g);I?.type?d[x]=Wn(y,I.type,{optionName:I.name,strictTypes:n.strictTypes}):d[x]=y===void 0?null:y}for(const g of e){const y=n.camelCase?r?.get(g.name)??g.name:g.name;!(y in d)&&g.defaultValue!==void 0&&(g.multiple??g.lazyMultiple?d[y]=Array.isArray(g.defaultValue)?[...g.defaultValue]:[g.defaultValue]:d[y]=g.defaultValue)}if(v){const g={},y={},x={};for(const N of e)if(N.group){const L=Array.isArray(N.group)?N.group:[N.group];for(const M of L)Fe(M)||(g[M]??={})}for(const N of Object.keys(d))if(!Gn(N)){y[N]=d[N];let L=N;n.camelCase&&(L=l?.get(N)??N);const M=o.get(L);if(M?.group){const E=Array.isArray(M.group)?M.group:[M.group];for(const U of E)Fe(U)||g[U]&&(g[U][N]=d[N])}else x[N]=d[N]}const I={_all:y};for(const[N,L]of Object.entries(g))I[N]=L;Object.keys(x).length>0&&(I._none=x),d._unknown&&(I._unknown=d._unknown),Object.keys(d).forEach(N=>delete d[N]),Object.assign(d,I)}const O=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));return _(s,"Final parsed result:","resolver",O),O},ee="-".codePointAt(0),K="=",Jn=K.codePointAt(0),Kn="--",Zn="-",Xn="--",dt=t=>t.length>2&&t.startsWith(Xn),Yn=t=>dt(t)&&!t.includes(K,3),Qn=t=>dt(t)&&t.includes(K,3),ei=t=>{if(t.length!==2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},ti=t=>{if(t.length<=2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee)return!1;const e=t.codePointAt(1);return!(e!==void 0&&e>=48&&e<=57)},ni=t=>{const e=[];let n=0,i=[],s=0,o=-1,c=0;for(;s<i.length||n<t.length;){let a;if(s<i.length?(a=i[s],s++):(a=t[n],n++),c>0?c--:o++,a===Kn){e.push({index:o,kind:"option-terminator"});const u=[...i.slice(s),...t.slice(n)],r=u.map((l,d)=>({index:o+d+1,kind:"positional",value:l}));e.push(...r),o+=u.length;break}if(ei(a)){const u=a.charAt(1);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(ti(a)&&!a.includes(K)){const u=[];let r="",l=!1;for(let d=1;d<a.length;d++){const h=a.charAt(d);l?r+=h:h.codePointAt(0)===Jn?l=!0:u.push(`${Zn}${h}`)}if(l)if(u.length>0){const d=u.pop();u.push(`${d}=${r}`)}else u.push(r);i=s<i.length?[...u,...i.slice(s)]:u,s=0,c=u.length;continue}if(Yn(a)){const u=a.slice(2);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(Qn(a)){const u=a.indexOf(K),r=a.slice(2,u),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}if(a.length>2&&a.codePointAt(0)===ee&&a.codePointAt(1)!==ee&&a.includes(K)){const u=a.indexOf(K),r=a.charAt(1),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}e.push({index:o,kind:"positional",value:a})}return e},ii=/\d/,oi=t=>typeof t=="function",si=(t,e,n)=>{const i=n?.debug??!1;_(i,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,o=new Set,c=new Set,a=new Set;let u=0;for(const r of t){if(_(i,"Checking definition:","validation",r),!r.name)throw _(i,"Validation failed: name is required","validation"),new P("Invalid option definition: name is required");if(typeof r.name!="string")throw new P("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new P("Invalid option definition: name cannot be empty");const l=e?r.name.toLowerCase():"";if(s.has(r.name)||e&&c.has(l))throw new P(`Invalid option definition: duplicate name '${r.name}'`);if(o.has(r.name)||e&&a.has(l))throw new P(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(s.add(r.name),e&&c.add(l),r.alias!==void 0){if(typeof r.alias!="string")throw new P("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new P("Invalid option definition: alias must be a single character");if(ii.test(r.alias))throw new P("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new P('Invalid option definition: alias cannot be "-"');const d=e?r.alias.toLowerCase():"";if(o.has(r.alias)||e&&a.has(d))throw new P(`Invalid option definition: duplicate alias '${r.alias}'`);if(s.has(r.alias)||e&&c.has(d))throw new P(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);o.add(r.alias),e&&a.add(d)}if(r.defaultOption&&(u++,r.type!==void 0&&J(r.type)))throw new P("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&oi(r.type)))throw new P("Invalid option definition: invalid type")}if(u>1)throw _(i,"Validation failed: multiple defaultOptions not allowed","validation"),new P("Invalid option definition: multiple defaultOptions not allowed");_(i,"Validation completed successfully","validation")};function ri(t,e={}){const n=e.debug??!1;_(n,"Starting command-line-args parsing","index"),_(n,"Options:","index",e);const i={...e};i.stopAtFirstUnknown&&(i.partial=!0);const s=Array.isArray(t)?t:[t];_(n,"Normalized definitions:","index",s),si(s,i.caseInsensitive,n?i:void 0);let{argv:o}=i;o??=process.argv.slice(2),_(n,"Using argv:","index",o);let c=o;i.caseInsensitive&&(c=o.map(r=>{if(r.startsWith("--")){const l=r.indexOf("="),d=(l===-1?r.slice(2):r.slice(2,l)).toLowerCase();return l===-1?`--${d}`:`--${d}${r.slice(l)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const l=r.indexOf("="),d=l===-1?r.slice(1):r.slice(1,l);if(!d)return r;const h=d.toLowerCase();return l===-1?`-${h}`:`-${h}${r.slice(l)}`}return r}));const a=ni(c.map(String));_(n,"Tokenized arguments:","index",a);const u=Hn(a,s,i,o);return _(n,"Command-line-args parsing completed","index"),u}class ai{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let $e=class extends A{commandName;constructor(e,n,i){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.",i!==void 0&&(this.cause=i)}};const li=/^-{1,2}(\w+)(=(.+))?$/,ft=(t,e,n,i)=>{const s=li.exec(t);if(s===null)return{};const o=s[1];if(!o)return{};const c=n&&i?n.get(o)??i.get(o):e.find(a=>a.name===o||a.alias===o);return c!==void 0?{argName:c.name,argValue:s[3],option:c}:{}},Ge=(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)},ci=new Set(["0","1","false","true"]),ui=(t,e,n,i)=>{if(e.length===0||t.length===0)return{};const s=(o,c)=>{const{argName:a,argValue:u,option:r}=ft(c,e,n,i),{lastOption:l}=o;return r&&oe(r)&&u&&a?o.partial[a]=Ge(u,r):o.lastName&&l&&oe(l)&&ci.has(c)&&(o.partial[o.lastName]=Ge(c,l)),{lastName:a,lastOption:r,partial:o.partial}};return t.reduce(s,{partial:{}}).partial},hi=new Set(["0","1","false","true"]),pi=(t,e,n,i)=>{if(e.length===0||t.length===0)return t;const s=(o,c)=>{const{argValue:a,option:u}=ft(c,e,n,i),{lastOption:r}=o;if(r&&oe(r)&&hi.has(c)){const{args:l}=o;return{args:l.slice(0,-1)}}return u&&oe(u)&&a?{args:o.args}:{args:[...o.args,c],lastOption:u}};return t.reduce(s,{args:[]}).args},di=t=>{const e=new Map;for(const n of t){const i=e.get(n.name);i?e.set(n.name,{...i,...n}):e.set(n.name,n)}return[...e.values()]},fi=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},mi=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return fi(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)}},gi=/_./g,wi=/^[A-Z]/,yi=t=>t.toLowerCase().replaceAll(gi,e=>e[1]?.toUpperCase()??e).replace(wi,e=>e.toLowerCase()),vi=(t,e=he())=>{if(!t||t.length===0)return{};const n={};for(const i of t){const s=e[i.name],o=mi(i,s),c=o===void 0?i.defaultValue:o,a=yi(i.name);n[a]=c}return n},$i=t=>{const e=new Map,n=new Map;for(const i of t)if(e.set(i.name,i),i.alias){const s=Array.isArray(i.alias)?i.alias:[i.alias];for(const o of s)n.set(o,i)}return{optionMapByAlias:n,optionMapByName:e}},mt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new $e(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(i){throw new $e(t.name,i instanceof Error?i.message:String(i),i)}const n=e.default;if(typeof n!="function")throw new $e(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},xi=(t,e,n,i,s)=>{const o=new ai(t.name,t),{_all:c,_unknown:a,positionals:u}=e,r=Object.keys(n).length>0?{...c,...n}:c;le in r&&delete r[le],o.argument=u?.[le]??[],o.rawUnknown=[...a??[]];const l=Object.keys(i).length>0;return o.options=l?{...r,...i}:r,o.env=vi(t.env,s),o},bi=(t,e,n)=>{const i=t.options??[],s=i.length>0;let o=di(s?[...i,...n]:n);if(o.length>0){for(const r of o)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(o=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:le,type:t.argument.type,typeLabel:t.argument.typeLabel},...o]);let c,a;if(s){const{optionMapByAlias:r,optionMapByName:l}=$i(i);c=pi(e,i,l,r),a=ui(e,i,l,r)}else c=e,a={};const u=ri(o,{argv:c,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:a,parsedArgs:u}},xe=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await mt(t))(e),Ni=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Ai=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),ki=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const i=[];let s="",o="";for(let c=0;c<n;c++){const a=t[c];if(ce.test(a)){s?(i.push(s+o+a),s="",o=""):(i.length>0&&i.push(e),s=a);continue}s?(o&&(o+=e),o+=a):(i.length>0&&i.push(e),i.push(a))}return i.join("")},Q=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return ki(yn(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(i=>{const s=i,o=s.toLowerCase();return n?(n=!1,Ni(o)):Ai(o)}),"")};let Ci=class extends A{commandName;missingOptions;constructor(t,e){super(`Command "${t}" is missing required options: ${e.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:t,missingOptions:e}),this.name="CommandValidationError",this.commandName=t,this.missingOptions=e,this.hint=`Provide the following required options: ${e.join(", ")}`}},Ei=class extends A{choices;option;value;constructor(t,e,n){super(`Invalid value "${e}" for option "${t}". Allowed values: ${n.join(", ")}`,"INVALID_CHOICE",{choices:n,option:t,value:e}),this.name="InvalidChoiceError",this.option=t,this.value=e,this.choices=n,this.hint=`Use one of: ${n.map(i=>`--${t} ${i}`).join(", ")}`}};const He=(t,e,n=!1)=>{const i=[],s=e._all??e;for(const o of t){if(!n&&!o.required)continue;const c=o.__camelCaseName__??o.name;if(s[c]===void 0){if(o.type?.name==="Boolean"){e[c]=!1;continue}i.push(o)}}return i},_i=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:xn(t,e)<=t.length/3,z=(t,e)=>{const n=t.toLowerCase();return e.filter(i=>_i(i.toLowerCase(),n))},Oi=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(i=>{const s=i.startsWith("--");let o=`Found unknown ${s?"option":"argument"} "${i}"`;if(s){const c=z(i.replace("--",""),(e.options??[]).map(a=>a.name));if(c.length>0){const[a,...u]=c.map(r=>`--${r}`);o+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(o)}),n.length>0)throw new Error(n.join(`
2
2
  `))},Ii=(t,e,n)=>{const i=n.__requiredOptions__,s=i?He(i,e,!0):He(t,e,!1);if(s.length>0)throw new Ci(n.name,s.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&Oi(e,n)},Li=(t,e,n)=>{const i=n.__conflictingOptions__??t.filter(s=>s.conflicts!==void 0);if(i.length>0){const s=i.find(o=>{const c=o.__camelCaseName__??Q(o.name);return Array.isArray(o.conflicts)?o.conflicts.some(a=>e[Q(a)]!==void 0)&&e[c]!==void 0:e[Q(o.conflicts)]!==void 0&&e[c]!==void 0});if(s)throw new at(s.name,typeof s.conflicts=="string"?s.conflicts:s.conflicts?.[0]??"unknown")}},Si=(t,e)=>{const n=e.options;if(n)for(const i of n){if(!i.choices||i.choices.length===0)continue;const s=i.__camelCaseName__??Q(i.name),o=t[s];if(o==null)continue;const c=Array.isArray(o)?o:[o];for(const a of c){const u=String(a);if(!i.choices.includes(u))throw new Ei(i.name,u,i.choices)}}},Pi=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const s of t.options){if(s.name){const o=e.get(s.name)??[];o.push(s),e.set(s.name,o)}if(typeof s.alias=="string"&&s.alias.length>0){const o=n.get(s.alias)??[];o.push(s),n.set(s.alias,o)}else if(Array.isArray(s.alias)){for(const o of s.alias)if(o.length>0){const c=n.get(o)??[];c.push(s),n.set(o,c)}}}const i=[];for(const[s,o]of e)o.length>1&&i.push(`Duplicate option name "${s}" in command "${t.name}": ${JSON.stringify(o)}`);for(const[s,o]of n)o.length>1&&i.push(`Duplicate option alias "-${s}" used by options ${o.map(c=>`"${c.name}"`).join(", ")} in command "${t.name}"`);if(i.length>0)throw new Error(i.join(`
3
3
  `))},Mi=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let i;for(let s=1;s<=e.length;s+=1){const o=e[s-1];if(o===void 0||o.startsWith("-"))break;n.push(o);const c=n.join(" ");t.has(c)&&(i={commandPath:[...n],depth:s})}return i?{argv:e.slice(i.depth),commandPath:i.commandPath}:{argv:e,commandPath:void 0}},H=t=>t.join(" "),Je=(t,e)=>e&&e.length>0?[...e,t]:[t],Ui=/^no-/,Vi=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Q(e.name)})},ji=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const i of t.options)e.add(i.name);const n=[];for(const i of t.options)if(i.name.startsWith("no-")){const s=i.name.replace(Ui,"");if(!e.has(s)){if(i.type!==Boolean)throw new Error(`Cannot add negated option "${i.name}" to command "${t.name}" because it is not a boolean.`);const o={...i,defaultValue:i.defaultValue===void 0?!0:!i.defaultValue,name:s};n.push(o),e.add(s)}}n.length>0&&t.options.push(...n)},Di=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,i=new Map;for(const o of e.options)if(o.name.startsWith("no-")){const c=Q(o.name);i.set(c,o)}const s=Object.keys(n).filter(o=>i.has(o));if(s.length!==0)for(const o of s){const c=o.charAt(2);if(!c)continue;const a=c.toLowerCase()+o.slice(3),u=i.get(o);u&&(u.__negated__=!0),n[a]=!n[o],Reflect.deleteProperty(n,o)}},Ti=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const s of e.options)s.__camelCaseName__&&s.__negated__===void 0&&s.implies!==void 0&&n.set(s.__camelCaseName__,s);if(n.size===0)return;const{options:i}=t;for(const s of Object.keys(i)){const o=n.get(s);if(o?.implies){const{implies:c}=o;for(const[a,u]of Object.entries(c))i[a]===void 0&&(i[a]=u)}}},Ri=()=>!!process.versions.electron,Bi=()=>Ri()&&!process.defaultApp,zi=()=>Bi()?0:1,Wi=t=>t.slice(zi()+1),Fi=" ",qi=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,i)=>n===e[i]),Gi=t=>{if(typeof t=="string")return t.split(Fi);const e=Ae();return qi(t,e)?Wi(t):t},Hi=t=>{const e=o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),W(1)},n=(o,c)=>{if(o instanceof Error)t.error(`Promise rejection: ${o.message||o}`),o.stack&&t.error(o.stack);else{let a;if(typeof o=="string")a=o;else try{a=JSON.stringify(o)}catch{a=String(o)}t.error(`Promise rejection: ${a}`)}W(1)},i=Oe("uncaughtException",e),s=Oe("unhandledRejection",n);return()=>{i(),s()}},Ke=100,Ji=/^[a-z][\w-]*$/i,Ce=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new A(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},Ze=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new A(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},be=(t,e)=>{if(typeof t!="object"||t===null)throw new A(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},ae=t=>{const e=Ce(t,"Command name");if(e.length>Ke)throw new A(`Command name is too long (maximum ${String(Ke)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new A(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Ji.test(e))throw new A(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Ki=new Set([`
4
4
  `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Zi=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,i=n.maxArgumentLength??1e6;if(Number.isFinite(i)&&i>0&&t.length>i)throw new Error(`Argument is too long (maximum ${String(i)} characters)`);if(n.checkDangerousChars){for(const s of t)if(Ki.has(s))throw new Error(`Argument contains dangerous character: ${s}`)}return n.trim?t.trim():t},Xe=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,i=n.maxArguments??1e5;if(Number.isFinite(i)&&i>0&&t.length>i)throw new Error(`Too many arguments (maximum ${String(i)})`);return t.map(s=>Zi(s,n))},Xi=/^-([^\d-])$/,Yi=/^--(\S+)/,Qi=/^-([^\d-]{2,})$/,Ne=t=>Xi.test(t)||Yi.test(t)||Qi.test(t),eo={access:(t,e)=>In(t,e),mkdir:(t,e)=>On(t,e),readdir:t=>_n(t),readFile:(async(t,e)=>e===void 0?De(t):De(t,e)),rm:(t,e)=>En(t,e),stat:t=>Cn(t),writeFile:(t,e,n)=>kn(t,e,n)},to=(t,e,n)=>{const i=e.indexOf("--"),s=i===-1?new Set:new Set(e.slice(i+1)),o=n.filter(u=>u.startsWith("--")&&u!=="--"&&!s.has(u));if(o.length===0)return;const c=(t.options??[]).map(u=>u.name),a=o.flatMap(u=>z(u.slice(2),c).map(r=>`--${r}`));throw new Ln(o,a)};let no=class gt{#t;#e;#u;#p;#d;#f;#A;#k;#C;#$;#E;#x;#_;#b=fe;#h;#n;#i;#o;#s;#r;#O=!1;#I;#L=!1;#m;#g;#w;#l=[];#j(){return this.#m===void 0&&(this.#m=[...this.#i.keys()]),this.#m}#S(){return this.#g===void 0&&(this.#g=[...this.#n.keys()]),this.#g}#a(){return this.#w===void 0&&(this.#w=[...this.#j(),...this.#S()]),this.#w}#P(){return this.#l.length===0?re:[...re,...this.#l]}#M(){this.#m=void 0,this.#g=void 0,this.#w=void 0}#N(){if(this.#u===void 0){const e=Gi(this.#e.argv);this.#u=Xe(e,{maxArguments:this.#x}),this.#D()}return this.#u}#y(){return this.#$??he()}#v(e){this.#b=e,this.#y().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){return this.#b}#D(){if(!this.#u)return;let e=!1;for(const n of this.#u){if(n==="--quiet"||n==="-q"){this.#v(Tt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#v(Rt),e=!0;break}if(n==="--debug"){this.#v(T),e=!0;break}}e||this.#v(Object.hasOwn(this.#y(),"DEBUG")?T:fe)}#T(){this.#L||(this.#I=Hi(this.#t),this.#L=!0)}#R(){return{arch:Ut(),argv:this.#N(),cwd:this.#p,env:this.#$??he(),exit:this.#C??(e=>W(e??0)),platform:Mt(),stdin:this.#E}}#U(e,n,i,s){this.#c()===T&&this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:c,parsedArgs:a}=bi(e,n,this.#P()),u=Object.keys(c).length>0;let r=a;u&&(r={...a,_all:{...a._all,...c}}),Ii(o,r,e);const l=xi(e,a,c,i,this.#y());l.runtime=this,l.argv=this.#N(),l.fs=this.#k??eo,l.process=this.#R(),l.console=this.#t;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),v=n.includes($);if(m&&v)throw new at(p,f.name)}}return d&&(Di(l,e),Ti(l,e)),Li(o,l.options,e),Si(l.options,e),this.#_&&to(e,n,l.rawUnknown),this.#c()===T&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(l.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(l.argument,null,2))),{arguments_:o,booleanValues:c,commandArgs:r,parsedArgs:a,toolbox:l}}async#V(e,n,i){const s=this.getPluginManager();try{!this.#O&&s.hasPlugins()&&(await s.init({cli:this,cwd:this.#p,logger:this.#t}),this.#O=!0),await s.executeLifecycle("execute",n),await s.executeLifecycle("beforeCommand",n);let o;const c=i.global;if(c?.help){const a=this.#n.get("help");if(!a)throw new A("Help command not found","COMMAND_NOT_FOUND");o=await xe(a,n)}else if(c?.version??c?.V){const a=this.#n.get("version");if(!a)throw new A("Version command not found","COMMAND_NOT_FOUND");o=await xe(a,n)}else o=await xe(e,n);return await s.executeLifecycle("afterCommand",n,o),o}catch(o){throw await s.executeErrorHandlers(o,n),o}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new A("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#d=e.trim();const i=n.argv??Ae(),s=n.cwd??Vt();if(this.#e={...n,argv:i,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new A("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 A("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new A("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new A("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 A(`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.#c()===T&&console.debug(...d)}};this.#f=this.#e.packageVersion,this.#A=this.#e.packageName,this.#p=this.#e.cwd,this.#s="help",this.#r={};const o=n.fs;if(o!==void 0&&(typeof o!="object"||o===null))throw new A("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const c=n.exit;if(c!==void 0&&typeof c!="function")throw new A("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new A("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 A("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#k=n.fs,this.#C=n.exit,this.#$=n.env,this.#E=n.stdin??"",this.#x=n.maxArguments,this.#_=n.strictOptions??!1;const r=this.#y().CEREBRO_OUTPUT_LEVEL,l=r===void 0?Number.NaN:Number(r);this.#b=Number.isNaN(l)?fe:l,this.#n=new Map,this.#i=new Map,this.#o=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.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){be(e,"Command"),ae(e.name);const n=typeof e.execute=="function",i=typeof e.loader=="function";if(n&&i)throw new A(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!i)throw new A(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?ae(e.alias):Ze(e.alias,"Command alias").forEach(r=>ae(r))),e.argument&&be(e.argument,"Command argument"),e.options&&be(e.options,"Command options"),e.commandPath&&(Ze(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{ae(r)}));const s=Je(e.name,e.commandPath),o=H(s);if(this.#i.has(o))throw new A(`Command with path "${o}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const c=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),u=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!c&&u)throw new A(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)Te(r);if(Pi(e),ji(e),Vi(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),c&&a!==void 0)this.#n.set(o,e);else{if(!c&&a!==void 0&&!u){const r=Je(a.name,a.commandPath);this.#n.set(H(r),a)}this.#n.set(e.name,e)}if(this.#i.set(o,s),this.#o.set(o,e),this.#M(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const l of r){if(this.#c()===T&&this.#t.debug("adding alias",l),this.#n.has(l))throw new A(`Command alias "${l}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:l,commandName:e.name});this.#n.set(l,e)}}return this}addGlobalOption(e){const n=e,i=new Set(re.map(o=>o.name)),s=new Set(re.map(o=>o.alias).filter(Boolean));if(i.has(n.name))throw new A(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new A(`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.#l.map(o=>o.name)).has(n.name))throw new A(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",Te(n),this.#l.push(n),this}getGlobalOptions(){return this.#P()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#h?this.#h:(this.#h=new Pn(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.#A}getCommands(){return this.#n}getCwd(){return this.#p}dispose(){this.#I?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:i=!0,...s}=e;if(!this.#n.has("help")){const{default:m}=await import("../packem_chunks/help-command.js");this.addCommand(new m(this.#n))}const o=this.#S(),c=this.#i;this.#T();const a=this.#N();let u,r=[...a];this.#c()===T&&(this.#t.debug(`process.execPath: ${jt()}`),this.#t.debug(`process.execArgv: ${Dt().join(" ")}`),this.#t.debug(`process.argv: ${Ae().join(" ")}`));const l=Mi(c,[...a]);if(l.commandPath)u=l.commandPath,r=l.argv;else{if(a.length>1&&a[0]&&a[1]&&!Ne(a[0])&&!Ne(a[1])){const v=[];let b=0;for(;b<a.length;){const k=a[b];if(!k||Ne(k))break;v.push(k),b+=1}const C=H(v);if(v[0]&&!o.includes(v[0])){const k=this.#a(),V=z(C,k);throw new G(C,V)}}let m;try{m=Tn([null,...o],[...a])}catch(v){if(v instanceof Error&&v.name==="INVALID_COMMAND"&&"command"in v){const b=v.command,C=this.#a(),k=z(b,C);throw new G(b,k)}throw v}m.command&&(u=[m.command],r=m.argv)}if(!u)if(this.#s)u=[this.#s];else{const m=this.#a();throw new G("",m)}const d=H(u),h=this.#i.get(d);let f;if(h){if(f=this.#o.get(d),!f||H(h)!==d){const m=this.#a(),v=z(d,m);throw new G(d,v)}}else{const m=u.at(-1);if(f=m?this.#n.get(m):void 0,!f){const v=this.#a(),b=z(d,v);throw new G(d,b)}}if(typeof f.execute!="function"&&typeof f.loader!="function")return this.#t.error(`Command "${f.name}" has no function to execute.`),i?W(1):void 0;const p=r;let w,$;try{({commandArgs:w,toolbox:$}=this.#U(f,p,s,d))}catch(m){if(this.#t.error(m),i)return W(1);throw m}try{return await this.#V(f,$,w),i?W(0):void 0}catch(m){if(i)return this.#t.error(m),W(1);throw m}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:i=[],...s}=n;Ce(e,"Command name");const o=e.split(" ").filter(Boolean),c=H(o),a=this.#i.get(c)?this.#o.get(c):this.#n.get(e);if(!a){const d=this.#a(),h=z(c||e,d);throw new G(e,h)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new A(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const u=[...Xe(i,{maxArguments:this.#x})];this.#c()===T&&this.#t.debug(`running command '${e}' programmatically with args: ${u.join(", ")}`);const{commandArgs:r,toolbox:l}=this.#U(a,u,s,c||e);return this.#V(a,l,r)}clone(e){const n={...this.#e,...e},i=new gt(this.#d,n);for(const[s,o]of this.#n)i.#n.set(s,o);for(const[s,o]of this.#i)i.#i.set(s,[...o]);for(const[s,o]of this.#o)i.#o.set(s,o);for(const s of this.#l)i.#l.push(s);return i.#s=this.#s,i.#r={...this.#r},i.#M(),i}async getAction(e){Ce(e,"Command name");const n=e.split(" ").filter(Boolean),i=H(n),s=this.#i.get(i)?this.#o.get(i):this.#n.get(e);if(!s){const o=this.#a(),c=z(i||e,o);throw new G(e,c)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return mt(s);throw new A(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}};const is=(t,e)=>new no(t,e),io=globalThis.process??Object.create(null),Ye={versions:{}},se=new Proxy(io,{get(t,e){if(e in t)return t[e];if(e in Ye)return Ye[e]}}),oo=t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
@@ -1 +1 @@
1
- import{createRequire as b}from"node:module";import{P as v,J as j,b as W}from"./index-uBVnF4ji.js";import{p as h}from"../packem_chunks/cli-main.js";let $;const y=o=>($??=b(import.meta.url))(o),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=o=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[c,r]=m.versions.node.split(".").map(Number);if(c>22||c===22&&r>=3||c===20&&r>=16)return m.getBuiltinModule(o)}return y(o)},{watch:T}=p("node:fs"),{execFileSync:S}=p("node:child_process"),{createRequire:k}=p("node:module"),g=k(import.meta.url);let w;const q=()=>{if(w!==void 0)return w;try{g.resolve("fb-watchman")}catch{return w=!1,!1}try{S("watchman",["--version"],{stdio:"ignore",timeout:2e3})}catch{return w=!1,!1}return w=!0,!0},R=(o,c)=>{if(!q())return;let r;try{r=g("fb-watchman")}catch(s){h.warn(`[vis watch] fb-watchman failed to load, using native watcher: ${s.message}`);return}const a=new r.Client;a.on("error",s=>{h.warn(`[vis watch] watchman error: ${s.message}`)}),a.on("subscription",s=>{const t=s;if(!t.is_fresh_instance)for(const e of t.files??[])c(e)});for(const[s,t]of o.entries()){const e=v(t),i=`vis-watch-${s}-${process.pid}`;a.command(["watch-project",e],(l,f)=>{if(l){h.warn(`[vis watch] watchman could not watch ${t}: ${l.message}`);return}const u={expression:["allof",["type","f"]],fields:["name"]};f.relative_path&&(u.relative_root=f.relative_path),a.command(["subscribe",f.watch,i,u],n=>{n&&h.warn(`[vis watch] watchman subscribe failed for ${t}: ${n.message}`)})})}return{close:()=>{try{a.end()}catch{}}}},x=[/node_modules(?:\/|$)/,/\.git(?:\/|$)/,/\.vis(?:\/|$)/],B=(o,c)=>{const r=new Set,a=new Set;for(const[,e]of o){const i=e.task.hashDetails?.nodes;if(i)for(const l of Object.keys(i))r.add(l),a.add(j(v(c,l)))}const s=[...a].sort(),t=[];for(const e of s)t.some(i=>e===i||e.startsWith(`${i}/`))||t.push(e);return{directories:t,files:r}},D=(o,c,r)=>{const a=new Set;for(const s of o){const t=v(c,s);for(const e of r)if(t===e||t.startsWith(`${e}/`)){const i=W(e,t);i.length>0&&a.add(i)}}return s=>{const t=s.replaceAll("\\","/");return a.has(t)}},A=o=>{const c=o.replaceAll("\\","/");return x.some(r=>r.test(c))},J=o=>{const{debounceMs:c=150,filter:r,onChange:a,paths:s}=o;let t=new Set,e;const i=()=>{e=void 0;const n=[...t];t=new Set,n.length!==0&&Promise.resolve(a(n)).catch(d=>{h.error("[vis watch] onChange handler failed:",d)})},l=n=>{A(n)||r&&!r(n)||(t.add(n),e&&clearTimeout(e),e=setTimeout(i,c))},f=R(s,l);if(f)return{close:()=>{e&&clearTimeout(e),f.close()}};const u=[];for(const n of s)try{const d=T(n,{recursive:!0},(C,_)=>{_&&l(_)});u.push(d)}catch(d){h.warn(`[vis watch] unable to watch ${n}: ${d.message}`)}return{close:()=>{e&&clearTimeout(e);for(const n of u)try{n.close()}catch{}}}};export{D as a,B as c,J as s};
1
+ import{createRequire as b}from"node:module";import{P as v,J as j,b as W}from"./index-BLtnel38.js";import{p as h}from"../packem_chunks/cli-main.js";let $;const y=o=>($??=b(import.meta.url))(o),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=o=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[c,r]=m.versions.node.split(".").map(Number);if(c>22||c===22&&r>=3||c===20&&r>=16)return m.getBuiltinModule(o)}return y(o)},{watch:T}=p("node:fs"),{execFileSync:S}=p("node:child_process"),{createRequire:k}=p("node:module"),g=k(import.meta.url);let w;const q=()=>{if(w!==void 0)return w;try{g.resolve("fb-watchman")}catch{return w=!1,!1}try{S("watchman",["--version"],{stdio:"ignore",timeout:2e3})}catch{return w=!1,!1}return w=!0,!0},R=(o,c)=>{if(!q())return;let r;try{r=g("fb-watchman")}catch(s){h.warn(`[vis watch] fb-watchman failed to load, using native watcher: ${s.message}`);return}const a=new r.Client;a.on("error",s=>{h.warn(`[vis watch] watchman error: ${s.message}`)}),a.on("subscription",s=>{const t=s;if(!t.is_fresh_instance)for(const e of t.files??[])c(e)});for(const[s,t]of o.entries()){const e=v(t),i=`vis-watch-${s}-${process.pid}`;a.command(["watch-project",e],(l,f)=>{if(l){h.warn(`[vis watch] watchman could not watch ${t}: ${l.message}`);return}const u={expression:["allof",["type","f"]],fields:["name"]};f.relative_path&&(u.relative_root=f.relative_path),a.command(["subscribe",f.watch,i,u],n=>{n&&h.warn(`[vis watch] watchman subscribe failed for ${t}: ${n.message}`)})})}return{close:()=>{try{a.end()}catch{}}}},x=[/node_modules(?:\/|$)/,/\.git(?:\/|$)/,/\.vis(?:\/|$)/],B=(o,c)=>{const r=new Set,a=new Set;for(const[,e]of o){const i=e.task.hashDetails?.nodes;if(i)for(const l of Object.keys(i))r.add(l),a.add(j(v(c,l)))}const s=[...a].sort(),t=[];for(const e of s)t.some(i=>e===i||e.startsWith(`${i}/`))||t.push(e);return{directories:t,files:r}},D=(o,c,r)=>{const a=new Set;for(const s of o){const t=v(c,s);for(const e of r)if(t===e||t.startsWith(`${e}/`)){const i=W(e,t);i.length>0&&a.add(i)}}return s=>{const t=s.replaceAll("\\","/");return a.has(t)}},A=o=>{const c=o.replaceAll("\\","/");return x.some(r=>r.test(c))},J=o=>{const{debounceMs:c=150,filter:r,onChange:a,paths:s}=o;let t=new Set,e;const i=()=>{e=void 0;const n=[...t];t=new Set,n.length!==0&&Promise.resolve(a(n)).catch(d=>{h.error("[vis watch] onChange handler failed:",d)})},l=n=>{A(n)||r&&!r(n)||(t.add(n),e&&clearTimeout(e),e=setTimeout(i,c))},f=R(s,l);if(f)return{close:()=>{e&&clearTimeout(e),f.close()}};const u=[];for(const n of s)try{const d=T(n,{recursive:!0},(C,_)=>{_&&l(_)});u.push(d)}catch(d){h.warn(`[vis watch] unable to watch ${n}: ${d.message}`)}return{close:()=>{e&&clearTimeout(e);for(const n of u)try{n.close()}catch{}}}};export{D as a,B as c,J as s};
@@ -1,4 +1,4 @@
1
- import{createRequire as K}from"node:module";import{w as g,l as A,z as U,v as S,P as Q,d as X,J as Y}from"./index-uBVnF4ji.js";import{n as w}from"../packem_chunks/catalog.js";import{a as te}from"./readJsonSync-DweZd5ZA-0eZh9sGm.js";import{s as ue}from"./watch-BXOOX7lx.js";let G;const H=e=>(G??=K(import.meta.url))(e),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=e=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[t,s]=x.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return x.getBuiltinModule(e)}return H(e)},{createHash:m}=v("node:crypto"),{fileURLToPath:Z,pathToFileURL:ee}=v("node:url"),{spawnSync:se,spawn:ne}=v("node:child_process"),{openSync:re,writeSync:oe,closeSync:ie,statSync:ae,readFileSync:N,mkdirSync:ce,writeFileSync:le}=v("node:fs"),{availableParallelism:b}=v("node:os"),W=(e,t)=>{for(const s of["dependencies","devDependencies","optionalDependencies","peerDependencies"]){const n=e[s];if(n&&typeof n[t]=="string")return n[t]}},k=(e,t)=>{for(const s of t){const n=g(e,s);if(A(n))return n}},de=e=>{const t=g(e,"package.json");if(!A(t))return{};try{return te(t)}catch{return{}}},st=(e,t)=>{const s=de(e),n=new Map;for(const o of t){const r=o.detect(e,s);r&&n.set(o.id,r)}return n},fe={error:"error",info:"info",information:"info",warning:"warning"},nt={argsCheck:(e,t)=>j(e,t,!1),argsFix:(e,t)=>j(e,t,!0),bin:()=>["pnpm","exec","biome"],cacheKey:(e,t)=>{const s=["biome",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=W(t,w.biome.packageNames[0]),n=k(e,w.biome.configFiles);if(!(!s&&!n))return{adapter:"biome",configFile:n,declared:!!s,declaredVersion:s,root:e}},extensions:["astro","cjs","css","cts","js","json","jsonc","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"biome",kind:"both",parse:(e,t)=>{if(!e.stdout.trim())return[];let s;try{s=JSON.parse(e.stdout)}catch{return[{adapter:"biome",file:t.root,fixable:!1,message:`biome output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const o of s.diagnostics??[]){const r=o.location?.start,i=o.location?.end,a=pe(t.root,o.location?.path),c=o.category??"",l=c==="format"||c.startsWith("format/");n.push({adapter:"biome",column:r?.column&&r.column>0?r.column:void 0,endColumn:i?.column&&i.column>0?i.column:void 0,endLine:i?.line&&i.line>0?i.line:void 0,file:a,fixable:!0,line:r?.line&&r.line>0?r.line:void 0,message:l?"Code style issues would be auto-fixed":o.message??"",ruleId:c||void 0,severity:fe[o.severity??""]??"warning"})}return n}},j=(e,t,s)=>{const n=["check","--reporter=json"];return s&&n.push("--write"),typeof t.maxWarnings=="number"&&n.push(`--max-diagnostics=${String(t.maxWarnings)}`),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},pe=(e,t)=>{const s=typeof t=="string"?t:t?.file;return s?s.startsWith("/")||/^[a-z]:[\\/]/i.test(s)?s:g(e,s):e},D=e=>t=>{const s=k(t,w.deno.configFiles);if(s)return{adapter:e,configFile:s,declared:!1,root:t}},B=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),rt={argsCheck:(e,t)=>F(e,t,!1),argsFix:(e,t)=>F(e,t,!0),bin:()=>["deno","lint"],cacheKey:(e,t)=>{const s=["deno-lint",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:D("deno-lint"),extensions:["js","jsx","mjs","mts","ts","tsx"],id:"deno-lint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let s;try{s=JSON.parse(e.stdout)}catch{return[{adapter:"deno-lint",file:t.root,fixable:!1,message:`deno lint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const o of s.diagnostics??[]){const r=o.range?.start,i=o.range?.end;n.push({adapter:"deno-lint",column:r?.col===void 0?void 0:r.col+1,endColumn:i?.col===void 0?void 0:i.col+1,endLine:i?.line===void 0?void 0:i.line+1,file:ge(o.filename??t.root,t.root),fixable:!1,line:r?.line===void 0?void 0:r.line+1,message:o.message??"",ruleId:o.code,severity:"warning"})}return n}},ot={argsCheck:(e,t)=>I(e,t,!1),argsFix:(e,t)=>I(e,t,!0),bin:()=>["deno","fmt"],cacheKey:(e,t)=>{const s=["deno-fmt",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:D("deno-fmt"),extensions:["astro","cjs","css","cts","html","ipynb","js","json","jsonc","jsx","less","md","mjs","mts","sass","scss","sql","svelte","ts","tsx","vue","yaml","yml"],id:"deno-fmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[],n=new Set;for(const o of e.stdout.split(/\r?\n/)){const r=/^from (.+):$/.exec(o);if(!r)continue;const i=r[1];n.has(i)||(n.add(i),s.push({adapter:"deno-fmt",file:B(i)?i:`${t.root}/${i}`,fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},F=(e,t,s)=>{const n=["--json"];return s&&n.push("--fix"),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},I=(e,t,s)=>{const n=[];return s||n.push("--check"),t.quiet&&n.push("--quiet"),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},ge=(e,t)=>e.startsWith("file://")?Z(e):B(e)?e:`${t}/${e}`,J="pyproject.toml",he=/^\[tool\.ruff(?:\.[\w-]+)*\]\s*$/m,me=/^Would reformat:?\s+(.+)$/,ye=e=>{const t=g(e,J);if(!A(t))return!1;try{const s=U(t);return he.test(s)}catch{return!1}},P=e=>(t,s)=>{const n=w.ruff.packageNames.map(a=>W(s,a)).find(a=>a!==void 0),o=k(t,w.ruff.configFiles),r=o?void 0:ye(t)?g(t,J):void 0,i=o??r;if(!(!n&&!i))return{adapter:e,configFile:i,declared:!!n,declaredVersion:n,root:t}},xe=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),z=(e,t)=>e?xe(e)?e:g(t,e):t,$e=e=>me.exec(e)?.[1]?.trim(),it={argsCheck:(e,t)=>R(e,t,!1),argsFix:(e,t)=>R(e,t,!0),bin:()=>["ruff","check"],cacheKey:(e,t)=>{const s=["ruff-check",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:P("ruff-check"),extensions:["py","pyi"],id:"ruff-check",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let s;try{s=JSON.parse(e.stdout)}catch{return[{adapter:"ruff-check",file:t.root,fixable:!1,message:`ruff check output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const o of s){const r=o.location,i=o.end_location;n.push({adapter:"ruff-check",column:r?.column,endColumn:i?.column,endLine:i?.row,file:z(o.filename,t.root),fixable:!!o.fix,line:r?.row,message:o.message??"",ruleId:o.code,severity:"warning"})}return n}},at={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["ruff","format"],cacheKey:(e,t)=>{const s=["ruff-fmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:P("ruff-fmt"),extensions:["py","pyi"],id:"ruff-fmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[],n=new Set;for(const o of e.stdout.split(/\r?\n/)){const r=$e(o);!r||n.has(r)||(n.add(r),s.push({adapter:"ruff-fmt",file:z(r,t.root),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},R=(e,t,s)=>{const n=["--output-format=json"];return s&&n.push("--fix"),t.quiet&&n.push("--quiet"),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},L=(e,t,s)=>{const n=[];return s||n.push("--check"),t.quiet&&n.push("--quiet"),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},ct=(e,t)=>{const s=$(e,["diff","--name-only","--diff-filter=ACMR","-z",`${t}...HEAD`]);if(s===void 0)return;const n=$(e,["diff","--name-only","--diff-filter=ACMR","-z"]),o=$(e,["diff","--name-only","--diff-filter=ACMR","--cached","-z"]),r=$(e,["ls-files","--others","--exclude-standard","-z"]),i=new Set;for(const a of[s,n??"",o??"",r??""])for(const c of a.split("\0"))c.length!==0&&i.add(S(c)?c:g(e,c));return[...i].sort()},lt=e=>{const t=$(e,["diff","--name-only","--diff-filter=ACMR","--cached","-z"]);if(t===void 0)return;const s=new Set;for(const n of t.split("\0"))n.length!==0&&s.add(S(n)?n:g(e,n));return[...s].sort()},$=(e,t)=>{const s=se("git",[...t],{cwd:e,encoding:"utf8",timeout:1e4});if(s.status===0)return s.stdout},ut=(e,t)=>{const s=new Set(t.map(r=>r.toLowerCase())),n=[],o=new Set;for(const r of e){const i=r.lastIndexOf(".");if(i===-1||i===r.length-1)continue;const a=r.slice(i+1).toLowerCase();s.has(a)&&(o.has(r)||(o.add(r),n.push(r)))}return n},we=new Set(["-","stdout"]),M=e=>({close:()=>{},write:t=>{e.write(t)}}),ve=e=>{X(Y(e));const t=re(e,"w");let s=[];return{close:()=>{s.length>0&&(oe(t,s.join("")),s=[]),ie(t)},write:n=>{s.push(n)}}},dt=e=>{const{cwd:t,target:s}=e;if(s===void 0||we.has(s))return M(process.stdout);if(s==="stderr")return M(process.stderr);const n=S(s)?s:Q(t,s);return ve(n)},q=["oxlint","oxfmt","biome","eslint","dprint","prettier","stylelint","ruff-check","ruff-fmt","markdownlint","shellcheck","deno-lint","deno-fmt"],ft=(e,t)=>{const s=new Map(e.map(i=>[i.id,i])),n=[],o=new Set,r=t&&t.length>0?t:q;for(const i of r){const a=s.get(i);a&&!o.has(i)&&(n.push(a),o.add(i))}if(t&&t.length>0)for(const i of q){const a=s.get(i);a&&!o.has(i)&&(n.push(a),o.add(i))}for(const i of e)o.has(i.id)||(n.push(i),o.add(i.id));return n},pt=(e,t,s)=>{const n=[];for(const o of t){const r=e.get(o.id);r&&Se(o.kind,s)&&n.push({adapter:o,presence:r})}return n},Se=(e,t)=>e===t||e==="both",gt=(e,t,s={})=>{const n=new Map;for(const o of e){const r=Ce(o),i=Ae(r,t,s);if(!i)continue;const a=n.get(i);a?a.push(o):n.set(i,[o])}return n},Ce=e=>{const t=e.lastIndexOf(".");return t===-1||t===e.length-1?"":e.slice(t+1).toLowerCase()},Ae=(e,t,s)=>{const n=s[e];if(n&&t.some(o=>o.adapter.id===n))return n;for(const{adapter:o}of t)if(o.extensions.includes(e))return o.id},ke=e=>e==="error"?"error":e==="warning"?"warning":"notice",E=e=>e.replaceAll("%","%25").replaceAll("\r","%0D").replaceAll(`
1
+ import{createRequire as K}from"node:module";import{w as g,l as A,z as U,v as S,P as Q,d as X,J as Y}from"./index-BLtnel38.js";import{n as w}from"../packem_chunks/catalog.js";import{a as te}from"./readJsonSync-DweZd5ZA-CtrDlqpb.js";import{s as ue}from"./watch-D_oAxW_Z.js";let G;const H=e=>(G??=K(import.meta.url))(e),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=e=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[t,s]=x.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return x.getBuiltinModule(e)}return H(e)},{createHash:m}=v("node:crypto"),{fileURLToPath:Z,pathToFileURL:ee}=v("node:url"),{spawnSync:se,spawn:ne}=v("node:child_process"),{openSync:re,writeSync:oe,closeSync:ie,statSync:ae,readFileSync:N,mkdirSync:ce,writeFileSync:le}=v("node:fs"),{availableParallelism:b}=v("node:os"),W=(e,t)=>{for(const s of["dependencies","devDependencies","optionalDependencies","peerDependencies"]){const n=e[s];if(n&&typeof n[t]=="string")return n[t]}},k=(e,t)=>{for(const s of t){const n=g(e,s);if(A(n))return n}},de=e=>{const t=g(e,"package.json");if(!A(t))return{};try{return te(t)}catch{return{}}},st=(e,t)=>{const s=de(e),n=new Map;for(const o of t){const r=o.detect(e,s);r&&n.set(o.id,r)}return n},fe={error:"error",info:"info",information:"info",warning:"warning"},nt={argsCheck:(e,t)=>j(e,t,!1),argsFix:(e,t)=>j(e,t,!0),bin:()=>["pnpm","exec","biome"],cacheKey:(e,t)=>{const s=["biome",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=W(t,w.biome.packageNames[0]),n=k(e,w.biome.configFiles);if(!(!s&&!n))return{adapter:"biome",configFile:n,declared:!!s,declaredVersion:s,root:e}},extensions:["astro","cjs","css","cts","js","json","jsonc","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"biome",kind:"both",parse:(e,t)=>{if(!e.stdout.trim())return[];let s;try{s=JSON.parse(e.stdout)}catch{return[{adapter:"biome",file:t.root,fixable:!1,message:`biome output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const o of s.diagnostics??[]){const r=o.location?.start,i=o.location?.end,a=pe(t.root,o.location?.path),c=o.category??"",l=c==="format"||c.startsWith("format/");n.push({adapter:"biome",column:r?.column&&r.column>0?r.column:void 0,endColumn:i?.column&&i.column>0?i.column:void 0,endLine:i?.line&&i.line>0?i.line:void 0,file:a,fixable:!0,line:r?.line&&r.line>0?r.line:void 0,message:l?"Code style issues would be auto-fixed":o.message??"",ruleId:c||void 0,severity:fe[o.severity??""]??"warning"})}return n}},j=(e,t,s)=>{const n=["check","--reporter=json"];return s&&n.push("--write"),typeof t.maxWarnings=="number"&&n.push(`--max-diagnostics=${String(t.maxWarnings)}`),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},pe=(e,t)=>{const s=typeof t=="string"?t:t?.file;return s?s.startsWith("/")||/^[a-z]:[\\/]/i.test(s)?s:g(e,s):e},D=e=>t=>{const s=k(t,w.deno.configFiles);if(s)return{adapter:e,configFile:s,declared:!1,root:t}},B=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),rt={argsCheck:(e,t)=>F(e,t,!1),argsFix:(e,t)=>F(e,t,!0),bin:()=>["deno","lint"],cacheKey:(e,t)=>{const s=["deno-lint",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:D("deno-lint"),extensions:["js","jsx","mjs","mts","ts","tsx"],id:"deno-lint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let s;try{s=JSON.parse(e.stdout)}catch{return[{adapter:"deno-lint",file:t.root,fixable:!1,message:`deno lint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const o of s.diagnostics??[]){const r=o.range?.start,i=o.range?.end;n.push({adapter:"deno-lint",column:r?.col===void 0?void 0:r.col+1,endColumn:i?.col===void 0?void 0:i.col+1,endLine:i?.line===void 0?void 0:i.line+1,file:ge(o.filename??t.root,t.root),fixable:!1,line:r?.line===void 0?void 0:r.line+1,message:o.message??"",ruleId:o.code,severity:"warning"})}return n}},ot={argsCheck:(e,t)=>I(e,t,!1),argsFix:(e,t)=>I(e,t,!0),bin:()=>["deno","fmt"],cacheKey:(e,t)=>{const s=["deno-fmt",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:D("deno-fmt"),extensions:["astro","cjs","css","cts","html","ipynb","js","json","jsonc","jsx","less","md","mjs","mts","sass","scss","sql","svelte","ts","tsx","vue","yaml","yml"],id:"deno-fmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[],n=new Set;for(const o of e.stdout.split(/\r?\n/)){const r=/^from (.+):$/.exec(o);if(!r)continue;const i=r[1];n.has(i)||(n.add(i),s.push({adapter:"deno-fmt",file:B(i)?i:`${t.root}/${i}`,fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},F=(e,t,s)=>{const n=["--json"];return s&&n.push("--fix"),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},I=(e,t,s)=>{const n=[];return s||n.push("--check"),t.quiet&&n.push("--quiet"),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},ge=(e,t)=>e.startsWith("file://")?Z(e):B(e)?e:`${t}/${e}`,J="pyproject.toml",he=/^\[tool\.ruff(?:\.[\w-]+)*\]\s*$/m,me=/^Would reformat:?\s+(.+)$/,ye=e=>{const t=g(e,J);if(!A(t))return!1;try{const s=U(t);return he.test(s)}catch{return!1}},P=e=>(t,s)=>{const n=w.ruff.packageNames.map(a=>W(s,a)).find(a=>a!==void 0),o=k(t,w.ruff.configFiles),r=o?void 0:ye(t)?g(t,J):void 0,i=o??r;if(!(!n&&!i))return{adapter:e,configFile:i,declared:!!n,declaredVersion:n,root:t}},xe=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),z=(e,t)=>e?xe(e)?e:g(t,e):t,$e=e=>me.exec(e)?.[1]?.trim(),it={argsCheck:(e,t)=>R(e,t,!1),argsFix:(e,t)=>R(e,t,!0),bin:()=>["ruff","check"],cacheKey:(e,t)=>{const s=["ruff-check",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:P("ruff-check"),extensions:["py","pyi"],id:"ruff-check",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let s;try{s=JSON.parse(e.stdout)}catch{return[{adapter:"ruff-check",file:t.root,fixable:!1,message:`ruff check output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const n=[];for(const o of s){const r=o.location,i=o.end_location;n.push({adapter:"ruff-check",column:r?.column,endColumn:i?.column,endLine:i?.row,file:z(o.filename,t.root),fixable:!!o.fix,line:r?.row,message:o.message??"",ruleId:o.code,severity:"warning"})}return n}},at={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["ruff","format"],cacheKey:(e,t)=>{const s=["ruff-fmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return m("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:P("ruff-fmt"),extensions:["py","pyi"],id:"ruff-fmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[],n=new Set;for(const o of e.stdout.split(/\r?\n/)){const r=$e(o);!r||n.has(r)||(n.add(r),s.push({adapter:"ruff-fmt",file:z(r,t.root),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},R=(e,t,s)=>{const n=["--output-format=json"];return s&&n.push("--fix"),t.quiet&&n.push("--quiet"),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},L=(e,t,s)=>{const n=[];return s||n.push("--check"),t.quiet&&n.push("--quiet"),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},ct=(e,t)=>{const s=$(e,["diff","--name-only","--diff-filter=ACMR","-z",`${t}...HEAD`]);if(s===void 0)return;const n=$(e,["diff","--name-only","--diff-filter=ACMR","-z"]),o=$(e,["diff","--name-only","--diff-filter=ACMR","--cached","-z"]),r=$(e,["ls-files","--others","--exclude-standard","-z"]),i=new Set;for(const a of[s,n??"",o??"",r??""])for(const c of a.split("\0"))c.length!==0&&i.add(S(c)?c:g(e,c));return[...i].sort()},lt=e=>{const t=$(e,["diff","--name-only","--diff-filter=ACMR","--cached","-z"]);if(t===void 0)return;const s=new Set;for(const n of t.split("\0"))n.length!==0&&s.add(S(n)?n:g(e,n));return[...s].sort()},$=(e,t)=>{const s=se("git",[...t],{cwd:e,encoding:"utf8",timeout:1e4});if(s.status===0)return s.stdout},ut=(e,t)=>{const s=new Set(t.map(r=>r.toLowerCase())),n=[],o=new Set;for(const r of e){const i=r.lastIndexOf(".");if(i===-1||i===r.length-1)continue;const a=r.slice(i+1).toLowerCase();s.has(a)&&(o.has(r)||(o.add(r),n.push(r)))}return n},we=new Set(["-","stdout"]),M=e=>({close:()=>{},write:t=>{e.write(t)}}),ve=e=>{X(Y(e));const t=re(e,"w");let s=[];return{close:()=>{s.length>0&&(oe(t,s.join("")),s=[]),ie(t)},write:n=>{s.push(n)}}},dt=e=>{const{cwd:t,target:s}=e;if(s===void 0||we.has(s))return M(process.stdout);if(s==="stderr")return M(process.stderr);const n=S(s)?s:Q(t,s);return ve(n)},q=["oxlint","oxfmt","biome","eslint","dprint","prettier","stylelint","ruff-check","ruff-fmt","markdownlint","shellcheck","deno-lint","deno-fmt"],ft=(e,t)=>{const s=new Map(e.map(i=>[i.id,i])),n=[],o=new Set,r=t&&t.length>0?t:q;for(const i of r){const a=s.get(i);a&&!o.has(i)&&(n.push(a),o.add(i))}if(t&&t.length>0)for(const i of q){const a=s.get(i);a&&!o.has(i)&&(n.push(a),o.add(i))}for(const i of e)o.has(i.id)||(n.push(i),o.add(i.id));return n},pt=(e,t,s)=>{const n=[];for(const o of t){const r=e.get(o.id);r&&Se(o.kind,s)&&n.push({adapter:o,presence:r})}return n},Se=(e,t)=>e===t||e==="both",gt=(e,t,s={})=>{const n=new Map;for(const o of e){const r=Ce(o),i=Ae(r,t,s);if(!i)continue;const a=n.get(i);a?a.push(o):n.set(i,[o])}return n},Ce=e=>{const t=e.lastIndexOf(".");return t===-1||t===e.length-1?"":e.slice(t+1).toLowerCase()},Ae=(e,t,s)=>{const n=s[e];if(n&&t.some(o=>o.adapter.id===n))return n;for(const{adapter:o}of t)if(o.extensions.includes(e))return o.id},ke=e=>e==="error"?"error":e==="warning"?"warning":"notice",E=e=>e.replaceAll("%","%25").replaceAll("\r","%0D").replaceAll(`
2
2
  `,"%0A"),_=e=>E(e).replaceAll(",","%2C").replaceAll(":","%3A").replaceAll("=","%3D"),be=(e,t)=>t&&e.startsWith(`${t}/`)?e.slice(t.length+1):e,je=(e,t)=>e.file!==t.file?e.file<t.file?-1:1:(e.line??0)-(t.line??0)||(e.column??0)-(t.column??0),Fe=(e,t)=>{const s=ke(e.severity),n=be(e.file,t),o=e.ruleId?`${e.adapter}(${e.ruleId})`:e.adapter,r=[`file=${_(n)}`];return e.line!==void 0&&r.push(`line=${String(e.line)}`),e.endLine!==void 0&&r.push(`endLine=${String(e.endLine)}`),e.column!==void 0&&r.push(`col=${String(e.column)}`),e.endColumn!==void 0&&r.push(`endColumn=${String(e.endColumn)}`),r.push(`title=${_(o)}`),`::${s} ${r.join(",")}::${E(e.message)}
3
3
  `},ht=e=>e.runs.flatMap(t=>[...t.findings]).sort(je).map(t=>Fe(t,e.workspaceRoot)).join(""),y=e=>e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;"),Ie=e=>`<![CDATA[${e.replaceAll("]]>","]]]]><![CDATA[>")}]]>`,Re=(e,t)=>e.file!==t.file?e.file<t.file?-1:1:(e.line??0)-(t.line??0)||(e.column??0)-(t.column??0),Le=e=>e==="error"?"error":e==="warning"?"warning":"info",Me=(e,t)=>{let{file:s}=e;return t&&e.file.startsWith(`${t}/`)&&(s=e.file.slice(t.length+1)),e.line===void 0?s:e.column===void 0?`${s}:${String(e.line)}`:`${s}:${String(e.line)}:${String(e.column)}`},qe=(e,t,s)=>{const n=Me(e,s),o=Le(e.severity),r=e.ruleId?`[${e.ruleId}] ${e.message}`:e.message;return[` <testcase classname="${y(t)}" name="${y(n)}">`,` <failure type="${y(o)}" message="${y(r)}">${Ie(e.message)}</failure>`," </testcase>",""].join(`
4
4
  `)},_e=(e,t,s)=>{const n=[...e.findings].sort(Re),o=n.filter(l=>l.severity==="error").length,r=n.filter(l=>l.severity==="warning").length,i=n.length,a=(e.durationMs/1e3).toFixed(3),c=n.map(l=>qe(l,e.adapter,s)).join("");return` <testsuite ${[`name="${y(e.adapter)}"`,`tests="${String(i)}"`,`failures="${String(o)}"`,'errors="0"',`skipped="${String(r)}"`,`time="${a}"`,`timestamp="${t}"`].join(" ")}>
@@ -1 +1 @@
1
- import{c as r}from"../packem_shared/compile-cache-B_Vf_WxT.js";import{p as o}from"../packem_shared/augment-24KX2nkI.js";import{r as p}from"../packem_chunks/ts-loader.js";r();p();await o(process.cwd());
1
+ import{c as r}from"../packem_shared/compile-cache-B_Vf_WxT.js";import{p as o}from"../packem_shared/augment-BkJxi_GW.js";import{r as p}from"../packem_chunks/ts-loader.js";r();p();await o(process.cwd());