stormflow
Version:
StormFlow is a versatile Node.js data management library designed for efficient data management.
3 lines • 86 kB
JavaScript
import Me from"fs/promises";import Pe from"path";import Sr from"events";import x from"fs";import{EventEmitter as Zi}from"node:events";import Bs from"node:stream";import{StringDecoder as _r}from"node:string_decoder";import Ps from"node:path";import Ne from"node:fs";import{dirname as Mr,parse as Pr}from"path";import{EventEmitter as Gr}from"events";import _i from"assert";import{Buffer as Ee}from"buffer";import*as ns from"zlib";import Yr from"zlib";import{posix as Oe}from"node:path";import{basename as vn}from"node:path";import Pt from"fs";import Z from"fs";import us from"path";import{win32 as In}from"node:path";import gs from"path";import er from"node:fs";import Xn from"node:assert";import{randomBytes as tr}from"node:crypto";import u from"node:fs";import v from"node:path";import ir from"fs";import Vt from"node:fs";import it from"node:path";import N from"node:fs";import sh from"node:fs/promises";import jt from"node:path";import{join as fr}from"node:path";import D from"node:fs";import pr from"node:path";var vr=Object.defineProperty,Rr=(e,t)=>{for(var i in t)vr(e,i,{get:t[i],enumerable:!0})},ts=typeof process=="object"&&process?process:{stdout:null,stderr:null},Or=e=>!!e&&typeof e=="object"&&(e instanceof Se||e instanceof Bs||kr(e)||Tr(e)),kr=e=>!!e&&typeof e=="object"&&e instanceof Zi&&typeof e.pipe=="function"&&e.pipe!==Bs.Writable.prototype.pipe,Tr=e=>!!e&&typeof e=="object"&&e instanceof Zi&&typeof e.write=="function"&&typeof e.end=="function",G=Symbol("EOF"),Y=Symbol("maybeEmitEnd"),J=Symbol("emittedEnd"),ct=Symbol("emittingEnd"),ze=Symbol("emittedError"),ut=Symbol("closed"),is=Symbol("read"),ft=Symbol("flush"),ss=Symbol("flushChunk"),B=Symbol("encoding"),_e=Symbol("decoder"),R=Symbol("flowing"),Ue=Symbol("paused"),xe=Symbol("resume"),S=Symbol("buffer"),L=Symbol("pipes"),_=Symbol("bufferLength"),Xt=Symbol("bufferPush"),mt=Symbol("bufferShift"),T=Symbol("objectMode"),w=Symbol("destroyed"),qt=Symbol("error"),Jt=Symbol("emitData"),rs=Symbol("emitEnd"),Qt=Symbol("emitEnd2"),U=Symbol("async"),ei=Symbol("abort"),pt=Symbol("aborted"),je=Symbol("signal"),ce=Symbol("dataListeners"),A=Symbol("discarded"),He=e=>Promise.resolve().then(e),Lr=e=>e(),xr=e=>e==="end"||e==="finish"||e==="prefinish",Ar=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,Dr=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Cs=class{src;dest;opts;ondrain;constructor(e,t,i){this.src=e,this.dest=t,this.opts=i,this.ondrain=()=>e[xe](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Nr=class extends Cs{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,t,i){super(e,t,i),this.proxyErrors=s=>this.dest.emit("error",s),e.on("error",this.proxyErrors)}},Ir=e=>!!e.objectMode,Fr=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",Se=class extends Zi{[R]=!1;[Ue]=!1;[L]=[];[S]=[];[T];[B];[U];[_e];[G]=!1;[J]=!1;[ct]=!1;[ut]=!1;[ze]=null;[_]=0;[w]=!1;[je];[pt]=!1;[ce]=0;[A]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Ir(t)?(this[T]=!0,this[B]=null):Fr(t)?(this[B]=t.encoding,this[T]=!1):(this[T]=!1,this[B]=null),this[U]=!!t.async,this[_e]=this[B]?new _r(this[B]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[S]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[L]});let{signal:i}=t;i&&(this[je]=i,i.aborted?this[ei]():i.addEventListener("abort",()=>this[ei]()))}get bufferLength(){return this[_]}get encoding(){return this[B]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[T]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[U]}set async(e){this[U]=this[U]||!!e}[ei](){this[pt]=!0,this.emit("abort",this[je]?.reason),this.destroy(this[je]?.reason)}get aborted(){return this[pt]}set aborted(e){}write(e,t,i){if(this[pt])return!1;if(this[G])throw new Error("write after end");if(this[w])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof t=="function"&&(i=t,t="utf8"),t||(t="utf8");let s=this[U]?He:Lr;if(!this[T]&&!Buffer.isBuffer(e)){if(Dr(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Ar(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[T]?(this[R]&&this[_]!==0&&this[ft](!0),this[R]?this.emit("data",e):this[Xt](e),this[_]!==0&&this.emit("readable"),i&&s(i),this[R]):e.length?(typeof e=="string"&&!(t===this[B]&&!this[_e]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[B]&&(e=this[_e].write(e)),this[R]&&this[_]!==0&&this[ft](!0),this[R]?this.emit("data",e):this[Xt](e),this[_]!==0&&this.emit("readable"),i&&s(i),this[R]):(this[_]!==0&&this.emit("readable"),i&&s(i),this[R])}read(e){if(this[w])return null;if(this[A]=!1,this[_]===0||e===0||e&&e>this[_])return this[Y](),null;this[T]&&(e=null),this[S].length>1&&!this[T]&&(this[S]=[this[B]?this[S].join(""):Buffer.concat(this[S],this[_])]);let t=this[is](e||null,this[S][0]);return this[Y](),t}[is](e,t){if(this[T])this[mt]();else{let i=t;e===i.length||e===null?this[mt]():typeof i=="string"?(this[S][0]=i.slice(e),t=i.slice(0,e),this[_]-=e):(this[S][0]=i.subarray(e),t=i.subarray(0,e),this[_]-=e)}return this.emit("data",t),!this[S].length&&!this[G]&&this.emit("drain"),t}end(e,t,i){return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t="utf8"),e!==void 0&&this.write(e,t),i&&this.once("end",i),this[G]=!0,this.writable=!1,(this[R]||!this[Ue])&&this[Y](),this}[xe](){this[w]||(!this[ce]&&!this[L].length&&(this[A]=!0),this[Ue]=!1,this[R]=!0,this.emit("resume"),this[S].length?this[ft]():this[G]?this[Y]():this.emit("drain"))}resume(){return this[xe]()}pause(){this[R]=!1,this[Ue]=!0,this[A]=!1}get destroyed(){return this[w]}get flowing(){return this[R]}get paused(){return this[Ue]}[Xt](e){this[T]?this[_]+=1:this[_]+=e.length,this[S].push(e)}[mt](){return this[T]?this[_]-=1:this[_]-=this[S][0].length,this[S].shift()}[ft](e=!1){do;while(this[ss](this[mt]())&&this[S].length);!e&&!this[S].length&&!this[G]&&this.emit("drain")}[ss](e){return this.emit("data",e),this[R]}pipe(e,t){if(this[w])return e;this[A]=!1;let i=this[J];return t=t||{},e===ts.stdout||e===ts.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,i?t.end&&e.end():(this[L].push(t.proxyErrors?new Nr(this,e,t):new Cs(this,e,t)),this[U]?He(()=>this[xe]()):this[xe]()),e}unpipe(e){let t=this[L].find(i=>i.dest===e);t&&(this[L].length===1?(this[R]&&this[ce]===0&&(this[R]=!1),this[L]=[]):this[L].splice(this[L].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let i=super.on(e,t);if(e==="data")this[A]=!1,this[ce]++,!this[L].length&&!this[R]&&this[xe]();else if(e==="readable"&&this[_]!==0)super.emit("readable");else if(xr(e)&&this[J])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[ze]){let s=t;this[U]?He(()=>s.call(this,this[ze])):s.call(this,this[ze])}return i}removeListener(e,t){return this.off(e,t)}off(e,t){let i=super.off(e,t);return e==="data"&&(this[ce]=this.listeners("data").length,this[ce]===0&&!this[A]&&!this[L].length&&(this[R]=!1)),i}removeAllListeners(e){let t=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[ce]=0,!this[A]&&!this[L].length&&(this[R]=!1)),t}get emittedEnd(){return this[J]}[Y](){!this[ct]&&!this[J]&&!this[w]&&this[S].length===0&&this[G]&&(this[ct]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ut]&&this.emit("close"),this[ct]=!1)}emit(e,...t){let i=t[0];if(e!=="error"&&e!=="close"&&e!==w&&this[w])return!1;if(e==="data")return!this[T]&&!i?!1:this[U]?(He(()=>this[Jt](i)),!0):this[Jt](i);if(e==="end")return this[rs]();if(e==="close"){if(this[ut]=!0,!this[J]&&!this[w])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(e==="error"){this[ze]=i,super.emit(qt,i);let r=!this[je]||this.listeners("error").length?super.emit("error",i):!1;return this[Y](),r}else if(e==="resume"){let r=super.emit("resume");return this[Y](),r}else if(e==="finish"||e==="prefinish"){let r=super.emit(e);return this.removeAllListeners(e),r}let s=super.emit(e,...t);return this[Y](),s}[Jt](e){for(let i of this[L])i.dest.write(e)===!1&&this.pause();let t=this[A]?!1:super.emit("data",e);return this[Y](),t}[rs](){return this[J]?!1:(this[J]=!0,this.readable=!1,this[U]?(He(()=>this[Qt]()),!0):this[Qt]())}[Qt](){if(this[_e]){let t=this[_e].end();if(t){for(let i of this[L])i.dest.write(t);this[A]||super.emit("data",t)}}for(let t of this[L])t.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[T]||(e.dataLength=0);let t=this.promise();return this.on("data",i=>{e.push(i),this[T]||(e.dataLength+=i.length)}),await t,e}async concat(){if(this[T])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[B]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(w,()=>t(new Error("stream destroyed"))),this.on("error",i=>t(i)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[A]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[G])return t();let s,r,n=l=>{this.off("data",h),this.off("end",o),this.off(w,a),t(),r(l)},h=l=>{this.off("error",n),this.off("end",o),this.off(w,a),this.pause(),s({value:l,done:!!this[G]})},o=()=>{this.off("error",n),this.off("data",h),this.off(w,a),t(),s({done:!0,value:void 0})},a=()=>n(new Error("stream destroyed"));return new Promise((l,d)=>{r=d,s=l,this.once(w,a),this.once("error",n),this.once("end",o),this.once("data",h)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[A]=!1;let e=!1,t=()=>(this.pause(),this.off(qt,t),this.off(w,t),this.off("end",t),e=!0,{done:!0,value:void 0}),i=()=>{if(e)return t();let s=this.read();return s===null?t():{done:!1,value:s}};return this.once("end",t),this.once(qt,t),this.once(w,t),{next:i,throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[w])return e?this.emit("error",e):this.emit(w),this;this[w]=!0,this[A]=!0,this[S].length=0,this[_]=0;let t=this;return typeof t.close=="function"&&!this[ut]&&t.close(),e?this.emit("error",e):this.emit(w),this}static get isStream(){return Or}},Br=x.writev,ae=Symbol("_autoClose"),z=Symbol("_close"),Ze=Symbol("_ended"),p=Symbol("_fd"),ti=Symbol("_finished"),q=Symbol("_flags"),ii=Symbol("_flush"),Ri=Symbol("_handleChunk"),Si=Symbol("_makeBuf"),et=Symbol("_mode"),yt=Symbol("_needDrain"),Fe=Symbol("_onerror"),Be=Symbol("_onopen"),si=Symbol("_onread"),Ae=Symbol("_onwrite"),le=Symbol("_open"),P=Symbol("_path"),se=Symbol("_pos"),j=Symbol("_queue"),De=Symbol("_read"),ri=Symbol("_readSize"),X=Symbol("_reading"),$e=Symbol("_remain"),ni=Symbol("_size"),kt=Symbol("_write"),ue=Symbol("_writing"),Tt=Symbol("_defaultFlag"),ge=Symbol("_errored"),$i=class extends Se{[ge]=!1;[p];[P];[ri];[X]=!1;[ni];[$e];[ae];constructor(e,t){if(t=t||{},super(t),this.readable=!0,this.writable=!1,typeof e!="string")throw new TypeError("path must be a string");this[ge]=!1,this[p]=typeof t.fd=="number"?t.fd:void 0,this[P]=e,this[ri]=t.readSize||16*1024*1024,this[X]=!1,this[ni]=typeof t.size=="number"?t.size:1/0,this[$e]=this[ni],this[ae]=typeof t.autoClose=="boolean"?t.autoClose:!0,typeof this[p]=="number"?this[De]():this[le]()}get fd(){return this[p]}get path(){return this[P]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[le](){x.open(this[P],"r",(e,t)=>this[Be](e,t))}[Be](e,t){e?this[Fe](e):(this[p]=t,this.emit("open",t),this[De]())}[Si](){return Buffer.allocUnsafe(Math.min(this[ri],this[$e]))}[De](){if(!this[X]){this[X]=!0;let e=this[Si]();if(e.length===0)return process.nextTick(()=>this[si](null,0,e));x.read(this[p],e,0,e.length,null,(t,i,s)=>this[si](t,i,s))}}[si](e,t,i){this[X]=!1,e?this[Fe](e):this[Ri](t,i)&&this[De]()}[z](){if(this[ae]&&typeof this[p]=="number"){let e=this[p];this[p]=void 0,x.close(e,t=>t?this.emit("error",t):this.emit("close"))}}[Fe](e){this[X]=!0,this[z](),this.emit("error",e)}[Ri](e,t){let i=!1;return this[$e]-=e,e>0&&(i=super.write(e<t.length?t.subarray(0,e):t)),(e===0||this[$e]<=0)&&(i=!1,this[z](),super.end()),i}emit(e,...t){switch(e){case"prefinish":case"finish":return!1;case"drain":return typeof this[p]=="number"&&this[De](),!1;case"error":return this[ge]?!1:(this[ge]=!0,super.emit(e,...t));default:return super.emit(e,...t)}}},Cr=class extends $i{[le](){let e=!0;try{this[Be](null,x.openSync(this[P],"r")),e=!1}finally{e&&this[z]()}}[De](){let e=!0;try{if(!this[X]){this[X]=!0;do{let t=this[Si](),i=t.length===0?0:x.readSync(this[p],t,0,t.length,null);if(!this[Ri](i,t))break}while(!0);this[X]=!1}e=!1}finally{e&&this[z]()}}[z](){if(this[ae]&&typeof this[p]=="number"){let e=this[p];this[p]=void 0,x.closeSync(e),this.emit("close")}}},Ht=class extends Sr{readable=!1;writable=!0;[ge]=!1;[ue]=!1;[Ze]=!1;[j]=[];[yt]=!1;[P];[et];[ae];[p];[Tt];[q];[ti]=!1;[se];constructor(e,t){t=t||{},super(t),this[P]=e,this[p]=typeof t.fd=="number"?t.fd:void 0,this[et]=t.mode===void 0?438:t.mode,this[se]=typeof t.start=="number"?t.start:void 0,this[ae]=typeof t.autoClose=="boolean"?t.autoClose:!0;let i=this[se]!==void 0?"r+":"w";this[Tt]=t.flags===void 0,this[q]=t.flags===void 0?i:t.flags,this[p]===void 0&&this[le]()}emit(e,...t){if(e==="error"){if(this[ge])return!1;this[ge]=!0}return super.emit(e,...t)}get fd(){return this[p]}get path(){return this[P]}[Fe](e){this[z](),this[ue]=!0,this.emit("error",e)}[le](){x.open(this[P],this[q],this[et],(e,t)=>this[Be](e,t))}[Be](e,t){this[Tt]&&this[q]==="r+"&&e&&e.code==="ENOENT"?(this[q]="w",this[le]()):e?this[Fe](e):(this[p]=t,this.emit("open",t),this[ue]||this[ii]())}end(e,t){return e&&this.write(e,t),this[Ze]=!0,!this[ue]&&!this[j].length&&typeof this[p]=="number"&&this[Ae](null,0),this}write(e,t){return typeof e=="string"&&(e=Buffer.from(e,t)),this[Ze]?(this.emit("error",new Error("write() after end()")),!1):this[p]===void 0||this[ue]||this[j].length?(this[j].push(e),this[yt]=!0,!1):(this[ue]=!0,this[kt](e),!0)}[kt](e){x.write(this[p],e,0,e.length,this[se],(t,i)=>this[Ae](t,i))}[Ae](e,t){e?this[Fe](e):(this[se]!==void 0&&typeof t=="number"&&(this[se]+=t),this[j].length?this[ii]():(this[ue]=!1,this[Ze]&&!this[ti]?(this[ti]=!0,this[z](),this.emit("finish")):this[yt]&&(this[yt]=!1,this.emit("drain"))))}[ii](){if(this[j].length===0)this[Ze]&&this[Ae](null,0);else if(this[j].length===1)this[kt](this[j].pop());else{let e=this[j];this[j]=[],Br(this[p],e,this[se],(t,i)=>this[Ae](t,i))}}[z](){if(this[ae]&&typeof this[p]=="number"){let e=this[p];this[p]=void 0,x.close(e,t=>t?this.emit("error",t):this.emit("close"))}}},Ms=class extends Ht{[le](){let e;if(this[Tt]&&this[q]==="r+")try{e=x.openSync(this[P],this[q],this[et])}catch(t){if(t?.code==="ENOENT")return this[q]="w",this[le]();throw t}else e=x.openSync(this[P],this[q],this[et]);this[Be](null,e)}[z](){if(this[ae]&&typeof this[p]=="number"){let e=this[p];this[p]=void 0,x.closeSync(e),this.emit("close")}}[kt](e){let t=!0;try{this[Ae](null,x.writeSync(this[p],e,0,e.length,this[se])),t=!1}finally{if(t)try{this[z]()}catch{}}}},zr=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"]]),Ur=e=>!!e.sync&&!!e.file,jr=e=>!e.sync&&!!e.file,Hr=e=>!!e.sync&&!e.file,Zr=e=>!e.sync&&!e.file,$r=e=>!!e.file,Wr=e=>zr.get(e)||e,Wi=(e={})=>{if(!e)return{};let t={};for(let[i,s]of Object.entries(e)){let r=Wr(i);t[r]=s}return t.chmod===void 0&&t.noChmod===!1&&(t.chmod=!0),delete t.noChmod,t},lt=(e,t,i,s,r)=>Object.assign((n=[],h,o)=>{Array.isArray(n)&&(h=n,n={}),typeof h=="function"&&(o=h,h=void 0),h=h?Array.from(h):[];let a=Wi(n);if(r?.(a,h),Ur(a)){if(typeof o=="function")throw new TypeError("callback not supported for sync tar functions");return e(a,h)}else if(jr(a)){let l=t(a,h);return o?l.then(()=>o(),o):l}else if(Hr(a)){if(typeof o=="function")throw new TypeError("callback not supported for sync tar functions");return i(a,h)}else if(Zr(a)){if(typeof o=="function")throw new TypeError("callback only supported with file option");return s(a,h)}throw new Error("impossible options??")},{syncFile:e,asyncFile:t,syncNoFile:i,asyncNoFile:s,validate:r}),Vr=Yr.constants||{ZLIB_VERNUM:4736},W=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Vr)),Kr=Ee.concat,hs=Object.getOwnPropertyDescriptor(Ee,"concat"),Xr=e=>e,hi=hs?.writable===!0||hs?.set!==void 0?e=>{Ee.concat=e?Xr:Kr}:e=>{},ve=Symbol("_superWrite"),bt=class extends Error{code;errno;constructor(e,t){super("zlib: "+e.message,{cause:e}),this.code=e.code,this.errno=e.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+e.message,Error.captureStackTrace(this,t??this.constructor)}get name(){return"ZlibError"}},oi=Symbol("flushFlag"),Gi=class extends Se{#e=!1;#i=!1;#s;#n;#r;#t;#h;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#s}constructor(e,t){if(!e||typeof e!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(e),this.#s=e.flush??0,this.#n=e.finishFlush??0,this.#r=e.fullFlushFlag??0,typeof ns[t]!="function")throw new TypeError("Compression method not supported: "+t);try{this.#t=new ns[t](e)}catch(i){throw new bt(i,this.constructor)}this.#h=i=>{this.#e||(this.#e=!0,this.close(),this.emit("error",i))},this.#t?.on("error",i=>this.#h(new bt(i))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return _i(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(e){this.ended||(typeof e!="number"&&(e=this.#r),this.write(Object.assign(Ee.alloc(0),{[oi]:e})))}end(e,t,i){return typeof e=="function"&&(i=e,t=void 0,e=void 0),typeof t=="function"&&(i=t,t=void 0),e&&(t?this.write(e,t):this.write(e)),this.flush(this.#n),this.#i=!0,super.end(i)}get ended(){return this.#i}[ve](e){return super.write(e)}write(e,t,i){if(typeof t=="function"&&(i=t,t="utf8"),typeof e=="string"&&(e=Ee.from(e,t)),this.#e)return;_i(this.#t,"zlib binding closed");let s=this.#t._handle,r=s.close;s.close=()=>{};let n=this.#t.close;this.#t.close=()=>{},hi(!0);let h;try{let a=typeof e[oi]=="number"?e[oi]:this.#s;h=this.#t._processChunk(e,a),hi(!1)}catch(a){hi(!1),this.#h(new bt(a,this.write))}finally{this.#t&&(this.#t._handle=s,s.close=r,this.#t.close=n,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",a=>this.#h(new bt(a,this.write)));let o;if(h)if(Array.isArray(h)&&h.length>0){let a=h[0];o=this[ve](Ee.from(a));for(let l=1;l<h.length;l++)o=this[ve](h[l])}else o=this[ve](Ee.from(h));return i&&i(),o}},zs=class extends Gi{#e;#i;constructor(e,t){e=e||{},e.flush=e.flush||W.Z_NO_FLUSH,e.finishFlush=e.finishFlush||W.Z_FINISH,e.fullFlushFlag=W.Z_FULL_FLUSH,super(e,t),this.#e=e.level,this.#i=e.strategy}params(e,t){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.#e!==e||this.#i!==t){this.flush(W.Z_SYNC_FLUSH),_i(this.handle,"zlib binding closed");let i=this.handle.flush;this.handle.flush=(s,r)=>{typeof s=="function"&&(r=s,s=this.flushFlag),this.flush(s),r?.()};try{this.handle.params(e,t)}finally{this.handle.flush=i}this.handle&&(this.#e=e,this.#i=t)}}}},qr=class extends zs{#e;constructor(e){super(e,"Gzip"),this.#e=e&&!!e.portable}[ve](e){return this.#e?(this.#e=!1,e[9]=255,super[ve](e)):super[ve](e)}},Jr=class extends zs{constructor(e){super(e,"Unzip")}},Us=class extends Gi{constructor(e,t){e=e||{},e.flush=e.flush||W.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||W.BROTLI_OPERATION_FINISH,e.fullFlushFlag=W.BROTLI_OPERATION_FLUSH,super(e,t)}},Qr=class extends Us{constructor(e){super(e,"BrotliCompress")}},en=class extends Us{constructor(e){super(e,"BrotliDecompress")}},js=class extends Gi{constructor(e,t){e=e||{},e.flush=e.flush||W.ZSTD_e_continue,e.finishFlush=e.finishFlush||W.ZSTD_e_end,e.fullFlushFlag=W.ZSTD_e_flush,super(e,t)}},tn=class extends js{constructor(e){super(e,"ZstdCompress")}},sn=class extends js{constructor(e){super(e,"ZstdDecompress")}},rn=(e,t)=>{if(Number.isSafeInteger(e))e<0?hn(e,t):nn(e,t);else throw Error("cannot encode number outside of javascript safe integer range");return t},nn=(e,t)=>{t[0]=128;for(var i=t.length;i>1;i--)t[i-1]=e&255,e=Math.floor(e/256)},hn=(e,t)=>{t[0]=255;var i=!1;e=e*-1;for(var s=t.length;s>1;s--){var r=e&255;e=Math.floor(e/256),i?t[s-1]=Hs(r):r===0?t[s-1]=0:(i=!0,t[s-1]=Zs(r))}},on=e=>{let t=e[0],i=t===128?ln(e.subarray(1,e.length)):t===255?an(e):null;if(i===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(i))throw Error("parsed number outside of javascript safe integer range");return i},an=e=>{for(var t=e.length,i=0,s=!1,r=t-1;r>-1;r--){var n=Number(e[r]),h;s?h=Hs(n):n===0?h=n:(s=!0,h=Zs(n)),h!==0&&(i-=h*Math.pow(256,t-r-1))}return i},ln=e=>{for(var t=e.length,i=0,s=t-1;s>-1;s--){var r=Number(e[s]);r!==0&&(i+=r*Math.pow(256,t-s-1))}return i},Hs=e=>(255^e)&255,Zs=e=>(255^e)+1&255,dn={};Rr(dn,{code:()=>Yi,isCode:()=>Lt,isName:()=>cn,name:()=>Zt,normalFsTypes:()=>$s});var Lt=e=>Zt.has(e),cn=e=>Yi.has(e),$s=new Set(["0","","1","2","3","4","5","6","7","D"]),Zt=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"]]),Yi=new Map(Array.from(Zt).map(e=>[e[1],e[0]])),Re=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,t=0,i,s){Buffer.isBuffer(e)?this.decode(e,t||0,i,s):e&&this.#i(e)}decode(e,t,i,s){if(t||(t=0),!e||!(e.length>=t+512))throw new Error("need 512 bytes for header");let r=fe(e,t+156,1),n=$s.has(r),h=n?i:void 0,o=n?s:void 0;if(this.path=h?.path??fe(e,t,100),this.mode=h?.mode??o?.mode??re(e,t+100,8),this.uid=h?.uid??o?.uid??re(e,t+108,8),this.gid=h?.gid??o?.gid??re(e,t+116,8),this.size=h?.size??o?.size??re(e,t+124,12),this.mtime=h?.mtime??o?.mtime??ai(e,t+136,12),this.cksum=re(e,t+148,12),o&&this.#i(o,!0),h&&this.#i(h),Lt(r)&&(this.#e=r||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=fe(e,t+157,100),e.subarray(t+257,t+265).toString()==="ustar\x0000")if(this.uname=h?.uname??o?.uname??fe(e,t+265,32),this.gname=h?.gname??o?.gname??fe(e,t+297,32),this.devmaj=h?.devmaj??o?.devmaj??re(e,t+329,8)??0,this.devmin=h?.devmin??o?.devmin??re(e,t+337,8)??0,e[t+475]!==0){let l=fe(e,t+345,155);this.path=l+"/"+this.path}else{let l=fe(e,t+345,130);l&&(this.path=l+"/"+this.path),this.atime=i?.atime??s?.atime??ai(e,t+476,12),this.ctime=i?.ctime??s?.ctime??ai(e,t+488,12)}let a=256;for(let l=t;l<t+148;l++)a+=e[l];for(let l=t+156;l<t+512;l++)a+=e[l];this.cksumValid=a===this.cksum,this.cksum===void 0&&a===256&&(this.nullBlock=!0)}#i(e,t=!1){Object.assign(this,Object.fromEntries(Object.entries(e).filter(([i,s])=>!(s==null||i==="path"&&t||i==="linkpath"&&t||i==="global"))))}encode(e,t=0){if(e||(e=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(e.length>=t+512))throw new Error("need 512 bytes for header");let i=this.ctime||this.atime?130:155,s=un(this.path||"",i),r=s[0],n=s[1];this.needPax=!!s[2],this.needPax=me(e,t,100,r)||this.needPax,this.needPax=ne(e,t+100,8,this.mode)||this.needPax,this.needPax=ne(e,t+108,8,this.uid)||this.needPax,this.needPax=ne(e,t+116,8,this.gid)||this.needPax,this.needPax=ne(e,t+124,12,this.size)||this.needPax,this.needPax=li(e,t+136,12,this.mtime)||this.needPax,e[t+156]=Number(this.#e.codePointAt(0)),this.needPax=me(e,t+157,100,this.linkpath)||this.needPax,e.write("ustar\x0000",t+257,8),this.needPax=me(e,t+265,32,this.uname)||this.needPax,this.needPax=me(e,t+297,32,this.gname)||this.needPax,this.needPax=ne(e,t+329,8,this.devmaj)||this.needPax,this.needPax=ne(e,t+337,8,this.devmin)||this.needPax,this.needPax=me(e,t+345,i,n)||this.needPax,e[t+475]!==0?this.needPax=me(e,t+345,155,n)||this.needPax:(this.needPax=me(e,t+345,130,n)||this.needPax,this.needPax=li(e,t+476,12,this.atime)||this.needPax,this.needPax=li(e,t+488,12,this.ctime)||this.needPax);let h=256;for(let o=t;o<t+148;o++)h+=e[o];for(let o=t+156;o<t+512;o++)h+=e[o];return this.cksum=h,ne(e,t+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Zt.get(this.#e)}get typeKey(){return this.#e}set type(e){let t=String(Yi.get(e));if(Lt(t)||t==="Unsupported")this.#e=t;else if(Lt(e))this.#e=e;else throw new TypeError("invalid entry type: "+e)}},un=(e,t)=>{let i=e,s="",r,n=Oe.parse(e).root||".";if(Buffer.byteLength(i)<100)r=[i,s,!1];else{s=Oe.dirname(i),i=Oe.basename(i);do Buffer.byteLength(i)<=100&&Buffer.byteLength(s)<=t?r=[i,s,!1]:Buffer.byteLength(i)>100&&Buffer.byteLength(s)<=t?r=[i.slice(0,99),s,!0]:(i=Oe.join(Oe.basename(s),i),s=Oe.dirname(s));while(s!==n&&r===void 0);r||(r=[e.slice(0,99),"",!0])}return r},fe=(e,t,i)=>e.subarray(t,t+i).toString("utf8").replace(/\0.*/,""),ai=(e,t,i)=>fn(re(e,t,i)),fn=e=>e===void 0?void 0:new Date(e*1e3),re=(e,t,i)=>Number(e[t])&128?on(e.subarray(t,t+i)):pn(e,t,i),mn=e=>isNaN(e)?void 0:e,pn=(e,t,i)=>mn(parseInt(e.subarray(t,t+i).toString("utf8").replace(/\0.*$/,"").trim(),8)),yn={12:8589934591,8:2097151},ne=(e,t,i,s)=>s===void 0?!1:s>yn[i]||s<0?(rn(s,e.subarray(t,t+i)),!0):(bn(e,t,i,s),!1),bn=(e,t,i,s)=>e.write(wn(s,i),t,i,"ascii"),wn=(e,t)=>gn(Math.floor(e).toString(8),t),gn=(e,t)=>(e.length===t-1?e:new Array(t-e.length-1).join("0")+e+" ")+"\0",li=(e,t,i,s)=>s===void 0?!1:ne(e,t,i,s.getTime()/1e3),En=new Array(156).join("\0"),me=(e,t,i,s)=>s===void 0?!1:(e.write(s+En,t,i,"utf8"),s.length!==Buffer.byteLength(s)||s.length>i),Mt=class Ws{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(t,i=!1){this.atime=t.atime,this.charset=t.charset,this.comment=t.comment,this.ctime=t.ctime,this.dev=t.dev,this.gid=t.gid,this.global=i,this.gname=t.gname,this.ino=t.ino,this.linkpath=t.linkpath,this.mtime=t.mtime,this.nlink=t.nlink,this.path=t.path,this.size=t.size,this.uid=t.uid,this.uname=t.uname}encode(){let t=this.encodeBody();if(t==="")return Buffer.allocUnsafe(0);let i=Buffer.byteLength(t),s=512*Math.ceil(1+i/512),r=Buffer.allocUnsafe(s);for(let n=0;n<512;n++)r[n]=0;new Re({path:("PaxHeader/"+vn(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:i,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(r),r.write(t,512,i,"utf8");for(let n=i+512;n<r.length;n++)r[n]=0;return r}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(t){if(this[t]===void 0)return"";let i=this[t],s=i instanceof Date?i.getTime()/1e3:i,r=" "+(t==="dev"||t==="ino"||t==="nlink"?"SCHILY.":"")+t+"="+s+`
`,n=Buffer.byteLength(r),h=Math.floor(Math.log(n)/Math.log(10))+1;return n+h>=Math.pow(10,h)&&(h+=1),h+n+r}static parse(t,i,s=!1){return new Ws(Rn(Sn(t),i),s)}},Rn=(e,t)=>t?Object.assign({},t,e):e,Sn=e=>e.replace(/\n$/,"").split(`
`).reduce(_n,Object.create(null)),_n=(e,t)=>{let i=parseInt(t,10);if(i!==Buffer.byteLength(t)+1)return e;t=t.slice((i+" ").length);let s=t.split("="),r=s.shift();if(!r)return e;let n=r.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),h=s.join("=").replace(/\0.*/,"");return e[n]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(n)?new Date(Number(h)*1e3):/^[0-9]+$/.test(h)?+h:h,e},On=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,c=On!=="win32"?e=>e:e=>e&&e.replaceAll(/\\/g,"/"),kn=class extends Se{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(e,t,i){switch(super({}),this.pause(),this.extended=t,this.globalExtended=i,this.header=e,this.remain=e.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=e.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!e.path)throw new Error("no path provided for tar.ReadEntry");this.path=c(e.path),this.mode=e.mode,this.mode&&(this.mode=this.mode&4095),this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=this.remain,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?c(e.linkpath):void 0,this.uname=e.uname,this.gname=e.gname,t&&this.#e(t),i&&this.#e(i,!0)}write(e){let t=e.length;if(t>this.blockRemain)throw new Error("writing more to entry than is appropriate");let i=this.remain,s=this.blockRemain;return this.remain=Math.max(0,i-t),this.blockRemain=Math.max(0,s-t),this.ignore?!0:i>=t?super.write(e):super.write(e.subarray(0,i))}#e(e,t=!1){e.path&&(e.path=c(e.path)),e.linkpath&&(e.linkpath=c(e.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(e).filter(([i,s])=>!(s==null||i==="path"&&t))))}},$t=(e,t,i,s={})=>{e.file&&(s.file=e.file),e.cwd&&(s.cwd=e.cwd),s.code=i instanceof Error&&i.code||t,s.tarCode=t,!e.strict&&s.recoverable!==!1?(i instanceof Error&&(s=Object.assign(i,s),i=i.message),e.emit("warn",t,i,s)):i instanceof Error?e.emit("error",Object.assign(i,s)):e.emit("error",Object.assign(new Error(`${t}: ${i}`),s))},Tn=1024*1024,Oi=Buffer.from([31,139]),ki=Buffer.from([40,181,47,253]),Ln=Math.max(Oi.length,ki.length),I=Symbol("state"),pe=Symbol("writeEntry"),V=Symbol("readEntry"),di=Symbol("nextEntry"),os=Symbol("processEntry"),H=Symbol("extendedHeader"),We=Symbol("globalExtendedHeader"),Q=Symbol("meta"),as=Symbol("emitMeta"),y=Symbol("buffer"),K=Symbol("queue"),ee=Symbol("ended"),ci=Symbol("emittedEnd"),ye=Symbol("emit"),E=Symbol("unzip"),wt=Symbol("consumeChunk"),gt=Symbol("consumeChunkSub"),ui=Symbol("consumeBody"),ls=Symbol("consumeMeta"),ds=Symbol("consumeHeader"),Ge=Symbol("consuming"),fi=Symbol("bufferConcat"),Et=Symbol("maybeEnd"),ke=Symbol("writing"),te=Symbol("aborted"),vt=Symbol("onDone"),be=Symbol("sawValidEntry"),Rt=Symbol("sawNullBlock"),St=Symbol("sawEOF"),cs=Symbol("closeStream"),xn=()=>!0,at=class extends Gr{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[K]=[];[y];[V];[pe];[I]="begin";[Q]="";[H];[We];[ee]=!1;[E];[te]=!1;[be];[Rt]=!1;[St]=!1;[ke]=!1;[Ge]=!1;[ci]=!1;constructor(e={}){super(),this.file=e.file||"",this.on(vt,()=>{(this[I]==="begin"||this[be]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),e.ondone?this.on(vt,e.ondone):this.on(vt,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!e.strict,this.maxMetaEntrySize=e.maxMetaEntrySize||Tn,this.filter=typeof e.filter=="function"?e.filter:xn;let t=e.file&&(e.file.endsWith(".tar.br")||e.file.endsWith(".tbr"));this.brotli=!(e.gzip||e.zstd)&&e.brotli!==void 0?e.brotli:t?void 0:!1;let i=e.file&&(e.file.endsWith(".tar.zst")||e.file.endsWith(".tzst"));this.zstd=!(e.gzip||e.brotli)&&e.zstd!==void 0?e.zstd:i?!0:void 0,this.on("end",()=>this[cs]()),typeof e.onwarn=="function"&&this.on("warn",e.onwarn),typeof e.onReadEntry=="function"&&this.on("entry",e.onReadEntry)}warn(e,t,i={}){$t(this,e,t,i)}[ds](e,t){this[be]===void 0&&(this[be]=!1);let i;try{i=new Re(e,t,this[H],this[We])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(i.nullBlock)this[Rt]?(this[St]=!0,this[I]==="begin"&&(this[I]="header"),this[ye]("eof")):(this[Rt]=!0,this[ye]("nullBlock"));else if(this[Rt]=!1,!i.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:i});else if(!i.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:i});else{let s=i.type;if(/^(Symbolic)?Link$/.test(s)&&!i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:i});else if(!/^(Symbolic)?Link$/.test(s)&&!/^(Global)?ExtendedHeader$/.test(s)&&i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:i});else{let r=this[pe]=new kn(i,this[H],this[We]);if(!this[be])if(r.remain){let n=()=>{r.invalid||(this[be]=!0)};r.on("end",n)}else this[be]=!0;r.meta?r.size>this.maxMetaEntrySize?(r.ignore=!0,this[ye]("ignoredEntry",r),this[I]="ignore",r.resume()):r.size>0&&(this[Q]="",r.on("data",n=>this[Q]+=n),this[I]="meta"):(this[H]=void 0,r.ignore=r.ignore||!this.filter(r.path,r),r.ignore?(this[ye]("ignoredEntry",r),this[I]=r.remain?"ignore":"header",r.resume()):(r.remain?this[I]="body":(this[I]="header",r.end()),this[V]?this[K].push(r):(this[K].push(r),this[di]())))}}}[cs](){queueMicrotask(()=>this.emit("close"))}[os](e){let t=!0;if(!e)this[V]=void 0,t=!1;else if(Array.isArray(e)){let[i,...s]=e;this.emit(i,...s)}else this[V]=e,this.emit("entry",e),e.emittedEnd||(e.on("end",()=>this[di]()),t=!1);return t}[di](){do;while(this[os](this[K].shift()));if(this[K].length===0){let e=this[V];!e||e.flowing||e.size===e.remain?this[ke]||this.emit("drain"):e.once("drain",()=>this.emit("drain"))}}[ui](e,t){let i=this[pe];if(!i)throw new Error("attempt to consume body without entry??");let s=i.blockRemain??0,r=s>=e.length&&t===0?e:e.subarray(t,t+s);return i.write(r),i.blockRemain||(this[I]="header",this[pe]=void 0,i.end()),r.length}[ls](e,t){let i=this[pe],s=this[ui](e,t);return!this[pe]&&i&&this[as](i),s}[ye](e,t,i){this[K].length===0&&!this[V]?this.emit(e,t,i):this[K].push([e,t,i])}[as](e){switch(this[ye]("meta",this[Q]),e.type){case"ExtendedHeader":case"OldExtendedHeader":this[H]=Mt.parse(this[Q],this[H],!1);break;case"GlobalExtendedHeader":this[We]=Mt.parse(this[Q],this[We],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let t=this[H]??Object.create(null);this[H]=t,t.path=this[Q].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let t=this[H]||Object.create(null);this[H]=t,t.linkpath=this[Q].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+e.type)}}abort(e){this[te]=!0,this.emit("abort",e),this.warn("TAR_ABORT",e,{recoverable:!1})}write(e,t,i){if(typeof t=="function"&&(i=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof t=="string"?t:"utf8")),this[te])return i?.(),!1;if((this[E]===void 0||this.brotli===void 0&&this[E]===!1)&&e){if(this[y]&&(e=Buffer.concat([this[y],e]),this[y]=void 0),e.length<Ln)return this[y]=e,i?.(),!0;for(let h=0;this[E]===void 0&&h<Oi.length;h++)e[h]!==Oi[h]&&(this[E]=!1);let r=!1;if(this[E]===!1&&this.zstd!==!1){r=!0;for(let h=0;h<ki.length;h++)if(e[h]!==ki[h]){r=!1;break}}let n=this.brotli===void 0&&!r;if(this[E]===!1&&n)if(e.length<512)if(this[ee])this.brotli=!0;else return this[y]=e,i?.(),!0;else try{new Re(e.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[E]===void 0||this[E]===!1&&(this.brotli||r)){let h=this[ee];this[ee]=!1,this[E]=this[E]===void 0?new Jr({}):r?new sn({}):new en({}),this[E].on("data",a=>this[wt](a)),this[E].on("error",a=>this.abort(a)),this[E].on("end",()=>{this[ee]=!0,this[wt]()}),this[ke]=!0;let o=!!this[E][h?"end":"write"](e);return this[ke]=!1,i?.(),o}}this[ke]=!0,this[E]?this[E].write(e):this[wt](e),this[ke]=!1;let s=this[K].length>0?!1:this[V]?this[V].flowing:!0;return!s&&this[K].length===0&&this[V]?.once("drain",()=>this.emit("drain")),i?.(),s}[fi](e){e&&!this[te]&&(this[y]=this[y]?Buffer.concat([this[y],e]):e)}[Et](){if(this[ee]&&!this[ci]&&!this[te]&&!this[Ge]){this[ci]=!0;let e=this[pe];if(e&&e.blockRemain){let t=this[y]?this[y].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${e.blockRemain} more bytes, only ${t} available)`,{entry:e}),this[y]&&e.write(this[y]),e.end()}this[ye](vt)}}[wt](e){if(this[Ge]&&e)this[fi](e);else if(!e&&!this[y])this[Et]();else if(e){if(this[Ge]=!0,this[y]){this[fi](e);let t=this[y];this[y]=void 0,this[gt](t)}else this[gt](e);for(;this[y]&&this[y]?.length>=512&&!this[te]&&!this[St];){let t=this[y];this[y]=void 0,this[gt](t)}this[Ge]=!1}(!this[y]||this[ee])&&this[Et]()}[gt](e){let t=0,i=e.length;for(;t+512<=i&&!this[te]&&!this[St];)switch(this[I]){case"begin":case"header":this[ds](e,t),t+=512;break;case"ignore":case"body":t+=this[ui](e,t);break;case"meta":t+=this[ls](e,t);break;default:throw new Error("invalid state: "+this[I])}t<i&&(this[y]=this[y]?Buffer.concat([e.subarray(t),this[y]]):e.subarray(t))}end(e,t,i){return typeof e=="function"&&(i=e,t=void 0,e=void 0),typeof t=="function"&&(i=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,t)),i&&this.once("finish",i),this[te]||(this[E]?(e&&this[E].write(e),this[E].end()):(this[ee]=!0,(this.brotli===void 0||this.zstd===void 0)&&(e=e||Buffer.alloc(0)),e&&this.write(e),this[Et]())),this}},tt=e=>{let t=e.length-1,i=-1;for(;t>-1&&e.charAt(t)==="/";)i=t,t--;return i===-1?e:e.slice(0,i)},An=e=>{let t=e.onReadEntry;e.onReadEntry=t?i=>{t(i),i.resume()}:i=>i.resume()},Gs=(e,t)=>{let i=new Map(t.map(n=>[tt(n),!0])),s=e.filter,r=(n,h="")=>{let o=h||Pr(n).root||".",a;if(n===o)a=!1;else{let l=i.get(n);a=l!==void 0?l:r(Mr(n),o)}return i.set(n,a),a};e.filter=s?(n,h)=>s(n,h)&&r(tt(n)):n=>r(tt(n))},Dn=e=>{let t=new at(e),i=e.file,s;try{s=Ne.openSync(i,"r");let r=Ne.fstatSync(s),n=e.maxReadSize||16*1024*1024;if(r.size<n){let h=Buffer.allocUnsafe(r.size),o=Ne.readSync(s,h,0,r.size,0);t.end(o===h.byteLength?h:h.subarray(0,o))}else{let h=0,o=Buffer.allocUnsafe(n);for(;h<r.size;){let a=Ne.readSync(s,o,0,n,h);if(a===0)break;h+=a,t.write(o.subarray(0,a))}t.end()}}finally{if(typeof s=="number")try{Ne.closeSync(s)}catch{}}},Nn=(e,t)=>{let i=new at(e),s=e.maxReadSize||16*1024*1024,r=e.file;return new Promise((n,h)=>{i.on("error",h),i.on("end",n),Ne.stat(r,(o,a)=>{if(o)h(o);else{let l=new $i(r,{readSize:s,size:a.size});l.on("error",h),l.pipe(i)}})})},Wt=lt(Dn,Nn,e=>new at(e),e=>new at(e),(e,t)=>{t?.length&&Gs(e,t),e.noResume||An(e)}),Ys=(e,t,i)=>(e&=4095,i&&(e=(e|384)&-19),t&&(e&256&&(e|=64),e&32&&(e|=8),e&4&&(e|=1)),e),{isAbsolute:Fn,parse:fs}=In,Vi=e=>{let t="",i=fs(e);for(;Fn(e)||i.root;){let s=e.charAt(0)==="/"&&e.slice(0,4)!=="//?/"?"/":i.root;e=e.slice(s.length),t+=s,i=fs(e)}return[t,e]},Gt=["|","<",">","?",":"],Ki=Gt.map(e=>String.fromCodePoint(61440+Number(e.codePointAt(0)))),Bn=new Map(Gt.map((e,t)=>[e,Ki[t]])),Cn=new Map(Ki.map((e,t)=>[e,Gt[t]])),ms=e=>Gt.reduce((t,i)=>t.split(i).join(Bn.get(i)),e),Mn=e=>Ki.reduce((t,i)=>t.split(i).join(Cn.get(i)),e),Vs=(e,t)=>t?(e=c(e).replace(/^\.(\/|$)/,""),tt(t)+"/"+e):c(e),Pn=16*1024*1024,ps=Symbol("process"),ys=Symbol("file"),bs=Symbol("directory"),Ti=Symbol("symlink"),ws=Symbol("hardlink"),Ye=Symbol("header"),xt=Symbol("read"),Li=Symbol("lstat"),At=Symbol("onlstat"),xi=Symbol("onread"),Ai=Symbol("onreadlink"),Di=Symbol("openfile"),Ni=Symbol("onopenfile"),he=Symbol("close"),zt=Symbol("mode"),Ii=Symbol("awaitDrain"),mi=Symbol("ondrain"),$=Symbol("prefix"),Ks=class extends Se{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(e,t={}){let i=Wi(t);super(),this.path=c(e),this.portable=!!i.portable,this.maxReadSize=i.maxReadSize||Pn,this.linkCache=i.linkCache||new Map,this.statCache=i.statCache||new Map,this.preservePaths=!!i.preservePaths,this.cwd=c(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?c(i.prefix):void 0,this.onWriteEntry=i.onWriteEntry,typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let s=!1;if(!this.preservePaths){let[n,h]=Vi(this.path);n&&typeof h=="string"&&(this.path=h,s=n)}this.win32=!!i.win32||process.platform==="win32",this.win32&&(this.path=Mn(this.path.replaceAll(/\\/g,"/")),e=e.replaceAll(/\\/g,"/")),this.absolute=c(i.absolute||us.resolve(this.cwd,e)),this.path===""&&(this.path="./"),s&&this.warn("TAR_ENTRY_INFO",`stripping ${s} from absolute path`,{entry:this,path:s+this.path});let r=this.statCache.get(this.absolute);r?this[At](r):this[Li]()}warn(e,t,i={}){return $t(this,e,t,i)}emit(e,...t){return e==="error"&&(this.#e=!0),super.emit(e,...t)}[Li](){Z.lstat(this.absolute,(e,t)=>{if(e)return this.emit("error",e);this[At](t)})}[At](e){this.statCache.set(this.absolute,e),this.stat=e,e.isFile()||(e.size=0),this.type=jn(e),this.emit("stat",e),this[ps]()}[ps](){switch(this.type){case"File":return this[ys]();case"Directory":return this[bs]();case"SymbolicLink":return this[Ti]();default:return this.end()}}[zt](e){return Ys(e,this.type==="Directory",this.portable)}[$](e){return Vs(e,this.prefix)}[Ye](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Re({path:this[$](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[$](this.linkpath):this.linkpath,mode:this[zt](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Mt({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[$](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[$](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let e=this.header?.block;if(!e)throw new Error("failed to encode header");super.write(e)}[bs](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Ye](),this.end()}[Ti](){Z.readlink(this.absolute,(e,t)=>{if(e)return this.emit("error",e);this[Ai](t)})}[Ai](e){this.linkpath=c(e),this[Ye](),this.end()}[ws](e){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=c(us.relative(this.cwd,e)),this.stat.size=0,this[Ye](),this.end()}[ys](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let e=`${this.stat.dev}:${this.stat.ino}`,t=this.linkCache.get(e);if(t?.indexOf(this.cwd)===0)return this[ws](t);this.linkCache.set(e,this.absolute)}if(this[Ye](),this.stat.size===0)return this.end();this[Di]()}[Di](){Z.open(this.absolute,"r",(e,t)=>{if(e)return this.emit("error",e);this[Ni](t)})}[Ni](e){if(this.fd=e,this.#e)return this[he]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let t=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(t),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[xt]()}[xt](){let{fd:e,buf:t,offset:i,length:s,pos:r}=this;if(e===void 0||t===void 0)throw new Error("cannot read file without first opening");Z.read(e,t,i,s,r,(n,h)=>{if(n)return this[he](()=>this.emit("error",n));this[xi](h)})}[he](e=()=>{}){this.fd!==void 0&&Z.close(this.fd,e)}[xi](e){if(e<=0&&this.remain>0){let i=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[he](()=>this.emit("error",i))}if(e>this.remain){let i=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[he](()=>this.emit("error",i))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(e===this.remain)for(let i=e;i<this.length&&e<this.blockRemain;i++)this.buf[i+this.offset]=0,e++,this.remain++;let t=this.offset===0&&e===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+e);this.write(t)?this[mi]():this[Ii](()=>this[mi]())}[Ii](e){this.once("drain",e)}write(e,t,i){if(typeof t=="function"&&(i=t,t=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof t=="string"?t:"utf8")),this.blockRemain<e.length){let s=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=e.length,this.blockRemain-=e.length,this.pos+=e.length,this.offset+=e.length,super.write(e,null,i)}[mi](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[he](e=>e?this.emit("error",e):this.end());if(!this.buf)throw 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[xt]()}},zn=class extends Ks{sync=!0;[Li](){this[At](Z.lstatSync(this.absolute))}[Ti](){this[Ai](Z.readlinkSync(this.absolute))}[Di](){this[Ni](Z.openSync(this.absolute,"r"))}[xt](){let e=!0;try{let{fd:t,buf:i,offset:s,length:r,pos:n}=this;if(t===void 0||i===void 0)throw new Error("fd and buf must be set in READ method");let h=Z.readSync(t,i,s,r,n);this[xi](h),e=!1}finally{if(e)try{this[he](()=>{})}catch{}}}[Ii](e){e()}[he](e=()=>{}){this.fd!==void 0&&Z.closeSync(this.fd),e()}},Un=class extends Se{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;h