@visulima/vis 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## @visulima/vis [1.0.7](https://github.com/visulima/visulima/compare/%40visulima%2Fvis%401.0.6...%40visulima%2Fvis%401.0.7) (2026-07-26)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/tui:** upgraded to 1.0.7
7
+ * **@visulima/cerebro:** upgraded to 3.0.2
8
+ * **@visulima/colorize:** upgraded to 2.0.1
9
+ * **@visulima/fs:** upgraded to 5.0.7
10
+ * **@visulima/package:** upgraded to 5.0.7
11
+ * **@visulima/pail:** upgraded to 4.0.1
12
+ * **@visulima/tsconfig:** upgraded to 3.2.2
13
+
1
14
  ## @visulima/vis [1.0.6](https://github.com/visulima/visulima/compare/%40visulima%2Fvis%401.0.5...%40visulima%2Fvis%401.0.6) (2026-07-26)
2
15
 
3
16
 
package/dist/bin.js CHANGED
@@ -1 +1 @@
1
- import"./packem_shared/compile-cache-B_Vf_WxT.js";import"./packem_shared/bin-CMAImDGD.js";
1
+ import"./packem_shared/compile-cache-B_Vf_WxT.js";import"./packem_shared/bin-BZ_m_tag.js";
package/dist/binx.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{V as o,h as c,e as i,r as p}from"./packem_shared/index-BtpMNLKq.js";import{c as a}from"./packem_shared/compile-cache-B_Vf_WxT.js";import{m as r}from"./packem_shared/package-version-gyjskW3N.js";process.argv.includes("--no-color")&&(process.env.NO_COLOR="1",process.env.FORCE_COLOR="0");process.argv.slice(2).some(s=>s==="--version"||s==="-v"||s==="-V")&&(process.stdout.write(`${r()}
2
+ import{V as o,h as c,e as i,r as p}from"./packem_shared/index-ZfYDID5E.js";import{c as a}from"./packem_shared/compile-cache-B_Vf_WxT.js";import{m as r}from"./packem_shared/package-version-DBJLduJL.js";process.argv.includes("--no-color")&&(process.env.NO_COLOR="1",process.env.FORCE_COLOR="0");process.argv.slice(2).some(s=>s==="--version"||s==="-v"||s==="-V")&&(process.stdout.write(`${r()}
3
3
  `),process.exit(0));process.argv.splice(2,0,"dlx");a();const e=o("visx",{packageName:"visx",packageVersion:r()}),n=process.argv.includes("--debug")||!!process.env.DEBUG;e.addPlugin(c({detailed:n,exitOnError:!1}));e.addCommand(i);p(e);
@@ -1 +1 @@
1
- import{V as r,h as o,e as i,r as n}from"../packem_shared/index-BtpMNLKq.js";import{e as t}from"../packem_shared/index-DjTWo3sH.js";import{m as d}from"../packem_shared/package-version-gyjskW3N.js";const l=async()=>{const e=r("vis",{packageName:"vis",packageVersion:d()}),a=process.argv.includes("--debug")||!!process.env.DEBUG;e.addPlugin(o({detailed:a,exitOnError:!1})),e.addGlobalOption({description:"Target JS runtime: node (default) or bun. Overrides VIS_RUNTIME; falls back to lockfile detection.",name:"runtime",type:String}),e.addCommand(t),e.addCommand(i),await n(e)};export{l as runExecCli};
1
+ import{V as r,h as o,e as i,r as n}from"../packem_shared/index-ZfYDID5E.js";import{e as t}from"../packem_shared/index-DjTWo3sH.js";import{m as d}from"../packem_shared/package-version-DBJLduJL.js";const l=async()=>{const e=r("vis",{packageName:"vis",packageVersion:d()}),a=process.argv.includes("--debug")||!!process.env.DEBUG;e.addPlugin(o({detailed:a,exitOnError:!1})),e.addGlobalOption({description:"Target JS runtime: node (default) or bun. Overrides VIS_RUNTIME; falls back to lockfile detection.",name:"runtime",type:String}),e.addCommand(t),e.addCommand(i),await n(e)};export{l as runExecCli};
@@ -1,4 +1,4 @@
1
- import{createRequire as iY}from"node:module";import{c as nY,e as aY,V as tY,h as sY,r as rY}from"../packem_shared/index-BtpMNLKq.js";import{T as ri,f as Y,v as K,m as j,a as gn,u as Hn,H as G0,y as ts,o as uY,O as dY,B as Ja,A as A0}from"../packem_shared/index-D75r1yKp.js";import{S as Q0,m as ur}from"../packem_shared/package-version-gyjskW3N.js";import{L as lY}from"../packem_shared/public-api-WqUCiyIe.js";import{r as T,B as gY,D as Xc,J as W0,K as hY,M as Hc,P as Ko,Y as F0,m as k,n as I,i as D,Q as cY,v as Mo,b as pY,S as vY,W as Mc,e as yY,l as fY,a as zd,U as Nc,$ as mY,d as bY,c as wY,f as jY,X as qd,a0 as Vd,a1 as kY,a2 as SY}from"./catalog.js";import{f as hn,i as Rc,V as YY,L as _0,g as LY,d as cn,M as Ud,N as CY,_ as xa,c as Mt,O as I0}from"../packem_shared/en-BRcjb70R.js";import{I as en}from"../packem_shared/index-B0EsgdzO.js";import{findVisConfigFile as In,loadVisConfig as Oc}from"./CONFIG_FILES.js";import{a as We}from"../packem_shared/readJsonSync-DuMMeB3s-wlhgSHes.js";import{s as XY}from"../packem_shared/bin-CMAImDGD.js";import{V as Qu,j as ho,s as Jt,q as zo,E as wa,Q as HY,a as Dr,I as MY}from"../packem_shared/index.server-qvZ-cy29.js";import{s as el}from"../packem_shared/index-BAe6e0XE.js";import{A as Gc}from"../packem_shared/pm-runner-D5NWL8yv.js";import{m as EY}from"./ts-loader.js";import{getMainWorktreeRoot as OY,Cache as lr,readLastRunSummary as U0,getLastRunSummaryPath as il,parseCacheSize as GY,digestFile as ef}from"@visulima/task-runner";import{e as zY}from"../packem_shared/index-DjTWo3sH.js";const oY=iY(import.meta.url),lt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,zi=e=>{if(typeof lt<"u"&&lt.versions&&lt.versions.node){const[i,o]=lt.versions.node.split(".").map(Number);if(i>22||i===22&&o>=3||i===20&&o>=16)return lt.getBuiltinModule(e)}return oY(e)},{spawnSync:ba,execSync:K0,execFileSync:$Y,execFile:ZY}=zi("node:child_process"),{writeFileSync:Xe,existsSync:Pc,renameSync:z0,statSync:Mn,rmSync:Ta,readdirSync:Oi,copyFileSync:JY,unlinkSync:pn,mkdirSync:xY,cpSync:TY,readFileSync:DY,watch:BY}=zi("node:fs"),{createRequire:ss}=zi("node:module"),{dirname:q0,delimiter:Ec,resolve:dr}=zi("node:path"),{createInterface:V0}=zi("node:readline"),{homedir:NY,platform:RY,tmpdir:PY}=zi("node:os"),{readFile:of,readdir:rs,stat:Pa,realpath:Ac,rm:cg,mkdtemp:AY,mkdir:QY}=zi("node:fs/promises"),{createServer:WY,STATUS_CODES:FY}=zi("node:http"),{Http2ServerRequest:ja,constants:_Y}=zi("node:http2"),{Readable:Qc}=zi("node:stream"),{randomUUID:IY}=zi("node:crypto"),{fileURLToPath:KY}=zi("node:url");function nf(e,i,o,n){let a,t,s;t=o,s=n;const r=lY(i,t,s??a);ri(e,r,a)}const le=(e,i)=>async()=>({default:(await e())[i]}),qY=new Set(["--cwd"]),VY=new Set(["--help","--version","-h","-V"]),UY=e=>{const i=[];for(let o=0;o<e.length;o+=1){const n=e[o];if(n!==void 0){if(VY.has(n))return!1;if(n.startsWith("-")){const a=n.indexOf("="),t=a===-1?n:n.slice(0,a);if(qY.has(t)&&a===-1){const s=e[o+1];s!==void 0&&!s.startsWith("-")&&(o+=1)}continue}i.push(n)}}return i.length===1&&i[0]==="migrate"},eL=e=>{if(e.length===0)return!1;for(const i of e){const o=i.codePointAt(0)??0;return!(o<=127||o<=255)}return!1};let iL=class{buffer="";timer;onFlush;timeout;constructor({onFlush:i,timeout:o}){this.onFlush=i,this.timeout=o}add(i){this.buffer+=i,this.timer!==void 0&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},this.timeout)}flush(){if(this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer.length>0){const i=this.buffer;this.buffer="",this.onFlush(i)}}destroy(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer=""}};const xs=e=>{const i=/rgb:([\da-f]{2,4})\/([\da-f]{2,4})\/([\da-f]{2,4})/i.exec(e);if(!i)return null;const o=n=>n.length<=2?n.padStart(2,"0"):n.slice(0,2);return`#${o(i[1])}${o(i[2])}${o(i[3])}`},oL=()=>{const e=process.env.TERM_PROGRAM??"";return new Set(["Alacritty","contour","foot","Ghostty","iTerm2","iTerm.app","kitty","rio","WezTerm"]).has(e)?!0:(process.env.TERM??"").startsWith("xterm")||!!process.env.WT_SESSION},Ts=(e,i,o,n=500)=>new Promise(a=>{let t="",s;const r=()=>{s&&clearTimeout(s),e.removeListener("data",u)},u=d=>{if(t+=d.toString(),t.length>256){r(),a(null);return}(t.includes("\x07")||t.includes("\x1B\\"))&&(r(),a(t))};s=setTimeout(()=>{r(),a(null)},n),e.on("data",u),i.write(o)}),nL=async(e,i,o=500)=>{const n={},a=await Ts(e,i,"\x1B]10;?\x07",o);if(a){const u=xs(a);u&&(n.foreground=u)}const t=await Ts(e,i,"\x1B]11;?\x07",o);if(t){const u=xs(t);u&&(n.background=u)}const s=await Ts(e,i,"\x1B]12;?\x07",o);if(s){const u=xs(s);u&&(n.cursor=u)}const r=[];for(let u=0;u<16;u++){const d=await Ts(e,i,`\x1B]4;${u};?\x07`,o);if(d){const l=xs(d);r.push(l??"")}else r.push("")}return r.some(u=>u.length>0)&&(n.colors=r),n},af=()=>T.useContext(gY),tf=()=>{const{stdout:e}=af(),[i,o]=T.useState(()=>Xc(e));return T.useEffect(()=>{const n=()=>{o(Xc(e))};return e.on("resize",n),()=>{e.off("resize",n)}},[e]),i},aL=()=>T.useContext(W0),sf=()=>T.useContext(W0);class tL{#o;#e=new Set;constructor(i){this.#o={applyProgress:null,checkedItems:new Set(i.map(o=>o.entry.id)),error:null,focusedPanel:"list",items:i,phase:"browsing",selectedIndex:0}}getSnapshot=()=>this.#o;subscribe=i=>(this.#e.add(i),()=>{this.#e.delete(i)});getCheckedItems(){return this.#o.items.filter(i=>this.#o.checkedItems.has(i.entry.id))}getSelectedItem(){return this.#o.items[this.#o.selectedIndex]??null}setSelectedIndex(i){const o=Math.max(0,Math.min(i,this.#o.items.length-1));o!==this.#o.selectedIndex&&this.#i({...this.#o,selectedIndex:o})}setFocusedPanel(i){i!==this.#o.focusedPanel&&this.#i({...this.#o,focusedPanel:i})}toggleCheck(i){const o=new Set(this.#o.checkedItems);o.has(i)?o.delete(i):o.add(i),this.#i({...this.#o,checkedItems:o})}checkAll(){this.#i({...this.#o,checkedItems:new Set(this.#o.items.map(i=>i.entry.id))})}uncheckAll(){this.#i({...this.#o,checkedItems:new Set})}toggleAll(){this.#o.checkedItems.size===this.#o.items.length?this.uncheckAll():this.checkAll()}startApply(){const i=this.getCheckedItems().length;this.#i({...this.#o,applyProgress:{current:0,total:i},phase:"applying"})}updateApplyProgress(i){this.#o.applyProgress&&this.#i({...this.#o,applyProgress:{...this.#o.applyProgress,current:i}})}markDone(){this.#i({...this.#o,phase:"done"})}setError(i){this.#i({...this.#o,error:i,phase:"error"})}#i(i){this.#o=i;for(const o of this.#e)try{o()}catch{}}}const sL=()=>{const{stdin:e}=sf(),{stdout:i}=af(),[o,n]=T.useState(null),[a,t]=T.useState(!0),s=T.useMemo(()=>oL(),[]);return T.useEffect(()=>{if(!s||!e||!i){t(!1);return}let r=!1;return(async()=>{try{const u=await nL(e,i,200);r||n(u)}catch{}finally{r||t(!1)}})(),()=>{r=!0}},[s,e,i]),{isLoading:a,isSupported:s,palette:o}},rL=({autoFocus:e=!1,id:i,isActive:o=!0}={})=>{const{isRawModeSupported:n,setRawMode:a}=aL(),{activate:t,activeId:s,add:r,deactivate:u,focus:d,remove:l}=T.useContext(hY),g=T.useMemo(()=>i??Math.random().toString().slice(2,7),[i]);return T.useEffect(()=>(r(g,{autoFocus:e}),()=>{l(g)}),[g,e]),T.useEffect(()=>{o?t(g):u(g)},[o,g]),T.useEffect(()=>{if(!(!n||!o))return a(!0),()=>{a(!1)}},[o]),{focus:d,isFocused:!!g&&s===g}},uL=ss(import.meta.url),gt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,dL=e=>{if(typeof gt<"u"&&gt.versions&&gt.versions.node){const[i,o]=gt.versions.node.split(".").map(Number);if(i>22||i===22&&o>=3||i===20&&o>=16)return gt.getBuiltinModule(e)}return uL(e)},{Buffer:lL}=dL("node:buffer"),gL=/^\u001B([a-z0-9])$/i,hL=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,rf={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},cL=[...Object.values(rf),"backspace"],pL=e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),vL=e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),uf=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,yL=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,fL={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},mL={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},Wc={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},df=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),Wu=e=>df(e)?String.fromCodePoint(e):"?";function lf(e){return e===3?"release":e===2?"repeat":"press"}function gf(e){return{capsLock:!!(e&Ko.capsLock),ctrl:!!(e&Ko.ctrl),hyper:!!(e&Ko.hyper),meta:!!(e&Ko.meta),numLock:!!(e&Ko.numLock),option:!!(e&Ko.alt),shift:!!(e&Ko.shift),super:!!(e&Ko.super)}}const bL=e=>{const i=uf.exec(e);if(!i)return null;const o=Number.parseInt(i[1],10),n=i[2]?Math.max(0,Number.parseInt(i[2],10)-1):0,a=i[3]?Number.parseInt(i[3],10):1,t=i[4];if(!df(o))return null;let s;t&&(s=t.split(":").map(d=>Wu(Number.parseInt(d,10))).join(""));let r,u;return o===32?(r="space",u=!0):o===13?(r="return",u=!0):Wc[o]?(r=Wc[o],u=!1):o>=1&&o<=26?(r=String.fromCodePoint(o+96),u=!1):(r=Wu(o).toLowerCase(),u=!0),u&&!s&&(s=Wu(o)),{name:r,...gf(n),eventType:lf(a),isKittyProtocol:!0,isPrintable:u,raw:e,sequence:e,text:s}},wL=e=>{const i=yL.exec(e);if(!i)return null;const o=Number.parseInt(i[1],10),n=Math.max(0,Number.parseInt(i[2],10)-1),a=Number.parseInt(i[3],10),t=i[4],s=t==="~"?mL[o]:fL[t];return s?{name:s,...gf(n),eventType:lf(a),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},jL=(e="")=>{let i;lL.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const o=bL(e);if(o)return o;const n=wL(e);if(n)return n;if(uf.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const a={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(a.sequence=a.sequence||e||a.name,e){case"\r":case"\x1B\r":{a.raw=void 0,a.name="return",a.option=e.length===2;break}case`
1
+ import{createRequire as iY}from"node:module";import{c as nY,e as aY,V as tY,h as sY,r as rY}from"../packem_shared/index-ZfYDID5E.js";import{T as ri,f as Y,v as K,m as j,a as gn,u as Hn,H as G0,y as ts,o as uY,O as dY,B as Ja,A as A0}from"../packem_shared/index-D75r1yKp.js";import{S as Q0,m as ur}from"../packem_shared/package-version-DBJLduJL.js";import{L as lY}from"../packem_shared/public-api-WqUCiyIe.js";import{r as T,B as gY,D as Xc,J as W0,K as hY,M as Hc,P as Ko,Y as F0,m as k,n as I,i as D,Q as cY,v as Mo,b as pY,S as vY,W as Mc,e as yY,l as fY,a as zd,U as Nc,$ as mY,d as bY,c as wY,f as jY,X as qd,a0 as Vd,a1 as kY,a2 as SY}from"./catalog.js";import{f as hn,i as Rc,V as YY,L as _0,g as LY,d as cn,M as Ud,N as CY,_ as xa,c as Mt,O as I0}from"../packem_shared/en-BRcjb70R.js";import{I as en}from"../packem_shared/index-B0EsgdzO.js";import{findVisConfigFile as In,loadVisConfig as Oc}from"./CONFIG_FILES.js";import{a as We}from"../packem_shared/readJsonSync-DuMMeB3s-wlhgSHes.js";import{s as XY}from"../packem_shared/bin-BZ_m_tag.js";import{V as Qu,j as ho,s as Jt,q as zo,E as wa,Q as HY,a as Dr,I as MY}from"../packem_shared/index.server-qvZ-cy29.js";import{s as el}from"../packem_shared/index-BAe6e0XE.js";import{A as Gc}from"../packem_shared/pm-runner-D5NWL8yv.js";import{m as EY}from"./ts-loader.js";import{getMainWorktreeRoot as OY,Cache as lr,readLastRunSummary as U0,getLastRunSummaryPath as il,parseCacheSize as GY,digestFile as ef}from"@visulima/task-runner";import{e as zY}from"../packem_shared/index-DjTWo3sH.js";const oY=iY(import.meta.url),lt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,zi=e=>{if(typeof lt<"u"&&lt.versions&&lt.versions.node){const[i,o]=lt.versions.node.split(".").map(Number);if(i>22||i===22&&o>=3||i===20&&o>=16)return lt.getBuiltinModule(e)}return oY(e)},{spawnSync:ba,execSync:K0,execFileSync:$Y,execFile:ZY}=zi("node:child_process"),{writeFileSync:Xe,existsSync:Pc,renameSync:z0,statSync:Mn,rmSync:Ta,readdirSync:Oi,copyFileSync:JY,unlinkSync:pn,mkdirSync:xY,cpSync:TY,readFileSync:DY,watch:BY}=zi("node:fs"),{createRequire:ss}=zi("node:module"),{dirname:q0,delimiter:Ec,resolve:dr}=zi("node:path"),{createInterface:V0}=zi("node:readline"),{homedir:NY,platform:RY,tmpdir:PY}=zi("node:os"),{readFile:of,readdir:rs,stat:Pa,realpath:Ac,rm:cg,mkdtemp:AY,mkdir:QY}=zi("node:fs/promises"),{createServer:WY,STATUS_CODES:FY}=zi("node:http"),{Http2ServerRequest:ja,constants:_Y}=zi("node:http2"),{Readable:Qc}=zi("node:stream"),{randomUUID:IY}=zi("node:crypto"),{fileURLToPath:KY}=zi("node:url");function nf(e,i,o,n){let a,t,s;t=o,s=n;const r=lY(i,t,s??a);ri(e,r,a)}const le=(e,i)=>async()=>({default:(await e())[i]}),qY=new Set(["--cwd"]),VY=new Set(["--help","--version","-h","-V"]),UY=e=>{const i=[];for(let o=0;o<e.length;o+=1){const n=e[o];if(n!==void 0){if(VY.has(n))return!1;if(n.startsWith("-")){const a=n.indexOf("="),t=a===-1?n:n.slice(0,a);if(qY.has(t)&&a===-1){const s=e[o+1];s!==void 0&&!s.startsWith("-")&&(o+=1)}continue}i.push(n)}}return i.length===1&&i[0]==="migrate"},eL=e=>{if(e.length===0)return!1;for(const i of e){const o=i.codePointAt(0)??0;return!(o<=127||o<=255)}return!1};let iL=class{buffer="";timer;onFlush;timeout;constructor({onFlush:i,timeout:o}){this.onFlush=i,this.timeout=o}add(i){this.buffer+=i,this.timer!==void 0&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},this.timeout)}flush(){if(this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer.length>0){const i=this.buffer;this.buffer="",this.onFlush(i)}}destroy(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer=""}};const xs=e=>{const i=/rgb:([\da-f]{2,4})\/([\da-f]{2,4})\/([\da-f]{2,4})/i.exec(e);if(!i)return null;const o=n=>n.length<=2?n.padStart(2,"0"):n.slice(0,2);return`#${o(i[1])}${o(i[2])}${o(i[3])}`},oL=()=>{const e=process.env.TERM_PROGRAM??"";return new Set(["Alacritty","contour","foot","Ghostty","iTerm2","iTerm.app","kitty","rio","WezTerm"]).has(e)?!0:(process.env.TERM??"").startsWith("xterm")||!!process.env.WT_SESSION},Ts=(e,i,o,n=500)=>new Promise(a=>{let t="",s;const r=()=>{s&&clearTimeout(s),e.removeListener("data",u)},u=d=>{if(t+=d.toString(),t.length>256){r(),a(null);return}(t.includes("\x07")||t.includes("\x1B\\"))&&(r(),a(t))};s=setTimeout(()=>{r(),a(null)},n),e.on("data",u),i.write(o)}),nL=async(e,i,o=500)=>{const n={},a=await Ts(e,i,"\x1B]10;?\x07",o);if(a){const u=xs(a);u&&(n.foreground=u)}const t=await Ts(e,i,"\x1B]11;?\x07",o);if(t){const u=xs(t);u&&(n.background=u)}const s=await Ts(e,i,"\x1B]12;?\x07",o);if(s){const u=xs(s);u&&(n.cursor=u)}const r=[];for(let u=0;u<16;u++){const d=await Ts(e,i,`\x1B]4;${u};?\x07`,o);if(d){const l=xs(d);r.push(l??"")}else r.push("")}return r.some(u=>u.length>0)&&(n.colors=r),n},af=()=>T.useContext(gY),tf=()=>{const{stdout:e}=af(),[i,o]=T.useState(()=>Xc(e));return T.useEffect(()=>{const n=()=>{o(Xc(e))};return e.on("resize",n),()=>{e.off("resize",n)}},[e]),i},aL=()=>T.useContext(W0),sf=()=>T.useContext(W0);class tL{#o;#e=new Set;constructor(i){this.#o={applyProgress:null,checkedItems:new Set(i.map(o=>o.entry.id)),error:null,focusedPanel:"list",items:i,phase:"browsing",selectedIndex:0}}getSnapshot=()=>this.#o;subscribe=i=>(this.#e.add(i),()=>{this.#e.delete(i)});getCheckedItems(){return this.#o.items.filter(i=>this.#o.checkedItems.has(i.entry.id))}getSelectedItem(){return this.#o.items[this.#o.selectedIndex]??null}setSelectedIndex(i){const o=Math.max(0,Math.min(i,this.#o.items.length-1));o!==this.#o.selectedIndex&&this.#i({...this.#o,selectedIndex:o})}setFocusedPanel(i){i!==this.#o.focusedPanel&&this.#i({...this.#o,focusedPanel:i})}toggleCheck(i){const o=new Set(this.#o.checkedItems);o.has(i)?o.delete(i):o.add(i),this.#i({...this.#o,checkedItems:o})}checkAll(){this.#i({...this.#o,checkedItems:new Set(this.#o.items.map(i=>i.entry.id))})}uncheckAll(){this.#i({...this.#o,checkedItems:new Set})}toggleAll(){this.#o.checkedItems.size===this.#o.items.length?this.uncheckAll():this.checkAll()}startApply(){const i=this.getCheckedItems().length;this.#i({...this.#o,applyProgress:{current:0,total:i},phase:"applying"})}updateApplyProgress(i){this.#o.applyProgress&&this.#i({...this.#o,applyProgress:{...this.#o.applyProgress,current:i}})}markDone(){this.#i({...this.#o,phase:"done"})}setError(i){this.#i({...this.#o,error:i,phase:"error"})}#i(i){this.#o=i;for(const o of this.#e)try{o()}catch{}}}const sL=()=>{const{stdin:e}=sf(),{stdout:i}=af(),[o,n]=T.useState(null),[a,t]=T.useState(!0),s=T.useMemo(()=>oL(),[]);return T.useEffect(()=>{if(!s||!e||!i){t(!1);return}let r=!1;return(async()=>{try{const u=await nL(e,i,200);r||n(u)}catch{}finally{r||t(!1)}})(),()=>{r=!0}},[s,e,i]),{isLoading:a,isSupported:s,palette:o}},rL=({autoFocus:e=!1,id:i,isActive:o=!0}={})=>{const{isRawModeSupported:n,setRawMode:a}=aL(),{activate:t,activeId:s,add:r,deactivate:u,focus:d,remove:l}=T.useContext(hY),g=T.useMemo(()=>i??Math.random().toString().slice(2,7),[i]);return T.useEffect(()=>(r(g,{autoFocus:e}),()=>{l(g)}),[g,e]),T.useEffect(()=>{o?t(g):u(g)},[o,g]),T.useEffect(()=>{if(!(!n||!o))return a(!0),()=>{a(!1)}},[o]),{focus:d,isFocused:!!g&&s===g}},uL=ss(import.meta.url),gt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,dL=e=>{if(typeof gt<"u"&&gt.versions&&gt.versions.node){const[i,o]=gt.versions.node.split(".").map(Number);if(i>22||i===22&&o>=3||i===20&&o>=16)return gt.getBuiltinModule(e)}return uL(e)},{Buffer:lL}=dL("node:buffer"),gL=/^\u001B([a-z0-9])$/i,hL=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,rf={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},cL=[...Object.values(rf),"backspace"],pL=e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),vL=e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),uf=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,yL=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,fL={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},mL={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},Wc={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},df=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),Wu=e=>df(e)?String.fromCodePoint(e):"?";function lf(e){return e===3?"release":e===2?"repeat":"press"}function gf(e){return{capsLock:!!(e&Ko.capsLock),ctrl:!!(e&Ko.ctrl),hyper:!!(e&Ko.hyper),meta:!!(e&Ko.meta),numLock:!!(e&Ko.numLock),option:!!(e&Ko.alt),shift:!!(e&Ko.shift),super:!!(e&Ko.super)}}const bL=e=>{const i=uf.exec(e);if(!i)return null;const o=Number.parseInt(i[1],10),n=i[2]?Math.max(0,Number.parseInt(i[2],10)-1):0,a=i[3]?Number.parseInt(i[3],10):1,t=i[4];if(!df(o))return null;let s;t&&(s=t.split(":").map(d=>Wu(Number.parseInt(d,10))).join(""));let r,u;return o===32?(r="space",u=!0):o===13?(r="return",u=!0):Wc[o]?(r=Wc[o],u=!1):o>=1&&o<=26?(r=String.fromCodePoint(o+96),u=!1):(r=Wu(o).toLowerCase(),u=!0),u&&!s&&(s=Wu(o)),{name:r,...gf(n),eventType:lf(a),isKittyProtocol:!0,isPrintable:u,raw:e,sequence:e,text:s}},wL=e=>{const i=yL.exec(e);if(!i)return null;const o=Number.parseInt(i[1],10),n=Math.max(0,Number.parseInt(i[2],10)-1),a=Number.parseInt(i[3],10),t=i[4],s=t==="~"?mL[o]:fL[t];return s?{name:s,...gf(n),eventType:lf(a),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},jL=(e="")=>{let i;lL.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const o=bL(e);if(o)return o;const n=wL(e);if(n)return n;if(uf.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const a={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(a.sequence=a.sequence||e||a.name,e){case"\r":case"\x1B\r":{a.raw=void 0,a.name="return",a.option=e.length===2;break}case`
2
2
  `:{a.name="enter";break}case" ":{a.name="tab";break}case" ":case"\x1B ":{a.name="space",a.meta=e.length===2;break}case"\b":case"\x1B\b":{a.name="backspace",a.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{a.name="escape",a.meta=e.length===2;break}case"\x1B":case"":{a.name="backspace",a.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")a.name=String.fromCharCode(e.charCodeAt(0)+97-1),a.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")a.name="number";else if(e.length===1&&e>="a"&&e<="z")a.name=e;else if(e.length===1&&e>="A"&&e<="Z")a.name=e.toLowerCase(),a.shift=!0;else if(i=gL.exec(e))a.meta=!0,a.shift=/^[A-Z]$/.test(i[1]);else if(i=hL.exec(e)){const t=[...e];t[0]==="\x1B"&&t[1]==="\x1B"&&(a.option=!0);const s=[i[1],i[2],i[4],i[6]].filter(Boolean).join(""),r=(i[3]||i[5]||1)-1;a.ctrl=!!(r&4),a.meta=!!(r&10),a.shift=!!(r&1),a.code=s,a.name=rf[s]??"",a.shift=pL(s)||a.shift,a.ctrl=vL(s)||a.ctrl}}return a},pg=(e,i={})=>{const{internal_eventEmitter:o,internal_exitOnCtrlC:n,setRawMode:a,stdin:t}=sf(),s=i.imeEnabled??!0,r=i.imeTimeout??50,u=T.useRef(void 0),d=T.useEffectEvent(e);T.useEffect(()=>{if(s)return u.current=new iL({onFlush:l=>{const g={backspace:!1,capsLock:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,hyper:!1,leftArrow:!1,meta:!1,numLock:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,super:!1,tab:!1,upArrow:!1};Hc.discreteUpdates(()=>{d(l,g)})},timeout:r}),()=>{u.current?.destroy(),u.current=void 0}},[s,r]),T.useEffect(()=>{if(i.isActive!==!1)return a(!0),()=>{a(!1)}},[i.isActive,a]),T.useEffect(()=>{if(i.isActive===!1)return;const l=g=>{if(s&&eL(g)){u.current?.add(g);return}u.current?.flush();const h=jL(g),c={backspace:h.name==="backspace",capsLock:h.capsLock??!1,ctrl:h.ctrl,delete:h.name==="delete",downArrow:h.name==="down",end:h.name==="end",escape:h.name==="escape",eventType:h.eventType,home:h.name==="home",hyper:h.hyper??!1,leftArrow:h.name==="left",meta:h.meta||h.option,numLock:h.numLock??!1,pageDown:h.name==="pagedown",pageUp:h.name==="pageup",return:h.name==="return",rightArrow:h.name==="right",shift:h.shift,super:h.super??!1,tab:h.name==="tab",upArrow:h.name==="up"};let p;h.isKittyProtocol?h.isPrintable?p=h.text??h.name:h.ctrl&&h.name.length===1?p=h.name:p="":h.ctrl?p=h.name:p=h.sequence,!h.isKittyProtocol&&cL.includes(h.name)&&(p=""),p.startsWith("\x1B")&&(p=p.slice(1)),p.length===1&&typeof p[0]=="string"&&/[A-Z]/.test(p[0])&&(c.shift=!0),!(p==="c"&&c.ctrl&&n)&&(!h.name&&p===""||Hc.discreteUpdates(()=>{d(p,c)}))};return o.on("input",l),()=>{o.removeListener("input",l)}},[i.isActive,t,n,s])},kL=e=>{const{getViewportHeight:i,isActive:o=!0,scrollBy:n,scrollToBottom:a,scrollToTop:t,vimBindings:s=!1}=e,{isFocused:r}=rL({isActive:o});return pg((u,d)=>{if(d.upArrow){n(-1);return}if(d.downArrow){n(1);return}if(d.pageUp){n(-i());return}if(d.pageDown){n(i());return}if(d.home){t();return}if(d.end){a();return}if(d.ctrl&&u==="u"){n(-Math.floor(i()/2));return}if(d.ctrl&&u==="d"){n(Math.floor(i()/2));return}if(s){if(u==="k"){n(-1);return}if(u==="j"){n(1);return}if(u==="G"&&d.shift){a();return}if(u==="g"&&!d.shift){t();return}if(u==="u"&&!d.ctrl){n(-Math.floor(i()/2));return}u==="d"&&!d.ctrl&&n(Math.floor(i()/2))}},{isActive:o}),{isFocused:r}},ol=e=>{const[i,o]=T.useState(e),n=T.useRef(e),a=T.useCallback(s=>{const r=typeof s=="function"?s(n.current):s;n.current=r,o(r)},[]),t=T.useCallback(()=>n.current,[]);return[i,a,t]},SL=({children:e,index:i,measureKey:o,onMeasure:n,width:a})=>{const t=T.useRef(null);return T.useLayoutEffect(()=>{if(t.current){const{height:s}=F0(t.current);n(i,s)}},[i,n,a,o,e]),k.jsx(I,{flexDirection:"column",flexShrink:0,ref:t,width:"100%",children:e})},gr=e=>{if(e==null)return[];if(Array.isArray(e)){const i=[];for(let o=0;o<e.length;o+=1){const n=e[o];T.isValidElement(n)&&n.type===T.Fragment?i.push(...gr(n.props.children)):i.push(n)}return i}return T.isValidElement(e)&&e.type===T.Fragment?gr(e.props.children):[e]},Fc=({children:e,debug:i=!1,onContentHeightChange:o,onItemHeightChange:n,onViewportSizeChange:a,overscan:t=3,ref:s,scrollOffset:r,virtualize:u=!1,...d})=>{const l=T.useRef(!1),[g,h,c]=ol({height:0,width:0}),[p,f,m]=ol(0),[b,w]=T.useState({}),L=T.useRef(null),C=T.useRef(0);T.useLayoutEffect(()=>{p!==C.current&&(o?.(p,C.current),C.current=p)},[p,o]);const J=T.useRef({}),Z=T.useRef([]),x=T.useRef([]),H=T.useRef(0),O=T.useCallback((X,N)=>{const B=Z.current[X]??X;if(J.current[B]!==N){const A=J.current[B]??0;J.current={...J.current,[B]:N};let _=0;for(let te=0;te<Z.current.length;te+=1){const R=Z.current[te];R!=null&&(_+=J.current[R]??0)}const U=m();_!==U&&f(_),n?.(X,N,A),H.current=Math.min(H.current,X+1)}},[n,m,f]),Ce=T.useCallback(()=>{if(L.current){const{height:X,width:N}=F0(L.current),B=c();(N!==B.width||X!==B.height)&&(a?.({height:X,width:N},B),h({height:X,width:N}))}},[L,a,c,h]);T.useLayoutEffect(()=>{Ce()});const Oe=T.useRef(null);if(Oe.current!==e){Oe.current=e;const X=[],N={};gr(e).forEach((_,U)=>{if(!_)return;const te=(T.isValidElement(_)?_.key:null)??U;X[U]=te;const R=J.current[te]??0;N[te]=R}),J.current=N,Z.current=X,x.current=Array.from({length:X.length}).fill(0),H.current=0;let B=0;X.forEach(_=>{B+=N[_]??0});const A=m();B!==A&&f(B)}T.useImperativeHandle(s,()=>({getBottomOffset:()=>Math.max(0,m()-c().height),getContentHeight:m,getItemHeight:X=>{const N=Z.current[X]??X;return J.current[N]??0},getItemPosition:X=>{if(X<0||X>=Z.current.length)return null;if(X>=H.current){let A=0,_=0;if(H.current>0){_=H.current;const U=_-1,te=Z.current[U]??U,R=J.current[te]??0;A=(x.current[U]??0)+R}for(let U=_;U<=X;U+=1){x.current[U]=A;const te=Z.current[U]??U,R=J.current[te]??0;A+=R}H.current=X+1}const N=x.current[X]??0,B=Z.current[X]??X;return{height:J.current[B]??0,top:N}},getViewportHeight:()=>c().height,remeasure:Ce,remeasureItem:X=>{w(N=>({...N,[X]:(N[X]??0)+1}))}}),[Ce,m,c,w]);const ke=gr(e);!l.current&&p>0&&(l.current=!0);let Se=0,Be=ke.length-1,G=0,S=0;const M=ke.length>0&&ke.every((X,N)=>{const B=Z.current[N]??N;return(J.current[B]??0)>0}),F=u&&l.current&&M;if(F){const X=Z.current.length;if(H.current<X){let B=0,A=0;if(H.current>0){A=H.current;const _=A-1,U=Z.current[_]??_,te=J.current[U]??0;B=(x.current[_]??0)+te}for(let _=A;_<X;_+=1){x.current[_]=B;const U=Z.current[_]??_;B+=J.current[U]??0}H.current=X}const N=r+g.height;Se=ke.length,Be=-1;for(let B=0;B<X;B+=1){const A=x.current[B]??0,_=Z.current[B]??B,U=J.current[_]??0;A+U>r&&A<N&&(B<Se&&(Se=B),Be=B)}if(Se>Be&&(Se=0,Be=-1),Se=Math.max(0,Se-t),Be=Math.min(ke.length-1,Math.max(-1,Be)+t),G=x.current[Se]??0,Be<ke.length-1){const B=Z.current[Be]??Be,A=(x.current[Be]??0)+(J.current[B]??0);S=p-A}}return k.jsx(I,{...d,children:k.jsx(I,{ref:L,width:"100%",children:k.jsx(I,{overflow:i?void 0:"hidden",width:"100%",children:k.jsxs(I,{flexDirection:"column",marginTop:-r,width:"100%",children:[F&&G>0&&k.jsx(I,{height:G}),ke.map((X,N)=>!X||F&&(N<Se||N>Be)?null:k.jsx(SL,{index:N,measureKey:b[N],onMeasure:O,width:g.width,children:X},T.isValidElement(X)?X.key??N:N)),F&&S>0&&k.jsx(I,{height:S})]})})})})},_c={arrow:{lowerThumb:"╽",thumb:"┃",track:"|",upperThumb:"╿"},block:{thumb:"█",track:"░"},bold:{lowerThumb:"╿",thumb:"│",track:"┃",upperThumb:"╽"},classic:{thumb:"┃",track:"|"},dots:{thumb:"●",track:"·"},double:{thumb:"┃",track:"║"},doubleSingle:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},line:{thumb:"│",track:" "},round:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},single:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},singleDouble:{thumb:"┃",track:"║"},thick:{thumb:"┃",track:"╏"}},Ic={arrow:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},bold:{bottomLeft:"┗",bottomRight:"┛",topLeft:"┏",topRight:"┓"},classic:{bottomLeft:"+",bottomRight:"+",topLeft:"+",topRight:"+"},double:{bottomLeft:"╚",bottomRight:"╝",topLeft:"╔",topRight:"╗"},doubleSingle:{bottomLeft:"╘",bottomRight:"╛",topLeft:"╒",topRight:"╕"},round:{bottomLeft:"╰",bottomRight:"╯",topLeft:"╭",topRight:"╮"},single:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},singleDouble:{bottomLeft:"╙",bottomRight:"╜",topLeft:"╓",topRight:"╖"}},YL=e=>_c[typeof e=="string"?e:"single"]??_c.single??{thumb:"┃",track:"│"},LL=e=>Ic[typeof e=="string"?e:"single"]??Ic.single??{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},hf=({autoHide:e=!1,color:i,contentHeight:o,dimColor:n,placement:a="right",scrollOffset:t,style:s,thumbChar:r,trackChar:u,viewportHeight:d})=>{const l=T.useMemo(()=>{const p=Math.max(o,d);if(e&&p<=d)return null;const f=YL(s),m=r??f.thumb,b=u??f.track,w=d*2,L=Math.min(d/p,1),C=Math.max(2,Math.round(w*L)),J=p-d,Z=J>0?Math.min(Math.max(t/J,0),1):0,x=w-C,H=Math.round(Z*x),O=H+C,Ce=[];for(let Oe=0;Oe<d;Oe+=1){const ke=Oe*2,Se=Oe*2+1,Be=ke>=H&&ke<O,G=Se>=H&&Se<O;Be&&G?Ce.push(m):Be&&!G?Ce.push(f.lowerThumb??m):!Be&&G?Ce.push(f.upperThumb??m):Ce.push(b)}return Ce},[o,d,t,s,r,u,e]);if(l===null)return null;if(a==="inset")return k.jsx(I,{flexDirection:"column",flexShrink:0,width:1,children:l.map((p,f)=>k.jsx(D,{color:i,dimColor:n,children:p},f))});const g=LL(s),h=a==="left"?g.topLeft:g.topRight,c=a==="left"?g.bottomLeft:g.bottomRight;return k.jsxs(I,{flexDirection:"column",flexShrink:0,width:1,children:[k.jsx(D,{color:i,dimColor:n,children:h}),l.map((p,f)=>k.jsx(D,{color:i,dimColor:n,children:p},f)),k.jsx(D,{color:i,dimColor:n,children:c})]})},cf=({children:e,debug:i=!1,followOutput:o=!1,followThreshold:n=3,keyboard:a=!1,onContentHeightChange:t,onItemHeightChange:s,onReachEnd:r,onReachStart:u,onScroll:d,onViewportSizeChange:l,overscan:g,reachThreshold:h=5,ref:c,scrollbar:p=!1,scrollbarColor:f,scrollbarStyle:m="line",vimBindings:b=!1,virtualize:w,...L})=>{const[C,J,Z]=ol(0),x=T.useRef(null),H=T.useRef(0),O=T.useRef(0),[Ce,Oe]=T.useState(0),[ke,Se]=T.useState(0),Be=T.useRef(!1),G=T.useRef(!1),S=T.useCallback(()=>Math.max(0,H.current-O.current),[]),M=T.useCallback(R=>{const oe=S();r&&R>=oe-h&&!Be.current?(Be.current=!0,r()):R<oe-h&&(Be.current=!1),u&&R<=h&&!G.current?(G.current=!0,u()):R>h&&(G.current=!1)},[r,u,h,S]),F=T.useCallback(R=>{R!==Z()&&(J(R),d?.(R),M(R))},[Z,J,d,M]),X=T.useCallback((R,oe)=>{const Ge=Z()>=S()-n;if(H.current=R,Oe(R),t?.(R,oe),o&&Ge&&R>oe){const ei=Math.max(0,R-O.current);F(ei)}else{const ei=Math.max(0,R-O.current);Z()>ei&&F(ei)}},[t,o,n,Z,S,F]),N=T.useCallback((R,oe)=>{O.current=R.height,Se(R.height),l?.(R,oe)},[l]),B=T.useCallback(R=>{if(typeof R!="number"||Number.isNaN(R))return;const oe=Math.max(0,H.current-O.current),Ge=Math.max(0,Math.min(Z()+R,oe));F(Ge)},[Z,F]),A=T.useCallback(R=>{if(typeof R!="number"||Number.isNaN(R))return;const oe=Math.max(0,H.current-O.current),Ge=Math.max(0,Math.min(R,oe));F(Ge)},[F]),_=T.useCallback(()=>{const R=S();F(R)},[S,F]),U=T.useCallback(()=>{F(0)},[F]),te=T.useCallback(()=>O.current,[]);return kL({getViewportHeight:te,isActive:a,scrollBy:B,scrollToBottom:_,scrollToTop:U,vimBindings:b}),T.useImperativeHandle(c,()=>({getBottomOffset:S,getContentHeight:()=>H.current,getItemHeight:R=>x.current?.getItemHeight(R)??0,getItemPosition:R=>x.current?.getItemPosition(R)??null,getScrollOffset:Z,getViewportHeight:()=>O.current,remeasure:()=>x.current?.remeasure(),remeasureItem:R=>x.current?.remeasureItem(R),scrollBy:B,scrollTo:A,scrollToBottom:_,scrollToTop:U}),[S,Z,B,A,_,U]),p&&Ce>ke&&ke>0?k.jsxs(I,{flexDirection:"row",flexGrow:L.flexGrow,flexShrink:L.flexShrink,overflow:"hidden",children:[k.jsx(Fc,{children:e,debug:i,onContentHeightChange:X,onItemHeightChange:s,onViewportSizeChange:N,overscan:g,ref:x,scrollOffset:C,virtualize:w,...L,flexGrow:1}),k.jsx(hf,{color:f,contentHeight:Ce,placement:"inset",scrollOffset:C,style:m,viewportHeight:ke})]}):k.jsx(Fc,{children:e,debug:i,onContentHeightChange:X,onItemHeightChange:s,onViewportSizeChange:N,overscan:g,ref:x,scrollOffset:C,virtualize:w,...L})},nl=({backgroundColor:e,borderColor:i="cyan",borderStyle:o="round",children:n,columns:a,footer:t,maxHeight:s=.8,paddingX:r=2,paddingY:u=1,rows:d,scrollbarStyle:l="block",scrollRef:g,title:h,visible:c=!0,width:p=60})=>{const f=tf(),{isLoading:m,palette:b}=sL(),w=T.useRef(null),L=g??w;if(!c)return null;const C=a??(f.columns||80),J=d??(f.rows||24),Z=e??(m?"black":b?.background??"black"),x=s<=1?Math.floor(J*s):Math.min(s,J-2),H=typeof h=="string"?k.jsx(I,{marginBottom:1,children:k.jsx(D,{bold:!0,color:i,children:h})}):h??null;return k.jsx(I,{alignItems:"center",height:J,justifyContent:"center",position:"absolute",width:C,children:k.jsxs(I,{backgroundColor:Z,borderBackgroundColor:Z,borderColor:i,borderStyle:o,flexDirection:"column",maxHeight:x,opaque:!0,paddingY:u,width:Math.min(p,C-4),children:[H!=null&&k.jsx(I,{flexShrink:0,paddingX:r,children:H}),k.jsx(cf,{flexGrow:1,flexShrink:1,paddingX:r,ref:L,scrollbar:!0,scrollbarColor:i,scrollbarStyle:l,children:n}),t!=null&&k.jsx(I,{alignItems:"center",flexDirection:"column",flexShrink:0,marginTop:1,paddingX:r,children:t})]})})},pf=()=>T.useContext(cY),Kc=({autoExitSeconds:e,onCancel:i,visible:o})=>{const{exit:n}=pf(),[a,t]=T.useState(e||3),s=T.useRef(null),r=T.useRef(0);T.useEffect(()=>{if(!o)return;const d=e||3;t(d),r.current=Date.now();let l=d;return s.current=setInterval(()=>{l-=1,l<=0?(s.current&&(clearInterval(s.current),s.current=null),t(0),n()):t(l)},1e3),()=>{s.current&&(clearInterval(s.current),s.current=null)}},[o,e,n]);const u=T.useCallback(()=>{s.current&&(clearInterval(s.current),s.current=null),i()},[i]);return pg((d,l)=>{Date.now()-r.current<200||(d==="q"?n():u())},{isActive:o}),k.jsx(nl,{backgroundColor:"#1e1e1e",footer:k.jsxs(D,{dimColor:!0,children:["Press"," ",k.jsx(D,{bold:!0,color:"white",children:"q"})," ","to exit,"," ",k.jsx(D,{bold:!0,color:"white",children:"any key"})," ","to stay"]}),title:`Exiting in ${a}…`,visible:o,width:50,children:k.jsx(D,{dimColor:!0,children:"Stay to explore the results interactively."})})},CL=e=>{if(e.startsWith("⚠"))return"yellow";e.startsWith("── ")||e.startsWith("[dry-run]")},$L=({focused:e,item:i,scrollRef:o})=>{const n=e?"white":"gray";return i?k.jsxs(I,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[k.jsx(I,{flexShrink:0,paddingTop:1,paddingX:2,children:k.jsx(D,{bold:!0,color:"white",children:i.entry.title})}),k.jsx(I,{flexShrink:0,paddingBottom:1,paddingX:2,children:k.jsx(D,{dimColor:!0,children:i.entry.description})}),k.jsx(cf,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:k.jsxs(I,{flexDirection:"column",children:[k.jsx(D,{dimColor:!0,children:"── What will change ──"}),k.jsx(D,{}),i.preview.length===0&&k.jsx(D,{dimColor:!0,children:"(no preview available)"}),i.preview.map((a,t)=>{const s=CL(a);return a===""?k.jsx(D,{},`blank-${String(t)}`):k.jsx(D,{color:s,children:a},`${String(t)}-${a.slice(0,20)}`)})]})})]}):k.jsx(I,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:k.jsx(D,{dimColor:!0,children:"No migration selected"})})},ZL=({checked:e,isSelected:i,item:o})=>{const n=e?"☑":"☐",a=o.preview.length;return k.jsxs(I,{flexShrink:0,height:1,children:[k.jsx(D,{children:i?">":" "}),k.jsxs(D,{color:e?"white":"gray",children:[" ",n," "]}),k.jsx(I,{flexGrow:1,children:k.jsx(D,{bold:i,inverse:i,wrap:"truncate",children:o.entry.title})}),k.jsxs(D,{dimColor:!0,children:[" ",a," ","change",a===1?"":"s"," "]})]})},JL=({checkedItems:e,focused:i,isDryRun:o,items:n,scrollOffset:a,selectedIndex:t,viewportHeight:s})=>{const r=i?"white":"gray",u=n.filter(h=>e.has(h.entry.id)).length,d=n.map((h,c)=>k.jsx(ZL,{checked:e.has(h.entry.id),isSelected:c===t,item:h},h.entry.id)),l=n.length,g=l>s&&s>0;return k.jsxs(I,{borderColor:r,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[k.jsxs(I,{flexShrink:0,gap:1,paddingX:1,children:[k.jsx(D,{bold:!0,inverse:!0,children:" MIGRATE "}),k.jsxs(D,{wrap:"truncate",children:[n.length," ","applicable"]}),u>0&&k.jsxs(D,{dimColor:!0,children:[" — ",u," selected"]}),o&&k.jsx(D,{color:"yellow",children:" (dry-run)"})]}),k.jsxs(I,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[k.jsx(I,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:k.jsx(I,{flexDirection:"column",marginTop:-a,children:d})}),g&&k.jsx(I,{flexShrink:0,marginLeft:1,marginRight:1,children:k.jsx(hf,{contentHeight:l,placement:"inset",scrollOffset:a,style:"block",viewportHeight:s})})]})]})},xL=100,TL=40,DL=10,BL=({autoExitSeconds:e=0,isDryRun:i,store:o})=>{const{exit:n}=pf(),{columns:a,rows:t}=tf(),s=T.useSyncExternalStore(o.subscribe,o.getSnapshot),[r,u]=T.useState(!1),[d,l]=T.useState(!1),[g,h]=T.useState(!1),[c,p]=T.useState(0),f=T.useRef(null),m=T.useRef(null),b=T.useRef(null),w=s.items[s.selectedIndex]??null,L=Math.max(1,t-6),C=T.useCallback(G=>{p(S=>G>=S+L?Math.max(0,G-L+1):G<S?Math.max(0,G):S)},[L]);if(T.useEffect(()=>{m.current?.scrollToTop()},[w?.entry.id]),pg((G,S)=>{if(G==="c"&&S.ctrl){n();return}if(!g){if(d){G==="u"||S.return?(l(!1),o.startApply(),n(o.getCheckedItems())):S.escape||G==="q"?l(!1):S.downArrow||G==="j"?b.current?.scrollBy(1):(S.upArrow||G==="k")&&b.current?.scrollBy(-1);return}if(r){S.escape||G==="?"?u(!1):G==="q"?(u(!1),h(!0)):S.downArrow||G==="j"?f.current?.scrollBy(1):(S.upArrow||G==="k")&&f.current?.scrollBy(-1);return}if(G==="?"){u(!0);return}if(G==="q"){h(!0);return}if(S.tab){o.setFocusedPanel(s.focusedPanel==="list"?"detail":"list");return}if(s.focusedPanel==="list"){if(S.downArrow||G==="j"){const M=Math.min(s.selectedIndex+1,s.items.length-1);o.setSelectedIndex(M),C(M);return}if(S.upArrow||G==="k"){const M=Math.max(s.selectedIndex-1,0);o.setSelectedIndex(M),C(M);return}if(S.pageDown){const M=Math.min(s.selectedIndex+10,s.items.length-1);o.setSelectedIndex(M),C(M);return}if(S.pageUp){const M=Math.max(s.selectedIndex-10,0);o.setSelectedIndex(M),C(M);return}if(S.home){o.setSelectedIndex(0),p(0);return}if(S.end){const M=s.items.length-1;o.setSelectedIndex(M),C(M);return}if(G===" "||S.return){w&&o.toggleCheck(w.entry.id);return}if(G==="a"){o.toggleAll();return}if(G==="u"&&!i&&s.checkedItems.size>0){l(!0);return}S.rightArrow&&o.setFocusedPanel("detail");return}if(s.focusedPanel==="detail"){if(S.escape||S.leftArrow){o.setFocusedPanel("list");return}if(S.downArrow||G==="j"){m.current?.scrollBy(1);return}if(S.upArrow||G==="k"){m.current?.scrollBy(-1);return}if(S.pageDown){m.current?.scrollBy(10);return}if(S.pageUp){m.current?.scrollBy(-10);return}if(S.home){m.current?.scrollToTop();return}S.end&&m.current?.scrollToBottom()}}},{isActive:!0}),a<TL||t<DL)return k.jsx(I,{alignItems:"center",height:t,justifyContent:"center",width:a,children:k.jsxs(D,{color:"yellow",children:["Terminal too small (",a,"x",t,")"]})});const J=a>=xL,Z=[k.jsxs(I,{gap:1,children:[k.jsx(D,{bold:!0,color:"white",children:"q"}),k.jsx(D,{dimColor:!0,children:"QUIT"})]},"q"),k.jsxs(I,{gap:1,children:[k.jsx(D,{bold:!0,color:"white",children:"?"}),k.jsx(D,{dimColor:!0,children:"HELP"})]},"?"),k.jsxs(I,{gap:1,children:[k.jsx(D,{bold:!0,color:"white",children:"↑↓"}),k.jsx(D,{dimColor:!0,children:"NAV"})]},"nav"),k.jsxs(I,{gap:1,children:[k.jsx(D,{bold:!0,color:"white",children:"Space"}),k.jsx(D,{dimColor:!0,children:"CHECK"})]},"sp"),k.jsxs(I,{gap:1,children:[k.jsx(D,{bold:!0,color:"white",children:"a"}),k.jsx(D,{dimColor:!0,children:"ALL"})]},"a")];!i&&s.checkedItems.size>0&&Z.push(k.jsxs(I,{gap:1,children:[k.jsx(D,{bold:!0,color:"green",children:"u"}),k.jsx(D,{dimColor:!0,children:"APPLY"})]},"u")),Z.push(k.jsxs(I,{gap:1,children:[k.jsx(D,{bold:!0,color:"white",children:"Tab"}),k.jsx(D,{dimColor:!0,children:"PANEL"})]},"tab"));const x=k.jsx(I,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:k.jsx(I,{flexWrap:"wrap",gap:2,paddingX:1,children:Z})}),H=k.jsxs(nl,{footer:k.jsxs(D,{dimColor:!0,children:[k.jsx(D,{bold:!0,color:"white",children:"↑↓"})," scroll ",k.jsx(D,{bold:!0,color:"white",children:"?"}),"/",k.jsx(D,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:f,title:"KEYBOARD SHORTCUTS",visible:r,width:52,children:[k.jsxs(I,{flexDirection:"column",marginBottom:1,children:[k.jsx(D,{bold:!0,color:"white",children:"NAVIGATION"}),k.jsxs(D,{children:[k.jsx(D,{bold:!0,color:"white",children:" ↑/k"}),k.jsx(D,{dimColor:!0,children:" Move up"})]}),k.jsxs(D,{children:[k.jsx(D,{bold:!0,color:"white",children:" ↓/j"}),k.jsx(D,{dimColor:!0,children:" Move down"})]}),k.jsxs(D,{children:[k.jsx(D,{bold:!0,color:"white",children:" Tab"}),k.jsx(D,{dimColor:!0,children:" Switch panel"})]}),k.jsxs(D,{children:[k.jsx(D,{bold:!0,color:"white",children:" →/←"}),k.jsx(D,{dimColor:!0,children:" Focus detail/list"})]})]}),k.jsxs(I,{flexDirection:"column",marginBottom:1,children:[k.jsx(D,{bold:!0,color:"white",children:"SELECTION"}),k.jsxs(D,{children:[k.jsx(D,{bold:!0,color:"white",children:" Space"}),k.jsx(D,{dimColor:!0,children:" Toggle migration"})]}),k.jsxs(D,{children:[k.jsx(D,{bold:!0,color:"white",children:" a"}),k.jsx(D,{dimColor:!0,children:" Toggle all"})]})]}),k.jsxs(I,{flexDirection:"column",children:[k.jsx(D,{bold:!0,color:"white",children:"ACTIONS"}),!i&&k.jsxs(D,{children:[k.jsx(D,{bold:!0,color:"white",children:" u"}),k.jsx(D,{dimColor:!0,children:" Apply selected migrations"})]}),k.jsxs(D,{children:[k.jsx(D,{bold:!0,color:"white",children:" q"}),k.jsx(D,{dimColor:!0,children:" Quit"})]}),k.jsxs(D,{children:[k.jsx(D,{bold:!0,color:"white",children:" ?"}),k.jsx(D,{dimColor:!0,children:" Toggle help"})]})]})]}),O=o.getCheckedItems(),Ce=k.jsx(I,{alignItems:"center",flexDirection:"column",children:k.jsxs(D,{dimColor:!0,children:["Press ",k.jsx(D,{bold:!0,color:"white",children:"u"})," or ",k.jsx(D,{bold:!0,color:"white",children:"Enter"})," to confirm, ",k.jsx(D,{bold:!0,color:"white",children:"Esc"})," to cancel"]})}),Oe=k.jsx(nl,{footer:Ce,scrollRef:b,title:`Apply ${String(O.length)} migration${O.length===1?"":"s"}?`,visible:d,width:70,children:O.map(G=>k.jsxs(I,{gap:1,children:[k.jsxs(D,{children:[" ",G.entry.title]}),k.jsxs(D,{dimColor:!0,children:["(",G.preview.length," ","change",G.preview.length===1?"":"s",")"]})]},G.entry.id))}),ke=k.jsx(JL,{checkedItems:s.checkedItems,focused:s.focusedPanel==="list",isDryRun:i,items:s.items,scrollOffset:c,selectedIndex:s.selectedIndex,viewportHeight:L}),Se=k.jsx($L,{focused:s.focusedPanel==="detail",item:w,scrollRef:m});if(J){const G=Math.floor(a*.55);return k.jsxs(I,{flexDirection:"column",height:t,width:a,children:[k.jsxs(I,{flexDirection:"row",flexGrow:1,children:[k.jsx(I,{flexGrow:1,children:ke}),k.jsx(I,{width:G,children:Se})]}),x,Oe,k.jsx(Kc,{autoExitSeconds:e||3,onCancel:()=>{h(!1)},visible:g}),H]})}const Be=Math.floor(t*.45);return k.jsxs(I,{flexDirection:"column",height:t,width:a,children:[k.jsx(I,{height:Be,children:ke}),k.jsx(I,{flexGrow:1,children:Se}),x,Oe,k.jsx(Kc,{autoExitSeconds:e||3,onCancel:()=>{h(!1)},visible:g}),H]})},vf=[".lintstagedrc.json",".lintstagedrc"],yf=[".lintstagedrc.yaml",".lintstagedrc.yml",".lintstagedrc.mjs","lint-staged.config.mjs",".lintstagedrc.cjs","lint-staged.config.cjs",".lintstagedrc.js","lint-staged.config.js",".lintstagedrc.ts","lint-staged.config.ts",".lintstagedrc.mts","lint-staged.config.mts",".lintstagedrc.cts","lint-staged.config.cts"],ff=[...vf,...yf],XL=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+lint-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)lint-staged\b/],mf=[".nano-staged.json",".nanostagedrc"],bf=[".nano-staged.mjs",".nano-staged.cjs",".nano-staged.js","nano-staged.config.mjs","nano-staged.config.cjs","nano-staged.config.js","nano-staged.config.mts","nano-staged.config.cts","nano-staged.config.ts"],wf=[...mf,...bf],HL=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+nano-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)nano-staged\b/],jf=["husky","lint-staged","nano-staged"],ML=/\(is-ci \|\| husky \|\| exit 0\)\s*&&\s*/g,NL=/\bhusky(?:\s+install)?\s*&&\s*/g,RL=/\s*&&\s*husky(?:\s+install)?/g,PL=/\s*\|\|\s*husky(?:\s+install)?/g,EL=[ML,NL,RL,PL],kf=e=>{if(e==="husky"||e==="husky install")return;let i=e;for(const o of EL)i=i.replace(o,"");return i=i.trim(),i===e?e:i||void 0},Sf=["pre-commit","pre-merge-commit","prepare-commit-msg","commit-msg","post-commit","applypatch-msg","pre-applypatch","post-applypatch","pre-rebase","post-rewrite","post-checkout","post-merge","pre-push","pre-auto-gc"],vg=".vis/hooks",va=".vis-hooks",Ewe=[".pre-commit-config.yaml",".pre-commit-config.yml","prek.toml"],Owe={commit:"pre-commit","merge-commit":"pre-merge-commit",push:"pre-push"},Gwe=new Set(["commit-msg","post-checkout","post-commit","post-merge","post-rewrite","pre-commit","pre-merge-commit","pre-push","pre-rebase","prepare-commit-msg"]),Awe=new Set(["commit-msg","post-checkout","post-merge","post-rewrite","pre-rebase","prepare-commit-msg"]),Qwe=new Set(["fail","script","system"]),OL="config.json",Fu=1,GL=new Set(["alwaysRun","args","builtin","entry","exclude","excludeTypes","fail","files","id","name","passFilenames","types","typesOr","verbose"]),AL=new Set(["failFast","skipInCI","stages","version"]),QL=["args","exclude","excludeTypes","files","passFilenames","types","typesOr"],Yf=(e,i)=>j(e,i,OL),al=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ds=e=>{if(!Array.isArray(e))return;const i=[];for(const o of e){if(typeof o!="string")return;i.push(o)}return i},Nt=e=>typeof e=="boolean"?e:void 0,ra=e=>typeof e=="string"&&e.length>0?e:void 0,WL=(e,i,o)=>{if(!al(e))throw new TypeError("hook entry must be an object");if(typeof e.id!="string"||e.id.length===0)throw new TypeError("hook entry is missing `id`");const n={id:e.id},a=Nt(e.alwaysRun);a!==void 0&&(n.alwaysRun=a);const t=Ds(e.args);t&&(n.args=t);const s=ra(e.builtin);s&&(n.builtin=s);const r=ra(e.entry);r&&(n.entry=r);const u=ra(e.exclude);u&&(n.exclude=u);const d=Ds(e.excludeTypes);d&&(n.excludeTypes=d);const l=ra(e.fail);l&&(n.fail=l);const g=ra(e.files);g&&(n.files=g);const h=ra(e.name);h&&(n.name=h);const c=Nt(e.passFilenames);c!==void 0&&(n.passFilenames=c);const p=Ds(e.types);p&&(n.types=p);const f=Ds(e.typesOr);f&&(n.typesOr=f);const m=Nt(e.verbose);if(m!==void 0&&(n.verbose=m),[n.builtin,n.entry,n.fail].filter(b=>b!==void 0).length!==1)throw new TypeError(`hook "${n.id}" must set exactly one of \`builtin\`, \`entry\`, \`fail\``);if(n.fail!==void 0){const b=QL.filter(w=>n[w]!==void 0);if(b.length>0)throw new TypeError(`hook "${n.id}" is a \`fail\` entry — remove ${b.join(", ")} (filters do not apply)`)}for(const b of Object.keys(e))GL.has(b)||i.push({hookId:n.id,message:`unknown field "${b}" ignored`,stage:o});return n},FL=(e,i)=>{if(!al(e))throw new TypeError("hook config must be an object");if(e.version!==Fu)throw new TypeError(`unsupported hook config version: expected ${Fu}, got ${String(e.version)}`);if(!al(e.stages))throw new TypeError("hook config is missing `stages` map");const o={};for(const[s,r]of Object.entries(e.stages)){if(!Array.isArray(r))throw new TypeError(`hook config: stage "${s}" must be an array`);o[s]=r.map(u=>WL(u,i,s))}const n={stages:o,version:Fu},a=Nt(e.failFast);a!==void 0&&(n.failFast=a);const t=Nt(e.skipInCI);t!==void 0&&(n.skipInCI=t);for(const s of Object.keys(e))AL.has(s)||i.push({message:`unknown top-level field "${s}" ignored`});return n},_L=(e,i=vg,o)=>{const n=Yf(e,i);if(!Y(n))return;const a=K(n);let t;try{t=JSON.parse(a)}catch(s){const r=s instanceof Error?s.message:String(s);throw new TypeError(`failed to parse ${n}: ${r}`,{cause:s})}return FL(t,[])},Wwe=(e,i,o)=>{const n=Yf(e,i);Xe(n,`${JSON.stringify(o,void 0,4)}
3
3
  `,"utf8")},IL=/\/$/,KL=e=>{if(e===va||!Pc(va)||Pc(e))return;const i=q0(e);return i&&i!=="."&&gn(i),z0(va,e),`migrated ${va} → ${e}`},zL=e=>{let i='"$0"';for(let o=0;o<e;o+=1)i=`"$(dirname ${i})"`;return i},qL=(e,i={})=>{const o=e.split("/").filter(a=>a!==""&&a!==".").length+2,n=zL(o);return`#!/usr/bin/env sh
4
4
  { [ "$VIS_GIT_HOOKS" = "2" ]; } && set -x
@@ -1 +1 @@
1
- import{createRequire as M}from"node:module";import{I as R,E as j,V as A,s as I}from"../packem_shared/index.server-qvZ-cy29.js";import{m as L,O as B}from"../packem_shared/index-D75r1yKp.js";import{P as N}from"../packem_shared/package-version-gyjskW3N.js";import"../packem_shared/public-api-WqUCiyIe.js";import{c as F,f as z,b as U,R as V,l as H}from"./catalog.js";import{i as b,p as f}from"./cli-main.js";import{h as J,j as W,y as Y}from"../packem_shared/pm-runner-D5NWL8yv.js";import{r as G,a as K}from"../packem_shared/command-runtime-Buz4F5LM.js";import{r as P,a as Q,p as X,b as Z}from"../packem_shared/resolve-explicit-CnEsy-zC.js";import{H as ee,F as C,D as oe,J as te,y,B as se,h as ne}from"../packem_shared/en-BRcjb70R.js";import{r as re}from"../packem_shared/typosquats-DWB80Gyv.js";import{f as D,i as S}from"../packem_shared/utils-CRueU43T.js";import{a as ie}from"../packem_shared/readJsonSync-DuMMeB3s-wlhgSHes.js";const q=M(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=t=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[c,e]=w.versions.node.split(".").map(Number);if(c>22||c===22&&e>=3||c===20&&e>=16)return w.getBuiltinModule(t)}return q(t)},{createInterface:T}=O("node:readline"),x=t=>t==="default"?"catalog:":`catalog:${t}`,v=t=>t==="default"?"default catalog":`catalog "${t}"`,ae=(t,c)=>{const e=[];for(const[o,s]of c)o.includes(":")||s.has(t)&&e.push(o);if(e.length===0)return;if(e.length===1){const[o]=e;return{source:v(o),spec:x(o)}}const r=e.find(o=>o==="default")??e[0],i=e.filter(o=>o!==r);return{candidates:[...e],conflict:!0,source:`${v(r)} (also in: ${i.map(o=>v(o)).join(", ")})`,spec:x(r)}},ce=(t,c)=>{const e=new Map;for(const[a,u]of c){if(!a.includes(":"))continue;const p=u.get(t);p!==void 0&&e.set(p,(e.get(p)??0)+1)}if(e.size===0)return;const r=[...e.entries()],i=r.reduce((a,[,u])=>a+u,0);if(r.length===1){const[[a]]=r;return{source:`siblings (${String(i)} pkg${i===1?"":"s"} on ${a})`,spec:a}}const o=[...r].sort((a,u)=>u[1]-a[1]),[s,n]=o[0],l=o.slice(1).map(([a,u])=>`${a} (×${String(u)})`);return{candidates:o.map(([a])=>a),conflict:!0,source:`siblings (most common: ${s} ×${String(n)}; conflicts: ${l.join(", ")})`,spec:s}},le=(t,c)=>ae(t,c)||ce(t,c),pe=(t,c,e)=>{const r=[];for(const i of t.values()){const{overall:o}=i.score,s=se(o),n=`${String(Math.round(o*100))}%`,l=i.alerts.length,a=y(i),u=ee(a,i.version,e),p=s==="red"?A:s==="yellow"?I:R;if(u?f.info(` ${p(n)} ${C(i)} ${j(`[accepted: ${u.reason}]`)}`):f.info(` ${p(n)} ${C(i)}`),l>0){const g=i.alerts.filter(d=>d.severity==="critical"||d.severity==="high").length;g>0&&f.warn(` ${String(g)} critical/high alert${g===1?"":"s"}`)}o<c&&!u&&r.push(i)}return r},fe=async(t,c)=>{const e=T({input:process.stdin,output:process.stdout}),r=n=>new Promise(l=>{e.question(n,a=>{l(a.trim())})}),i=String(Math.round(c*100));f.warn(""),f.warn(`${String(t.length)} package${t.length===1?"":"s"} scored below the minimum threshold (${i}%):`);for(const n of t){const l=y(n),a=`${String(Math.round(n.score.overall*100))}%`;f.warn(` • ${l}@${n.version} — score: ${a} (${oe(n.score.overall)})`)}f.warn("");const o=await r("Continue adding these packages? [y/N] ");if(o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes")return e.close(),!1;const s=await r("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),s.toLowerCase()==="y"||s.toLowerCase()==="yes"){f.notice(""),f.notice("Add the following to security.acceptedRisks in vis.config.ts:"),f.notice("");for(const n of t){const l=y(n),a=te(l,n.version,n.score.overall,"Reviewed and accepted");f.notice(a)}f.notice("")}return!0},ue=async(t,c,e,r)=>{const i=await P(t);if(i.length===0)return!0;f.info(""),f.info(`${c.map(n=>n.displayName).join(" + ")} security check:`);const o=await z(c,i);if(o.size===0)return f.info(" Could not fetch security data. Proceeding."),!0;const s=pe(o,e,r);return s.length===0?(f.info(""),!0):process.stdin.isTTY?fe(s,e):(f.warn(`Aborting: ${String(s.length)} package${s.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},de=["dependencies","devDependencies","peerDependencies","optionalDependencies"],ge=t=>t.savePeer?"peerDependencies":t.saveOptional?"optionalDependencies":t.saveDev?"devDependencies":"dependencies",_=(t,c)=>t.startsWith("catalog:")||!c?t:t.replace(/^[\^~]/,""),me=async(t,c)=>{const e=[];for(const o of t){const{name:s,versionSpec:n}=D(o);if(!s)continue;if(n!==void 0){e.push({explicit:n,name:s});continue}const l=le(s,c);if(l){l.conflict&&f.warn(`${s}: ambiguous constraint — picking ${l.spec} (${l.source}). Pass ${s}@<version> to override.`),e.push({entry:{name:s,source:l.source,spec:l.spec},kind:"resolved",name:s});continue}e.push({kind:"missing",name:s})}const r=e.filter(o=>"kind"in o&&o.kind==="missing").map(o=>o.name),i=r.length>0?await Z(r):new Map;return e.map(o=>{if("explicit"in o)return{name:o.name,source:"explicit",spec:o.explicit};if(o.kind==="resolved")return o.entry;const s=i.get(o.name);if(s===void 0)throw new Error(`--to: cannot resolve a version for "${o.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${o.name}@<version> explicitly.`);const n=`^${s}`;return f.info(`${o.name}: no existing constraint — using registry latest (${n}). Add to a catalog to share this version across workspace packages.`),{name:o.name,source:"registry latest",spec:n}})},he=(t,c,e,r)=>{for(const{name:i,spec:o}of c){const s=_(o,r);for(const l of de){if(l===e)continue;const a=t[l];a?.[i]!==void 0&&(delete a[i],Object.keys(a).length===0&&delete t[l])}let n=t[e];n===void 0&&(n={},t[e]=n),n[i]=s}},ke=async({ignoreScripts:t,logger:c,options:e,packages:r,pm:i,target:o,visConfig:s,workspaceRoot:n})=>{const{workspace:l}=U(n,s??{}),a=l.projects[o];if(!a){const m=Object.keys(l.projects).sort();throw new Error(`--to: workspace package "${o}" not found. Available: ${m.length>0?m.slice(0,10).join(", "):"(none)"}${m.length>10?`, ... (${String(m.length-10)} more)`:""}.`)}const u=L(n,a.root,"package.json"),{packageManager:p}=N(n),g=V(n,p),d=ge(e),k=e.exact??!1,h=await me(r,g);if(h.length===0)return 0;const $=ie(u);he($,h,d,k),B(u,$,{indent:H(u,{useEditorconfig:s?.editorconfig??!0}),overwrite:!0});for(const m of h){const E=_(m.spec,k);f.info(`${R("+")} ${m.name}@${E} → ${o}/${d} (${j(m.source)})`)}return Y(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:t,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,c)},Me=async({argument:t,logger:c,options:e,visConfig:r,workspaceRoot:i})=>{let o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const p=o.map(d=>D(d)),g=await re(p.map(d=>d.name),r?.security?.typosquatAllowlist);if(!g.ok){process.exitCode=1;return}o=p.map((d,k)=>{const h=g.packages[k];return h!==d.name?d.versionSpec?`${h}@${d.versionSpec}`:h??"":o[k]??""})}if(e.marshallCheck!==!1){const p=await P(o);if(p.length>0){const g=await Q(p,{config:r?.security?.marshalls,workspaceRoot:i});if(!await X(g)){process.exitCode=1;return}}}if(e.socketCheck!==!1){const p=new Set;b("socket")&&p.add("socket"),b("depsDev")&&p.add("deps-dev");const g=F(r?.security,{disabled:p,minimumScore:r?.security?.policies?.score?.minimum});if(g.length>0){const d=r?.security?.policies?.score?.minimum??ne;if(!await ue(o,g,d,r?.security?.acceptedRisks)){process.exitCode=1;return}}}const s=process.cwd(),n=G({logger:c,options:e,visConfig:r},i??s),l=J(i??s,{backend:K(n),configBackend:r?.install?.backend,configCorepack:r?.install?.corepack}),a=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&S(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!i)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const p=await ke({ignoreScripts:a,logger:c,options:e,packages:o,pm:l,target:e.to,visConfig:r,workspaceRoot:i});p!==0&&(process.exitCode=p);return}const u=W(l,{exact:e.exact||!1,filter:S(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:o,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},s,c,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:a});u!==0&&(process.exitCode=u)};export{Me as default};
1
+ import{createRequire as M}from"node:module";import{I as R,E as j,V as A,s as I}from"../packem_shared/index.server-qvZ-cy29.js";import{m as L,O as B}from"../packem_shared/index-D75r1yKp.js";import{P as N}from"../packem_shared/package-version-DBJLduJL.js";import"../packem_shared/public-api-WqUCiyIe.js";import{c as F,f as z,b as U,R as V,l as H}from"./catalog.js";import{i as b,p as f}from"./cli-main.js";import{h as J,j as W,y as Y}from"../packem_shared/pm-runner-D5NWL8yv.js";import{r as G,a as K}from"../packem_shared/command-runtime-Buz4F5LM.js";import{r as P,a as Q,p as X,b as Z}from"../packem_shared/resolve-explicit-CnEsy-zC.js";import{H as ee,F as C,D as oe,J as te,y,B as se,h as ne}from"../packem_shared/en-BRcjb70R.js";import{r as re}from"../packem_shared/typosquats-DWB80Gyv.js";import{f as D,i as S}from"../packem_shared/utils-CRueU43T.js";import{a as ie}from"../packem_shared/readJsonSync-DuMMeB3s-wlhgSHes.js";const q=M(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=t=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[c,e]=w.versions.node.split(".").map(Number);if(c>22||c===22&&e>=3||c===20&&e>=16)return w.getBuiltinModule(t)}return q(t)},{createInterface:T}=O("node:readline"),x=t=>t==="default"?"catalog:":`catalog:${t}`,v=t=>t==="default"?"default catalog":`catalog "${t}"`,ae=(t,c)=>{const e=[];for(const[o,s]of c)o.includes(":")||s.has(t)&&e.push(o);if(e.length===0)return;if(e.length===1){const[o]=e;return{source:v(o),spec:x(o)}}const r=e.find(o=>o==="default")??e[0],i=e.filter(o=>o!==r);return{candidates:[...e],conflict:!0,source:`${v(r)} (also in: ${i.map(o=>v(o)).join(", ")})`,spec:x(r)}},ce=(t,c)=>{const e=new Map;for(const[a,u]of c){if(!a.includes(":"))continue;const p=u.get(t);p!==void 0&&e.set(p,(e.get(p)??0)+1)}if(e.size===0)return;const r=[...e.entries()],i=r.reduce((a,[,u])=>a+u,0);if(r.length===1){const[[a]]=r;return{source:`siblings (${String(i)} pkg${i===1?"":"s"} on ${a})`,spec:a}}const o=[...r].sort((a,u)=>u[1]-a[1]),[s,n]=o[0],l=o.slice(1).map(([a,u])=>`${a} (×${String(u)})`);return{candidates:o.map(([a])=>a),conflict:!0,source:`siblings (most common: ${s} ×${String(n)}; conflicts: ${l.join(", ")})`,spec:s}},le=(t,c)=>ae(t,c)||ce(t,c),pe=(t,c,e)=>{const r=[];for(const i of t.values()){const{overall:o}=i.score,s=se(o),n=`${String(Math.round(o*100))}%`,l=i.alerts.length,a=y(i),u=ee(a,i.version,e),p=s==="red"?A:s==="yellow"?I:R;if(u?f.info(` ${p(n)} ${C(i)} ${j(`[accepted: ${u.reason}]`)}`):f.info(` ${p(n)} ${C(i)}`),l>0){const g=i.alerts.filter(d=>d.severity==="critical"||d.severity==="high").length;g>0&&f.warn(` ${String(g)} critical/high alert${g===1?"":"s"}`)}o<c&&!u&&r.push(i)}return r},fe=async(t,c)=>{const e=T({input:process.stdin,output:process.stdout}),r=n=>new Promise(l=>{e.question(n,a=>{l(a.trim())})}),i=String(Math.round(c*100));f.warn(""),f.warn(`${String(t.length)} package${t.length===1?"":"s"} scored below the minimum threshold (${i}%):`);for(const n of t){const l=y(n),a=`${String(Math.round(n.score.overall*100))}%`;f.warn(` • ${l}@${n.version} — score: ${a} (${oe(n.score.overall)})`)}f.warn("");const o=await r("Continue adding these packages? [y/N] ");if(o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes")return e.close(),!1;const s=await r("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),s.toLowerCase()==="y"||s.toLowerCase()==="yes"){f.notice(""),f.notice("Add the following to security.acceptedRisks in vis.config.ts:"),f.notice("");for(const n of t){const l=y(n),a=te(l,n.version,n.score.overall,"Reviewed and accepted");f.notice(a)}f.notice("")}return!0},ue=async(t,c,e,r)=>{const i=await P(t);if(i.length===0)return!0;f.info(""),f.info(`${c.map(n=>n.displayName).join(" + ")} security check:`);const o=await z(c,i);if(o.size===0)return f.info(" Could not fetch security data. Proceeding."),!0;const s=pe(o,e,r);return s.length===0?(f.info(""),!0):process.stdin.isTTY?fe(s,e):(f.warn(`Aborting: ${String(s.length)} package${s.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},de=["dependencies","devDependencies","peerDependencies","optionalDependencies"],ge=t=>t.savePeer?"peerDependencies":t.saveOptional?"optionalDependencies":t.saveDev?"devDependencies":"dependencies",_=(t,c)=>t.startsWith("catalog:")||!c?t:t.replace(/^[\^~]/,""),me=async(t,c)=>{const e=[];for(const o of t){const{name:s,versionSpec:n}=D(o);if(!s)continue;if(n!==void 0){e.push({explicit:n,name:s});continue}const l=le(s,c);if(l){l.conflict&&f.warn(`${s}: ambiguous constraint — picking ${l.spec} (${l.source}). Pass ${s}@<version> to override.`),e.push({entry:{name:s,source:l.source,spec:l.spec},kind:"resolved",name:s});continue}e.push({kind:"missing",name:s})}const r=e.filter(o=>"kind"in o&&o.kind==="missing").map(o=>o.name),i=r.length>0?await Z(r):new Map;return e.map(o=>{if("explicit"in o)return{name:o.name,source:"explicit",spec:o.explicit};if(o.kind==="resolved")return o.entry;const s=i.get(o.name);if(s===void 0)throw new Error(`--to: cannot resolve a version for "${o.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${o.name}@<version> explicitly.`);const n=`^${s}`;return f.info(`${o.name}: no existing constraint — using registry latest (${n}). Add to a catalog to share this version across workspace packages.`),{name:o.name,source:"registry latest",spec:n}})},he=(t,c,e,r)=>{for(const{name:i,spec:o}of c){const s=_(o,r);for(const l of de){if(l===e)continue;const a=t[l];a?.[i]!==void 0&&(delete a[i],Object.keys(a).length===0&&delete t[l])}let n=t[e];n===void 0&&(n={},t[e]=n),n[i]=s}},ke=async({ignoreScripts:t,logger:c,options:e,packages:r,pm:i,target:o,visConfig:s,workspaceRoot:n})=>{const{workspace:l}=U(n,s??{}),a=l.projects[o];if(!a){const m=Object.keys(l.projects).sort();throw new Error(`--to: workspace package "${o}" not found. Available: ${m.length>0?m.slice(0,10).join(", "):"(none)"}${m.length>10?`, ... (${String(m.length-10)} more)`:""}.`)}const u=L(n,a.root,"package.json"),{packageManager:p}=N(n),g=V(n,p),d=ge(e),k=e.exact??!1,h=await me(r,g);if(h.length===0)return 0;const $=ie(u);he($,h,d,k),B(u,$,{indent:H(u,{useEditorconfig:s?.editorconfig??!0}),overwrite:!0});for(const m of h){const E=_(m.spec,k);f.info(`${R("+")} ${m.name}@${E} → ${o}/${d} (${j(m.source)})`)}return Y(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:t,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,c)},Me=async({argument:t,logger:c,options:e,visConfig:r,workspaceRoot:i})=>{let o=t;if(!o||o.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const p=o.map(d=>D(d)),g=await re(p.map(d=>d.name),r?.security?.typosquatAllowlist);if(!g.ok){process.exitCode=1;return}o=p.map((d,k)=>{const h=g.packages[k];return h!==d.name?d.versionSpec?`${h}@${d.versionSpec}`:h??"":o[k]??""})}if(e.marshallCheck!==!1){const p=await P(o);if(p.length>0){const g=await Q(p,{config:r?.security?.marshalls,workspaceRoot:i});if(!await X(g)){process.exitCode=1;return}}}if(e.socketCheck!==!1){const p=new Set;b("socket")&&p.add("socket"),b("depsDev")&&p.add("deps-dev");const g=F(r?.security,{disabled:p,minimumScore:r?.security?.policies?.score?.minimum});if(g.length>0){const d=r?.security?.policies?.score?.minimum??ne;if(!await ue(o,g,d,r?.security?.acceptedRisks)){process.exitCode=1;return}}}const s=process.cwd(),n=G({logger:c,options:e,visConfig:r},i??s),l=J(i??s,{backend:K(n),configBackend:r?.install?.backend,configCorepack:r?.install?.corepack}),a=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&S(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!i)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const p=await ke({ignoreScripts:a,logger:c,options:e,packages:o,pm:l,target:e.to,visConfig:r,workspaceRoot:i});p!==0&&(process.exitCode=p);return}const u=W(l,{exact:e.exact||!1,filter:S(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:o,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},s,c,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:a});u!==0&&(process.exitCode=u)};export{Me as default};
@@ -1,2 +1,2 @@
1
- import{B as k,a as B,H as g}from"../packem_shared/index-D75r1yKp.js";import{b as h,O as j}from"./catalog.js";import{p}from"./cli-main.js";import{b as v,s as y}from"../packem_shared/cyclonedx-C96cm9hF.js";const l=["json","xml"],C=n=>l.includes(n),F=async({fs:n,options:e,visConfig:f,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:d,workspace:i}=h(o,f),u=j(o,i,d),c=e.focus,w=c?c.split(",").map(b=>b.trim()).filter(Boolean):void 0,s=(e.format??"json").toLowerCase();if(!C(s))throw new Error(`Unknown --format: "${s}". Expected one of: ${l.join(", ")}.`);const t=v({focus:w,includeDev:!!e.includeDev,projectGraph:u,workspace:i,workspaceRoot:o}),a=s==="xml"?y(t):`${JSON.stringify(t,void 0,2)}
1
+ import{B as k,a as B,H as g}from"../packem_shared/index-D75r1yKp.js";import{b as h,O as j}from"./catalog.js";import{p}from"./cli-main.js";import{b as v,s as y}from"../packem_shared/cyclonedx-DFlz2HRz.js";const l=["json","xml"],C=n=>l.includes(n),F=async({fs:n,options:e,visConfig:f,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:d,workspace:i}=h(o,f),u=j(o,i,d),c=e.focus,w=c?c.split(",").map(b=>b.trim()).filter(Boolean):void 0,s=(e.format??"json").toLowerCase();if(!C(s))throw new Error(`Unknown --format: "${s}". Expected one of: ${l.join(", ")}.`);const t=v({focus:w,includeDev:!!e.includeDev,projectGraph:u,workspace:i,workspaceRoot:o}),a=s==="xml"?y(t):`${JSON.stringify(t,void 0,2)}
2
2
  `,m=e.output??(s==="xml"?"sbom.cdx.xml":"sbom.cdx.json");if(m==="-"){process.stdout.write(a);return}const r=k(o,m);B(g(r)),await n.writeFile(r,a,"utf8");const x=t.components?.length??0,$=t.dependencies?.length??0;p.success(`SBOM written to ${r}`),p.notice(`${x} components, ${$} dependency edges`)};export{F as default};
@@ -1,3 +1,3 @@
1
- import{createRequire as u}from"node:module";import{m as p}from"../packem_shared/package-version-gyjskW3N.js";const f=u(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,a=s=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[n,i]=r.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return r.getBuiltinModule(s)}return f(s)},{execSync:d,spawnSync:l}=a("node:child_process"),v=async({argument:s,logger:n,options:i})=>{const t=s?.[0];n.info("info: checking for updates...");const o=p();let e;try{const c=d("npm view @visulima/vis version",{encoding:"utf8"}).trim();e=t??c}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(o===e&&!i.force){n.info(`
1
+ import{createRequire as u}from"node:module";import{m as p}from"../packem_shared/package-version-DBJLduJL.js";const f=u(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,a=s=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[n,i]=r.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return r.getBuiltinModule(s)}return f(s)},{execSync:d,spawnSync:l}=a("node:child_process"),v=async({argument:s,logger:n,options:i})=>{const t=s?.[0];n.info("info: checking for updates...");const o=p();let e;try{const c=d("npm view @visulima/vis version",{encoding:"utf8"}).trim();e=t??c}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(o===e&&!i.force){n.info(`
2
2
  ✓ Already up to date (${o})`);return}if(i.check){o===e?n.info(`✓ Already up to date (${o})`):n.info(`info: found @visulima/vis@${e} (current: ${o})`);return}if(n.info(`info: found @visulima/vis@${e} (current: ${o})`),n.info("info: installing..."),l("npm",["install","-g",`@visulima/vis@${e}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");n.info(`
3
3
  ✓ Updated @visulima/vis from ${o} → ${e}`)};export{v as default};
@@ -1,4 +1,4 @@
1
- import{P as N}from"../packem_shared/package-version-gyjskW3N.js";import"../packem_shared/index-D75r1yKp.js";import"../packem_shared/public-api-WqUCiyIe.js";import{K as C,Z as P,W as T}from"../packem_shared/ai-analysis-DWBi9tSU.js";import{R as I,T as j,a as h,N as q,c as x,f as z,q as A,I as F}from"./catalog.js";const M=/^[\^~>=<]+/,V=async({argument:v,logger:n,options:c,visConfig:l,workspaceRoot:f})=>{if(!f)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const m=v,e=m[0];if(!e)throw new Error("Package name is required. Usage: vis analyze <package> [version]");const p=m[1],{packageManager:R}=N(f);let t,u="default";const b=I(f,R);for(const[o,i]of b){const a=i.get(e);if(a){t=a,u=o;break}}if(!t)throw new Error(`Package "${e}" not found in any catalog or package.json. Make sure it exists in your workspace dependencies.`);let r;if(p)r=p;else{n.info(`Fetching latest version for ${e}...
1
+ import{P as N}from"../packem_shared/package-version-DBJLduJL.js";import"../packem_shared/index-D75r1yKp.js";import"../packem_shared/public-api-WqUCiyIe.js";import{K as C,Z as P,W as T}from"../packem_shared/ai-analysis-DWBi9tSU.js";import{R as I,T as j,a as h,N as q,c as x,f as z,q as A,I as F}from"./catalog.js";const M=/^[\^~>=<]+/,V=async({argument:v,logger:n,options:c,visConfig:l,workspaceRoot:f})=>{if(!f)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const m=v,e=m[0];if(!e)throw new Error("Package name is required. Usage: vis analyze <package> [version]");const p=m[1],{packageManager:R}=N(f);let t,u="default";const b=I(f,R);for(const[o,i]of b){const a=i.get(e);if(a){t=a,u=o;break}}if(!t)throw new Error(`Package "${e}" not found in any catalog or package.json. Make sure it exists in your workspace dependencies.`);let r;if(p)r=p;else{n.info(`Fetching latest version for ${e}...
2
2
  `);const o=await j(e);if(!o.latest)throw new Error(`Could not determine latest version for "${e}".`);r=o.latest}const d=h(t),w=h(r);if(!d||!w)throw new Error(`Could not parse versions: current="${t}", target="${r}".`);const k=A(d,w);if(k==="none"){n.info(`${e} is already at ${r}. Nothing to analyze.`);return}const E=F(t),g={catalogName:u,currentRange:t,newRange:`${E}${r}`,packageName:e,targetVersion:r,updateType:k},y=C(c.aiType??"impact");if(y==="security"||c.security){n.info(`Checking for known vulnerabilities...
3
3
  `);const o=t.replace(M,""),i=(await q([{name:e,version:o}])).get(e);i&&i.length>0&&(g.vulnerabilities=i);const a=x(l?.security,{minimumScore:l?.security?.policies?.score?.minimum});if(a.length>0){const s=(await z(a,[{name:e,version:o}])).get(`${e}@${o}`);s&&(g.socketReport={alerts:s.alerts,license:s.license,score:s.score})}}const $=await P([g],n,l?.ai,y);(c.format??"table")==="json"?process.stdout.write(`${JSON.stringify($,void 0,2)}
4
4
  `):n.info(T($))};export{V as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as b}from"node:module";import{h as _,d as O,E as j}from"./catalog.js";import"../packem_shared/en-BRcjb70R.js";import{A as R}from"../packem_shared/pm-runner-D5NWL8yv.js";import{l as E}from"../packem_shared/dependency-scan-I_UnVof_.js";import{r as I}from"../packem_shared/provenance-ByHgofYo.js";import{r as P}from"../packem_shared/signatures-kvrwi3Un.js";import{loadOptionalSigstore as C}from"./loader.js";const N=b(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=r=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[o,t]=u.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return u.getBuiltinModule(r)}return N(r)},{createHash:S}=$("node:crypto"),{isAbsolute:y,resolve:k,basename:v}=$("node:path"),T=r=>(r??"").split(",").map(o=>o.trim()).filter(o=>o.length>0),G=async({logger:r,options:o,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=o.format??"table",c=o.prodOnly??!1,p=o.failOn==="error"?"error":"warning",l=T(o.allowlist),a=R(t),d=E(t,a.name,{includeDev:!c}).map(({name:e,version:i})=>({name:e,version:i})),[m,g]=await Promise.all([I(d,{allowlist:l,workspaceRoot:t}),P(d,{allowlist:l,workspaceRoot:t})]),s=[...m.map(e=>({code:"provenance-regression",message:`Resolved ${e.packageName}@${e.version} has no published provenance attestation, but ${e.packageName}@${e.priorVersionWithProvenance} did — a provenance regression.`,packageName:e.packageName,severity:"warning",version:e.version})),...g.map(e=>({code:e.code,message:e.message,packageName:e.packageName,severity:e.severity,version:e.version}))],f=s.filter(e=>p==="error"?e.severity==="error":!0);if(n==="json")process.stdout.write(`${JSON.stringify({findings:s,ok:f.length===0},void 0,2)}
1
+ import{createRequire as b}from"node:module";import{h as _,d as O,E as j}from"./catalog.js";import"../packem_shared/en-BRcjb70R.js";import{A as R}from"../packem_shared/pm-runner-D5NWL8yv.js";import{l as E}from"../packem_shared/dependency-scan-173U3WXB.js";import{r as I}from"../packem_shared/provenance-ByHgofYo.js";import{r as P}from"../packem_shared/signatures-kvrwi3Un.js";import{loadOptionalSigstore as C}from"./loader.js";const N=b(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=r=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[o,t]=u.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return u.getBuiltinModule(r)}return N(r)},{createHash:S}=$("node:crypto"),{isAbsolute:y,resolve:k,basename:v}=$("node:path"),T=r=>(r??"").split(",").map(o=>o.trim()).filter(o=>o.length>0),G=async({logger:r,options:o,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=o.format??"table",c=o.prodOnly??!1,p=o.failOn==="error"?"error":"warning",l=T(o.allowlist),a=R(t),d=E(t,a.name,{includeDev:!c}).map(({name:e,version:i})=>({name:e,version:i})),[m,g]=await Promise.all([I(d,{allowlist:l,workspaceRoot:t}),P(d,{allowlist:l,workspaceRoot:t})]),s=[...m.map(e=>({code:"provenance-regression",message:`Resolved ${e.packageName}@${e.version} has no published provenance attestation, but ${e.packageName}@${e.priorVersionWithProvenance} did — a provenance regression.`,packageName:e.packageName,severity:"warning",version:e.version})),...g.map(e=>({code:e.code,message:e.message,packageName:e.packageName,severity:e.severity,version:e.version}))],f=s.filter(e=>p==="error"?e.severity==="error":!0);if(n==="json")process.stdout.write(`${JSON.stringify({findings:s,ok:f.length===0},void 0,2)}
2
2
  `);else if(n==="ndjson")for(const e of s)process.stdout.write(`${JSON.stringify(e)}
3
3
  `);else if(s.length===0)r.info(`No provenance regressions or signature problems across ${String(d.length)} locked packages.`);else{const e=process.stdout.columns||80;r.info(_(O.createElement(j,{data:s.map(i=>({code:i.code,package:`${i.packageName}@${i.version}`,severity:i.severity}))}),{columns:e}));for(const i of s)r.warn(`${i.packageName}@${i.version}: ${i.message}`)}f.length>0&&(process.exitCode=1)},D=()=>process.env.CI==="true"||typeof process.env.ACTIONS_ID_TOKEN_REQUEST_URL=="string"||typeof process.env.SIGSTORE_ID_TOKEN=="string",q=(r,o,t)=>({_type:"https://in-toto.io/Statement/v1",predicate:{buildDefinition:{buildType:"https://visulima.com/vis/attest/v1",externalParameters:{workspaceRoot:t},internalParameters:{},resolvedDependencies:[]},runDetails:{builder:{id:"https://visulima.com/vis"},metadata:{invocationId:process.env.GITHUB_RUN_ID??"",startedOn:new Date().toISOString()}}},predicateType:"https://slsa.dev/provenance/v1",subject:[{digest:{sha256:o},name:r}]}),H=async({argument:r,fs:o,logger:t,options:n,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const p=r[0];if(!p)throw new Error("Missing subject. Usage: vis attest <path-to-artifact>");const l=n.predicate??"slsaProvenance";if(l!=="slsaProvenance")throw new Error(`Unsupported predicate '${l}'. Only 'slsaProvenance' is supported.`);const a=y(p)?p:k(c,p),d=n.requireSigning??!1,m=n.format??"table";let g;try{g=await o.readFile(a)}catch{throw new Error(`Cannot read subject artifact at ${a}.`)}const s=S("sha256").update(g).digest("hex");if(!D()){const h="No ambient OIDC token (not running in CI). Keyless signing needs a Fulcio identity from CI OIDC.";if(d)throw new Error(`${h} Re-run in CI or drop --require-signing.`);if(m==="json"){process.stdout.write(`${JSON.stringify({ok:!1,reason:"no-ambient-oidc",sha256:s,skipped:!0,subject:v(a)},void 0,2)}
4
4
  `);return}t.warn(`${h} Skipping signing (subject sha256: ${s}). Pass --require-signing to make this fatal.`);return}const f=q(v(a),s,c),e=Buffer.from(JSON.stringify(f)),i=await(await C({workspaceRoot:c})).attest(e,"application/vnd.in-toto+json"),w=n.output?y(n.output)?n.output:k(c,n.output):`${a}.sigstore`;if(await o.writeFile(w,`${JSON.stringify(i,void 0,2)}
@@ -1,4 +1,4 @@
1
- import{createRequire as G}from"node:module";import{P as H}from"../packem_shared/package-version-gyjskW3N.js";import"../packem_shared/index-D75r1yKp.js";import"../packem_shared/public-api-WqUCiyIe.js";import{g as J,R as O,c as V,V as W,$ as S,d as a,h as K,i as g,H as T,j as Z,G as Q,F as p}from"./catalog.js";import{B as X}from"../packem_shared/en-BRcjb70R.js";import{I as ee}from"../packem_shared/index-B0EsgdzO.js";import{K as te,Z as oe,W as re}from"../packem_shared/ai-analysis-DWBi9tSU.js";import{w as se,k as ne,p as m,i as M}from"./cli-main.js";import{A as ie}from"../packem_shared/pm-runner-D5NWL8yv.js";import{U as ae,b as ce,u as N}from"../packem_shared/vis-update-app-M3dw6XRC.js";const de=G(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const Re=async({argument:E,logger:o,options:e,visConfig:i,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.securityConfig){const t=ie(d);if(se(i??{},t.name),e.sync&&t.name==="pnpm"){const r=ne(i??{});if(r.length>0){m.info(`
1
+ import{createRequire as G}from"node:module";import{P as H}from"../packem_shared/package-version-DBJLduJL.js";import"../packem_shared/index-D75r1yKp.js";import"../packem_shared/public-api-WqUCiyIe.js";import{g as J,R as O,c as V,V as W,$ as S,d as a,h as K,i as g,H as T,j as Z,G as Q,F as p}from"./catalog.js";import{B as X}from"../packem_shared/en-BRcjb70R.js";import{I as ee}from"../packem_shared/index-B0EsgdzO.js";import{K as te,Z as oe,W as re}from"../packem_shared/ai-analysis-DWBi9tSU.js";import{w as se,k as ne,p as m,i as M}from"./cli-main.js";import{A as ie}from"../packem_shared/pm-runner-D5NWL8yv.js";import{U as ae,b as ce,u as N}from"../packem_shared/vis-update-app-M3dw6XRC.js";const de=G(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const Re=async({argument:E,logger:o,options:e,visConfig:i,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.securityConfig){const t=ie(d);if(se(i??{},t.name),e.sync&&t.name==="pnpm"){const r=ne(i??{});if(r.length>0){m.info(`
2
2
  Settings that would sync to pnpm-workspace.yaml:`);for(const b of r)m.success(` ${b}`)}else m.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(m.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),m.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!E?.length)return}const{packageManager:U}=H(d),B=J(d),c=i?.update??{},y=O(d,U,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(y.size===0){o.info("No catalogs found.");return}const h=e.target??c.target??"latest";if(!["latest","minor","patch"].includes(h))throw new Error(`Invalid target "${h}". Use: latest, minor, or patch.`);const D={exclude:[...p(e.exclude),...p(c.exclude)],ignore:p(c.ignore),include:[...p(e.include),...p(c.include),...E],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||c.prerelease||!1,security:e.security!==!1,target:h};let j=0;for(const t of y.values())j+=t.size;const $=!!process.stdout.isTTY&&!ee;let l;const F=$?(t,r)=>{l?l.rerender(a.createElement(N,{current:t,total:r})):l=S(a.createElement(N,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{o.info(`Checking ${String(t)}/${String(r)} dependencies...`)};$||o.info(`Checking ${String(j)} catalog dependencies against npm registry...
3
3
  `);const v=new Set;M("socket")&&v.add("socket"),M("depsDev")&&v.add("deps-dev");const w=i?.security?.policies?.score?.minimum,I=V(i?.security,{disabled:v,minimumScore:w}),{failed:k,outdated:n}=await W(y,D,B,F,d,I,i?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),k.length>0&&o.warn(`Failed to fetch: ${k.join(", ")}`),n.length===0){o.info("All catalog dependencies are up to date.");return}const R=e.format??c.format??"table",P=te(e.aiType??"impact"),u=e.ai?await oe(n,o,i?.ai,P):void 0;if($&&R==="table"){const t=new ae(n,u??null),r=i?.tui?.autoExit??!1,b=r===!0?3:typeof r=="number"?r:0;await S(a.createElement(ce,{autoExitSeconds:b,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
4
4
  `);for(const s of n){const z=s.vulnerabilities?.length||s.socketReport&&s.socketReport.alerts.length>0,_=!!s.acceptedRisk,A=z?_?"✓":"⚠":"✓",L=_?"gray":s.updateType==="major"?"red":s.updateType==="minor"?"yellow":"green",f=s.socketReport?.score.overall,Y=f===void 0?"":` [${String(Math.round(f*100))}%]`,x=f===void 0?void 0:X(f);process.stdout.write(`${K(a.createElement(g,null," ",a.createElement(g,{color:L},A),` ${s.packageName} ${s.currentRange} → ${s.newRange}`,a.createElement(g,{dimColor:!0},` ${s.updateType}`),x?a.createElement(g,{color:x},Y):null),{columns:q})}
@@ -1,4 +1,4 @@
1
- import{createRequire as mt}from"node:module";import{E as v,j as le,q as ke,I as fe,V as ve,s as Re}from"../packem_shared/index.server-qvZ-cy29.js";import{P as We}from"../packem_shared/package-version-gyjskW3N.js";import{m as W,f as be,a as yt,v as wt,u as kt,A as vt,B as Ke}from"../packem_shared/index-D75r1yKp.js";import{E as bt}from"../packem_shared/public-api-WqUCiyIe.js";import{m as s,n as u,i as r,r as O,R as Xe,c as Je,$ as jt,d as $t,g as St,V as Ct,N as Rt,f as At}from"./catalog.js";import{g as It,B as Pe,h as Qe}from"../packem_shared/en-BRcjb70R.js";import{I as Mt}from"../packem_shared/index-B0EsgdzO.js";import{a3 as Et,I as Dt,_ as Ft,J as Pt,G as zt,y as Ot,K as Bt,M as Oe,p as d,S as N}from"./cli-main.js";import{a as et}from"../packem_shared/readJsonSync-DuMMeB3s-wlhgSHes.js";import{findVisConfigFile as Lt}from"./CONFIG_FILES.js";import{A as tt,x as Be,N as _t,F as Vt,T as Gt,a as Ut,I as Ht,U as Yt}from"./handler67.js";import{A as it,y as qt}from"../packem_shared/pm-runner-D5NWL8yv.js";import{c as Wt}from"../packem_shared/runtime-check-B1OF152E.js";import{s as Kt}from"../packem_shared/scan-progress-CHdHWhVw.js";import{l as Xt,r as Jt,f as Qt}from"../packem_shared/dependency-scan-I_UnVof_.js";import{o as st}from"../packem_shared/spinner-DuJJvFTl.js";import{F as Zt,a as ei}from"../packem_shared/tabs-CgxCvjCY.js";import{u as ti}from"../packem_shared/use-measured-height-C4jA0yNy.js";import{s as ii}from"../packem_shared/verify-BajubByH.js";const xt=mt(import.meta.url),ye=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,qe=e=>{if(typeof ye<"u"&&ye.versions&&ye.versions.node){const[t,i]=ye.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return ye.getBuiltinModule(e)}return xt(e)},{spawnSync:Ae}=qe("node:child_process"),{rmSync:ze,writeFileSync:Tt,statSync:Nt,readFileSync:Ze}=qe("node:fs"),Te=()=>W(It(),"doctor"),si=1800*1e3,Le=e=>{if(!e)return"";try{return String(Nt(e).mtimeMs)}catch{return""}},ri=2,ni=e=>{const t=JSON.stringify({configMtime:Le(e.configPath),lockfileMtime:Le(e.lockfilePath),schema:ri,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return Et(Buffer.from(t))},oi=e=>{const t=W(Te(),`${e}.json`);if(be(t))try{const i=et(t);if(Date.now()-i.createdAt>i.ttlMs){ze(t,{force:!0});return}return{...i.results,sections:new Set(i.results.sections)}}catch{ze(t,{force:!0});return}},li=(e,t,i=si)=>{yt(Te());const l={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:i};Tt(W(Te(),`${e}.json`),JSON.stringify(l,void 0,2),"utf8")},$e="orphans",ai=()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=Ze("/proc/sys/fs/inotify/max_user_watches","utf8").trim(),i=Number.parseInt(t,10);Number.isFinite(i)&&i>0&&(e=i)}catch{return{id:"inotify",message:"Could not read /proc/sys/fs/inotify/max_user_watches.",status:"warn"}}return e===void 0?{id:"inotify",message:"inotify max_user_watches reported a non-numeric value.",status:"warn"}:e<65536?{detail:{maxWatches:e},id:"inotify",message:`inotify watcher limit is ${String(e)} — large monorepos can exhaust this. Bump now with \`sudo sysctl fs.inotify.max_user_watches=524288\` and persist via \`/etc/sysctl.d/99-vis.conf\` so it survives reboot.`,status:"warn"}:{detail:{maxWatches:e},id:"inotify",message:`inotify capacity OK (${String(e)} watches).`,status:"ok"}},ci=()=>{const e=!!process.stdin.isTTY,t=!!process.stdout.isTTY;return e&&t?{id:"tty",message:"Interactive TTY available — watch keybinds enabled.",status:"ok"}:!e&&!t?{id:"tty",message:"No TTY on stdin/stdout — running in CI / piped mode (keybinds disabled).",status:"skip"}:{detail:{stdin:String(e),stdout:String(t)},id:"tty",message:e?"stdin is a TTY but stdout is not — output is being captured; keybinds still work.":"stdout is a TTY but stdin is not — keybinds disabled (input is piped).",status:"skip"}},di=()=>{const e=process.pid;try{return process.platform==="win32"?ot(e):nt(e)}catch{return[]}},ui=()=>{const e=process.pid;let t;try{t=process.platform==="win32"?ot(e):nt(e)}catch{return{id:$e,message:"Could not enumerate processes (ps/tasklist failed).",status:"warn"}}if(t.length===0)return{id:$e,message:"No orphaned vis/task-runner processes detected.",status:"ok"};if(t.length<=2)return{detail:{count:t.length,pids:t.join(",")},id:$e,message:`${String(t.length)} possibly orphaned process(es) detected (PIDs: ${t.join(", ")}). Likely benign.`,status:"skip"};const i=process.platform==="win32"?t.map(l=>`taskkill /F /PID ${String(l)}`).join(" & "):`kill ${t.join(" ")}`;return{detail:{count:t.length,pids:t.join(",")},id:"orphans",message:`${String(t.length)} possibly orphaned vis/task-runner processes — run \`vis doctor --fix\` to clean them up, or kill them manually: ${i}`,status:"warn"}},hi=(e={})=>{const t=e.enumerate??di,i=e.force===!0?"SIGKILL":"SIGTERM",l=e.kill??xi,n=t(),o=[],c=[];for(const h of n)try{l(h,i),o.push(h)}catch(a){const p=a.code??a.message;if(p==="ESRCH"){o.push(h);continue}c.push({pid:h,reason:p})}return{failed:c,killed:o}},pi=e=>Ae("taskkill",e,{encoding:"utf8",timeout:1e4}),gi=(e,t)=>{process.kill(e,t)},fi=(e,t,i=pi)=>{const l=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],n=i(l);if(n.error)throw n.error;if(typeof n.status=="number"&&n.status!==0){const o=n.status===128?"ESRCH":`taskkill exited with code ${String(n.status)}`,c=new Error(o);throw c.code=o,c}},mi=(e,t,i=gi)=>{i(e,t)},xi=(e,t)=>{if(process.platform==="win32"){fi(e,t);return}mi(e,t)},rt=(e,t)=>{const i=Ae(e,t,{encoding:"utf8",timeout:1e4});if(i.error)throw i.error;if(typeof i.status=="number"&&i.status!==0)throw new Error(`${e} exited with code ${String(i.status)}`);return typeof i.stdout=="string"?i.stdout:""},nt=e=>{const t=rt("ps",["-Ao","pid=,command="]),i=[];for(const l of t.split(`
1
+ import{createRequire as mt}from"node:module";import{E as v,j as le,q as ke,I as fe,V as ve,s as Re}from"../packem_shared/index.server-qvZ-cy29.js";import{P as We}from"../packem_shared/package-version-DBJLduJL.js";import{m as W,f as be,a as yt,v as wt,u as kt,A as vt,B as Ke}from"../packem_shared/index-D75r1yKp.js";import{E as bt}from"../packem_shared/public-api-WqUCiyIe.js";import{m as s,n as u,i as r,r as O,R as Xe,c as Je,$ as jt,d as $t,g as St,V as Ct,N as Rt,f as At}from"./catalog.js";import{g as It,B as Pe,h as Qe}from"../packem_shared/en-BRcjb70R.js";import{I as Mt}from"../packem_shared/index-B0EsgdzO.js";import{a3 as Et,I as Dt,_ as Ft,J as Pt,G as zt,y as Ot,K as Bt,M as Oe,p as d,S as N}from"./cli-main.js";import{a as et}from"../packem_shared/readJsonSync-DuMMeB3s-wlhgSHes.js";import{findVisConfigFile as Lt}from"./CONFIG_FILES.js";import{A as tt,x as Be,N as _t,F as Vt,T as Gt,a as Ut,I as Ht,U as Yt}from"./handler67.js";import{A as it,y as qt}from"../packem_shared/pm-runner-D5NWL8yv.js";import{c as Wt}from"../packem_shared/runtime-check-B1OF152E.js";import{s as Kt}from"../packem_shared/scan-progress-CHdHWhVw.js";import{l as Xt,r as Jt,f as Qt}from"../packem_shared/dependency-scan-173U3WXB.js";import{o as st}from"../packem_shared/spinner-DuJJvFTl.js";import{F as Zt,a as ei}from"../packem_shared/tabs-CgxCvjCY.js";import{u as ti}from"../packem_shared/use-measured-height-C4jA0yNy.js";import{s as ii}from"../packem_shared/verify-BajubByH.js";const xt=mt(import.meta.url),ye=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,qe=e=>{if(typeof ye<"u"&&ye.versions&&ye.versions.node){const[t,i]=ye.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return ye.getBuiltinModule(e)}return xt(e)},{spawnSync:Ae}=qe("node:child_process"),{rmSync:ze,writeFileSync:Tt,statSync:Nt,readFileSync:Ze}=qe("node:fs"),Te=()=>W(It(),"doctor"),si=1800*1e3,Le=e=>{if(!e)return"";try{return String(Nt(e).mtimeMs)}catch{return""}},ri=2,ni=e=>{const t=JSON.stringify({configMtime:Le(e.configPath),lockfileMtime:Le(e.lockfilePath),schema:ri,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return Et(Buffer.from(t))},oi=e=>{const t=W(Te(),`${e}.json`);if(be(t))try{const i=et(t);if(Date.now()-i.createdAt>i.ttlMs){ze(t,{force:!0});return}return{...i.results,sections:new Set(i.results.sections)}}catch{ze(t,{force:!0});return}},li=(e,t,i=si)=>{yt(Te());const l={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:i};Tt(W(Te(),`${e}.json`),JSON.stringify(l,void 0,2),"utf8")},$e="orphans",ai=()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=Ze("/proc/sys/fs/inotify/max_user_watches","utf8").trim(),i=Number.parseInt(t,10);Number.isFinite(i)&&i>0&&(e=i)}catch{return{id:"inotify",message:"Could not read /proc/sys/fs/inotify/max_user_watches.",status:"warn"}}return e===void 0?{id:"inotify",message:"inotify max_user_watches reported a non-numeric value.",status:"warn"}:e<65536?{detail:{maxWatches:e},id:"inotify",message:`inotify watcher limit is ${String(e)} — large monorepos can exhaust this. Bump now with \`sudo sysctl fs.inotify.max_user_watches=524288\` and persist via \`/etc/sysctl.d/99-vis.conf\` so it survives reboot.`,status:"warn"}:{detail:{maxWatches:e},id:"inotify",message:`inotify capacity OK (${String(e)} watches).`,status:"ok"}},ci=()=>{const e=!!process.stdin.isTTY,t=!!process.stdout.isTTY;return e&&t?{id:"tty",message:"Interactive TTY available — watch keybinds enabled.",status:"ok"}:!e&&!t?{id:"tty",message:"No TTY on stdin/stdout — running in CI / piped mode (keybinds disabled).",status:"skip"}:{detail:{stdin:String(e),stdout:String(t)},id:"tty",message:e?"stdin is a TTY but stdout is not — output is being captured; keybinds still work.":"stdout is a TTY but stdin is not — keybinds disabled (input is piped).",status:"skip"}},di=()=>{const e=process.pid;try{return process.platform==="win32"?ot(e):nt(e)}catch{return[]}},ui=()=>{const e=process.pid;let t;try{t=process.platform==="win32"?ot(e):nt(e)}catch{return{id:$e,message:"Could not enumerate processes (ps/tasklist failed).",status:"warn"}}if(t.length===0)return{id:$e,message:"No orphaned vis/task-runner processes detected.",status:"ok"};if(t.length<=2)return{detail:{count:t.length,pids:t.join(",")},id:$e,message:`${String(t.length)} possibly orphaned process(es) detected (PIDs: ${t.join(", ")}). Likely benign.`,status:"skip"};const i=process.platform==="win32"?t.map(l=>`taskkill /F /PID ${String(l)}`).join(" & "):`kill ${t.join(" ")}`;return{detail:{count:t.length,pids:t.join(",")},id:"orphans",message:`${String(t.length)} possibly orphaned vis/task-runner processes — run \`vis doctor --fix\` to clean them up, or kill them manually: ${i}`,status:"warn"}},hi=(e={})=>{const t=e.enumerate??di,i=e.force===!0?"SIGKILL":"SIGTERM",l=e.kill??xi,n=t(),o=[],c=[];for(const h of n)try{l(h,i),o.push(h)}catch(a){const p=a.code??a.message;if(p==="ESRCH"){o.push(h);continue}c.push({pid:h,reason:p})}return{failed:c,killed:o}},pi=e=>Ae("taskkill",e,{encoding:"utf8",timeout:1e4}),gi=(e,t)=>{process.kill(e,t)},fi=(e,t,i=pi)=>{const l=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],n=i(l);if(n.error)throw n.error;if(typeof n.status=="number"&&n.status!==0){const o=n.status===128?"ESRCH":`taskkill exited with code ${String(n.status)}`,c=new Error(o);throw c.code=o,c}},mi=(e,t,i=gi)=>{i(e,t)},xi=(e,t)=>{if(process.platform==="win32"){fi(e,t);return}mi(e,t)},rt=(e,t)=>{const i=Ae(e,t,{encoding:"utf8",timeout:1e4});if(i.error)throw i.error;if(typeof i.status=="number"&&i.status!==0)throw new Error(`${e} exited with code ${String(i.status)}`);return typeof i.stdout=="string"?i.stdout:""},nt=e=>{const t=rt("ps",["-Ao","pid=,command="]),i=[];for(const l of t.split(`
2
2
  `)){if(l.length===0)continue;const n=/^\s*(\d+)\s+(.+)$/.exec(l);if(!n)continue;const o=Number.parseInt(n[1]??"",10),c=(n[2]??"").toLowerCase();!Number.isFinite(o)||o===e||(/(?:^|[ /])vis-native(?:\s|$|[-.])/.test(c)||/(?:^|[ /])vis\s+run\b/.test(c)||/(?:^|[ /])task-runner(?:\s|$|[-.])/.test(c))&&i.push(o)}return i},ot=e=>{const t=rt("tasklist",["/FO","CSV","/NH"]),i=[];for(const l of t.split(/\r?\n/)){if(l.length===0)continue;const n=l.split(/","/).map(h=>h.replaceAll(/^"|"$/g,"")),o=(n[0]??"").toLowerCase(),c=Number.parseInt(n[1]??"",10);!Number.isFinite(c)||c===e||(o==="vis.exe"||o.startsWith("vis-native")||o.includes("task-runner"))&&i.push(c)}return i},yi=()=>{let e;try{const t=Ae("watchman",["--version"],{encoding:"utf8",timeout:2e3});if(t.error||typeof t.status=="number"&&t.status!==0)throw t.error??new Error("watchman exited non-zero");e=typeof t.stdout=="string"?t.stdout.trim():void 0}catch{return{id:"watchman",message:"Watchman not found — `vis` uses native fs.watch (fine for small repos). Install Watchman + `fb-watchman` to scale watch mode on large monorepos.",status:"skip"}}return{detail:e?{version:e}:void 0,id:"watchman",message:e?`Watchman available (${e}) — scalable watch backend in use.`:"Watchman available — scalable watch backend in use.",status:"ok"}},wi=(e=process.cwd())=>{let t="";try{t=Ze(W(e,".gitattributes"),"utf8")}catch(i){if(i.code!=="ENOENT")return{id:"git-lfs",message:"Could not read .gitattributes.",status:"warn"}}if(!t.includes("filter=lfs"))return{id:"git-lfs",message:"No Git LFS tracking declared in .gitattributes.",status:"skip"};try{const i=Ae("git",["lfs","version"],{encoding:"utf8",timeout:2e3});if(i.error||typeof i.status=="number"&&i.status!==0)throw i.error??new Error("git-lfs not available")}catch{return{id:"git-lfs",message:"Repo tracks files via Git LFS but `git-lfs` is not installed — checked-out LFS files are pointer stubs, not real content. Install git-lfs and run `git lfs pull`.",status:"warn"}}return{id:"git-lfs",message:"Git LFS tracking declared and `git-lfs` is installed.",status:"ok"}},ki=e=>[ai(),ci(),yi(),wi(e),ui()],ge=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],Ce=["dependencies","security","optimization","runtime"],he=e=>{const t=new Map;for(const i of Ce)t.set(i,[]);for(const i of e)t.get(i.section).push(i);for(const[i,l]of t)l.length===0&&t.delete(i);return t},pe=(e,t,i,l)=>{let n=e.filter(o=>o.section===t);if(l&&(n=n.filter(o=>o.severity===l)),i){const o=i.toLowerCase();n=n.filter(c=>c.title.toLowerCase().includes(o))}return[...n]},vi=e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const i of Ce)e.has(i)&&(t[i]="idle");return t};class _e{#e;#i=new Set;constructor(t=[]){const i=Array.isArray(t)?{findings:t}:t,l=i.findings??[],n=i.activeSections??new Set(Ce),o=Ce.find(a=>n.has(a))??"dependencies",c=pe(l,o,"",void 0),h=vi(n);if(l.length>0)for(const a of l)h[a.section]="done";this.#e={all:l,entries:c,filterActive:!1,filterText:"",filterType:o,focusedPanel:"list",grouped:he(c),pendingAction:void 0,sectionError:{},sectionMessage:{},sectionStatus:h,selectedIndex:0,severityFilter:void 0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#i.add(t),()=>{this.#i.delete(t)});setSelectedIndex(t){const i=Math.max(0,Math.min(t,this.#e.entries.length-1));i!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:i})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:t})}setFilterType(t){if(t===this.#e.filterType)return;const i=pe(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterType:t,grouped:he(i),selectedIndex:0})}setFilter(t){const i=pe(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterText:t,grouped:he(i),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const i=pe(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:i,filterActive:!1,filterText:"",grouped:he(i),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const i=pe(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:i,grouped:he(i),selectedIndex:0,severityFilter:t})}startSection(t,i){this.#t({...this.#e,sectionMessage:{...this.#e.sectionMessage,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"running"}})}completeSection(t,i){const l=[...this.#e.all,...i],n=pe(l,this.#e.filterType,this.#e.filterText,this.#e.severityFilter),o={...this.#e.sectionMessage};delete o[t],this.#t({...this.#e,all:l,entries:n,grouped:he(n),sectionMessage:o,sectionStatus:{...this.#e.sectionStatus,[t]:"done"}})}failSection(t,i){this.#t({...this.#e,sectionError:{...this.#e.sectionError,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"error"}})}#t(t){this.#e=t;for(const i of this.#i)try{i()}catch{}}}const Ve={error:0,warn:1},bi=e=>!!e.acceptedRisk,lt=e=>{const t=[];if(e.sections.has("dependencies")){for(const i of e.outdated)t.push({entry:i,id:`outdated:${i.packageName}`,kind:"outdated",section:"dependencies",severity:"warn",subtitle:`${i.currentRange} → ${i.newRange} (${i.updateType})`,title:i.packageName});for(const i of e.duplicates)t.push({id:`duplicate:${i.name}`,kind:"duplicate",pkg:i,section:"dependencies",severity:"warn",subtitle:`${String(i.versions.length)} versions installed`,title:i.name})}if(e.sections.has("security"))for(const i of e.outdated){if(i.vulnerabilities&&i.vulnerabilities.length>0){const l=i.vulnerabilities[0],n=bi(i)?"warn":"error",o=i.vulnerabilities.length;t.push({entry:i,id:`vuln:${i.packageName}`,kind:"vulnerability",packageName:i.packageName,section:"security",severity:n,subtitle:o===1?`${l.severity} · ${l.id}`:`${String(o)} advisories · top: ${l.severity} ${l.id}`,title:i.packageName})}if(i.socketReport&&i.socketReport.alerts.length>0){const l=Math.round(i.socketReport.score.overall*100);t.push({entry:i,id:`socket:${i.packageName}`,kind:"socket",packageName:i.packageName,section:"security",severity:"warn",subtitle:`${String(i.socketReport.alerts.length)} alert${i.socketReport.alerts.length===1?"":"s"} · score ${String(l)}%`,title:i.packageName})}}if(e.sections.has("optimization"))for(const i of e.optimizations)t.push({entry:i,id:`opt:${i.packageName}`,kind:"optimization",section:"optimization",severity:"warn",subtitle:`${i.category} → ${i.replacement}`,title:i.packageName});if(e.sections.has("runtime"))for(const i of e.runtime)i.status==="warn"&&t.push({diagnostic:i,id:`runtime:${i.id}`,kind:"runtime",section:"runtime",severity:"warn",title:i.message});return t.sort((i,l)=>{if(i.section!==l.section){const n=["dependencies","security","optimization","runtime"];return n.indexOf(i.section)-n.indexOf(l.section)}return Ve[i.severity]-Ve[l.severity]}),t},at={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"},ji={error:"red",warn:"yellow"},$i={error:"✖",warn:"⚠"},Si={error:" ERROR ",warn:" WARN "},Ci=({children:e,hint:t,message:i,severity:l,title:n})=>{const o=ji[l];return s.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[s.jsxs(u,{gap:1,children:[s.jsx(r,{backgroundColor:o,bold:!0,color:"black",children:Si[l]}),s.jsx(r,{bold:!0,color:o,children:$i[l]}),s.jsx(r,{bold:!0,wrap:"truncate-end",children:n})]}),s.jsx(r,{wrap:"truncate-end",children:i}),t?s.jsx(r,{dimColor:!0,wrap:"truncate-end",children:t}):null,e]})},Ri={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},Ai={critical:"red",high:"red",low:"gray",medium:"yellow"},Ii={major:"red",minor:"yellow",patch:"green"},C=({children:e,label:t,width:i=14})=>s.jsxs(u,{children:[s.jsx(u,{width:i,children:s.jsxs(r,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?s.jsx(r,{children:e}):e]}),re=({children:e})=>s.jsx(u,{marginTop:1,children:s.jsx(r,{bold:!0,color:"white",children:e})}),Ti=({finding:e})=>{const{entry:t}=e,i=Ii[t.updateType]??"white";return s.jsxs(u,{flexDirection:"column",children:[s.jsx(C,{label:"Current",children:t.currentRange}),s.jsxs(C,{label:"Target",children:[s.jsx(r,{children:t.newRange}),s.jsxs(r,{bold:!0,color:i,children:[" (",t.updateType,")"]})]}),s.jsx(C,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?s.jsx(C,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,s.jsx(re,{children:"Action"}),s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},Ni=({finding:e})=>s.jsxs(u,{flexDirection:"column",children:[s.jsx(C,{label:"Versions",children:s.jsx(r,{children:String(e.pkg.versions.length)})}),s.jsx(re,{children:"Installed versions"}),e.pkg.versions.map(t=>s.jsxs(r,{children:[" · ",t]},t)),s.jsx(re,{children:"Action"}),s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),Mi=({finding:e})=>{const t=e.entry.vulnerabilities??[];return s.jsxs(u,{flexDirection:"column",children:[s.jsx(C,{label:"Package",children:e.packageName}),s.jsx(C,{label:"Current",children:e.entry.currentRange}),s.jsx(C,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?s.jsx(C,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(i=>{const l=Ri[i.severity]??"gray";return s.jsxs(u,{flexDirection:"column",marginTop:1,children:[s.jsxs(u,{children:[s.jsx(r,{bold:!0,color:l,children:i.severity}),s.jsx(r,{children:" "}),s.jsx(r,{children:i.id}),typeof i.cvssScore=="number"?s.jsxs(r,{dimColor:!0,children:[" · CVSS ",i.cvssScore.toFixed(1)]}):null]}),s.jsx(r,{wrap:"wrap",children:i.summary}),i.fixedVersions.length>0?s.jsxs(r,{dimColor:!0,children:["Fixed in: ",i.fixedVersions.join(", ")]}):null,i.aliases&&i.aliases.length>0?s.jsxs(r,{dimColor:!0,children:["Aliases: ",i.aliases.join(", ")]}):null]},i.id)})]})},Ei=({finding:e})=>{const t=e.entry.socketReport;if(!t)return s.jsx(r,{dimColor:!0,children:"No Socket report attached."});const i=Math.round(t.score.overall*100),l=Pe(t.score.overall);return s.jsxs(u,{flexDirection:"column",children:[s.jsx(C,{label:"Package",children:e.packageName}),s.jsx(C,{label:"Overall",children:s.jsxs(r,{color:l,children:[String(i),"%"]})}),s.jsx(C,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?s.jsx(C,{label:"Risk ack",children:s.jsx(r,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,s.jsx(re,{children:"Score breakdown"}),Object.entries(t.score).map(([n,o])=>{if(n==="overall")return null;const c=typeof o=="number"?o:0,h=Math.round(c*100),a=Pe(c);return s.jsxs(u,{children:[s.jsx(u,{width:14,children:s.jsxs(r,{dimColor:!0,children:[n,":"]})}),s.jsxs(r,{color:a,children:[String(h),"%"]})]},n)}),s.jsx(re,{children:"Alerts"}),t.alerts.map((n,o)=>{const c=Ai[n.severity]??"gray";return s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{children:[s.jsx(r,{bold:!0,color:c,children:n.severity}),s.jsx(r,{children:" "}),s.jsx(r,{children:n.type})]}),n.props?s.jsx(r,{dimColor:!0,wrap:"wrap",children:JSON.stringify(n.props)}):null]},`${n.type}-${String(o)}`)})]})},Di=({finding:e})=>{const{entry:t}=e;return s.jsxs(u,{flexDirection:"column",children:[s.jsx(C,{label:"Package",children:t.packageName}),s.jsx(C,{label:"Category",children:t.category}),s.jsx(C,{label:"Replacement",children:t.replacement}),t.overrideSpec?s.jsx(C,{label:"Override",children:t.overrideSpec}):null,s.jsx(C,{label:"Codemod",children:s.jsx(r,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?s.jsx(C,{label:"Guide",children:s.jsx(r,{color:"cyan",underline:!0,children:t.docUrl})}):null,s.jsx(re,{children:"Action"}),t.hasCodemod?s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?s.jsxs(r,{dimColor:!0,children:["Run"," ",s.jsx(r,{bold:!0,color:"white",children:"vis optimize"})," ","to install the package override."]}):t.docUrl?s.jsx(r,{dimColor:!0,children:"No automated codemod. Open the migration guide above for the recommended alternative and steps."}):s.jsx(r,{dimColor:!0,children:"No automated codemod. Consult the package's docs or the e18e module-replacements guide for an alternative."})]})},Fi=({finding:e})=>{const{diagnostic:t}=e,i=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return s.jsxs(u,{flexDirection:"column",children:[s.jsx(C,{label:"Check",children:t.id}),s.jsx(C,{label:"Status",children:s.jsx(r,{color:i,children:t.status})}),s.jsx(re,{children:"Message"}),s.jsx(r,{wrap:"wrap",children:t.message}),t.detail&&Object.keys(t.detail).length>0?s.jsxs(s.Fragment,{children:[s.jsx(re,{children:"Details"}),Object.entries(t.detail).map(([l,n])=>s.jsxs(u,{children:[s.jsx(u,{width:20,children:s.jsxs(r,{dimColor:!0,children:[l,":"]})}),s.jsx(r,{children:String(n)})]},l))]}):null]})},Pi=({finding:e,focused:t,scrollRef:i})=>{const l=t?"white":"gray";if(!e)return s.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:s.jsx(r,{dimColor:!0,children:"No finding selected"})});let n;switch(e.kind){case"duplicate":{n=s.jsx(Ni,{finding:e});break}case"optimization":{n=s.jsx(Di,{finding:e});break}case"outdated":{n=s.jsx(Ti,{finding:e});break}case"runtime":{n=s.jsx(Fi,{finding:e});break}case"socket":{n=s.jsx(Ei,{finding:e});break}case"vulnerability":{n=s.jsx(Mi,{finding:e});break}default:{n=s.jsx(r,{dimColor:!0,children:"Unknown finding kind."});break}}return s.jsxs(u,{borderColor:l,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s.jsxs(u,{flexShrink:0,paddingTop:1,paddingX:2,children:[s.jsx(r,{bold:!0,color:"white",children:e.title}),s.jsxs(r,{dimColor:!0,children:[" ",at[e.section]]})]}),s.jsxs(Dt,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[s.jsx(r,{}),n]})]})},ct={error:"red",warn:"yellow"},zi={error:"✖",warn:"⚠"},Oi=e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,Bi=({finding:e,isSelected:t})=>{const i=ct[e.severity],l=Oi(e);return s.jsxs(u,{flexShrink:0,height:1,children:[s.jsx(r,{children:t?">":" "}),s.jsxs(r,{color:i,children:[" ",zi[e.severity]," "]}),s.jsx(u,{flexGrow:1,children:s.jsx(r,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),l?s.jsx(r,{color:"cyan",children:" ack"}):null,e.subtitle?s.jsxs(r,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},Li=({count:e,section:t})=>s.jsxs(u,{flexShrink:0,height:1,marginTop:1,children:[s.jsx(r,{dimColor:!0,children:"▼ "}),s.jsx(r,{bold:!0,color:"white",children:at[t].toUpperCase()}),s.jsxs(r,{dimColor:!0,children:[" (",e,")"]})]}),_i=({count:e,label:t,status:i})=>s.jsxs(r,{children:[t,i==="running"?s.jsxs(r,{children:[" ",s.jsx(st,{type:"dots"})]}):null,i==="error"?s.jsx(r,{bold:!0,color:"red",children:" ✖"}):s.jsxs(r,{dimColor:!0,children:[" (",String(e),")"]})]}),Vi=({elapsedMs:e,entries:t,filterActive:i,filterText:l,filterType:n,focused:o,fromCache:c=!1,grouped:h,onViewportHeightChange:a,scrollOffset:p,sectionCounts:y,sectionMessage:j,sectionStatus:k,selectedIndex:D,severityFilter:$,totalAll:f,viewportHeight:A})=>{const M=o?"white":"gray",{measuredHeight:F,ref:E}=ti(A,a);let R=0,P=0;for(const b of t)b.severity==="error"?R+=1:b.severity==="warn"&&(P+=1);const Y=[];R>0&&Y.push(`${String(R)} error${R===1?"":"s"}`),P>0&&Y.push(`${String(P)} warn${P===1?"":"s"}`);const Z=Y.length>0?` (${Y.join(", ")})`:"",ee=(e/1e3).toFixed(1),q=[];for(const[b,S]of h){q.push(s.jsx(Li,{count:S.length,section:b},`hdr-${b}`));for(const _ of S){const V=t.indexOf(_);q.push(s.jsx(Bi,{finding:_,isSelected:V===D},_.id))}}let B=0;for(const[,b]of h)B+=2+b.length;const L=B>F&&F>0;return s.jsxs(u,{borderColor:M,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[s.jsx(r,{bold:!0,inverse:!0,children:" DOCTOR "}),s.jsxs(r,{wrap:"truncate",children:[t.length,t.length===f?"":`/${String(f)}`," finding",t.length===1?"":"s",Z]}),$?s.jsx(r,{bold:!0,color:ct[$],inverse:!0,children:` ${$.toUpperCase()} ONLY `}):null,c?s.jsx(r,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,s.jsxs(r,{dimColor:!0,children:[" · ",ee,"s"]})]}),s.jsx(u,{flexShrink:0,paddingX:1,paddingY:1,children:s.jsx(Zt,{isFocused:o,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:()=>{},showIndex:!1,value:n,children:ge.map(({id:b,label:S})=>s.jsx(ei,{name:b,children:s.jsx(_i,{count:y[b],label:S,status:k[b]})},b))})}),(()=>{const b=Object.keys(k).filter(S=>k[S]==="running"&&j[S]).map(S=>j[S]);return b.length===0?null:s.jsx(u,{flexShrink:0,paddingX:1,children:s.jsxs(r,{dimColor:!0,wrap:"truncate",children:[s.jsx(st,{type:"dots"})," ",b.join(" · ")]})})})(),i&&s.jsxs(u,{flexShrink:0,paddingX:1,children:[s.jsx(r,{bold:!0,color:"white",children:"/ "}),s.jsx(r,{children:l}),s.jsx(r,{inverse:!0,children:" "})]}),s.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:E,children:[s.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:s.jsx(u,{flexDirection:"column",marginTop:-p,children:q.length>0?q:s.jsx(u,{marginTop:1,children:s.jsx(r,{dimColor:!0,children:"No findings match the current filter."})})})}),L&&s.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:s.jsx(Ft,{contentHeight:B,placement:"inset",scrollOffset:p,style:"block",viewportHeight:F})})]},`list-${n}-${l}`)]})},Gi=e=>{if(e.kind==="outdated")return{command:`vis update ${e.entry.packageName}`,description:`Update ${e.entry.packageName} to ${e.entry.newRange}`};if(e.kind==="duplicate")return{command:`vis dedupe ${e.pkg.name}`,description:`Dedupe ${e.pkg.name} (${String(e.pkg.versions.length)} versions)`}},Ui=e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},Hi=e=>{if(e.kind!=="outdated"&&e.kind!=="vulnerability"&&e.kind!=="socket")return;const t=e.kind==="outdated"?e.entry.packageName:e.packageName,i=["// Add to vis.config.ts:","security: {"," acceptedRisks: {",` "${t}": {`,' reason: "explain why this risk is acceptable",',' expiresAt: "YYYY-MM-DD",'," },"," },","},"].join(`
3
3
  `);return{command:i,configSnippet:i,description:`Acknowledge risk for ${t}`}},Yi=100,qi=40,Wi=10,Ki=({autoExitSeconds:e=0,banner:t,fromCache:i=!1,startedAt:l,store:n})=>{const{exit:o}=Pt(),{columns:c,rows:h}=zt(),a=O.useSyncExternalStore(n.subscribe,n.getSnapshot),[p,y]=O.useState(!1),[j,k]=O.useState(!1),[D,$]=O.useState(0),[f,A]=O.useState(()=>Date.now());O.useEffect(()=>{const x=setInterval(()=>{A(Date.now())},1e3);return()=>{clearInterval(x)}},[]);const M=f-l,F=O.useRef(null),E=O.useRef(null),R=a.entries[a.selectedIndex]??null,P=O.useMemo(()=>{const x={dependencies:0,optimization:0,runtime:0,security:0};for(const m of a.all)x[m.section]+=1;return x},[a.all]),Y=t?t.hint?5:4:0,Z=O.useMemo(()=>{for(const x of Object.keys(a.sectionStatus))if(a.sectionStatus[x]==="running"&&a.sectionMessage[x])return 1;return 0},[a.sectionStatus,a.sectionMessage]),ee=c>=Yi,q=ee?Math.max(1,h-Y-2):Math.floor(h*.55),B=Math.max(1,q-6-Z-(a.filterActive?1:0)),[L,b]=O.useState(B),S=L>0?L:B,_=O.useMemo(()=>{let x=0;for(const[,m]of a.grouped)x+=2+m.length;return x},[a.grouped]),V=Math.max(0,_-S),G=Math.min(D,V),ne=O.useCallback(x=>{let m=0,w=0;for(const[,xe]of a.grouped){m+=2;for(let oe=0;oe<xe.length;oe++){if(w===x)return m;m+=1,w+=1}}return m},[a.grouped]),Q=O.useCallback(x=>{const m=ne(x);$(w=>m>w+S-2?Math.min(V,Math.max(0,m-S+2)):m<w+1?Math.max(0,m-1):w)},[ne,S,V]);if(O.useEffect(()=>{E.current?.scrollToTop()},[R?.id]),Ot((x,m)=>{if(x==="c"&&m.ctrl){o();return}if(!j){if(p){m.escape||x==="?"?y(!1):x==="q"?(y(!1),k(!0)):m.downArrow||x==="j"?F.current?.scrollBy(1):(m.upArrow||x==="k")&&F.current?.scrollBy(-1);return}if(x==="?"){y(!0);return}if(x==="q"){k(!0);return}if(m.tab){n.setFocusedPanel(a.focusedPanel==="list"?"detail":"list");return}if(a.filterActive){if(m.escape||m.return){n.setFilterActive(!1);return}if(m.backspace){$(0),n.setFilter(a.filterText.slice(0,-1));return}x&&!m.ctrl&&!m.meta&&($(0),n.setFilter(a.filterText+x));return}if(a.focusedPanel==="list"&&(m.leftArrow||m.rightArrow)){const w=ge.findIndex(oe=>oe.id===a.filterType),xe=m.rightArrow?(w+1)%ge.length:(w-1+ge.length)%ge.length;$(0),E.current?.scrollToTop(),n.setFilterType(ge[xe].id);return}if(a.focusedPanel==="list"){if(m.downArrow||x==="j"){const w=Math.min(a.selectedIndex+1,a.entries.length-1);n.setSelectedIndex(w),Q(w);return}if(m.upArrow||x==="k"){const w=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(w),Q(w);return}if(m.pageDown){const w=Math.min(a.selectedIndex+10,a.entries.length-1);n.setSelectedIndex(w),Q(w);return}if(m.pageUp){const w=Math.max(a.selectedIndex-10,0);n.setSelectedIndex(w),Q(w);return}if(m.home){n.setSelectedIndex(0),$(0);return}if(m.end){const w=a.entries.length-1;n.setSelectedIndex(w),Q(w);return}if(x==="/"){n.setFilterActive(!0);return}if(x==="e"){n.setSeverityFilter(a.severityFilter==="error"?void 0:"error"),$(0);return}if(x==="w"){n.setSeverityFilter(a.severityFilter==="warn"?void 0:"warn"),$(0);return}if(x==="u"&&R){const w=Gi(R);w&&(n.setPendingAction(w),o());return}if(x==="o"&&R){const w=Ui(R);w&&(n.setPendingAction(w),o());return}if(x==="a"&&R){const w=Hi(R);w&&(n.setPendingAction(w),o());return}if(x==="d"){n.setFocusedPanel("detail");return}return}if(m.escape||m.leftArrow){n.setFocusedPanel("list");return}if(m.downArrow||x==="j"){E.current?.scrollBy(1);return}if(m.upArrow||x==="k"){E.current?.scrollBy(-1);return}if(m.pageDown){E.current?.scrollBy(10);return}if(m.pageUp){E.current?.scrollBy(-10);return}if(m.home){E.current?.scrollToTop();return}m.end&&E.current?.scrollToBottom()}},{isActive:!0}),c<qi||h<Wi)return s.jsx(u,{alignItems:"center",height:h,justifyContent:"center",width:c,children:s.jsxs(r,{color:"yellow",children:["Terminal too small (",c,"x",h,")"]})});const z=a.focusedPanel==="detail",U=[s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"q"}),s.jsx(r,{dimColor:!0,children:"QUIT"})]},"q"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"?"}),s.jsx(r,{dimColor:!0,children:"HELP"})]},"?"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"↑↓"}),s.jsx(r,{dimColor:!0,children:z?"SCROLL":"NAV"})]},"nav"),z?s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"←/Esc"}),s.jsx(r,{dimColor:!0,children:"LIST"})]},"lr"):s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"←→"}),s.jsx(r,{dimColor:!0,children:"SECTION"})]},"lr"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"/"}),s.jsx(r,{dimColor:!0,children:"SEARCH"})]},"search"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"e/w"}),s.jsx(r,{dimColor:!0,children:"SEVERITY"})]},"sev"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"u/o/a"}),s.jsx(r,{dimColor:!0,children:"ACTION"})]},"actions"),s.jsxs(u,{gap:1,children:[s.jsx(r,{bold:!0,color:"white",children:"Tab"}),s.jsx(r,{dimColor:!0,children:"PANEL"})]},"tab")],te=s.jsx(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:s.jsx(u,{gap:2,overflow:"hidden",paddingX:1,children:U})}),ce=s.jsxs(Bt,{footer:s.jsxs(r,{dimColor:!0,children:[s.jsx(r,{bold:!0,color:"white",children:"↑↓"})," scroll ",s.jsx(r,{bold:!0,color:"white",children:"?"}),"/",s.jsx(r,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:F,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:p,width:56,children:[s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" ↑/k "}),s.jsx(r,{dimColor:!0,children:"Move up"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" ↓/j "}),s.jsx(r,{dimColor:!0,children:"Move down"})]})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" PgUp"}),s.jsx(r,{dimColor:!0,children:" Jump up 10"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" PgDn"}),s.jsx(r,{dimColor:!0,children:" Jump down 10"})]})]}),s.jsxs(u,{children:[s.jsx(u,{width:26,children:s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Home"}),s.jsx(r,{dimColor:!0,children:" Jump to top"})]})}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" End"}),s.jsx(r,{dimColor:!0,children:" Jump to bottom"})]})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Tab"}),s.jsx(r,{dimColor:!0,children:" Switch panel"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" →/←"}),s.jsx(r,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"FILTER"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" /"}),s.jsx(r,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" e"}),s.jsx(r,{dimColor:!0,children:" Toggle errors-only filter"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" w"}),s.jsx(r,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),s.jsxs(u,{flexDirection:"column",marginBottom:1,children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"ACTIONS"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" u"}),s.jsx(r,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" o"}),s.jsx(r,{dimColor:!0,children:" Exit + suggest optimize command"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" a"}),s.jsx(r,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" d"}),s.jsx(r,{dimColor:!0,children:" Focus detail panel"})]})]}),s.jsxs(u,{flexDirection:"column",children:[s.jsxs(u,{marginBottom:1,children:[s.jsx(r,{dimColor:!0,children:"── "}),s.jsx(r,{bold:!0,color:"white",children:"EXIT"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" q"}),s.jsx(r,{dimColor:!0,children:" Quit (with countdown)"})]}),s.jsxs(r,{children:[s.jsx(r,{bold:!0,color:"white",children:" Ctrl+C"}),s.jsx(r,{dimColor:!0,children:" Quit immediately"})]})]})]}),de=s.jsx(Vi,{elapsedMs:M,entries:a.entries,filterActive:a.filterActive,filterText:a.filterText,filterType:a.filterType,focused:a.focusedPanel==="list",fromCache:i,grouped:a.grouped,onViewportHeightChange:b,scrollOffset:G,sectionCounts:P,sectionMessage:a.sectionMessage,sectionStatus:a.sectionStatus,selectedIndex:a.selectedIndex,severityFilter:a.severityFilter,totalAll:a.all.length,viewportHeight:S}),ue=t?s.jsx(Ci,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,me=s.jsx(Pi,{finding:R,focused:a.focusedPanel==="detail",scrollRef:E});if(ee){const x=Math.floor(c*.4);return s.jsxs(u,{flexDirection:"column",height:h,width:c,children:[ue,s.jsxs(u,{flexDirection:"row",flexGrow:1,children:[s.jsx(u,{flexGrow:1,children:de}),s.jsx(u,{width:x,children:me})]}),te,s.jsx(Oe,{autoExitSeconds:e||3,onCancel:()=>{k(!1)},visible:j}),ce]})}return s.jsxs(u,{flexDirection:"column",height:h,width:c,children:[ue,s.jsx(u,{height:q,children:de}),s.jsx(u,{flexGrow:1,children:me}),te,s.jsx(Oe,{autoExitSeconds:e||3,onCancel:()=>{k(!1)},visible:j}),ce]})},Xi=e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),Ji=e=>{const t=e.split("*").map(i=>Xi(i));return new RegExp(`^${t.join(".*")}$`,"i")},Qi=e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>Ji(t)):[],Se=(e,t)=>{for(const i of t)if(i.test(e))return!0;return!1},Zi=(e,t,i)=>{if(t.length===0)return e;const l=e.outdated.filter(p=>Se(p.packageName,t)),n=e.duplicates.filter(p=>Se(p.name,t)),o=e.optimizations.filter(p=>Se(p.packageName,t));let c=0,h=0,a=0;for(const p of l)p.vulnerabilities&&(c+=p.vulnerabilities.length),p.socketReport&&(h+=p.socketReport.alerts.length,p.socketReport.score.overall<i&&(a+=1));return{...e,duplicates:n,optimizations:o,outdated:l,socketIssues:{alerts:h,lowScore:a},vulnCount:c}},dt=(e,t)=>t.length===0?[...e]:e.filter(i=>{if(i.kind==="runtime")return!0;const l=i.kind==="duplicate"?i.pkg.name:i.kind==="outdated"||i.kind==="optimization"?i.entry.packageName:i.packageName;return Se(l,t)}),ut=["dependencies","security","optimization","runtime"],Ge=e=>{const t=new Set;if(!e)return t;for(const i of e.split(",")){const l=i.trim().toLowerCase();ut.includes(l)&&t.add(l)}return t},es=(e,t)=>{if(e!==void 0&&e!=="")return Ge(e);const i=Ge(t);return new Set(ut.filter(l=>!i.has(l)))},ht=e=>{const t={micro:0,native:0,preferred:0,socket:0,total:e.length};for(const i of e)switch(i.category){case"micro-utility":{t.micro+=1;break}case"native":{t.native+=1;break}case"preferred":{t.preferred+=1;break}case"socket":{t.socket+=1;break}}return t},se=(e,t)=>{if(!e.sections.has(t))return"skip";switch(t){case"dependencies":return e.outdated.length>0||e.duplicates.length>0?"warn":"ok";case"optimization":return e.optimizations.length>0?"warn":"ok";case"runtime":return e.runtime.some(i=>i.status==="warn")?"warn":"ok";case"security":return e.vulnCount>0||e.socketIssues.alerts>0?"error":e.socketIssues.lowScore>0?"warn":"ok";default:return"ok"}},ts=(e,t)=>{const i=ht(e.optimizations),l={dependencies:se(e,"dependencies"),optimization:se(e,"optimization"),runtime:se(e,"runtime"),security:se(e,"security")},n=new Set([...Object.values(l),e.supplyChain.status]),o=n.has("error")?"error":n.has("warn")?"warn":"ok";return{dependencies:{duplicates:e.duplicates.length,installed:e.installedCount,outdated:e.outdated.length,status:l.dependencies},elapsedMs:e.elapsedMs,optimizations:{microUtilities:i.micro,native:i.native,preferred:i.preferred,socket:i.socket,status:l.optimization,total:i.total},packageManager:t,runtime:e.runtime.map(c=>({detail:c.detail,id:c.id,message:c.message,status:c.status})),runtimeStatus:l.runtime,security:{alerts:e.socketIssues.alerts,lowScorePackages:e.socketIssues.lowScore,status:l.security,vulnerabilities:e.vulnCount},status:o,supplyChain:{findings:e.supplyChain.findings.map(c=>({detail:c.detail,label:c.label,severity:c.severity})),status:e.supplyChain.status},workspaces:e.workspaceCount}},Ue=(e,t)=>{const i=e.runtime.some(n=>n.status==="warn"),l=e.vulnCount>0||e.socketIssues.alerts>0;return t?l||e.outdated.length>0||e.duplicates.length>0||i:l},is=["aube-workspace.yaml","pnpm-workspace.yaml"],we=e=>typeof e=="boolean"?e:void 0,ss=e=>{if(e==="no-downgrade"||e==="off")return e},rs=e=>{const t={allowBuildsCount:0,blockExoticSubdeps:void 0,jailBuilds:void 0,minimumReleaseAge:void 0,minimumReleaseAgeStrict:void 0,paranoid:void 0,source:void 0,strictDepBuilds:void 0,trustPolicy:void 0};for(const i of is){const l=W(e,i);if(!be(l))continue;let n;try{n=bt(wt(l))}catch{continue}if(typeof n!="object"||n===null)continue;const o=n;return t.source=i,t.paranoid=we(o.paranoid),t.trustPolicy=ss(o.trustPolicy),t.blockExoticSubdeps=we(o.blockExoticSubdeps),t.jailBuilds=we(o.jailBuilds),t.strictDepBuilds=we(o.strictDepBuilds),t.minimumReleaseAgeStrict=we(o.minimumReleaseAgeStrict),typeof o.minimumReleaseAge=="number"&&Number.isFinite(o.minimumReleaseAge)&&(t.minimumReleaseAge=o.minimumReleaseAge),o.allowBuilds&&typeof o.allowBuilds=="object"&&!Array.isArray(o.allowBuilds)&&(t.allowBuildsCount=Object.keys(o.allowBuilds).length),t}return t},ns=e=>e.paranoid?{...e,jailBuilds:!0,minimumReleaseAgeStrict:!0,strictDepBuilds:!0,trustPolicy:"no-downgrade"}:e,os=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,ls=e=>{const t=os.exec(e);if(t)return{name:t[1],version:t[2]}},as=(e,t)=>{let i;try{if(t==="pnpm"){const n=W(e,"pnpm-workspace.yaml");be(n)&&(i=kt(n)?.patchedDependencies)}else if(t==="bun"){const n=W(e,"package.json");be(n)&&(i=et(n)?.patchedDependencies)}}catch{return[]}if(!i||typeof i!="object")return[];const l=[];for(const[n,o]of Object.entries(i)){if(typeof o!="string"||o.length===0)continue;const c=ls(n);c&&l.push({name:c.name,patchFile:o,resolvedPatchFile:vt(o)?o:Ke(e,o),version:c.version})}return l},cs=e=>{const t=[];for(const i of e)be(i.resolvedPatchFile)||t.push({entry:i,kind:"missing-file"});return t},He=e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok",ds=(e,t={})=>{const i=[],l=e?.security;if(!l)return i.push({detail:"Use defineConfig() from '@visulima/vis/config' to apply secure defaults.",label:"No security config — running with the PM's native defaults",severity:"warn"}),{findings:i,status:He(i)};const n=l.policies?.firstSeen?.minutes,o=l.policies?.publisherChange,c=l.policies?.installScripts;n===void 0?i.push({detail:"Set security.policies.firstSeen.minutes to block packages published in the last N minutes (mitigates supply-chain attacks).",label:"policies.firstSeen.minutes is not set",severity:"warn"}):n===0?i.push({detail:"New packages can be installed immediately after publishing. Consider setting a non-zero cooldown.",label:"policies.firstSeen.minutes is explicitly 0",severity:"warn"}):i.push({label:`policies.firstSeen.minutes: ${String(n)} minutes`,severity:"ok"}),o?.mode===void 0||o.mode==="off"?i.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`policies.publisherChange.mode: ${o?.mode??"not set"}`,severity:"warn"}):i.push({label:`policies.publisherChange.mode: ${o.mode}`,severity:"ok"}),l.blockExoticSubdeps===void 0||!l.blockExoticSubdeps?i.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(l.blockExoticSubdeps??!1)}`,severity:"warn"}):i.push({label:"blockExoticSubdeps: true",severity:"ok"});const h=c?.allow?Object.keys(c.allow).length:0;if(h===0?i.push({detail:"Lifecycle scripts are blocked by default. List trusted packages here to opt them back in (e.g. esbuild, @prisma/client).",label:"policies.installScripts.allow: not configured",severity:"warn"}):i.push({label:`policies.installScripts.allow: ${String(h)} ${h===1?"entry":"entries"}`,severity:"ok"}),c?.strict&&h===0&&i.push({detail:"All dependencies with build scripts will be blocked. Run 'vis approve-builds' to populate the allow list.",label:"policies.installScripts.strict is on but allow is empty",severity:"error"}),t.workspaceRoot){const a=ii(t.workspaceRoot);if(a.length>0){const p=[...new Set(a.map(y=>y.tool))].sort((y,j)=>y.localeCompare(j)).join(", ");i.push({detail:"Run `vis migrate verify` for the full list, then re-run `vis migrate <tool>` to clean up.",label:`${String(a.length)} leftover ${a.length===1?"reference":"references"} to ${p}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager==="aube"){const a=rs(t.workspaceRoot),p=ns(a),y=p.source?` (from ${p.source})`:"";p.paranoid===!0&&i.push({detail:"Forces jailBuilds, trustPolicy=no-downgrade, minimumReleaseAgeStrict, strictStoreIntegrity, and strictDepBuilds on.",label:`aube paranoid: true${y}`,severity:"ok"}),p.trustPolicy==="off"&&i.push({detail:"Trust downgrades between releases will not be blocked. Set trustPolicy: no-downgrade in aube-workspace.yaml.",label:`aube trustPolicy: off${y}`,severity:"warn"}),p.blockExoticSubdeps===!1&&i.push({detail:"Transitive deps from git+, file:, and tarball URLs will not be blocked. Re-enable with blockExoticSubdeps: true.",label:`aube blockExoticSubdeps: false${y}`,severity:"warn"}),p.minimumReleaseAge===0&&i.push({detail:"Newly published versions are not held in a cooling window. Restore with minimumReleaseAge: 1440 (24h) or higher.",label:`aube minimumReleaseAge: 0${y}`,severity:"warn"}),p.jailBuilds===!0&&i.push({label:`aube jailBuilds: true${y}`,severity:"ok"}),p.strictDepBuilds===!0&&i.push({label:`aube strictDepBuilds: true${y}`,severity:"ok"}),p.allowBuildsCount>0&&i.push({label:`aube allowBuilds: ${String(p.allowBuildsCount)} ${p.allowBuildsCount===1?"entry":"entries"}${y}`,severity:"ok"})}if(t.workspaceRoot&&t.packageManager){const a=as(t.workspaceRoot,t.packageManager);if(a.length>0){const p=cs(a);if(p.length===0)i.push({label:`patchedDependencies: ${String(a.length)} ${a.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const y of p)i.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${y.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${y.entry.name}@${y.entry.version}`,severity:"error"})}}return{findings:i,status:He(i)}},H=e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,je=async(e,t,i,l)=>{if(!e)return i();e.start(t);const n=Date.now();try{const o=await i(),c=Date.now()-n,{status:h,summary:a}=l(o,c);return e.finish(t,h,a),o}catch(o){const c=Date.now()-n,h=o instanceof Error?o.message:String(o);throw e.finish(t,"error",`${h} (${H(c)})`),o}},us=(e,t)=>{const i={duplicates:t.duplicates,optimizations:t.optimizations,outdated:t.outdated,runtime:t.runtime,sections:new Set([e])};return lt(i)},Ye=async e=>{const{filterPatterns:t,installed:i,progress:l,resolveCodemods:n,sections:o,store:c,visConfig:h,workspaceRoot:a}=e,p=o.has("dependencies"),y=o.has("security"),j=o.has("optimization"),k=o.has("runtime"),D=(g,I)=>dt(us(g,I),t),$=it(a),{packageManager:f}=We(a),A=Be(W(a,"package.json"),!1),M=tt(a),F=new Set(A);for(const g of M){const I=Be(W(Ke(a,g),"package.json"),!1);for(const T of I)F.add(T)}const E=St(a),R=Xe(a,f),P=Je(h?.security,{minimumScore:h?.security?.policies?.score?.minimum}),Y=h?.security?.policies?.score?.minimum??Qe,Z=h?.security?.acceptedRisks,ee=_t(a,$.name),q={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},B=p?Qt(a,$.name):[],L=j?Vt(F):[],b=j?Gt(F,ee,$,!1):[],S=new Set(L.map(g=>g.packageName)),_=b.filter(g=>!S.has(g.packageName)),V=[...L,..._],G=k?ki(a):[];c&&(p&&c.startSection("dependencies",R.size>0?"checking outdated catalog dependencies":"scanning duplicates"),y&&c.startSection("security",i.length>0?`scanning ${String(i.length)} packages for advisories`:"no installed packages to scan"),j&&c.startSection("optimization","matching e18e + socket overrides"),k&&c.startSection("runtime","running runtime diagnostics")),c&&k&&c.completeSection("runtime",D("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:G}));const ne=(p||y)&&R.size>0?je(l,"outdated",()=>Ct(R,q,E,void 0,a,P,Z),(g,I)=>{const T=g.outdated.length;return{status:T>0?"warn":"ok",summary:T>0?`${String(T)} outdated · ${H(I)}`:`up to date · ${H(I)}`}}):Promise.resolve({failed:[],ignored:[],outdated:[]}),Q=y&&i.length>0?je(l,"vulnerabilities",()=>Rt(i.map(g=>({name:g.name,version:g.version}))),(g,I)=>{let T=0;for(const ie of g.values())T+=ie.length;return{status:T>0?"error":"ok",summary:T>0?`${String(T)} found · ${H(I)}`:`none found · ${H(I)}`}}):Promise.resolve(new Map),z=y&&P.length>0&&i.length>0?je(l,"socket",()=>At(P,i.map(g=>({name:g.name,version:g.version}))),(g,I)=>{let T=0,ie=0;for(const Fe of g.values())T+=Fe.alerts.length,Fe.score.overall<Y&&(ie+=1);const De=T+ie;return{status:De>0?"warn":"ok",summary:De>0?`${String(T)} alert${T===1?"":"s"}, ${String(ie)} low-score · ${H(I)}`:`clean · ${H(I)}`}}):Promise.resolve(new Map);let U,te,ce,de;const ue=ne.catch(g=>(U=g instanceof Error?g.message:String(g),c||d.warn(`Outdated scan failed: ${U}`),{failed:[],ignored:[],outdated:[]})),me=Q.catch(g=>(te=g instanceof Error?g.message:String(g),c||d.warn(`Vulnerability scan failed: ${te}`),new Map)),x=z.catch(g=>(ce=g instanceof Error?g.message:String(g),c||d.warn(`Socket scan failed: ${ce}`),new Map)),m=c&&p?ue.then(g=>{if(U){c.failSection("dependencies",U);return}c.completeSection("dependencies",D("dependencies",{duplicates:B,optimizations:[],outdated:g.outdated,runtime:[]}))}):void 0,w=c&&y?Promise.all([ue,me,x]).then(([g])=>{const I=U??te??ce;if(I){c.failSection("security",I);return}c.completeSection("security",D("security",{duplicates:[],optimizations:[],outdated:g.outdated,runtime:[]}))}):void 0,xe=(async()=>{if(n&&j&&V.length>0&&await je(l,"codemods",async()=>(await Yt(V),V),(g,I)=>{const T=g.filter(ie=>ie.hasCodemod||ie.category==="socket").length;return{status:"ok",summary:`${String(T)} auto-fixable · ${H(I)}`}}).catch(g=>{de=g instanceof Error?g.message:String(g)}),c&&j){if(de){c.failSection("optimization",de);return}c.completeSection("optimization",D("optimization",{duplicates:[],optimizations:V,outdated:[],runtime:[]}))}})(),[oe,gt,ft]=await Promise.all([ue,me,x]);await Promise.all([m,w,xe]);let Me=0,Ee=0;if(y&&P.length>0)for(const g of ft.values())Me+=g.alerts.length,g.score.overall<Y&&(Ee+=1);let Ie=0;if(y){for(const g of oe.outdated)g.vulnerabilities&&g.vulnerabilities.length>0&&(Ie+=g.vulnerabilities.length);for(const g of gt.values())Ie+=g.length}return{duplicates:B,installedCount:i.length,optimizations:j?V:[],outdated:p?oe.outdated:[],runtime:G,sections:o,socketIssues:{alerts:Me,lowScore:Ee},supplyChain:ds(h,{packageManager:f,workspaceRoot:a}),vulnCount:Ie,workspaceCount:M.length}},hs=e=>{switch(e){case"error":return ve(N.failure);case"skip":return v(N.dash);case"warn":return Re(N.warning);default:return fe(N.success)}},ae=(e,t)=>{const i=process.stderr.columns??80,l=Math.max(20,Math.min(i-2,60)),n=N.dash.repeat(2),o=`${hs(t)} ${le(e)}`,c=o.replaceAll(/\[[0-9;]*m/g,"").length,h=Math.max(0,l-c-n.length-2);return`${n} ${o} ${v(N.dash.repeat(h))}`},J=e=>` ${fe(N.success)} ${e}`,K=e=>` ${Re(N.warning)} ${e}`,Ne=e=>` ${ve(N.failure)} ${e}`,pt=e=>` ${v(N.dash)} ${v(e)}`,X=(e,t,i)=>{const l=`${le(String(e))} ${v(t)}`;return i?`${l} ${v(`(${i})`)}`:l},ps=e=>{if(e.sections.has("dependencies")){if(d.log(""),d.log(ae("Dependencies",se(e,"dependencies"))),d.log(J(X(e.installedCount,"packages installed"))),e.outdated.length>0){const t=e.outdated.filter(o=>o.updateType==="major").length,i=e.outdated.filter(o=>o.updateType==="minor").length,l=e.outdated.filter(o=>o.updateType==="patch").length,n=[];t>0&&n.push(`${String(t)} major`),i>0&&n.push(`${String(i)} minor`),l>0&&n.push(`${String(l)} patch`),d.log(K(X(e.outdated.length,"outdated",n.join(", "))))}else d.log(J("All dependencies up to date"));e.duplicates.length>0?d.log(K(X(e.duplicates.length,"packages with duplicate versions"))):d.log(J("No duplicate dependencies"))}},gs=e=>{e.sections.has("security")&&(d.log(""),d.log(ae("Security",se(e,"security"))),e.vulnCount>0?d.log(Ne(X(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):d.log(J("No known vulnerabilities")),e.socketIssues.alerts>0&&d.log(K(X(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&d.log(K(X(e.socketIssues.lowScore,`package${e.socketIssues.lowScore===1?"":"s"} with low security score`))),e.socketIssues.alerts===0&&e.socketIssues.lowScore===0&&e.vulnCount===0&&d.log(J("No security issues detected")))},fs=e=>{if(!e.sections.has("optimization"))return;d.log(""),d.log(ae("Optimization",se(e,"optimization")));const t=ht(e.optimizations);if(t.total===0){d.log(J("No optimizations available"));return}t.native>0&&d.log(K(X(t.native,"replaceable with native APIs"))),t.preferred>0&&d.log(K(X(t.preferred,"with lighter alternatives"))),t.micro>0&&d.log(K(X(t.micro,"trivial micro-utilities"))),t.socket>0&&d.log(K(X(t.socket,"@socketregistry overrides available")))},ms=e=>{d.log(""),d.log(ae("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const i=t.severity==="ok"?J(t.label):t.severity==="error"?Ne(t.label):K(t.label);d.log(i),t.detail&&d.log(` ${v(N.arrow)} ${v(t.detail)}`)}e.supplyChain.status!=="ok"&&d.log(` ${v(N.arrow)} ${v("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},xs=e=>{if(e.sections.has("runtime")){d.log(""),d.log(ae("Runtime",se(e,"runtime")));for(const t of e.runtime)t.status==="ok"?d.log(J(t.message)):t.status==="skip"?d.log(pt(t.message)):d.log(K(t.message))}},ys=(e,t)=>{const i=e.vulnCount,l=e.runtime.filter(o=>o.status==="warn").length,n=e.outdated.length+e.duplicates.length+e.optimizations.length+l;if(t){if(i===0&&n===0)d.success(`Everything looks good! ${v(`(${H(e.elapsedMs)})`)}`);else{const o=[];i>0&&o.push(ve(`${String(i)} security`)),n>0&&o.push(Re(`${String(n)} improvement${n===1?"":"s"}`)),d.log(`${ve(N.failure)} ${o.join(", ")} ${v(`(${H(e.elapsedMs)})`)}`)}return}d.log(""),d.log(ae("Summary","ok")),i===0&&n===0?d.success(`Everything looks good! ${v(`(${H(e.elapsedMs)})`)}`):(i>0&&d.error(`${String(i)} security issue${i===1?"":"s"}`),n>0&&d.log(` ${ke(N.arrow)} ${le(String(n))} ${v(`improvement${n===1?"":"s"} available`)} ${v(`(${H(e.elapsedMs)})`)}`))},ws=e=>{const t=[];if(e.outdated.length>0&&t.push("vis update — update outdated dependencies"),(e.vulnCount>0||e.socketIssues.alerts>0)&&t.push("vis audit — detailed security analysis"),e.optimizations.length>0&&t.push("vis optimize — apply optimizations interactively"),e.duplicates.length>0&&t.push("vis dedupe — reduce duplicate versions"),t.length>0){d.log(""),d.log(le("Next steps:"));for(const i of t)d.log(` ${v(N.arrow)} ${i}`)}d.log("")},ks=(e,t)=>{t||(ps(e),gs(e),fs(e),xs(e),ms(e)),ys(e,t)},vs=(e,t,i,l,n)=>{const o=[],c=e.has("dependencies"),h=e.has("security"),a=e.has("optimization");return(c||h)&&t>0&&o.push({id:"outdated",label:"Outdated catalog dependencies"}),h&&l>0&&o.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),h&&i&&l>0&&o.push({id:"socket",label:"Socket.dev supply-chain reports"}),a&&n&&o.push({id:"codemods",label:"Codemod availability"}),o},bs=e=>{if(d.log(""),d.log(`${le(ke("vis doctor"))} ${v("— project health check")}`),d.log(J(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.runtimeFindings.length===0)d.log(J(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const i=t.severity==="error"?ve:Re;d.log(Ne(`Runtime: ${i(t.message)}`))}d.log(` ${v(N.arrow)} Run ${fe("vis toolchain install")} to install pinned versions, or ${fe("vis toolchain status")} for the per-tool breakdown.`)}d.log("")},Us=async({fs:e,logger:t,options:i,visConfig:l,visConfigError:n,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root.");const c=i.format==="json"||i.json===!0,h=es(i.only,i.skip),a=!!i.quiet,p=i.progress===!1,y=Qi(i.filter);if(h.size===0){d.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const j=Date.now(),k=it(o),D=Wt(o),$=!!process.stdout.isTTY,f=!c&&$&&!Mt&&!a&&!p;!c&&!f&&bs({nodeVersion:process.versions.node,packageManagerName:k.name,packageManagerVersion:k.version,runtimeFindings:D});const A=Xe(o,We(o).packageManager),M=Xt(o,k.name),F=M.length,E=Je(l?.security).length>0,R=l?.security?.policies?.score?.minimum??Qe,P=tt(o);if(!c&&!a&&!f){const z=P.length>0?v(` · ${String(P.length)} workspace package${P.length===1?"":"s"}`):"";d.log(`${v("·")} ${v("Found")} ${le(String(F))} ${v(`installed package${F===1?"":"s"}`)}${z}`)}const Y=n?{hint:n.file?`Continuing with default settings — fix or regenerate ${n.file} (vis init --force).`:"Continuing with default settings.",message:n.message,severity:"error",title:n.file?`Failed to load ${n.file}`:"Failed to load vis.config"}:void 0,Z=Jt(o,k.name)?.file,ee=Z?W(o,Z):void 0,q=Lt(o),B=i.cache!==!1&&!i.fix?ni({configPath:q,lockfilePath:ee,sections:h,socketEnabled:E,workspaceRoot:o}):void 0,L=B?oi(B):void 0,b=L!==void 0;let S,_;if(f){const z=L?new _e({activeSections:h,findings:dt(lt(L),y)}):new _e({activeSections:h}),U=jt($t.createElement(Ki,{banner:Y,fromCache:b,startedAt:j,store:z}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{S=L??await Ye({filterPatterns:y,installed:M,resolveCodemods:!!i.fix,sections:h,store:z,visConfig:l,workspaceRoot:o})}catch(te){throw U.unmount(),te}await U.waitUntilExit(),_=z.getSnapshot().pendingAction}else if(L)S=L;else{const z=vs(h,A.size,E,F,!!i.fix),U=Kt(z,{live:!c&&!a&&!p});try{S=await Ye({filterPatterns:y,installed:M,progress:U,resolveCodemods:!!i.fix,sections:h,visConfig:l,workspaceRoot:o})}finally{U.stop()}}const V={...S,elapsedMs:Date.now()-j};if(B&&!b)try{li(B,V)}catch{}const G=Zi(V,y,R);if(c){process.stdout.write(`${JSON.stringify(ts(G,k.name),void 0,2)}
4
4
  `),i.exitCode&&Ue(G,!!i.strict)&&(process.exitCode=1);return}b&&!a&&d.log(`${v("·")} Cached results (use --no-cache to refresh)`),y.length>0&&!a&&d.log(`${v("·")} Filter active: ${ke(i.filter??"")}`),ks(G,a);const ne=G.runtime.some(z=>z.id===$e&&z.status==="warn"),Q=G.sections.has("optimization")&&G.optimizations.length>0;i.fix&&(Q||ne)?await js({force:!!i.fixForce,fs:e,logger:t,pm:k,recoverOrphans:ne,results:G,useEditorconfig:l?.editorconfig??!0,workspaceRoot:o}):a||ws(G),_&&(process.stdout.write(`
@@ -1,4 +1,4 @@
1
- import{createRequire as Et}from"node:module";import{V as we,E as D,s as ye,q as pt,Q as dt}from"../packem_shared/index.server-qvZ-cy29.js";import{I as Lt,m as z,f as J,v as be,T as Ze,u as Ve,B as Tt}from"../packem_shared/index-D75r1yKp.js";import{I as De}from"../packem_shared/index-B0EsgdzO.js";import{whichBin as Pt}from"#native";import{r as zt,R as Wt,b as _t}from"../packem_shared/ai-analysis-DWBi9tSU.js";import{N as Ht,O as Ut,B as Ft,X as Gt,p as u,i as Xe}from"./cli-main.js";import"../packem_shared/public-api-WqUCiyIe.js";import{e as Bt,W as Kt,v as qt,c as Jt,N as Yt,f as Zt,b as Xt,O as Qt}from"./catalog.js";import{A as ei,j as ti}from"../packem_shared/pm-runner-D5NWL8yv.js";import{s as L}from"../packem_shared/index-BAe6e0XE.js";import{c as gt,s as he,p as ii,e as ai,g as ni}from"../packem_shared/index-Ro_3oUtR.js";import{d as oi}from"../packem_shared/anolilab-text-CAM_E6uK.js";import{t as ri,b as si}from"../packem_shared/cyclonedx-C96cm9hF.js";import{s as pi}from"../packem_shared/scan-progress-CHdHWhVw.js";import{r as di,A as Qe,q as et}from"../packem_shared/advisories-B76fBVL-.js";import{a as ut}from"../packem_shared/readJsonSync-DuMMeB3s-wlhgSHes.js";import{l as gi,f as fi,a as ui}from"../packem_shared/dependency-scan-I_UnVof_.js";import{r as mi}from"../packem_shared/manifests-mFrrpzXW.js";import{l as bi,p as xi,O as ki}from"../packem_shared/osv-bloom-DMhXP184.js";import{H as tt,h as $i,D as Si,y as Ni}from"../packem_shared/en-BRcjb70R.js";const Ot=Et(import.meta.url),ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Y=e=>{if(typeof ee<"u"&&ee.versions&&ee.versions.node){const[t,i]=ee.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return ee.getBuiltinModule(e)}return Ot(e)},{spawnSync:Dt}=Y("node:child_process"),{createInterface:Mt}=Y("node:readline"),{stripVTControlCharacters:Vt}=Y("node:util"),{createHash:li}=Y("node:crypto"),{relative:ft,join:ci}=Y("node:path"),{readFileSync:mt,existsSync:hi,writeFileSync:vi,renameSync:wi,unlinkSync:yi}=Y("node:fs"),it=(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const i=[];for(const a of Lt(e,t))i.push(a.path);return i},xe=e=>`${e.packageName}@${e.packageVersion}:${e.vulnerability.id}`,Ai=e=>e==null||e===!0||e===""||e==="true"||e.toString().toLowerCase()==="all",Ci=(e,t)=>{if(Ai(t))return e;const i=String(t).trim();if(/^\d+$/.test(i)){const n=Number.parseInt(i,10)-1,r=e[n];return r?[r]:[]}const a=i.toLowerCase();return e.filter(n=>{const{aliases:r,id:o}=n.vulnerability;return o.toLowerCase()===a||(r??[]).some(l=>l.toLowerCase()===a)})},Ri=e=>{const{packageName:t,packageVersion:i,vulnerability:a}=e,n=(a.aliases??[]).join(", ")||"none",r=(a.fixedVersions??[]).join(", ")||"no fixed version published";return`You are a security engineer. Explain this dependency vulnerability for a developer triaging it.
1
+ import{createRequire as Et}from"node:module";import{V as we,E as D,s as ye,q as pt,Q as dt}from"../packem_shared/index.server-qvZ-cy29.js";import{I as Lt,m as z,f as J,v as be,T as Ze,u as Ve,B as Tt}from"../packem_shared/index-D75r1yKp.js";import{I as De}from"../packem_shared/index-B0EsgdzO.js";import{whichBin as Pt}from"#native";import{r as zt,R as Wt,b as _t}from"../packem_shared/ai-analysis-DWBi9tSU.js";import{N as Ht,O as Ut,B as Ft,X as Gt,p as u,i as Xe}from"./cli-main.js";import"../packem_shared/public-api-WqUCiyIe.js";import{e as Bt,W as Kt,v as qt,c as Jt,N as Yt,f as Zt,b as Xt,O as Qt}from"./catalog.js";import{A as ei,j as ti}from"../packem_shared/pm-runner-D5NWL8yv.js";import{s as L}from"../packem_shared/index-BAe6e0XE.js";import{c as gt,s as he,p as ii,e as ai,g as ni}from"../packem_shared/index-BtbefKtY.js";import{d as oi}from"../packem_shared/anolilab-text-CAM_E6uK.js";import{t as ri,b as si}from"../packem_shared/cyclonedx-DFlz2HRz.js";import{s as pi}from"../packem_shared/scan-progress-CHdHWhVw.js";import{r as di,A as Qe,q as et}from"../packem_shared/advisories-B76fBVL-.js";import{a as ut}from"../packem_shared/readJsonSync-DuMMeB3s-wlhgSHes.js";import{l as gi,f as fi,a as ui}from"../packem_shared/dependency-scan-173U3WXB.js";import{r as mi}from"../packem_shared/manifests-mFrrpzXW.js";import{l as bi,p as xi,O as ki}from"../packem_shared/osv-bloom-DMhXP184.js";import{H as tt,h as $i,D as Si,y as Ni}from"../packem_shared/en-BRcjb70R.js";const Ot=Et(import.meta.url),ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Y=e=>{if(typeof ee<"u"&&ee.versions&&ee.versions.node){const[t,i]=ee.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return ee.getBuiltinModule(e)}return Ot(e)},{spawnSync:Dt}=Y("node:child_process"),{createInterface:Mt}=Y("node:readline"),{stripVTControlCharacters:Vt}=Y("node:util"),{createHash:li}=Y("node:crypto"),{relative:ft,join:ci}=Y("node:path"),{readFileSync:mt,existsSync:hi,writeFileSync:vi,renameSync:wi,unlinkSync:yi}=Y("node:fs"),it=(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const i=[];for(const a of Lt(e,t))i.push(a.path);return i},xe=e=>`${e.packageName}@${e.packageVersion}:${e.vulnerability.id}`,Ai=e=>e==null||e===!0||e===""||e==="true"||e.toString().toLowerCase()==="all",Ci=(e,t)=>{if(Ai(t))return e;const i=String(t).trim();if(/^\d+$/.test(i)){const n=Number.parseInt(i,10)-1,r=e[n];return r?[r]:[]}const a=i.toLowerCase();return e.filter(n=>{const{aliases:r,id:o}=n.vulnerability;return o.toLowerCase()===a||(r??[]).some(l=>l.toLowerCase()===a)})},Ri=e=>{const{packageName:t,packageVersion:i,vulnerability:a}=e,n=(a.aliases??[]).join(", ")||"none",r=(a.fixedVersions??[]).join(", ")||"no fixed version published";return`You are a security engineer. Explain this dependency vulnerability for a developer triaging it.
2
2
 
3
3
  Package: ${t}@${i}
4
4
  Advisory: ${a.id} (aliases: ${n})
@@ -1,4 +1,4 @@
1
- import{createRequire as ht}from"node:module";import{I as ze,s as I,E as q,q as Ge,V as G,j as yt}from"../packem_shared/index.server-qvZ-cy29.js";import{m as _,f as O,v as K,I as Y,A as wt,T as kt,u as Ee}from"../packem_shared/index-D75r1yKp.js";import{m as vt}from"./ts-loader.js";import{E as bt}from"../packem_shared/public-api-WqUCiyIe.js";import{P as Rt,T as xt}from"../packem_shared/package-version-gyjskW3N.js";import{_ as At,w as St,x as Et,g as Ct,R as Tt,c as jt,V as It,y as Nt,z as Ke,$ as Ce,d as P,h as ge,i as L,H as Je,A as Dt,F as W,Z as Ut,L as Vt,j as Ot,G as Bt}from"./catalog.js";import{B as _t}from"../packem_shared/en-BRcjb70R.js";import{I as le}from"../packem_shared/index-B0EsgdzO.js";import{K as qt,Z as Wt,W as Te}from"../packem_shared/ai-analysis-DWBi9tSU.js";import{v as Ht,h as Lt,s as Ye}from"../packem_shared/pm-runner-D5NWL8yv.js";import{a as Ft,r as zt}from"../packem_shared/command-runtime-Buz4F5LM.js";import{r as Gt,a as Kt,p as Jt}from"../packem_shared/resolve-explicit-CnEsy-zC.js";import{i as me}from"./cli-main.js";import{S as Yt}from"../packem_shared/min-release-age-Cdh1dLz1.js";import{r as Zt,s as Xt}from"../packem_shared/typosquats-DWB80Gyv.js";import{U as Qt,b as en,u as je,e as tn}from"../packem_shared/vis-update-app-M3dw6XRC.js";import{h as Ze,P as Xe}from"../packem_shared/peer-warnings-BXAzXqY3.js";import{f as Qe}from"../packem_shared/utils-CRueU43T.js";import{s as te}from"../packem_shared/index-BAe6e0XE.js";import{r as nn,q as sn}from"../packem_shared/advisories-B76fBVL-.js";const $t=ht(import.meta.url),Q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Le=e=>{if(typeof Q<"u"&&Q.versions&&Q.versions.node){const[n,t]=Q.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return Q.getBuiltinModule(e)}return $t(e)},{createInterface:Fe}=Le("node:readline"),{existsSync:Mt,realpathSync:Pt}=Le("node:fs"),on=e=>{const n=[];for(const t of e.filters)n.push("--filter",t);return e.workspaceRoot&&n.push("--filter","."),n.push("update"),e.latest&&n.push("--latest"),e.recursive&&n.push("--recursive"),e.interactive&&n.push("--interactive"),e.dev&&n.push("--dev"),e.prod&&n.push("--prod"),e.noOptional&&n.push("--no-optional"),e.noSave&&n.push("--no-save"),n.push(...e.packages),{args:n,bin:"pnpm"}},rn=e=>{const n=[];return e.filters.length>0&&n.push("workspace",e.filters[0]),n.push("upgrade"),e.latest&&n.push("--latest"),n.push(...e.packages),{args:n,bin:"yarn"}},an=e=>{const n=[];if(e.filters.length>0||e.recursive){n.push("workspaces","foreach","--all");for(const t of e.filters)n.push("--include",t)}return n.push("up"),e.interactive&&n.push("--interactive"),n.push(...e.packages),{args:n,bin:"yarn"}},cn=(e,n)=>{const t=["update"];e.latest&&n.push("npm does not support --latest flag. Packages will be updated within their semver range."),e.interactive&&n.push("npm does not support --interactive mode.");for(const s of e.filters)t.push("--workspace",s);return e.recursive&&t.push("--workspaces"),e.workspaceRoot&&t.push("--include-workspace-root"),e.dev&&t.push("--dev"),e.prod&&t.push("--production"),e.noOptional&&t.push("--no-optional"),e.noSave&&t.push("--no-save"),t.push(...e.packages),{args:t,bin:"npm"}},ln=e=>{const n=["update"];e.latest&&n.push("--latest");for(const t of e.filters)n.push("--filter",t);return n.push(...e.packages),{args:n,bin:"bun"}},un=(e,n)=>{const t=["outdated","--update"];return e.latest&&t.push("--latest"),e.interactive&&t.push("--interactive"),e.filters.length>0&&n.push("deno outdated has no --filter flag; ignoring."),(e.dev||e.prod)&&n.push("deno outdated has no --dev / --prod flags; dev/prod is governed by deno.json."),e.noOptional&&n.push("deno outdated has no --no-optional flag; ignoring."),e.noSave&&n.push("deno outdated has no --no-save flag; ignoring."),t.push(...e.packages),{args:t,bin:"deno"}},dn=(e,n,t)=>{const s=[];if(t.global&&e!=="aube"&&e!=="deno")return{command:{args:["update","--global",...t.packages],bin:"npm"},warnings:s};let r;switch(e){case"aube":{const o=Ht(t);r={args:o.args,bin:o.bin},s.push(...o.warnings);break}case"bun":{r=ln(t);break}case"deno":{r=un(t,s);break}case"npm":{r=cn(t,s);break}case"pnpm":{r=on(t);break}case"yarn":{r=n.startsWith("1.")?rn(t):an(t);break}default:{const o=e;throw new Error(`Unsupported package manager: ${String(o)}`)}}return{command:r,warnings:s}},et=e=>{const n=e.indexOf("@");return n<=0?e:e.slice(0,n)},pn=e=>{switch(e){case"docker":case"docker-compose":return"docker";case"github-actions":return"actions";case"gitlab-ci":return"gitlab";default:return}},fn=(e,n)=>{const t=[".github/dependabot.yml",".github/dependabot.yaml"];for(const s of t){const r=_(e,s);if(!O(r))continue;let o;try{o=bt(K(r))}catch{continue}if(o?.updates){for(const i of o.updates){const a=pn(i["package-ecosystem"]);if(!(!a||!Array.isArray(i.ignore)))for(const d of i.ignore){const c=d["dependency-name"];typeof c=="string"&&c.length>0&&n[a].add(et(c))}}return}}},gn=Object.freeze({"docker-compose":"docker",dockerfile:"docker","github-actions":"actions",gitlabci:"gitlab","gitlabci-include":"gitlab"}),mn=Object.freeze({docker:"docker","github-tags":"actions"}),he=(e,n)=>{if(n)for(const t of n)typeof t=="string"&&t.length>0&&e.add(et(t))},hn=e=>{let n="",t=0;const{length:s}=e;let r=!1,o="";for(;t<s;){const i=e[t]??"";if(r){if(n+=i,i==="\\"&&t+1<s){n+=e[t+1]??"",t+=2;continue}i===o&&(r=!1),t+=1;continue}if(i==='"'||i==="'"){r=!0,o=i,n+=i,t+=1;continue}if(i==="/"&&e[t+1]==="/"){for(;t<s&&e[t]!==`
1
+ import{createRequire as ht}from"node:module";import{I as ze,s as I,E as q,q as Ge,V as G,j as yt}from"../packem_shared/index.server-qvZ-cy29.js";import{m as _,f as O,v as K,I as Y,A as wt,T as kt,u as Ee}from"../packem_shared/index-D75r1yKp.js";import{m as vt}from"./ts-loader.js";import{E as bt}from"../packem_shared/public-api-WqUCiyIe.js";import{P as Rt,T as xt}from"../packem_shared/package-version-DBJLduJL.js";import{_ as At,w as St,x as Et,g as Ct,R as Tt,c as jt,V as It,y as Nt,z as Ke,$ as Ce,d as P,h as ge,i as L,H as Je,A as Dt,F as W,Z as Ut,L as Vt,j as Ot,G as Bt}from"./catalog.js";import{B as _t}from"../packem_shared/en-BRcjb70R.js";import{I as le}from"../packem_shared/index-B0EsgdzO.js";import{K as qt,Z as Wt,W as Te}from"../packem_shared/ai-analysis-DWBi9tSU.js";import{v as Ht,h as Lt,s as Ye}from"../packem_shared/pm-runner-D5NWL8yv.js";import{a as Ft,r as zt}from"../packem_shared/command-runtime-Buz4F5LM.js";import{r as Gt,a as Kt,p as Jt}from"../packem_shared/resolve-explicit-CnEsy-zC.js";import{i as me}from"./cli-main.js";import{S as Yt}from"../packem_shared/min-release-age-Cdh1dLz1.js";import{r as Zt,s as Xt}from"../packem_shared/typosquats-DWB80Gyv.js";import{U as Qt,b as en,u as je,e as tn}from"../packem_shared/vis-update-app-M3dw6XRC.js";import{h as Ze,P as Xe}from"../packem_shared/peer-warnings-BXAzXqY3.js";import{f as Qe}from"../packem_shared/utils-CRueU43T.js";import{s as te}from"../packem_shared/index-BAe6e0XE.js";import{r as nn,q as sn}from"../packem_shared/advisories-B76fBVL-.js";const $t=ht(import.meta.url),Q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Le=e=>{if(typeof Q<"u"&&Q.versions&&Q.versions.node){const[n,t]=Q.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return Q.getBuiltinModule(e)}return $t(e)},{createInterface:Fe}=Le("node:readline"),{existsSync:Mt,realpathSync:Pt}=Le("node:fs"),on=e=>{const n=[];for(const t of e.filters)n.push("--filter",t);return e.workspaceRoot&&n.push("--filter","."),n.push("update"),e.latest&&n.push("--latest"),e.recursive&&n.push("--recursive"),e.interactive&&n.push("--interactive"),e.dev&&n.push("--dev"),e.prod&&n.push("--prod"),e.noOptional&&n.push("--no-optional"),e.noSave&&n.push("--no-save"),n.push(...e.packages),{args:n,bin:"pnpm"}},rn=e=>{const n=[];return e.filters.length>0&&n.push("workspace",e.filters[0]),n.push("upgrade"),e.latest&&n.push("--latest"),n.push(...e.packages),{args:n,bin:"yarn"}},an=e=>{const n=[];if(e.filters.length>0||e.recursive){n.push("workspaces","foreach","--all");for(const t of e.filters)n.push("--include",t)}return n.push("up"),e.interactive&&n.push("--interactive"),n.push(...e.packages),{args:n,bin:"yarn"}},cn=(e,n)=>{const t=["update"];e.latest&&n.push("npm does not support --latest flag. Packages will be updated within their semver range."),e.interactive&&n.push("npm does not support --interactive mode.");for(const s of e.filters)t.push("--workspace",s);return e.recursive&&t.push("--workspaces"),e.workspaceRoot&&t.push("--include-workspace-root"),e.dev&&t.push("--dev"),e.prod&&t.push("--production"),e.noOptional&&t.push("--no-optional"),e.noSave&&t.push("--no-save"),t.push(...e.packages),{args:t,bin:"npm"}},ln=e=>{const n=["update"];e.latest&&n.push("--latest");for(const t of e.filters)n.push("--filter",t);return n.push(...e.packages),{args:n,bin:"bun"}},un=(e,n)=>{const t=["outdated","--update"];return e.latest&&t.push("--latest"),e.interactive&&t.push("--interactive"),e.filters.length>0&&n.push("deno outdated has no --filter flag; ignoring."),(e.dev||e.prod)&&n.push("deno outdated has no --dev / --prod flags; dev/prod is governed by deno.json."),e.noOptional&&n.push("deno outdated has no --no-optional flag; ignoring."),e.noSave&&n.push("deno outdated has no --no-save flag; ignoring."),t.push(...e.packages),{args:t,bin:"deno"}},dn=(e,n,t)=>{const s=[];if(t.global&&e!=="aube"&&e!=="deno")return{command:{args:["update","--global",...t.packages],bin:"npm"},warnings:s};let r;switch(e){case"aube":{const o=Ht(t);r={args:o.args,bin:o.bin},s.push(...o.warnings);break}case"bun":{r=ln(t);break}case"deno":{r=un(t,s);break}case"npm":{r=cn(t,s);break}case"pnpm":{r=on(t);break}case"yarn":{r=n.startsWith("1.")?rn(t):an(t);break}default:{const o=e;throw new Error(`Unsupported package manager: ${String(o)}`)}}return{command:r,warnings:s}},et=e=>{const n=e.indexOf("@");return n<=0?e:e.slice(0,n)},pn=e=>{switch(e){case"docker":case"docker-compose":return"docker";case"github-actions":return"actions";case"gitlab-ci":return"gitlab";default:return}},fn=(e,n)=>{const t=[".github/dependabot.yml",".github/dependabot.yaml"];for(const s of t){const r=_(e,s);if(!O(r))continue;let o;try{o=bt(K(r))}catch{continue}if(o?.updates){for(const i of o.updates){const a=pn(i["package-ecosystem"]);if(!(!a||!Array.isArray(i.ignore)))for(const d of i.ignore){const c=d["dependency-name"];typeof c=="string"&&c.length>0&&n[a].add(et(c))}}return}}},gn=Object.freeze({"docker-compose":"docker",dockerfile:"docker","github-actions":"actions",gitlabci:"gitlab","gitlabci-include":"gitlab"}),mn=Object.freeze({docker:"docker","github-tags":"actions"}),he=(e,n)=>{if(n)for(const t of n)typeof t=="string"&&t.length>0&&e.add(et(t))},hn=e=>{let n="",t=0;const{length:s}=e;let r=!1,o="";for(;t<s;){const i=e[t]??"";if(r){if(n+=i,i==="\\"&&t+1<s){n+=e[t+1]??"",t+=2;continue}i===o&&(r=!1),t+=1;continue}if(i==='"'||i==="'"){r=!0,o=i,n+=i,t+=1;continue}if(i==="/"&&e[t+1]==="/"){for(;t<s&&e[t]!==`
2
2
  `;)t+=1;continue}if(i==="/"&&e[t+1]==="*"){for(t+=2;t<s&&!(e[t]==="*"&&e[t+1]==="/");)t+=1;t+=2;continue}if(i===","){let a=t+1;for(;a<s&&/\s/.test(e[a]??"");)a+=1;const d=e[a];if(d==="}"||d==="]"){t+=1;continue}}n+=i,t+=1}return n},$n=(e,n)=>{const t=["renovate.json","renovate.json5",".renovaterc",".renovaterc.json"];for(const s of t){const r=_(e,s);if(!O(r))continue;let o;try{const a=K(r);o=JSON.parse(hn(a))}catch{continue}if(!o)continue;if(Array.isArray(o.ignoreDeps))for(const a of["actions","docker","gitlab"])he(n[a],o.ignoreDeps);const i=[["github-actions","actions"],["dockerfile","docker"],["docker-compose","docker"],["gitlabci","gitlab"],["gitlabci-include","gitlab"]];for(const[a,d]of i){const c=o[a];he(n[d],c?.ignoreDeps)}if(!Array.isArray(o.packageRules))return;for(const a of o.packageRules){if(a.enabled!==!1)continue;const d=new Set;for(const u of a.matchManagers??[]){const f=gn[u];f&&d.add(f)}for(const u of a.matchDatasources??[]){const f=mn[u];f&&d.add(f)}d.size===0&&(d.add("actions"),d.add("docker"),d.add("gitlab"));const c=[...a.matchPackageNames??[],...a.matchDepNames??[],...a.matchPackagePatterns??[]];for(const u of d)he(n[u],c)}return}},yn=e=>{const n={actions:new Set,docker:new Set,gitlab:new Set};return fn(e,n),$n(e,n),n},we=(e,n,t)=>{const s=t[n];if(s.size===0)return!1;if(s.has(e))return!0;for(const r of s)if(/[*?[\]/.+]/.test(r))try{const o=r.replaceAll(/[.+^${}()|]/g,String.raw`\$&`).replaceAll("*",".*").replaceAll("?",".");if(new RegExp(`^${o}$`).test(e))return!0}catch{}return!1},F=e=>{const n=e.trim();if(n==="")return;const t=n.startsWith("v")||n.startsWith("V")?n.slice(1):n,s=(te.valid(t)?te.parse(t):void 0)??te.coerce(t,{includePrerelease:!0});if(s)return{major:s.major,minor:s.minor,normalized:`${String(s.major)}.${String(s.minor)}.${String(s.patch)}${s.prerelease.length>0?`-${s.prerelease.join(".")}`:""}`,patch:s.patch,prerelease:s.prerelease.length>0,raw:n}},wn=(e,n)=>te.rcompare(e.normalized,n.normalized),ke=(e,n,t,s)=>{if(!n&&t!=="latest")return;const r=e.filter(o=>o.prerelease?!1:n?t==="patch"&&(o.major!==n.major||o.minor!==n.minor)||t==="minor"&&o.major!==n.major?!1:te.gt(o.normalized,n.normalized):!0);if(r.length!==0)return r.toSorted(wn)[0]},ve=(e,n)=>!e||!n?"unknown":n.major!==e.major?"major":n.minor!==e.minor?"minor":n.patch!==e.patch?"patch":"unknown",kn="GitHub Actions",Ie=(e,n)=>`${e}@${n}`,vn=e=>({fixedVersions:e.fixedVersions,id:e.id,severity:e.severity,summary:e.summary}),bn=(e,n)=>{if(n.length===0)return n;const t=nn(e);if(!Mt(t))return n;const s=new Map;for(const o of n){const i=o.currentVersion??o.currentRef;i&&s.set(Ie(o.name,i),{name:o.name,version:i})}if(s.size===0)return n;const r=new Map;try{for(const[o,i]of s){const a=sn([i],{ecosystem:kn,workspaceRoot:e}).get(i.name);a&&a.length>0&&r.set(o,a)}}catch{return n}return r.size===0?n:n.map(o=>{const i=o.currentVersion??o.currentRef;if(!i)return o;const a=r.get(Ie(o.name,i));return a?{...o,advisories:a.map(d=>vn(d))}:o})},tt=e=>{if(!e)return{};const n={};for(const t of e.split(",")){const s=/^\s*<([^>]+)>\s*;\s*(.+)$/.exec(t);if(!s)continue;const r=s[1]??"",o=s[2]??"";switch(/rel\s*=\s*"?([^";\s]+)"?/i.exec(o)?.[1]?.toLowerCase()){case"first":{n.first=r;break}case"last":{n.last=r;break}case"next":{n.next=r;break}case"prev":case"previous":{n.previous=r;break}}}return n};class Rn{token;apiBase;fetchImpl;tagsCache=new Map;commitCache=new Map;constructor(n){this.token=n.token??process.env.GITHUB_TOKEN??process.env.GH_TOKEN,this.apiBase=n.apiBase??"https://api.github.com",this.fetchImpl=n.fetch??fetch}async listTags(n,t){const s=`${n}/${t}`,r=this.tagsCache.get(s);if(r)return r;const o=this.fetchTags(n,t);return this.tagsCache.set(s,o),o}async resolveRef(n,t,s){const r=`${n}/${t}@${s}`,o=this.commitCache.get(r);if(o)return o;const i=this.fetchCommit(n,t,s);return this.commitCache.set(r,i),i}buildHeaders(){const n={Accept:"application/vnd.github+json","User-Agent":"vis-update-actions","X-GitHub-Api-Version":"2022-11-28"};return this.token&&(n.Authorization=`Bearer ${this.token}`),n}async fetchTags(n,t){const s=`${this.apiBase}/repos/${encodeURIComponent(n)}/${encodeURIComponent(t)}/tags?per_page=100`,r={parsed:[],tags:[]},o=[];let i=s,a=0;for(;i&&a<5;){const c=i;let u;try{u=await this.fetchImpl(c,{headers:this.buildHeaders()})}catch{return r}if(!u.ok)return r;let f;try{f=await u.json()}catch{return r}if(!Array.isArray(f))return r;for(const g of f){const m=typeof g.name=="string"?g.name:"",h=typeof g.commit?.sha=="string"?g.commit.sha:"";m!==""&&h!==""&&o.push({name:m,sha:h})}i=tt(u.headers.get("link")).next,a+=1}const d=[];for(const c of o){const u=F(c.name);u&&d.push({...u,sha:c.sha})}return{parsed:d,tags:o}}async fetchCommit(n,t,s){const r=`${this.apiBase}/repos/${encodeURIComponent(n)}/${encodeURIComponent(t)}/commits/${encodeURIComponent(s)}`;try{const o=await this.fetchImpl(r,{headers:this.buildHeaders()});if(!o.ok)return;const i=await o.json();return typeof i.sha!="string"?void 0:{committedAt:i.commit?.committer?.date,sha:i.sha}}catch{return}}}const xn=".github/workflows",An=".github/actions",Sn=/^\s*-?\s*uses:\s*(['"]?)([^'"\s#]+)\1(?:\s*#\s*(.+))?\s*$/,En=/^[a-f0-9]{40}$/i,Cn=/actions-up-ignore-next-line(?::\s*(.+))?/i,Tn=/actions-up-ignore-start/i,jn=/actions-up-ignore-end/i,In=e=>{const n=e.split("/");if(n.length<2)return;const[t,s,...r]=n;if(!(!t||!s))return{owner:t,repo:s,subpath:r.length>0?r.join("/"):void 0}},Nn=(e,n)=>{const t=n.split(/\r?\n/),s=[];let r,o=!1;for(const[i,a]of t.entries()){const d=a??"";if(Tn.test(d)&&(o=!0),jn.test(d)){o=!1;continue}const c=d.trim(),u=c===""||c.startsWith("#")?Cn.exec(d):void 0;if(u){r=u[1]??"actions-up-ignore-next-line";continue}const f=Sn.exec(d);if(!f){r=void 0;continue}const g=f[1]??"",m=g==="'"||g==='"'?g:"",h=f[2]??"",R=f[3]?.trim();if(h.startsWith("./")||h.startsWith("../")||h.startsWith("docker://")){r=void 0;continue}const A=h.lastIndexOf("@");if(A<=0){r=void 0;continue}const $=h.slice(0,A),S=h.slice(A+1),y=In($);if(!y){r=void 0;continue}let p=r??(o?"actions-up-ignore-block":void 0);if(R){const w=/^actions-up-ignore(?:-next-line)?(?::\s*(.+))?(?:\s|$)/i.exec(R);w&&(p=p??w[1]??"actions-up-ignore")}r=void 0,s.push({file:e,ignoreReason:p,isSha:En.test(S),line:i+1,original:`${m}${h}${m}`,owner:y.owner,quote:m,ref:S,repo:y.repo,slug:$,subpath:y.subpath,trailingComment:R&&!p?R:void 0})}return s},Ne=e=>e.endsWith(".yml")||e.endsWith(".yaml"),Dn=(e,n=[])=>{const t=[],s=new Set,r=a=>{if(s.has(a))return;s.add(a);let d;try{d=K(a)}catch{return}const c=Nn(a,d);t.push(...c)},o=_(e,xn);if(O(o))for(const a of Y(o,{includeDirs:!1,includeSymlinks:!1,maxDepth:1}))Ne(a.name)&&r(a.path);const i=_(e,An);if(O(i))for(const a of Y(i,{includeDirs:!1,includeSymlinks:!1,maxDepth:3}))(a.name==="action.yml"||a.name==="action.yaml")&&r(a.path);for(const a of["action.yml","action.yaml"]){const d=_(e,a);O(d)&&r(d)}for(const a of n){const d=wt(a)?a:_(e,a);if(O(d))for(const c of Y(d,{includeDirs:!1,includeSymlinks:!1}))Ne(c.name)&&r(c.path)}return t},Un=40,Vn=1440*60*1e3,On=new Set(["develop","edge","main","master","stable","trunk"]),Bn=e=>e.length===Un&&/^[a-f0-9]{40}$/i.test(e)?!1:On.has(e.toLowerCase())?!0:F(e)===void 0,De=(e,n)=>{for(const t of n)try{if(new RegExp(t).test(e))return!0}catch{if(e.includes(t))return!0}return!1},_n=(e,n,t,s)=>{const r=s==="sha"||e.isSha,{quote:o}=e;return r?`${o}${e.slug}@${n}${o} # ${t}`:`${o}${e.slug}@${t}${o}`},Mn=async(e,n)=>{const{ignoreRules:t,options:s,references:r,resolverOptions:o}=n,i=[],a=[],d=[];if(r.length===0)return{failed:d,ignored:a,updates:i};const c=new Rn({apiBase:o?.apiBase,fetch:o?.fetch,token:s.githubToken??o?.token}),u=new Map;for(const $ of r){const S=`${$.owner}/${$.repo}`,y=u.get(S)??[];y.push($),u.set(S,y)}const f=Math.max(1,s.maxConcurrentRequests),g=[...u.keys()];let m=0;const h=async $=>{const S=u.get($)??[],[y,p]=$.split("/");if(!y||!p)return;let w;try{w=await c.listTags(y,p)}catch{for(const l of S)d.push({file:l.file,reason:`failed to list tags for ${$}`});return}for(const l of S){const E=l.slug;let k;if(l.ignoreReason?k=l.ignoreReason:De(E,s.exclude)?k="matched --exclude":s.include.length>0&&!De(E,s.include)?k="not matched by --include":s.respectDependabotConfig&&t&&we(E,"actions",t)&&(k="ignored by dependabot/renovate config"),k){a.push({currentRef:l.ref,currentVersion:l.isSha?l.trailingComment?.replace(/^#\s*/,""):l.ref,ecosystem:"actions",file:l.file,ignored:!0,line:l.line,name:E,newRef:l.ref,newVersion:void 0,original:l.original,reason:k,replacement:l.original,updateType:"unknown"});continue}if(!s.includeBranches&&!l.isSha&&Bn(l.ref)){a.push({currentRef:l.ref,currentVersion:l.ref,ecosystem:"actions",file:l.file,ignored:!0,line:l.line,name:E,newRef:l.ref,newVersion:void 0,original:l.original,reason:"branch reference (use --include-branches)",replacement:l.original,updateType:"unknown"});continue}const C=l.isSha?l.trailingComment?.replace(/^#\s*/,"").split(/\s+/)[0]??"":l.ref,T=F(C);if(l.isSha&&!T&&s.mode!=="latest"){a.push({currentRef:l.ref,currentVersion:void 0,ecosystem:"actions",file:l.file,ignored:!0,line:l.line,name:E,newRef:l.ref,newVersion:void 0,original:l.original,reason:`SHA pin has no version-hint comment; cannot apply --target=${s.mode}`,replacement:l.original,updateType:"unknown"});continue}const x=ke(w.parsed,T,s.mode);if(!x)continue;if(s.minAgeDays!==void 0){const M=await c.resolveRef(y,p,x.sha),D=M?.committedAt?new Date(M.committedAt).getTime():void 0;if(D&&(Date.now()-D)/Vn<s.minAgeDays){a.push({currentRef:l.ref,currentVersion:T?.raw,ecosystem:"actions",file:l.file,ignored:!0,line:l.line,name:E,newRef:l.ref,newVersion:x.raw,original:l.original,reason:`release younger than ${String(s.minAgeDays)} days`,replacement:l.original,updateType:"unknown"});continue}}const j=s.style==="sha"||l.isSha?x.sha:x.raw,N=_n(l,x.sha,x.raw,s.style);i.push({currentRef:l.ref,currentVersion:T?.raw??l.trailingComment?.replace(/^#\s*/,""),ecosystem:"actions",file:l.file,line:l.line,name:E,newRef:j,newVersion:x.raw,original:l.original,replacement:N,updateType:ve(T,x),url:`https://github.com/${y}/${p}/releases/tag/${x.raw}`})}},R=[];for(let $=0;$<Math.min(f,g.length);$++)R.push((async()=>{for(;m<g.length;){const S=g[m];m+=1,S!==void 0&&await h(S)}})());await Promise.all(R);const A=bn(e,i);return{failed:d,ignored:a,updates:A}},Pn=e=>e.toSorted((n,t)=>n.file!==t.file?n.file<t.file?-1:1:n.line-t.line),nt=e=>{const n=[],t=[];if(e.length===0)return{applied:n,skipped:t};const s=Pn(e),r=new Map;for(const o of s){const i=r.get(o.file)??[];i.push(o),r.set(o.file,i)}for(const[o,i]of r){let a;try{a=K(o)}catch(g){for(const m of i)t.push({reason:`read failed: ${g.message}`,update:m});continue}const d=a.includes(`\r
3
3
  `)?`\r
4
4
  `:`