@visulima/vis 1.0.0-alpha.30 → 1.0.0-alpha.32
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 +17 -0
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/bin.js +290 -290
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/config.js +15 -15
- package/dist/packem_chunks/doctor-probe.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler32.js +1 -1
- package/dist/packem_chunks/handler35.js +1 -1
- package/dist/packem_chunks/handler36.js +1 -1
- package/dist/packem_chunks/handler37.js +1 -1
- package/dist/packem_chunks/handler38.js +1 -1
- package/dist/packem_chunks/handler39.js +1 -1
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler42.js +1 -1
- package/dist/packem_chunks/handler43.js +1 -1
- package/dist/packem_chunks/handler44.js +1 -1
- package/dist/packem_chunks/handler45.js +1 -1
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +1 -1
- package/dist/packem_chunks/handler48.js +1 -1
- package/dist/packem_chunks/handler49.js +1 -1
- package/dist/packem_chunks/handler50.js +1 -1
- package/dist/packem_chunks/handler51.js +37 -37
- package/dist/packem_chunks/handler52.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/Table-3pFgIUZ2-DABgc6rj.js +12 -0
- package/dist/packem_shared/{advisories-BxXiKFbL.js → advisories-CGKZo9Rx.js} +1 -1
- package/dist/packem_shared/{cyclonedx-BpGVHqSW.js → cyclonedx-BilSFCNY.js} +1 -1
- package/dist/packem_shared/{docker-CTE3s4LW.js → docker-EJiTY0Sz.js} +1 -1
- package/dist/packem_shared/{index-D1xC1Y_R.js → index-BnANMQ7k.js} +1 -1
- package/dist/packem_shared/{index-hoWfZmNo.js → index-K8aQuMvx.js} +1 -1
- package/dist/packem_shared/{lifecycle-CXaqPGAQ.js → lifecycle-Buigdp7P.js} +2 -2
- package/dist/packem_shared/{osv-bloom-DSZcHLsM.js → osv-bloom-0Vu8YRhg.js} +1 -1
- package/dist/packem_shared/{provenance-DkCA8BrN.js → provenance-D8vU1u2L.js} +1 -1
- package/dist/packem_shared/{registry-keys-Mixm4eAY.js → registry-keys-E3cZn4FI.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-D5E72FfN.js → resolve-explicit-cPzwdiEE.js} +1 -1
- package/dist/packem_shared/{s1ngularity-Qxc6tRRI.js → s1ngularity-DBcjspCC.js} +1 -1
- package/dist/packem_shared/{scan-progress-DVtCtI2z.js → scan-progress-CTVVf9WW.js} +1 -1
- package/dist/packem_shared/{signatures-byuFrtAH.js → signatures-ChTfrQvT.js} +1 -1
- package/dist/packem_shared/{typosquats-BiDxQj7R.js → typosquats-acxQ7blw.js} +1 -1
- package/dist/packem_shared/{watch-loop-C31Ar7BX.js → watch-loop-BpA_pxU9.js} +1 -1
- package/index.d.ts +201 -201
- package/index.js +52 -52
- package/package.json +10 -10
- package/dist/packem_shared/Table-DoSoazT6-DwnyTUsA.js +0 -12
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var ai=Object.defineProperty;var $=(t,e)=>ai(t,"name",{value:e,configurable:!0});import{createRequire as hi}from"node:module";const ci=hi(import.meta.url),ft=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,li=$(t=>{if(typeof ft<"u"&&ft.versions&&ft.versions.node){const[e,i]=ft.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return ft.getBuiltinModule(t)}return ci(t)},"__cjs_getBuiltinModule"),{createRequire:di}=li("node:module"),xt=0,H=1,mt=2,G=3;var ui=Object.defineProperty,fi=$((t,e)=>ui(t,"name",{value:e,configurable:!0}),"p$2"),mi=Object.defineProperty,gi=fi((t,e)=>mi(t,"name",{value:e,configurable:!0}),"_"),pi=Object.defineProperty,$t=gi((t,e)=>pi(t,"name",{value:e,configurable:!0}),"u");const bi=/^-{1,2}(no-color|no-colors|color=false|color=never)$/,wi=/^-{1,2}(color=256)$/,yi=/^-{1,2}(color=16m|color=full|color=truecolor)$/,vi=/^-{1,2}(color|colors|color=true|color=always)$/,xi=/-mono|dumb/i,Bi=/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/,Wi=/-256(color)?$/i,Ri=/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i,Te=$t(t=>{const e=globalThis,i=e.Deno!=null,o=e.process??e.Deno??{},h=o.argv??o.args??[],s=$t(g=>{const b=h.indexOf("--"),f=h.findIndex(x=>g.test(x));return f!==-1&&(b===-1||f<b)},"oneOfFlags");let r={};try{r=i?o.env.toObject():o.env??{}}catch{}const a="FORCE_COLOR",n=a in r,c=r[a]??void 0,d=Object.prototype.toString.call(c).slice(8,-1)==="String",l=typeof c=="number";let u;if(c==="true")u=H;else if(c==="false")u=xt;else if(d&&c.length===0)u=H;else if(d&&c.length>0){const g=Number.parseInt(c,10);u=Number.isNaN(g)?void 0:Math.min(g,3)}else l&&(u=Number.isNaN(c)?void 0:Math.min(c,3));if(c!=="true"&&c!=="false"&&u!==void 0&&u<4)return u;if("NO_COLOR"in r||n&&u===0||s(bi))return xt;if(s(wi))return mt;if(s(yi))return G;if(s(vi))return H;const p=u??xt;if("TF_BUILD"in r&&"AGENT_NAME"in r)return H;if(r.TERM&&xi.test(r.TERM))return p;if((i?e.Deno.build.os:o.platform)==="win32")try{const g=(i?e.Deno.osRelease():o.os.release()).split(".");return Number(g[0])>=10&&Number(g[2])>=10586?Number(g[2])>=14931?G:mt:H}catch{}if("CI"in r)return["GITEA_ACTIONS","CIRCLECI","GITHUB_WORKFLOW","GITHUB_ACTIONS"].some(g=>g in r)?G:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(g=>g in r)||r.CI_NAME==="codeship"?H:p;if(r.TERMINAL_EMULATOR?.includes("JediTerm"))return G;if("TEAMCITY_VERSION"in r)return Bi.test(r.TEAMCITY_VERSION)?H:xt;if(r.COLORTERM==="truecolor"||r.TERM==="xterm-kitty"||r.TERM==="xterm-ghostty"||r.TERM==="wezterm")return G;if("TERM_PROGRAM"in r){const g=Number.parseInt((r.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(r.TERM_PROGRAM==="iTerm.app")return g>=3?G:mt;if(r.TERM_PROGRAM==="Apple_Terminal")return mt}if(Wi.test(r.TERM))return mt;let m;return i?m=t==="out"?e.Deno.stdout.isTerminal():e.Deno.stderr.isTerminal():"PM2_HOME"in r&&"pm_id"in r?m=!0:m=!!o[`std${t}`]?.isTTY,m&&Ri.test(r.TERM)||"COLORTERM"in r?H:p},"isColorSupportedFactory"),Si=$t(()=>Te("out"),"isStdoutColorSupported");$t(()=>Te("err"),"isStderrColorSupported");var ji=Object.defineProperty,ke=$((t,e)=>ji(t,"name",{value:e,configurable:!0}),"B$2"),Ai=Object.defineProperty,q=ke((t,e)=>Ai(t,"name",{value:e,configurable:!0}),"u"),Ci=Object.defineProperty,Ii=q((t,e)=>Ci(t,"name",{value:e,configurable:!0}),"e$1");function Pt({onlyFirst:t=!1}={}){const e="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(e,t?void 0:"g")}$(Pt,"x");ke(Pt,"N");q(Pt,"t$1");Ii(Pt,"ansiRegex");var Oi=Object.defineProperty,Mi=q((t,e)=>Oi(t,"name",{value:e,configurable:!0}),"n$1");const V=Mi((t,e,i)=>e>t?e:Math.min(t,i),"clamp");var Ei=Object.defineProperty,$i=q((t,e)=>Ei(t,"name",{value:e,configurable:!0}),"a$1");const Ti=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,ki=$i(t=>{let[,e]=Ti.exec(t)??[];const i=e?e.length:0;if(i===3){const h=e.charAt(0),s=e.charAt(1),r=e.charAt(2);e=h+h+s+s+r+r}else if(i!==6)return[0,0,0];const o=Number.parseInt(e,16);return[o>>16&255,o>>8&255,o&255]},"convertHexToRgb");var Ni=Object.defineProperty,ne=q((t,e)=>Ni(t,"name",{value:e,configurable:!0}),"e");const Ne=ne((t,e,i)=>t===e&&e===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/51)+6*Math.round(e/51)+Math.round(i/51),"rgbToAnsi256"),Kt=ne(t=>{let e,i,o;if(t<8)return 30+t;if(t<16)return 90+(t-8);if(t>=232)e=i=o=((t-232)*10+8)/255;else{t-=16;const r=t%36;e=Math.floor(t/36)/5,i=Math.floor(r/6)/5,o=r%6/5}const h=Math.max(e,i,o)*2;if(h===0)return 30;const s=30+(Math.round(o)<<2|Math.round(i)<<1|Math.round(e));return h===2?s+60:s},"ansi256To16"),ue=ne((t,e,i)=>Kt(Ne(t,e,i)),"rgbToAnsi16");var Pi=Object.defineProperty,T=q((t,e)=>Pi(t,"name",{value:e,configurable:!0}),"b");const I=39,O=49,fe=10,Zt=Si(),Pe={close:"",open:""},y=Zt>0?(t,e)=>({close:`\x1B[${String(e)}m`,open:`\x1B[${String(t)}m`}):()=>Pe,me=T(t=>(e,i,o)=>t(Ne(Number(e),Number(i),Number(o))),"createRgbFunction"),ge=T(t=>e=>{const[i,o,h]=ki(e);return t(i,o,h)},"createHexFunction");let Xt=T(t=>y(`38;5;${String(t)}`,I),"createAnsi256"),Qt=T(t=>y(`48;5;${String(t)}`,O),"createBgAnsi256"),Tt=T((t,e,i)=>y(`38;2;${String(t)};${String(e)};${String(i)}`,I),"createRgb"),kt=T((t,e,i)=>y(`48;2;${String(t)};${String(e)};${String(i)}`,O),"createBgRgb");Zt===1?(Xt=T(t=>y(Kt(Number(t)),I),"createAnsi256"),Qt=T(t=>y(Kt(Number(t))+fe,O),"createBgAnsi256"),Tt=T((t,e,i)=>y(ue(Number(t),Number(e),Number(i)),I),"createRgb"),kt=T((t,e,i)=>y(ue(Number(t),Number(e),Number(i))+fe,O),"createBgRgb")):Zt===2&&(Tt=me(Xt),kt=me(Qt));const pe={bold:y(1,22),dim:y(2,22),hidden:y(8,28),inverse:y(7,27),italic:y(3,23),overline:y(53,55),reset:y(0,0),strike:y(9,29),strikethrough:y(9,29),underline:y(4,24),visible:Pe},be={bgBlack:y(40,O),bgBlackBright:y(100,O),bgBlue:y(44,O),bgBlueBright:y(104,O),bgCyan:y(46,O),bgCyanBright:y(106,O),bgGray:y(100,O),bgGreen:y(42,O),bgGreenBright:y(102,O),bgGrey:y(100,O),bgMagenta:y(45,O),bgMagentaBright:y(105,O),bgRed:y(41,O),bgRedBright:y(101,O),bgWhite:y(47,O),bgWhiteBright:y(107,O),bgYellow:y(43,O),bgYellowBright:y(103,O),black:y(30,I),blackBright:y(90,I),blue:y(34,I),blueBright:y(94,I),cyan:y(36,I),cyanBright:y(96,I),gray:y(90,I),green:y(32,I),greenBright:y(92,I),grey:y(90,I),magenta:y(35,I),magentaBright:y(95,I),red:y(31,I),redBright:y(91,I),white:y(37,I),whiteBright:y(97,I),yellow:y(33,I),yellowBright:y(93,I)},we={bg:T(t=>Qt(V(t,0,255)),"bg"),bgHex:ge(kt),bgRgb:T((t,e,i)=>kt(V(t,0,255),V(e,0,255),V(i,0,255)),"bgRgb"),fg:T(t=>Xt(V(t,0,255)),"fg"),hex:ge(Tt),rgb:T((t,e,i)=>Tt(V(t,0,255),V(e,0,255),V(i,0,255)),"rgb")};var Li=Object.defineProperty,Fi=q((t,e)=>Li(t,"name",{value:e,configurable:!0}),"s");const _i=Fi((t,e,i)=>{if(e==="")return t;let o=t.indexOf(e);if(o<0)return t;const h=e.length;let s=0,r="";for(;~o;)r+=t.slice(s,o)+i,s=o+h,o=t.indexOf(e,s);return r+t.slice(s)},"stringReplaceAll");var Ji=Object.defineProperty,bt=q((t,e)=>Ji(t,"name",{value:e,configurable:!0}),"a");const z={};let te=null;const Hi=bt((t,e,i)=>{if(!t)return"";let o;if(t.raw===void 0?o=String(t):o=String.raw(t,...e),o.includes("\x1B"))for(let h=i;h;h=h.props)o=_i(o,h.close,h.open);return o.includes(`
|
|
2
|
+
`)&&(o=o.replace(/(\r*\n)/g,`${i.closeStack}$1${i.openStack}`)),i.openStack+o+i.closeStack},"wrapText"),ee=bt(({props:t},{close:e,open:i})=>{const o=(t?.openStack??"")+i,h=e+(t?.closeStack??""),s=bt((r,...a)=>Hi(r,a,s.props),"style");return Object.setPrototypeOf(s,te),s.props={close:e,closeStack:h,open:i,openStack:o,props:t},s.open=o,s.close=h,s},"createStyle"),Gi=bt(function(){const t=bt(e=>String(e),"self");t.strip=e=>e.replaceAll(Pt(),"");for(const e in be)z[e]={get(){const i=ee(this,be[e]);return Object.defineProperty(this,e,{value:i}),i}};for(const e in pe)z[e]={get(){const i=ee(this,pe[e]);return Object.defineProperty(this,e,{value:i}),i}};return te=Object.defineProperties({},z),Object.setPrototypeOf(t,te),t},"Colorize");for(const t in we)z[t]={get(){return(...e)=>ee(this,we[t](...e))}};z.ansi256=z.fg;z.bgAnsi256=z.bg;const U=new Gi,dn=U.bold,un=U.cyan,fn=U.dim,mn=U.green,gn=U.inverse,pn=U.magenta,bn=U.red,wn=U.yellow;var Vi=Object.defineProperty,_=$((t,e)=>Vi(t,"name",{value:e,configurable:!0}),"O"),Di=Object.defineProperty,S=_((t,e)=>Di(t,"name",{value:e,configurable:!0}),"$");const zi=di(import.meta.url),at=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=S(t=>{if(typeof at<"u"&&at.versions&&at.versions.node){const[e,i]=at.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return at.getBuiltinModule(t)}return zi(t)},"__cjs_getBuiltinModule"),X=at,{execFileSync:Yi}=se("node:child_process"),pt=se("node:fs"),qi=se("node:tty");var Ui=Object.defineProperty,ae=S((t,e)=>Ui(t,"name",{value:e,configurable:!0}),"u$6"),Ki=Object.defineProperty,Lt=ae((t,e)=>Ki(t,"name",{value:e,configurable:!0}),"l");const Zi=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Xi=12288,Qi=65510,tr=[12288,12288,65281,65376,65504,65510],er=8361,ir=65518,rr=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],or=32,nr=10630,sr=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],ar=4352,hr=262141,Le=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var cr=Object.defineProperty,lr=Lt((t,e)=>cr(t,"name",{value:e,configurable:!0}),"r$1");const yt=lr((t,e)=>{let i=0,o=Math.floor(t.length/2)-1;for(;i<=o;){const h=Math.floor((i+o)/2),s=h*2;if(e<t[s])o=h-1;else if(e>t[s+1])i=h+1;else return!0}return!1},"isInRange");var dr=Object.defineProperty,tt=Lt((t,e)=>dr(t,"name",{value:e,configurable:!0}),"r");const ye=19968,[ur,fr]=ct(Le);function ct(t){let e=t[0],i=t[1];for(let o=0;o<t.length;o+=2){const h=t[o],s=t[o+1];if(ye>=h&&ye<=s)return[h,s];s-h>i-e&&(e=h,i=s)}return[e,i]}$(ct,"rt");_(ct,"ge");S(ct,"c$1");ae(ct,"f");Lt(ct,"k");tt(ct,"findWideFastPathRange");const Fe=tt(t=>t<161||t>1114109?!1:yt(Zi,t),"isAmbiguous"),_e=tt(t=>t<Xi||t>Qi?!1:yt(tr,t),"isFullWidth"),mr=tt(t=>t<er||t>ir?!1:yt(rr,t),"isHalfWidth"),gr=tt(t=>t<or||t>nr?!1:yt(sr,t),"isNarrow"),Je=tt(t=>t>=ur&&t<=fr?!0:t<ar||t>hr?!1:yt(Le,t),"isWide");function lt(t){return Fe(t)?"ambiguous":_e(t)?"fullwidth":mr(t)?"halfwidth":gr(t)?"narrow":Je(t)?"wide":"neutral"}$(lt,"ot");_(lt,"be");S(lt,"g$4");ae(lt,"S");Lt(lt,"getCategory");tt(lt,"getCategory");var pr=Object.defineProperty,Ft=S((t,e)=>pr(t,"name",{value:e,configurable:!0}),"i$4"),br=Object.defineProperty,_t=Ft((t,e)=>br(t,"name",{value:e,configurable:!0}),"a"),wr=Object.defineProperty,he=_t((t,e)=>wr(t,"name",{value:e,configurable:!0}),"e");function et(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}$(et,"U");_(et,"te");S(et,"s$2");Ft(et,"s");_t(et,"r");he(et,"validate");function it(t){return et(t),lt(t)}$(it,"Z");_(it,"ie");S(it,"r$4");Ft(it,"p");_t(it,"eastAsianWidthType");he(it,"eastAsianWidthType");function vt(t,{ambiguousAsWide:e=!1}={}){return et(t),_e(t)||Je(t)||e&&Fe(t)?2:1}$(vt,"yt");_(vt,"Oe");S(vt,"o$2");Ft(vt,"W");_t(vt,"eastAsianWidth");he(vt,"eastAsianWidth");var yr=Object.defineProperty,vr=S((t,e)=>yr(t,"name",{value:e,configurable:!0}),"p$3"),xr=Object.defineProperty,He=vr((t,e)=>xr(t,"name",{value:e,configurable:!0}),"e"),Br=Object.defineProperty,Wr=He((t,e)=>Br(t,"name",{value:e,configurable:!0}),"E");const Ge=String.raw,ve=Ge`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Rr=Wr(()=>new RegExp(Ge`\p{RI}{2}|(?)${ve}(?:\u200D${ve})*`,"gu"),"default");var Sr=Object.defineProperty,jr=He((t,e)=>Sr(t,"name",{value:e,configurable:!0}),"p");const dt=new Set(["\x1B",""]),Jt="\x07",Ve="[",ce="m",wt="]8;;",Ar=39,Cr=/[\u200B\uFEFF\u2060-\u2064]/g,Ir=new RegExp(`(?:\\${Ve}(?<code>\\d+)m|\\${wt}(?<uri>.*)${Jt})`),Or=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),Z=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,xe=/\u001B\[(\d+(?:;\d+)*)?m[^\u001B]*(?:\u001B\[(?:\d+(?:;\d+)*)?m|$)/g,Be=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)(.*?)\u001B\]8;;(?:\u0007|\u001B\\)/g,Bt=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,Ot=Rr();jr(t=>t.replace(Ot,""),"stripEmoji");var Mr=Object.defineProperty,Er=S((t,e)=>Mr(t,"name",{value:e,configurable:!0}),"E$1"),$r=Object.defineProperty,Tr=Er((t,e)=>$r(t,"name",{value:e,configurable:!0}),"A"),kr=Object.defineProperty,Ht=Tr((t,e)=>kr(t,"name",{value:e,configurable:!0}),"d");const We=new Map,Wt=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Mt=Ht(t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other","getCharType"),Nr=Ht((t,e)=>{const i=Math.floor(t/65536),o=t%65536;let h=We.get(i);if(h||(h=new Map,We.set(i,h)),h.has(o))return h.get(o);let s;if(Mt(t)==="latin")s=e.width.regular;else if(Mt(t)==="control")s=e.width.control;else if(Mt(t)==="wide")s=e.width.wide;else switch(it(t)){case"ambiguous":{s=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{s=e.width.fullWidth;break}case"wide":{s=e.width.wide;break}default:s=e.width.regular}return h.set(o,s),s},"getCachedCharWidth"),Pr=Ht(t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,"isCombiningCharacter"),ht=Ht((t,e={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const i={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?ht(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},o=Math.max(0,i.truncation.limit-i.truncation.ellipsisWidth),{length:h}=t,s=h>1e4;let r=0,a=0,n=h,c=!1;const d=t.includes("\x1B")||t.includes("");for(;r<h;){if(d&&(t[r]==="\x1B"||t[r]==="")){if(t.startsWith("\x1B]8;;",r)){const b="\x1B]8;;\x07",f=b.length,x=t.indexOf("\x07",r+5);if(x!==-1){const w=t.indexOf(b,x+1);if(w!==-1){const v=w+f,B=t.slice(x+1,w).replace(Z,""),W=ht(B,{ambiguousIsNarrow:i.width.ambiguousIsNarrow,ansiWidth:i.width.ansi,controlWidth:i.width.control,countAnsiEscapeCodes:!1,ellipsis:i.truncation.ellipsis,ellipsisWidth:i.truncation.ellipsisWidth,emojiWidth:i.width.emoji,fullWidth:i.width.fullWidth,halfWidth:i.width.halfWidth,limit:Math.max(0,o-a),regularWidth:i.width.regular,tabWidth:i.width.tab,wideWidth:i.width.wide}),j=W.width;if(W.truncated)c=!0,n=Math.min(n,r);else if(a+j>o&&(n=Math.min(n,r),c=!0,a+j>i.truncation.limit))break;if(a+=j,r=v,c&&a>=i.truncation.limit)break;continue}}}if(Z.lastIndex=r,Z.test(t)){const b=Z.lastIndex-r,f=i.truncation.countAnsiEscapeCodes?b:i.width.ansi;if(a+f>o&&(n=Math.min(n,r),a+f>i.truncation.limit)){c=!0;break}a+=f,r=Z.lastIndex;continue}}const p=t.codePointAt(r);if(p===8203||p===65279||p>=8288&&p<=8292){r+=1;continue}if(p===9){if(a+i.width.tab>o&&(n=Math.min(n,r),a+i.width.tab>i.truncation.limit)){c=!0;break}a+=i.width.tab,r+=1;continue}if(Wt.lastIndex=r,Wt.test(t)){const b=(Wt.lastIndex-r)*i.width.regular;if(a+b>o){const f=Math.floor((o-a)/i.width.regular);if(n=Math.min(n,r+f),a+b>i.truncation.limit){c=!0;break}}a+=b,r=Wt.lastIndex;continue}if((p<=31||p>=127&&p<=159)&&(Bt.lastIndex=r,Bt.test(t))){const b=(Bt.lastIndex-r)*i.width.control;if(a+b>o&&(n=Math.min(n,r+Math.floor((o-a)/i.width.control)),a+b>i.truncation.limit)){c=!0;break}a+=b,r=Bt.lastIndex;continue}if(Ot.lastIndex=r,Ot.test(t)){if(a+i.width.emoji>o&&(n=Math.min(n,r),a+i.width.emoji>i.truncation.limit)){c=!0;break}a+=i.width.emoji,r=Ot.lastIndex;continue}const m=t.codePointAt(r)??0;if(Pr(m)){r+=m>65535?2:1;continue}let g;if(s)g=Nr(m,i);else switch(Mt(m)){case"control":{g=i.width.control;break}case"latin":{g=i.width.regular;break}case"wide":{g=i.width.wide;break}case"zero":{g=0;break}default:switch(it(m)){case"ambiguous":{g=i.width.ambiguousIsNarrow?i.width.regular:i.width.wide;break}case"fullwidth":{g=i.width.fullWidth;break}case"wide":{g=i.width.wide;break}default:g=i.width.regular}}if(a+g>o&&(n=Math.min(n,r),a+g>i.truncation.limit)){c=!0;break}a+=g,r+=m>65535?2:1}let l=a,u=!1;return c&&i.truncation.limit>=i.truncation.ellipsisWidth&&(l=i.truncation.limit,u=!0),{ellipsed:u,index:c?n:h,truncated:c,width:l}},"getStringTruncatedWidth");var Lr=Object.defineProperty,Fr=S((t,e)=>Lr(t,"name",{value:e,configurable:!0}),"i$2"),_r=Object.defineProperty,Jr=Fr((t,e)=>_r(t,"name",{value:e,configurable:!0}),"e"),Hr=Object.defineProperty,Gr=Jr((t,e)=>Hr(t,"name",{value:e,configurable:!0}),"r");const M=Gr((t,e={})=>ht(t,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");var Vr=Object.defineProperty,De=S((t,e)=>Vr(t,"name",{value:e,configurable:!0}),"a$2"),Dr=Object.defineProperty,ze=De((t,e)=>Dr(t,"name",{value:e,configurable:!0}),"a"),zr=Object.defineProperty,Yr=ze((t,e)=>zr(t,"name",{value:e,configurable:!0}),"a");let qr=class{static{$(this,"Ii")}static{_(this,"Bi")}static{S(this,"u")}static{De(this,"n")}static{ze(this,"s")}static{Yr(this,"LRUCache")}capacity;cache;constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;const e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}has(t){return this.cache.has(t)}set(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const i=this.cache.keys().next().value;i!==void 0&&this.cache.delete(i)}this.cache.set(t,e)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}};var Ur=Object.defineProperty,Kr=S((t,e)=>Ur(t,"name",{value:e,configurable:!0}),"S$1"),Zr=Object.defineProperty,Xr=Kr((t,e)=>Zr(t,"name",{value:e,configurable:!0}),"w"),Qr=Object.defineProperty,ut=Xr((t,e)=>Qr(t,"name",{value:e,configurable:!0}),"y");const Re=new qr(100),to=new Intl.Segmenter("en",{granularity:"grapheme"}),eo=/^[\u0000-\u007F]*$/,io=new Set(["0","22","23","24","27","28","29","39","49"]),ro=new Set(["1","3","4","7","8","9"]),Se=new Map([["22","1"],["23","3"],["24","4"],["27","7"],["28","8"],["29","9"]]),Rt=ut(t=>t>="30"&&t<="37"||t>="90"&&t<="97"||t.startsWith("38;"),"isForegroundColor"),St=ut(t=>t>="40"&&t<="47"||t>="100"&&t<="107"||t.startsWith("48;"),"isBackgroundColor"),oo=[{close:"\x1B[22m",open:"\x1B[1m"},{close:"\x1B[23m",open:"\x1B[3m"},{close:"\x1B[24m",open:"\x1B[4m"},{close:"\x1B[27m",open:"\x1B[7m"},{close:"\x1B[28m",open:"\x1B[8m"},{close:"\x1B[29m",open:"\x1B[9m"}],je=ut((t,e)=>{let i=-1;for(const o of e){const h=t.indexOf(o);h!==-1&&(i===-1||h<i)&&(i=h)}return i},"findFirstPositionOfAny"),no=ut((t,e)=>{if(!t.includes("\x1B"))return[{after:"",before:"",content:t,visibleLength:M(t,e.width)}];const i=Re.get(t);if(i)return i;const o=[],h=[];let s=0,r;for(Z.lastIndex=0;(r=Z.exec(t))!==null;){const d=r[0];o.push(t.slice(s,r.index)),h.push(d),s=r.index+d.length}s<t.length&&o.push(t.slice(s));const a=[];for(const d of h){if(d==="\x1B[0m"||d==="\x1B]8;;\x07"){a.push(d);continue}if(d.startsWith("\x1B[")&&d.endsWith("m")){const l=d.slice(2,-1);if(io.has(l)){a.push(d);continue}}}const n=new Set,c=[];for(const[d,l]of o.entries()){if(d>0&&h[d-1]){const m=h[d-1];if(m==="\x1B[0m")n.clear();else if(m==="\x1B]8;;\x07"){for(const g of n)if(g.startsWith("\x1B]8;;")&&!g.endsWith("\x1B]8;;\x07")){n.delete(g);break}}else if(m.startsWith("\x1B[")&&m.endsWith("m")){const g=m.slice(2,-1);if(g==="39"){for(const b of n)if(b.startsWith("\x1B[")&&b.endsWith("m")){const f=b.slice(2,-1);if(Rt(f)){n.delete(b);break}}}else if(g==="49"){for(const b of n)if(b.startsWith("\x1B[")&&b.endsWith("m")){const f=b.slice(2,-1);if(St(f)){n.delete(b);break}}}else if(Se.has(g)){const b=Se.get(g);for(const f of n)if(f===`\x1B[${b}m`){n.delete(f);break}}else{if(Rt(g)){for(const b of n)if(b.startsWith("\x1B[")&&b.endsWith("m")){const f=b.slice(2,-1);if(Rt(f)){n.delete(b);break}}}else if(St(g)){for(const b of n)if(b.startsWith("\x1B[")&&b.endsWith("m")){const f=b.slice(2,-1);if(St(f)){n.delete(b);break}}}else if(ro.has(g)){const b=`\x1B[${g}m`;n.has(b)&&n.delete(b)}n.add(m)}}else if(m.startsWith("\x1B]8;;")&&!m.endsWith("\x1B]8;;\x07")){for(const g of n)if(g.startsWith("\x1B]8;;")&&!g.endsWith("\x1B]8;;\x07")){n.delete(g);break}n.add(m)}}if(l==="")continue;let u="";if(n.size>0)if(a.includes("\x1B[0m"))u="\x1B[0m";else{const m=[];let g=!1;for(const w of n)if(w.startsWith("\x1B]8;;")&&!w.endsWith("\x1B]8;;\x07")){g=!0;break}g&&a.includes("\x1B]8;;\x07")&&m.push("\x1B]8;;\x07");let b=!1,f=!1;for(const w of n)if(w.startsWith("\x1B[")&&w.endsWith("m")){const v=w.slice(2,-1);Rt(v)?b=!0:St(v)&&(f=!0)}if(b&&f){const w=je(t,["\x1B[3","\x1B[9","\x1B[38;"]),v=je(t,["\x1B[4","\x1B[10","\x1B[48;"]);w>=0&&v>=0?w>v?m.push("\x1B[39m","\x1B[49m"):m.push("\x1B[49m","\x1B[39m"):m.push("\x1B[39m","\x1B[49m")}else b&&m.push("\x1B[39m"),f&&m.push("\x1B[49m");b&&f&&t.includes("\x1B[39m")&&t.includes("\x1B[49m")&&(t.indexOf("\x1B[39m")<t.indexOf("\x1B[49m")?(m.length-=2,m.push("\x1B[39m","\x1B[49m")):t.indexOf("\x1B[49m")<t.indexOf("\x1B[39m")&&(m.length-=2,m.push("\x1B[49m","\x1B[39m")));const x=oo.filter(w=>n.has(w.open)).map(w=>({position:t.indexOf(w.open),style:w})).filter(w=>w.position>=0).toSorted((w,v)=>v.position-w.position);for(const w of x){const v=w;a.includes(v.style.close)&&m.push(v.style.close)}u=m.join("")}const p=[...n].join("");c.push({after:u,before:p,content:l,visibleLength:M(l,{fullWidth:1,wideWidth:1})})}return Re.set(t,c),c},"processIntoStyledSegments"),so=ut((t,e,i,o)=>{const h=[...o.segmenter.segment(t)],s=[];let r=0,a=!1;for(const n of h){const c=M(n.segment,o.width),d=r,l=r+c;if(!a)if(d<e){r=l;continue}else a=!0;if(d>=i||l>i)break;s.push(n.segment),r=l}return s.join("")},"fastSlice"),D=ut((t,e=0,i=Number.MAX_SAFE_INTEGER,o={})=>{const h={segmenter:to,...o};if(e>=i||t==="")return"";const s=M(t,h.width);if(e===0&&i>=s)return t;if(e<0||i<0)throw new RangeError("Negative indices aren't supported");if(!t.includes("\x1B"))return eo.test(t)?t.slice(e,i):so(t,e,i,h);if(xe.lastIndex=0,Be.lastIndex=0,!xe.test(t)&&!Be.test(t))return t;const r=no(t,h);if(r.length===0)return"";let a=0;const n=[];for(const[l,u]of r.entries()){const p=a,m=a+u.visibleLength;if(m>e&&p<i){const g=Math.max(0,e-p),b=Math.min(u.visibleLength,i-p);n.push({end:b,index:l,segment:u,start:g})}a=m}if(n.length===0)return"";const c=[],d=n[0].segment;c.push(d.before);for(let l=0;l<n.length;l++){const{end:u,segment:p,start:m}=n[l];if(m===0&&u===p.visibleLength)c.push(p.content);else{const g=[...h.segmenter.segment(p.content)];c.push(g.slice(m,u).map(b=>b.segment).join(""))}if(l<n.length-1){const g=n[l+1].segment,b=p.after,f=g.before;b!==f&&(b||f)&&c.push(b,f)}}return c.push(n.at(-1).segment.after),c.join("")},"slice");var ao=Object.defineProperty,ho=S((t,e)=>ao(t,"name",{value:e,configurable:!0}),"x$1"),co=Object.defineProperty,lo=ho((t,e)=>co(t,"name",{value:e,configurable:!0}),"T"),uo=Object.defineProperty,Gt=lo((t,e)=>uo(t,"name",{value:e,configurable:!0}),"f");const Ae="…",fo=3,jt=Gt((t,e,i=!1)=>{if(t.charAt(e)===" ")return e;const o=i?1:-1,h=Math.min(fo,i?t.length-e:e);for(let s=1;s<=h;s++){const r=e+s*o;if(t.charAt(r)===" ")return r}return e},"findNearestSpace"),At=Gt((t,e,i)=>ht(t,{...i,ellipsis:"",ellipsisWidth:0,limit:e}).index,"widthToIndex"),Ct=Gt((t,e,i)=>M(t.slice(0,e),i),"indexToWidth"),Ce=Gt((t,e,i={})=>{if(typeof t!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof t}`);if(typeof e!="number")throw new TypeError(`Expected \`limit\` to be a number, got ${typeof e}`);if(t===""||e<=0)return"";const o=t.normalize("NFC"),{ellipsis:h=Ae,position:s="end",preferTruncationOnSpace:r=!1}=i;let a=i.ellipsisWidth??(h===Ae?1:void 0);a??=ht(h,{...i.width,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width;const{width:n}=ht(o,{...i.width,ellipsis:h,ellipsisWidth:a});if(n<=e)return o;switch(s){case"end":{if(r){const c=e-a,d=At(o,c,i.width),l=jt(o,d),u=Ct(o,l,i.width);return D(o,0,u,{width:i.width})+h}return D(o,0,e-a,{width:i.width})+h}case"middle":{const c=Math.floor(e/2),d=Math.max(0,e-a),l=Math.min(c,d),u=Math.max(0,d-l);if(r){const p=At(o,l,i.width),m=jt(o,p),g=Ct(o,m,i.width),b=n-u,f=At(o,b,i.width),x=jt(o,f,!0),w=Ct(o,x,i.width);return D(o,0,g,{width:i.width})+h+D(o,w,n,{width:i.width}).trim()}return D(o,0,l,{width:i.width})+h+D(o,n-u,n,{width:i.width})}case"start":{if(r){const c=n-e+a,d=At(o,c,i.width),l=jt(o,d,!0),u=Ct(o,l,i.width);return h+D(o,u,n,{width:i.width}).trim()}return h+D(o,n-e+a,n,{width:i.width})}default:throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${s}'`)}},"truncate");var mo=Object.defineProperty,Ye=S((t,e)=>mo(t,"name",{value:e,configurable:!0}),"k"),go=Object.defineProperty,rt=Ye((t,e)=>go(t,"name",{value:e,configurable:!0}),"d"),po=Object.defineProperty,bo=rt((t,e)=>po(t,"name",{value:e,configurable:!0}),"a");const wo=/\x1B\[(\d+)m/;let qe=class{static{$(this,"he")}static{_(this,"lt")}static{S(this,"T")}static{Ye(this,"T")}static{rt(this,"d")}static{bo(this,"AnsiStateTracker")}activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const e=wo.exec(t);if(!e)return;const i=Number.parseInt(e[1],10);switch(i){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(i>=30&&i<=37||i>=90&&i<=97)this.activeForeground=t;else if(i>=40&&i<=47||i>=100&&i<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(i))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(i)){const o={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[i];o&&(this.activeFormatting=this.activeFormatting.filter(h=>!h.includes(o)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const e={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(i=>{const o=e[i];o&&t.push(o)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};var yo=Object.defineProperty,Ue=rt((t,e)=>yo(t,"name",{value:e,configurable:!0}),"o");const vo=Ue((t,e)=>{if(!dt.has(t[e]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const i=!0,o=t.slice(e+1,e+1+wt.length).join("")===wt;return{isInsideEscape:i,isInsideLinkEscape:o}},"checkEscapeSequence"),xo=Ue((t,e={})=>{const i=new qe;let o="",h=!1,s="",r="",a=!1;const n=[...t];for(let c=0;c<n.length;c++){const d=n[c];if(d&&dt.has(d)){if(o){const g=e.getWidth?.(o)??0,b={isEscapeSequence:!1,isGrapheme:!0,text:o,width:g};if(a&&(b.isHyperlink=!0,b.hyperlinkUrl=r),e.onSegment?.(b,i)===!1)return;o=""}h=!0,s=d;const p=vo(n,c),{isInsideLinkEscape:m}=p;if(m){let g=c+1;for(r="";g<n.length;){const f=n[g];if(f===Jt)break;r+=f,g+=1}r=r.slice(4);const b={hyperlinkUrl:r,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(e.onSegment?.(b,i)===!1)return;c=g,a=!0,h=!1,s="";continue}if(c+1<n.length&&n[c+1]==="\\"&&a){const g={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(e.onSegment?.(g,i)===!1)return;a=!1,r="",c+=1,h=!1,s="";continue}}if(h){if(s!==d&&(s+=d),d===ce){h=!1,i.processEscape(s);const p={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};if(e.onSegment?.(p,i)===!1)return;s=""}continue}o+=d;const l=e.getWidth?.(o)??0,u={isEscapeSequence:!1,isGrapheme:!0,text:o,width:l};if(a&&(u.isHyperlink=!0,u.hyperlinkUrl=r),e.onSegment?.(u,i)===!1)return;o=""}if(o){const c=e.getWidth?.(o)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:o,width:c};a&&(d.isHyperlink=!0,d.hyperlinkUrl=r),e.onSegment?.(d,i)}if(s){const c={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};e.onSegment?.(c,i)}},"processAnsiString");var Bo=Object.defineProperty,Wo=rt((t,e)=>Bo(t,"name",{value:e,configurable:!0}),"t$1");const Ie=Wo(t=>`${dt.values().next().value}${Ve}${String(t)}${ce}`,"wrapAnsiCode");var Ro=Object.defineProperty,So=rt((t,e)=>Ro(t,"name",{value:e,configurable:!0}),"s");const Oe=So(t=>`${dt.values().next().value}${wt}${t}${Jt}`,"wrapAnsiHyperlink");var jo=Object.defineProperty,Ao=rt((t,e)=>jo(t,"name",{value:e,configurable:!0}),"l");const Co=Ao(t=>{if(t.length===0)return"";if(t.length===1)return t[0];let e="",i,o;const h=t.join(`
|
|
3
|
+
`),s=[...h];let r=0;for(const[a,n]of s.entries()){if(e+=n,dt.has(n)){const d=Ir.exec(h.slice(r))?.groups??{};if(d.code!==void 0){const l=Number.parseFloat(d.code);i=l===Ar?void 0:l}else d.uri!==void 0&&(o=d.uri.length===0?void 0:d.uri)}const c=Or.get(Number(i));s[a+1]===`
|
|
4
|
+
`?(o&&(e+=Oe("")),i&&c&&(e+=Ie(c))):n===`
|
|
5
|
+
`&&(i&&c&&(e+=Ie(i)),o&&(e+=Oe(o))),r+=n.length}return e},"preserveAnsi");var Io=Object.defineProperty,Y=rt((t,e)=>Io(t,"name",{value:e,configurable:!0}),"h");const Ke=/(?=\s)|(?<=\s)/,Ze=/^\s+$/,qt=Y(t=>{if(!t.includes("\x1B"))return t;let e=t;return t.includes("\x1B[30m")&&(e+="\x1B[39m"),t.includes("\x1B[42m")&&(e+="\x1B[49m"),e},"resetAnsiAtLineBreak"),Q=Y(t=>{const e=t.split(" ");let i=e.length;for(;i>0&&M(e[i-1])===0;)i--;return i===e.length?t:e.slice(0,i).join(" ")+e.slice(i).join("")},"stringVisibleTrimSpacesRight"),Xe=Y((t,e,i)=>{if(t.length===0)return[""];if(e<=0)return[t];const o=[],h=new qe;let s="",r=0,a=!1,n=!1,c="",d=0;for(;d<t.length;){const l=t[d];if(dt.has(l)){a=!0,c=l,s+=l,n=t.startsWith(wt,d+1),d+=1;continue}if(a){c+=l,s+=l,n?l===Jt&&(a=n=!1):l===ce&&(a=!1,h.processEscape(c)),d+=1;continue}const u=M(l),p=l===" ";if(u===0){s+=l,d+=1;continue}if(r+u>e&&(s&&o.push(s+h.getEndEscapesForAllActiveAttributes()),s=h.getStartEscapesForAllActiveAttributes(),r=M(s),p&&i)){for(;d<t.length&&t[d]===" ";)d+=1;continue}if(s+=l,r+=u,r===e&&d<t.length-1&&(o.push(s+h.getEndEscapesForAllActiveAttributes()),s=h.getStartEscapesForAllActiveAttributes(),r=M(s),d+1<t.length&&t[d+1]===" "&&i)){for(d+=1;d<t.length&&t[d]===" ";)d+=1;continue}d+=1}return s&&o.push(s+h.getEndEscapesForAllActiveAttributes()),i?o.map(l=>Q(l)):o},"wrapWithBreakAtWidth"),Oo=Y((t,e,i)=>{if(t.length===0)return[];const o=i?t.trim():t;if(o.length===0)return[];const h=[];let s="",r=0;return xo(o,{getWidth:M,onSegment:Y((a,n)=>{const c=a.text??"";if(a.isEscapeSequence)s+=c;else{const d=c===" ";if(a.width===0)return s+=c,!0;if(r+a.width>e&&(s&&h.push(s),s=n.getStartEscapesForAllActiveAttributes(),r=0,d))return i||h.push(n.getStartEscapesForAllActiveAttributes()+c),!0;s+=c,r+=a.width}return!0},"onSegment")}),s&&h.push(s),i?h.map(a=>Q(a)):h},"wrapCharByChar"),Mo=Y((t,e,i)=>{if(t.length===0)return[];const o=i?t.trim():t;if(o.length===0)return[];const h=o.split(Ke),s=[];let r="",a=0,n=0;for(;n<h.length;){const c=h[n],d=Ze.test(c),l=M(c);if(c.length===0){n+=1;continue}if(i&&d&&a===0){n+=1;continue}if(a+l>e&&a>0){i?s.push(Q(r)):s.push(r),r="",a=0;continue}r+=c,a+=l,n+=1}return r&&(i?s.push(Q(r)):s.push(r)),s},"wrapWithWordBoundaries"),Eo=Y((t,e,i)=>{if(t.length===0)return[];const o=i?t.trim():t;if(o.length===0)return[];const h=o.split(Ke),s=[];let r="",a=0,n=0;for(;n<h.length;){const c=h[n],d=Ze.test(c),l=M(c);if(c.length===0){n+=1;continue}if(i&&d&&a===0){n+=1;continue}if(l>e){r&&s.push(qt(i?Q(r):r));const u=Xe(c,e,i);if(u.length>0){for(let p=0;p<u.length-1;p+=1)s.push(u[p]);r=u.at(-1),a=M(r)}else r="",a=0;n+=1;continue}if(a+l>e&&a>0&&(s.push(qt(i?Q(r):r)),r="",a=0,i&&d)){n+=1;continue}r+=c,a+=l,n+=1}return r&&s.push(qt(i?Q(r):r)),s},"wrapAndBreakWords"),It={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},$o=Y((t,e={})=>{const{removeZeroWidthCharacters:i=!0,trim:o=!0,width:h=80,wrapMode:s=It.PRESERVE_WORDS}=e;if(o&&t.trim()==="")return"";let r=t.normalize("NFC").replaceAll(`\r
|
|
6
|
+
`,`
|
|
7
|
+
`);return i&&(r=r.replaceAll(Cr,"")),r.split(`
|
|
8
|
+
`).map(a=>{if(o&&a.trim()==="")return"";let n;switch(s){case It.BREAK_AT_CHARACTERS:{n=Oo(a,h,o);break}case It.BREAK_WORDS:{n=Eo(a,h,o);break}case It.STRICT_WIDTH:{n=Xe(a,h,o);break}default:n=Mo(a,h,o)}return Co(n)}).join(`
|
|
9
|
+
`)},"wordWrap");var To=Object.defineProperty,K=S((t,e)=>To(t,"name",{value:e,configurable:!0}),"n$3");const Qe=80,ti=24,ie=K((t,e,{shell:i,env:o}={})=>Yi(t,e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:i,env:o}).trim(),"exec"),Et=K((t,e)=>({columns:Number.parseInt(t,10),rows:Number.parseInt(e,10)}),"create"),ei=K((t,e)=>{const{columns:i,rows:o}=Et(t,e);if(!(Number.isNaN(i)||Number.isNaN(o))&&!(i===Qe&&o===ti))return{columns:i,rows:o}},"createIfNotDefault"),ko=K(()=>{if(X.platform!=="linux")return!0;try{const t=pt.readFileSync("/proc/self/stat","utf8"),e=t.lastIndexOf(") ");if(e===-1)return!1;const i=t.slice(e+2).trim().split(/\s+/),o=Number.parseInt(i[2],10),h=Number.parseInt(i[5],10);return Number.isNaN(o)||Number.isNaN(h)||h<=0?!1:o===h}catch{return!1}},"isForegroundProcess");function Vt(){const{env:t,stdout:e,stderr:i}=X;if(e?.columns&&e?.rows)return Et(e.columns,e.rows);if(i?.columns&&i?.rows)return Et(i.columns,i.rows);if(t.COLUMNS&&t.LINES)return Et(t.COLUMNS,t.LINES);const o={columns:Qe,rows:ti};return X.platform==="win32"?Ut()??o:X.platform==="darwin"?Me()??Ut()??o:Me()??Ut()??No()??o}$(Vt,"Tt");_(Vt,"gt");S(Vt,"O");K(Vt,"terminalSize");const Me=K(()=>{try{const t=X.platform==="darwin"?pt.constants.O_EVTONLY|pt.constants.O_NONBLOCK:pt.constants.O_NONBLOCK,{columns:e,rows:i}=qi.WriteStream(pt.openSync("/dev/tty",t));return{columns:e,rows:i}}catch{}},"devTty"),Ut=K(()=>{try{const t=ie("tput",["cols"],{env:{TERM:"dumb",...X.env}}),e=ie("tput",["lines"],{env:{TERM:"dumb",...X.env}});if(t&&e)return ei(t,e)}catch{}},"tput"),No=K(()=>{try{if(!ko())return;const t=ie("resize",["-u"]).match(/\d+/g);if(t.length===2)return ei(t[0],t[1])}catch{}},"resize");var Po=Object.defineProperty,ii=S((t,e)=>Po(t,"name",{value:e,configurable:!0}),"e");const nt=ii((t,e)=>{switch(e){case"bottom":return{body:t.bottomBody,join:t.bottomJoin,left:t.bottomLeft,right:t.bottomRight};case"middle":return{body:t.joinBody,join:t.joinJoin,left:t.joinLeft,right:t.joinRight};case"top":return{body:t.topBody,join:t.topJoin,left:t.topLeft,right:t.topRight};default:throw new Error(`Invalid borderType: ${String(e)}`)}},"getHorizontalBorderChars"),Lo=ii(t=>({join:t.bodyJoin,left:t.bodyLeft,right:t.bodyRight}),"getVerticalBorderChars");var Fo=Object.defineProperty,_o=S((t,e)=>Fo(t,"name",{value:e,configurable:!0}),"n$1");const Nt=_o((t,e,i)=>{let o=0;for(let h=0;h<i;h+=1)o+=t[e+h]??0;return i>1&&(o+=i-1),o},"calculateCellTotalWidth");var Jo=Object.defineProperty,Ho=S((t,e)=>Jo(t,"name",{value:e,configurable:!0}),"a");const re=Ho((t,e,i,o)=>{let h=e;for(;h>0&&t[h-1]?.[i]===o;)h-=1;let s=e;for(;s<t.length-1&&t[s+1]?.[i]===o;)s+=1;let r;const a=s-h+1;if(a===1)r=!0;else switch(o.vAlign){case"bottom":{r=e===s;break}case"middle":{const n=h+Math.floor(a/2);r=e===n;break}case"top":{r=e===h;break}default:r=e===h}return{firstRow:h,lastRow:s,showContent:r}},"determineCellVerticalPosition");var Go=Object.defineProperty,Vo=S((t,e)=>Go(t,"name",{value:e,configurable:!0}),"F");const Do=Vo((t,e,i,o,h)=>{if(t.length===0)return[];let s=t.length-1;for(let n=0;n<t.length;n+=1){const c=t[n];if(c){for(const[d,l]of c.entries())if(l&&h(t,n,d,l)===n){const u=re(t,n,d,l);s=Math.max(s,u.lastRow)}}}const r=Array.from({length:s+1}).fill(1);for(let n=0;n<t.length;n+=1){const c=t[n];if(c)for(let d=0;d<i.columns;d+=1){const l=c[d];if(l&&h(t,n,d,l)===n&&(l.rowSpan??1)===1){const u=l.colSpan??1,p=Nt(e,d,u),m=o(l,p).length;r[n]=Math.max(r[n]??1,m)}}}const a=Array.from({length:r.length}).fill(!1);if(i.fixedRowHeights)for(let n=0;n<r.length;n+=1){let c;i.fixedRowHeights[n]!==void 0?c=i.fixedRowHeights[n]:i.fixedRowHeights.length===1&&i.fixedRowHeights[0]!==void 0&&(c=i.fixedRowHeights[0]),c!==void 0&&(r[n]=Math.max(1,c),a[n]=!0)}for(let n=0;n<t.length;n+=1){const c=t[n];if(c)for(let d=0;d<i.columns;d+=1){const l=c[d];if(l&&h(t,n,d,l)===n&&(l.rowSpan??1)>1){const u=l.colSpan??1,p=Nt(e,d,u),m=o(l,p).length-1,g=re(t,n,d,l),{firstRow:b,lastRow:f}=g;let x=0,w=0;for(let B=b;B<=f&&B<r.length;B+=1)x+=r[B]??1,a[B]||(w+=1);const v=m-x;if(v>0)if(w>0){const B=Math.ceil(v/w);let W=0;for(let j=b;j<=f&&j<r.length;j+=1)if(!a[j]){const A=Math.min(B,v-W);if(r[j]=(r[j]??1)+A,W+=A,W>=v)break}}else console.warn(`[calculateRowHeights] Content of spanning cell exceeds fixed height allocated. Cell: ${JSON.stringify(l.content)}, Required: ${String(m)}, Allocated: ${String(x)} (fixed).`)}}}return r},"calculateRowHeights");var zo=Object.defineProperty,Yo=S((t,e)=>zo(t,"name",{value:e,configurable:!0}),"i");const st=Yo((t,e,i,o)=>{let h=e;for(;h>0&&t[h-1]?.[i]===o;)h-=1;return h},"findFirstOccurrenceRow");var qo=Object.defineProperty,Uo=S((t,e)=>qo(t,"name",{value:e,configurable:!0}),"n");const oe="__EMPTY__",Ee=Uo(t=>{if(typeof t=="string")return{content:t};if(typeof t=="number"||typeof t=="bigint"||typeof t=="boolean")return{content:String(t)};if(t==null)return{content:oe};if(typeof t=="object"&&"content"in t){let{content:e}=t;if(typeof e=="number"||typeof e=="bigint"||typeof e=="boolean")e=String(e);else if(e==null)e=oe;else if(typeof e!="string")throw new TypeError(`Invalid item type in grid cell: expected string, number, null, undefined, or GridItem object, but received ${JSON.stringify(t)} (type: ${typeof t})`);return{...t,content:e}}throw new TypeError(`Invalid item type in grid cell: expected string, number, null, undefined, or GridItem object, but received ${JSON.stringify(t)} (type: ${typeof t})`)},"normalizeGridCell");var Ko=Object.defineProperty,Zo=S((t,e)=>Ko(t,"name",{value:e,configurable:!0}),"p");const Xo=Zo((t,e,i,o,h)=>{const s=M(t),r=" ".repeat(Math.max(0,o)),a=" ".repeat(Math.max(0,h));if(s===0)return r+" ".repeat(Math.max(0,e))+a;const n=Math.max(0,e-s);switch(i){case"center":{const c=Math.floor(n/2),d=n-c;return r+" ".repeat(c)+t+" ".repeat(d)+a}case"right":return r+" ".repeat(n)+t+a;default:return r+t+" ".repeat(n)+a}},"padAndAlignContent");var Qo=Object.defineProperty,le=S((t,e)=>Qo(t,"name",{value:e,configurable:!0}),"H");const gt=/\r?\n/,$e=/\s+/,R=le((t,e)=>!t||!e?t:typeof e=="function"?e(t):e.open+t+e.close,"applyColor");class Dt{static{$(this,"Ct")}static{_(this,"Fe")}static{S(this,"Grid")}static{le(this,"Grid")}#t;#o=[];#e;#n=new WeakMap;#i=new WeakMap;static createGridLayout(){return[]}constructor(e){const i={autoColumns:1,autoFlow:"row",autoRows:1,balancedWidths:!1,gap:0,paddingLeft:1,paddingRight:1,rows:0,showBorders:e.border!==void 0,truncate:!1,truncateOverflow:!0,wordWrap:!1};let o;Array.isArray(e.fixedRowHeights)?o=e.fixedRowHeights:typeof e.fixedRowHeights=="number"&&(o=[e.fixedRowHeights]),this.#t={...i,...e,columns:e.columns,fixedRowHeights:o,showBorders:e.border!==void 0||(e.showBorders??!1)};let{terminalWidth:h}=this.#t;if(h===void 0){const{columns:s}=Vt();h=s}this.#e=h,this.#t.maxWidth&&(this.#t.maxWidth=Math.min(this.#t.maxWidth,this.#e))}addItem(e){return this.#o.push(Ee(e)),this}addItems(e){return this.#o.push(...e.map(i=>Ee(i))),this}setColumns(e){return this.#t.columns=e,this}setRows(e){return this.#t.rows=e,this}setBorder(e){return this.#t.border=e,this}setShowBorders(e){return this.#t.showBorders=e,this}setMaxWidth(e){return this.#t.maxWidth=e,this}toString(){const e=Dt.createGridLayout();if(this.#n=new WeakMap,this.#i=new WeakMap,this.placeItems(e),e.length===0||e[0]?.length===0)return"";let i=this.calculateColumnWidths(e);const o=this.calculateTotalGridWidth(i),h=typeof this.#t.maxWidth=="number"&&this.#t.maxWidth>0?Math.min(this.#t.maxWidth,this.#e):this.#e;return o>h&&(i=this.adjustColumnWidthsForTerminal(i,o)),this.renderGrid(e,i)}placeItems(e){let i=0,o=0;const h=this.#t.rows>0?this.#t.rows:Number.POSITIVE_INFINITY;for(let s=0;s<this.#o.length;s+=1){const r=this.#o[s];if(r.content===oe&&!(r.rowSpan&&r.rowSpan>1)&&!(r.colSpan&&r.colSpan>1)){if(this.#t.autoFlow==="row")o+=1,o>=this.#t.columns&&(o=0,i+=1);else{i+=1;const m=e.length>0?e.length:h;i>=m&&m!==Number.POSITIVE_INFINITY?(i=0,o+=1):e.length===0&&m===Number.POSITIVE_INFINITY&&(o+=1)}continue}const a=r.colSpan??1,n=r.rowSpan??1;let c=!1,d=i,l=o,u=0;const p=(e.length+n+5)*this.#t.columns;for(;!c&&d<h&&u<p;){for(u+=1;d+n>e.length;)e.push(Array.from({length:this.#t.columns}).fill(void 0));if(this.canPlaceItem(e,d,l,a,n))if(this.placeItem(e,d,l,r),c=!0,this.#t.autoFlow==="row")o=l+a,i=d,o>=this.#t.columns&&(o=0,i+=1);else{i=d+n,o=l;const m=e.length>0?e.length:h;i>=m&&(i=0,o+=1)}else if(this.#t.autoFlow==="row")l+=1,l>=this.#t.columns&&(l=0,d+=1);else{for(d+=1;d+n>e.length;)e.push(Array.from({length:this.#t.columns}).fill(void 0));const m=e.length>0?e.length:h;if(d>=m&&(d=0,l+=1,l>=this.#t.columns))break}}if(!c)if(console.warn(`@visulima/tabular: Could not find position for item: ${JSON.stringify(r)} after ${String(u)} attempts. Grid might be too small or layout impossible.`),this.#t.autoFlow==="row")o+=1,o>=this.#t.columns&&(o=0,i+=1);else{i+=1;const m=e.length>0?e.length:h;i>=m&&(i=0,o+=1)}if(u>=p)break}if(this.#t.rows===0)for(;e.length>0&&e.at(-1)?.every(s=>s===void 0);)e.pop()}canPlaceItem(e,i,o,h,s,r=!1){if(o+h>this.#t.columns)return!1;for(let a=i;a<i+s;a+=1)if(a<e.length){if(!e[a])return console.warn(`Grid layout unexpectedly missing row ${String(a)} during canPlaceItem check.`),!1;for(let n=o;n<o+h;n+=1)if(e[a]?.[n]!==void 0)return!1}else if(!r)return!1;return!0}computeWrappedContentWidth(e,i,o,h){let s=e;if(h){if(s>20){let r=0;for(const a of i){const n=a.split($e);for(const c of n)r=Math.max(r,Math.min(M(c),o))}s=Math.min(s,Math.max(r+4,12))}}else{let r=0;for(const a of i){const n=a.split($e);for(const c of n)r=Math.max(r,Math.min(M(c),o))}s=Math.min(s,Math.max(r+12,20))}return s}placeItem(e,i,o,h){const s=h.rowSpan??1,r=h.colSpan??1;for(let a=i;a<i+s;a+=1){for(;a>=e.length;)e.push(Array.from({length:this.#t.columns}).fill(void 0));for(let n=o;n<o+r;n+=1)n<this.#t.columns&&(e[a]||(console.error(`Logic error: Row ${String(a)} not found in placeItem despite check.`),e[a]=Array.from({length:this.#t.columns}).fill(void 0)),e[a][n]=h)}}calculateTotalGridWidth(e){let i=0;const o=this.#t.showBorders?this.#t.border:void 0;o&&(i+=o.bodyLeft.width,i+=o.bodyRight.width);const h=e.length,s=this.#t.showBorders?o?.bodyJoin.width??0:0,r=this.#t.gap;for(let a=0;a<h;a+=1)i+=e[a]??0,a<h-1&&(i+=r,i+=s);return i}adjustColumnWidthsForTerminal(e,i){const o=typeof this.#t.maxWidth=="number"&&this.#t.maxWidth>0?Math.min(this.#t.maxWidth??0,this.#e):this.#e;if(i<=o)return e;let h=0;const s=e.length,r=this.#t.showBorders?this.#t.border:void 0;if(r&&(h+=r.bodyLeft.width,h+=r.bodyRight.width),s>1){h+=(s-1)*this.#t.gap;const u=r?.bodyJoin.width??0;h+=(s-1)*u}if(h>=o)return Array.from({length:s}).fill(1);const a=o-h,n=e.reduce((u,p)=>u+p,0);if(n===0){const u=Math.floor(a/s);return Array.from({length:s}).fill(u)}const c=e.map(u=>{const p=u/n;return Math.max(1,Math.floor(a*p))});let d=c.reduce((u,p)=>u+p,0)-a;for(;d>0;){let u=-1;for(let p=0;p<c.length;p+=1)(c[p]??0)>1&&(u===-1||(c[p]??0)>(c[u]??0))&&(u=p);if(u===-1)break;c[u]-=1,d-=1}let l=a-c.reduce((u,p)=>u+p,0);if(l>0){const u=c.map((p,m)=>{const g=n>0?(e[m]??0)/n:1/s;return{index:m,remainder:a*g%1}}).toSorted((p,m)=>m.remainder-p.remainder);for(const p of u){if(l<=0)break;const{index:m}=p;c[m]!==void 0&&(c[m]+=1,l-=1)}}return c}calculateBalancedColumnWidths(e){const i=this.calculateMinimumColumnWidthsWithGrowableInfo(e),o=i.widths,{growableColumns:h}=i,s=typeof this.#t.maxWidth=="number"&&this.#t.maxWidth>0?Math.min(this.#t.maxWidth,this.#e):this.#e,r=this.#t.showBorders?this.#t.border:void 0;let a=0;if(r&&(a+=r.bodyLeft.width,a+=r.bodyRight.width),this.#t.columns>1){a+=(this.#t.columns-1)*this.#t.gap;const d=r?.bodyJoin.width??0;a+=(this.#t.columns-1)*d}const n=Math.max(0,s-a);if(o.reduce((d,l)=>d+l,0)>0){const d=Math.floor(n/this.#t.columns),l=Array.from({length:this.#t.columns}).fill(d),u=d*this.#t.columns;let p=n-u;for(let f=0;f<l.length&&p>0;f+=1)l[f]=(l[f]??0)+1,p-=1;const m=[];let g=0;for(let f=0;f<this.#t.columns;f+=1){const x=l[f]??0,w=o[f]??0,v=Math.max(x,w);m.push(v),g+=v}if(g>n){const f=n/g,x=m.map(B=>Math.max(3,Math.floor(B*f))),w=x.reduce((B,W)=>B+W,0);let v=n-w;for(let B=0;B<x.length&&v>0;B+=1)x[B]=(x[B]??0)+1,v-=1;return x}let b=n-g;if(b>0){const f=h.length>0?h:m.map((x,w)=>w);for(;b>0&&f.length>0;)for(const x of f){if(b<=0)break;m[x]=(m[x]??0)+1,b-=1}}return m}const c=Math.floor(n/this.#t.columns);return Array.from({length:this.#t.columns}).fill(c)}calculateMinimumColumnWidthsWithGrowableInfo(e){const i=Array.from({length:this.#t.columns}).fill(0),o=[],h=this.#t.paddingLeft+this.#t.paddingRight,s=this.#t.gap+(this.#t.showBorders?this.#t.border?.bodyJoin.width??0:0);for(let r=0;r<this.#t.columns;r+=1)for(let a=0;a<e.length;a+=1){const n=e[a]?.[r];if(!n||st(e,a,r,n)!==a||r>0&&e[a]?.[r-1]===n)continue;const c=n.colSpan??1,d=n.maxWidth??Number.POSITIVE_INFINITY,l=String(n.content??"").split(gt),u=this.#t.wordWrap&&n.wordWrap!==!1;let p=0;for(const m of l)p=Math.max(p,Math.min(M(m),d));p=this.computeWrappedContentWidth(p,l,d,u),c===1&&(i[r]=Math.max(i[r]??0,p+h),u&&!o.includes(r)&&o.push(r))}for(let r=0;r<e.length;r+=1)for(let a=0;a<this.#t.columns;a+=1){const n=e[r]?.[a];if(!n||st(e,r,a,n)!==r||a>0&&e[r]?.[a-1]===n)continue;const c=n.colSpan??1;if(c>1){const d=n.maxWidth??Number.POSITIVE_INFINITY,l=String(n.content??"").split(gt),u=this.#t.wordWrap&&n.wordWrap!==!1;let p=0;for(const f of l)p=Math.max(p,Math.min(M(f),d));p=this.computeWrappedContentWidth(p,l,d,u);const m=(c-1)*s,g=p+h+m;let b=0;for(let f=a;f<a+c;f+=1)b+=i[f]??0;if(g>b){const f=g-b,x=Math.ceil(f/c);for(let w=0;w<c&&a+w<this.#t.columns;w+=1)i[a+w]=Math.max(i[a+w]??0,x)}}}return{growableColumns:o,widths:i}}calculateColumnWidths(e){if(this.#t.fixedColumnWidths&&this.#t.fixedColumnWidths.length===this.#t.columns){const s=this.#t.fixedColumnWidths;if(!s.some(r=>r===void 0||!Number.isFinite(r)))return[...s];if(this.#t.balancedWidths){const r=Array.from({length:s.length}).fill(0),a=typeof this.#t.maxWidth=="number"&&this.#t.maxWidth>0?Math.min(this.#t.maxWidth,this.#e):this.#e,n=this.calculateTotalGridWidth(Array.from({length:r.length}).fill(0)),c=Math.max(0,a-n);let d=0;const l=[];for(const[m,g]of s.entries())typeof g=="number"&&Number.isFinite(g)?(r[m]=g,d+=g):l.push(m);let u=Math.max(0,c-d);const p=l.length>0?Math.floor(u/l.length):0;for(const m of l)r[m]=p;u-=p*l.length;for(const m of l){if(u<=0)break;r[m]+=1,u-=1}return r}}if(this.#t.balancedWidths)return this.calculateBalancedColumnWidths(e);const i=Array.from({length:this.#t.columns}).fill(0),o=this.#t.paddingLeft+this.#t.paddingRight,h=this.#t.gap+(this.#t.showBorders?this.#t.border?.bodyJoin.width??0:0);for(let s=0;s<this.#t.columns;s+=1)for(let r=0;r<e.length;r+=1){const a=e[r]?.[s];if(!a||st(e,r,s,a)!==r||s>0&&e[r]?.[s-1]===a)continue;const n=a.colSpan??1,c=a.maxWidth??Number.POSITIVE_INFINITY,d=String(a.content??"").split(gt);let l=0;for(const u of d)l=Math.max(l,Math.min(M(u),c));n===1&&(i[s]=Math.max(i[s]??0,l+o))}for(let s=0;s<e.length;s+=1)for(let r=0;r<this.#t.columns;r+=1){const a=e[s]?.[r];if(!a||st(e,s,r,a)!==s||r>0&&e[s]?.[r-1]===a)continue;const n=a.colSpan??1;if(n>1){const c=a.maxWidth??Number.POSITIVE_INFINITY,d=String(a.content??"").split(gt),l=this.#t.wordWrap&&a.wordWrap!==!1;let u=0;for(const f of d)u=Math.max(u,Math.min(M(f),c));u=this.computeWrappedContentWidth(u,d,c,l);let p=0;for(let f=r;f<r+n;f+=1)p+=i[f]??0;const m=n>1?(n-1)*h:0,g=u+o+m,b=p+m;if(g>b){const f=g-b,x=Math.floor(f/n);let w=0;for(let v=0;v<n&&r+v<this.#t.columns;v+=1){const B=Math.min(x,f-w);if(i[r+v]=(i[r+v]??0)+B,w+=B,w>=f)break}}}}if(this.#t.maxWidth){const s=this.calculateTotalGridWidth(i);if(s>this.#t.maxWidth)return this.adjustColumnWidthsForTerminal(i,s)}return i}renderVisualRowContent(e,i,o,h,s){const r=e[i];if(!r)return"";const a=this.#t.borderColor??this.#t.foregroundColor??void 0,n=[],c=this.#t.showBorders&&this.#t.border?Lo(this.#t.border):void 0,d=c&&c.left.width>0?c.left.char:"",l=c&&c.right.width>0?c.right.char:"",u=c&&c.join.width>0?c.join.char:"",p=" ".repeat(this.#t.gap);d&&n.push(R(R(d,a),this.#t.backgroundColor));let m=0;for(;m<this.#t.columns;){const g=r[m]??void 0;let b=1,f;if(g){const x=g.colSpan??1;b=x;const w=st(e,i,m,g),v=Nt(h,m,x),B=this.alignCellContent(g,v),W=B.length,j=this.getCachedCellVerticalPosition(e,i,m,g);j.firstRow!==w&&console.warn(`Mismatch between findFirstOccurrenceRow (${String(w)}) and determineCellVerticalPosition (${String(j.firstRow)})`);const A=s.slice(w,j.lastRow+1).reduce((C,P)=>C+P,0),E=j.lastRow-j.firstRow+1;let k=o,N=0;for(let C=w;C<i;C+=1)C<s.length&&(k+=s[C]??1),C<j.lastRow&&(N+=1);k+=N;const J=g.vAlign??"top";let F;switch(J){case"bottom":{let C=o;for(let L=w;L<i;L+=1)C+=s[L]??1;const P=A-W;F=C>=P?C-P:-1;break}case"middle":{const C=Math.round((A-W)/2);let P=o;for(let L=w;L<i;L+=1)P+=s[L]??1;F=P>=C&&P<C+W?P-C:-1;break}case"top":{F=k;break}default:F=k}const zt=F>=0&&F<W;if(f=" ".repeat(Math.max(0,v)),zt){let C=!1;J==="middle"&&E%2===0&&F===0&&(C=!0),C||(f=B[F]??f)}g.colSpan&&g.colSpan>1&&(f+=p.repeat(g.colSpan)),g.foregroundColor?f=R(f,g.foregroundColor):this.#t.foregroundColor&&(f=R(f,this.#t.foregroundColor)),g.backgroundColor?f=R(f,g.backgroundColor):this.#t.backgroundColor&&(f=R(f,this.#t.backgroundColor))}else{const x=this.#t.paddingLeft+this.#t.paddingRight,w=Math.max(0,(h[m]??0)-x),v=" ".repeat(this.#t.paddingLeft+w+this.#t.paddingRight);f=R(R(o===0?v:" ".repeat(v.length),this.#t.foregroundColor),this.#t.backgroundColor)}n.push(f),m+b<this.#t.columns&&(n.push(p),this.#t.showBorders&&u&&n.push(R(R(u,a),this.#t.backgroundColor)),this.#t.gap>0&&n.push(p)),m+=b}return l&&n.push(R(R(l,a),this.#t.backgroundColor)),n.join("")}alignCellContent(e,i){const o=this.#n.get(e);if(o?.has(i))return o.get(i);const{paddingLeft:h,paddingRight:s}=this.#t,r=h+s,a=i-r;if(a<=0){const l=[" ".repeat(r+this.#t.gap)];return o?o.set(i,l):this.#n.set(e,new Map([[i,l]])),l}let n;const c=String(e.content??"");if(n=c.includes(`
|
|
10
|
+
`)||c.includes("\r")?c.split(gt):[c],this.#t.wordWrap&&e.wordWrap!==!1){const l=typeof this.#t.wordWrap=="object"?this.#t.wordWrap:{},u=typeof e.wordWrap=="object"?e.wordWrap:l;n=$o(c,{...u,width:a}).split(`
|
|
11
|
+
`)}if(this.#t.truncate&&e.truncate!==!1){const l=typeof this.#t.truncate=="object"?this.#t.truncate:{},u=typeof e.truncate=="object"?e.truncate:l;n=n.map(p=>Ce(p,a,u))}else this.#t.truncateOverflow&&(n=n.map(l=>M(l)>a?Ce(l,a,{}):l));const d=n.map(l=>Xo(l,a,e.hAlign??"left",h,s));return o?o.set(i,d):this.#n.set(e,new Map([[i,d]])),d}renderHorizontalBorder(e,i,o,h,s,r=-1){if(!this.#t.showBorders||!this.#t.border)return"";const a=this.#t.border,n=nt(a,s),c=n.body.char,d=n.body.width,l=a.bodyJoin.char;if(s!=="middle"&&d===0)return"";let u=n.left.char,p=n.right.char;if(s==="middle"&&r!==-1){const f=e[o]?.[0]??void 0,x=e[r]?.[0]??void 0;f&&x&&f===x&&(u=l);const w=this.#t.columns-1,v=e[o]?.[w]??void 0,B=e[r]?.[w]??void 0;v&&B&&v===B&&(p=l)}const m=[],g=" ".repeat(this.#t.gap);u&&m.push(R(R(u,this.#t.borderColor),this.#t.backgroundColor));let b;for(let f=0;f<this.#t.columns;f+=1){const x=e[o]?.[f]??void 0,w=s==="middle"&&r!==-1?e[r]?.[f]??void 0:void 0;let v,B=!1;if(x&&(f===0||e[o]?.[f-1]!==x)&&(v=x,B=!0),x&&!B)continue;if(!x){const A=h[f]??0;if(b=d>0?c.repeat(A):" ".repeat(A),m.push(R(R(b,this.#t.borderColor),this.#t.backgroundColor)),f<this.#t.columns-1){const E=this.determineJoinChar(s,e,o,r,f,f+1);m.push(g),E.width>0&&m.push(R(R(E.char,this.#t.borderColor),this.#t.backgroundColor))}continue}const W=v?.colSpan??1;if(s==="middle"&&s==="middle"&&w&&x===w&&v){const A=v.vAlign==="middle",{firstRow:E,lastRow:k}=this.getCachedCellVerticalPosition(e,o,f,v),N=k-E+1,J=N%2===0,F=E+Math.ceil(N/2)-1,zt=Nt(h,f,W),C=this.alignCellContent(v,zt),P=C.length;if(A&&J&&o===F)b=R(C[0]??"",this.#t.borderColor);else{let L=0;for(let ot=E;ot<=o;ot+=1)L+=i[ot]??1,ot<o&&(L+=1);const Yt=L;if(Yt>=0&&Yt<P)b=R(C[Yt]??"",this.#t.foregroundColor);else{const ot=h.slice(f,f+W).reduce((ni,si)=>ni+si,0)+(W-1)*(this.#t.gap+this.#t.border.bodyJoin.width);b=R(" ".repeat(ot),this.#t.borderColor)}}m.push(R(b,this.#t.backgroundColor))}else{const A=[];for(let E=f;E<f+W;E+=1){const k=h[E]??0,N=d>0?c:" ";if(A.push(N.repeat(k+this.#t.gap)),E<f+W-1){const J=this.determineJoinChar(s,e,o,r,E,E+1);J.width>0&&A.push(J.char)}}b=A.join(""),m.push(R(R(b,this.#t.borderColor),this.#t.backgroundColor))}const j=f+W-1;if(j<this.#t.columns-1){const A=this.determineJoinChar(s,e,o,r,j,j+1);A.width>0&&m.push(R(R(A.char,this.#t.borderColor),this.#t.backgroundColor))}f+=W-1}return p&&m.push(R(R(p,this.#t.borderColor),this.#t.backgroundColor)),m.join("")}determineJoinChar(e,i,o,h,s,r=-1){if(!this.#t.showBorders||!this.#t.border)return{char:" ",width:this.#t.gap};const a=this.#t.border;if(e!=="middle"){const B=nt(a,e),W=i[o]?.[s]??void 0,j=r===-1?s+1:r,A=i[o]?.[j]??void 0,E=W!==void 0&&A!==void 0&&W===A?B.body:B.join,{char:k,width:N}=E;return{char:k,width:N>0?N:this.#t.gap}}if(h===-1||r===-1)return{char:" ",width:this.#t.gap};const n=a.bodyJoin,c=i[o]?.[s]??void 0,d=i[h]?.[s]??void 0,l=i[o]?.[r]??void 0,u=i[h]?.[r]??void 0,p=c!==void 0&&d!==void 0&&c===d,m=l!==void 0&&u!==void 0&&l===u,g=c!==void 0&&l!==void 0&&c===l,b=d!==void 0&&u!==void 0&&d===u;let f;const x=nt(a,"middle");p&&m?f=g?{char:" ",width:n.width}:n:p?f=a.joinLeft:m?f=a.joinRight:g&&b?f=x.body:g?f=a.topJoin:b?f=a.bottomJoin:f=a.joinJoin;const{char:w,width:v}=f;return{char:w,width:v>0?v:this.#t.gap}}renderGrid(e,i){if(e.length===0)return"";const o=[],h=Do(e,i,this.#t,this.alignCellContent.bind(this),st),s=this.#t.showBorders&&this.#t.border?nt(this.#t.border,"top"):void 0;s&&s.body.width>0&&o.push(this.renderHorizontalBorder(e,h,0,i,"top"));for(let a=0;a<e.length;a+=1){const n=h[a]??1;for(let d=0;d<n;d+=1)o.push(this.renderVisualRowContent(e,a,d,i,h));const c=this.#t.showBorders&&this.#t.border?nt(this.#t.border,"middle"):void 0;if(a<e.length-1&&c&&c.body.width>0){const d=e[a],l=e[a+1];let u=!1;if(d&&l)for(let p=0;p<this.#t.columns;p+=1){const m=d[p],g=l[p];if(m!==g){u=!0;break}}u&&o.push(this.renderHorizontalBorder(e,h,a,i,"middle",a+1))}}const r=this.#t.showBorders&&this.#t.border?nt(this.#t.border,"bottom"):void 0;return r&&r.body.width>0&&o.push(this.renderHorizontalBorder(e,h,e.length-1,i,"bottom")),o.join(`
|
|
12
|
+
`)}getCachedCellVerticalPosition(e,i,o,h){const s=this.#i.get(h);if(s)return s;const r=re(e,i,o,h);return this.#i.set(h,r),r}}le(t=>new Dt(t),"createGrid");const tn={bodyJoin:{char:"│",width:1},bodyLeft:{char:"│",width:1},bodyRight:{char:"│",width:1},bottomBody:{char:"─",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"└",width:1},bottomRight:{char:"┘",width:1},joinBody:{char:"─",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"─",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"┌",width:1},topRight:{char:"┐",width:1}},yn={bodyJoin:{char:" ",width:1},bodyLeft:{char:" ",width:1},bodyRight:{char:" ",width:1},bottomBody:{char:"-",width:1},bottomJoin:{char:"-",width:1},bottomLeft:{char:"-",width:1},bottomRight:{char:"-",width:1},joinBody:{char:"-",width:1},joinJoin:{char:"-",width:1},joinLeft:{char:"-",width:1},joinRight:{char:"-",width:1},topBody:{char:"-",width:1},topJoin:{char:"-",width:1},topLeft:{char:"-",width:1},topRight:{char:"-",width:1}},vn={bodyJoin:{char:"║",width:1},bodyLeft:{char:"║",width:1},bodyRight:{char:"║",width:1},bottomBody:{char:"═",width:1},bottomJoin:{char:"╩",width:1},bottomLeft:{char:"╚",width:1},bottomRight:{char:"╝",width:1},joinBody:{char:"═",width:1},joinJoin:{char:"╬",width:1},joinLeft:{char:"╠",width:1},joinRight:{char:"╣",width:1},topBody:{char:"═",width:1},topJoin:{char:"╦",width:1},topLeft:{char:"╔",width:1},topRight:{char:"╗",width:1}},xn={bodyJoin:{char:"│",width:1},bodyLeft:{char:"│",width:1},bodyRight:{char:"│",width:1},bottomBody:{char:"─",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"╰",width:1},bottomRight:{char:"╯",width:1},joinBody:{char:"─",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"─",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"╭",width:1},topRight:{char:"╮",width:1}},Bn={bodyJoin:{char:"┊",width:1},bodyLeft:{char:"┊",width:1},bodyRight:{char:"┊",width:1},bottomBody:{char:"┈",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"└",width:1},bottomRight:{char:"┘",width:1},joinBody:{char:"┈",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"┈",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"┌",width:1},topRight:{char:"┐",width:1}},Wn={bodyJoin:{char:"|",width:1},bodyLeft:{char:"|",width:1},bodyRight:{char:"|",width:1},bottomBody:{char:"-",width:1},bottomJoin:{char:"|",width:1},bottomLeft:{char:"|",width:1},bottomRight:{char:"|",width:1},joinBody:{char:"-",width:1},joinJoin:{char:"|",width:1},joinLeft:{char:"|",width:1},joinRight:{char:"|",width:1},topBody:{char:"-",width:1},topJoin:{char:"|",width:1},topLeft:{char:"|",width:1},topRight:{char:"|",width:1}},Rn={bodyJoin:{char:"|",width:1},bodyLeft:{char:"|",width:1},bodyRight:{char:"|",width:1},bottomBody:{char:"-",width:1},bottomJoin:{char:"+",width:1},bottomLeft:{char:"+",width:1},bottomRight:{char:"+",width:1},joinBody:{char:"-",width:1},joinJoin:{char:"+",width:1},joinLeft:{char:"+",width:1},joinRight:{char:"+",width:1},topBody:{char:"-",width:1},topJoin:{char:"+",width:1},topLeft:{char:"+",width:1},topRight:{char:"+",width:1}},Sn={bodyJoin:{char:"",width:0},bodyLeft:{char:"",width:0},bodyRight:{char:"",width:0},bottomBody:{char:"",width:0},bottomJoin:{char:"",width:0},bottomLeft:{char:"",width:0},bottomRight:{char:"",width:0},joinBody:{char:"",width:0},joinJoin:{char:"",width:0},joinLeft:{char:"",width:0},joinRight:{char:"",width:0},topBody:{char:"",width:0},topJoin:{char:"",width:0},topLeft:{char:"",width:0},topRight:{char:"",width:0}},jn={bodyJoin:{char:"█",width:1},bodyLeft:{char:"█",width:1},bodyRight:{char:"█",width:1},bottomBody:{char:"█",width:1},bottomJoin:{char:"█",width:1},bottomLeft:{char:"█",width:1},bottomRight:{char:"█",width:1},joinBody:{char:"█",width:1},joinJoin:{char:"█",width:1},joinLeft:{char:"█",width:1},joinRight:{char:"█",width:1},topBody:{char:"█",width:1},topJoin:{char:"█",width:1},topLeft:{char:"█",width:1},topRight:{char:"█",width:1}},An={bodyJoin:{char:"┃",width:1},bodyLeft:{char:"┃",width:1},bodyRight:{char:"┃",width:1},bottomBody:{char:"━",width:1},bottomJoin:{char:"┻",width:1},bottomLeft:{char:"┗",width:1},bottomRight:{char:"┛",width:1},joinBody:{char:"━",width:1},joinJoin:{char:"╋",width:1},joinLeft:{char:"┣",width:1},joinRight:{char:"┫",width:1},topBody:{char:"━",width:1},topJoin:{char:"┳",width:1},topLeft:{char:"┏",width:1},topRight:{char:"┓",width:1}};var en=Object.defineProperty,ri=$((t,e)=>en(t,"name",{value:e,configurable:!0}),"p"),rn=Object.defineProperty,de=ri((t,e)=>rn(t,"name",{value:e,configurable:!0}),"y"),on=Object.defineProperty,nn=de((t,e)=>on(t,"name",{value:e,configurable:!0}),"t");const sn=nn(t=>t.reduce((e,i)=>{if(i===null)return e+1;if(typeof i=="object"&&!Array.isArray(i)){const o=typeof i.colSpan=="number"?i.colSpan:1;return e+(o<=0?1:o)}return e+1},0),"computeRowLogicalWidth");var an=Object.defineProperty,oi=de((t,e)=>an(t,"name",{value:e,configurable:!0}),"b");class hn{static{$(this,"H")}static{ri(this,"D")}static{de(this,"Table")}static{oi(this,"Table")}#t;#o=[];#e=[];#n=[];#i=!0;#r=void 0;constructor(e={}){this.#t={...e,showFooter:e.showFooter??!0,showHeader:e.showHeader??!0,style:{border:tn,paddingLeft:1,paddingRight:1,...e.style}}}setHeaders(e){return e.length>0&&!Array.isArray(e[0])?this.#e=[e]:this.#e=e.map(i=>Array.isArray(i)?i:[i]),this.#i=!0,this.#r=void 0,this}setFooter(e){return e.length>0&&!Array.isArray(e[0])?this.#n=[e]:this.#n=e.map(i=>Array.isArray(i)?i:[i]),this.#i=!0,this.#r=void 0,this}addRow(e){if(!Array.isArray(e))throw new TypeError("Row must be an array");return this.#o.push(e),this.#i=!0,this.#r=void 0,this}addRows(...e){for(const i of e)this.addRow(i);return this.#i=!0,this.#r=void 0,this}toString(){if(!this.#i&&this.#r!==void 0)return this.#r;const e=this.#t.showHeader?this.#e:[],i=this.#t.showFooter?this.#n:[],o=[...e,...this.#o,...i];if(o.length===0)return this.#r="",this.#i=!1,"";let h=0;for(const l of o){const u=l;Array.isArray(u)?h=Math.max(h,sn(u)):console.error("Unexpected non-array element found while calculating columns:",u)}if(h===0)return this.#r="",this.#i=!1,"";let s;Array.isArray(this.#t.columnWidths)?s=this.#t.columnWidths.length>=h?this.#t.columnWidths.slice(0,h):[...this.#t.columnWidths,...Array.from({length:h-this.#t.columnWidths.length}).fill(void 0)]:typeof this.#t.columnWidths=="number"&&(s=Array.from({length:h}).fill(this.#t.columnWidths));let r;const a=o.length;if(Array.isArray(this.#t.rowHeights)?r=this.#t.rowHeights:typeof this.#t.rowHeights=="number"&&(r=Array.from({length:a}).fill(this.#t.rowHeights)),s&&Array.isArray(s)){const l=[...s];for(const u of o){const p=u;for(const[m,g]of p.entries()){let b={};if(typeof g=="object"&&g!==null&&!Array.isArray(g)){const{content:f,href:x,...w}=g;b=w}b.width!==void 0?l[m]=b.width:b.maxWidth!==void 0&&l[m]!==void 0&&(l[m]=Math.min(l[m],b.maxWidth))}}s=l}const n={autoFlow:"row",backgroundColor:this.#t.style?.backgroundColor,balancedWidths:this.#t.balancedWidths??!1,border:this.#t.style?.border,borderColor:this.#t.style?.borderColor,columns:h,fixedColumnWidths:s,fixedRowHeights:r,foregroundColor:this.#t.style?.foregroundColor,gap:this.#t.gap??0,maxWidth:this.#t.maxWidth,paddingLeft:this.#t.style?.paddingLeft,paddingRight:this.#t.style?.paddingRight,terminalWidth:this.#t.terminalWidth,truncate:this.#t.truncate??(s?.every(l=>typeof l=="number")||this.#t.maxWidth!==void 0&&!this.#t.balancedWidths),truncateOverflow:this.#t.truncateOverflow??!0,wordWrap:this.#t.wordWrap??!1},c=new Dt(n),d=[];for(const[l,u]of o.entries()){const p=u;if(!Array.isArray(p)){console.error("Skipping non-array row while creating GridItems:",p);continue}const m=this.#t.showHeader?this.#e.length:0,g=this.#o.length,b=this.#t.showHeader&&l<m,f=this.#t.showFooter&&l>=m+g,x=b&&p.length===1&&h>1,w=f&&p.length===1&&h>1;for(const v of p){let B=v,W={};if(typeof B=="object"&&B!==null&&!Array.isArray(B)){const{content:k,href:N,...J}=B;B=N?`\x1B]8;;${N}\x1B\\${String(k)}\x1B]8;;\x1B\\`:k,W=J}x&&(W.colSpan=h),w&&(W.colSpan=h);const j=this.#t.transformTabToSpace&&typeof B=="string"?B.replaceAll(" "," ".repeat(this.#t.transformTabToSpace)):B,{maxWidth:A,width:E}=W;d.push({backgroundColor:W.backgroundColor,colSpan:W.colSpan,content:j,foregroundColor:W.foregroundColor,hAlign:W.hAlign,maxWidth:A,rowSpan:W.rowSpan,truncate:W.truncate??(A===void 0?void 0:!0),vAlign:W.vAlign,width:E,wordWrap:W.wordWrap})}}return c.addItems(d),this.#r=c.toString(),this.#i=!1,this.#r}}const Cn=oi(t=>new hn(t),"createTable");export{Si as B,fn as E,hn as H,mn as I,Cn as M,gn as N,pn as P,An as R,bn as T,Wn as a,Rn as c,Bn as d,wn as e,U as g,yn as h,vn as i,dn as j,xn as o,un as q,Sn as r,tn as t,jn as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var I=Object.defineProperty;var d=(s,e)=>I(s,"name",{value:e,configurable:!0});import{createRequire as $}from"node:module";import{
|
|
1
|
+
var I=Object.defineProperty;var d=(s,e)=>I(s,"name",{value:e,configurable:!0});import{createRequire as $}from"node:module";import{p as j}from"../packem_chunks/config.js";import{advisoriesStatus as E,NATIVE_BINDING_VERSION as A,advisoriesIngest as q,advisoriesQuery as B}from"#native";const T=$(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=d(s=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[e,t]=v.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return v.getBuiltinModule(s)}return T(s)},"__cjs_getBuiltinModule"),{randomUUID:O}=l("node:crypto"),{createWriteStream:P,existsSync:k}=l("node:fs"),{mkdir:U,unlink:x,stat:C}=l("node:fs/promises"),{join:w,dirname:L}=l("node:path"),{Readable:M}=l("node:stream"),{pipeline:W}=l("node:stream/promises");var F=Object.defineProperty,r=d((s,e)=>F(s,"name",{value:e,configurable:!0}),"s");const b=5;if(A!==b)throw new Error(`vis native binding ABI mismatch in advisories: expected ${b}, got ${A}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const es="https://osv-vulnerabilities.storage.googleapis.com",V=new Set(["osv-vulnerabilities.storage.googleapis.com"]);class H extends Error{static{d(this,"AdvisoryDbNotFoundError")}static{r(this,"AdvisoryDbNotFoundError")}cause="DB_NOT_FOUND";constructor(e){super(`No local advisory DB at ${e}. Run 'vis advisories sync' first.`),this.name="AdvisoryDbNotFoundError"}}class h extends Error{static{d(this,"AdvisorySourceNotAllowedError")}static{r(this,"AdvisorySourceNotAllowedError")}cause="SOURCE_NOT_ALLOWED";constructor(e){super(`Advisory source host '${e}' is not in the built-in allowlist. Add it to \`security.audit.advisories.allowedHosts\` if intentional.`),this.name="AdvisorySourceNotAllowedError"}}class N extends Error{static{d(this,"AdvisorySyncNetworkError")}static{r(this,"AdvisorySyncNetworkError")}cause="SYNC_NETWORK";constructor(e,t){super(`Advisory sync failed for ${e}: ${t}. Check connectivity, proxy env vars, or --source.`),this.name="AdvisorySyncNetworkError"}}const g=r(s=>{const e=j("vis",{create:!0,cwd:s})??w(s,"node_modules",".cache","vis");return w(e,"advisories","db.sqlite")},"resolveAdvisoryDbPath"),z=r((s,e)=>{let t;try{t=new URL(s)}catch{throw new h(s)}if(t.protocol!=="https:")throw new h(`${t.protocol}//${t.host}`);if(!new Set([...V,...e??[]]).has(t.host))throw new h(t.host);return t},"validateAdvisorySource"),ts=r(async s=>{const e=s.dbPath??g(s.workspaceRoot);await U(L(e),{recursive:!0});const t=z(s.source,s.allowedHosts),u=new URL(`${s.ecosystem}/all.zip`,Q(t.toString())),y=await G(e,s.ecosystem);let i=null;if(!s.force){const n=await S(u,{method:"HEAD"});if(n.ok&&(i=n.headers.get("etag"),i&&y&&i===y))return{advisoriesIngested:0,dbPath:e,durationMs:0,upToDate:!0}}const a=`${e}.${s.ecosystem}.${process.pid}.${O()}.zip.tmp`,o=await S(u,{method:"GET"});if(!o.ok||!o.body)throw new N(u.toString(),o.status);i||(i=o.headers.get("etag"));const m=o.headers.get("content-length"),c=m?Number.parseInt(m,10):null;let p=0;const _=P(a),f=M.fromWeb(o.body);s.onProgress&&c&&f.on("data",n=>{p+=n.byteLength,s.onProgress?.(p,c,"download")}),await W(f,_);try{const n=await q({dbPath:e,ecosystem:s.ecosystem,manifestEtag:i??void 0,zipPath:a},(D,R)=>s.onProgress?.(D,R,"ingest"));return{advisoriesIngested:n.advisoriesIngested,dbPath:e,durationMs:n.durationMs,upToDate:!1}}finally{await x(a).catch(()=>{})}},"syncAdvisories"),rs=r((s,e)=>{if(s.length===0)return new Map;const t=e.dbPath??g(e.workspaceRoot),u=e.ecosystem??"npm";if(!k(t))throw new H(t);const y=s.map(o=>({ecosystem:u,name:o.name,version:o.version})),i=B(t,y),a=new Map;for(const[o,m]of s.entries()){const c=i[o];!c||c.vulnerabilities.length===0||a.set(m.name,c.vulnerabilities.map(p=>K(p)))}return a},"queryAdvisories"),os=r(async(s,e)=>{const t=e??g(s);return E(t)},"getAdvisoryStatus"),G=r(async(s,e)=>{try{await C(s)}catch{return null}return E(s).ecosystems.find(t=>t.name===e)?.manifestEtag??null},"readStoredEtag"),K=r(s=>({aliases:s.aliases.length>0?s.aliases:void 0,cvssScore:s.cvssScore??void 0,fixedVersions:s.fixedVersions,id:s.id,severity:Y(s.severity),summary:s.summary}),"toSecurityVulnerability"),Y=r(s=>{const e=s.toUpperCase();return e==="CRITICAL"||e==="HIGH"||e==="MODERATE"||e==="LOW"?e:"UNKNOWN"},"normalizeSeverity"),Q=r(s=>s.endsWith("/")?s:`${s}/`,"ensureTrailingSlash"),S=r(async(s,e)=>{try{return await fetch(s,e)}catch(t){throw new N(s.toString(),t instanceof Error?t.message:String(t))}},"safeFetch");export{H as A,es as D,os as g,rs as q,g as r,ts as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var de=Object.defineProperty;var w=(e,n)=>de(e,"name",{value:n,configurable:!0});import{createRequire as he}from"node:module";import{s as ie}from"../packem_chunks/config.js";import{M as B,B as _e}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{r as be}from"./docker-
|
|
1
|
+
var de=Object.defineProperty;var w=(e,n)=>de(e,"name",{value:n,configurable:!0});import{createRequire as he}from"node:module";import{s as ie}from"../packem_chunks/config.js";import{M as B,B as _e}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{r as be}from"./docker-EJiTY0Sz.js";import{e as $e}from"./license-zZU7aavK.js";import{S as Oe}from"./lockfile-CrT86D6d.js";import{x as ke}from"./pm-runner-DmKT2FqF.js";const ge=he(import.meta.url),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ae=w(e=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[n,t]=W.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return W.getBuiltinModule(e)}return ge(e)},"__cjs_getBuiltinModule"),{randomUUID:ye}=ae("node:crypto"),{readdirSync:ve}=ae("node:fs");var je=Object.defineProperty,pe=w((e,n)=>je(e,"name",{value:n,configurable:!0}),"r$1");const z=pe(e=>e.replaceAll(/[^\w.~-]/g,n=>`%${(n.codePointAt(0)??0).toString(16).toUpperCase().padStart(2,"0")}`),"encodeSegment"),M=pe((e,n)=>{const t=e.toLowerCase();if(t.startsWith("@")){const o=t.indexOf("/");if(o>0){const r=t.slice(0,o),p=t.slice(o+1);return`pkg:npm/${z(r)}/${z(p)}@${z(n)}`}}return`pkg:npm/${z(t)}@${z(n)}`},"toNpmPurl");var Se=Object.defineProperty,j=w((e,n)=>Se(e,"name",{value:n,configurable:!0}),"a");const m={ARRAY:"array",BOOLEAN:"boolean",DATE:"date",FUNCTION:"function",JSTOXML_OBJECT:"jstoxml-object",NULL:"null",NUMBER:"number",OBJECT:"object",STRING:"string"},Te=[m.STRING,m.NUMBER,m.BOOLEAN],Ae='<?xml version="1.0" encoding="UTF-8"?>',se=["_selfCloseTag","_attrs"],xe=j((e="",n=0)=>e.repeat(n),"getIndentStr"),Q=j(e=>Array.isArray(e)&&m.ARRAY||typeof e===m.OBJECT&&e!==null&&e._name&&m.JSTOXML_OBJECT||e instanceof Date&&m.DATE||e===null&&m.NULL||typeof e,"getType"),le=j(e=>e.startsWith("<![CDATA["),"isCDATA"),ue=j((e="",n={},t)=>{let o=e;if(typeof e===m.STRING){if(le(e))return e;const r=new RegExp(`(${Object.keys(n).join("|")})(?!(\\w|#)*;)`,"g");o=String(e).replace(r,(p,g)=>n[g]||"")}return typeof t=="function"?t(o):o},"mapStr"),Ce=j((e={},n,t,o)=>(Array.isArray(e)?e:Object.entries(e).map(([r,p])=>({[r]:p}))).reduce((r,p)=>{const g=Object.keys(p)[0],y=p[g];if(typeof t===m.FUNCTION&&t(g,y))return r;const b=n?ue(y,n):y,$=!o&&b===!0?"":`="${b}"`;return r.push(`${g}${$}`),r},[]),"getAttributeKeyVals"),Ne=j((e={},n,t,o)=>{const r=Ce(e,n,t,o);return r.length===0?"":` ${r.join(" ")}`},"formatAttributes"),Re=j((e={})=>Object.keys(e).map(n=>({_name:n,_content:e[n]})),"objToArray"),we=j(e=>Te.includes(Q(e)),"isPrimitive"),Pe=j(e=>!e.match("<"),"isSimpleXML"),De=j(({header:e,isOutputStart:n})=>e&&n?typeof e===m.BOOLEAN?Ae:e:"","getHeaderString"),re={"<":"<",">":">","&":"&",'"':"""},X=j((e={},n={})=>{const{depth:t=0,indent:o,_isFirstItem:r,_isOutputStart:p=!0,header:g,attributeReplacements:y={},attributeFilter:b,attributeExplicitTrue:$=!1,contentReplacements:q={},contentMap:L,selfCloseTags:I=!0}=n,H=typeof y=="boolean"&&!y?{}:{...re,...y},Y=typeof q=="boolean"&&!q?{}:{...re,...q},P=typeof o=="string",T=xe(o,t),G=Q(e),U=De({header:g,indent:o,depth:t,isOutputStart:p}),D=p&&!U&&r&&t===0,E=P&&!D?`
|
|
2
2
|
`:"";let v="";switch(G){case m.JSTOXML_OBJECT:{const{_name:f,_content:l}=e;if(l===null&&typeof L!="function"){v=`${E}${T}${f}`;break}if(Array.isArray(l)&&l.every(we))return l.map(S=>X({_name:f,_content:S},{...n,depth:t,_isOutputStart:!1})).join("");if(se.includes(f))break;const _=X(l,{...n,depth:t+1,_isOutputStart:D}),N=Q(_),O=Pe(_),k=le(_),R=`${E}${T}`;if(f==="_comment"){v+=`${R}<!-- ${l} -->`;break}const K=N==="undefined"||_==="",c=I,s=e._selfCloseTag,i=typeof s===m.BOOLEAN?K&&s:K&&c,a=i?"/":"",u=Ne(e._attrs,H,b,$),d=`<${f}${u}${a}>`,A=P&&!O&&!k?`
|
|
3
3
|
${T}`:"",x=i?"":`${_}${A}</${f}>`;v+=`${R}${d}${x}`;break}case m.OBJECT:{const f=Object.keys(e);v=f.map((l,_)=>{const N={...n,_isFirstItem:_===0,_isLastItem:_+1===f.length,_isOutputStart:D},O={_name:l};if(Q(e[l])===m.OBJECT&&(se.forEach(k=>{const R=e[l][k];typeof R<"u"&&(O[k]=R,delete e[l][k])}),typeof e[l]._content<"u"&&Object.keys(e[l]).length>1)){const k=Object.assign({},e[l]);delete k._content,O._content=[...Re(k),e[l]._content]}return typeof O._content>"u"&&(O._content=e[l]),X(O,N)},n).join("");break}case m.FUNCTION:{const f=e(n);v=X(f,n);break}case m.ARRAY:{v=e.map((f,l)=>{const _={...n,_isFirstItem:l===0,_isLastItem:l+1===e.length,_isOutputStart:D};return X(f,_)}).join("");break}default:{v=ue(e,Y,L);break}}return`${U}${v}`},"toXML");var Ee=Object.defineProperty,F=w((e,n)=>Ee(e,"name",{value:n,configurable:!0}),"r");const te=F(e=>{try{return ie(e)}catch{return}},"readJsonSafe"),Me=F(e=>{if(e.length===0||e.includes("..")||e.startsWith(".")||e.includes("\0")||e.includes("\\"))return!1;if(e.startsWith("@")){const n=e.indexOf("/");return n>1&&!e.includes("/",n+1)}return!e.includes("/")},"isSafePackageName"),Be=F(e=>e.length>0&&!e.includes("/")&&!e.includes("\\")&&!e.includes("..")&&!e.includes("\0"),"isSafeVersion"),Le=F((e,n,t)=>{const o=`${n.replaceAll("/","+")}@${t}`,r=B(e,"node_modules",".pnpm"),p=te(B(r,o,"node_modules",n,"package.json"));if(p)return p;let g;try{g=ve(r)}catch{return}const y=`${o}_`;for(const b of g){if(!b.startsWith(y))continue;const $=te(B(r,b,"node_modules",n,"package.json"));if($)return $}},"readPnpmVirtualStore"),Ie=F((e,n,t)=>{const o=te(B(e,"node_modules",n,"package.json"));return o?.version===t?o:void 0},"readHoistedCopy"),Ue=F((e,n,t)=>{if(!(!Me(n)||!Be(t)))return Le(e,n,t)??Ie(e,n,t)},"readInstalledPackageMetadata");var Je=Object.defineProperty,me=w((e,n)=>Je(e,"name",{value:n,configurable:!0}),"t");const Xe={sha256:"SHA-256",sha384:"SHA-384",sha512:"SHA-512"},Fe={sha256:64,sha384:96,sha512:128},qe=me(e=>{const n={name:e.name,version:e.version},{integrity:t}=e;return t&&t.hex.length===Fe[t.algorithm]&&(n.hash={alg:Xe[t.algorithm],content:t.hex}),e.dependencies&&(n.dependencies=e.dependencies),e.peerDependencies&&(n.peerDependencies=e.peerDependencies),e.optionalDependencies&&(n.optionalDependencies=e.optionalDependencies),n},"toResolvedPackage"),He=[{file:"pnpm-lock.yaml",type:"pnpm"},{file:"npm-shrinkwrap.json",type:"npm"},{file:"package-lock.json",type:"npm"},{file:"yarn.lock",type:"yarn"},{file:"bun.lock",type:"bun"}],Ve=me(e=>{for(const{file:n,type:t}of He){let o;try{o=_e(B(e,n))}catch{continue}const r=new Map;for(const p of Oe(o,t))r.set(`${p.name}@${p.version}`,qe(p));return{packages:r,type:t}}},"readLockfilePackages");var We=Object.defineProperty,fe=w((e,n)=>We(e,"name",{value:n,configurable:!0}),"s");const ze=fe(e=>{const n=e.indexOf(":");return n<=0?e:e.slice(0,n)==="npm"?e.slice(n+1):e},"stripProtocolPrefix"),ee=fe((e,n,t)=>{const o=t.get(e);if(!o||o.size===0)return;if(o.has(n))return n;const r=ze(n);if(r!==n&&o.has(r))return r;const p=[...o];return ke.maxSatisfying(p,r,{includePrerelease:!0})||p[0]},"resolveSpecifier");var Ye=Object.defineProperty,h=w((e,n)=>Ye(e,"name",{value:n,configurable:!0}),"p");const Ge="1.7",Ke="CycloneDX",Qe="http://cyclonedx.org/schema/bom-1.7.schema.json",Ze="@visulima/vis",ce=h(e=>{try{return ie(e)}catch{return}},"readPackageJson"),en=h(e=>{if(e){if(typeof e=="string")return e;if(typeof e=="object"&&e.name)return e.email?`${e.name} <${e.email}>`:e.name}},"toAuthorString"),nn=h(e=>{if(e)return typeof e=="string"?e:e.url},"toRepositoryUrl"),tn=h(e=>{if(e)return typeof e=="string"?e:e.url},"toBugsUrl"),on=h(e=>{const n=[];e.homepage&&n.push({type:"website",url:e.homepage});const t=nn(e.repository);t&&n.push({type:"vcs",url:t});const o=tn(e.bugs);return o&&n.push({type:"issue-tracker",url:o}),n.length>0?n:void 0},"buildExternalReferences"),sn=h(e=>e==="application"||e==="service"||e==="tool"?"application":"library","toCycloneDxComponentType"),ne=h((e,n)=>{if(!n)return;n.description&&(e.description=n.description);const t=en(n.author);t&&(e.author=t);const o=$e(n);o&&(e.licenses=o);const r=on(n);r&&(e.externalReferences=r)},"decoratePackageComponent"),yn=h(e=>{const{focus:n,generatorVersion:t,includeDev:o=!1,now:r=new Date,projectGraph:p,serialNumber:g,workspace:y,workspaceRoot:b}=e,$=n&&n.length>0?[...be(n,p)].sort():Object.keys(y.projects).sort(),q=new Set($),L=new Map;for(const c of $){const s=y.projects[c];s&&L.set(c,ce(B(b,s.root,"package.json")))}const I=[],H=new Map;for(const c of $){const s=y.projects[c];if(!s)continue;const i=L.get(c),a=i?.version??"0.0.0",u=M(c,a);H.set(c,u);const d={"bom-ref":u,name:c,purl:u,type:sn(s.projectType),version:a};ne(d,i),I.push(d)}const Y=Ve(b),P=new Map,T=new Map;if(Y)for(const c of Y.packages.values()){P.set(`${c.name}@${c.version}`,c);let s=T.get(c.name);s||(s=new Set,T.set(c.name,s)),s.add(c.version)}const G=[],U=[],D=new Map;for(const c of $){const s=L.get(c);if(!s)continue;const i=[s.dependencies,s.peerDependencies];o&&i.push(s.devDependencies);const a=new Set,u=h((d,A)=>{if(A)for(const[x,S]of Object.entries(A)){if(q.has(x)){const J=H.get(x);J&&a.add(J);continue}const C=ee(x,S,T);C&&(a.add(M(x,C)),d.push(`${x}@${C}`))}},"seedRef");for(const d of i)u(G,d);u(U,s.optionalDependencies),D.set(c,a)}const E=new Map,v=new Map,f=h((c,s)=>{const i=[...c];for(;i.length>0;){const a=i.pop(),u=E.get(a);if(u==="required"||u==="optional"&&s==="optional")continue;E.set(a,s);const d=P.get(a);if(!d)continue;const A=v.get(a)??new Set,x=[d.dependencies,d.peerDependencies];for(const S of x)if(S)for(const[C,J]of Object.entries(S))for(const V of J){const Z=ee(C,V,T);Z&&(A.add(M(C,Z)),i.push(`${C}@${Z}`))}if(d.optionalDependencies)for(const[S,C]of Object.entries(d.optionalDependencies))for(const J of C){const V=ee(S,J,T);V&&(A.add(M(S,V)),U.push(`${S}@${V}`))}A.size>0&&v.set(a,A)}},"walk");f(G,"required"),f(U,"optional");const l=[],_=[...E.keys()].sort();for(const c of _){const s=P.get(c);if(!s)continue;const i=M(s.name,s.version),a={"bom-ref":i,name:s.name,purl:i,scope:E.get(c)??"required",type:"library",version:s.version};s.hash&&(a.hashes=[s.hash]),ne(a,Ue(b,s.name,s.version)),l.push(a)}const N=[];for(const[c,s]of D){const i=H.get(c);if(!i)continue;const a=[...s].sort();N.push(a.length>0?{dependsOn:a,ref:i}:{ref:i})}for(const c of _){const s=P.get(c);if(!s)continue;const i=M(s.name,s.version),a=v.get(c),u=a?[...a].sort():[];N.push(u.length>0?{dependsOn:u,ref:i}:{ref:i})}N.sort((c,s)=>c.ref.localeCompare(s.ref));const O=ce(B(b,"package.json")),k=(()=>{if(n?.length===1){const u=I.find(d=>d.name===n[0]);if(u)return{"bom-ref":u["bom-ref"],name:u.name,purl:u.purl,type:u.type,version:u.version}}const c=O?.name??"workspace",s=O?.version??"0.0.0",i=M(c,s),a={"bom-ref":i,name:c,purl:i,type:"application",version:s};return ne(a,O),a})(),R=k["bom-ref"],K=R?I.filter(c=>c["bom-ref"]!==R):I;return{$schema:Qe,bomFormat:Ke,components:[...K,...l],dependencies:N,metadata:{component:k,lifecycles:[{phase:"build"}],timestamp:r.toISOString(),tools:{components:[{name:Ze,type:"application",...t?{version:t}:{}}]}},serialNumber:g??`urn:uuid:${ye()}`,specVersion:Ge,version:1}},"buildCycloneDxBom"),_n=h(e=>{const n={version:e.version??1,xmlns:"http://cyclonedx.org/schema/bom/1.7"};e.serialNumber&&(n.serialNumber=e.serialNumber);const t=[];return e.metadata&&t.push(rn(e.metadata)),e.components&&e.components.length>0&&t.push({_content:e.components.map(o=>oe(o)),_name:"components"}),e.dependencies&&e.dependencies.length>0&&t.push({_content:e.dependencies.map(o=>an(o)),_name:"dependencies"}),`${X({_attrs:n,_content:t,_name:"bom"},{header:!0,indent:" ",selfCloseTags:!0})}
|
|
4
4
|
`},"serializeBomToXml"),rn=h(e=>{const n=[];return e.timestamp&&n.push({timestamp:e.timestamp}),e.lifecycles&&e.lifecycles.length>0&&n.push({_content:e.lifecycles.map(t=>{const o=[];return t.phase&&o.push({phase:t.phase}),t.name&&o.push({name:t.name}),t.description&&o.push({description:t.description}),{_content:o,_name:"lifecycle"}}),_name:"lifecycles"}),e.tools?.components&&n.push({_content:[{_content:e.tools.components.map(t=>oe(t)),_name:"components"}],_name:"tools"}),e.component&&n.push(oe(e.component)),{_content:n,_name:"metadata"}},"metadataToXmlElement"),oe=h(e=>{const n={type:e.type};e["bom-ref"]&&(n["bom-ref"]=e["bom-ref"]);const t=[];e.group&&t.push({group:e.group}),t.push({name:e.name}),e.version&&t.push({version:e.version}),e.description&&t.push({description:e.description}),e.author&&t.push({author:e.author}),e.hashes&&e.hashes.length>0&&t.push({_content:e.hashes.map(r=>({_attrs:{alg:r.alg},_content:r.content,_name:"hash"})),_name:"hashes"});const o=cn(e.licenses);return o&&t.push(o),e.purl&&t.push({purl:e.purl}),e.scope&&t.push({scope:e.scope}),e.externalReferences&&e.externalReferences.length>0&&t.push({_content:e.externalReferences.map(r=>({_attrs:{type:r.type},_content:[{url:r.url}],_name:"reference"})),_name:"externalReferences"}),{_attrs:n,_content:t,_name:"component"}},"componentToXmlElement"),cn=h(e=>{if(!e||e.length===0)return;const n=[];for(const t of e){if("expression"in t){n.push({expression:t.expression});continue}const o=[];"id"in t.license&&t.license.id?o.push({id:t.license.id}):"name"in t.license&&t.license.name&&o.push({name:t.license.name}),n.push({_content:o,_name:"license"})}return{_content:n,_name:"licenses"}},"licensesToXmlElement"),an=h(e=>e.dependsOn&&e.dependsOn.length>0?{_attrs:{ref:e.ref},_content:e.dependsOn.map(n=>({_attrs:{ref:n},_name:"dependency"})),_name:"dependency"}:{_attrs:{ref:e.ref},_name:"dependency"},"dependencyToXmlElement");export{yn as b,_n as s,M as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var pa=Object.defineProperty;var c=(h,n)=>pa(h,"name",{value:n,configurable:!0});import{createRequire as da}from"node:module";import{
|
|
1
|
+
var pa=Object.defineProperty;var c=(h,n)=>pa(h,"name",{value:n,configurable:!0});import{createRequire as da}from"node:module";import{b as va,s as Do,E as Ji}from"../packem_chunks/config.js";import{K as ci,M as Be,l as Aa,z as ba}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{c2 as Ca,c3 as $a}from"../packem_chunks/bin.js";import"./_commonjsHelpers-CLblCigl.js";const ha=da(import.meta.url),vr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ga=c(h=>{if(typeof vr<"u"&&vr.versions&&vr.versions.node){const[n,m]=vr.versions.node.split(".").map(Number);if(n>22||n===22&&m>=3||n===20&&m>=16)return vr.getBuiltinModule(h)}return ha(h)},"__cjs_getBuiltinModule"),{cpSync:No,lstatSync:ma,readdirSync:ya,existsSync:Mo,rmSync:si,readFileSync:Vi}=ga("node:fs");var Sa=Object.defineProperty,Ea=c((h,n)=>Sa(h,"name",{value:n,configurable:!0}),"t");class ft extends Error{static{c(this,"LockfilePruneError")}static{Ea(this,"LockfilePruneError")}constructor(n){super(n),this.name="LockfilePruneError"}}var wa=Object.defineProperty,Bt=c((h,n)=>wa(h,"name",{value:n,configurable:!0}),"p$2");const qo=Bt(h=>{let n=h.startsWith("/")?h.slice(1):h;const m=n.indexOf("(");return m!==-1&&(n=n.slice(0,m)),n},"canonicalKey"),ka=Bt((h,n)=>{if(!(n.startsWith("link:")||n.startsWith("file:")||n.startsWith("workspace:")))return`${h}@${n}`},"resolveDepKey"),xa=Bt(h=>{const n=[];for(const m of[h.dependencies,h.devDependencies,h.optionalDependencies])if(m)for(const[v,$]of Object.entries(m))$?.version&&n.push({name:v,version:$.version});return n},"collectImporterDeps"),Ki=Bt(h=>{const n=[];for(const m of[h.dependencies,h.optionalDependencies])if(m)for(const[v,$]of Object.entries(m))typeof $=="string"&&n.push({name:v,version:$});return n},"collectPackageDeps"),Gi=Bt(h=>{const n=new Map;if(!h)return n;for(const m of Object.keys(h)){const v=qo(m),$=n.get(v);$?$.push(m):n.set(v,[m])}return n},"buildKeyIndex"),Yo=Bt(h=>{const n=h.displayName??"pnpm-lock.yaml",m=typeof h.lockfileContent=="string"?h.lockfileContent:h.lockfileContent.toString("utf8");let v;try{v=Ca(m)}catch(oe){throw new ft(`${n}: parse failed — ${oe.message}`)}const $=Bt(oe=>oe.packages?Object.keys(oe.packages).length:0,"packageCount");let a;for(const oe of v){const[T]=oe.errors;if(T)throw new ft(`${n}: parse failed — ${T.message}`);const ne=oe.toJS();if(!ne||typeof ne!="object")continue;const me=ne;(a===void 0||$(me)>$(a))&&(a=me)}if(a===void 0)throw new ft(`${n}: top-level value is not an object`);const g=a.importers??{},e=Gi(a.packages),C=Gi(a.snapshots),k=new Set(["."]);for(const oe of h.closure)k.add(oe.relativeRoot===""?".":oe.relativeRoot);const b={};for(const[oe,T]of Object.entries(g))k.has(oe)&&(b[oe]=T);const S=new Set,O=new Set,H=[];for(const oe of Object.values(b))for(const T of xa(oe))H.push(T);for(;H.length>0;){const{name:oe,version:T}=H.shift(),ne=ka(oe,T);if(!ne)continue;const me=qo(ne),U=C.get(me)??C.get(ne)??[];for(const be of U){if(O.has(be))continue;O.add(be);const ye=a.snapshots?.[be];if(ye)for(const je of Ki(ye))H.push(je)}const ue=e.get(me)??e.get(ne)??[];for(const be of ue){if(S.has(be))continue;S.add(be);const ye=a.packages?.[be];if(ye&&!a.snapshots)for(const je of Ki(ye))H.push(je)}}const A={lockfileVersion:a.lockfileVersion};for(const oe of["settings","overrides","patchedDependencies","catalogs"])a[oe]!==void 0&&(A[oe]=a[oe]);if(A.importers=b,a.packages){const oe={};for(const T of Object.keys(a.packages))S.has(T)&&(oe[T]=a.packages[T]);A.packages=oe}if(a.snapshots){const oe={};for(const T of Object.keys(a.snapshots))O.has(T)&&(oe[T]=a.snapshots[T]);A.snapshots=oe}const y=Object.keys(a.packages??{}).length,E=Object.keys(A.packages??{}).length,X=y-E,fe=Object.keys(g).length-Object.keys(b).length;return{content:$a(A,{lineWidth:0}),message:`${n}: kept ${E}/${y} packages and ${Object.keys(b).length} importers (dropped ${X} packages, ${fe} importers)`,status:"pruned"}},"prunePnpmLockfile");var Oa=Object.defineProperty,ja=c((h,n)=>Oa(h,"name",{value:n,configurable:!0}),"p$1");const _a=ja(h=>Yo({...h,displayName:h.displayName??"aube-lock.yaml"}),"pruneAubeLockfile");var Ta=Object.defineProperty,Sr=c((h,n)=>Ta(h,"name",{value:n,configurable:!0}),"p");const Ra=Sr(h=>{let n="",m=!1,v=!1,$=!1;for(let a=0;a<h.length;a+=1){const g=h[a],e=h[a+1];if(v){g===`
|
|
2
2
|
`&&(v=!1,n+=g);continue}if($){g==="*"&&e==="/"&&($=!1,a+=1);continue}if(m){if(g==="\\"){n+=g,e!==void 0&&(n+=e,a+=1);continue}g==='"'&&(m=!1),n+=g;continue}if(g==='"'){m=!0,n+=g;continue}if(g==="/"&&e==="/"){v=!0,a+=1;continue}if(g==="/"&&e==="*"){$=!0,a+=1;continue}n+=g}return n},"stripJsonComments"),La=Sr(h=>{const n=[];for(const m of[h.dependencies,h.devDependencies,h.optionalDependencies,h.peerDependencies])if(m)for(const[v,$]of Object.entries(m))typeof $=="string"&&n.push({name:v,spec:$});return n},"collectWorkspaceDeps"),Fa=Sr(h=>{for(const n of h)if(typeof n=="object"&&!Array.isArray(n))return n},"extractMetadata"),Pa=Sr(h=>{if(!h)return[];const n=[];for(const m of["dependencies","optionalDependencies","peerDependencies"]){const v=h[m];v!==null&&typeof v=="object"&&!Array.isArray(v)&&n.push(...Object.keys(v))}return n},"collectMetadataDeps"),Ia=Sr(h=>{if(Buffer.isBuffer(h.lockfileContent))return{message:"bun.lockb is binary; run `bun install --save-text-lockfile` to regenerate as bun.lock, then rerun `vis docker scaffold`.",status:"skipped"};const n=Ra(h.lockfileContent);let m;try{m=JSON.parse(n)}catch(y){throw new ft(`bun.lock: parse failed — ${y.message}`)}if(!m||typeof m!="object")throw new ft("bun.lock: top-level value is not an object");const v=m.workspaces??{},$=m.packages??{},a=new Set([""]);for(const y of h.closure)a.add(y.relativeRoot===""?"":y.relativeRoot);const g={},e=[];for(const[y,E]of Object.entries(v))a.has(y)&&(g[y]=E,e.push(...La(E)));const C=new Set;for(const{name:y}of e)C.add(y);const k=[...C];for(;k.length>0;){const y=k.shift();for(const E of Object.keys($)){if(E.split("/")[0]!==y&&E!==y)continue;const X=Fa($[E]);for(const fe of Pa(X))C.has(fe)||(C.add(fe),k.push(fe))}}const b={};for(const[y,E]of Object.entries($)){const X=y.split("/")[0];(C.has(X)||C.has(y))&&(b[y]=E)}const S={...m,packages:b,workspaces:g},O=Object.keys($).length,H=Object.keys(b).length,A=O-H;return{content:`${JSON.stringify(S,null,2)}
|
|
3
3
|
`,message:`bun.lock: kept ${H}/${O} packages (dropped ${A})`,status:"pruned"}},"pruneBunLockfile");var Na=Object.defineProperty,li=c((h,n)=>Na(h,"name",{value:n,configurable:!0}),"k");const _n="node_modules/",Ma=li((h,n,m)=>{let v=n;for(;;){const $=v===""?`${_n}${m}`:`${v}/${_n}${m}`;if(h[$]!==void 0)return $;if(v==="")return;const a=v.lastIndexOf(`/${_n.slice(0,-1)}/`);v=a===-1?"":v.slice(0,a)}},"resolveDep"),Da=li(h=>{const n=[];for(const m of[h.dependencies,h.devDependencies,h.optionalDependencies,h.peerDependencies])if(m)for(const v of Object.keys(m))n.push(v);return n},"collectDepNames"),qa=li(h=>{const n=h.displayName??"package-lock.json",m=typeof h.lockfileContent=="string"?h.lockfileContent:h.lockfileContent.toString("utf8");let v;try{v=JSON.parse(m)}catch(A){throw new ft(`${n}: parse failed — ${A.message}`)}if(!v||typeof v!="object")throw new ft(`${n}: top-level value is not an object`);const $=v.packages??{},a=new Set([""]);for(const A of h.closure)A.relativeRoot!==""&&a.add(A.relativeRoot);const g=new Set,e=[];for(const A of Object.keys($))a.has(A)&&(g.add(A),e.push(A));for(const[A,y]of Object.entries($))y.link===!0&&typeof y.resolved=="string"&&a.has(y.resolved)&&g.add(A);for(;e.length>0;){const A=e.shift(),y=$[A];if(y)for(const E of Da(y)){const X=Ma($,A,E);if(!X||g.has(X))continue;g.add(X);const fe=$[X];fe.link===!0&&typeof fe.resolved=="string"&&$[fe.resolved]!==void 0&&!g.has(fe.resolved)?(g.add(fe.resolved),e.push(fe.resolved)):e.push(X)}}const C={};for(const A of Object.keys($))g.has(A)&&(C[A]=$[A]);const k=C[""];k&&Array.isArray(k.workspaces)&&(k.workspaces=k.workspaces.filter(A=>{if(typeof A!="string")return!1;const y=A.replace(/\/?\*+$/,"").replace(/\/$/,"");if(y===""||y==="*")return!0;for(const E of a)if(E===A||E===y||E.startsWith(`${y}/`))return!0;return!1}));const b={...v,packages:C};delete b.dependencies;const S=Object.keys($).length,O=Object.keys(C).length,H=S-O;return{content:`${JSON.stringify(b,null,2)}
|
|
4
4
|
`,message:`${n}: kept ${O}/${S} entries (dropped ${H})`,status:"pruned"}},"pruneNpmLockfile");var Tn={},Fe={},Rn,Qi;function Ya(){if(Qi)return Rn;Qi=1;var h=Object.defineProperty,n=c((a,g)=>h(a,"name",{value:g,configurable:!0}),"a");function m(a,g){function e(){this.constructor=a}c(e,"s"),n(e,"ctor"),e.prototype=g.prototype,a.prototype=new e}c(m,"peg$subclass"),n(m,"peg$subclass");function v(a,g,e,C){this.message=a,this.expected=g,this.found=e,this.location=C,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,v)}c(v,"peg$SyntaxError"),n(v,"peg$SyntaxError"),m(v,Error),v.buildMessage=function(a,g){var e={literal:n(function(A){return'"'+k(A.text)+'"'},"literal"),class:n(function(A){var y="",E;for(E=0;E<A.parts.length;E++)y+=A.parts[E]instanceof Array?b(A.parts[E][0])+"-"+b(A.parts[E][1]):b(A.parts[E]);return"["+(A.inverted?"^":"")+y+"]"},"class"),any:n(function(A){return"any character"},"any"),end:n(function(A){return"end of input"},"end"),other:n(function(A){return A.description},"other")};function C(A){return A.charCodeAt(0).toString(16).toUpperCase()}c(C,"T"),n(C,"hex");function k(A){return A.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(y){return"\\x0"+C(y)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(y){return"\\x"+C(y)})}c(k,"q"),n(k,"literalEscape");function b(A){return A.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(y){return"\\x0"+C(y)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(y){return"\\x"+C(y)})}c(b,"_"),n(b,"classEscape");function S(A){return e[A.type](A)}c(S,"re"),n(S,"describeExpectation");function O(A){var y=new Array(A.length),E,X;for(E=0;E<A.length;E++)y[E]=S(A[E]);if(y.sort(),y.length>0){for(E=1,X=1;E<y.length;E++)y[E-1]!==y[E]&&(y[X]=y[E],X++);y.length=X}switch(y.length){case 1:return y[0];case 2:return y[0]+" or "+y[1];default:return y.slice(0,-1).join(", ")+", or "+y[y.length-1]}}c(O,"le"),n(O,"describeExpected");function H(A){return A?'"'+k(A)+'"':"end of input"}return c(H,"te"),n(H,"describeFound"),"Expected "+O(a)+" but "+H(g)+" found."};function $(a,g){g=g!==void 0?g:{};var e={},C={Start:pn},k=pn,b=n(function(t){return t||[]},"peg$c0"),S=n(function(t,o,u){return[{command:t,type:o}].concat(u||[])},"peg$c1"),O=n(function(t,o){return[{command:t,type:o||";"}]},"peg$c2"),H=n(function(t){return t},"peg$c3"),A=";",y=ce(";",!1),E="&",X=ce("&",!1),fe=n(function(t,o){return o?{chain:t,then:o}:{chain:t}},"peg$c8"),oe=n(function(t,o){return{type:t,line:o}},"peg$c9"),T="&&",ne=ce("&&",!1),me="||",U=ce("||",!1),ue=n(function(t,o){return o?{...t,then:o}:t},"peg$c14"),be=n(function(t,o){return{type:t,chain:o}},"peg$c15"),ye="|&",je=ce("|&",!1),Me="|",De=ce("|",!1),qe="=",rt=ce("=",!1),Ee=n(function(t,o){return{name:t,args:[o]}},"peg$c22"),He=n(function(t){return{name:t,args:[]}},"peg$c23"),Ge="(",Qe=ce("(",!1),re=")",Pe=ce(")",!1),We=n(function(t,o){return{type:"subshell",subshell:t,args:o}},"peg$c28"),ke="{",xe=ce("{",!1),$e="}",Le=ce("}",!1),Ae=n(function(t,o){return{type:"group",group:t,args:o}},"peg$c33"),Ye=n(function(t,o){return{type:"command",args:o,envs:t}},"peg$c34"),Ue=n(function(t){return{type:"envs",envs:t}},"peg$c35"),Ve=n(function(t){return t},"peg$c36"),Je=n(function(t){return t},"peg$c37"),q=/^[0-9]/,W=Ze([["0","9"]],!1,!1),se=n(function(t,o,u){return{type:"redirection",subtype:o,fd:t!==null?parseInt(t):null,args:[u]}},"peg$c40"),Ce=">>",nt=ce(">>",!1),at=">&",st=ce(">&",!1),At=">",Ke=ce(">",!1),pt="<<<",et=ce("<<<",!1),ze="<&",dt=ce("<&",!1),bt="<",ht=ce("<",!1),r=n(function(t){return{type:"argument",segments:[].concat(...t)}},"peg$c53"),_=n(function(t){return t},"peg$c54"),R="$'",z=ce("$'",!1),Y="'",l=ce("'",!1),w=n(function(t){return[{type:"text",text:t}]},"peg$c59"),L='""',F=ce('""',!1),D=n(function(){return{type:"text",text:""}},"peg$c62"),V='"',P=ce('"',!1),Z=n(function(t){return t},"peg$c65"),J=n(function(t){return{type:"arithmetic",arithmetic:t,quoted:!0}},"peg$c66"),ie=n(function(t){return{type:"shell",shell:t,quoted:!0}},"peg$c67"),ve=n(function(t){return{type:"variable",...t,quoted:!0}},"peg$c68"),pe=n(function(t){return{type:"text",text:t}},"peg$c69"),_e=n(function(t){return{type:"arithmetic",arithmetic:t,quoted:!1}},"peg$c70"),Qr=n(function(t){return{type:"shell",shell:t,quoted:!1}},"peg$c71"),zr=n(function(t){return{type:"variable",...t,quoted:!1}},"peg$c72"),wr=n(function(t){return{type:"glob",pattern:t}},"peg$c73"),Ut=/^[^']/,Wt=Ze(["'"],!0,!1),wt=n(function(t){return t.join("")},"peg$c76"),kr=/^[^$"]/,xr=Ze(["$",'"'],!0,!1),tr=`\\
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var D=Object.defineProperty;var v=(t,e)=>D(t,"name",{value:e,configurable:!0});import{m as w,D as C,g as S,f as A}from"./provenance-DkCA8BrN.js";import{$ as m}from"../packem_chunks/bin.js";import{x as W}from"./build-scripts-DE6U8jVq.js";import{n as b}from"./license-zZU7aavK.js";import{a as j,C as F,B as U}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{S as E}from"./lockfile-CrT86D6d.js";import{L as N}from"./dependency-scan-BUbOcMwX.js";var I=Object.defineProperty,L=v((t,e)=>I(t,"name",{value:e,configurable:!0}),"i");const g={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},we=L((t,e)=>{const i=g[(t.vulnerability.severity??"UNKNOWN").toUpperCase()]??4,n=g[(e.vulnerability.severity??"UNKNOWN").toUpperCase()]??4;return i-n||t.packageName.localeCompare(e.packageName)||t.packageVersion.localeCompare(e.packageVersion)},"compareFindingsForDisplay"),M=L((t,e)=>{const i=g[e.toUpperCase()]??2;return(g[t.toUpperCase()]??4)<=i},"severityPassesFilter"),P=["firstSeen","installScripts","license","malware","publisherChange","score","unexpectedDeps","vulnerability"];var V=Object.defineProperty,R=v((t,e)=>V(t,"name",{value:e,configurable:!0}),"r");const $=6e4,_=R((t,e,i)=>{for(const n of i)if(n===t||n===`${t}@${e}`||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},"isExcluded"),T=R(async(t,e)=>{const i=e.security?.policies?.firstSeen;if(i?.minutes===void 0||i.minutes<=0)return[];const{minutes:n}=i,a=i.exclude??[],o=e.security?.acceptedRisks,c=n*$,s=Date.now();return(await w(t.packages,C,async r=>{if(_(r.name,r.version,a))return;const l=await S(r.name,{workspaceRoot:t.workspaceRoot});if(l===void 0)return;const p=l.time?.[r.version];if(p===void 0)return;const u=Date.parse(p);if(Number.isNaN(u))return;const f=s-u;if(f>=c)return;const k=Math.max(0,Math.floor(f/$));return{acceptedRisk:m(r.name,r.version,o,"firstSeen"),data:{ageMinutes:k,minimumMinutes:n,publishedAt:p},packageName:r.name,policy:"firstSeen",reason:`${r.name}@${r.version} was published ${String(k)} min ago — below the ${String(n)} min firstSeen cooldown.`,severity:"block",version:r.version}})).filter(r=>r!==void 0)},"evaluateFirstSeenPolicy");var K=Object.defineProperty,H=v((t,e)=>K(t,"name",{value:e,configurable:!0}),"n");const q=H((t,e)=>{const i=e.security?.policies?.installScripts;if(!i)return[];const n=i.allow??{},a=i.strict===!0;if(!a&&Object.keys(n).length===0)return[];const o=W(t.workspaceRoot,n,{pinVersions:e.security?.pinVersions===!0});if(o.unapproved.length===0)return[];const c=e.security?.acceptedRisks,s=a?"block":"warn";return o.unapproved.map(r=>({acceptedRisk:m(r.name,r.version??"*",c,"installScripts"),data:{hooks:r.hooks},packageName:r.name,policy:"installScripts",reason:`${r.name}${r.version?`@${r.version}`:""} declares unapproved build script(s): ${r.hooks.join(", ")}`,severity:s,version:r.version??"*"}))},"evaluateInstallScriptsPolicy");var z=Object.defineProperty,y=v((t,e)=>z(t,"name",{value:e,configurable:!0}),"a");const Y=new Set(["AND","OR"]),B=y(t=>{const e=t.replaceAll("("," ").replaceAll(")"," ").split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0),i=[];let n=!1;for(const a of e){const o=a.toUpperCase();if(n){n=!1;continue}if(o==="WITH"){n=!0;continue}if(Y.has(o))continue;const c=a.endsWith("+"),s=c?a.slice(0,-1):a,r=b(s)??s;i.push(r),c&&i.push(`${r}-or-later`)}return i},"extractSpdxLeaves"),G=y(t=>{if(typeof t.license=="string"){const e=t.license.trim();return e.length>0?e:void 0}if(t.license&&typeof t.license=="object"&&typeof t.license.type=="string"){const e=t.license.type.trim();if(e.length>0)return e}if(Array.isArray(t.licenses)&&t.licenses.length>0){const e=t.licenses.map(i=>i&&typeof i.type=="string"?i.type.trim():"").filter(i=>i.length>0);if(e.length>0)return e.length===1?e[0]:`(${e.join(" OR ")})`}},"declaredLicense"),J=y((t,e)=>{if(e.length===0)return;const i=new Set(e.map(n=>b(n)??n).map(n=>n.toLowerCase()));for(const n of t)if(i.has(n.toLowerCase()))return n},"findDeniedLeaf"),Q=y((t,e)=>{if(e.length===0)return;const i=new Set(e.map(n=>b(n)??n).map(n=>n.toLowerCase()));for(const n of t)if(!i.has(n.toLowerCase()))return n},"findUnallowedLeaf"),X=y((t,e)=>{const i=e.security?.policies?.license;if(!i)return[];const n=i.allow??[],a=i.deny??[];if(n.length===0&&a.length===0)return[];const o=e.security?.acceptedRisks,c=[];for(const s of t.packages){const r=t.manifestData?.get(`${s.name}@${s.version}`),l=r?G(r):void 0;if(!l){n.length>0&&c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{declaredLicense:null},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} declares no license; allow-list mode requires one of: ${n.join(", ")}`,severity:"block",version:s.version});continue}const p=B(l),u=J(p,a);if(u){c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{declaredLicense:l,deniedLicense:u},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} uses denied license '${u}' (declared: ${l})`,severity:"block",version:s.version});continue}const f=Q(p,n);f&&c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{allowList:n,declaredLicense:l,unallowedLicense:f},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} uses license '${f}' which is not on the allow-list (declared: ${l})`,severity:"block",version:s.version})}return c},"evaluateLicensePolicy");var Z=Object.defineProperty,O=v((t,e)=>Z(t,"name",{value:e,configurable:!0}),"c$1");const ee=6e4,te=O((t,e,i)=>{for(const n of i)if(n===t||n===`${t}@${e}`||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},"isExcluded"),ie=O(async(t,e)=>{const i=e.security?.policies?.publisherChange;if(i?.mode!=="no-downgrade")return[];const n=i.exclude??[],a=typeof i.ignoreAfter=="number"?i.ignoreAfter*ee:void 0,o=e.security?.acceptedRisks,c=Date.now();return(await w(t.packages,C,async s=>{if(te(s.name,s.version,n))return;const r=await S(s.name,{workspaceRoot:t.workspaceRoot});if(r===void 0)return;if(a!==void 0){const p=r.time?.[s.version],u=p===void 0?Number.NaN:Date.parse(p);if(!Number.isNaN(u)&&c-u>a)return}if(r.versions[s.version]?.dist?.attestations?.provenance!==void 0)return;const l=A(r,s.version);if(l!==void 0)return{acceptedRisk:m(s.name,s.version,o,"publisherChange"),data:{priorVersionWithProvenance:l},packageName:s.name,policy:"publisherChange",reason:`${s.name}@${s.version} dropped the provenance attestation that ${s.name}@${l} carried — publisher trust downgrade.`,severity:"block",version:s.version}})).filter(s=>s!==void 0)},"evaluatePublisherChangePolicy");var ne=Object.defineProperty,h=v((t,e)=>ne(t,"name",{value:e,configurable:!0}),"l$1");const se=h(t=>{for(const e of Object.values(N))for(const i of[e.file,...e.aliases??[]])if(t===i||t.endsWith(`/${i}`)||t.endsWith(`.${i}`))return e.type},"detectLockfileType"),re=h((t,e,i)=>{const n=j(e)?e:F(t,e);let a;try{a=U(n)}catch{return}const o=se(n)??N[i]?.type;if(!o)return;const c=E(a,o);if(c.length===0)return;const s=new Set;for(const r of c)s.add(`${r.name}@${r.version}`);return s},"loadBaselineKeys"),oe=h((t,e)=>{for(const i of e)if(i===t||i.endsWith("*")&&t.startsWith(i.slice(0,-1)))return!0;return!1},"matchesAllowList"),ae=h((t,e)=>{const i=e.security?.policies?.unexpectedDeps;if(!i)return[];const n=i.allow??[],a=i.baselineLockfile;if(n.length===0&&!a)return[];const o=a?re(t.workspaceRoot,a,t.packageManager):void 0,c=e.security?.acceptedRisks,s=[];for(const r of t.packages){const l=n.length===0||oe(r.name,n),p=o?o.has(`${r.name}@${r.version}`):!0;if(l&&p)continue;const u=[],f={};l||(u.push(`not on allow-list (${n.length} entr${n.length===1?"y":"ies"})`),f.allowList=n),!p&&o&&(u.push(`not present in baseline lockfile (${a})`),f.baselineLockfile=a),s.push({acceptedRisk:m(r.name,r.version,c,"unexpectedDeps"),data:f,packageName:r.name,policy:"unexpectedDeps",reason:`${r.name}@${r.version} is unexpected: ${u.join("; ")}`,severity:"block",version:r.version})}return s},"evaluateUnexpectedDepsPolicy");var ce=Object.defineProperty,le=v((t,e)=>ce(t,"name",{value:e,configurable:!0}),"c");const ue=le((t,e)=>{if(!t.osvFindings||t.osvFindings.size===0)return[];const i=e.security?.policies?.vulnerability?.failOn,n=e.security?.acceptedRisks,a=[];for(const o of t.packages){const c=t.osvFindings.get(o.name);if(!(!c||c.length===0))for(const s of c){const r=i?M(s.severity,i)?"block":"warn":"info";a.push({acceptedRisk:m(o.name,o.version,n,"vulnerability"),data:{advisoryId:s.id,aliases:s.aliases??[],cvssScore:s.cvssScore,fixedVersions:s.fixedVersions,severity:s.severity,summary:s.summary},packageName:o.name,policy:"vulnerability",reason:`${s.severity} ${s.id} affects ${o.name}@${o.version}: ${s.summary}`,severity:r,version:o.version})}}return a},"evaluateVulnerabilityPolicy");var pe=Object.defineProperty,d=v((t,e)=>pe(t,"name",{value:e,configurable:!0}),"t");const x=[{evaluate:ue,isConfigured:d(t=>t.security?.policies?.vulnerability!==void 0,"isConfigured"),name:"vulnerability",offlineSupported:!0,surfaces:["audit","doctor"]},{evaluate:X,isConfigured:d(t=>{const e=t.security?.policies?.license;return!!(e&&(e.allow&&e.allow.length>0||e.deny&&e.deny.length>0))},"isConfigured"),name:"license",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:q,isConfigured:d(t=>{const e=t.security?.policies?.installScripts;return!!(e&&(e.allow&&Object.keys(e.allow).length>0||e.strict===!0))},"isConfigured"),name:"installScripts",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:ae,isConfigured:d(t=>{const e=t.security?.policies?.unexpectedDeps;return!!(e&&(e.allow&&e.allow.length>0||typeof e.baselineLockfile=="string"))},"isConfigured"),name:"unexpectedDeps",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:T,isConfigured:d(t=>{const e=t.security?.policies?.firstSeen?.minutes;return typeof e=="number"&&e>0},"isConfigured"),name:"firstSeen",offlineSupported:!1,surfaces:["audit","doctor","install"]},{evaluate:ie,isConfigured:d(t=>t.security?.policies?.publisherChange?.mode==="no-downgrade","isConfigured"),name:"publisherChange",offlineSupported:!1,surfaces:["audit","doctor","install"]}],fe=d((t,e,i)=>x.filter(n=>n.surfaces.includes(t)?i!==void 0?i.has(n.name):n.isConfigured(e):!1),"selectModules"),Ce=d(async(t,e,i)=>{const n=fe(e,i.visConfig,i.enabledPolicies),a=[];for(const o of n){if(t.offline&&!o.offlineSupported){a.push({packageName:"*",policy:o.name,reason:`policy.${o.name} skipped: requires network (--offline)`,severity:"info",version:"*"});continue}try{const c=await o.evaluate(t,i.visConfig);a.push(...c)}catch(c){const s=c instanceof Error?c.message:String(c);a.push({packageName:"*",policy:o.name,reason:`policy.${o.name} failed: ${s}`,severity:"info",version:"*"})}}return a},"evaluatePolicies"),de=(()=>{const t=new Map;for(const e of P)t.set(e.toLowerCase(),e);return t})(),Se=d(()=>x.map(t=>t.name),"getRegisteredPolicyNames"),Ne=d((t,e)=>{if(t===void 0)return;const i=t.trim().toLowerCase();if(i===""||i==="none")return new Set;if(i==="all")return new Set(P);const n=new Set;for(const a of t.split(",").map(o=>o.trim()).filter(o=>o.length>0)){const o=a.replace(/^_+/,"").replaceAll(/_+([a-z])/g,(s,r)=>r.toUpperCase()),c=de.get(o.toLowerCase());c===void 0?e?.(a):n.add(c)}return n},"parsePoliciesFlag");export{we as c,Ce as e,Se as g,Ne as p,M as s};
|
|
1
|
+
var D=Object.defineProperty;var v=(t,e)=>D(t,"name",{value:e,configurable:!0});import{m as w,D as C,g as S,f as A}from"./provenance-D8vU1u2L.js";import{$ as m}from"../packem_chunks/bin.js";import{x as W}from"./build-scripts-DE6U8jVq.js";import{n as b}from"./license-zZU7aavK.js";import{a as j,C as F,B as U}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{S as E}from"./lockfile-CrT86D6d.js";import{L as N}from"./dependency-scan-BUbOcMwX.js";var I=Object.defineProperty,L=v((t,e)=>I(t,"name",{value:e,configurable:!0}),"i");const g={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},we=L((t,e)=>{const i=g[(t.vulnerability.severity??"UNKNOWN").toUpperCase()]??4,n=g[(e.vulnerability.severity??"UNKNOWN").toUpperCase()]??4;return i-n||t.packageName.localeCompare(e.packageName)||t.packageVersion.localeCompare(e.packageVersion)},"compareFindingsForDisplay"),M=L((t,e)=>{const i=g[e.toUpperCase()]??2;return(g[t.toUpperCase()]??4)<=i},"severityPassesFilter"),P=["firstSeen","installScripts","license","malware","publisherChange","score","unexpectedDeps","vulnerability"];var V=Object.defineProperty,R=v((t,e)=>V(t,"name",{value:e,configurable:!0}),"r");const $=6e4,_=R((t,e,i)=>{for(const n of i)if(n===t||n===`${t}@${e}`||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},"isExcluded"),T=R(async(t,e)=>{const i=e.security?.policies?.firstSeen;if(i?.minutes===void 0||i.minutes<=0)return[];const{minutes:n}=i,a=i.exclude??[],o=e.security?.acceptedRisks,c=n*$,s=Date.now();return(await w(t.packages,C,async r=>{if(_(r.name,r.version,a))return;const l=await S(r.name,{workspaceRoot:t.workspaceRoot});if(l===void 0)return;const p=l.time?.[r.version];if(p===void 0)return;const u=Date.parse(p);if(Number.isNaN(u))return;const f=s-u;if(f>=c)return;const k=Math.max(0,Math.floor(f/$));return{acceptedRisk:m(r.name,r.version,o,"firstSeen"),data:{ageMinutes:k,minimumMinutes:n,publishedAt:p},packageName:r.name,policy:"firstSeen",reason:`${r.name}@${r.version} was published ${String(k)} min ago — below the ${String(n)} min firstSeen cooldown.`,severity:"block",version:r.version}})).filter(r=>r!==void 0)},"evaluateFirstSeenPolicy");var K=Object.defineProperty,H=v((t,e)=>K(t,"name",{value:e,configurable:!0}),"n");const q=H((t,e)=>{const i=e.security?.policies?.installScripts;if(!i)return[];const n=i.allow??{},a=i.strict===!0;if(!a&&Object.keys(n).length===0)return[];const o=W(t.workspaceRoot,n,{pinVersions:e.security?.pinVersions===!0});if(o.unapproved.length===0)return[];const c=e.security?.acceptedRisks,s=a?"block":"warn";return o.unapproved.map(r=>({acceptedRisk:m(r.name,r.version??"*",c,"installScripts"),data:{hooks:r.hooks},packageName:r.name,policy:"installScripts",reason:`${r.name}${r.version?`@${r.version}`:""} declares unapproved build script(s): ${r.hooks.join(", ")}`,severity:s,version:r.version??"*"}))},"evaluateInstallScriptsPolicy");var z=Object.defineProperty,y=v((t,e)=>z(t,"name",{value:e,configurable:!0}),"a");const Y=new Set(["AND","OR"]),B=y(t=>{const e=t.replaceAll("("," ").replaceAll(")"," ").split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0),i=[];let n=!1;for(const a of e){const o=a.toUpperCase();if(n){n=!1;continue}if(o==="WITH"){n=!0;continue}if(Y.has(o))continue;const c=a.endsWith("+"),s=c?a.slice(0,-1):a,r=b(s)??s;i.push(r),c&&i.push(`${r}-or-later`)}return i},"extractSpdxLeaves"),G=y(t=>{if(typeof t.license=="string"){const e=t.license.trim();return e.length>0?e:void 0}if(t.license&&typeof t.license=="object"&&typeof t.license.type=="string"){const e=t.license.type.trim();if(e.length>0)return e}if(Array.isArray(t.licenses)&&t.licenses.length>0){const e=t.licenses.map(i=>i&&typeof i.type=="string"?i.type.trim():"").filter(i=>i.length>0);if(e.length>0)return e.length===1?e[0]:`(${e.join(" OR ")})`}},"declaredLicense"),J=y((t,e)=>{if(e.length===0)return;const i=new Set(e.map(n=>b(n)??n).map(n=>n.toLowerCase()));for(const n of t)if(i.has(n.toLowerCase()))return n},"findDeniedLeaf"),Q=y((t,e)=>{if(e.length===0)return;const i=new Set(e.map(n=>b(n)??n).map(n=>n.toLowerCase()));for(const n of t)if(!i.has(n.toLowerCase()))return n},"findUnallowedLeaf"),X=y((t,e)=>{const i=e.security?.policies?.license;if(!i)return[];const n=i.allow??[],a=i.deny??[];if(n.length===0&&a.length===0)return[];const o=e.security?.acceptedRisks,c=[];for(const s of t.packages){const r=t.manifestData?.get(`${s.name}@${s.version}`),l=r?G(r):void 0;if(!l){n.length>0&&c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{declaredLicense:null},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} declares no license; allow-list mode requires one of: ${n.join(", ")}`,severity:"block",version:s.version});continue}const p=B(l),u=J(p,a);if(u){c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{declaredLicense:l,deniedLicense:u},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} uses denied license '${u}' (declared: ${l})`,severity:"block",version:s.version});continue}const f=Q(p,n);f&&c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{allowList:n,declaredLicense:l,unallowedLicense:f},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} uses license '${f}' which is not on the allow-list (declared: ${l})`,severity:"block",version:s.version})}return c},"evaluateLicensePolicy");var Z=Object.defineProperty,O=v((t,e)=>Z(t,"name",{value:e,configurable:!0}),"c$1");const ee=6e4,te=O((t,e,i)=>{for(const n of i)if(n===t||n===`${t}@${e}`||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},"isExcluded"),ie=O(async(t,e)=>{const i=e.security?.policies?.publisherChange;if(i?.mode!=="no-downgrade")return[];const n=i.exclude??[],a=typeof i.ignoreAfter=="number"?i.ignoreAfter*ee:void 0,o=e.security?.acceptedRisks,c=Date.now();return(await w(t.packages,C,async s=>{if(te(s.name,s.version,n))return;const r=await S(s.name,{workspaceRoot:t.workspaceRoot});if(r===void 0)return;if(a!==void 0){const p=r.time?.[s.version],u=p===void 0?Number.NaN:Date.parse(p);if(!Number.isNaN(u)&&c-u>a)return}if(r.versions[s.version]?.dist?.attestations?.provenance!==void 0)return;const l=A(r,s.version);if(l!==void 0)return{acceptedRisk:m(s.name,s.version,o,"publisherChange"),data:{priorVersionWithProvenance:l},packageName:s.name,policy:"publisherChange",reason:`${s.name}@${s.version} dropped the provenance attestation that ${s.name}@${l} carried — publisher trust downgrade.`,severity:"block",version:s.version}})).filter(s=>s!==void 0)},"evaluatePublisherChangePolicy");var ne=Object.defineProperty,h=v((t,e)=>ne(t,"name",{value:e,configurable:!0}),"l$1");const se=h(t=>{for(const e of Object.values(N))for(const i of[e.file,...e.aliases??[]])if(t===i||t.endsWith(`/${i}`)||t.endsWith(`.${i}`))return e.type},"detectLockfileType"),re=h((t,e,i)=>{const n=j(e)?e:F(t,e);let a;try{a=U(n)}catch{return}const o=se(n)??N[i]?.type;if(!o)return;const c=E(a,o);if(c.length===0)return;const s=new Set;for(const r of c)s.add(`${r.name}@${r.version}`);return s},"loadBaselineKeys"),oe=h((t,e)=>{for(const i of e)if(i===t||i.endsWith("*")&&t.startsWith(i.slice(0,-1)))return!0;return!1},"matchesAllowList"),ae=h((t,e)=>{const i=e.security?.policies?.unexpectedDeps;if(!i)return[];const n=i.allow??[],a=i.baselineLockfile;if(n.length===0&&!a)return[];const o=a?re(t.workspaceRoot,a,t.packageManager):void 0,c=e.security?.acceptedRisks,s=[];for(const r of t.packages){const l=n.length===0||oe(r.name,n),p=o?o.has(`${r.name}@${r.version}`):!0;if(l&&p)continue;const u=[],f={};l||(u.push(`not on allow-list (${n.length} entr${n.length===1?"y":"ies"})`),f.allowList=n),!p&&o&&(u.push(`not present in baseline lockfile (${a})`),f.baselineLockfile=a),s.push({acceptedRisk:m(r.name,r.version,c,"unexpectedDeps"),data:f,packageName:r.name,policy:"unexpectedDeps",reason:`${r.name}@${r.version} is unexpected: ${u.join("; ")}`,severity:"block",version:r.version})}return s},"evaluateUnexpectedDepsPolicy");var ce=Object.defineProperty,le=v((t,e)=>ce(t,"name",{value:e,configurable:!0}),"c");const ue=le((t,e)=>{if(!t.osvFindings||t.osvFindings.size===0)return[];const i=e.security?.policies?.vulnerability?.failOn,n=e.security?.acceptedRisks,a=[];for(const o of t.packages){const c=t.osvFindings.get(o.name);if(!(!c||c.length===0))for(const s of c){const r=i?M(s.severity,i)?"block":"warn":"info";a.push({acceptedRisk:m(o.name,o.version,n,"vulnerability"),data:{advisoryId:s.id,aliases:s.aliases??[],cvssScore:s.cvssScore,fixedVersions:s.fixedVersions,severity:s.severity,summary:s.summary},packageName:o.name,policy:"vulnerability",reason:`${s.severity} ${s.id} affects ${o.name}@${o.version}: ${s.summary}`,severity:r,version:o.version})}}return a},"evaluateVulnerabilityPolicy");var pe=Object.defineProperty,d=v((t,e)=>pe(t,"name",{value:e,configurable:!0}),"t");const x=[{evaluate:ue,isConfigured:d(t=>t.security?.policies?.vulnerability!==void 0,"isConfigured"),name:"vulnerability",offlineSupported:!0,surfaces:["audit","doctor"]},{evaluate:X,isConfigured:d(t=>{const e=t.security?.policies?.license;return!!(e&&(e.allow&&e.allow.length>0||e.deny&&e.deny.length>0))},"isConfigured"),name:"license",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:q,isConfigured:d(t=>{const e=t.security?.policies?.installScripts;return!!(e&&(e.allow&&Object.keys(e.allow).length>0||e.strict===!0))},"isConfigured"),name:"installScripts",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:ae,isConfigured:d(t=>{const e=t.security?.policies?.unexpectedDeps;return!!(e&&(e.allow&&e.allow.length>0||typeof e.baselineLockfile=="string"))},"isConfigured"),name:"unexpectedDeps",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:T,isConfigured:d(t=>{const e=t.security?.policies?.firstSeen?.minutes;return typeof e=="number"&&e>0},"isConfigured"),name:"firstSeen",offlineSupported:!1,surfaces:["audit","doctor","install"]},{evaluate:ie,isConfigured:d(t=>t.security?.policies?.publisherChange?.mode==="no-downgrade","isConfigured"),name:"publisherChange",offlineSupported:!1,surfaces:["audit","doctor","install"]}],fe=d((t,e,i)=>x.filter(n=>n.surfaces.includes(t)?i!==void 0?i.has(n.name):n.isConfigured(e):!1),"selectModules"),Ce=d(async(t,e,i)=>{const n=fe(e,i.visConfig,i.enabledPolicies),a=[];for(const o of n){if(t.offline&&!o.offlineSupported){a.push({packageName:"*",policy:o.name,reason:`policy.${o.name} skipped: requires network (--offline)`,severity:"info",version:"*"});continue}try{const c=await o.evaluate(t,i.visConfig);a.push(...c)}catch(c){const s=c instanceof Error?c.message:String(c);a.push({packageName:"*",policy:o.name,reason:`policy.${o.name} failed: ${s}`,severity:"info",version:"*"})}}return a},"evaluatePolicies"),de=(()=>{const t=new Map;for(const e of P)t.set(e.toLowerCase(),e);return t})(),Se=d(()=>x.map(t=>t.name),"getRegisteredPolicyNames"),Ne=d((t,e)=>{if(t===void 0)return;const i=t.trim().toLowerCase();if(i===""||i==="none")return new Set;if(i==="all")return new Set(P);const n=new Set;for(const a of t.split(",").map(o=>o.trim()).filter(o=>o.length>0)){const o=a.replace(/^_+/,"").replaceAll(/_+([a-z])/g,(s,r)=>r.toUpperCase()),c=de.get(o.toLowerCase());c===void 0?e?.(a):n.add(c)}return n},"parsePoliciesFlag");export{we as c,Ce as e,Se as g,Ne as p,M as s};
|
|
@@ -27,4 +27,4 @@ ${en(i,e,n+1,o)}`),`
|
|
|
27
27
|
${s}`},"getCause"),ar=L((t,e)=>(t.length>0?`
|
|
28
28
|
`:"")+t.map(n=>Ve(n,e)).join(`
|
|
29
29
|
`),"getStacktrace"),tn=L((t,e,n)=>{const o={cwd:nr(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...e,color:{fileLine:L(a=>a,"fileLine"),gutter:L(a=>a,"gutter"),hint:L(a=>a,"hint"),marker:L(a=>a,"marker"),message:L(a=>a,"message"),method:L(a=>a,"method"),title:L(a=>a,"title"),...e.color}},s=Jt(t,{filter:e.filterStacktrace,frameLimit:o.framesMaxLimit}),i=s.shift();return[e.hideMessage?void 0:Yt(t,o,n),Zt(t,o,n),i?Ve(i,o,n):void 0,i&&!o.hideErrorCodeView?Qt(i,o,n):void 0,t instanceof AggregateError?Xt(t,o,n):void 0,t.cause===void 0?void 0:en(t,o,n),s.length>0?ar(s,o):void 0].filter(Boolean).join(`
|
|
30
|
-
`).replaceAll("\\","/")},"internalRenderError"),lr=L((t,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return tn(t,e,0)},"renderError");var cr=Object.defineProperty,mt=_((t,e)=>cr(t,"name",{value:e,configurable:!0}),"i$1");const kr=mt((t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:mt((e,n)=>{const{logger:o,runtime:s}=n,{detailed:i=!1,exitOnError:a=!0,formatter:l,logErrors:h=!0,renderOptions:r={}}=t;if(h)if(l)o.error(l(e));else if(i){const c=s.getCwd(),m=lr(e,{cwd:c,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...r});o.error(m)}else o.error(e);a&&z(1)},"onError"),version:"1.0.0"}),"E");var ur="1.0.0-alpha.
|
|
30
|
+
`).replaceAll("\\","/")},"internalRenderError"),lr=L((t,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return tn(t,e,0)},"renderError");var cr=Object.defineProperty,mt=_((t,e)=>cr(t,"name",{value:e,configurable:!0}),"i$1");const kr=mt((t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:mt((e,n)=>{const{logger:o,runtime:s}=n,{detailed:i=!1,exitOnError:a=!0,formatter:l,logErrors:h=!0,renderOptions:r={}}=t;if(h)if(l)o.error(l(e));else if(i){const c=s.getCwd(),m=lr(e,{cwd:c,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...r});o.error(m)}else o.error(e);a&&z(1)},"onError"),version:"1.0.0"}),"E");var ur="1.0.0-alpha.31";const Or={version:ur};var pr=Object.defineProperty,hr=_((t,e)=>pr(t,"name",{value:e,configurable:!0}),"e");const Cr={argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"],["vis install && vis dlx --offline typescript tsc --version","Hardened: pre-install + offline (no registry fetch on dlx)"]],group:"Run & Execute",loader:hr(()=>import("../packem_chunks/handler9.js"),"loader"),name:"dlx",options:[{alias:"p",description:"Additional packages to install (repeatable)",multiple:!0,name:"package",type:String},{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output except command results",name:"silent",type:Boolean},{defaultValue:!1,description:"Resolve from local store only — fail rather than fetch from the registry. Pair with `vis install` for hardened npx-style workflows.",name:"offline",type:Boolean}]};export{Er as $,vr as E,Nr as I,Ar as a,G as b,yr as c,k as d,q as h,Cr as i,Or as m,kr as p};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var z=Object.defineProperty;var n=(t,e)=>z(t,"name",{value:e,configurable:!0});import{createRequire as Q}from"node:module";import{n as tt,M as w}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{
|
|
2
|
-
`,{mode:R});try{await It(r,s)}catch(i){throw await T(r,{force:!0}).catch(()=>{}),i}},"writeEntry"),xt=new Set(["EACCES","EBUSY","EPERM"]),Ct=8,At=20,It=h(async(t,e)=>{let o=0;for(;;)try{await it(t,e);return}catch(s){const{code:r}=s;if(!(r!==void 0&&xt.has(r))||o>=Ct)throw s;const i=At*2**o;await new Promise(c=>{setTimeout(c,i)}),o+=1}},"renameWithRetry"),
|
|
1
|
+
var z=Object.defineProperty;var n=(t,e)=>z(t,"name",{value:e,configurable:!0});import{createRequire as Q}from"node:module";import{n as tt,M as w}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{f as j}from"../packem_chunks/config.js";import{aT as ht,U as dt,aU as L}from"../packem_chunks/bin.js";import{withEnhancedPath as wt}from"@visulima/task-runner";const Z=Q(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=n(t=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[e,o]=m.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return m.getBuiltinModule(t)}return Z(t)},"__cjs_getBuiltinModule"),{Socket:et}=p("node:net"),{randomBytes:ot}=p("node:crypto"),{readdir:st,writeFile:rt,rm:T,rename:it,open:nt,readFile:at,stat:ct,unlink:O}=p("node:fs/promises"),{createRequire:lt}=p("node:module"),{spawn:ft}=p("node:child_process"),{openSync:ut,closeSync:pt}=p("node:fs");var kt=Object.defineProperty,W=n((t,e)=>kt(t,"name",{value:e,configurable:!0}),"s$2");const mt=lt(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,yt=W(t=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[e,o]=y.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return y.getBuiltinModule(t)}return mt(t)},"a"),{lstat:x,mkdir:vt}=yt("node:fs/promises"),gt=W(async t=>{tt(t);try{const e=await x(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(j(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await vt(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const o=await x(t);if(!o.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(j(o))}'`,{cause:e})}},"m");var _t=Object.defineProperty,f=n((t,e)=>_t(t,"name",{value:e,configurable:!0}),"s$1");const bt=3e4,N=100;class Et extends Error{static{n(this,"ServiceReadinessError")}constructor(e,o){super(e),this.elapsedMs=o,this.name="ServiceReadinessError"}elapsedMs;static{f(this,"ServiceReadinessError")}}const $t=f(async t=>{const e=t.host??"127.0.0.1",{port:o}=t,s=t.timeoutMs??bt,r=Date.now();for(;Date.now()-r<s;){if(await St(e,o))return;await Ht(N)}throw new Et(`Timed out waiting for ${e}:${String(o)} to accept TCP connections (${String(s)}ms)`,Date.now()-r)},"waitForTcp"),St=f((t,e)=>new Promise(o=>{const s=new et,r=f(i=>{s.removeAllListeners(),s.destroy(),o(i)},"onDone");s.once("connect",()=>{r(!0)}),s.once("error",()=>{r(!1)}),s.setTimeout(N,()=>{r(!1)});try{s.connect(e,t)}catch{r(!1)}}),"tryConnect"),Ht=f(t=>new Promise(e=>{setTimeout(e,t)}),"delay"),Pt=f(async(t,e)=>{const o=t.readiness??(t.port===void 0?void 0:{tcp:{port:t.port}});o&&await $t({host:o.tcp.host,port:o.tcp.port,timeoutMs:e?.timeoutMs??o.tcp.timeoutMs})},"runReadiness");var Tt=Object.defineProperty,h=n((t,e)=>Tt(t,"name",{value:e,configurable:!0}),"o");const R=384,C=5e3,Rt=50,Mt=3e4,k=h(async t=>{const e=w(ht(t),"services");try{await gt(e)}catch(o){throw o.code==="ENOTDIR"?new Error(`Service registry path ${e} exists but is not a directory. Remove it or move the conflicting file before running \`vis service\`.`,{cause:o}):o}return e},"getRegistryDir"),M=h(t=>t.replaceAll("/","_").replaceAll(":","__"),"slugify"),D=h((t,e)=>w(t,`${M(e)}.json`),"entryPath"),Dt=h((t,e)=>w(t,`${M(e)}.lock`),"lockPath"),b=h(async(t,e)=>{const o=await k(t),s=D(o,e);if(await dt(s))try{return await L(s)}catch{return}},"readEntry"),Ot=h(async t=>{const e=await k(t);let o;try{o=await st(e)}catch{return[]}const s=[];for(const r of o)if(r.endsWith(".json"))try{const i=await L(w(e,r));s.push(i)}catch{}return s},"readAllEntries"),jt=h(async(t,e)=>{const o=await k(t),s=D(o,e.id),r=w(o,`.${ot(8).toString("hex")}.tmp`);await rt(r,`${JSON.stringify(e,void 0,2)}
|
|
2
|
+
`,{mode:R});try{await It(r,s)}catch(i){throw await T(r,{force:!0}).catch(()=>{}),i}},"writeEntry"),xt=new Set(["EACCES","EBUSY","EPERM"]),Ct=8,At=20,It=h(async(t,e)=>{let o=0;for(;;)try{await it(t,e);return}catch(s){const{code:r}=s;if(!(r!==void 0&&xt.has(r))||o>=Ct)throw s;const i=At*2**o;await new Promise(c=>{setTimeout(c,i)}),o+=1}},"renameWithRetry"),v=h(async(t,e,o)=>{const s=await k(t),r=o??await b(t,e);await T(D(s,e),{force:!0}),r&&await T(r.logFile,{force:!0}).catch(()=>{})},"deleteEntry"),u=h(t=>{try{return process.kill(t,0),!0}catch{return!1}},"isAlive"),ie=h(async t=>{const e=await Ot(t),o=[],s=[];for(const r of e){if(u(r.pid)){s.push(r);continue}const i=await b(t,r.id);if(i&&i.pid!==r.pid){s.push(i);continue}await v(t,r.id,r).catch(()=>{}),o.push(r.id)}return{pruned:o,surviving:s}},"pruneDead"),Ft=h(t=>new Promise(e=>{setTimeout(e,t)}),"sleep"),Lt=h(async t=>{try{const e=await nt(t,"wx",R);try{await e.writeFile(String(process.pid))}finally{await e.close().catch(()=>{})}return!0}catch(e){if(e.code==="EEXIST")return!1;throw e}},"tryClaimLock"),Wt=h(async t=>{let e;try{const o=await at(t,"utf8"),s=Number.parseInt(o.trim(),10);e=Number.isFinite(s)?s:void 0}catch{return!0}if(e!==void 0&&!u(e))return!0;try{const o=await ct(t);return Date.now()-o.mtimeMs>Mt}catch{return!0}},"isLockStale"),B=h(async(t,e,o)=>{const s=await k(t),r=Dt(s,e),i=Date.now();for(;!await Lt(r);){if(await Wt(r)){await O(r).catch(()=>{});continue}if(Date.now()-i>=C)throw new Error(`Could not acquire service lock for ${e} within ${String(C)}ms — another \`vis service\` invocation appears to be holding it.`);await Ft(Rt)}try{return await o()}finally{await O(r).catch(()=>{})}},"withServiceLock");var Nt=Object.defineProperty,l=n((t,e)=>Nt(t,"name",{value:e,configurable:!0}),"r");function g(t,e={},o){for(const s in t){const r=t[s],i=o?`${o}:${s}`:s;typeof r=="object"&&r!==null?g(r,e,i):typeof r=="function"&&(e[i]=r)}return e}n(g,"c");l(g,"flatHooks");function Bt(...t){const e={};for(const o of t){const s=g(o);for(const r in s)e[r]?e[r].push(s[r]):e[r]=[s[r]]}for(const o in e)if(e[o].length>1){const s=e[o];e[o]=(...r)=>G(s,i=>i(...r))}else e[o]=e[o][0];return e}n(Bt,"v");l(Bt,"mergeHooks");function G(t,e){return t.reduce((o,s)=>o.then(()=>e(s)),Promise.resolve())}n(G,"d$1");l(G,"serial");const V=(()=>{if(console.createTask)return console.createTask;const t={run:l(e=>e(),"run")};return()=>t})();function E(t,e,o,s){for(let r=o;r<t.length;r+=1)try{const i=s?s.run(()=>t[r](...e)):t[r](...e);if(i&&typeof i.then=="function")return Promise.resolve(i).then(()=>E(t,e,r+1,s))}catch(i){return Promise.reject(i)}}n(E,"k");l(E,"callHooks");function q(t,e,o){if(t.length>0)return E(t,e,0,V(o))}n(q,"y");l(q,"serialTaskCaller");function U(t,e,o){if(t.length>0){const s=V(o);return Promise.all(t.map(r=>s.run(()=>r(...e))))}}n(U,"m");l(U,"parallelTaskCaller");function Gt(t,e){return t.reduce((o,s)=>o.then(()=>s(...e||[])),Promise.resolve())}n(Gt,"x");l(Gt,"serialCaller");function Vt(t,e){return Promise.all(t.map(o=>o(...e||[])))}n(Vt,"P");l(Vt,"parallelCaller");function _(t,e){for(const o of[...t])o(e)}n(_,"a");l(_,"callEachWith");var qt=class{static{n(this,"p")}static{l(this,"Hookable")}_hooks;_before;_after;_deprecatedHooks;_deprecatedMessages;constructor(){this._hooks={},this._before=void 0,this._after=void 0,this._deprecatedMessages=void 0,this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this),this.callHookWith=this.callHookWith.bind(this)}hook(t,e,o={}){if(!t||typeof e!="function")return()=>{};const s=t;let r;for(;this._deprecatedHooks[t];)r=this._deprecatedHooks[t],t=r.to;if(r&&!o.allowDeprecated){let i=r.message;i||(i=`${s} hook has been deprecated`+(r.to?`, please use ${r.to}`:"")),this._deprecatedMessages||(this._deprecatedMessages=new Set),this._deprecatedMessages.has(i)||(console.warn(i),this._deprecatedMessages.add(i))}if(!e.name)try{Object.defineProperty(e,"name",{get:l(()=>"_"+t.replace(/\W+/g,"_")+"_hook_cb","get"),configurable:!0})}catch{}return this._hooks[t]=this._hooks[t]||[],this._hooks[t].push(e),()=>{e&&(this.removeHook(t,e),e=void 0)}}hookOnce(t,e){let o,s=l((...r)=>(typeof o=="function"&&o(),o=void 0,s=void 0,e(...r)),"_function");return o=this.hook(t,s),o}removeHook(t,e){const o=this._hooks[t];if(o){const s=o.indexOf(e);s!==-1&&o.splice(s,1),o.length===0&&(this._hooks[t]=void 0)}}clearHook(t){this._hooks[t]=void 0}deprecateHook(t,e){this._deprecatedHooks[t]=typeof e=="string"?{to:e}:e;const o=this._hooks[t]||[];this._hooks[t]=void 0;for(const s of o)this.hook(t,s)}deprecateHooks(t){for(const e in t)this.deprecateHook(e,t[e])}addHooks(t){const e=g(t),o=Object.keys(e).map(s=>this.hook(s,e[s]));return()=>{for(const s of o)s();o.length=0}}removeHooks(t){const e=g(t);for(const o in e)this.removeHook(o,e[o])}removeAllHooks(){this._hooks={}}callHook(t,...e){return this.callHookWith(q,t,e)}callHookParallel(t,...e){return this.callHookWith(U,t,e)}callHookWith(t,e,o){const s=this._before||this._after?{name:e,args:o,context:{}}:void 0;this._before&&_(this._before,s);const r=t(this._hooks[e]?[...this._hooks[e]]:[],o,e);return r instanceof Promise?r.finally(()=>{this._after&&s&&_(this._after,s)}):(this._after&&s&&_(this._after,s),r)}beforeEach(t){return this._before=this._before||[],this._before.push(t),()=>{if(this._before!==void 0){const e=this._before.indexOf(t);e!==-1&&this._before.splice(e,1)}}}afterEach(t){return this._after=this._after||[],this._after.push(t),()=>{if(this._after!==void 0){const e=this._after.indexOf(t);e!==-1&&this._after.splice(e,1)}}}};function X(){return new qt}n(X,"w$1");l(X,"createHooks");(class{static{l(this,"HookableCore")}_hooks;constructor(){this._hooks={}}hook(t,e){return!t||typeof e!="function"?()=>{}:(this._hooks[t]=this._hooks[t]||[],this._hooks[t].push(e),()=>{e&&(this.removeHook(t,e),e=void 0)})}removeHook(t,e){const o=this._hooks[t];if(o){const s=o.indexOf(e);s!==-1&&o.splice(s,1),o.length===0&&(this._hooks[t]=void 0)}}callHook(t,...e){const o=this._hooks[t];if(!(!o||o.length===0))return E(o,e,0)}});const A=typeof window<"u";function Ut(t,e={}){const o={inspect:A,group:A,filter:l(()=>!0,"filter"),...e},s=o.filter,r=typeof s=="string"?a=>a.startsWith(s):s,i=o.tag?`[${o.tag}] `:"",c=l(a=>i+a.name+"".padEnd(a._id,"\0"),"logPrefix"),d={},H=t.beforeEach(a=>{r!==void 0&&!r(a.name)||(d[a.name]=d[a.name]||0,a._id=d[a.name]++,console.time(c(a)))}),P=t.afterEach(a=>{r!==void 0&&!r(a.name)||(o.group&&console.groupCollapsed(a.name),o.inspect?console.timeLog(c(a),a.args):console.timeEnd(c(a)),o.group&&console.groupEnd(),d[a.name]--)});return{close:l(()=>{H(),P()},"close")}}n(Ut,"W");l(Ut,"createDebugger");var Xt=Object.defineProperty,$=n((t,e)=>Xt(t,"name",{value:e,configurable:!0}),"t$1");const ne=$(()=>X(),"createVisHooks"),ae=$(async(t,e)=>{if(!(!e||e.length===0))for(const o of e){if(o.hooks)for(const[s,r]of Object.entries(o.hooks)){const i=Array.isArray(r)?r:[r];for(const c of i)t.hook(s,c)}o.setup&&await o.setup(t)}},"registerPlugins");class ce{static{n(this,"HookableLifeCycle")}static{$(this,"HookableLifeCycle")}#o;#e;#s=new Map;constructor(e,o){this.#o=e,this.#e=o}startTasks(e){for(const o of e)this.#s.set(o.id,o),this.#t("task:before",o)}endTasks(e){for(const o of e)this.#s.delete(o.task.id),this.#t("task:after",o.task,o),o.status==="failure"?this.#t("task:failure",o.task,o):Yt(o.status)&&this.#t("task:cacheHit",o.task,o)}printCacheMiss(e,o){this.#t("task:cacheMiss",e,o)}onTaskStdout(e,o){this.#t("task:stdout",e,o)}onTaskStderr(e,o){this.#t("task:stderr",e,o)}#t(e,...o){Promise.resolve(this.#o.callHook(e,...o)).catch(s=>{if(this.#e)try{this.#e(e,s)}catch{}})}}const Yt=$(t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache","isCacheStatus");var Jt=Object.defineProperty,Kt=n((t,e)=>Jt(t,"name",{value:e,configurable:!0}),"i");const I=process.platform==="win32",zt=Kt(async t=>{const{command:e,cwd:o,env:s,logFile:r}=t,i=ut(r,"a",R);let c;const d=I?"cmd":"/bin/sh",H=I?["/d","/s","/c",e]:["-c",e];try{c=ft(d,H,{cwd:o,detached:!0,env:wt({...process.env,...s},o),stdio:["ignore",i,i],windowsHide:!0})}finally{pt(i)}if(c.pid===void 0&&await new Promise((P,a)=>{c.once("spawn",()=>{P()}),c.once("error",K=>{a(K)})}),c.pid===void 0)throw new Error(`Failed to spawn detached process for command: ${e}`);return c.unref(),{pid:c.pid}},"spawnDetached");var Qt=Object.defineProperty,S=n((t,e)=>Qt(t,"name",{value:e,configurable:!0}),"t");const Y=5e3,le=S(async t=>B(t.workspaceRoot,t.id,async()=>{const e=await b(t.workspaceRoot,t.id);if(e&&u(e.pid))throw new Error(`Service ${t.id} is already running (pid ${String(e.pid)})`);e&&await v(t.workspaceRoot,t.id,e);const o=await k(t.workspaceRoot),s=M(t.id),r=w(o,`${s}.log`),{pid:i}=await zt({command:t.command,cwd:t.cwd,env:t.env,logFile:r}),c={command:t.command,config:t.config,cwd:t.cwd,env:t.config.env??{},id:t.id,logFile:r,pid:i,slug:s,startedAt:new Date().toISOString(),visVersion:process.env.VIS_VERSION??"0.0.0"};if(await jt(t.workspaceRoot,c),t.skipReadiness!==!0)try{await Pt(t.config,{timeoutMs:t.readinessTimeoutMs})}catch(d){throw await J(i,t.config.killGracePeriodMs??Y).catch(()=>{}),await v(t.workspaceRoot,t.id,c).catch(()=>{}),d}return{entry:c}}),"startService"),he=S(async t=>B(t.workspaceRoot,t.id,async()=>{const e=await b(t.workspaceRoot,t.id);if(!e)return{stopped:!1};if(!u(e.pid))return await v(t.workspaceRoot,t.id,e),{stopped:!1};const o=t.graceMs??e.config.killGracePeriodMs??Y;return await J(e.pid,o),await v(t.workspaceRoot,t.id,e),{stopped:!0}}),"stopService"),J=S(async(t,e)=>{F(t,"SIGTERM");const o=Date.now();for(;Date.now()-o<e;){if(!u(t))return;await new Promise(s=>{setTimeout(s,100)})}u(t)&&F(t,"SIGKILL")},"stopServiceByPid"),F=S((t,e)=>{try{process.platform==="win32"?process.kill(t,e):process.kill(-t,e)}catch(o){if(o.code==="ESRCH")return;throw o}},"sendSignalToServiceGroup");export{ce as H,Et as S,b as a,he as b,ne as c,Ot as d,Pt as e,v as f,u as i,ie as p,ae as r,le as s};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var U=Object.defineProperty;var l=(e,o)=>U(e,"name",{value:o,configurable:!0});import{createRequire as P}from"node:module";import{
|
|
1
|
+
var U=Object.defineProperty;var l=(e,o)=>U(e,"name",{value:o,configurable:!0});import{createRequire as P}from"node:module";import{p as K}from"../packem_chunks/config.js";import{NATIVE_BINDING_VERSION as M,osvBloomDecode as Y,osvBloomProbe as Q,osvBloomProbeBatch as X}from"#native";const V=P(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=l(e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[o,t]=d.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return d.getBuiltinModule(e)}return V(e)},"__cjs_getBuiltinModule"),{randomUUID:H,createHash:F}=O("node:crypto"),{existsSync:p}=O("node:fs"),{readFile:y,mkdir:L,stat:I,rm:q,writeFile:G,rename:J,unlink:W}=O("node:fs/promises"),{join:w,dirname:z}=O("node:path");var Z=Object.defineProperty,s=l((e,o)=>Z(e,"name",{value:o,configurable:!0}),"r");const N=5;if(M!==N)throw new Error(`vis native binding ABI mismatch in osv-bloom: expected ${N}, got ${M}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const ut="https://endevco.github.io/osv-bloom",tt=new Set(["endevco.github.io"]);class g extends Error{static{l(this,"OsvBloomSourceNotAllowedError")}static{s(this,"OsvBloomSourceNotAllowedError")}cause="OSV_BLOOM_SOURCE_NOT_ALLOWED";constructor(o){super(`osv-bloom source host '${o}' is not in the built-in allowlist. Add it to \`security.audit.advisories.bloom.allowedHosts\` if intentional.`),this.name="OsvBloomSourceNotAllowedError"}}class B extends Error{static{l(this,"OsvBloomNetworkError")}static{s(this,"OsvBloomNetworkError")}cause="OSV_BLOOM_NETWORK";constructor(o,t){super(`osv-bloom fetch failed for ${o}: ${t}. Check connectivity, proxy env vars, or --source.`),this.name="OsvBloomNetworkError"}}class et extends Error{static{l(this,"OsvBloomIntegrityError")}static{s(this,"OsvBloomIntegrityError")}cause="OSV_BLOOM_INTEGRITY";constructor(o,t){super(`osv-bloom filter.bin sha256 mismatch (expected ${o}, got ${t}). Refusing to install a corrupted filter.`),this.name="OsvBloomIntegrityError"}}class v extends Error{static{l(this,"OsvBloomManifestError")}static{s(this,"OsvBloomManifestError")}cause="OSV_BLOOM_MANIFEST";constructor(o){super(`osv-bloom manifest invalid: ${o}`),this.name="OsvBloomManifestError"}}class ot extends Error{static{l(this,"OsvBloomCacheMissError")}static{s(this,"OsvBloomCacheMissError")}cause="OSV_BLOOM_CACHE_MISS";constructor(o){super(`No osv-bloom cache at ${o}. Run 'vis advisories bloom sync' first.`),this.name="OsvBloomCacheMissError"}}const b=s(e=>{const o=K("vis",{create:!0,cwd:e})??w(e,"node_modules",".cache","vis");return w(o,"osv-bloom")},"resolveOsvBloomCacheDir"),h=s(e=>w(e,"filter.bin"),"filterPath"),R=s(e=>w(e,"manifest.json"),"manifestPath"),T=s(e=>w(e,"state.json"),"statePath"),st=s((e,o)=>{let t;try{t=new URL(e)}catch{throw new g(e)}if(!t.host)throw new g(e);if(t.protocol!=="https:")throw new g(`${t.protocol}//${t.host}`);if(!new Set([...tt,...o??[]]).has(t.host))throw new g(t.host);return t},"validateOsvBloomSource"),ht=s(async e=>{const o=Date.now(),t=e.cacheDir??b(e.workspaceRoot);await L(t,{recursive:!0});const r=st(e.source,e.allowedHosts),a=new URL("manifest.json",$(r.toString())),i=new URL("filter.bin",$(r.toString())),n=await x(a,{method:"GET"});if(!n.ok)throw new B(a.toString(),n.status);const S=await n.text(),c=k(S),m=await C(t);if(!e.force&&m?.setDigestSha256===c.setDigestSha256&&p(h(t)))return{bytesOnDisk:(await I(h(t))).size,cacheDir:t,durationMs:Date.now()-o,manifest:c,upToDate:!0};const E={};!e.force&&m?.filterEtag&&(E.headers={"if-none-match":m.filterEtag});const f=await x(i,{...E,method:"GET"});if(f.status===304&&m&&p(h(t)))return await A(t,S,{fetchedAtIso:new Date().toISOString(),filterEtag:m.filterEtag,setDigestSha256:c.setDigestSha256}),{bytesOnDisk:(await I(h(t))).size,cacheDir:t,durationMs:Date.now()-o,manifest:c,upToDate:!0};if(!f.ok||!f.body)throw new B(i.toString(),f.status);const u=Buffer.from(await f.arrayBuffer());e.onProgress&&e.onProgress(u.length,u.length);const D=rt(u);if(D!==c.filterSha256)throw new et(c.filterSha256,D);if(u.length!==c.bloomByteLen)throw new v(`filter.bin length ${u.length} does not match manifest.bloom_byte_len ${c.bloomByteLen}`);const j=f.headers.get("etag")??void 0;return await _(h(t),u),await A(t,S,{fetchedAtIso:new Date().toISOString(),filterEtag:j,setDigestSha256:c.setDigestSha256}),{bytesOnDisk:u.length,cacheDir:t,durationMs:Date.now()-o,manifest:c,upToDate:!1}},"syncOsvBloom"),ft=s(async(e,o)=>{const t=o?.cacheDir??b(e),r=h(t);if(!p(r)){if(o?.softFail)return null;throw new ot(t)}const a=await y(r);return Y(a)},"loadOsvBloomHandle");s((e,o,t)=>Q(e,o,t),"probeOsvBloom");const mt=s((e,o)=>X(e,o),"probeOsvBloomBatch"),dt=s(async(e,o)=>{const t=o??b(e);if(!p(h(t)))return{cacheDir:t,present:!1};let r,a;try{r=k(await y(R(t),"utf8"))}catch{}try{a=await C(t)}catch{}return{cacheDir:t,fetchedAtIso:a?.fetchedAtIso,manifest:r,present:!0}},"getOsvBloomStatus");s(async(e,o)=>{const t=o??b(e);await q(t,{force:!0,recursive:!0})},"clearOsvBloomCache");const k=s(e=>{let o;try{o=JSON.parse(e)}catch(i){throw new v(i instanceof Error?i.message:String(i))}const t=s(i=>{const n=o[i];if(typeof n!="number"||Number.isNaN(n))throw new v(`field '${i}' missing or non-numeric`);return n},"requireNumber"),r=s(i=>{const n=o[i];if(typeof n!="string"||n.length===0)throw new v(`field '${i}' missing or empty`);return n},"requireString"),a=t("format_version");if(a!==1)throw new v(`unsupported format_version ${a} (this build expects v1)`);return{advisoryCount:t("advisory_count"),bloomByteLen:t("bloom_byte_len"),bloomKHashes:t("bloom_k_hashes"),bloomMBits:t("bloom_m_bits"),builtAtRfc3339:r("built_at_rfc3339"),builtAtUnix:t("built_at_unix"),entryCount:t("entry_count"),filterSha256:r("filter_sha256"),formatVersion:a,setDigestSha256:r("set_digest_sha256"),sourceUrl:r("source_url"),targetFpr:t("target_fpr")}},"parseManifest"),C=s(async e=>{try{const o=await y(T(e),"utf8"),t=JSON.parse(o);return typeof t.setDigestSha256!="string"||typeof t.fetchedAtIso!="string"?void 0:{fetchedAtIso:t.fetchedAtIso,filterEtag:typeof t.filterEtag=="string"?t.filterEtag:void 0,setDigestSha256:t.setDigestSha256}}catch{return}},"readState"),A=s(async(e,o,t)=>{await _(R(e),Buffer.from(o,"utf8")),await _(T(e),Buffer.from(`${JSON.stringify(t,void 0,2)}
|
|
2
2
|
`,"utf8"))},"persistManifestAndState"),_=s(async(e,o)=>{await L(z(e),{recursive:!0});const t=`${e}.${process.pid}.${H()}.tmp`;try{await G(t,o),await J(t,e)}catch(r){throw await W(t).catch(()=>{}),r}},"atomicWrite"),rt=s(e=>F("sha256").update(e).digest("hex"),"sha256Hex"),$=s(e=>e.endsWith("/")?e:`${e}/`,"ensureTrailingSlash"),it=3e4,x=s(async(e,o)=>{try{return await fetch(e,{...o,signal:AbortSignal.timeout(it)})}catch(t){throw new B(e.toString(),t instanceof Error?t.message:String(t))}},"safeFetch");export{ut as D,ot as O,dt as g,ft as l,mt as p,ht as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var R=Object.defineProperty;var d=(e,t)=>R(e,"name",{value:t,configurable:!0});import{createRequire as M}from"node:module";import{s as u}from"./pm-runner-DmKT2FqF.js";import{s as $,
|
|
1
|
+
var R=Object.defineProperty;var d=(e,t)=>R(e,"name",{value:t,configurable:!0});import{createRequire as M}from"node:module";import{s as u}from"./pm-runner-DmKT2FqF.js";import{s as $,b as S}from"../packem_chunks/config.js";import{M as v,l as k}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{m as U,i as D}from"../packem_chunks/bin.js";const T=M(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=d(e=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,r]=f.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return f.getBuiltinModule(e)}return T(e)},"__cjs_getBuiltinModule"),{rmSync:p,writeFileSync:C,readdirSync:O}=A("node:fs");var N=Object.defineProperty,b=d((e,t)=>N(e,"name",{value:t,configurable:!0}),"o$1");const F=8,V=b(async(e,t,r)=>{if(e.length===0)return[];const o=Math.max(1,Math.min(t,e.length)),a=Array.from({length:e.length});let n=0;const i=b(async()=>{for(;n<e.length;){const s=n;n+=1;const l=e[s];a[s]=await r(l,s)}},"worker");return await Promise.all(Array.from({length:o},()=>i())),a},"mapWithConcurrency");var W=Object.defineProperty,c=d((e,t)=>W(e,"name",{value:t,configurable:!0}),"o");const w=2,E=1800*1e3,L=15e3,g=c(()=>v(U(),"packuments"),"getPackumentCacheDir"),P=c(e=>v(g(),`${encodeURIComponent(e)}.json`),"cacheFilePath"),x=c(e=>{const t=P(e);if(k(t))try{const r=$(t);if(r.cacheVersion!==w){p(t,{force:!0});return}if(Date.now()-r.createdAt>r.ttlMs){p(t,{force:!0});return}return r.packument}catch{p(t,{force:!0});return}},"readCached"),q=c((e,t,r)=>{S(g());const o={cacheVersion:w,createdAt:Date.now(),packument:t,ttlMs:r};C(P(e),JSON.stringify(o),"utf8")},"writeCached"),B=c(e=>{const t={},r=e.versions??{};for(const[a,n]of Object.entries(r)){const i=n.dist,s={version:a};if(n._npmUser!==void 0&&(s._npmUser=n._npmUser),n.maintainers!==void 0&&(s.maintainers=n.maintainers),n.bin!==void 0&&(s.bin=n.bin),i!==void 0){const l={};i.signatures!==void 0&&(l.signatures=i.signatures),i.attestations!==void 0&&(l.attestations=i.attestations),typeof i.integrity=="string"&&(l.integrity=i.integrity),typeof i.tarball=="string"&&(l.tarball=i.tarball),s.dist=l}n.repository!==void 0&&(s.repository=n.repository),n.license!==void 0&&(s.license=n.license),typeof n.readme=="string"&&(s.readme=n.readme),typeof n.readmeFilename=="string"&&(s.readmeFilename=n.readmeFilename),typeof n.private=="boolean"&&(s.private=n.private),typeof n.deprecated=="string"&&(s.deprecated=n.deprecated),n.scripts!==void 0&&typeof n.scripts=="object"&&(s.scripts=n.scripts),t[a]=s}const o={name:typeof e.name=="string"?e.name:"",versions:t};return e["dist-tags"]!==void 0&&(o["dist-tags"]=e["dist-tags"]),e.time!==void 0&&(o.time=e.time),typeof e.readme=="string"&&(o.readme=e.readme),o},"stripPackument"),H=c(e=>{const t={Accept:"application/json"};return e!==void 0&&e!==""&&(t.Authorization=`Bearer ${e}`),t},"buildHeaders"),z=c(async(e,t)=>{if(t.registryUrl!==void 0)return{authToken:t.authToken,url:t.registryUrl};if(t.workspaceRoot!==void 0){const{getRegistryForPackage:r,loadNpmrc:o}=await import("../packem_chunks/bin.js").then(s=>s.c7),a=o(t.workspaceRoot),{token:n,url:i}=r(e,a);return{authToken:t.authToken??n,url:i}}return{authToken:t.authToken,url:"https://registry.npmjs.org"}},"resolveRegistry"),I=c(async(e,t={})=>{const r=t.cacheTtlMs??E,o=x(e);if(o!==void 0)return o;const a=await z(e,t),n=`${a.url.endsWith("/")?a.url.slice(0,-1):a.url}/${e.replace("/","%2f")}`,i=new AbortController,s=setTimeout(()=>{i.abort()},L),l=c(()=>{i.abort()},"abortListener");t.signal?.addEventListener("abort",l,{once:!0});try{const m=await fetch(n,{headers:H(a.authToken),signal:i.signal});if(m.status===404)return;if(!m.ok)throw new Error(`Registry returned ${String(m.status)} for ${e}`);const _=await m.json(),y=B(_);return q(e,y,r),y}finally{clearTimeout(s),t.signal?.removeEventListener("abort",l)}},"getPackument"),te=c((e,t)=>{const r=Object.keys(e.versions);if(r.length===0)return;if(t===void 0||t===""||t==="latest")return e["dist-tags"]?.latest??r.at(-1);const o=e["dist-tags"]?.[t];return o!==void 0?o:Object.hasOwn(e.versions,t)?t:u.maxSatisfying(r,t)??void 0},"resolveVersionRange");c(()=>{const e=g();if(!k(e))return 0;let t=0;for(const r of O(e))r.endsWith(".json")&&(p(v(e,r),{force:!0}),t+=1);return t},"clearPackumentCache");var J=Object.defineProperty,h=d((e,t)=>J(e,"name",{value:t,configurable:!0}),"i");const j=h((e,t)=>e.versions[t]?.dist?.attestations?.provenance!==void 0,"hasProvenance"),Y=h((e,t)=>u.valid(t)?Object.keys(e.versions).filter(r=>u.valid(r)!==null&&u.lt(r,t)).filter(r=>u.satisfies(r,"*",{includePrerelease:!1})).filter(r=>j(e,r)).sort((r,o)=>u.lt(r,o)?1:-1)[0]:void 0,"findNewestPriorWithAttestations"),re=h(async(e,t={})=>{if(D("provenance"))return[];const r=new Set(t.allowlist),o=t.concurrency??F;return(await V(e,o,async({name:a,version:n})=>{if(r.has(a))return;const i=await I(a,{workspaceRoot:t.workspaceRoot});if(i===void 0||j(i,n))return;const s=Y(i,n);if(s!==void 0)return{packageName:a,priorVersionWithProvenance:s,version:n}})).filter(a=>a!==void 0)},"runProvenanceMarshall");export{F as D,te as a,Y as f,I as g,V as m,re as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var v=Object.defineProperty;var a=(e,r)=>v(e,"name",{value:r,configurable:!0});import{createRequire as _}from"node:module";import{s as j,
|
|
1
|
+
var v=Object.defineProperty;var a=(e,r)=>v(e,"name",{value:r,configurable:!0});import{createRequire as _}from"node:module";import{s as j,b as R}from"../packem_chunks/config.js";import{l as d,M as p}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{m as K}from"../packem_chunks/bin.js";const k=_(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=a(e=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[r,t]=n.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return n.getBuiltinModule(e)}return k(e)},"__cjs_getBuiltinModule"),{rmSync:m,writeFileSync:C}=b("node:fs");var M=Object.defineProperty,o=a((e,r)=>M(e,"name",{value:r,configurable:!0}),"r");const w=1440*60*1e3,A=15e3,S="https://registry.npmjs.org/-/npm/v1/keys",h=o(()=>p(K(),"registry-keys"),"getRegistryKeysCacheDir"),c=o(()=>p(h(),"npmjs.json"),"cacheFilePath"),T=o(()=>{const e=c();if(d(e))try{const r=j(e),t=Date.now()-r.createdAt>r.ttlMs;return{entry:r,expired:t}}catch{m(e,{force:!0});return}},"readCachedKeys"),D=o((e,r)=>{R(h());const t={createdAt:Date.now(),keys:e,ttlMs:r};C(c(),JSON.stringify(t),"utf8")},"writeCachedKeys"),N=o(async(e={})=>{const r=e.ttlMs??w,t=e.keysUrl??process.env.VIS_NPM_KEYS_URL??S,s=T();if(s!==void 0&&!s.expired&&e.forceRefresh!==!0)return{fromCache:!0,keys:s.entry.keys};const i=new AbortController,g=setTimeout(()=>{i.abort()},A),y=o(()=>{i.abort()},"abortListener");e.signal?.addEventListener("abort",y,{once:!0});try{const l=await fetch(t,{headers:{Accept:"application/json"},signal:i.signal});if(!l.ok)return s!==void 0?{fromCache:!0,keys:s.entry.keys,stale:!0}:void 0;const f=await l.json(),u=Array.isArray(f.keys)?f.keys:[];return D(u,r),{fromCache:!1,keys:u}}catch{return s!==void 0?{fromCache:!0,keys:s.entry.keys,stale:!0}:void 0}finally{clearTimeout(g),e.signal?.removeEventListener("abort",y)}},"fetchRegistryKeys"),B=o(()=>{const e=c();return d(e)?(m(e,{force:!0}),!0):!1},"clearRegistryKeysCache");export{B as c,N as f};
|