@karmaniverous/stan-core 0.5.1 → 0.6.1
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 +29 -21
- package/dist/mjs/index-CERcUEt-.js +1 -0
- package/dist/mjs/index-DEnUXENF.js +1 -0
- package/dist/mjs/index-WrHikElU.js +1 -0
- package/dist/mjs/index.js +1 -1
- package/dist/mjs/typescript-CwUyYoqG.js +6 -0
- package/dist/stan.system.md +404 -437
- package/dist/types/index.d.ts +722 -74
- package/package.json +30 -25
- package/dist/cjs/classifier-ClvtQeTy.js +0 -1
- package/dist/cjs/index-B7xvXIws.js +0 -1
- package/dist/cjs/index.js +0 -1
- package/dist/mjs/index-CQYvnMvw.js +0 -1
package/package.json
CHANGED
|
@@ -17,13 +17,15 @@
|
|
|
17
17
|
"ignore": "^7.0.5",
|
|
18
18
|
"package-directory": "^8.1.0",
|
|
19
19
|
"picomatch": "^4.0.3",
|
|
20
|
+
"radash": "^12.1.1",
|
|
20
21
|
"yaml": "^2.8.2",
|
|
21
|
-
"zod": "^4.3.
|
|
22
|
+
"zod": "^4.3.6"
|
|
22
23
|
},
|
|
23
24
|
"description": "Engine for STAN — programmatic archiving/diffing/snapshotting, patch application, config loading, selection, and imports staging. No CLI/TTY concerns.",
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@dotenvx/dotenvx": "^1.
|
|
26
|
+
"@dotenvx/dotenvx": "^1.52.0",
|
|
26
27
|
"@eslint/js": "^9.39.2",
|
|
28
|
+
"@karmaniverous/stan-context": "^0.3.0",
|
|
27
29
|
"@rollup/plugin-alias": "^6.0.0",
|
|
28
30
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
29
31
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -33,9 +35,9 @@
|
|
|
33
35
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
34
36
|
"@types/fs-extra": "^11.0.4",
|
|
35
37
|
"@types/glob-parent": "^5.1.3",
|
|
36
|
-
"@types/node": "^25.0.
|
|
38
|
+
"@types/node": "^25.0.10",
|
|
37
39
|
"@types/picomatch": "^4.0.2",
|
|
38
|
-
"@vitest/coverage-v8": "^4.0.
|
|
40
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
39
41
|
"@vitest/eslint-plugin": "^1.6.6",
|
|
40
42
|
"auto-changelog": "^2.5.0",
|
|
41
43
|
"cross-env": "^10.1.0",
|
|
@@ -45,38 +47,32 @@
|
|
|
45
47
|
"eslint-plugin-prettier": "^5.5.5",
|
|
46
48
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
47
49
|
"eslint-plugin-tsdoc": "^0.5.0",
|
|
48
|
-
"happy-dom": "^20.3.
|
|
50
|
+
"happy-dom": "^20.3.7",
|
|
49
51
|
"jsonc-eslint-parser": "^2.4.2",
|
|
50
|
-
"knip": "^5.82.
|
|
52
|
+
"knip": "^5.82.1",
|
|
51
53
|
"lefthook": "^2.0.15",
|
|
52
|
-
"prettier": "^3.8.
|
|
53
|
-
"release-it": "^19.2.
|
|
54
|
+
"prettier": "^3.8.1",
|
|
55
|
+
"release-it": "^19.2.4",
|
|
54
56
|
"rimraf": "^6.1.2",
|
|
55
|
-
"rollup": "^4.
|
|
57
|
+
"rollup": "^4.56.0",
|
|
56
58
|
"rollup-plugin-dts": "^6.3.0",
|
|
57
|
-
"tar": "^7.5.
|
|
59
|
+
"tar": "^7.5.6",
|
|
58
60
|
"tslib": "^2.8.1",
|
|
59
61
|
"tsx": "^4.21.0",
|
|
60
62
|
"typedoc": "^0.28.16",
|
|
61
|
-
"typedoc-plugin-mdn-links": "^5.0
|
|
63
|
+
"typedoc-plugin-mdn-links": "^5.1.0",
|
|
62
64
|
"typedoc-plugin-replace-text": "^4.2.0",
|
|
63
65
|
"typescript": "^5.9.3",
|
|
64
|
-
"typescript-eslint": "^8.53.
|
|
65
|
-
"vitest": "^4.0.
|
|
66
|
+
"typescript-eslint": "^8.53.1",
|
|
67
|
+
"vitest": "^4.0.18"
|
|
66
68
|
},
|
|
67
69
|
"engines": {
|
|
68
70
|
"node": ">=20"
|
|
69
71
|
},
|
|
70
72
|
"exports": {
|
|
71
73
|
".": {
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
"default": "./dist/mjs/index.js"
|
|
75
|
-
},
|
|
76
|
-
"require": {
|
|
77
|
-
"types": "./dist/types/index.d.ts",
|
|
78
|
-
"default": "./dist/cjs/index.js"
|
|
79
|
-
}
|
|
74
|
+
"types": "./dist/types/index.d.ts",
|
|
75
|
+
"import": "./dist/mjs/index.js"
|
|
80
76
|
}
|
|
81
77
|
},
|
|
82
78
|
"files": [
|
|
@@ -96,9 +92,18 @@
|
|
|
96
92
|
"typescript"
|
|
97
93
|
],
|
|
98
94
|
"license": "BSD-3-Clause",
|
|
99
|
-
"main": "dist/
|
|
95
|
+
"main": "dist/mjs/index.js",
|
|
100
96
|
"module": "dist/mjs/index.js",
|
|
101
97
|
"name": "@karmaniverous/stan-core",
|
|
98
|
+
"peerDependencies": {
|
|
99
|
+
"@karmaniverous/stan-context": ">=0.0.0",
|
|
100
|
+
"typescript": ">=5"
|
|
101
|
+
},
|
|
102
|
+
"peerDependenciesMeta": {
|
|
103
|
+
"typescript": {
|
|
104
|
+
"optional": true
|
|
105
|
+
}
|
|
106
|
+
},
|
|
102
107
|
"publishConfig": {
|
|
103
108
|
"access": "public"
|
|
104
109
|
},
|
|
@@ -147,10 +152,10 @@
|
|
|
147
152
|
"release:pre": "npm run release -- --no-git.requireBranch --github.prerelease --preRelease",
|
|
148
153
|
"release": "dotenvx run -f .env.local -- release-it",
|
|
149
154
|
"relink": "npm uninstall -g @karmaniverous/stan-core && npm run build && npm link",
|
|
150
|
-
"test": "vitest --run --
|
|
155
|
+
"test": "vitest --run --silent",
|
|
151
156
|
"typecheck": "tsc"
|
|
152
157
|
},
|
|
153
158
|
"type": "module",
|
|
154
|
-
"types": "dist/index.d.ts",
|
|
155
|
-
"version": "0.
|
|
159
|
+
"types": "dist/types/index.d.ts",
|
|
160
|
+
"version": "0.6.1"
|
|
156
161
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var t=require("node:fs/promises"),e=require("node:path");const n=1048576;exports.classifyForArchive=async function(r,s){const i=[],a=[],o=[];await Promise.all(s.map(async s=>{const c=s.replace(/\\/g,"/");const l=e.resolve(r,s);let h=0;try{h=(await t.stat(l)).size}catch{return}let u,p=!1;try{p=await(async e=>{try{const n=await t.open(e,"r");try{const t=Buffer.allocUnsafe(8192),{bytesRead:e}=await n.read(t,0,t.length,0);for(let n=0;n<e;n+=1)if(0===t[n])return!0;return!1}finally{await n.close().catch(()=>{})}}catch{return!1}})(l)}catch{p=!1}if(p)return void a.push({path:c,size:h});i.push(c);try{if(h<=n||h<5*n){u=(t=>{const e=t.replace(/\r\n/g,"\n");return 0===e.length?0:e.split("\n").length})(await t.readFile(l,"utf8"))}}catch{}(h>n||"number"==typeof u&&u>3e3)&&o.push({path:c,size:h,loc:u})}));const c=[];if(a.length>0){c.push(`Binary files excluded from archive (${a.length.toString()}):`);for(const t of a)c.push(` - ${t.path} (${t.size.toString()} bytes)`);c.push("")}if(o.length>0){c.push(`Large text files (included; consider excludes if unwanted) (${o.length.toString()}):`);for(const t of o){const e=[` - ${t.path}`,`(${t.size.toString()} bytes)`];"number"==typeof t.loc&&e.push(`${t.loc.toString()} LOC`),c.push(e.join(" "))}c.push(""),c.push(`Thresholds: size > ${n.toString()} bytes or LOC > ${3e3.toString()}`)}0===c.length&&c.push("No archive warnings.");const l=c.join("\n")+(c.length?"\n":"");return{textFiles:i,excludedBinaries:a,largeText:o,warningsBody:l}};
|
|
@@ -1 +0,0 @@
|
|
|
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"),f=require("node:fs/promises");function m(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=m(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)||g(t)),w=t=>!!t&&"object"==typeof t&&t instanceof i.EventEmitter&&"function"==typeof t.pipe&&t.pipe!==s.Writable.prototype.pipe,g=t=>!!t&&"object"==typeof t&&t instanceof i.EventEmitter&&"function"==typeof t.write&&"function"==typeof t.end,E=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"),F=Symbol("buffer"),B=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"),q=Symbol("abort"),Y=Symbol("aborted"),V=Symbol("signal"),$=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;[B]=[];[F]=[];[z];[x];[G];[D];[E]=!1;[_]=!1;[S]=!1;[O]=!1;[v]=null;[M]=0;[U]=!1;[V];[Y]=!1;[$]=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[F]}),e&&!0===e.debugExposePipes&&Object.defineProperty(this,"pipes",{get:()=>this[B]});const{signal:i}=e;i&&(this[V]=i,i.aborted?this[q]():i.addEventListener("abort",()=>this[q]()))}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}[q](){this[Y]=!0,this.emit("abort",this[V]?.reason),this.destroy(this[V]?.reason)}get aborted(){return this[Y]}set aborted(t){}write(t,e,i){if(this[Y])return!1;if(this[E])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[F].length>1&&!this[z]&&(this[F]=[this[x]?this[F].join(""):Buffer.concat(this[F],this[M])]);const e=this[T](t||null,this[F][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[F][0]=i.slice(t),e=i.slice(0,t),this[M]-=t):(this[F][0]=i.subarray(t),e=i.subarray(0,t),this[M]-=t)}return this.emit("data",e),this[F].length||this[E]||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[E]=!0,this.writable=!1,!this[A]&&this[I]||this[R](),this}[N](){this[U]||(this[$]||this[B].length||(this[K]=!0),this[I]=!1,this[A]=!0,this.emit("resume"),this[F].length?this[k]():this[E]?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[F].push(t)}[P](){return this[z]?this[M]-=1:this[M]-=this[F][0].length,this[F].shift()}[k](t=!1){do{}while(this[L](this[P]())&&this[F].length);t||this[F].length||this[E]||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[B].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[B].find(e=>e.dest===t);e&&(1===this[B].length?(this[A]&&0===this[$]&&(this[A]=!1),this[B]=[]):this[B].splice(this[B].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[$]++,this[B].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[$]=this.listeners("data").length,0!==this[$]||this[K]||this[B].length||(this[A]=!1)),i}removeAllListeners(t){const e=super.removeAllListeners(t);return"data"!==t&&void 0!==t||(this[$]=0,this[K]||this[B].length||(this[A]=!1)),e}get emittedEnd(){return this[_]}[R](){this[S]||this[_]||this[U]||0!==this[F].length||!this[E]||(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[V]&&!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[B])!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[B])e.dest.write(t);this[K]||super.emit("data",t)}}for(const t of this[B])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[E])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[E]})},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){if(this[U])return t?this.emit("error",t):this.emit(U),this;this[U]=!0,this[K]=!0,this[F].length=0,this[M]=0;return"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"),ft=Symbol("_needDrain"),mt=Symbol("_onerror"),pt=Symbol("_onopen"),yt=Symbol("_onread"),bt=Symbol("_onwrite"),wt=Symbol("_open"),gt=Symbol("_path"),Et=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];[gt];[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[gt]=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[gt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[wt](){e.open(this[gt],"r",(t,e)=>this[pt](t,e))}[pt](t,e){t?this[mt](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[mt](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"))}}[mt](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[gt],"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]=[];[ft]=!1;[gt];[ut];[st];[ht];[xt];[at];[ot]=!1;[Et];constructor(t,e){super(e=e||{}),this[gt]=t,this[ht]="number"==typeof e.fd?e.fd:void 0,this[ut]=void 0===e.mode?438:e.mode,this[Et]="number"==typeof e.start?e.start:void 0,this[st]="boolean"!=typeof e.autoClose||e.autoClose;const i=void 0!==this[Et]?"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[gt]}[mt](t){this[rt](),this[Lt]=!0,this.emit("error",t)}[wt](){e.open(this[gt],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[mt](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[ft]=!0,!1):(this[Lt]=!0,this[kt](t),!0)}[kt](t){e.write(this[ht],t,0,t.length,this[Et],(t,e)=>this[bt](t,e))}[bt](t,e){t?this[mt](t):(void 0!==this[Et]&&"number"==typeof e&&(this[Et]+=e),this[Rt].length?this[lt]():(this[Lt]=!1,this[nt]&&!this[ot]?(this[ot]=!0,this[rt](),this.emit("finish")):this[ft]&&(this[ft]=!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[Et],(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 Ft extends Nt{[wt](){let t;if(this[xt]&&"r+"===this[at])try{t=e.openSync(this[gt],this[at],this[ut])}catch(t){if("ENOENT"===t?.code)return this[at]="w",this[wt]();throw t}else t=e.openSync(this[gt],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[Et])),i=!1}finally{if(i)try{this[rt]()}catch{}}}}const Bt=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=>{const e=Bt.get(t);return e||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 qt 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 Yt=Symbol("flushFlag");class Vt 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 qt(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 qt(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),{[Yt]: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[Yt]?t[Yt]:this.#i;h=this.#n._processChunk(t,e),Wt(!1)}catch(t){Wt(!1),this.#h(new qt(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 qt(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 $t extends Vt{#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 $t{#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 $t{constructor(t){super(t,"Unzip")}}class Qt extends Vt{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 Vt{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,e)=>{e[0]=128;for(var i=e.length;i>1;i--)e[i-1]=255&t,t=Math.floor(t/256)},ne=(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]=ae(r):0===r?e[s-1]=0:(i=!0,e[s-1]=le(r))}},he=t=>{for(var e=t.length,i=0,s=!1,r=e-1;r>-1;r--){var n,h=Number(t[r]);s?n=ae(h):0===h?n=h:(s=!0,n=le(h)),0!==n&&(i-=n*Math.pow(256,e-r-1))}return i},oe=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},ae=t=>255&(255^t),le=t=>1+(255^t)&255,de=t=>ce.has(t),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"]]),ue=new Map(Array.from(ce).map(t=>[t[1],t[0]]));class fe{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??pe(t,e,100),this.mode=i?.mode??s?.mode??we(t,e+100,8),this.uid=i?.uid??s?.uid??we(t,e+108,8),this.gid=i?.gid??s?.gid??we(t,e+116,8),this.size=i?.size??s?.size??we(t,e+124,12),this.mtime=i?.mtime??s?.mtime??ye(t,e+136,12),this.cksum=we(t,e+148,12),s&&this.#c(s,!0),i&&this.#c(i);const r=pe(t,e+156,1);if(de(r)&&(this.#d=r||"0"),"0"===this.#d&&"/"===this.path.slice(-1)&&(this.#d="5"),"5"===this.#d&&(this.size=0),this.linkpath=pe(t,e+157,100),"ustar\x0000"===t.subarray(e+257,e+265).toString())if(this.uname=i?.uname??s?.uname??pe(t,e+265,32),this.gname=i?.gname??s?.gname??pe(t,e+297,32),this.devmaj=i?.devmaj??s?.devmaj??we(t,e+329,8)??0,this.devmin=i?.devmin??s?.devmin??we(t,e+337,8)??0,0!==t[e+475]){const i=pe(t,e+345,155);this.path=i+"/"+this.path}else{const r=pe(t,e+345,130);r&&(this.path=r+"/"+this.path),this.atime=i?.atime??s?.atime??ye(t,e+476,12),this.ctime=i?.ctime??s?.ctime??ye(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=me(this.path||"",i),r=s[0],n=s[1];this.needPax=!!s[2],this.needPax=ke(t,e,100,r)||this.needPax,this.needPax=Re(t,e+100,8,this.mode)||this.needPax,this.needPax=Re(t,e+108,8,this.uid)||this.needPax,this.needPax=Re(t,e+116,8,this.gid)||this.needPax,this.needPax=Re(t,e+124,12,this.size)||this.needPax,this.needPax=Oe(t,e+136,12,this.mtime)||this.needPax,t[e+156]=this.#d.charCodeAt(0),this.needPax=ke(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=ke(t,e+265,32,this.uname)||this.needPax,this.needPax=ke(t,e+297,32,this.gname)||this.needPax,this.needPax=Re(t,e+329,8,this.devmaj)||this.needPax,this.needPax=Re(t,e+337,8,this.devmin)||this.needPax,this.needPax=ke(t,e+345,i,n)||this.needPax,0!==t[e+475]?this.needPax=ke(t,e+345,155,n)||this.needPax:(this.needPax=ke(t,e+345,130,n)||this.needPax,this.needPax=Oe(t,e+476,12,this.atime)||this.needPax,this.needPax=Oe(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,Re(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return"Unsupported"===this.#d?this.#d:ce.get(this.#d)}get typeKey(){return this.#d}set type(t){const e=String(ue.get(t));if(de(e)||"Unsupported"===e)this.#d=e;else{if(!de(t))throw new TypeError("invalid entry type: "+t);this.#d=t}}}const me=(t,e)=>{const i=100;let s,r=t,h="";const o=n.posix.parse(t).root||".";if(Buffer.byteLength(r)<i)s=[r,h,!1];else{h=n.posix.dirname(r),r=n.posix.basename(r);do{Buffer.byteLength(r)<=i&&Buffer.byteLength(h)<=e?s=[r,h,!1]:Buffer.byteLength(r)>i&&Buffer.byteLength(h)<=e?s=[r.slice(0,99),h,!0]:(r=n.posix.join(n.posix.basename(h),r),h=n.posix.dirname(h))}while(h!==o&&void 0===s);s||(s=[t.slice(0,99),"",!0])}return s},pe=(t,e,i)=>t.subarray(e,e+i).toString("utf8").replace(/\0.*/,""),ye=(t,e,i)=>be(we(t,e,i)),be=t=>void 0===t?void 0:new Date(1e3*t),we=(t,e,i)=>128&Number(t[e])?(t=>{const e=t[0],i=128===e?oe(t.subarray(1,t.length)):255===e?he(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)):ge(t,e,i),ge=(t,e,i)=>{return s=parseInt(t.subarray(e,e+i).toString("utf8").replace(/\0.*$/,"").trim(),8),isNaN(s)?void 0:s;var s},Ee={12:8589934591,8:2097151},Re=(t,e,i,s)=>void 0!==s&&(s>Ee[i]||s<0?(((t,e)=>{if(!Number.isSafeInteger(t))throw Error("cannot encode number outside of javascript safe integer range");t<0?ne(t,e):re(t,e)})(s,t.subarray(e,e+i)),!0):(_e(t,e,i,s),!1)),_e=(t,e,i,s)=>t.write(Se(s,i),e,i,"ascii"),Se=(t,e)=>ve(Math.floor(t).toString(8),e),ve=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Oe=(t,e,i,s)=>void 0!==s&&Re(t,e,i,s.getTime()/1e3),Te=new Array(156).join("\0"),ke=(t,e,i,s)=>void 0!==s&&(t.write(s+Te,e,i,"utf8"),s.length!==Buffer.byteLength(s)||s.length>i);class Le{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 fe({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;s+r>=Math.pow(10,r)&&(r+=1);return r+s+i}static parse(t,e,i=!1){return new Le(xe(De(t),e),i)}}const xe=(t,e)=>e?Object.assign({},e,t):t,De=t=>t.replace(/\n$/,"").split("\n").reduce(Ae,Object.create(null)),Ae=(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},Ie="win32"!==(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)?t=>t:t=>t&&t.replace(/\\/g,"/");class Ne 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=Ie(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?Ie(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=Ie(t.path)),t.linkpath&&(t.linkpath=Ie(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([t,i])=>!(null==i||"path"===t&&e))))}}const Fe=(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))},Be=Buffer.from([31,139]),Me=Buffer.from([40,181,47,253]),Ce=Math.max(Be.length,Me.length),Pe=Symbol("state"),ze=Symbol("writeEntry"),Ue=Symbol("readEntry"),je=Symbol("nextEntry"),He=Symbol("processEntry"),Ze=Symbol("extendedHeader"),We=Symbol("globalExtendedHeader"),Ge=Symbol("meta"),qe=Symbol("emitMeta"),Ye=Symbol("buffer"),Ve=Symbol("queue"),$e=Symbol("ended"),Ke=Symbol("emittedEnd"),Xe=Symbol("emit"),Qe=Symbol("unzip"),Je=Symbol("consumeChunk"),ti=Symbol("consumeChunkSub"),ei=Symbol("consumeBody"),ii=Symbol("consumeMeta"),si=Symbol("consumeHeader"),ri=Symbol("consuming"),ni=Symbol("bufferConcat"),hi=Symbol("maybeEnd"),oi=Symbol("writing"),ai=Symbol("aborted"),li=Symbol("onDone"),di=Symbol("sawValidEntry"),ci=Symbol("sawNullBlock"),ui=Symbol("sawEOF"),fi=Symbol("closeStream"),mi=()=>!0;class pi extends t.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ve]=[];[Ye];[Ue];[ze];[Pe]="begin";[Ge]="";[Ze];[We];[$e]=!1;[Qe];[ai]=!1;[di];[ci]=!1;[ui]=!1;[oi]=!1;[ri]=!1;[Ke]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(li,()=>{"begin"!==this[Pe]&&!1!==this[di]||this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(li,t.ondone):this.on(li,()=>{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:mi;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[fi]()),"function"==typeof t.onwarn&&this.on("warn",t.onwarn),"function"==typeof t.onReadEntry&&this.on("entry",t.onReadEntry)}warn(t,e,i={}){Fe(this,t,e,i)}[si](t,e){let i;void 0===this[di]&&(this[di]=!1);try{i=new fe(t,e,this[Ze],this[We])}catch(t){return this.warn("TAR_ENTRY_INVALID",t)}if(i.nullBlock)this[ci]?(this[ui]=!0,"begin"===this[Pe]&&(this[Pe]="header"),this[Xe]("eof")):(this[ci]=!0,this[Xe]("nullBlock"));else if(this[ci]=!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[ze]=new Ne(i,this[Ze],this[We]);if(!this[di])if(t.remain){const e=()=>{t.invalid||(this[di]=!0)};t.on("end",e)}else this[di]=!0;t.meta?t.size>this.maxMetaEntrySize?(t.ignore=!0,this[Xe]("ignoredEntry",t),this[Pe]="ignore",t.resume()):t.size>0&&(this[Ge]="",t.on("data",t=>this[Ge]+=t),this[Pe]="meta"):(this[Ze]=void 0,t.ignore=t.ignore||!this.filter(t.path,t),t.ignore?(this[Xe]("ignoredEntry",t),this[Pe]=t.remain?"ignore":"header",t.resume()):(t.remain?this[Pe]="body":(this[Pe]="header",t.end()),this[Ue]?this[Ve].push(t):(this[Ve].push(t),this[je]())))}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})}[fi](){queueMicrotask(()=>this.emit("close"))}[He](t){let e=!0;if(t)if(Array.isArray(t)){const[e,...i]=t;this.emit(e,...i)}else this[Ue]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[je]()),e=!1);else this[Ue]=void 0,e=!1;return e}[je](){do{}while(this[He](this[Ve].shift()));if(!this[Ve].length){const t=this[Ue];!t||t.flowing||t.size===t.remain?this[oi]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[ei](t,e){const i=this[ze];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[Pe]="header",this[ze]=void 0,i.end()),r.length}[ii](t,e){const i=this[ze],s=this[ei](t,e);return!this[ze]&&i&&this[qe](i),s}[Xe](t,e,i){this[Ve].length||this[Ue]?this[Ve].push([t,e,i]):this.emit(t,e,i)}[qe](t){switch(this[Xe]("meta",this[Ge]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Ze]=Le.parse(this[Ge],this[Ze],!1);break;case"GlobalExtendedHeader":this[We]=Le.parse(this[Ge],this[We],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{const t=this[Ze]??Object.create(null);this[Ze]=t,t.path=this[Ge].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{const t=this[Ze]||Object.create(null);this[Ze]=t,t.linkpath=this[Ge].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[ai]=!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[ai])return i?.(),!1;if((void 0===this[Qe]||void 0===this.brotli&&!1===this[Qe])&&t){if(this[Ye]&&(t=Buffer.concat([this[Ye],t]),this[Ye]=void 0),t.length<Ce)return this[Ye]=t,i?.(),!0;for(let e=0;void 0===this[Qe]&&e<Be.length;e++)t[e]!==Be[e]&&(this[Qe]=!1);let e=!1;if(!1===this[Qe]&&!1!==this.zstd){e=!0;for(let i=0;i<Me.length;i++)if(t[i]!==Me[i]){e=!1;break}}const s=void 0===this.brotli&&!e;if(!1===this[Qe]&&s)if(t.length<512){if(!this[$e])return this[Ye]=t,i?.(),!0;this.brotli=!0}else try{new fe(t.subarray(0,512)),this.brotli=!1}catch(t){this.brotli=!0}if(void 0===this[Qe]||!1===this[Qe]&&(this.brotli||e)){const s=this[$e];this[$e]=!1,this[Qe]=void 0===this[Qe]?new Xt({}):e?new se({}):new te({}),this[Qe].on("data",t=>this[Je](t)),this[Qe].on("error",t=>this.abort(t)),this[Qe].on("end",()=>{this[$e]=!0,this[Je]()}),this[oi]=!0;const r=!!this[Qe][s?"end":"write"](t);return this[oi]=!1,i?.(),r}}this[oi]=!0,this[Qe]?this[Qe].write(t):this[Je](t),this[oi]=!1;const s=!this[Ve].length&&(!this[Ue]||this[Ue].flowing);return s||this[Ve].length||this[Ue]?.once("drain",()=>this.emit("drain")),i?.(),s}[ni](t){t&&!this[ai]&&(this[Ye]=this[Ye]?Buffer.concat([this[Ye],t]):t)}[hi](){if(this[$e]&&!this[Ke]&&!this[ai]&&!this[ri]){this[Ke]=!0;const t=this[ze];if(t&&t.blockRemain){const e=this[Ye]?this[Ye].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[Ye]&&t.write(this[Ye]),t.end()}this[Xe](li)}}[Je](t){if(this[ri]&&t)this[ni](t);else if(t||this[Ye]){if(t){if(this[ri]=!0,this[Ye]){this[ni](t);const e=this[Ye];this[Ye]=void 0,this[ti](e)}else this[ti](t);for(;this[Ye]&&this[Ye]?.length>=512&&!this[ai]&&!this[ui];){const t=this[Ye];this[Ye]=void 0,this[ti](t)}this[ri]=!1}}else this[hi]();this[Ye]&&!this[$e]||this[hi]()}[ti](t){let e=0;const i=t.length;for(;e+512<=i&&!this[ai]&&!this[ui];)switch(this[Pe]){case"begin":case"header":this[si](t,e),e+=512;break;case"ignore":case"body":e+=this[ei](t,e);break;case"meta":e+=this[ii](t,e);break;default:throw new Error("invalid state: "+this[Pe])}e<i&&(this[Ye]?this[Ye]=Buffer.concat([t.subarray(e),this[Ye]]):this[Ye]=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[ai]||(this[Qe]?(t&&this[Qe].write(t),this[Qe].end()):(this[$e]=!0,void 0!==this.brotli&&void 0!==this.zstd||(t=t||Buffer.alloc(0)),t&&this.write(t),this[hi]())),this}}const yi=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)},bi=(t,e)=>{const i=new Map(e.map(t=>[yi(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(yi(t)):t=>r(yi(t))},wi=Pt(t=>{const e=new pi(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 pi(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 pi(t),t=>new pi(t),(t,e)=>{e?.length&&bi(t,e),t.noResume||(t=>{const e=t.onReadEntry;t.onReadEntry=e?t=>{e(t),t.resume()}:t=>t.resume()})(t)}),gi=(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:Ei,parse:Ri}=n.win32,_i=t=>{let e="",i=Ri(t);for(;Ei(t)||i.root;){const s="/"===t.charAt(0)&&"//?/"!==t.slice(0,4)?"/":i.root;t=t.slice(s.length),e+=s,i=Ri(t)}return[e,t]},Si=["|","<",">","?",":"],vi=Si.map(t=>String.fromCharCode(61440+t.charCodeAt(0))),Oi=new Map(Si.map((t,e)=>[t,vi[e]])),Ti=new Map(vi.map((t,e)=>[t,Si[e]])),ki=t=>Si.reduce((t,e)=>t.split(e).join(Oi.get(e)),t),Li=(t,e)=>e?(t=Ie(t).replace(/^\.(\/|$)/,""),yi(e)+"/"+t):Ie(t),xi=Symbol("process"),Di=Symbol("file"),Ai=Symbol("directory"),Ii=Symbol("symlink"),Ni=Symbol("hardlink"),Fi=Symbol("header"),Bi=Symbol("read"),Mi=Symbol("lstat"),Ci=Symbol("onlstat"),Pi=Symbol("onread"),zi=Symbol("onreadlink"),Ui=Symbol("openfile"),ji=Symbol("onopenfile"),Hi=Symbol("close"),Zi=Symbol("mode"),Wi=Symbol("awaitDrain"),Gi=Symbol("ondrain"),qi=Symbol("prefix");class Yi 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=Ie(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=Ie(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?Ie(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]=_i(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,"/"),vi.reduce((t,e)=>t.split(e).join(Ti.get(e)),r)),t=t.replace(/\\/g,"/")),this.absolute=Ie(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[Ci](n):this[Mi]()}warn(t,e,i={}){return Fe(this,t,e,i)}emit(t,...e){return"error"===t&&(this.#u=!0),super.emit(t,...e)}[Mi](){e.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ci](e)})}[Ci](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Ki(t),this.emit("stat",t),this[xi]()}[xi](){switch(this.type){case"File":return this[Di]();case"Directory":return this[Ai]();case"SymbolicLink":return this[Ii]();default:return this.end()}}[Zi](t){return gi(t,"Directory"===this.type,this.portable)}[qi](t){return Li(t,this.prefix)}[Fi](){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 fe({path:this[qi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[qi](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 Le({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[qi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[qi](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)}[Ai](){if(!this.stat)throw new Error("cannot create directory entry without stat");"/"!==this.path.slice(-1)&&(this.path+="/"),this.stat.size=0,this[Fi](),this.end()}[Ii](){e.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[zi](e)})}[zi](t){this.linkpath=Ie(t),this[Fi](),this.end()}[Ni](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Ie(o.relative(this.cwd,t)),this.stat.size=0,this[Fi](),this.end()}[Di](){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[Ni](e);this.linkCache.set(t,this.absolute)}if(this[Fi](),0===this.stat.size)return this.end();this[Ui]()}[Ui](){e.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[ji](e)})}[ji](t){if(this.fd=t,this.#u)return this[Hi]();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[Bi]()}[Bi](){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[Hi](()=>this.emit("error",t));this[Pi](e)})}[Hi](t=()=>{}){void 0!==this.fd&&e.close(this.fd,t)}[Pi](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[Hi](()=>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[Hi](()=>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[Gi]():this[Wi](()=>this[Gi]())}[Wi](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)}[Gi](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[Hi](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[Bi]()}}class Vi extends Yi{sync=!0;[Mi](){this[Ci](e.lstatSync(this.absolute))}[Ii](){this[zi](e.readlinkSync(this.absolute))}[Ui](){this[ji](e.openSync(this.absolute,"r"))}[Bi](){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[Pi](o),t=!1}finally{if(t)try{this[Hi](()=>{})}catch(t){}}}[Wi](t){t()}[Hi](t=()=>{}){void 0!==this.fd&&e.closeSync(this.fd),t()}}class $i 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 Fe(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=Ie(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?Ie(t.linkpath):void 0,"function"==typeof i.onwarn&&this.on("warn",i.onwarn);let r=!1;if(!this.preservePaths){const[t,e]=_i(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 fe({path:this[qi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[qi](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 Le({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[qi](this.path),linkpath:"Link"===this.type&&void 0!==this.linkpath?this[qi](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)}[qi](t){return Li(t,this.prefix)}[Zi](t){return gi(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 Ki=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";class Xi{tail;head;length=0;static create(t=[]){return new Xi(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++)Ji(this,t[e]);return this.length}unshift(...t){for(var e=0,i=t.length;e<i;e++)ts(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 Xi;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 Xi;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 Xi;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 Xi;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=Qi(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 Qi(t,e,i){const s=e,r=e?e.next:t.head,n=new es(i,s,r,t);return void 0===n.next&&(t.tail=n),void 0===n.prev&&(t.head=n),t.length++,n}function Ji(t,e){t.tail=new es(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function ts(t,e){t.head=new es(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}class es{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 is{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}}const ss=Buffer.alloc(1024),rs=Symbol("onStat"),ns=Symbol("ended"),hs=Symbol("queue"),os=Symbol("current"),as=Symbol("process"),ls=Symbol("processing"),ds=Symbol("processJob"),cs=Symbol("jobs"),us=Symbol("jobDone"),fs=Symbol("addFSEntry"),ms=Symbol("addTarEntry"),ps=Symbol("stat"),ys=Symbol("readdir"),bs=Symbol("onreaddir"),ws=Symbol("pipe"),gs=Symbol("entry"),Es=Symbol("entryOpt"),Rs=Symbol("writeEntryClass"),_s=Symbol("write"),Ss=Symbol("ondrain");class vs extends et{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Rs];onWriteEntry;[hs];[cs]=0;[ls]=!1;[ns]=!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=Ie(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[Rs]=Yi,"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[Ss]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ss]);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[hs]=new Xi,this[cs]=0,this.jobs=Number(t.jobs)||4,this[ls]=!1,this[ns]=!1}[_s](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[ns]=!0,this[as](),i&&i(),this}write(t){if(this[ns])throw new Error("write after end");return t instanceof Ne?this[ms](t):this[fs](t),this.flowing}[ms](t){const e=Ie(o.resolve(this.cwd,t.path));if(this.filter(t.path,t)){const i=new is(t.path,e);i.entry=new $i(t,this[Es](i)),i.entry.on("end",()=>this[us](i)),this[cs]+=1,this[hs].push(i)}else t.resume();this[as]()}[fs](t){const e=Ie(o.resolve(this.cwd,t));this[hs].push(new is(t,e)),this[as]()}[ps](t){t.pending=!0,this[cs]+=1;const i=this.follow?"stat":"lstat";e[i](t.absolute,(e,i)=>{t.pending=!1,this[cs]-=1,e?this.emit("error",e):this[rs](t,i)})}[rs](t,e){this.statCache.set(t.absolute,e),t.stat=e,this.filter(t.path,e)||(t.ignore=!0),this[as]()}[ys](t){t.pending=!0,this[cs]+=1,e.readdir(t.absolute,(e,i)=>{if(t.pending=!1,this[cs]-=1,e)return this.emit("error",e);this[bs](t,i)})}[bs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[as]()}[as](){if(!this[ls]){this[ls]=!0;for(let t=this[hs].head;t&&this[cs]<this.jobs;t=t.next)if(this[ds](t.value),t.value.ignore){const e=t.next;this[hs].removeNode(t),t.next=e}this[ls]=!1,this[ns]&&!this[hs].length&&0===this[cs]&&(this.zip?this.zip.end(ss):(super.write(ss),super.end()))}}get[os](){return this[hs]&&this[hs].head&&this[hs].head.value}[us](t){this[hs].shift(),this[cs]-=1,this[as]()}[ds](t){if(!t.pending)if(t.entry)t!==this[os]||t.piped||this[ws](t);else{if(!t.stat){const e=this.statCache.get(t.absolute);e?this[rs](t,e):this[ps](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){const e=this.readdirCache.get(t.absolute);if(e?this[bs](t,e):this[ys](t),!t.readdir)return}t.entry=this[gs](t),t.entry?t!==this[os]||t.piped||this[ws](t):t.ignore=!0}}}[Es](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}}[gs](t){this[cs]+=1;try{return new this[Rs](t.path,this[Es](t)).on("end",()=>this[us](t)).on("error",t=>this.emit("error",t))}catch(t){this.emit("error",t)}}[Ss](){this[os]&&this[os].entry&&this[os].entry.resume()}[ws](t){t.piped=!0,t.readdir&&t.readdir.forEach(e=>{const i=t.path,s="./"===i?"":i.replace(/\/*$/,"/");this[fs](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={}){Fe(this,t,e,i)}}class Os extends vs{sync=!0;constructor(t){super(t),this[Rs]=Vi}pause(){}resume(){}[ps](t){const i=this.follow?"statSync":"lstatSync";this[rs](t,e[i](t.absolute))}[ys](t){this[bs](t,e.readdirSync(t.absolute))}[ws](t){const e=t.entry,i=this.zip;if(t.readdir&&t.readdir.forEach(e=>{const i=t.path,s="./"===i?"":i.replace(/\/*$/,"/");this[fs](s+e)}),!e)throw new Error("Cannot pipe without source");i?e.on("data",t=>{i.write(t)}):e.on("data",t=>{super[_s](t)})}}const Ts=(t,e)=>{e.forEach(e=>{"@"===e.charAt(0)?wi({file:n.resolve(t.cwd,e.slice(1)),sync:!0,noResume:!0,onReadEntry:e=>t.add(e)}):t.add(e)}),t.end()},ks=async(t,e)=>{for(let i=0;i<e.length;i++){const s=String(e[i]);"@"===s.charAt(0)?await wi({file:n.resolve(String(t.cwd),s.slice(1)),noResume:!0,onReadEntry:e=>{t.add(e)}}):t.add(s)}t.end()},Ls=Pt((t,e)=>{const i=new Os(t),s=new Ft(t.file,{mode:t.mode||438});i.pipe(s),Ts(i,e)},(t,e)=>{const i=new vs(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 ks(i,e),r},(t,e)=>{const i=new Os(t);return Ts(i,e),i},(t,e)=>{const i=new vs(t);return ks(i,e),i},(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),xs="win32"===(process.env.__FAKE_PLATFORM__||process.platform),{O_CREAT:Ds,O_TRUNC:As,O_WRONLY:Is}=e.constants,Ns=Number(process.env.__FAKE_FS_O_FILENAME__)||e.constants.UV_FS_O_FILEMAP||0,Fs=Ns|As|Ds|Is,Bs=xs&&!!Ns?t=>t<524288?Fs:"w":()=>"w",Ms=(t,e,i)=>{try{return h.lchownSync(t,e,i)}catch(t){if("ENOENT"!==t?.code)throw t}},Cs=(t,e,i,s)=>{h.lchown(t,e,i,t=>{s(t&&"ENOENT"!==t?.code?t:null)})},Ps=(t,e,i,s,r)=>{if(e.isDirectory())zs(n.resolve(t,e.name),i,s,h=>{if(h)return r(h);const o=n.resolve(t,e.name);Cs(o,i,s,r)});else{const h=n.resolve(t,e.name);Cs(h,i,s,r)}},zs=(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 Cs(t,e,i,s);let h=n.length,o=null;const a=r=>{if(!o)return r?s(o=r):0===--h?Cs(t,e,i,s):void 0};for(const s of n)Ps(t,s,e,i,a)})},Us=(t,e,i,s)=>{e.isDirectory()&&js(n.resolve(t,e.name),i,s),Ms(n.resolve(t,e.name),i,s)},js=(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 Ms(t,e,i);throw r}for(const r of s)Us(t,r,e,i);return Ms(t,e,i)};class Hs 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 Ws=(t,e,i)=>{t=Ie(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,m=Ie(e.cwd),p=(e,s)=>{e?i(e):s&&d?zs(s,a,l,t=>p(t)):o?h.chmod(t,r,i):i()};if(t===m)return((t,e)=>{h.stat(t,(i,s)=>{!i&&s.isDirectory()||(i=new Hs(t,i?.code||"ENOTDIR")),e(i)})})(t,p);if(c)return f.mkdir(t,{mode:r,recursive:!0}).then(t=>p(null,t??void 0),p);const y=Ie(n.relative(m,t)).split("/");Gs(m,y,r,u,m,void 0,p)},Gs=(t,e,i,s,r,o,a)=>{if(!e.length)return a(null,o);const l=e.shift(),d=Ie(n.resolve(t+"/"+l));h.mkdir(d,i,qs(d,e,i,s,r,o,a))},qs=(t,e,i,s,r,n,o)=>a=>{a?h.lstat(t,(l,d)=>{if(l)l.path=l.path&&Ie(l.path),o(l);else if(d.isDirectory())Gs(t,e,i,s,r,n,o);else if(s)h.unlink(t,a=>{if(a)return o(a);h.mkdir(t,i,qs(t,e,i,s,r,n,o))});else{if(d.isSymbolicLink())return o(new Zs(t,t+"/"+e.join("/")));o(a)}}):Gs(t,e,i,s,r,n=n||t,o)},Ys=(t,e)=>{t=Ie(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=Ie(e.cwd),f=e=>{e&&l&&js(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 Hs(t,e??"ENOTDIR")}})(u),f();if(d)return f(h.mkdirSync(t,{mode:s,recursive:!0})??void 0);const m=Ie(n.relative(u,t)).split("/");let p;for(let t=m.shift(),e=u;t&&(e+="/"+t);t=m.shift()){e=Ie(n.resolve(e));try{h.mkdirSync(e,s),p=p||e}catch(t){const i=h.lstatSync(e);if(i.isDirectory())continue;if(c){h.unlinkSync(e),h.mkdirSync(e,s),p=p||e;continue}if(i.isSymbolicLink())return new Zs(e,e+"/"+m.join("/"))}}return f(p)},Vs=Object.create(null),$s=new Set,Ks="win32"===(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform),Xs=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};class Qs{#f=new Map;#m=new Map;#p=new Set;reserve(t,e){t=Ks?["win32 parallelization disabled"]:t.map(t=>yi(n.join((t=>{$s.has(t)?$s.delete(t):Vs[t]=t.normalize("NFD"),$s.add(t);const e=Vs[t];let i=$s.size-1e4;if(i>1e3)for(const t of $s)if($s.delete(t),delete Vs[t],--i<=0)break;return e})(t))).toLowerCase());const i=new Set(t.map(t=>Xs(t)).reduce((t,e)=>t.concat(e)));this.#m.set(e,{dirs:i,paths:t});for(const i of t){const t=this.#f.get(i);t?t.push(e):this.#f.set(i,[e])}for(const t of i){const i=this.#f.get(t);if(i){const t=i[i.length-1];t instanceof Set?t.add(e):i.push(new Set([e]))}else this.#f.set(t,[new Set([e])])}return this.#y(e)}#b(t){const e=this.#m.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(t=>this.#f.get(t)),dirs:[...e.dirs].map(t=>this.#f.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.#m.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.#f.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.#f.delete(e)}for(const e of s){const i=this.#f.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.#f.delete(e)}return this.#p.delete(t),r.forEach(t=>this.#y(t)),!0}}const Js=Symbol("onEntry"),tr=Symbol("checkFs"),er=Symbol("checkFs2"),ir=Symbol("isReusable"),sr=Symbol("makeFs"),rr=Symbol("file"),nr=Symbol("directory"),hr=Symbol("link"),or=Symbol("symlink"),ar=Symbol("hardlink"),lr=Symbol("unsupported"),dr=Symbol("checkPath"),cr=Symbol("stripAbsolutePath"),ur=Symbol("mkdir"),fr=Symbol("onError"),mr=Symbol("pending"),pr=Symbol("pend"),yr=Symbol("unpend"),br=Symbol("ended"),wr=Symbol("maybeClose"),gr=Symbol("skip"),Er=Symbol("doChown"),Rr=Symbol("uid"),_r=Symbol("gid"),Sr=Symbol("checkedCwd"),vr="win32"===(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform),Or=(t,e,i)=>void 0!==t&&t===t>>>0?t:void 0!==e&&e===e>>>0?e:i;class Tr extends pi{[br]=!1;[Sr]=!1;[mr]=0;reservations=new Qs;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[br]=!0,this[wr]()},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||vr,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Ie(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[Js](t))}warn(t,e,i={}){return"TAR_BAD_ARCHIVE"!==t&&"TAR_ABORT"!==t||(i.recoverable=!1),super.warn(t,e,i)}[wr](){this[br]&&0===this[mr]&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[cr](t,e){const i=t[e];if(!i||this.preservePaths)return!0;const s=i.split("/");if(s.includes("..")||vr&&/^[a-z]:\.\.$/i.test(s[0]??""))return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:i}),!1;const[r,n]=_i(i);return r&&(t[e]=String(n),this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute ${e}`,{entry:t,[e]:i})),!0}[dr](t){const e=Ie(t.path),i=e.split("/");if(this.strip){if(i.length<this.strip)return!1;if("Link"===t.type){const e=Ie(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[cr](t,"path")||!this[cr](t,"linkpath"))return!1;if(n.isAbsolute(t.path)?t.absolute=Ie(n.resolve(t.path)):t.absolute=Ie(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:Ie(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+ki(String(t.absolute).slice(e.length));const{root:i}=n.win32.parse(t.path);t.path=i+ki(t.path.slice(i.length))}return!0}[Js](t){if(!this[dr](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[tr](t);default:return this[lr](t)}}[fr](t,e){"CwdError"===t.name?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[yr](),e.resume())}[ur](t,e,i){Ws(Ie(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)}[Er](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}[Rr](t){return Or(this.uid,t.uid,this.processUid)}[_r](t){return Or(this.gid,t.gid,this.processGid)}[rr](t,e){const i="number"==typeof t.mode?4095&t.mode:this.fmode,s=new Nt(String(t.absolute),{flags:Bs(t.size),mode:i,autoClose:!1});s.on("error",i=>{s.fd&&h.close(s.fd,()=>{}),s.write=()=>!0,this[fr](i,t),e()});let r=1;const n=i=>{if(i)return s.fd&&h.close(s.fd,()=>{}),this[fr](i,t),void e();0===--r&&void 0!==s.fd&&h.close(s.fd,i=>{i?this[fr](i,t):this[yr](),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[Er](t)){r++;const s=this[Rr](t),o=this[_r](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[fr](i,t),e()}),t.pipe(o)),o.pipe(s)}[nr](t,e){const i="number"==typeof t.mode?4095&t.mode:this.dmode;this[ur](String(t.absolute),i,i=>{if(i)return this[fr](i,t),void e();let s=1;const r=()=>{0===--s&&(e(),this[yr](),t.resume())};t.mtime&&!this.noMtime&&(s++,h.utimes(String(t.absolute),t.atime||new Date,t.mtime,r)),this[Er](t)&&(s++,h.chown(String(t.absolute),Number(this[Rr](t)),Number(this[_r](t)),r)),r()})}[lr](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[or](t,e){this[hr](t,String(t.linkpath),"symlink",e)}[ar](t,e){const i=Ie(n.resolve(this.cwd,String(t.linkpath)));this[hr](t,i,"link",e)}[pr](){this[mr]++}[yr](){this[mr]--,this[wr]()}[gr](t){this[yr](),t.resume()}[ir](t,e){return"File"===t.type&&!this.unlink&&e.isFile()&&e.nlink<=1&&!vr}[tr](t){this[pr]();const e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,e=>this[er](t,e))}[er](t,e){const i=t=>{e(t)},s=()=>{this[ur](this.cwd,this.dmode,e=>{if(e)return this[fr](e,t),void i();this[Sr]=!0,r()})},r=()=>{if(t.absolute!==this.cwd){const e=Ie(n.dirname(String(t.absolute)));if(e!==this.cwd)return this[ur](e,this.dmode,e=>{if(e)return this[fr](e,t),void i();o()})}o()},o=()=>{h.lstat(String(t.absolute),(e,s)=>{if(s&&(this.keep||this.newer&&s.mtime>(t.mtime??s.mtime)))return this[gr](t),void i();if(e||this[ir](t,s))return this[sr](null,t,i);if(s.isDirectory()){if("Directory"===t.type){const e=e=>this[sr](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[sr](e??null,t,i))}if(t.absolute===this.cwd)return this[sr](null,t,i);((t,e)=>{if(!vr)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[sr](e??null,t,i))})};this[Sr]?r():s()}[sr](t,e,i){if(t)return this[fr](t,e),void i();switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[rr](e,i);case"Link":return this[ar](e,i);case"SymbolicLink":return this[or](e,i);case"Directory":case"GNUDumpDir":return this[nr](e,i)}}[hr](t,e,i,s){h[i](e,String(t.absolute),e=>{e?this[fr](e,t):(this[yr](),t.resume()),s()})}}const kr=t=>{try{return[null,t()]}catch(t){return[t,null]}};class Lr extends Tr{sync=!0;[sr](t,e){return super[sr](t,e,()=>{})}[tr](t){if(!this[Sr]){const e=this[ur](this.cwd,this.dmode);if(e)return this[fr](e,t);this[Sr]=!0}if(t.absolute!==this.cwd){const e=Ie(n.dirname(String(t.absolute)));if(e!==this.cwd){const i=this[ur](e,this.dmode);if(i)return this[fr](i,t)}}const[e,i]=kr(()=>h.lstatSync(String(t.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(t.mtime??i.mtime)))return this[gr](t);if(e||this[ir](t,i))return this[sr](null,t);if(i.isDirectory()){if("Directory"===t.type){const e=this.chmod&&t.mode&&(4095&i.mode)!==t.mode,[s]=e?kr(()=>{h.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[sr](s,t)}const[e]=kr(()=>h.rmdirSync(String(t.absolute)));this[sr](e,t)}const[s]=t.absolute===this.cwd?[]:kr(()=>(t=>{if(!vr)return h.unlinkSync(t);const e=t+".DELETE."+u.randomBytes(16).toString("hex");h.renameSync(t,e),h.unlinkSync(e)})(String(t.absolute)));this[sr](s,t)}[rr](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[fr](i||s,t),e()};let r;try{r=h.openSync(String(t.absolute),Bs(t.size),i)}catch(t){return s(t)}const n=this.transform&&this.transform(t)||t;n!==t&&(n.on("error",e=>this[fr](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[Er](t)){const i=this[Rr](t),s=this[_r](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)})}[nr](t,e){const i="number"==typeof t.mode?4095&t.mode:this.dmode,s=this[ur](String(t.absolute),i);if(s)return this[fr](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[Er](t))try{h.chownSync(String(t.absolute),Number(this[Rr](t)),Number(this[_r](t)))}catch(s){}e(),t.resume()}[ur](t,e){try{return Ys(Ie(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}}[hr](t,e,i,s){const r=`${i}Sync`;try{h[r](e,String(t.absolute)),s(),t.resume()}catch(e){return this[fr](e,t)}}}Pt(t=>{const e=new Lr(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 Tr(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 Lr(t),t=>new Tr(t),(t,e)=>{e?.length&&bi(t,e)});const xr=(t,e,i,s,r)=>{const n=new Ft(t.file,{fd:s,start:i});e.pipe(n),Dr(e,r)},Dr=(t,e)=>{e.forEach(e=>{"@"===e.charAt(0)?wi({file:n.resolve(t.cwd,e.slice(1)),sync:!0,noResume:!0,onReadEntry:e=>t.add(e)}):t.add(e)}),t.end()},Ar=async(t,e)=>{for(let i=0;i<e.length;i++){const s=String(e[i]);"@"===s.charAt(0)?await wi({file:n.resolve(String(t.cwd),s.slice(1)),noResume:!0,onReadEntry:e=>t.add(e)}):t.add(s)}t.end()},Ir=Pt((t,e)=>{const i=new Os(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 fe(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,xr(t,i,r,s,e)}finally{if(n)try{h.closeSync(s)}catch(t){}}},(t,e)=>{e=Array.from(e);const i=new vs(t),s=new Promise((s,r)=>{i.on("error",r);let n="r+";const o=(a,l)=>a&&"ENOENT"===a.code&&"r+"===n?(n="w+",h.open(t.file,n,o)):a||!l?r(a):void h.fstat(l,(n,o)=>{if(n)return h.close(l,()=>r(n));((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 fe(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)})(l,o.size,(n,h)=>{if(n)return r(n);const o=new Nt(t.file,{fd:l,start:h});i.pipe(o),o.on("error",r),o.on("close",s),Ar(i,e)})});h.open(t.file,n,o)});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(Ir.syncFile,Ir.asyncFile,Ir.syncNoFile,Ir.asyncNoFile,(t,e=[])=>{Ir.validate?.(t,e),Nr(t)});const Nr=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=fe,exports.Pack=vs,exports.PackJob=is,exports.PackSync=Os,exports.Parser=pi,exports.Pax=Le,exports.ReadEntry=Ne,exports.Unpack=Tr,exports.UnpackSync=Lr,exports.WriteEntry=Yi,exports.WriteEntrySync=Vi,exports.WriteEntryTar=$i,exports.c=Ls,exports.create=Ls,exports.filesFilter=bi,exports.list=wi,exports.r=Ir,exports.replace=Ir,exports.t=wi;
|