@lukoweb/create-apitogo 0.2.71 → 0.2.75
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 +6 -13
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(952);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 y=String(g.relaxZeros);let v=String(g.shorthand);let b=String(g.capture);let w=String(g.wrap);let E=t+":"+u+"="+y+v+b+w;if(toRegexRange.cache.hasOwnProperty(E)){return toRegexRange.cache[E].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 A=hasPadding(t)||hasPadding(u);let O={min:t,max:u,a:$,b:P};let R=[];let x=[];if(A){O.isPadded=A;O.maxLen=String(O.max).length}if($<0){let t=P<0?Math.abs(P):1;x=splitToPatterns(t,Math.abs($),O,g);$=O.a=0}if(P>=0){R=splitToPatterns($,P,O,g)}O.negatives=x;O.positives=R;O.result=collatePatterns(x,R,g);if(g.capture===true){O.result=`(${O.result})`}else if(g.wrap!==false&&R.length+x.length>1){O.result=`(?:${O.result})`}toRegexRange.cache[E]=O;return O.result};function collatePatterns(t,u,p){let m=filterPatterns(t,u,"-",false,p)||[];let g=filterPatterns(u,t,"",false,p)||[];let y=filterPatterns(t,u,"-?",true,p)||[];let v=m.concat(y).concat(g);return v.join("|")}function splitToRanges(t,u){let p=1;let m=1;let g=countNines(t,p);let y=new Set([u]);while(t<=g&&g<=u){y.add(g);p+=1;g=countNines(t,p)}g=countZeros(u+1,m)-1;while(t<g&&g<=u){y.add(g);m+=1;g=countZeros(u+1,m)-1}y=[...y];y.sort(compare);return y}function rangeToPattern(t,u,p){if(t===u){return{pattern:t,count:[],digits:0}}let m=zip(t,u);let g=m.length;let y="";let v=0;for(let t=0;t<g;t++){let[u,g]=m[t];if(u===g){y+=u}else if(u!=="0"||g!=="9"){y+=toCharacterClass(u,g,p)}else{v++}}if(v){y+=p.shorthand===true?"\\d":"[0-9]"}return{pattern:y,count:[v],digits:g}}function splitToPatterns(t,u,p,m){let g=splitToRanges(t,u);let y=[];let v=t;let b;for(let t=0;t<g.length;t++){let u=g[t];let w=rangeToPattern(String(v),String(u),m);let E="";if(!p.isPadded&&b&&b.pattern===w.pattern){if(b.count.length>1){b.count.pop()}b.count.push(w.count[0]);b.string=b.pattern+toQuantifier(b.count);v=u+1;continue}if(p.isPadded){E=padZeros(u,p,m)}w.string=E+w.pattern+toQuantifier(w.count);y.push(w);v=u+1;b=w}return y}function filterPatterns(t,u,p,m,g){let y=[];for(let g of t){let{string:t}=g;if(!m&&!contains(u,"string",t)){y.push(p+t)}if(m&&contains(u,"string",t)){y.push(p+t)}}return y}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},5059:(t,u,p)=>{const{URL:m}=p(7016);const{join:g}=p(6928);const y=p(7515);const{promisify:v}=p(9023);const{tmpdir:b}=p(857);const w=p(3805);const E=v(y.writeFile);const $=v(y.mkdir);const P=v(y.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=b();const m=g(p,"update-check");if(!y.existsSync(m)){await $(m)}let v=`${t.name}-${u}.json`;if(t.scope){v=`${t.scope}-${v}`}return g(m,v)};const evaluateCache=async(t,u,p)=>{if(y.existsSync(t)){const m=await P(t,"utf8");const{lastUpdate:g,latest:y}=JSON.parse(m);const v=g+p;if(v>u){return{shouldCheck:false,latest:y}}}return{shouldCheck:true,latest:null}};const updateCache=async(t,u,p)=>{const m=JSON.stringify({latest:u,lastUpdate:p});await E(t,m,"utf8")};const loadPackage=(t,u)=>new Promise(((m,g)=>{const y={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){y.headers.authorization=`${u.type} ${u.token}`}const{get:v}=p(t.protocol==="https:"?5692:8611);v(y,(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 y=w(u);const v=new m(t,y);let b=null;try{b=await loadPackage(v)}catch(t){if(t.code&&String(t.code).startsWith(4)){const t=p(4133);const u=t(y,{recursive:true});b=await loadPackage(v,u)}else{throw t}}const E=b["dist-tags"][g];if(!E){throw new Error(`Distribution tag ${g} is not available`)}return E};const A={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:y}=Object.assign({},A,u);const v=await getFile(p,g);let b=null;let w=true;({shouldCheck:w,latest:b}=await evaluateCache(v,m,y));if(w){b=await getMostRecent(p,g);await updateCache(v,b,m)}const E=compareVersions(t.version,b);if(E===-1){return{latest:b,fromCache:!w}}return null}},8904:(t,u,p)=>{"use strict";const m=p(6737);var g=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");var y=["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.startsWith(".")){p.push("name cannot start with a period")}if(t.startsWith("-")){p.push("name cannot start with a hyphen")}if(t.match(/^_/)){p.push("name cannot start with an underscore")}if(t.trim()!==t){p.push("name cannot contain leading or trailing spaces")}y.forEach((function(u){if(t.toLowerCase()===u){p.push(u+" is not a valid package 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 v=t.match(g);if(v){var b=v[1];var w=v[2];if(w.startsWith(".")){p.push("name cannot start with a period")}if(encodeURIComponent(b)===b&&encodeURIComponent(w)===w){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},1192:(t,u,p)=>{const m=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys";const g=p(6928);const y=m?";":":";const v=p(7105);const getNotFoundError=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"});const getPathInfo=(t,u)=>{const p=u.colon||y;const g=t.match(/\//)||m&&t.match(/\\/)?[""]:[...m?[process.cwd()]:[],...(u.path||process.env.PATH||"").split(p)];const v=m?u.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"";const b=m?v.split(p):[""];if(m){if(t.indexOf(".")!==-1&&b[0]!=="")b.unshift("")}return{pathEnv:g,pathExt:b,pathExtExe:v}};const which=(t,u,p)=>{if(typeof u==="function"){p=u;u={}}if(!u)u={};const{pathEnv:m,pathExt:y,pathExtExe:b}=getPathInfo(t,u);const w=[];const step=p=>new Promise(((y,v)=>{if(p===m.length)return u.all&&w.length?y(w):v(getNotFoundError(t));const b=m[p];const E=/^".*"$/.test(b)?b.slice(1,-1):b;const $=g.join(E,t);const P=!E&&/^\.[\\\/]/.test(t)?t.slice(0,2)+$:$;y(subStep(P,p,0))}));const subStep=(t,p,m)=>new Promise(((g,E)=>{if(m===y.length)return g(step(p+1));const $=y[m];v(t+$,{pathExt:b},((y,v)=>{if(!y&&v){if(u.all)w.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:y}=getPathInfo(t,u);const b=[];for(let w=0;w<p.length;w++){const E=p[w];const $=/^".*"$/.test(E)?E.slice(1,-1):E;const P=g.join($,t);const A=!$&&/^\.[\\\/]/.test(t)?t.slice(0,2)+P:P;for(let t=0;t<m.length;t++){const p=A+m[t];try{const t=v.sync(p,{pathExt:y});if(t){if(u.all)b.push(p);else return p}}catch(t){}}}if(u.all&&b.length)return b;if(u.nothrow)return null;throw getNotFoundError(t)};t.exports=which;which.sync=whichSync},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")},7515:t=>{"use strict";t.exports=require("fs")},8611:t=>{"use strict";t.exports=require("http")},5692:t=>{"use strict";t.exports=require("https")},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")},7016:t=>{"use strict";t.exports=require("url")},9023:t=>{"use strict";t.exports=require("util")},4732:(t,u,p)=>{"use strict";const m=p(7028);const g=process.env;Object.defineProperty(u,"_vendors",{value:m.map((function(t){return t.constant}))});u.name=null;u.isPR=null;u.id=null;if(g.CI!=="false"){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;u.isPR=checkPR(t);u.id=t.constant}))}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]}))}function checkPR(t){switch(typeof t.pr){case"string":return!!g[t.pr];case"object":if("env"in t.pr){if("any"in t.pr){return t.pr.any.some((function(u){return g[t.pr.env]===u}))}else{return t.pr.env in g&&g[t.pr.env]!==t.pr.ne}}else if("any"in t.pr){return t.pr.any.some((function(t){return!!g[t]}))}else{return checkEnv(t.pr)}default:return null}}},206:(t,u,p)=>{const{Argument:m}=p(1455);const{Command:g}=p(4623);const{CommanderError:y,InvalidArgumentError:v}=p(9400);const{Help:b}=p(2559);const{Option:w}=p(1033);u.DM=new g;u.gu=t=>new g(t);u.Ww=(t,u)=>new w(t,u);u.er=(t,u)=>new m(t,u);u.uB=g;u.c$=w;u.ef=m;u._V=b;u.b7=y;u.Di=v;u.a2=v},1455:(t,u,p)=>{const{InvalidArgumentError:m}=p(9400);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.endsWith("...")){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_collectValue(t,u){if(u===this.defaultValue||!Array.isArray(u)){return[t]}u.push(t);return u}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._collectValue(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},4623:(t,u,p)=>{const m=p(8474).EventEmitter;const g=p(1421);const y=p(6760);const v=p(3024);const b=p(1708);const{Argument:w,humanReadableArgName:E}=p(1455);const{CommanderError:$}=p(9400);const{Help:P,stripColor:A}=p(2559);const{Option:O,DualOptions:R}=p(1033);const{suggestSimilar:x}=p(3683);class Command extends m{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=false;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._savedState=null;this._outputConfiguration={writeOut:t=>b.stdout.write(t),writeErr:t=>b.stderr.write(t),outputError:(t,u)=>u(t),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:undefined,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:undefined,getOutHasColors:()=>useColor()??(b.stdout.isTTY&&b.stdout.hasColors?.()),getErrHasColors:()=>useColor()??(b.stderr.isTTY&&b.stderr.hasColors?.()),stripColor:t=>A(t)};this._hidden=false;this._helpOption=undefined;this._addImplicitHelpCommand=undefined;this._helpCommand=undefined;this._helpConfiguration={};this._helpGroupHeading=undefined;this._defaultCommandGroup=undefined;this._defaultOptionGroup=undefined}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[,y,v]=t.match(/([^ ]+) *(.*)/);const b=this.createCommand(y);if(m){b.description(m);b._executableHandler=true}if(g.isDefault)this._defaultCommandName=b._name;b._hidden=!!(g.noHelp||g.hidden);b._executableFile=g.executableFile||null;if(v)b.arguments(v);this._registerCommand(b);b.parent=this;b.copyInheritedSettings(this);if(m)return this;return b}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;this._outputConfiguration={...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 w(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?.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;if(t&&this._defaultCommandGroup){this._initCommandGroup(this._getHelpCommand())}return this}const p=t??"help [command]";const[,m,g]=p.match(/([^ ]+) *(.*)/);const y=u??"display help for command";const v=this.createCommand(m);v.helpOption(false);if(g)v.arguments(g);if(y)v.description(y);this._addImplicitHelpCommand=true;this._helpCommand=v;if(t||u)this._initCommandGroup(v);return this}addHelpCommand(t,u){if(typeof t!=="object"){this.helpCommand(t,u);return this}this._addImplicitHelpCommand=true;this._helpCommand=t;this._initCommandGroup(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))}b.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 O(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._initOptionGroup(t);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._initCommandGroup(t);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 y=this.getOptionValue(p);if(u!==null&&t.parseArg){u=this._callParseArg(t,u,y,m)}else if(u!==null&&t.variadic){u=t._collectValue(u,y)}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 O){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const y=this.createOption(u,p);y.makeOptionMandatory(!!t.mandatory);if(typeof m==="function"){y.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};y.default(g).argParser(m)}else{y.default(m)}return this.addOption(y)}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(b.versions?.electron){u.from="electron"}const t=b.execArgv??[];if(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print")){u.from="eval"}}if(t===undefined){t=b.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(b.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){this._prepareForParse();const p=this._prepareUserArgs(t,u);this._parseCommand([],p);return this}async parseAsync(t,u){this._prepareForParse();const p=this._prepareUserArgs(t,u);await this._parseCommand([],p);return this}_prepareForParse(){if(this._savedState===null){this.saveStateBeforeParse()}else{this.restoreStateBeforeParse()}}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name;this._scriptPath=null;this.rawArgs=[];this._optionValues={...this._savedState._optionValues};this._optionValueSources={...this._savedState._optionValueSources};this.args=[];this.processedArgs=[]}_checkForMissingExecutable(t,u,p){if(v.existsSync(t))return;const m=u?`searched for local subcommand relative to directory '${u}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const g=`'${t}' does not exist\n - if '${p}' 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 - ${m}`;throw new Error(g)}_executeSubCommand(t,u){u=u.slice();let p=false;const m=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,u){const p=y.resolve(t,u);if(v.existsSync(p))return p;if(m.includes(y.extname(u)))return undefined;const g=m.find((t=>v.existsSync(`${p}${t}`)));if(g)return`${p}${g}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let w=t._executableFile||`${this._name}-${t._name}`;let E=this._executableDir||"";if(this._scriptPath){let t;try{t=v.realpathSync(this._scriptPath)}catch{t=this._scriptPath}E=y.resolve(y.dirname(t),E)}if(E){let u=findFile(E,w);if(!u&&!t._executableFile&&this._scriptPath){const p=y.basename(this._scriptPath,y.extname(this._scriptPath));if(p!==this._name){u=findFile(E,`${p}-${t._name}`)}}w=u||w}p=m.includes(y.extname(w));let P;if(b.platform!=="win32"){if(p){u.unshift(w);u=incrementNodeInspectorPort(b.execArgv).concat(u);P=g.spawn(b.argv[0],u,{stdio:"inherit"})}else{P=g.spawn(w,u,{stdio:"inherit"})}}else{this._checkForMissingExecutable(w,E,t._name);u.unshift(w);u=incrementNodeInspectorPort(b.execArgv).concat(u);P=g.spawn(b.execPath,u,{stdio:"inherit"})}if(!P.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{b.on(t,(()=>{if(P.killed===false&&P.exitCode===null){P.kill(t)}}))}))}const A=this._exitCallback;P.on("close",(t=>{t=t??1;if(!A){b.exit(t)}else{A(new $(t,"commander.executeSubCommandAsync","(close)"))}}));P.on("error",(u=>{if(u.code==="ENOENT"){this._checkForMissingExecutable(w,E,t._name)}else if(u.code==="EACCES"){throw new Error(`'${w}' not executable`)}if(!A){b.exit(1)}else{const t=new $(1,"commander.executeSubCommandAsync","(error)");t.nestedError=u;A(t)}}));this.runningCommand=P}_dispatchSubcommand(t,u,p){const m=this._findCommand(t);if(!m)this.help({error:true});m._prepareForParse();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?.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?.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;function maybeOption(t){return t.length>1&&t[0]==="-"}const negativeNumberArg=t=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(t))return false;return!this._getCommandAndAncestors().some((t=>t.options.map((t=>t.short)).some((t=>/^-\d$/.test(t)))))};let g=null;let y=null;let v=0;while(v<t.length||y){const b=y??t[v++];y=null;if(b==="--"){if(m===p)m.push(b);m.push(...t.slice(v));break}if(g&&(!maybeOption(b)||negativeNumberArg(b))){this.emit(`option:${g.name()}`,b);continue}g=null;if(maybeOption(b)){const u=this._findOption(b);if(u){if(u.required){const p=t[v++];if(p===undefined)this.optionMissingArgument(u);this.emit(`option:${u.name()}`,p)}else if(u.optional){let p=null;if(v<t.length&&(!maybeOption(t[v])||negativeNumberArg(t[v]))){p=t[v++]}this.emit(`option:${u.name()}`,p)}else{this.emit(`option:${u.name()}`)}g=u.variadic?u:null;continue}}if(b.length>2&&b[0]==="-"&&b[1]!=="-"){const t=this._findOption(`-${b[1]}`);if(t){if(t.required||t.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${t.name()}`,b.slice(2))}else{this.emit(`option:${t.name()}`);y=`-${b.slice(2)}`}continue}}if(/^--[^=]+=/.test(b)){const t=b.indexOf("=");const u=this._findOption(b.slice(0,t));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,b.slice(t+1));continue}}if(m===u&&maybeOption(b)&&!(this.commands.length===0&&negativeNumberArg(b))){m=p}if((this._enablePositionalOptions||this._passThroughOptions)&&u.length===0&&p.length===0){if(this._findCommand(b)){u.push(b);p.push(...t.slice(v));break}else if(this._getHelpCommand()&&b===this._getHelpCommand().name()){u.push(b,...t.slice(v));break}else if(this._defaultCommandName){p.push(b,...t.slice(v));break}}if(this._passThroughOptions){m.push(b,...t.slice(v));break}m.push(b)}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 b.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()}`,b.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=x(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=x(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=>E(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}helpGroup(t){if(t===undefined)return this._helpGroupHeading??"";this._helpGroupHeading=t;return this}commandsGroup(t){if(t===undefined)return this._defaultCommandGroup??"";this._defaultCommandGroup=t;return this}optionsGroup(t){if(t===undefined)return this._defaultOptionGroup??"";this._defaultOptionGroup=t;return this}_initOptionGroup(t){if(this._defaultOptionGroup&&!t.helpGroupHeading)t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){if(this._defaultCommandGroup&&!t.helpGroup())t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){this._name=y.basename(t,y.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const u=this.createHelp();const p=this._getOutputContext(t);u.prepareContext({error:p.error,helpWidth:p.helpWidth,outputHasColors:p.hasColors});const m=u.formatHelp(this,u);if(p.hasColors)return m;return this._outputConfiguration.stripColor(m)}_getOutputContext(t){t=t||{};const u=!!t.error;let p;let m;let g;if(u){p=t=>this._outputConfiguration.writeErr(t);m=this._outputConfiguration.getErrHasColors();g=this._outputConfiguration.getErrHelpWidth()}else{p=t=>this._outputConfiguration.writeOut(t);m=this._outputConfiguration.getOutHasColors();g=this._outputConfiguration.getOutHelpWidth()}const write=t=>{if(!m)t=this._outputConfiguration.stripColor(t);return p(t)};return{error:u,write:write,hasColors:m,helpWidth:g}}outputHelp(t){let u;if(typeof t==="function"){u=t;t=undefined}const p=this._getOutputContext(t);const m={error:p.error,write:p.write,command:this};this._getCommandAndAncestors().reverse().forEach((t=>t.emit("beforeAllHelp",m)));this.emit("beforeHelp",m);let g=this.helpInformation({error:p.error});if(u){g=u(g);if(typeof g!=="string"&&!Buffer.isBuffer(g)){throw new Error("outputHelp callback must return a string or a Buffer")}}p.write(g);if(this._getHelpOption()?.long){this.emit(this._getHelpOption().long)}this.emit("afterHelp",m);this._getCommandAndAncestors().forEach((t=>t.emit("afterAllHelp",m)))}helpOption(t,u){if(typeof t==="boolean"){if(t){if(this._helpOption===null)this._helpOption=undefined;if(this._defaultOptionGroup){this._initOptionGroup(this._getHelpOption())}}else{this._helpOption=null}return this}this._helpOption=this.createOption(t??"-h, --help",u??"display help for command");if(t||u)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===undefined){this.helpOption(undefined,undefined)}return this._helpOption}addHelpOption(t){this._helpOption=t;this._initOptionGroup(t);return this}help(t){this.outputHelp(t);let u=Number(b.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}))}function useColor(){if(b.env.NO_COLOR||b.env.FORCE_COLOR==="0"||b.env.FORCE_COLOR==="false")return false;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==undefined)return true;return undefined}u.Command=Command;u.useColor=useColor},9400:(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},2559:(t,u,p)=>{const{humanReadableArgName:m}=p(1455);class Help{constructor(){this.helpWidth=undefined;this.minWidthToWrap=40;this.sortSubcommands=false;this.sortOptions=false;this.showGlobalOptions=false}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}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,this.displayWidth(u.styleSubcommandTerm(u.subcommandTerm(p))))),0)}longestOptionTermLength(t,u){return u.visibleOptions(t).reduce(((t,p)=>Math.max(t,this.displayWidth(u.styleOptionTerm(u.optionTerm(p))))),0)}longestGlobalOptionTermLength(t,u){return u.visibleGlobalOptions(t).reduce(((t,p)=>Math.max(t,this.displayWidth(u.styleOptionTerm(u.optionTerm(p))))),0)}longestArgumentTermLength(t,u){return u.visibleArguments(t).reduce(((t,p)=>Math.max(t,this.displayWidth(u.styleArgumentTerm(u.argumentTerm(p))))),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){const p=`(${u.join(", ")})`;if(t.description){return`${t.description} ${p}`}return p}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}formatItemList(t,u,p){if(u.length===0)return[];return[p.styleTitle(t),...u,""]}groupItems(t,u,p){const m=new Map;t.forEach((t=>{const u=p(t);if(!m.has(u))m.set(u,[])}));u.forEach((t=>{const u=p(t);if(!m.has(u)){m.set(u,[])}m.get(u).push(t)}));return m}formatHelp(t,u){const p=u.padWidth(t,u);const m=u.helpWidth??80;function callFormatItem(t,m){return u.formatItem(t,p,m,u)}let g=[`${u.styleTitle("Usage:")} ${u.styleUsage(u.commandUsage(t))}`,""];const y=u.commandDescription(t);if(y.length>0){g=g.concat([u.boxWrap(u.styleCommandDescription(y),m),""])}const v=u.visibleArguments(t).map((t=>callFormatItem(u.styleArgumentTerm(u.argumentTerm(t)),u.styleArgumentDescription(u.argumentDescription(t)))));g=g.concat(this.formatItemList("Arguments:",v,u));const b=this.groupItems(t.options,u.visibleOptions(t),(t=>t.helpGroupHeading??"Options:"));b.forEach(((t,p)=>{const m=t.map((t=>callFormatItem(u.styleOptionTerm(u.optionTerm(t)),u.styleOptionDescription(u.optionDescription(t)))));g=g.concat(this.formatItemList(p,m,u))}));if(u.showGlobalOptions){const p=u.visibleGlobalOptions(t).map((t=>callFormatItem(u.styleOptionTerm(u.optionTerm(t)),u.styleOptionDescription(u.optionDescription(t)))));g=g.concat(this.formatItemList("Global Options:",p,u))}const w=this.groupItems(t.commands,u.visibleCommands(t),(t=>t.helpGroup()||"Commands:"));w.forEach(((t,p)=>{const m=t.map((t=>callFormatItem(u.styleSubcommandTerm(u.subcommandTerm(t)),u.styleSubcommandDescription(u.subcommandDescription(t)))));g=g.concat(this.formatItemList(p,m,u))}));return g.join("\n")}displayWidth(t){return stripColor(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map((t=>{if(t==="[options]")return this.styleOptionText(t);if(t==="[command]")return this.styleSubcommandText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleCommandText(t)})).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map((t=>{if(t==="[options]")return this.styleOptionText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleSubcommandText(t)})).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,u){return Math.max(u.longestOptionTermLength(t,u),u.longestGlobalOptionTermLength(t,u),u.longestSubcommandTermLength(t,u),u.longestArgumentTermLength(t,u))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,u,p,m){const g=2;const y=" ".repeat(g);if(!p)return y+t;const v=t.padEnd(u+t.length-m.displayWidth(t));const b=2;const w=this.helpWidth??80;const E=w-u-b-g;let $;if(E<this.minWidthToWrap||m.preformatted(p)){$=p}else{const t=m.boxWrap(p,E);$=t.replace(/\n/g,"\n"+" ".repeat(u+b))}return y+v+" ".repeat(b)+$.replace(/\n/g,`\n${y}`)}boxWrap(t,u){if(u<this.minWidthToWrap)return t;const p=t.split(/\r\n|\n/);const m=/[\s]*[^\s]+/g;const g=[];p.forEach((t=>{const p=t.match(m);if(p===null){g.push("");return}let y=[p.shift()];let v=this.displayWidth(y[0]);p.forEach((t=>{const p=this.displayWidth(t);if(v+p<=u){y.push(t);v+=p;return}g.push(y.join(""));const m=t.trimStart();y=[m];v=this.displayWidth(m)}));g.push(y.join(""))}));return g.join("\n")}}function stripColor(t){const u=/\x1b\[\d*(;\d*)*m/g;return t.replace(u,"")}u.Help=Help;u.stripColor=stripColor},1033:(t,u,p)=>{const{InvalidArgumentError:m}=p(9400);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;this.helpGroupHeading=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}_collectValue(t,u){if(u===this.defaultValue||!Array.isArray(u)){return[t]}u.push(t);return u}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._collectValue(t,u)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){if(this.negate){return camelcase(this.name().replace(/^no-/,""))}return camelcase(this.name())}helpGroup(t){this.helpGroupHeading=t;return this}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=/^-[^-]$/;const g=/^--[^-]/;const y=t.split(/[ |,]+/).concat("guard");if(m.test(y[0]))u=y.shift();if(g.test(y[0]))p=y.shift();if(!u&&m.test(y[0]))u=y.shift();if(!u&&g.test(y[0])){u=p;p=y.shift()}if(y[0].startsWith("-")){const u=y[0];const p=`option creation failed due to '${u}' in option flags '${t}'`;if(/^-[^-][^-]/.test(u))throw new Error(`${p}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(m.test(u))throw new Error(`${p}\n- too many short flags`);if(g.test(u))throw new Error(`${p}\n- too many long flags`);throw new Error(`${p}\n- unrecognised flag format`)}if(u===undefined&&p===undefined)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:u,longFlag:p}}u.Option=Option;u.DualOptions=DualOptions},3683:(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 y=1;if(t[g-1]===u[p-1]){y=0}else{y=1}m[g][p]=Math.min(m[g-1][p]+1,m[g][p-1]+1,m[g-1][p-1]+y);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 y=p;const v=.4;u.forEach((u=>{if(u.length<=1)return;const p=editDistance(t,u);const m=Math.max(t.length,u.length);const b=(m-p)/m;if(b>v){if(p<y){y=p;g=[u]}else if(p===y){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},6564:(t,u,p)=>{"use strict";const{normalizeIPv6:m,removeDotSegments:g,recomposeAuthority:y,normalizeComponentEncoding:v,isIPv4:b,nonSimpleDomain:w}=p(1097);const{SCHEMES:E,getSchemeHandler:$}=p(2424);function normalize(t,u){if(typeof t==="string"){t=serialize(parse(t,u),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 g=resolveComponent(parse(t,m),parse(u,m),m,true);m.skipEscape=true;return serialize(g,m)}function resolveComponent(t,u,p,m){const y={};if(!m){t=parse(serialize(t,p),p);u=parse(serialize(u,p),p)}p=p||{};if(!p.tolerant&&u.scheme){y.scheme=u.scheme;y.userinfo=u.userinfo;y.host=u.host;y.port=u.port;y.path=g(u.path||"");y.query=u.query}else{if(u.userinfo!==undefined||u.host!==undefined||u.port!==undefined){y.userinfo=u.userinfo;y.host=u.host;y.port=u.port;y.path=g(u.path||"");y.query=u.query}else{if(!u.path){y.path=t.path;if(u.query!==undefined){y.query=u.query}else{y.query=t.query}}else{if(u.path[0]==="/"){y.path=g(u.path)}else{if((t.userinfo!==undefined||t.host!==undefined||t.port!==undefined)&&!t.path){y.path="/"+u.path}else if(!t.path){y.path=u.path}else{y.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+u.path}y.path=g(y.path)}y.query=u.query}y.userinfo=t.userinfo;y.host=t.host;y.port=t.port}y.scheme=t.scheme}y.fragment=u.fragment;return y}function equal(t,u,p){if(typeof t==="string"){t=unescape(t);t=serialize(v(parse(t,p),true),{...p,skipEscape:true})}else if(typeof t==="object"){t=serialize(v(t,true),{...p,skipEscape:true})}if(typeof u==="string"){u=unescape(u);u=serialize(v(parse(u,p),true),{...p,skipEscape:true})}else if(typeof u==="object"){u=serialize(v(u,true),{...p,skipEscape:true})}return t.toLowerCase()===u.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 v=[];const b=$(m.scheme||p.scheme);if(b&&b.serialize)b.serialize(p,m);if(p.path!==undefined){if(!m.skipEscape){p.path=escape(p.path);if(p.scheme!==undefined){p.path=p.path.split("%3A").join(":")}}else{p.path=unescape(p.path)}}if(m.reference!=="suffix"&&p.scheme){v.push(p.scheme,":")}const w=y(p);if(w!==undefined){if(m.reference!=="suffix"){v.push("//")}v.push(w);if(p.path&&p.path[0]!=="/"){v.push("/")}}if(p.path!==undefined){let t=p.path;if(!m.absolutePath&&(!b||!b.absolutePath)){t=g(t)}if(w===undefined&&t[0]==="/"&&t[1]==="/"){t="/%2F"+t.slice(2)}v.push(t)}if(p.query!==undefined){v.push("?",p.query)}if(p.fragment!==undefined){v.push("#",p.fragment)}return v.join("")}const P=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function parse(t,u){const p=Object.assign({},u);const g={scheme:undefined,userinfo:undefined,host:"",port:undefined,path:"",query:undefined,fragment:undefined};let y=false;if(p.reference==="suffix"){if(p.scheme){t=p.scheme+":"+t}else{t="//"+t}}const v=t.match(P);if(v){g.scheme=v[1];g.userinfo=v[3];g.host=v[4];g.port=parseInt(v[5],10);g.path=v[6]||"";g.query=v[7];g.fragment=v[8];if(isNaN(g.port)){g.port=v[5]}if(g.host){const t=b(g.host);if(t===false){const t=m(g.host);g.host=t.host.toLowerCase();y=t.isIPV6}else{y=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 u=$(p.scheme||g.scheme);if(!p.unicodeSupport&&(!u||!u.unicodeSupport)){if(g.host&&(p.domainHost||u&&u.domainHost)&&y===false&&w(g.host)){try{g.host=URL.domainToASCII(g.host.toLowerCase())}catch(t){g.error=g.error||"Host's domain name can not be converted to ASCII: "+t}}}if(!u||u&&!u.skipNormalize){if(t.indexOf("%")!==-1){if(g.scheme!==undefined){g.scheme=unescape(g.scheme)}if(g.host!==undefined){g.host=unescape(g.host)}}if(g.path){g.path=escape(unescape(g.path))}if(g.fragment){g.fragment=encodeURI(decodeURIComponent(g.fragment))}}if(u&&u.parse){u.parse(g,p)}}else{g.error=g.error||"URI can not be parsed."}return g}const A={SCHEMES:E,normalize:normalize,resolve:resolve,resolveComponent:resolveComponent,equal:equal,serialize:serialize,parse:parse};t.exports=A;t.exports["default"]=A;t.exports.fastUri=A},2424:(t,u,p)=>{"use strict";const{isUUID:m}=p(1097);const g=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;const y=["http","https","ws","wss","urn","urn:uuid"];function isValidSchemeName(t){return y.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 y=getSchemeHandler(g);t.path=undefined;if(y){t=y.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 y=getSchemeHandler(g);if(y){t=y.serialize(t,u)}const v=t;const b=t.nss;v.path=`${m||u.nid}:${b}`;u.skipEscape=true;return v}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 v={scheme:"http",domainHost:true,parse:httpParse,serialize:httpSerialize};const b={scheme:"https",domainHost:v.domainHost,parse:httpParse,serialize:httpSerialize};const w={scheme:"ws",domainHost:true,parse:wsParse,serialize:wsSerialize};const E={scheme:"wss",domainHost:w.domainHost,parse:w.parse,serialize:w.serialize};const $={scheme:"urn",parse:urnParse,serialize:urnSerialize,skipNormalize:true};const P={scheme:"urn:uuid",parse:urnuuidParse,serialize:urnuuidSerialize,skipNormalize:true};const A={http:v,https:b,ws:w,wss:E,urn:$,"urn:uuid":P};Object.setPrototypeOf(A,null);function getSchemeHandler(t){return t&&(A[t]||A[t.toLowerCase()])||undefined}t.exports={wsIsSecure:wsIsSecure,SCHEMES:A,isValidSchemeName:isValidSchemeName,getSchemeHandler:getSchemeHandler}},1097: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);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 m=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 y=false;let v=false;let b=consumeHextets;for(let w=0;w<t.length;w++){const E=t[w];if(E==="["||E==="]"){continue}if(E===":"){if(y===true){v=true}if(!b(g,m,p)){break}if(++u>7){p.error=true;break}if(w>0&&t[w-1]===":"){y=true}m.push(":");continue}else if(E==="%"){if(!b(g,m,p)){break}b=consumeIsZone}else{g.push(E);continue}}if(g.length){if(b===consumeIsZone){p.zone=g.join("")}else if(v){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("")}function normalizeComponentEncoding(t,u){const p=u!==true?escape:unescape;if(t.scheme!==undefined){t.scheme=p(t.scheme)}if(t.userinfo!==undefined){t.userinfo=p(t.userinfo)}if(t.host!==undefined){t.host=p(t.host)}if(t.path!==undefined){t.path=p(t.path)}if(t.query!==undefined){t.query=p(t.query)}if(t.fragment!==undefined){t.fragment=p(t.fragment)}return t}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 u=normalizeIPv6(m);if(u.isIPV6===true){m=`[${u.escapedHost}]`}else{m=t.host}}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:m,recomposeAuthority:recomposeAuthority,normalizeComponentEncoding:normalizeComponentEncoding,removeDotSegments:removeDotSegments,isIPv4:p,isUUID:u,normalizeIPv6:normalizeIPv6,stringArrayToHexStripped:stringArrayToHexStripped}},2200: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}')},5727: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"}}}}')},1447: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"}}}')},4877: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"}}}')},9041: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"}}}')},5118: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}}}')},8606: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"}}}')},3073: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":[]}}}')},1115: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}}}')},7578: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}')},7028:t=>{"use strict";t.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Alpic","constant":"ALPIC","env":"ALPIC_HOST"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE","pr":{"env":"AC_GIT_PR","ne":"false"}},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN","pr":{"env":"CODEBUILD_WEBHOOK_EVENT","any":["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{"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":"Cloudflare Pages","constant":"CLOUDFLARE_PAGES","env":"CF_PAGES"},{"name":"Cloudflare Workers","constant":"CLOUDFLARE_WORKERS","env":"WORKERS_CI"},{"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"}]')},6737:t=>{"use strict";t.exports=JSON.parse('["_http_agent","_http_client","_http_common","_http_incoming","_http_outgoing","_http_server","_stream_duplex","_stream_passthrough","_stream_readable","_stream_transform","_stream_wrap","_stream_writable","_tls_common","_tls_wrap","assert","assert/strict","async_hooks","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","dns/promises","domain","events","fs","fs/promises","http","http2","https","inspector","inspector/promises","module","net","os","path","path/posix","path/win32","perf_hooks","process","punycode","querystring","readline","readline/promises","repl","stream","stream/consumers","stream/promises","stream/web","string_decoder","sys","timers","timers/promises","tls","trace_events","tty","url","util","util/types","v8","vm","wasi","worker_threads","zlib","node:sea","node:sqlite","node:test","node:test/reporters"]')}};var u={};function __nccwpck_require__(p){var m=u[p];if(m!==undefined){return m.exports}var g=u[p]={exports:{}};var y=true;try{t[p](g,g.exports,__nccwpck_require__);y=false}finally{if(y)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 y={};u=u||[null,t({}),t([]),t(t)];for(var v=m&2&&p;typeof v=="object"&&!~u.indexOf(v);v=t(v)){Object.getOwnPropertyNames(v).forEach((t=>y[t]=()=>p[t]))}y["default"]=()=>p;__nccwpck_require__.d(g,y);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__(3024);var u=__nccwpck_require__(6760);var p=__nccwpck_require__.n(u);var m=__nccwpck_require__(4732);var g=__nccwpck_require__.n(m);var y=__nccwpck_require__(206);const{DM:v,gu:b,er:w,Ww:E,b7:$,Di:P,a2:A,uB:O,ef:R,c$:x,_V:T}=y;const k=require("node:util");var C=__nccwpck_require__(1708);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=>{if(!isObject(t)){return false}for(const u in t){if(Object.hasOwn(t,u)){return false}}return true};const D=new Set(["__proto__","prototype","constructor"]);const j=1e6;const isDigit=t=>t>="0"&&t<="9";function shouldCoerceToNumber(t){if(t==="0"){return true}if(/^[1-9]\d*$/.test(t)){const u=Number.parseInt(t,10);return u<=Number.MAX_SAFE_INTEGER&&u<=j}return false}function processSegment(t,u){if(D.has(t)){return false}if(t&&shouldCoerceToNumber(t)){u.push(Number.parseInt(t,10))}else{u.push(t)}return true}function parsePath(t){if(typeof t!=="string"){throw new TypeError(`Expected a string, got ${typeof t}`)}const u=[];let p="";let m="start";let g=false;let y=0;for(const v of t){y++;if(g){p+=v;g=false;continue}if(v==="\\"){if(m==="index"){throw new Error(`Invalid character '${v}' in an index at position ${y}`)}if(m==="indexEnd"){throw new Error(`Invalid character '${v}' after an index at position ${y}`)}g=true;m=m==="start"?"property":m;continue}switch(v){case".":{if(m==="index"){throw new Error(`Invalid character '${v}' in an index at position ${y}`)}if(m==="indexEnd"){m="property";break}if(!processSegment(p,u)){return[]}p="";m="property";break}case"[":{if(m==="index"){throw new Error(`Invalid character '${v}' in an index at position ${y}`)}if(m==="indexEnd"){m="index";break}if(m==="property"||m==="start"){if((p||m==="property")&&!processSegment(p,u)){return[]}p=""}m="index";break}case"]":{if(m==="index"){if(p===""){const t=u.pop()||"";p=t+"[]";m="property"}else{const t=Number.parseInt(p,10);const g=!Number.isNaN(t)&&Number.isFinite(t)&&t>=0&&t<=Number.MAX_SAFE_INTEGER&&t<=j&&p===String(t);if(g){u.push(t)}else{u.push(p)}p="";m="indexEnd"}break}if(m==="indexEnd"){throw new Error(`Invalid character '${v}' after an index at position ${y}`)}p+=v;break}default:{if(m==="index"&&!isDigit(v)){throw new Error(`Invalid character '${v}' in an index at position ${y}`)}if(m==="indexEnd"){throw new Error(`Invalid character '${v}' after an index at position ${y}`)}if(m==="start"){m="property"}p+=v}}}if(g){p+="\\"}switch(m){case"property":{if(!processSegment(p,u)){return[]}break}case"index":{throw new Error("Index was not closed")}case"start":{u.push("");break}}return u}function normalizePath(t){if(typeof t==="string"){return parsePath(t)}if(Array.isArray(t)){const u=[];for(const[p,m]of t.entries()){if(typeof m!=="string"&&typeof m!=="number"){throw new TypeError(`Expected a string or number for path segment at index ${p}, got ${typeof m}`)}if(typeof m==="number"&&!Number.isFinite(m)){throw new TypeError(`Path segment at index ${p} must be a finite number, got ${m}`)}if(D.has(m)){return[]}if(typeof m==="string"&&shouldCoerceToNumber(m)){u.push(Number.parseInt(m,10))}else{u.push(m)}}return u}return[]}function getProperty(t,u,p){if(!isObject(t)||typeof u!=="string"&&!Array.isArray(u)){return p===undefined?t:p}const m=normalizePath(u);if(m.length===0){return p}for(let u=0;u<m.length;u++){const g=m[u];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"&&!Array.isArray(u)){return t}const m=t;const g=normalizePath(u);if(g.length===0){return t}for(let u=0;u<g.length;u++){const m=g[u];if(u===g.length-1){t[m]=p}else if(!isObject(t[m])){const p=g[u+1];const y=typeof p==="number";t[m]=y?[]:{}}t=t[m]}return m}function deleteProperty(t,u){if(!isObject(t)||typeof u!=="string"&&!Array.isArray(u)){return false}const p=normalizePath(u);if(p.length===0){return false}for(let u=0;u<p.length;u++){const m=p[u];if(u===p.length-1){const u=Object.hasOwn(t,m);if(!u){return false}delete t[m];return true}t=t[m];if(!isObject(t)){return false}}}function hasProperty(t,u){if(!isObject(t)||typeof u!=="string"&&!Array.isArray(u)){return false}const p=normalizePath(u);if(p.length===0){return false}for(const u of p){if(!isObject(t)||!(u in t)){return false}t=t[u]}return true}function escapePath(t){if(typeof t!=="string"){throw new TypeError(`Expected a string, got ${typeof t}`)}return t.replaceAll(/[\\.[]/g,String.raw`\$&`)}function normalizeEntries(t){const u=Object.entries(t);if(Array.isArray(t)){return u.map((([t,u])=>{const p=shouldCoerceToNumber(t)?Number.parseInt(t,10):t;return[p,u]}))}return u}function stringifyPath(t,u={}){if(!Array.isArray(t)){throw new TypeError(`Expected an array, got ${typeof t}`)}const{preferDotForIndices:p=false}=u;const m=[];for(const[u,g]of t.entries()){if(typeof g!=="string"&&typeof g!=="number"){throw new TypeError(`Expected a string or number for path segment at index ${u}, got ${typeof g}`)}if(typeof g==="number"){if(!Number.isInteger(g)||g<0){const t=escapePath(String(g));m.push(u===0?t:`.${t}`)}else if(p&&u>0){m.push(`.${g}`)}else{m.push(`[${g}]`)}}else if(typeof g==="string"){if(g===""){if(u===0){}else{m.push(".")}}else if(shouldCoerceToNumber(g)){const t=Number.parseInt(g,10);if(p&&u>0){m.push(`.${t}`)}else{m.push(`[${t}]`)}}else{const t=escapePath(g);m.push(u===0?t:`.${t}`)}}}return m.join("")}function*deepKeysIterator(t,u=[],p=new Set){if(!isObject(t)||isEmptyObject(t)){if(u.length>0){yield stringifyPath(u)}return}if(p.has(t)){return}p.add(t);for(const[m,g]of normalizeEntries(t)){u.push(m);yield*deepKeysIterator(g,u,p);u.pop()}p.delete(t)}function deepKeys(t){return[...deepKeysIterator(t)]}function unflatten(t){const u={};if(!isObject(t)){return u}for(const[p,m]of Object.entries(t)){setProperty(u,p,m)}return u}const L=require("node:os");var M=__nccwpck_require__.n(L);const U=L.homedir();const B=L.tmpdir();const{env:H}=C;const macos=t=>{const p=u.join(U,"Library");return{data:u.join(p,"Application Support",t),config:u.join(p,"Preferences",t),cache:u.join(p,"Caches",t),log:u.join(p,"Logs",t),temp:u.join(B,t)}};const windows=t=>{const p=H.APPDATA||u.join(U,"AppData","Roaming");const m=H.LOCALAPPDATA||u.join(U,"AppData","Local");return{data:u.join(m,t,"Data"),config:u.join(p,t,"Config"),cache:u.join(m,t,"Cache"),log:u.join(m,t,"Log"),temp:u.join(B,t)}};const linux=t=>{const p=u.basename(U);return{data:u.join(H.XDG_DATA_HOME||u.join(U,".local","share"),t),config:u.join(H.XDG_CONFIG_HOME||u.join(U,".config"),t),cache:u.join(H.XDG_CACHE_HOME||u.join(U,".cache"),t),log:u.join(H.XDG_STATE_HOME||u.join(U,".local","state"),t),temp:u.join(B,p,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(C.platform==="darwin"){return macos(t)}if(C.platform==="win32"){return windows(t)}return linux(t)}var V=__nccwpck_require__(8474);const z=require("node:stream");const attemptifyAsync=(t,u)=>{const{onError:p}=u;return function attemptified(...u){return t.apply(undefined,u).catch(p)}};const G=attemptifyAsync;const attemptifySync=(t,u)=>{const{onError:p}=u;return function attemptified(...u){try{return t.apply(undefined,u)}catch(t){return p(t)}}};const W=attemptifySync;const q=250;const retryifyAsync=(t,u)=>{const{isRetriable:p}=u;return function retryified(u){const{timeout:m}=u;const g=u.interval??q;const y=Date.now()+m;return function attempt(...u){return t.apply(undefined,u).catch((t=>{if(!p(t))throw t;if(Date.now()>=y)throw t;const m=Math.round(g*Math.random());if(m>0){const t=new Promise((t=>setTimeout(t,m)));return t.then((()=>attempt.apply(undefined,u)))}else{return attempt.apply(undefined,u)}}))}}};const Y=retryifyAsync;const retryifySync=(t,u)=>{const{isRetriable:p}=u;return function retryified(u){const{timeout:m}=u;const g=Date.now()+m;return function attempt(...u){while(true){try{return t.apply(undefined,u)}catch(t){if(!p(t))throw t;if(Date.now()>=g)throw t;continue}}}}};const J=retryifySync;const Z={isChangeErrorOk:t=>{if(!Z.isNodeError(t))return false;const{code:u}=t;if(u==="ENOSYS")return true;if(!se&&(u==="EINVAL"||u==="EPERM"))return true;return false},isNodeError:t=>t instanceof Error,isRetriableError:t=>{if(!Z.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(!Z.isNodeError(t))throw t;if(Z.isChangeErrorOk(t))return;throw t}};const X=Z;const Q={onError:X.onChangeError};const ee={onError:()=>undefined};const se=C.getuid?!C.getuid():false;const ie={isRetriable:X.isRetriableError};const ne={attempt:{chmod:G((0,k.promisify)(t.chmod),Q),chown:G((0,k.promisify)(t.chown),Q),close:G((0,k.promisify)(t.close),ee),fsync:G((0,k.promisify)(t.fsync),ee),mkdir:G((0,k.promisify)(t.mkdir),ee),realpath:G((0,k.promisify)(t.realpath),ee),stat:G((0,k.promisify)(t.stat),ee),unlink:G((0,k.promisify)(t.unlink),ee),chmodSync:W(t.chmodSync,Q),chownSync:W(t.chownSync,Q),closeSync:W(t.closeSync,ee),existsSync:W(t.existsSync,ee),fsyncSync:W(t.fsync,ee),mkdirSync:W(t.mkdirSync,ee),realpathSync:W(t.realpathSync,ee),statSync:W(t.statSync,ee),unlinkSync:W(t.unlinkSync,ee)},retry:{close:Y((0,k.promisify)(t.close),ie),fsync:Y((0,k.promisify)(t.fsync),ie),open:Y((0,k.promisify)(t.open),ie),readFile:Y((0,k.promisify)(t.readFile),ie),rename:Y((0,k.promisify)(t.rename),ie),stat:Y((0,k.promisify)(t.stat),ie),write:Y((0,k.promisify)(t.write),ie),writeFile:Y((0,k.promisify)(t.writeFile),ie),closeSync:J(t.closeSync,ie),fsyncSync:J(t.fsyncSync,ie),openSync:J(t.openSync,ie),readFileSync:J(t.readFileSync,ie),renameSync:J(t.renameSync,ie),statSync:J(t.statSync,ie),writeSync:J(t.writeSync,ie),writeFileSync:J(t.writeFileSync,ie)}};const ae=ne;const le="utf8";const ue=438;const he=511;const de={};const fe={};const pe=C.geteuid?C.geteuid():-1;const me=C.getegid?C.getegid():-1;const ge=200;const ye=7500;const ve=1e3;const _e=!!C.getuid;const be=C.getuid?!C.getuid():false;const we=128;const 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 Ee={};const $e={next:t=>{const u=Ee[t];if(!u)return;u.shift();const p=u[0];if(p){p((()=>$e.next(t)))}else{delete Ee[t]}},schedule:t=>new Promise((u=>{let p=Ee[t];if(!p)p=Ee[t]=[];p.push(u);if(p.length>1)return;u((()=>$e.next(t)))}))};const Pe=null&&$e;const Ae=C.platform==="linux";const Oe=C.platform==="win32";const Re=["SIGHUP","SIGINT","SIGTERM"];if(!Oe){Re.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT")}if(Ae){Re.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")}const xe=Re;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(Oe&&(t!=="SIGINT"&&t!=="SIGTERM"&&t!=="SIGKILL")){C.kill(C.pid,"SIGTERM")}else{C.kill(C.pid,t)}}};this.hook=()=>{C.once("exit",(()=>this.exit()));for(const t of xe){try{C.once(t,(()=>this.exit(t)))}catch{}}};this.register=t=>{this.callbacks.add(t);return()=>{this.callbacks.delete(t)}};this.hook()}}const Te=new Interceptor;const ke=Te.register;const Ce=ke;const Ie={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 y=`${t}${g}`;return y},get:(t,u,p=true)=>{const m=Ie.truncate(u(t));if(m in Ie.store)return Ie.get(t,u,p);Ie.store[m]=p;const disposer=()=>delete Ie.store[m];return[m,disposer]},purge:t=>{if(!Ie.store[t])return;delete Ie.store[t];ae.attempt.unlink(t)},purgeSync:t=>{if(!Ie.store[t])return;delete Ie.store[t];ae.attempt.unlinkSync(t)},purgeSyncAll:()=>{for(const t in Ie.store){Ie.purgeSync(t)}},truncate:t=>{const p=u.basename(t);if(p.length<=we)return t;const m=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(p);if(!m)return t;const g=p.length-we;return`${t.slice(0,-p.length)}${m[1]}${m[2].slice(0,-g)}${m[3]}`}};Ce(Ie.purgeSyncAll);const Ne=Ie;function dist_readFile(t,u=DEFAULT_READ_OPTIONS){if(isString(u))return dist_readFile(t,{encoding:u});const p=u.timeout??DEFAULT_TIMEOUT_ASYNC;const m={timeout:p,interval:DEFAULT_INTERVAL_ASYNC};return fs.retry.readFile(m)(t,u)}function readFileSync(t,u=DEFAULT_READ_OPTIONS){if(isString(u))return readFileSync(t,{encoding:u});const p=u.timeout??DEFAULT_TIMEOUT_SYNC;const m={timeout:p};return fs.retry.readFileSync(m)(t,u)}function dist_writeFile(t,u,p,m){if(isFunction(p))return dist_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=p.timeout??DEFAULT_TIMEOUT_ASYNC;const g={timeout:m,interval:DEFAULT_INTERVAL_ASYNC};let y=null;let v=null;let b=null;let w=null;let E=null;try{if(p.schedule)y=await p.schedule(t);v=await Scheduler.schedule(t);const m=await fs.attempt.realpath(t);const $=!!m;t=m||t;[w,b]=Temp.get(t,p.tmpCreate||Temp.create,!(p.tmpPurge===false));const P=IS_POSIX&&isUndefined(p.chown);const A=isUndefined(p.mode);if($&&(P||A)){const u=await fs.attempt.stat(t);if(u){p={...p};if(P){p.chown={uid:u.uid,gid:u.gid}}if(A){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(g)(w,"w",p.mode||DEFAULT_FILE_MODE);if(p.tmpCreated){p.tmpCreated(w)}if(isString(u)){await fs.retry.write(g)(E,u,0,p.encoding||DEFAULT_ENCODING)}else if(u instanceof Readable){const t=createWriteStream(w,{fd:E,autoClose:false});const p=once(t,"finish");u.pipe(t);await p}else if(!isUndefined(u)){await fs.retry.write(g)(E,u,0,u.length,0)}if(p.fsync!==false){if(p.fsyncWait!==false){await fs.retry.fsync(g)(E)}else{fs.attempt.fsync(E)}}await fs.retry.close(g)(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(g)(w,t)}catch(u){if(!isException(u))throw u;if(u.code!=="ENAMETOOLONG")throw u;await fs.retry.rename(g)(w,Temp.truncate(t))}b();w=null}finally{if(E)await fs.attempt.close(E);if(w)Temp.purge(w);if(y)y();if(v)v()}}function writeFileSync(t,p,m=fe){if(lang_isString(m))return writeFileSync(t,p,{encoding:m});const g=m.timeout??ve;const y={timeout:g};let v=null;let b=null;let w=null;try{const g=ae.attempt.realpathSync(t);const E=!!g;t=g||t;[b,v]=Ne.get(t,m.tmpCreate||Ne.create,!(m.tmpPurge===false));const $=_e&&lang_isUndefined(m.chown);const P=lang_isUndefined(m.mode);if(E&&($||P)){const u=ae.attempt.statSync(t);if(u){m={...m};if($){m.chown={uid:u.uid,gid:u.gid}}if(P){m.mode=u.mode}}}if(!E){const p=u.dirname(t);ae.attempt.mkdirSync(p,{mode:he,recursive:true})}w=ae.retry.openSync(y)(b,"w",m.mode||ue);if(m.tmpCreated){m.tmpCreated(b)}if(lang_isString(p)){ae.retry.writeSync(y)(w,p,0,m.encoding||le)}else if(!lang_isUndefined(p)){ae.retry.writeSync(y)(w,p,0,p.length,0)}if(m.fsync!==false){if(m.fsyncWait!==false){ae.retry.fsyncSync(y)(w)}else{ae.attempt.fsync(w)}}ae.retry.closeSync(y)(w);w=null;if(m.chown&&(m.chown.uid!==pe||m.chown.gid!==me)){ae.attempt.chownSync(b,m.chown.uid,m.chown.gid)}if(m.mode&&m.mode!==ue){ae.attempt.chmodSync(b,m.mode)}try{ae.retry.renameSync(y)(b,t)}catch(u){if(!lang_isException(u))throw u;if(u.code!=="ENAMETOOLONG")throw u;ae.retry.renameSync(y)(b,Ne.truncate(t))}v();b=null}finally{if(w)ae.attempt.closeSync(w);if(b)Ne.purge(b)}}var De=__nccwpck_require__(8861);var je=__nccwpck_require__(8631);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 y=Object.getOwnPropertyDescriptor(u,p);if(!canCopyProperty(g,y)&&m){return}Object.defineProperty(t,p,y)};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 Le=Object.getOwnPropertyDescriptor(Function.prototype,"toString");const Me=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",Me);const{writable:y,enumerable:v,configurable:b}=Le;Object.defineProperty(t,"toString",{value:g,writable:y,enumerable:v,configurable:b})};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:y=true}=u;if(p<0||m<0){throw new RangeError("`wait` and `maxWait` must not be negative.")}if(!g&&!y){throw new Error("Both `before` and `after` are false, function wouldn't be called.")}let v;let b;let w;const debouncedFunction=function(...u){const E=this;const later=()=>{v=undefined;if(b){clearTimeout(b);b=undefined}if(y){w=t.apply(E,u)}};const maxLater=()=>{b=undefined;if(v){clearTimeout(v);v=undefined}if(y){w=t.apply(E,u)}};const $=g&&!v;clearTimeout(v);v=setTimeout(later,p);if(m>0&&m!==Number.POSITIVE_INFINITY&&!b){b=setTimeout(maxLater,m)}if($){w=t.apply(E,u)}return w};mimicFunction(debouncedFunction,t);debouncedFunction.cancel=()=>{if(v){clearTimeout(v);v=undefined}if(b){clearTimeout(b);b=undefined}};return debouncedFunction};const Fe=debounceFunction;var Ue=__nccwpck_require__(4423);const Be=Object.prototype.toString;const He="[object Uint8Array]";const Ve="[object ArrayBuffer]";function isType(t,u,p){if(!t){return false}if(t.constructor===u){return true}return Be.call(t)===p}function isUint8Array(t){return isType(t,Uint8Array,He)}function isArrayBuffer(t){return isType(t,ArrayBuffer,Ve)}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 ze={utf8:new globalThis.TextDecoder("utf8")};function uint8ArrayToString(t,u="utf8"){assertUint8ArrayOrArrayBuffer(t);ze[u]??=new globalThis.TextDecoder(u);return ze[u].decode(t)}function assertString(t){if(typeof t!=="string"){throw new TypeError(`Expected \`string\`, got \`${typeof t}\``)}}const Ge=new globalThis.TextEncoder;function stringToUint8Array(t){assertString(t);return Ge.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 We=65535;function uint8ArrayToBase64(t,{urlSafe:u=false}={}){assertUint8Array(t);let p="";for(let u=0;u<t.length;u+=We){const m=t.subarray(u,u+We);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 qe=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+=qe[t[p]]}return u}const Ke={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=Ke[t[m*2]];const g=Ke[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 y=0;y<m;y++){if(t[p+y]!==u[y]){g=false;break}}if(g){return p}}return-1}function includes(t,u){return indexOf(t,u)!==-1}const Ye="aes-256-cbc";const Je=new Set(["aes-256-cbc","aes-256-gcm","aes-256-ctr"]);const isSupportedEncryptionAlgorithm=t=>typeof t==="string"&&Je.has(t);const createPlainObject=()=>Object.create(null);const isExist=t=>t!==undefined;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 Ze="__internal__";const Xe=`${Ze}.migrations.version`;class Conf{path;events;#e;#t;#r;#s;#i={};#n=false;#o;#a;#c;constructor(t={}){const u=this.#l(t);this.#s=u;this.#u(u);this.#h(u);this.#d(u);this.events=new EventTarget;this.#t=u.encryptionKey;this.#r=u.encryptionAlgorithm??Ye;this.path=this.#f(u);this.#p(u);if(u.watch){this._watch()}}get(t,u){if(this.#s.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 ${Ze} key, as it's used to manage this module internal operations.`)}const{store:p}=this;const set=(t,u)=>{checkValueType(t,u);if(this.#s.accessPropertiesByDotNotation){setProperty(p,t,u)}else{if(t==="__proto__"||t==="constructor"||t==="prototype"){return}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.#s.accessPropertiesByDotNotation){return hasProperty(this.store,t)}return t in this.store}appendToArray(t,u){checkValueType(t,u);const p=this.#s.accessPropertiesByDotNotation?this._get(t,[]):t in this.store?this.store[t]:[];if(!Array.isArray(p)){throw new TypeError(`The key \`${t}\` is already set to a non-array value`)}this.set(t,[...p,u])}reset(...t){for(const u of t){if(isExist(this.#i[u])){this.set(u,this.#i[u])}}}delete(t){const{store:u}=this;if(this.#s.accessPropertiesByDotNotation){deleteProperty(u,t)}else{delete u[t]}this.store=u}clear(){const t=createPlainObject();for(const u of Object.keys(this.#i)){if(isExist(this.#i[u])){checkValueType(u,this.#i[u]);if(this.#s.accessPropertiesByDotNotation){setProperty(t,u,this.#i[u])}else{t[u]=this.#i[u]}}}this.store=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._handleValueChange((()=>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._handleStoreChange(t)}get size(){const t=Object.keys(this.store);return t.filter((t=>!this._isReservedKeyPath(t))).length}get store(){try{const u=t.readFileSync(this.path,this.#t?null:"utf8");const p=this._decryptData(u);const parseStore=t=>{const u=this._deserialize(t);if(!this.#n){this._validate(u)}return Object.assign(createPlainObject(),u)};return parseStore(p)}catch(t){if(t?.code==="ENOENT"){this._ensureDirectory();return createPlainObject()}if(this.#s.clearInvalidConfig){const u=t;if(u.name==="SyntaxError"){return createPlainObject()}if(u.message?.startsWith("Config schema violation:")){return createPlainObject()}if(u.message==="Failed to decrypt config data."){return createPlainObject()}}throw t}}set store(u){this._ensureDirectory();if(!hasProperty(u,Ze)){try{const p=t.readFileSync(this.path,this.#t?null:"utf8");const m=this._decryptData(p);const g=this._deserialize(m);if(hasProperty(g,Ze)){setProperty(u,Ze,getProperty(g,Ze))}}catch{}}if(!this.#n){this._validate(u)}this._write(u);this.events.dispatchEvent(new Event("change"))}*[Symbol.iterator](){for(const[t,u]of Object.entries(this.store)){if(!this._isReservedKeyPath(t)){yield[t,u]}}}_closeWatcher(){if(this.#o){this.#o.close();this.#o=undefined}if(this.#a){t.unwatchFile(this.path);this.#a=false}this.#c=undefined}_decryptData(t){const u=this.#t;if(!u){return typeof t==="string"?t:uint8ArrayToString(t)}const p=this.#r;const m=p==="aes-256-gcm"?16:0;const g=":".codePointAt(0);const y=typeof t==="string"?t.codePointAt(16):t[16];const v=g!==undefined&&y===g;if(!v){if(p==="aes-256-cbc"){return typeof t==="string"?t:uint8ArrayToString(t)}throw new Error("Failed to decrypt config data.")}const getEncryptedPayload=t=>{if(m===0){return{ciphertext:t}}const u=t.length-m;if(u<0){throw new Error("Invalid authentication tag length.")}return{ciphertext:t.slice(0,u),authenticationTag:t.slice(u)}};const b=t.slice(0,16);const w=t.slice(17);const E=typeof w==="string"?stringToUint8Array(w):w;const decrypt=t=>{const{ciphertext:m,authenticationTag:g}=getEncryptedPayload(E);const y=I.pbkdf2Sync(u,t,1e4,32,"sha512");const v=I.createDecipheriv(p,y,b);if(g){v.setAuthTag(g)}return uint8ArrayToString(concatUint8Arrays([v.update(m),v.final()]))};try{return decrypt(b)}catch{try{return decrypt(b.toString())}catch{}}if(p==="aes-256-cbc"){return typeof t==="string"?t:uint8ArrayToString(t)}throw new Error("Failed to decrypt config data.")}_handleStoreChange(t){let u=this.store;const onChange=()=>{const p=u;const m=this.store;if((0,k.isDeepStrictEqual)(m,p)){return}u=m;t.call(this,m,p)};this.events.addEventListener("change",onChange);return()=>{this.events.removeEventListener("change",onChange)}}_handleValueChange(t,u){let p=t();const onChange=()=>{const m=p;const g=t();if((0,k.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(){t.mkdirSync(u.dirname(this.path),{recursive:true})}_write(u){let p=this._serialize(u);const m=this.#t;if(m){const t=I.randomBytes(16);const u=I.pbkdf2Sync(m,t,1e4,32,"sha512");const g=I.createCipheriv(this.#r,u,t);const y=concatUint8Arrays([g.update(stringToUint8Array(p)),g.final()]);const v=[t,stringToUint8Array(":"),y];if(this.#r==="aes-256-gcm"){v.push(g.getAuthTag())}p=concatUint8Arrays(v)}if(C.env.SNAP){t.writeFileSync(this.path,p,{mode:this.#s.configFileMode})}else{try{writeFileSync(this.path,p,{mode:this.#s.configFileMode})}catch(u){if(u?.code==="EXDEV"){t.writeFileSync(this.path,p,{mode:this.#s.configFileMode});return}throw u}}}_watch(){this._ensureDirectory();if(!t.existsSync(this.path)){this._write(createPlainObject())}if(C.platform==="win32"||C.platform==="darwin"){this.#c??=Fe((()=>{this.events.dispatchEvent(new Event("change"))}),{wait:100});const p=u.dirname(this.path);const m=u.basename(this.path);this.#o=t.watch(p,{persistent:false,encoding:"utf8"},((t,u)=>{if(u&&u!==m){return}if(typeof this.#c==="function"){this.#c()}}))}else{this.#c??=Fe((()=>{this.events.dispatchEvent(new Event("change"))}),{wait:1e3});t.watchFile(this.path,{persistent:false},((t,u)=>{if(typeof this.#c==="function"){this.#c()}}));this.#a=true}}_migrate(t,u,p){let m=this._get(Xe,"0.0.0");const g=Object.keys(t).filter((t=>this._shouldPerformMigration(t,m,u)));let y=structuredClone(this.store);for(const v of g){try{if(p){p(this,{fromVersion:m,toVersion:v,finalVersion:u,versions:g})}const b=t[v];b?.(this);this._set(Xe,v);m=v;y=structuredClone(this.store)}catch(t){this.store=y;const u=t instanceof Error?t.message:String(t);throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${u}`)}}if(this._isVersionInRangeFormat(m)||!Ue.eq(m,u)){this._set(Xe,u)}}_containsReservedKey(t){if(typeof t==="string"){return this._isReservedKeyPath(t)}if(!t||typeof t!=="object"){return false}return this._objectContainsReservedKey(t)}_objectContainsReservedKey(t){if(!t||typeof t!=="object"){return false}for(const[u,p]of Object.entries(t)){if(this._isReservedKeyPath(u)){return true}if(this._objectContainsReservedKey(p)){return true}}return false}_isReservedKeyPath(t){return t===Ze||t.startsWith(`${Ze}.`)}_isVersionInRangeFormat(t){return Ue.clean(t)===null}_shouldPerformMigration(t,u,p){if(this._isVersionInRangeFormat(t)){if(u!=="0.0.0"&&Ue.satisfies(u,t)){return false}return Ue.satisfies(p,t)}if(Ue.lte(t,u)){return false}if(Ue.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}#l(t){const u={configName:"config",fileExtension:"json",projectSuffix:"nodejs",clearInvalidConfig:false,accessPropertiesByDotNotation:true,configFileMode:438,...t};u.encryptionAlgorithm??=Ye;if(!isSupportedEncryptionAlgorithm(u.encryptionAlgorithm)){throw new TypeError(`The \`encryptionAlgorithm\` option must be one of: ${[...Je].join(", ")}`)}if(!u.cwd){if(!u.projectName){throw new Error("Please specify the `projectName` option.")}u.cwd=envPaths(u.projectName,{suffix:u.projectSuffix}).config}if(typeof u.fileExtension==="string"){u.fileExtension=u.fileExtension.replace(/^\.+/,"")}return u}#u(t){if(!(t.schema??t.ajvOptions??t.rootSchema)){return}if(t.schema&&typeof t.schema!=="object"){throw new TypeError("The `schema` option must be an object.")}const u=je["default"];const p=new De.Ajv2020({allErrors:true,useDefaults:true,...t.ajvOptions});u(p);const m={...t.rootSchema,type:"object",properties:t.schema};this.#e=p.compile(m);this.#m(t.schema)}#m(t){const u=Object.entries(t??{});for(const[t,p]of u){if(!p||typeof p!=="object"){continue}if(!Object.hasOwn(p,"default")){continue}const{default:u}=p;if(u===undefined){continue}this.#i[t]=u}}#h(t){if(t.defaults){Object.assign(this.#i,t.defaults)}}#d(t){if(t.serialize){this._serialize=t.serialize}if(t.deserialize){this._deserialize=t.deserialize}}#f(t){const p=typeof t.fileExtension==="string"?t.fileExtension:undefined;const m=p?`.${p}`:"";return u.resolve(t.cwd,`${t.configName??"config"}${m}`)}#p(t){if(t.migrations){this.#g(t);this._validate(this.store);return}const u=this.store;const p=Object.assign(createPlainObject(),t.defaults??{},u);this._validate(p);try{N.deepEqual(u,p)}catch{this.store=p}}#g(t){const{migrations:u,projectVersion:p}=t;if(!u){return}if(!p){throw new Error("Please specify the `projectVersion` option.")}this.#n=true;try{const m=this.store;const g=Object.assign(createPlainObject(),t.defaults??{},m);try{N.deepEqual(m,g)}catch{this._write(g)}this._migrate(u,p,t.beforeEachMigration)}finally{this.#n=false}}}var Qe=__nccwpck_require__(9212);var et=__nccwpck_require__(6133);var tt=__nccwpck_require__.n(et);var rt=__nccwpck_require__(5059);var st=__nccwpck_require__.n(rt);var it=__nccwpck_require__(9642);var nt=__nccwpck_require__.n(it);const ot=require("node:fs/promises");var ct=__nccwpck_require__.n(ot);const ut="apitogo.config.json";const ht="Documentation";const dt="/api";const ft="API Reference";function isPlainObject(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}function deepMerge(t,u){const p={...t};for(const[t,m]of Object.entries(u)){const u=p[t];if(isPlainObject(u)&&isPlainObject(m)){p[t]=deepMerge(u,m)}else{p[t]=m}}return p}function parseJsonObjectFlag(t,u){if(t===undefined||t.trim()===""){return undefined}let p;try{p=JSON.parse(t)}catch{throw new Error(`--${u} must be a JSON object.`)}if(!isPlainObject(p)){throw new Error(`--${u} must be a JSON object.`)}return p}function titleFromDirectoryName(t){const u=t.split(/[-_\s]+/).filter(Boolean).map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join(" ");return u||"Developer Portal"}function createDefaultApitogoJsonConfig(t){const u=`/${t.pagesDir}/**/*.{md,mdx}`;return{site:{title:t.title,showTitleInHeader:false,logo:{src:{...DEFAULT_SITE_LOGO.src}}},authentication:{enabled:true,type:"dev-portal",redirectToAfterSignIn:"/account/dashboard",redirectToAfterSignUp:"/account/dashboard"},metadata:{favicon:"/Icon.png"},theme:{fonts:{sans:"Inter",mono:"JetBrains Mono"},light:{background:"#ffffff",foreground:"#252b3b",card:"#ffffff",cardForeground:"#252b3b",primary:"#0d9488",primaryForeground:"#ffffff",secondary:"#f4f6fb",secondaryForeground:"#252b3b",muted:"#e9edf5",mutedForeground:"rgba(37, 43, 59, 0.55)",accent:"rgba(13, 148, 136, 0.1)",accentForeground:"#0d9488",border:"#d9deea",input:"#d9deea",ring:"#0d9488"},dark:{background:"#252b3b",foreground:"#e9edf5",card:"#2b3243",cardForeground:"#e9edf5",primary:"#0d9488",primaryForeground:"#ffffff",secondary:"#1e2330",secondaryForeground:"#e9edf5",muted:"#1e2330",mutedForeground:"rgba(217, 222, 234, 0.58)",accent:"rgba(13, 148, 136, 0.12)",accentForeground:"#0d9488",border:"rgba(217, 222, 234, 0.18)",input:"#323a4f",ring:"#0d9488"}},header:{placements:{navigation:"center"},navigation:[{label:"Product",to:"/#features"},{label:"Pricing",to:"/pricing"},{label:"Docs",to:"/introduction"}]},modules:{docs:{files:u},landing:{enabled:true,path:"/",layout:"landing",page:"./landing/LandingPage.tsx",content:{footer:{brand:{name:"SampleAPI",tagline:"A hosted sandbox API for prototypes, demos, and QA — realistic data, real auth, real limits."},columns:[{title:"Product",links:[{label:"Overview",href:"/#features"},{label:"Pricing",href:"/pricing"},{label:"Documentation",href:"/introduction"}]},{title:"Account",links:[{label:"Log in",href:"/signin"},{label:"Get started",href:"/signup"},{label:"Dashboard",href:"/account/dashboard"}]},{title:"Company",links:[{label:"Contact",href:"#"},{label:"Terms",href:"#"},{label:"Privacy",href:"#"}]}],copyright:"© 2026 Sample API"}}},userPanel:{enabled:true,dashboard:{enabled:true,page:"./user-panel/DashboardPage.tsx"},userManagement:{enabled:true},plans:{enabled:true,page:"./user-panel/AccountPlansPage.tsx",items:[{sku:"free",displayName:"Free",priceAmount:0,billingPeriod:"month",limits:{rateLimit:{calls:1,renewalPeriodSeconds:60},quota:{calls:1e3,renewalPeriodDays:30}}},{sku:"developer",displayName:"Developer",priceAmount:19,billingPeriod:"month",limits:{rateLimit:{calls:2,renewalPeriodSeconds:60},quota:{calls:5e3,renewalPeriodDays:30}}},{sku:"team",displayName:"Team",priceAmount:79,billingPeriod:"month",limits:{rateLimit:{calls:60,renewalPeriodSeconds:60},quota:{calls:1e4,renewalPeriodDays:30}}},{sku:"enterprise",displayName:"Enterprise",pricingModel:"custom",priceLabel:"Let's talk",billingPeriod:"month"}]}}}}}function applyConfigPatches(t,u){var p;const m={...t};if(u.site){m.site=deepMerge(isPlainObject(m.site)?m.site:{},u.site)}if(u.theme){m.theme=deepMerge(isPlainObject(m.theme)?m.theme:{},u.theme)}if(u.authentication){m.authentication=deepMerge(isPlainObject(m.authentication)?m.authentication:{},u.authentication)}if((p=u.title)===null||p===void 0?void 0:p.trim()){const t=isPlainObject(m.site)?m.site:{};m.site={...t,title:u.title.trim()}}return m}const docSortRank=t=>{var u;const p=(u=t.split("/").at(-1))!==null&&u!==void 0?u:t;if(p==="introduction")return 0;if(p==="example")return 1;if(p==="getting-started")return 2;if(p==="index")return 3;return 4};const sortDocPaths=t=>[...t].sort(((t,u)=>{const p=docSortRank(t)-docSortRank(u);if(p!==0)return p;return t.localeCompare(u)}));const createTreeNode=()=>({docs:[],children:new Map});const titleCase=t=>t.split(/[-_\s]+/).filter(Boolean).map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join(" ");const buildTree=t=>{const u=createTreeNode();for(const p of t){const t=p.replace(/^\//,"").split("/").filter(Boolean);const m=t.slice(0,-1);let g=u;for(const t of m){let u=g.children.get(t);if(!u){u=createTreeNode();g.children.set(t,u)}g=u}g.docs.push(p)}return u};const treeToNavigationItems=t=>{const u=sortDocPaths(t.docs);const p=[...t.children.keys()].sort(((t,u)=>t.localeCompare(u))).map((u=>{const p=t.children.get(u);if(!p){throw new Error(`Missing child node for directory '${u}'.`)}return{type:"category",label:titleCase(u),items:treeToNavigationItems(p)}}));return[...u,...p]};function buildDocumentationItems(t){return treeToNavigationItems(buildTree(sortDocPaths([...new Set(t)])))}function navItemKey(t){if(typeof t==="string"){return`path:${t}`}if(typeof t.to==="string"){return`to:${t.to}`}if(typeof t.path==="string"){return`path:${t.path}`}if(t.type==="category"&&typeof t.label==="string"){return`category:${t.label}`}return JSON.stringify(t)}function normalizeDocRoute(t){const u=t.trim().replace(/^\.?\/+/,"").replace(/\.mdx?$/i,"").replace(/(^|\/)index$/,"");return`/${u}`}function docRoutesOf(t){if(typeof t==="string")return[normalizeDocRoute(t)];if(!isRecord(t))return[];if(t.type==="doc"){return[t.file,t.path].filter((t=>typeof t==="string")).map(normalizeDocRoute)}if(t.type==="link"&&typeof t.to==="string"){return t.to.startsWith("/")?[normalizeDocRoute(t.to)]:[]}if(t.type==="category"){return[...docRoutesOf(t.link),...Array.isArray(t.items)?t.items.flatMap(docRoutesOf):[]]}return[]}function collectNavigationDocRoutes(t){return new Set(Array.isArray(t)?t.flatMap(docRoutesOf):[])}function pruneKnownDocs(t,u){return t.flatMap((t=>{if(typeof t==="string"){return u.has(normalizeDocRoute(t))?[]:[t]}if(t.type!=="category"||!Array.isArray(t.items))return[t];const p=pruneKnownDocs(t.items,u);return p.length>0?[{...t,items:p}]:[]}))}function mergeNavItems(t,u){const p=[...t];for(const t of u){const u=navItemKey(t);const m=p.findIndex((t=>navItemKey(t)===u));if(m===-1){p.push(t);continue}const g=p[m];if(isRecord(g)&&isRecord(t)&&g.type==="category"&&t.type==="category"){p[m]={...g,items:mergeNavItems(Array.isArray(g.items)?g.items:[],Array.isArray(t.items)?t.items:[])}}}return p}function isRecord(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}function isDocumentationCategory(t){return typeof t==="object"&&t.type==="category"&&t.label===ht}function isApiReferenceLink(t){return typeof t==="object"&&t.type==="link"&&t.to===dt}function mergeDocumentationNavigation(t,u,p){const m=Array.isArray(t)?t:[];const g=buildDocumentationItems(u);const y=m.filter((t=>!isDocumentationCategory(t)));const v=m.find(isDocumentationCategory);const b=Array.isArray(v===null||v===void 0?void 0:v.items)?v.items:[];const w=p.force?g:mergeNavItems(b,pruneKnownDocs(g,collectNavigationDocRoutes(m)));const E={...v,type:"category",label:ht,items:w};if(g.length===0||!v&&w.length===0){return m}if(v){const t=m.findIndex(isDocumentationCategory);const u=[...m];u[t]=E;return u}return[E,...y]}function applyOpenApiToJsonConfig(t,u){const p={...t};p.apis=[{type:"file",input:u,path:"api"}];const m=Array.isArray(p.navigation)?[...p.navigation]:[];if(!m.some(isApiReferenceLink)){m.push({type:"link",to:dt,label:ft})}p.navigation=m;return ensureHeaderApiReferenceNavigation(p,dt,ft)}function openapiInputForConfig(t){if(t.startsWith("./")){return t}return`./${t}`}function toRelativeOpenApiInput(t,u){const p=path.isAbsolute(u)?u:path.resolve(t,u);const m=path.relative(t,p);const g=m.split(path.sep).join(path.posix.sep);if(!g){throw new Error("OpenAPI path must point to a file.")}return openapiInputForConfig(g)}function normalizePageSlug(t){return t.replace(/^\/+/,"").replace(/\/+$/,"").replace(/\.(mdx?|tsx|jsx)$/i,"")}function slugifyPlanSku(t){const u=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return u||"plan"}function buildLimits(t,u){return{rateLimit:{calls:t,renewalPeriodSeconds:60},quota:{calls:u,renewalPeriodDays:30}}}function buildPlanItemFromWizard(t){var u;const p=(u=t.sku)!==null&&u!==void 0?u:slugifyPlanSku(t.displayName);const m={sku:p,displayName:t.displayName,priceAmount:t.priceAmount,limits:buildLimits(t.rateLimitCalls,t.monthlyQuota)};if(t.pricingModel==="custom"){m.priceAmount=0;m.pricingModel="custom";return m}if(t.priceAmount>0){m.priceCurrency="usd";m.billingPeriod="month"}return m}function applyPlansToJsonConfig(t,u){if(u.length===0){return t}const p=isPlainObject(t.modules)?{...t.modules}:{};const m=isPlainObject(p.userPanel)?{...p.userPanel}:{};const g=isPlainObject(m.plans)?{...m.plans}:{};const y=Array.isArray(g.items)?[...g.items]:[];for(const t of u){const u=t.sku;const p=typeof u==="string"?y.findIndex((t=>t.sku===u)):-1;if(p>=0){y[p]={...y[p],...t}}else{y.push(t)}}m.plans={...g,enabled:true,items:y};p.userPanel=m;return ensureHeaderPricingNavigation({...t,modules:p})}const pt=null&&["dotnet","nodejs","python"];const yt={nodejs:["NODE_22_LTS","NODE_24_LTS"],python:["PYTHON_310","PYTHON_311","PYTHON_312","PYTHON_313","PYTHON_314"],dotnet:["DOTNET_8","DOTNET_9","DOTNET_10"]};function parseBackendRuntime(t){const u=t.trim().toLowerCase();if(u==="node"||u==="nodejs"){return"nodejs"}if(u==="dotnet"||u==="python"){return u}return null}function parseRuntimeVersion(t,u){const p=u.trim().toUpperCase();const m=yt[t];return m.includes(p)?p:null}function applyBackendToJsonConfig(t,u){const p=isPlainObject(t.backend)?t.backend:{};return{...t,backend:{...p,sourceDirectory:u.sourceDirectory,runtime:u.runtime,runtimeVersion:u.runtimeVersion}}}function toRoutePath(t,u){const p=t.replace(/\.(mdx?|tsx|jsx)$/i,"");const m=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const g=p.replace(new RegExp(`^${m}/?`),"");const y=g.replace(/\/index$/,"");return`/${y||"index"}`}function pageComponentName(t){const u=t.replace(/^\/+/,"").split(/[^a-zA-Z0-9]+/).filter(Boolean).map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join("");const p=/^[A-Za-z]/.test(u)?u:`Page${u}`;return p.endsWith("Page")?p:`${p}Page`}const vt=null&&`import { devPortalBillingPlugin } from "@lukoweb/apitogo-plugin-dev-portal-billing";\nimport { buildApitogoConfig } from "@lukoweb/apitogo/build-config";\nimport siteConfig from "./apitogo.config.json";\n\nexport default buildApitogoConfig({\n ...siteConfig,\n plugins: [devPortalBillingPlugin()],\n});\n`;function isThinConfigWrapper(t){return/export\s+default\s+buildApitogoConfig\s*\(/.test(t)}function isManagedConfigWrapper(t){if(isThinConfigWrapper(t)){return true}return/from\s+["']\.\/apitogo\.config\.json["']/.test(t)&&/buildApitogoConfig\s*\(/.test(t)&&/type:\s*["']custom-page["']/.test(t)}function labelFromRoutePath(t){var u;const p=t.replace(/^\/+/,"");const m=(u=p.split("/").filter(Boolean).pop())!==null&&u!==void 0?u:p;return titleFromDirectoryName(m)}function buildThinWrapperWithCustomPages(t){if(t.length===0){return vt}const u=t.map((t=>{const u=t.replace(/^\//,"");const p=pageComponentName(u);return`import ${p} from "./pages/${u}";`})).join("\n");const p=t.map((t=>{const u=t.replace(/^\//,"");const p=pageComponentName(u);const m=labelFromRoutePath(t);return` {\n type: "custom-page",\n path: ${JSON.stringify(t)},\n label: ${JSON.stringify(m)},\n element: <${p} />,\n },`})).join("\n");return`${u}\nimport { devPortalBillingPlugin } from "@lukoweb/apitogo-plugin-dev-portal-billing";\nimport { buildApitogoConfig } from "@lukoweb/apitogo/build-config";\nimport siteConfig from "./apitogo.config.json";\n\nconst config = buildApitogoConfig({\n ...siteConfig,\n plugins: [devPortalBillingPlugin()],\n});\n\nexport default {\n ...config,\n navigation: [\n {\n type: "category",\n label: ${JSON.stringify(ht)},\n items: [\n${p}\n ...((((config.navigation ?? []).find(\n (item) =>\n typeof item === "object" &&\n item !== null &&\n "label" in item &&\n item.label === ${JSON.stringify(ht)},\n ) as { items?: unknown[] } | undefined)?.items ?? []).filter(\n (item) =>\n typeof item !== "string" ||\n !${JSON.stringify(t)}.includes(item),\n )),\n ],\n },\n ...(config.navigation ?? []).filter(\n (item) =>\n !(\n typeof item === "object" &&\n item !== null &&\n "label" in item &&\n item.label === ${JSON.stringify(ht)}\n ),\n ),\n ],\n};\n`}const _t="Docs";const bt="API Reference";const wt="/introduction";function header_docs_nav_isPlainObject(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}function readHeaderNavigation(t){if(!header_docs_nav_isPlainObject(t.header))return null;const{navigation:u}=t.header;if(!Array.isArray(u)||u.length===0)return null;return{header:{...t.header},navigation:[...u]}}function isDocsItem(t){return header_docs_nav_isPlainObject(t)&&(t.to===wt||typeof t.label==="string"&&t.label.trim().toLowerCase()===_t.toLowerCase())}function ensureHeaderDocsNavigation(t,u){const p=sortDocPaths(u)[0];const m=readHeaderNavigation(t);if(!p||!m)return t;const{header:g,navigation:y}=m;const v=y.findIndex(isDocsItem);if(v>=0){const u=y[v];if(u.to!==wt)return t;y[v]={...u,to:p}}else{y.push({label:_t,to:p})}return{...t,header:{...g,navigation:y}}}function header_docs_nav_ensureHeaderApiReferenceNavigation(t,u,p=bt){const m=readHeaderNavigation(t);if(!m)return t;const{header:g,navigation:y}=m;if(y.some((t=>header_docs_nav_isPlainObject(t)&&t.to===u))){return t}const v=y.findIndex(isDocsItem);const b={label:p,to:u};if(v>=0){y.splice(v+1,0,b)}else{y.push(b)}return{...t,header:{...g,navigation:y}}}const Et="apitogo.config.json";const St="apitogo.local.json";const $t="https://dp-example.azurecontainerapps.io";function isPlanFree(t){var u;return((u=t.priceAmount)!==null&&u!==void 0?u:0)<=0}function manifestFilePath(t){return path.join(path.resolve(t),Et)}const Pt=null&&["authentication","backend","gateway","projectId"];function readPlanItemsFromConfig(t){const u=t.modules;const p=u===null||u===void 0?void 0:u.userPanel;const m=p===null||p===void 0?void 0:p.plans;const g=m===null||m===void 0?void 0:m.items;if(Array.isArray(g)&&g.length){return g.map((t=>planForConfig(t)))}const y=t.plans;if(Array.isArray(y)&&y.length){return y.map((t=>planForConfig(t)))}return undefined}function readPricingEnabledFromConfig(t){const u=t.modules;const p=u===null||u===void 0?void 0:u.userPanel;const m=p===null||p===void 0?void 0:p.plans;if((m===null||m===void 0?void 0:m.enabled)===true){return true}const g=t.pricing;return(g===null||g===void 0?void 0:g.enabled)===true}function applyPlansToUserPanel(t,u,p){var m,g,y,v;if(u===undefined){return}const b=(m=t.modules)!==null&&m!==void 0?m:{};const w=(g=b.userPanel)!==null&&g!==void 0?g:{};const E=(y=w.plans)!==null&&y!==void 0?y:{};if(u.length>0){E.items=u.map((t=>planForConfig(t)));if(p!==false){E.enabled=(v=E.enabled)!==null&&v!==void 0?v:true}}else{delete E.items}w.plans=E;b.userPanel=w;t.modules=b;delete t.plans;if(u.length>0){const u=ensureHeaderPricingNavigation(t);t.header=u.header}}function applyPricingToUserPanel(t,u){var p,m,g;if((u===null||u===void 0?void 0:u.enabled)===undefined){return}const y=(p=t.modules)!==null&&p!==void 0?p:{};const v=(m=y.userPanel)!==null&&m!==void 0?m:{};const b=(g=v.plans)!==null&&g!==void 0?g:{};b.enabled=u.enabled;v.plans=b;y.userPanel=v;t.modules=y;delete t.pricing}function readSiteTitle(t){const u=t.site;if(typeof(u===null||u===void 0?void 0:u.title)==="string"&&u.title.trim()){return u.title.trim()}if(typeof t.siteName==="string"&&t.siteName.trim()){return t.siteName.trim()}const p=t.branding;if(typeof(p===null||p===void 0?void 0:p.title)==="string"&&p.title.trim()){return p.title.trim()}return undefined}function readLogoUrl(t){var u,p,m,g;const y=t.site;const v=t.branding;return((p=(u=y===null||y===void 0?void 0:y.logo)===null||u===void 0?void 0:u.src)===null||p===void 0?void 0:p.light)||((g=(m=y===null||y===void 0?void 0:y.logo)===null||m===void 0?void 0:m.src)===null||g===void 0?void 0:g.dark)||(y===null||y===void 0?void 0:y.logoUrl)||(v===null||v===void 0?void 0:v.logoUrl)}function readUserPanelEnabled(t){const u=t.modules;const p=u===null||u===void 0?void 0:u.userPanel;if((p===null||p===void 0?void 0:p.enabled)===true){return true}const m=p===null||p===void 0?void 0:p.dashboard;const g=p===null||p===void 0?void 0:p.userManagement;const y=p===null||p===void 0?void 0:p.apiKeys;const v=p===null||p===void 0?void 0:p.plans;return(m===null||m===void 0?void 0:m.enabled)===true||(g===null||g===void 0?void 0:g.enabled)===true||(y===null||y===void 0?void 0:y.enabled)===true||(v===null||v===void 0?void 0:v.enabled)===true}function stripAuthenticationSecrets(t){const{gateway:u,oidc:p,stripe:m,type:g,email:y,providers:v,...b}=t;const w=y;if(w){const{connectionString:t,...u}=w;b.email=u}if(Array.isArray(v)){b.providers=v.map((t=>{const u=t;const{clientSecret:p,...m}=u;return m}))}return b}function extractManifestFromConfig(t){var u,p,m;const g={};const y=readSiteTitle(t);if(y){g.siteName=y;const u=readLogoUrl(t);g.branding=u?{title:y,logoUrl:u}:{title:y}}const v=readUserPanelEnabled(t);const b=t.authentication;if(b||v){const t=stripAuthenticationSecrets({...b!==null&&b!==void 0?b:{},enabled:v,native:{...(u=b===null||b===void 0?void 0:b.native)!==null&&u!==void 0?u:{},enabled:(m=(p=b===null||b===void 0?void 0:b.native)===null||p===void 0?void 0:p.enabled)!==null&&m!==void 0?m:true},providers:Array.isArray(b===null||b===void 0?void 0:b.providers)?b.providers:[]});g.authentication=t}for(const u of Pt){if(u==="authentication"){continue}if(t[u]!==undefined){g[u]=t[u]}}if(g.gateway){g.gateway=gatewayForConfig(g.gateway)}const w=readPlanItemsFromConfig(t);if(w){g.plans=w}if(readPricingEnabledFromConfig(t)){g.pricing={enabled:true}}const E=readLandingFromConfig(t);if(E){g.landing=E}return g}function applyManifestToConfig(t,u){var p,m,g,y,v,b,w,E;const $={...t};const P=((p=u.siteName)===null||p===void 0?void 0:p.trim())||((g=(m=u.branding)===null||m===void 0?void 0:m.title)===null||g===void 0?void 0:g.trim())||readSiteTitle(t);if(P){const t=(y=$.site)!==null&&y!==void 0?y:{};t.title=P;if((v=u.branding)===null||v===void 0?void 0:v.logoUrl){const p=(b=t.logo)!==null&&b!==void 0?b:{};const m=(w=p.src)!==null&&w!==void 0?w:{};t.logo={...p,src:{...m,light:u.branding.logoUrl}}}$.site=t}for(const t of Pt){const p=u[t];if(p!==undefined){$[t]=t==="gateway"?gatewayForConfig(p):p}else{delete $[t]}}if(u.pricing!==undefined){applyPricingToUserPanel($,u.pricing)}if(u.plans!==undefined){applyPlansToUserPanel($,u.plans,(E=u.pricing)===null||E===void 0?void 0:E.enabled)}delete $.plans;delete $.pricing;if($.authentication&&typeof $.authentication==="object"){const t={...$.authentication};delete t.gateway;$.authentication=t}delete $.siteName;delete $.branding;delete $.projectName;return $}async function readLegacyManifest(t){return null}async function pathExists(t){try{await access(t);return true}catch{return false}}function normalizeBillingPeriod(t){if(!t){return"monthly"}const u=t.toLowerCase();if(u==="month"){return"monthly"}if(u==="year"){return"annual"}return u}const At=[{sku:"free",displayName:"Free",priceAmount:0,limits:{rateLimit:{calls:60,renewalPeriodSeconds:60}},includedActionKeys:[]},{sku:"pro",displayName:"Pro",priceAmount:9.99,billingPeriod:"month",limits:{rateLimit:{calls:100,renewalPeriodSeconds:60},quota:{calls:5e4,renewalPeriodDays:1}},includedActionKeys:[]}];const Ot=[{id:"docs",label:"Docs and custom React pages",availableLocally:true},{id:"pricing",label:"/pricing",availableLocally:false},{id:"apiReference",label:"API reference",availableLocally:true,requiresPublish:false},{id:"signIn",label:"Sign-in and account area",availableLocally:false,requiresPublish:true},{id:"subscriptions",label:"Free plan entitlement and paid checkout",availableLocally:false,requiresPublish:true},{id:"credentials",label:"Subscription keys via /credentials",availableLocally:false,requiresPublish:true}];const Rt=[{target:"apitogo.config.json",purpose:"Plans, branding, site settings, backend paths, projectId",tool:"update_dev_portal_manifest"},{target:"landing/LandingPage.tsx",purpose:"Home page sections composed as JSX (HeroSection, FeaturesSection, etc.)",tool:"get_dev_portal_landing_guide"},{target:"apitogo.config.tsx",purpose:"Plugins and custom code-only configuration"},{target:"pages/**/*.tsx",purpose:"Content pages as React components under a Documentation nav category (custom-page)",tool:"add_dev_portal_page"},{target:"OpenAPI (wire via set_dev_portal_openapi)",purpose:"API reference spec — points at the source file; does not copy into the site",tool:"set_dev_portal_openapi"}];const kt={id:"openapi",phase:"shape",prompt:"No OpenAPI found nearby — create a starter OpenAPI for the user (or ask for a path), then call set_dev_portal_openapi?",tool:"set_dev_portal_openapi",note:"Offer to draft openapi.yaml from their API description when they have no spec yet."};const Ct=[{id:"openapi",phase:"shape",prompt:"Add an OpenAPI spec to the site?",tool:"set_dev_portal_openapi"},{id:"designLanding",phase:"shape",prompt:"Design your home page?",tool:"get_dev_portal_landing_guide",optional:true,note:"Ask the user for their real content (product, endpoints, audience, tone, sections) before editing landing/LandingPage.tsx — compose HeroSection, TrustSection, FeaturesSection, StepsSection, ApiShowcaseSection, PlansPreviewSection, and PricingCtaSection inside LandingShell."},{id:"addPlans",phase:"shape",prompt:"Add subscription plans for /pricing?",tool:"update_dev_portal_manifest",note:"Or pass includeDefaultPlans: true on create_dev_portal for Free + Pro defaults."},{id:"customizePlans",phase:"shape",prompt:"Customize subscription plan SKUs, prices, or limits?",tool:"update_dev_portal_manifest",optional:true},{id:"pagesBranding",phase:"shape",prompt:"Add pages or update branding?",tool:"add_dev_portal_page",optional:true,note:"Use add_dev_portal_page or update_dev_portal_manifest for branding."},{id:"bootstrapProject",phase:"shape",prompt:"Bootstrap an API ToGo project (apihub + dev-portal)?",tool:"bootstrap_project",optional:true,note:"Creates the platform project only. Ask the tenant Free, Starter, or Professional hosting (see list_platform_plans), then call ensure_platform_plan. Or pass bootstrapProject: true on create_dev_portal."},{id:"goLive",phase:"publish",prompt:"Publish for real sign-in and subscriptions?",tool:"publish_dev_portal",note:"User saves OIDC (and Stripe if paid plans) in .env via APITOGO_CONFIG_AUTHENTICATION__* — never in chat."},{id:"backend",phase:"postPublish",prompt:"Connect/deploy an API backend?",tool:"update_dev_portal_manifest",optional:true},{id:"syncActions",phase:"postPublish",prompt:"Attach OpenAPI actions to gateway plans?",tool:"sync_gateway_plans_from_manifest",optional:true,note:"Use syncActionsOnly after backend deploy; publish already upserts plans."}];function buildScaffoldJourneyPhases(t=Ct){return[{id:"shape",title:"Shape the site",steps:t.filter((t=>t.phase==="shape"))},{id:"publish",title:"Go live",steps:t.filter((t=>t.phase==="publish"))},{id:"postPublish",title:"Post-publish API product",steps:t.filter((t=>t.phase==="postPublish"))}]}const It=buildScaffoldJourneyPhases();const Nt="Scaffold only — dependencies are installed but the dev server is not started. Tell the user the site is ready and to run npm run dev in outputDirectory. The home page lives in landing/LandingPage.tsx (default sample sections including plans). After npm run dev, ask if they want to customize the home page. When they do, always ask for their real content first (what the API does, key endpoints, audience, tone, desired sections) before editing — never invent placeholder copy unless they explicitly ask for placeholders — then edit that TSX file directly or call get_dev_portal_landing_guide for the component catalog. Do not write home page content to apitogo.config.json. Then ask what else they want (OpenAPI, plans, bootstrap API ToGo, or go live). Do not mention missing plans, null projectId, skipped bootstrap, publishPrerequisites, or other absent setup unless the user asks about publish or platform provisioning. One user intent → one MCP tool. When preview is running, shape-phase file edits hot-reload. Never pass restartPreview: true on update_dev_portal_manifest or set_dev_portal_theme (ignored; used to time out against npm run dev). For publish, the user saves OIDC (+ Stripe if paid) in .env using APITOGO_CONFIG_AUTHENTICATION__* keys — never collect secrets in chat. Call check_dev_portal_publish_readiness after they confirm, then publish_dev_portal. Do not call sync_gateway_plans_from_manifest before publish.";function manifestRequiresStripe(t){return(t!==null&&t!==void 0?t:[]).some((t=>!isPlanFree(t)))}function isNativeAuthEnabledInManifest(t){var u,p;if(((u=t.authentication)===null||u===void 0?void 0:u.enabled)!==true){return false}return((p=t.authentication.native)===null||p===void 0?void 0:p.enabled)!==false}function readManifestAuthProviders(t){var u,p;return(p=(u=t.authentication)===null||u===void 0?void 0:u.providers)!==null&&p!==void 0?p:[]}function getPublishPrerequisites(t,u,p){var m,g,y,v,b,w,E,$,P,A,O,R;void p;const x=[];const T=manifestRequiresStripe(t.plans);const k=((m=t.authentication)===null||m===void 0?void 0:m.enabled)===true;const C=k&&isNativeAuthEnabledInManifest(t);const I=(g=readManifestAuthProviders(t))!==null&&g!==void 0?g:[];if(!((y=t.plans)===null||y===void 0?void 0:y.length)){x.push("plans")}if(k){if(!C&&I.length===0){x.push("authentication.methods")}for(const t of I){const p=t.id.trim();if(!((v=t.authority)===null||v===void 0?void 0:v.trim())){x.push(`providers.${p}.authority`)}if(!((b=t.clientId)===null||b===void 0?void 0:b.trim())){x.push(`providers.${p}.clientId`)}if(!(($=(E=(w=u===null||u===void 0?void 0:u.providers)===null||w===void 0?void 0:w[p])===null||E===void 0?void 0:E.clientSecret)===null||$===void 0?void 0:$.trim())){x.push(`providers.${p}.clientSecret`)}}}const N=(A=(P=u===null||u===void 0?void 0:u.stripe)===null||P===void 0?void 0:P.secretKey)===null||A===void 0?void 0:A.trim();const D=(R=(O=u===null||u===void 0?void 0:u.stripe)===null||O===void 0?void 0:O.webhookSecret)===null||R===void 0?void 0:R.trim();if(T){if(!N){x.push("stripe.secretKey")}if(!D){x.push("stripe.webhookSecret")}}return{nativeAuthRequired:C,stripeRequired:T,missingFields:x,readyToPublish:x.length===0}}function resolveManifestNextStep(t,u){var p;if(!((p=t.plans)===null||p===void 0?void 0:p.length)){return"Ask the user what subscription plans they want (SKUs, free/paid, pricing). "+"Call update_dev_portal_manifest only after they specify — never add Free+Pro defaults on go-live unless they explicitly request them."}const m=getPublishPrerequisites(t,u);if(m.readyToPublish){return"Run publish_dev_portal when the tenant confirms go-live."}if(!u){return"Continue shaping the site in the running local preview. For publish, save auth secrets (OIDC provider secrets, and Stripe if paid plans) in .env using APITOGO_CONFIG_AUTHENTICATION__* keys — never in chat. Native auth email is always platform-managed."}const g=m.missingFields.filter((t=>t!=="plans"));if(g.length>0){return`Publish prerequisites incomplete in .env: ${g.join(", ")}.`}return`Publish prerequisites incomplete: ${m.missingFields.join(", ")}.`}function createScaffoldManifest(t){const u=(t===null||t===void 0?void 0:t.trim())||"Sample API";return{siteName:u,branding:{title:u}}}function resolveProjectDisplayName(t,u){var p,m,g;return((p=t.siteName)===null||p===void 0?void 0:p.trim())||((g=(m=t.branding)===null||m===void 0?void 0:m.title)===null||g===void 0?void 0:g.trim())||(u?readSiteTitle(u):undefined)||"Developer Portal"}function createDefaultManifest(t){return{...createScaffoldManifest(t),pricing:{enabled:true},plans:At}}function applyScaffoldManifestPolicy(t,u){var p,m,g,y,v,b;const w=((p=u.siteName)===null||p===void 0?void 0:p.trim())||((m=t.siteName)===null||m===void 0?void 0:m.trim())||((y=(g=t.branding)===null||g===void 0?void 0:g.title)===null||y===void 0?void 0:y.trim())||"Sample API";const E={...t,siteName:w,branding:{...t.branding,title:(b=(v=t.branding)===null||v===void 0?void 0:v.title)!==null&&b!==void 0?b:w}};if(u.includeDefaultPlans){E.plans=mergePlansBySku(E.plans,At);E.pricing={enabled:true}}return E}function mergePlansBySku(t,u){const p=new Map;for(const u of t!==null&&t!==void 0?t:[]){p.set(u.sku,u)}for(const t of u){const u=p.get(t.sku);p.set(t.sku,mergeLimitsSource(u,t))}return Array.from(p.values())}function resolveBackendSourceDirectory(t,u){const p=u===null||u===void 0?void 0:u.trim();if(!p){return undefined}return path.resolve(t,p)}function resolveBackendOpenApiPath(t,u){var p;const m=t===null||t===void 0?void 0:t.trim();if(!m){return undefined}if(path.isAbsolute(m)){return m}const g=path.resolve(u.siteDirectory,m);if(existsSync(g)){return g}const y=(p=u.backendSourceDirectory)===null||p===void 0?void 0:p.trim();if(y){const t=path.resolve(y,m);if(existsSync(t)){return t}}return g}function toSiteRelativeOpenApiInput(t,u){const m=p().relative(p().resolve(t),p().resolve(u));const g=m.split(p().sep).join("/");if(!g||g==="."){return"./"}if(p().isAbsolute(g)||g.startsWith("..")){return g}return g.startsWith("./")?g:`./${g}`}const Dt=new Set(["siteName","branding","pricing","authentication","plans","backend","gateway","projectId"]);const jt="Home page content belongs in landing/LandingPage.tsx — edit that file directly or call get_dev_portal_landing_guide.";function formatIgnoredManifestPatchWarning(t){if(t.length===0){return undefined}const u=t.some((t=>t==="landing"||t==="modules.landing"));const p=u?` ${jt}`:"";return`Patch keys not in the manifest schema were dropped: ${t.join(", ")}.${p} Verify the returned manifest contains your change.`}function normalizeManifestPatch(t){const u={...t};const p=[];const m=u.modules;if(m&&typeof m==="object"&&!Array.isArray(m)){if(m.landing!==undefined){p.push("modules.landing")}delete u.modules}if(u.landing!==undefined){p.push("landing");delete u.landing}for(const t of Object.keys(u)){if(!Dt.has(t)){p.push(t);delete u[t]}}return{patch:u,ignoredKeys:p}}function mergePublishPrerequisitesWithPlatformValidation(t,u){return{...t,manifestFieldIssues:u.length>0?u:undefined,readyToPublish:t.readyToPublish&&u.length===0}}function mergeManifest(t,u){var p,m,g;const y={...t,...u};if(u.branding){y.branding={...t.branding,...u.branding}}if(u.pricing){y.pricing={...t.pricing,...u.pricing}}if(u.backend){y.backend={...t.backend,...u.backend}}if(u.gateway){const g=(m=(p=t.gateway)===null||p===void 0?void 0:p.publicRoutes)!==null&&m!==void 0?m:[];const v=u.gateway.publicRoutes;y.gateway=mergeLimitsSource(t.gateway,u.gateway);if(v){y.gateway.publicRoutes=[...new Set([...g,...v].map((t=>t.trim())).filter(Boolean))]}}if(u.plans){y.plans=mergePlansBySku(t.plans,u.plans);if(u.plans.length>0&&((g=u.pricing)===null||g===void 0?void 0:g.enabled)!==false){y.pricing={...y.pricing,enabled:true}}}return y}function applyOpenApiToSiteConfig(t,u){var p;const m={...t};m.apis=[{type:"file",input:u.input,path:u.apiPath}];const g=`/${u.apiPath.replace(/^\//,"")}`;const y=Array.isArray(m.navigation)?[...m.navigation]:[];const v=y.some((t=>typeof t==="object"&&t!==null&&t.to===g));if(!v){y.push({type:"link",to:g,label:(p=u.navLabel)!==null&&p!==void 0?p:"API Reference"})}m.navigation=y;return header_docs_nav_ensureHeaderApiReferenceNavigation(m,g,u.navLabel)}async function readManifest(t){const u=manifestFilePath(t);if(await pathExists(u)){const t=await readFile(u,"utf8");const p=JSON.parse(t);return extractManifestFromConfig(p)}return readLegacyManifest(t)}async function writeManifest(t,u){const p=manifestFilePath(t);await mkdir(path.dirname(p),{recursive:true});let m={};if(await pathExists(p)){const t=await readFile(p,"utf8");m=JSON.parse(t)}const{oidc:g,stripe:y,...v}=u;m=applyManifestToConfig(m,v);await writeFile(p,`${JSON.stringify(m,null,2)}\n`,"utf8");return p}function plansToMockEnvValue(t){if(!(t===null||t===void 0?void 0:t.length)){return null}const u=t.map((t=>{var u,p,m,g;return{sku:t.sku,displayName:t.displayName,priceAmount:(u=t.priceAmount)!==null&&u!==void 0?u:0,pricingModel:(p=t.pricingModel)!==null&&p!==void 0?p:"fixed",priceLabel:t.priceLabel,priceCurrency:(m=t.priceCurrency)!==null&&m!==void 0?m:"usd",billingPeriod:normalizeBillingPeriod(t.billingPeriod),limitsJson:(g=planLimitsForPlatform(t))!==null&&g!==void 0?g:null}}));return JSON.stringify(u)}function mockPlansPreviewChanged(t,u){return plansToMockEnvValue(t)!==plansToMockEnvValue(u)}const Mt={dotnet:"DOTNET_10",nodejs:"NODE_22_LTS",python:"PYTHON_312"};const Ft=["pyproject.toml","requirements.txt","Pipfile"];async function listFiles(t){try{const u=await(0,ot.readdir)(t,{withFileTypes:true});return u.filter((t=>t.isFile())).map((t=>t.name))}catch{return[]}}async function readText(t){try{return await(0,ot.readFile)(t,"utf8")}catch{return undefined}}function dotnetVersionFromCsproj(t){const u=t===null||t===void 0?void 0:t.match(/<TargetFrameworks?>\s*net(\d+)\.\d/i);const p=u===null||u===void 0?void 0:u[1];if(p==="8"||p==="9"||p==="10"){return`DOTNET_${p}`}return Mt.dotnet}function nodeVersionFromEngines(t){const u=t&&typeof t==="object"&&!Array.isArray(t)?t.node:undefined;if(typeof u==="string"&&/(^|[^\d])24/.test(u)){return"NODE_24_LTS"}return Mt.nodejs}function pythonVersionFromText(t){const u=t===null||t===void 0?void 0:t.match(/3\.(1[0-4])/);return u?`PYTHON_3${u[1]}`:Mt.python}function isRunnableNodePackage(t){const u=t.scripts&&typeof t.scripts==="object"?t.scripts:{};return typeof u.start==="string"||typeof t.main==="string"}async function detectParentBackend(t){var u,m,g;const y=p().resolve(t);const v=p().dirname(y);if(v===y){return undefined}const b=await listFiles(v);const toResult=(t,u,m)=>({directory:v,sourceDirectory:p().relative(y,v).split(p().sep).join("/")||".",runtime:t,runtimeVersion:u,marker:m});const w=b.find((t=>t.endsWith(".csproj")));const E=b.find((t=>/\.slnx?$/.test(t)));if(w||E){const t=w?await readText(p().join(v,w)):undefined;return toResult("dotnet",dotnetVersionFromCsproj(t),w!==null&&w!==void 0?w:E)}if(b.includes("package.json")){const t=await readText(p().join(v,"package.json"));try{const u=JSON.parse(t!==null&&t!==void 0?t:"");if(isRunnableNodePackage(u)){return toResult("nodejs",nodeVersionFromEngines(u.engines),"package.json")}}catch{}}const $=Ft.find((t=>b.includes(t)));if($){const t=(u=await readText(p().join(v,".python-version")))!==null&&u!==void 0?u:$==="pyproject.toml"?(g=(m=await readText(p().join(v,$)))===null||m===void 0?void 0:m.match(/requires-python\s*=\s*"([^"]+)"/))===null||g===void 0?void 0:g[1]:undefined;return toResult("python",pythonVersionFromText(t),$)}return undefined}const Ut=["openapi.yaml","openapi.yml","openapi.json","swagger.yaml","swagger.yml","swagger.json"];const Bt="No OpenAPI file found near the site (checked parent, sibling folders, and the site directory for openapi.yaml|yml|json / swagger.yaml|yml|json). Ask the user for a path, or offer to draft a starter OpenAPI 3 spec from their API description, write it next to the site (e.g. ../openapi.yaml), then call set_dev_portal_openapi.";const Ht=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo",".cache",".apitogo"]);async function collectFromDir(u,m,g){const y=p().resolve(u);if(m.includes(y)){return}m.push(y);for(const u of Ut){const m=p().join(y,u);try{await t.promises.access(m);g.push(m)}catch{}}}async function collectSiteOpenApiFiles(t){const u=[];const p=[];await collectFromDir(t,u,p);return{candidates:[...new Set(p)],searchedDirectories:u}}async function collectNearbyOpenApiFiles(u){const m=p().resolve(u);const g=p().dirname(m);const y=[];const v=[];if(g&&g!==m){await collectFromDir(g,y,v);try{const u=await t.promises.readdir(g,{withFileTypes:true});for(const t of u){if(!t.isDirectory()||Ht.has(t.name)){continue}const u=p().join(g,t.name);if(p().resolve(u)===m){continue}await collectFromDir(u,y,v)}}catch{}}await collectFromDir(m,y,v);return{candidates:[...new Set(v)],searchedDirectories:y}}function parseOpenApiObject(t){const u=t.openapi;if(typeof u!=="string"||!u.startsWith("3.")){return{valid:false,errors:[`OpenAPI 3.x required; found ${String(u!==null&&u!==void 0?u:"missing")}.`]}}const p=t.info;return{valid:true,version:u,title:p===null||p===void 0?void 0:p.title,errors:[]}}function liteParseOpenApi(t,u){var m,g;const y=p().extname(u).toLowerCase();if(y===".json"){try{const u=JSON.parse(t);if(!u||typeof u!=="object"||Array.isArray(u)){return{valid:false,errors:["OpenAPI document must be a JSON object."]}}return parseOpenApiObject(u)}catch(t){return{valid:false,errors:[`Failed to parse OpenAPI document: ${t instanceof Error?t.message:String(t)}`]}}}const v=t.match(/^\s*openapi:\s*['"]?(3\.\d+(?:\.\d+)?)['"]?/m);if(!(v===null||v===void 0?void 0:v[1])){return{valid:false,errors:["OpenAPI 3.x required; missing openapi: 3.x field."]}}const b=t.match(/^\s*info:\s*\n((?:[ \t].*\n)+)/m);const w=(m=b===null||b===void 0?void 0:b[1])===null||m===void 0?void 0:m.match(/^\s*title:\s*['"]?(.+?)['"]?\s*$/m);return{valid:true,version:v[1],title:(g=w===null||w===void 0?void 0:w[1])===null||g===void 0?void 0:g.trim(),errors:[]}}const Vt=["docs","documents","documentation","doc"];const zt=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo",".cache",".apitogo"]);const Gt="pages";const Wt="apitogo.config.json";async function wire_docs_pathExists(t){try{await(0,ot.access)(t);return true}catch{return false}}async function isDirectory(t){try{const u=await(0,ot.lstat)(t);return u.isDirectory()}catch{return false}}function toPosix(t){return t.split(p().sep).join(p().posix.sep)}function isWhitelistedDirName(t){return Vt.includes(t.toLowerCase())}function isInside(t,u){const m=p().relative(t,u);return m===""||!m.startsWith("..")&&!p().isAbsolute(m)}async function collectMarkdownFiles(t,u){const m=[];let g;try{g=await(0,ot.readdir)(t,{withFileTypes:true})}catch{return m}for(const y of g){if(y.name.startsWith(".")){continue}const g=p().join(t,y.name);if(y.isDirectory()){if(zt.has(y.name)||y.isSymbolicLink()||u&&p().resolve(g)===u){continue}m.push(...await collectMarkdownFiles(g,u));continue}if((y.isFile()||y.isSymbolicLink())&&/\.mdx?$/i.test(y.name)){m.push(g)}}return m}async function collectSearchRoots(t){const u=p().resolve(t);const m=p().dirname(u);const g=[];const add=t=>{const u=p().resolve(t);if(!g.includes(u)){g.push(u)}};if(m&&m!==u){add(m);try{const t=await(0,ot.readdir)(m,{withFileTypes:true});for(const u of t){if(!u.isDirectory()||zt.has(u.name)){continue}add(p().join(m,u.name))}}catch{}}add(u);return g}async function discoverNearbyDocsDirectories(t){const u=p().resolve(t);const m=p().join(u,Gt);const g=await collectSearchRoots(u);const y=[];const v=new Set;const consider=async t=>{const g=p().resolve(t);if(g===u||v.has(g)||isInside(m,g)){return}if(!await isDirectory(g)){return}const b=(await collectMarkdownFiles(g,u)).sort(((t,u)=>t.localeCompare(u)));if(b.length===0){return}v.add(g);y.push({sourceDirectory:g,files:b})};for(const t of g){if(isWhitelistedDirName(p().basename(t))){await consider(t)}try{const u=await(0,ot.readdir)(t,{withFileTypes:true});for(const m of u){if(!m.isDirectory()||zt.has(m.name)){continue}if(!isWhitelistedDirName(m.name)){continue}await consider(p().join(t,m.name))}}catch{}}const coveredBy=(t,p)=>t!==p&&isInside(t,p)&&(!isInside(u,p)||isInside(u,t));return{directories:y.filter((t=>!y.some((u=>coveredBy(u.sourceDirectory,t.sourceDirectory))))),searchedDirectories:g}}function slugifyDirName(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"docs"}async function allocateLinkName(t,u,m){var g;const y=slugifyDirName(p().basename(u));const v=slugifyDirName(p().basename(p().dirname(u)));const b=[y,`${v}-${y}`];let w=2;while(true){const u=(g=b.shift())!==null&&g!==void 0?g:`${y}-${w++}`;if(m.has(u)){continue}const v=p().join(t,u);if(await wire_docs_pathExists(v)){const t=await(0,ot.lstat)(v);if(!t.isDirectory()||!await isManagedLinkDir(v)){continue}}m.add(u);return u}}async function isManagedLinkDir(t){try{const u=await(0,ot.readdir)(t,{withFileTypes:true});if(u.length===0){return true}return u.every((t=>t.isSymbolicLink()||t.isDirectory()))}catch{return false}}async function alreadyLinked(t,u){try{const m=await(0,ot.lstat)(t);if(!m.isSymbolicLink()){return false}const g=await(0,ot.readlink)(t);const y=p().resolve(p().dirname(t),g);return y===p().resolve(u)}catch{return false}}async function linkMarkdownFile(t,u){if(await alreadyLinked(u,t)){return"exists"}if(await wire_docs_pathExists(u)){return"skipped"}await(0,ot.mkdir)(p().dirname(u),{recursive:true});const m=p().relative(p().dirname(u),t);await(0,ot.symlink)(m,u,process.platform==="win32"?"file":undefined);return"linked"}function wire_docs_isPlainObject(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}async function applyDocsNavigation(t,u){if(u.length===0){return}const m=p().join(t,Wt);if(!await wire_docs_pathExists(m)){return}const g=await(0,ot.readFile)(m,"utf8");const y=JSON.parse(g);if(!wire_docs_isPlainObject(y)){return}y.navigation=mergeDocumentationNavigation(y.navigation,u,{force:false});const v=ensureHeaderDocsNavigation(y,u);await(0,ot.writeFile)(m,`${JSON.stringify(v,null,2)}\n`,"utf8")}async function discoverAndWireDocs(t){const u=p().resolve(t);const m=p().join(u,Gt);const{directories:g,searchedDirectories:y}=await discoverNearbyDocsDirectories(u);if(g.length===0){return{status:"not_found",whitelist:Vt,searchedDirectories:y,sources:[],fileCount:0,skippedCount:0}}await(0,ot.mkdir)(m,{recursive:true});const v=new Set;const b=[];const w=[];for(const t of g){const g=await allocateLinkName(m,t.sourceDirectory,v);const y=p().join(m,g);const E=[];const $=[];for(const m of t.files){const g=toPosix(p().relative(t.sourceDirectory,m));const v=p().join(y,g);const b=toPosix(p().relative(u,v));const P=toRoutePath(b,Gt);if(w.includes(P)){$.push({sourcePath:m,reason:`route ${P} is already used by another file`});continue}const A=await linkMarkdownFile(m,v);if(A==="skipped"){$.push({sourcePath:m,reason:"target already exists and is not this source"});continue}E.push({sourcePath:m,linkPath:v,route:P,relativeSource:g});w.push(P)}b.push({sourceDirectory:t.sourceDirectory,linkDirectory:y,linkName:g,files:E,skipped:$})}await applyDocsNavigation(u,w);const E=b.reduce(((t,u)=>t+u.files.length),0);const $=b.reduce(((t,u)=>t+u.skipped.length),0);const P=E===0?"not_found":$>0?"partial":"wired";return{status:P,whitelist:Vt,searchedDirectories:y,sources:b,fileCount:E,skippedCount:$}}function siteRelative(t,u){const m=toPosix(p().relative(t,u));if(!m){return"."}if(p().isAbsolute(m)){return toPosix(u)}if(m.startsWith("..")){return m}return`./${m}`}function formatOpenApiDiscoveryLines(t,u){var p;const m=String((p=u.status)!==null&&p!==void 0?p:"unknown");if(m==="wired"){const p=typeof u.openApiInput==="string"?u.openApiInput:typeof u.openApiPath==="string"?siteRelative(t,u.openApiPath):"OpenAPI";const m=typeof u.openApiTitle==="string"?` (${u.openApiTitle})`:"";const g=typeof u.apiReferencePath==="string"?u.apiReferencePath:"/api";return[`OpenAPI: wired ${p}${m} → ${g}`]}if(m==="skipped"){return["OpenAPI: search skipped"]}if(m==="invalid"||m==="wire_failed"){const t=typeof u.error==="string"?`: ${u.error}`:"";return[`OpenAPI: found a spec but did not wire it${t}`]}return["OpenAPI: none found nearby"]}function formatDocsDiscoveryLines(t,u){if(u.status==="not_found"){return[`Docs: none found in ${Vt.join("/")}/ folders nearby`]}const p=[`Docs: linked ${u.fileCount} markdown file${u.fileCount===1?"":"s"} (not copied)`];for(const m of u.sources){const u=siteRelative(t,m.sourceDirectory);const g=siteRelative(t,m.linkDirectory);p.push(` ${u} → ${g}`);for(const t of m.files){p.push(` ${t.relativeSource} → ${t.route}`)}for(const u of m.skipped){p.push(` skipped ${siteRelative(t,u.sourcePath)}`)}}return p}function formatBackendDiscoveryLines(t){var u,p,m,g;const y=String((u=t===null||t===void 0?void 0:t.status)!==null&&u!==void 0?u:"unknown");if(y==="wired"||y==="already_configured"){const u=(p=t===null||t===void 0?void 0:t.runtime)!==null&&p!==void 0?p:"unknown runtime";const v=(m=t===null||t===void 0?void 0:t.runtimeVersion)!==null&&m!==void 0?m:"";const b=(g=t===null||t===void 0?void 0:t.sourceDirectory)!==null&&g!==void 0?g:"";const w=y==="wired"?"detected":"kept";return[`Backend: ${w} ${u} ${v} at ${b}`.trimEnd()]}if(y==="wire_failed"){const u=typeof(t===null||t===void 0?void 0:t.error)==="string"?`: ${t.error}`:"";return[`Backend: found a project but did not wire it${u}`]}if(y==="skipped"){return["Backend: search skipped"]}return["Backend: none detected in the parent folder (set one with apitogo config)"]}function formatInitDiscoveryReport(t,u,p,m){return[...formatOpenApiDiscoveryLines(t,u),...formatDocsDiscoveryLines(t,p),...m?formatBackendDiscoveryLines(m):[]]}async function run_scaffold_discovery_pathExists(t){try{await(0,ot.access)(t);return true}catch{return false}}async function wireOpenApiIntoJsonConfig(t,u){const m=toSiteRelativeOpenApiInput(t,u);const g=p().join(t,"apitogo.config.json");const y=await(0,ot.readFile)(g,"utf8");const v=JSON.parse(y);const b=applyOpenApiToSiteConfig(v,{input:m,apiPath:"api"});const w=b.backend&&typeof b.backend==="object"&&!Array.isArray(b.backend)?{...b.backend}:{};b.backend={...w,openApiPath:m};await(0,ot.writeFile)(g,`${JSON.stringify(b,null,2)}\n`,"utf8");return{input:m}}async function discoverAndWireOpenApiLite(t,u){var m,g;if(u==="none"){return{openApiDiscovery:{status:"skipped",mode:u},wired:false}}const y=u==="site"?await collectSiteOpenApiFiles(t):await collectNearbyOpenApiFiles(t);const v=[];let b;for(const t of y.candidates){const u=await(0,ot.readFile)(t,"utf8");const p=liteParseOpenApi(u,t);if(p.valid){b={path:t,version:p.version,title:p.title};break}v.push({path:t,errors:p.errors})}if(!b){return{openApiDiscovery:{status:y.candidates.length>0?"invalid":"not_found",candidates:y.candidates,searchedDirectories:y.searchedDirectories,...v.length>0?{invalidCandidates:v}:{},suggestion:Bt},wired:false}}const w=p().join(t,"apitogo.config.json");if(!await run_scaffold_discovery_pathExists(w)){return{openApiDiscovery:{status:"wire_failed",openApiPath:b.path,error:"apitogo.config.json not found",candidates:y.candidates,searchedDirectories:y.searchedDirectories,suggestion:Bt},wired:false}}try{const{input:u}=await wireOpenApiIntoJsonConfig(t,b.path);return{openApiDiscovery:{status:"wired",openApiPath:b.path,openApiInput:u,openApiTitle:(m=b.title)!==null&&m!==void 0?m:null,openApiVersion:(g=b.version)!==null&&g!==void 0?g:null,apiReferencePath:"/api",candidates:y.candidates,searchedDirectories:y.searchedDirectories},wired:true}}catch(t){return{openApiDiscovery:{status:"wire_failed",openApiPath:b.path,error:t instanceof Error?t.message:String(t),candidates:y.candidates,searchedDirectories:y.searchedDirectories,suggestion:Bt},wired:false}}}async function discoverAndWireBackend(t,u){var m,g;if(u!=="nearby"){return{status:"skipped",mode:u}}const y=p().join(t,"apitogo.config.json");if(!await run_scaffold_discovery_pathExists(y)){return{status:"not_found"}}try{const u=JSON.parse(await(0,ot.readFile)(y,"utf8"));const p=u.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{};if(typeof p.sourceDirectory==="string"&&p.sourceDirectory.trim()){return{status:"already_configured",sourceDirectory:p.sourceDirectory,runtime:(m=p.runtime)!==null&&m!==void 0?m:null,runtimeVersion:(g=p.runtimeVersion)!==null&&g!==void 0?g:null}}const v=await detectParentBackend(t);if(!v){return{status:"not_found"}}u.backend={...p,sourceDirectory:v.sourceDirectory,runtime:v.runtime,runtimeVersion:v.runtimeVersion};await(0,ot.writeFile)(y,`${JSON.stringify(u,null,2)}\n`,"utf8");return{status:"wired",directory:v.directory,sourceDirectory:v.sourceDirectory,runtime:v.runtime,runtimeVersion:v.runtimeVersion,marker:v.marker}}catch(t){return{status:"wire_failed",error:t instanceof Error?t.message:String(t)}}}async function runScaffoldDiscovery(t,u){var p;const m=(p=u===null||u===void 0?void 0:u.openapiSearch)!==null&&p!==void 0?p:"nearby";const{openApiDiscovery:g}=await discoverAndWireOpenApiLite(t,m);const y=await discoverAndWireDocs(t);const v=await discoverAndWireBackend(t,m);return{openApiDiscovery:g,docsDiscovery:y,backendDiscovery:v}}const qt=require("node:stream/promises");var Kt=__nccwpck_require__(4434);var Yt=__nccwpck_require__(7515);const Jt=require("node:string_decoder");var Zt=__nccwpck_require__(6928);const Xt=require("assert");var Qt=__nccwpck_require__(181);const er=require("zlib");var rr=__nccwpck_require__.t(er,2);var sr=Object.defineProperty;var Ar=(t,u)=>{for(var p in u)sr(t,p,{get:u[p],enumerable:!0})};var ir=typeof process=="object"&&process?process:{stdout:null,stderr:null},Cr=t=>!!t&&typeof t=="object"&&(t instanceof hs||t instanceof z||Fr(t)||kr(t)),Fr=t=>!!t&&typeof t=="object"&&t instanceof V.EventEmitter&&typeof t.pipe=="function"&&t.pipe!==z.Writable.prototype.pipe,kr=t=>!!t&&typeof t=="object"&&t instanceof V.EventEmitter&&typeof t.write=="function"&&typeof t.end=="function",nr=Symbol("EOF"),cr=Symbol("maybeEmitEnd"),lr=Symbol("emittedEnd"),mr=Symbol("emittingEnd"),gr=Symbol("emittedError"),yr=Symbol("closed"),_r=Symbol("read"),br=Symbol("flush"),Er=Symbol("flushChunk"),Sr=Symbol("encoding"),Or=Symbol("decoder"),Rr=Symbol("flowing"),xr=Symbol("paused"),Ir=Symbol("resume"),Nr=Symbol("buffer"),Dr=Symbol("pipes"),Lr=Symbol("bufferLength"),Hr=Symbol("bufferPush"),Vr=Symbol("bufferShift"),Gr=Symbol("objectMode"),Wr=Symbol("destroyed"),Kr=Symbol("error"),Yr=Symbol("emitData"),Xr=Symbol("emitEnd"),es=Symbol("emitEnd2"),ts=Symbol("async"),rs=Symbol("abort"),ss=Symbol("aborted"),is=Symbol("signal"),ns=Symbol("dataListeners"),os=Symbol("discarded"),te=t=>Promise.resolve().then(t),vr=t=>t(),Mr=t=>t==="end"||t==="finish"||t==="prefinish",Br=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Pr=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),as=class{src;dest;opts;ondrain;constructor(t,u,p){this.src=t,this.dest=u,this.opts=p,this.ondrain=()=>t[Ir](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ls=class extends as{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)}},zr=t=>!!t.objectMode,Ur=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",hs=class extends V.EventEmitter{[Rr]=!1;[xr]=!1;[Dr]=[];[Nr]=[];[Gr];[Sr];[ts];[Or];[nr]=!1;[lr]=!1;[mr]=!1;[yr]=!1;[gr]=null;[Lr]=0;[Wr]=!1;[is];[ss]=!1;[ns]=0;[os]=!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");zr(u)?(this[Gr]=!0,this[Sr]=null):Ur(u)?(this[Sr]=u.encoding,this[Gr]=!1):(this[Gr]=!1,this[Sr]=null),this[ts]=!!u.async,this[Or]=this[Sr]?new Jt.StringDecoder(this[Sr]):null,u&&u.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Nr]}),u&&u.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Dr]});let{signal:p}=u;p&&(this[is]=p,p.aborted?this[rs]():p.addEventListener("abort",(()=>this[rs]())))}get bufferLength(){return this[Lr]}get encoding(){return this[Sr]}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[Gr]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[ts]}set async(t){this[ts]=this[ts]||!!t}[rs](){this[ss]=!0,this.emit("abort",this[is]?.reason),this.destroy(this[is]?.reason)}get aborted(){return this[ss]}set aborted(t){}write(t,u,p){if(this[ss])return!1;if(this[nr])throw new Error("write after end");if(this[Wr])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[ts]?te:vr;if(!this[Gr]&&!Buffer.isBuffer(t)){if(Pr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Br(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Gr]?(this[Rr]&&this[Lr]!==0&&this[br](!0),this[Rr]?this.emit("data",t):this[Hr](t),this[Lr]!==0&&this.emit("readable"),p&&m(p),this[Rr]):t.length?(typeof t=="string"&&!(u===this[Sr]&&!this[Or]?.lastNeed)&&(t=Buffer.from(t,u)),Buffer.isBuffer(t)&&this[Sr]&&(t=this[Or].write(t)),this[Rr]&&this[Lr]!==0&&this[br](!0),this[Rr]?this.emit("data",t):this[Hr](t),this[Lr]!==0&&this.emit("readable"),p&&m(p),this[Rr]):(this[Lr]!==0&&this.emit("readable"),p&&m(p),this[Rr])}read(t){if(this[Wr])return null;if(this[os]=!1,this[Lr]===0||t===0||t&&t>this[Lr])return this[cr](),null;this[Gr]&&(t=null),this[Nr].length>1&&!this[Gr]&&(this[Nr]=[this[Sr]?this[Nr].join(""):Buffer.concat(this[Nr],this[Lr])]);let u=this[_r](t||null,this[Nr][0]);return this[cr](),u}[_r](t,u){if(this[Gr])this[Vr]();else{let p=u;t===p.length||t===null?this[Vr]():typeof p=="string"?(this[Nr][0]=p.slice(t),u=p.slice(0,t),this[Lr]-=t):(this[Nr][0]=p.subarray(t),u=p.subarray(0,t),this[Lr]-=t)}return this.emit("data",u),!this[Nr].length&&!this[nr]&&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[nr]=!0,this.writable=!1,(this[Rr]||!this[xr])&&this[cr](),this}[Ir](){this[Wr]||(!this[ns]&&!this[Dr].length&&(this[os]=!0),this[xr]=!1,this[Rr]=!0,this.emit("resume"),this[Nr].length?this[br]():this[nr]?this[cr]():this.emit("drain"))}resume(){return this[Ir]()}pause(){this[Rr]=!1,this[xr]=!0,this[os]=!1}get destroyed(){return this[Wr]}get flowing(){return this[Rr]}get paused(){return this[xr]}[Hr](t){this[Gr]?this[Lr]+=1:this[Lr]+=t.length,this[Nr].push(t)}[Vr](){return this[Gr]?this[Lr]-=1:this[Lr]-=this[Nr][0].length,this[Nr].shift()}[br](t=!1){do{}while(this[Er](this[Vr]())&&this[Nr].length);!t&&!this[Nr].length&&!this[nr]&&this.emit("drain")}[Er](t){return this.emit("data",t),this[Rr]}pipe(t,u){if(this[Wr])return t;this[os]=!1;let p=this[lr];return u=u||{},t===ir.stdout||t===ir.stderr?u.end=!1:u.end=u.end!==!1,u.proxyErrors=!!u.proxyErrors,p?u.end&&t.end():(this[Dr].push(u.proxyErrors?new ls(this,t,u):new as(this,t,u)),this[ts]?te((()=>this[Ir]())):this[Ir]()),t}unpipe(t){let u=this[Dr].find((u=>u.dest===t));u&&(this[Dr].length===1?(this[Rr]&&this[ns]===0&&(this[Rr]=!1),this[Dr]=[]):this[Dr].splice(this[Dr].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[os]=!1,this[ns]++,!this[Dr].length&&!this[Rr]&&this[Ir]();else if(t==="readable"&&this[Lr]!==0)super.emit("readable");else if(Mr(t)&&this[lr])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[gr]){let t=u;this[ts]?te((()=>t.call(this,this[gr]))):t.call(this,this[gr])}return p}removeListener(t,u){return this.off(t,u)}off(t,u){let p=super.off(t,u);return t==="data"&&(this[ns]=this.listeners("data").length,this[ns]===0&&!this[os]&&!this[Dr].length&&(this[Rr]=!1)),p}removeAllListeners(t){let u=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[ns]=0,!this[os]&&!this[Dr].length&&(this[Rr]=!1)),u}get emittedEnd(){return this[lr]}[cr](){!this[mr]&&!this[lr]&&!this[Wr]&&this[Nr].length===0&&this[nr]&&(this[mr]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[yr]&&this.emit("close"),this[mr]=!1)}emit(t,...u){let p=u[0];if(t!=="error"&&t!=="close"&&t!==Wr&&this[Wr])return!1;if(t==="data")return!this[Gr]&&!p?!1:this[ts]?(te((()=>this[Yr](p))),!0):this[Yr](p);if(t==="end")return this[Xr]();if(t==="close"){if(this[yr]=!0,!this[lr]&&!this[Wr])return!1;let t=super.emit("close");return this.removeAllListeners("close"),t}else if(t==="error"){this[gr]=p,super.emit(Kr,p);let t=!this[is]||this.listeners("error").length?super.emit("error",p):!1;return this[cr](),t}else if(t==="resume"){let t=super.emit("resume");return this[cr](),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[cr](),m}[Yr](t){for(let u of this[Dr])u.dest.write(t)===!1&&this.pause();let u=this[os]?!1:super.emit("data",t);return this[cr](),u}[Xr](){return this[lr]?!1:(this[lr]=!0,this.readable=!1,this[ts]?(te((()=>this[es]())),!0):this[es]())}[es](){if(this[Or]){let t=this[Or].end();if(t){for(let u of this[Dr])u.dest.write(t);this[os]||super.emit("data",t)}}for(let t of this[Dr])t.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Gr]||(t.dataLength=0);let u=this.promise();return this.on("data",(u=>{t.push(u),this[Gr]||(t.dataLength+=u.length)})),await u,t}async concat(){if(this[Gr])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Sr]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise(((t,u)=>{this.on(Wr,(()=>u(new Error("stream destroyed")))),this.on("error",(t=>u(t))),this.on("end",(()=>t()))}))}[Symbol.asyncIterator](){this[os]=!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[nr])return e();let p,m,h=t=>{this.off("data",a),this.off("end",l),this.off(Wr,c),e(),m(t)},a=t=>{this.off("error",h),this.off("end",l),this.off(Wr,c),this.pause(),p({value:t,done:!!this[nr]})},l=()=>{this.off("error",h),this.off("data",a),this.off(Wr,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(Wr,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[os]=!1;let t=!1,e=()=>(this.pause(),this.off(Kr,e),this.off(Wr,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(Kr,e),this.once(Wr,e),{next:i,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Wr])return t?this.emit("error",t):this.emit(Wr),this;this[Wr]=!0,this[os]=!0,this[Nr].length=0,this[Lr]=0;let u=this;return typeof u.close=="function"&&!this[yr]&&u.close(),t?this.emit("error",t):this.emit(Wr),this}static get isStream(){return Cr}};var ps=Yt.writev,ms=Symbol("_autoClose"),gs=Symbol("_close"),ys=Symbol("_ended"),vs=Symbol("_fd"),_s=Symbol("_finished"),bs=Symbol("_flags"),ws=Symbol("_flush"),Es=Symbol("_handleChunk"),Ss=Symbol("_makeBuf"),$s=Symbol("_mode"),Os=Symbol("_needDrain"),Rs=Symbol("_onerror"),xs=Symbol("_onopen"),Ts=Symbol("_onread"),Ns=Symbol("_onwrite"),Ds=Symbol("_open"),js=Symbol("_path"),Ls=Symbol("_pos"),Ms=Symbol("_queue"),Hs=Symbol("_read"),Gs=Symbol("_readSize"),Ws=Symbol("_reading"),qs=Symbol("_remain"),Ks=Symbol("_size"),Ys=Symbol("_write"),Js=Symbol("_writing"),Zs=Symbol("_defaultFlag"),Xs=Symbol("_errored"),Qs=class extends hs{[Xs]=!1;[vs];[js];[Gs];[Ws]=!1;[Ks];[qs];[ms];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[Xs]=!1,this[vs]=typeof u.fd=="number"?u.fd:void 0,this[js]=t,this[Gs]=u.readSize||16*1024*1024,this[Ws]=!1,this[Ks]=typeof u.size=="number"?u.size:1/0,this[qs]=this[Ks],this[ms]=typeof u.autoClose=="boolean"?u.autoClose:!0,typeof this[vs]=="number"?this[Hs]():this[Ds]()}get fd(){return this[vs]}get path(){return this[js]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[Ds](){Yt.open(this[js],"r",((t,u)=>this[xs](t,u)))}[xs](t,u){t?this[Rs](t):(this[vs]=u,this.emit("open",u),this[Hs]())}[Ss](){return Buffer.allocUnsafe(Math.min(this[Gs],this[qs]))}[Hs](){if(!this[Ws]){this[Ws]=!0;let t=this[Ss]();if(t.length===0)return process.nextTick((()=>this[Ts](null,0,t)));Yt.read(this[vs],t,0,t.length,null,((t,u,p)=>this[Ts](t,u,p)))}}[Ts](t,u,p){this[Ws]=!1,t?this[Rs](t):this[Es](u,p)&&this[Hs]()}[gs](){if(this[ms]&&typeof this[vs]=="number"){let t=this[vs];this[vs]=void 0,Yt.close(t,(t=>t?this.emit("error",t):this.emit("close")))}}[Rs](t){this[Ws]=!0,this[gs](),this.emit("error",t)}[Es](t,u){let p=!1;return this[qs]-=t,t>0&&(p=super.write(t<u.length?u.subarray(0,t):u)),(t===0||this[qs]<=0)&&(p=!1,this[gs](),super.end()),p}emit(t,...u){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[vs]=="number"&&this[Hs](),!1;case"error":return this[Xs]?!1:(this[Xs]=!0,super.emit(t,...u));default:return super.emit(t,...u)}}},ei=class extends Qs{[Ds](){let t=!0;try{this[xs](null,Yt.openSync(this[js],"r")),t=!1}finally{t&&this[gs]()}}[Hs](){let t=!0;try{if(!this[Ws]){this[Ws]=!0;do{let t=this[Ss](),u=t.length===0?0:Yt.readSync(this[vs],t,0,t.length,null);if(!this[Es](u,t))break}while(!0);this[Ws]=!1}t=!1}finally{t&&this[gs]()}}[gs](){if(this[ms]&&typeof this[vs]=="number"){let t=this[vs];this[vs]=void 0,Yt.closeSync(t),this.emit("close")}}},ti=class extends Kt{readable=!1;writable=!0;[Xs]=!1;[Js]=!1;[ys]=!1;[Ms]=[];[Os]=!1;[js];[$s];[ms];[vs];[Zs];[bs];[_s]=!1;[Ls];constructor(t,u){u=u||{},super(u),this[js]=t,this[vs]=typeof u.fd=="number"?u.fd:void 0,this[$s]=u.mode===void 0?438:u.mode,this[Ls]=typeof u.start=="number"?u.start:void 0,this[ms]=typeof u.autoClose=="boolean"?u.autoClose:!0;let p=this[Ls]!==void 0?"r+":"w";this[Zs]=u.flags===void 0,this[bs]=u.flags===void 0?p:u.flags,this[vs]===void 0&&this[Ds]()}emit(t,...u){if(t==="error"){if(this[Xs])return!1;this[Xs]=!0}return super.emit(t,...u)}get fd(){return this[vs]}get path(){return this[js]}[Rs](t){this[gs](),this[Js]=!0,this.emit("error",t)}[Ds](){Yt.open(this[js],this[bs],this[$s],((t,u)=>this[xs](t,u)))}[xs](t,u){this[Zs]&&this[bs]==="r+"&&t&&t.code==="ENOENT"?(this[bs]="w",this[Ds]()):t?this[Rs](t):(this[vs]=u,this.emit("open",u),this[Js]||this[ws]())}end(t,u){return t&&this.write(t,u),this[ys]=!0,!this[Js]&&!this[Ms].length&&typeof this[vs]=="number"&&this[Ns](null,0),this}write(t,u){return typeof t=="string"&&(t=Buffer.from(t,u)),this[ys]?(this.emit("error",new Error("write() after end()")),!1):this[vs]===void 0||this[Js]||this[Ms].length?(this[Ms].push(t),this[Os]=!0,!1):(this[Js]=!0,this[Ys](t),!0)}[Ys](t){Yt.write(this[vs],t,0,t.length,this[Ls],((t,u)=>this[Ns](t,u)))}[Ns](t,u){t?this[Rs](t):(this[Ls]!==void 0&&typeof u=="number"&&(this[Ls]+=u),this[Ms].length?this[ws]():(this[Js]=!1,this[ys]&&!this[_s]?(this[_s]=!0,this[gs](),this.emit("finish")):this[Os]&&(this[Os]=!1,this.emit("drain"))))}[ws](){if(this[Ms].length===0)this[ys]&&this[Ns](null,0);else if(this[Ms].length===1)this[Ys](this[Ms].pop());else{let t=this[Ms];this[Ms]=[],ps(this[vs],t,this[Ls],((t,u)=>this[Ns](t,u)))}}[gs](){if(this[ms]&&typeof this[vs]=="number"){let t=this[vs];this[vs]=void 0,Yt.close(t,(t=>t?this.emit("error",t):this.emit("close")))}}},ri=class extends ti{[Ds](){let t;if(this[Zs]&&this[bs]==="r+")try{t=Yt.openSync(this[js],this[bs],this[$s])}catch(t){if(t?.code==="ENOENT")return this[bs]="w",this[Ds]();throw t}else t=Yt.openSync(this[js],this[bs],this[$s]);this[xs](null,t)}[gs](){if(this[ms]&&typeof this[vs]=="number"){let t=this[vs];this[vs]=void 0,Yt.closeSync(t),this.emit("close")}}[Ys](t){let u=!0;try{this[Ns](null,Yt.writeSync(this[vs],t,0,t.length,this[Ls])),u=!1}finally{if(u)try{this[gs]()}catch{}}}};var si=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"]]),As=t=>!!t.sync&&!!t.file,Is=t=>!t.sync&&!!t.file,Cs=t=>!!t.sync&&!t.file,Fs=t=>!t.sync&&!t.file;var ks=t=>!!t.file;var Zr=t=>{let u=si.get(t);return u||t},re=(t={})=>{if(!t)return{};let u={};for(let[p,m]of Object.entries(t)){let t=Zr(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(((y=[],v,b)=>{Array.isArray(y)&&(v=y,y={}),typeof v=="function"&&(b=v,v=void 0),v?v=Array.from(v):v=[];let w=re(y);if(g?.(w,v),As(w)){if(typeof b=="function")throw new TypeError("callback not supported for sync tar functions");return t(w,v)}else if(Is(w)){let t=u(w,v),p=b||void 0;return p?t.then((()=>p()),p):t}else if(Cs(w)){if(typeof b=="function")throw new TypeError("callback not supported for sync tar functions");return p(w,v)}else if(Fs(w)){if(typeof b=="function")throw new TypeError("callback only supported with file option");return m(w,v)}else throw new Error("impossible options??")}),{syncFile:t,asyncFile:u,syncNoFile:p,asyncNoFile:m,validate:g});var ii=er.constants||{ZLIB_VERNUM:4736},ni=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},ii));var oi=Qt.Buffer.concat,ai=Object.getOwnPropertyDescriptor(Qt.Buffer,"concat"),$r=t=>t,ci=ai?.writable===!0||ai?.set!==void 0?t=>{Qt.Buffer.concat=t?$r:oi}:t=>{},li=Symbol("_superWrite"),ui=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"}},hi=Symbol("flushFlag"),fi=class extends hs{#y=!1;#v=!1;#_;#b;#w;#E;#S;get sawError(){return this.#y}get handle(){return this.#E}get flushFlag(){return this.#_}constructor(t,u){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#_=t.flush??0,this.#b=t.finishFlush??0,this.#w=t.fullFlushFlag??0,typeof rr[u]!="function")throw new TypeError("Compression method not supported: "+u);try{this.#E=new rr[u](t)}catch(t){throw new ui(t,this.constructor)}this.#S=t=>{this.#y||(this.#y=!0,this.close(),this.emit("error",t))},this.#E?.on("error",(t=>this.#S(new ui(t)))),this.once("end",(()=>this.close))}close(){this.#E&&(this.#E.close(),this.#E=void 0,this.emit("close"))}reset(){if(!this.#y)return Xt(this.#E,"zlib binding closed"),this.#E.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#w),this.write(Object.assign(Qt.Buffer.alloc(0),{[hi]: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.#b),this.#v=!0,super.end(p)}get ended(){return this.#v}[li](t){return super.write(t)}write(t,u,p){if(typeof u=="function"&&(p=u,u="utf8"),typeof t=="string"&&(t=Qt.Buffer.from(t,u)),this.#y)return;Xt(this.#E,"zlib binding closed");let m=this.#E._handle,g=m.close;m.close=()=>{};let y=this.#E.close;this.#E.close=()=>{},ci(!0);let v;try{let u=typeof t[hi]=="number"?t[hi]:this.#_;v=this.#E._processChunk(t,u),ci(!1)}catch(t){ci(!1),this.#S(new ui(t,this.write))}finally{this.#E&&(this.#E._handle=m,m.close=g,this.#E.close=y,this.#E.removeAllListeners("error"))}this.#E&&this.#E.on("error",(t=>this.#S(new ui(t,this.write))));let b;if(v)if(Array.isArray(v)&&v.length>0){let t=v[0];b=this[li](Qt.Buffer.from(t));for(let t=1;t<v.length;t++)b=this[li](v[t])}else b=this[li](Qt.Buffer.from(v));return p&&p(),b}},pi=class extends fi{#y;#v;constructor(t,u){t=t||{},t.flush=t.flush||ni.Z_NO_FLUSH,t.finishFlush=t.finishFlush||ni.Z_FINISH,t.fullFlushFlag=ni.Z_FULL_FLUSH,super(t,u),this.#y=t.level,this.#v=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.#y!==t||this.#v!==u){this.flush(ni.Z_SYNC_FLUSH),Xt(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.#y=t,this.#v=u)}}}};var mi=class extends pi{#y;constructor(t){super(t,"Gzip"),this.#y=t&&!!t.portable}[li](t){return this.#y?(this.#y=!1,t[9]=255,super[li](t)):super[li](t)}};var gi=class extends pi{constructor(t){super(t,"Unzip")}},yi=class extends fi{constructor(t,u){t=t||{},t.flush=t.flush||ni.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||ni.BROTLI_OPERATION_FINISH,t.fullFlushFlag=ni.BROTLI_OPERATION_FLUSH,super(t,u)}},vi=class extends yi{constructor(t){super(t,"BrotliCompress")}},_i=class extends yi{constructor(t){super(t,"BrotliDecompress")}},bi=class extends fi{constructor(t,u){t=t||{},t.flush=t.flush||ni.ZSTD_e_continue,t.finishFlush=t.finishFlush||ni.ZSTD_e_end,t.fullFlushFlag=ni.ZSTD_e_flush,super(t,u)}},wi=class extends bi{constructor(t){super(t,"ZstdCompress")}},Ei=class extends bi{constructor(t){super(t,"ZstdDecompress")}};var Bs=(t,u)=>{if(Number.isSafeInteger(t))t<0?jr(t,u):qr(t,u);else throw Error("cannot encode number outside of javascript safe integer range");return u},qr=(t,u)=>{u[0]=128;for(var p=u.length;p>1;p--)u[p-1]=t&255,t=Math.floor(t/256)},jr=(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]=zs(g):g===0?u[m-1]=0:(p=!0,u[m-1]=Us(g))}},Ps=t=>{let u=t[0],p=u===128?Jr(t.subarray(1,t.length)):u===255?Qr(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},Qr=t=>{for(var u=t.length,p=0,m=!1,g=u-1;g>-1;g--){var y=Number(t[g]),v;m?v=zs(y):y===0?v=y:(m=!0,v=Us(y)),v!==0&&(p-=v*Math.pow(256,u-g-1))}return p},Jr=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},zs=t=>(255^t)&255,Us=t=>(255^t)+1&255;var Si={};Ar(Si,{code:()=>Oi,isCode:()=>oe,isName:()=>en,name:()=>Ai});var oe=t=>Ai.has(t),en=t=>Oi.has(t),Ai=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"]]),Oi=new Map(Array.from(Ai).map((t=>[t[1],t[0]])));var Ri=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#y="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.#v(t)}decode(t,u,p,m){if(u||(u=0),!t||!(t.length>=u+512))throw new Error("need 512 bytes for header");this.path=p?.path??Tt(t,u,100),this.mode=p?.mode??m?.mode??at(t,u+100,8),this.uid=p?.uid??m?.uid??at(t,u+108,8),this.gid=p?.gid??m?.gid??at(t,u+116,8),this.size=p?.size??m?.size??at(t,u+124,12),this.mtime=p?.mtime??m?.mtime??Bi(t,u+136,12),this.cksum=at(t,u+148,12),m&&this.#v(m,!0),p&&this.#v(p);let g=Tt(t,u+156,1);if(oe(g)&&(this.#y=g||"0"),this.#y==="0"&&this.path.slice(-1)==="/"&&(this.#y="5"),this.#y==="5"&&(this.size=0),this.linkpath=Tt(t,u+157,100),t.subarray(u+257,u+265).toString()==="ustar\x0000")if(this.uname=p?.uname??m?.uname??Tt(t,u+265,32),this.gname=p?.gname??m?.gname??Tt(t,u+297,32),this.devmaj=p?.devmaj??m?.devmaj??at(t,u+329,8)??0,this.devmin=p?.devmin??m?.devmin??at(t,u+337,8)??0,t[u+475]!==0){let p=Tt(t,u+345,155);this.path=p+"/"+this.path}else{let g=Tt(t,u+345,130);g&&(this.path=g+"/"+this.path),this.atime=p?.atime??m?.atime??Bi(t,u+476,12),this.ctime=p?.ctime??m?.ctime??Bi(t,u+488,12)}let y=256;for(let p=u;p<u+148;p++)y+=t[p];for(let p=u+156;p<u+512;p++)y+=t[p];this.cksumValid=y===this.cksum,this.cksum===void 0&&y===256&&(this.nullBlock=!0)}#v(t,u=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter((([t,p])=>!(p==null||t==="path"&&u||t==="linkpath"&&u||t==="global")))))}encode(t,u=0){if(t||(t=this.block=Buffer.alloc(512)),this.#y==="Unsupported"&&(this.#y="0"),!(t.length>=u+512))throw new Error("need 512 bytes for header");let p=this.ctime||this.atime?130:155,m=sn(this.path||"",p),g=m[0],y=m[1];this.needPax=!!m[2],this.needPax=xt(t,u,100,g)||this.needPax,this.needPax=lt(t,u+100,8,this.mode)||this.needPax,this.needPax=lt(t,u+108,8,this.uid)||this.needPax,this.needPax=lt(t,u+116,8,this.gid)||this.needPax,this.needPax=lt(t,u+124,12,this.size)||this.needPax,this.needPax=Pi(t,u+136,12,this.mtime)||this.needPax,t[u+156]=this.#y.charCodeAt(0),this.needPax=xt(t,u+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",u+257,8),this.needPax=xt(t,u+265,32,this.uname)||this.needPax,this.needPax=xt(t,u+297,32,this.gname)||this.needPax,this.needPax=lt(t,u+329,8,this.devmaj)||this.needPax,this.needPax=lt(t,u+337,8,this.devmin)||this.needPax,this.needPax=xt(t,u+345,p,y)||this.needPax,t[u+475]!==0?this.needPax=xt(t,u+345,155,y)||this.needPax:(this.needPax=xt(t,u+345,130,y)||this.needPax,this.needPax=Pi(t,u+476,12,this.atime)||this.needPax,this.needPax=Pi(t,u+488,12,this.ctime)||this.needPax);let v=256;for(let p=u;p<u+148;p++)v+=t[p];for(let p=u+156;p<u+512;p++)v+=t[p];return this.cksum=v,lt(t,u+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#y==="Unsupported"?this.#y:Ai.get(this.#y)}get typeKey(){return this.#y}set type(t){let u=String(Oi.get(t));if(oe(u)||u==="Unsupported")this.#y=u;else if(oe(t))this.#y=t;else throw new TypeError("invalid entry type: "+t)}},sn=(t,p)=>{let m=t,g="",y,v=u.posix.parse(t).root||".";if(Buffer.byteLength(m)<100)y=[m,g,!1];else{g=u.posix.dirname(m),m=u.posix.basename(m);do{Buffer.byteLength(m)<=100&&Buffer.byteLength(g)<=p?y=[m,g,!1]:Buffer.byteLength(m)>100&&Buffer.byteLength(g)<=p?y=[m.slice(0,99),g,!0]:(m=u.posix.join(u.posix.basename(g),m),g=u.posix.dirname(g))}while(g!==v&&y===void 0);y||(y=[t.slice(0,99),"",!0])}return y},Tt=(t,u,p)=>t.subarray(u,u+p).toString("utf8").replace(/\0.*/,""),Bi=(t,u,p)=>rn(at(t,u,p)),rn=t=>t===void 0?void 0:new Date(t*1e3),at=(t,u,p)=>Number(t[u])&128?Ps(t.subarray(u,u+p)):on(t,u,p),nn=t=>isNaN(t)?void 0:t,on=(t,u,p)=>nn(parseInt(t.subarray(u,u+p).toString("utf8").replace(/\0.*$/,"").trim(),8)),xi={12:8589934591,8:2097151},lt=(t,u,p,m)=>m===void 0?!1:m>xi[p]||m<0?(Bs(m,t.subarray(u,u+p)),!0):(an(t,u,p,m),!1),an=(t,u,p,m)=>t.write(ln(m,p),u,p,"ascii"),ln=(t,u)=>cn(Math.floor(t).toString(8),u),cn=(t,u)=>(t.length===u-1?t:new Array(u-t.length-1).join("0")+t+" ")+"\0",Pi=(t,u,p,m)=>m===void 0?!1:lt(t,u,p,m.getTime()/1e3),Ti=new Array(156).join("\0"),xt=(t,u,p,m)=>m===void 0?!1:(t.write(m+Ti,u,p,"utf8"),m.length!==Buffer.byteLength(m)||m.length>p);var ki=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 p=Buffer.byteLength(t),m=512*Math.ceil(1+p/512),g=Buffer.allocUnsafe(m);for(let t=0;t<512;t++)g[t]=0;new Ri({path:("PaxHeader/"+(0,u.basename)(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:p,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(g),g.write(t,512,p,"utf8");for(let t=p+512;t<g.length;t++)g[t]=0;return g}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),y=Math.floor(Math.log(g)/Math.log(10))+1;return g+y>=Math.pow(10,y)&&(y+=1),y+g+m}static parse(t,u,p=!1){return new s(un(mn(t),u),p)}},un=(t,u)=>u?Object.assign({},u,t):t,mn=t=>t.replace(/\n$/,"").split(`\n`).reduce(pn,Object.create(null)),pn=(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 y=g.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),v=m.join("=");return t[y]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(y)?new Date(Number(v)*1e3):/^[0-9]+$/.test(v)?+v:v,t};var Ci=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ii=Ci!=="win32"?t=>t:t=>t&&t.replace(/\\/g,"/");var Ni=class extends hs{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=Ii(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?Ii(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,u&&this.#y(u),p&&this.#y(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))}#y(t,u=!1){t.path&&(t.path=Ii(t.path)),t.linkpath&&(t.linkpath=Ii(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter((([t,p])=>!(p==null||t==="path"&&u)))))}};var Lt=(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 Di=1024*1024,ji=Buffer.from([31,139]),Li=Buffer.from([40,181,47,253]),Mi=Math.max(ji.length,Li.length),Fi=Symbol("state"),Ui=Symbol("writeEntry"),Hi=Symbol("readEntry"),Vi=Symbol("nextEntry"),zi=Symbol("processEntry"),Gi=Symbol("extendedHeader"),Wi=Symbol("globalExtendedHeader"),qi=Symbol("meta"),Ji=Symbol("emitMeta"),Zi=Symbol("buffer"),Xi=Symbol("queue"),Qi=Symbol("ended"),tn=Symbol("emittedEnd"),hn=Symbol("emit"),dn=Symbol("unzip"),fn=Symbol("consumeChunk"),gn=Symbol("consumeChunkSub"),yn=Symbol("consumeBody"),bn=Symbol("consumeMeta"),wn=Symbol("consumeHeader"),En=Symbol("consuming"),Sn=Symbol("bufferConcat"),An=Symbol("maybeEnd"),xn=Symbol("writing"),Nn=Symbol("aborted"),Dn=Symbol("onDone"),Ln=Symbol("sawValidEntry"),Un=Symbol("sawNullBlock"),Hn=Symbol("sawEOF"),Vn=Symbol("closeStream"),Rn=()=>!0,zn=class extends Kt.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Xi]=[];[Zi];[Hi];[Ui];[Fi]="begin";[qi]="";[Gi];[Wi];[Qi]=!1;[dn];[Nn]=!1;[Ln];[Un]=!1;[Hn]=!1;[xn]=!1;[En]=!1;[tn]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Dn,(()=>{(this[Fi]==="begin"||this[Ln]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")})),t.ondone?this.on(Dn,t.ondone):this.on(Dn,(()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")})),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Di,this.filter=typeof t.filter=="function"?t.filter:Rn;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[Vn]())),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,u,p={}){Lt(this,t,u,p)}[wn](t,u){this[Ln]===void 0&&(this[Ln]=!1);let p;try{p=new Ri(t,u,this[Gi],this[Wi])}catch(t){return this.warn("TAR_ENTRY_INVALID",t)}if(p.nullBlock)this[Un]?(this[Hn]=!0,this[Fi]==="begin"&&(this[Fi]="header"),this[hn]("eof")):(this[Un]=!0,this[hn]("nullBlock"));else if(this[Un]=!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[Ui]=new Ni(p,this[Gi],this[Wi]);if(!this[Ln])if(t.remain){let o=()=>{t.invalid||(this[Ln]=!0)};t.on("end",o)}else this[Ln]=!0;t.meta?t.size>this.maxMetaEntrySize?(t.ignore=!0,this[hn]("ignoredEntry",t),this[Fi]="ignore",t.resume()):t.size>0&&(this[qi]="",t.on("data",(t=>this[qi]+=t)),this[Fi]="meta"):(this[Gi]=void 0,t.ignore=t.ignore||!this.filter(t.path,t),t.ignore?(this[hn]("ignoredEntry",t),this[Fi]=t.remain?"ignore":"header",t.resume()):(t.remain?this[Fi]="body":(this[Fi]="header",t.end()),this[Hi]?this[Xi].push(t):(this[Xi].push(t),this[Vi]())))}}}[Vn](){queueMicrotask((()=>this.emit("close")))}[zi](t){let u=!0;if(!t)this[Hi]=void 0,u=!1;else if(Array.isArray(t)){let[u,...p]=t;this.emit(u,...p)}else this[Hi]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",(()=>this[Vi]())),u=!1);return u}[Vi](){do{}while(this[zi](this[Xi].shift()));if(!this[Xi].length){let t=this[Hi];!t||t.flowing||t.size===t.remain?this[xn]||this.emit("drain"):t.once("drain",(()=>this.emit("drain")))}}[yn](t,u){let p=this[Ui];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[Fi]="header",this[Ui]=void 0,p.end()),g.length}[bn](t,u){let p=this[Ui],m=this[yn](t,u);return!this[Ui]&&p&&this[Ji](p),m}[hn](t,u,p){!this[Xi].length&&!this[Hi]?this.emit(t,u,p):this[Xi].push([t,u,p])}[Ji](t){switch(this[hn]("meta",this[qi]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Gi]=ki.parse(this[qi],this[Gi],!1);break;case"GlobalExtendedHeader":this[Wi]=ki.parse(this[qi],this[Wi],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let t=this[Gi]??Object.create(null);this[Gi]=t,t.path=this[qi].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let t=this[Gi]||Object.create(null);this[Gi]=t,t.linkpath=this[qi].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[Nn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}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[Nn])return p?.(),!1;if((this[dn]===void 0||this.brotli===void 0&&this[dn]===!1)&&t){if(this[Zi]&&(t=Buffer.concat([this[Zi],t]),this[Zi]=void 0),t.length<Mi)return this[Zi]=t,p?.(),!0;for(let u=0;this[dn]===void 0&&u<ji.length;u++)t[u]!==ji[u]&&(this[dn]=!1);let u=!1;if(this[dn]===!1&&this.zstd!==!1){u=!0;for(let p=0;p<Li.length;p++)if(t[p]!==Li[p]){u=!1;break}}let m=this.brotli===void 0&&!u;if(this[dn]===!1&&m)if(t.length<512)if(this[Qi])this.brotli=!0;else return this[Zi]=t,p?.(),!0;else try{new Ri(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[dn]===void 0||this[dn]===!1&&(this.brotli||u)){let m=this[Qi];this[Qi]=!1,this[dn]=this[dn]===void 0?new gi({}):u?new Ei({}):new _i({}),this[dn].on("data",(t=>this[fn](t))),this[dn].on("error",(t=>this.abort(t))),this[dn].on("end",(()=>{this[Qi]=!0,this[fn]()})),this[xn]=!0;let g=!!this[dn][m?"end":"write"](t);return this[xn]=!1,p?.(),g}}this[xn]=!0,this[dn]?this[dn].write(t):this[fn](t),this[xn]=!1;let m=this[Xi].length?!1:this[Hi]?this[Hi].flowing:!0;return!m&&!this[Xi].length&&this[Hi]?.once("drain",(()=>this.emit("drain"))),p?.(),m}[Sn](t){t&&!this[Nn]&&(this[Zi]=this[Zi]?Buffer.concat([this[Zi],t]):t)}[An](){if(this[Qi]&&!this[tn]&&!this[Nn]&&!this[En]){this[tn]=!0;let t=this[Ui];if(t&&t.blockRemain){let u=this[Zi]?this[Zi].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${u} available)`,{entry:t}),this[Zi]&&t.write(this[Zi]),t.end()}this[hn](Dn)}}[fn](t){if(this[En]&&t)this[Sn](t);else if(!t&&!this[Zi])this[An]();else if(t){if(this[En]=!0,this[Zi]){this[Sn](t);let u=this[Zi];this[Zi]=void 0,this[gn](u)}else this[gn](t);for(;this[Zi]&&this[Zi]?.length>=512&&!this[Nn]&&!this[Hn];){let t=this[Zi];this[Zi]=void 0,this[gn](t)}this[En]=!1}(!this[Zi]||this[Qi])&&this[An]()}[gn](t){let u=0,p=t.length;for(;u+512<=p&&!this[Nn]&&!this[Hn];)switch(this[Fi]){case"begin":case"header":this[wn](t,u),u+=512;break;case"ignore":case"body":u+=this[yn](t,u);break;case"meta":u+=this[bn](t,u);break;default:throw new Error("invalid state: "+this[Fi])}u<p&&(this[Zi]?this[Zi]=Buffer.concat([t.subarray(u),this[Zi]]):this[Zi]=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[Nn]||(this[dn]?(t&&this[dn].write(t),this[dn].end()):(this[Qi]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[An]())),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 _n=t=>{let u=t.onReadEntry;t.onReadEntry=u?t=>{u(t),t.resume()}:t=>t.resume()},Yi=(t,u)=>{let p=new Map(u.map((t=>[mt(t),!0]))),m=t.filter,r=(t,u="")=>{let m=u||(0,Zt.parse)(t).root||".",g;if(t===m)g=!1;else{let u=p.get(t);u!==void 0?g=u:g=r((0,Zt.dirname)(t),m)}return p.set(t,g),g};t.filter=m?(t,u)=>m(t,u)&&r(mt(t)):t=>r(mt(t))},On=u=>{let p=new zn(u),m=u.file,g;try{g=t.openSync(m,"r");let y=t.fstatSync(g),v=u.maxReadSize||16*1024*1024;if(y.size<v){let u=Buffer.allocUnsafe(y.size),m=t.readSync(g,u,0,y.size,0);p.end(m===u.byteLength?u:u.subarray(0,m))}else{let u=0,m=Buffer.allocUnsafe(v);for(;u<y.size;){let y=t.readSync(g,m,0,v,u);if(y===0)break;u+=y,p.write(m.subarray(0,y))}p.end()}}finally{if(typeof g=="number")try{t.closeSync(g)}catch{}}},Tn=(u,p)=>{let m=new zn(u),g=u.maxReadSize||16*1024*1024,y=u.file;return new Promise(((u,p)=>{m.on("error",p),m.on("end",u),t.stat(y,((t,u)=>{if(t)p(t);else{let t=new Qs(y,{readSize:g,size:u.size});t.on("error",p),t.pipe(m)}}))}))},Gn=K(On,Tn,(t=>new zn(t)),(t=>new zn(t)),((t,u)=>{u?.length&&Yi(t,u),t.noResume||_n(t)}));var Ki=(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:Wn,parse:qn}=u.win32,ce=t=>{let u="",p=qn(t);for(;Wn(t)||p.root;){let m=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":p.root;t=t.slice(m.length),u+=m,p=qn(t)}return[u,t]};var Kn=["|","<",">","?",":"],Yn=Kn.map((t=>String.fromCharCode(61440+t.charCodeAt(0)))),Jn=new Map(Kn.map(((t,u)=>[t,Yn[u]]))),Zn=new Map(Yn.map(((t,u)=>[t,Kn[u]]))),$i=t=>Kn.reduce(((t,u)=>t.split(u).join(Jn.get(u))),t),Vs=t=>Yn.reduce(((t,u)=>t.split(u).join(Zn.get(u))),t);var tr=(t,u)=>u?(t=Ii(t).replace(/^\.(\/|$)/,""),mt(u)+"/"+t):Ii(t),to=16*1024*1024,ro=Symbol("process"),so=Symbol("file"),io=Symbol("directory"),lo=Symbol("symlink"),go=Symbol("hardlink"),yo=Symbol("header"),vo=Symbol("read"),_o=Symbol("lstat"),bo=Symbol("onlstat"),Eo=Symbol("onread"),So=Symbol("onreadlink"),$o=Symbol("openfile"),Po=Symbol("onopenfile"),Ao=Symbol("close"),Oo=Symbol("mode"),Ro=Symbol("awaitDrain"),xo=Symbol("ondrain"),To=Symbol("prefix"),ko=class extends hs{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;#y=!1;constructor(t,u={}){let p=re(u);super(),this.path=Ii(t),this.portable=!!p.portable,this.maxReadSize=p.maxReadSize||to,this.linkCache=p.linkCache||new Map,this.statCache=p.statCache||new Map,this.preservePaths=!!p.preservePaths,this.cwd=Ii(p.cwd||process.cwd()),this.strict=!!p.strict,this.noPax=!!p.noPax,this.noMtime=!!p.noMtime,this.mtime=p.mtime,this.prefix=p.prefix?Ii(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=Vs(this.path.replace(/\\/g,"/")),t=t.replace(/\\/g,"/")),this.absolute=Ii(p.absolute||Zt.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[bo](g):this[_o]()}warn(t,u,p={}){return Lt(this,t,u,p)}emit(t,...u){return t==="error"&&(this.#y=!0),super.emit(t,...u)}[_o](){Yt.lstat(this.absolute,((t,u)=>{if(t)return this.emit("error",t);this[bo](u)}))}[bo](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=In(t),this.emit("stat",t),this[ro]()}[ro](){switch(this.type){case"File":return this[so]();case"Directory":return this[io]();case"SymbolicLink":return this[lo]();default:return this.end()}}[Oo](t){return Ki(t,this.type==="Directory",this.portable)}[To](t){return tr(t,this.prefix)}[yo](){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 Ri({path:this[To](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[To](this.linkpath):this.linkpath,mode:this[Oo](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 ki({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[To](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[To](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)}[io](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[yo](),this.end()}[lo](){Yt.readlink(this.absolute,((t,u)=>{if(t)return this.emit("error",t);this[So](u)}))}[So](t){this.linkpath=Ii(t),this[yo](),this.end()}[go](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Ii(Zt.relative(this.cwd,t)),this.stat.size=0,this[yo](),this.end()}[so](){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[go](u);this.linkCache.set(t,this.absolute)}if(this[yo](),this.stat.size===0)return this.end();this[$o]()}[$o](){Yt.open(this.absolute,"r",((t,u)=>{if(t)return this.emit("error",t);this[Po](u)}))}[Po](t){if(this.fd=t,this.#y)return this[Ao]();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[vo]()}[vo](){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");Yt.read(t,u,p,m,g,((t,u)=>{if(t)return this[Ao]((()=>this.emit("error",t)));this[Eo](u)}))}[Ao](t=()=>{}){this.fd!==void 0&&Yt.close(this.fd,t)}[Eo](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[Ao]((()=>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[Ao]((()=>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[xo]():this[Ro]((()=>this[xo]()))}[Ro](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)}[xo](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[Ao]((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[vo]()}},Co=class extends ko{sync=!0;[_o](){this[bo](Yt.lstatSync(this.absolute))}[lo](){this[So](Yt.readlinkSync(this.absolute))}[$o](){this[Po](Yt.openSync(this.absolute,"r"))}[vo](){let t=!0;try{let{fd:u,buf:p,offset:m,length:g,pos:y}=this;if(u===void 0||p===void 0)throw new Error("fd and buf must be set in READ method");let v=Yt.readSync(u,p,m,g,y);this[Eo](v),t=!1}finally{if(t)try{this[Ao]((()=>{}))}catch{}}}[Ro](t){t()}[Ao](t=()=>{}){this.fd!==void 0&&Yt.closeSync(this.fd),t()}},Io=class extends hs{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 Lt(this,t,u,p)}constructor(t,u={}){let p=re(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=Ii(t.path),this.mode=t.mode!==void 0?this[Oo](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?Ii(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 Ri({path:this[To](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[To](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 ki({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[To](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[To](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 y=this.header?.block;if(!y)throw new Error("failed to encode header");super.write(y),t.pipe(this)}[To](t){return tr(t,this.prefix)}[Oo](t){return Ki(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}},In=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";var No=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++)Fn(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=Cn(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 Cn(t,u,p){let m=u,g=u?u.next:t.head,y=new Do(p,m,g,t);return y.next===void 0&&(t.tail=y),y.prev===void 0&&(t.head=y),t.length++,y}function Fn(t,u){t.tail=new Do(u,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function kn(t,u){t.head=new Do(u,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Do=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 jo=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(t,u){this.path=t||"./",this.absolute=u}},Lo=Buffer.alloc(1024),Mo=Symbol("onStat"),Fo=Symbol("ended"),Uo=Symbol("queue"),Bo=Symbol("current"),Ho=Symbol("process"),Vo=Symbol("processing"),zo=Symbol("processJob"),Go=Symbol("jobs"),Wo=Symbol("jobDone"),qo=Symbol("addFSEntry"),Ko=Symbol("addTarEntry"),Yo=Symbol("stat"),Jo=Symbol("readdir"),Zo=Symbol("onreaddir"),Xo=Symbol("pipe"),Qo=Symbol("entry"),ea=Symbol("entryOpt"),ta=Symbol("writeEntryClass"),ra=Symbol("write"),sa=Symbol("ondrain"),ia=class extends hs{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[ta];onWriteEntry;[Uo];[Go]=0;[Vo]=!1;[Fo]=!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=Ii(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[ta]=ko,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 mi(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new vi(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new wi(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[sa]())),this.on("resume",(()=>u.resume()))}else this.on("drain",this[sa]);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[Uo]=new No,this[Go]=0,this.jobs=Number(t.jobs)||4,this[Vo]=!1,this[Fo]=!1}[ra](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[Fo]=!0,this[Ho](),p&&p(),this}write(t){if(this[Fo])throw new Error("write after end");return t instanceof Ni?this[Ko](t):this[qo](t),this.flowing}[Ko](t){let u=Ii(Zt.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let p=new jo(t.path,u);p.entry=new Io(t,this[ea](p)),p.entry.on("end",(()=>this[Wo](p))),this[Go]+=1,this[Uo].push(p)}this[Ho]()}[qo](t){let u=Ii(Zt.resolve(this.cwd,t));this[Uo].push(new jo(t,u)),this[Ho]()}[Yo](t){t.pending=!0,this[Go]+=1;let u=this.follow?"stat":"lstat";Yt[u](t.absolute,((u,p)=>{t.pending=!1,this[Go]-=1,u?this.emit("error",u):this[Mo](t,p)}))}[Mo](t,u){this.statCache.set(t.absolute,u),t.stat=u,this.filter(t.path,u)?u.isFile()&&u.nlink>1&&t===this[Bo]&&!this.linkCache.get(`${u.dev}:${u.ino}`)&&!this.sync&&this[zo](t):t.ignore=!0,this[Ho]()}[Jo](t){t.pending=!0,this[Go]+=1,Yt.readdir(t.absolute,((u,p)=>{if(t.pending=!1,this[Go]-=1,u)return this.emit("error",u);this[Zo](t,p)}))}[Zo](t,u){this.readdirCache.set(t.absolute,u),t.readdir=u,this[Ho]()}[Ho](){if(!this[Vo]){this[Vo]=!0;for(let t=this[Uo].head;t&&this[Go]<this.jobs;t=t.next)if(this[zo](t.value),t.value.ignore){let u=t.next;this[Uo].removeNode(t),t.next=u}this[Vo]=!1,this[Fo]&&!this[Uo].length&&this[Go]===0&&(this.zip?this.zip.end(Lo):(super.write(Lo),super.end()))}}get[Bo](){return this[Uo]&&this[Uo].head&&this[Uo].head.value}[Wo](t){this[Uo].shift(),this[Go]-=1,this[Ho]()}[zo](t){if(!t.pending){if(t.entry){t===this[Bo]&&!t.piped&&this[Xo](t);return}if(!t.stat){let u=this.statCache.get(t.absolute);u?this[Mo](t,u):this[Yo](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let u=this.readdirCache.get(t.absolute);if(u?this[Zo](t,u):this[Jo](t),!t.readdir)return}if(t.entry=this[Qo](t),!t.entry){t.ignore=!0;return}t===this[Bo]&&!t.piped&&this[Xo](t)}}}[ea](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}}[Qo](t){this[Go]+=1;try{return new this[ta](t.path,this[ea](t)).on("end",(()=>this[Wo](t))).on("error",(t=>this.emit("error",t)))}catch(t){this.emit("error",t)}}[sa](){this[Bo]&&this[Bo].entry&&this[Bo].entry.resume()}[Xo](t){t.piped=!0,t.readdir&&t.readdir.forEach((u=>{let p=t.path,m=p==="./"?"":p.replace(/\/*$/,"/");this[qo](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={}){Lt(this,t,u,p)}},na=class extends ia{sync=!0;constructor(t){super(t),this[ta]=Co}pause(){}resume(){}[Yo](t){let u=this.follow?"statSync":"lstatSync";this[Mo](t,Yt[u](t.absolute))}[Jo](t){this[Zo](t,Yt.readdirSync(t.absolute))}[Xo](t){let u=t.entry,p=this.zip;if(t.readdir&&t.readdir.forEach((u=>{let p=t.path,m=p==="./"?"":p.replace(/\/*$/,"/");this[qo](m+u)})),!u)throw new Error("Cannot pipe without source");p?u.on("data",(t=>{p.write(t)})):u.on("data",(t=>{super[ra](t)}))}};var vn=(t,u)=>{let p=new na(t),m=new ri(t.file,{mode:t.mode||438});p.pipe(m),hr(p,u)},Mn=(t,u)=>{let p=new ia(t),m=new ti(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 ar(p,u),g},hr=(t,p)=>{p.forEach((p=>{p.charAt(0)==="@"?Gn({file:u.resolve(t.cwd,p.slice(1)),sync:!0,noResume:!0,onReadEntry:u=>t.add(u)}):t.add(p)})),t.end()},ar=async(t,p)=>{for(let m=0;m<p.length;m++){let g=String(p[m]);g.charAt(0)==="@"?await Gn({file:u.resolve(String(t.cwd),g.slice(1)),noResume:!0,onReadEntry:u=>{t.add(u)}}):t.add(g)}t.end()},Bn=(t,u)=>{let p=new na(t);return hr(p,u),p},Pn=(t,u)=>{let p=new ia(t);return ar(p,u),p},oa=K(vn,Mn,Bn,Pn,((t,u)=>{if(!u?.length)throw new TypeError("no paths specified to add to archive")}));var aa=process.env.__FAKE_PLATFORM__||process.platform,ca=aa==="win32",{O_CREAT:la,O_TRUNC:ua,O_WRONLY:ha}=Yt.constants,da=Number(process.env.__FAKE_FS_O_FILENAME__)||Yt.constants.UV_FS_O_FILEMAP||0,fa=ca&&!!da,pa=512*1024,ma=da|ua|la|ha,ga=fa?t=>t<pa?ma:"w":()=>"w";var cs=(u,p,m)=>{try{return t.lchownSync(u,p,m)}catch(t){if(t?.code!=="ENOENT")throw t}},di=(u,p,m,g)=>{t.lchown(u,p,m,(t=>{g(t&&t?.code!=="ENOENT"?t:null)}))},$n=(t,p,m,g,y)=>{if(p.isDirectory())index_min_fs(u.resolve(t,p.name),m,g,(v=>{if(v)return y(v);let b=u.resolve(t,p.name);di(b,m,g,y)}));else{let v=u.resolve(t,p.name);di(v,m,g,y)}},index_min_fs=(u,p,m,g)=>{t.readdir(u,{withFileTypes:!0},((t,y)=>{if(t){if(t.code==="ENOENT")return g();if(t.code!=="ENOTDIR"&&t.code!=="ENOTSUP")return g(t)}if(t||!y.length)return di(u,p,m,g);let v=y.length,b=null,a=t=>{if(!b){if(t)return g(b=t);if(--v===0)return di(u,p,m,g)}};for(let t of y)$n(u,t,p,m,a)}))},Xn=(t,p,m,g)=>{p.isDirectory()&&ds(u.resolve(t,p.name),m,g),cs(u.resolve(t,p.name),m,g)},ds=(u,p,m)=>{let g;try{g=t.readdirSync(u,{withFileTypes:!0})}catch(t){let g=t;if(g?.code==="ENOENT")return;if(g?.code==="ENOTDIR"||g?.code==="ENOTSUP")return cs(u,p,m);throw g}for(let t of g)Xn(u,t,p,m);return cs(u,p,m)};var ya=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 va=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 jn=(u,p)=>{t.stat(u,((t,m)=>{(t||!m.isDirectory())&&(t=new ya(u,t?.code||"ENOTDIR")),p(t)}))},fr=(p,m,g)=>{p=Ii(p);let y=m.umask??18,v=m.mode|448,b=(v&y)!==0,w=m.uid,E=m.gid,$=typeof w=="number"&&typeof E=="number"&&(w!==m.processUid||E!==m.processGid),P=m.preserve,A=m.unlink,O=Ii(m.cwd),S=(u,m)=>{u?g(u):m&&$?index_min_fs(m,w,E,(t=>S(t))):b?t.chmod(p,v,g):g()};if(p===O)return jn(p,S);if(P)return ot.mkdir(p,{mode:v,recursive:!0}).then((t=>S(null,t??void 0)),S);let R=Ii(u.relative(O,p)).split("/");us(O,R,v,A,O,void 0,S)},us=(p,m,g,y,v,b,w)=>{if(!m.length)return w(null,b);let E=m.shift(),$=Ii(u.resolve(p+"/"+E));t.mkdir($,g,dr($,m,g,y,v,b,w))},dr=(u,p,m,g,y,v,b)=>w=>{w?t.lstat(u,((E,$)=>{if(E)E.path=E.path&&Ii(E.path),b(E);else if($.isDirectory())us(u,p,m,g,y,v,b);else if(g)t.unlink(u,(w=>{if(w)return b(w);t.mkdir(u,m,dr(u,p,m,g,y,v,b))}));else{if($.isSymbolicLink())return b(new va(u,u+"/"+p.join("/")));b(w)}})):(v=v||u,us(u,p,m,g,y,v,b))},Qn=u=>{let p=!1,m;try{p=t.statSync(u).isDirectory()}catch(t){m=t?.code}finally{if(!p)throw new ya(u,m??"ENOTDIR")}},ur=(p,m)=>{p=Ii(p);let g=m.umask??18,y=m.mode|448,v=(y&g)!==0,b=m.uid,w=m.gid,E=typeof b=="number"&&typeof w=="number"&&(b!==m.processUid||w!==m.processGid),$=m.preserve,P=m.unlink,A=Ii(m.cwd),d=u=>{u&&E&&ds(u,b,w),v&&t.chmodSync(p,y)};if(p===A)return Qn(A),d();if($)return d(t.mkdirSync(p,{mode:y,recursive:!0})??void 0);let O=Ii(u.relative(A,p)).split("/"),R;for(let p=O.shift(),m=A;p&&(m+="/"+p);p=O.shift()){m=Ii(u.resolve(m));try{t.mkdirSync(m,y),R=R||m}catch{let u=t.lstatSync(m);if(u.isDirectory())continue;if(P){t.unlinkSync(m),t.mkdirSync(m,y),R=R||m;continue}else if(u.isSymbolicLink())return new va(m,m+"/"+O.join("/"))}}return d(R)};var _a=Object.create(null),ba=1e4,wa=new Set,pr=t=>{wa.has(t)?wa.delete(t):_a[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),wa.add(t);let u=_a[t],p=wa.size-ba;if(p>ba/10){for(let t of wa)if(wa.delete(t),delete _a[t],--p<=0)break}return u};var Ea=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Sa=Ea==="win32",eo=t=>t.split("/").slice(0,-1).reduce(((t,p)=>{let m=t[t.length-1];return m!==void 0&&(p=(0,u.join)(m,p)),t.push(p||"/"),t}),[]),$a=class{#y=new Map;#v=new Map;#_=new Set;reserve(t,p){t=Sa?["win32 parallelization disabled"]:t.map((t=>mt((0,u.join)(pr(t)))));let m=new Set(t.map((t=>eo(t))).reduce(((t,u)=>t.concat(u))));this.#v.set(p,{dirs:m,paths:t});for(let u of t){let t=this.#y.get(u);t?t.push(p):this.#y.set(u,[p])}for(let t of m){let u=this.#y.get(t);if(!u)this.#y.set(t,[new Set([p])]);else{let t=u[u.length-1];t instanceof Set?t.add(p):u.push(new Set([p]))}}return this.#w(p)}#b(t){let u=this.#v.get(t);if(!u)throw new Error("function does not have any path reservations");return{paths:u.paths.map((t=>this.#y.get(t))),dirs:[...u.dirs].map((t=>this.#y.get(t)))}}check(t){let{paths:u,dirs:p}=this.#b(t);return u.every((u=>u&&u[0]===t))&&p.every((u=>u&&u[0]instanceof Set&&u[0].has(t)))}#w(t){return this.#_.has(t)||!this.check(t)?!1:(this.#_.add(t),t((()=>this.#E(t))),!0)}#E(t){if(!this.#_.has(t))return!1;let u=this.#v.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.#y.get(u);if(!p||p?.[0]!==t)continue;let m=p[1];if(!m){this.#y.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.#y.get(u),m=p?.[0];if(!(!p||!(m instanceof Set)))if(m.size===1&&p.length===1){this.#y.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.#_.delete(t),g.forEach((t=>this.#w(t))),!0}};var wr=()=>process.umask();var Pa=Symbol("onEntry"),Aa=Symbol("checkFs"),Oa=Symbol("checkFs2"),Ra=Symbol("isReusable"),xa=Symbol("makeFs"),Ta=Symbol("file"),ka=Symbol("directory"),Ca=Symbol("link"),Ia=Symbol("symlink"),Na=Symbol("hardlink"),Da=Symbol("ensureNoSymlink"),ja=Symbol("unsupported"),La=Symbol("checkPath"),Ma=Symbol("stripAbsolutePath"),Fa=Symbol("mkdir"),Ua=Symbol("onError"),Ba=Symbol("pending"),Ha=Symbol("pend"),Va=Symbol("unpend"),za=Symbol("ended"),Ga=Symbol("maybeClose"),Wa=Symbol("skip"),qa=Symbol("doChown"),Ka=Symbol("uid"),Ya=Symbol("gid"),Ja=Symbol("checkedCwd"),Za=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Xa=Za==="win32",Qa=1024,no=(u,p)=>{if(!Xa)return t.unlink(u,p);let m=u+".DELETE."+(0,I.randomBytes)(16).toString("hex");t.rename(u,m,(u=>{if(u)return p(u);t.unlink(m,p)}))},oo=u=>{if(!Xa)return t.unlinkSync(u);let p=u+".DELETE."+(0,I.randomBytes)(16).toString("hex");t.renameSync(u,p),t.unlinkSync(p)},Tr=(t,u,p)=>t!==void 0&&t===t>>>0?t:u!==void 0&&u===u>>>0?u:p,ec=class extends zn{[za]=!1;[Ja]=!1;[Ba]=0;reservations=new $a;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[za]=!0,this[Ga]()},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;t.preserveOwner===void 0&&typeof t.uid!="number"?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Qa,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Xa,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Ii(u.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:wr():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[Pa](t)))}warn(t,u,p={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(p.recoverable=!1),super.warn(t,u,p)}[Ga](){this[za]&&this[Ba]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ma](t,p){let m=t[p],{type:g}=t;if(!m||this.preservePaths)return!0;let[y,v]=ce(m),b=v.replace(/\\/g,"/").split("/");if(b.includes("..")||Xa&&/^[a-z]:\.\.$/i.test(b[0]??"")){if(p==="path"||g==="Link")return this.warn("TAR_ENTRY_ERROR",`${p} contains '..'`,{entry:t,[p]:m}),!1;{let g=u.posix.dirname(t.path),y=u.posix.normalize(u.posix.join(g,b.join("/")));if(y.startsWith("../")||y==="..")return this.warn("TAR_ENTRY_ERROR",`${p} escapes extraction directory`,{entry:t,[p]:m}),!1}}return y&&(t[p]=String(v),this.warn("TAR_ENTRY_INFO",`stripping ${y} from absolute ${p}`,{entry:t,[p]:m})),!0}[La](t){let p=Ii(t.path),m=p.split("/");if(this.strip){if(m.length<this.strip)return!1;if(t.type==="Link"){let u=Ii(String(t.linkpath)).split("/");if(u.length>=this.strip)t.linkpath=u.slice(this.strip).join("/");else return!1}m.splice(0,this.strip),t.path=m.join("/")}if(isFinite(this.maxDepth)&&m.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:p,depth:m.length,maxDepth:this.maxDepth}),!1;if(!this[Ma](t,"path")||!this[Ma](t,"linkpath"))return!1;if(u.isAbsolute(t.path)?t.absolute=Ii(u.resolve(t.path)):t.absolute=Ii(u.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:Ii(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:p}=u.win32.parse(String(t.absolute));t.absolute=p+$i(String(t.absolute).slice(p.length));let{root:m}=u.win32.parse(t.path);t.path=m+$i(t.path.slice(m.length))}return!0}[Pa](t){if(!this[La](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[Aa](t);default:return this[ja](t)}}[Ua](t,u){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:u}),this[Va](),u.resume())}[Fa](t,u,p){fr(Ii(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)}[qa](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}[Ka](t){return Tr(this.uid,t.uid,this.processUid)}[Ya](t){return Tr(this.gid,t.gid,this.processGid)}[Ta](u,p){let m=typeof u.mode=="number"?u.mode&4095:this.fmode,g=new ti(String(u.absolute),{flags:ga(u.size),mode:m,autoClose:!1});g.on("error",(m=>{g.fd&&t.close(g.fd,(()=>{})),g.write=()=>!0,this[Ua](m,u),p()}));let y=1,o=m=>{if(m){g.fd&&t.close(g.fd,(()=>{})),this[Ua](m,u),p();return}--y===0&&g.fd!==void 0&&t.close(g.fd,(t=>{t?this[Ua](t,u):this[Va](),p()}))};g.on("finish",(()=>{let p=String(u.absolute),m=g.fd;if(typeof m=="number"&&u.mtime&&!this.noMtime){y++;let g=u.atime||new Date,v=u.mtime;t.futimes(m,g,v,(u=>u?t.utimes(p,g,v,(t=>o(t&&u))):o()))}if(typeof m=="number"&&this[qa](u)){y++;let g=this[Ka](u),v=this[Ya](u);typeof g=="number"&&typeof v=="number"&&t.fchown(m,g,v,(u=>u?t.chown(p,g,v,(t=>o(t&&u))):o()))}o()}));let v=this.transform&&this.transform(u)||u;v!==u&&(v.on("error",(t=>{this[Ua](t,u),p()})),u.pipe(v)),v.pipe(g)}[ka](u,p){let m=typeof u.mode=="number"?u.mode&4095:this.dmode;this[Fa](String(u.absolute),m,(m=>{if(m){this[Ua](m,u),p();return}let g=1,o=()=>{--g===0&&(p(),this[Va](),u.resume())};u.mtime&&!this.noMtime&&(g++,t.utimes(String(u.absolute),u.atime||new Date,u.mtime,o)),this[qa](u)&&(g++,t.chown(String(u.absolute),Number(this[Ka](u)),Number(this[Ya](u)),o)),o()}))}[ja](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Ia](t,p){let m=Ii(u.relative(this.cwd,u.resolve(u.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Da](t,this.cwd,m,(()=>this[Ca](t,String(t.linkpath),"symlink",p)),(u=>{this[Ua](u,t),p()}))}[Na](t,p){let m=Ii(u.resolve(this.cwd,String(t.linkpath))),g=Ii(String(t.linkpath)).split("/");this[Da](t,this.cwd,g,(()=>this[Ca](t,m,"link",p)),(u=>{this[Ua](u,t),p()}))}[Da](p,m,g,y,v){let b=g.shift();if(this.preservePaths||b===void 0)return y();let w=u.resolve(m,b);t.lstat(w,((t,m)=>{if(t)return y();if(m?.isSymbolicLink())return v(new va(w,u.resolve(w,g.join("/"))));this[Da](p,w,g,y,v)}))}[Ha](){this[Ba]++}[Va](){this[Ba]--,this[Ga]()}[Wa](t){this[Va](),t.resume()}[Ra](t,u){return t.type==="File"&&!this.unlink&&u.isFile()&&u.nlink<=1&&!Xa}[Aa](t){this[Ha]();let u=[t.path];t.linkpath&&u.push(t.linkpath),this.reservations.reserve(u,(u=>this[Oa](t,u)))}[Oa](p,m){let i=t=>{m(t)},r=()=>{this[Fa](this.cwd,this.dmode,(t=>{if(t){this[Ua](t,p),i();return}this[Ja]=!0,n()}))},n=()=>{if(p.absolute!==this.cwd){let t=Ii(u.dirname(String(p.absolute)));if(t!==this.cwd)return this[Fa](t,this.dmode,(t=>{if(t){this[Ua](t,p),i();return}o()}))}o()},o=()=>{t.lstat(String(p.absolute),((u,m)=>{if(m&&(this.keep||this.newer&&m.mtime>(p.mtime??m.mtime))){this[Wa](p),i();return}if(u||this[Ra](p,m))return this[xa](null,p,i);if(m.isDirectory()){if(p.type==="Directory"){let u=this.chmod&&p.mode&&(m.mode&4095)!==p.mode,c=t=>this[xa](t??null,p,i);return u?t.chmod(String(p.absolute),Number(p.mode),c):c()}if(p.absolute!==this.cwd)return t.rmdir(String(p.absolute),(t=>this[xa](t??null,p,i)))}if(p.absolute===this.cwd)return this[xa](null,p,i);no(String(p.absolute),(t=>this[xa](t??null,p,i)))}))};this[Ja]?n():r()}[xa](t,u,p){if(t){this[Ua](t,u),p();return}switch(u.type){case"File":case"OldFile":case"ContiguousFile":return this[Ta](u,p);case"Link":return this[Na](u,p);case"SymbolicLink":return this[Ia](u,p);case"Directory":case"GNUDumpDir":return this[ka](u,p)}}[Ca](u,p,m,g){t[m](p,String(u.absolute),(t=>{t?this[Ua](t,u):(this[Va](),u.resume()),g()}))}},Se=t=>{try{return[null,t()]}catch(t){return[t,null]}},tc=class extends ec{sync=!0;[xa](t,u){return super[xa](t,u,(()=>{}))}[Aa](p){if(!this[Ja]){let t=this[Fa](this.cwd,this.dmode);if(t)return this[Ua](t,p);this[Ja]=!0}if(p.absolute!==this.cwd){let t=Ii(u.dirname(String(p.absolute)));if(t!==this.cwd){let u=this[Fa](t,this.dmode);if(u)return this[Ua](u,p)}}let[m,g]=Se((()=>t.lstatSync(String(p.absolute))));if(g&&(this.keep||this.newer&&g.mtime>(p.mtime??g.mtime)))return this[Wa](p);if(m||this[Ra](p,g))return this[xa](null,p);if(g.isDirectory()){if(p.type==="Directory"){let u=this.chmod&&p.mode&&(g.mode&4095)!==p.mode,[m]=u?Se((()=>{t.chmodSync(String(p.absolute),Number(p.mode))})):[];return this[xa](m,p)}let[u]=Se((()=>t.rmdirSync(String(p.absolute))));this[xa](u,p)}let[y]=p.absolute===this.cwd?[]:Se((()=>oo(String(p.absolute))));this[xa](y,p)}[Ta](u,p){let m=typeof u.mode=="number"?u.mode&4095:this.fmode,r=m=>{let y;try{t.closeSync(g)}catch(t){y=t}(m||y)&&this[Ua](m||y,u),p()},g;try{g=t.openSync(String(u.absolute),ga(u.size),m)}catch(t){return r(t)}let y=this.transform&&this.transform(u)||u;y!==u&&(y.on("error",(t=>this[Ua](t,u))),u.pipe(y)),y.on("data",(u=>{try{t.writeSync(g,u,0,u.length)}catch(t){r(t)}})),y.on("end",(()=>{let p=null;if(u.mtime&&!this.noMtime){let m=u.atime||new Date,y=u.mtime;try{t.futimesSync(g,m,y)}catch(g){try{t.utimesSync(String(u.absolute),m,y)}catch{p=g}}}if(this[qa](u)){let m=this[Ka](u),y=this[Ya](u);try{t.fchownSync(g,Number(m),Number(y))}catch(g){try{t.chownSync(String(u.absolute),Number(m),Number(y))}catch{p=p||g}}}r(p)}))}[ka](u,p){let m=typeof u.mode=="number"?u.mode&4095:this.dmode,g=this[Fa](String(u.absolute),m);if(g){this[Ua](g,u),p();return}if(u.mtime&&!this.noMtime)try{t.utimesSync(String(u.absolute),u.atime||new Date,u.mtime)}catch{}if(this[qa](u))try{t.chownSync(String(u.absolute),Number(this[Ka](u)),Number(this[Ya](u)))}catch{}p(),u.resume()}[Fa](t,u){try{return ur(Ii(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}}[Da](p,m,g,y,v){if(this.preservePaths||!g.length)return y();let b=m;for(let p of g){b=u.resolve(b,p);let[w,E]=Se((()=>t.lstatSync(b)));if(w)return y();if(E.isSymbolicLink())return v(new va(b,u.resolve(m,g.join("/"))))}y()}[Ca](u,p,m,g){let y=`${m}Sync`;try{t[y](p,String(u.absolute)),g(),u.resume()}catch(t){return this[Ua](t,u)}}};var ho=u=>{let p=new tc(u),m=u.file,g=t.statSync(m),y=u.maxReadSize||16*1024*1024;new ei(m,{readSize:y,size:g.size}).pipe(p)},ao=(u,p)=>{let m=new ec(u),g=u.maxReadSize||16*1024*1024,y=u.file;return new Promise(((u,p)=>{m.on("error",p),m.on("close",u),t.stat(y,((t,u)=>{if(t)p(t);else{let t=new Qs(y,{readSize:g,size:u.size});t.on("error",p),t.pipe(m)}}))}))},rc=K(ho,ao,(t=>new tc(t)),(t=>new ec(t)),((t,u)=>{u?.length&&Yi(t,u)}));var co=(u,p)=>{let m=new na(u),g=!0,y,v;try{try{y=t.openSync(u.file,"r+")}catch(p){if(p?.code==="ENOENT")y=t.openSync(u.file,"w+");else throw p}let b=t.fstatSync(y),w=Buffer.alloc(512);e:for(v=0;v<b.size;v+=512){for(let u=0,p=0;u<512;u+=p){if(p=t.readSync(y,w,u,w.length-u,v+u),v===0&&w[0]===31&&w[1]===139)throw new Error("cannot append to compressed archives");if(!p)break e}let p=new Ri(w);if(!p.cksumValid)break;let m=512*Math.ceil((p.size||0)/512);if(v+m+512>b.size)break;v+=m,u.mtimeCache&&p.mtime&&u.mtimeCache.set(String(p.path),p.mtime)}g=!1,fo(u,m,v,y,p)}finally{if(g)try{t.closeSync(y)}catch{}}},fo=(t,u,p,m,g)=>{let y=new ri(t.file,{fd:m,start:p});u.pipe(y),mo(u,g)},uo=(u,p)=>{p=Array.from(p);let m=new ia(u),i=(p,m,g)=>{let a=(u,m)=>{u?t.close(p,(t=>g(u))):g(null,m)},y=0;if(m===0)return a(null,0);let v=0,b=Buffer.alloc(512),S=(g,w)=>{if(g||typeof w>"u")return a(g);if(v+=w,v<512&&w)return t.read(p,b,v,b.length-v,y+v,S);if(y===0&&b[0]===31&&b[1]===139)return a(new Error("cannot append to compressed archives"));if(v<512)return a(null,y);let E=new Ri(b);if(!E.cksumValid)return a(null,y);let $=512*Math.ceil((E.size??0)/512);if(y+$+512>m||(y+=$+512,y>=m))return a(null,y);u.mtimeCache&&E.mtime&&u.mtimeCache.set(String(E.path),E.mtime),v=0,t.read(p,b,0,512,y,S)};t.read(p,b,0,512,y,S)};return new Promise(((g,y)=>{m.on("error",y);let v="r+",a=(b,w)=>{if(b&&b.code==="ENOENT"&&v==="r+")return v="w+",t.open(u.file,v,a);if(b||!w)return y(b);t.fstat(w,((v,b)=>{if(v)return t.close(w,(()=>y(v)));i(w,b.size,((t,v)=>{if(t)return y(t);let b=new ti(u.file,{fd:w,start:v});m.pipe(b),b.on("error",y),b.on("close",g),po(m,p)}))}))};t.open(u.file,v,a)}))},mo=(t,p)=>{p.forEach((p=>{p.charAt(0)==="@"?Gn({file:u.resolve(t.cwd,p.slice(1)),sync:!0,noResume:!0,onReadEntry:u=>t.add(u)}):t.add(p)})),t.end()},po=async(t,p)=>{for(let m=0;m<p.length;m++){let g=String(p[m]);g.charAt(0)==="@"?await Gn({file:u.resolve(String(t.cwd),g.slice(1)),noResume:!0,onReadEntry:u=>t.add(u)}):t.add(g)}t.end()},sc=K(co,uo,(()=>{throw new TypeError("file is required")}),(()=>{throw new TypeError("file is required")}),((t,u)=>{if(!ks(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 ic=K(sc.syncFile,sc.asyncFile,sc.syncNoFile,sc.asyncNoFile,((t,u=[])=>{sc.validate?.(t,u),wo(t)})),wo=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))};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,y,...v]=t.pathname.split("/");const b=u?u.replace(/^\//,""):v.join("/");if(g===undefined||g===""&&y===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:b}}catch{return}}const w=u?`${y}/${v.join("/")}`.replace(new RegExp(`/${b}|/$`),""):y;if(p&&m&&w&&g==="tree"){return{username:p,name:m,branch:w,filePath:b}}}function hasRepo({username:t,name:u,branch:p,filePath:m}){const g=`https://api.github.com/repos/${t}/${u}/contents`;const y=`${m?`/${m}`:""}/package.json`;return isUrlOk(`${g}${y}?ref=${p}`)}function existsInRepo(t){try{const u=new URL(t);return isUrlOk(u.href)}catch{return isUrlOk(`https://api.github.com/repos/zuplo/zudoku/contents/examples/${encodeURIComponent(t)}`)}}async function downloadTarStream(t){const u=await fetch(t);if(!u.body){throw new Error(`Failed to download: ${t}`)}return z.Readable.fromWeb(u.body)}async function downloadAndExtractRepo(t,{username:p,name:m,branch:g,filePath:y}){let v=null;await(0,qt.pipeline)(await downloadTarStream(`https://codeload.github.com/${p}/${m}/tar.gz/${g}`),rc({cwd:t,strip:y?y.split("/").length+1:1,filter:t=>{if(v===null){const p=t.split(u.sep);v=p.length?p[0]:null}return t.startsWith(`${v}${y?`/${y}/`:"/"}`)}}))}async function downloadAndExtractExample(t,u){if(u==="__internal-testing-retry"){throw new Error("This is an internal example for testing the CLI.")}await(0,qt.pipeline)(await downloadTarStream("https://codeload.github.com/zuplo/zudoku/tar.gz/canary"),rc({cwd:t,strip:2+u.split("/").length,filter:t=>t.includes(`zudoku-canary/examples/${u}/`)}))}var nc=__nccwpck_require__(1421);function isInGitRepository(){try{(0,nc.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch{}return false}function isInMercurialRepository(){try{(0,nc.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch{}return false}function isDefaultBranchSet(){try{(0,nc.execSync)("git config init.defaultBranch",{stdio:"ignore"});return true}catch{}return false}function tryGitInit(p){let m=false;try{(0,nc.execSync)("git --version",{stdio:"ignore"});if(isInGitRepository()||isInMercurialRepository()){return false}(0,nc.execSync)("git init",{stdio:"ignore"});m=true;if(!isDefaultBranchSet()){(0,nc.execSync)("git checkout -b main",{stdio:"ignore"})}(0,nc.execSync)("git add -A",{stdio:"ignore"});(0,nc.execSync)('git commit -m "Initial commit from Create Next App"',{stdio:"ignore"});return true}catch{if(m){try{(0,t.rmSync)((0,u.join)(p,".git"),{recursive:true,force:true})}catch{}}return false}}var oc=__nccwpck_require__(670);var ac=__nccwpck_require__.n(oc);async function install(t,u){const p=["install"];if(!u){console.log((0,Qe.yellow)("You appear to be offline.\nFalling back to the local cache."));p.push("--offline")}return new Promise(((u,m)=>{const g=ac()(t,p,{stdio:"inherit",env:{...process.env,ADBLOCK:"1",NODE_ENV:"development",DISABLE_OPENCOLLECTIVE:"1"}});g.on("close",(g=>{if(g!==0){m({command:`${t} ${p.join(" ")}`});return}u()}))}))}function isFolderEmpty(p,m){const g=[".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 y=(0,t.readdirSync)(p).filter((t=>!g.includes(t)&&!/\.iml$/.test(t)));if(y.length>0){console.log(`The directory ${(0,Qe.green)(m)} contains files that could conflict:`);console.log();for(const m of y){try{const g=(0,t.lstatSync)((0,u.join)(p,m));if(g.isDirectory()){console.log(` ${(0,Qe.blue)(m)}/`)}else{console.log(` ${m}`)}}catch{console.log(` ${m}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}const cc=require("node:dns/promises");const lc=require("node:url");var uc=__nccwpck_require__.n(lc);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const t=(0,nc.execSync)("npm config get https-proxy").toString().trim();return t!=="null"?t:undefined}catch{return}}async function getOnline(){try{await(0,cc.lookup)("registry.yarnpkg.com");return true}catch{const t=getProxy();if(!t){return false}const{hostname:u}=uc().parse(t);if(!u){return false}try{await(0,cc.lookup)(u);return true}catch{return false}}}const hc=require("node:constants");async function isWriteable(t){try{await(0,ot.access)(t,hc.W_OK);return true}catch{return false}}var dc=__nccwpck_require__(2457);const identity=t=>t;const copy=async(t,p,{cwd:m,rename:g=identity,parents:y=true}={})=>{const v=typeof t==="string"?[t]:t;if(v.length===0||!p){throw new TypeError("`src` and `dest` are required")}const b=await(0,dc.async)(v,{cwd:m,dot:true,absolute:false,stats:false});const w=m?(0,u.resolve)(m,p):p;return Promise.all(b.map((async t=>{const p=(0,u.dirname)(t);const v=g((0,u.basename)(t));const b=m?(0,u.resolve)(m,t):t;const E=y?(0,u.join)(w,p,v):(0,u.join)(w,v);await(0,ot.mkdir)((0,u.dirname)(E),{recursive:true});return(0,ot.copyFile)(b,E)})))};var fc;const pc=__dirname.endsWith("dist")?p().dirname(__dirname):p().dirname(__dirname);const mc=__dirname.endsWith("dist")?p().join(__dirname,"templates"):__dirname;const gc=p().resolve(pc,"../..");const yc=(fc=process.env.ComSpec)!==null&&fc!==void 0?fc:"cmd.exe";const formatAppTitle=t=>t.split(/[-_\s]+/).filter(Boolean).map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join(" ");const resolveCoreApitogoPackageName=async()=>{const t=JSON.parse(await ct().readFile(p().join(pc,"package.json"),"utf8"));return t.name.replace("/create-apitogo","/apitogo")};const vc="@lukow"+"eb";const normalizeDependencyVersion=t=>t.replace(/^[\^~>=<]+/,"");const _c="0.577.0";const ensureRequiredApitogoModules=(t,u,p)=>{var m,g,y,v;const b=u.slice(0,u.indexOf("/"));const w=`${b}/apitogo-module-landing`;const E=`${b}/apitogo-module-user-panel`;const $=`${b}/apitogo-plugin-dev-portal-billing`;const P=`^${normalizeDependencyVersion(p)}`;(m=t[w])!==null&&m!==void 0?m:t[w]=P;(g=t[E])!==null&&g!==void 0?g:t[E]=P;(y=t[$])!==null&&y!==void 0?y:t[$]=P;(v=t["lucide-react"])!==null&&v!==void 0?v:t["lucide-react"]=_c};const ensureSecondaryApitogoAliases=(t,u,p)=>{if(u.startsWith(`${vc}/`)){return}const alias=t=>`npm:${t}@${normalizeDependencyVersion(p)}`;const m=u.slice(0,u.indexOf("/"));t[`${vc}/apitogo`]=alias(u);t[`${vc}/apitogo-module-landing`]=alias(`${m}/apitogo-module-landing`);t[`${vc}/apitogo-module-user-panel`]=alias(`${m}/apitogo-module-user-panel`);t[`${vc}/apitogo-plugin-dev-portal-billing`]=alias(`${m}/apitogo-plugin-dev-portal-billing`)};const parseWorkspaceCatalog=async t=>{var u,p,m;const g=await ct().readFile(t,"utf8");const y={};let v=false;for(const t of g.split(/\r?\n/)){if(!v){v=t.trim()==="catalog:";continue}if(!t.startsWith(" "))break;const g=t.match(/^ {2}(?:"([^"]+)"|([^:]+)):\s+(.+)$/);if(!g)continue;const b=(u=g[1])!==null&&u!==void 0?u:(p=g[2])===null||p===void 0?void 0:p.trim();const w=(m=g[3])===null||m===void 0?void 0:m.trim();if(b&&w)y[b]=w}return y};const replaceCatalogVersions=(t,u)=>{if(Array.isArray(t)){return t.map((t=>replaceCatalogVersions(t,u)))}if(!t||typeof t!=="object"){return t}return Object.fromEntries(Object.entries(t).map((([t,p])=>{var m;return[t,p==="catalog:"?(m=u[t])!==null&&m!==void 0?m:p:replaceCatalogVersions(p,u)]})))};const stageLocalZudokuPackage=async(t,u)=>{var m,g;const y=await parseWorkspaceCatalog(p().join(gc,"pnpm-workspace.yaml"));const v=p().join(t,"package.json");const b=JSON.parse(await ct().readFile(v,"utf8"));const w=replaceCatalogVersions(b,y);const E=new Set(["package.json",...Array.isArray(b.files)?b.files:[]]);await ct().rm(u,{recursive:true,force:true});await ct().mkdir(u,{recursive:true});for(const m of E){if(m==="package.json")continue;const g=p().join(t,m);const y=p().join(u,m);const v=await ct().stat(g).catch((()=>null));if(!v)continue;if(v.isDirectory()){await ct().cp(g,y,{recursive:true})}else{await ct().mkdir(p().dirname(y),{recursive:true});await ct().copyFile(g,y)}}(m=w.scripts)===null||m===void 0?true:delete m.prepublishOnly;(g=w.scripts)===null||g===void 0?true:delete g.postpublish;if(w.scripts&&Object.keys(w.scripts).length===0){delete w.scripts}await ct().writeFile(p().join(u,"package.json"),JSON.stringify(w,null,2)+M().EOL)};const getTemplateFile=({template:t,mode:u,file:m})=>p().join(mc,t,u,m);const installTemplate=async({appName:t,root:u,packageManager:m,isOnline:g,template:y,mode:v,eslint:b,skipInstall:w,zudokuVersion:E})=>{var $;console.log((0,Qe.bold)(`Using ${m}.`));console.log("\nInitializing project with template:",y,"\n");const P=p().join(mc,y,v);const A=["**"];if(!b)A.push("!eslintrc.json");await copy(A,u,{parents:true,cwd:P,rename(t){switch(t){case"gitignore":case"eslintrc.json":{return`.${t}`}case"env":{return".env"}case"README-template.md":{return"README.md"}case"zudoku.config.tsx":{return"apitogo.config.tsx"}case"zudoku.config.jsx":{return"apitogo.config.jsx"}default:{return t}}}});const O=formatAppTitle(t);const substituteAppTitle=t=>t.split("__APP_TITLE__").join(O);const R=v==="ts"?"apitogo.config.tsx":"apitogo.config.jsx";const x=p().join(u,R);const T=await ct().readFile(x,"utf8");await ct().writeFile(x,substituteAppTitle(T),"utf8");const k=p().join(u,"apitogo.config.json");try{const t=await ct().readFile(k,"utf8");await ct().writeFile(k,substituteAppTitle(t),"utf8")}catch{}const C=($=process.env.ZUDOKU_PRIVATE_TEST_VERSION)!==null&&$!==void 0?$:E;const I=p().join(gc,"packages","zudoku");const N=p().join(I,"package.json");const D=await ct().access(N).then((async()=>{const t=p().join(u,".apitogo-local");const m=p().join(t,"zudoku-package");await ct().mkdir(t,{recursive:true});await stageLocalZudokuPackage(I,m);const g=p().relative(m,t);const y=(process.platform==="win32"?(0,nc.execFileSync)(yc,["/d","/c","npm","pack","--pack-destination",g],{cwd:m,encoding:"utf8"}):(0,nc.execFileSync)("npm",["pack","--pack-destination",g],{cwd:m,encoding:"utf8"})).trim().split(/\r?\n/).at(-1);if(!y){throw new Error("Failed to pack local zudoku package.")}return`file:.apitogo-local/${y}`})).catch((()=>C));const j=await resolveCoreApitogoPackageName();const L={name:t,version:"0.1.0",type:"module",private:true,scripts:{dev:"apitogo run",build:"apitogo build",preview:"apitogo build --preview",deploy:"apitogo deploy",lint:"eslint"},dependencies:{react:">=19.0.0","react-dom":">=19.0.0",[j]:D},devDependencies:{}};if(!D.startsWith("file:")){ensureRequiredApitogoModules(L.dependencies,j,D);ensureSecondaryApitogoAliases(L.dependencies,j,D)}if(v==="ts"){L.devDependencies={...L.devDependencies,"@types/node":"^22","@types/react":"^19","@types/react-dom":"^19",typescript:"^5"}}if(b){L.devDependencies={...L.devDependencies,eslint:"^8"}}if(b&&v==="ts"){L.devDependencies={...L.devDependencies,"@typescript-eslint/eslint-plugin":"^8","@typescript-eslint/parser":"^8"}}const U=Object.keys(L.devDependencies).length;if(!U)delete L.devDependencies;await ct().writeFile(p().join(u,"package.json"),JSON.stringify(L,null,2)+M().EOL);if(w)return;console.log("\nInstalling dependencies:");for(const t in L.dependencies)console.log(`- ${(0,Qe.cyan)(t)}`);if(U){console.log("\nInstalling devDependencies:");for(const t in L.devDependencies)console.log(`- ${(0,Qe.cyan)(t)}`)}console.log();await install(m,g)};class DownloadError extends Error{}async function createApp({appPath:p,packageManager:m,example:g,examplePath:y,typescript:v,eslint:b,skipInstall:w,zudokuVersion:E,withExamples:$=true}){let P;const A=v?"ts":"js";const O=$?"default":"empty";if(g){let L;try{L=new URL(g)}catch(M){const U=M;if(U.code!=="ERR_INVALID_URL"){console.error(M);process.exit(1)}}if(L){if(L.origin!=="https://github.com"){console.error(`Invalid URL: ${(0,Qe.red)(`"${g}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);process.exit(1)}P=await getRepoInfo(L,y);if(!P){console.error(`Found invalid GitHub URL: ${(0,Qe.red)(`"${g}"`)}. Please fix the URL and try again.`);process.exit(1)}const B=await hasRepo(P);if(!B){console.error(`Could not locate the repository for ${(0,Qe.red)(`"${g}"`)}. Please check that the repository exists and try again.`);process.exit(1)}}else if(g!=="__internal-testing-retry"){const H=await existsInRepo(g);if(!H){console.error(`Could not locate an example named ${(0,Qe.red)(`"${g}"`)}. It could be due to the following:\n`,`1. Your spelling of example ${(0,Qe.red)(`"${g}"`)} might be incorrect.\n`,`2. You might not be connected to the internet or you are behind a proxy.`);process.exit(1)}}}const R=(0,u.resolve)(p);if(!await isWriteable((0,u.dirname)(R))){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 x=(0,u.basename)(R);(0,t.mkdirSync)(R,{recursive:true});if(!isFolderEmpty(R,x)){process.exit(1)}const T=m==="yarn";const k=!T||await getOnline();const C=process.cwd();console.log(`Creating a new API ToGo app in ${(0,Qe.green)(R)}.`);console.log();process.chdir(R);const I=(0,u.join)(R,"package.json");let N=false;if(g){try{if(P){const z=P;console.log(`Downloading files from repo ${(0,Qe.cyan)(g)}. This might take a moment.`);console.log();await nt()((()=>downloadAndExtractRepo(R,z)),{retries:3})}else{console.log(`Downloading files for example ${(0,Qe.cyan)(g)}. This might take a moment.`);console.log();await nt()((()=>downloadAndExtractExample(R,g)),{retries:3})}}catch(G){function isErrorLike(t){return typeof t==="object"&&t!==null&&typeof t.message==="string"}throw new DownloadError(isErrorLike(G)?G.message:String(G))}const V=(0,u.join)(R,".gitignore");if(!(0,t.existsSync)(V)){(0,t.copyFileSync)(getTemplateFile({template:O,mode:A,file:"gitignore"}),V)}N=(0,t.existsSync)(I);if(!w&&N){console.log("Installing packages. This might take a couple of minutes.");console.log();await install(m,k);console.log()}}else{await installTemplate({appName:x,root:R,template:O,mode:A,packageManager:m,isOnline:k,eslint:b,skipInstall:w,zudokuVersion:E})}const D=process.env.APITOGO_SKIP_NEARBY_DISCOVERY==="1";if(!g&&!D){try{const{openApiDiscovery:W,docsDiscovery:q}=await runScaffoldDiscovery(R);const Y=formatInitDiscoveryReport(R,W,q);if(Y.length>0){console.log("Discovered nearby API docs:");for(const J of Y){console.log(` ${J}`)}console.log()}}catch(Z){console.log("Could not auto-wire nearby OpenAPI/docs:",Z instanceof Error?Z.message:String(Z));console.log()}}if(tryGitInit(R)){console.log("Initialized a git repository.");console.log()}let j;if((0,u.join)(C,x)===p){j=x}else{j=p}console.log(`${(0,Qe.green)("Success!")} Created ${x} at ${p}`);if(N){console.log("Inside that directory, you can run several commands:");console.log();console.log((0,Qe.cyan)(` ${m} ${T?"":"run "}dev`));console.log(" Starts the development server.");console.log();console.log((0,Qe.cyan)(` ${m} ${T?"":"run "}build`));console.log(" Builds the app for production.");console.log();console.log((0,Qe.cyan)(` ${m} start`));console.log(" Runs the built app in production mode.");console.log();console.log("We suggest that you begin by typing:");console.log();console.log((0,Qe.cyan)(" cd"),j);console.log(` ${(0,Qe.cyan)(`${m} ${T?"":"run "}dev`)}`)}console.log()}function getPkgManager(){var t;const u=(t=process.env.npm_config_user_agent)!==null&&t!==void 0?t:"";if(u.startsWith("yarn")){return"yarn"}if(u.startsWith("pnpm")){return"pnpm"}if(u.startsWith("bun")){return"bun"}return"npm"}var bc=__nccwpck_require__(8904);var wc=__nccwpck_require__.n(bc);function validateNpmName(t){const u=wc()(t);if(u.validForNewPackages){return{valid:true}}return{valid:false,problems:[...u.errors||[],...u.warnings||[]]}}let Ec="";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 Sc=JSON.parse((0,t.readFileSync)(p().resolve(__dirname,"../package.json"),"utf-8"));const $c=new O(Sc.name).version(Sc.version,"-v, --version","Output the current version of @lukoweb/create-apitogo.").description("Create a new APItoGo developer portal.\n\nRun without arguments for an interactive setup, or pass flags such as --typescript --eslint.\nAuto-discovers nearby OpenAPI and docs/ folders after scaffold.").argument("[directory]",'Project directory (defaults to "dev-portal")').usage("[directory] [options]").helpOption("-h, --help","Display this help message.").option("--ts, --typescript","Initialize as a TypeScript project (default).").option("--js, --javascript","Initialize as a JavaScript project.").option("--eslint","Initialize with ESLint config. Use --no-eslint to skip.").option("--include-examples, --with-examples","Use the default template (sample homepage, docs, OpenAPI, and plans). On by default. Use --no-include-examples for the empty template.").option("--import-alias <prefix/*>",'Specify import alias to use (default "@/*").').option("--use-npm","Use npm as the package manager.").option("--use-pnpm","Use pnpm as the package manager.").option("--use-yarn","Use Yarn as the package manager.").option("--use-bun","Use Bun as the package manager.").option("--reset, --reset-preferences","Reset the preferences saved for @lukoweb/create-apitogo.").option("--skip-install","Skip installing packages after scaffolding.").option("-y, --yes","Skip remaining prompts and use defaults for unspecified options.").option("-e, --example <example-name|github-url>","Bootstrap from an example in the Zudoku repo or a public GitHub URL.").option("--example-path <path-to-example>","Path to the example within the repo (use when the branch name contains slashes).").addHelpText("after",`\nExamples:\n $ npx @lukoweb/create-apitogo@latest\n $ npx @lukoweb/create-apitogo@latest dev-portal --typescript --eslint\n $ npx @lukoweb/create-apitogo@latest dev-portal --javascript --no-eslint\n $ npx @lukoweb/create-apitogo@latest dev-portal --typescript --eslint --no-include-examples\n`).action((t=>{if(t&&!t.startsWith("--no-")){Ec=t}})).allowUnknownOption().parse(process.argv);const Pc=$c.opts();const{args:Ac}=$c;const Oc=Pc.useNpm?"npm":Pc.usePnpm?"pnpm":Pc.useYarn?"yarn":Pc.useBun?"bun":getPkgManager();async function run(){const p=new Conf({projectName:"@lukoweb/create-apitogo"});if(Pc.resetPreferences){const{resetPreferences:t}=await tt()({onState:onPromptState,type:"toggle",name:"resetPreferences",message:"Would you like to reset the saved preferences?",initial:false,active:"Yes",inactive:"No"});if(t){p.clear();console.log("The preferences have been reset successfully!")}process.exit(0)}const m=g().isCI||Pc.yes;const y=!Ac.includes("--no-include-examples")&&Pc.includeExamples!==false;const v=Ac.includes("--no-eslint");if(typeof Ec==="string"){Ec=Ec.trim()}if(!Ec){if(m){Ec="dev-portal"}else{const t=await tt()({onState:onPromptState,type:"text",name:"path",message:"What is your project named?",initial:"dev-portal",validate:t=>{const p=validateNpmName((0,u.basename)((0,u.resolve)(t)));if(p.valid){return true}return`Invalid project name: ${p.problems[0]}`}});if(typeof t.path==="string"){Ec=t.path.trim()}}}if(!Ec){console.log("\nPlease specify the project directory:\n"+` ${(0,Qe.cyan)(Pc.name())} ${(0,Qe.green)("<project-directory>")}\n`+"For example:\n"+` ${(0,Qe.cyan)(Pc.name())} ${(0,Qe.green)("my-zudoku-app")}\n\n`+`Run ${(0,Qe.cyan)(`${Pc.name()} --help`)} to see all options.`);process.exit(1)}const b=(0,u.resolve)(Ec);const w=(0,u.basename)(b);const E=validateNpmName(w);if(!E.valid){console.error(`Could not create a project called ${(0,Qe.red)(`"${w}"`)} because of npm naming restrictions:`);E.problems.forEach((t=>console.error(` ${(0,Qe.red)((0,Qe.bold)("*"))} ${t}`)));process.exit(1)}if(Pc.example===true){console.error("Please provide an example name or url, otherwise remove the example option.");process.exit(1)}if((0,t.existsSync)(b)&&!isFolderEmpty(b,w)){process.exit(1)}const $=typeof Pc.example==="string"&&Pc.example.trim();const P=p.get("preferences")||{};if(!$){const t={typescript:true,eslint:true};const getPrefOrDefault=u=>{var p;return(p=P[u])!==null&&p!==void 0?p:t[u]};if(!Pc.typescript&&!Pc.javascript){if(m){Pc.typescript=getPrefOrDefault("typescript")}else{const t=(0,Qe.blue)("TypeScript");const{typescript:u}=await tt()({type:"toggle",name:"typescript",message:`Would you like to use ${t}?`,initial:getPrefOrDefault("typescript"),active:"Yes",inactive:"No"},{onCancel:()=>{console.error("Exiting.");process.exit(1)}});Pc.typescript=Boolean(u);Pc.javascript=!u;P.typescript=Boolean(u)}}if(v){Pc.eslint=false}else if(!Pc.eslint){if(m){Pc.eslint=getPrefOrDefault("eslint")}else{const t=(0,Qe.blue)("ESLint");const{eslint:u}=await tt()({onState:onPromptState,type:"toggle",name:"eslint",message:`Would you like to use ${t}?`,initial:getPrefOrDefault("eslint"),active:"Yes",inactive:"No"});Pc.eslint=Boolean(u);P.eslint=Boolean(u)}}}try{await createApp({appPath:b,packageManager:Oc,example:$&&$!=="default"?$:undefined,examplePath:Pc.examplePath,typescript:Pc.typescript,eslint:Pc.eslint,skipInstall:Pc.skipInstall,zudokuVersion:Sc.version,withExamples:y})}catch(t){if(!(t instanceof DownloadError)){throw t}const u=await tt()({onState:onPromptState,type:"confirm",name:"builtin",message:`Could not download "${$}" 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:b,packageManager:Oc,typescript:Pc.typescript,eslint:Pc.eslint,skipInstall:Pc.skipInstall,zudokuVersion:Sc.version,withExamples:true})}p.set("preferences",P)}const Rc=st()(Sc).catch((()=>null));async function notifyUpdate(){var t;try{if((t=await Rc)===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[Oc]} @lukoweb/create-apitogo`;console.log((0,Qe.yellow)((0,Qe.bold)("A new version of `@lukoweb/create-apitogo` 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)}console.log();await notifyUpdate();process.exit(1)}run().then(notifyUpdate).catch(exit)})();module.exports=p})();
|
|
72
|
+
*/const m=p(952);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 y=String(g.relaxZeros);let v=String(g.shorthand);let b=String(g.capture);let w=String(g.wrap);let E=t+":"+u+"="+y+v+b+w;if(toRegexRange.cache.hasOwnProperty(E)){return toRegexRange.cache[E].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 A=hasPadding(t)||hasPadding(u);let O={min:t,max:u,a:$,b:P};let R=[];let x=[];if(A){O.isPadded=A;O.maxLen=String(O.max).length}if($<0){let t=P<0?Math.abs(P):1;x=splitToPatterns(t,Math.abs($),O,g);$=O.a=0}if(P>=0){R=splitToPatterns($,P,O,g)}O.negatives=x;O.positives=R;O.result=collatePatterns(x,R,g);if(g.capture===true){O.result=`(${O.result})`}else if(g.wrap!==false&&R.length+x.length>1){O.result=`(?:${O.result})`}toRegexRange.cache[E]=O;return O.result};function collatePatterns(t,u,p){let m=filterPatterns(t,u,"-",false,p)||[];let g=filterPatterns(u,t,"",false,p)||[];let y=filterPatterns(t,u,"-?",true,p)||[];let v=m.concat(y).concat(g);return v.join("|")}function splitToRanges(t,u){let p=1;let m=1;let g=countNines(t,p);let y=new Set([u]);while(t<=g&&g<=u){y.add(g);p+=1;g=countNines(t,p)}g=countZeros(u+1,m)-1;while(t<g&&g<=u){y.add(g);m+=1;g=countZeros(u+1,m)-1}y=[...y];y.sort(compare);return y}function rangeToPattern(t,u,p){if(t===u){return{pattern:t,count:[],digits:0}}let m=zip(t,u);let g=m.length;let y="";let v=0;for(let t=0;t<g;t++){let[u,g]=m[t];if(u===g){y+=u}else if(u!=="0"||g!=="9"){y+=toCharacterClass(u,g,p)}else{v++}}if(v){y+=p.shorthand===true?"\\d":"[0-9]"}return{pattern:y,count:[v],digits:g}}function splitToPatterns(t,u,p,m){let g=splitToRanges(t,u);let y=[];let v=t;let b;for(let t=0;t<g.length;t++){let u=g[t];let w=rangeToPattern(String(v),String(u),m);let E="";if(!p.isPadded&&b&&b.pattern===w.pattern){if(b.count.length>1){b.count.pop()}b.count.push(w.count[0]);b.string=b.pattern+toQuantifier(b.count);v=u+1;continue}if(p.isPadded){E=padZeros(u,p,m)}w.string=E+w.pattern+toQuantifier(w.count);y.push(w);v=u+1;b=w}return y}function filterPatterns(t,u,p,m,g){let y=[];for(let g of t){let{string:t}=g;if(!m&&!contains(u,"string",t)){y.push(p+t)}if(m&&contains(u,"string",t)){y.push(p+t)}}return y}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},5059:(t,u,p)=>{const{URL:m}=p(7016);const{join:g}=p(6928);const y=p(7515);const{promisify:v}=p(9023);const{tmpdir:b}=p(857);const w=p(3805);const E=v(y.writeFile);const $=v(y.mkdir);const P=v(y.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=b();const m=g(p,"update-check");if(!y.existsSync(m)){await $(m)}let v=`${t.name}-${u}.json`;if(t.scope){v=`${t.scope}-${v}`}return g(m,v)};const evaluateCache=async(t,u,p)=>{if(y.existsSync(t)){const m=await P(t,"utf8");const{lastUpdate:g,latest:y}=JSON.parse(m);const v=g+p;if(v>u){return{shouldCheck:false,latest:y}}}return{shouldCheck:true,latest:null}};const updateCache=async(t,u,p)=>{const m=JSON.stringify({latest:u,lastUpdate:p});await E(t,m,"utf8")};const loadPackage=(t,u)=>new Promise(((m,g)=>{const y={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){y.headers.authorization=`${u.type} ${u.token}`}const{get:v}=p(t.protocol==="https:"?5692:8611);v(y,(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 y=w(u);const v=new m(t,y);let b=null;try{b=await loadPackage(v)}catch(t){if(t.code&&String(t.code).startsWith(4)){const t=p(4133);const u=t(y,{recursive:true});b=await loadPackage(v,u)}else{throw t}}const E=b["dist-tags"][g];if(!E){throw new Error(`Distribution tag ${g} is not available`)}return E};const A={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:y}=Object.assign({},A,u);const v=await getFile(p,g);let b=null;let w=true;({shouldCheck:w,latest:b}=await evaluateCache(v,m,y));if(w){b=await getMostRecent(p,g);await updateCache(v,b,m)}const E=compareVersions(t.version,b);if(E===-1){return{latest:b,fromCache:!w}}return null}},8904:(t,u,p)=>{"use strict";const m=p(6737);var g=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");var y=["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.startsWith(".")){p.push("name cannot start with a period")}if(t.startsWith("-")){p.push("name cannot start with a hyphen")}if(t.match(/^_/)){p.push("name cannot start with an underscore")}if(t.trim()!==t){p.push("name cannot contain leading or trailing spaces")}y.forEach((function(u){if(t.toLowerCase()===u){p.push(u+" is not a valid package 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 v=t.match(g);if(v){var b=v[1];var w=v[2];if(w.startsWith(".")){p.push("name cannot start with a period")}if(encodeURIComponent(b)===b&&encodeURIComponent(w)===w){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},1192:(t,u,p)=>{const m=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys";const g=p(6928);const y=m?";":":";const v=p(7105);const getNotFoundError=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"});const getPathInfo=(t,u)=>{const p=u.colon||y;const g=t.match(/\//)||m&&t.match(/\\/)?[""]:[...m?[process.cwd()]:[],...(u.path||process.env.PATH||"").split(p)];const v=m?u.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"";const b=m?v.split(p):[""];if(m){if(t.indexOf(".")!==-1&&b[0]!=="")b.unshift("")}return{pathEnv:g,pathExt:b,pathExtExe:v}};const which=(t,u,p)=>{if(typeof u==="function"){p=u;u={}}if(!u)u={};const{pathEnv:m,pathExt:y,pathExtExe:b}=getPathInfo(t,u);const w=[];const step=p=>new Promise(((y,v)=>{if(p===m.length)return u.all&&w.length?y(w):v(getNotFoundError(t));const b=m[p];const E=/^".*"$/.test(b)?b.slice(1,-1):b;const $=g.join(E,t);const P=!E&&/^\.[\\\/]/.test(t)?t.slice(0,2)+$:$;y(subStep(P,p,0))}));const subStep=(t,p,m)=>new Promise(((g,E)=>{if(m===y.length)return g(step(p+1));const $=y[m];v(t+$,{pathExt:b},((y,v)=>{if(!y&&v){if(u.all)w.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:y}=getPathInfo(t,u);const b=[];for(let w=0;w<p.length;w++){const E=p[w];const $=/^".*"$/.test(E)?E.slice(1,-1):E;const P=g.join($,t);const A=!$&&/^\.[\\\/]/.test(t)?t.slice(0,2)+P:P;for(let t=0;t<m.length;t++){const p=A+m[t];try{const t=v.sync(p,{pathExt:y});if(t){if(u.all)b.push(p);else return p}}catch(t){}}}if(u.all&&b.length)return b;if(u.nothrow)return null;throw getNotFoundError(t)};t.exports=which;which.sync=whichSync},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")},7515:t=>{"use strict";t.exports=require("fs")},8611:t=>{"use strict";t.exports=require("http")},5692:t=>{"use strict";t.exports=require("https")},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")},7016:t=>{"use strict";t.exports=require("url")},9023:t=>{"use strict";t.exports=require("util")},4732:(t,u,p)=>{"use strict";const m=p(7028);const g=process.env;Object.defineProperty(u,"_vendors",{value:m.map((function(t){return t.constant}))});u.name=null;u.isPR=null;u.id=null;if(g.CI!=="false"){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;u.isPR=checkPR(t);u.id=t.constant}))}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]}))}function checkPR(t){switch(typeof t.pr){case"string":return!!g[t.pr];case"object":if("env"in t.pr){if("any"in t.pr){return t.pr.any.some((function(u){return g[t.pr.env]===u}))}else{return t.pr.env in g&&g[t.pr.env]!==t.pr.ne}}else if("any"in t.pr){return t.pr.any.some((function(t){return!!g[t]}))}else{return checkEnv(t.pr)}default:return null}}},206:(t,u,p)=>{const{Argument:m}=p(1455);const{Command:g}=p(4623);const{CommanderError:y,InvalidArgumentError:v}=p(9400);const{Help:b}=p(2559);const{Option:w}=p(1033);u.DM=new g;u.gu=t=>new g(t);u.Ww=(t,u)=>new w(t,u);u.er=(t,u)=>new m(t,u);u.uB=g;u.c$=w;u.ef=m;u._V=b;u.b7=y;u.Di=v;u.a2=v},1455:(t,u,p)=>{const{InvalidArgumentError:m}=p(9400);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.endsWith("...")){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_collectValue(t,u){if(u===this.defaultValue||!Array.isArray(u)){return[t]}u.push(t);return u}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._collectValue(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},4623:(t,u,p)=>{const m=p(8474).EventEmitter;const g=p(1421);const y=p(6760);const v=p(3024);const b=p(1708);const{Argument:w,humanReadableArgName:E}=p(1455);const{CommanderError:$}=p(9400);const{Help:P,stripColor:A}=p(2559);const{Option:O,DualOptions:R}=p(1033);const{suggestSimilar:x}=p(3683);class Command extends m{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=false;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._savedState=null;this._outputConfiguration={writeOut:t=>b.stdout.write(t),writeErr:t=>b.stderr.write(t),outputError:(t,u)=>u(t),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:undefined,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:undefined,getOutHasColors:()=>useColor()??(b.stdout.isTTY&&b.stdout.hasColors?.()),getErrHasColors:()=>useColor()??(b.stderr.isTTY&&b.stderr.hasColors?.()),stripColor:t=>A(t)};this._hidden=false;this._helpOption=undefined;this._addImplicitHelpCommand=undefined;this._helpCommand=undefined;this._helpConfiguration={};this._helpGroupHeading=undefined;this._defaultCommandGroup=undefined;this._defaultOptionGroup=undefined}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[,y,v]=t.match(/([^ ]+) *(.*)/);const b=this.createCommand(y);if(m){b.description(m);b._executableHandler=true}if(g.isDefault)this._defaultCommandName=b._name;b._hidden=!!(g.noHelp||g.hidden);b._executableFile=g.executableFile||null;if(v)b.arguments(v);this._registerCommand(b);b.parent=this;b.copyInheritedSettings(this);if(m)return this;return b}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;this._outputConfiguration={...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 w(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?.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;if(t&&this._defaultCommandGroup){this._initCommandGroup(this._getHelpCommand())}return this}const p=t??"help [command]";const[,m,g]=p.match(/([^ ]+) *(.*)/);const y=u??"display help for command";const v=this.createCommand(m);v.helpOption(false);if(g)v.arguments(g);if(y)v.description(y);this._addImplicitHelpCommand=true;this._helpCommand=v;if(t||u)this._initCommandGroup(v);return this}addHelpCommand(t,u){if(typeof t!=="object"){this.helpCommand(t,u);return this}this._addImplicitHelpCommand=true;this._helpCommand=t;this._initCommandGroup(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))}b.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 O(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._initOptionGroup(t);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._initCommandGroup(t);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 y=this.getOptionValue(p);if(u!==null&&t.parseArg){u=this._callParseArg(t,u,y,m)}else if(u!==null&&t.variadic){u=t._collectValue(u,y)}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 O){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const y=this.createOption(u,p);y.makeOptionMandatory(!!t.mandatory);if(typeof m==="function"){y.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};y.default(g).argParser(m)}else{y.default(m)}return this.addOption(y)}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(b.versions?.electron){u.from="electron"}const t=b.execArgv??[];if(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print")){u.from="eval"}}if(t===undefined){t=b.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(b.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){this._prepareForParse();const p=this._prepareUserArgs(t,u);this._parseCommand([],p);return this}async parseAsync(t,u){this._prepareForParse();const p=this._prepareUserArgs(t,u);await this._parseCommand([],p);return this}_prepareForParse(){if(this._savedState===null){this.saveStateBeforeParse()}else{this.restoreStateBeforeParse()}}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name;this._scriptPath=null;this.rawArgs=[];this._optionValues={...this._savedState._optionValues};this._optionValueSources={...this._savedState._optionValueSources};this.args=[];this.processedArgs=[]}_checkForMissingExecutable(t,u,p){if(v.existsSync(t))return;const m=u?`searched for local subcommand relative to directory '${u}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const g=`'${t}' does not exist\n - if '${p}' 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 - ${m}`;throw new Error(g)}_executeSubCommand(t,u){u=u.slice();let p=false;const m=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,u){const p=y.resolve(t,u);if(v.existsSync(p))return p;if(m.includes(y.extname(u)))return undefined;const g=m.find((t=>v.existsSync(`${p}${t}`)));if(g)return`${p}${g}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let w=t._executableFile||`${this._name}-${t._name}`;let E=this._executableDir||"";if(this._scriptPath){let t;try{t=v.realpathSync(this._scriptPath)}catch{t=this._scriptPath}E=y.resolve(y.dirname(t),E)}if(E){let u=findFile(E,w);if(!u&&!t._executableFile&&this._scriptPath){const p=y.basename(this._scriptPath,y.extname(this._scriptPath));if(p!==this._name){u=findFile(E,`${p}-${t._name}`)}}w=u||w}p=m.includes(y.extname(w));let P;if(b.platform!=="win32"){if(p){u.unshift(w);u=incrementNodeInspectorPort(b.execArgv).concat(u);P=g.spawn(b.argv[0],u,{stdio:"inherit"})}else{P=g.spawn(w,u,{stdio:"inherit"})}}else{this._checkForMissingExecutable(w,E,t._name);u.unshift(w);u=incrementNodeInspectorPort(b.execArgv).concat(u);P=g.spawn(b.execPath,u,{stdio:"inherit"})}if(!P.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{b.on(t,(()=>{if(P.killed===false&&P.exitCode===null){P.kill(t)}}))}))}const A=this._exitCallback;P.on("close",(t=>{t=t??1;if(!A){b.exit(t)}else{A(new $(t,"commander.executeSubCommandAsync","(close)"))}}));P.on("error",(u=>{if(u.code==="ENOENT"){this._checkForMissingExecutable(w,E,t._name)}else if(u.code==="EACCES"){throw new Error(`'${w}' not executable`)}if(!A){b.exit(1)}else{const t=new $(1,"commander.executeSubCommandAsync","(error)");t.nestedError=u;A(t)}}));this.runningCommand=P}_dispatchSubcommand(t,u,p){const m=this._findCommand(t);if(!m)this.help({error:true});m._prepareForParse();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?.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?.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;function maybeOption(t){return t.length>1&&t[0]==="-"}const negativeNumberArg=t=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(t))return false;return!this._getCommandAndAncestors().some((t=>t.options.map((t=>t.short)).some((t=>/^-\d$/.test(t)))))};let g=null;let y=null;let v=0;while(v<t.length||y){const b=y??t[v++];y=null;if(b==="--"){if(m===p)m.push(b);m.push(...t.slice(v));break}if(g&&(!maybeOption(b)||negativeNumberArg(b))){this.emit(`option:${g.name()}`,b);continue}g=null;if(maybeOption(b)){const u=this._findOption(b);if(u){if(u.required){const p=t[v++];if(p===undefined)this.optionMissingArgument(u);this.emit(`option:${u.name()}`,p)}else if(u.optional){let p=null;if(v<t.length&&(!maybeOption(t[v])||negativeNumberArg(t[v]))){p=t[v++]}this.emit(`option:${u.name()}`,p)}else{this.emit(`option:${u.name()}`)}g=u.variadic?u:null;continue}}if(b.length>2&&b[0]==="-"&&b[1]!=="-"){const t=this._findOption(`-${b[1]}`);if(t){if(t.required||t.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${t.name()}`,b.slice(2))}else{this.emit(`option:${t.name()}`);y=`-${b.slice(2)}`}continue}}if(/^--[^=]+=/.test(b)){const t=b.indexOf("=");const u=this._findOption(b.slice(0,t));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,b.slice(t+1));continue}}if(m===u&&maybeOption(b)&&!(this.commands.length===0&&negativeNumberArg(b))){m=p}if((this._enablePositionalOptions||this._passThroughOptions)&&u.length===0&&p.length===0){if(this._findCommand(b)){u.push(b);p.push(...t.slice(v));break}else if(this._getHelpCommand()&&b===this._getHelpCommand().name()){u.push(b,...t.slice(v));break}else if(this._defaultCommandName){p.push(b,...t.slice(v));break}}if(this._passThroughOptions){m.push(b,...t.slice(v));break}m.push(b)}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 b.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()}`,b.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=x(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=x(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=>E(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}helpGroup(t){if(t===undefined)return this._helpGroupHeading??"";this._helpGroupHeading=t;return this}commandsGroup(t){if(t===undefined)return this._defaultCommandGroup??"";this._defaultCommandGroup=t;return this}optionsGroup(t){if(t===undefined)return this._defaultOptionGroup??"";this._defaultOptionGroup=t;return this}_initOptionGroup(t){if(this._defaultOptionGroup&&!t.helpGroupHeading)t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){if(this._defaultCommandGroup&&!t.helpGroup())t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){this._name=y.basename(t,y.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const u=this.createHelp();const p=this._getOutputContext(t);u.prepareContext({error:p.error,helpWidth:p.helpWidth,outputHasColors:p.hasColors});const m=u.formatHelp(this,u);if(p.hasColors)return m;return this._outputConfiguration.stripColor(m)}_getOutputContext(t){t=t||{};const u=!!t.error;let p;let m;let g;if(u){p=t=>this._outputConfiguration.writeErr(t);m=this._outputConfiguration.getErrHasColors();g=this._outputConfiguration.getErrHelpWidth()}else{p=t=>this._outputConfiguration.writeOut(t);m=this._outputConfiguration.getOutHasColors();g=this._outputConfiguration.getOutHelpWidth()}const write=t=>{if(!m)t=this._outputConfiguration.stripColor(t);return p(t)};return{error:u,write:write,hasColors:m,helpWidth:g}}outputHelp(t){let u;if(typeof t==="function"){u=t;t=undefined}const p=this._getOutputContext(t);const m={error:p.error,write:p.write,command:this};this._getCommandAndAncestors().reverse().forEach((t=>t.emit("beforeAllHelp",m)));this.emit("beforeHelp",m);let g=this.helpInformation({error:p.error});if(u){g=u(g);if(typeof g!=="string"&&!Buffer.isBuffer(g)){throw new Error("outputHelp callback must return a string or a Buffer")}}p.write(g);if(this._getHelpOption()?.long){this.emit(this._getHelpOption().long)}this.emit("afterHelp",m);this._getCommandAndAncestors().forEach((t=>t.emit("afterAllHelp",m)))}helpOption(t,u){if(typeof t==="boolean"){if(t){if(this._helpOption===null)this._helpOption=undefined;if(this._defaultOptionGroup){this._initOptionGroup(this._getHelpOption())}}else{this._helpOption=null}return this}this._helpOption=this.createOption(t??"-h, --help",u??"display help for command");if(t||u)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===undefined){this.helpOption(undefined,undefined)}return this._helpOption}addHelpOption(t){this._helpOption=t;this._initOptionGroup(t);return this}help(t){this.outputHelp(t);let u=Number(b.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}))}function useColor(){if(b.env.NO_COLOR||b.env.FORCE_COLOR==="0"||b.env.FORCE_COLOR==="false")return false;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==undefined)return true;return undefined}u.Command=Command;u.useColor=useColor},9400:(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},2559:(t,u,p)=>{const{humanReadableArgName:m}=p(1455);class Help{constructor(){this.helpWidth=undefined;this.minWidthToWrap=40;this.sortSubcommands=false;this.sortOptions=false;this.showGlobalOptions=false}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}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,this.displayWidth(u.styleSubcommandTerm(u.subcommandTerm(p))))),0)}longestOptionTermLength(t,u){return u.visibleOptions(t).reduce(((t,p)=>Math.max(t,this.displayWidth(u.styleOptionTerm(u.optionTerm(p))))),0)}longestGlobalOptionTermLength(t,u){return u.visibleGlobalOptions(t).reduce(((t,p)=>Math.max(t,this.displayWidth(u.styleOptionTerm(u.optionTerm(p))))),0)}longestArgumentTermLength(t,u){return u.visibleArguments(t).reduce(((t,p)=>Math.max(t,this.displayWidth(u.styleArgumentTerm(u.argumentTerm(p))))),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){const p=`(${u.join(", ")})`;if(t.description){return`${t.description} ${p}`}return p}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}formatItemList(t,u,p){if(u.length===0)return[];return[p.styleTitle(t),...u,""]}groupItems(t,u,p){const m=new Map;t.forEach((t=>{const u=p(t);if(!m.has(u))m.set(u,[])}));u.forEach((t=>{const u=p(t);if(!m.has(u)){m.set(u,[])}m.get(u).push(t)}));return m}formatHelp(t,u){const p=u.padWidth(t,u);const m=u.helpWidth??80;function callFormatItem(t,m){return u.formatItem(t,p,m,u)}let g=[`${u.styleTitle("Usage:")} ${u.styleUsage(u.commandUsage(t))}`,""];const y=u.commandDescription(t);if(y.length>0){g=g.concat([u.boxWrap(u.styleCommandDescription(y),m),""])}const v=u.visibleArguments(t).map((t=>callFormatItem(u.styleArgumentTerm(u.argumentTerm(t)),u.styleArgumentDescription(u.argumentDescription(t)))));g=g.concat(this.formatItemList("Arguments:",v,u));const b=this.groupItems(t.options,u.visibleOptions(t),(t=>t.helpGroupHeading??"Options:"));b.forEach(((t,p)=>{const m=t.map((t=>callFormatItem(u.styleOptionTerm(u.optionTerm(t)),u.styleOptionDescription(u.optionDescription(t)))));g=g.concat(this.formatItemList(p,m,u))}));if(u.showGlobalOptions){const p=u.visibleGlobalOptions(t).map((t=>callFormatItem(u.styleOptionTerm(u.optionTerm(t)),u.styleOptionDescription(u.optionDescription(t)))));g=g.concat(this.formatItemList("Global Options:",p,u))}const w=this.groupItems(t.commands,u.visibleCommands(t),(t=>t.helpGroup()||"Commands:"));w.forEach(((t,p)=>{const m=t.map((t=>callFormatItem(u.styleSubcommandTerm(u.subcommandTerm(t)),u.styleSubcommandDescription(u.subcommandDescription(t)))));g=g.concat(this.formatItemList(p,m,u))}));return g.join("\n")}displayWidth(t){return stripColor(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map((t=>{if(t==="[options]")return this.styleOptionText(t);if(t==="[command]")return this.styleSubcommandText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleCommandText(t)})).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map((t=>{if(t==="[options]")return this.styleOptionText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleSubcommandText(t)})).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,u){return Math.max(u.longestOptionTermLength(t,u),u.longestGlobalOptionTermLength(t,u),u.longestSubcommandTermLength(t,u),u.longestArgumentTermLength(t,u))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,u,p,m){const g=2;const y=" ".repeat(g);if(!p)return y+t;const v=t.padEnd(u+t.length-m.displayWidth(t));const b=2;const w=this.helpWidth??80;const E=w-u-b-g;let $;if(E<this.minWidthToWrap||m.preformatted(p)){$=p}else{const t=m.boxWrap(p,E);$=t.replace(/\n/g,"\n"+" ".repeat(u+b))}return y+v+" ".repeat(b)+$.replace(/\n/g,`\n${y}`)}boxWrap(t,u){if(u<this.minWidthToWrap)return t;const p=t.split(/\r\n|\n/);const m=/[\s]*[^\s]+/g;const g=[];p.forEach((t=>{const p=t.match(m);if(p===null){g.push("");return}let y=[p.shift()];let v=this.displayWidth(y[0]);p.forEach((t=>{const p=this.displayWidth(t);if(v+p<=u){y.push(t);v+=p;return}g.push(y.join(""));const m=t.trimStart();y=[m];v=this.displayWidth(m)}));g.push(y.join(""))}));return g.join("\n")}}function stripColor(t){const u=/\x1b\[\d*(;\d*)*m/g;return t.replace(u,"")}u.Help=Help;u.stripColor=stripColor},1033:(t,u,p)=>{const{InvalidArgumentError:m}=p(9400);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;this.helpGroupHeading=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}_collectValue(t,u){if(u===this.defaultValue||!Array.isArray(u)){return[t]}u.push(t);return u}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._collectValue(t,u)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){if(this.negate){return camelcase(this.name().replace(/^no-/,""))}return camelcase(this.name())}helpGroup(t){this.helpGroupHeading=t;return this}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=/^-[^-]$/;const g=/^--[^-]/;const y=t.split(/[ |,]+/).concat("guard");if(m.test(y[0]))u=y.shift();if(g.test(y[0]))p=y.shift();if(!u&&m.test(y[0]))u=y.shift();if(!u&&g.test(y[0])){u=p;p=y.shift()}if(y[0].startsWith("-")){const u=y[0];const p=`option creation failed due to '${u}' in option flags '${t}'`;if(/^-[^-][^-]/.test(u))throw new Error(`${p}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(m.test(u))throw new Error(`${p}\n- too many short flags`);if(g.test(u))throw new Error(`${p}\n- too many long flags`);throw new Error(`${p}\n- unrecognised flag format`)}if(u===undefined&&p===undefined)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:u,longFlag:p}}u.Option=Option;u.DualOptions=DualOptions},3683:(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 y=1;if(t[g-1]===u[p-1]){y=0}else{y=1}m[g][p]=Math.min(m[g-1][p]+1,m[g][p-1]+1,m[g-1][p-1]+y);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 y=p;const v=.4;u.forEach((u=>{if(u.length<=1)return;const p=editDistance(t,u);const m=Math.max(t.length,u.length);const b=(m-p)/m;if(b>v){if(p<y){y=p;g=[u]}else if(p===y){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},6564:(t,u,p)=>{"use strict";const{normalizeIPv6:m,removeDotSegments:g,recomposeAuthority:y,normalizeComponentEncoding:v,isIPv4:b,nonSimpleDomain:w}=p(1097);const{SCHEMES:E,getSchemeHandler:$}=p(2424);function normalize(t,u){if(typeof t==="string"){t=serialize(parse(t,u),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 g=resolveComponent(parse(t,m),parse(u,m),m,true);m.skipEscape=true;return serialize(g,m)}function resolveComponent(t,u,p,m){const y={};if(!m){t=parse(serialize(t,p),p);u=parse(serialize(u,p),p)}p=p||{};if(!p.tolerant&&u.scheme){y.scheme=u.scheme;y.userinfo=u.userinfo;y.host=u.host;y.port=u.port;y.path=g(u.path||"");y.query=u.query}else{if(u.userinfo!==undefined||u.host!==undefined||u.port!==undefined){y.userinfo=u.userinfo;y.host=u.host;y.port=u.port;y.path=g(u.path||"");y.query=u.query}else{if(!u.path){y.path=t.path;if(u.query!==undefined){y.query=u.query}else{y.query=t.query}}else{if(u.path[0]==="/"){y.path=g(u.path)}else{if((t.userinfo!==undefined||t.host!==undefined||t.port!==undefined)&&!t.path){y.path="/"+u.path}else if(!t.path){y.path=u.path}else{y.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+u.path}y.path=g(y.path)}y.query=u.query}y.userinfo=t.userinfo;y.host=t.host;y.port=t.port}y.scheme=t.scheme}y.fragment=u.fragment;return y}function equal(t,u,p){if(typeof t==="string"){t=unescape(t);t=serialize(v(parse(t,p),true),{...p,skipEscape:true})}else if(typeof t==="object"){t=serialize(v(t,true),{...p,skipEscape:true})}if(typeof u==="string"){u=unescape(u);u=serialize(v(parse(u,p),true),{...p,skipEscape:true})}else if(typeof u==="object"){u=serialize(v(u,true),{...p,skipEscape:true})}return t.toLowerCase()===u.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 v=[];const b=$(m.scheme||p.scheme);if(b&&b.serialize)b.serialize(p,m);if(p.path!==undefined){if(!m.skipEscape){p.path=escape(p.path);if(p.scheme!==undefined){p.path=p.path.split("%3A").join(":")}}else{p.path=unescape(p.path)}}if(m.reference!=="suffix"&&p.scheme){v.push(p.scheme,":")}const w=y(p);if(w!==undefined){if(m.reference!=="suffix"){v.push("//")}v.push(w);if(p.path&&p.path[0]!=="/"){v.push("/")}}if(p.path!==undefined){let t=p.path;if(!m.absolutePath&&(!b||!b.absolutePath)){t=g(t)}if(w===undefined&&t[0]==="/"&&t[1]==="/"){t="/%2F"+t.slice(2)}v.push(t)}if(p.query!==undefined){v.push("?",p.query)}if(p.fragment!==undefined){v.push("#",p.fragment)}return v.join("")}const P=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function parse(t,u){const p=Object.assign({},u);const g={scheme:undefined,userinfo:undefined,host:"",port:undefined,path:"",query:undefined,fragment:undefined};let y=false;if(p.reference==="suffix"){if(p.scheme){t=p.scheme+":"+t}else{t="//"+t}}const v=t.match(P);if(v){g.scheme=v[1];g.userinfo=v[3];g.host=v[4];g.port=parseInt(v[5],10);g.path=v[6]||"";g.query=v[7];g.fragment=v[8];if(isNaN(g.port)){g.port=v[5]}if(g.host){const t=b(g.host);if(t===false){const t=m(g.host);g.host=t.host.toLowerCase();y=t.isIPV6}else{y=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 u=$(p.scheme||g.scheme);if(!p.unicodeSupport&&(!u||!u.unicodeSupport)){if(g.host&&(p.domainHost||u&&u.domainHost)&&y===false&&w(g.host)){try{g.host=URL.domainToASCII(g.host.toLowerCase())}catch(t){g.error=g.error||"Host's domain name can not be converted to ASCII: "+t}}}if(!u||u&&!u.skipNormalize){if(t.indexOf("%")!==-1){if(g.scheme!==undefined){g.scheme=unescape(g.scheme)}if(g.host!==undefined){g.host=unescape(g.host)}}if(g.path){g.path=escape(unescape(g.path))}if(g.fragment){g.fragment=encodeURI(decodeURIComponent(g.fragment))}}if(u&&u.parse){u.parse(g,p)}}else{g.error=g.error||"URI can not be parsed."}return g}const A={SCHEMES:E,normalize:normalize,resolve:resolve,resolveComponent:resolveComponent,equal:equal,serialize:serialize,parse:parse};t.exports=A;t.exports["default"]=A;t.exports.fastUri=A},2424:(t,u,p)=>{"use strict";const{isUUID:m}=p(1097);const g=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;const y=["http","https","ws","wss","urn","urn:uuid"];function isValidSchemeName(t){return y.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 y=getSchemeHandler(g);t.path=undefined;if(y){t=y.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 y=getSchemeHandler(g);if(y){t=y.serialize(t,u)}const v=t;const b=t.nss;v.path=`${m||u.nid}:${b}`;u.skipEscape=true;return v}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 v={scheme:"http",domainHost:true,parse:httpParse,serialize:httpSerialize};const b={scheme:"https",domainHost:v.domainHost,parse:httpParse,serialize:httpSerialize};const w={scheme:"ws",domainHost:true,parse:wsParse,serialize:wsSerialize};const E={scheme:"wss",domainHost:w.domainHost,parse:w.parse,serialize:w.serialize};const $={scheme:"urn",parse:urnParse,serialize:urnSerialize,skipNormalize:true};const P={scheme:"urn:uuid",parse:urnuuidParse,serialize:urnuuidSerialize,skipNormalize:true};const A={http:v,https:b,ws:w,wss:E,urn:$,"urn:uuid":P};Object.setPrototypeOf(A,null);function getSchemeHandler(t){return t&&(A[t]||A[t.toLowerCase()])||undefined}t.exports={wsIsSecure:wsIsSecure,SCHEMES:A,isValidSchemeName:isValidSchemeName,getSchemeHandler:getSchemeHandler}},1097: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);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 m=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 y=false;let v=false;let b=consumeHextets;for(let w=0;w<t.length;w++){const E=t[w];if(E==="["||E==="]"){continue}if(E===":"){if(y===true){v=true}if(!b(g,m,p)){break}if(++u>7){p.error=true;break}if(w>0&&t[w-1]===":"){y=true}m.push(":");continue}else if(E==="%"){if(!b(g,m,p)){break}b=consumeIsZone}else{g.push(E);continue}}if(g.length){if(b===consumeIsZone){p.zone=g.join("")}else if(v){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("")}function normalizeComponentEncoding(t,u){const p=u!==true?escape:unescape;if(t.scheme!==undefined){t.scheme=p(t.scheme)}if(t.userinfo!==undefined){t.userinfo=p(t.userinfo)}if(t.host!==undefined){t.host=p(t.host)}if(t.path!==undefined){t.path=p(t.path)}if(t.query!==undefined){t.query=p(t.query)}if(t.fragment!==undefined){t.fragment=p(t.fragment)}return t}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 u=normalizeIPv6(m);if(u.isIPV6===true){m=`[${u.escapedHost}]`}else{m=t.host}}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:m,recomposeAuthority:recomposeAuthority,normalizeComponentEncoding:normalizeComponentEncoding,removeDotSegments:removeDotSegments,isIPv4:p,isUUID:u,normalizeIPv6:normalizeIPv6,stringArrayToHexStripped:stringArrayToHexStripped}},2200: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}')},5727: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"}}}}')},1447: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"}}}')},4877: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"}}}')},9041: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"}}}')},5118: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}}}')},8606: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"}}}')},3073: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":[]}}}')},1115: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}}}')},7578: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}')},7028:t=>{"use strict";t.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Alpic","constant":"ALPIC","env":"ALPIC_HOST"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE","pr":{"env":"AC_GIT_PR","ne":"false"}},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN","pr":{"env":"CODEBUILD_WEBHOOK_EVENT","any":["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{"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":"Cloudflare Pages","constant":"CLOUDFLARE_PAGES","env":"CF_PAGES"},{"name":"Cloudflare Workers","constant":"CLOUDFLARE_WORKERS","env":"WORKERS_CI"},{"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"}]')},6737:t=>{"use strict";t.exports=JSON.parse('["_http_agent","_http_client","_http_common","_http_incoming","_http_outgoing","_http_server","_stream_duplex","_stream_passthrough","_stream_readable","_stream_transform","_stream_wrap","_stream_writable","_tls_common","_tls_wrap","assert","assert/strict","async_hooks","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","dns/promises","domain","events","fs","fs/promises","http","http2","https","inspector","inspector/promises","module","net","os","path","path/posix","path/win32","perf_hooks","process","punycode","querystring","readline","readline/promises","repl","stream","stream/consumers","stream/promises","stream/web","string_decoder","sys","timers","timers/promises","tls","trace_events","tty","url","util","util/types","v8","vm","wasi","worker_threads","zlib","node:sea","node:sqlite","node:test","node:test/reporters"]')}};var u={};function __nccwpck_require__(p){var m=u[p];if(m!==undefined){return m.exports}var g=u[p]={exports:{}};var y=true;try{t[p](g,g.exports,__nccwpck_require__);y=false}finally{if(y)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 y={};u=u||[null,t({}),t([]),t(t)];for(var v=m&2&&p;typeof v=="object"&&!~u.indexOf(v);v=t(v)){Object.getOwnPropertyNames(v).forEach((t=>y[t]=()=>p[t]))}y["default"]=()=>p;__nccwpck_require__.d(g,y);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__(3024);var u=__nccwpck_require__(6760);var p=__nccwpck_require__.n(u);var m=__nccwpck_require__(4732);var g=__nccwpck_require__.n(m);var y=__nccwpck_require__(206);const{DM:v,gu:b,er:w,Ww:E,b7:$,Di:P,a2:A,uB:O,ef:R,c$:x,_V:T}=y;const k=require("node:util");var C=__nccwpck_require__(1708);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=>{if(!isObject(t)){return false}for(const u in t){if(Object.hasOwn(t,u)){return false}}return true};const D=new Set(["__proto__","prototype","constructor"]);const j=1e6;const isDigit=t=>t>="0"&&t<="9";function shouldCoerceToNumber(t){if(t==="0"){return true}if(/^[1-9]\d*$/.test(t)){const u=Number.parseInt(t,10);return u<=Number.MAX_SAFE_INTEGER&&u<=j}return false}function processSegment(t,u){if(D.has(t)){return false}if(t&&shouldCoerceToNumber(t)){u.push(Number.parseInt(t,10))}else{u.push(t)}return true}function parsePath(t){if(typeof t!=="string"){throw new TypeError(`Expected a string, got ${typeof t}`)}const u=[];let p="";let m="start";let g=false;let y=0;for(const v of t){y++;if(g){p+=v;g=false;continue}if(v==="\\"){if(m==="index"){throw new Error(`Invalid character '${v}' in an index at position ${y}`)}if(m==="indexEnd"){throw new Error(`Invalid character '${v}' after an index at position ${y}`)}g=true;m=m==="start"?"property":m;continue}switch(v){case".":{if(m==="index"){throw new Error(`Invalid character '${v}' in an index at position ${y}`)}if(m==="indexEnd"){m="property";break}if(!processSegment(p,u)){return[]}p="";m="property";break}case"[":{if(m==="index"){throw new Error(`Invalid character '${v}' in an index at position ${y}`)}if(m==="indexEnd"){m="index";break}if(m==="property"||m==="start"){if((p||m==="property")&&!processSegment(p,u)){return[]}p=""}m="index";break}case"]":{if(m==="index"){if(p===""){const t=u.pop()||"";p=t+"[]";m="property"}else{const t=Number.parseInt(p,10);const g=!Number.isNaN(t)&&Number.isFinite(t)&&t>=0&&t<=Number.MAX_SAFE_INTEGER&&t<=j&&p===String(t);if(g){u.push(t)}else{u.push(p)}p="";m="indexEnd"}break}if(m==="indexEnd"){throw new Error(`Invalid character '${v}' after an index at position ${y}`)}p+=v;break}default:{if(m==="index"&&!isDigit(v)){throw new Error(`Invalid character '${v}' in an index at position ${y}`)}if(m==="indexEnd"){throw new Error(`Invalid character '${v}' after an index at position ${y}`)}if(m==="start"){m="property"}p+=v}}}if(g){p+="\\"}switch(m){case"property":{if(!processSegment(p,u)){return[]}break}case"index":{throw new Error("Index was not closed")}case"start":{u.push("");break}}return u}function normalizePath(t){if(typeof t==="string"){return parsePath(t)}if(Array.isArray(t)){const u=[];for(const[p,m]of t.entries()){if(typeof m!=="string"&&typeof m!=="number"){throw new TypeError(`Expected a string or number for path segment at index ${p}, got ${typeof m}`)}if(typeof m==="number"&&!Number.isFinite(m)){throw new TypeError(`Path segment at index ${p} must be a finite number, got ${m}`)}if(D.has(m)){return[]}if(typeof m==="string"&&shouldCoerceToNumber(m)){u.push(Number.parseInt(m,10))}else{u.push(m)}}return u}return[]}function getProperty(t,u,p){if(!isObject(t)||typeof u!=="string"&&!Array.isArray(u)){return p===undefined?t:p}const m=normalizePath(u);if(m.length===0){return p}for(let u=0;u<m.length;u++){const g=m[u];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"&&!Array.isArray(u)){return t}const m=t;const g=normalizePath(u);if(g.length===0){return t}for(let u=0;u<g.length;u++){const m=g[u];if(u===g.length-1){t[m]=p}else if(!isObject(t[m])){const p=g[u+1];const y=typeof p==="number";t[m]=y?[]:{}}t=t[m]}return m}function deleteProperty(t,u){if(!isObject(t)||typeof u!=="string"&&!Array.isArray(u)){return false}const p=normalizePath(u);if(p.length===0){return false}for(let u=0;u<p.length;u++){const m=p[u];if(u===p.length-1){const u=Object.hasOwn(t,m);if(!u){return false}delete t[m];return true}t=t[m];if(!isObject(t)){return false}}}function hasProperty(t,u){if(!isObject(t)||typeof u!=="string"&&!Array.isArray(u)){return false}const p=normalizePath(u);if(p.length===0){return false}for(const u of p){if(!isObject(t)||!(u in t)){return false}t=t[u]}return true}function escapePath(t){if(typeof t!=="string"){throw new TypeError(`Expected a string, got ${typeof t}`)}return t.replaceAll(/[\\.[]/g,String.raw`\$&`)}function normalizeEntries(t){const u=Object.entries(t);if(Array.isArray(t)){return u.map((([t,u])=>{const p=shouldCoerceToNumber(t)?Number.parseInt(t,10):t;return[p,u]}))}return u}function stringifyPath(t,u={}){if(!Array.isArray(t)){throw new TypeError(`Expected an array, got ${typeof t}`)}const{preferDotForIndices:p=false}=u;const m=[];for(const[u,g]of t.entries()){if(typeof g!=="string"&&typeof g!=="number"){throw new TypeError(`Expected a string or number for path segment at index ${u}, got ${typeof g}`)}if(typeof g==="number"){if(!Number.isInteger(g)||g<0){const t=escapePath(String(g));m.push(u===0?t:`.${t}`)}else if(p&&u>0){m.push(`.${g}`)}else{m.push(`[${g}]`)}}else if(typeof g==="string"){if(g===""){if(u===0){}else{m.push(".")}}else if(shouldCoerceToNumber(g)){const t=Number.parseInt(g,10);if(p&&u>0){m.push(`.${t}`)}else{m.push(`[${t}]`)}}else{const t=escapePath(g);m.push(u===0?t:`.${t}`)}}}return m.join("")}function*deepKeysIterator(t,u=[],p=new Set){if(!isObject(t)||isEmptyObject(t)){if(u.length>0){yield stringifyPath(u)}return}if(p.has(t)){return}p.add(t);for(const[m,g]of normalizeEntries(t)){u.push(m);yield*deepKeysIterator(g,u,p);u.pop()}p.delete(t)}function deepKeys(t){return[...deepKeysIterator(t)]}function unflatten(t){const u={};if(!isObject(t)){return u}for(const[p,m]of Object.entries(t)){setProperty(u,p,m)}return u}const L=require("node:os");var M=__nccwpck_require__.n(L);const U=L.homedir();const B=L.tmpdir();const{env:H}=C;const macos=t=>{const p=u.join(U,"Library");return{data:u.join(p,"Application Support",t),config:u.join(p,"Preferences",t),cache:u.join(p,"Caches",t),log:u.join(p,"Logs",t),temp:u.join(B,t)}};const windows=t=>{const p=H.APPDATA||u.join(U,"AppData","Roaming");const m=H.LOCALAPPDATA||u.join(U,"AppData","Local");return{data:u.join(m,t,"Data"),config:u.join(p,t,"Config"),cache:u.join(m,t,"Cache"),log:u.join(m,t,"Log"),temp:u.join(B,t)}};const linux=t=>{const p=u.basename(U);return{data:u.join(H.XDG_DATA_HOME||u.join(U,".local","share"),t),config:u.join(H.XDG_CONFIG_HOME||u.join(U,".config"),t),cache:u.join(H.XDG_CACHE_HOME||u.join(U,".cache"),t),log:u.join(H.XDG_STATE_HOME||u.join(U,".local","state"),t),temp:u.join(B,p,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(C.platform==="darwin"){return macos(t)}if(C.platform==="win32"){return windows(t)}return linux(t)}var V=__nccwpck_require__(8474);const z=require("node:stream");const attemptifyAsync=(t,u)=>{const{onError:p}=u;return function attemptified(...u){return t.apply(undefined,u).catch(p)}};const G=attemptifyAsync;const attemptifySync=(t,u)=>{const{onError:p}=u;return function attemptified(...u){try{return t.apply(undefined,u)}catch(t){return p(t)}}};const W=attemptifySync;const q=250;const retryifyAsync=(t,u)=>{const{isRetriable:p}=u;return function retryified(u){const{timeout:m}=u;const g=u.interval??q;const y=Date.now()+m;return function attempt(...u){return t.apply(undefined,u).catch((t=>{if(!p(t))throw t;if(Date.now()>=y)throw t;const m=Math.round(g*Math.random());if(m>0){const t=new Promise((t=>setTimeout(t,m)));return t.then((()=>attempt.apply(undefined,u)))}else{return attempt.apply(undefined,u)}}))}}};const Y=retryifyAsync;const retryifySync=(t,u)=>{const{isRetriable:p}=u;return function retryified(u){const{timeout:m}=u;const g=Date.now()+m;return function attempt(...u){while(true){try{return t.apply(undefined,u)}catch(t){if(!p(t))throw t;if(Date.now()>=g)throw t;continue}}}}};const J=retryifySync;const Z={isChangeErrorOk:t=>{if(!Z.isNodeError(t))return false;const{code:u}=t;if(u==="ENOSYS")return true;if(!se&&(u==="EINVAL"||u==="EPERM"))return true;return false},isNodeError:t=>t instanceof Error,isRetriableError:t=>{if(!Z.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(!Z.isNodeError(t))throw t;if(Z.isChangeErrorOk(t))return;throw t}};const X=Z;const Q={onError:X.onChangeError};const ee={onError:()=>undefined};const se=C.getuid?!C.getuid():false;const ie={isRetriable:X.isRetriableError};const ne={attempt:{chmod:G((0,k.promisify)(t.chmod),Q),chown:G((0,k.promisify)(t.chown),Q),close:G((0,k.promisify)(t.close),ee),fsync:G((0,k.promisify)(t.fsync),ee),mkdir:G((0,k.promisify)(t.mkdir),ee),realpath:G((0,k.promisify)(t.realpath),ee),stat:G((0,k.promisify)(t.stat),ee),unlink:G((0,k.promisify)(t.unlink),ee),chmodSync:W(t.chmodSync,Q),chownSync:W(t.chownSync,Q),closeSync:W(t.closeSync,ee),existsSync:W(t.existsSync,ee),fsyncSync:W(t.fsync,ee),mkdirSync:W(t.mkdirSync,ee),realpathSync:W(t.realpathSync,ee),statSync:W(t.statSync,ee),unlinkSync:W(t.unlinkSync,ee)},retry:{close:Y((0,k.promisify)(t.close),ie),fsync:Y((0,k.promisify)(t.fsync),ie),open:Y((0,k.promisify)(t.open),ie),readFile:Y((0,k.promisify)(t.readFile),ie),rename:Y((0,k.promisify)(t.rename),ie),stat:Y((0,k.promisify)(t.stat),ie),write:Y((0,k.promisify)(t.write),ie),writeFile:Y((0,k.promisify)(t.writeFile),ie),closeSync:J(t.closeSync,ie),fsyncSync:J(t.fsyncSync,ie),openSync:J(t.openSync,ie),readFileSync:J(t.readFileSync,ie),renameSync:J(t.renameSync,ie),statSync:J(t.statSync,ie),writeSync:J(t.writeSync,ie),writeFileSync:J(t.writeFileSync,ie)}};const ae=ne;const le="utf8";const ue=438;const he=511;const de={};const fe={};const pe=C.geteuid?C.geteuid():-1;const me=C.getegid?C.getegid():-1;const ge=200;const ye=7500;const ve=1e3;const _e=!!C.getuid;const be=C.getuid?!C.getuid():false;const we=128;const 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 Ee={};const $e={next:t=>{const u=Ee[t];if(!u)return;u.shift();const p=u[0];if(p){p((()=>$e.next(t)))}else{delete Ee[t]}},schedule:t=>new Promise((u=>{let p=Ee[t];if(!p)p=Ee[t]=[];p.push(u);if(p.length>1)return;u((()=>$e.next(t)))}))};const Pe=null&&$e;const Ae=C.platform==="linux";const Oe=C.platform==="win32";const Re=["SIGHUP","SIGINT","SIGTERM"];if(!Oe){Re.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT")}if(Ae){Re.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")}const xe=Re;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(Oe&&(t!=="SIGINT"&&t!=="SIGTERM"&&t!=="SIGKILL")){C.kill(C.pid,"SIGTERM")}else{C.kill(C.pid,t)}}};this.hook=()=>{C.once("exit",(()=>this.exit()));for(const t of xe){try{C.once(t,(()=>this.exit(t)))}catch{}}};this.register=t=>{this.callbacks.add(t);return()=>{this.callbacks.delete(t)}};this.hook()}}const Te=new Interceptor;const ke=Te.register;const Ce=ke;const Ie={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 y=`${t}${g}`;return y},get:(t,u,p=true)=>{const m=Ie.truncate(u(t));if(m in Ie.store)return Ie.get(t,u,p);Ie.store[m]=p;const disposer=()=>delete Ie.store[m];return[m,disposer]},purge:t=>{if(!Ie.store[t])return;delete Ie.store[t];ae.attempt.unlink(t)},purgeSync:t=>{if(!Ie.store[t])return;delete Ie.store[t];ae.attempt.unlinkSync(t)},purgeSyncAll:()=>{for(const t in Ie.store){Ie.purgeSync(t)}},truncate:t=>{const p=u.basename(t);if(p.length<=we)return t;const m=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(p);if(!m)return t;const g=p.length-we;return`${t.slice(0,-p.length)}${m[1]}${m[2].slice(0,-g)}${m[3]}`}};Ce(Ie.purgeSyncAll);const Ne=Ie;function dist_readFile(t,u=DEFAULT_READ_OPTIONS){if(isString(u))return dist_readFile(t,{encoding:u});const p=u.timeout??DEFAULT_TIMEOUT_ASYNC;const m={timeout:p,interval:DEFAULT_INTERVAL_ASYNC};return fs.retry.readFile(m)(t,u)}function readFileSync(t,u=DEFAULT_READ_OPTIONS){if(isString(u))return readFileSync(t,{encoding:u});const p=u.timeout??DEFAULT_TIMEOUT_SYNC;const m={timeout:p};return fs.retry.readFileSync(m)(t,u)}function dist_writeFile(t,u,p,m){if(isFunction(p))return dist_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=p.timeout??DEFAULT_TIMEOUT_ASYNC;const g={timeout:m,interval:DEFAULT_INTERVAL_ASYNC};let y=null;let v=null;let b=null;let w=null;let E=null;try{if(p.schedule)y=await p.schedule(t);v=await Scheduler.schedule(t);const m=await fs.attempt.realpath(t);const $=!!m;t=m||t;[w,b]=Temp.get(t,p.tmpCreate||Temp.create,!(p.tmpPurge===false));const P=IS_POSIX&&isUndefined(p.chown);const A=isUndefined(p.mode);if($&&(P||A)){const u=await fs.attempt.stat(t);if(u){p={...p};if(P){p.chown={uid:u.uid,gid:u.gid}}if(A){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(g)(w,"w",p.mode||DEFAULT_FILE_MODE);if(p.tmpCreated){p.tmpCreated(w)}if(isString(u)){await fs.retry.write(g)(E,u,0,p.encoding||DEFAULT_ENCODING)}else if(u instanceof Readable){const t=createWriteStream(w,{fd:E,autoClose:false});const p=once(t,"finish");u.pipe(t);await p}else if(!isUndefined(u)){await fs.retry.write(g)(E,u,0,u.length,0)}if(p.fsync!==false){if(p.fsyncWait!==false){await fs.retry.fsync(g)(E)}else{fs.attempt.fsync(E)}}await fs.retry.close(g)(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(g)(w,t)}catch(u){if(!isException(u))throw u;if(u.code!=="ENAMETOOLONG")throw u;await fs.retry.rename(g)(w,Temp.truncate(t))}b();w=null}finally{if(E)await fs.attempt.close(E);if(w)Temp.purge(w);if(y)y();if(v)v()}}function writeFileSync(t,p,m=fe){if(lang_isString(m))return writeFileSync(t,p,{encoding:m});const g=m.timeout??ve;const y={timeout:g};let v=null;let b=null;let w=null;try{const g=ae.attempt.realpathSync(t);const E=!!g;t=g||t;[b,v]=Ne.get(t,m.tmpCreate||Ne.create,!(m.tmpPurge===false));const $=_e&&lang_isUndefined(m.chown);const P=lang_isUndefined(m.mode);if(E&&($||P)){const u=ae.attempt.statSync(t);if(u){m={...m};if($){m.chown={uid:u.uid,gid:u.gid}}if(P){m.mode=u.mode}}}if(!E){const p=u.dirname(t);ae.attempt.mkdirSync(p,{mode:he,recursive:true})}w=ae.retry.openSync(y)(b,"w",m.mode||ue);if(m.tmpCreated){m.tmpCreated(b)}if(lang_isString(p)){ae.retry.writeSync(y)(w,p,0,m.encoding||le)}else if(!lang_isUndefined(p)){ae.retry.writeSync(y)(w,p,0,p.length,0)}if(m.fsync!==false){if(m.fsyncWait!==false){ae.retry.fsyncSync(y)(w)}else{ae.attempt.fsync(w)}}ae.retry.closeSync(y)(w);w=null;if(m.chown&&(m.chown.uid!==pe||m.chown.gid!==me)){ae.attempt.chownSync(b,m.chown.uid,m.chown.gid)}if(m.mode&&m.mode!==ue){ae.attempt.chmodSync(b,m.mode)}try{ae.retry.renameSync(y)(b,t)}catch(u){if(!lang_isException(u))throw u;if(u.code!=="ENAMETOOLONG")throw u;ae.retry.renameSync(y)(b,Ne.truncate(t))}v();b=null}finally{if(w)ae.attempt.closeSync(w);if(b)Ne.purge(b)}}var De=__nccwpck_require__(8861);var je=__nccwpck_require__(8631);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 y=Object.getOwnPropertyDescriptor(u,p);if(!canCopyProperty(g,y)&&m){return}Object.defineProperty(t,p,y)};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 Le=Object.getOwnPropertyDescriptor(Function.prototype,"toString");const Me=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",Me);const{writable:y,enumerable:v,configurable:b}=Le;Object.defineProperty(t,"toString",{value:g,writable:y,enumerable:v,configurable:b})};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:y=true}=u;if(p<0||m<0){throw new RangeError("`wait` and `maxWait` must not be negative.")}if(!g&&!y){throw new Error("Both `before` and `after` are false, function wouldn't be called.")}let v;let b;let w;const debouncedFunction=function(...u){const E=this;const later=()=>{v=undefined;if(b){clearTimeout(b);b=undefined}if(y){w=t.apply(E,u)}};const maxLater=()=>{b=undefined;if(v){clearTimeout(v);v=undefined}if(y){w=t.apply(E,u)}};const $=g&&!v;clearTimeout(v);v=setTimeout(later,p);if(m>0&&m!==Number.POSITIVE_INFINITY&&!b){b=setTimeout(maxLater,m)}if($){w=t.apply(E,u)}return w};mimicFunction(debouncedFunction,t);debouncedFunction.cancel=()=>{if(v){clearTimeout(v);v=undefined}if(b){clearTimeout(b);b=undefined}};return debouncedFunction};const Fe=debounceFunction;var Ue=__nccwpck_require__(4423);const Be=Object.prototype.toString;const He="[object Uint8Array]";const Ve="[object ArrayBuffer]";function isType(t,u,p){if(!t){return false}if(t.constructor===u){return true}return Be.call(t)===p}function isUint8Array(t){return isType(t,Uint8Array,He)}function isArrayBuffer(t){return isType(t,ArrayBuffer,Ve)}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 ze={utf8:new globalThis.TextDecoder("utf8")};function uint8ArrayToString(t,u="utf8"){assertUint8ArrayOrArrayBuffer(t);ze[u]??=new globalThis.TextDecoder(u);return ze[u].decode(t)}function assertString(t){if(typeof t!=="string"){throw new TypeError(`Expected \`string\`, got \`${typeof t}\``)}}const Ge=new globalThis.TextEncoder;function stringToUint8Array(t){assertString(t);return Ge.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 We=65535;function uint8ArrayToBase64(t,{urlSafe:u=false}={}){assertUint8Array(t);let p="";for(let u=0;u<t.length;u+=We){const m=t.subarray(u,u+We);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 qe=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+=qe[t[p]]}return u}const Ke={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=Ke[t[m*2]];const g=Ke[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 y=0;y<m;y++){if(t[p+y]!==u[y]){g=false;break}}if(g){return p}}return-1}function includes(t,u){return indexOf(t,u)!==-1}const Ye="aes-256-cbc";const Je=new Set(["aes-256-cbc","aes-256-gcm","aes-256-ctr"]);const isSupportedEncryptionAlgorithm=t=>typeof t==="string"&&Je.has(t);const createPlainObject=()=>Object.create(null);const isExist=t=>t!==undefined;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 Ze="__internal__";const Xe=`${Ze}.migrations.version`;class Conf{path;events;#e;#t;#r;#s;#i={};#n=false;#o;#a;#c;constructor(t={}){const u=this.#l(t);this.#s=u;this.#u(u);this.#h(u);this.#d(u);this.events=new EventTarget;this.#t=u.encryptionKey;this.#r=u.encryptionAlgorithm??Ye;this.path=this.#f(u);this.#p(u);if(u.watch){this._watch()}}get(t,u){if(this.#s.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 ${Ze} key, as it's used to manage this module internal operations.`)}const{store:p}=this;const set=(t,u)=>{checkValueType(t,u);if(this.#s.accessPropertiesByDotNotation){setProperty(p,t,u)}else{if(t==="__proto__"||t==="constructor"||t==="prototype"){return}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.#s.accessPropertiesByDotNotation){return hasProperty(this.store,t)}return t in this.store}appendToArray(t,u){checkValueType(t,u);const p=this.#s.accessPropertiesByDotNotation?this._get(t,[]):t in this.store?this.store[t]:[];if(!Array.isArray(p)){throw new TypeError(`The key \`${t}\` is already set to a non-array value`)}this.set(t,[...p,u])}reset(...t){for(const u of t){if(isExist(this.#i[u])){this.set(u,this.#i[u])}}}delete(t){const{store:u}=this;if(this.#s.accessPropertiesByDotNotation){deleteProperty(u,t)}else{delete u[t]}this.store=u}clear(){const t=createPlainObject();for(const u of Object.keys(this.#i)){if(isExist(this.#i[u])){checkValueType(u,this.#i[u]);if(this.#s.accessPropertiesByDotNotation){setProperty(t,u,this.#i[u])}else{t[u]=this.#i[u]}}}this.store=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._handleValueChange((()=>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._handleStoreChange(t)}get size(){const t=Object.keys(this.store);return t.filter((t=>!this._isReservedKeyPath(t))).length}get store(){try{const u=t.readFileSync(this.path,this.#t?null:"utf8");const p=this._decryptData(u);const parseStore=t=>{const u=this._deserialize(t);if(!this.#n){this._validate(u)}return Object.assign(createPlainObject(),u)};return parseStore(p)}catch(t){if(t?.code==="ENOENT"){this._ensureDirectory();return createPlainObject()}if(this.#s.clearInvalidConfig){const u=t;if(u.name==="SyntaxError"){return createPlainObject()}if(u.message?.startsWith("Config schema violation:")){return createPlainObject()}if(u.message==="Failed to decrypt config data."){return createPlainObject()}}throw t}}set store(u){this._ensureDirectory();if(!hasProperty(u,Ze)){try{const p=t.readFileSync(this.path,this.#t?null:"utf8");const m=this._decryptData(p);const g=this._deserialize(m);if(hasProperty(g,Ze)){setProperty(u,Ze,getProperty(g,Ze))}}catch{}}if(!this.#n){this._validate(u)}this._write(u);this.events.dispatchEvent(new Event("change"))}*[Symbol.iterator](){for(const[t,u]of Object.entries(this.store)){if(!this._isReservedKeyPath(t)){yield[t,u]}}}_closeWatcher(){if(this.#o){this.#o.close();this.#o=undefined}if(this.#a){t.unwatchFile(this.path);this.#a=false}this.#c=undefined}_decryptData(t){const u=this.#t;if(!u){return typeof t==="string"?t:uint8ArrayToString(t)}const p=this.#r;const m=p==="aes-256-gcm"?16:0;const g=":".codePointAt(0);const y=typeof t==="string"?t.codePointAt(16):t[16];const v=g!==undefined&&y===g;if(!v){if(p==="aes-256-cbc"){return typeof t==="string"?t:uint8ArrayToString(t)}throw new Error("Failed to decrypt config data.")}const getEncryptedPayload=t=>{if(m===0){return{ciphertext:t}}const u=t.length-m;if(u<0){throw new Error("Invalid authentication tag length.")}return{ciphertext:t.slice(0,u),authenticationTag:t.slice(u)}};const b=t.slice(0,16);const w=t.slice(17);const E=typeof w==="string"?stringToUint8Array(w):w;const decrypt=t=>{const{ciphertext:m,authenticationTag:g}=getEncryptedPayload(E);const y=I.pbkdf2Sync(u,t,1e4,32,"sha512");const v=I.createDecipheriv(p,y,b);if(g){v.setAuthTag(g)}return uint8ArrayToString(concatUint8Arrays([v.update(m),v.final()]))};try{return decrypt(b)}catch{try{return decrypt(b.toString())}catch{}}if(p==="aes-256-cbc"){return typeof t==="string"?t:uint8ArrayToString(t)}throw new Error("Failed to decrypt config data.")}_handleStoreChange(t){let u=this.store;const onChange=()=>{const p=u;const m=this.store;if((0,k.isDeepStrictEqual)(m,p)){return}u=m;t.call(this,m,p)};this.events.addEventListener("change",onChange);return()=>{this.events.removeEventListener("change",onChange)}}_handleValueChange(t,u){let p=t();const onChange=()=>{const m=p;const g=t();if((0,k.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(){t.mkdirSync(u.dirname(this.path),{recursive:true})}_write(u){let p=this._serialize(u);const m=this.#t;if(m){const t=I.randomBytes(16);const u=I.pbkdf2Sync(m,t,1e4,32,"sha512");const g=I.createCipheriv(this.#r,u,t);const y=concatUint8Arrays([g.update(stringToUint8Array(p)),g.final()]);const v=[t,stringToUint8Array(":"),y];if(this.#r==="aes-256-gcm"){v.push(g.getAuthTag())}p=concatUint8Arrays(v)}if(C.env.SNAP){t.writeFileSync(this.path,p,{mode:this.#s.configFileMode})}else{try{writeFileSync(this.path,p,{mode:this.#s.configFileMode})}catch(u){if(u?.code==="EXDEV"){t.writeFileSync(this.path,p,{mode:this.#s.configFileMode});return}throw u}}}_watch(){this._ensureDirectory();if(!t.existsSync(this.path)){this._write(createPlainObject())}if(C.platform==="win32"||C.platform==="darwin"){this.#c??=Fe((()=>{this.events.dispatchEvent(new Event("change"))}),{wait:100});const p=u.dirname(this.path);const m=u.basename(this.path);this.#o=t.watch(p,{persistent:false,encoding:"utf8"},((t,u)=>{if(u&&u!==m){return}if(typeof this.#c==="function"){this.#c()}}))}else{this.#c??=Fe((()=>{this.events.dispatchEvent(new Event("change"))}),{wait:1e3});t.watchFile(this.path,{persistent:false},((t,u)=>{if(typeof this.#c==="function"){this.#c()}}));this.#a=true}}_migrate(t,u,p){let m=this._get(Xe,"0.0.0");const g=Object.keys(t).filter((t=>this._shouldPerformMigration(t,m,u)));let y=structuredClone(this.store);for(const v of g){try{if(p){p(this,{fromVersion:m,toVersion:v,finalVersion:u,versions:g})}const b=t[v];b?.(this);this._set(Xe,v);m=v;y=structuredClone(this.store)}catch(t){this.store=y;const u=t instanceof Error?t.message:String(t);throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${u}`)}}if(this._isVersionInRangeFormat(m)||!Ue.eq(m,u)){this._set(Xe,u)}}_containsReservedKey(t){if(typeof t==="string"){return this._isReservedKeyPath(t)}if(!t||typeof t!=="object"){return false}return this._objectContainsReservedKey(t)}_objectContainsReservedKey(t){if(!t||typeof t!=="object"){return false}for(const[u,p]of Object.entries(t)){if(this._isReservedKeyPath(u)){return true}if(this._objectContainsReservedKey(p)){return true}}return false}_isReservedKeyPath(t){return t===Ze||t.startsWith(`${Ze}.`)}_isVersionInRangeFormat(t){return Ue.clean(t)===null}_shouldPerformMigration(t,u,p){if(this._isVersionInRangeFormat(t)){if(u!=="0.0.0"&&Ue.satisfies(u,t)){return false}return Ue.satisfies(p,t)}if(Ue.lte(t,u)){return false}if(Ue.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}#l(t){const u={configName:"config",fileExtension:"json",projectSuffix:"nodejs",clearInvalidConfig:false,accessPropertiesByDotNotation:true,configFileMode:438,...t};u.encryptionAlgorithm??=Ye;if(!isSupportedEncryptionAlgorithm(u.encryptionAlgorithm)){throw new TypeError(`The \`encryptionAlgorithm\` option must be one of: ${[...Je].join(", ")}`)}if(!u.cwd){if(!u.projectName){throw new Error("Please specify the `projectName` option.")}u.cwd=envPaths(u.projectName,{suffix:u.projectSuffix}).config}if(typeof u.fileExtension==="string"){u.fileExtension=u.fileExtension.replace(/^\.+/,"")}return u}#u(t){if(!(t.schema??t.ajvOptions??t.rootSchema)){return}if(t.schema&&typeof t.schema!=="object"){throw new TypeError("The `schema` option must be an object.")}const u=je["default"];const p=new De.Ajv2020({allErrors:true,useDefaults:true,...t.ajvOptions});u(p);const m={...t.rootSchema,type:"object",properties:t.schema};this.#e=p.compile(m);this.#m(t.schema)}#m(t){const u=Object.entries(t??{});for(const[t,p]of u){if(!p||typeof p!=="object"){continue}if(!Object.hasOwn(p,"default")){continue}const{default:u}=p;if(u===undefined){continue}this.#i[t]=u}}#h(t){if(t.defaults){Object.assign(this.#i,t.defaults)}}#d(t){if(t.serialize){this._serialize=t.serialize}if(t.deserialize){this._deserialize=t.deserialize}}#f(t){const p=typeof t.fileExtension==="string"?t.fileExtension:undefined;const m=p?`.${p}`:"";return u.resolve(t.cwd,`${t.configName??"config"}${m}`)}#p(t){if(t.migrations){this.#g(t);this._validate(this.store);return}const u=this.store;const p=Object.assign(createPlainObject(),t.defaults??{},u);this._validate(p);try{N.deepEqual(u,p)}catch{this.store=p}}#g(t){const{migrations:u,projectVersion:p}=t;if(!u){return}if(!p){throw new Error("Please specify the `projectVersion` option.")}this.#n=true;try{const m=this.store;const g=Object.assign(createPlainObject(),t.defaults??{},m);try{N.deepEqual(m,g)}catch{this._write(g)}this._migrate(u,p,t.beforeEachMigration)}finally{this.#n=false}}}var Qe=__nccwpck_require__(9212);var et=__nccwpck_require__(6133);var tt=__nccwpck_require__.n(et);var rt=__nccwpck_require__(5059);var st=__nccwpck_require__.n(rt);var it=__nccwpck_require__(9642);var nt=__nccwpck_require__.n(it);const ot=require("node:fs/promises");var ct=__nccwpck_require__.n(ot);const ut="apitogo.config.json";const ht="Documentation";const dt="/api";const ft="API Reference";function isPlainObject(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}function deepMerge(t,u){const p={...t};for(const[t,m]of Object.entries(u)){const u=p[t];if(isPlainObject(u)&&isPlainObject(m)){p[t]=deepMerge(u,m)}else{p[t]=m}}return p}function parseJsonObjectFlag(t,u){if(t===undefined||t.trim()===""){return undefined}let p;try{p=JSON.parse(t)}catch{throw new Error(`--${u} must be a JSON object.`)}if(!isPlainObject(p)){throw new Error(`--${u} must be a JSON object.`)}return p}function titleFromDirectoryName(t){const u=t.split(/[-_\s]+/).filter(Boolean).map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join(" ");return u||"Developer Portal"}function createDefaultApitogoJsonConfig(t){const u=`/${t.pagesDir}/**/*.{md,mdx}`;return{site:{title:t.title,showTitleInHeader:false,logo:{src:{...DEFAULT_SITE_LOGO.src}}},authentication:{enabled:true,type:"dev-portal",redirectToAfterSignIn:"/account/dashboard",redirectToAfterSignUp:"/account/dashboard"},metadata:{favicon:"/Icon.png"},theme:{fonts:{sans:"Inter",mono:"JetBrains Mono"},light:{background:"#ffffff",foreground:"#252b3b",card:"#ffffff",cardForeground:"#252b3b",primary:"#0d9488",primaryForeground:"#ffffff",secondary:"#f4f6fb",secondaryForeground:"#252b3b",muted:"#e9edf5",mutedForeground:"rgba(37, 43, 59, 0.55)",accent:"rgba(13, 148, 136, 0.1)",accentForeground:"#0d9488",border:"#d9deea",input:"#d9deea",ring:"#0d9488"},dark:{background:"#252b3b",foreground:"#e9edf5",card:"#2b3243",cardForeground:"#e9edf5",primary:"#0d9488",primaryForeground:"#ffffff",secondary:"#1e2330",secondaryForeground:"#e9edf5",muted:"#1e2330",mutedForeground:"rgba(217, 222, 234, 0.58)",accent:"rgba(13, 148, 136, 0.12)",accentForeground:"#0d9488",border:"rgba(217, 222, 234, 0.18)",input:"#323a4f",ring:"#0d9488"}},header:{placements:{navigation:"center"},navigation:[{label:"Product",to:"/#features"},{label:"Pricing",to:"/pricing"},{label:"Docs",to:"/introduction"}]},modules:{docs:{files:u},landing:{enabled:true,path:"/",layout:"landing",page:"./landing/LandingPage.tsx",content:{footer:{brand:{name:"SampleAPI",tagline:"A hosted sandbox API for prototypes, demos, and QA — realistic data, real auth, real limits."},columns:[{title:"Product",links:[{label:"Overview",href:"/#features"},{label:"Pricing",href:"/pricing"},{label:"Documentation",href:"/introduction"}]},{title:"Account",links:[{label:"Log in",href:"/signin"},{label:"Get started",href:"/signup"},{label:"Dashboard",href:"/account/dashboard"}]},{title:"Company",links:[{label:"Contact",href:"#"},{label:"Terms",href:"#"},{label:"Privacy",href:"#"}]}],copyright:"© 2026 Sample API"}}},userPanel:{enabled:true,dashboard:{enabled:true,page:"./user-panel/DashboardPage.tsx"},userManagement:{enabled:true},plans:{enabled:true,page:"./user-panel/AccountPlansPage.tsx",items:[{sku:"free",displayName:"Free",priceAmount:0,billingPeriod:"month",limits:{rateLimit:{calls:1,renewalPeriodSeconds:60},quota:{calls:1e3,renewalPeriodDays:30}}},{sku:"developer",displayName:"Developer",priceAmount:19,billingPeriod:"month",limits:{rateLimit:{calls:2,renewalPeriodSeconds:60},quota:{calls:5e3,renewalPeriodDays:30}}},{sku:"team",displayName:"Team",priceAmount:79,billingPeriod:"month",limits:{rateLimit:{calls:60,renewalPeriodSeconds:60},quota:{calls:1e4,renewalPeriodDays:30}}},{sku:"enterprise",displayName:"Enterprise",pricingModel:"custom",priceLabel:"Let's talk",billingPeriod:"month"}]}}}}}function applyConfigPatches(t,u){var p;const m={...t};if(u.site){m.site=deepMerge(isPlainObject(m.site)?m.site:{},u.site)}if(u.theme){m.theme=deepMerge(isPlainObject(m.theme)?m.theme:{},u.theme)}if(u.authentication){m.authentication=deepMerge(isPlainObject(m.authentication)?m.authentication:{},u.authentication)}if((p=u.title)===null||p===void 0?void 0:p.trim()){const t=isPlainObject(m.site)?m.site:{};m.site={...t,title:u.title.trim()}}return m}const docSortRank=t=>{var u;const p=(u=t.split("/").at(-1))!==null&&u!==void 0?u:t;if(p==="introduction")return 0;if(p==="example")return 1;if(p==="getting-started")return 2;if(p==="index")return 3;return 4};const sortDocPaths=t=>[...t].sort(((t,u)=>{const p=docSortRank(t)-docSortRank(u);if(p!==0)return p;return t.localeCompare(u)}));const createTreeNode=()=>({docs:[],children:new Map});const titleCase=t=>t.split(/[-_\s]+/).filter(Boolean).map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join(" ");const buildTree=t=>{const u=createTreeNode();for(const p of t){const t=p.replace(/^\//,"").split("/").filter(Boolean);const m=t.slice(0,-1);let g=u;for(const t of m){let u=g.children.get(t);if(!u){u=createTreeNode();g.children.set(t,u)}g=u}g.docs.push(p)}return u};const treeToNavigationItems=t=>{const u=sortDocPaths(t.docs);const p=[...t.children.keys()].sort(((t,u)=>t.localeCompare(u))).map((u=>{const p=t.children.get(u);if(!p){throw new Error(`Missing child node for directory '${u}'.`)}return{type:"category",label:titleCase(u),items:treeToNavigationItems(p)}}));return[...u,...p]};function buildDocumentationItems(t){return treeToNavigationItems(buildTree(sortDocPaths([...new Set(t)])))}function navItemKey(t){if(typeof t==="string"){return`path:${t}`}if(typeof t.to==="string"){return`to:${t.to}`}if(typeof t.path==="string"){return`path:${t.path}`}if(t.type==="category"&&typeof t.label==="string"){return`category:${t.label}`}return JSON.stringify(t)}function normalizeDocRoute(t){const u=t.trim().replace(/^\.?\/+/,"").replace(/\.mdx?$/i,"").replace(/(^|\/)index$/,"");return`/${u}`}function docRoutesOf(t){if(typeof t==="string")return[normalizeDocRoute(t)];if(!isRecord(t))return[];if(t.type==="doc"){return[t.file,t.path].filter((t=>typeof t==="string")).map(normalizeDocRoute)}if(t.type==="link"&&typeof t.to==="string"){return t.to.startsWith("/")?[normalizeDocRoute(t.to)]:[]}if(t.type==="category"){return[...docRoutesOf(t.link),...Array.isArray(t.items)?t.items.flatMap(docRoutesOf):[]]}return[]}function collectNavigationDocRoutes(t){return new Set(Array.isArray(t)?t.flatMap(docRoutesOf):[])}function pruneKnownDocs(t,u){return t.flatMap((t=>{if(typeof t==="string"){return u.has(normalizeDocRoute(t))?[]:[t]}if(t.type!=="category"||!Array.isArray(t.items))return[t];const p=pruneKnownDocs(t.items,u);return p.length>0?[{...t,items:p}]:[]}))}function mergeNavItems(t,u){const p=[...t];for(const t of u){const u=navItemKey(t);const m=p.findIndex((t=>navItemKey(t)===u));if(m===-1){p.push(t);continue}const g=p[m];if(isRecord(g)&&isRecord(t)&&g.type==="category"&&t.type==="category"){p[m]={...g,items:mergeNavItems(Array.isArray(g.items)?g.items:[],Array.isArray(t.items)?t.items:[])}}}return p}function isRecord(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}function isDocumentationCategory(t){return typeof t==="object"&&t.type==="category"&&t.label===ht}function isApiReferenceLink(t){return typeof t==="object"&&t.type==="link"&&t.to===dt}function mergeDocumentationNavigation(t,u,p){const m=Array.isArray(t)?t:[];const g=buildDocumentationItems(u);const y=m.filter((t=>!isDocumentationCategory(t)));const v=m.find(isDocumentationCategory);const b=Array.isArray(v===null||v===void 0?void 0:v.items)?v.items:[];const w=p.force?g:mergeNavItems(b,pruneKnownDocs(g,collectNavigationDocRoutes(m)));const E={...v,type:"category",label:ht,items:w};if(g.length===0||!v&&w.length===0){return m}if(v){const t=m.findIndex(isDocumentationCategory);const u=[...m];u[t]=E;return u}return[E,...y]}function applyOpenApiToJsonConfig(t,u){const p={...t};p.apis=[{type:"file",input:u,path:"api"}];const m=Array.isArray(p.navigation)?[...p.navigation]:[];if(!m.some(isApiReferenceLink)){m.push({type:"link",to:dt,label:ft})}p.navigation=m;return ensureHeaderApiReferenceNavigation(p,dt,ft)}function openapiInputForConfig(t){if(t.startsWith("./")){return t}return`./${t}`}function toRelativeOpenApiInput(t,u){const p=path.isAbsolute(u)?u:path.resolve(t,u);const m=path.relative(t,p);const g=m.split(path.sep).join(path.posix.sep);if(!g){throw new Error("OpenAPI path must point to a file.")}return openapiInputForConfig(g)}function normalizePageSlug(t){return t.replace(/^\/+/,"").replace(/\/+$/,"").replace(/\.(mdx?|tsx|jsx)$/i,"")}function slugifyPlanSku(t){const u=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return u||"plan"}function buildLimits(t,u){return{rateLimit:{calls:t,renewalPeriodSeconds:60},quota:{calls:u,renewalPeriodDays:30}}}function buildPlanItemFromWizard(t){var u;const p=(u=t.sku)!==null&&u!==void 0?u:slugifyPlanSku(t.displayName);const m={sku:p,displayName:t.displayName,priceAmount:t.priceAmount,limits:buildLimits(t.rateLimitCalls,t.monthlyQuota)};if(t.pricingModel==="custom"){m.priceAmount=0;m.pricingModel="custom";return m}if(t.priceAmount>0){m.priceCurrency="usd";m.billingPeriod="month"}return m}function applyPlansToJsonConfig(t,u){if(u.length===0){return t}const p=isPlainObject(t.modules)?{...t.modules}:{};const m=isPlainObject(p.userPanel)?{...p.userPanel}:{};const g=isPlainObject(m.plans)?{...m.plans}:{};const y=Array.isArray(g.items)?[...g.items]:[];for(const t of u){const u=t.sku;const p=typeof u==="string"?y.findIndex((t=>t.sku===u)):-1;if(p>=0){y[p]={...y[p],...t}}else{y.push(t)}}m.plans={...g,enabled:true,items:y};p.userPanel=m;return ensureHeaderPricingNavigation({...t,modules:p})}const pt=null&&["dotnet","nodejs","python"];const yt={nodejs:["NODE_22_LTS","NODE_24_LTS"],python:["PYTHON_310","PYTHON_311","PYTHON_312","PYTHON_313","PYTHON_314"],dotnet:["DOTNET_8","DOTNET_9","DOTNET_10"]};function parseBackendRuntime(t){const u=t.trim().toLowerCase();if(u==="node"||u==="nodejs"){return"nodejs"}if(u==="dotnet"||u==="python"){return u}return null}function parseRuntimeVersion(t,u){const p=u.trim().toUpperCase();const m=yt[t];return m.includes(p)?p:null}function applyBackendToJsonConfig(t,u){const p=isPlainObject(t.backend)?t.backend:{};return{...t,backend:{...p,sourceDirectory:u.sourceDirectory,runtime:u.runtime,runtimeVersion:u.runtimeVersion}}}function toRoutePath(t,u){const p=t.replace(/\.(mdx?|tsx|jsx)$/i,"");const m=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");const g=p.replace(new RegExp(`^${m}/?`),"");const y=g.replace(/\/index$/,"");return`/${y||"index"}`}function pageComponentName(t){const u=t.replace(/^\/+/,"").split(/[^a-zA-Z0-9]+/).filter(Boolean).map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join("");const p=/^[A-Za-z]/.test(u)?u:`Page${u}`;return p.endsWith("Page")?p:`${p}Page`}const vt=null&&`import { devPortalBillingPlugin } from "@lukoweb/apitogo-plugin-dev-portal-billing";\nimport { buildApitogoConfig } from "@lukoweb/apitogo/build-config";\nimport siteConfig from "./apitogo.config.json";\n\nexport default buildApitogoConfig({\n ...siteConfig,\n plugins: [devPortalBillingPlugin()],\n});\n`;function isThinConfigWrapper(t){return/export\s+default\s+buildApitogoConfig\s*\(/.test(t)}function isManagedConfigWrapper(t){if(isThinConfigWrapper(t)){return true}return/from\s+["']\.\/apitogo\.config\.json["']/.test(t)&&/buildApitogoConfig\s*\(/.test(t)&&/type:\s*["']custom-page["']/.test(t)}function labelFromRoutePath(t){var u;const p=t.replace(/^\/+/,"");const m=(u=p.split("/").filter(Boolean).pop())!==null&&u!==void 0?u:p;return titleFromDirectoryName(m)}function buildThinWrapperWithCustomPages(t){if(t.length===0){return vt}const u=t.map((t=>{const u=t.replace(/^\//,"");const p=pageComponentName(u);return`import ${p} from "./pages/${u}";`})).join("\n");const p=t.map((t=>{const u=t.replace(/^\//,"");const p=pageComponentName(u);const m=labelFromRoutePath(t);return` {\n type: "custom-page",\n path: ${JSON.stringify(t)},\n label: ${JSON.stringify(m)},\n element: <${p} />,\n },`})).join("\n");return`${u}\nimport { devPortalBillingPlugin } from "@lukoweb/apitogo-plugin-dev-portal-billing";\nimport { buildApitogoConfig } from "@lukoweb/apitogo/build-config";\nimport siteConfig from "./apitogo.config.json";\n\nconst config = buildApitogoConfig({\n ...siteConfig,\n plugins: [devPortalBillingPlugin()],\n});\n\nexport default {\n ...config,\n navigation: [\n {\n type: "category",\n label: ${JSON.stringify(ht)},\n items: [\n${p}\n ...((((config.navigation ?? []).find(\n (item) =>\n typeof item === "object" &&\n item !== null &&\n "label" in item &&\n item.label === ${JSON.stringify(ht)},\n ) as { items?: unknown[] } | undefined)?.items ?? []).filter(\n (item) =>\n typeof item !== "string" ||\n !${JSON.stringify(t)}.includes(item),\n )),\n ],\n },\n ...(config.navigation ?? []).filter(\n (item) =>\n !(\n typeof item === "object" &&\n item !== null &&\n "label" in item &&\n item.label === ${JSON.stringify(ht)}\n ),\n ),\n ],\n};\n`}const _t="Docs";const bt="API Reference";const wt="/introduction";function header_docs_nav_isPlainObject(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}function readHeaderNavigation(t){if(!header_docs_nav_isPlainObject(t.header))return null;const{navigation:u}=t.header;if(!Array.isArray(u)||u.length===0)return null;return{header:{...t.header},navigation:[...u]}}function isDocsItem(t){return header_docs_nav_isPlainObject(t)&&(t.to===wt||typeof t.label==="string"&&t.label.trim().toLowerCase()===_t.toLowerCase())}function ensureHeaderDocsNavigation(t,u){const p=sortDocPaths(u)[0];const m=readHeaderNavigation(t);if(!p||!m)return t;const{header:g,navigation:y}=m;const v=y.findIndex(isDocsItem);if(v>=0){const u=y[v];if(u.to!==wt)return t;y[v]={...u,to:p}}else{y.push({label:_t,to:p})}return{...t,header:{...g,navigation:y}}}function header_docs_nav_ensureHeaderApiReferenceNavigation(t,u,p=bt){const m=readHeaderNavigation(t);if(!m)return t;const{header:g,navigation:y}=m;if(y.some((t=>header_docs_nav_isPlainObject(t)&&t.to===u))){return t}const v=y.findIndex(isDocsItem);const b={label:p,to:u};if(v>=0){y.splice(v+1,0,b)}else{y.push(b)}return{...t,header:{...g,navigation:y}}}const Et="apitogo.config.json";const St="apitogo.local.json";const $t="https://dp-example.azurecontainerapps.io";function isPlanFree(t){var u;return((u=t.priceAmount)!==null&&u!==void 0?u:0)<=0}function manifestFilePath(t){return path.join(path.resolve(t),Et)}const Pt=null&&["authentication","backend","gateway","projectId"];function readPlanItemsFromConfig(t){const u=t.modules;const p=u===null||u===void 0?void 0:u.userPanel;const m=p===null||p===void 0?void 0:p.plans;const g=m===null||m===void 0?void 0:m.items;if(Array.isArray(g)&&g.length){return g.map((t=>planForConfig(t)))}const y=t.plans;if(Array.isArray(y)&&y.length){return y.map((t=>planForConfig(t)))}return undefined}function readPricingEnabledFromConfig(t){const u=t.modules;const p=u===null||u===void 0?void 0:u.userPanel;const m=p===null||p===void 0?void 0:p.plans;if((m===null||m===void 0?void 0:m.enabled)===true){return true}const g=t.pricing;return(g===null||g===void 0?void 0:g.enabled)===true}function applyPlansToUserPanel(t,u,p){var m,g,y,v;if(u===undefined){return}const b=(m=t.modules)!==null&&m!==void 0?m:{};const w=(g=b.userPanel)!==null&&g!==void 0?g:{};const E=(y=w.plans)!==null&&y!==void 0?y:{};if(u.length>0){E.items=u.map((t=>planForConfig(t)));if(p!==false){E.enabled=(v=E.enabled)!==null&&v!==void 0?v:true}}else{delete E.items}w.plans=E;b.userPanel=w;t.modules=b;delete t.plans;if(u.length>0){const u=ensureHeaderPricingNavigation(t);t.header=u.header}}function applyPricingToUserPanel(t,u){var p,m,g;if((u===null||u===void 0?void 0:u.enabled)===undefined){return}const y=(p=t.modules)!==null&&p!==void 0?p:{};const v=(m=y.userPanel)!==null&&m!==void 0?m:{};const b=(g=v.plans)!==null&&g!==void 0?g:{};b.enabled=u.enabled;v.plans=b;y.userPanel=v;t.modules=y;delete t.pricing}function readSiteTitle(t){const u=t.site;if(typeof(u===null||u===void 0?void 0:u.title)==="string"&&u.title.trim()){return u.title.trim()}if(typeof t.siteName==="string"&&t.siteName.trim()){return t.siteName.trim()}const p=t.branding;if(typeof(p===null||p===void 0?void 0:p.title)==="string"&&p.title.trim()){return p.title.trim()}return undefined}function readLogoUrl(t){var u,p,m,g;const y=t.site;const v=t.branding;return((p=(u=y===null||y===void 0?void 0:y.logo)===null||u===void 0?void 0:u.src)===null||p===void 0?void 0:p.light)||((g=(m=y===null||y===void 0?void 0:y.logo)===null||m===void 0?void 0:m.src)===null||g===void 0?void 0:g.dark)||(y===null||y===void 0?void 0:y.logoUrl)||(v===null||v===void 0?void 0:v.logoUrl)}function readUserPanelEnabled(t){const u=t.modules;const p=u===null||u===void 0?void 0:u.userPanel;if((p===null||p===void 0?void 0:p.enabled)===true){return true}const m=p===null||p===void 0?void 0:p.dashboard;const g=p===null||p===void 0?void 0:p.userManagement;const y=p===null||p===void 0?void 0:p.apiKeys;const v=p===null||p===void 0?void 0:p.plans;return(m===null||m===void 0?void 0:m.enabled)===true||(g===null||g===void 0?void 0:g.enabled)===true||(y===null||y===void 0?void 0:y.enabled)===true||(v===null||v===void 0?void 0:v.enabled)===true}function stripAuthenticationSecrets(t){const{gateway:u,oidc:p,stripe:m,type:g,email:y,providers:v,...b}=t;const w=y;if(w){const{connectionString:t,...u}=w;b.email=u}if(Array.isArray(v)){b.providers=v.map((t=>{const u=t;const{clientSecret:p,...m}=u;return m}))}return b}function extractManifestFromConfig(t){var u,p,m;const g={};const y=readSiteTitle(t);if(y){g.siteName=y;const u=readLogoUrl(t);g.branding=u?{title:y,logoUrl:u}:{title:y}}const v=readUserPanelEnabled(t);const b=t.authentication;if(b||v){const t=stripAuthenticationSecrets({...b!==null&&b!==void 0?b:{},enabled:v,native:{...(u=b===null||b===void 0?void 0:b.native)!==null&&u!==void 0?u:{},enabled:(m=(p=b===null||b===void 0?void 0:b.native)===null||p===void 0?void 0:p.enabled)!==null&&m!==void 0?m:true},providers:Array.isArray(b===null||b===void 0?void 0:b.providers)?b.providers:[]});g.authentication=t}for(const u of Pt){if(u==="authentication"){continue}if(t[u]!==undefined){g[u]=t[u]}}if(g.gateway){g.gateway=gatewayForConfig(g.gateway)}const w=readPlanItemsFromConfig(t);if(w){g.plans=w}if(readPricingEnabledFromConfig(t)){g.pricing={enabled:true}}const E=readLandingFromConfig(t);if(E){g.landing=E}return g}function applyManifestToConfig(t,u){var p,m,g,y,v,b,w,E;const $={...t};const P=((p=u.siteName)===null||p===void 0?void 0:p.trim())||((g=(m=u.branding)===null||m===void 0?void 0:m.title)===null||g===void 0?void 0:g.trim())||readSiteTitle(t);if(P){const t=(y=$.site)!==null&&y!==void 0?y:{};t.title=P;if((v=u.branding)===null||v===void 0?void 0:v.logoUrl){const p=(b=t.logo)!==null&&b!==void 0?b:{};const m=(w=p.src)!==null&&w!==void 0?w:{};t.logo={...p,src:{...m,light:u.branding.logoUrl}}}$.site=t}for(const t of Pt){const p=u[t];if(p!==undefined){$[t]=t==="gateway"?gatewayForConfig(p):p}else{delete $[t]}}if(u.pricing!==undefined){applyPricingToUserPanel($,u.pricing)}if(u.plans!==undefined){applyPlansToUserPanel($,u.plans,(E=u.pricing)===null||E===void 0?void 0:E.enabled)}delete $.plans;delete $.pricing;if($.authentication&&typeof $.authentication==="object"){const t={...$.authentication};delete t.gateway;$.authentication=t}delete $.siteName;delete $.branding;delete $.projectName;return $}async function readLegacyManifest(t){return null}async function pathExists(t){try{await access(t);return true}catch{return false}}function normalizeBillingPeriod(t){if(!t){return"monthly"}const u=t.toLowerCase();if(u==="month"){return"monthly"}if(u==="year"){return"annual"}return u}const At=[{sku:"free",displayName:"Free",priceAmount:0,limits:{rateLimit:{calls:60,renewalPeriodSeconds:60}},includedActionKeys:[]},{sku:"pro",displayName:"Pro",priceAmount:9.99,billingPeriod:"month",limits:{rateLimit:{calls:100,renewalPeriodSeconds:60},quota:{calls:5e4,renewalPeriodDays:1}},includedActionKeys:[]}];const Ot=[{id:"docs",label:"Docs and custom React pages",availableLocally:true},{id:"pricing",label:"/pricing",availableLocally:false},{id:"apiReference",label:"API reference",availableLocally:true,requiresPublish:false},{id:"signIn",label:"Sign-in and account area",availableLocally:false,requiresPublish:true},{id:"subscriptions",label:"Free plan entitlement and paid checkout",availableLocally:false,requiresPublish:true},{id:"credentials",label:"Subscription keys via /credentials",availableLocally:false,requiresPublish:true}];const Rt=[{target:"apitogo.config.json",purpose:"Plans, branding, site settings, backend paths, projectId",tool:"update_dev_portal_manifest"},{target:"landing/LandingPage.tsx",purpose:"Home page sections composed as JSX (HeroSection, FeaturesSection, etc.)",tool:"get_dev_portal_landing_guide"},{target:"apitogo.config.tsx",purpose:"Plugins and custom code-only configuration"},{target:"pages/**/*.tsx",purpose:"Content pages as React components under a Documentation nav category (custom-page)",tool:"add_dev_portal_page"},{target:"OpenAPI (wire via set_dev_portal_openapi)",purpose:"API reference spec — points at the source file; does not copy into the site",tool:"set_dev_portal_openapi"}];const kt={id:"openapi",phase:"shape",prompt:"No OpenAPI found nearby — create a starter OpenAPI for the user (or ask for a path), then call set_dev_portal_openapi?",tool:"set_dev_portal_openapi",note:"Offer to draft openapi.yaml from their API description when they have no spec yet."};const Ct=[{id:"openapi",phase:"shape",prompt:"Add an OpenAPI spec to the site?",tool:"set_dev_portal_openapi"},{id:"designLanding",phase:"shape",prompt:"Design your home page?",tool:"get_dev_portal_landing_guide",optional:true,note:"Ask the user for their real content (product, endpoints, audience, tone, sections) before editing landing/LandingPage.tsx — compose HeroSection, TrustSection, FeaturesSection, StepsSection, ApiShowcaseSection, PlansPreviewSection, and PricingCtaSection inside LandingShell."},{id:"addPlans",phase:"shape",prompt:"Add subscription plans for /pricing?",tool:"update_dev_portal_manifest",note:"Or pass includeDefaultPlans: true on create_dev_portal for Free + Pro defaults."},{id:"customizePlans",phase:"shape",prompt:"Customize subscription plan SKUs, prices, or limits?",tool:"update_dev_portal_manifest",optional:true},{id:"pagesBranding",phase:"shape",prompt:"Add pages or update branding?",tool:"add_dev_portal_page",optional:true,note:"Use add_dev_portal_page or update_dev_portal_manifest for branding."},{id:"bootstrapProject",phase:"shape",prompt:"Bootstrap an API ToGo project (apihub + dev-portal)?",tool:"bootstrap_project",optional:true,note:"Creates the platform project only. Ask the tenant Free, Starter, or Professional hosting (see list_platform_plans), then call ensure_platform_plan. Or pass bootstrapProject: true on create_dev_portal."},{id:"goLive",phase:"publish",prompt:"Publish for real sign-in and subscriptions?",tool:"publish_dev_portal",note:"User saves OIDC (and Stripe if paid plans) in .env via APITOGO_CONFIG_AUTHENTICATION__* — never in chat."},{id:"backend",phase:"postPublish",prompt:"Connect/deploy an API backend?",tool:"update_dev_portal_manifest",optional:true},{id:"syncActions",phase:"postPublish",prompt:"Attach OpenAPI actions to gateway plans?",tool:"sync_gateway_plans_from_manifest",optional:true,note:"Use syncActionsOnly after backend deploy; publish already upserts plans."}];function buildScaffoldJourneyPhases(t=Ct){return[{id:"shape",title:"Shape the site",steps:t.filter((t=>t.phase==="shape"))},{id:"publish",title:"Go live",steps:t.filter((t=>t.phase==="publish"))},{id:"postPublish",title:"Post-publish API product",steps:t.filter((t=>t.phase==="postPublish"))}]}const It=buildScaffoldJourneyPhases();const Nt="Scaffold only — dependencies are installed but the dev server is not started. Tell the user the site is ready and to run npm run dev in outputDirectory. The home page lives in landing/LandingPage.tsx (default sample sections including plans). After npm run dev, ask if they want to customize the home page. When they do, always ask for their real content first (what the API does, key endpoints, audience, tone, desired sections) before editing — never invent placeholder copy unless they explicitly ask for placeholders — then edit that TSX file directly or call get_dev_portal_landing_guide for the component catalog. Do not write home page content to apitogo.config.json. Then ask what else they want (OpenAPI, plans, bootstrap API ToGo, or go live). Do not mention missing plans, null projectId, skipped bootstrap, publishPrerequisites, or other absent setup unless the user asks about publish or platform provisioning. One user intent → one MCP tool. When preview is running, shape-phase file edits hot-reload. Never pass restartPreview: true on update_dev_portal_manifest or set_dev_portal_theme (ignored; used to time out against npm run dev). For publish, the user saves OIDC (+ Stripe if paid) in .env using APITOGO_CONFIG_AUTHENTICATION__* keys — never collect secrets in chat. Call check_dev_portal_publish_readiness after they confirm, then publish_dev_portal. Do not call sync_gateway_plans_from_manifest before publish.";function manifestRequiresStripe(t){return(t!==null&&t!==void 0?t:[]).some((t=>!isPlanFree(t)))}function isNativeAuthEnabledInManifest(t){var u,p;if(((u=t.authentication)===null||u===void 0?void 0:u.enabled)!==true){return false}return((p=t.authentication.native)===null||p===void 0?void 0:p.enabled)!==false}function readManifestAuthProviders(t){var u,p;return(p=(u=t.authentication)===null||u===void 0?void 0:u.providers)!==null&&p!==void 0?p:[]}function getPublishPrerequisites(t,u,p){var m,g,y,v,b,w,E,$,P,A,O,R;void p;const x=[];const T=manifestRequiresStripe(t.plans);const k=((m=t.authentication)===null||m===void 0?void 0:m.enabled)===true;const C=k&&isNativeAuthEnabledInManifest(t);const I=(g=readManifestAuthProviders(t))!==null&&g!==void 0?g:[];if(!((y=t.plans)===null||y===void 0?void 0:y.length)){x.push("plans")}if(k){if(!C&&I.length===0){x.push("authentication.methods")}for(const t of I){const p=t.id.trim();if(!((v=t.authority)===null||v===void 0?void 0:v.trim())){x.push(`providers.${p}.authority`)}if(!((b=t.clientId)===null||b===void 0?void 0:b.trim())){x.push(`providers.${p}.clientId`)}if(!(($=(E=(w=u===null||u===void 0?void 0:u.providers)===null||w===void 0?void 0:w[p])===null||E===void 0?void 0:E.clientSecret)===null||$===void 0?void 0:$.trim())){x.push(`providers.${p}.clientSecret`)}}}const N=(A=(P=u===null||u===void 0?void 0:u.stripe)===null||P===void 0?void 0:P.secretKey)===null||A===void 0?void 0:A.trim();const D=(R=(O=u===null||u===void 0?void 0:u.stripe)===null||O===void 0?void 0:O.webhookSecret)===null||R===void 0?void 0:R.trim();if(T){if(!N){x.push("stripe.secretKey")}if(!D){x.push("stripe.webhookSecret")}}return{nativeAuthRequired:C,stripeRequired:T,missingFields:x,readyToPublish:x.length===0}}function resolveManifestNextStep(t,u){var p;if(!((p=t.plans)===null||p===void 0?void 0:p.length)){return"Ask the user what subscription plans they want (SKUs, free/paid, pricing). "+"Call update_dev_portal_manifest only after they specify — never add Free+Pro defaults on go-live unless they explicitly request them."}const m=getPublishPrerequisites(t,u);if(m.readyToPublish){return"Run publish_dev_portal when the tenant confirms go-live."}if(!u){return"Continue shaping the site in the running local preview. For publish, save auth secrets (OIDC provider secrets, and Stripe if paid plans) in .env using APITOGO_CONFIG_AUTHENTICATION__* keys — never in chat. Native auth email is always platform-managed."}const g=m.missingFields.filter((t=>t!=="plans"));if(g.length>0){return`Publish prerequisites incomplete in .env: ${g.join(", ")}.`}return`Publish prerequisites incomplete: ${m.missingFields.join(", ")}.`}function createScaffoldManifest(t){const u=(t===null||t===void 0?void 0:t.trim())||"Sample API";return{siteName:u,branding:{title:u}}}function resolveProjectDisplayName(t,u){var p,m,g;return((p=t.siteName)===null||p===void 0?void 0:p.trim())||((g=(m=t.branding)===null||m===void 0?void 0:m.title)===null||g===void 0?void 0:g.trim())||(u?readSiteTitle(u):undefined)||"Developer Portal"}function createDefaultManifest(t){return{...createScaffoldManifest(t),pricing:{enabled:true},plans:At}}function applyScaffoldManifestPolicy(t,u){var p,m,g,y,v,b;const w=((p=u.siteName)===null||p===void 0?void 0:p.trim())||((m=t.siteName)===null||m===void 0?void 0:m.trim())||((y=(g=t.branding)===null||g===void 0?void 0:g.title)===null||y===void 0?void 0:y.trim())||"Sample API";const E={...t,siteName:w,branding:{...t.branding,title:(b=(v=t.branding)===null||v===void 0?void 0:v.title)!==null&&b!==void 0?b:w}};if(u.includeDefaultPlans){E.plans=mergePlansBySku(E.plans,At);E.pricing={enabled:true}}return E}function mergePlansBySku(t,u){const p=new Map;for(const u of t!==null&&t!==void 0?t:[]){p.set(u.sku,u)}for(const t of u){const u=p.get(t.sku);p.set(t.sku,mergeLimitsSource(u,t))}return Array.from(p.values())}function resolveBackendSourceDirectory(t,u){const p=u===null||u===void 0?void 0:u.trim();if(!p){return undefined}return path.resolve(t,p)}function resolveBackendOpenApiPath(t,u){var p;const m=t===null||t===void 0?void 0:t.trim();if(!m){return undefined}if(path.isAbsolute(m)){return m}const g=path.resolve(u.siteDirectory,m);if(existsSync(g)){return g}const y=(p=u.backendSourceDirectory)===null||p===void 0?void 0:p.trim();if(y){const t=path.resolve(y,m);if(existsSync(t)){return t}}return g}function toSiteRelativeOpenApiInput(t,u){const m=p().relative(p().resolve(t),p().resolve(u));const g=m.split(p().sep).join("/");if(!g||g==="."){return"./"}if(p().isAbsolute(g)||g.startsWith("..")){return g}return g.startsWith("./")?g:`./${g}`}const Dt=new Set(["siteName","branding","pricing","authentication","plans","backend","gateway","projectId"]);const jt="Home page content belongs in landing/LandingPage.tsx — edit that file directly or call get_dev_portal_landing_guide.";function formatIgnoredManifestPatchWarning(t){if(t.length===0){return undefined}const u=t.some((t=>t==="landing"||t==="modules.landing"));const p=u?` ${jt}`:"";return`Patch keys not in the manifest schema were dropped: ${t.join(", ")}.${p} Verify the returned manifest contains your change.`}function normalizeManifestPatch(t){const u={...t};const p=[];const m=u.modules;if(m&&typeof m==="object"&&!Array.isArray(m)){if(m.landing!==undefined){p.push("modules.landing")}delete u.modules}if(u.landing!==undefined){p.push("landing");delete u.landing}for(const t of Object.keys(u)){if(!Dt.has(t)){p.push(t);delete u[t]}}return{patch:u,ignoredKeys:p}}function mergePublishPrerequisitesWithPlatformValidation(t,u){return{...t,manifestFieldIssues:u.length>0?u:undefined,readyToPublish:t.readyToPublish&&u.length===0}}function mergeManifest(t,u){var p,m,g;const y={...t,...u};if(u.branding){y.branding={...t.branding,...u.branding}}if(u.pricing){y.pricing={...t.pricing,...u.pricing}}if(u.backend){y.backend={...t.backend,...u.backend}}if(u.gateway){const g=(m=(p=t.gateway)===null||p===void 0?void 0:p.publicRoutes)!==null&&m!==void 0?m:[];const v=u.gateway.publicRoutes;y.gateway=mergeLimitsSource(t.gateway,u.gateway);if(v){y.gateway.publicRoutes=[...new Set([...g,...v].map((t=>t.trim())).filter(Boolean))]}}if(u.plans){y.plans=mergePlansBySku(t.plans,u.plans);if(u.plans.length>0&&((g=u.pricing)===null||g===void 0?void 0:g.enabled)!==false){y.pricing={...y.pricing,enabled:true}}}return y}function applyOpenApiToSiteConfig(t,u){var p;const m={...t};m.apis=[{type:"file",input:u.input,path:u.apiPath}];const g=`/${u.apiPath.replace(/^\//,"")}`;const y=Array.isArray(m.navigation)?[...m.navigation]:[];const v=y.some((t=>typeof t==="object"&&t!==null&&t.to===g));if(!v){y.push({type:"link",to:g,label:(p=u.navLabel)!==null&&p!==void 0?p:"API Reference"})}m.navigation=y;return header_docs_nav_ensureHeaderApiReferenceNavigation(m,g,u.navLabel)}async function readManifest(t){const u=manifestFilePath(t);if(await pathExists(u)){const t=await readFile(u,"utf8");const p=JSON.parse(t);return extractManifestFromConfig(p)}return readLegacyManifest(t)}async function writeManifest(t,u){const p=manifestFilePath(t);await mkdir(path.dirname(p),{recursive:true});let m={};if(await pathExists(p)){const t=await readFile(p,"utf8");m=JSON.parse(t)}const{oidc:g,stripe:y,...v}=u;m=applyManifestToConfig(m,v);await writeFile(p,`${JSON.stringify(m,null,2)}\n`,"utf8");return p}function plansToMockEnvValue(t){if(!(t===null||t===void 0?void 0:t.length)){return null}const u=t.map((t=>{var u,p,m,g;return{sku:t.sku,displayName:t.displayName,priceAmount:(u=t.priceAmount)!==null&&u!==void 0?u:0,pricingModel:(p=t.pricingModel)!==null&&p!==void 0?p:"fixed",priceLabel:t.priceLabel,priceCurrency:(m=t.priceCurrency)!==null&&m!==void 0?m:"usd",billingPeriod:normalizeBillingPeriod(t.billingPeriod),limitsJson:(g=planLimitsForPlatform(t))!==null&&g!==void 0?g:null}}));return JSON.stringify(u)}function mockPlansPreviewChanged(t,u){return plansToMockEnvValue(t)!==plansToMockEnvValue(u)}const Mt={dotnet:"DOTNET_10",nodejs:"NODE_22_LTS",python:"PYTHON_312"};const Ft=["pyproject.toml","requirements.txt","Pipfile"];async function listFiles(t){try{const u=await(0,ot.readdir)(t,{withFileTypes:true});return u.filter((t=>t.isFile())).map((t=>t.name))}catch{return[]}}async function readText(t){try{return await(0,ot.readFile)(t,"utf8")}catch{return undefined}}function dotnetVersionFromCsproj(t){const u=t===null||t===void 0?void 0:t.match(/<TargetFrameworks?>\s*net(\d+)\.\d/i);const p=u===null||u===void 0?void 0:u[1];if(p==="8"||p==="9"||p==="10"){return`DOTNET_${p}`}return Mt.dotnet}function nodeVersionFromEngines(t){const u=t&&typeof t==="object"&&!Array.isArray(t)?t.node:undefined;if(typeof u==="string"&&/(^|[^\d])24/.test(u)){return"NODE_24_LTS"}return Mt.nodejs}function pythonVersionFromText(t){const u=t===null||t===void 0?void 0:t.match(/3\.(1[0-4])/);return u?`PYTHON_3${u[1]}`:Mt.python}function isRunnableNodePackage(t){const u=t.scripts&&typeof t.scripts==="object"?t.scripts:{};return typeof u.start==="string"||typeof t.main==="string"}async function detectParentBackend(t){var u,m,g;const y=p().resolve(t);const v=p().dirname(y);if(v===y){return undefined}const b=await listFiles(v);const toResult=(t,u,m)=>({directory:v,sourceDirectory:p().relative(y,v).split(p().sep).join("/")||".",runtime:t,runtimeVersion:u,marker:m});const w=b.find((t=>t.endsWith(".csproj")));const E=b.find((t=>/\.slnx?$/.test(t)));if(w||E){const t=w?await readText(p().join(v,w)):undefined;return toResult("dotnet",dotnetVersionFromCsproj(t),w!==null&&w!==void 0?w:E)}if(b.includes("package.json")){const t=await readText(p().join(v,"package.json"));try{const u=JSON.parse(t!==null&&t!==void 0?t:"");if(isRunnableNodePackage(u)){return toResult("nodejs",nodeVersionFromEngines(u.engines),"package.json")}}catch{}}const $=Ft.find((t=>b.includes(t)));if($){const t=(u=await readText(p().join(v,".python-version")))!==null&&u!==void 0?u:$==="pyproject.toml"?(g=(m=await readText(p().join(v,$)))===null||m===void 0?void 0:m.match(/requires-python\s*=\s*"([^"]+)"/))===null||g===void 0?void 0:g[1]:undefined;return toResult("python",pythonVersionFromText(t),$)}return undefined}const Ut=["openapi.yaml","openapi.yml","openapi.json","swagger.yaml","swagger.yml","swagger.json"];const Bt="No OpenAPI file found near the site (checked parent, sibling folders, and the site directory for openapi.yaml|yml|json / swagger.yaml|yml|json). Ask the user for a path, or offer to draft a starter OpenAPI 3 spec from their API description, write it next to the site (e.g. ../openapi.yaml), then call set_dev_portal_openapi.";const Ht=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo",".cache",".apitogo"]);async function collectFromDir(u,m,g){const y=p().resolve(u);if(m.includes(y)){return}m.push(y);for(const u of Ut){const m=p().join(y,u);try{await t.promises.access(m);g.push(m)}catch{}}}async function collectSiteOpenApiFiles(t){const u=[];const p=[];await collectFromDir(t,u,p);return{candidates:[...new Set(p)],searchedDirectories:u}}async function collectNearbyOpenApiFiles(u){const m=p().resolve(u);const g=p().dirname(m);const y=[];const v=[];if(g&&g!==m){await collectFromDir(g,y,v);try{const u=await t.promises.readdir(g,{withFileTypes:true});for(const t of u){if(!t.isDirectory()||Ht.has(t.name)){continue}const u=p().join(g,t.name);if(p().resolve(u)===m){continue}await collectFromDir(u,y,v)}}catch{}}await collectFromDir(m,y,v);return{candidates:[...new Set(v)],searchedDirectories:y}}function parseOpenApiObject(t){const u=t.openapi;if(typeof u!=="string"||!u.startsWith("3.")){return{valid:false,errors:[`OpenAPI 3.x required; found ${String(u!==null&&u!==void 0?u:"missing")}.`]}}const p=t.info;return{valid:true,version:u,title:p===null||p===void 0?void 0:p.title,errors:[]}}function liteParseOpenApi(t,u){var m,g;const y=p().extname(u).toLowerCase();if(y===".json"){try{const u=JSON.parse(t);if(!u||typeof u!=="object"||Array.isArray(u)){return{valid:false,errors:["OpenAPI document must be a JSON object."]}}return parseOpenApiObject(u)}catch(t){return{valid:false,errors:[`Failed to parse OpenAPI document: ${t instanceof Error?t.message:String(t)}`]}}}const v=t.match(/^\s*openapi:\s*['"]?(3\.\d+(?:\.\d+)?)['"]?/m);if(!(v===null||v===void 0?void 0:v[1])){return{valid:false,errors:["OpenAPI 3.x required; missing openapi: 3.x field."]}}const b=t.match(/^\s*info:\s*\n((?:[ \t].*\n)+)/m);const w=(m=b===null||b===void 0?void 0:b[1])===null||m===void 0?void 0:m.match(/^\s*title:\s*['"]?(.+?)['"]?\s*$/m);return{valid:true,version:v[1],title:(g=w===null||w===void 0?void 0:w[1])===null||g===void 0?void 0:g.trim(),errors:[]}}const Vt=["docs","documents","documentation","doc"];const zt=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo",".cache",".apitogo"]);const Gt="pages";const Wt="apitogo.config.json";async function wire_docs_pathExists(t){try{await(0,ot.access)(t);return true}catch{return false}}async function isDirectory(t){try{const u=await(0,ot.lstat)(t);return u.isDirectory()}catch{return false}}function toPosix(t){return t.split(p().sep).join(p().posix.sep)}function isWhitelistedDirName(t){return Vt.includes(t.toLowerCase())}function isInside(t,u){const m=p().relative(t,u);return m===""||!m.startsWith("..")&&!p().isAbsolute(m)}async function collectMarkdownFiles(t,u){const m=[];let g;try{g=await(0,ot.readdir)(t,{withFileTypes:true})}catch{return m}for(const y of g){if(y.name.startsWith(".")){continue}const g=p().join(t,y.name);if(y.isDirectory()){if(zt.has(y.name)||y.isSymbolicLink()||u&&p().resolve(g)===u){continue}m.push(...await collectMarkdownFiles(g,u));continue}if((y.isFile()||y.isSymbolicLink())&&/\.mdx?$/i.test(y.name)){m.push(g)}}return m}async function collectSearchRoots(t){const u=p().resolve(t);const m=p().dirname(u);const g=[];const add=t=>{const u=p().resolve(t);if(!g.includes(u)){g.push(u)}};if(m&&m!==u){add(m);try{const t=await(0,ot.readdir)(m,{withFileTypes:true});for(const u of t){if(!u.isDirectory()||zt.has(u.name)){continue}add(p().join(m,u.name))}}catch{}}add(u);return g}async function discoverNearbyDocsDirectories(t){const u=p().resolve(t);const m=p().join(u,Gt);const g=await collectSearchRoots(u);const y=[];const v=new Set;const consider=async t=>{const g=p().resolve(t);if(g===u||v.has(g)||isInside(m,g)){return}if(!await isDirectory(g)){return}const b=(await collectMarkdownFiles(g,u)).sort(((t,u)=>t.localeCompare(u)));if(b.length===0){return}v.add(g);y.push({sourceDirectory:g,files:b})};for(const t of g){if(isWhitelistedDirName(p().basename(t))){await consider(t)}try{const u=await(0,ot.readdir)(t,{withFileTypes:true});for(const m of u){if(!m.isDirectory()||zt.has(m.name)){continue}if(!isWhitelistedDirName(m.name)){continue}await consider(p().join(t,m.name))}}catch{}}const coveredBy=(t,p)=>t!==p&&isInside(t,p)&&(!isInside(u,p)||isInside(u,t));return{directories:y.filter((t=>!y.some((u=>coveredBy(u.sourceDirectory,t.sourceDirectory))))),searchedDirectories:g}}function slugifyDirName(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"docs"}async function allocateLinkName(t,u,m){var g;const y=slugifyDirName(p().basename(u));const v=slugifyDirName(p().basename(p().dirname(u)));const b=[y,`${v}-${y}`];let w=2;while(true){const u=(g=b.shift())!==null&&g!==void 0?g:`${y}-${w++}`;if(m.has(u)){continue}const v=p().join(t,u);if(await wire_docs_pathExists(v)){const t=await(0,ot.lstat)(v);if(!t.isDirectory()||!await isManagedLinkDir(v)){continue}}m.add(u);return u}}const qt=".apitogo-linked";async function isManagedLinkDir(t){try{const u=await(0,ot.readdir)(t,{withFileTypes:true});if(u.length===0){return true}if(u.some((t=>t.name===qt))){return true}return u.every((t=>t.isSymbolicLink()||t.isDirectory()))}catch{return false}}async function alreadyLinked(t,u){try{const m=await(0,ot.lstat)(t);if(m.isSymbolicLink()){const m=await(0,ot.readlink)(t);const g=p().resolve(p().dirname(t),m);return g===p().resolve(u)}const g=await(0,ot.lstat)(u);return m.ino!==0&&m.ino===g.ino&&m.dev===g.dev}catch{return false}}const isSymlinkRefused=t=>t instanceof Error&&"code"in t&&["EPERM","EACCES","ENOTSUP","EINVAL"].includes(String(t.code));async function linkMarkdownFile(t,u){if(await alreadyLinked(u,t)){return"exists"}if(await wire_docs_pathExists(u)){return"skipped"}await(0,ot.mkdir)(p().dirname(u),{recursive:true});const m=p().relative(p().dirname(u),t);try{await(0,ot.symlink)(m,u,process.platform==="win32"?"file":undefined)}catch(m){if(!isSymlinkRefused(m))throw m;try{await(0,ot.link)(t,u)}catch{await(0,ot.copyFile)(t,u)}await(0,ot.writeFile)(p().join(p().dirname(u),qt),"")}return"linked"}function wire_docs_isPlainObject(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}async function applyDocsNavigation(t,u){if(u.length===0){return}const m=p().join(t,Wt);if(!await wire_docs_pathExists(m)){return}const g=await(0,ot.readFile)(m,"utf8");const y=JSON.parse(g);if(!wire_docs_isPlainObject(y)){return}y.navigation=mergeDocumentationNavigation(y.navigation,u,{force:false});const v=ensureHeaderDocsNavigation(y,u);await(0,ot.writeFile)(m,`${JSON.stringify(v,null,2)}\n`,"utf8")}async function discoverAndWireDocs(t){const u=p().resolve(t);const m=p().join(u,Gt);const{directories:g,searchedDirectories:y}=await discoverNearbyDocsDirectories(u);if(g.length===0){return{status:"not_found",whitelist:Vt,searchedDirectories:y,sources:[],fileCount:0,skippedCount:0}}await(0,ot.mkdir)(m,{recursive:true});const v=new Set;const b=[];const w=[];for(const t of g){const g=await allocateLinkName(m,t.sourceDirectory,v);const y=p().join(m,g);const E=[];const $=[];for(const m of t.files){const g=toPosix(p().relative(t.sourceDirectory,m));const v=p().join(y,g);const b=toPosix(p().relative(u,v));const P=toRoutePath(b,Gt);if(w.includes(P)){$.push({sourcePath:m,reason:`route ${P} is already used by another file`});continue}const A=await linkMarkdownFile(m,v);if(A==="skipped"){$.push({sourcePath:m,reason:"target already exists and is not this source"});continue}E.push({sourcePath:m,linkPath:v,route:P,relativeSource:g});w.push(P)}b.push({sourceDirectory:t.sourceDirectory,linkDirectory:y,linkName:g,files:E,skipped:$})}await applyDocsNavigation(u,w);const E=b.reduce(((t,u)=>t+u.files.length),0);const $=b.reduce(((t,u)=>t+u.skipped.length),0);const P=E===0?"not_found":$>0?"partial":"wired";return{status:P,whitelist:Vt,searchedDirectories:y,sources:b,fileCount:E,skippedCount:$}}function siteRelative(t,u){const m=toPosix(p().relative(t,u));if(!m){return"."}if(p().isAbsolute(m)){return toPosix(u)}if(m.startsWith("..")){return m}return`./${m}`}function formatOpenApiDiscoveryLines(t,u){var p;const m=String((p=u.status)!==null&&p!==void 0?p:"unknown");if(m==="wired"){const p=typeof u.openApiInput==="string"?u.openApiInput:typeof u.openApiPath==="string"?siteRelative(t,u.openApiPath):"OpenAPI";const m=typeof u.openApiTitle==="string"?` (${u.openApiTitle})`:"";const g=typeof u.apiReferencePath==="string"?u.apiReferencePath:"/api";return[`OpenAPI: wired ${p}${m} → ${g}`]}if(m==="skipped"){return["OpenAPI: search skipped"]}if(m==="invalid"||m==="wire_failed"){const t=typeof u.error==="string"?`: ${u.error}`:"";return[`OpenAPI: found a spec but did not wire it${t}`]}return["OpenAPI: none found nearby"]}function formatDocsDiscoveryLines(t,u){if(u.status==="not_found"){return[`Docs: none found in ${Vt.join("/")}/ folders nearby`]}const p=[`Docs: linked ${u.fileCount} markdown file${u.fileCount===1?"":"s"} (not copied)`];for(const m of u.sources){const u=siteRelative(t,m.sourceDirectory);const g=siteRelative(t,m.linkDirectory);p.push(` ${u} → ${g}`);for(const t of m.files){p.push(` ${t.relativeSource} → ${t.route}`)}for(const u of m.skipped){p.push(` skipped ${siteRelative(t,u.sourcePath)}`)}}return p}function formatBackendDiscoveryLines(t){var u,p,m,g;const y=String((u=t===null||t===void 0?void 0:t.status)!==null&&u!==void 0?u:"unknown");if(y==="wired"||y==="already_configured"){const u=(p=t===null||t===void 0?void 0:t.runtime)!==null&&p!==void 0?p:"unknown runtime";const v=(m=t===null||t===void 0?void 0:t.runtimeVersion)!==null&&m!==void 0?m:"";const b=(g=t===null||t===void 0?void 0:t.sourceDirectory)!==null&&g!==void 0?g:"";const w=y==="wired"?"detected":"kept";return[`Backend: ${w} ${u} ${v} at ${b}`.trimEnd()]}if(y==="wire_failed"){const u=typeof(t===null||t===void 0?void 0:t.error)==="string"?`: ${t.error}`:"";return[`Backend: found a project but did not wire it${u}`]}if(y==="skipped"){return["Backend: search skipped"]}return["Backend: none detected in the parent folder (set one with apitogo config)"]}function formatInitDiscoveryReport(t,u,p,m){return[...formatOpenApiDiscoveryLines(t,u),...formatDocsDiscoveryLines(t,p),...m?formatBackendDiscoveryLines(m):[]]}async function run_scaffold_discovery_pathExists(t){try{await(0,ot.access)(t);return true}catch{return false}}async function wireOpenApiIntoJsonConfig(t,u){const m=toSiteRelativeOpenApiInput(t,u);const g=p().join(t,"apitogo.config.json");const y=await(0,ot.readFile)(g,"utf8");const v=JSON.parse(y);const b=applyOpenApiToSiteConfig(v,{input:m,apiPath:"api"});const w=b.backend&&typeof b.backend==="object"&&!Array.isArray(b.backend)?{...b.backend}:{};b.backend={...w,openApiPath:m};await(0,ot.writeFile)(g,`${JSON.stringify(b,null,2)}\n`,"utf8");return{input:m}}async function discoverAndWireOpenApiLite(t,u){var m,g;if(u==="none"){return{openApiDiscovery:{status:"skipped",mode:u},wired:false}}const y=u==="site"?await collectSiteOpenApiFiles(t):await collectNearbyOpenApiFiles(t);const v=[];let b;for(const t of y.candidates){const u=await(0,ot.readFile)(t,"utf8");const p=liteParseOpenApi(u,t);if(p.valid){b={path:t,version:p.version,title:p.title};break}v.push({path:t,errors:p.errors})}if(!b){return{openApiDiscovery:{status:y.candidates.length>0?"invalid":"not_found",candidates:y.candidates,searchedDirectories:y.searchedDirectories,...v.length>0?{invalidCandidates:v}:{},suggestion:Bt},wired:false}}const w=p().join(t,"apitogo.config.json");if(!await run_scaffold_discovery_pathExists(w)){return{openApiDiscovery:{status:"wire_failed",openApiPath:b.path,error:"apitogo.config.json not found",candidates:y.candidates,searchedDirectories:y.searchedDirectories,suggestion:Bt},wired:false}}try{const{input:u}=await wireOpenApiIntoJsonConfig(t,b.path);return{openApiDiscovery:{status:"wired",openApiPath:b.path,openApiInput:u,openApiTitle:(m=b.title)!==null&&m!==void 0?m:null,openApiVersion:(g=b.version)!==null&&g!==void 0?g:null,apiReferencePath:"/api",candidates:y.candidates,searchedDirectories:y.searchedDirectories},wired:true}}catch(t){return{openApiDiscovery:{status:"wire_failed",openApiPath:b.path,error:t instanceof Error?t.message:String(t),candidates:y.candidates,searchedDirectories:y.searchedDirectories,suggestion:Bt},wired:false}}}async function discoverAndWireBackend(t,u){var m,g;if(u!=="nearby"){return{status:"skipped",mode:u}}const y=p().join(t,"apitogo.config.json");if(!await run_scaffold_discovery_pathExists(y)){return{status:"not_found"}}try{const u=JSON.parse(await(0,ot.readFile)(y,"utf8"));const p=u.backend&&typeof u.backend==="object"&&!Array.isArray(u.backend)?u.backend:{};if(typeof p.sourceDirectory==="string"&&p.sourceDirectory.trim()){return{status:"already_configured",sourceDirectory:p.sourceDirectory,runtime:(m=p.runtime)!==null&&m!==void 0?m:null,runtimeVersion:(g=p.runtimeVersion)!==null&&g!==void 0?g:null}}const v=await detectParentBackend(t);if(!v){return{status:"not_found"}}u.backend={...p,sourceDirectory:v.sourceDirectory,runtime:v.runtime,runtimeVersion:v.runtimeVersion};await(0,ot.writeFile)(y,`${JSON.stringify(u,null,2)}\n`,"utf8");return{status:"wired",directory:v.directory,sourceDirectory:v.sourceDirectory,runtime:v.runtime,runtimeVersion:v.runtimeVersion,marker:v.marker}}catch(t){return{status:"wire_failed",error:t instanceof Error?t.message:String(t)}}}async function runScaffoldDiscovery(t,u){var p;const m=(p=u===null||u===void 0?void 0:u.openapiSearch)!==null&&p!==void 0?p:"nearby";const{openApiDiscovery:g}=await discoverAndWireOpenApiLite(t,m);const y=await discoverAndWireDocs(t);const v=await discoverAndWireBackend(t,m);return{openApiDiscovery:g,docsDiscovery:y,backendDiscovery:v}}const Kt=require("node:stream/promises");var Yt=__nccwpck_require__(4434);var Jt=__nccwpck_require__(7515);const Zt=require("node:string_decoder");var Xt=__nccwpck_require__(6928);const Qt=require("assert");var er=__nccwpck_require__(181);const rr=require("zlib");var sr=__nccwpck_require__.t(rr,2);var ir=Object.defineProperty;var Ar=(t,u)=>{for(var p in u)ir(t,p,{get:u[p],enumerable:!0})};var nr=typeof process=="object"&&process?process:{stdout:null,stderr:null},Cr=t=>!!t&&typeof t=="object"&&(t instanceof ps||t instanceof z||Fr(t)||kr(t)),Fr=t=>!!t&&typeof t=="object"&&t instanceof V.EventEmitter&&typeof t.pipe=="function"&&t.pipe!==z.Writable.prototype.pipe,kr=t=>!!t&&typeof t=="object"&&t instanceof V.EventEmitter&&typeof t.write=="function"&&typeof t.end=="function",cr=Symbol("EOF"),lr=Symbol("maybeEmitEnd"),mr=Symbol("emittedEnd"),gr=Symbol("emittingEnd"),yr=Symbol("emittedError"),_r=Symbol("closed"),br=Symbol("read"),Er=Symbol("flush"),Sr=Symbol("flushChunk"),Or=Symbol("encoding"),Rr=Symbol("decoder"),xr=Symbol("flowing"),Ir=Symbol("paused"),Nr=Symbol("resume"),Dr=Symbol("buffer"),Lr=Symbol("pipes"),Hr=Symbol("bufferLength"),Vr=Symbol("bufferPush"),Gr=Symbol("bufferShift"),Wr=Symbol("objectMode"),Kr=Symbol("destroyed"),Yr=Symbol("error"),Xr=Symbol("emitData"),es=Symbol("emitEnd"),ts=Symbol("emitEnd2"),rs=Symbol("async"),ss=Symbol("abort"),is=Symbol("aborted"),ns=Symbol("signal"),os=Symbol("dataListeners"),as=Symbol("discarded"),te=t=>Promise.resolve().then(t),vr=t=>t(),Mr=t=>t==="end"||t==="finish"||t==="prefinish",Br=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Pr=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),ls=class{src;dest;opts;ondrain;constructor(t,u,p){this.src=t,this.dest=u,this.opts=p,this.ondrain=()=>t[Nr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},hs=class extends ls{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)}},zr=t=>!!t.objectMode,Ur=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",ps=class extends V.EventEmitter{[xr]=!1;[Ir]=!1;[Lr]=[];[Dr]=[];[Wr];[Or];[rs];[Rr];[cr]=!1;[mr]=!1;[gr]=!1;[_r]=!1;[yr]=null;[Hr]=0;[Kr]=!1;[ns];[is]=!1;[os]=0;[as]=!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");zr(u)?(this[Wr]=!0,this[Or]=null):Ur(u)?(this[Or]=u.encoding,this[Wr]=!1):(this[Wr]=!1,this[Or]=null),this[rs]=!!u.async,this[Rr]=this[Or]?new Zt.StringDecoder(this[Or]):null,u&&u.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Dr]}),u&&u.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Lr]});let{signal:p}=u;p&&(this[ns]=p,p.aborted?this[ss]():p.addEventListener("abort",(()=>this[ss]())))}get bufferLength(){return this[Hr]}get encoding(){return this[Or]}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[Wr]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[rs]}set async(t){this[rs]=this[rs]||!!t}[ss](){this[is]=!0,this.emit("abort",this[ns]?.reason),this.destroy(this[ns]?.reason)}get aborted(){return this[is]}set aborted(t){}write(t,u,p){if(this[is])return!1;if(this[cr])throw new Error("write after end");if(this[Kr])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[rs]?te:vr;if(!this[Wr]&&!Buffer.isBuffer(t)){if(Pr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Br(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Wr]?(this[xr]&&this[Hr]!==0&&this[Er](!0),this[xr]?this.emit("data",t):this[Vr](t),this[Hr]!==0&&this.emit("readable"),p&&m(p),this[xr]):t.length?(typeof t=="string"&&!(u===this[Or]&&!this[Rr]?.lastNeed)&&(t=Buffer.from(t,u)),Buffer.isBuffer(t)&&this[Or]&&(t=this[Rr].write(t)),this[xr]&&this[Hr]!==0&&this[Er](!0),this[xr]?this.emit("data",t):this[Vr](t),this[Hr]!==0&&this.emit("readable"),p&&m(p),this[xr]):(this[Hr]!==0&&this.emit("readable"),p&&m(p),this[xr])}read(t){if(this[Kr])return null;if(this[as]=!1,this[Hr]===0||t===0||t&&t>this[Hr])return this[lr](),null;this[Wr]&&(t=null),this[Dr].length>1&&!this[Wr]&&(this[Dr]=[this[Or]?this[Dr].join(""):Buffer.concat(this[Dr],this[Hr])]);let u=this[br](t||null,this[Dr][0]);return this[lr](),u}[br](t,u){if(this[Wr])this[Gr]();else{let p=u;t===p.length||t===null?this[Gr]():typeof p=="string"?(this[Dr][0]=p.slice(t),u=p.slice(0,t),this[Hr]-=t):(this[Dr][0]=p.subarray(t),u=p.subarray(0,t),this[Hr]-=t)}return this.emit("data",u),!this[Dr].length&&!this[cr]&&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[cr]=!0,this.writable=!1,(this[xr]||!this[Ir])&&this[lr](),this}[Nr](){this[Kr]||(!this[os]&&!this[Lr].length&&(this[as]=!0),this[Ir]=!1,this[xr]=!0,this.emit("resume"),this[Dr].length?this[Er]():this[cr]?this[lr]():this.emit("drain"))}resume(){return this[Nr]()}pause(){this[xr]=!1,this[Ir]=!0,this[as]=!1}get destroyed(){return this[Kr]}get flowing(){return this[xr]}get paused(){return this[Ir]}[Vr](t){this[Wr]?this[Hr]+=1:this[Hr]+=t.length,this[Dr].push(t)}[Gr](){return this[Wr]?this[Hr]-=1:this[Hr]-=this[Dr][0].length,this[Dr].shift()}[Er](t=!1){do{}while(this[Sr](this[Gr]())&&this[Dr].length);!t&&!this[Dr].length&&!this[cr]&&this.emit("drain")}[Sr](t){return this.emit("data",t),this[xr]}pipe(t,u){if(this[Kr])return t;this[as]=!1;let p=this[mr];return u=u||{},t===nr.stdout||t===nr.stderr?u.end=!1:u.end=u.end!==!1,u.proxyErrors=!!u.proxyErrors,p?u.end&&t.end():(this[Lr].push(u.proxyErrors?new hs(this,t,u):new ls(this,t,u)),this[rs]?te((()=>this[Nr]())):this[Nr]()),t}unpipe(t){let u=this[Lr].find((u=>u.dest===t));u&&(this[Lr].length===1?(this[xr]&&this[os]===0&&(this[xr]=!1),this[Lr]=[]):this[Lr].splice(this[Lr].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[as]=!1,this[os]++,!this[Lr].length&&!this[xr]&&this[Nr]();else if(t==="readable"&&this[Hr]!==0)super.emit("readable");else if(Mr(t)&&this[mr])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[yr]){let t=u;this[rs]?te((()=>t.call(this,this[yr]))):t.call(this,this[yr])}return p}removeListener(t,u){return this.off(t,u)}off(t,u){let p=super.off(t,u);return t==="data"&&(this[os]=this.listeners("data").length,this[os]===0&&!this[as]&&!this[Lr].length&&(this[xr]=!1)),p}removeAllListeners(t){let u=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[os]=0,!this[as]&&!this[Lr].length&&(this[xr]=!1)),u}get emittedEnd(){return this[mr]}[lr](){!this[gr]&&!this[mr]&&!this[Kr]&&this[Dr].length===0&&this[cr]&&(this[gr]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[_r]&&this.emit("close"),this[gr]=!1)}emit(t,...u){let p=u[0];if(t!=="error"&&t!=="close"&&t!==Kr&&this[Kr])return!1;if(t==="data")return!this[Wr]&&!p?!1:this[rs]?(te((()=>this[Xr](p))),!0):this[Xr](p);if(t==="end")return this[es]();if(t==="close"){if(this[_r]=!0,!this[mr]&&!this[Kr])return!1;let t=super.emit("close");return this.removeAllListeners("close"),t}else if(t==="error"){this[yr]=p,super.emit(Yr,p);let t=!this[ns]||this.listeners("error").length?super.emit("error",p):!1;return this[lr](),t}else if(t==="resume"){let t=super.emit("resume");return this[lr](),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[lr](),m}[Xr](t){for(let u of this[Lr])u.dest.write(t)===!1&&this.pause();let u=this[as]?!1:super.emit("data",t);return this[lr](),u}[es](){return this[mr]?!1:(this[mr]=!0,this.readable=!1,this[rs]?(te((()=>this[ts]())),!0):this[ts]())}[ts](){if(this[Rr]){let t=this[Rr].end();if(t){for(let u of this[Lr])u.dest.write(t);this[as]||super.emit("data",t)}}for(let t of this[Lr])t.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Wr]||(t.dataLength=0);let u=this.promise();return this.on("data",(u=>{t.push(u),this[Wr]||(t.dataLength+=u.length)})),await u,t}async concat(){if(this[Wr])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Or]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise(((t,u)=>{this.on(Kr,(()=>u(new Error("stream destroyed")))),this.on("error",(t=>u(t))),this.on("end",(()=>t()))}))}[Symbol.asyncIterator](){this[as]=!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[cr])return e();let p,m,h=t=>{this.off("data",a),this.off("end",l),this.off(Kr,c),e(),m(t)},a=t=>{this.off("error",h),this.off("end",l),this.off(Kr,c),this.pause(),p({value:t,done:!!this[cr]})},l=()=>{this.off("error",h),this.off("data",a),this.off(Kr,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(Kr,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[as]=!1;let t=!1,e=()=>(this.pause(),this.off(Yr,e),this.off(Kr,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(Yr,e),this.once(Kr,e),{next:i,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Kr])return t?this.emit("error",t):this.emit(Kr),this;this[Kr]=!0,this[as]=!0,this[Dr].length=0,this[Hr]=0;let u=this;return typeof u.close=="function"&&!this[_r]&&u.close(),t?this.emit("error",t):this.emit(Kr),this}static get isStream(){return Cr}};var ms=Jt.writev,gs=Symbol("_autoClose"),ys=Symbol("_close"),vs=Symbol("_ended"),_s=Symbol("_fd"),bs=Symbol("_finished"),ws=Symbol("_flags"),Es=Symbol("_flush"),Ss=Symbol("_handleChunk"),$s=Symbol("_makeBuf"),Os=Symbol("_mode"),Rs=Symbol("_needDrain"),xs=Symbol("_onerror"),Ts=Symbol("_onopen"),Ns=Symbol("_onread"),Ds=Symbol("_onwrite"),js=Symbol("_open"),Ls=Symbol("_path"),Ms=Symbol("_pos"),Hs=Symbol("_queue"),Gs=Symbol("_read"),Ws=Symbol("_readSize"),qs=Symbol("_reading"),Ks=Symbol("_remain"),Ys=Symbol("_size"),Js=Symbol("_write"),Zs=Symbol("_writing"),Xs=Symbol("_defaultFlag"),Qs=Symbol("_errored"),ei=class extends ps{[Qs]=!1;[_s];[Ls];[Ws];[qs]=!1;[Ys];[Ks];[gs];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[Qs]=!1,this[_s]=typeof u.fd=="number"?u.fd:void 0,this[Ls]=t,this[Ws]=u.readSize||16*1024*1024,this[qs]=!1,this[Ys]=typeof u.size=="number"?u.size:1/0,this[Ks]=this[Ys],this[gs]=typeof u.autoClose=="boolean"?u.autoClose:!0,typeof this[_s]=="number"?this[Gs]():this[js]()}get fd(){return this[_s]}get path(){return this[Ls]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[js](){Jt.open(this[Ls],"r",((t,u)=>this[Ts](t,u)))}[Ts](t,u){t?this[xs](t):(this[_s]=u,this.emit("open",u),this[Gs]())}[$s](){return Buffer.allocUnsafe(Math.min(this[Ws],this[Ks]))}[Gs](){if(!this[qs]){this[qs]=!0;let t=this[$s]();if(t.length===0)return process.nextTick((()=>this[Ns](null,0,t)));Jt.read(this[_s],t,0,t.length,null,((t,u,p)=>this[Ns](t,u,p)))}}[Ns](t,u,p){this[qs]=!1,t?this[xs](t):this[Ss](u,p)&&this[Gs]()}[ys](){if(this[gs]&&typeof this[_s]=="number"){let t=this[_s];this[_s]=void 0,Jt.close(t,(t=>t?this.emit("error",t):this.emit("close")))}}[xs](t){this[qs]=!0,this[ys](),this.emit("error",t)}[Ss](t,u){let p=!1;return this[Ks]-=t,t>0&&(p=super.write(t<u.length?u.subarray(0,t):u)),(t===0||this[Ks]<=0)&&(p=!1,this[ys](),super.end()),p}emit(t,...u){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[_s]=="number"&&this[Gs](),!1;case"error":return this[Qs]?!1:(this[Qs]=!0,super.emit(t,...u));default:return super.emit(t,...u)}}},ti=class extends ei{[js](){let t=!0;try{this[Ts](null,Jt.openSync(this[Ls],"r")),t=!1}finally{t&&this[ys]()}}[Gs](){let t=!0;try{if(!this[qs]){this[qs]=!0;do{let t=this[$s](),u=t.length===0?0:Jt.readSync(this[_s],t,0,t.length,null);if(!this[Ss](u,t))break}while(!0);this[qs]=!1}t=!1}finally{t&&this[ys]()}}[ys](){if(this[gs]&&typeof this[_s]=="number"){let t=this[_s];this[_s]=void 0,Jt.closeSync(t),this.emit("close")}}},ri=class extends Yt{readable=!1;writable=!0;[Qs]=!1;[Zs]=!1;[vs]=!1;[Hs]=[];[Rs]=!1;[Ls];[Os];[gs];[_s];[Xs];[ws];[bs]=!1;[Ms];constructor(t,u){u=u||{},super(u),this[Ls]=t,this[_s]=typeof u.fd=="number"?u.fd:void 0,this[Os]=u.mode===void 0?438:u.mode,this[Ms]=typeof u.start=="number"?u.start:void 0,this[gs]=typeof u.autoClose=="boolean"?u.autoClose:!0;let p=this[Ms]!==void 0?"r+":"w";this[Xs]=u.flags===void 0,this[ws]=u.flags===void 0?p:u.flags,this[_s]===void 0&&this[js]()}emit(t,...u){if(t==="error"){if(this[Qs])return!1;this[Qs]=!0}return super.emit(t,...u)}get fd(){return this[_s]}get path(){return this[Ls]}[xs](t){this[ys](),this[Zs]=!0,this.emit("error",t)}[js](){Jt.open(this[Ls],this[ws],this[Os],((t,u)=>this[Ts](t,u)))}[Ts](t,u){this[Xs]&&this[ws]==="r+"&&t&&t.code==="ENOENT"?(this[ws]="w",this[js]()):t?this[xs](t):(this[_s]=u,this.emit("open",u),this[Zs]||this[Es]())}end(t,u){return t&&this.write(t,u),this[vs]=!0,!this[Zs]&&!this[Hs].length&&typeof this[_s]=="number"&&this[Ds](null,0),this}write(t,u){return typeof t=="string"&&(t=Buffer.from(t,u)),this[vs]?(this.emit("error",new Error("write() after end()")),!1):this[_s]===void 0||this[Zs]||this[Hs].length?(this[Hs].push(t),this[Rs]=!0,!1):(this[Zs]=!0,this[Js](t),!0)}[Js](t){Jt.write(this[_s],t,0,t.length,this[Ms],((t,u)=>this[Ds](t,u)))}[Ds](t,u){t?this[xs](t):(this[Ms]!==void 0&&typeof u=="number"&&(this[Ms]+=u),this[Hs].length?this[Es]():(this[Zs]=!1,this[vs]&&!this[bs]?(this[bs]=!0,this[ys](),this.emit("finish")):this[Rs]&&(this[Rs]=!1,this.emit("drain"))))}[Es](){if(this[Hs].length===0)this[vs]&&this[Ds](null,0);else if(this[Hs].length===1)this[Js](this[Hs].pop());else{let t=this[Hs];this[Hs]=[],ms(this[_s],t,this[Ms],((t,u)=>this[Ds](t,u)))}}[ys](){if(this[gs]&&typeof this[_s]=="number"){let t=this[_s];this[_s]=void 0,Jt.close(t,(t=>t?this.emit("error",t):this.emit("close")))}}},si=class extends ri{[js](){let t;if(this[Xs]&&this[ws]==="r+")try{t=Jt.openSync(this[Ls],this[ws],this[Os])}catch(t){if(t?.code==="ENOENT")return this[ws]="w",this[js]();throw t}else t=Jt.openSync(this[Ls],this[ws],this[Os]);this[Ts](null,t)}[ys](){if(this[gs]&&typeof this[_s]=="number"){let t=this[_s];this[_s]=void 0,Jt.closeSync(t),this.emit("close")}}[Js](t){let u=!0;try{this[Ds](null,Jt.writeSync(this[_s],t,0,t.length,this[Ms])),u=!1}finally{if(u)try{this[ys]()}catch{}}}};var ii=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"]]),As=t=>!!t.sync&&!!t.file,Is=t=>!t.sync&&!!t.file,Cs=t=>!!t.sync&&!t.file,Fs=t=>!t.sync&&!t.file;var ks=t=>!!t.file;var Zr=t=>{let u=ii.get(t);return u||t},re=(t={})=>{if(!t)return{};let u={};for(let[p,m]of Object.entries(t)){let t=Zr(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(((y=[],v,b)=>{Array.isArray(y)&&(v=y,y={}),typeof v=="function"&&(b=v,v=void 0),v?v=Array.from(v):v=[];let w=re(y);if(g?.(w,v),As(w)){if(typeof b=="function")throw new TypeError("callback not supported for sync tar functions");return t(w,v)}else if(Is(w)){let t=u(w,v),p=b||void 0;return p?t.then((()=>p()),p):t}else if(Cs(w)){if(typeof b=="function")throw new TypeError("callback not supported for sync tar functions");return p(w,v)}else if(Fs(w)){if(typeof b=="function")throw new TypeError("callback only supported with file option");return m(w,v)}else throw new Error("impossible options??")}),{syncFile:t,asyncFile:u,syncNoFile:p,asyncNoFile:m,validate:g});var ni=rr.constants||{ZLIB_VERNUM:4736},oi=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},ni));var ai=er.Buffer.concat,ci=Object.getOwnPropertyDescriptor(er.Buffer,"concat"),$r=t=>t,li=ci?.writable===!0||ci?.set!==void 0?t=>{er.Buffer.concat=t?$r:ai}:t=>{},ui=Symbol("_superWrite"),hi=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"}},fi=Symbol("flushFlag"),pi=class extends ps{#y=!1;#v=!1;#_;#b;#w;#E;#S;get sawError(){return this.#y}get handle(){return this.#E}get flushFlag(){return this.#_}constructor(t,u){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#_=t.flush??0,this.#b=t.finishFlush??0,this.#w=t.fullFlushFlag??0,typeof sr[u]!="function")throw new TypeError("Compression method not supported: "+u);try{this.#E=new sr[u](t)}catch(t){throw new hi(t,this.constructor)}this.#S=t=>{this.#y||(this.#y=!0,this.close(),this.emit("error",t))},this.#E?.on("error",(t=>this.#S(new hi(t)))),this.once("end",(()=>this.close))}close(){this.#E&&(this.#E.close(),this.#E=void 0,this.emit("close"))}reset(){if(!this.#y)return Qt(this.#E,"zlib binding closed"),this.#E.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#w),this.write(Object.assign(er.Buffer.alloc(0),{[fi]: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.#b),this.#v=!0,super.end(p)}get ended(){return this.#v}[ui](t){return super.write(t)}write(t,u,p){if(typeof u=="function"&&(p=u,u="utf8"),typeof t=="string"&&(t=er.Buffer.from(t,u)),this.#y)return;Qt(this.#E,"zlib binding closed");let m=this.#E._handle,g=m.close;m.close=()=>{};let y=this.#E.close;this.#E.close=()=>{},li(!0);let v;try{let u=typeof t[fi]=="number"?t[fi]:this.#_;v=this.#E._processChunk(t,u),li(!1)}catch(t){li(!1),this.#S(new hi(t,this.write))}finally{this.#E&&(this.#E._handle=m,m.close=g,this.#E.close=y,this.#E.removeAllListeners("error"))}this.#E&&this.#E.on("error",(t=>this.#S(new hi(t,this.write))));let b;if(v)if(Array.isArray(v)&&v.length>0){let t=v[0];b=this[ui](er.Buffer.from(t));for(let t=1;t<v.length;t++)b=this[ui](v[t])}else b=this[ui](er.Buffer.from(v));return p&&p(),b}},mi=class extends pi{#y;#v;constructor(t,u){t=t||{},t.flush=t.flush||oi.Z_NO_FLUSH,t.finishFlush=t.finishFlush||oi.Z_FINISH,t.fullFlushFlag=oi.Z_FULL_FLUSH,super(t,u),this.#y=t.level,this.#v=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.#y!==t||this.#v!==u){this.flush(oi.Z_SYNC_FLUSH),Qt(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.#y=t,this.#v=u)}}}};var gi=class extends mi{#y;constructor(t){super(t,"Gzip"),this.#y=t&&!!t.portable}[ui](t){return this.#y?(this.#y=!1,t[9]=255,super[ui](t)):super[ui](t)}};var yi=class extends mi{constructor(t){super(t,"Unzip")}},vi=class extends pi{constructor(t,u){t=t||{},t.flush=t.flush||oi.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||oi.BROTLI_OPERATION_FINISH,t.fullFlushFlag=oi.BROTLI_OPERATION_FLUSH,super(t,u)}},_i=class extends vi{constructor(t){super(t,"BrotliCompress")}},bi=class extends vi{constructor(t){super(t,"BrotliDecompress")}},wi=class extends pi{constructor(t,u){t=t||{},t.flush=t.flush||oi.ZSTD_e_continue,t.finishFlush=t.finishFlush||oi.ZSTD_e_end,t.fullFlushFlag=oi.ZSTD_e_flush,super(t,u)}},Ei=class extends wi{constructor(t){super(t,"ZstdCompress")}},Si=class extends wi{constructor(t){super(t,"ZstdDecompress")}};var Bs=(t,u)=>{if(Number.isSafeInteger(t))t<0?jr(t,u):qr(t,u);else throw Error("cannot encode number outside of javascript safe integer range");return u},qr=(t,u)=>{u[0]=128;for(var p=u.length;p>1;p--)u[p-1]=t&255,t=Math.floor(t/256)},jr=(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]=zs(g):g===0?u[m-1]=0:(p=!0,u[m-1]=Us(g))}},Ps=t=>{let u=t[0],p=u===128?Jr(t.subarray(1,t.length)):u===255?Qr(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},Qr=t=>{for(var u=t.length,p=0,m=!1,g=u-1;g>-1;g--){var y=Number(t[g]),v;m?v=zs(y):y===0?v=y:(m=!0,v=Us(y)),v!==0&&(p-=v*Math.pow(256,u-g-1))}return p},Jr=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},zs=t=>(255^t)&255,Us=t=>(255^t)+1&255;var Ai={};Ar(Ai,{code:()=>Ri,isCode:()=>oe,isName:()=>en,name:()=>Oi});var oe=t=>Oi.has(t),en=t=>Ri.has(t),Oi=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"]]),Ri=new Map(Array.from(Oi).map((t=>[t[1],t[0]])));var xi=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#y="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.#v(t)}decode(t,u,p,m){if(u||(u=0),!t||!(t.length>=u+512))throw new Error("need 512 bytes for header");this.path=p?.path??Tt(t,u,100),this.mode=p?.mode??m?.mode??at(t,u+100,8),this.uid=p?.uid??m?.uid??at(t,u+108,8),this.gid=p?.gid??m?.gid??at(t,u+116,8),this.size=p?.size??m?.size??at(t,u+124,12),this.mtime=p?.mtime??m?.mtime??Bi(t,u+136,12),this.cksum=at(t,u+148,12),m&&this.#v(m,!0),p&&this.#v(p);let g=Tt(t,u+156,1);if(oe(g)&&(this.#y=g||"0"),this.#y==="0"&&this.path.slice(-1)==="/"&&(this.#y="5"),this.#y==="5"&&(this.size=0),this.linkpath=Tt(t,u+157,100),t.subarray(u+257,u+265).toString()==="ustar\x0000")if(this.uname=p?.uname??m?.uname??Tt(t,u+265,32),this.gname=p?.gname??m?.gname??Tt(t,u+297,32),this.devmaj=p?.devmaj??m?.devmaj??at(t,u+329,8)??0,this.devmin=p?.devmin??m?.devmin??at(t,u+337,8)??0,t[u+475]!==0){let p=Tt(t,u+345,155);this.path=p+"/"+this.path}else{let g=Tt(t,u+345,130);g&&(this.path=g+"/"+this.path),this.atime=p?.atime??m?.atime??Bi(t,u+476,12),this.ctime=p?.ctime??m?.ctime??Bi(t,u+488,12)}let y=256;for(let p=u;p<u+148;p++)y+=t[p];for(let p=u+156;p<u+512;p++)y+=t[p];this.cksumValid=y===this.cksum,this.cksum===void 0&&y===256&&(this.nullBlock=!0)}#v(t,u=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter((([t,p])=>!(p==null||t==="path"&&u||t==="linkpath"&&u||t==="global")))))}encode(t,u=0){if(t||(t=this.block=Buffer.alloc(512)),this.#y==="Unsupported"&&(this.#y="0"),!(t.length>=u+512))throw new Error("need 512 bytes for header");let p=this.ctime||this.atime?130:155,m=sn(this.path||"",p),g=m[0],y=m[1];this.needPax=!!m[2],this.needPax=xt(t,u,100,g)||this.needPax,this.needPax=lt(t,u+100,8,this.mode)||this.needPax,this.needPax=lt(t,u+108,8,this.uid)||this.needPax,this.needPax=lt(t,u+116,8,this.gid)||this.needPax,this.needPax=lt(t,u+124,12,this.size)||this.needPax,this.needPax=Pi(t,u+136,12,this.mtime)||this.needPax,t[u+156]=this.#y.charCodeAt(0),this.needPax=xt(t,u+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",u+257,8),this.needPax=xt(t,u+265,32,this.uname)||this.needPax,this.needPax=xt(t,u+297,32,this.gname)||this.needPax,this.needPax=lt(t,u+329,8,this.devmaj)||this.needPax,this.needPax=lt(t,u+337,8,this.devmin)||this.needPax,this.needPax=xt(t,u+345,p,y)||this.needPax,t[u+475]!==0?this.needPax=xt(t,u+345,155,y)||this.needPax:(this.needPax=xt(t,u+345,130,y)||this.needPax,this.needPax=Pi(t,u+476,12,this.atime)||this.needPax,this.needPax=Pi(t,u+488,12,this.ctime)||this.needPax);let v=256;for(let p=u;p<u+148;p++)v+=t[p];for(let p=u+156;p<u+512;p++)v+=t[p];return this.cksum=v,lt(t,u+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#y==="Unsupported"?this.#y:Oi.get(this.#y)}get typeKey(){return this.#y}set type(t){let u=String(Ri.get(t));if(oe(u)||u==="Unsupported")this.#y=u;else if(oe(t))this.#y=t;else throw new TypeError("invalid entry type: "+t)}},sn=(t,p)=>{let m=t,g="",y,v=u.posix.parse(t).root||".";if(Buffer.byteLength(m)<100)y=[m,g,!1];else{g=u.posix.dirname(m),m=u.posix.basename(m);do{Buffer.byteLength(m)<=100&&Buffer.byteLength(g)<=p?y=[m,g,!1]:Buffer.byteLength(m)>100&&Buffer.byteLength(g)<=p?y=[m.slice(0,99),g,!0]:(m=u.posix.join(u.posix.basename(g),m),g=u.posix.dirname(g))}while(g!==v&&y===void 0);y||(y=[t.slice(0,99),"",!0])}return y},Tt=(t,u,p)=>t.subarray(u,u+p).toString("utf8").replace(/\0.*/,""),Bi=(t,u,p)=>rn(at(t,u,p)),rn=t=>t===void 0?void 0:new Date(t*1e3),at=(t,u,p)=>Number(t[u])&128?Ps(t.subarray(u,u+p)):on(t,u,p),nn=t=>isNaN(t)?void 0:t,on=(t,u,p)=>nn(parseInt(t.subarray(u,u+p).toString("utf8").replace(/\0.*$/,"").trim(),8)),Ti={12:8589934591,8:2097151},lt=(t,u,p,m)=>m===void 0?!1:m>Ti[p]||m<0?(Bs(m,t.subarray(u,u+p)),!0):(an(t,u,p,m),!1),an=(t,u,p,m)=>t.write(ln(m,p),u,p,"ascii"),ln=(t,u)=>cn(Math.floor(t).toString(8),u),cn=(t,u)=>(t.length===u-1?t:new Array(u-t.length-1).join("0")+t+" ")+"\0",Pi=(t,u,p,m)=>m===void 0?!1:lt(t,u,p,m.getTime()/1e3),ki=new Array(156).join("\0"),xt=(t,u,p,m)=>m===void 0?!1:(t.write(m+ki,u,p,"utf8"),m.length!==Buffer.byteLength(m)||m.length>p);var Ci=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 p=Buffer.byteLength(t),m=512*Math.ceil(1+p/512),g=Buffer.allocUnsafe(m);for(let t=0;t<512;t++)g[t]=0;new xi({path:("PaxHeader/"+(0,u.basename)(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:p,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(g),g.write(t,512,p,"utf8");for(let t=p+512;t<g.length;t++)g[t]=0;return g}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),y=Math.floor(Math.log(g)/Math.log(10))+1;return g+y>=Math.pow(10,y)&&(y+=1),y+g+m}static parse(t,u,p=!1){return new s(un(mn(t),u),p)}},un=(t,u)=>u?Object.assign({},u,t):t,mn=t=>t.replace(/\n$/,"").split(`\n`).reduce(pn,Object.create(null)),pn=(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 y=g.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),v=m.join("=");return t[y]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(y)?new Date(Number(v)*1e3):/^[0-9]+$/.test(v)?+v:v,t};var Ii=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ni=Ii!=="win32"?t=>t:t=>t&&t.replace(/\\/g,"/");var Di=class extends ps{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=Ni(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?Ni(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,u&&this.#y(u),p&&this.#y(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))}#y(t,u=!1){t.path&&(t.path=Ni(t.path)),t.linkpath&&(t.linkpath=Ni(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter((([t,p])=>!(p==null||t==="path"&&u)))))}};var Lt=(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 ji=1024*1024,Li=Buffer.from([31,139]),Mi=Buffer.from([40,181,47,253]),Fi=Math.max(Li.length,Mi.length),Ui=Symbol("state"),Hi=Symbol("writeEntry"),Vi=Symbol("readEntry"),zi=Symbol("nextEntry"),Gi=Symbol("processEntry"),Wi=Symbol("extendedHeader"),qi=Symbol("globalExtendedHeader"),Ji=Symbol("meta"),Zi=Symbol("emitMeta"),Xi=Symbol("buffer"),Qi=Symbol("queue"),tn=Symbol("ended"),hn=Symbol("emittedEnd"),dn=Symbol("emit"),fn=Symbol("unzip"),gn=Symbol("consumeChunk"),yn=Symbol("consumeChunkSub"),bn=Symbol("consumeBody"),wn=Symbol("consumeMeta"),En=Symbol("consumeHeader"),Sn=Symbol("consuming"),An=Symbol("bufferConcat"),xn=Symbol("maybeEnd"),Nn=Symbol("writing"),Dn=Symbol("aborted"),Ln=Symbol("onDone"),Un=Symbol("sawValidEntry"),Hn=Symbol("sawNullBlock"),Vn=Symbol("sawEOF"),zn=Symbol("closeStream"),Rn=()=>!0,Gn=class extends Yt.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Qi]=[];[Xi];[Vi];[Hi];[Ui]="begin";[Ji]="";[Wi];[qi];[tn]=!1;[fn];[Dn]=!1;[Un];[Hn]=!1;[Vn]=!1;[Nn]=!1;[Sn]=!1;[hn]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Ln,(()=>{(this[Ui]==="begin"||this[Un]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")})),t.ondone?this.on(Ln,t.ondone):this.on(Ln,(()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")})),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||ji,this.filter=typeof t.filter=="function"?t.filter:Rn;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[zn]())),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,u,p={}){Lt(this,t,u,p)}[En](t,u){this[Un]===void 0&&(this[Un]=!1);let p;try{p=new xi(t,u,this[Wi],this[qi])}catch(t){return this.warn("TAR_ENTRY_INVALID",t)}if(p.nullBlock)this[Hn]?(this[Vn]=!0,this[Ui]==="begin"&&(this[Ui]="header"),this[dn]("eof")):(this[Hn]=!0,this[dn]("nullBlock"));else if(this[Hn]=!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[Hi]=new Di(p,this[Wi],this[qi]);if(!this[Un])if(t.remain){let o=()=>{t.invalid||(this[Un]=!0)};t.on("end",o)}else this[Un]=!0;t.meta?t.size>this.maxMetaEntrySize?(t.ignore=!0,this[dn]("ignoredEntry",t),this[Ui]="ignore",t.resume()):t.size>0&&(this[Ji]="",t.on("data",(t=>this[Ji]+=t)),this[Ui]="meta"):(this[Wi]=void 0,t.ignore=t.ignore||!this.filter(t.path,t),t.ignore?(this[dn]("ignoredEntry",t),this[Ui]=t.remain?"ignore":"header",t.resume()):(t.remain?this[Ui]="body":(this[Ui]="header",t.end()),this[Vi]?this[Qi].push(t):(this[Qi].push(t),this[zi]())))}}}[zn](){queueMicrotask((()=>this.emit("close")))}[Gi](t){let u=!0;if(!t)this[Vi]=void 0,u=!1;else if(Array.isArray(t)){let[u,...p]=t;this.emit(u,...p)}else this[Vi]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",(()=>this[zi]())),u=!1);return u}[zi](){do{}while(this[Gi](this[Qi].shift()));if(!this[Qi].length){let t=this[Vi];!t||t.flowing||t.size===t.remain?this[Nn]||this.emit("drain"):t.once("drain",(()=>this.emit("drain")))}}[bn](t,u){let p=this[Hi];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[Ui]="header",this[Hi]=void 0,p.end()),g.length}[wn](t,u){let p=this[Hi],m=this[bn](t,u);return!this[Hi]&&p&&this[Zi](p),m}[dn](t,u,p){!this[Qi].length&&!this[Vi]?this.emit(t,u,p):this[Qi].push([t,u,p])}[Zi](t){switch(this[dn]("meta",this[Ji]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Wi]=Ci.parse(this[Ji],this[Wi],!1);break;case"GlobalExtendedHeader":this[qi]=Ci.parse(this[Ji],this[qi],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let t=this[Wi]??Object.create(null);this[Wi]=t,t.path=this[Ji].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let t=this[Wi]||Object.create(null);this[Wi]=t,t.linkpath=this[Ji].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[Dn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}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[Dn])return p?.(),!1;if((this[fn]===void 0||this.brotli===void 0&&this[fn]===!1)&&t){if(this[Xi]&&(t=Buffer.concat([this[Xi],t]),this[Xi]=void 0),t.length<Fi)return this[Xi]=t,p?.(),!0;for(let u=0;this[fn]===void 0&&u<Li.length;u++)t[u]!==Li[u]&&(this[fn]=!1);let u=!1;if(this[fn]===!1&&this.zstd!==!1){u=!0;for(let p=0;p<Mi.length;p++)if(t[p]!==Mi[p]){u=!1;break}}let m=this.brotli===void 0&&!u;if(this[fn]===!1&&m)if(t.length<512)if(this[tn])this.brotli=!0;else return this[Xi]=t,p?.(),!0;else try{new xi(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[fn]===void 0||this[fn]===!1&&(this.brotli||u)){let m=this[tn];this[tn]=!1,this[fn]=this[fn]===void 0?new yi({}):u?new Si({}):new bi({}),this[fn].on("data",(t=>this[gn](t))),this[fn].on("error",(t=>this.abort(t))),this[fn].on("end",(()=>{this[tn]=!0,this[gn]()})),this[Nn]=!0;let g=!!this[fn][m?"end":"write"](t);return this[Nn]=!1,p?.(),g}}this[Nn]=!0,this[fn]?this[fn].write(t):this[gn](t),this[Nn]=!1;let m=this[Qi].length?!1:this[Vi]?this[Vi].flowing:!0;return!m&&!this[Qi].length&&this[Vi]?.once("drain",(()=>this.emit("drain"))),p?.(),m}[An](t){t&&!this[Dn]&&(this[Xi]=this[Xi]?Buffer.concat([this[Xi],t]):t)}[xn](){if(this[tn]&&!this[hn]&&!this[Dn]&&!this[Sn]){this[hn]=!0;let t=this[Hi];if(t&&t.blockRemain){let u=this[Xi]?this[Xi].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${u} available)`,{entry:t}),this[Xi]&&t.write(this[Xi]),t.end()}this[dn](Ln)}}[gn](t){if(this[Sn]&&t)this[An](t);else if(!t&&!this[Xi])this[xn]();else if(t){if(this[Sn]=!0,this[Xi]){this[An](t);let u=this[Xi];this[Xi]=void 0,this[yn](u)}else this[yn](t);for(;this[Xi]&&this[Xi]?.length>=512&&!this[Dn]&&!this[Vn];){let t=this[Xi];this[Xi]=void 0,this[yn](t)}this[Sn]=!1}(!this[Xi]||this[tn])&&this[xn]()}[yn](t){let u=0,p=t.length;for(;u+512<=p&&!this[Dn]&&!this[Vn];)switch(this[Ui]){case"begin":case"header":this[En](t,u),u+=512;break;case"ignore":case"body":u+=this[bn](t,u);break;case"meta":u+=this[wn](t,u);break;default:throw new Error("invalid state: "+this[Ui])}u<p&&(this[Xi]?this[Xi]=Buffer.concat([t.subarray(u),this[Xi]]):this[Xi]=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[Dn]||(this[fn]?(t&&this[fn].write(t),this[fn].end()):(this[tn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[xn]())),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 _n=t=>{let u=t.onReadEntry;t.onReadEntry=u?t=>{u(t),t.resume()}:t=>t.resume()},Yi=(t,u)=>{let p=new Map(u.map((t=>[mt(t),!0]))),m=t.filter,r=(t,u="")=>{let m=u||(0,Xt.parse)(t).root||".",g;if(t===m)g=!1;else{let u=p.get(t);u!==void 0?g=u:g=r((0,Xt.dirname)(t),m)}return p.set(t,g),g};t.filter=m?(t,u)=>m(t,u)&&r(mt(t)):t=>r(mt(t))},On=u=>{let p=new Gn(u),m=u.file,g;try{g=t.openSync(m,"r");let y=t.fstatSync(g),v=u.maxReadSize||16*1024*1024;if(y.size<v){let u=Buffer.allocUnsafe(y.size),m=t.readSync(g,u,0,y.size,0);p.end(m===u.byteLength?u:u.subarray(0,m))}else{let u=0,m=Buffer.allocUnsafe(v);for(;u<y.size;){let y=t.readSync(g,m,0,v,u);if(y===0)break;u+=y,p.write(m.subarray(0,y))}p.end()}}finally{if(typeof g=="number")try{t.closeSync(g)}catch{}}},Tn=(u,p)=>{let m=new Gn(u),g=u.maxReadSize||16*1024*1024,y=u.file;return new Promise(((u,p)=>{m.on("error",p),m.on("end",u),t.stat(y,((t,u)=>{if(t)p(t);else{let t=new ei(y,{readSize:g,size:u.size});t.on("error",p),t.pipe(m)}}))}))},Wn=K(On,Tn,(t=>new Gn(t)),(t=>new Gn(t)),((t,u)=>{u?.length&&Yi(t,u),t.noResume||_n(t)}));var Ki=(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:qn,parse:Kn}=u.win32,ce=t=>{let u="",p=Kn(t);for(;qn(t)||p.root;){let m=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":p.root;t=t.slice(m.length),u+=m,p=Kn(t)}return[u,t]};var Yn=["|","<",">","?",":"],Jn=Yn.map((t=>String.fromCharCode(61440+t.charCodeAt(0)))),Zn=new Map(Yn.map(((t,u)=>[t,Jn[u]]))),to=new Map(Jn.map(((t,u)=>[t,Yn[u]]))),$i=t=>Yn.reduce(((t,u)=>t.split(u).join(Zn.get(u))),t),Vs=t=>Jn.reduce(((t,u)=>t.split(u).join(to.get(u))),t);var tr=(t,u)=>u?(t=Ni(t).replace(/^\.(\/|$)/,""),mt(u)+"/"+t):Ni(t),ro=16*1024*1024,so=Symbol("process"),io=Symbol("file"),lo=Symbol("directory"),go=Symbol("symlink"),yo=Symbol("hardlink"),vo=Symbol("header"),_o=Symbol("read"),bo=Symbol("lstat"),Eo=Symbol("onlstat"),So=Symbol("onread"),$o=Symbol("onreadlink"),Po=Symbol("openfile"),Ao=Symbol("onopenfile"),Oo=Symbol("close"),Ro=Symbol("mode"),xo=Symbol("awaitDrain"),To=Symbol("ondrain"),ko=Symbol("prefix"),Co=class extends ps{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;#y=!1;constructor(t,u={}){let p=re(u);super(),this.path=Ni(t),this.portable=!!p.portable,this.maxReadSize=p.maxReadSize||ro,this.linkCache=p.linkCache||new Map,this.statCache=p.statCache||new Map,this.preservePaths=!!p.preservePaths,this.cwd=Ni(p.cwd||process.cwd()),this.strict=!!p.strict,this.noPax=!!p.noPax,this.noMtime=!!p.noMtime,this.mtime=p.mtime,this.prefix=p.prefix?Ni(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=Vs(this.path.replace(/\\/g,"/")),t=t.replace(/\\/g,"/")),this.absolute=Ni(p.absolute||Xt.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[Eo](g):this[bo]()}warn(t,u,p={}){return Lt(this,t,u,p)}emit(t,...u){return t==="error"&&(this.#y=!0),super.emit(t,...u)}[bo](){Jt.lstat(this.absolute,((t,u)=>{if(t)return this.emit("error",t);this[Eo](u)}))}[Eo](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=In(t),this.emit("stat",t),this[so]()}[so](){switch(this.type){case"File":return this[io]();case"Directory":return this[lo]();case"SymbolicLink":return this[go]();default:return this.end()}}[Ro](t){return Ki(t,this.type==="Directory",this.portable)}[ko](t){return tr(t,this.prefix)}[vo](){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 xi({path:this[ko](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[ko](this.linkpath):this.linkpath,mode:this[Ro](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 Ci({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[ko](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[ko](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)}[lo](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[vo](),this.end()}[go](){Jt.readlink(this.absolute,((t,u)=>{if(t)return this.emit("error",t);this[$o](u)}))}[$o](t){this.linkpath=Ni(t),this[vo](),this.end()}[yo](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Ni(Xt.relative(this.cwd,t)),this.stat.size=0,this[vo](),this.end()}[io](){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[yo](u);this.linkCache.set(t,this.absolute)}if(this[vo](),this.stat.size===0)return this.end();this[Po]()}[Po](){Jt.open(this.absolute,"r",((t,u)=>{if(t)return this.emit("error",t);this[Ao](u)}))}[Ao](t){if(this.fd=t,this.#y)return this[Oo]();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[_o]()}[_o](){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");Jt.read(t,u,p,m,g,((t,u)=>{if(t)return this[Oo]((()=>this.emit("error",t)));this[So](u)}))}[Oo](t=()=>{}){this.fd!==void 0&&Jt.close(this.fd,t)}[So](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[Oo]((()=>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[Oo]((()=>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[To]():this[xo]((()=>this[To]()))}[xo](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)}[To](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[Oo]((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[_o]()}},Io=class extends Co{sync=!0;[bo](){this[Eo](Jt.lstatSync(this.absolute))}[go](){this[$o](Jt.readlinkSync(this.absolute))}[Po](){this[Ao](Jt.openSync(this.absolute,"r"))}[_o](){let t=!0;try{let{fd:u,buf:p,offset:m,length:g,pos:y}=this;if(u===void 0||p===void 0)throw new Error("fd and buf must be set in READ method");let v=Jt.readSync(u,p,m,g,y);this[So](v),t=!1}finally{if(t)try{this[Oo]((()=>{}))}catch{}}}[xo](t){t()}[Oo](t=()=>{}){this.fd!==void 0&&Jt.closeSync(this.fd),t()}},No=class extends ps{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 Lt(this,t,u,p)}constructor(t,u={}){let p=re(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=Ni(t.path),this.mode=t.mode!==void 0?this[Ro](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?Ni(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 xi({path:this[ko](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[ko](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 Ci({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[ko](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[ko](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 y=this.header?.block;if(!y)throw new Error("failed to encode header");super.write(y),t.pipe(this)}[ko](t){return tr(t,this.prefix)}[Ro](t){return Ki(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}},In=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";var Do=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++)Fn(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=Cn(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 Cn(t,u,p){let m=u,g=u?u.next:t.head,y=new jo(p,m,g,t);return y.next===void 0&&(t.tail=y),y.prev===void 0&&(t.head=y),t.length++,y}function Fn(t,u){t.tail=new jo(u,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function kn(t,u){t.head=new jo(u,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var jo=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 Lo=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(t,u){this.path=t||"./",this.absolute=u}},Mo=Buffer.alloc(1024),Fo=Symbol("onStat"),Uo=Symbol("ended"),Bo=Symbol("queue"),Ho=Symbol("current"),Vo=Symbol("process"),zo=Symbol("processing"),Go=Symbol("processJob"),Wo=Symbol("jobs"),qo=Symbol("jobDone"),Ko=Symbol("addFSEntry"),Yo=Symbol("addTarEntry"),Jo=Symbol("stat"),Zo=Symbol("readdir"),Xo=Symbol("onreaddir"),Qo=Symbol("pipe"),ea=Symbol("entry"),ta=Symbol("entryOpt"),ra=Symbol("writeEntryClass"),sa=Symbol("write"),ia=Symbol("ondrain"),na=class extends ps{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[ra];onWriteEntry;[Bo];[Wo]=0;[zo]=!1;[Uo]=!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=Ni(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[ra]=Co,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 gi(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new _i(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Ei(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[ia]())),this.on("resume",(()=>u.resume()))}else this.on("drain",this[ia]);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[Bo]=new Do,this[Wo]=0,this.jobs=Number(t.jobs)||4,this[zo]=!1,this[Uo]=!1}[sa](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[Uo]=!0,this[Vo](),p&&p(),this}write(t){if(this[Uo])throw new Error("write after end");return t instanceof Di?this[Yo](t):this[Ko](t),this.flowing}[Yo](t){let u=Ni(Xt.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let p=new Lo(t.path,u);p.entry=new No(t,this[ta](p)),p.entry.on("end",(()=>this[qo](p))),this[Wo]+=1,this[Bo].push(p)}this[Vo]()}[Ko](t){let u=Ni(Xt.resolve(this.cwd,t));this[Bo].push(new Lo(t,u)),this[Vo]()}[Jo](t){t.pending=!0,this[Wo]+=1;let u=this.follow?"stat":"lstat";Jt[u](t.absolute,((u,p)=>{t.pending=!1,this[Wo]-=1,u?this.emit("error",u):this[Fo](t,p)}))}[Fo](t,u){this.statCache.set(t.absolute,u),t.stat=u,this.filter(t.path,u)?u.isFile()&&u.nlink>1&&t===this[Ho]&&!this.linkCache.get(`${u.dev}:${u.ino}`)&&!this.sync&&this[Go](t):t.ignore=!0,this[Vo]()}[Zo](t){t.pending=!0,this[Wo]+=1,Jt.readdir(t.absolute,((u,p)=>{if(t.pending=!1,this[Wo]-=1,u)return this.emit("error",u);this[Xo](t,p)}))}[Xo](t,u){this.readdirCache.set(t.absolute,u),t.readdir=u,this[Vo]()}[Vo](){if(!this[zo]){this[zo]=!0;for(let t=this[Bo].head;t&&this[Wo]<this.jobs;t=t.next)if(this[Go](t.value),t.value.ignore){let u=t.next;this[Bo].removeNode(t),t.next=u}this[zo]=!1,this[Uo]&&!this[Bo].length&&this[Wo]===0&&(this.zip?this.zip.end(Mo):(super.write(Mo),super.end()))}}get[Ho](){return this[Bo]&&this[Bo].head&&this[Bo].head.value}[qo](t){this[Bo].shift(),this[Wo]-=1,this[Vo]()}[Go](t){if(!t.pending){if(t.entry){t===this[Ho]&&!t.piped&&this[Qo](t);return}if(!t.stat){let u=this.statCache.get(t.absolute);u?this[Fo](t,u):this[Jo](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let u=this.readdirCache.get(t.absolute);if(u?this[Xo](t,u):this[Zo](t),!t.readdir)return}if(t.entry=this[ea](t),!t.entry){t.ignore=!0;return}t===this[Ho]&&!t.piped&&this[Qo](t)}}}[ta](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}}[ea](t){this[Wo]+=1;try{return new this[ra](t.path,this[ta](t)).on("end",(()=>this[qo](t))).on("error",(t=>this.emit("error",t)))}catch(t){this.emit("error",t)}}[ia](){this[Ho]&&this[Ho].entry&&this[Ho].entry.resume()}[Qo](t){t.piped=!0,t.readdir&&t.readdir.forEach((u=>{let p=t.path,m=p==="./"?"":p.replace(/\/*$/,"/");this[Ko](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={}){Lt(this,t,u,p)}},oa=class extends na{sync=!0;constructor(t){super(t),this[ra]=Io}pause(){}resume(){}[Jo](t){let u=this.follow?"statSync":"lstatSync";this[Fo](t,Jt[u](t.absolute))}[Zo](t){this[Xo](t,Jt.readdirSync(t.absolute))}[Qo](t){let u=t.entry,p=this.zip;if(t.readdir&&t.readdir.forEach((u=>{let p=t.path,m=p==="./"?"":p.replace(/\/*$/,"/");this[Ko](m+u)})),!u)throw new Error("Cannot pipe without source");p?u.on("data",(t=>{p.write(t)})):u.on("data",(t=>{super[sa](t)}))}};var vn=(t,u)=>{let p=new oa(t),m=new si(t.file,{mode:t.mode||438});p.pipe(m),hr(p,u)},Mn=(t,u)=>{let p=new na(t),m=new ri(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 ar(p,u),g},hr=(t,p)=>{p.forEach((p=>{p.charAt(0)==="@"?Wn({file:u.resolve(t.cwd,p.slice(1)),sync:!0,noResume:!0,onReadEntry:u=>t.add(u)}):t.add(p)})),t.end()},ar=async(t,p)=>{for(let m=0;m<p.length;m++){let g=String(p[m]);g.charAt(0)==="@"?await Wn({file:u.resolve(String(t.cwd),g.slice(1)),noResume:!0,onReadEntry:u=>{t.add(u)}}):t.add(g)}t.end()},Bn=(t,u)=>{let p=new oa(t);return hr(p,u),p},Pn=(t,u)=>{let p=new na(t);return ar(p,u),p},aa=K(vn,Mn,Bn,Pn,((t,u)=>{if(!u?.length)throw new TypeError("no paths specified to add to archive")}));var ca=process.env.__FAKE_PLATFORM__||process.platform,la=ca==="win32",{O_CREAT:ua,O_TRUNC:ha,O_WRONLY:da}=Jt.constants,fa=Number(process.env.__FAKE_FS_O_FILENAME__)||Jt.constants.UV_FS_O_FILEMAP||0,pa=la&&!!fa,ma=512*1024,ga=fa|ha|ua|da,ya=pa?t=>t<ma?ga:"w":()=>"w";var cs=(u,p,m)=>{try{return t.lchownSync(u,p,m)}catch(t){if(t?.code!=="ENOENT")throw t}},di=(u,p,m,g)=>{t.lchown(u,p,m,(t=>{g(t&&t?.code!=="ENOENT"?t:null)}))},$n=(t,p,m,g,y)=>{if(p.isDirectory())index_min_fs(u.resolve(t,p.name),m,g,(v=>{if(v)return y(v);let b=u.resolve(t,p.name);di(b,m,g,y)}));else{let v=u.resolve(t,p.name);di(v,m,g,y)}},index_min_fs=(u,p,m,g)=>{t.readdir(u,{withFileTypes:!0},((t,y)=>{if(t){if(t.code==="ENOENT")return g();if(t.code!=="ENOTDIR"&&t.code!=="ENOTSUP")return g(t)}if(t||!y.length)return di(u,p,m,g);let v=y.length,b=null,a=t=>{if(!b){if(t)return g(b=t);if(--v===0)return di(u,p,m,g)}};for(let t of y)$n(u,t,p,m,a)}))},Xn=(t,p,m,g)=>{p.isDirectory()&&ds(u.resolve(t,p.name),m,g),cs(u.resolve(t,p.name),m,g)},ds=(u,p,m)=>{let g;try{g=t.readdirSync(u,{withFileTypes:!0})}catch(t){let g=t;if(g?.code==="ENOENT")return;if(g?.code==="ENOTDIR"||g?.code==="ENOTSUP")return cs(u,p,m);throw g}for(let t of g)Xn(u,t,p,m);return cs(u,p,m)};var va=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 _a=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 jn=(u,p)=>{t.stat(u,((t,m)=>{(t||!m.isDirectory())&&(t=new va(u,t?.code||"ENOTDIR")),p(t)}))},fr=(p,m,g)=>{p=Ni(p);let y=m.umask??18,v=m.mode|448,b=(v&y)!==0,w=m.uid,E=m.gid,$=typeof w=="number"&&typeof E=="number"&&(w!==m.processUid||E!==m.processGid),P=m.preserve,A=m.unlink,O=Ni(m.cwd),S=(u,m)=>{u?g(u):m&&$?index_min_fs(m,w,E,(t=>S(t))):b?t.chmod(p,v,g):g()};if(p===O)return jn(p,S);if(P)return ot.mkdir(p,{mode:v,recursive:!0}).then((t=>S(null,t??void 0)),S);let R=Ni(u.relative(O,p)).split("/");us(O,R,v,A,O,void 0,S)},us=(p,m,g,y,v,b,w)=>{if(!m.length)return w(null,b);let E=m.shift(),$=Ni(u.resolve(p+"/"+E));t.mkdir($,g,dr($,m,g,y,v,b,w))},dr=(u,p,m,g,y,v,b)=>w=>{w?t.lstat(u,((E,$)=>{if(E)E.path=E.path&&Ni(E.path),b(E);else if($.isDirectory())us(u,p,m,g,y,v,b);else if(g)t.unlink(u,(w=>{if(w)return b(w);t.mkdir(u,m,dr(u,p,m,g,y,v,b))}));else{if($.isSymbolicLink())return b(new _a(u,u+"/"+p.join("/")));b(w)}})):(v=v||u,us(u,p,m,g,y,v,b))},Qn=u=>{let p=!1,m;try{p=t.statSync(u).isDirectory()}catch(t){m=t?.code}finally{if(!p)throw new va(u,m??"ENOTDIR")}},ur=(p,m)=>{p=Ni(p);let g=m.umask??18,y=m.mode|448,v=(y&g)!==0,b=m.uid,w=m.gid,E=typeof b=="number"&&typeof w=="number"&&(b!==m.processUid||w!==m.processGid),$=m.preserve,P=m.unlink,A=Ni(m.cwd),d=u=>{u&&E&&ds(u,b,w),v&&t.chmodSync(p,y)};if(p===A)return Qn(A),d();if($)return d(t.mkdirSync(p,{mode:y,recursive:!0})??void 0);let O=Ni(u.relative(A,p)).split("/"),R;for(let p=O.shift(),m=A;p&&(m+="/"+p);p=O.shift()){m=Ni(u.resolve(m));try{t.mkdirSync(m,y),R=R||m}catch{let u=t.lstatSync(m);if(u.isDirectory())continue;if(P){t.unlinkSync(m),t.mkdirSync(m,y),R=R||m;continue}else if(u.isSymbolicLink())return new _a(m,m+"/"+O.join("/"))}}return d(R)};var ba=Object.create(null),wa=1e4,Ea=new Set,pr=t=>{Ea.has(t)?Ea.delete(t):ba[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),Ea.add(t);let u=ba[t],p=Ea.size-wa;if(p>wa/10){for(let t of Ea)if(Ea.delete(t),delete ba[t],--p<=0)break}return u};var Sa=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,$a=Sa==="win32",eo=t=>t.split("/").slice(0,-1).reduce(((t,p)=>{let m=t[t.length-1];return m!==void 0&&(p=(0,u.join)(m,p)),t.push(p||"/"),t}),[]),Pa=class{#y=new Map;#v=new Map;#_=new Set;reserve(t,p){t=$a?["win32 parallelization disabled"]:t.map((t=>mt((0,u.join)(pr(t)))));let m=new Set(t.map((t=>eo(t))).reduce(((t,u)=>t.concat(u))));this.#v.set(p,{dirs:m,paths:t});for(let u of t){let t=this.#y.get(u);t?t.push(p):this.#y.set(u,[p])}for(let t of m){let u=this.#y.get(t);if(!u)this.#y.set(t,[new Set([p])]);else{let t=u[u.length-1];t instanceof Set?t.add(p):u.push(new Set([p]))}}return this.#w(p)}#b(t){let u=this.#v.get(t);if(!u)throw new Error("function does not have any path reservations");return{paths:u.paths.map((t=>this.#y.get(t))),dirs:[...u.dirs].map((t=>this.#y.get(t)))}}check(t){let{paths:u,dirs:p}=this.#b(t);return u.every((u=>u&&u[0]===t))&&p.every((u=>u&&u[0]instanceof Set&&u[0].has(t)))}#w(t){return this.#_.has(t)||!this.check(t)?!1:(this.#_.add(t),t((()=>this.#E(t))),!0)}#E(t){if(!this.#_.has(t))return!1;let u=this.#v.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.#y.get(u);if(!p||p?.[0]!==t)continue;let m=p[1];if(!m){this.#y.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.#y.get(u),m=p?.[0];if(!(!p||!(m instanceof Set)))if(m.size===1&&p.length===1){this.#y.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.#_.delete(t),g.forEach((t=>this.#w(t))),!0}};var wr=()=>process.umask();var Aa=Symbol("onEntry"),Oa=Symbol("checkFs"),Ra=Symbol("checkFs2"),xa=Symbol("isReusable"),Ta=Symbol("makeFs"),ka=Symbol("file"),Ca=Symbol("directory"),Ia=Symbol("link"),Na=Symbol("symlink"),Da=Symbol("hardlink"),ja=Symbol("ensureNoSymlink"),La=Symbol("unsupported"),Ma=Symbol("checkPath"),Fa=Symbol("stripAbsolutePath"),Ua=Symbol("mkdir"),Ba=Symbol("onError"),Ha=Symbol("pending"),Va=Symbol("pend"),za=Symbol("unpend"),Ga=Symbol("ended"),Wa=Symbol("maybeClose"),qa=Symbol("skip"),Ka=Symbol("doChown"),Ya=Symbol("uid"),Ja=Symbol("gid"),Za=Symbol("checkedCwd"),Xa=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Qa=Xa==="win32",ec=1024,no=(u,p)=>{if(!Qa)return t.unlink(u,p);let m=u+".DELETE."+(0,I.randomBytes)(16).toString("hex");t.rename(u,m,(u=>{if(u)return p(u);t.unlink(m,p)}))},oo=u=>{if(!Qa)return t.unlinkSync(u);let p=u+".DELETE."+(0,I.randomBytes)(16).toString("hex");t.renameSync(u,p),t.unlinkSync(p)},Tr=(t,u,p)=>t!==void 0&&t===t>>>0?t:u!==void 0&&u===u>>>0?u:p,tc=class extends Gn{[Ga]=!1;[Za]=!1;[Ha]=0;reservations=new Pa;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[Ga]=!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;t.preserveOwner===void 0&&typeof t.uid!="number"?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:ec,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Qa,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Ni(u.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:wr():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[Aa](t)))}warn(t,u,p={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(p.recoverable=!1),super.warn(t,u,p)}[Wa](){this[Ga]&&this[Ha]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Fa](t,p){let m=t[p],{type:g}=t;if(!m||this.preservePaths)return!0;let[y,v]=ce(m),b=v.replace(/\\/g,"/").split("/");if(b.includes("..")||Qa&&/^[a-z]:\.\.$/i.test(b[0]??"")){if(p==="path"||g==="Link")return this.warn("TAR_ENTRY_ERROR",`${p} contains '..'`,{entry:t,[p]:m}),!1;{let g=u.posix.dirname(t.path),y=u.posix.normalize(u.posix.join(g,b.join("/")));if(y.startsWith("../")||y==="..")return this.warn("TAR_ENTRY_ERROR",`${p} escapes extraction directory`,{entry:t,[p]:m}),!1}}return y&&(t[p]=String(v),this.warn("TAR_ENTRY_INFO",`stripping ${y} from absolute ${p}`,{entry:t,[p]:m})),!0}[Ma](t){let p=Ni(t.path),m=p.split("/");if(this.strip){if(m.length<this.strip)return!1;if(t.type==="Link"){let u=Ni(String(t.linkpath)).split("/");if(u.length>=this.strip)t.linkpath=u.slice(this.strip).join("/");else return!1}m.splice(0,this.strip),t.path=m.join("/")}if(isFinite(this.maxDepth)&&m.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:p,depth:m.length,maxDepth:this.maxDepth}),!1;if(!this[Fa](t,"path")||!this[Fa](t,"linkpath"))return!1;if(u.isAbsolute(t.path)?t.absolute=Ni(u.resolve(t.path)):t.absolute=Ni(u.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:Ni(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:p}=u.win32.parse(String(t.absolute));t.absolute=p+$i(String(t.absolute).slice(p.length));let{root:m}=u.win32.parse(t.path);t.path=m+$i(t.path.slice(m.length))}return!0}[Aa](t){if(!this[Ma](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[Oa](t);default:return this[La](t)}}[Ba](t,u){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:u}),this[za](),u.resume())}[Ua](t,u,p){fr(Ni(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)}[Ka](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}[Ya](t){return Tr(this.uid,t.uid,this.processUid)}[Ja](t){return Tr(this.gid,t.gid,this.processGid)}[ka](u,p){let m=typeof u.mode=="number"?u.mode&4095:this.fmode,g=new ri(String(u.absolute),{flags:ya(u.size),mode:m,autoClose:!1});g.on("error",(m=>{g.fd&&t.close(g.fd,(()=>{})),g.write=()=>!0,this[Ba](m,u),p()}));let y=1,o=m=>{if(m){g.fd&&t.close(g.fd,(()=>{})),this[Ba](m,u),p();return}--y===0&&g.fd!==void 0&&t.close(g.fd,(t=>{t?this[Ba](t,u):this[za](),p()}))};g.on("finish",(()=>{let p=String(u.absolute),m=g.fd;if(typeof m=="number"&&u.mtime&&!this.noMtime){y++;let g=u.atime||new Date,v=u.mtime;t.futimes(m,g,v,(u=>u?t.utimes(p,g,v,(t=>o(t&&u))):o()))}if(typeof m=="number"&&this[Ka](u)){y++;let g=this[Ya](u),v=this[Ja](u);typeof g=="number"&&typeof v=="number"&&t.fchown(m,g,v,(u=>u?t.chown(p,g,v,(t=>o(t&&u))):o()))}o()}));let v=this.transform&&this.transform(u)||u;v!==u&&(v.on("error",(t=>{this[Ba](t,u),p()})),u.pipe(v)),v.pipe(g)}[Ca](u,p){let m=typeof u.mode=="number"?u.mode&4095:this.dmode;this[Ua](String(u.absolute),m,(m=>{if(m){this[Ba](m,u),p();return}let g=1,o=()=>{--g===0&&(p(),this[za](),u.resume())};u.mtime&&!this.noMtime&&(g++,t.utimes(String(u.absolute),u.atime||new Date,u.mtime,o)),this[Ka](u)&&(g++,t.chown(String(u.absolute),Number(this[Ya](u)),Number(this[Ja](u)),o)),o()}))}[La](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Na](t,p){let m=Ni(u.relative(this.cwd,u.resolve(u.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[ja](t,this.cwd,m,(()=>this[Ia](t,String(t.linkpath),"symlink",p)),(u=>{this[Ba](u,t),p()}))}[Da](t,p){let m=Ni(u.resolve(this.cwd,String(t.linkpath))),g=Ni(String(t.linkpath)).split("/");this[ja](t,this.cwd,g,(()=>this[Ia](t,m,"link",p)),(u=>{this[Ba](u,t),p()}))}[ja](p,m,g,y,v){let b=g.shift();if(this.preservePaths||b===void 0)return y();let w=u.resolve(m,b);t.lstat(w,((t,m)=>{if(t)return y();if(m?.isSymbolicLink())return v(new _a(w,u.resolve(w,g.join("/"))));this[ja](p,w,g,y,v)}))}[Va](){this[Ha]++}[za](){this[Ha]--,this[Wa]()}[qa](t){this[za](),t.resume()}[xa](t,u){return t.type==="File"&&!this.unlink&&u.isFile()&&u.nlink<=1&&!Qa}[Oa](t){this[Va]();let u=[t.path];t.linkpath&&u.push(t.linkpath),this.reservations.reserve(u,(u=>this[Ra](t,u)))}[Ra](p,m){let i=t=>{m(t)},r=()=>{this[Ua](this.cwd,this.dmode,(t=>{if(t){this[Ba](t,p),i();return}this[Za]=!0,n()}))},n=()=>{if(p.absolute!==this.cwd){let t=Ni(u.dirname(String(p.absolute)));if(t!==this.cwd)return this[Ua](t,this.dmode,(t=>{if(t){this[Ba](t,p),i();return}o()}))}o()},o=()=>{t.lstat(String(p.absolute),((u,m)=>{if(m&&(this.keep||this.newer&&m.mtime>(p.mtime??m.mtime))){this[qa](p),i();return}if(u||this[xa](p,m))return this[Ta](null,p,i);if(m.isDirectory()){if(p.type==="Directory"){let u=this.chmod&&p.mode&&(m.mode&4095)!==p.mode,c=t=>this[Ta](t??null,p,i);return u?t.chmod(String(p.absolute),Number(p.mode),c):c()}if(p.absolute!==this.cwd)return t.rmdir(String(p.absolute),(t=>this[Ta](t??null,p,i)))}if(p.absolute===this.cwd)return this[Ta](null,p,i);no(String(p.absolute),(t=>this[Ta](t??null,p,i)))}))};this[Za]?n():r()}[Ta](t,u,p){if(t){this[Ba](t,u),p();return}switch(u.type){case"File":case"OldFile":case"ContiguousFile":return this[ka](u,p);case"Link":return this[Da](u,p);case"SymbolicLink":return this[Na](u,p);case"Directory":case"GNUDumpDir":return this[Ca](u,p)}}[Ia](u,p,m,g){t[m](p,String(u.absolute),(t=>{t?this[Ba](t,u):(this[za](),u.resume()),g()}))}},Se=t=>{try{return[null,t()]}catch(t){return[t,null]}},rc=class extends tc{sync=!0;[Ta](t,u){return super[Ta](t,u,(()=>{}))}[Oa](p){if(!this[Za]){let t=this[Ua](this.cwd,this.dmode);if(t)return this[Ba](t,p);this[Za]=!0}if(p.absolute!==this.cwd){let t=Ni(u.dirname(String(p.absolute)));if(t!==this.cwd){let u=this[Ua](t,this.dmode);if(u)return this[Ba](u,p)}}let[m,g]=Se((()=>t.lstatSync(String(p.absolute))));if(g&&(this.keep||this.newer&&g.mtime>(p.mtime??g.mtime)))return this[qa](p);if(m||this[xa](p,g))return this[Ta](null,p);if(g.isDirectory()){if(p.type==="Directory"){let u=this.chmod&&p.mode&&(g.mode&4095)!==p.mode,[m]=u?Se((()=>{t.chmodSync(String(p.absolute),Number(p.mode))})):[];return this[Ta](m,p)}let[u]=Se((()=>t.rmdirSync(String(p.absolute))));this[Ta](u,p)}let[y]=p.absolute===this.cwd?[]:Se((()=>oo(String(p.absolute))));this[Ta](y,p)}[ka](u,p){let m=typeof u.mode=="number"?u.mode&4095:this.fmode,r=m=>{let y;try{t.closeSync(g)}catch(t){y=t}(m||y)&&this[Ba](m||y,u),p()},g;try{g=t.openSync(String(u.absolute),ya(u.size),m)}catch(t){return r(t)}let y=this.transform&&this.transform(u)||u;y!==u&&(y.on("error",(t=>this[Ba](t,u))),u.pipe(y)),y.on("data",(u=>{try{t.writeSync(g,u,0,u.length)}catch(t){r(t)}})),y.on("end",(()=>{let p=null;if(u.mtime&&!this.noMtime){let m=u.atime||new Date,y=u.mtime;try{t.futimesSync(g,m,y)}catch(g){try{t.utimesSync(String(u.absolute),m,y)}catch{p=g}}}if(this[Ka](u)){let m=this[Ya](u),y=this[Ja](u);try{t.fchownSync(g,Number(m),Number(y))}catch(g){try{t.chownSync(String(u.absolute),Number(m),Number(y))}catch{p=p||g}}}r(p)}))}[Ca](u,p){let m=typeof u.mode=="number"?u.mode&4095:this.dmode,g=this[Ua](String(u.absolute),m);if(g){this[Ba](g,u),p();return}if(u.mtime&&!this.noMtime)try{t.utimesSync(String(u.absolute),u.atime||new Date,u.mtime)}catch{}if(this[Ka](u))try{t.chownSync(String(u.absolute),Number(this[Ya](u)),Number(this[Ja](u)))}catch{}p(),u.resume()}[Ua](t,u){try{return ur(Ni(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}}[ja](p,m,g,y,v){if(this.preservePaths||!g.length)return y();let b=m;for(let p of g){b=u.resolve(b,p);let[w,E]=Se((()=>t.lstatSync(b)));if(w)return y();if(E.isSymbolicLink())return v(new _a(b,u.resolve(m,g.join("/"))))}y()}[Ia](u,p,m,g){let y=`${m}Sync`;try{t[y](p,String(u.absolute)),g(),u.resume()}catch(t){return this[Ba](t,u)}}};var ho=u=>{let p=new rc(u),m=u.file,g=t.statSync(m),y=u.maxReadSize||16*1024*1024;new ti(m,{readSize:y,size:g.size}).pipe(p)},ao=(u,p)=>{let m=new tc(u),g=u.maxReadSize||16*1024*1024,y=u.file;return new Promise(((u,p)=>{m.on("error",p),m.on("close",u),t.stat(y,((t,u)=>{if(t)p(t);else{let t=new ei(y,{readSize:g,size:u.size});t.on("error",p),t.pipe(m)}}))}))},sc=K(ho,ao,(t=>new rc(t)),(t=>new tc(t)),((t,u)=>{u?.length&&Yi(t,u)}));var co=(u,p)=>{let m=new oa(u),g=!0,y,v;try{try{y=t.openSync(u.file,"r+")}catch(p){if(p?.code==="ENOENT")y=t.openSync(u.file,"w+");else throw p}let b=t.fstatSync(y),w=Buffer.alloc(512);e:for(v=0;v<b.size;v+=512){for(let u=0,p=0;u<512;u+=p){if(p=t.readSync(y,w,u,w.length-u,v+u),v===0&&w[0]===31&&w[1]===139)throw new Error("cannot append to compressed archives");if(!p)break e}let p=new xi(w);if(!p.cksumValid)break;let m=512*Math.ceil((p.size||0)/512);if(v+m+512>b.size)break;v+=m,u.mtimeCache&&p.mtime&&u.mtimeCache.set(String(p.path),p.mtime)}g=!1,fo(u,m,v,y,p)}finally{if(g)try{t.closeSync(y)}catch{}}},fo=(t,u,p,m,g)=>{let y=new si(t.file,{fd:m,start:p});u.pipe(y),mo(u,g)},uo=(u,p)=>{p=Array.from(p);let m=new na(u),i=(p,m,g)=>{let a=(u,m)=>{u?t.close(p,(t=>g(u))):g(null,m)},y=0;if(m===0)return a(null,0);let v=0,b=Buffer.alloc(512),S=(g,w)=>{if(g||typeof w>"u")return a(g);if(v+=w,v<512&&w)return t.read(p,b,v,b.length-v,y+v,S);if(y===0&&b[0]===31&&b[1]===139)return a(new Error("cannot append to compressed archives"));if(v<512)return a(null,y);let E=new xi(b);if(!E.cksumValid)return a(null,y);let $=512*Math.ceil((E.size??0)/512);if(y+$+512>m||(y+=$+512,y>=m))return a(null,y);u.mtimeCache&&E.mtime&&u.mtimeCache.set(String(E.path),E.mtime),v=0,t.read(p,b,0,512,y,S)};t.read(p,b,0,512,y,S)};return new Promise(((g,y)=>{m.on("error",y);let v="r+",a=(b,w)=>{if(b&&b.code==="ENOENT"&&v==="r+")return v="w+",t.open(u.file,v,a);if(b||!w)return y(b);t.fstat(w,((v,b)=>{if(v)return t.close(w,(()=>y(v)));i(w,b.size,((t,v)=>{if(t)return y(t);let b=new ri(u.file,{fd:w,start:v});m.pipe(b),b.on("error",y),b.on("close",g),po(m,p)}))}))};t.open(u.file,v,a)}))},mo=(t,p)=>{p.forEach((p=>{p.charAt(0)==="@"?Wn({file:u.resolve(t.cwd,p.slice(1)),sync:!0,noResume:!0,onReadEntry:u=>t.add(u)}):t.add(p)})),t.end()},po=async(t,p)=>{for(let m=0;m<p.length;m++){let g=String(p[m]);g.charAt(0)==="@"?await Wn({file:u.resolve(String(t.cwd),g.slice(1)),noResume:!0,onReadEntry:u=>t.add(u)}):t.add(g)}t.end()},ic=K(co,uo,(()=>{throw new TypeError("file is required")}),(()=>{throw new TypeError("file is required")}),((t,u)=>{if(!ks(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 nc=K(ic.syncFile,ic.asyncFile,ic.syncNoFile,ic.asyncNoFile,((t,u=[])=>{ic.validate?.(t,u),wo(t)})),wo=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))};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,y,...v]=t.pathname.split("/");const b=u?u.replace(/^\//,""):v.join("/");if(g===undefined||g===""&&y===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:b}}catch{return}}const w=u?`${y}/${v.join("/")}`.replace(new RegExp(`/${b}|/$`),""):y;if(p&&m&&w&&g==="tree"){return{username:p,name:m,branch:w,filePath:b}}}function hasRepo({username:t,name:u,branch:p,filePath:m}){const g=`https://api.github.com/repos/${t}/${u}/contents`;const y=`${m?`/${m}`:""}/package.json`;return isUrlOk(`${g}${y}?ref=${p}`)}function existsInRepo(t){try{const u=new URL(t);return isUrlOk(u.href)}catch{return isUrlOk(`https://api.github.com/repos/zuplo/zudoku/contents/examples/${encodeURIComponent(t)}`)}}async function downloadTarStream(t){const u=await fetch(t);if(!u.body){throw new Error(`Failed to download: ${t}`)}return z.Readable.fromWeb(u.body)}async function downloadAndExtractRepo(t,{username:p,name:m,branch:g,filePath:y}){let v=null;await(0,Kt.pipeline)(await downloadTarStream(`https://codeload.github.com/${p}/${m}/tar.gz/${g}`),sc({cwd:t,strip:y?y.split("/").length+1:1,filter:t=>{if(v===null){const p=t.split(u.sep);v=p.length?p[0]:null}return t.startsWith(`${v}${y?`/${y}/`:"/"}`)}}))}async function downloadAndExtractExample(t,u){if(u==="__internal-testing-retry"){throw new Error("This is an internal example for testing the CLI.")}await(0,Kt.pipeline)(await downloadTarStream("https://codeload.github.com/zuplo/zudoku/tar.gz/canary"),sc({cwd:t,strip:2+u.split("/").length,filter:t=>t.includes(`zudoku-canary/examples/${u}/`)}))}var oc=__nccwpck_require__(1421);function isInGitRepository(){try{(0,oc.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch{}return false}function isInMercurialRepository(){try{(0,oc.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch{}return false}function isDefaultBranchSet(){try{(0,oc.execSync)("git config init.defaultBranch",{stdio:"ignore"});return true}catch{}return false}function tryGitInit(p){let m=false;try{(0,oc.execSync)("git --version",{stdio:"ignore"});if(isInGitRepository()||isInMercurialRepository()){return false}(0,oc.execSync)("git init",{stdio:"ignore"});m=true;if(!isDefaultBranchSet()){(0,oc.execSync)("git checkout -b main",{stdio:"ignore"})}(0,oc.execSync)("git add -A",{stdio:"ignore"});(0,oc.execSync)('git commit -m "Initial commit from Create Next App"',{stdio:"ignore"});return true}catch{if(m){try{(0,t.rmSync)((0,u.join)(p,".git"),{recursive:true,force:true})}catch{}}return false}}var ac=__nccwpck_require__(670);var cc=__nccwpck_require__.n(ac);async function install(t,u){const p=["install"];if(!u){console.log((0,Qe.yellow)("You appear to be offline.\nFalling back to the local cache."));p.push("--offline")}return new Promise(((u,m)=>{const g=cc()(t,p,{stdio:"inherit",env:{...process.env,ADBLOCK:"1",NODE_ENV:"development",DISABLE_OPENCOLLECTIVE:"1"}});g.on("close",(g=>{if(g!==0){m({command:`${t} ${p.join(" ")}`});return}u()}))}))}function isFolderEmpty(p,m){const g=[".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 y=(0,t.readdirSync)(p).filter((t=>!g.includes(t)&&!/\.iml$/.test(t)));if(y.length>0){console.log(`The directory ${(0,Qe.green)(m)} contains files that could conflict:`);console.log();for(const m of y){try{const g=(0,t.lstatSync)((0,u.join)(p,m));if(g.isDirectory()){console.log(` ${(0,Qe.blue)(m)}/`)}else{console.log(` ${m}`)}}catch{console.log(` ${m}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}const lc=require("node:dns/promises");const uc=require("node:url");var hc=__nccwpck_require__.n(uc);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const t=(0,oc.execSync)("npm config get https-proxy").toString().trim();return t!=="null"?t:undefined}catch{return}}async function getOnline(){try{await(0,lc.lookup)("registry.yarnpkg.com");return true}catch{const t=getProxy();if(!t){return false}const{hostname:u}=hc().parse(t);if(!u){return false}try{await(0,lc.lookup)(u);return true}catch{return false}}}const dc=require("node:constants");async function isWriteable(t){try{await(0,ot.access)(t,dc.W_OK);return true}catch{return false}}var fc=__nccwpck_require__(2457);const identity=t=>t;const copy=async(t,p,{cwd:m,rename:g=identity,parents:y=true}={})=>{const v=typeof t==="string"?[t]:t;if(v.length===0||!p){throw new TypeError("`src` and `dest` are required")}const b=await(0,fc.async)(v,{cwd:m,dot:true,absolute:false,stats:false});const w=m?(0,u.resolve)(m,p):p;return Promise.all(b.map((async t=>{const p=(0,u.dirname)(t);const v=g((0,u.basename)(t));const b=m?(0,u.resolve)(m,t):t;const E=y?(0,u.join)(w,p,v):(0,u.join)(w,v);await(0,ot.mkdir)((0,u.dirname)(E),{recursive:true});return(0,ot.copyFile)(b,E)})))};var pc;const mc=__dirname.endsWith("dist")?p().dirname(__dirname):p().dirname(__dirname);const gc=__dirname.endsWith("dist")?p().join(__dirname,"templates"):__dirname;const yc=p().resolve(mc,"../..");const vc=(pc=process.env.ComSpec)!==null&&pc!==void 0?pc:"cmd.exe";const formatAppTitle=t=>t.split(/[-_\s]+/).filter(Boolean).map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join(" ");const resolveCoreApitogoPackageName=async()=>{const t=JSON.parse(await ct().readFile(p().join(mc,"package.json"),"utf8"));return t.name.replace("/create-apitogo","/apitogo")};const _c="@lukow"+"eb";const normalizeDependencyVersion=t=>t.replace(/^[\^~>=<]+/,"");const bc="0.577.0";const ensureRequiredApitogoModules=(t,u,p)=>{var m,g,y,v;const b=u.slice(0,u.indexOf("/"));const w=`${b}/apitogo-module-landing`;const E=`${b}/apitogo-module-user-panel`;const $=`${b}/apitogo-plugin-dev-portal-billing`;const P=`^${normalizeDependencyVersion(p)}`;(m=t[w])!==null&&m!==void 0?m:t[w]=P;(g=t[E])!==null&&g!==void 0?g:t[E]=P;(y=t[$])!==null&&y!==void 0?y:t[$]=P;(v=t["lucide-react"])!==null&&v!==void 0?v:t["lucide-react"]=bc};const ensureSecondaryApitogoAliases=(t,u,p)=>{if(u.startsWith(`${_c}/`)){return}const alias=t=>`npm:${t}@${normalizeDependencyVersion(p)}`;const m=u.slice(0,u.indexOf("/"));t[`${_c}/apitogo`]=alias(u);t[`${_c}/apitogo-module-landing`]=alias(`${m}/apitogo-module-landing`);t[`${_c}/apitogo-module-user-panel`]=alias(`${m}/apitogo-module-user-panel`);t[`${_c}/apitogo-plugin-dev-portal-billing`]=alias(`${m}/apitogo-plugin-dev-portal-billing`)};const parseWorkspaceCatalog=async t=>{var u,p,m;const g=await ct().readFile(t,"utf8");const y={};let v=false;for(const t of g.split(/\r?\n/)){if(!v){v=t.trim()==="catalog:";continue}if(!t.startsWith(" "))break;const g=t.match(/^ {2}(?:"([^"]+)"|([^:]+)):\s+(.+)$/);if(!g)continue;const b=(u=g[1])!==null&&u!==void 0?u:(p=g[2])===null||p===void 0?void 0:p.trim();const w=(m=g[3])===null||m===void 0?void 0:m.trim();if(b&&w)y[b]=w}return y};const replaceCatalogVersions=(t,u)=>{if(Array.isArray(t)){return t.map((t=>replaceCatalogVersions(t,u)))}if(!t||typeof t!=="object"){return t}return Object.fromEntries(Object.entries(t).map((([t,p])=>{var m;return[t,p==="catalog:"?(m=u[t])!==null&&m!==void 0?m:p:replaceCatalogVersions(p,u)]})))};const stageLocalZudokuPackage=async(t,u)=>{var m,g;const y=await parseWorkspaceCatalog(p().join(yc,"pnpm-workspace.yaml"));const v=p().join(t,"package.json");const b=JSON.parse(await ct().readFile(v,"utf8"));const w=replaceCatalogVersions(b,y);const E=new Set(["package.json",...Array.isArray(b.files)?b.files:[]]);await ct().rm(u,{recursive:true,force:true});await ct().mkdir(u,{recursive:true});for(const m of E){if(m==="package.json")continue;const g=p().join(t,m);const y=p().join(u,m);const v=await ct().stat(g).catch((()=>null));if(!v)continue;if(v.isDirectory()){await ct().cp(g,y,{recursive:true})}else{await ct().mkdir(p().dirname(y),{recursive:true});await ct().copyFile(g,y)}}(m=w.scripts)===null||m===void 0?true:delete m.prepublishOnly;(g=w.scripts)===null||g===void 0?true:delete g.postpublish;if(w.scripts&&Object.keys(w.scripts).length===0){delete w.scripts}await ct().writeFile(p().join(u,"package.json"),JSON.stringify(w,null,2)+M().EOL)};const getTemplateFile=({template:t,mode:u,file:m})=>p().join(gc,t,u,m);const installTemplate=async({appName:t,root:u,packageManager:m,isOnline:g,template:y,mode:v,eslint:b,skipInstall:w,zudokuVersion:E})=>{var $;console.log((0,Qe.bold)(`Using ${m}.`));console.log("\nInitializing project with template:",y,"\n");const P=p().join(gc,y,v);const A=["**"];if(!b)A.push("!eslintrc.json");await copy(A,u,{parents:true,cwd:P,rename(t){switch(t){case"gitignore":case"eslintrc.json":{return`.${t}`}case"env":{return".env"}case"README-template.md":{return"README.md"}case"zudoku.config.tsx":{return"apitogo.config.tsx"}case"zudoku.config.jsx":{return"apitogo.config.jsx"}default:{return t}}}});const O=formatAppTitle(t);const substituteAppTitle=t=>t.split("__APP_TITLE__").join(O);const R=v==="ts"?"apitogo.config.tsx":"apitogo.config.jsx";const x=p().join(u,R);const T=await ct().readFile(x,"utf8");await ct().writeFile(x,substituteAppTitle(T),"utf8");const k=p().join(u,"apitogo.config.json");try{const t=await ct().readFile(k,"utf8");await ct().writeFile(k,substituteAppTitle(t),"utf8")}catch{}const C=($=process.env.ZUDOKU_PRIVATE_TEST_VERSION)!==null&&$!==void 0?$:E;const I=p().join(yc,"packages","zudoku");const N=p().join(I,"package.json");const D=await ct().access(N).then((async()=>{const t=p().join(u,".apitogo-local");const m=p().join(t,"zudoku-package");await ct().mkdir(t,{recursive:true});await stageLocalZudokuPackage(I,m);const g=p().relative(m,t);const y=(process.platform==="win32"?(0,oc.execFileSync)(vc,["/d","/c","npm","pack","--pack-destination",g],{cwd:m,encoding:"utf8"}):(0,oc.execFileSync)("npm",["pack","--pack-destination",g],{cwd:m,encoding:"utf8"})).trim().split(/\r?\n/).at(-1);if(!y){throw new Error("Failed to pack local zudoku package.")}return`file:.apitogo-local/${y}`})).catch((()=>C));const j=await resolveCoreApitogoPackageName();const L={name:t,version:"0.1.0",type:"module",private:true,scripts:{dev:"apitogo run",build:"apitogo build",preview:"apitogo build --preview",deploy:"apitogo deploy",lint:"eslint"},dependencies:{react:">=19.0.0","react-dom":">=19.0.0",[j]:D},devDependencies:{}};if(!D.startsWith("file:")){ensureRequiredApitogoModules(L.dependencies,j,D);ensureSecondaryApitogoAliases(L.dependencies,j,D)}if(v==="ts"){L.devDependencies={...L.devDependencies,"@types/node":"^22","@types/react":"^19","@types/react-dom":"^19",typescript:"^5"}}if(b){L.devDependencies={...L.devDependencies,eslint:"^8"}}if(b&&v==="ts"){L.devDependencies={...L.devDependencies,"@typescript-eslint/eslint-plugin":"^8","@typescript-eslint/parser":"^8"}}const U=Object.keys(L.devDependencies).length;if(!U)delete L.devDependencies;await ct().writeFile(p().join(u,"package.json"),JSON.stringify(L,null,2)+M().EOL);if(w)return;console.log("\nInstalling dependencies:");for(const t in L.dependencies)console.log(`- ${(0,Qe.cyan)(t)}`);if(U){console.log("\nInstalling devDependencies:");for(const t in L.devDependencies)console.log(`- ${(0,Qe.cyan)(t)}`)}console.log();await install(m,g)};class DownloadError extends Error{}async function createApp({appPath:p,packageManager:m,example:g,examplePath:y,typescript:v,eslint:b,skipInstall:w,zudokuVersion:E,withExamples:$=true}){let P;const A=v?"ts":"js";const O=$?"default":"empty";if(g){let L;try{L=new URL(g)}catch(M){const U=M;if(U.code!=="ERR_INVALID_URL"){console.error(M);process.exit(1)}}if(L){if(L.origin!=="https://github.com"){console.error(`Invalid URL: ${(0,Qe.red)(`"${g}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);process.exit(1)}P=await getRepoInfo(L,y);if(!P){console.error(`Found invalid GitHub URL: ${(0,Qe.red)(`"${g}"`)}. Please fix the URL and try again.`);process.exit(1)}const B=await hasRepo(P);if(!B){console.error(`Could not locate the repository for ${(0,Qe.red)(`"${g}"`)}. Please check that the repository exists and try again.`);process.exit(1)}}else if(g!=="__internal-testing-retry"){const H=await existsInRepo(g);if(!H){console.error(`Could not locate an example named ${(0,Qe.red)(`"${g}"`)}. It could be due to the following:\n`,`1. Your spelling of example ${(0,Qe.red)(`"${g}"`)} might be incorrect.\n`,`2. You might not be connected to the internet or you are behind a proxy.`);process.exit(1)}}}const R=(0,u.resolve)(p);if(!await isWriteable((0,u.dirname)(R))){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 x=(0,u.basename)(R);(0,t.mkdirSync)(R,{recursive:true});if(!isFolderEmpty(R,x)){process.exit(1)}const T=m==="yarn";const k=!T||await getOnline();const C=process.cwd();console.log(`Creating a new API ToGo app in ${(0,Qe.green)(R)}.`);console.log();process.chdir(R);const I=(0,u.join)(R,"package.json");let N=false;if(g){try{if(P){const z=P;console.log(`Downloading files from repo ${(0,Qe.cyan)(g)}. This might take a moment.`);console.log();await nt()((()=>downloadAndExtractRepo(R,z)),{retries:3})}else{console.log(`Downloading files for example ${(0,Qe.cyan)(g)}. This might take a moment.`);console.log();await nt()((()=>downloadAndExtractExample(R,g)),{retries:3})}}catch(G){function isErrorLike(t){return typeof t==="object"&&t!==null&&typeof t.message==="string"}throw new DownloadError(isErrorLike(G)?G.message:String(G))}const V=(0,u.join)(R,".gitignore");if(!(0,t.existsSync)(V)){(0,t.copyFileSync)(getTemplateFile({template:O,mode:A,file:"gitignore"}),V)}N=(0,t.existsSync)(I);if(!w&&N){console.log("Installing packages. This might take a couple of minutes.");console.log();await install(m,k);console.log()}}else{await installTemplate({appName:x,root:R,template:O,mode:A,packageManager:m,isOnline:k,eslint:b,skipInstall:w,zudokuVersion:E})}const D=process.env.APITOGO_SKIP_NEARBY_DISCOVERY==="1";if(!g&&!D){try{const{openApiDiscovery:W,docsDiscovery:q}=await runScaffoldDiscovery(R);const Y=formatInitDiscoveryReport(R,W,q);if(Y.length>0){console.log("Discovered nearby API docs:");for(const J of Y){console.log(` ${J}`)}console.log()}}catch(Z){console.log("Could not auto-wire nearby OpenAPI/docs:",Z instanceof Error?Z.message:String(Z));console.log()}}if(tryGitInit(R)){console.log("Initialized a git repository.");console.log()}let j;if((0,u.join)(C,x)===p){j=x}else{j=p}console.log(`${(0,Qe.green)("Success!")} Created ${x} at ${p}`);if(N){console.log("Inside that directory, you can run several commands:");console.log();console.log((0,Qe.cyan)(` ${m} ${T?"":"run "}dev`));console.log(" Starts the development server.");console.log();console.log((0,Qe.cyan)(` ${m} ${T?"":"run "}build`));console.log(" Builds the app for production.");console.log();console.log((0,Qe.cyan)(` ${m} start`));console.log(" Runs the built app in production mode.");console.log();console.log("We suggest that you begin by typing:");console.log();console.log((0,Qe.cyan)(" cd"),j);console.log(` ${(0,Qe.cyan)(`${m} ${T?"":"run "}dev`)}`)}console.log()}function getPkgManager(){var t;const u=(t=process.env.npm_config_user_agent)!==null&&t!==void 0?t:"";if(u.startsWith("yarn")){return"yarn"}if(u.startsWith("pnpm")){return"pnpm"}if(u.startsWith("bun")){return"bun"}return"npm"}var wc=__nccwpck_require__(8904);var Ec=__nccwpck_require__.n(wc);function validateNpmName(t){const u=Ec()(t);if(u.validForNewPackages){return{valid:true}}return{valid:false,problems:[...u.errors||[],...u.warnings||[]]}}let Sc="";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 $c=JSON.parse((0,t.readFileSync)(p().resolve(__dirname,"../package.json"),"utf-8"));const Pc=new O($c.name).version($c.version,"-v, --version","Output the current version of @lukoweb/create-apitogo.").description("Create a new APItoGo developer portal.\n\nRun without arguments for an interactive setup, or pass flags such as --typescript --eslint.\nAuto-discovers nearby OpenAPI and docs/ folders after scaffold.").argument("[directory]",'Project directory (defaults to "dev-portal")').usage("[directory] [options]").helpOption("-h, --help","Display this help message.").option("--ts, --typescript","Initialize as a TypeScript project (default).").option("--js, --javascript","Initialize as a JavaScript project.").option("--eslint","Initialize with ESLint config. Use --no-eslint to skip.").option("--include-examples, --with-examples","Use the default template (sample homepage, docs, OpenAPI, and plans). On by default. Use --no-include-examples for the empty template.").option("--import-alias <prefix/*>",'Specify import alias to use (default "@/*").').option("--use-npm","Use npm as the package manager.").option("--use-pnpm","Use pnpm as the package manager.").option("--use-yarn","Use Yarn as the package manager.").option("--use-bun","Use Bun as the package manager.").option("--reset, --reset-preferences","Reset the preferences saved for @lukoweb/create-apitogo.").option("--skip-install","Skip installing packages after scaffolding.").option("-y, --yes","Skip remaining prompts and use defaults for unspecified options.").option("-e, --example <example-name|github-url>","Bootstrap from an example in the Zudoku repo or a public GitHub URL.").option("--example-path <path-to-example>","Path to the example within the repo (use when the branch name contains slashes).").addHelpText("after",`\nExamples:\n $ npx @lukoweb/create-apitogo@latest\n $ npx @lukoweb/create-apitogo@latest dev-portal --typescript --eslint\n $ npx @lukoweb/create-apitogo@latest dev-portal --javascript --no-eslint\n $ npx @lukoweb/create-apitogo@latest dev-portal --typescript --eslint --no-include-examples\n`).action((t=>{if(t&&!t.startsWith("--no-")){Sc=t}})).allowUnknownOption().parse(process.argv);const Ac=Pc.opts();const{args:Oc}=Pc;const Rc=Ac.useNpm?"npm":Ac.usePnpm?"pnpm":Ac.useYarn?"yarn":Ac.useBun?"bun":getPkgManager();async function run(){const p=new Conf({projectName:"@lukoweb/create-apitogo"});if(Ac.resetPreferences){const{resetPreferences:t}=await tt()({onState:onPromptState,type:"toggle",name:"resetPreferences",message:"Would you like to reset the saved preferences?",initial:false,active:"Yes",inactive:"No"});if(t){p.clear();console.log("The preferences have been reset successfully!")}process.exit(0)}const m=g().isCI||Ac.yes;const y=!Oc.includes("--no-include-examples")&&Ac.includeExamples!==false;const v=Oc.includes("--no-eslint");if(typeof Sc==="string"){Sc=Sc.trim()}if(!Sc){if(m){Sc="dev-portal"}else{const t=await tt()({onState:onPromptState,type:"text",name:"path",message:"What is your project named?",initial:"dev-portal",validate:t=>{const p=validateNpmName((0,u.basename)((0,u.resolve)(t)));if(p.valid){return true}return`Invalid project name: ${p.problems[0]}`}});if(typeof t.path==="string"){Sc=t.path.trim()}}}if(!Sc){console.log("\nPlease specify the project directory:\n"+` ${(0,Qe.cyan)(Ac.name())} ${(0,Qe.green)("<project-directory>")}\n`+"For example:\n"+` ${(0,Qe.cyan)(Ac.name())} ${(0,Qe.green)("my-zudoku-app")}\n\n`+`Run ${(0,Qe.cyan)(`${Ac.name()} --help`)} to see all options.`);process.exit(1)}const b=(0,u.resolve)(Sc);const w=(0,u.basename)(b);const E=validateNpmName(w);if(!E.valid){console.error(`Could not create a project called ${(0,Qe.red)(`"${w}"`)} because of npm naming restrictions:`);E.problems.forEach((t=>console.error(` ${(0,Qe.red)((0,Qe.bold)("*"))} ${t}`)));process.exit(1)}if(Ac.example===true){console.error("Please provide an example name or url, otherwise remove the example option.");process.exit(1)}if((0,t.existsSync)(b)&&!isFolderEmpty(b,w)){process.exit(1)}const $=typeof Ac.example==="string"&&Ac.example.trim();const P=p.get("preferences")||{};if(!$){const t={typescript:true,eslint:true};const getPrefOrDefault=u=>{var p;return(p=P[u])!==null&&p!==void 0?p:t[u]};if(!Ac.typescript&&!Ac.javascript){if(m){Ac.typescript=getPrefOrDefault("typescript")}else{const t=(0,Qe.blue)("TypeScript");const{typescript:u}=await tt()({type:"toggle",name:"typescript",message:`Would you like to use ${t}?`,initial:getPrefOrDefault("typescript"),active:"Yes",inactive:"No"},{onCancel:()=>{console.error("Exiting.");process.exit(1)}});Ac.typescript=Boolean(u);Ac.javascript=!u;P.typescript=Boolean(u)}}if(v){Ac.eslint=false}else if(!Ac.eslint){if(m){Ac.eslint=getPrefOrDefault("eslint")}else{const t=(0,Qe.blue)("ESLint");const{eslint:u}=await tt()({onState:onPromptState,type:"toggle",name:"eslint",message:`Would you like to use ${t}?`,initial:getPrefOrDefault("eslint"),active:"Yes",inactive:"No"});Ac.eslint=Boolean(u);P.eslint=Boolean(u)}}}try{await createApp({appPath:b,packageManager:Rc,example:$&&$!=="default"?$:undefined,examplePath:Ac.examplePath,typescript:Ac.typescript,eslint:Ac.eslint,skipInstall:Ac.skipInstall,zudokuVersion:$c.version,withExamples:y})}catch(t){if(!(t instanceof DownloadError)){throw t}const u=await tt()({onState:onPromptState,type:"confirm",name:"builtin",message:`Could not download "${$}" 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:b,packageManager:Rc,typescript:Ac.typescript,eslint:Ac.eslint,skipInstall:Ac.skipInstall,zudokuVersion:$c.version,withExamples:true})}p.set("preferences",P)}const xc=st()($c).catch((()=>null));async function notifyUpdate(){var t;try{if((t=await xc)===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[Rc]} @lukoweb/create-apitogo`;console.log((0,Qe.yellow)((0,Qe.bold)("A new version of `@lukoweb/create-apitogo` 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)}console.log();await notifyUpdate();process.exit(1)}run().then(notifyUpdate).catch(exit)})();module.exports=p})();
|