@visulima/vis 3.0.1 → 3.0.3

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 (90) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE.md +33 -22
  3. package/dashboard/dist/index.html +12 -12
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +1 -1
  6. package/dist/packem_chunks/CONFIG_FILES.js +1 -1
  7. package/dist/packem_chunks/bloom-status.js +1 -1
  8. package/dist/packem_chunks/bloom-sync.js +1 -1
  9. package/dist/packem_chunks/catalog.js +2 -2
  10. package/dist/packem_chunks/cli-exec.js +1 -1
  11. package/dist/packem_chunks/cli-main.js +168 -170
  12. package/dist/packem_chunks/doctor-probe.js +2 -2
  13. package/dist/packem_chunks/fix.js +5 -5
  14. package/dist/packem_chunks/handler13.js +1 -1
  15. package/dist/packem_chunks/handler14.js +1 -1
  16. package/dist/packem_chunks/handler15.js +1 -1
  17. package/dist/packem_chunks/handler19.js +1 -1
  18. package/dist/packem_chunks/handler2.js +1 -1
  19. package/dist/packem_chunks/handler20.js +1 -1
  20. package/dist/packem_chunks/handler21.js +1 -1
  21. package/dist/packem_chunks/handler23.js +1 -1
  22. package/dist/packem_chunks/handler24.js +1 -1
  23. package/dist/packem_chunks/handler26.js +1 -1
  24. package/dist/packem_chunks/handler28.js +1 -1
  25. package/dist/packem_chunks/handler3.js +1 -1
  26. package/dist/packem_chunks/handler50.js +4 -4
  27. package/dist/packem_chunks/handler53.js +1 -1
  28. package/dist/packem_chunks/handler54.js +1 -1
  29. package/dist/packem_chunks/handler55.js +1 -1
  30. package/dist/packem_chunks/handler58.js +1 -1
  31. package/dist/packem_chunks/handler59.js +1 -1
  32. package/dist/packem_chunks/handler6.js +5 -5
  33. package/dist/packem_chunks/handler60.js +1 -1
  34. package/dist/packem_chunks/handler61.js +7 -7
  35. package/dist/packem_chunks/handler62.js +1 -1
  36. package/dist/packem_chunks/handler63.js +1 -1
  37. package/dist/packem_chunks/handler64.js +2 -2
  38. package/dist/packem_chunks/handler65.js +2 -2
  39. package/dist/packem_chunks/handler66.js +1 -1
  40. package/dist/packem_chunks/handler67.js +25 -24
  41. package/dist/packem_chunks/handler68.js +153 -25
  42. package/dist/packem_chunks/handler69.js +10 -153
  43. package/dist/packem_chunks/handler70.js +22 -10
  44. package/dist/packem_chunks/handler71.js +4 -4
  45. package/dist/packem_chunks/handler72.js +3 -3
  46. package/dist/packem_chunks/handler73.js +6 -6
  47. package/dist/packem_chunks/handler74.js +1 -1
  48. package/dist/packem_chunks/handler75.js +1 -1
  49. package/dist/packem_chunks/handler76.js +1 -1
  50. package/dist/packem_chunks/handler77.js +40 -40
  51. package/dist/packem_chunks/handler78.js +20 -20
  52. package/dist/packem_chunks/heal.js +4 -4
  53. package/dist/packem_chunks/help-command.js +5 -5
  54. package/dist/packem_chunks/index4.js +6 -8
  55. package/dist/packem_chunks/index6.js +5 -5
  56. package/dist/packem_chunks/list.js +1 -1
  57. package/dist/packem_chunks/prompts.js +1 -1
  58. package/dist/packem_chunks/prune.js +1 -1
  59. package/dist/packem_chunks/run.js +1 -1
  60. package/dist/packem_chunks/shell-runner.js +1 -1
  61. package/dist/packem_chunks/status.js +1 -1
  62. package/dist/packem_chunks/sync.js +1 -1
  63. package/dist/packem_chunks/tar.js +3 -3
  64. package/dist/packem_shared/{advisories-CyDqzi5j.js → advisories-0ScpWAHV.js} +1 -1
  65. package/dist/packem_shared/{affected-selection-DPQR-Bd3.js → affected-selection-BMoQWuHl.js} +1 -1
  66. package/dist/packem_shared/{ai-fix-6nXZbecQ.js → ai-fix-CKN1JGRh.js} +1 -1
  67. package/dist/packem_shared/{bin-wafzkjaB.js → bin-CN4heKmb.js} +1 -1
  68. package/dist/packem_shared/{cyclonedx-C_ezHg8b.js → cyclonedx-B1vzerwP.js} +1 -1
  69. package/dist/packem_shared/{docker-Br_iFmI-.js → docker-Bex05Qcn.js} +16 -16
  70. package/dist/packem_shared/giget-D8Kwb0kD.js +2 -0
  71. package/dist/packem_shared/index.server-BAjDJSEu.js +2 -0
  72. package/dist/packem_shared/main-BP-w-K-6.js +1 -0
  73. package/dist/packem_shared/{osv-bloom-5wDAoZ1e.js → osv-bloom-JYIWcH3F.js} +1 -1
  74. package/dist/packem_shared/{package-version-BJkg7-6H.js → package-version-CJxZ_B7G.js} +3 -3
  75. package/dist/packem_shared/{project-name-filter-BeREbPMI.js → project-name-filter-DsrVo0MY.js} +1 -1
  76. package/dist/packem_shared/{resolve-explicit-COmP7eqr.js → resolve-explicit-DYaHAVDg.js} +1 -1
  77. package/dist/packem_shared/{s1ngularity-RZOHbGrE.js → s1ngularity-C8sva2SO.js} +1 -1
  78. package/dist/packem_shared/{scan-progress-C9nMDLis.js → scan-progress-5uTRdC1G.js} +2 -2
  79. package/dist/packem_shared/{spinner-CbJfWYwB.js → spinner-BM_0Bj6x.js} +1 -1
  80. package/dist/packem_shared/{tabs-BilwonkM.js → tabs-UDYQ3tqt.js} +1 -1
  81. package/dist/packem_shared/target-merge-B4No-LHM.js +4 -0
  82. package/dist/packem_shared/{typosquats-D8ppc5kr.js → typosquats-Cdsnf6aN.js} +1 -1
  83. package/dist/packem_shared/{vis-update-app-ngwL2mRv.js → vis-update-app-zqSa2clT.js} +1 -1
  84. package/dist/packem_shared/{vis-user-error-jhNwmkZp.js → vis-user-error-Dkc97rGY.js} +1 -1
  85. package/index.js +26 -26
  86. package/package.json +14 -14
  87. package/dist/packem_shared/giget-CVyyR7x8.js +0 -2
  88. package/dist/packem_shared/index.server-CwSgbeN7.js +0 -2
  89. package/dist/packem_shared/main-BjJN8kWj.js +0 -1
  90. package/dist/packem_shared/target-merge-D1xbylFw.js +0 -4
@@ -1,3 +1,3 @@
1
- import{createRequire as nr}from"node:module";import{_ as lr}from"../packem_shared/giget-CVyyR7x8.js";let ar;const or=t=>(ar??=nr(import.meta.url))(t),Ft=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=t=>{if(typeof Ft<"u"&&Ft.versions&&Ft.versions.node){const[e,i]=Ft.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return Ft.getBuiltinModule(t)}return or(t)},d=D("node:fs"),dr=D("node:fs/promises"),Ls=D("node:stream"),c=D("node:path"),{posix:_t,basename:ur,win32:fr,join:As}=c,Ds=D("events"),{EventEmitter:cr}=Ds,p=D("fs"),{EventEmitter:Ci}=D("node:events"),{StringDecoder:mr}=D("node:string_decoder"),se=D("path"),{parse:pr,dirname:vr}=se,mi=D("assert"),{Buffer:bt}=D("buffer"),Vi=D("zlib"),Ki={...Vi,default:Vi},yr=D("zlib"),br=D("node:assert"),{randomBytes:xs}=D("node:crypto");var en=lr({Header:()=>ot,Pack:()=>ne,PackJob:()=>ki,PackSync:()=>Ue,Parser:()=>xt,Pax:()=>re,ReadEntry:()=>Hs,Unpack:()=>Fe,UnpackSync:()=>Mi,WriteEntry:()=>Gi,WriteEntrySync:()=>Gs,WriteEntryTar:()=>$s,c:()=>ps,create:()=>ps,extract:()=>Ts,filesFilter:()=>Hi,list:()=>Bt,r:()=>yt,replace:()=>yt,t:()=>Bt,types:()=>zs,x:()=>Ts}),gr=Object.defineProperty,Er=(t,e)=>{for(var i in e)gr(t,i,{get:e[i],enumerable:!0})},Xi=process||{stdout:null,stderr:null},wr=t=>!!t&&typeof t=="object"&&(t instanceof wt||t instanceof Ls||_r(t)||Rr(t)),_r=t=>!!t&&typeof t=="object"&&t instanceof Ci&&typeof t.pipe=="function"&&t.pipe!==Ls.Writable.prototype.pipe,Rr=t=>!!t&&typeof t=="object"&&t instanceof Ci&&typeof t.write=="function"&&typeof t.end=="function",W=Symbol("EOF"),G=Symbol("maybeEmitEnd"),X=Symbol("emittedEnd"),ae=Symbol("emittingEnd"),Mt=Symbol("emittedError"),oe=Symbol("closed"),qi=Symbol("read"),le=Symbol("flush"),Qi=Symbol("flushChunk"),B=Symbol("encoding"),Rt=Symbol("decoder"),_=Symbol("flowing"),Ct=Symbol("paused"),Tt=Symbol("resume"),R=Symbol("buffer"),A=Symbol("pipes"),S=Symbol("bufferLength"),He=Symbol("bufferPush"),de=Symbol("bufferShift"),L=Symbol("objectMode"),g=Symbol("destroyed"),Ze=Symbol("error"),We=Symbol("emitData"),Ji=Symbol("emitEnd"),Ge=Symbol("emitEnd2"),z=Symbol("async"),$e=Symbol("abort"),ue=Symbol("aborted"),Pt=Symbol("signal"),lt=Symbol("dataListeners"),x=Symbol("discarded"),zt=t=>Promise.resolve().then(t),Sr=t=>t(),Or=t=>t==="end"||t==="finish"||t==="prefinish",kr=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Tr=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Ns=class{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[Tt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Lr=class extends Ns{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=s=>this.dest.emit("error",s),t.on("error",this.proxyErrors)}},Ar=t=>!!t.objectMode,Dr=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",wt=class extends Ci{[_]=!1;[Ct]=!1;[A]=[];[R]=[];[L];[B];[z];[Rt];[W]=!1;[X]=!1;[ae]=!1;[oe]=!1;[Mt]=null;[S]=0;[g]=!1;[Pt];[ue]=!1;[lt]=0;[x]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw TypeError("Encoding and objectMode may not be used together");Ar(e)?(this[L]=!0,this[B]=null):Dr(e)?(this[B]=e.encoding,this[L]=!1):(this[L]=!1,this[B]=null),this[z]=!!e.async,this[Rt]=this[B]?new mr(this[B]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[R]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[A]});let{signal:i}=e;i&&(this[Pt]=i,i.aborted?this[$e]():i.addEventListener("abort",()=>this[$e]()))}get bufferLength(){return this[S]}get encoding(){return this[B]}set encoding(t){throw Error("Encoding must be set at instantiation time")}setEncoding(t){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[L]}set objectMode(t){throw Error("objectMode must be set at instantiation time")}get async(){return this[z]}set async(t){this[z]=this[z]||!!t}[$e](){this[ue]=!0,this.emit("abort",this[Pt]?.reason),this.destroy(this[Pt]?.reason)}get aborted(){return this[ue]}set aborted(t){}write(t,e,i){if(this[ue])return!1;if(this[W])throw Error("write after end");if(this[g])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(i=e,e="utf8"),e||="utf8";let s=this[z]?zt:Sr;if(!this[L]&&!Buffer.isBuffer(t)){if(Tr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(kr(t))t=Buffer.from(t);else if(typeof t!="string")throw Error("Non-contiguous data written to non-objectMode stream")}return this[L]?(this[_]&&this[S]!==0&&this[le](!0),this[_]?this.emit("data",t):this[He](t),this[S]!==0&&this.emit("readable"),i&&s(i),this[_]):t.length?(typeof t=="string"&&!(e===this[B]&&!this[Rt]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[B]&&(t=this[Rt].write(t)),this[_]&&this[S]!==0&&this[le](!0),this[_]?this.emit("data",t):this[He](t),this[S]!==0&&this.emit("readable"),i&&s(i),this[_]):(this[S]!==0&&this.emit("readable"),i&&s(i),this[_])}read(t){if(this[g])return null;if(this[x]=!1,this[S]===0||t===0||t&&t>this[S])return this[G](),null;this[L]&&(t=null),this[R].length>1&&!this[L]&&(this[R]=[this[B]?this[R].join(""):Buffer.concat(this[R],this[S])]);let e=this[qi](t||null,this[R][0]);return this[G](),e}[qi](t,e){if(this[L])this[de]();else{let i=e;t===i.length||t===null?this[de]():typeof i=="string"?(this[R][0]=i.slice(t),e=i.slice(0,t),this[S]-=t):(this[R][0]=i.subarray(t),e=i.subarray(0,t),this[S]-=t)}return this.emit("data",e),!this[R].length&&!this[W]&&this.emit("drain"),e}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e="utf8"),t!==void 0&&this.write(t,e),i&&this.once("end",i),this[W]=!0,this.writable=!1,(this[_]||!this[Ct])&&this[G](),this}[Tt](){this[g]||(!this[lt]&&!this[A].length&&(this[x]=!0),this[Ct]=!1,this[_]=!0,this.emit("resume"),this[R].length?this[le]():this[W]?this[G]():this.emit("drain"))}resume(){return this[Tt]()}pause(){this[_]=!1,this[Ct]=!0,this[x]=!1}get destroyed(){return this[g]}get flowing(){return this[_]}get paused(){return this[Ct]}[He](t){this[L]?this[S]+=1:this[S]+=t.length,this[R].push(t)}[de](){return this[L]?--this[S]:this[S]-=this[R][0].length,this[R].shift()}[le](t=!1){do;while(this[Qi](this[de]())&&this[R].length);!t&&!this[R].length&&!this[W]&&this.emit("drain")}[Qi](t){return this.emit("data",t),this[_]}pipe(t,e){if(this[g])return t;this[x]=!1;let i=this[X];return e||={},t===Xi.stdout||t===Xi.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[A].push(e.proxyErrors?new Lr(this,t,e):new Ns(this,t,e)),this[z]?zt(()=>this[Tt]()):this[Tt]()),t}unpipe(t){let e=this[A].find(i=>i.dest===t);e&&(this[A].length===1?(this[_]&&this[lt]===0&&(this[_]=!1),this[A]=[]):this[A].splice(this[A].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let i=super.on(t,e);if(t==="data")this[x]=!1,this[lt]++,!this[A].length&&!this[_]&&this[Tt]();else if(t==="readable"&&this[S]!==0)super.emit("readable");else if(Or(t)&&this[X])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Mt]){let s=e;this[z]?zt(()=>s.call(this,this[Mt])):s.call(this,this[Mt])}return i}removeListener(t,e){return this.off(t,e)}off(t,e){let i=super.off(t,e);return t==="data"&&(this[lt]=this.listeners("data").length,this[lt]===0&&!this[x]&&!this[A].length&&(this[_]=!1)),i}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[lt]=0,!this[x]&&!this[A].length&&(this[_]=!1)),e}get emittedEnd(){return this[X]}[G](){!this[ae]&&!this[X]&&!this[g]&&this[R].length===0&&this[W]&&(this[ae]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[oe]&&this.emit("close"),this[ae]=!1)}emit(t,...e){let i=e[0];if(t!=="error"&&t!=="close"&&t!==g&&this[g])return!1;if(t==="data")return!this[L]&&!i?!1:this[z]?(zt(()=>this[We](i)),!0):this[We](i);if(t==="end")return this[Ji]();if(t==="close"){if(this[oe]=!0,!this[X]&&!this[g])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[Mt]=i,super.emit(Ze,i);let r=!this[Pt]||this.listeners("error").length?super.emit("error",i):!1;return this[G](),r}else if(t==="resume"){let r=super.emit("resume");return this[G](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let s=super.emit(t,...e);return this[G](),s}[We](t){for(let i of this[A])i.dest.write(t)===!1&&this.pause();let e=this[x]?!1:super.emit("data",t);return this[G](),e}[Ji](){return this[X]?!1:(this[X]=!0,this.readable=!1,this[z]?(zt(()=>this[Ge]()),!0):this[Ge]())}[Ge](){if(this[Rt]){let e=this[Rt].end();if(e){for(let i of this[A])i.dest.write(e);this[x]||super.emit("data",e)}}for(let e of this[A])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[L]||(t.dataLength=0);let e=this.promise();return this.on("data",i=>{t.push(i),this[L]||(t.dataLength+=i.length)}),await e,t}async concat(){if(this[L])throw Error("cannot concat in objectMode");let t=await this.collect();return this[B]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(g,()=>e(Error("stream destroyed"))),this.on("error",i=>e(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[x]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[W])return e();let s,r,h=l=>{this.off("data",n),this.off("end",a),this.off(g,o),e(),r(l)},n=l=>{this.off("error",h),this.off("end",a),this.off(g,o),this.pause(),s({value:l,done:!!this[W]})},a=()=>{this.off("error",h),this.off("data",n),this.off(g,o),e(),s({done:!0,value:void 0})},o=()=>h(Error("stream destroyed"));return new Promise((l,f)=>{r=f,s=l,this.once(g,o),this.once("error",h),this.once("end",a),this.once("data",n)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[x]=!1;let t=!1,e=()=>(this.pause(),this.off(Ze,e),this.off(g,e),this.off("end",e),t=!0,{done:!0,value:void 0});return this.once("end",e),this.once(Ze,e),this.once(g,e),{next:()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}},throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[g])return t?this.emit("error",t):this.emit(g),this;this[g]=!0,this[x]=!0,this[R].length=0,this[S]=0;let e=this;return typeof e.close=="function"&&!this[oe]&&e.close(),t?this.emit("error",t):this.emit(g),this}static get isStream(){return wr}},xr=p.writev,nt=Symbol("_autoClose"),P=Symbol("_close"),Ut=Symbol("_ended"),m=Symbol("_fd"),Ye=Symbol("_finished"),K=Symbol("_flags"),Ve=Symbol("_flush"),pi=Symbol("_handleChunk"),vi=Symbol("_makeBuf"),Xt=Symbol("_mode"),fe=Symbol("_needDrain"),Nt=Symbol("_onerror"),It=Symbol("_onopen"),Ke=Symbol("_onread"),Lt=Symbol("_onwrite"),at=Symbol("_open"),C=Symbol("_path"),et=Symbol("_pos"),U=Symbol("_queue"),At=Symbol("_read"),Xe=Symbol("_readSize"),V=Symbol("_reading"),jt=Symbol("_remain"),qe=Symbol("_size"),_e=Symbol("_write"),dt=Symbol("_writing"),Re=Symbol("_defaultFlag"),gt=Symbol("_errored"),Pi=class extends wt{[gt]=!1;[m];[C];[Xe];[V]=!1;[qe];[jt];[nt];constructor(t,e){if(e||={},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw TypeError("path must be a string");this[gt]=!1,this[m]=typeof e.fd=="number"?e.fd:void 0,this[C]=t,this[Xe]=e.readSize||16*1024*1024,this[V]=!1,this[qe]=typeof e.size=="number"?e.size:1/0,this[jt]=this[qe],this[nt]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[m]=="number"?this[At]():this[at]()}get fd(){return this[m]}get path(){return this[C]}write(){throw TypeError("this is a readable stream")}end(){throw TypeError("this is a readable stream")}[at](){p.open(this[C],"r",(t,e)=>this[It](t,e))}[It](t,e){t?this[Nt](t):(this[m]=e,this.emit("open",e),this[At]())}[vi](){return Buffer.allocUnsafe(Math.min(this[Xe],this[jt]))}[At](){if(!this[V]){this[V]=!0;let t=this[vi]();if(t.length===0)return process.nextTick(()=>this[Ke](null,0,t));p.read(this[m],t,0,t.length,null,(e,i,s)=>this[Ke](e,i,s))}}[Ke](t,e,i){this[V]=!1,t?this[Nt](t):this[pi](e,i)&&this[At]()}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Nt](t){this[V]=!0,this[P](),this.emit("error",t)}[pi](t,e){let i=!1;return this[jt]-=t,t>0&&(i=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[jt]<=0)&&(i=!1,this[P](),super.end()),i}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[m]=="number"&&this[At](),!1;case"error":return this[gt]?!1:(this[gt]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Nr=class extends Pi{[at](){let t=!0;try{this[It](null,p.openSync(this[C],"r")),t=!1}finally{t&&this[P]()}}[At](){let t=!0;try{if(!this[V]){this[V]=!0;do{let e=this[vi](),i=e.length===0?0:p.readSync(this[m],e,0,e.length,null);if(!this[pi](i,e))break}while(!0);this[V]=!1}t=!1}finally{t&&this[P]()}}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.closeSync(t),this.emit("close")}}},Me=class extends Ds{readable=!1;writable=!0;[gt]=!1;[dt]=!1;[Ut]=!1;[U]=[];[fe]=!1;[C];[Xt];[nt];[m];[Re];[K];[Ye]=!1;[et];constructor(t,e){e||={},super(e),this[C]=t,this[m]=typeof e.fd=="number"?e.fd:void 0,this[Xt]=e.mode===void 0?438:e.mode,this[et]=typeof e.start=="number"?e.start:void 0,this[nt]=typeof e.autoClose=="boolean"?e.autoClose:!0;let i=this[et]===void 0?"w":"r+";this[Re]=e.flags===void 0,this[K]=e.flags===void 0?i:e.flags,this[m]===void 0&&this[at]()}emit(t,...e){if(t==="error"){if(this[gt])return!1;this[gt]=!0}return super.emit(t,...e)}get fd(){return this[m]}get path(){return this[C]}[Nt](t){this[P](),this[dt]=!0,this.emit("error",t)}[at](){p.open(this[C],this[K],this[Xt],(t,e)=>this[It](t,e))}[It](t,e){this[Re]&&this[K]==="r+"&&t&&t.code==="ENOENT"?(this[K]="w",this[at]()):t?this[Nt](t):(this[m]=e,this.emit("open",e),this[dt]||this[Ve]())}end(t,e){return t&&this.write(t,e),this[Ut]=!0,!this[dt]&&!this[U].length&&typeof this[m]=="number"&&this[Lt](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[Ut]?(this.emit("error",Error("write() after end()")),!1):this[m]===void 0||this[dt]||this[U].length?(this[U].push(t),this[fe]=!0,!1):(this[dt]=!0,this[_e](t),!0)}[_e](t){p.write(this[m],t,0,t.length,this[et],(e,i)=>this[Lt](e,i))}[Lt](t,e){t?this[Nt](t):(this[et]!==void 0&&typeof e=="number"&&(this[et]+=e),this[U].length?this[Ve]():(this[dt]=!1,this[Ut]&&!this[Ye]?(this[Ye]=!0,this[P](),this.emit("finish")):this[fe]&&(this[fe]=!1,this.emit("drain"))))}[Ve](){if(this[U].length===0)this[Ut]&&this[Lt](null,0);else if(this[U].length===1)this[_e](this[U].pop());else{let t=this[U];this[U]=[],xr(this[m],t,this[et],(e,i)=>this[Lt](e,i))}}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Is=class extends Me{[at](){let t;if(this[Re]&&this[K]==="r+")try{t=p.openSync(this[C],this[K],this[Xt])}catch(e){if(e?.code==="ENOENT")return this[K]="w",this[at]();throw e}else t=p.openSync(this[C],this[K],this[Xt]);this[It](null,t)}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.closeSync(t),this.emit("close")}}[_e](t){let e=!0;try{this[Lt](null,p.writeSync(this[m],t,0,t.length,this[et])),e=!1}finally{if(e)try{this[P]()}catch{}}}},Ir=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"]]),Br=t=>!!t.sync&&!!t.file,Fr=t=>!t.sync&&!!t.file,Mr=t=>!!t.sync&&!t.file,Cr=t=>!t.sync&&!t.file,Pr=t=>!!t.file,zr=t=>Ir.get(t)||t,zi=(t={})=>{if(!t)return{};let e={};for(let[i,s]of Object.entries(t)){let r=zr(i);e[r]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},he=(t,e,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 o=zi(h);if(r?.(o,n),Br(o)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return t(o,n)}else if(Fr(o)){let l=e(o,n);return a?l.then(()=>a(),a):l}else if(Mr(o)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return i(o,n)}else if(Cr(o)){if(typeof a=="function")throw TypeError("callback only supported with file option");return s(o,n)}throw Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:i,asyncNoFile:s,validate:r}),Ur=yr.constants||{ZLIB_VERNUM:4736},Z=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},Ur)),jr=bt.concat,ts=Object.getOwnPropertyDescriptor(bt,"concat"),Hr=t=>t,Qe=ts?.writable===!0||ts?.set!==void 0?t=>{bt.concat=t?Hr:jr}:t=>{},Et=Symbol("_superWrite"),ce=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||="ZLIB_ERROR",this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},Je=Symbol("flushFlag"),Ui=class extends wt{#t=!1;#i=!1;#s;#h;#r;#e;#n;get sawError(){return this.#t}get handle(){return this.#e}get flushFlag(){return this.#s}constructor(t,e){if(!t||typeof t!="object")throw TypeError("invalid options for ZlibBase constructor");if(super(t),this.#s=t.flush??0,this.#h=t.finishFlush??0,this.#r=t.fullFlushFlag??0,typeof Ki[e]!="function")throw TypeError("Compression method not supported: "+e);try{this.#e=new Ki[e](t)}catch(i){throw new ce(i,this.constructor)}this.#n=i=>{this.#t||(this.#t=!0,this.close(),this.emit("error",i))},this.#e?.on("error",i=>this.#n(new ce(i))),this.once("end",()=>this.close)}close(){this.#e&&(this.#e.close(),this.#e=void 0,this.emit("close"))}reset(){if(!this.#t)return mi(this.#e,"zlib binding closed"),this.#e.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#r),this.write(Object.assign(bt.alloc(0),{[Je]:t})))}end(t,e,i){return typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#h),this.#i=!0,super.end(i)}get ended(){return this.#i}[Et](t){return super.write(t)}write(t,e,i){if(typeof e=="function"&&(i=e,e="utf8"),typeof t=="string"&&(t=bt.from(t,e)),this.#t)return;mi(this.#e,"zlib binding closed");let s=this.#e._handle,r=s.close;s.close=()=>{};let h=this.#e.close;this.#e.close=()=>{},Qe(!0);let n;try{let o=typeof t[Je]=="number"?t[Je]:this.#s;n=this.#e._processChunk(t,o),Qe(!1)}catch(o){Qe(!1),this.#n(new ce(o,this.write))}finally{this.#e&&(this.#e._handle=s,s.close=r,this.#e.close=h,this.#e.removeAllListeners("error"))}this.#e&&this.#e.on("error",o=>this.#n(new ce(o,this.write)));let a;if(n)if(Array.isArray(n)&&n.length>0){let o=n[0];a=this[Et](bt.from(o));for(let l=1;l<n.length;l++)a=this[Et](n[l])}else a=this[Et](bt.from(n));return i&&i(),a}},Bs=class extends Ui{#t;#i;constructor(t,e){t||={},t.flush=t.flush||Z.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Z.Z_FINISH,t.fullFlushFlag=Z.Z_FULL_FLUSH,super(t,e),this.#t=t.level,this.#i=t.strategy}params(t,e){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.#t!==t||this.#i!==e){this.flush(Z.Z_SYNC_FLUSH),mi(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(t,e)}finally{this.handle.flush=i}this.handle&&(this.#t=t,this.#i=e)}}}},Zr=class extends Bs{#t;constructor(t){super(t,"Gzip"),this.#t=t&&!!t.portable}[Et](t){return this.#t?(this.#t=!1,t[9]=255,super[Et](t)):super[Et](t)}},Wr=class extends Bs{constructor(t){super(t,"Unzip")}},Fs=class extends Ui{constructor(t,e){t||={},t.flush=t.flush||Z.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Z.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Z.BROTLI_OPERATION_FLUSH,super(t,e)}},Gr=class extends Fs{constructor(t){super(t,"BrotliCompress")}},$r=class extends Fs{constructor(t){super(t,"BrotliDecompress")}},Ms=class extends Ui{constructor(t,e){t||={},t.flush=t.flush||Z.ZSTD_e_continue,t.finishFlush=t.finishFlush||Z.ZSTD_e_end,t.fullFlushFlag=Z.ZSTD_e_flush,super(t,e)}},Yr=class extends Ms{constructor(t){super(t,"ZstdCompress")}},Vr=class extends Ms{constructor(t){super(t,"ZstdDecompress")}},Kr=(t,e)=>{if(Number.isSafeInteger(t))t<0?qr(t,e):Xr(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Xr=(t,e)=>{e[0]=128;for(var i=e.length;i>1;i--)e[i-1]=t&255,t=Math.floor(t/256)},qr=(t,e)=>{e[0]=255;var i=!1;t*=-1;for(var s=e.length;s>1;s--){var r=t&255;t=Math.floor(t/256),i?e[s-1]=Cs(r):r===0?e[s-1]=0:(i=!0,e[s-1]=Ps(r))}},Qr=t=>{let e=t[0],i=e===128?th(t.subarray(1,t.length)):e===255?Jr(t):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},Jr=t=>{for(var e=t.length,i=0,s=!1,r=e-1;r>-1;r--){var h=Number(t[r]),n;s?n=Cs(h):h===0?n=h:(s=!0,n=Ps(h)),n!==0&&(i-=n*256**(e-r-1))}return i},th=t=>{for(var e=t.length,i=0,s=e-1;s>-1;s--){var r=Number(t[s]);r!==0&&(i+=r*256**(e-s-1))}return i},Cs=t=>(255^t)&255,Ps=t=>(255^t)+1&255,zs={};Er(zs,{code:()=>ji,isCode:()=>Se,isName:()=>eh,name:()=>Ce,normalFsTypes:()=>Us});var Se=t=>Ce.has(t),eh=t=>ji.has(t),Us=new Set(["0","","1","2","3","4","5","6","7","D"]),Ce=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"]]),ji=new Map(Array.from(Ce).map(t=>[t[1],t[0]])),ot=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#t="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,i,s){Buffer.isBuffer(t)?this.decode(t,e||0,i,s):t&&this.#i(t)}decode(t,e,i,s){if(e||=0,!t||!(t.length>=e+512))throw Error("need 512 bytes for header");let r=ut(t,e+156,1),h=Us.has(r),n=h?i:void 0,a=h?s:void 0;if(this.path=n?.path??ut(t,e,100),this.mode=n?.mode??a?.mode??it(t,e+100,8),this.uid=n?.uid??a?.uid??it(t,e+108,8),this.gid=n?.gid??a?.gid??it(t,e+116,8),this.size=n?.size??a?.size??it(t,e+124,12),this.mtime=n?.mtime??a?.mtime??ti(t,e+136,12),this.cksum=it(t,e+148,12),a&&this.#i(a,!0),n&&this.#i(n),Se(r)&&(this.#t=r||"0"),this.#t==="0"&&this.path.slice(-1)==="/"&&(this.#t="5"),this.#t==="5"&&(this.size=0),this.linkpath=ut(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=n?.uname??a?.uname??ut(t,e+265,32),this.gname=n?.gname??a?.gname??ut(t,e+297,32),this.devmaj=n?.devmaj??a?.devmaj??it(t,e+329,8)??0,this.devmin=n?.devmin??a?.devmin??it(t,e+337,8)??0,t[e+475]!==0){let l=ut(t,e+345,155);this.path=l+"/"+this.path}else{let l=ut(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=i?.atime??s?.atime??ti(t,e+476,12),this.ctime=i?.ctime??s?.ctime??ti(t,e+488,12)}let o=256;for(let l=e;l<e+148;l++)o+=t[l];for(let l=e+156;l<e+512;l++)o+=t[l];this.cksumValid=o===this.cksum,this.cksum===void 0&&o===256&&(this.nullBlock=!0)}#i(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,s])=>!(s==null||i==="path"&&e||i==="linkpath"&&e||i==="global"))))}encode(t,e=0){if(t||=this.block=Buffer.alloc(512),this.#t==="Unsupported"&&(this.#t="0"),!(t.length>=e+512))throw Error("need 512 bytes for header");let i=this.ctime||this.atime?130:155,s=ih(this.path||"",i),r=s[0],h=s[1];this.needPax=!!s[2],this.needPax=ft(t,e,100,r)||this.needPax,this.needPax=st(t,e+100,8,this.mode)||this.needPax,this.needPax=st(t,e+108,8,this.uid)||this.needPax,this.needPax=st(t,e+116,8,this.gid)||this.needPax,this.needPax=st(t,e+124,12,this.size)||this.needPax,this.needPax=ei(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#t.codePointAt(0)),this.needPax=ft(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=ft(t,e+265,32,this.uname)||this.needPax,this.needPax=ft(t,e+297,32,this.gname)||this.needPax,this.needPax=st(t,e+329,8,this.devmaj)||this.needPax,this.needPax=st(t,e+337,8,this.devmin)||this.needPax,this.needPax=ft(t,e+345,i,h)||this.needPax,t[e+475]===0?(this.needPax=ft(t,e+345,130,h)||this.needPax,this.needPax=ei(t,e+476,12,this.atime)||this.needPax,this.needPax=ei(t,e+488,12,this.ctime)||this.needPax):this.needPax=ft(t,e+345,155,h)||this.needPax;let n=256;for(let a=e;a<e+148;a++)n+=t[a];for(let a=e+156;a<e+512;a++)n+=t[a];return this.cksum=n,st(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#t==="Unsupported"?this.#t:Ce.get(this.#t)}get typeKey(){return this.#t}set type(t){let e=String(ji.get(t));if(Se(e)||e==="Unsupported")this.#t=e;else if(Se(t))this.#t=t;else throw TypeError("invalid entry type: "+t)}},ih=(t,e)=>{let i=t,s="",r,h=_t.parse(t).root||".";if(Buffer.byteLength(i)<100)r=[i,s,!1];else{s=_t.dirname(i),i=_t.basename(i);do Buffer.byteLength(i)<=100&&Buffer.byteLength(s)<=e?r=[i,s,!1]:Buffer.byteLength(i)>100&&Buffer.byteLength(s)<=e?r=[i.slice(0,99),s,!0]:(i=_t.join(_t.basename(s),i),s=_t.dirname(s));while(s!==h&&r===void 0);r||=[t.slice(0,99),"",!0]}return r},ut=(t,e,i)=>t.subarray(e,e+i).toString("utf8").replace(/\0.*/,""),ti=(t,e,i)=>sh(it(t,e,i)),sh=t=>t===void 0?void 0:new Date(t*1e3),it=(t,e,i)=>Number(t[e])&128?Qr(t.subarray(e,e+i)):hh(t,e,i),rh=t=>isNaN(t)?void 0:t,hh=(t,e,i)=>rh(parseInt(t.subarray(e,e+i).toString("utf8").replace(/\0.*$/,"").trim(),8)),nh={12:8589934591,8:2097151},st=(t,e,i,s)=>s===void 0?!1:s>nh[i]||s<0?(Kr(s,t.subarray(e,e+i)),!0):(ah(t,e,i,s),!1),ah=(t,e,i,s)=>t.write(oh(s,i),e,i,"ascii"),oh=(t,e)=>lh(Math.floor(t).toString(8),e),lh=(t,e)=>(t.length===e-1?t:Array(e-t.length-1).join("0")+t+" ")+"\0",ei=(t,e,i,s)=>s===void 0?!1:st(t,e,i,s.getTime()/1e3),dh=Array(156).join("\0"),ft=(t,e,i,s)=>s===void 0?!1:(t.write(s+dh,e,i,"utf8"),s.length!==Buffer.byteLength(s)||s.length>i),re=class js{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,i=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=i,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let i=Buffer.byteLength(e),s=512*Math.ceil(1+i/512),r=Buffer.allocUnsafe(s);for(let h=0;h<512;h++)r[h]=0;new ot({path:("PaxHeader/"+ur(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(e,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(e){if(this[e]===void 0)return"";let i=this[e],s=i instanceof Date?i.getTime()/1e3:i,r=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+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(e,i,s=!1){return new js(uh(fh(e),i),s)}},uh=(t,e)=>e?Object.assign({},e,t):t,fh=t=>t.replace(/\n$/,"").split(`
3
- `).reduce(ch,Object.create(null)),ch=(t,e)=>{let i=parseInt(e,10);if(i!==Buffer.byteLength(e)+1)return t;e=e.slice((i+" ").length);let s=e.split("="),r=s.shift();if(!r)return t;let h=r.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),n=s.join("=");return t[h]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(h)?new Date(Number(n)*1e3):/^[0-9]+$/.test(n)?+n:n,t},u=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32"?t=>t&&t.replaceAll(/\\/g,"/"):t=>t,Hs=class extends wt{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(t,e,i){switch(super({}),this.pause(),this.extended=e,this.globalExtended=i,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.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(!t.path)throw Error("no path provided for tar.ReadEntry");this.path=u(t.path),this.mode=t.mode,this.mode&&(this.mode&=4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?u(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#t(e),i&&this.#t(i,!0)}write(t){let e=t.length;if(e>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-e),this.blockRemain=Math.max(0,s-e),this.ignore?!0:i>=e?super.write(t):super.write(t.subarray(0,i))}#t(t,e=!1){t.path&&=u(t.path),t.linkpath&&=u(t.linkpath),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,s])=>!(s==null||i==="path"&&e))))}},Pe=(t,e,i,s={})=>{t.file&&(s.file=t.file),t.cwd&&(s.cwd=t.cwd),s.code=i instanceof Error&&i.code||e,s.tarCode=e,!t.strict&&s.recoverable!==!1?(i instanceof Error&&(s=Object.assign(i,s),i=i.message),t.emit("warn",e,i,s)):i instanceof Error?t.emit("error",Object.assign(i,s)):t.emit("error",Object.assign(Error(`${e}: ${i}`),s))},mh=1024*1024,yi=Buffer.from([31,139]),bi=Buffer.from([40,181,47,253]),ph=Math.max(yi.length,bi.length),N=Symbol("state"),ct=Symbol("writeEntry"),$=Symbol("readEntry"),ii=Symbol("nextEntry"),es=Symbol("processEntry"),j=Symbol("extendedHeader"),Ht=Symbol("globalExtendedHeader"),q=Symbol("meta"),is=Symbol("emitMeta"),v=Symbol("buffer"),Y=Symbol("queue"),Q=Symbol("ended"),si=Symbol("emittedEnd"),mt=Symbol("emit"),w=Symbol("unzip"),me=Symbol("consumeChunk"),pe=Symbol("consumeChunkSub"),ri=Symbol("consumeBody"),ss=Symbol("consumeMeta"),rs=Symbol("consumeHeader"),Zt=Symbol("consuming"),hi=Symbol("bufferConcat"),ve=Symbol("maybeEnd"),St=Symbol("writing"),J=Symbol("aborted"),ye=Symbol("onDone"),pt=Symbol("sawValidEntry"),be=Symbol("sawNullBlock"),ge=Symbol("sawEOF"),hs=Symbol("closeStream"),vh=()=>!0,xt=class extends cr{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Y]=[];[v];[$];[ct];[N]="begin";[q]="";[j];[Ht];[Q]=!1;[w];[J]=!1;[pt];[be]=!1;[ge]=!1;[St]=!1;[Zt]=!1;[si]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(ye,()=>{(this[N]==="begin"||this[pt]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(ye,t.ondone):this.on(ye,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||mh,this.filter=typeof t.filter=="function"?t.filter:vh;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let i=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:i?!0:void 0,this.on("end",()=>this[hs]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,i={}){Pe(this,t,e,i)}[rs](t,e){this[pt]===void 0&&(this[pt]=!1);let i;try{i=new ot(t,e,this[j],this[Ht])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(i.nullBlock)this[be]?(this[ge]=!0,this[N]==="begin"&&(this[N]="header"),this[mt]("eof")):(this[be]=!0,this[mt]("nullBlock"));else if(this[be]=!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[ct]=new Hs(i,this[j],this[Ht]);this[pt]||(r.remain?r.on("end",()=>{r.invalid||(this[pt]=!0)}):this[pt]=!0),r.meta?r.size>this.maxMetaEntrySize?(r.ignore=!0,this[mt]("ignoredEntry",r),this[N]="ignore",r.resume()):r.size>0&&(this[q]="",r.on("data",h=>this[q]+=h),this[N]="meta"):(this[j]=void 0,r.ignore=r.ignore||!this.filter(r.path,r),r.ignore?(this[mt]("ignoredEntry",r),this[N]=r.remain?"ignore":"header",r.resume()):(r.remain?this[N]="body":(this[N]="header",r.end()),this[$]?this[Y].push(r):(this[Y].push(r),this[ii]())))}}}[hs](){queueMicrotask(()=>this.emit("close"))}[es](t){let e=!0;if(!t)this[$]=void 0,e=!1;else if(Array.isArray(t)){let[i,...s]=t;this.emit(i,...s)}else this[$]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ii]()),e=!1);return e}[ii](){do;while(this[es](this[Y].shift()));if(this[Y].length===0){let t=this[$];!t||t.flowing||t.size===t.remain?this[St]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[ri](t,e){let i=this[ct];if(!i)throw Error("attempt to consume body without entry??");let s=i.blockRemain??0,r=s>=t.length&&e===0?t:t.subarray(e,e+s);return i.write(r),i.blockRemain||(this[N]="header",this[ct]=void 0,i.end()),r.length}[ss](t,e){let i=this[ct],s=this[ri](t,e);return!this[ct]&&i&&this[is](i),s}[mt](t,e,i){this[Y].length===0&&!this[$]?this.emit(t,e,i):this[Y].push([t,e,i])}[is](t){switch(this[mt]("meta",this[q]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[j]=re.parse(this[q],this[j],!1);break;case"GlobalExtendedHeader":this[Ht]=re.parse(this[q],this[Ht],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[j]??Object.create(null);this[j]=e,e.path=this[q].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[j]||Object.create(null);this[j]=e,e.linkpath=this[q].replace(/\0.*/,"");break}default:throw Error("unknown meta: "+t.type)}}abort(t){this[J]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,i){if(typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[J])return i?.(),!1;if((this[w]===void 0||this.brotli===void 0&&this[w]===!1)&&t){if(this[v]&&(t=Buffer.concat([this[v],t]),this[v]=void 0),t.length<ph)return this[v]=t,i?.(),!0;for(let n=0;this[w]===void 0&&n<yi.length;n++)t[n]!==yi[n]&&(this[w]=!1);let r=!1;if(this[w]===!1&&this.zstd!==!1){r=!0;for(let n=0;n<bi.length;n++)if(t[n]!==bi[n]){r=!1;break}}let h=this.brotli===void 0&&!r;if(this[w]===!1&&h)if(t.length<512)if(this[Q])this.brotli=!0;else return this[v]=t,i?.(),!0;else try{new ot(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[w]===void 0||this[w]===!1&&(this.brotli||r)){let n=this[Q];this[Q]=!1,this[w]=this[w]===void 0?new Wr({}):r?new Vr({}):new $r({}),this[w].on("data",o=>this[me](o)),this[w].on("error",o=>this.abort(o)),this[w].on("end",()=>{this[Q]=!0,this[me]()}),this[St]=!0;let a=!!this[w][n?"end":"write"](t);return this[St]=!1,i?.(),a}}this[St]=!0,this[w]?this[w].write(t):this[me](t),this[St]=!1;let s=this[Y].length>0?!1:this[$]?this[$].flowing:!0;return!s&&this[Y].length===0&&this[$]?.once("drain",()=>this.emit("drain")),i?.(),s}[hi](t){t&&!this[J]&&(this[v]=this[v]?Buffer.concat([this[v],t]):t)}[ve](){if(this[Q]&&!this[si]&&!this[J]&&!this[Zt]){this[si]=!0;let t=this[ct];if(t&&t.blockRemain){let e=this[v]?this[v].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[v]&&t.write(this[v]),t.end()}this[mt](ye)}}[me](t){if(this[Zt]&&t)this[hi](t);else if(!t&&!this[v])this[ve]();else if(t){if(this[Zt]=!0,this[v]){this[hi](t);let e=this[v];this[v]=void 0,this[pe](e)}else this[pe](t);for(;this[v]&&this[v]?.length>=512&&!this[J]&&!this[ge];){let e=this[v];this[v]=void 0,this[pe](e)}this[Zt]=!1}(!this[v]||this[Q])&&this[ve]()}[pe](t){let e=0,i=t.length;for(;e+512<=i&&!this[J]&&!this[ge];)switch(this[N]){case"begin":case"header":this[rs](t,e),e+=512;break;case"ignore":case"body":e+=this[ri](t,e);break;case"meta":e+=this[ss](t,e);break;default:throw Error("invalid state: "+this[N])}e<i&&(this[v]=this[v]?Buffer.concat([t.subarray(e),this[v]]):t.subarray(e))}end(t,e,i){return typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),i&&this.once("finish",i),this[J]||(this[w]?(t&&this[w].write(t),this[w].end()):(this[Q]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t||=Buffer.alloc(0)),t&&this.write(t),this[ve]())),this}},qt=t=>{let e=t.length-1,i=-1;for(;e>-1&&t.charAt(e)==="/";)i=e,e--;return i===-1?t:t.slice(0,i)},yh=t=>{let e=t.onReadEntry;t.onReadEntry=e?i=>{e(i),i.resume()}:i=>i.resume()},Hi=(t,e)=>{let i=new Map(e.map(h=>[qt(h),!0])),s=t.filter,r=(h,n="")=>{let a=n||pr(h).root||".",o;if(h===a)o=!1;else{let l=i.get(h);o=l===void 0?r(vr(h),a):l}return i.set(h,o),o};t.filter=s?(h,n)=>s(h,n)&&r(qt(h)):h=>r(qt(h))},Bt=he(t=>{let e=new xt(t),i=t.file,s;try{s=d.openSync(i,"r");let r=d.fstatSync(s),h=t.maxReadSize||16*1024*1024;if(r.size<h){let n=Buffer.allocUnsafe(r.size),a=d.readSync(s,n,0,r.size,0);e.end(a===n.byteLength?n:n.subarray(0,a))}else{let n=0,a=Buffer.allocUnsafe(h);for(;n<r.size;){let o=d.readSync(s,a,0,h,n);if(o===0)break;n+=o,e.write(a.subarray(0,o))}e.end()}}finally{if(typeof s=="number")try{d.closeSync(s)}catch{}}},(t,e)=>{let i=new xt(t),s=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((h,n)=>{i.on("error",n),i.on("end",h),d.stat(r,(a,o)=>{if(a)n(a);else{let l=new Pi(r,{readSize:s,size:o.size});l.on("error",n),l.pipe(i)}})})},t=>new xt(t),t=>new xt(t),(t,e)=>{e?.length&&Hi(t,e),t.noResume||yh(t)}),Zs=(t,e,i)=>(t&=4095,i&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:bh,parse:ns}=fr,Zi=t=>{let e="",i=ns(t);for(;bh(t)||i.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":i.root;t=t.slice(s.length),e+=s,i=ns(t)}return[e,t]},ze=["|","<",">","?",":"],Wi=ze.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),gh=new Map(ze.map((t,e)=>[t,Wi[e]])),Eh=new Map(Wi.map((t,e)=>[t,ze[e]])),as=t=>ze.reduce((e,i)=>e.split(i).join(gh.get(i)),t),wh=t=>Wi.reduce((e,i)=>e.split(i).join(Eh.get(i)),t),Ws=(t,e)=>e?(t=u(t).replace(/^\.(\/|$)/,""),qt(e)+"/"+t):u(t),_h=16*1024*1024,os=Symbol("process"),ls=Symbol("file"),ds=Symbol("directory"),gi=Symbol("symlink"),us=Symbol("hardlink"),Wt=Symbol("header"),Oe=Symbol("read"),Ei=Symbol("lstat"),ke=Symbol("onlstat"),wi=Symbol("onread"),_i=Symbol("onreadlink"),Ri=Symbol("openfile"),Si=Symbol("onopenfile"),rt=Symbol("close"),Ie=Symbol("mode"),Oi=Symbol("awaitDrain"),ni=Symbol("ondrain"),H=Symbol("prefix"),Gi=class extends wt{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;#t=!1;constructor(t,e={}){let i=zi(e);super(),this.path=u(t),this.portable=!!i.portable,this.maxReadSize=i.maxReadSize||_h,this.linkCache=i.linkCache||new Map,this.statCache=i.statCache||new Map,this.preservePaths=!!i.preservePaths,this.cwd=u(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?u(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]=Zi(this.path);h&&typeof n=="string"&&(this.path=n,s=h)}this.win32=!!i.win32||process.platform==="win32",this.win32&&(this.path=wh(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=u(i.absolute||se.resolve(this.cwd,t)),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[ke](r):this[Ei]()}warn(t,e,i={}){return Pe(this,t,e,i)}emit(t,...e){return t==="error"&&(this.#t=!0),super.emit(t,...e)}[Ei](){p.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ke](e)})}[ke](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Rh(t),this.emit("stat",t),this[os]()}[os](){switch(this.type){case"File":return this[ls]();case"Directory":return this[ds]();case"SymbolicLink":return this[gi]();default:return this.end()}}[Ie](t){return Zs(t,this.type==="Directory",this.portable)}[H](t){return Ws(t,this.prefix)}[Wt](){if(!this.stat)throw Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new ot({path:this[H](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[H](this.linkpath):this.linkpath,mode:this[Ie](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 re({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[H](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[H](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 t=this.header?.block;if(!t)throw Error("failed to encode header");super.write(t)}[ds](){if(!this.stat)throw Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Wt](),this.end()}[gi](){p.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[_i](e)})}[_i](t){this.linkpath=u(t),this[Wt](),this.end()}[us](t){if(!this.stat)throw Error("cannot create link entry without stat");this.type="Link",this.linkpath=u(se.relative(this.cwd,t)),this.stat.size=0,this[Wt](),this.end()}[ls](){if(!this.stat)throw Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[us](e);this.linkCache.set(t,this.absolute)}if(this[Wt](),this.stat.size===0)return this.end();this[Ri]()}[Ri](){p.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Si](e)})}[Si](t){if(this.fd=t,this.#t)return this[rt]();if(!this.stat)throw Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Oe]()}[Oe](){let{fd:t,buf:e,offset:i,length:s,pos:r}=this;if(t===void 0||e===void 0)throw Error("cannot read file without first opening");p.read(t,e,i,s,r,(h,n)=>{if(h)return this[rt](()=>this.emit("error",h));this[wi](n)})}[rt](t=()=>{}){this.fd!==void 0&&p.close(this.fd,t)}[wi](t){if(t<=0&&this.remain>0){let i=Object.assign(Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rt](()=>this.emit("error",i))}if(t>this.remain){let i=Object.assign(Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rt](()=>this.emit("error",i))}if(!this.buf)throw Error("should have created buffer prior to reading");if(t===this.remain)for(let i=t;i<this.length&&t<this.blockRemain;i++)this.buf[i+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[ni]():this[Oi](()=>this[ni]())}[Oi](t){this.once("drain",t)}write(t,e,i){if(typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let s=Object.assign(Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,i)}[ni](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[rt](t=>t?this.emit("error",t):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[Oe]()}},Gs=class extends Gi{sync=!0;[Ei](){this[ke](p.lstatSync(this.absolute))}[gi](){this[_i](p.readlinkSync(this.absolute))}[Ri](){this[Si](p.openSync(this.absolute,"r"))}[Oe](){let t=!0;try{let{fd:e,buf:i,offset:s,length:r,pos:h}=this;if(e===void 0||i===void 0)throw Error("fd and buf must be set in READ method");let n=p.readSync(e,i,s,r,h);this[wi](n),t=!1}finally{if(t)try{this[rt](()=>{})}catch{}}}[Oi](t){t()}[rt](t=()=>{}){this.fd!==void 0&&p.closeSync(this.fd),t()}},$s=class extends wt{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(t,e,i={}){return Pe(this,t,e,i)}constructor(t,e={}){let i=zi(e);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=t;let{type:s}=t;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=u(t.path),this.mode=t.mode===void 0?void 0:this[Ie](t.mode),this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:i.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath===void 0?void 0:u(t.linkpath),typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let r=!1;if(!this.preservePaths){let[n,a]=Zi(this.path);n&&typeof a=="string"&&(this.path=a,r=n)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new ot({path:this[H](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[H](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 re({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[H](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[H](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),t.pipe(this)}[H](t){return Ws(t,this.prefix)}[Ie](t){return Zs(t,this.type==="Directory",this.portable)}write(t,e,i){typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let s=t.length;if(s>this.blockRemain)throw Error("writing more to entry than is appropriate");return this.blockRemain-=s,super.write(t,i)}end(t,e,i){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),i&&this.once("finish",i),t?super.end(t,i):super.end(i),this}},Rh=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",Sh=class Dt{tail;head;length=0;static create(e=[]){return new Dt(e)}constructor(e=[]){for(let i of e)this.push(i)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw Error("removing node which does not belong to this list");let i=e.next,s=e.prev;return i&&(i.prev=s),s&&(s.next=i),e===this.head&&(this.head=i),e===this.tail&&(this.tail=s),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,i}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let i=this.head;e.list=this,e.next=i,i&&(i.prev=e),this.head=e,this.tail||=e,this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let i=this.tail;e.list=this,e.prev=i,i&&(i.next=e),this.tail=e,this.head||=e,this.length++}push(...e){for(let i=0,s=e.length;i<s;i++)kh(this,e[i]);return this.length}unshift(...e){for(var i=0,s=e.length;i<s;i++)Th(this,e[i]);return this.length}pop(){if(!this.tail)return;let e=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--,e}shift(){if(!this.head)return;let e=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--,e}forEach(e,i){i||=this;for(let s=this.head,r=0;s;r++)e.call(i,s.value,r,this),s=s.next}forEachReverse(e,i){i||=this;for(let s=this.tail,r=this.length-1;s;r--)e.call(i,s.value,r,this),s=s.prev}get(e){let i=0,s=this.head;for(;s&&i<e;i++)s=s.next;if(i===e&&s)return s.value}getReverse(e){let i=0,s=this.tail;for(;s&&i<e;i++)s=s.prev;if(i===e&&s)return s.value}map(e,i){i||=this;let s=new Dt;for(let r=this.head;r;)s.push(e.call(i,r.value,this)),r=r.next;return s}mapReverse(e,i){i||=this;var s=new Dt;for(let r=this.tail;r;)s.push(e.call(i,r.value,this)),r=r.prev;return s}reduce(e,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=e(s,r.value,h),r=r.next;return s}reduceReverse(e,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=e(s,r.value,h),r=r.prev;return s}toArray(){let e=Array(this.length);for(let i=0,s=this.head;s;i++)e[i]=s.value,s=s.next;return e}toArrayReverse(){let e=Array(this.length);for(let i=0,s=this.tail;s;i++)e[i]=s.value,s=s.prev;return e}slice(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let s=new Dt;if(i<e||i<0)return s;e<0&&(e=0),i>this.length&&(i=this.length);let r=this.head,h=0;for(h=0;r&&h<e;h++)r=r.next;for(;r&&h<i;h++,r=r.next)s.push(r.value);return s}sliceReverse(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let s=new Dt;if(i<e||i<0)return s;e<0&&(e=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>e;r--,h=h.prev)s.push(h.value);return s}splice(e,i=0,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let r=this.head;for(let n=0;r&&n<e;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=Oh(this,r,n);return h}reverse(){let e=this.head,i=this.tail;for(let s=e;s;s=s.prev){let r=s.prev;s.prev=s.next,s.next=r}return this.head=i,this.tail=e,this}};function Oh(t,e,i){let s=new $i(i,e,e?e.next:t.head,t);return s.next===void 0&&(t.tail=s),s.prev===void 0&&(t.head=s),t.length++,s}function kh(t,e){t.tail=new $i(e,t.tail,void 0,t),t.head||=t.tail,t.length++}function Th(t,e){t.head=new $i(e,void 0,t.head,t),t.tail||=t.head,t.length++}var $i=class{list;next;prev;value;constructor(t,e,i,s){this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,i?(i.prev=this,this.next=i):this.next=void 0}},ki=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},fs=Buffer.alloc(1024),Te=Symbol("onStat"),Gt=Symbol("ended"),F=Symbol("queue"),$t=Symbol("pendingLinks"),tt=Symbol("current"),vt=Symbol("process"),Yt=Symbol("processing"),Ee=Symbol("processJob"),M=Symbol("jobs"),ai=Symbol("jobDone"),Le=Symbol("addFSEntry"),cs=Symbol("addTarEntry"),Ti=Symbol("stat"),Li=Symbol("readdir"),Ae=Symbol("onreaddir"),De=Symbol("pipe"),ms=Symbol("entry"),oi=Symbol("entryOpt"),xe=Symbol("writeEntryClass"),Ys=Symbol("write"),li=Symbol("ondrain"),ne=class extends wt{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[xe];onWriteEntry;[F];[$t]=new Map;[M]=0;[Yt]=!1;[Gt]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=u(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[xe]=Gi,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if(+!!t.gzip+ +!!t.brotli+ +!!t.zstd>1)throw TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new Zr(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Gr(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Yr(t.zstd)),!this.zip)throw Error("impossible");let e=this.zip;e.on("data",i=>super.write(i)),e.on("end",()=>super.end()),e.on("drain",()=>this[li]()),this.on("resume",()=>e.resume())}else this.on("drain",this[li]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[F]=new Sh,this[M]=0,this.jobs=Number(t.jobs)||4,this[Yt]=!1,this[Gt]=!1}[Ys](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e=void 0),t&&this.add(t),this[Gt]=!0,this[vt](),i&&i(),this}write(t){if(this[Gt])throw Error("write after end");return typeof t=="string"?this[Le](t):this[cs](t),this.flowing}[cs](t){let e=u(se.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let i=new ki(t.path,e);i.entry=new $s(t,this[oi](i)),i.entry.on("end",()=>this[ai](i)),this[M]+=1,this[F].push(i)}this[vt]()}[Le](t){let e=u(se.resolve(this.cwd,t));this[F].push(new ki(t,e)),this[vt]()}[Ti](t){t.pending=!0,this[M]+=1,p[this.follow?"stat":"lstat"](t.absolute,(e,i)=>{t.pending=!1,--this[M],e?this.emit("error",e):this[Te](t,i)})}[Te](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[tt])this[Ee](t);else{let i=`${e.dev}:${e.ino}`,s=this[$t].get(i);s?s.push(t):this[$t].set(i,[t]),t.pendingLink=!0,t.pending=!0}this[vt]()}[Li](t){t.pending=!0,this[M]+=1,p.readdir(t.absolute,(e,i)=>{if(t.pending=!1,--this[M],e)return this.emit("error",e);this[Ae](t,i)})}[Ae](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[vt]()}[vt](){if(!this[Yt]){this[Yt]=!0;for(let t=this[F].head;t&&this[M]<this.jobs;t=t.next)if(this[Ee](t.value),t.value.ignore){let e=t.next;this[F].removeNode(t),t.next=e}this[Yt]=!1,this[Gt]&&this[F].length===0&&this[M]===0&&(this.zip?this.zip.end(fs):(super.write(fs),super.end()))}}get[tt](){return this[F]&&this[F].head&&this[F].head.value}[ai](t){this[F].shift(),--this[M];let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let i=`${e.dev}:${e.ino}`,s=this[$t].get(i);if(s){this[$t].delete(i);for(let r of s)r.pending=!1,this[Ee](r)}}this[vt]()}[Ee](t){if(t.pending&&t.pendingLink&&t===this[tt]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[tt]&&!t.piped&&this[De](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Te](t,e):this[Ti](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Ae](t,e):this[Li](t),!t.readdir)return}if(t.entry=this[ms](t),!t.entry){t.ignore=!0;return}t===this[tt]&&!t.piped&&this[De](t)}}}[oi](t){return{onwarn:(e,i,s)=>this.warn(e,i,s),noPax:this.noPax,cwd:this.cwd,absolute:t.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}}[ms](t){this[M]+=1;try{return new this[xe](t.path,this[oi](t)).on("end",()=>this[ai](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[li](){this[tt]&&this[tt].entry&&this[tt].entry.resume()}[De](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let r=t.path,h=r==="./"?"":r.replace(/\/*$/,"/");this[Le](h+s)});let e=t.entry,i=this.zip;if(!e)throw Error("cannot pipe without source");i?e.on("data",s=>{i.write(s)||e.pause()}):e.on("data",s=>{super.write(s)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,i={}){Pe(this,t,e,i)}},Ue=class extends ne{sync=!0;constructor(t){super(t),this[xe]=Gs}pause(){}resume(){}[Ti](t){let e=this.follow?"statSync":"lstatSync";this[Te](t,p[e](t.absolute))}[Li](t){this[Ae](t,p.readdirSync(t.absolute))}[De](t){let e=t.entry,i=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let r=t.path,h=r==="./"?"":r.replace(/\/*$/,"/");this[Le](h+s)}),!e)throw Error("Cannot pipe without source");i?e.on("data",s=>{i.write(s)}):e.on("data",s=>{super[Ys](s)})}},Lh=(t,e)=>{let i=new Ue(t),s=new Is(t.file,{mode:t.mode||438});i.pipe(s),Vs(i,e)},Ah=(t,e)=>{let i=new ne(t),s=new Me(t.file,{mode:t.mode||438});i.pipe(s);let r=new Promise((h,n)=>{s.on("error",n),s.on("close",h),i.on("error",n)});return Ks(i,e).catch(h=>i.emit("error",h)),r},Vs=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?Bt({file:c.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(i)}),t.end()},Ks=async(t,e)=>{for(let i of e)i.charAt(0)==="@"?await Bt({file:c.resolve(String(t.cwd),i.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(i);t.end()},ps=he(Lh,Ah,(t,e)=>{let i=new Ue(t);return Vs(i,e),i},(t,e)=>{let i=new ne(t);return Ks(i,e).catch(s=>i.emit("error",s)),i},(t,e)=>{if(!e?.length)throw TypeError("no paths specified to add to archive")}),Xs=(process.env.__FAKE_PLATFORM__||process.platform)==="win32",{O_CREAT:qs,O_NOFOLLOW:vs,O_TRUNC:Qs,O_WRONLY:Js}=p.constants,tr=Number(process.env.__FAKE_FS_O_FILENAME__)||p.constants.UV_FS_O_FILEMAP||0,Dh=Xs&&!!tr,xh=512*1024,Nh=tr|Qs|qs|Js,ys=!Xs&&typeof vs=="number"?vs|Qs|qs|Js:null,er=ys===null?Dh?t=>t<xh?Nh:"w":()=>"w":()=>ys,Ai=(t,e,i)=>{try{return d.lchownSync(t,e,i)}catch(s){if(s?.code!=="ENOENT")throw s}},Be=(t,e,i,s)=>{d.lchown(t,e,i,r=>{s(r&&r?.code!=="ENOENT"?r:null)})},Ih=(t,e,i,s,r)=>{e.isDirectory()?ir(c.resolve(t,e.name),i,s,h=>{if(h)return r(h);Be(c.resolve(t,e.name),i,s,r)}):Be(c.resolve(t,e.name),i,s,r)},ir=(t,e,i,s)=>{d.readdir(t,{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 Be(t,e,i,s);let n=h.length,a=null,o=l=>{if(!a){if(l)return s(a=l);if(--n===0)return Be(t,e,i,s)}};for(let l of h)Ih(t,l,e,i,o)})},Bh=(t,e,i,s)=>{e.isDirectory()&&sr(c.resolve(t,e.name),i,s),Ai(c.resolve(t,e.name),i,s)},sr=(t,e,i)=>{let s;try{s=d.readdirSync(t,{withFileTypes:!0})}catch(r){let h=r;if(h?.code==="ENOENT")return;if(h?.code==="ENOTDIR"||h?.code==="ENOTSUP")return Ai(t,e,i);throw h}for(let r of s)Bh(t,r,e,i);return Ai(t,e,i)},rr=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},je=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Fh=(t,e)=>{d.stat(t,(i,s)=>{(i||!s.isDirectory())&&(i=new rr(t,i?.code||"ENOTDIR")),e(i)})},Mh=(t,e,i)=>{t=u(t);let s=e.umask??18,r=e.mode|448,h=(r&s)!==0,n=e.uid,a=e.gid,o=typeof n=="number"&&typeof a=="number"&&(n!==e.processUid||a!==e.processGid),l=e.preserve,f=e.unlink,y=u(e.cwd),b=(k,E)=>{k?i(k):E&&o?ir(E,n,a,T=>b(T)):h?d.chmod(t,r,i):i()};if(t===y)return Fh(t,b);if(l)return dr.mkdir(t,{mode:r,recursive:!0}).then(k=>b(null,k??void 0),b);Di(y,u(c.relative(y,t)).split("/"),r,f,y,void 0,b)},Di=(t,e,i,s,r,h,n)=>{if(e.length===0)return n(null,h);let a=e.shift(),o=u(c.resolve(t+"/"+a));d.mkdir(o,i,hr(o,e,i,s,r,h,n))},hr=(t,e,i,s,r,h,n)=>a=>{a?d.lstat(t,(o,l)=>{if(o)o.path=o.path&&u(o.path),n(o);else if(l.isDirectory())Di(t,e,i,s,r,h,n);else if(s)d.unlink(t,f=>{if(f)return n(f);d.mkdir(t,i,hr(t,e,i,s,r,h,n))});else{if(l.isSymbolicLink())return n(new je(t,t+"/"+e.join("/")));n(a)}}):(h||=t,Di(t,e,i,s,r,h,n))},Ch=t=>{let e=!1,i;try{e=d.statSync(t).isDirectory()}catch(s){i=s?.code}finally{if(!e)throw new rr(t,i??"ENOTDIR")}},Ph=(t,e)=>{t=u(t);let i=e.umask??18,s=e.mode|448,r=(s&i)!==0,h=e.uid,n=e.gid,a=typeof h=="number"&&typeof n=="number"&&(h!==e.processUid||n!==e.processGid),o=e.preserve,l=e.unlink,f=u(e.cwd),y=E=>{E&&a&&sr(E,h,n),r&&d.chmodSync(t,s)};if(t===f)return Ch(f),y();if(o)return y(d.mkdirSync(t,{mode:s,recursive:!0})??void 0);let b=u(c.relative(f,t)).split("/"),k;for(let E=b.shift(),T=f;E&&(T+="/"+E);E=b.shift()){T=u(c.resolve(T));try{d.mkdirSync(T,s),k||=T}catch{let Yi=d.lstatSync(T);if(Yi.isDirectory())continue;if(l){d.unlinkSync(T),d.mkdirSync(T,s),k||=T;continue}else if(Yi.isSymbolicLink())return new je(T,T+"/"+b.join("/"))}}return y(k)},di=Object.create(null),bs=1e4,Ot=new Set,zh=t=>{Ot.has(t)?Ot.delete(t):di[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),Ot.add(t);let e=di[t],i=Ot.size-bs;if(i>bs/10){for(let s of Ot)if(Ot.delete(s),delete di[s],--i<=0)break}return e},Uh=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32",jh=t=>t.split("/").slice(0,-1).reduce((e,i)=>{let s=e.at(-1);return s!==void 0&&(i=As(s,i)),e.push(i||"/"),e},[]),Hh=class{#t=new Map;#i=new Map;#s=new Set;reserve(t,e){t=Uh?["win32 parallelization disabled"]:t.map(s=>qt(As(zh(s))));let i=new Set(t.map(s=>jh(s)).reduce((s,r)=>s.concat(r)));this.#i.set(e,{dirs:i,paths:t});for(let s of t){let r=this.#t.get(s);r?r.push(e):this.#t.set(s,[e])}for(let s of i){let r=this.#t.get(s);if(!r)this.#t.set(s,[new Set([e])]);else{let h=r.at(-1);h instanceof Set?h.add(e):r.push(new Set([e]))}}return this.#r(e)}#h(t){let e=this.#i.get(t);if(!e)throw Error("function does not have any path reservations");return{paths:e.paths.map(i=>this.#t.get(i)),dirs:[...e.dirs].map(i=>this.#t.get(i))}}check(t){let{paths:e,dirs:i}=this.#h(t);return e.every(s=>s&&s[0]===t)&&i.every(s=>s&&s[0]instanceof Set&&s[0].has(t))}#r(t){return this.#s.has(t)||!this.check(t)?!1:(this.#s.add(t),t(()=>this.#e(t)),!0)}#e(t){if(!this.#s.has(t))return!1;let e=this.#i.get(t);if(!e)throw Error("invalid reservation");let{paths:i,dirs:s}=e,r=new Set;for(let h of i){let n=this.#t.get(h);if(!n||n?.[0]!==t)continue;let a=n[1];if(!a){this.#t.delete(h);continue}if(n.shift(),typeof a=="function")r.add(a);else for(let o of a)r.add(o)}for(let h of s){let n=this.#t.get(h),a=n?.[0];if(!(!n||!(a instanceof Set)))if(a.size===1&&n.length===1){this.#t.delete(h);continue}else if(a.size===1){n.shift();let o=n[0];typeof o=="function"&&r.add(o)}else a.delete(t)}return this.#s.delete(t),r.forEach(h=>this.#r(h)),!0}},Zh=()=>process.umask(),gs=Symbol("onEntry"),xi=Symbol("checkFs"),Es=Symbol("checkFs2"),Ni=Symbol("isReusable"),I=Symbol("makeFs"),Ii=Symbol("file"),Bi=Symbol("directory"),Ne=Symbol("link"),ws=Symbol("symlink"),_s=Symbol("hardlink"),Kt=Symbol("ensureNoSymlink"),Rs=Symbol("unsupported"),Ss=Symbol("checkPath"),ui=Symbol("stripAbsolutePath"),ht=Symbol("mkdir"),O=Symbol("onError"),we=Symbol("pending"),Os=Symbol("pend"),kt=Symbol("unpend"),fi=Symbol("ended"),ci=Symbol("maybeClose"),Fi=Symbol("skip"),Qt=Symbol("doChown"),Jt=Symbol("uid"),te=Symbol("gid"),ee=Symbol("checkedCwd"),ie=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32",Wh=1024,Gh=(t,e)=>{if(!ie)return d.unlink(t,e);let i=t+".DELETE."+xs(16).toString("hex");d.rename(t,i,s=>{if(s)return e(s);d.unlink(i,e)})},$h=t=>{if(!ie)return d.unlinkSync(t);let e=t+".DELETE."+xs(16).toString("hex");d.renameSync(t,e),d.unlinkSync(e)},ks=(t,e,i)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:i,Fe=class extends xt{[fi]=!1;[ee]=!1;[we]=0;reservations=new Hh;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(t={}){if(t.ondone=()=>{this[fi]=!0,this[ci]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.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 t.maxDepth=="number"?t.maxDepth:Wh,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||ie,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=u(c.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Zh():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[gs](e))}warn(t,e,i={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(i.recoverable=!1),super.warn(t,e,i)}[ci](){this[fi]&&this[we]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[ui](t,e){let i=t[e],{type:s}=t;if(!i||this.preservePaths)return!0;let[r,h]=Zi(i),n=h.replaceAll(/\\/g,"/").split("/");if(n.includes("..")||ie&&/^[a-z]:\.\.$/i.test(n[0]??"")){if(e==="path"||s==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:i}),!1;let a=c.posix.dirname(t.path),o=c.posix.normalize(c.posix.join(a,n.join("/")));if(o.startsWith("../")||o==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:i}),!1}return r&&(t[e]=String(h),this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute ${e}`,{entry:t,[e]:i})),!0}[Ss](t){let e=u(t.path),i=e.split("/");if(this.strip){if(i.length<this.strip)return!1;if(t.type==="Link"){let s=u(String(t.linkpath)).split("/");if(s.length>=this.strip)t.linkpath=s.slice(this.strip).join("/");else return!1}i.splice(0,this.strip),t.path=i.join("/")}if(isFinite(this.maxDepth)&&i.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:i.length,maxDepth:this.maxDepth}),!1;if(!this[ui](t,"path")||!this[ui](t,"linkpath"))return!1;if(t.absolute=c.isAbsolute(t.path)?u(c.resolve(t.path)):u(c.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:u(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:s}=c.win32.parse(String(t.absolute));t.absolute=s+as(String(t.absolute).slice(s.length));let{root:r}=c.win32.parse(t.path);t.path=r+as(t.path.slice(r.length))}return!0}[gs](t){if(!this[Ss](t))return t.resume();switch(br.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode|=448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[xi](t);default:return this[Rs](t)}}[O](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[kt](),e.resume())}[ht](t,e,i){Mh(u(t),{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:e},i)}[Qt](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Jt](t){return ks(this.uid,t.uid,this.processUid)}[te](t){return ks(this.gid,t.gid,this.processGid)}[Ii](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new Me(String(t.absolute),{flags:er(t.size),mode:i,autoClose:!1});s.on("error",a=>{s.fd&&d.close(s.fd,()=>{}),s.write=()=>!0,this[O](a,t),e()});let r=1,h=a=>{if(a){s.fd&&d.close(s.fd,()=>{}),this[O](a,t),e();return}--r===0&&s.fd!==void 0&&d.close(s.fd,o=>{o?this[O](o,t):this[kt](),e()})};s.on("finish",()=>{let a=String(t.absolute),o=s.fd;if(typeof o=="number"&&t.mtime&&!this.noMtime){r++;let l=t.atime||new Date,f=t.mtime;d.futimes(o,l,f,y=>y?d.utimes(a,l,f,b=>h(b&&y)):h())}if(typeof o=="number"&&this[Qt](t)){r++;let l=this[Jt](t),f=this[te](t);typeof l=="number"&&typeof f=="number"&&d.fchown(o,l,f,y=>y?d.chown(a,l,f,b=>h(b&&y)):h())}h()});let n=this.transform&&this.transform(t)||t;n!==t&&(n.on("error",a=>{this[O](a,t),e()}),t.pipe(n)),n.pipe(s)}[Bi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.dmode;this[ht](String(t.absolute),i,s=>{if(s){this[O](s,t),e();return}let r=1,h=()=>{--r===0&&(e(),this[kt](),t.resume())};t.mtime&&!this.noMtime&&(r++,d.utimes(String(t.absolute),t.atime||new Date,t.mtime,h)),this[Qt](t)&&(r++,d.chown(String(t.absolute),Number(this[Jt](t)),Number(this[te](t)),h)),h()})}[Rs](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[ws](t,e){let i=u(c.relative(this.cwd,c.resolve(c.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Kt](t,this.cwd,i,()=>this[Ne](t,String(t.linkpath),"symlink",e),s=>{this[O](s,t),e()})}[_s](t,e){let i=u(c.resolve(this.cwd,String(t.linkpath))),s=u(String(t.linkpath)).split("/");this[Kt](t,this.cwd,s,()=>this[Ne](t,i,"link",e),r=>{this[O](r,t),e()})}[Kt](t,e,i,s,r){let h=i.shift();if(this.preservePaths||h===void 0)return s();let n=c.resolve(e,h);d.lstat(n,(a,o)=>{if(a)return s();if(o?.isSymbolicLink())return r(new je(n,c.resolve(n,i.join("/"))));this[Kt](t,n,i,s,r)})}[Os](){this[we]++}[kt](){this[we]--,this[ci]()}[Fi](t){this[kt](),t.resume()}[Ni](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!ie}[xi](t){this[Os]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,i=>this[Es](t,i))}[Es](t,e){let i=n=>{e(n)},s=()=>{this[ht](this.cwd,this.dmode,n=>{if(n){this[O](n,t),i();return}this[ee]=!0,r()})},r=()=>{if(t.absolute!==this.cwd){let n=u(c.dirname(String(t.absolute)));if(n!==this.cwd)return this[ht](n,this.dmode,a=>{if(a){this[O](a,t),i();return}h()})}h()},h=()=>{d.lstat(String(t.absolute),(n,a)=>{if(a&&(this.keep||this.newer&&a.mtime>(t.mtime??a.mtime))){this[Fi](t),i();return}if(n||this[Ni](t,a))return this[I](null,t,i);if(a.isDirectory()){if(t.type==="Directory"){let o=this.chmod&&t.mode&&(a.mode&4095)!==t.mode,l=f=>this[I](f??null,t,i);return o?d.chmod(String(t.absolute),Number(t.mode),l):l()}if(t.absolute!==this.cwd)return d.rmdir(String(t.absolute),o=>this[I](o??null,t,i))}if(t.absolute===this.cwd)return this[I](null,t,i);Gh(String(t.absolute),o=>this[I](o??null,t,i))})};this[ee]?r():s()}[I](t,e,i){if(t){this[O](t,e),i();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Ii](e,i);case"Link":return this[_s](e,i);case"SymbolicLink":return this[ws](e,i);case"Directory":case"GNUDumpDir":return this[Bi](e,i)}}[Ne](t,e,i,s){d[i](e,String(t.absolute),r=>{r?this[O](r,t):(this[kt](),t.resume()),s()})}},Vt=t=>{try{return[null,t()]}catch(e){return[e,null]}},Mi=class extends Fe{sync=!0;[I](t,e){return super[I](t,e,()=>{})}[xi](t){if(!this[ee]){let r=this[ht](this.cwd,this.dmode);if(r)return this[O](r,t);this[ee]=!0}if(t.absolute!==this.cwd){let r=u(c.dirname(String(t.absolute)));if(r!==this.cwd){let h=this[ht](r,this.dmode);if(h)return this[O](h,t)}}let[e,i]=Vt(()=>d.lstatSync(String(t.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(t.mtime??i.mtime)))return this[Fi](t);if(e||this[Ni](t,i))return this[I](null,t);if(i.isDirectory()){if(t.type==="Directory"){let[h]=this.chmod&&t.mode&&(i.mode&4095)!==t.mode?Vt(()=>{d.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[I](h,t)}let[r]=Vt(()=>d.rmdirSync(String(t.absolute)));this[I](r,t)}let[s]=t.absolute===this.cwd?[]:Vt(()=>$h(String(t.absolute)));this[I](s,t)}[Ii](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,s=n=>{let a;try{d.closeSync(r)}catch(o){a=o}(n||a)&&this[O](n||a,t),e()},r;try{r=d.openSync(String(t.absolute),er(t.size),i)}catch(n){return s(n)}let h=this.transform&&this.transform(t)||t;h!==t&&(h.on("error",n=>this[O](n,t)),t.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(t.mtime&&!this.noMtime){let a=t.atime||new Date,o=t.mtime;try{d.futimesSync(r,a,o)}catch(l){try{d.utimesSync(String(t.absolute),a,o)}catch{n=l}}}if(this[Qt](t)){let a=this[Jt](t),o=this[te](t);try{d.fchownSync(r,Number(a),Number(o))}catch(l){try{d.chownSync(String(t.absolute),Number(a),Number(o))}catch{n||=l}}}s(n)})}[Bi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[ht](String(t.absolute),i);if(s){this[O](s,t),e();return}if(t.mtime&&!this.noMtime)try{d.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Qt](t))try{d.chownSync(String(t.absolute),Number(this[Jt](t)),Number(this[te](t)))}catch{}e(),t.resume()}[ht](t,e){try{return Ph(u(t),{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:e})}catch(i){return i}}[Kt](t,e,i,s,r){if(this.preservePaths||i.length===0)return s();let h=e;for(let n of i){h=c.resolve(h,n);let[a,o]=Vt(()=>d.lstatSync(h));if(a)return s();if(o.isSymbolicLink())return r(new je(h,c.resolve(e,i.join("/"))))}s()}[Ne](t,e,i,s){let r=`${i}Sync`;try{d[r](e,String(t.absolute)),s(),t.resume()}catch(h){return this[O](h,t)}}},Ts=he(t=>{let e=new Mi(t),i=t.file,s=d.statSync(i);new Nr(i,{readSize:t.maxReadSize||16*1024*1024,size:s.size}).pipe(e)},(t,e)=>{let i=new Fe(t),s=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((h,n)=>{i.on("error",n),i.on("close",h),d.stat(r,(a,o)=>{if(a)n(a);else{let l=new Pi(r,{readSize:s,size:o.size});l.on("error",n),l.pipe(i)}})})},t=>new Mi(t),t=>new Fe(t),(t,e)=>{e?.length&&Hi(t,e)}),Yh=(t,e)=>{let i=new Ue(t),s=!0,r,h;try{try{r=d.openSync(t.file,"r+")}catch(o){if(o?.code==="ENOENT")r=d.openSync(t.file,"w+");else throw o}let n=d.fstatSync(r),a=Buffer.alloc(512);t:for(h=0;h<n.size;h+=512){for(let f=0,y=0;f<512;f+=y){if(y=d.readSync(r,a,f,a.length-f,h+f),h===0&&a[0]===31&&a[1]===139)throw Error("cannot append to compressed archives");if(!y)break t}let o=new ot(a);if(!o.cksumValid)break;let l=512*Math.ceil((o.size||0)/512);if(h+l+512>n.size)break;h+=l,t.mtimeCache&&o.mtime&&t.mtimeCache.set(String(o.path),o.mtime)}s=!1,Vh(t,i,h,r,e)}finally{if(s)try{d.closeSync(r)}catch{}}},Vh=(t,e,i,s,r)=>{let h=new Is(t.file,{fd:s,start:i});e.pipe(h),Xh(e,r)},Kh=(t,e)=>{e=Array.from(e);let i=new ne(t),s=(r,h,n)=>{let a=(b,k)=>{b?d.close(r,E=>n(b)):n(null,k)},o=0;if(h===0)return a(null,0);let l=0,f=Buffer.alloc(512),y=(b,k)=>{if(b||k===void 0)return a(b);if(l+=k,l<512&&k)return d.read(r,f,l,f.length-l,o+l,y);if(o===0&&f[0]===31&&f[1]===139)return a(Error("cannot append to compressed archives"));if(l<512)return a(null,o);let E=new ot(f);if(!E.cksumValid)return a(null,o);let T=512*Math.ceil((E.size??0)/512);if(o+T+512>h||(o+=T+512,o>=h))return a(null,o);t.mtimeCache&&E.mtime&&t.mtimeCache.set(String(E.path),E.mtime),l=0,d.read(r,f,0,512,o,y)};d.read(r,f,0,512,o,y)};return new Promise((r,h)=>{i.on("error",h);let n="r+",a=(o,l)=>{if(o&&o.code==="ENOENT"&&n==="r+")return n="w+",d.open(t.file,n,a);if(o||!l)return h(o);d.fstat(l,(f,y)=>{if(f)return d.close(l,()=>h(f));s(l,y.size,(b,k)=>{if(b)return h(b);let E=new Me(t.file,{fd:l,start:k});i.pipe(E),E.on("error",h),E.on("close",r),qh(i,e)})})};d.open(t.file,n,a)})},Xh=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?Bt({file:c.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(i)}),t.end()},qh=async(t,e)=>{for(let i of e)i.charAt(0)==="@"?await Bt({file:c.resolve(String(t.cwd),i.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(i);t.end()},yt=he(Yh,Kh,()=>{throw TypeError("file is required")},()=>{throw TypeError("file is required")},(t,e)=>{if(!Pr(t))throw TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw TypeError("cannot append to compressed archives");if(!e?.length)throw TypeError("no paths specified to add/replace")});he(yt.syncFile,yt.asyncFile,yt.syncNoFile,yt.asyncNoFile,(t,e=[])=>{yt.validate?.(t,e),Qh(t)});var Qh=t=>{let e=t.filter;t.mtimeCache||=new Map,t.filter=e?(i,s)=>e(i,s)&&!((t.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0)):(i,s)=>!((t.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0))};export{en as index_min_exports};
1
+ import{createRequire as lr}from"node:module";import{_ as fr}from"../packem_shared/giget-D8Kwb0kD.js";let dr;const ur=t=>(dr??=lr(import.meta.url))(t),Ft=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=t=>{if(typeof Ft<"u"&&Ft.versions&&Ft.versions.node){const[e,i]=Ft.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return Ft.getBuiltinModule(t)}return ur(t)},d=D("node:fs"),cr=D("node:fs/promises"),As=D("node:stream"),c=D("node:path"),{posix:Rt,basename:mr,win32:pr,join:Ns}=c,Is=D("events"),{EventEmitter:vr}=Is,p=D("fs"),{EventEmitter:zi}=D("node:events"),{StringDecoder:yr}=D("node:string_decoder"),re=D("path"),{parse:br,dirname:gr}=re,vi=D("assert"),{Buffer:bt}=D("buffer"),Xi=D("zlib"),qi={...Xi,default:Xi},Er=D("zlib"),wr=D("node:assert"),{randomBytes:Bs}=D("node:crypto");var an=fr({Header:()=>ot,Pack:()=>ae,PackJob:()=>Li,PackSync:()=>je,Parser:()=>At,Pax:()=>he,ReadEntry:()=>Gs,Unpack:()=>Me,UnpackSync:()=>Pi,WriteEntry:()=>Yi,WriteEntrySync:()=>Vs,WriteEntryTar:()=>Ks,c:()=>bs,create:()=>bs,extract:()=>Ds,filesFilter:()=>Wi,list:()=>Bt,r:()=>yt,replace:()=>yt,t:()=>Bt,types:()=>Hs,x:()=>Ds}),Rr=Object.defineProperty,_r=(t,e)=>{for(var i in e)Rr(t,i,{get:e[i],enumerable:!0})},Qi=process||{stdout:null,stderr:null},Sr=t=>!!t&&typeof t=="object"&&(t instanceof wt||t instanceof As||Or(t)||kr(t)),Or=t=>!!t&&typeof t=="object"&&t instanceof zi&&typeof t.pipe=="function"&&t.pipe!==As.Writable.prototype.pipe,kr=t=>!!t&&typeof t=="object"&&t instanceof zi&&typeof t.write=="function"&&typeof t.end=="function",G=Symbol("EOF"),$=Symbol("maybeEmitEnd"),q=Symbol("emittedEnd"),oe=Symbol("emittingEnd"),Mt=Symbol("emittedError"),le=Symbol("closed"),Ji=Symbol("read"),de=Symbol("flush"),ts=Symbol("flushChunk"),B=Symbol("encoding"),_t=Symbol("decoder"),R=Symbol("flowing"),Ct=Symbol("paused"),Tt=Symbol("resume"),_=Symbol("buffer"),x=Symbol("pipes"),S=Symbol("bufferLength"),Ze=Symbol("bufferPush"),ue=Symbol("bufferShift"),L=Symbol("objectMode"),E=Symbol("destroyed"),We=Symbol("error"),Ge=Symbol("emitData"),es=Symbol("emitEnd"),$e=Symbol("emitEnd2"),z=Symbol("async"),Ye=Symbol("abort"),fe=Symbol("aborted"),Pt=Symbol("signal"),lt=Symbol("dataListeners"),A=Symbol("discarded"),zt=t=>Promise.resolve().then(t),Tr=t=>t(),Lr=t=>t==="end"||t==="finish"||t==="prefinish",xr=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Dr=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Fs=class{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[Tt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ar=class extends Fs{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=s=>this.dest.emit("error",s),t.on("error",this.proxyErrors)}},Nr=t=>!!t.objectMode,Ir=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",wt=class extends zi{[R]=!1;[Ct]=!1;[x]=[];[_]=[];[L];[B];[z];[_t];[G]=!1;[q]=!1;[oe]=!1;[le]=!1;[Mt]=null;[S]=0;[E]=!1;[Pt];[fe]=!1;[lt]=0;[A]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw TypeError("Encoding and objectMode may not be used together");Nr(e)?(this[L]=!0,this[B]=null):Ir(e)?(this[B]=e.encoding,this[L]=!1):(this[L]=!1,this[B]=null),this[z]=!!e.async,this[_t]=this[B]?new yr(this[B]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[_]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[x]});let{signal:i}=e;i&&(this[Pt]=i,i.aborted?this[Ye]():i.addEventListener("abort",()=>this[Ye]()))}get bufferLength(){return this[S]}get encoding(){return this[B]}set encoding(t){throw Error("Encoding must be set at instantiation time")}setEncoding(t){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[L]}set objectMode(t){throw Error("objectMode must be set at instantiation time")}get async(){return this[z]}set async(t){this[z]=this[z]||!!t}[Ye](){this[fe]=!0,this.emit("abort",this[Pt]?.reason),this.destroy(this[Pt]?.reason)}get aborted(){return this[fe]}set aborted(t){}write(t,e,i){if(this[fe])return!1;if(this[G])throw Error("write after end");if(this[E])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(i=e,e="utf8"),e||="utf8";let s=this[z]?zt:Tr;if(!this[L]&&!Buffer.isBuffer(t)){if(Dr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(xr(t))t=Buffer.from(t);else if(typeof t!="string")throw Error("Non-contiguous data written to non-objectMode stream")}return this[L]?(this[R]&&this[S]!==0&&this[de](!0),this[R]?this.emit("data",t):this[Ze](t),this[S]!==0&&this.emit("readable"),i&&s(i),this[R]):t.length?(typeof t=="string"&&!(e===this[B]&&!this[_t]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[B]&&(t=this[_t].write(t)),this[R]&&this[S]!==0&&this[de](!0),this[R]?this.emit("data",t):this[Ze](t),this[S]!==0&&this.emit("readable"),i&&s(i),this[R]):(this[S]!==0&&this.emit("readable"),i&&s(i),this[R])}read(t){if(this[E])return null;if(this[A]=!1,this[S]===0||t===0||t&&t>this[S])return this[$](),null;this[L]&&(t=null),this[_].length>1&&!this[L]&&(this[_]=[this[B]?this[_].join(""):Buffer.concat(this[_],this[S])]);let e=this[Ji](t||null,this[_][0]);return this[$](),e}[Ji](t,e){if(this[L])this[ue]();else{let i=e;t===i.length||t===null?this[ue]():typeof i=="string"?(this[_][0]=i.slice(t),e=i.slice(0,t),this[S]-=t):(this[_][0]=i.subarray(t),e=i.subarray(0,t),this[S]-=t)}return this.emit("data",e),!this[_].length&&!this[G]&&this.emit("drain"),e}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e="utf8"),t!==void 0&&this.write(t,e),i&&this.once("end",i),this[G]=!0,this.writable=!1,(this[R]||!this[Ct])&&this[$](),this}[Tt](){this[E]||(!this[lt]&&!this[x].length&&(this[A]=!0),this[Ct]=!1,this[R]=!0,this.emit("resume"),this[_].length?this[de]():this[G]?this[$]():this.emit("drain"))}resume(){return this[Tt]()}pause(){this[R]=!1,this[Ct]=!0,this[A]=!1}get destroyed(){return this[E]}get flowing(){return this[R]}get paused(){return this[Ct]}[Ze](t){this[L]?this[S]+=1:this[S]+=t.length,this[_].push(t)}[ue](){return this[L]?--this[S]:this[S]-=this[_][0].length,this[_].shift()}[de](t=!1){do;while(this[ts](this[ue]())&&this[_].length);!t&&!this[_].length&&!this[G]&&this.emit("drain")}[ts](t){return this.emit("data",t),this[R]}pipe(t,e){if(this[E])return t;this[A]=!1;let i=this[q];return e||={},t===Qi.stdout||t===Qi.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[x].push(e.proxyErrors?new Ar(this,t,e):new Fs(this,t,e)),this[z]?zt(()=>this[Tt]()):this[Tt]()),t}unpipe(t){let e=this[x].find(i=>i.dest===t);e&&(this[x].length===1?(this[R]&&this[lt]===0&&(this[R]=!1),this[x]=[]):this[x].splice(this[x].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let i=super.on(t,e);if(t==="data")this[A]=!1,this[lt]++,!this[x].length&&!this[R]&&this[Tt]();else if(t==="readable"&&this[S]!==0)super.emit("readable");else if(Lr(t)&&this[q])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Mt]){let s=e;this[z]?zt(()=>s.call(this,this[Mt])):s.call(this,this[Mt])}return i}removeListener(t,e){return this.off(t,e)}off(t,e){let i=super.off(t,e);return t==="data"&&(this[lt]=this.listeners("data").length,this[lt]===0&&!this[A]&&!this[x].length&&(this[R]=!1)),i}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[lt]=0,!this[A]&&!this[x].length&&(this[R]=!1)),e}get emittedEnd(){return this[q]}[$](){!this[oe]&&!this[q]&&!this[E]&&this[_].length===0&&this[G]&&(this[oe]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[le]&&this.emit("close"),this[oe]=!1)}emit(t,...e){let i=e[0];if(t!=="error"&&t!=="close"&&t!==E&&this[E])return!1;if(t==="data")return!this[L]&&!i?!1:this[z]?(zt(()=>this[Ge](i)),!0):this[Ge](i);if(t==="end")return this[es]();if(t==="close"){if(this[le]=!0,!this[q]&&!this[E])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[Mt]=i,super.emit(We,i);let r=!this[Pt]||this.listeners("error").length?super.emit("error",i):!1;return this[$](),r}else if(t==="resume"){let r=super.emit("resume");return this[$](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let s=super.emit(t,...e);return this[$](),s}[Ge](t){for(let i of this[x])i.dest.write(t)===!1&&this.pause();let e=!this[A]&&super.emit("data",t);return this[$](),e}[es](){return this[q]?!1:(this[q]=!0,this.readable=!1,this[z]?(zt(()=>this[$e]()),!0):this[$e]())}[$e](){if(this[_t]){let e=this[_t].end();if(e){for(let i of this[x])i.dest.write(e);this[A]||super.emit("data",e)}}for(let e of this[x])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[L]||(t.dataLength=0);let e=this.promise();return this.on("data",i=>{t.push(i),this[L]||(t.dataLength+=i.length)}),await e,t}async concat(){if(this[L])throw Error("cannot concat in objectMode");let t=await this.collect();return this[B]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(E,()=>e(Error("stream destroyed"))),this.on("error",i=>e(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[A]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[G])return e();let s,r,h=l=>{this.off("data",n),this.off("end",a),this.off(E,o),e(),r(l)},n=l=>{this.off("error",h),this.off("end",a),this.off(E,o),this.pause(),s({value:l,done:!!this[G]})},a=()=>{this.off("error",h),this.off("data",n),this.off(E,o),e(),s({done:!0,value:void 0})},o=()=>h(Error("stream destroyed"));return new Promise((l,u)=>{r=u,s=l,this.once(E,o),this.once("error",h),this.once("end",a),this.once("data",n)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[A]=!1;let t=!1,e=()=>(this.pause(),this.off(We,e),this.off(E,e),this.off("end",e),t=!0,{done:!0,value:void 0});return this.once("end",e),this.once(We,e),this.once(E,e),{next:()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}},throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[E])return t?this.emit("error",t):this.emit(E),this;this[E]=!0,this[A]=!0,this[_].length=0,this[S]=0;let e=this;return typeof e.close=="function"&&!this[le]&&e.close(),t?this.emit("error",t):this.emit(E),this}static get isStream(){return Sr}},Br=p.writev,nt=Symbol("_autoClose"),P=Symbol("_close"),Ut=Symbol("_ended"),m=Symbol("_fd"),Ve=Symbol("_finished"),X=Symbol("_flags"),Ke=Symbol("_flush"),yi=Symbol("_handleChunk"),bi=Symbol("_makeBuf"),qt=Symbol("_mode"),ce=Symbol("_needDrain"),Nt=Symbol("_onerror"),It=Symbol("_onopen"),Xe=Symbol("_onread"),Lt=Symbol("_onwrite"),at=Symbol("_open"),C=Symbol("_path"),et=Symbol("_pos"),U=Symbol("_queue"),xt=Symbol("_read"),qe=Symbol("_readSize"),K=Symbol("_reading"),jt=Symbol("_remain"),Qe=Symbol("_size"),_e=Symbol("_write"),dt=Symbol("_writing"),Se=Symbol("_defaultFlag"),gt=Symbol("_errored"),Ui=class extends wt{[gt]=!1;[m];[C];[qe];[K]=!1;[Qe];[jt];[nt];constructor(t,e){if(e||={},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw TypeError("path must be a string");this[gt]=!1,this[m]=typeof e.fd=="number"?e.fd:void 0,this[C]=t,this[qe]=e.readSize||16*1024*1024,this[K]=!1,this[Qe]=typeof e.size=="number"?e.size:1/0,this[jt]=this[Qe],this[nt]=typeof e.autoClose!="boolean"||e.autoClose,typeof this[m]=="number"?this[xt]():this[at]()}get fd(){return this[m]}get path(){return this[C]}write(){throw TypeError("this is a readable stream")}end(){throw TypeError("this is a readable stream")}[at](){p.open(this[C],"r",(t,e)=>this[It](t,e))}[It](t,e){t?this[Nt](t):(this[m]=e,this.emit("open",e),this[xt]())}[bi](){return Buffer.allocUnsafe(Math.min(this[qe],this[jt]))}[xt](){if(!this[K]){this[K]=!0;let t=this[bi]();if(t.length===0)return process.nextTick(()=>this[Xe](null,0,t));p.read(this[m],t,0,t.length,null,(e,i,s)=>this[Xe](e,i,s))}}[Xe](t,e,i){this[K]=!1,t?this[Nt](t):this[yi](e,i)&&this[xt]()}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Nt](t){this[K]=!0,this[P](),this.emit("error",t)}[yi](t,e){let i=!1;return this[jt]-=t,t>0&&(i=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[jt]<=0)&&(i=!1,this[P](),super.end()),i}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[m]=="number"&&this[xt](),!1;case"error":return this[gt]?!1:(this[gt]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Fr=class extends Ui{[at](){let t=!0;try{this[It](null,p.openSync(this[C],"r")),t=!1}finally{t&&this[P]()}}[xt](){let t=!0;try{if(!this[K]){this[K]=!0;do{let e=this[bi](),i=e.length===0?0:p.readSync(this[m],e,0,e.length,null);if(!this[yi](i,e))break}while(!0);this[K]=!1}t=!1}finally{t&&this[P]()}}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.closeSync(t),this.emit("close")}}},Ce=class extends Is{readable=!1;writable=!0;[gt]=!1;[dt]=!1;[Ut]=!1;[U]=[];[ce]=!1;[C];[qt];[nt];[m];[Se];[X];[Ve]=!1;[et];constructor(t,e){e||={},super(e),this[C]=t,this[m]=typeof e.fd=="number"?e.fd:void 0,this[qt]=e.mode===void 0?438:e.mode,this[et]=typeof e.start=="number"?e.start:void 0,this[nt]=typeof e.autoClose!="boolean"||e.autoClose;let i=this[et]===void 0?"w":"r+";this[Se]=e.flags===void 0,this[X]=e.flags===void 0?i:e.flags,this[m]===void 0&&this[at]()}emit(t,...e){if(t==="error"){if(this[gt])return!1;this[gt]=!0}return super.emit(t,...e)}get fd(){return this[m]}get path(){return this[C]}[Nt](t){this[P](),this[dt]=!0,this.emit("error",t)}[at](){p.open(this[C],this[X],this[qt],(t,e)=>this[It](t,e))}[It](t,e){this[Se]&&this[X]==="r+"&&t&&t.code==="ENOENT"?(this[X]="w",this[at]()):t?this[Nt](t):(this[m]=e,this.emit("open",e),this[dt]||this[Ke]())}end(t,e){return t&&this.write(t,e),this[Ut]=!0,!this[dt]&&!this[U].length&&typeof this[m]=="number"&&this[Lt](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[Ut]?(this.emit("error",Error("write() after end()")),!1):this[m]===void 0||this[dt]||this[U].length?(this[U].push(t),this[ce]=!0,!1):(this[dt]=!0,this[_e](t),!0)}[_e](t){p.write(this[m],t,0,t.length,this[et],(e,i)=>this[Lt](e,i))}[Lt](t,e){t?this[Nt](t):(this[et]!==void 0&&typeof e=="number"&&(this[et]+=e),this[U].length?this[Ke]():(this[dt]=!1,this[Ut]&&!this[Ve]?(this[Ve]=!0,this[P](),this.emit("finish")):this[ce]&&(this[ce]=!1,this.emit("drain"))))}[Ke](){if(this[U].length===0)this[Ut]&&this[Lt](null,0);else if(this[U].length===1)this[_e](this[U].pop());else{let t=this[U];this[U]=[],Br(this[m],t,this[et],(e,i)=>this[Lt](e,i))}}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Ms=class extends Ce{[at](){let t;if(this[Se]&&this[X]==="r+")try{t=p.openSync(this[C],this[X],this[qt])}catch(e){if(e?.code==="ENOENT")return this[X]="w",this[at]();throw e}else t=p.openSync(this[C],this[X],this[qt]);this[It](null,t)}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.closeSync(t),this.emit("close")}}[_e](t){let e=!0;try{this[Lt](null,p.writeSync(this[m],t,0,t.length,this[et])),e=!1}finally{if(e)try{this[P]()}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"]]),Cr=t=>!!t.sync&&!!t.file,Pr=t=>!t.sync&&!!t.file,zr=t=>!!t.sync&&!t.file,Ur=t=>!t.sync&&!t.file,jr=t=>!!t.file,Hr=t=>Mr.get(t)||t,ji=(t={})=>{if(!t)return{};let e={};for(let[i,s]of Object.entries(t)){let r=Hr(i);e[r]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},ne=(t,e,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 o=ji(h);if(r?.(o,n),Cr(o)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return t(o,n)}else if(Pr(o)){let l=e(o,n);return a?l.then(()=>a(),a):l}else if(zr(o)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return i(o,n)}else if(Ur(o)){if(typeof a=="function")throw TypeError("callback only supported with file option");return s(o,n)}throw Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:i,asyncNoFile:s,validate:r}),Zr=Er.constants||{ZLIB_VERNUM:4736},W=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},Zr)),Wr=bt.concat,is=Object.getOwnPropertyDescriptor(bt,"concat"),Gr=t=>t,Je=is?.writable===!0||is?.set!==void 0?t=>{bt.concat=t?Gr:Wr}:t=>{},Et=Symbol("_superWrite"),me=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||="ZLIB_ERROR",this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ti=Symbol("flushFlag"),Hi=class extends wt{#t=!1;#i=!1;#s;#h;#r;#e;#n;get sawError(){return this.#t}get handle(){return this.#e}get flushFlag(){return this.#s}constructor(t,e){if(!t||typeof t!="object")throw TypeError("invalid options for ZlibBase constructor");if(super(t),this.#s=t.flush??0,this.#h=t.finishFlush??0,this.#r=t.fullFlushFlag??0,typeof qi[e]!="function")throw TypeError("Compression method not supported: "+e);try{this.#e=new qi[e](t)}catch(i){throw new me(i,this.constructor)}this.#n=i=>{this.#t||(this.#t=!0,this.close(),this.emit("error",i))},this.#e?.on("error",i=>this.#n(new me(i))),this.once("end",()=>this.close)}close(){this.#e&&(this.#e.close(),this.#e=void 0,this.emit("close"))}reset(){if(!this.#t)return vi(this.#e,"zlib binding closed"),this.#e.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#r),this.write(Object.assign(bt.alloc(0),{[ti]:t})))}end(t,e,i){return typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#h),this.#i=!0,super.end(i)}get ended(){return this.#i}[Et](t){return super.write(t)}write(t,e,i){if(typeof e=="function"&&(i=e,e="utf8"),typeof t=="string"&&(t=bt.from(t,e)),this.#t)return;vi(this.#e,"zlib binding closed");let s=this.#e._handle,r=s.close;s.close=()=>{};let h=this.#e.close;this.#e.close=()=>{},Je(!0);let n;try{let o=typeof t[ti]=="number"?t[ti]:this.#s;n=this.#e._processChunk(t,o),Je(!1)}catch(o){Je(!1),this.#n(new me(o,this.write))}finally{this.#e&&(this.#e._handle=s,s.close=r,this.#e.close=h,this.#e.removeAllListeners("error"))}this.#e&&this.#e.on("error",o=>this.#n(new me(o,this.write)));let a;if(n)if(Array.isArray(n)&&n.length>0){let o=n[0];a=this[Et](bt.from(o));for(let l=1;l<n.length;l++)a=this[Et](n[l])}else a=this[Et](bt.from(n));return i&&i(),a}},Cs=class extends Hi{#t;#i;constructor(t,e){t||={},t.flush=t.flush||W.Z_NO_FLUSH,t.finishFlush=t.finishFlush||W.Z_FINISH,t.fullFlushFlag=W.Z_FULL_FLUSH,super(t,e),this.#t=t.level,this.#i=t.strategy}params(t,e){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.#t!==t||this.#i!==e){this.flush(W.Z_SYNC_FLUSH),vi(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(t,e)}finally{this.handle.flush=i}this.handle&&(this.#t=t,this.#i=e)}}}},$r=class extends Cs{#t;constructor(t){super(t,"Gzip"),this.#t=t&&!!t.portable}[Et](t){return this.#t?(this.#t=!1,t[9]=255,super[Et](t)):super[Et](t)}},Yr=class extends Cs{constructor(t){super(t,"Unzip")}},Ps=class extends Hi{constructor(t,e){t||={},t.flush=t.flush||W.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||W.BROTLI_OPERATION_FINISH,t.fullFlushFlag=W.BROTLI_OPERATION_FLUSH,super(t,e)}},Vr=class extends Ps{constructor(t){super(t,"BrotliCompress")}},Kr=class extends Ps{constructor(t){super(t,"BrotliDecompress")}},zs=class extends Hi{constructor(t,e){t||={},t.flush=t.flush||W.ZSTD_e_continue,t.finishFlush=t.finishFlush||W.ZSTD_e_end,t.fullFlushFlag=W.ZSTD_e_flush,super(t,e)}},Xr=class extends zs{constructor(t){super(t,"ZstdCompress")}},qr=class extends zs{constructor(t){super(t,"ZstdDecompress")}},Qr=(t,e)=>{if(Number.isSafeInteger(t))t<0?th(t,e):Jr(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Jr=(t,e)=>{e[0]=128;for(var i=e.length;i>1;i--)e[i-1]=t&255,t=Math.floor(t/256)},th=(t,e)=>{e[0]=255;var i=!1;t*=-1;for(var s=e.length;s>1;s--){var r=t&255;t=Math.floor(t/256),i?e[s-1]=Us(r):r===0?e[s-1]=0:(i=!0,e[s-1]=js(r))}},eh=t=>{let e=t[0],i=e===128?sh(t.subarray(1,t.length)):e===255?ih(t):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},ih=t=>{for(var e=t.length,i=0,s=!1,r=e-1;r>-1;r--){var h=Number(t[r]),n;s?n=Us(h):h===0?n=h:(s=!0,n=js(h)),n!==0&&(i-=n*256**(e-r-1))}return i},sh=t=>{for(var e=t.length,i=0,s=e-1;s>-1;s--){var r=Number(t[s]);r!==0&&(i+=r*256**(e-s-1))}return i},Us=t=>(255^t)&255,js=t=>(255^t)+1&255,Hs={};_r(Hs,{code:()=>Zi,isCode:()=>Oe,isName:()=>rh,name:()=>Pe,normalFsTypes:()=>Zs});var Oe=t=>Pe.has(t),rh=t=>Zi.has(t),Zs=new Set(["0","","1","2","3","4","5","6","7","D"]),Pe=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"]]),Zi=new Map(Array.from(Pe).map(t=>[t[1],t[0]])),hh=t=>t===void 0||t<0?void 0:t,ot=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#t="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,i,s){Buffer.isBuffer(t)?this.decode(t,e||0,i,s):t&&this.#i(t)}decode(t,e,i,s){if(e||=0,!t||!(t.length>=e+512))throw Error("need 512 bytes for header");let r=ut(t,e+156,1),h=Zs.has(r),n=h?i:void 0,a=h?s:void 0;if(this.path=n?.path??ut(t,e,100),this.mode=n?.mode??a?.mode??it(t,e+100,8),this.uid=n?.uid??a?.uid??it(t,e+108,8),this.gid=n?.gid??a?.gid??it(t,e+116,8),this.size=hh(n?.size??a?.size??it(t,e+124,12)),this.mtime=n?.mtime??a?.mtime??ei(t,e+136,12),this.cksum=it(t,e+148,12),a&&this.#i(a,!0),n&&this.#i(n),Oe(r)&&(this.#t=r||"0"),this.#t==="0"&&this.path.slice(-1)==="/"&&(this.#t="5"),this.#t==="5"&&(this.size=0),this.linkpath=ut(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=n?.uname??a?.uname??ut(t,e+265,32),this.gname=n?.gname??a?.gname??ut(t,e+297,32),this.devmaj=n?.devmaj??a?.devmaj??it(t,e+329,8)??0,this.devmin=n?.devmin??a?.devmin??it(t,e+337,8)??0,t[e+475]!==0){let l=ut(t,e+345,155);this.path=l+"/"+this.path}else{let l=ut(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=i?.atime??s?.atime??ei(t,e+476,12),this.ctime=i?.ctime??s?.ctime??ei(t,e+488,12)}let o=256;for(let l=e;l<e+148;l++)o+=t[l];for(let l=e+156;l<e+512;l++)o+=t[l];this.cksumValid=o===this.cksum,this.cksum===void 0&&o===256&&(this.nullBlock=!0)}#i(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,s])=>!(s==null||i==="size"&&Number(s)<0||i==="path"&&e||i==="linkpath"&&e||i==="global"))))}encode(t,e=0){if(t||=this.block=Buffer.alloc(512),this.#t==="Unsupported"&&(this.#t="0"),!(t.length>=e+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=ft(t,e,100,r)||this.needPax,this.needPax=st(t,e+100,8,this.mode)||this.needPax,this.needPax=st(t,e+108,8,this.uid)||this.needPax,this.needPax=st(t,e+116,8,this.gid)||this.needPax,this.needPax=st(t,e+124,12,this.size)||this.needPax,this.needPax=ii(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#t.codePointAt(0)),this.needPax=ft(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=ft(t,e+265,32,this.uname)||this.needPax,this.needPax=ft(t,e+297,32,this.gname)||this.needPax,this.needPax=st(t,e+329,8,this.devmaj)||this.needPax,this.needPax=st(t,e+337,8,this.devmin)||this.needPax,this.needPax=ft(t,e+345,i,h)||this.needPax,t[e+475]===0?(this.needPax=ft(t,e+345,130,h)||this.needPax,this.needPax=ii(t,e+476,12,this.atime)||this.needPax,this.needPax=ii(t,e+488,12,this.ctime)||this.needPax):this.needPax=ft(t,e+345,155,h)||this.needPax;let n=256;for(let a=e;a<e+148;a++)n+=t[a];for(let a=e+156;a<e+512;a++)n+=t[a];return this.cksum=n,st(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#t==="Unsupported"?this.#t:Pe.get(this.#t)}get typeKey(){return this.#t}set type(t){let e=String(Zi.get(t));if(Oe(e)||e==="Unsupported")this.#t=e;else if(Oe(t))this.#t=t;else throw TypeError("invalid entry type: "+t)}},nh=(t,e)=>{let i=t,s="",r,h=Rt.parse(t).root||".";if(Buffer.byteLength(i)<100)r=[i,s,!1];else{s=Rt.dirname(i),i=Rt.basename(i);do Buffer.byteLength(i)<=100&&Buffer.byteLength(s)<=e?r=[i,s,!1]:Buffer.byteLength(i)>100&&Buffer.byteLength(s)<=e?r=[i.slice(0,99),s,!0]:(i=Rt.join(Rt.basename(s),i),s=Rt.dirname(s));while(s!==h&&r===void 0);r||=[t.slice(0,99),"",!0]}return r},ut=(t,e,i)=>t.subarray(e,e+i).toString("utf8").replace(/\0.*/,""),ei=(t,e,i)=>ah(it(t,e,i)),ah=t=>t===void 0?void 0:new Date(t*1e3),it=(t,e,i)=>Number(t[e])&128?eh(t.subarray(e,e+i)):lh(t,e,i),oh=t=>isNaN(t)?void 0:t,lh=(t,e,i)=>oh(parseInt(t.subarray(e,e+i).toString("utf8").replace(/\0.*$/,"").trim(),8)),dh={12:8589934591,8:2097151},st=(t,e,i,s)=>s===void 0?!1:s>dh[i]||s<0?(Qr(s,t.subarray(e,e+i)),!0):(uh(t,e,i,s),!1),uh=(t,e,i,s)=>t.write(fh(s,i),e,i,"ascii"),fh=(t,e)=>ch(Math.floor(t).toString(8),e),ch=(t,e)=>(t.length===e-1?t:Array(e-t.length-1).join("0")+t+" ")+"\0",ii=(t,e,i,s)=>s!==void 0&&st(t,e,i,s.getTime()/1e3),mh=Array(156).join("\0"),ft=(t,e,i,s)=>s===void 0?!1:(t.write(s+mh,e,i,"utf8"),s.length!==Buffer.byteLength(s)||s.length>i),he=class Ws{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,i=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=i,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let i=Buffer.byteLength(e),s=512*Math.ceil(1+i/512),r=Buffer.allocUnsafe(s);for(let h=0;h<512;h++)r[h]=0;new ot({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(e,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(e){if(this[e]===void 0)return"";let i=this[e],s=i instanceof Date?i.getTime()/1e3:i,r=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+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(e,i,s=!1){return new Ws(ph(vh(e),i),s)}},ph=(t,e)=>e?Object.assign({},e,t):t,vh=t=>t.replace(/\n$/,"").split(`
3
+ `).reduce(yh,Object.create(null)),yh=(t,e)=>{let i=parseInt(e,10);if(i!==Buffer.byteLength(e)+1)return t;e=e.slice((i+" ").length);let s=e.split("="),r=s.shift();if(!r)return t;let h=r.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),n=s.join("=").replace(/\0.*/,"");switch(h){case"path":case"linkpath":case"type":case"charset":case"comment":case"gname":case"uname":t[h]=n;break;case"ctime":case"atime":case"mtime":t[h]=new Date(Number(n)*1e3);break;case"size":let a=+n;a>=0&&(t[h]=a);break;case"gid":case"uid":case"dev":case"ino":case"nlink":case"mode":t[h]=+n;break}return t},f=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32"?t=>String(t).replaceAll(/\\/g,"/"):t=>String(t),Gs=class extends wt{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(t,e,i){switch(super({}),this.pause(),this.extended=e,this.globalExtended=i,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.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(!t.path)throw Error("no path provided for tar.ReadEntry");this.path=f(t.path),this.mode=t.mode,this.mode&&(this.mode&=4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?f(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#t(e),i&&this.#t(i,!0)}write(t){let e=t.length;if(e>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-e),this.blockRemain=Math.max(0,s-e),this.ignore?!0:i>=e?super.write(t):super.write(t.subarray(0,i))}#t(t,e=!1){t.path&&=f(t.path),t.linkpath&&=f(t.linkpath),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,s])=>!(s==null||i==="path"&&e))))}},ze=(t,e,i,s={})=>{t.file&&(s.file=t.file),t.cwd&&(s.cwd=t.cwd),s.code=i instanceof Error&&i.code||e,s.tarCode=e,!t.strict&&s.recoverable!==!1?(i instanceof Error&&(s=Object.assign(i,s),i=i.message),t.emit("warn",e,i,s)):i instanceof Error?t.emit("error",Object.assign(i,s)):t.emit("error",Object.assign(Error(`${e}: ${i}`),s))},bh=1024*1024,gi=Buffer.from([31,139]),Ei=Buffer.from([40,181,47,253]),gh=Math.max(gi.length,Ei.length),N=Symbol("state"),ct=Symbol("writeEntry"),Y=Symbol("readEntry"),si=Symbol("nextEntry"),ss=Symbol("processEntry"),j=Symbol("extendedHeader"),Ht=Symbol("globalExtendedHeader"),Q=Symbol("meta"),rs=Symbol("emitMeta"),v=Symbol("buffer"),V=Symbol("queue"),J=Symbol("ended"),ri=Symbol("emittedEnd"),mt=Symbol("emit"),g=Symbol("unzip"),pe=Symbol("consumeChunk"),ve=Symbol("consumeChunkSub"),hi=Symbol("consumeBody"),hs=Symbol("consumeMeta"),ns=Symbol("consumeHeader"),Zt=Symbol("consuming"),ni=Symbol("bufferConcat"),ye=Symbol("maybeEnd"),St=Symbol("writing"),H=Symbol("aborted"),be=Symbol("onDone"),pt=Symbol("sawValidEntry"),ge=Symbol("sawNullBlock"),Ee=Symbol("sawEOF"),as=Symbol("closeStream"),Eh=1e3,Wt=Symbol("compressedBytesRead"),ai=Symbol("decompressedBytesRead"),os=Symbol("checkDecompressionRatio"),wh=()=>!0,At=class extends vr{file;strict;maxMetaEntrySize;filter;brotli;zstd;maxDecompressionRatio;writable=!0;readable=!1;[V]=[];[v];[Y];[ct];[N]="begin";[Q]="";[j];[Ht];[J]=!1;[g];[H]=!1;[pt];[ge]=!1;[Ee]=!1;[St]=!1;[Zt]=!1;[ri]=!1;[Wt]=0;[ai]=0;constructor(t={}){super(),this.file=t.file||"",this.on(be,()=>{(this[N]==="begin"||this[pt]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(be,t.ondone):this.on(be,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxDecompressionRatio=typeof t.maxDecompressionRatio=="number"?t.maxDecompressionRatio:Eh,this.maxMetaEntrySize=t.maxMetaEntrySize||bh,this.filter=typeof t.filter=="function"?t.filter:wh;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let i=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:i?!0:void 0,this.on("end",()=>this[as]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,i={}){ze(this,t,e,i)}[ns](t,e){this[pt]===void 0&&(this[pt]=!1);let i;try{i=new ot(t,e,this[j],this[Ht])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(i.nullBlock)this[ge]?(this[Ee]=!0,this[N]==="begin"&&(this[N]="header"),this[mt]("eof")):(this[ge]=!0,this[mt]("nullBlock"));else if(this[ge]=!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[ct]=new Gs(i,this[j],this[Ht]);this[pt]||(r.remain?r.on("end",()=>{r.invalid||(this[pt]=!0)}):this[pt]=!0),r.meta?r.size>this.maxMetaEntrySize?(r.ignore=!0,this[mt]("ignoredEntry",r),this[N]="ignore",r.resume()):r.size>0&&(this[Q]="",r.on("data",h=>this[Q]+=h),this[N]="meta"):(this[j]=void 0,r.ignore=r.ignore||!this.filter(r.path,r),r.ignore?(this[mt]("ignoredEntry",r),this[N]=r.remain?"ignore":"header",r.resume()):(r.remain?this[N]="body":(this[N]="header",r.end()),this[Y]?this[V].push(r):(this[V].push(r),this[si]())))}}}[as](){queueMicrotask(()=>this.emit("close"))}[ss](t){let e=!0;if(!t)this[Y]=void 0,e=!1;else if(Array.isArray(t)){let[i,...s]=t;this.emit(i,...s)}else this[Y]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[si]()),e=!1);return e}[si](){do;while(this[ss](this[V].shift()));if(this[V].length===0){let t=this[Y];!t||t.flowing||t.size===t.remain?this[St]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[hi](t,e){let i=this[ct];if(!i)throw Error("attempt to consume body without entry??");let s=i.blockRemain??0,r=s>=t.length&&e===0?t:t.subarray(e,e+s);return i.write(r),i.blockRemain||(this[N]="header",this[ct]=void 0,i.end()),r.length}[hs](t,e){let i=this[ct],s=this[hi](t,e);return!this[ct]&&i&&this[rs](i),s}[mt](t,e,i){this[V].length===0&&!this[Y]?this.emit(t,e,i):this[V].push([t,e,i])}[rs](t){switch(this[mt]("meta",this[Q]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[j]=he.parse(this[Q],this[j],!1);break;case"GlobalExtendedHeader":this[Ht]=he.parse(this[Q],this[Ht],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[j]??Object.create(null);this[j]=e,e.path=this[Q].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[j]||Object.create(null);this[j]=e,e.linkpath=this[Q].replace(/\0.*/,"");break}default:throw Error("unknown meta: "+t.type)}}abort(t){if(!this[H]){if(this[g]){let e=this[g];e.write=()=>!0,e.end=()=>e,e.emit=()=>!1,e.destroy?.()}this[H]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}}[os](t){this[ai]+=t.length;let e=this[ai]/this[Wt];return e>this.maxDecompressionRatio?(this.abort(Error(`max decompression ratio exceeded: ${e.toFixed(2)} > ${this.maxDecompressionRatio}`)),!1):!0}write(t,e,i){if(typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[H])return i?.(),!1;if((this[g]===void 0||this.brotli===void 0&&this[g]===!1)&&t){if(this[v]&&(t=Buffer.concat([this[v],t]),this[v]=void 0),t.length<gh)return this[v]=t,i?.(),!0;for(let n=0;this[g]===void 0&&n<gi.length;n++)t[n]!==gi[n]&&(this[g]=!1);let r=!1;if(this[g]===!1&&this.zstd!==!1){r=!0;for(let n=0;n<Ei.length;n++)if(t[n]!==Ei[n]){r=!1;break}}let h=this.brotli===void 0&&!r;if(this[g]===!1&&h)if(t.length<512)if(this[J])this.brotli=!0;else return this[v]=t,i?.(),!0;else try{new ot(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[g]===void 0||this[g]===!1&&(this.brotli||r)){let n=this[J];this[J]=!1,this[g]=this[g]===void 0?new Yr({}):r?new qr({}):new Kr({}),this[g].on("data",o=>{this[os](o)&&this[pe](o)}),this[g].on("error",o=>{this[H]||this.abort(o)}),this[g].on("end",()=>{this[J]=!0,this[pe]()}),this[St]=!0,this[Wt]+=t.length;let a=!!this[g][n?"end":"write"](t);return this[St]=!1,i?.(),a}}this[St]=!0,this[g]?(this[Wt]+=t.length,this[g].write(t)):this[pe](t),this[St]=!1;let s=this[V].length>0?!1:!this[Y]||this[Y].flowing;return!s&&this[V].length===0&&this[Y]?.once("drain",()=>this.emit("drain")),i?.(),s}[ni](t){t&&!this[H]&&(this[v]=this[v]?Buffer.concat([this[v],t]):t)}[ye](){if(this[J]&&!this[ri]&&!this[H]&&!this[Zt]){this[ri]=!0;let t=this[ct];if(t?.blockRemain){let e=this[v]?this[v].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[v]&&t.write(this[v]),t.end()}this[mt](be)}}[pe](t){if(this[Zt]&&t)this[ni](t);else if(!t&&!this[v])this[ye]();else if(t){if(this[Zt]=!0,this[v]){this[ni](t);let e=this[v];this[v]=void 0,this[ve](e)}else this[ve](t);for(;this[v]&&this[v]?.length>=512&&!this[H]&&!this[Ee];){let e=this[v];this[v]=void 0,this[ve](e)}this[Zt]=!1}(!this[v]||this[J])&&this[ye]()}[ve](t){let e=0,i=t.length;for(;e+512<=i&&!this[H]&&!this[Ee];)switch(this[N]){case"begin":case"header":this[ns](t,e),e+=512;break;case"ignore":case"body":e+=this[hi](t,e);break;case"meta":e+=this[hs](t,e);break;default:throw Error("invalid state: "+this[N])}e<i&&(this[v]=this[v]?Buffer.concat([t.subarray(e),this[v]]):t.subarray(e))}end(t,e,i){return typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),i&&this.once("finish",i),this[H]||(this[g]?(t&&(this[Wt]+=t.length,this[g].write(t)),this[g].end()):(this[J]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t||=Buffer.alloc(0)),t&&this.write(t),this[ye]())),this}},Qt=t=>{let e=t.length-1,i=-1;for(;e>-1&&t.charAt(e)==="/";)i=e,e--;return i===-1?t:t.slice(0,i)},Rh=t=>{let e=t.onReadEntry;t.onReadEntry=e?i=>{e(i),i.resume()}:i=>i.resume()},Wi=(t,e)=>{let i=new Map(e.map(h=>[Qt(h),!0])),s=t.filter,r=(h,n="",a=0)=>{if(a>=100)return i.set(h,!1),!1;let o=n||br(h).root||".",l;if(h===o)l=!1;else{let u=i.get(h);l=u===void 0?r(gr(h),o,a+1):u}return i.set(h,l),l};t.filter=s?(h,n)=>s(h,n)&&r(Qt(h)):h=>r(Qt(h))},Bt=ne(t=>{let e=new At(t),i=t.file,s;try{s=d.openSync(i,"r");let r=d.fstatSync(s),h=t.maxReadSize||16*1024*1024;if(r.size<h){let n=Buffer.allocUnsafe(r.size),a=d.readSync(s,n,0,r.size,0);e.end(a===n.byteLength?n:n.subarray(0,a))}else{let n=0,a=Buffer.allocUnsafe(h);for(;n<r.size;){let o=d.readSync(s,a,0,h,n);if(o===0)break;n+=o,e.write(a.subarray(0,o))}e.end()}}finally{if(typeof s=="number")try{d.closeSync(s)}catch{}}},(t,e)=>{let i=new At(t),s=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((h,n)=>{i.on("error",n),i.on("end",h),d.stat(r,(a,o)=>{if(a)n(a);else{let l=new Ui(r,{readSize:s,size:o.size});l.on("error",n),l.pipe(i)}})})},t=>new At(t),t=>new At(t),(t,e)=>{e?.length&&Wi(t,e),t.noResume||Rh(t)}),$s=(t,e,i)=>(t&=4095,i&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:_h,parse:ls}=pr,Gi=t=>{let e="",i=ls(t);for(;_h(t)||i.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":i.root;t=t.slice(s.length),e+=s,i=ls(t)}return[e,t]},Ue=["|","<",">","?",":"],$i=Ue.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Sh=new Map(Ue.map((t,e)=>[t,$i[e]])),Oh=new Map($i.map((t,e)=>[t,Ue[e]])),ds=t=>Ue.reduce((e,i)=>e.split(i).join(Sh.get(i)),t),kh=t=>$i.reduce((e,i)=>e.split(i).join(Oh.get(i)),t),Ys=(t,e)=>e?(t=f(t).replace(/^\.(\/|$)/,""),Qt(e)+"/"+t):f(t),Th=16*1024*1024,us=Symbol("process"),fs=Symbol("file"),cs=Symbol("directory"),wi=Symbol("symlink"),ms=Symbol("hardlink"),Gt=Symbol("header"),ke=Symbol("read"),Ri=Symbol("lstat"),Te=Symbol("onlstat"),_i=Symbol("onread"),Si=Symbol("onreadlink"),Oi=Symbol("openfile"),ki=Symbol("onopenfile"),rt=Symbol("close"),Be=Symbol("mode"),Ti=Symbol("awaitDrain"),oi=Symbol("ondrain"),Z=Symbol("prefix"),Yi=class extends wt{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;#t=!1;constructor(t,e={}){let i=ji(e);super(),this.path=f(t),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=f(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?f(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=kh(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=f(i.absolute||re.resolve(this.cwd,t)),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[Te](r):this[Ri]()}warn(t,e,i={}){return ze(this,t,e,i)}emit(t,...e){return t==="error"&&(this.#t=!0),super.emit(t,...e)}[Ri](){p.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Te](e)})}[Te](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Lh(t),this.emit("stat",t),this[us]()}[us](){switch(this.type){case"File":return this[fs]();case"Directory":return this[cs]();case"SymbolicLink":return this[wi]();default:return this.end()}}[Be](t){return $s(t,this.type==="Directory",this.portable)}[Z](t){return Ys(t,this.prefix)}[Gt](){if(!this.stat)throw Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new ot({path:this[Z](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Z](this.linkpath):this.linkpath,mode:this[Be](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 he({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[Z](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Z](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 t=this.header?.block;if(!t)throw Error("failed to encode header");super.write(t)}[cs](){if(!this.stat)throw Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Gt](),this.end()}[wi](){p.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Si](e)})}[Si](t){this.linkpath=f(t),this[Gt](),this.end()}[ms](t){if(!this.stat)throw Error("cannot create link entry without stat");this.type="Link",this.linkpath=f(re.relative(this.cwd,t)),this.stat.size=0,this[Gt](),this.end()}[fs](){if(!this.stat)throw Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[ms](e);this.linkCache.set(t,this.absolute)}if(this[Gt](),this.stat.size===0)return this.end();this[Oi]()}[Oi](){p.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[ki](e)})}[ki](t){if(this.fd=t,this.#t)return this[rt]();if(!this.stat)throw Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[ke]()}[ke](){let{fd:t,buf:e,offset:i,length:s,pos:r}=this;if(t===void 0||e===void 0)throw Error("cannot read file without first opening");p.read(t,e,i,s,r,(h,n)=>{if(h)return this[rt](()=>this.emit("error",h));this[_i](n)})}[rt](t=()=>{}){this.fd!==void 0&&p.close(this.fd,t)}[_i](t){if(t<=0&&this.remain>0){let i=Object.assign(Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rt](()=>this.emit("error",i))}if(t>this.remain){let i=Object.assign(Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rt](()=>this.emit("error",i))}if(!this.buf)throw Error("should have created buffer prior to reading");if(t===this.remain)for(let i=t;i<this.length&&t<this.blockRemain;i++)this.buf[i+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[oi]():this[Ti](()=>this[oi]())}[Ti](t){this.once("drain",t)}write(t,e,i){if(typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let s=Object.assign(Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,i)}[oi](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[rt](t=>t?this.emit("error",t):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[ke]()}},Vs=class extends Yi{sync=!0;[Ri](){this[Te](p.lstatSync(this.absolute))}[wi](){this[Si](p.readlinkSync(this.absolute))}[Oi](){this[ki](p.openSync(this.absolute,"r"))}[ke](){let t=!0;try{let{fd:e,buf:i,offset:s,length:r,pos:h}=this;if(e===void 0||i===void 0)throw Error("fd and buf must be set in READ method");let n=p.readSync(e,i,s,r,h);this[_i](n),t=!1}finally{if(t)try{this[rt](()=>{})}catch{}}}[Ti](t){t()}[rt](t=()=>{}){this.fd!==void 0&&p.closeSync(this.fd),t()}},Ks=class extends wt{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(t,e,i={}){return ze(this,t,e,i)}constructor(t,e={}){let i=ji(e);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=t;let{type:s}=t;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=f(t.path),this.mode=t.mode===void 0?void 0:this[Be](t.mode),this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:i.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath===void 0?void 0:f(t.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=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new ot({path:this[Z](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Z](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 he({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[Z](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Z](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),t.pipe(this)}[Z](t){return Ys(t,this.prefix)}[Be](t){return $s(t,this.type==="Directory",this.portable)}write(t,e,i){typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let s=t.length;if(s>this.blockRemain)throw Error("writing more to entry than is appropriate");return this.blockRemain-=s,super.write(t,i)}end(t,e,i){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),i&&this.once("finish",i),t?super.end(t,i):super.end(i),this}},Lh=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",xh=class Dt{tail;head;length=0;static create(e=[]){return new Dt(e)}constructor(e=[]){for(let i of e)this.push(i)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw Error("removing node which does not belong to this list");let i=e.next,s=e.prev;return i&&(i.prev=s),s&&(s.next=i),e===this.head&&(this.head=i),e===this.tail&&(this.tail=s),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,i}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let i=this.head;e.list=this,e.next=i,i&&(i.prev=e),this.head=e,this.tail||=e,this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let i=this.tail;e.list=this,e.prev=i,i&&(i.next=e),this.tail=e,this.head||=e,this.length++}push(...e){for(let i=0,s=e.length;i<s;i++)Ah(this,e[i]);return this.length}unshift(...e){for(var i=0,s=e.length;i<s;i++)Nh(this,e[i]);return this.length}pop(){if(!this.tail)return;let e=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--,e}shift(){if(!this.head)return;let e=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--,e}forEach(e,i){i||=this;for(let s=this.head,r=0;s;r++)e.call(i,s.value,r,this),s=s.next}forEachReverse(e,i){i||=this;for(let s=this.tail,r=this.length-1;s;r--)e.call(i,s.value,r,this),s=s.prev}get(e){let i=0,s=this.head;for(;s&&i<e;i++)s=s.next;if(i===e&&s)return s.value}getReverse(e){let i=0,s=this.tail;for(;s&&i<e;i++)s=s.prev;if(i===e&&s)return s.value}map(e,i){i||=this;let s=new Dt;for(let r=this.head;r;)s.push(e.call(i,r.value,this)),r=r.next;return s}mapReverse(e,i){i||=this;var s=new Dt;for(let r=this.tail;r;)s.push(e.call(i,r.value,this)),r=r.prev;return s}reduce(e,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=e(s,r.value,h),r=r.next;return s}reduceReverse(e,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=e(s,r.value,h),r=r.prev;return s}toArray(){let e=Array(this.length);for(let i=0,s=this.head;s;i++)e[i]=s.value,s=s.next;return e}toArrayReverse(){let e=Array(this.length);for(let i=0,s=this.tail;s;i++)e[i]=s.value,s=s.prev;return e}slice(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let s=new Dt;if(i<e||i<0)return s;e<0&&(e=0),i>this.length&&(i=this.length);let r=this.head,h=0;for(h=0;r&&h<e;h++)r=r.next;for(;r&&h<i;h++,r=r.next)s.push(r.value);return s}sliceReverse(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let s=new Dt;if(i<e||i<0)return s;e<0&&(e=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>e;r--,h=h.prev)s.push(h.value);return s}splice(e,i=0,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let r=this.head;for(let n=0;r&&n<e;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=Dh(this,r,n);return h}reverse(){let e=this.head,i=this.tail;for(let s=e;s;s=s.prev){let r=s.prev;s.prev=s.next,s.next=r}return this.head=i,this.tail=e,this}};function Dh(t,e,i){let s=new Vi(i,e,e?e.next:t.head,t);return s.next===void 0&&(t.tail=s),s.prev===void 0&&(t.head=s),t.length++,s}function Ah(t,e){t.tail=new Vi(e,t.tail,void 0,t),t.head||=t.tail,t.length++}function Nh(t,e){t.head=new Vi(e,void 0,t.head,t),t.tail||=t.head,t.length++}var Vi=class{list;next;prev;value;constructor(t,e,i,s){this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,i?(i.prev=this,this.next=i):this.next=void 0}},Li=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},ps=Buffer.alloc(1024),Le=Symbol("onStat"),$t=Symbol("ended"),F=Symbol("queue"),Yt=Symbol("pendingLinks"),tt=Symbol("current"),vt=Symbol("process"),Vt=Symbol("processing"),we=Symbol("processJob"),M=Symbol("jobs"),li=Symbol("jobDone"),xe=Symbol("addFSEntry"),vs=Symbol("addTarEntry"),xi=Symbol("stat"),Di=Symbol("readdir"),De=Symbol("onreaddir"),Ae=Symbol("pipe"),ys=Symbol("entry"),di=Symbol("entryOpt"),Ne=Symbol("writeEntryClass"),Xs=Symbol("write"),ui=Symbol("ondrain"),ae=class extends wt{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Ne];onWriteEntry;[F];[Yt]=new Map;[M]=0;[Vt]=!1;[$t]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=f(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Ne]=Yi,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if(+!!t.gzip+ +!!t.brotli+ +!!t.zstd>1)throw TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new $r(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Vr(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Xr(t.zstd)),!this.zip)throw Error("impossible");let e=this.zip;e.on("data",i=>super.write(i)),e.on("end",()=>super.end()),e.on("drain",()=>this[ui]()),this.on("resume",()=>e.resume())}else this.on("drain",this[ui]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[F]=new xh,this[M]=0,this.jobs=Number(t.jobs)||4,this[Vt]=!1,this[$t]=!1}[Xs](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e=void 0),t&&this.add(t),this[$t]=!0,this[vt](),i&&i(),this}write(t){if(this[$t])throw Error("write after end");return typeof t=="string"?this[xe](t):this[vs](t),this.flowing}[vs](t){let e=f(re.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let i=new Li(t.path,e);i.entry=new Ks(t,this[di](i)),i.entry.on("end",()=>this[li](i)),this[M]+=1,this[F].push(i)}this[vt]()}[xe](t){let e=f(re.resolve(this.cwd,t));this[F].push(new Li(t,e)),this[vt]()}[xi](t){t.pending=!0,this[M]+=1,p[this.follow?"stat":"lstat"](t.absolute,(e,i)=>{t.pending=!1,--this[M],e?this.emit("error",e):this[Le](t,i)})}[Le](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[tt])this[we](t);else{let i=`${e.dev}:${e.ino}`,s=this[Yt].get(i);s?s.push(t):this[Yt].set(i,[t]),t.pendingLink=!0,t.pending=!0}this[vt]()}[Di](t){t.pending=!0,this[M]+=1,p.readdir(t.absolute,(e,i)=>{if(t.pending=!1,--this[M],e)return this.emit("error",e);this[De](t,i)})}[De](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[vt]()}[vt](){if(!this[Vt]){this[Vt]=!0;for(let t=this[F].head;t&&this[M]<this.jobs;t=t.next)if(this[we](t.value),t.value.ignore){let e=t.next;this[F].removeNode(t),t.next=e}this[Vt]=!1,this[$t]&&this[F].length===0&&this[M]===0&&(this.zip?this.zip.end(ps):(super.write(ps),super.end()))}}get[tt](){return this[F]&&this[F].head&&this[F].head.value}[li](t){this[F].shift(),--this[M];let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let i=`${e.dev}:${e.ino}`,s=this[Yt].get(i);if(s){this[Yt].delete(i);for(let r of s)r.pending=!1,this[we](r)}}this[vt]()}[we](t){if(t.pending&&t.pendingLink&&t===this[tt]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[tt]&&!t.piped&&this[Ae](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Le](t,e):this[xi](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[De](t,e):this[Di](t),!t.readdir)return}if(t.entry=this[ys](t),!t.entry){t.ignore=!0;return}t===this[tt]&&!t.piped&&this[Ae](t)}}}[di](t){return{onwarn:(e,i,s)=>this.warn(e,i,s),noPax:this.noPax,cwd:this.cwd,absolute:t.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](t){this[M]+=1;try{return new this[Ne](t.path,this[di](t)).on("end",()=>this[li](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[ui](){this[tt]&&this[tt].entry&&this[tt].entry.resume()}[Ae](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let r=t.path,h=r==="./"?"":r.replace(/\/*$/,"/");this[xe](h+s)});let e=t.entry,i=this.zip;if(!e)throw Error("cannot pipe without source");i?e.on("data",s=>{i.write(s)||e.pause()}):e.on("data",s=>{super.write(s)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,i={}){ze(this,t,e,i)}},je=class extends ae{sync=!0;constructor(t){super(t),this[Ne]=Vs}pause(){}resume(){}[xi](t){let e=this.follow?"statSync":"lstatSync";this[Le](t,p[e](t.absolute))}[Di](t){this[De](t,p.readdirSync(t.absolute))}[Ae](t){let e=t.entry,i=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let r=t.path,h=r==="./"?"":r.replace(/\/*$/,"/");this[xe](h+s)}),!e)throw Error("Cannot pipe without source");i?e.on("data",s=>{i.write(s)}):e.on("data",s=>{super[Xs](s)})}},Ih=(t,e)=>{let i=new je(t),s=new Ms(t.file,{mode:t.mode||438});i.pipe(s),qs(i,e)},Bh=(t,e)=>{let i=new ae(t),s=new Ce(t.file,{mode:t.mode||438});i.pipe(s);let r=new Promise((h,n)=>{s.on("error",n),s.on("close",h),i.on("error",n)});return Qs(i,e).catch(h=>i.emit("error",h)),r},qs=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?Bt({file:c.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(i)}),t.end()},Qs=async(t,e)=>{for(let i of e)i.charAt(0)==="@"?await Bt({file:c.resolve(String(t.cwd),i.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(i);t.end()},bs=ne(Ih,Bh,(t,e)=>{let i=new je(t);return qs(i,e),i},(t,e)=>{let i=new ae(t);return Qs(i,e).catch(s=>i.emit("error",s)),i},(t,e)=>{if(!e?.length)throw TypeError("no paths specified to add to archive")}),Js=(process.env.__FAKE_PLATFORM__||process.platform)==="win32",{O_CREAT:tr,O_NOFOLLOW:gs,O_TRUNC:er,O_WRONLY:ir}=p.constants,sr=Number(process.env.__FAKE_FS_O_FILENAME__)||p.constants.UV_FS_O_FILEMAP||0,Fh=Js&&!!sr,Mh=512*1024,Ch=sr|er|tr|ir,Es=!Js&&typeof gs=="number"?gs|er|tr|ir:null,rr=Es===null?Fh?t=>t<Mh?Ch:"w":()=>"w":()=>Es,Ai=(t,e,i)=>{try{return d.lchownSync(t,e,i)}catch(s){if(s?.code!=="ENOENT")throw s}},Fe=(t,e,i,s)=>{d.lchown(t,e,i,r=>{s(r&&r?.code!=="ENOENT"?r:null)})},Ph=(t,e,i,s,r)=>{e.isDirectory()?hr(c.resolve(t,e.name),i,s,h=>{if(h)return r(h);Fe(c.resolve(t,e.name),i,s,r)}):Fe(c.resolve(t,e.name),i,s,r)},hr=(t,e,i,s)=>{d.readdir(t,{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 Fe(t,e,i,s);let n=h.length,a=null,o=l=>{if(!a){if(l)return s(a=l);if(--n===0)return Fe(t,e,i,s)}};for(let l of h)Ph(t,l,e,i,o)})},zh=(t,e,i,s)=>{e.isDirectory()&&nr(c.resolve(t,e.name),i,s),Ai(c.resolve(t,e.name),i,s)},nr=(t,e,i)=>{let s;try{s=d.readdirSync(t,{withFileTypes:!0})}catch(r){let h=r;if(h?.code==="ENOENT")return;if(h?.code==="ENOTDIR"||h?.code==="ENOTSUP")return Ai(t,e,i);throw h}for(let r of s)zh(t,r,e,i);return Ai(t,e,i)},ar=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},He=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Uh=(t,e)=>{d.stat(t,(i,s)=>{(i||!s.isDirectory())&&(i=new ar(t,i?.code||"ENOTDIR")),e(i)})},jh=(t,e,i)=>{t=f(t);let s=e.umask??18,r=e.mode|448,h=(r&s)!==0,n=e.uid,a=e.gid,o=typeof n=="number"&&typeof a=="number"&&(n!==e.processUid||a!==e.processGid),l=e.preserve,u=e.unlink,y=f(e.cwd),b=(k,w)=>{k?i(k):w&&o?hr(w,n,a,T=>b(T)):h?d.chmod(t,r,i):i()};if(t===y)return Uh(t,b);if(l)return cr.mkdir(t,{mode:r,recursive:!0}).then(k=>b(null,k??void 0),b);Ni(y,f(c.relative(y,t)).split("/"),r,u,y,void 0,b)},Ni=(t,e,i,s,r,h,n)=>{if(e.length===0)return n(null,h);let a=e.shift(),o=f(c.resolve(t+"/"+a));d.mkdir(o,i,or(o,e,i,s,r,h,n))},or=(t,e,i,s,r,h,n)=>a=>{a?d.lstat(t,(o,l)=>{if(o)o.path=o.path&&f(o.path),n(o);else if(l.isDirectory())Ni(t,e,i,s,r,h,n);else if(s)d.unlink(t,u=>{if(u)return n(u);d.mkdir(t,i,or(t,e,i,s,r,h,n))});else{if(l.isSymbolicLink())return n(new He(t,t+"/"+e.join("/")));n(a)}}):(h||=t,Ni(t,e,i,s,r,h,n))},Hh=t=>{let e=!1,i;try{e=d.statSync(t).isDirectory()}catch(s){i=s?.code}finally{if(!e)throw new ar(t,i??"ENOTDIR")}},Zh=(t,e)=>{t=f(t);let i=e.umask??18,s=e.mode|448,r=(s&i)!==0,h=e.uid,n=e.gid,a=typeof h=="number"&&typeof n=="number"&&(h!==e.processUid||n!==e.processGid),o=e.preserve,l=e.unlink,u=f(e.cwd),y=w=>{w&&a&&nr(w,h,n),r&&d.chmodSync(t,s)};if(t===u)return Hh(u),y();if(o)return y(d.mkdirSync(t,{mode:s,recursive:!0})??void 0);let b=f(c.relative(u,t)).split("/"),k;for(let w=b.shift(),T=u;w&&(T+="/"+w);w=b.shift()){T=f(c.resolve(T));try{d.mkdirSync(T,s),k||=T}catch{let Ki=d.lstatSync(T);if(Ki.isDirectory())continue;if(l){d.unlinkSync(T),d.mkdirSync(T,s),k||=T;continue}else if(Ki.isSymbolicLink())return new He(T,T+"/"+b.join("/"))}}return y(k)},fi=Object.create(null),ws=1e4,Ot=new Set,Wh=t=>{Ot.has(t)?Ot.delete(t):fi[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),Ot.add(t);let e=fi[t],i=Ot.size-ws;if(i>ws/10){for(let s of Ot)if(Ot.delete(s),delete fi[s],--i<=0)break}return e},Gh=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32",$h=t=>t.split("/").slice(0,-1).reduce((e,i)=>{let s=e.at(-1);return s!==void 0&&(i=Ns(s,i)),e.push(i||"/"),e},[]),Yh=class{#t=new Map;#i=new Map;#s=new Set;reserve(t,e){t=Gh?["win32 parallelization disabled"]:t.map(s=>Qt(Ns(Wh(s))));let i=new Set(t.map(s=>$h(s)).reduce((s,r)=>s.concat(r)));this.#i.set(e,{dirs:i,paths:t});for(let s of t){let r=this.#t.get(s);r?r.push(e):this.#t.set(s,[e])}for(let s of i){let r=this.#t.get(s);if(!r)this.#t.set(s,[new Set([e])]);else{let h=r.at(-1);h instanceof Set?h.add(e):r.push(new Set([e]))}}return this.#r(e)}#h(t){let e=this.#i.get(t);if(!e)throw Error("function does not have any path reservations");return{paths:e.paths.map(i=>this.#t.get(i)),dirs:[...e.dirs].map(i=>this.#t.get(i))}}check(t){let{paths:e,dirs:i}=this.#h(t);return e.every(s=>s&&s[0]===t)&&i.every(s=>s&&s[0]instanceof Set&&s[0].has(t))}#r(t){return this.#s.has(t)||!this.check(t)?!1:(this.#s.add(t),t(()=>this.#e(t)),!0)}#e(t){if(!this.#s.has(t))return!1;let e=this.#i.get(t);if(!e)throw Error("invalid reservation");let{paths:i,dirs:s}=e,r=new Set;for(let h of i){let n=this.#t.get(h);if(!n||n?.[0]!==t)continue;let a=n[1];if(!a){this.#t.delete(h);continue}if(n.shift(),typeof a=="function")r.add(a);else for(let o of a)r.add(o)}for(let h of s){let n=this.#t.get(h),a=n?.[0];if(!(!n||!(a instanceof Set)))if(a.size===1&&n.length===1){this.#t.delete(h);continue}else if(a.size===1){n.shift();let o=n[0];typeof o=="function"&&r.add(o)}else a.delete(t)}return this.#s.delete(t),r.forEach(h=>this.#r(h)),!0}},Vh=()=>process.umask(),Rs=Symbol("onEntry"),Ii=Symbol("checkFs"),_s=Symbol("checkFs2"),Bi=Symbol("isReusable"),I=Symbol("makeFs"),Fi=Symbol("file"),Mi=Symbol("directory"),Ie=Symbol("link"),Ss=Symbol("symlink"),Os=Symbol("hardlink"),Xt=Symbol("ensureNoSymlink"),ks=Symbol("unsupported"),Ts=Symbol("checkPath"),ci=Symbol("stripAbsolutePath"),ht=Symbol("mkdir"),O=Symbol("onError"),Re=Symbol("pending"),Ls=Symbol("pend"),kt=Symbol("unpend"),mi=Symbol("ended"),pi=Symbol("maybeClose"),Ci=Symbol("skip"),Jt=Symbol("doChown"),te=Symbol("uid"),ee=Symbol("gid"),ie=Symbol("checkedCwd"),se=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32",Kh=1024,Xh=(t,e)=>{if(!se)return d.unlink(t,e);let i=t+".DELETE."+Bs(16).toString("hex");d.rename(t,i,s=>{if(s)return e(s);d.unlink(i,e)})},qh=t=>{if(!se)return d.unlinkSync(t);let e=t+".DELETE."+Bs(16).toString("hex");d.renameSync(t,e),d.unlinkSync(e)},xs=(t,e,i)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:i,Me=class extends At{[mi]=!1;[ie]=!1;[Re]=0;reservations=new Yh;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(t={}){if(t.ondone=()=>{this[mi]=!0,this[pi]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?process.getuid?.()===0:!!t.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 t.maxDepth=="number"?t.maxDepth:Kh,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||se,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=f(c.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Vh():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Rs](e))}warn(t,e,i={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(i.recoverable=!1),super.warn(t,e,i)}[pi](){this[mi]&&this[Re]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[ci](t,e){let i=t[e],{type:s}=t;if(!i||this.preservePaths)return!0;let[r,h]=Gi(i),n=h.replaceAll(/\\/g,"/").split("/");if(n.includes("..")||se&&/^[a-z]:\.\.$/i.test(n[0]??"")){if(e==="path"||s==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:i}),!1;let a=c.posix.dirname(t.path),o=c.posix.normalize(c.posix.join(a,n.join("/")));if(o.startsWith("../")||o==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:i}),!1}return r&&(t[e]=String(h),this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute ${e}`,{entry:t,[e]:i})),!0}[Ts](t){let e=f(t.path),i=e.split("/");if(this.strip){if(i.length<this.strip)return!1;if(t.type==="Link"){let s=f(String(t.linkpath)).split("/");if(s.length>=this.strip)t.linkpath=s.slice(this.strip).join("/");else return!1}i.splice(0,this.strip),t.path=i.join("/")}if(isFinite(this.maxDepth)&&i.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:i.length,maxDepth:this.maxDepth}),!1;if(!this[ci](t,"path")||!this[ci](t,"linkpath"))return!1;if(t.absolute=c.isAbsolute(t.path)?f(c.resolve(t.path)):f(c.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:f(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:s}=c.win32.parse(String(t.absolute));t.absolute=s+ds(String(t.absolute).slice(s.length));let{root:r}=c.win32.parse(t.path);t.path=r+ds(t.path.slice(r.length))}return!0}[Rs](t){if(!this[Ts](t))return t.resume();switch(wr.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode|=448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Ii](t);default:return this[ks](t)}}[O](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[kt](),e.resume())}[ht](t,e,i){jh(f(t),{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:e},i)}[Jt](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[te](t){return xs(this.uid,t.uid,this.processUid)}[ee](t){return xs(this.gid,t.gid,this.processGid)}[Fi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new Ce(String(t.absolute),{flags:rr(t.size),mode:i,autoClose:!1});s.on("error",a=>{s.fd&&d.close(s.fd,()=>{}),s.write=()=>!0,this[O](a,t),e()});let r=1,h=a=>{if(a){s.fd&&d.close(s.fd,()=>{}),this[O](a,t),e();return}--r===0&&s.fd!==void 0&&d.close(s.fd,o=>{o?this[O](o,t):this[kt](),e()})};s.on("finish",()=>{let a=String(t.absolute),o=s.fd;if(typeof o=="number"&&t.mtime&&!this.noMtime){r++;let l=t.atime||new Date,u=t.mtime;d.futimes(o,l,u,y=>y?d.utimes(a,l,u,b=>h(b&&y)):h())}if(typeof o=="number"&&this[Jt](t)){r++;let l=this[te](t),u=this[ee](t);typeof l=="number"&&typeof u=="number"&&d.fchown(o,l,u,y=>y?d.chown(a,l,u,b=>h(b&&y)):h())}h()});let n=this.transform&&this.transform(t)||t;n!==t&&(n.on("error",a=>{this[O](a,t),e()}),t.pipe(n)),n.pipe(s)}[Mi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.dmode;this[ht](String(t.absolute),i,s=>{if(s){this[O](s,t),e();return}let r=1,h=()=>{--r===0&&(e(),this[kt](),t.resume())};t.mtime&&!this.noMtime&&(r++,d.utimes(String(t.absolute),t.atime||new Date,t.mtime,h)),this[Jt](t)&&(r++,d.chown(String(t.absolute),Number(this[te](t)),Number(this[ee](t)),h)),h()})}[ks](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Ss](t,e){let i=f(c.relative(this.cwd,c.resolve(c.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Xt](t,this.cwd,i,()=>this[Ie](t,String(t.linkpath),"symlink",e),s=>{this[O](s,t),e()})}[Os](t,e){let i=f(c.resolve(this.cwd,String(t.linkpath))),s=f(String(t.linkpath)).split("/");this[Xt](t,this.cwd,s,()=>this[Ie](t,i,"link",e),r=>{this[O](r,t),e()})}[Xt](t,e,i,s,r){let h=i.shift();if(this.preservePaths||h===void 0)return s();let n=c.resolve(e,h);d.lstat(n,(a,o)=>{if(a)return s();if(o?.isSymbolicLink())return r(new He(n,c.resolve(n,i.join("/"))));this[Xt](t,n,i,s,r)})}[Ls](){this[Re]++}[kt](){this[Re]--,this[pi]()}[Ci](t){this[kt](),t.resume()}[Bi](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!se}[Ii](t){this[Ls]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,i=>this[_s](t,i))}[_s](t,e){let i=n=>{e(n)},s=()=>{this[ht](this.cwd,this.dmode,n=>{if(n){this[O](n,t),i();return}this[ie]=!0,r()})},r=()=>{if(t.absolute!==this.cwd){let n=f(c.dirname(String(t.absolute)));if(n!==this.cwd)return this[ht](n,this.dmode,a=>{if(a){this[O](a,t),i();return}h()})}h()},h=()=>{d.lstat(String(t.absolute),(n,a)=>{if(a&&(this.keep||this.newer&&a.mtime>(t.mtime??a.mtime))){this[Ci](t),i();return}if(n||this[Bi](t,a))return this[I](null,t,i);if(a.isDirectory()){if(t.type==="Directory"){let o=this.chmod&&t.mode&&(a.mode&4095)!==t.mode,l=u=>this[I](u??null,t,i);return o?d.chmod(String(t.absolute),Number(t.mode),l):l()}if(t.absolute!==this.cwd)return d.rmdir(String(t.absolute),o=>this[I](o??null,t,i))}if(t.absolute===this.cwd)return this[I](null,t,i);Xh(String(t.absolute),o=>this[I](o??null,t,i))})};this[ie]?r():s()}[I](t,e,i){if(t){this[O](t,e),i();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Fi](e,i);case"Link":return this[Os](e,i);case"SymbolicLink":return this[Ss](e,i);case"Directory":case"GNUDumpDir":return this[Mi](e,i)}}[Ie](t,e,i,s){d[i](e,String(t.absolute),r=>{r?this[O](r,t):(this[kt](),t.resume()),s()})}},Kt=t=>{try{return[null,t()]}catch(e){return[e,null]}},Pi=class extends Me{sync=!0;[I](t,e){return super[I](t,e,()=>{})}[Ii](t){if(!this[ie]){let r=this[ht](this.cwd,this.dmode);if(r)return this[O](r,t);this[ie]=!0}if(t.absolute!==this.cwd){let r=f(c.dirname(String(t.absolute)));if(r!==this.cwd){let h=this[ht](r,this.dmode);if(h)return this[O](h,t)}}let[e,i]=Kt(()=>d.lstatSync(String(t.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(t.mtime??i.mtime)))return this[Ci](t);if(e||this[Bi](t,i))return this[I](null,t);if(i.isDirectory()){if(t.type==="Directory"){let[h]=this.chmod&&t.mode&&(i.mode&4095)!==t.mode?Kt(()=>{d.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[I](h,t)}let[r]=Kt(()=>d.rmdirSync(String(t.absolute)));this[I](r,t)}let[s]=t.absolute===this.cwd?[]:Kt(()=>qh(String(t.absolute)));this[I](s,t)}[Fi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,s=n=>{let a;try{d.closeSync(r)}catch(o){a=o}(n||a)&&this[O](n||a,t),e()},r;try{r=d.openSync(String(t.absolute),rr(t.size),i)}catch(n){return s(n)}let h=this.transform&&this.transform(t)||t;h!==t&&(h.on("error",n=>this[O](n,t)),t.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(t.mtime&&!this.noMtime){let a=t.atime||new Date,o=t.mtime;try{d.futimesSync(r,a,o)}catch(l){try{d.utimesSync(String(t.absolute),a,o)}catch{n=l}}}if(this[Jt](t)){let a=this[te](t),o=this[ee](t);try{d.fchownSync(r,Number(a),Number(o))}catch(l){try{d.chownSync(String(t.absolute),Number(a),Number(o))}catch{n||=l}}}s(n)})}[Mi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[ht](String(t.absolute),i);if(s){this[O](s,t),e();return}if(t.mtime&&!this.noMtime)try{d.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Jt](t))try{d.chownSync(String(t.absolute),Number(this[te](t)),Number(this[ee](t)))}catch{}e(),t.resume()}[ht](t,e){try{return Zh(f(t),{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:e})}catch(i){return i}}[Xt](t,e,i,s,r){if(this.preservePaths||i.length===0)return s();let h=e;for(let n of i){h=c.resolve(h,n);let[a,o]=Kt(()=>d.lstatSync(h));if(a)return s();if(o.isSymbolicLink())return r(new He(h,c.resolve(e,i.join("/"))))}s()}[Ie](t,e,i,s){let r=`${i}Sync`;try{d[r](e,String(t.absolute)),s(),t.resume()}catch(h){return this[O](h,t)}}},Ds=ne(t=>{let e=new Pi(t),i=t.file,s=d.statSync(i);new Fr(i,{readSize:t.maxReadSize||16*1024*1024,size:s.size}).pipe(e)},(t,e)=>{let i=new Me(t),s=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((h,n)=>{i.on("error",n),i.on("close",h),d.stat(r,(a,o)=>{if(a)n(a);else{let l=new Ui(r,{readSize:s,size:o.size});l.on("error",n),l.pipe(i)}})})},t=>new Pi(t),t=>new Me(t),(t,e)=>{e?.length&&Wi(t,e)}),Qh=(t,e)=>{let i=new je(t),s=!0,r,h;try{try{r=d.openSync(t.file,"r+")}catch(o){if(o?.code==="ENOENT")r=d.openSync(t.file,"w+");else throw o}let n=d.fstatSync(r),a=Buffer.alloc(512);t:for(h=0;h<n.size;h+=512){for(let u=0,y=0;u<512;u+=y){if(y=d.readSync(r,a,u,a.length-u,h+u),h===0&&a[0]===31&&a[1]===139)throw Error("cannot append to compressed archives");if(!y)break t}let o=new ot(a);if(!o.cksumValid)break;let l=512*Math.ceil((o.size||0)/512);if(h+l+512>n.size)break;h+=l,t.mtimeCache&&o.mtime&&t.mtimeCache.set(String(o.path),o.mtime)}s=!1,Jh(t,i,h,r,e)}finally{if(s)try{d.closeSync(r)}catch{}}},Jh=(t,e,i,s,r)=>{let h=new Ms(t.file,{fd:s,start:i});e.pipe(h),en(e,r)},tn=(t,e)=>{e=Array.from(e);let i=new ae(t),s=(r,h,n)=>{let a=(b,k)=>{b?d.close(r,w=>n(b)):n(null,k)},o=0;if(h===0)return a(null,0);let l=0,u=Buffer.alloc(512),y=(b,k)=>{if(b||k===void 0)return a(b);if(l+=k,l<512&&k)return d.read(r,u,l,u.length-l,o+l,y);if(o===0&&u[0]===31&&u[1]===139)return a(Error("cannot append to compressed archives"));if(l<512)return a(null,o);let w=new ot(u);if(!w.cksumValid)return a(null,o);let T=512*Math.ceil((w.size??0)/512);if(o+T+512>h||(o+=T+512,o>=h))return a(null,o);t.mtimeCache&&w.mtime&&t.mtimeCache.set(String(w.path),w.mtime),l=0,d.read(r,u,0,512,o,y)};d.read(r,u,0,512,o,y)};return new Promise((r,h)=>{i.on("error",h);let n="r+",a=(o,l)=>{if(o&&o.code==="ENOENT"&&n==="r+")return n="w+",d.open(t.file,n,a);if(o||!l)return h(o);d.fstat(l,(u,y)=>{if(u)return d.close(l,()=>h(u));s(l,y.size,(b,k)=>{if(b)return h(b);let w=new Ce(t.file,{fd:l,start:k});i.pipe(w),w.on("error",h),w.on("close",r),sn(i,e)})})};d.open(t.file,n,a)})},en=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?Bt({file:c.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(i)}),t.end()},sn=async(t,e)=>{for(let i of e)i.charAt(0)==="@"?await Bt({file:c.resolve(String(t.cwd),i.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(i);t.end()},yt=ne(Qh,tn,()=>{throw TypeError("file is required")},()=>{throw TypeError("file is required")},(t,e)=>{if(!jr(t))throw TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw TypeError("cannot append to compressed archives");if(!e?.length)throw TypeError("no paths specified to add/replace")});ne(yt.syncFile,yt.asyncFile,yt.syncNoFile,yt.asyncNoFile,(t,e=[])=>{yt.validate?.(t,e),rn(t)});var rn=t=>{let e=t.filter;t.mtimeCache||=new Map,t.filter=e?(i,s)=>e(i,s)&&!((t.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0)):(i,s)=>!((t.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0))};export{an as index_min_exports};
@@ -1 +1 @@
1
- import{createRequire as D}from"node:module";import{w as q}from"./target-merge-D1xbylFw.js";import{advisoriesQuery as C,advisoriesIngest as M,advisoriesStatus as S,NATIVE_BINDING_VERSION as w}from"#native";let I;const R=e=>(I??=D(import.meta.url))(e),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[t,s]=u.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return u.getBuiltinModule(e)}return R(e)},{randomUUID:T}=l("node:crypto"),{existsSync:O,createWriteStream:$}=l("node:fs"),{mkdir:L,unlink:U,stat:x}=l("node:fs/promises"),{join:g,dirname:P}=l("node:path"),{Readable:k}=l("node:stream"),{pipeline:B}=l("node:stream/promises"),p=6;if(w!==p)throw new Error(`vis native binding ABI mismatch in advisories: expected ${p}, got ${w}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const X="https://osv-vulnerabilities.storage.googleapis.com",W=new Set(["osv-vulnerabilities.storage.googleapis.com"]);class j extends Error{cause="DB_NOT_FOUND";constructor(t){super(`No local advisory DB at ${t}. Run 'vis advisories sync' first.`),this.name="AdvisoryDbNotFoundError"}}class y extends Error{cause="SOURCE_NOT_ALLOWED";constructor(t){super(`Advisory source host '${t}' is not in the built-in allowlist. Add it to \`security.audit.advisories.allowedHosts\` if intentional.`),this.name="AdvisorySourceNotAllowedError"}}class _ extends Error{cause="SYNC_NETWORK";constructor(t,s){super(`Advisory sync failed for ${t}: ${s}. Check connectivity, proxy env vars, or --source.`),this.name="AdvisorySyncNetworkError"}}const v=e=>{const s=q("vis",{create:!0,cwd:e})??g(e,"node_modules",".cache","vis");return g(s,"advisories","db.sqlite")},V=(e,t)=>{let s;try{s=new URL(e)}catch{throw new y(e)}if(s.protocol!=="https:")throw new y(`${s.protocol}//${s.host}`);if(!new Set([...W,...t??[]]).has(s.host))throw new y(s.host);return s},J=async e=>{const t=e.dbPath??v(e.workspaceRoot);await L(P(t),{recursive:!0});const s=V(e.source,e.allowedHosts),n=new URL(`${e.ecosystem}/all.zip`,G(s.toString())),a=await H(t,e.ecosystem);let o=null;if(!e.force){const i=await E(n,{method:"HEAD"});if(i.ok&&(o=i.headers.get("etag"),o&&a&&o===a))return{advisoriesIngested:0,dbPath:t,durationMs:0,upToDate:!0}}const c=`${t}.${e.ecosystem}.${process.pid}.${T()}.zip.tmp`,r=await E(n,{method:"GET"});if(!r.ok||!r.body)throw new _(n.toString(),r.status);o||(o=r.headers.get("etag"));const m=r.headers.get("content-length"),d=m?Number.parseInt(m,10):null;let h=0;const b=$(c),f=k.fromWeb(r.body);e.onProgress&&d&&f.on("data",i=>{h+=i.byteLength,e.onProgress?.(h,d,"download")}),await B(f,b);try{const i=await M({dbPath:t,ecosystem:e.ecosystem,manifestEtag:o??void 0,zipPath:c},(A,N)=>e.onProgress?.(A,N,"ingest"));return{advisoriesIngested:i.advisoriesIngested,dbPath:t,durationMs:i.durationMs,upToDate:!1}}finally{await U(c).catch(()=>{})}},Z=(e,t)=>{if(e.length===0)return new Map;const s=t.dbPath??v(t.workspaceRoot),n=t.ecosystem??"npm";if(!O(s))throw new j(s);const a=e.map(r=>({ecosystem:n,name:r.name,version:r.version})),o=C(s,a),c=new Map;for(const[r,m]of e.entries()){const d=o[r];!d||d.vulnerabilities.length===0||c.set(m.name,d.vulnerabilities.map(h=>z(h)))}return c},ee=async(e,t)=>{const s=t??v(e);return S(s)},H=async(e,t)=>{try{await x(e)}catch{return null}return S(e).ecosystems.find(a=>a.name===t)?.manifestEtag??null},z=e=>({aliases:e.aliases.length>0?e.aliases:void 0,cvssScore:e.cvssScore??void 0,fixedVersions:e.fixedVersions,id:e.id,severity:F(e.severity),summary:e.summary}),F=e=>{const t=e.toUpperCase();return t==="CRITICAL"||t==="HIGH"||t==="MODERATE"||t==="LOW"?t:"UNKNOWN"},G=e=>e.endsWith("/")?e:`${e}/`,E=async(e,t)=>{try{return await fetch(e,t)}catch(s){throw new _(e.toString(),s instanceof Error?s.message:String(s))}};export{j as A,X as D,ee as g,Z as q,v as r,J as s};
1
+ import{createRequire as D}from"node:module";import{L as q}from"./target-merge-B4No-LHM.js";import{advisoriesQuery as C,advisoriesIngest as M,advisoriesStatus as S,NATIVE_BINDING_VERSION as w}from"#native";let I;const R=e=>(I??=D(import.meta.url))(e),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[t,s]=u.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return u.getBuiltinModule(e)}return R(e)},{randomUUID:T}=l("node:crypto"),{existsSync:O,createWriteStream:L}=l("node:fs"),{mkdir:$,unlink:U,stat:x}=l("node:fs/promises"),{join:g,dirname:P}=l("node:path"),{Readable:k}=l("node:stream"),{pipeline:B}=l("node:stream/promises"),p=6;if(w!==p)throw new Error(`vis native binding ABI mismatch in advisories: expected ${p}, got ${w}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const X="https://osv-vulnerabilities.storage.googleapis.com",W=new Set(["osv-vulnerabilities.storage.googleapis.com"]);class j extends Error{cause="DB_NOT_FOUND";constructor(t){super(`No local advisory DB at ${t}. Run 'vis advisories sync' first.`),this.name="AdvisoryDbNotFoundError"}}class y extends Error{cause="SOURCE_NOT_ALLOWED";constructor(t){super(`Advisory source host '${t}' is not in the built-in allowlist. Add it to \`security.audit.advisories.allowedHosts\` if intentional.`),this.name="AdvisorySourceNotAllowedError"}}class _ extends Error{cause="SYNC_NETWORK";constructor(t,s){super(`Advisory sync failed for ${t}: ${s}. Check connectivity, proxy env vars, or --source.`),this.name="AdvisorySyncNetworkError"}}const v=e=>{const s=q("vis",{create:!0,cwd:e})??g(e,"node_modules",".cache","vis");return g(s,"advisories","db.sqlite")},V=(e,t)=>{let s;try{s=new URL(e)}catch{throw new y(e)}if(s.protocol!=="https:")throw new y(`${s.protocol}//${s.host}`);if(!new Set([...W,...t??[]]).has(s.host))throw new y(s.host);return s},J=async e=>{const t=e.dbPath??v(e.workspaceRoot);await $(P(t),{recursive:!0});const s=V(e.source,e.allowedHosts),n=new URL(`${e.ecosystem}/all.zip`,G(s.toString())),a=await H(t,e.ecosystem);let o=null;if(!e.force){const i=await E(n,{method:"HEAD"});if(i.ok&&(o=i.headers.get("etag"),o&&a&&o===a))return{advisoriesIngested:0,dbPath:t,durationMs:0,upToDate:!0}}const c=`${t}.${e.ecosystem}.${process.pid}.${T()}.zip.tmp`,r=await E(n,{method:"GET"});if(!r.ok||!r.body)throw new _(n.toString(),r.status);o||(o=r.headers.get("etag"));const m=r.headers.get("content-length"),d=m?Number.parseInt(m,10):null;let h=0;const b=L(c),f=k.fromWeb(r.body);e.onProgress&&d&&f.on("data",i=>{h+=i.byteLength,e.onProgress?.(h,d,"download")}),await B(f,b);try{const i=await M({dbPath:t,ecosystem:e.ecosystem,manifestEtag:o??void 0,zipPath:c},(A,N)=>e.onProgress?.(A,N,"ingest"));return{advisoriesIngested:i.advisoriesIngested,dbPath:t,durationMs:i.durationMs,upToDate:!1}}finally{await U(c).catch(()=>{})}},Z=(e,t)=>{if(e.length===0)return new Map;const s=t.dbPath??v(t.workspaceRoot),n=t.ecosystem??"npm";if(!O(s))throw new j(s);const a=e.map(r=>({ecosystem:n,name:r.name,version:r.version})),o=C(s,a),c=new Map;for(const[r,m]of e.entries()){const d=o[r];!d||d.vulnerabilities.length===0||c.set(m.name,d.vulnerabilities.map(h=>z(h)))}return c},ee=async(e,t)=>{const s=t??v(e);return S(s)},H=async(e,t)=>{try{await x(e)}catch{return null}return S(e).ecosystems.find(a=>a.name===t)?.manifestEtag??null},z=e=>({aliases:e.aliases.length>0?e.aliases:void 0,cvssScore:e.cvssScore??void 0,fixedVersions:e.fixedVersions,id:e.id,severity:F(e.severity),summary:e.summary}),F=e=>{const t=e.toUpperCase();return t==="CRITICAL"||t==="HIGH"||t==="MODERATE"||t==="LOW"?t:"UNKNOWN"},G=e=>e.endsWith("/")?e:`${e}/`,E=async(e,t)=>{try{return await fetch(e,t)}catch(s){throw new _(e.toString(),s instanceof Error?s.message:String(s))}};export{j as A,X as D,ee as g,Z as q,v as r,J as s};
@@ -1 +1 @@
1
- import{createRequire as C}from"node:module";import{getAffectedProjects as S}from"@visulima/task-runner";import{i as W}from"./index-BjdW45xX.js";import{V as j}from"./vis-user-error-jhNwmkZp.js";import{r as A}from"./affected-shas-Dd0P7fGD.js";let T;const $=e=>(T??=C(import.meta.url))(e),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=e=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,s]=f.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return f.getBuiltinModule(e)}return $(e)},{spawnSync:I}=R("node:child_process"),v=new Set(["deep","direct","none"]),B=e=>{const t=[],s=e.split("\0");for(let n=0;n<s.length;n++){const o=s[n];if(!o||o.length<4)continue;const p=o.slice(0,2),d=o.slice(3);if(d&&t.push(d),p.includes("R")||p.includes("C")){n+=1;const c=s[n];c&&t.push(c)}}return t},P=e=>{const t=I("git",["status","--porcelain","-z"],{cwd:e,encoding:"utf8"});return t.error||t.status!==0||typeof t.stdout!="string"?[]:B(t.stdout)},D=async(e,t,s={})=>{const n=e.downstream??"deep",o=e.upstream??"none";if(!v.has(n))throw new j(`Invalid --downstream value: "${n}". Must be "none", "direct", or "deep".`);if(!v.has(o))throw new j(`Invalid --upstream value: "${o}". Must be "none", "direct", or "deep".`);const{projectGraph:p,projects:d,workspaceRoot:c}=t,u=[];let{base:m}=e,{head:r}=e;if(!m||!r){const l=A({defaultBase:s.defaultBase,workspaceRoot:c});m=m||l.base,r=r||l.head,u.push(`Resolved affected refs from ${l.provider} (${l.notes.join("; ")})`)}const k=s.runningInCi??W,h=r==="HEAD"||r==="",b=e.uncommitted??(!k&&h);let a=[];if(b)if(h){const g=(s.readWorkingTreeChanges??P)(c),y=Object.values(d).map(i=>i.root?.replace(/\/$/,"")).filter(i=>!!i&&i!==".");a=g.filter(i=>y.some(_=>i===_||i.startsWith(`${_}/`)));const w=g.length-a.length;a.length>0&&u.push(`including ${a.length} uncommitted working-tree file(s)`),w>0&&u.push(`ignoring ${w} uncommitted path(s) outside any project (untracked scratch would otherwise mark every project affected)`)}else u.push(`ignoring --uncommitted: --head=${r} pins the comparison to a commit, not the working tree`);return{...await S({additionalChangedFiles:a,base:m,downstream:n,head:r,projectGraph:p,projects:d,upstream:o,workspaceRoot:c}),notes:u,uncommittedFileCount:a.length}};export{D as s};
1
+ import{createRequire as C}from"node:module";import{getAffectedProjects as S}from"@visulima/task-runner";import{i as W}from"./index-BjdW45xX.js";import{V as j}from"./vis-user-error-Dkc97rGY.js";import{r as A}from"./affected-shas-Dd0P7fGD.js";let T;const $=e=>(T??=C(import.meta.url))(e),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=e=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,s]=f.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return f.getBuiltinModule(e)}return $(e)},{spawnSync:I}=R("node:child_process"),v=new Set(["deep","direct","none"]),B=e=>{const t=[],s=e.split("\0");for(let n=0;n<s.length;n++){const o=s[n];if(!o||o.length<4)continue;const p=o.slice(0,2),d=o.slice(3);if(d&&t.push(d),p.includes("R")||p.includes("C")){n+=1;const c=s[n];c&&t.push(c)}}return t},P=e=>{const t=I("git",["status","--porcelain","-z"],{cwd:e,encoding:"utf8"});return t.error||t.status!==0||typeof t.stdout!="string"?[]:B(t.stdout)},D=async(e,t,s={})=>{const n=e.downstream??"deep",o=e.upstream??"none";if(!v.has(n))throw new j(`Invalid --downstream value: "${n}". Must be "none", "direct", or "deep".`);if(!v.has(o))throw new j(`Invalid --upstream value: "${o}". Must be "none", "direct", or "deep".`);const{projectGraph:p,projects:d,workspaceRoot:c}=t,u=[];let{base:m}=e,{head:r}=e;if(!m||!r){const l=A({defaultBase:s.defaultBase,workspaceRoot:c});m=m||l.base,r=r||l.head,u.push(`Resolved affected refs from ${l.provider} (${l.notes.join("; ")})`)}const k=s.runningInCi??W,h=r==="HEAD"||r==="",b=e.uncommitted??(!k&&h);let a=[];if(b)if(h){const g=(s.readWorkingTreeChanges??P)(c),y=Object.values(d).map(i=>i.root?.replace(/\/$/,"")).filter(i=>!!i&&i!==".");a=g.filter(i=>y.some(_=>i===_||i.startsWith(`${_}/`)));const w=g.length-a.length;a.length>0&&u.push(`including ${a.length} uncommitted working-tree file(s)`),w>0&&u.push(`ignoring ${w} uncommitted path(s) outside any project (untracked scratch would otherwise mark every project affected)`)}else u.push(`ignoring --uncommitted: --head=${r} pins the comparison to a commit, not the working tree`);return{...await S({additionalChangedFiles:a,base:m,downstream:n,head:r,projectGraph:p,projects:d,upstream:o,workspaceRoot:c}),notes:u,uncommittedFileCount:a.length}};export{D as s};
@@ -1,4 +1,4 @@
1
- import{createRequire as T}from"node:module";import{readLastRunSummary as _}from"@visulima/task-runner";import{a as $}from"./failure-log-D92tM0ie.js";import{m as v,n as P,o as D,d as j,q as E,s as N,t as A}from"../packem_chunks/cli-main.js";import{c as R}from"./formatBytes-BHAzNIrn-DFIppnY0.js";import{v as x,U as y,e as B,a as H}from"./index-DHD8wb6Z.js";import{a as q,b as C,e as U}from"./ai-analysis-DSQQDFU9.js";let I;const F=e=>(I??=T(import.meta.url))(e),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,n]=h.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return h.getBuiltinModule(e)}return F(e)},{readFile:L,writeFile:M}=O("node:fs/promises"),k=32*1024,W=(e,t)=>{if(e.length<=t)return e;const n=e.slice(-t),o=e.length-n.length;return`[…${String(o)} bytes truncated from head…]
1
+ import{createRequire as T}from"node:module";import{readLastRunSummary as _}from"@visulima/task-runner";import{a as $}from"./failure-log-D92tM0ie.js";import{n as v,o as P,q as D,f as j,s as E,t as N,u as A}from"../packem_chunks/cli-main.js";import{c as R}from"./formatBytes-BHAzNIrn-DFIppnY0.js";import{v as x,U as y,e as B,a as H}from"./index-DHD8wb6Z.js";import{a as q,b as C,e as U}from"./ai-analysis-DSQQDFU9.js";let I;const F=e=>(I??=T(import.meta.url))(e),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,n]=h.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return h.getBuiltinModule(e)}return F(e)},{readFile:L,writeFile:M}=O("node:fs/promises"),k=32*1024,W=(e,t)=>{if(e.length<=t)return e;const n=e.slice(-t),o=e.length-n.length;return`[…${String(o)} bytes truncated from head…]
2
2
  ${n}`},J=async(e,t)=>t===void 0?_(e,{dataDirectory:R(e)}):j(e,t),pe=async(e,t,n={})=>{const o=n.terminalOutputLimit??k,[r,i]=await Promise.all([$(e,t),J(e,n.runId)]),s=i?v(i,t):void 0;if(!r&&!s)return;let a,c;if(i&&s){const u=await P(e,i.id),f=u?v(u,t):void 0;a=D(s.hashDetails,f?.hashDetails),c=u?.id}const d=r?.terminalOutput??"";return{command:r?.command??void 0,cwd:r?.cwd??void 0,dependencies:s?.dependencies??[],duration:s?.duration,exitCode:r?.exitCode??s?.exitCode,hash:s?.hash??r?.hash,hashDetails:s?.hashDetails,hashDiff:a,previousRunId:c,project:s?.target.project,runId:i?.id??r?.runId,status:r?.status??(s?K(s):void 0),target:s?.target.target,taskId:t,terminalOutput:W(d,o),terminalOutputCaptured:!!r,timestamp:r?.timestamp??s?.endTime??s?.startTime}},K=e=>{if(e.exitCode!==void 0&&e.exitCode!==0)return"failure";switch(e.cacheStatus){case"HIT":return"local-cache";case"REMOTE_HIT":return"remote-cache";case"SKIPPED":return"skipped";default:return e.exitCode===0?"success":void 0}},Y=3600*1e3,w=80,V=new Set(["high","low","medium"]),X=()=>`You are an expert software engineer helping fix a failing build/test/lint task.
3
3
 
4
4
  You will be given:
@@ -1 +1 @@
1
- import{createRequire as v}from"node:module";import{t as T}from"./compile-cache-DoMHRsRZ.js";import{l as y,i as R,a as j,b as M,c as m,g as S}from"./package-version-BJkg7-6H.js";import{i as $}from"./index-BjdW45xX.js";let _;const x=s=>(_??=v(import.meta.url))(s),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=s=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,o]=t.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return t.getBuiltinModule(s)}return x(s)},{createRequire:w}=b("node:module");let N;const O=s=>(N??=w(import.meta.url))(s),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=s=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,o]=r.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return r.getBuiltinModule(s)}return O(s)},{execFileSync:C}=f("node:child_process"),{totalmem:I}=f("node:os"),q=/--max-old-space-size=(\d+)/,z=/--max-semi-space-size=(\d+)/,E=s=>Math.floor(I()/1024/1024*s),P=s=>s<=512?4:s<=1024?8:s<=2048?16:s<=4096?32:s<=8192?64:Math.floor(Math.log2(s))*8,d=(s,e)=>{for(const o of e){const n=s.exec(o);if(n)return Number.parseInt(n[1],10)}},B=s=>{const o=[...y()],n=[...R()],a=d(q,o),p=d(z,o);if(a!==void 0&&p!==void 0)return;const l=a??E(.75),g=p??P(l),c=[];if(a===void 0&&c.push(`--max-old-space-size=${String(l)}`),p===void 0&&c.push(`--max-semi-space-size=${String(g)}`),c.length!==0)try{C(j(),[...c,...o,...n.slice(1)],{env:M(),stdio:"inherit"}),m(0)}catch(h){const u=h.status;m(typeof u=="number"?u:1)}},V=()=>{process.env.VIS_VERSION=S()},H=s=>{!process.stdout.isTTY||$||process.env.TERM==="dumb"||process.stdout.write(`\x1B]0;${s}\x07`)},L=new Set(["","--help","--version","-h","-v","completion","dlx","exec","x"]),i=process.argv[2]??"";!L.has(i)&&!process.argv.includes("--help")&&!process.argv.includes("-h")&&B();process.argv.includes("--no-color")&&(process.env.NO_COLOR="1",process.env.FORCE_COLOR="0");V();T();(async()=>{if(i==="__pm-shim"){const{dispatchShim:e}=await import("../packem_chunks/dispatch.js");e(process.argv[3]??"",process.argv.slice(4));return}if(i==="x"){const{runLeanX:e}=await import("../packem_chunks/lean.js");await e(process.argv.slice(3));return}if(i==="exec"||i==="dlx"){const{runExecCli:e}=await import("../packem_chunks/cli-exec.js");await e();return}const{runCli:s}=await import("../packem_chunks/cli-main.js").then(e=>e.aw);await s()})();export{H as s};
1
+ import{createRequire as v}from"node:module";import{t as T}from"./compile-cache-DoMHRsRZ.js";import{l as y,i as R,a as j,b as M,c as m,g as S}from"./package-version-CJxZ_B7G.js";import{i as $}from"./index-BjdW45xX.js";let _;const x=s=>(_??=v(import.meta.url))(s),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=s=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,o]=t.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return t.getBuiltinModule(s)}return x(s)},{createRequire:w}=b("node:module");let N;const O=s=>(N??=w(import.meta.url))(s),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=s=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,o]=r.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return r.getBuiltinModule(s)}return O(s)},{execFileSync:C}=f("node:child_process"),{totalmem:I}=f("node:os"),q=/--max-old-space-size=(\d+)/,z=/--max-semi-space-size=(\d+)/,E=s=>Math.floor(I()/1024/1024*s),P=s=>s<=512?4:s<=1024?8:s<=2048?16:s<=4096?32:s<=8192?64:Math.floor(Math.log2(s))*8,d=(s,e)=>{for(const o of e){const n=s.exec(o);if(n)return Number.parseInt(n[1],10)}},B=s=>{const o=[...y()],n=[...R()],a=d(q,o),p=d(z,o);if(a!==void 0&&p!==void 0)return;const l=a??E(.75),g=p??P(l),c=[];if(a===void 0&&c.push(`--max-old-space-size=${String(l)}`),p===void 0&&c.push(`--max-semi-space-size=${String(g)}`),c.length!==0)try{C(j(),[...c,...o,...n.slice(1)],{env:M(),stdio:"inherit"}),m(0)}catch(h){const u=h.status;m(typeof u=="number"?u:1)}},V=()=>{process.env.VIS_VERSION=S()},H=s=>{!process.stdout.isTTY||$||process.env.TERM==="dumb"||process.stdout.write(`\x1B]0;${s}\x07`)},L=new Set(["","--help","--version","-h","-v","completion","dlx","exec","x"]),i=process.argv[2]??"";!L.has(i)&&!process.argv.includes("--help")&&!process.argv.includes("-h")&&B();process.argv.includes("--no-color")&&(process.env.NO_COLOR="1",process.env.FORCE_COLOR="0");V();T();(async()=>{if(i==="__pm-shim"){const{dispatchShim:e}=await import("../packem_chunks/dispatch.js");e(process.argv[3]??"",process.argv.slice(4));return}if(i==="x"){const{runLeanX:e}=await import("../packem_chunks/lean.js");await e(process.argv.slice(3));return}if(i==="exec"||i==="dlx"){const{runExecCli:e}=await import("../packem_chunks/cli-exec.js");await e();return}const{runCli:s}=await import("../packem_chunks/cli-main.js").then(e=>e.aw);await s()})();export{H as s};
@@ -1,4 +1,4 @@
1
- import{createRequire as ie}from"node:module";import{e as I,z as ue}from"./index-DHD8wb6Z.js";import{r as fe}from"./docker-Br_iFmI-.js";import{p as oe}from"./readJsonSync-CbryXYxN-B2aSeDpC.js";import{e as me}from"./license-DvlYdo6T.js";import{S as he}from"./lockfile-DhHAaHN5.js";import{a as _e}from"./index-B4AjSxHU.js";let ae;const pe=e=>(ae??=ie(import.meta.url))(e),J=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=e=>{if(typeof J<"u"&&J.versions&&J.versions.node){const[t,n]=J.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return J.getBuiltinModule(e)}return pe(e)},{randomUUID:le}=se("node:crypto"),{readdirSync:de}=se("node:fs"),H=e=>e.replaceAll(/[^\w.~-]/g,t=>`%${(t.codePointAt(0)??0).toString(16).toUpperCase().padStart(2,"0")}`),j=(e,t)=>{const n=e.toLowerCase();if(n.startsWith("@")){const s=n.indexOf("/");if(s>0){const c=n.slice(0,s),p=n.slice(s+1);return`pkg:npm/${H(c)}/${H(p)}@${H(t)}`}}return`pkg:npm/${H(n)}@${H(t)}`},d={ARRAY:"array",BOOLEAN:"boolean",DATE:"date",FUNCTION:"function",JSTOXML_OBJECT:"jstoxml-object",NULL:"null",NUMBER:"number",OBJECT:"object",STRING:"string"},ge=[d.STRING,d.NUMBER,d.BOOLEAN],ye='<?xml version="1.0" encoding="UTF-8"?>',ee=["_selfCloseTag","_attrs"],Oe=(e="",t=0)=>e.repeat(t),W=e=>Array.isArray(e)&&d.ARRAY||typeof e===d.OBJECT&&e!==null&&e._name&&d.JSTOXML_OBJECT||e instanceof Date&&d.DATE||e===null&&d.NULL||typeof e,re=e=>e.startsWith("<![CDATA["),ce=(e="",t={},n)=>{let s=e;if(typeof e===d.STRING){if(re(e))return e;const c=new RegExp(`(${Object.keys(t).join("|")})(?!(\\w|#)*;)`,"g");s=String(e).replace(c,(p,m)=>t[m]||"")}return typeof n=="function"?n(s):s},Se=(e={},t,n,s)=>(Array.isArray(e)?e:Object.entries(e).map(([p,m])=>({[p]:m}))).reduce((p,m)=>{const _=Object.keys(m)[0],O=m[_];if(typeof n===d.FUNCTION&&n(_,O))return p;const S=t?ce(O,t):O,v=!s&&S===!0?"":`="${S}"`;return p.push(`${_}${v}`),p},[]),Ce=(e={},t,n,s)=>{const c=Se(e,t,n,s);return c.length===0?"":` ${c.join(" ")}`},Ae=(e={})=>Object.keys(e).map(t=>({_name:t,_content:e[t]})),ve=e=>ge.includes(W(e)),Te=e=>!e.match("<"),Re=({header:e,isOutputStart:t})=>e&&t?typeof e===d.BOOLEAN?ye:e:"",te={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;"},B=(e={},t={})=>{const{depth:n=0,indent:s,_isFirstItem:c,_isOutputStart:p=!0,header:m,attributeReplacements:_={},attributeFilter:O,attributeExplicitTrue:S=!1,contentReplacements:v={},contentMap:x,selfCloseTags:L=!0}=t,Y=typeof _=="boolean"&&!_?{}:{...te,..._},k=typeof v=="boolean"&&!v?{}:{...te,...v},U=typeof s=="string",D=Oe(s,n),G=W(e),w=Re({header:m,isOutputStart:p}),b=p&&!w&&c&&n===0,X=U&&!b?`
1
+ import{createRequire as ie}from"node:module";import{e as I,z as ue}from"./index-DHD8wb6Z.js";import{r as fe}from"./docker-Bex05Qcn.js";import{p as oe}from"./readJsonSync-CbryXYxN-B2aSeDpC.js";import{e as me}from"./license-DvlYdo6T.js";import{S as he}from"./lockfile-DhHAaHN5.js";import{a as _e}from"./index-B4AjSxHU.js";let ae;const pe=e=>(ae??=ie(import.meta.url))(e),J=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=e=>{if(typeof J<"u"&&J.versions&&J.versions.node){const[t,n]=J.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return J.getBuiltinModule(e)}return pe(e)},{randomUUID:le}=se("node:crypto"),{readdirSync:de}=se("node:fs"),H=e=>e.replaceAll(/[^\w.~-]/g,t=>`%${(t.codePointAt(0)??0).toString(16).toUpperCase().padStart(2,"0")}`),j=(e,t)=>{const n=e.toLowerCase();if(n.startsWith("@")){const s=n.indexOf("/");if(s>0){const c=n.slice(0,s),p=n.slice(s+1);return`pkg:npm/${H(c)}/${H(p)}@${H(t)}`}}return`pkg:npm/${H(n)}@${H(t)}`},d={ARRAY:"array",BOOLEAN:"boolean",DATE:"date",FUNCTION:"function",JSTOXML_OBJECT:"jstoxml-object",NULL:"null",NUMBER:"number",OBJECT:"object",STRING:"string"},ge=[d.STRING,d.NUMBER,d.BOOLEAN],ye='<?xml version="1.0" encoding="UTF-8"?>',ee=["_selfCloseTag","_attrs"],Oe=(e="",t=0)=>e.repeat(t),W=e=>Array.isArray(e)&&d.ARRAY||typeof e===d.OBJECT&&e!==null&&e._name&&d.JSTOXML_OBJECT||e instanceof Date&&d.DATE||e===null&&d.NULL||typeof e,re=e=>e.startsWith("<![CDATA["),ce=(e="",t={},n)=>{let s=e;if(typeof e===d.STRING){if(re(e))return e;const c=new RegExp(`(${Object.keys(t).join("|")})(?!(\\w|#)*;)`,"g");s=String(e).replace(c,(p,m)=>t[m]||"")}return typeof n=="function"?n(s):s},Se=(e={},t,n,s)=>(Array.isArray(e)?e:Object.entries(e).map(([p,m])=>({[p]:m}))).reduce((p,m)=>{const _=Object.keys(m)[0],O=m[_];if(typeof n===d.FUNCTION&&n(_,O))return p;const S=t?ce(O,t):O,v=!s&&S===!0?"":`="${S}"`;return p.push(`${_}${v}`),p},[]),Ce=(e={},t,n,s)=>{const c=Se(e,t,n,s);return c.length===0?"":` ${c.join(" ")}`},Ae=(e={})=>Object.keys(e).map(t=>({_name:t,_content:e[t]})),ve=e=>ge.includes(W(e)),Te=e=>!e.match("<"),Re=({header:e,isOutputStart:t})=>e&&t?typeof e===d.BOOLEAN?ye:e:"",te={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;"},B=(e={},t={})=>{const{depth:n=0,indent:s,_isFirstItem:c,_isOutputStart:p=!0,header:m,attributeReplacements:_={},attributeFilter:O,attributeExplicitTrue:S=!1,contentReplacements:v={},contentMap:x,selfCloseTags:L=!0}=t,Y=typeof _=="boolean"&&!_?{}:{...te,..._},k=typeof v=="boolean"&&!v?{}:{...te,...v},U=typeof s=="string",D=Oe(s,n),G=W(e),w=Re({header:m,isOutputStart:p}),b=p&&!w&&c&&n===0,X=U&&!b?`
2
2
  `:"";let C="";switch(G){case d.JSTOXML_OBJECT:{const{_name:h,_content:g}=e;if(g===null&&typeof x!="function"){C=`${X}${D}${h}`;break}if(Array.isArray(g)&&g.every(ve))return g.map(F=>B({_name:h,_content:F},{...t,depth:n,_isOutputStart:!1})).join("");if(ee.includes(h))break;const y=B(g,{...t,depth:n+1,_isOutputStart:b}),M=W(y),R=Te(y),r=re(y),o=`${X}${D}`;if(h==="_comment"){C+=`${o}<!-- ${g} -->`;break}const i=M==="undefined"||y==="",a=L,l=e._selfCloseTag,f=typeof l===d.BOOLEAN?i&&l:i&&a,E=f?"/":"",$=Ce(e._attrs,Y,O,S),T=`<${h}${$}${E}>`,A=U&&!R&&!r?`
3
3
  ${D}`:"",N=f?"":`${y}${A}</${h}>`;C+=`${o}${T}${N}`;break}case d.OBJECT:{const h=Object.keys(e);C=h.map((u,y)=>{const M={...t,_isFirstItem:y===0,_isLastItem:y+1===h.length,_isOutputStart:b},R={_name:u};if(W(e[u])===d.OBJECT&&(ee.forEach(i=>{const a=e[u][i];typeof a<"u"&&(R[i]=a,delete e[u][i])}),typeof e[u]._content<"u"&&Object.keys(e[u]).length>1)){const i=Object.assign({},e[u]);delete i._content,R._content=[...Ae(i),e[u]._content]}return typeof R._content>"u"&&(R._content=e[u]),B(R,M)},t).join("");break}case d.FUNCTION:{const h=e(t);C=B(h,t);break}case d.ARRAY:{C=e.map((g,u)=>{const y={...t,_isFirstItem:u===0,_isLastItem:u+1===e.length,_isOutputStart:b};return B(g,y)}).join("");break}default:{C=ce(e,k,x);break}}return`${w}${C}`},Q=e=>{try{return oe(e)}catch{return}},Ee=e=>{if(e.length===0||e.includes("..")||e.startsWith(".")||e.includes("\0")||e.includes("\\"))return!1;if(e.startsWith("@")){const t=e.indexOf("/");return t>1&&!e.includes("/",t+1)}return!e.includes("/")},$e=e=>e.length>0&&!e.includes("/")&&!e.includes("\\")&&!e.includes("..")&&!e.includes("\0"),be=(e,t,n)=>{const c=`${t.replaceAll("/","+")}@${n}`,p=I(e,"node_modules",".pnpm"),m=Q(I(p,c,"node_modules",t,"package.json"));if(m)return m;let _;try{_=de(p)}catch{return}const O=`${c}_`;for(const S of _){if(!S.startsWith(O))continue;const v=Q(I(p,S,"node_modules",t,"package.json"));if(v)return v}},Ne=(e,t,n)=>{const s=Q(I(e,"node_modules",t,"package.json"));return s?.version===n?s:void 0},xe=(e,t,n)=>{if(!(!Ee(t)||!$e(n)))return be(e,t,n)??Ne(e,t,n)},ke={sha256:"SHA-256",sha384:"SHA-384",sha512:"SHA-512"},De={sha256:64,sha384:96,sha512:128},we=e=>{const t={name:e.name,version:e.version},{integrity:n}=e;return n&&n.hex.length===De[n.algorithm]&&(t.hash={alg:ke[n.algorithm],content:n.hex}),e.dependencies&&(t.dependencies=e.dependencies),e.peerDependencies&&(t.peerDependencies=e.peerDependencies),e.optionalDependencies&&(t.optionalDependencies=e.optionalDependencies),t},je=[{file:"pnpm-lock.yaml",type:"pnpm"},{file:"npm-shrinkwrap.json",type:"npm"},{file:"package-lock.json",type:"npm"},{file:"yarn.lock",type:"yarn"},{file:"bun.lock",type:"bun"}],Ie=e=>{for(const{file:t,type:n}of je){let s;try{s=ue(I(e,t))}catch{continue}const c=new Map;for(const p of he(s,n))c.set(`${p.name}@${p.version}`,we(p));return{packages:c,type:n}}},Le=e=>{const t=e.indexOf(":");return t<=0?e:e.slice(0,t)==="npm"?e.slice(t+1):e},z=(e,t,n)=>{const s=n.get(e);if(!s||s.size===0)return;if(s.has(t))return t;const c=Le(t);if(c!==t&&s.has(c))return c;const p=[...s],m=_e.maxSatisfying(p,c,{includePrerelease:!0});return m||p[0]},Me="1.7",Pe="CycloneDX",Be="http://cyclonedx.org/schema/bom-1.7.schema.json",Ve="@visulima/vis",ne=e=>{try{return oe(e)}catch{return}},Ue=e=>{if(e){if(typeof e=="string")return e;if(typeof e=="object"&&e.name)return e.email?`${e.name} <${e.email}>`:e.name}},Xe=e=>{if(e)return typeof e=="string"?e:e.url},Fe=e=>{if(e)return typeof e=="string"?e:e.url},Je=e=>{const t=[];e.homepage&&t.push({type:"website",url:e.homepage});const n=Xe(e.repository);n&&t.push({type:"vcs",url:n});const s=Fe(e.bugs);return s&&t.push({type:"issue-tracker",url:s}),t.length>0?t:void 0},He=e=>e==="application"||e==="service"||e==="tool"?"application":"library",K=(e,t)=>{if(!t)return;t.description&&(e.description=t.description);const n=Ue(t.author);n&&(e.author=n);const s=me(t);s&&(e.licenses=s);const c=Je(t);c&&(e.externalReferences=c)},nt=e=>{const{focus:t,generatorVersion:n,includeDev:s=!1,now:c=new Date,projectGraph:p,serialNumber:m,workspace:_,workspaceRoot:O}=e,S=t&&t.length>0?[...fe(t,p)].sort():Object.keys(_.projects).sort(),v=new Set(S),x=new Map;for(const r of S){const o=_.projects[r];o&&x.set(r,ne(I(O,o.root,"package.json")))}const L=[],q=new Map;for(const r of S){const o=_.projects[r];if(!o)continue;const i=x.get(r),a=i?.version??"0.0.0",l=j(r,a);q.set(r,l);const f={"bom-ref":l,name:r,purl:l,type:He(o.projectType),version:a};K(f,i),L.push(f)}const Y=Ie(O),V=new Map,k=new Map;if(Y)for(const r of Y.packages.values()){V.set(`${r.name}@${r.version}`,r);let o=k.get(r.name);o||(o=new Set,k.set(r.name,o)),o.add(r.version)}const U=[],D=[],G=new Map;for(const r of S){const o=x.get(r);if(!o)continue;const i=[o.dependencies,o.peerDependencies];s&&i.push(o.devDependencies);const a=new Set,l=(f,E)=>{if(E)for(const[$,T]of Object.entries(E)){if(v.has($)){const N=q.get($);N&&a.add(N);continue}const A=z($,T,k);A&&(a.add(j($,A)),f.push(`${$}@${A}`))}};for(const f of i)l(U,f);l(D,o.optionalDependencies),G.set(r,a)}const w=new Map,b=new Map,X=(r,o)=>{const i=[...r];for(;i.length>0;){const a=i.pop(),l=w.get(a);if(l==="required"||l==="optional"&&o==="optional")continue;w.set(a,o);const f=V.get(a);if(!f)continue;const E=b.get(a)??new Set,$=[f.dependencies,f.peerDependencies];for(const T of $)if(T)for(const[A,N]of Object.entries(T))for(const P of N){const F=z(A,P,k);F&&(E.add(j(A,F)),i.push(`${A}@${F}`))}if(f.optionalDependencies)for(const[T,A]of Object.entries(f.optionalDependencies))for(const N of A){const P=z(T,N,k);P&&(E.add(j(T,P)),D.push(`${T}@${P}`))}E.size>0&&b.set(a,E)}};X(U,"required"),X(D,"optional");const C=[],h=[...w.keys()].sort();for(const r of h){const o=V.get(r);if(!o)continue;const i=j(o.name,o.version),a={"bom-ref":i,name:o.name,purl:i,scope:w.get(r)??"required",type:"library",version:o.version};o.hash&&(a.hashes=[o.hash]),K(a,xe(O,o.name,o.version)),C.push(a)}const g=[];for(const[r,o]of G){const i=q.get(r);if(!i)continue;const a=[...o].sort();g.push(a.length>0?{dependsOn:a,ref:i}:{ref:i})}for(const r of h){const o=V.get(r);if(!o)continue;const i=j(o.name,o.version),a=b.get(r),l=a?[...a].sort():[];g.push(l.length>0?{dependsOn:l,ref:i}:{ref:i})}g.sort((r,o)=>r.ref.localeCompare(o.ref));const u=ne(I(O,"package.json")),y=(()=>{if(t?.length===1){const l=L.find(f=>f.name===t[0]);if(l)return{"bom-ref":l["bom-ref"],name:l.name,purl:l.purl,type:l.type,version:l.version}}const r=u?.name??"workspace",o=u?.version??"0.0.0",i=j(r,o),a={"bom-ref":i,name:r,purl:i,type:"application",version:o};return K(a,u),a})(),M=y["bom-ref"],R=M?L.filter(r=>r["bom-ref"]!==M):L;return{$schema:Be,bomFormat:Pe,components:[...R,...C],dependencies:g,metadata:{component:y,lifecycles:[{phase:"build"}],timestamp:c.toISOString(),tools:{components:[{name:Ve,type:"application",...n?{version:n}:{}}]}},serialNumber:m??`urn:uuid:${le()}`,specVersion:Me,version:1}},st=e=>{const t={version:e.version??1,xmlns:"http://cyclonedx.org/schema/bom/1.7"};e.serialNumber&&(t.serialNumber=e.serialNumber);const n=[];return e.metadata&&n.push(qe(e.metadata)),e.components&&e.components.length>0&&n.push({_content:e.components.map(c=>Z(c)),_name:"components"}),e.dependencies&&e.dependencies.length>0&&n.push({_content:e.dependencies.map(c=>Ge(c)),_name:"dependencies"}),`${B({_attrs:t,_content:n,_name:"bom"},{header:!0,indent:" ",selfCloseTags:!0})}
4
4
  `},qe=e=>{const t=[];return e.timestamp&&t.push({timestamp:e.timestamp}),e.lifecycles&&e.lifecycles.length>0&&t.push({_content:e.lifecycles.map(n=>{const s=[];return n.phase&&s.push({phase:n.phase}),n.name&&s.push({name:n.name}),n.description&&s.push({description:n.description}),{_content:s,_name:"lifecycle"}}),_name:"lifecycles"}),e.tools?.components&&t.push({_content:[{_content:e.tools.components.map(n=>Z(n)),_name:"components"}],_name:"tools"}),e.component&&t.push(Z(e.component)),{_content:t,_name:"metadata"}},Z=e=>{const t={type:e.type};e["bom-ref"]&&(t["bom-ref"]=e["bom-ref"]);const n=[];e.group&&n.push({group:e.group}),n.push({name:e.name}),e.version&&n.push({version:e.version}),e.description&&n.push({description:e.description}),e.author&&n.push({author:e.author}),e.hashes&&e.hashes.length>0&&n.push({_content:e.hashes.map(c=>({_attrs:{alg:c.alg},_content:c.content,_name:"hash"})),_name:"hashes"});const s=Ye(e.licenses);return s&&n.push(s),e.purl&&n.push({purl:e.purl}),e.scope&&n.push({scope:e.scope}),e.externalReferences&&e.externalReferences.length>0&&n.push({_content:e.externalReferences.map(c=>({_attrs:{type:c.type},_content:[{url:c.url}],_name:"reference"})),_name:"externalReferences"}),{_attrs:t,_content:n,_name:"component"}},Ye=e=>{if(!e||e.length===0)return;const t=[];for(const n of e){if("expression"in n){t.push({expression:n.expression});continue}const s=[];"id"in n.license&&n.license.id?s.push({id:n.license.id}):"name"in n.license&&n.license.name&&s.push({name:n.license.name}),t.push({_content:s,_name:"license"})}return{_content:t,_name:"licenses"}},Ge=e=>e.dependsOn&&e.dependsOn.length>0?{_attrs:{ref:e.ref},_content:e.dependsOn.map(t=>({_attrs:{ref:t},_name:"dependency"})),_name:"dependency"}:{_attrs:{ref:e.ref},_name:"dependency"};export{nt as b,st as s,j as t};