@visulima/vis 1.0.0-alpha.43 → 1.0.0-alpha.45
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 +78 -0
- package/LICENSE.md +256 -0
- package/bin/resolve-binary.mjs +85 -0
- package/bin/vis.mjs +76 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +1 -2
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +1 -1
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +63 -62
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +173 -973
- package/dist/packem_chunks/detect.js +1 -1
- package/dist/packem_chunks/dispatch.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +2 -2
- package/dist/packem_chunks/handler13.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/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +13 -4
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler5.js +3 -3
- package/dist/packem_chunks/handler50.js +4 -4
- package/dist/packem_chunks/handler51.js +3 -3
- package/dist/packem_chunks/handler53.js +1 -1
- package/dist/packem_chunks/handler54.js +2 -2
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler57.js +4 -4
- package/dist/packem_chunks/handler58.js +1 -1
- package/dist/packem_chunks/handler59.js +2 -2
- package/dist/packem_chunks/handler6.js +6 -6
- package/dist/packem_chunks/handler60.js +18 -18
- package/dist/packem_chunks/handler61.js +1 -1
- package/dist/packem_chunks/handler62.js +3 -3
- package/dist/packem_chunks/handler63.js +4 -4
- package/dist/packem_chunks/handler65.js +2 -2
- package/dist/packem_chunks/handler66.js +15 -15
- package/dist/packem_chunks/handler67.js +5 -5
- package/dist/packem_chunks/handler68.js +16 -16
- package/dist/packem_chunks/handler69.js +5 -5
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler70.js +16 -17
- package/dist/packem_chunks/handler71.js +2 -2
- package/dist/packem_chunks/handler72.js +2 -2
- package/dist/packem_chunks/handler73.js +13 -13
- package/dist/packem_chunks/handler74.js +3 -3
- package/dist/packem_chunks/handler75.js +3 -3
- package/dist/packem_chunks/handler76.js +63 -63
- package/dist/packem_chunks/handler77.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/index2.js +802 -7
- package/dist/packem_chunks/index3.js +7 -135
- package/dist/packem_chunks/index4.js +134 -73
- package/dist/packem_chunks/index5.js +74 -0
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +3 -3
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/loader2.js +1 -1
- package/dist/packem_chunks/print-config.js +1 -1
- package/dist/packem_chunks/registry.js +2 -2
- package/dist/packem_chunks/shell-runner.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +2 -2
- package/dist/packem_chunks/ts-loader.js +22 -2
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/version-resolver.js +2 -2
- package/dist/packem_shared/{Table-CcVkyULl-DLWu6XHL.js → Table-BGIHvenQ-D2oJtNQj.js} +1 -1
- package/dist/packem_shared/affected-shas-CCxG4tvm.js +1 -0
- package/dist/packem_shared/{ai-analysis-Co-b15d_.js → ai-analysis-rC48NLfB.js} +5 -5
- package/dist/packem_shared/{ai-fix-DnJDgPN-.js → ai-fix-D_ijV3Rn.js} +3 -3
- package/dist/packem_shared/augment-DaSS2Lgs.js +4 -0
- package/dist/packem_shared/bin-CPMo34SM.js +1 -0
- package/dist/packem_shared/{build-scripts-Doxce2VM.js → build-scripts-MTSK6TNr.js} +1 -1
- package/dist/packem_shared/{command-runtime-RiCMa2C8.js → command-runtime-3FTGuUsK.js} +1 -1
- package/dist/packem_shared/{cyclonedx-BTBzGCBW.js → cyclonedx-BeUmPgfO.js} +1 -1
- package/dist/packem_shared/{dependency-scan-DEv-scN6.js → dependency-scan-DpOFiZuI.js} +1 -1
- package/dist/packem_shared/{docker-DKlF-gk3.js → docker-CViFYtmM.js} +1 -1
- package/dist/packem_shared/{env-XJzocuUP.js → env-Ct3hMEYB.js} +2 -2
- package/dist/packem_shared/{failure-log-Sp1j-5qo.js → failure-log-Dy2G-rKi.js} +1 -1
- package/dist/packem_shared/glob-fqg4KepW-1S3z30c8.js +1 -0
- package/dist/packem_shared/index-CE6MsgcV.js +22 -0
- package/dist/packem_shared/{index-CkZnT2Fe.js → index-Cntyu-w8.js} +1 -1
- package/dist/packem_shared/{index-DJAnbLEh.js → index-XAb0QGqA.js} +1 -1
- package/dist/packem_shared/{lifecycle-C4nRsXxc.js → lifecycle-CHcFuWf_.js} +1 -1
- package/dist/packem_shared/{lockfile-DIGyLfmF.js → lockfile-C1qCKGH6.js} +1 -1
- package/dist/packem_shared/{manifests-pLwnVmCN.js → manifests-WBnsV_Eb.js} +1 -1
- package/dist/packem_shared/{min-release-age-B23Mr7NO.js → min-release-age-C71MO72F.js} +1 -1
- package/dist/packem_shared/{missing-package-json-DdMNbe_j.js → missing-package-json-CTF71tE5.js} +1 -1
- package/dist/packem_shared/{native-config-sync-4K9wWTj5.js → native-config-sync-BFDVK9LH.js} +4 -4
- package/dist/packem_shared/{osv-bloom-BsQ-aFiM.js → osv-bloom-DVMlkcAO.js} +2 -2
- package/dist/packem_shared/{packument-QjOLAMSk.js → packument-C-A3Uhhx.js} +1 -1
- package/dist/packem_shared/pm-runner-CQcraCcu.js +1 -0
- package/dist/packem_shared/{provenance-CilBg0Ee.js → provenance-R2csDSNg.js} +1 -1
- package/dist/packem_shared/readJsonSync-CvkZyKmL-ihoybKvs.js +1 -0
- package/dist/packem_shared/{registry-keys-BEavOCPz.js → registry-keys-CMnS_Qt_.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-C4o8_-SE.js → resolve-explicit-C4oQMyoB.js} +1 -1
- package/dist/packem_shared/resolve-runtime-QRaQucfL.js +1 -0
- package/dist/packem_shared/run-file-DD7Ne23Z.js +1 -0
- package/dist/packem_shared/{runtime-check-0lUJvgKt.js → runtime-check-BXehSP06.js} +1 -1
- package/dist/packem_shared/{s1ngularity-DuG-LLaX.js → s1ngularity-BCDt28u0.js} +1 -1
- package/dist/packem_shared/scan-progress-YRpDs90j.js +2 -0
- package/dist/packem_shared/{selectors-UmnAuc26.js → selectors-D4iCvITE.js} +1 -1
- package/dist/packem_shared/{signatures-CYheSqd3.js → signatures-B3srzCEv.js} +1 -1
- package/dist/packem_shared/target-options-CR0OuYJr.js +1 -0
- package/dist/packem_shared/toolchain-C44mPKPu.js +5 -0
- package/dist/packem_shared/{typosquats-hCtH-23t.js → typosquats-CQz-1Y6K.js} +1 -1
- package/dist/packem_shared/use-measured-height-DHi0xOPO.js +1 -0
- package/dist/packem_shared/utils-CRueU43T.js +1 -0
- package/dist/packem_shared/verify-DStfg3nb.js +1 -0
- package/dist/packem_shared/{vis-update-app-K-qATSeh.js → vis-update-app-B3I14Vfy.js} +1 -1
- package/dist/packem_shared/{watch-Bkp_AAbc.js → watch-BXNI7dC6.js} +1 -1
- package/dist/packem_shared/{watch-loop-WE7nWIEt.js → watch-loop-JfGKIgKB.js} +1 -1
- package/dist/runtime/preload.js +1 -1
- package/index.js +52 -52
- package/package.json +18 -14
- package/dist/packem_shared/affected-shas-C1XuRlvo.js +0 -1
- package/dist/packem_shared/augment-8fIWWGSc.js +0 -3
- package/dist/packem_shared/bin-DDq2oszw.js +0 -1
- package/dist/packem_shared/glob-fqg4KepW-7Bs2kZuM.js +0 -1
- package/dist/packem_shared/index-OQZQyN5R.js +0 -19
- package/dist/packem_shared/pm-runner-CIH0wPh-.js +0 -1
- package/dist/packem_shared/readJsonSync-CvkZyKmL-CY7PZob_.js +0 -4
- package/dist/packem_shared/resolve-runtime-CJSWV-K8.js +0 -1
- package/dist/packem_shared/run-file-B4TqKa0X.js +0 -1
- package/dist/packem_shared/scan-progress-RTMsE3Z4.js +0 -2
- package/dist/packem_shared/target-options-ChWcK60i.js +0 -1
- package/dist/packem_shared/toolchain-DyCKnGch.js +0 -5
- package/dist/packem_shared/use-measured-height-BKUjhm_3.js +0 -1
- package/dist/packem_shared/utils-Cxree603.js +0 -1
- package/dist/packem_shared/verify-CVPYlUrF.js +0 -1
- package/dist/packem_shared/window-ops-DDePlWLV.js +0 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{createRequire as Dr}from"node:module";const Ir=Dr(import.meta.url),Et=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Pr=t=>{if(typeof Et<"u"&&Et.versions&&Et.versions.node){const[e,r]=Et.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Et.getBuiltinModule(t)}return Ir(t)},{createRequire:B}=Pr("node:module"),_e=0,Fr=4,Gr=Symbol("findUpStop"),tu=/"(?:[^"\\]|\\.)*"|\/\/[^\r\n]*|\/\*[\s\S]*?\*\//g,Ur=/^[A-Z]:\//i,$t=(t="")=>t&&t.replaceAll("\\","/").replace(Ur,e=>e.toUpperCase()),jr=/^[/\\]{2}/,zr=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,cr=/^[A-Z]:$/i,Le=/^\/([A-Z]:)?$/i,Wr=/.(\.[^./]+)$/,qr=/^[/\\]|^[a-z]:[/\\]/i,Kr=/\/$/,Xr=()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/",eu="/",pr=(t,e)=>{let r="",o=0,n=-1,s=0,i;for(let u=0;u<=t.length;++u){if(u<t.length)i=t[u];else{if(i==="/")break;i="/"}if(i==="/"){if(!(n===u-1||s===1))if(s===2){if(r.length<2||o!==2||!r.endsWith(".")||r.at(-2)!=="."){if(r.length>2){const a=r.lastIndexOf("/");a===-1?(r="",o=0):(r=r.slice(0,a),o=r.length-1-r.lastIndexOf("/")),n=u,s=0;continue}else if(r.length>0){r="",o=0,n=u,s=0;continue}}e&&(r+=r.length>0?"/..":"..",o=2)}else r.length>0?r+=`/${t.slice(n+1,u)}`:r=t.slice(n+1,u),o=u-n-1;n=u,s=0}else i==="."&&s!==-1?++s:s=-1}return r},bt=t=>zr.test(t),ae=function(t){if(t.length===0)return".";t=$t(t);const e=jr.exec(t),r=bt(t),o=t.at(-1)==="/";return t=pr(t,!r),t.length===0?r?"/":o?"./":".":(o&&(t+="/"),cr.test(t)&&(t+="/"),e?r?`//${t}`:`//./${t}`:r&&!bt(t)?`/${t}`:t)},Qr=(...t)=>{let e="";for(const r of t)if(r)if(e.length>0){const o=e.at(-1)==="/",n=r[0]==="/";o&&n?e+=r.slice(1):e+=o||n?r:`/${r}`}else e+=r;return ae(e)},vt=function(...t){t=t.map(o=>$t(o));let e="",r=!1;for(let o=t.length-1;o>=-1&&!r;o--){const n=o>=0?t[o]:Xr();!n||n.length===0||(e=`${n}/${e}`,r=bt(n))}return e=pr(e,!r),r&&!bt(e)?`/${e}`:e.length>0?e:"."},ru=function(t){return $t(t)},Zr=function(t){return Wr.exec($t(t))?.[1]??""},su=function(t,e){const r=vt(t).replace(Le,"$1").split("/"),o=vt(e).replace(Le,"$1").split("/");if(o[0][1]===":"&&r[0][1]===":"&&r[0]!==o[0])return o.join("/");const n=Math.min(r.length,o.length);let s=0;for(;s<n&&r[s]===o[s];)s+=1;const i=r.length-s;return[...Array.from({length:i}).fill(".."),...o.slice(s)].join("/")},ke=t=>{const e=$t(t).replace(Kr,""),r=e.lastIndexOf("/");if(r===-1)return bt(t)?"/":".";const o=e.slice(0,r);return cr.test(o)?`${o}/`:o||(bt(t)?"/":".")},fr=(t,e)=>{const r=$t(t),o=r.slice(r.lastIndexOf("/")+1);if(e&&o.endsWith(e)){if(e===r)return"";const n=o.slice(0,-e.length);if(n.length>0)return n}return o},Yr=function(t){const e=qr.exec(t)?.[0]?.replaceAll("\\","/")??"",r=fr(t),o=Zr(r);return{base:r,dir:ke(t),ext:o,name:r.slice(0,r.length-o.length),root:e}},Vr=B(import.meta.url),xt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Jr=t=>{if(typeof xt<"u"&&xt.versions&&xt.versions.node){const[e,r]=xt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return xt.getBuiltinModule(t)}return Vr(t)},{fileURLToPath:ts}=Jr("node:url");function es(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var He,Be;function rs(){return Be||(Be=1,He=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cr3","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),He}var ss=rs();const os=es(ss);new Set(os);const ns=/^(?:\.?\.[/\\]|\.\.\B)/,ou=t=>ns.test(t)||t==="..",ct=t=>$t(t instanceof URL?ts(t):t);let is=class extends Error{constructor(e){super(`EEXIST: ${e}`)}get code(){return"EEXIST"}set code(e){throw new Error("Cannot overwrite code EEXIST")}get name(){return"AlreadyExistsError"}set name(e){throw new Error("Cannot overwrite name of AlreadyExistsError")}};const pt=t=>{if(!t||!(t instanceof URL)&&typeof t!="string")throw new TypeError("Path must be a non-empty string or URL.")},us=B(import.meta.url),At=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ls=t=>{if(typeof At<"u"&&At.versions&&At.versions.node){const[e,r]=At.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return At.getBuiltinModule(t)}return us(t)};ls("node:fs/promises");const as=B(import.meta.url),St=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,cs=t=>{if(typeof St<"u"&&St.versions&&St.versions.node){const[e,r]=St.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return St.getBuiltinModule(t)}return as(t)};cs("node:fs");const ce=t=>{if(t.isFile())return"file";if(t.isDirectory())return"dir";if(t.isSymbolicLink())return"symlink"},ps=B(import.meta.url),wt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,fs=t=>{if(typeof wt<"u"&&wt.versions&&wt.versions.node){const[e,r]=wt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return wt.getBuiltinModule(t)}return ps(t)},{lstat:Me,mkdir:hs}=fs("node:fs/promises"),iu=async t=>{pt(t);try{const e=await Me(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(ce(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await hs(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const r=await Me(t);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(ce(r))}'`,{cause:e})}},gs=B(import.meta.url),Rt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ds=t=>{if(typeof Rt<"u"&&Rt.versions&&Rt.versions.node){const[e,r]=Rt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Rt.getBuiltinModule(t)}return gs(t)},{lstatSync:De,mkdirSync:ys}=ds("node:fs"),uu=t=>{pt(t);try{const e=De(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(ce(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{ys(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const r=De(t);if(!r.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(ce(r))}'`,{cause:e})}},ms=B(import.meta.url),Tt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,bs=t=>{if(typeof Tt<"u"&&Tt.versions&&Tt.versions.node){const[e,r]=Tt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Tt.getBuiltinModule(t)}return ms(t)};bs("node:fs/promises");const $s=B(import.meta.url),_t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vs=t=>{if(typeof _t<"u"&&_t.versions&&_t.versions.node){const[e,r]=_t.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return _t.getBuiltinModule(t)}return $s(t)};vs("node:fs");const Es=B(import.meta.url),kt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,xs=t=>{if(typeof kt<"u"&&kt.versions&&kt.versions.node){const[e,r]=kt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return kt.getBuiltinModule(t)}return Es(t)};xs("node:fs/promises");const As=B(import.meta.url),Ct=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ss=t=>{if(typeof Ct<"u"&&Ct.versions&&Ct.versions.node){const[e,r]=Ct.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Ct.getBuiltinModule(t)}return As(t)};Ss("node:fs");const ws=B(import.meta.url),Ot=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Rs=t=>{if(typeof Ot<"u"&&Ot.versions&&Ot.versions.node){const[e,r]=Ot.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Ot.getBuiltinModule(t)}return ws(t)};Rs("node:fs/promises");const Ts=B(import.meta.url),Nt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_s=t=>{if(typeof Nt<"u"&&Nt.versions&&Nt.versions.node){const[e,r]=Nt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Nt.getBuiltinModule(t)}return Ts(t)};_s("node:fs");B(import.meta.url);let Ie=class extends Error{root;constructor(e,r){super(`${e instanceof Error?e.message:String(e)} for path "${r}"`),this.cause=e,this.root=r}get name(){return"WalkError"}set name(e){throw new Error("Cannot overwrite name of WalkError")}};const Pe=t=>{const e=t.replace(/[$()+\\^]/g,String.raw`\$&`).replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,String.raw`\.`).replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");try{return new RegExp(`^${e}$`)}catch(r){throw new Error(`Invalid glob pattern: ${t}`,{cause:r})}};let ks=class{name;path;#t;constructor(e,r,o){this.#t=e,this.name=r,this.path=o}isDirectory(){return this.#t.isDirectory()}isFile(){return this.#t.isFile()}isSymbolicLink(){return this.#t.isSymbolicLink()}};const we=(t,e,r)=>new ks(t,e,r),le=(t,e,r,o)=>{if(Array.isArray(e)&&e.length>0&&!e.some(s=>t.endsWith(s)))return!1;const n=t.includes("\\")?t.replaceAll("\\","/"):t;return r&&!r.some(s=>s.test(n))?!1:!o?.some(s=>s.test(n))},Cs=B(import.meta.url),Lt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Os=t=>{if(typeof Lt<"u"&&Lt.versions&&Lt.versions.node){const[e,r]=Lt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Lt.getBuiltinModule(t)}return Cs(t)};Os("node:fs/promises");const Ns=B(import.meta.url),Ht=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ls=t=>{if(typeof Ht<"u"&&Ht.versions&&Ht.versions.node){const[e,r]=Ht.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Ht.getBuiltinModule(t)}return Ns(t)},{readdirSync:Hs,realpathSync:Bs,statSync:hr}=Ls("node:fs"),Ms=t=>{const e=ae(t),r=hr(e);return we(r,fr(e),e)};function*Ds(t,e={}){const{extensions:r,followSymlinks:o=!1,includeDirs:n=!0,includeFiles:s=!0,includeSymlinks:i=!0,match:u,maxDepth:a=Number.POSITIVE_INFINITY,skip:b}=e;if(pt(t),a<0)return;const h=e.visited??new Set,y=u?u.map(g=>typeof g=="string"?Pe(g):g):void 0,x=b?b.map(g=>typeof g=="string"?Pe(g):g):void 0;if(t=vt(ct(t)),n&&le(t,r,y,x)&&(yield Ms(t)),!(a<1||!le(t,void 0,void 0,x)))try{const g=Hs(t,{withFileTypes:!0});for(const $ of g){let _=Qr(t,$.name),R=$.isDirectory(),O=$.isFile();if($.isSymbolicLink())if(o){const d=Bs(_);if(h.has(d))continue;_=d;const E=hr(d);R=E.isDirectory(),O=E.isFile()}else if(i&&le(_,r,y,x)){yield we($,$.name,ae(_));continue}else continue;R?(o&&h.add(_),yield*Ds(_,{extensions:r,followSymlinks:o,includeDirs:n,includeFiles:s,includeSymlinks:i,match:y,maxDepth:a-1,skip:x,visited:h})):O&&s&&le(_,r,y,x)&&(yield we($,$.name,ae(_)))}}catch(g){throw g instanceof Ie?g:new Ie(g,t)}}const Is=B(import.meta.url),Bt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ps=t=>{if(typeof Bt<"u"&&Bt.versions&&Bt.versions.node){const[e,r]=Bt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Bt.getBuiltinModule(t)}return Is(t)};Ps("node:fs/promises");const Fs=B(import.meta.url),Mt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Gs=t=>{if(typeof Mt<"u"&&Mt.versions&&Mt.versions.node){const[e,r]=Mt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Mt.getBuiltinModule(t)}return Fs(t)},{statSync:Us,lstatSync:js}=Gs("node:fs"),cu=(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");const r=e.cwd?ct(e.cwd):process.cwd();let o=vt(r);const{root:n}=Yr(o),s=ct(e.stopAt??n),i=vt(o,s),u=e.type??"file",a=function(h){return typeof t=="function"?[t(h)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};e.allowSymlinks??=!0;const b=e.allowSymlinks?Us:js;for(;o&&o!==i&&o!==n;){for(let h of a(o)){if(h===Gr)return;if(h===void 0)continue;Buffer.isBuffer(h)?h=h.toString():h instanceof URL&&(h=ct(h));const y=bt(h)?h:vt(o,h);try{const x=b(y);if(u==="file"&&x.isFile()||u==="directory"&&x.isDirectory())return y}catch{}}o=ke(o)}};function Ce(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Fe={},ge,Ge;function pe(){if(Ge)return ge;Ge=1;const t="[^\\\\/]",e=Symbol("unignore"),r="\\.",o="\\+",n="\\?",s="\\/",i="(?=.)",u="[^/]",a=`(?:${s}|$)`,b=`(?:^|${s})`,h=`${r}{1,2}${a}`,y=`(?!${r})`,x=`(?!${b}${h})`,g=`(?!${r}{0,1}${a})`,$=`(?!${h})`,_=`[^.${s}]`,R=`${u}*?`,O="/",d={DOT_LITERAL:r,PLUS_LITERAL:o,QMARK_LITERAL:n,SLASH_LITERAL:s,ONE_CHAR:i,QMARK:u,END_ANCHOR:a,DOTS_SLASH:h,NO_DOT:y,NO_DOTS:x,NO_DOT_SLASH:g,NO_DOTS_SLASH:$,QMARK_NO_DOT:_,STAR:R,START_ANCHOR:b,SEP:O},E={...d,SLASH_LITERAL:"[\\\\/]",QMARK:t,STAR:`${t}*?`,DOTS_SLASH:`${r}{1,2}(?:[\\\\/]|$)`,NO_DOT:`(?!${r})`,NO_DOTS:`(?!(?:^|[\\\\/])${r}{1,2}(?:[\\\\/]|$))`,NO_DOT_SLASH:`(?!${r}{0,1}(?:[\\\\/]|$))`,NO_DOTS_SLASH:`(?!${r}{1,2}(?:[\\\\/]|$))`,QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},l={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};return ge={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:l,UNIGNORE:e,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(A){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${A.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(A){return A===!0?E:d}},ge}var Ue;function fe(){return Ue||(Ue=1,(function(t){const{REGEX_BACKSLASH:e,REGEX_REMOVE_BACKSLASH:r,REGEX_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_GLOBAL:n}=pe();t.isObject=s=>s!==null&&typeof s=="object"&&!Array.isArray(s),t.hasRegexChars=s=>o.test(s),t.isRegexChar=s=>s.length===1&&t.hasRegexChars(s),t.escapeRegex=s=>s.replace(n,"\\$1"),t.toPosixSlashes=s=>s.replace(e,"/"),t.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){const s=navigator.platform.toLowerCase();return s==="win32"||s==="windows"}return process.platform?process.platform==="win32":!1},t.removeBackslashes=s=>s.replace(r,i=>i==="\\"?"":i),t.escapeLast=(s,i,u)=>{const a=s.lastIndexOf(i,u);return a===-1?s:s[a-1]==="\\"?t.escapeLast(s,i,a-1):`${s.slice(0,a)}\\${s.slice(a)}`},t.removePrefix=(s,i={})=>{let u=s;return u.startsWith("./")&&(u=u.slice(2),i.prefix="./"),u},t.wrapOutput=(s,i={},u={})=>{const a=u.contains?"":"^",b=u.contains?"":"$";let h=`${a}(?:${s})${b}`;return i.negated===!0&&(h=`(?:^(?!${h}).*$)`),h},t.basename=(s,{windows:i}={})=>{const u=s.split(i?/[\\/]/:"/"),a=u[u.length-1];return a===""?u[u.length-2]:a}})(Fe)),Fe}var de,je;function zs(){if(je)return de;je=1;const t=fe(),{CHAR_ASTERISK:e,CHAR_AT:r,CHAR_BACKWARD_SLASH:o,CHAR_COMMA:n,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:i,CHAR_FORWARD_SLASH:u,CHAR_LEFT_CURLY_BRACE:a,CHAR_LEFT_PARENTHESES:b,CHAR_LEFT_SQUARE_BRACKET:h,CHAR_PLUS:y,CHAR_QUESTION_MARK:x,CHAR_RIGHT_CURLY_BRACE:g,CHAR_RIGHT_PARENTHESES:$,CHAR_RIGHT_SQUARE_BRACKET:_}=pe(),R=d=>d===u||d===o,O=d=>{d.isPrefix!==!0&&(d.depth=d.isGlobstar?1/0:1)};return de=(d,E)=>{const l=E||{},A=d.length-1,w=l.parts===!0||l.scanToEnd===!0,T=[],S=[],k=[];let F=d,D=-1,U=0,rt=0,Z=!1,st=!1,j=!1,lt=!1,gt=!1,ot=!1,P=!1,nt=!1,dt=!1,Y=!1,Q=0,J,C,H={value:"",depth:0,isGlob:!1};const f=()=>D>=A,V=()=>F.charCodeAt(D+1),K=()=>(J=C,F.charCodeAt(++D));for(;D<A;){C=K();let M;if(C===o){P=H.backslashes=!0,C=K(),C===a&&(ot=!0);continue}if(ot===!0||C===a){for(Q++;f()!==!0&&(C=K());){if(C===o){P=H.backslashes=!0,K();continue}if(C===a){Q++;continue}if(ot!==!0&&C===s&&(C=K())===s){if(Z=H.isBrace=!0,j=H.isGlob=!0,Y=!0,w===!0)continue;break}if(ot!==!0&&C===n){if(Z=H.isBrace=!0,j=H.isGlob=!0,Y=!0,w===!0)continue;break}if(C===g&&(Q--,Q===0)){ot=!1,Z=H.isBrace=!0,Y=!0;break}}if(w===!0)continue;break}if(C===u){if(T.push(D),S.push(H),H={value:"",depth:0,isGlob:!1},Y===!0)continue;if(J===s&&D===U+1){U+=2;continue}rt=D+1;continue}if(l.noext!==!0&&(C===y||C===r||C===e||C===x||C===i)&&V()===b){if(j=H.isGlob=!0,lt=H.isExtglob=!0,Y=!0,C===i&&D===U&&(dt=!0),w===!0){for(;f()!==!0&&(C=K());){if(C===o){P=H.backslashes=!0,C=K();continue}if(C===$){j=H.isGlob=!0,Y=!0;break}}continue}break}if(C===e){if(J===e&&(gt=H.isGlobstar=!0),j=H.isGlob=!0,Y=!0,w===!0)continue;break}if(C===x){if(j=H.isGlob=!0,Y=!0,w===!0)continue;break}if(C===h){for(;f()!==!0&&(M=K());){if(M===o){P=H.backslashes=!0,K();continue}if(M===_){st=H.isBracket=!0,j=H.isGlob=!0,Y=!0;break}}if(w===!0)continue;break}if(l.nonegate!==!0&&C===i&&D===U){nt=H.negated=!0,U++;continue}if(l.noparen!==!0&&C===b){if(j=H.isGlob=!0,w===!0){for(;f()!==!0&&(C=K());){if(C===b){P=H.backslashes=!0,C=K();continue}if(C===$){Y=!0;break}}continue}break}if(j===!0){if(Y=!0,w===!0)continue;break}}l.noext===!0&&(lt=!1,j=!1);let q=F,c="",p="";U>0&&(c=F.slice(0,U),F=F.slice(U),rt-=U),q&&j===!0&&rt>0?(q=F.slice(0,rt),p=F.slice(rt)):j===!0?(q="",p=F):q=F,q&&q!==""&&q!=="/"&&q!==F&&R(q.charCodeAt(q.length-1))&&(q=q.slice(0,-1)),l.unescape===!0&&(p&&(p=t.removeBackslashes(p)),q&&P===!0&&(q=t.removeBackslashes(q)));const et={prefix:c,input:d,start:U,base:q,glob:p,isBrace:Z,isBracket:st,isGlob:j,isExtglob:lt,isGlobstar:gt,negated:nt,negatedExtglob:dt};if(l.tokens===!0&&(et.maxDepth=0,R(C)||S.push(H),et.tokens=S),l.parts===!0||l.tokens===!0){let M;for(let z=0;z<T.length;z++){const at=M?M+1:U,tt=T[z],ft=d.slice(at,tt);l.tokens&&(z===0&&U!==0?(S[z].isPrefix=!0,S[z].value=c):S[z].value=ft,O(S[z]),et.maxDepth+=S[z].depth),(z!==0||ft!=="")&&k.push(ft),M=tt}if(M&&M+1<d.length){const z=d.slice(M+1);k.push(z),l.tokens&&(S[S.length-1].value=z,O(S[S.length-1]),et.maxDepth+=S[S.length-1].depth)}et.slashes=T,et.parts=k}return et},de}var ye,ze;function Ws(){if(ze)return ye;ze=1;const t=pe(),e=fe(),{MAX_LENGTH:r,POSIX_REGEX_SOURCE:o,REGEX_NON_SPECIAL_CHARS:n,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:i}=t,u=(d,E)=>typeof E.expandRange=="function"?E.expandRange(...d,E):(d.sort(),`[${d.join("-")}]`),a=(d,E)=>`Missing ${d}: "${E}" - use "\\\\${E}" to match literal characters`,b=d=>{const E=[];let l=0,A=0,w=0,T="",S=!1;for(const k of d){if(S===!0){T+=k,S=!1;continue}if(k==="\\"){T+=k,S=!0;continue}if(k==='"'){w=w===1?0:1,T+=k;continue}if(w===0){if(k==="[")l++;else if(k==="]"&&l>0)l--;else if(l===0){if(k==="(")A++;else if(k===")"&&A>0)A--;else if(k==="|"&&A===0){E.push(T),T="";continue}}}T+=k}return E.push(T),E},h=d=>{let E=!1;for(const l of d){if(E===!0){E=!1;continue}if(l==="\\"){E=!0;continue}if(/[?*+@!()[\]{}]/.test(l))return!1}return!0},y=d=>{let E=d.trim(),l=!0;for(;l===!0;)l=!1,/^@\([^\\()[\]{}|]+\)$/.test(E)&&(E=E.slice(2,-1),l=!0);if(h(E))return E.replace(/\\(.)/g,"$1")},x=d=>{const E=d.map(y).filter(Boolean);for(let l=0;l<E.length;l++)for(let A=l+1;A<E.length;A++){const w=E[l],T=E[A],S=w[0];if(!(!S||w!==S.repeat(w.length)||T!==S.repeat(T.length))&&(w===T||w.startsWith(T)||T.startsWith(w)))return!0}return!1},g=(d,E=!0)=>{if(d[0]!=="+"&&d[0]!=="*"||d[1]!=="(")return;let l=0,A=0,w=0,T=!1;for(let S=1;S<d.length;S++){const k=d[S];if(T===!0){T=!1;continue}if(k==="\\"){T=!0;continue}if(k==='"'){w=w===1?0:1;continue}if(w!==1){if(k==="["){l++;continue}if(k==="]"&&l>0){l--;continue}if(!(l>0)){if(k==="("){A++;continue}if(k===")"&&(A--,A===0))return E===!0&&S!==d.length-1?void 0:{type:d[0],body:d.slice(2,S),end:S}}}}},$=d=>{let E=0;const l=[];for(;E<d.length;){const A=g(d.slice(E),!1);if(!A||A.type!=="*")return;const w=b(A.body).map(S=>S.trim());if(w.length!==1)return;const T=y(w[0]);if(!T||T.length!==1)return;l.push(T),E+=A.end+1}return l.length<1?void 0:`${l.length===1?e.escapeRegex(l[0]):`[${l.map(A=>e.escapeRegex(A)).join("")}]`}*`},_=d=>{let E=0,l=d.trim(),A=g(l);for(;A;)E++,l=A.body.trim(),A=g(l);return E},R=(d,E)=>{if(E.maxExtglobRecursion===!1)return{risky:!1};const l=typeof E.maxExtglobRecursion=="number"?E.maxExtglobRecursion:t.DEFAULT_MAX_EXTGLOB_RECURSION,A=b(d).map(w=>w.trim());if(A.length>1&&(A.some(w=>w==="")||A.some(w=>/^[*?]+$/.test(w))||x(A)))return{risky:!0};for(const w of A){const T=$(w);if(T)return{risky:!0,safeOutput:T};if(_(w)>l)return{risky:!0}}return{risky:!1}},O=(d,E)=>{if(typeof d!="string")throw new TypeError("Expected a string");d=i[d]||d;const l={...E},A=typeof l.maxLength=="number"?Math.min(r,l.maxLength):r;let w=d.length;if(w>A)throw new SyntaxError(`Input length: ${w}, exceeds maximum allowed length: ${A}`);const T={type:"bos",value:"",output:l.prepend||""},S=[T],k=l.capture?"":"?:",F=t.globChars(l.windows),D=t.extglobChars(F),{DOT_LITERAL:U,PLUS_LITERAL:rt,SLASH_LITERAL:Z,ONE_CHAR:st,DOTS_SLASH:j,NO_DOT:lt,NO_DOT_SLASH:gt,NO_DOTS_SLASH:ot,QMARK:P,QMARK_NO_DOT:nt,STAR:dt,START_ANCHOR:Y}=F,Q=v=>`(${k}(?:(?!${Y}${v.dot?j:U}).)*?)`,J=l.dot?"":lt,C=l.dot?P:nt;let H=l.bash===!0?Q(l):dt;l.capture&&(H=`(${H})`),typeof l.noext=="boolean"&&(l.noextglob=l.noext);const f={input:d,index:-1,start:0,dot:l.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:S};d=e.removePrefix(d,f),w=d.length;const V=[],K=[],q=[];let c=T,p;const et=()=>f.index===w-1,M=f.peek=(v=1)=>d[f.index+v],z=f.advance=()=>d[++f.index]||"",at=()=>d.slice(f.index+1),tt=(v="",G=0)=>{f.consumed+=v,f.index+=G},ft=v=>{f.output+=v.output!=null?v.output:v.value,tt(v.value)},Br=()=>{let v=1;for(;M()==="!"&&(M(2)!=="("||M(3)==="?");)z(),f.start++,v++;return v%2===0?!1:(f.negated=!0,f.start++,!0)},ie=v=>{f[v]++,q.push(v)},ht=v=>{f[v]--,q.pop()},N=v=>{if(c.type==="globstar"){const G=f.braces>0&&(v.type==="comma"||v.type==="brace"),m=v.extglob===!0||V.length&&(v.type==="pipe"||v.type==="paren");v.type!=="slash"&&v.type!=="paren"&&!G&&!m&&(f.output=f.output.slice(0,-c.output.length),c.type="star",c.value="*",c.output=H,f.output+=c.output)}if(V.length&&v.type!=="paren"&&(V[V.length-1].inner+=v.value),(v.value||v.output)&&ft(v),c&&c.type==="text"&&v.type==="text"){c.output=(c.output||c.value)+v.value,c.value+=v.value;return}v.prev=c,S.push(v),c=v},ue=(v,G)=>{const m={...D[G],conditions:1,inner:""};m.prev=c,m.parens=f.parens,m.output=f.output,m.startIndex=f.index,m.tokensIndex=S.length;const L=(l.capture?"(":"")+m.open;ie("parens"),N({type:v,value:G,output:f.output?"":st}),N({type:"paren",extglob:!0,value:z(),output:L}),V.push(m)},Mr=v=>{const G=d.slice(v.startIndex,f.index+1),m=d.slice(v.startIndex+2,f.index),L=R(m,l);if((v.type==="plus"||v.type==="star")&&L.risky){const I=L.safeOutput?(v.output?"":st)+(l.capture?`(${L.safeOutput})`:L.safeOutput):void 0,it=S[v.tokensIndex];it.type="text",it.value=G,it.output=I||e.escapeRegex(G);for(let ut=v.tokensIndex+1;ut<S.length;ut++)S[ut].value="",S[ut].output="",delete S[ut].suffix;f.output=v.output+it.output,f.backtrack=!0,N({type:"paren",extglob:!0,value:p,output:""}),ht("parens");return}let W=v.close+(l.capture?")":""),X;if(v.type==="negate"){let I=H;if(v.inner&&v.inner.length>1&&v.inner.includes("/")&&(I=Q(l)),(I!==H||et()||/^\)+$/.test(at()))&&(W=v.close=`)$))${I}`),v.inner.includes("*")&&(X=at())&&/^\.[^\\/.]+$/.test(X)){const it=O(X,{...E,fastpaths:!1}).output;W=v.close=`)${it})${I})`}v.prev.type==="bos"&&(f.negatedExtglob=!0)}N({type:"paren",extglob:!0,value:p,output:W}),ht("parens")};if(l.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(d)){let v=!1,G=d.replace(s,(m,L,W,X,I,it)=>X==="\\"?(v=!0,m):X==="?"?L?L+X+(I?P.repeat(I.length):""):it===0?C+(I?P.repeat(I.length):""):P.repeat(W.length):X==="."?U.repeat(W.length):X==="*"?L?L+X+(I?H:""):H:L?m:`\\${m}`);return v===!0&&(l.unescape===!0?G=G.replace(/\\/g,""):G=G.replace(/\\+/g,m=>m.length%2===0?"\\\\":m?"\\":"")),G===d&&l.contains===!0?(f.output=d,f):(f.output=e.wrapOutput(G,f,E),f)}for(;!et();){if(p=z(),p==="\0")continue;if(p==="\\"){const m=M();if(m==="/"&&l.bash!==!0||m==="."||m===";")continue;if(!m){p+="\\",N({type:"text",value:p});continue}const L=/^\\+/.exec(at());let W=0;if(L&&L[0].length>2&&(W=L[0].length,f.index+=W,W%2!==0&&(p+="\\")),l.unescape===!0?p=z():p+=z(),f.brackets===0){N({type:"text",value:p});continue}}if(f.brackets>0&&(p!=="]"||c.value==="["||c.value==="[^")){if(l.posix!==!1&&p===":"){const m=c.value.slice(1);if(m.includes("[")&&(c.posix=!0,m.includes(":"))){const L=c.value.lastIndexOf("["),W=c.value.slice(0,L),X=c.value.slice(L+2),I=o[X];if(I){c.value=W+I,f.backtrack=!0,z(),!T.output&&S.indexOf(c)===1&&(T.output=st);continue}}}(p==="["&&M()!==":"||p==="-"&&M()==="]")&&(p=`\\${p}`),p==="]"&&(c.value==="["||c.value==="[^")&&(p=`\\${p}`),l.posix===!0&&p==="!"&&c.value==="["&&(p="^"),c.value+=p,ft({value:p});continue}if(f.quotes===1&&p!=='"'){p=e.escapeRegex(p),c.value+=p,ft({value:p});continue}if(p==='"'){f.quotes=f.quotes===1?0:1,l.keepQuotes===!0&&N({type:"text",value:p});continue}if(p==="("){ie("parens"),N({type:"paren",value:p});continue}if(p===")"){if(f.parens===0&&l.strictBrackets===!0)throw new SyntaxError(a("opening","("));const m=V[V.length-1];if(m&&f.parens===m.parens+1){Mr(V.pop());continue}N({type:"paren",value:p,output:f.parens?")":"\\)"}),ht("parens");continue}if(p==="["){if(l.nobracket===!0||!at().includes("]")){if(l.nobracket!==!0&&l.strictBrackets===!0)throw new SyntaxError(a("closing","]"));p=`\\${p}`}else ie("brackets");N({type:"bracket",value:p});continue}if(p==="]"){if(l.nobracket===!0||c&&c.type==="bracket"&&c.value.length===1){N({type:"text",value:p,output:`\\${p}`});continue}if(f.brackets===0){if(l.strictBrackets===!0)throw new SyntaxError(a("opening","["));N({type:"text",value:p,output:`\\${p}`});continue}ht("brackets");const m=c.value.slice(1);if(c.posix!==!0&&m[0]==="^"&&!m.includes("/")&&(p=`/${p}`),c.value+=p,ft({value:p}),l.literalBrackets===!1||e.hasRegexChars(m))continue;const L=e.escapeRegex(c.value);if(f.output=f.output.slice(0,-c.value.length),l.literalBrackets===!0){f.output+=L,c.value=L;continue}c.value=`(${k}${L}|${c.value})`,f.output+=c.value;continue}if(p==="{"&&l.nobrace!==!0){ie("braces");const m={type:"brace",value:p,output:"(",outputIndex:f.output.length,tokensIndex:f.tokens.length};K.push(m),N(m);continue}if(p==="}"){const m=K[K.length-1];if(l.nobrace===!0||!m){N({type:"text",value:p,output:p});continue}let L=")";if(m.dots===!0){const W=S.slice(),X=[];for(let I=W.length-1;I>=0&&(S.pop(),W[I].type!=="brace");I--)W[I].type!=="dots"&&X.unshift(W[I].value);L=u(X,l),f.backtrack=!0}if(m.comma!==!0&&m.dots!==!0){const W=f.output.slice(0,m.outputIndex),X=f.tokens.slice(m.tokensIndex);m.value=m.output="\\{",p=L="\\}",f.output=W;for(const I of X)f.output+=I.output||I.value}N({type:"brace",value:p,output:L}),ht("braces"),K.pop();continue}if(p==="|"){V.length>0&&V[V.length-1].conditions++,N({type:"text",value:p});continue}if(p===","){let m=p;const L=K[K.length-1];L&&q[q.length-1]==="braces"&&(L.comma=!0,m="|"),N({type:"comma",value:p,output:m});continue}if(p==="/"){if(c.type==="dot"&&f.index===f.start+1){f.start=f.index+1,f.consumed="",f.output="",S.pop(),c=T;continue}N({type:"slash",value:p,output:Z});continue}if(p==="."){if(f.braces>0&&c.type==="dot"){c.value==="."&&(c.output=U);const m=K[K.length-1];c.type="dots",c.output+=p,c.value+=p,m.dots=!0;continue}if(f.braces+f.parens===0&&c.type!=="bos"&&c.type!=="slash"){N({type:"text",value:p,output:U});continue}N({type:"dot",value:p,output:U});continue}if(p==="?"){if(!(c&&c.value==="(")&&l.noextglob!==!0&&M()==="("&&M(2)!=="?"){ue("qmark",p);continue}if(c&&c.type==="paren"){const m=M();let L=p;(c.value==="("&&!/[!=<:]/.test(m)||m==="<"&&!/<([!=]|\w+>)/.test(at()))&&(L=`\\${p}`),N({type:"text",value:p,output:L});continue}if(l.dot!==!0&&(c.type==="slash"||c.type==="bos")){N({type:"qmark",value:p,output:nt});continue}N({type:"qmark",value:p,output:P});continue}if(p==="!"){if(l.noextglob!==!0&&M()==="("&&(M(2)!=="?"||!/[!=<:]/.test(M(3)))){ue("negate",p);continue}if(l.nonegate!==!0&&f.index===0){Br();continue}}if(p==="+"){if(l.noextglob!==!0&&M()==="("&&M(2)!=="?"){ue("plus",p);continue}if(c&&c.value==="("||l.regex===!1){N({type:"plus",value:p,output:rt});continue}if(c&&(c.type==="bracket"||c.type==="paren"||c.type==="brace")||f.parens>0){N({type:"plus",value:p});continue}N({type:"plus",value:rt});continue}if(p==="@"){if(l.noextglob!==!0&&M()==="("&&M(2)!=="?"){N({type:"at",extglob:!0,value:p,output:""});continue}N({type:"text",value:p});continue}if(p!=="*"){(p==="$"||p==="^")&&(p=`\\${p}`);const m=n.exec(at());m&&(p+=m[0],f.index+=m[0].length),N({type:"text",value:p});continue}if(c&&(c.type==="globstar"||c.star===!0)){c.type="star",c.star=!0,c.value+=p,c.output=H,f.backtrack=!0,f.globstar=!0,tt(p);continue}let v=at();if(l.noextglob!==!0&&/^\([^?]/.test(v)){ue("star",p);continue}if(c.type==="star"){if(l.noglobstar===!0){tt(p);continue}const m=c.prev,L=m.prev,W=m.type==="slash"||m.type==="bos",X=L&&(L.type==="star"||L.type==="globstar");if(l.bash===!0&&(!W||v[0]&&v[0]!=="/")){N({type:"star",value:p,output:""});continue}const I=f.braces>0&&(m.type==="comma"||m.type==="brace"),it=V.length&&(m.type==="pipe"||m.type==="paren");if(!W&&m.type!=="paren"&&!I&&!it){N({type:"star",value:p,output:""});continue}for(;v.slice(0,3)==="/**";){const ut=d[f.index+4];if(ut&&ut!=="/")break;v=v.slice(3),tt("/**",3)}if(m.type==="bos"&&et()){c.type="globstar",c.value+=p,c.output=Q(l),f.output=c.output,f.globstar=!0,tt(p);continue}if(m.type==="slash"&&m.prev.type!=="bos"&&!X&&et()){f.output=f.output.slice(0,-(m.output+c.output).length),m.output=`(?:${m.output}`,c.type="globstar",c.output=Q(l)+(l.strictSlashes?")":"|$)"),c.value+=p,f.globstar=!0,f.output+=m.output+c.output,tt(p);continue}if(m.type==="slash"&&m.prev.type!=="bos"&&v[0]==="/"){const ut=v[1]!==void 0?"|$":"";f.output=f.output.slice(0,-(m.output+c.output).length),m.output=`(?:${m.output}`,c.type="globstar",c.output=`${Q(l)}${Z}|${Z}${ut})`,c.value+=p,f.output+=m.output+c.output,f.globstar=!0,tt(p+z()),N({type:"slash",value:"/",output:""});continue}if(m.type==="bos"&&v[0]==="/"){c.type="globstar",c.value+=p,c.output=`(?:^|${Z}|${Q(l)}${Z})`,f.output=c.output,f.globstar=!0,tt(p+z()),N({type:"slash",value:"/",output:""});continue}if(I&&v[0]==="/"){c.type="globstar",c.value+=p,c.output=`(?:^|${Z}|${Q(l)}${Z})`,f.output+=c.output,f.globstar=!0,tt(p+z()),N({type:"slash",value:"/",output:""});continue}f.output=f.output.slice(0,-c.output.length),c.type="globstar",c.output=Q(l),c.value+=p,f.output+=c.output,f.globstar=!0,tt(p);continue}const G={type:"star",value:p,output:H};if(l.bash===!0){G.output=".*?",(c.type==="bos"||c.type==="slash")&&(G.output=J+G.output),N(G);continue}if(c&&(c.type==="bracket"||c.type==="paren")&&l.regex===!0){G.output=p,N(G);continue}(f.index===f.start||c.type==="slash"||c.type==="dot")&&(c.type==="dot"?(f.output+=gt,c.output+=gt):l.dot===!0?(f.output+=ot,c.output+=ot):(f.output+=J,c.output+=J),M()!=="*"&&(f.output+=st,c.output+=st)),N(G)}for(;f.brackets>0;){if(l.strictBrackets===!0)throw new SyntaxError(a("closing","]"));f.output=e.escapeLast(f.output,"["),ht("brackets")}for(;f.parens>0;){if(l.strictBrackets===!0)throw new SyntaxError(a("closing",")"));f.output=e.escapeLast(f.output,"("),ht("parens")}for(;f.braces>0;){if(l.strictBrackets===!0)throw new SyntaxError(a("closing","}"));f.output=e.escapeLast(f.output,"{"),ht("braces")}if(l.strictSlashes!==!0&&(c.type==="star"||c.type==="bracket")&&N({type:"maybe_slash",value:"",output:`${Z}?`}),f.backtrack===!0){f.output="";for(const v of f.tokens)f.output+=v.output!=null?v.output:v.value,v.suffix&&(f.output+=v.suffix)}return f};return O.fastpaths=(d,E)=>{const l={...E},A=typeof l.maxLength=="number"?Math.min(r,l.maxLength):r,w=d.length;if(w>A)throw new SyntaxError(`Input length: ${w}, exceeds maximum allowed length: ${A}`);d=i[d]||d;const{DOT_LITERAL:T,SLASH_LITERAL:S,ONE_CHAR:k,DOTS_SLASH:F,NO_DOT:D,NO_DOTS:U,NO_DOTS_SLASH:rt,STAR:Z,START_ANCHOR:st}=t.globChars(l.windows),j=l.dot?U:D,lt=l.dot?rt:D,gt=l.capture?"":"?:",ot={negated:!1,prefix:""};let P=l.bash===!0?".*?":Z;l.capture&&(P=`(${P})`);const nt=J=>J.noglobstar===!0?P:`(${gt}(?:(?!${st}${J.dot?F:T}).)*?)`,dt=J=>{switch(J){case"*":return`${j}${k}${P}`;case".*":return`${T}${k}${P}`;case"*.*":return`${j}${P}${T}${k}${P}`;case"*/*":return`${j}${P}${S}${k}${lt}${P}`;case"**":return j+nt(l);case"**/*":return`(?:${j}${nt(l)}${S})?${lt}${k}${P}`;case"**/*.*":return`(?:${j}${nt(l)}${S})?${lt}${P}${T}${k}${P}`;case"**/.*":return`(?:${j}${nt(l)}${S})?${T}${k}${P}`;default:{const C=/^(.*?)\.(\w+)$/.exec(J);if(!C)return;const H=dt(C[1]);return H?H+T+C[2]:void 0}}},Y=e.removePrefix(d,ot);let Q=dt(Y);return Q&&l.strictSlashes!==!0&&(Q+=`${S}?`),Q},ye=O,ye}var me,We;function qs(){if(We)return me;We=1;const t=zs(),e=Ws(),r=fe(),o=pe(),n=i=>i&&typeof i=="object"&&!Array.isArray(i),s=(i,u,a=!1)=>{if(Array.isArray(i)){const R=i.map(O=>s(O,u,a));return O=>{for(const d of R){const E=d(O);if(E)return E}return!1}}const b=n(i)&&i.tokens&&i.input;if(i===""||typeof i!="string"&&!b)throw new TypeError("Expected pattern to be a non-empty string");const h=u||{},y=h.windows,x=b?s.compileRe(i,u):s.makeRe(i,u,!1,!0),g=x.state;delete x.state;let $=()=>!1;if(h.ignore){const R={...u,ignore:null,onMatch:null,onResult:null};$=s(h.ignore,R,a)}const _=(R,O=!1)=>{const{isMatch:d,match:E,output:l}=s.test(R,x,u,{glob:i,posix:y}),A={glob:i,state:g,regex:x,posix:y,input:R,output:l,match:E,isMatch:d};if(typeof h.onResult=="function"&&h.onResult(A),d===!1)return A.isMatch=!1,O?A:!1;t:if($(R)){if(typeof h.onIgnore=="function"&&h.onIgnore(A)===o.UNIGNORE){A.isMatch=!0;break t}return A.isMatch=!1,O?A:!1}return typeof h.onMatch=="function"&&h.onMatch(A),O?A:!0};return a&&(_.state=g),_};return s.test=(i,u,a,{glob:b,posix:h}={})=>{if(typeof i!="string")throw new TypeError("Expected input to be a string");if(i==="")return{isMatch:!1,output:""};const y=a||{},x=y.format||(h?r.toPosixSlashes:null);let g=i===b,$=g&&x?x(i):i;return g===!1&&($=x?x(i):i,g=$===b),(g===!1||y.capture===!0)&&(y.matchBase===!0||y.basename===!0?g=s.matchBase(i,u,a,h):g=u.exec($)),{isMatch:!!g,match:g,output:$}},s.matchBase=(i,u,a)=>(u instanceof RegExp?u:s.makeRe(u,a)).test(r.basename(i)),s.isMatch=(i,u,a)=>s(u,a)(i),s.parse=(i,u)=>Array.isArray(i)?i.map(a=>s.parse(a,u)):e(i,{...u,fastpaths:!1}),s.scan=(i,u)=>t(i,u),s.compileRe=(i,u,a=!1,b=!1)=>{if(a===!0)return i.output;const h=u||{},y=h.contains?"":"^",x=h.contains?"":"$";let g=`${y}(?:${i.output})${x}`;i&&i.negated===!0&&(g=`^(?!${g}).*$`);const $=s.toRegex(g,u);return b===!0&&($.state=i),$},s.makeRe=(i,u={},a=!1,b=!1)=>{if(!i||typeof i!="string")throw new TypeError("Expected a non-empty string");let h={negated:!1,fastpaths:!0};return u.fastpaths!==!1&&(i[0]==="."||i[0]==="*")&&(h.output=e.fastpaths(i,u)),h.output||(h=e(i,u)),s.compileRe(h,u,a,b)},s.toRegex=(i,u)=>{try{const a=u||{};return new RegExp(i,a.flags||(a.nocase?"i":""))}catch(a){if(u&&u.debug===!0)throw a;return/$^/}},s.constants=o,me=s,me}var be,qe;function Ks(){if(qe)return be;qe=1;const t=qs(),e=fe();function r(o,n,s=!1){return n&&(n.windows===null||n.windows===void 0)&&(n={...n,windows:e.isWindows()}),t(o,n,s)}return Object.assign(r,t),be=r,be}var Xs=Ks();const yt=Ce(Xs),Qs=B(import.meta.url),Dt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,oe=t=>{if(typeof Dt<"u"&&Dt.versions&&Dt.versions.node){const[e,r]=Dt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Dt.getBuiltinModule(t)}return Qs(t)},Ke=oe("fs"),Zs={...Ke,default:Ke},{statSync:Ys,stat:Vs,realpathSync:Js,realpath:to,readdirSync:eo,readdir:ro}=oe("fs"),{sep:gr,basename:so,dirname:Re,resolve:dr,normalize:oo,relative:no,posix:mt,isAbsolute:io}=oe("path"),{fileURLToPath:uo}=oe("url"),{createRequire:lo}=oe("module");var Xe=lo(import.meta.url);function ao(t){let e=oo(t);return e.length>1&&e[e.length-1]===gr&&(e=e.substring(0,e.length-1)),e}const co=/[\\/]/g;function yr(t,e){return t.replace(co,e)}const po=/^[a-z]:[\\/]$/i;function fo(t){return t==="/"||po.test(t)}function $e(t,e){const{resolvePaths:r,normalizePath:o,pathSeparator:n}=e,s=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(r&&(t=dr(t)),(o||s)&&(t=ao(t)),t===".")return"";const i=t[t.length-1]!==n;return yr(i?t+n:t,n)}function mr(t,e){return e+t}function ho(t,e){return function(r,o){return o.startsWith(t)?o.slice(t.length)+r:yr(no(t,o),e.pathSeparator)+e.pathSeparator+r}}function go(t){return t}function yo(t,e,r){return e+t+r}function mo(t,e){const{relativePaths:r,includeBasePath:o}=e;return r&&t?ho(t,e):o?mr:go}function bo(t){return function(e,r){r.push(e.substring(t.length)||".")}}function $o(t){return function(e,r,o){const n=e.substring(t.length)||".";o.every(s=>s(n,!0))&&r.push(n)}}const vo=(t,e)=>{e.push(t||".")},Eo=(t,e,r)=>{const o=t||".";r.every(n=>n(o,!0))&&e.push(o)},xo=()=>{};function Ao(t,e){const{includeDirs:r,filters:o,relativePaths:n}=e;return r?n?o&&o.length?$o(t):bo(t):o&&o.length?Eo:vo:xo}const So=(t,e,r,o)=>{o.every(n=>n(t,!1))&&r.files++},wo=(t,e,r,o)=>{o.every(n=>n(t,!1))&&e.push(t)},Ro=(t,e,r,o)=>{r.files++},To=(t,e)=>{e.push(t)},_o=()=>{};function ko(t){const{excludeFiles:e,filters:r,onlyCounts:o}=t;return e?_o:r&&r.length?o?So:wo:o?Ro:To}const Co=t=>t,Oo=()=>[""].slice(0,0);function No(t){return t.group?Oo:Co}const Lo=(t,e,r)=>{t.push({directory:e,files:r,dir:e})},Ho=()=>{};function Bo(t){return t.group?Lo:Ho}const Mo=function(t,e,r){const{queue:o,fs:n,options:{suppressErrors:s}}=e;o.enqueue(),n.realpath(t,(i,u)=>{if(i)return o.dequeue(s?null:i,e);n.stat(u,(a,b)=>{if(a)return o.dequeue(s?null:a,e);if(b.isDirectory()&&br(t,u,e))return o.dequeue(null,e);r(b,u),o.dequeue(null,e)})})},Do=function(t,e,r){const{queue:o,fs:n,options:{suppressErrors:s}}=e;o.enqueue();try{const i=n.realpathSync(t),u=n.statSync(i);if(u.isDirectory()&&br(t,i,e))return;r(u,i)}catch(i){if(!s)throw i}};function Io(t,e){return!t.resolveSymlinks||t.excludeSymlinks?null:e?Do:Mo}function br(t,e,r){if(r.options.useRealPaths)return Po(e,r);let o=Re(t),n=1;for(;o!==r.root&&n<2;){const s=r.symlinks.get(o);s&&(s===e||s.startsWith(e)||e.startsWith(s))?n++:o=Re(o)}return r.symlinks.set(t,e),n>1}function Po(t,e){return e.visited.includes(t+e.options.pathSeparator)}const Fo=t=>t.counts,Go=t=>t.groups,Uo=t=>t.paths,jo=t=>t.paths.slice(0,t.options.maxFiles),zo=(t,e,r)=>(he(e,r,t.counts,t.options.suppressErrors),null),Wo=(t,e,r)=>(he(e,r,t.paths,t.options.suppressErrors),null),qo=(t,e,r)=>(he(e,r,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),Ko=(t,e,r)=>(he(e,r,t.groups,t.options.suppressErrors),null);function he(t,e,r,o){e(t&&!o?t:null,r)}function Xo(t,e){const{onlyCounts:r,group:o,maxFiles:n}=t;return r?e?Fo:zo:o?e?Go:Ko:n?e?jo:qo:e?Uo:Wo}const $r={withFileTypes:!0},Qo=(t,e,r,o,n)=>{if(t.queue.enqueue(),o<0)return t.queue.dequeue(null,t);const{fs:s}=t;t.visited.push(e),t.counts.directories++,s.readdir(e||".",$r,(i,u=[])=>{n(u,r,o),t.queue.dequeue(t.options.suppressErrors?null:i,t)})},Zo=(t,e,r,o,n)=>{const{fs:s}=t;if(o<0)return;t.visited.push(e),t.counts.directories++;let i=[];try{i=s.readdirSync(e||".",$r)}catch(u){if(!t.options.suppressErrors)throw u}n(i,r,o)};function Yo(t){return t?Zo:Qo}var Vo=class{count=0;constructor(t){this.onQueueEmpty=t}enqueue(){return this.count++,this.count}dequeue(t,e){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,e),t&&(e.controller.abort(),this.onQueueEmpty=void 0))}},Jo=class{_files=0;_directories=0;set files(t){this._files=t}get files(){return this._files}set directories(t){this._directories=t}get directories(){return this._directories}get dirs(){return this._directories}},tn=class{aborted=!1;abort(){this.aborted=!0}},vr=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,r,o){this.isSynchronous=!o,this.callbackInvoker=Xo(r,this.isSynchronous),this.root=$e(e,r),this.state={root:fo(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new Jo,options:r,queue:new Vo((n,s)=>this.callbackInvoker(s,n,o)),symlinks:new Map,visited:[""].slice(0,0),controller:new tn,fs:r.fs||Zs},this.joinPath=mo(this.root,r),this.pushDirectory=Ao(this.root,r),this.pushFile=ko(r),this.getArray=No(r),this.groupFiles=Bo(r),this.resolveSymlink=Io(r,this.isSynchronous),this.walkDirectory=Yo(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,r,o)=>{const{paths:n,options:{filters:s,resolveSymlinks:i,excludeSymlinks:u,exclude:a,maxFiles:b,signal:h,useRealPaths:y,pathSeparator:x},controller:g}=this.state;if(g.aborted||h&&h.aborted||b&&n.length>b)return;const $=this.getArray(this.state.paths);for(let _=0;_<e.length;++_){const R=e[_];if(R.isFile()||R.isSymbolicLink()&&!i&&!u){const O=this.joinPath(R.name,r);this.pushFile(O,$,this.state.counts,s)}else if(R.isDirectory()){let O=yo(R.name,r,this.state.options.pathSeparator);if(a&&a(R.name,O))continue;this.pushDirectory(O,n,s),this.walkDirectory(this.state,O,O,o-1,this.walk)}else if(this.resolveSymlink&&R.isSymbolicLink()){let O=mr(R.name,r);this.resolveSymlink(O,this.state,(d,E)=>{if(d.isDirectory()){if(E=$e(E,this.state.options),a&&a(R.name,y?E:O+x))return;this.walkDirectory(this.state,E,y?E:O+x,o-1,this.walk)}else{E=y?E:O;const l=so(E),A=$e(Re(E),this.state.options);E=this.joinPath(l,A),this.pushFile(E,$,this.state.counts,s)}})}}this.groupFiles(this.state.groups,r,$)}};function en(t,e){return new Promise((r,o)=>{Er(t,e,(n,s)=>{if(n)return o(n);r(s)})})}function Er(t,e,r){new vr(t,e,r).start()}function rn(t,e){return new vr(t,e).start()}var Qe=class{constructor(e,r){this.root=e,this.options=r}withPromise(){return en(this.root,this.options)}withCallback(e){Er(this.root,this.options,e)}sync(){return rn(this.root,this.options)}};let xr=null;try{Xe.resolve("picomatch"),xr=Xe("picomatch")}catch{}var sn=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:gr,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:t=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=!0,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(t){return new Qe(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,e){return this.options={...this.options,...e},new Qe(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:!0})}globWithOptions(t,...e){const r=this.globFunction||xr;if(!r)throw new Error("Please specify a glob function to use glob matching.");var o=this.globCache[t.join("\0")];return o||(o=r(t,...e),this.globCache[t.join("\0")]=o),this.options.filters.push(n=>o(n)),this}};const on=Array.isArray,Ar=/\\/g,nn=/^[A-Za-z]:$/,Sr=process.platform==="win32",un=/^(\/?\.\.)+$/;function Ze(t,e={}){const r=t.length,o=Array(r),n=Array(r);let s,i;for(s=0;s<r;s++){const u=wr(t[s]);o[s]=u;const a=u.length,b=Array(a);for(i=0;i<a;i++)b[i]=yt(u[i],e);n[s]=b}return u=>{const a=u.split("/");if(a[0]===".."&&un.test(u))return!0;for(s=0;s<r;s++){const b=o[s],h=n[s],y=a.length,x=Math.min(y,b.length);for(i=0;i<x;){const g=b[i];if(g.includes("/"))return!0;if(!h[i](a[i]))break;if(!e.noglobstar&&g==="**")return!0;i++}if(i===y)return!0}return!1}}const ln=/^[A-Z]:\/$/i,an=Sr?t=>ln.test(t):t=>t==="/";function Ye(t,e,r){if(t===e||e.startsWith(`${t}/`)){if(r){const n=t.length+ +!an(t);return(s,i)=>s.slice(n,i?-1:void 0)||"."}const o=e.slice(t.length+1);return o?(n,s)=>{if(n===".")return o;const i=`${o}/${n}`;return s?i.slice(0,-1):i}:(n,s)=>s&&n!=="."?n.slice(0,-1):n}return r?o=>mt.relative(t,o)||".":o=>mt.relative(t,`${e}/${o}`)||"."}function cn(t,e){if(e.startsWith(`${t}/`)){const r=e.slice(t.length+1);return o=>`${r}/${o}`}return r=>{const o=mt.relative(t,`${e}/${r}`);return r[r.length-1]==="/"&&o!==""?`${o}/`:o||"."}}function Ve(t){return t.replace(nn,e=>`${e}/`)}const pn={parts:!0};function wr(t){var e;const r=yt.scan(t,pn);return!((e=r.parts)===null||e===void 0)&&e.length?r.parts:[t]}const fn=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,hn=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,gn=t=>t.replace(fn,"\\$&"),dn=t=>t.replace(hn,"\\$&"),yn=Sr?dn:gn;function mn(t,e){const r=yt.scan(t);return r.isGlob||r.negated}function se(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t)}function Rr(t){return typeof t=="string"?[t]:t??[]}const bn=/^(\/?\.\.)+/,$n=/\\(?=[()[\]{}!*+?@|])/g;function ve(t,e,r,o){var n;const s=e.cwd;let i=t;t[t.length-1]==="/"&&(i=t.slice(0,-1));const u=i.lastIndexOf("/"),a=(u===-1?i:i.slice(u+1)).startsWith("!(");i[i.length-1]!=="*"&&!a&&e.expandDirectories&&(i+="/**");const b=yn(s);i=io(i.replace($n,""))?mt.relative(b,i):mt.normalize(i);const h=(n=bn.exec(i))===null||n===void 0?void 0:n[0],y=wr(i);if(h){const g=(h.length+1)/3;let $=0;const _=b.split("/");for(;$<g&&y[$+g]===_[_.length+$-g];)i=i.slice(0,(g-$-1)*3)+i.slice((g-$)*3+y[$+g].length+1)||".",$++;const R=mt.join(s,h.slice($*3));R[0]!=="."&&r.root.length>R.length&&(r.root=Ve(R),r.depthOffset=-g+$)}if(!o&&r.depthOffset>=0){var x;(x=r.commonPath)!==null&&x!==void 0||(r.commonPath=y);const g=[],$=Math.min(r.commonPath.length,y.length);for(let _=0;_<$;_++){const R=y[_];if(R==="**"&&!y[_+1]){g.pop();break}if(_===y.length-1||R!==r.commonPath[_]||mn(R))break;g.push(R)}r.depthOffset=g.length,r.commonPath=g,r.root=Ve(g.length>0?mt.join(s,...g):s)}return i}function vn(t,e,r){const o=[],n=[],s=[];for(const i of t.ignore)i&&(i[0]!=="!"||i[1]==="("?n.push(ve(i,t,r,!0)):s.push(i.slice(1)));for(const i of e)i&&(i[0]!=="!"||i[1]==="("?o.push(ve(i,t,r,!1)):(i[1]!=="!"||i[2]==="(")&&n.push(ve(i.slice(1),t,r,!0)));return{match:o,ignore:n,unignore:s}}function En(t,e){const r=t.cwd,o={root:r,depthOffset:0},n=vn(t,e,o);t.debug&&se("internal processing patterns:",n);const{absolute:s,caseSensitiveMatch:i,debug:u,dot:a,followSymbolicLinks:b,onlyDirectories:h}=t,y=o.root.replace(Ar,""),x={dot:a,nobrace:t.braceExpansion===!1,nocase:!i,noextglob:t.extglob===!1,noglobstar:t.globstar===!1,posix:!0},g=n.unignore.length>0,$=g?yt(n.unignore,x):void 0,_=g?Ze(n.unignore,x):void 0,R=yt(n.match,{...x,ignore:n.ignore,onIgnore:$?k=>$(k.output)&&yt.constants.UNIGNORE:void 0}),O=yt(n.ignore,x),d=Ze(n.match,x),E=Ye(r,y,s),l=s?E:Ye(r,y,!0),A=n.match.length>0&&n.match.every(k=>k==="**"||k==="**/*"),w=n.ignore.length>0||g||!A?(k,F)=>{const D=l(F,!0);return D==="."||_&&_(D)?!1:!d(D)||O(D)}:void 0;let T;t.deep!==void 0&&(T=Math.round(t.deep-o.depthOffset));const S=new sn({filters:[u?(k,F)=>{const D=E(k,F),U=R(D);return U&&se(`matched ${D}`),U}:(k,F)=>{const D=E(k,F);return R(D)}],exclude:u&&w?(k,F)=>{const D=w(k,F);return se(`${D?"skipped":"crawling"} ${F}`),D}:w,fs:t.fs,pathSeparator:"/",relativePaths:!s,resolvePaths:s,includeBasePath:s,resolveSymlinks:b,excludeSymlinks:!b,excludeFiles:h,includeDirs:h||!t.onlyFiles,maxDepth:T,signal:t.signal}).crawl(y);return t.debug&&se("internal properties:",{...o,root:y}),[S,r!==y&&!s&&cn(r,y)]}function xn(t,e){if(e)for(let r=t.length-1;r>=0;r--)t[r]=e(t[r]);return t}const Je={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function An(t){const e=Object.assign({},t);for(const r in Je)e[r]===void 0&&Object.assign(e,{[r]:Je[r]});return e.cwd=(e.cwd instanceof URL?uo(e.cwd):dr(e.cwd||process.cwd())).replace(Ar,"/"),e.ignore=Rr(e.ignore),e.fs&&(e.fs={readdir:e.fs.readdir||ro,readdirSync:e.fs.readdirSync||eo,realpath:e.fs.realpath||to,realpathSync:e.fs.realpathSync||Js,stat:e.fs.stat||Vs,statSync:e.fs.statSync||Ys}),e.debug&&se("globbing with options:",e),e}function Sn(t,e={}){var r;if(t&&e?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");const o=on(t)||typeof t=="string",n=Rr((r=o?t:t.patterns)!==null&&r!==void 0?r:"**/*"),s=An(o?e:t);return n.length>0?En(s,n):[]}async function hu(t,e){const[r,o]=Sn(t,e);return r?xn(await r.withPromise(),o):[]}var Ee,tr;function wn(){if(tr)return Ee;tr=1;/*!
|
|
2
|
+
* is-extglob <https://github.com/jonschlinkert/is-extglob>
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2014-2016, Jon Schlinkert.
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
*/return Ee=function(t){if(typeof t!="string"||t==="")return!1;for(var e;e=/(\\).|([@?!+*]\(.*\))/g.exec(t);){if(e[2])return!0;t=t.slice(e.index+e[0].length)}return!1},Ee}var xe,er;function Tr(){if(er)return xe;er=1;/*!
|
|
7
|
+
* is-glob <https://github.com/jonschlinkert/is-glob>
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
10
|
+
* Released under the MIT License.
|
|
11
|
+
*/var t=wn(),e={"{":"}","(":")","[":"]"},r=function(n){if(n[0]==="!")return!0;for(var s=0,i=-2,u=-2,a=-2,b=-2,h=-2;s<n.length;){if(n[s]==="*"||n[s+1]==="?"&&/[\].+)]/.test(n[s])||u!==-1&&n[s]==="["&&n[s+1]!=="]"&&(u<s&&(u=n.indexOf("]",s)),u>s&&(h===-1||h>u||(h=n.indexOf("\\",s),h===-1||h>u)))||a!==-1&&n[s]==="{"&&n[s+1]!=="}"&&(a=n.indexOf("}",s),a>s&&(h=n.indexOf("\\",s),h===-1||h>a))||b!==-1&&n[s]==="("&&n[s+1]==="?"&&/[:!=]/.test(n[s+2])&&n[s+3]!==")"&&(b=n.indexOf(")",s),b>s&&(h=n.indexOf("\\",s),h===-1||h>b))||i!==-1&&n[s]==="("&&n[s+1]!=="|"&&(i<s&&(i=n.indexOf("|",s)),i!==-1&&n[i+1]!==")"&&(b=n.indexOf(")",i),b>i&&(h=n.indexOf("\\",i),h===-1||h>b))))return!0;if(n[s]==="\\"){var y=n[s+1];s+=2;var x=e[y];if(x){var g=n.indexOf(x,s);g!==-1&&(s=g+1)}if(n[s]==="!")return!0}else s++}return!1},o=function(n){if(n[0]==="!")return!0;for(var s=0;s<n.length;){if(/[*?{}()[\]]/.test(n[s]))return!0;if(n[s]==="\\"){var i=n[s+1];s+=2;var u=e[i];if(u){var a=n.indexOf(u,s);a!==-1&&(s=a+1)}if(n[s]==="!")return!0}else s++}return!1};return xe=function(n,s){if(typeof n!="string"||n==="")return!1;if(t(n))return!0;var i=r;return s&&s.strict===!1&&(i=o),i(n)},xe}const Rn=B(import.meta.url),It=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_r=t=>{if(typeof It<"u"&&It.versions&&It.versions.node){const[e,r]=It.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return It.getBuiltinModule(t)}return Rn(t)},Tn=_r("path"),_n=_r("os");var Ae,rr;function kn(){if(rr)return Ae;rr=1;var t=Tr(),e=Tn.posix.dirname,r=_n.platform()==="win32",o="/",n=/\\/g,s=/\\([!*?|[\](){}])/g;Ae=function(a,b){var h=Object.assign({flipBackslashes:!0},b);h.flipBackslashes&&r&&a.indexOf(o)<0&&(a=a.replace(n,o)),i(a)&&(a+=o),a+="a";do a=e(a);while(u(a));return a.replace(s,"$1")};function i(a){var b=a.slice(-1),h;switch(b){case"}":h="{";break;case"]":h="[";break;default:return!1}var y=a.indexOf(h);return y<0?!1:a.slice(y+1,-1).includes(o)}function u(a){return/\([^()]+$/.test(a)||a[0]==="{"||a[0]==="["||/[^\\][{[]/.test(a)?!0:t(a)}return Ae}var Cn=kn();Ce(Cn);const On=B(import.meta.url),Pt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Nn=t=>{if(typeof Pt<"u"&&Pt.versions&&Pt.versions.node){const[e,r]=Pt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Pt.getBuiltinModule(t)}return On(t)},{access:Ln}=Nn("node:fs/promises");async function gu(t,e=_e){pt(t),t=ct(t);try{return await Ln(t,e),!0}catch{return!1}}const Hn=B(import.meta.url),Ft=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Bn=t=>{if(typeof Ft<"u"&&Ft.versions&&Ft.versions.node){const[e,r]=Ft.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Ft.getBuiltinModule(t)}return Hn(t)},{accessSync:Mn}=Bn("node:fs");function Te(t,e=_e){pt(t),t=ct(t);try{return Mn(t,e),!0}catch{return!1}}var Dn=Tr();Ce(Dn);const In=B(import.meta.url),Gt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,kr=t=>{if(typeof Gt<"u"&&Gt.versions&&Gt.versions.node){const[e,r]=Gt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Gt.getBuiltinModule(t)}return In(t)};kr("node:fs/promises");kr("node:fs");let Pn=class extends Error{constructor(e){super(`ENOENT: ${e}`)}get code(){return"ENOENT"}set code(e){throw new Error("Cannot overwrite code ENOENT")}get name(){return"NotFoundError"}set name(e){throw new Error("Cannot overwrite name of NotFoundError")}},Fn=class extends Error{constructor(e){super(`EPERM: Operation not permitted, ${e}`)}get code(){return"EPERM"}set code(e){throw new Error("Cannot overwrite code EPERM")}get name(){return"PermissionError"}set name(e){throw new Error("Cannot overwrite name of PermissionError")}};const Cr=(t,e)=>{const r=t?.code;return r==="ENOENT"?new Pn(`no such file or directory, open '${e}'`):r==="EACCES"||r==="EPERM"?new Fn(`unable to read the non-readable file: ${e}`):t},Gn=B(import.meta.url),Ut=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Or=t=>{if(typeof Ut<"u"&&Ut.versions&&Ut.versions.node){const[e,r]=Ut.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Ut.getBuiltinModule(t)}return Gn(t)},{readFile:Un}=Or("node:fs/promises"),{unzip:jn,brotliDecompress:zn}=Or("node:zlib"),Wn={brotli:zn,gzip:jn,none:(t,e)=>{e(null,t)}},mu=async(t,e)=>{pt(t),t=ct(t);const{buffer:r,compression:o,encoding:n,flag:s}=e??{};let i;try{i=await Un(t,s?{flag:s}:{})}catch(u){throw Cr(u,t)}return await new Promise((u,a)=>{Wn[o??"none"](i,(b,h)=>{b?a(b):u(r?h:h.toString(n??"utf8"))})})},qn=B(import.meta.url),jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Nr=t=>{if(typeof jt<"u"&&jt.versions&&jt.versions.node){const[e,r]=jt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return jt.getBuiltinModule(t)}return qn(t)},{readFileSync:Kn}=Nr("node:fs"),{unzipSync:Xn,brotliDecompressSync:Qn}=Nr("node:zlib"),Zn={brotli:Qn,gzip:Xn,none:t=>t},bu=(t,e)=>{pt(t),t=ct(t);const{buffer:r,compression:o,encoding:n,flag:s}=e??{};let i;try{i=Kn(t,s?{flag:s}:{})}catch(b){throw Cr(b,t)}const u=Zn[o??"none"],a=u(i);return r?a:a.toString(n??"utf8")},Yn=B(import.meta.url),zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Vn=t=>{if(typeof zt<"u"&&zt.versions&&zt.versions.node){const[e,r]=zt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return zt.getBuiltinModule(t)}return Yn(t)},{createRequire:Lr}=Vn("node:module"),Jn=globalThis.process??Object.create(null),sr={versions:{}},or=new Proxy(Jn,{get(t,e){if(e in t)return t[e];if(e in sr)return sr[e]}}),ti=t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
12
|
+
`),ei=(t,e,r,o)=>{const n={column:0,line:-1,...t.start},s={...n,...t.end},i=n.line,u=n.column,a=s.line,b=s.column;let h=Math.max(i-(r+1),0),y=Math.min(e.length,a+o);i===-1&&(h=0),a===-1&&(y=e.length);const x=a-i,g={};if(x)for(let $=0;$<=x;$++){const _=$+i;if(!u)g[_]=!0;else if($===0){const R=e[_-1]?.length;g[_]=[u,(R??0)-u+1]}else if($===x)g[_]=[0,b];else{const R=e[_-$]?.length;g[_]=[0,R]}}else u===b?g[i]=u?[u,0]:!0:g[i]=[u,(b??0)-(u??0)];return{end:y,markerLines:g,start:h}},ri=or.platform==="win32"&&!or.env?.WT_SESSION?">":"❯",$u=(t,e,r)=>{const o={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...r,color:{gutter:$=>$,marker:$=>$,message:$=>$,...r?.color}},n=typeof e.start.column=="number";let s=(t.includes("\r")?ti(t):t).split(`
|
|
13
|
+
`);typeof o.tabWidth=="number"&&t.includes(" ")&&(s=s.map($=>$.replaceAll(" "," ".repeat(o.tabWidth))));const{end:i,markerLines:u,start:a}=ei(e,s,o.linesAbove,o.linesBelow),b=String(i).length,{gutter:h,marker:y,message:x}=o.color;let g=s.slice(a,i).map(($,_)=>{const R=a+1+_,O=u[R],d=String(R).padStart(b),E=!u[R+1],l=` ${d}${o.showGutter?" |":""}`;if(O){let A="";if(Array.isArray(O)){const w=$.replaceAll(/[^\t]/g," ").slice(0,Math.max(O[0]-1,0)),T=O[1]||1;A=[`
|
|
14
|
+
`,o.prefix+h(l.replaceAll(/\d/g," "))," ",w,y("^").repeat(T)].join(""),E&&o.message&&(A+=` ${x(o.message)}`)}return[o.prefix+y(ri),h(l),$.length>0?` ${$}`:"",A].join("")}return`${o.prefix} ${h(l)}${$.length>0?` ${$}`:""}`}).join(`
|
|
15
|
+
`);return o.message&&!n&&(g=`${o.prefix+" ".repeat(b+1)+o.message}
|
|
16
|
+
${g}`),g},nr=(t,e)=>{let r=0,o=e.length-2;for(;r<o;){const n=r+(o-r>>1);if(t<e[n])o=n-1;else if(t>=e[n+1])r=n+1;else{r=n;break}}return r},si=/\n|\r(?!\n)/,oi=t=>t.split(si).reduce((e,r)=>(e.push(e.at(-1)+r.length+1),e),[0]),vu=(t,e,r)=>{if(!Array.isArray(t)&&typeof t!="string"||(typeof t=="string"||Array.isArray(t))&&t.length===0)return{column:0,line:0};if(typeof e!="number"||typeof t=="string"&&e>=t.length||Array.isArray(t)&&e+1>=t.at(-1))return{column:0,line:0};if(typeof t=="string"){const n=oi(t),s=nr(e,n);return{column:e-n[s]+1,line:s+1}}const o=nr(e,t);return{column:e-t[o]+1,line:o+1}},ni=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&ni.set("AggregateError",AggregateError);const ii=Lr(import.meta.url),Wt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ui=t=>{if(typeof Wt<"u"&&Wt.versions&&Wt.versions.node){const[e,r]=Wt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Wt.getBuiltinModule(t)}return ii(t)};ui("node:util");const li=Lr(import.meta.url),qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Oe=t=>{if(typeof qt<"u"&&qt.versions&&qt.versions.node){const[e,r]=qt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return qt.getBuiltinModule(t)}return li(t)};Oe("node:fs");Oe("node:path");Oe("node:url");let Eu=class extends Error{fileName;codeFrame;name="JSONError";#t;constructor(e){super(),this.#t=e}get message(){return`${this.#t}${this.fileName?` in ${this.fileName}`:""}${this.codeFrame?`
|
|
17
|
+
|
|
18
|
+
${this.codeFrame}
|
|
19
|
+
`:""}`}set message(e){this.#t=e}};const ai=t=>{const e={force:!0,recursive:!0};return t?.maxRetries!==void 0&&(e.maxRetries=t.maxRetries),t?.retryDelay!==void 0&&(e.retryDelay=t.retryDelay),e},ci=B(import.meta.url),Kt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Hr=t=>{if(typeof Kt<"u"&&Kt.versions&&Kt.versions.node){const[e,r]=Kt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Kt.getBuiltinModule(t)}return ci(t)};Hr("node:fs");Hr("node:fs/promises");const pi=B(import.meta.url),Xt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,fi=t=>{if(typeof Xt<"u"&&Xt.versions&&Xt.versions.node){const[e,r]=Xt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Xt.getBuiltinModule(t)}return pi(t)};fi("node:fs");const hi=B(import.meta.url),Qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,gi=t=>{if(typeof Qt<"u"&&Qt.versions&&Qt.versions.node){const[e,r]=Qt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Qt.getBuiltinModule(t)}return hi(t)};gi("node:fs/promises");const di=B(import.meta.url),Zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,yi=t=>{if(typeof Zt<"u"&&Zt.versions&&Zt.versions.node){const[e,r]=Zt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Zt.getBuiltinModule(t)}return di(t)},{rmSync:mi}=yi("node:fs"),Au=(t,e={})=>{pt(t),mi(t,ai(e))};B(import.meta.url);const bi=t=>{if(typeof t!="string"&&!(t instanceof ArrayBuffer)&&!ArrayBuffer.isView(t))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},$i=B(import.meta.url),Yt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vi=t=>{if(typeof Yt<"u"&&Yt.versions&&Yt.versions.node){const[e,r]=Yt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Yt.getBuiltinModule(t)}return $i(t)},{randomBytes:Ei}=vi("node:crypto"),xi=t=>`${t}.${process.pid.toString(36)}.${Ei(6).toString("hex")}.tmp`,Ai=new TextEncoder,Si=t=>{if(t instanceof Uint8Array)return t;if(typeof t=="string")return Ai.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t)){const e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},wi=B(import.meta.url),Vt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ri=t=>{if(typeof Vt<"u"&&Vt.versions&&Vt.versions.node){const[e,r]=Vt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Vt.getBuiltinModule(t)}return wi(t)};Ri("node:fs/promises");const Ti=B(import.meta.url),Jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_i=t=>{if(typeof Jt<"u"&&Jt.versions&&Jt.versions.node){const[e,r]=Jt.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return Jt.getBuiltinModule(t)}return Ti(t)},{mkdirSync:ki,writeFileSync:Ci,statSync:Oi,renameSync:ir,chownSync:Ni,chmodSync:Li,unlinkSync:Hi}=_i("node:fs"),Bi=(t,e,r)=>{r={backup:!1,encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},pt(t),bi(e),t=ct(t);const o=Te(t,_e);if(o&&!r.overwrite)throw new is(`file already exists, open '${t}'`);const n=xi(t);try{!o&&r.recursive&&ki(ke(t),{recursive:!0});let s;if(Ci(n,typeof e=="string"?Buffer.from(e,r.encoding??"utf8"):Si(e),{flag:"wx"}),o&&r.backup&&(s=Oi(t),r.chown??={gid:s.gid,uid:s.uid},ir(t,`${t}.bak`)),r.chown)try{Ni(n,r.chown.uid,r.chown.gid)}catch{}Li(n,s&&!r.mode?s.mode:r.mode??438),ir(n,t)}catch(s){throw new Error(`Failed to write file at: ${t} - ${s.message}`,{cause:s})}finally{Te(n)&&Hi(n)}},Mi=/^(?:( )+|\t+)/,ne="space";function ur(t,e,r){return t&&e===ne&&r===1}function lr(t,e){const r=new Map;let o=0,n,s;for(const i of t.split(/\n/g)){if(!i)continue;const u=i.match(Mi);if(u===null)o=0,n="";else{const a=u[0].length,b=u[1]?ne:"tab";if(ur(e,b,a))continue;b!==n&&(o=0),n=b;let h=1,y=0;const x=a-o;if(o=a,x===0)h=0,y=1;else{const $=Math.abs(x);if(ur(e,b,$))continue;s=Di(b,$)}const g=r.get(s);r.set(s,g===void 0?[1,0]:[g[0]+h,g[1]+y])}}return r}function Di(t,e){return(t===ne?"s":"t")+String(e)}function Ii(t){const e=t[0]==="s"?ne:"tab",r=Number(t.slice(1));return{type:e,amount:r}}function Pi(t){let e,r=0,o=0;for(const[n,[s,i]]of t)(s>r||s===r&&i>o)&&(r=s,o=i,e=n);return e}function Fi(t,e){return(t===ne?" ":" ").repeat(e)}function Gi(t){if(typeof t!="string")throw new TypeError("Expected a string");let e=lr(t,!0);e.size===0&&(e=lr(t,!1));const r=Pi(e);let o,n=0,s="";return r!==void 0&&({type:o,amount:n}=Ii(r),s=Fi(o,n)),{amount:n,type:o,indent:s}}const Ui=B(import.meta.url),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ji=t=>{if(typeof te<"u"&&te.versions&&te.versions.node){const[e,r]=te.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return te.getBuiltinModule(t)}return Ui(t)};ji("node:fs/promises");const zi=B(import.meta.url),ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Wi=t=>{if(typeof ee<"u"&&ee.versions&&ee.versions.node){const[e,r]=ee.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return ee.getBuiltinModule(t)}return zi(t)},{readFileSync:qi}=Wi("node:fs"),Su=(t,e,r={})=>{const{detectIndent:o,indent:n,replacer:s,stringify:i=JSON.stringify,...u}={indent:" ",...r};let a=n,b=`
|
|
20
|
+
`;if(Te(t,Fr))try{const y=qi(t,"utf8");if(o){const{indent:x}=Gi(y);a=x}b=y.endsWith(`
|
|
21
|
+
`)?`
|
|
22
|
+
`:""}catch(y){if(y.code!=="ENOENT")throw y}const h=i(e,s,a);Bi(t,`${h}${b}`,u)},Ki=B(import.meta.url),re=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ne=t=>{if(typeof re<"u"&&re.versions&&re.versions.node){const[e,r]=re.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return re.getBuiltinModule(t)}return Ki(t)},Xi=Ne("fs"),Qi=Ne("os"),Zi=Ne("path");var Se={},ar;function Yi(){if(ar)return Se;ar=1;var t=Object.defineProperty,e=(h,y)=>t(h,"name",{value:y,configurable:!0}),r=Xi,o=Qi,n=Zi;const s=e(h=>{let y="";for(let x=0;x<h.length;x+=1){const g=h[x],$=g.toUpperCase();y+=g===$?g.toLowerCase():$}return y},"invertCase"),i=new Map,u=e((h,y)=>{const x=n.join(h,`.is-fs-case-sensitive-test-${process.pid}`);try{return y.writeFileSync(x,""),!y.existsSync(s(x))}finally{try{y.unlinkSync(x)}catch{}}},"checkDirectoryCaseWithWrite"),a=e((h,y,x)=>{try{return u(h,x)}catch(g){if(y===void 0)return u(o.tmpdir(),x);throw g}},"checkDirectoryCaseWithFallback"),b=e((h,y=r,x=!0)=>{const g=h??process.cwd();if(x&&i.has(g))return i.get(g);let $;const _=s(g);return _!==g&&y.existsSync(g)?$=!y.existsSync(_):$=a(g,h,y),x&&i.set(g,$),$},"isFsCaseSensitive");return Se.isFsCaseSensitive=b,Se}var Vi=Yi();const wu=Vi.isFsCaseSensitive;export{bt as A,vt as B,cu as F,ke as H,Ds as I,fr as J,ct as L,Su as O,Bi as T,$u as U,hu as W,uu as a,gu as b,mu as c,iu as d,Pn as e,Te as f,ae as g,ou as h,tu as i,Yr as j,wu as k,Au as l,Qr as m,eu as o,Eu as s,bu as v,ru as w,su as y,vu as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as h,D as k,f as S}from"./provenance-
|
|
1
|
+
import{m as h,D as k,f as S}from"./provenance-R2csDSNg.js";import{g as $}from"./packument-C-A3Uhhx.js";import{H as d}from"./env-Ct3hMEYB.js";import{W as N}from"./build-scripts-MTSK6TNr.js";import{n as v}from"./license-t5KnNX6v.js";import{A as R,B as L,v as D}from"./index-CE6MsgcV.js";import{D as A}from"../packem_chunks/cli-main.js";import"./public-api-WqUCiyIe.js";import{L as w}from"./dependency-scan-DpOFiZuI.js";const m={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},oe=(t,e)=>{const n=m[(t.vulnerability.severity??"UNKNOWN").toUpperCase()]??4,s=m[(e.vulnerability.severity??"UNKNOWN").toUpperCase()]??4;return n-s||t.packageName.localeCompare(e.packageName)||t.packageVersion.localeCompare(e.packageVersion)},P=(t,e)=>{const n=m[e.toUpperCase()]??2;return(m[t.toUpperCase()]??4)<=n},b=["firstSeen","installScripts","license","malware","publisherChange","score","unexpectedDeps","vulnerability"],g=6e4,W=(t,e,n)=>{for(const s of n)if(s===t||s===`${t}@${e}`||s.endsWith("*")&&t.startsWith(s.slice(0,-1)))return!0;return!1},x=async(t,e)=>{const n=e.security?.policies?.firstSeen;if(n?.minutes===void 0||n.minutes<=0)return[];const{minutes:s}=n,a=n.exclude??[],r=e.security?.acceptedRisks,c=s*g,i=Date.now();return(await h(t.packages,k,async o=>{if(W(o.name,o.version,a))return;const l=await $(o.name,{workspaceRoot:t.workspaceRoot});if(l===void 0)return;const p=l.time?.[o.version];if(p===void 0)return;const u=Date.parse(p);if(Number.isNaN(u))return;const f=i-u;if(f>=c)return;const y=Math.max(0,Math.floor(f/g));return{acceptedRisk:d(o.name,o.version,r,"firstSeen"),data:{ageMinutes:y,minimumMinutes:s,publishedAt:p},packageName:o.name,policy:"firstSeen",reason:`${o.name}@${o.version} was published ${String(y)} min ago — below the ${String(s)} min firstSeen cooldown.`,severity:"block",version:o.version}})).filter(o=>o!==void 0)},O=(t,e)=>{const n=e.security?.policies?.installScripts;if(!n)return[];const s=n.allow??{},a=n.strict===!0;if(!a&&Object.keys(s).length===0)return[];const r=N(t.workspaceRoot,s,{pinVersions:e.security?.pinVersions===!0});if(r.unapproved.length===0)return[];const c=e.security?.acceptedRisks,i=a?"block":"warn";return r.unapproved.map(o=>({acceptedRisk:d(o.name,o.version??"*",c,"installScripts"),data:{hooks:o.hooks},packageName:o.name,policy:"installScripts",reason:`${o.name}${o.version?`@${o.version}`:""} declares unapproved build script(s): ${o.hooks.join(", ")}`,severity:i,version:o.version??"*"}))},U=new Set(["AND","OR"]),E=t=>{const e=t.replaceAll("("," ").replaceAll(")"," ").split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0),n=[];let s=!1;for(const a of e){const r=a.toUpperCase();if(s){s=!1;continue}if(r==="WITH"){s=!0;continue}if(U.has(r))continue;const c=a.endsWith("+"),i=c?a.slice(0,-1):a,o=v(i)??i;n.push(o),c&&n.push(`${o}-or-later`)}return n},F=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(n=>n&&typeof n.type=="string"?n.type.trim():"").filter(n=>n.length>0);if(e.length>0)return e.length===1?e[0]:`(${e.join(" OR ")})`}},I=(t,e)=>{if(e.length===0)return;const n=new Set(e.map(s=>v(s)??s).map(s=>s.toLowerCase()));for(const s of t)if(n.has(s.toLowerCase()))return s},M=(t,e)=>{if(e.length===0)return;const n=new Set(e.map(s=>v(s)??s).map(s=>s.toLowerCase()));for(const s of t)if(!n.has(s.toLowerCase()))return s},V=(t,e)=>{const n=e.security?.policies?.license;if(!n)return[];const s=n.allow??[],a=n.deny??[];if(s.length===0&&a.length===0)return[];const r=e.security?.acceptedRisks,c=[];for(const i of t.packages){const o=t.manifestData?.get(`${i.name}@${i.version}`),l=o?F(o):void 0;if(!l){s.length>0&&c.push({acceptedRisk:d(i.name,i.version,r,"license"),data:{declaredLicense:null},packageName:i.name,policy:"license",reason:`${i.name}@${i.version} declares no license; allow-list mode requires one of: ${s.join(", ")}`,severity:"block",version:i.version});continue}const p=E(l),u=I(p,a);if(u){c.push({acceptedRisk:d(i.name,i.version,r,"license"),data:{declaredLicense:l,deniedLicense:u},packageName:i.name,policy:"license",reason:`${i.name}@${i.version} uses denied license '${u}' (declared: ${l})`,severity:"block",version:i.version});continue}const f=M(p,s);f&&c.push({acceptedRisk:d(i.name,i.version,r,"license"),data:{allowList:s,declaredLicense:l,unallowedLicense:f},packageName:i.name,policy:"license",reason:`${i.name}@${i.version} uses license '${f}' which is not on the allow-list (declared: ${l})`,severity:"block",version:i.version})}return c},j=6e4,_=(t,e,n)=>{for(const s of n)if(s===t||s===`${t}@${e}`||s.endsWith("*")&&t.startsWith(s.slice(0,-1)))return!0;return!1},H=async(t,e)=>{const n=e.security?.policies?.publisherChange;if(n?.mode!=="no-downgrade")return[];const s=n.exclude??[],a=typeof n.ignoreAfter=="number"?n.ignoreAfter*j:void 0,r=e.security?.acceptedRisks,c=Date.now();return(await h(t.packages,k,async i=>{if(_(i.name,i.version,s))return;const o=await $(i.name,{workspaceRoot:t.workspaceRoot});if(o===void 0)return;if(a!==void 0){const p=o.time?.[i.version],u=p===void 0?Number.NaN:Date.parse(p);if(!Number.isNaN(u)&&c-u>a)return}if(o.versions[i.version]?.dist?.attestations?.provenance!==void 0)return;const l=S(o,i.version);if(l!==void 0)return{acceptedRisk:d(i.name,i.version,r,"publisherChange"),data:{priorVersionWithProvenance:l},packageName:i.name,policy:"publisherChange",reason:`${i.name}@${i.version} dropped the provenance attestation that ${i.name}@${l} carried — publisher trust downgrade.`,severity:"block",version:i.version}})).filter(i=>i!==void 0)},T=t=>{for(const e of Object.values(w))for(const n of[e.file,...e.aliases??[]])if(t===n||t.endsWith(`/${n}`)||t.endsWith(`.${n}`))return e.type},K=(t,e,n)=>{const s=R(e)?e:L(t,e);let a;try{a=D(s)}catch{return}const r=T(s)??w[n]?.type;if(!r)return;const c=A(a,r);if(c.length===0)return;const i=new Set;for(const o of c)i.add(`${o.name}@${o.version}`);return i},z=(t,e)=>{for(const n of e)if(n===t||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},Y=(t,e)=>{const n=e.security?.policies?.unexpectedDeps;if(!n)return[];const s=n.allow??[],a=n.baselineLockfile;if(s.length===0&&!a)return[];const r=a?K(t.workspaceRoot,a,t.packageManager):void 0,c=e.security?.acceptedRisks,i=[];for(const o of t.packages){const l=s.length===0||z(o.name,s),p=r?r.has(`${o.name}@${o.version}`):!0;if(l&&p)continue;const u=[],f={};l||(u.push(`not on allow-list (${s.length} entr${s.length===1?"y":"ies"})`),f.allowList=s),!p&&r&&(u.push(`not present in baseline lockfile (${a})`),f.baselineLockfile=a),i.push({acceptedRisk:d(o.name,o.version,c,"unexpectedDeps"),data:f,packageName:o.name,policy:"unexpectedDeps",reason:`${o.name}@${o.version} is unexpected: ${u.join("; ")}`,severity:"block",version:o.version})}return i},q=(t,e)=>{if(!t.osvFindings||t.osvFindings.size===0)return[];const n=e.security?.policies?.vulnerability?.failOn,s=e.security?.acceptedRisks,a=[];for(const r of t.packages){const c=t.osvFindings.get(r.name);if(!(!c||c.length===0))for(const i of c){const o=n?P(i.severity,n)?"block":"warn":"info";a.push({acceptedRisk:d(r.name,r.version,s,"vulnerability"),data:{advisoryId:i.id,aliases:i.aliases??[],cvssScore:i.cvssScore,fixedVersions:i.fixedVersions,severity:i.severity,summary:i.summary},packageName:r.name,policy:"vulnerability",reason:`${i.severity} ${i.id} affects ${r.name}@${r.version}: ${i.summary}`,severity:o,version:r.version})}}return a},C=[{evaluate:q,isConfigured:t=>t.security?.policies?.vulnerability!==void 0,name:"vulnerability",offlineSupported:!0,surfaces:["audit","doctor"]},{evaluate:V,isConfigured:t=>{const e=t.security?.policies?.license;return!!(e&&(e.allow&&e.allow.length>0||e.deny&&e.deny.length>0))},name:"license",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:O,isConfigured:t=>{const e=t.security?.policies?.installScripts;return!!(e&&(e.allow&&Object.keys(e.allow).length>0||e.strict===!0))},name:"installScripts",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:Y,isConfigured:t=>{const e=t.security?.policies?.unexpectedDeps;return!!(e&&(e.allow&&e.allow.length>0||typeof e.baselineLockfile=="string"))},name:"unexpectedDeps",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:x,isConfigured:t=>{const e=t.security?.policies?.firstSeen?.minutes;return typeof e=="number"&&e>0},name:"firstSeen",offlineSupported:!1,surfaces:["audit","doctor","install"]},{evaluate:H,isConfigured:t=>t.security?.policies?.publisherChange?.mode==="no-downgrade",name:"publisherChange",offlineSupported:!1,surfaces:["audit","doctor","install"]}],B=(t,e,n)=>C.filter(s=>s.surfaces.includes(t)?n!==void 0?n.has(s.name):s.isConfigured(e):!1),re=async(t,e,n)=>{const s=B(e,n.visConfig,n.enabledPolicies),a=[];for(const r of s){if(t.offline&&!r.offlineSupported){a.push({packageName:"*",policy:r.name,reason:`policy.${r.name} skipped: requires network (--offline)`,severity:"info",version:"*"});continue}try{const c=await r.evaluate(t,n.visConfig);a.push(...c)}catch(c){const i=c instanceof Error?c.message:String(c);a.push({packageName:"*",policy:r.name,reason:`policy.${r.name} failed: ${i}`,severity:"info",version:"*"})}}return a},G=(()=>{const t=new Map;for(const e of b)t.set(e.toLowerCase(),e);return t})(),ae=()=>C.map(t=>t.name),ce=(t,e)=>{if(t===void 0)return;const n=t.trim().toLowerCase();if(n===""||n==="none")return new Set;if(n==="all")return new Set(b);const s=new Set;for(const a of t.split(",").map(r=>r.trim()).filter(r=>r.length>0)){const r=a.replace(/^_+/,"").replaceAll(/_+([a-z])/g,(i,o)=>o.toUpperCase()),c=G.get(r.toLowerCase());c===void 0?e?.(a):s.add(c)}return s};export{oe as c,re as e,ae as g,ce as p,P as s};
|
|
@@ -25,4 +25,4 @@ ${s}`},Un=(t,e)=>(t.length>0?`
|
|
|
25
25
|
`)},Vn=(t,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return vt(t,e,0)};class te extends Error{loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:i,message:s,name:o,stack:c,title:a}){super(s,{cause:e}),this.title=a,this.name=o,this.stack=c??this.stack,this.loc=i,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}}class k extends te{code;context;constructor(e,n,i){super({message:e,name:"CerebroError"}),this.code=n,this.context=i}}const R=new Uint32Array(65536),Tn=(t,e)=>{const n=t.length,i=e.length,s=1<<n-1;let o=-1,c=0,a=n,u=n;for(;u--;)R[t.charCodeAt(u)]|=1<<u;for(u=0;u<i;u++){let r=R[e.charCodeAt(u)];const l=r|c;r|=(r&o)+o^o,c|=~(r|o),o&=r,c&s&&a++,o&s&&a--,c=c<<1|1,o=o<<1|~(l|c),c&=l}for(u=n;u--;)R[t.charCodeAt(u)]=0;return a},jn=(t,e)=>{const n=e.length,i=t.length,s=[],o=[],c=Math.ceil(n/32),a=Math.ceil(i/32);for(let h=0;h<c;h++)o[h]=-1,s[h]=0;let u=0;for(;u<a-1;u++){let h=0,g=-1;const $=u*32,w=Math.min(32,i)+$;for(let y=$;y<w;y++)R[t.charCodeAt(y)]|=1<<y;for(let y=0;y<n;y++){const x=R[e.charCodeAt(y)],N=o[y/32|0]>>>y&1,E=s[y/32|0]>>>y&1,I=x|h,O=((x|E)&g)+g^g|x|E;let m=h|~(O|g),v=g&O;m>>>31^N&&(o[y/32|0]^=1<<y),v>>>31^E&&(s[y/32|0]^=1<<y),m=m<<1|N,v=v<<1|E,g=v|~(I|m),h=m&I}for(let y=$;y<w;y++)R[t.charCodeAt(y)]=0}let r=0,l=-1;const d=u*32,p=Math.min(32,i-d)+d;for(let h=d;h<p;h++)R[t.charCodeAt(h)]|=1<<h;let f=i;for(let h=0;h<n;h++){const g=R[e.charCodeAt(h)],$=o[h/32|0]>>>h&1,w=s[h/32|0]>>>h&1,y=g|r,x=((g|w)&l)+l^l|g|w;let N=r|~(x|l),E=l&x;f+=N>>>i-1&1,f-=E>>>i-1&1,N>>>31^$&&(o[h/32|0]^=1<<h),E>>>31^w&&(s[h/32|0]^=1<<h),N=N<<1|$,E=E<<1|w,l=E|~(y|N),r=N&y}for(let h=d;h<p;h++)R[t.charCodeAt(h)]=0;return f},Rn=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?Tn(t,e):jn(t,e)},Bn=Ce(import.meta.url),se=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Wn=t=>{if(typeof se<"u"&&se.versions&&se.versions.node){const[e,n]=se.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return se.getBuiltinModule(t)}return Bn(t)},{createRequire:zn}=Wn("node:module"),$t=String.raw,Ue=$t`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Fn=()=>new RegExp($t`\p{RI}{2}|(?)${Ue}(?:\u200D${Ue})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const ss=/^[ \t]*(?:\r\n|\r|\n)/,rs=/(?:\r\n|\r|\n)[ \t]*$/,as=/^(?:[\r\n]|$)/,ls=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,cs=/^[ \t]*[\r\n][ \t\r\n]*$/,us=/\r\n|\n|\r/g,ps=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,hs=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,z=Fn(),qn=/[-_./\s]+/g,de=/(\u001B\[[0-9;]*[a-z])/i,Ve=new RegExp("\\p{Script=Arabic}","u"),Gn=new RegExp("\\p{Script=Bengali}","u"),X=new RegExp("\\p{Script=Cyrillic}","u"),Hn=new RegExp("\\p{Script=Devanagari}","u"),Jn=new RegExp("\\p{Script=Ethiopic}","u"),we=new RegExp("\\p{Script=Greek}","u"),Te=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),Kn=new RegExp("\\p{Script=Gujarati}","u"),Yn=new RegExp("\\p{Script=Gurmukhi}","u"),je=new RegExp("\\p{Script=Hangul}","u"),Re=new RegExp("\\p{Script=Hebrew}","u"),Xn=new RegExp("\\p{Script=Hiragana}","u"),Be=new RegExp("\\p{Script=Han}","u"),Qn=new RegExp("\\p{Script=Kannada}","u"),Zn=new RegExp("\\p{Script=Katakana}","u"),ei=new RegExp("\\p{Script=Khmer}","u"),ti=new RegExp("\\p{Script=Lao}","u"),P=new RegExp("\\p{Script=Latin}","u"),ni=new RegExp("\\p{Script=Malayalam}","u"),ii=new RegExp("\\p{Script=Myanmar}","u"),oi=new RegExp("\\p{Script=Oriya}","u"),si=new RegExp("\\p{Script=Sinhala}","u"),ri=new RegExp("\\p{Script=Tamil}","u"),ai=new RegExp("\\p{Script=Telugu}","u"),li=new RegExp("\\p{Script=Thai}","u"),ci=new RegExp("\\p{Script=Tibetan}","u"),We=/[\u02BB\u02BC\u0027]/u,ui=t=>t.replace(z,"");let pi=class{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const i=this.cache.keys().next().value;i!==void 0&&this.cache.delete(i)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};const hi=zn(import.meta.url),re=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,di=t=>{if(typeof re<"u"&&re.versions&&re.versions.node){const[e,n]=re.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return re.getBuiltinModule(t)}return hi(t)},{stripVTControlCharacters:fi}=di("node:util"),ye=new pi(1e3),mi=/[.*+?^${}()|[\]\\]/g,gi=t=>{const e=t.join("");if(ye.has(e)){const s=ye.get(e);return s.lastIndex=0,s}const n=t.map(s=>s.replaceAll(mi,String.raw`\$&`)).join("|"),i=new RegExp(n,"g");return ye.set(e,i),i},wi=t=>{const e=[];let n=0,i;for(z.lastIndex=0;(i=z.exec(t))!==null;)i.index>n&&e.push(t.slice(n,i.index)),e.push(i[0]),n=z.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},yi=/[ČŠŽĐ]/i,xt=new Uint8Array(128),bt=new Uint8Array(128),Nt=new Uint8Array(128);for(let t=0;t<128;t++)xt[t]=t>=65&&t<=90?1:0,bt[t]=t>=97&&t<=122?1:0,Nt[t]=t>=48&&t<=57?1:0;const ve=t=>xt[t],ze=t=>bt[t],$e=t=>Nt[t],B=(t,e,n,i,s)=>{if(t.length===0)return[];let o=!1;const c=Object.values(e);for(const f of c)if(f(t[0])){o=!0;break}if(!o&&!n)return[t];const a=[...t],u=[];let r=a[0],l="other";const d=Object.entries(e);for(const f of d){const[h,g]=f;if(g(a[0])){l=h;break}}let p=n&&i?a[0]===a[0].toLocaleUpperCase(i):!1;for(let f=1;f<a.length;f++){const h=a[f];let g="other";for(const y of d){const[x,N]=y;if(N(h)){g=x;break}}const $=n&&i?h===h.toLocaleUpperCase(i):!1;let w=!1;s?w=s(l,g,p,$,h,f,a):(l!==g&&l!=="other"&&g!=="other"&&(w=!0),n&&g!=="other"&&!p&&$&&(w=!0)),w?(u.push(r),r=h):r+=h,l=g,n&&(p=$)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},vi=(t,e,n,i)=>{if(n.size===0)return e;for(const s of n)if(t.startsWith(s,e))return i.push(s),e+s.length;return e},At=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const i=[],s=t.length;for(let o=1;o<s;o++){const c=vi(t,n,e,i);if(c!==n){n=c,o=n-1;continue}const a=t.codePointAt(o-1),u=t.codePointAt(o),r=a&&a<128&&ve(a),l=u&&u<128&&ve(u),d=a&&a<128&&ze(a),p=a&&a<128&&$e(a),f=u&&u<128&&$e(u);if(d&&l){i.push(t.slice(n,o)),n=o;continue}if(p&&!f||!p&&f){i.push(t.slice(n,o)),n=o;continue}if(f&&!p){let h=!1,g=!1;if(o+1<s){const $=t.codePointAt(o+1);h=$&&$<128&&ve($),g=$&&$<128&&$e($)}if(!g&&h){i.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<s){const h=t.codePointAt(o+1),g=h&&h<128&&ze(h);if(r&&l&&g){const $=t.slice(n,o+1);e.has($)||(i.push(t.slice(n,o)),n=o)}}}return n<s&&i.push(t.slice(n)),i.filter(o=>o!=="")},kt=(t,e,n)=>{if(t.length===0)return[];const i=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!i&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],l=r.length,d=[];let p=r[0],f=r[0]===r[0].toLocaleUpperCase(e),h=f,g=f?0:-1;for(let $=1;$<l;$++){const w=r[$],y=w===w.toLocaleUpperCase(e);if(y===f)p+=w;else if(y)p&&p.length>0&&(d.push(p),p=w),h=!0,g=$;else{if(h&&$-g>1){const x=r[$-1],N=p.slice(0,-1);N&&N.length>0&&d.push(N),p=x+w}else p+=w;h=!1,g=-1}f=y}return p&&p.length>0&&d.push(p),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!X.test(t)&&!P.test(t))return[t];const r=[...t],l=r.length,d=[];let p=r[0];const f=r[0];let h;X.test(f)?h=1:P.test(f)?h=2:h=0;let g=f===f.toLocaleUpperCase(e);for(let w=1;w<l;w++){const y=r[w];let x;X.test(y)?x=1:P.test(y)?x=2:x=0;const N=y===y.toLocaleUpperCase(e);h!==x&&(h===1||h===2)&&(x===1||x===2)||x===h&&!g&&N?(d.push(p),p=y):p+=y,h=x,g=N}p&&p.length>0&&d.push(p);const $=[];for(let w=0;w<d.length;w++)w<d.length-1&&d[w].length===1&&P.test(d[w])&&X.test(d[w+1][0])?($.push(d[w]+d[w+1]),w+=1):$.push(d[w]);return $}if(e.startsWith("el")){if(!we.test(t)&&!P.test(t))return[t];const r=[];Te.lastIndex=0;let l;for(;(l=Te.exec(t))!==null;)r.push(l[0]);r.length===0&&r.push(t);const d=[];if(r.length===1){const p=r[0];if(!p||!we.test(p[0])||p.length===1)return[p??t]}for(const p of r){if(!p)continue;if(!we.test(p[0])||p.length===1){d.push(p);continue}const f=p.length;let h=p[0],g=p[0]===p[0].toLocaleUpperCase(e);for(let $=1;$<f;$++){const w=p[$],y=w===w.toLocaleUpperCase(e);!g&&y?(d.push(h),h=w):h+=w,g=y}h&&d.push(h)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),l=r?{hiragana:p=>Xn.test(p),kanji:p=>Be.test(p),katakana:p=>Zn.test(p),latin:p=>P.test(p)}:{hangul:p=>je.test(p),latin:p=>P.test(p)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const p=B(t,l,!1,e,(h,g)=>h==="hiragana"&&g==="katakana"||h==="katakana"&&g==="hiragana"||h==="hiragana"&&g==="latin"||h==="katakana"&&g==="latin"||h==="kanji"&&g==="latin"||h==="latin"&&(g==="hiragana"||g==="katakana"||g==="kanji")),f=[];for(const h of p){const g=h;g.length===1&&d.has(g)&&f.length>0?f[f.length-1]=f.at(-1)+g:f.push(g)}return f.length>0?f:[t]}return B(t,l,!1,e,(p,f)=>p==="hangul"&&f==="latin"||p==="latin"&&f==="hangul")}if(e.startsWith("sl")){const r=[...t],l=r.length,d=[];let p=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let h=1;h<l;h++){const g=r[h],$=g===g.toLocaleUpperCase(e),w=yi.test(g),y=h<l-1&&r[h+1]===r[h+1].toLocaleUpperCase(e);!f&&$||w&&y?(d.push(p),p=g,w&&y&&(d.push(p),p="")):p+=g,f=$}return p&&p.length>0&&d.push(p),d}if(e.startsWith("zh"))return B(t,{han:r=>Be.test(r),latin:r=>P.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=l=>Re.test(l)||Ve.test(l);return B(t,{latin:l=>P.test(l),rtl:l=>r(l)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=l=>Hn.test(l)||Gn.test(l)||Kn.test(l)||Yn.test(l)||Qn.test(l)||ri.test(l)||ai.test(l)||ni.test(l)||si.test(l)||li.test(l)||ti.test(l)||ci.test(l)||ii.test(l)||Jn.test(l)||ei.test(l)||oi.test(l);return B(t,{indic:l=>r(l),latin:l=>P.test(l)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return B(t,{cyrillic:r=>X.test(r),latin:r=>P.test(r)},!0,e);if(["ar","fa","he"].includes(e))return B(t,{latin:r=>P.test(r),rtl:r=>Re.test(r)||Ve.test(r)},!1,e);if(e.startsWith("ko"))return B(t,{hangul:r=>je.test(r),latin:r=>P.test(r)},!1,e);if(e.startsWith("uz")){if(!X.test(t)&&!P.test(t))return[t];const r=[...t],l=r.length,d=[];let p=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let h=1;h<l;h++){const g=r[h],$=g===g.toLocaleUpperCase(e);if(We.test(g)||We.test(r[h-1])){p+=g;continue}!f&&$?(d.push(p),p=g):p+=g,f=$}return p&&p.length>0&&d.push(p),d}const s=[...t],o=s.length,c=[];let a=s[0],u=s[0]===s[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){c.push(r),a=s[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<o;r++){const l=s[r],d=l===l.toLocaleUpperCase(e);let p=0;for(const f of n)if(t.startsWith(f,r)){c.push(a,f),p=f.length,a="";const h=f.at(-1);h&&(u=h===h.toLocaleUpperCase(e));break}if(p>0){r+=p-1;continue}!u&&d?(c.push(a),a=l):a+=l,u=d}return a&&c.push(a),c},$i=(t,e,n)=>{const i=[],s=de.test(t)?t.split(de).filter(Boolean):[t];for(const o of s){const c=o;if(de.test(c))i.push(c);else{z.lastIndex=0;const a=z.test(c)?wi(c).filter(Boolean):[c];for(const u of a)if(z.lastIndex=0,z.test(u))i.push(u);else if(e){const r=e.toLowerCase().split("-")[0];i.push(...kt(u,r,n))}else i.push(...At(u,n))}}return i},xi=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:i=!1,knownAcronyms:s=[],locale:o,normalize:c=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,l=new Set([...s].toSorted((w,y)=>y.length-w.length));let d=t;u&&(d=fi(d)),r&&(d=ui(d));let p;Array.isArray(a)?p=gi(a):a instanceof RegExp?p=a:p=qn;const f=[];let h=d;const g=p.flags.includes("g")?p:new RegExp(p.source,`${p.flags}g`);for(;h.length>0;){const w=g.exec(h);if(!w){h===".."?f.push(".."):h==="."?f.push("."):h.length>0&&f.push(h);break}const y=w.index,x=w[0],N=x.length,E=h.slice(0,y),I=h.slice(y+N);if(x.startsWith("../"))f.push(".."),h=h.slice(y+3);else if(x.startsWith("./"))f.push("."),h=h.slice(y+2);else if(y===0&&x==="..")f.push(".."),h=h.slice(2);else if(y===0&&x===".")f.push("."),h=h.slice(1);else{E.length>0&&f.push(E);let O=0;for(;(O=x.indexOf("../",O))!==-1;)f.push(".."),O+=3;for(O=0;(O=x.indexOf("./",O))!==-1;)(O===0||x[O-1]!==".")&&f.push("."),O+=2;let m=I;for(;m.startsWith("../");)f.push(".."),m=m.slice(3);for(;m.startsWith("./");)f.push("."),m=m.slice(2);if(m===".."){f.push("..");break}else if(m==="."){f.push(".");break}else h=m}g.lastIndex=0}if(f.length===0){const w=d.split(p).filter(Boolean);f.push(...w)}let $=[];for(const w of f)n||i?$.push(...$i(w,o,l)):o?$.push(...kt(w,o,l)):$.push(...At(w,l));return c&&($=$.map(w=>l.has(w)?w:o&&w===w.toLocaleUpperCase(o)?w[0]+w.slice(1).toLocaleLowerCase(o):w.toUpperCase()===w&&!l.has(w)?w.slice(0,1)+w.slice(1).toLowerCase():w)),$},bi=Ce(import.meta.url),ae=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ni=t=>{if(typeof ae<"u"&&ae.versions&&ae.versions.node){const[e,n]=ae.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ae.getBuiltinModule(t)}return bi(t)},{writeFile:Ai,stat:ki,rm:Ei,readFile:Fe,readdir:Ci,mkdir:Oi,access:_i}=Ni("node:fs/promises"),ce=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];let F=class extends k{commandName;constructor(t,e=[]){const n=`Command "${t}" not found${e.length>0?`. Did you mean: ${e.join(", ")}?`:""}`;super(n,"COMMAND_NOT_FOUND",{commandName:t,suggestions:e}),this.name="CommandNotFoundError",this.commandName=t,e.length>0&&(this.hint=`Try one of these commands: ${e.join(", ")}`)}},Et=class extends k{option1;option2;constructor(t,e){super(`Options "${t}" and "${e}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:t,option2:e}),this.name="ConflictingOptionsError",this.option1=t,this.option2=e,this.hint=`Remove either --${t} or --${e}`}},Ii=class extends k{unknownOptions;constructor(t,e){const n=t.join(", "),i=`Found unknown ${t.length===1?"option":"options"}: ${n}`;super(i,"UNKNOWN_OPTION",{suggestions:e,unknownOptions:t}),this.name="UnknownOptionError",this.unknownOptions=t,e&&e.length>0&&(this.hint=`Did you mean: ${e.join(", ")}?`)}},Li=class extends k{pluginName;constructor(t,e,n){super(`Plugin "${t}" error: ${e}`,"PLUGIN_ERROR",{originalError:n,pluginName:t}),this.name="PluginError",this.pluginName=t,n&&(this.cause=n)}},Si=class{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(t){this.logger=t}hasPlugins(){return this.plugins.size>0}register(t){if(this.initialized)throw new Error(`Cannot register plugin "${t.name}" after initialization`);if(this.plugins.has(t.name))throw new Error(`Plugin "${t.name}" is already registered`);fe().CEREBRO_OUTPUT_LEVEL===String(j)&&this.logger.debug(`registering plugin: ${t.name}`),this.plugins.set(t.name,t),this.cachedDependencyOrder=void 0}async init(t){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const e=this.getDependencyOrder();this.logger.debug(`initializing ${String(e.length)} plugin(s)...`);for(const n of e)if(typeof n.init=="function"){this.logger.debug(`initializing plugin: ${n.name}`);try{await n.init(t)}catch(i){const s=new Li(n.name,`Failed to initialize: ${i instanceof Error?i.message:String(i)}`,i instanceof Error?i:void 0);throw this.logger.error(s.message),s}}this.initialized=!0}async executeLifecycle(t,e,n){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const i=this.getDependencyOrder();for(const s of i){const o=s[t];if(typeof o=="function"){this.logger.debug(`executing ${t} hook for plugin: ${s.name}`);try{await(t==="afterCommand"?o(e,n):o(e))}catch(c){throw this.logger.error(`Error in ${t} hook for plugin "${s.name}":`,c),c}}}}async executeErrorHandlers(t,e){if(!this.initialized||this.plugins.size===0)return;const n=this.getDependencyOrder();for(const i of n)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(t,e)}catch(s){this.logger.error(`Error in error handler for plugin "${i.name}":`,s)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const t=[],e=new Set,n=new Set,i=s=>{if(e.has(s))return;if(n.has(s))throw new Error(`Circular dependency detected involving plugin "${s}"`);const o=this.plugins.get(s);if(!o)throw new Error(`Plugin "${s}" not found`);if(n.add(s),o.dependencies)for(const c of o.dependencies)i(c);n.delete(s),e.add(s),t.push(o)};for(const s of this.plugins.keys())i(s);return this.cachedDependencyOrder=t,t}validateDependencies(){for(const t of this.plugins.values())if(t.dependencies){for(const e of t.dependencies)if(!this.plugins.has(e))throw new Error(`Plugin "${t.name}" depends on "${e}" which is not registered`)}}};const le=t=>t.type?.name==="Boolean",Mi=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},qe=t=>(le(t)||(t.typeLabel=t.typeLabel??Mi(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),Pi=new RegExp(/^-([^\d-])$/),Di=new RegExp(/^--(\S+)/),Ui=new RegExp(/^-([^\d-]{2,})$/),Vi=t=>Pi.test(t)||Di.test(t)||Ui.test(t),Ti=(t,e)=>{const n=e[0]&&Vi(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const i=new Error(`Command not recognised: ${String(n)}`);throw i.command=n,i.name="INVALID_COMMAND",i}return{argv:e,command:n}};class Ie extends te{optionName;value;constructor(e,n,i){super({hint:`Pass a valid ${i} value for '${e}'.`,message:`Invalid ${i} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,Ie.prototype)}}let ji=class Ct extends te{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,Ct.prototype)}},Ge=class Ot extends te{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,Ot.prototype)}},Ri=class _t extends te{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,_t.prototype)}};class S extends te{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,S.prototype)}}const He=(t,e,n)=>{const i=Number(t);if(e&&Number.isNaN(i)&&String(t).trim().toLowerCase()!=="nan")throw new Ie(n??"",String(t),"Number");return i},Je=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",Ke=t=>t===Number||typeof t=="function"&&t.name==="Number",Ye=t=>t===String||typeof t=="function"&&t.name==="String",Bi=(t,e,n={})=>{const{optionName:i,strictTypes:s}=n;return Array.isArray(t)?Je(e)?t.map(Boolean):Ke(e)?t.map(o=>He(o,s,i)):Ye(e)?t.map(String):t.map(o=>e(String(o))):t===null?null:Je(e)?!!t:Ke(e)?He(t,s,i):Ye(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},_=(t,e,n,...i)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...i)},Wi=/-([a-z])/g,zi=/^\d+$/,ue=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",Fi=t=>t.codePointAt(0)===95,Xe=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Qe=t=>t==="__proto__"||t==="constructor"||t==="prototype",Ze=(t,e,n,i=!1)=>{t[e]===void 0?t[e]=i?[n]:n:i&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},et=(t,e,n,i,s)=>{let o=e.get(t)??n.get(t);if(!o&&i){const c=t.toLowerCase();o=i.get(c)??s?.get(c)}return o},qi=(t,e,n,i)=>{const s=n.debug??!1;_(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),_(s,"Starting argument resolution","resolver"),_(s,"Tokens:","resolver",t),_(s,"Definitions:","resolver",e),_(s,"Processing tokens...","resolver");const o=new Map,c=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,l=n.camelCase?new Map:void 0;for(const m of e)if(o.set(m.name,m),m.alias&&c.set(m.alias,m),n.caseInsensitive&&a&&(a.set(m.name.toLowerCase(),m),m.alias&&u&&u.set(m.alias.toLowerCase(),m)),n.camelCase&&r&&l){const v=m.name.replaceAll(Wi,(b,L)=>L.toUpperCase());r.set(m.name,v),l.set(v,m.name)}const d=Object.create(null),p=Object.create(null),f=[],h=[],g=new Set;let $=!1;const w=e.find(m=>m.defaultOption),y=e.some(m=>m.group),x=e.find(m=>m.type===Number);for(let m=0;m<t.length;m++){const v=t[m];if(v.kind==="option-terminator"){d._unknown=i.slice(v.index),$=!0;break}if(v.kind==="option"&&v.name){let b=et(v.name,o,c,a,u);!b&&v.value===void 0&&x&&zi.test(v.name)&&(b=x,v.value=v.name,v.name=x.name);let L=!1;if(!b&&n.negation&&v.value===void 0&&v.name.startsWith("no-")){const C=v.name.slice(3),D=et(C,o,c,a,u);D?.type&&ue(D.type)&&(b=D,L=!0)}const A=b?b.name:v.name,M=b?.multiple,U=b?.lazyMultiple;if(Object.hasOwn(p,A)&&p[A]!==void 0&&!M&&!U&&!n.partial)throw new ji(A);if(!b&&n.partial){const C=v.rawName??`--${v.name}${v.value!==void 0&&v.inlineValue?`=${v.value}`:""}`;f.push({index:v.index,value:C});continue}if(!b&&n.stopAtFirstUnknown){d._unknown=i.slice(v.index);break}if(!b&&!n.partial)throw new Ge(v.name);if(v.value===void 0){const C=t[m+1],D=C?.kind==="option"&&!("name"in C)&&C.value!==void 0,V=C&&b&&!(b.type&&ue(b.type))&&(C.kind==="positional"||D),Pt=b&&b.defaultOption&&!b.multiple&&!b.lazyMultiple;if(V&&(!b?.defaultOption||Pt))if(M){let T=m+1;const me=[];for(;T<t.length&&(t[T].kind==="positional"||t[T].kind==="option"&&!("name"in t[T])&&t[T].value!==void 0);)me.push(t[T].value),g.add(t[T].index),T++;p[A]=p[A]===void 0?me:Xe(p[A],me),m=T-1}else U?(Ze(p,A,C.value,!0),g.add(C.index),m++):(p[A]=C.value,g.add(C.index),m++);else b?.type&&ue(b.type)?Ze(p,A,!L,M):p[A]=M?[]:null}else{let{value:C}=v;if(b?.type&&ue(b.type))switch(C){case"":{if(n.partial){p._unknown??=[];const V=`${v.rawName??`--${v.name}`}${v.value?`=${v.value}`:""}`;p._unknown.push(V),h.push({index:v.index,value:V}),C=!0}else throw new Ge(v.name);break}case"false":{C=!1;break}case"true":{C=!0;break}default:C=!0}const D=[C];if(M){let V=m+1;for(;V<t.length&&t[V].kind==="positional";)D.push(t[V].value),g.add(t[V].index),V++;m=V-1}p[A]===void 0?p[A]=M||U?D:C:M||U?p[A]=Xe(p[A],D):p[A]=C}}else if(v.kind==="positional"&&n.stopAtFirstUnknown&&!g.has(v.index)&&!w){_(s,`Found unconsumed positional token at index ${String(v.index)}, stopping processing`,"resolver"),d._unknown=i.slice(v.index);break}}for(const[m,v]of Object.entries(p)){const b=o.get(m);b&&(b.multiple||b.lazyMultiple)&&!Array.isArray(v)&&(p[m]=[v])}const N=m=>m.kind==="option"&&!o.has(m.name??"")&&!c.has(m.name??"")&&(!n.caseInsensitive||!a?.has(m.name?.toLowerCase()??"")&&!u?.has(m.name?.toLowerCase()??""));let E=-1,I=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!$&&(E=t.findIndex(m=>N(m)),E!==-1&&(I=t[E].index)),w){const m=[],v=[];for(const b of t)b.kind==="positional"&&!g.has(b.index)&&b.index<I&&(m.push(b.value),v.push(b));if(m.length>0){const b=p[w.name],L=w.multiple??w.lazyMultiple;b===void 0?L?(v.forEach(A=>g.add(A.index)),p[w.name]=m):(g.add(v[0].index),p[w.name]=m[0]):L&&(v.forEach(A=>g.add(A.index)),p[w.name]=Array.isArray(b)?[...m,...b]:[...m,b])}}if(!n.partial){for(const m of t)if(m.kind==="positional"&&!g.has(m.index))throw new Ri(i[m.index])}if(n.partial&&!n.stopAtFirstUnknown){const m=[...f];if(p._unknown)for(const v of h)m.push({index:v.index,value:v.value});for(const v of t)v.kind==="positional"&&!g.has(v.index)&&m.push({index:v.index,value:i[v.index]});m.length>0&&(m.sort((v,b)=>v.index-b.index),d._unknown=m.map(v=>v.value))}if(n.stopAtFirstUnknown&&!$){const m=t.findIndex(b=>b.kind==="positional"&&!g.has(b.index));let v=-1;if(E!==-1&&m!==-1?v=Math.min(E,m):E!==-1?v=E:m!==-1&&(v=m),v>=0){const b=t[v].index;d._unknown=i.slice(b)}}else f.length>0&&!n.partial&&(d._unknown=f.map(m=>m.value));for(const[m,v]of Object.entries(p)){const b=n.camelCase?r?.get(m)??m:m,L=o.get(m);L?.type?d[b]=Bi(v,L.type,{optionName:L.name,strictTypes:n.strictTypes}):d[b]=v===void 0?null:v}for(const m of e){const v=n.camelCase?r?.get(m.name)??m.name:m.name;!(v in d)&&m.defaultValue!==void 0&&(m.multiple??m.lazyMultiple?d[v]=Array.isArray(m.defaultValue)?[...m.defaultValue]:[m.defaultValue]:d[v]=m.defaultValue)}if(y){const m={},v={},b={};for(const A of e)if(A.group){const M=Array.isArray(A.group)?A.group:[A.group];for(const U of M)Qe(U)||(m[U]??={})}for(const A of Object.keys(d))if(!Fi(A)){v[A]=d[A];let M=A;n.camelCase&&(M=l?.get(A)??A);const U=o.get(M);if(U?.group){const C=Array.isArray(U.group)?U.group:[U.group];for(const D of C)Qe(D)||m[D]&&(m[D][A]=d[A])}else b[A]=d[A]}const L={_all:v};for(const[A,M]of Object.entries(m))L[A]=M;Object.keys(b).length>0&&(L._none=b),d._unknown&&(L._unknown=d._unknown),Object.keys(d).forEach(A=>delete d[A]),Object.assign(d,L)}const O=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));return _(s,"Final parsed result:","resolver",O),O},ee="-".codePointAt(0),H="=",Gi=H.codePointAt(0),Hi="--",Ji="-",Ki="--",It=t=>t.length>2&&t.startsWith(Ki),Yi=t=>It(t)&&!t.includes(H,3),Xi=t=>It(t)&&t.includes(H,3),Qi=t=>{if(t.length!==2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},Zi=t=>!(t.length<=2||t.codePointAt(0)!==ee||t.codePointAt(1)===ee),eo=t=>{const e=[];let n=0,i=[],s=0,o=-1,c=0;for(;s<i.length||n<t.length;){let a;if(s<i.length?(a=i[s],s++):(a=t[n],n++),c>0?c--:o++,a===Hi){e.push({index:o,kind:"option-terminator"});const u=[...i.slice(s),...t.slice(n)],r=u.map((l,d)=>({index:o+d+1,kind:"positional",value:l}));e.push(...r),o+=u.length;break}if(Qi(a)){const u=a.charAt(1);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(Zi(a)&&!a.includes(H)){const u=[];let r="",l=!1;for(let d=1;d<a.length;d++){const p=a.charAt(d);l?r+=p:p.codePointAt(0)===Gi?l=!0:u.push(`${Ji}${p}`)}if(l)if(u.length>0){const d=u.pop();u.push(`${d}=${r}`)}else u.push(r);i=s<i.length?[...u,...i.slice(s)]:u,s=0,c=u.length;continue}if(Yi(a)){const u=a.slice(2);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(Xi(a)){const u=a.indexOf(H),r=a.slice(2,u),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}if(a.length>2&&a.codePointAt(0)===ee&&a.codePointAt(1)!==ee&&a.includes(H)){const u=a.indexOf(H),r=a.charAt(1),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}e.push({index:o,kind:"positional",value:a})}return e},to=/\d/,no=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",io=t=>typeof t=="function",oo=(t,e,n)=>{const i=n?.debug??!1;_(i,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,o=new Set,c=new Set,a=new Set;let u=0;for(const r of t){if(_(i,"Checking definition:","validation",r),!r.name)throw _(i,"Validation failed: name is required","validation"),new S("Invalid option definition: name is required");if(typeof r.name!="string")throw new S("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new S("Invalid option definition: name cannot be empty");const l=e?r.name.toLowerCase():"";if(s.has(r.name)||e&&c.has(l))throw new S(`Invalid option definition: duplicate name '${r.name}'`);if(o.has(r.name)||e&&a.has(l))throw new S(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(s.add(r.name),e&&c.add(l),r.alias!==void 0){if(typeof r.alias!="string")throw new S("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new S("Invalid option definition: alias must be a single character");if(to.test(r.alias))throw new S("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new S('Invalid option definition: alias cannot be "-"');const d=e?r.alias.toLowerCase():"";if(o.has(r.alias)||e&&a.has(d))throw new S(`Invalid option definition: duplicate alias '${r.alias}'`);if(s.has(r.alias)||e&&c.has(d))throw new S(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);o.add(r.alias),e&&a.add(d)}if(r.defaultOption&&(u++,r.type!==void 0&&no(r.type)))throw new S("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&io(r.type)))throw new S("Invalid option definition: invalid type")}if(u>1)throw _(i,"Validation failed: multiple defaultOptions not allowed","validation"),new S("Invalid option definition: multiple defaultOptions not allowed");_(i,"Validation completed successfully","validation")};function so(t,e={}){const n=e.debug??!1;_(n,"Starting command-line-args parsing","index"),_(n,"Options:","index",e);const i={...e};i.stopAtFirstUnknown&&(i.partial=!0);const s=Array.isArray(t)?t:[t];_(n,"Normalized definitions:","index",s),oo(s,i.caseInsensitive,n?i:void 0);let{argv:o}=i;if(!o&&(o=process.argv.slice(2),process.execArgv.length>0)){const r=new Set(process.execArgv);o=o.filter(l=>!r.has(l))}_(n,"Using argv:","index",o);let c=o;i.caseInsensitive&&(c=o.map(r=>{if(r.startsWith("--")){const l=r.indexOf("="),d=(l===-1?r.slice(2):r.slice(2,l)).toLowerCase();return l===-1?`--${d}`:`--${d}${r.slice(l)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const l=r.slice(1).split("=",2),d=l[0],p=l[1];if(!d)return r;const f=d.toLowerCase();return p===void 0?`-${f}`:`-${f}=${p}`}return r}));const a=eo(c.map(String));_(n,"Tokenized arguments:","index",a);const u=qi(a,s,i,o);return _(n,"Command-line-args parsing completed","index"),u}class ro{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let xe=class extends k{commandName;constructor(t,e,n){super(`Failed to load command "${t}": ${e}`,"COMMAND_LOADER_ERROR",{commandName:t,reason:e}),this.name="CommandLoaderError",this.commandName=t,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",n!==void 0&&(this.cause=n)}};const ao=/^-{1,2}(\w+)(=(.+))?$/,Lt=(t,e,n,i)=>{const s=ao.exec(t);if(s===null)return{};const o=s[1];if(!o)return{};const c=n&&i?n.get(o)??i.get(o):e.find(a=>a.name===o||a.alias===o);return c!==void 0?{argName:c.name,argValue:s[3],option:c}:{}},tt=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},lo=new Set(["0","1","false","true"]),co=(t,e,n,i)=>{if(e.length===0||t.length===0)return{};const s=(o,c)=>{const{argName:a,argValue:u,option:r}=Lt(c,e,n,i),{lastOption:l}=o;return r&&le(r)&&u&&a?o.partial[a]=tt(u,r):o.lastName&&l&&le(l)&&lo.has(c)&&(o.partial[o.lastName]=tt(c,l)),{lastName:a,lastOption:r,partial:o.partial}};return t.reduce(s,{partial:{}}).partial},uo=new Set(["0","1","false","true"]),po=(t,e,n,i)=>{if(e.length===0||t.length===0)return t;const s=(o,c)=>{const{argValue:a,option:u}=Lt(c,e,n,i),{lastOption:r}=o;if(r&&le(r)&&uo.has(c)){const{args:l}=o;return{args:l.slice(0,-1)}}return u&&le(u)&&a?{args:o.args}:{args:[...o.args,c],lastOption:u}};return t.reduce(s,{args:[]}).args},ho=t=>{const e=new Map;for(const n of t){const i=e.get(n.name);i?e.set(n.name,{...i,...n}):e.set(n.name,n)}return[...e.values()]},fo=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},mo=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return fo(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},go=/_./g,wo=/^[A-Z]/,yo=t=>t.toLowerCase().replaceAll(go,e=>e[1]?.toUpperCase()??e).replace(wo,e=>e.toLowerCase()),vo=t=>{if(!t||t.length===0)return{};const e={},n=fe();for(const i of t){const s=n[i.name],o=mo(i,s),c=o===void 0?i.defaultValue:o,a=yo(i.name);e[a]=c}return e},$o=t=>{const e=new Map,n=new Map;for(const i of t)if(e.set(i.name,i),i.alias){const s=Array.isArray(i.alias)?i.alias:[i.alias];for(const o of s)n.set(o,i)}return{optionMapByAlias:n,optionMapByName:e}},St=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new xe(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(i){throw new xe(t.name,i instanceof Error?i.message:String(i),i)}const n=e.default;if(typeof n!="function")throw new xe(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},xo=(t,e,n,i)=>{const s=new ro(t.name,t),{_all:o,_unknown:c,positionals:a}=e,u=Object.keys(n).length>0?{...o,...n}:o;he in u&&delete u[he],s.argument=a?.[he]??[],s.rawUnknown=[...c??[]];const r=Object.keys(i).length>0;return s.options=r?{...u,...i}:u,s.env=vo(t.env),s},bo=(t,e,n)=>{const i=t.options??[],s=i.length>0;let o=ho(s?[...i,...n]:n);if(o.length>0){for(const r of o)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(o=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:he,type:t.argument.type,typeLabel:t.argument.typeLabel},...o]);let c,a;if(s){const{optionMapByAlias:r,optionMapByName:l}=$o(i);c=po(e,i,l,r),a=co(e,i,l,r)}else c=e,a={};const u=so(o,{argv:c,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:a,parsedArgs:u}},Q=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await St(t))(e);let No=class extends k{commandName;missingOptions;constructor(t,e){super(`Command "${t}" is missing required options: ${e.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:t,missingOptions:e}),this.name="CommandValidationError",this.commandName=t,this.missingOptions=e,this.hint=`Provide the following required options: ${e.join(", ")}`}},Ao=class extends k{choices;option;value;constructor(t,e,n){super(`Invalid value "${e}" for option "${t}". Allowed values: ${n.join(", ")}`,"INVALID_CHOICE",{choices:n,option:t,value:e}),this.name="InvalidChoiceError",this.option=t,this.value=e,this.choices=n,this.hint=`Use one of: ${n.map(i=>`--${t} ${i}`).join(", ")}`}};const nt=(t,e,n=!1)=>{const i=[];for(const s of t)if(!(!n&&!s.required)&&e[s.name]===void 0){if(s.type?.name==="Boolean"){e[s.name]=!1;continue}i.push(s)}return i},ko=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Rn(t,e)<=t.length/3,W=(t,e)=>{const n=t.toLowerCase();return e.filter(i=>ko(i.toLowerCase(),n))},Eo=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(i=>{const s=i.startsWith("--");let o=`Found unknown ${s?"option":"argument"} "${i}"`;if(s){const c=W(i.replace("--",""),(e.options??[]).map(a=>a.name));if(c.length>0){const[a,...u]=c.map(r=>`--${r}`);o+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(o)}),n.length>0)throw new Error(n.join(`
|
|
26
26
|
`))},Co=(t,e,n)=>{const i=n.__requiredOptions__,s=i?nt(i,e,!0):nt(t,e,!1);if(s.length>0)throw new No(n.name,s.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&Eo(e,n)},Oo=(t,e,n)=>{const i=n.__conflictingOptions__??t.filter(s=>s.conflicts!==void 0);if(i.length>0){const s=i.find(o=>Array.isArray(o.conflicts)?o.conflicts.some(c=>e[c]!==void 0)&&e[o.name]!==void 0:e[o.conflicts]!==void 0&&e[o.name]!==void 0);if(s)throw new Et(s.name,typeof s.conflicts=="string"?s.conflicts:s.conflicts?.[0]??"unknown")}},_o=(t,e)=>{const n=e.options;if(n)for(const i of n){if(!i.choices||i.choices.length===0)continue;const s=t[i.name];if(s==null)continue;const o=Array.isArray(s)?s:[s];for(const c of o){const a=String(c);if(!i.choices.includes(a))throw new Ao(i.name,a,i.choices)}}},Io=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const s of t.options){if(s.name){const o=e.get(s.name)??[];o.push(s),e.set(s.name,o)}if(typeof s.alias=="string"&&s.alias.length>0){const o=n.get(s.alias)??[];o.push(s),n.set(s.alias,o)}else if(Array.isArray(s.alias)){for(const o of s.alias)if(o.length>0){const c=n.get(o)??[];c.push(s),n.set(o,c)}}}const i=[];for(const[s,o]of e)o.length>1&&i.push(`Duplicate option name "${s}" in command "${t.name}": ${JSON.stringify(o)}`);for(const[s,o]of n)o.length>1&&i.push(`Duplicate option alias "-${s}" used by options ${o.map(c=>`"${c.name}"`).join(", ")} in command "${t.name}"`);if(i.length>0)throw new Error(i.join(`
|
|
27
27
|
`))},Lo=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let i;for(let s=1;s<=e.length;s+=1){const o=e[s-1];if(o===void 0||o.startsWith("-"))break;n.push(o);const c=n.join(" ");t.has(c)&&(i={commandPath:[...n],depth:s})}return i?{argv:e.slice(i.depth),commandPath:i.commandPath}:{argv:e,commandPath:void 0}},q=t=>t.join(" "),it=(t,e)=>e&&e.length>0?[...e,t]:[t],So=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Mo=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),Po=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const i=[];let s="",o="";for(let c=0;c<n;c++){const a=t[c];if(de.test(a)){s?(i.push(s+o+a),s="",o=""):(i.length>0&&i.push(e),s=a);continue}s?(o&&(o+=e),o+=a):(i.length>0&&i.push(e),i.push(a))}return i.join("")},Mt=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return Po(xi(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(i=>{const s=i,o=s.toLowerCase();return n?(n=!1,So(o)):Mo(o)}),"")},Do=/^no-/,Uo=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Mt(e.name)})},Vo=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const i of t.options)e.add(i.name);const n=[];for(const i of t.options)if(i.name.startsWith("no-")){const s=i.name.replace(Do,"");if(!e.has(s)){if(i.type!==Boolean)throw new Error(`Cannot add negated option "${i.name}" to command "${t.name}" because it is not a boolean.`);const o={...i,defaultValue:i.defaultValue===void 0?!0:!i.defaultValue,name:s};n.push(o),e.add(s)}}n.length>0&&t.options.push(...n)},To=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,i=new Map;for(const o of e.options)if(o.name.startsWith("no-")){const c=Mt(o.name);i.set(c,o)}const s=Object.keys(n).filter(o=>i.has(o));if(s.length!==0)for(const o of s){const c=o.charAt(2);if(!c)continue;const a=c.toLowerCase()+o.slice(3),u=i.get(o);u&&(u.__negated__=!0),n[a]=!n[o],Reflect.deleteProperty(n,o)}},jo=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const s of e.options)s.__camelCaseName__&&s.__negated__===void 0&&s.implies!==void 0&&n.set(s.__camelCaseName__,s);if(n.size===0)return;const{options:i}=t;for(const s of Object.keys(i)){const o=n.get(s);if(o?.implies){const{implies:c}=o;for(const[a,u]of Object.entries(c))i[a]===void 0&&(i[a]=u)}}},Ro=()=>!!process.versions.electron,Bo=()=>Ro()&&!process.defaultApp,Wo=()=>Bo()?0:1,zo=t=>t.slice(Wo()+1),Fo=" ",qo=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,i)=>n===e[i]),Go=t=>{if(typeof t=="string")return t.split(Fo);const e=Ae();return qo(t,e)?zo(t):t},Ho=t=>{const e=o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),G(1)},n=(o,c)=>{if(o instanceof Error)t.error(`Promise rejection: ${o.message||o}`),o.stack&&t.error(o.stack);else{let a;if(typeof o=="string")a=o;else try{a=JSON.stringify(o)}catch{a=String(o)}t.error(`Promise rejection: ${a}`)}G(1)},i=Se("uncaughtException",e),s=Se("unhandledRejection",n);return()=>{i(),s()}},ot=100,Jo=/^[a-z][\w-]*$/i,Ee=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new k(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},st=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new k(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},be=(t,e)=>{if(typeof t!="object"||t===null)throw new k(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},pe=t=>{const e=Ee(t,"Command name");if(e.length>ot)throw new k(`Command name is too long (maximum ${String(ot)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new k(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Jo.test(e))throw new k(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Ko=new Set([`
|
|
28
|
-
`,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Yo=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,i=n.maxArgumentLength??1e6;if(Number.isFinite(i)&&i>0&&t.length>i)throw new Error(`Argument is too long (maximum ${String(i)} characters)`);if(n.checkDangerousChars){for(const s of t)if(Ko.has(s))throw new Error(`Argument contains dangerous character: ${s}`)}return n.trim?t.trim():t},rt=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,i=n.maxArguments??1e5;if(Number.isFinite(i)&&i>0&&t.length>i)throw new Error(`Too many arguments (maximum ${String(i)})`);return t.map(s=>Yo(s,n))},Xo=/^-([^\d-])$/,Qo=/^--(\S+)/,Zo=/^-([^\d-]{2,})$/,Ne=t=>Xo.test(t)||Qo.test(t)||Zo.test(t),es={access:(t,e)=>_i(t,e),mkdir:(t,e)=>Oi(t,e),readdir:t=>Ci(t),readFile:(async(t,e)=>e===void 0?Fe(t):Fe(t,e)),rm:(t,e)=>Ei(t,e),stat:t=>ki(t),writeFile:(t,e,n)=>Ai(t,e,n)},ts=(t,e,n)=>{const i=e.indexOf("--"),s=i===-1?new Set:new Set(e.slice(i+1)),o=n.filter(u=>u.startsWith("--")&&u!=="--"&&!s.has(u));if(o.length===0)return;const c=(t.options??[]).map(u=>u.name),a=o.flatMap(u=>W(u.slice(2),c).map(r=>`--${r}`));throw new Ii(o,a)};class Le{#t;#e;#u;#p;#f;#m;#A;#k;#E;#$;#C;#x;#O;#_=ge;#h;#n;#i;#o;#s;#r;#g=!1;#I;#L=!1;#w;#y;#v;#l=[];#U(){return this.#w===void 0&&(this.#w=[...this.#i.keys()]),this.#w}#S(){return this.#y===void 0&&(this.#y=[...this.#n.keys()]),this.#y}#a(){return this.#v===void 0&&(this.#v=[...this.#U(),...this.#S()]),this.#v}#M(){return this.#l.length===0?ce:[...ce,...this.#l]}#P(){this.#w=void 0,this.#y=void 0,this.#v=void 0}#b(){if(this.#u===void 0){const e=Go(this.#e.argv);this.#u=rt(e,{maxArguments:this.#x}),this.#V()}return this.#u}#N(){return this.#$??fe()}#d(e){this.#_=e,this.#N().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){const e=this.#N().CEREBRO_OUTPUT_LEVEL,n=e===void 0?Number.NaN:Number(e);return Number.isNaN(n)?this.#_:n}#V(){if(!this.#u)return;let e=!1;for(const n of this.#u){if(n==="--quiet"||n==="-q"){this.#d(zt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#d(Ft),e=!0;break}if(n==="--debug"){this.#d(j),e=!0;break}}e||this.#d(Object.hasOwn(this.#N(),"DEBUG")?j:ge)}#T(){this.#L||(this.#I=Ho(this.#t),this.#L=!0)}#j(){return{arch:jt(),argv:this.#b(),cwd:this.#p,env:this.#$??fe(),exit:this.#E??(e=>G(e??0)),platform:Tt(),stdin:this.#C}}#D(e,n,i,s){this.#c()===j&&this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:c,parsedArgs:a}=bo(e,n,this.#M()),u=Object.keys(c).length>0;let r=a;u&&(r={...a,_all:{...a._all,...c}}),Co(o,r,e);const l=xo(e,a,c,i);l.runtime=this,l.argv=this.#b(),l.fs=this.#k??es,l.process=this.#j(),l.console=this.#t;const d=e.options&&e.options.length>0;if(d&&e.options){const p=e.options.filter(f=>f.name.startsWith("no-"));for(const f of p){const h=f.name.slice(3),g=`--${f.name}`,$=`--${h}`,w=n.includes(g),y=n.includes($);if(w&&y)throw new Et(h,f.name)}}return d&&(To(l,e),jo(l,e)),Oo(o,l.options,e),_o(l.options,e),this.#O&&ts(e,n,l.rawUnknown),this.#c()===j&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(l.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(l.argument,null,2))),{arguments_:o,booleanValues:c,commandArgs:r,parsedArgs:a,toolbox:l}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new k("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const i=n.argv??Ae(),s=n.cwd??Rt();if(this.#e={...n,argv:i,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new k("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new k("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new k("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new k("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const r=["debug","error","info","log","warn"],l=[],d=this.#e.logger;for(const p of r)typeof d[p]!="function"&&l.push(p);if(l.length>0)throw new k(`Logger object is missing required methods: ${l.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:l});this.#t=this.#e.logger}else this.#t={...console,debug:(...r)=>{this.#c()===j&&console.debug(...r)}};this.#m=this.#e.packageVersion,this.#A=this.#e.packageName,this.#p=this.#e.cwd,this.#s="help",this.#r={};const o=n.fs;if(o!==void 0&&(typeof o!="object"||o===null))throw new k("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const c=n.exit;if(c!==void 0&&typeof c!="function")throw new k("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new k("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new k("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#k=n.fs,this.#E=n.exit,this.#$=n.env,this.#C=n.stdin??"",this.#x=n.maxArguments,this.#O=n.strictOptions??!1,this.#d(ge),this.#n=new Map,this.#i=new Map,this.#o=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#m?` v${this.#m}`:""}`),this.#r}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){be(e,"Command"),pe(e.name);const n=typeof e.execute=="function",i=typeof e.loader=="function";if(n&&i)throw new k(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!i)throw new k(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?pe(e.alias):st(e.alias,"Command alias").forEach(r=>pe(r))),e.argument&&be(e.argument,"Command argument"),e.options&&be(e.options,"Command options"),e.commandPath&&(st(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{pe(r)}));const s=it(e.name,e.commandPath),o=q(s);if(this.#i.has(o))throw new k(`Command with path "${o}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const c=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),u=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!c&&u)throw new k(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)qe(r);if(Io(e),Vo(e),Uo(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),c&&a!==void 0)this.#n.set(o,e);else{if(!c&&a!==void 0&&!u){const r=it(a.name,a.commandPath);this.#n.set(q(r),a)}this.#n.set(e.name,e)}if(this.#i.set(o,s),this.#o.set(o,e),this.#P(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const l of r){if(this.#c()===j&&this.#t.debug("adding alias",l),this.#n.has(l))throw new k(`Command alias "${l}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:l,commandName:e.name});this.#n.set(l,e)}}return this}addGlobalOption(e){const n=e,i=new Set(ce.map(o=>o.name)),s=new Set(ce.map(o=>o.alias).filter(Boolean));if(i.has(n.name))throw new k(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new k(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(o=>o.name)).has(n.name))throw new k(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",qe(n),this.#l.push(n),this}getGlobalOptions(){return this.#M()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#h?this.#h:(this.#h=new Si(this.#t),this.#h.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#h)}getCliName(){return this.#f}getPackageVersion(){return this.#m}getPackageName(){return this.#A}getCommands(){return this.#n}getCwd(){return this.#p}dispose(){this.#I?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:i=!0,...s}=e;if(!this.#n.has("help")){const{default:y}=await import("../packem_chunks/help-command.js");this.addCommand(new y(this.#n))}const o=this.#S(),c=this.#i;this.#T();const a=this.#b();let u,r=[...a];this.#c()===j&&(this.#t.debug(`process.execPath: ${Bt()}`),this.#t.debug(`process.execArgv: ${Wt().join(" ")}`),this.#t.debug(`process.argv: ${Ae().join(" ")}`));const l=Lo(c,[...a]);if(l.commandPath)u=l.commandPath,r=l.argv;else{if(a.length>1&&a[0]&&a[1]&&!Ne(a[0])&&!Ne(a[1])){const x=[];let N=0;for(;N<a.length;){const I=a[N];if(!I||Ne(I))break;x.push(I),N+=1}const E=q(x);if(x[0]&&!o.includes(x[0])){const I=this.#a(),O=W(E,I);throw new F(E,O)}}let y;try{y=Ti([null,...o],[...a])}catch(x){if(x instanceof Error&&x.name==="INVALID_COMMAND"&&"command"in x){const N=x.command,E=this.#a(),I=W(N,E);throw new F(N,I)}throw x}y.command&&(u=[y.command],r=y.argv)}if(!u)if(this.#s)u=[this.#s];else{const y=this.#a();throw new F("",y)}const d=q(u),p=this.#i.get(d);let f;if(p){if(f=this.#o.get(d),!f||q(p)!==d){const y=this.#a(),x=W(d,y);throw new F(d,x)}}else{const y=u.at(-1);if(f=y?this.#n.get(y):void 0,!f){const x=this.#a(),N=W(d,x);throw new F(d,N)}}if(typeof f.execute!="function"&&typeof f.loader!="function")return this.#t.error(`Command "${f.name}" has no function to execute.`),i?G(1):void 0;const h=r;let g,$;try{({commandArgs:g,toolbox:$}=this.#D(f,h,s,d))}catch(y){if(this.#t.error(y),i)return G(1);throw y}const w=this.getPluginManager();try{!this.#g&&w.hasPlugins()&&(await w.init({cli:this,cwd:this.#p,logger:this.#t}),this.#g=!0),await w.executeLifecycle("execute",$),await w.executeLifecycle("beforeCommand",$);let y;const x=g.global;if(x?.help){const N=this.#n.get("help");if(!N)throw new k("Help command not found","COMMAND_NOT_FOUND");y=await Q(N,$)}else if(x?.version??x?.V){const N=this.#n.get("version");if(!N)throw new k("Version command not found","COMMAND_NOT_FOUND");y=await Q(N,$)}else y=await Q(f,$);return await w.executeLifecycle("afterCommand",$,y),i?G(0):void 0}catch(y){throw await w.executeErrorHandlers(y,$),y}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:i=[],...s}=n;Ee(e,"Command name");const o=e.split(" ").filter(Boolean),c=q(o),a=this.#i.get(c)?this.#o.get(c):this.#n.get(e);if(!a){const p=this.#a(),f=W(c||e,p);throw new F(e,f)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new k(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const u=[...rt(i,{maxArguments:this.#x})];this.#c()===j&&this.#t.debug(`running command '${e}' programmatically with args: ${u.join(", ")}`);const{commandArgs:r,toolbox:l}=this.#D(a,u,s,c||e),d=this.getPluginManager();try{!this.#g&&d.hasPlugins()&&(await d.init({cli:this,cwd:this.#p,logger:this.#t}),this.#g=!0),await d.executeLifecycle("execute",l),await d.executeLifecycle("beforeCommand",l);let p;const f=r.global;if(f?.help){const h=this.#n.get("help");if(!h)throw new k("Help command not found","COMMAND_NOT_FOUND");p=await Q(h,l)}else if(f?.version??f?.V){const h=this.#n.get("version");if(!h)throw new k("Version command not found","COMMAND_NOT_FOUND");p=await Q(h,l)}else p=await Q(a,l);return await d.executeLifecycle("afterCommand",l,p),p}catch(p){throw await d.executeErrorHandlers(p,l),p}}clone(e){const n={...this.#e,...e},i=new Le(this.#f,n);for(const[s,o]of this.#n)i.#n.set(s,o);for(const[s,o]of this.#i)i.#i.set(s,[...o]);for(const[s,o]of this.#o)i.#o.set(s,o);for(const s of this.#l)i.#l.push(s);return i.#s=this.#s,i.#r={...this.#r},i.#P(),i}async getAction(e){Ee(e,"Command name");const n=e.split(" ").filter(Boolean),i=q(n),s=this.#i.get(i)?this.#o.get(i):this.#n.get(e);if(!s){const o=this.#a(),c=W(i||e,o);throw new F(e,c)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return St(s);throw new k(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}}const fs=(t,e)=>new Le(t,e),ms=(t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:i,runtime:s}=n,{detailed:o=!1,exitOnError:c=!0,formatter:a,logErrors:u=!0,renderOptions:r={}}=t;if(u)if(a)i.error(a(e));else if(o){const l=s.getCwd(),d=Vn(e,{cwd:l,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...r});i.error(d)}else i.error(e);c&&G(1)},version:"1.0.0"});var ns="1.0.0-alpha.42";const gs={version:ns},ws=async t=>{try{await t.run({shouldExitProcess:!1})}catch{process.exitCode=process.exitCode||1}finally{process.exit(process.exitCode??0)}},ys={argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"],["vis install && vis dlx --offline typescript tsc --version","Hardened: pre-install + offline (no registry fetch on dlx)"],["vis dlx --info create-vite","Always show the first-run panel (size, score, permissions, changelog)"],["vis dlx --yes create-vite my-app","Skip the first-run panel and confirmation"]],group:"Run & Execute",loader:()=>import("../packem_chunks/handler65.js"),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},{alias:"y",defaultValue:!1,description:"Skip the first-run info panel and confirmation prompt (also via VIS_DLX_YES — note this auto-approves every package)",name:"yes",type:Boolean},{defaultValue:!1,description:"Always show the first-run info panel (size, security score, permissions, changelog), even for an approved package",name:"info",type:Boolean},{defaultValue:!1,description:"Disable the first-run info panel entirely (also via VIS_DLX_NO_INFO)",name:"no-info",type:Boolean}]};export{z as L,fs as V,us as a,ls as b,gs as c,k as d,ys as e,ms as h,cs as i,as as n,ps as o,hs as p,ws as r,rs as s,ss as t};
|
|
28
|
+
`,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Yo=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,i=n.maxArgumentLength??1e6;if(Number.isFinite(i)&&i>0&&t.length>i)throw new Error(`Argument is too long (maximum ${String(i)} characters)`);if(n.checkDangerousChars){for(const s of t)if(Ko.has(s))throw new Error(`Argument contains dangerous character: ${s}`)}return n.trim?t.trim():t},rt=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,i=n.maxArguments??1e5;if(Number.isFinite(i)&&i>0&&t.length>i)throw new Error(`Too many arguments (maximum ${String(i)})`);return t.map(s=>Yo(s,n))},Xo=/^-([^\d-])$/,Qo=/^--(\S+)/,Zo=/^-([^\d-]{2,})$/,Ne=t=>Xo.test(t)||Qo.test(t)||Zo.test(t),es={access:(t,e)=>_i(t,e),mkdir:(t,e)=>Oi(t,e),readdir:t=>Ci(t),readFile:(async(t,e)=>e===void 0?Fe(t):Fe(t,e)),rm:(t,e)=>Ei(t,e),stat:t=>ki(t),writeFile:(t,e,n)=>Ai(t,e,n)},ts=(t,e,n)=>{const i=e.indexOf("--"),s=i===-1?new Set:new Set(e.slice(i+1)),o=n.filter(u=>u.startsWith("--")&&u!=="--"&&!s.has(u));if(o.length===0)return;const c=(t.options??[]).map(u=>u.name),a=o.flatMap(u=>W(u.slice(2),c).map(r=>`--${r}`));throw new Ii(o,a)};class Le{#t;#e;#u;#p;#f;#m;#A;#k;#E;#$;#C;#x;#O;#_=ge;#h;#n;#i;#o;#s;#r;#g=!1;#I;#L=!1;#w;#y;#v;#l=[];#U(){return this.#w===void 0&&(this.#w=[...this.#i.keys()]),this.#w}#S(){return this.#y===void 0&&(this.#y=[...this.#n.keys()]),this.#y}#a(){return this.#v===void 0&&(this.#v=[...this.#U(),...this.#S()]),this.#v}#M(){return this.#l.length===0?ce:[...ce,...this.#l]}#P(){this.#w=void 0,this.#y=void 0,this.#v=void 0}#b(){if(this.#u===void 0){const e=Go(this.#e.argv);this.#u=rt(e,{maxArguments:this.#x}),this.#V()}return this.#u}#N(){return this.#$??fe()}#d(e){this.#_=e,this.#N().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){const e=this.#N().CEREBRO_OUTPUT_LEVEL,n=e===void 0?Number.NaN:Number(e);return Number.isNaN(n)?this.#_:n}#V(){if(!this.#u)return;let e=!1;for(const n of this.#u){if(n==="--quiet"||n==="-q"){this.#d(zt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#d(Ft),e=!0;break}if(n==="--debug"){this.#d(j),e=!0;break}}e||this.#d(Object.hasOwn(this.#N(),"DEBUG")?j:ge)}#T(){this.#L||(this.#I=Ho(this.#t),this.#L=!0)}#j(){return{arch:jt(),argv:this.#b(),cwd:this.#p,env:this.#$??fe(),exit:this.#E??(e=>G(e??0)),platform:Tt(),stdin:this.#C}}#D(e,n,i,s){this.#c()===j&&this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:c,parsedArgs:a}=bo(e,n,this.#M()),u=Object.keys(c).length>0;let r=a;u&&(r={...a,_all:{...a._all,...c}}),Co(o,r,e);const l=xo(e,a,c,i);l.runtime=this,l.argv=this.#b(),l.fs=this.#k??es,l.process=this.#j(),l.console=this.#t;const d=e.options&&e.options.length>0;if(d&&e.options){const p=e.options.filter(f=>f.name.startsWith("no-"));for(const f of p){const h=f.name.slice(3),g=`--${f.name}`,$=`--${h}`,w=n.includes(g),y=n.includes($);if(w&&y)throw new Et(h,f.name)}}return d&&(To(l,e),jo(l,e)),Oo(o,l.options,e),_o(l.options,e),this.#O&&ts(e,n,l.rawUnknown),this.#c()===j&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(l.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(l.argument,null,2))),{arguments_:o,booleanValues:c,commandArgs:r,parsedArgs:a,toolbox:l}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new k("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const i=n.argv??Ae(),s=n.cwd??Rt();if(this.#e={...n,argv:i,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new k("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new k("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new k("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new k("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const r=["debug","error","info","log","warn"],l=[],d=this.#e.logger;for(const p of r)typeof d[p]!="function"&&l.push(p);if(l.length>0)throw new k(`Logger object is missing required methods: ${l.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:l});this.#t=this.#e.logger}else this.#t={...console,debug:(...r)=>{this.#c()===j&&console.debug(...r)}};this.#m=this.#e.packageVersion,this.#A=this.#e.packageName,this.#p=this.#e.cwd,this.#s="help",this.#r={};const o=n.fs;if(o!==void 0&&(typeof o!="object"||o===null))throw new k("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const c=n.exit;if(c!==void 0&&typeof c!="function")throw new k("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new k("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new k("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#k=n.fs,this.#E=n.exit,this.#$=n.env,this.#C=n.stdin??"",this.#x=n.maxArguments,this.#O=n.strictOptions??!1,this.#d(ge),this.#n=new Map,this.#i=new Map,this.#o=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#m?` v${this.#m}`:""}`),this.#r}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){be(e,"Command"),pe(e.name);const n=typeof e.execute=="function",i=typeof e.loader=="function";if(n&&i)throw new k(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!i)throw new k(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?pe(e.alias):st(e.alias,"Command alias").forEach(r=>pe(r))),e.argument&&be(e.argument,"Command argument"),e.options&&be(e.options,"Command options"),e.commandPath&&(st(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{pe(r)}));const s=it(e.name,e.commandPath),o=q(s);if(this.#i.has(o))throw new k(`Command with path "${o}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const c=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),u=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!c&&u)throw new k(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)qe(r);if(Io(e),Vo(e),Uo(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),c&&a!==void 0)this.#n.set(o,e);else{if(!c&&a!==void 0&&!u){const r=it(a.name,a.commandPath);this.#n.set(q(r),a)}this.#n.set(e.name,e)}if(this.#i.set(o,s),this.#o.set(o,e),this.#P(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const l of r){if(this.#c()===j&&this.#t.debug("adding alias",l),this.#n.has(l))throw new k(`Command alias "${l}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:l,commandName:e.name});this.#n.set(l,e)}}return this}addGlobalOption(e){const n=e,i=new Set(ce.map(o=>o.name)),s=new Set(ce.map(o=>o.alias).filter(Boolean));if(i.has(n.name))throw new k(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new k(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(o=>o.name)).has(n.name))throw new k(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",qe(n),this.#l.push(n),this}getGlobalOptions(){return this.#M()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#h?this.#h:(this.#h=new Si(this.#t),this.#h.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#h)}getCliName(){return this.#f}getPackageVersion(){return this.#m}getPackageName(){return this.#A}getCommands(){return this.#n}getCwd(){return this.#p}dispose(){this.#I?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:i=!0,...s}=e;if(!this.#n.has("help")){const{default:y}=await import("../packem_chunks/help-command.js");this.addCommand(new y(this.#n))}const o=this.#S(),c=this.#i;this.#T();const a=this.#b();let u,r=[...a];this.#c()===j&&(this.#t.debug(`process.execPath: ${Bt()}`),this.#t.debug(`process.execArgv: ${Wt().join(" ")}`),this.#t.debug(`process.argv: ${Ae().join(" ")}`));const l=Lo(c,[...a]);if(l.commandPath)u=l.commandPath,r=l.argv;else{if(a.length>1&&a[0]&&a[1]&&!Ne(a[0])&&!Ne(a[1])){const x=[];let N=0;for(;N<a.length;){const I=a[N];if(!I||Ne(I))break;x.push(I),N+=1}const E=q(x);if(x[0]&&!o.includes(x[0])){const I=this.#a(),O=W(E,I);throw new F(E,O)}}let y;try{y=Ti([null,...o],[...a])}catch(x){if(x instanceof Error&&x.name==="INVALID_COMMAND"&&"command"in x){const N=x.command,E=this.#a(),I=W(N,E);throw new F(N,I)}throw x}y.command&&(u=[y.command],r=y.argv)}if(!u)if(this.#s)u=[this.#s];else{const y=this.#a();throw new F("",y)}const d=q(u),p=this.#i.get(d);let f;if(p){if(f=this.#o.get(d),!f||q(p)!==d){const y=this.#a(),x=W(d,y);throw new F(d,x)}}else{const y=u.at(-1);if(f=y?this.#n.get(y):void 0,!f){const x=this.#a(),N=W(d,x);throw new F(d,N)}}if(typeof f.execute!="function"&&typeof f.loader!="function")return this.#t.error(`Command "${f.name}" has no function to execute.`),i?G(1):void 0;const h=r;let g,$;try{({commandArgs:g,toolbox:$}=this.#D(f,h,s,d))}catch(y){if(this.#t.error(y),i)return G(1);throw y}const w=this.getPluginManager();try{!this.#g&&w.hasPlugins()&&(await w.init({cli:this,cwd:this.#p,logger:this.#t}),this.#g=!0),await w.executeLifecycle("execute",$),await w.executeLifecycle("beforeCommand",$);let y;const x=g.global;if(x?.help){const N=this.#n.get("help");if(!N)throw new k("Help command not found","COMMAND_NOT_FOUND");y=await Q(N,$)}else if(x?.version??x?.V){const N=this.#n.get("version");if(!N)throw new k("Version command not found","COMMAND_NOT_FOUND");y=await Q(N,$)}else y=await Q(f,$);return await w.executeLifecycle("afterCommand",$,y),i?G(0):void 0}catch(y){throw await w.executeErrorHandlers(y,$),y}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:i=[],...s}=n;Ee(e,"Command name");const o=e.split(" ").filter(Boolean),c=q(o),a=this.#i.get(c)?this.#o.get(c):this.#n.get(e);if(!a){const p=this.#a(),f=W(c||e,p);throw new F(e,f)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new k(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const u=[...rt(i,{maxArguments:this.#x})];this.#c()===j&&this.#t.debug(`running command '${e}' programmatically with args: ${u.join(", ")}`);const{commandArgs:r,toolbox:l}=this.#D(a,u,s,c||e),d=this.getPluginManager();try{!this.#g&&d.hasPlugins()&&(await d.init({cli:this,cwd:this.#p,logger:this.#t}),this.#g=!0),await d.executeLifecycle("execute",l),await d.executeLifecycle("beforeCommand",l);let p;const f=r.global;if(f?.help){const h=this.#n.get("help");if(!h)throw new k("Help command not found","COMMAND_NOT_FOUND");p=await Q(h,l)}else if(f?.version??f?.V){const h=this.#n.get("version");if(!h)throw new k("Version command not found","COMMAND_NOT_FOUND");p=await Q(h,l)}else p=await Q(a,l);return await d.executeLifecycle("afterCommand",l,p),p}catch(p){throw await d.executeErrorHandlers(p,l),p}}clone(e){const n={...this.#e,...e},i=new Le(this.#f,n);for(const[s,o]of this.#n)i.#n.set(s,o);for(const[s,o]of this.#i)i.#i.set(s,[...o]);for(const[s,o]of this.#o)i.#o.set(s,o);for(const s of this.#l)i.#l.push(s);return i.#s=this.#s,i.#r={...this.#r},i.#P(),i}async getAction(e){Ee(e,"Command name");const n=e.split(" ").filter(Boolean),i=q(n),s=this.#i.get(i)?this.#o.get(i):this.#n.get(e);if(!s){const o=this.#a(),c=W(i||e,o);throw new F(e,c)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return St(s);throw new k(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}}const fs=(t,e)=>new Le(t,e),ms=(t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:i,runtime:s}=n,{detailed:o=!1,exitOnError:c=!0,formatter:a,logErrors:u=!0,renderOptions:r={}}=t;if(u)if(a)i.error(a(e));else if(o){const l=s.getCwd(),d=Vn(e,{cwd:l,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...r});i.error(d)}else i.error(e);c&&G(1)},version:"1.0.0"});var ns="1.0.0-alpha.44";const gs={version:ns},ws=async t=>{try{await t.run({shouldExitProcess:!1})}catch{process.exitCode=process.exitCode||1}finally{process.exit(process.exitCode??0)}},ys={argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"],["vis install && vis dlx --offline typescript tsc --version","Hardened: pre-install + offline (no registry fetch on dlx)"],["vis dlx --info create-vite","Always show the first-run panel (size, score, permissions, changelog)"],["vis dlx --yes create-vite my-app","Skip the first-run panel and confirmation"]],group:"Run & Execute",loader:()=>import("../packem_chunks/handler65.js"),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},{alias:"y",defaultValue:!1,description:"Skip the first-run info panel and confirmation prompt (also via VIS_DLX_YES — note this auto-approves every package)",name:"yes",type:Boolean},{defaultValue:!1,description:"Always show the first-run info panel (size, security score, permissions, changelog), even for an approved package",name:"info",type:Boolean},{defaultValue:!1,description:"Disable the first-run info panel entirely (also via VIS_DLX_NO_INFO)",name:"no-info",type:Boolean}]};export{z as L,fs as V,us as a,ls as b,gs as c,k as d,ys as e,ms as h,cs as i,as as n,ps as o,hs as p,ws as r,rs as s,ss as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as A}from"node:module";import{c as L,L as N,m as c,d as W,b as C}from"./index-
|
|
1
|
+
import{createRequire as A}from"node:module";import{c as L,L as N,m as c,d as W,b as C}from"./index-CE6MsgcV.js";import{e as U}from"./env-Ct3hMEYB.js";import{N as X}from"./readJsonSync-CvkZyKmL-ihoybKvs.js";import{withEnhancedPath as ot}from"@visulima/task-runner";const F=A(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=t=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[o,e]=d.versions.node.split(".").map(Number);if(o>22||o===22&&e>=3||o===20&&e>=16)return d.getBuiltinModule(t)}return F(t)},{Socket:G}=l("node:net"),{randomBytes:V}=l("node:crypto"),{readdir:q,rm:k,unlink:v,open:B,readFile:Y,stat:z,writeFile:J,rename:K}=l("node:fs/promises"),{spawn:Q}=l("node:child_process"),{openSync:Z,closeSync:tt}=l("node:fs");async function $(t,o,e){const s=await L(t,{buffer:!0,encoding:void 0});let i=new TextDecoder().decode(s);const{beforeParse:r,color:n}={};return typeof r=="function"&&(i=r(i)),X(i,o,N(t),{color:n})}const et=3e4,E=100;class st extends Error{constructor(o,e){super(o),this.elapsedMs=e,this.name="ServiceReadinessError"}elapsedMs}const it=async t=>{const o=t.host??"127.0.0.1",{port:e}=t,s=t.timeoutMs??et,i=Date.now();for(;Date.now()-i<s;){if(await rt(o,e))return;await nt(E)}throw new st(`Timed out waiting for ${o}:${String(e)} to accept TCP connections (${String(s)}ms)`,Date.now()-i)},rt=(t,o)=>new Promise(e=>{const s=new G,i=r=>{s.removeAllListeners(),s.destroy(),e(r)};s.once("connect",()=>{i(!0)}),s.once("error",()=>{i(!1)}),s.setTimeout(E,()=>{i(!1)});try{s.connect(o,t)}catch{i(!1)}}),nt=t=>new Promise(o=>{setTimeout(o,t)}),at=async(t,o)=>{const e=t.readiness??(t.port===void 0?void 0:{tcp:{port:t.port}});e&&await it({host:e.tcp.host,port:e.tcp.port,timeoutMs:o?.timeoutMs??e.tcp.timeoutMs})},y=384,b=5e3,ct=50,ht=3e4,h=async t=>{const o=c(U(t),"services");try{await W(o)}catch(e){throw e.code==="ENOTDIR"?new Error(`Service registry path ${o} exists but is not a directory. Remove it or move the conflicting file before running \`vis service\`.`,{cause:e}):e}return o},_=t=>t.replaceAll("/","_").replaceAll(":","__"),g=(t,o)=>c(t,`${_(o)}.json`),dt=(t,o)=>c(t,`${_(o)}.lock`),u=async(t,o)=>{const e=await h(t),s=g(e,o);if(await C(s))try{return await $(s)}catch{return}},ft=async t=>{const o=await h(t);let e;try{e=await q(o)}catch{return[]}const s=[];for(const i of e)if(i.endsWith(".json"))try{const r=await $(c(o,i));s.push(r)}catch{}return s},lt=async(t,o)=>{const e=await h(t),s=g(e,o.id),i=c(e,`.${V(8).toString("hex")}.tmp`);await J(i,`${JSON.stringify(o,void 0,2)}
|
|
2
2
|
`,{mode:y});try{await kt(i,s)}catch(r){throw await k(i,{force:!0}).catch(()=>{}),r}},ut=new Set(["EACCES","EBUSY","EPERM"]),pt=8,wt=20,kt=async(t,o)=>{let e=0;for(;;)try{await K(t,o);return}catch(s){const{code:i}=s;if(!(i!==void 0&&ut.has(i))||e>=pt)throw s;const r=wt*2**e;await new Promise(n=>{setTimeout(n,r)}),e+=1}},f=async(t,o,e)=>{const s=await h(t),i=e??await u(t,o);await k(g(s,o),{force:!0}),i&&await k(i.logFile,{force:!0}).catch(()=>{})},a=t=>{try{return process.kill(t,0),!0}catch{return!1}},Dt=async t=>{const o=await ft(t),e=[],s=[];for(const i of o){if(a(i.pid)){s.push(i);continue}const r=await u(t,i.id);if(r&&r.pid!==i.pid){s.push(r);continue}await f(t,i.id,i).catch(()=>{}),e.push(i.id)}return{pruned:e,surviving:s}},mt=t=>new Promise(o=>{setTimeout(o,t)}),yt=async t=>{try{const o=await B(t,"wx",y);try{await o.writeFile(String(process.pid))}finally{await o.close().catch(()=>{})}return!0}catch(o){if(o.code==="EEXIST")return!1;throw o}},_t=async t=>{let o;try{const e=await Y(t,"utf8"),s=Number.parseInt(e.trim(),10);o=Number.isFinite(s)?s:void 0}catch{return!0}if(o!==void 0&&!a(o))return!0;try{const e=await z(t);return Date.now()-e.mtimeMs>ht}catch{return!0}},M=async(t,o,e)=>{const s=await h(t),i=dt(s,o),r=Date.now();for(;!await yt(i);){if(await _t(i)){await v(i).catch(()=>{});continue}if(Date.now()-r>=b)throw new Error(`Could not acquire service lock for ${o} within ${String(b)}ms — another \`vis service\` invocation appears to be holding it.`);await mt(ct)}try{return await e()}finally{await v(i).catch(()=>{})}};function m(t,o={},e){for(const s in t){const i=t[s],r=e?`${e}:${s}`:s;typeof i=="object"&&i!==null?m(i,o,r):typeof i=="function"&&(o[r]=i)}return o}const R=(()=>{if(console.createTask)return console.createTask;const t={run:o=>o()};return()=>t})();function T(t,o,e,s){for(let i=e;i<t.length;i+=1)try{const r=s?s.run(()=>t[i](...o)):t[i](...o);if(r&&typeof r.then=="function")return Promise.resolve(r).then(()=>T(t,o,i+1,s))}catch(r){return Promise.reject(r)}}function gt(t,o,e){if(t.length>0)return T(t,o,0,R(e))}function vt(t,o,e){if(t.length>0){const s=R(e);return Promise.all(t.map(i=>s.run(()=>i(...o))))}}function w(t,o){for(const e of[...t])e(o)}var bt=class{_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,o,e={}){if(!t||typeof o!="function")return()=>{};const s=t;let i;for(;this._deprecatedHooks[t];)i=this._deprecatedHooks[t],t=i.to;if(i&&!e.allowDeprecated){let r=i.message;r||(r=`${s} hook has been deprecated`+(i.to?`, please use ${i.to}`:"")),this._deprecatedMessages||(this._deprecatedMessages=new Set),this._deprecatedMessages.has(r)||(console.warn(r),this._deprecatedMessages.add(r))}if(!o.name)try{Object.defineProperty(o,"name",{get:()=>"_"+t.replace(/\W+/g,"_")+"_hook_cb",configurable:!0})}catch{}return this._hooks[t]=this._hooks[t]||[],this._hooks[t].push(o),()=>{o&&(this.removeHook(t,o),o=void 0)}}hookOnce(t,o){let e,s=(...i)=>(typeof e=="function"&&e(),e=void 0,s=void 0,o(...i));return e=this.hook(t,s),e}removeHook(t,o){const e=this._hooks[t];if(e){const s=e.indexOf(o);s!==-1&&e.splice(s,1),e.length===0&&(this._hooks[t]=void 0)}}clearHook(t){this._hooks[t]=void 0}deprecateHook(t,o){this._deprecatedHooks[t]=typeof o=="string"?{to:o}:o;const e=this._hooks[t]||[];this._hooks[t]=void 0;for(const s of e)this.hook(t,s)}deprecateHooks(t){for(const o in t)this.deprecateHook(o,t[o])}addHooks(t){const o=m(t),e=Object.keys(o).map(s=>this.hook(s,o[s]));return()=>{for(const s of e)s();e.length=0}}removeHooks(t){const o=m(t);for(const e in o)this.removeHook(e,o[e])}removeAllHooks(){this._hooks={}}callHook(t,...o){return this.callHookWith(gt,t,o)}callHookParallel(t,...o){return this.callHookWith(vt,t,o)}callHookWith(t,o,e){const s=this._before||this._after?{name:o,args:e,context:{}}:void 0;this._before&&w(this._before,s);const i=t(this._hooks[o]?[...this._hooks[o]]:[],e,o);return i instanceof Promise?i.finally(()=>{this._after&&s&&w(this._after,s)}):(this._after&&s&&w(this._after,s),i)}beforeEach(t){return this._before=this._before||[],this._before.push(t),()=>{if(this._before!==void 0){const o=this._before.indexOf(t);o!==-1&&this._before.splice(o,1)}}}afterEach(t){return this._after=this._after||[],this._after.push(t),()=>{if(this._after!==void 0){const o=this._after.indexOf(t);o!==-1&&this._after.splice(o,1)}}}};function St(){return new bt}const xt=()=>St(),Ot=async(t,o)=>{if(!(!o||o.length===0))for(const e of o){if(e.hooks)for(const[s,i]of Object.entries(e.hooks)){const r=Array.isArray(i)?i:[i];for(const n of r)t.hook(s,n)}e.setup&&await e.setup(t)}};class jt{#e;#o;#s=new Map;constructor(o,e){this.#e=o,this.#o=e}startTasks(o){for(const e of o)this.#s.set(e.id,e),this.#t("task:before",e)}endTasks(o){for(const e of o)this.#s.delete(e.task.id),this.#t("task:after",e.task,e),e.status==="failure"?this.#t("task:failure",e.task,e):Ht(e.status)&&this.#t("task:cacheHit",e.task,e)}printCacheMiss(o,e){this.#t("task:cacheMiss",o,e)}onTaskStdout(o,e){this.#t("task:stdout",o,e)}onTaskStderr(o,e){this.#t("task:stderr",o,e)}#t(o,...e){Promise.resolve(this.#e.callHook(o,...e)).catch(s=>{if(this.#o)try{this.#o(o,s)}catch{}})}}const Ht=t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache",S=process.platform==="win32",$t=async t=>{const{command:o,cwd:e,env:s,logFile:i}=t,r=Z(i,"a",y);let n;const p=S?"cmd":"/bin/sh",x=S?["/d","/s","/c",o]:["-c",o];try{n=Q(p,x,{cwd:e,detached:!0,env:ot({...process.env,...s},e),stdio:["ignore",r,r],windowsHide:!0})}finally{tt(r)}if(n.pid===void 0&&await new Promise((O,j)=>{n.once("spawn",()=>{O()}),n.once("error",I=>{j(I)})}),n.pid===void 0)throw new Error(`Failed to spawn detached process for command: ${o}`);return n.unref(),{pid:n.pid}},P=5e3,It=async t=>M(t.workspaceRoot,t.id,async()=>{const o=await u(t.workspaceRoot,t.id);if(o&&a(o.pid))throw new Error(`Service ${t.id} is already running (pid ${String(o.pid)})`);o&&await f(t.workspaceRoot,t.id,o);const e=await h(t.workspaceRoot),s=_(t.id),i=c(e,`${s}.log`),{pid:r}=await $t({command:t.command,cwd:t.cwd,env:t.env,logFile:i}),n={command:t.command,config:t.config,cwd:t.cwd,env:t.config.env??{},id:t.id,logFile:i,pid:r,slug:s,startedAt:new Date().toISOString(),visVersion:process.env.VIS_VERSION??"0.0.0"};if(await lt(t.workspaceRoot,n),t.skipReadiness!==!0)try{await at(t.config,{timeoutMs:t.readinessTimeoutMs})}catch(p){throw await D(r,t.config.killGracePeriodMs??P).catch(()=>{}),await f(t.workspaceRoot,t.id,n).catch(()=>{}),p}return{entry:n}}),At=async t=>M(t.workspaceRoot,t.id,async()=>{const o=await u(t.workspaceRoot,t.id);if(!o)return{stopped:!1};if(!a(o.pid))return await f(t.workspaceRoot,t.id,o),{stopped:!1};const e=t.graceMs??o.config.killGracePeriodMs??P;return await D(o.pid,e),await f(t.workspaceRoot,t.id,o),{stopped:!0}}),D=async(t,o)=>{H(t,"SIGTERM");const e=Date.now();for(;Date.now()-e<o;){if(!a(t))return;await new Promise(s=>{setTimeout(s,100)})}a(t)&&H(t,"SIGKILL")},H=(t,o)=>{try{process.platform==="win32"?process.kill(t,o):process.kill(-t,o)}catch(e){if(e.code==="ESRCH")return;throw e}};export{jt as H,st as S,It as a,at as b,ft as c,xt as d,Ot as e,f,a as i,Dt as p,u as r,At as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as f}from"node:module";import{m as c}from"./index-
|
|
1
|
+
import{createRequire as f}from"node:module";import{m as c}from"./index-CE6MsgcV.js";const p=f(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=n=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[t,e]=a.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return a.getBuiltinModule(n)}return p(n)},{statSync:m,existsSync:d}=k("node:fs"),g={aube:["aube-lock.yaml"],bun:["bun.lock","bun.lockb"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]},b={aube:["node_modules/.aube-state","node_modules/.modules.yaml"],bun:["node_modules/.bun-tag"],npm:["node_modules/.package-lock.json"],pnpm:["node_modules/.modules.yaml","node_modules/.pnpm/lock.yaml"],yarn:["node_modules/.yarn-integrity","node_modules/.yarn-state.yml",".yarn/install-state.gz"]},y={ci:{aube:"aube ci",bun:"bun install --frozen-lockfile",npm:"npm ci",pnpm:"pnpm install --frozen-lockfile",yarn:"yarn install --immutable"},tty:{aube:"aube install",bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}},h=1e3,_=n=>{for(const[t,e]of Object.entries(g))for(const s of e)if(d(c(n,s)))return{lockfileFile:s,manager:t}},M=(n,t)=>{let e;for(const s of b[t]){const o=c(n,s);if(!d(o))continue;const{mtimeMs:i}=m(o);(!e||i>e.mtimeMs)&&(e={mtimeMs:i,path:s})}return e},j=(n,t={})=>{const e=_(n);if(!e)return{checked:!1};const{lockfileFile:s,manager:o}=e,i=m(c(n,s)).mtimeMs,l=M(n,o),u=y[t.inCi?"ci":"tty"][o],r={installMarkerMtimeMs:l?.mtimeMs,lockfileMtimeMs:i,lockfilePath:s,marker:l?.path,packageManager:o};return l?i>l.mtimeMs+h?{checked:!0,detail:r,failure:"stale-install",message:`${s} is newer than node_modules (${l.path}) — run \`${u}\` to sync.`}:{checked:!0,detail:r}:{checked:!0,detail:r,failure:"missing-install",message:`lockfile detected but node_modules looks uninitialised — run \`${u}\` before \`vis run\`.`}},v=(n,t,e,s={})=>{if(s.skip)return{checked:!1,shouldContinue:!0};const o=j(n,{inCi:t});if(!o.failure)return{...o,shouldContinue:!0};const i=`preflight: ${o.message??"lockfile drift detected"}`;return t&&!s.ciAsWarning?{...o,formattedMessage:i,shouldContinue:!1}:(e.warn(i),{...o,formattedMessage:i,shouldContinue:!0})};export{_ as d,v as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as j}from"node:module";import{m as d,f as y}from"./index-
|
|
1
|
+
import{createRequire as j}from"node:module";import{m as d,f as y}from"./index-CE6MsgcV.js";import{a as A}from"./readJsonSync-CvkZyKmL-ihoybKvs.js";const M=j(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=i=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[e,t]=l.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return l.getBuiltinModule(i)}return M(i)},{readdirSync:_,lstatSync:S}=b("node:fs"),$=/^([^<(]+?)?(?:<([^>]+)>)?\s*(?:\(([^)]+)\))?\s*$/u,q=i=>{const e=i.match($);if(!e)return;const t=e[1]?.trim(),n=e[2]?.trim(),o=e[3]?.trim();if(!(!t&&!n&&!o))return{email:n||void 0,name:t||void 0,url:o||void 0}},w=i=>{if(!Array.isArray(i)||i.length===0)return;const e=[];for(const t of i)if(typeof t=="string"){const n=q(t);n&&e.push(n)}else if(t&&typeof t=="object"){const n=t,o=typeof n.name=="string"?n.name:void 0,r=typeof n.email=="string"?n.email:void 0,f=typeof n.url=="string"?n.url:void 0;(o||r||f)&&e.push({email:r,name:o,url:f})}return e.length>0?e:void 0},D=i=>{const e=d(i,"node_modules");if(!y(e))return new Map;const t=new Map,n=new Set,o=(r,f="")=>{if(n.has(r))return;n.add(r);let v;try{v=_(r)}catch{return}for(const a of v){const c=d(r,a);let m;try{m=S(c)}catch{continue}if(m.isSymbolicLink())continue;if(a.startsWith("@")){m.isDirectory()&&o(c,`${a}/`);continue}if(a===".pnpm"&&f===""){let s;try{s=_(c)}catch{continue}for(const p of s){const u=d(c,p,"node_modules");y(u)&&o(u)}continue}if(a.startsWith(".")||!m.isDirectory())continue;const g=f+a,h=d(c,"package.json");try{if(!y(h))continue;const s=A(h);if(typeof s.version!="string")continue;const p=`${g}@${s.version}`;t.has(p)||t.set(p,{directory:c,license:s.license,licenses:Array.isArray(s.licenses)?s.licenses:void 0,maintainers:w(s.maintainers),name:g,scripts:s.scripts&&typeof s.scripts=="object"?s.scripts:void 0,version:s.version});const u=d(c,"node_modules");y(u)&&o(u)}catch{}}};return o(e),t};export{w as n,D as r};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as d,f as u,v as o,T as $}from"./index-
|
|
1
|
+
import{m as d,f as u,v as o,T as $}from"./index-CE6MsgcV.js";import{a as k}from"../packem_chunks/cli-main.js";const E=(x,g,h,m=[])=>{const t=[];if(h===void 0)return t.push("minimumReleaseAge not set in vis.config; skipping native sync."),t;const l=Number.isFinite(h)?Math.max(0,Math.round(h)):0;switch(x){case"bun":{const n=d(g,"bunfig.toml");let e=u(n)?o(n):"";const a=l*60,i=`minimumReleaseAge = ${String(a)}`,s=m.length>0?`minimumReleaseAgeExcludes = [${m.map(p=>`"${p.replaceAll(String.raw`"`,String.raw`\"`)}"`).join(", ")}]`:void 0,c=/^\[install\][ \t]*\n/m.exec(e);if(c?.index===void 0){const p=s?`${i}
|
|
2
2
|
${s}`:i;e=`${e.trimEnd()?`${e.trimEnd()}
|
|
3
3
|
|
|
4
4
|
`:""}[install]
|
package/dist/packem_shared/{missing-package-json-DdMNbe_j.js → missing-package-json-CTF71tE5.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as a,m as h,B as l,I as f}from"./index-
|
|
1
|
+
import{f as a,m as h,B as l,I as f}from"./index-CE6MsgcV.js";import{e as d,k as $}from"../packem_chunks/catalog.js";const k=/\/+$/,p=/node_modules/,u=/\.git/,g=/[$()+.?[\\\]^{|}]/g,S=/\/\*\*$|\/\*\/\*$/,W=(i,c)=>{const e=c.replace(k,"");if(e.startsWith("!"))return[];const n=[];if(e.endsWith("/*")){const s=e.slice(0,-2),t=l(i,s);if(!a(t))return[];for(const r of f(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1,skip:[p,u]}))r.path===t||r.name.startsWith(".")||n.push(h(s,r.name));return n}if(e.endsWith("/**")||e.endsWith("/*/*")){const s=e.replace(S,""),t=l(i,s);if(!a(t))return[];for(const r of f(t,{includeFiles:!1,includeSymlinks:!1,skip:[p,u]})){if(r.path===t)continue;const m=r.path.slice(t.length+1);n.push(`${s}/${m}`)}return n}if(!e.includes("/")&&e.includes("*")){const s=e.replaceAll(g,String.raw`\$&`).replaceAll("*",".*"),t=new RegExp(`^${s}$`);for(const r of f(i,{includeFiles:!1,includeSymlinks:!1,maxDepth:1,skip:[p,u]}))r.path!==i&&t.test(r.name)&&n.push(r.name);return n}const o=l(i,e);return a(o)&&n.push(e),n},y=i=>{const c=d(i)??$(i)??[],e=new Set,n=[];for(const o of c)for(const s of W(i,o))s==="."||e.has(s)||(e.add(s),a(h(i,s,"package.json"))||n.push({packageDir:s}));return n};export{y as l};
|