@visulima/vis 1.0.0-alpha.3 → 1.0.0-alpha.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/CHANGELOG.md +1117 -24
  2. package/LICENSE.md +11958 -0
  3. package/README.md +344 -20
  4. package/dashboard/dist/index.html +152 -0
  5. package/dist/bin.js +1 -146
  6. package/dist/binx.js +3 -0
  7. package/dist/config/index.d.ts +3154 -0
  8. package/dist/config/index.js +1 -0
  9. package/dist/generate/index.d.ts +157 -0
  10. package/dist/generate/index.js +1 -0
  11. package/dist/packem_chunks/bin.js +1415 -0
  12. package/dist/packem_chunks/bloom-status.js +2 -0
  13. package/dist/packem_chunks/bloom-sync.js +2 -0
  14. package/dist/packem_chunks/cache-attestation.js +1 -0
  15. package/dist/packem_chunks/config.js +19 -0
  16. package/dist/packem_chunks/devtools.js +82 -0
  17. package/dist/packem_chunks/doctor-probe.js +2 -0
  18. package/dist/packem_chunks/fix.js +11 -0
  19. package/dist/packem_chunks/handler.js +1 -0
  20. package/dist/packem_chunks/handler10.js +1 -0
  21. package/dist/packem_chunks/handler11.js +5 -0
  22. package/dist/packem_chunks/handler12.js +1 -0
  23. package/dist/packem_chunks/handler13.js +27 -0
  24. package/dist/packem_chunks/handler14.js +5 -0
  25. package/dist/packem_chunks/handler15.js +1 -0
  26. package/dist/packem_chunks/handler16.js +1 -0
  27. package/dist/packem_chunks/handler17.js +1 -0
  28. package/dist/packem_chunks/handler18.js +1 -0
  29. package/dist/packem_chunks/handler19.js +1 -0
  30. package/dist/packem_chunks/handler2.js +4 -0
  31. package/dist/packem_chunks/handler20.js +5 -0
  32. package/dist/packem_chunks/handler21.js +2 -0
  33. package/dist/packem_chunks/handler22.js +2 -0
  34. package/dist/packem_chunks/handler23.js +1 -0
  35. package/dist/packem_chunks/handler24.js +1 -0
  36. package/dist/packem_chunks/handler25.js +5 -0
  37. package/dist/packem_chunks/handler26.js +1 -0
  38. package/dist/packem_chunks/handler27.js +3 -0
  39. package/dist/packem_chunks/handler28.js +1 -0
  40. package/dist/packem_chunks/handler29.js +7 -0
  41. package/dist/packem_chunks/handler3.js +4 -0
  42. package/dist/packem_chunks/handler30.js +33 -0
  43. package/dist/packem_chunks/handler31.js +3 -0
  44. package/dist/packem_chunks/handler32.js +8 -0
  45. package/dist/packem_chunks/handler33.js +1 -0
  46. package/dist/packem_chunks/handler34.js +5 -0
  47. package/dist/packem_chunks/handler35.js +11 -0
  48. package/dist/packem_chunks/handler36.js +3 -0
  49. package/dist/packem_chunks/handler37.js +22 -0
  50. package/dist/packem_chunks/handler38.js +61 -0
  51. package/dist/packem_chunks/handler39.js +3 -0
  52. package/dist/packem_chunks/handler4.js +6 -0
  53. package/dist/packem_chunks/handler40.js +6 -0
  54. package/dist/packem_chunks/handler41.js +24 -0
  55. package/dist/packem_chunks/handler42.js +153 -0
  56. package/dist/packem_chunks/handler43.js +25 -0
  57. package/dist/packem_chunks/handler44.js +10 -0
  58. package/dist/packem_chunks/handler45.js +708 -0
  59. package/dist/packem_chunks/handler46.js +24 -0
  60. package/dist/packem_chunks/handler47.js +322 -0
  61. package/dist/packem_chunks/handler48.js +48 -0
  62. package/dist/packem_chunks/handler49.js +3 -0
  63. package/dist/packem_chunks/handler5.js +8 -0
  64. package/dist/packem_chunks/handler50.js +27 -0
  65. package/dist/packem_chunks/handler51.js +195 -0
  66. package/dist/packem_chunks/handler52.js +34 -0
  67. package/dist/packem_chunks/handler6.js +1 -0
  68. package/dist/packem_chunks/handler7.js +1 -0
  69. package/dist/packem_chunks/handler8.js +1 -0
  70. package/dist/packem_chunks/handler9.js +1 -0
  71. package/dist/packem_chunks/heal-accept.js +10 -0
  72. package/dist/packem_chunks/heal.js +14 -0
  73. package/dist/packem_chunks/help-command.js +8 -0
  74. package/dist/packem_chunks/index.js +7 -0
  75. package/dist/packem_chunks/keys-refresh.js +4 -0
  76. package/dist/packem_chunks/list.js +3 -0
  77. package/dist/packem_chunks/loader.js +4 -0
  78. package/dist/packem_chunks/loader2.js +1 -0
  79. package/dist/packem_chunks/prune.js +3 -0
  80. package/dist/packem_chunks/run.js +1 -0
  81. package/dist/packem_chunks/status.js +2 -0
  82. package/dist/packem_chunks/sync.js +2 -0
  83. package/dist/packem_chunks/sync2.js +2 -0
  84. package/dist/packem_chunks/tar.js +3 -0
  85. package/dist/packem_chunks/tripwire.js +2 -0
  86. package/dist/packem_chunks/verify-lockfile.js +2 -0
  87. package/dist/packem_shared/Table-DoSoazT6-DwnyTUsA.js +12 -0
  88. package/dist/packem_shared/_commonjsHelpers-CLblCigl.js +1 -0
  89. package/dist/packem_shared/advisories-BxXiKFbL.js +1 -0
  90. package/dist/packem_shared/affected-shas-BdnlfiV1.js +1 -0
  91. package/dist/packem_shared/ai-analysis-KP8b5lc0.js +68 -0
  92. package/dist/packem_shared/ai-fix-BkPUHA0z.js +43 -0
  93. package/dist/packem_shared/anolilab-text-CAM_E6uK.js +13 -0
  94. package/dist/packem_shared/applyDefaults-BogleaFi.js +1 -0
  95. package/dist/packem_shared/build-scripts-DE6U8jVq.js +1 -0
  96. package/dist/packem_shared/cyclonedx-BpGVHqSW.js +4 -0
  97. package/dist/packem_shared/definePlugin-CWm4Dv_t.js +1 -0
  98. package/dist/packem_shared/dependency-scan-BUbOcMwX.js +1 -0
  99. package/dist/packem_shared/docker-CTE3s4LW.js +60 -0
  100. package/dist/packem_shared/failure-log-34Wl3npC.js +2 -0
  101. package/dist/packem_shared/giget-CcEy_Elm.js +2 -0
  102. package/dist/packem_shared/glob-D_7bct6p-D8itOHsr.js +1 -0
  103. package/dist/packem_shared/index-D1xC1Y_R.js +1 -0
  104. package/dist/packem_shared/index-DH-5hsrC.js +1 -0
  105. package/dist/packem_shared/index-hoWfZmNo.js +30 -0
  106. package/dist/packem_shared/license-zZU7aavK.js +1 -0
  107. package/dist/packem_shared/lifecycle-CXaqPGAQ.js +2 -0
  108. package/dist/packem_shared/lockfile-CrT86D6d.js +1 -0
  109. package/dist/packem_shared/lockfile-Cu2BH6bl.js +1 -0
  110. package/dist/packem_shared/manifests-BzWpKW8F.js +1 -0
  111. package/dist/packem_shared/min-release-age-BPVXwPUg.js +34 -0
  112. package/dist/packem_shared/native-config-sync-BRZZetn3.js +21 -0
  113. package/dist/packem_shared/osv-bloom-DSZcHLsM.js +2 -0
  114. package/dist/packem_shared/otelPlugin-CJR2T_lk.js +1 -0
  115. package/dist/packem_shared/peer-warnings-EvSJ18gE.js +1 -0
  116. package/dist/packem_shared/pm-runner-DmKT2FqF.js +1 -0
  117. package/dist/packem_shared/provenance-DkCA8BrN.js +1 -0
  118. package/dist/packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js +1 -0
  119. package/dist/packem_shared/registry-keys-Mixm4eAY.js +1 -0
  120. package/dist/packem_shared/resolve-explicit-D5E72FfN.js +5 -0
  121. package/dist/packem_shared/runtime-check-CilFOqUU.js +1 -0
  122. package/dist/packem_shared/s1ngularity-Qxc6tRRI.js +1 -0
  123. package/dist/packem_shared/scan-progress-DVtCtI2z.js +2 -0
  124. package/dist/packem_shared/selectors-DkgYFzdq.js +3 -0
  125. package/dist/packem_shared/signatures-byuFrtAH.js +2 -0
  126. package/dist/packem_shared/spinner-C8xs6QZv.js +1 -0
  127. package/dist/packem_shared/spinners-f91Rbo99-Bjf3NcO0.js +1 -0
  128. package/dist/packem_shared/symbols-CQmER5MT.js +1 -0
  129. package/dist/packem_shared/tabs-xZkm6Y_J.js +1 -0
  130. package/dist/packem_shared/toolchain-DoG6b_G_.js +5 -0
  131. package/dist/packem_shared/typosquats-BiDxQj7R.js +1 -0
  132. package/dist/packem_shared/use-measured-height-Lea6TCVD.js +1 -0
  133. package/dist/packem_shared/utils-DrNg0XTR.js +1 -0
  134. package/dist/packem_shared/verify-cLcZwKqe.js +1 -0
  135. package/dist/packem_shared/vis-update-app-BCKzlqj8.js +1 -0
  136. package/dist/packem_shared/watch-DEL0yol9.js +1 -0
  137. package/dist/packem_shared/watch-loop-C31Ar7BX.js +11 -0
  138. package/index.d.ts +436 -0
  139. package/index.js +613 -0
  140. package/package.json +71 -26
  141. package/schemas/project.schema.json +991 -0
  142. package/schemas/vis-config.schema.json +4958 -0
  143. package/skills/vis/SKILL.md +96 -0
  144. package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
  145. package/templates/buildkite-ci/template.yml +20 -0
  146. package/dist/ai-analysis.d.ts +0 -40
  147. package/dist/ai-cache.d.ts +0 -21
  148. package/dist/bin.d.ts +0 -1
  149. package/dist/catalog.d.ts +0 -110
  150. package/dist/commands/affected.d.ts +0 -3
  151. package/dist/commands/ai.d.ts +0 -3
  152. package/dist/commands/analyze.d.ts +0 -3
  153. package/dist/commands/check.d.ts +0 -3
  154. package/dist/commands/graph.d.ts +0 -3
  155. package/dist/commands/hook/constants.d.ts +0 -8
  156. package/dist/commands/hook/index.d.ts +0 -3
  157. package/dist/commands/hook/install.d.ts +0 -7
  158. package/dist/commands/hook/migrate.d.ts +0 -27
  159. package/dist/commands/hook/uninstall.d.ts +0 -3
  160. package/dist/commands/migrate/constants.d.ts +0 -12
  161. package/dist/commands/migrate/deps.d.ts +0 -32
  162. package/dist/commands/migrate/index.d.ts +0 -3
  163. package/dist/commands/migrate/json.d.ts +0 -20
  164. package/dist/commands/migrate/lint-staged.d.ts +0 -62
  165. package/dist/commands/migrate/types.d.ts +0 -20
  166. package/dist/commands/run.d.ts +0 -3
  167. package/dist/commands/staged.d.ts +0 -3
  168. package/dist/commands/update.d.ts +0 -3
  169. package/dist/config.d.ts +0 -40
  170. package/dist/config.js +0 -1
  171. package/dist/package-manager.d.ts +0 -23
  172. package/dist/workspace.d.ts +0 -58
@@ -0,0 +1,3 @@
1
+ var lr=Object.defineProperty;var f=(e,t)=>lr(e,"name",{value:t,configurable:!0});import{createRequire as dr}from"node:module";import{p as fr}from"../packem_shared/giget-CcEy_Elm.js";const ur=dr(import.meta.url),Me=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,N=f(e=>{if(typeof Me<"u"&&Me.versions&&Me.versions.node){const[t,i]=Me.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return Me.getBuiltinModule(e)}return ur(e)},"__cjs_getBuiltinModule"),d=N("node:fs"),cr=N("node:fs/promises"),As=N("node:stream"),p=N("node:path"),{posix:ve,basename:mr,join:Ds,win32:pr}=p,Ns=N("events"),{EventEmitter:yr}=Ns,b=N("fs"),{EventEmitter:Pi}=N("node:events"),{StringDecoder:br}=N("node:string_decoder"),rt=N("path"),{parse:Er,dirname:gr}=rt,pi=N("assert"),{Buffer:we}=N("buffer"),Xi=N("zlib"),qi={...Xi,default:Xi},wr=N("zlib"),Rr=N("node:assert"),{randomBytes:Is}=N("node:crypto");var _r=Object.defineProperty,o=f((e,t)=>_r(e,"name",{value:t,configurable:!0}),"o"),rn=fr({Header:o(()=>le,"Header"),Pack:o(()=>ot,"Pack"),PackJob:o(()=>ki,"PackJob"),PackSync:o(()=>Ut,"PackSync"),Parser:o(()=>Ie,"Parser"),Pax:o(()=>ht,"Pax"),ReadEntry:o(()=>Zi,"ReadEntry"),Unpack:o(()=>Ft,"Unpack"),UnpackSync:o(()=>Mi,"UnpackSync"),WriteEntry:o(()=>Yi,"WriteEntry"),WriteEntrySync:o(()=>Gs,"WriteEntrySync"),WriteEntryTar:o(()=>$s,"WriteEntryTar"),c:o(()=>bs,"c"),create:o(()=>bs,"create"),extract:o(()=>xs,"extract"),filesFilter:o(()=>Wi,"filesFilter"),list:o(()=>Ce,"list"),r:o(()=>ge,"r"),replace:o(()=>ge,"replace"),t:o(()=>Ce,"t"),types:o(()=>js,"types"),x:o(()=>xs,"x")}),Sr=Object.defineProperty,vr=o((e,t)=>{for(var i in t)Sr(e,i,{get:t[i],enumerable:!0})},"ue"),Ji=process||{stdout:null,stderr:null},Or=o(e=>!!e&&typeof e=="object"&&(e instanceof Se||e instanceof As||Tr(e)||kr(e)),"fe"),Tr=o(e=>!!e&&typeof e=="object"&&e instanceof Pi&&typeof e.pipe=="function"&&e.pipe!==As.Writable.prototype.pipe,"pe"),kr=o(e=>!!e&&typeof e=="object"&&e instanceof Pi&&typeof e.write=="function"&&typeof e.end=="function","me"),$=Symbol("EOF"),Y=Symbol("maybeEmitEnd"),J=Symbol("emittedEnd"),at=Symbol("emittingEnd"),Pe=Symbol("emittedError"),lt=Symbol("closed"),Qi=Symbol("read"),dt=Symbol("flush"),es=Symbol("flushChunk"),C=Symbol("encoding"),Oe=Symbol("decoder"),v=Symbol("flowing"),ze=Symbol("paused"),xe=Symbol("resume"),O=Symbol("buffer"),D=Symbol("pipes"),T=Symbol("bufferLength"),Ht=Symbol("bufferPush"),ut=Symbol("bufferShift"),A=Symbol("objectMode"),R=Symbol("destroyed"),Zt=Symbol("error"),Wt=Symbol("emitData"),ts=Symbol("emitEnd"),Gt=Symbol("emitEnd2"),j=Symbol("async"),$t=Symbol("abort"),ft=Symbol("aborted"),Ue=Symbol("signal"),de=Symbol("dataListeners"),I=Symbol("discarded"),je=o(e=>Promise.resolve().then(e),"Pe"),Lr=o(e=>e(),"Fe"),xr=o(e=>e==="end"||e==="finish"||e==="prefinish","Ie"),Ar=o(e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,"Le"),Dr=o(e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),"Re"),Bs=class{static{f(this,"As")}static{o(this,"ze")}src;dest;opts;ondrain;constructor(e,t,i){this.src=e,this.dest=t,this.opts=i,this.ondrain=()=>e[xe](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Nr=class extends Bs{static{f(this,"Sr")}static{o(this,"Be")}unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,i){super(e,t,i),this.proxyErrors=s=>this.dest.emit("error",s),e.on("error",this.proxyErrors)}},Ir=o(e=>!!e.objectMode,"Ve"),Br=o(e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer","He"),Se=class extends Pi{static{f(this,"Rt")}static{o(this,"Ue")}[v]=!1;[ze]=!1;[D]=[];[O]=[];[A];[C];[j];[Oe];[$]=!1;[J]=!1;[at]=!1;[lt]=!1;[Pe]=null;[T]=0;[R]=!1;[Ue];[ft]=!1;[de]=0;[I]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw TypeError("Encoding and objectMode may not be used together");Ir(t)?(this[A]=!0,this[C]=null):Br(t)?(this[C]=t.encoding,this[A]=!1):(this[A]=!1,this[C]=null),this[j]=!!t.async,this[Oe]=this[C]?new br(this[C]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:o(()=>this[O],"get")}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:o(()=>this[D],"get")});let{signal:i}=t;i&&(this[Ue]=i,i.aborted?this[$t]():i.addEventListener("abort",()=>this[$t]()))}get bufferLength(){return this[T]}get encoding(){return this[C]}set encoding(e){throw Error("Encoding must be set at instantiation time")}setEncoding(e){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[A]}set objectMode(e){throw Error("objectMode must be set at instantiation time")}get async(){return this[j]}set async(e){this[j]=this[j]||!!e}[$t](){this[ft]=!0,this.emit("abort",this[Ue]?.reason),this.destroy(this[Ue]?.reason)}get aborted(){return this[ft]}set aborted(e){}write(e,t,i){if(this[ft])return!1;if(this[$])throw Error("write after end");if(this[R])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(i=t,t="utf8"),t||="utf8";let s=this[j]?je:Lr;if(!this[A]&&!Buffer.isBuffer(e)){if(Dr(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Ar(e))e=Buffer.from(e);else if(typeof e!="string")throw Error("Non-contiguous data written to non-objectMode stream")}return this[A]?(this[v]&&this[T]!==0&&this[dt](!0),this[v]?this.emit("data",e):this[Ht](e),this[T]!==0&&this.emit("readable"),i&&s(i),this[v]):e.length?(typeof e=="string"&&!(t===this[C]&&!this[Oe]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[C]&&(e=this[Oe].write(e)),this[v]&&this[T]!==0&&this[dt](!0),this[v]?this.emit("data",e):this[Ht](e),this[T]!==0&&this.emit("readable"),i&&s(i),this[v]):(this[T]!==0&&this.emit("readable"),i&&s(i),this[v])}read(e){if(this[R])return null;if(this[I]=!1,this[T]===0||e===0||e&&e>this[T])return this[Y](),null;this[A]&&(e=null),this[O].length>1&&!this[A]&&(this[O]=[this[C]?this[O].join(""):Buffer.concat(this[O],this[T])]);let t=this[Qi](e||null,this[O][0]);return this[Y](),t}[Qi](e,t){if(this[A])this[ut]();else{let i=t;e===i.length||e===null?this[ut]():typeof i=="string"?(this[O][0]=i.slice(e),t=i.slice(0,e),this[T]-=e):(this[O][0]=i.subarray(e),t=i.subarray(0,e),this[T]-=e)}return this.emit("data",t),!this[O].length&&!this[$]&&this.emit("drain"),t}end(e,t,i){return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t="utf8"),e!==void 0&&this.write(e,t),i&&this.once("end",i),this[$]=!0,this.writable=!1,(this[v]||!this[ze])&&this[Y](),this}[xe](){this[R]||(!this[de]&&!this[D].length&&(this[I]=!0),this[ze]=!1,this[v]=!0,this.emit("resume"),this[O].length?this[dt]():this[$]?this[Y]():this.emit("drain"))}resume(){return this[xe]()}pause(){this[v]=!1,this[ze]=!0,this[I]=!1}get destroyed(){return this[R]}get flowing(){return this[v]}get paused(){return this[ze]}[Ht](e){this[A]?this[T]+=1:this[T]+=e.length,this[O].push(e)}[ut](){return this[A]?--this[T]:this[T]-=this[O][0].length,this[O].shift()}[dt](e=!1){do;while(this[es](this[ut]())&&this[O].length);!e&&!this[O].length&&!this[$]&&this.emit("drain")}[es](e){return this.emit("data",e),this[v]}pipe(e,t){if(this[R])return e;this[I]=!1;let i=this[J];return t||={},e===Ji.stdout||e===Ji.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,i?t.end&&e.end():(this[D].push(t.proxyErrors?new Nr(this,e,t):new Bs(this,e,t)),this[j]?je(()=>this[xe]()):this[xe]()),e}unpipe(e){let t=this[D].find(i=>i.dest===e);t&&(this[D].length===1?(this[v]&&this[de]===0&&(this[v]=!1),this[D]=[]):this[D].splice(this[D].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let i=super.on(e,t);if(e==="data")this[I]=!1,this[de]++,!this[D].length&&!this[v]&&this[xe]();else if(e==="readable"&&this[T]!==0)super.emit("readable");else if(xr(e)&&this[J])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[Pe]){let s=t;this[j]?je(()=>s.call(this,this[Pe])):s.call(this,this[Pe])}return i}removeListener(e,t){return this.off(e,t)}off(e,t){let i=super.off(e,t);return e==="data"&&(this[de]=this.listeners("data").length,this[de]===0&&!this[I]&&!this[D].length&&(this[v]=!1)),i}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[de]=0,!this[I]&&!this[D].length&&(this[v]=!1)),t}get emittedEnd(){return this[J]}[Y](){!this[at]&&!this[J]&&!this[R]&&this[O].length===0&&this[$]&&(this[at]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[lt]&&this.emit("close"),this[at]=!1)}emit(e,...t){let i=t[0];if(e!=="error"&&e!=="close"&&e!==R&&this[R])return!1;if(e==="data")return!this[A]&&!i?!1:this[j]?(je(()=>this[Wt](i)),!0):this[Wt](i);if(e==="end")return this[ts]();if(e==="close"){if(this[lt]=!0,!this[J]&&!this[R])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(e==="error"){this[Pe]=i,super.emit(Zt,i);let r=!this[Ue]||this.listeners("error").length?super.emit("error",i):!1;return this[Y](),r}else if(e==="resume"){let r=super.emit("resume");return this[Y](),r}else if(e==="finish"||e==="prefinish"){let r=super.emit(e);return this.removeAllListeners(e),r}let s=super.emit(e,...t);return this[Y](),s}[Wt](e){for(let i of this[D])i.dest.write(e)===!1&&this.pause();let t=this[I]?!1:super.emit("data",e);return this[Y](),t}[ts](){return this[J]?!1:(this[J]=!0,this.readable=!1,this[j]?(je(()=>this[Gt]()),!0):this[Gt]())}[Gt](){if(this[Oe]){let t=this[Oe].end();if(t){for(let i of this[D])i.dest.write(t);this[I]||super.emit("data",t)}}for(let t of this[D])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[A]||(e.dataLength=0);let t=this.promise();return this.on("data",i=>{e.push(i),this[A]||(e.dataLength+=i.length)}),await t,e}async concat(){if(this[A])throw Error("cannot concat in objectMode");let e=await this.collect();return this[C]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(R,()=>t(Error("stream destroyed"))),this.on("error",i=>t(i)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[I]=!1;let e=!1,t=o(async()=>(this.pause(),e=!0,{value:void 0,done:!0}),"t");return{next:o(()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[$])return t();let s,r,h=o(u=>{this.off("data",n),this.off("end",a),this.off(R,l),t(),r(u)},"a"),n=o(u=>{this.off("error",h),this.off("end",a),this.off(R,l),this.pause(),s({value:u,done:!!this[$]})},"o"),a=o(()=>{this.off("error",h),this.off("data",n),this.off(R,l),t(),s({done:!0,value:void 0})},"s"),l=o(()=>h(Error("stream destroyed")),"c");return new Promise((u,m)=>{r=m,s=u,this.once(R,l),this.once("error",h),this.once("end",a),this.once("data",n)})},"next"),throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[I]=!1;let e=!1,t=o(()=>(this.pause(),this.off(Zt,t),this.off(R,t),this.off("end",t),e=!0,{done:!0,value:void 0}),"t");return this.once("end",t),this.once(Zt,t),this.once(R,t),{next:o(()=>{if(e)return t();let i=this.read();return i===null?t():{done:!1,value:i}},"next"),throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[R])return e?this.emit("error",e):this.emit(R),this;this[R]=!0,this[I]=!0,this[O].length=0,this[T]=0;let t=this;return typeof t.close=="function"&&!this[lt]&&t.close(),e?this.emit("error",e):this.emit(R),this}static get isStream(){return Or}},Fr=b.writev,oe=Symbol("_autoClose"),U=Symbol("_close"),He=Symbol("_ended"),y=Symbol("_fd"),Yt=Symbol("_finished"),q=Symbol("_flags"),Vt=Symbol("_flush"),yi=Symbol("_handleChunk"),bi=Symbol("_makeBuf"),qe=Symbol("_mode"),ct=Symbol("_needDrain"),Be=Symbol("_onerror"),Fe=Symbol("_onopen"),Kt=Symbol("_onread"),Ae=Symbol("_onwrite"),ae=Symbol("_open"),z=Symbol("_path"),ie=Symbol("_pos"),H=Symbol("_queue"),De=Symbol("_read"),Xt=Symbol("_readSize"),X=Symbol("_reading"),Ze=Symbol("_remain"),qt=Symbol("_size"),_t=Symbol("_write"),ue=Symbol("_writing"),St=Symbol("_defaultFlag"),Re=Symbol("_errored"),zi=class extends Se{static{f(this,"Ce")}static{o(this,"dt")}[Re]=!1;[y];[z];[Xt];[X]=!1;[qt];[Ze];[oe];constructor(e,t){if(t||={},super(t),this.readable=!0,this.writable=!1,typeof e!="string")throw TypeError("path must be a string");this[Re]=!1,this[y]=typeof t.fd=="number"?t.fd:void 0,this[z]=e,this[Xt]=t.readSize||16*1024*1024,this[X]=!1,this[qt]=typeof t.size=="number"?t.size:1/0,this[Ze]=this[qt],this[oe]=typeof t.autoClose=="boolean"?t.autoClose:!0,typeof this[y]=="number"?this[De]():this[ae]()}get fd(){return this[y]}get path(){return this[z]}write(){throw TypeError("this is a readable stream")}end(){throw TypeError("this is a readable stream")}[ae](){b.open(this[z],"r",(e,t)=>this[Fe](e,t))}[Fe](e,t){e?this[Be](e):(this[y]=t,this.emit("open",t),this[De]())}[bi](){return Buffer.allocUnsafe(Math.min(this[Xt],this[Ze]))}[De](){if(!this[X]){this[X]=!0;let e=this[bi]();if(e.length===0)return process.nextTick(()=>this[Kt](null,0,e));b.read(this[y],e,0,e.length,null,(t,i,s)=>this[Kt](t,i,s))}}[Kt](e,t,i){this[X]=!1,e?this[Be](e):this[yi](t,i)&&this[De]()}[U](){if(this[oe]&&typeof this[y]=="number"){let e=this[y];this[y]=void 0,b.close(e,t=>t?this.emit("error",t):this.emit("close"))}}[Be](e){this[X]=!0,this[U](),this.emit("error",e)}[yi](e,t){let i=!1;return this[Ze]-=e,e>0&&(i=super.write(e<t.length?t.subarray(0,e):t)),(e===0||this[Ze]<=0)&&(i=!1,this[U](),super.end()),i}emit(e,...t){switch(e){case"prefinish":case"finish":return!1;case"drain":return typeof this[y]=="number"&&this[De](),!1;case"error":return this[Re]?!1:(this[Re]=!0,super.emit(e,...t));default:return super.emit(e,...t)}}},Cr=class extends zi{static{f(this,"kr")}static{o(this,"ft")}[ae](){let e=!0;try{this[Fe](null,b.openSync(this[z],"r")),e=!1}finally{e&&this[U]()}}[De](){let e=!0;try{if(!this[X]){this[X]=!0;do{let t=this[bi](),i=t.length===0?0:b.readSync(this[y],t,0,t.length,null);if(!this[yi](i,t))break}while(!0);this[X]=!1}e=!1}finally{e&&this[U]()}}[U](){if(this[oe]&&typeof this[y]=="number"){let e=this[y];this[y]=void 0,b.closeSync(e),this.emit("close")}}},Ct=class extends Ns{static{f(this,"Ii")}static{o(this,"pt")}readable=!1;writable=!0;[Re]=!1;[ue]=!1;[He]=!1;[H]=[];[ct]=!1;[z];[qe];[oe];[y];[St];[q];[Yt]=!1;[ie];constructor(e,t){t||={},super(t),this[z]=e,this[y]=typeof t.fd=="number"?t.fd:void 0,this[qe]=t.mode===void 0?438:t.mode,this[ie]=typeof t.start=="number"?t.start:void 0,this[oe]=typeof t.autoClose=="boolean"?t.autoClose:!0;let i=this[ie]===void 0?"w":"r+";this[St]=t.flags===void 0,this[q]=t.flags===void 0?i:t.flags,this[y]===void 0&&this[ae]()}emit(e,...t){if(e==="error"){if(this[Re])return!1;this[Re]=!0}return super.emit(e,...t)}get fd(){return this[y]}get path(){return this[z]}[Be](e){this[U](),this[ue]=!0,this.emit("error",e)}[ae](){b.open(this[z],this[q],this[qe],(e,t)=>this[Fe](e,t))}[Fe](e,t){this[St]&&this[q]==="r+"&&e&&e.code==="ENOENT"?(this[q]="w",this[ae]()):e?this[Be](e):(this[y]=t,this.emit("open",t),this[ue]||this[Vt]())}end(e,t){return e&&this.write(e,t),this[He]=!0,!this[ue]&&!this[H].length&&typeof this[y]=="number"&&this[Ae](null,0),this}write(e,t){return typeof e=="string"&&(e=Buffer.from(e,t)),this[He]?(this.emit("error",Error("write() after end()")),!1):this[y]===void 0||this[ue]||this[H].length?(this[H].push(e),this[ct]=!0,!1):(this[ue]=!0,this[_t](e),!0)}[_t](e){b.write(this[y],e,0,e.length,this[ie],(t,i)=>this[Ae](t,i))}[Ae](e,t){e?this[Be](e):(this[ie]!==void 0&&typeof t=="number"&&(this[ie]+=t),this[H].length?this[Vt]():(this[ue]=!1,this[He]&&!this[Yt]?(this[Yt]=!0,this[U](),this.emit("finish")):this[ct]&&(this[ct]=!1,this.emit("drain"))))}[Vt](){if(this[H].length===0)this[He]&&this[Ae](null,0);else if(this[H].length===1)this[_t](this[H].pop());else{let e=this[H];this[H]=[],Fr(this[y],e,this[ie],(t,i)=>this[Ae](t,i))}}[U](){if(this[oe]&&typeof this[y]=="number"){let e=this[y];this[y]=void 0,b.close(e,t=>t?this.emit("error",t):this.emit("close"))}}},Fs=class extends Ct{static{f(this,"Ds")}static{o(this,"mt")}[ae](){let e;if(this[St]&&this[q]==="r+")try{e=b.openSync(this[z],this[q],this[qe])}catch(t){if(t?.code==="ENOENT")return this[q]="w",this[ae]();throw t}else e=b.openSync(this[z],this[q],this[qe]);this[Fe](null,e)}[U](){if(this[oe]&&typeof this[y]=="number"){let e=this[y];this[y]=void 0,b.closeSync(e),this.emit("close")}}[_t](e){let t=!0;try{this[Ae](null,b.writeSync(this[y],e,0,e.length,this[ie])),t=!1}finally{if(t)try{this[U]()}catch{}}}},Mr=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),Pr=o(e=>!!e.sync&&!!e.file,"gt"),zr=o(e=>!e.sync&&!!e.file,"_t"),Ur=o(e=>!!e.sync&&!e.file,"vt"),jr=o(e=>!e.sync&&!e.file,"yt"),Hr=o(e=>!!e.file,"bt"),Zr=o(e=>Mr.get(e)||e,"xt"),Ui=o((e={})=>{if(!e)return{};let t={};for(let[i,s]of Object.entries(e)){let r=Zr(i);t[r]=s}return t.chmod===void 0&&t.noChmod===!1&&(t.chmod=!0),delete t.noChmod,t},"St"),nt=o((e,t,i,s,r)=>Object.assign((h=[],n,a)=>{Array.isArray(h)&&(n=h,h={}),typeof n=="function"&&(a=n,n=void 0),n=n?Array.from(n):[];let l=Ui(h);if(r?.(l,n),Pr(l)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return e(l,n)}else if(zr(l)){let u=t(l,n);return a?u.then(()=>a(),a):u}else if(Ur(l)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return i(l,n)}else if(jr(l)){if(typeof a=="function")throw TypeError("callback only supported with file option");return s(l,n)}throw Error("impossible options??")},{syncFile:e,asyncFile:t,syncNoFile:i,asyncNoFile:s,validate:r}),"Ct"),Wr=wr.constants||{ZLIB_VERNUM:4736},G=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Wr)),Gr=we.concat,is=Object.getOwnPropertyDescriptor(we,"concat"),$r=o(e=>e,"Dt"),Jt=is?.writable===!0||is?.set!==void 0?e=>{we.concat=e?$r:Gr}:e=>{},_e=Symbol("_superWrite"),mt=class extends Error{static{f(this,"di")}static{o(this,"At")}code;errno;constructor(e,t){super("zlib: "+e.message,{cause:e}),this.code=e.code,this.errno=e.errno,this.code||="ZLIB_ERROR",this.message="zlib: "+e.message,Error.captureStackTrace(this,t??this.constructor)}get name(){return"ZlibError"}},Qt=Symbol("flushFlag"),ji=class extends Se{static{f(this,"Pe")}static{o(this,"Mt")}#e=!1;#i=!1;#s;#h;#r;#t;#n;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#s}constructor(e,t){if(!e||typeof e!="object")throw TypeError("invalid options for ZlibBase constructor");if(super(e),this.#s=e.flush??0,this.#h=e.finishFlush??0,this.#r=e.fullFlushFlag??0,typeof qi[t]!="function")throw TypeError("Compression method not supported: "+t);try{this.#t=new qi[t](e)}catch(i){throw new mt(i,this.constructor)}this.#n=i=>{this.#e||(this.#e=!0,this.close(),this.emit("error",i))},this.#t?.on("error",i=>this.#n(new mt(i))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return pi(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(e){this.ended||(typeof e!="number"&&(e=this.#r),this.write(Object.assign(we.alloc(0),{[Qt]:e})))}end(e,t,i){return typeof e=="function"&&(i=e,t=void 0,e=void 0),typeof t=="function"&&(i=t,t=void 0),e&&(t?this.write(e,t):this.write(e)),this.flush(this.#h),this.#i=!0,super.end(i)}get ended(){return this.#i}[_e](e){return super.write(e)}write(e,t,i){if(typeof t=="function"&&(i=t,t="utf8"),typeof e=="string"&&(e=we.from(e,t)),this.#e)return;pi(this.#t,"zlib binding closed");let s=this.#t._handle,r=s.close;s.close=()=>{};let h=this.#t.close;this.#t.close=()=>{},Jt(!0);let n;try{let l=typeof e[Qt]=="number"?e[Qt]:this.#s;n=this.#t._processChunk(e,l),Jt(!1)}catch(l){Jt(!1),this.#n(new mt(l,this.write))}finally{this.#t&&(this.#t._handle=s,s.close=r,this.#t.close=h,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",l=>this.#n(new mt(l,this.write)));let a;if(n)if(Array.isArray(n)&&n.length>0){let l=n[0];a=this[_e](we.from(l));for(let u=1;u<n.length;u++)a=this[_e](n[u])}else a=this[_e](we.from(n));return i&&i(),a}},Cs=class extends ji{static{f(this,"xs")}static{o(this,"Nt")}#e;#i;constructor(e,t){e||={},e.flush=e.flush||G.Z_NO_FLUSH,e.finishFlush=e.finishFlush||G.Z_FINISH,e.fullFlushFlag=G.Z_FULL_FLUSH,super(e,t),this.#e=e.level,this.#i=e.strategy}params(e,t){if(!this.sawError){if(!this.handle)throw Error("cannot switch params when binding is closed");if(!this.handle.params)throw Error("not supported in this implementation");if(this.#e!==e||this.#i!==t){this.flush(G.Z_SYNC_FLUSH),pi(this.handle,"zlib binding closed");let i=this.handle.flush;this.handle.flush=(s,r)=>{typeof s=="function"&&(r=s,s=this.flushFlag),this.flush(s),r?.()};try{this.handle.params(e,t)}finally{this.handle.flush=i}this.handle&&(this.#e=e,this.#i=t)}}}},Yr=class extends Cs{static{f(this,"Pr")}static{o(this,"Pt")}#e;constructor(e){super(e,"Gzip"),this.#e=e&&!!e.portable}[_e](e){return this.#e?(this.#e=!1,e[9]=255,super[_e](e)):super[_e](e)}},Vr=class extends Cs{static{f(this,"zr")}static{o(this,"Ft")}constructor(e){super(e,"Unzip")}},Ms=class extends ji{static{f(this,"Ns")}static{o(this,"It")}constructor(e,t){e||={},e.flush=e.flush||G.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||G.BROTLI_OPERATION_FINISH,e.fullFlushFlag=G.BROTLI_OPERATION_FLUSH,super(e,t)}},Kr=class extends Ms{static{f(this,"Ur")}static{o(this,"Lt")}constructor(e){super(e,"BrotliCompress")}},Xr=class extends Ms{static{f(this,"jr")}static{o(this,"Rt")}constructor(e){super(e,"BrotliDecompress")}},Ps=class extends ji{static{f(this,"Is")}static{o(this,"zt")}constructor(e,t){e||={},e.flush=e.flush||G.ZSTD_e_continue,e.finishFlush=e.finishFlush||G.ZSTD_e_end,e.fullFlushFlag=G.ZSTD_e_flush,super(e,t)}},qr=class extends Ps{static{f(this,"Hr")}static{o(this,"Bt")}constructor(e){super(e,"ZstdCompress")}},Jr=class extends Ps{static{f(this,"Zr")}static{o(this,"Vt")}constructor(e){super(e,"ZstdDecompress")}},Qr=o((e,t)=>{if(Number.isSafeInteger(e))e<0?th(e,t):eh(e,t);else throw Error("cannot encode number outside of javascript safe integer range");return t},"Ht"),eh=o((e,t)=>{t[0]=128;for(var i=t.length;i>1;i--)t[i-1]=e&255,e=Math.floor(e/256)},"Ut"),th=o((e,t)=>{t[0]=255;var i=!1;e*=-1;for(var s=t.length;s>1;s--){var r=e&255;e=Math.floor(e/256),i?t[s-1]=zs(r):r===0?t[s-1]=0:(i=!0,t[s-1]=Us(r))}},"Wt"),ih=o(e=>{let t=e[0],i=t===128?rh(e.subarray(1,e.length)):t===255?sh(e):null;if(i===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(i))throw Error("parsed number outside of javascript safe integer range");return i},"Gt"),sh=o(e=>{for(var t=e.length,i=0,s=!1,r=t-1;r>-1;r--){var h=Number(e[r]),n;s?n=zs(h):h===0?n=h:(s=!0,n=Us(h)),n!==0&&(i-=n*256**(t-r-1))}return i},"Kt"),rh=o(e=>{for(var t=e.length,i=0,s=t-1;s>-1;s--){var r=Number(e[s]);r!==0&&(i+=r*256**(t-s-1))}return i},"qt"),zs=o(e=>(255^e)&255,"Jt"),Us=o(e=>(255^e)+1&255,"Yt"),js={};vr(js,{code:o(()=>Hi,"code"),isCode:o(()=>vt,"isCode"),isName:o(()=>hh,"isName"),name:o(()=>Mt,"name")});var vt=o(e=>Mt.has(e),"Zt"),hh=o(e=>Hi.has(e),"Qt"),Mt=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Hi=new Map(Array.from(Mt).map(e=>[e[1],e[0]])),le=class{static{f(this,"ot")}static{o(this,"I")}cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,t=0,i,s){Buffer.isBuffer(e)?this.decode(e,t||0,i,s):e&&this.#i(e)}decode(e,t,i,s){if(t||=0,!e||!(e.length>=t+512))throw Error("need 512 bytes for header");this.path=i?.path??fe(e,t,100),this.mode=i?.mode??s?.mode??se(e,t+100,8),this.uid=i?.uid??s?.uid??se(e,t+108,8),this.gid=i?.gid??s?.gid??se(e,t+116,8),this.size=i?.size??s?.size??se(e,t+124,12),this.mtime=i?.mtime??s?.mtime??ei(e,t+136,12),this.cksum=se(e,t+148,12),s&&this.#i(s,!0),i&&this.#i(i);let r=fe(e,t+156,1);if(vt(r)&&(this.#e=r||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=fe(e,t+157,100),e.subarray(t+257,t+265).toString()==="ustar\x0000")if(this.uname=i?.uname??s?.uname??fe(e,t+265,32),this.gname=i?.gname??s?.gname??fe(e,t+297,32),this.devmaj=i?.devmaj??s?.devmaj??se(e,t+329,8)??0,this.devmin=i?.devmin??s?.devmin??se(e,t+337,8)??0,e[t+475]!==0)this.path=fe(e,t+345,155)+"/"+this.path;else{let n=fe(e,t+345,130);n&&(this.path=n+"/"+this.path),this.atime=i?.atime??s?.atime??ei(e,t+476,12),this.ctime=i?.ctime??s?.ctime??ei(e,t+488,12)}let h=256;for(let n=t;n<t+148;n++)h+=e[n];for(let n=t+156;n<t+512;n++)h+=e[n];this.cksumValid=h===this.cksum,this.cksum===void 0&&h===256&&(this.nullBlock=!0)}#i(e,t=!1){Object.assign(this,Object.fromEntries(Object.entries(e).filter(([i,s])=>!(s==null||i==="path"&&t||i==="linkpath"&&t||i==="global"))))}encode(e,t=0){if(e||=this.block=Buffer.alloc(512),this.#e==="Unsupported"&&(this.#e="0"),!(e.length>=t+512))throw Error("need 512 bytes for header");let i=this.ctime||this.atime?130:155,s=nh(this.path||"",i),r=s[0],h=s[1];this.needPax=!!s[2],this.needPax=ce(e,t,100,r)||this.needPax,this.needPax=re(e,t+100,8,this.mode)||this.needPax,this.needPax=re(e,t+108,8,this.uid)||this.needPax,this.needPax=re(e,t+116,8,this.gid)||this.needPax,this.needPax=re(e,t+124,12,this.size)||this.needPax,this.needPax=ti(e,t+136,12,this.mtime)||this.needPax,e[t+156]=Number(this.#e.codePointAt(0)),this.needPax=ce(e,t+157,100,this.linkpath)||this.needPax,e.write("ustar\x0000",t+257,8),this.needPax=ce(e,t+265,32,this.uname)||this.needPax,this.needPax=ce(e,t+297,32,this.gname)||this.needPax,this.needPax=re(e,t+329,8,this.devmaj)||this.needPax,this.needPax=re(e,t+337,8,this.devmin)||this.needPax,this.needPax=ce(e,t+345,i,h)||this.needPax,e[t+475]===0?(this.needPax=ce(e,t+345,130,h)||this.needPax,this.needPax=ti(e,t+476,12,this.atime)||this.needPax,this.needPax=ti(e,t+488,12,this.ctime)||this.needPax):this.needPax=ce(e,t+345,155,h)||this.needPax;let n=256;for(let a=t;a<t+148;a++)n+=e[a];for(let a=t+156;a<t+512;a++)n+=e[a];return this.cksum=n,re(e,t+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Mt.get(this.#e)}get typeKey(){return this.#e}set type(e){let t=String(Hi.get(e));if(vt(t)||t==="Unsupported")this.#e=t;else if(vt(e))this.#e=e;else throw TypeError("invalid entry type: "+e)}},nh=o((e,t)=>{let i=e,s="",r,h=ve.parse(e).root||".";if(Buffer.byteLength(i)<100)r=[i,s,!1];else{s=ve.dirname(i),i=ve.basename(i);do Buffer.byteLength(i)<=100&&Buffer.byteLength(s)<=t?r=[i,s,!1]:Buffer.byteLength(i)>100&&Buffer.byteLength(s)<=t?r=[i.slice(0,99),s,!0]:(i=ve.join(ve.basename(s),i),s=ve.dirname(s));while(s!==h&&r===void 0);r||=[e.slice(0,99),"",!0]}return r},"tn"),fe=o((e,t,i)=>e.subarray(t,t+i).toString("utf8").replace(/\0.*/,""),"nn"),ei=o((e,t,i)=>oh(se(e,t,i)),"rn"),oh=o(e=>e===void 0?void 0:new Date(e*1e3),"an"),se=o((e,t,i)=>Number(e[t])&128?ih(e.subarray(t,t+i)):lh(e,t,i),"L"),ah=o(e=>isNaN(e)?void 0:e,"on"),lh=o((e,t,i)=>ah(parseInt(e.subarray(t,t+i).toString("utf8").replace(/\0.*$/,"").trim(),8)),"sn"),dh={12:8589934591,8:2097151},re=o((e,t,i,s)=>s===void 0?!1:s>dh[i]||s<0?(Qr(s,e.subarray(t,t+i)),!0):(uh(e,t,i,s),!1),"R"),uh=o((e,t,i,s)=>e.write(fh(s,i),t,i,"ascii"),"ln"),fh=o((e,t)=>ch(Math.floor(e).toString(8),t),"un"),ch=o((e,t)=>(e.length===t-1?e:Array(t-e.length-1).join("0")+e+" ")+"\0","dn"),ti=o((e,t,i,s)=>s===void 0?!1:re(e,t,i,s.getTime()/1e3),"fn"),mh=Array(156).join("\0"),ce=o((e,t,i,s)=>s===void 0?!1:(e.write(s+mh,t,i,"utf8"),s.length!==Buffer.byteLength(s)||s.length>i),"mn"),ht=class Hs{static{f(this,"Ms")}static{o(this,"e")}atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(t,i=!1){this.atime=t.atime,this.charset=t.charset,this.comment=t.comment,this.ctime=t.ctime,this.dev=t.dev,this.gid=t.gid,this.global=i,this.gname=t.gname,this.ino=t.ino,this.linkpath=t.linkpath,this.mtime=t.mtime,this.nlink=t.nlink,this.path=t.path,this.size=t.size,this.uid=t.uid,this.uname=t.uname}encode(){let t=this.encodeBody();if(t==="")return Buffer.allocUnsafe(0);let i=Buffer.byteLength(t),s=512*Math.ceil(1+i/512),r=Buffer.allocUnsafe(s);for(let h=0;h<512;h++)r[h]=0;new le({path:("PaxHeader/"+mr(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:i,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(r),r.write(t,512,i,"utf8");for(let h=i+512;h<r.length;h++)r[h]=0;return r}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(t){if(this[t]===void 0)return"";let i=this[t],s=i instanceof Date?i.getTime()/1e3:i,r=" "+(t==="dev"||t==="ino"||t==="nlink"?"SCHILY.":"")+t+"="+s+`
2
+ `,h=Buffer.byteLength(r),n=Math.floor(Math.log(h)/Math.log(10))+1;return h+n>=10**n&&(n+=1),n+h+r}static parse(t,i,s=!1){return new Hs(ph(yh(t),i),s)}},ph=o((e,t)=>t?Object.assign({},t,e):e,"gn"),yh=o(e=>e.replace(/\n$/,"").split(`
3
+ `).reduce(bh,Object.create(null)),"_n"),bh=o((e,t)=>{let i=parseInt(t,10);if(i!==Buffer.byteLength(t)+1)return e;t=t.slice((i+" ").length);let s=t.split("="),r=s.shift();if(!r)return e;let h=r.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),n=s.join("=");return e[h]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(h)?new Date(Number(n)*1e3):/^[0-9]+$/.test(n)?+n:n,e},"vn"),c=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32"?e=>e&&e.replaceAll(/\\/g,"/"):e=>e,Zi=class extends Se{static{f(this,"Ue")}static{o(this,"yn")}extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(e,t,i){switch(super({}),this.pause(),this.extended=t,this.globalExtended=i,this.header=e,this.remain=e.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=e.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!e.path)throw Error("no path provided for tar.ReadEntry");this.path=c(e.path),this.mode=e.mode,this.mode&&(this.mode&=4095),this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=this.remain,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?c(e.linkpath):void 0,this.uname=e.uname,this.gname=e.gname,t&&this.#e(t),i&&this.#e(i,!0)}write(e){let t=e.length;if(t>this.blockRemain)throw Error("writing more to entry than is appropriate");let i=this.remain,s=this.blockRemain;return this.remain=Math.max(0,i-t),this.blockRemain=Math.max(0,s-t),this.ignore?!0:i>=t?super.write(e):super.write(e.subarray(0,i))}#e(e,t=!1){e.path&&=c(e.path),e.linkpath&&=c(e.linkpath),Object.assign(this,Object.fromEntries(Object.entries(e).filter(([i,s])=>!(s==null||i==="path"&&t))))}},Pt=o((e,t,i,s={})=>{e.file&&(s.file=e.file),e.cwd&&(s.cwd=e.cwd),s.code=i instanceof Error&&i.code||t,s.tarCode=t,!e.strict&&s.recoverable!==!1?(i instanceof Error&&(s=Object.assign(i,s),i=i.message),e.emit("warn",t,i,s)):i instanceof Error?e.emit("error",Object.assign(i,s)):e.emit("error",Object.assign(Error(`${t}: ${i}`),s))},"bn"),Eh=1024*1024,Ei=Buffer.from([31,139]),gi=Buffer.from([40,181,47,253]),gh=Math.max(Ei.length,gi.length),B=Symbol("state"),me=Symbol("writeEntry"),V=Symbol("readEntry"),ii=Symbol("nextEntry"),ss=Symbol("processEntry"),Z=Symbol("extendedHeader"),We=Symbol("globalExtendedHeader"),Q=Symbol("meta"),rs=Symbol("emitMeta"),E=Symbol("buffer"),K=Symbol("queue"),ee=Symbol("ended"),si=Symbol("emittedEnd"),pe=Symbol("emit"),S=Symbol("unzip"),pt=Symbol("consumeChunk"),yt=Symbol("consumeChunkSub"),ri=Symbol("consumeBody"),hs=Symbol("consumeMeta"),ns=Symbol("consumeHeader"),Ge=Symbol("consuming"),hi=Symbol("bufferConcat"),bt=Symbol("maybeEnd"),Te=Symbol("writing"),te=Symbol("aborted"),Et=Symbol("onDone"),ye=Symbol("sawValidEntry"),gt=Symbol("sawNullBlock"),wt=Symbol("sawEOF"),os=Symbol("closeStream"),wh=o(()=>!0,"qn"),Ie=class extends yr{static{f(this,"xt")}static{o(this,"Jn")}file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[K]=[];[E];[V];[me];[B]="begin";[Q]="";[Z];[We];[ee]=!1;[S];[te]=!1;[ye];[gt]=!1;[wt]=!1;[Te]=!1;[Ge]=!1;[si]=!1;constructor(e={}){super(),this.file=e.file||"",this.on(Et,()=>{(this[B]==="begin"||this[ye]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),e.ondone?this.on(Et,e.ondone):this.on(Et,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!e.strict,this.maxMetaEntrySize=e.maxMetaEntrySize||Eh,this.filter=typeof e.filter=="function"?e.filter:wh;let t=e.file&&(e.file.endsWith(".tar.br")||e.file.endsWith(".tbr"));this.brotli=!(e.gzip||e.zstd)&&e.brotli!==void 0?e.brotli:t?void 0:!1;let i=e.file&&(e.file.endsWith(".tar.zst")||e.file.endsWith(".tzst"));this.zstd=!(e.gzip||e.brotli)&&e.zstd!==void 0?e.zstd:i?!0:void 0,this.on("end",()=>this[os]()),typeof e.onwarn=="function"&&this.on("warn",e.onwarn),typeof e.onReadEntry=="function"&&this.on("entry",e.onReadEntry)}warn(e,t,i={}){Pt(this,e,t,i)}[ns](e,t){this[ye]===void 0&&(this[ye]=!1);let i;try{i=new le(e,t,this[Z],this[We])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(i.nullBlock)this[gt]?(this[wt]=!0,this[B]==="begin"&&(this[B]="header"),this[pe]("eof")):(this[gt]=!0,this[pe]("nullBlock"));else if(this[gt]=!1,!i.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:i});else if(!i.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:i});else{let s=i.type;if(/^(Symbolic)?Link$/.test(s)&&!i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:i});else if(!/^(Symbolic)?Link$/.test(s)&&!/^(Global)?ExtendedHeader$/.test(s)&&i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:i});else{let r=this[me]=new Zi(i,this[Z],this[We]);this[ye]||(r.remain?r.on("end",()=>{r.invalid||(this[ye]=!0)}):this[ye]=!0),r.meta?r.size>this.maxMetaEntrySize?(r.ignore=!0,this[pe]("ignoredEntry",r),this[B]="ignore",r.resume()):r.size>0&&(this[Q]="",r.on("data",h=>this[Q]+=h),this[B]="meta"):(this[Z]=void 0,r.ignore=r.ignore||!this.filter(r.path,r),r.ignore?(this[pe]("ignoredEntry",r),this[B]=r.remain?"ignore":"header",r.resume()):(r.remain?this[B]="body":(this[B]="header",r.end()),this[V]?this[K].push(r):(this[K].push(r),this[ii]())))}}}[os](){queueMicrotask(()=>this.emit("close"))}[ss](e){let t=!0;if(!e)this[V]=void 0,t=!1;else if(Array.isArray(e)){let[i,...s]=e;this.emit(i,...s)}else this[V]=e,this.emit("entry",e),e.emittedEnd||(e.on("end",()=>this[ii]()),t=!1);return t}[ii](){do;while(this[ss](this[K].shift()));if(this[K].length===0){let e=this[V];!e||e.flowing||e.size===e.remain?this[Te]||this.emit("drain"):e.once("drain",()=>this.emit("drain"))}}[ri](e,t){let i=this[me];if(!i)throw Error("attempt to consume body without entry??");let s=i.blockRemain??0,r=s>=e.length&&t===0?e:e.subarray(t,t+s);return i.write(r),i.blockRemain||(this[B]="header",this[me]=void 0,i.end()),r.length}[hs](e,t){let i=this[me],s=this[ri](e,t);return!this[me]&&i&&this[rs](i),s}[pe](e,t,i){this[K].length===0&&!this[V]?this.emit(e,t,i):this[K].push([e,t,i])}[rs](e){switch(this[pe]("meta",this[Q]),e.type){case"ExtendedHeader":case"OldExtendedHeader":this[Z]=ht.parse(this[Q],this[Z],!1);break;case"GlobalExtendedHeader":this[We]=ht.parse(this[Q],this[We],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let t=this[Z]??Object.create(null);this[Z]=t,t.path=this[Q].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let t=this[Z]||Object.create(null);this[Z]=t,t.linkpath=this[Q].replace(/\0.*/,"");break}default:throw Error("unknown meta: "+e.type)}}abort(e){this[te]=!0,this.emit("abort",e),this.warn("TAR_ABORT",e,{recoverable:!1})}write(e,t,i){if(typeof t=="function"&&(i=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof t=="string"?t:"utf8")),this[te])return i?.(),!1;if((this[S]===void 0||this.brotli===void 0&&this[S]===!1)&&e){if(this[E]&&(e=Buffer.concat([this[E],e]),this[E]=void 0),e.length<gh)return this[E]=e,i?.(),!0;for(let n=0;this[S]===void 0&&n<Ei.length;n++)e[n]!==Ei[n]&&(this[S]=!1);let r=!1;if(this[S]===!1&&this.zstd!==!1){r=!0;for(let n=0;n<gi.length;n++)if(e[n]!==gi[n]){r=!1;break}}let h=this.brotli===void 0&&!r;if(this[S]===!1&&h)if(e.length<512)if(this[ee])this.brotli=!0;else return this[E]=e,i?.(),!0;else try{new le(e.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[S]===void 0||this[S]===!1&&(this.brotli||r)){let n=this[ee];this[ee]=!1,this[S]=this[S]===void 0?new Vr({}):r?new Jr({}):new Xr({}),this[S].on("data",l=>this[pt](l)),this[S].on("error",l=>this.abort(l)),this[S].on("end",()=>{this[ee]=!0,this[pt]()}),this[Te]=!0;let a=!!this[S][n?"end":"write"](e);return this[Te]=!1,i?.(),a}}this[Te]=!0,this[S]?this[S].write(e):this[pt](e),this[Te]=!1;let s=this[K].length>0?!1:this[V]?this[V].flowing:!0;return!s&&this[K].length===0&&this[V]?.once("drain",()=>this.emit("drain")),i?.(),s}[hi](e){e&&!this[te]&&(this[E]=this[E]?Buffer.concat([this[E],e]):e)}[bt](){if(this[ee]&&!this[si]&&!this[te]&&!this[Ge]){this[si]=!0;let e=this[me];if(e&&e.blockRemain){let t=this[E]?this[E].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${e.blockRemain} more bytes, only ${t} available)`,{entry:e}),this[E]&&e.write(this[E]),e.end()}this[pe](Et)}}[pt](e){if(this[Ge]&&e)this[hi](e);else if(!e&&!this[E])this[bt]();else if(e){if(this[Ge]=!0,this[E]){this[hi](e);let t=this[E];this[E]=void 0,this[yt](t)}else this[yt](e);for(;this[E]&&this[E]?.length>=512&&!this[te]&&!this[wt];){let t=this[E];this[E]=void 0,this[yt](t)}this[Ge]=!1}(!this[E]||this[ee])&&this[bt]()}[yt](e){let t=0,i=e.length;for(;t+512<=i&&!this[te]&&!this[wt];)switch(this[B]){case"begin":case"header":this[ns](e,t),t+=512;break;case"ignore":case"body":t+=this[ri](e,t);break;case"meta":t+=this[hs](e,t);break;default:throw Error("invalid state: "+this[B])}t<i&&(this[E]=this[E]?Buffer.concat([e.subarray(t),this[E]]):e.subarray(t))}end(e,t,i){return typeof e=="function"&&(i=e,t=void 0,e=void 0),typeof t=="function"&&(i=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,t)),i&&this.once("finish",i),this[te]||(this[S]?(e&&this[S].write(e),this[S].end()):(this[ee]=!0,(this.brotli===void 0||this.zstd===void 0)&&(e||=Buffer.alloc(0)),e&&this.write(e),this[bt]())),this}},Je=o(e=>{let t=e.length-1,i=-1;for(;t>-1&&e.charAt(t)==="/";)i=t,t--;return i===-1?e:e.slice(0,i)},"Yn"),Rh=o(e=>{let t=e.onReadEntry;e.onReadEntry=t?i=>{t(i),i.resume()}:i=>i.resume()},"Xn"),Wi=o((e,t)=>{let i=new Map(t.map(h=>[Je(h),!0])),s=e.filter,r=o((h,n="")=>{let a=n||Er(h).root||".",l;if(h===a)l=!1;else{let u=i.get(h);l=u===void 0?r(gr(h),a):u}return i.set(h,l),l},"i");e.filter=s?(h,n)=>s(h,n)&&r(Je(h)):h=>r(Je(h))},"Zn"),Ce=nt(e=>{let t=new Ie(e),i=e.file,s;try{s=d.openSync(i,"r");let r=d.fstatSync(s),h=e.maxReadSize||16*1024*1024;if(r.size<h){let n=Buffer.allocUnsafe(r.size),a=d.readSync(s,n,0,r.size,0);t.end(a===n.byteLength?n:n.subarray(0,a))}else{let n=0,a=Buffer.allocUnsafe(h);for(;n<r.size;){let l=d.readSync(s,a,0,h,n);if(l===0)break;n+=l,t.write(a.subarray(0,l))}t.end()}}finally{if(typeof s=="number")try{d.closeSync(s)}catch{}}},(e,t)=>{let i=new Ie(e),s=e.maxReadSize||16*1024*1024,r=e.file;return new Promise((h,n)=>{i.on("error",n),i.on("end",h),d.stat(r,(a,l)=>{if(a)n(a);else{let u=new zi(r,{readSize:s,size:l.size});u.on("error",n),u.pipe(i)}})})},e=>new Ie(e),e=>new Ie(e),(e,t)=>{t?.length&&Wi(e,t),e.noResume||Rh(e)}),Zs=o((e,t,i)=>(e&=4095,i&&(e=(e|384)&-19),t&&(e&256&&(e|=64),e&32&&(e|=8),e&4&&(e|=1)),e),"$n"),{isAbsolute:_h,parse:as}=pr,Gi=o(e=>{let t="",i=as(e);for(;_h(e)||i.root;){let s=e.charAt(0)==="/"&&e.slice(0,4)!=="//?/"?"/":i.root;e=e.slice(s.length),t+=s,i=as(e)}return[t,e]},"nr"),zt=["|","<",">","?",":"],$i=zt.map(e=>String.fromCodePoint(61440+Number(e.codePointAt(0)))),Sh=new Map(zt.map((e,t)=>[e,$i[t]])),vh=new Map($i.map((e,t)=>[e,zt[t]])),ls=o(e=>zt.reduce((t,i)=>t.split(i).join(Sh.get(i)),e),"sr"),Oh=o(e=>$i.reduce((t,i)=>t.split(i).join(vh.get(i)),e),"cr"),Ws=o((e,t)=>t?(e=c(e).replace(/^\.(\/|$)/,""),Je(t)+"/"+e):c(e),"lr"),Th=16*1024*1024,ds=Symbol("process"),us=Symbol("file"),fs=Symbol("directory"),wi=Symbol("symlink"),cs=Symbol("hardlink"),$e=Symbol("header"),Ot=Symbol("read"),Ri=Symbol("lstat"),Tt=Symbol("onlstat"),_i=Symbol("onread"),Si=Symbol("onreadlink"),vi=Symbol("openfile"),Oi=Symbol("onopenfile"),he=Symbol("close"),It=Symbol("mode"),Ti=Symbol("awaitDrain"),ni=Symbol("ondrain"),W=Symbol("prefix"),Yi=class extends Se{static{f(this,"We")}static{o(this,"Dr")}path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(e,t={}){let i=Ui(t);super(),this.path=c(e),this.portable=!!i.portable,this.maxReadSize=i.maxReadSize||Th,this.linkCache=i.linkCache||new Map,this.statCache=i.statCache||new Map,this.preservePaths=!!i.preservePaths,this.cwd=c(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?c(i.prefix):void 0,this.onWriteEntry=i.onWriteEntry,typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let s=!1;if(!this.preservePaths){let[h,n]=Gi(this.path);h&&typeof n=="string"&&(this.path=n,s=h)}this.win32=!!i.win32||process.platform==="win32",this.win32&&(this.path=Oh(this.path.replaceAll(/\\/g,"/")),e=e.replaceAll(/\\/g,"/")),this.absolute=c(i.absolute||rt.resolve(this.cwd,e)),this.path===""&&(this.path="./"),s&&this.warn("TAR_ENTRY_INFO",`stripping ${s} from absolute path`,{entry:this,path:s+this.path});let r=this.statCache.get(this.absolute);r?this[Tt](r):this[Ri]()}warn(e,t,i={}){return Pt(this,e,t,i)}emit(e,...t){return e==="error"&&(this.#e=!0),super.emit(e,...t)}[Ri](){b.lstat(this.absolute,(e,t)=>{if(e)return this.emit("error",e);this[Tt](t)})}[Tt](e){this.statCache.set(this.absolute,e),this.stat=e,e.isFile()||(e.size=0),this.type=kh(e),this.emit("stat",e),this[ds]()}[ds](){switch(this.type){case"File":return this[us]();case"Directory":return this[fs]();case"SymbolicLink":return this[wi]();default:return this.end()}}[It](e){return Zs(e,this.type==="Directory",this.portable)}[W](e){return Ws(e,this.prefix)}[$e](){if(!this.stat)throw Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new le({path:this[W](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[W](this.linkpath):this.linkpath,mode:this[It](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new ht({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[W](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[W](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let e=this.header?.block;if(!e)throw Error("failed to encode header");super.write(e)}[fs](){if(!this.stat)throw Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[$e](),this.end()}[wi](){b.readlink(this.absolute,(e,t)=>{if(e)return this.emit("error",e);this[Si](t)})}[Si](e){this.linkpath=c(e),this[$e](),this.end()}[cs](e){if(!this.stat)throw Error("cannot create link entry without stat");this.type="Link",this.linkpath=c(rt.relative(this.cwd,e)),this.stat.size=0,this[$e](),this.end()}[us](){if(!this.stat)throw Error("cannot create file entry without stat");if(this.stat.nlink>1){let e=`${this.stat.dev}:${this.stat.ino}`,t=this.linkCache.get(e);if(t?.indexOf(this.cwd)===0)return this[cs](t);this.linkCache.set(e,this.absolute)}if(this[$e](),this.stat.size===0)return this.end();this[vi]()}[vi](){b.open(this.absolute,"r",(e,t)=>{if(e)return this.emit("error",e);this[Oi](t)})}[Oi](e){if(this.fd=e,this.#e)return this[he]();if(!this.stat)throw Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let t=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(t),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Ot]()}[Ot](){let{fd:e,buf:t,offset:i,length:s,pos:r}=this;if(e===void 0||t===void 0)throw Error("cannot read file without first opening");b.read(e,t,i,s,r,(h,n)=>{if(h)return this[he](()=>this.emit("error",h));this[_i](n)})}[he](e=()=>{}){this.fd!==void 0&&b.close(this.fd,e)}[_i](e){if(e<=0&&this.remain>0){let i=Object.assign(Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[he](()=>this.emit("error",i))}if(e>this.remain){let i=Object.assign(Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[he](()=>this.emit("error",i))}if(!this.buf)throw Error("should have created buffer prior to reading");if(e===this.remain)for(let i=e;i<this.length&&e<this.blockRemain;i++)this.buf[i+this.offset]=0,e++,this.remain++;let t=this.offset===0&&e===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+e);this.write(t)?this[ni]():this[Ti](()=>this[ni]())}[Ti](e){this.once("drain",e)}write(e,t,i){if(typeof t=="function"&&(i=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof t=="string"?t:"utf8")),this.blockRemain<e.length){let s=Object.assign(Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=e.length,this.blockRemain-=e.length,this.pos+=e.length,this.offset+=e.length,super.write(e,null,i)}[ni](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[he](e=>e?this.emit("error",e):this.end());if(!this.buf)throw Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[Ot]()}},Gs=class extends Yi{static{f(this,"Us")}static{o(this,"Or")}sync=!0;[Ri](){this[Tt](b.lstatSync(this.absolute))}[wi](){this[Si](b.readlinkSync(this.absolute))}[vi](){this[Oi](b.openSync(this.absolute,"r"))}[Ot](){let e=!0;try{let{fd:t,buf:i,offset:s,length:r,pos:h}=this;if(t===void 0||i===void 0)throw Error("fd and buf must be set in READ method");let n=b.readSync(t,i,s,r,h);this[_i](n),e=!1}finally{if(e)try{this[he](()=>{})}catch{}}}[Ti](e){e()}[he](e=()=>{}){this.fd!==void 0&&b.closeSync(this.fd),e()}},$s=class extends Se{static{f(this,"js")}static{o(this,"kr")}blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(e,t,i={}){return Pt(this,e,t,i)}constructor(e,t={}){let i=Ui(t);super(),this.preservePaths=!!i.preservePaths,this.portable=!!i.portable,this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.onWriteEntry=i.onWriteEntry,this.readEntry=e;let{type:s}=e;if(s==="Unsupported")throw Error("writing entry that should be ignored");this.type=s,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=i.prefix,this.path=c(e.path),this.mode=e.mode===void 0?void 0:this[It](e.mode),this.uid=this.portable?void 0:e.uid,this.gid=this.portable?void 0:e.gid,this.uname=this.portable?void 0:e.uname,this.gname=this.portable?void 0:e.gname,this.size=e.size,this.mtime=this.noMtime?void 0:i.mtime||e.mtime,this.atime=this.portable?void 0:e.atime,this.ctime=this.portable?void 0:e.ctime,this.linkpath=e.linkpath===void 0?void 0:c(e.linkpath),typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let r=!1;if(!this.preservePaths){let[n,a]=Gi(this.path);n&&typeof a=="string"&&(this.path=a,r=n)}this.remain=e.size,this.blockRemain=e.startBlockSize,this.onWriteEntry?.(this),this.header=new le({path:this[W](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[W](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),r&&this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute path`,{entry:this,path:r+this.path}),this.header.encode()&&!this.noPax&&super.write(new ht({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[W](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[W](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let h=this.header?.block;if(!h)throw Error("failed to encode header");super.write(h),e.pipe(this)}[W](e){return Ws(e,this.prefix)}[It](e){return Zs(e,this.type==="Directory",this.portable)}write(e,t,i){typeof t=="function"&&(i=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof t=="string"?t:"utf8"));let s=e.length;if(s>this.blockRemain)throw Error("writing more to entry than is appropriate");return this.blockRemain-=s,super.write(e,i)}end(e,t,i){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof e=="function"&&(i=e,t=void 0,e=void 0),typeof t=="function"&&(i=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,t??"utf8")),i&&this.once("finish",i),e?super.end(e,i):super.end(i),this}},kh=o(e=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":"Unsupported","Ar"),Lh=class Ne{static{f(this,"Dt")}static{o(this,"e")}tail;head;length=0;static create(t=[]){return new Ne(t)}constructor(t=[]){for(let i of t)this.push(i)}*[Symbol.iterator](){for(let t=this.head;t;t=t.next)yield t.value}removeNode(t){if(t.list!==this)throw Error("removing node which does not belong to this list");let i=t.next,s=t.prev;return i&&(i.prev=s),s&&(s.next=i),t===this.head&&(this.head=i),t===this.tail&&(this.tail=s),this.length--,t.next=void 0,t.prev=void 0,t.list=void 0,i}unshiftNode(t){if(t===this.head)return;t.list&&t.list.removeNode(t);let i=this.head;t.list=this,t.next=i,i&&(i.prev=t),this.head=t,this.tail||=t,this.length++}pushNode(t){if(t===this.tail)return;t.list&&t.list.removeNode(t);let i=this.tail;t.list=this,t.prev=i,i&&(i.next=t),this.tail=t,this.head||=t,this.length++}push(...t){for(let i=0,s=t.length;i<s;i++)Vs(this,t[i]);return this.length}unshift(...t){for(var i=0,s=t.length;i<s;i++)Ks(this,t[i]);return this.length}pop(){if(!this.tail)return;let t=this.tail.value,i=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,i.list=void 0,this.length--,t}shift(){if(!this.head)return;let t=this.head.value,i=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,i.list=void 0,this.length--,t}forEach(t,i){i||=this;for(let s=this.head,r=0;s;r++)t.call(i,s.value,r,this),s=s.next}forEachReverse(t,i){i||=this;for(let s=this.tail,r=this.length-1;s;r--)t.call(i,s.value,r,this),s=s.prev}get(t){let i=0,s=this.head;for(;s&&i<t;i++)s=s.next;if(i===t&&s)return s.value}getReverse(t){let i=0,s=this.tail;for(;s&&i<t;i++)s=s.prev;if(i===t&&s)return s.value}map(t,i){i||=this;let s=new Ne;for(let r=this.head;r;)s.push(t.call(i,r.value,this)),r=r.next;return s}mapReverse(t,i){i||=this;var s=new Ne;for(let r=this.tail;r;)s.push(t.call(i,r.value,this)),r=r.prev;return s}reduce(t,i){let s,r=this.head;if(arguments.length>1)s=i;else if(this.head)r=this.head.next,s=this.head.value;else throw TypeError("Reduce of empty list with no initial value");for(var h=0;r;h++)s=t(s,r.value,h),r=r.next;return s}reduceReverse(t,i){let s,r=this.tail;if(arguments.length>1)s=i;else if(this.tail)r=this.tail.prev,s=this.tail.value;else throw TypeError("Reduce of empty list with no initial value");for(let h=this.length-1;r;h--)s=t(s,r.value,h),r=r.prev;return s}toArray(){let t=Array(this.length);for(let i=0,s=this.head;s;i++)t[i]=s.value,s=s.next;return t}toArrayReverse(){let t=Array(this.length);for(let i=0,s=this.tail;s;i++)t[i]=s.value,s=s.prev;return t}slice(t=0,i=this.length){i<0&&(i+=this.length),t<0&&(t+=this.length);let s=new Ne;if(i<t||i<0)return s;t<0&&(t=0),i>this.length&&(i=this.length);let r=this.head,h=0;for(h=0;r&&h<t;h++)r=r.next;for(;r&&h<i;h++,r=r.next)s.push(r.value);return s}sliceReverse(t=0,i=this.length){i<0&&(i+=this.length),t<0&&(t+=this.length);let s=new Ne;if(i<t||i<0)return s;t<0&&(t=0),i>this.length&&(i=this.length);let r=this.length,h=this.tail;for(;h&&r>i;r--)h=h.prev;for(;h&&r>t;r--,h=h.prev)s.push(h.value);return s}splice(t,i=0,...s){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);let r=this.head;for(let n=0;r&&n<t;n++)r=r.next;let h=[];for(let n=0;r&&n<i;n++)h.push(r.value),r=this.removeNode(r);r?r!==this.tail&&(r=r.prev):r=this.tail;for(let n of s)r=Ys(this,r,n);return h}reverse(){let t=this.head,i=this.tail;for(let s=t;s;s=s.prev){let r=s.prev;s.prev=s.next,s.next=r}return this.head=i,this.tail=t,this}};function Ys(e,t,i){let s=new Vi(i,t,t?t.next:e.head,e);return s.next===void 0&&(e.tail=s),s.prev===void 0&&(e.head=s),e.length++,s}f(Ys,"wh");o(Ys,"Mr");function Vs(e,t){e.tail=new Vi(t,e.tail,void 0,e),e.head||=e.tail,e.length++}f(Vs,"Rh");o(Vs,"Nr");function Ks(e,t){e.head=new Vi(t,void 0,e.head,e),e.tail||=e.head,e.length++}f(Ks,"_h");o(Ks,"Pr");var Vi=class{static{f(this,"Ge")}static{o(this,"Fr")}list;next;prev;value;constructor(e,t,i,s){this.list=s,this.value=e,t?(t.next=this,this.prev=t):this.prev=void 0,i?(i.prev=this,this.next=i):this.next=void 0}},ki=class{static{f(this,"ve")}static{o(this,"Ir")}path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(e,t){this.path=e||"./",this.absolute=t}},ms=Buffer.alloc(1024),kt=Symbol("onStat"),Ye=Symbol("ended"),M=Symbol("queue"),be=Symbol("current"),Ee=Symbol("process"),Ve=Symbol("processing"),oi=Symbol("processJob"),P=Symbol("jobs"),ai=Symbol("jobDone"),Lt=Symbol("addFSEntry"),ps=Symbol("addTarEntry"),Li=Symbol("stat"),xi=Symbol("readdir"),xt=Symbol("onreaddir"),At=Symbol("pipe"),ys=Symbol("entry"),li=Symbol("entryOpt"),Dt=Symbol("writeEntryClass"),Xs=Symbol("write"),di=Symbol("ondrain"),ot=class extends Se{static{f(this,"si")}static{o(this,"ni")}sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Dt];onWriteEntry;[M];[P]=0;[Ve]=!1;[Ye]=!1;constructor(e={}){if(super(),this.opt=e,this.file=e.file||"",this.cwd=e.cwd||process.cwd(),this.maxReadSize=e.maxReadSize,this.preservePaths=!!e.preservePaths,this.strict=!!e.strict,this.noPax=!!e.noPax,this.prefix=c(e.prefix||""),this.linkCache=e.linkCache||new Map,this.statCache=e.statCache||new Map,this.readdirCache=e.readdirCache||new Map,this.onWriteEntry=e.onWriteEntry,this[Dt]=Yi,typeof e.onwarn=="function"&&this.on("warn",e.onwarn),this.portable=!!e.portable,e.gzip||e.brotli||e.zstd){if((e.gzip?1:0)+(e.brotli?1:0)+(e.zstd?1:0)>1)throw TypeError("gzip, brotli, zstd are mutually exclusive");if(e.gzip&&(typeof e.gzip!="object"&&(e.gzip={}),this.portable&&(e.gzip.portable=!0),this.zip=new Yr(e.gzip)),e.brotli&&(typeof e.brotli!="object"&&(e.brotli={}),this.zip=new Kr(e.brotli)),e.zstd&&(typeof e.zstd!="object"&&(e.zstd={}),this.zip=new qr(e.zstd)),!this.zip)throw Error("impossible");let t=this.zip;t.on("data",i=>super.write(i)),t.on("end",()=>super.end()),t.on("drain",()=>this[di]()),this.on("resume",()=>t.resume())}else this.on("drain",this[di]);this.noDirRecurse=!!e.noDirRecurse,this.follow=!!e.follow,this.noMtime=!!e.noMtime,e.mtime&&(this.mtime=e.mtime),this.filter=typeof e.filter=="function"?e.filter:()=>!0,this[M]=new Lh,this[P]=0,this.jobs=Number(e.jobs)||4,this[Ve]=!1,this[Ye]=!1}[Xs](e){return super.write(e)}add(e){return this.write(e),this}end(e,t,i){return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e&&this.add(e),this[Ye]=!0,this[Ee](),i&&i(),this}write(e){if(this[Ye])throw Error("write after end");return e instanceof Zi?this[ps](e):this[Lt](e),this.flowing}[ps](e){let t=c(rt.resolve(this.cwd,e.path));if(!this.filter(e.path,e))e.resume();else{let i=new ki(e.path,t);i.entry=new $s(e,this[li](i)),i.entry.on("end",()=>this[ai](i)),this[P]+=1,this[M].push(i)}this[Ee]()}[Lt](e){let t=c(rt.resolve(this.cwd,e));this[M].push(new ki(e,t)),this[Ee]()}[Li](e){e.pending=!0,this[P]+=1,b[this.follow?"stat":"lstat"](e.absolute,(t,i)=>{e.pending=!1,--this[P],t?this.emit("error",t):this[kt](e,i)})}[kt](e,t){this.statCache.set(e.absolute,t),e.stat=t,this.filter(e.path,t)?t.isFile()&&t.nlink>1&&e===this[be]&&!this.linkCache.get(`${t.dev}:${t.ino}`)&&!this.sync&&this[oi](e):e.ignore=!0,this[Ee]()}[xi](e){e.pending=!0,this[P]+=1,b.readdir(e.absolute,(t,i)=>{if(e.pending=!1,--this[P],t)return this.emit("error",t);this[xt](e,i)})}[xt](e,t){this.readdirCache.set(e.absolute,t),e.readdir=t,this[Ee]()}[Ee](){if(!this[Ve]){this[Ve]=!0;for(let e=this[M].head;e&&this[P]<this.jobs;e=e.next)if(this[oi](e.value),e.value.ignore){let t=e.next;this[M].removeNode(e),e.next=t}this[Ve]=!1,this[Ye]&&this[M].length===0&&this[P]===0&&(this.zip?this.zip.end(ms):(super.write(ms),super.end()))}}get[be](){return this[M]&&this[M].head&&this[M].head.value}[ai](e){this[M].shift(),--this[P],this[Ee]()}[oi](e){if(!e.pending){if(e.entry){e===this[be]&&!e.piped&&this[At](e);return}if(!e.stat){let t=this.statCache.get(e.absolute);t?this[kt](e,t):this[Li](e)}if(e.stat&&!e.ignore){if(!this.noDirRecurse&&e.stat.isDirectory()&&!e.readdir){let t=this.readdirCache.get(e.absolute);if(t?this[xt](e,t):this[xi](e),!e.readdir)return}if(e.entry=this[ys](e),!e.entry){e.ignore=!0;return}e===this[be]&&!e.piped&&this[At](e)}}}[li](e){return{onwarn:o((t,i,s)=>this.warn(t,i,s),"onwarn"),noPax:this.noPax,cwd:this.cwd,absolute:e.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[ys](e){this[P]+=1;try{return new this[Dt](e.path,this[li](e)).on("end",()=>this[ai](e)).on("error",t=>this.emit("error",t))}catch(t){this.emit("error",t)}}[di](){this[be]&&this[be].entry&&this[be].entry.resume()}[At](e){e.piped=!0,e.readdir&&e.readdir.forEach(s=>{let r=e.path,h=r==="./"?"":r.replace(/\/*$/,"/");this[Lt](h+s)});let t=e.entry,i=this.zip;if(!t)throw Error("cannot pipe without source");i?t.on("data",s=>{i.write(s)||t.pause()}):t.on("data",s=>{super.write(s)||t.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(e,t,i={}){Pt(this,e,t,i)}},Ut=class extends ot{static{f(this,"Mi")}static{o(this,"ri")}sync=!0;constructor(e){super(e),this[Dt]=Gs}pause(){}resume(){}[Li](e){let t=this.follow?"statSync":"lstatSync";this[kt](e,b[t](e.absolute))}[xi](e){this[xt](e,b.readdirSync(e.absolute))}[At](e){let t=e.entry,i=this.zip;if(e.readdir&&e.readdir.forEach(s=>{let r=e.path,h=r==="./"?"":r.replace(/\/*$/,"/");this[Lt](h+s)}),!t)throw Error("Cannot pipe without source");i?t.on("data",s=>{i.write(s)}):t.on("data",s=>{super[Xs](s)})}},xh=o((e,t)=>{let i=new Ut(e),s=new Fs(e.file,{mode:e.mode||438});i.pipe(s),qs(i,t)},"ii"),Ah=o((e,t)=>{let i=new ot(e),s=new Ct(e.file,{mode:e.mode||438});i.pipe(s);let r=new Promise((h,n)=>{s.on("error",n),s.on("close",h),i.on("error",n)});return Js(i,t).catch(h=>i.emit("error",h)),r},"ai"),qs=o((e,t)=>{t.forEach(i=>{i.charAt(0)==="@"?Ce({file:p.resolve(e.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:o(s=>e.add(s),"onReadEntry")}):e.add(i)}),e.end()},"oi"),Js=o(async(e,t)=>{for(let i of t)i.charAt(0)==="@"?await Ce({file:p.resolve(String(e.cwd),i.slice(1)),noResume:!0,onReadEntry:o(s=>{e.add(s)},"onReadEntry")}):e.add(i);e.end()},"si"),bs=nt(xh,Ah,(e,t)=>{let i=new Ut(e);return qs(i,t),i},(e,t)=>{let i=new ot(e);return Js(i,t).catch(s=>i.emit("error",s)),i},(e,t)=>{if(!t?.length)throw TypeError("no paths specified to add to archive")}),Qs=(process.env.__FAKE_PLATFORM__||process.platform)==="win32",{O_CREAT:er,O_NOFOLLOW:Es,O_TRUNC:tr,O_WRONLY:ir}=b.constants,sr=Number(process.env.__FAKE_FS_O_FILENAME__)||b.constants.UV_FS_O_FILEMAP||0,Dh=Qs&&!!sr,Nh=512*1024,Ih=sr|tr|er|ir,gs=!Qs&&typeof Es=="number"?Es|tr|er|ir:null,rr=gs===null?Dh?e=>e<Nh?Ih:"w":()=>"w":()=>gs,Ai=o((e,t,i)=>{try{return d.lchownSync(e,t,i)}catch(s){if(s?.code!=="ENOENT")throw s}},"bi"),Bt=o((e,t,i,s)=>{d.lchown(e,t,i,r=>{s(r&&r?.code!=="ENOENT"?r:null)})},"xi"),Bh=o((e,t,i,s,r)=>{t.isDirectory()?hr(p.resolve(e,t.name),i,s,h=>{if(h)return r(h);Bt(p.resolve(e,t.name),i,s,r)}):Bt(p.resolve(e,t.name),i,s,r)},"Si"),hr=o((e,t,i,s)=>{d.readdir(e,{withFileTypes:!0},(r,h)=>{if(r){if(r.code==="ENOENT")return s();if(r.code!=="ENOTDIR"&&r.code!=="ENOTSUP")return s(r)}if(r||!h.length)return Bt(e,t,i,s);let n=h.length,a=null,l=o(u=>{if(!a){if(u)return s(a=u);if(--n===0)return Bt(e,t,i,s)}},"c");for(let u of h)Bh(e,u,t,i,l)})},"Ci"),Fh=o((e,t,i,s)=>{t.isDirectory()&&nr(p.resolve(e,t.name),i,s),Ai(p.resolve(e,t.name),i,s)},"wi"),nr=o((e,t,i)=>{let s;try{s=d.readdirSync(e,{withFileTypes:!0})}catch(r){let h=r;if(h?.code==="ENOENT")return;if(h?.code==="ENOTDIR"||h?.code==="ENOTSUP")return Ai(e,t,i);throw h}for(let r of s)Fh(e,r,t,i);return Ai(e,t,i)},"Ti"),or=class extends Error{static{f(this,"Js")}static{o(this,"Ei")}path;code;syscall="chdir";constructor(e,t){super(`${t}: Cannot cd into '${e}'`),this.path=e,this.code=t}get name(){return"CwdError"}},jt=class extends Error{static{f(this,"Pi")}static{o(this,"Di")}path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(e,t){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=e,this.path=t}get name(){return"SymlinkError"}},Ch=o((e,t)=>{d.stat(e,(i,s)=>{(i||!s.isDirectory())&&(i=new or(e,i?.code||"ENOTDIR")),t(i)})},"Oi"),Mh=o((e,t,i)=>{e=c(e);let s=t.umask??18,r=t.mode|448,h=(r&s)!==0,n=t.uid,a=t.gid,l=typeof n=="number"&&typeof a=="number"&&(n!==t.processUid||a!==t.processGid),u=t.preserve,m=t.unlink,g=c(t.cwd),w=o((L,_)=>{L?i(L):_&&l?hr(_,n,a,x=>w(x)):h?d.chmod(e,r,i):i()},"m");if(e===g)return Ch(e,w);if(u)return cr.mkdir(e,{mode:r,recursive:!0}).then(L=>w(null,L??void 0),w);Di(g,c(p.relative(g,e)).split("/"),r,m,g,void 0,w)},"ki"),Di=o((e,t,i,s,r,h,n)=>{if(t.length===0)return n(null,h);let a=t.shift(),l=c(p.resolve(e+"/"+a));d.mkdir(l,i,ar(l,t,i,s,r,h,n))},"Ai"),ar=o((e,t,i,s,r,h,n)=>a=>{a?d.lstat(e,(l,u)=>{if(l)l.path=l.path&&c(l.path),n(l);else if(u.isDirectory())Di(e,t,i,s,r,h,n);else if(s)d.unlink(e,m=>{if(m)return n(m);d.mkdir(e,i,ar(e,t,i,s,r,h,n))});else{if(u.isSymbolicLink())return n(new jt(e,e+"/"+t.join("/")));n(a)}}):(h||=e,Di(e,t,i,s,r,h,n))},"ji"),Ph=o(e=>{let t=!1,i;try{t=d.statSync(e).isDirectory()}catch(s){i=s?.code}finally{if(!t)throw new or(e,i??"ENOTDIR")}},"Mi"),zh=o((e,t)=>{e=c(e);let i=t.umask??18,s=t.mode|448,r=(s&i)!==0,h=t.uid,n=t.gid,a=typeof h=="number"&&typeof n=="number"&&(h!==t.processUid||n!==t.processGid),l=t.preserve,u=t.unlink,m=c(t.cwd),g=o(_=>{_&&a&&nr(_,h,n),r&&d.chmodSync(e,s)},"ee");if(e===m)return Ph(m),g();if(l)return g(d.mkdirSync(e,{mode:s,recursive:!0})??void 0);let w=c(p.relative(m,e)).split("/"),L;for(let _=w.shift(),x=m;_&&(x+="/"+_);_=w.shift()){x=c(p.resolve(x));try{d.mkdirSync(x,s),L||=x}catch{let Ki=d.lstatSync(x);if(Ki.isDirectory())continue;if(u){d.unlinkSync(x),d.mkdirSync(x,s),L||=x;continue}else if(Ki.isSymbolicLink())return new jt(x,x+"/"+w.join("/"))}}return g(L)},"Ni"),ui=Object.create(null),ws=1e4,ke=new Set,Uh=o(e=>{ke.has(e)?ke.delete(e):ui[e]=e.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),ke.add(e);let t=ui[e],i=ke.size-ws;if(i>ws/10){for(let s of ke)if(ke.delete(s),delete ui[s],--i<=0)break}return t},"Li"),jh=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32",Hh=o(e=>e.split("/").slice(0,-1).reduce((t,i)=>{let s=t.at(-1);return s!==void 0&&(i=Ds(s,i)),t.push(i||"/"),t},[]),"zi"),Zh=class{static{f(this,"Mh")}static{o(this,"Bi")}#e=new Map;#i=new Map;#s=new Set;reserve(e,t){e=jh?["win32 parallelization disabled"]:e.map(s=>Je(Ds(Uh(s))));let i=new Set(e.map(s=>Hh(s)).reduce((s,r)=>s.concat(r)));this.#i.set(t,{dirs:i,paths:e});for(let s of e){let r=this.#e.get(s);r?r.push(t):this.#e.set(s,[t])}for(let s of i){let r=this.#e.get(s);if(!r)this.#e.set(s,[new Set([t])]);else{let h=r.at(-1);h instanceof Set?h.add(t):r.push(new Set([t]))}}return this.#r(t)}#h(e){let t=this.#i.get(e);if(!t)throw Error("function does not have any path reservations");return{paths:t.paths.map(i=>this.#e.get(i)),dirs:[...t.dirs].map(i=>this.#e.get(i))}}check(e){let{paths:t,dirs:i}=this.#h(e);return t.every(s=>s&&s[0]===e)&&i.every(s=>s&&s[0]instanceof Set&&s[0].has(e))}#r(e){return this.#s.has(e)||!this.check(e)?!1:(this.#s.add(e),e(()=>this.#t(e)),!0)}#t(e){if(!this.#s.has(e))return!1;let t=this.#i.get(e);if(!t)throw Error("invalid reservation");let{paths:i,dirs:s}=t,r=new Set;for(let h of i){let n=this.#e.get(h);if(!n||n?.[0]!==e)continue;let a=n[1];if(!a){this.#e.delete(h);continue}if(n.shift(),typeof a=="function")r.add(a);else for(let l of a)r.add(l)}for(let h of s){let n=this.#e.get(h),a=n?.[0];if(!(!n||!(a instanceof Set)))if(a.size===1&&n.length===1){this.#e.delete(h);continue}else if(a.size===1){n.shift();let l=n[0];typeof l=="function"&&r.add(l)}else a.delete(e)}return this.#s.delete(e),r.forEach(h=>this.#r(h)),!0}},Wh=o(()=>process.umask(),"Vi"),Rs=Symbol("onEntry"),Ni=Symbol("checkFs"),_s=Symbol("checkFs2"),Ii=Symbol("isReusable"),F=Symbol("makeFs"),Bi=Symbol("file"),Fi=Symbol("directory"),Nt=Symbol("link"),Ss=Symbol("symlink"),vs=Symbol("hardlink"),Xe=Symbol("ensureNoSymlink"),Os=Symbol("unsupported"),Ts=Symbol("checkPath"),fi=Symbol("stripAbsolutePath"),ne=Symbol("mkdir"),k=Symbol("onError"),Rt=Symbol("pending"),ks=Symbol("pend"),Le=Symbol("unpend"),ci=Symbol("ended"),mi=Symbol("maybeClose"),Ci=Symbol("skip"),Qe=Symbol("doChown"),et=Symbol("uid"),tt=Symbol("gid"),it=Symbol("checkedCwd"),st=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32",Gh=1024,$h=o((e,t)=>{if(!st)return d.unlink(e,t);let i=e+".DELETE."+Is(16).toString("hex");d.rename(e,i,s=>{if(s)return t(s);d.unlink(i,t)})},"ma"),Yh=o(e=>{if(!st)return d.unlinkSync(e);let t=e+".DELETE."+Is(16).toString("hex");d.renameSync(e,t),d.unlinkSync(t)},"ha"),Ls=o((e,t,i)=>e!==void 0&&e===e>>>0?e:t!==void 0&&t===t>>>0?t:i,"ga"),Ft=class extends Ie{static{f(this,"Ni")}static{o(this,"_a")}[ci]=!1;[it]=!1;[Rt]=0;reservations=new Zh;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(e={}){if(e.ondone=()=>{this[ci]=!0,this[mi]()},super(e),this.transform=e.transform,this.chmod=!!e.chmod,typeof e.uid=="number"||typeof e.gid=="number"){if(typeof e.uid!="number"||typeof e.gid!="number")throw TypeError("cannot set owner without number uid and gid");if(e.preserveOwner)throw TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=e.uid,this.gid=e.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=e.preserveOwner===void 0&&typeof e.uid!="number"?!!(process.getuid&&process.getuid()===0):!!e.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:Gh,this.forceChown=e.forceChown===!0,this.win32=!!e.win32||st,this.newer=!!e.newer,this.keep=!!e.keep,this.noMtime=!!e.noMtime,this.preservePaths=!!e.preservePaths,this.unlink=!!e.unlink,this.cwd=c(p.resolve(e.cwd||process.cwd())),this.strip=Number(e.strip)||0,this.processUmask=this.chmod?typeof e.processUmask=="number"?e.processUmask:Wh():0,this.umask=typeof e.umask=="number"?e.umask:this.processUmask,this.dmode=e.dmode||511&~this.umask,this.fmode=e.fmode||438&~this.umask,this.on("entry",t=>this[Rs](t))}warn(e,t,i={}){return(e==="TAR_BAD_ARCHIVE"||e==="TAR_ABORT")&&(i.recoverable=!1),super.warn(e,t,i)}[mi](){this[ci]&&this[Rt]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[fi](e,t){let i=e[t],{type:s}=e;if(!i||this.preservePaths)return!0;let[r,h]=Gi(i),n=h.replaceAll(/\\/g,"/").split("/");if(n.includes("..")||st&&/^[a-z]:\.\.$/i.test(n[0]??"")){if(t==="path"||s==="Link")return this.warn("TAR_ENTRY_ERROR",`${t} contains '..'`,{entry:e,[t]:i}),!1;let a=p.posix.dirname(e.path),l=p.posix.normalize(p.posix.join(a,n.join("/")));if(l.startsWith("../")||l==="..")return this.warn("TAR_ENTRY_ERROR",`${t} escapes extraction directory`,{entry:e,[t]:i}),!1}return r&&(e[t]=String(h),this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute ${t}`,{entry:e,[t]:i})),!0}[Ts](e){let t=c(e.path),i=t.split("/");if(this.strip){if(i.length<this.strip)return!1;if(e.type==="Link"){let s=c(String(e.linkpath)).split("/");if(s.length>=this.strip)e.linkpath=s.slice(this.strip).join("/");else return!1}i.splice(0,this.strip),e.path=i.join("/")}if(isFinite(this.maxDepth)&&i.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:e,path:t,depth:i.length,maxDepth:this.maxDepth}),!1;if(!this[fi](e,"path")||!this[fi](e,"linkpath"))return!1;if(e.absolute=p.isAbsolute(e.path)?c(p.resolve(e.path)):c(p.resolve(this.cwd,e.path)),!this.preservePaths&&typeof e.absolute=="string"&&e.absolute.indexOf(this.cwd+"/")!==0&&e.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:e,path:c(e.path),resolvedPath:e.absolute,cwd:this.cwd}),!1;if(e.absolute===this.cwd&&e.type!=="Directory"&&e.type!=="GNUDumpDir")return!1;if(this.win32){let{root:s}=p.win32.parse(String(e.absolute));e.absolute=s+ls(String(e.absolute).slice(s.length));let{root:r}=p.win32.parse(e.path);e.path=r+ls(e.path.slice(r.length))}return!0}[Rs](e){if(!this[Ts](e))return e.resume();switch(Rr.equal(typeof e.absolute,"string"),e.type){case"Directory":case"GNUDumpDir":e.mode&&(e.mode|=448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Ni](e);default:return this[Os](e)}}[k](e,t){e.name==="CwdError"?this.emit("error",e):(this.warn("TAR_ENTRY_ERROR",e,{entry:t}),this[Le](),t.resume())}[ne](e,t,i){Mh(c(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:t},i)}[Qe](e){return this.forceChown||this.preserveOwner&&(typeof e.uid=="number"&&e.uid!==this.processUid||typeof e.gid=="number"&&e.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[et](e){return Ls(this.uid,e.uid,this.processUid)}[tt](e){return Ls(this.gid,e.gid,this.processGid)}[Bi](e,t){let i=typeof e.mode=="number"?e.mode&4095:this.fmode,s=new Ct(String(e.absolute),{flags:rr(e.size),mode:i,autoClose:!1});s.on("error",a=>{s.fd&&d.close(s.fd,()=>{}),s.write=()=>!0,this[k](a,e),t()});let r=1,h=o(a=>{if(a){s.fd&&d.close(s.fd,()=>{}),this[k](a,e),t();return}--r===0&&s.fd!==void 0&&d.close(s.fd,l=>{l?this[k](l,e):this[Le](),t()})},"o");s.on("finish",()=>{let a=String(e.absolute),l=s.fd;if(typeof l=="number"&&e.mtime&&!this.noMtime){r++;let u=e.atime||new Date,m=e.mtime;d.futimes(l,u,m,g=>g?d.utimes(a,u,m,w=>h(w&&g)):h())}if(typeof l=="number"&&this[Qe](e)){r++;let u=this[et](e),m=this[tt](e);typeof u=="number"&&typeof m=="number"&&d.fchown(l,u,m,g=>g?d.chown(a,u,m,w=>h(w&&g)):h())}h()});let n=this.transform&&this.transform(e)||e;n!==e&&(n.on("error",a=>{this[k](a,e),t()}),e.pipe(n)),n.pipe(s)}[Fi](e,t){let i=typeof e.mode=="number"?e.mode&4095:this.dmode;this[ne](String(e.absolute),i,s=>{if(s){this[k](s,e),t();return}let r=1,h=o(()=>{--r===0&&(t(),this[Le](),e.resume())},"a");e.mtime&&!this.noMtime&&(r++,d.utimes(String(e.absolute),e.atime||new Date,e.mtime,h)),this[Qe](e)&&(r++,d.chown(String(e.absolute),Number(this[et](e)),Number(this[tt](e)),h)),h()})}[Os](e){e.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${e.type}`,{entry:e}),e.resume()}[Ss](e,t){let i=c(p.relative(this.cwd,p.resolve(p.dirname(String(e.absolute)),String(e.linkpath)))).split("/");this[Xe](e,this.cwd,i,()=>this[Nt](e,String(e.linkpath),"symlink",t),s=>{this[k](s,e),t()})}[vs](e,t){let i=c(p.resolve(this.cwd,String(e.linkpath))),s=c(String(e.linkpath)).split("/");this[Xe](e,this.cwd,s,()=>this[Nt](e,i,"link",t),r=>{this[k](r,e),t()})}[Xe](e,t,i,s,r){let h=i.shift();if(this.preservePaths||h===void 0)return s();let n=p.resolve(t,h);d.lstat(n,(a,l)=>{if(a)return s();if(l?.isSymbolicLink())return r(new jt(n,p.resolve(n,i.join("/"))));this[Xe](e,n,i,s,r)})}[ks](){this[Rt]++}[Le](){this[Rt]--,this[mi]()}[Ci](e){this[Le](),e.resume()}[Ii](e,t){return e.type==="File"&&!this.unlink&&t.isFile()&&t.nlink<=1&&!st}[Ni](e){this[ks]();let t=[e.path];e.linkpath&&t.push(e.linkpath),this.reservations.reserve(t,i=>this[_s](e,i))}[_s](e,t){let i=o(n=>{t(n)},"r"),s=o(()=>{this[ne](this.cwd,this.dmode,n=>{if(n){this[k](n,e),i();return}this[it]=!0,r()})},"a"),r=o(()=>{if(e.absolute!==this.cwd){let n=c(p.dirname(String(e.absolute)));if(n!==this.cwd)return this[ne](n,this.dmode,a=>{if(a){this[k](a,e),i();return}h()})}h()},"o"),h=o(()=>{d.lstat(String(e.absolute),(n,a)=>{if(a&&(this.keep||this.newer&&a.mtime>(e.mtime??a.mtime))){this[Ci](e),i();return}if(n||this[Ii](e,a))return this[F](null,e,i);if(a.isDirectory()){if(e.type==="Directory"){let l=this.chmod&&e.mode&&(a.mode&4095)!==e.mode,u=o(m=>this[F](m??null,e,i),"a");return l?d.chmod(String(e.absolute),Number(e.mode),u):u()}if(e.absolute!==this.cwd)return d.rmdir(String(e.absolute),l=>this[F](l??null,e,i))}if(e.absolute===this.cwd)return this[F](null,e,i);$h(String(e.absolute),l=>this[F](l??null,e,i))})},"s");this[it]?r():s()}[F](e,t,i){if(e){this[k](e,t),i();return}switch(t.type){case"File":case"OldFile":case"ContiguousFile":return this[Bi](t,i);case"Link":return this[vs](t,i);case"SymbolicLink":return this[Ss](t,i);case"Directory":case"GNUDumpDir":return this[Fi](t,i)}}[Nt](e,t,i,s){d[i](t,String(e.absolute),r=>{r?this[k](r,e):(this[Le](),e.resume()),s()})}},Ke=o(e=>{try{return[null,e()]}catch(t){return[t,null]}},"va"),Mi=class extends Ft{static{f(this,"Be")}static{o(this,"ya")}sync=!0;[F](e,t){return super[F](e,t,()=>{})}[Ni](e){if(!this[it]){let r=this[ne](this.cwd,this.dmode);if(r)return this[k](r,e);this[it]=!0}if(e.absolute!==this.cwd){let r=c(p.dirname(String(e.absolute)));if(r!==this.cwd){let h=this[ne](r,this.dmode);if(h)return this[k](h,e)}}let[t,i]=Ke(()=>d.lstatSync(String(e.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(e.mtime??i.mtime)))return this[Ci](e);if(t||this[Ii](e,i))return this[F](null,e);if(i.isDirectory()){if(e.type==="Directory"){let[h]=this.chmod&&e.mode&&(i.mode&4095)!==e.mode?Ke(()=>{d.chmodSync(String(e.absolute),Number(e.mode))}):[];return this[F](h,e)}let[r]=Ke(()=>d.rmdirSync(String(e.absolute)));this[F](r,e)}let[s]=e.absolute===this.cwd?[]:Ke(()=>Yh(String(e.absolute)));this[F](s,e)}[Bi](e,t){let i=typeof e.mode=="number"?e.mode&4095:this.fmode,s=o(n=>{let a;try{d.closeSync(r)}catch(l){a=l}(n||a)&&this[k](n||a,e),t()},"i"),r;try{r=d.openSync(String(e.absolute),rr(e.size),i)}catch(n){return s(n)}let h=this.transform&&this.transform(e)||e;h!==e&&(h.on("error",n=>this[k](n,e)),e.pipe(h)),h.on("data",n=>{try{d.writeSync(r,n,0,n.length)}catch(a){s(a)}}),h.on("end",()=>{let n=null;if(e.mtime&&!this.noMtime){let a=e.atime||new Date,l=e.mtime;try{d.futimesSync(r,a,l)}catch(u){try{d.utimesSync(String(e.absolute),a,l)}catch{n=u}}}if(this[Qe](e)){let a=this[et](e),l=this[tt](e);try{d.fchownSync(r,Number(a),Number(l))}catch(u){try{d.chownSync(String(e.absolute),Number(a),Number(l))}catch{n||=u}}}s(n)})}[Fi](e,t){let i=typeof e.mode=="number"?e.mode&4095:this.dmode,s=this[ne](String(e.absolute),i);if(s){this[k](s,e),t();return}if(e.mtime&&!this.noMtime)try{d.utimesSync(String(e.absolute),e.atime||new Date,e.mtime)}catch{}if(this[Qe](e))try{d.chownSync(String(e.absolute),Number(this[et](e)),Number(this[tt](e)))}catch{}t(),e.resume()}[ne](e,t){try{return zh(c(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:t})}catch(i){return i}}[Xe](e,t,i,s,r){if(this.preservePaths||i.length===0)return s();let h=t;for(let n of i){h=p.resolve(h,n);let[a,l]=Ke(()=>d.lstatSync(h));if(a)return s();if(l.isSymbolicLink())return r(new jt(h,p.resolve(t,i.join("/"))))}s()}[Nt](e,t,i,s){let r=`${i}Sync`;try{d[r](t,String(e.absolute)),s(),e.resume()}catch(h){return this[k](h,e)}}},xs=nt(e=>{let t=new Mi(e),i=e.file,s=d.statSync(i);new Cr(i,{readSize:e.maxReadSize||16*1024*1024,size:s.size}).pipe(t)},(e,t)=>{let i=new Ft(e),s=e.maxReadSize||16*1024*1024,r=e.file;return new Promise((h,n)=>{i.on("error",n),i.on("close",h),d.stat(r,(a,l)=>{if(a)n(a);else{let u=new zi(r,{readSize:s,size:l.size});u.on("error",n),u.pipe(i)}})})},e=>new Mi(e),e=>new Ft(e),(e,t)=>{t?.length&&Wi(e,t)}),Vh=o((e,t)=>{let i=new Ut(e),s=!0,r,h;try{try{r=d.openSync(e.file,"r+")}catch(l){if(l?.code==="ENOENT")r=d.openSync(e.file,"w+");else throw l}let n=d.fstatSync(r),a=Buffer.alloc(512);e:for(h=0;h<n.size;h+=512){for(let m=0,g=0;m<512;m+=g){if(g=d.readSync(r,a,m,a.length-m,h+m),h===0&&a[0]===31&&a[1]===139)throw Error("cannot append to compressed archives");if(!g)break e}let l=new le(a);if(!l.cksumValid)break;let u=512*Math.ceil((l.size||0)/512);if(h+u+512>n.size)break;h+=u,e.mtimeCache&&l.mtime&&e.mtimeCache.set(String(l.path),l.mtime)}s=!1,Kh(e,i,h,r,t)}finally{if(s)try{d.closeSync(r)}catch{}}},"xa"),Kh=o((e,t,i,s,r)=>{let h=new Fs(e.file,{fd:s,start:i});t.pipe(h),qh(t,r)},"Sa"),Xh=o((e,t)=>{t=Array.from(t);let i=new ot(e),s=o((r,h,n)=>{let a=o((w,L)=>{w?d.close(r,_=>n(w)):n(null,L)},"a"),l=0;if(h===0)return a(null,0);let u=0,m=Buffer.alloc(512),g=o((w,L)=>{if(w||L===void 0)return a(w);if(u+=L,u<512&&L)return d.read(r,m,u,m.length-u,l+u,g);if(l===0&&m[0]===31&&m[1]===139)return a(Error("cannot append to compressed archives"));if(u<512)return a(null,l);let _=new le(m);if(!_.cksumValid)return a(null,l);let x=512*Math.ceil((_.size??0)/512);if(l+x+512>h||(l+=x+512,l>=h))return a(null,l);e.mtimeCache&&_.mtime&&e.mtimeCache.set(String(_.path),_.mtime),u=0,d.read(r,m,0,512,l,g)},"l");d.read(r,m,0,512,l,g)},"i");return new Promise((r,h)=>{i.on("error",h);let n="r+",a=o((l,u)=>{if(l&&l.code==="ENOENT"&&n==="r+")return n="w+",d.open(e.file,n,a);if(l||!u)return h(l);d.fstat(u,(m,g)=>{if(m)return d.close(u,()=>h(m));s(u,g.size,(w,L)=>{if(w)return h(w);let _=new Ct(e.file,{fd:u,start:L});i.pipe(_),_.on("error",h),_.on("close",r),Jh(i,t)})})},"c");d.open(e.file,n,a)})},"Ca"),qh=o((e,t)=>{t.forEach(i=>{i.charAt(0)==="@"?Ce({file:p.resolve(e.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:o(s=>e.add(s),"onReadEntry")}):e.add(i)}),e.end()},"wa"),Jh=o(async(e,t)=>{for(let i of t)i.charAt(0)==="@"?await Ce({file:p.resolve(String(e.cwd),i.slice(1)),noResume:!0,onReadEntry:o(s=>e.add(s),"onReadEntry")}):e.add(i);e.end()},"Ta"),ge=nt(Vh,Xh,()=>{throw TypeError("file is required")},()=>{throw TypeError("file is required")},(e,t)=>{if(!Hr(e))throw TypeError("file is required");if(e.gzip||e.brotli||e.zstd||e.file.endsWith(".br")||e.file.endsWith(".tbr"))throw TypeError("cannot append to compressed archives");if(!t?.length)throw TypeError("no paths specified to add/replace")});nt(ge.syncFile,ge.asyncFile,ge.syncNoFile,ge.asyncNoFile,(e,t=[])=>{ge.validate?.(e,t),Qh(e)});var Qh=o(e=>{let t=e.filter;e.mtimeCache||=new Map,e.filter=t?(i,s)=>t(i,s)&&!((e.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0)):(i,s)=>!((e.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0))},"Da");export{rn as t};
@@ -0,0 +1,2 @@
1
+ var y=Object.defineProperty;var d=(r,n)=>y(r,"name",{value:n,configurable:!0});import{createRequire as w}from"node:module";import{M as u,l as f}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{s as m,E as k}from"./config.js";import{p as e}from"./bin.js";import{A as j}from"../packem_shared/pm-runner-DmKT2FqF.js";const v=w(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=d(r=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[n,s]=l.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return l.getBuiltinModule(r)}return v(r)},"__cjs_getBuiltinModule"),{spawnSync:h}=$("node:child_process");var _=Object.defineProperty,c=d((r,n)=>_(r,"name",{value:n,configurable:!0}),"c");const t="@lavamoat/preinstall-always-fail",p=c(r=>{const n=u(r,"package.json");if(!f(n))return"no-package-json";try{const s=m(n);if(s.devDependencies?.[t]||s.dependencies?.[t])return"installed"}catch{}return"missing"},"tripwireStatus"),b=c(r=>{const n=u(r,"package.json");if(!f(n))return!1;try{const s=m(n);let o=!1;const a=c(i=>!i||!(t in i)?i:(o=!0,Object.fromEntries(Object.entries(i).filter(([g])=>g!==t))),"stripFrom");return s.devDependencies=a(s.devDependencies),s.dependencies=a(s.dependencies),o&&k(n,`${JSON.stringify(s,null,2)}
2
+ `),o}catch{return!1}},"removeFromPackageJson"),O=c(({options:r,workspaceRoot:n})=>{const s=n??process.cwd();if(r.status){switch(p(s)){case"installed":{e.success(`Preinstall tripwire is installed (${t}).`),e.info("Removing 'ignore-scripts=true' will cause future installs to fail loudly.");break}case"missing":{e.warn("Preinstall tripwire is not installed."),e.info(`Run 'vis security tripwire' to add ${t} as a devDependency.`);break}default:e.error("No package.json found at the workspace root."),process.exitCode=1}return}if(r.remove){b(s)?e.success(`Removed ${t} from package.json. Run your PM's install to clean node_modules.`):e.info(`${t} was not present in package.json.`);return}if(p(s)==="installed"){e.info(`${t} is already installed.`);return}const o=j(s),a={bun:["add","-d",t],npm:["install","--save-dev",t],pnpm:["add","-D","-w",t],yarn:["add","-D",t]}[o.name];if(!a){e.error(`Cannot install tripwire — unsupported package manager '${o.name}'.`),process.exitCode=1;return}e.info(`Installing ${t} via ${o.name}…`);const i=h(o.name,a,{cwd:s,stdio:"inherit"});if(i.error){e.error(`Failed to install tripwire: ${i.error.message}`),process.exitCode=1;return}if(i.signal!==null){e.error(`${o.name} was terminated by signal ${i.signal}`),process.exitCode=1;return}if(i.status!==0){e.error(`${o.name} exited with code ${String(i.status)}`),process.exitCode=i.status??1;return}e.success(`Installed ${t} as a devDependency.`),e.notice(""),e.notice("How the tripwire works:"),e.notice(` ${t} declares a preinstall script that always fails.`),e.notice(" When 'ignore-scripts=true' is set (.npmrc / bunfig.toml / .yarnrc.yml),"),e.notice(" the script is skipped and installs succeed normally. If someone deletes"),e.notice(" that setting, the next install fails — loudly — instead of silently"),e.notice(" running every dependency's lifecycle scripts.")},"execute");export{O as default};
@@ -0,0 +1,2 @@
1
+ var $=Object.defineProperty;var k=(e,o)=>$(e,"name",{value:o,configurable:!0});import{p}from"./bin.js";import{A as S}from"../packem_shared/pm-runner-DmKT2FqF.js";import{r as v,l as x,L as C}from"../packem_shared/dependency-scan-BUbOcMwX.js";import{B as M,M as h,l as L}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{S as E}from"../packem_shared/lockfile-CrT86D6d.js";import{e as P}from"../packem_shared/index-D1xC1Y_R.js";var D=Object.defineProperty,m=k((e,o)=>D(e,"name",{value:o,configurable:!0}),"r");const V=m(e=>{const o=e.trim();return o===""?!1:/^(?:git\+|git:\/\/|git@|ssh:\/\/)/i.test(o)||/^(?:github|gitlab|bitbucket|gist):/i.test(o)||/^[\w.-]+\/[\w.-]+(?:#.+)?$/.test(o)&&!o.includes("@")?!0:/^https?:\/\//i.test(o)},"isExoticSpecifier"),N=m((e,o)=>{for(const s of o)if(s===e||s.endsWith("*")&&e.startsWith(s.slice(0,-1)))return!0;return!1},"matchesAllow"),O=m((e,o,s={})=>{const t=v(e,o);if(!t)return[];let i;try{i=M(h(e,t.file))}catch{return[]}const n=E(i,t.type);if(n.length===0)return[];const c=s.allow??[],l=[],f=new Set;for(const r of n){const a=`${r.name}@${r.version}`;for(const g of[r.dependencies,r.optionalDependencies])if(g){for(const[u,w]of Object.entries(g))if(!N(u,c))for(const y of w){if(!V(y))continue;const b=`${a}->${u}@${y}`;f.has(b)||(f.add(b),l.push({declaredBy:a,packageName:u,source:y}))}}}return l.sort((r,a)=>r.packageName.localeCompare(a.packageName)||r.declaredBy.localeCompare(a.declaredBy))},"scanExoticSubdeps");var R=Object.defineProperty,d=k((e,o)=>R(e,"name",{value:o,configurable:!0}),"n");const j=new Set(["firstSeen","publisherChange"]),B=d(e=>e.severity==="block"&&e.acceptedRisk===void 0,"isGatingDecision"),A=d(e=>{const o=e.security?.policies?.firstSeen?.minutes,s=typeof o=="number"&&o>0,t=e.security?.policies?.publisherChange?.mode==="no-downgrade",i=e.security?.blockExoticSubdeps===!0;return s||t||i},"anyPolicyConfigured"),F=d(async e=>{const{offline:o=!1,packageManager:s,visConfig:t,workspaceRoot:i}=e,n=Date.now();if(!A(t))return{decisions:[],durationMs:Date.now()-n,entryCount:0,exoticViolations:[],lockfileMissing:!1,status:"skipped"};const c=v(i,s);if(!c||!L(h(i,c.file)))return{decisions:[],durationMs:Date.now()-n,entryCount:0,exoticViolations:[],lockfileMissing:!0,status:"fail"};const l=x(i,s,{includeDev:!0}),f=l.length,r=await P({offline:o,packageManager:s,packages:l,workspaceRoot:i},"install",{enabledPolicies:new Set(j),visConfig:t}),a=t.security?.blockExoticSubdeps===!0?O(i,s,{allow:t.security.exoticSubdepsAllow}):[],g=r.some(u=>B(u))||a.length>0;return{decisions:r,durationMs:Date.now()-n,entryCount:f,exoticViolations:a,lockfileMissing:!1,status:g?"fail":"pass"}},"verifyLockfile"),W=d(e=>e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`,"formatElapsed"),G=d(e=>{if(e.status==="skipped")return["– Lockfile supply-chain verification skipped (no firstSeen / publisherChange / blockExoticSubdeps policy configured)"];if(e.lockfileMissing)return["✗ Lockfile supply-chain verification failed — no lockfile found, the resolved closure cannot be attested"];const o=`(${String(e.entryCount)} ${e.entryCount===1?"entry":"entries"}, ${W(e.durationMs)})`;if(e.status==="pass")return[`✓ Lockfile passes supply-chain policies ${o}`];const s=[`✗ Lockfile failed supply-chain policy check ${o}`];for(const t of e.decisions)t.severity==="block"&&t.acceptedRisk===void 0&&s.push(` [${t.policy}] ${t.reason}`);for(const t of e.exoticViolations)s.push(` [blockExoticSubdeps] ${t.packageName} pulled from exotic source by ${t.declaredBy}: ${t.source}`);return s},"formatLockfileVerification");var I=Object.defineProperty,J=k((e,o)=>I(e,"name",{value:o,configurable:!0}),"a");const U=J(async({options:e,visConfig:o,workspaceRoot:s})=>{const t=s??process.cwd(),i=S(t);if(!C[i.name]){p.warn(`Package manager '${i.name}' has no lockfile vis can verify.`);return}const n=await F({offline:!!e.offline,packageManager:i.name,visConfig:o??{},workspaceRoot:t});if(e.json){process.stdout.write(`${JSON.stringify(n,void 0,2)}
2
+ `),n.status==="fail"&&(process.exitCode=1);return}const[c,...l]=G(n);if(n.status==="skipped"){p.info(c);return}if(n.status==="pass"){p.success(c);return}p.error(c);for(const f of l)p.error(f);process.exitCode=1},"execute");export{U as default};
@@ -0,0 +1,12 @@
1
+ var Xe=Object.defineProperty;var O=(t,e)=>Xe(t,"name",{value:e,configurable:!0});import{createRequire as Qe}from"node:module";const ti=Qe(import.meta.url),at=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ei=O(t=>{if(typeof at<"u"&&at.versions&&at.versions.node){const[e,i]=at.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return at.getBuiltinModule(t)}return ti(t)},"__cjs_getBuiltinModule"),{createRequire:ii}=ei("node:module"),wt=0,G=1,ct=2,V=3;var ri=Object.defineProperty,oi=O((t,e)=>ri(t,"name",{value:e,configurable:!0}),"p$2"),ni=Object.defineProperty,si=oi((t,e)=>ni(t,"name",{value:e,configurable:!0}),"_"),hi=Object.defineProperty,jt=si((t,e)=>hi(t,"name",{value:e,configurable:!0}),"u");const ai=/^-{1,2}(no-color|no-colors|color=false|color=never)$/,ci=/^-{1,2}(color=256)$/,li=/^-{1,2}(color=16m|color=full|color=truecolor)$/,di=/^-{1,2}(color|colors|color=true|color=always)$/,ui=/-mono|dumb/i,fi=/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/,mi=/-256(color)?$/i,gi=/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i,je=jt(t=>{const e=globalThis,i=e.Deno!=null,r=e.process??e.Deno??{},a=r.argv??r.args??[],s=jt(g=>{const w=a.indexOf("--"),f=a.findIndex(v=>g.test(v));return f!==-1&&(w===-1||f<w)},"oneOfFlags");let o={};try{o=i?r.env.toObject():r.env??{}}catch{}const h="FORCE_COLOR",n=h in o,c=o[h]??void 0,d=Object.prototype.toString.call(c).slice(8,-1)==="String",l=typeof c=="number";let u;if(c==="true")u=G;else if(c==="false")u=wt;else if(d&&c.length===0)u=G;else if(d&&c.length>0){const g=Number.parseInt(c,10);u=Number.isNaN(g)?void 0:Math.min(g,3)}else l&&(u=Number.isNaN(c)?void 0:Math.min(c,3));if(c!=="true"&&c!=="false"&&u!==void 0&&u<4)return u;if("NO_COLOR"in o||n&&u===0||s(ai))return wt;if(s(ci))return ct;if(s(li))return V;if(s(di))return G;const p=u??wt;if("TF_BUILD"in o&&"AGENT_NAME"in o)return G;if(o.TERM&&ui.test(o.TERM))return p;if((i?e.Deno.build.os:r.platform)==="win32")try{const g=(i?e.Deno.osRelease():r.os.release()).split(".");return Number(g[0])>=10&&Number(g[2])>=10586?Number(g[2])>=14931?V:ct:G}catch{}if("CI"in o)return["GITEA_ACTIONS","CIRCLECI","GITHUB_WORKFLOW","GITHUB_ACTIONS"].some(g=>g in o)?V:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(g=>g in o)||o.CI_NAME==="codeship"?G:p;if(o.TERMINAL_EMULATOR?.includes("JediTerm"))return V;if("TEAMCITY_VERSION"in o)return fi.test(o.TEAMCITY_VERSION)?G:wt;if(o.COLORTERM==="truecolor"||o.TERM==="xterm-kitty"||o.TERM==="xterm-ghostty"||o.TERM==="wezterm")return V;if("TERM_PROGRAM"in o){const g=Number.parseInt((o.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(o.TERM_PROGRAM==="iTerm.app")return g>=3?V:ct;if(o.TERM_PROGRAM==="Apple_Terminal")return ct}if(mi.test(o.TERM))return ct;let m;return i?m=t==="out"?e.Deno.stdout.isTerminal():e.Deno.stderr.isTerminal():"PM2_HOME"in o&&"pm_id"in o?m=!0:m=!!r[`std${t}`]?.isTTY,m&&gi.test(o.TERM)||"COLORTERM"in o?G:p},"isColorSupportedFactory"),pi=jt(()=>je("out"),"isStdoutColorSupported");jt(()=>je("err"),"isStderrColorSupported");var wi=Object.defineProperty,Ce=O((t,e)=>wi(t,"name",{value:e,configurable:!0}),"B$1"),bi=Object.defineProperty,q=Ce((t,e)=>bi(t,"name",{value:e,configurable:!0}),"u"),yi=Object.defineProperty,xi=q((t,e)=>yi(t,"name",{value:e,configurable:!0}),"e$1");function Ot({onlyFirst:t=!1}={}){const e="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(e,t?void 0:"g")}O(Ot,"x");Ce(Ot,"N");q(Ot,"t$1");xi(Ot,"ansiRegex");var vi=Object.defineProperty,Bi=q((t,e)=>vi(t,"name",{value:e,configurable:!0}),"n$1");const z=Bi((t,e,i)=>e>t?e:Math.min(t,i),"clamp");var Ri=Object.defineProperty,Wi=q((t,e)=>Ri(t,"name",{value:e,configurable:!0}),"a$1");const Si=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,Ii=Wi(t=>{let[,e]=Si.exec(t)??[];const i=e?e.length:0;if(i===3){const a=e.charAt(0),s=e.charAt(1),o=e.charAt(2);e=a+a+s+s+o+o}else if(i!==6)return[0,0,0];const r=Number.parseInt(e,16);return[r>>16&255,r>>8&255,r&255]},"convertHexToRgb");var Mi=Object.defineProperty,te=q((t,e)=>Mi(t,"name",{value:e,configurable:!0}),"e");const $e=te((t,e,i)=>t===e&&e===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/51)+6*Math.round(e/51)+Math.round(i/51),"rgbToAnsi256"),zt=te(t=>{let e,i,r;if(t<8)return 30+t;if(t<16)return 90+(t-8);if(t>=232)e=i=r=((t-232)*10+8)/255;else{t-=16;const o=t%36;e=Math.floor(t/36)/5,i=Math.floor(o/6)/5,r=o%6/5}const a=Math.max(e,i,r)*2;if(a===0)return 30;const s=30+(Math.round(r)<<2|Math.round(i)<<1|Math.round(e));return a===2?s+60:s},"ansi256To16"),he=te((t,e,i)=>zt($e(t,e,i)),"rgbToAnsi16");var Ai=Object.defineProperty,N=q((t,e)=>Ai(t,"name",{value:e,configurable:!0}),"b");const j=39,C=49,ae=10,Dt=pi(),Ee={close:"",open:""},y=Dt>0?(t,e)=>({close:`\x1B[${String(e)}m`,open:`\x1B[${String(t)}m`}):()=>Ee,ce=N(t=>(e,i,r)=>t($e(Number(e),Number(i),Number(r))),"createRgbFunction"),le=N(t=>e=>{const[i,r,a]=Ii(e);return t(i,r,a)},"createHexFunction");let Yt=N(t=>y(`38;5;${String(t)}`,j),"createAnsi256"),qt=N(t=>y(`48;5;${String(t)}`,C),"createBgAnsi256"),Ct=N((t,e,i)=>y(`38;2;${String(t)};${String(e)};${String(i)}`,j),"createRgb"),$t=N((t,e,i)=>y(`48;2;${String(t)};${String(e)};${String(i)}`,C),"createBgRgb");Dt===1?(Yt=N(t=>y(zt(Number(t)),j),"createAnsi256"),qt=N(t=>y(zt(Number(t))+ae,C),"createBgAnsi256"),Ct=N((t,e,i)=>y(he(Number(t),Number(e),Number(i)),j),"createRgb"),$t=N((t,e,i)=>y(he(Number(t),Number(e),Number(i))+ae,C),"createBgRgb")):Dt===2&&(Ct=ce(Yt),$t=ce(qt));const de={bold:y(1,22),dim:y(2,22),hidden:y(8,28),inverse:y(7,27),italic:y(3,23),overline:y(53,55),reset:y(0,0),strike:y(9,29),strikethrough:y(9,29),underline:y(4,24),visible:Ee},ue={bgBlack:y(40,C),bgBlackBright:y(100,C),bgBlue:y(44,C),bgBlueBright:y(104,C),bgCyan:y(46,C),bgCyanBright:y(106,C),bgGray:y(100,C),bgGreen:y(42,C),bgGreenBright:y(102,C),bgGrey:y(100,C),bgMagenta:y(45,C),bgMagentaBright:y(105,C),bgRed:y(41,C),bgRedBright:y(101,C),bgWhite:y(47,C),bgWhiteBright:y(107,C),bgYellow:y(43,C),bgYellowBright:y(103,C),black:y(30,j),blackBright:y(90,j),blue:y(34,j),blueBright:y(94,j),cyan:y(36,j),cyanBright:y(96,j),gray:y(90,j),green:y(32,j),greenBright:y(92,j),grey:y(90,j),magenta:y(35,j),magentaBright:y(95,j),red:y(31,j),redBright:y(91,j),white:y(37,j),whiteBright:y(97,j),yellow:y(33,j),yellowBright:y(93,j)},fe={bg:N(t=>qt(z(t,0,255)),"bg"),bgHex:le($t),bgRgb:N((t,e,i)=>$t(z(t,0,255),z(e,0,255),z(i,0,255)),"bgRgb"),fg:N(t=>Yt(z(t,0,255)),"fg"),hex:le(Ct),rgb:N((t,e,i)=>Ct(z(t,0,255),z(e,0,255),z(i,0,255)),"rgb")};var ji=Object.defineProperty,Ci=q((t,e)=>ji(t,"name",{value:e,configurable:!0}),"s");const $i=Ci((t,e,i)=>{if(e==="")return t;let r=t.indexOf(e);if(r<0)return t;const a=e.length;let s=0,o="";for(;~r;)o+=t.slice(s,r)+i,s=r+a,r=t.indexOf(e,s);return o+t.slice(s)},"stringReplaceAll");var Ei=Object.defineProperty,ut=q((t,e)=>Ei(t,"name",{value:e,configurable:!0}),"a");const Y={};let Ut=null;const Oi=ut((t,e,i)=>{if(!t)return"";let r;if(t.raw===void 0?r=String(t):r=String.raw(t,...e),r.includes("\x1B"))for(let a=i;a;a=a.props)r=$i(r,a.close,a.open);return r.includes(`
2
+ `)&&(r=r.replace(/(\r*\n)/g,`${i.closeStack}$1${i.openStack}`)),i.openStack+r+i.closeStack},"wrapText"),Kt=ut(({props:t},{close:e,open:i})=>{const r=(t?.openStack??"")+i,a=e+(t?.closeStack??""),s=ut((o,...h)=>Oi(o,h,s.props),"style");return Object.setPrototypeOf(s,Ut),s.props={close:e,closeStack:a,open:i,openStack:r,props:t},s.open=r,s.close=a,s},"createStyle"),Ni=ut(function(){const t=ut(e=>String(e),"self");t.strip=e=>e.replaceAll(Ot(),"");for(const e in ue)Y[e]={get(){const i=Kt(this,ue[e]);return Object.defineProperty(this,e,{value:i}),i}};for(const e in de)Y[e]={get(){const i=Kt(this,de[e]);return Object.defineProperty(this,e,{value:i}),i}};return Ut=Object.defineProperties({},Y),Object.setPrototypeOf(t,Ut),t},"Colorize");for(const t in fe)Y[t]={get(){return(...e)=>Kt(this,fe[t](...e))}};Y.ansi256=Y.fg;Y.bgAnsi256=Y.bg;const U=new Ni,mo=U.bold,go=U.cyan,po=U.dim,wo=U.green,bo=U.inverse,yo=U.magenta,xo=U.red,vo=U.yellow;var Ti=Object.defineProperty,J=O((t,e)=>Ti(t,"name",{value:e,configurable:!0}),"F"),ki=Object.defineProperty,S=J((t,e)=>ki(t,"name",{value:e,configurable:!0}),"W");const Li=ii(import.meta.url),ot=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ee=S(t=>{if(typeof ot<"u"&&ot.versions&&ot.versions.node){const[e,i]=ot.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return ot.getBuiltinModule(t)}return Li(t)},"__cjs_getBuiltinModule"),Q=ot,{execFileSync:Fi}=ee("node:child_process"),dt=ee("node:fs"),Pi=ee("node:tty");var _i=Object.defineProperty,K=S((t,e)=>_i(t,"name",{value:e,configurable:!0}),"e$4");const Ji=[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],Hi=12288,Gi=65510,Vi=[12288,12288,65281,65376,65504,65510],zi=8361,Di=65518,Yi=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],qi=32,Ui=10630,Ki=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Zi=4352,Xi=262141,Oe=[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],mt=K((t,e)=>{let i=0,r=Math.floor(t.length/2)-1;for(;i<=r;){const a=Math.floor((i+r)/2),s=a*2;if(e<t[s])r=a-1;else if(e>t[s+1])i=a+1;else return!0}return!1},"s"),me=19968,[Qi,tr]=Nt(Oe);function Nt(t){let e=t[0],i=t[1];for(let r=0;r<t.length;r+=2){const a=t[r],s=t[r+1];if(me>=a&&me<=s)return[a,s];s-a>i-e&&(e=a,i=s)}return[e,i]}O(Nt,"Et");J(Nt,"zt");S(Nt,"W$3");K(Nt,"W");const Ne=K(t=>t<161||t>1114109?!1:mt(Ji,t),"j"),Te=K(t=>t<Hi||t>Gi?!1:mt(Vi,t),"k"),er=K(t=>t<zi||t>Di?!1:mt(Yi,t),"p"),ir=K(t=>t<qi||t>Ui?!1:mt(Ki,t),"y"),ke=K(t=>t>=Qi&&t<=tr?!0:t<Zi||t>Xi?!1:mt(Oe,t),"A");function Tt(t){return Ne(t)?"ambiguous":Te(t)?"fullwidth":er(t)?"halfwidth":ir(t)?"narrow":ke(t)?"wide":"neutral"}O(Tt,"Ct");J(Tt,"Kt");S(Tt,"z$1");K(Tt,"E");var rr=Object.defineProperty,ie=S((t,e)=>rr(t,"name",{value:e,configurable:!0}),"i$3");function gt(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}O(gt,"ft");J(gt,"$t");S(gt,"r$3");ie(gt,"t");function pt(t){return gt(t),Tt(t)}O(pt,"mt");J(pt,"It");S(pt,"d$4");ie(pt,"u");function re(t,{ambiguousAsWide:e=!1}={}){return gt(t),Te(t)||ke(t)||e&&Ne(t)?2:1}O(re,"Zt");J(re,"Ne");S(re,"f$3");ie(re,"d");var or=Object.defineProperty,Le=S((t,e)=>or(t,"name",{value:e,configurable:!0}),"a$3");const Fe=String.raw,ge=Fe`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,nr=Le(()=>new RegExp(Fe`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${ge}(?:\u200D${ge})*`,"gu"),"a"),st=new Set(["\x1B","›"]),kt="\x07",Pe="[",oe="m",ft="]8;;",sr=39,hr=/[\u200B\uFEFF\u2060-\u2064]/g,ar=new RegExp(`(?:\\${Pe}(?<code>\\d+)m|\\${ft}(?<uri>.*)${kt})`),cr=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]])),X=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,pe=/\u001B\[(\d+(?:;\d+)*)?m[^\u001B]*(?:\u001B\[(?:\d+(?:;\d+)*)?m|$)/g,we=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)(.*?)\u001B\]8;;(?:\u0007|\u001B\\)/g,bt=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,It=nr();Le(t=>t.replace(It,""),"X");var lr=Object.defineProperty,Lt=S((t,e)=>lr(t,"name",{value:e,configurable:!0}),"m$2");const be=new Map,yt=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Mt=Lt(t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other","I"),dr=Lt((t,e)=>{const i=Math.floor(t/65536),r=t%65536;let a=be.get(i);if(a||(a=new Map,be.set(i,a)),a.has(r))return a.get(r);let s;if(Mt(t)==="latin")s=e.width.regular;else if(Mt(t)==="control")s=e.width.control;else if(Mt(t)==="wide")s=e.width.wide;else switch(pt(t)){case"ambiguous":{s=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{s=e.width.fullWidth;break}case"wide":{s=e.width.wide;break}default:s=e.width.regular}return a.set(r,s),s},"_"),ur=Lt(t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,"B"),nt=Lt((t,e={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const i={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?nt(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},r=Math.max(0,i.truncation.limit-i.truncation.ellipsisWidth),{length:a}=t,s=a>1e4;let o=0,h=0,n=a,c=!1;const d=t.includes("\x1B")||t.includes("›");for(;o<a;){if(d&&(t[o]==="\x1B"||t[o]==="›")){if(t.startsWith("\x1B]8;;",o)){const w="\x1B]8;;\x07",f=w.length,v=t.indexOf("\x07",o+5);if(v!==-1){const b=t.indexOf(w,v+1);if(b!==-1){const x=b+f,B=t.slice(v+1,b).replace(X,""),R=nt(B,{ambiguousIsNarrow:i.width.ambiguousIsNarrow,ansiWidth:i.width.ansi,controlWidth:i.width.control,countAnsiEscapeCodes:!1,ellipsis:i.truncation.ellipsis,ellipsisWidth:i.truncation.ellipsisWidth,emojiWidth:i.width.emoji,fullWidth:i.width.fullWidth,halfWidth:i.width.halfWidth,limit:Math.max(0,r-h),regularWidth:i.width.regular,tabWidth:i.width.tab,wideWidth:i.width.wide}),I=R.width;if(R.truncated)c=!0,n=Math.min(n,o);else if(h+I>r&&(n=Math.min(n,o),c=!0,h+I>i.truncation.limit))break;if(h+=I,o=x,c&&h>=i.truncation.limit)break;continue}}}if(X.lastIndex=o,X.test(t)){const w=X.lastIndex-o,f=i.truncation.countAnsiEscapeCodes?w:i.width.ansi;if(h+f>r&&(n=Math.min(n,o),h+f>i.truncation.limit)){c=!0;break}h+=f,o=X.lastIndex;continue}}const p=t.codePointAt(o);if(p===8203||p===65279||p>=8288&&p<=8292){o+=1;continue}if(p===9){if(h+i.width.tab>r&&(n=Math.min(n,o),h+i.width.tab>i.truncation.limit)){c=!0;break}h+=i.width.tab,o+=1;continue}if(yt.lastIndex=o,yt.test(t)){const w=(yt.lastIndex-o)*i.width.regular;if(h+w>r){const f=Math.floor((r-h)/i.width.regular);if(n=Math.min(n,o+f),h+w>i.truncation.limit){c=!0;break}}h+=w,o=yt.lastIndex;continue}if((p<=31||p>=127&&p<=159)&&(bt.lastIndex=o,bt.test(t))){const w=(bt.lastIndex-o)*i.width.control;if(h+w>r&&(n=Math.min(n,o+Math.floor((r-h)/i.width.control)),h+w>i.truncation.limit)){c=!0;break}h+=w,o=bt.lastIndex;continue}if(It.lastIndex=o,It.test(t)){if(h+i.width.emoji>r&&(n=Math.min(n,o),h+i.width.emoji>i.truncation.limit)){c=!0;break}h+=i.width.emoji,o=It.lastIndex;continue}const m=t.codePointAt(o)??0;if(ur(m)){o+=m>65535?2:1;continue}let g;if(s)g=dr(m,i);else switch(Mt(m)){case"control":{g=i.width.control;break}case"latin":{g=i.width.regular;break}case"wide":{g=i.width.wide;break}case"zero":{g=0;break}default:switch(pt(m)){case"ambiguous":{g=i.width.ambiguousIsNarrow?i.width.regular:i.width.wide;break}case"fullwidth":{g=i.width.fullWidth;break}case"wide":{g=i.width.wide;break}default:g=i.width.regular}}if(h+g>r&&(n=Math.min(n,o),h+g>i.truncation.limit)){c=!0;break}h+=g,o+=m>65535?2:1}let l=h,u=!1;return c&&i.truncation.limit>=i.truncation.ellipsisWidth&&(l=i.truncation.limit,u=!0),{ellipsed:u,index:c?n:a,truncated:c,width:l}},"O");var fr=Object.defineProperty,mr=S((t,e)=>fr(t,"name",{value:e,configurable:!0}),"e$1");const $=mr((t,e={})=>nt(t,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"d");var gr=Object.defineProperty,pr=S((t,e)=>gr(t,"name",{value:e,configurable:!0}),"s");let wr=class{static{O(this,"Ke")}static{J(this,"Ye")}static{S(this,"i")}static{pr(this,"s")}capacity;cache;constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;const e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}has(t){return this.cache.has(t)}set(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const i=this.cache.keys().next().value;i!==void 0&&this.cache.delete(i)}this.cache.set(t,e)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}};var br=Object.defineProperty,ht=S((t,e)=>br(t,"name",{value:e,configurable:!0}),"b$3");const ye=new wr(100),yr=new Intl.Segmenter("en",{granularity:"grapheme"}),xr=/^[\u0000-\u007F]*$/,vr=new Set(["0","22","23","24","27","28","29","39","49"]),Br=new Set(["1","3","4","7","8","9"]),xe=new Map([["22","1"],["23","3"],["24","4"],["27","7"],["28","8"],["29","9"]]),xt=ht(t=>t>="30"&&t<="37"||t>="90"&&t<="97"||t.startsWith("38;"),"b"),vt=ht(t=>t>="40"&&t<="47"||t>="100"&&t<="107"||t.startsWith("48;"),"S"),Rr=[{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"}],ve=ht((t,e)=>{let i=-1;for(const r of e){const a=t.indexOf(r);a!==-1&&(i===-1||a<i)&&(i=a)}return i},"R"),Wr=ht((t,e)=>{if(!t.includes("\x1B"))return[{after:"",before:"",content:t,visibleLength:$(t,e.width)}];const i=ye.get(t);if(i)return i;const r=[],a=[];let s=0,o;for(X.lastIndex=0;(o=X.exec(t))!==null;){const d=o[0];r.push(t.slice(s,o.index)),a.push(d),s=o.index+d.length}s<t.length&&r.push(t.slice(s));const h=[];for(const d of a){if(d==="\x1B[0m"||d==="\x1B]8;;\x07"){h.push(d);continue}if(d.startsWith("\x1B[")&&d.endsWith("m")){const l=d.slice(2,-1);if(vr.has(l)){h.push(d);continue}}}const n=new Set,c=[];for(const[d,l]of r.entries()){if(d>0&&a[d-1]){const m=a[d-1];if(m==="\x1B[0m")n.clear();else if(m==="\x1B]8;;\x07"){for(const g of n)if(g.startsWith("\x1B]8;;")&&!g.endsWith("\x1B]8;;\x07")){n.delete(g);break}}else if(m.startsWith("\x1B[")&&m.endsWith("m")){const g=m.slice(2,-1);if(g==="39"){for(const w of n)if(w.startsWith("\x1B[")&&w.endsWith("m")){const f=w.slice(2,-1);if(xt(f)){n.delete(w);break}}}else if(g==="49"){for(const w of n)if(w.startsWith("\x1B[")&&w.endsWith("m")){const f=w.slice(2,-1);if(vt(f)){n.delete(w);break}}}else if(xe.has(g)){const w=xe.get(g);for(const f of n)if(f===`\x1B[${w}m`){n.delete(f);break}}else{if(xt(g)){for(const w of n)if(w.startsWith("\x1B[")&&w.endsWith("m")){const f=w.slice(2,-1);if(xt(f)){n.delete(w);break}}}else if(vt(g)){for(const w of n)if(w.startsWith("\x1B[")&&w.endsWith("m")){const f=w.slice(2,-1);if(vt(f)){n.delete(w);break}}}else if(Br.has(g)){const w=`\x1B[${g}m`;n.has(w)&&n.delete(w)}n.add(m)}}else if(m.startsWith("\x1B]8;;")&&!m.endsWith("\x1B]8;;\x07")){for(const g of n)if(g.startsWith("\x1B]8;;")&&!g.endsWith("\x1B]8;;\x07")){n.delete(g);break}n.add(m)}}if(l==="")continue;let u="";if(n.size>0)if(h.includes("\x1B[0m"))u="\x1B[0m";else{const m=[];let g=!1;for(const b of n)if(b.startsWith("\x1B]8;;")&&!b.endsWith("\x1B]8;;\x07")){g=!0;break}g&&h.includes("\x1B]8;;\x07")&&m.push("\x1B]8;;\x07");let w=!1,f=!1;for(const b of n)if(b.startsWith("\x1B[")&&b.endsWith("m")){const x=b.slice(2,-1);xt(x)?w=!0:vt(x)&&(f=!0)}if(w&&f){const b=ve(t,["\x1B[3","\x1B[9","\x1B[38;"]),x=ve(t,["\x1B[4","\x1B[10","\x1B[48;"]);b>=0&&x>=0?b>x?m.push("\x1B[39m","\x1B[49m"):m.push("\x1B[49m","\x1B[39m"):m.push("\x1B[39m","\x1B[49m")}else w&&m.push("\x1B[39m"),f&&m.push("\x1B[49m");w&&f&&t.includes("\x1B[39m")&&t.includes("\x1B[49m")&&(t.indexOf("\x1B[39m")<t.indexOf("\x1B[49m")?(m.length-=2,m.push("\x1B[39m","\x1B[49m")):t.indexOf("\x1B[49m")<t.indexOf("\x1B[39m")&&(m.length-=2,m.push("\x1B[49m","\x1B[39m")));const v=Rr.filter(b=>n.has(b.open)).map(b=>({position:t.indexOf(b.open),style:b})).filter(b=>b.position>=0).toSorted((b,x)=>x.position-b.position);for(const b of v){const x=b;h.includes(x.style.close)&&m.push(x.style.close)}u=m.join("")}const p=[...n].join("");c.push({after:u,before:p,content:l,visibleLength:$(l,{fullWidth:1,wideWidth:1})})}return ye.set(t,c),c},"F"),Sr=ht((t,e,i,r)=>{const a=[...r.segmenter.segment(t)],s=[];let o=0,h=!1;for(const n of a){const c=$(n.segment,r.width),d=o,l=o+c;if(!h)if(d<e){o=l;continue}else h=!0;if(d>=i||l>i)break;s.push(n.segment),o=l}return s.join("")},"P"),D=ht((t,e=0,i=Number.MAX_SAFE_INTEGER,r={})=>{const a={segmenter:yr,...r};if(e>=i||t==="")return"";const s=$(t,a.width);if(e===0&&i>=s)return t;if(e<0||i<0)throw new RangeError("Negative indices aren't supported");if(!t.includes("\x1B"))return xr.test(t)?t.slice(e,i):Sr(t,e,i,a);if(pe.lastIndex=0,we.lastIndex=0,!pe.test(t)&&!we.test(t))return t;const o=Wr(t,a);if(o.length===0)return"";let h=0;const n=[];for(const[l,u]of o.entries()){const p=h,m=h+u.visibleLength;if(m>e&&p<i){const g=Math.max(0,e-p),w=Math.min(u.visibleLength,i-p);n.push({end:w,index:l,segment:u,start:g})}h=m}if(n.length===0)return"";const c=[],d=n[0].segment;c.push(d.before);for(let l=0;l<n.length;l++){const{end:u,segment:p,start:m}=n[l];if(m===0&&u===p.visibleLength)c.push(p.content);else{const g=[...a.segmenter.segment(p.content)];c.push(g.slice(m,u).map(w=>w.segment).join(""))}if(l<n.length-1){const g=n[l+1].segment,w=p.after,f=g.before;w!==f&&(w||f)&&c.push(w,f)}}return c.push(n.at(-1).segment.after),c.join("")},"T");var Ir=Object.defineProperty,Ft=S((t,e)=>Ir(t,"name",{value:e,configurable:!0}),"m$1");const Be="…",Mr=3,Bt=Ft((t,e,i=!1)=>{if(t.charAt(e)===" ")return e;const r=i?1:-1,a=Math.min(Mr,i?t.length-e:e);for(let s=1;s<=a;s++){const o=e+s*r;if(t.charAt(o)===" ")return o}return e},"u"),Rt=Ft((t,e,i)=>nt(t,{...i,ellipsis:"",ellipsisWidth:0,limit:e}).index,"f"),Wt=Ft((t,e,i)=>$(t.slice(0,e),i),"m"),Re=Ft((t,e,i={})=>{if(typeof t!="string")throw new TypeError(`Expected \`input\` to be a string, got ${typeof t}`);if(typeof e!="number")throw new TypeError(`Expected \`limit\` to be a number, got ${typeof e}`);if(t===""||e<=0)return"";const r=t.normalize("NFC"),{ellipsis:a=Be,position:s="end",preferTruncationOnSpace:o=!1}=i;let h=i.ellipsisWidth??(a===Be?1:void 0);h??=nt(a,{...i.width,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width;const{width:n}=nt(r,{...i.width,ellipsis:a,ellipsisWidth:h});if(n<=e)return r;switch(s){case"end":{if(o){const c=e-h,d=Rt(r,c,i.width),l=Bt(r,d),u=Wt(r,l,i.width);return D(r,0,u,{width:i.width})+a}return D(r,0,e-h,{width:i.width})+a}case"middle":{const c=Math.floor(e/2),d=Math.max(0,e-h),l=Math.min(c,d),u=Math.max(0,d-l);if(o){const p=Rt(r,l,i.width),m=Bt(r,p),g=Wt(r,m,i.width),w=n-u,f=Rt(r,w,i.width),v=Bt(r,f,!0),b=Wt(r,v,i.width);return D(r,0,g,{width:i.width})+a+D(r,b,n,{width:i.width}).trim()}return D(r,0,l,{width:i.width})+a+D(r,n-u,n,{width:i.width})}case"start":{if(o){const c=n-e+h,d=Rt(r,c,i.width),l=Bt(r,d,!0),u=Wt(r,l,i.width);return a+D(r,u,n,{width:i.width}).trim()}return a+D(r,n-e+h,n,{width:i.width})}default:throw new Error(`Invalid position: expected 'start', 'middle' or 'end', got '${s}'`)}},"v");var Ar=Object.defineProperty,T=S((t,e)=>Ar(t,"name",{value:e,configurable:!0}),"p$2");const jr=/\x1B\[(\d+)m/;class _e{static{O(this,"ie")}static{J(this,"Qt")}static{S(this,"w")}static{T(this,"I")}activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(e){const i=jr.exec(e);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=e;else if(r>=40&&r<=47||r>=100&&r<=107)this.activeBackground=e;else if([1,2,3,4,7,8,9].includes(r))this.activeFormatting.push(e);else if([22,23,24,27,28,29].includes(r)){const a={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[r];a&&(this.activeFormatting=this.activeFormatting.filter(s=>!s.includes(a)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const e=[];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 a=i[r];a&&e.push(a)})}return this.activeForeground&&e.push("\x1B[39m"),this.activeBackground&&e.push("\x1B[49m"),e.join("")}}const Cr=T((t,e)=>{if(!st.has(t[e]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const i=!0,r=t.slice(e+1,e+1+ft.length).join("")===ft;return{isInsideEscape:i,isInsideLinkEscape:r}},"O"),$r=T((t,e={})=>{const i=new _e;let r="",a=!1,s="",o="",h=!1;const n=[...t];for(let c=0;c<n.length;c++){const d=n[c];if(d&&st.has(d)){if(r){const g=e.getWidth?.(r)??0,w={isEscapeSequence:!1,isGrapheme:!0,text:r,width:g};if(h&&(w.isHyperlink=!0,w.hyperlinkUrl=o),e.onSegment?.(w,i)===!1)return;r=""}a=!0,s=d;const p=Cr(n,c),{isInsideLinkEscape:m}=p;if(m){let g=c+1;for(o="";g<n.length;){const f=n[g];if(f===kt)break;o+=f,g+=1}o=o.slice(4);const w={hyperlinkUrl:o,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(e.onSegment?.(w,i)===!1)return;c=g,h=!0,a=!1,s="";continue}if(c+1<n.length&&n[c+1]==="\\"&&h){const g={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(e.onSegment?.(g,i)===!1)return;h=!1,o="",c+=1,a=!1,s="";continue}}if(a){if(s!==d&&(s+=d),d===oe){a=!1,i.processEscape(s);const p={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};if(e.onSegment?.(p,i)===!1)return;s=""}continue}r+=d;const l=e.getWidth?.(r)??0,u={isEscapeSequence:!1,isGrapheme:!0,text:r,width:l};if(h&&(u.isHyperlink=!0,u.hyperlinkUrl=o),e.onSegment?.(u,i)===!1)return;r=""}if(r){const c=e.getWidth?.(r)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:r,width:c};h&&(d.isHyperlink=!0,d.hyperlinkUrl=o),e.onSegment?.(d,i)}if(s){const c={isEscapeSequence:!0,isGrapheme:!1,text:s,width:0};e.onSegment?.(c,i)}},"P"),We=T(t=>`${st.values().next().value}${Pe}${String(t)}${oe}`,"k"),Se=T(t=>`${st.values().next().value}${ft}${t}${kt}`,"F"),Er=T(t=>{if(t.length===0)return"";if(t.length===1)return t[0];let e="",i,r;const a=t.join(`
3
+ `),s=[...a];let o=0;for(const[h,n]of s.entries()){if(e+=n,st.has(n)){const d=ar.exec(a.slice(o))?.groups??{};if(d.code!==void 0){const l=Number.parseFloat(d.code);i=l===sr?void 0:l}else d.uri!==void 0&&(r=d.uri.length===0?void 0:d.uri)}const c=cr.get(Number(i));s[h+1]===`
4
+ `?(r&&(e+=Se("")),i&&c&&(e+=We(c))):n===`
5
+ `&&(i&&c&&(e+=We(i)),r&&(e+=Se(r))),o+=n.length}return e},"q"),Je=/(?=\s)|(?<=\s)/,He=/^\s+$/,Gt=T(t=>{if(!t.includes("\x1B"))return t;let e=t;return t.includes("\x1B[30m")&&(e+="\x1B[39m"),t.includes("\x1B[42m")&&(e+="\x1B[49m"),e},"B"),tt=T(t=>{const e=t.split(" ");let i=e.length;for(;i>0&&$(e[i-1])===0;)i--;return i===e.length?t:e.slice(0,i).join(" ")+e.slice(i).join("")},"m"),Ge=T((t,e,i)=>{if(t.length===0)return[""];if(e<=0)return[t];const r=[],a=new _e;let s="",o=0,h=!1,n=!1,c="",d=0;for(;d<t.length;){const l=t[d];if(st.has(l)){h=!0,c=l,s+=l,n=t.startsWith(ft,d+1),d+=1;continue}if(h){c+=l,s+=l,n?l===kt&&(h=n=!1):l===oe&&(h=!1,a.processEscape(c)),d+=1;continue}const u=$(l),p=l===" ";if(u===0){s+=l,d+=1;continue}if(o+u>e&&(s&&r.push(s+a.getEndEscapesForAllActiveAttributes()),s=a.getStartEscapesForAllActiveAttributes(),o=$(s),p&&i)){for(;d<t.length&&t[d]===" ";)d+=1;continue}if(s+=l,o+=u,o===e&&d<t.length-1&&(r.push(s+a.getEndEscapesForAllActiveAttributes()),s=a.getStartEscapesForAllActiveAttributes(),o=$(s),d+1<t.length&&t[d+1]===" "&&i)){for(d+=1;d<t.length&&t[d]===" ";)d+=1;continue}d+=1}return s&&r.push(s+a.getEndEscapesForAllActiveAttributes()),i?r.map(l=>tt(l)):r},"b"),Or=T((t,e,i)=>{if(t.length===0)return[];const r=i?t.trim():t;if(r.length===0)return[];const a=[];let s="",o=0;return $r(r,{getWidth:$,onSegment:T((h,n)=>{const c=h.text??"";if(h.isEscapeSequence)s+=c;else{const d=c===" ";if(h.width===0)return s+=c,!0;if(o+h.width>e&&(s&&a.push(s),s=n.getStartEscapesForAllActiveAttributes(),o=0,d))return i||a.push(n.getStartEscapesForAllActiveAttributes()+c),!0;s+=c,o+=h.width}return!0},"onSegment")}),s&&a.push(s),i?a.map(h=>tt(h)):a},"G"),Nr=T((t,e,i)=>{if(t.length===0)return[];const r=i?t.trim():t;if(r.length===0)return[];const a=r.split(Je),s=[];let o="",h=0,n=0;for(;n<a.length;){const c=a[n],d=He.test(c),l=$(c);if(c.length===0){n+=1;continue}if(i&&d&&h===0){n+=1;continue}if(h+l>e&&h>0){i?s.push(tt(o)):s.push(o),o="",h=0;continue}o+=c,h+=l,n+=1}return o&&(i?s.push(tt(o)):s.push(o)),s},"j"),Tr=T((t,e,i)=>{if(t.length===0)return[];const r=i?t.trim():t;if(r.length===0)return[];const a=r.split(Je),s=[];let o="",h=0,n=0;for(;n<a.length;){const c=a[n],d=He.test(c),l=$(c);if(c.length===0){n+=1;continue}if(i&&d&&h===0){n+=1;continue}if(l>e){o&&s.push(Gt(i?tt(o):o));const u=Ge(c,e,i);if(u.length>0){for(let p=0;p<u.length-1;p+=1)s.push(u[p]);o=u.at(-1),h=$(o)}else o="",h=0;n+=1;continue}if(h+l>e&&h>0&&(s.push(Gt(i?tt(o):o)),o="",h=0,i&&d)){n+=1;continue}o+=c,h+=l,n+=1}return o&&s.push(Gt(i?tt(o):o)),s},"K"),St={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},kr=T((t,e={})=>{const{removeZeroWidthCharacters:i=!0,trim:r=!0,width:a=80,wrapMode:s=St.PRESERVE_WORDS}=e;if(r&&t.trim()==="")return"";let o=t.normalize("NFC").replaceAll(`\r
6
+ `,`
7
+ `);return i&&(o=o.replaceAll(hr,"")),o.split(`
8
+ `).map(h=>{if(r&&h.trim()==="")return"";let n;switch(s){case St.BREAK_AT_CHARACTERS:{n=Or(h,a,r);break}case St.BREAK_WORDS:{n=Tr(h,a,r);break}case St.STRICT_WIDTH:{n=Ge(h,a,r);break}default:n=Nr(h,a,r)}return Er(n)}).join(`
9
+ `)},"V");var Lr=Object.defineProperty,Z=S((t,e)=>Lr(t,"name",{value:e,configurable:!0}),"n$3");const Ve=80,ze=24,Zt=Z((t,e,{shell:i,env:r}={})=>Fi(t,e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:i,env:r}).trim(),"exec"),At=Z((t,e)=>({columns:Number.parseInt(t,10),rows:Number.parseInt(e,10)}),"create"),De=Z((t,e)=>{const{columns:i,rows:r}=At(t,e);if(!(Number.isNaN(i)||Number.isNaN(r))&&!(i===Ve&&r===ze))return{columns:i,rows:r}},"createIfNotDefault"),Fr=Z(()=>{if(Q.platform!=="linux")return!0;try{const t=dt.readFileSync("/proc/self/stat","utf8"),e=t.lastIndexOf(") ");if(e===-1)return!1;const i=t.slice(e+2).trim().split(/\s+/),r=Number.parseInt(i[2],10),a=Number.parseInt(i[5],10);return Number.isNaN(r)||Number.isNaN(a)||a<=0?!1:r===a}catch{return!1}},"isForegroundProcess");function Pt(){const{env:t,stdout:e,stderr:i}=Q;if(e?.columns&&e?.rows)return At(e.columns,e.rows);if(i?.columns&&i?.rows)return At(i.columns,i.rows);if(t.COLUMNS&&t.LINES)return At(t.COLUMNS,t.LINES);const r={columns:Ve,rows:ze};return Q.platform==="win32"?Vt()??r:Q.platform==="darwin"?Ie()??Vt()??r:Ie()??Vt()??Pr()??r}O(Pt,"At");J(Pt,"se");S(Pt,"O");Z(Pt,"terminalSize");const Ie=Z(()=>{try{const t=Q.platform==="darwin"?dt.constants.O_EVTONLY|dt.constants.O_NONBLOCK:dt.constants.O_NONBLOCK,{columns:e,rows:i}=Pi.WriteStream(dt.openSync("/dev/tty",t));return{columns:e,rows:i}}catch{}},"devTty"),Vt=Z(()=>{try{const t=Zt("tput",["cols"],{env:{TERM:"dumb",...Q.env}}),e=Zt("tput",["lines"],{env:{TERM:"dumb",...Q.env}});if(t&&e)return De(t,e)}catch{}},"tput"),Pr=Z(()=>{try{if(!Fr())return;const t=Zt("resize",["-u"]).match(/\d+/g);if(t.length===2)return De(t[0],t[1])}catch{}},"resize");var _r=Object.defineProperty,Ye=S((t,e)=>_r(t,"name",{value:e,configurable:!0}),"e");const it=Ye((t,e)=>{switch(e){case"bottom":return{body:t.bottomBody,join:t.bottomJoin,left:t.bottomLeft,right:t.bottomRight};case"middle":return{body:t.joinBody,join:t.joinJoin,left:t.joinLeft,right:t.joinRight};case"top":return{body:t.topBody,join:t.topJoin,left:t.topLeft,right:t.topRight};default:throw new Error(`Invalid borderType: ${String(e)}`)}},"getHorizontalBorderChars"),Jr=Ye(t=>({join:t.bodyJoin,left:t.bodyLeft,right:t.bodyRight}),"getVerticalBorderChars");var Hr=Object.defineProperty,Gr=S((t,e)=>Hr(t,"name",{value:e,configurable:!0}),"n$1");const Et=Gr((t,e,i)=>{let r=0;for(let a=0;a<i;a+=1)r+=t[e+a]??0;return i>1&&(r+=i-1),r},"calculateCellTotalWidth");var Vr=Object.defineProperty,zr=S((t,e)=>Vr(t,"name",{value:e,configurable:!0}),"a");const Xt=zr((t,e,i,r)=>{let a=e;for(;a>0&&t[a-1]?.[i]===r;)a-=1;let s=e;for(;s<t.length-1&&t[s+1]?.[i]===r;)s+=1;let o;const h=s-a+1;if(h===1)o=!0;else switch(r.vAlign){case"bottom":{o=e===s;break}case"middle":{const n=a+Math.floor(h/2);o=e===n;break}case"top":{o=e===a;break}default:o=e===a}return{firstRow:a,lastRow:s,showContent:o}},"determineCellVerticalPosition");var Dr=Object.defineProperty,Yr=S((t,e)=>Dr(t,"name",{value:e,configurable:!0}),"F");const qr=Yr((t,e,i,r,a)=>{if(t.length===0)return[];let s=t.length-1;for(let n=0;n<t.length;n+=1){const c=t[n];if(c){for(const[d,l]of c.entries())if(l&&a(t,n,d,l)===n){const u=Xt(t,n,d,l);s=Math.max(s,u.lastRow)}}}const o=Array.from({length:s+1}).fill(1);for(let n=0;n<t.length;n+=1){const c=t[n];if(c)for(let d=0;d<i.columns;d+=1){const l=c[d];if(l&&a(t,n,d,l)===n&&(l.rowSpan??1)===1){const u=l.colSpan??1,p=Et(e,d,u),m=r(l,p).length;o[n]=Math.max(o[n]??1,m)}}}const h=Array.from({length:o.length}).fill(!1);if(i.fixedRowHeights)for(let n=0;n<o.length;n+=1){let c;i.fixedRowHeights[n]!==void 0?c=i.fixedRowHeights[n]:i.fixedRowHeights.length===1&&i.fixedRowHeights[0]!==void 0&&(c=i.fixedRowHeights[0]),c!==void 0&&(o[n]=Math.max(1,c),h[n]=!0)}for(let n=0;n<t.length;n+=1){const c=t[n];if(c)for(let d=0;d<i.columns;d+=1){const l=c[d];if(l&&a(t,n,d,l)===n&&(l.rowSpan??1)>1){const u=l.colSpan??1,p=Et(e,d,u),m=r(l,p).length-1,g=Xt(t,n,d,l),{firstRow:w,lastRow:f}=g;let v=0,b=0;for(let B=w;B<=f&&B<o.length;B+=1)v+=o[B]??1,h[B]||(b+=1);const x=m-v;if(x>0)if(b>0){const B=Math.ceil(x/b);let R=0;for(let I=w;I<=f&&I<o.length;I+=1)if(!h[I]){const M=Math.min(B,x-R);if(o[I]=(o[I]??1)+M,R+=M,R>=x)break}}else console.warn(`[calculateRowHeights] Content of spanning cell exceeds fixed height allocated. Cell: ${JSON.stringify(l.content)}, Required: ${String(m)}, Allocated: ${String(v)} (fixed).`)}}}return o},"calculateRowHeights");var Ur=Object.defineProperty,Kr=S((t,e)=>Ur(t,"name",{value:e,configurable:!0}),"i");const rt=Kr((t,e,i,r)=>{let a=e;for(;a>0&&t[a-1]?.[i]===r;)a-=1;return a},"findFirstOccurrenceRow");var Zr=Object.defineProperty,Xr=S((t,e)=>Zr(t,"name",{value:e,configurable:!0}),"n");const Qt="__EMPTY__",Me=Xr(t=>{if(typeof t=="string")return{content:t};if(typeof t=="number"||typeof t=="bigint"||typeof t=="boolean")return{content:String(t)};if(t==null)return{content:Qt};if(typeof t=="object"&&"content"in t){let{content:e}=t;if(typeof e=="number"||typeof e=="bigint"||typeof e=="boolean")e=String(e);else if(e==null)e=Qt;else if(typeof e!="string")throw new TypeError(`Invalid item type in grid cell: expected string, number, null, undefined, or GridItem object, but received ${JSON.stringify(t)} (type: ${typeof t})`);return{...t,content:e}}throw new TypeError(`Invalid item type in grid cell: expected string, number, null, undefined, or GridItem object, but received ${JSON.stringify(t)} (type: ${typeof t})`)},"normalizeGridCell");var Qr=Object.defineProperty,to=S((t,e)=>Qr(t,"name",{value:e,configurable:!0}),"p");const eo=to((t,e,i,r,a)=>{const s=$(t),o=" ".repeat(Math.max(0,r)),h=" ".repeat(Math.max(0,a));if(s===0)return o+" ".repeat(Math.max(0,e))+h;const n=Math.max(0,e-s);switch(i){case"center":{const c=Math.floor(n/2),d=n-c;return o+" ".repeat(c)+t+" ".repeat(d)+h}case"right":return o+" ".repeat(n)+t+h;default:return o+t+" ".repeat(n)+h}},"padAndAlignContent");var io=Object.defineProperty,ne=S((t,e)=>io(t,"name",{value:e,configurable:!0}),"H");const lt=/\r?\n/,Ae=/\s+/,W=ne((t,e)=>!t||!e?t:typeof e=="function"?e(t):e.open+t+e.close,"applyColor");class _t{static{O(this,"bt")}static{J(this,"Mt")}static{S(this,"Grid")}static{ne(this,"Grid")}#t;#o=[];#e;#n=new WeakMap;#i=new WeakMap;static createGridLayout(){return[]}constructor(e){const i={autoColumns:1,autoFlow:"row",autoRows:1,balancedWidths:!1,gap:0,paddingLeft:1,paddingRight:1,rows:0,showBorders:e.border!==void 0,truncate:!1,truncateOverflow:!0,wordWrap:!1};let r;Array.isArray(e.fixedRowHeights)?r=e.fixedRowHeights:typeof e.fixedRowHeights=="number"&&(r=[e.fixedRowHeights]),this.#t={...i,...e,columns:e.columns,fixedRowHeights:r,showBorders:e.border!==void 0||(e.showBorders??!1)};let{terminalWidth:a}=this.#t;if(a===void 0){const{columns:s}=Pt();a=s}this.#e=a,this.#t.maxWidth&&(this.#t.maxWidth=Math.min(this.#t.maxWidth,this.#e))}addItem(e){return this.#o.push(Me(e)),this}addItems(e){return this.#o.push(...e.map(i=>Me(i))),this}setColumns(e){return this.#t.columns=e,this}setRows(e){return this.#t.rows=e,this}setBorder(e){return this.#t.border=e,this}setShowBorders(e){return this.#t.showBorders=e,this}setMaxWidth(e){return this.#t.maxWidth=e,this}toString(){const e=_t.createGridLayout();if(this.#n=new WeakMap,this.#i=new WeakMap,this.placeItems(e),e.length===0||e[0]?.length===0)return"";let i=this.calculateColumnWidths(e);const r=this.calculateTotalGridWidth(i),a=typeof this.#t.maxWidth=="number"&&this.#t.maxWidth>0?Math.min(this.#t.maxWidth,this.#e):this.#e;return r>a&&(i=this.adjustColumnWidthsForTerminal(i,r)),this.renderGrid(e,i)}placeItems(e){let i=0,r=0;const a=this.#t.rows>0?this.#t.rows:Number.POSITIVE_INFINITY;for(let s=0;s<this.#o.length;s+=1){const o=this.#o[s];if(o.content===Qt&&!(o.rowSpan&&o.rowSpan>1)&&!(o.colSpan&&o.colSpan>1)){if(this.#t.autoFlow==="row")r+=1,r>=this.#t.columns&&(r=0,i+=1);else{i+=1;const m=e.length>0?e.length:a;i>=m&&m!==Number.POSITIVE_INFINITY?(i=0,r+=1):e.length===0&&m===Number.POSITIVE_INFINITY&&(r+=1)}continue}const h=o.colSpan??1,n=o.rowSpan??1;let c=!1,d=i,l=r,u=0;const p=(e.length+n+5)*this.#t.columns;for(;!c&&d<a&&u<p;){for(u+=1;d+n>e.length;)e.push(Array.from({length:this.#t.columns}).fill(void 0));if(this.canPlaceItem(e,d,l,h,n))if(this.placeItem(e,d,l,o),c=!0,this.#t.autoFlow==="row")r=l+h,i=d,r>=this.#t.columns&&(r=0,i+=1);else{i=d+n,r=l;const m=e.length>0?e.length:a;i>=m&&(i=0,r+=1)}else if(this.#t.autoFlow==="row")l+=1,l>=this.#t.columns&&(l=0,d+=1);else{for(d+=1;d+n>e.length;)e.push(Array.from({length:this.#t.columns}).fill(void 0));const m=e.length>0?e.length:a;if(d>=m&&(d=0,l+=1,l>=this.#t.columns))break}}if(!c)if(console.warn(`@visulima/tabular: Could not find position for item: ${JSON.stringify(o)} after ${String(u)} attempts. Grid might be too small or layout impossible.`),this.#t.autoFlow==="row")r+=1,r>=this.#t.columns&&(r=0,i+=1);else{i+=1;const m=e.length>0?e.length:a;i>=m&&(i=0,r+=1)}if(u>=p)break}if(this.#t.rows===0)for(;e.length>0&&e.at(-1)?.every(s=>s===void 0);)e.pop()}canPlaceItem(e,i,r,a,s,o=!1){if(r+a>this.#t.columns)return!1;for(let h=i;h<i+s;h+=1)if(h<e.length){if(!e[h])return console.warn(`Grid layout unexpectedly missing row ${String(h)} during canPlaceItem check.`),!1;for(let n=r;n<r+a;n+=1)if(e[h]?.[n]!==void 0)return!1}else if(!o)return!1;return!0}computeWrappedContentWidth(e,i,r,a){let s=e;if(a){if(s>20){let o=0;for(const h of i){const n=h.split(Ae);for(const c of n)o=Math.max(o,Math.min($(c),r))}s=Math.min(s,Math.max(o+4,12))}}else{let o=0;for(const h of i){const n=h.split(Ae);for(const c of n)o=Math.max(o,Math.min($(c),r))}s=Math.min(s,Math.max(o+12,20))}return s}placeItem(e,i,r,a){const s=a.rowSpan??1,o=a.colSpan??1;for(let h=i;h<i+s;h+=1){for(;h>=e.length;)e.push(Array.from({length:this.#t.columns}).fill(void 0));for(let n=r;n<r+o;n+=1)n<this.#t.columns&&(e[h]||(console.error(`Logic error: Row ${String(h)} not found in placeItem despite check.`),e[h]=Array.from({length:this.#t.columns}).fill(void 0)),e[h][n]=a)}}calculateTotalGridWidth(e){let i=0;const r=this.#t.showBorders?this.#t.border:void 0;r&&(i+=r.bodyLeft.width,i+=r.bodyRight.width);const a=e.length,s=this.#t.showBorders?r?.bodyJoin.width??0:0,o=this.#t.gap;for(let h=0;h<a;h+=1)i+=e[h]??0,h<a-1&&(i+=o,i+=s);return i}adjustColumnWidthsForTerminal(e,i){const r=typeof this.#t.maxWidth=="number"&&this.#t.maxWidth>0?Math.min(this.#t.maxWidth??0,this.#e):this.#e;if(i<=r)return e;let a=0;const s=e.length,o=this.#t.showBorders?this.#t.border:void 0;if(o&&(a+=o.bodyLeft.width,a+=o.bodyRight.width),s>1){a+=(s-1)*this.#t.gap;const u=o?.bodyJoin.width??0;a+=(s-1)*u}if(a>=r)return Array.from({length:s}).fill(1);const h=r-a,n=e.reduce((u,p)=>u+p,0);if(n===0){const u=Math.floor(h/s);return Array.from({length:s}).fill(u)}const c=e.map(u=>{const p=u/n;return Math.max(1,Math.floor(h*p))});let d=c.reduce((u,p)=>u+p,0)-h;for(;d>0;){let u=-1;for(let p=0;p<c.length;p+=1)(c[p]??0)>1&&(u===-1||(c[p]??0)>(c[u]??0))&&(u=p);if(u===-1)break;c[u]-=1,d-=1}let l=h-c.reduce((u,p)=>u+p,0);if(l>0){const u=c.map((p,m)=>{const g=n>0?(e[m]??0)/n:1/s;return{index:m,remainder:h*g%1}}).toSorted((p,m)=>m.remainder-p.remainder);for(const p of u){if(l<=0)break;const{index:m}=p;c[m]!==void 0&&(c[m]+=1,l-=1)}}return c}calculateBalancedColumnWidths(e){const i=this.calculateMinimumColumnWidthsWithGrowableInfo(e),r=i.widths,{growableColumns:a}=i,s=typeof this.#t.maxWidth=="number"&&this.#t.maxWidth>0?Math.min(this.#t.maxWidth,this.#e):this.#e,o=this.#t.showBorders?this.#t.border:void 0;let h=0;if(o&&(h+=o.bodyLeft.width,h+=o.bodyRight.width),this.#t.columns>1){h+=(this.#t.columns-1)*this.#t.gap;const d=o?.bodyJoin.width??0;h+=(this.#t.columns-1)*d}const n=Math.max(0,s-h);if(r.reduce((d,l)=>d+l,0)>0){const d=Math.floor(n/this.#t.columns),l=Array.from({length:this.#t.columns}).fill(d),u=d*this.#t.columns;let p=n-u;for(let f=0;f<l.length&&p>0;f+=1)l[f]=(l[f]??0)+1,p-=1;const m=[];let g=0;for(let f=0;f<this.#t.columns;f+=1){const v=l[f]??0,b=r[f]??0,x=Math.max(v,b);m.push(x),g+=x}if(g>n){const f=n/g,v=m.map(B=>Math.max(3,Math.floor(B*f))),b=v.reduce((B,R)=>B+R,0);let x=n-b;for(let B=0;B<v.length&&x>0;B+=1)v[B]=(v[B]??0)+1,x-=1;return v}let w=n-g;if(w>0){const f=a.length>0?a:m.map((v,b)=>b);for(;w>0&&f.length>0;)for(const v of f){if(w<=0)break;m[v]=(m[v]??0)+1,w-=1}}return m}const c=Math.floor(n/this.#t.columns);return Array.from({length:this.#t.columns}).fill(c)}calculateMinimumColumnWidthsWithGrowableInfo(e){const i=Array.from({length:this.#t.columns}).fill(0),r=[],a=this.#t.paddingLeft+this.#t.paddingRight,s=this.#t.gap+(this.#t.showBorders?this.#t.border?.bodyJoin.width??0:0);for(let o=0;o<this.#t.columns;o+=1)for(let h=0;h<e.length;h+=1){const n=e[h]?.[o];if(!n||rt(e,h,o,n)!==h||o>0&&e[h]?.[o-1]===n)continue;const c=n.colSpan??1,d=n.maxWidth??Number.POSITIVE_INFINITY,l=String(n.content??"").split(lt),u=this.#t.wordWrap&&n.wordWrap!==!1;let p=0;for(const m of l)p=Math.max(p,Math.min($(m),d));p=this.computeWrappedContentWidth(p,l,d,u),c===1&&(i[o]=Math.max(i[o]??0,p+a),u&&!r.includes(o)&&r.push(o))}for(let o=0;o<e.length;o+=1)for(let h=0;h<this.#t.columns;h+=1){const n=e[o]?.[h];if(!n||rt(e,o,h,n)!==o||h>0&&e[o]?.[h-1]===n)continue;const c=n.colSpan??1;if(c>1){const d=n.maxWidth??Number.POSITIVE_INFINITY,l=String(n.content??"").split(lt),u=this.#t.wordWrap&&n.wordWrap!==!1;let p=0;for(const f of l)p=Math.max(p,Math.min($(f),d));p=this.computeWrappedContentWidth(p,l,d,u);const m=(c-1)*s,g=p+a+m;let w=0;for(let f=h;f<h+c;f+=1)w+=i[f]??0;if(g>w){const f=g-w,v=Math.ceil(f/c);for(let b=0;b<c&&h+b<this.#t.columns;b+=1)i[h+b]=Math.max(i[h+b]??0,v)}}}return{growableColumns:r,widths:i}}calculateColumnWidths(e){if(this.#t.fixedColumnWidths&&this.#t.fixedColumnWidths.length===this.#t.columns){const s=this.#t.fixedColumnWidths;if(!s.some(o=>o===void 0||!Number.isFinite(o)))return[...s];if(this.#t.balancedWidths){const o=Array.from({length:s.length}).fill(0),h=typeof this.#t.maxWidth=="number"&&this.#t.maxWidth>0?Math.min(this.#t.maxWidth,this.#e):this.#e,n=this.calculateTotalGridWidth(Array.from({length:o.length}).fill(0)),c=Math.max(0,h-n);let d=0;const l=[];for(const[m,g]of s.entries())typeof g=="number"&&Number.isFinite(g)?(o[m]=g,d+=g):l.push(m);let u=Math.max(0,c-d);const p=l.length>0?Math.floor(u/l.length):0;for(const m of l)o[m]=p;u-=p*l.length;for(const m of l){if(u<=0)break;o[m]+=1,u-=1}return o}}if(this.#t.balancedWidths)return this.calculateBalancedColumnWidths(e);const i=Array.from({length:this.#t.columns}).fill(0),r=this.#t.paddingLeft+this.#t.paddingRight,a=this.#t.gap+(this.#t.showBorders?this.#t.border?.bodyJoin.width??0:0);for(let s=0;s<this.#t.columns;s+=1)for(let o=0;o<e.length;o+=1){const h=e[o]?.[s];if(!h||rt(e,o,s,h)!==o||s>0&&e[o]?.[s-1]===h)continue;const n=h.colSpan??1,c=h.maxWidth??Number.POSITIVE_INFINITY,d=String(h.content??"").split(lt);let l=0;for(const u of d)l=Math.max(l,Math.min($(u),c));n===1&&(i[s]=Math.max(i[s]??0,l+r))}for(let s=0;s<e.length;s+=1)for(let o=0;o<this.#t.columns;o+=1){const h=e[s]?.[o];if(!h||rt(e,s,o,h)!==s||o>0&&e[s]?.[o-1]===h)continue;const n=h.colSpan??1;if(n>1){const c=h.maxWidth??Number.POSITIVE_INFINITY,d=String(h.content??"").split(lt),l=this.#t.wordWrap&&h.wordWrap!==!1;let u=0;for(const f of d)u=Math.max(u,Math.min($(f),c));u=this.computeWrappedContentWidth(u,d,c,l);let p=0;for(let f=o;f<o+n;f+=1)p+=i[f]??0;const m=n>1?(n-1)*a:0,g=u+r+m,w=p+m;if(g>w){const f=g-w,v=Math.floor(f/n);let b=0;for(let x=0;x<n&&o+x<this.#t.columns;x+=1){const B=Math.min(v,f-b);if(i[o+x]=(i[o+x]??0)+B,b+=B,b>=f)break}}}}if(this.#t.maxWidth){const s=this.calculateTotalGridWidth(i);if(s>this.#t.maxWidth)return this.adjustColumnWidthsForTerminal(i,s)}return i}renderVisualRowContent(e,i,r,a,s){const o=e[i];if(!o)return"";const h=this.#t.borderColor??this.#t.foregroundColor??void 0,n=[],c=this.#t.showBorders&&this.#t.border?Jr(this.#t.border):void 0,d=c&&c.left.width>0?c.left.char:"",l=c&&c.right.width>0?c.right.char:"",u=c&&c.join.width>0?c.join.char:"",p=" ".repeat(this.#t.gap);d&&n.push(W(W(d,h),this.#t.backgroundColor));let m=0;for(;m<this.#t.columns;){const g=o[m]??void 0;let w=1,f;if(g){const v=g.colSpan??1;w=v;const b=rt(e,i,m,g),x=Et(a,m,v),B=this.alignCellContent(g,x),R=B.length,I=this.getCachedCellVerticalPosition(e,i,m,g);I.firstRow!==b&&console.warn(`Mismatch between findFirstOccurrenceRow (${String(b)}) and determineCellVerticalPosition (${String(I.firstRow)})`);const M=s.slice(b,I.lastRow+1).reduce((A,F)=>A+F,0),E=I.lastRow-I.firstRow+1;let k=r,L=0;for(let A=b;A<i;A+=1)A<s.length&&(k+=s[A]??1),A<I.lastRow&&(L+=1);k+=L;const H=g.vAlign??"top";let _;switch(H){case"bottom":{let A=r;for(let P=b;P<i;P+=1)A+=s[P]??1;const F=M-R;_=A>=F?A-F:-1;break}case"middle":{const A=Math.round((M-R)/2);let F=r;for(let P=b;P<i;P+=1)F+=s[P]??1;_=F>=A&&F<A+R?F-A:-1;break}case"top":{_=k;break}default:_=k}const Jt=_>=0&&_<R;if(f=" ".repeat(Math.max(0,x)),Jt){let A=!1;H==="middle"&&E%2===0&&_===0&&(A=!0),A||(f=B[_]??f)}g.colSpan&&g.colSpan>1&&(f+=p.repeat(g.colSpan)),g.foregroundColor?f=W(f,g.foregroundColor):this.#t.foregroundColor&&(f=W(f,this.#t.foregroundColor)),g.backgroundColor?f=W(f,g.backgroundColor):this.#t.backgroundColor&&(f=W(f,this.#t.backgroundColor))}else{const v=this.#t.paddingLeft+this.#t.paddingRight,b=Math.max(0,(a[m]??0)-v),x=" ".repeat(this.#t.paddingLeft+b+this.#t.paddingRight);f=W(W(r===0?x:" ".repeat(x.length),this.#t.foregroundColor),this.#t.backgroundColor)}n.push(f),m+w<this.#t.columns&&(n.push(p),this.#t.showBorders&&u&&n.push(W(W(u,h),this.#t.backgroundColor)),this.#t.gap>0&&n.push(p)),m+=w}return l&&n.push(W(W(l,h),this.#t.backgroundColor)),n.join("")}alignCellContent(e,i){const r=this.#n.get(e);if(r?.has(i))return r.get(i);const{paddingLeft:a,paddingRight:s}=this.#t,o=a+s,h=i-o;if(h<=0){const l=[" ".repeat(o+this.#t.gap)];return r?r.set(i,l):this.#n.set(e,new Map([[i,l]])),l}let n;const c=String(e.content??"");if(n=c.includes(`
10
+ `)||c.includes("\r")?c.split(lt):[c],this.#t.wordWrap&&e.wordWrap!==!1){const l=typeof this.#t.wordWrap=="object"?this.#t.wordWrap:{},u=typeof e.wordWrap=="object"?e.wordWrap:l;n=kr(c,{...u,width:h}).split(`
11
+ `)}if(this.#t.truncate&&e.truncate!==!1){const l=typeof this.#t.truncate=="object"?this.#t.truncate:{},u=typeof e.truncate=="object"?e.truncate:l;n=n.map(p=>Re(p,h,u))}else this.#t.truncateOverflow&&(n=n.map(l=>$(l)>h?Re(l,h,{}):l));const d=n.map(l=>eo(l,h,e.hAlign??"left",a,s));return r?r.set(i,d):this.#n.set(e,new Map([[i,d]])),d}renderHorizontalBorder(e,i,r,a,s,o=-1){if(!this.#t.showBorders||!this.#t.border)return"";const h=this.#t.border,n=it(h,s),c=n.body.char,d=n.body.width,l=h.bodyJoin.char;if(s!=="middle"&&d===0)return"";let u=n.left.char,p=n.right.char;if(s==="middle"&&o!==-1){const f=e[r]?.[0]??void 0,v=e[o]?.[0]??void 0;f&&v&&f===v&&(u=l);const b=this.#t.columns-1,x=e[r]?.[b]??void 0,B=e[o]?.[b]??void 0;x&&B&&x===B&&(p=l)}const m=[],g=" ".repeat(this.#t.gap);u&&m.push(W(W(u,this.#t.borderColor),this.#t.backgroundColor));let w;for(let f=0;f<this.#t.columns;f+=1){const v=e[r]?.[f]??void 0,b=s==="middle"&&o!==-1?e[o]?.[f]??void 0:void 0;let x,B=!1;if(v&&(f===0||e[r]?.[f-1]!==v)&&(x=v,B=!0),v&&!B)continue;if(!v){const M=a[f]??0;if(w=d>0?c.repeat(M):" ".repeat(M),m.push(W(W(w,this.#t.borderColor),this.#t.backgroundColor)),f<this.#t.columns-1){const E=this.determineJoinChar(s,e,r,o,f,f+1);m.push(g),E.width>0&&m.push(W(W(E.char,this.#t.borderColor),this.#t.backgroundColor))}continue}const R=x?.colSpan??1;if(s==="middle"&&s==="middle"&&b&&v===b&&x){const M=x.vAlign==="middle",{firstRow:E,lastRow:k}=this.getCachedCellVerticalPosition(e,r,f,x),L=k-E+1,H=L%2===0,_=E+Math.ceil(L/2)-1,Jt=Et(a,f,R),A=this.alignCellContent(x,Jt),F=A.length;if(M&&H&&r===_)w=W(A[0]??"",this.#t.borderColor);else{let P=0;for(let et=E;et<=r;et+=1)P+=i[et]??1,et<r&&(P+=1);const Ht=P;if(Ht>=0&&Ht<F)w=W(A[Ht]??"",this.#t.foregroundColor);else{const et=a.slice(f,f+R).reduce((Ke,Ze)=>Ke+Ze,0)+(R-1)*(this.#t.gap+this.#t.border.bodyJoin.width);w=W(" ".repeat(et),this.#t.borderColor)}}m.push(W(w,this.#t.backgroundColor))}else{const M=[];for(let E=f;E<f+R;E+=1){const k=a[E]??0,L=d>0?c:" ";if(M.push(L.repeat(k+this.#t.gap)),E<f+R-1){const H=this.determineJoinChar(s,e,r,o,E,E+1);H.width>0&&M.push(H.char)}}w=M.join(""),m.push(W(W(w,this.#t.borderColor),this.#t.backgroundColor))}const I=f+R-1;if(I<this.#t.columns-1){const M=this.determineJoinChar(s,e,r,o,I,I+1);M.width>0&&m.push(W(W(M.char,this.#t.borderColor),this.#t.backgroundColor))}f+=R-1}return p&&m.push(W(W(p,this.#t.borderColor),this.#t.backgroundColor)),m.join("")}determineJoinChar(e,i,r,a,s,o=-1){if(!this.#t.showBorders||!this.#t.border)return{char:" ",width:this.#t.gap};const h=this.#t.border;if(e!=="middle"){const B=it(h,e),R=i[r]?.[s]??void 0,I=o===-1?s+1:o,M=i[r]?.[I]??void 0,E=R!==void 0&&M!==void 0&&R===M?B.body:B.join,{char:k,width:L}=E;return{char:k,width:L>0?L:this.#t.gap}}if(a===-1||o===-1)return{char:" ",width:this.#t.gap};const n=h.bodyJoin,c=i[r]?.[s]??void 0,d=i[a]?.[s]??void 0,l=i[r]?.[o]??void 0,u=i[a]?.[o]??void 0,p=c!==void 0&&d!==void 0&&c===d,m=l!==void 0&&u!==void 0&&l===u,g=c!==void 0&&l!==void 0&&c===l,w=d!==void 0&&u!==void 0&&d===u;let f;const v=it(h,"middle");p&&m?f=g?{char:" ",width:n.width}:n:p?f=h.joinLeft:m?f=h.joinRight:g&&w?f=v.body:g?f=h.topJoin:w?f=h.bottomJoin:f=h.joinJoin;const{char:b,width:x}=f;return{char:b,width:x>0?x:this.#t.gap}}renderGrid(e,i){if(e.length===0)return"";const r=[],a=qr(e,i,this.#t,this.alignCellContent.bind(this),rt),s=this.#t.showBorders&&this.#t.border?it(this.#t.border,"top"):void 0;s&&s.body.width>0&&r.push(this.renderHorizontalBorder(e,a,0,i,"top"));for(let h=0;h<e.length;h+=1){const n=a[h]??1;for(let d=0;d<n;d+=1)r.push(this.renderVisualRowContent(e,h,d,i,a));const c=this.#t.showBorders&&this.#t.border?it(this.#t.border,"middle"):void 0;if(h<e.length-1&&c&&c.body.width>0){const d=e[h],l=e[h+1];let u=!1;if(d&&l)for(let p=0;p<this.#t.columns;p+=1){const m=d[p],g=l[p];if(m!==g){u=!0;break}}u&&r.push(this.renderHorizontalBorder(e,a,h,i,"middle",h+1))}}const o=this.#t.showBorders&&this.#t.border?it(this.#t.border,"bottom"):void 0;return o&&o.body.width>0&&r.push(this.renderHorizontalBorder(e,a,e.length-1,i,"bottom")),r.join(`
12
+ `)}getCachedCellVerticalPosition(e,i,r,a){const s=this.#i.get(a);if(s)return s;const o=Xt(e,i,r,a);return this.#i.set(a,o),o}}ne(t=>new _t(t),"createGrid");const ro={bodyJoin:{char:"│",width:1},bodyLeft:{char:"│",width:1},bodyRight:{char:"│",width:1},bottomBody:{char:"─",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"└",width:1},bottomRight:{char:"┘",width:1},joinBody:{char:"─",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"─",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"┌",width:1},topRight:{char:"┐",width:1}},Bo={bodyJoin:{char:" ",width:1},bodyLeft:{char:" ",width:1},bodyRight:{char:" ",width:1},bottomBody:{char:"-",width:1},bottomJoin:{char:"-",width:1},bottomLeft:{char:"-",width:1},bottomRight:{char:"-",width:1},joinBody:{char:"-",width:1},joinJoin:{char:"-",width:1},joinLeft:{char:"-",width:1},joinRight:{char:"-",width:1},topBody:{char:"-",width:1},topJoin:{char:"-",width:1},topLeft:{char:"-",width:1},topRight:{char:"-",width:1}},Ro={bodyJoin:{char:"║",width:1},bodyLeft:{char:"║",width:1},bodyRight:{char:"║",width:1},bottomBody:{char:"═",width:1},bottomJoin:{char:"╩",width:1},bottomLeft:{char:"╚",width:1},bottomRight:{char:"╝",width:1},joinBody:{char:"═",width:1},joinJoin:{char:"╬",width:1},joinLeft:{char:"╠",width:1},joinRight:{char:"╣",width:1},topBody:{char:"═",width:1},topJoin:{char:"╦",width:1},topLeft:{char:"╔",width:1},topRight:{char:"╗",width:1}},Wo={bodyJoin:{char:"│",width:1},bodyLeft:{char:"│",width:1},bodyRight:{char:"│",width:1},bottomBody:{char:"─",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"╰",width:1},bottomRight:{char:"╯",width:1},joinBody:{char:"─",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"─",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"╭",width:1},topRight:{char:"╮",width:1}},So={bodyJoin:{char:"┊",width:1},bodyLeft:{char:"┊",width:1},bodyRight:{char:"┊",width:1},bottomBody:{char:"┈",width:1},bottomJoin:{char:"┴",width:1},bottomLeft:{char:"└",width:1},bottomRight:{char:"┘",width:1},joinBody:{char:"┈",width:1},joinJoin:{char:"┼",width:1},joinLeft:{char:"├",width:1},joinRight:{char:"┤",width:1},topBody:{char:"┈",width:1},topJoin:{char:"┬",width:1},topLeft:{char:"┌",width:1},topRight:{char:"┐",width:1}},Io={bodyJoin:{char:"|",width:1},bodyLeft:{char:"|",width:1},bodyRight:{char:"|",width:1},bottomBody:{char:"-",width:1},bottomJoin:{char:"|",width:1},bottomLeft:{char:"|",width:1},bottomRight:{char:"|",width:1},joinBody:{char:"-",width:1},joinJoin:{char:"|",width:1},joinLeft:{char:"|",width:1},joinRight:{char:"|",width:1},topBody:{char:"-",width:1},topJoin:{char:"|",width:1},topLeft:{char:"|",width:1},topRight:{char:"|",width:1}},Mo={bodyJoin:{char:"|",width:1},bodyLeft:{char:"|",width:1},bodyRight:{char:"|",width:1},bottomBody:{char:"-",width:1},bottomJoin:{char:"+",width:1},bottomLeft:{char:"+",width:1},bottomRight:{char:"+",width:1},joinBody:{char:"-",width:1},joinJoin:{char:"+",width:1},joinLeft:{char:"+",width:1},joinRight:{char:"+",width:1},topBody:{char:"-",width:1},topJoin:{char:"+",width:1},topLeft:{char:"+",width:1},topRight:{char:"+",width:1}},Ao={bodyJoin:{char:"",width:0},bodyLeft:{char:"",width:0},bodyRight:{char:"",width:0},bottomBody:{char:"",width:0},bottomJoin:{char:"",width:0},bottomLeft:{char:"",width:0},bottomRight:{char:"",width:0},joinBody:{char:"",width:0},joinJoin:{char:"",width:0},joinLeft:{char:"",width:0},joinRight:{char:"",width:0},topBody:{char:"",width:0},topJoin:{char:"",width:0},topLeft:{char:"",width:0},topRight:{char:"",width:0}},jo={bodyJoin:{char:"█",width:1},bodyLeft:{char:"█",width:1},bodyRight:{char:"█",width:1},bottomBody:{char:"█",width:1},bottomJoin:{char:"█",width:1},bottomLeft:{char:"█",width:1},bottomRight:{char:"█",width:1},joinBody:{char:"█",width:1},joinJoin:{char:"█",width:1},joinLeft:{char:"█",width:1},joinRight:{char:"█",width:1},topBody:{char:"█",width:1},topJoin:{char:"█",width:1},topLeft:{char:"█",width:1},topRight:{char:"█",width:1}},Co={bodyJoin:{char:"┃",width:1},bodyLeft:{char:"┃",width:1},bodyRight:{char:"┃",width:1},bottomBody:{char:"━",width:1},bottomJoin:{char:"┻",width:1},bottomLeft:{char:"┗",width:1},bottomRight:{char:"┛",width:1},joinBody:{char:"━",width:1},joinJoin:{char:"╋",width:1},joinLeft:{char:"┣",width:1},joinRight:{char:"┫",width:1},topBody:{char:"━",width:1},topJoin:{char:"┳",width:1},topLeft:{char:"┏",width:1},topRight:{char:"┓",width:1}};var oo=Object.defineProperty,qe=O((t,e)=>oo(t,"name",{value:e,configurable:!0}),"p"),no=Object.defineProperty,se=qe((t,e)=>no(t,"name",{value:e,configurable:!0}),"y"),so=Object.defineProperty,ho=se((t,e)=>so(t,"name",{value:e,configurable:!0}),"t");const ao=ho(t=>t.reduce((e,i)=>{if(i===null)return e+1;if(typeof i=="object"&&!Array.isArray(i)){const r=typeof i.colSpan=="number"?i.colSpan:1;return e+(r<=0?1:r)}return e+1},0),"computeRowLogicalWidth");var co=Object.defineProperty,Ue=se((t,e)=>co(t,"name",{value:e,configurable:!0}),"b");class lo{static{O(this,"H")}static{qe(this,"D")}static{se(this,"Table")}static{Ue(this,"Table")}#t;#o=[];#e=[];#n=[];#i=!0;#r=void 0;constructor(e={}){this.#t={...e,showFooter:e.showFooter??!0,showHeader:e.showHeader??!0,style:{border:ro,paddingLeft:1,paddingRight:1,...e.style}}}setHeaders(e){return e.length>0&&!Array.isArray(e[0])?this.#e=[e]:this.#e=e.map(i=>Array.isArray(i)?i:[i]),this.#i=!0,this.#r=void 0,this}setFooter(e){return e.length>0&&!Array.isArray(e[0])?this.#n=[e]:this.#n=e.map(i=>Array.isArray(i)?i:[i]),this.#i=!0,this.#r=void 0,this}addRow(e){if(!Array.isArray(e))throw new TypeError("Row must be an array");return this.#o.push(e),this.#i=!0,this.#r=void 0,this}addRows(...e){for(const i of e)this.addRow(i);return this.#i=!0,this.#r=void 0,this}toString(){if(!this.#i&&this.#r!==void 0)return this.#r;const e=this.#t.showHeader?this.#e:[],i=this.#t.showFooter?this.#n:[],r=[...e,...this.#o,...i];if(r.length===0)return this.#r="",this.#i=!1,"";let a=0;for(const l of r){const u=l;Array.isArray(u)?a=Math.max(a,ao(u)):console.error("Unexpected non-array element found while calculating columns:",u)}if(a===0)return this.#r="",this.#i=!1,"";let s;Array.isArray(this.#t.columnWidths)?s=this.#t.columnWidths.length>=a?this.#t.columnWidths.slice(0,a):[...this.#t.columnWidths,...Array.from({length:a-this.#t.columnWidths.length}).fill(void 0)]:typeof this.#t.columnWidths=="number"&&(s=Array.from({length:a}).fill(this.#t.columnWidths));let o;const h=r.length;if(Array.isArray(this.#t.rowHeights)?o=this.#t.rowHeights:typeof this.#t.rowHeights=="number"&&(o=Array.from({length:h}).fill(this.#t.rowHeights)),s&&Array.isArray(s)){const l=[...s];for(const u of r){const p=u;for(const[m,g]of p.entries()){let w={};if(typeof g=="object"&&g!==null&&!Array.isArray(g)){const{content:f,href:v,...b}=g;w=b}w.width!==void 0?l[m]=w.width:w.maxWidth!==void 0&&l[m]!==void 0&&(l[m]=Math.min(l[m],w.maxWidth))}}s=l}const n={autoFlow:"row",backgroundColor:this.#t.style?.backgroundColor,balancedWidths:this.#t.balancedWidths??!1,border:this.#t.style?.border,borderColor:this.#t.style?.borderColor,columns:a,fixedColumnWidths:s,fixedRowHeights:o,foregroundColor:this.#t.style?.foregroundColor,gap:this.#t.gap??0,maxWidth:this.#t.maxWidth,paddingLeft:this.#t.style?.paddingLeft,paddingRight:this.#t.style?.paddingRight,terminalWidth:this.#t.terminalWidth,truncate:this.#t.truncate??(s?.every(l=>typeof l=="number")||this.#t.maxWidth!==void 0&&!this.#t.balancedWidths),truncateOverflow:this.#t.truncateOverflow??!0,wordWrap:this.#t.wordWrap??!1},c=new _t(n),d=[];for(const[l,u]of r.entries()){const p=u;if(!Array.isArray(p)){console.error("Skipping non-array row while creating GridItems:",p);continue}const m=this.#t.showHeader?this.#e.length:0,g=this.#o.length,w=this.#t.showHeader&&l<m,f=this.#t.showFooter&&l>=m+g,v=w&&p.length===1&&a>1,b=f&&p.length===1&&a>1;for(const x of p){let B=x,R={};if(typeof B=="object"&&B!==null&&!Array.isArray(B)){const{content:k,href:L,...H}=B;B=L?`\x1B]8;;${L}\x1B\\${String(k)}\x1B]8;;\x1B\\`:k,R=H}v&&(R.colSpan=a),b&&(R.colSpan=a);const I=this.#t.transformTabToSpace&&typeof B=="string"?B.replaceAll(" "," ".repeat(this.#t.transformTabToSpace)):B,{maxWidth:M,width:E}=R;d.push({backgroundColor:R.backgroundColor,colSpan:R.colSpan,content:I,foregroundColor:R.foregroundColor,hAlign:R.hAlign,maxWidth:M,rowSpan:R.rowSpan,truncate:R.truncate??(M===void 0?void 0:!0),vAlign:R.vAlign,width:E,wordWrap:R.wordWrap})}}return c.addItems(d),this.#r=c.toString(),this.#i=!1,this.#r}}const $o=Ue(t=>new lo(t),"createTable");export{pi as B,po as E,lo as H,wo as I,$o as M,bo as N,yo as P,Co as R,xo as T,Io as a,Mo as c,So as d,vo as e,U as g,Bo as h,Ro as i,mo as j,Wo as o,go as q,Ao as r,ro as t,jo as w};
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var r=(t,e)=>c(t,"name",{value:e,configurable:!0});var p=Object.defineProperty,a=r((t,e)=>p(t,"name",{value:e,configurable:!0}),"t");function f(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}r(f,"getDefaultExportFromCjs");a(f,"getDefaultExportFromCjs");function l(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}r(l,"getDefaultExportFromNamespaceIfPresent");a(l,"getDefaultExportFromNamespaceIfPresent");function s(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")&&Object.keys(t).length===1?t.default:t}r(s,"getDefaultExportFromNamespaceIfNotNamed");a(s,"getDefaultExportFromNamespaceIfNotNamed");function m(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var o=a(r(function n(){var u=!1;try{u=this instanceof n}catch{}return u?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)},"a"),"a");o.prototype=e.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var u=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(o,n,u.get?u:{enumerable:!0,get:a(function(){return t[n]},"get")})}),o}r(m,"getAugmentedNamespace");a(m,"getAugmentedNamespace");export{m as a,f as g};
@@ -0,0 +1 @@
1
+ var I=Object.defineProperty;var d=(s,e)=>I(s,"name",{value:e,configurable:!0});import{createRequire as $}from"node:module";import{b as j}from"../packem_chunks/config.js";import{advisoriesStatus as E,NATIVE_BINDING_VERSION as A,advisoriesIngest as q,advisoriesQuery as B}from"#native";const T=$(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=d(s=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[e,t]=v.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return v.getBuiltinModule(s)}return T(s)},"__cjs_getBuiltinModule"),{randomUUID:O}=l("node:crypto"),{createWriteStream:P,existsSync:k}=l("node:fs"),{mkdir:U,unlink:x,stat:C}=l("node:fs/promises"),{join:w,dirname:L}=l("node:path"),{Readable:M}=l("node:stream"),{pipeline:W}=l("node:stream/promises");var F=Object.defineProperty,r=d((s,e)=>F(s,"name",{value:e,configurable:!0}),"s");const b=5;if(A!==b)throw new Error(`vis native binding ABI mismatch in advisories: expected ${b}, got ${A}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const es="https://osv-vulnerabilities.storage.googleapis.com",V=new Set(["osv-vulnerabilities.storage.googleapis.com"]);class H extends Error{static{d(this,"AdvisoryDbNotFoundError")}static{r(this,"AdvisoryDbNotFoundError")}cause="DB_NOT_FOUND";constructor(e){super(`No local advisory DB at ${e}. Run 'vis advisories sync' first.`),this.name="AdvisoryDbNotFoundError"}}class p extends Error{static{d(this,"AdvisorySourceNotAllowedError")}static{r(this,"AdvisorySourceNotAllowedError")}cause="SOURCE_NOT_ALLOWED";constructor(e){super(`Advisory source host '${e}' is not in the built-in allowlist. Add it to \`security.audit.advisories.allowedHosts\` if intentional.`),this.name="AdvisorySourceNotAllowedError"}}class N extends Error{static{d(this,"AdvisorySyncNetworkError")}static{r(this,"AdvisorySyncNetworkError")}cause="SYNC_NETWORK";constructor(e,t){super(`Advisory sync failed for ${e}: ${t}. Check connectivity, proxy env vars, or --source.`),this.name="AdvisorySyncNetworkError"}}const g=r(s=>{const e=j("vis",{create:!0,cwd:s})??w(s,"node_modules",".cache","vis");return w(e,"advisories","db.sqlite")},"resolveAdvisoryDbPath"),z=r((s,e)=>{let t;try{t=new URL(s)}catch{throw new p(s)}if(t.protocol!=="https:")throw new p(`${t.protocol}//${t.host}`);if(!new Set([...V,...e??[]]).has(t.host))throw new p(t.host);return t},"validateAdvisorySource"),ts=r(async s=>{const e=s.dbPath??g(s.workspaceRoot);await U(L(e),{recursive:!0});const t=z(s.source,s.allowedHosts),u=new URL(`${s.ecosystem}/all.zip`,Q(t.toString())),y=await G(e,s.ecosystem);let i=null;if(!s.force){const n=await S(u,{method:"HEAD"});if(n.ok&&(i=n.headers.get("etag"),i&&y&&i===y))return{advisoriesIngested:0,dbPath:e,durationMs:0,upToDate:!0}}const a=`${e}.${s.ecosystem}.${process.pid}.${O()}.zip.tmp`,o=await S(u,{method:"GET"});if(!o.ok||!o.body)throw new N(u.toString(),o.status);i||(i=o.headers.get("etag"));const m=o.headers.get("content-length"),c=m?Number.parseInt(m,10):null;let h=0;const _=P(a),f=M.fromWeb(o.body);s.onProgress&&c&&f.on("data",n=>{h+=n.byteLength,s.onProgress?.(h,c,"download")}),await W(f,_);try{const n=await q({dbPath:e,ecosystem:s.ecosystem,manifestEtag:i??void 0,zipPath:a},(D,R)=>s.onProgress?.(D,R,"ingest"));return{advisoriesIngested:n.advisoriesIngested,dbPath:e,durationMs:n.durationMs,upToDate:!1}}finally{await x(a).catch(()=>{})}},"syncAdvisories"),rs=r((s,e)=>{if(s.length===0)return new Map;const t=e.dbPath??g(e.workspaceRoot),u=e.ecosystem??"npm";if(!k(t))throw new H(t);const y=s.map(o=>({ecosystem:u,name:o.name,version:o.version})),i=B(t,y),a=new Map;for(const[o,m]of s.entries()){const c=i[o];!c||c.vulnerabilities.length===0||a.set(m.name,c.vulnerabilities.map(h=>K(h)))}return a},"queryAdvisories"),os=r(async(s,e)=>{const t=e??g(s);return E(t)},"getAdvisoryStatus"),G=r(async(s,e)=>{try{await C(s)}catch{return null}return E(s).ecosystems.find(t=>t.name===e)?.manifestEtag??null},"readStoredEtag"),K=r(s=>({aliases:s.aliases.length>0?s.aliases:void 0,cvssScore:s.cvssScore??void 0,fixedVersions:s.fixedVersions,id:s.id,severity:Y(s.severity),summary:s.summary}),"toSecurityVulnerability"),Y=r(s=>{const e=s.toUpperCase();return e==="CRITICAL"||e==="HIGH"||e==="MODERATE"||e==="LOW"?e:"UNKNOWN"},"normalizeSeverity"),Q=r(s=>s.endsWith("/")?s:`${s}/`,"ensureTrailingSlash"),S=r(async(s,e)=>{try{return await fetch(s,e)}catch(t){throw new N(s.toString(),t instanceof Error?t.message:String(t))}},"safeFetch");export{H as A,es as D,os as g,rs as q,g as r,ts as s};
@@ -0,0 +1 @@
1
+ var E=Object.defineProperty;var c=(e,t)=>E(e,"name",{value:t,configurable:!0});import{createRequire as p}from"node:module";import{l as f,B as A}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";const g=p(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=c(e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[t,r]=l.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return l.getBuiltinModule(e)}return g(e)},"__cjs_getBuiltinModule"),{spawnSync:b}=h("node:child_process");var v=Object.defineProperty,i=c((e,t)=>v(e,"name",{value:t,configurable:!0}),"o");const I="0000000000000000000000000000000000000000",R=i(e=>{if(f(e))try{const t=A(e);return JSON.parse(t)}catch{return}},"defaultReadEventPayload"),C=i((e,t)=>{const r=b("git",e,{cwd:t,encoding:"utf8"});if(!(r.error||typeof r.status!="number"||r.status!==0))return typeof r.stdout=="string"?r.stdout.trim():void 0},"defaultRunGit"),d=i(e=>typeof e=="string"&&e.length>0&&e!==I,"isNonEmptySha");i((e,...t)=>{let r=e;for(const o of t){if(r===null||typeof r!="object")return;r=r[o]}return r},"getNested");const B=i((e,t,r)=>{const o=[],s=e.GITHUB_BASE_REF,n=e.GITHUB_SHA??"HEAD";if(s&&s.length>0)return o.push(`pull_request: $GITHUB_BASE_REF=${s}`),{base:`origin/${s}`,head:n,notes:o,provider:"github"};const u=e.GITHUB_EVENT_PATH,a=u?r(u):void 0;if(a){const _=typeof a.before=="string"?a.before:void 0;if(d(_))return o.push(`push: event.before=${_}`),{base:_,head:n,notes:o,provider:"github"}}return o.push(`fallback: origin/${t}`),{base:`origin/${t}`,head:n,notes:o,provider:"github"}},"resolveGithub"),T=i((e,t)=>{const r=[],o=e.CI_COMMIT_SHA??"HEAD";if(e.CI_PIPELINE_SOURCE==="merge_request_event"){const u=e.CI_MERGE_REQUEST_DIFF_BASE_SHA;if(d(u))return r.push(`merge_request: $CI_MERGE_REQUEST_DIFF_BASE_SHA=${u}`),{base:u,head:o,notes:r,provider:"gitlab"};const a=e.CI_MERGE_REQUEST_TARGET_BRANCH_NAME;if(a&&a.length>0)return r.push(`merge_request: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME=${a}`),{base:`origin/${a}`,head:o,notes:r,provider:"gitlab"}}const s=e.CI_COMMIT_BEFORE_SHA;if(d(s))return r.push(`push: $CI_COMMIT_BEFORE_SHA=${s}`),{base:s,head:o,notes:r,provider:"gitlab"};const n=e.CI_DEFAULT_BRANCH??t;return r.push(`fallback: origin/${n}`),{base:`origin/${n}`,head:o,notes:r,provider:"gitlab"}},"resolveGitlab"),$=i((e,t)=>{const r=[],o=e.BUILDKITE_COMMIT??"HEAD",s=e.BUILDKITE_PULL_REQUEST_BASE_BRANCH;return s&&s.length>0?(r.push(`pull_request: $BUILDKITE_PULL_REQUEST_BASE_BRANCH=${s}`),{base:`origin/${s}`,head:o,notes:r,provider:"buildkite"}):(r.push(`fallback: origin/${t} (buildkite has no canonical previous-build SHA env)`),{base:`origin/${t}`,head:o,notes:r,provider:"buildkite"})},"resolveBuildkite"),H=i((e,t)=>{const r=[],o=e.CIRCLE_SHA1??"HEAD",s=e.CIRCLE_PR_BASE_BRANCH;return s&&s.length>0?(r.push(`pull_request: $CIRCLE_PR_BASE_BRANCH=${s}`),{base:`origin/${s}`,head:o,notes:r,provider:"circleci"}):(r.push(`fallback: origin/${t} (circleci has no canonical previous-build SHA env)`),{base:`origin/${t}`,head:o,notes:r,provider:"circleci"})},"resolveCircleCI"),S=i((e,t,r)=>{const o=[],s=t(["merge-base","HEAD",`origin/${e}`],r);return s&&s.length>0?(o.push(`local: git merge-base HEAD origin/${e}=${s}`),{base:s,head:"HEAD",notes:o,provider:"local"}):(o.push(`local fallback: origin/${e} (no merge-base available)`),{base:`origin/${e}`,head:"HEAD",notes:o,provider:"local"})},"resolveLocal"),L=i(e=>{const t=e?.env??process.env,r=e?.defaultBase??"main",o=e?.readEventPayload??R,s=e?.runGit??C,n=e?.workspaceRoot??process.cwd();return t.GITHUB_ACTIONS==="true"?B(t,r,o):t.GITLAB_CI==="true"?T(t,r):t.BUILDKITE==="true"?$(t,r):t.CIRCLECI==="true"?H(t,r):S(r,s,n)},"resolveAffectedShas");export{L as r};
@@ -0,0 +1,68 @@
1
+ var F=Object.defineProperty;var k=(e,r)=>F(e,"name",{value:r,configurable:!0});import{createRequire as B}from"node:module";import{d as U,R as v,a6 as W,n as b,y as K,aj as G,ak as Y,al as X,am as Q}from"../packem_chunks/bin.js";const D=B(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=k(e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[r,a]=w.versions.node.split(".").map(Number);if(r>22||r===22&&a>=3||r===20&&a>=16)return w.getBuiltinModule(e)}return D(e)},"__cjs_getBuiltinModule"),{spawn:J,execFileSync:E}=$("node:child_process"),{existsSync:j}=$("node:fs"),{platform:z,homedir:M}=$("node:os"),{join:g}=$("node:path"),Z=/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/,ee=5e3,re=1e4,te=3e5,ae=4096,T=z()==="win32",x=["amp","claude","codex","copilot","crush","cursor","droid","gemini","kimi","opencode","qwen"];var ne=Object.defineProperty,ie=k((e,r)=>ne(e,"name",{value:r,configurable:!0}),"O"),oe=Object.defineProperty,m=ie((e,r)=>oe(e,"name",{value:r,configurable:!0}),"a"),se=Object.defineProperty,ce=m((e,r)=>se(e,"name",{value:r,configurable:!0}),"a$6");const le={alternateCommands:[],buildArgs:ce((e,r,a)=>["-x",e,"--dangerously-allow-all"],"buildArgs"),command:"amp",defaultModel:"",envVariable:"AMP_PATH"};var ue=Object.defineProperty,de=m((e,r)=>ue(e,"name",{value:r,configurable:!0}),"t$8");const me={alternateCommands:[],buildArgs:de((e,r,a)=>["--dangerously-skip-permissions","--model",r,"--output-format","text","-p",e],"buildArgs"),command:"claude",defaultModel:"claude-sonnet-4-20250514",envVariable:"CLAUDE_PATH"};var pe=Object.defineProperty,ge=m((e,r)=>pe(e,"name",{value:r,configurable:!0}),"a$4");const fe={alternateCommands:["openai-codex"],buildArgs:ge((e,r,a)=>[e,"--approval-mode","full-auto","--quiet","--model",r,"--max-tokens",String(a)],"buildArgs"),command:"codex",defaultModel:"o3",envVariable:"CODEX_PATH"};var he=Object.defineProperty,ve=m((e,r)=>he(e,"name",{value:r,configurable:!0}),"l");const ye={alternateCommands:[],buildArgs:ve((e,r,a)=>{const t=["-p",e,"--allow-all-tools"];return r&&t.push("--model",r),t},"buildArgs"),command:"copilot",defaultModel:"",envVariable:"COPILOT_PATH"};var be=Object.defineProperty,ke=m((e,r)=>be(e,"name",{value:r,configurable:!0}),"n$2");const we={alternateCommands:[],buildArgs:ke((e,r,a)=>{const t=["run","--yolo"];return r&&t.push("-m",r),t.push(e),t},"buildArgs"),command:"crush",defaultModel:"",envVariable:"CRUSH_PATH"};var Ae=Object.defineProperty,$e=m((e,r)=>Ae(e,"name",{value:r,configurable:!0}),"t$5");const Se={alternateCommands:["cursor"],buildArgs:$e((e,r,a)=>{const t=["-p","--force","--output-format","text"];return r&&t.push("--model",r),t.push(e),t},"buildArgs"),command:"agent",defaultModel:"",envVariable:"CURSOR_PATH"};var Pe=Object.defineProperty,Te=m((e,r)=>Pe(e,"name",{value:r,configurable:!0}),"i");const Ce={alternateCommands:[],buildArgs:Te((e,r,a)=>{const t=[e,"--skip-permissions-unsafe","-o","text"];return r&&t.push("-m",r),t},"buildArgs"),command:"droid",defaultModel:"",envVariable:"DROID_PATH"};var je=Object.defineProperty,Oe=m((e,r)=>je(e,"name",{value:r,configurable:!0}),"o$1");const Re={alternateCommands:["gemini-cli"],buildArgs:Oe((e,r,a)=>["--sandbox","--model",r,"--max-output-tokens",String(a),"-p",e],"buildArgs"),command:"gemini",defaultModel:"gemini-2.5-pro",envVariable:"GEMINI_PATH"};var Ee=Object.defineProperty,Me=m((e,r)=>Ee(e,"name",{value:r,configurable:!0}),"o");const xe={alternateCommands:[],buildArgs:Me((e,r,a)=>{const t=["--quiet","-p",e];return r&&t.push("-m",r),t},"buildArgs"),command:"kimi",defaultModel:"",envVariable:"KIMI_PATH"};var Ie=Object.defineProperty,_e=m((e,r)=>Ie(e,"name",{value:r,configurable:!0}),"r");const Ne={alternateCommands:[],buildArgs:_e((e,r,a)=>{const t=["run",e];return r&&t.push("-m",r),t},"buildArgs"),command:"opencode",defaultModel:"anthropic/claude-sonnet-4",envVariable:"OPENCODE_PATH"};var Le=Object.defineProperty,qe=m((e,r)=>Le(e,"name",{value:r,configurable:!0}),"n");const Ve={alternateCommands:["qwen-code"],buildArgs:qe((e,r,a)=>["-p",e,"--yolo","-o","text"],"buildArgs"),command:"qwen",defaultModel:"",envVariable:"QWEN_PATH"};var He=Object.defineProperty,f=m((e,r)=>He(e,"name",{value:r,configurable:!0}),"s");const I={amp:le,claude:me,codex:fe,copilot:ye,crush:we,cursor:Se,droid:Ce,gemini:Re,kimi:xe,opencode:Ne,qwen:Ve},O=f(e=>e==="~"||e.startsWith("~/")||T&&e.startsWith("~\\")?g(M(),e.slice(2)):e,"resolveHome"),Fe=f(e=>{try{const r=E(T?"where":"which",[e],{encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:ee}).trim().split(`
2
+ `)[0]?.trim();return r&&r.length>0?r:void 0}catch{return}},"whichCommand"),Be=f(e=>{const r=M();if(T){const a=process.env.APPDATA??"",t=process.env.LOCALAPPDATA??"",n=process.env.ProgramFiles??"";return[g(a,"npm",`${e}.cmd`),g(a,"npm",e),g(t,"Programs",e,`${e}.exe`),g(n,e,`${e}.exe`),g(r,".npm-global","bin",`${e}.cmd`)]}return[`/opt/homebrew/bin/${e}`,`/usr/local/bin/${e}`,g(r,".npm-global","bin",e),g(r,".local","bin",e),g(r,".cargo","bin",e)]},"getKnownPaths"),S=f(e=>{try{const r=E(e,["--version"],{encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:re}),a=Z.exec(r);return a?a[1]:void 0}catch{return}},"detectVersion"),_=f(e=>{const r=I[e],a={available:!1,name:e},t=process.env[r.envVariable];if(t&&j(O(t))){const i=O(t);return{...a,available:!0,detectionMethod:"envvar",path:i,version:S(i)}}const n=[r.command,...r.alternateCommands];for(const i of n){const o=Fe(i);if(o)return{...a,available:!0,detectionMethod:"which",path:o,version:S(o)}}for(const i of n)for(const o of Be(i))if(j(o))return{...a,available:!0,detectionMethod:"known-path",path:o,version:S(o)};return a},"detectProvider"),De=f(()=>x.map(e=>_(e)),"detectAllProviders"),Je=f(()=>De().filter(e=>e.available),"detectAvailableProviders"),ze=f((e,r,a={})=>{const t=I[e],n=a.model??t.defaultModel,i=a.maxTokens!==void 0&&Number.isFinite(a.maxTokens)?a.maxTokens:ae;return t.buildArgs(r,n,i)},"buildCliArgs"),Ue=f(async(e,r,a={})=>{if(!e.available||!e.path)throw new Error(`AI provider "${e.name}" is not available.`);const t=ze(e.name,r,a),n=a.timeoutMs!==void 0&&Number.isFinite(a.timeoutMs)?a.timeoutMs:te;return new Promise((i,o)=>{const p={env:{...process.env,FORCE_COLOR:"0",NO_COLOR:"1"},stdio:["pipe","pipe","pipe"]},s=J(e.path,t,p);s.stdin.end();let c="",d="",u=!1,y;const C=setTimeout(()=>{u=!0,s.kill("SIGTERM"),y=setTimeout(()=>s.kill("SIGKILL"),5e3),o(new Error(`${e.name} CLI timed out after ${String(n)}ms`))},n);s.stdout.on("data",h=>{c+=h.toString("utf8")}),s.stderr.on("data",h=>{d+=h.toString("utf8")}),s.on("close",h=>{clearTimeout(C),clearTimeout(y),!u&&(h===0?i({provider:e.name,stderr:d,stdout:c}):o(new Error(`${e.name} CLI exited with code ${String(h)}: ${d||c}`)))}),s.on("error",h=>{clearTimeout(C),clearTimeout(y),u||o(new Error(`Failed to spawn ${e.name} CLI: ${h.message}`))})})},"runProvider");var We=Object.defineProperty,N=k((e,r)=>We(e,"name",{value:r,configurable:!0}),"i");const Ke=12e4,Ge=2,Ye=1e3,Xe=N(e=>new Promise(r=>{setTimeout(r,e)}),"sleep"),L=N(async(e,r,a=Ge)=>{let t;for(let n=0;n<=a;n+=1)try{return(await Ue(e,r,{timeoutMs:Ke})).stdout}catch(i){if(t=i instanceof Error?i:new Error(String(i)),t.message.includes("timed out"))throw t;if(n<a){const o=Ye*2**n;await Xe(o)}}throw t??new Error("AI request failed after retries")},"runWithRetry");var Qe=Object.defineProperty,l=k((e,r)=>Qe(e,"name",{value:r,configurable:!0}),"c");const Ze={amp:30,claude:80,codex:60,copilot:50,crush:35,cursor:40,droid:20,gemini:100,kimi:25,opencode:35,qwen:30},er=l(e=>{if(e?.provider){if(!x.includes(e.provider))return;const t=_(e.provider);return t.available?t:void 0}const r=Je();if(r.length===0)return;const a={...Ze,...e?.priority};return r.toSorted((t,n)=>(a[n.name]??0)-(a[t.name]??0))[0]},"resolveProvider"),rr=new Set(["defer","review","skip","update"]),tr=new Set(["critical","high","low","medium"]),ar=new Set(["high","low","medium"]),nr=50,P=30,ir=l(e=>e.map(r=>{const a=r.vulnerabilities&&r.vulnerabilities.length>0?` [VULNERABILITIES: ${r.vulnerabilities.map(n=>`${n.severity} ${n.id}`).join(", ")}]`:"";let t="";if(r.socketReport){const n=Math.round(r.socketReport.score.overall*100),i=[`score:${String(n)}%`];if(r.socketReport.alerts.length>0){const o={};for(const s of r.socketReport.alerts)o[s.severity]=(o[s.severity]??0)+1;const p=Object.entries(o).map(([s,c])=>`${String(c)} ${s}`).join(", ");i.push(`alerts: ${p}`)}i.push(`supply-chain:${String(Math.round(r.socketReport.score.supplyChain*100))}%`),i.push(`quality:${String(Math.round(r.socketReport.score.quality*100))}%`),t=` [SOCKET.DEV: ${i.join(", ")}]`}return`- ${r.packageName}: ${r.currentRange} → ${r.newRange} (${r.updateType})${a}${t}`}).join(`
3
+ `),"buildPackageList"),A=`Respond ONLY with valid JSON in this exact structure:
4
+ {
5
+ "summary": "Brief overall summary",
6
+ "recommendations": [
7
+ {
8
+ "package": "package-name",
9
+ "action": "update|skip|review|defer",
10
+ "reason": "explanation",
11
+ "riskLevel": "low|medium|high|critical",
12
+ "breakingChanges": ["change1"],
13
+ "effort": "low|medium|high"
14
+ }
15
+ ],
16
+ "warnings": ["warning1"]
17
+ }`,or={compatibility:l(e=>`Analyze the compatibility of these package updates:
18
+
19
+ ${e}
20
+
21
+ For each package:
22
+ 1. Check peer dependency compatibility
23
+ 2. Identify potential conflicts with other packages in the list
24
+ 3. Assess API compatibility between current and target versions
25
+ 4. Check for deprecated features being removed
26
+ 5. Evaluate Node.js version requirements
27
+
28
+ ${A}`,"compatibility"),impact:l(e=>`Analyze the impact of updating these npm packages:
29
+
30
+ ${e}
31
+
32
+ For each package, provide:
33
+ 1. Risk level (low/medium/high/critical)
34
+ 2. Recommended action (update/skip/review/defer)
35
+ 3. Reason for recommendation
36
+ 4. Known breaking changes (if any)
37
+ 5. Estimated migration effort (low/medium/high)
38
+
39
+ ${A}`,"impact"),recommend:l(e=>`Provide smart recommendations for updating these packages:
40
+
41
+ ${e}
42
+
43
+ Consider:
44
+ 1. Update priority based on security, features, and stability
45
+ 2. Grouping related packages for atomic updates
46
+ 3. Best practices for the specific package ecosystem
47
+ 4. Risk vs. benefit analysis
48
+ 5. Suggested update order
49
+ 6. If Socket.dev scores are provided, prioritize packages with low supply chain or quality scores
50
+
51
+ ${A}`,"recommend"),security:l(e=>`Analyze the security implications of these package updates:
52
+
53
+ ${e}
54
+
55
+ For each package:
56
+ 1. Check if the update fixes known vulnerabilities (use the vulnerability data above)
57
+ 2. Assess if the new version introduces security risks
58
+ 3. Evaluate if this is a security-sensitive package (auth, crypto, session, etc.)
59
+ 4. Recommend urgency of the update based on vulnerability severity
60
+ 5. Flag any packages where skipping the update poses security risk
61
+ 6. If Socket.dev scores are provided, factor in supply chain and quality scores — low scores indicate higher risk
62
+
63
+ ${A}`,"security")},sr=new Set(["compatibility","impact","recommend","security"]),br=l(e=>sr.has(e)?e:"impact","validateAnalysisType"),q=l((e,r="impact")=>{const a=ir(e);return or[r](a)},"buildAnalysisPrompt"),cr=/```(?:json)?\s*([\s\S]*?)```/,lr=/\{[\s\S]*\}/,ur=l(e=>{try{return JSON.parse(e)}catch{}const r=cr.exec(e);if(r?.[1])try{return JSON.parse(r[1])}catch{}const a=lr.exec(e);if(a?.[0])try{return JSON.parse(a[0])}catch{}},"extractJson"),dr=l(e=>({action:rr.has(e.action)?e.action:"review",breakingChanges:Array.isArray(e.breakingChanges)?e.breakingChanges:[],effort:ar.has(e.effort)?e.effort:"medium",package:typeof e.package=="string"?e.package:"",reason:typeof e.reason=="string"?e.reason:"",riskLevel:tr.has(e.riskLevel)?e.riskLevel:"medium"}),"normalizeRecommendation"),V=l((e,r,a)=>{const t=ur(e);if(!t||typeof t!="object")return{analysisType:a,provider:r,recommendations:[],summary:"Failed to parse AI response.",warnings:["AI response was not valid JSON."]};const n=t,i=Array.isArray(n.recommendations)?n.recommendations:[];return{analysisType:a,provider:r,recommendations:i.map(o=>dr(o)),summary:typeof n.summary=="string"?n.summary:"",warnings:Array.isArray(n.warnings)?n.warnings:[]}},"parseAiResponse"),mr={eslint:["ESLint 9.0: Flat config required","ESLint 8.0+: New rule formats"],next:["Next.js 13+: App router changes","Next.js 14+: Server components default"],react:["React 17 to 18: Concurrent features","React 18+: Strict mode changes"],typescript:["TypeScript 5.0: New decorators","TypeScript 4.7+: ESM changes"],vite:["Vite 5: Node.js 18+ required"],vue:["Vue 3: Composition API","Vue 3: Breaking template changes"],webpack:["Webpack 5: Node.js polyfills removed"]},pr=new Set(["bcrypt","cors","crypto-js","express-session","helmet","jose","jsonwebtoken","node-forge","oauth","passport"]),R=l((e,r)=>{const a=e.map(t=>{const n=t.vulnerabilities&&t.vulnerabilities.length>0,i=pr.has(t.packageName),o=mr[t.packageName]??[];let p="low",s="update",c="low",d="Patch/minor update, safe to apply.";return t.updateType==="major"?(p="high",s=o.length>0?"review":"update",c="medium",d=o.length>0?`Major update with known breaking changes: ${o[0]}`:"Major version update, review changelog before applying."):t.updateType==="minor"&&(p="medium",d="Minor update, generally safe."),n&&(p="high",s="update",d="Security update — current version has known vulnerabilities."),i&&t.updateType==="major"&&(s="review",d="Security-sensitive package with major update, careful review needed.",c="high"),{action:s,breakingChanges:o,effort:c,package:t.packageName,reason:d,riskLevel:p}});return{analysisType:r,provider:"rule-engine",recommendations:a,summary:`Rule-based ${r} analysis for ${String(e.length)} packages.`,warnings:["No AI provider available — using built-in rule engine."]}},"ruleBasedAnalysis"),gr=l(async(e,r,a)=>{const t=q(r,a),n=await L(e,t);return V(n,e.name,a)},"analyzeChunk"),fr=l((e,r,a)=>{const t=[],n=[],i=[];for(const o of e)t.push(...o.recommendations),n.push(...o.warnings),o.summary&&i.push(o.summary);return{analysisType:a,provider:r,recommendations:t,summary:i.length===1?i[0]??"":`Analyzed ${String(t.length)} packages in ${String(e.length)} batches.`,warnings:[...new Set(n)]}},"mergeResults"),H={compatibility:"Compatibility",impact:"Impact",recommend:"Recommendations",security:"Security"},kr=l(e=>{const r=`${H[e.analysisType]??e.analysisType} Analysis (${e.provider})`,a=e.recommendations.flatMap(n=>{const i=[{action:n.action,effort:n.effort,package:n.package,reason:n.reason,risk:n.riskLevel}];return n.breakingChanges.length>0&&i.push({action:"",effort:"",package:"",reason:`Breaking: ${n.breakingChanges.join("; ")}`,risk:""}),i}),t=process.stdout.columns||80;return U(v.createElement(W,{borderStyle:"round",flexDirection:"column",paddingLeft:1,paddingRight:1},v.createElement(b,{bold:!0},r),v.createElement(b,null,""),v.createElement(b,null,e.summary),v.createElement(b,null,""),v.createElement(K,{borderStyle:"none",data:a}),...e.warnings.length>0?[v.createElement(b,null,""),...e.warnings.map((n,i)=>v.createElement(b,{dimColor:!0,key:String(i)},` ${n}`))]:[]),{columns:t})},"formatAiAnalysis");l(e=>JSON.stringify(e,void 0,2),"formatAiAnalysisJson");const wr=l(async(e,r,a,t="impact")=>{const n=er(a);if(!n)return r.info(`No AI CLI tool found, using rule-based analysis.
64
+ `),R(e,t);const i=G(n.name,t,e),o=Y(i);if(o)return r.info(`Using cached ${t} analysis from ${o.provider}.
65
+ `),o;const p=H[t]??t;r.info(`Running ${p.toLowerCase()} analysis with ${n.name}...
66
+ `);try{let s;if(e.length>nr){r.info(`Splitting ${String(e.length)} packages into batches of ${String(P)}...
67
+ `);const c=[];for(let u=0;u<e.length;u+=P)c.push(e.slice(u,u+P));const d=[];for(let u=0;u<c.length;u+=1){r.info(` Batch ${String(u+1)}/${String(c.length)}...`);const y=c[u];y&&d.push(await gr(n,y,t))}s=fr(d,n.name,t)}else{const c=await L(n,q(e,t));s=V(c,n.name,t)}return X(i,s,Q(t,a?.cacheTtl)),s}catch(s){const c=s instanceof Error?s.message:String(s);return r.warn(`AI analysis failed (${c}), falling back to rule engine.
68
+ `),R(e,t)}},"runAiAnalysis");export{br as H,Ze as R,kr as Z,De as _,er as b,wr as e,Ue as h,L as r,ur as w};