@visulima/vis 1.0.0-alpha.22 → 1.0.0-alpha.24
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 +77 -0
- package/LICENSE.md +135 -2
- package/README.md +1 -1
- package/dashboard/dist/index.html +152 -0
- package/dist/bin.js +1 -1
- package/dist/binx.js +3 -0
- package/dist/config/index.d.ts +28 -41
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/bin.js +373 -367
- package/dist/packem_chunks/bloom-status.js +2 -2
- package/dist/packem_chunks/bloom-sync.js +2 -2
- package/dist/packem_chunks/config.js +12 -12
- package/dist/packem_chunks/doctor-probe.js +2 -2
- package/dist/packem_chunks/fix.js +3 -3
- 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 +3 -3
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +10 -10
- package/dist/packem_chunks/handler15.js +2 -2
- 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 +2 -2
- package/dist/packem_chunks/handler22.js +2 -2
- package/dist/packem_chunks/handler23.js +2 -2
- package/dist/packem_chunks/handler24.js +1 -18
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +5 -1
- package/dist/packem_chunks/handler27.js +1 -5
- package/dist/packem_chunks/handler28.js +3 -1
- package/dist/packem_chunks/handler29.js +1 -3
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +7 -1
- package/dist/packem_chunks/handler31.js +32 -6
- package/dist/packem_chunks/handler32.js +3 -33
- package/dist/packem_chunks/handler33.js +1 -3
- package/dist/packem_chunks/handler34.js +28 -1
- package/dist/packem_chunks/handler35.js +5 -26
- package/dist/packem_chunks/handler36.js +22 -5
- package/dist/packem_chunks/handler37.js +60 -21
- package/dist/packem_chunks/handler38.js +6 -428
- package/dist/packem_chunks/handler39.js +708 -61
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler40.js +24 -6
- package/dist/packem_chunks/handler41.js +237 -166
- package/dist/packem_chunks/handler42.js +153 -24
- package/dist/packem_chunks/handler43.js +10 -153
- package/dist/packem_chunks/handler44.js +25 -10
- package/dist/packem_chunks/handler45.js +24 -25
- package/dist/packem_chunks/handler46.js +3 -24
- package/dist/packem_chunks/handler47.js +27 -3
- package/dist/packem_chunks/handler48.js +173 -21
- package/dist/packem_chunks/handler49.js +33 -173
- package/dist/packem_chunks/handler5.js +6 -6
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler7.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 +4 -4
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +2 -2
- package/dist/packem_chunks/index.js +2 -2
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/list.js +2 -2
- package/dist/packem_chunks/loader.js +3 -3
- package/dist/packem_chunks/loader2.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/status.js +2 -2
- package/dist/packem_chunks/sync.js +2 -2
- package/dist/packem_chunks/sync2.js +2 -2
- package/dist/packem_chunks/tripwire.js +2 -2
- package/dist/packem_chunks/verify-lockfile.js +2 -2
- package/dist/packem_shared/{advisories-DS8JEB_g.js → advisories-U1QKY_tg.js} +1 -1
- package/dist/packem_shared/{ai-analysis-DGBZYlxF.js → ai-analysis-B8pDCOuT.js} +2 -2
- package/dist/packem_shared/ai-fix-DiGSrGKv.js +43 -0
- package/dist/packem_shared/anolilab-text-CAM_E6uK.js +13 -0
- package/dist/packem_shared/applyDefaults-KxZkvlp3.js +1 -0
- package/dist/packem_shared/build-scripts-3E2pmscY.js +1 -0
- package/dist/packem_shared/{cyclonedx-CO7-Y1B1.js → cyclonedx-DPEW0nwS.js} +3 -3
- package/dist/packem_shared/dependency-scan-BbtivycX.js +1 -0
- package/dist/packem_shared/docker-_pBC9Loj.js +60 -0
- package/dist/packem_shared/failure-log-B0Uh-65U.js +2 -0
- package/dist/packem_shared/index-B8Ko8mwG.js +29 -0
- package/dist/packem_shared/index-D_tAc2nS.js +1 -0
- package/dist/packem_shared/index.server-B7ETiT4C.js +2 -0
- package/dist/packem_shared/lifecycle-DJDsjoic.js +2 -0
- package/dist/packem_shared/{lockfile-C5DYMHVq.js → lockfile-CQLFNyVa.js} +1 -1
- package/dist/packem_shared/manifests-Z3spBpxv.js +1 -0
- package/dist/packem_shared/{min-release-age-D462DvYM.js → min-release-age-Cz6HbF-I.js} +2 -2
- package/dist/packem_shared/native-config-sync-BOeuyrBj.js +21 -0
- package/dist/packem_shared/{osv-bloom-QSAn2Dcw.js → osv-bloom-CyCDpXBl.js} +2 -2
- package/dist/packem_shared/peer-warnings-EvSJ18gE.js +1 -0
- package/dist/packem_shared/pm-runner-Dnj9J3KF.js +1 -0
- package/dist/packem_shared/provenance-yESbF7Vs.js +1 -0
- package/dist/packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js +1 -0
- package/dist/packem_shared/registry-keys-pemEkRM9.js +1 -0
- package/dist/packem_shared/{resolve-explicit-BgFQHUEP.js → resolve-explicit-BpxcFRuk.js} +3 -3
- package/dist/packem_shared/runtime-check-DgXsKCsv.js +1 -0
- package/dist/packem_shared/s1ngularity-B_xjP4lC.js +1 -0
- package/dist/packem_shared/scan-progress-EbvmIh4i.js +2 -0
- package/dist/packem_shared/{selectors-B2ISH581.js → selectors-BE2BCnTR.js} +1 -1
- package/dist/packem_shared/{signatures-b-jJYoZd.js → signatures-DBwSnMBB.js} +1 -1
- package/dist/packem_shared/toolchain-Jx2lkAYy.js +5 -0
- package/dist/packem_shared/typosquats-Citu7BRY.js +1 -0
- package/dist/packem_shared/verify-C8EAHql6.js +1 -0
- package/dist/packem_shared/{vis-update-app-Bnu1EIgE.js → vis-update-app-BWA1kA1q.js} +1 -1
- package/index.js +52 -52
- package/package.json +23 -12
- package/schemas/vis-config.schema.json +61 -12
- package/dist/packem_chunks/handler50.js +0 -34
- package/dist/packem_shared/ai-cache-BjlXWJtl.js +0 -1
- package/dist/packem_shared/ai-fix-BhcTrkuW.js +0 -43
- package/dist/packem_shared/applyDefaults-BOVDw1jD.js +0 -1
- package/dist/packem_shared/build-scripts-DsWMSWDs.js +0 -1
- package/dist/packem_shared/cache-directory-DQak1Vjc.js +0 -1
- package/dist/packem_shared/dependency-scan-DPHTzA5r.js +0 -1
- package/dist/packem_shared/docker-lk0-5Z-i.js +0 -60
- package/dist/packem_shared/failure-log-DF7nrFIs.js +0 -2
- package/dist/packem_shared/flakiness-DKCOYwN7.js +0 -1
- package/dist/packem_shared/index-B4gpNmrG.js +0 -1
- package/dist/packem_shared/lifecycle-boYwVQSE.js +0 -2
- package/dist/packem_shared/manifests-B0fMp872.js +0 -1
- package/dist/packem_shared/native-config-sync-B0_ef78M.js +0 -21
- package/dist/packem_shared/provenance-smHa8efI.js +0 -1
- package/dist/packem_shared/registry-keys-3qaVog76.js +0 -1
- package/dist/packem_shared/run-summary-utils-DIJV_dUD.js +0 -1
- package/dist/packem_shared/runtime-check-DrMx4Q9L.js +0 -1
- package/dist/packem_shared/s1ngularity-CwSBPB3I.js +0 -1
- package/dist/packem_shared/scan-progress-CMynp3eA.js +0 -2
- package/dist/packem_shared/toolchain-OH1PXwbZ.js +0 -5
- package/dist/packem_shared/typosquats-CJ4o1l7U.js +0 -1
- package/dist/packem_shared/verify-CQbzknur.js +0 -1
- package/dist/packem_shared/xxh3-DrAUNq4n.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var J=Object.defineProperty;var j=(c,o)=>J(c,"name",{value:o,configurable:!0});import{
|
|
2
|
-
Settings that would sync to pnpm-workspace.yaml:`);for(const $ of r)m.success(` ${$}`)}else m.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(m.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),m.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!c?.length)return}const{packageManager:M}=
|
|
3
|
-
`);const k=new Set;U("socket")&&k.add("socket"),U("depsDev")&&k.add("deps-dev");const C=a?.security?.policies?.score?.minimum,H=
|
|
4
|
-
`);for(const s of n){const P=s.vulnerabilities?.length||s.socketReport&&s.socketReport.alerts.length>0,S=!!s.acceptedRisk,V=P?S?"✓":"⚠":"✓",Y=S?"gray":s.updateType==="major"?"red":s.updateType==="minor"?"yellow":"green",g=s.socketReport?.score.overall,G=g===void 0?"":` [${String(Math.round(g*100))}%]`,T=g===void 0?void 0:
|
|
1
|
+
var J=Object.defineProperty;var j=(c,o)=>J(c,"name",{value:o,configurable:!0});import{a as W,y as q,p as m,U as B,c as K,R as Z,F as f,i as U,b as Q,V as X,K as _,H as A,W as ee,G as te,s as oe}from"./bin.js";import{render as D,renderToString as re}from"@visulima/tui";import{Text as y}from"@visulima/tui/components/text";import i from"react";import{H as se,e as ne,Z as ae}from"../packem_shared/ai-analysis-B8pDCOuT.js";import{A as ie}from"../packem_shared/pm-runner-Dnj9J3KF.js";import{U as ce,C as le,a as F}from"../packem_shared/vis-update-app-BWA1kA1q.js";var de=Object.defineProperty,ue=j((c,o)=>de(c,"name",{value:o,configurable:!0}),"A");const ke=ue(async({argument:c,logger:o,options:e,visConfig:a,workspaceRoot:x})=>{if(!x)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const u=x;if(e.securityConfig){const t=ie(u);if(W(a??{},t.name),e.sync&&t.name==="pnpm"){const r=q(a??{});if(r.length>0){m.info(`
|
|
2
|
+
Settings that would sync to pnpm-workspace.yaml:`);for(const $ of r)m.success(` ${$}`)}else m.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(m.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),m.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!c?.length)return}const{packageManager:M}=B(u),N=K(u),l=a?.update??{},v=Z(u,M,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(v.size===0){o.info("No catalogs found.");return}const w=e.target??l.target??"latest";if(!["latest","minor","patch"].includes(w))throw new Error(`Invalid target "${w}". Use: latest, minor, or patch.`);const O={exclude:[...f(e.exclude),...f(l.exclude)],ignore:f(l.ignore),include:[...f(e.include),...f(l.include),...c],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||l.prerelease||!1,security:e.security!==!1,target:w};let R=0;for(const t of v.values())R+=t.size;const h=!!process.stdout.isTTY&&!oe;let d;const z=h?(t,r)=>{d?d.rerender(i.createElement(F,{current:t,total:r})):d=D(i.createElement(F,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{o.info(`Checking ${String(t)}/${String(r)} dependencies...`)};h||o.info(`Checking ${String(R)} catalog dependencies against npm registry...
|
|
3
|
+
`);const k=new Set;U("socket")&&k.add("socket"),U("depsDev")&&k.add("deps-dev");const C=a?.security?.policies?.score?.minimum,H=Q(a?.security,{disabled:k,minimumScore:C}),{failed:b,outdated:n}=await X(v,O,N,z,u,H,a?.security?.acceptedRisks);if(d&&(d.clear(),d.unmount()),b.length>0&&o.warn(`Failed to fetch: ${b.join(", ")}`),n.length===0){o.info("All catalog dependencies are up to date.");return}const E=e.format??l.format??"table",I=se(e.aiType??"impact"),p=e.ai?await ne(n,o,a?.ai,I):void 0;if(h&&E==="table"){const t=new ce(n,p??null),r=a?.tui?.autoExit??!1,$=r===!0?3:typeof r=="number"?r:0;await D(i.createElement(le,{autoExitSeconds:$,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const L=process.stdout.columns||80;process.stdout.write(`
|
|
4
|
+
`);for(const s of n){const P=s.vulnerabilities?.length||s.socketReport&&s.socketReport.alerts.length>0,S=!!s.acceptedRisk,V=P?S?"✓":"⚠":"✓",Y=S?"gray":s.updateType==="major"?"red":s.updateType==="minor"?"yellow":"green",g=s.socketReport?.score.overall,G=g===void 0?"":` [${String(Math.round(g*100))}%]`,T=g===void 0?void 0:_(g);process.stdout.write(`${re(i.createElement(y,null," ",i.createElement(y,{color:Y},V),` ${s.packageName} ${s.currentRange} → ${s.newRange}`,i.createElement(y,{dimColor:!0},` ${s.updateType}`),T?i.createElement(y,{color:T},G):null),{columns:L})}
|
|
5
5
|
`)}process.stdout.write(`
|
|
6
6
|
`),o.info(A(n,C))}else if(E==="json"){const t={failed:b,outdated:n};p&&(t.aiAnalysis=p),process.stdout.write(`${JSON.stringify(t,void 0,2)}
|
|
7
|
-
`)}else E==="minimal"?process.stdout.write(`${
|
|
8
|
-
`):(
|
|
7
|
+
`)}else E==="minimal"?process.stdout.write(`${ee(n)}
|
|
8
|
+
`):(te(n,o),o.info(A(n,C)),p&&(o.info(""),o.info(ae(p))));e.exitCode&&n.length>0&&(process.exitCode=1)},"execute");export{ke as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=Object.defineProperty;var g=(r,n)=>h(r,"name",{value:n,configurable:!0});import{r as m}from"../packem_shared/toolchain-
|
|
1
|
+
var h=Object.defineProperty;var g=(r,n)=>h(r,"name",{value:n,configurable:!0});import{r as m}from"../packem_shared/toolchain-Jx2lkAYy.js";var C=Object.defineProperty,a=g((r,n)=>C(r,"name",{value:n,configurable:!0}),"a");const u=a(()=>process.env.GITHUB_BASE_REF?{base:`origin/${process.env.GITHUB_BASE_REF}`,head:process.env.GITHUB_SHA??"HEAD"}:process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME?{base:`origin/${process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME}`,head:process.env.CI_COMMIT_SHA??"HEAD"}:process.env.BUILDKITE_PULL_REQUEST_BASE_BRANCH?{base:`origin/${process.env.BUILDKITE_PULL_REQUEST_BASE_BRANCH}`,head:process.env.BUILDKITE_COMMIT??"HEAD"}:process.env.CIRCLE_BRANCH&&process.env.CIRCLE_SHA1?{base:"origin/main",head:process.env.CIRCLE_SHA1}:{base:"origin/main",head:"HEAD"},"detectCiRefs"),A=a(async({argument:r,logger:n,options:e,runtime:s,visConfig:f,workspaceRoot:t})=>{const p=r[0];if(!p)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=p.split(",").map(o=>o.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const{base:_,head:d}=u(),c=e.base??_,E=e.head??d;e.skipToolchain||n.info("▸ Toolchain pre-flight"),await m(t,f?.toolchain,{error:a(o=>{n.error(o)},"error"),info:a(o=>{n.info(o)},"info"),warn:a(o=>{n.warn(o)},"warn")},!!e.skipToolchain),e.install===!1?n.info("▸ Skipping install (--no-install)"):(n.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]}));for(const o of l){n.info(`▸ Running affected ${o} (base=${c}, head=${E})`);const i=[o,`--base=${c}`,`--head=${E}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];e.parallel!==void 0&&i.push(`--parallel=${String(e.parallel)}`),e.partition&&i.push(`--partition=${String(e.partition)}`),e.query&&i.push(`--query=${String(e.query)}`),await s.runCommand("affected",{argv:i})}n.info("▸ CI pipeline complete")},"execute");export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var m=Object.defineProperty;var d=(s,o)=>m(s,"name",{value:o,configurable:!0});import{createRequire as p}from"node:module";import{M as a,i as k}from"
|
|
1
|
+
var m=Object.defineProperty;var d=(s,o)=>m(s,"name",{value:o,configurable:!0});import{createRequire as p}from"node:module";import{M as a,i as k}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{cleanWorkspace as b}from"#native";import{p as c}from"./bin.js";import{f as $}from"../packem_shared/utils-DrNg0XTR.js";const g=p(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=d(s=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[o,n]=f.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return f.getBuiltinModule(s)}return g(s)},"__cjs_getBuiltinModule"),{readdirSync:v,lstatSync:y,unlinkSync:_}=h("node:fs");var R=Object.defineProperty,u=d((s,o)=>R(s,"name",{value:o,configurable:!0}),"f");const j=u(s=>{const o=[],n=[s];for(;n.length>0;){const t=n.pop();let i;try{i=v(t)}catch{continue}for(const r of i){const e=a(t,r);try{const l=y(e);if(l.isSymbolicLink()||!l.isDirectory())continue}catch{continue}r==="node_modules"?o.push(e):r!==".git"&&r!==".hg"&&n.push(e)}}return o},"findNodeModulesDirectories"),M=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],x=u((s,o,n)=>{let t=0,i=!1;for(const r of M){const e=a(s,r);if(k(e)){if(o){n.info(` ${e}`),t++;continue}try{_(e),c.success(`Removed ${e}`),t++}catch(l){c.error(`${e}: ${$(l)}`),i=!0}}}return{hadError:i,removed:t}},"removeLockfiles"),C=u(async({logger:s,options:o,workspaceRoot:n})=>{const t=n??process.cwd(),i=o.lockfile||!1;if(o.dryRun){const e=j(t);if(e.length>0){c.info("Would remove:");for(const l of e)s.info(` ${l}`)}else c.info("No node_modules directories found.");i&&x(t,!0,s);return}const r=b(t,i);for(const e of r.removed)c.success(`Removed ${e}`);for(const e of r.lockfilesRemoved)c.success(`Removed ${e}`);for(const e of r.errors)c.error(e);r.removed.length===0&&r.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${r.removed.length} node_modules director${r.removed.length===1?"y":"ies"}`),r.errors.length>0&&(process.exitCode=1)},"execute");export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var i=Object.defineProperty;var s=(e,o)=>i(e,"name",{value:o,configurable:!0});import{
|
|
1
|
+
var i=Object.defineProperty;var s=(e,o)=>i(e,"name",{value:o,configurable:!0});import{R as l,M as p}from"../packem_shared/pm-runner-Dnj9J3KF.js";var f=Object.defineProperty,d=s((e,o)=>f(e,"name",{value:o,configurable:!0}),"n");const u=d(async({logger:e,options:o,visConfig:a,workspaceRoot:r})=>{const c=r??process.cwd(),t=l(c,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),n=p(t,o.check||!1,c,e);n!==0&&(process.exitCode=n)},"execute");export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var d=Object.defineProperty;var i=(e,s)=>d(e,"name",{value:s,configurable:!0});import{
|
|
1
|
+
var d=Object.defineProperty;var i=(e,s)=>d(e,"name",{value:s,configurable:!0});import{R as k,B as u}from"../packem_shared/pm-runner-Dnj9J3KF.js";var v=Object.defineProperty,x=i((e,s)=>v(e,"name",{value:s,configurable:!0}),"n");const w=x(async({argument:e,logger:s,options:a,visConfig:r,workspaceRoot:l})=>{const o=e;if(!o||o.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[t,...g]=o,n=l??process.cwd(),p=k(n,{configBackend:r?.install?.backend,configCorepack:r?.install?.corepack}),f=a.package?Array.isArray(a.package)?a.package:[a.package]:[],c=u(p,{additionalPackages:f,args:g,package:t,shellMode:a.shellMode||!1,silent:a.silent||!1},n,s,{offline:a.offline||!1});c!==0&&(process.exitCode=c)},"execute");export{w as default};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var H=Object.defineProperty;var I=(e,t)=>H(e,"name",{value:t,configurable:!0});import{createRequire as U}from"node:module";import{C as O,z as F}from"
|
|
1
|
+
var H=Object.defineProperty;var I=(e,t)=>H(e,"name",{value:t,configurable:!0});import{createRequire as U}from"node:module";import{C as O,z as F}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{d as D,P as K,R as S,w as j,p as V}from"./heal.js";import{A as q,P as Y}from"../packem_shared/pm-runner-Dnj9J3KF.js";import{p as a}from"./bin.js";const P=U(import.meta.url),T=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=I(e=>{if(typeof T<"u"&&T.versions&&T.versions.node){const[t,o]=T.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return T.getBuiltinModule(e)}return P(e)},"__cjs_getBuiltinModule"),{readFile:B}=A("node:fs/promises"),{createInterface:M}=A("node:readline");var J=Object.defineProperty,k=I((e,t)=>J(e,"name",{value:t,configurable:!0}),"o");const z=k(()=>!!process.stdout.isTTY&&process.env.CI!=="true","isInteractive"),W=k(e=>new Promise(t=>{const o=M({input:process.stdin,output:process.stderr});o.question(`${e} (Y/n) `,i=>{o.close();const s=i.trim().toLowerCase();t(s===""||s==="y"||s==="yes")})}),"defaultPrompt"),X=k((e,t)=>{const o=q(t),i=Y(o,{exact:!1,filter:[],global:!1,optional:!1,packages:[e],peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},t,console);return Promise.resolve({exitCode:i})},"defaultRunInstall"),y=k(e=>`pnpm add ${e}`,"installCommandFor"),Q=k(e=>e==="@gitbeaker/rest"?import("@gitbeaker/rest"):import("@octokit/rest"),"defaultImport"),L=k(async(e,t={})=>{const o=t.interactive??z(),i=t.prompt??W,s=t.runInstall??X,l=t.importImpl??Q,d=t.workspaceRoot??process.cwd();try{return await l(e)}catch(n){const{code:p}=n;if(p!=="ERR_MODULE_NOT_FOUND"&&p!=="MODULE_NOT_FOUND")throw n}if(!o)throw new Error(`${e} is not installed. \`vis ai heal accept\` needs it to talk to the host. Install it in your repo first:
|
|
2
2
|
${y(e)}`);if(!await i(`${e} isn't installed. Install it now?`))throw new Error(`${e} install declined. Re-run \`vis ai heal accept\` after installing manually:
|
|
3
3
|
${y(e)}`);const r=await s(e,d);if(r.exitCode!==0)throw new Error(`Install of ${e} failed (exit ${String(r.exitCode)}). Install manually and retry:
|
|
4
|
-
${y(e)}`);return await l(e)},"loadOptionalSdk");var Z=Object.defineProperty,_=I((e,t)=>Z(e,"name",{value:t,configurable:!0}),"s");const ee=_(e=>{const t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`Expected GITHUB_REPOSITORY in "owner/repo" form, got: ${e}`);return{owner:e.slice(0,t),repo:e.slice(t+1)}},"splitGithubRepo"),te=_(async(e,t)=>{if(t.githubClient)return t.githubClient;const o=(await(t.loadSdk??L)("@octokit/rest")).Octokit;if(!o)throw new TypeError("Loaded `@octokit/rest` but no `Octokit` export was found. Reinstall the package or pin to a supported major.");return new o({auth:e})},"loadGithubClient"),oe=_(async(e,t,o)=>{if(o.gitlabClient)return o.gitlabClient;const i=(await(o.loadSdk??L)("@gitbeaker/rest")).Gitlab;if(!i)throw new TypeError("Loaded `@gitbeaker/rest` but no `Gitlab` export was found. Reinstall the package or pin to a supported major.");return new i({host:t,token:e})},"loadGitlabClient"),re=_(e=>e.replace(/\/api\/v\d+\/?$/,""),"apiBaseToHost"),ie=_(async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(w=>B(w,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitHub: GITHUB_REPOSITORY (owner/repo) is not set.");if(!o.token)throw new Error("Cannot commit on GitHub: GITHUB_TOKEN is not set. Grant the workflow `contents: write` and pass the token through.");const{owner:r,repo:n}=ee(o.repo),
|
|
4
|
+
${y(e)}`);return await l(e)},"loadOptionalSdk");var Z=Object.defineProperty,_=I((e,t)=>Z(e,"name",{value:t,configurable:!0}),"s");const ee=_(e=>{const t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`Expected GITHUB_REPOSITORY in "owner/repo" form, got: ${e}`);return{owner:e.slice(0,t),repo:e.slice(t+1)}},"splitGithubRepo"),te=_(async(e,t)=>{if(t.githubClient)return t.githubClient;const o=(await(t.loadSdk??L)("@octokit/rest")).Octokit;if(!o)throw new TypeError("Loaded `@octokit/rest` but no `Octokit` export was found. Reinstall the package or pin to a supported major.");return new o({auth:e})},"loadGithubClient"),oe=_(async(e,t,o)=>{if(o.gitlabClient)return o.gitlabClient;const i=(await(o.loadSdk??L)("@gitbeaker/rest")).Gitlab;if(!i)throw new TypeError("Loaded `@gitbeaker/rest` but no `Gitlab` export was found. Reinstall the package or pin to a supported major.");return new i({host:t,token:e})},"loadGitlabClient"),re=_(e=>e.replace(/\/api\/v\d+\/?$/,""),"apiBaseToHost"),ie=_(async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(w=>B(w,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitHub: GITHUB_REPOSITORY (owner/repo) is not set.");if(!o.token)throw new Error("Cannot commit on GitHub: GITHUB_TOKEN is not set. Grant the workflow `contents: write` and pass the token through.");const{owner:r,repo:n}=ee(o.repo),p=await te(o.token,e),u=(await p.rest.git.getRef({owner:r,ref:`heads/${t}`,repo:n})).data.object.sha,h=(await p.rest.git.getCommit({commit_sha:u,owner:r,repo:n})).data.tree.sha,m=await Promise.all(i.map(async w=>{const v=O(l,w),E=await d(v),C=await p.rest.git.createBlob({content:Buffer.from(E,"utf8").toString("base64"),encoding:"base64",owner:r,repo:n});return{mode:"100644",path:w,sha:C.data.sha,type:"blob"}})),f=await p.rest.git.createTree({base_tree:h,owner:r,repo:n,tree:m}),b=await p.rest.git.createCommit({message:s,owner:r,parents:[u],repo:n,tree:f.data.sha});return await p.rest.git.updateRef({owner:r,ref:`heads/${t}`,repo:n,sha:b.data.sha}),{sha:b.data.sha,url:b.data.html_url}},"commitToGithub"),ae=_(async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(m=>B(m,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitLab: CI_PROJECT_ID / CI_PROJECT_PATH is not set.");if(!o.token)throw new Error("Cannot commit on GitLab: no token. CI_JOB_TOKEN cannot push commits — set GITLAB_TOKEN to a PAT/project-token with `api` scope.");if(!o.apiBaseUrl)throw new Error("Cannot commit on GitLab: CI_API_V4_URL is not set.");const r=re(o.apiBaseUrl),n=await oe(o.token,r,e),p=await Promise.all(i.map(async m=>{const f=O(l,m);return{action:"update",content:await d(f),filePath:m}})),u=await n.Commits.create(o.repo,t,s,p),h=u.id??u.sha;if(!h)throw new Error("GitLab Commits.create returned no commit ID — cannot reference the new commit.");return{sha:h,url:u.web_url??u.webUrl}},"commitToGitlab"),ne=_(async e=>{if(e.files.length===0)throw new Error("Cannot commit: no files to include.");if(e.ciContext.provider==="github-actions")return await ie(e);if(e.ciContext.provider==="gitlab-ci")return await ae(e);throw new Error(`Cannot commit: unsupported CI provider \`${e.ciContext.provider}\`. Run \`vis ai heal accept\` from a recognised CI environment.`)},"commitFiles");var se=Object.defineProperty,g=I((e,t)=>se(e,"name",{value:t,configurable:!0}),"u");const G="/vis heal accept",ce=g(async e=>{if(!e)return;let t;try{t=await B(e,"utf8")}catch{return}const o=JSON.parse(t),i=o.comment?.body??"",s=o.comment?.user?.login??"",l=o.pull_request?.head?.repo?.full_name,d=o.pull_request?.base?.repo?.full_name??o.repository?.full_name,r=l!==void 0&&d!==void 0&&l!==d;return{actor:s,body:i,headRef:o.pull_request?.head?.ref,isFork:r}},"loadGithubTrigger"),le=g(e=>{const t=e.VIS_HEAL_TRIGGER_BODY,o=e.VIS_HEAL_TRIGGER_ACTOR;if(!(!t||!o))return{actor:o,body:t,headRef:e.VIS_HEAL_HEAD_REF,isFork:!1}},"loadGitlabTrigger"),de=g(e=>{const t=e.BUILDKITE_UNBLOCKER_EMAIL??e.BUILDKITE_UNBLOCKER;if(t)return{actor:t,body:G,headRef:e.BUILDKITE_BRANCH,isFork:!1}},"loadBuildkiteTrigger"),pe=g(async(e,t)=>{if(e.provider==="github-actions")return await ce(t.GITHUB_EVENT_PATH);if(e.provider==="gitlab-ci")return le(t);if(e.provider==="buildkite")return de(t)},"loadTrigger"),ue=g((e,t)=>{const o=t.BUILDKITE_REPO;if(!o)return;const i=/(?:^|@|\/\/)github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(o);if(i&&t.GITHUB_TOKEN)return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"github-actions",repo:`${i[1]}/${i[2]}`,sha:e.sha,token:t.GITHUB_TOKEN};const s=/\/\/([^/]*gitlab[^/]*)\/([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),l=s?null:/@([^/:]*gitlab[^/:]*):([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),d=s??l;if(d&&t.GITLAB_TOKEN){const r=d[1];return{apiBaseUrl:t.CI_API_V4_URL??`https://${r}/api/v4`,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"gitlab-ci",repo:`${d[2]}/${d[3]}`,sha:e.sha,token:t.GITLAB_TOKEN}}},"deriveBuildkiteCommitContext"),me=g(async e=>{const t=e.fetchImpl??globalThis.fetch,o=`${(e.apiBaseUrl??"https://api.github.com").replace(/\/+$/,"")}/repos/${e.repo}/pulls/${String(e.prNumber)}`;try{const i=await t(o,{headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${e.token}`,"X-GitHub-Api-Version":"2022-11-28"}});return i.ok?(await i.json()).head?.ref:void 0}catch{return}},"fetchGithubHeadRef"),fe=g((e,t,o,i)=>{const s=t.map(l=>`- \`${l}\``).join(`
|
|
5
5
|
`);return["## vis ai heal — committed","",`Accepted by @${i}.`,"",`Failing task: \`${o}\``,e.url?`Commit: [\`${e.sha.slice(0,7)}\`](${e.url})`:`Commit: \`${e.sha.slice(0,7)}\``,"","### Files changed",s,"","_Re-run the failing job to confirm the fix landed._"].join(`
|
|
6
|
-
`)},"summariseDetail"),he=g(async(e,t={})=>{const{logger:o,visConfig:i,workspaceRoot:s}=e,l=s??process.cwd(),d=t.env??process.env,r=await(t.detectCi??(()=>D(d)))();if(r.provider==="unknown"){a.error("`vis ai heal accept` must run inside a recognised CI provider (GitHub Actions, GitLab CI, or Buildkite)."),process.exitCode=1;return}const n=await
|
|
6
|
+
`)},"summariseDetail"),he=g(async(e,t={})=>{const{logger:o,visConfig:i,workspaceRoot:s}=e,l=s??process.cwd(),d=t.env??process.env,r=await(t.detectCi??(()=>D(d)))();if(r.provider==="unknown"){a.error("`vis ai heal accept` must run inside a recognised CI provider (GitHub Actions, GitLab CI, or Buildkite)."),process.exitCode=1;return}const n=await pe(r,d);if(!n){const c=r.provider==="github-actions"?"No issue_comment payload found. Trigger this command from a workflow listening for `issue_comment.created`.":r.provider==="gitlab-ci"?"No GitLab trigger payload found. Set VIS_HEAL_TRIGGER_BODY, VIS_HEAL_TRIGGER_ACTOR, and VIS_HEAL_HEAD_REF in the bridge that re-emits note hooks as pipeline runs.":"No Buildkite unblock signal found. Wire this command to run after a manually-unblocked block step so BUILDKITE_UNBLOCKER_EMAIL is set.";a.error(c),process.exitCode=1;return}if(r.provider!=="buildkite"&&!n.body.includes(G)){a.notice(`Trigger comment does not contain \`${G}\`; nothing to do.`);return}const p=i?.ai?.heal?.allowedActors??[];if(p.length===0){a.error("`ai.heal.allowedActors` is empty. Configure the allow-list in `vis.config.*` before enabling auto-commit."),process.exitCode=1;return}if(!n.actor||!p.includes(n.actor)){const c=r.provider==="buildkite"?"Buildkite entries are emails (BUILDKITE_UNBLOCKER_EMAIL) or Buildkite usernames (BUILDKITE_UNBLOCKER), not the upstream GitHub/GitLab username.":r.provider==="gitlab-ci"?"GitLab entries are platform usernames (without the leading `@`).":"GitHub entries are platform usernames (without the leading `@`).";a.error(`Actor \`${n.actor||"(unknown)"}\` is not in \`ai.heal.allowedActors\`. Refusing to commit. ${c}`),process.exitCode=1;return}if(n.isFork){a.error("Refusing to accept: the change is from a forked repository. The CI token does not have write access to the fork."),process.exitCode=1;return}let u=n.headRef;if(!u&&r.provider==="github-actions"&&r.prNumber!==void 0&&r.repo&&r.token&&(u=await me({fetchImpl:t.fetchImpl,prNumber:r.prNumber,repo:r.repo,token:r.token})),!u){a.error("Could not resolve the PR / MR head branch. Ensure the trigger payload includes head.ref or set VIS_HEAL_HEAD_REF."),process.exitCode=1;return}a.info(`Accepting fix on \`${u}\` for actor \`${n.actor}\`.`);const h=await K(l,e.options.run);if(h.outcome==="no-failed-task"){a.error("No failed tasks found in the run summary. The accept command should run on the same workspace as the original failure."),process.exitCode=1;return}if(h.outcome==="missing-metadata"){a.error(`Failed task ${h.failedTask.taskId} is missing project/target metadata; cannot validate the fix.`),process.exitCode=1;return}if(h.outcome==="no-failure-context"){a.error(`No failure log or run summary found for ${h.failedTask.taskId}.`),process.exitCode=1;return}const m=h,f=await S(e,m);if(f.outcome==="no-proposal"){a.error("AI fix proposal failed; cannot commit."),process.exitCode=1;return}if(f.outcome==="cannot-fix"){a.warn(`AI declined to fix: ${f.detail??"(no reason)"}. Nothing to commit.`),process.exitCode=1;return}if(f.outcome==="empty-patches"){a.warn("AI returned an empty patch set. Nothing to commit."),process.exitCode=1;return}if(f.outcome==="no-patches-applied"){a.error("Patches could not be applied to the workspace. Refusing to commit."),process.exitCode=1;return}a.info(`Re-running ${m.failedTask.taskId} to validate the fix before committing...`);const b=await j(e,m,{validate:t.validate});if(b.exitCode!==0){a.error(`Validation failed (exit ${String(b.exitCode)}). Refusing to commit.`),b.stderr.trim().length>0&&(o.info("--- validation stderr (tail) ---"),o.info(b.stderr.split(`
|
|
7
7
|
`).slice(-20).join(`
|
|
8
8
|
`))),process.exitCode=1;return}a.success("Validation passed. Committing.");const w=(f.applyResults??[]).filter(c=>c.status==="applied").map(c=>{const $=c.absolutePath??c.patch.file,x=F(l,$);return x===""||x.startsWith("..")?c.patch.file:x});if(w.length===0){a.error("No applied files to commit. Aborting."),process.exitCode=1;return}const v=[`fix: vis ai heal accepted by @${n.actor}`,"",`Failing task: ${m.failedTask.taskId}`,f.proposal?.explanation?`
|
|
9
9
|
${f.proposal.explanation}`:"","","Auto-committed by `vis ai heal accept`."].join(`
|
|
10
|
-
`);let E=r;if(r.provider==="buildkite"){const c=
|
|
10
|
+
`);let E=r;if(r.provider==="buildkite"){const c=ue(r,d);if(!c){a.error("Cannot determine the upstream VCS to commit to. Buildkite jobs need GITHUB_TOKEN or GITLAB_TOKEN set (matching the host parsed from BUILDKITE_REPO) for `vis ai heal accept` to land the commit."),process.exitCode=1;return}E=c}let C;try{C=await ne({branch:u,ciContext:E,files:w,message:v,workspaceRoot:l,...t.commitOverrides})}catch(c){a.error(`Commit failed: ${c instanceof Error?c.message:String(c)}`),process.exitCode=1;return}a.success(`Committed as ${C.sha.slice(0,7)}${C.url?` — ${C.url}`:""}.`);const N=fe(C,w,m.failedTask.taskId,n.actor),R=await(t.postComment??(async(c,$)=>V({body:c,context:$})))(N,r);!R.posted&&R.method!=="skipped"&&a.warn(`Commit landed but the confirmation comment failed: ${R.error??"unknown"}`)},"acceptHeal"),Ie=g(async e=>{await he(e)},"aiHealAccept");export{G as TRIGGER_PHRASE,Ie as aiHealAccept,ue as deriveBuildkiteCommitContextForTesting,me as fetchGithubHeadRefForTesting,de as loadBuildkiteTriggerForTesting,ce as loadGithubTriggerForTesting,le as loadGitlabTriggerForTesting,he as runHealAcceptForTesting,fe as summariseDetailForTesting};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var U=Object.defineProperty;var I=(t,e)=>U(t,"name",{value:e,configurable:!0});import{createRequire as A}from"node:module";import{j as O,E as v,
|
|
1
|
+
var U=Object.defineProperty;var I=(t,e)=>U(t,"name",{value:e,configurable:!0});import{createRequire as A}from"node:module";import{j as O,E as v,T as G,I as j,e as F}from"../packem_shared/index.server-B7ETiT4C.js";import{z as D}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{readLastRunSummary as K}from"@visulima/task-runner";import{r as H,a as M,b as V,c as z}from"../packem_shared/ai-fix-DiGSrGKv.js";import{r as q,p as u}from"./bin.js";const L=A(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=I(t=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[e,o]=b.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return b.getBuiltinModule(t)}return L(t)},"__cjs_getBuiltinModule"),{spawn:k}=T("node:child_process"),{readFile:J}=T("node:fs/promises");var Q=Object.defineProperty,g=I((t,e)=>Q(t,"name",{value:e,configurable:!0}),"i");const W=g(t=>{if(!t)return;const e=/^refs\/pull\/(\d+)\//.exec(t);return e?Number.parseInt(e[1],10):void 0},"parsePrNumberFromGithubRef"),Y=g(async t=>{if(!t)return{prNumber:void 0,sha:void 0};try{const e=await J(t,"utf8"),o=JSON.parse(e),r=o.pull_request?.number??o.issue?.number??o.number,i=o.pull_request?.head?.sha;return{prNumber:r,sha:i}}catch{return{prNumber:void 0,sha:void 0}}},"readPrNumberFromGithubEvent"),Z=g(async t=>{const e=W(t.GITHUB_REF),{prNumber:o,sha:r}=e===void 0?await Y(t.GITHUB_EVENT_PATH):{prNumber:e,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:e??o,provider:"github-actions",repo:t.GITHUB_REPOSITORY,sha:r??t.GITHUB_SHA,token:t.GITHUB_TOKEN}},"detectGithubActions"),X=g(t=>{const e=t.CI_MERGE_REQUEST_IID,o=e!==void 0&&e!==""?Number.parseInt(e,10):void 0,r=t.CI_API_V4_URL,i=t.GITLAB_TOKEN??t.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:t.CI_PROJECT_ID??t.CI_PROJECT_PATH,sha:t.CI_COMMIT_SHA,token:i}},"detectGitlabCi"),ee=g(t=>{const e=t.BUILDKITE_PULL_REQUEST,o=e!==void 0&&e!==""&&e!=="false"?Number.parseInt(e,10):void 0,r=t.BUILDKITE_BUILD_NUMBER,i=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=t.BUILDKITE_ORGANIZATION_SLUG,a=t.BUILDKITE_PIPELINE_SLUG,s=n!==void 0&&n!==""&&a!==void 0&&a!==""?`${n}/${a}`:void 0;return{apiBaseUrl:(t.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:t.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(i)?i:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:s,sha:t.BUILDKITE_COMMIT,token:t.BUILDKITE_API_TOKEN}},"detectBuildkite"),te=g(async(t=process.env)=>t.GITHUB_ACTIONS==="true"?await Z(t):t.GITLAB_CI==="true"?X(t):t.BUILDKITE==="true"?ee(t):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},"detectCiContext");var oe=Object.defineProperty,h=I((t,e)=>oe(t,"name",{value:e,configurable:!0}),"p");const re=h((t,e,o,r)=>new Promise(i=>{const n=["pr","comment",String(e),"--body-file","-"];r&&n.push("--repo",r);const a=k(t,n,{stdio:["pipe","ignore","pipe"]});let s="";a.stderr?.setEncoding("utf8"),a.stderr?.on("data",d=>{s+=d}),a.once("error",()=>{i({exitCode:127,stderr:s})}),a.once("close",d=>{i({exitCode:d??-1,stderr:s})}),a.stdin?.on("error",()=>{}),a.stdin?.end(o)}),"runGhComment"),ie=h(async(t,e,o,r,i)=>{const n=`https://api.github.com/repos/${e}/issues/${String(o)}/comments`;try{const a=await t(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!a.ok){const s=await a.text().catch(()=>"");return{error:`GitHub REST returned ${String(a.status)}: ${s.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(a){return{error:a instanceof Error?a.message:String(a),ok:!1}}},"postViaGithubRest"),ne=h(async(t,e,o,r,i,n)=>{const a=encodeURIComponent(o),s=`${e.replace(/\/+$/,"")}/projects/${a}/merge_requests/${String(r)}/notes`;try{const d=await t(s,{body:JSON.stringify({body:i}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const p=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${p.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},"postViaGitlabRest"),ae=h((t,e,o,r)=>new Promise(i=>{const n=k(t,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";n.stderr?.setEncoding("utf8"),n.stderr?.on("data",s=>{a+=s}),n.once("error",()=>{i({exitCode:127,stderr:a})}),n.once("close",s=>{i({exitCode:s??-1,stderr:a})}),n.stdin?.on("error",()=>{}),n.stdin?.end(e)}),"runBuildkiteAnnotate"),se=h(async(t,e,o,r,i,n,a,s)=>{const[d,p]=o.split("/",2);if(!d||!p)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const m=`${e}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(p)}/builds/${String(r)}/annotations`;try{const c=await t(m,{body:JSON.stringify({body:i,context:a,style:n}),headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},method:"POST"});if(!c.ok){const l=await c.text().catch(()=>"");return{error:`Buildkite REST returned ${String(c.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(c){return{error:c instanceof Error?c.message:String(c),ok:!1}}},"postViaBuildkiteRest"),de=h(async(t,e,o,r)=>{const i=e.buildId?`vis-ai-heal-${e.buildId}`:"vis-ai-heal",n="info",a=await ae(o,t,n,i);if(a.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!e.apiBaseUrl||!e.repo||e.buildNumber===void 0||!e.token){const d=[];return e.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),e.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),e.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(a.exitCode)} (${a.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const s=await se(r,e.apiBaseUrl,e.repo,e.buildNumber,t,n,i,e.token);return s.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(a.exitCode)}; REST fallback also failed: ${s.error??"unknown"}`,method:"rest",posted:!1}},"postBuildkiteAnnotation"),pe=h(async(t,e,o,r)=>{if(e.prNumber===void 0)return{method:"skipped",posted:!1};const i=await re(o,e.prNumber,t,e.repo);if(i.exitCode===0)return{method:"gh-cli",posted:!0};if(!e.repo||!e.token)return{error:`gh exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await ie(r,e.repo,e.prNumber,t,e.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(i.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},"postGithubComment"),ce=h(async(t,e,o)=>{if(e.prNumber===void 0)return{method:"skipped",posted:!1};if(!e.apiBaseUrl||!e.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!e.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await ne(o,e.apiBaseUrl,e.repo,e.prNumber,t,e.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},"postGitlabComment"),ue=h(async t=>{const{body:e,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:i=globalThis.fetch,ghBin:n="gh"}=t;return r.provider==="github-actions"?await pe(e,r,n,i):r.provider==="gitlab-ci"?await ce(e,r,i):r.provider==="buildkite"?await de(e,r,o,i):{method:"skipped",posted:!1}},"postPrComment");var le=Object.defineProperty,f=I((t,e)=>le(t,"name",{value:e,configurable:!0}),"l");const C=f(t=>{let e=0,o=0;for(const r of t)r.status==="applied"?e+=1:o+=1;return{applied:e,failed:o}},"summarizeApply"),_=f((t,e,o)=>{const r=H(t,e,o),i=D(t,r);return i===""||i.startsWith("..")?r:i},"formatDisplayPath"),fe=f((t,e,o,r)=>new Promise(i=>{const n=process.argv[1];if(!n){i({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const a=[n,"run",o,"--projects",e,"--no-cache","--summarize","--fail-fast"],s=k(process.execPath,a,{cwd:t,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",p="";const m=setTimeout(()=>{s.kill("SIGTERM"),setTimeout(()=>s.kill("SIGKILL"),2e3).unref()},r);s.stdout?.setEncoding("utf8"),s.stdout?.on("data",c=>{d+=c}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",c=>{p+=c}),s.once("error",c=>{clearTimeout(m),i({exitCode:-1,stderr:c.message,stdout:d})}),s.once("close",c=>{clearTimeout(m),i({exitCode:c??-1,stderr:p,stdout:d})})}),"validateFixByRerun"),me=6e4,y=f(t=>{let e=0;const o=t.match(/`{3,}/g);if(o)for(const r of o)e=Math.max(e,r.length);return"`".repeat(Math.max(3,e+1))},"pickFence"),$=f((t,e,o)=>{if(t.patches.length===0)return"_No patches proposed._";const r=[];for(const[i,n]of t.patches.entries()){const a=_(e,o,n.file),s=[`**[${String(i+1)}] \`${a}\`**`];n.reason&&s.push(`_${n.reason}_`);const d=y(`${n.oldString}
|
|
2
2
|
${n.newString}`);s.push(`${d}diff`);for(const p of n.oldString.split(`
|
|
3
3
|
`))s.push(`- ${p}`);for(const p of n.newString.split(`
|
|
4
4
|
`))s.push(`+ ${p}`);s.push(d),r.push(s.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var mr=Object.defineProperty;var O=(e,t)=>mr(e,"name",{value:t,configurable:!0});import{createRequire as pr}from"node:module";import{bj as ve,bk as Ee,bl as Wt,bm as br,j as wr,bn as yr,I as G,bo as R,q as fe,e as Ke}from"./bin.js";const gr=pr(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,it=O(e=>{if(typeof ue<"u"&&ue.versions&&ue.versions.node){const[t,i]=ue.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return ue.getBuiltinModule(e)}return gr(e)},"__cjs_getBuiltinModule"),{createRequire:Si}=it("node:module"),X=ue,{execFileSync:vr}=it("node:child_process"),Oe=it("node:fs"),$r=it("node:tty");var xr=Object.defineProperty,Lt=O((e,t)=>xr(e,"name",{value:t,configurable:!0}),"u$5"),Wr=Object.defineProperty,rt=Lt((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"l");const Or=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Br=12288,Sr=65510,Ar=[12288,12288,65281,65376,65504,65510],jr=8361,Ir=65518,Cr=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Nr=32,Er=10630,kr=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Pr=4352,Rr=262141,Ai=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Mr=Object.defineProperty,Tr=rt((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"r$1");const Ae=Tr((e,t)=>{let i=0,r=Math.floor(e.length/2)-1;for(;i<=r;){const s=Math.floor((i+r)/2),o=s*2;if(t<e[o])r=s-1;else if(t>e[o+1])i=s+1;else return!0}return!1},"isInRange");var Fr=Object.defineProperty,re=rt((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"r");const Kt=19968,[Lr,_r]=nt(Ai);function nt(e){let t=e[0],i=e[1];for(let r=0;r<e.length;r+=2){const s=e[r],o=e[r+1];if(Kt>=s&&Kt<=o)return[s,o];o-s>i-t&&(t=s,i=o)}return[t,i]}O(nt,"c$1");Lt(nt,"f");rt(nt,"k");re(nt,"findWideFastPathRange");const ji=re(e=>e<161||e>1114109?!1:Ae(Or,e),"isAmbiguous"),Ii=re(e=>e<Br||e>Sr?!1:Ae(Ar,e),"isFullWidth"),Hr=re(e=>e<jr||e>Ir?!1:Ae(Cr,e),"isHalfWidth"),Gr=re(e=>e<Nr||e>Er?!1:Ae(kr,e),"isNarrow"),Ci=re(e=>e>=Lr&&e<=_r?!0:e<Pr||e>Rr?!1:Ae(Ai,e),"isWide");function ot(e){return ji(e)?"ambiguous":Ii(e)?"fullwidth":Hr(e)?"halfwidth":Gr(e)?"narrow":Ci(e)?"wide":"neutral"}O(ot,"g$5");Lt(ot,"S");rt(ot,"getCategory");re(ot,"getCategory");var Vr=Object.defineProperty,st=O((e,t)=>Vr(e,"name",{value:t,configurable:!0}),"i$3"),Jr=Object.defineProperty,at=st((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"a"),zr=Object.defineProperty,_t=at((e,t)=>zr(e,"name",{value:t,configurable:!0}),"e");function je(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}O(je,"s$3");st(je,"s");at(je,"r");_t(je,"validate");function Ie(e){return je(e),ot(e)}O(Ie,"r$2");st(Ie,"p");at(Ie,"eastAsianWidthType");_t(Ie,"eastAsianWidthType");function Ht(e,{ambiguousAsWide:t=!1}={}){return je(e),Ii(e)||Ci(e)||t&&ji(e)?2:1}O(Ht,"o$3");st(Ht,"W");at(Ht,"eastAsianWidth");_t(Ht,"eastAsianWidth");var qr=Object.defineProperty,Ur=O((e,t)=>qr(e,"name",{value:t,configurable:!0}),"E$3"),Dr=Object.defineProperty,Yr=Ur((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"A"),Kr=Object.defineProperty,lt=Yr((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"d");const Zt=new Map,ke=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Ge=lt(e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other","getCharType"),Zr=lt((e,t)=>{const i=Math.floor(e/65536),r=e%65536;let s=Zt.get(i);if(s||(s=new Map,Zt.set(i,s)),s.has(r))return s.get(r);let o;if(Ge(e)==="latin")o=t.width.regular;else if(Ge(e)==="control")o=t.width.control;else if(Ge(e)==="wide")o=t.width.wide;else switch(Ie(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}return s.set(r,o),o},"getCachedCharWidth"),Qr=lt(e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,"isCombiningCharacter"),At=lt((e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const i={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?At(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},r=Math.max(0,i.truncation.limit-i.truncation.ellipsisWidth),{length:s}=e,o=s>1e4;let n=0,a=0,l=s,h=!1;const c=e.includes("\x1B")||e.includes("");for(;n<s;){if(c&&(e[n]==="\x1B"||e[n]==="")){if(e.startsWith("\x1B]8;;",n)){const m="\x1B]8;;\x07",d=m.length,$=e.indexOf("\x07",n+5);if($!==-1){const w=e.indexOf(m,$+1);if(w!==-1){const v=w+d,x=e.slice($+1,w).replace(ve,""),W=At(x,{ambiguousIsNarrow:i.width.ambiguousIsNarrow,ansiWidth:i.width.ansi,controlWidth:i.width.control,countAnsiEscapeCodes:!1,ellipsis:i.truncation.ellipsis,ellipsisWidth:i.truncation.ellipsisWidth,emojiWidth:i.width.emoji,fullWidth:i.width.fullWidth,halfWidth:i.width.halfWidth,limit:Math.max(0,r-a),regularWidth:i.width.regular,tabWidth:i.width.tab,wideWidth:i.width.wide}),B=W.width;if(W.truncated)h=!0,l=Math.min(l,n);else if(a+B>r&&(l=Math.min(l,n),h=!0,a+B>i.truncation.limit))break;if(a+=B,n=v,h&&a>=i.truncation.limit)break;continue}}}if(ve.lastIndex=n,ve.test(e)){const m=ve.lastIndex-n,d=i.truncation.countAnsiEscapeCodes?m:i.width.ansi;if(a+d>r&&(l=Math.min(l,n),a+d>i.truncation.limit)){h=!0;break}a+=d,n=ve.lastIndex;continue}}const b=e.codePointAt(n);if(b===8203||b===65279||b>=8288&&b<=8292){n+=1;continue}if(b===9){if(a+i.width.tab>r&&(l=Math.min(l,n),a+i.width.tab>i.truncation.limit)){h=!0;break}a+=i.width.tab,n+=1;continue}if(ke.lastIndex=n,ke.test(e)){const m=(ke.lastIndex-n)*i.width.regular;if(a+m>r){const d=Math.floor((r-a)/i.width.regular);if(l=Math.min(l,n+d),a+m>i.truncation.limit){h=!0;break}}a+=m,n=ke.lastIndex;continue}if((b<=31||b>=127&&b<=159)&&(Ee.lastIndex=n,Ee.test(e))){const m=(Ee.lastIndex-n)*i.width.control;if(a+m>r&&(l=Math.min(l,n+Math.floor((r-a)/i.width.control)),a+m>i.truncation.limit)){h=!0;break}a+=m,n=Ee.lastIndex;continue}if(Wt.lastIndex=n,Wt.test(e)){if(a+i.width.emoji>r&&(l=Math.min(l,n),a+i.width.emoji>i.truncation.limit)){h=!0;break}a+=i.width.emoji,n=Wt.lastIndex;continue}const f=e.codePointAt(n)??0;if(Qr(f)){n+=f>65535?2:1;continue}let p;if(o)p=Zr(f,i);else switch(Ge(f)){case"control":{p=i.width.control;break}case"latin":{p=i.width.regular;break}case"wide":{p=i.width.wide;break}case"zero":{p=0;break}default:switch(Ie(f)){case"ambiguous":{p=i.width.ambiguousIsNarrow?i.width.regular:i.width.wide;break}case"fullwidth":{p=i.width.fullWidth;break}case"wide":{p=i.width.wide;break}default:p=i.width.regular}}if(a+p>r&&(l=Math.min(l,n),a+p>i.truncation.limit)){h=!0;break}a+=p,n+=f>65535?2:1}let u=a,g=!1;return h&&i.truncation.limit>=i.truncation.ellipsisWidth&&(u=i.truncation.limit,g=!0),{ellipsed:g,index:h?l:s,truncated:h,width:u}},"getStringTruncatedWidth");var Xr=Object.defineProperty,en=O((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"i$2"),tn=Object.defineProperty,rn=en((e,t)=>tn(e,"name",{value:t,configurable:!0}),"e"),nn=Object.defineProperty,on=rn((e,t)=>nn(e,"name",{value:t,configurable:!0}),"r");const sn=on((e,t={})=>At(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");var an=Object.defineProperty,V=O((e,t)=>an(e,"name",{value:t,configurable:!0}),"j$2"),ln=Object.defineProperty,A=V((e,t)=>ln(e,"name",{value:t,configurable:!0}),"$");const cn=Si(import.meta.url),de=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Gt=A(e=>{if(typeof de<"u"&&de.versions&&de.versions.node){const[t,i]=de.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return de.getBuiltinModule(e)}return cn(e)},"__cjs_getBuiltinModule"),ee=de,{execFileSync:hn}=Gt("node:child_process"),Be=Gt("node:fs"),un=Gt("node:tty");var dn=Object.defineProperty,Vt=A((e,t)=>dn(e,"name",{value:t,configurable:!0}),"u$5"),fn=Object.defineProperty,ct=Vt((e,t)=>fn(e,"name",{value:t,configurable:!0}),"l");const mn=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],pn=12288,gn=65510,bn=[12288,12288,65281,65376,65504,65510],wn=8361,yn=65518,vn=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],$n=32,xn=10630,Wn=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],On=4352,Bn=262141,Ni=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Sn=Object.defineProperty,An=ct((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"r$1");const Ce=An((e,t)=>{let i=0,r=Math.floor(e.length/2)-1;for(;i<=r;){const s=Math.floor((i+r)/2),o=s*2;if(t<e[o])r=s-1;else if(t>e[o+1])i=s+1;else return!0}return!1},"isInRange");var jn=Object.defineProperty,ne=ct((e,t)=>jn(e,"name",{value:t,configurable:!0}),"r");const Qt=19968,[In,Cn]=pe(Ni);function pe(e){let t=e[0],i=e[1];for(let r=0;r<e.length;r+=2){const s=e[r],o=e[r+1];if(Qt>=s&&Qt<=o)return[s,o];o-s>i-t&&(t=s,i=o)}return[t,i]}O(pe,"nt");V(pe,"ge");A(pe,"c$2");Vt(pe,"f");ct(pe,"k");ne(pe,"findWideFastPathRange");const Ei=ne(e=>e<161||e>1114109?!1:Ce(mn,e),"isAmbiguous"),ki=ne(e=>e<pn||e>gn?!1:Ce(bn,e),"isFullWidth"),Nn=ne(e=>e<wn||e>yn?!1:Ce(vn,e),"isHalfWidth"),En=ne(e=>e<$n||e>xn?!1:Ce(Wn,e),"isNarrow"),Pi=ne(e=>e>=In&&e<=Cn?!0:e<On||e>Bn?!1:Ce(Ni,e),"isWide");function ge(e){return Ei(e)?"ambiguous":ki(e)?"fullwidth":Nn(e)?"halfwidth":En(e)?"narrow":Pi(e)?"wide":"neutral"}O(ge,"rt");V(ge,"be");A(ge,"g$4");Vt(ge,"S");ct(ge,"getCategory");ne(ge,"getCategory");var kn=Object.defineProperty,ht=A((e,t)=>kn(e,"name",{value:t,configurable:!0}),"i$4"),Pn=Object.defineProperty,ut=ht((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"a"),Rn=Object.defineProperty,Jt=ut((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"e");function oe(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}O(oe,"U$3");V(oe,"ee");A(oe,"s$1");ht(oe,"s");ut(oe,"r");Jt(oe,"validate");function se(e){return oe(e),ge(e)}O(se,"Z$1");V(se,"te");A(se,"r$3");ht(se,"p");ut(se,"eastAsianWidthType");Jt(se,"eastAsianWidthType");function Ne(e,{ambiguousAsWide:t=!1}={}){return oe(e),ki(e)||Pi(e)||t&&Ei(e)?2:1}O(Ne,"yt");V(Ne,"je");A(Ne,"o$2");ht(Ne,"W");ut(Ne,"eastAsianWidth");Jt(Ne,"eastAsianWidth");var Mn=Object.defineProperty,Tn=A((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"p$3"),Fn=Object.defineProperty,Ri=Tn((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"e"),Ln=Object.defineProperty,_n=Ri((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"E");const Mi=String.raw,Xt=Mi`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Hn=_n(()=>new RegExp(Mi`\p{RI}{2}|(?)${Xt}(?:\u200D${Xt})*`,"gu"),"default");var Gn=Object.defineProperty,Vn=Ri((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"p");const be=new Set(["\x1B",""]),dt="\x07",Ti="[",zt="m",Ze="]8;;",Jn=39,zn=/[\u200B\uFEFF\u2060-\u2064]/g,qn=new RegExp(`(?:\\${Ti}(?<code>\\d+)m|\\${Ze}(?<uri>.*)${dt})`),Un=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]])),Q=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,ei=/\u001B\[(\d+(?:;\d+)*)?m[^\u001B]*(?:\u001B\[(?:\d+(?:;\d+)*)?m|$)/g,ti=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)(.*?)\u001B\]8;;(?:\u0007|\u001B\\)/g,Pe=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,Ve=Hn();Vn(e=>e.replace(Ve,""),"stripEmoji");var Dn=Object.defineProperty,Yn=A((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"E$1"),Kn=Object.defineProperty,Zn=Yn((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"A"),Qn=Object.defineProperty,ft=Zn((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"d");const ii=new Map,Re=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Je=ft(e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other","getCharType"),Xn=ft((e,t)=>{const i=Math.floor(e/65536),r=e%65536;let s=ii.get(i);if(s||(s=new Map,ii.set(i,s)),s.has(r))return s.get(r);let o;if(Je(e)==="latin")o=t.width.regular;else if(Je(e)==="control")o=t.width.control;else if(Je(e)==="wide")o=t.width.wide;else switch(se(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}return s.set(r,o),o},"getCachedCharWidth"),eo=ft(e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,"isCombiningCharacter"),me=ft((e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const i={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?me(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},r=Math.max(0,i.truncation.limit-i.truncation.ellipsisWidth),{length:s}=e,o=s>1e4;let n=0,a=0,l=s,h=!1;const c=e.includes("\x1B")||e.includes("");for(;n<s;){if(c&&(e[n]==="\x1B"||e[n]==="")){if(e.startsWith("\x1B]8;;",n)){const m="\x1B]8;;\x07",d=m.length,$=e.indexOf("\x07",n+5);if($!==-1){const w=e.indexOf(m,$+1);if(w!==-1){const v=w+d,x=e.slice($+1,w).replace(Q,""),W=me(x,{ambiguousIsNarrow:i.width.ambiguousIsNarrow,ansiWidth:i.width.ansi,controlWidth:i.width.control,countAnsiEscapeCodes:!1,ellipsis:i.truncation.ellipsis,ellipsisWidth:i.truncation.ellipsisWidth,emojiWidth:i.width.emoji,fullWidth:i.width.fullWidth,halfWidth:i.width.halfWidth,limit:Math.max(0,r-a),regularWidth:i.width.regular,tabWidth:i.width.tab,wideWidth:i.width.wide}),B=W.width;if(W.truncated)h=!0,l=Math.min(l,n);else if(a+B>r&&(l=Math.min(l,n),h=!0,a+B>i.truncation.limit))break;if(a+=B,n=v,h&&a>=i.truncation.limit)break;continue}}}if(Q.lastIndex=n,Q.test(e)){const m=Q.lastIndex-n,d=i.truncation.countAnsiEscapeCodes?m:i.width.ansi;if(a+d>r&&(l=Math.min(l,n),a+d>i.truncation.limit)){h=!0;break}a+=d,n=Q.lastIndex;continue}}const b=e.codePointAt(n);if(b===8203||b===65279||b>=8288&&b<=8292){n+=1;continue}if(b===9){if(a+i.width.tab>r&&(l=Math.min(l,n),a+i.width.tab>i.truncation.limit)){h=!0;break}a+=i.width.tab,n+=1;continue}if(Re.lastIndex=n,Re.test(e)){const m=(Re.lastIndex-n)*i.width.regular;if(a+m>r){const d=Math.floor((r-a)/i.width.regular);if(l=Math.min(l,n+d),a+m>i.truncation.limit){h=!0;break}}a+=m,n=Re.lastIndex;continue}if((b<=31||b>=127&&b<=159)&&(Pe.lastIndex=n,Pe.test(e))){const m=(Pe.lastIndex-n)*i.width.control;if(a+m>r&&(l=Math.min(l,n+Math.floor((r-a)/i.width.control)),a+m>i.truncation.limit)){h=!0;break}a+=m,n=Pe.lastIndex;continue}if(Ve.lastIndex=n,Ve.test(e)){if(a+i.width.emoji>r&&(l=Math.min(l,n),a+i.width.emoji>i.truncation.limit)){h=!0;break}a+=i.width.emoji,n=Ve.lastIndex;continue}const f=e.codePointAt(n)??0;if(eo(f)){n+=f>65535?2:1;continue}let p;if(o)p=Xn(f,i);else switch(Je(f)){case"control":{p=i.width.control;break}case"latin":{p=i.width.regular;break}case"wide":{p=i.width.wide;break}case"zero":{p=0;break}default:switch(se(f)){case"ambiguous":{p=i.width.ambiguousIsNarrow?i.width.regular:i.width.wide;break}case"fullwidth":{p=i.width.fullWidth;break}case"wide":{p=i.width.wide;break}default:p=i.width.regular}}if(a+p>r&&(l=Math.min(l,n),a+p>i.truncation.limit)){h=!0;break}a+=p,n+=f>65535?2:1}let u=a,g=!1;return h&&i.truncation.limit>=i.truncation.ellipsisWidth&&(u=i.truncation.limit,g=!0),{ellipsed:g,index:h?l:s,truncated:h,width:u}},"getStringTruncatedWidth");var to=Object.defineProperty,io=A((e,t)=>to(e,"name",{value:t,configurable:!0}),"i$2"),ro=Object.defineProperty,no=io((e,t)=>ro(e,"name",{value:t,configurable:!0}),"e"),oo=Object.defineProperty,so=no((e,t)=>oo(e,"name",{value:t,configurable:!0}),"r");const E=so((e,t={})=>me(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");var ao=Object.defineProperty,Fi=A((e,t)=>ao(e,"name",{value:t,configurable:!0}),"i$1"),lo=Object.defineProperty,Li=Fi((e,t)=>lo(e,"name",{value:t,configurable:!0}),"r"),co=Object.defineProperty,ho=Li((e,t)=>co(e,"name",{value:t,configurable:!0}),"c");let uo=class{static{O(this,"ki")}static{V(this,"Si")}static{A(this,"l")}static{Fi(this,"y")}static{Li(this,"s")}static{ho(this,"LRUCache")}capacity;cache;keyOrder;constructor(e){this.capacity=e,this.cache=new Map,this.keyOrder=[]}get(e){if(this.cache.has(e))return this.keyOrder=this.keyOrder.filter(t=>t!==e),this.keyOrder.push(e),this.cache.get(e)}has(e){return this.cache.has(e)}set(e,t){if(this.cache.has(e))this.keyOrder=this.keyOrder.filter(i=>i!==e);else if(this.cache.size>=this.capacity){const i=this.keyOrder.shift();i!==void 0&&this.cache.delete(i)}this.cache.set(e,t),this.keyOrder.push(e)}delete(e){this.cache.delete(e),this.keyOrder=this.keyOrder.filter(t=>t!==e)}clear(){this.cache.clear(),this.keyOrder=[]}size(){return this.cache.size}};var fo=Object.defineProperty,mo=A((e,t)=>fo(e,"name",{value:t,configurable:!0}),"S$1"),po=Object.defineProperty,go=mo((e,t)=>po(e,"name",{value:t,configurable:!0}),"w"),bo=Object.defineProperty,we=go((e,t)=>bo(e,"name",{value:t,configurable:!0}),"y");const ri=new uo(100),wo=new Intl.Segmenter("en",{granularity:"grapheme"}),yo=/^[\u0000-\u007F]*$/,vo=new Set(["0","22","23","24","27","28","29","39","49"]),$o=new Set(["1","3","4","7","8","9"]),ni=new Map([["22","1"],["23","3"],["24","4"],["27","7"],["28","8"],["29","9"]]),Me=we(e=>e>="30"&&e<="37"||e>="90"&&e<="97"||e.startsWith("38;"),"isForegroundColor"),Te=we(e=>e>="40"&&e<="47"||e>="100"&&e<="107"||e.startsWith("48;"),"isBackgroundColor"),xo=[{close:"\x1B[22m",open:"\x1B[1m"},{close:"\x1B[23m",open:"\x1B[3m"},{close:"\x1B[24m",open:"\x1B[4m"},{close:"\x1B[27m",open:"\x1B[7m"},{close:"\x1B[28m",open:"\x1B[8m"},{close:"\x1B[29m",open:"\x1B[9m"}],oi=we((e,t)=>{let i=-1;for(const r of t){const s=e.indexOf(r);s!==-1&&(i===-1||s<i)&&(i=s)}return i},"findFirstPositionOfAny"),Wo=we((e,t)=>{if(!e.includes("\x1B"))return[{after:"",before:"",content:e,visibleLength:E(e,t.width)}];const i=ri.get(e);if(i)return i;const r=[],s=[];let o=0,n;for(Q.lastIndex=0;(n=Q.exec(e))!==null;){const c=n[0];r.push(e.slice(o,n.index)),s.push(c),o=n.index+c.length}o<e.length&&r.push(e.slice(o));const a=[];for(const c of s){if(c==="\x1B[0m"||c==="\x1B]8;;\x07"){a.push(c);continue}if(c.startsWith("\x1B[")&&c.endsWith("m")){const u=c.slice(2,-1);if(vo.has(u)){a.push(c);continue}}}const l=new Set,h=[];for(const[c,u]of r.entries()){if(c>0&&s[c-1]){const f=s[c-1];if(f==="\x1B[0m")l.clear();else if(f==="\x1B]8;;\x07"){for(const p of l)if(p.startsWith("\x1B]8;;")&&!p.endsWith("\x1B]8;;\x07")){l.delete(p);break}}else if(f.startsWith("\x1B[")&&f.endsWith("m")){const p=f.slice(2,-1);if(p==="39"){for(const m of l)if(m.startsWith("\x1B[")&&m.endsWith("m")){const d=m.slice(2,-1);if(Me(d)){l.delete(m);break}}}else if(p==="49"){for(const m of l)if(m.startsWith("\x1B[")&&m.endsWith("m")){const d=m.slice(2,-1);if(Te(d)){l.delete(m);break}}}else if(ni.has(p)){const m=ni.get(p);for(const d of l)if(d===`\x1B[${m}m`){l.delete(d);break}}else{if(Me(p)){for(const m of l)if(m.startsWith("\x1B[")&&m.endsWith("m")){const d=m.slice(2,-1);if(Me(d)){l.delete(m);break}}}else if(Te(p)){for(const m of l)if(m.startsWith("\x1B[")&&m.endsWith("m")){const d=m.slice(2,-1);if(Te(d)){l.delete(m);break}}}else if($o.has(p)){const m=`\x1B[${p}m`;l.has(m)&&l.delete(m)}l.add(f)}}else if(f.startsWith("\x1B]8;;")&&!f.endsWith("\x1B]8;;\x07")){for(const p of l)if(p.startsWith("\x1B]8;;")&&!p.endsWith("\x1B]8;;\x07")){l.delete(p);break}l.add(f)}}if(u==="")continue;let g="";if(l.size>0)if(a.includes("\x1B[0m"))g="\x1B[0m";else{const f=[];let p=!1;for(const w of l)if(w.startsWith("\x1B]8;;")&&!w.endsWith("\x1B]8;;\x07")){p=!0;break}p&&a.includes("\x1B]8;;\x07")&&f.push("\x1B]8;;\x07");let m=!1,d=!1;for(const w of l)if(w.startsWith("\x1B[")&&w.endsWith("m")){const v=w.slice(2,-1);Me(v)?m=!0:Te(v)&&(d=!0)}if(m&&d){const w=oi(e,["\x1B[3","\x1B[9","\x1B[38;"]),v=oi(e,["\x1B[4","\x1B[10","\x1B[48;"]);w>=0&&v>=0?w>v?f.push("\x1B[39m","\x1B[49m"):f.push("\x1B[49m","\x1B[39m"):f.push("\x1B[39m","\x1B[49m")}else m&&f.push("\x1B[39m"),d&&f.push("\x1B[49m");m&&d&&e.includes("\x1B[39m")&&e.includes("\x1B[49m")&&(e.indexOf("\x1B[39m")<e.indexOf("\x1B[49m")?(f.length-=2,f.push("\x1B[39m","\x1B[49m")):e.indexOf("\x1B[49m")<e.indexOf("\x1B[39m")&&(f.length-=2,f.push("\x1B[49m","\x1B[39m")));const $=xo.filter(w=>l.has(w.open)).map(w=>({position:e.indexOf(w.open),style:w})).filter(w=>w.position>=0).toSorted((w,v)=>v.position-w.position);for(const w of $){const v=w;a.includes(v.style.close)&&f.push(v.style.close)}g=f.join("")}const b=[...l].join("");h.push({after:g,before:b,content:u,visibleLength:E(u,{fullWidth:1,wideWidth:1})})}return ri.set(e,h),h},"processIntoStyledSegments"),Oo=we((e,t,i,r)=>{const s=[...r.segmenter.segment(e)],o=[];let n=0,a=!1;for(const l of s){const h=E(l.segment,r.width),c=n,u=n+h;if(!a)if(c<t){n=u;continue}else a=!0;if(c>=i||u>i)break;o.push(l.segment),n=u}return o.join("")},"fastSlice"),q=we((e,t=0,i=Number.MAX_SAFE_INTEGER,r={})=>{const s={segmenter:wo,...r};if(t>=i||e==="")return"";const o=E(e,s.width);if(t===0&&i>=o)return e;if(t<0||i<0)throw new RangeError("Negative indices aren't supported");if(!e.includes("\x1B"))return yo.test(e)?e.slice(t,i):Oo(e,t,i,s);if(ei.lastIndex=0,ti.lastIndex=0,!ei.test(e)&&!ti.test(e))return e;const n=Wo(e,s);if(n.length===0)return"";let a=0;const l=[];for(const[u,g]of n.entries()){const b=a,f=a+g.visibleLength;if(f>t&&b<i){const p=Math.max(0,t-b),m=Math.min(g.visibleLength,i-b);l.push({end:m,index:u,segment:g,start:p})}a=f}if(l.length===0)return"";const h=[],c=l[0].segment;h.push(c.before);for(let u=0;u<l.length;u++){const{end:g,segment:b,start:f}=l[u];if(f===0&&g===b.visibleLength)h.push(b.content);else{const p=[...s.segmenter.segment(b.content)];h.push(p.slice(f,g).map(m=>m.segment).join(""))}if(u<l.length-1){const p=l[u+1].segment,m=b.after,d=p.before;m!==d&&(m||d)&&h.push(m,d)}}return h.push(l.at(-1).segment.after),h.join("")},"slice");var Bo=Object.defineProperty,So=A((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"x"),Ao=Object.defineProperty,jo=So((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"T"),Io=Object.defineProperty,mt=jo((e,t)=>Io(e,"name",{value:t,configurable:!0}),"f");const si="…",Co=3,Fe=mt((e,t,i=!1)=>{if(e.charAt(t)===" ")return t;const r=i?1:-1,s=Math.min(Co,i?e.length-t:t);for(let o=1;o<=s;o++){const n=t+o*r;if(e.charAt(n)===" ")return n}return t},"findNearestSpace"),Le=mt((e,t,i)=>me(e,{...i,ellipsis:"",ellipsisWidth:0,limit:t}).index,"widthToIndex"),_e=mt((e,t,i)=>E(e.slice(0,t),i),"indexToWidth"),ai=mt((e,t,i={})=>{if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof t!="number")throw new TypeError(`Expected \`limit\` to be a number, got ${typeof t}`);if(e===""||t<=0)return"";const r=e.normalize("NFC"),{ellipsis:s=si,position:o="end",preferTruncationOnSpace:n=!1}=i;let a=i.ellipsisWidth??s===si?1:void 0;a??=me(s,{...i.width,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width;const{width:l}=me(r,{...i.width,ellipsis:s,ellipsisWidth:a});if(l<=t)return r;switch(o){case"end":{if(n){const h=t-a,c=Le(r,h,i.width),u=Fe(r,c),g=_e(r,u,i.width);return q(r,0,g,{width:i.width})+s}return q(r,0,t-a,{width:i.width})+s}case"middle":{const h=Math.floor(t/2),c=Math.max(0,t-a),u=Math.min(h,c),g=Math.max(0,c-u);if(n){const b=Le(r,u,i.width),f=Fe(r,b),p=_e(r,f,i.width),m=l-g,d=Le(r,m,i.width),$=Fe(r,d,!0),w=_e(r,$,i.width);return q(r,0,p,{width:i.width})+s+q(r,w,l,{width:i.width}).trim()}return q(r,0,u,{width:i.width})+s+q(r,l-g,l,{width:i.width})}case"start":{if(n){const h=l-t+a,c=Le(r,h,i.width),u=Fe(r,c,!0),g=_e(r,u,i.width);return s+q(r,g,l,{width:i.width}).trim()}return s+q(r,l-t+a,l,{width:i.width})}default:throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${o}'`)}},"truncate");var No=Object.defineProperty,_i=A((e,t)=>No(e,"name",{value:t,configurable:!0}),"b$2"),Eo=Object.defineProperty,ae=_i((e,t)=>Eo(e,"name",{value:t,configurable:!0}),"d"),ko=Object.defineProperty,Po=ae((e,t)=>ko(e,"name",{value:t,configurable:!0}),"a");const Ro=/\x1B\[(\d+)m/;class Hi{static{O(this,"he")}static{V(this,"at")}static{A(this,"T")}static{_i(this,"T")}static{ae(this,"d")}static{Po(this,"AnsiStateTracker")}activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const i=Ro.exec(t);if(!i)return;const r=Number.parseInt(i[1],10);switch(r){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(r>=30&&r<=37||r>=90&&r<=97)this.activeForeground=t;else if(r>=40&&r<=47||r>=100&&r<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(r))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(r)){const s={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[r];s&&(this.activeFormatting=this.activeFormatting.filter(o=>!o.includes(s)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const i={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(r=>{const s=i[r];s&&t.push(s)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}}var Mo=Object.defineProperty,Gi=ae((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"o");const Vi=Gi((e,t)=>{if(!be.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const i=!0,r=e.slice(t+1,t+1+Ze.length).join("")===Ze;return{isInsideEscape:i,isInsideLinkEscape:r}},"checkEscapeSequence"),To=Gi((e,t={})=>{const i=new Hi;let r="",s=!1,o="",n="",a=!1;const l=[...e];for(let h=0;h<l.length;h++){const c=l[h];if(c&&be.has(c)){if(r){const p=t.getWidth?.(r)??0,m={isEscapeSequence:!1,isGrapheme:!0,text:r,width:p};if(a&&(m.isHyperlink=!0,m.hyperlinkUrl=n),t.onSegment?.(m,i)===!1)return;r=""}s=!0,o=c;const b=Vi(l,h),{isInsideLinkEscape:f}=b;if(f){let p=h+1;for(n="";p<l.length;){const d=l[p];if(d===dt)break;n+=d,p+=1}n=n.slice(4);const m={hyperlinkUrl:n,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(m,i)===!1)return;h=p,a=!0,s=!1,o="";continue}if(h+1<l.length&&l[h+1]==="\\"&&a){const p={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(p,i)===!1)return;a=!1,n="",h+=1,s=!1,o="";continue}}if(s){if(o!==c&&(o+=c),c===zt){s=!1,i.processEscape(o);const b={isEscapeSequence:!0,isGrapheme:!1,text:o,width:0};if(t.onSegment?.(b,i)===!1)return;o=""}continue}r+=c;const u=t.getWidth?.(r)??0,g={isEscapeSequence:!1,isGrapheme:!0,text:r,width:u};if(a&&(g.isHyperlink=!0,g.hyperlinkUrl=n),t.onSegment?.(g,i)===!1)return;r=""}if(r){const h=t.getWidth?.(r)??0,c={isEscapeSequence:!1,isGrapheme:!0,text:r,width:h};a&&(c.isHyperlink=!0,c.hyperlinkUrl=n),t.onSegment?.(c,i)}if(o){const h={isEscapeSequence:!0,isGrapheme:!1,text:o,width:0};t.onSegment?.(h,i)}},"processAnsiString");var Fo=Object.defineProperty,Lo=ae((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"t$1");const li=Lo(e=>`${be.values().next().value}${Ti}${String(e)}${zt}`,"wrapAnsiCode");var _o=Object.defineProperty,Ho=ae((e,t)=>_o(e,"name",{value:t,configurable:!0}),"s");const ci=Ho(e=>`${be.values().next().value}${Ze}${e}${dt}`,"wrapAnsiHyperlink");var Go=Object.defineProperty,Vo=ae((e,t)=>Go(e,"name",{value:t,configurable:!0}),"l");const Jo=Vo(e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",i,r;const s=e.join(`
|
|
1
|
+
var mr=Object.defineProperty;var O=(e,t)=>mr(e,"name",{value:t,configurable:!0});import{createRequire as pr}from"node:module";import{B as br,j as wr,I as G,N as R,q as fe,e as Ke}from"../packem_shared/index.server-B7ETiT4C.js";import{h as ve,H as Ee,E as Wt,d as yr}from"../packem_shared/index-B8Ko8mwG.js";const gr=pr(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,it=O(e=>{if(typeof ue<"u"&&ue.versions&&ue.versions.node){const[t,i]=ue.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return ue.getBuiltinModule(e)}return gr(e)},"__cjs_getBuiltinModule"),{createRequire:Si}=it("node:module"),X=ue,{execFileSync:vr}=it("node:child_process"),Oe=it("node:fs"),$r=it("node:tty");var xr=Object.defineProperty,Lt=O((e,t)=>xr(e,"name",{value:t,configurable:!0}),"u$5"),Wr=Object.defineProperty,rt=Lt((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"l");const Or=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Br=12288,Sr=65510,Ar=[12288,12288,65281,65376,65504,65510],jr=8361,Ir=65518,Cr=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Nr=32,Er=10630,kr=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Pr=4352,Rr=262141,Ai=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Mr=Object.defineProperty,Tr=rt((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"r$1");const Ae=Tr((e,t)=>{let i=0,r=Math.floor(e.length/2)-1;for(;i<=r;){const s=Math.floor((i+r)/2),o=s*2;if(t<e[o])r=s-1;else if(t>e[o+1])i=s+1;else return!0}return!1},"isInRange");var Fr=Object.defineProperty,re=rt((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"r");const Kt=19968,[Lr,_r]=nt(Ai);function nt(e){let t=e[0],i=e[1];for(let r=0;r<e.length;r+=2){const s=e[r],o=e[r+1];if(Kt>=s&&Kt<=o)return[s,o];o-s>i-t&&(t=s,i=o)}return[t,i]}O(nt,"c$1");Lt(nt,"f");rt(nt,"k");re(nt,"findWideFastPathRange");const ji=re(e=>e<161||e>1114109?!1:Ae(Or,e),"isAmbiguous"),Ii=re(e=>e<Br||e>Sr?!1:Ae(Ar,e),"isFullWidth"),Hr=re(e=>e<jr||e>Ir?!1:Ae(Cr,e),"isHalfWidth"),Gr=re(e=>e<Nr||e>Er?!1:Ae(kr,e),"isNarrow"),Ci=re(e=>e>=Lr&&e<=_r?!0:e<Pr||e>Rr?!1:Ae(Ai,e),"isWide");function ot(e){return ji(e)?"ambiguous":Ii(e)?"fullwidth":Hr(e)?"halfwidth":Gr(e)?"narrow":Ci(e)?"wide":"neutral"}O(ot,"g$5");Lt(ot,"S");rt(ot,"getCategory");re(ot,"getCategory");var Vr=Object.defineProperty,st=O((e,t)=>Vr(e,"name",{value:t,configurable:!0}),"i$3"),Jr=Object.defineProperty,at=st((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"a"),zr=Object.defineProperty,_t=at((e,t)=>zr(e,"name",{value:t,configurable:!0}),"e");function je(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}O(je,"s$3");st(je,"s");at(je,"r");_t(je,"validate");function Ie(e){return je(e),ot(e)}O(Ie,"r$2");st(Ie,"p");at(Ie,"eastAsianWidthType");_t(Ie,"eastAsianWidthType");function Ht(e,{ambiguousAsWide:t=!1}={}){return je(e),Ii(e)||Ci(e)||t&&ji(e)?2:1}O(Ht,"o$3");st(Ht,"W");at(Ht,"eastAsianWidth");_t(Ht,"eastAsianWidth");var qr=Object.defineProperty,Ur=O((e,t)=>qr(e,"name",{value:t,configurable:!0}),"E$3"),Dr=Object.defineProperty,Yr=Ur((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"A"),Kr=Object.defineProperty,lt=Yr((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"d");const Zt=new Map,ke=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Ge=lt(e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other","getCharType"),Zr=lt((e,t)=>{const i=Math.floor(e/65536),r=e%65536;let s=Zt.get(i);if(s||(s=new Map,Zt.set(i,s)),s.has(r))return s.get(r);let o;if(Ge(e)==="latin")o=t.width.regular;else if(Ge(e)==="control")o=t.width.control;else if(Ge(e)==="wide")o=t.width.wide;else switch(Ie(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}return s.set(r,o),o},"getCachedCharWidth"),Qr=lt(e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,"isCombiningCharacter"),At=lt((e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const i={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?At(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},r=Math.max(0,i.truncation.limit-i.truncation.ellipsisWidth),{length:s}=e,o=s>1e4;let n=0,a=0,l=s,h=!1;const c=e.includes("\x1B")||e.includes("");for(;n<s;){if(c&&(e[n]==="\x1B"||e[n]==="")){if(e.startsWith("\x1B]8;;",n)){const m="\x1B]8;;\x07",d=m.length,$=e.indexOf("\x07",n+5);if($!==-1){const w=e.indexOf(m,$+1);if(w!==-1){const v=w+d,x=e.slice($+1,w).replace(ve,""),W=At(x,{ambiguousIsNarrow:i.width.ambiguousIsNarrow,ansiWidth:i.width.ansi,controlWidth:i.width.control,countAnsiEscapeCodes:!1,ellipsis:i.truncation.ellipsis,ellipsisWidth:i.truncation.ellipsisWidth,emojiWidth:i.width.emoji,fullWidth:i.width.fullWidth,halfWidth:i.width.halfWidth,limit:Math.max(0,r-a),regularWidth:i.width.regular,tabWidth:i.width.tab,wideWidth:i.width.wide}),B=W.width;if(W.truncated)h=!0,l=Math.min(l,n);else if(a+B>r&&(l=Math.min(l,n),h=!0,a+B>i.truncation.limit))break;if(a+=B,n=v,h&&a>=i.truncation.limit)break;continue}}}if(ve.lastIndex=n,ve.test(e)){const m=ve.lastIndex-n,d=i.truncation.countAnsiEscapeCodes?m:i.width.ansi;if(a+d>r&&(l=Math.min(l,n),a+d>i.truncation.limit)){h=!0;break}a+=d,n=ve.lastIndex;continue}}const b=e.codePointAt(n);if(b===8203||b===65279||b>=8288&&b<=8292){n+=1;continue}if(b===9){if(a+i.width.tab>r&&(l=Math.min(l,n),a+i.width.tab>i.truncation.limit)){h=!0;break}a+=i.width.tab,n+=1;continue}if(ke.lastIndex=n,ke.test(e)){const m=(ke.lastIndex-n)*i.width.regular;if(a+m>r){const d=Math.floor((r-a)/i.width.regular);if(l=Math.min(l,n+d),a+m>i.truncation.limit){h=!0;break}}a+=m,n=ke.lastIndex;continue}if((b<=31||b>=127&&b<=159)&&(Ee.lastIndex=n,Ee.test(e))){const m=(Ee.lastIndex-n)*i.width.control;if(a+m>r&&(l=Math.min(l,n+Math.floor((r-a)/i.width.control)),a+m>i.truncation.limit)){h=!0;break}a+=m,n=Ee.lastIndex;continue}if(Wt.lastIndex=n,Wt.test(e)){if(a+i.width.emoji>r&&(l=Math.min(l,n),a+i.width.emoji>i.truncation.limit)){h=!0;break}a+=i.width.emoji,n=Wt.lastIndex;continue}const f=e.codePointAt(n)??0;if(Qr(f)){n+=f>65535?2:1;continue}let p;if(o)p=Zr(f,i);else switch(Ge(f)){case"control":{p=i.width.control;break}case"latin":{p=i.width.regular;break}case"wide":{p=i.width.wide;break}case"zero":{p=0;break}default:switch(Ie(f)){case"ambiguous":{p=i.width.ambiguousIsNarrow?i.width.regular:i.width.wide;break}case"fullwidth":{p=i.width.fullWidth;break}case"wide":{p=i.width.wide;break}default:p=i.width.regular}}if(a+p>r&&(l=Math.min(l,n),a+p>i.truncation.limit)){h=!0;break}a+=p,n+=f>65535?2:1}let u=a,g=!1;return h&&i.truncation.limit>=i.truncation.ellipsisWidth&&(u=i.truncation.limit,g=!0),{ellipsed:g,index:h?l:s,truncated:h,width:u}},"getStringTruncatedWidth");var Xr=Object.defineProperty,en=O((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"i$2"),tn=Object.defineProperty,rn=en((e,t)=>tn(e,"name",{value:t,configurable:!0}),"e"),nn=Object.defineProperty,on=rn((e,t)=>nn(e,"name",{value:t,configurable:!0}),"r");const sn=on((e,t={})=>At(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");var an=Object.defineProperty,V=O((e,t)=>an(e,"name",{value:t,configurable:!0}),"j$2"),ln=Object.defineProperty,A=V((e,t)=>ln(e,"name",{value:t,configurable:!0}),"$");const cn=Si(import.meta.url),de=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Gt=A(e=>{if(typeof de<"u"&&de.versions&&de.versions.node){const[t,i]=de.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return de.getBuiltinModule(e)}return cn(e)},"__cjs_getBuiltinModule"),ee=de,{execFileSync:hn}=Gt("node:child_process"),Be=Gt("node:fs"),un=Gt("node:tty");var dn=Object.defineProperty,Vt=A((e,t)=>dn(e,"name",{value:t,configurable:!0}),"u$5"),fn=Object.defineProperty,ct=Vt((e,t)=>fn(e,"name",{value:t,configurable:!0}),"l");const mn=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],pn=12288,gn=65510,bn=[12288,12288,65281,65376,65504,65510],wn=8361,yn=65518,vn=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],$n=32,xn=10630,Wn=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],On=4352,Bn=262141,Ni=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Sn=Object.defineProperty,An=ct((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"r$1");const Ce=An((e,t)=>{let i=0,r=Math.floor(e.length/2)-1;for(;i<=r;){const s=Math.floor((i+r)/2),o=s*2;if(t<e[o])r=s-1;else if(t>e[o+1])i=s+1;else return!0}return!1},"isInRange");var jn=Object.defineProperty,ne=ct((e,t)=>jn(e,"name",{value:t,configurable:!0}),"r");const Qt=19968,[In,Cn]=pe(Ni);function pe(e){let t=e[0],i=e[1];for(let r=0;r<e.length;r+=2){const s=e[r],o=e[r+1];if(Qt>=s&&Qt<=o)return[s,o];o-s>i-t&&(t=s,i=o)}return[t,i]}O(pe,"nt");V(pe,"ge");A(pe,"c$2");Vt(pe,"f");ct(pe,"k");ne(pe,"findWideFastPathRange");const Ei=ne(e=>e<161||e>1114109?!1:Ce(mn,e),"isAmbiguous"),ki=ne(e=>e<pn||e>gn?!1:Ce(bn,e),"isFullWidth"),Nn=ne(e=>e<wn||e>yn?!1:Ce(vn,e),"isHalfWidth"),En=ne(e=>e<$n||e>xn?!1:Ce(Wn,e),"isNarrow"),Pi=ne(e=>e>=In&&e<=Cn?!0:e<On||e>Bn?!1:Ce(Ni,e),"isWide");function ge(e){return Ei(e)?"ambiguous":ki(e)?"fullwidth":Nn(e)?"halfwidth":En(e)?"narrow":Pi(e)?"wide":"neutral"}O(ge,"rt");V(ge,"be");A(ge,"g$4");Vt(ge,"S");ct(ge,"getCategory");ne(ge,"getCategory");var kn=Object.defineProperty,ht=A((e,t)=>kn(e,"name",{value:t,configurable:!0}),"i$4"),Pn=Object.defineProperty,ut=ht((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"a"),Rn=Object.defineProperty,Jt=ut((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"e");function oe(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}O(oe,"U$3");V(oe,"ee");A(oe,"s$1");ht(oe,"s");ut(oe,"r");Jt(oe,"validate");function se(e){return oe(e),ge(e)}O(se,"Z$1");V(se,"te");A(se,"r$3");ht(se,"p");ut(se,"eastAsianWidthType");Jt(se,"eastAsianWidthType");function Ne(e,{ambiguousAsWide:t=!1}={}){return oe(e),ki(e)||Pi(e)||t&&Ei(e)?2:1}O(Ne,"yt");V(Ne,"je");A(Ne,"o$2");ht(Ne,"W");ut(Ne,"eastAsianWidth");Jt(Ne,"eastAsianWidth");var Mn=Object.defineProperty,Tn=A((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"p$3"),Fn=Object.defineProperty,Ri=Tn((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"e"),Ln=Object.defineProperty,_n=Ri((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"E");const Mi=String.raw,Xt=Mi`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Hn=_n(()=>new RegExp(Mi`\p{RI}{2}|(?)${Xt}(?:\u200D${Xt})*`,"gu"),"default");var Gn=Object.defineProperty,Vn=Ri((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"p");const be=new Set(["\x1B",""]),dt="\x07",Ti="[",zt="m",Ze="]8;;",Jn=39,zn=/[\u200B\uFEFF\u2060-\u2064]/g,qn=new RegExp(`(?:\\${Ti}(?<code>\\d+)m|\\${Ze}(?<uri>.*)${dt})`),Un=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]])),Q=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,ei=/\u001B\[(\d+(?:;\d+)*)?m[^\u001B]*(?:\u001B\[(?:\d+(?:;\d+)*)?m|$)/g,ti=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)(.*?)\u001B\]8;;(?:\u0007|\u001B\\)/g,Pe=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,Ve=Hn();Vn(e=>e.replace(Ve,""),"stripEmoji");var Dn=Object.defineProperty,Yn=A((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"E$1"),Kn=Object.defineProperty,Zn=Yn((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"A"),Qn=Object.defineProperty,ft=Zn((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"d");const ii=new Map,Re=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Je=ft(e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other","getCharType"),Xn=ft((e,t)=>{const i=Math.floor(e/65536),r=e%65536;let s=ii.get(i);if(s||(s=new Map,ii.set(i,s)),s.has(r))return s.get(r);let o;if(Je(e)==="latin")o=t.width.regular;else if(Je(e)==="control")o=t.width.control;else if(Je(e)==="wide")o=t.width.wide;else switch(se(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}return s.set(r,o),o},"getCachedCharWidth"),eo=ft(e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,"isCombiningCharacter"),me=ft((e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const i={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?me(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},r=Math.max(0,i.truncation.limit-i.truncation.ellipsisWidth),{length:s}=e,o=s>1e4;let n=0,a=0,l=s,h=!1;const c=e.includes("\x1B")||e.includes("");for(;n<s;){if(c&&(e[n]==="\x1B"||e[n]==="")){if(e.startsWith("\x1B]8;;",n)){const m="\x1B]8;;\x07",d=m.length,$=e.indexOf("\x07",n+5);if($!==-1){const w=e.indexOf(m,$+1);if(w!==-1){const v=w+d,x=e.slice($+1,w).replace(Q,""),W=me(x,{ambiguousIsNarrow:i.width.ambiguousIsNarrow,ansiWidth:i.width.ansi,controlWidth:i.width.control,countAnsiEscapeCodes:!1,ellipsis:i.truncation.ellipsis,ellipsisWidth:i.truncation.ellipsisWidth,emojiWidth:i.width.emoji,fullWidth:i.width.fullWidth,halfWidth:i.width.halfWidth,limit:Math.max(0,r-a),regularWidth:i.width.regular,tabWidth:i.width.tab,wideWidth:i.width.wide}),B=W.width;if(W.truncated)h=!0,l=Math.min(l,n);else if(a+B>r&&(l=Math.min(l,n),h=!0,a+B>i.truncation.limit))break;if(a+=B,n=v,h&&a>=i.truncation.limit)break;continue}}}if(Q.lastIndex=n,Q.test(e)){const m=Q.lastIndex-n,d=i.truncation.countAnsiEscapeCodes?m:i.width.ansi;if(a+d>r&&(l=Math.min(l,n),a+d>i.truncation.limit)){h=!0;break}a+=d,n=Q.lastIndex;continue}}const b=e.codePointAt(n);if(b===8203||b===65279||b>=8288&&b<=8292){n+=1;continue}if(b===9){if(a+i.width.tab>r&&(l=Math.min(l,n),a+i.width.tab>i.truncation.limit)){h=!0;break}a+=i.width.tab,n+=1;continue}if(Re.lastIndex=n,Re.test(e)){const m=(Re.lastIndex-n)*i.width.regular;if(a+m>r){const d=Math.floor((r-a)/i.width.regular);if(l=Math.min(l,n+d),a+m>i.truncation.limit){h=!0;break}}a+=m,n=Re.lastIndex;continue}if((b<=31||b>=127&&b<=159)&&(Pe.lastIndex=n,Pe.test(e))){const m=(Pe.lastIndex-n)*i.width.control;if(a+m>r&&(l=Math.min(l,n+Math.floor((r-a)/i.width.control)),a+m>i.truncation.limit)){h=!0;break}a+=m,n=Pe.lastIndex;continue}if(Ve.lastIndex=n,Ve.test(e)){if(a+i.width.emoji>r&&(l=Math.min(l,n),a+i.width.emoji>i.truncation.limit)){h=!0;break}a+=i.width.emoji,n=Ve.lastIndex;continue}const f=e.codePointAt(n)??0;if(eo(f)){n+=f>65535?2:1;continue}let p;if(o)p=Xn(f,i);else switch(Je(f)){case"control":{p=i.width.control;break}case"latin":{p=i.width.regular;break}case"wide":{p=i.width.wide;break}case"zero":{p=0;break}default:switch(se(f)){case"ambiguous":{p=i.width.ambiguousIsNarrow?i.width.regular:i.width.wide;break}case"fullwidth":{p=i.width.fullWidth;break}case"wide":{p=i.width.wide;break}default:p=i.width.regular}}if(a+p>r&&(l=Math.min(l,n),a+p>i.truncation.limit)){h=!0;break}a+=p,n+=f>65535?2:1}let u=a,g=!1;return h&&i.truncation.limit>=i.truncation.ellipsisWidth&&(u=i.truncation.limit,g=!0),{ellipsed:g,index:h?l:s,truncated:h,width:u}},"getStringTruncatedWidth");var to=Object.defineProperty,io=A((e,t)=>to(e,"name",{value:t,configurable:!0}),"i$2"),ro=Object.defineProperty,no=io((e,t)=>ro(e,"name",{value:t,configurable:!0}),"e"),oo=Object.defineProperty,so=no((e,t)=>oo(e,"name",{value:t,configurable:!0}),"r");const E=so((e,t={})=>me(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");var ao=Object.defineProperty,Fi=A((e,t)=>ao(e,"name",{value:t,configurable:!0}),"i$1"),lo=Object.defineProperty,Li=Fi((e,t)=>lo(e,"name",{value:t,configurable:!0}),"r"),co=Object.defineProperty,ho=Li((e,t)=>co(e,"name",{value:t,configurable:!0}),"c");let uo=class{static{O(this,"ki")}static{V(this,"Si")}static{A(this,"l")}static{Fi(this,"y")}static{Li(this,"s")}static{ho(this,"LRUCache")}capacity;cache;keyOrder;constructor(e){this.capacity=e,this.cache=new Map,this.keyOrder=[]}get(e){if(this.cache.has(e))return this.keyOrder=this.keyOrder.filter(t=>t!==e),this.keyOrder.push(e),this.cache.get(e)}has(e){return this.cache.has(e)}set(e,t){if(this.cache.has(e))this.keyOrder=this.keyOrder.filter(i=>i!==e);else if(this.cache.size>=this.capacity){const i=this.keyOrder.shift();i!==void 0&&this.cache.delete(i)}this.cache.set(e,t),this.keyOrder.push(e)}delete(e){this.cache.delete(e),this.keyOrder=this.keyOrder.filter(t=>t!==e)}clear(){this.cache.clear(),this.keyOrder=[]}size(){return this.cache.size}};var fo=Object.defineProperty,mo=A((e,t)=>fo(e,"name",{value:t,configurable:!0}),"S$1"),po=Object.defineProperty,go=mo((e,t)=>po(e,"name",{value:t,configurable:!0}),"w"),bo=Object.defineProperty,we=go((e,t)=>bo(e,"name",{value:t,configurable:!0}),"y");const ri=new uo(100),wo=new Intl.Segmenter("en",{granularity:"grapheme"}),yo=/^[\u0000-\u007F]*$/,vo=new Set(["0","22","23","24","27","28","29","39","49"]),$o=new Set(["1","3","4","7","8","9"]),ni=new Map([["22","1"],["23","3"],["24","4"],["27","7"],["28","8"],["29","9"]]),Me=we(e=>e>="30"&&e<="37"||e>="90"&&e<="97"||e.startsWith("38;"),"isForegroundColor"),Te=we(e=>e>="40"&&e<="47"||e>="100"&&e<="107"||e.startsWith("48;"),"isBackgroundColor"),xo=[{close:"\x1B[22m",open:"\x1B[1m"},{close:"\x1B[23m",open:"\x1B[3m"},{close:"\x1B[24m",open:"\x1B[4m"},{close:"\x1B[27m",open:"\x1B[7m"},{close:"\x1B[28m",open:"\x1B[8m"},{close:"\x1B[29m",open:"\x1B[9m"}],oi=we((e,t)=>{let i=-1;for(const r of t){const s=e.indexOf(r);s!==-1&&(i===-1||s<i)&&(i=s)}return i},"findFirstPositionOfAny"),Wo=we((e,t)=>{if(!e.includes("\x1B"))return[{after:"",before:"",content:e,visibleLength:E(e,t.width)}];const i=ri.get(e);if(i)return i;const r=[],s=[];let o=0,n;for(Q.lastIndex=0;(n=Q.exec(e))!==null;){const c=n[0];r.push(e.slice(o,n.index)),s.push(c),o=n.index+c.length}o<e.length&&r.push(e.slice(o));const a=[];for(const c of s){if(c==="\x1B[0m"||c==="\x1B]8;;\x07"){a.push(c);continue}if(c.startsWith("\x1B[")&&c.endsWith("m")){const u=c.slice(2,-1);if(vo.has(u)){a.push(c);continue}}}const l=new Set,h=[];for(const[c,u]of r.entries()){if(c>0&&s[c-1]){const f=s[c-1];if(f==="\x1B[0m")l.clear();else if(f==="\x1B]8;;\x07"){for(const p of l)if(p.startsWith("\x1B]8;;")&&!p.endsWith("\x1B]8;;\x07")){l.delete(p);break}}else if(f.startsWith("\x1B[")&&f.endsWith("m")){const p=f.slice(2,-1);if(p==="39"){for(const m of l)if(m.startsWith("\x1B[")&&m.endsWith("m")){const d=m.slice(2,-1);if(Me(d)){l.delete(m);break}}}else if(p==="49"){for(const m of l)if(m.startsWith("\x1B[")&&m.endsWith("m")){const d=m.slice(2,-1);if(Te(d)){l.delete(m);break}}}else if(ni.has(p)){const m=ni.get(p);for(const d of l)if(d===`\x1B[${m}m`){l.delete(d);break}}else{if(Me(p)){for(const m of l)if(m.startsWith("\x1B[")&&m.endsWith("m")){const d=m.slice(2,-1);if(Me(d)){l.delete(m);break}}}else if(Te(p)){for(const m of l)if(m.startsWith("\x1B[")&&m.endsWith("m")){const d=m.slice(2,-1);if(Te(d)){l.delete(m);break}}}else if($o.has(p)){const m=`\x1B[${p}m`;l.has(m)&&l.delete(m)}l.add(f)}}else if(f.startsWith("\x1B]8;;")&&!f.endsWith("\x1B]8;;\x07")){for(const p of l)if(p.startsWith("\x1B]8;;")&&!p.endsWith("\x1B]8;;\x07")){l.delete(p);break}l.add(f)}}if(u==="")continue;let g="";if(l.size>0)if(a.includes("\x1B[0m"))g="\x1B[0m";else{const f=[];let p=!1;for(const w of l)if(w.startsWith("\x1B]8;;")&&!w.endsWith("\x1B]8;;\x07")){p=!0;break}p&&a.includes("\x1B]8;;\x07")&&f.push("\x1B]8;;\x07");let m=!1,d=!1;for(const w of l)if(w.startsWith("\x1B[")&&w.endsWith("m")){const v=w.slice(2,-1);Me(v)?m=!0:Te(v)&&(d=!0)}if(m&&d){const w=oi(e,["\x1B[3","\x1B[9","\x1B[38;"]),v=oi(e,["\x1B[4","\x1B[10","\x1B[48;"]);w>=0&&v>=0?w>v?f.push("\x1B[39m","\x1B[49m"):f.push("\x1B[49m","\x1B[39m"):f.push("\x1B[39m","\x1B[49m")}else m&&f.push("\x1B[39m"),d&&f.push("\x1B[49m");m&&d&&e.includes("\x1B[39m")&&e.includes("\x1B[49m")&&(e.indexOf("\x1B[39m")<e.indexOf("\x1B[49m")?(f.length-=2,f.push("\x1B[39m","\x1B[49m")):e.indexOf("\x1B[49m")<e.indexOf("\x1B[39m")&&(f.length-=2,f.push("\x1B[49m","\x1B[39m")));const $=xo.filter(w=>l.has(w.open)).map(w=>({position:e.indexOf(w.open),style:w})).filter(w=>w.position>=0).toSorted((w,v)=>v.position-w.position);for(const w of $){const v=w;a.includes(v.style.close)&&f.push(v.style.close)}g=f.join("")}const b=[...l].join("");h.push({after:g,before:b,content:u,visibleLength:E(u,{fullWidth:1,wideWidth:1})})}return ri.set(e,h),h},"processIntoStyledSegments"),Oo=we((e,t,i,r)=>{const s=[...r.segmenter.segment(e)],o=[];let n=0,a=!1;for(const l of s){const h=E(l.segment,r.width),c=n,u=n+h;if(!a)if(c<t){n=u;continue}else a=!0;if(c>=i||u>i)break;o.push(l.segment),n=u}return o.join("")},"fastSlice"),q=we((e,t=0,i=Number.MAX_SAFE_INTEGER,r={})=>{const s={segmenter:wo,...r};if(t>=i||e==="")return"";const o=E(e,s.width);if(t===0&&i>=o)return e;if(t<0||i<0)throw new RangeError("Negative indices aren't supported");if(!e.includes("\x1B"))return yo.test(e)?e.slice(t,i):Oo(e,t,i,s);if(ei.lastIndex=0,ti.lastIndex=0,!ei.test(e)&&!ti.test(e))return e;const n=Wo(e,s);if(n.length===0)return"";let a=0;const l=[];for(const[u,g]of n.entries()){const b=a,f=a+g.visibleLength;if(f>t&&b<i){const p=Math.max(0,t-b),m=Math.min(g.visibleLength,i-b);l.push({end:m,index:u,segment:g,start:p})}a=f}if(l.length===0)return"";const h=[],c=l[0].segment;h.push(c.before);for(let u=0;u<l.length;u++){const{end:g,segment:b,start:f}=l[u];if(f===0&&g===b.visibleLength)h.push(b.content);else{const p=[...s.segmenter.segment(b.content)];h.push(p.slice(f,g).map(m=>m.segment).join(""))}if(u<l.length-1){const p=l[u+1].segment,m=b.after,d=p.before;m!==d&&(m||d)&&h.push(m,d)}}return h.push(l.at(-1).segment.after),h.join("")},"slice");var Bo=Object.defineProperty,So=A((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"x"),Ao=Object.defineProperty,jo=So((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"T"),Io=Object.defineProperty,mt=jo((e,t)=>Io(e,"name",{value:t,configurable:!0}),"f");const si="…",Co=3,Fe=mt((e,t,i=!1)=>{if(e.charAt(t)===" ")return t;const r=i?1:-1,s=Math.min(Co,i?e.length-t:t);for(let o=1;o<=s;o++){const n=t+o*r;if(e.charAt(n)===" ")return n}return t},"findNearestSpace"),Le=mt((e,t,i)=>me(e,{...i,ellipsis:"",ellipsisWidth:0,limit:t}).index,"widthToIndex"),_e=mt((e,t,i)=>E(e.slice(0,t),i),"indexToWidth"),ai=mt((e,t,i={})=>{if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof e}`);if(typeof t!="number")throw new TypeError(`Expected \`limit\` to be a number, got ${typeof t}`);if(e===""||t<=0)return"";const r=e.normalize("NFC"),{ellipsis:s=si,position:o="end",preferTruncationOnSpace:n=!1}=i;let a=i.ellipsisWidth??s===si?1:void 0;a??=me(s,{...i.width,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width;const{width:l}=me(r,{...i.width,ellipsis:s,ellipsisWidth:a});if(l<=t)return r;switch(o){case"end":{if(n){const h=t-a,c=Le(r,h,i.width),u=Fe(r,c),g=_e(r,u,i.width);return q(r,0,g,{width:i.width})+s}return q(r,0,t-a,{width:i.width})+s}case"middle":{const h=Math.floor(t/2),c=Math.max(0,t-a),u=Math.min(h,c),g=Math.max(0,c-u);if(n){const b=Le(r,u,i.width),f=Fe(r,b),p=_e(r,f,i.width),m=l-g,d=Le(r,m,i.width),$=Fe(r,d,!0),w=_e(r,$,i.width);return q(r,0,p,{width:i.width})+s+q(r,w,l,{width:i.width}).trim()}return q(r,0,u,{width:i.width})+s+q(r,l-g,l,{width:i.width})}case"start":{if(n){const h=l-t+a,c=Le(r,h,i.width),u=Fe(r,c,!0),g=_e(r,u,i.width);return s+q(r,g,l,{width:i.width}).trim()}return s+q(r,l-t+a,l,{width:i.width})}default:throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${o}'`)}},"truncate");var No=Object.defineProperty,_i=A((e,t)=>No(e,"name",{value:t,configurable:!0}),"b$2"),Eo=Object.defineProperty,ae=_i((e,t)=>Eo(e,"name",{value:t,configurable:!0}),"d"),ko=Object.defineProperty,Po=ae((e,t)=>ko(e,"name",{value:t,configurable:!0}),"a");const Ro=/\x1B\[(\d+)m/;class Hi{static{O(this,"he")}static{V(this,"at")}static{A(this,"T")}static{_i(this,"T")}static{ae(this,"d")}static{Po(this,"AnsiStateTracker")}activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const i=Ro.exec(t);if(!i)return;const r=Number.parseInt(i[1],10);switch(r){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(r>=30&&r<=37||r>=90&&r<=97)this.activeForeground=t;else if(r>=40&&r<=47||r>=100&&r<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(r))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(r)){const s={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[r];s&&(this.activeFormatting=this.activeFormatting.filter(o=>!o.includes(s)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const i={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(r=>{const s=i[r];s&&t.push(s)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}}var Mo=Object.defineProperty,Gi=ae((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"o");const Vi=Gi((e,t)=>{if(!be.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const i=!0,r=e.slice(t+1,t+1+Ze.length).join("")===Ze;return{isInsideEscape:i,isInsideLinkEscape:r}},"checkEscapeSequence"),To=Gi((e,t={})=>{const i=new Hi;let r="",s=!1,o="",n="",a=!1;const l=[...e];for(let h=0;h<l.length;h++){const c=l[h];if(c&&be.has(c)){if(r){const p=t.getWidth?.(r)??0,m={isEscapeSequence:!1,isGrapheme:!0,text:r,width:p};if(a&&(m.isHyperlink=!0,m.hyperlinkUrl=n),t.onSegment?.(m,i)===!1)return;r=""}s=!0,o=c;const b=Vi(l,h),{isInsideLinkEscape:f}=b;if(f){let p=h+1;for(n="";p<l.length;){const d=l[p];if(d===dt)break;n+=d,p+=1}n=n.slice(4);const m={hyperlinkUrl:n,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(m,i)===!1)return;h=p,a=!0,s=!1,o="";continue}if(h+1<l.length&&l[h+1]==="\\"&&a){const p={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(p,i)===!1)return;a=!1,n="",h+=1,s=!1,o="";continue}}if(s){if(o!==c&&(o+=c),c===zt){s=!1,i.processEscape(o);const b={isEscapeSequence:!0,isGrapheme:!1,text:o,width:0};if(t.onSegment?.(b,i)===!1)return;o=""}continue}r+=c;const u=t.getWidth?.(r)??0,g={isEscapeSequence:!1,isGrapheme:!0,text:r,width:u};if(a&&(g.isHyperlink=!0,g.hyperlinkUrl=n),t.onSegment?.(g,i)===!1)return;r=""}if(r){const h=t.getWidth?.(r)??0,c={isEscapeSequence:!1,isGrapheme:!0,text:r,width:h};a&&(c.isHyperlink=!0,c.hyperlinkUrl=n),t.onSegment?.(c,i)}if(o){const h={isEscapeSequence:!0,isGrapheme:!1,text:o,width:0};t.onSegment?.(h,i)}},"processAnsiString");var Fo=Object.defineProperty,Lo=ae((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"t$1");const li=Lo(e=>`${be.values().next().value}${Ti}${String(e)}${zt}`,"wrapAnsiCode");var _o=Object.defineProperty,Ho=ae((e,t)=>_o(e,"name",{value:t,configurable:!0}),"s");const ci=Ho(e=>`${be.values().next().value}${Ze}${e}${dt}`,"wrapAnsiHyperlink");var Go=Object.defineProperty,Vo=ae((e,t)=>Go(e,"name",{value:t,configurable:!0}),"l");const Jo=Vo(e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",i,r;const s=e.join(`
|
|
2
2
|
`),o=[...s];let n=0;for(const[a,l]of o.entries()){if(t+=l,be.has(l)){const c=qn.exec(s.slice(n))?.groups??{};if(c.code!==void 0){const u=Number.parseFloat(c.code);i=u===Jn?void 0:u}else c.uri!==void 0&&(r=c.uri.length===0?void 0:c.uri)}const h=Un.get(Number(i));o[a+1]===`
|
|
3
3
|
`?(r&&(t+=ci("")),i&&h&&(t+=li(h))):l===`
|
|
4
4
|
`&&(i&&h&&(t+=li(i)),r&&(t+=ci(r))),n+=l.length}return t},"preserveAnsi");var zo=Object.defineProperty,Y=ae((e,t)=>zo(e,"name",{value:t,configurable:!0}),"f");const Ji=/(?=\s)|(?<=\s)/,zi=/^\s+$/,Ot=Y(e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},"resetAnsiAtLineBreak"),te=Y(e=>{const t=e.split(" ");let i=t.length;for(;i>0&&E(t[i-1])===0;)i--;return i===t.length?e:t.slice(0,i).join(" ")+t.slice(i).join("")},"stringVisibleTrimSpacesRight"),qi=Y((e,t,i)=>{if(e.length===0)return[""];if(t<=0)return[e];const r=[],s=new Hi;let o="",n=0,a=!1,l=!1,h="",c=0;for(;c<e.length;){const u=e[c];if(be.has(u)){a=!0,h=u,o+=u,l=Vi([...e],c).isInsideLinkEscape,c+=1;continue}if(a){h+=u,o+=u,l?u===dt&&(a=l=!1):u===zt&&(a=!1,s.processEscape(h)),c+=1;continue}const g=E(u),b=u===" ";if(g===0){o+=u,c+=1;continue}if(n+g>t&&(o&&r.push(o+s.getEndEscapesForAllActiveAttributes()),o=s.getStartEscapesForAllActiveAttributes(),n=E(o),b&&i)){for(;c<e.length&&e[c]===" ";)c+=1;continue}if(o+=u,n+=g,n===t&&c<e.length-1&&(r.push(o+s.getEndEscapesForAllActiveAttributes()),o=s.getStartEscapesForAllActiveAttributes(),n=E(o),c+1<e.length&&e[c+1]===" "&&i)){for(c+=1;c<e.length&&e[c]===" ";)c+=1;continue}c+=1}return o&&r.push(o+s.getEndEscapesForAllActiveAttributes()),i?r.map(u=>te(u)):r},"wrapWithBreakAtWidth"),qo=Y((e,t,i)=>{if(e.length===0)return[];const r=i?e.trim():e;if(r.length===0)return[];const s=[];let o="",n=0;return To(r,{getWidth:E,onSegment:Y((a,l)=>{const h=a.text??"";if(a.isEscapeSequence)o+=h;else{const c=h===" ";if(a.width===0)return o+=h,!0;if(n+a.width>t&&(o&&s.push(o),o=l.getStartEscapesForAllActiveAttributes(),n=0,c))return i||s.push(l.getStartEscapesForAllActiveAttributes()+h),!0;o+=h,n+=a.width}return!0},"onSegment")}),o&&s.push(o),i?s.map(a=>te(a)):s},"wrapCharByChar"),Uo=Y((e,t,i)=>{if(e.length===0)return[];const r=i?e.trim():e;if(r.length===0)return[];const s=r.split(Ji),o=[];let n="",a=0,l=0;for(;l<s.length;){const h=s[l],c=zi.test(h),u=E(h);if(h.length===0){l+=1;continue}if(i&&c&&a===0){l+=1;continue}if(a+u>t&&a>0){i?o.push(te(n)):o.push(n),n="",a=0;continue}n+=h,a+=u,l+=1}return n&&(i?o.push(te(n)):o.push(n)),o},"wrapWithWordBoundaries"),Do=Y((e,t,i)=>{if(e.length===0)return[];const r=i?e.trim():e;if(r.length===0)return[];const s=r.split(Ji),o=[];let n="",a=0,l=0;for(;l<s.length;){const h=s[l],c=zi.test(h),u=E(h);if(h.length===0){l+=1;continue}if(i&&c&&a===0){l+=1;continue}if(u>t){n&&o.push(Ot(i?te(n):n));const g=qi(h,t,i);if(g.length>0){for(let b=0;b<g.length-1;b+=1)o.push(g[b]);n=g.at(-1),a=E(n)}else n="",a=0;l+=1;continue}if(a+u>t&&a>0&&(o.push(Ot(i?te(n):n)),n="",a=0,i&&c)){l+=1;continue}n+=h,a+=u,l+=1}return n&&o.push(Ot(i?te(n):n)),o},"wrapAndBreakWords"),He={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},Yo=Y((e,t={})=>{const{removeZeroWidthCharacters:i=!0,trim:r=!0,width:s=80,wrapMode:o=He.PRESERVE_WORDS}=t;if(r&&e.trim()==="")return"";let n=e.normalize("NFC").replaceAll(`\r
|
|
@@ -15,4 +15,4 @@ ${JSON.stringify(t)}`);const r=Ue({showHeader:!1,style:{border:qe,paddingLeft:4,
|
|
|
15
15
|
|
|
16
16
|
${JSON.stringify(t)}`)}}var Pa=Object.defineProperty,Ra=J((e,t)=>Pa(e,"name",{value:t,configurable:!0}),"m");class Ma extends cr{static{O(this,"U")}static{vt(this,"k")}static{J(this,"O")}static{Ra(this,"OptionListSection")}constructor(t){super();let i=t.optionList??[];const r=Array.isArray(t.hide)?t.hide:[t.hide].filter(n=>typeof n=="string"),s=Array.isArray(t.group)?t.group:[t.group].filter(n=>typeof n=="string");r.length>0&&(i=i.filter(n=>!r.includes(n.name))),t.header&&this.header(P(t.header)),s.length>0&&(i=i.filter(n=>{const a=n,l=s.includes("_none")&&!a.group,h=a.group,c=this.intersect(Array.isArray(h)?h:[h],s);return l||c?n:void 0}));const o=Ue({showHeader:!1,style:{border:qe,paddingLeft:2,paddingRight:1,...t.tableOptions?.style},terminalWidth:Ye()??t.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:t.tableOptions?.wordWrap??!0,...t.tableOptions});i.forEach(n=>{const a=n;o.addRow([this.getOptionNames(a,t.reverseNameOrder??!1,t.isArgument??!1),P(a.description)])}),this.add(o.toString()),this.lines.push("")}getOptionNames(t,i,r){if(!t.name)throw new TypeError("Invalid option definition, name is required.");let s=t.type?t.type.name.toLowerCase():"string";const o=t.multiple||t.lazyMultiple?"[]":"";s=P(t.typeLabel??`{underline ${s}${o}}`);let n;if(t.alias)if(t.name){const a=r?t.name:`{yellow --${t.name}}`;n=P(i?`{bold ${a}}, {bold -${t.alias}} ${s}`:`{bold -${t.alias}}, {bold ${a}} ${s}`)}else i?n=P(`{bold -${t.alias}} ${s}`):n=P(`{bold -${t.alias}} ${s}`);else n=P(`{bold ${r?t.name:`{yellow --${t.name}}`}} ${s}`);return n}intersect(t,i){return t.some(r=>i.includes(r))}}var Ta=Object.defineProperty,Fa=J((e,t)=>Ta(e,"name",{value:t,configurable:!0}),"o");const Yt=Fa(e=>(Array.isArray(e)?e:[e]).length===0?"":`
|
|
17
17
|
${e.map(t=>t.optionList?new Ma(t).toString():new ka(t).toString()).join(`
|
|
18
|
-
`)}`,"commandLineUsage");var La=Object.defineProperty,hr=O((e,t)=>La(e,"name",{value:t,configurable:!0}),"b"),_a=Object.defineProperty,ur=hr((e,t)=>_a(e,"name",{value:t,configurable:!0}),"b");const Ha=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}];var Ga=Object.defineProperty,ie=ur((e,t)=>Ga(e,"name",{value:t,configurable:!0}),"f");const Wi="__Other",Oi=ie(e=>e.charAt(0).toUpperCase()+e.slice(1),"upperFirstChar"),Va=ie((e,t,i,r)=>{e.debug("no command given, printing general help...");let s=[...new Set(i.values())].filter(a=>!a.hidden);r&&(s=s.filter(a=>a.group===r));const o=s.reduce((a,l)=>{const h=l.group??Wi;return a[h]??=[],a[h].push(l),a},{}),n=ie(a=>a.map(l=>{let h="";typeof l.alias=="string"?h=l.alias:Array.isArray(l.alias)&&(h=l.alias.join(", ")),h!==""&&(h=` [${h}]`);let c=l.name;return l.commandPath&&l.commandPath.length>0&&(c=`${l.commandPath.join(" ")} ${l.name}`),[`${G(c)}${h}`,l.description??""]}),"buildCommandList");(e.raw??e.log)(Yt([{content:`${fe(t.getCliName())} ${G("<command>")} [positional arguments] ${Ke("[options]")}`,header:R.cyan(" Usage ")},...Object.keys(o).map(a=>{const l=r?` ${Oi(r)}`:"";return{content:n(o[a]),header:a===Wi||r?R.green(` Available${l} Commands `):` ${R.green(` ${Oi(a)} `)}`}}),i.has("help")?{header:R.yellow(" Command Options "),optionList:i.get("help").options?.filter(a=>!a.hidden)}:void 0,{header:R.yellow(" Global Options "),optionList:t.getGlobalOptions()},{content:Ha.filter(a=>!a.hidden).map(a=>[a.name,a.description??""]),header:R.magenta(" Environment Variables ")},{content:`Run "${fe(t.getCliName())} ${G("help <command>")}" or "${fe(t.getCliName())} ${G("<command>")} ${Ke("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),Bi=ie((e,t)=>{const i=[];for(const r of e.values()){if(r.hidden)continue;const s=r.commandPath??[];if(s.length!==t.length)continue;let o=!0;for(const[n,a]of t.entries())if(s[n]!==a){o=!1;break}o&&i.push(r)}return i},"findChildren"),Ja=ie((e,t,i,r)=>{const s=i.join(" "),o=[{content:`${fe(t.getCliName())} ${G(s)} ${G("<subcommand>")} [positional arguments] ${Ke("[options]")}`,header:R.cyan(" Usage ")},{content:r.map(n=>{const a=[...n.commandPath??[],n.name].join(" ");return[G(a),n.description??""]}),header:R.green(" Subcommands ")},{header:R.yellow(" Global Options "),optionList:t.getGlobalOptions()},{content:`Run "${fe(t.getCliName())} ${G(`${s} <subcommand>`)} ${Ke("--help")}" for help with a specific subcommand.`,raw:!0}];(e.raw??e.log)(Yt(o))},"printParentHelp"),za=ie((e,t,i,r,s)=>{let o=s??i.get(r);if(!o)for(const c of i.values()){const u=c.commandPath?[...c.commandPath,c.name]:[c.name];if(u.at(-1)===r||u.join(" ")===r){o=c;break}}if(!o){const c=r.split(" ").filter(Boolean),u=c.length>0?Bi(i,c):[];if(u.length>0){Ja(e,t,c,u);return}e.error(`Command "${r}" not found`);return}const n=[],a=(o.commandPath?[...o.commandPath,o.name]:[o.name]).join(" ");if(n.push({content:`${fe(t.getCliName())} ${G(a)}${o.argument?" [positional arguments]":""}${o.options?" [options]":""}`,header:R.cyan(" Usage ")}),o.description&&n.push({content:o.description,header:R.green(" Description ")}),o.argument&&n.push({header:"Command Positional Arguments",isArgument:!0,optionList:[o.argument]}),Array.isArray(o.options)&&o.options.length>0&&n.push({header:R.yellow(" Command Options "),optionList:o.options.filter(c=>!c.hidden)}),n.push({header:R.yellow(" Global Options "),optionList:t.getGlobalOptions()}),Array.isArray(o.env)&&o.env.length>0){const c=o.env.filter(u=>!u.hidden);c.length>0&&n.push({content:c.map(u=>[u.name,u.description??""]),header:R.magenta(" Environment Variables ")})}if(o.alias!==void 0&&o.alias.length>0){let c=o.alias;typeof o.alias=="string"&&(c=[o.alias]),n.splice(1,0,{content:c,header:"Alias(es)"})}Array.isArray(o.examples)&&o.examples.length>0&&n.push({content:o.examples,header:"Examples"});const l=[...o.commandPath??[],o.name],h=Bi(i,l);h.length>0&&n.push({content:h.map(c=>{const u=[...c.commandPath??[],c.name].join(" ");return[G(u),c.description??""]}),header:R.green(" Subcommands ")}),(e.raw??e.log)(Yt(n))},"printCommandHelp");class
|
|
18
|
+
`)}`,"commandLineUsage");var La=Object.defineProperty,hr=O((e,t)=>La(e,"name",{value:t,configurable:!0}),"b"),_a=Object.defineProperty,ur=hr((e,t)=>_a(e,"name",{value:t,configurable:!0}),"b");const Ha=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}];var Ga=Object.defineProperty,ie=ur((e,t)=>Ga(e,"name",{value:t,configurable:!0}),"f");const Wi="__Other",Oi=ie(e=>e.charAt(0).toUpperCase()+e.slice(1),"upperFirstChar"),Va=ie((e,t,i,r)=>{e.debug("no command given, printing general help...");let s=[...new Set(i.values())].filter(a=>!a.hidden);r&&(s=s.filter(a=>a.group===r));const o=s.reduce((a,l)=>{const h=l.group??Wi;return a[h]??=[],a[h].push(l),a},{}),n=ie(a=>a.map(l=>{let h="";typeof l.alias=="string"?h=l.alias:Array.isArray(l.alias)&&(h=l.alias.join(", ")),h!==""&&(h=` [${h}]`);let c=l.name;return l.commandPath&&l.commandPath.length>0&&(c=`${l.commandPath.join(" ")} ${l.name}`),[`${G(c)}${h}`,l.description??""]}),"buildCommandList");(e.raw??e.log)(Yt([{content:`${fe(t.getCliName())} ${G("<command>")} [positional arguments] ${Ke("[options]")}`,header:R.cyan(" Usage ")},...Object.keys(o).map(a=>{const l=r?` ${Oi(r)}`:"";return{content:n(o[a]),header:a===Wi||r?R.green(` Available${l} Commands `):` ${R.green(` ${Oi(a)} `)}`}}),i.has("help")?{header:R.yellow(" Command Options "),optionList:i.get("help").options?.filter(a=>!a.hidden)}:void 0,{header:R.yellow(" Global Options "),optionList:t.getGlobalOptions()},{content:Ha.filter(a=>!a.hidden).map(a=>[a.name,a.description??""]),header:R.magenta(" Environment Variables ")},{content:`Run "${fe(t.getCliName())} ${G("help <command>")}" or "${fe(t.getCliName())} ${G("<command>")} ${Ke("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),Bi=ie((e,t)=>{const i=[];for(const r of e.values()){if(r.hidden)continue;const s=r.commandPath??[];if(s.length!==t.length)continue;let o=!0;for(const[n,a]of t.entries())if(s[n]!==a){o=!1;break}o&&i.push(r)}return i},"findChildren"),Ja=ie((e,t,i,r)=>{const s=i.join(" "),o=[{content:`${fe(t.getCliName())} ${G(s)} ${G("<subcommand>")} [positional arguments] ${Ke("[options]")}`,header:R.cyan(" Usage ")},{content:r.map(n=>{const a=[...n.commandPath??[],n.name].join(" ");return[G(a),n.description??""]}),header:R.green(" Subcommands ")},{header:R.yellow(" Global Options "),optionList:t.getGlobalOptions()},{content:`Run "${fe(t.getCliName())} ${G(`${s} <subcommand>`)} ${Ke("--help")}" for help with a specific subcommand.`,raw:!0}];(e.raw??e.log)(Yt(o))},"printParentHelp"),za=ie((e,t,i,r,s)=>{let o=s??i.get(r);if(!o)for(const c of i.values()){const u=c.commandPath?[...c.commandPath,c.name]:[c.name];if(u.at(-1)===r||u.join(" ")===r){o=c;break}}if(!o){const c=r.split(" ").filter(Boolean),u=c.length>0?Bi(i,c):[];if(u.length>0){Ja(e,t,c,u);return}e.error(`Command "${r}" not found`);return}const n=[],a=(o.commandPath?[...o.commandPath,o.name]:[o.name]).join(" ");if(n.push({content:`${fe(t.getCliName())} ${G(a)}${o.argument?" [positional arguments]":""}${o.options?" [options]":""}`,header:R.cyan(" Usage ")}),o.description&&n.push({content:o.description,header:R.green(" Description ")}),o.argument&&n.push({header:"Command Positional Arguments",isArgument:!0,optionList:[o.argument]}),Array.isArray(o.options)&&o.options.length>0&&n.push({header:R.yellow(" Command Options "),optionList:o.options.filter(c=>!c.hidden)}),n.push({header:R.yellow(" Global Options "),optionList:t.getGlobalOptions()}),Array.isArray(o.env)&&o.env.length>0){const c=o.env.filter(u=>!u.hidden);c.length>0&&n.push({content:c.map(u=>[u.name,u.description??""]),header:R.magenta(" Environment Variables ")})}if(o.alias!==void 0&&o.alias.length>0){let c=o.alias;typeof o.alias=="string"&&(c=[o.alias]),n.splice(1,0,{content:c,header:"Alias(es)"})}Array.isArray(o.examples)&&o.examples.length>0&&n.push({content:o.examples,header:"Examples"});const l=[...o.commandPath??[],o.name],h=Bi(i,l);h.length>0&&n.push({content:h.map(c=>{const u=[...c.commandPath??[],c.name].join(" ");return[G(u),c.description??""]}),header:R.green(" Subcommands ")}),(e.raw??e.log)(Yt(n))},"printCommandHelp");class Qa{static{O(this,"L")}static{hr(this,"L")}static{ur(this,"x")}static{ie(this,"HelpCommand")}argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(t){this.commands=t}execute(t){const{argument:i,command:r,commandName:s,logger:o,options:n,runtime:a}=t,{footer:l,header:h}=a.getCommandSection();h&&(o.raw??o.log)(P(h));const c=s==="help"&&Array.isArray(i)&&i.length>0?i.join(" "):void 0;if(s==="help"&&c===void 0)Va(o,a,this.commands,typeof n?.group=="string"?n.group:void 0);else{const u=c!==void 0||r===void 0||r.name==="help"?void 0:r;za(o,a,this.commands,c??s,u)}l&&(o.raw??o.log)(P(l))}}export{Qa as default};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var ie=Object.defineProperty;var h=(e,t)=>ie(e,"name",{value:t,configurable:!0});import{
|
|
1
|
+
var ie=Object.defineProperty;var h=(e,t)=>ie(e,"name",{value:t,configurable:!0});import{o as ae,am as oe,p as se,aO as le}from"./bin.js";import{z as U,M as z,$ as A}from"../packem_shared/readFileSync-CGmzMUF2-D6rUjGDn.js";import{b as S,l as E,O as _,M as q,v as Q,c as W,s as G,L as ce}from"../packem_shared/index-B8Ko8mwG.js";var fe=Object.defineProperty,ue=h((e,t)=>fe(e,"name",{value:t,configurable:!0}),"l$3"),pe=Object.defineProperty,me=ue((e,t)=>pe(e,"name",{value:t,configurable:!0}),"l"),de=Object.defineProperty,he=me((e,t)=>de(e,"name",{value:t,configurable:!0}),"o");const ye=new E(1e3),T=he((e,t)=>{if(typeof e!="string")return"";const n=t?.cache??!1,r=t?.cacheStore??ye;let i;if(n&&(i=S(e,t)),n&&i&&r.has(i))return r.get(i);const a=_(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(s=>{if(t?.handleAnsi&&q.test(s))return s;if(t?.toUpperCase)return t.locale?s.toLocaleUpperCase(t.locale):s.toUpperCase();const l=t?.locale?.startsWith("de")?Q(s):s;return t?.locale?l.toLocaleLowerCase(t.locale):l.toLowerCase()}),o=W(a,t?.joiner??"-");return n&&i&&r.set(i,o),o},"kebabCase");var be=Object.defineProperty,ge=h((e,t)=>be(e,"name",{value:t,configurable:!0}),"r$2"),ve=Object.defineProperty,$e=ge((e,t)=>ve(e,"name",{value:t,configurable:!0}),"a"),we=Object.defineProperty,je=$e((e,t)=>we(e,"name",{value:t,configurable:!0}),"s");const Oe=new E(1e3),Ee=je((e,t)=>T(e,{cacheStore:Oe,...t,joiner:"_",toUpperCase:!0}),"constantCase");var xe=Object.defineProperty,Ae=h((e,t)=>xe(e,"name",{value:t,configurable:!0}),"l$2"),ke=Object.defineProperty,Pe=Ae((e,t)=>ke(e,"name",{value:t,configurable:!0}),"l"),Ce=Object.defineProperty,Se=Pe((e,t)=>Ce(e,"name",{value:t,configurable:!0}),"i");const _e=new E(1e3),We=Se((e,t)=>{if(typeof e!="string"||!e)return"";const n=t?.cache??!1,r=t?.cacheStore??_e;let i;if(n&&(i=S(e,t)),n&&i&&r.has(i))return r.get(i);const a=W(_(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(o=>{if(t?.handleAnsi&&q.test(o))return o;const s=t?.locale?.startsWith("de")?Q(o):o;return G(t?.locale?s.toLocaleLowerCase(t.locale):s.toLowerCase(),{locale:t?.locale})}),"");return n&&i&&r.set(i,a),a},"pascalCase");var Te=Object.defineProperty,Le=h((e,t)=>Te(e,"name",{value:t,configurable:!0}),"r$1"),Me=Object.defineProperty,Fe=Le((e,t)=>Me(e,"name",{value:t,configurable:!0}),"a"),Ne=Object.defineProperty,Re=Fe((e,t)=>Ne(e,"name",{value:t,configurable:!0}),"s");const Ie=new E(1e3),Ue=Re((e,t)=>T(e,{cacheStore:Ie,...t,joiner:"_"}),"snakeCase");var ze=Object.defineProperty,qe=h((e,t)=>ze(e,"name",{value:t,configurable:!0}),"r"),Qe=Object.defineProperty,Ge=qe((e,t)=>Qe(e,"name",{value:t,configurable:!0}),"e"),Ve=Object.defineProperty,Be=Ge((e,t)=>Ve(e,"name",{value:t,configurable:!0}),"i");const De=new E(1e3),Je=Be((e,t)=>{if(typeof e!="string")return"";const n=t?.cache??!1,r=t?.cacheStore??De;let i;if(n&&(i=S(e,t)),n&&i&&r.has(i))return r.get(i);const a=W(_(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(o=>G(o,{locale:t?.locale})),"-");return n&&i&&r.set(i,a),a},"trainCase");var Ke=Object.defineProperty,d=h((e,t)=>Ke(e,"name",{value:t,configurable:!0}),"e");const y=d(e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),"stringify"),P={camel_case:d(e=>ce(y(e)),"camel_case"),kebab_case:d(e=>T(y(e)),"kebab_case"),lower_case:d(e=>y(e).toLowerCase(),"lower_case"),pascal_case:d(e=>We(y(e)),"pascal_case"),path_join:d((e,...t)=>{const n=[y(e),...t.map(r=>y(r))];return z(...n)},"path_join"),path_relative:d((e,t)=>U(y(t),y(e)),"path_relative"),snake_case:d(e=>Ue(y(e)),"snake_case"),upper_case:d(e=>y(e).toUpperCase(),"upper_case"),upper_kebab_case:d(e=>Je(y(e)),"upper_kebab_case"),upper_snake_case:d(e=>Ee(y(e)),"upper_snake_case")};d(e=>Object.hasOwn(P,e),"isKnownFilter");const V=d((e,t,n=[])=>{const r=P[e];if(!r)throw new Error(`Unknown filter "${e}". Known filters: ${Object.keys(P).sort().join(", ")}.`);return r(t,...n)},"applyFilter");var Ye=Object.defineProperty,B=h((e,t)=>Ye(e,"name",{value:t,configurable:!0}),"d$1");const D=B(e=>{const t=[];let n=0,r=0,i,a=-1;for(const o of e){if(a+=1,i){o===i&&(i=void 0);continue}if(o==='"'||o==="'"){i=o;continue}o==="("?n+=1:o===")"?n-=1:o===","&&n===0&&(t.push(e.slice(r,a)),r=a+1)}return t.push(e.slice(r)),t},"splitCommaOutsideQuotes"),He=B(e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},"stripQuotes");var Xe=Object.defineProperty,w=h((e,t)=>Xe(e,"name",{value:t,configurable:!0}),"s$1");const Ze=/\[([^\]]+)\]/g,et=w(e=>{const t=e.trim(),n=t.indexOf("(");if(n===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const r=t.slice(0,n).trim(),i=t.slice(n+1,-1).trim();return i===""?{args:[],name:r}:{args:D(i).map(a=>{const o=a.trim();return He(o)??o}),name:r}},"parseFilterCall"),tt=w(e=>{const t=e.split("|").map(r=>r.trim()),n=t[0]??"";if(!n)throw new Error(`Empty variable name in expression "${e}"`);return{filters:t.slice(1).map(r=>et(r)),name:n}},"parsePipe"),rt=w(e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),"stringify"),nt=w((e,t)=>{const n=e.replaceAll(Ze,(r,i)=>{const{filters:a,name:o}=tt(i);if(!Object.hasOwn(t,o))throw new Error(`Variable "${o}" used in filename "${e}" but not defined`);let s=t[o];for(const l of a)s=V(l.name,s,l.args);return rt(s)});return J(n)},"interpolateFilename"),J=w(e=>e.split("/").map(t=>t.endsWith(".tera")||t.endsWith(".twig")?t.slice(0,-5):t).join("/"),"stripTeraSuffix"),it=w(e=>e.endsWith(".raw")?e.slice(0,-4):e,"stripRawSuffix"),at=w(e=>{const t=e.split("/");return(t.at(-1)??"").startsWith("_")?!0:t.slice(0,-1).includes("partials")},"isPartialPath");var ot=Object.defineProperty,st=h((e,t)=>ot(e,"name",{value:t,configurable:!0}),"i");const lt=st((e,t)=>{if(!e.startsWith(`---
|
|
2
2
|
`)&&!e.startsWith(`---\r
|
|
3
3
|
`))return{body:e};const n=e.indexOf(`
|
|
4
4
|
---`,3);if(n===-1)return{body:e};let r=n+1+3;e[r]==="\r"&&(r+=1),e[r]===`
|
|
5
5
|
`&&(r+=1);const i=e.startsWith(`---\r
|
|
6
6
|
`)?5:4,a=e.slice(i,n).replaceAll("\r","");let o;try{o=t(a)}catch(s){const l=s instanceof Error?s.message:String(s);throw new Error(`Failed to parse frontmatter YAML: ${l}`,{cause:s})}if(o==null)return{body:e.slice(r)};if(typeof o!="object"||Array.isArray(o))throw new TypeError(`Frontmatter must be a YAML mapping, got ${Array.isArray(o)?"array":typeof o}`);return{body:e.slice(r),frontmatter:o}},"splitFrontmatter");var ct=Object.defineProperty,f=h((e,t)=>ct(e,"name",{value:t,configurable:!0}),"c");const ft=/\{\{-?(.+?)-?\}\}|\{%-?(.+?)-?%\}/gs,K=f(e=>{const t=[];let n=0,r=1;const i=f(a=>{for(const o of a)o===`
|
|
7
|
-
`&&(r+=1)},"advanceLine");for(const a of e.matchAll(ft)){const o=a.index??0;if(o>n){const c=e.slice(n,o);t.push({line:r,type:"text",value:c}),i(c)}const s=r,l=a[0];l.startsWith("{{")?t.push({line:s,type:"expr",value:(a[1]??"").trim()}):t.push({line:s,type:"stmt",value:(a[2]??"").trim()}),i(l),n=o+l.length}if(n<e.length){const a=e.slice(n);t.push({line:r,type:"text",value:a})}return t},"tokenize"),ut=new Set(["block","endblock","endfilter","endmacro","extends","filter","import","macro","set"]),Y=f((e,t)=>{let n=0;const r=f((a,o)=>{throw new Error(`${t}:${a}: ${o}`)},"error"),i=f(a=>{const o=[];for(;n<e.length;){const s=e[n];if(s.type==="text"){o.push({type:"text",value:s.value}),n+=1;continue}if(s.type==="expr"){o.push({expression:s.value,line:s.line,type:"expr"}),n+=1;continue}const l=s.value.split(/\s+/)[0]??"";if(a.includes(l))return o;if(ut.has(l)&&r(s.line,`Tera feature "{% ${l} %}" is not supported. Supported: if/else/endif, for/endfor, include. Rewrite the template to avoid macros, set, extends, block, and import.`),l==="if"){n+=1;const c=s.value.slice(2).trim(),m=i(["else","endif"]);let u;n<e.length&&e[n].type==="stmt"&&e[n].value.split(/\s+/)[0]==="else"&&(n+=1,u=i(["endif"])),(n>=e.length||e[n].type!=="stmt"||e[n].value.split(/\s+/)[0]!=="endif")&&r(s.line,"Unterminated {% if %} — missing {% endif %}"),n+=1,o.push({alternate:u,condition:c,consequent:m,line:s.line,type:"if"});continue}if(l==="for"){n+=1;const c=s.value.slice(3).trim(),m=c.indexOf(" in ");m===-1&&r(s.line,"Malformed {% for %} — expected `for <name> in <collection>`");const u=c.slice(0,m).trim(),g=c.slice(m+4).trim();(!u||!g)&&r(s.line,"Malformed {% for %} — missing binding or collection");const p=i(["endfor"]);(n>=e.length||e[n].type!=="stmt"||e[n].value.split(/\s+/)[0]!=="endfor")&&r(s.line,"Unterminated {% for %} — missing {% endfor %}"),n+=1,o.push({binding:u,body:p,collection:g,line:s.line,type:"for"});continue}if(l==="include"){n+=1;const c=s.value.slice(7).trim(),m=H(c);m===void 0&&r(s.line,"Malformed {% include %} — expected a quoted partial name"),o.push({line:s.line,name:m,type:"include"});continue}r(s.line,`Unknown tag "{% ${l} %}". Supported: if, for, include.`)}return o},"parseBlock");return i([])},"parse"),H=f(e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},"stripQuotes"),pt=f(e=>e==null?"":typeof e=="boolean"||typeof e=="number"?String(e):typeof e=="string"?e:JSON.stringify(e),"stringify"),mt=f(e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:!0,"isTruthy"),X=f((e,t,n,r,i=!0)=>{const a=e.split(".");if(i&&a.length>0&&!Object.hasOwn(t,a[0]))throw new Error(`${r}:${n}: Variable "${e}" is not defined`);let o=t;for(const s of a){if(o==null)return;if(typeof o!="object")throw new TypeError(`${r}:${n}: Cannot read "${s}" on non-object value`);o=o[s]}return o},"lookupVariable"),dt=f(e=>{const t=[];let n=0,r=0,i;for(let a=0;a<e.length;a+=1){const o=e[a];if(i){o===i&&(i=void 0);continue}if(o==='"'||o==="'"){i=o;continue}o==="("?n+=1:o===")"?n-=1:o==="|"&&n===0&&(t.push(e.slice(r,a)),r=a+1)}return t.push(e.slice(r)),t},"splitFilterPipe"),ht=f(e=>{const t=e.trim(),n=t.indexOf("(");if(n===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const r=t.slice(0,n).trim(),i=t.slice(n+1,-1).trim();return i?{args:B(i).map(a=>a.trim()),name:r}:{args:[],name:r}},"parseFilterCall"),k=f((e,t,n,r,i=!0)=>{const a=e.trim();if(a==="true")return!0;if(a==="false")return!1;if(a==="null"||a==="none")return null;const o=H(a);return o!==void 0?o:/^-?\d+(?:\.\d+)?$/.test(a)?Number(a):X(a,t,n,r,i)},"evaluatePrimary"),Z=f((e,t,n,r,i=!0)=>{const a=dt(e),o=a[0].trim();let s=k(o,t,n,r,i);for(let l=1;l<a.length;l+=1){const c=a[l].trim(),{args:m,name:u}=ht(c),g=m.map(p=>k(p,t,n,r,i));try{s=G(u,s,g)}catch(p){const $=p instanceof Error?p.message:String(p);throw new Error(`${r}:${n}: ${$}`,{cause:p})}}return s},"evaluateExpression"),ee=f((e,t)=>{let n,r=0;for(let i=0;i<=e.length-t.length;i+=1){const a=e[i];if(n){a===n&&(n=void 0);continue}if(a==='"'||a==="'"){n=a;continue}if(a==="("){r+=1;continue}if(a===")"){r-=1;continue}if(r===0&&e.slice(i,i+t.length)===t)return i}return-1},"findOperatorOutsideQuotes"),N=f((e,t)=>{const n=[];let r=0,i=0;for(;i<=e.length-t.length;){const a=ee(e.slice(i),t);if(a===-1)break;n.push(e.slice(r,i+a)),i+=a+t.length,r=i}return n.push(e.slice(r)),n},"splitLogical"),j=f((e,t,n,r)=>{const i=e.trim();if(i==="")return!1;if(i.startsWith("(")&&i.endsWith(")")&&yt(i)===i.length-1)return j(i.slice(1,-1),t,n,r);const a=N(i," or ");if(a.length>1)return a.some(s=>j(s,t,n,r));const o=N(i," and ");if(o.length>1)return o.every(s=>j(s,t,n,r));if(i.startsWith("not "))return!j(i.slice(4),t,n,r);for(const s of["==","!="]){const l=ee(i,s);if(l!==-1){const c=k(i.slice(0,l),t,r,n,!1),m=k(i.slice(l+s.length),t,r,n,!1),u=c===m;return s==="=="?u:!u}}return mt(Z(i,t,r,n,!1))},"evaluateConditionExpression"),yt=f(e=>{if(e[0]!=="(")return-1;let t=0,n,r=-1;for(const i of e){if(r+=1,n){i===n&&(n=void 0);continue}if(i==='"'||i==="'"){n=i;continue}if(i==="(")t+=1;else if(i===")"&&(t-=1,t===0))return r}return-1},"matchingParen"),O=f((e,t)=>{let n="";for(const r of e){if(r.type==="text"){n+=r.value;continue}if(r.type==="expr"){n+=pt(Z(r.expression,t.scope,r.line,t.filename));continue}if(r.type==="if"){const i=j(r.condition,t.scope,t.filename,r.line)?r.consequent:r.alternate??[];n+=O(i,t);continue}if(r.type==="for"){const i=X(r.collection,t.scope,r.line,t.filename,!1);if(i==null)continue;if(!Array.isArray(i))throw new TypeError(`${t.filename}:${r.line}: {% for %} expected an array, got ${typeof i}`);for(const a of i){const o={...t.scope,[r.binding]:a};n+=O(r.body,{...t,scope:o})}continue}if(r.type==="include"){const i=t.partials?.get(r.name);if(!i)throw new Error(`${t.filename}:${r.line}: Partial "${r.name}" not found. Available: ${[...t.partials?.keys()??[]].join(", ")||"(none)"}`);const a=t.includeStack??new Set;if(a.has(r.name)){const o=[...a,r.name].join(" → ");throw new Error(`${t.filename}:${r.line}: Circular partial include detected: ${o}`)}a.add(r.name);try{n+=O(i,{...t,filename:`<partial:${r.name}>`,includeStack:a})}finally{a.delete(r.name)}}}return n},"renderNodes"),bt=f((e,t)=>Y(K(e),t),"parseTemplate");f((e,t)=>O(e,t),"renderAst");const C=f((e,t)=>O(Y(K(e),t.filename),t),"renderTemplate");var gt=Object.defineProperty,b=h((e,t)=>gt(e,"name",{value:t,configurable:!0}),"s");const R="template.yml",vt=".raw",$t=new Set([".cjs",".css",".env",".gitattributes",".gitignore",".graphql",".html",".ini",".js",".json",".json5",".jsonc",".jsx",".lock",".md",".mdx",".mjs",".prettierrc",".raw",".rs",".scss",".sh",".sql",".svg",".tera",".toml",".ts",".tsx",".twig",".txt",".vue",".xml",".yaml",".yml"]),wt=new Set(["Brewfile","CHANGELOG","CODEOWNERS","CONTRIBUTING","COPYING","Dockerfile","Gemfile","LICENCE","LICENSE","Makefile","NOTICE","Procfile","Rakefile","README","VERSION"]),jt=b(e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),n=t===-1?e:e.slice(t+1),r=n.lastIndexOf(".");return r===-1||r===0?"":n.slice(r).toLowerCase()},"lastDot"),te=b(e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?e:e.slice(t+1)},"basename"),Ot=b(e=>{const t=jt(e);if(t!=="")return $t.has(t);const n=te(e);return wt.has(n)},"isLikelyText"),Et=b(e=>{const t={default:e.default,internal:e.internal,order:e.order,prompt:e.prompt,required:e.required};switch(e.type){case"array":return{...t,type:"array"};case"boolean":return{...t,default:typeof t.default=="boolean"?t.default:void 0,type:"boolean"};case"enum":return{...t,multiple:e.multiple,type:"enum",values:e.values??[]};case"number":return{...t,type:"number"};case"string":return{...t,type:"string"};default:throw new Error(`Unsupported variable type "${String(e.type)}"`)}},"yamlVariableToVariable"),xt=b(e=>e.replaceAll("\\","/").replace(/^\.\//,"").replaceAll(/\/+/g,"/"),"normalizeDestinationPath"),At=b((e,t,n)=>{const r=t.split("/").filter(Boolean);if(r.length===0)throw new Error("Empty destination path for value");let i=e;for(let a=0;a<r.length-1;a+=1){const o=r[a],s=i[o];if(s===void 0){const l={};i[o]=l,i=l}else if(typeof s=="object"&&!Buffer.isBuffer(s))i=s;else throw new TypeError(`Path conflict: "${r.slice(0,a+1).join("/")}" is both a file and a directory`)}i[r.at(-1)]=n},"flattenFiles"),I=b((e,t,n)=>{if(typeof e!="string")return kt(e);const r=e.includes("{{")||e.includes("{%")?C(e,{filename:`${n}#frontmatter`,scope:t}):e;return j(r,t,`${n}#frontmatter`,1)},"evaluateGate"),kt=b(e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e!=="false"&&e!=="0":!0,"truthyValue"),Wt=b((e,t)=>{const n=D(e,R),r=oe(n);if(!r||typeof r!="object")throw new Error(`${n}: must contain a YAML mapping`);const i={};if(r.variables)for(const[l,c]of Object.entries(r.variables))i[l]=Et(c);const a=new Map,o=[];for(const l of se(e,{includeDirs:!1,includeSymlinks:!1})){if(l.path===n)continue;const c=Q(e,l.path).replaceAll("\\","/");if(c===R)continue;if(at(c)){const u=A(l.path),g=bt(u,c);for(const p of Pt(c))a.has(p)&&a.get(p)!==g&&le.warn(`partial name "${p}" is declared by multiple files — last one wins. Use distinct names or fully-qualified includes.`),a.set(p,g);continue}if(c.endsWith(vt)){const u=A(l.path);o.push({binary:null,isRaw:!0,rawText:u,relativePath:c});continue}if(Ot(c)){const u=A(l.path);o.push({binary:null,isRaw:!1,rawText:u,relativePath:c});continue}const m=A(l.path,{buffer:!0});o.push({binary:m,isRaw:!1,rawText:null,relativePath:c})}const s=b(l=>{const c={...l.builtins,...l.options},m={},u={};for(const p of o){const $=p.relativePath;let x,L,M=!1;if(p.binary)x=p.binary;else if(p.isRaw)x=p.rawText??"";else{const re=p.rawText??"",v=lt(re,ne=>ce(ne));if(v.frontmatter){if(v.frontmatter.skip!==void 0&&I(v.frontmatter.skip,c,$)||v.frontmatter.if!==void 0&&!I(v.frontmatter.if,c,$))continue;typeof v.frontmatter.to=="string"&&(L=C(v.frontmatter.to,{filename:`${$}#frontmatter.to`,partials:a,scope:c})),v.frontmatter.force===!0&&(M=!0)}x=C(v.body,{filename:$,partials:a,scope:c})}const F=xt(L??nt(it($),c));At(m,F,x),M&&(u[F]={force:!0})}const g={files:m};return Object.keys(u).length>0&&(g.filesMeta=u),g},"produce");return{about:{description:r.description??`Moon-format template at ${e}`,name:r.title??t},destination:r.destination,options:i,produce:s}},"loadMoonTemplate"),Pt=b(e=>{const t=J(e),n=te(t),r=new Set([n,t]);if(n.startsWith("_")){r.add(n.replace(/^_+/,""));const i=t.slice(0,t.length-n.length);r.add(`${i}${n.replace(/^_+/,"")}`)}return[...r]},"partialKeys");export{Wt as loadMoonTemplate};
|
|
7
|
+
`&&(r+=1)},"advanceLine");for(const a of e.matchAll(ft)){const o=a.index??0;if(o>n){const c=e.slice(n,o);t.push({line:r,type:"text",value:c}),i(c)}const s=r,l=a[0];l.startsWith("{{")?t.push({line:s,type:"expr",value:(a[1]??"").trim()}):t.push({line:s,type:"stmt",value:(a[2]??"").trim()}),i(l),n=o+l.length}if(n<e.length){const a=e.slice(n);t.push({line:r,type:"text",value:a})}return t},"tokenize"),ut=new Set(["block","endblock","endfilter","endmacro","extends","filter","import","macro","set"]),Y=f((e,t)=>{let n=0;const r=f((a,o)=>{throw new Error(`${t}:${a}: ${o}`)},"error"),i=f(a=>{const o=[];for(;n<e.length;){const s=e[n];if(s.type==="text"){o.push({type:"text",value:s.value}),n+=1;continue}if(s.type==="expr"){o.push({expression:s.value,line:s.line,type:"expr"}),n+=1;continue}const l=s.value.split(/\s+/)[0]??"";if(a.includes(l))return o;if(ut.has(l)&&r(s.line,`Tera feature "{% ${l} %}" is not supported. Supported: if/else/endif, for/endfor, include. Rewrite the template to avoid macros, set, extends, block, and import.`),l==="if"){n+=1;const c=s.value.slice(2).trim(),m=i(["else","endif"]);let u;n<e.length&&e[n].type==="stmt"&&e[n].value.split(/\s+/)[0]==="else"&&(n+=1,u=i(["endif"])),(n>=e.length||e[n].type!=="stmt"||e[n].value.split(/\s+/)[0]!=="endif")&&r(s.line,"Unterminated {% if %} — missing {% endif %}"),n+=1,o.push({alternate:u,condition:c,consequent:m,line:s.line,type:"if"});continue}if(l==="for"){n+=1;const c=s.value.slice(3).trim(),m=c.indexOf(" in ");m===-1&&r(s.line,"Malformed {% for %} — expected `for <name> in <collection>`");const u=c.slice(0,m).trim(),g=c.slice(m+4).trim();(!u||!g)&&r(s.line,"Malformed {% for %} — missing binding or collection");const p=i(["endfor"]);(n>=e.length||e[n].type!=="stmt"||e[n].value.split(/\s+/)[0]!=="endfor")&&r(s.line,"Unterminated {% for %} — missing {% endfor %}"),n+=1,o.push({binding:u,body:p,collection:g,line:s.line,type:"for"});continue}if(l==="include"){n+=1;const c=s.value.slice(7).trim(),m=H(c);m===void 0&&r(s.line,"Malformed {% include %} — expected a quoted partial name"),o.push({line:s.line,name:m,type:"include"});continue}r(s.line,`Unknown tag "{% ${l} %}". Supported: if, for, include.`)}return o},"parseBlock");return i([])},"parse"),H=f(e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},"stripQuotes"),pt=f(e=>e==null?"":typeof e=="boolean"||typeof e=="number"?String(e):typeof e=="string"?e:JSON.stringify(e),"stringify"),mt=f(e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:!0,"isTruthy"),X=f((e,t,n,r,i=!0)=>{const a=e.split(".");if(i&&a.length>0&&!Object.hasOwn(t,a[0]))throw new Error(`${r}:${n}: Variable "${e}" is not defined`);let o=t;for(const s of a){if(o==null)return;if(typeof o!="object")throw new TypeError(`${r}:${n}: Cannot read "${s}" on non-object value`);o=o[s]}return o},"lookupVariable"),dt=f(e=>{const t=[];let n=0,r=0,i;for(let a=0;a<e.length;a+=1){const o=e[a];if(i){o===i&&(i=void 0);continue}if(o==='"'||o==="'"){i=o;continue}o==="("?n+=1:o===")"?n-=1:o==="|"&&n===0&&(t.push(e.slice(r,a)),r=a+1)}return t.push(e.slice(r)),t},"splitFilterPipe"),ht=f(e=>{const t=e.trim(),n=t.indexOf("(");if(n===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const r=t.slice(0,n).trim(),i=t.slice(n+1,-1).trim();return i?{args:D(i).map(a=>a.trim()),name:r}:{args:[],name:r}},"parseFilterCall"),k=f((e,t,n,r,i=!0)=>{const a=e.trim();if(a==="true")return!0;if(a==="false")return!1;if(a==="null"||a==="none")return null;const o=H(a);return o!==void 0?o:/^-?\d+(?:\.\d+)?$/.test(a)?Number(a):X(a,t,n,r,i)},"evaluatePrimary"),Z=f((e,t,n,r,i=!0)=>{const a=dt(e),o=a[0].trim();let s=k(o,t,n,r,i);for(let l=1;l<a.length;l+=1){const c=a[l].trim(),{args:m,name:u}=ht(c),g=m.map(p=>k(p,t,n,r,i));try{s=V(u,s,g)}catch(p){const $=p instanceof Error?p.message:String(p);throw new Error(`${r}:${n}: ${$}`,{cause:p})}}return s},"evaluateExpression"),ee=f((e,t)=>{let n,r=0;for(let i=0;i<=e.length-t.length;i+=1){const a=e[i];if(n){a===n&&(n=void 0);continue}if(a==='"'||a==="'"){n=a;continue}if(a==="("){r+=1;continue}if(a===")"){r-=1;continue}if(r===0&&e.slice(i,i+t.length)===t)return i}return-1},"findOperatorOutsideQuotes"),N=f((e,t)=>{const n=[];let r=0,i=0;for(;i<=e.length-t.length;){const a=ee(e.slice(i),t);if(a===-1)break;n.push(e.slice(r,i+a)),i+=a+t.length,r=i}return n.push(e.slice(r)),n},"splitLogical"),j=f((e,t,n,r)=>{const i=e.trim();if(i==="")return!1;if(i.startsWith("(")&&i.endsWith(")")&&yt(i)===i.length-1)return j(i.slice(1,-1),t,n,r);const a=N(i," or ");if(a.length>1)return a.some(s=>j(s,t,n,r));const o=N(i," and ");if(o.length>1)return o.every(s=>j(s,t,n,r));if(i.startsWith("not "))return!j(i.slice(4),t,n,r);for(const s of["==","!="]){const l=ee(i,s);if(l!==-1){const c=k(i.slice(0,l),t,r,n,!1),m=k(i.slice(l+s.length),t,r,n,!1),u=c===m;return s==="=="?u:!u}}return mt(Z(i,t,r,n,!1))},"evaluateConditionExpression"),yt=f(e=>{if(e[0]!=="(")return-1;let t=0,n,r=-1;for(const i of e){if(r+=1,n){i===n&&(n=void 0);continue}if(i==='"'||i==="'"){n=i;continue}if(i==="(")t+=1;else if(i===")"&&(t-=1,t===0))return r}return-1},"matchingParen"),O=f((e,t)=>{let n="";for(const r of e){if(r.type==="text"){n+=r.value;continue}if(r.type==="expr"){n+=pt(Z(r.expression,t.scope,r.line,t.filename));continue}if(r.type==="if"){const i=j(r.condition,t.scope,t.filename,r.line)?r.consequent:r.alternate??[];n+=O(i,t);continue}if(r.type==="for"){const i=X(r.collection,t.scope,r.line,t.filename,!1);if(i==null)continue;if(!Array.isArray(i))throw new TypeError(`${t.filename}:${r.line}: {% for %} expected an array, got ${typeof i}`);for(const a of i){const o={...t.scope,[r.binding]:a};n+=O(r.body,{...t,scope:o})}continue}if(r.type==="include"){const i=t.partials?.get(r.name);if(!i)throw new Error(`${t.filename}:${r.line}: Partial "${r.name}" not found. Available: ${[...t.partials?.keys()??[]].join(", ")||"(none)"}`);const a=t.includeStack??new Set;if(a.has(r.name)){const o=[...a,r.name].join(" → ");throw new Error(`${t.filename}:${r.line}: Circular partial include detected: ${o}`)}a.add(r.name);try{n+=O(i,{...t,filename:`<partial:${r.name}>`,includeStack:a})}finally{a.delete(r.name)}}}return n},"renderNodes"),bt=f((e,t)=>Y(K(e),t),"parseTemplate");f((e,t)=>O(e,t),"renderAst");const C=f((e,t)=>O(Y(K(e),t.filename),t),"renderTemplate");var gt=Object.defineProperty,b=h((e,t)=>gt(e,"name",{value:t,configurable:!0}),"s");const R="template.yml",vt=".raw",$t=new Set([".cjs",".css",".env",".gitattributes",".gitignore",".graphql",".html",".ini",".js",".json",".json5",".jsonc",".jsx",".lock",".md",".mdx",".mjs",".prettierrc",".raw",".rs",".scss",".sh",".sql",".svg",".tera",".toml",".ts",".tsx",".twig",".txt",".vue",".xml",".yaml",".yml"]),wt=new Set(["Brewfile","CHANGELOG","CODEOWNERS","CONTRIBUTING","COPYING","Dockerfile","Gemfile","LICENCE","LICENSE","Makefile","NOTICE","Procfile","Rakefile","README","VERSION"]),jt=b(e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),n=t===-1?e:e.slice(t+1),r=n.lastIndexOf(".");return r===-1||r===0?"":n.slice(r).toLowerCase()},"lastDot"),te=b(e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?e:e.slice(t+1)},"basename"),Ot=b(e=>{const t=jt(e);if(t!=="")return $t.has(t);const n=te(e);return wt.has(n)},"isLikelyText"),Et=b(e=>{const t={default:e.default,internal:e.internal,order:e.order,prompt:e.prompt,required:e.required};switch(e.type){case"array":return{...t,type:"array"};case"boolean":return{...t,default:typeof t.default=="boolean"?t.default:void 0,type:"boolean"};case"enum":return{...t,multiple:e.multiple,type:"enum",values:e.values??[]};case"number":return{...t,type:"number"};case"string":return{...t,type:"string"};default:throw new Error(`Unsupported variable type "${String(e.type)}"`)}},"yamlVariableToVariable"),xt=b(e=>e.replaceAll("\\","/").replace(/^\.\//,"").replaceAll(/\/+/g,"/"),"normalizeDestinationPath"),At=b((e,t,n)=>{const r=t.split("/").filter(Boolean);if(r.length===0)throw new Error("Empty destination path for value");let i=e;for(let a=0;a<r.length-1;a+=1){const o=r[a],s=i[o];if(s===void 0){const l={};i[o]=l,i=l}else if(typeof s=="object"&&!Buffer.isBuffer(s))i=s;else throw new TypeError(`Path conflict: "${r.slice(0,a+1).join("/")}" is both a file and a directory`)}i[r.at(-1)]=n},"flattenFiles"),I=b((e,t,n)=>{if(typeof e!="string")return kt(e);const r=e.includes("{{")||e.includes("{%")?C(e,{filename:`${n}#frontmatter`,scope:t}):e;return j(r,t,`${n}#frontmatter`,1)},"evaluateGate"),kt=b(e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e!=="false"&&e!=="0":!0,"truthyValue"),Tt=b((e,t)=>{const n=z(e,R),r=ae(n);if(!r||typeof r!="object")throw new Error(`${n}: must contain a YAML mapping`);const i={};if(r.variables)for(const[l,c]of Object.entries(r.variables))i[l]=Et(c);const a=new Map,o=[];for(const l of oe(e,{includeDirs:!1,includeSymlinks:!1})){if(l.path===n)continue;const c=U(e,l.path).replaceAll("\\","/");if(c===R)continue;if(at(c)){const u=A(l.path),g=bt(u,c);for(const p of Pt(c))a.has(p)&&a.get(p)!==g&&se.warn(`partial name "${p}" is declared by multiple files — last one wins. Use distinct names or fully-qualified includes.`),a.set(p,g);continue}if(c.endsWith(vt)){const u=A(l.path);o.push({binary:null,isRaw:!0,rawText:u,relativePath:c});continue}if(Ot(c)){const u=A(l.path);o.push({binary:null,isRaw:!1,rawText:u,relativePath:c});continue}const m=A(l.path,{buffer:!0});o.push({binary:m,isRaw:!1,rawText:null,relativePath:c})}const s=b(l=>{const c={...l.builtins,...l.options},m={},u={};for(const p of o){const $=p.relativePath;let x,L,M=!1;if(p.binary)x=p.binary;else if(p.isRaw)x=p.rawText??"";else{const re=p.rawText??"",v=lt(re,ne=>le(ne));if(v.frontmatter){if(v.frontmatter.skip!==void 0&&I(v.frontmatter.skip,c,$)||v.frontmatter.if!==void 0&&!I(v.frontmatter.if,c,$))continue;typeof v.frontmatter.to=="string"&&(L=C(v.frontmatter.to,{filename:`${$}#frontmatter.to`,partials:a,scope:c})),v.frontmatter.force===!0&&(M=!0)}x=C(v.body,{filename:$,partials:a,scope:c})}const F=xt(L??nt(it($),c));At(m,F,x),M&&(u[F]={force:!0})}const g={files:m};return Object.keys(u).length>0&&(g.filesMeta=u),g},"produce");return{about:{description:r.description??`Moon-format template at ${e}`,name:r.title??t},destination:r.destination,options:i,produce:s}},"loadMoonTemplate"),Pt=b(e=>{const t=J(e),n=te(t),r=new Set([n,t]);if(n.startsWith("_")){r.add(n.replace(/^_+/,""));const i=t.slice(0,t.length-n.length);r.add(`${i}${n.replace(/^_+/,"")}`)}return[...r]},"partialKeys");export{Tt as loadMoonTemplate};
|