create-zuplo-api 7.10.0 → 7.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,4 +69,4 @@ var m=p(181);var g=m.Buffer;function copyProps(t,u){for(var p in t){u[p]=t[p]}}i
|
|
|
69
69
|
*
|
|
70
70
|
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
71
71
|
* Released under the MIT License.
|
|
72
|
-
*/const m=p(7311);const toRegexRange=(t,u,p)=>{if(m(t)===false){throw new TypeError("toRegexRange: expected the first argument to be a number")}if(u===void 0||t===u){return String(t)}if(m(u)===false){throw new TypeError("toRegexRange: expected the second argument to be a number.")}let g={relaxZeros:true,...p};if(typeof g.strictZeros==="boolean"){g.relaxZeros=g.strictZeros===false}let v=String(g.relaxZeros);let b=String(g.shorthand);let w=String(g.capture);let E=String(g.wrap);let S=t+":"+u+"="+v+b+w+E;if(toRegexRange.cache.hasOwnProperty(S)){return toRegexRange.cache[S].result}let $=Math.min(t,u);let P=Math.max(t,u);if(Math.abs($-P)===1){let p=t+"|"+u;if(g.capture){return`(${p})`}if(g.wrap===false){return p}return`(?:${p})`}let x=hasPadding(t)||hasPadding(u);let R={min:t,max:u,a:$,b:P};let O=[];let A=[];if(x){R.isPadded=x;R.maxLen=String(R.max).length}if($<0){let t=P<0?Math.abs(P):1;A=splitToPatterns(t,Math.abs($),R,g);$=R.a=0}if(P>=0){O=splitToPatterns($,P,R,g)}R.negatives=A;R.positives=O;R.result=collatePatterns(A,O,g);if(g.capture===true){R.result=`(${R.result})`}else if(g.wrap!==false&&O.length+A.length>1){R.result=`(?:${R.result})`}toRegexRange.cache[S]=R;return R.result};function collatePatterns(t,u,p){let m=filterPatterns(t,u,"-",false,p)||[];let g=filterPatterns(u,t,"",false,p)||[];let v=filterPatterns(t,u,"-?",true,p)||[];let b=m.concat(v).concat(g);return b.join("|")}function splitToRanges(t,u){let p=1;let m=1;let g=countNines(t,p);let v=new Set([u]);while(t<=g&&g<=u){v.add(g);p+=1;g=countNines(t,p)}g=countZeros(u+1,m)-1;while(t<g&&g<=u){v.add(g);m+=1;g=countZeros(u+1,m)-1}v=[...v];v.sort(compare);return v}function rangeToPattern(t,u,p){if(t===u){return{pattern:t,count:[],digits:0}}let m=zip(t,u);let g=m.length;let v="";let b=0;for(let t=0;t<g;t++){let[u,g]=m[t];if(u===g){v+=u}else if(u!=="0"||g!=="9"){v+=toCharacterClass(u,g,p)}else{b++}}if(b){v+=p.shorthand===true?"\\d":"[0-9]"}return{pattern:v,count:[b],digits:g}}function splitToPatterns(t,u,p,m){let g=splitToRanges(t,u);let v=[];let b=t;let w;for(let t=0;t<g.length;t++){let u=g[t];let E=rangeToPattern(String(b),String(u),m);let S="";if(!p.isPadded&&w&&w.pattern===E.pattern){if(w.count.length>1){w.count.pop()}w.count.push(E.count[0]);w.string=w.pattern+toQuantifier(w.count);b=u+1;continue}if(p.isPadded){S=padZeros(u,p,m)}E.string=S+E.pattern+toQuantifier(E.count);v.push(E);b=u+1;w=E}return v}function filterPatterns(t,u,p,m,g){let v=[];for(let g of t){let{string:t}=g;if(!m&&!contains(u,"string",t)){v.push(p+t)}if(m&&contains(u,"string",t)){v.push(p+t)}}return v}function zip(t,u){let p=[];for(let m=0;m<t.length;m++)p.push([t[m],u[m]]);return p}function compare(t,u){return t>u?1:u>t?-1:0}function contains(t,u,p){return t.some((t=>t[u]===p))}function countNines(t,u){return Number(String(t).slice(0,-u)+"9".repeat(u))}function countZeros(t,u){return t-t%Math.pow(10,u)}function toQuantifier(t){let[u=0,p=""]=t;if(p||u>1){return`{${u+(p?","+p:"")}}`}return""}function toCharacterClass(t,u,p){return`[${t}${u-t===1?"":"-"}${u}]`}function hasPadding(t){return/^-?(0+)\d/.test(t)}function padZeros(t,u,p){if(!u.isPadded){return t}let m=Math.abs(u.maxLen-String(t).length);let g=p.relaxZeros!==false;switch(m){case 0:return"";case 1:return g?"0?":"0";case 2:return g?"0{0,2}":"00";default:{return g?`0{0,${m}}`:`0{${m}}`}}}toRegexRange.cache={};toRegexRange.clearCache=()=>toRegexRange.cache={};t.exports=toRegexRange},1083:(t,u,p)=>{const{URL:m}=p(7016);const{join:g}=p(6928);const v=p(9896);const{promisify:b}=p(9023);const{tmpdir:w}=p(857);const E=p(2804);const S=b(v.writeFile);const $=b(v.mkdir);const P=b(v.readFile);const compareVersions=(t,u)=>t.localeCompare(u,"en-US",{numeric:true});const encode=t=>encodeURIComponent(t).replace(/^%40/,"@");const getFile=async(t,u)=>{const p=w();const m=g(p,"update-check");if(!v.existsSync(m)){await $(m)}let b=`${t.name}-${u}.json`;if(t.scope){b=`${t.scope}-${b}`}return g(m,b)};const evaluateCache=async(t,u,p)=>{if(v.existsSync(t)){const m=await P(t,"utf8");const{lastUpdate:g,latest:v}=JSON.parse(m);const b=g+p;if(b>u){return{shouldCheck:false,latest:v}}}return{shouldCheck:true,latest:null}};const updateCache=async(t,u,p)=>{const m=JSON.stringify({latest:u,lastUpdate:p});await S(t,m,"utf8")};const loadPackage=(t,u)=>new Promise(((m,g)=>{const v={host:t.hostname,path:t.pathname,port:t.port,headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"},timeout:2e3};if(u){v.headers.authorization=`${u.type} ${u.token}`}const{get:b}=p(t.protocol==="https:"?5692:8611);b(v,(t=>{const{statusCode:u}=t;if(u!==200){const p=new Error(`Request failed with code ${u}`);p.code=u;g(p);t.resume();return}let p="";t.setEncoding("utf8");t.on("data",(t=>{p+=t}));t.on("end",(()=>{try{const t=JSON.parse(p);m(t)}catch(t){g(t)}}))})).on("error",g).on("timeout",g)}));const getMostRecent=async({full:t,scope:u},g)=>{const v=E(u);const b=new m(t,v);let w=null;try{w=await loadPackage(b)}catch(t){if(t.code&&String(t.code).startsWith(4)){const t=p(373);const u=t(v,{recursive:true});w=await loadPackage(b,u)}else{throw t}}const S=w["dist-tags"][g];if(!S){throw new Error(`Distribution tag ${g} is not available`)}return S};const x={interval:36e5,distTag:"latest"};const getDetails=t=>{const u={full:encode(t)};if(t.includes("/")){const p=t.split("/");u.scope=p[0];u.name=p[1]}else{u.scope=null;u.name=t}return u};t.exports=async(t,u)=>{if(typeof t!=="object"){throw new Error("The first parameter should be your package.json file content")}const p=getDetails(t.name);const m=Date.now();const{distTag:g,interval:v}=Object.assign({},x,u);const b=await getFile(p,g);let w=null;let E=true;({shouldCheck:E,latest:w}=await evaluateCache(b,m,v));if(E){w=await getMostRecent(p,g);await updateCache(b,w,m)}const S=compareVersions(t.version,w);if(S===-1){return{latest:w,fromCache:!E}}return null}},3969:(t,u,p)=>{const m=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys";const g=p(6928);const v=m?";":":";const b=p(6173);const getNotFoundError=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"});const getPathInfo=(t,u)=>{const p=u.colon||v;const g=t.match(/\//)||m&&t.match(/\\/)?[""]:[...m?[process.cwd()]:[],...(u.path||process.env.PATH||"").split(p)];const b=m?u.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"";const w=m?b.split(p):[""];if(m){if(t.indexOf(".")!==-1&&w[0]!=="")w.unshift("")}return{pathEnv:g,pathExt:w,pathExtExe:b}};const which=(t,u,p)=>{if(typeof u==="function"){p=u;u={}}if(!u)u={};const{pathEnv:m,pathExt:v,pathExtExe:w}=getPathInfo(t,u);const E=[];const step=p=>new Promise(((v,b)=>{if(p===m.length)return u.all&&E.length?v(E):b(getNotFoundError(t));const w=m[p];const S=/^".*"$/.test(w)?w.slice(1,-1):w;const $=g.join(S,t);const P=!S&&/^\.[\\\/]/.test(t)?t.slice(0,2)+$:$;v(subStep(P,p,0))}));const subStep=(t,p,m)=>new Promise(((g,S)=>{if(m===v.length)return g(step(p+1));const $=v[m];b(t+$,{pathExt:w},((v,b)=>{if(!v&&b){if(u.all)E.push(t+$);else return g(t+$)}return g(subStep(t,p,m+1))}))}));return p?step(0).then((t=>p(null,t)),p):step(0)};const whichSync=(t,u)=>{u=u||{};const{pathEnv:p,pathExt:m,pathExtExe:v}=getPathInfo(t,u);const w=[];for(let E=0;E<p.length;E++){const S=p[E];const $=/^".*"$/.test(S)?S.slice(1,-1):S;const P=g.join($,t);const x=!$&&/^\.[\\\/]/.test(t)?t.slice(0,2)+P:P;for(let t=0;t<m.length;t++){const p=x+m[t];try{const t=b.sync(p,{pathExt:v});if(t){if(u.all)w.push(p);else return p}}catch(t){}}}if(u.all&&w.length)return w;if(u.nothrow)return null;throw getNotFoundError(t)};t.exports=which;which.sync=whichSync},6395:(t,u,p)=>{"use strict";const m=p(2040);const g=process.env;Object.defineProperty(u,"_vendors",{value:m.map((function(t){return t.constant}))});u.name=null;u.isPR=null;m.forEach((function(t){const p=Array.isArray(t.env)?t.env:[t.env];const m=p.every((function(t){return checkEnv(t)}));u[t.constant]=m;if(!m){return}u.name=t.name;switch(typeof t.pr){case"string":u.isPR=!!g[t.pr];break;case"object":if("env"in t.pr){u.isPR=t.pr.env in g&&g[t.pr.env]!==t.pr.ne}else if("any"in t.pr){u.isPR=t.pr.any.some((function(t){return!!g[t]}))}else{u.isPR=checkEnv(t.pr)}break;default:u.isPR=null}}));u.isCI=!!(g.CI!=="false"&&(g.BUILD_ID||g.BUILD_NUMBER||g.CI||g.CI_APP_ID||g.CI_BUILD_ID||g.CI_BUILD_NUMBER||g.CI_NAME||g.CONTINUOUS_INTEGRATION||g.RUN_ID||u.name||false));function checkEnv(t){if(typeof t==="string")return!!g[t];if("env"in t){return g[t.env]&&g[t.env].includes(t.includes)}if("any"in t){return t.any.some((function(t){return!!g[t]}))}return Object.keys(t).every((function(u){return g[u]===t[u]}))}},7825:(t,u,p)=>{"use strict";const{builtinModules:m}=p(3339);var g=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");var v=["node_modules","favicon.ico"];function validate(t){var u=[];var p=[];if(t===null){p.push("name cannot be null");return done(u,p)}if(t===undefined){p.push("name cannot be undefined");return done(u,p)}if(typeof t!=="string"){p.push("name must be a string");return done(u,p)}if(!t.length){p.push("name length must be greater than zero")}if(t.match(/^\./)){p.push("name cannot start with a period")}if(t.match(/^_/)){p.push("name cannot start with an underscore")}if(t.trim()!==t){p.push("name cannot contain leading or trailing spaces")}v.forEach((function(u){if(t.toLowerCase()===u){p.push(u+" is a blacklisted name")}}));if(m.includes(t.toLowerCase())){u.push(t+" is a core module name")}if(t.length>214){u.push("name can no longer contain more than 214 characters")}if(t.toLowerCase()!==t){u.push("name can no longer contain capital letters")}if(/[~'!()*]/.test(t.split("/").slice(-1)[0])){u.push('name can no longer contain special characters ("~\'!()*")')}if(encodeURIComponent(t)!==t){var b=t.match(g);if(b){var w=b[1];var E=b[2];if(encodeURIComponent(w)===w&&encodeURIComponent(E)===E){return done(u,p)}}p.push("name can only contain URL-friendly characters")}return done(u,p)}var done=function(t,u){var p={validForNewPackages:u.length===0&&t.length===0,validForOldPackages:u.length===0,warnings:t,errors:u};if(!p.warnings.length){delete p.warnings}if(!p.errors.length){delete p.errors}return p};t.exports=validate},181:t=>{"use strict";t.exports=require("buffer")},5317:t=>{"use strict";t.exports=require("child_process")},4434:t=>{"use strict";t.exports=require("events")},9896:t=>{"use strict";t.exports=require("fs")},8611:t=>{"use strict";t.exports=require("http")},5692:t=>{"use strict";t.exports=require("https")},3339:t=>{"use strict";t.exports=require("module")},1421:t=>{"use strict";t.exports=require("node:child_process")},8474:t=>{"use strict";t.exports=require("node:events")},3024:t=>{"use strict";t.exports=require("node:fs")},6760:t=>{"use strict";t.exports=require("node:path")},1708:t=>{"use strict";t.exports=require("node:process")},857:t=>{"use strict";t.exports=require("os")},6928:t=>{"use strict";t.exports=require("path")},3785:t=>{"use strict";t.exports=require("readline")},2203:t=>{"use strict";t.exports=require("stream")},2018:t=>{"use strict";t.exports=require("tty")},7016:t=>{"use strict";t.exports=require("url")},9023:t=>{"use strict";t.exports=require("util")},1311:(t,u,p)=>{"use strict";const{normalizeIPv6:m,removeDotSegments:g,recomposeAuthority:v,normalizePercentEncoding:b,normalizePathEncoding:w,escapePreservingEscapes:E,reescapeHostDelimiters:S,isIPv4:$,nonSimpleDomain:P}=p(6138);const{SCHEMES:x,getSchemeHandler:R}=p(8415);function normalize(t,u){if(typeof t==="string"){t=normalizeString(t,u)}else if(typeof t==="object"){t=parse(serialize(t,u),u)}return t}function resolve(t,u,p){const m=p?Object.assign({scheme:"null"},p):{scheme:"null"};const{parsed:g,malformedAuthorityOrPort:v}=parseWithStatus(t,m);const{parsed:b,malformedAuthorityOrPort:w}=parseWithStatus(u,m);if(v||w){throw new Error(g.error||b.error||"URI is malformed.")}const E=resolveComponent(g,b,m,true);m.skipEscape=true;return serialize(E,m)}function resolveComponent(t,u,p,m){const v={};if(!m){t=parse(serialize(t,p),p);u=parse(serialize(u,p),p)}p=p||{};if(!p.tolerant&&u.scheme){v.scheme=u.scheme;v.userinfo=u.userinfo;v.host=u.host;v.port=u.port;v.path=g(u.path||"");v.query=u.query}else{if(u.userinfo!==undefined||u.host!==undefined||u.port!==undefined){v.userinfo=u.userinfo;v.host=u.host;v.port=u.port;v.path=g(u.path||"");v.query=u.query}else{if(!u.path){v.path=t.path;if(u.query!==undefined){v.query=u.query}else{v.query=t.query}}else{if(u.path[0]==="/"){v.path=g(u.path)}else{if((t.userinfo!==undefined||t.host!==undefined||t.port!==undefined)&&!t.path){v.path="/"+u.path}else if(!t.path){v.path=u.path}else{v.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+u.path}v.path=g(v.path)}v.query=u.query}v.userinfo=t.userinfo;v.host=t.host;v.port=t.port}v.scheme=t.scheme}v.fragment=u.fragment;return v}function equal(t,u,p){const m=normalizeComparableURI(t,p);const g=normalizeComparableURI(u,p);return m!==undefined&&g!==undefined&&m.toLowerCase()===g.toLowerCase()}function serialize(t,u){const p={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""};const m=Object.assign({},u);const w=[];const S=R(m.scheme||p.scheme);if(S&&S.serialize)S.serialize(p,m);if(p.path!==undefined){if(!m.skipEscape){p.path=E(p.path);if(p.scheme!==undefined){p.path=p.path.split("%3A").join(":")}}else{p.path=b(p.path)}}if(m.reference!=="suffix"&&p.scheme){w.push(p.scheme,":")}const $=v(p);if($!==undefined){if(m.reference!=="suffix"){w.push("//")}w.push($);if(p.path&&p.path[0]!=="/"){w.push("/")}}if(p.path!==undefined){let t=p.path;if(!m.absolutePath&&(!S||!S.absolutePath)){t=g(t)}if($===undefined&&t[0]==="/"&&t[1]==="/"){t="/%2F"+t.slice(2)}w.push(t)}if(p.query!==undefined){w.push("?",p.query)}if(p.fragment!==undefined){w.push("#",p.fragment)}return w.join("")}const O=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;const A=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;const k=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function getParseError(t,u){if(u[2]!==undefined&&t.path&&t.path[0]!=="/"){return'URI path must start with "/" when authority is present.'}if(typeof t.port==="number"&&(t.port<0||t.port>65535)){return"URI port is malformed."}return undefined}function parseWithStatus(t,u){const p=Object.assign({},u);const g={scheme:undefined,userinfo:undefined,host:"",port:undefined,path:"",query:undefined,fragment:undefined};let v=false;let b=false;if(p.reference==="suffix"){if(p.scheme){t=p.scheme+":"+t}else{t="//"+t}}const E=t.match(A);if(E!==null&&E[1].indexOf("\\")!==-1){g.error="URI authority must not contain a literal backslash.";v=true}const x=t.match(k);if(x!==null){const t=x[1];const u=t.replace(/[\t\n\r]/g,"");if(u.length>=2){if(u.slice(0,2)!=="//"){g.error=g.error||"URI authority must not contain a literal backslash.";v=true}else if(t.length!==u.length){g.error=g.error||"URI authority introducer must not contain whitespace.";v=true}}}const T=t.match(O);if(T){g.scheme=T[1];g.userinfo=T[3];g.host=T[4];g.port=parseInt(T[5],10);g.path=T[6]||"";g.query=T[7];g.fragment=T[8];if(isNaN(g.port)){g.port=T[5]}const u=getParseError(g,T);if(u!==undefined){g.error=g.error||u;v=true}if(g.host){const t=$(g.host);if(t===false){const t=m(g.host);g.host=t.host.toLowerCase();b=t.isIPV6}else{b=true}}if(g.scheme===undefined&&g.userinfo===undefined&&g.host===undefined&&g.port===undefined&&g.query===undefined&&!g.path){g.reference="same-document"}else if(g.scheme===undefined){g.reference="relative"}else if(g.fragment===undefined){g.reference="absolute"}else{g.reference="uri"}if(p.reference&&p.reference!=="suffix"&&p.reference!==g.reference){g.error=g.error||"URI is not a "+p.reference+" reference."}const E=R(p.scheme||g.scheme);if(!p.unicodeSupport&&(!E||!E.unicodeSupport)){if(g.host&&(p.domainHost||E&&E.domainHost)&&b===false&&P(g.host)){try{g.host=new URL("http://"+g.host).hostname}catch(t){g.error=g.error||"Host's domain name can not be converted to ASCII: "+t}}}if(!E||E&&!E.skipNormalize){if(t.indexOf("%")!==-1){if(g.scheme!==undefined){g.scheme=unescape(g.scheme)}if(g.host!==undefined){g.host=S(unescape(g.host),b)}}if(g.path){g.path=w(g.path)}if(g.fragment){try{g.fragment=encodeURI(decodeURIComponent(g.fragment))}catch{g.error=g.error||"URI malformed"}}}if(E&&E.parse){E.parse(g,p)}}else{g.error=g.error||"URI can not be parsed."}return{parsed:g,malformedAuthorityOrPort:v}}function parse(t,u){return parseWithStatus(t,u).parsed}function normalizeString(t,u){return normalizeStringWithStatus(t,u).normalized}function normalizeStringWithStatus(t,u){const{parsed:p,malformedAuthorityOrPort:m}=parseWithStatus(t,u);return{normalized:m?t:serialize(p,u),malformedAuthorityOrPort:m}}function normalizeComparableURI(t,u){if(typeof t==="string"){const{normalized:p,malformedAuthorityOrPort:m}=normalizeStringWithStatus(t,u);return m?undefined:p}if(typeof t==="object"){return serialize(t,u)}}const T={SCHEMES:x,normalize:normalize,resolve:resolve,resolveComponent:resolveComponent,equal:equal,serialize:serialize,parse:parse};t.exports=T;t.exports["default"]=T;t.exports.fastUri=T},8415:(t,u,p)=>{"use strict";const{isUUID:m}=p(6138);const g=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;const v=["http","https","ws","wss","urn","urn:uuid"];function isValidSchemeName(t){return v.indexOf(t)!==-1}function wsIsSecure(t){if(t.secure===true){return true}else if(t.secure===false){return false}else if(t.scheme){return t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S")}else{return false}}function httpParse(t){if(!t.host){t.error=t.error||"HTTP URIs must have a host."}return t}function httpSerialize(t){const u=String(t.scheme).toLowerCase()==="https";if(t.port===(u?443:80)||t.port===""){t.port=undefined}if(!t.path){t.path="/"}return t}function wsParse(t){t.secure=wsIsSecure(t);t.resourceName=(t.path||"/")+(t.query?"?"+t.query:"");t.path=undefined;t.query=undefined;return t}function wsSerialize(t){if(t.port===(wsIsSecure(t)?443:80)||t.port===""){t.port=undefined}if(typeof t.secure==="boolean"){t.scheme=t.secure?"wss":"ws";t.secure=undefined}if(t.resourceName){const[u,p]=t.resourceName.split("?");t.path=u&&u!=="/"?u:undefined;t.query=p;t.resourceName=undefined}t.fragment=undefined;return t}function urnParse(t,u){if(!t.path){t.error="URN can not be parsed";return t}const p=t.path.match(g);if(p){const m=u.scheme||t.scheme||"urn";t.nid=p[1].toLowerCase();t.nss=p[2];const g=`${m}:${u.nid||t.nid}`;const v=getSchemeHandler(g);t.path=undefined;if(v){t=v.parse(t,u)}}else{t.error=t.error||"URN can not be parsed."}return t}function urnSerialize(t,u){if(t.nid===undefined){throw new Error("URN without nid cannot be serialized")}const p=u.scheme||t.scheme||"urn";const m=t.nid.toLowerCase();const g=`${p}:${u.nid||m}`;const v=getSchemeHandler(g);if(v){t=v.serialize(t,u)}const b=t;const w=t.nss;b.path=`${m||u.nid}:${w}`;u.skipEscape=true;return b}function urnuuidParse(t,u){const p=t;p.uuid=p.nss;p.nss=undefined;if(!u.tolerant&&(!p.uuid||!m(p.uuid))){p.error=p.error||"UUID is not valid."}return p}function urnuuidSerialize(t){const u=t;u.nss=(t.uuid||"").toLowerCase();return u}const b={scheme:"http",domainHost:true,parse:httpParse,serialize:httpSerialize};const w={scheme:"https",domainHost:b.domainHost,parse:httpParse,serialize:httpSerialize};const E={scheme:"ws",domainHost:true,parse:wsParse,serialize:wsSerialize};const S={scheme:"wss",domainHost:E.domainHost,parse:E.parse,serialize:E.serialize};const $={scheme:"urn",parse:urnParse,serialize:urnSerialize,skipNormalize:true};const P={scheme:"urn:uuid",parse:urnuuidParse,serialize:urnuuidSerialize,skipNormalize:true};const x={http:b,https:w,ws:E,wss:S,urn:$,"urn:uuid":P};Object.setPrototypeOf(x,null);function getSchemeHandler(t){return t&&(x[t]||x[t.toLowerCase()])||undefined}t.exports={wsIsSecure:wsIsSecure,SCHEMES:x,isValidSchemeName:isValidSchemeName,getSchemeHandler:getSchemeHandler}},6138:t=>{"use strict";const u=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);const p=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);const m=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);const g=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);const v=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function stringArrayToHexStripped(t){let u="";let p=0;let m=0;for(m=0;m<t.length;m++){p=t[m].charCodeAt(0);if(p===48){continue}if(!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102)){return""}u+=t[m];break}for(m+=1;m<t.length;m++){p=t[m].charCodeAt(0);if(!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102)){return""}u+=t[m]}return u}const b=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function consumeIsZone(t){t.length=0;return true}function consumeHextets(t,u,p){if(t.length){const m=stringArrayToHexStripped(t);if(m!==""){u.push(m)}else{p.error=true;return false}t.length=0}return true}function getIPV6(t){let u=0;const p={error:false,address:"",zone:""};const m=[];const g=[];let v=false;let b=false;let w=consumeHextets;for(let E=0;E<t.length;E++){const S=t[E];if(S==="["||S==="]"){continue}if(S===":"){if(v===true){b=true}if(!w(g,m,p)){break}if(++u>7){p.error=true;break}if(E>0&&t[E-1]===":"){v=true}m.push(":");continue}else if(S==="%"){if(!w(g,m,p)){break}w=consumeIsZone}else{g.push(S);continue}}if(g.length){if(w===consumeIsZone){p.zone=g.join("")}else if(b){m.push(g.join(""))}else{m.push(stringArrayToHexStripped(g))}}p.address=m.join("");return p}function normalizeIPv6(t){if(findToken(t,":")<2){return{host:t,isIPV6:false}}const u=getIPV6(t);if(!u.error){let t=u.address;let p=u.address;if(u.zone){t+="%"+u.zone;p+="%25"+u.zone}return{host:t,isIPV6:true,escapedHost:p}}else{return{host:t,isIPV6:false}}}function findToken(t,u){let p=0;for(let m=0;m<t.length;m++){if(t[m]===u)p++}return p}function removeDotSegments(t){let u=t;const p=[];let m=-1;let g=0;while(g=u.length){if(g===1){if(u==="."){break}else if(u==="/"){p.push("/");break}else{p.push(u);break}}else if(g===2){if(u[0]==="."){if(u[1]==="."){break}else if(u[1]==="/"){u=u.slice(2);continue}}else if(u[0]==="/"){if(u[1]==="."||u[1]==="/"){p.push("/");break}}}else if(g===3){if(u==="/.."){if(p.length!==0){p.pop()}p.push("/");break}}if(u[0]==="."){if(u[1]==="."){if(u[2]==="/"){u=u.slice(3);continue}}else if(u[1]==="/"){u=u.slice(2);continue}}else if(u[0]==="/"){if(u[1]==="."){if(u[2]==="/"){u=u.slice(2);continue}else if(u[2]==="."){if(u[3]==="/"){u=u.slice(3);if(p.length!==0){p.pop()}continue}}}}if((m=u.indexOf("/",1))===-1){p.push(u);break}else{p.push(u.slice(0,m));u=u.slice(m)}}return p.join("")}const w={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"};const E=/[@/?#:]/g;const S=/[@/?#]/g;function reescapeHostDelimiters(t,u){const p=u?S:E;p.lastIndex=0;return t.replace(p,(t=>w[t]))}function normalizePercentEncoding(t,u=false){if(t.indexOf("%")===-1){return t}let p="";for(let v=0;v<t.length;v++){if(t[v]==="%"&&v+2<t.length){const b=t.slice(v+1,v+3);if(m(b)){const t=b.toUpperCase();const m=String.fromCharCode(parseInt(t,16));if(u&&g(m)){p+=m}else{p+="%"+t}v+=2;continue}}p+=t[v]}return p}function normalizePathEncoding(t){let u="";for(let p=0;p<t.length;p++){if(t[p]==="%"&&p+2<t.length){const v=t.slice(p+1,p+3);if(m(v)){const t=v.toUpperCase();const m=String.fromCharCode(parseInt(t,16));if(m!=="."&&g(m)){u+=m}else{u+="%"+t}p+=2;continue}}if(v(t[p])){u+=t[p]}else{u+=escape(t[p])}}return u}function escapePreservingEscapes(t){let u="";for(let p=0;p<t.length;p++){if(t[p]==="%"&&p+2<t.length){const g=t.slice(p+1,p+3);if(m(g)){u+="%"+g.toUpperCase();p+=2;continue}}u+=escape(t[p])}return u}function recomposeAuthority(t){const u=[];if(t.userinfo!==undefined){u.push(t.userinfo);u.push("@")}if(t.host!==undefined){let m=unescape(t.host);if(!p(m)){const t=normalizeIPv6(m);if(t.isIPV6===true){m=`[${t.escapedHost}]`}else{m=reescapeHostDelimiters(m,false)}}u.push(m)}if(typeof t.port==="number"||typeof t.port==="string"){u.push(":");u.push(String(t.port))}return u.length?u.join(""):undefined}t.exports={nonSimpleDomain:b,recomposeAuthority:recomposeAuthority,reescapeHostDelimiters:reescapeHostDelimiters,normalizePercentEncoding:normalizePercentEncoding,normalizePathEncoding:normalizePathEncoding,escapePreservingEscapes:escapePreservingEscapes,removeDotSegments:removeDotSegments,isIPv4:p,isUUID:u,normalizeIPv6:normalizeIPv6,stringArrayToHexStripped:stringArrayToHexStripped}},8909:(t,u,p)=>{const{Argument:m}=p(9154);const{Command:g}=p(4348);const{CommanderError:v,InvalidArgumentError:b}=p(1135);const{Help:w}=p(9754);const{Option:E}=p(5240);u.DM=new g;u.gu=t=>new g(t);u.Ww=(t,u)=>new E(t,u);u.er=(t,u)=>new m(t,u);u.uB=g;u.c$=E;u.ef=m;u._V=w;u.b7=v;u.Di=b;u.a2=b},9154:(t,u,p)=>{const{InvalidArgumentError:m}=p(1135);class Argument{constructor(t,u){this.description=u||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(t[0]){case"<":this.required=true;this._name=t.slice(1,-1);break;case"[":this.required=false;this._name=t.slice(1,-1);break;default:this.required=true;this._name=t;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(t,u){if(u===this.defaultValue||!Array.isArray(u)){return[t]}return u.concat(t)}default(t,u){this.defaultValue=t;this.defaultValueDescription=u;return this}argParser(t){this.parseArg=t;return this}choices(t){this.argChoices=t.slice();this.parseArg=(t,u)=>{if(!this.argChoices.includes(t)){throw new m(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,u)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(t){const u=t.name()+(t.variadic===true?"...":"");return t.required?"<"+u+">":"["+u+"]"}u.Argument=Argument;u.humanReadableArgName=humanReadableArgName},4348:(t,u,p)=>{const m=p(8474).EventEmitter;const g=p(1421);const v=p(6760);const b=p(3024);const w=p(1708);const{Argument:E,humanReadableArgName:S}=p(9154);const{CommanderError:$}=p(1135);const{Help:P}=p(9754);const{Option:x,DualOptions:R}=p(5240);const{suggestSimilar:O}=p(5030);class Command extends m{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this.registeredArguments=[];this._args=this.registeredArguments;this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=t||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._executableDir=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._summary="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=true;this._outputConfiguration={writeOut:t=>w.stdout.write(t),writeErr:t=>w.stderr.write(t),getOutHelpWidth:()=>w.stdout.isTTY?w.stdout.columns:undefined,getErrHelpWidth:()=>w.stderr.isTTY?w.stderr.columns:undefined,outputError:(t,u)=>u(t)};this._hidden=false;this._helpOption=undefined;this._addImplicitHelpCommand=undefined;this._helpCommand=undefined;this._helpConfiguration={}}copyInheritedSettings(t){this._outputConfiguration=t._outputConfiguration;this._helpOption=t._helpOption;this._helpCommand=t._helpCommand;this._helpConfiguration=t._helpConfiguration;this._exitCallback=t._exitCallback;this._storeOptionsAsProperties=t._storeOptionsAsProperties;this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue;this._allowExcessArguments=t._allowExcessArguments;this._enablePositionalOptions=t._enablePositionalOptions;this._showHelpAfterError=t._showHelpAfterError;this._showSuggestionAfterError=t._showSuggestionAfterError;return this}_getCommandAndAncestors(){const t=[];for(let u=this;u;u=u.parent){t.push(u)}return t}command(t,u,p){let m=u;let g=p;if(typeof m==="object"&&m!==null){g=m;m=null}g=g||{};const[,v,b]=t.match(/([^ ]+) *(.*)/);const w=this.createCommand(v);if(m){w.description(m);w._executableHandler=true}if(g.isDefault)this._defaultCommandName=w._name;w._hidden=!!(g.noHelp||g.hidden);w._executableFile=g.executableFile||null;if(b)w.arguments(b);this._registerCommand(w);w.parent=this;w.copyInheritedSettings(this);if(m)return this;return w}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new P,this.configureHelp())}configureHelp(t){if(t===undefined)return this._helpConfiguration;this._helpConfiguration=t;return this}configureOutput(t){if(t===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,t);return this}showHelpAfterError(t=true){if(typeof t!=="string")t=!!t;this._showHelpAfterError=t;return this}showSuggestionAfterError(t=true){this._showSuggestionAfterError=!!t;return this}addCommand(t,u){if(!t._name){throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`)}u=u||{};if(u.isDefault)this._defaultCommandName=t._name;if(u.noHelp||u.hidden)t._hidden=true;this._registerCommand(t);t.parent=this;t._checkForBrokenPassThrough();return this}createArgument(t,u){return new E(t,u)}argument(t,u,p,m){const g=this.createArgument(t,u);if(typeof p==="function"){g.default(m).argParser(p)}else{g.default(p)}this.addArgument(g);return this}arguments(t){t.trim().split(/ +/).forEach((t=>{this.argument(t)}));return this}addArgument(t){const u=this.registeredArguments.slice(-1)[0];if(u&&u.variadic){throw new Error(`only the last argument can be variadic '${u.name()}'`)}if(t.required&&t.defaultValue!==undefined&&t.parseArg===undefined){throw new Error(`a default value for a required argument is never used: '${t.name()}'`)}this.registeredArguments.push(t);return this}helpCommand(t,u){if(typeof t==="boolean"){this._addImplicitHelpCommand=t;return this}t=t??"help [command]";const[,p,m]=t.match(/([^ ]+) *(.*)/);const g=u??"display help for command";const v=this.createCommand(p);v.helpOption(false);if(m)v.arguments(m);if(g)v.description(g);this._addImplicitHelpCommand=true;this._helpCommand=v;return this}addHelpCommand(t,u){if(typeof t!=="object"){this.helpCommand(t,u);return this}this._addImplicitHelpCommand=true;this._helpCommand=t;return this}_getHelpCommand(){const t=this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"));if(t){if(this._helpCommand===undefined){this.helpCommand(undefined,undefined)}return this._helpCommand}return null}hook(t,u){const p=["preSubcommand","preAction","postAction"];if(!p.includes(t)){throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${p.join("', '")}'`)}if(this._lifeCycleHooks[t]){this._lifeCycleHooks[t].push(u)}else{this._lifeCycleHooks[t]=[u]}return this}exitOverride(t){if(t){this._exitCallback=t}else{this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync"){throw t}else{}}}return this}_exit(t,u,p){if(this._exitCallback){this._exitCallback(new $(t,u,p))}w.exit(t)}action(t){const listener=u=>{const p=this.registeredArguments.length;const m=u.slice(0,p);if(this._storeOptionsAsProperties){m[p]=this}else{m[p]=this.opts()}m.push(this);return t.apply(this,m)};this._actionHandler=listener;return this}createOption(t,u){return new x(t,u)}_callParseArg(t,u,p,m){try{return t.parseArg(u,p)}catch(t){if(t.code==="commander.invalidArgument"){const u=`${m} ${t.message}`;this.error(u,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(t){const u=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(u){const p=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${p}'\n- already used by option '${u.flags}'`)}this.options.push(t)}_registerCommand(t){const knownBy=t=>[t.name()].concat(t.aliases());const u=knownBy(t).find((t=>this._findCommand(t)));if(u){const p=knownBy(this._findCommand(u)).join("|");const m=knownBy(t).join("|");throw new Error(`cannot add command '${m}' as already have command '${p}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);const u=t.name();const p=t.attributeName();if(t.negate){const u=t.long.replace(/^--no-/,"--");if(!this._findOption(u)){this.setOptionValueWithSource(p,t.defaultValue===undefined?true:t.defaultValue,"default")}}else if(t.defaultValue!==undefined){this.setOptionValueWithSource(p,t.defaultValue,"default")}const handleOptionValue=(u,m,g)=>{if(u==null&&t.presetArg!==undefined){u=t.presetArg}const v=this.getOptionValue(p);if(u!==null&&t.parseArg){u=this._callParseArg(t,u,v,m)}else if(u!==null&&t.variadic){u=t._concatValue(u,v)}if(u==null){if(t.negate){u=false}else if(t.isBoolean()||t.optional){u=true}else{u=""}}this.setOptionValueWithSource(p,u,g)};this.on("option:"+u,(u=>{const p=`error: option '${t.flags}' argument '${u}' is invalid.`;handleOptionValue(u,p,"cli")}));if(t.envVar){this.on("optionEnv:"+u,(u=>{const p=`error: option '${t.flags}' value '${u}' from env '${t.envVar}' is invalid.`;handleOptionValue(u,p,"env")}))}return this}_optionEx(t,u,p,m,g){if(typeof u==="object"&&u instanceof x){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const v=this.createOption(u,p);v.makeOptionMandatory(!!t.mandatory);if(typeof m==="function"){v.default(g).argParser(m)}else if(m instanceof RegExp){const t=m;m=(u,p)=>{const m=t.exec(u);return m?m[0]:p};v.default(g).argParser(m)}else{v.default(m)}return this.addOption(v)}option(t,u,p,m){return this._optionEx({},t,u,p,m)}requiredOption(t,u,p,m){return this._optionEx({mandatory:true},t,u,p,m)}combineFlagAndOptionalValue(t=true){this._combineFlagAndOptionalValue=!!t;return this}allowUnknownOption(t=true){this._allowUnknownOption=!!t;return this}allowExcessArguments(t=true){this._allowExcessArguments=!!t;return this}enablePositionalOptions(t=true){this._enablePositionalOptions=!!t;return this}passThroughOptions(t=true){this._passThroughOptions=!!t;this._checkForBrokenPassThrough();return this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions){throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}}storeOptionsAsProperties(t=true){if(this.options.length){throw new Error("call .storeOptionsAsProperties() before adding options")}if(Object.keys(this._optionValues).length){throw new Error("call .storeOptionsAsProperties() before setting option values")}this._storeOptionsAsProperties=!!t;return this}getOptionValue(t){if(this._storeOptionsAsProperties){return this[t]}return this._optionValues[t]}setOptionValue(t,u){return this.setOptionValueWithSource(t,u,undefined)}setOptionValueWithSource(t,u,p){if(this._storeOptionsAsProperties){this[t]=u}else{this._optionValues[t]=u}this._optionValueSources[t]=p;return this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let u;this._getCommandAndAncestors().forEach((p=>{if(p.getOptionValueSource(t)!==undefined){u=p.getOptionValueSource(t)}}));return u}_prepareUserArgs(t,u){if(t!==undefined&&!Array.isArray(t)){throw new Error("first parameter to parse must be array or undefined")}u=u||{};if(t===undefined&&u.from===undefined){if(w.versions?.electron){u.from="electron"}const t=w.execArgv??[];if(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print")){u.from="eval"}}if(t===undefined){t=w.argv}this.rawArgs=t.slice();let p;switch(u.from){case undefined:case"node":this._scriptPath=t[1];p=t.slice(2);break;case"electron":if(w.defaultApp){this._scriptPath=t[1];p=t.slice(2)}else{p=t.slice(1)}break;case"user":p=t.slice(0);break;case"eval":p=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${u.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);this._name=this._name||"program";return p}parse(t,u){const p=this._prepareUserArgs(t,u);this._parseCommand([],p);return this}async parseAsync(t,u){const p=this._prepareUserArgs(t,u);await this._parseCommand([],p);return this}_executeSubCommand(t,u){u=u.slice();let p=false;const m=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,u){const p=v.resolve(t,u);if(b.existsSync(p))return p;if(m.includes(v.extname(u)))return undefined;const g=m.find((t=>b.existsSync(`${p}${t}`)));if(g)return`${p}${g}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let E=t._executableFile||`${this._name}-${t._name}`;let S=this._executableDir||"";if(this._scriptPath){let t;try{t=b.realpathSync(this._scriptPath)}catch(u){t=this._scriptPath}S=v.resolve(v.dirname(t),S)}if(S){let u=findFile(S,E);if(!u&&!t._executableFile&&this._scriptPath){const p=v.basename(this._scriptPath,v.extname(this._scriptPath));if(p!==this._name){u=findFile(S,`${p}-${t._name}`)}}E=u||E}p=m.includes(v.extname(E));let P;if(w.platform!=="win32"){if(p){u.unshift(E);u=incrementNodeInspectorPort(w.execArgv).concat(u);P=g.spawn(w.argv[0],u,{stdio:"inherit"})}else{P=g.spawn(E,u,{stdio:"inherit"})}}else{u.unshift(E);u=incrementNodeInspectorPort(w.execArgv).concat(u);P=g.spawn(w.execPath,u,{stdio:"inherit"})}if(!P.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{w.on(t,(()=>{if(P.killed===false&&P.exitCode===null){P.kill(t)}}))}))}const x=this._exitCallback;P.on("close",(t=>{t=t??1;if(!x){w.exit(t)}else{x(new $(t,"commander.executeSubCommandAsync","(close)"))}}));P.on("error",(u=>{if(u.code==="ENOENT"){const u=S?`searched for local subcommand relative to directory '${S}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const p=`'${E}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${u}`;throw new Error(p)}else if(u.code==="EACCES"){throw new Error(`'${E}' not executable`)}if(!x){w.exit(1)}else{const t=new $(1,"commander.executeSubCommandAsync","(error)");t.nestedError=u;x(t)}}));this.runningCommand=P}_dispatchSubcommand(t,u,p){const m=this._findCommand(t);if(!m)this.help({error:true});let g;g=this._chainOrCallSubCommandHook(g,m,"preSubcommand");g=this._chainOrCall(g,(()=>{if(m._executableHandler){this._executeSubCommand(m,u.concat(p))}else{return m._parseCommand(u,p)}}));return g}_dispatchHelpCommand(t){if(!t){this.help()}const u=this._findCommand(t);if(u&&!u._executableHandler){u.help()}return this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach(((t,u)=>{if(t.required&&this.args[u]==null){this.missingArgument(t.name())}}));if(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic){return}if(this.args.length>this.registeredArguments.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(t,u,p)=>{let m=u;if(u!==null&&t.parseArg){const g=`error: command-argument value '${u}' is invalid for argument '${t.name()}'.`;m=this._callParseArg(t,u,p,g)}return m};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((u,p)=>{let m=u.defaultValue;if(u.variadic){if(p<this.args.length){m=this.args.slice(p);if(u.parseArg){m=m.reduce(((t,p)=>myParseArg(u,p,t)),u.defaultValue)}}else if(m===undefined){m=[]}}else if(p<this.args.length){m=this.args[p];if(u.parseArg){m=myParseArg(u,m,u.defaultValue)}}t[p]=m}));this.processedArgs=t}_chainOrCall(t,u){if(t&&t.then&&typeof t.then==="function"){return t.then((()=>u()))}return u()}_chainOrCallHooks(t,u){let p=t;const m=[];this._getCommandAndAncestors().reverse().filter((t=>t._lifeCycleHooks[u]!==undefined)).forEach((t=>{t._lifeCycleHooks[u].forEach((u=>{m.push({hookedCommand:t,callback:u})}))}));if(u==="postAction"){m.reverse()}m.forEach((t=>{p=this._chainOrCall(p,(()=>t.callback(t.hookedCommand,this)))}));return p}_chainOrCallSubCommandHook(t,u,p){let m=t;if(this._lifeCycleHooks[p]!==undefined){this._lifeCycleHooks[p].forEach((t=>{m=this._chainOrCall(m,(()=>t(this,u)))}))}return m}_parseCommand(t,u){const p=this.parseOptions(u);this._parseOptionsEnv();this._parseOptionsImplied();t=t.concat(p.operands);u=p.unknown;this.args=t.concat(u);if(t&&this._findCommand(t[0])){return this._dispatchSubcommand(t[0],t.slice(1),u)}if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name()){return this._dispatchHelpCommand(t[1])}if(this._defaultCommandName){this._outputHelpIfRequested(u);return this._dispatchSubcommand(this._defaultCommandName,t,u)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}this._outputHelpIfRequested(p.unknown);this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();const checkForUnknownOptions=()=>{if(p.unknown.length>0){this.unknownOption(p.unknown[0])}};const m=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let p;p=this._chainOrCallHooks(p,"preAction");p=this._chainOrCall(p,(()=>this._actionHandler(this.processedArgs)));if(this.parent){p=this._chainOrCall(p,(()=>{this.parent.emit(m,t,u)}))}p=this._chainOrCallHooks(p,"postAction");return p}if(this.parent&&this.parent.listenerCount(m)){checkForUnknownOptions();this._processArguments();this.parent.emit(m,t,u)}else if(t.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",t,u)}if(this.listenerCount("command:*")){this.emit("command:*",t,u)}else if(this.commands.length){this.unknownCommand()}else{checkForUnknownOptions();this._processArguments()}}else if(this.commands.length){checkForUnknownOptions();this.help({error:true})}else{checkForUnknownOptions();this._processArguments()}}_findCommand(t){if(!t)return undefined;return this.commands.find((u=>u._name===t||u._aliases.includes(t)))}_findOption(t){return this.options.find((u=>u.is(t)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((t=>{t.options.forEach((u=>{if(u.mandatory&&t.getOptionValue(u.attributeName())===undefined){t.missingMandatoryOptionValue(u)}}))}))}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const u=t.attributeName();if(this.getOptionValue(u)===undefined){return false}return this.getOptionValueSource(u)!=="default"}));const u=t.filter((t=>t.conflictsWith.length>0));u.forEach((u=>{const p=t.find((t=>u.conflictsWith.includes(t.attributeName())));if(p){this._conflictingOption(u,p)}}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((t=>{t._checkForConflictingLocalOptions()}))}parseOptions(t){const u=[];const p=[];let m=u;const g=t.slice();function maybeOption(t){return t.length>1&&t[0]==="-"}let v=null;while(g.length){const t=g.shift();if(t==="--"){if(m===p)m.push(t);m.push(...g);break}if(v&&!maybeOption(t)){this.emit(`option:${v.name()}`,t);continue}v=null;if(maybeOption(t)){const u=this._findOption(t);if(u){if(u.required){const t=g.shift();if(t===undefined)this.optionMissingArgument(u);this.emit(`option:${u.name()}`,t)}else if(u.optional){let t=null;if(g.length>0&&!maybeOption(g[0])){t=g.shift()}this.emit(`option:${u.name()}`,t)}else{this.emit(`option:${u.name()}`)}v=u.variadic?u:null;continue}}if(t.length>2&&t[0]==="-"&&t[1]!=="-"){const u=this._findOption(`-${t[1]}`);if(u){if(u.required||u.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${u.name()}`,t.slice(2))}else{this.emit(`option:${u.name()}`);g.unshift(`-${t.slice(2)}`)}continue}}if(/^--[^=]+=/.test(t)){const u=t.indexOf("=");const p=this._findOption(t.slice(0,u));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,t.slice(u+1));continue}}if(maybeOption(t)){m=p}if((this._enablePositionalOptions||this._passThroughOptions)&&u.length===0&&p.length===0){if(this._findCommand(t)){u.push(t);if(g.length>0)p.push(...g);break}else if(this._getHelpCommand()&&t===this._getHelpCommand().name()){u.push(t);if(g.length>0)u.push(...g);break}else if(this._defaultCommandName){p.push(t);if(g.length>0)p.push(...g);break}}if(this._passThroughOptions){m.push(t);if(g.length>0)m.push(...g);break}m.push(t)}return{operands:u,unknown:p}}opts(){if(this._storeOptionsAsProperties){const t={};const u=this.options.length;for(let p=0;p<u;p++){const u=this.options[p].attributeName();t[u]=u===this._versionOptionName?this._version:this[u]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(((t,u)=>Object.assign(t,u.opts())),{})}error(t,u){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr);if(typeof this._showHelpAfterError==="string"){this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`)}else if(this._showHelpAfterError){this._outputConfiguration.writeErr("\n");this.outputHelp({error:true})}const p=u||{};const m=p.exitCode||1;const g=p.code||"commander.error";this._exit(m,g,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in w.env){const u=t.attributeName();if(this.getOptionValue(u)===undefined||["default","config","env"].includes(this.getOptionValueSource(u))){if(t.required||t.optional){this.emit(`optionEnv:${t.name()}`,w.env[t.envVar])}else{this.emit(`optionEnv:${t.name()}`)}}}}))}_parseOptionsImplied(){const t=new R(this.options);const hasCustomOptionValue=t=>this.getOptionValue(t)!==undefined&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((u=>u.implied!==undefined&&hasCustomOptionValue(u.attributeName())&&t.valueFromOption(this.getOptionValue(u.attributeName()),u))).forEach((t=>{Object.keys(t.implied).filter((t=>!hasCustomOptionValue(t))).forEach((u=>{this.setOptionValueWithSource(u,t.implied[u],"implied")}))}))}missingArgument(t){const u=`error: missing required argument '${t}'`;this.error(u,{code:"commander.missingArgument"})}optionMissingArgument(t){const u=`error: option '${t.flags}' argument missing`;this.error(u,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const u=`error: required option '${t.flags}' not specified`;this.error(u,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,u){const findBestOptionFromValue=t=>{const u=t.attributeName();const p=this.getOptionValue(u);const m=this.options.find((t=>t.negate&&u===t.attributeName()));const g=this.options.find((t=>!t.negate&&u===t.attributeName()));if(m&&(m.presetArg===undefined&&p===false||m.presetArg!==undefined&&p===m.presetArg)){return m}return g||t};const getErrorMessage=t=>{const u=findBestOptionFromValue(t);const p=u.attributeName();const m=this.getOptionValueSource(p);if(m==="env"){return`environment variable '${u.envVar}'`}return`option '${u.flags}'`};const p=`error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(u)}`;this.error(p,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let u="";if(t.startsWith("--")&&this._showSuggestionAfterError){let p=[];let m=this;do{const t=m.createHelp().visibleOptions(m).filter((t=>t.long)).map((t=>t.long));p=p.concat(t);m=m.parent}while(m&&!m._enablePositionalOptions);u=O(t,p)}const p=`error: unknown option '${t}'${u}`;this.error(p,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const u=this.registeredArguments.length;const p=u===1?"":"s";const m=this.parent?` for '${this.name()}'`:"";const g=`error: too many arguments${m}. Expected ${u} argument${p} but got ${t.length}.`;this.error(g,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let u="";if(this._showSuggestionAfterError){const p=[];this.createHelp().visibleCommands(this).forEach((t=>{p.push(t.name());if(t.alias())p.push(t.alias())}));u=O(t,p)}const p=`error: unknown command '${t}'${u}`;this.error(p,{code:"commander.unknownCommand"})}version(t,u,p){if(t===undefined)return this._version;this._version=t;u=u||"-V, --version";p=p||"output the version number";const m=this.createOption(u,p);this._versionOptionName=m.attributeName();this._registerOption(m);this.on("option:"+m.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`);this._exit(0,"commander.version",t)}));return this}description(t,u){if(t===undefined&&u===undefined)return this._description;this._description=t;if(u){this._argsDescription=u}return this}summary(t){if(t===undefined)return this._summary;this._summary=t;return this}alias(t){if(t===undefined)return this._aliases[0];let u=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){u=this.commands[this.commands.length-1]}if(t===u._name)throw new Error("Command alias can't be the same as its name");const p=this.parent?._findCommand(t);if(p){const u=[p.name()].concat(p.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${u}'`)}u._aliases.push(t);return this}aliases(t){if(t===undefined)return this._aliases;t.forEach((t=>this.alias(t)));return this}usage(t){if(t===undefined){if(this._usage)return this._usage;const t=this.registeredArguments.map((t=>S(t)));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}this._usage=t;return this}name(t){if(t===undefined)return this._name;this._name=t;return this}nameFromFilename(t){this._name=v.basename(t,v.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const u=this.createHelp();if(u.helpWidth===undefined){u.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return u.formatHelp(this,u)}_getHelpContext(t){t=t||{};const u={error:!!t.error};let p;if(u.error){p=t=>this._outputConfiguration.writeErr(t)}else{p=t=>this._outputConfiguration.writeOut(t)}u.write=t.write||p;u.command=this;return u}outputHelp(t){let u;if(typeof t==="function"){u=t;t=undefined}const p=this._getHelpContext(t);this._getCommandAndAncestors().reverse().forEach((t=>t.emit("beforeAllHelp",p)));this.emit("beforeHelp",p);let m=this.helpInformation(p);if(u){m=u(m);if(typeof m!=="string"&&!Buffer.isBuffer(m)){throw new Error("outputHelp callback must return a string or a Buffer")}}p.write(m);if(this._getHelpOption()?.long){this.emit(this._getHelpOption().long)}this.emit("afterHelp",p);this._getCommandAndAncestors().forEach((t=>t.emit("afterAllHelp",p)))}helpOption(t,u){if(typeof t==="boolean"){if(t){this._helpOption=this._helpOption??undefined}else{this._helpOption=null}return this}t=t??"-h, --help";u=u??"display help for command";this._helpOption=this.createOption(t,u);return this}_getHelpOption(){if(this._helpOption===undefined){this.helpOption(undefined,undefined)}return this._helpOption}addHelpOption(t){this._helpOption=t;return this}help(t){this.outputHelp(t);let u=w.exitCode||0;if(u===0&&t&&typeof t!=="function"&&t.error){u=1}this._exit(u,"commander.help","(outputHelp)")}addHelpText(t,u){const p=["beforeAll","before","after","afterAll"];if(!p.includes(t)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${p.join("', '")}'`)}const m=`${t}Help`;this.on(m,(t=>{let p;if(typeof u==="function"){p=u({error:t.error,command:t.command})}else{p=u}if(p){t.write(`${p}\n`)}}));return this}_outputHelpIfRequested(t){const u=this._getHelpOption();const p=u&&t.find((t=>u.is(t)));if(p){this.outputHelp();this._exit(0,"commander.helpDisplayed","(outputHelp)")}}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect")){return t}let u;let p="127.0.0.1";let m="9229";let g;if((g=t.match(/^(--inspect(-brk)?)$/))!==null){u=g[1]}else if((g=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){u=g[1];if(/^\d+$/.test(g[3])){m=g[3]}else{p=g[3]}}else if((g=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){u=g[1];p=g[3];m=g[4]}if(u&&m!=="0"){return`${u}=${p}:${parseInt(m)+1}`}return t}))}u.Command=Command},1135:(t,u)=>{class CommanderError extends Error{constructor(t,u,p){super(p);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=u;this.exitCode=t;this.nestedError=undefined}}class InvalidArgumentError extends CommanderError{constructor(t){super(1,"commander.invalidArgument",t);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name}}u.CommanderError=CommanderError;u.InvalidArgumentError=InvalidArgumentError},9754:(t,u,p)=>{const{humanReadableArgName:m}=p(9154);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false;this.showGlobalOptions=false}visibleCommands(t){const u=t.commands.filter((t=>!t._hidden));const p=t._getHelpCommand();if(p&&!p._hidden){u.push(p)}if(this.sortSubcommands){u.sort(((t,u)=>t.name().localeCompare(u.name())))}return u}compareOptions(t,u){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return getSortKey(t).localeCompare(getSortKey(u))}visibleOptions(t){const u=t.options.filter((t=>!t.hidden));const p=t._getHelpOption();if(p&&!p.hidden){const m=p.short&&t._findOption(p.short);const g=p.long&&t._findOption(p.long);if(!m&&!g){u.push(p)}else if(p.long&&!g){u.push(t.createOption(p.long,p.description))}else if(p.short&&!m){u.push(t.createOption(p.short,p.description))}}if(this.sortOptions){u.sort(this.compareOptions)}return u}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const u=[];for(let p=t.parent;p;p=p.parent){const t=p.options.filter((t=>!t.hidden));u.push(...t)}if(this.sortOptions){u.sort(this.compareOptions)}return u}visibleArguments(t){if(t._argsDescription){t.registeredArguments.forEach((u=>{u.description=u.description||t._argsDescription[u.name()]||""}))}if(t.registeredArguments.find((t=>t.description))){return t.registeredArguments}return[]}subcommandTerm(t){const u=t.registeredArguments.map((t=>m(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(u?" "+u:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,u){return u.visibleCommands(t).reduce(((t,p)=>Math.max(t,u.subcommandTerm(p).length)),0)}longestOptionTermLength(t,u){return u.visibleOptions(t).reduce(((t,p)=>Math.max(t,u.optionTerm(p).length)),0)}longestGlobalOptionTermLength(t,u){return u.visibleGlobalOptions(t).reduce(((t,p)=>Math.max(t,u.optionTerm(p).length)),0)}longestArgumentTermLength(t,u){return u.visibleArguments(t).reduce(((t,p)=>Math.max(t,u.argumentTerm(p).length)),0)}commandUsage(t){let u=t._name;if(t._aliases[0]){u=u+"|"+t._aliases[0]}let p="";for(let u=t.parent;u;u=u.parent){p=u.name()+" "+p}return p+u+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const u=[];if(t.argChoices){u.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){const p=t.required||t.optional||t.isBoolean()&&typeof t.defaultValue==="boolean";if(p){u.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}}if(t.presetArg!==undefined&&t.optional){u.push(`preset: ${JSON.stringify(t.presetArg)}`)}if(t.envVar!==undefined){u.push(`env: ${t.envVar}`)}if(u.length>0){return`${t.description} (${u.join(", ")})`}return t.description}argumentDescription(t){const u=[];if(t.argChoices){u.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){u.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}if(u.length>0){const p=`(${u.join(", ")})`;if(t.description){return`${t.description} ${p}`}return p}return t.description}formatHelp(t,u){const p=u.padWidth(t,u);const m=u.helpWidth||80;const g=2;const v=2;function formatItem(t,b){if(b){const w=`${t.padEnd(p+v)}${b}`;return u.wrap(w,m-g,p+v)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(g))}let b=[`Usage: ${u.commandUsage(t)}`,""];const w=u.commandDescription(t);if(w.length>0){b=b.concat([u.wrap(w,m,0),""])}const E=u.visibleArguments(t).map((t=>formatItem(u.argumentTerm(t),u.argumentDescription(t))));if(E.length>0){b=b.concat(["Arguments:",formatList(E),""])}const S=u.visibleOptions(t).map((t=>formatItem(u.optionTerm(t),u.optionDescription(t))));if(S.length>0){b=b.concat(["Options:",formatList(S),""])}if(this.showGlobalOptions){const p=u.visibleGlobalOptions(t).map((t=>formatItem(u.optionTerm(t),u.optionDescription(t))));if(p.length>0){b=b.concat(["Global Options:",formatList(p),""])}}const $=u.visibleCommands(t).map((t=>formatItem(u.subcommandTerm(t),u.subcommandDescription(t))));if($.length>0){b=b.concat(["Commands:",formatList($),""])}return b.join("\n")}padWidth(t,u){return Math.max(u.longestOptionTermLength(t,u),u.longestGlobalOptionTermLength(t,u),u.longestSubcommandTermLength(t,u),u.longestArgumentTermLength(t,u))}wrap(t,u,p,m=40){const g=" \\f\\t\\v - \ufeff";const v=new RegExp(`[\\n][${g}]+`);if(t.match(v))return t;const b=u-p;if(b<m)return t;const w=t.slice(0,p);const E=t.slice(p).replace("\r\n","\n");const S=" ".repeat(p);const $="";const P=`\\s${$}`;const x=new RegExp(`\n|.{1,${b-1}}([${P}]|$)|[^${P}]+?([${P}]|$)`,"g");const R=E.match(x)||[];return w+R.map(((t,u)=>{if(t==="\n")return"";return(u>0?S:"")+t.trimEnd()})).join("\n")}}u.Help=Help},5240:(t,u,p)=>{const{InvalidArgumentError:m}=p(1135);class Option{constructor(t,u){this.flags=t;this.description=u||"";this.required=t.includes("<");this.optional=t.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(t);this.mandatory=false;const p=splitOptionFlags(t);this.short=p.shortFlag;this.long=p.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.presetArg=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined;this.conflictsWith=[];this.implied=undefined}default(t,u){this.defaultValue=t;this.defaultValueDescription=u;return this}preset(t){this.presetArg=t;return this}conflicts(t){this.conflictsWith=this.conflictsWith.concat(t);return this}implies(t){let u=t;if(typeof t==="string"){u={[t]:true}}this.implied=Object.assign(this.implied||{},u);return this}env(t){this.envVar=t;return this}argParser(t){this.parseArg=t;return this}makeOptionMandatory(t=true){this.mandatory=!!t;return this}hideHelp(t=true){this.hidden=!!t;return this}_concatValue(t,u){if(u===this.defaultValue||!Array.isArray(u)){return[t]}return u.concat(t)}choices(t){this.argChoices=t.slice();this.parseArg=(t,u)=>{if(!this.argChoices.includes(t)){throw new m(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,u)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class DualOptions{constructor(t){this.positiveOptions=new Map;this.negativeOptions=new Map;this.dualOptions=new Set;t.forEach((t=>{if(t.negate){this.negativeOptions.set(t.attributeName(),t)}else{this.positiveOptions.set(t.attributeName(),t)}}));this.negativeOptions.forEach(((t,u)=>{if(this.positiveOptions.has(u)){this.dualOptions.add(u)}}))}valueFromOption(t,u){const p=u.attributeName();if(!this.dualOptions.has(p))return true;const m=this.negativeOptions.get(p).presetArg;const g=m!==undefined?m:false;return u.negate===(g===t)}}function camelcase(t){return t.split("-").reduce(((t,u)=>t+u[0].toUpperCase()+u.slice(1)))}function splitOptionFlags(t){let u;let p;const m=t.split(/[ |,]+/);if(m.length>1&&!/^[[<]/.test(m[1]))u=m.shift();p=m.shift();if(!u&&/^-[^-]$/.test(p)){u=p;p=undefined}return{shortFlag:u,longFlag:p}}u.Option=Option;u.DualOptions=DualOptions},5030:(t,u)=>{const p=3;function editDistance(t,u){if(Math.abs(t.length-u.length)>p)return Math.max(t.length,u.length);const m=[];for(let u=0;u<=t.length;u++){m[u]=[u]}for(let t=0;t<=u.length;t++){m[0][t]=t}for(let p=1;p<=u.length;p++){for(let g=1;g<=t.length;g++){let v=1;if(t[g-1]===u[p-1]){v=0}else{v=1}m[g][p]=Math.min(m[g-1][p]+1,m[g][p-1]+1,m[g-1][p-1]+v);if(g>1&&p>1&&t[g-1]===u[p-2]&&t[g-2]===u[p-1]){m[g][p]=Math.min(m[g][p],m[g-2][p-2]+1)}}}return m[t.length][u.length]}function suggestSimilar(t,u){if(!u||u.length===0)return"";u=Array.from(new Set(u));const m=t.startsWith("--");if(m){t=t.slice(2);u=u.map((t=>t.slice(2)))}let g=[];let v=p;const b=.4;u.forEach((u=>{if(u.length<=1)return;const p=editDistance(t,u);const m=Math.max(t.length,u.length);const w=(m-p)/m;if(w>b){if(p<v){v=p;g=[u]}else if(p===v){g.push(u)}}}));g.sort(((t,u)=>t.localeCompare(u)));if(m){g=g.map((t=>`--${t}`))}if(g.length>1){return`\n(Did you mean one of ${g.join(", ")}?)`}if(g.length===1){return`\n(Did you mean ${g[0]}?)`}return""}u.suggestSimilar=suggestSimilar},3770:t=>{"use strict";t.exports=JSON.parse('{"$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON AnySchema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},13:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/applicator","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/applicator":true},"$dynamicAnchor":"meta","title":"Applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"prefixItems":{"$ref":"#/$defs/schemaArray"},"items":{"$dynamicRef":"#meta"},"contains":{"$dynamicRef":"#meta"},"additionalProperties":{"$dynamicRef":"#meta"},"properties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"propertyNames":{"format":"regex"},"default":{}},"dependentSchemas":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"propertyNames":{"$dynamicRef":"#meta"},"if":{"$dynamicRef":"#meta"},"then":{"$dynamicRef":"#meta"},"else":{"$dynamicRef":"#meta"},"allOf":{"$ref":"#/$defs/schemaArray"},"anyOf":{"$ref":"#/$defs/schemaArray"},"oneOf":{"$ref":"#/$defs/schemaArray"},"not":{"$dynamicRef":"#meta"}},"$defs":{"schemaArray":{"type":"array","minItems":1,"items":{"$dynamicRef":"#meta"}}}}')},2394:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/content","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Content vocabulary meta-schema","type":["object","boolean"],"properties":{"contentEncoding":{"type":"string"},"contentMediaType":{"type":"string"},"contentSchema":{"$dynamicRef":"#meta"}}}')},4771:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/core","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true},"$dynamicAnchor":"meta","title":"Core vocabulary meta-schema","type":["object","boolean"],"properties":{"$id":{"$ref":"#/$defs/uriReferenceString","$comment":"Non-empty fragments not allowed.","pattern":"^[^#]*#?$"},"$schema":{"$ref":"#/$defs/uriString"},"$ref":{"$ref":"#/$defs/uriReferenceString"},"$anchor":{"$ref":"#/$defs/anchorString"},"$dynamicRef":{"$ref":"#/$defs/uriReferenceString"},"$dynamicAnchor":{"$ref":"#/$defs/anchorString"},"$vocabulary":{"type":"object","propertyNames":{"$ref":"#/$defs/uriString"},"additionalProperties":{"type":"boolean"}},"$comment":{"type":"string"},"$defs":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"}}},"$defs":{"anchorString":{"type":"string","pattern":"^[A-Za-z_][-A-Za-z0-9._]*$"},"uriString":{"type":"string","format":"uri"},"uriReferenceString":{"type":"string","format":"uri-reference"}}}')},9567:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/format-annotation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/format-annotation":true},"$dynamicAnchor":"meta","title":"Format vocabulary meta-schema for annotation results","type":["object","boolean"],"properties":{"format":{"type":"string"}}}')},8364:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/meta-data","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/meta-data":true},"$dynamicAnchor":"meta","title":"Meta-data vocabulary meta-schema","type":["object","boolean"],"properties":{"title":{"type":"string"},"description":{"type":"string"},"default":true,"deprecated":{"type":"boolean","default":false},"readOnly":{"type":"boolean","default":false},"writeOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true}}}')},7388:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/unevaluated","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/unevaluated":true},"$dynamicAnchor":"meta","title":"Unevaluated applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"unevaluatedItems":{"$dynamicRef":"#meta"},"unevaluatedProperties":{"$dynamicRef":"#meta"}}}')},2943:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/validation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/validation":true},"$dynamicAnchor":"meta","title":"Validation vocabulary meta-schema","type":["object","boolean"],"properties":{"type":{"anyOf":[{"$ref":"#/$defs/simpleTypes"},{"type":"array","items":{"$ref":"#/$defs/simpleTypes"},"minItems":1,"uniqueItems":true}]},"const":true,"enum":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/$defs/nonNegativeInteger"},"minLength":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"maxItems":{"$ref":"#/$defs/nonNegativeInteger"},"minItems":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"maxContains":{"$ref":"#/$defs/nonNegativeInteger"},"minContains":{"$ref":"#/$defs/nonNegativeInteger","default":1},"maxProperties":{"$ref":"#/$defs/nonNegativeInteger"},"minProperties":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"required":{"$ref":"#/$defs/stringArray"},"dependentRequired":{"type":"object","additionalProperties":{"$ref":"#/$defs/stringArray"}}},"$defs":{"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"$ref":"#/$defs/nonNegativeInteger","default":0},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}}}')},6261:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/schema","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true,"https://json-schema.org/draft/2020-12/vocab/applicator":true,"https://json-schema.org/draft/2020-12/vocab/unevaluated":true,"https://json-schema.org/draft/2020-12/vocab/validation":true,"https://json-schema.org/draft/2020-12/vocab/meta-data":true,"https://json-schema.org/draft/2020-12/vocab/format-annotation":true,"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Core and Validation specifications meta-schema","allOf":[{"$ref":"meta/core"},{"$ref":"meta/applicator"},{"$ref":"meta/unevaluated"},{"$ref":"meta/validation"},{"$ref":"meta/meta-data"},{"$ref":"meta/format-annotation"},{"$ref":"meta/content"}],"type":["object","boolean"],"$comment":"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.","properties":{"definitions":{"$comment":"\\"definitions\\" has been replaced by \\"$defs\\".","type":"object","additionalProperties":{"$dynamicRef":"#meta"},"deprecated":true,"default":{}},"dependencies":{"$comment":"\\"dependencies\\" has been split and replaced by \\"dependentSchemas\\" and \\"dependentRequired\\" in order to serve their differing semantics.","type":"object","additionalProperties":{"anyOf":[{"$dynamicRef":"#meta"},{"$ref":"meta/validation#/$defs/stringArray"}]},"deprecated":true,"default":{}},"$recursiveAnchor":{"$comment":"\\"$recursiveAnchor\\" has been replaced by \\"$dynamicAnchor\\".","$ref":"meta/core#/$defs/anchorString","deprecated":true},"$recursiveRef":{"$comment":"\\"$recursiveRef\\" has been replaced by \\"$dynamicRef\\".","$ref":"meta/core#/$defs/uriReferenceString","deprecated":true}}}')},3928:t=>{"use strict";t.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')},2040:t=>{"use strict";t.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE"},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN"},{"name":"Azure Pipelines","constant":"AZURE_PIPELINES","env":"TF_BUILD","pr":{"BUILD_REASON":"PullRequest"}},{"name":"Bamboo","constant":"BAMBOO","env":"bamboo_planKey"},{"name":"Bitbucket Pipelines","constant":"BITBUCKET","env":"BITBUCKET_COMMIT","pr":"BITBUCKET_PR_ID"},{"name":"Bitrise","constant":"BITRISE","env":"BITRISE_IO","pr":"BITRISE_PULL_REQUEST"},{"name":"Buddy","constant":"BUDDY","env":"BUDDY_WORKSPACE_ID","pr":"BUDDY_EXECUTION_PULL_REQUEST_ID"},{"name":"Buildkite","constant":"BUILDKITE","env":"BUILDKITE","pr":{"env":"BUILDKITE_PULL_REQUEST","ne":"false"}},{"name":"CircleCI","constant":"CIRCLE","env":"CIRCLECI","pr":"CIRCLE_PULL_REQUEST"},{"name":"Cirrus CI","constant":"CIRRUS","env":"CIRRUS_CI","pr":"CIRRUS_PR"},{"name":"Codefresh","constant":"CODEFRESH","env":"CF_BUILD_ID","pr":{"any":["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{"name":"Codemagic","constant":"CODEMAGIC","env":"CM_BUILD_ID","pr":"CM_PULL_REQUEST"},{"name":"Codeship","constant":"CODESHIP","env":{"CI_NAME":"codeship"}},{"name":"Drone","constant":"DRONE","env":"DRONE","pr":{"DRONE_BUILD_EVENT":"pull_request"}},{"name":"dsari","constant":"DSARI","env":"DSARI"},{"name":"Earthly","constant":"EARTHLY","env":"EARTHLY_CI"},{"name":"Expo Application Services","constant":"EAS","env":"EAS_BUILD"},{"name":"Gerrit","constant":"GERRIT","env":"GERRIT_PROJECT"},{"name":"Gitea Actions","constant":"GITEA_ACTIONS","env":"GITEA_ACTIONS"},{"name":"GitHub Actions","constant":"GITHUB_ACTIONS","env":"GITHUB_ACTIONS","pr":{"GITHUB_EVENT_NAME":"pull_request"}},{"name":"GitLab CI","constant":"GITLAB","env":"GITLAB_CI","pr":"CI_MERGE_REQUEST_ID"},{"name":"GoCD","constant":"GOCD","env":"GO_PIPELINE_LABEL"},{"name":"Google Cloud Build","constant":"GOOGLE_CLOUD_BUILD","env":"BUILDER_OUTPUT"},{"name":"Harness CI","constant":"HARNESS","env":"HARNESS_BUILD_ID"},{"name":"Heroku","constant":"HEROKU","env":{"env":"NODE","includes":"/app/.heroku/node/bin/node"}},{"name":"Hudson","constant":"HUDSON","env":"HUDSON_URL"},{"name":"Jenkins","constant":"JENKINS","env":["JENKINS_URL","BUILD_ID"],"pr":{"any":["ghprbPullId","CHANGE_ID"]}},{"name":"LayerCI","constant":"LAYERCI","env":"LAYERCI","pr":"LAYERCI_PULL_REQUEST"},{"name":"Magnum CI","constant":"MAGNUM","env":"MAGNUM"},{"name":"Netlify CI","constant":"NETLIFY","env":"NETLIFY","pr":{"env":"PULL_REQUEST","ne":"false"}},{"name":"Nevercode","constant":"NEVERCODE","env":"NEVERCODE","pr":{"env":"NEVERCODE_PULL_REQUEST","ne":"false"}},{"name":"Prow","constant":"PROW","env":"PROW_JOB_ID"},{"name":"ReleaseHub","constant":"RELEASEHUB","env":"RELEASE_BUILD_ID"},{"name":"Render","constant":"RENDER","env":"RENDER","pr":{"IS_PULL_REQUEST":"true"}},{"name":"Sail CI","constant":"SAIL","env":"SAILCI","pr":"SAIL_PULL_REQUEST_NUMBER"},{"name":"Screwdriver","constant":"SCREWDRIVER","env":"SCREWDRIVER","pr":{"env":"SD_PULL_REQUEST","ne":"false"}},{"name":"Semaphore","constant":"SEMAPHORE","env":"SEMAPHORE","pr":"PULL_REQUEST_NUMBER"},{"name":"Sourcehut","constant":"SOURCEHUT","env":{"CI_NAME":"sourcehut"}},{"name":"Strider CD","constant":"STRIDER","env":"STRIDER"},{"name":"TaskCluster","constant":"TASKCLUSTER","env":["TASK_ID","RUN_ID"]},{"name":"TeamCity","constant":"TEAMCITY","env":"TEAMCITY_VERSION"},{"name":"Travis CI","constant":"TRAVIS","env":"TRAVIS","pr":{"env":"TRAVIS_PULL_REQUEST","ne":"false"}},{"name":"Vela","constant":"VELA","env":"VELA","pr":{"VELA_PULL_REQUEST":"1"}},{"name":"Vercel","constant":"VERCEL","env":{"any":["NOW_BUILDER","VERCEL"]},"pr":"VERCEL_GIT_PULL_REQUEST_ID"},{"name":"Visual Studio App Center","constant":"APPCENTER","env":"APPCENTER_BUILD_ID"},{"name":"Woodpecker","constant":"WOODPECKER","env":{"CI":"woodpecker"},"pr":{"CI_BUILD_EVENT":"pull_request"}},{"name":"Xcode Cloud","constant":"XCODE_CLOUD","env":"CI_XCODE_PROJECT","pr":"CI_PULL_REQUEST_NUMBER"},{"name":"Xcode Server","constant":"XCODE_SERVER","env":"XCS"}]')}};var u={};function __nccwpck_require__(p){var m=u[p];if(m!==undefined){return m.exports}var g=u[p]={exports:{}};var v=true;try{t[p](g,g.exports,__nccwpck_require__);v=false}finally{if(v)delete u[p]}return g.exports}(()=>{__nccwpck_require__.n=t=>{var u=t&&t.__esModule?()=>t["default"]:()=>t;__nccwpck_require__.d(u,{a:u});return u}})();(()=>{var t=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__;var u;__nccwpck_require__.t=function(p,m){if(m&1)p=this(p);if(m&8)return p;if(typeof p==="object"&&p){if(m&4&&p.__esModule)return p;if(m&16&&typeof p.then==="function")return p}var g=Object.create(null);__nccwpck_require__.r(g);var v={};u=u||[null,t({}),t([]),t(t)];for(var b=m&2&&p;typeof b=="object"&&!~u.indexOf(b);b=t(b)){Object.getOwnPropertyNames(b).forEach((t=>v[t]=()=>p[t]))}v["default"]=()=>p;__nccwpck_require__.d(g,v);return g}})();(()=>{__nccwpck_require__.d=(t,u)=>{for(var p in u){if(__nccwpck_require__.o(u,p)&&!__nccwpck_require__.o(t,p)){Object.defineProperty(t,p,{enumerable:true,get:u[p]})}}}})();(()=>{__nccwpck_require__.o=(t,u)=>Object.prototype.hasOwnProperty.call(t,u)})();(()=>{__nccwpck_require__.r=t=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(t,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var p={};(()=>{"use strict";var t=__nccwpck_require__(6395);var u=__nccwpck_require__.n(t);var p=__nccwpck_require__(8909);const{DM:m,gu:g,er:v,Ww:b,b7:w,Di:E,a2:S,uB:$,ef:P,c$:x,_V:R}=p;const O=require("node:util");var A=__nccwpck_require__(1708);var k=__nccwpck_require__(3024);var T=__nccwpck_require__(6760);var C=__nccwpck_require__.n(T);const I=require("node:crypto");const N=require("node:assert");const isObject=t=>{const u=typeof t;return t!==null&&(u==="object"||u==="function")};const isEmptyObject=t=>isObject(t)&&Object.keys(t).length===0;const D=new Set(["__proto__","prototype","constructor"]);const j=new Set("0123456789");function getPathSegments(t){const u=[];let p="";let m="start";let g=false;for(const v of t){switch(v){case"\\":{if(m==="index"){throw new Error("Invalid character in an index")}if(m==="indexEnd"){throw new Error("Invalid character after an index")}if(g){p+=v}m="property";g=!g;break}case".":{if(m==="index"){throw new Error("Invalid character in an index")}if(m==="indexEnd"){m="property";break}if(g){g=false;p+=v;break}if(D.has(p)){return[]}u.push(p);p="";m="property";break}case"[":{if(m==="index"){throw new Error("Invalid character in an index")}if(m==="indexEnd"){m="index";break}if(g){g=false;p+=v;break}if(m==="property"){if(D.has(p)){return[]}u.push(p);p=""}m="index";break}case"]":{if(m==="index"){u.push(Number.parseInt(p,10));p="";m="indexEnd";break}if(m==="indexEnd"){throw new Error("Invalid character after an index")}}default:{if(m==="index"&&!j.has(v)){throw new Error("Invalid character in an index")}if(m==="indexEnd"){throw new Error("Invalid character after an index")}if(m==="start"){m="property"}if(g){g=false;p+="\\"}p+=v}}}if(g){p+="\\"}switch(m){case"property":{if(D.has(p)){return[]}u.push(p);break}case"index":{throw new Error("Index was not closed")}case"start":{u.push("");break}}return u}function isStringIndex(t,u){if(typeof u!=="number"&&Array.isArray(t)){const p=Number.parseInt(u,10);return Number.isInteger(p)&&t[p]===t[u]}return false}function assertNotStringIndex(t,u){if(isStringIndex(t,u)){throw new Error("Cannot use string index")}}function getProperty(t,u,p){if(!isObject(t)||typeof u!=="string"){return p===undefined?t:p}const m=getPathSegments(u);if(m.length===0){return p}for(let u=0;u<m.length;u++){const g=m[u];if(isStringIndex(t,g)){t=u===m.length-1?undefined:null}else{t=t[g]}if(t===undefined||t===null){if(u!==m.length-1){return p}break}}return t===undefined?p:t}function setProperty(t,u,p){if(!isObject(t)||typeof u!=="string"){return t}const m=t;const g=getPathSegments(u);for(let u=0;u<g.length;u++){const m=g[u];assertNotStringIndex(t,m);if(u===g.length-1){t[m]=p}else if(!isObject(t[m])){t[m]=typeof g[u+1]==="number"?[]:{}}t=t[m]}return m}function deleteProperty(t,u){if(!isObject(t)||typeof u!=="string"){return false}const p=getPathSegments(u);for(let u=0;u<p.length;u++){const m=p[u];assertNotStringIndex(t,m);if(u===p.length-1){delete t[m];return true}t=t[m];if(!isObject(t)){return false}}}function hasProperty(t,u){if(!isObject(t)||typeof u!=="string"){return false}const p=getPathSegments(u);if(p.length===0){return false}for(const u of p){if(!isObject(t)||!(u in t)||isStringIndex(t,u)){return false}t=t[u]}return true}function escapePath(t){if(typeof t!=="string"){throw new TypeError("Expected a string")}return t.replaceAll(/[\\.[]/g,"\\$&")}function entries(t){const u=Object.entries(t);if(Array.isArray(t)){return u.map((([t,u])=>[Number(t),u]))}return u}function stringifyPath(t){let u="";for(let[p,m]of entries(t)){if(typeof m==="number"){u+=`[${m}]`}else{m=escapePath(m);u+=p===0?m:`.${m}`}}return u}function*deepKeysIterator(t,u=[]){if(!isObject(t)||isEmptyObject(t)){if(u.length>0){yield stringifyPath(u)}return}for(const[p,m]of entries(t)){yield*deepKeysIterator(m,[...u,p])}}function deepKeys(t){return[...deepKeysIterator(t)]}const L=require("node:os");const M=L.homedir();const U=L.tmpdir();const{env:B}=A;const macos=t=>{const u=T.join(M,"Library");return{data:T.join(u,"Application Support",t),config:T.join(u,"Preferences",t),cache:T.join(u,"Caches",t),log:T.join(u,"Logs",t),temp:T.join(U,t)}};const windows=t=>{const u=B.APPDATA||T.join(M,"AppData","Roaming");const p=B.LOCALAPPDATA||T.join(M,"AppData","Local");return{data:T.join(p,t,"Data"),config:T.join(u,t,"Config"),cache:T.join(p,t,"Cache"),log:T.join(p,t,"Log"),temp:T.join(U,t)}};const linux=t=>{const u=T.basename(M);return{data:T.join(B.XDG_DATA_HOME||T.join(M,".local","share"),t),config:T.join(B.XDG_CONFIG_HOME||T.join(M,".config"),t),cache:T.join(B.XDG_CACHE_HOME||T.join(M,".cache"),t),log:T.join(B.XDG_STATE_HOME||T.join(M,".local","state"),t),temp:T.join(U,u,t)}};function envPaths(t,{suffix:u="nodejs"}={}){if(typeof t!=="string"){throw new TypeError(`Expected a string, got ${typeof t}`)}if(u){t+=`-${u}`}if(A.platform==="darwin"){return macos(t)}if(A.platform==="win32"){return windows(t)}return linux(t)}const attemptifyAsync=(t,u)=>function attemptified(...p){return t.apply(undefined,p).catch(u)};const attemptifySync=(t,u)=>function attemptified(...p){try{return t.apply(undefined,p)}catch(t){return u(t)}};const H=A.getuid?!A.getuid():false;const z=1e4;const NOOP=()=>undefined;const V={isChangeErrorOk:t=>{if(!V.isNodeError(t))return false;const{code:u}=t;if(u==="ENOSYS")return true;if(!H&&(u==="EINVAL"||u==="EPERM"))return true;return false},isNodeError:t=>t instanceof Error,isRetriableError:t=>{if(!V.isNodeError(t))return false;const{code:u}=t;if(u==="EMFILE"||u==="ENFILE"||u==="EAGAIN"||u==="EBUSY"||u==="EACCESS"||u==="EACCES"||u==="EACCS"||u==="EPERM")return true;return false},onChangeError:t=>{if(!V.isNodeError(t))throw t;if(V.isChangeErrorOk(t))return;throw t}};const G=V;class RetryfyQueue{constructor(){this.interval=25;this.intervalId=undefined;this.limit=z;this.queueActive=new Set;this.queueWaiting=new Set;this.init=()=>{if(this.intervalId)return;this.intervalId=setInterval(this.tick,this.interval)};this.reset=()=>{if(!this.intervalId)return;clearInterval(this.intervalId);delete this.intervalId};this.add=t=>{this.queueWaiting.add(t);if(this.queueActive.size<this.limit/2){this.tick()}else{this.init()}};this.remove=t=>{this.queueWaiting.delete(t);this.queueActive.delete(t)};this.schedule=()=>new Promise((t=>{const cleanup=()=>this.remove(resolver);const resolver=()=>t(cleanup);this.add(resolver)}));this.tick=()=>{if(this.queueActive.size>=this.limit)return;if(!this.queueWaiting.size)return this.reset();for(const t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t);this.queueActive.add(t);t()}}}}const q=new RetryfyQueue;const retryifyAsync=(t,u)=>function retrified(p){return function attempt(...m){return q.schedule().then((g=>{const onResolve=t=>{g();return t};const onReject=t=>{g();if(Date.now()>=p)throw t;if(u(t)){const t=Math.round(100*Math.random());const u=new Promise((u=>setTimeout(u,t)));return u.then((()=>attempt.apply(undefined,m)))}throw t};return t.apply(undefined,m).then(onResolve,onReject)}))}};const retryifySync=(t,u)=>function retrified(p){return function attempt(...m){try{return t.apply(undefined,m)}catch(t){if(Date.now()>p)throw t;if(u(t))return attempt.apply(undefined,m);throw t}}};const W={attempt:{chmod:attemptifyAsync((0,O.promisify)(k.chmod),G.onChangeError),chown:attemptifyAsync((0,O.promisify)(k.chown),G.onChangeError),close:attemptifyAsync((0,O.promisify)(k.close),NOOP),fsync:attemptifyAsync((0,O.promisify)(k.fsync),NOOP),mkdir:attemptifyAsync((0,O.promisify)(k.mkdir),NOOP),realpath:attemptifyAsync((0,O.promisify)(k.realpath),NOOP),stat:attemptifyAsync((0,O.promisify)(k.stat),NOOP),unlink:attemptifyAsync((0,O.promisify)(k.unlink),NOOP),chmodSync:attemptifySync(k.chmodSync,G.onChangeError),chownSync:attemptifySync(k.chownSync,G.onChangeError),closeSync:attemptifySync(k.closeSync,NOOP),existsSync:attemptifySync(k.existsSync,NOOP),fsyncSync:attemptifySync(k.fsync,NOOP),mkdirSync:attemptifySync(k.mkdirSync,NOOP),realpathSync:attemptifySync(k.realpathSync,NOOP),statSync:attemptifySync(k.statSync,NOOP),unlinkSync:attemptifySync(k.unlinkSync,NOOP)},retry:{close:retryifyAsync((0,O.promisify)(k.close),G.isRetriableError),fsync:retryifyAsync((0,O.promisify)(k.fsync),G.isRetriableError),open:retryifyAsync((0,O.promisify)(k.open),G.isRetriableError),readFile:retryifyAsync((0,O.promisify)(k.readFile),G.isRetriableError),rename:retryifyAsync((0,O.promisify)(k.rename),G.isRetriableError),stat:retryifyAsync((0,O.promisify)(k.stat),G.isRetriableError),write:retryifyAsync((0,O.promisify)(k.write),G.isRetriableError),writeFile:retryifyAsync((0,O.promisify)(k.writeFile),G.isRetriableError),closeSync:retryifySync(k.closeSync,G.isRetriableError),fsyncSync:retryifySync(k.fsyncSync,G.isRetriableError),openSync:retryifySync(k.openSync,G.isRetriableError),readFileSync:retryifySync(k.readFileSync,G.isRetriableError),renameSync:retryifySync(k.renameSync,G.isRetriableError),statSync:retryifySync(k.statSync,G.isRetriableError),writeSync:retryifySync(k.writeSync,G.isRetriableError),writeFileSync:retryifySync(k.writeFileSync,G.isRetriableError)}};const Y=W;const Z="utf8";const J=438;const X=511;const Q={};const ee={};const te=L.userInfo().uid;const re=L.userInfo().gid;const ie=7500;const oe=1e3;const ae=!!A.getuid;const le=A.getuid?!A.getuid():false;const ue=128;const he=1e4;const constants_NOOP=()=>{};const lang_isException=t=>t instanceof Error&&"code"in t;const lang_isFunction=t=>typeof t==="function";const lang_isString=t=>typeof t==="string";const lang_isUndefined=t=>t===undefined;const de={};const fe={next:t=>{const u=de[t];if(!u)return;u.shift();const p=u[0];if(p){p((()=>fe.next(t)))}else{delete de[t]}},schedule:t=>new Promise((u=>{let p=de[t];if(!p)p=de[t]=[];p.push(u);if(p.length>1)return;u((()=>fe.next(t)))}))};const pe=null&&fe;const me=A.platform==="linux";const ge=A.platform==="win32";const ve=["SIGHUP","SIGINT","SIGTERM"];if(!ge){ve.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT")}if(me){ve.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")}const _e=ve;class Interceptor{constructor(){this.callbacks=new Set;this.exited=false;this.exit=t=>{if(this.exited)return;this.exited=true;for(const t of this.callbacks){t()}if(t){if(ge&&(t!=="SIGINT"&&t!=="SIGTERM"&&t!=="SIGKILL")){A.kill(A.pid,"SIGTERM")}else{A.kill(A.pid,t)}}};this.hook=()=>{A.once("exit",(()=>this.exit()));for(const t of _e){try{A.once(t,(()=>this.exit(t)))}catch{}}};this.register=t=>{this.callbacks.add(t);return()=>{this.callbacks.delete(t)}};this.hook()}}const be=new Interceptor;const we=be.register;const Ee=we;const Se={store:{},create:t=>{const u=`000000${Math.floor(Math.random()*16777215).toString(16)}`.slice(-6);const p=Date.now().toString().slice(-10);const m="tmp-";const g=`.${m}${p}${u}`;const v=`${t}${g}`;return v},get:(t,u,p=true)=>{const m=Se.truncate(u(t));if(m in Se.store)return Se.get(t,u,p);Se.store[m]=p;const disposer=()=>delete Se.store[m];return[m,disposer]},purge:t=>{if(!Se.store[t])return;delete Se.store[t];Y.attempt.unlink(t)},purgeSync:t=>{if(!Se.store[t])return;delete Se.store[t];Y.attempt.unlinkSync(t)},purgeSyncAll:()=>{for(const t in Se.store){Se.purgeSync(t)}},truncate:t=>{const u=T.basename(t);if(u.length<=ue)return t;const p=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(u);if(!p)return t;const m=u.length-ue;return`${t.slice(0,-u.length)}${p[1]}${p[2].slice(0,-m)}${p[3]}`}};Ee(Se.purgeSyncAll);const $e=Se;function readFile(t,u=DEFAULT_READ_OPTIONS){if(isString(u))return readFile(t,{encoding:u});const p=Date.now()+((u.timeout??DEFAULT_TIMEOUT_ASYNC)||-1);return fs.retry.readFile(p)(t,u)}function readFileSync(t,u=DEFAULT_READ_OPTIONS){if(isString(u))return readFileSync(t,{encoding:u});const p=Date.now()+((u.timeout??DEFAULT_TIMEOUT_SYNC)||-1);return fs.retry.readFileSync(p)(t,u)}function writeFile(t,u,p,m){if(isFunction(p))return writeFile(t,u,DEFAULT_WRITE_OPTIONS,p);const g=writeFileAsync(t,u,p);if(m)g.then(m,m);return g}async function writeFileAsync(t,u,p=DEFAULT_WRITE_OPTIONS){if(isString(p))return writeFileAsync(t,u,{encoding:p});const m=Date.now()+((p.timeout??DEFAULT_TIMEOUT_ASYNC)||-1);let g=null;let v=null;let b=null;let w=null;let E=null;try{if(p.schedule)g=await p.schedule(t);v=await Scheduler.schedule(t);const S=await fs.attempt.realpath(t);const $=!!S;t=S||t;[w,b]=Temp.get(t,p.tmpCreate||Temp.create,!(p.tmpPurge===false));const P=IS_POSIX&&isUndefined(p.chown);const x=isUndefined(p.mode);if($&&(P||x)){const u=await fs.attempt.stat(t);if(u){p={...p};if(P){p.chown={uid:u.uid,gid:u.gid}}if(x){p.mode=u.mode}}}if(!$){const u=path.dirname(t);await fs.attempt.mkdir(u,{mode:DEFAULT_FOLDER_MODE,recursive:true})}E=await fs.retry.open(m)(w,"w",p.mode||DEFAULT_FILE_MODE);if(p.tmpCreated){p.tmpCreated(w)}if(isString(u)){await fs.retry.write(m)(E,u,0,p.encoding||DEFAULT_ENCODING)}else if(!isUndefined(u)){await fs.retry.write(m)(E,u,0,u.length,0)}if(p.fsync!==false){if(p.fsyncWait!==false){await fs.retry.fsync(m)(E)}else{fs.attempt.fsync(E)}}await fs.retry.close(m)(E);E=null;if(p.chown&&(p.chown.uid!==DEFAULT_USER_UID||p.chown.gid!==DEFAULT_USER_GID)){await fs.attempt.chown(w,p.chown.uid,p.chown.gid)}if(p.mode&&p.mode!==DEFAULT_FILE_MODE){await fs.attempt.chmod(w,p.mode)}try{await fs.retry.rename(m)(w,t)}catch(u){if(!isException(u))throw u;if(u.code!=="ENAMETOOLONG")throw u;await fs.retry.rename(m)(w,Temp.truncate(t))}b();w=null}finally{if(E)await fs.attempt.close(E);if(w)Temp.purge(w);if(g)g();if(v)v()}}function writeFileSync(t,u,p=ee){if(lang_isString(p))return writeFileSync(t,u,{encoding:p});const m=Date.now()+((p.timeout??oe)||-1);let g=null;let v=null;let b=null;try{const w=Y.attempt.realpathSync(t);const E=!!w;t=w||t;[v,g]=$e.get(t,p.tmpCreate||$e.create,!(p.tmpPurge===false));const S=ae&&lang_isUndefined(p.chown);const $=lang_isUndefined(p.mode);if(E&&(S||$)){const u=Y.attempt.statSync(t);if(u){p={...p};if(S){p.chown={uid:u.uid,gid:u.gid}}if($){p.mode=u.mode}}}if(!E){const u=T.dirname(t);Y.attempt.mkdirSync(u,{mode:X,recursive:true})}b=Y.retry.openSync(m)(v,"w",p.mode||J);if(p.tmpCreated){p.tmpCreated(v)}if(lang_isString(u)){Y.retry.writeSync(m)(b,u,0,p.encoding||Z)}else if(!lang_isUndefined(u)){Y.retry.writeSync(m)(b,u,0,u.length,0)}if(p.fsync!==false){if(p.fsyncWait!==false){Y.retry.fsyncSync(m)(b)}else{Y.attempt.fsync(b)}}Y.retry.closeSync(m)(b);b=null;if(p.chown&&(p.chown.uid!==te||p.chown.gid!==re)){Y.attempt.chownSync(v,p.chown.uid,p.chown.gid)}if(p.mode&&p.mode!==J){Y.attempt.chmodSync(v,p.mode)}try{Y.retry.renameSync(m)(v,t)}catch(u){if(!lang_isException(u))throw u;if(u.code!=="ENAMETOOLONG")throw u;Y.retry.renameSync(m)(v,$e.truncate(t))}g();v=null}finally{if(b)Y.attempt.closeSync(b);if(v)$e.purge(v)}}var Pe=__nccwpck_require__(939);var xe=__nccwpck_require__(6848);const copyProperty=(t,u,p,m)=>{if(p==="length"||p==="prototype"){return}if(p==="arguments"||p==="caller"){return}const g=Object.getOwnPropertyDescriptor(t,p);const v=Object.getOwnPropertyDescriptor(u,p);if(!canCopyProperty(g,v)&&m){return}Object.defineProperty(t,p,v)};const canCopyProperty=function(t,u){return t===undefined||t.configurable||t.writable===u.writable&&t.enumerable===u.enumerable&&t.configurable===u.configurable&&(t.writable||t.value===u.value)};const changePrototype=(t,u)=>{const p=Object.getPrototypeOf(u);if(p===Object.getPrototypeOf(t)){return}Object.setPrototypeOf(t,p)};const wrappedToString=(t,u)=>`/* Wrapped ${t}*/\n${u}`;const Re=Object.getOwnPropertyDescriptor(Function.prototype,"toString");const Oe=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name");const changeToString=(t,u,p)=>{const m=p===""?"":`with ${p.trim()}() `;const g=wrappedToString.bind(null,m,u.toString());Object.defineProperty(g,"name",Oe);const{writable:v,enumerable:b,configurable:w}=Re;Object.defineProperty(t,"toString",{value:g,writable:v,enumerable:b,configurable:w})};function mimicFunction(t,u,{ignoreNonConfigurable:p=false}={}){const{name:m}=t;for(const m of Reflect.ownKeys(u)){copyProperty(t,u,m,p)}changePrototype(t,u);changeToString(t,u,m);return t}const debounceFunction=(t,u={})=>{if(typeof t!=="function"){throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``)}const{wait:p=0,maxWait:m=Number.POSITIVE_INFINITY,before:g=false,after:v=true}=u;if(p<0||m<0){throw new RangeError("`wait` and `maxWait` must not be negative.")}if(!g&&!v){throw new Error("Both `before` and `after` are false, function wouldn't be called.")}let b;let w;let E;const debouncedFunction=function(...u){const S=this;const later=()=>{b=undefined;if(w){clearTimeout(w);w=undefined}if(v){E=t.apply(S,u)}};const maxLater=()=>{w=undefined;if(b){clearTimeout(b);b=undefined}if(v){E=t.apply(S,u)}};const $=g&&!b;clearTimeout(b);b=setTimeout(later,p);if(m>0&&m!==Number.POSITIVE_INFINITY&&!w){w=setTimeout(maxLater,m)}if($){E=t.apply(S,u)}return E};mimicFunction(debouncedFunction,t);debouncedFunction.cancel=()=>{if(b){clearTimeout(b);b=undefined}if(w){clearTimeout(w);w=undefined}};return debouncedFunction};const Ae=debounceFunction;var ke=__nccwpck_require__(6723);const Te=Object.prototype.toString;const Ce="[object Uint8Array]";const Ie="[object ArrayBuffer]";function isType(t,u,p){if(!t){return false}if(t.constructor===u){return true}return Te.call(t)===p}function isUint8Array(t){return isType(t,Uint8Array,Ce)}function isArrayBuffer(t){return isType(t,ArrayBuffer,Ie)}function isUint8ArrayOrArrayBuffer(t){return isUint8Array(t)||isArrayBuffer(t)}function assertUint8Array(t){if(!isUint8Array(t)){throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof t}\``)}}function assertUint8ArrayOrArrayBuffer(t){if(!isUint8ArrayOrArrayBuffer(t)){throw new TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``)}}function toUint8Array(t){if(t instanceof ArrayBuffer){return new Uint8Array(t)}if(ArrayBuffer.isView(t)){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}throw new TypeError(`Unsupported value, got \`${typeof t}\`.`)}function concatUint8Arrays(t,u){if(t.length===0){return new Uint8Array(0)}u??=t.reduce(((t,u)=>t+u.length),0);const p=new Uint8Array(u);let m=0;for(const u of t){assertUint8Array(u);p.set(u,m);m+=u.length}return p}function areUint8ArraysEqual(t,u){assertUint8Array(t);assertUint8Array(u);if(t===u){return true}if(t.length!==u.length){return false}for(let p=0;p<t.length;p++){if(t[p]!==u[p]){return false}}return true}function compareUint8Arrays(t,u){assertUint8Array(t);assertUint8Array(u);const p=Math.min(t.length,u.length);for(let m=0;m<p;m++){const p=t[m]-u[m];if(p!==0){return Math.sign(p)}}return Math.sign(t.length-u.length)}const Ne={utf8:new globalThis.TextDecoder("utf8")};function uint8ArrayToString(t,u="utf8"){assertUint8ArrayOrArrayBuffer(t);Ne[u]??=new globalThis.TextDecoder(u);return Ne[u].decode(t)}function assertString(t){if(typeof t!=="string"){throw new TypeError(`Expected \`string\`, got \`${typeof t}\``)}}const De=new globalThis.TextEncoder;function stringToUint8Array(t){assertString(t);return De.encode(t)}function base64ToBase64Url(t){return t.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function base64UrlToBase64(t){const u=t.replaceAll("-","+").replaceAll("_","/");const p=(4-u.length%4)%4;return u+"=".repeat(p)}const je=65535;function uint8ArrayToBase64(t,{urlSafe:u=false}={}){assertUint8Array(t);let p="";for(let u=0;u<t.length;u+=je){const m=t.subarray(u,u+je);p+=globalThis.btoa(String.fromCodePoint.apply(undefined,m))}return u?base64ToBase64Url(p):p}function base64ToUint8Array(t){assertString(t);return Uint8Array.from(globalThis.atob(base64UrlToBase64(t)),(t=>t.codePointAt(0)))}function stringToBase64(t,{urlSafe:u=false}={}){assertString(t);return uint8ArrayToBase64(stringToUint8Array(t),{urlSafe:u})}function base64ToString(t){assertString(t);return uint8ArrayToString(base64ToUint8Array(t))}const Le=Array.from({length:256},((t,u)=>u.toString(16).padStart(2,"0")));function uint8ArrayToHex(t){assertUint8Array(t);let u="";for(let p=0;p<t.length;p++){u+=Le[t[p]]}return u}const Me={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function hexToUint8Array(t){assertString(t);if(t.length%2!==0){throw new Error("Invalid Hex string length.")}const u=t.length/2;const p=new Uint8Array(u);for(let m=0;m<u;m++){const u=Me[t[m*2]];const g=Me[t[m*2+1]];if(u===undefined||g===undefined){throw new Error(`Invalid Hex character encountered at position ${m*2}`)}p[m]=u<<4|g}return p}function getUintBE(t){const{byteLength:u}=t;if(u===6){return t.getUint16(0)*2**32+t.getUint32(2)}if(u===5){return t.getUint8(0)*2**32+t.getUint32(1)}if(u===4){return t.getUint32(0)}if(u===3){return t.getUint8(0)*2**16+t.getUint16(1)}if(u===2){return t.getUint16(0)}if(u===1){return t.getUint8(0)}}function indexOf(t,u){const p=t.length;const m=u.length;if(m===0){return-1}if(m>p){return-1}const g=p-m;for(let p=0;p<=g;p++){let g=true;for(let v=0;v<m;v++){if(t[p+v]!==u[v]){g=false;break}}if(g){return p}}return-1}function includes(t,u){return indexOf(t,u)!==-1}const Fe=xe["default"];const Ue="aes-256-cbc";const createPlainObject=()=>Object.create(null);const isExist=t=>t!==undefined&&t!==null;const checkValueType=(t,u)=>{const p=new Set(["undefined","symbol","function"]);const m=typeof u;if(p.has(m)){throw new TypeError(`Setting a value of type \`${m}\` for key \`${t}\` is not allowed as it's not supported by JSON`)}};const Be="__internal__";const He=`${Be}.migrations.version`;class Conf{path;events;#e;#t;#r;#s={};constructor(t={}){const u={configName:"config",fileExtension:"json",projectSuffix:"nodejs",clearInvalidConfig:false,accessPropertiesByDotNotation:true,configFileMode:438,...t};if(!u.cwd){if(!u.projectName){throw new Error("Please specify the `projectName` option.")}u.cwd=envPaths(u.projectName,{suffix:u.projectSuffix}).config}this.#r=u;if(u.schema){if(typeof u.schema!=="object"){throw new TypeError("The `schema` option must be an object.")}const t=new Pe.Ajv2020({allErrors:true,useDefaults:true});Fe(t);const p={type:"object",properties:u.schema};this.#e=t.compile(p);for(const[t,p]of Object.entries(u.schema)){if(p?.default){this.#s[t]=p.default}}}if(u.defaults){this.#s={...this.#s,...u.defaults}}if(u.serialize){this._serialize=u.serialize}if(u.deserialize){this._deserialize=u.deserialize}this.events=new EventTarget;this.#t=u.encryptionKey;const p=u.fileExtension?`.${u.fileExtension}`:"";this.path=T.resolve(u.cwd,`${u.configName??"config"}${p}`);const m=this.store;const g=Object.assign(createPlainObject(),u.defaults,m);if(u.migrations){if(!u.projectVersion){throw new Error("Please specify the `projectVersion` option.")}this._migrate(u.migrations,u.projectVersion,u.beforeEachMigration)}this._validate(g);try{N.deepEqual(m,g)}catch{this.store=g}if(u.watch){this._watch()}}get(t,u){if(this.#r.accessPropertiesByDotNotation){return this._get(t,u)}const{store:p}=this;return t in p?p[t]:u}set(t,u){if(typeof t!=="string"&&typeof t!=="object"){throw new TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof t}`)}if(typeof t!=="object"&&u===undefined){throw new TypeError("Use `delete()` to clear values")}if(this._containsReservedKey(t)){throw new TypeError(`Please don't use the ${Be} key, as it's used to manage this module internal operations.`)}const{store:p}=this;const set=(t,u)=>{checkValueType(t,u);if(this.#r.accessPropertiesByDotNotation){setProperty(p,t,u)}else{p[t]=u}};if(typeof t==="object"){const u=t;for(const[t,p]of Object.entries(u)){set(t,p)}}else{set(t,u)}this.store=p}has(t){if(this.#r.accessPropertiesByDotNotation){return hasProperty(this.store,t)}return t in this.store}reset(...t){for(const u of t){if(isExist(this.#s[u])){this.set(u,this.#s[u])}}}delete(t){const{store:u}=this;if(this.#r.accessPropertiesByDotNotation){deleteProperty(u,t)}else{delete u[t]}this.store=u}clear(){this.store=createPlainObject();for(const t of Object.keys(this.#s)){this.reset(t)}}onDidChange(t,u){if(typeof t!=="string"){throw new TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof t}`)}if(typeof u!=="function"){throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof u}`)}return this._handleChange((()=>this.get(t)),u)}onDidAnyChange(t){if(typeof t!=="function"){throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof t}`)}return this._handleChange((()=>this.store),t)}get size(){return Object.keys(this.store).length}get store(){try{const t=k.readFileSync(this.path,this.#t?null:"utf8");const u=this._encryptData(t);const p=this._deserialize(u);this._validate(p);return Object.assign(createPlainObject(),p)}catch(t){if(t?.code==="ENOENT"){this._ensureDirectory();return createPlainObject()}if(this.#r.clearInvalidConfig&&t.name==="SyntaxError"){return createPlainObject()}throw t}}set store(t){this._ensureDirectory();this._validate(t);this._write(t);this.events.dispatchEvent(new Event("change"))}*[Symbol.iterator](){for(const[t,u]of Object.entries(this.store)){yield[t,u]}}_encryptData(t){if(!this.#t){return typeof t==="string"?t:uint8ArrayToString(t)}try{const u=t.slice(0,16);const p=I.pbkdf2Sync(this.#t,u.toString(),1e4,32,"sha512");const m=I.createDecipheriv(Ue,p,u);const g=t.slice(17);const v=typeof g==="string"?stringToUint8Array(g):g;return uint8ArrayToString(concatUint8Arrays([m.update(v),m.final()]))}catch{}return t.toString()}_handleChange(t,u){let p=t();const onChange=()=>{const m=p;const g=t();if((0,O.isDeepStrictEqual)(g,m)){return}p=g;u.call(this,g,m)};this.events.addEventListener("change",onChange);return()=>{this.events.removeEventListener("change",onChange)}}_deserialize=t=>JSON.parse(t);_serialize=t=>JSON.stringify(t,undefined,"\t");_validate(t){if(!this.#e){return}const u=this.#e(t);if(u||!this.#e.errors){return}const p=this.#e.errors.map((({instancePath:t,message:u=""})=>`\`${t.slice(1)}\` ${u}`));throw new Error("Config schema violation: "+p.join("; "))}_ensureDirectory(){k.mkdirSync(T.dirname(this.path),{recursive:true})}_write(t){let u=this._serialize(t);if(this.#t){const t=I.randomBytes(16);const p=I.pbkdf2Sync(this.#t,t.toString(),1e4,32,"sha512");const m=I.createCipheriv(Ue,p,t);u=concatUint8Arrays([t,stringToUint8Array(":"),m.update(stringToUint8Array(u)),m.final()])}if(A.env.SNAP){k.writeFileSync(this.path,u,{mode:this.#r.configFileMode})}else{try{writeFileSync(this.path,u,{mode:this.#r.configFileMode})}catch(t){if(t?.code==="EXDEV"){k.writeFileSync(this.path,u,{mode:this.#r.configFileMode});return}throw t}}}_watch(){this._ensureDirectory();if(!k.existsSync(this.path)){this._write(createPlainObject())}if(A.platform==="win32"){k.watch(this.path,{persistent:false},Ae((()=>{this.events.dispatchEvent(new Event("change"))}),{wait:100}))}else{k.watchFile(this.path,{persistent:false},Ae((()=>{this.events.dispatchEvent(new Event("change"))}),{wait:5e3}))}}_migrate(t,u,p){let m=this._get(He,"0.0.0");const g=Object.keys(t).filter((t=>this._shouldPerformMigration(t,m,u)));let v={...this.store};for(const b of g){try{if(p){p(this,{fromVersion:m,toVersion:b,finalVersion:u,versions:g})}const w=t[b];w?.(this);this._set(He,b);m=b;v={...this.store}}catch(t){this.store=v;throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${t}`)}}if(this._isVersionInRangeFormat(m)||!ke.eq(m,u)){this._set(He,u)}}_containsReservedKey(t){if(typeof t==="object"){const u=Object.keys(t)[0];if(u===Be){return true}}if(typeof t!=="string"){return false}if(this.#r.accessPropertiesByDotNotation){if(t.startsWith(`${Be}.`)){return true}return false}return false}_isVersionInRangeFormat(t){return ke.clean(t)===null}_shouldPerformMigration(t,u,p){if(this._isVersionInRangeFormat(t)){if(u!=="0.0.0"&&ke.satisfies(u,t)){return false}return ke.satisfies(p,t)}if(ke.lte(t,u)){return false}if(ke.gt(t,p)){return false}return true}_get(t,u){return getProperty(this.store,t,u)}_set(t,u){const{store:p}=this;setProperty(p,t,u);this.store=p}}var ze=__nccwpck_require__(9896);var Ve=__nccwpck_require__(6928);var Ge=__nccwpck_require__.n(Ve);var qe=__nccwpck_require__(9033);var We=__nccwpck_require__(7298);var Ke=__nccwpck_require__.n(We);var Ye=__nccwpck_require__(1083);var Ze=__nccwpck_require__.n(Ye);var Je=__nccwpck_require__(9850);var Xe=__nccwpck_require__.n(Je);const Qe=require("fs/promises");var et=__nccwpck_require__.n(Qe);var tt=__nccwpck_require__(857);var rt=__nccwpck_require__.n(tt);var st=__nccwpck_require__(2203);const it=require("stream/promises");var nt=__nccwpck_require__(4434);var ot=__nccwpck_require__(8474);const at=require("node:stream");const ut=require("node:string_decoder");const ht=require("assert");var dt=__nccwpck_require__(181);const ft=require("zlib");var pt=__nccwpck_require__.t(ft,2);const yt=require("node:fs/promises");var vt=Object.defineProperty;var Ur=(t,u)=>{for(var p in u)vt(t,p,{get:u[p],enumerable:!0})};var _t=typeof process=="object"&&process?process:{stdout:null,stderr:null},Wr=t=>!!t&&typeof t=="object"&&(t instanceof ir||t instanceof at||Gr(t)||Zr(t)),Gr=t=>!!t&&typeof t=="object"&&t instanceof ot.EventEmitter&&typeof t.pipe=="function"&&t.pipe!==at.Writable.prototype.pipe,Zr=t=>!!t&&typeof t=="object"&&t instanceof ot.EventEmitter&&typeof t.write=="function"&&typeof t.end=="function",bt=Symbol("EOF"),wt=Symbol("maybeEmitEnd"),Et=Symbol("emittedEnd"),St=Symbol("emittingEnd"),$t=Symbol("emittedError"),Pt=Symbol("closed"),Rt=Symbol("read"),Ot=Symbol("flush"),At=Symbol("flushChunk"),kt=Symbol("encoding"),Tt=Symbol("decoder"),Ct=Symbol("flowing"),It=Symbol("paused"),Nt=Symbol("resume"),Mt=Symbol("buffer"),Ft=Symbol("pipes"),Ut=Symbol("bufferLength"),Bt=Symbol("bufferPush"),Ht=Symbol("bufferShift"),zt=Symbol("objectMode"),Vt=Symbol("destroyed"),Gt=Symbol("error"),qt=Symbol("emitData"),Wt=Symbol("emitEnd"),Kt=Symbol("emitEnd2"),Yt=Symbol("async"),Zt=Symbol("abort"),Jt=Symbol("aborted"),Xt=Symbol("signal"),Qt=Symbol("dataListeners"),er=Symbol("discarded"),jt=t=>Promise.resolve().then(t),Yr=t=>t(),Kr=t=>t==="end"||t==="finish"||t==="prefinish",Vr=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,$r=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),tr=class{src;dest;opts;ondrain;constructor(t,u,p){this.src=t,this.dest=u,this.opts=p,this.ondrain=()=>t[Nt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},sr=class extends tr{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,u,p){super(t,u,p),this.proxyErrors=t=>this.dest.emit("error",t),t.on("error",this.proxyErrors)}},Xr=t=>!!t.objectMode,qr=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",ir=class extends ot.EventEmitter{[Ct]=!1;[It]=!1;[Ft]=[];[Mt]=[];[zt];[kt];[Yt];[Tt];[bt]=!1;[Et]=!1;[St]=!1;[Pt]=!1;[$t]=null;[Ut]=0;[Vt]=!1;[Xt];[Jt]=!1;[Qt]=0;[er]=!1;writable=!0;readable=!0;constructor(...t){let u=t[0]||{};if(super(),u.objectMode&&typeof u.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Xr(u)?(this[zt]=!0,this[kt]=null):qr(u)?(this[kt]=u.encoding,this[zt]=!1):(this[zt]=!1,this[kt]=null),this[Yt]=!!u.async,this[Tt]=this[kt]?new ut.StringDecoder(this[kt]):null,u&&u.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Mt]}),u&&u.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ft]});let{signal:p}=u;p&&(this[Xt]=p,p.aborted?this[Zt]():p.addEventListener("abort",(()=>this[Zt]())))}get bufferLength(){return this[Ut]}get encoding(){return this[kt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[zt]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Yt]}set async(t){this[Yt]=this[Yt]||!!t}[Zt](){this[Jt]=!0,this.emit("abort",this[Xt]?.reason),this.destroy(this[Xt]?.reason)}get aborted(){return this[Jt]}set aborted(t){}write(t,u,p){if(this[Jt])return!1;if(this[bt])throw new Error("write after end");if(this[Vt])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof u=="function"&&(p=u,u="utf8"),u||(u="utf8");let m=this[Yt]?jt:Yr;if(!this[zt]&&!Buffer.isBuffer(t)){if($r(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Vr(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[zt]?(this[Ct]&&this[Ut]!==0&&this[Ot](!0),this[Ct]?this.emit("data",t):this[Bt](t),this[Ut]!==0&&this.emit("readable"),p&&m(p),this[Ct]):t.length?(typeof t=="string"&&!(u===this[kt]&&!this[Tt]?.lastNeed)&&(t=Buffer.from(t,u)),Buffer.isBuffer(t)&&this[kt]&&(t=this[Tt].write(t)),this[Ct]&&this[Ut]!==0&&this[Ot](!0),this[Ct]?this.emit("data",t):this[Bt](t),this[Ut]!==0&&this.emit("readable"),p&&m(p),this[Ct]):(this[Ut]!==0&&this.emit("readable"),p&&m(p),this[Ct])}read(t){if(this[Vt])return null;if(this[er]=!1,this[Ut]===0||t===0||t&&t>this[Ut])return this[wt](),null;this[zt]&&(t=null),this[Mt].length>1&&!this[zt]&&(this[Mt]=[this[kt]?this[Mt].join(""):Buffer.concat(this[Mt],this[Ut])]);let u=this[Rt](t||null,this[Mt][0]);return this[wt](),u}[Rt](t,u){if(this[zt])this[Ht]();else{let p=u;t===p.length||t===null?this[Ht]():typeof p=="string"?(this[Mt][0]=p.slice(t),u=p.slice(0,t),this[Ut]-=t):(this[Mt][0]=p.subarray(t),u=p.subarray(0,t),this[Ut]-=t)}return this.emit("data",u),!this[Mt].length&&!this[bt]&&this.emit("drain"),u}end(t,u,p){return typeof t=="function"&&(p=t,t=void 0),typeof u=="function"&&(p=u,u="utf8"),t!==void 0&&this.write(t,u),p&&this.once("end",p),this[bt]=!0,this.writable=!1,(this[Ct]||!this[It])&&this[wt](),this}[Nt](){this[Vt]||(!this[Qt]&&!this[Ft].length&&(this[er]=!0),this[It]=!1,this[Ct]=!0,this.emit("resume"),this[Mt].length?this[Ot]():this[bt]?this[wt]():this.emit("drain"))}resume(){return this[Nt]()}pause(){this[Ct]=!1,this[It]=!0,this[er]=!1}get destroyed(){return this[Vt]}get flowing(){return this[Ct]}get paused(){return this[It]}[Bt](t){this[zt]?this[Ut]+=1:this[Ut]+=t.length,this[Mt].push(t)}[Ht](){return this[zt]?this[Ut]-=1:this[Ut]-=this[Mt][0].length,this[Mt].shift()}[Ot](t=!1){do{}while(this[At](this[Ht]())&&this[Mt].length);!t&&!this[Mt].length&&!this[bt]&&this.emit("drain")}[At](t){return this.emit("data",t),this[Ct]}pipe(t,u){if(this[Vt])return t;this[er]=!1;let p=this[Et];return u=u||{},t===_t.stdout||t===_t.stderr?u.end=!1:u.end=u.end!==!1,u.proxyErrors=!!u.proxyErrors,p?u.end&&t.end():(this[Ft].push(u.proxyErrors?new sr(this,t,u):new tr(this,t,u)),this[Yt]?jt((()=>this[Nt]())):this[Nt]()),t}unpipe(t){let u=this[Ft].find((u=>u.dest===t));u&&(this[Ft].length===1?(this[Ct]&&this[Qt]===0&&(this[Ct]=!1),this[Ft]=[]):this[Ft].splice(this[Ft].indexOf(u),1),u.unpipe())}addListener(t,u){return this.on(t,u)}on(t,u){let p=super.on(t,u);if(t==="data")this[er]=!1,this[Qt]++,!this[Ft].length&&!this[Ct]&&this[Nt]();else if(t==="readable"&&this[Ut]!==0)super.emit("readable");else if(Kr(t)&&this[Et])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[$t]){let t=u;this[Yt]?jt((()=>t.call(this,this[$t]))):t.call(this,this[$t])}return p}removeListener(t,u){return this.off(t,u)}off(t,u){let p=super.off(t,u);return t==="data"&&(this[Qt]=this.listeners("data").length,this[Qt]===0&&!this[er]&&!this[Ft].length&&(this[Ct]=!1)),p}removeAllListeners(t){let u=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Qt]=0,!this[er]&&!this[Ft].length&&(this[Ct]=!1)),u}get emittedEnd(){return this[Et]}[wt](){!this[St]&&!this[Et]&&!this[Vt]&&this[Mt].length===0&&this[bt]&&(this[St]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Pt]&&this.emit("close"),this[St]=!1)}emit(t,...u){let p=u[0];if(t!=="error"&&t!=="close"&&t!==Vt&&this[Vt])return!1;if(t==="data")return!this[zt]&&!p?!1:this[Yt]?(jt((()=>this[qt](p))),!0):this[qt](p);if(t==="end")return this[Wt]();if(t==="close"){if(this[Pt]=!0,!this[Et]&&!this[Vt])return!1;let t=super.emit("close");return this.removeAllListeners("close"),t}else if(t==="error"){this[$t]=p,super.emit(Gt,p);let t=!this[Xt]||this.listeners("error").length?super.emit("error",p):!1;return this[wt](),t}else if(t==="resume"){let t=super.emit("resume");return this[wt](),t}else if(t==="finish"||t==="prefinish"){let u=super.emit(t);return this.removeAllListeners(t),u}let m=super.emit(t,...u);return this[wt](),m}[qt](t){for(let u of this[Ft])u.dest.write(t)===!1&&this.pause();let u=this[er]?!1:super.emit("data",t);return this[wt](),u}[Wt](){return this[Et]?!1:(this[Et]=!0,this.readable=!1,this[Yt]?(jt((()=>this[Kt]())),!0):this[Kt]())}[Kt](){if(this[Tt]){let t=this[Tt].end();if(t){for(let u of this[Ft])u.dest.write(t);this[er]||super.emit("data",t)}}for(let t of this[Ft])t.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[zt]||(t.dataLength=0);let u=this.promise();return this.on("data",(u=>{t.push(u),this[zt]||(t.dataLength+=u.length)})),await u,t}async concat(){if(this[zt])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[kt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise(((t,u)=>{this.on(Vt,(()=>u(new Error("stream destroyed")))),this.on("error",(t=>u(t))),this.on("end",(()=>t()))}))}[Symbol.asyncIterator](){this[er]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let u=this.read();if(u!==null)return Promise.resolve({done:!1,value:u});if(this[bt])return e();let p,m,h=t=>{this.off("data",a),this.off("end",l),this.off(Vt,c),e(),m(t)},a=t=>{this.off("error",h),this.off("end",l),this.off(Vt,c),this.pause(),p({value:t,done:!!this[bt]})},l=()=>{this.off("error",h),this.off("data",a),this.off(Vt,c),e(),p({done:!0,value:void 0})},c=()=>h(new Error("stream destroyed"));return new Promise(((t,u)=>{m=u,p=t,this.once(Vt,c),this.once("error",h),this.once("end",l),this.once("data",a)}))},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[er]=!1;let t=!1,e=()=>(this.pause(),this.off(Gt,e),this.off(Vt,e),this.off("end",e),t=!0,{done:!0,value:void 0}),i=()=>{if(t)return e();let u=this.read();return u===null?e():{done:!1,value:u}};return this.once("end",e),this.once(Gt,e),this.once(Vt,e),{next:i,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Vt])return t?this.emit("error",t):this.emit(Vt),this;this[Vt]=!0,this[er]=!0,this[Mt].length=0,this[Ut]=0;let u=this;return typeof u.close=="function"&&!this[Pt]&&u.close(),t?this.emit("error",t):this.emit(Vt),this}static get isStream(){return Wr}};var nr=ze.writev,ar=Symbol("_autoClose"),cr=Symbol("_close"),lr=Symbol("_ended"),ur=Symbol("_fd"),hr=Symbol("_finished"),pr=Symbol("_flags"),mr=Symbol("_flush"),yr=Symbol("_handleChunk"),wr=Symbol("_makeBuf"),Er=Symbol("_mode"),Sr=Symbol("_needDrain"),Pr=Symbol("_onerror"),xr=Symbol("_onopen"),Rr=Symbol("_onread"),Or=Symbol("_onwrite"),Ar=Symbol("_open"),kr=Symbol("_path"),Cr=Symbol("_pos"),Ir=Symbol("_queue"),Nr=Symbol("_read"),Dr=Symbol("_readSize"),jr=Symbol("_reading"),Mr=Symbol("_remain"),Fr=Symbol("_size"),Br=Symbol("_write"),Hr=Symbol("_writing"),zr=Symbol("_defaultFlag"),Jr=Symbol("_errored"),Qr=class extends ir{[Jr]=!1;[ur];[kr];[Dr];[jr]=!1;[Fr];[Mr];[ar];constructor(t,u){if(u=u||{},super(u),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Jr]=!1,this[ur]=typeof u.fd=="number"?u.fd:void 0,this[kr]=t,this[Dr]=u.readSize||16*1024*1024,this[jr]=!1,this[Fr]=typeof u.size=="number"?u.size:1/0,this[Mr]=this[Fr],this[ar]=typeof u.autoClose=="boolean"?u.autoClose:!0,typeof this[ur]=="number"?this[Nr]():this[Ar]()}get fd(){return this[ur]}get path(){return this[kr]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[Ar](){ze.open(this[kr],"r",((t,u)=>this[xr](t,u)))}[xr](t,u){t?this[Pr](t):(this[ur]=u,this.emit("open",u),this[Nr]())}[wr](){return Buffer.allocUnsafe(Math.min(this[Dr],this[Mr]))}[Nr](){if(!this[jr]){this[jr]=!0;let t=this[wr]();if(t.length===0)return process.nextTick((()=>this[Rr](null,0,t)));ze.read(this[ur],t,0,t.length,null,((t,u,p)=>this[Rr](t,u,p)))}}[Rr](t,u,p){this[jr]=!1,t?this[Pr](t):this[yr](u,p)&&this[Nr]()}[cr](){if(this[ar]&&typeof this[ur]=="number"){let t=this[ur];this[ur]=void 0,ze.close(t,(t=>t?this.emit("error",t):this.emit("close")))}}[Pr](t){this[jr]=!0,this[cr](),this.emit("error",t)}[yr](t,u){let p=!1;return this[Mr]-=t,t>0&&(p=super.write(t<u.length?u.subarray(0,t):u)),(t===0||this[Mr]<=0)&&(p=!1,this[cr](),super.end()),p}emit(t,...u){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ur]=="number"&&this[Nr](),!1;case"error":return this[Jr]?!1:(this[Jr]=!0,super.emit(t,...u));default:return super.emit(t,...u)}}},es=class extends Qr{[Ar](){let t=!0;try{this[xr](null,ze.openSync(this[kr],"r")),t=!1}finally{t&&this[cr]()}}[Nr](){let t=!0;try{if(!this[jr]){this[jr]=!0;do{let t=this[wr](),u=t.length===0?0:ze.readSync(this[ur],t,0,t.length,null);if(!this[yr](u,t))break}while(!0);this[jr]=!1}t=!1}finally{t&&this[cr]()}}[cr](){if(this[ar]&&typeof this[ur]=="number"){let t=this[ur];this[ur]=void 0,ze.closeSync(t),this.emit("close")}}},rs=class extends nt{readable=!1;writable=!0;[Jr]=!1;[Hr]=!1;[lr]=!1;[Ir]=[];[Sr]=!1;[kr];[Er];[ar];[ur];[zr];[pr];[hr]=!1;[Cr];constructor(t,u){u=u||{},super(u),this[kr]=t,this[ur]=typeof u.fd=="number"?u.fd:void 0,this[Er]=u.mode===void 0?438:u.mode,this[Cr]=typeof u.start=="number"?u.start:void 0,this[ar]=typeof u.autoClose=="boolean"?u.autoClose:!0;let p=this[Cr]!==void 0?"r+":"w";this[zr]=u.flags===void 0,this[pr]=u.flags===void 0?p:u.flags,this[ur]===void 0&&this[Ar]()}emit(t,...u){if(t==="error"){if(this[Jr])return!1;this[Jr]=!0}return super.emit(t,...u)}get fd(){return this[ur]}get path(){return this[kr]}[Pr](t){this[cr](),this[Hr]=!0,this.emit("error",t)}[Ar](){ze.open(this[kr],this[pr],this[Er],((t,u)=>this[xr](t,u)))}[xr](t,u){this[zr]&&this[pr]==="r+"&&t&&t.code==="ENOENT"?(this[pr]="w",this[Ar]()):t?this[Pr](t):(this[ur]=u,this.emit("open",u),this[Hr]||this[mr]())}end(t,u){return t&&this.write(t,u),this[lr]=!0,!this[Hr]&&!this[Ir].length&&typeof this[ur]=="number"&&this[Or](null,0),this}write(t,u){return typeof t=="string"&&(t=Buffer.from(t,u)),this[lr]?(this.emit("error",new Error("write() after end()")),!1):this[ur]===void 0||this[Hr]||this[Ir].length?(this[Ir].push(t),this[Sr]=!0,!1):(this[Hr]=!0,this[Br](t),!0)}[Br](t){ze.write(this[ur],t,0,t.length,this[Cr],((t,u)=>this[Or](t,u)))}[Or](t,u){t?this[Pr](t):(this[Cr]!==void 0&&typeof u=="number"&&(this[Cr]+=u),this[Ir].length?this[mr]():(this[Hr]=!1,this[lr]&&!this[hr]?(this[hr]=!0,this[cr](),this.emit("finish")):this[Sr]&&(this[Sr]=!1,this.emit("drain"))))}[mr](){if(this[Ir].length===0)this[lr]&&this[Or](null,0);else if(this[Ir].length===1)this[Br](this[Ir].pop());else{let t=this[Ir];this[Ir]=[],nr(this[ur],t,this[Cr],((t,u)=>this[Or](t,u)))}}[cr](){if(this[ar]&&typeof this[ur]=="number"){let t=this[ur];this[ur]=void 0,ze.close(t,(t=>t?this.emit("error",t):this.emit("close")))}}},ss=class extends rs{[Ar](){let t;if(this[zr]&&this[pr]==="r+")try{t=ze.openSync(this[kr],this[pr],this[Er])}catch(t){if(t?.code==="ENOENT")return this[pr]="w",this[Ar]();throw t}else t=ze.openSync(this[kr],this[pr],this[Er]);this[xr](null,t)}[cr](){if(this[ar]&&typeof this[ur]=="number"){let t=this[ur];this[ur]=void 0,ze.closeSync(t),this.emit("close")}}[Br](t){let u=!0;try{this[Or](null,ze.writeSync(this[ur],t,0,t.length,this[Cr])),u=!1}finally{if(u)try{this[cr]()}catch{}}}};var is=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"]]),Fs=t=>!!t.sync&&!!t.file,ks=t=>!t.sync&&!!t.file,vs=t=>!!t.sync&&!t.file,Ms=t=>!t.sync&&!t.file;var Bs=t=>!!t.file;var tn=t=>{let u=is.get(t);return u||t},se=(t={})=>{if(!t)return{};let u={};for(let[p,m]of Object.entries(t)){let t=tn(p);u[t]=m}return u.chmod===void 0&&u.noChmod===!1&&(u.chmod=!0),delete u.noChmod,u};var K=(t,u,p,m,g)=>Object.assign(((v=[],b,w)=>{Array.isArray(v)&&(b=v,v={}),typeof b=="function"&&(w=b,b=void 0),b=b?Array.from(b):[];let E=se(v);if(g?.(E,b),Fs(E)){if(typeof w=="function")throw new TypeError("callback not supported for sync tar functions");return t(E,b)}else if(ks(E)){let t=u(E,b);return w?t.then((()=>w()),w):t}else if(vs(E)){if(typeof w=="function")throw new TypeError("callback not supported for sync tar functions");return p(E,b)}else if(Ms(E)){if(typeof w=="function")throw new TypeError("callback only supported with file option");return m(E,b)}throw new Error("impossible options??")}),{syncFile:t,asyncFile:u,syncNoFile:p,asyncNoFile:m,validate:g});var ns=ft.constants||{ZLIB_VERNUM:4736},os=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},ns));var as=dt.Buffer.concat,cs=Object.getOwnPropertyDescriptor(dt.Buffer,"concat"),nn=t=>t,ls=cs?.writable===!0||cs?.set!==void 0?t=>{dt.Buffer.concat=t?nn:as}:t=>{},us=Symbol("_superWrite"),hs=class extends Error{code;errno;constructor(t,u){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,u??this.constructor)}get name(){return"ZlibError"}},ds=Symbol("flushFlag"),ms=class extends ir{#i=!1;#n=!1;#o;#a;#c;#l;#u;get sawError(){return this.#i}get handle(){return this.#l}get flushFlag(){return this.#o}constructor(t,u){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#o=t.flush??0,this.#a=t.finishFlush??0,this.#c=t.fullFlushFlag??0,typeof pt[u]!="function")throw new TypeError("Compression method not supported: "+u);try{this.#l=new pt[u](t)}catch(t){throw new hs(t,this.constructor)}this.#u=t=>{this.#i||(this.#i=!0,this.close(),this.emit("error",t))},this.#l?.on("error",(t=>this.#u(new hs(t)))),this.once("end",(()=>this.close))}close(){this.#l&&(this.#l.close(),this.#l=void 0,this.emit("close"))}reset(){if(!this.#i)return ht(this.#l,"zlib binding closed"),this.#l.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#c),this.write(Object.assign(dt.Buffer.alloc(0),{[ds]:t})))}end(t,u,p){return typeof t=="function"&&(p=t,u=void 0,t=void 0),typeof u=="function"&&(p=u,u=void 0),t&&(u?this.write(t,u):this.write(t)),this.flush(this.#a),this.#n=!0,super.end(p)}get ended(){return this.#n}[us](t){return super.write(t)}write(t,u,p){if(typeof u=="function"&&(p=u,u="utf8"),typeof t=="string"&&(t=dt.Buffer.from(t,u)),this.#i)return;ht(this.#l,"zlib binding closed");let m=this.#l._handle,g=m.close;m.close=()=>{};let v=this.#l.close;this.#l.close=()=>{},ls(!0);let b;try{let u=typeof t[ds]=="number"?t[ds]:this.#o;b=this.#l._processChunk(t,u),ls(!1)}catch(t){ls(!1),this.#u(new hs(t,this.write))}finally{this.#l&&(this.#l._handle=m,m.close=g,this.#l.close=v,this.#l.removeAllListeners("error"))}this.#l&&this.#l.on("error",(t=>this.#u(new hs(t,this.write))));let w;if(b)if(Array.isArray(b)&&b.length>0){let t=b[0];w=this[us](dt.Buffer.from(t));for(let t=1;t<b.length;t++)w=this[us](b[t])}else w=this[us](dt.Buffer.from(b));return p&&p(),w}},gs=class extends ms{#i;#n;constructor(t,u){t=t||{},t.flush=t.flush||os.Z_NO_FLUSH,t.finishFlush=t.finishFlush||os.Z_FINISH,t.fullFlushFlag=os.Z_FULL_FLUSH,super(t,u),this.#i=t.level,this.#n=t.strategy}params(t,u){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#i!==t||this.#n!==u){this.flush(os.Z_SYNC_FLUSH),ht(this.handle,"zlib binding closed");let p=this.handle.flush;this.handle.flush=(t,u)=>{typeof t=="function"&&(u=t,t=this.flushFlag),this.flush(t),u?.()};try{this.handle.params(t,u)}finally{this.handle.flush=p}this.handle&&(this.#i=t,this.#n=u)}}}};var ys=class extends gs{#i;constructor(t){super(t,"Gzip"),this.#i=t&&!!t.portable}[us](t){return this.#i?(this.#i=!1,t[9]=255,super[us](t)):super[us](t)}};var _s=class extends gs{constructor(t){super(t,"Unzip")}},bs=class extends ms{constructor(t,u){t=t||{},t.flush=t.flush||os.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||os.BROTLI_OPERATION_FINISH,t.fullFlushFlag=os.BROTLI_OPERATION_FLUSH,super(t,u)}},$s=class extends bs{constructor(t){super(t,"BrotliCompress")}},Ps=class extends bs{constructor(t){super(t,"BrotliDecompress")}},xs=class extends ms{constructor(t,u){t=t||{},t.flush=t.flush||os.ZSTD_e_continue,t.finishFlush=t.finishFlush||os.ZSTD_e_end,t.fullFlushFlag=os.ZSTD_e_flush,super(t,u)}},Rs=class extends xs{constructor(t){super(t,"ZstdCompress")}},Os=class extends xs{constructor(t){super(t,"ZstdDecompress")}};var Us=(t,u)=>{if(Number.isSafeInteger(t))t<0?an(t,u):hn(t,u);else throw Error("cannot encode number outside of javascript safe integer range");return u},hn=(t,u)=>{u[0]=128;for(var p=u.length;p>1;p--)u[p-1]=t&255,t=Math.floor(t/256)},an=(t,u)=>{u[0]=255;var p=!1;t=t*-1;for(var m=u.length;m>1;m--){var g=t&255;t=Math.floor(t/256),p?u[m-1]=Ws(g):g===0?u[m-1]=0:(p=!0,u[m-1]=Gs(g))}},Hs=t=>{let u=t[0],p=u===128?cn(t.subarray(1,t.length)):u===255?ln(t):null;if(p===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(p))throw Error("parsed number outside of javascript safe integer range");return p},ln=t=>{for(var u=t.length,p=0,m=!1,g=u-1;g>-1;g--){var v=Number(t[g]),b;m?b=Ws(v):v===0?b=v:(m=!0,b=Gs(v)),b!==0&&(p-=b*Math.pow(256,u-g-1))}return p},cn=t=>{for(var u=t.length,p=0,m=u-1;m>-1;m--){var g=Number(t[m]);g!==0&&(p+=g*Math.pow(256,u-m-1))}return p},Ws=t=>(255^t)&255,Gs=t=>(255^t)+1&255;var As={};Ur(As,{code:()=>Is,isCode:()=>ne,isName:()=>dn,name:()=>Cs,normalFsTypes:()=>Ts});var ne=t=>Cs.has(t),dn=t=>Is.has(t),Ts=new Set(["0","","1","2","3","4","5","6","7","D"]),Cs=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"]]),Is=new Map(Array.from(Cs).map((t=>[t[1],t[0]])));var un=t=>t===void 0||t<0?void 0:t,Ns=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#i="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,u=0,p,m){Buffer.isBuffer(t)?this.decode(t,u||0,p,m):t&&this.#n(t)}decode(t,u,p,m){if(u||(u=0),!t||!(t.length>=u+512))throw new Error("need 512 bytes for header");let g=xt(t,u+156,1),v=Ts.has(g),b=v?p:void 0,w=v?m:void 0;if(this.path=b?.path??xt(t,u,100),this.mode=b?.mode??w?.mode??lt(t,u+100,8),this.uid=b?.uid??w?.uid??lt(t,u+108,8),this.gid=b?.gid??w?.gid??lt(t,u+116,8),this.size=un(b?.size??w?.size??lt(t,u+124,12)),this.mtime=b?.mtime??w?.mtime??Wi(t,u+136,12),this.cksum=lt(t,u+148,12),w&&this.#n(w,!0),b&&this.#n(b),ne(g)&&(this.#i=g||"0"),this.#i==="0"&&this.path.slice(-1)==="/"&&(this.#i="5"),this.#i==="5"&&(this.size=0),this.linkpath=xt(t,u+157,100),t.subarray(u+257,u+265).toString()==="ustar\x0000")if(this.uname=b?.uname??w?.uname??xt(t,u+265,32),this.gname=b?.gname??w?.gname??xt(t,u+297,32),this.devmaj=b?.devmaj??w?.devmaj??lt(t,u+329,8)??0,this.devmin=b?.devmin??w?.devmin??lt(t,u+337,8)??0,t[u+475]!==0){let p=xt(t,u+345,155);this.path=p+"/"+this.path}else{let g=xt(t,u+345,130);g&&(this.path=g+"/"+this.path),this.atime=p?.atime??m?.atime??Wi(t,u+476,12),this.ctime=p?.ctime??m?.ctime??Wi(t,u+488,12)}let E=256;for(let p=u;p<u+148;p++)E+=t[p];for(let p=u+156;p<u+512;p++)E+=t[p];this.cksumValid=E===this.cksum,this.cksum===void 0&&E===256&&(this.nullBlock=!0)}#n(t,u=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter((([t,p])=>!(p==null||t==="size"&&Number(p)<0||t==="path"&&u||t==="linkpath"&&u||t==="global")))))}encode(t,u=0){if(t||(t=this.block=Buffer.alloc(512)),this.#i==="Unsupported"&&(this.#i="0"),!(t.length>=u+512))throw new Error("need 512 bytes for header");let p=this.ctime||this.atime?130:155,m=mn(this.path||"",p),g=m[0],v=m[1];this.needPax=!!m[2],this.needPax=Lt(t,u,100,g)||this.needPax,this.needPax=ct(t,u+100,8,this.mode)||this.needPax,this.needPax=ct(t,u+108,8,this.uid)||this.needPax,this.needPax=ct(t,u+116,8,this.gid)||this.needPax,this.needPax=ct(t,u+124,12,this.size)||this.needPax,this.needPax=Gi(t,u+136,12,this.mtime)||this.needPax,t[u+156]=Number(this.#i.codePointAt(0)),this.needPax=Lt(t,u+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",u+257,8),this.needPax=Lt(t,u+265,32,this.uname)||this.needPax,this.needPax=Lt(t,u+297,32,this.gname)||this.needPax,this.needPax=ct(t,u+329,8,this.devmaj)||this.needPax,this.needPax=ct(t,u+337,8,this.devmin)||this.needPax,this.needPax=Lt(t,u+345,p,v)||this.needPax,t[u+475]!==0?this.needPax=Lt(t,u+345,155,v)||this.needPax:(this.needPax=Lt(t,u+345,130,v)||this.needPax,this.needPax=Gi(t,u+476,12,this.atime)||this.needPax,this.needPax=Gi(t,u+488,12,this.ctime)||this.needPax);let b=256;for(let p=u;p<u+148;p++)b+=t[p];for(let p=u+156;p<u+512;p++)b+=t[p];return this.cksum=b,ct(t,u+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#i==="Unsupported"?this.#i:Cs.get(this.#i)}get typeKey(){return this.#i}set type(t){let u=String(Is.get(t));if(ne(u)||u==="Unsupported")this.#i=u;else if(ne(t))this.#i=t;else throw new TypeError("invalid entry type: "+t)}},mn=(t,u)=>{let p=t,m="",g,v=T.posix.parse(t).root||".";if(Buffer.byteLength(p)<100)g=[p,m,!1];else{m=T.posix.dirname(p),p=T.posix.basename(p);do{Buffer.byteLength(p)<=100&&Buffer.byteLength(m)<=u?g=[p,m,!1]:Buffer.byteLength(p)>100&&Buffer.byteLength(m)<=u?g=[p.slice(0,99),m,!0]:(p=T.posix.join(T.posix.basename(m),p),m=T.posix.dirname(m))}while(m!==v&&g===void 0);g||(g=[t.slice(0,99),"",!0])}return g},xt=(t,u,p)=>t.subarray(u,u+p).toString("utf8").replace(/\0.*/,""),Wi=(t,u,p)=>pn(lt(t,u,p)),pn=t=>t===void 0?void 0:new Date(t*1e3),lt=(t,u,p)=>Number(t[u])&128?Hs(t.subarray(u,u+p)):wn(t,u,p),En=t=>isNaN(t)?void 0:t,wn=(t,u,p)=>En(parseInt(t.subarray(u,u+p).toString("utf8").replace(/\0.*$/,"").trim(),8)),Ds={12:8589934591,8:2097151},ct=(t,u,p,m)=>m===void 0?!1:m>Ds[p]||m<0?(Us(m,t.subarray(u,u+p)),!0):(yn(t,u,p,m),!1),yn=(t,u,p,m)=>t.write(Rn(m,p),u,p,"ascii"),Rn=(t,u)=>gn(Math.floor(t).toString(8),u),gn=(t,u)=>(t.length===u-1?t:new Array(u-t.length-1).join("0")+t+" ")+"\0",Gi=(t,u,p,m)=>m===void 0?!1:ct(t,u,p,m.getTime()/1e3),js=new Array(156).join("\0"),Lt=(t,u,p,m)=>m===void 0?!1:(t.write(m+js,u,p,"utf8"),m.length!==Buffer.byteLength(m)||m.length>p);var Ls=class s{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(t,u=!1){this.atime=t.atime,this.charset=t.charset,this.comment=t.comment,this.ctime=t.ctime,this.dev=t.dev,this.gid=t.gid,this.global=u,this.gname=t.gname,this.ino=t.ino,this.linkpath=t.linkpath,this.mtime=t.mtime,this.nlink=t.nlink,this.path=t.path,this.size=t.size,this.uid=t.uid,this.uname=t.uname}encode(){let t=this.encodeBody();if(t==="")return Buffer.allocUnsafe(0);let u=Buffer.byteLength(t),p=512*Math.ceil(1+u/512),m=Buffer.allocUnsafe(p);for(let t=0;t<512;t++)m[t]=0;new Ns({path:("PaxHeader/"+(0,T.basename)(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:u,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(m),m.write(t,512,u,"utf8");for(let t=u+512;t<m.length;t++)m[t]=0;return m}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(t){if(this[t]===void 0)return"";let u=this[t],p=u instanceof Date?u.getTime()/1e3:u,m=" "+(t==="dev"||t==="ino"||t==="nlink"?"SCHILY.":"")+t+"="+p+`\n`,g=Buffer.byteLength(m),v=Math.floor(Math.log(g)/Math.log(10))+1;return g+v>=Math.pow(10,v)&&(v+=1),v+g+m}static parse(t,u,p=!1){return new s(On(Tn(t),u),p)}},On=(t,u)=>u?Object.assign({},u,t):t,Tn=t=>t.replace(/\n$/,"").split(`\n`).reduce(xn,Object.create(null)),xn=(t,u)=>{let p=parseInt(u,10);if(p!==Buffer.byteLength(u)+1)return t;u=u.slice((p+" ").length);let m=u.split("="),g=m.shift();if(!g)return t;let v=g.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),b=m.join("=").replace(/\0.*/,"");switch(v){case"path":case"linkpath":case"type":case"charset":case"comment":case"gname":case"uname":t[v]=b;break;case"ctime":case"atime":case"mtime":t[v]=new Date(Number(b)*1e3);break;case"size":let u=+b;u>=0&&(t[v]=u);break;case"gid":case"uid":case"dev":case"ino":case"nlink":case"mode":t[v]=+b;break}return t};var zs=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Vs=zs!=="win32"?t=>String(t):t=>String(t).replaceAll(/\\/g,"/");var qs=class extends ir{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,u,p){switch(super({}),this.pause(),this.extended=u,this.globalExtended=p,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Vs(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Vs(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,u&&this.#i(u),p&&this.#i(p,!0)}write(t){let u=t.length;if(u>this.blockRemain)throw new Error("writing more to entry than is appropriate");let p=this.remain,m=this.blockRemain;return this.remain=Math.max(0,p-u),this.blockRemain=Math.max(0,m-u),this.ignore?!0:p>=u?super.write(t):super.write(t.subarray(0,p))}#i(t,u=!1){t.path&&(t.path=Vs(t.path)),t.linkpath&&(t.linkpath=Vs(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter((([t,p])=>!(p==null||t==="path"&&u)))))}};var Dt=(t,u,p,m={})=>{t.file&&(m.file=t.file),t.cwd&&(m.cwd=t.cwd),m.code=p instanceof Error&&p.code||u,m.tarCode=u,!t.strict&&m.recoverable!==!1?(p instanceof Error&&(m=Object.assign(p,m),p=p.message),t.emit("warn",u,p,m)):p instanceof Error?t.emit("error",Object.assign(p,m)):t.emit("error",Object.assign(new Error(`${u}: ${p}`),m))};var Ks=1024*1024,Ys=Buffer.from([31,139]),Zs=Buffer.from([40,181,47,253]),Js=Math.max(Ys.length,Zs.length),Xs=Symbol("state"),ei=Symbol("writeEntry"),ti=Symbol("readEntry"),ri=Symbol("nextEntry"),si=Symbol("processEntry"),ii=Symbol("extendedHeader"),ni=Symbol("globalExtendedHeader"),oi=Symbol("meta"),ai=Symbol("emitMeta"),ci=Symbol("buffer"),li=Symbol("queue"),ui=Symbol("ended"),hi=Symbol("emittedEnd"),di=Symbol("emit"),fi=Symbol("unzip"),pi=Symbol("consumeChunk"),mi=Symbol("consumeChunkSub"),gi=Symbol("consumeBody"),yi=Symbol("consumeMeta"),vi=Symbol("consumeHeader"),_i=Symbol("consuming"),bi=Symbol("bufferConcat"),wi=Symbol("maybeEnd"),Si=Symbol("writing"),$i=Symbol("aborted"),Pi=Symbol("onDone"),xi=Symbol("sawValidEntry"),Ri=Symbol("sawNullBlock"),Oi=Symbol("sawEOF"),Ai=Symbol("closeStream"),ki=1e3,Ti=Symbol("compressedBytesRead"),Ci=Symbol("decompressedBytesRead"),Ii=Symbol("checkDecompressionRatio"),Cn=()=>!0,Ni=class extends nt.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;maxDecompressionRatio;writable=!0;readable=!1;[li]=[];[ci];[ti];[ei];[Xs]="begin";[oi]="";[ii];[ni];[ui]=!1;[fi];[$i]=!1;[xi];[Ri]=!1;[Oi]=!1;[Si]=!1;[_i]=!1;[hi]=!1;[Ti]=0;[Ci]=0;constructor(t={}){super(),this.file=t.file||"",this.on(Pi,(()=>{(this[Xs]==="begin"||this[xi]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")})),t.ondone?this.on(Pi,t.ondone):this.on(Pi,(()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")})),this.strict=!!t.strict,this.maxDecompressionRatio=typeof t.maxDecompressionRatio=="number"?t.maxDecompressionRatio:ki,this.maxMetaEntrySize=t.maxMetaEntrySize||Ks,this.filter=typeof t.filter=="function"?t.filter:Cn;let u=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:u?void 0:!1;let p=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:p?!0:void 0,this.on("end",(()=>this[Ai]())),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,u,p={}){Dt(this,t,u,p)}[vi](t,u){this[xi]===void 0&&(this[xi]=!1);let p;try{p=new Ns(t,u,this[ii],this[ni])}catch(t){return this.warn("TAR_ENTRY_INVALID",t)}if(p.nullBlock)this[Ri]?(this[Oi]=!0,this[Xs]==="begin"&&(this[Xs]="header"),this[di]("eof")):(this[Ri]=!0,this[di]("nullBlock"));else if(this[Ri]=!1,!p.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:p});else if(!p.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:p});else{let t=p.type;if(/^(Symbolic)?Link$/.test(t)&&!p.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:p});else if(!/^(Symbolic)?Link$/.test(t)&&!/^(Global)?ExtendedHeader$/.test(t)&&p.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:p});else{let t=this[ei]=new qs(p,this[ii],this[ni]);if(!this[xi])if(t.remain){let o=()=>{t.invalid||(this[xi]=!0)};t.on("end",o)}else this[xi]=!0;t.meta?t.size>this.maxMetaEntrySize?(t.ignore=!0,this[di]("ignoredEntry",t),this[Xs]="ignore",t.resume()):t.size>0&&(this[oi]="",t.on("data",(t=>this[oi]+=t)),this[Xs]="meta"):(this[ii]=void 0,t.ignore=t.ignore||!this.filter(t.path,t),t.ignore?(this[di]("ignoredEntry",t),this[Xs]=t.remain?"ignore":"header",t.resume()):(t.remain?this[Xs]="body":(this[Xs]="header",t.end()),this[ti]?this[li].push(t):(this[li].push(t),this[ri]())))}}}[Ai](){queueMicrotask((()=>this.emit("close")))}[si](t){let u=!0;if(!t)this[ti]=void 0,u=!1;else if(Array.isArray(t)){let[u,...p]=t;this.emit(u,...p)}else this[ti]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",(()=>this[ri]())),u=!1);return u}[ri](){do{}while(this[si](this[li].shift()));if(this[li].length===0){let t=this[ti];!t||t.flowing||t.size===t.remain?this[Si]||this.emit("drain"):t.once("drain",(()=>this.emit("drain")))}}[gi](t,u){let p=this[ei];if(!p)throw new Error("attempt to consume body without entry??");let m=p.blockRemain??0,g=m>=t.length&&u===0?t:t.subarray(u,u+m);return p.write(g),p.blockRemain||(this[Xs]="header",this[ei]=void 0,p.end()),g.length}[yi](t,u){let p=this[ei],m=this[gi](t,u);return!this[ei]&&p&&this[ai](p),m}[di](t,u,p){this[li].length===0&&!this[ti]?this.emit(t,u,p):this[li].push([t,u,p])}[ai](t){switch(this[di]("meta",this[oi]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[ii]=Ls.parse(this[oi],this[ii],!1);break;case"GlobalExtendedHeader":this[ni]=Ls.parse(this[oi],this[ni],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let t=this[ii]??Object.create(null);this[ii]=t,t.path=this[oi].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let t=this[ii]||Object.create(null);this[ii]=t,t.linkpath=this[oi].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){if(!this[$i]){if(this[fi]){let t=this[fi];t.write=()=>!0,t.end=()=>t,t.emit=()=>!1,t.destroy?.()}this[$i]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}}[Ii](t){this[Ci]+=t.length;let u=this[Ci]/this[Ti];return u>this.maxDecompressionRatio?(this.abort(new Error(`max decompression ratio exceeded: ${u.toFixed(2)} > ${this.maxDecompressionRatio}`)),!1):!0}write(t,u,p){if(typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof u=="string"?u:"utf8")),this[$i])return p?.(),!1;if((this[fi]===void 0||this.brotli===void 0&&this[fi]===!1)&&t){if(this[ci]&&(t=Buffer.concat([this[ci],t]),this[ci]=void 0),t.length<Js)return this[ci]=t,p?.(),!0;for(let u=0;this[fi]===void 0&&u<Ys.length;u++)t[u]!==Ys[u]&&(this[fi]=!1);let u=!1;if(this[fi]===!1&&this.zstd!==!1){u=!0;for(let p=0;p<Zs.length;p++)if(t[p]!==Zs[p]){u=!1;break}}let m=this.brotli===void 0&&!u;if(this[fi]===!1&&m)if(t.length<512)if(this[ui])this.brotli=!0;else return this[ci]=t,p?.(),!0;else try{new Ns(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[fi]===void 0||this[fi]===!1&&(this.brotli||u)){let m=this[ui];this[ui]=!1,this[fi]=this[fi]===void 0?new _s({}):u?new Os({}):new Ps({}),this[fi].on("data",(t=>{this[Ii](t)&&this[pi](t)})),this[fi].on("error",(t=>{this[$i]||this.abort(t)})),this[fi].on("end",(()=>{this[ui]=!0,this[pi]()})),this[Si]=!0,this[Ti]+=t.length;let g=!!this[fi][m?"end":"write"](t);return this[Si]=!1,p?.(),g}}this[Si]=!0,this[fi]?(this[Ti]+=t.length,this[fi].write(t)):this[pi](t),this[Si]=!1;let m=this[li].length>0?!1:this[ti]?this[ti].flowing:!0;return!m&&this[li].length===0&&this[ti]?.once("drain",(()=>this.emit("drain"))),p?.(),m}[bi](t){t&&!this[$i]&&(this[ci]=this[ci]?Buffer.concat([this[ci],t]):t)}[wi](){if(this[ui]&&!this[hi]&&!this[$i]&&!this[_i]){this[hi]=!0;let t=this[ei];if(t?.blockRemain){let u=this[ci]?this[ci].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${u} available)`,{entry:t}),this[ci]&&t.write(this[ci]),t.end()}this[di](Pi)}}[pi](t){if(this[_i]&&t)this[bi](t);else if(!t&&!this[ci])this[wi]();else if(t){if(this[_i]=!0,this[ci]){this[bi](t);let u=this[ci];this[ci]=void 0,this[mi](u)}else this[mi](t);for(;this[ci]&&this[ci]?.length>=512&&!this[$i]&&!this[Oi];){let t=this[ci];this[ci]=void 0,this[mi](t)}this[_i]=!1}(!this[ci]||this[ui])&&this[wi]()}[mi](t){let u=0,p=t.length;for(;u+512<=p&&!this[$i]&&!this[Oi];)switch(this[Xs]){case"begin":case"header":this[vi](t,u),u+=512;break;case"ignore":case"body":u+=this[gi](t,u);break;case"meta":u+=this[yi](t,u);break;default:throw new Error("invalid state: "+this[Xs])}u<p&&(this[ci]=this[ci]?Buffer.concat([t.subarray(u),this[ci]]):t.subarray(u))}end(t,u,p){return typeof t=="function"&&(p=t,u=void 0,t=void 0),typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,u)),p&&this.once("finish",p),this[$i]||(this[fi]?(t&&(this[Ti]+=t.length,this[fi].write(t)),this[fi].end()):(this[ui]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[wi]())),this}};var mt=t=>{let u=t.length-1,p=-1;for(;u>-1&&t.charAt(u)==="/";)p=u,u--;return p===-1?t:t.slice(0,p)};var vn=t=>{let u=t.onReadEntry;t.onReadEntry=u?t=>{u(t),t.resume()}:t=>t.resume()},Qi=(t,u)=>{let p=new Map(u.map((t=>[mt(t),!0]))),m=t.filter,g=100,n=(t,u="",m=0)=>{if(m>=g)return p.set(t,!1),!1;let v=u||(0,Ve.parse)(t).root||".",b;if(t===v)b=!1;else{let u=p.get(t);b=u!==void 0?u:n((0,Ve.dirname)(t),v,m+1)}return p.set(t,b),b};t.filter=m?(t,u)=>m(t,u)&&n(mt(t)):t=>n(mt(t))},Mn=t=>{let u=new Ni(t),p=t.file,m;try{m=k.openSync(p,"r");let g=k.fstatSync(m),v=t.maxReadSize||16*1024*1024;if(g.size<v){let t=Buffer.allocUnsafe(g.size),p=k.readSync(m,t,0,g.size,0);u.end(p===t.byteLength?t:t.subarray(0,p))}else{let t=0,p=Buffer.allocUnsafe(v);for(;t<g.size;){let g=k.readSync(m,p,0,v,t);if(g===0)break;t+=g,u.write(p.subarray(0,g))}u.end()}}finally{if(typeof m=="number")try{k.closeSync(m)}catch{}}},Bn=(t,u)=>{let p=new Ni(t),m=t.maxReadSize||16*1024*1024,g=t.file;return new Promise(((t,u)=>{p.on("error",u),p.on("end",t),k.stat(g,((t,v)=>{if(t)u(t);else{let t=new Qr(g,{readSize:m,size:v.size});t.on("error",u),t.pipe(p)}}))}))},Di=K(Mn,Bn,(t=>new Ni(t)),(t=>new Ni(t)),((t,u)=>{u?.length&&Qi(t,u),t.noResume||vn(t)}));var Ji=(t,u,p)=>(t&=4095,p&&(t=(t|384)&-19),u&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t);var{isAbsolute:ji,parse:Li}=T.win32,ce=t=>{let u="",p=Li(t);for(;ji(t)||p.root;){let m=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":p.root;t=t.slice(m.length),u+=m,p=Li(t)}return[u,t]};var Mi=["|","<",">","?",":"],Fi=Mi.map((t=>String.fromCodePoint(61440+Number(t.codePointAt(0))))),Ui=new Map(Mi.map(((t,u)=>[t,Fi[u]]))),Bi=new Map(Fi.map(((t,u)=>[t,Mi[u]]))),ts=t=>Mi.reduce(((t,u)=>t.split(u).join(Ui.get(u))),t),Qs=t=>Fi.reduce(((t,u)=>t.split(u).join(Bi.get(u))),t);var rr=(t,u)=>u?(t=Vs(t).replace(/^\.(\/|$)/,""),mt(u)+"/"+t):Vs(t),Hi=16*1024*1024,zi=Symbol("process"),Vi=Symbol("file"),qi=Symbol("directory"),Ki=Symbol("symlink"),Yi=Symbol("hardlink"),Zi=Symbol("header"),Xi=Symbol("read"),en=Symbol("lstat"),rn=Symbol("onlstat"),sn=Symbol("onread"),on=Symbol("onreadlink"),fn=Symbol("openfile"),_n=Symbol("onopenfile"),bn=Symbol("close"),Sn=Symbol("mode"),Pn=Symbol("awaitDrain"),An=Symbol("ondrain"),kn=Symbol("prefix"),In=class extends ir{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#i=!1;constructor(t,u={}){let p=se(u);super(),this.path=Vs(t),this.portable=!!p.portable,this.maxReadSize=p.maxReadSize||Hi,this.linkCache=p.linkCache||new Map,this.statCache=p.statCache||new Map,this.preservePaths=!!p.preservePaths,this.cwd=Vs(p.cwd||process.cwd()),this.strict=!!p.strict,this.noPax=!!p.noPax,this.noMtime=!!p.noMtime,this.mtime=p.mtime,this.prefix=p.prefix?Vs(p.prefix):void 0,this.onWriteEntry=p.onWriteEntry,typeof p.onwarn=="function"&&this.on("warn",p.onwarn);let m=!1;if(!this.preservePaths){let[t,u]=ce(this.path);t&&typeof u=="string"&&(this.path=u,m=t)}this.win32=!!p.win32||process.platform==="win32",this.win32&&(this.path=Qs(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Vs(p.absolute||Ve.resolve(this.cwd,t)),this.path===""&&(this.path="./"),m&&this.warn("TAR_ENTRY_INFO",`stripping ${m} from absolute path`,{entry:this,path:m+this.path});let g=this.statCache.get(this.absolute);g?this[rn](g):this[en]()}warn(t,u,p={}){return Dt(this,t,u,p)}emit(t,...u){return t==="error"&&(this.#i=!0),super.emit(t,...u)}[en](){ze.lstat(this.absolute,((t,u)=>{if(t)return this.emit("error",t);this[rn](u)}))}[rn](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Gn(t),this.emit("stat",t),this[zi]()}[zi](){switch(this.type){case"File":return this[Vi]();case"Directory":return this[qi]();case"SymbolicLink":return this[Ki]();default:return this.end()}}[Sn](t){return Ji(t,this.type==="Directory",this.portable)}[kn](t){return rr(t,this.prefix)}[Zi](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Ns({path:this[kn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kn](this.linkpath):this.linkpath,mode:this[Sn](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 Ls({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[kn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kn](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[qi](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Zi](),this.end()}[Ki](){ze.readlink(this.absolute,((t,u)=>{if(t)return this.emit("error",t);this[on](u)}))}[on](t){this.linkpath=Vs(t),this[Zi](),this.end()}[Yi](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Vs(Ve.relative(this.cwd,t)),this.stat.size=0,this[Zi](),this.end()}[Vi](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,u=this.linkCache.get(t);if(u?.indexOf(this.cwd)===0)return this[Yi](u);this.linkCache.set(t,this.absolute)}if(this[Zi](),this.stat.size===0)return this.end();this[fn]()}[fn](){ze.open(this.absolute,"r",((t,u)=>{if(t)return this.emit("error",t);this[_n](u)}))}[_n](t){if(this.fd=t,this.#i)return this[bn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let u=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(u),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Xi]()}[Xi](){let{fd:t,buf:u,offset:p,length:m,pos:g}=this;if(t===void 0||u===void 0)throw new Error("cannot read file without first opening");ze.read(t,u,p,m,g,((t,u)=>{if(t)return this[bn]((()=>this.emit("error",t)));this[sn](u)}))}[bn](t=()=>{}){this.fd!==void 0&&ze.close(this.fd,t)}[sn](t){if(t<=0&&this.remain>0){let t=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[bn]((()=>this.emit("error",t)))}if(t>this.remain){let t=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[bn]((()=>this.emit("error",t)))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let u=t;u<this.length&&t<this.blockRemain;u++)this.buf[u+this.offset]=0,t++,this.remain++;let u=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(u)?this[An]():this[Pn]((()=>this[An]()))}[Pn](t){this.once("drain",t)}write(t,u,p){if(typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof u=="string"?u:"utf8")),this.blockRemain<t.length){let t=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",t)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,p)}[An](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[bn]((t=>t?this.emit("error",t):this.end()));if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[Xi]()}},Nn=class extends In{sync=!0;[en](){this[rn](ze.lstatSync(this.absolute))}[Ki](){this[on](ze.readlinkSync(this.absolute))}[fn](){this[_n](ze.openSync(this.absolute,"r"))}[Xi](){let t=!0;try{let{fd:u,buf:p,offset:m,length:g,pos:v}=this;if(u===void 0||p===void 0)throw new Error("fd and buf must be set in READ method");let b=ze.readSync(u,p,m,g,v);this[sn](b),t=!1}finally{if(t)try{this[bn]((()=>{}))}catch{}}}[Pn](t){t()}[bn](t=()=>{}){this.fd!==void 0&&ze.closeSync(this.fd),t()}},Dn=class extends ir{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,u,p={}){return Dt(this,t,u,p)}constructor(t,u={}){let p=se(u);super(),this.preservePaths=!!p.preservePaths,this.portable=!!p.portable,this.strict=!!p.strict,this.noPax=!!p.noPax,this.noMtime=!!p.noMtime,this.onWriteEntry=p.onWriteEntry,this.readEntry=t;let{type:m}=t;if(m==="Unsupported")throw new Error("writing entry that should be ignored");this.type=m,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=p.prefix,this.path=Vs(t.path),this.mode=t.mode!==void 0?this[Sn](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:p.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Vs(t.linkpath):void 0,typeof p.onwarn=="function"&&this.on("warn",p.onwarn);let g=!1;if(!this.preservePaths){let[t,u]=ce(this.path);t&&typeof u=="string"&&(this.path=u,g=t)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Ns({path:this[kn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kn](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}),g&&this.warn("TAR_ENTRY_INFO",`stripping ${g} from absolute path`,{entry:this,path:g+this.path}),this.header.encode()&&!this.noPax&&super.write(new Ls({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[kn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kn](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let v=this.header?.block;if(!v)throw new Error("failed to encode header");super.write(v),t.pipe(this)}[kn](t){return rr(t,this.prefix)}[Sn](t){return Ji(t,this.type==="Directory",this.portable)}write(t,u,p){typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof u=="string"?u:"utf8"));let m=t.length;if(m>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=m,super.write(t,p)}end(t,u,p){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(p=t,u=void 0,t=void 0),typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,u??"utf8")),p&&this.once("finish",p),t?super.end(t,p):super.end(p),this}},Gn=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";var jn=class s{tail;head;length=0;static create(t=[]){return new s(t)}constructor(t=[]){for(let u of t)this.push(u)}*[Symbol.iterator](){for(let t=this.head;t;t=t.next)yield t.value}removeNode(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");let u=t.next,p=t.prev;return u&&(u.prev=p),p&&(p.next=u),t===this.head&&(this.head=u),t===this.tail&&(this.tail=p),this.length--,t.next=void 0,t.prev=void 0,t.list=void 0,u}unshiftNode(t){if(t===this.head)return;t.list&&t.list.removeNode(t);let u=this.head;t.list=this,t.next=u,u&&(u.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}pushNode(t){if(t===this.tail)return;t.list&&t.list.removeNode(t);let u=this.tail;t.list=this,t.prev=u,u&&(u.next=t),this.tail=t,this.head||(this.head=t),this.length++}push(...t){for(let u=0,p=t.length;u<p;u++)Yn(this,t[u]);return this.length}unshift(...t){for(var u=0,p=t.length;u<p;u++)Kn(this,t[u]);return this.length}pop(){if(!this.tail)return;let t=this.tail.value,u=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,u.list=void 0,this.length--,t}shift(){if(!this.head)return;let t=this.head.value,u=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,u.list=void 0,this.length--,t}forEach(t,u){u=u||this;for(let p=this.head,m=0;p;m++)t.call(u,p.value,m,this),p=p.next}forEachReverse(t,u){u=u||this;for(let p=this.tail,m=this.length-1;p;m--)t.call(u,p.value,m,this),p=p.prev}get(t){let u=0,p=this.head;for(;p&&u<t;u++)p=p.next;if(u===t&&p)return p.value}getReverse(t){let u=0,p=this.tail;for(;p&&u<t;u++)p=p.prev;if(u===t&&p)return p.value}map(t,u){u=u||this;let p=new s;for(let m=this.head;m;)p.push(t.call(u,m.value,this)),m=m.next;return p}mapReverse(t,u){u=u||this;var p=new s;for(let m=this.tail;m;)p.push(t.call(u,m.value,this)),m=m.prev;return p}reduce(t,u){let p,m=this.head;if(arguments.length>1)p=u;else if(this.head)m=this.head.next,p=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var g=0;m;g++)p=t(p,m.value,g),m=m.next;return p}reduceReverse(t,u){let p,m=this.tail;if(arguments.length>1)p=u;else if(this.tail)m=this.tail.prev,p=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let u=this.length-1;m;u--)p=t(p,m.value,u),m=m.prev;return p}toArray(){let t=new Array(this.length);for(let u=0,p=this.head;p;u++)t[u]=p.value,p=p.next;return t}toArrayReverse(){let t=new Array(this.length);for(let u=0,p=this.tail;p;u++)t[u]=p.value,p=p.prev;return t}slice(t=0,u=this.length){u<0&&(u+=this.length),t<0&&(t+=this.length);let p=new s;if(u<t||u<0)return p;t<0&&(t=0),u>this.length&&(u=this.length);let m=this.head,g=0;for(g=0;m&&g<t;g++)m=m.next;for(;m&&g<u;g++,m=m.next)p.push(m.value);return p}sliceReverse(t=0,u=this.length){u<0&&(u+=this.length),t<0&&(t+=this.length);let p=new s;if(u<t||u<0)return p;t<0&&(t=0),u>this.length&&(u=this.length);let m=this.length,g=this.tail;for(;g&&m>u;m--)g=g.prev;for(;g&&m>t;m--,g=g.prev)p.push(g.value);return p}splice(t,u=0,...p){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);let m=this.head;for(let u=0;m&&u<t;u++)m=m.next;let g=[];for(let t=0;m&&t<u;t++)g.push(m.value),m=this.removeNode(m);m?m!==this.tail&&(m=m.prev):m=this.tail;for(let t of p)m=Zn(this,m,t);return g}reverse(){let t=this.head,u=this.tail;for(let u=t;u;u=u.prev){let t=u.prev;u.prev=u.next,u.next=t}return this.head=u,this.tail=t,this}};function Zn(t,u,p){let m=u,g=u?u.next:t.head,v=new Ln(p,m,g,t);return v.next===void 0&&(t.tail=v),v.prev===void 0&&(t.head=v),t.length++,v}function Yn(t,u){t.tail=new Ln(u,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function Kn(t,u){t.head=new Ln(u,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Ln=class{list;next;prev;value;constructor(t,u,p,m){this.list=m,this.value=t,u?(u.next=this,this.prev=u):this.prev=void 0,p?(p.prev=this,this.next=p):this.next=void 0}};var Fn=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,u){this.path=t||"./",this.absolute=u}},Un=Buffer.alloc(1024),Hn=Symbol("onStat"),zn=Symbol("ended"),Wn=Symbol("queue"),Jn=Symbol("pendingLinks"),Qn=Symbol("current"),eo=Symbol("process"),to=Symbol("processing"),ro=Symbol("processJob"),ao=Symbol("jobs"),co=Symbol("jobDone"),uo=Symbol("addFSEntry"),ho=Symbol("addTarEntry"),fo=Symbol("stat"),vo=Symbol("readdir"),So=Symbol("onreaddir"),$o=Symbol("pipe"),Po=Symbol("entry"),xo=Symbol("entryOpt"),Oo=Symbol("writeEntryClass"),Ao=Symbol("write"),ko=Symbol("ondrain"),Co=class extends ir{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Oo];onWriteEntry;[Wn];[Jn]=new Map;[ao]=0;[to]=!1;[zn]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Vs(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Oo]=In,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new ys(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new $s(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Rs(t.zstd)),!this.zip)throw new Error("impossible");let u=this.zip;u.on("data",(t=>super.write(t))),u.on("end",(()=>super.end())),u.on("drain",(()=>this[ko]())),this.on("resume",(()=>u.resume()))}else this.on("drain",this[ko]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[Wn]=new jn,this[ao]=0,this.jobs=Number(t.jobs)||4,this[to]=!1,this[zn]=!1}[Ao](t){return super.write(t)}add(t){return this.write(t),this}end(t,u,p){return typeof t=="function"&&(p=t,t=void 0),typeof u=="function"&&(p=u,u=void 0),t&&this.add(t),this[zn]=!0,this[eo](),p&&p(),this}write(t){if(this[zn])throw new Error("write after end");return typeof t=="string"?this[uo](t):this[ho](t),this.flowing}[ho](t){let u=Vs(Ve.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let p=new Fn(t.path,u);p.entry=new Dn(t,this[xo](p)),p.entry.on("end",(()=>this[co](p))),this[ao]+=1,this[Wn].push(p)}this[eo]()}[uo](t){let u=Vs(Ve.resolve(this.cwd,t));this[Wn].push(new Fn(t,u)),this[eo]()}[fo](t){t.pending=!0,this[ao]+=1;let u=this.follow?"stat":"lstat";ze[u](t.absolute,((u,p)=>{t.pending=!1,this[ao]-=1,u?this.emit("error",u):this[Hn](t,p)}))}[Hn](t,u){if(this.statCache.set(t.absolute,u),t.stat=u,!this.filter(t.path,u))t.ignore=!0;else if(u.isFile()&&u.nlink>1&&!this.linkCache.get(`${u.dev}:${u.ino}`)&&!this.sync)if(t===this[Qn])this[ro](t);else{let p=`${u.dev}:${u.ino}`,m=this[Jn].get(p);m?m.push(t):this[Jn].set(p,[t]),t.pendingLink=!0,t.pending=!0}this[eo]()}[vo](t){t.pending=!0,this[ao]+=1,ze.readdir(t.absolute,((u,p)=>{if(t.pending=!1,this[ao]-=1,u)return this.emit("error",u);this[So](t,p)}))}[So](t,u){this.readdirCache.set(t.absolute,u),t.readdir=u,this[eo]()}[eo](){if(!this[to]){this[to]=!0;for(let t=this[Wn].head;t&&this[ao]<this.jobs;t=t.next)if(this[ro](t.value),t.value.ignore){let u=t.next;this[Wn].removeNode(t),t.next=u}this[to]=!1,this[zn]&&this[Wn].length===0&&this[ao]===0&&(this.zip?this.zip.end(Un):(super.write(Un),super.end()))}}get[Qn](){return this[Wn]&&this[Wn].head&&this[Wn].head.value}[co](t){this[Wn].shift(),this[ao]-=1;let{stat:u}=t;if(u&&u.isFile()&&u.nlink>1){let t=`${u.dev}:${u.ino}`,p=this[Jn].get(t);if(p){this[Jn].delete(t);for(let t of p)t.pending=!1,this[ro](t)}}this[eo]()}[ro](t){if(t.pending&&t.pendingLink&&t===this[Qn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[Qn]&&!t.piped&&this[$o](t);return}if(!t.stat){let u=this.statCache.get(t.absolute);u?this[Hn](t,u):this[fo](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let u=this.readdirCache.get(t.absolute);if(u?this[So](t,u):this[vo](t),!t.readdir)return}if(t.entry=this[Po](t),!t.entry){t.ignore=!0;return}t===this[Qn]&&!t.piped&&this[$o](t)}}}[xo](t){return{onwarn:(t,u,p)=>this.warn(t,u,p),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Po](t){this[ao]+=1;try{return new this[Oo](t.path,this[xo](t)).on("end",(()=>this[co](t))).on("error",(t=>this.emit("error",t)))}catch(t){this.emit("error",t)}}[ko](){this[Qn]&&this[Qn].entry&&this[Qn].entry.resume()}[$o](t){t.piped=!0,t.readdir&&t.readdir.forEach((u=>{let p=t.path,m=p==="./"?"":p.replace(/\/*$/,"/");this[uo](m+u)}));let u=t.entry,p=this.zip;if(!u)throw new Error("cannot pipe without source");p?u.on("data",(t=>{p.write(t)||u.pause()})):u.on("data",(t=>{super.write(t)||u.pause()}))}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,u,p={}){Dt(this,t,u,p)}},Io=class extends Co{sync=!0;constructor(t){super(t),this[Oo]=Nn}pause(){}resume(){}[fo](t){let u=this.follow?"statSync":"lstatSync";this[Hn](t,ze[u](t.absolute))}[vo](t){this[So](t,ze.readdirSync(t.absolute))}[$o](t){let u=t.entry,p=this.zip;if(t.readdir&&t.readdir.forEach((u=>{let p=t.path,m=p==="./"?"":p.replace(/\/*$/,"/");this[uo](m+u)})),!u)throw new Error("Cannot pipe without source");p?u.on("data",(t=>{p.write(t)})):u.on("data",(t=>{super[Ao](t)}))}};var Vn=(t,u)=>{let p=new Io(t),m=new ss(t.file,{mode:t.mode||438});p.pipe(m),fr(p,u)},$n=(t,u)=>{let p=new Co(t),m=new rs(t.file,{mode:t.mode||438});p.pipe(m);let g=new Promise(((t,u)=>{m.on("error",u),m.on("close",t),p.on("error",u)}));return dr(p,u).catch((t=>p.emit("error",t))),g},fr=(t,u)=>{u.forEach((u=>{u.charAt(0)==="@"?Di({file:T.resolve(t.cwd,u.slice(1)),sync:!0,noResume:!0,onReadEntry:u=>t.add(u)}):t.add(u)})),t.end()},dr=async(t,u)=>{for(let p of u)p.charAt(0)==="@"?await Di({file:T.resolve(String(t.cwd),p.slice(1)),noResume:!0,onReadEntry:u=>{t.add(u)}}):t.add(p);t.end()},Xn=(t,u)=>{let p=new Io(t);return fr(p,u),p},qn=(t,u)=>{let p=new Co(t);return dr(p,u).catch((t=>p.emit("error",t))),p},No=K(Vn,$n,Xn,qn,((t,u)=>{if(!u?.length)throw new TypeError("no paths specified to add to archive")}));var Do=process.env.__FAKE_PLATFORM__||process.platform,jo=Do==="win32",{O_CREAT:Lo,O_NOFOLLOW:Mo,O_TRUNC:Fo,O_WRONLY:Uo}=ze.constants,Bo=Number(process.env.__FAKE_FS_O_FILENAME__)||ze.constants.UV_FS_O_FILEMAP||0,Ho=jo&&!!Bo,zo=512*1024,Vo=Bo|Fo|Lo|Uo,Go=!jo&&typeof Mo=="number"?Mo|Fo|Lo|Uo:null,qo=Go!==null?()=>Go:Ho?t=>t<zo?Vo:"w":()=>"w";var ps=(t,u,p)=>{try{return k.lchownSync(t,u,p)}catch(t){if(t?.code!=="ENOENT")throw t}},Ei=(t,u,p,m)=>{k.lchown(t,u,p,(t=>{m(t&&t?.code!=="ENOENT"?t:null)}))},io=(t,u,p,m,g)=>{if(u.isDirectory())Es(T.resolve(t,u.name),p,m,(v=>{if(v)return g(v);let b=T.resolve(t,u.name);Ei(b,p,m,g)}));else{let v=T.resolve(t,u.name);Ei(v,p,m,g)}},Es=(t,u,p,m)=>{k.readdir(t,{withFileTypes:!0},((g,v)=>{if(g){if(g.code==="ENOENT")return m();if(g.code!=="ENOTDIR"&&g.code!=="ENOTSUP")return m(g)}if(g||!v.length)return Ei(t,u,p,m);let b=v.length,w=null,a=g=>{if(!w){if(g)return m(w=g);if(--b===0)return Ei(t,u,p,m)}};for(let m of v)io(t,m,u,p,a)}))},so=(t,u,p,m)=>{u.isDirectory()&&ws(T.resolve(t,u.name),p,m),ps(T.resolve(t,u.name),p,m)},ws=(t,u,p)=>{let m;try{m=k.readdirSync(t,{withFileTypes:!0})}catch(m){let g=m;if(g?.code==="ENOENT")return;if(g?.code==="ENOTDIR"||g?.code==="ENOTSUP")return ps(t,u,p);throw g}for(let g of m)so(t,g,u,p);return ps(t,u,p)};var Wo=class extends Error{path;code;syscall="chdir";constructor(t,u){super(`${u}: Cannot cd into '${t}'`),this.path=t,this.code=u}get name(){return"CwdError"}};var Ko=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,u){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=u}get name(){return"SymlinkError"}};var no=(t,u)=>{k.stat(t,((p,m)=>{(p||!m.isDirectory())&&(p=new Wo(t,p?.code||"ENOTDIR")),u(p)}))},gr=(t,u,p)=>{t=Vs(t);let m=u.umask??18,g=u.mode|448,v=(g&m)!==0,b=u.uid,w=u.gid,E=typeof b=="number"&&typeof w=="number"&&(b!==u.processUid||w!==u.processGid),S=u.preserve,$=u.unlink,P=Vs(u.cwd),y=(u,m)=>{u?p(u):m&&E?Es(m,b,w,(t=>y(t))):v?k.chmod(t,g,p):p()};if(t===P)return no(t,y);if(S)return yt.mkdir(t,{mode:g,recursive:!0}).then((t=>y(null,t??void 0)),y);let x=Vs(T.relative(P,t)).split("/");Ss(P,x,g,$,P,void 0,y)},Ss=(t,u,p,m,g,v,b)=>{if(u.length===0)return b(null,v);let w=u.shift(),E=Vs(T.resolve(t+"/"+w));k.mkdir(E,p,br(E,u,p,m,g,v,b))},br=(t,u,p,m,g,v,b)=>w=>{w?k.lstat(t,((E,S)=>{if(E)E.path=E.path&&Vs(E.path),b(E);else if(S.isDirectory())Ss(t,u,p,m,g,v,b);else if(m)k.unlink(t,(w=>{if(w)return b(w);k.mkdir(t,p,br(t,u,p,m,g,v,b))}));else{if(S.isSymbolicLink())return b(new Ko(t,t+"/"+u.join("/")));b(w)}})):(v=v||t,Ss(t,u,p,m,g,v,b))},oo=t=>{let u=!1,p;try{u=k.statSync(t).isDirectory()}catch(t){p=t?.code}finally{if(!u)throw new Wo(t,p??"ENOTDIR")}},_r=(t,u)=>{t=Vs(t);let p=u.umask??18,m=u.mode|448,g=(m&p)!==0,v=u.uid,b=u.gid,w=typeof v=="number"&&typeof b=="number"&&(v!==u.processUid||b!==u.processGid),E=u.preserve,S=u.unlink,$=Vs(u.cwd),d=u=>{u&&w&&ws(u,v,b),g&&k.chmodSync(t,m)};if(t===$)return oo($),d();if(E)return d(k.mkdirSync(t,{mode:m,recursive:!0})??void 0);let P=Vs(T.relative($,t)).split("/"),x;for(let t=P.shift(),u=$;t&&(u+="/"+t);t=P.shift()){u=Vs(T.resolve(u));try{k.mkdirSync(u,m),x=x||u}catch{let t=k.lstatSync(u);if(t.isDirectory())continue;if(S){k.unlinkSync(u),k.mkdirSync(u,m),x=x||u;continue}else if(t.isSymbolicLink())return new Ko(u,u+"/"+P.join("/"))}}return d(x)};var Yo=Object.create(null),Zo=1e4,Jo=new Set,Tr=t=>{Jo.has(t)?Jo.delete(t):Yo[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),Jo.add(t);let u=Yo[t],p=Jo.size-Zo;if(p>Zo/10){for(let t of Jo)if(Jo.delete(t),delete Yo[t],--p<=0)break}return u};var Xo=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Qo=Xo==="win32",lo=t=>t.split("/").slice(0,-1).reduce(((t,u)=>{let p=t.at(-1);return p!==void 0&&(u=(0,T.join)(p,u)),t.push(u||"/"),t}),[]),ea=class{#i=new Map;#n=new Map;#o=new Set;reserve(t,u){t=Qo?["win32 parallelization disabled"]:t.map((t=>mt((0,T.join)(Tr(t)))));let p=new Set(t.map((t=>lo(t))).reduce(((t,u)=>t.concat(u))));this.#n.set(u,{dirs:p,paths:t});for(let p of t){let t=this.#i.get(p);t?t.push(u):this.#i.set(p,[u])}for(let t of p){let p=this.#i.get(t);if(!p)this.#i.set(t,[new Set([u])]);else{let t=p.at(-1);t instanceof Set?t.add(u):p.push(new Set([u]))}}return this.#c(u)}#a(t){let u=this.#n.get(t);if(!u)throw new Error("function does not have any path reservations");return{paths:u.paths.map((t=>this.#i.get(t))),dirs:[...u.dirs].map((t=>this.#i.get(t)))}}check(t){let{paths:u,dirs:p}=this.#a(t);return u.every((u=>u&&u[0]===t))&&p.every((u=>u&&u[0]instanceof Set&&u[0].has(t)))}#c(t){return this.#o.has(t)||!this.check(t)?!1:(this.#o.add(t),t((()=>this.#l(t))),!0)}#l(t){if(!this.#o.has(t))return!1;let u=this.#n.get(t);if(!u)throw new Error("invalid reservation");let{paths:p,dirs:m}=u,g=new Set;for(let u of p){let p=this.#i.get(u);if(!p||p?.[0]!==t)continue;let m=p[1];if(!m){this.#i.delete(u);continue}if(p.shift(),typeof m=="function")g.add(m);else for(let t of m)g.add(t)}for(let u of m){let p=this.#i.get(u),m=p?.[0];if(!(!p||!(m instanceof Set)))if(m.size===1&&p.length===1){this.#i.delete(u);continue}else if(m.size===1){p.shift();let t=p[0];typeof t=="function"&&g.add(t)}else m.delete(t)}return this.#o.delete(t),g.forEach((t=>this.#c(t))),!0}};var Lr=()=>process.umask();var ta=Symbol("onEntry"),ra=Symbol("checkFs"),sa=Symbol("checkFs2"),ia=Symbol("isReusable"),na=Symbol("makeFs"),oa=Symbol("file"),aa=Symbol("directory"),ca=Symbol("link"),la=Symbol("symlink"),ua=Symbol("hardlink"),ha=Symbol("ensureNoSymlink"),da=Symbol("unsupported"),fa=Symbol("checkPath"),pa=Symbol("stripAbsolutePath"),ma=Symbol("mkdir"),ga=Symbol("onError"),ya=Symbol("pending"),va=Symbol("pend"),_a=Symbol("unpend"),ba=Symbol("ended"),wa=Symbol("maybeClose"),Ea=Symbol("skip"),Sa=Symbol("doChown"),$a=Symbol("uid"),Pa=Symbol("gid"),xa=Symbol("checkedCwd"),Ra=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Oa=Ra==="win32",Aa=1024,mo=(t,u)=>{if(!Oa)return k.unlink(t,u);let p=t+".DELETE."+(0,I.randomBytes)(16).toString("hex");k.rename(t,p,(t=>{if(t)return u(t);k.unlink(p,u)}))},po=t=>{if(!Oa)return k.unlinkSync(t);let u=t+".DELETE."+(0,I.randomBytes)(16).toString("hex");k.renameSync(t,u),k.unlinkSync(u)},vr=(t,u,p)=>t!==void 0&&t===t>>>0?t:u!==void 0&&u===u>>>0?u:p,ka=class extends Ni{[ba]=!1;[xa]=!1;[ya]=0;reservations=new ea;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[ba]=!0,this[wa]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?process.getuid?.()===0:!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Aa,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Oa,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Vs(T.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Lr():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",(t=>this[ta](t)))}warn(t,u,p={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(p.recoverable=!1),super.warn(t,u,p)}[wa](){this[ba]&&this[ya]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[pa](t,u){let p=t[u],{type:m}=t;if(!p||this.preservePaths)return!0;let[g,v]=ce(p),b=v.replaceAll(/\\/g,"/").split("/");if(b.includes("..")||Oa&&/^[a-z]:\.\.$/i.test(b[0]??"")){if(u==="path"||m==="Link")return this.warn("TAR_ENTRY_ERROR",`${u} contains '..'`,{entry:t,[u]:p}),!1;let g=T.posix.dirname(t.path),v=T.posix.normalize(T.posix.join(g,b.join("/")));if(v.startsWith("../")||v==="..")return this.warn("TAR_ENTRY_ERROR",`${u} escapes extraction directory`,{entry:t,[u]:p}),!1}return g&&(t[u]=String(v),this.warn("TAR_ENTRY_INFO",`stripping ${g} from absolute ${u}`,{entry:t,[u]:p})),!0}[fa](t){let u=Vs(t.path),p=u.split("/");if(this.strip){if(p.length<this.strip)return!1;if(t.type==="Link"){let u=Vs(String(t.linkpath)).split("/");if(u.length>=this.strip)t.linkpath=u.slice(this.strip).join("/");else return!1}p.splice(0,this.strip),t.path=p.join("/")}if(isFinite(this.maxDepth)&&p.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:u,depth:p.length,maxDepth:this.maxDepth}),!1;if(!this[pa](t,"path")||!this[pa](t,"linkpath"))return!1;if(t.absolute=T.isAbsolute(t.path)?Vs(T.resolve(t.path)):Vs(T.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Vs(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:u}=T.win32.parse(String(t.absolute));t.absolute=u+ts(String(t.absolute).slice(u.length));let{root:p}=T.win32.parse(t.path);t.path=p+ts(t.path.slice(p.length))}return!0}[ta](t){if(!this[fa](t))return t.resume();switch(N.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[ra](t);default:return this[da](t)}}[ga](t,u){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:u}),this[_a](),u.resume())}[ma](t,u,p){gr(Vs(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:u},p)}[Sa](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[$a](t){return vr(this.uid,t.uid,this.processUid)}[Pa](t){return vr(this.gid,t.gid,this.processGid)}[oa](t,u){let p=typeof t.mode=="number"?t.mode&4095:this.fmode,m=new rs(String(t.absolute),{flags:qo(t.size),mode:p,autoClose:!1});m.on("error",(p=>{m.fd&&k.close(m.fd,(()=>{})),m.write=()=>!0,this[ga](p,t),u()}));let g=1,o=p=>{if(p){m.fd&&k.close(m.fd,(()=>{})),this[ga](p,t),u();return}--g===0&&m.fd!==void 0&&k.close(m.fd,(p=>{p?this[ga](p,t):this[_a](),u()}))};m.on("finish",(()=>{let u=String(t.absolute),p=m.fd;if(typeof p=="number"&&t.mtime&&!this.noMtime){g++;let m=t.atime||new Date,v=t.mtime;k.futimes(p,m,v,(t=>t?k.utimes(u,m,v,(u=>o(u&&t))):o()))}if(typeof p=="number"&&this[Sa](t)){g++;let m=this[$a](t),v=this[Pa](t);typeof m=="number"&&typeof v=="number"&&k.fchown(p,m,v,(t=>t?k.chown(u,m,v,(u=>o(u&&t))):o()))}o()}));let v=this.transform&&this.transform(t)||t;v!==t&&(v.on("error",(p=>{this[ga](p,t),u()})),t.pipe(v)),v.pipe(m)}[aa](t,u){let p=typeof t.mode=="number"?t.mode&4095:this.dmode;this[ma](String(t.absolute),p,(p=>{if(p){this[ga](p,t),u();return}let m=1,o=()=>{--m===0&&(u(),this[_a](),t.resume())};t.mtime&&!this.noMtime&&(m++,k.utimes(String(t.absolute),t.atime||new Date,t.mtime,o)),this[Sa](t)&&(m++,k.chown(String(t.absolute),Number(this[$a](t)),Number(this[Pa](t)),o)),o()}))}[da](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[la](t,u){let p=Vs(T.relative(this.cwd,T.resolve(T.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[ha](t,this.cwd,p,(()=>this[ca](t,String(t.linkpath),"symlink",u)),(p=>{this[ga](p,t),u()}))}[ua](t,u){let p=Vs(T.resolve(this.cwd,String(t.linkpath))),m=Vs(String(t.linkpath)).split("/");this[ha](t,this.cwd,m,(()=>this[ca](t,p,"link",u)),(p=>{this[ga](p,t),u()}))}[ha](t,u,p,m,g){let v=p.shift();if(this.preservePaths||v===void 0)return m();let b=T.resolve(u,v);k.lstat(b,((u,v)=>{if(u)return m();if(v?.isSymbolicLink())return g(new Ko(b,T.resolve(b,p.join("/"))));this[ha](t,b,p,m,g)}))}[va](){this[ya]++}[_a](){this[ya]--,this[wa]()}[Ea](t){this[_a](),t.resume()}[ia](t,u){return t.type==="File"&&!this.unlink&&u.isFile()&&u.nlink<=1&&!Oa}[ra](t){this[va]();let u=[t.path];t.linkpath&&u.push(t.linkpath),this.reservations.reserve(u,(u=>this[sa](t,u)))}[sa](t,u){let i=t=>{u(t)},r=()=>{this[ma](this.cwd,this.dmode,(u=>{if(u){this[ga](u,t),i();return}this[xa]=!0,n()}))},n=()=>{if(t.absolute!==this.cwd){let u=Vs(T.dirname(String(t.absolute)));if(u!==this.cwd)return this[ma](u,this.dmode,(u=>{if(u){this[ga](u,t),i();return}o()}))}o()},o=()=>{k.lstat(String(t.absolute),((u,p)=>{if(p&&(this.keep||this.newer&&p.mtime>(t.mtime??p.mtime))){this[Ea](t),i();return}if(u||this[ia](t,p))return this[na](null,t,i);if(p.isDirectory()){if(t.type==="Directory"){let u=this.chmod&&t.mode&&(p.mode&4095)!==t.mode,c=u=>this[na](u??null,t,i);return u?k.chmod(String(t.absolute),Number(t.mode),c):c()}if(t.absolute!==this.cwd)return k.rmdir(String(t.absolute),(u=>this[na](u??null,t,i)))}if(t.absolute===this.cwd)return this[na](null,t,i);mo(String(t.absolute),(u=>this[na](u??null,t,i)))}))};this[xa]?n():r()}[na](t,u,p){if(t){this[ga](t,u),p();return}switch(u.type){case"File":case"OldFile":case"ContiguousFile":return this[oa](u,p);case"Link":return this[ua](u,p);case"SymbolicLink":return this[la](u,p);case"Directory":case"GNUDumpDir":return this[aa](u,p)}}[ca](t,u,p,m){k[p](u,String(t.absolute),(u=>{u?this[ga](u,t):(this[_a](),t.resume()),m()}))}},ye=t=>{try{return[null,t()]}catch(t){return[t,null]}},Ta=class extends ka{sync=!0;[na](t,u){return super[na](t,u,(()=>{}))}[ra](t){if(!this[xa]){let u=this[ma](this.cwd,this.dmode);if(u)return this[ga](u,t);this[xa]=!0}if(t.absolute!==this.cwd){let u=Vs(T.dirname(String(t.absolute)));if(u!==this.cwd){let p=this[ma](u,this.dmode);if(p)return this[ga](p,t)}}let[u,p]=ye((()=>k.lstatSync(String(t.absolute))));if(p&&(this.keep||this.newer&&p.mtime>(t.mtime??p.mtime)))return this[Ea](t);if(u||this[ia](t,p))return this[na](null,t);if(p.isDirectory()){if(t.type==="Directory"){let u=this.chmod&&t.mode&&(p.mode&4095)!==t.mode,[m]=u?ye((()=>{k.chmodSync(String(t.absolute),Number(t.mode))})):[];return this[na](m,t)}let[u]=ye((()=>k.rmdirSync(String(t.absolute))));this[na](u,t)}let[m]=t.absolute===this.cwd?[]:ye((()=>po(String(t.absolute))));this[na](m,t)}[oa](t,u){let p=typeof t.mode=="number"?t.mode&4095:this.fmode,r=p=>{let g;try{k.closeSync(m)}catch(t){g=t}(p||g)&&this[ga](p||g,t),u()},m;try{m=k.openSync(String(t.absolute),qo(t.size),p)}catch(t){return r(t)}let g=this.transform&&this.transform(t)||t;g!==t&&(g.on("error",(u=>this[ga](u,t))),t.pipe(g)),g.on("data",(t=>{try{k.writeSync(m,t,0,t.length)}catch(t){r(t)}})),g.on("end",(()=>{let u=null;if(t.mtime&&!this.noMtime){let p=t.atime||new Date,g=t.mtime;try{k.futimesSync(m,p,g)}catch(m){try{k.utimesSync(String(t.absolute),p,g)}catch{u=m}}}if(this[Sa](t)){let p=this[$a](t),g=this[Pa](t);try{k.fchownSync(m,Number(p),Number(g))}catch(m){try{k.chownSync(String(t.absolute),Number(p),Number(g))}catch{u=u||m}}}r(u)}))}[aa](t,u){let p=typeof t.mode=="number"?t.mode&4095:this.dmode,m=this[ma](String(t.absolute),p);if(m){this[ga](m,t),u();return}if(t.mtime&&!this.noMtime)try{k.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Sa](t))try{k.chownSync(String(t.absolute),Number(this[$a](t)),Number(this[Pa](t)))}catch{}u(),t.resume()}[ma](t,u){try{return _r(Vs(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:u})}catch(t){return t}}[ha](t,u,p,m,g){if(this.preservePaths||p.length===0)return m();let v=u;for(let t of p){v=T.resolve(v,t);let[b,w]=ye((()=>k.lstatSync(v)));if(b)return m();if(w.isSymbolicLink())return g(new Ko(v,T.resolve(u,p.join("/"))))}m()}[ca](t,u,p,m){let g=`${p}Sync`;try{k[g](u,String(t.absolute)),m(),t.resume()}catch(u){return this[ga](u,t)}}};var Eo=t=>{let u=new Ta(t),p=t.file,m=k.statSync(p),g=t.maxReadSize||16*1024*1024;new es(p,{readSize:g,size:m.size}).pipe(u)},wo=(t,u)=>{let p=new ka(t),m=t.maxReadSize||16*1024*1024,g=t.file;return new Promise(((t,u)=>{p.on("error",u),p.on("close",t),k.stat(g,((t,v)=>{if(t)u(t);else{let t=new Qr(g,{readSize:m,size:v.size});t.on("error",u),t.pipe(p)}}))}))},Ca=K(Eo,wo,(t=>new Ta(t)),(t=>new ka(t)),((t,u)=>{u?.length&&Qi(t,u)}));var yo=(t,u)=>{let p=new Io(t),m=!0,g,v;try{try{g=k.openSync(t.file,"r+")}catch(u){if(u?.code==="ENOENT")g=k.openSync(t.file,"w+");else throw u}let b=k.fstatSync(g),w=Buffer.alloc(512);e:for(v=0;v<b.size;v+=512){for(let t=0,u=0;t<512;t+=u){if(u=k.readSync(g,w,t,w.length-t,v+t),v===0&&w[0]===31&&w[1]===139)throw new Error("cannot append to compressed archives");if(!u)break e}let u=new Ns(w);if(!u.cksumValid)break;let p=512*Math.ceil((u.size||0)/512);if(v+p+512>b.size)break;v+=p,t.mtimeCache&&u.mtime&&t.mtimeCache.set(String(u.path),u.mtime)}m=!1,Ro(t,p,v,g,u)}finally{if(m)try{k.closeSync(g)}catch{}}},Ro=(t,u,p,m,g)=>{let v=new ss(t.file,{fd:m,start:p});u.pipe(v),bo(u,g)},go=(t,u)=>{u=Array.from(u);let p=new Co(t),i=(u,p,m)=>{let a=(t,p)=>{t?k.close(u,(u=>m(t))):m(null,p)},g=0;if(p===0)return a(null,0);let v=0,b=Buffer.alloc(512),y=(m,w)=>{if(m||w===void 0)return a(m);if(v+=w,v<512&&w)return k.read(u,b,v,b.length-v,g+v,y);if(g===0&&b[0]===31&&b[1]===139)return a(new Error("cannot append to compressed archives"));if(v<512)return a(null,g);let E=new Ns(b);if(!E.cksumValid)return a(null,g);let S=512*Math.ceil((E.size??0)/512);if(g+S+512>p||(g+=S+512,g>=p))return a(null,g);t.mtimeCache&&E.mtime&&t.mtimeCache.set(String(E.path),E.mtime),v=0,k.read(u,b,0,512,g,y)};k.read(u,b,0,512,g,y)};return new Promise(((m,g)=>{p.on("error",g);let v="r+",a=(b,w)=>{if(b&&b.code==="ENOENT"&&v==="r+")return v="w+",k.open(t.file,v,a);if(b||!w)return g(b);k.fstat(w,((v,b)=>{if(v)return k.close(w,(()=>g(v)));i(w,b.size,((v,b)=>{if(v)return g(v);let E=new rs(t.file,{fd:w,start:b});p.pipe(E),E.on("error",g),E.on("close",m),_o(p,u)}))}))};k.open(t.file,v,a)}))},bo=(t,u)=>{u.forEach((u=>{u.charAt(0)==="@"?Di({file:T.resolve(t.cwd,u.slice(1)),sync:!0,noResume:!0,onReadEntry:u=>t.add(u)}):t.add(u)})),t.end()},_o=async(t,u)=>{for(let p of u)p.charAt(0)==="@"?await Di({file:T.resolve(String(t.cwd),p.slice(1)),noResume:!0,onReadEntry:u=>t.add(u)}):t.add(p);t.end()},Ia=K(yo,go,(()=>{throw new TypeError("file is required")}),(()=>{throw new TypeError("file is required")}),((t,u)=>{if(!Bs(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!u?.length)throw new TypeError("no paths specified to add/replace")}));var Na=K(Ia.syncFile,Ia.asyncFile,Ia.syncNoFile,Ia.asyncNoFile,((t,u=[])=>{Ia.validate?.(t,u),To(t)})),To=t=>{let u=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=u?(p,m)=>u(p,m)&&!((t.mtimeCache?.get(p)??m.mtime??0)>(m.mtime??0)):(u,p)=>!((t.mtimeCache?.get(u)??p.mtime??0)>(p.mtime??0))};const Da="none";const ja=[{title:"Claude Code",value:"claude",description:"CLAUDE.md, .claude/, .mcp.json"},{title:"GitHub Copilot",value:"copilot",description:".github/copilot-instructions.md, .mcp.json"},{title:"Cursor",value:"cursor",description:".cursorrules, .mcp.json"},{title:"Windsurf",value:"windsurf",description:".windsurfrules, .mcp.json"},{title:"OpenAI Codex",value:"codex",description:"AGENTS.md, .mcp.json"},{title:"None",value:Da,description:"Skip AI agent setup"}];function resolveAgentSelection(t){if(t.includes(Da)){return[]}return t}const La="https://codeload.github.com/zuplo/tools/tar.gz/main";const Ma={claude:".claude/skills",copilot:".agents/skills",cursor:".cursor/skills",windsurf:".windsurf/skills",codex:".agents/skills"};const Fa={claude:"CLAUDE.md",copilot:".github/copilot-instructions.md",cursor:".cursorrules",windsurf:".windsurfrules",codex:"AGENTS.md"};function getSharedInstructions(){return`## Project Overview\n\nThis is a Zuplo API gateway project with an accompanying Zudoku-based developer portal.\n\n## Commands\n\n- **Dev server:** \`npm run dev\` (runs on http://localhost:9000)\n- **Run tests:** \`npm run test\`\n- **Typecheck:** \`npm run typecheck\`\n- **Dev portal:** \`npm run docs\`\n\n## Architecture\n\n- **\`config/routes.oas.json\`** — OpenAPI 3.1 route definitions. Each operation uses \`x-zuplo-route\` to configure handlers (e.g., \`urlForwardHandler\`) and policies. This is the primary file for defining API routes.\n- **\`config/policies.json\`** — Policy configurations applied to routes (e.g., \`MockApiInboundPolicy\`).\n- **\`modules/\`** — Custom TypeScript request handlers. Handlers receive \`(ZuploRequest, ZuploContext)\` and return a \`Response\` or serializable value.\n- **\`docs/\`** — Zudoku developer portal (separate workspace). Config is in \`docs/zudoku.config.tsx\`. Reads the OpenAPI spec from \`../config/routes.oas.json\`.\n- **\`zuplo.jsonc\`** — Zuplo project configuration (version, compatibility date).\n\n## Key Patterns\n\n- Routes are configured declaratively in \`config/routes.oas.json\`, not in code. Custom logic goes in \`modules/\` and is referenced via \`x-zuplo-route.handler\`.\n- The project uses ESM (\`"type": "module"\`) with TypeScript targeting ES2022.\n- Environment variables are defined in \`.env\` (gitignored). See \`.env.example\` for available vars.`}function getLocalDocsSection(){return`## Local Documentation (node_modules)\n\nFull markdown documentation is bundled in node_modules and can be read directly:\n\n- **Zuplo docs:** \`node_modules/zuplo/docs/\` — includes docs on policies (\`policies/\`), handlers (\`handlers/\`), CLI (\`cli/\`), dev portal (\`dev-portal/\`), guides, and articles.\n- **Zuplo policy configs:** \`node_modules/zuplo/docs/policies/\` — each policy has its own folder with full configuration docs. Reference these when adding or configuring policies in \`config/policies.json\`.\n- **Zudoku docs:** \`docs/node_modules/zudoku/docs/\` — configuration, components, customization, plugins, and deployment docs for the developer portal.`}function getGenericInstructions(){return`${getSharedInstructions()}\n\n${getLocalDocsSection()}\n`}function getClaudeMd(){return`# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n${getSharedInstructions()}\n\n## Available Tools and Documentation\n\n### MCP Tools\n\n- **Zuplo Docs MCP** (configured in \`.mcp.json\`) — search Zuplo documentation via \`mcp__zuplo_docs__ask-question-about-zuplo\` and \`mcp__zuplo_docs__search-zuplo-docs\`.\n- **Zuplo Skills** — installed skills for working with Zuplo projects: \`zuplo-guide\`, \`zuplo-project-setup\`, \`zuplo-policies\`, \`zuplo-handlers\`, \`zuplo-monetization\`, \`zuplo-cli\`, and \`zudoku-guide\`.\n\n${getLocalDocsSection()}\n`}function getClaudeSettings(){return JSON.stringify({enabledPlugins:{"zudoku-skills@zuplo-tools":true,"zuplo-skills@zuplo-tools":true},extraKnownMarketplaces:{"zuplo-tools":{source:{source:"github",repo:"zuplo/tools"}}},enableAllProjectMcpServers:true},null,2)}function getMcpJson(){return JSON.stringify({mcpServers:{zuplo_docs:{type:"http",url:"https://dev.zuplo.com/mcp/docs"}}},null,2)}async function agents_writeFile(t,u){await et().mkdir(Ge().dirname(t),{recursive:true});await et().writeFile(t,u+rt().EOL,"utf-8")}async function downloadSkillsToTmp(){const t=await et().mkdtemp(Ge().join(rt().tmpdir(),"zuplo-skills-"));const u=await fetch(La);if(!u.body){throw new Error("Failed to download zuplo/tools tarball")}const p=u.body;const m=st.Readable.fromWeb(p);let g=0;const v=new st.Transform({transform(t,u,p){g+=t.length;if(g>10*1024*1024){return p(new Error("Download too large"))}p(null,t)}});await(0,it.pipeline)(m.pipe(v),Ca({cwd:t,strip:1,filter:t=>/\/skills\/[^/]+\/SKILL\.md$/.test(t)}));return t}async function installSkills(t,u){const p=await downloadSkillsToTmp();try{const m=Ge().join(p,"skills");let g;try{g=await et().readdir(m)}catch{throw new Error("No skills found in zuplo/tools tarball")}for(const p of u){const u=Ma[p];for(const p of g){const g=Ge().join(m,p,"SKILL.md");try{const m=await et().readFile(g,"utf-8");await agents_writeFile(Ge().join(t,u,p,"SKILL.md"),m)}catch{}}}}finally{await et().rm(p,{recursive:true,force:true})}}async function installAgentConfigs(t,u){if(u.length>0){await agents_writeFile(Ge().join(t,".mcp.json"),getMcpJson())}for(const p of u){if(p==="claude"){await agents_writeFile(Ge().join(t,".claude","settings.json"),getClaudeSettings());await agents_writeFile(Ge().join(t,"CLAUDE.md"),getClaudeMd())}else{await agents_writeFile(Ge().join(t,Fa[p]),getGenericInstructions())}}const p=u.filter((t=>t!=="claude"));if(p.length>0){try{console.log("Installing Zuplo agent skills...");await installSkills(t,p)}catch{console.log("Failed to download agent skills. You can install them later with:");console.log(" npx skills add zuplo/tools")}}}async function isUrlOk(t){try{const u=await fetch(t,{method:"HEAD"});return u.status===200}catch{return false}}async function getRepoInfo(t,u){const[,p,m,g,v,...b]=t.pathname.split("/");const w=u?u.replace(/^\//,""):b.join("/");if(g===undefined||g===""&&v===undefined){try{const t=await fetch(`https://api.github.com/repos/${p}/${m}`);if(t.status!==200){return}const u=await t.json();return{username:p,name:m,branch:u["default_branch"],filePath:w}}catch{return}}const E=u?`${v}/${b.join("/")}`.replace(new RegExp(`/${w}|/$`),""):v;if(p&&m&&E&&g==="tree"){return{username:p,name:m,branch:E,filePath:w}}}function hasRepo({username:t,name:u,branch:p,filePath:m}){const g=`https://api.github.com/repos/${t}/${u}/contents`;const v=`${m?`/${m}`:""}/package.json`;return isUrlOk(`${g+v}?ref=${p}`)}function existsInRepo(t){try{const u=new URL(t);return isUrlOk(u.href)}catch{return isUrlOk(`https://api.github.com/repos/zuplo/zuplo/contents/examples/${encodeURIComponent(t)}`)}}async function downloadTarStream(t,u=50*1024*1024){const p=await fetch(t);if(!p.body){throw new Error(`Failed to download: ${t}`)}const m=p.headers.get("content-length");if(m&&parseInt(m,10)>u){throw new Error(`File too large! ${m} bytes exceeds limit of ${u} bytes`)}const g=p.body;const v=st.Readable.fromWeb(g);let b=0;const w=new st.Transform({transform(t,p,m){b+=t.length;if(b>u){return m(new Error(`Download aborted! File size exceeded ${u} bytes`))}m(null,t)}});return v.pipe(w)}async function downloadAndExtractRepo(t,{username:u,name:p,branch:m,filePath:g},v){const b=`https://codeload.github.com/${u}/${p}/tar.gz/${m}`;if(v){console.log(`Downloading repo from ${b}`)}let w=null;await(0,it.pipeline)(await downloadTarStream(b),Ca({cwd:t,strip:g?g.split("/").length+1:1,filter:t=>{if(w===null){const u=t.split(Ve.sep);w=u.length?u[0]:null}return t.startsWith(`${w}${g?`/${g}/`:"/"}`)}}))}async function downloadAndExtractExample(t,u,p){if(u==="__internal-testing-retry"){throw new Error("This is an internal example for testing the CLI.")}const m="https://codeload.github.com/zuplo/zuplo/tar.gz/main";if(p){console.log(`Downloading example from ${m}`)}await(0,it.pipeline)(await downloadTarStream(m),Ca({cwd:t,strip:2+u.split("/").length,filter:t=>t.includes(`zuplo-main/examples/${u}/`)}))}var Ua=__nccwpck_require__(5317);function isInGitRepository(){try{(0,Ua.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch{}return false}function isInMercurialRepository(){try{(0,Ua.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch{}return false}function isDefaultBranchSet(){try{(0,Ua.execSync)("git config init.defaultBranch",{stdio:"ignore"});return true}catch{}return false}function tryGitInit(t,u){let p=false;const m=u?"inherit":"ignore";try{(0,Ua.execSync)("git --version",{stdio:m});if(isInGitRepository()||isInMercurialRepository()){return false}(0,Ua.execSync)("git init",{stdio:m});p=true;if(!isDefaultBranchSet()){(0,Ua.execSync)("git checkout -b main",{stdio:m})}(0,Ua.execSync)("git add -A",{stdio:m});(0,Ua.execSync)('git commit -m "Initial commit from create-zuplo-api"',{stdio:m});return true}catch(m){if(u){console.error("Git init failed:",m)}if(p){try{(0,ze.rmSync)((0,Ve.join)(t,".git"),{recursive:true,force:true})}catch{}}return false}}var Ba=__nccwpck_require__(4791);var Ha=__nccwpck_require__.n(Ba);async function install(t,u,p){const m=["install"];if(!u){console.log((0,qe.yellow)("You appear to be offline.\nFalling back to the local cache."));m.push("--offline")}else if(t==="npm"){m.push("--no-audit");m.push("--no-fund")}if(p){m.push("--verbose")}return new Promise(((u,p)=>{const g=Ha()(t,m,{stdio:"inherit",env:{...process.env,ADBLOCK:"1",NODE_ENV:"development",DISABLE_OPENCOLLECTIVE:"1"}});g.on("close",(g=>{if(g!==0){p({command:`${t} ${m.join(" ")}`});return}u()}))}))}function isFolderEmpty(t,u){const p=[".DS_Store",".git",".gitattributes",".gitignore",".gitlab-ci.yml",".hg",".hgcheck",".hgignore",".idea",".npmignore",".travis.yml","LICENSE","Thumbs.db","docs","mkdocs.yml","npm-debug.log","yarn-debug.log","yarn-error.log","yarnrc.yml",".yarn"];const m=(0,ze.readdirSync)(t).filter((t=>!p.includes(t)&&!/\.iml$/.test(t)));if(m.length>0){console.log(`The directory ${(0,qe.green)(u)} contains files that could conflict:`);console.log();for(const u of m){try{const p=(0,ze.lstatSync)((0,Ve.join)(t,u));if(p.isDirectory()){console.log(` ${(0,qe.blue)(u)}/`)}else{console.log(` ${u}`)}}catch{console.log(` ${u}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}const za=require("dns/promises");var Va=__nccwpck_require__(7016);var Ga=__nccwpck_require__.n(Va);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const t=(0,Ua.execSync)("npm config get https-proxy").toString().trim();return t!=="null"?t:undefined}catch{return}}async function getOnline(){try{await(0,za.lookup)("registry.yarnpkg.com");return true}catch{const t=getProxy();if(!t){return false}const{hostname:u}=Ga().parse(t);if(!u){return false}try{await(0,za.lookup)(u);return true}catch{return false}}}const qa=require("constants");async function isWriteable(t){try{await(0,Qe.access)(t,qa.W_OK);return true}catch{return false}}function unquote(t){if(t.length<2){return t}const u=t[0];const p=t[t.length-1];if(u==='"'&&p==='"'||u==="'"&&p==="'"){return t.slice(1,-1)}return t}function extractEnvValue(t,u){const p=new RegExp(`^${u}=(.*)$`,"m").exec(t);if(!p){return undefined}const m=unquote(p[1].trim());return m.length>0?m:undefined}function readLinkedConfig(t){try{const u=(0,ze.readFileSync)((0,Ve.join)(t,".env.zuplo"),"utf-8");const p=extractEnvValue(u,"ZUPLO_ACCOUNT_NAME");const m=extractEnvValue(u,"ZUPLO_PROJECT_NAME");if(!p||!m){return undefined}return{account:p,project:m}}catch{return undefined}}function getZuploAuthFilePath(){var t;const u=(t=process.env.XDG_DATA_HOME)!==null&&t!==void 0?t:(0,Ve.join)((0,tt.homedir)(),".local","state");return(0,Ve.join)(u,"zuplo","auth.json")}function getZuploDeveloperApiEndpoint(){var t;return(t=process.env.ZUPLO_DEVELOPER_API_ENDPOINT)!==null&&t!==void 0?t:"https://dev.zuplo.com"}function readZuploAccessToken(){try{const t=getZuploAuthFilePath();if(!(0,ze.existsSync)(t)){return undefined}const u=(0,ze.readFileSync)(t,"utf-8");const p=JSON.parse(u);return typeof p.access_token==="string"?p.access_token:undefined}catch{return undefined}}async function fetchZuploAccountNames(t){try{const u=await fetch(`${getZuploDeveloperApiEndpoint()}/v1/accounts`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});if(!u.ok){return undefined}const p=await u.json();if(!Array.isArray(p.data)){return undefined}return p.data.map((t=>typeof(t===null||t===void 0?void 0:t.name)==="string"?t.name:undefined)).filter((t=>typeof t==="string")).sort(((t,u)=>t.localeCompare(u)))}catch{return undefined}}async function probeProjectDeployments(t,u,p){try{const m=`${getZuploDeveloperApiEndpoint()}/v1/accounts/${encodeURIComponent(u)}/projects/${encodeURIComponent(p)}/deployments`;const g=await fetch(m,{method:"GET",headers:{Authorization:`Bearer ${t}`}});if(!g.ok){return{exists:false,soleWorkingCopy:undefined}}const v=await g.json();if(!Array.isArray(v.data)){return{exists:true,soleWorkingCopy:undefined}}const b=v.data.filter((t=>(t===null||t===void 0?void 0:t.environmentType)==="WORKING_COPY")).map((t=>typeof(t===null||t===void 0?void 0:t.name)==="string"?t.name:undefined)).filter((t=>typeof t==="string"));return{exists:true,soleWorkingCopy:b.length===1?b[0]:undefined}}catch{return{exists:false,soleWorkingCopy:undefined}}}async function fetchSoleWorkingCopyName(t,u,p){const m=await probeProjectDeployments(t,u,p);return m.soleWorkingCopy}async function findAccountWithProject(t,u,p){for(const m of u){const u=await probeProjectDeployments(t,m,p);if(u.exists){return{account:m,soleWorkingCopy:u.soleWorkingCopy}}}return undefined}const defaultRunZuplo=t=>new Promise(((u,p)=>{const m=process.platform==="win32"?"npx.cmd":"npx";const g=(0,Ua.spawn)(m,["zuplo",...t],{stdio:"inherit"});g.on("close",((m,g)=>{if(m===0){u();return}let v;if(m!==null&&m!==undefined){v=`exited with code ${m}`}else if(g){v=`was terminated by signal ${g}`}else{v="exited unsuccessfully"}p(new Error(`"zuplo ${t.join(" ")}" ${v}.`))}));g.on("error",p)}));const defaultPromptForAccount=async t=>{const u=await Ke()({type:"select",name:"account",message:"Which Zuplo account should host this project?",choices:t.map((t=>({title:t,value:t}))),onState:t=>{if(t.aborted){process.stdout.write("[?25h");process.stdout.write("\n");process.exit(1)}}});return typeof u.account==="string"?u.account:undefined};const Wa={readToken:readZuploAccessToken,fetchAccounts:fetchZuploAccountNames,fetchWorkingCopy:fetchSoleWorkingCopyName,findAccountWithProject:findAccountWithProject,readLinked:readLinkedConfig,runZuplo:defaultRunZuplo,promptForAccount:defaultPromptForAccount};async function createAndLinkServerProject(t,u=Wa){const{appPath:p,appName:m,account:g,skipPrompts:v}=t;let b=(g===null||g===void 0?void 0:g.trim())||undefined;if(!b){const t=u.readToken();const p=t?await u.fetchAccounts(t):undefined;if(p&&p.length===1){b=p[0];console.log();console.log(`Using Zuplo account ${(0,qe.cyan)(`'${b}'`)}.`)}else if(v){console.log();console.log(`${(0,qe.yellow)("Note:")} Skipping server-project setup in non-interactive mode.`);console.log(`Pass ${(0,qe.cyan)("--account <name>")} to create a server project, or ${(0,qe.cyan)("--no-server-project")} to silence this note.`);return undefined}else if(p&&p.length>1){b=await u.promptForAccount(p)}}console.log();console.log("Creating your project on portal.zuplo.com...");console.log();const w=["project","create","--name",m];if(b){w.push("--account",b)}try{await u.runZuplo(w)}catch{console.log();console.log(`${(0,qe.yellow)("Note:")} Failed to create the server project. Your local files are ready.`);console.log(`You can finish setup later by running ${(0,qe.cyan)(`zuplo project create --name ${m}`)} and ${(0,qe.cyan)(`zuplo link`)} from inside your project directory.`);return undefined}console.log();console.log("Linking your working copy to the server project...");console.log();const E=["link","--dir",p,"--project",m];let S;if(!b){const t=u.readToken();if(t){const p=await u.fetchAccounts(t);if(p&&p.length===1){b=p[0]}else if(p&&p.length>1){const g=await u.findAccountWithProject(t,p,m);if(g){b=g.account;S=g.soleWorkingCopy}}}}if(b){E.push("--account",b)}if(b){if(S){E.push("--environment",S)}else{const t=u.readToken();if(t){const p=await u.fetchWorkingCopy(t,b,m);if(p){E.push("--environment",p)}}}}try{await u.runZuplo(E)}catch{console.log();console.log(`${(0,qe.yellow)("Note:")} The server project was created but linking failed.`);console.log(`You can finish setup later by running ${(0,qe.cyan)(`zuplo link`)} from inside your project directory.`);return undefined}return u.readLinked(p)}const Ka=JSON.parse('{"aC":"70b476fc2524c3c2ce0cc10ad5f91837a7aefceefb088542390c02754238693d"}');const Ya={rE:"7.10.0"};function gatewayProvenance(t=Ya.rE){return`${JSON.stringify({formatVersion:1,template:"ai-gateway",origin:{revision:Ka.aC,release:t},appliedSteps:[]},null,2)}\n`}var Za=__nccwpck_require__(4761);const identity=t=>t;const copy=async(t,u,{cwd:p,rename:m=identity,parents:g=true,verbose:v=false}={})=>{const b=typeof t==="string"?[t]:t;if(b.length===0||!u){throw new TypeError("`src` and `dest` are required")}const w=await(0,Za.async)(b,{cwd:p,dot:true,absolute:false,stats:false});const E=p?(0,Ve.resolve)(p,u):u;return Promise.all(w.map((async t=>{const u=(0,Ve.dirname)(t);const b=m((0,Ve.basename)(t),t);const w=p?(0,Ve.resolve)(p,t):t;const S=g?(0,Ve.join)(E,u,b):(0,Ve.join)(E,b);await(0,Qe.mkdir)((0,Ve.dirname)(S),{recursive:true});if(v){console.log(`Copying ${w} to ${S}`)}return(0,Qe.copyFile)(w,S)})))};const Ja=["eslint","biome","oxlint","none"];const Xa=["prettier","biome","oxfmt","none"];function isLinter(t){return Ja.includes(t)}function isFormatter(t){return Xa.includes(t)}const Qa=[{title:"ESLint",value:"eslint",description:"The most widely used JavaScript/TypeScript linter"},{title:"Biome",value:"biome",description:"Fast Rust-based linter (can also format)"},{title:"Oxlint",value:"oxlint",description:"Fast Rust-based linter from the Oxc project"},{title:"None",value:"none",description:"Skip linter setup"}];const ec=[{title:"Prettier",value:"prettier",description:"The most widely used code formatter"},{title:"Biome",value:"biome",description:"Fast Rust-based formatter (can also lint)"},{title:"Oxfmt",value:"oxfmt",description:"Fast Rust-based, Prettier-compatible formatter (beta)"},{title:"None",value:"none",description:"Skip formatter setup"}];function resolveLinterFromLegacyFlags({eslint:t,noEslint:u}){if(t)return"eslint";if(u)return"none";return undefined}function resolveFormatterFromLegacyFlags({prettier:t,noPrettier:u}){if(t)return"prettier";if(u)return"none";return undefined}function migrateLegacyLintPreferences(t){if(t.linter===undefined&&typeof t.eslint==="boolean"){t.linter=t.eslint?"eslint":"none"}if(t.formatter===undefined&&typeof t.prettier==="boolean"){t.formatter=t.prettier?"prettier":"none"}delete t.eslint;delete t.prettier}function eslintConfig(t){const u=[`import js from "@eslint/js";`,`import { defineConfig } from "eslint/config";`,...t?[`import prettier from "eslint-config-prettier/flat";`]:[],`import tseslint from "typescript-eslint";`,``,`export default defineConfig(`,` js.configs.recommended,`,` tseslint.configs.recommended,`,...t?[` prettier,`]:[],`);`,``];return u.join(rt().EOL)}function biomeConfig({lint:t,format:u}){return JSON.stringify({$schema:"https://biomejs.dev/schemas/2.5.3/schema.json",vcs:{enabled:true,clientKind:"git",useIgnoreFile:true},files:{ignoreUnknown:true},linter:{enabled:t,rules:{preset:"recommended"}},formatter:u?{enabled:true,indentStyle:"space"}:{enabled:false},assist:{enabled:true,actions:{source:{organizeImports:"on"}}}},null,2)+rt().EOL}function oxlintConfig(){return JSON.stringify({$schema:"./node_modules/oxlint/configuration_schema.json",categories:{correctness:"error"}},null,2)+rt().EOL}function prettierConfig(){return JSON.stringify({overrides:[{files:"*.jsonc",options:{trailingComma:"none"}}]},null,2)+rt().EOL}function oxfmtConfig(){return[`{`,` "$schema": "./node_modules/oxfmt/configuration_schema.json",`,` "printWidth": 80,`,` "overrides": [`,` {`,` "files": ["*.jsonc"],`,` "options": {`,` "trailingComma": "none"`,` }`,` }`,` ]`,`}`,``].join(rt().EOL)}function buildLintFormatSetup(t,u){const p={};const m={};const g={};const v=[];switch(t){case"eslint":{p.lint="eslint";p["lint:fix"]="eslint --fix";m["@eslint/js"]="^10";m.eslint="^10";m["typescript-eslint"]="^8";g["eslint.config.js"]=eslintConfig(u==="prettier");if(u==="prettier"){m["eslint-config-prettier"]="^10"}v.push("dbaeumer.vscode-eslint");break}case"oxlint":{p.lint="oxlint";p["lint:fix"]="oxlint --fix";m.oxlint="^1";g[".oxlintrc.json"]=oxlintConfig();v.push("oxc.oxc-vscode");break}case"biome":{p.lint="biome lint .";p["lint:fix"]="biome lint --write .";break}case"none":break}switch(u){case"prettier":{p.format="prettier --write .";p["format:check"]="prettier --check .";m.prettier="^3";g[".prettierrc.json"]=prettierConfig();v.push("esbenp.prettier-vscode");break}case"oxfmt":{p.format="oxfmt";p["format:check"]="oxfmt --check";m.oxfmt="^0.58.0";g[".oxfmtrc.json"]=oxfmtConfig();if(!v.includes("oxc.oxc-vscode")){v.push("oxc.oxc-vscode")}break}case"biome":{p.format="biome format --write .";p["format:check"]="biome format .";break}case"none":break}if(t==="biome"||u==="biome"){m["@biomejs/biome"]="^2";g["biome.json"]=biomeConfig({lint:t==="biome",format:u==="biome"});v.push("biomejs.biome")}return{scripts:p,docsScripts:p.lint?{lint:p.lint}:{},devDependencies:m,files:g,vscodeExtensions:v}}function buildProjectDependencies(t,u){const p={zuplo:`^${u}`};if(t==="default"||t==="default-empty"){p["@zuplo/otel"]=`^${u}`}return p}const tc="shared";const getTemplateFile=({template:t,file:u})=>{const p=__nccwpck_require__.ab+"templates/"+t+"/"+u;if((0,ze.existsSync)(p)){return p}return __nccwpck_require__.ab+"shared/"+u};const installTemplate=async({appName:t,root:u,packageManager:p,isOnline:m,template:g,linter:v,formatter:b,installPackages:w,verbose:E,zuploVersion:S,agents:$})=>{var P;console.log((0,qe.bold)(`Using ${p}.`));console.log("\nInitializing project with template:",g,"\n");const x=__nccwpck_require__.ab+"shared";const R=__nccwpck_require__.ab+"templates/"+g;const O=(0,ze.existsSync)(Ge().join(R,"docs"));const A=["**","!vscode/**"];for(const t of[__nccwpck_require__.ab+"shared",R]){await copy(A,u,{parents:true,cwd:t,verbose:E,rename(t){switch(t){case"gitignore":case"env.example":{return`.${t}`}case"README-template.md":{return"README.md"}default:{return t}}}})}if(g==="ai-gateway"){await et().writeFile(Ge().join(u,".zuplo-template.json"),gatewayProvenance(),"utf-8")}const k=buildLintFormatSetup(v,b);for(const[t,p]of Object.entries(k.files)){await et().writeFile(Ge().join(u,t),p,"utf-8")}const T=["settings.json","launch.json"];for(const t of T){const p=[R,__nccwpck_require__.ab+"shared"].map((u=>Ge().join(u,"vscode",t))).find((t=>(0,ze.existsSync)(t)));if(p){await et().mkdir(Ge().join(u,".vscode"),{recursive:true});await et().copyFile(p,Ge().join(u,".vscode",t))}}if(k.vscodeExtensions.length>0){await et().mkdir(Ge().join(u,".vscode"),{recursive:true});const t=k.vscodeExtensions.map((t=>`"${t}"`)).join(", ");await et().writeFile(Ge().join(u,".vscode","extensions.json"),`{${rt().EOL} "recommendations": [${t}]${rt().EOL}}${rt().EOL}`,"utf-8")}const C=(P=process.env.ZUPLO_PRIVATE_TEST_VERSION)!==null&&P!==void 0?P:S;const I=new ke.SemVer(C);const N={name:t,version:"0.1.0",private:true,type:"module",scripts:{dev:`zuplo dev`,...g==="ai-gateway"?{}:{test:"zuplo test"},typecheck:"tsc --noEmit",...O?{docs:"zuplo docs"}:{},...k.scripts},dependencies:buildProjectDependencies(g,I.major),devDependencies:{typescript:"^5","@types/node":"^22",...k.devDependencies}};if(O){if(p==="pnpm"){await et().writeFile(Ge().join(u,"pnpm-workspace.yaml"),["packages:",' - "docs"',"onlyBuiltDependencies:",' - "@swc/core"'," - deno"," - esbuild"," - protobufjs"," - workerd",""].join(rt().EOL),"utf-8")}else{N.workspaces=["docs"]}}const sortObjectKeys=t=>Object.keys(t).sort().reduce(((u,p)=>{u[p]=t[p];return u}),{});if(N.dependencies){N.dependencies=sortObjectKeys(N.dependencies)}if(N.devDependencies){N.devDependencies=sortObjectKeys(N.devDependencies)}const D=Object.keys(N.devDependencies).length;if(!D)delete N.devDependencies;await et().writeFile(Ge().join(u,"package.json"),JSON.stringify(N,null,2)+rt().EOL);let j="^0.82";if(O&&m){try{const t=await fetch("https://api.github.com/repos/zuplo/zudoku/releases/latest");const u=await t.json();const p=u.tag_name.replace("v","");const m=new ke.SemVer(p);j=`^${m.major}.${m.minor}`}catch{console.warn("\nFailed to determine the latest dev portal version. Using the default version.")}}const L=[{name:"@zudoku/plugin-graphql",label:"GraphQL plugin"},{name:"@zuplo/zudoku-plugin-monetization",label:"monetization plugin"}];const M={};for(const{name:t,label:u}of L){let p="latest";if(O&&m){try{const u=await fetch(`https://registry.npmjs.org/${t}/latest`);const m=await u.json();const g=new ke.SemVer(m.version);p=`^${g.major}.${g.minor}`}catch{console.warn(`\nFailed to determine the latest ${u} version. Using the default version.`)}}M[t]=p}const U={name:"docs",version:"0.1.0",private:true,type:"module",scripts:{dev:"zudoku dev --zuplo",build:"zudoku build --zuplo",...k.docsScripts},dependencies:sortObjectKeys({react:"^19","react-dom":"^19","@mdx-js/react":"3.0.1",...M,zudoku:j}),devDependencies:{"@types/node":"^22","@types/react":"^19","@types/react-dom":"^19",typescript:"^5"}};if(O){await et().writeFile(Ge().join(u,"docs","package.json"),JSON.stringify(U,null,2)+rt().EOL)}if($.length>0){await installAgentConfigs(u,$);const t=Ge().join(u,"README.md");const p=await et().readFile(t,"utf-8");const m=["","## AI Coding Agents","","This project is configured for AI coding agents. Skills from","[zuplo/tools](https://github.com/zuplo/tools) provide agents with Zuplo and","Zudoku-specific knowledge.","","To update skills to the latest version:","","```bash","npx skills add zuplo/tools","```","","Learn more about using AI agents with Zuplo at","[zuplo.com/docs/articles/ai-agents](https://zuplo.com/docs/articles/ai-agents).",""].join("\n");await et().writeFile(t,p+m,"utf-8")}if(!w)return;console.log("\nInstalling dependencies:");for(const t in N.dependencies)console.log(`- ${(0,qe.cyan)(t)}`);if(D){console.log("\nInstalling devDependencies:");for(const t in N.devDependencies)console.log(`- ${(0,qe.cyan)(t)}`)}console.log();await install(p,m,E)};class DownloadError extends Error{}async function createApp({appPath:t,packageManager:u,example:p,examplePath:m,template:g,linter:v,formatter:b,installPackages:w,empty:E,initGit:S,verbose:$,zuploVersion:P,serverProject:x,account:R,skipPrompts:O,agents:A}){var k;let T;const C=g!==null&&g!==void 0?g:`default${E?"-empty":""}`;if(p){let z;try{z=new URL(p)}catch(V){const G=V;if(G.code!=="ERR_INVALID_URL"){console.error(V);process.exit(1)}}if(z){if(z.origin!=="https://github.com"){console.error(`Invalid URL: ${(0,qe.red)(`"${p}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);process.exit(1)}T=await getRepoInfo(z,m);if(!T){console.error(`Found invalid GitHub URL: ${(0,qe.red)(`"${p}"`)}. Please fix the URL and try again.`);process.exit(1)}const q=await hasRepo(T);if(!q){console.error(`Could not locate the repository for ${(0,qe.red)(`"${p}"`)}. Please check that the repository exists and try again.`);process.exit(1)}}else if(p!=="__internal-testing-retry"){const W=await existsInRepo(p);if(!W){console.error(`Could not locate an example named ${(0,qe.red)(`"${p}"`)}. It could be due to the following:\n`,`1. Your spelling of example ${(0,qe.red)(`"${p}"`)} might be incorrect.\n`,`2. You might not be connected to the internet or you are behind a proxy.`);process.exit(1)}}}const I=(0,Ve.resolve)(t);if(!await isWriteable((0,Ve.dirname)(I))){console.error("The application path is not writable, please check folder permissions and try again.");console.error("It is likely you do not have write permissions for this folder.");process.exit(1)}const N=(0,Ve.basename)(I);(0,ze.mkdirSync)(I,{recursive:true});if(!isFolderEmpty(I,N)){process.exit(1)}const D=u==="yarn";const j=!D||await getOnline();const L=process.cwd();console.log(`Creating a new Zuplo API in ${(0,qe.green)(I)}.`);console.log();process.chdir(I);const M=(0,Ve.join)(I,"package.json");if(p){try{if(T){const Z=T;console.log(`Downloading files from repo ${(0,qe.cyan)(p)}. This might take a moment.`);console.log();await Xe()((()=>downloadAndExtractRepo(I,Z,$)),{retries:3})}else{console.log(`Downloading files for example ${(0,qe.cyan)(p)}. This might take a moment.`);console.log();await Xe()((()=>downloadAndExtractExample(I,p,$)),{retries:3})}}catch(J){function isErrorLike(t){return typeof t==="object"&&t!==null&&typeof t.message==="string"}throw new DownloadError(isErrorLike(J)?J.message:`${J}`)}const Y=(0,Ve.join)(I,".gitignore");if(!(0,ze.existsSync)(Y)){(0,ze.copyFileSync)(getTemplateFile({template:C,file:"gitignore"}),Y)}if(A.length>0){await installAgentConfigs(I,A)}if(w&&(0,ze.existsSync)(M)){console.log("Installing packages. This might take a couple of minutes.");console.log();await install(u,j,$);console.log()}}else{await installTemplate({appName:N,root:I,template:C,packageManager:u,isOnline:j,linter:v,formatter:b,installPackages:w,verbose:$,zuploVersion:P,agents:A})}const U=(0,ze.existsSync)(M);if(S){if(tryGitInit(I,$)){console.log("Initialized a git repository.");console.log()}}let B;if((0,Ve.join)(L,N)===t){B=N}else{B=t}console.log(`${(0,qe.green)("Success!")} Created ${N} at ${t}`);let H;if(x){H=await createAndLinkServerProject({appPath:I,appName:N,account:R,skipPrompts:O})}if(H){const X=`https://portal.zuplo.com/${H.account}/${H.project}`;console.log();console.log(`${(0,qe.green)("Success!")} Your project ${(0,qe.cyan)(`'${H.project}'`)} has been created in account ${(0,qe.cyan)(`'${H.account}'`)}.`);console.log();console.log("You can access this project online at:");console.log(` ${(0,qe.cyan)(X)}`);console.log();console.log("To connect your project to source control for easy, automated deployments:");console.log(` ${(0,qe.cyan)(`${X}/settings/source-control-settings`)}`);console.log()}if(U){const Q=(k=JSON.parse((0,ze.readFileSync)(M,"utf-8")).scripts)!==null&&k!==void 0?k:{};const run=t=>`${u} ${D?"":"run "}${t}`;const ee={dev:"Starts the local development server.",docs:"Starts the developer portal.",test:"Runs your API tests."};const te=Object.entries(ee).filter((([t])=>t in Q));console.log();if(te.length>0){console.log("Inside that directory, you can run several commands:");console.log();for(const[re,ie]of te){console.log((0,qe.cyan)(` ${run(re)}`));console.log(` ${ie}`);console.log()}}console.log("We suggest that you begin by typing:");console.log();console.log((0,qe.cyan)(" cd"),B);if(C==="ai-gateway"&&!p&&!H){console.log(` ${(0,qe.cyan)("npx zuplo link")}`)}if("dev"in Q){console.log(` ${(0,qe.cyan)(run("dev"))}`)}}console.log()}const rc=require("crypto");function basename(t){if(!t){return undefined}return C().basename(t).toLowerCase()}function parseUserAgent(t){var u;const p=t===null||t===void 0?void 0:t.match(/^([^/\s]+)\/([^\s]+)/);const m=(u=p===null||p===void 0?void 0:p[1])===null||u===void 0?void 0:u.toLowerCase();switch(m){case"npm":case"pnpm":case"yarn":case"bun":return{family:m,version:p===null||p===void 0?void 0:p[2]};default:return{family:"unknown"}}}function inferFamilyFromExecutable(t){if(t==="npm"||t==="npm-cli.js"||t==="npx"||t==="npx-cli.js"){return"npm"}if(t==="pnpm"||t==="pnpm.cjs"||t==="pnpx"){return"pnpm"}if(t==="yarn"||t==="yarn.js"){return"yarn"}if(t==="bun"||t==="bunx"){return"bun"}return undefined}function inferRunner({family:t,command:u,execPathBasename:p,runnerBasename:m}){if(t==="npm"){if(p==="npx-cli.js"||m==="npx"){return"npx"}if(u==="init"||u==="create"){return"npm-create"}if(u==="exec"){return"npm-exec"}return"npm"}if(t==="pnpm"){if(m==="pnpx"||p==="pnpx"){return"pnpx"}if(u==="create"||u==="init"){return"pnpm-create"}if(u==="dlx"){return"pnpm-dlx"}if(u==="exec"){return"pnpm-exec"}return"pnpm"}if(t==="yarn"){if(u==="create"){return"yarn-create"}if(u==="dlx"){return"yarn-dlx"}return"yarn"}if(t==="bun"){if(m==="bunx"){return"bunx"}if(u==="create"){return"bun-create"}return"bun"}return"unknown"}function inferInstallSource(t){if(!t){return"unknown"}const u=t.toLowerCase().replace(/\\/g,"/");if(u.includes("/node_modules/.bin/")){return"project-local"}if(u.includes("/corepack/")){return"corepack"}if(u.includes("/.volta/")||u.includes("/volta/")){return"volta"}if(u.includes("/.nvm/")){return"nvm"}if(u.includes("/.asdf/")){return"asdf"}if(u.includes("/.fnm/")||u.includes("/fnm_multishells/")){return"fnm"}if(u.includes("/homebrew/")||u.includes("/cellar/")||u.startsWith("/opt/homebrew/")){return"homebrew"}if(u.startsWith("/usr/bin/")||u.startsWith("/usr/local/bin/")||u.startsWith("/usr/local/lib/")||u.startsWith("/bin/")||u.startsWith("c:/program files/")||u.startsWith("c:/programdata/")){return"system"}return"unknown"}function getPackageManagerUsageProperties(t=process.env){var u,p,m;const g=t["npm_config_user_agent"]||undefined;const v=(u=t["npm_command"])===null||u===void 0?void 0:u.toLowerCase();const b=t["npm_execpath"];const w=basename(b);const E=basename(t["_"]);const S=parseUserAgent(g);const $=S.family!=="unknown"?S.family:(m=(p=inferFamilyFromExecutable(E))!==null&&p!==void 0?p:inferFamilyFromExecutable(w))!==null&&m!==void 0?m:"unknown";return{packageManager:$,packageManagerVersion:S.version,runner:inferRunner({family:$,command:v,execPathBasename:w,runnerBasename:E}),installSource:inferInstallSource(b),nodeVersion:process.versions.node,platform:process.platform,arch:process.arch}}function getPkgManager(){const{packageManager:t}=getPackageManagerUsageProperties();if(t!=="unknown"){return t}return"npm"}const sc="phc_xB1aydh7a41MW9TwUtLJjKme4izQiWf9zKbKhpysAiW";const ic="https://app.posthog.com";const nc=1e3;function isAnalyticsEnabled(){return!process.env.ZUPLO_DO_NOT_TRACK}function getOrCreateAnalyticsDistinctId(t){try{const u=t.get("analyticsDistinctId");if(typeof u==="string"&&u.length>0){return u}const p=(0,rc.randomUUID)();try{t.set("analyticsDistinctId",p)}catch{}return p}catch{return(0,rc.randomUUID)()}}async function captureCreateZuploApiEvent({distinctId:t,event:u,properties:p}){if(!isAnalyticsEnabled()){return}const m=new AbortController;const g=setTimeout((()=>m.abort()),nc);g.unref();try{await fetch(`${ic}/capture/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({["api_key"]:sc,event:u,["distinct_id"]:t,properties:{...getPackageManagerUsageProperties(),...p!==null&&p!==void 0?p:{}},timestamp:(new Date).toISOString()}),signal:m.signal})}catch{}finally{clearTimeout(g)}}function resolvePackageManager(t,u){if(t.useNpm)return"npm";if(t.usePnpm)return"pnpm";if(t.useYarn)return"yarn";if(t.useBun)return"bun";return u()}function resolveNegatableFlag(t,u,p){return t!==null&&t!==void 0?t:!u.includes(p)}function parseAgentsFlag(t){const u=t.split(",").map((t=>t.trim())).filter(Boolean);const p=new Set(ja.map((t=>t.value)));const m=u.filter((t=>!p.has(t)));if(m.length>0){return{ok:false,error:`Invalid agent value(s): ${m.join(", ")}\nValid agents are: ${Array.from(p).join(", ")}`}}if(u.includes(Da)){if(u.some((t=>t!==Da))){return{ok:false,error:`'none' cannot be combined with other agents. Use --agents none to skip agent setup, or list specific agents.`}}return{ok:true,agents:[]}}return{ok:true,agents:u}}const oc=["default","default-empty","ai-gateway"];function resolveTemplate(t){const{template:u,empty:p,example:m}=t;if(u===undefined){return{template:p?"default-empty":"default"}}if(m){return{error:"The --template option cannot be combined with --example. Remove one of the two options."}}if(p){return{error:"The --template option cannot be combined with --empty. Use --template default-empty instead."}}const g=oc.find((t=>t===u));if(!g){return{error:`Unknown template "${u}". Valid templates are: ${oc.join(", ")}.`}}return{template:g}}function resolveServerProjectFromFlags(t){if(t.noServerProject){return false}if(t.serverProject){return true}if(typeof t.account==="string"&&t.account.trim().length>0){return true}return undefined}var ac=__nccwpck_require__(7825);var cc=__nccwpck_require__.n(ac);function validateNpmName(t){const u=cc()(t);if(u.validForNewPackages){return{valid:true}}return{valid:false,problems:[...u.errors||[],...u.warnings||[]]}}let lc="";const handleSigTerm=()=>process.exit(0);process.on("SIGINT",handleSigTerm);process.on("SIGTERM",handleSigTerm);const onPromptState=t=>{if(t.aborted){process.stdout.write("[?25h");process.stdout.write("\n");process.exit(1)}};const uc=JSON.parse((0,ze.readFileSync)(Ge().resolve(__dirname,Ge().join("..","package.json")),"utf-8"));const hc=new $(uc.name).version(uc.version,"-v, --version","Output the current version of create-zuplo-api.").argument("[directory]").usage("[directory] [options]").helpOption("-h, --help","Display this help message.").option("--linter <linter>",`The linter to configure: ${Ja.join(", ")}.`).option("--formatter <formatter>",`The formatter to configure: ${Xa.join(", ")}.`).option("--eslint","Initialize with ESLint config. (deprecated: use --linter eslint)").option("--prettier","Initialize with Prettier config. (deprecated: use --formatter prettier)").option("--empty","Initialize an empty project.").option("--use-npm","Explicitly tell the CLI to bootstrap the application using npm.").option("--use-pnpm","Explicitly tell the CLI to bootstrap the application using pnpm.").option("--use-yarn","Explicitly tell the CLI to bootstrap the application using Yarn.").option("--use-bun","Explicitly tell the CLI to bootstrap the application using Bun.").option("--reset, --reset-preferences","Reset the preferences saved for create-zuplo-api.").option("--git","Whether or not to initialize the project as a git repo.").option("--version-check","Whether or not to check for an outdated version.").option("--install","Whether or not to install packages.").option("--verbose","Enable verbose logging.",false).option("--yes","Use saved preferences or defaults for unprovided options.").option("--server-project","Create a matching project on portal.zuplo.com and link this working copy to it (skips the interactive prompt).").option("--account <account-name>","The Zuplo account that will host the server project. Implies --server-project.").option("--agents <agents>","Comma-separated list of AI coding agents to configure (claude,copilot,cursor,windsurf,codex), or 'none' to skip agent setup.").option("--template <template-name>",`\n\n A built-in template to bootstrap the api with (default, default-empty,\n ai-gateway). Cannot be combined with --example or --empty.\n`).option("-e, --example <example-name|github-url>",`\n\n An example to bootstrap the api with. You can use an example name\n from the official Zuplo repo or a public GitHub URL. The URL can use\n any branch and/or subdirectory.\n`).option("--example-path <path-to-example>",`\n\n In a rare case, your GitHub URL might contain a branch name with\n a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar).\n In this case, you must specify the path to the example separately:\n --example-path foo/bar\n`).action((t=>{if(t&&!t.startsWith("-")){lc=t}})).allowUnknownOption().parse(process.argv);const dc=hc.opts();const{args:fc}=hc;const pc=resolvePackageManager(dc,getPkgManager);async function run(){var t,p,m,g,v,b,w,E,S;const $=new Conf({projectName:"create-zuplo-api"});if(typeof dc.linter==="string"&&!isLinter(dc.linter)){console.error((0,qe.red)(`Invalid linter: "${dc.linter}"\nValid linters are: ${Ja.join(", ")}`));process.exit(1)}if(typeof dc.formatter==="string"&&!isFormatter(dc.formatter)){console.error((0,qe.red)(`Invalid formatter: "${dc.formatter}"\nValid formatters are: ${Xa.join(", ")}`));process.exit(1)}if(dc.resetPreferences){const{resetPreferences:t}=await Ke()({onState:onPromptState,type:"toggle",name:"resetPreferences",message:"Would you like to reset the saved preferences?",initial:false,active:"Yes",inactive:"No"});if(t){$.clear();console.log("The preferences have been reset successfully!")}process.exit(0)}if(typeof lc==="string"){lc=lc.trim()}if(!lc){const t=await Ke()({onState:onPromptState,type:"text",name:"path",message:"What is your project named?",initial:"my-api",validate:t=>{const u=validateNpmName((0,Ve.basename)((0,Ve.resolve)(t)));if(u.valid){return true}return`Invalid project name: ${u.problems[0]}`}});if(typeof t.path==="string"){lc=t.path.trim()}}if(!lc){console.log("\nPlease specify the project directory:\n"+` ${(0,qe.cyan)(dc.name())} ${(0,qe.green)("<project-directory>")}\n`+"For example:\n"+` ${(0,qe.cyan)(dc.name())} ${(0,qe.green)("my-zuplo-api")}\n\n`+`Run ${(0,qe.cyan)(`${dc.name()} --help`)} to see all options.`);process.exit(1)}const P=(0,Ve.resolve)(lc);const x=(0,Ve.basename)(P);const R=validateNpmName(x);if(!R.valid){console.error(`Could not create a project called ${(0,qe.red)(`"${x}"`)} because of npm naming restrictions:`);R.problems.forEach((t=>console.error(` ${(0,qe.red)((0,qe.bold)("*"))} ${t}`)));process.exit(1)}if(dc.example===true){console.error("Please provide an example name or url, otherwise remove the example option.");process.exit(1)}if((0,ze.existsSync)(P)&&!isFolderEmpty(P,x)){process.exit(1)}const O=typeof dc.example==="string"&&dc.example.trim();const A=resolveTemplate({template:typeof dc.template==="string"?dc.template:undefined,empty:Boolean(dc.empty),example:Boolean(O)});if("error"in A){console.error((0,qe.red)(A.error));process.exit(1)}const k=$.get("preferences")||{};const T=u().isCI||dc.yes;let C=resolveServerProjectFromFlags({noServerProject:fc.includes("--no-server-project"),serverProject:dc.serverProject===true,account:typeof dc.account==="string"?dc.account:undefined});if(C===undefined&&!T){const{serverProject:t}=await Ke()({onState:onPromptState,type:"toggle",name:"serverProject",message:"Create a matching project on portal.zuplo.com?",hint:"Connect this working copy to your Zuplo account so you can deploy and manage it from portal.zuplo.com.",initial:true,active:"Yes",inactive:"No"});C=Boolean(t)}if(!O){const u={linter:"eslint",formatter:"prettier",git:true,install:true,versionCheck:true,empty:false,zudoku:false};migrateLegacyLintPreferences(k);const getPrefOrDefault=t=>{var p;return(p=k[t])!==null&&p!==void 0?p:u[t]};if(!dc.linter){const t=resolveLinterFromLegacyFlags({eslint:dc.eslint===true,noEslint:fc.includes("--no-eslint")});if(t){dc.linter=t}else if(T){dc.linter=getPrefOrDefault("linter")}else{const t=getPrefOrDefault("linter");const{linter:u}=await Ke()({onState:onPromptState,type:"select",name:"linter",message:`Which ${(0,qe.blue)("linter")} would you like to use?`,choices:Qa,initial:Math.max(0,Qa.findIndex((u=>u.value===t)))});dc.linter=u;k.linter=dc.linter}}if(!dc.formatter){const p=resolveFormatterFromLegacyFlags({prettier:dc.prettier===true,noPrettier:fc.includes("--no-prettier")});if(p){dc.formatter=p}else if(T){dc.formatter=getPrefOrDefault("formatter")}else{const p=(t=k.formatter)!==null&&t!==void 0?t:dc.linter==="biome"?"biome":u.formatter;const{formatter:m}=await Ke()({onState:onPromptState,type:"select",name:"formatter",message:`Which ${(0,qe.blue)("formatter")} would you like to use?`,choices:ec,initial:Math.max(0,ec.findIndex((t=>t.value===p)))});dc.formatter=m;k.formatter=dc.formatter}}if(!dc.agents){if(T){dc.agents=[]}else{const{agents:t}=await Ke()({onState:onPromptState,type:"multiselect",name:"agents",message:"Which AI coding agents would you like to configure?",choices:ja,hint:"- Space to select. Return to submit"});dc.agents=resolveAgentSelection((p=t)!==null&&p!==void 0?p:[])}}}dc.git=resolveNegatableFlag(dc.git,fc,"--no-git");dc.install=resolveNegatableFlag(dc.install,fc,"--no-install");dc.versionCheck=resolveNegatableFlag(dc.versionCheck,fc,"--no-version-check");dc.serverProject=C!==null&&C!==void 0?C:false;if(typeof dc.agents==="string"){const t=parseAgentsFlag(dc.agents);if(!t.ok){console.error((0,qe.red)(t.error));process.exit(1)}dc.agents=t.agents}dc.agents=(m=dc.agents)!==null&&m!==void 0?m:[];if(isAnalyticsEnabled()){void captureCreateZuploApiEvent({distinctId:getOrCreateAnalyticsDistinctId($),event:"create-zuplo-api invoked",properties:{version:uc.version,selectedPackageManager:pc,hasExample:Boolean(O),template:A.template,emptyTemplate:Boolean(dc.empty),installPackages:Boolean(dc.install),initGit:Boolean(dc.git),serverProject:Boolean(dc.serverProject),skipPrompts:T,agentsCount:dc.agents.length,linter:(g=dc.linter)!==null&&g!==void 0?g:null,formatter:(v=dc.formatter)!==null&&v!==void 0?v:null}})}try{await createApp({appPath:P,packageManager:pc,example:O&&O!=="default"?O:undefined,examplePath:dc.examplePath,template:A.template,linter:(b=dc.linter)!==null&&b!==void 0?b:"none",formatter:(w=dc.formatter)!==null&&w!==void 0?w:"none",installPackages:dc.install,empty:dc.empty,initGit:dc.git,verbose:dc.verbose,zuploVersion:uc.version,serverProject:dc.serverProject,account:dc.account,skipPrompts:T,agents:dc.agents})}catch(t){if(!(t instanceof DownloadError)){throw t}const u=await Ke()({onState:onPromptState,type:"confirm",name:"builtin",message:`Could not download "${O}" because of a connectivity issue between your machine and GitHub.\n`+`Do you want to use the default template instead?`,initial:true});if(!u.builtin){throw t}await createApp({appPath:P,packageManager:pc,template:A.template,linter:(E=dc.linter)!==null&&E!==void 0?E:"none",formatter:(S=dc.formatter)!==null&&S!==void 0?S:"none",installPackages:dc.install,empty:dc.empty,initGit:dc.git,verbose:dc.verbose,zuploVersion:uc.version,serverProject:dc.serverProject,account:dc.account,skipPrompts:T,agents:dc.agents})}$.set("preferences",k);if(dc.versionCheck){console.log();await notifyUpdate()}}const mc=Ze()(uc).catch((()=>null));async function notifyUpdate(){var t;try{if((t=await mc)===null||t===void 0?void 0:t.latest){const t={npm:"npm i -g",yarn:"yarn global add",pnpm:"pnpm add -g",bun:"bun add -g"};const u=`${t[pc]} create-zuplo-api`;console.log((0,qe.yellow)((0,qe.bold)("A new version of `create-zuplo-api` is available!"))+"\n"+"You can update by running: "+(0,qe.cyan)(u)+"\n")}process.exit(0)}catch{}}async function exit(t){console.log();console.log("Aborting installation.");if(t.command){console.log(` ${(0,qe.cyan)(t.command)} has failed.`)}else{console.log(`${(0,qe.red)("Unexpected error. Please report it as a bug:")}\n`,t)}process.exit(1)}run().catch(exit)})();module.exports=p})();
|
|
72
|
+
*/const m=p(7311);const toRegexRange=(t,u,p)=>{if(m(t)===false){throw new TypeError("toRegexRange: expected the first argument to be a number")}if(u===void 0||t===u){return String(t)}if(m(u)===false){throw new TypeError("toRegexRange: expected the second argument to be a number.")}let g={relaxZeros:true,...p};if(typeof g.strictZeros==="boolean"){g.relaxZeros=g.strictZeros===false}let v=String(g.relaxZeros);let b=String(g.shorthand);let w=String(g.capture);let E=String(g.wrap);let S=t+":"+u+"="+v+b+w+E;if(toRegexRange.cache.hasOwnProperty(S)){return toRegexRange.cache[S].result}let $=Math.min(t,u);let P=Math.max(t,u);if(Math.abs($-P)===1){let p=t+"|"+u;if(g.capture){return`(${p})`}if(g.wrap===false){return p}return`(?:${p})`}let x=hasPadding(t)||hasPadding(u);let R={min:t,max:u,a:$,b:P};let O=[];let A=[];if(x){R.isPadded=x;R.maxLen=String(R.max).length}if($<0){let t=P<0?Math.abs(P):1;A=splitToPatterns(t,Math.abs($),R,g);$=R.a=0}if(P>=0){O=splitToPatterns($,P,R,g)}R.negatives=A;R.positives=O;R.result=collatePatterns(A,O,g);if(g.capture===true){R.result=`(${R.result})`}else if(g.wrap!==false&&O.length+A.length>1){R.result=`(?:${R.result})`}toRegexRange.cache[S]=R;return R.result};function collatePatterns(t,u,p){let m=filterPatterns(t,u,"-",false,p)||[];let g=filterPatterns(u,t,"",false,p)||[];let v=filterPatterns(t,u,"-?",true,p)||[];let b=m.concat(v).concat(g);return b.join("|")}function splitToRanges(t,u){let p=1;let m=1;let g=countNines(t,p);let v=new Set([u]);while(t<=g&&g<=u){v.add(g);p+=1;g=countNines(t,p)}g=countZeros(u+1,m)-1;while(t<g&&g<=u){v.add(g);m+=1;g=countZeros(u+1,m)-1}v=[...v];v.sort(compare);return v}function rangeToPattern(t,u,p){if(t===u){return{pattern:t,count:[],digits:0}}let m=zip(t,u);let g=m.length;let v="";let b=0;for(let t=0;t<g;t++){let[u,g]=m[t];if(u===g){v+=u}else if(u!=="0"||g!=="9"){v+=toCharacterClass(u,g,p)}else{b++}}if(b){v+=p.shorthand===true?"\\d":"[0-9]"}return{pattern:v,count:[b],digits:g}}function splitToPatterns(t,u,p,m){let g=splitToRanges(t,u);let v=[];let b=t;let w;for(let t=0;t<g.length;t++){let u=g[t];let E=rangeToPattern(String(b),String(u),m);let S="";if(!p.isPadded&&w&&w.pattern===E.pattern){if(w.count.length>1){w.count.pop()}w.count.push(E.count[0]);w.string=w.pattern+toQuantifier(w.count);b=u+1;continue}if(p.isPadded){S=padZeros(u,p,m)}E.string=S+E.pattern+toQuantifier(E.count);v.push(E);b=u+1;w=E}return v}function filterPatterns(t,u,p,m,g){let v=[];for(let g of t){let{string:t}=g;if(!m&&!contains(u,"string",t)){v.push(p+t)}if(m&&contains(u,"string",t)){v.push(p+t)}}return v}function zip(t,u){let p=[];for(let m=0;m<t.length;m++)p.push([t[m],u[m]]);return p}function compare(t,u){return t>u?1:u>t?-1:0}function contains(t,u,p){return t.some((t=>t[u]===p))}function countNines(t,u){return Number(String(t).slice(0,-u)+"9".repeat(u))}function countZeros(t,u){return t-t%Math.pow(10,u)}function toQuantifier(t){let[u=0,p=""]=t;if(p||u>1){return`{${u+(p?","+p:"")}}`}return""}function toCharacterClass(t,u,p){return`[${t}${u-t===1?"":"-"}${u}]`}function hasPadding(t){return/^-?(0+)\d/.test(t)}function padZeros(t,u,p){if(!u.isPadded){return t}let m=Math.abs(u.maxLen-String(t).length);let g=p.relaxZeros!==false;switch(m){case 0:return"";case 1:return g?"0?":"0";case 2:return g?"0{0,2}":"00";default:{return g?`0{0,${m}}`:`0{${m}}`}}}toRegexRange.cache={};toRegexRange.clearCache=()=>toRegexRange.cache={};t.exports=toRegexRange},1083:(t,u,p)=>{const{URL:m}=p(7016);const{join:g}=p(6928);const v=p(9896);const{promisify:b}=p(9023);const{tmpdir:w}=p(857);const E=p(2804);const S=b(v.writeFile);const $=b(v.mkdir);const P=b(v.readFile);const compareVersions=(t,u)=>t.localeCompare(u,"en-US",{numeric:true});const encode=t=>encodeURIComponent(t).replace(/^%40/,"@");const getFile=async(t,u)=>{const p=w();const m=g(p,"update-check");if(!v.existsSync(m)){await $(m)}let b=`${t.name}-${u}.json`;if(t.scope){b=`${t.scope}-${b}`}return g(m,b)};const evaluateCache=async(t,u,p)=>{if(v.existsSync(t)){const m=await P(t,"utf8");const{lastUpdate:g,latest:v}=JSON.parse(m);const b=g+p;if(b>u){return{shouldCheck:false,latest:v}}}return{shouldCheck:true,latest:null}};const updateCache=async(t,u,p)=>{const m=JSON.stringify({latest:u,lastUpdate:p});await S(t,m,"utf8")};const loadPackage=(t,u)=>new Promise(((m,g)=>{const v={host:t.hostname,path:t.pathname,port:t.port,headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"},timeout:2e3};if(u){v.headers.authorization=`${u.type} ${u.token}`}const{get:b}=p(t.protocol==="https:"?5692:8611);b(v,(t=>{const{statusCode:u}=t;if(u!==200){const p=new Error(`Request failed with code ${u}`);p.code=u;g(p);t.resume();return}let p="";t.setEncoding("utf8");t.on("data",(t=>{p+=t}));t.on("end",(()=>{try{const t=JSON.parse(p);m(t)}catch(t){g(t)}}))})).on("error",g).on("timeout",g)}));const getMostRecent=async({full:t,scope:u},g)=>{const v=E(u);const b=new m(t,v);let w=null;try{w=await loadPackage(b)}catch(t){if(t.code&&String(t.code).startsWith(4)){const t=p(373);const u=t(v,{recursive:true});w=await loadPackage(b,u)}else{throw t}}const S=w["dist-tags"][g];if(!S){throw new Error(`Distribution tag ${g} is not available`)}return S};const x={interval:36e5,distTag:"latest"};const getDetails=t=>{const u={full:encode(t)};if(t.includes("/")){const p=t.split("/");u.scope=p[0];u.name=p[1]}else{u.scope=null;u.name=t}return u};t.exports=async(t,u)=>{if(typeof t!=="object"){throw new Error("The first parameter should be your package.json file content")}const p=getDetails(t.name);const m=Date.now();const{distTag:g,interval:v}=Object.assign({},x,u);const b=await getFile(p,g);let w=null;let E=true;({shouldCheck:E,latest:w}=await evaluateCache(b,m,v));if(E){w=await getMostRecent(p,g);await updateCache(b,w,m)}const S=compareVersions(t.version,w);if(S===-1){return{latest:w,fromCache:!E}}return null}},3969:(t,u,p)=>{const m=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys";const g=p(6928);const v=m?";":":";const b=p(6173);const getNotFoundError=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"});const getPathInfo=(t,u)=>{const p=u.colon||v;const g=t.match(/\//)||m&&t.match(/\\/)?[""]:[...m?[process.cwd()]:[],...(u.path||process.env.PATH||"").split(p)];const b=m?u.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"";const w=m?b.split(p):[""];if(m){if(t.indexOf(".")!==-1&&w[0]!=="")w.unshift("")}return{pathEnv:g,pathExt:w,pathExtExe:b}};const which=(t,u,p)=>{if(typeof u==="function"){p=u;u={}}if(!u)u={};const{pathEnv:m,pathExt:v,pathExtExe:w}=getPathInfo(t,u);const E=[];const step=p=>new Promise(((v,b)=>{if(p===m.length)return u.all&&E.length?v(E):b(getNotFoundError(t));const w=m[p];const S=/^".*"$/.test(w)?w.slice(1,-1):w;const $=g.join(S,t);const P=!S&&/^\.[\\\/]/.test(t)?t.slice(0,2)+$:$;v(subStep(P,p,0))}));const subStep=(t,p,m)=>new Promise(((g,S)=>{if(m===v.length)return g(step(p+1));const $=v[m];b(t+$,{pathExt:w},((v,b)=>{if(!v&&b){if(u.all)E.push(t+$);else return g(t+$)}return g(subStep(t,p,m+1))}))}));return p?step(0).then((t=>p(null,t)),p):step(0)};const whichSync=(t,u)=>{u=u||{};const{pathEnv:p,pathExt:m,pathExtExe:v}=getPathInfo(t,u);const w=[];for(let E=0;E<p.length;E++){const S=p[E];const $=/^".*"$/.test(S)?S.slice(1,-1):S;const P=g.join($,t);const x=!$&&/^\.[\\\/]/.test(t)?t.slice(0,2)+P:P;for(let t=0;t<m.length;t++){const p=x+m[t];try{const t=b.sync(p,{pathExt:v});if(t){if(u.all)w.push(p);else return p}}catch(t){}}}if(u.all&&w.length)return w;if(u.nothrow)return null;throw getNotFoundError(t)};t.exports=which;which.sync=whichSync},6395:(t,u,p)=>{"use strict";const m=p(2040);const g=process.env;Object.defineProperty(u,"_vendors",{value:m.map((function(t){return t.constant}))});u.name=null;u.isPR=null;m.forEach((function(t){const p=Array.isArray(t.env)?t.env:[t.env];const m=p.every((function(t){return checkEnv(t)}));u[t.constant]=m;if(!m){return}u.name=t.name;switch(typeof t.pr){case"string":u.isPR=!!g[t.pr];break;case"object":if("env"in t.pr){u.isPR=t.pr.env in g&&g[t.pr.env]!==t.pr.ne}else if("any"in t.pr){u.isPR=t.pr.any.some((function(t){return!!g[t]}))}else{u.isPR=checkEnv(t.pr)}break;default:u.isPR=null}}));u.isCI=!!(g.CI!=="false"&&(g.BUILD_ID||g.BUILD_NUMBER||g.CI||g.CI_APP_ID||g.CI_BUILD_ID||g.CI_BUILD_NUMBER||g.CI_NAME||g.CONTINUOUS_INTEGRATION||g.RUN_ID||u.name||false));function checkEnv(t){if(typeof t==="string")return!!g[t];if("env"in t){return g[t.env]&&g[t.env].includes(t.includes)}if("any"in t){return t.any.some((function(t){return!!g[t]}))}return Object.keys(t).every((function(u){return g[u]===t[u]}))}},7825:(t,u,p)=>{"use strict";const{builtinModules:m}=p(3339);var g=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");var v=["node_modules","favicon.ico"];function validate(t){var u=[];var p=[];if(t===null){p.push("name cannot be null");return done(u,p)}if(t===undefined){p.push("name cannot be undefined");return done(u,p)}if(typeof t!=="string"){p.push("name must be a string");return done(u,p)}if(!t.length){p.push("name length must be greater than zero")}if(t.match(/^\./)){p.push("name cannot start with a period")}if(t.match(/^_/)){p.push("name cannot start with an underscore")}if(t.trim()!==t){p.push("name cannot contain leading or trailing spaces")}v.forEach((function(u){if(t.toLowerCase()===u){p.push(u+" is a blacklisted name")}}));if(m.includes(t.toLowerCase())){u.push(t+" is a core module name")}if(t.length>214){u.push("name can no longer contain more than 214 characters")}if(t.toLowerCase()!==t){u.push("name can no longer contain capital letters")}if(/[~'!()*]/.test(t.split("/").slice(-1)[0])){u.push('name can no longer contain special characters ("~\'!()*")')}if(encodeURIComponent(t)!==t){var b=t.match(g);if(b){var w=b[1];var E=b[2];if(encodeURIComponent(w)===w&&encodeURIComponent(E)===E){return done(u,p)}}p.push("name can only contain URL-friendly characters")}return done(u,p)}var done=function(t,u){var p={validForNewPackages:u.length===0&&t.length===0,validForOldPackages:u.length===0,warnings:t,errors:u};if(!p.warnings.length){delete p.warnings}if(!p.errors.length){delete p.errors}return p};t.exports=validate},181:t=>{"use strict";t.exports=require("buffer")},5317:t=>{"use strict";t.exports=require("child_process")},4434:t=>{"use strict";t.exports=require("events")},9896:t=>{"use strict";t.exports=require("fs")},8611:t=>{"use strict";t.exports=require("http")},5692:t=>{"use strict";t.exports=require("https")},3339:t=>{"use strict";t.exports=require("module")},1421:t=>{"use strict";t.exports=require("node:child_process")},8474:t=>{"use strict";t.exports=require("node:events")},3024:t=>{"use strict";t.exports=require("node:fs")},6760:t=>{"use strict";t.exports=require("node:path")},1708:t=>{"use strict";t.exports=require("node:process")},857:t=>{"use strict";t.exports=require("os")},6928:t=>{"use strict";t.exports=require("path")},3785:t=>{"use strict";t.exports=require("readline")},2203:t=>{"use strict";t.exports=require("stream")},2018:t=>{"use strict";t.exports=require("tty")},7016:t=>{"use strict";t.exports=require("url")},9023:t=>{"use strict";t.exports=require("util")},1311:(t,u,p)=>{"use strict";const{normalizeIPv6:m,removeDotSegments:g,recomposeAuthority:v,normalizePercentEncoding:b,normalizePathEncoding:w,escapePreservingEscapes:E,reescapeHostDelimiters:S,isIPv4:$,nonSimpleDomain:P}=p(6138);const{SCHEMES:x,getSchemeHandler:R}=p(8415);function normalize(t,u){if(typeof t==="string"){t=normalizeString(t,u)}else if(typeof t==="object"){t=parse(serialize(t,u),u)}return t}function resolve(t,u,p){const m=p?Object.assign({scheme:"null"},p):{scheme:"null"};const{parsed:g,malformedAuthorityOrPort:v}=parseWithStatus(t,m);const{parsed:b,malformedAuthorityOrPort:w}=parseWithStatus(u,m);if(v||w){throw new Error(g.error||b.error||"URI is malformed.")}const E=resolveComponent(g,b,m,true);m.skipEscape=true;return serialize(E,m)}function resolveComponent(t,u,p,m){const v={};if(!m){t=parse(serialize(t,p),p);u=parse(serialize(u,p),p)}p=p||{};if(!p.tolerant&&u.scheme){v.scheme=u.scheme;v.userinfo=u.userinfo;v.host=u.host;v.port=u.port;v.path=g(u.path||"");v.query=u.query}else{if(u.userinfo!==undefined||u.host!==undefined||u.port!==undefined){v.userinfo=u.userinfo;v.host=u.host;v.port=u.port;v.path=g(u.path||"");v.query=u.query}else{if(!u.path){v.path=t.path;if(u.query!==undefined){v.query=u.query}else{v.query=t.query}}else{if(u.path[0]==="/"){v.path=g(u.path)}else{if((t.userinfo!==undefined||t.host!==undefined||t.port!==undefined)&&!t.path){v.path="/"+u.path}else if(!t.path){v.path=u.path}else{v.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+u.path}v.path=g(v.path)}v.query=u.query}v.userinfo=t.userinfo;v.host=t.host;v.port=t.port}v.scheme=t.scheme}v.fragment=u.fragment;return v}function equal(t,u,p){const m=normalizeComparableURI(t,p);const g=normalizeComparableURI(u,p);return m!==undefined&&g!==undefined&&m.toLowerCase()===g.toLowerCase()}function serialize(t,u){const p={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""};const m=Object.assign({},u);const w=[];const S=R(m.scheme||p.scheme);if(S&&S.serialize)S.serialize(p,m);if(p.path!==undefined){if(!m.skipEscape){p.path=E(p.path);if(p.scheme!==undefined){p.path=p.path.split("%3A").join(":")}}else{p.path=b(p.path)}}if(m.reference!=="suffix"&&p.scheme){w.push(p.scheme,":")}const $=v(p);if($!==undefined){if(m.reference!=="suffix"){w.push("//")}w.push($);if(p.path&&p.path[0]!=="/"){w.push("/")}}if(p.path!==undefined){let t=p.path;if(!m.absolutePath&&(!S||!S.absolutePath)){t=g(t)}if($===undefined&&t[0]==="/"&&t[1]==="/"){t="/%2F"+t.slice(2)}w.push(t)}if(p.query!==undefined){w.push("?",p.query)}if(p.fragment!==undefined){w.push("#",p.fragment)}return w.join("")}const O=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;const A=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;const k=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function getParseError(t,u){if(u[2]!==undefined&&t.path&&t.path[0]!=="/"){return'URI path must start with "/" when authority is present.'}if(typeof t.port==="number"&&(t.port<0||t.port>65535)){return"URI port is malformed."}return undefined}function parseWithStatus(t,u){const p=Object.assign({},u);const g={scheme:undefined,userinfo:undefined,host:"",port:undefined,path:"",query:undefined,fragment:undefined};let v=false;let b=false;if(p.reference==="suffix"){if(p.scheme){t=p.scheme+":"+t}else{t="//"+t}}const E=t.match(A);if(E!==null&&E[1].indexOf("\\")!==-1){g.error="URI authority must not contain a literal backslash.";v=true}const x=t.match(k);if(x!==null){const t=x[1];const u=t.replace(/[\t\n\r]/g,"");if(u.length>=2){if(u.slice(0,2)!=="//"){g.error=g.error||"URI authority must not contain a literal backslash.";v=true}else if(t.length!==u.length){g.error=g.error||"URI authority introducer must not contain whitespace.";v=true}}}const T=t.match(O);if(T){g.scheme=T[1];g.userinfo=T[3];g.host=T[4];g.port=parseInt(T[5],10);g.path=T[6]||"";g.query=T[7];g.fragment=T[8];if(isNaN(g.port)){g.port=T[5]}const u=getParseError(g,T);if(u!==undefined){g.error=g.error||u;v=true}if(g.host){const t=$(g.host);if(t===false){const t=m(g.host);g.host=t.host.toLowerCase();b=t.isIPV6}else{b=true}}if(g.scheme===undefined&&g.userinfo===undefined&&g.host===undefined&&g.port===undefined&&g.query===undefined&&!g.path){g.reference="same-document"}else if(g.scheme===undefined){g.reference="relative"}else if(g.fragment===undefined){g.reference="absolute"}else{g.reference="uri"}if(p.reference&&p.reference!=="suffix"&&p.reference!==g.reference){g.error=g.error||"URI is not a "+p.reference+" reference."}const E=R(p.scheme||g.scheme);if(!p.unicodeSupport&&(!E||!E.unicodeSupport)){if(g.host&&(p.domainHost||E&&E.domainHost)&&b===false&&P(g.host)){try{g.host=new URL("http://"+g.host).hostname}catch(t){g.error=g.error||"Host's domain name can not be converted to ASCII: "+t}}}if(!E||E&&!E.skipNormalize){if(t.indexOf("%")!==-1){if(g.scheme!==undefined){g.scheme=unescape(g.scheme)}if(g.host!==undefined){g.host=S(unescape(g.host),b)}}if(g.path){g.path=w(g.path)}if(g.fragment){try{g.fragment=encodeURI(decodeURIComponent(g.fragment))}catch{g.error=g.error||"URI malformed"}}}if(E&&E.parse){E.parse(g,p)}}else{g.error=g.error||"URI can not be parsed."}return{parsed:g,malformedAuthorityOrPort:v}}function parse(t,u){return parseWithStatus(t,u).parsed}function normalizeString(t,u){return normalizeStringWithStatus(t,u).normalized}function normalizeStringWithStatus(t,u){const{parsed:p,malformedAuthorityOrPort:m}=parseWithStatus(t,u);return{normalized:m?t:serialize(p,u),malformedAuthorityOrPort:m}}function normalizeComparableURI(t,u){if(typeof t==="string"){const{normalized:p,malformedAuthorityOrPort:m}=normalizeStringWithStatus(t,u);return m?undefined:p}if(typeof t==="object"){return serialize(t,u)}}const T={SCHEMES:x,normalize:normalize,resolve:resolve,resolveComponent:resolveComponent,equal:equal,serialize:serialize,parse:parse};t.exports=T;t.exports["default"]=T;t.exports.fastUri=T},8415:(t,u,p)=>{"use strict";const{isUUID:m}=p(6138);const g=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;const v=["http","https","ws","wss","urn","urn:uuid"];function isValidSchemeName(t){return v.indexOf(t)!==-1}function wsIsSecure(t){if(t.secure===true){return true}else if(t.secure===false){return false}else if(t.scheme){return t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S")}else{return false}}function httpParse(t){if(!t.host){t.error=t.error||"HTTP URIs must have a host."}return t}function httpSerialize(t){const u=String(t.scheme).toLowerCase()==="https";if(t.port===(u?443:80)||t.port===""){t.port=undefined}if(!t.path){t.path="/"}return t}function wsParse(t){t.secure=wsIsSecure(t);t.resourceName=(t.path||"/")+(t.query?"?"+t.query:"");t.path=undefined;t.query=undefined;return t}function wsSerialize(t){if(t.port===(wsIsSecure(t)?443:80)||t.port===""){t.port=undefined}if(typeof t.secure==="boolean"){t.scheme=t.secure?"wss":"ws";t.secure=undefined}if(t.resourceName){const[u,p]=t.resourceName.split("?");t.path=u&&u!=="/"?u:undefined;t.query=p;t.resourceName=undefined}t.fragment=undefined;return t}function urnParse(t,u){if(!t.path){t.error="URN can not be parsed";return t}const p=t.path.match(g);if(p){const m=u.scheme||t.scheme||"urn";t.nid=p[1].toLowerCase();t.nss=p[2];const g=`${m}:${u.nid||t.nid}`;const v=getSchemeHandler(g);t.path=undefined;if(v){t=v.parse(t,u)}}else{t.error=t.error||"URN can not be parsed."}return t}function urnSerialize(t,u){if(t.nid===undefined){throw new Error("URN without nid cannot be serialized")}const p=u.scheme||t.scheme||"urn";const m=t.nid.toLowerCase();const g=`${p}:${u.nid||m}`;const v=getSchemeHandler(g);if(v){t=v.serialize(t,u)}const b=t;const w=t.nss;b.path=`${m||u.nid}:${w}`;u.skipEscape=true;return b}function urnuuidParse(t,u){const p=t;p.uuid=p.nss;p.nss=undefined;if(!u.tolerant&&(!p.uuid||!m(p.uuid))){p.error=p.error||"UUID is not valid."}return p}function urnuuidSerialize(t){const u=t;u.nss=(t.uuid||"").toLowerCase();return u}const b={scheme:"http",domainHost:true,parse:httpParse,serialize:httpSerialize};const w={scheme:"https",domainHost:b.domainHost,parse:httpParse,serialize:httpSerialize};const E={scheme:"ws",domainHost:true,parse:wsParse,serialize:wsSerialize};const S={scheme:"wss",domainHost:E.domainHost,parse:E.parse,serialize:E.serialize};const $={scheme:"urn",parse:urnParse,serialize:urnSerialize,skipNormalize:true};const P={scheme:"urn:uuid",parse:urnuuidParse,serialize:urnuuidSerialize,skipNormalize:true};const x={http:b,https:w,ws:E,wss:S,urn:$,"urn:uuid":P};Object.setPrototypeOf(x,null);function getSchemeHandler(t){return t&&(x[t]||x[t.toLowerCase()])||undefined}t.exports={wsIsSecure:wsIsSecure,SCHEMES:x,isValidSchemeName:isValidSchemeName,getSchemeHandler:getSchemeHandler}},6138:t=>{"use strict";const u=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);const p=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);const m=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);const g=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);const v=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function stringArrayToHexStripped(t){let u="";let p=0;let m=0;for(m=0;m<t.length;m++){p=t[m].charCodeAt(0);if(p===48){continue}if(!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102)){return""}u+=t[m];break}for(m+=1;m<t.length;m++){p=t[m].charCodeAt(0);if(!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102)){return""}u+=t[m]}return u}const b=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function consumeIsZone(t){t.length=0;return true}function consumeHextets(t,u,p){if(t.length){const m=stringArrayToHexStripped(t);if(m!==""){u.push(m)}else{p.error=true;return false}t.length=0}return true}function getIPV6(t){let u=0;const p={error:false,address:"",zone:""};const m=[];const g=[];let v=false;let b=false;let w=consumeHextets;for(let E=0;E<t.length;E++){const S=t[E];if(S==="["||S==="]"){continue}if(S===":"){if(v===true){b=true}if(!w(g,m,p)){break}if(++u>7){p.error=true;break}if(E>0&&t[E-1]===":"){v=true}m.push(":");continue}else if(S==="%"){if(!w(g,m,p)){break}w=consumeIsZone}else{g.push(S);continue}}if(g.length){if(w===consumeIsZone){p.zone=g.join("")}else if(b){m.push(g.join(""))}else{m.push(stringArrayToHexStripped(g))}}p.address=m.join("");return p}function normalizeIPv6(t){if(findToken(t,":")<2){return{host:t,isIPV6:false}}const u=getIPV6(t);if(!u.error){let t=u.address;let p=u.address;if(u.zone){t+="%"+u.zone;p+="%25"+u.zone}return{host:t,isIPV6:true,escapedHost:p}}else{return{host:t,isIPV6:false}}}function findToken(t,u){let p=0;for(let m=0;m<t.length;m++){if(t[m]===u)p++}return p}function removeDotSegments(t){let u=t;const p=[];let m=-1;let g=0;while(g=u.length){if(g===1){if(u==="."){break}else if(u==="/"){p.push("/");break}else{p.push(u);break}}else if(g===2){if(u[0]==="."){if(u[1]==="."){break}else if(u[1]==="/"){u=u.slice(2);continue}}else if(u[0]==="/"){if(u[1]==="."||u[1]==="/"){p.push("/");break}}}else if(g===3){if(u==="/.."){if(p.length!==0){p.pop()}p.push("/");break}}if(u[0]==="."){if(u[1]==="."){if(u[2]==="/"){u=u.slice(3);continue}}else if(u[1]==="/"){u=u.slice(2);continue}}else if(u[0]==="/"){if(u[1]==="."){if(u[2]==="/"){u=u.slice(2);continue}else if(u[2]==="."){if(u[3]==="/"){u=u.slice(3);if(p.length!==0){p.pop()}continue}}}}if((m=u.indexOf("/",1))===-1){p.push(u);break}else{p.push(u.slice(0,m));u=u.slice(m)}}return p.join("")}const w={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"};const E=/[@/?#:]/g;const S=/[@/?#]/g;function reescapeHostDelimiters(t,u){const p=u?S:E;p.lastIndex=0;return t.replace(p,(t=>w[t]))}function normalizePercentEncoding(t,u=false){if(t.indexOf("%")===-1){return t}let p="";for(let v=0;v<t.length;v++){if(t[v]==="%"&&v+2<t.length){const b=t.slice(v+1,v+3);if(m(b)){const t=b.toUpperCase();const m=String.fromCharCode(parseInt(t,16));if(u&&g(m)){p+=m}else{p+="%"+t}v+=2;continue}}p+=t[v]}return p}function normalizePathEncoding(t){let u="";for(let p=0;p<t.length;p++){if(t[p]==="%"&&p+2<t.length){const v=t.slice(p+1,p+3);if(m(v)){const t=v.toUpperCase();const m=String.fromCharCode(parseInt(t,16));if(m!=="."&&g(m)){u+=m}else{u+="%"+t}p+=2;continue}}if(v(t[p])){u+=t[p]}else{u+=escape(t[p])}}return u}function escapePreservingEscapes(t){let u="";for(let p=0;p<t.length;p++){if(t[p]==="%"&&p+2<t.length){const g=t.slice(p+1,p+3);if(m(g)){u+="%"+g.toUpperCase();p+=2;continue}}u+=escape(t[p])}return u}function recomposeAuthority(t){const u=[];if(t.userinfo!==undefined){u.push(t.userinfo);u.push("@")}if(t.host!==undefined){let m=unescape(t.host);if(!p(m)){const t=normalizeIPv6(m);if(t.isIPV6===true){m=`[${t.escapedHost}]`}else{m=reescapeHostDelimiters(m,false)}}u.push(m)}if(typeof t.port==="number"||typeof t.port==="string"){u.push(":");u.push(String(t.port))}return u.length?u.join(""):undefined}t.exports={nonSimpleDomain:b,recomposeAuthority:recomposeAuthority,reescapeHostDelimiters:reescapeHostDelimiters,normalizePercentEncoding:normalizePercentEncoding,normalizePathEncoding:normalizePathEncoding,escapePreservingEscapes:escapePreservingEscapes,removeDotSegments:removeDotSegments,isIPv4:p,isUUID:u,normalizeIPv6:normalizeIPv6,stringArrayToHexStripped:stringArrayToHexStripped}},8909:(t,u,p)=>{const{Argument:m}=p(9154);const{Command:g}=p(4348);const{CommanderError:v,InvalidArgumentError:b}=p(1135);const{Help:w}=p(9754);const{Option:E}=p(5240);u.DM=new g;u.gu=t=>new g(t);u.Ww=(t,u)=>new E(t,u);u.er=(t,u)=>new m(t,u);u.uB=g;u.c$=E;u.ef=m;u._V=w;u.b7=v;u.Di=b;u.a2=b},9154:(t,u,p)=>{const{InvalidArgumentError:m}=p(1135);class Argument{constructor(t,u){this.description=u||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(t[0]){case"<":this.required=true;this._name=t.slice(1,-1);break;case"[":this.required=false;this._name=t.slice(1,-1);break;default:this.required=true;this._name=t;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(t,u){if(u===this.defaultValue||!Array.isArray(u)){return[t]}return u.concat(t)}default(t,u){this.defaultValue=t;this.defaultValueDescription=u;return this}argParser(t){this.parseArg=t;return this}choices(t){this.argChoices=t.slice();this.parseArg=(t,u)=>{if(!this.argChoices.includes(t)){throw new m(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,u)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(t){const u=t.name()+(t.variadic===true?"...":"");return t.required?"<"+u+">":"["+u+"]"}u.Argument=Argument;u.humanReadableArgName=humanReadableArgName},4348:(t,u,p)=>{const m=p(8474).EventEmitter;const g=p(1421);const v=p(6760);const b=p(3024);const w=p(1708);const{Argument:E,humanReadableArgName:S}=p(9154);const{CommanderError:$}=p(1135);const{Help:P}=p(9754);const{Option:x,DualOptions:R}=p(5240);const{suggestSimilar:O}=p(5030);class Command extends m{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this.registeredArguments=[];this._args=this.registeredArguments;this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=t||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._executableDir=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._summary="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=true;this._outputConfiguration={writeOut:t=>w.stdout.write(t),writeErr:t=>w.stderr.write(t),getOutHelpWidth:()=>w.stdout.isTTY?w.stdout.columns:undefined,getErrHelpWidth:()=>w.stderr.isTTY?w.stderr.columns:undefined,outputError:(t,u)=>u(t)};this._hidden=false;this._helpOption=undefined;this._addImplicitHelpCommand=undefined;this._helpCommand=undefined;this._helpConfiguration={}}copyInheritedSettings(t){this._outputConfiguration=t._outputConfiguration;this._helpOption=t._helpOption;this._helpCommand=t._helpCommand;this._helpConfiguration=t._helpConfiguration;this._exitCallback=t._exitCallback;this._storeOptionsAsProperties=t._storeOptionsAsProperties;this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue;this._allowExcessArguments=t._allowExcessArguments;this._enablePositionalOptions=t._enablePositionalOptions;this._showHelpAfterError=t._showHelpAfterError;this._showSuggestionAfterError=t._showSuggestionAfterError;return this}_getCommandAndAncestors(){const t=[];for(let u=this;u;u=u.parent){t.push(u)}return t}command(t,u,p){let m=u;let g=p;if(typeof m==="object"&&m!==null){g=m;m=null}g=g||{};const[,v,b]=t.match(/([^ ]+) *(.*)/);const w=this.createCommand(v);if(m){w.description(m);w._executableHandler=true}if(g.isDefault)this._defaultCommandName=w._name;w._hidden=!!(g.noHelp||g.hidden);w._executableFile=g.executableFile||null;if(b)w.arguments(b);this._registerCommand(w);w.parent=this;w.copyInheritedSettings(this);if(m)return this;return w}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new P,this.configureHelp())}configureHelp(t){if(t===undefined)return this._helpConfiguration;this._helpConfiguration=t;return this}configureOutput(t){if(t===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,t);return this}showHelpAfterError(t=true){if(typeof t!=="string")t=!!t;this._showHelpAfterError=t;return this}showSuggestionAfterError(t=true){this._showSuggestionAfterError=!!t;return this}addCommand(t,u){if(!t._name){throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`)}u=u||{};if(u.isDefault)this._defaultCommandName=t._name;if(u.noHelp||u.hidden)t._hidden=true;this._registerCommand(t);t.parent=this;t._checkForBrokenPassThrough();return this}createArgument(t,u){return new E(t,u)}argument(t,u,p,m){const g=this.createArgument(t,u);if(typeof p==="function"){g.default(m).argParser(p)}else{g.default(p)}this.addArgument(g);return this}arguments(t){t.trim().split(/ +/).forEach((t=>{this.argument(t)}));return this}addArgument(t){const u=this.registeredArguments.slice(-1)[0];if(u&&u.variadic){throw new Error(`only the last argument can be variadic '${u.name()}'`)}if(t.required&&t.defaultValue!==undefined&&t.parseArg===undefined){throw new Error(`a default value for a required argument is never used: '${t.name()}'`)}this.registeredArguments.push(t);return this}helpCommand(t,u){if(typeof t==="boolean"){this._addImplicitHelpCommand=t;return this}t=t??"help [command]";const[,p,m]=t.match(/([^ ]+) *(.*)/);const g=u??"display help for command";const v=this.createCommand(p);v.helpOption(false);if(m)v.arguments(m);if(g)v.description(g);this._addImplicitHelpCommand=true;this._helpCommand=v;return this}addHelpCommand(t,u){if(typeof t!=="object"){this.helpCommand(t,u);return this}this._addImplicitHelpCommand=true;this._helpCommand=t;return this}_getHelpCommand(){const t=this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"));if(t){if(this._helpCommand===undefined){this.helpCommand(undefined,undefined)}return this._helpCommand}return null}hook(t,u){const p=["preSubcommand","preAction","postAction"];if(!p.includes(t)){throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${p.join("', '")}'`)}if(this._lifeCycleHooks[t]){this._lifeCycleHooks[t].push(u)}else{this._lifeCycleHooks[t]=[u]}return this}exitOverride(t){if(t){this._exitCallback=t}else{this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync"){throw t}else{}}}return this}_exit(t,u,p){if(this._exitCallback){this._exitCallback(new $(t,u,p))}w.exit(t)}action(t){const listener=u=>{const p=this.registeredArguments.length;const m=u.slice(0,p);if(this._storeOptionsAsProperties){m[p]=this}else{m[p]=this.opts()}m.push(this);return t.apply(this,m)};this._actionHandler=listener;return this}createOption(t,u){return new x(t,u)}_callParseArg(t,u,p,m){try{return t.parseArg(u,p)}catch(t){if(t.code==="commander.invalidArgument"){const u=`${m} ${t.message}`;this.error(u,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(t){const u=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(u){const p=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${p}'\n- already used by option '${u.flags}'`)}this.options.push(t)}_registerCommand(t){const knownBy=t=>[t.name()].concat(t.aliases());const u=knownBy(t).find((t=>this._findCommand(t)));if(u){const p=knownBy(this._findCommand(u)).join("|");const m=knownBy(t).join("|");throw new Error(`cannot add command '${m}' as already have command '${p}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);const u=t.name();const p=t.attributeName();if(t.negate){const u=t.long.replace(/^--no-/,"--");if(!this._findOption(u)){this.setOptionValueWithSource(p,t.defaultValue===undefined?true:t.defaultValue,"default")}}else if(t.defaultValue!==undefined){this.setOptionValueWithSource(p,t.defaultValue,"default")}const handleOptionValue=(u,m,g)=>{if(u==null&&t.presetArg!==undefined){u=t.presetArg}const v=this.getOptionValue(p);if(u!==null&&t.parseArg){u=this._callParseArg(t,u,v,m)}else if(u!==null&&t.variadic){u=t._concatValue(u,v)}if(u==null){if(t.negate){u=false}else if(t.isBoolean()||t.optional){u=true}else{u=""}}this.setOptionValueWithSource(p,u,g)};this.on("option:"+u,(u=>{const p=`error: option '${t.flags}' argument '${u}' is invalid.`;handleOptionValue(u,p,"cli")}));if(t.envVar){this.on("optionEnv:"+u,(u=>{const p=`error: option '${t.flags}' value '${u}' from env '${t.envVar}' is invalid.`;handleOptionValue(u,p,"env")}))}return this}_optionEx(t,u,p,m,g){if(typeof u==="object"&&u instanceof x){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const v=this.createOption(u,p);v.makeOptionMandatory(!!t.mandatory);if(typeof m==="function"){v.default(g).argParser(m)}else if(m instanceof RegExp){const t=m;m=(u,p)=>{const m=t.exec(u);return m?m[0]:p};v.default(g).argParser(m)}else{v.default(m)}return this.addOption(v)}option(t,u,p,m){return this._optionEx({},t,u,p,m)}requiredOption(t,u,p,m){return this._optionEx({mandatory:true},t,u,p,m)}combineFlagAndOptionalValue(t=true){this._combineFlagAndOptionalValue=!!t;return this}allowUnknownOption(t=true){this._allowUnknownOption=!!t;return this}allowExcessArguments(t=true){this._allowExcessArguments=!!t;return this}enablePositionalOptions(t=true){this._enablePositionalOptions=!!t;return this}passThroughOptions(t=true){this._passThroughOptions=!!t;this._checkForBrokenPassThrough();return this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions){throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}}storeOptionsAsProperties(t=true){if(this.options.length){throw new Error("call .storeOptionsAsProperties() before adding options")}if(Object.keys(this._optionValues).length){throw new Error("call .storeOptionsAsProperties() before setting option values")}this._storeOptionsAsProperties=!!t;return this}getOptionValue(t){if(this._storeOptionsAsProperties){return this[t]}return this._optionValues[t]}setOptionValue(t,u){return this.setOptionValueWithSource(t,u,undefined)}setOptionValueWithSource(t,u,p){if(this._storeOptionsAsProperties){this[t]=u}else{this._optionValues[t]=u}this._optionValueSources[t]=p;return this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let u;this._getCommandAndAncestors().forEach((p=>{if(p.getOptionValueSource(t)!==undefined){u=p.getOptionValueSource(t)}}));return u}_prepareUserArgs(t,u){if(t!==undefined&&!Array.isArray(t)){throw new Error("first parameter to parse must be array or undefined")}u=u||{};if(t===undefined&&u.from===undefined){if(w.versions?.electron){u.from="electron"}const t=w.execArgv??[];if(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print")){u.from="eval"}}if(t===undefined){t=w.argv}this.rawArgs=t.slice();let p;switch(u.from){case undefined:case"node":this._scriptPath=t[1];p=t.slice(2);break;case"electron":if(w.defaultApp){this._scriptPath=t[1];p=t.slice(2)}else{p=t.slice(1)}break;case"user":p=t.slice(0);break;case"eval":p=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${u.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);this._name=this._name||"program";return p}parse(t,u){const p=this._prepareUserArgs(t,u);this._parseCommand([],p);return this}async parseAsync(t,u){const p=this._prepareUserArgs(t,u);await this._parseCommand([],p);return this}_executeSubCommand(t,u){u=u.slice();let p=false;const m=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,u){const p=v.resolve(t,u);if(b.existsSync(p))return p;if(m.includes(v.extname(u)))return undefined;const g=m.find((t=>b.existsSync(`${p}${t}`)));if(g)return`${p}${g}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let E=t._executableFile||`${this._name}-${t._name}`;let S=this._executableDir||"";if(this._scriptPath){let t;try{t=b.realpathSync(this._scriptPath)}catch(u){t=this._scriptPath}S=v.resolve(v.dirname(t),S)}if(S){let u=findFile(S,E);if(!u&&!t._executableFile&&this._scriptPath){const p=v.basename(this._scriptPath,v.extname(this._scriptPath));if(p!==this._name){u=findFile(S,`${p}-${t._name}`)}}E=u||E}p=m.includes(v.extname(E));let P;if(w.platform!=="win32"){if(p){u.unshift(E);u=incrementNodeInspectorPort(w.execArgv).concat(u);P=g.spawn(w.argv[0],u,{stdio:"inherit"})}else{P=g.spawn(E,u,{stdio:"inherit"})}}else{u.unshift(E);u=incrementNodeInspectorPort(w.execArgv).concat(u);P=g.spawn(w.execPath,u,{stdio:"inherit"})}if(!P.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{w.on(t,(()=>{if(P.killed===false&&P.exitCode===null){P.kill(t)}}))}))}const x=this._exitCallback;P.on("close",(t=>{t=t??1;if(!x){w.exit(t)}else{x(new $(t,"commander.executeSubCommandAsync","(close)"))}}));P.on("error",(u=>{if(u.code==="ENOENT"){const u=S?`searched for local subcommand relative to directory '${S}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const p=`'${E}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${u}`;throw new Error(p)}else if(u.code==="EACCES"){throw new Error(`'${E}' not executable`)}if(!x){w.exit(1)}else{const t=new $(1,"commander.executeSubCommandAsync","(error)");t.nestedError=u;x(t)}}));this.runningCommand=P}_dispatchSubcommand(t,u,p){const m=this._findCommand(t);if(!m)this.help({error:true});let g;g=this._chainOrCallSubCommandHook(g,m,"preSubcommand");g=this._chainOrCall(g,(()=>{if(m._executableHandler){this._executeSubCommand(m,u.concat(p))}else{return m._parseCommand(u,p)}}));return g}_dispatchHelpCommand(t){if(!t){this.help()}const u=this._findCommand(t);if(u&&!u._executableHandler){u.help()}return this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach(((t,u)=>{if(t.required&&this.args[u]==null){this.missingArgument(t.name())}}));if(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic){return}if(this.args.length>this.registeredArguments.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(t,u,p)=>{let m=u;if(u!==null&&t.parseArg){const g=`error: command-argument value '${u}' is invalid for argument '${t.name()}'.`;m=this._callParseArg(t,u,p,g)}return m};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((u,p)=>{let m=u.defaultValue;if(u.variadic){if(p<this.args.length){m=this.args.slice(p);if(u.parseArg){m=m.reduce(((t,p)=>myParseArg(u,p,t)),u.defaultValue)}}else if(m===undefined){m=[]}}else if(p<this.args.length){m=this.args[p];if(u.parseArg){m=myParseArg(u,m,u.defaultValue)}}t[p]=m}));this.processedArgs=t}_chainOrCall(t,u){if(t&&t.then&&typeof t.then==="function"){return t.then((()=>u()))}return u()}_chainOrCallHooks(t,u){let p=t;const m=[];this._getCommandAndAncestors().reverse().filter((t=>t._lifeCycleHooks[u]!==undefined)).forEach((t=>{t._lifeCycleHooks[u].forEach((u=>{m.push({hookedCommand:t,callback:u})}))}));if(u==="postAction"){m.reverse()}m.forEach((t=>{p=this._chainOrCall(p,(()=>t.callback(t.hookedCommand,this)))}));return p}_chainOrCallSubCommandHook(t,u,p){let m=t;if(this._lifeCycleHooks[p]!==undefined){this._lifeCycleHooks[p].forEach((t=>{m=this._chainOrCall(m,(()=>t(this,u)))}))}return m}_parseCommand(t,u){const p=this.parseOptions(u);this._parseOptionsEnv();this._parseOptionsImplied();t=t.concat(p.operands);u=p.unknown;this.args=t.concat(u);if(t&&this._findCommand(t[0])){return this._dispatchSubcommand(t[0],t.slice(1),u)}if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name()){return this._dispatchHelpCommand(t[1])}if(this._defaultCommandName){this._outputHelpIfRequested(u);return this._dispatchSubcommand(this._defaultCommandName,t,u)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}this._outputHelpIfRequested(p.unknown);this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();const checkForUnknownOptions=()=>{if(p.unknown.length>0){this.unknownOption(p.unknown[0])}};const m=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let p;p=this._chainOrCallHooks(p,"preAction");p=this._chainOrCall(p,(()=>this._actionHandler(this.processedArgs)));if(this.parent){p=this._chainOrCall(p,(()=>{this.parent.emit(m,t,u)}))}p=this._chainOrCallHooks(p,"postAction");return p}if(this.parent&&this.parent.listenerCount(m)){checkForUnknownOptions();this._processArguments();this.parent.emit(m,t,u)}else if(t.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",t,u)}if(this.listenerCount("command:*")){this.emit("command:*",t,u)}else if(this.commands.length){this.unknownCommand()}else{checkForUnknownOptions();this._processArguments()}}else if(this.commands.length){checkForUnknownOptions();this.help({error:true})}else{checkForUnknownOptions();this._processArguments()}}_findCommand(t){if(!t)return undefined;return this.commands.find((u=>u._name===t||u._aliases.includes(t)))}_findOption(t){return this.options.find((u=>u.is(t)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((t=>{t.options.forEach((u=>{if(u.mandatory&&t.getOptionValue(u.attributeName())===undefined){t.missingMandatoryOptionValue(u)}}))}))}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const u=t.attributeName();if(this.getOptionValue(u)===undefined){return false}return this.getOptionValueSource(u)!=="default"}));const u=t.filter((t=>t.conflictsWith.length>0));u.forEach((u=>{const p=t.find((t=>u.conflictsWith.includes(t.attributeName())));if(p){this._conflictingOption(u,p)}}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((t=>{t._checkForConflictingLocalOptions()}))}parseOptions(t){const u=[];const p=[];let m=u;const g=t.slice();function maybeOption(t){return t.length>1&&t[0]==="-"}let v=null;while(g.length){const t=g.shift();if(t==="--"){if(m===p)m.push(t);m.push(...g);break}if(v&&!maybeOption(t)){this.emit(`option:${v.name()}`,t);continue}v=null;if(maybeOption(t)){const u=this._findOption(t);if(u){if(u.required){const t=g.shift();if(t===undefined)this.optionMissingArgument(u);this.emit(`option:${u.name()}`,t)}else if(u.optional){let t=null;if(g.length>0&&!maybeOption(g[0])){t=g.shift()}this.emit(`option:${u.name()}`,t)}else{this.emit(`option:${u.name()}`)}v=u.variadic?u:null;continue}}if(t.length>2&&t[0]==="-"&&t[1]!=="-"){const u=this._findOption(`-${t[1]}`);if(u){if(u.required||u.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${u.name()}`,t.slice(2))}else{this.emit(`option:${u.name()}`);g.unshift(`-${t.slice(2)}`)}continue}}if(/^--[^=]+=/.test(t)){const u=t.indexOf("=");const p=this._findOption(t.slice(0,u));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,t.slice(u+1));continue}}if(maybeOption(t)){m=p}if((this._enablePositionalOptions||this._passThroughOptions)&&u.length===0&&p.length===0){if(this._findCommand(t)){u.push(t);if(g.length>0)p.push(...g);break}else if(this._getHelpCommand()&&t===this._getHelpCommand().name()){u.push(t);if(g.length>0)u.push(...g);break}else if(this._defaultCommandName){p.push(t);if(g.length>0)p.push(...g);break}}if(this._passThroughOptions){m.push(t);if(g.length>0)m.push(...g);break}m.push(t)}return{operands:u,unknown:p}}opts(){if(this._storeOptionsAsProperties){const t={};const u=this.options.length;for(let p=0;p<u;p++){const u=this.options[p].attributeName();t[u]=u===this._versionOptionName?this._version:this[u]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(((t,u)=>Object.assign(t,u.opts())),{})}error(t,u){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr);if(typeof this._showHelpAfterError==="string"){this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`)}else if(this._showHelpAfterError){this._outputConfiguration.writeErr("\n");this.outputHelp({error:true})}const p=u||{};const m=p.exitCode||1;const g=p.code||"commander.error";this._exit(m,g,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in w.env){const u=t.attributeName();if(this.getOptionValue(u)===undefined||["default","config","env"].includes(this.getOptionValueSource(u))){if(t.required||t.optional){this.emit(`optionEnv:${t.name()}`,w.env[t.envVar])}else{this.emit(`optionEnv:${t.name()}`)}}}}))}_parseOptionsImplied(){const t=new R(this.options);const hasCustomOptionValue=t=>this.getOptionValue(t)!==undefined&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((u=>u.implied!==undefined&&hasCustomOptionValue(u.attributeName())&&t.valueFromOption(this.getOptionValue(u.attributeName()),u))).forEach((t=>{Object.keys(t.implied).filter((t=>!hasCustomOptionValue(t))).forEach((u=>{this.setOptionValueWithSource(u,t.implied[u],"implied")}))}))}missingArgument(t){const u=`error: missing required argument '${t}'`;this.error(u,{code:"commander.missingArgument"})}optionMissingArgument(t){const u=`error: option '${t.flags}' argument missing`;this.error(u,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const u=`error: required option '${t.flags}' not specified`;this.error(u,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,u){const findBestOptionFromValue=t=>{const u=t.attributeName();const p=this.getOptionValue(u);const m=this.options.find((t=>t.negate&&u===t.attributeName()));const g=this.options.find((t=>!t.negate&&u===t.attributeName()));if(m&&(m.presetArg===undefined&&p===false||m.presetArg!==undefined&&p===m.presetArg)){return m}return g||t};const getErrorMessage=t=>{const u=findBestOptionFromValue(t);const p=u.attributeName();const m=this.getOptionValueSource(p);if(m==="env"){return`environment variable '${u.envVar}'`}return`option '${u.flags}'`};const p=`error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(u)}`;this.error(p,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let u="";if(t.startsWith("--")&&this._showSuggestionAfterError){let p=[];let m=this;do{const t=m.createHelp().visibleOptions(m).filter((t=>t.long)).map((t=>t.long));p=p.concat(t);m=m.parent}while(m&&!m._enablePositionalOptions);u=O(t,p)}const p=`error: unknown option '${t}'${u}`;this.error(p,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const u=this.registeredArguments.length;const p=u===1?"":"s";const m=this.parent?` for '${this.name()}'`:"";const g=`error: too many arguments${m}. Expected ${u} argument${p} but got ${t.length}.`;this.error(g,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let u="";if(this._showSuggestionAfterError){const p=[];this.createHelp().visibleCommands(this).forEach((t=>{p.push(t.name());if(t.alias())p.push(t.alias())}));u=O(t,p)}const p=`error: unknown command '${t}'${u}`;this.error(p,{code:"commander.unknownCommand"})}version(t,u,p){if(t===undefined)return this._version;this._version=t;u=u||"-V, --version";p=p||"output the version number";const m=this.createOption(u,p);this._versionOptionName=m.attributeName();this._registerOption(m);this.on("option:"+m.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`);this._exit(0,"commander.version",t)}));return this}description(t,u){if(t===undefined&&u===undefined)return this._description;this._description=t;if(u){this._argsDescription=u}return this}summary(t){if(t===undefined)return this._summary;this._summary=t;return this}alias(t){if(t===undefined)return this._aliases[0];let u=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){u=this.commands[this.commands.length-1]}if(t===u._name)throw new Error("Command alias can't be the same as its name");const p=this.parent?._findCommand(t);if(p){const u=[p.name()].concat(p.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${u}'`)}u._aliases.push(t);return this}aliases(t){if(t===undefined)return this._aliases;t.forEach((t=>this.alias(t)));return this}usage(t){if(t===undefined){if(this._usage)return this._usage;const t=this.registeredArguments.map((t=>S(t)));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}this._usage=t;return this}name(t){if(t===undefined)return this._name;this._name=t;return this}nameFromFilename(t){this._name=v.basename(t,v.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const u=this.createHelp();if(u.helpWidth===undefined){u.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return u.formatHelp(this,u)}_getHelpContext(t){t=t||{};const u={error:!!t.error};let p;if(u.error){p=t=>this._outputConfiguration.writeErr(t)}else{p=t=>this._outputConfiguration.writeOut(t)}u.write=t.write||p;u.command=this;return u}outputHelp(t){let u;if(typeof t==="function"){u=t;t=undefined}const p=this._getHelpContext(t);this._getCommandAndAncestors().reverse().forEach((t=>t.emit("beforeAllHelp",p)));this.emit("beforeHelp",p);let m=this.helpInformation(p);if(u){m=u(m);if(typeof m!=="string"&&!Buffer.isBuffer(m)){throw new Error("outputHelp callback must return a string or a Buffer")}}p.write(m);if(this._getHelpOption()?.long){this.emit(this._getHelpOption().long)}this.emit("afterHelp",p);this._getCommandAndAncestors().forEach((t=>t.emit("afterAllHelp",p)))}helpOption(t,u){if(typeof t==="boolean"){if(t){this._helpOption=this._helpOption??undefined}else{this._helpOption=null}return this}t=t??"-h, --help";u=u??"display help for command";this._helpOption=this.createOption(t,u);return this}_getHelpOption(){if(this._helpOption===undefined){this.helpOption(undefined,undefined)}return this._helpOption}addHelpOption(t){this._helpOption=t;return this}help(t){this.outputHelp(t);let u=w.exitCode||0;if(u===0&&t&&typeof t!=="function"&&t.error){u=1}this._exit(u,"commander.help","(outputHelp)")}addHelpText(t,u){const p=["beforeAll","before","after","afterAll"];if(!p.includes(t)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${p.join("', '")}'`)}const m=`${t}Help`;this.on(m,(t=>{let p;if(typeof u==="function"){p=u({error:t.error,command:t.command})}else{p=u}if(p){t.write(`${p}\n`)}}));return this}_outputHelpIfRequested(t){const u=this._getHelpOption();const p=u&&t.find((t=>u.is(t)));if(p){this.outputHelp();this._exit(0,"commander.helpDisplayed","(outputHelp)")}}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect")){return t}let u;let p="127.0.0.1";let m="9229";let g;if((g=t.match(/^(--inspect(-brk)?)$/))!==null){u=g[1]}else if((g=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){u=g[1];if(/^\d+$/.test(g[3])){m=g[3]}else{p=g[3]}}else if((g=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){u=g[1];p=g[3];m=g[4]}if(u&&m!=="0"){return`${u}=${p}:${parseInt(m)+1}`}return t}))}u.Command=Command},1135:(t,u)=>{class CommanderError extends Error{constructor(t,u,p){super(p);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=u;this.exitCode=t;this.nestedError=undefined}}class InvalidArgumentError extends CommanderError{constructor(t){super(1,"commander.invalidArgument",t);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name}}u.CommanderError=CommanderError;u.InvalidArgumentError=InvalidArgumentError},9754:(t,u,p)=>{const{humanReadableArgName:m}=p(9154);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false;this.showGlobalOptions=false}visibleCommands(t){const u=t.commands.filter((t=>!t._hidden));const p=t._getHelpCommand();if(p&&!p._hidden){u.push(p)}if(this.sortSubcommands){u.sort(((t,u)=>t.name().localeCompare(u.name())))}return u}compareOptions(t,u){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return getSortKey(t).localeCompare(getSortKey(u))}visibleOptions(t){const u=t.options.filter((t=>!t.hidden));const p=t._getHelpOption();if(p&&!p.hidden){const m=p.short&&t._findOption(p.short);const g=p.long&&t._findOption(p.long);if(!m&&!g){u.push(p)}else if(p.long&&!g){u.push(t.createOption(p.long,p.description))}else if(p.short&&!m){u.push(t.createOption(p.short,p.description))}}if(this.sortOptions){u.sort(this.compareOptions)}return u}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const u=[];for(let p=t.parent;p;p=p.parent){const t=p.options.filter((t=>!t.hidden));u.push(...t)}if(this.sortOptions){u.sort(this.compareOptions)}return u}visibleArguments(t){if(t._argsDescription){t.registeredArguments.forEach((u=>{u.description=u.description||t._argsDescription[u.name()]||""}))}if(t.registeredArguments.find((t=>t.description))){return t.registeredArguments}return[]}subcommandTerm(t){const u=t.registeredArguments.map((t=>m(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(u?" "+u:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,u){return u.visibleCommands(t).reduce(((t,p)=>Math.max(t,u.subcommandTerm(p).length)),0)}longestOptionTermLength(t,u){return u.visibleOptions(t).reduce(((t,p)=>Math.max(t,u.optionTerm(p).length)),0)}longestGlobalOptionTermLength(t,u){return u.visibleGlobalOptions(t).reduce(((t,p)=>Math.max(t,u.optionTerm(p).length)),0)}longestArgumentTermLength(t,u){return u.visibleArguments(t).reduce(((t,p)=>Math.max(t,u.argumentTerm(p).length)),0)}commandUsage(t){let u=t._name;if(t._aliases[0]){u=u+"|"+t._aliases[0]}let p="";for(let u=t.parent;u;u=u.parent){p=u.name()+" "+p}return p+u+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const u=[];if(t.argChoices){u.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){const p=t.required||t.optional||t.isBoolean()&&typeof t.defaultValue==="boolean";if(p){u.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}}if(t.presetArg!==undefined&&t.optional){u.push(`preset: ${JSON.stringify(t.presetArg)}`)}if(t.envVar!==undefined){u.push(`env: ${t.envVar}`)}if(u.length>0){return`${t.description} (${u.join(", ")})`}return t.description}argumentDescription(t){const u=[];if(t.argChoices){u.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){u.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}if(u.length>0){const p=`(${u.join(", ")})`;if(t.description){return`${t.description} ${p}`}return p}return t.description}formatHelp(t,u){const p=u.padWidth(t,u);const m=u.helpWidth||80;const g=2;const v=2;function formatItem(t,b){if(b){const w=`${t.padEnd(p+v)}${b}`;return u.wrap(w,m-g,p+v)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(g))}let b=[`Usage: ${u.commandUsage(t)}`,""];const w=u.commandDescription(t);if(w.length>0){b=b.concat([u.wrap(w,m,0),""])}const E=u.visibleArguments(t).map((t=>formatItem(u.argumentTerm(t),u.argumentDescription(t))));if(E.length>0){b=b.concat(["Arguments:",formatList(E),""])}const S=u.visibleOptions(t).map((t=>formatItem(u.optionTerm(t),u.optionDescription(t))));if(S.length>0){b=b.concat(["Options:",formatList(S),""])}if(this.showGlobalOptions){const p=u.visibleGlobalOptions(t).map((t=>formatItem(u.optionTerm(t),u.optionDescription(t))));if(p.length>0){b=b.concat(["Global Options:",formatList(p),""])}}const $=u.visibleCommands(t).map((t=>formatItem(u.subcommandTerm(t),u.subcommandDescription(t))));if($.length>0){b=b.concat(["Commands:",formatList($),""])}return b.join("\n")}padWidth(t,u){return Math.max(u.longestOptionTermLength(t,u),u.longestGlobalOptionTermLength(t,u),u.longestSubcommandTermLength(t,u),u.longestArgumentTermLength(t,u))}wrap(t,u,p,m=40){const g=" \\f\\t\\v - \ufeff";const v=new RegExp(`[\\n][${g}]+`);if(t.match(v))return t;const b=u-p;if(b<m)return t;const w=t.slice(0,p);const E=t.slice(p).replace("\r\n","\n");const S=" ".repeat(p);const $="";const P=`\\s${$}`;const x=new RegExp(`\n|.{1,${b-1}}([${P}]|$)|[^${P}]+?([${P}]|$)`,"g");const R=E.match(x)||[];return w+R.map(((t,u)=>{if(t==="\n")return"";return(u>0?S:"")+t.trimEnd()})).join("\n")}}u.Help=Help},5240:(t,u,p)=>{const{InvalidArgumentError:m}=p(1135);class Option{constructor(t,u){this.flags=t;this.description=u||"";this.required=t.includes("<");this.optional=t.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(t);this.mandatory=false;const p=splitOptionFlags(t);this.short=p.shortFlag;this.long=p.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.presetArg=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined;this.conflictsWith=[];this.implied=undefined}default(t,u){this.defaultValue=t;this.defaultValueDescription=u;return this}preset(t){this.presetArg=t;return this}conflicts(t){this.conflictsWith=this.conflictsWith.concat(t);return this}implies(t){let u=t;if(typeof t==="string"){u={[t]:true}}this.implied=Object.assign(this.implied||{},u);return this}env(t){this.envVar=t;return this}argParser(t){this.parseArg=t;return this}makeOptionMandatory(t=true){this.mandatory=!!t;return this}hideHelp(t=true){this.hidden=!!t;return this}_concatValue(t,u){if(u===this.defaultValue||!Array.isArray(u)){return[t]}return u.concat(t)}choices(t){this.argChoices=t.slice();this.parseArg=(t,u)=>{if(!this.argChoices.includes(t)){throw new m(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,u)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class DualOptions{constructor(t){this.positiveOptions=new Map;this.negativeOptions=new Map;this.dualOptions=new Set;t.forEach((t=>{if(t.negate){this.negativeOptions.set(t.attributeName(),t)}else{this.positiveOptions.set(t.attributeName(),t)}}));this.negativeOptions.forEach(((t,u)=>{if(this.positiveOptions.has(u)){this.dualOptions.add(u)}}))}valueFromOption(t,u){const p=u.attributeName();if(!this.dualOptions.has(p))return true;const m=this.negativeOptions.get(p).presetArg;const g=m!==undefined?m:false;return u.negate===(g===t)}}function camelcase(t){return t.split("-").reduce(((t,u)=>t+u[0].toUpperCase()+u.slice(1)))}function splitOptionFlags(t){let u;let p;const m=t.split(/[ |,]+/);if(m.length>1&&!/^[[<]/.test(m[1]))u=m.shift();p=m.shift();if(!u&&/^-[^-]$/.test(p)){u=p;p=undefined}return{shortFlag:u,longFlag:p}}u.Option=Option;u.DualOptions=DualOptions},5030:(t,u)=>{const p=3;function editDistance(t,u){if(Math.abs(t.length-u.length)>p)return Math.max(t.length,u.length);const m=[];for(let u=0;u<=t.length;u++){m[u]=[u]}for(let t=0;t<=u.length;t++){m[0][t]=t}for(let p=1;p<=u.length;p++){for(let g=1;g<=t.length;g++){let v=1;if(t[g-1]===u[p-1]){v=0}else{v=1}m[g][p]=Math.min(m[g-1][p]+1,m[g][p-1]+1,m[g-1][p-1]+v);if(g>1&&p>1&&t[g-1]===u[p-2]&&t[g-2]===u[p-1]){m[g][p]=Math.min(m[g][p],m[g-2][p-2]+1)}}}return m[t.length][u.length]}function suggestSimilar(t,u){if(!u||u.length===0)return"";u=Array.from(new Set(u));const m=t.startsWith("--");if(m){t=t.slice(2);u=u.map((t=>t.slice(2)))}let g=[];let v=p;const b=.4;u.forEach((u=>{if(u.length<=1)return;const p=editDistance(t,u);const m=Math.max(t.length,u.length);const w=(m-p)/m;if(w>b){if(p<v){v=p;g=[u]}else if(p===v){g.push(u)}}}));g.sort(((t,u)=>t.localeCompare(u)));if(m){g=g.map((t=>`--${t}`))}if(g.length>1){return`\n(Did you mean one of ${g.join(", ")}?)`}if(g.length===1){return`\n(Did you mean ${g[0]}?)`}return""}u.suggestSimilar=suggestSimilar},3770:t=>{"use strict";t.exports=JSON.parse('{"$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON AnySchema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}')},13:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/applicator","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/applicator":true},"$dynamicAnchor":"meta","title":"Applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"prefixItems":{"$ref":"#/$defs/schemaArray"},"items":{"$dynamicRef":"#meta"},"contains":{"$dynamicRef":"#meta"},"additionalProperties":{"$dynamicRef":"#meta"},"properties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"propertyNames":{"format":"regex"},"default":{}},"dependentSchemas":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"},"default":{}},"propertyNames":{"$dynamicRef":"#meta"},"if":{"$dynamicRef":"#meta"},"then":{"$dynamicRef":"#meta"},"else":{"$dynamicRef":"#meta"},"allOf":{"$ref":"#/$defs/schemaArray"},"anyOf":{"$ref":"#/$defs/schemaArray"},"oneOf":{"$ref":"#/$defs/schemaArray"},"not":{"$dynamicRef":"#meta"}},"$defs":{"schemaArray":{"type":"array","minItems":1,"items":{"$dynamicRef":"#meta"}}}}')},2394:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/content","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Content vocabulary meta-schema","type":["object","boolean"],"properties":{"contentEncoding":{"type":"string"},"contentMediaType":{"type":"string"},"contentSchema":{"$dynamicRef":"#meta"}}}')},4771:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/core","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true},"$dynamicAnchor":"meta","title":"Core vocabulary meta-schema","type":["object","boolean"],"properties":{"$id":{"$ref":"#/$defs/uriReferenceString","$comment":"Non-empty fragments not allowed.","pattern":"^[^#]*#?$"},"$schema":{"$ref":"#/$defs/uriString"},"$ref":{"$ref":"#/$defs/uriReferenceString"},"$anchor":{"$ref":"#/$defs/anchorString"},"$dynamicRef":{"$ref":"#/$defs/uriReferenceString"},"$dynamicAnchor":{"$ref":"#/$defs/anchorString"},"$vocabulary":{"type":"object","propertyNames":{"$ref":"#/$defs/uriString"},"additionalProperties":{"type":"boolean"}},"$comment":{"type":"string"},"$defs":{"type":"object","additionalProperties":{"$dynamicRef":"#meta"}}},"$defs":{"anchorString":{"type":"string","pattern":"^[A-Za-z_][-A-Za-z0-9._]*$"},"uriString":{"type":"string","format":"uri"},"uriReferenceString":{"type":"string","format":"uri-reference"}}}')},9567:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/format-annotation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/format-annotation":true},"$dynamicAnchor":"meta","title":"Format vocabulary meta-schema for annotation results","type":["object","boolean"],"properties":{"format":{"type":"string"}}}')},8364:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/meta-data","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/meta-data":true},"$dynamicAnchor":"meta","title":"Meta-data vocabulary meta-schema","type":["object","boolean"],"properties":{"title":{"type":"string"},"description":{"type":"string"},"default":true,"deprecated":{"type":"boolean","default":false},"readOnly":{"type":"boolean","default":false},"writeOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true}}}')},7388:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/unevaluated","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/unevaluated":true},"$dynamicAnchor":"meta","title":"Unevaluated applicator vocabulary meta-schema","type":["object","boolean"],"properties":{"unevaluatedItems":{"$dynamicRef":"#meta"},"unevaluatedProperties":{"$dynamicRef":"#meta"}}}')},2943:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/meta/validation","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/validation":true},"$dynamicAnchor":"meta","title":"Validation vocabulary meta-schema","type":["object","boolean"],"properties":{"type":{"anyOf":[{"$ref":"#/$defs/simpleTypes"},{"type":"array","items":{"$ref":"#/$defs/simpleTypes"},"minItems":1,"uniqueItems":true}]},"const":true,"enum":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/$defs/nonNegativeInteger"},"minLength":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"maxItems":{"$ref":"#/$defs/nonNegativeInteger"},"minItems":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"maxContains":{"$ref":"#/$defs/nonNegativeInteger"},"minContains":{"$ref":"#/$defs/nonNegativeInteger","default":1},"maxProperties":{"$ref":"#/$defs/nonNegativeInteger"},"minProperties":{"$ref":"#/$defs/nonNegativeIntegerDefault0"},"required":{"$ref":"#/$defs/stringArray"},"dependentRequired":{"type":"object","additionalProperties":{"$ref":"#/$defs/stringArray"}}},"$defs":{"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"$ref":"#/$defs/nonNegativeInteger","default":0},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}}}')},6261:t=>{"use strict";t.exports=JSON.parse('{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://json-schema.org/draft/2020-12/schema","$vocabulary":{"https://json-schema.org/draft/2020-12/vocab/core":true,"https://json-schema.org/draft/2020-12/vocab/applicator":true,"https://json-schema.org/draft/2020-12/vocab/unevaluated":true,"https://json-schema.org/draft/2020-12/vocab/validation":true,"https://json-schema.org/draft/2020-12/vocab/meta-data":true,"https://json-schema.org/draft/2020-12/vocab/format-annotation":true,"https://json-schema.org/draft/2020-12/vocab/content":true},"$dynamicAnchor":"meta","title":"Core and Validation specifications meta-schema","allOf":[{"$ref":"meta/core"},{"$ref":"meta/applicator"},{"$ref":"meta/unevaluated"},{"$ref":"meta/validation"},{"$ref":"meta/meta-data"},{"$ref":"meta/format-annotation"},{"$ref":"meta/content"}],"type":["object","boolean"],"$comment":"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.","properties":{"definitions":{"$comment":"\\"definitions\\" has been replaced by \\"$defs\\".","type":"object","additionalProperties":{"$dynamicRef":"#meta"},"deprecated":true,"default":{}},"dependencies":{"$comment":"\\"dependencies\\" has been split and replaced by \\"dependentSchemas\\" and \\"dependentRequired\\" in order to serve their differing semantics.","type":"object","additionalProperties":{"anyOf":[{"$dynamicRef":"#meta"},{"$ref":"meta/validation#/$defs/stringArray"}]},"deprecated":true,"default":{}},"$recursiveAnchor":{"$comment":"\\"$recursiveAnchor\\" has been replaced by \\"$dynamicAnchor\\".","$ref":"meta/core#/$defs/anchorString","deprecated":true},"$recursiveRef":{"$comment":"\\"$recursiveRef\\" has been replaced by \\"$dynamicRef\\".","$ref":"meta/core#/$defs/uriReferenceString","deprecated":true}}}')},3928:t=>{"use strict";t.exports=JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}')},2040:t=>{"use strict";t.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE"},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN"},{"name":"Azure Pipelines","constant":"AZURE_PIPELINES","env":"TF_BUILD","pr":{"BUILD_REASON":"PullRequest"}},{"name":"Bamboo","constant":"BAMBOO","env":"bamboo_planKey"},{"name":"Bitbucket Pipelines","constant":"BITBUCKET","env":"BITBUCKET_COMMIT","pr":"BITBUCKET_PR_ID"},{"name":"Bitrise","constant":"BITRISE","env":"BITRISE_IO","pr":"BITRISE_PULL_REQUEST"},{"name":"Buddy","constant":"BUDDY","env":"BUDDY_WORKSPACE_ID","pr":"BUDDY_EXECUTION_PULL_REQUEST_ID"},{"name":"Buildkite","constant":"BUILDKITE","env":"BUILDKITE","pr":{"env":"BUILDKITE_PULL_REQUEST","ne":"false"}},{"name":"CircleCI","constant":"CIRCLE","env":"CIRCLECI","pr":"CIRCLE_PULL_REQUEST"},{"name":"Cirrus CI","constant":"CIRRUS","env":"CIRRUS_CI","pr":"CIRRUS_PR"},{"name":"Codefresh","constant":"CODEFRESH","env":"CF_BUILD_ID","pr":{"any":["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{"name":"Codemagic","constant":"CODEMAGIC","env":"CM_BUILD_ID","pr":"CM_PULL_REQUEST"},{"name":"Codeship","constant":"CODESHIP","env":{"CI_NAME":"codeship"}},{"name":"Drone","constant":"DRONE","env":"DRONE","pr":{"DRONE_BUILD_EVENT":"pull_request"}},{"name":"dsari","constant":"DSARI","env":"DSARI"},{"name":"Earthly","constant":"EARTHLY","env":"EARTHLY_CI"},{"name":"Expo Application Services","constant":"EAS","env":"EAS_BUILD"},{"name":"Gerrit","constant":"GERRIT","env":"GERRIT_PROJECT"},{"name":"Gitea Actions","constant":"GITEA_ACTIONS","env":"GITEA_ACTIONS"},{"name":"GitHub Actions","constant":"GITHUB_ACTIONS","env":"GITHUB_ACTIONS","pr":{"GITHUB_EVENT_NAME":"pull_request"}},{"name":"GitLab CI","constant":"GITLAB","env":"GITLAB_CI","pr":"CI_MERGE_REQUEST_ID"},{"name":"GoCD","constant":"GOCD","env":"GO_PIPELINE_LABEL"},{"name":"Google Cloud Build","constant":"GOOGLE_CLOUD_BUILD","env":"BUILDER_OUTPUT"},{"name":"Harness CI","constant":"HARNESS","env":"HARNESS_BUILD_ID"},{"name":"Heroku","constant":"HEROKU","env":{"env":"NODE","includes":"/app/.heroku/node/bin/node"}},{"name":"Hudson","constant":"HUDSON","env":"HUDSON_URL"},{"name":"Jenkins","constant":"JENKINS","env":["JENKINS_URL","BUILD_ID"],"pr":{"any":["ghprbPullId","CHANGE_ID"]}},{"name":"LayerCI","constant":"LAYERCI","env":"LAYERCI","pr":"LAYERCI_PULL_REQUEST"},{"name":"Magnum CI","constant":"MAGNUM","env":"MAGNUM"},{"name":"Netlify CI","constant":"NETLIFY","env":"NETLIFY","pr":{"env":"PULL_REQUEST","ne":"false"}},{"name":"Nevercode","constant":"NEVERCODE","env":"NEVERCODE","pr":{"env":"NEVERCODE_PULL_REQUEST","ne":"false"}},{"name":"Prow","constant":"PROW","env":"PROW_JOB_ID"},{"name":"ReleaseHub","constant":"RELEASEHUB","env":"RELEASE_BUILD_ID"},{"name":"Render","constant":"RENDER","env":"RENDER","pr":{"IS_PULL_REQUEST":"true"}},{"name":"Sail CI","constant":"SAIL","env":"SAILCI","pr":"SAIL_PULL_REQUEST_NUMBER"},{"name":"Screwdriver","constant":"SCREWDRIVER","env":"SCREWDRIVER","pr":{"env":"SD_PULL_REQUEST","ne":"false"}},{"name":"Semaphore","constant":"SEMAPHORE","env":"SEMAPHORE","pr":"PULL_REQUEST_NUMBER"},{"name":"Sourcehut","constant":"SOURCEHUT","env":{"CI_NAME":"sourcehut"}},{"name":"Strider CD","constant":"STRIDER","env":"STRIDER"},{"name":"TaskCluster","constant":"TASKCLUSTER","env":["TASK_ID","RUN_ID"]},{"name":"TeamCity","constant":"TEAMCITY","env":"TEAMCITY_VERSION"},{"name":"Travis CI","constant":"TRAVIS","env":"TRAVIS","pr":{"env":"TRAVIS_PULL_REQUEST","ne":"false"}},{"name":"Vela","constant":"VELA","env":"VELA","pr":{"VELA_PULL_REQUEST":"1"}},{"name":"Vercel","constant":"VERCEL","env":{"any":["NOW_BUILDER","VERCEL"]},"pr":"VERCEL_GIT_PULL_REQUEST_ID"},{"name":"Visual Studio App Center","constant":"APPCENTER","env":"APPCENTER_BUILD_ID"},{"name":"Woodpecker","constant":"WOODPECKER","env":{"CI":"woodpecker"},"pr":{"CI_BUILD_EVENT":"pull_request"}},{"name":"Xcode Cloud","constant":"XCODE_CLOUD","env":"CI_XCODE_PROJECT","pr":"CI_PULL_REQUEST_NUMBER"},{"name":"Xcode Server","constant":"XCODE_SERVER","env":"XCS"}]')}};var u={};function __nccwpck_require__(p){var m=u[p];if(m!==undefined){return m.exports}var g=u[p]={exports:{}};var v=true;try{t[p](g,g.exports,__nccwpck_require__);v=false}finally{if(v)delete u[p]}return g.exports}(()=>{__nccwpck_require__.n=t=>{var u=t&&t.__esModule?()=>t["default"]:()=>t;__nccwpck_require__.d(u,{a:u});return u}})();(()=>{var t=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__;var u;__nccwpck_require__.t=function(p,m){if(m&1)p=this(p);if(m&8)return p;if(typeof p==="object"&&p){if(m&4&&p.__esModule)return p;if(m&16&&typeof p.then==="function")return p}var g=Object.create(null);__nccwpck_require__.r(g);var v={};u=u||[null,t({}),t([]),t(t)];for(var b=m&2&&p;typeof b=="object"&&!~u.indexOf(b);b=t(b)){Object.getOwnPropertyNames(b).forEach((t=>v[t]=()=>p[t]))}v["default"]=()=>p;__nccwpck_require__.d(g,v);return g}})();(()=>{__nccwpck_require__.d=(t,u)=>{for(var p in u){if(__nccwpck_require__.o(u,p)&&!__nccwpck_require__.o(t,p)){Object.defineProperty(t,p,{enumerable:true,get:u[p]})}}}})();(()=>{__nccwpck_require__.o=(t,u)=>Object.prototype.hasOwnProperty.call(t,u)})();(()=>{__nccwpck_require__.r=t=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(t,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var p={};(()=>{"use strict";var t=__nccwpck_require__(6395);var u=__nccwpck_require__.n(t);var p=__nccwpck_require__(8909);const{DM:m,gu:g,er:v,Ww:b,b7:w,Di:E,a2:S,uB:$,ef:P,c$:x,_V:R}=p;const O=require("node:util");var A=__nccwpck_require__(1708);var k=__nccwpck_require__(3024);var T=__nccwpck_require__(6760);var C=__nccwpck_require__.n(T);const I=require("node:crypto");const N=require("node:assert");const isObject=t=>{const u=typeof t;return t!==null&&(u==="object"||u==="function")};const isEmptyObject=t=>isObject(t)&&Object.keys(t).length===0;const D=new Set(["__proto__","prototype","constructor"]);const j=new Set("0123456789");function getPathSegments(t){const u=[];let p="";let m="start";let g=false;for(const v of t){switch(v){case"\\":{if(m==="index"){throw new Error("Invalid character in an index")}if(m==="indexEnd"){throw new Error("Invalid character after an index")}if(g){p+=v}m="property";g=!g;break}case".":{if(m==="index"){throw new Error("Invalid character in an index")}if(m==="indexEnd"){m="property";break}if(g){g=false;p+=v;break}if(D.has(p)){return[]}u.push(p);p="";m="property";break}case"[":{if(m==="index"){throw new Error("Invalid character in an index")}if(m==="indexEnd"){m="index";break}if(g){g=false;p+=v;break}if(m==="property"){if(D.has(p)){return[]}u.push(p);p=""}m="index";break}case"]":{if(m==="index"){u.push(Number.parseInt(p,10));p="";m="indexEnd";break}if(m==="indexEnd"){throw new Error("Invalid character after an index")}}default:{if(m==="index"&&!j.has(v)){throw new Error("Invalid character in an index")}if(m==="indexEnd"){throw new Error("Invalid character after an index")}if(m==="start"){m="property"}if(g){g=false;p+="\\"}p+=v}}}if(g){p+="\\"}switch(m){case"property":{if(D.has(p)){return[]}u.push(p);break}case"index":{throw new Error("Index was not closed")}case"start":{u.push("");break}}return u}function isStringIndex(t,u){if(typeof u!=="number"&&Array.isArray(t)){const p=Number.parseInt(u,10);return Number.isInteger(p)&&t[p]===t[u]}return false}function assertNotStringIndex(t,u){if(isStringIndex(t,u)){throw new Error("Cannot use string index")}}function getProperty(t,u,p){if(!isObject(t)||typeof u!=="string"){return p===undefined?t:p}const m=getPathSegments(u);if(m.length===0){return p}for(let u=0;u<m.length;u++){const g=m[u];if(isStringIndex(t,g)){t=u===m.length-1?undefined:null}else{t=t[g]}if(t===undefined||t===null){if(u!==m.length-1){return p}break}}return t===undefined?p:t}function setProperty(t,u,p){if(!isObject(t)||typeof u!=="string"){return t}const m=t;const g=getPathSegments(u);for(let u=0;u<g.length;u++){const m=g[u];assertNotStringIndex(t,m);if(u===g.length-1){t[m]=p}else if(!isObject(t[m])){t[m]=typeof g[u+1]==="number"?[]:{}}t=t[m]}return m}function deleteProperty(t,u){if(!isObject(t)||typeof u!=="string"){return false}const p=getPathSegments(u);for(let u=0;u<p.length;u++){const m=p[u];assertNotStringIndex(t,m);if(u===p.length-1){delete t[m];return true}t=t[m];if(!isObject(t)){return false}}}function hasProperty(t,u){if(!isObject(t)||typeof u!=="string"){return false}const p=getPathSegments(u);if(p.length===0){return false}for(const u of p){if(!isObject(t)||!(u in t)||isStringIndex(t,u)){return false}t=t[u]}return true}function escapePath(t){if(typeof t!=="string"){throw new TypeError("Expected a string")}return t.replaceAll(/[\\.[]/g,"\\$&")}function entries(t){const u=Object.entries(t);if(Array.isArray(t)){return u.map((([t,u])=>[Number(t),u]))}return u}function stringifyPath(t){let u="";for(let[p,m]of entries(t)){if(typeof m==="number"){u+=`[${m}]`}else{m=escapePath(m);u+=p===0?m:`.${m}`}}return u}function*deepKeysIterator(t,u=[]){if(!isObject(t)||isEmptyObject(t)){if(u.length>0){yield stringifyPath(u)}return}for(const[p,m]of entries(t)){yield*deepKeysIterator(m,[...u,p])}}function deepKeys(t){return[...deepKeysIterator(t)]}const L=require("node:os");const M=L.homedir();const U=L.tmpdir();const{env:B}=A;const macos=t=>{const u=T.join(M,"Library");return{data:T.join(u,"Application Support",t),config:T.join(u,"Preferences",t),cache:T.join(u,"Caches",t),log:T.join(u,"Logs",t),temp:T.join(U,t)}};const windows=t=>{const u=B.APPDATA||T.join(M,"AppData","Roaming");const p=B.LOCALAPPDATA||T.join(M,"AppData","Local");return{data:T.join(p,t,"Data"),config:T.join(u,t,"Config"),cache:T.join(p,t,"Cache"),log:T.join(p,t,"Log"),temp:T.join(U,t)}};const linux=t=>{const u=T.basename(M);return{data:T.join(B.XDG_DATA_HOME||T.join(M,".local","share"),t),config:T.join(B.XDG_CONFIG_HOME||T.join(M,".config"),t),cache:T.join(B.XDG_CACHE_HOME||T.join(M,".cache"),t),log:T.join(B.XDG_STATE_HOME||T.join(M,".local","state"),t),temp:T.join(U,u,t)}};function envPaths(t,{suffix:u="nodejs"}={}){if(typeof t!=="string"){throw new TypeError(`Expected a string, got ${typeof t}`)}if(u){t+=`-${u}`}if(A.platform==="darwin"){return macos(t)}if(A.platform==="win32"){return windows(t)}return linux(t)}const attemptifyAsync=(t,u)=>function attemptified(...p){return t.apply(undefined,p).catch(u)};const attemptifySync=(t,u)=>function attemptified(...p){try{return t.apply(undefined,p)}catch(t){return u(t)}};const H=A.getuid?!A.getuid():false;const z=1e4;const NOOP=()=>undefined;const V={isChangeErrorOk:t=>{if(!V.isNodeError(t))return false;const{code:u}=t;if(u==="ENOSYS")return true;if(!H&&(u==="EINVAL"||u==="EPERM"))return true;return false},isNodeError:t=>t instanceof Error,isRetriableError:t=>{if(!V.isNodeError(t))return false;const{code:u}=t;if(u==="EMFILE"||u==="ENFILE"||u==="EAGAIN"||u==="EBUSY"||u==="EACCESS"||u==="EACCES"||u==="EACCS"||u==="EPERM")return true;return false},onChangeError:t=>{if(!V.isNodeError(t))throw t;if(V.isChangeErrorOk(t))return;throw t}};const G=V;class RetryfyQueue{constructor(){this.interval=25;this.intervalId=undefined;this.limit=z;this.queueActive=new Set;this.queueWaiting=new Set;this.init=()=>{if(this.intervalId)return;this.intervalId=setInterval(this.tick,this.interval)};this.reset=()=>{if(!this.intervalId)return;clearInterval(this.intervalId);delete this.intervalId};this.add=t=>{this.queueWaiting.add(t);if(this.queueActive.size<this.limit/2){this.tick()}else{this.init()}};this.remove=t=>{this.queueWaiting.delete(t);this.queueActive.delete(t)};this.schedule=()=>new Promise((t=>{const cleanup=()=>this.remove(resolver);const resolver=()=>t(cleanup);this.add(resolver)}));this.tick=()=>{if(this.queueActive.size>=this.limit)return;if(!this.queueWaiting.size)return this.reset();for(const t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t);this.queueActive.add(t);t()}}}}const q=new RetryfyQueue;const retryifyAsync=(t,u)=>function retrified(p){return function attempt(...m){return q.schedule().then((g=>{const onResolve=t=>{g();return t};const onReject=t=>{g();if(Date.now()>=p)throw t;if(u(t)){const t=Math.round(100*Math.random());const u=new Promise((u=>setTimeout(u,t)));return u.then((()=>attempt.apply(undefined,m)))}throw t};return t.apply(undefined,m).then(onResolve,onReject)}))}};const retryifySync=(t,u)=>function retrified(p){return function attempt(...m){try{return t.apply(undefined,m)}catch(t){if(Date.now()>p)throw t;if(u(t))return attempt.apply(undefined,m);throw t}}};const W={attempt:{chmod:attemptifyAsync((0,O.promisify)(k.chmod),G.onChangeError),chown:attemptifyAsync((0,O.promisify)(k.chown),G.onChangeError),close:attemptifyAsync((0,O.promisify)(k.close),NOOP),fsync:attemptifyAsync((0,O.promisify)(k.fsync),NOOP),mkdir:attemptifyAsync((0,O.promisify)(k.mkdir),NOOP),realpath:attemptifyAsync((0,O.promisify)(k.realpath),NOOP),stat:attemptifyAsync((0,O.promisify)(k.stat),NOOP),unlink:attemptifyAsync((0,O.promisify)(k.unlink),NOOP),chmodSync:attemptifySync(k.chmodSync,G.onChangeError),chownSync:attemptifySync(k.chownSync,G.onChangeError),closeSync:attemptifySync(k.closeSync,NOOP),existsSync:attemptifySync(k.existsSync,NOOP),fsyncSync:attemptifySync(k.fsync,NOOP),mkdirSync:attemptifySync(k.mkdirSync,NOOP),realpathSync:attemptifySync(k.realpathSync,NOOP),statSync:attemptifySync(k.statSync,NOOP),unlinkSync:attemptifySync(k.unlinkSync,NOOP)},retry:{close:retryifyAsync((0,O.promisify)(k.close),G.isRetriableError),fsync:retryifyAsync((0,O.promisify)(k.fsync),G.isRetriableError),open:retryifyAsync((0,O.promisify)(k.open),G.isRetriableError),readFile:retryifyAsync((0,O.promisify)(k.readFile),G.isRetriableError),rename:retryifyAsync((0,O.promisify)(k.rename),G.isRetriableError),stat:retryifyAsync((0,O.promisify)(k.stat),G.isRetriableError),write:retryifyAsync((0,O.promisify)(k.write),G.isRetriableError),writeFile:retryifyAsync((0,O.promisify)(k.writeFile),G.isRetriableError),closeSync:retryifySync(k.closeSync,G.isRetriableError),fsyncSync:retryifySync(k.fsyncSync,G.isRetriableError),openSync:retryifySync(k.openSync,G.isRetriableError),readFileSync:retryifySync(k.readFileSync,G.isRetriableError),renameSync:retryifySync(k.renameSync,G.isRetriableError),statSync:retryifySync(k.statSync,G.isRetriableError),writeSync:retryifySync(k.writeSync,G.isRetriableError),writeFileSync:retryifySync(k.writeFileSync,G.isRetriableError)}};const Y=W;const Z="utf8";const J=438;const X=511;const Q={};const ee={};const te=L.userInfo().uid;const re=L.userInfo().gid;const ie=7500;const oe=1e3;const ae=!!A.getuid;const le=A.getuid?!A.getuid():false;const ue=128;const he=1e4;const constants_NOOP=()=>{};const lang_isException=t=>t instanceof Error&&"code"in t;const lang_isFunction=t=>typeof t==="function";const lang_isString=t=>typeof t==="string";const lang_isUndefined=t=>t===undefined;const de={};const fe={next:t=>{const u=de[t];if(!u)return;u.shift();const p=u[0];if(p){p((()=>fe.next(t)))}else{delete de[t]}},schedule:t=>new Promise((u=>{let p=de[t];if(!p)p=de[t]=[];p.push(u);if(p.length>1)return;u((()=>fe.next(t)))}))};const pe=null&&fe;const me=A.platform==="linux";const ge=A.platform==="win32";const ve=["SIGHUP","SIGINT","SIGTERM"];if(!ge){ve.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT")}if(me){ve.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")}const _e=ve;class Interceptor{constructor(){this.callbacks=new Set;this.exited=false;this.exit=t=>{if(this.exited)return;this.exited=true;for(const t of this.callbacks){t()}if(t){if(ge&&(t!=="SIGINT"&&t!=="SIGTERM"&&t!=="SIGKILL")){A.kill(A.pid,"SIGTERM")}else{A.kill(A.pid,t)}}};this.hook=()=>{A.once("exit",(()=>this.exit()));for(const t of _e){try{A.once(t,(()=>this.exit(t)))}catch{}}};this.register=t=>{this.callbacks.add(t);return()=>{this.callbacks.delete(t)}};this.hook()}}const be=new Interceptor;const we=be.register;const Ee=we;const Se={store:{},create:t=>{const u=`000000${Math.floor(Math.random()*16777215).toString(16)}`.slice(-6);const p=Date.now().toString().slice(-10);const m="tmp-";const g=`.${m}${p}${u}`;const v=`${t}${g}`;return v},get:(t,u,p=true)=>{const m=Se.truncate(u(t));if(m in Se.store)return Se.get(t,u,p);Se.store[m]=p;const disposer=()=>delete Se.store[m];return[m,disposer]},purge:t=>{if(!Se.store[t])return;delete Se.store[t];Y.attempt.unlink(t)},purgeSync:t=>{if(!Se.store[t])return;delete Se.store[t];Y.attempt.unlinkSync(t)},purgeSyncAll:()=>{for(const t in Se.store){Se.purgeSync(t)}},truncate:t=>{const u=T.basename(t);if(u.length<=ue)return t;const p=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(u);if(!p)return t;const m=u.length-ue;return`${t.slice(0,-u.length)}${p[1]}${p[2].slice(0,-m)}${p[3]}`}};Ee(Se.purgeSyncAll);const $e=Se;function readFile(t,u=DEFAULT_READ_OPTIONS){if(isString(u))return readFile(t,{encoding:u});const p=Date.now()+((u.timeout??DEFAULT_TIMEOUT_ASYNC)||-1);return fs.retry.readFile(p)(t,u)}function readFileSync(t,u=DEFAULT_READ_OPTIONS){if(isString(u))return readFileSync(t,{encoding:u});const p=Date.now()+((u.timeout??DEFAULT_TIMEOUT_SYNC)||-1);return fs.retry.readFileSync(p)(t,u)}function writeFile(t,u,p,m){if(isFunction(p))return writeFile(t,u,DEFAULT_WRITE_OPTIONS,p);const g=writeFileAsync(t,u,p);if(m)g.then(m,m);return g}async function writeFileAsync(t,u,p=DEFAULT_WRITE_OPTIONS){if(isString(p))return writeFileAsync(t,u,{encoding:p});const m=Date.now()+((p.timeout??DEFAULT_TIMEOUT_ASYNC)||-1);let g=null;let v=null;let b=null;let w=null;let E=null;try{if(p.schedule)g=await p.schedule(t);v=await Scheduler.schedule(t);const S=await fs.attempt.realpath(t);const $=!!S;t=S||t;[w,b]=Temp.get(t,p.tmpCreate||Temp.create,!(p.tmpPurge===false));const P=IS_POSIX&&isUndefined(p.chown);const x=isUndefined(p.mode);if($&&(P||x)){const u=await fs.attempt.stat(t);if(u){p={...p};if(P){p.chown={uid:u.uid,gid:u.gid}}if(x){p.mode=u.mode}}}if(!$){const u=path.dirname(t);await fs.attempt.mkdir(u,{mode:DEFAULT_FOLDER_MODE,recursive:true})}E=await fs.retry.open(m)(w,"w",p.mode||DEFAULT_FILE_MODE);if(p.tmpCreated){p.tmpCreated(w)}if(isString(u)){await fs.retry.write(m)(E,u,0,p.encoding||DEFAULT_ENCODING)}else if(!isUndefined(u)){await fs.retry.write(m)(E,u,0,u.length,0)}if(p.fsync!==false){if(p.fsyncWait!==false){await fs.retry.fsync(m)(E)}else{fs.attempt.fsync(E)}}await fs.retry.close(m)(E);E=null;if(p.chown&&(p.chown.uid!==DEFAULT_USER_UID||p.chown.gid!==DEFAULT_USER_GID)){await fs.attempt.chown(w,p.chown.uid,p.chown.gid)}if(p.mode&&p.mode!==DEFAULT_FILE_MODE){await fs.attempt.chmod(w,p.mode)}try{await fs.retry.rename(m)(w,t)}catch(u){if(!isException(u))throw u;if(u.code!=="ENAMETOOLONG")throw u;await fs.retry.rename(m)(w,Temp.truncate(t))}b();w=null}finally{if(E)await fs.attempt.close(E);if(w)Temp.purge(w);if(g)g();if(v)v()}}function writeFileSync(t,u,p=ee){if(lang_isString(p))return writeFileSync(t,u,{encoding:p});const m=Date.now()+((p.timeout??oe)||-1);let g=null;let v=null;let b=null;try{const w=Y.attempt.realpathSync(t);const E=!!w;t=w||t;[v,g]=$e.get(t,p.tmpCreate||$e.create,!(p.tmpPurge===false));const S=ae&&lang_isUndefined(p.chown);const $=lang_isUndefined(p.mode);if(E&&(S||$)){const u=Y.attempt.statSync(t);if(u){p={...p};if(S){p.chown={uid:u.uid,gid:u.gid}}if($){p.mode=u.mode}}}if(!E){const u=T.dirname(t);Y.attempt.mkdirSync(u,{mode:X,recursive:true})}b=Y.retry.openSync(m)(v,"w",p.mode||J);if(p.tmpCreated){p.tmpCreated(v)}if(lang_isString(u)){Y.retry.writeSync(m)(b,u,0,p.encoding||Z)}else if(!lang_isUndefined(u)){Y.retry.writeSync(m)(b,u,0,u.length,0)}if(p.fsync!==false){if(p.fsyncWait!==false){Y.retry.fsyncSync(m)(b)}else{Y.attempt.fsync(b)}}Y.retry.closeSync(m)(b);b=null;if(p.chown&&(p.chown.uid!==te||p.chown.gid!==re)){Y.attempt.chownSync(v,p.chown.uid,p.chown.gid)}if(p.mode&&p.mode!==J){Y.attempt.chmodSync(v,p.mode)}try{Y.retry.renameSync(m)(v,t)}catch(u){if(!lang_isException(u))throw u;if(u.code!=="ENAMETOOLONG")throw u;Y.retry.renameSync(m)(v,$e.truncate(t))}g();v=null}finally{if(b)Y.attempt.closeSync(b);if(v)$e.purge(v)}}var Pe=__nccwpck_require__(939);var xe=__nccwpck_require__(6848);const copyProperty=(t,u,p,m)=>{if(p==="length"||p==="prototype"){return}if(p==="arguments"||p==="caller"){return}const g=Object.getOwnPropertyDescriptor(t,p);const v=Object.getOwnPropertyDescriptor(u,p);if(!canCopyProperty(g,v)&&m){return}Object.defineProperty(t,p,v)};const canCopyProperty=function(t,u){return t===undefined||t.configurable||t.writable===u.writable&&t.enumerable===u.enumerable&&t.configurable===u.configurable&&(t.writable||t.value===u.value)};const changePrototype=(t,u)=>{const p=Object.getPrototypeOf(u);if(p===Object.getPrototypeOf(t)){return}Object.setPrototypeOf(t,p)};const wrappedToString=(t,u)=>`/* Wrapped ${t}*/\n${u}`;const Re=Object.getOwnPropertyDescriptor(Function.prototype,"toString");const Oe=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name");const changeToString=(t,u,p)=>{const m=p===""?"":`with ${p.trim()}() `;const g=wrappedToString.bind(null,m,u.toString());Object.defineProperty(g,"name",Oe);const{writable:v,enumerable:b,configurable:w}=Re;Object.defineProperty(t,"toString",{value:g,writable:v,enumerable:b,configurable:w})};function mimicFunction(t,u,{ignoreNonConfigurable:p=false}={}){const{name:m}=t;for(const m of Reflect.ownKeys(u)){copyProperty(t,u,m,p)}changePrototype(t,u);changeToString(t,u,m);return t}const debounceFunction=(t,u={})=>{if(typeof t!=="function"){throw new TypeError(`Expected the first argument to be a function, got \`${typeof t}\``)}const{wait:p=0,maxWait:m=Number.POSITIVE_INFINITY,before:g=false,after:v=true}=u;if(p<0||m<0){throw new RangeError("`wait` and `maxWait` must not be negative.")}if(!g&&!v){throw new Error("Both `before` and `after` are false, function wouldn't be called.")}let b;let w;let E;const debouncedFunction=function(...u){const S=this;const later=()=>{b=undefined;if(w){clearTimeout(w);w=undefined}if(v){E=t.apply(S,u)}};const maxLater=()=>{w=undefined;if(b){clearTimeout(b);b=undefined}if(v){E=t.apply(S,u)}};const $=g&&!b;clearTimeout(b);b=setTimeout(later,p);if(m>0&&m!==Number.POSITIVE_INFINITY&&!w){w=setTimeout(maxLater,m)}if($){E=t.apply(S,u)}return E};mimicFunction(debouncedFunction,t);debouncedFunction.cancel=()=>{if(b){clearTimeout(b);b=undefined}if(w){clearTimeout(w);w=undefined}};return debouncedFunction};const Ae=debounceFunction;var ke=__nccwpck_require__(6723);const Te=Object.prototype.toString;const Ce="[object Uint8Array]";const Ie="[object ArrayBuffer]";function isType(t,u,p){if(!t){return false}if(t.constructor===u){return true}return Te.call(t)===p}function isUint8Array(t){return isType(t,Uint8Array,Ce)}function isArrayBuffer(t){return isType(t,ArrayBuffer,Ie)}function isUint8ArrayOrArrayBuffer(t){return isUint8Array(t)||isArrayBuffer(t)}function assertUint8Array(t){if(!isUint8Array(t)){throw new TypeError(`Expected \`Uint8Array\`, got \`${typeof t}\``)}}function assertUint8ArrayOrArrayBuffer(t){if(!isUint8ArrayOrArrayBuffer(t)){throw new TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``)}}function toUint8Array(t){if(t instanceof ArrayBuffer){return new Uint8Array(t)}if(ArrayBuffer.isView(t)){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}throw new TypeError(`Unsupported value, got \`${typeof t}\`.`)}function concatUint8Arrays(t,u){if(t.length===0){return new Uint8Array(0)}u??=t.reduce(((t,u)=>t+u.length),0);const p=new Uint8Array(u);let m=0;for(const u of t){assertUint8Array(u);p.set(u,m);m+=u.length}return p}function areUint8ArraysEqual(t,u){assertUint8Array(t);assertUint8Array(u);if(t===u){return true}if(t.length!==u.length){return false}for(let p=0;p<t.length;p++){if(t[p]!==u[p]){return false}}return true}function compareUint8Arrays(t,u){assertUint8Array(t);assertUint8Array(u);const p=Math.min(t.length,u.length);for(let m=0;m<p;m++){const p=t[m]-u[m];if(p!==0){return Math.sign(p)}}return Math.sign(t.length-u.length)}const Ne={utf8:new globalThis.TextDecoder("utf8")};function uint8ArrayToString(t,u="utf8"){assertUint8ArrayOrArrayBuffer(t);Ne[u]??=new globalThis.TextDecoder(u);return Ne[u].decode(t)}function assertString(t){if(typeof t!=="string"){throw new TypeError(`Expected \`string\`, got \`${typeof t}\``)}}const De=new globalThis.TextEncoder;function stringToUint8Array(t){assertString(t);return De.encode(t)}function base64ToBase64Url(t){return t.replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function base64UrlToBase64(t){const u=t.replaceAll("-","+").replaceAll("_","/");const p=(4-u.length%4)%4;return u+"=".repeat(p)}const je=65535;function uint8ArrayToBase64(t,{urlSafe:u=false}={}){assertUint8Array(t);let p="";for(let u=0;u<t.length;u+=je){const m=t.subarray(u,u+je);p+=globalThis.btoa(String.fromCodePoint.apply(undefined,m))}return u?base64ToBase64Url(p):p}function base64ToUint8Array(t){assertString(t);return Uint8Array.from(globalThis.atob(base64UrlToBase64(t)),(t=>t.codePointAt(0)))}function stringToBase64(t,{urlSafe:u=false}={}){assertString(t);return uint8ArrayToBase64(stringToUint8Array(t),{urlSafe:u})}function base64ToString(t){assertString(t);return uint8ArrayToString(base64ToUint8Array(t))}const Le=Array.from({length:256},((t,u)=>u.toString(16).padStart(2,"0")));function uint8ArrayToHex(t){assertUint8Array(t);let u="";for(let p=0;p<t.length;p++){u+=Le[t[p]]}return u}const Me={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function hexToUint8Array(t){assertString(t);if(t.length%2!==0){throw new Error("Invalid Hex string length.")}const u=t.length/2;const p=new Uint8Array(u);for(let m=0;m<u;m++){const u=Me[t[m*2]];const g=Me[t[m*2+1]];if(u===undefined||g===undefined){throw new Error(`Invalid Hex character encountered at position ${m*2}`)}p[m]=u<<4|g}return p}function getUintBE(t){const{byteLength:u}=t;if(u===6){return t.getUint16(0)*2**32+t.getUint32(2)}if(u===5){return t.getUint8(0)*2**32+t.getUint32(1)}if(u===4){return t.getUint32(0)}if(u===3){return t.getUint8(0)*2**16+t.getUint16(1)}if(u===2){return t.getUint16(0)}if(u===1){return t.getUint8(0)}}function indexOf(t,u){const p=t.length;const m=u.length;if(m===0){return-1}if(m>p){return-1}const g=p-m;for(let p=0;p<=g;p++){let g=true;for(let v=0;v<m;v++){if(t[p+v]!==u[v]){g=false;break}}if(g){return p}}return-1}function includes(t,u){return indexOf(t,u)!==-1}const Fe=xe["default"];const Ue="aes-256-cbc";const createPlainObject=()=>Object.create(null);const isExist=t=>t!==undefined&&t!==null;const checkValueType=(t,u)=>{const p=new Set(["undefined","symbol","function"]);const m=typeof u;if(p.has(m)){throw new TypeError(`Setting a value of type \`${m}\` for key \`${t}\` is not allowed as it's not supported by JSON`)}};const Be="__internal__";const He=`${Be}.migrations.version`;class Conf{path;events;#e;#t;#r;#s={};constructor(t={}){const u={configName:"config",fileExtension:"json",projectSuffix:"nodejs",clearInvalidConfig:false,accessPropertiesByDotNotation:true,configFileMode:438,...t};if(!u.cwd){if(!u.projectName){throw new Error("Please specify the `projectName` option.")}u.cwd=envPaths(u.projectName,{suffix:u.projectSuffix}).config}this.#r=u;if(u.schema){if(typeof u.schema!=="object"){throw new TypeError("The `schema` option must be an object.")}const t=new Pe.Ajv2020({allErrors:true,useDefaults:true});Fe(t);const p={type:"object",properties:u.schema};this.#e=t.compile(p);for(const[t,p]of Object.entries(u.schema)){if(p?.default){this.#s[t]=p.default}}}if(u.defaults){this.#s={...this.#s,...u.defaults}}if(u.serialize){this._serialize=u.serialize}if(u.deserialize){this._deserialize=u.deserialize}this.events=new EventTarget;this.#t=u.encryptionKey;const p=u.fileExtension?`.${u.fileExtension}`:"";this.path=T.resolve(u.cwd,`${u.configName??"config"}${p}`);const m=this.store;const g=Object.assign(createPlainObject(),u.defaults,m);if(u.migrations){if(!u.projectVersion){throw new Error("Please specify the `projectVersion` option.")}this._migrate(u.migrations,u.projectVersion,u.beforeEachMigration)}this._validate(g);try{N.deepEqual(m,g)}catch{this.store=g}if(u.watch){this._watch()}}get(t,u){if(this.#r.accessPropertiesByDotNotation){return this._get(t,u)}const{store:p}=this;return t in p?p[t]:u}set(t,u){if(typeof t!=="string"&&typeof t!=="object"){throw new TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof t}`)}if(typeof t!=="object"&&u===undefined){throw new TypeError("Use `delete()` to clear values")}if(this._containsReservedKey(t)){throw new TypeError(`Please don't use the ${Be} key, as it's used to manage this module internal operations.`)}const{store:p}=this;const set=(t,u)=>{checkValueType(t,u);if(this.#r.accessPropertiesByDotNotation){setProperty(p,t,u)}else{p[t]=u}};if(typeof t==="object"){const u=t;for(const[t,p]of Object.entries(u)){set(t,p)}}else{set(t,u)}this.store=p}has(t){if(this.#r.accessPropertiesByDotNotation){return hasProperty(this.store,t)}return t in this.store}reset(...t){for(const u of t){if(isExist(this.#s[u])){this.set(u,this.#s[u])}}}delete(t){const{store:u}=this;if(this.#r.accessPropertiesByDotNotation){deleteProperty(u,t)}else{delete u[t]}this.store=u}clear(){this.store=createPlainObject();for(const t of Object.keys(this.#s)){this.reset(t)}}onDidChange(t,u){if(typeof t!=="string"){throw new TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof t}`)}if(typeof u!=="function"){throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof u}`)}return this._handleChange((()=>this.get(t)),u)}onDidAnyChange(t){if(typeof t!=="function"){throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof t}`)}return this._handleChange((()=>this.store),t)}get size(){return Object.keys(this.store).length}get store(){try{const t=k.readFileSync(this.path,this.#t?null:"utf8");const u=this._encryptData(t);const p=this._deserialize(u);this._validate(p);return Object.assign(createPlainObject(),p)}catch(t){if(t?.code==="ENOENT"){this._ensureDirectory();return createPlainObject()}if(this.#r.clearInvalidConfig&&t.name==="SyntaxError"){return createPlainObject()}throw t}}set store(t){this._ensureDirectory();this._validate(t);this._write(t);this.events.dispatchEvent(new Event("change"))}*[Symbol.iterator](){for(const[t,u]of Object.entries(this.store)){yield[t,u]}}_encryptData(t){if(!this.#t){return typeof t==="string"?t:uint8ArrayToString(t)}try{const u=t.slice(0,16);const p=I.pbkdf2Sync(this.#t,u.toString(),1e4,32,"sha512");const m=I.createDecipheriv(Ue,p,u);const g=t.slice(17);const v=typeof g==="string"?stringToUint8Array(g):g;return uint8ArrayToString(concatUint8Arrays([m.update(v),m.final()]))}catch{}return t.toString()}_handleChange(t,u){let p=t();const onChange=()=>{const m=p;const g=t();if((0,O.isDeepStrictEqual)(g,m)){return}p=g;u.call(this,g,m)};this.events.addEventListener("change",onChange);return()=>{this.events.removeEventListener("change",onChange)}}_deserialize=t=>JSON.parse(t);_serialize=t=>JSON.stringify(t,undefined,"\t");_validate(t){if(!this.#e){return}const u=this.#e(t);if(u||!this.#e.errors){return}const p=this.#e.errors.map((({instancePath:t,message:u=""})=>`\`${t.slice(1)}\` ${u}`));throw new Error("Config schema violation: "+p.join("; "))}_ensureDirectory(){k.mkdirSync(T.dirname(this.path),{recursive:true})}_write(t){let u=this._serialize(t);if(this.#t){const t=I.randomBytes(16);const p=I.pbkdf2Sync(this.#t,t.toString(),1e4,32,"sha512");const m=I.createCipheriv(Ue,p,t);u=concatUint8Arrays([t,stringToUint8Array(":"),m.update(stringToUint8Array(u)),m.final()])}if(A.env.SNAP){k.writeFileSync(this.path,u,{mode:this.#r.configFileMode})}else{try{writeFileSync(this.path,u,{mode:this.#r.configFileMode})}catch(t){if(t?.code==="EXDEV"){k.writeFileSync(this.path,u,{mode:this.#r.configFileMode});return}throw t}}}_watch(){this._ensureDirectory();if(!k.existsSync(this.path)){this._write(createPlainObject())}if(A.platform==="win32"){k.watch(this.path,{persistent:false},Ae((()=>{this.events.dispatchEvent(new Event("change"))}),{wait:100}))}else{k.watchFile(this.path,{persistent:false},Ae((()=>{this.events.dispatchEvent(new Event("change"))}),{wait:5e3}))}}_migrate(t,u,p){let m=this._get(He,"0.0.0");const g=Object.keys(t).filter((t=>this._shouldPerformMigration(t,m,u)));let v={...this.store};for(const b of g){try{if(p){p(this,{fromVersion:m,toVersion:b,finalVersion:u,versions:g})}const w=t[b];w?.(this);this._set(He,b);m=b;v={...this.store}}catch(t){this.store=v;throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${t}`)}}if(this._isVersionInRangeFormat(m)||!ke.eq(m,u)){this._set(He,u)}}_containsReservedKey(t){if(typeof t==="object"){const u=Object.keys(t)[0];if(u===Be){return true}}if(typeof t!=="string"){return false}if(this.#r.accessPropertiesByDotNotation){if(t.startsWith(`${Be}.`)){return true}return false}return false}_isVersionInRangeFormat(t){return ke.clean(t)===null}_shouldPerformMigration(t,u,p){if(this._isVersionInRangeFormat(t)){if(u!=="0.0.0"&&ke.satisfies(u,t)){return false}return ke.satisfies(p,t)}if(ke.lte(t,u)){return false}if(ke.gt(t,p)){return false}return true}_get(t,u){return getProperty(this.store,t,u)}_set(t,u){const{store:p}=this;setProperty(p,t,u);this.store=p}}var ze=__nccwpck_require__(9896);var Ve=__nccwpck_require__(6928);var Ge=__nccwpck_require__.n(Ve);var qe=__nccwpck_require__(9033);var We=__nccwpck_require__(7298);var Ke=__nccwpck_require__.n(We);var Ye=__nccwpck_require__(1083);var Ze=__nccwpck_require__.n(Ye);var Je=__nccwpck_require__(9850);var Xe=__nccwpck_require__.n(Je);const Qe=require("fs/promises");var et=__nccwpck_require__.n(Qe);var tt=__nccwpck_require__(857);var rt=__nccwpck_require__.n(tt);var st=__nccwpck_require__(2203);const it=require("stream/promises");var nt=__nccwpck_require__(4434);var ot=__nccwpck_require__(8474);const at=require("node:stream");const ut=require("node:string_decoder");const ht=require("assert");var dt=__nccwpck_require__(181);const ft=require("zlib");var pt=__nccwpck_require__.t(ft,2);const yt=require("node:fs/promises");var vt=Object.defineProperty;var Ur=(t,u)=>{for(var p in u)vt(t,p,{get:u[p],enumerable:!0})};var _t=typeof process=="object"&&process?process:{stdout:null,stderr:null},Wr=t=>!!t&&typeof t=="object"&&(t instanceof ir||t instanceof at||Gr(t)||Zr(t)),Gr=t=>!!t&&typeof t=="object"&&t instanceof ot.EventEmitter&&typeof t.pipe=="function"&&t.pipe!==at.Writable.prototype.pipe,Zr=t=>!!t&&typeof t=="object"&&t instanceof ot.EventEmitter&&typeof t.write=="function"&&typeof t.end=="function",bt=Symbol("EOF"),wt=Symbol("maybeEmitEnd"),Et=Symbol("emittedEnd"),St=Symbol("emittingEnd"),$t=Symbol("emittedError"),Pt=Symbol("closed"),Rt=Symbol("read"),Ot=Symbol("flush"),At=Symbol("flushChunk"),kt=Symbol("encoding"),Tt=Symbol("decoder"),Ct=Symbol("flowing"),It=Symbol("paused"),Nt=Symbol("resume"),Mt=Symbol("buffer"),Ft=Symbol("pipes"),Ut=Symbol("bufferLength"),Bt=Symbol("bufferPush"),Ht=Symbol("bufferShift"),zt=Symbol("objectMode"),Vt=Symbol("destroyed"),Gt=Symbol("error"),qt=Symbol("emitData"),Wt=Symbol("emitEnd"),Kt=Symbol("emitEnd2"),Yt=Symbol("async"),Zt=Symbol("abort"),Jt=Symbol("aborted"),Xt=Symbol("signal"),Qt=Symbol("dataListeners"),er=Symbol("discarded"),jt=t=>Promise.resolve().then(t),Yr=t=>t(),Kr=t=>t==="end"||t==="finish"||t==="prefinish",Vr=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,$r=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),tr=class{src;dest;opts;ondrain;constructor(t,u,p){this.src=t,this.dest=u,this.opts=p,this.ondrain=()=>t[Nt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},sr=class extends tr{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,u,p){super(t,u,p),this.proxyErrors=t=>this.dest.emit("error",t),t.on("error",this.proxyErrors)}},Xr=t=>!!t.objectMode,qr=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",ir=class extends ot.EventEmitter{[Ct]=!1;[It]=!1;[Ft]=[];[Mt]=[];[zt];[kt];[Yt];[Tt];[bt]=!1;[Et]=!1;[St]=!1;[Pt]=!1;[$t]=null;[Ut]=0;[Vt]=!1;[Xt];[Jt]=!1;[Qt]=0;[er]=!1;writable=!0;readable=!0;constructor(...t){let u=t[0]||{};if(super(),u.objectMode&&typeof u.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Xr(u)?(this[zt]=!0,this[kt]=null):qr(u)?(this[kt]=u.encoding,this[zt]=!1):(this[zt]=!1,this[kt]=null),this[Yt]=!!u.async,this[Tt]=this[kt]?new ut.StringDecoder(this[kt]):null,u&&u.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Mt]}),u&&u.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ft]});let{signal:p}=u;p&&(this[Xt]=p,p.aborted?this[Zt]():p.addEventListener("abort",(()=>this[Zt]())))}get bufferLength(){return this[Ut]}get encoding(){return this[kt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[zt]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Yt]}set async(t){this[Yt]=this[Yt]||!!t}[Zt](){this[Jt]=!0,this.emit("abort",this[Xt]?.reason),this.destroy(this[Xt]?.reason)}get aborted(){return this[Jt]}set aborted(t){}write(t,u,p){if(this[Jt])return!1;if(this[bt])throw new Error("write after end");if(this[Vt])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof u=="function"&&(p=u,u="utf8"),u||(u="utf8");let m=this[Yt]?jt:Yr;if(!this[zt]&&!Buffer.isBuffer(t)){if($r(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Vr(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[zt]?(this[Ct]&&this[Ut]!==0&&this[Ot](!0),this[Ct]?this.emit("data",t):this[Bt](t),this[Ut]!==0&&this.emit("readable"),p&&m(p),this[Ct]):t.length?(typeof t=="string"&&!(u===this[kt]&&!this[Tt]?.lastNeed)&&(t=Buffer.from(t,u)),Buffer.isBuffer(t)&&this[kt]&&(t=this[Tt].write(t)),this[Ct]&&this[Ut]!==0&&this[Ot](!0),this[Ct]?this.emit("data",t):this[Bt](t),this[Ut]!==0&&this.emit("readable"),p&&m(p),this[Ct]):(this[Ut]!==0&&this.emit("readable"),p&&m(p),this[Ct])}read(t){if(this[Vt])return null;if(this[er]=!1,this[Ut]===0||t===0||t&&t>this[Ut])return this[wt](),null;this[zt]&&(t=null),this[Mt].length>1&&!this[zt]&&(this[Mt]=[this[kt]?this[Mt].join(""):Buffer.concat(this[Mt],this[Ut])]);let u=this[Rt](t||null,this[Mt][0]);return this[wt](),u}[Rt](t,u){if(this[zt])this[Ht]();else{let p=u;t===p.length||t===null?this[Ht]():typeof p=="string"?(this[Mt][0]=p.slice(t),u=p.slice(0,t),this[Ut]-=t):(this[Mt][0]=p.subarray(t),u=p.subarray(0,t),this[Ut]-=t)}return this.emit("data",u),!this[Mt].length&&!this[bt]&&this.emit("drain"),u}end(t,u,p){return typeof t=="function"&&(p=t,t=void 0),typeof u=="function"&&(p=u,u="utf8"),t!==void 0&&this.write(t,u),p&&this.once("end",p),this[bt]=!0,this.writable=!1,(this[Ct]||!this[It])&&this[wt](),this}[Nt](){this[Vt]||(!this[Qt]&&!this[Ft].length&&(this[er]=!0),this[It]=!1,this[Ct]=!0,this.emit("resume"),this[Mt].length?this[Ot]():this[bt]?this[wt]():this.emit("drain"))}resume(){return this[Nt]()}pause(){this[Ct]=!1,this[It]=!0,this[er]=!1}get destroyed(){return this[Vt]}get flowing(){return this[Ct]}get paused(){return this[It]}[Bt](t){this[zt]?this[Ut]+=1:this[Ut]+=t.length,this[Mt].push(t)}[Ht](){return this[zt]?this[Ut]-=1:this[Ut]-=this[Mt][0].length,this[Mt].shift()}[Ot](t=!1){do{}while(this[At](this[Ht]())&&this[Mt].length);!t&&!this[Mt].length&&!this[bt]&&this.emit("drain")}[At](t){return this.emit("data",t),this[Ct]}pipe(t,u){if(this[Vt])return t;this[er]=!1;let p=this[Et];return u=u||{},t===_t.stdout||t===_t.stderr?u.end=!1:u.end=u.end!==!1,u.proxyErrors=!!u.proxyErrors,p?u.end&&t.end():(this[Ft].push(u.proxyErrors?new sr(this,t,u):new tr(this,t,u)),this[Yt]?jt((()=>this[Nt]())):this[Nt]()),t}unpipe(t){let u=this[Ft].find((u=>u.dest===t));u&&(this[Ft].length===1?(this[Ct]&&this[Qt]===0&&(this[Ct]=!1),this[Ft]=[]):this[Ft].splice(this[Ft].indexOf(u),1),u.unpipe())}addListener(t,u){return this.on(t,u)}on(t,u){let p=super.on(t,u);if(t==="data")this[er]=!1,this[Qt]++,!this[Ft].length&&!this[Ct]&&this[Nt]();else if(t==="readable"&&this[Ut]!==0)super.emit("readable");else if(Kr(t)&&this[Et])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[$t]){let t=u;this[Yt]?jt((()=>t.call(this,this[$t]))):t.call(this,this[$t])}return p}removeListener(t,u){return this.off(t,u)}off(t,u){let p=super.off(t,u);return t==="data"&&(this[Qt]=this.listeners("data").length,this[Qt]===0&&!this[er]&&!this[Ft].length&&(this[Ct]=!1)),p}removeAllListeners(t){let u=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Qt]=0,!this[er]&&!this[Ft].length&&(this[Ct]=!1)),u}get emittedEnd(){return this[Et]}[wt](){!this[St]&&!this[Et]&&!this[Vt]&&this[Mt].length===0&&this[bt]&&(this[St]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Pt]&&this.emit("close"),this[St]=!1)}emit(t,...u){let p=u[0];if(t!=="error"&&t!=="close"&&t!==Vt&&this[Vt])return!1;if(t==="data")return!this[zt]&&!p?!1:this[Yt]?(jt((()=>this[qt](p))),!0):this[qt](p);if(t==="end")return this[Wt]();if(t==="close"){if(this[Pt]=!0,!this[Et]&&!this[Vt])return!1;let t=super.emit("close");return this.removeAllListeners("close"),t}else if(t==="error"){this[$t]=p,super.emit(Gt,p);let t=!this[Xt]||this.listeners("error").length?super.emit("error",p):!1;return this[wt](),t}else if(t==="resume"){let t=super.emit("resume");return this[wt](),t}else if(t==="finish"||t==="prefinish"){let u=super.emit(t);return this.removeAllListeners(t),u}let m=super.emit(t,...u);return this[wt](),m}[qt](t){for(let u of this[Ft])u.dest.write(t)===!1&&this.pause();let u=this[er]?!1:super.emit("data",t);return this[wt](),u}[Wt](){return this[Et]?!1:(this[Et]=!0,this.readable=!1,this[Yt]?(jt((()=>this[Kt]())),!0):this[Kt]())}[Kt](){if(this[Tt]){let t=this[Tt].end();if(t){for(let u of this[Ft])u.dest.write(t);this[er]||super.emit("data",t)}}for(let t of this[Ft])t.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[zt]||(t.dataLength=0);let u=this.promise();return this.on("data",(u=>{t.push(u),this[zt]||(t.dataLength+=u.length)})),await u,t}async concat(){if(this[zt])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[kt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise(((t,u)=>{this.on(Vt,(()=>u(new Error("stream destroyed")))),this.on("error",(t=>u(t))),this.on("end",(()=>t()))}))}[Symbol.asyncIterator](){this[er]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let u=this.read();if(u!==null)return Promise.resolve({done:!1,value:u});if(this[bt])return e();let p,m,h=t=>{this.off("data",a),this.off("end",l),this.off(Vt,c),e(),m(t)},a=t=>{this.off("error",h),this.off("end",l),this.off(Vt,c),this.pause(),p({value:t,done:!!this[bt]})},l=()=>{this.off("error",h),this.off("data",a),this.off(Vt,c),e(),p({done:!0,value:void 0})},c=()=>h(new Error("stream destroyed"));return new Promise(((t,u)=>{m=u,p=t,this.once(Vt,c),this.once("error",h),this.once("end",l),this.once("data",a)}))},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[er]=!1;let t=!1,e=()=>(this.pause(),this.off(Gt,e),this.off(Vt,e),this.off("end",e),t=!0,{done:!0,value:void 0}),i=()=>{if(t)return e();let u=this.read();return u===null?e():{done:!1,value:u}};return this.once("end",e),this.once(Gt,e),this.once(Vt,e),{next:i,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Vt])return t?this.emit("error",t):this.emit(Vt),this;this[Vt]=!0,this[er]=!0,this[Mt].length=0,this[Ut]=0;let u=this;return typeof u.close=="function"&&!this[Pt]&&u.close(),t?this.emit("error",t):this.emit(Vt),this}static get isStream(){return Wr}};var nr=ze.writev,ar=Symbol("_autoClose"),cr=Symbol("_close"),lr=Symbol("_ended"),ur=Symbol("_fd"),hr=Symbol("_finished"),pr=Symbol("_flags"),mr=Symbol("_flush"),yr=Symbol("_handleChunk"),wr=Symbol("_makeBuf"),Er=Symbol("_mode"),Sr=Symbol("_needDrain"),Pr=Symbol("_onerror"),xr=Symbol("_onopen"),Rr=Symbol("_onread"),Or=Symbol("_onwrite"),Ar=Symbol("_open"),kr=Symbol("_path"),Cr=Symbol("_pos"),Ir=Symbol("_queue"),Nr=Symbol("_read"),Dr=Symbol("_readSize"),jr=Symbol("_reading"),Mr=Symbol("_remain"),Fr=Symbol("_size"),Br=Symbol("_write"),Hr=Symbol("_writing"),zr=Symbol("_defaultFlag"),Jr=Symbol("_errored"),Qr=class extends ir{[Jr]=!1;[ur];[kr];[Dr];[jr]=!1;[Fr];[Mr];[ar];constructor(t,u){if(u=u||{},super(u),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Jr]=!1,this[ur]=typeof u.fd=="number"?u.fd:void 0,this[kr]=t,this[Dr]=u.readSize||16*1024*1024,this[jr]=!1,this[Fr]=typeof u.size=="number"?u.size:1/0,this[Mr]=this[Fr],this[ar]=typeof u.autoClose=="boolean"?u.autoClose:!0,typeof this[ur]=="number"?this[Nr]():this[Ar]()}get fd(){return this[ur]}get path(){return this[kr]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[Ar](){ze.open(this[kr],"r",((t,u)=>this[xr](t,u)))}[xr](t,u){t?this[Pr](t):(this[ur]=u,this.emit("open",u),this[Nr]())}[wr](){return Buffer.allocUnsafe(Math.min(this[Dr],this[Mr]))}[Nr](){if(!this[jr]){this[jr]=!0;let t=this[wr]();if(t.length===0)return process.nextTick((()=>this[Rr](null,0,t)));ze.read(this[ur],t,0,t.length,null,((t,u,p)=>this[Rr](t,u,p)))}}[Rr](t,u,p){this[jr]=!1,t?this[Pr](t):this[yr](u,p)&&this[Nr]()}[cr](){if(this[ar]&&typeof this[ur]=="number"){let t=this[ur];this[ur]=void 0,ze.close(t,(t=>t?this.emit("error",t):this.emit("close")))}}[Pr](t){this[jr]=!0,this[cr](),this.emit("error",t)}[yr](t,u){let p=!1;return this[Mr]-=t,t>0&&(p=super.write(t<u.length?u.subarray(0,t):u)),(t===0||this[Mr]<=0)&&(p=!1,this[cr](),super.end()),p}emit(t,...u){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ur]=="number"&&this[Nr](),!1;case"error":return this[Jr]?!1:(this[Jr]=!0,super.emit(t,...u));default:return super.emit(t,...u)}}},es=class extends Qr{[Ar](){let t=!0;try{this[xr](null,ze.openSync(this[kr],"r")),t=!1}finally{t&&this[cr]()}}[Nr](){let t=!0;try{if(!this[jr]){this[jr]=!0;do{let t=this[wr](),u=t.length===0?0:ze.readSync(this[ur],t,0,t.length,null);if(!this[yr](u,t))break}while(!0);this[jr]=!1}t=!1}finally{t&&this[cr]()}}[cr](){if(this[ar]&&typeof this[ur]=="number"){let t=this[ur];this[ur]=void 0,ze.closeSync(t),this.emit("close")}}},rs=class extends nt{readable=!1;writable=!0;[Jr]=!1;[Hr]=!1;[lr]=!1;[Ir]=[];[Sr]=!1;[kr];[Er];[ar];[ur];[zr];[pr];[hr]=!1;[Cr];constructor(t,u){u=u||{},super(u),this[kr]=t,this[ur]=typeof u.fd=="number"?u.fd:void 0,this[Er]=u.mode===void 0?438:u.mode,this[Cr]=typeof u.start=="number"?u.start:void 0,this[ar]=typeof u.autoClose=="boolean"?u.autoClose:!0;let p=this[Cr]!==void 0?"r+":"w";this[zr]=u.flags===void 0,this[pr]=u.flags===void 0?p:u.flags,this[ur]===void 0&&this[Ar]()}emit(t,...u){if(t==="error"){if(this[Jr])return!1;this[Jr]=!0}return super.emit(t,...u)}get fd(){return this[ur]}get path(){return this[kr]}[Pr](t){this[cr](),this[Hr]=!0,this.emit("error",t)}[Ar](){ze.open(this[kr],this[pr],this[Er],((t,u)=>this[xr](t,u)))}[xr](t,u){this[zr]&&this[pr]==="r+"&&t&&t.code==="ENOENT"?(this[pr]="w",this[Ar]()):t?this[Pr](t):(this[ur]=u,this.emit("open",u),this[Hr]||this[mr]())}end(t,u){return t&&this.write(t,u),this[lr]=!0,!this[Hr]&&!this[Ir].length&&typeof this[ur]=="number"&&this[Or](null,0),this}write(t,u){return typeof t=="string"&&(t=Buffer.from(t,u)),this[lr]?(this.emit("error",new Error("write() after end()")),!1):this[ur]===void 0||this[Hr]||this[Ir].length?(this[Ir].push(t),this[Sr]=!0,!1):(this[Hr]=!0,this[Br](t),!0)}[Br](t){ze.write(this[ur],t,0,t.length,this[Cr],((t,u)=>this[Or](t,u)))}[Or](t,u){t?this[Pr](t):(this[Cr]!==void 0&&typeof u=="number"&&(this[Cr]+=u),this[Ir].length?this[mr]():(this[Hr]=!1,this[lr]&&!this[hr]?(this[hr]=!0,this[cr](),this.emit("finish")):this[Sr]&&(this[Sr]=!1,this.emit("drain"))))}[mr](){if(this[Ir].length===0)this[lr]&&this[Or](null,0);else if(this[Ir].length===1)this[Br](this[Ir].pop());else{let t=this[Ir];this[Ir]=[],nr(this[ur],t,this[Cr],((t,u)=>this[Or](t,u)))}}[cr](){if(this[ar]&&typeof this[ur]=="number"){let t=this[ur];this[ur]=void 0,ze.close(t,(t=>t?this.emit("error",t):this.emit("close")))}}},ss=class extends rs{[Ar](){let t;if(this[zr]&&this[pr]==="r+")try{t=ze.openSync(this[kr],this[pr],this[Er])}catch(t){if(t?.code==="ENOENT")return this[pr]="w",this[Ar]();throw t}else t=ze.openSync(this[kr],this[pr],this[Er]);this[xr](null,t)}[cr](){if(this[ar]&&typeof this[ur]=="number"){let t=this[ur];this[ur]=void 0,ze.closeSync(t),this.emit("close")}}[Br](t){let u=!0;try{this[Or](null,ze.writeSync(this[ur],t,0,t.length,this[Cr])),u=!1}finally{if(u)try{this[cr]()}catch{}}}};var is=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"]]),Fs=t=>!!t.sync&&!!t.file,ks=t=>!t.sync&&!!t.file,vs=t=>!!t.sync&&!t.file,Ms=t=>!t.sync&&!t.file;var Bs=t=>!!t.file;var tn=t=>{let u=is.get(t);return u||t},se=(t={})=>{if(!t)return{};let u={};for(let[p,m]of Object.entries(t)){let t=tn(p);u[t]=m}return u.chmod===void 0&&u.noChmod===!1&&(u.chmod=!0),delete u.noChmod,u};var K=(t,u,p,m,g)=>Object.assign(((v=[],b,w)=>{Array.isArray(v)&&(b=v,v={}),typeof b=="function"&&(w=b,b=void 0),b=b?Array.from(b):[];let E=se(v);if(g?.(E,b),Fs(E)){if(typeof w=="function")throw new TypeError("callback not supported for sync tar functions");return t(E,b)}else if(ks(E)){let t=u(E,b);return w?t.then((()=>w()),w):t}else if(vs(E)){if(typeof w=="function")throw new TypeError("callback not supported for sync tar functions");return p(E,b)}else if(Ms(E)){if(typeof w=="function")throw new TypeError("callback only supported with file option");return m(E,b)}throw new Error("impossible options??")}),{syncFile:t,asyncFile:u,syncNoFile:p,asyncNoFile:m,validate:g});var ns=ft.constants||{ZLIB_VERNUM:4736},os=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},ns));var as=dt.Buffer.concat,cs=Object.getOwnPropertyDescriptor(dt.Buffer,"concat"),nn=t=>t,ls=cs?.writable===!0||cs?.set!==void 0?t=>{dt.Buffer.concat=t?nn:as}:t=>{},us=Symbol("_superWrite"),hs=class extends Error{code;errno;constructor(t,u){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,u??this.constructor)}get name(){return"ZlibError"}},ds=Symbol("flushFlag"),ms=class extends ir{#i=!1;#n=!1;#o;#a;#c;#l;#u;get sawError(){return this.#i}get handle(){return this.#l}get flushFlag(){return this.#o}constructor(t,u){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#o=t.flush??0,this.#a=t.finishFlush??0,this.#c=t.fullFlushFlag??0,typeof pt[u]!="function")throw new TypeError("Compression method not supported: "+u);try{this.#l=new pt[u](t)}catch(t){throw new hs(t,this.constructor)}this.#u=t=>{this.#i||(this.#i=!0,this.close(),this.emit("error",t))},this.#l?.on("error",(t=>this.#u(new hs(t)))),this.once("end",(()=>this.close))}close(){this.#l&&(this.#l.close(),this.#l=void 0,this.emit("close"))}reset(){if(!this.#i)return ht(this.#l,"zlib binding closed"),this.#l.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#c),this.write(Object.assign(dt.Buffer.alloc(0),{[ds]:t})))}end(t,u,p){return typeof t=="function"&&(p=t,u=void 0,t=void 0),typeof u=="function"&&(p=u,u=void 0),t&&(u?this.write(t,u):this.write(t)),this.flush(this.#a),this.#n=!0,super.end(p)}get ended(){return this.#n}[us](t){return super.write(t)}write(t,u,p){if(typeof u=="function"&&(p=u,u="utf8"),typeof t=="string"&&(t=dt.Buffer.from(t,u)),this.#i)return;ht(this.#l,"zlib binding closed");let m=this.#l._handle,g=m.close;m.close=()=>{};let v=this.#l.close;this.#l.close=()=>{},ls(!0);let b;try{let u=typeof t[ds]=="number"?t[ds]:this.#o;b=this.#l._processChunk(t,u),ls(!1)}catch(t){ls(!1),this.#u(new hs(t,this.write))}finally{this.#l&&(this.#l._handle=m,m.close=g,this.#l.close=v,this.#l.removeAllListeners("error"))}this.#l&&this.#l.on("error",(t=>this.#u(new hs(t,this.write))));let w;if(b)if(Array.isArray(b)&&b.length>0){let t=b[0];w=this[us](dt.Buffer.from(t));for(let t=1;t<b.length;t++)w=this[us](b[t])}else w=this[us](dt.Buffer.from(b));return p&&p(),w}},gs=class extends ms{#i;#n;constructor(t,u){t=t||{},t.flush=t.flush||os.Z_NO_FLUSH,t.finishFlush=t.finishFlush||os.Z_FINISH,t.fullFlushFlag=os.Z_FULL_FLUSH,super(t,u),this.#i=t.level,this.#n=t.strategy}params(t,u){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#i!==t||this.#n!==u){this.flush(os.Z_SYNC_FLUSH),ht(this.handle,"zlib binding closed");let p=this.handle.flush;this.handle.flush=(t,u)=>{typeof t=="function"&&(u=t,t=this.flushFlag),this.flush(t),u?.()};try{this.handle.params(t,u)}finally{this.handle.flush=p}this.handle&&(this.#i=t,this.#n=u)}}}};var ys=class extends gs{#i;constructor(t){super(t,"Gzip"),this.#i=t&&!!t.portable}[us](t){return this.#i?(this.#i=!1,t[9]=255,super[us](t)):super[us](t)}};var _s=class extends gs{constructor(t){super(t,"Unzip")}},bs=class extends ms{constructor(t,u){t=t||{},t.flush=t.flush||os.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||os.BROTLI_OPERATION_FINISH,t.fullFlushFlag=os.BROTLI_OPERATION_FLUSH,super(t,u)}},$s=class extends bs{constructor(t){super(t,"BrotliCompress")}},Ps=class extends bs{constructor(t){super(t,"BrotliDecompress")}},xs=class extends ms{constructor(t,u){t=t||{},t.flush=t.flush||os.ZSTD_e_continue,t.finishFlush=t.finishFlush||os.ZSTD_e_end,t.fullFlushFlag=os.ZSTD_e_flush,super(t,u)}},Rs=class extends xs{constructor(t){super(t,"ZstdCompress")}},Os=class extends xs{constructor(t){super(t,"ZstdDecompress")}};var Us=(t,u)=>{if(Number.isSafeInteger(t))t<0?an(t,u):hn(t,u);else throw Error("cannot encode number outside of javascript safe integer range");return u},hn=(t,u)=>{u[0]=128;for(var p=u.length;p>1;p--)u[p-1]=t&255,t=Math.floor(t/256)},an=(t,u)=>{u[0]=255;var p=!1;t=t*-1;for(var m=u.length;m>1;m--){var g=t&255;t=Math.floor(t/256),p?u[m-1]=Ws(g):g===0?u[m-1]=0:(p=!0,u[m-1]=Gs(g))}},Hs=t=>{let u=t[0],p=u===128?cn(t.subarray(1,t.length)):u===255?ln(t):null;if(p===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(p))throw Error("parsed number outside of javascript safe integer range");return p},ln=t=>{for(var u=t.length,p=0,m=!1,g=u-1;g>-1;g--){var v=Number(t[g]),b;m?b=Ws(v):v===0?b=v:(m=!0,b=Gs(v)),b!==0&&(p-=b*Math.pow(256,u-g-1))}return p},cn=t=>{for(var u=t.length,p=0,m=u-1;m>-1;m--){var g=Number(t[m]);g!==0&&(p+=g*Math.pow(256,u-m-1))}return p},Ws=t=>(255^t)&255,Gs=t=>(255^t)+1&255;var As={};Ur(As,{code:()=>Is,isCode:()=>ne,isName:()=>dn,name:()=>Cs,normalFsTypes:()=>Ts});var ne=t=>Cs.has(t),dn=t=>Is.has(t),Ts=new Set(["0","","1","2","3","4","5","6","7","D"]),Cs=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"]]),Is=new Map(Array.from(Cs).map((t=>[t[1],t[0]])));var un=t=>t===void 0||t<0?void 0:t,Ns=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#i="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,u=0,p,m){Buffer.isBuffer(t)?this.decode(t,u||0,p,m):t&&this.#n(t)}decode(t,u,p,m){if(u||(u=0),!t||!(t.length>=u+512))throw new Error("need 512 bytes for header");let g=xt(t,u+156,1),v=Ts.has(g),b=v?p:void 0,w=v?m:void 0;if(this.path=b?.path??xt(t,u,100),this.mode=b?.mode??w?.mode??lt(t,u+100,8),this.uid=b?.uid??w?.uid??lt(t,u+108,8),this.gid=b?.gid??w?.gid??lt(t,u+116,8),this.size=un(b?.size??w?.size??lt(t,u+124,12)),this.mtime=b?.mtime??w?.mtime??Wi(t,u+136,12),this.cksum=lt(t,u+148,12),w&&this.#n(w,!0),b&&this.#n(b),ne(g)&&(this.#i=g||"0"),this.#i==="0"&&this.path.slice(-1)==="/"&&(this.#i="5"),this.#i==="5"&&(this.size=0),this.linkpath=xt(t,u+157,100),t.subarray(u+257,u+265).toString()==="ustar\x0000")if(this.uname=b?.uname??w?.uname??xt(t,u+265,32),this.gname=b?.gname??w?.gname??xt(t,u+297,32),this.devmaj=b?.devmaj??w?.devmaj??lt(t,u+329,8)??0,this.devmin=b?.devmin??w?.devmin??lt(t,u+337,8)??0,t[u+475]!==0){let p=xt(t,u+345,155);this.path=p+"/"+this.path}else{let g=xt(t,u+345,130);g&&(this.path=g+"/"+this.path),this.atime=p?.atime??m?.atime??Wi(t,u+476,12),this.ctime=p?.ctime??m?.ctime??Wi(t,u+488,12)}let E=256;for(let p=u;p<u+148;p++)E+=t[p];for(let p=u+156;p<u+512;p++)E+=t[p];this.cksumValid=E===this.cksum,this.cksum===void 0&&E===256&&(this.nullBlock=!0)}#n(t,u=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter((([t,p])=>!(p==null||t==="size"&&Number(p)<0||t==="path"&&u||t==="linkpath"&&u||t==="global")))))}encode(t,u=0){if(t||(t=this.block=Buffer.alloc(512)),this.#i==="Unsupported"&&(this.#i="0"),!(t.length>=u+512))throw new Error("need 512 bytes for header");let p=this.ctime||this.atime?130:155,m=mn(this.path||"",p),g=m[0],v=m[1];this.needPax=!!m[2],this.needPax=Lt(t,u,100,g)||this.needPax,this.needPax=ct(t,u+100,8,this.mode)||this.needPax,this.needPax=ct(t,u+108,8,this.uid)||this.needPax,this.needPax=ct(t,u+116,8,this.gid)||this.needPax,this.needPax=ct(t,u+124,12,this.size)||this.needPax,this.needPax=Gi(t,u+136,12,this.mtime)||this.needPax,t[u+156]=Number(this.#i.codePointAt(0)),this.needPax=Lt(t,u+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",u+257,8),this.needPax=Lt(t,u+265,32,this.uname)||this.needPax,this.needPax=Lt(t,u+297,32,this.gname)||this.needPax,this.needPax=ct(t,u+329,8,this.devmaj)||this.needPax,this.needPax=ct(t,u+337,8,this.devmin)||this.needPax,this.needPax=Lt(t,u+345,p,v)||this.needPax,t[u+475]!==0?this.needPax=Lt(t,u+345,155,v)||this.needPax:(this.needPax=Lt(t,u+345,130,v)||this.needPax,this.needPax=Gi(t,u+476,12,this.atime)||this.needPax,this.needPax=Gi(t,u+488,12,this.ctime)||this.needPax);let b=256;for(let p=u;p<u+148;p++)b+=t[p];for(let p=u+156;p<u+512;p++)b+=t[p];return this.cksum=b,ct(t,u+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#i==="Unsupported"?this.#i:Cs.get(this.#i)}get typeKey(){return this.#i}set type(t){let u=String(Is.get(t));if(ne(u)||u==="Unsupported")this.#i=u;else if(ne(t))this.#i=t;else throw new TypeError("invalid entry type: "+t)}},mn=(t,u)=>{let p=t,m="",g,v=T.posix.parse(t).root||".";if(Buffer.byteLength(p)<100)g=[p,m,!1];else{m=T.posix.dirname(p),p=T.posix.basename(p);do{Buffer.byteLength(p)<=100&&Buffer.byteLength(m)<=u?g=[p,m,!1]:Buffer.byteLength(p)>100&&Buffer.byteLength(m)<=u?g=[p.slice(0,99),m,!0]:(p=T.posix.join(T.posix.basename(m),p),m=T.posix.dirname(m))}while(m!==v&&g===void 0);g||(g=[t.slice(0,99),"",!0])}return g},xt=(t,u,p)=>t.subarray(u,u+p).toString("utf8").replace(/\0.*/,""),Wi=(t,u,p)=>pn(lt(t,u,p)),pn=t=>t===void 0?void 0:new Date(t*1e3),lt=(t,u,p)=>Number(t[u])&128?Hs(t.subarray(u,u+p)):wn(t,u,p),En=t=>isNaN(t)?void 0:t,wn=(t,u,p)=>En(parseInt(t.subarray(u,u+p).toString("utf8").replace(/\0.*$/,"").trim(),8)),Ds={12:8589934591,8:2097151},ct=(t,u,p,m)=>m===void 0?!1:m>Ds[p]||m<0?(Us(m,t.subarray(u,u+p)),!0):(yn(t,u,p,m),!1),yn=(t,u,p,m)=>t.write(Rn(m,p),u,p,"ascii"),Rn=(t,u)=>gn(Math.floor(t).toString(8),u),gn=(t,u)=>(t.length===u-1?t:new Array(u-t.length-1).join("0")+t+" ")+"\0",Gi=(t,u,p,m)=>m===void 0?!1:ct(t,u,p,m.getTime()/1e3),js=new Array(156).join("\0"),Lt=(t,u,p,m)=>m===void 0?!1:(t.write(m+js,u,p,"utf8"),m.length!==Buffer.byteLength(m)||m.length>p);var Ls=class s{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(t,u=!1){this.atime=t.atime,this.charset=t.charset,this.comment=t.comment,this.ctime=t.ctime,this.dev=t.dev,this.gid=t.gid,this.global=u,this.gname=t.gname,this.ino=t.ino,this.linkpath=t.linkpath,this.mtime=t.mtime,this.nlink=t.nlink,this.path=t.path,this.size=t.size,this.uid=t.uid,this.uname=t.uname}encode(){let t=this.encodeBody();if(t==="")return Buffer.allocUnsafe(0);let u=Buffer.byteLength(t),p=512*Math.ceil(1+u/512),m=Buffer.allocUnsafe(p);for(let t=0;t<512;t++)m[t]=0;new Ns({path:("PaxHeader/"+(0,T.basename)(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:u,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(m),m.write(t,512,u,"utf8");for(let t=u+512;t<m.length;t++)m[t]=0;return m}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(t){if(this[t]===void 0)return"";let u=this[t],p=u instanceof Date?u.getTime()/1e3:u,m=" "+(t==="dev"||t==="ino"||t==="nlink"?"SCHILY.":"")+t+"="+p+`\n`,g=Buffer.byteLength(m),v=Math.floor(Math.log(g)/Math.log(10))+1;return g+v>=Math.pow(10,v)&&(v+=1),v+g+m}static parse(t,u,p=!1){return new s(On(Tn(t),u),p)}},On=(t,u)=>u?Object.assign({},u,t):t,Tn=t=>t.replace(/\n$/,"").split(`\n`).reduce(xn,Object.create(null)),xn=(t,u)=>{let p=parseInt(u,10);if(p!==Buffer.byteLength(u)+1)return t;u=u.slice((p+" ").length);let m=u.split("="),g=m.shift();if(!g)return t;let v=g.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),b=m.join("=").replace(/\0.*/,"");switch(v){case"path":case"linkpath":case"type":case"charset":case"comment":case"gname":case"uname":t[v]=b;break;case"ctime":case"atime":case"mtime":t[v]=new Date(Number(b)*1e3);break;case"size":let u=+b;u>=0&&(t[v]=u);break;case"gid":case"uid":case"dev":case"ino":case"nlink":case"mode":t[v]=+b;break}return t};var zs=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Vs=zs!=="win32"?t=>String(t):t=>String(t).replaceAll(/\\/g,"/");var qs=class extends ir{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,u,p){switch(super({}),this.pause(),this.extended=u,this.globalExtended=p,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Vs(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Vs(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,u&&this.#i(u),p&&this.#i(p,!0)}write(t){let u=t.length;if(u>this.blockRemain)throw new Error("writing more to entry than is appropriate");let p=this.remain,m=this.blockRemain;return this.remain=Math.max(0,p-u),this.blockRemain=Math.max(0,m-u),this.ignore?!0:p>=u?super.write(t):super.write(t.subarray(0,p))}#i(t,u=!1){t.path&&(t.path=Vs(t.path)),t.linkpath&&(t.linkpath=Vs(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter((([t,p])=>!(p==null||t==="path"&&u)))))}};var Dt=(t,u,p,m={})=>{t.file&&(m.file=t.file),t.cwd&&(m.cwd=t.cwd),m.code=p instanceof Error&&p.code||u,m.tarCode=u,!t.strict&&m.recoverable!==!1?(p instanceof Error&&(m=Object.assign(p,m),p=p.message),t.emit("warn",u,p,m)):p instanceof Error?t.emit("error",Object.assign(p,m)):t.emit("error",Object.assign(new Error(`${u}: ${p}`),m))};var Ks=1024*1024,Ys=Buffer.from([31,139]),Zs=Buffer.from([40,181,47,253]),Js=Math.max(Ys.length,Zs.length),Xs=Symbol("state"),ei=Symbol("writeEntry"),ti=Symbol("readEntry"),ri=Symbol("nextEntry"),si=Symbol("processEntry"),ii=Symbol("extendedHeader"),ni=Symbol("globalExtendedHeader"),oi=Symbol("meta"),ai=Symbol("emitMeta"),ci=Symbol("buffer"),li=Symbol("queue"),ui=Symbol("ended"),hi=Symbol("emittedEnd"),di=Symbol("emit"),fi=Symbol("unzip"),pi=Symbol("consumeChunk"),mi=Symbol("consumeChunkSub"),gi=Symbol("consumeBody"),yi=Symbol("consumeMeta"),vi=Symbol("consumeHeader"),_i=Symbol("consuming"),bi=Symbol("bufferConcat"),wi=Symbol("maybeEnd"),Si=Symbol("writing"),$i=Symbol("aborted"),Pi=Symbol("onDone"),xi=Symbol("sawValidEntry"),Ri=Symbol("sawNullBlock"),Oi=Symbol("sawEOF"),Ai=Symbol("closeStream"),ki=1e3,Ti=Symbol("compressedBytesRead"),Ci=Symbol("decompressedBytesRead"),Ii=Symbol("checkDecompressionRatio"),Cn=()=>!0,Ni=class extends nt.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;maxDecompressionRatio;writable=!0;readable=!1;[li]=[];[ci];[ti];[ei];[Xs]="begin";[oi]="";[ii];[ni];[ui]=!1;[fi];[$i]=!1;[xi];[Ri]=!1;[Oi]=!1;[Si]=!1;[_i]=!1;[hi]=!1;[Ti]=0;[Ci]=0;constructor(t={}){super(),this.file=t.file||"",this.on(Pi,(()=>{(this[Xs]==="begin"||this[xi]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")})),t.ondone?this.on(Pi,t.ondone):this.on(Pi,(()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")})),this.strict=!!t.strict,this.maxDecompressionRatio=typeof t.maxDecompressionRatio=="number"?t.maxDecompressionRatio:ki,this.maxMetaEntrySize=t.maxMetaEntrySize||Ks,this.filter=typeof t.filter=="function"?t.filter:Cn;let u=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:u?void 0:!1;let p=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:p?!0:void 0,this.on("end",(()=>this[Ai]())),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,u,p={}){Dt(this,t,u,p)}[vi](t,u){this[xi]===void 0&&(this[xi]=!1);let p;try{p=new Ns(t,u,this[ii],this[ni])}catch(t){return this.warn("TAR_ENTRY_INVALID",t)}if(p.nullBlock)this[Ri]?(this[Oi]=!0,this[Xs]==="begin"&&(this[Xs]="header"),this[di]("eof")):(this[Ri]=!0,this[di]("nullBlock"));else if(this[Ri]=!1,!p.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:p});else if(!p.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:p});else{let t=p.type;if(/^(Symbolic)?Link$/.test(t)&&!p.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:p});else if(!/^(Symbolic)?Link$/.test(t)&&!/^(Global)?ExtendedHeader$/.test(t)&&p.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:p});else{let t=this[ei]=new qs(p,this[ii],this[ni]);if(!this[xi])if(t.remain){let o=()=>{t.invalid||(this[xi]=!0)};t.on("end",o)}else this[xi]=!0;t.meta?t.size>this.maxMetaEntrySize?(t.ignore=!0,this[di]("ignoredEntry",t),this[Xs]="ignore",t.resume()):t.size>0&&(this[oi]="",t.on("data",(t=>this[oi]+=t)),this[Xs]="meta"):(this[ii]=void 0,t.ignore=t.ignore||!this.filter(t.path,t),t.ignore?(this[di]("ignoredEntry",t),this[Xs]=t.remain?"ignore":"header",t.resume()):(t.remain?this[Xs]="body":(this[Xs]="header",t.end()),this[ti]?this[li].push(t):(this[li].push(t),this[ri]())))}}}[Ai](){queueMicrotask((()=>this.emit("close")))}[si](t){let u=!0;if(!t)this[ti]=void 0,u=!1;else if(Array.isArray(t)){let[u,...p]=t;this.emit(u,...p)}else this[ti]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",(()=>this[ri]())),u=!1);return u}[ri](){do{}while(this[si](this[li].shift()));if(this[li].length===0){let t=this[ti];!t||t.flowing||t.size===t.remain?this[Si]||this.emit("drain"):t.once("drain",(()=>this.emit("drain")))}}[gi](t,u){let p=this[ei];if(!p)throw new Error("attempt to consume body without entry??");let m=p.blockRemain??0,g=m>=t.length&&u===0?t:t.subarray(u,u+m);return p.write(g),p.blockRemain||(this[Xs]="header",this[ei]=void 0,p.end()),g.length}[yi](t,u){let p=this[ei],m=this[gi](t,u);return!this[ei]&&p&&this[ai](p),m}[di](t,u,p){this[li].length===0&&!this[ti]?this.emit(t,u,p):this[li].push([t,u,p])}[ai](t){switch(this[di]("meta",this[oi]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[ii]=Ls.parse(this[oi],this[ii],!1);break;case"GlobalExtendedHeader":this[ni]=Ls.parse(this[oi],this[ni],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let t=this[ii]??Object.create(null);this[ii]=t,t.path=this[oi].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let t=this[ii]||Object.create(null);this[ii]=t,t.linkpath=this[oi].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){if(!this[$i]){if(this[fi]){let t=this[fi];t.write=()=>!0,t.end=()=>t,t.emit=()=>!1,t.destroy?.()}this[$i]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}}[Ii](t){this[Ci]+=t.length;let u=this[Ci]/this[Ti];return u>this.maxDecompressionRatio?(this.abort(new Error(`max decompression ratio exceeded: ${u.toFixed(2)} > ${this.maxDecompressionRatio}`)),!1):!0}write(t,u,p){if(typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof u=="string"?u:"utf8")),this[$i])return p?.(),!1;if((this[fi]===void 0||this.brotli===void 0&&this[fi]===!1)&&t){if(this[ci]&&(t=Buffer.concat([this[ci],t]),this[ci]=void 0),t.length<Js)return this[ci]=t,p?.(),!0;for(let u=0;this[fi]===void 0&&u<Ys.length;u++)t[u]!==Ys[u]&&(this[fi]=!1);let u=!1;if(this[fi]===!1&&this.zstd!==!1){u=!0;for(let p=0;p<Zs.length;p++)if(t[p]!==Zs[p]){u=!1;break}}let m=this.brotli===void 0&&!u;if(this[fi]===!1&&m)if(t.length<512)if(this[ui])this.brotli=!0;else return this[ci]=t,p?.(),!0;else try{new Ns(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[fi]===void 0||this[fi]===!1&&(this.brotli||u)){let m=this[ui];this[ui]=!1,this[fi]=this[fi]===void 0?new _s({}):u?new Os({}):new Ps({}),this[fi].on("data",(t=>{this[Ii](t)&&this[pi](t)})),this[fi].on("error",(t=>{this[$i]||this.abort(t)})),this[fi].on("end",(()=>{this[ui]=!0,this[pi]()})),this[Si]=!0,this[Ti]+=t.length;let g=!!this[fi][m?"end":"write"](t);return this[Si]=!1,p?.(),g}}this[Si]=!0,this[fi]?(this[Ti]+=t.length,this[fi].write(t)):this[pi](t),this[Si]=!1;let m=this[li].length>0?!1:this[ti]?this[ti].flowing:!0;return!m&&this[li].length===0&&this[ti]?.once("drain",(()=>this.emit("drain"))),p?.(),m}[bi](t){t&&!this[$i]&&(this[ci]=this[ci]?Buffer.concat([this[ci],t]):t)}[wi](){if(this[ui]&&!this[hi]&&!this[$i]&&!this[_i]){this[hi]=!0;let t=this[ei];if(t?.blockRemain){let u=this[ci]?this[ci].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${u} available)`,{entry:t}),this[ci]&&t.write(this[ci]),t.end()}this[di](Pi)}}[pi](t){if(this[_i]&&t)this[bi](t);else if(!t&&!this[ci])this[wi]();else if(t){if(this[_i]=!0,this[ci]){this[bi](t);let u=this[ci];this[ci]=void 0,this[mi](u)}else this[mi](t);for(;this[ci]&&this[ci]?.length>=512&&!this[$i]&&!this[Oi];){let t=this[ci];this[ci]=void 0,this[mi](t)}this[_i]=!1}(!this[ci]||this[ui])&&this[wi]()}[mi](t){let u=0,p=t.length;for(;u+512<=p&&!this[$i]&&!this[Oi];)switch(this[Xs]){case"begin":case"header":this[vi](t,u),u+=512;break;case"ignore":case"body":u+=this[gi](t,u);break;case"meta":u+=this[yi](t,u);break;default:throw new Error("invalid state: "+this[Xs])}u<p&&(this[ci]=this[ci]?Buffer.concat([t.subarray(u),this[ci]]):t.subarray(u))}end(t,u,p){return typeof t=="function"&&(p=t,u=void 0,t=void 0),typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,u)),p&&this.once("finish",p),this[$i]||(this[fi]?(t&&(this[Ti]+=t.length,this[fi].write(t)),this[fi].end()):(this[ui]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[wi]())),this}};var mt=t=>{let u=t.length-1,p=-1;for(;u>-1&&t.charAt(u)==="/";)p=u,u--;return p===-1?t:t.slice(0,p)};var vn=t=>{let u=t.onReadEntry;t.onReadEntry=u?t=>{u(t),t.resume()}:t=>t.resume()},Qi=(t,u)=>{let p=new Map(u.map((t=>[mt(t),!0]))),m=t.filter,g=100,n=(t,u="",m=0)=>{if(m>=g)return p.set(t,!1),!1;let v=u||(0,Ve.parse)(t).root||".",b;if(t===v)b=!1;else{let u=p.get(t);b=u!==void 0?u:n((0,Ve.dirname)(t),v,m+1)}return p.set(t,b),b};t.filter=m?(t,u)=>m(t,u)&&n(mt(t)):t=>n(mt(t))},Mn=t=>{let u=new Ni(t),p=t.file,m;try{m=k.openSync(p,"r");let g=k.fstatSync(m),v=t.maxReadSize||16*1024*1024;if(g.size<v){let t=Buffer.allocUnsafe(g.size),p=k.readSync(m,t,0,g.size,0);u.end(p===t.byteLength?t:t.subarray(0,p))}else{let t=0,p=Buffer.allocUnsafe(v);for(;t<g.size;){let g=k.readSync(m,p,0,v,t);if(g===0)break;t+=g,u.write(p.subarray(0,g))}u.end()}}finally{if(typeof m=="number")try{k.closeSync(m)}catch{}}},Bn=(t,u)=>{let p=new Ni(t),m=t.maxReadSize||16*1024*1024,g=t.file;return new Promise(((t,u)=>{p.on("error",u),p.on("end",t),k.stat(g,((t,v)=>{if(t)u(t);else{let t=new Qr(g,{readSize:m,size:v.size});t.on("error",u),t.pipe(p)}}))}))},Di=K(Mn,Bn,(t=>new Ni(t)),(t=>new Ni(t)),((t,u)=>{u?.length&&Qi(t,u),t.noResume||vn(t)}));var Ji=(t,u,p)=>(t&=4095,p&&(t=(t|384)&-19),u&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t);var{isAbsolute:ji,parse:Li}=T.win32,ce=t=>{let u="",p=Li(t);for(;ji(t)||p.root;){let m=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":p.root;t=t.slice(m.length),u+=m,p=Li(t)}return[u,t]};var Mi=["|","<",">","?",":"],Fi=Mi.map((t=>String.fromCodePoint(61440+Number(t.codePointAt(0))))),Ui=new Map(Mi.map(((t,u)=>[t,Fi[u]]))),Bi=new Map(Fi.map(((t,u)=>[t,Mi[u]]))),ts=t=>Mi.reduce(((t,u)=>t.split(u).join(Ui.get(u))),t),Qs=t=>Fi.reduce(((t,u)=>t.split(u).join(Bi.get(u))),t);var rr=(t,u)=>u?(t=Vs(t).replace(/^\.(\/|$)/,""),mt(u)+"/"+t):Vs(t),Hi=16*1024*1024,zi=Symbol("process"),Vi=Symbol("file"),qi=Symbol("directory"),Ki=Symbol("symlink"),Yi=Symbol("hardlink"),Zi=Symbol("header"),Xi=Symbol("read"),en=Symbol("lstat"),rn=Symbol("onlstat"),sn=Symbol("onread"),on=Symbol("onreadlink"),fn=Symbol("openfile"),_n=Symbol("onopenfile"),bn=Symbol("close"),Sn=Symbol("mode"),Pn=Symbol("awaitDrain"),An=Symbol("ondrain"),kn=Symbol("prefix"),In=class extends ir{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#i=!1;constructor(t,u={}){let p=se(u);super(),this.path=Vs(t),this.portable=!!p.portable,this.maxReadSize=p.maxReadSize||Hi,this.linkCache=p.linkCache||new Map,this.statCache=p.statCache||new Map,this.preservePaths=!!p.preservePaths,this.cwd=Vs(p.cwd||process.cwd()),this.strict=!!p.strict,this.noPax=!!p.noPax,this.noMtime=!!p.noMtime,this.mtime=p.mtime,this.prefix=p.prefix?Vs(p.prefix):void 0,this.onWriteEntry=p.onWriteEntry,typeof p.onwarn=="function"&&this.on("warn",p.onwarn);let m=!1;if(!this.preservePaths){let[t,u]=ce(this.path);t&&typeof u=="string"&&(this.path=u,m=t)}this.win32=!!p.win32||process.platform==="win32",this.win32&&(this.path=Qs(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Vs(p.absolute||Ve.resolve(this.cwd,t)),this.path===""&&(this.path="./"),m&&this.warn("TAR_ENTRY_INFO",`stripping ${m} from absolute path`,{entry:this,path:m+this.path});let g=this.statCache.get(this.absolute);g?this[rn](g):this[en]()}warn(t,u,p={}){return Dt(this,t,u,p)}emit(t,...u){return t==="error"&&(this.#i=!0),super.emit(t,...u)}[en](){ze.lstat(this.absolute,((t,u)=>{if(t)return this.emit("error",t);this[rn](u)}))}[rn](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Gn(t),this.emit("stat",t),this[zi]()}[zi](){switch(this.type){case"File":return this[Vi]();case"Directory":return this[qi]();case"SymbolicLink":return this[Ki]();default:return this.end()}}[Sn](t){return Ji(t,this.type==="Directory",this.portable)}[kn](t){return rr(t,this.prefix)}[Zi](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Ns({path:this[kn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kn](this.linkpath):this.linkpath,mode:this[Sn](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 Ls({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[kn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kn](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[qi](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Zi](),this.end()}[Ki](){ze.readlink(this.absolute,((t,u)=>{if(t)return this.emit("error",t);this[on](u)}))}[on](t){this.linkpath=Vs(t),this[Zi](),this.end()}[Yi](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Vs(Ve.relative(this.cwd,t)),this.stat.size=0,this[Zi](),this.end()}[Vi](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,u=this.linkCache.get(t);if(u?.indexOf(this.cwd)===0)return this[Yi](u);this.linkCache.set(t,this.absolute)}if(this[Zi](),this.stat.size===0)return this.end();this[fn]()}[fn](){ze.open(this.absolute,"r",((t,u)=>{if(t)return this.emit("error",t);this[_n](u)}))}[_n](t){if(this.fd=t,this.#i)return this[bn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let u=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(u),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Xi]()}[Xi](){let{fd:t,buf:u,offset:p,length:m,pos:g}=this;if(t===void 0||u===void 0)throw new Error("cannot read file without first opening");ze.read(t,u,p,m,g,((t,u)=>{if(t)return this[bn]((()=>this.emit("error",t)));this[sn](u)}))}[bn](t=()=>{}){this.fd!==void 0&&ze.close(this.fd,t)}[sn](t){if(t<=0&&this.remain>0){let t=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[bn]((()=>this.emit("error",t)))}if(t>this.remain){let t=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[bn]((()=>this.emit("error",t)))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let u=t;u<this.length&&t<this.blockRemain;u++)this.buf[u+this.offset]=0,t++,this.remain++;let u=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(u)?this[An]():this[Pn]((()=>this[An]()))}[Pn](t){this.once("drain",t)}write(t,u,p){if(typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof u=="string"?u:"utf8")),this.blockRemain<t.length){let t=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",t)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,p)}[An](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[bn]((t=>t?this.emit("error",t):this.end()));if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[Xi]()}},Nn=class extends In{sync=!0;[en](){this[rn](ze.lstatSync(this.absolute))}[Ki](){this[on](ze.readlinkSync(this.absolute))}[fn](){this[_n](ze.openSync(this.absolute,"r"))}[Xi](){let t=!0;try{let{fd:u,buf:p,offset:m,length:g,pos:v}=this;if(u===void 0||p===void 0)throw new Error("fd and buf must be set in READ method");let b=ze.readSync(u,p,m,g,v);this[sn](b),t=!1}finally{if(t)try{this[bn]((()=>{}))}catch{}}}[Pn](t){t()}[bn](t=()=>{}){this.fd!==void 0&&ze.closeSync(this.fd),t()}},Dn=class extends ir{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,u,p={}){return Dt(this,t,u,p)}constructor(t,u={}){let p=se(u);super(),this.preservePaths=!!p.preservePaths,this.portable=!!p.portable,this.strict=!!p.strict,this.noPax=!!p.noPax,this.noMtime=!!p.noMtime,this.onWriteEntry=p.onWriteEntry,this.readEntry=t;let{type:m}=t;if(m==="Unsupported")throw new Error("writing entry that should be ignored");this.type=m,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=p.prefix,this.path=Vs(t.path),this.mode=t.mode!==void 0?this[Sn](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:p.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Vs(t.linkpath):void 0,typeof p.onwarn=="function"&&this.on("warn",p.onwarn);let g=!1;if(!this.preservePaths){let[t,u]=ce(this.path);t&&typeof u=="string"&&(this.path=u,g=t)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Ns({path:this[kn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kn](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}),g&&this.warn("TAR_ENTRY_INFO",`stripping ${g} from absolute path`,{entry:this,path:g+this.path}),this.header.encode()&&!this.noPax&&super.write(new Ls({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[kn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kn](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let v=this.header?.block;if(!v)throw new Error("failed to encode header");super.write(v),t.pipe(this)}[kn](t){return rr(t,this.prefix)}[Sn](t){return Ji(t,this.type==="Directory",this.portable)}write(t,u,p){typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof u=="string"?u:"utf8"));let m=t.length;if(m>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=m,super.write(t,p)}end(t,u,p){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(p=t,u=void 0,t=void 0),typeof u=="function"&&(p=u,u=void 0),typeof t=="string"&&(t=Buffer.from(t,u??"utf8")),p&&this.once("finish",p),t?super.end(t,p):super.end(p),this}},Gn=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";var jn=class s{tail;head;length=0;static create(t=[]){return new s(t)}constructor(t=[]){for(let u of t)this.push(u)}*[Symbol.iterator](){for(let t=this.head;t;t=t.next)yield t.value}removeNode(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");let u=t.next,p=t.prev;return u&&(u.prev=p),p&&(p.next=u),t===this.head&&(this.head=u),t===this.tail&&(this.tail=p),this.length--,t.next=void 0,t.prev=void 0,t.list=void 0,u}unshiftNode(t){if(t===this.head)return;t.list&&t.list.removeNode(t);let u=this.head;t.list=this,t.next=u,u&&(u.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}pushNode(t){if(t===this.tail)return;t.list&&t.list.removeNode(t);let u=this.tail;t.list=this,t.prev=u,u&&(u.next=t),this.tail=t,this.head||(this.head=t),this.length++}push(...t){for(let u=0,p=t.length;u<p;u++)Yn(this,t[u]);return this.length}unshift(...t){for(var u=0,p=t.length;u<p;u++)Kn(this,t[u]);return this.length}pop(){if(!this.tail)return;let t=this.tail.value,u=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,u.list=void 0,this.length--,t}shift(){if(!this.head)return;let t=this.head.value,u=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,u.list=void 0,this.length--,t}forEach(t,u){u=u||this;for(let p=this.head,m=0;p;m++)t.call(u,p.value,m,this),p=p.next}forEachReverse(t,u){u=u||this;for(let p=this.tail,m=this.length-1;p;m--)t.call(u,p.value,m,this),p=p.prev}get(t){let u=0,p=this.head;for(;p&&u<t;u++)p=p.next;if(u===t&&p)return p.value}getReverse(t){let u=0,p=this.tail;for(;p&&u<t;u++)p=p.prev;if(u===t&&p)return p.value}map(t,u){u=u||this;let p=new s;for(let m=this.head;m;)p.push(t.call(u,m.value,this)),m=m.next;return p}mapReverse(t,u){u=u||this;var p=new s;for(let m=this.tail;m;)p.push(t.call(u,m.value,this)),m=m.prev;return p}reduce(t,u){let p,m=this.head;if(arguments.length>1)p=u;else if(this.head)m=this.head.next,p=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var g=0;m;g++)p=t(p,m.value,g),m=m.next;return p}reduceReverse(t,u){let p,m=this.tail;if(arguments.length>1)p=u;else if(this.tail)m=this.tail.prev,p=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let u=this.length-1;m;u--)p=t(p,m.value,u),m=m.prev;return p}toArray(){let t=new Array(this.length);for(let u=0,p=this.head;p;u++)t[u]=p.value,p=p.next;return t}toArrayReverse(){let t=new Array(this.length);for(let u=0,p=this.tail;p;u++)t[u]=p.value,p=p.prev;return t}slice(t=0,u=this.length){u<0&&(u+=this.length),t<0&&(t+=this.length);let p=new s;if(u<t||u<0)return p;t<0&&(t=0),u>this.length&&(u=this.length);let m=this.head,g=0;for(g=0;m&&g<t;g++)m=m.next;for(;m&&g<u;g++,m=m.next)p.push(m.value);return p}sliceReverse(t=0,u=this.length){u<0&&(u+=this.length),t<0&&(t+=this.length);let p=new s;if(u<t||u<0)return p;t<0&&(t=0),u>this.length&&(u=this.length);let m=this.length,g=this.tail;for(;g&&m>u;m--)g=g.prev;for(;g&&m>t;m--,g=g.prev)p.push(g.value);return p}splice(t,u=0,...p){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);let m=this.head;for(let u=0;m&&u<t;u++)m=m.next;let g=[];for(let t=0;m&&t<u;t++)g.push(m.value),m=this.removeNode(m);m?m!==this.tail&&(m=m.prev):m=this.tail;for(let t of p)m=Zn(this,m,t);return g}reverse(){let t=this.head,u=this.tail;for(let u=t;u;u=u.prev){let t=u.prev;u.prev=u.next,u.next=t}return this.head=u,this.tail=t,this}};function Zn(t,u,p){let m=u,g=u?u.next:t.head,v=new Ln(p,m,g,t);return v.next===void 0&&(t.tail=v),v.prev===void 0&&(t.head=v),t.length++,v}function Yn(t,u){t.tail=new Ln(u,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function Kn(t,u){t.head=new Ln(u,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Ln=class{list;next;prev;value;constructor(t,u,p,m){this.list=m,this.value=t,u?(u.next=this,this.prev=u):this.prev=void 0,p?(p.prev=this,this.next=p):this.next=void 0}};var Fn=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,u){this.path=t||"./",this.absolute=u}},Un=Buffer.alloc(1024),Hn=Symbol("onStat"),zn=Symbol("ended"),Wn=Symbol("queue"),Jn=Symbol("pendingLinks"),Qn=Symbol("current"),eo=Symbol("process"),to=Symbol("processing"),ro=Symbol("processJob"),ao=Symbol("jobs"),co=Symbol("jobDone"),uo=Symbol("addFSEntry"),ho=Symbol("addTarEntry"),fo=Symbol("stat"),vo=Symbol("readdir"),So=Symbol("onreaddir"),$o=Symbol("pipe"),Po=Symbol("entry"),xo=Symbol("entryOpt"),Oo=Symbol("writeEntryClass"),Ao=Symbol("write"),ko=Symbol("ondrain"),Co=class extends ir{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Oo];onWriteEntry;[Wn];[Jn]=new Map;[ao]=0;[to]=!1;[zn]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Vs(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Oo]=In,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new ys(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new $s(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Rs(t.zstd)),!this.zip)throw new Error("impossible");let u=this.zip;u.on("data",(t=>super.write(t))),u.on("end",(()=>super.end())),u.on("drain",(()=>this[ko]())),this.on("resume",(()=>u.resume()))}else this.on("drain",this[ko]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[Wn]=new jn,this[ao]=0,this.jobs=Number(t.jobs)||4,this[to]=!1,this[zn]=!1}[Ao](t){return super.write(t)}add(t){return this.write(t),this}end(t,u,p){return typeof t=="function"&&(p=t,t=void 0),typeof u=="function"&&(p=u,u=void 0),t&&this.add(t),this[zn]=!0,this[eo](),p&&p(),this}write(t){if(this[zn])throw new Error("write after end");return typeof t=="string"?this[uo](t):this[ho](t),this.flowing}[ho](t){let u=Vs(Ve.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let p=new Fn(t.path,u);p.entry=new Dn(t,this[xo](p)),p.entry.on("end",(()=>this[co](p))),this[ao]+=1,this[Wn].push(p)}this[eo]()}[uo](t){let u=Vs(Ve.resolve(this.cwd,t));this[Wn].push(new Fn(t,u)),this[eo]()}[fo](t){t.pending=!0,this[ao]+=1;let u=this.follow?"stat":"lstat";ze[u](t.absolute,((u,p)=>{t.pending=!1,this[ao]-=1,u?this.emit("error",u):this[Hn](t,p)}))}[Hn](t,u){if(this.statCache.set(t.absolute,u),t.stat=u,!this.filter(t.path,u))t.ignore=!0;else if(u.isFile()&&u.nlink>1&&!this.linkCache.get(`${u.dev}:${u.ino}`)&&!this.sync)if(t===this[Qn])this[ro](t);else{let p=`${u.dev}:${u.ino}`,m=this[Jn].get(p);m?m.push(t):this[Jn].set(p,[t]),t.pendingLink=!0,t.pending=!0}this[eo]()}[vo](t){t.pending=!0,this[ao]+=1,ze.readdir(t.absolute,((u,p)=>{if(t.pending=!1,this[ao]-=1,u)return this.emit("error",u);this[So](t,p)}))}[So](t,u){this.readdirCache.set(t.absolute,u),t.readdir=u,this[eo]()}[eo](){if(!this[to]){this[to]=!0;for(let t=this[Wn].head;t&&this[ao]<this.jobs;t=t.next)if(this[ro](t.value),t.value.ignore){let u=t.next;this[Wn].removeNode(t),t.next=u}this[to]=!1,this[zn]&&this[Wn].length===0&&this[ao]===0&&(this.zip?this.zip.end(Un):(super.write(Un),super.end()))}}get[Qn](){return this[Wn]&&this[Wn].head&&this[Wn].head.value}[co](t){this[Wn].shift(),this[ao]-=1;let{stat:u}=t;if(u&&u.isFile()&&u.nlink>1){let t=`${u.dev}:${u.ino}`,p=this[Jn].get(t);if(p){this[Jn].delete(t);for(let t of p)t.pending=!1,this[ro](t)}}this[eo]()}[ro](t){if(t.pending&&t.pendingLink&&t===this[Qn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[Qn]&&!t.piped&&this[$o](t);return}if(!t.stat){let u=this.statCache.get(t.absolute);u?this[Hn](t,u):this[fo](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let u=this.readdirCache.get(t.absolute);if(u?this[So](t,u):this[vo](t),!t.readdir)return}if(t.entry=this[Po](t),!t.entry){t.ignore=!0;return}t===this[Qn]&&!t.piped&&this[$o](t)}}}[xo](t){return{onwarn:(t,u,p)=>this.warn(t,u,p),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Po](t){this[ao]+=1;try{return new this[Oo](t.path,this[xo](t)).on("end",(()=>this[co](t))).on("error",(t=>this.emit("error",t)))}catch(t){this.emit("error",t)}}[ko](){this[Qn]&&this[Qn].entry&&this[Qn].entry.resume()}[$o](t){t.piped=!0,t.readdir&&t.readdir.forEach((u=>{let p=t.path,m=p==="./"?"":p.replace(/\/*$/,"/");this[uo](m+u)}));let u=t.entry,p=this.zip;if(!u)throw new Error("cannot pipe without source");p?u.on("data",(t=>{p.write(t)||u.pause()})):u.on("data",(t=>{super.write(t)||u.pause()}))}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,u,p={}){Dt(this,t,u,p)}},Io=class extends Co{sync=!0;constructor(t){super(t),this[Oo]=Nn}pause(){}resume(){}[fo](t){let u=this.follow?"statSync":"lstatSync";this[Hn](t,ze[u](t.absolute))}[vo](t){this[So](t,ze.readdirSync(t.absolute))}[$o](t){let u=t.entry,p=this.zip;if(t.readdir&&t.readdir.forEach((u=>{let p=t.path,m=p==="./"?"":p.replace(/\/*$/,"/");this[uo](m+u)})),!u)throw new Error("Cannot pipe without source");p?u.on("data",(t=>{p.write(t)})):u.on("data",(t=>{super[Ao](t)}))}};var Vn=(t,u)=>{let p=new Io(t),m=new ss(t.file,{mode:t.mode||438});p.pipe(m),fr(p,u)},$n=(t,u)=>{let p=new Co(t),m=new rs(t.file,{mode:t.mode||438});p.pipe(m);let g=new Promise(((t,u)=>{m.on("error",u),m.on("close",t),p.on("error",u)}));return dr(p,u).catch((t=>p.emit("error",t))),g},fr=(t,u)=>{u.forEach((u=>{u.charAt(0)==="@"?Di({file:T.resolve(t.cwd,u.slice(1)),sync:!0,noResume:!0,onReadEntry:u=>t.add(u)}):t.add(u)})),t.end()},dr=async(t,u)=>{for(let p of u)p.charAt(0)==="@"?await Di({file:T.resolve(String(t.cwd),p.slice(1)),noResume:!0,onReadEntry:u=>{t.add(u)}}):t.add(p);t.end()},Xn=(t,u)=>{let p=new Io(t);return fr(p,u),p},qn=(t,u)=>{let p=new Co(t);return dr(p,u).catch((t=>p.emit("error",t))),p},No=K(Vn,$n,Xn,qn,((t,u)=>{if(!u?.length)throw new TypeError("no paths specified to add to archive")}));var Do=process.env.__FAKE_PLATFORM__||process.platform,jo=Do==="win32",{O_CREAT:Lo,O_NOFOLLOW:Mo,O_TRUNC:Fo,O_WRONLY:Uo}=ze.constants,Bo=Number(process.env.__FAKE_FS_O_FILENAME__)||ze.constants.UV_FS_O_FILEMAP||0,Ho=jo&&!!Bo,zo=512*1024,Vo=Bo|Fo|Lo|Uo,Go=!jo&&typeof Mo=="number"?Mo|Fo|Lo|Uo:null,qo=Go!==null?()=>Go:Ho?t=>t<zo?Vo:"w":()=>"w";var ps=(t,u,p)=>{try{return k.lchownSync(t,u,p)}catch(t){if(t?.code!=="ENOENT")throw t}},Ei=(t,u,p,m)=>{k.lchown(t,u,p,(t=>{m(t&&t?.code!=="ENOENT"?t:null)}))},io=(t,u,p,m,g)=>{if(u.isDirectory())Es(T.resolve(t,u.name),p,m,(v=>{if(v)return g(v);let b=T.resolve(t,u.name);Ei(b,p,m,g)}));else{let v=T.resolve(t,u.name);Ei(v,p,m,g)}},Es=(t,u,p,m)=>{k.readdir(t,{withFileTypes:!0},((g,v)=>{if(g){if(g.code==="ENOENT")return m();if(g.code!=="ENOTDIR"&&g.code!=="ENOTSUP")return m(g)}if(g||!v.length)return Ei(t,u,p,m);let b=v.length,w=null,a=g=>{if(!w){if(g)return m(w=g);if(--b===0)return Ei(t,u,p,m)}};for(let m of v)io(t,m,u,p,a)}))},so=(t,u,p,m)=>{u.isDirectory()&&ws(T.resolve(t,u.name),p,m),ps(T.resolve(t,u.name),p,m)},ws=(t,u,p)=>{let m;try{m=k.readdirSync(t,{withFileTypes:!0})}catch(m){let g=m;if(g?.code==="ENOENT")return;if(g?.code==="ENOTDIR"||g?.code==="ENOTSUP")return ps(t,u,p);throw g}for(let g of m)so(t,g,u,p);return ps(t,u,p)};var Wo=class extends Error{path;code;syscall="chdir";constructor(t,u){super(`${u}: Cannot cd into '${t}'`),this.path=t,this.code=u}get name(){return"CwdError"}};var Ko=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,u){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=u}get name(){return"SymlinkError"}};var no=(t,u)=>{k.stat(t,((p,m)=>{(p||!m.isDirectory())&&(p=new Wo(t,p?.code||"ENOTDIR")),u(p)}))},gr=(t,u,p)=>{t=Vs(t);let m=u.umask??18,g=u.mode|448,v=(g&m)!==0,b=u.uid,w=u.gid,E=typeof b=="number"&&typeof w=="number"&&(b!==u.processUid||w!==u.processGid),S=u.preserve,$=u.unlink,P=Vs(u.cwd),y=(u,m)=>{u?p(u):m&&E?Es(m,b,w,(t=>y(t))):v?k.chmod(t,g,p):p()};if(t===P)return no(t,y);if(S)return yt.mkdir(t,{mode:g,recursive:!0}).then((t=>y(null,t??void 0)),y);let x=Vs(T.relative(P,t)).split("/");Ss(P,x,g,$,P,void 0,y)},Ss=(t,u,p,m,g,v,b)=>{if(u.length===0)return b(null,v);let w=u.shift(),E=Vs(T.resolve(t+"/"+w));k.mkdir(E,p,br(E,u,p,m,g,v,b))},br=(t,u,p,m,g,v,b)=>w=>{w?k.lstat(t,((E,S)=>{if(E)E.path=E.path&&Vs(E.path),b(E);else if(S.isDirectory())Ss(t,u,p,m,g,v,b);else if(m)k.unlink(t,(w=>{if(w)return b(w);k.mkdir(t,p,br(t,u,p,m,g,v,b))}));else{if(S.isSymbolicLink())return b(new Ko(t,t+"/"+u.join("/")));b(w)}})):(v=v||t,Ss(t,u,p,m,g,v,b))},oo=t=>{let u=!1,p;try{u=k.statSync(t).isDirectory()}catch(t){p=t?.code}finally{if(!u)throw new Wo(t,p??"ENOTDIR")}},_r=(t,u)=>{t=Vs(t);let p=u.umask??18,m=u.mode|448,g=(m&p)!==0,v=u.uid,b=u.gid,w=typeof v=="number"&&typeof b=="number"&&(v!==u.processUid||b!==u.processGid),E=u.preserve,S=u.unlink,$=Vs(u.cwd),d=u=>{u&&w&&ws(u,v,b),g&&k.chmodSync(t,m)};if(t===$)return oo($),d();if(E)return d(k.mkdirSync(t,{mode:m,recursive:!0})??void 0);let P=Vs(T.relative($,t)).split("/"),x;for(let t=P.shift(),u=$;t&&(u+="/"+t);t=P.shift()){u=Vs(T.resolve(u));try{k.mkdirSync(u,m),x=x||u}catch{let t=k.lstatSync(u);if(t.isDirectory())continue;if(S){k.unlinkSync(u),k.mkdirSync(u,m),x=x||u;continue}else if(t.isSymbolicLink())return new Ko(u,u+"/"+P.join("/"))}}return d(x)};var Yo=Object.create(null),Zo=1e4,Jo=new Set,Tr=t=>{Jo.has(t)?Jo.delete(t):Yo[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),Jo.add(t);let u=Yo[t],p=Jo.size-Zo;if(p>Zo/10){for(let t of Jo)if(Jo.delete(t),delete Yo[t],--p<=0)break}return u};var Xo=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Qo=Xo==="win32",lo=t=>t.split("/").slice(0,-1).reduce(((t,u)=>{let p=t.at(-1);return p!==void 0&&(u=(0,T.join)(p,u)),t.push(u||"/"),t}),[]),ea=class{#i=new Map;#n=new Map;#o=new Set;reserve(t,u){t=Qo?["win32 parallelization disabled"]:t.map((t=>mt((0,T.join)(Tr(t)))));let p=new Set(t.map((t=>lo(t))).reduce(((t,u)=>t.concat(u))));this.#n.set(u,{dirs:p,paths:t});for(let p of t){let t=this.#i.get(p);t?t.push(u):this.#i.set(p,[u])}for(let t of p){let p=this.#i.get(t);if(!p)this.#i.set(t,[new Set([u])]);else{let t=p.at(-1);t instanceof Set?t.add(u):p.push(new Set([u]))}}return this.#c(u)}#a(t){let u=this.#n.get(t);if(!u)throw new Error("function does not have any path reservations");return{paths:u.paths.map((t=>this.#i.get(t))),dirs:[...u.dirs].map((t=>this.#i.get(t)))}}check(t){let{paths:u,dirs:p}=this.#a(t);return u.every((u=>u&&u[0]===t))&&p.every((u=>u&&u[0]instanceof Set&&u[0].has(t)))}#c(t){return this.#o.has(t)||!this.check(t)?!1:(this.#o.add(t),t((()=>this.#l(t))),!0)}#l(t){if(!this.#o.has(t))return!1;let u=this.#n.get(t);if(!u)throw new Error("invalid reservation");let{paths:p,dirs:m}=u,g=new Set;for(let u of p){let p=this.#i.get(u);if(!p||p?.[0]!==t)continue;let m=p[1];if(!m){this.#i.delete(u);continue}if(p.shift(),typeof m=="function")g.add(m);else for(let t of m)g.add(t)}for(let u of m){let p=this.#i.get(u),m=p?.[0];if(!(!p||!(m instanceof Set)))if(m.size===1&&p.length===1){this.#i.delete(u);continue}else if(m.size===1){p.shift();let t=p[0];typeof t=="function"&&g.add(t)}else m.delete(t)}return this.#o.delete(t),g.forEach((t=>this.#c(t))),!0}};var Lr=()=>process.umask();var ta=Symbol("onEntry"),ra=Symbol("checkFs"),sa=Symbol("checkFs2"),ia=Symbol("isReusable"),na=Symbol("makeFs"),oa=Symbol("file"),aa=Symbol("directory"),ca=Symbol("link"),la=Symbol("symlink"),ua=Symbol("hardlink"),ha=Symbol("ensureNoSymlink"),da=Symbol("unsupported"),fa=Symbol("checkPath"),pa=Symbol("stripAbsolutePath"),ma=Symbol("mkdir"),ga=Symbol("onError"),ya=Symbol("pending"),va=Symbol("pend"),_a=Symbol("unpend"),ba=Symbol("ended"),wa=Symbol("maybeClose"),Ea=Symbol("skip"),Sa=Symbol("doChown"),$a=Symbol("uid"),Pa=Symbol("gid"),xa=Symbol("checkedCwd"),Ra=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Oa=Ra==="win32",Aa=1024,mo=(t,u)=>{if(!Oa)return k.unlink(t,u);let p=t+".DELETE."+(0,I.randomBytes)(16).toString("hex");k.rename(t,p,(t=>{if(t)return u(t);k.unlink(p,u)}))},po=t=>{if(!Oa)return k.unlinkSync(t);let u=t+".DELETE."+(0,I.randomBytes)(16).toString("hex");k.renameSync(t,u),k.unlinkSync(u)},vr=(t,u,p)=>t!==void 0&&t===t>>>0?t:u!==void 0&&u===u>>>0?u:p,ka=class extends Ni{[ba]=!1;[xa]=!1;[ya]=0;reservations=new ea;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[ba]=!0,this[wa]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?process.getuid?.()===0:!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Aa,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Oa,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Vs(T.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Lr():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",(t=>this[ta](t)))}warn(t,u,p={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(p.recoverable=!1),super.warn(t,u,p)}[wa](){this[ba]&&this[ya]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[pa](t,u){let p=t[u],{type:m}=t;if(!p||this.preservePaths)return!0;let[g,v]=ce(p),b=v.replaceAll(/\\/g,"/").split("/");if(b.includes("..")||Oa&&/^[a-z]:\.\.$/i.test(b[0]??"")){if(u==="path"||m==="Link")return this.warn("TAR_ENTRY_ERROR",`${u} contains '..'`,{entry:t,[u]:p}),!1;let g=T.posix.dirname(t.path),v=T.posix.normalize(T.posix.join(g,b.join("/")));if(v.startsWith("../")||v==="..")return this.warn("TAR_ENTRY_ERROR",`${u} escapes extraction directory`,{entry:t,[u]:p}),!1}return g&&(t[u]=String(v),this.warn("TAR_ENTRY_INFO",`stripping ${g} from absolute ${u}`,{entry:t,[u]:p})),!0}[fa](t){let u=Vs(t.path),p=u.split("/");if(this.strip){if(p.length<this.strip)return!1;if(t.type==="Link"){let u=Vs(String(t.linkpath)).split("/");if(u.length>=this.strip)t.linkpath=u.slice(this.strip).join("/");else return!1}p.splice(0,this.strip),t.path=p.join("/")}if(isFinite(this.maxDepth)&&p.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:u,depth:p.length,maxDepth:this.maxDepth}),!1;if(!this[pa](t,"path")||!this[pa](t,"linkpath"))return!1;if(t.absolute=T.isAbsolute(t.path)?Vs(T.resolve(t.path)):Vs(T.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Vs(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:u}=T.win32.parse(String(t.absolute));t.absolute=u+ts(String(t.absolute).slice(u.length));let{root:p}=T.win32.parse(t.path);t.path=p+ts(t.path.slice(p.length))}return!0}[ta](t){if(!this[fa](t))return t.resume();switch(N.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[ra](t);default:return this[da](t)}}[ga](t,u){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:u}),this[_a](),u.resume())}[ma](t,u,p){gr(Vs(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:u},p)}[Sa](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[$a](t){return vr(this.uid,t.uid,this.processUid)}[Pa](t){return vr(this.gid,t.gid,this.processGid)}[oa](t,u){let p=typeof t.mode=="number"?t.mode&4095:this.fmode,m=new rs(String(t.absolute),{flags:qo(t.size),mode:p,autoClose:!1});m.on("error",(p=>{m.fd&&k.close(m.fd,(()=>{})),m.write=()=>!0,this[ga](p,t),u()}));let g=1,o=p=>{if(p){m.fd&&k.close(m.fd,(()=>{})),this[ga](p,t),u();return}--g===0&&m.fd!==void 0&&k.close(m.fd,(p=>{p?this[ga](p,t):this[_a](),u()}))};m.on("finish",(()=>{let u=String(t.absolute),p=m.fd;if(typeof p=="number"&&t.mtime&&!this.noMtime){g++;let m=t.atime||new Date,v=t.mtime;k.futimes(p,m,v,(t=>t?k.utimes(u,m,v,(u=>o(u&&t))):o()))}if(typeof p=="number"&&this[Sa](t)){g++;let m=this[$a](t),v=this[Pa](t);typeof m=="number"&&typeof v=="number"&&k.fchown(p,m,v,(t=>t?k.chown(u,m,v,(u=>o(u&&t))):o()))}o()}));let v=this.transform&&this.transform(t)||t;v!==t&&(v.on("error",(p=>{this[ga](p,t),u()})),t.pipe(v)),v.pipe(m)}[aa](t,u){let p=typeof t.mode=="number"?t.mode&4095:this.dmode;this[ma](String(t.absolute),p,(p=>{if(p){this[ga](p,t),u();return}let m=1,o=()=>{--m===0&&(u(),this[_a](),t.resume())};t.mtime&&!this.noMtime&&(m++,k.utimes(String(t.absolute),t.atime||new Date,t.mtime,o)),this[Sa](t)&&(m++,k.chown(String(t.absolute),Number(this[$a](t)),Number(this[Pa](t)),o)),o()}))}[da](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[la](t,u){let p=Vs(T.relative(this.cwd,T.resolve(T.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[ha](t,this.cwd,p,(()=>this[ca](t,String(t.linkpath),"symlink",u)),(p=>{this[ga](p,t),u()}))}[ua](t,u){let p=Vs(T.resolve(this.cwd,String(t.linkpath))),m=Vs(String(t.linkpath)).split("/");this[ha](t,this.cwd,m,(()=>this[ca](t,p,"link",u)),(p=>{this[ga](p,t),u()}))}[ha](t,u,p,m,g){let v=p.shift();if(this.preservePaths||v===void 0)return m();let b=T.resolve(u,v);k.lstat(b,((u,v)=>{if(u)return m();if(v?.isSymbolicLink())return g(new Ko(b,T.resolve(b,p.join("/"))));this[ha](t,b,p,m,g)}))}[va](){this[ya]++}[_a](){this[ya]--,this[wa]()}[Ea](t){this[_a](),t.resume()}[ia](t,u){return t.type==="File"&&!this.unlink&&u.isFile()&&u.nlink<=1&&!Oa}[ra](t){this[va]();let u=[t.path];t.linkpath&&u.push(t.linkpath),this.reservations.reserve(u,(u=>this[sa](t,u)))}[sa](t,u){let i=t=>{u(t)},r=()=>{this[ma](this.cwd,this.dmode,(u=>{if(u){this[ga](u,t),i();return}this[xa]=!0,n()}))},n=()=>{if(t.absolute!==this.cwd){let u=Vs(T.dirname(String(t.absolute)));if(u!==this.cwd)return this[ma](u,this.dmode,(u=>{if(u){this[ga](u,t),i();return}o()}))}o()},o=()=>{k.lstat(String(t.absolute),((u,p)=>{if(p&&(this.keep||this.newer&&p.mtime>(t.mtime??p.mtime))){this[Ea](t),i();return}if(u||this[ia](t,p))return this[na](null,t,i);if(p.isDirectory()){if(t.type==="Directory"){let u=this.chmod&&t.mode&&(p.mode&4095)!==t.mode,c=u=>this[na](u??null,t,i);return u?k.chmod(String(t.absolute),Number(t.mode),c):c()}if(t.absolute!==this.cwd)return k.rmdir(String(t.absolute),(u=>this[na](u??null,t,i)))}if(t.absolute===this.cwd)return this[na](null,t,i);mo(String(t.absolute),(u=>this[na](u??null,t,i)))}))};this[xa]?n():r()}[na](t,u,p){if(t){this[ga](t,u),p();return}switch(u.type){case"File":case"OldFile":case"ContiguousFile":return this[oa](u,p);case"Link":return this[ua](u,p);case"SymbolicLink":return this[la](u,p);case"Directory":case"GNUDumpDir":return this[aa](u,p)}}[ca](t,u,p,m){k[p](u,String(t.absolute),(u=>{u?this[ga](u,t):(this[_a](),t.resume()),m()}))}},ye=t=>{try{return[null,t()]}catch(t){return[t,null]}},Ta=class extends ka{sync=!0;[na](t,u){return super[na](t,u,(()=>{}))}[ra](t){if(!this[xa]){let u=this[ma](this.cwd,this.dmode);if(u)return this[ga](u,t);this[xa]=!0}if(t.absolute!==this.cwd){let u=Vs(T.dirname(String(t.absolute)));if(u!==this.cwd){let p=this[ma](u,this.dmode);if(p)return this[ga](p,t)}}let[u,p]=ye((()=>k.lstatSync(String(t.absolute))));if(p&&(this.keep||this.newer&&p.mtime>(t.mtime??p.mtime)))return this[Ea](t);if(u||this[ia](t,p))return this[na](null,t);if(p.isDirectory()){if(t.type==="Directory"){let u=this.chmod&&t.mode&&(p.mode&4095)!==t.mode,[m]=u?ye((()=>{k.chmodSync(String(t.absolute),Number(t.mode))})):[];return this[na](m,t)}let[u]=ye((()=>k.rmdirSync(String(t.absolute))));this[na](u,t)}let[m]=t.absolute===this.cwd?[]:ye((()=>po(String(t.absolute))));this[na](m,t)}[oa](t,u){let p=typeof t.mode=="number"?t.mode&4095:this.fmode,r=p=>{let g;try{k.closeSync(m)}catch(t){g=t}(p||g)&&this[ga](p||g,t),u()},m;try{m=k.openSync(String(t.absolute),qo(t.size),p)}catch(t){return r(t)}let g=this.transform&&this.transform(t)||t;g!==t&&(g.on("error",(u=>this[ga](u,t))),t.pipe(g)),g.on("data",(t=>{try{k.writeSync(m,t,0,t.length)}catch(t){r(t)}})),g.on("end",(()=>{let u=null;if(t.mtime&&!this.noMtime){let p=t.atime||new Date,g=t.mtime;try{k.futimesSync(m,p,g)}catch(m){try{k.utimesSync(String(t.absolute),p,g)}catch{u=m}}}if(this[Sa](t)){let p=this[$a](t),g=this[Pa](t);try{k.fchownSync(m,Number(p),Number(g))}catch(m){try{k.chownSync(String(t.absolute),Number(p),Number(g))}catch{u=u||m}}}r(u)}))}[aa](t,u){let p=typeof t.mode=="number"?t.mode&4095:this.dmode,m=this[ma](String(t.absolute),p);if(m){this[ga](m,t),u();return}if(t.mtime&&!this.noMtime)try{k.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Sa](t))try{k.chownSync(String(t.absolute),Number(this[$a](t)),Number(this[Pa](t)))}catch{}u(),t.resume()}[ma](t,u){try{return _r(Vs(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:u})}catch(t){return t}}[ha](t,u,p,m,g){if(this.preservePaths||p.length===0)return m();let v=u;for(let t of p){v=T.resolve(v,t);let[b,w]=ye((()=>k.lstatSync(v)));if(b)return m();if(w.isSymbolicLink())return g(new Ko(v,T.resolve(u,p.join("/"))))}m()}[ca](t,u,p,m){let g=`${p}Sync`;try{k[g](u,String(t.absolute)),m(),t.resume()}catch(u){return this[ga](u,t)}}};var Eo=t=>{let u=new Ta(t),p=t.file,m=k.statSync(p),g=t.maxReadSize||16*1024*1024;new es(p,{readSize:g,size:m.size}).pipe(u)},wo=(t,u)=>{let p=new ka(t),m=t.maxReadSize||16*1024*1024,g=t.file;return new Promise(((t,u)=>{p.on("error",u),p.on("close",t),k.stat(g,((t,v)=>{if(t)u(t);else{let t=new Qr(g,{readSize:m,size:v.size});t.on("error",u),t.pipe(p)}}))}))},Ca=K(Eo,wo,(t=>new Ta(t)),(t=>new ka(t)),((t,u)=>{u?.length&&Qi(t,u)}));var yo=(t,u)=>{let p=new Io(t),m=!0,g,v;try{try{g=k.openSync(t.file,"r+")}catch(u){if(u?.code==="ENOENT")g=k.openSync(t.file,"w+");else throw u}let b=k.fstatSync(g),w=Buffer.alloc(512);e:for(v=0;v<b.size;v+=512){for(let t=0,u=0;t<512;t+=u){if(u=k.readSync(g,w,t,w.length-t,v+t),v===0&&w[0]===31&&w[1]===139)throw new Error("cannot append to compressed archives");if(!u)break e}let u=new Ns(w);if(!u.cksumValid)break;let p=512*Math.ceil((u.size||0)/512);if(v+p+512>b.size)break;v+=p,t.mtimeCache&&u.mtime&&t.mtimeCache.set(String(u.path),u.mtime)}m=!1,Ro(t,p,v,g,u)}finally{if(m)try{k.closeSync(g)}catch{}}},Ro=(t,u,p,m,g)=>{let v=new ss(t.file,{fd:m,start:p});u.pipe(v),bo(u,g)},go=(t,u)=>{u=Array.from(u);let p=new Co(t),i=(u,p,m)=>{let a=(t,p)=>{t?k.close(u,(u=>m(t))):m(null,p)},g=0;if(p===0)return a(null,0);let v=0,b=Buffer.alloc(512),y=(m,w)=>{if(m||w===void 0)return a(m);if(v+=w,v<512&&w)return k.read(u,b,v,b.length-v,g+v,y);if(g===0&&b[0]===31&&b[1]===139)return a(new Error("cannot append to compressed archives"));if(v<512)return a(null,g);let E=new Ns(b);if(!E.cksumValid)return a(null,g);let S=512*Math.ceil((E.size??0)/512);if(g+S+512>p||(g+=S+512,g>=p))return a(null,g);t.mtimeCache&&E.mtime&&t.mtimeCache.set(String(E.path),E.mtime),v=0,k.read(u,b,0,512,g,y)};k.read(u,b,0,512,g,y)};return new Promise(((m,g)=>{p.on("error",g);let v="r+",a=(b,w)=>{if(b&&b.code==="ENOENT"&&v==="r+")return v="w+",k.open(t.file,v,a);if(b||!w)return g(b);k.fstat(w,((v,b)=>{if(v)return k.close(w,(()=>g(v)));i(w,b.size,((v,b)=>{if(v)return g(v);let E=new rs(t.file,{fd:w,start:b});p.pipe(E),E.on("error",g),E.on("close",m),_o(p,u)}))}))};k.open(t.file,v,a)}))},bo=(t,u)=>{u.forEach((u=>{u.charAt(0)==="@"?Di({file:T.resolve(t.cwd,u.slice(1)),sync:!0,noResume:!0,onReadEntry:u=>t.add(u)}):t.add(u)})),t.end()},_o=async(t,u)=>{for(let p of u)p.charAt(0)==="@"?await Di({file:T.resolve(String(t.cwd),p.slice(1)),noResume:!0,onReadEntry:u=>t.add(u)}):t.add(p);t.end()},Ia=K(yo,go,(()=>{throw new TypeError("file is required")}),(()=>{throw new TypeError("file is required")}),((t,u)=>{if(!Bs(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!u?.length)throw new TypeError("no paths specified to add/replace")}));var Na=K(Ia.syncFile,Ia.asyncFile,Ia.syncNoFile,Ia.asyncNoFile,((t,u=[])=>{Ia.validate?.(t,u),To(t)})),To=t=>{let u=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=u?(p,m)=>u(p,m)&&!((t.mtimeCache?.get(p)??m.mtime??0)>(m.mtime??0)):(u,p)=>!((t.mtimeCache?.get(u)??p.mtime??0)>(p.mtime??0))};const Da="none";const ja=[{title:"Claude Code",value:"claude",description:"CLAUDE.md, .claude/, .mcp.json"},{title:"GitHub Copilot",value:"copilot",description:".github/copilot-instructions.md, .mcp.json"},{title:"Cursor",value:"cursor",description:".cursorrules, .mcp.json"},{title:"Windsurf",value:"windsurf",description:".windsurfrules, .mcp.json"},{title:"OpenAI Codex",value:"codex",description:"AGENTS.md, .mcp.json"},{title:"None",value:Da,description:"Skip AI agent setup"}];function resolveAgentSelection(t){if(t.includes(Da)){return[]}return t}const La="https://codeload.github.com/zuplo/tools/tar.gz/main";const Ma={claude:".claude/skills",copilot:".agents/skills",cursor:".cursor/skills",windsurf:".windsurf/skills",codex:".agents/skills"};const Fa={claude:"CLAUDE.md",copilot:".github/copilot-instructions.md",cursor:".cursorrules",windsurf:".windsurfrules",codex:"AGENTS.md"};function getSharedInstructions(){return`## Project Overview\n\nThis is a Zuplo API gateway project with an accompanying Zudoku-based developer portal.\n\n## Commands\n\n- **Dev server:** \`npm run dev\` (runs on http://localhost:9000)\n- **Run tests:** \`npm run test\`\n- **Typecheck:** \`npm run typecheck\`\n- **Dev portal:** \`npm run docs\`\n\n## Architecture\n\n- **\`config/routes.oas.json\`** — OpenAPI 3.1 route definitions. Each operation uses \`x-zuplo-route\` to configure handlers (e.g., \`urlForwardHandler\`) and policies. This is the primary file for defining API routes.\n- **\`config/policies.json\`** — Policy configurations applied to routes (e.g., \`MockApiInboundPolicy\`).\n- **\`modules/\`** — Custom TypeScript request handlers. Handlers receive \`(ZuploRequest, ZuploContext)\` and return a \`Response\` or serializable value.\n- **\`docs/\`** — Zudoku developer portal (separate workspace). Config is in \`docs/zudoku.config.tsx\`. Reads the OpenAPI spec from \`../config/routes.oas.json\`.\n- **\`zuplo.jsonc\`** — Zuplo project configuration (version, compatibility date).\n\n## Key Patterns\n\n- Routes are configured declaratively in \`config/routes.oas.json\`, not in code. Custom logic goes in \`modules/\` and is referenced via \`x-zuplo-route.handler\`.\n- The project uses ESM (\`"type": "module"\`) with TypeScript targeting ES2022.\n- Environment variables are defined in \`.env\` (gitignored). See \`.env.example\` for available vars.`}function getLocalDocsSection(){return`## Local Documentation (node_modules)\n\nFull markdown documentation is bundled in node_modules and can be read directly:\n\n- **Zuplo docs:** \`node_modules/zuplo/docs/\` — includes docs on policies (\`policies/\`), handlers (\`handlers/\`), CLI (\`cli/\`), dev portal (\`dev-portal/\`), guides, and articles.\n- **Zuplo policy configs:** \`node_modules/zuplo/docs/policies/\` — each policy has its own folder with full configuration docs. Reference these when adding or configuring policies in \`config/policies.json\`.\n- **Zudoku docs:** \`docs/node_modules/zudoku/docs/\` — configuration, components, customization, plugins, and deployment docs for the developer portal.`}function getGenericInstructions(){return`${getSharedInstructions()}\n\n${getLocalDocsSection()}\n`}function getClaudeMd(){return`# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n${getSharedInstructions()}\n\n## Available Tools and Documentation\n\n### MCP Tools\n\n- **Zuplo Docs MCP** (configured in \`.mcp.json\`) — search Zuplo documentation via \`mcp__zuplo_docs__ask-question-about-zuplo\` and \`mcp__zuplo_docs__search-zuplo-docs\`.\n- **Zuplo Skills** — installed skills for working with Zuplo projects: \`zuplo-guide\`, \`zuplo-project-setup\`, \`zuplo-policies\`, \`zuplo-handlers\`, \`zuplo-monetization\`, \`zuplo-cli\`, and \`zudoku-guide\`.\n\n${getLocalDocsSection()}\n`}function getClaudeSettings(){return JSON.stringify({enabledPlugins:{"zudoku-skills@zuplo-tools":true,"zuplo-skills@zuplo-tools":true},extraKnownMarketplaces:{"zuplo-tools":{source:{source:"github",repo:"zuplo/tools"}}},enableAllProjectMcpServers:true},null,2)}function getMcpJson(){return JSON.stringify({mcpServers:{zuplo_docs:{type:"http",url:"https://dev.zuplo.com/mcp/docs"}}},null,2)}async function agents_writeFile(t,u){await et().mkdir(Ge().dirname(t),{recursive:true});await et().writeFile(t,u+rt().EOL,"utf-8")}async function downloadSkillsToTmp(){const t=await et().mkdtemp(Ge().join(rt().tmpdir(),"zuplo-skills-"));const u=await fetch(La);if(!u.body){throw new Error("Failed to download zuplo/tools tarball")}const p=u.body;const m=st.Readable.fromWeb(p);let g=0;const v=new st.Transform({transform(t,u,p){g+=t.length;if(g>10*1024*1024){return p(new Error("Download too large"))}p(null,t)}});await(0,it.pipeline)(m.pipe(v),Ca({cwd:t,strip:1,filter:t=>/\/skills\/[^/]+\/SKILL\.md$/.test(t)}));return t}async function installSkills(t,u){const p=await downloadSkillsToTmp();try{const m=Ge().join(p,"skills");let g;try{g=await et().readdir(m)}catch{throw new Error("No skills found in zuplo/tools tarball")}for(const p of u){const u=Ma[p];for(const p of g){const g=Ge().join(m,p,"SKILL.md");try{const m=await et().readFile(g,"utf-8");await agents_writeFile(Ge().join(t,u,p,"SKILL.md"),m)}catch{}}}}finally{await et().rm(p,{recursive:true,force:true})}}async function installAgentConfigs(t,u){if(u.length>0){await agents_writeFile(Ge().join(t,".mcp.json"),getMcpJson())}for(const p of u){if(p==="claude"){await agents_writeFile(Ge().join(t,".claude","settings.json"),getClaudeSettings());await agents_writeFile(Ge().join(t,"CLAUDE.md"),getClaudeMd())}else{await agents_writeFile(Ge().join(t,Fa[p]),getGenericInstructions())}}const p=u.filter((t=>t!=="claude"));if(p.length>0){try{console.log("Installing Zuplo agent skills...");await installSkills(t,p)}catch{console.log("Failed to download agent skills. You can install them later with:");console.log(" npx skills add zuplo/tools")}}}async function isUrlOk(t){try{const u=await fetch(t,{method:"HEAD"});return u.status===200}catch{return false}}async function getRepoInfo(t,u){const[,p,m,g,v,...b]=t.pathname.split("/");const w=u?u.replace(/^\//,""):b.join("/");if(g===undefined||g===""&&v===undefined){try{const t=await fetch(`https://api.github.com/repos/${p}/${m}`);if(t.status!==200){return}const u=await t.json();return{username:p,name:m,branch:u["default_branch"],filePath:w}}catch{return}}const E=u?`${v}/${b.join("/")}`.replace(new RegExp(`/${w}|/$`),""):v;if(p&&m&&E&&g==="tree"){return{username:p,name:m,branch:E,filePath:w}}}function hasRepo({username:t,name:u,branch:p,filePath:m}){const g=`https://api.github.com/repos/${t}/${u}/contents`;const v=`${m?`/${m}`:""}/package.json`;return isUrlOk(`${g+v}?ref=${p}`)}function existsInRepo(t){try{const u=new URL(t);return isUrlOk(u.href)}catch{return isUrlOk(`https://api.github.com/repos/zuplo/zuplo/contents/examples/${encodeURIComponent(t)}`)}}async function downloadTarStream(t,u=50*1024*1024){const p=await fetch(t);if(!p.body){throw new Error(`Failed to download: ${t}`)}const m=p.headers.get("content-length");if(m&&parseInt(m,10)>u){throw new Error(`File too large! ${m} bytes exceeds limit of ${u} bytes`)}const g=p.body;const v=st.Readable.fromWeb(g);let b=0;const w=new st.Transform({transform(t,p,m){b+=t.length;if(b>u){return m(new Error(`Download aborted! File size exceeded ${u} bytes`))}m(null,t)}});return v.pipe(w)}async function downloadAndExtractRepo(t,{username:u,name:p,branch:m,filePath:g},v){const b=`https://codeload.github.com/${u}/${p}/tar.gz/${m}`;if(v){console.log(`Downloading repo from ${b}`)}let w=null;await(0,it.pipeline)(await downloadTarStream(b),Ca({cwd:t,strip:g?g.split("/").length+1:1,filter:t=>{if(w===null){const u=t.split(Ve.sep);w=u.length?u[0]:null}return t.startsWith(`${w}${g?`/${g}/`:"/"}`)}}))}async function downloadAndExtractExample(t,u,p){if(u==="__internal-testing-retry"){throw new Error("This is an internal example for testing the CLI.")}const m="https://codeload.github.com/zuplo/zuplo/tar.gz/main";if(p){console.log(`Downloading example from ${m}`)}await(0,it.pipeline)(await downloadTarStream(m),Ca({cwd:t,strip:2+u.split("/").length,filter:t=>t.includes(`zuplo-main/examples/${u}/`)}))}var Ua=__nccwpck_require__(5317);function isInGitRepository(){try{(0,Ua.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch{}return false}function isInMercurialRepository(){try{(0,Ua.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch{}return false}function isDefaultBranchSet(){try{(0,Ua.execSync)("git config init.defaultBranch",{stdio:"ignore"});return true}catch{}return false}function tryGitInit(t,u){let p=false;const m=u?"inherit":"ignore";try{(0,Ua.execSync)("git --version",{stdio:m});if(isInGitRepository()||isInMercurialRepository()){return false}(0,Ua.execSync)("git init",{stdio:m});p=true;if(!isDefaultBranchSet()){(0,Ua.execSync)("git checkout -b main",{stdio:m})}(0,Ua.execSync)("git add -A",{stdio:m});(0,Ua.execSync)('git commit -m "Initial commit from create-zuplo-api"',{stdio:m});return true}catch(m){if(u){console.error("Git init failed:",m)}if(p){try{(0,ze.rmSync)((0,Ve.join)(t,".git"),{recursive:true,force:true})}catch{}}return false}}var Ba=__nccwpck_require__(4791);var Ha=__nccwpck_require__.n(Ba);async function install(t,u,p){const m=["install"];if(!u){console.log((0,qe.yellow)("You appear to be offline.\nFalling back to the local cache."));m.push("--offline")}else if(t==="npm"){m.push("--no-audit");m.push("--no-fund")}if(p){m.push("--verbose")}return new Promise(((u,p)=>{const g=Ha()(t,m,{stdio:"inherit",env:{...process.env,ADBLOCK:"1",NODE_ENV:"development",DISABLE_OPENCOLLECTIVE:"1"}});g.on("close",(g=>{if(g!==0){p({command:`${t} ${m.join(" ")}`});return}u()}))}))}function isFolderEmpty(t,u){const p=[".DS_Store",".git",".gitattributes",".gitignore",".gitlab-ci.yml",".hg",".hgcheck",".hgignore",".idea",".npmignore",".travis.yml","LICENSE","Thumbs.db","docs","mkdocs.yml","npm-debug.log","yarn-debug.log","yarn-error.log","yarnrc.yml",".yarn"];const m=(0,ze.readdirSync)(t).filter((t=>!p.includes(t)&&!/\.iml$/.test(t)));if(m.length>0){console.log(`The directory ${(0,qe.green)(u)} contains files that could conflict:`);console.log();for(const u of m){try{const p=(0,ze.lstatSync)((0,Ve.join)(t,u));if(p.isDirectory()){console.log(` ${(0,qe.blue)(u)}/`)}else{console.log(` ${u}`)}}catch{console.log(` ${u}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}const za=require("dns/promises");var Va=__nccwpck_require__(7016);var Ga=__nccwpck_require__.n(Va);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const t=(0,Ua.execSync)("npm config get https-proxy").toString().trim();return t!=="null"?t:undefined}catch{return}}async function getOnline(){try{await(0,za.lookup)("registry.yarnpkg.com");return true}catch{const t=getProxy();if(!t){return false}const{hostname:u}=Ga().parse(t);if(!u){return false}try{await(0,za.lookup)(u);return true}catch{return false}}}const qa=require("constants");async function isWriteable(t){try{await(0,Qe.access)(t,qa.W_OK);return true}catch{return false}}function unquote(t){if(t.length<2){return t}const u=t[0];const p=t[t.length-1];if(u==='"'&&p==='"'||u==="'"&&p==="'"){return t.slice(1,-1)}return t}function extractEnvValue(t,u){const p=new RegExp(`^${u}=(.*)$`,"m").exec(t);if(!p){return undefined}const m=unquote(p[1].trim());return m.length>0?m:undefined}function readLinkedConfig(t){try{const u=(0,ze.readFileSync)((0,Ve.join)(t,".env.zuplo"),"utf-8");const p=extractEnvValue(u,"ZUPLO_ACCOUNT_NAME");const m=extractEnvValue(u,"ZUPLO_PROJECT_NAME");if(!p||!m){return undefined}return{account:p,project:m}}catch{return undefined}}function getZuploAuthFilePath(){var t;const u=(t=process.env.XDG_DATA_HOME)!==null&&t!==void 0?t:(0,Ve.join)((0,tt.homedir)(),".local","state");return(0,Ve.join)(u,"zuplo","auth.json")}function getZuploDeveloperApiEndpoint(){var t;return(t=process.env.ZUPLO_DEVELOPER_API_ENDPOINT)!==null&&t!==void 0?t:"https://dev.zuplo.com"}function readZuploAccessToken(){try{const t=getZuploAuthFilePath();if(!(0,ze.existsSync)(t)){return undefined}const u=(0,ze.readFileSync)(t,"utf-8");const p=JSON.parse(u);return typeof p.access_token==="string"?p.access_token:undefined}catch{return undefined}}async function fetchZuploAccountNames(t){try{const u=await fetch(`${getZuploDeveloperApiEndpoint()}/v1/accounts`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});if(!u.ok){return undefined}const p=await u.json();if(!Array.isArray(p.data)){return undefined}return p.data.map((t=>typeof(t===null||t===void 0?void 0:t.name)==="string"?t.name:undefined)).filter((t=>typeof t==="string")).sort(((t,u)=>t.localeCompare(u)))}catch{return undefined}}async function probeProjectDeployments(t,u,p){try{const m=`${getZuploDeveloperApiEndpoint()}/v1/accounts/${encodeURIComponent(u)}/projects/${encodeURIComponent(p)}/deployments`;const g=await fetch(m,{method:"GET",headers:{Authorization:`Bearer ${t}`}});if(!g.ok){return{exists:false,soleWorkingCopy:undefined}}const v=await g.json();if(!Array.isArray(v.data)){return{exists:true,soleWorkingCopy:undefined}}const b=v.data.filter((t=>(t===null||t===void 0?void 0:t.environmentType)==="WORKING_COPY")).map((t=>typeof(t===null||t===void 0?void 0:t.name)==="string"?t.name:undefined)).filter((t=>typeof t==="string"));return{exists:true,soleWorkingCopy:b.length===1?b[0]:undefined}}catch{return{exists:false,soleWorkingCopy:undefined}}}async function fetchSoleWorkingCopyName(t,u,p){const m=await probeProjectDeployments(t,u,p);return m.soleWorkingCopy}async function findAccountWithProject(t,u,p){for(const m of u){const u=await probeProjectDeployments(t,m,p);if(u.exists){return{account:m,soleWorkingCopy:u.soleWorkingCopy}}}return undefined}const defaultRunZuplo=t=>new Promise(((u,p)=>{const m=process.platform==="win32"?"npx.cmd":"npx";const g=(0,Ua.spawn)(m,["zuplo",...t],{stdio:"inherit"});g.on("close",((m,g)=>{if(m===0){u();return}let v;if(m!==null&&m!==undefined){v=`exited with code ${m}`}else if(g){v=`was terminated by signal ${g}`}else{v="exited unsuccessfully"}p(new Error(`"zuplo ${t.join(" ")}" ${v}.`))}));g.on("error",p)}));const defaultPromptForAccount=async t=>{const u=await Ke()({type:"select",name:"account",message:"Which Zuplo account should host this project?",choices:t.map((t=>({title:t,value:t}))),onState:t=>{if(t.aborted){process.stdout.write("[?25h");process.stdout.write("\n");process.exit(1)}}});return typeof u.account==="string"?u.account:undefined};const Wa={readToken:readZuploAccessToken,fetchAccounts:fetchZuploAccountNames,fetchWorkingCopy:fetchSoleWorkingCopyName,findAccountWithProject:findAccountWithProject,readLinked:readLinkedConfig,runZuplo:defaultRunZuplo,promptForAccount:defaultPromptForAccount};async function createAndLinkServerProject(t,u=Wa){const{appPath:p,appName:m,account:g,skipPrompts:v}=t;let b=(g===null||g===void 0?void 0:g.trim())||undefined;if(!b){const t=u.readToken();const p=t?await u.fetchAccounts(t):undefined;if(p&&p.length===1){b=p[0];console.log();console.log(`Using Zuplo account ${(0,qe.cyan)(`'${b}'`)}.`)}else if(v){console.log();console.log(`${(0,qe.yellow)("Note:")} Skipping server-project setup in non-interactive mode.`);console.log(`Pass ${(0,qe.cyan)("--account <name>")} to create a server project, or ${(0,qe.cyan)("--no-server-project")} to silence this note.`);return undefined}else if(p&&p.length>1){b=await u.promptForAccount(p)}}console.log();console.log("Creating your project on portal.zuplo.com...");console.log();const w=["project","create","--name",m];if(b){w.push("--account",b)}try{await u.runZuplo(w)}catch{console.log();console.log(`${(0,qe.yellow)("Note:")} Failed to create the server project. Your local files are ready.`);console.log(`You can finish setup later by running ${(0,qe.cyan)(`zuplo project create --name ${m}`)} and ${(0,qe.cyan)(`zuplo link`)} from inside your project directory.`);return undefined}console.log();console.log("Linking your working copy to the server project...");console.log();const E=["link","--dir",p,"--project",m];let S;if(!b){const t=u.readToken();if(t){const p=await u.fetchAccounts(t);if(p&&p.length===1){b=p[0]}else if(p&&p.length>1){const g=await u.findAccountWithProject(t,p,m);if(g){b=g.account;S=g.soleWorkingCopy}}}}if(b){E.push("--account",b)}if(b){if(S){E.push("--environment",S)}else{const t=u.readToken();if(t){const p=await u.fetchWorkingCopy(t,b,m);if(p){E.push("--environment",p)}}}}try{await u.runZuplo(E)}catch{console.log();console.log(`${(0,qe.yellow)("Note:")} The server project was created but linking failed.`);console.log(`You can finish setup later by running ${(0,qe.cyan)(`zuplo link`)} from inside your project directory.`);return undefined}return u.readLinked(p)}const Ka=JSON.parse('{"aC":"70b476fc2524c3c2ce0cc10ad5f91837a7aefceefb088542390c02754238693d"}');const Ya={rE:"7.11.1"};function gatewayProvenance(t=Ya.rE){return`${JSON.stringify({formatVersion:1,template:"ai-gateway",origin:{revision:Ka.aC,release:t},appliedSteps:[]},null,2)}\n`}var Za=__nccwpck_require__(4761);const identity=t=>t;const copy=async(t,u,{cwd:p,rename:m=identity,parents:g=true,verbose:v=false}={})=>{const b=typeof t==="string"?[t]:t;if(b.length===0||!u){throw new TypeError("`src` and `dest` are required")}const w=await(0,Za.async)(b,{cwd:p,dot:true,absolute:false,stats:false});const E=p?(0,Ve.resolve)(p,u):u;return Promise.all(w.map((async t=>{const u=(0,Ve.dirname)(t);const b=m((0,Ve.basename)(t),t);const w=p?(0,Ve.resolve)(p,t):t;const S=g?(0,Ve.join)(E,u,b):(0,Ve.join)(E,b);await(0,Qe.mkdir)((0,Ve.dirname)(S),{recursive:true});if(v){console.log(`Copying ${w} to ${S}`)}return(0,Qe.copyFile)(w,S)})))};const Ja=["eslint","biome","oxlint","none"];const Xa=["prettier","biome","oxfmt","none"];function isLinter(t){return Ja.includes(t)}function isFormatter(t){return Xa.includes(t)}const Qa=[{title:"ESLint",value:"eslint",description:"The most widely used JavaScript/TypeScript linter"},{title:"Biome",value:"biome",description:"Fast Rust-based linter (can also format)"},{title:"Oxlint",value:"oxlint",description:"Fast Rust-based linter from the Oxc project"},{title:"None",value:"none",description:"Skip linter setup"}];const ec=[{title:"Prettier",value:"prettier",description:"The most widely used code formatter"},{title:"Biome",value:"biome",description:"Fast Rust-based formatter (can also lint)"},{title:"Oxfmt",value:"oxfmt",description:"Fast Rust-based, Prettier-compatible formatter (beta)"},{title:"None",value:"none",description:"Skip formatter setup"}];function resolveLinterFromLegacyFlags({eslint:t,noEslint:u}){if(t)return"eslint";if(u)return"none";return undefined}function resolveFormatterFromLegacyFlags({prettier:t,noPrettier:u}){if(t)return"prettier";if(u)return"none";return undefined}function migrateLegacyLintPreferences(t){if(t.linter===undefined&&typeof t.eslint==="boolean"){t.linter=t.eslint?"eslint":"none"}if(t.formatter===undefined&&typeof t.prettier==="boolean"){t.formatter=t.prettier?"prettier":"none"}delete t.eslint;delete t.prettier}function eslintConfig(t){const u=[`import js from "@eslint/js";`,`import { defineConfig } from "eslint/config";`,...t?[`import prettier from "eslint-config-prettier/flat";`]:[],`import tseslint from "typescript-eslint";`,``,`export default defineConfig(`,` js.configs.recommended,`,` tseslint.configs.recommended,`,...t?[` prettier,`]:[],`);`,``];return u.join(rt().EOL)}function biomeConfig({lint:t,format:u}){return JSON.stringify({$schema:"https://biomejs.dev/schemas/2.5.3/schema.json",vcs:{enabled:true,clientKind:"git",useIgnoreFile:true},files:{ignoreUnknown:true},linter:{enabled:t,rules:{preset:"recommended"}},formatter:u?{enabled:true,indentStyle:"space"}:{enabled:false},assist:{enabled:true,actions:{source:{organizeImports:"on"}}}},null,2)+rt().EOL}function oxlintConfig(){return JSON.stringify({$schema:"./node_modules/oxlint/configuration_schema.json",categories:{correctness:"error"}},null,2)+rt().EOL}function prettierConfig(){return JSON.stringify({overrides:[{files:"*.jsonc",options:{trailingComma:"none"}}]},null,2)+rt().EOL}function oxfmtConfig(){return[`{`,` "$schema": "./node_modules/oxfmt/configuration_schema.json",`,` "printWidth": 80,`,` "overrides": [`,` {`,` "files": ["*.jsonc"],`,` "options": {`,` "trailingComma": "none"`,` }`,` }`,` ]`,`}`,``].join(rt().EOL)}function buildLintFormatSetup(t,u){const p={};const m={};const g={};const v=[];switch(t){case"eslint":{p.lint="eslint";p["lint:fix"]="eslint --fix";m["@eslint/js"]="^10";m.eslint="^10";m["typescript-eslint"]="^8";g["eslint.config.js"]=eslintConfig(u==="prettier");if(u==="prettier"){m["eslint-config-prettier"]="^10"}v.push("dbaeumer.vscode-eslint");break}case"oxlint":{p.lint="oxlint";p["lint:fix"]="oxlint --fix";m.oxlint="^1";g[".oxlintrc.json"]=oxlintConfig();v.push("oxc.oxc-vscode");break}case"biome":{p.lint="biome lint .";p["lint:fix"]="biome lint --write .";break}case"none":break}switch(u){case"prettier":{p.format="prettier --write .";p["format:check"]="prettier --check .";m.prettier="^3";g[".prettierrc.json"]=prettierConfig();v.push("esbenp.prettier-vscode");break}case"oxfmt":{p.format="oxfmt";p["format:check"]="oxfmt --check";m.oxfmt="^0.58.0";g[".oxfmtrc.json"]=oxfmtConfig();if(!v.includes("oxc.oxc-vscode")){v.push("oxc.oxc-vscode")}break}case"biome":{p.format="biome format --write .";p["format:check"]="biome format .";break}case"none":break}if(t==="biome"||u==="biome"){m["@biomejs/biome"]="^2";g["biome.json"]=biomeConfig({lint:t==="biome",format:u==="biome"});v.push("biomejs.biome")}return{scripts:p,docsScripts:p.lint?{lint:p.lint}:{},devDependencies:m,files:g,vscodeExtensions:v}}function buildProjectDependencies(t,u){const p={zuplo:`^${u}`};if(t==="default"||t==="default-empty"){p["@zuplo/otel"]=`^${u}`}return p}const tc="shared";const getTemplateFile=({template:t,file:u})=>{const p=__nccwpck_require__.ab+"templates/"+t+"/"+u;if((0,ze.existsSync)(p)){return p}return __nccwpck_require__.ab+"shared/"+u};const installTemplate=async({appName:t,root:u,packageManager:p,isOnline:m,template:g,linter:v,formatter:b,installPackages:w,verbose:E,zuploVersion:S,agents:$})=>{var P;console.log((0,qe.bold)(`Using ${p}.`));console.log("\nInitializing project with template:",g,"\n");const x=__nccwpck_require__.ab+"shared";const R=__nccwpck_require__.ab+"templates/"+g;const O=(0,ze.existsSync)(Ge().join(R,"docs"));const A=["**","!vscode/**"];for(const t of[__nccwpck_require__.ab+"shared",R]){await copy(A,u,{parents:true,cwd:t,verbose:E,rename(t){switch(t){case"gitignore":case"env.example":{return`.${t}`}case"README-template.md":{return"README.md"}default:{return t}}}})}if(g==="ai-gateway"){await et().writeFile(Ge().join(u,".zuplo-template.json"),gatewayProvenance(),"utf-8")}const k=buildLintFormatSetup(v,b);for(const[t,p]of Object.entries(k.files)){await et().writeFile(Ge().join(u,t),p,"utf-8")}const T=["settings.json","launch.json"];for(const t of T){const p=[R,__nccwpck_require__.ab+"shared"].map((u=>Ge().join(u,"vscode",t))).find((t=>(0,ze.existsSync)(t)));if(p){await et().mkdir(Ge().join(u,".vscode"),{recursive:true});await et().copyFile(p,Ge().join(u,".vscode",t))}}if(k.vscodeExtensions.length>0){await et().mkdir(Ge().join(u,".vscode"),{recursive:true});const t=k.vscodeExtensions.map((t=>`"${t}"`)).join(", ");await et().writeFile(Ge().join(u,".vscode","extensions.json"),`{${rt().EOL} "recommendations": [${t}]${rt().EOL}}${rt().EOL}`,"utf-8")}const C=(P=process.env.ZUPLO_PRIVATE_TEST_VERSION)!==null&&P!==void 0?P:S;const I=new ke.SemVer(C);const N={name:t,version:"0.1.0",private:true,type:"module",scripts:{dev:`zuplo dev`,...g==="ai-gateway"?{}:{test:"zuplo test"},typecheck:"tsc --noEmit",...O?{docs:"zuplo docs"}:{},...k.scripts},dependencies:buildProjectDependencies(g,I.major),devDependencies:{typescript:"^5","@types/node":"^22",...k.devDependencies}};if(O){if(p==="pnpm"){await et().writeFile(Ge().join(u,"pnpm-workspace.yaml"),["packages:",' - "docs"',"onlyBuiltDependencies:",' - "@swc/core"'," - deno"," - esbuild"," - protobufjs"," - workerd",""].join(rt().EOL),"utf-8")}else{N.workspaces=["docs"]}}const sortObjectKeys=t=>Object.keys(t).sort().reduce(((u,p)=>{u[p]=t[p];return u}),{});if(N.dependencies){N.dependencies=sortObjectKeys(N.dependencies)}if(N.devDependencies){N.devDependencies=sortObjectKeys(N.devDependencies)}const D=Object.keys(N.devDependencies).length;if(!D)delete N.devDependencies;await et().writeFile(Ge().join(u,"package.json"),JSON.stringify(N,null,2)+rt().EOL);let j="^0.82";if(O&&m){try{const t=await fetch("https://api.github.com/repos/zuplo/zudoku/releases/latest");const u=await t.json();const p=u.tag_name.replace("v","");const m=new ke.SemVer(p);j=`^${m.major}.${m.minor}`}catch{console.warn("\nFailed to determine the latest dev portal version. Using the default version.")}}const L=[{name:"@zudoku/plugin-graphql",label:"GraphQL plugin"},{name:"@zuplo/zudoku-plugin-monetization",label:"monetization plugin"}];const M={};for(const{name:t,label:u}of L){let p="latest";if(O&&m){try{const u=await fetch(`https://registry.npmjs.org/${t}/latest`);const m=await u.json();const g=new ke.SemVer(m.version);p=`^${g.major}.${g.minor}`}catch{console.warn(`\nFailed to determine the latest ${u} version. Using the default version.`)}}M[t]=p}const U={name:"docs",version:"0.1.0",private:true,type:"module",scripts:{dev:"zudoku dev --zuplo",build:"zudoku build --zuplo",...k.docsScripts},dependencies:sortObjectKeys({react:"^19","react-dom":"^19","@mdx-js/react":"3.0.1",...M,zudoku:j}),devDependencies:{"@types/node":"^22","@types/react":"^19","@types/react-dom":"^19",typescript:"^5"}};if(O){await et().writeFile(Ge().join(u,"docs","package.json"),JSON.stringify(U,null,2)+rt().EOL)}if($.length>0){await installAgentConfigs(u,$);const t=Ge().join(u,"README.md");const p=await et().readFile(t,"utf-8");const m=["","## AI Coding Agents","","This project is configured for AI coding agents. Skills from","[zuplo/tools](https://github.com/zuplo/tools) provide agents with Zuplo and","Zudoku-specific knowledge.","","To update skills to the latest version:","","```bash","npx skills add zuplo/tools","```","","Learn more about using AI agents with Zuplo at","[zuplo.com/docs/articles/ai-agents](https://zuplo.com/docs/articles/ai-agents).",""].join("\n");await et().writeFile(t,p+m,"utf-8")}if(!w)return;console.log("\nInstalling dependencies:");for(const t in N.dependencies)console.log(`- ${(0,qe.cyan)(t)}`);if(D){console.log("\nInstalling devDependencies:");for(const t in N.devDependencies)console.log(`- ${(0,qe.cyan)(t)}`)}console.log();await install(p,m,E)};class DownloadError extends Error{}async function createApp({appPath:t,packageManager:u,example:p,examplePath:m,template:g,linter:v,formatter:b,installPackages:w,empty:E,initGit:S,verbose:$,zuploVersion:P,serverProject:x,account:R,skipPrompts:O,agents:A}){var k;let T;const C=g!==null&&g!==void 0?g:`default${E?"-empty":""}`;if(p){let z;try{z=new URL(p)}catch(V){const G=V;if(G.code!=="ERR_INVALID_URL"){console.error(V);process.exit(1)}}if(z){if(z.origin!=="https://github.com"){console.error(`Invalid URL: ${(0,qe.red)(`"${p}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);process.exit(1)}T=await getRepoInfo(z,m);if(!T){console.error(`Found invalid GitHub URL: ${(0,qe.red)(`"${p}"`)}. Please fix the URL and try again.`);process.exit(1)}const q=await hasRepo(T);if(!q){console.error(`Could not locate the repository for ${(0,qe.red)(`"${p}"`)}. Please check that the repository exists and try again.`);process.exit(1)}}else if(p!=="__internal-testing-retry"){const W=await existsInRepo(p);if(!W){console.error(`Could not locate an example named ${(0,qe.red)(`"${p}"`)}. It could be due to the following:\n`,`1. Your spelling of example ${(0,qe.red)(`"${p}"`)} might be incorrect.\n`,`2. You might not be connected to the internet or you are behind a proxy.`);process.exit(1)}}}const I=(0,Ve.resolve)(t);if(!await isWriteable((0,Ve.dirname)(I))){console.error("The application path is not writable, please check folder permissions and try again.");console.error("It is likely you do not have write permissions for this folder.");process.exit(1)}const N=(0,Ve.basename)(I);(0,ze.mkdirSync)(I,{recursive:true});if(!isFolderEmpty(I,N)){process.exit(1)}const D=u==="yarn";const j=!D||await getOnline();const L=process.cwd();console.log(`Creating a new Zuplo API in ${(0,qe.green)(I)}.`);console.log();process.chdir(I);const M=(0,Ve.join)(I,"package.json");if(p){try{if(T){const Z=T;console.log(`Downloading files from repo ${(0,qe.cyan)(p)}. This might take a moment.`);console.log();await Xe()((()=>downloadAndExtractRepo(I,Z,$)),{retries:3})}else{console.log(`Downloading files for example ${(0,qe.cyan)(p)}. This might take a moment.`);console.log();await Xe()((()=>downloadAndExtractExample(I,p,$)),{retries:3})}}catch(J){function isErrorLike(t){return typeof t==="object"&&t!==null&&typeof t.message==="string"}throw new DownloadError(isErrorLike(J)?J.message:`${J}`)}const Y=(0,Ve.join)(I,".gitignore");if(!(0,ze.existsSync)(Y)){(0,ze.copyFileSync)(getTemplateFile({template:C,file:"gitignore"}),Y)}if(A.length>0){await installAgentConfigs(I,A)}if(w&&(0,ze.existsSync)(M)){console.log("Installing packages. This might take a couple of minutes.");console.log();await install(u,j,$);console.log()}}else{await installTemplate({appName:N,root:I,template:C,packageManager:u,isOnline:j,linter:v,formatter:b,installPackages:w,verbose:$,zuploVersion:P,agents:A})}const U=(0,ze.existsSync)(M);if(S){if(tryGitInit(I,$)){console.log("Initialized a git repository.");console.log()}}let B;if((0,Ve.join)(L,N)===t){B=N}else{B=t}console.log(`${(0,qe.green)("Success!")} Created ${N} at ${t}`);let H;if(x){H=await createAndLinkServerProject({appPath:I,appName:N,account:R,skipPrompts:O})}if(H){const X=`https://portal.zuplo.com/${H.account}/${H.project}`;console.log();console.log(`${(0,qe.green)("Success!")} Your project ${(0,qe.cyan)(`'${H.project}'`)} has been created in account ${(0,qe.cyan)(`'${H.account}'`)}.`);console.log();console.log("You can access this project online at:");console.log(` ${(0,qe.cyan)(X)}`);console.log();console.log("To connect your project to source control for easy, automated deployments:");console.log(` ${(0,qe.cyan)(`${X}/settings/source-control-settings`)}`);console.log()}if(U){const Q=(k=JSON.parse((0,ze.readFileSync)(M,"utf-8")).scripts)!==null&&k!==void 0?k:{};const run=t=>`${u} ${D?"":"run "}${t}`;const ee={dev:"Starts the local development server.",docs:"Starts the developer portal.",test:"Runs your API tests."};const te=Object.entries(ee).filter((([t])=>t in Q));console.log();if(te.length>0){console.log("Inside that directory, you can run several commands:");console.log();for(const[re,ie]of te){console.log((0,qe.cyan)(` ${run(re)}`));console.log(` ${ie}`);console.log()}}console.log("We suggest that you begin by typing:");console.log();console.log((0,qe.cyan)(" cd"),B);if(C==="ai-gateway"&&!p&&!H){console.log(` ${(0,qe.cyan)("npx zuplo link")}`)}if("dev"in Q){console.log(` ${(0,qe.cyan)(run("dev"))}`)}}console.log()}const rc=require("crypto");function basename(t){if(!t){return undefined}return C().basename(t).toLowerCase()}function parseUserAgent(t){var u;const p=t===null||t===void 0?void 0:t.match(/^([^/\s]+)\/([^\s]+)/);const m=(u=p===null||p===void 0?void 0:p[1])===null||u===void 0?void 0:u.toLowerCase();switch(m){case"npm":case"pnpm":case"yarn":case"bun":return{family:m,version:p===null||p===void 0?void 0:p[2]};default:return{family:"unknown"}}}function inferFamilyFromExecutable(t){if(t==="npm"||t==="npm-cli.js"||t==="npx"||t==="npx-cli.js"){return"npm"}if(t==="pnpm"||t==="pnpm.cjs"||t==="pnpx"){return"pnpm"}if(t==="yarn"||t==="yarn.js"){return"yarn"}if(t==="bun"||t==="bunx"){return"bun"}return undefined}function inferRunner({family:t,command:u,execPathBasename:p,runnerBasename:m}){if(t==="npm"){if(p==="npx-cli.js"||m==="npx"){return"npx"}if(u==="init"||u==="create"){return"npm-create"}if(u==="exec"){return"npm-exec"}return"npm"}if(t==="pnpm"){if(m==="pnpx"||p==="pnpx"){return"pnpx"}if(u==="create"||u==="init"){return"pnpm-create"}if(u==="dlx"){return"pnpm-dlx"}if(u==="exec"){return"pnpm-exec"}return"pnpm"}if(t==="yarn"){if(u==="create"){return"yarn-create"}if(u==="dlx"){return"yarn-dlx"}return"yarn"}if(t==="bun"){if(m==="bunx"){return"bunx"}if(u==="create"){return"bun-create"}return"bun"}return"unknown"}function inferInstallSource(t){if(!t){return"unknown"}const u=t.toLowerCase().replace(/\\/g,"/");if(u.includes("/node_modules/.bin/")){return"project-local"}if(u.includes("/corepack/")){return"corepack"}if(u.includes("/.volta/")||u.includes("/volta/")){return"volta"}if(u.includes("/.nvm/")){return"nvm"}if(u.includes("/.asdf/")){return"asdf"}if(u.includes("/.fnm/")||u.includes("/fnm_multishells/")){return"fnm"}if(u.includes("/homebrew/")||u.includes("/cellar/")||u.startsWith("/opt/homebrew/")){return"homebrew"}if(u.startsWith("/usr/bin/")||u.startsWith("/usr/local/bin/")||u.startsWith("/usr/local/lib/")||u.startsWith("/bin/")||u.startsWith("c:/program files/")||u.startsWith("c:/programdata/")){return"system"}return"unknown"}function getPackageManagerUsageProperties(t=process.env){var u,p,m;const g=t["npm_config_user_agent"]||undefined;const v=(u=t["npm_command"])===null||u===void 0?void 0:u.toLowerCase();const b=t["npm_execpath"];const w=basename(b);const E=basename(t["_"]);const S=parseUserAgent(g);const $=S.family!=="unknown"?S.family:(m=(p=inferFamilyFromExecutable(E))!==null&&p!==void 0?p:inferFamilyFromExecutable(w))!==null&&m!==void 0?m:"unknown";return{packageManager:$,packageManagerVersion:S.version,runner:inferRunner({family:$,command:v,execPathBasename:w,runnerBasename:E}),installSource:inferInstallSource(b),nodeVersion:process.versions.node,platform:process.platform,arch:process.arch}}function getPkgManager(){const{packageManager:t}=getPackageManagerUsageProperties();if(t!=="unknown"){return t}return"npm"}const sc="phc_xB1aydh7a41MW9TwUtLJjKme4izQiWf9zKbKhpysAiW";const ic="https://app.posthog.com";const nc=1e3;function isAnalyticsEnabled(){return!process.env.ZUPLO_DO_NOT_TRACK}function getOrCreateAnalyticsDistinctId(t){try{const u=t.get("analyticsDistinctId");if(typeof u==="string"&&u.length>0){return u}const p=(0,rc.randomUUID)();try{t.set("analyticsDistinctId",p)}catch{}return p}catch{return(0,rc.randomUUID)()}}async function captureCreateZuploApiEvent({distinctId:t,event:u,properties:p}){if(!isAnalyticsEnabled()){return}const m=new AbortController;const g=setTimeout((()=>m.abort()),nc);g.unref();try{await fetch(`${ic}/capture/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({["api_key"]:sc,event:u,["distinct_id"]:t,properties:{...getPackageManagerUsageProperties(),...p!==null&&p!==void 0?p:{}},timestamp:(new Date).toISOString()}),signal:m.signal})}catch{}finally{clearTimeout(g)}}function resolvePackageManager(t,u){if(t.useNpm)return"npm";if(t.usePnpm)return"pnpm";if(t.useYarn)return"yarn";if(t.useBun)return"bun";return u()}function resolveNegatableFlag(t,u,p){return t!==null&&t!==void 0?t:!u.includes(p)}function parseAgentsFlag(t){const u=t.split(",").map((t=>t.trim())).filter(Boolean);const p=new Set(ja.map((t=>t.value)));const m=u.filter((t=>!p.has(t)));if(m.length>0){return{ok:false,error:`Invalid agent value(s): ${m.join(", ")}\nValid agents are: ${Array.from(p).join(", ")}`}}if(u.includes(Da)){if(u.some((t=>t!==Da))){return{ok:false,error:`'none' cannot be combined with other agents. Use --agents none to skip agent setup, or list specific agents.`}}return{ok:true,agents:[]}}return{ok:true,agents:u}}const oc=["default","default-empty","ai-gateway"];function resolveTemplate(t){const{template:u,empty:p,example:m}=t;if(u===undefined){return{template:p?"default-empty":"default"}}if(m){return{error:"The --template option cannot be combined with --example. Remove one of the two options."}}if(p){return{error:"The --template option cannot be combined with --empty. Use --template default-empty instead."}}const g=oc.find((t=>t===u));if(!g){return{error:`Unknown template "${u}". Valid templates are: ${oc.join(", ")}.`}}return{template:g}}function resolveServerProjectFromFlags(t){if(t.noServerProject){return false}if(t.serverProject){return true}if(typeof t.account==="string"&&t.account.trim().length>0){return true}return undefined}var ac=__nccwpck_require__(7825);var cc=__nccwpck_require__.n(ac);function validateNpmName(t){const u=cc()(t);if(u.validForNewPackages){return{valid:true}}return{valid:false,problems:[...u.errors||[],...u.warnings||[]]}}let lc="";const handleSigTerm=()=>process.exit(0);process.on("SIGINT",handleSigTerm);process.on("SIGTERM",handleSigTerm);const onPromptState=t=>{if(t.aborted){process.stdout.write("[?25h");process.stdout.write("\n");process.exit(1)}};const uc=JSON.parse((0,ze.readFileSync)(Ge().resolve(__dirname,Ge().join("..","package.json")),"utf-8"));const hc=new $(uc.name).version(uc.version,"-v, --version","Output the current version of create-zuplo-api.").argument("[directory]").usage("[directory] [options]").helpOption("-h, --help","Display this help message.").option("--linter <linter>",`The linter to configure: ${Ja.join(", ")}.`).option("--formatter <formatter>",`The formatter to configure: ${Xa.join(", ")}.`).option("--eslint","Initialize with ESLint config. (deprecated: use --linter eslint)").option("--prettier","Initialize with Prettier config. (deprecated: use --formatter prettier)").option("--empty","Initialize an empty project.").option("--use-npm","Explicitly tell the CLI to bootstrap the application using npm.").option("--use-pnpm","Explicitly tell the CLI to bootstrap the application using pnpm.").option("--use-yarn","Explicitly tell the CLI to bootstrap the application using Yarn.").option("--use-bun","Explicitly tell the CLI to bootstrap the application using Bun.").option("--reset, --reset-preferences","Reset the preferences saved for create-zuplo-api.").option("--git","Whether or not to initialize the project as a git repo.").option("--version-check","Whether or not to check for an outdated version.").option("--install","Whether or not to install packages.").option("--verbose","Enable verbose logging.",false).option("--yes","Use saved preferences or defaults for unprovided options.").option("--server-project","Create a matching project on portal.zuplo.com and link this working copy to it (skips the interactive prompt).").option("--account <account-name>","The Zuplo account that will host the server project. Implies --server-project.").option("--agents <agents>","Comma-separated list of AI coding agents to configure (claude,copilot,cursor,windsurf,codex), or 'none' to skip agent setup.").option("--template <template-name>",`\n\n A built-in template to bootstrap the api with (default, default-empty,\n ai-gateway). Cannot be combined with --example or --empty.\n`).option("-e, --example <example-name|github-url>",`\n\n An example to bootstrap the api with. You can use an example name\n from the official Zuplo repo or a public GitHub URL. The URL can use\n any branch and/or subdirectory.\n`).option("--example-path <path-to-example>",`\n\n In a rare case, your GitHub URL might contain a branch name with\n a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar).\n In this case, you must specify the path to the example separately:\n --example-path foo/bar\n`).action((t=>{if(t&&!t.startsWith("-")){lc=t}})).allowUnknownOption().parse(process.argv);const dc=hc.opts();const{args:fc}=hc;const pc=resolvePackageManager(dc,getPkgManager);async function run(){var t,p,m,g,v,b,w,E,S;const $=new Conf({projectName:"create-zuplo-api"});if(typeof dc.linter==="string"&&!isLinter(dc.linter)){console.error((0,qe.red)(`Invalid linter: "${dc.linter}"\nValid linters are: ${Ja.join(", ")}`));process.exit(1)}if(typeof dc.formatter==="string"&&!isFormatter(dc.formatter)){console.error((0,qe.red)(`Invalid formatter: "${dc.formatter}"\nValid formatters are: ${Xa.join(", ")}`));process.exit(1)}if(dc.resetPreferences){const{resetPreferences:t}=await Ke()({onState:onPromptState,type:"toggle",name:"resetPreferences",message:"Would you like to reset the saved preferences?",initial:false,active:"Yes",inactive:"No"});if(t){$.clear();console.log("The preferences have been reset successfully!")}process.exit(0)}if(typeof lc==="string"){lc=lc.trim()}if(!lc){const t=await Ke()({onState:onPromptState,type:"text",name:"path",message:"What is your project named?",initial:"my-api",validate:t=>{const u=validateNpmName((0,Ve.basename)((0,Ve.resolve)(t)));if(u.valid){return true}return`Invalid project name: ${u.problems[0]}`}});if(typeof t.path==="string"){lc=t.path.trim()}}if(!lc){console.log("\nPlease specify the project directory:\n"+` ${(0,qe.cyan)(dc.name())} ${(0,qe.green)("<project-directory>")}\n`+"For example:\n"+` ${(0,qe.cyan)(dc.name())} ${(0,qe.green)("my-zuplo-api")}\n\n`+`Run ${(0,qe.cyan)(`${dc.name()} --help`)} to see all options.`);process.exit(1)}const P=(0,Ve.resolve)(lc);const x=(0,Ve.basename)(P);const R=validateNpmName(x);if(!R.valid){console.error(`Could not create a project called ${(0,qe.red)(`"${x}"`)} because of npm naming restrictions:`);R.problems.forEach((t=>console.error(` ${(0,qe.red)((0,qe.bold)("*"))} ${t}`)));process.exit(1)}if(dc.example===true){console.error("Please provide an example name or url, otherwise remove the example option.");process.exit(1)}if((0,ze.existsSync)(P)&&!isFolderEmpty(P,x)){process.exit(1)}const O=typeof dc.example==="string"&&dc.example.trim();const A=resolveTemplate({template:typeof dc.template==="string"?dc.template:undefined,empty:Boolean(dc.empty),example:Boolean(O)});if("error"in A){console.error((0,qe.red)(A.error));process.exit(1)}const k=$.get("preferences")||{};const T=u().isCI||dc.yes;let C=resolveServerProjectFromFlags({noServerProject:fc.includes("--no-server-project"),serverProject:dc.serverProject===true,account:typeof dc.account==="string"?dc.account:undefined});if(C===undefined&&!T){const{serverProject:t}=await Ke()({onState:onPromptState,type:"toggle",name:"serverProject",message:"Create a matching project on portal.zuplo.com?",hint:"Connect this working copy to your Zuplo account so you can deploy and manage it from portal.zuplo.com.",initial:true,active:"Yes",inactive:"No"});C=Boolean(t)}if(!O){const u={linter:"eslint",formatter:"prettier",git:true,install:true,versionCheck:true,empty:false,zudoku:false};migrateLegacyLintPreferences(k);const getPrefOrDefault=t=>{var p;return(p=k[t])!==null&&p!==void 0?p:u[t]};if(!dc.linter){const t=resolveLinterFromLegacyFlags({eslint:dc.eslint===true,noEslint:fc.includes("--no-eslint")});if(t){dc.linter=t}else if(T){dc.linter=getPrefOrDefault("linter")}else{const t=getPrefOrDefault("linter");const{linter:u}=await Ke()({onState:onPromptState,type:"select",name:"linter",message:`Which ${(0,qe.blue)("linter")} would you like to use?`,choices:Qa,initial:Math.max(0,Qa.findIndex((u=>u.value===t)))});dc.linter=u;k.linter=dc.linter}}if(!dc.formatter){const p=resolveFormatterFromLegacyFlags({prettier:dc.prettier===true,noPrettier:fc.includes("--no-prettier")});if(p){dc.formatter=p}else if(T){dc.formatter=getPrefOrDefault("formatter")}else{const p=(t=k.formatter)!==null&&t!==void 0?t:dc.linter==="biome"?"biome":u.formatter;const{formatter:m}=await Ke()({onState:onPromptState,type:"select",name:"formatter",message:`Which ${(0,qe.blue)("formatter")} would you like to use?`,choices:ec,initial:Math.max(0,ec.findIndex((t=>t.value===p)))});dc.formatter=m;k.formatter=dc.formatter}}if(!dc.agents){if(T){dc.agents=[]}else{const{agents:t}=await Ke()({onState:onPromptState,type:"multiselect",name:"agents",message:"Which AI coding agents would you like to configure?",choices:ja,hint:"- Space to select. Return to submit"});dc.agents=resolveAgentSelection((p=t)!==null&&p!==void 0?p:[])}}}dc.git=resolveNegatableFlag(dc.git,fc,"--no-git");dc.install=resolveNegatableFlag(dc.install,fc,"--no-install");dc.versionCheck=resolveNegatableFlag(dc.versionCheck,fc,"--no-version-check");dc.serverProject=C!==null&&C!==void 0?C:false;if(typeof dc.agents==="string"){const t=parseAgentsFlag(dc.agents);if(!t.ok){console.error((0,qe.red)(t.error));process.exit(1)}dc.agents=t.agents}dc.agents=(m=dc.agents)!==null&&m!==void 0?m:[];if(isAnalyticsEnabled()){void captureCreateZuploApiEvent({distinctId:getOrCreateAnalyticsDistinctId($),event:"create-zuplo-api invoked",properties:{version:uc.version,selectedPackageManager:pc,hasExample:Boolean(O),template:A.template,emptyTemplate:Boolean(dc.empty),installPackages:Boolean(dc.install),initGit:Boolean(dc.git),serverProject:Boolean(dc.serverProject),skipPrompts:T,agentsCount:dc.agents.length,linter:(g=dc.linter)!==null&&g!==void 0?g:null,formatter:(v=dc.formatter)!==null&&v!==void 0?v:null}})}try{await createApp({appPath:P,packageManager:pc,example:O&&O!=="default"?O:undefined,examplePath:dc.examplePath,template:A.template,linter:(b=dc.linter)!==null&&b!==void 0?b:"none",formatter:(w=dc.formatter)!==null&&w!==void 0?w:"none",installPackages:dc.install,empty:dc.empty,initGit:dc.git,verbose:dc.verbose,zuploVersion:uc.version,serverProject:dc.serverProject,account:dc.account,skipPrompts:T,agents:dc.agents})}catch(t){if(!(t instanceof DownloadError)){throw t}const u=await Ke()({onState:onPromptState,type:"confirm",name:"builtin",message:`Could not download "${O}" because of a connectivity issue between your machine and GitHub.\n`+`Do you want to use the default template instead?`,initial:true});if(!u.builtin){throw t}await createApp({appPath:P,packageManager:pc,template:A.template,linter:(E=dc.linter)!==null&&E!==void 0?E:"none",formatter:(S=dc.formatter)!==null&&S!==void 0?S:"none",installPackages:dc.install,empty:dc.empty,initGit:dc.git,verbose:dc.verbose,zuploVersion:uc.version,serverProject:dc.serverProject,account:dc.account,skipPrompts:T,agents:dc.agents})}$.set("preferences",k);if(dc.versionCheck){console.log();await notifyUpdate()}}const mc=Ze()(uc).catch((()=>null));async function notifyUpdate(){var t;try{if((t=await mc)===null||t===void 0?void 0:t.latest){const t={npm:"npm i -g",yarn:"yarn global add",pnpm:"pnpm add -g",bun:"bun add -g"};const u=`${t[pc]} create-zuplo-api`;console.log((0,qe.yellow)((0,qe.bold)("A new version of `create-zuplo-api` is available!"))+"\n"+"You can update by running: "+(0,qe.cyan)(u)+"\n")}process.exit(0)}catch{}}async function exit(t){console.log();console.log("Aborting installation.");if(t.command){console.log(` ${(0,qe.cyan)(t.command)} has failed.`)}else{console.log(`${(0,qe.red)("Unexpected error. Please report it as a bug:")}\n`,t)}process.exit(1)}run().catch(exit)})();module.exports=p})();
|