From 426db6688880aa2b508367fcf26b2db29244970b Mon Sep 17 00:00:00 2001 From: Elizabeth Date: Fri, 4 Oct 2024 18:17:54 -0500 Subject: [PATCH] fix: major refactors and fixes to error handling. should improve general reliability of this action in many different circumstances. --- action.yml | 19 ++-- dist/index.js | 4 +- src/index.ts | 287 ++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 219 insertions(+), 91 deletions(-) diff --git a/action.yml b/action.yml index ef8ea2a..b2e6413 100644 --- a/action.yml +++ b/action.yml @@ -9,20 +9,23 @@ branding: inputs: token: description: "The GitHub token to use for downloading the modding environment" - default: ${{ github.token }} + default: "${{ github.token }}" required: false version: - description: "The BeatSaber version to use" - required: true + description: "The Beat Saber version to use. Optional if 'ref' is provided or can be inferred from manifest.json." + required: false + ref: + description: "The Git reference to download (branch, tag, or commit SHA). Overrides the 'version' input if provided." + required: false manifest: - description: "The path to the manifest.json file to infer version if not specified" + description: "The path to the manifest.json file to infer version if 'version' is not specified" required: false path: - description: "The location to install the modding environment to, defaults to ./Refs" + description: "The location to install the modding environment to" required: false default: "./Refs" host: - description: "The GitHub host to use, defaults to github.com" + description: "The GitHub host to use" required: false default: "github.com" repo: @@ -31,5 +34,5 @@ inputs: required: false runs: - using: node20 - main: dist/index.js + using: "node20" + main: "dist/index.js" diff --git a/dist/index.js b/dist/index.js index 0727a24..3504131 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,3 +1,3 @@ -import{createRequire as D4}from"node:module";var O4=Object.create;var{getPrototypeOf:U4,defineProperty:R8,getOwnPropertyNames:T4}=Object;var j4=Object.prototype.hasOwnProperty;var C4=($,Q,V)=>{V=$!=null?O4(U4($)):{};const X=Q||!$||!$.__esModule?R8(V,"default",{value:$,enumerable:!0}):V;for(let J of T4($))if(!j4.call(X,J))R8(X,J,{get:()=>$[J],enumerable:!0});return X};var F=($,Q)=>()=>(Q||$((Q={exports:{}}).exports,Q),Q.exports);var U=D4(import.meta.url);var o$=F((g8)=>{function S4($){if($===null||$===void 0)return"";else if(typeof $==="string"||$ instanceof String)return $;return JSON.stringify($)}function N4($){if(!Object.keys($).length)return{};return{title:$.title,file:$.file,line:$.startLine,endLine:$.endLine,col:$.startColumn,endColumn:$.endColumn}}Object.defineProperty(g8,"__esModule",{value:!0});g8.toCommandProperties=g8.toCommandValue=void 0;g8.toCommandValue=S4;g8.toCommandProperties=N4});var h8=F((d)=>{function b8($,Q,V){const X=new E8($,Q,V);process.stdout.write(X.toString()+y4.EOL)}function m4($,Q=""){b8($,{},Q)}function b4($){return m8.toCommandValue($).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function E4($){return m8.toCommandValue($).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}var R4=d&&d.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),g4=d&&d.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),k4=d&&d.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))R4(Q,$,V)}return g4(Q,$),Q};Object.defineProperty(d,"__esModule",{value:!0});d.issue=d.issueCommand=void 0;var y4=k4(U("os")),m8=o$();d.issueCommand=b8;d.issue=m4;var y8="::";class E8{constructor($,Q,V){if(!$)$="missing.command";this.command=$,this.properties=Q,this.message=V}toString(){let $=y8+this.command;if(this.properties&&Object.keys(this.properties).length>0){$+=" ";let Q=!0;for(let V in this.properties)if(this.properties.hasOwnProperty(V)){const X=this.properties[V];if(X){if(Q)Q=!1;else $+=",";$+=`${V}=${E4(X)}`}}}return $+=`${y8}${b4(this.message)}`,$}}});var r5=F((u8)=>{function u4($){return $&&$.__esModule?$:{default:$}}function f4(){if(t$>e$.length-16)h4.default.randomFillSync(e$),t$=0;return e$.slice(t$,t$+=16)}Object.defineProperty(u8,"__esModule",{value:!0});u8.default=f4;var h4=u4(U("crypto")),e$=new Uint8Array(256),t$=e$.length});var l8=F((f8)=>{Object.defineProperty(f8,"__esModule",{value:!0});f8.default=void 0;var l4=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;f8.default=l4});var x$=F((d8)=>{function i4($){return $&&$.__esModule?$:{default:$}}function p4($){return typeof $==="string"&&d4.default.test($)}Object.defineProperty(d8,"__esModule",{value:!0});d8.default=void 0;var d4=i4(l8()),a4=p4;d8.default=a4});var O$=F((p8)=>{function s4($){return $&&$.__esModule?$:{default:$}}function r4($,Q=0){const V=(R[$[Q+0]]+R[$[Q+1]]+R[$[Q+2]]+R[$[Q+3]]+"-"+R[$[Q+4]]+R[$[Q+5]]+"-"+R[$[Q+6]]+R[$[Q+7]]+"-"+R[$[Q+8]]+R[$[Q+9]]+"-"+R[$[Q+10]]+R[$[Q+11]]+R[$[Q+12]]+R[$[Q+13]]+R[$[Q+14]]+R[$[Q+15]]).toLowerCase();if(!n4.default(V))throw TypeError("Stringified UUID is invalid");return V}Object.defineProperty(p8,"__esModule",{value:!0});p8.default=void 0;var n4=s4(x$()),R=[];for(let $=0;$<256;++$)R.push(($+256).toString(16).substr(1));var o4=r4;p8.default=o4});var t8=F((r8)=>{function s8($){return $&&$.__esModule?$:{default:$}}function $6($,Q,V){let X=Q&&V||0;const J=Q||new Array(16);$=$||{};let Z=$.node||n8,K=$.clockseq!==void 0?$.clockseq:o5;if(Z==null||K==null){const L=$.random||($.rng||t4.default)();if(Z==null)Z=n8=[L[0]|1,L[1],L[2],L[3],L[4],L[5]];if(K==null)K=o5=(L[6]<<8|L[7])&16383}let G=$.msecs!==void 0?$.msecs:Date.now(),Y=$.nsecs!==void 0?$.nsecs:e5+1;const W=G-t5+(Y-e5)/1e4;if(W<0&&$.clockseq===void 0)K=K+1&16383;if((W<0||G>t5)&&$.nsecs===void 0)Y=0;if(Y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");t5=G,e5=Y,o5=K,G+=12219292800000;const z=((G&268435455)*1e4+Y)%4294967296;J[X++]=z>>>24&255,J[X++]=z>>>16&255,J[X++]=z>>>8&255,J[X++]=z&255;const q=G/4294967296*1e4&268435455;J[X++]=q>>>8&255,J[X++]=q&255,J[X++]=q>>>24&15|16,J[X++]=q>>>16&255,J[X++]=K>>>8|128,J[X++]=K&255;for(let L=0;L<6;++L)J[X+L]=Z[L];return Q||e4.default(J)}Object.defineProperty(r8,"__esModule",{value:!0});r8.default=void 0;var t4=s8(r5()),e4=s8(O$()),n8,o5,t5=0,e5=0,Q6=$6;r8.default=Q6});var $1=F((e8)=>{function X6($){return $&&$.__esModule?$:{default:$}}function J6($){if(!V6.default($))throw TypeError("Invalid UUID");let Q;const V=new Uint8Array(16);return V[0]=(Q=parseInt($.slice(0,8),16))>>>24,V[1]=Q>>>16&255,V[2]=Q>>>8&255,V[3]=Q&255,V[4]=(Q=parseInt($.slice(9,13),16))>>>8,V[5]=Q&255,V[6]=(Q=parseInt($.slice(14,18),16))>>>8,V[7]=Q&255,V[8]=(Q=parseInt($.slice(19,23),16))>>>8,V[9]=Q&255,V[10]=(Q=parseInt($.slice(24,36),16))/1099511627776&255,V[11]=Q/4294967296&255,V[12]=Q>>>24&255,V[13]=Q>>>16&255,V[14]=Q>>>8&255,V[15]=Q&255,V}Object.defineProperty(e8,"__esModule",{value:!0});e8.default=void 0;var V6=X6(x$()),Z6=J6;e8.default=Z6});var Q1=F((J9)=>{function Q9($){return $&&$.__esModule?$:{default:$}}function Y6($){$=unescape(encodeURIComponent($));const Q=[];for(let V=0;V<$.length;++V)Q.push($.charCodeAt(V));return Q}function z6($,Q,V){function X(J,Z,K,G){if(typeof J==="string")J=Y6(J);if(typeof Z==="string")Z=G6.default(Z);if(Z.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let Y=new Uint8Array(16+J.length);if(Y.set(Z),Y.set(J,Z.length),Y=V(Y),Y[6]=Y[6]&15|Q,Y[8]=Y[8]&63|128,K){G=G||0;for(let W=0;W<16;++W)K[G+W]=Y[W];return K}return K6.default(Y)}try{X.name=$}catch(J){}return X.DNS=V9,X.URL=X9,X}Object.defineProperty(J9,"__esModule",{value:!0});J9.default=z6;J9.URL=J9.DNS=void 0;var K6=Q9(O$()),G6=Q9($1()),V9="6ba7b810-9dad-11d1-80b4-00c04fd430c8";J9.DNS=V9;var X9="6ba7b811-9dad-11d1-80b4-00c04fd430c8";J9.URL=X9});var Y9=F((K9)=>{function L6($){return $&&$.__esModule?$:{default:$}}function M6($){if(Array.isArray($))$=Buffer.from($);else if(typeof $==="string")$=Buffer.from($,"utf8");return B6.default.createHash("md5").update($).digest()}Object.defineProperty(K9,"__esModule",{value:!0});K9.default=void 0;var B6=L6(U("crypto")),w6=M6;K9.default=w6});var B9=F((W9)=>{function z9($){return $&&$.__esModule?$:{default:$}}Object.defineProperty(W9,"__esModule",{value:!0});W9.default=void 0;var A6=z9(Q1()),I6=z9(Y9()),P6=A6.default("v3",48,I6.default),F6=P6;W9.default=F6});var A9=F((M9)=>{function L9($){return $&&$.__esModule?$:{default:$}}function x6($,Q,V){$=$||{};const X=$.random||($.rng||v6.default)();if(X[6]=X[6]&15|64,X[8]=X[8]&63|128,Q){V=V||0;for(let J=0;J<16;++J)Q[V+J]=X[J];return Q}return H6.default(X)}Object.defineProperty(M9,"__esModule",{value:!0});M9.default=void 0;var v6=L9(r5()),H6=L9(O$()),O6=x6;M9.default=O6});var F9=F((I9)=>{function T6($){return $&&$.__esModule?$:{default:$}}function j6($){if(Array.isArray($))$=Buffer.from($);else if(typeof $==="string")$=Buffer.from($,"utf8");return U6.default.createHash("sha1").update($).digest()}Object.defineProperty(I9,"__esModule",{value:!0});I9.default=void 0;var U6=T6(U("crypto")),C6=j6;I9.default=C6});var O9=F((H9)=>{function v9($){return $&&$.__esModule?$:{default:$}}Object.defineProperty(H9,"__esModule",{value:!0});H9.default=void 0;var D6=v9(Q1()),S6=v9(F9()),N6=D6.default("v5",80,S6.default),_6=N6;H9.default=_6});var j9=F((U9)=>{Object.defineProperty(U9,"__esModule",{value:!0});U9.default=void 0;var R6="00000000-0000-0000-0000-000000000000";U9.default=R6});var S9=F((C9)=>{function k6($){return $&&$.__esModule?$:{default:$}}function y6($){if(!g6.default($))throw TypeError("Invalid UUID");return parseInt($.substr(14,1),16)}Object.defineProperty(C9,"__esModule",{value:!0});C9.default=void 0;var g6=k6(x$()),m6=y6;C9.default=m6});var N9=F((t)=>{function w0($){return $&&$.__esModule?$:{default:$}}Object.defineProperty(t,"__esModule",{value:!0});Object.defineProperty(t,"v1",{enumerable:!0,get:function(){return b6.default}});Object.defineProperty(t,"v3",{enumerable:!0,get:function(){return E6.default}});Object.defineProperty(t,"v4",{enumerable:!0,get:function(){return h6.default}});Object.defineProperty(t,"v5",{enumerable:!0,get:function(){return u6.default}});Object.defineProperty(t,"NIL",{enumerable:!0,get:function(){return f6.default}});Object.defineProperty(t,"version",{enumerable:!0,get:function(){return c6.default}});Object.defineProperty(t,"validate",{enumerable:!0,get:function(){return l6.default}});Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d6.default}});Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return i6.default}});var b6=w0(t8()),E6=w0(B9()),h6=w0(A9()),u6=w0(O9()),f6=w0(j9()),c6=w0(S9()),l6=w0(x$()),d6=w0(O$()),i6=w0($1())});var k9=F((i)=>{function s6($,Q){const V=process.env[`GITHUB_${$}`];if(!V)throw new Error(`Unable to find environment variable for file command ${$}`);if(!_9.existsSync(V))throw new Error(`Missing file at path: ${V}`);_9.appendFileSync(V,`${g9.toCommandValue(Q)}${V1.EOL}`,{encoding:"utf8"})}function r6($,Q){const V=`ghadelimiter_${n6.v4()}`,X=g9.toCommandValue(Q);if($.includes(V))throw new Error(`Unexpected input: name should not contain the delimiter "${V}"`);if(X.includes(V))throw new Error(`Unexpected input: value should not contain the delimiter "${V}"`);return`${$}<<${V}${V1.EOL}${X}${V1.EOL}${V}`}var p6=i&&i.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),a6=i&&i.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),R9=i&&i.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))p6(Q,$,V)}return a6(Q,$),Q};Object.defineProperty(i,"__esModule",{value:!0});i.prepareKeyValueMessage=i.issueFileCommand=void 0;var _9=R9(U("fs")),V1=R9(U("os")),n6=N9(),g9=o$();i.issueFileCommand=s6;i.prepareKeyValueMessage=r6});var E9=F((m9)=>{function o6($){const Q=$.protocol==="https:";if(y9($))return;const V=(()=>{if(Q)return process.env.https_proxy||process.env.HTTPS_PROXY;else return process.env.http_proxy||process.env.HTTP_PROXY})();if(V)try{return new URL(V)}catch(X){if(!V.startsWith("http://")&&!V.startsWith("https://"))return new URL(`http://${V}`)}else return}function y9($){if(!$.hostname)return!1;const Q=$.hostname;if(t6(Q))return!0;const V=process.env.no_proxy||process.env.NO_PROXY||"";if(!V)return!1;let X;if($.port)X=Number($.port);else if($.protocol==="http:")X=80;else if($.protocol==="https:")X=443;const J=[$.hostname.toUpperCase()];if(typeof X==="number")J.push(`${J[0]}:${X}`);for(let Z of V.split(",").map((K)=>K.trim().toUpperCase()).filter((K)=>K))if(Z==="*"||J.some((K)=>K===Z||K.endsWith(`.${Z}`)||Z.startsWith(".")&&K.endsWith(`${Z}`)))return!0;return!1}function t6($){const Q=$.toLowerCase();return Q==="localhost"||Q.startsWith("127.")||Q.startsWith("[::1]")||Q.startsWith("[0:0:0:0:0:0:0:1]")}Object.defineProperty(m9,"__esModule",{value:!0});m9.checkBypass=m9.getProxyUrl=void 0;m9.getProxyUrl=o6;m9.checkBypass=y9});var c9=F((GQ)=>{function XQ($){var Q=new A0($);return Q.request=X1.request,Q}function JQ($){var Q=new A0($);return Q.request=X1.request,Q.createSocket=u9,Q.defaultPort=443,Q}function ZQ($){var Q=new A0($);return Q.request=h9.request,Q}function KQ($){var Q=new A0($);return Q.request=h9.request,Q.createSocket=u9,Q.defaultPort=443,Q}function A0($){var Q=this;Q.options=$||{},Q.proxyOptions=Q.options.proxy||{},Q.maxSockets=Q.options.maxSockets||X1.Agent.defaultMaxSockets,Q.requests=[],Q.sockets=[],Q.on("free",function V(X,J,Z,K){var G=f9(J,Z,K);for(var Y=0,W=Q.requests.length;Y=this.maxSockets){Z.requests.push(K);return}Z.createSocket(K,function(G){G.on("free",Y),G.on("close",W),G.on("agentRemove",W),Q.onSocket(G);function Y(){Z.emit("free",G,K)}function W(z){Z.removeSocket(G),G.removeListener("free",Y),G.removeListener("close",W),G.removeListener("agentRemove",W)}})};A0.prototype.createSocket=function $(Q,V){var X=this,J={};X.sockets.push(J);var Z=J1({},X.proxyOptions,{method:"CONNECT",path:Q.host+":"+Q.port,agent:!1,headers:{host:Q.host+":"+Q.port}});if(Q.localAddress)Z.localAddress=Q.localAddress;if(Z.proxyAuth)Z.headers=Z.headers||{},Z.headers["Proxy-Authorization"]="Basic "+new Buffer(Z.proxyAuth).toString("base64");j0("making CONNECT request");var K=X.request(Z);K.useChunkedEncodingByDefault=!1,K.once("response",G),K.once("upgrade",Y),K.once("connect",W),K.once("error",z),K.end();function G(q){q.upgrade=!0}function Y(q,L,H){process.nextTick(function(){W(q,L,H)})}function W(q,L,H){if(K.removeAllListeners(),L.removeAllListeners(),q.statusCode!==200){j0("tunneling socket could not be established, statusCode=%d",q.statusCode),L.destroy();var j=new Error("tunneling socket could not be established, statusCode="+q.statusCode);j.code="ECONNRESET",Q.request.emit("error",j),X.removeSocket(J);return}if(H.length>0){j0("got illegal response body from proxy"),L.destroy();var j=new Error("got illegal response body from proxy");j.code="ECONNRESET",Q.request.emit("error",j),X.removeSocket(J);return}return j0("tunneling connection has established"),X.sockets[X.sockets.indexOf(J)]=L,V(L)}function z(q){K.removeAllListeners(),j0("tunneling socket could not be established, cause=%s\n",q.message,q.stack);var L=new Error("tunneling socket could not be established, cause="+q.message);L.code="ECONNRESET",Q.request.emit("error",L),X.removeSocket(J)}};A0.prototype.removeSocket=function $(Q){var V=this.sockets.indexOf(Q);if(V===-1)return;this.sockets.splice(V,1);var X=this.requests.shift();if(X)this.createSocket(X,function(J){X.request.onSocket(J)})};var j0;if(process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG))j0=function(){var $=Array.prototype.slice.call(arguments);if(typeof $[0]==="string")$[0]="TUNNEL: "+$[0];else $.unshift("TUNNEL:");console.error.apply(console,$)};else j0=function(){};GQ.debug=j0});var i9=F((P)=>{function wQ($){const Q=l9.getProxyUrl(new URL($));return Q?Q.href:""}function HQ($){return new URL($).protocol==="https:"}var LQ=P&&P.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),MQ=P&&P.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),X5=P&&P.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))LQ(Q,$,V)}return MQ(Q,$),Q},x=P&&P.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(P,"__esModule",{value:!0});P.HttpClient=P.isHttps=P.HttpClientResponse=P.HttpClientError=P.getProxyUrl=P.MediaTypes=P.Headers=P.HttpCodes=void 0;var $5=X5(U("http")),Z1=X5(U("https")),l9=X5(E9()),Q5=X5(c9()),e;(function($){$[$.OK=200]="OK",$[$.MultipleChoices=300]="MultipleChoices",$[$.MovedPermanently=301]="MovedPermanently",$[$.ResourceMoved=302]="ResourceMoved",$[$.SeeOther=303]="SeeOther",$[$.NotModified=304]="NotModified",$[$.UseProxy=305]="UseProxy",$[$.SwitchProxy=306]="SwitchProxy",$[$.TemporaryRedirect=307]="TemporaryRedirect",$[$.PermanentRedirect=308]="PermanentRedirect",$[$.BadRequest=400]="BadRequest",$[$.Unauthorized=401]="Unauthorized",$[$.PaymentRequired=402]="PaymentRequired",$[$.Forbidden=403]="Forbidden",$[$.NotFound=404]="NotFound",$[$.MethodNotAllowed=405]="MethodNotAllowed",$[$.NotAcceptable=406]="NotAcceptable",$[$.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",$[$.RequestTimeout=408]="RequestTimeout",$[$.Conflict=409]="Conflict",$[$.Gone=410]="Gone",$[$.TooManyRequests=429]="TooManyRequests",$[$.InternalServerError=500]="InternalServerError",$[$.NotImplemented=501]="NotImplemented",$[$.BadGateway=502]="BadGateway",$[$.ServiceUnavailable=503]="ServiceUnavailable",$[$.GatewayTimeout=504]="GatewayTimeout"})(e=P.HttpCodes||(P.HttpCodes={}));var y;(function($){$.Accept="accept",$.ContentType="content-type"})(y=P.Headers||(P.Headers={}));var C0;(function($){$.ApplicationJson="application/json"})(C0=P.MediaTypes||(P.MediaTypes={}));P.getProxyUrl=wQ;var AQ=[e.MovedPermanently,e.ResourceMoved,e.SeeOther,e.TemporaryRedirect,e.PermanentRedirect],IQ=[e.BadGateway,e.ServiceUnavailable,e.GatewayTimeout],PQ=["OPTIONS","GET","DELETE","HEAD"],FQ=10,vQ=5;class J5 extends Error{constructor($,Q){super($);this.name="HttpClientError",this.statusCode=Q,Object.setPrototypeOf(this,J5.prototype)}}P.HttpClientError=J5;class K1{constructor($){this.message=$}readBody(){return x(this,void 0,void 0,function*(){return new Promise(($)=>x(this,void 0,void 0,function*(){let Q=Buffer.alloc(0);this.message.on("data",(V)=>{Q=Buffer.concat([Q,V])}),this.message.on("end",()=>{$(Q.toString())})}))})}readBodyBuffer(){return x(this,void 0,void 0,function*(){return new Promise(($)=>x(this,void 0,void 0,function*(){const Q=[];this.message.on("data",(V)=>{Q.push(V)}),this.message.on("end",()=>{$(Buffer.concat(Q))})}))})}}P.HttpClientResponse=K1;P.isHttps=HQ;class d9{constructor($,Q,V){if(this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=$,this.handlers=Q||[],this.requestOptions=V,V){if(V.ignoreSslError!=null)this._ignoreSslError=V.ignoreSslError;if(this._socketTimeout=V.socketTimeout,V.allowRedirects!=null)this._allowRedirects=V.allowRedirects;if(V.allowRedirectDowngrade!=null)this._allowRedirectDowngrade=V.allowRedirectDowngrade;if(V.maxRedirects!=null)this._maxRedirects=Math.max(V.maxRedirects,0);if(V.keepAlive!=null)this._keepAlive=V.keepAlive;if(V.allowRetries!=null)this._allowRetries=V.allowRetries;if(V.maxRetries!=null)this._maxRetries=V.maxRetries}}options($,Q){return x(this,void 0,void 0,function*(){return this.request("OPTIONS",$,null,Q||{})})}get($,Q){return x(this,void 0,void 0,function*(){return this.request("GET",$,null,Q||{})})}del($,Q){return x(this,void 0,void 0,function*(){return this.request("DELETE",$,null,Q||{})})}post($,Q,V){return x(this,void 0,void 0,function*(){return this.request("POST",$,Q,V||{})})}patch($,Q,V){return x(this,void 0,void 0,function*(){return this.request("PATCH",$,Q,V||{})})}put($,Q,V){return x(this,void 0,void 0,function*(){return this.request("PUT",$,Q,V||{})})}head($,Q){return x(this,void 0,void 0,function*(){return this.request("HEAD",$,null,Q||{})})}sendStream($,Q,V,X){return x(this,void 0,void 0,function*(){return this.request($,Q,V,X)})}getJson($,Q={}){return x(this,void 0,void 0,function*(){Q[y.Accept]=this._getExistingOrDefaultHeader(Q,y.Accept,C0.ApplicationJson);const V=yield this.get($,Q);return this._processResponse(V,this.requestOptions)})}postJson($,Q,V={}){return x(this,void 0,void 0,function*(){const X=JSON.stringify(Q,null,2);V[y.Accept]=this._getExistingOrDefaultHeader(V,y.Accept,C0.ApplicationJson),V[y.ContentType]=this._getExistingOrDefaultHeader(V,y.ContentType,C0.ApplicationJson);const J=yield this.post($,X,V);return this._processResponse(J,this.requestOptions)})}putJson($,Q,V={}){return x(this,void 0,void 0,function*(){const X=JSON.stringify(Q,null,2);V[y.Accept]=this._getExistingOrDefaultHeader(V,y.Accept,C0.ApplicationJson),V[y.ContentType]=this._getExistingOrDefaultHeader(V,y.ContentType,C0.ApplicationJson);const J=yield this.put($,X,V);return this._processResponse(J,this.requestOptions)})}patchJson($,Q,V={}){return x(this,void 0,void 0,function*(){const X=JSON.stringify(Q,null,2);V[y.Accept]=this._getExistingOrDefaultHeader(V,y.Accept,C0.ApplicationJson),V[y.ContentType]=this._getExistingOrDefaultHeader(V,y.ContentType,C0.ApplicationJson);const J=yield this.patch($,X,V);return this._processResponse(J,this.requestOptions)})}request($,Q,V,X){return x(this,void 0,void 0,function*(){if(this._disposed)throw new Error("Client has already been disposed.");const J=new URL(Q);let Z=this._prepareRequest($,J,X);const K=this._allowRetries&&PQ.includes($)?this._maxRetries+1:1;let G=0,Y;do{if(Y=yield this.requestRaw(Z,V),Y&&Y.message&&Y.message.statusCode===e.Unauthorized){let z;for(let q of this.handlers)if(q.canHandleAuthentication(Y)){z=q;break}if(z)return z.handleAuthentication(this,Z,V);else return Y}let W=this._maxRedirects;while(Y.message.statusCode&&AQ.includes(Y.message.statusCode)&&this._allowRedirects&&W>0){const z=Y.message.headers.location;if(!z)break;const q=new URL(z);if(J.protocol==="https:"&&J.protocol!==q.protocol&&!this._allowRedirectDowngrade)throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");if(yield Y.readBody(),q.hostname!==J.hostname){for(let L in X)if(L.toLowerCase()==="authorization")delete X[L]}Z=this._prepareRequest($,q,X),Y=yield this.requestRaw(Z,V),W--}if(!Y.message.statusCode||!IQ.includes(Y.message.statusCode))return Y;if(G+=1,G{function J(Z,K){if(Z)X(Z);else if(!K)X(new Error("Unknown error"));else V(K)}this.requestRawWithCallback($,Q,J)})})}requestRawWithCallback($,Q,V){if(typeof Q==="string"){if(!$.options.headers)$.options.headers={};$.options.headers["Content-Length"]=Buffer.byteLength(Q,"utf8")}let X=!1;function J(G,Y){if(!X)X=!0,V(G,Y)}const Z=$.httpModule.request($.options,(G)=>{const Y=new K1(G);J(void 0,Y)});let K;if(Z.on("socket",(G)=>{K=G}),Z.setTimeout(this._socketTimeout||180000,()=>{if(K)K.end();J(new Error(`Request timeout: ${$.options.path}`))}),Z.on("error",function(G){J(G)}),Q&&typeof Q==="string")Z.write(Q,"utf8");if(Q&&typeof Q!=="string")Q.on("close",function(){Z.end()}),Q.pipe(Z);else Z.end()}getAgent($){const Q=new URL($);return this._getAgent(Q)}_prepareRequest($,Q,V){const X={};X.parsedUrl=Q;const J=X.parsedUrl.protocol==="https:";X.httpModule=J?Z1:$5;const Z=J?443:80;if(X.options={},X.options.host=X.parsedUrl.hostname,X.options.port=X.parsedUrl.port?parseInt(X.parsedUrl.port):Z,X.options.path=(X.parsedUrl.pathname||"")+(X.parsedUrl.search||""),X.options.method=$,X.options.headers=this._mergeHeaders(V),this.userAgent!=null)X.options.headers["user-agent"]=this.userAgent;if(X.options.agent=this._getAgent(X.parsedUrl),this.handlers)for(let K of this.handlers)K.prepareRequest(X.options);return X}_mergeHeaders($){if(this.requestOptions&&this.requestOptions.headers)return Object.assign({},V5(this.requestOptions.headers),V5($||{}));return V5($||{})}_getExistingOrDefaultHeader($,Q,V){let X;if(this.requestOptions&&this.requestOptions.headers)X=V5(this.requestOptions.headers)[Q];return $[Q]||X||V}_getAgent($){let Q;const V=l9.getProxyUrl($),X=V&&V.hostname;if(this._keepAlive&&X)Q=this._proxyAgent;if(this._keepAlive&&!X)Q=this._agent;if(Q)return Q;const J=$.protocol==="https:";let Z=100;if(this.requestOptions)Z=this.requestOptions.maxSockets||$5.globalAgent.maxSockets;if(V&&V.hostname){const K={maxSockets:Z,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(V.username||V.password)&&{proxyAuth:`${V.username}:${V.password}`}),{host:V.hostname,port:V.port})};let G;const Y=V.protocol==="https:";if(J)G=Y?Q5.httpsOverHttps:Q5.httpsOverHttp;else G=Y?Q5.httpOverHttps:Q5.httpOverHttp;Q=G(K),this._proxyAgent=Q}if(this._keepAlive&&!Q){const K={keepAlive:this._keepAlive,maxSockets:Z};Q=J?new Z1.Agent(K):new $5.Agent(K),this._agent=Q}if(!Q)Q=J?Z1.globalAgent:$5.globalAgent;if(J&&this._ignoreSslError)Q.options=Object.assign(Q.options||{},{rejectUnauthorized:!1});return Q}_performExponentialBackoff($){return x(this,void 0,void 0,function*(){$=Math.min(FQ,$);const Q=vQ*Math.pow(2,$);return new Promise((V)=>setTimeout(()=>V(),Q))})}_processResponse($,Q){return x(this,void 0,void 0,function*(){return new Promise((V,X)=>x(this,void 0,void 0,function*(){const J=$.message.statusCode||0,Z={statusCode:J,result:null,headers:{}};if(J===e.NotFound)V(Z);function K(W,z){if(typeof z==="string"){const q=new Date(z);if(!isNaN(q.valueOf()))return q}return z}let G,Y;try{if(Y=yield $.readBody(),Y&&Y.length>0){if(Q&&Q.deserializeDates)G=JSON.parse(Y,K);else G=JSON.parse(Y);Z.result=G}Z.headers=$.message.headers}catch(W){}if(J>299){let W;if(G&&G.message)W=G.message;else if(Y&&Y.length>0)W=Y;else W=`Failed request: (${J})`;const z=new J5(W,J);z.result=Z.result,X(z)}else V(Z)}))})}}P.HttpClient=d9;var V5=($)=>Object.keys($).reduce((Q,V)=>(Q[V.toLowerCase()]=$[V],Q),{})});var s9=F((Z0)=>{var G1=Z0&&Z0.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(Z0,"__esModule",{value:!0});Z0.PersonalAccessTokenCredentialHandler=Z0.BearerCredentialHandler=Z0.BasicCredentialHandler=void 0;class p9{constructor($,Q){this.username=$,this.password=Q}prepareRequest($){if(!$.headers)throw Error("The request has no headers");$.headers.Authorization=`Basic ${Buffer.from(`${this.username}:${this.password}`).toString("base64")}`}canHandleAuthentication(){return!1}handleAuthentication(){return G1(this,void 0,void 0,function*(){throw new Error("not implemented")})}}Z0.BasicCredentialHandler=p9;class a9{constructor($){this.token=$}prepareRequest($){if(!$.headers)throw Error("The request has no headers");$.headers.Authorization=`Bearer ${this.token}`}canHandleAuthentication(){return!1}handleAuthentication(){return G1(this,void 0,void 0,function*(){throw new Error("not implemented")})}}Z0.BearerCredentialHandler=a9;class n9{constructor($){this.token=$}prepareRequest($){if(!$.headers)throw Error("The request has no headers");$.headers.Authorization=`Basic ${Buffer.from(`PAT:${this.token}`).toString("base64")}`}canHandleAuthentication(){return!1}handleAuthentication(){return G1(this,void 0,void 0,function*(){throw new Error("not implemented")})}}Z0.PersonalAccessTokenCredentialHandler=n9});var t9=F((K$)=>{var r9=K$&&K$.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(K$,"__esModule",{value:!0});K$.OidcClient=void 0;var xQ=i9(),OQ=s9(),o9=Y1();class Z${static createHttpClient($=!0,Q=10){const V={allowRetries:$,maxRetries:Q};return new xQ.HttpClient("actions/oidc-client",[new OQ.BearerCredentialHandler(Z$.getRequestToken())],V)}static getRequestToken(){const $=process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(!$)throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable");return $}static getIDTokenUrl(){const $=process.env.ACTIONS_ID_TOKEN_REQUEST_URL;if(!$)throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable");return $}static getCall($){var Q;return r9(this,void 0,void 0,function*(){const J=(Q=(yield Z$.createHttpClient().getJson($).catch((Z)=>{throw new Error(`Failed to get ID Token. \n +import{createRequire as j4}from"node:module";var O4=Object.create;var{getPrototypeOf:U4,defineProperty:g$,getOwnPropertyNames:x4}=Object;var T4=Object.prototype.hasOwnProperty;var C4=($,Q,V)=>{V=$!=null?O4(U4($)):{};const X=Q||!$||!$.__esModule?g$(V,"default",{value:$,enumerable:!0}):V;for(let J of x4($))if(!T4.call(X,J))g$(X,J,{get:()=>$[J],enumerable:!0});return X};var H=($,Q)=>()=>(Q||$((Q={exports:{}}).exports,Q),Q.exports);var j=j4(import.meta.url);var t5=H((k$)=>{function D4($){if($===null||$===void 0)return"";else if(typeof $==="string"||$ instanceof String)return $;return JSON.stringify($)}function N4($){if(!Object.keys($).length)return{};return{title:$.title,file:$.file,line:$.startLine,endLine:$.endLine,col:$.startColumn,endColumn:$.endColumn}}Object.defineProperty(k$,"__esModule",{value:!0});k$.toCommandProperties=k$.toCommandValue=void 0;k$.toCommandValue=D4;k$.toCommandProperties=N4});var u$=H((d)=>{function m$($,Q,V){const X=new h$($,Q,V);process.stdout.write(X.toString()+k4.EOL)}function y4($,Q=""){m$($,{},Q)}function E4($){return b$.toCommandValue($).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function b4($){return b$.toCommandValue($).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}var _4=d&&d.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),R4=d&&d.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),g4=d&&d.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))_4(Q,$,V)}return R4(Q,$),Q};Object.defineProperty(d,"__esModule",{value:!0});d.issue=d.issueCommand=void 0;var k4=g4(j("os")),b$=t5();d.issueCommand=m$;d.issue=y4;var E$="::";class h${constructor($,Q,V){if(!$)$="missing.command";this.command=$,this.properties=Q,this.message=V}toString(){let $=E$+this.command;if(this.properties&&Object.keys(this.properties).length>0){$+=" ";let Q=!0;for(let V in this.properties)if(this.properties.hasOwnProperty(V)){const X=this.properties[V];if(X){if(Q)Q=!1;else $+=",";$+=`${V}=${b4(X)}`}}}return $+=`${E$}${E4(this.message)}`,$}}});var s8=H((f$)=>{function h4($){return $&&$.__esModule?$:{default:$}}function u4(){if(e5>$8.length-16)m4.default.randomFillSync($8),e5=0;return $8.slice(e5,e5+=16)}Object.defineProperty(f$,"__esModule",{value:!0});f$.default=u4;var m4=h4(j("crypto")),$8=new Uint8Array(256),e5=$8.length});var d$=H((c$)=>{Object.defineProperty(c$,"__esModule",{value:!0});c$.default=void 0;var c4=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;c$.default=c4});var U5=H((i$)=>{function d4($){return $&&$.__esModule?$:{default:$}}function i4($){return typeof $==="string"&&l4.default.test($)}Object.defineProperty(i$,"__esModule",{value:!0});i$.default=void 0;var l4=d4(d$()),p4=i4;i$.default=p4});var x5=H((a$)=>{function n4($){return $&&$.__esModule?$:{default:$}}function s4($,Q=0){const V=(g[$[Q+0]]+g[$[Q+1]]+g[$[Q+2]]+g[$[Q+3]]+"-"+g[$[Q+4]]+g[$[Q+5]]+"-"+g[$[Q+6]]+g[$[Q+7]]+"-"+g[$[Q+8]]+g[$[Q+9]]+"-"+g[$[Q+10]]+g[$[Q+11]]+g[$[Q+12]]+g[$[Q+13]]+g[$[Q+14]]+g[$[Q+15]]).toLowerCase();if(!a4.default(V))throw TypeError("Stringified UUID is invalid");return V}Object.defineProperty(a$,"__esModule",{value:!0});a$.default=void 0;var a4=n4(U5()),g=[];for(let $=0;$<256;++$)g.push(($+256).toString(16).substr(1));var o4=s4;a$.default=o4});var e$=H((r$)=>{function o$($){return $&&$.__esModule?$:{default:$}}function e4($,Q,V){let X=Q&&V||0;const J=Q||new Array(16);$=$||{};let Z=$.node||s$,K=$.clockseq!==void 0?$.clockseq:o8;if(Z==null||K==null){const M=$.random||($.rng||r4.default)();if(Z==null)Z=s$=[M[0]|1,M[1],M[2],M[3],M[4],M[5]];if(K==null)K=o8=(M[6]<<8|M[7])&16383}let G=$.msecs!==void 0?$.msecs:Date.now(),Y=$.nsecs!==void 0?$.nsecs:t8+1;const W=G-r8+(Y-t8)/1e4;if(W<0&&$.clockseq===void 0)K=K+1&16383;if((W<0||G>r8)&&$.nsecs===void 0)Y=0;if(Y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");r8=G,t8=Y,o8=K,G+=12219292800000;const z=((G&268435455)*1e4+Y)%4294967296;J[X++]=z>>>24&255,J[X++]=z>>>16&255,J[X++]=z>>>8&255,J[X++]=z&255;const q=G/4294967296*1e4&268435455;J[X++]=q>>>8&255,J[X++]=q&255,J[X++]=q>>>24&15|16,J[X++]=q>>>16&255,J[X++]=K>>>8|128,J[X++]=K&255;for(let M=0;M<6;++M)J[X+M]=Z[M];return Q||t4.default(J)}Object.defineProperty(r$,"__esModule",{value:!0});r$.default=void 0;var r4=o$(s8()),t4=o$(x5()),s$,o8,r8=0,t8=0,$6=e4;r$.default=$6});var e8=H(($7)=>{function V6($){return $&&$.__esModule?$:{default:$}}function X6($){if(!Q6.default($))throw TypeError("Invalid UUID");let Q;const V=new Uint8Array(16);return V[0]=(Q=parseInt($.slice(0,8),16))>>>24,V[1]=Q>>>16&255,V[2]=Q>>>8&255,V[3]=Q&255,V[4]=(Q=parseInt($.slice(9,13),16))>>>8,V[5]=Q&255,V[6]=(Q=parseInt($.slice(14,18),16))>>>8,V[7]=Q&255,V[8]=(Q=parseInt($.slice(19,23),16))>>>8,V[9]=Q&255,V[10]=(Q=parseInt($.slice(24,36),16))/1099511627776&255,V[11]=Q/4294967296&255,V[12]=Q>>>24&255,V[13]=Q>>>16&255,V[14]=Q>>>8&255,V[15]=Q&255,V}Object.defineProperty($7,"__esModule",{value:!0});$7.default=void 0;var Q6=V6(U5()),J6=X6;$7.default=J6});var $9=H((Z7)=>{function V7($){return $&&$.__esModule?$:{default:$}}function G6($){$=unescape(encodeURIComponent($));const Q=[];for(let V=0;V<$.length;++V)Q.push($.charCodeAt(V));return Q}function Y6($,Q,V){function X(J,Z,K,G){if(typeof J==="string")J=G6(J);if(typeof Z==="string")Z=K6.default(Z);if(Z.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let Y=new Uint8Array(16+J.length);if(Y.set(Z),Y.set(J,Z.length),Y=V(Y),Y[6]=Y[6]&15|Q,Y[8]=Y[8]&63|128,K){G=G||0;for(let W=0;W<16;++W)K[G+W]=Y[W];return K}return Z6.default(Y)}try{X.name=$}catch(J){}return X.DNS=X7,X.URL=J7,X}Object.defineProperty(Z7,"__esModule",{value:!0});Z7.default=Y6;Z7.URL=Z7.DNS=void 0;var Z6=V7(x5()),K6=V7(e8()),X7="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Z7.DNS=X7;var J7="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Z7.URL=J7});var z7=H((G7)=>{function B6($){return $&&$.__esModule?$:{default:$}}function L6($){if(Array.isArray($))$=Buffer.from($);else if(typeof $==="string")$=Buffer.from($,"utf8");return q6.default.createHash("md5").update($).digest()}Object.defineProperty(G7,"__esModule",{value:!0});G7.default=void 0;var q6=B6(j("crypto")),M6=L6;G7.default=M6});var L7=H((q7)=>{function W7($){return $&&$.__esModule?$:{default:$}}Object.defineProperty(q7,"__esModule",{value:!0});q7.default=void 0;var A6=W7($9()),I6=W7(z7()),w6=A6.default("v3",48,I6.default),F6=w6;q7.default=F6});var w7=H((A7)=>{function M7($){return $&&$.__esModule?$:{default:$}}function v6($,Q,V){$=$||{};const X=$.random||($.rng||H6.default)();if(X[6]=X[6]&15|64,X[8]=X[8]&63|128,Q){V=V||0;for(let J=0;J<16;++J)Q[V+J]=X[J];return Q}return P6.default(X)}Object.defineProperty(A7,"__esModule",{value:!0});A7.default=void 0;var H6=M7(s8()),P6=M7(x5()),O6=v6;A7.default=O6});var P7=H((F7)=>{function x6($){return $&&$.__esModule?$:{default:$}}function T6($){if(Array.isArray($))$=Buffer.from($);else if(typeof $==="string")$=Buffer.from($,"utf8");return U6.default.createHash("sha1").update($).digest()}Object.defineProperty(F7,"__esModule",{value:!0});F7.default=void 0;var U6=x6(j("crypto")),C6=T6;F7.default=C6});var x7=H((O7)=>{function v7($){return $&&$.__esModule?$:{default:$}}Object.defineProperty(O7,"__esModule",{value:!0});O7.default=void 0;var j6=v7($9()),D6=v7(P7()),N6=j6.default("v5",80,D6.default),S6=N6;O7.default=S6});var j7=H((T7)=>{Object.defineProperty(T7,"__esModule",{value:!0});T7.default=void 0;var _6="00000000-0000-0000-0000-000000000000";T7.default=_6});var S7=H((D7)=>{function g6($){return $&&$.__esModule?$:{default:$}}function k6($){if(!R6.default($))throw TypeError("Invalid UUID");return parseInt($.substr(14,1),16)}Object.defineProperty(D7,"__esModule",{value:!0});D7.default=void 0;var R6=g6(U5()),y6=k6;D7.default=y6});var _7=H((e)=>{function I0($){return $&&$.__esModule?$:{default:$}}Object.defineProperty(e,"__esModule",{value:!0});Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return E6.default}});Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return b6.default}});Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return m6.default}});Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return h6.default}});Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return u6.default}});Object.defineProperty(e,"version",{enumerable:!0,get:function(){return f6.default}});Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return c6.default}});Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return l6.default}});Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return d6.default}});var E6=I0(e$()),b6=I0(L7()),m6=I0(w7()),h6=I0(x7()),u6=I0(j7()),f6=I0(S7()),c6=I0(U5()),l6=I0(x5()),d6=I0(e8())});var y7=H((i)=>{function n6($,Q){const V=process.env[`GITHUB_${$}`];if(!V)throw new Error(`Unable to find environment variable for file command ${$}`);if(!R7.existsSync(V))throw new Error(`Missing file at path: ${V}`);R7.appendFileSync(V,`${k7.toCommandValue(Q)}${Q9.EOL}`,{encoding:"utf8"})}function s6($,Q){const V=`ghadelimiter_${a6.v4()}`,X=k7.toCommandValue(Q);if($.includes(V))throw new Error(`Unexpected input: name should not contain the delimiter "${V}"`);if(X.includes(V))throw new Error(`Unexpected input: value should not contain the delimiter "${V}"`);return`${$}<<${V}${Q9.EOL}${X}${Q9.EOL}${V}`}var i6=i&&i.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),p6=i&&i.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),g7=i&&i.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))i6(Q,$,V)}return p6(Q,$),Q};Object.defineProperty(i,"__esModule",{value:!0});i.prepareKeyValueMessage=i.issueFileCommand=void 0;var R7=g7(j("fs")),Q9=g7(j("os")),a6=_7(),k7=t5();i.issueFileCommand=n6;i.prepareKeyValueMessage=s6});var h7=H((b7)=>{function o6($){const Q=$.protocol==="https:";if(E7($))return;const V=(()=>{if(Q)return process.env.https_proxy||process.env.HTTPS_PROXY;else return process.env.http_proxy||process.env.HTTP_PROXY})();if(V)try{return new URL(V)}catch(X){if(!V.startsWith("http://")&&!V.startsWith("https://"))return new URL(`http://${V}`)}else return}function E7($){if(!$.hostname)return!1;const Q=$.hostname;if(r6(Q))return!0;const V=process.env.no_proxy||process.env.NO_PROXY||"";if(!V)return!1;let X;if($.port)X=Number($.port);else if($.protocol==="http:")X=80;else if($.protocol==="https:")X=443;const J=[$.hostname.toUpperCase()];if(typeof X==="number")J.push(`${J[0]}:${X}`);for(let Z of V.split(",").map((K)=>K.trim().toUpperCase()).filter((K)=>K))if(Z==="*"||J.some((K)=>K===Z||K.endsWith(`.${Z}`)||Z.startsWith(".")&&K.endsWith(`${Z}`)))return!0;return!1}function r6($){const Q=$.toLowerCase();return Q==="localhost"||Q.startsWith("127.")||Q.startsWith("[::1]")||Q.startsWith("[0:0:0:0:0:0:0:1]")}Object.defineProperty(b7,"__esModule",{value:!0});b7.checkBypass=b7.getProxyUrl=void 0;b7.getProxyUrl=o6;b7.checkBypass=E7});var l7=H((KQ)=>{function VQ($){var Q=new w0($);return Q.request=V9.request,Q}function XQ($){var Q=new w0($);return Q.request=V9.request,Q.createSocket=f7,Q.defaultPort=443,Q}function JQ($){var Q=new w0($);return Q.request=u7.request,Q}function ZQ($){var Q=new w0($);return Q.request=u7.request,Q.createSocket=f7,Q.defaultPort=443,Q}function w0($){var Q=this;Q.options=$||{},Q.proxyOptions=Q.options.proxy||{},Q.maxSockets=Q.options.maxSockets||V9.Agent.defaultMaxSockets,Q.requests=[],Q.sockets=[],Q.on("free",function V(X,J,Z,K){var G=c7(J,Z,K);for(var Y=0,W=Q.requests.length;Y=this.maxSockets){Z.requests.push(K);return}Z.createSocket(K,function(G){G.on("free",Y),G.on("close",W),G.on("agentRemove",W),Q.onSocket(G);function Y(){Z.emit("free",G,K)}function W(z){Z.removeSocket(G),G.removeListener("free",Y),G.removeListener("close",W),G.removeListener("agentRemove",W)}})};w0.prototype.createSocket=function $(Q,V){var X=this,J={};X.sockets.push(J);var Z=X9({},X.proxyOptions,{method:"CONNECT",path:Q.host+":"+Q.port,agent:!1,headers:{host:Q.host+":"+Q.port}});if(Q.localAddress)Z.localAddress=Q.localAddress;if(Z.proxyAuth)Z.headers=Z.headers||{},Z.headers["Proxy-Authorization"]="Basic "+new Buffer(Z.proxyAuth).toString("base64");j0("making CONNECT request");var K=X.request(Z);K.useChunkedEncodingByDefault=!1,K.once("response",G),K.once("upgrade",Y),K.once("connect",W),K.once("error",z),K.end();function G(q){q.upgrade=!0}function Y(q,M,O){process.nextTick(function(){W(q,M,O)})}function W(q,M,O){if(K.removeAllListeners(),M.removeAllListeners(),q.statusCode!==200){j0("tunneling socket could not be established, statusCode=%d",q.statusCode),M.destroy();var U=new Error("tunneling socket could not be established, statusCode="+q.statusCode);U.code="ECONNRESET",Q.request.emit("error",U),X.removeSocket(J);return}if(O.length>0){j0("got illegal response body from proxy"),M.destroy();var U=new Error("got illegal response body from proxy");U.code="ECONNRESET",Q.request.emit("error",U),X.removeSocket(J);return}return j0("tunneling connection has established"),X.sockets[X.sockets.indexOf(J)]=M,V(M)}function z(q){K.removeAllListeners(),j0("tunneling socket could not be established, cause=%s\n",q.message,q.stack);var M=new Error("tunneling socket could not be established, cause="+q.message);M.code="ECONNRESET",Q.request.emit("error",M),X.removeSocket(J)}};w0.prototype.removeSocket=function $(Q){var V=this.sockets.indexOf(Q);if(V===-1)return;this.sockets.splice(V,1);var X=this.requests.shift();if(X)this.createSocket(X,function(J){X.request.onSocket(J)})};var j0;if(process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG))j0=function(){var $=Array.prototype.slice.call(arguments);if(typeof $[0]==="string")$[0]="TUNNEL: "+$[0];else $.unshift("TUNNEL:");console.error.apply(console,$)};else j0=function(){};KQ.debug=j0});var p7=H((F)=>{function MQ($){const Q=d7.getProxyUrl(new URL($));return Q?Q.href:""}function PQ($){return new URL($).protocol==="https:"}var BQ=F&&F.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),LQ=F&&F.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),J8=F&&F.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))BQ(Q,$,V)}return LQ(Q,$),Q},T=F&&F.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(F,"__esModule",{value:!0});F.HttpClient=F.isHttps=F.HttpClientResponse=F.HttpClientError=F.getProxyUrl=F.MediaTypes=F.Headers=F.HttpCodes=void 0;var Q8=J8(j("http")),J9=J8(j("https")),d7=J8(h7()),V8=J8(l7()),$0;(function($){$[$.OK=200]="OK",$[$.MultipleChoices=300]="MultipleChoices",$[$.MovedPermanently=301]="MovedPermanently",$[$.ResourceMoved=302]="ResourceMoved",$[$.SeeOther=303]="SeeOther",$[$.NotModified=304]="NotModified",$[$.UseProxy=305]="UseProxy",$[$.SwitchProxy=306]="SwitchProxy",$[$.TemporaryRedirect=307]="TemporaryRedirect",$[$.PermanentRedirect=308]="PermanentRedirect",$[$.BadRequest=400]="BadRequest",$[$.Unauthorized=401]="Unauthorized",$[$.PaymentRequired=402]="PaymentRequired",$[$.Forbidden=403]="Forbidden",$[$.NotFound=404]="NotFound",$[$.MethodNotAllowed=405]="MethodNotAllowed",$[$.NotAcceptable=406]="NotAcceptable",$[$.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",$[$.RequestTimeout=408]="RequestTimeout",$[$.Conflict=409]="Conflict",$[$.Gone=410]="Gone",$[$.TooManyRequests=429]="TooManyRequests",$[$.InternalServerError=500]="InternalServerError",$[$.NotImplemented=501]="NotImplemented",$[$.BadGateway=502]="BadGateway",$[$.ServiceUnavailable=503]="ServiceUnavailable",$[$.GatewayTimeout=504]="GatewayTimeout"})($0=F.HttpCodes||(F.HttpCodes={}));var E;(function($){$.Accept="accept",$.ContentType="content-type"})(E=F.Headers||(F.Headers={}));var D0;(function($){$.ApplicationJson="application/json"})(D0=F.MediaTypes||(F.MediaTypes={}));F.getProxyUrl=MQ;var AQ=[$0.MovedPermanently,$0.ResourceMoved,$0.SeeOther,$0.TemporaryRedirect,$0.PermanentRedirect],IQ=[$0.BadGateway,$0.ServiceUnavailable,$0.GatewayTimeout],wQ=["OPTIONS","GET","DELETE","HEAD"],FQ=10,HQ=5;class Z8 extends Error{constructor($,Q){super($);this.name="HttpClientError",this.statusCode=Q,Object.setPrototypeOf(this,Z8.prototype)}}F.HttpClientError=Z8;class Z9{constructor($){this.message=$}readBody(){return T(this,void 0,void 0,function*(){return new Promise(($)=>T(this,void 0,void 0,function*(){let Q=Buffer.alloc(0);this.message.on("data",(V)=>{Q=Buffer.concat([Q,V])}),this.message.on("end",()=>{$(Q.toString())})}))})}readBodyBuffer(){return T(this,void 0,void 0,function*(){return new Promise(($)=>T(this,void 0,void 0,function*(){const Q=[];this.message.on("data",(V)=>{Q.push(V)}),this.message.on("end",()=>{$(Buffer.concat(Q))})}))})}}F.HttpClientResponse=Z9;F.isHttps=PQ;class i7{constructor($,Q,V){if(this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=$,this.handlers=Q||[],this.requestOptions=V,V){if(V.ignoreSslError!=null)this._ignoreSslError=V.ignoreSslError;if(this._socketTimeout=V.socketTimeout,V.allowRedirects!=null)this._allowRedirects=V.allowRedirects;if(V.allowRedirectDowngrade!=null)this._allowRedirectDowngrade=V.allowRedirectDowngrade;if(V.maxRedirects!=null)this._maxRedirects=Math.max(V.maxRedirects,0);if(V.keepAlive!=null)this._keepAlive=V.keepAlive;if(V.allowRetries!=null)this._allowRetries=V.allowRetries;if(V.maxRetries!=null)this._maxRetries=V.maxRetries}}options($,Q){return T(this,void 0,void 0,function*(){return this.request("OPTIONS",$,null,Q||{})})}get($,Q){return T(this,void 0,void 0,function*(){return this.request("GET",$,null,Q||{})})}del($,Q){return T(this,void 0,void 0,function*(){return this.request("DELETE",$,null,Q||{})})}post($,Q,V){return T(this,void 0,void 0,function*(){return this.request("POST",$,Q,V||{})})}patch($,Q,V){return T(this,void 0,void 0,function*(){return this.request("PATCH",$,Q,V||{})})}put($,Q,V){return T(this,void 0,void 0,function*(){return this.request("PUT",$,Q,V||{})})}head($,Q){return T(this,void 0,void 0,function*(){return this.request("HEAD",$,null,Q||{})})}sendStream($,Q,V,X){return T(this,void 0,void 0,function*(){return this.request($,Q,V,X)})}getJson($,Q={}){return T(this,void 0,void 0,function*(){Q[E.Accept]=this._getExistingOrDefaultHeader(Q,E.Accept,D0.ApplicationJson);const V=yield this.get($,Q);return this._processResponse(V,this.requestOptions)})}postJson($,Q,V={}){return T(this,void 0,void 0,function*(){const X=JSON.stringify(Q,null,2);V[E.Accept]=this._getExistingOrDefaultHeader(V,E.Accept,D0.ApplicationJson),V[E.ContentType]=this._getExistingOrDefaultHeader(V,E.ContentType,D0.ApplicationJson);const J=yield this.post($,X,V);return this._processResponse(J,this.requestOptions)})}putJson($,Q,V={}){return T(this,void 0,void 0,function*(){const X=JSON.stringify(Q,null,2);V[E.Accept]=this._getExistingOrDefaultHeader(V,E.Accept,D0.ApplicationJson),V[E.ContentType]=this._getExistingOrDefaultHeader(V,E.ContentType,D0.ApplicationJson);const J=yield this.put($,X,V);return this._processResponse(J,this.requestOptions)})}patchJson($,Q,V={}){return T(this,void 0,void 0,function*(){const X=JSON.stringify(Q,null,2);V[E.Accept]=this._getExistingOrDefaultHeader(V,E.Accept,D0.ApplicationJson),V[E.ContentType]=this._getExistingOrDefaultHeader(V,E.ContentType,D0.ApplicationJson);const J=yield this.patch($,X,V);return this._processResponse(J,this.requestOptions)})}request($,Q,V,X){return T(this,void 0,void 0,function*(){if(this._disposed)throw new Error("Client has already been disposed.");const J=new URL(Q);let Z=this._prepareRequest($,J,X);const K=this._allowRetries&&wQ.includes($)?this._maxRetries+1:1;let G=0,Y;do{if(Y=yield this.requestRaw(Z,V),Y&&Y.message&&Y.message.statusCode===$0.Unauthorized){let z;for(let q of this.handlers)if(q.canHandleAuthentication(Y)){z=q;break}if(z)return z.handleAuthentication(this,Z,V);else return Y}let W=this._maxRedirects;while(Y.message.statusCode&&AQ.includes(Y.message.statusCode)&&this._allowRedirects&&W>0){const z=Y.message.headers.location;if(!z)break;const q=new URL(z);if(J.protocol==="https:"&&J.protocol!==q.protocol&&!this._allowRedirectDowngrade)throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");if(yield Y.readBody(),q.hostname!==J.hostname){for(let M in X)if(M.toLowerCase()==="authorization")delete X[M]}Z=this._prepareRequest($,q,X),Y=yield this.requestRaw(Z,V),W--}if(!Y.message.statusCode||!IQ.includes(Y.message.statusCode))return Y;if(G+=1,G{function J(Z,K){if(Z)X(Z);else if(!K)X(new Error("Unknown error"));else V(K)}this.requestRawWithCallback($,Q,J)})})}requestRawWithCallback($,Q,V){if(typeof Q==="string"){if(!$.options.headers)$.options.headers={};$.options.headers["Content-Length"]=Buffer.byteLength(Q,"utf8")}let X=!1;function J(G,Y){if(!X)X=!0,V(G,Y)}const Z=$.httpModule.request($.options,(G)=>{const Y=new Z9(G);J(void 0,Y)});let K;if(Z.on("socket",(G)=>{K=G}),Z.setTimeout(this._socketTimeout||180000,()=>{if(K)K.end();J(new Error(`Request timeout: ${$.options.path}`))}),Z.on("error",function(G){J(G)}),Q&&typeof Q==="string")Z.write(Q,"utf8");if(Q&&typeof Q!=="string")Q.on("close",function(){Z.end()}),Q.pipe(Z);else Z.end()}getAgent($){const Q=new URL($);return this._getAgent(Q)}_prepareRequest($,Q,V){const X={};X.parsedUrl=Q;const J=X.parsedUrl.protocol==="https:";X.httpModule=J?J9:Q8;const Z=J?443:80;if(X.options={},X.options.host=X.parsedUrl.hostname,X.options.port=X.parsedUrl.port?parseInt(X.parsedUrl.port):Z,X.options.path=(X.parsedUrl.pathname||"")+(X.parsedUrl.search||""),X.options.method=$,X.options.headers=this._mergeHeaders(V),this.userAgent!=null)X.options.headers["user-agent"]=this.userAgent;if(X.options.agent=this._getAgent(X.parsedUrl),this.handlers)for(let K of this.handlers)K.prepareRequest(X.options);return X}_mergeHeaders($){if(this.requestOptions&&this.requestOptions.headers)return Object.assign({},X8(this.requestOptions.headers),X8($||{}));return X8($||{})}_getExistingOrDefaultHeader($,Q,V){let X;if(this.requestOptions&&this.requestOptions.headers)X=X8(this.requestOptions.headers)[Q];return $[Q]||X||V}_getAgent($){let Q;const V=d7.getProxyUrl($),X=V&&V.hostname;if(this._keepAlive&&X)Q=this._proxyAgent;if(this._keepAlive&&!X)Q=this._agent;if(Q)return Q;const J=$.protocol==="https:";let Z=100;if(this.requestOptions)Z=this.requestOptions.maxSockets||Q8.globalAgent.maxSockets;if(V&&V.hostname){const K={maxSockets:Z,keepAlive:this._keepAlive,proxy:Object.assign(Object.assign({},(V.username||V.password)&&{proxyAuth:`${V.username}:${V.password}`}),{host:V.hostname,port:V.port})};let G;const Y=V.protocol==="https:";if(J)G=Y?V8.httpsOverHttps:V8.httpsOverHttp;else G=Y?V8.httpOverHttps:V8.httpOverHttp;Q=G(K),this._proxyAgent=Q}if(this._keepAlive&&!Q){const K={keepAlive:this._keepAlive,maxSockets:Z};Q=J?new J9.Agent(K):new Q8.Agent(K),this._agent=Q}if(!Q)Q=J?J9.globalAgent:Q8.globalAgent;if(J&&this._ignoreSslError)Q.options=Object.assign(Q.options||{},{rejectUnauthorized:!1});return Q}_performExponentialBackoff($){return T(this,void 0,void 0,function*(){$=Math.min(FQ,$);const Q=HQ*Math.pow(2,$);return new Promise((V)=>setTimeout(()=>V(),Q))})}_processResponse($,Q){return T(this,void 0,void 0,function*(){return new Promise((V,X)=>T(this,void 0,void 0,function*(){const J=$.message.statusCode||0,Z={statusCode:J,result:null,headers:{}};if(J===$0.NotFound)V(Z);function K(W,z){if(typeof z==="string"){const q=new Date(z);if(!isNaN(q.valueOf()))return q}return z}let G,Y;try{if(Y=yield $.readBody(),Y&&Y.length>0){if(Q&&Q.deserializeDates)G=JSON.parse(Y,K);else G=JSON.parse(Y);Z.result=G}Z.headers=$.message.headers}catch(W){}if(J>299){let W;if(G&&G.message)W=G.message;else if(Y&&Y.length>0)W=Y;else W=`Failed request: (${J})`;const z=new Z8(W,J);z.result=Z.result,X(z)}else V(Z)}))})}}F.HttpClient=i7;var X8=($)=>Object.keys($).reduce((Q,V)=>(Q[V.toLowerCase()]=$[V],Q),{})});var o7=H((K0)=>{var K9=K0&&K0.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(K0,"__esModule",{value:!0});K0.PersonalAccessTokenCredentialHandler=K0.BearerCredentialHandler=K0.BasicCredentialHandler=void 0;class a7{constructor($,Q){this.username=$,this.password=Q}prepareRequest($){if(!$.headers)throw Error("The request has no headers");$.headers.Authorization=`Basic ${Buffer.from(`${this.username}:${this.password}`).toString("base64")}`}canHandleAuthentication(){return!1}handleAuthentication(){return K9(this,void 0,void 0,function*(){throw new Error("not implemented")})}}K0.BasicCredentialHandler=a7;class n7{constructor($){this.token=$}prepareRequest($){if(!$.headers)throw Error("The request has no headers");$.headers.Authorization=`Bearer ${this.token}`}canHandleAuthentication(){return!1}handleAuthentication(){return K9(this,void 0,void 0,function*(){throw new Error("not implemented")})}}K0.BearerCredentialHandler=n7;class s7{constructor($){this.token=$}prepareRequest($){if(!$.headers)throw Error("The request has no headers");$.headers.Authorization=`Basic ${Buffer.from(`PAT:${this.token}`).toString("base64")}`}canHandleAuthentication(){return!1}handleAuthentication(){return K9(this,void 0,void 0,function*(){throw new Error("not implemented")})}}K0.PersonalAccessTokenCredentialHandler=s7});var e7=H((K5)=>{var r7=K5&&K5.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(K5,"__esModule",{value:!0});K5.OidcClient=void 0;var vQ=p7(),OQ=o7(),t7=G9();class Z5{static createHttpClient($=!0,Q=10){const V={allowRetries:$,maxRetries:Q};return new vQ.HttpClient("actions/oidc-client",[new OQ.BearerCredentialHandler(Z5.getRequestToken())],V)}static getRequestToken(){const $=process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(!$)throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable");return $}static getIDTokenUrl(){const $=process.env.ACTIONS_ID_TOKEN_REQUEST_URL;if(!$)throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable");return $}static getCall($){var Q;return r7(this,void 0,void 0,function*(){const J=(Q=(yield Z5.createHttpClient().getJson($).catch((Z)=>{throw new Error(`Failed to get ID Token. \n Error Code : ${Z.statusCode}\n - Error Message: ${Z.message}`)})).result)===null||Q===void 0?void 0:Q.value;if(!J)throw new Error("Response json body do not have ID Token field");return J})}static getIDToken($){return r9(this,void 0,void 0,function*(){try{let Q=Z$.getIDTokenUrl();if($){const X=encodeURIComponent($);Q=`${Q}&audience=${X}`}o9.debug(`ID token url is ${Q}`);const V=yield Z$.getCall(Q);return o9.setSecret(V),V}catch(Q){throw new Error(`Error message: ${Q.message}`)}})}}K$.OidcClient=Z$});var q1=F((E)=>{var z1=E&&E.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(E,"__esModule",{value:!0});E.summary=E.markdownSummary=E.SUMMARY_DOCS_URL=E.SUMMARY_ENV_VAR=void 0;var UQ=U("os"),W1=U("fs"),{access:TQ,appendFile:jQ,writeFile:CQ}=W1.promises;E.SUMMARY_ENV_VAR="GITHUB_STEP_SUMMARY";E.SUMMARY_DOCS_URL="https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";class e9{constructor(){this._buffer=""}filePath(){return z1(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;const $=process.env[E.SUMMARY_ENV_VAR];if(!$)throw new Error(`Unable to find environment variable for \$${E.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`);try{yield TQ($,W1.constants.R_OK|W1.constants.W_OK)}catch(Q){throw new Error(`Unable to access summary file: '${$}'. Check if the file has correct read/write permissions.`)}return this._filePath=$,this._filePath})}wrap($,Q,V={}){const X=Object.entries(V).map(([J,Z])=>` ${J}="${Z}"`).join("");if(!Q)return`<${$}${X}>`;return`<${$}${X}>${Q}`}write($){return z1(this,void 0,void 0,function*(){const Q=!!($===null||$===void 0?void 0:$.overwrite),V=yield this.filePath();return yield(Q?CQ:jQ)(V,this._buffer,{encoding:"utf8"}),this.emptyBuffer()})}clear(){return z1(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer="",this}addRaw($,Q=!1){return this._buffer+=$,Q?this.addEOL():this}addEOL(){return this.addRaw(UQ.EOL)}addCodeBlock($,Q){const V=Object.assign({},Q&&{lang:Q}),X=this.wrap("pre",this.wrap("code",$),V);return this.addRaw(X).addEOL()}addList($,Q=!1){const V=Q?"ol":"ul",X=$.map((Z)=>this.wrap("li",Z)).join(""),J=this.wrap(V,X);return this.addRaw(J).addEOL()}addTable($){const Q=$.map((X)=>{const J=X.map((Z)=>{if(typeof Z==="string")return this.wrap("td",Z);const{header:K,data:G,colspan:Y,rowspan:W}=Z,z=K?"th":"td",q=Object.assign(Object.assign({},Y&&{colspan:Y}),W&&{rowspan:W});return this.wrap(z,G,q)}).join("");return this.wrap("tr",J)}).join(""),V=this.wrap("table",Q);return this.addRaw(V).addEOL()}addDetails($,Q){const V=this.wrap("details",this.wrap("summary",$)+Q);return this.addRaw(V).addEOL()}addImage($,Q,V){const{width:X,height:J}=V||{},Z=Object.assign(Object.assign({},X&&{width:X}),J&&{height:J}),K=this.wrap("img",null,Object.assign({src:$,alt:Q},Z));return this.addRaw(K).addEOL()}addHeading($,Q){const V=`h${Q}`,X=["h1","h2","h3","h4","h5","h6"].includes(V)?V:"h1",J=this.wrap(X,$);return this.addRaw(J).addEOL()}addSeparator(){const $=this.wrap("hr",null);return this.addRaw($).addEOL()}addBreak(){const $=this.wrap("br",null);return this.addRaw($).addEOL()}addQuote($,Q){const V=Object.assign({},Q&&{cite:Q}),X=this.wrap("blockquote",$,V);return this.addRaw(X).addEOL()}addLink($,Q){const V=this.wrap("a",$,{href:Q});return this.addRaw(V).addEOL()}}var $7=new e9;E.markdownSummary=$7;E.summary=$7});var Q7=F((h)=>{function RQ($){return $.replace(/[\\]/g,"/")}function gQ($){return $.replace(/[/]/g,"\\")}function kQ($){return $.replace(/[/\\]/g,_Q.sep)}var DQ=h&&h.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),SQ=h&&h.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),NQ=h&&h.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))DQ(Q,$,V)}return SQ(Q,$),Q};Object.defineProperty(h,"__esModule",{value:!0});h.toPlatformPath=h.toWin32Path=h.toPosixPath=void 0;var _Q=NQ(U("path"));h.toPosixPath=RQ;h.toWin32Path=gQ;h.toPlatformPath=kQ});var Y1=F((B)=>{function hQ($,Q){const V=G$.toCommandValue(Q);if(process.env[$]=V,process.env.GITHUB_ENV||"")return l0.issueFileCommand("ENV",l0.prepareKeyValueMessage($,Q));p.issueCommand("set-env",{name:$},V)}function uQ($){p.issueCommand("add-mask",{},$)}function fQ($){if(process.env.GITHUB_PATH||"")l0.issueFileCommand("PATH",$);else p.issueCommand("add-path",{},$);process.env.PATH=`${$}${bQ.delimiter}${process.env.PATH}`}function B1($,Q){const V=process.env[`INPUT_${$.replace(/ /g,"_").toUpperCase()}`]||"";if(Q&&Q.required&&!V)throw new Error(`Input required and not supplied: ${$}`);if(Q&&Q.trimWhitespace===!1)return V;return V.trim()}function cQ($,Q){const V=B1($,Q).split("\n").filter((X)=>X!=="");if(Q&&Q.trimWhitespace===!1)return V;return V.map((X)=>X.trim())}function lQ($,Q){const V=["true","True","TRUE"],X=["false","False","FALSE"],J=B1($,Q);if(V.includes(J))return!0;if(X.includes(J))return!1;throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${$}\nSupport boolean input list: \`true | True | TRUE | false | False | FALSE\``)}function dQ($,Q){if(process.env.GITHUB_OUTPUT||"")return l0.issueFileCommand("OUTPUT",l0.prepareKeyValueMessage($,Q));process.stdout.write(J7.EOL),p.issueCommand("set-output",{name:$},G$.toCommandValue(Q))}function iQ($){p.issue("echo",$?"on":"off")}function pQ($){process.exitCode=Z7.Failure,K7($)}function aQ(){return process.env.RUNNER_DEBUG==="1"}function nQ($){p.issueCommand("debug",{},$)}function K7($,Q={}){p.issueCommand("error",G$.toCommandProperties(Q),$ instanceof Error?$.toString():$)}function sQ($,Q={}){p.issueCommand("warning",G$.toCommandProperties(Q),$ instanceof Error?$.toString():$)}function rQ($,Q={}){p.issueCommand("notice",G$.toCommandProperties(Q),$ instanceof Error?$.toString():$)}function oQ($){process.stdout.write($+J7.EOL)}function G7($){p.issue("group",$)}function Y7(){p.issue("endgroup")}function tQ($,Q){return X7(this,void 0,void 0,function*(){G7($);let V;try{V=yield Q()}finally{Y7()}return V})}function eQ($,Q){if(process.env.GITHUB_STATE||"")return l0.issueFileCommand("STATE",l0.prepareKeyValueMessage($,Q));p.issueCommand("save-state",{name:$},G$.toCommandValue(Q))}function $V($){return process.env[`STATE_${$}`]||""}function QV($){return X7(this,void 0,void 0,function*(){return yield EQ.OidcClient.getIDToken($)})}var yQ=B&&B.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),mQ=B&&B.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),V7=B&&B.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))yQ(Q,$,V)}return mQ(Q,$),Q},X7=B&&B.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(B,"__esModule",{value:!0});B.getIDToken=B.getState=B.saveState=B.group=B.endGroup=B.startGroup=B.info=B.notice=B.warning=B.error=B.debug=B.isDebug=B.setFailed=B.setCommandEcho=B.setOutput=B.getBooleanInput=B.getMultilineInput=B.getInput=B.addPath=B.setSecret=B.exportVariable=B.ExitCode=void 0;var p=h8(),l0=k9(),G$=o$(),J7=V7(U("os")),bQ=V7(U("path")),EQ=t9(),Z7;(function($){$[$.Success=0]="Success",$[$.Failure=1]="Failure"})(Z7=B.ExitCode||(B.ExitCode={}));B.exportVariable=hQ;B.setSecret=uQ;B.addPath=fQ;B.getInput=B1;B.getMultilineInput=cQ;B.getBooleanInput=lQ;B.setOutput=dQ;B.setCommandEcho=iQ;B.setFailed=pQ;B.isDebug=aQ;B.debug=nQ;B.error=K7;B.warning=sQ;B.notice=rQ;B.info=oQ;B.startGroup=G7;B.endGroup=Y7;B.group=tQ;B.saveState=eQ;B.getState=$V;B.getIDToken=QV;var VV=q1();Object.defineProperty(B,"summary",{enumerable:!0,get:function(){return VV.summary}});var XV=q1();Object.defineProperty(B,"markdownSummary",{enumerable:!0,get:function(){return XV.markdownSummary}});var L1=Q7();Object.defineProperty(B,"toPosixPath",{enumerable:!0,get:function(){return L1.toPosixPath}});Object.defineProperty(B,"toWin32Path",{enumerable:!0,get:function(){return L1.toWin32Path}});Object.defineProperty(B,"toPlatformPath",{enumerable:!0,get:function(){return L1.toPlatformPath}})});var F4=F((f3,tX)=>{tX.exports={name:"init-beatsaber",description:"A GitHub Action to initialize a Beat Saber modding environment",version:"1.6.4",author:"BeatForge",private:!0,type:"module",homepage:"https://github.com/beat-forge/init-beatsaber",repository:{type:"git",url:"git+https://github.com/beat-forge/init-beatsaber.git"},bugs:{url:"https://github.com/beat-forge/init-beatsaber/issues"},main:"dist/index.js",engines:{node:">=20"},scripts:{all:"bun run format:write && bun run package","package:node":"bun build --target=node ./src/index.ts --outfile=dist/index.js --minify","package:bun":"bun build --target=bun ./src/index.ts --outfile=dist/index.js --minify","format:write":"prettier --write \"**/*.{ts,tsx}\"",bundle:"bun run format:write && bun run package:node"},license:"AGPL-3.0",dependencies:{"@actions/core":"^1.10.1","@actions/github":"^5.1.1",tar:"^7.4.0"},devDependencies:{"@types/node":"^20.14.10","bun-types":"^1.1.20",prettier:"^3.3.3",typescript:"^5.5.3"}}});var w=C4(Y1(),1);import{promises as J$,createWriteStream as eX}from"fs";import{dirname as v4,join as s5,resolve as n5}from"path";import{pipeline as $J}from"stream";import MV from"events";import u from"fs";import{EventEmitter as F1}from"node:events";import L7 from"node:stream";import{StringDecoder as JV}from"node:string_decoder";var z7=typeof process==="object"&&process?process:{stdout:null,stderr:null},ZV=($)=>!!$&&typeof $==="object"&&($ instanceof c||$ instanceof L7||KV($)||GV($)),KV=($)=>!!$&&typeof $==="object"&&$ instanceof F1&&typeof $.pipe==="function"&&$.pipe!==L7.Writable.prototype.pipe,GV=($)=>!!$&&typeof $==="object"&&$ instanceof F1&&typeof $.write==="function"&&typeof $.end==="function",I0=Symbol("EOF"),P0=Symbol("maybeEmitEnd"),D0=Symbol("emittedEnd"),Z5=Symbol("emittingEnd"),U$=Symbol("emittedError"),K5=Symbol("closed"),W7=Symbol("read"),G5=Symbol("flush"),q7=Symbol("flushChunk"),$0=Symbol("encoding"),Y$=Symbol("decoder"),S=Symbol("flowing"),T$=Symbol("paused"),z$=Symbol("resume"),N=Symbol("buffer"),m=Symbol("pipes"),_=Symbol("bufferLength"),M1=Symbol("bufferPush"),Y5=Symbol("bufferShift"),g=Symbol("objectMode"),O=Symbol("destroyed"),w1=Symbol("error"),A1=Symbol("emitData"),B7=Symbol("emitEnd"),I1=Symbol("emitEnd2"),K0=Symbol("async"),P1=Symbol("abort"),z5=Symbol("aborted"),j$=Symbol("signal"),d0=Symbol("dataListeners"),f=Symbol("discarded"),C$=($)=>Promise.resolve().then($),YV=($)=>$(),zV=($)=>$==="end"||$==="finish"||$==="prefinish",WV=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,qV=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class v1{src;dest;opts;ondrain;constructor($,Q,V){this.src=$,this.dest=Q,this.opts=V,this.ondrain=()=>$[z$](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors($){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class M7 extends v1{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Q,V){super($,Q,V);this.proxyErrors=(X)=>Q.emit("error",X),$.on("error",this.proxyErrors)}}var BV=($)=>!!$.objectMode,LV=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class c extends F1{[S]=!1;[T$]=!1;[m]=[];[N]=[];[g];[$0];[K0];[Y$];[I0]=!1;[D0]=!1;[Z5]=!1;[K5]=!1;[U$]=null;[_]=0;[O]=!1;[j$];[z5]=!1;[d0]=0;[f]=!1;writable=!0;readable=!0;constructor(...$){const Q=$[0]||{};super();if(Q.objectMode&&typeof Q.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(BV(Q))this[g]=!0,this[$0]=null;else if(LV(Q))this[$0]=Q.encoding,this[g]=!1;else this[g]=!1,this[$0]=null;if(this[K0]=!!Q.async,this[Y$]=this[$0]?new JV(this[$0]):null,Q&&Q.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[N]});if(Q&&Q.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[m]});const{signal:V}=Q;if(V)if(this[j$]=V,V.aborted)this[P1]();else V.addEventListener("abort",()=>this[P1]())}get bufferLength(){return this[_]}get encoding(){return this[$0]}set encoding($){throw new Error("Encoding must be set at instantiation time")}setEncoding($){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[g]}set objectMode($){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[K0]}set["async"]($){this[K0]=this[K0]||!!$}[P1](){this[z5]=!0,this.emit("abort",this[j$]?.reason),this.destroy(this[j$]?.reason)}get aborted(){return this[z5]}set aborted($){}write($,Q,V){if(this[z5])return!1;if(this[I0])throw new Error("write after end");if(this[O])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Q==="function")V=Q,Q="utf8";if(!Q)Q="utf8";const X=this[K0]?C$:YV;if(!this[g]&&!Buffer.isBuffer($)){if(qV($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(WV($))$=Buffer.from($);else if(typeof $!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[g]){if(this[S]&&this[_]!==0)this[G5](!0);if(this[S])this.emit("data",$);else this[M1]($);if(this[_]!==0)this.emit("readable");if(V)X(V);return this[S]}if(!$.length){if(this[_]!==0)this.emit("readable");if(V)X(V);return this[S]}if(typeof $==="string"&&!(Q===this[$0]&&!this[Y$]?.lastNeed))$=Buffer.from($,Q);if(Buffer.isBuffer($)&&this[$0])$=this[Y$].write($);if(this[S]&&this[_]!==0)this[G5](!0);if(this[S])this.emit("data",$);else this[M1]($);if(this[_]!==0)this.emit("readable");if(V)X(V);return this[S]}read($){if(this[O])return null;if(this[f]=!1,this[_]===0||$===0||$&&$>this[_])return this[P0](),null;if(this[g])$=null;if(this[N].length>1&&!this[g])this[N]=[this[$0]?this[N].join(""):Buffer.concat(this[N],this[_])];const Q=this[W7]($||null,this[N][0]);return this[P0](),Q}[W7]($,Q){if(this[g])this[Y5]();else{const V=Q;if($===V.length||$===null)this[Y5]();else if(typeof V==="string")this[N][0]=V.slice($),Q=V.slice(0,$),this[_]-=$;else this[N][0]=V.subarray($),Q=V.subarray(0,$),this[_]-=$}if(this.emit("data",Q),!this[N].length&&!this[I0])this.emit("drain");return Q}end($,Q,V){if(typeof $==="function")V=$,$=void 0;if(typeof Q==="function")V=Q,Q="utf8";if($!==void 0)this.write($,Q);if(V)this.once("end",V);if(this[I0]=!0,this.writable=!1,this[S]||!this[T$])this[P0]();return this}[z$](){if(this[O])return;if(!this[d0]&&!this[m].length)this[f]=!0;if(this[T$]=!1,this[S]=!0,this.emit("resume"),this[N].length)this[G5]();else if(this[I0])this[P0]();else this.emit("drain")}resume(){return this[z$]()}pause(){this[S]=!1,this[T$]=!0,this[f]=!1}get destroyed(){return this[O]}get flowing(){return this[S]}get paused(){return this[T$]}[M1]($){if(this[g])this[_]+=1;else this[_]+=$.length;this[N].push($)}[Y5](){if(this[g])this[_]-=1;else this[_]-=this[N][0].length;return this[N].shift()}[G5]($=!1){do;while(this[q7](this[Y5]())&&this[N].length);if(!$&&!this[N].length&&!this[I0])this.emit("drain")}[q7]($){return this.emit("data",$),this[S]}pipe($,Q){if(this[O])return $;this[f]=!1;const V=this[D0];if(Q=Q||{},$===z7.stdout||$===z7.stderr)Q.end=!1;else Q.end=Q.end!==!1;if(Q.proxyErrors=!!Q.proxyErrors,V){if(Q.end)$.end()}else if(this[m].push(!Q.proxyErrors?new v1(this,$,Q):new M7(this,$,Q)),this[K0])C$(()=>this[z$]());else this[z$]();return $}unpipe($){const Q=this[m].find((V)=>V.dest===$);if(Q){if(this[m].length===1){if(this[S]&&this[d0]===0)this[S]=!1;this[m]=[]}else this[m].splice(this[m].indexOf(Q),1);Q.unpipe()}}addListener($,Q){return this.on($,Q)}on($,Q){const V=super.on($,Q);if($==="data"){if(this[f]=!1,this[d0]++,!this[m].length&&!this[S])this[z$]()}else if($==="readable"&&this[_]!==0)super.emit("readable");else if(zV($)&&this[D0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[U$]){const X=Q;if(this[K0])C$(()=>X.call(this,this[U$]));else X.call(this,this[U$])}return V}removeListener($,Q){return this.off($,Q)}off($,Q){const V=super.off($,Q);if($==="data"){if(this[d0]=this.listeners("data").length,this[d0]===0&&!this[f]&&!this[m].length)this[S]=!1}return V}removeAllListeners($){const Q=super.removeAllListeners($);if($==="data"||$===void 0){if(this[d0]=0,!this[f]&&!this[m].length)this[S]=!1}return Q}get emittedEnd(){return this[D0]}[P0](){if(!this[Z5]&&!this[D0]&&!this[O]&&this[N].length===0&&this[I0]){if(this[Z5]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[K5])this.emit("close");this[Z5]=!1}}emit($,...Q){const V=Q[0];if($!=="error"&&$!=="close"&&$!==O&&this[O])return!1;else if($==="data")return!this[g]&&!V?!1:this[K0]?(C$(()=>this[A1](V)),!0):this[A1](V);else if($==="end")return this[B7]();else if($==="close"){if(this[K5]=!0,!this[D0]&&!this[O])return!1;const J=super.emit("close");return this.removeAllListeners("close"),J}else if($==="error"){this[U$]=V,super.emit(w1,V);const J=!this[j$]||this.listeners("error").length?super.emit("error",V):!1;return this[P0](),J}else if($==="resume"){const J=super.emit("resume");return this[P0](),J}else if($==="finish"||$==="prefinish"){const J=super.emit($);return this.removeAllListeners($),J}const X=super.emit($,...Q);return this[P0](),X}[A1]($){for(let V of this[m])if(V.dest.write($)===!1)this.pause();const Q=this[f]?!1:super.emit("data",$);return this[P0](),Q}[B7](){if(this[D0])return!1;return this[D0]=!0,this.readable=!1,this[K0]?(C$(()=>this[I1]()),!0):this[I1]()}[I1](){if(this[Y$]){const Q=this[Y$].end();if(Q){for(let V of this[m])V.dest.write(Q);if(!this[f])super.emit("data",Q)}}for(let Q of this[m])Q.end();const $=super.emit("end");return this.removeAllListeners("end"),$}async collect(){const $=Object.assign([],{dataLength:0});if(!this[g])$.dataLength=0;const Q=this.promise();return this.on("data",(V)=>{if($.push(V),!this[g])$.dataLength+=V.length}),await Q,$}async concat(){if(this[g])throw new Error("cannot concat in objectMode");const $=await this.collect();return this[$0]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Q)=>{this.on(O,()=>Q(new Error("stream destroyed"))),this.on("error",(V)=>Q(V)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[f]=!1;let $=!1;const Q=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Q();const X=this.read();if(X!==null)return Promise.resolve({done:!1,value:X});if(this[I0])return Q();let J,Z;const K=(z)=>{this.off("data",G),this.off("end",Y),this.off(O,W),Q(),Z(z)},G=(z)=>{this.off("error",K),this.off("end",Y),this.off(O,W),this.pause(),J({value:z,done:!!this[I0]})},Y=()=>{this.off("error",K),this.off("data",G),this.off(O,W),Q(),J({done:!0,value:void 0})},W=()=>K(new Error("stream destroyed"));return new Promise((z,q)=>{Z=q,J=z,this.once(O,W),this.once("error",K),this.once("end",Y),this.once("data",G)})},throw:Q,return:Q,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[f]=!1;let $=!1;const Q=()=>{return this.pause(),this.off(w1,Q),this.off(O,Q),this.off("end",Q),$=!0,{done:!0,value:void 0}},V=()=>{if($)return Q();const X=this.read();return X===null?Q():{done:!1,value:X}};return this.once("end",Q),this.once(w1,Q),this.once(O,Q),{next:V,throw:Q,return:Q,[Symbol.iterator](){return this}}}destroy($){if(this[O]){if($)this.emit("error",$);else this.emit(O);return this}this[O]=!0,this[f]=!0,this[N].length=0,this[_]=0;const Q=this;if(typeof Q.close==="function"&&!this[K5])Q.close();if($)this.emit("error",$);else this.emit(O);return this}static get isStream(){return ZV}}var wV=u.writev,N0=Symbol("_autoClose"),V0=Symbol("_close"),D$=Symbol("_ended"),I=Symbol("_fd"),H1=Symbol("_finished"),v0=Symbol("_flags"),x1=Symbol("_flush"),j1=Symbol("_handleChunk"),C1=Symbol("_makeBuf"),N$=Symbol("_mode"),W5=Symbol("_needDrain"),B$=Symbol("_onerror"),L$=Symbol("_onopen"),O1=Symbol("_onread"),W$=Symbol("_onwrite"),_0=Symbol("_open"),Q0=Symbol("_path"),S0=Symbol("_pos"),G0=Symbol("_queue"),q$=Symbol("_read"),U1=Symbol("_readSize"),F0=Symbol("_reading"),S$=Symbol("_remain"),T1=Symbol("_size"),q5=Symbol("_write"),i0=Symbol("_writing"),B5=Symbol("_defaultFlag"),p0=Symbol("_errored");class M$ extends c{[p0]=!1;[I];[Q0];[U1];[F0]=!1;[T1];[S$];[N0];constructor($,Q){Q=Q||{};super(Q);if(this.readable=!0,this.writable=!1,typeof $!=="string")throw new TypeError("path must be a string");if(this[p0]=!1,this[I]=typeof Q.fd==="number"?Q.fd:void 0,this[Q0]=$,this[U1]=Q.readSize||16777216,this[F0]=!1,this[T1]=typeof Q.size==="number"?Q.size:1/0,this[S$]=this[T1],this[N0]=typeof Q.autoClose==="boolean"?Q.autoClose:!0,typeof this[I]==="number")this[q$]();else this[_0]()}get fd(){return this[I]}get path(){return this[Q0]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[_0](){u.open(this[Q0],"r",($,Q)=>this[L$]($,Q))}[L$]($,Q){if($)this[B$]($);else this[I]=Q,this.emit("open",Q),this[q$]()}[C1](){return Buffer.allocUnsafe(Math.min(this[U1],this[S$]))}[q$](){if(!this[F0]){this[F0]=!0;const $=this[C1]();if($.length===0)return process.nextTick(()=>this[O1](null,0,$));u.read(this[I],$,0,$.length,null,(Q,V,X)=>this[O1](Q,V,X))}}[O1]($,Q,V){if(this[F0]=!1,$)this[B$]($);else if(this[j1](Q,V))this[q$]()}[V0](){if(this[N0]&&typeof this[I]==="number"){const $=this[I];this[I]=void 0,u.close($,(Q)=>Q?this.emit("error",Q):this.emit("close"))}}[B$]($){this[F0]=!0,this[V0](),this.emit("error",$)}[j1]($,Q){let V=!1;if(this[S$]-=$,$>0)V=super.write($this[L$]($,Q))}[L$]($,Q){if(this[B5]&&this[v0]==="r+"&&$&&$.code==="ENOENT")this[v0]="w",this[_0]();else if($)this[B$]($);else if(this[I]=Q,this.emit("open",Q),!this[i0])this[x1]()}end($,Q){if($)this.write($,Q);if(this[D$]=!0,!this[i0]&&!this[G0].length&&typeof this[I]==="number")this[W$](null,0);return this}write($,Q){if(typeof $==="string")$=Buffer.from($,Q);if(this[D$])return this.emit("error",new Error("write() after end()")),!1;if(this[I]===void 0||this[i0]||this[G0].length)return this[G0].push($),this[W5]=!0,!1;return this[i0]=!0,this[q5]($),!0}[q5]($){u.write(this[I],$,0,$.length,this[S0],(Q,V)=>this[W$](Q,V))}[W$]($,Q){if($)this[B$]($);else{if(this[S0]!==void 0&&typeof Q==="number")this[S0]+=Q;if(this[G0].length)this[x1]();else if(this[i0]=!1,this[D$]&&!this[H1])this[H1]=!0,this[V0](),this.emit("finish");else if(this[W5])this[W5]=!1,this.emit("drain")}}[x1](){if(this[G0].length===0){if(this[D$])this[W$](null,0)}else if(this[G0].length===1)this[q5](this[G0].pop());else{const $=this[G0];this[G0]=[],wV(this[I],$,this[S0],(Q,V)=>this[W$](Q,V))}}[V0](){if(this[N0]&&typeof this[I]==="number"){const $=this[I];this[I]=void 0,u.close($,(Q)=>Q?this.emit("error",Q):this.emit("close"))}}}class _$ extends R0{[_0](){let $;if(this[B5]&&this[v0]==="r+")try{$=u.openSync(this[Q0],this[v0],this[N$])}catch(Q){if(Q?.code==="ENOENT")return this[v0]="w",this[_0]();else throw Q}else $=u.openSync(this[Q0],this[v0],this[N$]);this[L$](null,$)}[V0](){if(this[N0]&&typeof this[I]==="number"){const $=this[I];this[I]=void 0,u.closeSync($),this.emit("close")}}[q5]($){let Q=!0;try{this[W$](null,u.writeSync(this[I],$,0,$.length,this[S0])),Q=!1}finally{if(Q)try{this[V0]()}catch{}}}}import a7 from"node:path";import I$ from"node:fs";import{dirname as aV,parse as nV}from"path";var AV=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"]]),w7=($)=>!!$.sync&&!!$.file,A7=($)=>!$.sync&&!!$.file,I7=($)=>!!$.sync&&!$.file,P7=($)=>!$.sync&&!$.file;var F7=($)=>!!$.file;var IV=($)=>{const Q=AV.get($);if(Q)return Q;return $},R$=($={})=>{if(!$)return{};const Q={};for(let[V,X]of Object.entries($)){const J=IV(V);Q[J]=X}if(Q.chmod===void 0&&Q.noChmod===!1)Q.chmod=!0;return delete Q.noChmod,Q};var Y0=($,Q,V,X,J)=>{return Object.assign((Z=[],K,G)=>{if(Array.isArray(Z))K=Z,Z={};if(typeof K==="function")G=K,K=void 0;if(!K)K=[];else K=Array.from(K);const Y=R$(Z);if(J?.(Y,K),w7(Y)){if(typeof G==="function")throw new TypeError("callback not supported for sync tar functions");return $(Y,K)}else if(A7(Y)){const W=Q(Y,K),z=G?G:void 0;return z?W.then(()=>z(),z):W}else if(I7(Y)){if(typeof G==="function")throw new TypeError("callback not supported for sync tar functions");return V(Y,K)}else if(P7(Y)){if(typeof G==="function")throw new TypeError("callback only supported with file option");return X(Y,K)}else throw new Error("impossible options??")},{syncFile:$,asyncFile:Q,syncNoFile:V,asyncNoFile:X,validate:J})};import{EventEmitter as dV}from"events";import _1 from"assert";import{Buffer as g0}from"buffer";import vV from"zlib";import PV from"zlib";var FV=PV.constants||{ZLIB_VERNUM:4736},H0=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},FV));var v7=g0.concat,a0=Symbol("_superWrite");class g$ extends Error{code;errno;constructor($){super("zlib: "+$.message);if(this.code=$.code,this.errno=$.errno,!this.code)this.code="ZLIB_ERROR";this.message="zlib: "+$.message,Error.captureStackTrace(this,this.constructor)}get name(){return"ZlibError"}}var N1=Symbol("flushFlag");class R1 extends c{#$=!1;#V=!1;#X;#Z;#J;#Q;#K;get sawError(){return this.#$}get handle(){return this.#Q}get flushFlag(){return this.#X}constructor($,Q){if(!$||typeof $!=="object")throw new TypeError("invalid options for ZlibBase constructor");super($);this.#X=$.flush??0,this.#Z=$.finishFlush??0,this.#J=$.fullFlushFlag??0;try{this.#Q=new vV[Q]($)}catch(V){throw new g$(V)}this.#K=(V)=>{if(this.#$)return;this.#$=!0,this.close(),this.emit("error",V)},this.#Q?.on("error",(V)=>this.#K(new g$(V))),this.once("end",()=>this.close)}close(){if(this.#Q)this.#Q.close(),this.#Q=void 0,this.emit("close")}reset(){if(!this.#$)return _1(this.#Q,"zlib binding closed"),this.#Q.reset?.()}flush($){if(this.ended)return;if(typeof $!=="number")$=this.#J;this.write(Object.assign(g0.alloc(0),{[N1]:$}))}end($,Q,V){if(typeof $==="function")V=$,Q=void 0,$=void 0;if(typeof Q==="function")V=Q,Q=void 0;if($)if(Q)this.write($,Q);else this.write($);return this.flush(this.#Z),this.#V=!0,super.end(V)}get ended(){return this.#V}[a0]($){return super.write($)}write($,Q,V){if(typeof Q==="function")V=Q,Q="utf8";if(typeof $==="string")$=g0.from($,Q);if(this.#$)return;_1(this.#Q,"zlib binding closed");const X=this.#Q._handle,J=X.close;X.close=()=>{};const Z=this.#Q.close;this.#Q.close=()=>{},g0.concat=(Y)=>Y;let K=void 0;try{const Y=typeof $[N1]==="number"?$[N1]:this.#X;K=this.#Q._processChunk($,Y),g0.concat=v7}catch(Y){g0.concat=v7,this.#K(new g$(Y))}finally{if(this.#Q)this.#Q._handle=X,X.close=J,this.#Q.close=Z,this.#Q.removeAllListeners("error")}if(this.#Q)this.#Q.on("error",(Y)=>this.#K(new g$(Y)));let G;if(K)if(Array.isArray(K)&&K.length>0){const Y=K[0];G=this[a0](g0.from(Y));for(let W=1;W{if(typeof X==="function")J=X,X=this.flushFlag;this.flush(X),J?.()};try{this.handle.params($,Q)}finally{this.handle.flush=V}if(this.handle)this.#$=$,this.#V=Q}}}class k1 extends g1{#$;constructor($){super($,"Gzip");this.#$=$&&!!$.portable}[a0]($){if(!this.#$)return super[a0]($);return this.#$=!1,$[9]=255,super[a0]($)}}class y1 extends g1{constructor($){super($,"Unzip")}}class m1 extends R1{constructor($,Q){$=$||{},$.flush=$.flush||H0.BROTLI_OPERATION_PROCESS,$.finishFlush=$.finishFlush||H0.BROTLI_OPERATION_FINISH,$.fullFlushFlag=H0.BROTLI_OPERATION_FLUSH;super($,Q)}}class b1 extends m1{constructor($){super($,"BrotliCompress")}}class E1 extends m1{constructor($){super($,"BrotliDecompress")}}function xV($,Q,V){const X=Q,J=Q?Q.next:$.head,Z=new L5(V,X,J,$);if(Z.next===void 0)$.tail=Z;if(Z.prev===void 0)$.head=Z;return $.length++,Z}function OV($,Q){if($.tail=new L5(Q,$.tail,void 0,$),!$.head)$.head=$.tail;$.length++}function UV($,Q){if($.head=new L5(Q,void 0,$.head,$),!$.tail)$.tail=$.head;$.length++}class z0{tail;head;length=0;static create($=[]){return new z0($)}constructor($=[]){for(let Q of $)this.push(Q)}*[Symbol.iterator](){for(let $=this.head;$;$=$.next)yield $.value}removeNode($){if($.list!==this)throw new Error("removing node which does not belong to this list");const{next:Q,prev:V}=$;if(Q)Q.prev=V;if(V)V.next=Q;if($===this.head)this.head=Q;if($===this.tail)this.tail=V;return this.length--,$.next=void 0,$.prev=void 0,$.list=void 0,Q}unshiftNode($){if($===this.head)return;if($.list)$.list.removeNode($);const Q=this.head;if($.list=this,$.next=Q,Q)Q.prev=$;if(this.head=$,!this.tail)this.tail=$;this.length++}pushNode($){if($===this.tail)return;if($.list)$.list.removeNode($);const Q=this.tail;if($.list=this,$.prev=Q,Q)Q.next=$;if(this.tail=$,!this.head)this.head=$;this.length++}push(...$){for(let Q=0,V=$.length;Q1)V=Q;else if(this.head)X=this.head.next,V=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var J=0;X;J++)V=$(V,X.value,J),X=X.next;return V}reduceReverse($,Q){let V,X=this.tail;if(arguments.length>1)V=Q;else if(this.tail)X=this.tail.prev,V=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let J=this.length-1;X;J--)V=$(V,X.value,J),X=X.prev;return V}toArray(){const $=new Array(this.length);for(let Q=0,V=this.head;V;Q++)$[Q]=V.value,V=V.next;return $}toArrayReverse(){const $=new Array(this.length);for(let Q=0,V=this.tail;V;Q++)$[Q]=V.value,V=V.prev;return $}slice($=0,Q=this.length){if(Q<0)Q+=this.length;if($<0)$+=this.length;const V=new z0;if(Q<$||Q<0)return V;if($<0)$=0;if(Q>this.length)Q=this.length;let X=this.head,J=0;for(J=0;!!X&&J<$;J++)X=X.next;for(;!!X&&Jthis.length)Q=this.length;let X=this.length,J=this.tail;for(;!!J&&X>Q;X--)J=J.prev;for(;!!J&&X>$;X--,J=J.prev)V.push(J.value);return V}splice($,Q=0,...V){if($>this.length)$=this.length-1;if($<0)$=this.length+$;let X=this.head;for(let Z=0;!!X&&Z<$;Z++)X=X.next;const J=[];for(let Z=0;!!X&&Z{if(!Number.isSafeInteger($))throw Error("cannot encode number outside of javascript safe integer range");else if($<0)jV($,Q);else TV($,Q);return Q},TV=($,Q)=>{Q[0]=128;for(var V=Q.length;V>1;V--)Q[V-1]=$&255,$=Math.floor($/256)},jV=($,Q)=>{Q[0]=255;var V=!1;$=$*-1;for(var X=Q.length;X>1;X--){var J=$&255;if($=Math.floor($/256),V)Q[X-1]=O7(J);else if(J===0)Q[X-1]=0;else V=!0,Q[X-1]=U7(J)}},x7=($)=>{const Q=$[0],V=Q===128?DV($.subarray(1,$.length)):Q===255?CV($):null;if(V===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(V))throw Error("parsed number outside of javascript safe integer range");return V},CV=($)=>{var Q=$.length,V=0,X=!1;for(var J=Q-1;J>-1;J--){var Z=Number($[J]),K;if(X)K=O7(Z);else if(Z===0)K=Z;else X=!0,K=U7(Z);if(K!==0)V-=K*Math.pow(256,Q-J-1)}return V},DV=($)=>{var Q=$.length,V=0;for(var X=Q-1;X>-1;X--){var J=Number($[X]);if(J!==0)V+=J*Math.pow(256,Q-X-1)}return V},O7=($)=>(255^$)&255,U7=($)=>(255^$)+1&255;var M5=($)=>w5.has($);var w5=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"]]),T7=new Map(Array.from(w5).map(($)=>[$[1],$[0]]));class a{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#$="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor($,Q=0,V,X){if(Buffer.isBuffer($))this.decode($,Q||0,V,X);else if($)this.#V($)}decode($,Q,V,X){if(!Q)Q=0;if(!$||!($.length>=Q+512))throw new Error("need 512 bytes for header");if(this.path=n0($,Q,100),this.mode=k0($,Q+100,8),this.uid=k0($,Q+108,8),this.gid=k0($,Q+116,8),this.size=k0($,Q+124,12),this.mtime=h1($,Q+136,12),this.cksum=k0($,Q+148,12),X)this.#V(X,!0);if(V)this.#V(V);const J=n0($,Q+156,1);if(M5(J))this.#$=J||"0";if(this.#$==="0"&&this.path.slice(-1)==="/")this.#$="5";if(this.#$==="5")this.size=0;if(this.linkpath=n0($,Q+157,100),$.subarray(Q+257,Q+265).toString()==="ustar\x0000")if(this.uname=n0($,Q+265,32),this.gname=n0($,Q+297,32),this.devmaj=k0($,Q+329,8)??0,this.devmin=k0($,Q+337,8)??0,$[Q+475]!==0){const K=n0($,Q+345,155);this.path=K+"/"+this.path}else{const K=n0($,Q+345,130);if(K)this.path=K+"/"+this.path;this.atime=h1($,Q+476,12),this.ctime=h1($,Q+488,12)}let Z=256;for(let K=Q;K{return!(X===null||X===void 0||V==="path"&&Q||V==="linkpath"&&Q||V==="global")})))}encode($,Q=0){if(!$)$=this.block=Buffer.alloc(512);if(this.#$==="Unsupported")this.#$="0";if(!($.length>=Q+512))throw new Error("need 512 bytes for header");const V=this.ctime||this.atime?130:155,X=NV(this.path||"",V),J=X[0],Z=X[1];if(this.needPax=!!X[2],this.needPax=s0($,Q,100,J)||this.needPax,this.needPax=y0($,Q+100,8,this.mode)||this.needPax,this.needPax=y0($,Q+108,8,this.uid)||this.needPax,this.needPax=y0($,Q+116,8,this.gid)||this.needPax,this.needPax=y0($,Q+124,12,this.size)||this.needPax,this.needPax=u1($,Q+136,12,this.mtime)||this.needPax,$[Q+156]=this.#$.charCodeAt(0),this.needPax=s0($,Q+157,100,this.linkpath)||this.needPax,$.write("ustar\x0000",Q+257,8),this.needPax=s0($,Q+265,32,this.uname)||this.needPax,this.needPax=s0($,Q+297,32,this.gname)||this.needPax,this.needPax=y0($,Q+329,8,this.devmaj)||this.needPax,this.needPax=y0($,Q+337,8,this.devmin)||this.needPax,this.needPax=s0($,Q+345,V,Z)||this.needPax,$[Q+475]!==0)this.needPax=s0($,Q+345,155,Z)||this.needPax;else this.needPax=s0($,Q+345,130,Z)||this.needPax,this.needPax=u1($,Q+476,12,this.atime)||this.needPax,this.needPax=u1($,Q+488,12,this.ctime)||this.needPax;let K=256;for(let G=Q;G{let X=$,J="",Z=void 0;const K=w$.parse($).root||".";if(Buffer.byteLength(X)<100)Z=[X,J,!1];else{J=w$.dirname(X),X=w$.basename(X);do if(Buffer.byteLength(X)<=100&&Buffer.byteLength(J)<=Q)Z=[X,J,!1];else if(Buffer.byteLength(X)>100&&Buffer.byteLength(J)<=Q)Z=[X.slice(0,99),J,!0];else X=w$.join(w$.basename(J),X),J=w$.dirname(J);while(J!==K&&Z===void 0);if(!Z)Z=[$.slice(0,99),"",!0]}return Z},n0=($,Q,V)=>$.subarray(Q,Q+V).toString("utf8").replace(/\0.*/,""),h1=($,Q,V)=>_V(k0($,Q,V)),_V=($)=>$===void 0?void 0:new Date($*1000),k0=($,Q,V)=>Number($[Q])&128?x7($.subarray(Q,Q+V)):gV($,Q,V),RV=($)=>isNaN($)?void 0:$,gV=($,Q,V)=>RV(parseInt($.subarray(Q,Q+V).toString("utf8").replace(/\0.*$/,"").trim(),8)),kV={12:8589934591,8:2097151},y0=($,Q,V,X)=>X===void 0?!1:X>kV[V]||X<0?(H7(X,$.subarray(Q,Q+V)),!0):(yV($,Q,V,X),!1),yV=($,Q,V,X)=>$.write(mV(X,V),Q,V,"ascii"),mV=($,Q)=>bV(Math.floor($).toString(8),Q),bV=($,Q)=>($.length===Q-1?$:new Array(Q-$.length-1).join("0")+$+" ")+"\0",u1=($,Q,V,X)=>X===void 0?!1:y0($,Q,V,X.getTime()/1000),EV=new Array(156).join("\0"),s0=($,Q,V,X)=>X===void 0?!1:($.write(X+EV,Q,V,"utf8"),X.length!==Buffer.byteLength(X)||X.length>V);import{basename as hV}from"node:path";class m0{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor($,Q=!1){this.atime=$.atime,this.charset=$.charset,this.comment=$.comment,this.ctime=$.ctime,this.dev=$.dev,this.gid=$.gid,this.global=Q,this.gname=$.gname,this.ino=$.ino,this.linkpath=$.linkpath,this.mtime=$.mtime,this.nlink=$.nlink,this.path=$.path,this.size=$.size,this.uid=$.uid,this.uname=$.uname}encode(){const $=this.encodeBody();if($==="")return Buffer.allocUnsafe(0);const Q=Buffer.byteLength($),V=512*Math.ceil(1+Q/512),X=Buffer.allocUnsafe(V);for(let J=0;J<512;J++)X[J]=0;new a({path:("PaxHeader/"+hV(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:Q,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(X),X.write($,512,Q,"utf8");for(let J=Q+512;J=Math.pow(10,Z))Z+=1;return Z+J+X}static parse($,Q,V=!1){return new m0(uV(fV($),Q),V)}}var uV=($,Q)=>Q?Object.assign({},Q,$):$,fV=($)=>$.replace(/\n$/,"").split("\n").reduce(cV,Object.create(null)),cV=($,Q)=>{const V=parseInt(Q,10);if(V!==Buffer.byteLength(Q)+1)return $;Q=Q.slice((V+" ").length);const X=Q.split("="),J=X.shift();if(!J)return $;const Z=J.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),K=X.join("=");return $[Z]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(Z)?new Date(Number(K)*1000):/^[0-9]+$/.test(K)?+K:K,$};var lV=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,M=lV!=="win32"?($)=>$:($)=>$&&$.replace(/\\/g,"/");class k$ extends c{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($,Q,V){super({});switch(this.pause(),this.extended=Q,this.globalExtended=V,this.header=$,this.remain=$.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=$.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(!$.path)throw new Error("no path provided for tar.ReadEntry");if(this.path=M($.path),this.mode=$.mode,this.mode)this.mode=this.mode&4095;if(this.uid=$.uid,this.gid=$.gid,this.uname=$.uname,this.gname=$.gname,this.size=this.remain,this.mtime=$.mtime,this.atime=$.atime,this.ctime=$.ctime,this.linkpath=$.linkpath?M($.linkpath):void 0,this.uname=$.uname,this.gname=$.gname,Q)this.#$(Q);if(V)this.#$(V,!0)}write($){const Q=$.length;if(Q>this.blockRemain)throw new Error("writing more to entry than is appropriate");const V=this.remain,X=this.blockRemain;if(this.remain=Math.max(0,V-Q),this.blockRemain=Math.max(0,X-Q),this.ignore)return!0;if(V>=Q)return super.write($);return super.write($.subarray(0,V))}#$($,Q=!1){if($.path)$.path=M($.path);if($.linkpath)$.linkpath=M($.linkpath);Object.assign(this,Object.fromEntries(Object.entries($).filter(([V,X])=>{return!(X===null||X===void 0||V==="path"&&Q)})))}}var r0=($,Q,V,X={})=>{if($.file)X.file=$.file;if($.cwd)X.cwd=$.cwd;if(X.code=V instanceof Error&&V.code||Q,X.tarCode=Q,!$.strict&&X.recoverable!==!1){if(V instanceof Error)X=Object.assign(V,X),V=V.message;$.emit("warn",Q,V,X)}else if(V instanceof Error)$.emit("error",Object.assign(V,X));else $.emit("error",Object.assign(new Error(`${Q}: ${V}`),X))};var iV=1048576,f1=Buffer.from([31,139]),n=Symbol("state"),o0=Symbol("writeEntry"),x0=Symbol("readEntry"),c1=Symbol("nextEntry"),C7=Symbol("processEntry"),W0=Symbol("extendedHeader"),y$=Symbol("globalExtendedHeader"),b0=Symbol("meta"),D7=Symbol("emitMeta"),v=Symbol("buffer"),O0=Symbol("queue"),E0=Symbol("ended"),l1=Symbol("emittedEnd"),t0=Symbol("emit"),T=Symbol("unzip"),A5=Symbol("consumeChunk"),I5=Symbol("consumeChunkSub"),d1=Symbol("consumeBody"),S7=Symbol("consumeMeta"),N7=Symbol("consumeHeader"),m$=Symbol("consuming"),i1=Symbol("bufferConcat"),P5=Symbol("maybeEnd"),A$=Symbol("writing"),h0=Symbol("aborted"),F5=Symbol("onDone"),e0=Symbol("sawValidEntry"),v5=Symbol("sawNullBlock"),H5=Symbol("sawEOF"),_7=Symbol("closeStream"),pV=()=>!0;class u0 extends dV{file;strict;maxMetaEntrySize;filter;brotli;writable=!0;readable=!1;[O0]=new z0;[v];[x0];[o0];[n]="begin";[b0]="";[W0];[y$];[E0]=!1;[T];[h0]=!1;[e0];[v5]=!1;[H5]=!1;[A$]=!1;[m$]=!1;[l1]=!1;constructor($={}){super();if(this.file=$.file||"",this.on(F5,()=>{if(this[n]==="begin"||this[e0]===!1)this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),$.ondone)this.on(F5,$.ondone);else this.on(F5,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")});this.strict=!!$.strict,this.maxMetaEntrySize=$.maxMetaEntrySize||iV,this.filter=typeof $.filter==="function"?$.filter:pV;const Q=$.file&&($.file.endsWith(".tar.br")||$.file.endsWith(".tbr"));if(this.brotli=!$.gzip&&$.brotli!==void 0?$.brotli:Q?void 0:!1,this.on("end",()=>this[_7]()),typeof $.onwarn==="function")this.on("warn",$.onwarn);if(typeof $.onReadEntry==="function")this.on("entry",$.onReadEntry)}warn($,Q,V={}){r0(this,$,Q,V)}[N7]($,Q){if(this[e0]===void 0)this[e0]=!1;let V;try{V=new a($,Q,this[W0],this[y$])}catch(X){return this.warn("TAR_ENTRY_INVALID",X)}if(V.nullBlock)if(this[v5]){if(this[H5]=!0,this[n]==="begin")this[n]="header";this[t0]("eof")}else this[v5]=!0,this[t0]("nullBlock");else if(this[v5]=!1,!V.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:V});else if(!V.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:V});else{const X=V.type;if(/^(Symbolic)?Link$/.test(X)&&!V.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:V});else if(!/^(Symbolic)?Link$/.test(X)&&!/^(Global)?ExtendedHeader$/.test(X)&&V.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:V});else{const J=this[o0]=new k$(V,this[W0],this[y$]);if(!this[e0])if(J.remain){const Z=()=>{if(!J.invalid)this[e0]=!0};J.on("end",Z)}else this[e0]=!0;if(J.meta){if(J.size>this.maxMetaEntrySize)J.ignore=!0,this[t0]("ignoredEntry",J),this[n]="ignore",J.resume();else if(J.size>0)this[b0]="",J.on("data",(Z)=>this[b0]+=Z),this[n]="meta"}else if(this[W0]=void 0,J.ignore=J.ignore||!this.filter(J.path,J),J.ignore)this[t0]("ignoredEntry",J),this[n]=J.remain?"ignore":"header",J.resume();else{if(J.remain)this[n]="body";else this[n]="header",J.end();if(!this[x0])this[O0].push(J),this[c1]();else this[O0].push(J)}}}}[_7](){queueMicrotask(()=>this.emit("close"))}[C7]($){let Q=!0;if(!$)this[x0]=void 0,Q=!1;else if(Array.isArray($)){const[V,...X]=$;this.emit(V,...X)}else if(this[x0]=$,this.emit("entry",$),!$.emittedEnd)$.on("end",()=>this[c1]()),Q=!1;return Q}[c1](){do;while(this[C7](this[O0].shift()));if(!this[O0].length){const $=this[x0];if(!$||$.flowing||$.size===$.remain){if(!this[A$])this.emit("drain")}else $.once("drain",()=>this.emit("drain"))}}[d1]($,Q){const V=this[o0];if(!V)throw new Error("attempt to consume body without entry??");const X=V.blockRemain??0,J=X>=$.length&&Q===0?$:$.subarray(Q,Q+X);if(V.write(J),!V.blockRemain)this[n]="header",this[o0]=void 0,V.end();return J.length}[S7]($,Q){const V=this[o0],X=this[d1]($,Q);if(!this[o0]&&V)this[D7](V);return X}[t0]($,Q,V){if(!this[O0].length&&!this[x0])this.emit($,Q,V);else this[O0].push([$,Q,V])}[D7]($){switch(this[t0]("meta",this[b0]),$.type){case"ExtendedHeader":case"OldExtendedHeader":this[W0]=m0.parse(this[b0],this[W0],!1);break;case"GlobalExtendedHeader":this[y$]=m0.parse(this[b0],this[y$],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{const Q=this[W0]??Object.create(null);this[W0]=Q,Q.path=this[b0].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{const Q=this[W0]||Object.create(null);this[W0]=Q,Q.linkpath=this[b0].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+$.type)}}abort($){this[h0]=!0,this.emit("abort",$),this.warn("TAR_ABORT",$,{recoverable:!1})}write($,Q,V){if(typeof Q==="function")V=Q,Q=void 0;if(typeof $==="string")$=Buffer.from($,typeof Q==="string"?Q:"utf8");if(this[h0])return V?.(),!1;if((this[T]===void 0||this.brotli===void 0&&this[T]===!1)&&$){if(this[v])$=Buffer.concat([this[v],$]),this[v]=void 0;if($.lengththis[A5](Y)),this[T].on("error",(Y)=>this.abort(Y)),this[T].on("end",()=>{this[E0]=!0,this[A5]()}),this[A$]=!0;const G=!!this[T][K?"end":"write"]($);return this[A$]=!1,V?.(),G}}if(this[A$]=!0,this[T])this[T].write($);else this[A5]($);this[A$]=!1;const J=this[O0].length?!1:this[x0]?this[x0].flowing:!0;if(!J&&!this[O0].length)this[x0]?.once("drain",()=>this.emit("drain"));return V?.(),J}[i1]($){if($&&!this[h0])this[v]=this[v]?Buffer.concat([this[v],$]):$}[P5](){if(this[E0]&&!this[l1]&&!this[h0]&&!this[m$]){this[l1]=!0;const $=this[o0];if($&&$.blockRemain){const Q=this[v]?this[v].length:0;if(this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${$.blockRemain} more bytes, only ${Q} available)`,{entry:$}),this[v])$.write(this[v]);$.end()}this[t0](F5)}}[A5]($){if(this[m$]&&$)this[i1]($);else if(!$&&!this[v])this[P5]();else if($){if(this[m$]=!0,this[v]){this[i1]($);const Q=this[v];this[v]=void 0,this[I5](Q)}else this[I5]($);while(this[v]&&this[v]?.length>=512&&!this[h0]&&!this[H5]){const Q=this[v];this[v]=void 0,this[I5](Q)}this[m$]=!1}if(!this[v]||this[E0])this[P5]()}[I5]($){let Q=0;const V=$.length;while(Q+512<=V&&!this[h0]&&!this[H5])switch(this[n]){case"begin":case"header":this[N7]($,Q),Q+=512;break;case"ignore":case"body":Q+=this[d1]($,Q);break;case"meta":Q+=this[S7]($,Q);break;default:throw new Error("invalid state: "+this[n])}if(Q{let Q=$.length-1,V=-1;while(Q>-1&&$.charAt(Q)==="/")V=Q,Q--;return V===-1?$:$.slice(0,V)};var sV=($)=>{const Q=$.onReadEntry;$.onReadEntry=Q?(V)=>{Q(V),V.resume()}:(V)=>V.resume()},p1=($,Q)=>{const V=new Map(Q.map((Z)=>[q0(Z),!0])),X=$.filter,J=(Z,K="")=>{const G=K||nV(Z).root||".";let Y;if(Z===G)Y=!1;else{const W=V.get(Z);if(W!==void 0)Y=W;else Y=J(aV(Z),G)}return V.set(Z,Y),Y};$.filter=X?(Z,K)=>X(Z,K)&&J(q0(Z)):(Z)=>J(q0(Z))},rV=($)=>{const Q=new u0($),V=$.file;let X;try{const J=I$.statSync(V),Z=$.maxReadSize||16777216;if(J.size{const V=new u0($),X=$.maxReadSize||16777216,J=$.file;return new Promise((K,G)=>{V.on("error",G),V.on("end",K),I$.stat(J,(Y,W)=>{if(Y)G(Y);else{const z=new M$(J,{readSize:X,size:W.size});z.on("error",G),z.pipe(V)}})})},$$=Y0(rV,oV,($)=>new u0($),($)=>new u0($),($,Q)=>{if(Q?.length)p1($,Q);if(!$.noResume)sV($)});import R5 from"fs";import B0 from"fs";import y7 from"path";var a1=($,Q,V)=>{if($&=4095,V)$=($|384)&-19;if(Q){if($&256)$|=64;if($&32)$|=8;if($&4)$|=1}return $};import{win32 as tV}from"node:path";var{isAbsolute:eV,parse:R7}=tV,b$=($)=>{let Q="",V=R7($);while(eV($)||V.root){const X=$.charAt(0)==="/"&&$.slice(0,4)!=="//?/"?"/":V.root;$=$.slice(X.length),Q+=X,V=R7($)}return[Q,$]};var x5=["|","<",">","?",":"],n1=x5.map(($)=>String.fromCharCode(61440+$.charCodeAt(0))),$X=new Map(x5.map(($,Q)=>[$,n1[Q]])),QX=new Map(n1.map(($,Q)=>[$,x5[Q]])),s1=($)=>x5.reduce((Q,V)=>Q.split(V).join($X.get(V)),$),g7=($)=>n1.reduce((Q,V)=>Q.split(V).join(QX.get(V)),$);var u7=($,Q)=>{if(!Q)return M($);return $=M($).replace(/^\.(\/|$)/,""),q0(Q)+"/"+$},VX=16777216,m7=Symbol("process"),b7=Symbol("file"),E7=Symbol("directory"),o1=Symbol("symlink"),h7=Symbol("hardlink"),E$=Symbol("header"),O5=Symbol("read"),t1=Symbol("lstat"),U5=Symbol("onlstat"),e1=Symbol("onread"),$8=Symbol("onreadlink"),Q8=Symbol("openfile"),V8=Symbol("onopenfile"),f0=Symbol("close"),T5=Symbol("mode"),X8=Symbol("awaitDrain"),r1=Symbol("ondrain"),L0=Symbol("prefix");class j5 extends c{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;#$=!1;constructor($,Q={}){const V=R$(Q);super();if(this.path=M($),this.portable=!!V.portable,this.maxReadSize=V.maxReadSize||VX,this.linkCache=V.linkCache||new Map,this.statCache=V.statCache||new Map,this.preservePaths=!!V.preservePaths,this.cwd=M(V.cwd||process.cwd()),this.strict=!!V.strict,this.noPax=!!V.noPax,this.noMtime=!!V.noMtime,this.mtime=V.mtime,this.prefix=V.prefix?M(V.prefix):void 0,typeof V.onwarn==="function")this.on("warn",V.onwarn);let X=!1;if(!this.preservePaths){const[Z,K]=b$(this.path);if(Z&&typeof K==="string")this.path=K,X=Z}if(this.win32=!!V.win32||process.platform==="win32",this.win32)this.path=g7(this.path.replace(/\\/g,"/")),$=$.replace(/\\/g,"/");if(this.absolute=M(V.absolute||y7.resolve(this.cwd,$)),this.path==="")this.path="./";if(X)this.warn("TAR_ENTRY_INFO",`stripping ${X} from absolute path`,{entry:this,path:X+this.path});const J=this.statCache.get(this.absolute);if(J)this[U5](J);else this[t1]()}warn($,Q,V={}){return r0(this,$,Q,V)}emit($,...Q){if($==="error")this.#$=!0;return super.emit($,...Q)}[t1](){B0.lstat(this.absolute,($,Q)=>{if($)return this.emit("error",$);this[U5](Q)})}[U5]($){if(this.statCache.set(this.absolute,$),this.stat=$,!$.isFile())$.size=0;this.type=XX($),this.emit("stat",$),this[m7]()}[m7](){switch(this.type){case"File":return this[b7]();case"Directory":return this[E7]();case"SymbolicLink":return this[o1]();default:return this.end()}}[T5]($){return a1($,this.type==="Directory",this.portable)}[L0]($){return u7($,this.prefix)}[E$](){if(!this.stat)throw new Error("cannot write header before stat");if(this.type==="Directory"&&this.portable)this.noMtime=!0;if(this.header=new a({path:this[L0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[L0](this.linkpath):this.linkpath,mode:this[T5](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 m0({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[L0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[L0](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 $=this.header?.block;if(!$)throw new Error("failed to encode header");super.write($)}[E7](){if(!this.stat)throw new Error("cannot create directory entry without stat");if(this.path.slice(-1)!=="/")this.path+="/";this.stat.size=0,this[E$](),this.end()}[o1](){B0.readlink(this.absolute,($,Q)=>{if($)return this.emit("error",$);this[$8](Q)})}[$8]($){this.linkpath=M($),this[E$](),this.end()}[h7]($){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=M(y7.relative(this.cwd,$)),this.stat.size=0,this[E$](),this.end()}[b7](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){const $=`${this.stat.dev}:${this.stat.ino}`,Q=this.linkCache.get($);if(Q?.indexOf(this.cwd)===0)return this[h7](Q);this.linkCache.set($,this.absolute)}if(this[E$](),this.stat.size===0)return this.end();this[Q8]()}[Q8](){B0.open(this.absolute,"r",($,Q)=>{if($)return this.emit("error",$);this[V8](Q)})}[V8]($){if(this.fd=$,this.#$)return this[f0]();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 Q=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(Q),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[O5]()}[O5](){const{fd:$,buf:Q,offset:V,length:X,pos:J}=this;if($===void 0||Q===void 0)throw new Error("cannot read file without first opening");B0.read($,Q,V,X,J,(Z,K)=>{if(Z)return this[f0](()=>this.emit("error",Z));this[e1](K)})}[f0]($=()=>{}){if(this.fd!==void 0)B0.close(this.fd,$)}[e1]($){if($<=0&&this.remain>0){const X=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[f0](()=>this.emit("error",X))}if($>this.remain){const X=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[f0](()=>this.emit("error",X))}if(!this.buf)throw new Error("should have created buffer prior to reading");if($===this.remain)for(let X=$;Xthis[r1]());else this[r1]()}[X8]($){this.once("drain",$)}write($,Q,V){if(typeof Q==="function")V=Q,Q=void 0;if(typeof $==="string")$=Buffer.from($,typeof Q==="string"?Q:"utf8");if(this.blockRemain<$.length){const X=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",X)}return this.remain-=$.length,this.blockRemain-=$.length,this.pos+=$.length,this.offset+=$.length,super.write($,null,V)}[r1](){if(!this.remain){if(this.blockRemain)super.write(Buffer.alloc(this.blockRemain));return this[f0](($)=>$?this.emit("error",$):this.end())}if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");if(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[O5]()}}class J8 extends j5{sync=!0;[t1](){this[U5](B0.lstatSync(this.absolute))}[o1](){this[$8](B0.readlinkSync(this.absolute))}[Q8](){this[V8](B0.openSync(this.absolute,"r"))}[O5](){let $=!0;try{const{fd:Q,buf:V,offset:X,length:J,pos:Z}=this;if(Q===void 0||V===void 0)throw new Error("fd and buf must be set in READ method");const K=B0.readSync(Q,V,X,J,Z);this[e1](K),$=!1}finally{if($)try{this[f0](()=>{})}catch(Q){}}}[X8]($){$()}[f0]($=()=>{}){if(this.fd!==void 0)B0.closeSync(this.fd);$()}}class Z8 extends c{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;warn($,Q,V={}){return r0(this,$,Q,V)}constructor($,Q={}){const V=R$(Q);super();this.preservePaths=!!V.preservePaths,this.portable=!!V.portable,this.strict=!!V.strict,this.noPax=!!V.noPax,this.noMtime=!!V.noMtime,this.readEntry=$;const{type:X}=$;if(X==="Unsupported")throw new Error("writing entry that should be ignored");if(this.type=X,this.type==="Directory"&&this.portable)this.noMtime=!0;if(this.prefix=V.prefix,this.path=M($.path),this.mode=$.mode!==void 0?this[T5]($.mode):void 0,this.uid=this.portable?void 0:$.uid,this.gid=this.portable?void 0:$.gid,this.uname=this.portable?void 0:$.uname,this.gname=this.portable?void 0:$.gname,this.size=$.size,this.mtime=this.noMtime?void 0:V.mtime||$.mtime,this.atime=this.portable?void 0:$.atime,this.ctime=this.portable?void 0:$.ctime,this.linkpath=$.linkpath!==void 0?M($.linkpath):void 0,typeof V.onwarn==="function")this.on("warn",V.onwarn);let J=!1;if(!this.preservePaths){const[K,G]=b$(this.path);if(K&&typeof G==="string")this.path=G,J=K}if(this.remain=$.size,this.blockRemain=$.startBlockSize,this.header=new a({path:this[L0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[L0](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}),J)this.warn("TAR_ENTRY_INFO",`stripping ${J} from absolute path`,{entry:this,path:J+this.path});if(this.header.encode()&&!this.noPax)super.write(new m0({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[L0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[L0](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 Z=this.header?.block;if(!Z)throw new Error("failed to encode header");super.write(Z),$.pipe(this)}[L0]($){return u7($,this.prefix)}[T5]($){return a1($,this.type==="Directory",this.portable)}write($,Q,V){if(typeof Q==="function")V=Q,Q=void 0;if(typeof $==="string")$=Buffer.from($,typeof Q==="string"?Q:"utf8");const X=$.length;if(X>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=X,super.write($,V)}end($,Q,V){if(this.blockRemain)super.write(Buffer.alloc(this.blockRemain));if(typeof $==="function")V=$,Q=void 0,$=void 0;if(typeof Q==="function")V=Q,Q=void 0;if(typeof $==="string")$=Buffer.from($,Q??"utf8");if(V)this.once("finish",V);return $?super.end($,V):super.end(V),this}}var XX=($)=>$.isFile()?"File":$.isDirectory()?"Directory":$.isSymbolicLink()?"SymbolicLink":"Unsupported";import i7 from"path";class z8{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor($,Q){this.path=$||"./",this.absolute=Q}}var f7=Buffer.alloc(1024),C5=Symbol("onStat"),h$=Symbol("ended"),X0=Symbol("queue"),P$=Symbol("current"),Q$=Symbol("process"),u$=Symbol("processing"),c7=Symbol("processJob"),J0=Symbol("jobs"),K8=Symbol("jobDone"),D5=Symbol("addFSEntry"),l7=Symbol("addTarEntry"),W8=Symbol("stat"),q8=Symbol("readdir"),S5=Symbol("onreaddir"),N5=Symbol("pipe"),d7=Symbol("entry"),G8=Symbol("entryOpt"),_5=Symbol("writeEntryClass"),p7=Symbol("write"),Y8=Symbol("ondrain");class V$ extends c{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[_5];onWriteEntry;[X0];[J0]=0;[u$]=!1;[h$]=!1;constructor($={}){super();if(this.opt=$,this.file=$.file||"",this.cwd=$.cwd||process.cwd(),this.maxReadSize=$.maxReadSize,this.preservePaths=!!$.preservePaths,this.strict=!!$.strict,this.noPax=!!$.noPax,this.prefix=M($.prefix||""),this.linkCache=$.linkCache||new Map,this.statCache=$.statCache||new Map,this.readdirCache=$.readdirCache||new Map,this.onWriteEntry=$.onWriteEntry,this[_5]=j5,typeof $.onwarn==="function")this.on("warn",$.onwarn);if(this.portable=!!$.portable,$.gzip||$.brotli){if($.gzip&&$.brotli)throw new TypeError("gzip and brotli are mutually exclusive");if($.gzip){if(typeof $.gzip!=="object")$.gzip={};if(this.portable)$.gzip.portable=!0;this.zip=new k1($.gzip)}if($.brotli){if(typeof $.brotli!=="object")$.brotli={};this.zip=new b1($.brotli)}if(!this.zip)throw new Error("impossible");const Q=this.zip;Q.on("data",(V)=>super.write(V)),Q.on("end",()=>super.end()),Q.on("drain",()=>this[Y8]()),this.on("resume",()=>Q.resume())}else this.on("drain",this[Y8]);if(this.noDirRecurse=!!$.noDirRecurse,this.follow=!!$.follow,this.noMtime=!!$.noMtime,$.mtime)this.mtime=$.mtime;this.filter=typeof $.filter==="function"?$.filter:()=>!0,this[X0]=new z0,this[J0]=0,this.jobs=Number($.jobs)||4,this[u$]=!1,this[h$]=!1}[p7]($){return super.write($)}add($){return this.write($),this}end($){if($)this.add($);return this[h$]=!0,this[Q$](),this}write($){if(this[h$])throw new Error("write after end");if($ instanceof k$)this[l7]($);else this[D5]($);return this.flowing}[l7]($){const Q=M(i7.resolve(this.cwd,$.path));if(!this.filter($.path,$))$.resume();else{const V=new z8($.path,Q);V.entry=new Z8($,this[G8](V)),V.entry.on("end",()=>this[K8](V)),this[J0]+=1,this[X0].push(V)}this[Q$]()}[D5]($){const Q=M(i7.resolve(this.cwd,$));this[X0].push(new z8($,Q)),this[Q$]()}[W8]($){$.pending=!0,this[J0]+=1;const Q=this.follow?"stat":"lstat";R5[Q]($.absolute,(V,X)=>{if($.pending=!1,this[J0]-=1,V)this.emit("error",V);else this[C5]($,X)})}[C5]($,Q){if(this.statCache.set($.absolute,Q),$.stat=Q,!this.filter($.path,Q))$.ignore=!0;this[Q$]()}[q8]($){$.pending=!0,this[J0]+=1,R5.readdir($.absolute,(Q,V)=>{if($.pending=!1,this[J0]-=1,Q)return this.emit("error",Q);this[S5]($,V)})}[S5]($,Q){this.readdirCache.set($.absolute,Q),$.readdir=Q,this[Q$]()}[Q$](){if(this[u$])return;this[u$]=!0;for(let $=this[X0].head;!!$&&this[J0]this.warn(Q,V,X),noPax:this.noPax,cwd:this.cwd,absolute:$.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}}[d7]($){this[J0]+=1;try{const Q=new this[_5]($.path,this[G8]($));return this.onWriteEntry?.(Q),Q.on("end",()=>this[K8]($)).on("error",(V)=>this.emit("error",V))}catch(Q){this.emit("error",Q)}}[Y8](){if(this[P$]&&this[P$].entry)this[P$].entry.resume()}[N5]($){if($.piped=!0,$.readdir)$.readdir.forEach((X)=>{const J=$.path,Z=J==="./"?"":J.replace(/\/*$/,"/");this[D5](Z+X)});const Q=$.entry,V=this.zip;if(!Q)throw new Error("cannot pipe without source");if(V)Q.on("data",(X)=>{if(!V.write(X))Q.pause()});else Q.on("data",(X)=>{if(!super.write(X))Q.pause()})}pause(){if(this.zip)this.zip.pause();return super.pause()}warn($,Q,V={}){r0(this,$,Q,V)}}class F$ extends V${sync=!0;constructor($){super($);this[_5]=J8}pause(){}resume(){}[W8]($){const Q=this.follow?"statSync":"lstatSync";this[C5]($,R5[Q]($.absolute))}[q8]($){this[S5]($,R5.readdirSync($.absolute))}[N5]($){const Q=$.entry,V=this.zip;if($.readdir)$.readdir.forEach((X)=>{const J=$.path,Z=J==="./"?"":J.replace(/\/*$/,"/");this[D5](Z+X)});if(!Q)throw new Error("Cannot pipe without source");if(V)Q.on("data",(X)=>{V.write(X)});else Q.on("data",(X)=>{super[p7](X)})}}var JX=($,Q)=>{const V=new F$($),X=new _$($.file,{mode:$.mode||438});V.pipe(X),n7(V,Q)},ZX=($,Q)=>{const V=new V$($),X=new R0($.file,{mode:$.mode||438});V.pipe(X);const J=new Promise((Z,K)=>{X.on("error",K),X.on("close",Z),V.on("error",K)});return s7(V,Q),J},n7=($,Q)=>{Q.forEach((V)=>{if(V.charAt(0)==="@")$$({file:a7.resolve($.cwd,V.slice(1)),sync:!0,noResume:!0,onReadEntry:(X)=>$.add(X)});else $.add(V)}),$.end()},s7=async($,Q)=>{for(let V=0;V{$.add(J)}});else $.add(X)}$.end()},KX=($,Q)=>{const V=new F$($);return n7(V,Q),V},GX=($,Q)=>{const V=new V$($);return s7(V,Q),V},YX=Y0(JX,ZX,KX,GX,($,Q)=>{if(!Q?.length)throw new TypeError("no paths specified to add to archive")});import I4 from"node:fs";import yX from"node:assert";import{randomBytes as A4}from"node:crypto";import A from"node:fs";import T0 from"node:path";import r7 from"fs";var zX=process.env.__FAKE_PLATFORM__||process.platform,WX=zX==="win32",{O_CREAT:qX,O_TRUNC:BX,O_WRONLY:LX}=r7.constants,o7=Number(process.env.__FAKE_FS_O_FILENAME__)||r7.constants.UV_FS_O_FILEMAP||0,MX=WX&&!!o7,wX=524288,AX=o7|BX|qX|LX,B8=!MX?()=>"w":($)=>${try{return k5.lchownSync($,Q,V)}catch(X){if(X?.code!=="ENOENT")throw X}},g5=($,Q,V,X)=>{k5.lchown($,Q,V,(J)=>{X(J&&J?.code!=="ENOENT"?J:null)})},IX=($,Q,V,X,J)=>{if(Q.isDirectory())M8(f$.resolve($,Q.name),V,X,(Z)=>{if(Z)return J(Z);const K=f$.resolve($,Q.name);g5(K,V,X,J)});else{const Z=f$.resolve($,Q.name);g5(Z,V,X,J)}},M8=($,Q,V,X)=>{k5.readdir($,{withFileTypes:!0},(J,Z)=>{if(J){if(J.code==="ENOENT")return X();else if(J.code!=="ENOTDIR"&&J.code!=="ENOTSUP")return X(J)}if(J||!Z.length)return g5($,Q,V,X);let K=Z.length,G=null;const Y=(W)=>{if(G)return;if(W)return X(G=W);if(--K===0)return g5($,Q,V,X)};for(let W of Z)IX($,W,Q,V,Y)})},PX=($,Q,V,X)=>{if(Q.isDirectory())w8(f$.resolve($,Q.name),V,X);L8(f$.resolve($,Q.name),V,X)},w8=($,Q,V)=>{let X;try{X=k5.readdirSync($,{withFileTypes:!0})}catch(J){const Z=J;if(Z?.code==="ENOENT")return;else if(Z?.code==="ENOTDIR"||Z?.code==="ENOTSUP")return L8($,Q,V);else throw Z}for(let J of X)PX($,J,Q,V);return L8($,Q,V)};import r from"fs";import{dirname as t7}from"path";import{mkdir as FX,mkdirSync as vX,stat as HX,statSync as xX}from"fs";var s=($)=>{if(!$)$={mode:511};else if(typeof $==="object")$={mode:511,...$};else if(typeof $==="number")$={mode:$};else if(typeof $==="string")$={mode:parseInt($,8)};else throw new TypeError("invalid options argument");const Q=$,V=$.fs||{};return $.mkdir=$.mkdir||V.mkdir||FX,$.mkdirAsync=$.mkdirAsync?$.mkdirAsync:async(X,J)=>{return new Promise((Z,K)=>Q.mkdir(X,J,(G,Y)=>G?K(G):Z(Y)))},$.stat=$.stat||V.stat||HX,$.statAsync=$.statAsync?$.statAsync:async(X)=>new Promise((J,Z)=>Q.stat(X,(K,G)=>K?Z(K):J(G))),$.statSync=$.statSync||V.statSync||xX,$.mkdirSync=$.mkdirSync||V.mkdirSync||vX,Q};var M0=($,Q,V)=>{const X=t7($),J={...s(Q),recursive:!1};if(X===$)try{return J.mkdirSync($,J)}catch(Z){const K=Z;if(K&&K.code!=="EISDIR")throw Z;return}try{return J.mkdirSync($,J),V||$}catch(Z){const K=Z;if(K&&K.code==="ENOENT")return M0($,J,M0(X,J,V));if(K&&K.code!=="EEXIST"&&K&&K.code!=="EROFS")throw Z;try{if(!J.statSync($).isDirectory())throw Z}catch(G){throw Z}}},U0=Object.assign(async($,Q,V)=>{const X=s(Q);X.recursive=!1;const J=t7($);if(J===$)return X.mkdirAsync($,X).catch((Z)=>{const K=Z;if(K&&K.code!=="EISDIR")throw Z});return X.mkdirAsync($,X).then(()=>V||$,async(Z)=>{const K=Z;if(K&&K.code==="ENOENT")return U0(J,X).then((G)=>U0($,X,G));if(K&&K.code!=="EEXIST"&&K.code!=="EROFS")throw Z;return X.statAsync($).then((G)=>{if(G.isDirectory())return V;else throw Z},()=>{throw Z})})},{sync:M0});import{dirname as $4}from"path";import{dirname as e7}from"path";var A8=async($,Q,V)=>{if(V===Q)return;return $.statAsync(Q).then((X)=>X.isDirectory()?V:void 0,(X)=>{const J=X;return J&&J.code==="ENOENT"?A8($,e7(Q),Q):void 0})},I8=($,Q,V)=>{if(V===Q)return;try{return $.statSync(Q).isDirectory()?V:void 0}catch(X){const J=X;return J&&J.code==="ENOENT"?I8($,e7(Q),Q):void 0}};var v$=($,Q)=>{const V=s(Q);if(V.recursive=!0,$4($)===$)return V.mkdirSync($,V);const J=I8(V,$);try{return V.mkdirSync($,V),J}catch(Z){const K=Z;if(K&&K.code==="ENOENT")return M0($,V);else throw Z}},c$=Object.assign(async($,Q)=>{const V={...s(Q),recursive:!0};if($4($)===$)return await V.mkdirAsync($,V);return A8(V,$).then((J)=>V.mkdirAsync($,V).then((Z)=>J||Z).catch((Z)=>{const K=Z;if(K&&K.code==="ENOENT")return U0($,V);else throw Z}))},{sync:v$});import{parse as UX,resolve as TX}from"path";var OX=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,P8=($)=>{if(/\0/.test($))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:$,code:"ERR_INVALID_ARG_VALUE"});if($=TX($),OX==="win32"){const Q=/[*|"<>?:]/,{root:V}=UX($);if(Q.test($.substring(V.length)))throw Object.assign(new Error("Illegal characters in path."),{path:$,code:"EINVAL"})}return $};import{mkdir as jX,mkdirSync as CX}from"fs";var DX=process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version,F8=DX.replace(/^v/,"").split("."),Q4=+F8[0]>10||+F8[0]===10&&+F8[1]>=12,l$=!Q4?()=>!1:($)=>s($).mkdirSync===CX,y5=Object.assign(!Q4?()=>!1:($)=>s($).mkdir===jX,{sync:l$});var m5=($,Q)=>{$=P8($);const V=s(Q);return l$(V)?v$($,V):M0($,V)};var V4=Object.assign(async($,Q)=>{$=P8($);const V=s(Q);return y5(V)?c$($,V):U0($,V)},{mkdirpSync:m5,mkdirpNative:c$,mkdirpNativeSync:v$,mkdirpManual:U0,mkdirpManualSync:M0,sync:m5,native:c$,nativeSync:v$,manual:U0,manualSync:M0,useNative:y5,useNativeSync:l$});import h5 from"node:path";class b5 extends Error{path;code;syscall="chdir";constructor($,Q){super(`${Q}: Cannot cd into '${$}'`);this.path=$,this.code=Q}get name(){return"CwdError"}}class E5 extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor($,Q){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link");this.symlink=$,this.path=Q}get name(){return"SymlinkError"}}var u5=($,Q)=>$.get(M(Q)),d$=($,Q,V)=>$.set(M(Q),V),SX=($,Q)=>{r.stat($,(V,X)=>{if(V||!X.isDirectory())V=new b5($,V?.code||"ENOTDIR");Q(V)})},X4=($,Q,V)=>{$=M($);const X=Q.umask??18,J=Q.mode|448,Z=(J&X)!==0,K=Q.uid,G=Q.gid,Y=typeof K==="number"&&typeof G==="number"&&(K!==Q.processUid||G!==Q.processGid),W=Q.preserve,z=Q.unlink,q=Q.cache,L=M(Q.cwd),H=(b,D)=>{if(b)V(b);else if(d$(q,$,!0),D&&Y)M8(D,K,G,(N8)=>H(N8));else if(Z)r.chmod($,J,V);else V()};if(q&&u5(q,$)===!0)return H();if($===L)return SX($,H);if(W)return V4($,{mode:J}).then((b)=>H(null,b??void 0),H);const C=M(h5.relative(L,$)).split("/");f5(L,C,J,q,z,L,void 0,H)},f5=($,Q,V,X,J,Z,K,G)=>{if(!Q.length)return G(null,K);const Y=Q.shift(),W=M(h5.resolve($+"/"+Y));if(u5(X,W))return f5(W,Q,V,X,J,Z,K,G);r.mkdir(W,V,J4(W,Q,V,X,J,Z,K,G))},J4=($,Q,V,X,J,Z,K,G)=>(Y)=>{if(Y)r.lstat($,(W,z)=>{if(W)W.path=W.path&&M(W.path),G(W);else if(z.isDirectory())f5($,Q,V,X,J,Z,K,G);else if(J)r.unlink($,(q)=>{if(q)return G(q);r.mkdir($,V,J4($,Q,V,X,J,Z,K,G))});else if(z.isSymbolicLink())return G(new E5($,$+"/"+Q.join("/")));else G(Y)});else K=K||$,f5($,Q,V,X,J,Z,K,G)},NX=($)=>{let Q=!1,V=void 0;try{Q=r.statSync($).isDirectory()}catch(X){V=X?.code}finally{if(!Q)throw new b5($,V??"ENOTDIR")}},Z4=($,Q)=>{$=M($);const V=Q.umask??18,X=Q.mode|448,J=(X&V)!==0,Z=Q.uid,K=Q.gid,G=typeof Z==="number"&&typeof K==="number"&&(Z!==Q.processUid||K!==Q.processGid),Y=Q.preserve,W=Q.unlink,z=Q.cache,q=M(Q.cwd),L=(b)=>{if(d$(z,$,!0),b&&G)w8(b,Z,K);if(J)r.chmodSync($,X)};if(z&&u5(z,$)===!0)return L();if($===q)return NX(q),L();if(Y)return L(m5($,X)??void 0);const j=M(h5.relative(q,$)).split("/");let C=void 0;for(let b=j.shift(),D=q;b&&(D+="/"+b);b=j.shift()){if(D=M(h5.resolve(D)),u5(z,D))continue;try{r.mkdirSync(D,X),C=C||D,d$(z,D,!0)}catch(N8){const _8=r.lstatSync(D);if(_8.isDirectory()){d$(z,D,!0);continue}else if(W){r.unlinkSync(D),r.mkdirSync(D,X),C=C||D,d$(z,D,!0);continue}else if(_8.isSymbolicLink())return new E5(D,D+"/"+j.join("/"))}}return L(C)};var v8=Object.create(null),{hasOwnProperty:_X}=Object.prototype,c5=($)=>{if(!_X.call(v8,$))v8[$]=$.normalize("NFD");return v8[$]};import{join as K4}from"node:path";var RX=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,gX=RX==="win32",kX=($)=>{return $.split("/").slice(0,-1).reduce((V,X)=>{const J=V[V.length-1];if(J!==void 0)X=K4(J,X);return V.push(X||"/"),V},[])};class H8{#$=new Map;#V=new Map;#X=new Set;reserve($,Q){$=gX?["win32 parallelization disabled"]:$.map((X)=>{return q0(K4(c5(X))).toLowerCase()});const V=new Set($.map((X)=>kX(X)).reduce((X,J)=>X.concat(J)));this.#V.set(Q,{dirs:V,paths:$});for(let X of $){const J=this.#$.get(X);if(!J)this.#$.set(X,[Q]);else J.push(Q)}for(let X of V){const J=this.#$.get(X);if(!J)this.#$.set(X,[new Set([Q])]);else{const Z=J[J.length-1];if(Z instanceof Set)Z.add(Q);else J.push(new Set([Q]))}}return this.#J(Q)}#Z($){const Q=this.#V.get($);if(!Q)throw new Error("function does not have any path reservations");return{paths:Q.paths.map((V)=>this.#$.get(V)),dirs:[...Q.dirs].map((V)=>this.#$.get(V))}}check($){const{paths:Q,dirs:V}=this.#Z($);return Q.every((X)=>X&&X[0]===$)&&V.every((X)=>X&&X[0]instanceof Set&&X[0].has($))}#J($){if(this.#X.has($)||!this.check($))return!1;return this.#X.add($),$(()=>this.#Q($)),!0}#Q($){if(!this.#X.has($))return!1;const Q=this.#V.get($);if(!Q)throw new Error("invalid reservation");const{paths:V,dirs:X}=Q,J=new Set;for(let Z of V){const K=this.#$.get(Z);if(!K||K?.[0]!==$)continue;const G=K[1];if(!G){this.#$.delete(Z);continue}if(K.shift(),typeof G==="function")J.add(G);else for(let Y of G)J.add(Y)}for(let Z of X){const K=this.#$.get(Z),G=K?.[0];if(!K||!(G instanceof Set))continue;if(G.size===1&&K.length===1){this.#$.delete(Z);continue}else if(G.size===1){K.shift();const Y=K[0];if(typeof Y==="function")J.add(Y)}else G.delete($)}return this.#X.delete($),J.forEach((Z)=>this.#J(Z)),!0}}var G4=Symbol("onEntry"),U8=Symbol("checkFs"),Y4=Symbol("checkFs2"),i5=Symbol("pruneCache"),T8=Symbol("isReusable"),o=Symbol("makeFs"),j8=Symbol("file"),C8=Symbol("directory"),p5=Symbol("link"),z4=Symbol("symlink"),W4=Symbol("hardlink"),q4=Symbol("unsupported"),B4=Symbol("checkPath"),c0=Symbol("mkdir"),k=Symbol("onError"),l5=Symbol("pending"),L4=Symbol("pend"),H$=Symbol("unpend"),x8=Symbol("ended"),O8=Symbol("maybeClose"),D8=Symbol("skip"),i$=Symbol("doChown"),p$=Symbol("uid"),a$=Symbol("gid"),n$=Symbol("checkedCwd"),mX=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,s$=mX==="win32",bX=1024,EX=($,Q)=>{if(!s$)return A.unlink($,Q);const V=$+".DELETE."+A4(16).toString("hex");A.rename($,V,(X)=>{if(X)return Q(X);A.unlink(V,Q)})},hX=($)=>{if(!s$)return A.unlinkSync($);const Q=$+".DELETE."+A4(16).toString("hex");A.renameSync($,Q),A.unlinkSync(Q)},M4=($,Q,V)=>$!==void 0&&$===$>>>0?$:Q!==void 0&&Q===Q>>>0?Q:V,w4=($)=>q0(M(c5($))).toLowerCase(),uX=($,Q)=>{Q=w4(Q);for(let V of $.keys()){const X=w4(V);if(X===Q||X.indexOf(Q+"/")===0)$.delete(V)}},fX=($)=>{for(let Q of $.keys())$.delete(Q)};class r$ extends u0{[x8]=!1;[n$]=!1;[l5]=0;reservations=new H8;transform;writable=!0;readable=!1;dirCache;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor($={}){$.ondone=()=>{this[x8]=!0,this[O8]()};super($);if(this.transform=$.transform,this.dirCache=$.dirCache||new Map,this.chmod=!!$.chmod,typeof $.uid==="number"||typeof $.gid==="number"){if(typeof $.uid!=="number"||typeof $.gid!=="number")throw new TypeError("cannot set owner without number uid and gid");if($.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=$.uid,this.gid=$.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;if($.preserveOwner===void 0&&typeof $.uid!=="number")this.preserveOwner=!!(process.getuid&&process.getuid()===0);else this.preserveOwner=!!$.preserveOwner;this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof $.maxDepth==="number"?$.maxDepth:bX,this.forceChown=$.forceChown===!0,this.win32=!!$.win32||s$,this.newer=!!$.newer,this.keep=!!$.keep,this.noMtime=!!$.noMtime,this.preservePaths=!!$.preservePaths,this.unlink=!!$.unlink,this.cwd=M(T0.resolve($.cwd||process.cwd())),this.strip=Number($.strip)||0,this.processUmask=!this.chmod?0:typeof $.processUmask==="number"?$.processUmask:process.umask(),this.umask=typeof $.umask==="number"?$.umask:this.processUmask,this.dmode=$.dmode||511&~this.umask,this.fmode=$.fmode||438&~this.umask,this.on("entry",(Q)=>this[G4](Q))}warn($,Q,V={}){if($==="TAR_BAD_ARCHIVE"||$==="TAR_ABORT")V.recoverable=!1;return super.warn($,Q,V)}[O8](){if(this[x8]&&this[l5]===0)this.emit("prefinish"),this.emit("finish"),this.emit("end")}[B4]($){const Q=M($.path),V=Q.split("/");if(this.strip){if(V.length=this.strip)$.linkpath=X.slice(this.strip).join("/");else return!1}V.splice(0,this.strip),$.path=V.join("/")}if(isFinite(this.maxDepth)&&V.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:$,path:Q,depth:V.length,maxDepth:this.maxDepth}),!1;if(!this.preservePaths){if(V.includes("..")||s$&&/^[a-z]:\.\.$/i.test(V[0]??""))return this.warn("TAR_ENTRY_ERROR","path contains '..'",{entry:$,path:Q}),!1;const[X,J]=b$(Q);if(X)$.path=String(J),this.warn("TAR_ENTRY_INFO",`stripping ${X} from absolute path`,{entry:$,path:Q})}if(T0.isAbsolute($.path))$.absolute=M(T0.resolve($.path));else $.absolute=M(T0.resolve(this.cwd,$.path));if(!this.preservePaths&&typeof $.absolute==="string"&&$.absolute.indexOf(this.cwd+"/")!==0&&$.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:$,path:M($.path),resolvedPath:$.absolute,cwd:this.cwd}),!1;if($.absolute===this.cwd&&$.type!=="Directory"&&$.type!=="GNUDumpDir")return!1;if(this.win32){const{root:X}=T0.win32.parse(String($.absolute));$.absolute=X+s1(String($.absolute).slice(X.length));const{root:J}=T0.win32.parse($.path);$.path=J+s1($.path.slice(J.length))}return!0}[G4]($){if(!this[B4]($))return $.resume();switch(yX.equal(typeof $.absolute,"string"),$.type){case"Directory":case"GNUDumpDir":if($.mode)$.mode=$.mode|448;case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[U8]($);case"CharacterDevice":case"BlockDevice":case"FIFO":default:return this[q4]($)}}[k]($,Q){if($.name==="CwdError")this.emit("error",$);else this.warn("TAR_ENTRY_ERROR",$,{entry:Q}),this[H$](),Q.resume()}[c0]($,Q,V){X4(M($),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:Q},V)}[i$]($){return this.forceChown||this.preserveOwner&&(typeof $.uid==="number"&&$.uid!==this.processUid||typeof $.gid==="number"&&$.gid!==this.processGid)||typeof this.uid==="number"&&this.uid!==this.processUid||typeof this.gid==="number"&&this.gid!==this.processGid}[p$]($){return M4(this.uid,$.uid,this.processUid)}[a$]($){return M4(this.gid,$.gid,this.processGid)}[j8]($,Q){const V=typeof $.mode==="number"?$.mode&4095:this.fmode,X=new R0(String($.absolute),{flags:B8($.size),mode:V,autoClose:!1});X.on("error",(G)=>{if(X.fd)A.close(X.fd,()=>{});X.write=()=>!0,this[k](G,$),Q()});let J=1;const Z=(G)=>{if(G){if(X.fd)A.close(X.fd,()=>{});this[k](G,$),Q();return}if(--J===0){if(X.fd!==void 0)A.close(X.fd,(Y)=>{if(Y)this[k](Y,$);else this[H$]();Q()})}};X.on("finish",()=>{const G=String($.absolute),Y=X.fd;if(typeof Y==="number"&&$.mtime&&!this.noMtime){J++;const W=$.atime||new Date,z=$.mtime;A.futimes(Y,W,z,(q)=>q?A.utimes(G,W,z,(L)=>Z(L&&q)):Z())}if(typeof Y==="number"&&this[i$]($)){J++;const W=this[p$]($),z=this[a$]($);if(typeof W==="number"&&typeof z==="number")A.fchown(Y,W,z,(q)=>q?A.chown(G,W,z,(L)=>Z(L&&q)):Z())}Z()});const K=this.transform?this.transform($)||$:$;if(K!==$)K.on("error",(G)=>{this[k](G,$),Q()}),$.pipe(K);K.pipe(X)}[C8]($,Q){const V=typeof $.mode==="number"?$.mode&4095:this.dmode;this[c0](String($.absolute),V,(X)=>{if(X){this[k](X,$),Q();return}let J=1;const Z=()=>{if(--J===0)Q(),this[H$](),$.resume()};if($.mtime&&!this.noMtime)J++,A.utimes(String($.absolute),$.atime||new Date,$.mtime,Z);if(this[i$]($))J++,A.chown(String($.absolute),Number(this[p$]($)),Number(this[a$]($)),Z);Z()})}[q4]($){$.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${$.type}`,{entry:$}),$.resume()}[z4]($,Q){this[p5]($,String($.linkpath),"symlink",Q)}[W4]($,Q){const V=M(T0.resolve(this.cwd,String($.linkpath)));this[p5]($,V,"link",Q)}[L4](){this[l5]++}[H$](){this[l5]--,this[O8]()}[D8]($){this[H$](),$.resume()}[T8]($,Q){return $.type==="File"&&!this.unlink&&Q.isFile()&&Q.nlink<=1&&!s$}[U8]($){this[L4]();const Q=[$.path];if($.linkpath)Q.push($.linkpath);this.reservations.reserve(Q,(V)=>this[Y4]($,V))}[i5]($){if($.type==="SymbolicLink")fX(this.dirCache);else if($.type!=="Directory")uX(this.dirCache,String($.absolute))}[Y4]($,Q){this[i5]($);const V=(K)=>{this[i5]($),Q(K)},X=()=>{this[c0](this.cwd,this.dmode,(K)=>{if(K){this[k](K,$),V();return}this[n$]=!0,J()})},J=()=>{if($.absolute!==this.cwd){const K=M(T0.dirname(String($.absolute)));if(K!==this.cwd)return this[c0](K,this.dmode,(G)=>{if(G){this[k](G,$),V();return}Z()})}Z()},Z=()=>{A.lstat(String($.absolute),(K,G)=>{if(G&&(this.keep||this.newer&&G.mtime>($.mtime??G.mtime))){this[D8]($),V();return}if(K||this[T8]($,G))return this[o](null,$,V);if(G.isDirectory()){if($.type==="Directory"){const Y=this.chmod&&$.mode&&(G.mode&4095)!==$.mode,W=(z)=>this[o](z??null,$,V);if(!Y)return W();return A.chmod(String($.absolute),Number($.mode),W)}if($.absolute!==this.cwd)return A.rmdir(String($.absolute),(Y)=>this[o](Y??null,$,V))}if($.absolute===this.cwd)return this[o](null,$,V);EX(String($.absolute),(Y)=>this[o](Y??null,$,V))})};if(this[n$])J();else X()}[o]($,Q,V){if($){this[k]($,Q),V();return}switch(Q.type){case"File":case"OldFile":case"ContiguousFile":return this[j8](Q,V);case"Link":return this[W4](Q,V);case"SymbolicLink":return this[z4](Q,V);case"Directory":case"GNUDumpDir":return this[C8](Q,V)}}[p5]($,Q,V,X){A[V](Q,String($.absolute),(J)=>{if(J)this[k](J,$);else this[H$](),$.resume();X()})}}var d5=($)=>{try{return[null,$()]}catch(Q){return[Q,null]}};class a5 extends r${sync=!0;[o]($,Q){return super[o]($,Q,()=>{})}[U8]($){if(this[i5]($),!this[n$]){const J=this[c0](this.cwd,this.dmode);if(J)return this[k](J,$);this[n$]=!0}if($.absolute!==this.cwd){const J=M(T0.dirname(String($.absolute)));if(J!==this.cwd){const Z=this[c0](J,this.dmode);if(Z)return this[k](Z,$)}}const[Q,V]=d5(()=>A.lstatSync(String($.absolute)));if(V&&(this.keep||this.newer&&V.mtime>($.mtime??V.mtime)))return this[D8]($);if(Q||this[T8]($,V))return this[o](null,$);if(V.isDirectory()){if($.type==="Directory"){const Z=this.chmod&&$.mode&&(V.mode&4095)!==$.mode,[K]=Z?d5(()=>{A.chmodSync(String($.absolute),Number($.mode))}):[];return this[o](K,$)}const[J]=d5(()=>A.rmdirSync(String($.absolute)));this[o](J,$)}const[X]=$.absolute===this.cwd?[]:d5(()=>hX(String($.absolute)));this[o](X,$)}[j8]($,Q){const V=typeof $.mode==="number"?$.mode&4095:this.fmode,X=(K)=>{let G;try{A.closeSync(J)}catch(Y){G=Y}if(K||G)this[k](K||G,$);Q()};let J;try{J=A.openSync(String($.absolute),B8($.size),V)}catch(K){return X(K)}const Z=this.transform?this.transform($)||$:$;if(Z!==$)Z.on("error",(K)=>this[k](K,$)),$.pipe(Z);Z.on("data",(K)=>{try{A.writeSync(J,K,0,K.length)}catch(G){X(G)}}),Z.on("end",()=>{let K=null;if($.mtime&&!this.noMtime){const G=$.atime||new Date,Y=$.mtime;try{A.futimesSync(J,G,Y)}catch(W){try{A.utimesSync(String($.absolute),G,Y)}catch(z){K=W}}}if(this[i$]($)){const G=this[p$]($),Y=this[a$]($);try{A.fchownSync(J,Number(G),Number(Y))}catch(W){try{A.chownSync(String($.absolute),Number(G),Number(Y))}catch(z){K=K||W}}}X(K)})}[C8]($,Q){const V=typeof $.mode==="number"?$.mode&4095:this.dmode,X=this[c0](String($.absolute),V);if(X){this[k](X,$),Q();return}if($.mtime&&!this.noMtime)try{A.utimesSync(String($.absolute),$.atime||new Date,$.mtime)}catch(J){}if(this[i$]($))try{A.chownSync(String($.absolute),Number(this[p$]($)),Number(this[a$]($)))}catch(J){}Q(),$.resume()}[c0]($,Q){try{return Z4(M($),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:Q})}catch(V){return V}}[p5]($,Q,V,X){const J=`${V}Sync`;try{A[J](Q,String($.absolute)),X(),$.resume()}catch(Z){return this[k](Z,$)}}}var cX=($)=>{const Q=new a5($),V=$.file,X=I4.statSync(V),J=$.maxReadSize||16777216;new D1(V,{readSize:J,size:X.size}).pipe(Q)},lX=($,Q)=>{const V=new r$($),X=$.maxReadSize||16777216,J=$.file;return new Promise((K,G)=>{V.on("error",G),V.on("close",K),I4.stat(J,(Y,W)=>{if(Y)G(Y);else{const z=new M$(J,{readSize:X,size:W.size});z.on("error",G),z.pipe(V)}})})},S8=Y0(cX,lX,($)=>new a5($),($)=>new r$($),($,Q)=>{if(Q?.length)p1($,Q)});import l from"node:fs";import P4 from"node:path";var dX=($,Q)=>{const V=new F$($);let X=!0,J,Z;try{try{J=l.openSync($.file,"r+")}catch(Y){if(Y?.code==="ENOENT")J=l.openSync($.file,"w+");else throw Y}const K=l.fstatSync(J),G=Buffer.alloc(512);$:for(Z=0;ZK.size)break;if(Z+=W,$.mtimeCache&&Y.mtime)$.mtimeCache.set(String(Y.path),Y.mtime)}X=!1,iX($,V,Z,J,Q)}finally{if(X)try{l.closeSync(J)}catch(K){}}},iX=($,Q,V,X,J)=>{const Z=new _$($.file,{fd:X,start:V});Q.pipe(Z),aX(Q,J)},pX=($,Q)=>{Q=Array.from(Q);const V=new V$($),X=(Z,K,G)=>{const Y=(H,j)=>{if(H)l.close(Z,(C)=>G(H));else G(null,j)};let W=0;if(K===0)return Y(null,0);let z=0;const q=Buffer.alloc(512),L=(H,j)=>{if(H||typeof j==="undefined")return Y(H);if(z+=j,z<512&&j)return l.read(Z,q,z,q.length-z,W+z,L);if(W===0&&q[0]===31&&q[1]===139)return Y(new Error("cannot append to compressed archives"));if(z<512)return Y(null,W);const C=new a(q);if(!C.cksumValid)return Y(null,W);const b=512*Math.ceil((C.size??0)/512);if(W+b+512>K)return Y(null,W);if(W+=b+512,W>=K)return Y(null,W);if($.mtimeCache&&C.mtime)$.mtimeCache.set(String(C.path),C.mtime);z=0,l.read(Z,q,0,512,W,L)};l.read(Z,q,0,512,W,L)};return new Promise((Z,K)=>{V.on("error",K);let G="r+";const Y=(W,z)=>{if(W&&W.code==="ENOENT"&&G==="r+")return G="w+",l.open($.file,G,Y);if(W||!z)return K(W);l.fstat(z,(q,L)=>{if(q)return l.close(z,()=>K(q));X(z,L.size,(H,j)=>{if(H)return K(H);const C=new R0($.file,{fd:z,start:j});V.pipe(C),C.on("error",K),C.on("close",Z),nX(V,Q)})})};l.open($.file,G,Y)})},aX=($,Q)=>{Q.forEach((V)=>{if(V.charAt(0)==="@")$$({file:P4.resolve($.cwd,V.slice(1)),sync:!0,noResume:!0,onReadEntry:(X)=>$.add(X)});else $.add(V)}),$.end()},nX=async($,Q)=>{for(let V=0;V$.add(J)});else $.add(X)}$.end()},X$=Y0(dX,pX,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},($,Q)=>{if(!F7($))throw new TypeError("file is required");if($.gzip||$.brotli||$.file.endsWith(".br")||$.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!Q?.length)throw new TypeError("no paths specified to add/replace")});var sX=Y0(X$.syncFile,X$.asyncFile,X$.syncNoFile,X$.asyncNoFile,($,Q=[])=>{X$.validate?.($,Q),rX($)}),rX=($)=>{const Q=$.filter;if(!$.mtimeCache)$.mtimeCache=new Map;$.filter=Q?(V,X)=>Q(V,X)&&!(($.mtimeCache?.get(V)??X.mtime??0)>(X.mtime??0)):(V,X)=>!(($.mtimeCache?.get(V)??X.mtime??0)>(X.mtime??0))};import{promisify as QJ}from"util";async function XJ($,Q,V){w.info(`Starting download from URL: ${$}`);const J=`beat-forge/init-beatsaber@${F4().version}`;w.debug(`User-Agent: ${J}`);const Z={"User-Agent":J};if(V)Z.Authorization=`token ${V}`;const K=await fetch($,{headers:Z});if(w.info(`Response status: ${K.status}`),w.debug(`Response headers: ${JSON.stringify([...K.headers])}`),!K.ok)throw w.error(`Failed to download file: ${K.statusText}`),new Error(`Failed to download file: ${K.statusText}`);await J$.mkdir(v4(Q),{recursive:!0}),w.debug(`Created directory for output path: ${v4(Q)}`);const G=eX(Q);if(w.info("Starting to read and write file stream"),K.body)await VJ(K.body,G);else throw new Error("Response body is null");w.info("File downloaded and written successfully")}async function JJ($,Q){w.info(`Extracting tarball from ${$} to ${Q}`);try{await J$.mkdir(Q,{recursive:!0}),await S8({file:$,cwd:Q}),w.info("Tarball extraction completed successfully")}catch(V){throw w.error(`Failed to extract tarball from ${$} to ${Q}`),w.error(`Error details: ${V}`),V}}async function H4($,Q){w.info(`Moving contents from ${$} to ${Q}`);try{await J$.mkdir(Q,{recursive:!0});const V=await J$.readdir($,{withFileTypes:!0});w.debug(`Files to move: ${V.map((X)=>X.name).join(", ")}`);for(let X of V){const J=s5($,X.name),Z=s5(Q,X.name);if(X.isDirectory())await H4(J,Z);else await J$.rename(J,Z);w.debug(`Moved ${J} to ${Z}`)}w.info("Content move completed successfully")}catch(V){throw w.error(`Failed to move contents from ${$} to ${Q}`),w.error(`Error details: ${V}`),V}}async function x4($){w.info(`Searching for manifest.json in directory: ${$}`);const Q=await J$.readdir($,{withFileTypes:!0});for(let V of Q){const X=s5($,V.name);if(V.isDirectory()){const J=await x4(X);if(J)return J}else if(V.name==="manifest.json")return w.info(`Found manifest.json at ${X}`),X}return w.debug(`No manifest.json found in directory: ${$}`),null}async function ZJ(){try{w.info("Initializing Beat Saber modding environment...");const $=w.getInput("token"),Q=w.getInput("repo"),V=w.getInput("host"),X=w.getInput("manifest"),J=w.getInput("path");let Z=w.getInput("version");if(w.debug(`Inputs: version=${Z}, manifest=${X}, path=${J}, repo=${Q}, host=${V}`),!Z){w.info("No version specified. Attempting to infer version from manifest.json...");const q=X?n5(X):await x4(process.cwd());if(q){w.info(`Found manifest.json at ${q}`);let L=await J$.readFile(q,"utf-8");if(L.startsWith("\uFEFF"))w.debug("Removing BOM from manifest.json"),L=L.substring(1);Z=JSON.parse(L).gameVersion,w.info(`Inferred version: ${Z}`)}else throw w.error("No manifest.json found and no version specified."),new Error("No manifest.json found and no version specified.")}if(Q.split("/").length!==2)throw w.error(`Invalid repo format: ${Q} (expected owner/repo)`),new Error(`Invalid repo format: ${Q} (expected owner/repo)`);const K=`version/${Z}`,G=`https://${V}/${Q}/archive/refs/heads/${K}.tar.gz`,Y=n5("archive.tar.gz"),W=n5("extract"),z=n5(J);w.info(`Downloading from ${G}`),await XJ(G,Y,$),w.info(`Extracting tarball to ${W}`),await JJ(Y,W),w.info(`Moving contents to ${z}`),await H4(s5(W,`beatsaber-stripped-version-${Z}`),z),w.info("Beat Saber references initialized successfully")}catch($){w.setFailed(`Action failed with error: ${$}`)}}var VJ=QJ($J);ZJ(); + Error Message: ${Z.message}`)})).result)===null||Q===void 0?void 0:Q.value;if(!J)throw new Error("Response json body do not have ID Token field");return J})}static getIDToken($){return r7(this,void 0,void 0,function*(){try{let Q=Z5.getIDTokenUrl();if($){const X=encodeURIComponent($);Q=`${Q}&audience=${X}`}t7.debug(`ID token url is ${Q}`);const V=yield Z5.getCall(Q);return t7.setSecret(V),V}catch(Q){throw new Error(`Error message: ${Q.message}`)}})}}K5.OidcClient=Z5});var W9=H((m)=>{var Y9=m&&m.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(m,"__esModule",{value:!0});m.summary=m.markdownSummary=m.SUMMARY_DOCS_URL=m.SUMMARY_ENV_VAR=void 0;var UQ=j("os"),z9=j("fs"),{access:xQ,appendFile:TQ,writeFile:CQ}=z9.promises;m.SUMMARY_ENV_VAR="GITHUB_STEP_SUMMARY";m.SUMMARY_DOCS_URL="https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";class $1{constructor(){this._buffer=""}filePath(){return Y9(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;const $=process.env[m.SUMMARY_ENV_VAR];if(!$)throw new Error(`Unable to find environment variable for \$${m.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`);try{yield xQ($,z9.constants.R_OK|z9.constants.W_OK)}catch(Q){throw new Error(`Unable to access summary file: '${$}'. Check if the file has correct read/write permissions.`)}return this._filePath=$,this._filePath})}wrap($,Q,V={}){const X=Object.entries(V).map(([J,Z])=>` ${J}="${Z}"`).join("");if(!Q)return`<${$}${X}>`;return`<${$}${X}>${Q}`}write($){return Y9(this,void 0,void 0,function*(){const Q=!!($===null||$===void 0?void 0:$.overwrite),V=yield this.filePath();return yield(Q?CQ:TQ)(V,this._buffer,{encoding:"utf8"}),this.emptyBuffer()})}clear(){return Y9(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer="",this}addRaw($,Q=!1){return this._buffer+=$,Q?this.addEOL():this}addEOL(){return this.addRaw(UQ.EOL)}addCodeBlock($,Q){const V=Object.assign({},Q&&{lang:Q}),X=this.wrap("pre",this.wrap("code",$),V);return this.addRaw(X).addEOL()}addList($,Q=!1){const V=Q?"ol":"ul",X=$.map((Z)=>this.wrap("li",Z)).join(""),J=this.wrap(V,X);return this.addRaw(J).addEOL()}addTable($){const Q=$.map((X)=>{const J=X.map((Z)=>{if(typeof Z==="string")return this.wrap("td",Z);const{header:K,data:G,colspan:Y,rowspan:W}=Z,z=K?"th":"td",q=Object.assign(Object.assign({},Y&&{colspan:Y}),W&&{rowspan:W});return this.wrap(z,G,q)}).join("");return this.wrap("tr",J)}).join(""),V=this.wrap("table",Q);return this.addRaw(V).addEOL()}addDetails($,Q){const V=this.wrap("details",this.wrap("summary",$)+Q);return this.addRaw(V).addEOL()}addImage($,Q,V){const{width:X,height:J}=V||{},Z=Object.assign(Object.assign({},X&&{width:X}),J&&{height:J}),K=this.wrap("img",null,Object.assign({src:$,alt:Q},Z));return this.addRaw(K).addEOL()}addHeading($,Q){const V=`h${Q}`,X=["h1","h2","h3","h4","h5","h6"].includes(V)?V:"h1",J=this.wrap(X,$);return this.addRaw(J).addEOL()}addSeparator(){const $=this.wrap("hr",null);return this.addRaw($).addEOL()}addBreak(){const $=this.wrap("br",null);return this.addRaw($).addEOL()}addQuote($,Q){const V=Object.assign({},Q&&{cite:Q}),X=this.wrap("blockquote",$,V);return this.addRaw(X).addEOL()}addLink($,Q){const V=this.wrap("a",$,{href:Q});return this.addRaw(V).addEOL()}}var Q1=new $1;m.markdownSummary=Q1;m.summary=Q1});var V1=H((h)=>{function _Q($){return $.replace(/[\\]/g,"/")}function RQ($){return $.replace(/[/]/g,"\\")}function gQ($){return $.replace(/[/\\]/g,SQ.sep)}var jQ=h&&h.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),DQ=h&&h.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),NQ=h&&h.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))jQ(Q,$,V)}return DQ(Q,$),Q};Object.defineProperty(h,"__esModule",{value:!0});h.toPlatformPath=h.toWin32Path=h.toPosixPath=void 0;var SQ=NQ(j("path"));h.toPosixPath=_Q;h.toWin32Path=RQ;h.toPlatformPath=gQ});var G9=H((B)=>{function mQ($,Q){const V=G5.toCommandValue(Q);if(process.env[$]=V,process.env.GITHUB_ENV||"")return d0.issueFileCommand("ENV",d0.prepareKeyValueMessage($,Q));p.issueCommand("set-env",{name:$},V)}function hQ($){p.issueCommand("add-mask",{},$)}function uQ($){if(process.env.GITHUB_PATH||"")d0.issueFileCommand("PATH",$);else p.issueCommand("add-path",{},$);process.env.PATH=`${$}${EQ.delimiter}${process.env.PATH}`}function q9($,Q){const V=process.env[`INPUT_${$.replace(/ /g,"_").toUpperCase()}`]||"";if(Q&&Q.required&&!V)throw new Error(`Input required and not supplied: ${$}`);if(Q&&Q.trimWhitespace===!1)return V;return V.trim()}function fQ($,Q){const V=q9($,Q).split("\n").filter((X)=>X!=="");if(Q&&Q.trimWhitespace===!1)return V;return V.map((X)=>X.trim())}function cQ($,Q){const V=["true","True","TRUE"],X=["false","False","FALSE"],J=q9($,Q);if(V.includes(J))return!0;if(X.includes(J))return!1;throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${$}\nSupport boolean input list: \`true | True | TRUE | false | False | FALSE\``)}function lQ($,Q){if(process.env.GITHUB_OUTPUT||"")return d0.issueFileCommand("OUTPUT",d0.prepareKeyValueMessage($,Q));process.stdout.write(Z1.EOL),p.issueCommand("set-output",{name:$},G5.toCommandValue(Q))}function dQ($){p.issue("echo",$?"on":"off")}function iQ($){process.exitCode=K1.Failure,G1($)}function pQ(){return process.env.RUNNER_DEBUG==="1"}function aQ($){p.issueCommand("debug",{},$)}function G1($,Q={}){p.issueCommand("error",G5.toCommandProperties(Q),$ instanceof Error?$.toString():$)}function nQ($,Q={}){p.issueCommand("warning",G5.toCommandProperties(Q),$ instanceof Error?$.toString():$)}function sQ($,Q={}){p.issueCommand("notice",G5.toCommandProperties(Q),$ instanceof Error?$.toString():$)}function oQ($){process.stdout.write($+Z1.EOL)}function Y1($){p.issue("group",$)}function z1(){p.issue("endgroup")}function rQ($,Q){return J1(this,void 0,void 0,function*(){Y1($);let V;try{V=yield Q()}finally{z1()}return V})}function tQ($,Q){if(process.env.GITHUB_STATE||"")return d0.issueFileCommand("STATE",d0.prepareKeyValueMessage($,Q));p.issueCommand("save-state",{name:$},G5.toCommandValue(Q))}function eQ($){return process.env[`STATE_${$}`]||""}function $V($){return J1(this,void 0,void 0,function*(){return yield bQ.OidcClient.getIDToken($)})}var kQ=B&&B.__createBinding||(Object.create?function($,Q,V,X){if(X===void 0)X=V;Object.defineProperty($,X,{enumerable:!0,get:function(){return Q[V]}})}:function($,Q,V,X){if(X===void 0)X=V;$[X]=Q[V]}),yQ=B&&B.__setModuleDefault||(Object.create?function($,Q){Object.defineProperty($,"default",{enumerable:!0,value:Q})}:function($,Q){$.default=Q}),X1=B&&B.__importStar||function($){if($&&$.__esModule)return $;var Q={};if($!=null){for(var V in $)if(V!=="default"&&Object.hasOwnProperty.call($,V))kQ(Q,$,V)}return yQ(Q,$),Q},J1=B&&B.__awaiter||function($,Q,V,X){function J(Z){return Z instanceof V?Z:new V(function(K){K(Z)})}return new(V||(V=Promise))(function(Z,K){function G(z){try{W(X.next(z))}catch(q){K(q)}}function Y(z){try{W(X.throw(z))}catch(q){K(q)}}function W(z){z.done?Z(z.value):J(z.value).then(G,Y)}W((X=X.apply($,Q||[])).next())})};Object.defineProperty(B,"__esModule",{value:!0});B.getIDToken=B.getState=B.saveState=B.group=B.endGroup=B.startGroup=B.info=B.notice=B.warning=B.error=B.debug=B.isDebug=B.setFailed=B.setCommandEcho=B.setOutput=B.getBooleanInput=B.getMultilineInput=B.getInput=B.addPath=B.setSecret=B.exportVariable=B.ExitCode=void 0;var p=u$(),d0=y7(),G5=t5(),Z1=X1(j("os")),EQ=X1(j("path")),bQ=e7(),K1;(function($){$[$.Success=0]="Success",$[$.Failure=1]="Failure"})(K1=B.ExitCode||(B.ExitCode={}));B.exportVariable=mQ;B.setSecret=hQ;B.addPath=uQ;B.getInput=q9;B.getMultilineInput=fQ;B.getBooleanInput=cQ;B.setOutput=lQ;B.setCommandEcho=dQ;B.setFailed=iQ;B.isDebug=pQ;B.debug=aQ;B.error=G1;B.warning=nQ;B.notice=sQ;B.info=oQ;B.startGroup=Y1;B.endGroup=z1;B.group=rQ;B.saveState=tQ;B.getState=eQ;B.getIDToken=$V;var QV=W9();Object.defineProperty(B,"summary",{enumerable:!0,get:function(){return QV.summary}});var VV=W9();Object.defineProperty(B,"markdownSummary",{enumerable:!0,get:function(){return VV.markdownSummary}});var B9=V1();Object.defineProperty(B,"toPosixPath",{enumerable:!0,get:function(){return B9.toPosixPath}});Object.defineProperty(B,"toWin32Path",{enumerable:!0,get:function(){return B9.toWin32Path}});Object.defineProperty(B,"toPlatformPath",{enumerable:!0,get:function(){return B9.toPlatformPath}})});var L=C4(G9(),1);import{promises as t,createWriteStream as rX}from"fs";import{dirname as N$,join as O5,resolve as S$}from"path";import{pipeline as tX}from"stream/promises";import LV from"events";import u from"fs";import{EventEmitter as F9}from"node:events";import M1 from"node:stream";import{StringDecoder as XV}from"node:string_decoder";var W1=typeof process==="object"&&process?process:{stdout:null,stderr:null},JV=($)=>!!$&&typeof $==="object"&&($ instanceof c||$ instanceof M1||ZV($)||KV($)),ZV=($)=>!!$&&typeof $==="object"&&$ instanceof F9&&typeof $.pipe==="function"&&$.pipe!==M1.Writable.prototype.pipe,KV=($)=>!!$&&typeof $==="object"&&$ instanceof F9&&typeof $.write==="function"&&typeof $.end==="function",F0=Symbol("EOF"),H0=Symbol("maybeEmitEnd"),N0=Symbol("emittedEnd"),K8=Symbol("emittingEnd"),T5=Symbol("emittedError"),G8=Symbol("closed"),q1=Symbol("read"),Y8=Symbol("flush"),B1=Symbol("flushChunk"),Q0=Symbol("encoding"),Y5=Symbol("decoder"),S=Symbol("flowing"),C5=Symbol("paused"),z5=Symbol("resume"),_=Symbol("buffer"),b=Symbol("pipes"),R=Symbol("bufferLength"),L9=Symbol("bufferPush"),z8=Symbol("bufferShift"),k=Symbol("objectMode"),C=Symbol("destroyed"),M9=Symbol("error"),A9=Symbol("emitData"),L1=Symbol("emitEnd"),I9=Symbol("emitEnd2"),G0=Symbol("async"),w9=Symbol("abort"),W8=Symbol("aborted"),j5=Symbol("signal"),i0=Symbol("dataListeners"),f=Symbol("discarded"),D5=($)=>Promise.resolve().then($),GV=($)=>$(),YV=($)=>$==="end"||$==="finish"||$==="prefinish",zV=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,WV=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class H9{src;dest;opts;ondrain;constructor($,Q,V){this.src=$,this.dest=Q,this.opts=V,this.ondrain=()=>$[z5](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors($){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class A1 extends H9{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Q,V){super($,Q,V);this.proxyErrors=(X)=>Q.emit("error",X),$.on("error",this.proxyErrors)}}var qV=($)=>!!$.objectMode,BV=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class c extends F9{[S]=!1;[C5]=!1;[b]=[];[_]=[];[k];[Q0];[G0];[Y5];[F0]=!1;[N0]=!1;[K8]=!1;[G8]=!1;[T5]=null;[R]=0;[C]=!1;[j5];[W8]=!1;[i0]=0;[f]=!1;writable=!0;readable=!0;constructor(...$){const Q=$[0]||{};super();if(Q.objectMode&&typeof Q.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(qV(Q))this[k]=!0,this[Q0]=null;else if(BV(Q))this[Q0]=Q.encoding,this[k]=!1;else this[k]=!1,this[Q0]=null;if(this[G0]=!!Q.async,this[Y5]=this[Q0]?new XV(this[Q0]):null,Q&&Q.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[_]});if(Q&&Q.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[b]});const{signal:V}=Q;if(V)if(this[j5]=V,V.aborted)this[w9]();else V.addEventListener("abort",()=>this[w9]())}get bufferLength(){return this[R]}get encoding(){return this[Q0]}set encoding($){throw new Error("Encoding must be set at instantiation time")}setEncoding($){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[k]}set objectMode($){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[G0]}set["async"]($){this[G0]=this[G0]||!!$}[w9](){this[W8]=!0,this.emit("abort",this[j5]?.reason),this.destroy(this[j5]?.reason)}get aborted(){return this[W8]}set aborted($){}write($,Q,V){if(this[W8])return!1;if(this[F0])throw new Error("write after end");if(this[C])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Q==="function")V=Q,Q="utf8";if(!Q)Q="utf8";const X=this[G0]?D5:GV;if(!this[k]&&!Buffer.isBuffer($)){if(WV($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(zV($))$=Buffer.from($);else if(typeof $!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[k]){if(this[S]&&this[R]!==0)this[Y8](!0);if(this[S])this.emit("data",$);else this[L9]($);if(this[R]!==0)this.emit("readable");if(V)X(V);return this[S]}if(!$.length){if(this[R]!==0)this.emit("readable");if(V)X(V);return this[S]}if(typeof $==="string"&&!(Q===this[Q0]&&!this[Y5]?.lastNeed))$=Buffer.from($,Q);if(Buffer.isBuffer($)&&this[Q0])$=this[Y5].write($);if(this[S]&&this[R]!==0)this[Y8](!0);if(this[S])this.emit("data",$);else this[L9]($);if(this[R]!==0)this.emit("readable");if(V)X(V);return this[S]}read($){if(this[C])return null;if(this[f]=!1,this[R]===0||$===0||$&&$>this[R])return this[H0](),null;if(this[k])$=null;if(this[_].length>1&&!this[k])this[_]=[this[Q0]?this[_].join(""):Buffer.concat(this[_],this[R])];const Q=this[q1]($||null,this[_][0]);return this[H0](),Q}[q1]($,Q){if(this[k])this[z8]();else{const V=Q;if($===V.length||$===null)this[z8]();else if(typeof V==="string")this[_][0]=V.slice($),Q=V.slice(0,$),this[R]-=$;else this[_][0]=V.subarray($),Q=V.subarray(0,$),this[R]-=$}if(this.emit("data",Q),!this[_].length&&!this[F0])this.emit("drain");return Q}end($,Q,V){if(typeof $==="function")V=$,$=void 0;if(typeof Q==="function")V=Q,Q="utf8";if($!==void 0)this.write($,Q);if(V)this.once("end",V);if(this[F0]=!0,this.writable=!1,this[S]||!this[C5])this[H0]();return this}[z5](){if(this[C])return;if(!this[i0]&&!this[b].length)this[f]=!0;if(this[C5]=!1,this[S]=!0,this.emit("resume"),this[_].length)this[Y8]();else if(this[F0])this[H0]();else this.emit("drain")}resume(){return this[z5]()}pause(){this[S]=!1,this[C5]=!0,this[f]=!1}get destroyed(){return this[C]}get flowing(){return this[S]}get paused(){return this[C5]}[L9]($){if(this[k])this[R]+=1;else this[R]+=$.length;this[_].push($)}[z8](){if(this[k])this[R]-=1;else this[R]-=this[_][0].length;return this[_].shift()}[Y8]($=!1){do;while(this[B1](this[z8]())&&this[_].length);if(!$&&!this[_].length&&!this[F0])this.emit("drain")}[B1]($){return this.emit("data",$),this[S]}pipe($,Q){if(this[C])return $;this[f]=!1;const V=this[N0];if(Q=Q||{},$===W1.stdout||$===W1.stderr)Q.end=!1;else Q.end=Q.end!==!1;if(Q.proxyErrors=!!Q.proxyErrors,V){if(Q.end)$.end()}else if(this[b].push(!Q.proxyErrors?new H9(this,$,Q):new A1(this,$,Q)),this[G0])D5(()=>this[z5]());else this[z5]();return $}unpipe($){const Q=this[b].find((V)=>V.dest===$);if(Q){if(this[b].length===1){if(this[S]&&this[i0]===0)this[S]=!1;this[b]=[]}else this[b].splice(this[b].indexOf(Q),1);Q.unpipe()}}addListener($,Q){return this.on($,Q)}on($,Q){const V=super.on($,Q);if($==="data"){if(this[f]=!1,this[i0]++,!this[b].length&&!this[S])this[z5]()}else if($==="readable"&&this[R]!==0)super.emit("readable");else if(YV($)&&this[N0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[T5]){const X=Q;if(this[G0])D5(()=>X.call(this,this[T5]));else X.call(this,this[T5])}return V}removeListener($,Q){return this.off($,Q)}off($,Q){const V=super.off($,Q);if($==="data"){if(this[i0]=this.listeners("data").length,this[i0]===0&&!this[f]&&!this[b].length)this[S]=!1}return V}removeAllListeners($){const Q=super.removeAllListeners($);if($==="data"||$===void 0){if(this[i0]=0,!this[f]&&!this[b].length)this[S]=!1}return Q}get emittedEnd(){return this[N0]}[H0](){if(!this[K8]&&!this[N0]&&!this[C]&&this[_].length===0&&this[F0]){if(this[K8]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[G8])this.emit("close");this[K8]=!1}}emit($,...Q){const V=Q[0];if($!=="error"&&$!=="close"&&$!==C&&this[C])return!1;else if($==="data")return!this[k]&&!V?!1:this[G0]?(D5(()=>this[A9](V)),!0):this[A9](V);else if($==="end")return this[L1]();else if($==="close"){if(this[G8]=!0,!this[N0]&&!this[C])return!1;const J=super.emit("close");return this.removeAllListeners("close"),J}else if($==="error"){this[T5]=V,super.emit(M9,V);const J=!this[j5]||this.listeners("error").length?super.emit("error",V):!1;return this[H0](),J}else if($==="resume"){const J=super.emit("resume");return this[H0](),J}else if($==="finish"||$==="prefinish"){const J=super.emit($);return this.removeAllListeners($),J}const X=super.emit($,...Q);return this[H0](),X}[A9]($){for(let V of this[b])if(V.dest.write($)===!1)this.pause();const Q=this[f]?!1:super.emit("data",$);return this[H0](),Q}[L1](){if(this[N0])return!1;return this[N0]=!0,this.readable=!1,this[G0]?(D5(()=>this[I9]()),!0):this[I9]()}[I9](){if(this[Y5]){const Q=this[Y5].end();if(Q){for(let V of this[b])V.dest.write(Q);if(!this[f])super.emit("data",Q)}}for(let Q of this[b])Q.end();const $=super.emit("end");return this.removeAllListeners("end"),$}async collect(){const $=Object.assign([],{dataLength:0});if(!this[k])$.dataLength=0;const Q=this.promise();return this.on("data",(V)=>{if($.push(V),!this[k])$.dataLength+=V.length}),await Q,$}async concat(){if(this[k])throw new Error("cannot concat in objectMode");const $=await this.collect();return this[Q0]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Q)=>{this.on(C,()=>Q(new Error("stream destroyed"))),this.on("error",(V)=>Q(V)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[f]=!1;let $=!1;const Q=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Q();const X=this.read();if(X!==null)return Promise.resolve({done:!1,value:X});if(this[F0])return Q();let J,Z;const K=(z)=>{this.off("data",G),this.off("end",Y),this.off(C,W),Q(),Z(z)},G=(z)=>{this.off("error",K),this.off("end",Y),this.off(C,W),this.pause(),J({value:z,done:!!this[F0]})},Y=()=>{this.off("error",K),this.off("data",G),this.off(C,W),Q(),J({done:!0,value:void 0})},W=()=>K(new Error("stream destroyed"));return new Promise((z,q)=>{Z=q,J=z,this.once(C,W),this.once("error",K),this.once("end",Y),this.once("data",G)})},throw:Q,return:Q,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[f]=!1;let $=!1;const Q=()=>{return this.pause(),this.off(M9,Q),this.off(C,Q),this.off("end",Q),$=!0,{done:!0,value:void 0}},V=()=>{if($)return Q();const X=this.read();return X===null?Q():{done:!1,value:X}};return this.once("end",Q),this.once(M9,Q),this.once(C,Q),{next:V,throw:Q,return:Q,[Symbol.iterator](){return this}}}destroy($){if(this[C]){if($)this.emit("error",$);else this.emit(C);return this}this[C]=!0,this[f]=!0,this[_].length=0,this[R]=0;const Q=this;if(typeof Q.close==="function"&&!this[G8])Q.close();if($)this.emit("error",$);else this.emit(C);return this}static get isStream(){return JV}}var MV=u.writev,_0=Symbol("_autoClose"),X0=Symbol("_close"),N5=Symbol("_ended"),w=Symbol("_fd"),P9=Symbol("_finished"),v0=Symbol("_flags"),v9=Symbol("_flush"),T9=Symbol("_handleChunk"),C9=Symbol("_makeBuf"),_5=Symbol("_mode"),q8=Symbol("_needDrain"),B5=Symbol("_onerror"),L5=Symbol("_onopen"),O9=Symbol("_onread"),W5=Symbol("_onwrite"),R0=Symbol("_open"),V0=Symbol("_path"),S0=Symbol("_pos"),Y0=Symbol("_queue"),q5=Symbol("_read"),U9=Symbol("_readSize"),P0=Symbol("_reading"),S5=Symbol("_remain"),x9=Symbol("_size"),B8=Symbol("_write"),p0=Symbol("_writing"),L8=Symbol("_defaultFlag"),a0=Symbol("_errored");class M5 extends c{[a0]=!1;[w];[V0];[U9];[P0]=!1;[x9];[S5];[_0];constructor($,Q){Q=Q||{};super(Q);if(this.readable=!0,this.writable=!1,typeof $!=="string")throw new TypeError("path must be a string");if(this[a0]=!1,this[w]=typeof Q.fd==="number"?Q.fd:void 0,this[V0]=$,this[U9]=Q.readSize||16777216,this[P0]=!1,this[x9]=typeof Q.size==="number"?Q.size:1/0,this[S5]=this[x9],this[_0]=typeof Q.autoClose==="boolean"?Q.autoClose:!0,typeof this[w]==="number")this[q5]();else this[R0]()}get fd(){return this[w]}get path(){return this[V0]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[R0](){u.open(this[V0],"r",($,Q)=>this[L5]($,Q))}[L5]($,Q){if($)this[B5]($);else this[w]=Q,this.emit("open",Q),this[q5]()}[C9](){return Buffer.allocUnsafe(Math.min(this[U9],this[S5]))}[q5](){if(!this[P0]){this[P0]=!0;const $=this[C9]();if($.length===0)return process.nextTick(()=>this[O9](null,0,$));u.read(this[w],$,0,$.length,null,(Q,V,X)=>this[O9](Q,V,X))}}[O9]($,Q,V){if(this[P0]=!1,$)this[B5]($);else if(this[T9](Q,V))this[q5]()}[X0](){if(this[_0]&&typeof this[w]==="number"){const $=this[w];this[w]=void 0,u.close($,(Q)=>Q?this.emit("error",Q):this.emit("close"))}}[B5]($){this[P0]=!0,this[X0](),this.emit("error",$)}[T9]($,Q){let V=!1;if(this[S5]-=$,$>0)V=super.write($this[L5]($,Q))}[L5]($,Q){if(this[L8]&&this[v0]==="r+"&&$&&$.code==="ENOENT")this[v0]="w",this[R0]();else if($)this[B5]($);else if(this[w]=Q,this.emit("open",Q),!this[p0])this[v9]()}end($,Q){if($)this.write($,Q);if(this[N5]=!0,!this[p0]&&!this[Y0].length&&typeof this[w]==="number")this[W5](null,0);return this}write($,Q){if(typeof $==="string")$=Buffer.from($,Q);if(this[N5])return this.emit("error",new Error("write() after end()")),!1;if(this[w]===void 0||this[p0]||this[Y0].length)return this[Y0].push($),this[q8]=!0,!1;return this[p0]=!0,this[B8]($),!0}[B8]($){u.write(this[w],$,0,$.length,this[S0],(Q,V)=>this[W5](Q,V))}[W5]($,Q){if($)this[B5]($);else{if(this[S0]!==void 0&&typeof Q==="number")this[S0]+=Q;if(this[Y0].length)this[v9]();else if(this[p0]=!1,this[N5]&&!this[P9])this[P9]=!0,this[X0](),this.emit("finish");else if(this[q8])this[q8]=!1,this.emit("drain")}}[v9](){if(this[Y0].length===0){if(this[N5])this[W5](null,0)}else if(this[Y0].length===1)this[B8](this[Y0].pop());else{const $=this[Y0];this[Y0]=[],MV(this[w],$,this[S0],(Q,V)=>this[W5](Q,V))}}[X0](){if(this[_0]&&typeof this[w]==="number"){const $=this[w];this[w]=void 0,u.close($,(Q)=>Q?this.emit("error",Q):this.emit("close"))}}}class R5 extends g0{[R0](){let $;if(this[L8]&&this[v0]==="r+")try{$=u.openSync(this[V0],this[v0],this[_5])}catch(Q){if(Q?.code==="ENOENT")return this[v0]="w",this[R0]();else throw Q}else $=u.openSync(this[V0],this[v0],this[_5]);this[L5](null,$)}[X0](){if(this[_0]&&typeof this[w]==="number"){const $=this[w];this[w]=void 0,u.closeSync($),this.emit("close")}}[B8]($){let Q=!0;try{this[W5](null,u.writeSync(this[w],$,0,$.length,this[S0])),Q=!1}finally{if(Q)try{this[X0]()}catch{}}}}import n1 from"node:path";import w5 from"node:fs";import{dirname as pV,parse as aV}from"path";var AV=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"]]),I1=($)=>!!$.sync&&!!$.file,w1=($)=>!$.sync&&!!$.file,F1=($)=>!!$.sync&&!$.file,H1=($)=>!$.sync&&!$.file;var P1=($)=>!!$.file;var IV=($)=>{const Q=AV.get($);if(Q)return Q;return $},g5=($={})=>{if(!$)return{};const Q={};for(let[V,X]of Object.entries($)){const J=IV(V);Q[J]=X}if(Q.chmod===void 0&&Q.noChmod===!1)Q.chmod=!0;return delete Q.noChmod,Q};var z0=($,Q,V,X,J)=>{return Object.assign((Z=[],K,G)=>{if(Array.isArray(Z))K=Z,Z={};if(typeof K==="function")G=K,K=void 0;if(!K)K=[];else K=Array.from(K);const Y=g5(Z);if(J?.(Y,K),I1(Y)){if(typeof G==="function")throw new TypeError("callback not supported for sync tar functions");return $(Y,K)}else if(w1(Y)){const W=Q(Y,K),z=G?G:void 0;return z?W.then(()=>z(),z):W}else if(F1(Y)){if(typeof G==="function")throw new TypeError("callback not supported for sync tar functions");return V(Y,K)}else if(H1(Y)){if(typeof G==="function")throw new TypeError("callback only supported with file option");return X(Y,K)}else throw new Error("impossible options??")},{syncFile:$,asyncFile:Q,syncNoFile:V,asyncNoFile:X,validate:J})};import{EventEmitter as lV}from"events";import S9 from"assert";import{Buffer as k0}from"buffer";import HV from"zlib";import wV from"zlib";var FV=wV.constants||{ZLIB_VERNUM:4736},O0=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},FV));var v1=k0.concat,n0=Symbol("_superWrite");class k5 extends Error{code;errno;constructor($){super("zlib: "+$.message);if(this.code=$.code,this.errno=$.errno,!this.code)this.code="ZLIB_ERROR";this.message="zlib: "+$.message,Error.captureStackTrace(this,this.constructor)}get name(){return"ZlibError"}}var N9=Symbol("flushFlag");class _9 extends c{#$=!1;#V=!1;#X;#Z;#J;#Q;#K;get sawError(){return this.#$}get handle(){return this.#Q}get flushFlag(){return this.#X}constructor($,Q){if(!$||typeof $!=="object")throw new TypeError("invalid options for ZlibBase constructor");super($);this.#X=$.flush??0,this.#Z=$.finishFlush??0,this.#J=$.fullFlushFlag??0;try{this.#Q=new HV[Q]($)}catch(V){throw new k5(V)}this.#K=(V)=>{if(this.#$)return;this.#$=!0,this.close(),this.emit("error",V)},this.#Q?.on("error",(V)=>this.#K(new k5(V))),this.once("end",()=>this.close)}close(){if(this.#Q)this.#Q.close(),this.#Q=void 0,this.emit("close")}reset(){if(!this.#$)return S9(this.#Q,"zlib binding closed"),this.#Q.reset?.()}flush($){if(this.ended)return;if(typeof $!=="number")$=this.#J;this.write(Object.assign(k0.alloc(0),{[N9]:$}))}end($,Q,V){if(typeof $==="function")V=$,Q=void 0,$=void 0;if(typeof Q==="function")V=Q,Q=void 0;if($)if(Q)this.write($,Q);else this.write($);return this.flush(this.#Z),this.#V=!0,super.end(V)}get ended(){return this.#V}[n0]($){return super.write($)}write($,Q,V){if(typeof Q==="function")V=Q,Q="utf8";if(typeof $==="string")$=k0.from($,Q);if(this.#$)return;S9(this.#Q,"zlib binding closed");const X=this.#Q._handle,J=X.close;X.close=()=>{};const Z=this.#Q.close;this.#Q.close=()=>{},k0.concat=(Y)=>Y;let K=void 0;try{const Y=typeof $[N9]==="number"?$[N9]:this.#X;K=this.#Q._processChunk($,Y),k0.concat=v1}catch(Y){k0.concat=v1,this.#K(new k5(Y))}finally{if(this.#Q)this.#Q._handle=X,X.close=J,this.#Q.close=Z,this.#Q.removeAllListeners("error")}if(this.#Q)this.#Q.on("error",(Y)=>this.#K(new k5(Y)));let G;if(K)if(Array.isArray(K)&&K.length>0){const Y=K[0];G=this[n0](k0.from(Y));for(let W=1;W{if(typeof X==="function")J=X,X=this.flushFlag;this.flush(X),J?.()};try{this.handle.params($,Q)}finally{this.handle.flush=V}if(this.handle)this.#$=$,this.#V=Q}}}class g9 extends R9{#$;constructor($){super($,"Gzip");this.#$=$&&!!$.portable}[n0]($){if(!this.#$)return super[n0]($);return this.#$=!1,$[9]=255,super[n0]($)}}class k9 extends R9{constructor($){super($,"Unzip")}}class y9 extends _9{constructor($,Q){$=$||{},$.flush=$.flush||O0.BROTLI_OPERATION_PROCESS,$.finishFlush=$.finishFlush||O0.BROTLI_OPERATION_FINISH,$.fullFlushFlag=O0.BROTLI_OPERATION_FLUSH;super($,Q)}}class E9 extends y9{constructor($){super($,"BrotliCompress")}}class b9 extends y9{constructor($){super($,"BrotliDecompress")}}function vV($,Q,V){const X=Q,J=Q?Q.next:$.head,Z=new M8(V,X,J,$);if(Z.next===void 0)$.tail=Z;if(Z.prev===void 0)$.head=Z;return $.length++,Z}function OV($,Q){if($.tail=new M8(Q,$.tail,void 0,$),!$.head)$.head=$.tail;$.length++}function UV($,Q){if($.head=new M8(Q,void 0,$.head,$),!$.tail)$.tail=$.head;$.length++}class W0{tail;head;length=0;static create($=[]){return new W0($)}constructor($=[]){for(let Q of $)this.push(Q)}*[Symbol.iterator](){for(let $=this.head;$;$=$.next)yield $.value}removeNode($){if($.list!==this)throw new Error("removing node which does not belong to this list");const{next:Q,prev:V}=$;if(Q)Q.prev=V;if(V)V.next=Q;if($===this.head)this.head=Q;if($===this.tail)this.tail=V;return this.length--,$.next=void 0,$.prev=void 0,$.list=void 0,Q}unshiftNode($){if($===this.head)return;if($.list)$.list.removeNode($);const Q=this.head;if($.list=this,$.next=Q,Q)Q.prev=$;if(this.head=$,!this.tail)this.tail=$;this.length++}pushNode($){if($===this.tail)return;if($.list)$.list.removeNode($);const Q=this.tail;if($.list=this,$.prev=Q,Q)Q.next=$;if(this.tail=$,!this.head)this.head=$;this.length++}push(...$){for(let Q=0,V=$.length;Q1)V=Q;else if(this.head)X=this.head.next,V=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var J=0;X;J++)V=$(V,X.value,J),X=X.next;return V}reduceReverse($,Q){let V,X=this.tail;if(arguments.length>1)V=Q;else if(this.tail)X=this.tail.prev,V=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let J=this.length-1;X;J--)V=$(V,X.value,J),X=X.prev;return V}toArray(){const $=new Array(this.length);for(let Q=0,V=this.head;V;Q++)$[Q]=V.value,V=V.next;return $}toArrayReverse(){const $=new Array(this.length);for(let Q=0,V=this.tail;V;Q++)$[Q]=V.value,V=V.prev;return $}slice($=0,Q=this.length){if(Q<0)Q+=this.length;if($<0)$+=this.length;const V=new W0;if(Q<$||Q<0)return V;if($<0)$=0;if(Q>this.length)Q=this.length;let X=this.head,J=0;for(J=0;!!X&&J<$;J++)X=X.next;for(;!!X&&Jthis.length)Q=this.length;let X=this.length,J=this.tail;for(;!!J&&X>Q;X--)J=J.prev;for(;!!J&&X>$;X--,J=J.prev)V.push(J.value);return V}splice($,Q=0,...V){if($>this.length)$=this.length-1;if($<0)$=this.length+$;let X=this.head;for(let Z=0;!!X&&Z<$;Z++)X=X.next;const J=[];for(let Z=0;!!X&&Z{if(!Number.isSafeInteger($))throw Error("cannot encode number outside of javascript safe integer range");else if($<0)TV($,Q);else xV($,Q);return Q},xV=($,Q)=>{Q[0]=128;for(var V=Q.length;V>1;V--)Q[V-1]=$&255,$=Math.floor($/256)},TV=($,Q)=>{Q[0]=255;var V=!1;$=$*-1;for(var X=Q.length;X>1;X--){var J=$&255;if($=Math.floor($/256),V)Q[X-1]=x1(J);else if(J===0)Q[X-1]=0;else V=!0,Q[X-1]=T1(J)}},U1=($)=>{const Q=$[0],V=Q===128?jV($.subarray(1,$.length)):Q===255?CV($):null;if(V===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(V))throw Error("parsed number outside of javascript safe integer range");return V},CV=($)=>{var Q=$.length,V=0,X=!1;for(var J=Q-1;J>-1;J--){var Z=Number($[J]),K;if(X)K=x1(Z);else if(Z===0)K=Z;else X=!0,K=T1(Z);if(K!==0)V-=K*Math.pow(256,Q-J-1)}return V},jV=($)=>{var Q=$.length,V=0;for(var X=Q-1;X>-1;X--){var J=Number($[X]);if(J!==0)V+=J*Math.pow(256,Q-X-1)}return V},x1=($)=>(255^$)&255,T1=($)=>(255^$)+1&255;var A8=($)=>I8.has($);var I8=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"]]),C1=new Map(Array.from(I8).map(($)=>[$[1],$[0]]));class a{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#$="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor($,Q=0,V,X){if(Buffer.isBuffer($))this.decode($,Q||0,V,X);else if($)this.#V($)}decode($,Q,V,X){if(!Q)Q=0;if(!$||!($.length>=Q+512))throw new Error("need 512 bytes for header");if(this.path=s0($,Q,100),this.mode=y0($,Q+100,8),this.uid=y0($,Q+108,8),this.gid=y0($,Q+116,8),this.size=y0($,Q+124,12),this.mtime=m9($,Q+136,12),this.cksum=y0($,Q+148,12),X)this.#V(X,!0);if(V)this.#V(V);const J=s0($,Q+156,1);if(A8(J))this.#$=J||"0";if(this.#$==="0"&&this.path.slice(-1)==="/")this.#$="5";if(this.#$==="5")this.size=0;if(this.linkpath=s0($,Q+157,100),$.subarray(Q+257,Q+265).toString()==="ustar\x0000")if(this.uname=s0($,Q+265,32),this.gname=s0($,Q+297,32),this.devmaj=y0($,Q+329,8)??0,this.devmin=y0($,Q+337,8)??0,$[Q+475]!==0){const K=s0($,Q+345,155);this.path=K+"/"+this.path}else{const K=s0($,Q+345,130);if(K)this.path=K+"/"+this.path;this.atime=m9($,Q+476,12),this.ctime=m9($,Q+488,12)}let Z=256;for(let K=Q;K{return!(X===null||X===void 0||V==="path"&&Q||V==="linkpath"&&Q||V==="global")})))}encode($,Q=0){if(!$)$=this.block=Buffer.alloc(512);if(this.#$==="Unsupported")this.#$="0";if(!($.length>=Q+512))throw new Error("need 512 bytes for header");const V=this.ctime||this.atime?130:155,X=NV(this.path||"",V),J=X[0],Z=X[1];if(this.needPax=!!X[2],this.needPax=o0($,Q,100,J)||this.needPax,this.needPax=E0($,Q+100,8,this.mode)||this.needPax,this.needPax=E0($,Q+108,8,this.uid)||this.needPax,this.needPax=E0($,Q+116,8,this.gid)||this.needPax,this.needPax=E0($,Q+124,12,this.size)||this.needPax,this.needPax=h9($,Q+136,12,this.mtime)||this.needPax,$[Q+156]=this.#$.charCodeAt(0),this.needPax=o0($,Q+157,100,this.linkpath)||this.needPax,$.write("ustar\x0000",Q+257,8),this.needPax=o0($,Q+265,32,this.uname)||this.needPax,this.needPax=o0($,Q+297,32,this.gname)||this.needPax,this.needPax=E0($,Q+329,8,this.devmaj)||this.needPax,this.needPax=E0($,Q+337,8,this.devmin)||this.needPax,this.needPax=o0($,Q+345,V,Z)||this.needPax,$[Q+475]!==0)this.needPax=o0($,Q+345,155,Z)||this.needPax;else this.needPax=o0($,Q+345,130,Z)||this.needPax,this.needPax=h9($,Q+476,12,this.atime)||this.needPax,this.needPax=h9($,Q+488,12,this.ctime)||this.needPax;let K=256;for(let G=Q;G{let X=$,J="",Z=void 0;const K=A5.parse($).root||".";if(Buffer.byteLength(X)<100)Z=[X,J,!1];else{J=A5.dirname(X),X=A5.basename(X);do if(Buffer.byteLength(X)<=100&&Buffer.byteLength(J)<=Q)Z=[X,J,!1];else if(Buffer.byteLength(X)>100&&Buffer.byteLength(J)<=Q)Z=[X.slice(0,99),J,!0];else X=A5.join(A5.basename(J),X),J=A5.dirname(J);while(J!==K&&Z===void 0);if(!Z)Z=[$.slice(0,99),"",!0]}return Z},s0=($,Q,V)=>$.subarray(Q,Q+V).toString("utf8").replace(/\0.*/,""),m9=($,Q,V)=>SV(y0($,Q,V)),SV=($)=>$===void 0?void 0:new Date($*1000),y0=($,Q,V)=>Number($[Q])&128?U1($.subarray(Q,Q+V)):RV($,Q,V),_V=($)=>isNaN($)?void 0:$,RV=($,Q,V)=>_V(parseInt($.subarray(Q,Q+V).toString("utf8").replace(/\0.*$/,"").trim(),8)),gV={12:8589934591,8:2097151},E0=($,Q,V,X)=>X===void 0?!1:X>gV[V]||X<0?(O1(X,$.subarray(Q,Q+V)),!0):(kV($,Q,V,X),!1),kV=($,Q,V,X)=>$.write(yV(X,V),Q,V,"ascii"),yV=($,Q)=>EV(Math.floor($).toString(8),Q),EV=($,Q)=>($.length===Q-1?$:new Array(Q-$.length-1).join("0")+$+" ")+"\0",h9=($,Q,V,X)=>X===void 0?!1:E0($,Q,V,X.getTime()/1000),bV=new Array(156).join("\0"),o0=($,Q,V,X)=>X===void 0?!1:($.write(X+bV,Q,V,"utf8"),X.length!==Buffer.byteLength(X)||X.length>V);import{basename as mV}from"node:path";class b0{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor($,Q=!1){this.atime=$.atime,this.charset=$.charset,this.comment=$.comment,this.ctime=$.ctime,this.dev=$.dev,this.gid=$.gid,this.global=Q,this.gname=$.gname,this.ino=$.ino,this.linkpath=$.linkpath,this.mtime=$.mtime,this.nlink=$.nlink,this.path=$.path,this.size=$.size,this.uid=$.uid,this.uname=$.uname}encode(){const $=this.encodeBody();if($==="")return Buffer.allocUnsafe(0);const Q=Buffer.byteLength($),V=512*Math.ceil(1+Q/512),X=Buffer.allocUnsafe(V);for(let J=0;J<512;J++)X[J]=0;new a({path:("PaxHeader/"+mV(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:Q,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(X),X.write($,512,Q,"utf8");for(let J=Q+512;J=Math.pow(10,Z))Z+=1;return Z+J+X}static parse($,Q,V=!1){return new b0(hV(uV($),Q),V)}}var hV=($,Q)=>Q?Object.assign({},Q,$):$,uV=($)=>$.replace(/\n$/,"").split("\n").reduce(fV,Object.create(null)),fV=($,Q)=>{const V=parseInt(Q,10);if(V!==Buffer.byteLength(Q)+1)return $;Q=Q.slice((V+" ").length);const X=Q.split("="),J=X.shift();if(!J)return $;const Z=J.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),K=X.join("=");return $[Z]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(Z)?new Date(Number(K)*1000):/^[0-9]+$/.test(K)?+K:K,$};var cV=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,A=cV!=="win32"?($)=>$:($)=>$&&$.replace(/\\/g,"/");class y5 extends c{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($,Q,V){super({});switch(this.pause(),this.extended=Q,this.globalExtended=V,this.header=$,this.remain=$.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=$.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(!$.path)throw new Error("no path provided for tar.ReadEntry");if(this.path=A($.path),this.mode=$.mode,this.mode)this.mode=this.mode&4095;if(this.uid=$.uid,this.gid=$.gid,this.uname=$.uname,this.gname=$.gname,this.size=this.remain,this.mtime=$.mtime,this.atime=$.atime,this.ctime=$.ctime,this.linkpath=$.linkpath?A($.linkpath):void 0,this.uname=$.uname,this.gname=$.gname,Q)this.#$(Q);if(V)this.#$(V,!0)}write($){const Q=$.length;if(Q>this.blockRemain)throw new Error("writing more to entry than is appropriate");const V=this.remain,X=this.blockRemain;if(this.remain=Math.max(0,V-Q),this.blockRemain=Math.max(0,X-Q),this.ignore)return!0;if(V>=Q)return super.write($);return super.write($.subarray(0,V))}#$($,Q=!1){if($.path)$.path=A($.path);if($.linkpath)$.linkpath=A($.linkpath);Object.assign(this,Object.fromEntries(Object.entries($).filter(([V,X])=>{return!(X===null||X===void 0||V==="path"&&Q)})))}}var r0=($,Q,V,X={})=>{if($.file)X.file=$.file;if($.cwd)X.cwd=$.cwd;if(X.code=V instanceof Error&&V.code||Q,X.tarCode=Q,!$.strict&&X.recoverable!==!1){if(V instanceof Error)X=Object.assign(V,X),V=V.message;$.emit("warn",Q,V,X)}else if(V instanceof Error)$.emit("error",Object.assign(V,X));else $.emit("error",Object.assign(new Error(`${Q}: ${V}`),X))};var dV=1048576,u9=Buffer.from([31,139]),n=Symbol("state"),t0=Symbol("writeEntry"),U0=Symbol("readEntry"),f9=Symbol("nextEntry"),D1=Symbol("processEntry"),q0=Symbol("extendedHeader"),E5=Symbol("globalExtendedHeader"),m0=Symbol("meta"),N1=Symbol("emitMeta"),P=Symbol("buffer"),x0=Symbol("queue"),h0=Symbol("ended"),c9=Symbol("emittedEnd"),e0=Symbol("emit"),D=Symbol("unzip"),w8=Symbol("consumeChunk"),F8=Symbol("consumeChunkSub"),l9=Symbol("consumeBody"),S1=Symbol("consumeMeta"),_1=Symbol("consumeHeader"),b5=Symbol("consuming"),d9=Symbol("bufferConcat"),H8=Symbol("maybeEnd"),I5=Symbol("writing"),u0=Symbol("aborted"),P8=Symbol("onDone"),$5=Symbol("sawValidEntry"),v8=Symbol("sawNullBlock"),O8=Symbol("sawEOF"),R1=Symbol("closeStream"),iV=()=>!0;class f0 extends lV{file;strict;maxMetaEntrySize;filter;brotli;writable=!0;readable=!1;[x0]=new W0;[P];[U0];[t0];[n]="begin";[m0]="";[q0];[E5];[h0]=!1;[D];[u0]=!1;[$5];[v8]=!1;[O8]=!1;[I5]=!1;[b5]=!1;[c9]=!1;constructor($={}){super();if(this.file=$.file||"",this.on(P8,()=>{if(this[n]==="begin"||this[$5]===!1)this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),$.ondone)this.on(P8,$.ondone);else this.on(P8,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")});this.strict=!!$.strict,this.maxMetaEntrySize=$.maxMetaEntrySize||dV,this.filter=typeof $.filter==="function"?$.filter:iV;const Q=$.file&&($.file.endsWith(".tar.br")||$.file.endsWith(".tbr"));if(this.brotli=!$.gzip&&$.brotli!==void 0?$.brotli:Q?void 0:!1,this.on("end",()=>this[R1]()),typeof $.onwarn==="function")this.on("warn",$.onwarn);if(typeof $.onReadEntry==="function")this.on("entry",$.onReadEntry)}warn($,Q,V={}){r0(this,$,Q,V)}[_1]($,Q){if(this[$5]===void 0)this[$5]=!1;let V;try{V=new a($,Q,this[q0],this[E5])}catch(X){return this.warn("TAR_ENTRY_INVALID",X)}if(V.nullBlock)if(this[v8]){if(this[O8]=!0,this[n]==="begin")this[n]="header";this[e0]("eof")}else this[v8]=!0,this[e0]("nullBlock");else if(this[v8]=!1,!V.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:V});else if(!V.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:V});else{const X=V.type;if(/^(Symbolic)?Link$/.test(X)&&!V.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:V});else if(!/^(Symbolic)?Link$/.test(X)&&!/^(Global)?ExtendedHeader$/.test(X)&&V.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:V});else{const J=this[t0]=new y5(V,this[q0],this[E5]);if(!this[$5])if(J.remain){const Z=()=>{if(!J.invalid)this[$5]=!0};J.on("end",Z)}else this[$5]=!0;if(J.meta){if(J.size>this.maxMetaEntrySize)J.ignore=!0,this[e0]("ignoredEntry",J),this[n]="ignore",J.resume();else if(J.size>0)this[m0]="",J.on("data",(Z)=>this[m0]+=Z),this[n]="meta"}else if(this[q0]=void 0,J.ignore=J.ignore||!this.filter(J.path,J),J.ignore)this[e0]("ignoredEntry",J),this[n]=J.remain?"ignore":"header",J.resume();else{if(J.remain)this[n]="body";else this[n]="header",J.end();if(!this[U0])this[x0].push(J),this[f9]();else this[x0].push(J)}}}}[R1](){queueMicrotask(()=>this.emit("close"))}[D1]($){let Q=!0;if(!$)this[U0]=void 0,Q=!1;else if(Array.isArray($)){const[V,...X]=$;this.emit(V,...X)}else if(this[U0]=$,this.emit("entry",$),!$.emittedEnd)$.on("end",()=>this[f9]()),Q=!1;return Q}[f9](){do;while(this[D1](this[x0].shift()));if(!this[x0].length){const $=this[U0];if(!$||$.flowing||$.size===$.remain){if(!this[I5])this.emit("drain")}else $.once("drain",()=>this.emit("drain"))}}[l9]($,Q){const V=this[t0];if(!V)throw new Error("attempt to consume body without entry??");const X=V.blockRemain??0,J=X>=$.length&&Q===0?$:$.subarray(Q,Q+X);if(V.write(J),!V.blockRemain)this[n]="header",this[t0]=void 0,V.end();return J.length}[S1]($,Q){const V=this[t0],X=this[l9]($,Q);if(!this[t0]&&V)this[N1](V);return X}[e0]($,Q,V){if(!this[x0].length&&!this[U0])this.emit($,Q,V);else this[x0].push([$,Q,V])}[N1]($){switch(this[e0]("meta",this[m0]),$.type){case"ExtendedHeader":case"OldExtendedHeader":this[q0]=b0.parse(this[m0],this[q0],!1);break;case"GlobalExtendedHeader":this[E5]=b0.parse(this[m0],this[E5],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{const Q=this[q0]??Object.create(null);this[q0]=Q,Q.path=this[m0].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{const Q=this[q0]||Object.create(null);this[q0]=Q,Q.linkpath=this[m0].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+$.type)}}abort($){this[u0]=!0,this.emit("abort",$),this.warn("TAR_ABORT",$,{recoverable:!1})}write($,Q,V){if(typeof Q==="function")V=Q,Q=void 0;if(typeof $==="string")$=Buffer.from($,typeof Q==="string"?Q:"utf8");if(this[u0])return V?.(),!1;if((this[D]===void 0||this.brotli===void 0&&this[D]===!1)&&$){if(this[P])$=Buffer.concat([this[P],$]),this[P]=void 0;if($.lengththis[w8](Y)),this[D].on("error",(Y)=>this.abort(Y)),this[D].on("end",()=>{this[h0]=!0,this[w8]()}),this[I5]=!0;const G=!!this[D][K?"end":"write"]($);return this[I5]=!1,V?.(),G}}if(this[I5]=!0,this[D])this[D].write($);else this[w8]($);this[I5]=!1;const J=this[x0].length?!1:this[U0]?this[U0].flowing:!0;if(!J&&!this[x0].length)this[U0]?.once("drain",()=>this.emit("drain"));return V?.(),J}[d9]($){if($&&!this[u0])this[P]=this[P]?Buffer.concat([this[P],$]):$}[H8](){if(this[h0]&&!this[c9]&&!this[u0]&&!this[b5]){this[c9]=!0;const $=this[t0];if($&&$.blockRemain){const Q=this[P]?this[P].length:0;if(this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${$.blockRemain} more bytes, only ${Q} available)`,{entry:$}),this[P])$.write(this[P]);$.end()}this[e0](P8)}}[w8]($){if(this[b5]&&$)this[d9]($);else if(!$&&!this[P])this[H8]();else if($){if(this[b5]=!0,this[P]){this[d9]($);const Q=this[P];this[P]=void 0,this[F8](Q)}else this[F8]($);while(this[P]&&this[P]?.length>=512&&!this[u0]&&!this[O8]){const Q=this[P];this[P]=void 0,this[F8](Q)}this[b5]=!1}if(!this[P]||this[h0])this[H8]()}[F8]($){let Q=0;const V=$.length;while(Q+512<=V&&!this[u0]&&!this[O8])switch(this[n]){case"begin":case"header":this[_1]($,Q),Q+=512;break;case"ignore":case"body":Q+=this[l9]($,Q);break;case"meta":Q+=this[S1]($,Q);break;default:throw new Error("invalid state: "+this[n])}if(Q{let Q=$.length-1,V=-1;while(Q>-1&&$.charAt(Q)==="/")V=Q,Q--;return V===-1?$:$.slice(0,V)};var nV=($)=>{const Q=$.onReadEntry;$.onReadEntry=Q?(V)=>{Q(V),V.resume()}:(V)=>V.resume()},i9=($,Q)=>{const V=new Map(Q.map((Z)=>[B0(Z),!0])),X=$.filter,J=(Z,K="")=>{const G=K||aV(Z).root||".";let Y;if(Z===G)Y=!1;else{const W=V.get(Z);if(W!==void 0)Y=W;else Y=J(pV(Z),G)}return V.set(Z,Y),Y};$.filter=X?(Z,K)=>X(Z,K)&&J(B0(Z)):(Z)=>J(B0(Z))},sV=($)=>{const Q=new f0($),V=$.file;let X;try{const J=w5.statSync(V),Z=$.maxReadSize||16777216;if(J.size{const V=new f0($),X=$.maxReadSize||16777216,J=$.file;return new Promise((K,G)=>{V.on("error",G),V.on("end",K),w5.stat(J,(Y,W)=>{if(Y)G(Y);else{const z=new M5(J,{readSize:X,size:W.size});z.on("error",G),z.pipe(V)}})})},Q5=z0(sV,oV,($)=>new f0($),($)=>new f0($),($,Q)=>{if(Q?.length)i9($,Q);if(!$.noResume)nV($)});import g8 from"fs";import L0 from"fs";import E1 from"path";var p9=($,Q,V)=>{if($&=4095,V)$=($|384)&-19;if(Q){if($&256)$|=64;if($&32)$|=8;if($&4)$|=1}return $};import{win32 as rV}from"node:path";var{isAbsolute:tV,parse:g1}=rV,m5=($)=>{let Q="",V=g1($);while(tV($)||V.root){const X=$.charAt(0)==="/"&&$.slice(0,4)!=="//?/"?"/":V.root;$=$.slice(X.length),Q+=X,V=g1($)}return[Q,$]};var U8=["|","<",">","?",":"],a9=U8.map(($)=>String.fromCharCode(61440+$.charCodeAt(0))),eV=new Map(U8.map(($,Q)=>[$,a9[Q]])),$X=new Map(a9.map(($,Q)=>[$,U8[Q]])),n9=($)=>U8.reduce((Q,V)=>Q.split(V).join(eV.get(V)),$),k1=($)=>a9.reduce((Q,V)=>Q.split(V).join($X.get(V)),$);var f1=($,Q)=>{if(!Q)return A($);return $=A($).replace(/^\.(\/|$)/,""),B0(Q)+"/"+$},QX=16777216,b1=Symbol("process"),m1=Symbol("file"),h1=Symbol("directory"),o9=Symbol("symlink"),u1=Symbol("hardlink"),h5=Symbol("header"),x8=Symbol("read"),r9=Symbol("lstat"),T8=Symbol("onlstat"),t9=Symbol("onread"),e9=Symbol("onreadlink"),$$=Symbol("openfile"),Q$=Symbol("onopenfile"),c0=Symbol("close"),C8=Symbol("mode"),V$=Symbol("awaitDrain"),s9=Symbol("ondrain"),M0=Symbol("prefix");class j8 extends c{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;#$=!1;constructor($,Q={}){const V=g5(Q);super();if(this.path=A($),this.portable=!!V.portable,this.maxReadSize=V.maxReadSize||QX,this.linkCache=V.linkCache||new Map,this.statCache=V.statCache||new Map,this.preservePaths=!!V.preservePaths,this.cwd=A(V.cwd||process.cwd()),this.strict=!!V.strict,this.noPax=!!V.noPax,this.noMtime=!!V.noMtime,this.mtime=V.mtime,this.prefix=V.prefix?A(V.prefix):void 0,typeof V.onwarn==="function")this.on("warn",V.onwarn);let X=!1;if(!this.preservePaths){const[Z,K]=m5(this.path);if(Z&&typeof K==="string")this.path=K,X=Z}if(this.win32=!!V.win32||process.platform==="win32",this.win32)this.path=k1(this.path.replace(/\\/g,"/")),$=$.replace(/\\/g,"/");if(this.absolute=A(V.absolute||E1.resolve(this.cwd,$)),this.path==="")this.path="./";if(X)this.warn("TAR_ENTRY_INFO",`stripping ${X} from absolute path`,{entry:this,path:X+this.path});const J=this.statCache.get(this.absolute);if(J)this[T8](J);else this[r9]()}warn($,Q,V={}){return r0(this,$,Q,V)}emit($,...Q){if($==="error")this.#$=!0;return super.emit($,...Q)}[r9](){L0.lstat(this.absolute,($,Q)=>{if($)return this.emit("error",$);this[T8](Q)})}[T8]($){if(this.statCache.set(this.absolute,$),this.stat=$,!$.isFile())$.size=0;this.type=VX($),this.emit("stat",$),this[b1]()}[b1](){switch(this.type){case"File":return this[m1]();case"Directory":return this[h1]();case"SymbolicLink":return this[o9]();default:return this.end()}}[C8]($){return p9($,this.type==="Directory",this.portable)}[M0]($){return f1($,this.prefix)}[h5](){if(!this.stat)throw new Error("cannot write header before stat");if(this.type==="Directory"&&this.portable)this.noMtime=!0;if(this.header=new a({path:this[M0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[M0](this.linkpath):this.linkpath,mode:this[C8](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 b0({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[M0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[M0](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 $=this.header?.block;if(!$)throw new Error("failed to encode header");super.write($)}[h1](){if(!this.stat)throw new Error("cannot create directory entry without stat");if(this.path.slice(-1)!=="/")this.path+="/";this.stat.size=0,this[h5](),this.end()}[o9](){L0.readlink(this.absolute,($,Q)=>{if($)return this.emit("error",$);this[e9](Q)})}[e9]($){this.linkpath=A($),this[h5](),this.end()}[u1]($){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=A(E1.relative(this.cwd,$)),this.stat.size=0,this[h5](),this.end()}[m1](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){const $=`${this.stat.dev}:${this.stat.ino}`,Q=this.linkCache.get($);if(Q?.indexOf(this.cwd)===0)return this[u1](Q);this.linkCache.set($,this.absolute)}if(this[h5](),this.stat.size===0)return this.end();this[$$]()}[$$](){L0.open(this.absolute,"r",($,Q)=>{if($)return this.emit("error",$);this[Q$](Q)})}[Q$]($){if(this.fd=$,this.#$)return this[c0]();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 Q=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(Q),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[x8]()}[x8](){const{fd:$,buf:Q,offset:V,length:X,pos:J}=this;if($===void 0||Q===void 0)throw new Error("cannot read file without first opening");L0.read($,Q,V,X,J,(Z,K)=>{if(Z)return this[c0](()=>this.emit("error",Z));this[t9](K)})}[c0]($=()=>{}){if(this.fd!==void 0)L0.close(this.fd,$)}[t9]($){if($<=0&&this.remain>0){const X=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[c0](()=>this.emit("error",X))}if($>this.remain){const X=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[c0](()=>this.emit("error",X))}if(!this.buf)throw new Error("should have created buffer prior to reading");if($===this.remain)for(let X=$;Xthis[s9]());else this[s9]()}[V$]($){this.once("drain",$)}write($,Q,V){if(typeof Q==="function")V=Q,Q=void 0;if(typeof $==="string")$=Buffer.from($,typeof Q==="string"?Q:"utf8");if(this.blockRemain<$.length){const X=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",X)}return this.remain-=$.length,this.blockRemain-=$.length,this.pos+=$.length,this.offset+=$.length,super.write($,null,V)}[s9](){if(!this.remain){if(this.blockRemain)super.write(Buffer.alloc(this.blockRemain));return this[c0](($)=>$?this.emit("error",$):this.end())}if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");if(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[x8]()}}class X$ extends j8{sync=!0;[r9](){this[T8](L0.lstatSync(this.absolute))}[o9](){this[e9](L0.readlinkSync(this.absolute))}[$$](){this[Q$](L0.openSync(this.absolute,"r"))}[x8](){let $=!0;try{const{fd:Q,buf:V,offset:X,length:J,pos:Z}=this;if(Q===void 0||V===void 0)throw new Error("fd and buf must be set in READ method");const K=L0.readSync(Q,V,X,J,Z);this[t9](K),$=!1}finally{if($)try{this[c0](()=>{})}catch(Q){}}}[V$]($){$()}[c0]($=()=>{}){if(this.fd!==void 0)L0.closeSync(this.fd);$()}}class J$ extends c{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;warn($,Q,V={}){return r0(this,$,Q,V)}constructor($,Q={}){const V=g5(Q);super();this.preservePaths=!!V.preservePaths,this.portable=!!V.portable,this.strict=!!V.strict,this.noPax=!!V.noPax,this.noMtime=!!V.noMtime,this.readEntry=$;const{type:X}=$;if(X==="Unsupported")throw new Error("writing entry that should be ignored");if(this.type=X,this.type==="Directory"&&this.portable)this.noMtime=!0;if(this.prefix=V.prefix,this.path=A($.path),this.mode=$.mode!==void 0?this[C8]($.mode):void 0,this.uid=this.portable?void 0:$.uid,this.gid=this.portable?void 0:$.gid,this.uname=this.portable?void 0:$.uname,this.gname=this.portable?void 0:$.gname,this.size=$.size,this.mtime=this.noMtime?void 0:V.mtime||$.mtime,this.atime=this.portable?void 0:$.atime,this.ctime=this.portable?void 0:$.ctime,this.linkpath=$.linkpath!==void 0?A($.linkpath):void 0,typeof V.onwarn==="function")this.on("warn",V.onwarn);let J=!1;if(!this.preservePaths){const[K,G]=m5(this.path);if(K&&typeof G==="string")this.path=G,J=K}if(this.remain=$.size,this.blockRemain=$.startBlockSize,this.header=new a({path:this[M0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[M0](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}),J)this.warn("TAR_ENTRY_INFO",`stripping ${J} from absolute path`,{entry:this,path:J+this.path});if(this.header.encode()&&!this.noPax)super.write(new b0({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[M0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[M0](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 Z=this.header?.block;if(!Z)throw new Error("failed to encode header");super.write(Z),$.pipe(this)}[M0]($){return f1($,this.prefix)}[C8]($){return p9($,this.type==="Directory",this.portable)}write($,Q,V){if(typeof Q==="function")V=Q,Q=void 0;if(typeof $==="string")$=Buffer.from($,typeof Q==="string"?Q:"utf8");const X=$.length;if(X>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=X,super.write($,V)}end($,Q,V){if(this.blockRemain)super.write(Buffer.alloc(this.blockRemain));if(typeof $==="function")V=$,Q=void 0,$=void 0;if(typeof Q==="function")V=Q,Q=void 0;if(typeof $==="string")$=Buffer.from($,Q??"utf8");if(V)this.once("finish",V);return $?super.end($,V):super.end(V),this}}var VX=($)=>$.isFile()?"File":$.isDirectory()?"Directory":$.isSymbolicLink()?"SymbolicLink":"Unsupported";import p1 from"path";class Y${path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor($,Q){this.path=$||"./",this.absolute=Q}}var c1=Buffer.alloc(1024),D8=Symbol("onStat"),u5=Symbol("ended"),J0=Symbol("queue"),F5=Symbol("current"),V5=Symbol("process"),f5=Symbol("processing"),l1=Symbol("processJob"),Z0=Symbol("jobs"),Z$=Symbol("jobDone"),N8=Symbol("addFSEntry"),d1=Symbol("addTarEntry"),z$=Symbol("stat"),W$=Symbol("readdir"),S8=Symbol("onreaddir"),_8=Symbol("pipe"),i1=Symbol("entry"),K$=Symbol("entryOpt"),R8=Symbol("writeEntryClass"),a1=Symbol("write"),G$=Symbol("ondrain");class X5 extends c{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[R8];onWriteEntry;[J0];[Z0]=0;[f5]=!1;[u5]=!1;constructor($={}){super();if(this.opt=$,this.file=$.file||"",this.cwd=$.cwd||process.cwd(),this.maxReadSize=$.maxReadSize,this.preservePaths=!!$.preservePaths,this.strict=!!$.strict,this.noPax=!!$.noPax,this.prefix=A($.prefix||""),this.linkCache=$.linkCache||new Map,this.statCache=$.statCache||new Map,this.readdirCache=$.readdirCache||new Map,this.onWriteEntry=$.onWriteEntry,this[R8]=j8,typeof $.onwarn==="function")this.on("warn",$.onwarn);if(this.portable=!!$.portable,$.gzip||$.brotli){if($.gzip&&$.brotli)throw new TypeError("gzip and brotli are mutually exclusive");if($.gzip){if(typeof $.gzip!=="object")$.gzip={};if(this.portable)$.gzip.portable=!0;this.zip=new g9($.gzip)}if($.brotli){if(typeof $.brotli!=="object")$.brotli={};this.zip=new E9($.brotli)}if(!this.zip)throw new Error("impossible");const Q=this.zip;Q.on("data",(V)=>super.write(V)),Q.on("end",()=>super.end()),Q.on("drain",()=>this[G$]()),this.on("resume",()=>Q.resume())}else this.on("drain",this[G$]);if(this.noDirRecurse=!!$.noDirRecurse,this.follow=!!$.follow,this.noMtime=!!$.noMtime,$.mtime)this.mtime=$.mtime;this.filter=typeof $.filter==="function"?$.filter:()=>!0,this[J0]=new W0,this[Z0]=0,this.jobs=Number($.jobs)||4,this[f5]=!1,this[u5]=!1}[a1]($){return super.write($)}add($){return this.write($),this}end($){if($)this.add($);return this[u5]=!0,this[V5](),this}write($){if(this[u5])throw new Error("write after end");if($ instanceof y5)this[d1]($);else this[N8]($);return this.flowing}[d1]($){const Q=A(p1.resolve(this.cwd,$.path));if(!this.filter($.path,$))$.resume();else{const V=new Y$($.path,Q);V.entry=new J$($,this[K$](V)),V.entry.on("end",()=>this[Z$](V)),this[Z0]+=1,this[J0].push(V)}this[V5]()}[N8]($){const Q=A(p1.resolve(this.cwd,$));this[J0].push(new Y$($,Q)),this[V5]()}[z$]($){$.pending=!0,this[Z0]+=1;const Q=this.follow?"stat":"lstat";g8[Q]($.absolute,(V,X)=>{if($.pending=!1,this[Z0]-=1,V)this.emit("error",V);else this[D8]($,X)})}[D8]($,Q){if(this.statCache.set($.absolute,Q),$.stat=Q,!this.filter($.path,Q))$.ignore=!0;this[V5]()}[W$]($){$.pending=!0,this[Z0]+=1,g8.readdir($.absolute,(Q,V)=>{if($.pending=!1,this[Z0]-=1,Q)return this.emit("error",Q);this[S8]($,V)})}[S8]($,Q){this.readdirCache.set($.absolute,Q),$.readdir=Q,this[V5]()}[V5](){if(this[f5])return;this[f5]=!0;for(let $=this[J0].head;!!$&&this[Z0]this.warn(Q,V,X),noPax:this.noPax,cwd:this.cwd,absolute:$.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}}[i1]($){this[Z0]+=1;try{const Q=new this[R8]($.path,this[K$]($));return this.onWriteEntry?.(Q),Q.on("end",()=>this[Z$]($)).on("error",(V)=>this.emit("error",V))}catch(Q){this.emit("error",Q)}}[G$](){if(this[F5]&&this[F5].entry)this[F5].entry.resume()}[_8]($){if($.piped=!0,$.readdir)$.readdir.forEach((X)=>{const J=$.path,Z=J==="./"?"":J.replace(/\/*$/,"/");this[N8](Z+X)});const Q=$.entry,V=this.zip;if(!Q)throw new Error("cannot pipe without source");if(V)Q.on("data",(X)=>{if(!V.write(X))Q.pause()});else Q.on("data",(X)=>{if(!super.write(X))Q.pause()})}pause(){if(this.zip)this.zip.pause();return super.pause()}warn($,Q,V={}){r0(this,$,Q,V)}}class H5 extends X5{sync=!0;constructor($){super($);this[R8]=X$}pause(){}resume(){}[z$]($){const Q=this.follow?"statSync":"lstatSync";this[D8]($,g8[Q]($.absolute))}[W$]($){this[S8]($,g8.readdirSync($.absolute))}[_8]($){const Q=$.entry,V=this.zip;if($.readdir)$.readdir.forEach((X)=>{const J=$.path,Z=J==="./"?"":J.replace(/\/*$/,"/");this[N8](Z+X)});if(!Q)throw new Error("Cannot pipe without source");if(V)Q.on("data",(X)=>{V.write(X)});else Q.on("data",(X)=>{super[a1](X)})}}var XX=($,Q)=>{const V=new H5($),X=new R5($.file,{mode:$.mode||438});V.pipe(X),s1(V,Q)},JX=($,Q)=>{const V=new X5($),X=new g0($.file,{mode:$.mode||438});V.pipe(X);const J=new Promise((Z,K)=>{X.on("error",K),X.on("close",Z),V.on("error",K)});return o1(V,Q),J},s1=($,Q)=>{Q.forEach((V)=>{if(V.charAt(0)==="@")Q5({file:n1.resolve($.cwd,V.slice(1)),sync:!0,noResume:!0,onReadEntry:(X)=>$.add(X)});else $.add(V)}),$.end()},o1=async($,Q)=>{for(let V=0;V{$.add(J)}});else $.add(X)}$.end()},ZX=($,Q)=>{const V=new H5($);return s1(V,Q),V},KX=($,Q)=>{const V=new X5($);return o1(V,Q),V},GX=z0(XX,JX,ZX,KX,($,Q)=>{if(!Q?.length)throw new TypeError("no paths specified to add to archive")});import F4 from"node:fs";import kX from"node:assert";import{randomBytes as w4}from"node:crypto";import I from"node:fs";import C0 from"node:path";import r1 from"fs";var YX=process.env.__FAKE_PLATFORM__||process.platform,zX=YX==="win32",{O_CREAT:WX,O_TRUNC:qX,O_WRONLY:BX}=r1.constants,t1=Number(process.env.__FAKE_FS_O_FILENAME__)||r1.constants.UV_FS_O_FILEMAP||0,LX=zX&&!!t1,MX=524288,AX=t1|qX|WX|BX,q$=!LX?()=>"w":($)=>${try{return y8.lchownSync($,Q,V)}catch(X){if(X?.code!=="ENOENT")throw X}},k8=($,Q,V,X)=>{y8.lchown($,Q,V,(J)=>{X(J&&J?.code!=="ENOENT"?J:null)})},IX=($,Q,V,X,J)=>{if(Q.isDirectory())L$(c5.resolve($,Q.name),V,X,(Z)=>{if(Z)return J(Z);const K=c5.resolve($,Q.name);k8(K,V,X,J)});else{const Z=c5.resolve($,Q.name);k8(Z,V,X,J)}},L$=($,Q,V,X)=>{y8.readdir($,{withFileTypes:!0},(J,Z)=>{if(J){if(J.code==="ENOENT")return X();else if(J.code!=="ENOTDIR"&&J.code!=="ENOTSUP")return X(J)}if(J||!Z.length)return k8($,Q,V,X);let K=Z.length,G=null;const Y=(W)=>{if(G)return;if(W)return X(G=W);if(--K===0)return k8($,Q,V,X)};for(let W of Z)IX($,W,Q,V,Y)})},wX=($,Q,V,X)=>{if(Q.isDirectory())M$(c5.resolve($,Q.name),V,X);B$(c5.resolve($,Q.name),V,X)},M$=($,Q,V)=>{let X;try{X=y8.readdirSync($,{withFileTypes:!0})}catch(J){const Z=J;if(Z?.code==="ENOENT")return;else if(Z?.code==="ENOTDIR"||Z?.code==="ENOTSUP")return B$($,Q,V);else throw Z}for(let J of X)wX($,J,Q,V);return B$($,Q,V)};import o from"fs";import{dirname as e1}from"path";import{mkdir as FX,mkdirSync as HX,stat as PX,statSync as vX}from"fs";var s=($)=>{if(!$)$={mode:511};else if(typeof $==="object")$={mode:511,...$};else if(typeof $==="number")$={mode:$};else if(typeof $==="string")$={mode:parseInt($,8)};else throw new TypeError("invalid options argument");const Q=$,V=$.fs||{};return $.mkdir=$.mkdir||V.mkdir||FX,$.mkdirAsync=$.mkdirAsync?$.mkdirAsync:async(X,J)=>{return new Promise((Z,K)=>Q.mkdir(X,J,(G,Y)=>G?K(G):Z(Y)))},$.stat=$.stat||V.stat||PX,$.statAsync=$.statAsync?$.statAsync:async(X)=>new Promise((J,Z)=>Q.stat(X,(K,G)=>K?Z(K):J(G))),$.statSync=$.statSync||V.statSync||vX,$.mkdirSync=$.mkdirSync||V.mkdirSync||HX,Q};var A0=($,Q,V)=>{const X=e1($),J={...s(Q),recursive:!1};if(X===$)try{return J.mkdirSync($,J)}catch(Z){const K=Z;if(K&&K.code!=="EISDIR")throw Z;return}try{return J.mkdirSync($,J),V||$}catch(Z){const K=Z;if(K&&K.code==="ENOENT")return A0($,J,A0(X,J,V));if(K&&K.code!=="EEXIST"&&K&&K.code!=="EROFS")throw Z;try{if(!J.statSync($).isDirectory())throw Z}catch(G){throw Z}}},T0=Object.assign(async($,Q,V)=>{const X=s(Q);X.recursive=!1;const J=e1($);if(J===$)return X.mkdirAsync($,X).catch((Z)=>{const K=Z;if(K&&K.code!=="EISDIR")throw Z});return X.mkdirAsync($,X).then(()=>V||$,async(Z)=>{const K=Z;if(K&&K.code==="ENOENT")return T0(J,X).then((G)=>T0($,X,G));if(K&&K.code!=="EEXIST"&&K.code!=="EROFS")throw Z;return X.statAsync($).then((G)=>{if(G.isDirectory())return V;else throw Z},()=>{throw Z})})},{sync:A0});import{dirname as Q4}from"path";import{dirname as $4}from"path";var A$=async($,Q,V)=>{if(V===Q)return;return $.statAsync(Q).then((X)=>X.isDirectory()?V:void 0,(X)=>{const J=X;return J&&J.code==="ENOENT"?A$($,$4(Q),Q):void 0})},I$=($,Q,V)=>{if(V===Q)return;try{return $.statSync(Q).isDirectory()?V:void 0}catch(X){const J=X;return J&&J.code==="ENOENT"?I$($,$4(Q),Q):void 0}};var P5=($,Q)=>{const V=s(Q);if(V.recursive=!0,Q4($)===$)return V.mkdirSync($,V);const J=I$(V,$);try{return V.mkdirSync($,V),J}catch(Z){const K=Z;if(K&&K.code==="ENOENT")return A0($,V);else throw Z}},l5=Object.assign(async($,Q)=>{const V={...s(Q),recursive:!0};if(Q4($)===$)return await V.mkdirAsync($,V);return A$(V,$).then((J)=>V.mkdirAsync($,V).then((Z)=>J||Z).catch((Z)=>{const K=Z;if(K&&K.code==="ENOENT")return T0($,V);else throw Z}))},{sync:P5});import{parse as UX,resolve as xX}from"path";var OX=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,w$=($)=>{if(/\0/.test($))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:$,code:"ERR_INVALID_ARG_VALUE"});if($=xX($),OX==="win32"){const Q=/[*|"<>?:]/,{root:V}=UX($);if(Q.test($.substring(V.length)))throw Object.assign(new Error("Illegal characters in path."),{path:$,code:"EINVAL"})}return $};import{mkdir as TX,mkdirSync as CX}from"fs";var jX=process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version,F$=jX.replace(/^v/,"").split("."),V4=+F$[0]>10||+F$[0]===10&&+F$[1]>=12,d5=!V4?()=>!1:($)=>s($).mkdirSync===CX,E8=Object.assign(!V4?()=>!1:($)=>s($).mkdir===TX,{sync:d5});var b8=($,Q)=>{$=w$($);const V=s(Q);return d5(V)?P5($,V):A0($,V)};var X4=Object.assign(async($,Q)=>{$=w$($);const V=s(Q);return E8(V)?l5($,V):T0($,V)},{mkdirpSync:b8,mkdirpNative:l5,mkdirpNativeSync:P5,mkdirpManual:T0,mkdirpManualSync:A0,sync:b8,native:l5,nativeSync:P5,manual:T0,manualSync:A0,useNative:E8,useNativeSync:d5});import u8 from"node:path";class m8 extends Error{path;code;syscall="chdir";constructor($,Q){super(`${Q}: Cannot cd into '${$}'`);this.path=$,this.code=Q}get name(){return"CwdError"}}class h8 extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor($,Q){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link");this.symlink=$,this.path=Q}get name(){return"SymlinkError"}}var f8=($,Q)=>$.get(A(Q)),i5=($,Q,V)=>$.set(A(Q),V),DX=($,Q)=>{o.stat($,(V,X)=>{if(V||!X.isDirectory())V=new m8($,V?.code||"ENOTDIR");Q(V)})},J4=($,Q,V)=>{$=A($);const X=Q.umask??18,J=Q.mode|448,Z=(J&X)!==0,K=Q.uid,G=Q.gid,Y=typeof K==="number"&&typeof G==="number"&&(K!==Q.processUid||G!==Q.processGid),W=Q.preserve,z=Q.unlink,q=Q.cache,M=A(Q.cwd),O=(N,x)=>{if(N)V(N);else if(i5(q,$,!0),x&&Y)L$(x,K,G,(_$)=>O(_$));else if(Z)o.chmod($,J,V);else V()};if(q&&f8(q,$)===!0)return O();if($===M)return DX($,O);if(W)return X4($,{mode:J}).then((N)=>O(null,N??void 0),O);const v=A(u8.relative(M,$)).split("/");c8(M,v,J,q,z,M,void 0,O)},c8=($,Q,V,X,J,Z,K,G)=>{if(!Q.length)return G(null,K);const Y=Q.shift(),W=A(u8.resolve($+"/"+Y));if(f8(X,W))return c8(W,Q,V,X,J,Z,K,G);o.mkdir(W,V,Z4(W,Q,V,X,J,Z,K,G))},Z4=($,Q,V,X,J,Z,K,G)=>(Y)=>{if(Y)o.lstat($,(W,z)=>{if(W)W.path=W.path&&A(W.path),G(W);else if(z.isDirectory())c8($,Q,V,X,J,Z,K,G);else if(J)o.unlink($,(q)=>{if(q)return G(q);o.mkdir($,V,Z4($,Q,V,X,J,Z,K,G))});else if(z.isSymbolicLink())return G(new h8($,$+"/"+Q.join("/")));else G(Y)});else K=K||$,c8($,Q,V,X,J,Z,K,G)},NX=($)=>{let Q=!1,V=void 0;try{Q=o.statSync($).isDirectory()}catch(X){V=X?.code}finally{if(!Q)throw new m8($,V??"ENOTDIR")}},K4=($,Q)=>{$=A($);const V=Q.umask??18,X=Q.mode|448,J=(X&V)!==0,Z=Q.uid,K=Q.gid,G=typeof Z==="number"&&typeof K==="number"&&(Z!==Q.processUid||K!==Q.processGid),Y=Q.preserve,W=Q.unlink,z=Q.cache,q=A(Q.cwd),M=(N)=>{if(i5(z,$,!0),N&&G)M$(N,Z,K);if(J)o.chmodSync($,X)};if(z&&f8(z,$)===!0)return M();if($===q)return NX(q),M();if(Y)return M(b8($,X)??void 0);const U=A(u8.relative(q,$)).split("/");let v=void 0;for(let N=U.shift(),x=q;N&&(x+="/"+N);N=U.shift()){if(x=A(u8.resolve(x)),f8(z,x))continue;try{o.mkdirSync(x,X),v=v||x,i5(z,x,!0)}catch(_$){const R$=o.lstatSync(x);if(R$.isDirectory()){i5(z,x,!0);continue}else if(W){o.unlinkSync(x),o.mkdirSync(x,X),v=v||x,i5(z,x,!0);continue}else if(R$.isSymbolicLink())return new h8(x,x+"/"+U.join("/"))}}return M(v)};var H$=Object.create(null),{hasOwnProperty:SX}=Object.prototype,l8=($)=>{if(!SX.call(H$,$))H$[$]=$.normalize("NFD");return H$[$]};import{join as G4}from"node:path";var _X=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,RX=_X==="win32",gX=($)=>{return $.split("/").slice(0,-1).reduce((V,X)=>{const J=V[V.length-1];if(J!==void 0)X=G4(J,X);return V.push(X||"/"),V},[])};class P${#$=new Map;#V=new Map;#X=new Set;reserve($,Q){$=RX?["win32 parallelization disabled"]:$.map((X)=>{return B0(G4(l8(X))).toLowerCase()});const V=new Set($.map((X)=>gX(X)).reduce((X,J)=>X.concat(J)));this.#V.set(Q,{dirs:V,paths:$});for(let X of $){const J=this.#$.get(X);if(!J)this.#$.set(X,[Q]);else J.push(Q)}for(let X of V){const J=this.#$.get(X);if(!J)this.#$.set(X,[new Set([Q])]);else{const Z=J[J.length-1];if(Z instanceof Set)Z.add(Q);else J.push(new Set([Q]))}}return this.#J(Q)}#Z($){const Q=this.#V.get($);if(!Q)throw new Error("function does not have any path reservations");return{paths:Q.paths.map((V)=>this.#$.get(V)),dirs:[...Q.dirs].map((V)=>this.#$.get(V))}}check($){const{paths:Q,dirs:V}=this.#Z($);return Q.every((X)=>X&&X[0]===$)&&V.every((X)=>X&&X[0]instanceof Set&&X[0].has($))}#J($){if(this.#X.has($)||!this.check($))return!1;return this.#X.add($),$(()=>this.#Q($)),!0}#Q($){if(!this.#X.has($))return!1;const Q=this.#V.get($);if(!Q)throw new Error("invalid reservation");const{paths:V,dirs:X}=Q,J=new Set;for(let Z of V){const K=this.#$.get(Z);if(!K||K?.[0]!==$)continue;const G=K[1];if(!G){this.#$.delete(Z);continue}if(K.shift(),typeof G==="function")J.add(G);else for(let Y of G)J.add(Y)}for(let Z of X){const K=this.#$.get(Z),G=K?.[0];if(!K||!(G instanceof Set))continue;if(G.size===1&&K.length===1){this.#$.delete(Z);continue}else if(G.size===1){K.shift();const Y=K[0];if(typeof Y==="function")J.add(Y)}else G.delete($)}return this.#X.delete($),J.forEach((Z)=>this.#J(Z)),!0}}var Y4=Symbol("onEntry"),U$=Symbol("checkFs"),z4=Symbol("checkFs2"),p8=Symbol("pruneCache"),x$=Symbol("isReusable"),r=Symbol("makeFs"),T$=Symbol("file"),C$=Symbol("directory"),a8=Symbol("link"),W4=Symbol("symlink"),q4=Symbol("hardlink"),B4=Symbol("unsupported"),L4=Symbol("checkPath"),l0=Symbol("mkdir"),y=Symbol("onError"),d8=Symbol("pending"),M4=Symbol("pend"),v5=Symbol("unpend"),v$=Symbol("ended"),O$=Symbol("maybeClose"),j$=Symbol("skip"),p5=Symbol("doChown"),a5=Symbol("uid"),n5=Symbol("gid"),s5=Symbol("checkedCwd"),yX=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,o5=yX==="win32",EX=1024,bX=($,Q)=>{if(!o5)return I.unlink($,Q);const V=$+".DELETE."+w4(16).toString("hex");I.rename($,V,(X)=>{if(X)return Q(X);I.unlink(V,Q)})},mX=($)=>{if(!o5)return I.unlinkSync($);const Q=$+".DELETE."+w4(16).toString("hex");I.renameSync($,Q),I.unlinkSync(Q)},A4=($,Q,V)=>$!==void 0&&$===$>>>0?$:Q!==void 0&&Q===Q>>>0?Q:V,I4=($)=>B0(A(l8($))).toLowerCase(),hX=($,Q)=>{Q=I4(Q);for(let V of $.keys()){const X=I4(V);if(X===Q||X.indexOf(Q+"/")===0)$.delete(V)}},uX=($)=>{for(let Q of $.keys())$.delete(Q)};class r5 extends f0{[v$]=!1;[s5]=!1;[d8]=0;reservations=new P$;transform;writable=!0;readable=!1;dirCache;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor($={}){$.ondone=()=>{this[v$]=!0,this[O$]()};super($);if(this.transform=$.transform,this.dirCache=$.dirCache||new Map,this.chmod=!!$.chmod,typeof $.uid==="number"||typeof $.gid==="number"){if(typeof $.uid!=="number"||typeof $.gid!=="number")throw new TypeError("cannot set owner without number uid and gid");if($.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=$.uid,this.gid=$.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;if($.preserveOwner===void 0&&typeof $.uid!=="number")this.preserveOwner=!!(process.getuid&&process.getuid()===0);else this.preserveOwner=!!$.preserveOwner;this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof $.maxDepth==="number"?$.maxDepth:EX,this.forceChown=$.forceChown===!0,this.win32=!!$.win32||o5,this.newer=!!$.newer,this.keep=!!$.keep,this.noMtime=!!$.noMtime,this.preservePaths=!!$.preservePaths,this.unlink=!!$.unlink,this.cwd=A(C0.resolve($.cwd||process.cwd())),this.strip=Number($.strip)||0,this.processUmask=!this.chmod?0:typeof $.processUmask==="number"?$.processUmask:process.umask(),this.umask=typeof $.umask==="number"?$.umask:this.processUmask,this.dmode=$.dmode||511&~this.umask,this.fmode=$.fmode||438&~this.umask,this.on("entry",(Q)=>this[Y4](Q))}warn($,Q,V={}){if($==="TAR_BAD_ARCHIVE"||$==="TAR_ABORT")V.recoverable=!1;return super.warn($,Q,V)}[O$](){if(this[v$]&&this[d8]===0)this.emit("prefinish"),this.emit("finish"),this.emit("end")}[L4]($){const Q=A($.path),V=Q.split("/");if(this.strip){if(V.length=this.strip)$.linkpath=X.slice(this.strip).join("/");else return!1}V.splice(0,this.strip),$.path=V.join("/")}if(isFinite(this.maxDepth)&&V.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:$,path:Q,depth:V.length,maxDepth:this.maxDepth}),!1;if(!this.preservePaths){if(V.includes("..")||o5&&/^[a-z]:\.\.$/i.test(V[0]??""))return this.warn("TAR_ENTRY_ERROR","path contains '..'",{entry:$,path:Q}),!1;const[X,J]=m5(Q);if(X)$.path=String(J),this.warn("TAR_ENTRY_INFO",`stripping ${X} from absolute path`,{entry:$,path:Q})}if(C0.isAbsolute($.path))$.absolute=A(C0.resolve($.path));else $.absolute=A(C0.resolve(this.cwd,$.path));if(!this.preservePaths&&typeof $.absolute==="string"&&$.absolute.indexOf(this.cwd+"/")!==0&&$.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:$,path:A($.path),resolvedPath:$.absolute,cwd:this.cwd}),!1;if($.absolute===this.cwd&&$.type!=="Directory"&&$.type!=="GNUDumpDir")return!1;if(this.win32){const{root:X}=C0.win32.parse(String($.absolute));$.absolute=X+n9(String($.absolute).slice(X.length));const{root:J}=C0.win32.parse($.path);$.path=J+n9($.path.slice(J.length))}return!0}[Y4]($){if(!this[L4]($))return $.resume();switch(kX.equal(typeof $.absolute,"string"),$.type){case"Directory":case"GNUDumpDir":if($.mode)$.mode=$.mode|448;case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[U$]($);case"CharacterDevice":case"BlockDevice":case"FIFO":default:return this[B4]($)}}[y]($,Q){if($.name==="CwdError")this.emit("error",$);else this.warn("TAR_ENTRY_ERROR",$,{entry:Q}),this[v5](),Q.resume()}[l0]($,Q,V){J4(A($),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:Q},V)}[p5]($){return this.forceChown||this.preserveOwner&&(typeof $.uid==="number"&&$.uid!==this.processUid||typeof $.gid==="number"&&$.gid!==this.processGid)||typeof this.uid==="number"&&this.uid!==this.processUid||typeof this.gid==="number"&&this.gid!==this.processGid}[a5]($){return A4(this.uid,$.uid,this.processUid)}[n5]($){return A4(this.gid,$.gid,this.processGid)}[T$]($,Q){const V=typeof $.mode==="number"?$.mode&4095:this.fmode,X=new g0(String($.absolute),{flags:q$($.size),mode:V,autoClose:!1});X.on("error",(G)=>{if(X.fd)I.close(X.fd,()=>{});X.write=()=>!0,this[y](G,$),Q()});let J=1;const Z=(G)=>{if(G){if(X.fd)I.close(X.fd,()=>{});this[y](G,$),Q();return}if(--J===0){if(X.fd!==void 0)I.close(X.fd,(Y)=>{if(Y)this[y](Y,$);else this[v5]();Q()})}};X.on("finish",()=>{const G=String($.absolute),Y=X.fd;if(typeof Y==="number"&&$.mtime&&!this.noMtime){J++;const W=$.atime||new Date,z=$.mtime;I.futimes(Y,W,z,(q)=>q?I.utimes(G,W,z,(M)=>Z(M&&q)):Z())}if(typeof Y==="number"&&this[p5]($)){J++;const W=this[a5]($),z=this[n5]($);if(typeof W==="number"&&typeof z==="number")I.fchown(Y,W,z,(q)=>q?I.chown(G,W,z,(M)=>Z(M&&q)):Z())}Z()});const K=this.transform?this.transform($)||$:$;if(K!==$)K.on("error",(G)=>{this[y](G,$),Q()}),$.pipe(K);K.pipe(X)}[C$]($,Q){const V=typeof $.mode==="number"?$.mode&4095:this.dmode;this[l0](String($.absolute),V,(X)=>{if(X){this[y](X,$),Q();return}let J=1;const Z=()=>{if(--J===0)Q(),this[v5](),$.resume()};if($.mtime&&!this.noMtime)J++,I.utimes(String($.absolute),$.atime||new Date,$.mtime,Z);if(this[p5]($))J++,I.chown(String($.absolute),Number(this[a5]($)),Number(this[n5]($)),Z);Z()})}[B4]($){$.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${$.type}`,{entry:$}),$.resume()}[W4]($,Q){this[a8]($,String($.linkpath),"symlink",Q)}[q4]($,Q){const V=A(C0.resolve(this.cwd,String($.linkpath)));this[a8]($,V,"link",Q)}[M4](){this[d8]++}[v5](){this[d8]--,this[O$]()}[j$]($){this[v5](),$.resume()}[x$]($,Q){return $.type==="File"&&!this.unlink&&Q.isFile()&&Q.nlink<=1&&!o5}[U$]($){this[M4]();const Q=[$.path];if($.linkpath)Q.push($.linkpath);this.reservations.reserve(Q,(V)=>this[z4]($,V))}[p8]($){if($.type==="SymbolicLink")uX(this.dirCache);else if($.type!=="Directory")hX(this.dirCache,String($.absolute))}[z4]($,Q){this[p8]($);const V=(K)=>{this[p8]($),Q(K)},X=()=>{this[l0](this.cwd,this.dmode,(K)=>{if(K){this[y](K,$),V();return}this[s5]=!0,J()})},J=()=>{if($.absolute!==this.cwd){const K=A(C0.dirname(String($.absolute)));if(K!==this.cwd)return this[l0](K,this.dmode,(G)=>{if(G){this[y](G,$),V();return}Z()})}Z()},Z=()=>{I.lstat(String($.absolute),(K,G)=>{if(G&&(this.keep||this.newer&&G.mtime>($.mtime??G.mtime))){this[j$]($),V();return}if(K||this[x$]($,G))return this[r](null,$,V);if(G.isDirectory()){if($.type==="Directory"){const Y=this.chmod&&$.mode&&(G.mode&4095)!==$.mode,W=(z)=>this[r](z??null,$,V);if(!Y)return W();return I.chmod(String($.absolute),Number($.mode),W)}if($.absolute!==this.cwd)return I.rmdir(String($.absolute),(Y)=>this[r](Y??null,$,V))}if($.absolute===this.cwd)return this[r](null,$,V);bX(String($.absolute),(Y)=>this[r](Y??null,$,V))})};if(this[s5])J();else X()}[r]($,Q,V){if($){this[y]($,Q),V();return}switch(Q.type){case"File":case"OldFile":case"ContiguousFile":return this[T$](Q,V);case"Link":return this[q4](Q,V);case"SymbolicLink":return this[W4](Q,V);case"Directory":case"GNUDumpDir":return this[C$](Q,V)}}[a8]($,Q,V,X){I[V](Q,String($.absolute),(J)=>{if(J)this[y](J,$);else this[v5](),$.resume();X()})}}var i8=($)=>{try{return[null,$()]}catch(Q){return[Q,null]}};class n8 extends r5{sync=!0;[r]($,Q){return super[r]($,Q,()=>{})}[U$]($){if(this[p8]($),!this[s5]){const J=this[l0](this.cwd,this.dmode);if(J)return this[y](J,$);this[s5]=!0}if($.absolute!==this.cwd){const J=A(C0.dirname(String($.absolute)));if(J!==this.cwd){const Z=this[l0](J,this.dmode);if(Z)return this[y](Z,$)}}const[Q,V]=i8(()=>I.lstatSync(String($.absolute)));if(V&&(this.keep||this.newer&&V.mtime>($.mtime??V.mtime)))return this[j$]($);if(Q||this[x$]($,V))return this[r](null,$);if(V.isDirectory()){if($.type==="Directory"){const Z=this.chmod&&$.mode&&(V.mode&4095)!==$.mode,[K]=Z?i8(()=>{I.chmodSync(String($.absolute),Number($.mode))}):[];return this[r](K,$)}const[J]=i8(()=>I.rmdirSync(String($.absolute)));this[r](J,$)}const[X]=$.absolute===this.cwd?[]:i8(()=>mX(String($.absolute)));this[r](X,$)}[T$]($,Q){const V=typeof $.mode==="number"?$.mode&4095:this.fmode,X=(K)=>{let G;try{I.closeSync(J)}catch(Y){G=Y}if(K||G)this[y](K||G,$);Q()};let J;try{J=I.openSync(String($.absolute),q$($.size),V)}catch(K){return X(K)}const Z=this.transform?this.transform($)||$:$;if(Z!==$)Z.on("error",(K)=>this[y](K,$)),$.pipe(Z);Z.on("data",(K)=>{try{I.writeSync(J,K,0,K.length)}catch(G){X(G)}}),Z.on("end",()=>{let K=null;if($.mtime&&!this.noMtime){const G=$.atime||new Date,Y=$.mtime;try{I.futimesSync(J,G,Y)}catch(W){try{I.utimesSync(String($.absolute),G,Y)}catch(z){K=W}}}if(this[p5]($)){const G=this[a5]($),Y=this[n5]($);try{I.fchownSync(J,Number(G),Number(Y))}catch(W){try{I.chownSync(String($.absolute),Number(G),Number(Y))}catch(z){K=K||W}}}X(K)})}[C$]($,Q){const V=typeof $.mode==="number"?$.mode&4095:this.dmode,X=this[l0](String($.absolute),V);if(X){this[y](X,$),Q();return}if($.mtime&&!this.noMtime)try{I.utimesSync(String($.absolute),$.atime||new Date,$.mtime)}catch(J){}if(this[p5]($))try{I.chownSync(String($.absolute),Number(this[a5]($)),Number(this[n5]($)))}catch(J){}Q(),$.resume()}[l0]($,Q){try{return K4(A($),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:Q})}catch(V){return V}}[a8]($,Q,V,X){const J=`${V}Sync`;try{I[J](Q,String($.absolute)),X(),$.resume()}catch(Z){return this[y](Z,$)}}}var fX=($)=>{const Q=new n8($),V=$.file,X=F4.statSync(V),J=$.maxReadSize||16777216;new j9(V,{readSize:J,size:X.size}).pipe(Q)},cX=($,Q)=>{const V=new r5($),X=$.maxReadSize||16777216,J=$.file;return new Promise((K,G)=>{V.on("error",G),V.on("close",K),F4.stat(J,(Y,W)=>{if(Y)G(Y);else{const z=new M5(J,{readSize:X,size:W.size});z.on("error",G),z.pipe(V)}})})},D$=z0(fX,cX,($)=>new n8($),($)=>new r5($),($,Q)=>{if(Q?.length)i9($,Q)});import l from"node:fs";import H4 from"node:path";var lX=($,Q)=>{const V=new H5($);let X=!0,J,Z;try{try{J=l.openSync($.file,"r+")}catch(Y){if(Y?.code==="ENOENT")J=l.openSync($.file,"w+");else throw Y}const K=l.fstatSync(J),G=Buffer.alloc(512);$:for(Z=0;ZK.size)break;if(Z+=W,$.mtimeCache&&Y.mtime)$.mtimeCache.set(String(Y.path),Y.mtime)}X=!1,dX($,V,Z,J,Q)}finally{if(X)try{l.closeSync(J)}catch(K){}}},dX=($,Q,V,X,J)=>{const Z=new R5($.file,{fd:X,start:V});Q.pipe(Z),pX(Q,J)},iX=($,Q)=>{Q=Array.from(Q);const V=new X5($),X=(Z,K,G)=>{const Y=(O,U)=>{if(O)l.close(Z,(v)=>G(O));else G(null,U)};let W=0;if(K===0)return Y(null,0);let z=0;const q=Buffer.alloc(512),M=(O,U)=>{if(O||typeof U==="undefined")return Y(O);if(z+=U,z<512&&U)return l.read(Z,q,z,q.length-z,W+z,M);if(W===0&&q[0]===31&&q[1]===139)return Y(new Error("cannot append to compressed archives"));if(z<512)return Y(null,W);const v=new a(q);if(!v.cksumValid)return Y(null,W);const N=512*Math.ceil((v.size??0)/512);if(W+N+512>K)return Y(null,W);if(W+=N+512,W>=K)return Y(null,W);if($.mtimeCache&&v.mtime)$.mtimeCache.set(String(v.path),v.mtime);z=0,l.read(Z,q,0,512,W,M)};l.read(Z,q,0,512,W,M)};return new Promise((Z,K)=>{V.on("error",K);let G="r+";const Y=(W,z)=>{if(W&&W.code==="ENOENT"&&G==="r+")return G="w+",l.open($.file,G,Y);if(W||!z)return K(W);l.fstat(z,(q,M)=>{if(q)return l.close(z,()=>K(q));X(z,M.size,(O,U)=>{if(O)return K(O);const v=new g0($.file,{fd:z,start:U});V.pipe(v),v.on("error",K),v.on("close",Z),aX(V,Q)})})};l.open($.file,G,Y)})},pX=($,Q)=>{Q.forEach((V)=>{if(V.charAt(0)==="@")Q5({file:H4.resolve($.cwd,V.slice(1)),sync:!0,noResume:!0,onReadEntry:(X)=>$.add(X)});else $.add(V)}),$.end()},aX=async($,Q)=>{for(let V=0;V$.add(J)});else $.add(X)}$.end()},J5=z0(lX,iX,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},($,Q)=>{if(!P1($))throw new TypeError("file is required");if($.gzip||$.brotli||$.file.endsWith(".br")||$.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!Q?.length)throw new TypeError("no paths specified to add/replace")});var nX=z0(J5.syncFile,J5.asyncFile,J5.syncNoFile,J5.asyncNoFile,($,Q=[])=>{J5.validate?.($,Q),sX($)}),sX=($)=>{const Q=$.filter;if(!$.mtimeCache)$.mtimeCache=new Map;$.filter=Q?(V,X)=>Q(V,X)&&!(($.mtimeCache?.get(V)??X.mtime??0)>(X.mtime??0)):(V,X)=>!(($.mtimeCache?.get(V)??X.mtime??0)>(X.mtime??0))};import eX from"os";async function $J($,Q,V){L.info(`Starting download from URL: ${$}`);const X=S$(__dirname,"../package.json");let J;try{J=await t.readFile(X,"utf-8")}catch(z){throw L.error(`Failed to read package.json from ${X}`),new Error(`Failed to read package.json: ${z}`)}let Z;try{Z=JSON.parse(J)}catch(z){throw L.error(`Failed to parse package.json: ${z}`),new Error(`Failed to parse package.json: ${z}`)}const K=`beat-forge/init-beatsaber@${Z.version}`;L.debug(`User-Agent: ${K}`);const G=new Headers({"User-Agent":K,Accept:"application/octet-stream"});if(V)G.set("Authorization",`token ${V}`);let Y;try{Y=await fetch($,{headers:G})}catch(z){throw L.error(`Network error while fetching ${$}: ${z}`),new Error(`Network error: ${z}`)}if(L.info(`Response status: ${Y.status} ${Y.statusText}`),!Y.ok){const z=await Y.text().catch(()=>"No response body");throw L.error(`Failed to download file: ${Y.statusText}`),L.debug(`Error response body: ${z}`),new Error(`Failed to download file: ${Y.status} ${Y.statusText}`)}try{await t.mkdir(N$(Q),{recursive:!0}),L.debug(`Created directory for output path: ${N$(Q)}`)}catch(z){throw L.error(`Failed to create directory ${N$(Q)}: ${z}`),z}const W=rX(Q);if(L.info("Starting to read and write file stream"),Y.body)try{await tX(Y.body,W)}catch(z){throw L.error(`Error during file stream pipeline: ${z}`),z}else throw new Error("Response body is null");L.info("File downloaded and written successfully")}async function QJ($,Q){L.info(`Extracting tarball from ${$} to ${Q}`);try{await t.mkdir(Q,{recursive:!0}),await D$({file:$,cwd:Q,strip:1}),L.info("Tarball extraction completed successfully")}catch(V){throw L.error(`Failed to extract tarball from ${$} to ${Q}: ${V}`),V}}async function P4($,Q){L.info(`Moving contents from ${$} to ${Q}`);try{await t.mkdir(Q,{recursive:!0});const V=await t.readdir($,{withFileTypes:!0});L.debug(`Entries to move: ${V.map((X)=>X.name).join(", ")}`);for(let X of V){const J=O5($,X.name),Z=O5(Q,X.name);if(X.isDirectory())await P4(J,Z);else try{await t.rename(J,Z),L.debug(`Renamed ${J} to ${Z}`)}catch(K){L.debug(`Rename failed for ${J}. Attempting to copy and delete.`),await t.copyFile(J,Z),await t.unlink(J),L.debug(`Copied and deleted ${J} to ${Z}`)}}L.info("Content move completed successfully")}catch(V){throw L.error(`Failed to move contents from ${$} to ${Q}: ${V}`),V}}async function v4($){L.info(`Searching for manifest.json in directory: ${$}`);try{const Q=await t.readdir($,{withFileTypes:!0});for(let V of Q){const X=O5($,V.name);if(V.isDirectory()){const J=await v4(X);if(J)return J}else if(V.isFile()&&V.name==="manifest.json")return L.info(`Found manifest.json at ${X}`),X}return L.debug(`No manifest.json found in directory: ${$}`),null}catch(Q){throw L.error(`Error searching for manifest.json in ${$}: ${Q}`),Q}}async function VJ(){let $=void 0;try{L.info("Initializing Beat Saber modding environment...");const Q=L.getInput("token",{required:!1}),V=L.getInput("repo",{required:!0}),X=L.getInput("host",{required:!0}),J=L.getInput("manifest",{required:!1}),Z=L.getInput("path",{required:!0});let K=L.getInput("version",{required:!1});const G=L.getInput("ref",{required:!1});if(L.debug(`Inputs - version: ${K}, manifest: ${J}, path: ${Z}, repo: ${V}, host: ${X}, ref: ${G}`),!/^([\w-]+)\/([\w-]+)$/.test(V))throw new Error(`Invalid repo format: "${V}". Expected format "owner/repo".`);let Y=K;if(!G&&!Y){L.info("No ref or version specified. Attempting to infer version from manifest.json...");const U=J?S$(J):await v4(process.cwd());if(U){L.info(`Using manifest.json at ${U} to infer version.`);let v;try{v=await t.readFile(U,"utf-8")}catch(x){throw L.error(`Failed to read manifest.json: ${x}`),new Error("Failed to read manifest.json.")}if(v.charCodeAt(0)===65279)L.debug("Removing BOM from manifest.json"),v=v.slice(1);let N;try{N=JSON.parse(v)}catch(x){throw L.error(`Failed to parse manifest.json: ${x}`),new Error("Invalid JSON in manifest.json.")}if(N.gameVersion)Y=N.gameVersion,L.info(`Inferred version from manifest: ${Y}`);else throw new Error('No version specified and "gameVersion" not found in manifest.json.')}else throw new Error("No manifest.json found and no version specified.")}let W;if(G)W=G,L.info(`Using ref from input: ${W}`);else if(Y)W=`version/${Y}`,L.info(`Using ref from version: ${W}`);else throw new Error("No ref or version specified, and unable to infer from manifest.");const z=`https://${X}/${V}/archive/${W}.tar.gz`;$=await t.mkdtemp(O5(eX.tmpdir(),"action-"));const q=O5($,"archive.tar.gz"),M=O5($,"extract"),O=S$(Z);L.info(`Downloading tarball from ${z}`),await $J(z,q,Q),L.info(`Extracting tarball to ${M}`),await QJ(q,M),L.info(`Moving extracted contents to ${O}`),await P4(M,O),L.info("Beat Saber references initialized successfully")}catch(Q){if(Q instanceof Error)L.setFailed(`Action failed with error: ${Q.message}`);else L.setFailed(`Action failed with unknown error: ${Q}`)}finally{if($)try{await t.rm($,{recursive:!0,force:!0}),L.debug(`Cleaned up temporary directory: ${$}`)}catch(Q){L.warning(`Failed to clean up temporary directory: ${Q}`)}}}var __dirname="/home/checksum/projects/beatforge/init-beatsaber/src";VJ(); diff --git a/src/index.ts b/src/index.ts index 26a0885..8707c94 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,50 +1,92 @@ import * as core from '@actions/core' -import { promises as fs, createWriteStream } from 'fs' -import { dirname, join, resolve } from 'path' -import { pipeline } from 'stream' +import { promises as fsPromises, createWriteStream } from 'fs' +import { dirname, join, resolve, basename } from 'path' +import { pipeline } from 'stream/promises' import * as tar from 'tar' -import { promisify } from 'util' - -const streamPipeline = promisify(pipeline) +import os from 'os' +/** + * Downloads a file from the given URL and saves it to the specified output path. + * Uses the provided GitHub token if available. + * @param url - The URL to download the file from. + * @param outputPath - The local file path where the file will be saved. + * @param token - Optional GitHub token for authenticated requests. + */ async function downloadFile( url: string, outputPath: string, token?: string ): Promise { core.info(`Starting download from URL: ${url}`) - const packageJson = require('../package.json') + + // Read package.json to get the version + const packageJsonPath = resolve(__dirname, '../package.json') + let packageJsonContent: string + try { + packageJsonContent = await fsPromises.readFile(packageJsonPath, 'utf-8') + } catch (error) { + core.error(`Failed to read package.json from ${packageJsonPath}`) + throw new Error(`Failed to read package.json: ${error}`) + } + + let packageJson: { version: string } + try { + packageJson = JSON.parse(packageJsonContent) + } catch (error) { + core.error(`Failed to parse package.json: ${error}`) + throw new Error(`Failed to parse package.json: ${error}`) + } + const userAgent = `beat-forge/init-beatsaber@${packageJson.version}` core.debug(`User-Agent: ${userAgent}`) - const headers: Record = { - 'User-Agent': userAgent - } + const headers = new Headers({ + 'User-Agent': userAgent, + Accept: 'application/octet-stream' + }) + if (token) { - headers['Authorization'] = `token ${token}` + headers.set('Authorization', `token ${token}`) } - const response = await fetch(url, { - headers - }) + let response: Response + try { + response = await fetch(url, { headers }) + } catch (error) { + core.error(`Network error while fetching ${url}: ${error}`) + throw new Error(`Network error: ${error}`) + } - core.info(`Response status: ${response.status}`) - core.debug(`Response headers: ${JSON.stringify([...response.headers])}`) + core.info(`Response status: ${response.status} ${response.statusText}`) if (!response.ok) { + const errorBody = await response.text().catch(() => 'No response body') core.error(`Failed to download file: ${response.statusText}`) - throw new Error(`Failed to download file: ${response.statusText}`) + core.debug(`Error response body: ${errorBody}`) + throw new Error( + `Failed to download file: ${response.status} ${response.statusText}` + ) } - await fs.mkdir(dirname(outputPath), { recursive: true }) - core.debug(`Created directory for output path: ${dirname(outputPath)}`) + try { + await fsPromises.mkdir(dirname(outputPath), { recursive: true }) + core.debug(`Created directory for output path: ${dirname(outputPath)}`) + } catch (error) { + core.error(`Failed to create directory ${dirname(outputPath)}: ${error}`) + throw error + } const fileStream = createWriteStream(outputPath) core.info('Starting to read and write file stream') if (response.body) { - await streamPipeline(response.body, fileStream) + try { + await pipeline(response.body, fileStream) + } catch (error) { + core.error(`Error during file stream pipeline: ${error}`) + throw error + } } else { throw new Error('Response body is null') } @@ -52,138 +94,221 @@ async function downloadFile( core.info('File downloaded and written successfully') } +/** + * Extracts a tarball file to the specified directory. + * @param tarballPath - The path to the tarball file. + * @param extractPath - The directory where the tarball will be extracted. + */ async function extractTarball( tarballPath: string, extractPath: string ): Promise { core.info(`Extracting tarball from ${tarballPath} to ${extractPath}`) try { - await fs.mkdir(extractPath, { recursive: true }) + await fsPromises.mkdir(extractPath, { recursive: true }) await tar.extract({ file: tarballPath, - cwd: extractPath + cwd: extractPath, + strip: 1 }) core.info('Tarball extraction completed successfully') } catch (error) { core.error( - `Failed to extract tarball from ${tarballPath} to ${extractPath}` + `Failed to extract tarball from ${tarballPath} to ${extractPath}: ${error}` ) - core.error(`Error details: ${error}`) throw error } } +/** + * Recursively moves contents from the source directory to the destination directory. + * @param srcDir - The source directory. + * @param destDir - The destination directory. + */ async function moveContents(srcDir: string, destDir: string): Promise { core.info(`Moving contents from ${srcDir} to ${destDir}`) try { - await fs.mkdir(destDir, { recursive: true }) - const files = await fs.readdir(srcDir, { withFileTypes: true }) - core.debug(`Files to move: ${files.map(file => file.name).join(', ')}`) + await fsPromises.mkdir(destDir, { recursive: true }) + const entries = await fsPromises.readdir(srcDir, { withFileTypes: true }) + core.debug(`Entries to move: ${entries.map(e => e.name).join(', ')}`) - for (const file of files) { - const srcPath = join(srcDir, file.name) - const destPath = join(destDir, file.name) + for (const entry of entries) { + const srcPath = join(srcDir, entry.name) + const destPath = join(destDir, entry.name) - if (file.isDirectory()) { + if (entry.isDirectory()) { await moveContents(srcPath, destPath) } else { - await fs.rename(srcPath, destPath) + try { + await fsPromises.rename(srcPath, destPath) + core.debug(`Renamed ${srcPath} to ${destPath}`) + } catch (renameError) { + // Fallback to copy and delete if rename fails (e.g., cross-filesystem) + core.debug( + `Rename failed for ${srcPath}. Attempting to copy and delete.` + ) + await fsPromises.copyFile(srcPath, destPath) + await fsPromises.unlink(srcPath) + core.debug(`Copied and deleted ${srcPath} to ${destPath}`) + } } - core.debug(`Moved ${srcPath} to ${destPath}`) } core.info('Content move completed successfully') } catch (error) { - core.error(`Failed to move contents from ${srcDir} to ${destDir}`) - core.error(`Error details: ${error}`) + core.error(`Failed to move contents from ${srcDir} to ${destDir}: ${error}`) throw error } } +/** + * Recursively searches for a 'manifest.json' file starting from the given directory. + * @param dir - The directory to start searching from. + * @returns The full path to 'manifest.json' if found, otherwise null. + */ async function findManifest(dir: string): Promise { core.info(`Searching for manifest.json in directory: ${dir}`) - const files = await fs.readdir(dir, { withFileTypes: true }) - for (const file of files) { - const fullPath = join(dir, file.name) - if (file.isDirectory()) { - const manifest = await findManifest(fullPath) - if (manifest) return manifest - } else if (file.name === 'manifest.json') { - core.info(`Found manifest.json at ${fullPath}`) - return fullPath + try { + const entries = await fsPromises.readdir(dir, { withFileTypes: true }) + for (const entry of entries) { + const fullPath = join(dir, entry.name) + if (entry.isDirectory()) { + const manifest = await findManifest(fullPath) + if (manifest) return manifest + } else if (entry.isFile() && entry.name === 'manifest.json') { + core.info(`Found manifest.json at ${fullPath}`) + return fullPath + } } + core.debug(`No manifest.json found in directory: ${dir}`) + return null + } catch (error) { + core.error(`Error searching for manifest.json in ${dir}: ${error}`) + throw error } - core.debug(`No manifest.json found in directory: ${dir}`) - return null } async function run(): Promise { + let tmpDir: string | undefined = undefined + try { core.info('Initializing Beat Saber modding environment...') - const token = core.getInput('token') - const repo = core.getInput('repo') - const host = core.getInput('host') - - const manifestPath = core.getInput('manifest') - const referencesPath = core.getInput('path') - let requestedVersion = core.getInput('version') + // Retrieve inputs + const token = core.getInput('token', { required: false }) + const repo = core.getInput('repo', { required: true }) + const host = core.getInput('host', { required: true }) + const manifestPathInput = core.getInput('manifest', { required: false }) + const referencesPathInput = core.getInput('path', { required: true }) + let requestedVersion = core.getInput('version', { required: false }) + const refInput = core.getInput('ref', { required: false }) core.debug( - `Inputs: version=${requestedVersion}, manifest=${manifestPath}, path=${referencesPath}, repo=${repo}, host=${host}` + `Inputs - version: ${requestedVersion}, manifest: ${manifestPathInput}, path: ${referencesPathInput}, repo: ${repo}, host: ${host}, ref: ${refInput}` ) - if (!requestedVersion) { + // Validate 'repo' format (owner/repo) + if (!/^([\w-]+)\/([\w-]+)$/.test(repo)) { + throw new Error( + `Invalid repo format: "${repo}". Expected format "owner/repo".` + ) + } + + let version = requestedVersion + // If no version specified, attempt to infer from manifest + if (!refInput && !version) { core.info( - 'No version specified. Attempting to infer version from manifest.json...' + 'No ref or version specified. Attempting to infer version from manifest.json...' ) - const manifestFile = manifestPath - ? resolve(manifestPath) + const manifestFile = manifestPathInput + ? resolve(manifestPathInput) : await findManifest(process.cwd()) + if (manifestFile) { - core.info(`Found manifest.json at ${manifestFile}`) + core.info(`Using manifest.json at ${manifestFile} to infer version.`) - let manifestStringData = await fs.readFile(manifestFile, 'utf-8') - if (manifestStringData.startsWith('\ufeff')) { + let manifestContent: string + try { + manifestContent = await fsPromises.readFile(manifestFile, 'utf-8') + } catch (readError) { + core.error(`Failed to read manifest.json: ${readError}`) + throw new Error('Failed to read manifest.json.') + } + + // Remove BOM if present + if (manifestContent.charCodeAt(0) === 0xfeff) { core.debug('Removing BOM from manifest.json') - manifestStringData = manifestStringData.substring(1) + manifestContent = manifestContent.slice(1) } - const manifest = JSON.parse(manifestStringData) - requestedVersion = manifest.gameVersion + let manifest: { gameVersion?: string } + try { + manifest = JSON.parse(manifestContent) + } catch (parseError) { + core.error(`Failed to parse manifest.json: ${parseError}`) + throw new Error('Invalid JSON in manifest.json.') + } - core.info(`Inferred version: ${requestedVersion}`) + if (manifest.gameVersion) { + version = manifest.gameVersion + core.info(`Inferred version from manifest: ${version}`) + } else { + throw new Error( + 'No version specified and "gameVersion" not found in manifest.json.' + ) + } } else { - core.error('No manifest.json found and no version specified.') throw new Error('No manifest.json found and no version specified.') } } - if (repo.split('/').length !== 2) { - core.error(`Invalid repo format: ${repo} (expected owner/repo)`) - throw new Error(`Invalid repo format: ${repo} (expected owner/repo)`) + let ref: string + if (refInput) { + ref = refInput + core.info(`Using ref from input: ${ref}`) + } else if (version) { + ref = `version/${version}` + core.info(`Using ref from version: ${ref}`) + } else { + throw new Error( + 'No ref or version specified, and unable to infer from manifest.' + ) } - const branch = `version/${requestedVersion}` - const archiveUrl = `https://${host}/${repo}/archive/refs/heads/${branch}.tar.gz` - const tarballPath = resolve('archive.tar.gz') - const extractPath = resolve('extract') - const refsPath = resolve(referencesPath) + const archiveUrl = `https://${host}/${repo}/archive/${ref}.tar.gz` + + // Create temporary directory + tmpDir = await fsPromises.mkdtemp(join(os.tmpdir(), 'action-')) - core.info(`Downloading from ${archiveUrl}`) + const tarballPath = join(tmpDir, 'archive.tar.gz') + const extractPath = join(tmpDir, 'extract') + const refsPath = resolve(referencesPathInput) + + core.info(`Downloading tarball from ${archiveUrl}`) await downloadFile(archiveUrl, tarballPath, token) core.info(`Extracting tarball to ${extractPath}`) await extractTarball(tarballPath, extractPath) - core.info(`Moving contents to ${refsPath}`) - await moveContents( - join(extractPath, `beatsaber-stripped-version-${requestedVersion}`), - refsPath - ) + core.info(`Moving extracted contents to ${refsPath}`) + await moveContents(extractPath, refsPath) core.info('Beat Saber references initialized successfully') } catch (error) { - core.setFailed(`Action failed with error: ${error}`) + if (error instanceof Error) { + core.setFailed(`Action failed with error: ${error.message}`) + } else { + core.setFailed(`Action failed with unknown error: ${error}`) + } + } finally { + // Clean up temporary files + if (tmpDir) { + try { + await fsPromises.rm(tmpDir, { recursive: true, force: true }) + core.debug(`Cleaned up temporary directory: ${tmpDir}`) + } catch (cleanupError) { + core.warning(`Failed to clean up temporary directory: ${cleanupError}`) + } + } } }