@karmaniverous/stan-cli 0.12.3 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -177,6 +177,50 @@ See [CLI Usage & Examples](./guides/cli-examples.md) for more!
177
177
 
178
178
  ---
179
179
 
180
+ ## Built With Stan
181
+
182
+ [aws-api-gateway-tools](https://github.com/karmaniverous/aws-api-gateway-tools) - Tools and get-dotenv plugin for AWS API Gateway (REST APIs, stage cache, API keys).
183
+
184
+ [aws-secrets-manager-tools](https://github.com/karmaniverous/aws-secrets-manager-tools) - Tools and get-dotenv plugin for AWS Secrets Manager env-map secrets.
185
+
186
+ [aws-xray-tools](https://github.com/karmaniverous/aws-xray-tools) - Guarded AWS X-Ray capture utilities for AWS SDK v3 clients.
187
+
188
+ [cached-axios](https://github.com/karmaniverous/cached-axios) - Tag‑aware caching for Axios: stable cache IDs, simple tag invalidation, and a drop‑in Orval mutator on top of axios‑cache‑interceptor.
189
+
190
+ [electron-react-template](https://github.com/karmaniverous/electron-react-template) - A modern Electron + React starter built on Electron Forge and Vite, with a batteries-included TypeScript/tooling setup for shipping production desktop apps.
191
+
192
+ [entity-client-dynamodb](https://github.com/karmaniverous/entity-client-dynamodb) - Convenience wrapper for DynamoDB SDK with enhanced batch processing & EntityManager support.
193
+
194
+ [entity-manager](https://github.com/karmaniverous/entity-manager) Rational indexing & cross-shard querying at scale in your NoSQL database so you can focus on your application logic.
195
+
196
+ [entity-manager-demo](https://github.com/karmaniverous/entity-manager-demo) - A working demonstration of Entity Manager in action.
197
+
198
+ [entity-tools](https://github.com/karmaniverous/entity-tools) - Types & low-level functions for entity operations.
199
+
200
+ [get-dotenv](https://github.com/karmaniverous/get-dotenv) - Manage environment variables from dotenv files across multiple environments. Supports async/CLI operations, dynamic variables, custom CLI creation & more!
201
+
202
+ [hook-form-semantic](https://github.com/karmaniverous/hook-form-semantic) - React Hook Form components with Semantic UI React integration - date pickers, WYSIWYG editor, phone input, JSON editor, and more.
203
+
204
+ [identity-engine](https://github.com/karmaniverous/identity-engine) - Deterministic identity-resolution engine in TypeScript: Zod-validated handlers, mocked deps, and a CLI that mirrors the future HTTP API.
205
+
206
+ [mock-db](https://github.com/karmaniverous/mock-db) - Mock DynamoDB-style query & scan behavior with local JSON data.
207
+
208
+ [npm-package-template-ts](https://github.com/karmaniverous/npm-package-template-ts) - A feature-rich NPM package template for TypeScript projects.
209
+
210
+ [react-component-npm-package-template-ts](https://github.com/karmaniverous/react-component-npm-package-template-ts) - A modern, batteries‑included React 18 component library template for TypeScript with ESM‑only bundling, Vite playground, Vitest, ESLint/Prettier, TypeDoc, release‑it, STAN, and optional cloud backup.
211
+
212
+ [rrstack](https://github.com/karmaniverous/rrstack) - Manage a stack of RRULEs.
213
+
214
+ [stan-cli](https://github.com/karmaniverous/stan-cli) & [stan-core](https://github.com/karmaniverous/stan-core) - The command-line interface for STAN, a tool for managing snapshots, patches, and archives in software development.
215
+
216
+ [smoz](https://github.com/karmaniverous/smoz) - SMOZ: a TypeScript toolkit for AWS Lambda combining Serverless, Middy, OpenAPI 3.1 and Zod for schema‑first apps with robust HTTP middleware and typed validation.
217
+
218
+ [string-utilities](https://github.com/karmaniverous/string-utilities) - Handy tagged template functions & other string utilities.
219
+
180
220
  ## License
181
221
 
182
222
  BSD‑3‑Clause
223
+
224
+ ---
225
+
226
+ Built for you with ❤️ on Bali! Find more great tools & templates on [my GitHub Profile](https://github.com/karmaniverous).
@@ -0,0 +1 @@
1
+ "use strict";var t=require("events"),e=require("fs"),i=require("node:events"),s=require("node:stream"),r=require("node:string_decoder"),n=require("node:path"),h=require("node:fs"),o=require("path"),a=require("assert"),l=require("buffer"),d=require("zlib"),c=require("node:assert"),u=require("node:crypto"),m=require("node:fs/promises");function f(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}}),e.default=t,Object.freeze(e)}var p=f(d);const y="object"==typeof process&&process?process:{stdout:null,stderr:null},b=t=>!!t&&"object"==typeof t&&(t instanceof et||t instanceof s||w(t)||E(t)),w=t=>!!t&&"object"==typeof t&&t instanceof i.EventEmitter&&"function"==typeof t.pipe&&t.pipe!==s.Writable.prototype.pipe,E=t=>!!t&&"object"==typeof t&&t instanceof i.EventEmitter&&"function"==typeof t.write&&"function"==typeof t.end,g=Symbol("EOF"),R=Symbol("maybeEmitEnd"),_=Symbol("emittedEnd"),S=Symbol("emittingEnd"),v=Symbol("emittedError"),O=Symbol("closed"),T=Symbol("read"),k=Symbol("flush"),L=Symbol("flushChunk"),x=Symbol("encoding"),D=Symbol("decoder"),A=Symbol("flowing"),I=Symbol("paused"),N=Symbol("resume"),B=Symbol("buffer"),F=Symbol("pipes"),M=Symbol("bufferLength"),C=Symbol("bufferPush"),P=Symbol("bufferShift"),z=Symbol("objectMode"),U=Symbol("destroyed"),j=Symbol("error"),H=Symbol("emitData"),Z=Symbol("emitEnd"),W=Symbol("emitEnd2"),G=Symbol("async"),Y=Symbol("abort"),V=Symbol("aborted"),$=Symbol("signal"),q=Symbol("dataListeners"),K=Symbol("discarded"),X=t=>Promise.resolve().then(t),Q=t=>t();class J{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[N](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}}class tt extends J{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=t=>e.emit("error",t),t.on("error",this.proxyErrors)}}class et extends i.EventEmitter{[A]=!1;[I]=!1;[F]=[];[B]=[];[z];[x];[G];[D];[g]=!1;[_]=!1;[S]=!1;[O]=!1;[v]=null;[M]=0;[U]=!1;[$];[V]=!1;[q]=0;[K]=!1;writable=!0;readable=!0;constructor(...t){const e=t[0]||{};if(super(),e.objectMode&&"string"==typeof e.encoding)throw new TypeError("Encoding and objectMode may not be used together");e.objectMode?(this[z]=!0,this[x]=null):(t=>!t.objectMode&&!!t.encoding&&"buffer"!==t.encoding)(e)?(this[x]=e.encoding,this[z]=!1):(this[z]=!1,this[x]=null),this[G]=!!e.async,this[D]=this[x]?new r.StringDecoder(this[x]):null,e&&!0===e.debugExposeBuffer&&Object.defineProperty(this,"buffer",{get:()=>this[B]}),e&&!0===e.debugExposePipes&&Object.defineProperty(this,"pipes",{get:()=>this[F]});const{signal:i}=e;i&&(this[$]=i,i.aborted?this[Y]():i.addEventListener("abort",()=>this[Y]()))}get bufferLength(){return this[M]}get encoding(){return this[x]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[z]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[G]}set async(t){this[G]=this[G]||!!t}[Y](){this[V]=!0,this.emit("abort",this[$]?.reason),this.destroy(this[$]?.reason)}get aborted(){return this[V]}set aborted(t){}write(t,e,i){if(this[V])return!1;if(this[g])throw new Error("write after end");if(this[U])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;"function"==typeof e&&(i=e,e="utf8"),e||(e="utf8");const s=this[G]?X:Q;if(!this[z]&&!Buffer.isBuffer(t))if(r=t,!Buffer.isBuffer(r)&&ArrayBuffer.isView(r))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if((t=>t instanceof ArrayBuffer||!!t&&"object"==typeof t&&t.constructor&&"ArrayBuffer"===t.constructor.name&&t.byteLength>=0)(t))t=Buffer.from(t);else if("string"!=typeof t)throw new Error("Non-contiguous data written to non-objectMode stream");var r;return this[z]?(this[A]&&0!==this[M]&&this[k](!0),this[A]?this.emit("data",t):this[C](t),0!==this[M]&&this.emit("readable"),i&&s(i),this[A]):t.length?("string"!=typeof t||e===this[x]&&!this[D]?.lastNeed||(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[x]&&(t=this[D].write(t)),this[A]&&0!==this[M]&&this[k](!0),this[A]?this.emit("data",t):this[C](t),0!==this[M]&&this.emit("readable"),i&&s(i),this[A]):(0!==this[M]&&this.emit("readable"),i&&s(i),this[A])}read(t){if(this[U])return null;if(this[K]=!1,0===this[M]||0===t||t&&t>this[M])return this[R](),null;this[z]&&(t=null),this[B].length>1&&!this[z]&&(this[B]=[this[x]?this[B].join(""):Buffer.concat(this[B],this[M])]);const e=this[T](t||null,this[B][0]);return this[R](),e}[T](t,e){if(this[z])this[P]();else{const i=e;t===i.length||null===t?this[P]():"string"==typeof i?(this[B][0]=i.slice(t),e=i.slice(0,t),this[M]-=t):(this[B][0]=i.subarray(t),e=i.subarray(0,t),this[M]-=t)}return this.emit("data",e),this[B].length||this[g]||this.emit("drain"),e}end(t,e,i){return"function"==typeof t&&(i=t,t=void 0),"function"==typeof e&&(i=e,e="utf8"),void 0!==t&&this.write(t,e),i&&this.once("end",i),this[g]=!0,this.writable=!1,!this[A]&&this[I]||this[R](),this}[N](){this[U]||(this[q]||this[F].length||(this[K]=!0),this[I]=!1,this[A]=!0,this.emit("resume"),this[B].length?this[k]():this[g]?this[R]():this.emit("drain"))}resume(){return this[N]()}pause(){this[A]=!1,this[I]=!0,this[K]=!1}get destroyed(){return this[U]}get flowing(){return this[A]}get paused(){return this[I]}[C](t){this[z]?this[M]+=1:this[M]+=t.length,this[B].push(t)}[P](){return this[z]?this[M]-=1:this[M]-=this[B][0].length,this[B].shift()}[k](t=!1){do{}while(this[L](this[P]())&&this[B].length);t||this[B].length||this[g]||this.emit("drain")}[L](t){return this.emit("data",t),this[A]}pipe(t,e){if(this[U])return t;this[K]=!1;const i=this[_];return e=e||{},t===y.stdout||t===y.stderr?e.end=!1:e.end=!1!==e.end,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[F].push(e.proxyErrors?new tt(this,t,e):new J(this,t,e)),this[G]?X(()=>this[N]()):this[N]()),t}unpipe(t){const e=this[F].find(e=>e.dest===t);e&&(1===this[F].length?(this[A]&&0===this[q]&&(this[A]=!1),this[F]=[]):this[F].splice(this[F].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){const i=super.on(t,e);if("data"===t)this[K]=!1,this[q]++,this[F].length||this[A]||this[N]();else if("readable"===t&&0!==this[M])super.emit("readable");else if((t=>"end"===t||"finish"===t||"prefinish"===t)(t)&&this[_])super.emit(t),this.removeAllListeners(t);else if("error"===t&&this[v]){const t=e;this[G]?X(()=>t.call(this,this[v])):t.call(this,this[v])}return i}removeListener(t,e){return this.off(t,e)}off(t,e){const i=super.off(t,e);return"data"===t&&(this[q]=this.listeners("data").length,0!==this[q]||this[K]||this[F].length||(this[A]=!1)),i}removeAllListeners(t){const e=super.removeAllListeners(t);return"data"!==t&&void 0!==t||(this[q]=0,this[K]||this[F].length||(this[A]=!1)),e}get emittedEnd(){return this[_]}[R](){this[S]||this[_]||this[U]||0!==this[B].length||!this[g]||(this[S]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[O]&&this.emit("close"),this[S]=!1)}emit(t,...e){const i=e[0];if("error"!==t&&"close"!==t&&t!==U&&this[U])return!1;if("data"===t)return!(!this[z]&&!i)&&(this[G]?(X(()=>this[H](i)),!0):this[H](i));if("end"===t)return this[Z]();if("close"===t){if(this[O]=!0,!this[_]&&!this[U])return!1;const t=super.emit("close");return this.removeAllListeners("close"),t}if("error"===t){this[v]=i,super.emit(j,i);const t=!(this[$]&&!this.listeners("error").length)&&super.emit("error",i);return this[R](),t}if("resume"===t){const t=super.emit("resume");return this[R](),t}if("finish"===t||"prefinish"===t){const e=super.emit(t);return this.removeAllListeners(t),e}const s=super.emit(t,...e);return this[R](),s}[H](t){for(const e of this[F])!1===e.dest.write(t)&&this.pause();const e=!this[K]&&super.emit("data",t);return this[R](),e}[Z](){return!this[_]&&(this[_]=!0,this.readable=!1,this[G]?(X(()=>this[W]()),!0):this[W]())}[W](){if(this[D]){const t=this[D].end();if(t){for(const e of this[F])e.dest.write(t);this[K]||super.emit("data",t)}}for(const t of this[F])t.end();const t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){const t=Object.assign([],{dataLength:0});this[z]||(t.dataLength=0);const e=this.promise();return this.on("data",e=>{t.push(e),this[z]||(t.dataLength+=e.length)}),await e,t}async concat(){if(this[z])throw new Error("cannot concat in objectMode");const t=await this.collect();return this[x]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(U,()=>e(new Error("stream destroyed"))),this.on("error",t=>e(t)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[K]=!1;let t=!1;const e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();const i=this.read();if(null!==i)return Promise.resolve({done:!1,value:i});if(this[g])return e();let s,r;const n=t=>{this.off("data",h),this.off("end",o),this.off(U,a),e(),r(t)},h=t=>{this.off("error",n),this.off("end",o),this.off(U,a),this.pause(),s({value:t,done:!!this[g]})},o=()=>{this.off("error",n),this.off("data",h),this.off(U,a),e(),s({done:!0,value:void 0})},a=()=>n(new Error("stream destroyed"));return new Promise((t,e)=>{r=e,s=t,this.once(U,a),this.once("error",n),this.once("end",o),this.once("data",h)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[K]=!1;let t=!1;const e=()=>(this.pause(),this.off(j,e),this.off(U,e),this.off("end",e),t=!0,{done:!0,value:void 0});return this.once("end",e),this.once(j,e),this.once(U,e),{next:()=>{if(t)return e();const i=this.read();return null===i?e():{done:!1,value:i}},throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){return this[U]?(t?this.emit("error",t):this.emit(U),this):(this[U]=!0,this[K]=!0,this[B].length=0,this[M]=0,"function"!=typeof this.close||this[O]||this.close(),t?this.emit("error",t):this.emit(U),this)}static get isStream(){return b}}const it=e.writev,st=Symbol("_autoClose"),rt=Symbol("_close"),nt=Symbol("_ended"),ht=Symbol("_fd"),ot=Symbol("_finished"),at=Symbol("_flags"),lt=Symbol("_flush"),dt=Symbol("_handleChunk"),ct=Symbol("_makeBuf"),ut=Symbol("_mode"),mt=Symbol("_needDrain"),ft=Symbol("_onerror"),pt=Symbol("_onopen"),yt=Symbol("_onread"),bt=Symbol("_onwrite"),wt=Symbol("_open"),Et=Symbol("_path"),gt=Symbol("_pos"),Rt=Symbol("_queue"),_t=Symbol("_read"),St=Symbol("_readSize"),vt=Symbol("_reading"),Ot=Symbol("_remain"),Tt=Symbol("_size"),kt=Symbol("_write"),Lt=Symbol("_writing"),xt=Symbol("_defaultFlag"),Dt=Symbol("_errored");class At extends et{[Dt]=!1;[ht];[Et];[St];[vt]=!1;[Tt];[Ot];[st];constructor(t,e){if(super(e=e||{}),this.readable=!0,this.writable=!1,"string"!=typeof t)throw new TypeError("path must be a string");this[Dt]=!1,this[ht]="number"==typeof e.fd?e.fd:void 0,this[Et]=t,this[St]=e.readSize||16777216,this[vt]=!1,this[Tt]="number"==typeof e.size?e.size:1/0,this[Ot]=this[Tt],this[st]="boolean"!=typeof e.autoClose||e.autoClose,"number"==typeof this[ht]?this[_t]():this[wt]()}get fd(){return this[ht]}get path(){return this[Et]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[wt](){e.open(this[Et],"r",(t,e)=>this[pt](t,e))}[pt](t,e){t?this[ft](t):(this[ht]=e,this.emit("open",e),this[_t]())}[ct](){return Buffer.allocUnsafe(Math.min(this[St],this[Ot]))}[_t](){if(!this[vt]){this[vt]=!0;const t=this[ct]();if(0===t.length)return process.nextTick(()=>this[yt](null,0,t));e.read(this[ht],t,0,t.length,null,(t,e,i)=>this[yt](t,e,i))}}[yt](t,e,i){this[vt]=!1,t?this[ft](t):this[dt](e,i)&&this[_t]()}[rt](){if(this[st]&&"number"==typeof this[ht]){const t=this[ht];this[ht]=void 0,e.close(t,t=>t?this.emit("error",t):this.emit("close"))}}[ft](t){this[vt]=!0,this[rt](),this.emit("error",t)}[dt](t,e){let i=!1;return this[Ot]-=t,t>0&&(i=super.write(t<e.length?e.subarray(0,t):e)),(0===t||this[Ot]<=0)&&(i=!1,this[rt](),super.end()),i}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return"number"==typeof this[ht]&&this[_t](),!1;case"error":return!this[Dt]&&(this[Dt]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}}class It extends At{[wt](){let t=!0;try{this[pt](null,e.openSync(this[Et],"r")),t=!1}finally{t&&this[rt]()}}[_t](){let t=!0;try{if(!this[vt]){for(this[vt]=!0;;){const t=this[ct](),i=0===t.length?0:e.readSync(this[ht],t,0,t.length,null);if(!this[dt](i,t))break}this[vt]=!1}t=!1}finally{t&&this[rt]()}}[rt](){if(this[st]&&"number"==typeof this[ht]){const t=this[ht];this[ht]=void 0,e.closeSync(t),this.emit("close")}}}class Nt extends t{readable=!1;writable=!0;[Dt]=!1;[Lt]=!1;[nt]=!1;[Rt]=[];[mt]=!1;[Et];[ut];[st];[ht];[xt];[at];[ot]=!1;[gt];constructor(t,e){super(e=e||{}),this[Et]=t,this[ht]="number"==typeof e.fd?e.fd:void 0,this[ut]=void 0===e.mode?438:e.mode,this[gt]="number"==typeof e.start?e.start:void 0,this[st]="boolean"!=typeof e.autoClose||e.autoClose;const i=void 0!==this[gt]?"r+":"w";this[xt]=void 0===e.flags,this[at]=void 0===e.flags?i:e.flags,void 0===this[ht]&&this[wt]()}emit(t,...e){if("error"===t){if(this[Dt])return!1;this[Dt]=!0}return super.emit(t,...e)}get fd(){return this[ht]}get path(){return this[Et]}[ft](t){this[rt](),this[Lt]=!0,this.emit("error",t)}[wt](){e.open(this[Et],this[at],this[ut],(t,e)=>this[pt](t,e))}[pt](t,e){this[xt]&&"r+"===this[at]&&t&&"ENOENT"===t.code?(this[at]="w",this[wt]()):t?this[ft](t):(this[ht]=e,this.emit("open",e),this[Lt]||this[lt]())}end(t,e){return t&&this.write(t,e),this[nt]=!0,this[Lt]||this[Rt].length||"number"!=typeof this[ht]||this[bt](null,0),this}write(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this[nt]?(this.emit("error",new Error("write() after end()")),!1):void 0===this[ht]||this[Lt]||this[Rt].length?(this[Rt].push(t),this[mt]=!0,!1):(this[Lt]=!0,this[kt](t),!0)}[kt](t){e.write(this[ht],t,0,t.length,this[gt],(t,e)=>this[bt](t,e))}[bt](t,e){t?this[ft](t):(void 0!==this[gt]&&"number"==typeof e&&(this[gt]+=e),this[Rt].length?this[lt]():(this[Lt]=!1,this[nt]&&!this[ot]?(this[ot]=!0,this[rt](),this.emit("finish")):this[mt]&&(this[mt]=!1,this.emit("drain"))))}[lt](){if(0===this[Rt].length)this[nt]&&this[bt](null,0);else if(1===this[Rt].length)this[kt](this[Rt].pop());else{const t=this[Rt];this[Rt]=[],it(this[ht],t,this[gt],(t,e)=>this[bt](t,e))}}[rt](){if(this[st]&&"number"==typeof this[ht]){const t=this[ht];this[ht]=void 0,e.close(t,t=>t?this.emit("error",t):this.emit("close"))}}}class Bt extends Nt{[wt](){let t;if(this[xt]&&"r+"===this[at])try{t=e.openSync(this[Et],this[at],this[ut])}catch(t){if("ENOENT"===t?.code)return this[at]="w",this[wt]();throw t}else t=e.openSync(this[Et],this[at],this[ut]);this[pt](null,t)}[rt](){if(this[st]&&"number"==typeof this[ht]){const t=this[ht];this[ht]=void 0,e.closeSync(t),this.emit("close")}}[kt](t){let i=!0;try{this[bt](null,e.writeSync(this[ht],t,0,t.length,this[gt])),i=!1}finally{if(i)try{this[rt]()}catch{}}}}const Ft=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"]]),Mt=t=>Ft.get(t)||t,Ct=(t={})=>{if(!t)return{};const e={};for(const[i,s]of Object.entries(t))e[Mt(i)]=s;return void 0===e.chmod&&!1===e.noChmod&&(e.chmod=!0),delete e.noChmod,e},Pt=(t,e,i,s,r)=>Object.assign((n=[],h,o)=>{Array.isArray(n)&&(h=n,n={}),"function"==typeof h&&(o=h,h=void 0),h=h?Array.from(h):[];const a=Ct(n);if(r?.(a,h),(l=a).sync&&l.file){if("function"==typeof o)throw new TypeError("callback not supported for sync tar functions");return t(a,h)}if((t=>!t.sync&&!!t.file)(a)){const t=e(a,h),i=o||void 0;return i?t.then(()=>i(),i):t}if((t=>!!t.sync&&!t.file)(a)){if("function"==typeof o)throw new TypeError("callback not supported for sync tar functions");return i(a,h)}if((t=>!t.sync&&!t.file)(a)){if("function"==typeof o)throw new TypeError("callback only supported with file option");return s(a,h)}throw new Error("impossible options??");var l},{syncFile:t,asyncFile:e,syncNoFile:i,asyncNoFile:s,validate:r}),zt=d.constants||{ZLIB_VERNUM:4736},Ut=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},zt)),jt=l.Buffer.concat,Ht=Object.getOwnPropertyDescriptor(l.Buffer,"concat"),Zt=t=>t,Wt=!0===Ht?.writable||void 0!==Ht?.set?t=>{l.Buffer.concat=t?Zt:jt}:t=>{},Gt=Symbol("_superWrite");class Yt extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}}const Vt=Symbol("flushFlag");class $t extends et{#t=!1;#e=!1;#i;#s;#r;#n;#h;get sawError(){return this.#t}get handle(){return this.#n}get flushFlag(){return this.#i}constructor(t,e){if(!t||"object"!=typeof t)throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#i=t.flush??0,this.#s=t.finishFlush??0,this.#r=t.fullFlushFlag??0,"function"!=typeof p[e])throw new TypeError("Compression method not supported: "+e);try{this.#n=new p[e](t)}catch(t){throw new Yt(t,this.constructor)}this.#h=t=>{this.#t||(this.#t=!0,this.close(),this.emit("error",t))},this.#n?.on("error",t=>this.#h(new Yt(t))),this.once("end",()=>this.close)}close(){this.#n&&(this.#n.close(),this.#n=void 0,this.emit("close"))}reset(){if(!this.#t)return a(this.#n,"zlib binding closed"),this.#n.reset?.()}flush(t){this.ended||("number"!=typeof t&&(t=this.#r),this.write(Object.assign(l.Buffer.alloc(0),{[Vt]:t})))}end(t,e,i){return"function"==typeof t&&(i=t,e=void 0,t=void 0),"function"==typeof e&&(i=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#e=!0,super.end(i)}get ended(){return this.#e}[Gt](t){return super.write(t)}write(t,e,i){if("function"==typeof e&&(i=e,e="utf8"),"string"==typeof t&&(t=l.Buffer.from(t,e)),this.#t)return;a(this.#n,"zlib binding closed");const s=this.#n._handle,r=s.close;s.close=()=>{};const n=this.#n.close;let h,o;this.#n.close=()=>{},Wt(!0);try{const e="number"==typeof t[Vt]?t[Vt]:this.#i;h=this.#n._processChunk(t,e),Wt(!1)}catch(t){Wt(!1),this.#h(new Yt(t,this.write))}finally{this.#n&&(this.#n._handle=s,s.close=r,this.#n.close=n,this.#n.removeAllListeners("error"))}if(this.#n&&this.#n.on("error",t=>this.#h(new Yt(t,this.write))),h)if(Array.isArray(h)&&h.length>0){const t=h[0];o=this[Gt](l.Buffer.from(t));for(let t=1;t<h.length;t++)o=this[Gt](h[t])}else o=this[Gt](l.Buffer.from(h));return i&&i(),o}}class qt extends $t{#o;#a;constructor(t,e){(t=t||{}).flush=t.flush||Ut.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Ut.Z_FINISH,t.fullFlushFlag=Ut.Z_FULL_FLUSH,super(t,e),this.#o=t.level,this.#a=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#o!==t||this.#a!==e){this.flush(Ut.Z_SYNC_FLUSH),a(this.handle,"zlib binding closed");const i=this.handle.flush;this.handle.flush=(t,e)=>{"function"==typeof t&&(e=t,t=this.flushFlag),this.flush(t),e?.()};try{this.handle.params(t,e)}finally{this.handle.flush=i}this.handle&&(this.#o=t,this.#a=e)}}}}class Kt extends qt{#l;constructor(t){super(t,"Gzip"),this.#l=t&&!!t.portable}[Gt](t){return this.#l?(this.#l=!1,t[9]=255,super[Gt](t)):super[Gt](t)}}class Xt extends qt{constructor(t){super(t,"Unzip")}}class Qt extends $t{constructor(t,e){(t=t||{}).flush=t.flush||Ut.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Ut.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Ut.BROTLI_OPERATION_FLUSH,super(t,e)}}class Jt extends Qt{constructor(t){super(t,"BrotliCompress")}}class te extends Qt{constructor(t){super(t,"BrotliDecompress")}}class ee extends $t{constructor(t,e){(t=t||{}).flush=t.flush||Ut.ZSTD_e_continue,t.finishFlush=t.finishFlush||Ut.ZSTD_e_end,t.fullFlushFlag=Ut.ZSTD_e_flush,super(t,e)}}class ie extends ee{constructor(t){super(t,"ZstdCompress")}}class se extends ee{constructor(t){super(t,"ZstdDecompress")}}const re=t=>255&(255^t),ne=t=>1+(255^t)&255,he=t=>oe.has(t),oe=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"]]),ae=new Map(Array.from(oe).map(t=>[t[1],t[0]]));class le{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#d="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.#c(t)}decode(t,e,i,s){if(e||(e=0),!(t&&t.length>=e+512))throw new Error("need 512 bytes for header");this.path=i?.path??ce(t,e,100),this.mode=i?.mode??s?.mode??fe(t,e+100,8),this.uid=i?.uid??s?.uid??fe(t,e+108,8),this.gid=i?.gid??s?.gid??fe(t,e+116,8),this.size=i?.size??s?.size??fe(t,e+124,12),this.mtime=i?.mtime??s?.mtime??ue(t,e+136,12),this.cksum=fe(t,e+148,12),s&&this.#c(s,!0),i&&this.#c(i);const r=ce(t,e+156,1);if(he(r)&&(this.#d=r||"0"),"0"===this.#d&&"/"===this.path.slice(-1)&&(this.#d="5"),"5"===this.#d&&(this.size=0),this.linkpath=ce(t,e+157,100),"ustar\x0000"===t.subarray(e+257,e+265).toString())if(this.uname=i?.uname??s?.uname??ce(t,e+265,32),this.gname=i?.gname??s?.gname??ce(t,e+297,32),this.devmaj=i?.devmaj??s?.devmaj??fe(t,e+329,8)??0,this.devmin=i?.devmin??s?.devmin??fe(t,e+337,8)??0,0!==t[e+475]){const i=ce(t,e+345,155);this.path=i+"/"+this.path}else{const r=ce(t,e+345,130);r&&(this.path=r+"/"+this.path),this.atime=i?.atime??s?.atime??ue(t,e+476,12),this.ctime=i?.ctime??s?.ctime??ue(t,e+488,12)}let n=256;for(let i=e;i<e+148;i++)n+=t[i];for(let i=e+156;i<e+512;i++)n+=t[i];this.cksumValid=n===this.cksum,void 0===this.cksum&&256===n&&(this.nullBlock=!0)}#c(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([t,i])=>!(null==i||"path"===t&&e||"linkpath"===t&&e||"global"===t))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),"Unsupported"===this.#d&&(this.#d="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");const i=this.ctime||this.atime?130:155,s=de(this.path||"",i),r=s[0],n=s[1];this.needPax=!!s[2],this.needPax=Se(t,e,100,r)||this.needPax,this.needPax=be(t,e+100,8,this.mode)||this.needPax,this.needPax=be(t,e+108,8,this.uid)||this.needPax,this.needPax=be(t,e+116,8,this.gid)||this.needPax,this.needPax=be(t,e+124,12,this.size)||this.needPax,this.needPax=Re(t,e+136,12,this.mtime)||this.needPax,t[e+156]=this.#d.charCodeAt(0),this.needPax=Se(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Se(t,e+265,32,this.uname)||this.needPax,this.needPax=Se(t,e+297,32,this.gname)||this.needPax,this.needPax=be(t,e+329,8,this.devmaj)||this.needPax,this.needPax=be(t,e+337,8,this.devmin)||this.needPax,this.needPax=Se(t,e+345,i,n)||this.needPax,0!==t[e+475]?this.needPax=Se(t,e+345,155,n)||this.needPax:(this.needPax=Se(t,e+345,130,n)||this.needPax,this.needPax=Re(t,e+476,12,this.atime)||this.needPax,this.needPax=Re(t,e+488,12,this.ctime)||this.needPax);let h=256;for(let i=e;i<e+148;i++)h+=t[i];for(let i=e+156;i<e+512;i++)h+=t[i];return this.cksum=h,be(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return"Unsupported"===this.#d?this.#d:oe.get(this.#d)}get typeKey(){return this.#d}set type(t){const e=String(ae.get(t));if(he(e)||"Unsupported"===e)this.#d=e;else{if(!he(t))throw new TypeError("invalid entry type: "+t);this.#d=t}}}const de=(t,e)=>{let i,s=t,r="";const h=n.posix.parse(t).root||".";if(Buffer.byteLength(s)<100)i=[s,r,!1];else{r=n.posix.dirname(s),s=n.posix.basename(s);do{Buffer.byteLength(s)<=100&&Buffer.byteLength(r)<=e?i=[s,r,!1]:Buffer.byteLength(s)>100&&Buffer.byteLength(r)<=e?i=[s.slice(0,99),r,!0]:(s=n.posix.join(n.posix.basename(r),s),r=n.posix.dirname(r))}while(r!==h&&void 0===i);i||(i=[t.slice(0,99),"",!0])}return i},ce=(t,e,i)=>t.subarray(e,e+i).toString("utf8").replace(/\0.*/,""),ue=(t,e,i)=>me(fe(t,e,i)),me=t=>void 0===t?void 0:new Date(1e3*t),fe=(t,e,i)=>128&Number(t[e])?(t=>{const e=t[0],i=128===e?(t=>{for(var e=t.length,i=0,s=e-1;s>-1;s--){var r=Number(t[s]);0!==r&&(i+=r*Math.pow(256,e-s-1))}return i})(t.subarray(1,t.length)):255===e?(t=>{for(var e=t.length,i=0,s=!1,r=e-1;r>-1;r--){var n,h=Number(t[r]);s?n=re(h):0===h?n=h:(s=!0,n=ne(h)),0!==n&&(i-=n*Math.pow(256,e-r-1))}return i})(t):null;if(null===i)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(i))throw Error("parsed number outside of javascript safe integer range");return i})(t.subarray(e,e+i)):pe(t,e,i),pe=(t,e,i)=>{return s=parseInt(t.subarray(e,e+i).toString("utf8").replace(/\0.*$/,"").trim(),8),isNaN(s)?void 0:s;var s},ye={12:8589934591,8:2097151},be=(t,e,i,s)=>void 0!==s&&(s>ye[i]||s<0?(((t,e)=>{if(!Number.isSafeInteger(t))throw Error("cannot encode number outside of javascript safe integer range");t<0?((t,e)=>{e[0]=255;var i=!1;t*=-1;for(var s=e.length;s>1;s--){var r=255&t;t=Math.floor(t/256),i?e[s-1]=re(r):0===r?e[s-1]=0:(i=!0,e[s-1]=ne(r))}})(t,e):((t,e)=>{e[0]=128;for(var i=e.length;i>1;i--)e[i-1]=255&t,t=Math.floor(t/256)})(t,e)})(s,t.subarray(e,e+i)),!0):(we(t,e,i,s),!1)),we=(t,e,i,s)=>t.write(Ee(s,i),e,i,"ascii"),Ee=(t,e)=>ge(Math.floor(t).toString(8),e),ge=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Re=(t,e,i,s)=>void 0!==s&&be(t,e,i,s.getTime()/1e3),_e=new Array(156).join("\0"),Se=(t,e,i,s)=>void 0!==s&&(t.write(s+_e,e,i,"utf8"),s.length!==Buffer.byteLength(s)||s.length>i);class ve{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(t,e=!1){this.atime=t.atime,this.charset=t.charset,this.comment=t.comment,this.ctime=t.ctime,this.dev=t.dev,this.gid=t.gid,this.global=e,this.gname=t.gname,this.ino=t.ino,this.linkpath=t.linkpath,this.mtime=t.mtime,this.nlink=t.nlink,this.path=t.path,this.size=t.size,this.uid=t.uid,this.uname=t.uname}encode(){const t=this.encodeBody();if(""===t)return Buffer.allocUnsafe(0);const e=Buffer.byteLength(t),i=512*Math.ceil(1+e/512),s=Buffer.allocUnsafe(i);for(let t=0;t<512;t++)s[t]=0;new le({path:("PaxHeader/"+n.basename(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:e,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(s),s.write(t,512,e,"utf8");for(let t=e+512;t<s.length;t++)s[t]=0;return s}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(t){if(void 0===this[t])return"";const e=this[t],i=" "+("dev"===t||"ino"===t||"nlink"===t?"SCHILY.":"")+t+"="+(e instanceof Date?e.getTime()/1e3:e)+"\n",s=Buffer.byteLength(i);let r=Math.floor(Math.log(s)/Math.log(10))+1;return s+r>=Math.pow(10,r)&&(r+=1),r+s+i}static parse(t,e,i=!1){return new ve(Oe(Te(t),e),i)}}const Oe=(t,e)=>e?Object.assign({},e,t):t,Te=t=>t.replace(/\n$/,"").split("\n").reduce(ke,Object.create(null)),ke=(t,e)=>{const i=parseInt(e,10);if(i!==Buffer.byteLength(e)+1)return t;const s=(e=e.slice((i+" ").length)).split("="),r=s.shift();if(!r)return t;const n=r.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),h=s.join("=");return t[n]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n)?new Date(1e3*Number(h)):/^[0-9]+$/.test(h)?+h:h,t},Le="win32"!==(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)?t=>t:t=>t&&t.replace(/\\/g,"/");class xe extends et{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 new Error("no path provided for tar.ReadEntry");this.path=Le(t.path),this.mode=t.mode,this.mode&&(this.mode=4095&this.mode),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?Le(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#c(e),i&&this.#c(i,!0)}write(t){const e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");const i=this.remain,s=this.blockRemain;return this.remain=Math.max(0,i-e),this.blockRemain=Math.max(0,s-e),!!this.ignore||(i>=e?super.write(t):super.write(t.subarray(0,i)))}#c(t,e=!1){t.path&&(t.path=Le(t.path)),t.linkpath&&(t.linkpath=Le(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([t,i])=>!(null==i||"path"===t&&e))))}}const De=(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||!1===s.recoverable?i instanceof Error?t.emit("error",Object.assign(i,s)):t.emit("error",Object.assign(new Error(`${e}: ${i}`),s)):(i instanceof Error&&(s=Object.assign(i,s),i=i.message),t.emit("warn",e,i,s))},Ae=Buffer.from([31,139]),Ie=Buffer.from([40,181,47,253]),Ne=Math.max(Ae.length,Ie.length),Be=Symbol("state"),Fe=Symbol("writeEntry"),Me=Symbol("readEntry"),Ce=Symbol("nextEntry"),Pe=Symbol("processEntry"),ze=Symbol("extendedHeader"),Ue=Symbol("globalExtendedHeader"),je=Symbol("meta"),He=Symbol("emitMeta"),Ze=Symbol("buffer"),We=Symbol("queue"),Ge=Symbol("ended"),Ye=Symbol("emittedEnd"),Ve=Symbol("emit"),$e=Symbol("unzip"),qe=Symbol("consumeChunk"),Ke=Symbol("consumeChunkSub"),Xe=Symbol("consumeBody"),Qe=Symbol("consumeMeta"),Je=Symbol("consumeHeader"),ti=Symbol("consuming"),ei=Symbol("bufferConcat"),ii=Symbol("maybeEnd"),si=Symbol("writing"),ri=Symbol("aborted"),ni=Symbol("onDone"),hi=Symbol("sawValidEntry"),oi=Symbol("sawNullBlock"),ai=Symbol("sawEOF"),li=Symbol("closeStream"),di=()=>!0;class ci extends t.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[We]=[];[Ze];[Me];[Fe];[Be]="begin";[je]="";[ze];[Ue];[Ge]=!1;[$e];[ri]=!1;[hi];[oi]=!1;[ai]=!1;[si]=!1;[ti]=!1;[Ye]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(ni,()=>{"begin"!==this[Be]&&!1!==this[hi]||this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(ni,t.ondone):this.on(ni,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||1048576,this.filter="function"==typeof t.filter?t.filter:di;const e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=t.gzip||t.zstd||void 0===t.brotli?!!e&&void 0:t.brotli;const i=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=t.gzip||t.brotli||void 0===t.zstd?!!i||void 0:t.zstd,this.on("end",()=>this[li]()),"function"==typeof t.onwarn&&this.on("warn",t.onwarn),"function"==typeof t.onReadEntry&&this.on("entry",t.onReadEntry)}warn(t,e,i={}){De(this,t,e,i)}[Je](t,e){let i;void 0===this[hi]&&(this[hi]=!1);try{i=new le(t,e,this[ze],this[Ue])}catch(t){return this.warn("TAR_ENTRY_INVALID",t)}if(i.nullBlock)this[oi]?(this[ai]=!0,"begin"===this[Be]&&(this[Be]="header"),this[Ve]("eof")):(this[oi]=!0,this[Ve]("nullBlock"));else if(this[oi]=!1,i.cksumValid)if(i.path){const t=i.type;if(/^(Symbolic)?Link$/.test(t)&&!i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:i});else if(/^(Symbolic)?Link$/.test(t)||/^(Global)?ExtendedHeader$/.test(t)||!i.linkpath){const t=this[Fe]=new xe(i,this[ze],this[Ue]);if(!this[hi])if(t.remain){const e=()=>{t.invalid||(this[hi]=!0)};t.on("end",e)}else this[hi]=!0;t.meta?t.size>this.maxMetaEntrySize?(t.ignore=!0,this[Ve]("ignoredEntry",t),this[Be]="ignore",t.resume()):t.size>0&&(this[je]="",t.on("data",t=>this[je]+=t),this[Be]="meta"):(this[ze]=void 0,t.ignore=t.ignore||!this.filter(t.path,t),t.ignore?(this[Ve]("ignoredEntry",t),this[Be]=t.remain?"ignore":"header",t.resume()):(t.remain?this[Be]="body":(this[Be]="header",t.end()),this[Me]?this[We].push(t):(this[We].push(t),this[Ce]())))}else this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:i})}else this.warn("TAR_ENTRY_INVALID","path is required",{header:i});else this.warn("TAR_ENTRY_INVALID","checksum failure",{header:i})}[li](){queueMicrotask(()=>this.emit("close"))}[Pe](t){let e=!0;if(t)if(Array.isArray(t)){const[e,...i]=t;this.emit(e,...i)}else this[Me]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Ce]()),e=!1);else this[Me]=void 0,e=!1;return e}[Ce](){do{}while(this[Pe](this[We].shift()));if(!this[We].length){const t=this[Me];!t||t.flowing||t.size===t.remain?this[si]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Xe](t,e){const i=this[Fe];if(!i)throw new Error("attempt to consume body without entry??");const s=i.blockRemain??0,r=s>=t.length&&0===e?t:t.subarray(e,e+s);return i.write(r),i.blockRemain||(this[Be]="header",this[Fe]=void 0,i.end()),r.length}[Qe](t,e){const i=this[Fe],s=this[Xe](t,e);return!this[Fe]&&i&&this[He](i),s}[Ve](t,e,i){this[We].length||this[Me]?this[We].push([t,e,i]):this.emit(t,e,i)}[He](t){switch(this[Ve]("meta",this[je]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[ze]=ve.parse(this[je],this[ze],!1);break;case"GlobalExtendedHeader":this[Ue]=ve.parse(this[je],this[Ue],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{const t=this[ze]??Object.create(null);this[ze]=t,t.path=this[je].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{const t=this[ze]||Object.create(null);this[ze]=t,t.linkpath=this[je].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[ri]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,i){if("function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,"string"==typeof e?e:"utf8")),this[ri])return i?.(),!1;if((void 0===this[$e]||void 0===this.brotli&&!1===this[$e])&&t){if(this[Ze]&&(t=Buffer.concat([this[Ze],t]),this[Ze]=void 0),t.length<Ne)return this[Ze]=t,i?.(),!0;for(let e=0;void 0===this[$e]&&e<Ae.length;e++)t[e]!==Ae[e]&&(this[$e]=!1);let e=!1;if(!1===this[$e]&&!1!==this.zstd){e=!0;for(let i=0;i<Ie.length;i++)if(t[i]!==Ie[i]){e=!1;break}}const s=void 0===this.brotli&&!e;if(!1===this[$e]&&s)if(t.length<512){if(!this[Ge])return this[Ze]=t,i?.(),!0;this.brotli=!0}else try{new le(t.subarray(0,512)),this.brotli=!1}catch(t){this.brotli=!0}if(void 0===this[$e]||!1===this[$e]&&(this.brotli||e)){const s=this[Ge];this[Ge]=!1,this[$e]=void 0===this[$e]?new Xt({}):e?new se({}):new te({}),this[$e].on("data",t=>this[qe](t)),this[$e].on("error",t=>this.abort(t)),this[$e].on("end",()=>{this[Ge]=!0,this[qe]()}),this[si]=!0;const r=!!this[$e][s?"end":"write"](t);return this[si]=!1,i?.(),r}}this[si]=!0,this[$e]?this[$e].write(t):this[qe](t),this[si]=!1;const s=!this[We].length&&(!this[Me]||this[Me].flowing);return s||this[We].length||this[Me]?.once("drain",()=>this.emit("drain")),i?.(),s}[ei](t){t&&!this[ri]&&(this[Ze]=this[Ze]?Buffer.concat([this[Ze],t]):t)}[ii](){if(this[Ge]&&!this[Ye]&&!this[ri]&&!this[ti]){this[Ye]=!0;const t=this[Fe];if(t&&t.blockRemain){const e=this[Ze]?this[Ze].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[Ze]&&t.write(this[Ze]),t.end()}this[Ve](ni)}}[qe](t){if(this[ti]&&t)this[ei](t);else if(t||this[Ze]){if(t){if(this[ti]=!0,this[Ze]){this[ei](t);const e=this[Ze];this[Ze]=void 0,this[Ke](e)}else this[Ke](t);for(;this[Ze]&&this[Ze]?.length>=512&&!this[ri]&&!this[ai];){const t=this[Ze];this[Ze]=void 0,this[Ke](t)}this[ti]=!1}}else this[ii]();this[Ze]&&!this[Ge]||this[ii]()}[Ke](t){let e=0;const i=t.length;for(;e+512<=i&&!this[ri]&&!this[ai];)switch(this[Be]){case"begin":case"header":this[Je](t,e),e+=512;break;case"ignore":case"body":e+=this[Xe](t,e);break;case"meta":e+=this[Qe](t,e);break;default:throw new Error("invalid state: "+this[Be])}e<i&&(this[Ze]?this[Ze]=Buffer.concat([t.subarray(e),this[Ze]]):this[Ze]=t.subarray(e))}end(t,e,i){return"function"==typeof t&&(i=t,e=void 0,t=void 0),"function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,e)),i&&this.once("finish",i),this[ri]||(this[$e]?(t&&this[$e].write(t),this[$e].end()):(this[Ge]=!0,void 0!==this.brotli&&void 0!==this.zstd||(t=t||Buffer.alloc(0)),t&&this.write(t),this[ii]())),this}}const ui=t=>{let e=t.length-1,i=-1;for(;e>-1&&"/"===t.charAt(e);)i=e,e--;return-1===i?t:t.slice(0,i)},mi=(t,e)=>{const i=new Map(e.map(t=>[ui(t),!0])),s=t.filter,r=(t,e="")=>{const s=e||o.parse(t).root||".";let n;if(t===s)n=!1;else{const e=i.get(t);n=void 0!==e?e:r(o.dirname(t),s)}return i.set(t,n),n};t.filter=s?(t,e)=>s(t,e)&&r(ui(t)):t=>r(ui(t))},fi=Pt(t=>{const e=new ci(t),i=t.file;let s;try{s=h.openSync(i,"r");const r=h.fstatSync(s),n=t.maxReadSize||16777216;if(r.size<n){const t=Buffer.allocUnsafe(r.size),i=h.readSync(s,t,0,r.size,0);e.end(i===t.byteLength?t:t.subarray(0,i))}else{let t=0;const i=Buffer.allocUnsafe(n);for(;t<r.size;){const r=h.readSync(s,i,0,n,t);if(0===r)break;t+=r,e.write(i.subarray(0,r))}e.end()}}finally{if("number"==typeof s)try{h.closeSync(s)}catch(t){}}},(t,e)=>{const i=new ci(t),s=t.maxReadSize||16777216,r=t.file;return new Promise((t,e)=>{i.on("error",e),i.on("end",t),h.stat(r,(t,n)=>{if(t)e(t);else{const t=new At(r,{readSize:s,size:n.size});t.on("error",e),t.pipe(i)}})})},t=>new ci(t),t=>new ci(t),(t,e)=>{e?.length&&mi(t,e),t.noResume||(t=>{const e=t.onReadEntry;t.onReadEntry=e?t=>{e(t),t.resume()}:t=>t.resume()})(t)}),pi=(t,e,i)=>(t&=4095,i&&(t=-19&t|384),e&&(256&t&&(t|=64),32&t&&(t|=8),4&t&&(t|=1)),t),{isAbsolute:yi,parse:bi}=n.win32,wi=t=>{let e="",i=bi(t);for(;yi(t)||i.root;){const s="/"===t.charAt(0)&&"//?/"!==t.slice(0,4)?"/":i.root;t=t.slice(s.length),e+=s,i=bi(t)}return[e,t]},Ei=["|","<",">","?",":"],gi=Ei.map(t=>String.fromCharCode(61440+t.charCodeAt(0))),Ri=new Map(Ei.map((t,e)=>[t,gi[e]])),_i=new Map(gi.map((t,e)=>[t,Ei[e]])),Si=t=>Ei.reduce((t,e)=>t.split(e).join(Ri.get(e)),t),vi=(t,e)=>e?(t=Le(t).replace(/^\.(\/|$)/,""),ui(e)+"/"+t):Le(t),Oi=Symbol("process"),Ti=Symbol("file"),ki=Symbol("directory"),Li=Symbol("symlink"),xi=Symbol("hardlink"),Di=Symbol("header"),Ai=Symbol("read"),Ii=Symbol("lstat"),Ni=Symbol("onlstat"),Bi=Symbol("onread"),Fi=Symbol("onreadlink"),Mi=Symbol("openfile"),Ci=Symbol("onopenfile"),Pi=Symbol("close"),zi=Symbol("mode"),Ui=Symbol("awaitDrain"),ji=Symbol("ondrain"),Hi=Symbol("prefix");class Zi extends et{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;#u=!1;constructor(t,e={}){const i=Ct(e);super(),this.path=Le(t),this.portable=!!i.portable,this.maxReadSize=i.maxReadSize||16777216,this.linkCache=i.linkCache||new Map,this.statCache=i.statCache||new Map,this.preservePaths=!!i.preservePaths,this.cwd=Le(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?Le(i.prefix):void 0,this.onWriteEntry=i.onWriteEntry,"function"==typeof i.onwarn&&this.on("warn",i.onwarn);let s=!1;if(!this.preservePaths){const[t,e]=wi(this.path);t&&"string"==typeof e&&(this.path=e,s=t)}var r;this.win32=!!i.win32||"win32"===process.platform,this.win32&&(this.path=(r=this.path.replace(/\\/g,"/"),gi.reduce((t,e)=>t.split(e).join(_i.get(e)),r)),t=t.replace(/\\/g,"/")),this.absolute=Le(i.absolute||o.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});const n=this.statCache.get(this.absolute);n?this[Ni](n):this[Ii]()}warn(t,e,i={}){return De(this,t,e,i)}emit(t,...e){return"error"===t&&(this.#u=!0),super.emit(t,...e)}[Ii](){e.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ni](e)})}[Ni](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Yi(t),this.emit("stat",t),this[Oi]()}[Oi](){switch(this.type){case"File":return this[Ti]();case"Directory":return this[ki]();case"SymbolicLink":return this[Li]();default:return this.end()}}[zi](t){return pi(t,"Directory"===this.type,this.portable)}[Hi](t){return vi(t,this.prefix)}[Di](){if(!this.stat)throw new Error("cannot write header before stat");"Directory"===this.type&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new le({path:this[Hi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[Hi](this.linkpath):this.linkpath,mode:this[zi](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:"Unsupported"===this.type?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 ve({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[Hi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[Hi](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());const t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[ki](){if(!this.stat)throw new Error("cannot create directory entry without stat");"/"!==this.path.slice(-1)&&(this.path+="/"),this.stat.size=0,this[Di](),this.end()}[Li](){e.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Fi](e)})}[Fi](t){this.linkpath=Le(t),this[Di](),this.end()}[xi](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Le(o.relative(this.cwd,t)),this.stat.size=0,this[Di](),this.end()}[Ti](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){const t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(0===e?.indexOf(this.cwd))return this[xi](e);this.linkCache.set(t,this.absolute)}if(this[Di](),0===this.stat.size)return this.end();this[Mi]()}[Mi](){e.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Ci](e)})}[Ci](t){if(this.fd=t,this.#u)return this[Pi]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;const 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[Ai]()}[Ai](){const{fd:t,buf:i,offset:s,length:r,pos:n}=this;if(void 0===t||void 0===i)throw new Error("cannot read file without first opening");e.read(t,i,s,r,n,(t,e)=>{if(t)return this[Pi](()=>this.emit("error",t));this[Bi](e)})}[Pi](t=()=>{}){void 0!==this.fd&&e.close(this.fd,t)}[Bi](t){if(t<=0&&this.remain>0){const t=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[Pi](()=>this.emit("error",t))}if(t>this.remain){const t=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[Pi](()=>this.emit("error",t))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let e=t;e<this.length&&t<this.blockRemain;e++)this.buf[e+this.offset]=0,t++,this.remain++;const e=0===this.offset&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[ji]():this[Ui](()=>this[ji]())}[Ui](t){this.once("drain",t)}write(t,e,i){if("function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,"string"==typeof e?e:"utf8")),this.blockRemain<t.length){const t=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",t)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,i)}[ji](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[Pi](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new 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[Ai]()}}class Wi extends Zi{sync=!0;[Ii](){this[Ni](e.lstatSync(this.absolute))}[Li](){this[Fi](e.readlinkSync(this.absolute))}[Mi](){this[Ci](e.openSync(this.absolute,"r"))}[Ai](){let t=!0;try{const{fd:i,buf:s,offset:r,length:n,pos:h}=this;if(void 0===i||void 0===s)throw new Error("fd and buf must be set in READ method");const o=e.readSync(i,s,r,n,h);this[Bi](o),t=!1}finally{if(t)try{this[Pi](()=>{})}catch(t){}}}[Ui](t){t()}[Pi](t=()=>{}){void 0!==this.fd&&e.closeSync(this.fd),t()}}class Gi extends et{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 De(this,t,e,i)}constructor(t,e={}){const i=Ct(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;const{type:s}=t;if("Unsupported"===s)throw new Error("writing entry that should be ignored");this.type=s,"Directory"===this.type&&this.portable&&(this.noMtime=!0),this.prefix=i.prefix,this.path=Le(t.path),this.mode=void 0!==t.mode?this[zi](t.mode):void 0,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=void 0!==t.linkpath?Le(t.linkpath):void 0,"function"==typeof i.onwarn&&this.on("warn",i.onwarn);let r=!1;if(!this.preservePaths){const[t,e]=wi(this.path);t&&"string"==typeof e&&(this.path=e,r=t)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new le({path:this[Hi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[Hi](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 ve({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[Hi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[Hi](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());const n=this.header?.block;if(!n)throw new Error("failed to encode header");super.write(n),t.pipe(this)}[Hi](t){return vi(t,this.prefix)}[zi](t){return pi(t,"Directory"===this.type,this.portable)}write(t,e,i){"function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,"string"==typeof e?e:"utf8"));const s=t.length;if(s>this.blockRemain)throw new 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)),"function"==typeof t&&(i=t,e=void 0,t=void 0),"function"==typeof e&&(i=e,e=void 0),"string"==typeof t&&(t=Buffer.from(t,e??"utf8")),i&&this.once("finish",i),t?super.end(t,i):super.end(i),this}}const Yi=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";class Vi{tail;head;length=0;static create(t=[]){return new Vi(t)}constructor(t=[]){for(const e of t)this.push(e)}*[Symbol.iterator](){for(let t=this.head;t;t=t.next)yield t.value}removeNode(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");const e=t.next,i=t.prev;return e&&(e.prev=i),i&&(i.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=i),this.length--,t.next=void 0,t.prev=void 0,t.list=void 0,e}unshiftNode(t){if(t===this.head)return;t.list&&t.list.removeNode(t);const e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}pushNode(t){if(t===this.tail)return;t.list&&t.list.removeNode(t);const e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}push(...t){for(let e=0,i=t.length;e<i;e++)qi(this,t[e]);return this.length}unshift(...t){for(var e=0,i=t.length;e<i;e++)Ki(this,t[e]);return this.length}pop(){if(!this.tail)return;const t=this.tail.value,e=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,e.list=void 0,this.length--,t}shift(){if(!this.head)return;const t=this.head.value,e=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,e.list=void 0,this.length--,t}forEach(t,e){e=e||this;for(let i=this.head,s=0;i;s++)t.call(e,i.value,s,this),i=i.next}forEachReverse(t,e){e=e||this;for(let i=this.tail,s=this.length-1;i;s--)t.call(e,i.value,s,this),i=i.prev}get(t){let e=0,i=this.head;for(;i&&e<t;e++)i=i.next;if(e===t&&i)return i.value}getReverse(t){let e=0,i=this.tail;for(;i&&e<t;e++)i=i.prev;if(e===t&&i)return i.value}map(t,e){e=e||this;const i=new Vi;for(let s=this.head;s;)i.push(t.call(e,s.value,this)),s=s.next;return i}mapReverse(t,e){e=e||this;var i=new Vi;for(let s=this.tail;s;)i.push(t.call(e,s.value,this)),s=s.prev;return i}reduce(t,e){let i,s=this.head;if(arguments.length>1)i=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");s=this.head.next,i=this.head.value}for(var r=0;s;r++)i=t(i,s.value,r),s=s.next;return i}reduceReverse(t,e){let i,s=this.tail;if(arguments.length>1)i=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");s=this.tail.prev,i=this.tail.value}for(let e=this.length-1;s;e--)i=t(i,s.value,e),s=s.prev;return i}toArray(){const t=new Array(this.length);for(let e=0,i=this.head;i;e++)t[e]=i.value,i=i.next;return t}toArrayReverse(){const t=new Array(this.length);for(let e=0,i=this.tail;i;e++)t[e]=i.value,i=i.prev;return t}slice(t=0,e=this.length){e<0&&(e+=this.length),t<0&&(t+=this.length);const i=new Vi;if(e<t||e<0)return i;t<0&&(t=0),e>this.length&&(e=this.length);let s=this.head,r=0;for(r=0;s&&r<t;r++)s=s.next;for(;s&&r<e;r++,s=s.next)i.push(s.value);return i}sliceReverse(t=0,e=this.length){e<0&&(e+=this.length),t<0&&(t+=this.length);const i=new Vi;if(e<t||e<0)return i;t<0&&(t=0),e>this.length&&(e=this.length);let s=this.length,r=this.tail;for(;r&&s>e;s--)r=r.prev;for(;r&&s>t;s--,r=r.prev)i.push(r.value);return i}splice(t,e=0,...i){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);let s=this.head;for(let e=0;s&&e<t;e++)s=s.next;const r=[];for(let t=0;s&&t<e;t++)r.push(s.value),s=this.removeNode(s);s?s!==this.tail&&(s=s.prev):s=this.tail;for(const t of i)s=$i(this,s,t);return r}reverse(){const t=this.head,e=this.tail;for(let e=t;e;e=e.prev){const t=e.prev;e.prev=e.next,e.next=t}return this.head=e,this.tail=t,this}}function $i(t,e,i){const s=e,r=e?e.next:t.head,n=new Xi(i,s,r,t);return void 0===n.next&&(t.tail=n),void 0===n.prev&&(t.head=n),t.length++,n}function qi(t,e){t.tail=new Xi(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function Ki(t,e){t.head=new Xi(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}class Xi{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}}class Qi{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}}const Ji=Buffer.alloc(1024),ts=Symbol("onStat"),es=Symbol("ended"),is=Symbol("queue"),ss=Symbol("current"),rs=Symbol("process"),ns=Symbol("processing"),hs=Symbol("processJob"),os=Symbol("jobs"),as=Symbol("jobDone"),ls=Symbol("addFSEntry"),ds=Symbol("addTarEntry"),cs=Symbol("stat"),us=Symbol("readdir"),ms=Symbol("onreaddir"),fs=Symbol("pipe"),ps=Symbol("entry"),ys=Symbol("entryOpt"),bs=Symbol("writeEntryClass"),ws=Symbol("write"),Es=Symbol("ondrain");class gs extends et{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[bs];onWriteEntry;[is];[os]=0;[ns]=!1;[es]=!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=Le(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[bs]=Zi,"function"==typeof t.onwarn&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&("object"!=typeof t.gzip&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new Kt(t.gzip)),t.brotli&&("object"!=typeof t.brotli&&(t.brotli={}),this.zip=new Jt(t.brotli)),t.zstd&&("object"!=typeof t.zstd&&(t.zstd={}),this.zip=new ie(t.zstd)),!this.zip)throw new Error("impossible");const e=this.zip;e.on("data",t=>super.write(t)),e.on("end",()=>super.end()),e.on("drain",()=>this[Es]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Es]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter="function"==typeof t.filter?t.filter:()=>!0,this[is]=new Vi,this[os]=0,this.jobs=Number(t.jobs)||4,this[ns]=!1,this[es]=!1}[ws](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,i){return"function"==typeof t&&(i=t,t=void 0),"function"==typeof e&&(i=e,e=void 0),t&&this.add(t),this[es]=!0,this[rs](),i&&i(),this}write(t){if(this[es])throw new Error("write after end");return t instanceof xe?this[ds](t):this[ls](t),this.flowing}[ds](t){const e=Le(o.resolve(this.cwd,t.path));if(this.filter(t.path,t)){const i=new Qi(t.path,e);i.entry=new Gi(t,this[ys](i)),i.entry.on("end",()=>this[as](i)),this[os]+=1,this[is].push(i)}else t.resume();this[rs]()}[ls](t){const e=Le(o.resolve(this.cwd,t));this[is].push(new Qi(t,e)),this[rs]()}[cs](t){t.pending=!0,this[os]+=1;const i=this.follow?"stat":"lstat";e[i](t.absolute,(e,i)=>{t.pending=!1,this[os]-=1,e?this.emit("error",e):this[ts](t,i)})}[ts](t,e){this.statCache.set(t.absolute,e),t.stat=e,this.filter(t.path,e)||(t.ignore=!0),this[rs]()}[us](t){t.pending=!0,this[os]+=1,e.readdir(t.absolute,(e,i)=>{if(t.pending=!1,this[os]-=1,e)return this.emit("error",e);this[ms](t,i)})}[ms](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[rs]()}[rs](){if(!this[ns]){this[ns]=!0;for(let t=this[is].head;t&&this[os]<this.jobs;t=t.next)if(this[hs](t.value),t.value.ignore){const e=t.next;this[is].removeNode(t),t.next=e}this[ns]=!1,this[es]&&!this[is].length&&0===this[os]&&(this.zip?this.zip.end(Ji):(super.write(Ji),super.end()))}}get[ss](){return this[is]&&this[is].head&&this[is].head.value}[as](t){this[is].shift(),this[os]-=1,this[rs]()}[hs](t){if(!t.pending)if(t.entry)t!==this[ss]||t.piped||this[fs](t);else{if(!t.stat){const e=this.statCache.get(t.absolute);e?this[ts](t,e):this[cs](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){const e=this.readdirCache.get(t.absolute);if(e?this[ms](t,e):this[us](t),!t.readdir)return}t.entry=this[ps](t),t.entry?t!==this[ss]||t.piped||this[fs](t):t.ignore=!0}}}[ys](t){return{onwarn:(t,e,i)=>this.warn(t,e,i),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}}[ps](t){this[os]+=1;try{return new this[bs](t.path,this[ys](t)).on("end",()=>this[as](t)).on("error",t=>this.emit("error",t))}catch(t){this.emit("error",t)}}[Es](){this[ss]&&this[ss].entry&&this[ss].entry.resume()}[fs](t){t.piped=!0,t.readdir&&t.readdir.forEach(e=>{const i=t.path,s="./"===i?"":i.replace(/\/*$/,"/");this[ls](s+e)});const e=t.entry,i=this.zip;if(!e)throw new Error("cannot pipe without source");i?e.on("data",t=>{i.write(t)||e.pause()}):e.on("data",t=>{super.write(t)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,i={}){De(this,t,e,i)}}class Rs extends gs{sync=!0;constructor(t){super(t),this[bs]=Wi}pause(){}resume(){}[cs](t){const i=this.follow?"statSync":"lstatSync";this[ts](t,e[i](t.absolute))}[us](t){this[ms](t,e.readdirSync(t.absolute))}[fs](t){const e=t.entry,i=this.zip;if(t.readdir&&t.readdir.forEach(e=>{const i=t.path,s="./"===i?"":i.replace(/\/*$/,"/");this[ls](s+e)}),!e)throw new Error("Cannot pipe without source");i?e.on("data",t=>{i.write(t)}):e.on("data",t=>{super[ws](t)})}}const _s=(t,e)=>{e.forEach(e=>{"@"===e.charAt(0)?fi({file:n.resolve(t.cwd,e.slice(1)),sync:!0,noResume:!0,onReadEntry:e=>t.add(e)}):t.add(e)}),t.end()},Ss=async(t,e)=>{for(let i=0;i<e.length;i++){const s=String(e[i]);"@"===s.charAt(0)?await fi({file:n.resolve(String(t.cwd),s.slice(1)),noResume:!0,onReadEntry:e=>{t.add(e)}}):t.add(s)}t.end()},vs=Pt((t,e)=>{const i=new Rs(t),s=new Bt(t.file,{mode:t.mode||438});i.pipe(s),_s(i,e)},(t,e)=>{const i=new gs(t),s=new Nt(t.file,{mode:t.mode||438});i.pipe(s);const r=new Promise((t,e)=>{s.on("error",e),s.on("close",t),i.on("error",e)});return Ss(i,e),r},(t,e)=>{const i=new Rs(t);return _s(i,e),i},(t,e)=>{const i=new gs(t);return Ss(i,e),i},(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Os="win32"===(process.env.__FAKE_PLATFORM__||process.platform),{O_CREAT:Ts,O_TRUNC:ks,O_WRONLY:Ls}=e.constants,xs=Number(process.env.__FAKE_FS_O_FILENAME__)||e.constants.UV_FS_O_FILEMAP||0,Ds=xs|ks|Ts|Ls,As=Os&&xs?t=>t<524288?Ds:"w":()=>"w",Is=(t,e,i)=>{try{return h.lchownSync(t,e,i)}catch(t){if("ENOENT"!==t?.code)throw t}},Ns=(t,e,i,s)=>{h.lchown(t,e,i,t=>{s(t&&"ENOENT"!==t?.code?t:null)})},Bs=(t,e,i,s,r)=>{if(e.isDirectory())Fs(n.resolve(t,e.name),i,s,h=>{if(h)return r(h);const o=n.resolve(t,e.name);Ns(o,i,s,r)});else{const h=n.resolve(t,e.name);Ns(h,i,s,r)}},Fs=(t,e,i,s)=>{h.readdir(t,{withFileTypes:!0},(r,n)=>{if(r){if("ENOENT"===r.code)return s();if("ENOTDIR"!==r.code&&"ENOTSUP"!==r.code)return s(r)}if(r||!n.length)return Ns(t,e,i,s);let h=n.length,o=null;const a=r=>{if(!o)return r?s(o=r):0===--h?Ns(t,e,i,s):void 0};for(const s of n)Bs(t,s,e,i,a)})},Ms=(t,e,i,s)=>{e.isDirectory()&&Cs(n.resolve(t,e.name),i,s),Is(n.resolve(t,e.name),i,s)},Cs=(t,e,i)=>{let s;try{s=h.readdirSync(t,{withFileTypes:!0})}catch(s){const r=s;if("ENOENT"===r?.code)return;if("ENOTDIR"===r?.code||"ENOTSUP"===r?.code)return Is(t,e,i);throw r}for(const r of s)Ms(t,r,e,i);return Is(t,e,i)};class Ps 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"}}class zs 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"}}const Us=(t,e,i,s,r,o,a)=>{if(!e.length)return a(null,o);const l=e.shift(),d=Le(n.resolve(t+"/"+l));h.mkdir(d,i,js(d,e,i,s,r,o,a))},js=(t,e,i,s,r,n,o)=>a=>{a?h.lstat(t,(l,d)=>{if(l)l.path=l.path&&Le(l.path),o(l);else if(d.isDirectory())Us(t,e,i,s,r,n,o);else if(s)h.unlink(t,a=>{if(a)return o(a);h.mkdir(t,i,js(t,e,i,s,r,n,o))});else{if(d.isSymbolicLink())return o(new zs(t,t+"/"+e.join("/")));o(a)}}):Us(t,e,i,s,r,n=n||t,o)},Hs=Object.create(null),Zs=new Set,Ws="win32"===(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform);class Gs{#m=new Map;#f=new Map;#p=new Set;reserve(t,e){t=Ws?["win32 parallelization disabled"]:t.map(t=>ui(n.join((t=>{Zs.has(t)?Zs.delete(t):Hs[t]=t.normalize("NFD"),Zs.add(t);const e=Hs[t];let i=Zs.size-1e4;if(i>1e3)for(const t of Zs)if(Zs.delete(t),delete Hs[t],--i<=0)break;return e})(t))).toLowerCase());const i=new Set(t.map(t=>(t=>{const e=t.split("/").slice(0,-1).reduce((t,e)=>{const i=t[t.length-1];return void 0!==i&&(e=n.join(i,e)),t.push(e||"/"),t},[]);return e})(t)).reduce((t,e)=>t.concat(e)));this.#f.set(e,{dirs:i,paths:t});for(const i of t){const t=this.#m.get(i);t?t.push(e):this.#m.set(i,[e])}for(const t of i){const i=this.#m.get(t);if(i){const t=i[i.length-1];t instanceof Set?t.add(e):i.push(new Set([e]))}else this.#m.set(t,[new Set([e])])}return this.#y(e)}#b(t){const e=this.#f.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(t=>this.#m.get(t)),dirs:[...e.dirs].map(t=>this.#m.get(t))}}check(t){const{paths:e,dirs:i}=this.#b(t);return e.every(e=>e&&e[0]===t)&&i.every(e=>e&&e[0]instanceof Set&&e[0].has(t))}#y(t){return!(this.#p.has(t)||!this.check(t)||(this.#p.add(t),t(()=>this.#w(t)),0))}#w(t){if(!this.#p.has(t))return!1;const e=this.#f.get(t);if(!e)throw new Error("invalid reservation");const{paths:i,dirs:s}=e,r=new Set;for(const e of i){const i=this.#m.get(e);if(!i||i?.[0]!==t)continue;const s=i[1];if(s)if(i.shift(),"function"==typeof s)r.add(s);else for(const t of s)r.add(t);else this.#m.delete(e)}for(const e of s){const i=this.#m.get(e),s=i?.[0];if(i&&s instanceof Set)if(1!==s.size||1!==i.length)if(1===s.size){i.shift();const t=i[0];"function"==typeof t&&r.add(t)}else s.delete(t);else this.#m.delete(e)}return this.#p.delete(t),r.forEach(t=>this.#y(t)),!0}}const Ys=Symbol("onEntry"),Vs=Symbol("checkFs"),$s=Symbol("checkFs2"),qs=Symbol("isReusable"),Ks=Symbol("makeFs"),Xs=Symbol("file"),Qs=Symbol("directory"),Js=Symbol("link"),tr=Symbol("symlink"),er=Symbol("hardlink"),ir=Symbol("unsupported"),sr=Symbol("checkPath"),rr=Symbol("stripAbsolutePath"),nr=Symbol("mkdir"),hr=Symbol("onError"),or=Symbol("pending"),ar=Symbol("pend"),lr=Symbol("unpend"),dr=Symbol("ended"),cr=Symbol("maybeClose"),ur=Symbol("skip"),mr=Symbol("doChown"),fr=Symbol("uid"),pr=Symbol("gid"),yr=Symbol("checkedCwd"),br="win32"===(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform),wr=(t,e,i)=>void 0!==t&&t===t>>>0?t:void 0!==e&&e===e>>>0?e:i;class Er extends ci{[dr]=!1;[yr]=!1;[or]=0;reservations=new Gs;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[dr]=!0,this[cr]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,"number"==typeof t.uid||"number"==typeof t.gid){if("number"!=typeof t.uid||"number"!=typeof t.gid)throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new 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;void 0===t.preserveOwner&&"number"!=typeof t.uid?this.preserveOwner=!(!process.getuid||0!==process.getuid()):this.preserveOwner=!!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="number"==typeof t.maxDepth?t.maxDepth:1024,this.forceChown=!0===t.forceChown,this.win32=!!t.win32||br,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Le(n.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?"number"==typeof t.processUmask?t.processUmask:process.umask():0,this.umask="number"==typeof t.umask?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",t=>this[Ys](t))}warn(t,e,i={}){return"TAR_BAD_ARCHIVE"!==t&&"TAR_ABORT"!==t||(i.recoverable=!1),super.warn(t,e,i)}[cr](){this[dr]&&0===this[or]&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[rr](t,e){const i=t[e];if(!i||this.preservePaths)return!0;const s=i.split("/");if(s.includes("..")||br&&/^[a-z]:\.\.$/i.test(s[0]??""))return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:i}),!1;const[r,n]=wi(i);return r&&(t[e]=String(n),this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute ${e}`,{entry:t,[e]:i})),!0}[sr](t){const e=Le(t.path),i=e.split("/");if(this.strip){if(i.length<this.strip)return!1;if("Link"===t.type){const e=Le(String(t.linkpath)).split("/");if(!(e.length>=this.strip))return!1;t.linkpath=e.slice(this.strip).join("/")}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[rr](t,"path")||!this[rr](t,"linkpath"))return!1;if(n.isAbsolute(t.path)?t.absolute=Le(n.resolve(t.path)):t.absolute=Le(n.resolve(this.cwd,t.path)),!this.preservePaths&&"string"==typeof t.absolute&&0!==t.absolute.indexOf(this.cwd+"/")&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Le(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&"Directory"!==t.type&&"GNUDumpDir"!==t.type)return!1;if(this.win32){const{root:e}=n.win32.parse(String(t.absolute));t.absolute=e+Si(String(t.absolute).slice(e.length));const{root:i}=n.win32.parse(t.path);t.path=i+Si(t.path.slice(i.length))}return!0}[Ys](t){if(!this[sr](t))return t.resume();switch(c.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=448|t.mode);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Vs](t);default:return this[ir](t)}}[hr](t,e){"CwdError"===t.name?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[lr](),e.resume())}[nr](t,e,i){((t,e,i)=>{t=Le(t);const s=e.umask??18,r=448|e.mode,o=0!==(r&s),a=e.uid,l=e.gid,d="number"==typeof a&&"number"==typeof l&&(a!==e.processUid||l!==e.processGid),c=e.preserve,u=e.unlink,f=Le(e.cwd),p=(e,s)=>{e?i(e):s&&d?Fs(s,a,l,t=>p(t)):o?h.chmod(t,r,i):i()};if(t===f)return((t,e)=>{h.stat(t,(i,s)=>{!i&&s.isDirectory()||(i=new Ps(t,i?.code||"ENOTDIR")),e(i)})})(t,p);if(c)return m.mkdir(t,{mode:r,recursive:!0}).then(t=>p(null,t??void 0),p);const y=Le(n.relative(f,t)).split("/");Us(f,y,r,u,f,void 0,p)})(Le(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)}[mr](t){return this.forceChown||this.preserveOwner&&("number"==typeof t.uid&&t.uid!==this.processUid||"number"==typeof t.gid&&t.gid!==this.processGid)||"number"==typeof this.uid&&this.uid!==this.processUid||"number"==typeof this.gid&&this.gid!==this.processGid}[fr](t){return wr(this.uid,t.uid,this.processUid)}[pr](t){return wr(this.gid,t.gid,this.processGid)}[Xs](t,e){const i="number"==typeof t.mode?4095&t.mode:this.fmode,s=new Nt(String(t.absolute),{flags:As(t.size),mode:i,autoClose:!1});s.on("error",i=>{s.fd&&h.close(s.fd,()=>{}),s.write=()=>!0,this[hr](i,t),e()});let r=1;const n=i=>{if(i)return s.fd&&h.close(s.fd,()=>{}),this[hr](i,t),void e();0===--r&&void 0!==s.fd&&h.close(s.fd,i=>{i?this[hr](i,t):this[lr](),e()})};s.on("finish",()=>{const e=String(t.absolute),i=s.fd;if("number"==typeof i&&t.mtime&&!this.noMtime){r++;const s=t.atime||new Date,o=t.mtime;h.futimes(i,s,o,t=>t?h.utimes(e,s,o,e=>n(e&&t)):n())}if("number"==typeof i&&this[mr](t)){r++;const s=this[fr](t),o=this[pr](t);"number"==typeof s&&"number"==typeof o&&h.fchown(i,s,o,t=>t?h.chown(e,s,o,e=>n(e&&t)):n())}n()});const o=this.transform&&this.transform(t)||t;o!==t&&(o.on("error",i=>{this[hr](i,t),e()}),t.pipe(o)),o.pipe(s)}[Qs](t,e){const i="number"==typeof t.mode?4095&t.mode:this.dmode;this[nr](String(t.absolute),i,i=>{if(i)return this[hr](i,t),void e();let s=1;const r=()=>{0===--s&&(e(),this[lr](),t.resume())};t.mtime&&!this.noMtime&&(s++,h.utimes(String(t.absolute),t.atime||new Date,t.mtime,r)),this[mr](t)&&(s++,h.chown(String(t.absolute),Number(this[fr](t)),Number(this[pr](t)),r)),r()})}[ir](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[tr](t,e){this[Js](t,String(t.linkpath),"symlink",e)}[er](t,e){const i=Le(n.resolve(this.cwd,String(t.linkpath)));this[Js](t,i,"link",e)}[ar](){this[or]++}[lr](){this[or]--,this[cr]()}[ur](t){this[lr](),t.resume()}[qs](t,e){return"File"===t.type&&!this.unlink&&e.isFile()&&e.nlink<=1&&!br}[Vs](t){this[ar]();const e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,e=>this[$s](t,e))}[$s](t,e){const i=t=>{e(t)},s=()=>{if(t.absolute!==this.cwd){const e=Le(n.dirname(String(t.absolute)));if(e!==this.cwd)return this[nr](e,this.dmode,e=>{if(e)return this[hr](e,t),void i();r()})}r()},r=()=>{h.lstat(String(t.absolute),(e,s)=>{if(s&&(this.keep||this.newer&&s.mtime>(t.mtime??s.mtime)))return this[ur](t),void i();if(e||this[qs](t,s))return this[Ks](null,t,i);if(s.isDirectory()){if("Directory"===t.type){const e=e=>this[Ks](e??null,t,i);return this.chmod&&t.mode&&(4095&s.mode)!==t.mode?h.chmod(String(t.absolute),Number(t.mode),e):e()}if(t.absolute!==this.cwd)return h.rmdir(String(t.absolute),e=>this[Ks](e??null,t,i))}if(t.absolute===this.cwd)return this[Ks](null,t,i);((t,e)=>{if(!br)return h.unlink(t,e);const i=t+".DELETE."+u.randomBytes(16).toString("hex");h.rename(t,i,t=>{if(t)return e(t);h.unlink(i,e)})})(String(t.absolute),e=>this[Ks](e??null,t,i))})};this[yr]?s():(()=>{this[nr](this.cwd,this.dmode,e=>{if(e)return this[hr](e,t),void i();this[yr]=!0,s()})})()}[Ks](t,e,i){if(t)return this[hr](t,e),void i();switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Xs](e,i);case"Link":return this[er](e,i);case"SymbolicLink":return this[tr](e,i);case"Directory":case"GNUDumpDir":return this[Qs](e,i)}}[Js](t,e,i,s){h[i](e,String(t.absolute),e=>{e?this[hr](e,t):(this[lr](),t.resume()),s()})}}const gr=t=>{try{return[null,t()]}catch(t){return[t,null]}};class Rr extends Er{sync=!0;[Ks](t,e){return super[Ks](t,e,()=>{})}[Vs](t){if(!this[yr]){const e=this[nr](this.cwd,this.dmode);if(e)return this[hr](e,t);this[yr]=!0}if(t.absolute!==this.cwd){const e=Le(n.dirname(String(t.absolute)));if(e!==this.cwd){const i=this[nr](e,this.dmode);if(i)return this[hr](i,t)}}const[e,i]=gr(()=>h.lstatSync(String(t.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(t.mtime??i.mtime)))return this[ur](t);if(e||this[qs](t,i))return this[Ks](null,t);if(i.isDirectory()){if("Directory"===t.type){const e=this.chmod&&t.mode&&(4095&i.mode)!==t.mode,[s]=e?gr(()=>{h.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[Ks](s,t)}const[e]=gr(()=>h.rmdirSync(String(t.absolute)));this[Ks](e,t)}const[s]=t.absolute===this.cwd?[]:gr(()=>(t=>{if(!br)return h.unlinkSync(t);const e=t+".DELETE."+u.randomBytes(16).toString("hex");h.renameSync(t,e),h.unlinkSync(e)})(String(t.absolute)));this[Ks](s,t)}[Xs](t,e){const i="number"==typeof t.mode?4095&t.mode:this.fmode,s=i=>{let s;try{h.closeSync(r)}catch(t){s=t}(i||s)&&this[hr](i||s,t),e()};let r;try{r=h.openSync(String(t.absolute),As(t.size),i)}catch(t){return s(t)}const n=this.transform&&this.transform(t)||t;n!==t&&(n.on("error",e=>this[hr](e,t)),t.pipe(n)),n.on("data",t=>{try{h.writeSync(r,t,0,t.length)}catch(t){s(t)}}),n.on("end",()=>{let e=null;if(t.mtime&&!this.noMtime){const i=t.atime||new Date,s=t.mtime;try{h.futimesSync(r,i,s)}catch(r){try{h.utimesSync(String(t.absolute),i,s)}catch(t){e=r}}}if(this[mr](t)){const i=this[fr](t),s=this[pr](t);try{h.fchownSync(r,Number(i),Number(s))}catch(r){try{h.chownSync(String(t.absolute),Number(i),Number(s))}catch(t){e=e||r}}}s(e)})}[Qs](t,e){const i="number"==typeof t.mode?4095&t.mode:this.dmode,s=this[nr](String(t.absolute),i);if(s)return this[hr](s,t),void e();if(t.mtime&&!this.noMtime)try{h.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch(s){}if(this[mr](t))try{h.chownSync(String(t.absolute),Number(this[fr](t)),Number(this[pr](t)))}catch(s){}e(),t.resume()}[nr](t,e){try{return((t,e)=>{t=Le(t);const i=e.umask??18,s=448|e.mode,r=0!==(s&i),o=e.uid,a=e.gid,l="number"==typeof o&&"number"==typeof a&&(o!==e.processUid||a!==e.processGid),d=e.preserve,c=e.unlink,u=Le(e.cwd),m=e=>{e&&l&&Cs(e,o,a),r&&h.chmodSync(t,s)};if(t===u)return(t=>{let e,i=!1;try{i=h.statSync(t).isDirectory()}catch(t){e=t?.code}finally{if(!i)throw new Ps(t,e??"ENOTDIR")}})(u),m();if(d)return m(h.mkdirSync(t,{mode:s,recursive:!0})??void 0);const f=Le(n.relative(u,t)).split("/");let p;for(let e=f.shift(),i=u;e&&(i+="/"+e);e=f.shift()){i=Le(n.resolve(i));try{h.mkdirSync(i,s),p=p||i}catch(t){const e=h.lstatSync(i);if(e.isDirectory())continue;if(c){h.unlinkSync(i),h.mkdirSync(i,s),p=p||i;continue}if(e.isSymbolicLink())return new zs(i,i+"/"+f.join("/"))}}return m(p)})(Le(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(t){return t}}[Js](t,e,i,s){const r=`${i}Sync`;try{h[r](e,String(t.absolute)),s(),t.resume()}catch(e){return this[hr](e,t)}}}Pt(t=>{const e=new Rr(t),i=t.file,s=h.statSync(i),r=t.maxReadSize||16777216;new It(i,{readSize:r,size:s.size}).pipe(e)},(t,e)=>{const i=new Er(t),s=t.maxReadSize||16777216,r=t.file;return new Promise((t,e)=>{i.on("error",e),i.on("close",t),h.stat(r,(t,n)=>{if(t)e(t);else{const t=new At(r,{readSize:s,size:n.size});t.on("error",e),t.pipe(i)}})})},t=>new Rr(t),t=>new Er(t),(t,e)=>{e?.length&&mi(t,e)});const _r=(t,e)=>{e.forEach(e=>{"@"===e.charAt(0)?fi({file:n.resolve(t.cwd,e.slice(1)),sync:!0,noResume:!0,onReadEntry:e=>t.add(e)}):t.add(e)}),t.end()},Sr=Pt((t,e)=>{const i=new Rs(t);let s,r,n=!0;try{try{s=h.openSync(t.file,"r+")}catch(e){if("ENOENT"!==e?.code)throw e;s=h.openSync(t.file,"w+")}const o=h.fstatSync(s),a=Buffer.alloc(512);t:for(r=0;r<o.size;r+=512){for(let t=0,e=0;t<512;t+=e){if(e=h.readSync(s,a,t,a.length-t,r+t),0===r&&31===a[0]&&139===a[1])throw new Error("cannot append to compressed archives");if(!e)break t}const e=new le(a);if(!e.cksumValid)break;const i=512*Math.ceil((e.size||0)/512);if(r+i+512>o.size)break;r+=i,t.mtimeCache&&e.mtime&&t.mtimeCache.set(String(e.path),e.mtime)}n=!1,((t,e,i,s,r)=>{const n=new Bt(t.file,{fd:s,start:i});e.pipe(n),_r(e,r)})(t,i,r,s,e)}finally{if(n)try{h.closeSync(s)}catch(t){}}},(t,e)=>{e=Array.from(e);const i=new gs(t),s=new Promise((s,r)=>{i.on("error",r);let o="r+";const a=(l,d)=>l&&"ENOENT"===l.code&&"r+"===o?(o="w+",h.open(t.file,o,a)):l||!d?r(l):void h.fstat(d,(o,a)=>{if(o)return h.close(d,()=>r(o));((e,i,s)=>{const r=(t,i)=>{t?h.close(e,e=>s(t)):s(null,i)};let n=0;if(0===i)return r(null,0);let o=0;const a=Buffer.alloc(512),l=(s,d)=>{if(s||void 0===d)return r(s);if(o+=d,o<512&&d)return h.read(e,a,o,a.length-o,n+o,l);if(0===n&&31===a[0]&&139===a[1])return r(new Error("cannot append to compressed archives"));if(o<512)return r(null,n);const c=new le(a);if(!c.cksumValid)return r(null,n);const u=512*Math.ceil((c.size??0)/512);return n+u+512>i?r(null,n):(n+=u+512,n>=i?r(null,n):(t.mtimeCache&&c.mtime&&t.mtimeCache.set(String(c.path),c.mtime),o=0,void h.read(e,a,0,512,n,l)))};h.read(e,a,0,512,n,l)})(d,a.size,(h,o)=>{if(h)return r(h);const a=new Nt(t.file,{fd:d,start:o});i.pipe(a),a.on("error",r),a.on("close",s),(async(t,e)=>{for(let i=0;i<e.length;i++){const s=String(e[i]);"@"===s.charAt(0)?await fi({file:n.resolve(String(t.cwd),s.slice(1)),noResume:!0,onReadEntry:e=>t.add(e)}):t.add(s)}t.end()})(i,e)})});h.open(t.file,o,a)});return s},()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!t.file)throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")});Pt(Sr.syncFile,Sr.asyncFile,Sr.syncNoFile,Sr.asyncNoFile,(t,e=[])=>{Sr.validate?.(t,e),vr(t)});const vr=t=>{const e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(i,s)=>e(i,s)&&!((t.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0)):(e,i)=>!((t.mtimeCache?.get(e)??i.mtime??0)>(i.mtime??0))};exports.Header=le,exports.Pack=gs,exports.PackJob=Qi,exports.PackSync=Rs,exports.Parser=ci,exports.Pax=ve,exports.ReadEntry=xe,exports.Unpack=Er,exports.UnpackSync=Rr,exports.WriteEntry=Zi,exports.WriteEntrySync=Wi,exports.WriteEntryTar=Gi,exports.c=vs,exports.create=vs,exports.filesFilter=mi,exports.list=fi,exports.r=Sr,exports.replace=Sr,exports.t=fi;